auvitekvar.h revision 1.2 1 /* $NetBSD: auvitekvar.h,v 1.2 2010/12/28 04:02:33 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_850,
47 AUVITEK_BOARD_HVR_950Q,
48 };
49
50 #define AUVITEK_NXFERS 8
51 #define AUVITEK_XFER_ALTNO 5
52
53 struct auvitek_isoc {
54 struct auvitek_xfer *i_ax;
55 usbd_xfer_handle i_xfer;
56 uint8_t *i_buf;
57 uint16_t *i_frlengths;
58 };
59
60 struct auvitek_videobuf {
61 uint8_t av_buf[720*480*2];
62 uint32_t av_el, av_eb;
63 uint32_t av_ol, av_ob;
64 uint32_t av_stride;
65 };
66
67 struct auvitek_xfer {
68 struct auvitek_softc *ax_sc;
69 int ax_endpt;
70 uint16_t ax_maxpktlen;
71 usbd_pipe_handle ax_pipe;
72 struct auvitek_isoc ax_i[AUVITEK_NXFERS];
73 uint32_t ax_nframes;
74 uint32_t ax_uframe_len;
75 uint8_t ax_frinfo;
76 int ax_frno;
77 struct auvitek_videobuf ax_av;
78 };
79
80 struct auvitek_softc {
81 device_t sc_dev;
82 device_t sc_videodev, sc_audiodev;
83 struct i2c_controller sc_i2c;
84 kmutex_t sc_i2c_lock;
85
86 usbd_device_handle sc_udev;
87 int sc_uport;
88 usbd_interface_handle sc_iface;
89
90 char sc_running;
91 char sc_dying;
92
93 enum auvitek_board sc_board;
94 const char *sc_descr;
95 uint8_t sc_i2c_clkdiv;
96
97 struct au8522 *sc_au8522;
98 struct xc5k *sc_xc5k;
99 kmutex_t sc_subdev_lock;
100
101 unsigned int sc_ainput, sc_vinput;
102 uint32_t sc_curfreq;
103
104 struct auvitek_xfer sc_ax;
105
106 char sc_businfo[32];
107 };
108
109 /* auvitek.c */
110 uint8_t auvitek_read_1(struct auvitek_softc *, uint16_t);
111 void auvitek_write_1(struct auvitek_softc *, uint16_t, uint8_t);
112
113 /* auvitek_audio.c */
114 int auvitek_audio_attach(struct auvitek_softc *);
115 int auvitek_audio_detach(struct auvitek_softc *, int);
116 void auvitek_audio_childdet(struct auvitek_softc *, device_t);
117
118 /* auvitek_board.c */
119 void auvitek_board_init(struct auvitek_softc *);
120 int auvitek_board_tuner_reset(struct auvitek_softc *);
121
122 /* auvitek_i2c.c */
123 int auvitek_i2c_attach(struct auvitek_softc *);
124 int auvitek_i2c_detach(struct auvitek_softc *, int);
125
126 /* auvitek_video.c */
127 int auvitek_video_attach(struct auvitek_softc *);
128 int auvitek_video_detach(struct auvitek_softc *, int);
129 void auvitek_video_childdet(struct auvitek_softc *, device_t);
130
131 #endif /* !_AUVITEKVAR_H */
132