Home | History | Annotate | Line # | Download | only in usb
emdtvvar.h revision 1.3.14.1
      1  1.3.14.1  jdolecek /* $NetBSD: emdtvvar.h,v 1.3.14.1 2017/12/03 11:37:33 jdolecek Exp $ */
      2       1.1  jmcneill 
      3       1.1  jmcneill /*-
      4       1.1  jmcneill  * Copyright (c) 2008 Jared D. McNeill <jmcneill (at) invisible.ca>
      5       1.1  jmcneill  * All rights reserved.
      6       1.1  jmcneill  *
      7       1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      8       1.1  jmcneill  * modification, are permitted provided that the following conditions
      9       1.1  jmcneill  * are met:
     10       1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     11       1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     12       1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14       1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15       1.1  jmcneill  *
     16       1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17       1.1  jmcneill  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18       1.1  jmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19       1.1  jmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20       1.1  jmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21       1.1  jmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22       1.1  jmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23       1.1  jmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24       1.1  jmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25       1.1  jmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26       1.1  jmcneill  * POSSIBILITY OF SUCH DAMAGE.
     27       1.1  jmcneill  */
     28       1.1  jmcneill 
     29       1.1  jmcneill #ifndef _DEV_USB_EMDTVVAR_H
     30       1.1  jmcneill #define _DEV_USB_EMDTVVAR_H
     31       1.1  jmcneill 
     32       1.1  jmcneill #include <sys/mutex.h>
     33       1.1  jmcneill #include <sys/condvar.h>
     34       1.1  jmcneill #include <sys/workqueue.h>
     35       1.1  jmcneill 
     36       1.1  jmcneill #include <dev/usb/usb.h>
     37       1.1  jmcneill #include <dev/usb/usbdi.h>
     38       1.1  jmcneill 
     39       1.1  jmcneill #include <dev/usb/emdtv_board.h>
     40       1.1  jmcneill 
     41       1.1  jmcneill #include <dev/i2c/i2cvar.h>
     42       1.1  jmcneill #include <dev/dtv/dtvif.h>
     43       1.1  jmcneill 
     44       1.1  jmcneill #include <dev/i2c/lg3303var.h>
     45       1.1  jmcneill #include <dev/i2c/xc3028var.h>
     46       1.1  jmcneill 
     47       1.1  jmcneill #define EMDTV_EEPROM_LEN	256
     48       1.1  jmcneill 
     49       1.1  jmcneill #define EMDTV_NXFERS		6
     50       1.1  jmcneill #define EMDTV_NFRAMES		64
     51       1.1  jmcneill 
     52       1.1  jmcneill #define EMDTV_CIR_BUFLEN	32
     53       1.1  jmcneill 
     54       1.1  jmcneill struct emdtv_softc;
     55       1.1  jmcneill 
     56       1.1  jmcneill struct emdtv_isoc_xfer {
     57       1.1  jmcneill 	struct emdtv_softc	*ix_sc;
     58  1.3.14.1  jdolecek 	struct usbd_xfer	*ix_xfer;
     59       1.1  jmcneill 	uint8_t			*ix_buf;
     60       1.1  jmcneill 	uint16_t		ix_frlengths[EMDTV_NFRAMES];
     61       1.1  jmcneill 	struct emdtv_isoc_xfer	*ix_altix;
     62       1.1  jmcneill };
     63       1.1  jmcneill 
     64       1.1  jmcneill struct emdtv_softc {
     65       1.1  jmcneill 	device_t		sc_dev;
     66  1.3.14.1  jdolecek 	struct usbd_device	*sc_udev;
     67       1.1  jmcneill 
     68       1.1  jmcneill 	device_t		sc_cirdev;
     69       1.1  jmcneill 	device_t		sc_dtvdev;
     70       1.1  jmcneill 
     71       1.1  jmcneill 	uint16_t		sc_vendor, sc_product;
     72       1.1  jmcneill 
     73       1.1  jmcneill 	const struct emdtv_board *sc_board;
     74       1.1  jmcneill 
     75       1.1  jmcneill 	struct lg3303		*sc_lg3303;
     76       1.1  jmcneill 	struct xc3028		*sc_xc3028;
     77       1.1  jmcneill 
     78       1.1  jmcneill 	struct i2c_controller	sc_i2c;
     79       1.1  jmcneill 	kmutex_t		sc_i2c_lock;
     80       1.1  jmcneill 
     81       1.1  jmcneill 	uint8_t			sc_eeprom[EMDTV_EEPROM_LEN];
     82       1.1  jmcneill 
     83  1.3.14.1  jdolecek 	struct usbd_interface	*sc_iface;
     84       1.1  jmcneill 
     85  1.3.14.1  jdolecek 	struct usbd_pipe	*sc_isoc_pipe;
     86       1.1  jmcneill 	int			sc_isoc_buflen;
     87       1.1  jmcneill 	int			sc_isoc_maxpacketsize;
     88       1.1  jmcneill 	struct emdtv_isoc_xfer	sc_ix[EMDTV_NXFERS];
     89       1.1  jmcneill 
     90  1.3.14.1  jdolecek 	struct usbd_pipe	*sc_intr_pipe;
     91       1.1  jmcneill 	uint8_t			sc_intr_buf;
     92       1.1  jmcneill 	struct workqueue	*sc_ir_wq;
     93       1.1  jmcneill 	struct work		sc_ir_work;
     94       1.1  jmcneill 	uint8_t			sc_ir_keyid;
     95       1.1  jmcneill 
     96       1.1  jmcneill 	kmutex_t		sc_ir_mutex;
     97       1.1  jmcneill 	uint8_t			sc_ir_queue[EMDTV_CIR_BUFLEN][3];
     98       1.1  jmcneill 	int			sc_ir_cnt;
     99       1.1  jmcneill 	int			sc_ir_ptr;
    100       1.1  jmcneill 	bool			sc_ir_open;
    101       1.1  jmcneill 
    102       1.1  jmcneill 	uint32_t		sc_frequency;
    103       1.1  jmcneill 
    104       1.1  jmcneill 	bool			sc_streaming;
    105       1.3  jmcneill 	void			(*sc_dtvsubmitcb)(void *,
    106       1.3  jmcneill 				    const struct dtv_payload *);
    107       1.3  jmcneill 	void			*sc_dtvsubmitarg;
    108       1.1  jmcneill 
    109       1.1  jmcneill 	bool			sc_dying;
    110       1.1  jmcneill };
    111       1.1  jmcneill 
    112       1.1  jmcneill void	emdtv_dtv_attach(struct emdtv_softc *);
    113       1.1  jmcneill void	emdtv_dtv_detach(struct emdtv_softc *, int);
    114       1.3  jmcneill void	emdtv_dtv_rescan(struct emdtv_softc *, const char *, const int *);
    115       1.1  jmcneill void	emdtv_ir_attach(struct emdtv_softc *);
    116       1.1  jmcneill void	emdtv_ir_detach(struct emdtv_softc *, int);
    117       1.1  jmcneill int	emdtv_i2c_attach(struct emdtv_softc *);
    118       1.1  jmcneill int	emdtv_i2c_detach(struct emdtv_softc *, int);
    119       1.1  jmcneill 
    120       1.1  jmcneill uint8_t	emdtv_read_1(struct emdtv_softc *, uint8_t, uint16_t);
    121       1.1  jmcneill void	emdtv_read_multi_1(struct emdtv_softc *, uint8_t, uint16_t,
    122       1.1  jmcneill 			   uint8_t *, uint16_t);
    123       1.1  jmcneill void	emdtv_write_1(struct emdtv_softc *, uint8_t, uint16_t, uint8_t);
    124       1.1  jmcneill void	emdtv_write_multi_1(struct emdtv_softc *, uint8_t, uint16_t,
    125       1.1  jmcneill 			    const uint8_t *, uint16_t);
    126       1.1  jmcneill 
    127       1.1  jmcneill bool	emdtv_gpio_ctl(struct emdtv_softc *, emdtv_gpio_reg_t, bool);
    128       1.1  jmcneill 
    129       1.1  jmcneill #endif /* !_DEV_USB_EMDTVVAR_H */
    130