Home | History | Annotate | Line # | Download | only in usb
auvitekvar.h revision 1.1
      1 /* $NetBSD: auvitekvar.h,v 1.1 2010/12/27 15:42:11 jmcneill Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2010 Jared D. McNeill <jmcneill (at) invisible.ca>
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  */
     28 
     29 #ifndef _AUVITEKVAR_H
     30 #define _AUVITEKVAR_H
     31 
     32 #include <sys/mutex.h>
     33 
     34 #include <dev/usb/usb.h>
     35 #include <dev/usb/usbdi.h>
     36 #include <dev/usb/usbdi_util.h>
     37 #include <dev/i2c/i2cvar.h>
     38 
     39 #include <dev/i2c/au8522var.h>
     40 #include <dev/i2c/xc5kvar.h>
     41 #include <dev/i2c/xc5kreg.h>
     42 
     43 struct auvitek_softc;
     44 
     45 enum auvitek_board {
     46 	AUVITEK_BOARD_HVR_950Q,
     47 };
     48 
     49 #define	AUVITEK_NXFERS		8
     50 #define AUVITEK_XFER_ALTNO	5
     51 
     52 struct auvitek_isoc {
     53 	struct auvitek_xfer	*i_ax;
     54 	usbd_xfer_handle	i_xfer;
     55 	uint8_t			*i_buf;
     56 	uint16_t		*i_frlengths;
     57 };
     58 
     59 struct auvitek_videobuf {
     60 	uint8_t			av_buf[720*480*2];
     61 	uint32_t		av_el, av_eb;
     62 	uint32_t		av_ol, av_ob;
     63 	uint32_t		av_stride;
     64 };
     65 
     66 struct auvitek_xfer {
     67 	struct auvitek_softc	*ax_sc;
     68 	int			ax_endpt;
     69 	uint16_t		ax_maxpktlen;
     70 	usbd_pipe_handle	ax_pipe;
     71 	struct auvitek_isoc	ax_i[AUVITEK_NXFERS];
     72 	uint32_t		ax_nframes;
     73 	uint32_t		ax_uframe_len;
     74 	uint8_t			ax_frinfo;
     75 	int			ax_frno;
     76 	struct auvitek_videobuf	ax_av;
     77 };
     78 
     79 struct auvitek_softc {
     80 	device_t		sc_dev;
     81 	device_t		sc_videodev, sc_audiodev;
     82 	struct i2c_controller	sc_i2c;
     83 	kmutex_t		sc_i2c_lock;
     84 
     85 	usbd_device_handle	sc_udev;
     86 	int			sc_uport;
     87 	usbd_interface_handle	sc_iface;
     88 
     89 	char			sc_running;
     90 	char			sc_dying;
     91 
     92 	enum auvitek_board	sc_board;
     93 	const char		*sc_descr;
     94 	uint8_t			sc_i2c_clkdiv;
     95 
     96 	struct au8522		*sc_au8522;
     97 	struct xc5k		*sc_xc5k;
     98 	kmutex_t		sc_subdev_lock;
     99 
    100 	unsigned int		sc_ainput, sc_vinput;
    101 	uint32_t		sc_curfreq;
    102 
    103 	struct auvitek_xfer	sc_ax;
    104 
    105 	char			sc_businfo[32];
    106 };
    107 
    108 /* auvitek.c */
    109 uint8_t	auvitek_read_1(struct auvitek_softc *, uint16_t);
    110 void	auvitek_write_1(struct auvitek_softc *, uint16_t, uint8_t);
    111 
    112 /* auvitek_audio.c */
    113 int	auvitek_audio_attach(struct auvitek_softc *);
    114 int	auvitek_audio_detach(struct auvitek_softc *, int);
    115 void	auvitek_audio_childdet(struct auvitek_softc *, device_t);
    116 
    117 /* auvitek_board.c */
    118 void	auvitek_board_init(struct auvitek_softc *);
    119 int	auvitek_board_tuner_reset(struct auvitek_softc *);
    120 
    121 /* auvitek_i2c.c */
    122 int	auvitek_i2c_attach(struct auvitek_softc *);
    123 int	auvitek_i2c_detach(struct auvitek_softc *, int);
    124 
    125 /* auvitek_video.c */
    126 int	auvitek_video_attach(struct auvitek_softc *);
    127 int	auvitek_video_detach(struct auvitek_softc *, int);
    128 void	auvitek_video_childdet(struct auvitek_softc *, device_t);
    129 
    130 #endif /* !_AUVITEKVAR_H */
    131