1 | /* $NetBSD: auvitekvar.h,v 1.9 2016/04/23 10:15:31 skrll Exp $ */ |
2 | |
3 | /*- |
4 | * Copyright (c) 2010 Jared D. McNeill <jmcneill@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 | #include <sys/condvar.h> |
34 | #include <sys/kthread.h> |
35 | |
36 | #include <dev/dtv/dtvif.h> |
37 | |
38 | #include <dev/usb/usb.h> |
39 | #include <dev/usb/usbdi.h> |
40 | #include <dev/usb/usbdi_util.h> |
41 | #include <dev/i2c/i2cvar.h> |
42 | |
43 | #include <dev/i2c/au8522var.h> |
44 | #include <dev/i2c/xc5kvar.h> |
45 | #include <dev/i2c/xc5kreg.h> |
46 | |
47 | struct auvitek_softc; |
48 | |
49 | enum auvitek_board { |
50 | AUVITEK_BOARD_HVR_850, |
51 | AUVITEK_BOARD_HVR_950Q, |
52 | }; |
53 | |
54 | #define AUVITEK_NISOC_XFERS 16 |
55 | #define AUVITEK_NBULK_XFERS 1 |
56 | #define AUVITEK_XFER_ALTNO 5 |
57 | #define AUVITEK_BULK_BUFLEN 58658 /* BDA driver uses the same */ |
58 | |
59 | struct auvitek_isoc { |
60 | struct auvitek_xfer *i_ax; |
61 | struct usbd_xfer *i_xfer; |
62 | uint8_t *i_buf; |
63 | uint16_t *i_frlengths; |
64 | }; |
65 | |
66 | struct auvitek_videobuf { |
67 | uint8_t av_buf[720*480*2]; |
68 | uint32_t av_el, av_eb; |
69 | uint32_t av_ol, av_ob; |
70 | uint32_t av_stride; |
71 | }; |
72 | |
73 | struct auvitek_xfer { |
74 | struct auvitek_softc *ax_sc; |
75 | int ax_endpt; |
76 | uint16_t ax_maxpktlen; |
77 | struct usbd_pipe * ax_pipe; |
78 | struct auvitek_isoc ax_i[AUVITEK_NISOC_XFERS]; |
79 | uint32_t ax_nframes; |
80 | uint32_t ax_uframe_len; |
81 | uint8_t ax_frinfo; |
82 | int ax_frno; |
83 | struct auvitek_videobuf ax_av; |
84 | }; |
85 | |
86 | struct auvitek_bulk_xfer { |
87 | struct auvitek_softc *bx_sc; |
88 | struct usbd_xfer *bx_xfer; |
89 | uint8_t *bx_buffer; |
90 | }; |
91 | |
92 | struct auvitek_bulk { |
93 | struct auvitek_softc *ab_sc; |
94 | int ab_endpt; |
95 | struct usbd_pipe *ab_pipe; |
96 | struct auvitek_bulk_xfer ab_bx[AUVITEK_NBULK_XFERS]; |
97 | bool ab_running; |
98 | }; |
99 | |
100 | struct auvitek_softc { |
101 | device_t sc_dev; |
102 | device_t sc_videodev, sc_dtvdev, sc_audiodev, sc_i2cdev; |
103 | struct i2c_controller sc_i2c; |
104 | kmutex_t sc_i2c_lock; |
105 | |
106 | struct usbd_device *sc_udev; |
107 | int sc_uport; |
108 | struct usbd_interface *sc_isoc_iface; |
109 | struct usbd_interface *sc_bulk_iface; |
110 | |
111 | char sc_running; |
112 | char sc_dying; |
113 | |
114 | enum auvitek_board sc_board; |
115 | const char *sc_descr; |
116 | uint8_t sc_i2c_clkdiv; |
117 | |
118 | struct au8522 *sc_au8522; |
119 | struct xc5k *sc_xc5k; |
120 | kmutex_t sc_subdev_lock; |
121 | |
122 | unsigned int sc_ainput, sc_vinput; |
123 | uint32_t sc_curfreq; |
124 | void (*sc_dtvsubmitcb)(void *, |
125 | const struct dtv_payload *); |
126 | void *sc_dtvsubmitarg; |
127 | |
128 | struct auvitek_xfer sc_ax; |
129 | struct auvitek_bulk sc_ab; |
130 | |
131 | char sc_businfo[32]; |
132 | }; |
133 | |
134 | /* auvitek.c */ |
135 | uint8_t auvitek_read_1(struct auvitek_softc *, uint16_t); |
136 | void auvitek_write_1(struct auvitek_softc *, uint16_t, uint8_t); |
137 | void auvitek_attach_tuner(device_t); |
138 | |
139 | /* auvitek_audio.c */ |
140 | int auvitek_audio_attach(struct auvitek_softc *); |
141 | int auvitek_audio_detach(struct auvitek_softc *, int); |
142 | void auvitek_audio_childdet(struct auvitek_softc *, device_t); |
143 | |
144 | /* auvitek_board.c */ |
145 | void auvitek_board_init(struct auvitek_softc *); |
146 | int auvitek_board_tuner_reset(void *); |
147 | unsigned int auvitek_board_get_if_frequency(struct auvitek_softc *); |
148 | |
149 | /* auvitek_i2c.c */ |
150 | int auvitek_i2c_attach(struct auvitek_softc *); |
151 | int auvitek_i2c_detach(struct auvitek_softc *, int); |
152 | void auvitek_i2c_rescan(struct auvitek_softc *, const char *, const int *); |
153 | void auvitek_i2c_childdet(struct auvitek_softc *, device_t); |
154 | |
155 | /* auvitek_video.c */ |
156 | int auvitek_video_attach(struct auvitek_softc *); |
157 | int auvitek_video_detach(struct auvitek_softc *, int); |
158 | void auvitek_video_rescan(struct auvitek_softc *, const char *, const int *); |
159 | void auvitek_video_childdet(struct auvitek_softc *, device_t); |
160 | |
161 | /* auvitek_dtv.c */ |
162 | int auvitek_dtv_attach(struct auvitek_softc *); |
163 | int auvitek_dtv_detach(struct auvitek_softc *, int); |
164 | void auvitek_dtv_rescan(struct auvitek_softc *, const char *, const int *); |
165 | void auvitek_dtv_childdet(struct auvitek_softc *, device_t); |
166 | |
167 | #endif /* !_AUVITEKVAR_H */ |
168 | |