diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-13 23:13:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-15 15:25:07 -0400 |
commit | 0c0d06cac63ee327ceaab4b5ffe2206574ab86bd (patch) | |
tree | e759f0dc3185d97f2a0c6b5cd5e32ea6faa74d40 /drivers/media/usb/cx231xx | |
parent | 84cfe9e79bd5ac11c963f4841158454fefa872f6 (diff) |
[media] rename most media/video usb drivers to media/usb
Rename all USB drivers with their own directory under
drivers/media/video into drivers/media/usb and update the
building system.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/cx231xx')
19 files changed, 21403 insertions, 0 deletions
diff --git a/drivers/media/usb/cx231xx/Kconfig b/drivers/media/usb/cx231xx/Kconfig new file mode 100644 index 000000000000..446f692aabb7 --- /dev/null +++ b/drivers/media/usb/cx231xx/Kconfig | |||
@@ -0,0 +1,51 @@ | |||
1 | config VIDEO_CX231XX | ||
2 | tristate "Conexant cx231xx USB video capture support" | ||
3 | depends on VIDEO_DEV && I2C | ||
4 | select VIDEO_TUNER | ||
5 | select VIDEO_TVEEPROM | ||
6 | depends on RC_CORE | ||
7 | select VIDEOBUF_VMALLOC | ||
8 | select VIDEO_CX25840 | ||
9 | select VIDEO_CX2341X | ||
10 | |||
11 | ---help--- | ||
12 | This is a video4linux driver for Conexant 231xx USB based TV cards. | ||
13 | |||
14 | To compile this driver as a module, choose M here: the | ||
15 | module will be called cx231xx | ||
16 | |||
17 | config VIDEO_CX231XX_RC | ||
18 | bool "Conexant cx231xx Remote Controller additional support" | ||
19 | depends on RC_CORE | ||
20 | depends on VIDEO_CX231XX | ||
21 | default y | ||
22 | ---help--- | ||
23 | cx231xx hardware has a builtin RX/TX support. However, a few | ||
24 | designs opted to not use it, but, instead, some other hardware. | ||
25 | This module enables the usage of those other hardware, like the | ||
26 | ones used with ISDB-T boards. | ||
27 | |||
28 | On most cases, all you need for IR is mceusb module. | ||
29 | |||
30 | config VIDEO_CX231XX_ALSA | ||
31 | tristate "Conexant Cx231xx ALSA audio module" | ||
32 | depends on VIDEO_CX231XX && SND | ||
33 | select SND_PCM | ||
34 | |||
35 | ---help--- | ||
36 | This is an ALSA driver for Cx231xx USB based TV cards. | ||
37 | |||
38 | To compile this driver as a module, choose M here: the | ||
39 | module will be called cx231xx-alsa | ||
40 | |||
41 | config VIDEO_CX231XX_DVB | ||
42 | tristate "DVB/ATSC Support for Cx231xx based TV cards" | ||
43 | depends on VIDEO_CX231XX && DVB_CORE && DVB_CAPTURE_DRIVERS | ||
44 | select VIDEOBUF_DVB | ||
45 | select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMISE | ||
46 | select MEDIA_TUNER_TDA18271 if !MEDIA_TUNER_CUSTOMISE | ||
47 | select DVB_MB86A20S if !DVB_FE_CUSTOMISE | ||
48 | |||
49 | ---help--- | ||
50 | This adds support for DVB cards based on the | ||
51 | Conexant cx231xx chips. | ||
diff --git a/drivers/media/usb/cx231xx/Makefile b/drivers/media/usb/cx231xx/Makefile new file mode 100644 index 000000000000..1d40fce77601 --- /dev/null +++ b/drivers/media/usb/cx231xx/Makefile | |||
@@ -0,0 +1,15 @@ | |||
1 | cx231xx-y += cx231xx-video.o cx231xx-i2c.o cx231xx-cards.o cx231xx-core.o | ||
2 | cx231xx-y += cx231xx-avcore.o cx231xx-417.o cx231xx-pcb-cfg.o cx231xx-vbi.o | ||
3 | cx231xx-$(CONFIG_VIDEO_CX231XX_RC) += cx231xx-input.o | ||
4 | |||
5 | cx231xx-alsa-objs := cx231xx-audio.o | ||
6 | |||
7 | obj-$(CONFIG_VIDEO_CX231XX) += cx231xx.o | ||
8 | obj-$(CONFIG_VIDEO_CX231XX_ALSA) += cx231xx-alsa.o | ||
9 | obj-$(CONFIG_VIDEO_CX231XX_DVB) += cx231xx-dvb.o | ||
10 | |||
11 | ccflags-y += -Idrivers/media/video | ||
12 | ccflags-y += -Idrivers/media/tuners | ||
13 | ccflags-y += -Idrivers/media/dvb-core | ||
14 | ccflags-y += -Idrivers/media/dvb-frontends | ||
15 | ccflags-y += -Idrivers/media/usb/dvb-usb | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-417.c b/drivers/media/usb/cx231xx/cx231xx-417.c new file mode 100644 index 000000000000..b024e5197a75 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-417.c | |||
@@ -0,0 +1,2197 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Support for a cx23417 mpeg encoder via cx231xx host port. | ||
4 | * | ||
5 | * (c) 2004 Jelle Foks <jelle@foks.us> | ||
6 | * (c) 2004 Gerd Knorr <kraxel@bytesex.org> | ||
7 | * (c) 2008 Steven Toth <stoth@linuxtv.org> | ||
8 | * - CX23885/7/8 support | ||
9 | * | ||
10 | * Includes parts from the ivtv driver( http://ivtv.sourceforge.net/), | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | ||
26 | |||
27 | #include <linux/module.h> | ||
28 | #include <linux/moduleparam.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/fs.h> | ||
31 | #include <linux/delay.h> | ||
32 | #include <linux/device.h> | ||
33 | #include <linux/firmware.h> | ||
34 | #include <linux/vmalloc.h> | ||
35 | #include <media/v4l2-common.h> | ||
36 | #include <media/v4l2-ioctl.h> | ||
37 | #include <media/cx2341x.h> | ||
38 | #include <linux/usb.h> | ||
39 | |||
40 | #include "cx231xx.h" | ||
41 | /*#include "cx23885-ioctl.h"*/ | ||
42 | |||
43 | #define CX231xx_FIRM_IMAGE_SIZE 376836 | ||
44 | #define CX231xx_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw" | ||
45 | |||
46 | /* for polaris ITVC */ | ||
47 | #define ITVC_WRITE_DIR 0x03FDFC00 | ||
48 | #define ITVC_READ_DIR 0x0001FC00 | ||
49 | |||
50 | #define MCI_MEMORY_DATA_BYTE0 0x00 | ||
51 | #define MCI_MEMORY_DATA_BYTE1 0x08 | ||
52 | #define MCI_MEMORY_DATA_BYTE2 0x10 | ||
53 | #define MCI_MEMORY_DATA_BYTE3 0x18 | ||
54 | |||
55 | #define MCI_MEMORY_ADDRESS_BYTE2 0x20 | ||
56 | #define MCI_MEMORY_ADDRESS_BYTE1 0x28 | ||
57 | #define MCI_MEMORY_ADDRESS_BYTE0 0x30 | ||
58 | |||
59 | #define MCI_REGISTER_DATA_BYTE0 0x40 | ||
60 | #define MCI_REGISTER_DATA_BYTE1 0x48 | ||
61 | #define MCI_REGISTER_DATA_BYTE2 0x50 | ||
62 | #define MCI_REGISTER_DATA_BYTE3 0x58 | ||
63 | |||
64 | #define MCI_REGISTER_ADDRESS_BYTE0 0x60 | ||
65 | #define MCI_REGISTER_ADDRESS_BYTE1 0x68 | ||
66 | |||
67 | #define MCI_REGISTER_MODE 0x70 | ||
68 | |||
69 | /* Read and write modes for polaris ITVC */ | ||
70 | #define MCI_MODE_REGISTER_READ 0x000 | ||
71 | #define MCI_MODE_REGISTER_WRITE 0x100 | ||
72 | #define MCI_MODE_MEMORY_READ 0x000 | ||
73 | #define MCI_MODE_MEMORY_WRITE 0x4000 | ||
74 | |||
75 | static unsigned int mpegbufs = 8; | ||
76 | module_param(mpegbufs, int, 0644); | ||
77 | MODULE_PARM_DESC(mpegbufs, "number of mpeg buffers, range 2-32"); | ||
78 | static unsigned int mpeglines = 128; | ||
79 | module_param(mpeglines, int, 0644); | ||
80 | MODULE_PARM_DESC(mpeglines, "number of lines in an MPEG buffer, range 2-32"); | ||
81 | static unsigned int mpeglinesize = 512; | ||
82 | module_param(mpeglinesize, int, 0644); | ||
83 | MODULE_PARM_DESC(mpeglinesize, | ||
84 | "number of bytes in each line of an MPEG buffer, range 512-1024"); | ||
85 | |||
86 | static unsigned int v4l_debug = 1; | ||
87 | module_param(v4l_debug, int, 0644); | ||
88 | MODULE_PARM_DESC(v4l_debug, "enable V4L debug messages"); | ||
89 | struct cx231xx_dmaqueue *dma_qq; | ||
90 | #define dprintk(level, fmt, arg...)\ | ||
91 | do { if (v4l_debug >= level) \ | ||
92 | printk(KERN_INFO "%s: " fmt, \ | ||
93 | (dev) ? dev->name : "cx231xx[?]", ## arg); \ | ||
94 | } while (0) | ||
95 | |||
96 | static struct cx231xx_tvnorm cx231xx_tvnorms[] = { | ||
97 | { | ||
98 | .name = "NTSC-M", | ||
99 | .id = V4L2_STD_NTSC_M, | ||
100 | }, { | ||
101 | .name = "NTSC-JP", | ||
102 | .id = V4L2_STD_NTSC_M_JP, | ||
103 | }, { | ||
104 | .name = "PAL-BG", | ||
105 | .id = V4L2_STD_PAL_BG, | ||
106 | }, { | ||
107 | .name = "PAL-DK", | ||
108 | .id = V4L2_STD_PAL_DK, | ||
109 | }, { | ||
110 | .name = "PAL-I", | ||
111 | .id = V4L2_STD_PAL_I, | ||
112 | }, { | ||
113 | .name = "PAL-M", | ||
114 | .id = V4L2_STD_PAL_M, | ||
115 | }, { | ||
116 | .name = "PAL-N", | ||
117 | .id = V4L2_STD_PAL_N, | ||
118 | }, { | ||
119 | .name = "PAL-Nc", | ||
120 | .id = V4L2_STD_PAL_Nc, | ||
121 | }, { | ||
122 | .name = "PAL-60", | ||
123 | .id = V4L2_STD_PAL_60, | ||
124 | }, { | ||
125 | .name = "SECAM-L", | ||
126 | .id = V4L2_STD_SECAM_L, | ||
127 | }, { | ||
128 | .name = "SECAM-DK", | ||
129 | .id = V4L2_STD_SECAM_DK, | ||
130 | } | ||
131 | }; | ||
132 | |||
133 | /* ------------------------------------------------------------------ */ | ||
134 | enum cx231xx_capture_type { | ||
135 | CX231xx_MPEG_CAPTURE, | ||
136 | CX231xx_RAW_CAPTURE, | ||
137 | CX231xx_RAW_PASSTHRU_CAPTURE | ||
138 | }; | ||
139 | enum cx231xx_capture_bits { | ||
140 | CX231xx_RAW_BITS_NONE = 0x00, | ||
141 | CX231xx_RAW_BITS_YUV_CAPTURE = 0x01, | ||
142 | CX231xx_RAW_BITS_PCM_CAPTURE = 0x02, | ||
143 | CX231xx_RAW_BITS_VBI_CAPTURE = 0x04, | ||
144 | CX231xx_RAW_BITS_PASSTHRU_CAPTURE = 0x08, | ||
145 | CX231xx_RAW_BITS_TO_HOST_CAPTURE = 0x10 | ||
146 | }; | ||
147 | enum cx231xx_capture_end { | ||
148 | CX231xx_END_AT_GOP, /* stop at the end of gop, generate irq */ | ||
149 | CX231xx_END_NOW, /* stop immediately, no irq */ | ||
150 | }; | ||
151 | enum cx231xx_framerate { | ||
152 | CX231xx_FRAMERATE_NTSC_30, /* NTSC: 30fps */ | ||
153 | CX231xx_FRAMERATE_PAL_25 /* PAL: 25fps */ | ||
154 | }; | ||
155 | enum cx231xx_stream_port { | ||
156 | CX231xx_OUTPUT_PORT_MEMORY, | ||
157 | CX231xx_OUTPUT_PORT_STREAMING, | ||
158 | CX231xx_OUTPUT_PORT_SERIAL | ||
159 | }; | ||
160 | enum cx231xx_data_xfer_status { | ||
161 | CX231xx_MORE_BUFFERS_FOLLOW, | ||
162 | CX231xx_LAST_BUFFER, | ||
163 | }; | ||
164 | enum cx231xx_picture_mask { | ||
165 | CX231xx_PICTURE_MASK_NONE, | ||
166 | CX231xx_PICTURE_MASK_I_FRAMES, | ||
167 | CX231xx_PICTURE_MASK_I_P_FRAMES = 0x3, | ||
168 | CX231xx_PICTURE_MASK_ALL_FRAMES = 0x7, | ||
169 | }; | ||
170 | enum cx231xx_vbi_mode_bits { | ||
171 | CX231xx_VBI_BITS_SLICED, | ||
172 | CX231xx_VBI_BITS_RAW, | ||
173 | }; | ||
174 | enum cx231xx_vbi_insertion_bits { | ||
175 | CX231xx_VBI_BITS_INSERT_IN_XTENSION_USR_DATA, | ||
176 | CX231xx_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1, | ||
177 | CX231xx_VBI_BITS_SEPARATE_STREAM = 0x2 << 1, | ||
178 | CX231xx_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1, | ||
179 | CX231xx_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1, | ||
180 | }; | ||
181 | enum cx231xx_dma_unit { | ||
182 | CX231xx_DMA_BYTES, | ||
183 | CX231xx_DMA_FRAMES, | ||
184 | }; | ||
185 | enum cx231xx_dma_transfer_status_bits { | ||
186 | CX231xx_DMA_TRANSFER_BITS_DONE = 0x01, | ||
187 | CX231xx_DMA_TRANSFER_BITS_ERROR = 0x04, | ||
188 | CX231xx_DMA_TRANSFER_BITS_LL_ERROR = 0x10, | ||
189 | }; | ||
190 | enum cx231xx_pause { | ||
191 | CX231xx_PAUSE_ENCODING, | ||
192 | CX231xx_RESUME_ENCODING, | ||
193 | }; | ||
194 | enum cx231xx_copyright { | ||
195 | CX231xx_COPYRIGHT_OFF, | ||
196 | CX231xx_COPYRIGHT_ON, | ||
197 | }; | ||
198 | enum cx231xx_notification_type { | ||
199 | CX231xx_NOTIFICATION_REFRESH, | ||
200 | }; | ||
201 | enum cx231xx_notification_status { | ||
202 | CX231xx_NOTIFICATION_OFF, | ||
203 | CX231xx_NOTIFICATION_ON, | ||
204 | }; | ||
205 | enum cx231xx_notification_mailbox { | ||
206 | CX231xx_NOTIFICATION_NO_MAILBOX = -1, | ||
207 | }; | ||
208 | enum cx231xx_field1_lines { | ||
209 | CX231xx_FIELD1_SAA7114 = 0x00EF, /* 239 */ | ||
210 | CX231xx_FIELD1_SAA7115 = 0x00F0, /* 240 */ | ||
211 | CX231xx_FIELD1_MICRONAS = 0x0105, /* 261 */ | ||
212 | }; | ||
213 | enum cx231xx_field2_lines { | ||
214 | CX231xx_FIELD2_SAA7114 = 0x00EF, /* 239 */ | ||
215 | CX231xx_FIELD2_SAA7115 = 0x00F0, /* 240 */ | ||
216 | CX231xx_FIELD2_MICRONAS = 0x0106, /* 262 */ | ||
217 | }; | ||
218 | enum cx231xx_custom_data_type { | ||
219 | CX231xx_CUSTOM_EXTENSION_USR_DATA, | ||
220 | CX231xx_CUSTOM_PRIVATE_PACKET, | ||
221 | }; | ||
222 | enum cx231xx_mute { | ||
223 | CX231xx_UNMUTE, | ||
224 | CX231xx_MUTE, | ||
225 | }; | ||
226 | enum cx231xx_mute_video_mask { | ||
227 | CX231xx_MUTE_VIDEO_V_MASK = 0x0000FF00, | ||
228 | CX231xx_MUTE_VIDEO_U_MASK = 0x00FF0000, | ||
229 | CX231xx_MUTE_VIDEO_Y_MASK = 0xFF000000, | ||
230 | }; | ||
231 | enum cx231xx_mute_video_shift { | ||
232 | CX231xx_MUTE_VIDEO_V_SHIFT = 8, | ||
233 | CX231xx_MUTE_VIDEO_U_SHIFT = 16, | ||
234 | CX231xx_MUTE_VIDEO_Y_SHIFT = 24, | ||
235 | }; | ||
236 | |||
237 | /* defines below are from ivtv-driver.h */ | ||
238 | #define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF | ||
239 | |||
240 | /* Firmware API commands */ | ||
241 | #define IVTV_API_STD_TIMEOUT 500 | ||
242 | |||
243 | /* Registers */ | ||
244 | /* IVTV_REG_OFFSET */ | ||
245 | #define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8) | ||
246 | #define IVTV_REG_ENC_SDRAM_PRECHARGE (0x07FC) | ||
247 | #define IVTV_REG_SPU (0x9050) | ||
248 | #define IVTV_REG_HW_BLOCKS (0x9054) | ||
249 | #define IVTV_REG_VPU (0x9058) | ||
250 | #define IVTV_REG_APU (0xA064) | ||
251 | |||
252 | /* | ||
253 | * Bit definitions for MC417_RWD and MC417_OEN registers | ||
254 | * | ||
255 | * bits 31-16 | ||
256 | *+-----------+ | ||
257 | *| Reserved | | ||
258 | *|+-----------+ | ||
259 | *| bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 | ||
260 | *|+-------+-------+-------+-------+-------+-------+-------+-------+ | ||
261 | *|| MIWR# | MIRD# | MICS# |MIRDY# |MIADDR3|MIADDR2|MIADDR1|MIADDR0| | ||
262 | *|+-------+-------+-------+-------+-------+-------+-------+-------+ | ||
263 | *| bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 | ||
264 | *|+-------+-------+-------+-------+-------+-------+-------+-------+ | ||
265 | *||MIDATA7|MIDATA6|MIDATA5|MIDATA4|MIDATA3|MIDATA2|MIDATA1|MIDATA0| | ||
266 | *|+-------+-------+-------+-------+-------+-------+-------+-------+ | ||
267 | */ | ||
268 | #define MC417_MIWR 0x8000 | ||
269 | #define MC417_MIRD 0x4000 | ||
270 | #define MC417_MICS 0x2000 | ||
271 | #define MC417_MIRDY 0x1000 | ||
272 | #define MC417_MIADDR 0x0F00 | ||
273 | #define MC417_MIDATA 0x00FF | ||
274 | |||
275 | |||
276 | /* Bit definitions for MC417_CTL register **** | ||
277 | *bits 31-6 bits 5-4 bit 3 bits 2-1 Bit 0 | ||
278 | *+--------+-------------+--------+--------------+------------+ | ||
279 | *|Reserved|MC417_SPD_CTL|Reserved|MC417_GPIO_SEL|UART_GPIO_EN| | ||
280 | *+--------+-------------+--------+--------------+------------+ | ||
281 | */ | ||
282 | #define MC417_SPD_CTL(x) (((x) << 4) & 0x00000030) | ||
283 | #define MC417_GPIO_SEL(x) (((x) << 1) & 0x00000006) | ||
284 | #define MC417_UART_GPIO_EN 0x00000001 | ||
285 | |||
286 | /* Values for speed control */ | ||
287 | #define MC417_SPD_CTL_SLOW 0x1 | ||
288 | #define MC417_SPD_CTL_MEDIUM 0x0 | ||
289 | #define MC417_SPD_CTL_FAST 0x3 /* b'1x, but we use b'11 */ | ||
290 | |||
291 | /* Values for GPIO select */ | ||
292 | #define MC417_GPIO_SEL_GPIO3 0x3 | ||
293 | #define MC417_GPIO_SEL_GPIO2 0x2 | ||
294 | #define MC417_GPIO_SEL_GPIO1 0x1 | ||
295 | #define MC417_GPIO_SEL_GPIO0 0x0 | ||
296 | |||
297 | |||
298 | #define CX23417_GPIO_MASK 0xFC0003FF | ||
299 | static int setITVCReg(struct cx231xx *dev, u32 gpio_direction, u32 value) | ||
300 | { | ||
301 | int status = 0; | ||
302 | u32 _gpio_direction = 0; | ||
303 | |||
304 | _gpio_direction = _gpio_direction & CX23417_GPIO_MASK; | ||
305 | _gpio_direction = _gpio_direction|gpio_direction; | ||
306 | status = cx231xx_send_gpio_cmd(dev, _gpio_direction, | ||
307 | (u8 *)&value, 4, 0, 0); | ||
308 | return status; | ||
309 | } | ||
310 | static int getITVCReg(struct cx231xx *dev, u32 gpio_direction, u32 *pValue) | ||
311 | { | ||
312 | int status = 0; | ||
313 | u32 _gpio_direction = 0; | ||
314 | |||
315 | _gpio_direction = _gpio_direction & CX23417_GPIO_MASK; | ||
316 | _gpio_direction = _gpio_direction|gpio_direction; | ||
317 | |||
318 | status = cx231xx_send_gpio_cmd(dev, _gpio_direction, | ||
319 | (u8 *)pValue, 4, 0, 1); | ||
320 | return status; | ||
321 | } | ||
322 | |||
323 | static int waitForMciComplete(struct cx231xx *dev) | ||
324 | { | ||
325 | u32 gpio; | ||
326 | u32 gpio_driection = 0; | ||
327 | u8 count = 0; | ||
328 | getITVCReg(dev, gpio_driection, &gpio); | ||
329 | |||
330 | while (!(gpio&0x020000)) { | ||
331 | msleep(10); | ||
332 | |||
333 | getITVCReg(dev, gpio_driection, &gpio); | ||
334 | |||
335 | if (count++ > 100) { | ||
336 | dprintk(3, "ERROR: Timeout - gpio=%x\n", gpio); | ||
337 | return -1; | ||
338 | } | ||
339 | } | ||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | static int mc417_register_write(struct cx231xx *dev, u16 address, u32 value) | ||
344 | { | ||
345 | u32 temp; | ||
346 | int status = 0; | ||
347 | |||
348 | temp = 0x82|MCI_REGISTER_DATA_BYTE0|((value&0x000000FF)<<8); | ||
349 | temp = temp<<10; | ||
350 | status = setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
351 | if (status < 0) | ||
352 | return status; | ||
353 | temp = temp|((0x05)<<10); | ||
354 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
355 | |||
356 | /*write data byte 1;*/ | ||
357 | temp = 0x82|MCI_REGISTER_DATA_BYTE1|(value&0x0000FF00); | ||
358 | temp = temp<<10; | ||
359 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
360 | temp = temp|((0x05)<<10); | ||
361 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
362 | |||
363 | /*write data byte 2;*/ | ||
364 | temp = 0x82|MCI_REGISTER_DATA_BYTE2|((value&0x00FF0000)>>8); | ||
365 | temp = temp<<10; | ||
366 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
367 | temp = temp|((0x05)<<10); | ||
368 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
369 | |||
370 | /*write data byte 3;*/ | ||
371 | temp = 0x82|MCI_REGISTER_DATA_BYTE3|((value&0xFF000000)>>16); | ||
372 | temp = temp<<10; | ||
373 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
374 | temp = temp|((0x05)<<10); | ||
375 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
376 | |||
377 | /*write address byte 0;*/ | ||
378 | temp = 0x82|MCI_REGISTER_ADDRESS_BYTE0|((address&0x000000FF)<<8); | ||
379 | temp = temp<<10; | ||
380 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
381 | temp = temp|((0x05)<<10); | ||
382 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
383 | |||
384 | /*write address byte 1;*/ | ||
385 | temp = 0x82|MCI_REGISTER_ADDRESS_BYTE1|(address&0x0000FF00); | ||
386 | temp = temp<<10; | ||
387 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
388 | temp = temp|((0x05)<<10); | ||
389 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
390 | |||
391 | /*Write that the mode is write.*/ | ||
392 | temp = 0x82 | MCI_REGISTER_MODE | MCI_MODE_REGISTER_WRITE; | ||
393 | temp = temp<<10; | ||
394 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
395 | temp = temp|((0x05)<<10); | ||
396 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
397 | |||
398 | return waitForMciComplete(dev); | ||
399 | } | ||
400 | |||
401 | static int mc417_register_read(struct cx231xx *dev, u16 address, u32 *value) | ||
402 | { | ||
403 | /*write address byte 0;*/ | ||
404 | u32 temp; | ||
405 | u32 return_value = 0; | ||
406 | int ret = 0; | ||
407 | |||
408 | temp = 0x82 | MCI_REGISTER_ADDRESS_BYTE0 | ((address & 0x00FF) << 8); | ||
409 | temp = temp << 10; | ||
410 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
411 | temp = temp | ((0x05) << 10); | ||
412 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
413 | |||
414 | /*write address byte 1;*/ | ||
415 | temp = 0x82 | MCI_REGISTER_ADDRESS_BYTE1 | (address & 0xFF00); | ||
416 | temp = temp << 10; | ||
417 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
418 | temp = temp | ((0x05) << 10); | ||
419 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
420 | |||
421 | /*write that the mode is read;*/ | ||
422 | temp = 0x82 | MCI_REGISTER_MODE | MCI_MODE_REGISTER_READ; | ||
423 | temp = temp << 10; | ||
424 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
425 | temp = temp | ((0x05) << 10); | ||
426 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
427 | |||
428 | /*wait for the MIRDY line to be asserted , | ||
429 | signalling that the read is done;*/ | ||
430 | ret = waitForMciComplete(dev); | ||
431 | |||
432 | /*switch the DATA- GPIO to input mode;*/ | ||
433 | |||
434 | /*Read data byte 0;*/ | ||
435 | temp = (0x82 | MCI_REGISTER_DATA_BYTE0) << 10; | ||
436 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
437 | temp = ((0x81 | MCI_REGISTER_DATA_BYTE0) << 10); | ||
438 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
439 | getITVCReg(dev, ITVC_READ_DIR, &temp); | ||
440 | return_value |= ((temp & 0x03FC0000) >> 18); | ||
441 | setITVCReg(dev, ITVC_READ_DIR, (0x87 << 10)); | ||
442 | |||
443 | /* Read data byte 1;*/ | ||
444 | temp = (0x82 | MCI_REGISTER_DATA_BYTE1) << 10; | ||
445 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
446 | temp = ((0x81 | MCI_REGISTER_DATA_BYTE1) << 10); | ||
447 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
448 | getITVCReg(dev, ITVC_READ_DIR, &temp); | ||
449 | |||
450 | return_value |= ((temp & 0x03FC0000) >> 10); | ||
451 | setITVCReg(dev, ITVC_READ_DIR, (0x87 << 10)); | ||
452 | |||
453 | /*Read data byte 2;*/ | ||
454 | temp = (0x82 | MCI_REGISTER_DATA_BYTE2) << 10; | ||
455 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
456 | temp = ((0x81 | MCI_REGISTER_DATA_BYTE2) << 10); | ||
457 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
458 | getITVCReg(dev, ITVC_READ_DIR, &temp); | ||
459 | return_value |= ((temp & 0x03FC0000) >> 2); | ||
460 | setITVCReg(dev, ITVC_READ_DIR, (0x87 << 10)); | ||
461 | |||
462 | /*Read data byte 3;*/ | ||
463 | temp = (0x82 | MCI_REGISTER_DATA_BYTE3) << 10; | ||
464 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
465 | temp = ((0x81 | MCI_REGISTER_DATA_BYTE3) << 10); | ||
466 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
467 | getITVCReg(dev, ITVC_READ_DIR, &temp); | ||
468 | return_value |= ((temp & 0x03FC0000) << 6); | ||
469 | setITVCReg(dev, ITVC_READ_DIR, (0x87 << 10)); | ||
470 | |||
471 | *value = return_value; | ||
472 | |||
473 | |||
474 | return ret; | ||
475 | } | ||
476 | |||
477 | static int mc417_memory_write(struct cx231xx *dev, u32 address, u32 value) | ||
478 | { | ||
479 | /*write data byte 0;*/ | ||
480 | |||
481 | u32 temp; | ||
482 | int ret = 0; | ||
483 | |||
484 | temp = 0x82 | MCI_MEMORY_DATA_BYTE0|((value & 0x000000FF) << 8); | ||
485 | temp = temp << 10; | ||
486 | ret = setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
487 | if (ret < 0) | ||
488 | return ret; | ||
489 | temp = temp | ((0x05) << 10); | ||
490 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
491 | |||
492 | /*write data byte 1;*/ | ||
493 | temp = 0x82 | MCI_MEMORY_DATA_BYTE1 | (value & 0x0000FF00); | ||
494 | temp = temp << 10; | ||
495 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
496 | temp = temp | ((0x05) << 10); | ||
497 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
498 | |||
499 | /*write data byte 2;*/ | ||
500 | temp = 0x82|MCI_MEMORY_DATA_BYTE2|((value&0x00FF0000)>>8); | ||
501 | temp = temp<<10; | ||
502 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
503 | temp = temp|((0x05)<<10); | ||
504 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
505 | |||
506 | /*write data byte 3;*/ | ||
507 | temp = 0x82|MCI_MEMORY_DATA_BYTE3|((value&0xFF000000)>>16); | ||
508 | temp = temp<<10; | ||
509 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
510 | temp = temp|((0x05)<<10); | ||
511 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
512 | |||
513 | /* write address byte 2;*/ | ||
514 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE2 | MCI_MODE_MEMORY_WRITE | | ||
515 | ((address & 0x003F0000)>>8); | ||
516 | temp = temp<<10; | ||
517 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
518 | temp = temp|((0x05)<<10); | ||
519 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
520 | |||
521 | /* write address byte 1;*/ | ||
522 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE1 | (address & 0xFF00); | ||
523 | temp = temp<<10; | ||
524 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
525 | temp = temp|((0x05)<<10); | ||
526 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
527 | |||
528 | /* write address byte 0;*/ | ||
529 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE0|((address & 0x00FF)<<8); | ||
530 | temp = temp<<10; | ||
531 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
532 | temp = temp|((0x05)<<10); | ||
533 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
534 | |||
535 | /*wait for MIRDY line;*/ | ||
536 | waitForMciComplete(dev); | ||
537 | |||
538 | return 0; | ||
539 | } | ||
540 | |||
541 | static int mc417_memory_read(struct cx231xx *dev, u32 address, u32 *value) | ||
542 | { | ||
543 | u32 temp = 0; | ||
544 | u32 return_value = 0; | ||
545 | int ret = 0; | ||
546 | |||
547 | /*write address byte 2;*/ | ||
548 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE2 | MCI_MODE_MEMORY_READ | | ||
549 | ((address & 0x003F0000)>>8); | ||
550 | temp = temp<<10; | ||
551 | ret = setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
552 | if (ret < 0) | ||
553 | return ret; | ||
554 | temp = temp|((0x05)<<10); | ||
555 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
556 | |||
557 | /*write address byte 1*/ | ||
558 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE1 | (address & 0xFF00); | ||
559 | temp = temp<<10; | ||
560 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
561 | temp = temp|((0x05)<<10); | ||
562 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
563 | |||
564 | /*write address byte 0*/ | ||
565 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE0 | ((address & 0x00FF)<<8); | ||
566 | temp = temp<<10; | ||
567 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
568 | temp = temp|((0x05)<<10); | ||
569 | setITVCReg(dev, ITVC_WRITE_DIR, temp); | ||
570 | |||
571 | /*Wait for MIRDY line*/ | ||
572 | ret = waitForMciComplete(dev); | ||
573 | |||
574 | |||
575 | /*Read data byte 3;*/ | ||
576 | temp = (0x82|MCI_MEMORY_DATA_BYTE3)<<10; | ||
577 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
578 | temp = ((0x81|MCI_MEMORY_DATA_BYTE3)<<10); | ||
579 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
580 | getITVCReg(dev, ITVC_READ_DIR, &temp); | ||
581 | return_value |= ((temp&0x03FC0000)<<6); | ||
582 | setITVCReg(dev, ITVC_READ_DIR, (0x87<<10)); | ||
583 | |||
584 | /*Read data byte 2;*/ | ||
585 | temp = (0x82|MCI_MEMORY_DATA_BYTE2)<<10; | ||
586 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
587 | temp = ((0x81|MCI_MEMORY_DATA_BYTE2)<<10); | ||
588 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
589 | getITVCReg(dev, ITVC_READ_DIR, &temp); | ||
590 | return_value |= ((temp&0x03FC0000)>>2); | ||
591 | setITVCReg(dev, ITVC_READ_DIR, (0x87<<10)); | ||
592 | |||
593 | /* Read data byte 1;*/ | ||
594 | temp = (0x82|MCI_MEMORY_DATA_BYTE1)<<10; | ||
595 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
596 | temp = ((0x81|MCI_MEMORY_DATA_BYTE1)<<10); | ||
597 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
598 | getITVCReg(dev, ITVC_READ_DIR, &temp); | ||
599 | return_value |= ((temp&0x03FC0000)>>10); | ||
600 | setITVCReg(dev, ITVC_READ_DIR, (0x87<<10)); | ||
601 | |||
602 | /*Read data byte 0;*/ | ||
603 | temp = (0x82|MCI_MEMORY_DATA_BYTE0)<<10; | ||
604 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
605 | temp = ((0x81|MCI_MEMORY_DATA_BYTE0)<<10); | ||
606 | setITVCReg(dev, ITVC_READ_DIR, temp); | ||
607 | getITVCReg(dev, ITVC_READ_DIR, &temp); | ||
608 | return_value |= ((temp&0x03FC0000)>>18); | ||
609 | setITVCReg(dev, ITVC_READ_DIR, (0x87<<10)); | ||
610 | |||
611 | *value = return_value; | ||
612 | return ret; | ||
613 | } | ||
614 | |||
615 | /* ------------------------------------------------------------------ */ | ||
616 | |||
617 | /* MPEG encoder API */ | ||
618 | static char *cmd_to_str(int cmd) | ||
619 | { | ||
620 | switch (cmd) { | ||
621 | case CX2341X_ENC_PING_FW: | ||
622 | return "PING_FW"; | ||
623 | case CX2341X_ENC_START_CAPTURE: | ||
624 | return "START_CAPTURE"; | ||
625 | case CX2341X_ENC_STOP_CAPTURE: | ||
626 | return "STOP_CAPTURE"; | ||
627 | case CX2341X_ENC_SET_AUDIO_ID: | ||
628 | return "SET_AUDIO_ID"; | ||
629 | case CX2341X_ENC_SET_VIDEO_ID: | ||
630 | return "SET_VIDEO_ID"; | ||
631 | case CX2341X_ENC_SET_PCR_ID: | ||
632 | return "SET_PCR_PID"; | ||
633 | case CX2341X_ENC_SET_FRAME_RATE: | ||
634 | return "SET_FRAME_RATE"; | ||
635 | case CX2341X_ENC_SET_FRAME_SIZE: | ||
636 | return "SET_FRAME_SIZE"; | ||
637 | case CX2341X_ENC_SET_BIT_RATE: | ||
638 | return "SET_BIT_RATE"; | ||
639 | case CX2341X_ENC_SET_GOP_PROPERTIES: | ||
640 | return "SET_GOP_PROPERTIES"; | ||
641 | case CX2341X_ENC_SET_ASPECT_RATIO: | ||
642 | return "SET_ASPECT_RATIO"; | ||
643 | case CX2341X_ENC_SET_DNR_FILTER_MODE: | ||
644 | return "SET_DNR_FILTER_PROPS"; | ||
645 | case CX2341X_ENC_SET_DNR_FILTER_PROPS: | ||
646 | return "SET_DNR_FILTER_PROPS"; | ||
647 | case CX2341X_ENC_SET_CORING_LEVELS: | ||
648 | return "SET_CORING_LEVELS"; | ||
649 | case CX2341X_ENC_SET_SPATIAL_FILTER_TYPE: | ||
650 | return "SET_SPATIAL_FILTER_TYPE"; | ||
651 | case CX2341X_ENC_SET_VBI_LINE: | ||
652 | return "SET_VBI_LINE"; | ||
653 | case CX2341X_ENC_SET_STREAM_TYPE: | ||
654 | return "SET_STREAM_TYPE"; | ||
655 | case CX2341X_ENC_SET_OUTPUT_PORT: | ||
656 | return "SET_OUTPUT_PORT"; | ||
657 | case CX2341X_ENC_SET_AUDIO_PROPERTIES: | ||
658 | return "SET_AUDIO_PROPERTIES"; | ||
659 | case CX2341X_ENC_HALT_FW: | ||
660 | return "HALT_FW"; | ||
661 | case CX2341X_ENC_GET_VERSION: | ||
662 | return "GET_VERSION"; | ||
663 | case CX2341X_ENC_SET_GOP_CLOSURE: | ||
664 | return "SET_GOP_CLOSURE"; | ||
665 | case CX2341X_ENC_GET_SEQ_END: | ||
666 | return "GET_SEQ_END"; | ||
667 | case CX2341X_ENC_SET_PGM_INDEX_INFO: | ||
668 | return "SET_PGM_INDEX_INFO"; | ||
669 | case CX2341X_ENC_SET_VBI_CONFIG: | ||
670 | return "SET_VBI_CONFIG"; | ||
671 | case CX2341X_ENC_SET_DMA_BLOCK_SIZE: | ||
672 | return "SET_DMA_BLOCK_SIZE"; | ||
673 | case CX2341X_ENC_GET_PREV_DMA_INFO_MB_10: | ||
674 | return "GET_PREV_DMA_INFO_MB_10"; | ||
675 | case CX2341X_ENC_GET_PREV_DMA_INFO_MB_9: | ||
676 | return "GET_PREV_DMA_INFO_MB_9"; | ||
677 | case CX2341X_ENC_SCHED_DMA_TO_HOST: | ||
678 | return "SCHED_DMA_TO_HOST"; | ||
679 | case CX2341X_ENC_INITIALIZE_INPUT: | ||
680 | return "INITIALIZE_INPUT"; | ||
681 | case CX2341X_ENC_SET_FRAME_DROP_RATE: | ||
682 | return "SET_FRAME_DROP_RATE"; | ||
683 | case CX2341X_ENC_PAUSE_ENCODER: | ||
684 | return "PAUSE_ENCODER"; | ||
685 | case CX2341X_ENC_REFRESH_INPUT: | ||
686 | return "REFRESH_INPUT"; | ||
687 | case CX2341X_ENC_SET_COPYRIGHT: | ||
688 | return "SET_COPYRIGHT"; | ||
689 | case CX2341X_ENC_SET_EVENT_NOTIFICATION: | ||
690 | return "SET_EVENT_NOTIFICATION"; | ||
691 | case CX2341X_ENC_SET_NUM_VSYNC_LINES: | ||
692 | return "SET_NUM_VSYNC_LINES"; | ||
693 | case CX2341X_ENC_SET_PLACEHOLDER: | ||
694 | return "SET_PLACEHOLDER"; | ||
695 | case CX2341X_ENC_MUTE_VIDEO: | ||
696 | return "MUTE_VIDEO"; | ||
697 | case CX2341X_ENC_MUTE_AUDIO: | ||
698 | return "MUTE_AUDIO"; | ||
699 | case CX2341X_ENC_MISC: | ||
700 | return "MISC"; | ||
701 | default: | ||
702 | return "UNKNOWN"; | ||
703 | } | ||
704 | } | ||
705 | |||
706 | static int cx231xx_mbox_func(void *priv, | ||
707 | u32 command, | ||
708 | int in, | ||
709 | int out, | ||
710 | u32 data[CX2341X_MBOX_MAX_DATA]) | ||
711 | { | ||
712 | struct cx231xx *dev = priv; | ||
713 | unsigned long timeout; | ||
714 | u32 value, flag, retval = 0; | ||
715 | int i; | ||
716 | |||
717 | dprintk(3, "%s: command(0x%X) = %s\n", __func__, command, | ||
718 | cmd_to_str(command)); | ||
719 | |||
720 | /* this may not be 100% safe if we can't read any memory location | ||
721 | without side effects */ | ||
722 | mc417_memory_read(dev, dev->cx23417_mailbox - 4, &value); | ||
723 | if (value != 0x12345678) { | ||
724 | dprintk(3, | ||
725 | "Firmware and/or mailbox pointer not initialized " | ||
726 | "or corrupted, signature = 0x%x, cmd = %s\n", value, | ||
727 | cmd_to_str(command)); | ||
728 | return -1; | ||
729 | } | ||
730 | |||
731 | /* This read looks at 32 bits, but flag is only 8 bits. | ||
732 | * Seems we also bail if CMD or TIMEOUT bytes are set??? | ||
733 | */ | ||
734 | mc417_memory_read(dev, dev->cx23417_mailbox, &flag); | ||
735 | if (flag) { | ||
736 | dprintk(3, "ERROR: Mailbox appears to be in use " | ||
737 | "(%x), cmd = %s\n", flag, cmd_to_str(command)); | ||
738 | return -1; | ||
739 | } | ||
740 | |||
741 | flag |= 1; /* tell 'em we're working on it */ | ||
742 | mc417_memory_write(dev, dev->cx23417_mailbox, flag); | ||
743 | |||
744 | /* write command + args + fill remaining with zeros */ | ||
745 | /* command code */ | ||
746 | mc417_memory_write(dev, dev->cx23417_mailbox + 1, command); | ||
747 | mc417_memory_write(dev, dev->cx23417_mailbox + 3, | ||
748 | IVTV_API_STD_TIMEOUT); /* timeout */ | ||
749 | for (i = 0; i < in; i++) { | ||
750 | mc417_memory_write(dev, dev->cx23417_mailbox + 4 + i, data[i]); | ||
751 | dprintk(3, "API Input %d = %d\n", i, data[i]); | ||
752 | } | ||
753 | for (; i < CX2341X_MBOX_MAX_DATA; i++) | ||
754 | mc417_memory_write(dev, dev->cx23417_mailbox + 4 + i, 0); | ||
755 | |||
756 | flag |= 3; /* tell 'em we're done writing */ | ||
757 | mc417_memory_write(dev, dev->cx23417_mailbox, flag); | ||
758 | |||
759 | /* wait for firmware to handle the API command */ | ||
760 | timeout = jiffies + msecs_to_jiffies(10); | ||
761 | for (;;) { | ||
762 | mc417_memory_read(dev, dev->cx23417_mailbox, &flag); | ||
763 | if (0 != (flag & 4)) | ||
764 | break; | ||
765 | if (time_after(jiffies, timeout)) { | ||
766 | dprintk(3, "ERROR: API Mailbox timeout\n"); | ||
767 | return -1; | ||
768 | } | ||
769 | udelay(10); | ||
770 | } | ||
771 | |||
772 | /* read output values */ | ||
773 | for (i = 0; i < out; i++) { | ||
774 | mc417_memory_read(dev, dev->cx23417_mailbox + 4 + i, data + i); | ||
775 | dprintk(3, "API Output %d = %d\n", i, data[i]); | ||
776 | } | ||
777 | |||
778 | mc417_memory_read(dev, dev->cx23417_mailbox + 2, &retval); | ||
779 | dprintk(3, "API result = %d\n", retval); | ||
780 | |||
781 | flag = 0; | ||
782 | mc417_memory_write(dev, dev->cx23417_mailbox, flag); | ||
783 | |||
784 | return retval; | ||
785 | } | ||
786 | |||
787 | /* We don't need to call the API often, so using just one | ||
788 | * mailbox will probably suffice | ||
789 | */ | ||
790 | static int cx231xx_api_cmd(struct cx231xx *dev, | ||
791 | u32 command, | ||
792 | u32 inputcnt, | ||
793 | u32 outputcnt, | ||
794 | ...) | ||
795 | { | ||
796 | u32 data[CX2341X_MBOX_MAX_DATA]; | ||
797 | va_list vargs; | ||
798 | int i, err; | ||
799 | |||
800 | dprintk(3, "%s() cmds = 0x%08x\n", __func__, command); | ||
801 | |||
802 | va_start(vargs, outputcnt); | ||
803 | for (i = 0; i < inputcnt; i++) | ||
804 | data[i] = va_arg(vargs, int); | ||
805 | |||
806 | err = cx231xx_mbox_func(dev, command, inputcnt, outputcnt, data); | ||
807 | for (i = 0; i < outputcnt; i++) { | ||
808 | int *vptr = va_arg(vargs, int *); | ||
809 | *vptr = data[i]; | ||
810 | } | ||
811 | va_end(vargs); | ||
812 | |||
813 | return err; | ||
814 | } | ||
815 | |||
816 | static int cx231xx_find_mailbox(struct cx231xx *dev) | ||
817 | { | ||
818 | u32 signature[4] = { | ||
819 | 0x12345678, 0x34567812, 0x56781234, 0x78123456 | ||
820 | }; | ||
821 | int signaturecnt = 0; | ||
822 | u32 value; | ||
823 | int i; | ||
824 | int ret = 0; | ||
825 | |||
826 | dprintk(2, "%s()\n", __func__); | ||
827 | |||
828 | for (i = 0; i < 0x100; i++) {/*CX231xx_FIRM_IMAGE_SIZE*/ | ||
829 | ret = mc417_memory_read(dev, i, &value); | ||
830 | if (ret < 0) | ||
831 | return ret; | ||
832 | if (value == signature[signaturecnt]) | ||
833 | signaturecnt++; | ||
834 | else | ||
835 | signaturecnt = 0; | ||
836 | if (4 == signaturecnt) { | ||
837 | dprintk(1, "Mailbox signature found at 0x%x\n", i+1); | ||
838 | return i+1; | ||
839 | } | ||
840 | } | ||
841 | dprintk(3, "Mailbox signature values not found!\n"); | ||
842 | return -1; | ||
843 | } | ||
844 | |||
845 | static void mciWriteMemoryToGPIO(struct cx231xx *dev, u32 address, u32 value, | ||
846 | u32 *p_fw_image) | ||
847 | { | ||
848 | |||
849 | u32 temp = 0; | ||
850 | int i = 0; | ||
851 | |||
852 | temp = 0x82|MCI_MEMORY_DATA_BYTE0|((value&0x000000FF)<<8); | ||
853 | temp = temp<<10; | ||
854 | *p_fw_image = temp; | ||
855 | p_fw_image++; | ||
856 | temp = temp|((0x05)<<10); | ||
857 | *p_fw_image = temp; | ||
858 | p_fw_image++; | ||
859 | |||
860 | /*write data byte 1;*/ | ||
861 | temp = 0x82|MCI_MEMORY_DATA_BYTE1|(value&0x0000FF00); | ||
862 | temp = temp<<10; | ||
863 | *p_fw_image = temp; | ||
864 | p_fw_image++; | ||
865 | temp = temp|((0x05)<<10); | ||
866 | *p_fw_image = temp; | ||
867 | p_fw_image++; | ||
868 | |||
869 | /*write data byte 2;*/ | ||
870 | temp = 0x82|MCI_MEMORY_DATA_BYTE2|((value&0x00FF0000)>>8); | ||
871 | temp = temp<<10; | ||
872 | *p_fw_image = temp; | ||
873 | p_fw_image++; | ||
874 | temp = temp|((0x05)<<10); | ||
875 | *p_fw_image = temp; | ||
876 | p_fw_image++; | ||
877 | |||
878 | /*write data byte 3;*/ | ||
879 | temp = 0x82|MCI_MEMORY_DATA_BYTE3|((value&0xFF000000)>>16); | ||
880 | temp = temp<<10; | ||
881 | *p_fw_image = temp; | ||
882 | p_fw_image++; | ||
883 | temp = temp|((0x05)<<10); | ||
884 | *p_fw_image = temp; | ||
885 | p_fw_image++; | ||
886 | |||
887 | /* write address byte 2;*/ | ||
888 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE2 | MCI_MODE_MEMORY_WRITE | | ||
889 | ((address & 0x003F0000)>>8); | ||
890 | temp = temp<<10; | ||
891 | *p_fw_image = temp; | ||
892 | p_fw_image++; | ||
893 | temp = temp|((0x05)<<10); | ||
894 | *p_fw_image = temp; | ||
895 | p_fw_image++; | ||
896 | |||
897 | /* write address byte 1;*/ | ||
898 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE1 | (address & 0xFF00); | ||
899 | temp = temp<<10; | ||
900 | *p_fw_image = temp; | ||
901 | p_fw_image++; | ||
902 | temp = temp|((0x05)<<10); | ||
903 | *p_fw_image = temp; | ||
904 | p_fw_image++; | ||
905 | |||
906 | /* write address byte 0;*/ | ||
907 | temp = 0x82|MCI_MEMORY_ADDRESS_BYTE0|((address & 0x00FF)<<8); | ||
908 | temp = temp<<10; | ||
909 | *p_fw_image = temp; | ||
910 | p_fw_image++; | ||
911 | temp = temp|((0x05)<<10); | ||
912 | *p_fw_image = temp; | ||
913 | p_fw_image++; | ||
914 | |||
915 | for (i = 0; i < 6; i++) { | ||
916 | *p_fw_image = 0xFFFFFFFF; | ||
917 | p_fw_image++; | ||
918 | } | ||
919 | } | ||
920 | |||
921 | |||
922 | static int cx231xx_load_firmware(struct cx231xx *dev) | ||
923 | { | ||
924 | static const unsigned char magic[8] = { | ||
925 | 0xa7, 0x0d, 0x00, 0x00, 0x66, 0xbb, 0x55, 0xaa | ||
926 | }; | ||
927 | const struct firmware *firmware; | ||
928 | int i, retval = 0; | ||
929 | u32 value = 0; | ||
930 | u32 gpio_output = 0; | ||
931 | /*u32 checksum = 0;*/ | ||
932 | /*u32 *dataptr;*/ | ||
933 | u32 transfer_size = 0; | ||
934 | u32 fw_data = 0; | ||
935 | u32 address = 0; | ||
936 | /*u32 current_fw[800];*/ | ||
937 | u32 *p_current_fw, *p_fw; | ||
938 | u32 *p_fw_data; | ||
939 | int frame = 0; | ||
940 | u16 _buffer_size = 4096; | ||
941 | u8 *p_buffer; | ||
942 | |||
943 | p_current_fw = vmalloc(1884180 * 4); | ||
944 | p_fw = p_current_fw; | ||
945 | if (p_current_fw == NULL) { | ||
946 | dprintk(2, "FAIL!!!\n"); | ||
947 | return -1; | ||
948 | } | ||
949 | |||
950 | p_buffer = vmalloc(4096); | ||
951 | if (p_buffer == NULL) { | ||
952 | dprintk(2, "FAIL!!!\n"); | ||
953 | return -1; | ||
954 | } | ||
955 | |||
956 | dprintk(2, "%s()\n", __func__); | ||
957 | |||
958 | /* Save GPIO settings before reset of APU */ | ||
959 | retval |= mc417_memory_read(dev, 0x9020, &gpio_output); | ||
960 | retval |= mc417_memory_read(dev, 0x900C, &value); | ||
961 | |||
962 | retval = mc417_register_write(dev, | ||
963 | IVTV_REG_VPU, 0xFFFFFFED); | ||
964 | retval |= mc417_register_write(dev, | ||
965 | IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); | ||
966 | retval |= mc417_register_write(dev, | ||
967 | IVTV_REG_ENC_SDRAM_REFRESH, 0x80000800); | ||
968 | retval |= mc417_register_write(dev, | ||
969 | IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A); | ||
970 | retval |= mc417_register_write(dev, | ||
971 | IVTV_REG_APU, 0); | ||
972 | |||
973 | if (retval != 0) { | ||
974 | printk(KERN_ERR "%s: Error with mc417_register_write\n", | ||
975 | __func__); | ||
976 | return -1; | ||
977 | } | ||
978 | |||
979 | retval = request_firmware(&firmware, CX231xx_FIRM_IMAGE_NAME, | ||
980 | &dev->udev->dev); | ||
981 | |||
982 | if (retval != 0) { | ||
983 | printk(KERN_ERR | ||
984 | "ERROR: Hotplug firmware request failed (%s).\n", | ||
985 | CX231xx_FIRM_IMAGE_NAME); | ||
986 | printk(KERN_ERR "Please fix your hotplug setup, the board will " | ||
987 | "not work without firmware loaded!\n"); | ||
988 | return -1; | ||
989 | } | ||
990 | |||
991 | if (firmware->size != CX231xx_FIRM_IMAGE_SIZE) { | ||
992 | printk(KERN_ERR "ERROR: Firmware size mismatch " | ||
993 | "(have %zd, expected %d)\n", | ||
994 | firmware->size, CX231xx_FIRM_IMAGE_SIZE); | ||
995 | release_firmware(firmware); | ||
996 | return -1; | ||
997 | } | ||
998 | |||
999 | if (0 != memcmp(firmware->data, magic, 8)) { | ||
1000 | printk(KERN_ERR | ||
1001 | "ERROR: Firmware magic mismatch, wrong file?\n"); | ||
1002 | release_firmware(firmware); | ||
1003 | return -1; | ||
1004 | } | ||
1005 | |||
1006 | initGPIO(dev); | ||
1007 | |||
1008 | /* transfer to the chip */ | ||
1009 | dprintk(2, "Loading firmware to GPIO...\n"); | ||
1010 | p_fw_data = (u32 *)firmware->data; | ||
1011 | dprintk(2, "firmware->size=%zd\n", firmware->size); | ||
1012 | for (transfer_size = 0; transfer_size < firmware->size; | ||
1013 | transfer_size += 4) { | ||
1014 | fw_data = *p_fw_data; | ||
1015 | |||
1016 | mciWriteMemoryToGPIO(dev, address, fw_data, p_current_fw); | ||
1017 | address = address + 1; | ||
1018 | p_current_fw += 20; | ||
1019 | p_fw_data += 1; | ||
1020 | } | ||
1021 | |||
1022 | /*download the firmware by ep5-out*/ | ||
1023 | |||
1024 | for (frame = 0; frame < (int)(CX231xx_FIRM_IMAGE_SIZE*20/_buffer_size); | ||
1025 | frame++) { | ||
1026 | for (i = 0; i < _buffer_size; i++) { | ||
1027 | *(p_buffer + i) = (u8)(*(p_fw + (frame * 128 * 8 + (i / 4))) & 0x000000FF); | ||
1028 | i++; | ||
1029 | *(p_buffer + i) = (u8)((*(p_fw + (frame * 128 * 8 + (i / 4))) & 0x0000FF00) >> 8); | ||
1030 | i++; | ||
1031 | *(p_buffer + i) = (u8)((*(p_fw + (frame * 128 * 8 + (i / 4))) & 0x00FF0000) >> 16); | ||
1032 | i++; | ||
1033 | *(p_buffer + i) = (u8)((*(p_fw + (frame * 128 * 8 + (i / 4))) & 0xFF000000) >> 24); | ||
1034 | } | ||
1035 | cx231xx_ep5_bulkout(dev, p_buffer, _buffer_size); | ||
1036 | } | ||
1037 | |||
1038 | p_current_fw = p_fw; | ||
1039 | vfree(p_current_fw); | ||
1040 | p_current_fw = NULL; | ||
1041 | uninitGPIO(dev); | ||
1042 | release_firmware(firmware); | ||
1043 | dprintk(1, "Firmware upload successful.\n"); | ||
1044 | |||
1045 | retval |= mc417_register_write(dev, IVTV_REG_HW_BLOCKS, | ||
1046 | IVTV_CMD_HW_BLOCKS_RST); | ||
1047 | if (retval < 0) { | ||
1048 | printk(KERN_ERR "%s: Error with mc417_register_write\n", | ||
1049 | __func__); | ||
1050 | return retval; | ||
1051 | } | ||
1052 | /* F/W power up disturbs the GPIOs, restore state */ | ||
1053 | retval |= mc417_register_write(dev, 0x9020, gpio_output); | ||
1054 | retval |= mc417_register_write(dev, 0x900C, value); | ||
1055 | |||
1056 | retval |= mc417_register_read(dev, IVTV_REG_VPU, &value); | ||
1057 | retval |= mc417_register_write(dev, IVTV_REG_VPU, value & 0xFFFFFFE8); | ||
1058 | |||
1059 | if (retval < 0) { | ||
1060 | printk(KERN_ERR "%s: Error with mc417_register_write\n", | ||
1061 | __func__); | ||
1062 | return retval; | ||
1063 | } | ||
1064 | return 0; | ||
1065 | } | ||
1066 | |||
1067 | static void cx231xx_417_check_encoder(struct cx231xx *dev) | ||
1068 | { | ||
1069 | u32 status, seq; | ||
1070 | |||
1071 | status = 0; | ||
1072 | seq = 0; | ||
1073 | cx231xx_api_cmd(dev, CX2341X_ENC_GET_SEQ_END, 0, 2, &status, &seq); | ||
1074 | dprintk(1, "%s() status = %d, seq = %d\n", __func__, status, seq); | ||
1075 | } | ||
1076 | |||
1077 | static void cx231xx_codec_settings(struct cx231xx *dev) | ||
1078 | { | ||
1079 | dprintk(1, "%s()\n", __func__); | ||
1080 | |||
1081 | /* assign frame size */ | ||
1082 | cx231xx_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, | ||
1083 | dev->ts1.height, dev->ts1.width); | ||
1084 | |||
1085 | dev->mpeg_params.width = dev->ts1.width; | ||
1086 | dev->mpeg_params.height = dev->ts1.height; | ||
1087 | |||
1088 | cx2341x_update(dev, cx231xx_mbox_func, NULL, &dev->mpeg_params); | ||
1089 | |||
1090 | cx231xx_api_cmd(dev, CX2341X_ENC_MISC, 2, 0, 3, 1); | ||
1091 | cx231xx_api_cmd(dev, CX2341X_ENC_MISC, 2, 0, 4, 1); | ||
1092 | } | ||
1093 | |||
1094 | static int cx231xx_initialize_codec(struct cx231xx *dev) | ||
1095 | { | ||
1096 | int version; | ||
1097 | int retval; | ||
1098 | u32 i; | ||
1099 | u32 val = 0; | ||
1100 | |||
1101 | dprintk(1, "%s()\n", __func__); | ||
1102 | cx231xx_disable656(dev); | ||
1103 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ | ||
1104 | if (retval < 0) { | ||
1105 | dprintk(2, "%s() PING OK\n", __func__); | ||
1106 | retval = cx231xx_load_firmware(dev); | ||
1107 | if (retval < 0) { | ||
1108 | printk(KERN_ERR "%s() f/w load failed\n", __func__); | ||
1109 | return retval; | ||
1110 | } | ||
1111 | retval = cx231xx_find_mailbox(dev); | ||
1112 | if (retval < 0) { | ||
1113 | printk(KERN_ERR "%s() mailbox < 0, error\n", | ||
1114 | __func__); | ||
1115 | return -1; | ||
1116 | } | ||
1117 | dev->cx23417_mailbox = retval; | ||
1118 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); | ||
1119 | if (retval < 0) { | ||
1120 | printk(KERN_ERR | ||
1121 | "ERROR: cx23417 firmware ping failed!\n"); | ||
1122 | return -1; | ||
1123 | } | ||
1124 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, | ||
1125 | &version); | ||
1126 | if (retval < 0) { | ||
1127 | printk(KERN_ERR "ERROR: cx23417 firmware get encoder :" | ||
1128 | "version failed!\n"); | ||
1129 | return -1; | ||
1130 | } | ||
1131 | dprintk(1, "cx23417 firmware version is 0x%08x\n", version); | ||
1132 | msleep(200); | ||
1133 | } | ||
1134 | |||
1135 | for (i = 0; i < 1; i++) { | ||
1136 | retval = mc417_register_read(dev, 0x20f8, &val); | ||
1137 | dprintk(3, "***before enable656() VIM Capture Lines =%d ***\n", | ||
1138 | val); | ||
1139 | if (retval < 0) | ||
1140 | return retval; | ||
1141 | } | ||
1142 | |||
1143 | cx231xx_enable656(dev); | ||
1144 | /* stop mpeg capture */ | ||
1145 | cx231xx_api_cmd(dev, CX2341X_ENC_STOP_CAPTURE, | ||
1146 | 3, 0, 1, 3, 4); | ||
1147 | |||
1148 | cx231xx_codec_settings(dev); | ||
1149 | msleep(60); | ||
1150 | |||
1151 | /* cx231xx_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0, | ||
1152 | CX231xx_FIELD1_SAA7115, CX231xx_FIELD2_SAA7115); | ||
1153 | cx231xx_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0, | ||
1154 | CX231xx_CUSTOM_EXTENSION_USR_DATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
1155 | 0, 0); | ||
1156 | */ | ||
1157 | |||
1158 | #if 0 | ||
1159 | /* TODO */ | ||
1160 | u32 data[7]; | ||
1161 | |||
1162 | /* Setup to capture VBI */ | ||
1163 | data[0] = 0x0001BD00; | ||
1164 | data[1] = 1; /* frames per interrupt */ | ||
1165 | data[2] = 4; /* total bufs */ | ||
1166 | data[3] = 0x91559155; /* start codes */ | ||
1167 | data[4] = 0x206080C0; /* stop codes */ | ||
1168 | data[5] = 6; /* lines */ | ||
1169 | data[6] = 64; /* BPL */ | ||
1170 | |||
1171 | cx231xx_api_cmd(dev, CX2341X_ENC_SET_VBI_CONFIG, 7, 0, data[0], data[1], | ||
1172 | data[2], data[3], data[4], data[5], data[6]); | ||
1173 | |||
1174 | for (i = 2; i <= 24; i++) { | ||
1175 | int valid; | ||
1176 | |||
1177 | valid = ((i >= 19) && (i <= 21)); | ||
1178 | cx231xx_api_cmd(dev, CX2341X_ENC_SET_VBI_LINE, 5, 0, i, | ||
1179 | valid, 0 , 0, 0); | ||
1180 | cx231xx_api_cmd(dev, CX2341X_ENC_SET_VBI_LINE, 5, 0, | ||
1181 | i | 0x80000000, valid, 0, 0, 0); | ||
1182 | } | ||
1183 | #endif | ||
1184 | /* cx231xx_api_cmd(dev, CX2341X_ENC_MUTE_AUDIO, 1, 0, CX231xx_UNMUTE); | ||
1185 | msleep(60); | ||
1186 | */ | ||
1187 | /* initialize the video input */ | ||
1188 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0); | ||
1189 | if (retval < 0) | ||
1190 | return retval; | ||
1191 | msleep(60); | ||
1192 | |||
1193 | /* Enable VIP style pixel invalidation so we work with scaled mode */ | ||
1194 | mc417_memory_write(dev, 2120, 0x00000080); | ||
1195 | |||
1196 | /* start capturing to the host interface */ | ||
1197 | retval = cx231xx_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, | ||
1198 | CX231xx_MPEG_CAPTURE, CX231xx_RAW_BITS_NONE); | ||
1199 | if (retval < 0) | ||
1200 | return retval; | ||
1201 | msleep(10); | ||
1202 | |||
1203 | for (i = 0; i < 1; i++) { | ||
1204 | mc417_register_read(dev, 0x20f8, &val); | ||
1205 | dprintk(3, "***VIM Capture Lines =%d ***\n", val); | ||
1206 | } | ||
1207 | |||
1208 | return 0; | ||
1209 | } | ||
1210 | |||
1211 | /* ------------------------------------------------------------------ */ | ||
1212 | |||
1213 | static int bb_buf_setup(struct videobuf_queue *q, | ||
1214 | unsigned int *count, unsigned int *size) | ||
1215 | { | ||
1216 | struct cx231xx_fh *fh = q->priv_data; | ||
1217 | |||
1218 | fh->dev->ts1.ts_packet_size = mpeglinesize; | ||
1219 | fh->dev->ts1.ts_packet_count = mpeglines; | ||
1220 | |||
1221 | *size = fh->dev->ts1.ts_packet_size * fh->dev->ts1.ts_packet_count; | ||
1222 | *count = mpegbufs; | ||
1223 | |||
1224 | return 0; | ||
1225 | } | ||
1226 | static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) | ||
1227 | { | ||
1228 | struct cx231xx_fh *fh = vq->priv_data; | ||
1229 | struct cx231xx *dev = fh->dev; | ||
1230 | unsigned long flags = 0; | ||
1231 | |||
1232 | if (in_interrupt()) | ||
1233 | BUG(); | ||
1234 | |||
1235 | spin_lock_irqsave(&dev->video_mode.slock, flags); | ||
1236 | if (dev->USE_ISO) { | ||
1237 | if (dev->video_mode.isoc_ctl.buf == buf) | ||
1238 | dev->video_mode.isoc_ctl.buf = NULL; | ||
1239 | } else { | ||
1240 | if (dev->video_mode.bulk_ctl.buf == buf) | ||
1241 | dev->video_mode.bulk_ctl.buf = NULL; | ||
1242 | } | ||
1243 | spin_unlock_irqrestore(&dev->video_mode.slock, flags); | ||
1244 | videobuf_waiton(vq, &buf->vb, 0, 0); | ||
1245 | videobuf_vmalloc_free(&buf->vb); | ||
1246 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
1247 | } | ||
1248 | |||
1249 | static void buffer_copy(struct cx231xx *dev, char *data, int len, struct urb *urb, | ||
1250 | struct cx231xx_dmaqueue *dma_q) | ||
1251 | { | ||
1252 | void *vbuf; | ||
1253 | struct cx231xx_buffer *buf; | ||
1254 | u32 tail_data = 0; | ||
1255 | char *p_data; | ||
1256 | |||
1257 | if (dma_q->mpeg_buffer_done == 0) { | ||
1258 | if (list_empty(&dma_q->active)) | ||
1259 | return; | ||
1260 | |||
1261 | buf = list_entry(dma_q->active.next, | ||
1262 | struct cx231xx_buffer, vb.queue); | ||
1263 | dev->video_mode.isoc_ctl.buf = buf; | ||
1264 | dma_q->mpeg_buffer_done = 1; | ||
1265 | } | ||
1266 | /* Fill buffer */ | ||
1267 | buf = dev->video_mode.isoc_ctl.buf; | ||
1268 | vbuf = videobuf_to_vmalloc(&buf->vb); | ||
1269 | |||
1270 | if ((dma_q->mpeg_buffer_completed+len) < | ||
1271 | mpeglines*mpeglinesize) { | ||
1272 | if (dma_q->add_ps_package_head == | ||
1273 | CX231XX_NEED_ADD_PS_PACKAGE_HEAD) { | ||
1274 | memcpy(vbuf+dma_q->mpeg_buffer_completed, | ||
1275 | dma_q->ps_head, 3); | ||
1276 | dma_q->mpeg_buffer_completed = | ||
1277 | dma_q->mpeg_buffer_completed + 3; | ||
1278 | dma_q->add_ps_package_head = | ||
1279 | CX231XX_NONEED_PS_PACKAGE_HEAD; | ||
1280 | } | ||
1281 | memcpy(vbuf+dma_q->mpeg_buffer_completed, data, len); | ||
1282 | dma_q->mpeg_buffer_completed = | ||
1283 | dma_q->mpeg_buffer_completed + len; | ||
1284 | } else { | ||
1285 | dma_q->mpeg_buffer_done = 0; | ||
1286 | |||
1287 | tail_data = | ||
1288 | mpeglines*mpeglinesize - dma_q->mpeg_buffer_completed; | ||
1289 | memcpy(vbuf+dma_q->mpeg_buffer_completed, | ||
1290 | data, tail_data); | ||
1291 | |||
1292 | buf->vb.state = VIDEOBUF_DONE; | ||
1293 | buf->vb.field_count++; | ||
1294 | do_gettimeofday(&buf->vb.ts); | ||
1295 | list_del(&buf->vb.queue); | ||
1296 | wake_up(&buf->vb.done); | ||
1297 | dma_q->mpeg_buffer_completed = 0; | ||
1298 | |||
1299 | if (len - tail_data > 0) { | ||
1300 | p_data = data + tail_data; | ||
1301 | dma_q->left_data_count = len - tail_data; | ||
1302 | memcpy(dma_q->p_left_data, | ||
1303 | p_data, len - tail_data); | ||
1304 | } | ||
1305 | |||
1306 | } | ||
1307 | |||
1308 | return; | ||
1309 | } | ||
1310 | |||
1311 | static void buffer_filled(char *data, int len, struct urb *urb, | ||
1312 | struct cx231xx_dmaqueue *dma_q) | ||
1313 | { | ||
1314 | void *vbuf; | ||
1315 | struct cx231xx_buffer *buf; | ||
1316 | |||
1317 | if (list_empty(&dma_q->active)) | ||
1318 | return; | ||
1319 | |||
1320 | |||
1321 | buf = list_entry(dma_q->active.next, | ||
1322 | struct cx231xx_buffer, vb.queue); | ||
1323 | |||
1324 | |||
1325 | /* Fill buffer */ | ||
1326 | vbuf = videobuf_to_vmalloc(&buf->vb); | ||
1327 | memcpy(vbuf, data, len); | ||
1328 | buf->vb.state = VIDEOBUF_DONE; | ||
1329 | buf->vb.field_count++; | ||
1330 | do_gettimeofday(&buf->vb.ts); | ||
1331 | list_del(&buf->vb.queue); | ||
1332 | wake_up(&buf->vb.done); | ||
1333 | |||
1334 | return; | ||
1335 | } | ||
1336 | static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb) | ||
1337 | { | ||
1338 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
1339 | unsigned char *p_buffer; | ||
1340 | u32 buffer_size = 0; | ||
1341 | u32 i = 0; | ||
1342 | |||
1343 | for (i = 0; i < urb->number_of_packets; i++) { | ||
1344 | if (dma_q->left_data_count > 0) { | ||
1345 | buffer_copy(dev, dma_q->p_left_data, | ||
1346 | dma_q->left_data_count, urb, dma_q); | ||
1347 | dma_q->mpeg_buffer_completed = dma_q->left_data_count; | ||
1348 | dma_q->left_data_count = 0; | ||
1349 | } | ||
1350 | |||
1351 | p_buffer = urb->transfer_buffer + | ||
1352 | urb->iso_frame_desc[i].offset; | ||
1353 | buffer_size = urb->iso_frame_desc[i].actual_length; | ||
1354 | |||
1355 | if (buffer_size > 0) | ||
1356 | buffer_copy(dev, p_buffer, buffer_size, urb, dma_q); | ||
1357 | } | ||
1358 | |||
1359 | return 0; | ||
1360 | } | ||
1361 | static inline int cx231xx_bulk_copy(struct cx231xx *dev, struct urb *urb) | ||
1362 | { | ||
1363 | |||
1364 | /*char *outp;*/ | ||
1365 | /*struct cx231xx_buffer *buf;*/ | ||
1366 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
1367 | unsigned char *p_buffer, *buffer; | ||
1368 | u32 buffer_size = 0; | ||
1369 | |||
1370 | p_buffer = urb->transfer_buffer; | ||
1371 | buffer_size = urb->actual_length; | ||
1372 | |||
1373 | buffer = kmalloc(buffer_size, GFP_ATOMIC); | ||
1374 | |||
1375 | memcpy(buffer, dma_q->ps_head, 3); | ||
1376 | memcpy(buffer+3, p_buffer, buffer_size-3); | ||
1377 | memcpy(dma_q->ps_head, p_buffer+buffer_size-3, 3); | ||
1378 | |||
1379 | p_buffer = buffer; | ||
1380 | buffer_filled(p_buffer, buffer_size, urb, dma_q); | ||
1381 | |||
1382 | kfree(buffer); | ||
1383 | return 0; | ||
1384 | } | ||
1385 | |||
1386 | static int bb_buf_prepare(struct videobuf_queue *q, | ||
1387 | struct videobuf_buffer *vb, enum v4l2_field field) | ||
1388 | { | ||
1389 | struct cx231xx_fh *fh = q->priv_data; | ||
1390 | struct cx231xx_buffer *buf = | ||
1391 | container_of(vb, struct cx231xx_buffer, vb); | ||
1392 | struct cx231xx *dev = fh->dev; | ||
1393 | int rc = 0, urb_init = 0; | ||
1394 | int size = fh->dev->ts1.ts_packet_size * fh->dev->ts1.ts_packet_count; | ||
1395 | |||
1396 | dma_qq = &dev->video_mode.vidq; | ||
1397 | |||
1398 | if (0 != buf->vb.baddr && buf->vb.bsize < size) | ||
1399 | return -EINVAL; | ||
1400 | buf->vb.width = fh->dev->ts1.ts_packet_size; | ||
1401 | buf->vb.height = fh->dev->ts1.ts_packet_count; | ||
1402 | buf->vb.size = size; | ||
1403 | buf->vb.field = field; | ||
1404 | |||
1405 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
1406 | rc = videobuf_iolock(q, &buf->vb, NULL); | ||
1407 | if (rc < 0) | ||
1408 | goto fail; | ||
1409 | } | ||
1410 | |||
1411 | if (dev->USE_ISO) { | ||
1412 | if (!dev->video_mode.isoc_ctl.num_bufs) | ||
1413 | urb_init = 1; | ||
1414 | } else { | ||
1415 | if (!dev->video_mode.bulk_ctl.num_bufs) | ||
1416 | urb_init = 1; | ||
1417 | } | ||
1418 | /*cx231xx_info("urb_init=%d dev->video_mode.max_pkt_size=%d\n", | ||
1419 | urb_init, dev->video_mode.max_pkt_size);*/ | ||
1420 | dev->mode_tv = 1; | ||
1421 | |||
1422 | if (urb_init) { | ||
1423 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
1424 | rc = cx231xx_unmute_audio(dev); | ||
1425 | if (dev->USE_ISO) { | ||
1426 | cx231xx_set_alt_setting(dev, INDEX_TS1, 4); | ||
1427 | rc = cx231xx_init_isoc(dev, mpeglines, | ||
1428 | mpegbufs, | ||
1429 | dev->ts1_mode.max_pkt_size, | ||
1430 | cx231xx_isoc_copy); | ||
1431 | } else { | ||
1432 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); | ||
1433 | rc = cx231xx_init_bulk(dev, mpeglines, | ||
1434 | mpegbufs, | ||
1435 | dev->ts1_mode.max_pkt_size, | ||
1436 | cx231xx_bulk_copy); | ||
1437 | } | ||
1438 | if (rc < 0) | ||
1439 | goto fail; | ||
1440 | } | ||
1441 | |||
1442 | buf->vb.state = VIDEOBUF_PREPARED; | ||
1443 | return 0; | ||
1444 | |||
1445 | fail: | ||
1446 | free_buffer(q, buf); | ||
1447 | return rc; | ||
1448 | } | ||
1449 | |||
1450 | static void bb_buf_queue(struct videobuf_queue *q, | ||
1451 | struct videobuf_buffer *vb) | ||
1452 | { | ||
1453 | struct cx231xx_fh *fh = q->priv_data; | ||
1454 | |||
1455 | struct cx231xx_buffer *buf = | ||
1456 | container_of(vb, struct cx231xx_buffer, vb); | ||
1457 | struct cx231xx *dev = fh->dev; | ||
1458 | struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq; | ||
1459 | |||
1460 | buf->vb.state = VIDEOBUF_QUEUED; | ||
1461 | list_add_tail(&buf->vb.queue, &vidq->active); | ||
1462 | |||
1463 | } | ||
1464 | |||
1465 | static void bb_buf_release(struct videobuf_queue *q, | ||
1466 | struct videobuf_buffer *vb) | ||
1467 | { | ||
1468 | struct cx231xx_buffer *buf = | ||
1469 | container_of(vb, struct cx231xx_buffer, vb); | ||
1470 | /*struct cx231xx_fh *fh = q->priv_data;*/ | ||
1471 | /*struct cx231xx *dev = (struct cx231xx *)fh->dev;*/ | ||
1472 | |||
1473 | free_buffer(q, buf); | ||
1474 | } | ||
1475 | |||
1476 | static struct videobuf_queue_ops cx231xx_qops = { | ||
1477 | .buf_setup = bb_buf_setup, | ||
1478 | .buf_prepare = bb_buf_prepare, | ||
1479 | .buf_queue = bb_buf_queue, | ||
1480 | .buf_release = bb_buf_release, | ||
1481 | }; | ||
1482 | |||
1483 | /* ------------------------------------------------------------------ */ | ||
1484 | |||
1485 | static const u32 *ctrl_classes[] = { | ||
1486 | cx2341x_mpeg_ctrls, | ||
1487 | NULL | ||
1488 | }; | ||
1489 | |||
1490 | static int cx231xx_queryctrl(struct cx231xx *dev, | ||
1491 | struct v4l2_queryctrl *qctrl) | ||
1492 | { | ||
1493 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | ||
1494 | if (qctrl->id == 0) | ||
1495 | return -EINVAL; | ||
1496 | |||
1497 | /* MPEG V4L2 controls */ | ||
1498 | if (cx2341x_ctrl_query(&dev->mpeg_params, qctrl)) | ||
1499 | qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; | ||
1500 | |||
1501 | return 0; | ||
1502 | } | ||
1503 | |||
1504 | static int cx231xx_querymenu(struct cx231xx *dev, | ||
1505 | struct v4l2_querymenu *qmenu) | ||
1506 | { | ||
1507 | struct v4l2_queryctrl qctrl; | ||
1508 | |||
1509 | qctrl.id = qmenu->id; | ||
1510 | cx231xx_queryctrl(dev, &qctrl); | ||
1511 | return v4l2_ctrl_query_menu(qmenu, &qctrl, | ||
1512 | cx2341x_ctrl_get_menu(&dev->mpeg_params, qmenu->id)); | ||
1513 | } | ||
1514 | |||
1515 | static int vidioc_g_std(struct file *file, void *fh0, v4l2_std_id *norm) | ||
1516 | { | ||
1517 | struct cx231xx_fh *fh = file->private_data; | ||
1518 | struct cx231xx *dev = fh->dev; | ||
1519 | |||
1520 | *norm = dev->encodernorm.id; | ||
1521 | return 0; | ||
1522 | } | ||
1523 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id) | ||
1524 | { | ||
1525 | struct cx231xx_fh *fh = file->private_data; | ||
1526 | struct cx231xx *dev = fh->dev; | ||
1527 | unsigned int i; | ||
1528 | |||
1529 | for (i = 0; i < ARRAY_SIZE(cx231xx_tvnorms); i++) | ||
1530 | if (*id & cx231xx_tvnorms[i].id) | ||
1531 | break; | ||
1532 | if (i == ARRAY_SIZE(cx231xx_tvnorms)) | ||
1533 | return -EINVAL; | ||
1534 | dev->encodernorm = cx231xx_tvnorms[i]; | ||
1535 | |||
1536 | if (dev->encodernorm.id & 0xb000) { | ||
1537 | dprintk(3, "encodernorm set to NTSC\n"); | ||
1538 | dev->norm = V4L2_STD_NTSC; | ||
1539 | dev->ts1.height = 480; | ||
1540 | dev->mpeg_params.is_50hz = 0; | ||
1541 | } else { | ||
1542 | dprintk(3, "encodernorm set to PAL\n"); | ||
1543 | dev->norm = V4L2_STD_PAL_B; | ||
1544 | dev->ts1.height = 576; | ||
1545 | dev->mpeg_params.is_50hz = 1; | ||
1546 | } | ||
1547 | call_all(dev, core, s_std, dev->norm); | ||
1548 | /* do mode control overrides */ | ||
1549 | cx231xx_do_mode_ctrl_overrides(dev); | ||
1550 | |||
1551 | dprintk(3, "exit vidioc_s_std() i=0x%x\n", i); | ||
1552 | return 0; | ||
1553 | } | ||
1554 | static int vidioc_g_audio(struct file *file, void *fh, | ||
1555 | struct v4l2_audio *a) | ||
1556 | { | ||
1557 | struct v4l2_audio *vin = a; | ||
1558 | |||
1559 | int ret = -EINVAL; | ||
1560 | if (vin->index > 0) | ||
1561 | return ret; | ||
1562 | strncpy(vin->name, "VideoGrabber Audio", 14); | ||
1563 | vin->capability = V4L2_AUDCAP_STEREO; | ||
1564 | return 0; | ||
1565 | } | ||
1566 | static int vidioc_enumaudio(struct file *file, void *fh, | ||
1567 | struct v4l2_audio *a) | ||
1568 | { | ||
1569 | struct v4l2_audio *vin = a; | ||
1570 | |||
1571 | int ret = -EINVAL; | ||
1572 | |||
1573 | if (vin->index > 0) | ||
1574 | return ret; | ||
1575 | strncpy(vin->name, "VideoGrabber Audio", 14); | ||
1576 | vin->capability = V4L2_AUDCAP_STEREO; | ||
1577 | |||
1578 | |||
1579 | return 0; | ||
1580 | } | ||
1581 | static const char *iname[] = { | ||
1582 | [CX231XX_VMUX_COMPOSITE1] = "Composite1", | ||
1583 | [CX231XX_VMUX_SVIDEO] = "S-Video", | ||
1584 | [CX231XX_VMUX_TELEVISION] = "Television", | ||
1585 | [CX231XX_VMUX_CABLE] = "Cable TV", | ||
1586 | [CX231XX_VMUX_DVB] = "DVB", | ||
1587 | [CX231XX_VMUX_DEBUG] = "for debug only", | ||
1588 | }; | ||
1589 | static int vidioc_enum_input(struct file *file, void *priv, | ||
1590 | struct v4l2_input *i) | ||
1591 | { | ||
1592 | struct cx231xx_fh *fh = file->private_data; | ||
1593 | struct cx231xx *dev = fh->dev; | ||
1594 | struct cx231xx_input *input; | ||
1595 | int n; | ||
1596 | dprintk(3, "enter vidioc_enum_input()i->index=%d\n", i->index); | ||
1597 | |||
1598 | if (i->index >= 4) | ||
1599 | return -EINVAL; | ||
1600 | |||
1601 | |||
1602 | input = &cx231xx_boards[dev->model].input[i->index]; | ||
1603 | |||
1604 | if (input->type == 0) | ||
1605 | return -EINVAL; | ||
1606 | |||
1607 | /* FIXME | ||
1608 | * strcpy(i->name, input->name); */ | ||
1609 | |||
1610 | n = i->index; | ||
1611 | strcpy(i->name, iname[INPUT(n)->type]); | ||
1612 | |||
1613 | if (input->type == CX231XX_VMUX_TELEVISION || | ||
1614 | input->type == CX231XX_VMUX_CABLE) | ||
1615 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
1616 | else | ||
1617 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
1618 | |||
1619 | |||
1620 | return 0; | ||
1621 | } | ||
1622 | |||
1623 | static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) | ||
1624 | { | ||
1625 | *i = 0; | ||
1626 | return 0; | ||
1627 | } | ||
1628 | |||
1629 | static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | ||
1630 | { | ||
1631 | struct cx231xx_fh *fh = file->private_data; | ||
1632 | struct cx231xx *dev = fh->dev; | ||
1633 | |||
1634 | dprintk(3, "enter vidioc_s_input() i=%d\n", i); | ||
1635 | |||
1636 | mutex_lock(&dev->lock); | ||
1637 | |||
1638 | video_mux(dev, i); | ||
1639 | |||
1640 | mutex_unlock(&dev->lock); | ||
1641 | |||
1642 | if (i >= 4) | ||
1643 | return -EINVAL; | ||
1644 | dev->input = i; | ||
1645 | dprintk(3, "exit vidioc_s_input()\n"); | ||
1646 | return 0; | ||
1647 | } | ||
1648 | |||
1649 | static int vidioc_g_tuner(struct file *file, void *priv, | ||
1650 | struct v4l2_tuner *t) | ||
1651 | { | ||
1652 | return 0; | ||
1653 | } | ||
1654 | |||
1655 | static int vidioc_s_tuner(struct file *file, void *priv, | ||
1656 | struct v4l2_tuner *t) | ||
1657 | { | ||
1658 | return 0; | ||
1659 | } | ||
1660 | |||
1661 | static int vidioc_g_frequency(struct file *file, void *priv, | ||
1662 | struct v4l2_frequency *f) | ||
1663 | { | ||
1664 | return 0; | ||
1665 | } | ||
1666 | |||
1667 | static int vidioc_s_frequency(struct file *file, void *priv, | ||
1668 | struct v4l2_frequency *f) | ||
1669 | { | ||
1670 | |||
1671 | |||
1672 | return 0; | ||
1673 | } | ||
1674 | |||
1675 | static int vidioc_s_ctrl(struct file *file, void *priv, | ||
1676 | struct v4l2_control *ctl) | ||
1677 | { | ||
1678 | struct cx231xx_fh *fh = file->private_data; | ||
1679 | struct cx231xx *dev = fh->dev; | ||
1680 | dprintk(3, "enter vidioc_s_ctrl()\n"); | ||
1681 | /* Update the A/V core */ | ||
1682 | call_all(dev, core, s_ctrl, ctl); | ||
1683 | dprintk(3, "exit vidioc_s_ctrl()\n"); | ||
1684 | return 0; | ||
1685 | } | ||
1686 | static struct v4l2_capability pvr_capability = { | ||
1687 | .driver = "cx231xx", | ||
1688 | .card = "VideoGrabber", | ||
1689 | .bus_info = "usb", | ||
1690 | .version = 1, | ||
1691 | .capabilities = (V4L2_CAP_VIDEO_CAPTURE | | ||
1692 | V4L2_CAP_TUNER | V4L2_CAP_AUDIO | V4L2_CAP_RADIO | | ||
1693 | V4L2_CAP_STREAMING | V4L2_CAP_READWRITE), | ||
1694 | }; | ||
1695 | static int vidioc_querycap(struct file *file, void *priv, | ||
1696 | struct v4l2_capability *cap) | ||
1697 | { | ||
1698 | |||
1699 | |||
1700 | |||
1701 | memcpy(cap, &pvr_capability, sizeof(struct v4l2_capability)); | ||
1702 | return 0; | ||
1703 | } | ||
1704 | |||
1705 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, | ||
1706 | struct v4l2_fmtdesc *f) | ||
1707 | { | ||
1708 | |||
1709 | if (f->index != 0) | ||
1710 | return -EINVAL; | ||
1711 | |||
1712 | strlcpy(f->description, "MPEG", sizeof(f->description)); | ||
1713 | f->pixelformat = V4L2_PIX_FMT_MPEG; | ||
1714 | |||
1715 | return 0; | ||
1716 | } | ||
1717 | |||
1718 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | ||
1719 | struct v4l2_format *f) | ||
1720 | { | ||
1721 | struct cx231xx_fh *fh = file->private_data; | ||
1722 | struct cx231xx *dev = fh->dev; | ||
1723 | dprintk(3, "enter vidioc_g_fmt_vid_cap()\n"); | ||
1724 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | ||
1725 | f->fmt.pix.bytesperline = 0; | ||
1726 | f->fmt.pix.sizeimage = | ||
1727 | dev->ts1.ts_packet_size * dev->ts1.ts_packet_count; | ||
1728 | f->fmt.pix.colorspace = 0; | ||
1729 | f->fmt.pix.width = dev->ts1.width; | ||
1730 | f->fmt.pix.height = dev->ts1.height; | ||
1731 | f->fmt.pix.field = fh->vidq.field; | ||
1732 | dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n", | ||
1733 | dev->ts1.width, dev->ts1.height, fh->vidq.field); | ||
1734 | dprintk(3, "exit vidioc_g_fmt_vid_cap()\n"); | ||
1735 | return 0; | ||
1736 | } | ||
1737 | |||
1738 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | ||
1739 | struct v4l2_format *f) | ||
1740 | { | ||
1741 | struct cx231xx_fh *fh = file->private_data; | ||
1742 | struct cx231xx *dev = fh->dev; | ||
1743 | dprintk(3, "enter vidioc_try_fmt_vid_cap()\n"); | ||
1744 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | ||
1745 | f->fmt.pix.bytesperline = 0; | ||
1746 | f->fmt.pix.sizeimage = | ||
1747 | dev->ts1.ts_packet_size * dev->ts1.ts_packet_count; | ||
1748 | f->fmt.pix.colorspace = 0; | ||
1749 | dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n", | ||
1750 | dev->ts1.width, dev->ts1.height, fh->vidq.field); | ||
1751 | dprintk(3, "exit vidioc_try_fmt_vid_cap()\n"); | ||
1752 | return 0; | ||
1753 | } | ||
1754 | |||
1755 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | ||
1756 | struct v4l2_format *f) | ||
1757 | { | ||
1758 | |||
1759 | return 0; | ||
1760 | } | ||
1761 | |||
1762 | static int vidioc_reqbufs(struct file *file, void *priv, | ||
1763 | struct v4l2_requestbuffers *p) | ||
1764 | { | ||
1765 | struct cx231xx_fh *fh = file->private_data; | ||
1766 | |||
1767 | return videobuf_reqbufs(&fh->vidq, p); | ||
1768 | } | ||
1769 | |||
1770 | static int vidioc_querybuf(struct file *file, void *priv, | ||
1771 | struct v4l2_buffer *p) | ||
1772 | { | ||
1773 | struct cx231xx_fh *fh = file->private_data; | ||
1774 | |||
1775 | return videobuf_querybuf(&fh->vidq, p); | ||
1776 | } | ||
1777 | |||
1778 | static int vidioc_qbuf(struct file *file, void *priv, | ||
1779 | struct v4l2_buffer *p) | ||
1780 | { | ||
1781 | struct cx231xx_fh *fh = file->private_data; | ||
1782 | |||
1783 | return videobuf_qbuf(&fh->vidq, p); | ||
1784 | } | ||
1785 | |||
1786 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
1787 | { | ||
1788 | struct cx231xx_fh *fh = priv; | ||
1789 | |||
1790 | return videobuf_dqbuf(&fh->vidq, b, file->f_flags & O_NONBLOCK); | ||
1791 | } | ||
1792 | |||
1793 | |||
1794 | static int vidioc_streamon(struct file *file, void *priv, | ||
1795 | enum v4l2_buf_type i) | ||
1796 | { | ||
1797 | struct cx231xx_fh *fh = file->private_data; | ||
1798 | |||
1799 | struct cx231xx *dev = fh->dev; | ||
1800 | dprintk(3, "enter vidioc_streamon()\n"); | ||
1801 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); | ||
1802 | cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
1803 | if (dev->USE_ISO) | ||
1804 | cx231xx_init_isoc(dev, CX231XX_NUM_PACKETS, | ||
1805 | CX231XX_NUM_BUFS, | ||
1806 | dev->video_mode.max_pkt_size, | ||
1807 | cx231xx_isoc_copy); | ||
1808 | else { | ||
1809 | cx231xx_init_bulk(dev, 320, | ||
1810 | 5, | ||
1811 | dev->ts1_mode.max_pkt_size, | ||
1812 | cx231xx_bulk_copy); | ||
1813 | } | ||
1814 | dprintk(3, "exit vidioc_streamon()\n"); | ||
1815 | return videobuf_streamon(&fh->vidq); | ||
1816 | } | ||
1817 | |||
1818 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | ||
1819 | { | ||
1820 | struct cx231xx_fh *fh = file->private_data; | ||
1821 | |||
1822 | return videobuf_streamoff(&fh->vidq); | ||
1823 | } | ||
1824 | |||
1825 | static int vidioc_g_ext_ctrls(struct file *file, void *priv, | ||
1826 | struct v4l2_ext_controls *f) | ||
1827 | { | ||
1828 | struct cx231xx_fh *fh = priv; | ||
1829 | struct cx231xx *dev = fh->dev; | ||
1830 | dprintk(3, "enter vidioc_g_ext_ctrls()\n"); | ||
1831 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
1832 | return -EINVAL; | ||
1833 | dprintk(3, "exit vidioc_g_ext_ctrls()\n"); | ||
1834 | return cx2341x_ext_ctrls(&dev->mpeg_params, 0, f, VIDIOC_G_EXT_CTRLS); | ||
1835 | } | ||
1836 | |||
1837 | static int vidioc_s_ext_ctrls(struct file *file, void *priv, | ||
1838 | struct v4l2_ext_controls *f) | ||
1839 | { | ||
1840 | struct cx231xx_fh *fh = priv; | ||
1841 | struct cx231xx *dev = fh->dev; | ||
1842 | struct cx2341x_mpeg_params p; | ||
1843 | int err; | ||
1844 | dprintk(3, "enter vidioc_s_ext_ctrls()\n"); | ||
1845 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
1846 | return -EINVAL; | ||
1847 | |||
1848 | p = dev->mpeg_params; | ||
1849 | err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_TRY_EXT_CTRLS); | ||
1850 | if (err == 0) { | ||
1851 | err = cx2341x_update(dev, cx231xx_mbox_func, | ||
1852 | &dev->mpeg_params, &p); | ||
1853 | dev->mpeg_params = p; | ||
1854 | } | ||
1855 | |||
1856 | return err; | ||
1857 | |||
1858 | |||
1859 | return 0; | ||
1860 | } | ||
1861 | |||
1862 | static int vidioc_try_ext_ctrls(struct file *file, void *priv, | ||
1863 | struct v4l2_ext_controls *f) | ||
1864 | { | ||
1865 | struct cx231xx_fh *fh = priv; | ||
1866 | struct cx231xx *dev = fh->dev; | ||
1867 | struct cx2341x_mpeg_params p; | ||
1868 | int err; | ||
1869 | dprintk(3, "enter vidioc_try_ext_ctrls()\n"); | ||
1870 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
1871 | return -EINVAL; | ||
1872 | |||
1873 | p = dev->mpeg_params; | ||
1874 | err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_TRY_EXT_CTRLS); | ||
1875 | dprintk(3, "exit vidioc_try_ext_ctrls() err=%d\n", err); | ||
1876 | return err; | ||
1877 | } | ||
1878 | |||
1879 | static int vidioc_log_status(struct file *file, void *priv) | ||
1880 | { | ||
1881 | struct cx231xx_fh *fh = priv; | ||
1882 | struct cx231xx *dev = fh->dev; | ||
1883 | char name[32 + 2]; | ||
1884 | |||
1885 | snprintf(name, sizeof(name), "%s/2", dev->name); | ||
1886 | dprintk(3, | ||
1887 | "%s/2: ============ START LOG STATUS ============\n", | ||
1888 | dev->name); | ||
1889 | call_all(dev, core, log_status); | ||
1890 | cx2341x_log_status(&dev->mpeg_params, name); | ||
1891 | dprintk(3, | ||
1892 | "%s/2: ============= END LOG STATUS =============\n", | ||
1893 | dev->name); | ||
1894 | return 0; | ||
1895 | } | ||
1896 | |||
1897 | static int vidioc_querymenu(struct file *file, void *priv, | ||
1898 | struct v4l2_querymenu *a) | ||
1899 | { | ||
1900 | struct cx231xx_fh *fh = priv; | ||
1901 | struct cx231xx *dev = fh->dev; | ||
1902 | dprintk(3, "enter vidioc_querymenu()\n"); | ||
1903 | dprintk(3, "exit vidioc_querymenu()\n"); | ||
1904 | return cx231xx_querymenu(dev, a); | ||
1905 | } | ||
1906 | |||
1907 | static int vidioc_queryctrl(struct file *file, void *priv, | ||
1908 | struct v4l2_queryctrl *c) | ||
1909 | { | ||
1910 | struct cx231xx_fh *fh = priv; | ||
1911 | struct cx231xx *dev = fh->dev; | ||
1912 | dprintk(3, "enter vidioc_queryctrl()\n"); | ||
1913 | dprintk(3, "exit vidioc_queryctrl()\n"); | ||
1914 | return cx231xx_queryctrl(dev, c); | ||
1915 | } | ||
1916 | |||
1917 | static int mpeg_open(struct file *file) | ||
1918 | { | ||
1919 | int minor = video_devdata(file)->minor; | ||
1920 | struct cx231xx *h, *dev = NULL; | ||
1921 | /*struct list_head *list;*/ | ||
1922 | struct cx231xx_fh *fh; | ||
1923 | /*u32 value = 0;*/ | ||
1924 | |||
1925 | dprintk(2, "%s()\n", __func__); | ||
1926 | |||
1927 | list_for_each_entry(h, &cx231xx_devlist, devlist) { | ||
1928 | if (h->v4l_device->minor == minor) | ||
1929 | dev = h; | ||
1930 | } | ||
1931 | |||
1932 | if (dev == NULL) | ||
1933 | return -ENODEV; | ||
1934 | |||
1935 | mutex_lock(&dev->lock); | ||
1936 | |||
1937 | /* allocate + initialize per filehandle data */ | ||
1938 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | ||
1939 | if (NULL == fh) { | ||
1940 | mutex_unlock(&dev->lock); | ||
1941 | return -ENOMEM; | ||
1942 | } | ||
1943 | |||
1944 | file->private_data = fh; | ||
1945 | fh->dev = dev; | ||
1946 | |||
1947 | |||
1948 | videobuf_queue_vmalloc_init(&fh->vidq, &cx231xx_qops, | ||
1949 | NULL, &dev->video_mode.slock, | ||
1950 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_INTERLACED, | ||
1951 | sizeof(struct cx231xx_buffer), fh, NULL); | ||
1952 | /* | ||
1953 | videobuf_queue_sg_init(&fh->vidq, &cx231xx_qops, | ||
1954 | &dev->udev->dev, &dev->ts1.slock, | ||
1955 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | ||
1956 | V4L2_FIELD_INTERLACED, | ||
1957 | sizeof(struct cx231xx_buffer), | ||
1958 | fh, NULL); | ||
1959 | */ | ||
1960 | |||
1961 | |||
1962 | cx231xx_set_alt_setting(dev, INDEX_VANC, 1); | ||
1963 | cx231xx_set_gpio_value(dev, 2, 0); | ||
1964 | |||
1965 | cx231xx_initialize_codec(dev); | ||
1966 | |||
1967 | mutex_unlock(&dev->lock); | ||
1968 | cx231xx_start_TS1(dev); | ||
1969 | |||
1970 | return 0; | ||
1971 | } | ||
1972 | |||
1973 | static int mpeg_release(struct file *file) | ||
1974 | { | ||
1975 | struct cx231xx_fh *fh = file->private_data; | ||
1976 | struct cx231xx *dev = fh->dev; | ||
1977 | |||
1978 | dprintk(3, "mpeg_release()! dev=0x%p\n", dev); | ||
1979 | |||
1980 | if (!dev) { | ||
1981 | dprintk(3, "abort!!!\n"); | ||
1982 | return 0; | ||
1983 | } | ||
1984 | |||
1985 | mutex_lock(&dev->lock); | ||
1986 | |||
1987 | cx231xx_stop_TS1(dev); | ||
1988 | |||
1989 | /* do this before setting alternate! */ | ||
1990 | if (dev->USE_ISO) | ||
1991 | cx231xx_uninit_isoc(dev); | ||
1992 | else | ||
1993 | cx231xx_uninit_bulk(dev); | ||
1994 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
1995 | |||
1996 | cx231xx_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, | ||
1997 | CX231xx_END_NOW, CX231xx_MPEG_CAPTURE, | ||
1998 | CX231xx_RAW_BITS_NONE); | ||
1999 | |||
2000 | /* FIXME: Review this crap */ | ||
2001 | /* Shut device down on last close */ | ||
2002 | if (atomic_cmpxchg(&fh->v4l_reading, 1, 0) == 1) { | ||
2003 | if (atomic_dec_return(&dev->v4l_reader_count) == 0) { | ||
2004 | /* stop mpeg capture */ | ||
2005 | |||
2006 | msleep(500); | ||
2007 | cx231xx_417_check_encoder(dev); | ||
2008 | |||
2009 | } | ||
2010 | } | ||
2011 | |||
2012 | if (fh->vidq.streaming) | ||
2013 | videobuf_streamoff(&fh->vidq); | ||
2014 | if (fh->vidq.reading) | ||
2015 | videobuf_read_stop(&fh->vidq); | ||
2016 | |||
2017 | videobuf_mmap_free(&fh->vidq); | ||
2018 | file->private_data = NULL; | ||
2019 | kfree(fh); | ||
2020 | mutex_unlock(&dev->lock); | ||
2021 | return 0; | ||
2022 | } | ||
2023 | |||
2024 | static ssize_t mpeg_read(struct file *file, char __user *data, | ||
2025 | size_t count, loff_t *ppos) | ||
2026 | { | ||
2027 | struct cx231xx_fh *fh = file->private_data; | ||
2028 | struct cx231xx *dev = fh->dev; | ||
2029 | |||
2030 | |||
2031 | /* Deal w/ A/V decoder * and mpeg encoder sync issues. */ | ||
2032 | /* Start mpeg encoder on first read. */ | ||
2033 | if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) { | ||
2034 | if (atomic_inc_return(&dev->v4l_reader_count) == 1) { | ||
2035 | if (cx231xx_initialize_codec(dev) < 0) | ||
2036 | return -EINVAL; | ||
2037 | } | ||
2038 | } | ||
2039 | |||
2040 | return videobuf_read_stream(&fh->vidq, data, count, ppos, 0, | ||
2041 | file->f_flags & O_NONBLOCK); | ||
2042 | } | ||
2043 | |||
2044 | static unsigned int mpeg_poll(struct file *file, | ||
2045 | struct poll_table_struct *wait) | ||
2046 | { | ||
2047 | struct cx231xx_fh *fh = file->private_data; | ||
2048 | /*struct cx231xx *dev = fh->dev;*/ | ||
2049 | |||
2050 | /*dprintk(2, "%s\n", __func__);*/ | ||
2051 | |||
2052 | return videobuf_poll_stream(file, &fh->vidq, wait); | ||
2053 | } | ||
2054 | |||
2055 | static int mpeg_mmap(struct file *file, struct vm_area_struct *vma) | ||
2056 | { | ||
2057 | struct cx231xx_fh *fh = file->private_data; | ||
2058 | struct cx231xx *dev = fh->dev; | ||
2059 | |||
2060 | dprintk(2, "%s()\n", __func__); | ||
2061 | |||
2062 | return videobuf_mmap_mapper(&fh->vidq, vma); | ||
2063 | } | ||
2064 | |||
2065 | static struct v4l2_file_operations mpeg_fops = { | ||
2066 | .owner = THIS_MODULE, | ||
2067 | .open = mpeg_open, | ||
2068 | .release = mpeg_release, | ||
2069 | .read = mpeg_read, | ||
2070 | .poll = mpeg_poll, | ||
2071 | .mmap = mpeg_mmap, | ||
2072 | .ioctl = video_ioctl2, | ||
2073 | }; | ||
2074 | |||
2075 | static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { | ||
2076 | .vidioc_s_std = vidioc_s_std, | ||
2077 | .vidioc_g_std = vidioc_g_std, | ||
2078 | .vidioc_enum_input = vidioc_enum_input, | ||
2079 | .vidioc_enumaudio = vidioc_enumaudio, | ||
2080 | .vidioc_g_audio = vidioc_g_audio, | ||
2081 | .vidioc_g_input = vidioc_g_input, | ||
2082 | .vidioc_s_input = vidioc_s_input, | ||
2083 | .vidioc_g_tuner = vidioc_g_tuner, | ||
2084 | .vidioc_s_tuner = vidioc_s_tuner, | ||
2085 | .vidioc_g_frequency = vidioc_g_frequency, | ||
2086 | .vidioc_s_frequency = vidioc_s_frequency, | ||
2087 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
2088 | .vidioc_querycap = vidioc_querycap, | ||
2089 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, | ||
2090 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | ||
2091 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | ||
2092 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | ||
2093 | .vidioc_reqbufs = vidioc_reqbufs, | ||
2094 | .vidioc_querybuf = vidioc_querybuf, | ||
2095 | .vidioc_qbuf = vidioc_qbuf, | ||
2096 | .vidioc_dqbuf = vidioc_dqbuf, | ||
2097 | .vidioc_streamon = vidioc_streamon, | ||
2098 | .vidioc_streamoff = vidioc_streamoff, | ||
2099 | .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls, | ||
2100 | .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls, | ||
2101 | .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, | ||
2102 | .vidioc_log_status = vidioc_log_status, | ||
2103 | .vidioc_querymenu = vidioc_querymenu, | ||
2104 | .vidioc_queryctrl = vidioc_queryctrl, | ||
2105 | /* .vidioc_g_chip_ident = cx231xx_g_chip_ident,*/ | ||
2106 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
2107 | /* .vidioc_g_register = cx231xx_g_register,*/ | ||
2108 | /* .vidioc_s_register = cx231xx_s_register,*/ | ||
2109 | #endif | ||
2110 | }; | ||
2111 | |||
2112 | static struct video_device cx231xx_mpeg_template = { | ||
2113 | .name = "cx231xx", | ||
2114 | .fops = &mpeg_fops, | ||
2115 | .ioctl_ops = &mpeg_ioctl_ops, | ||
2116 | .minor = -1, | ||
2117 | .tvnorms = CX231xx_NORMS, | ||
2118 | .current_norm = V4L2_STD_NTSC_M, | ||
2119 | }; | ||
2120 | |||
2121 | void cx231xx_417_unregister(struct cx231xx *dev) | ||
2122 | { | ||
2123 | dprintk(1, "%s()\n", __func__); | ||
2124 | dprintk(3, "%s()\n", __func__); | ||
2125 | |||
2126 | if (dev->v4l_device) { | ||
2127 | if (-1 != dev->v4l_device->minor) | ||
2128 | video_unregister_device(dev->v4l_device); | ||
2129 | else | ||
2130 | video_device_release(dev->v4l_device); | ||
2131 | dev->v4l_device = NULL; | ||
2132 | } | ||
2133 | } | ||
2134 | |||
2135 | static struct video_device *cx231xx_video_dev_alloc( | ||
2136 | struct cx231xx *dev, | ||
2137 | struct usb_device *usbdev, | ||
2138 | struct video_device *template, | ||
2139 | char *type) | ||
2140 | { | ||
2141 | struct video_device *vfd; | ||
2142 | |||
2143 | dprintk(1, "%s()\n", __func__); | ||
2144 | vfd = video_device_alloc(); | ||
2145 | if (NULL == vfd) | ||
2146 | return NULL; | ||
2147 | *vfd = *template; | ||
2148 | vfd->minor = -1; | ||
2149 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, | ||
2150 | type, cx231xx_boards[dev->model].name); | ||
2151 | |||
2152 | vfd->v4l2_dev = &dev->v4l2_dev; | ||
2153 | vfd->release = video_device_release; | ||
2154 | |||
2155 | return vfd; | ||
2156 | |||
2157 | } | ||
2158 | |||
2159 | int cx231xx_417_register(struct cx231xx *dev) | ||
2160 | { | ||
2161 | /* FIXME: Port1 hardcoded here */ | ||
2162 | int err = -ENODEV; | ||
2163 | struct cx231xx_tsport *tsport = &dev->ts1; | ||
2164 | |||
2165 | dprintk(1, "%s()\n", __func__); | ||
2166 | |||
2167 | /* Set default TV standard */ | ||
2168 | dev->encodernorm = cx231xx_tvnorms[0]; | ||
2169 | |||
2170 | if (dev->encodernorm.id & V4L2_STD_525_60) | ||
2171 | tsport->height = 480; | ||
2172 | else | ||
2173 | tsport->height = 576; | ||
2174 | |||
2175 | tsport->width = 720; | ||
2176 | cx2341x_fill_defaults(&dev->mpeg_params); | ||
2177 | dev->norm = V4L2_STD_NTSC; | ||
2178 | |||
2179 | dev->mpeg_params.port = CX2341X_PORT_SERIAL; | ||
2180 | |||
2181 | /* Allocate and initialize V4L video device */ | ||
2182 | dev->v4l_device = cx231xx_video_dev_alloc(dev, | ||
2183 | dev->udev, &cx231xx_mpeg_template, "mpeg"); | ||
2184 | err = video_register_device(dev->v4l_device, | ||
2185 | VFL_TYPE_GRABBER, -1); | ||
2186 | if (err < 0) { | ||
2187 | dprintk(3, "%s: can't register mpeg device\n", dev->name); | ||
2188 | return err; | ||
2189 | } | ||
2190 | |||
2191 | dprintk(3, "%s: registered device video%d [mpeg]\n", | ||
2192 | dev->name, dev->v4l_device->num); | ||
2193 | |||
2194 | return 0; | ||
2195 | } | ||
2196 | |||
2197 | MODULE_FIRMWARE(CX231xx_FIRM_IMAGE_NAME); | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c new file mode 100644 index 000000000000..b4c99c7270cf --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-audio.c | |||
@@ -0,0 +1,780 @@ | |||
1 | /* | ||
2 | * Conexant Cx231xx audio extension | ||
3 | * | ||
4 | * Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | * Based on em28xx driver | ||
6 | * | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/usb.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/sound.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/soundcard.h> | ||
29 | #include <linux/slab.h> | ||
30 | #include <linux/vmalloc.h> | ||
31 | #include <linux/proc_fs.h> | ||
32 | #include <linux/module.h> | ||
33 | #include <sound/core.h> | ||
34 | #include <sound/pcm.h> | ||
35 | #include <sound/pcm_params.h> | ||
36 | #include <sound/info.h> | ||
37 | #include <sound/initval.h> | ||
38 | #include <sound/control.h> | ||
39 | #include <media/v4l2-common.h> | ||
40 | #include "cx231xx.h" | ||
41 | |||
42 | static int debug; | ||
43 | module_param(debug, int, 0644); | ||
44 | MODULE_PARM_DESC(debug, "activates debug info"); | ||
45 | |||
46 | #define dprintk(fmt, arg...) do { \ | ||
47 | if (debug) \ | ||
48 | printk(KERN_INFO "cx231xx-audio %s: " fmt, \ | ||
49 | __func__, ##arg); \ | ||
50 | } while (0) | ||
51 | |||
52 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | ||
53 | |||
54 | static int cx231xx_isoc_audio_deinit(struct cx231xx *dev) | ||
55 | { | ||
56 | int i; | ||
57 | |||
58 | dprintk("Stopping isoc\n"); | ||
59 | |||
60 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
61 | if (dev->adev.urb[i]) { | ||
62 | if (!irqs_disabled()) | ||
63 | usb_kill_urb(dev->adev.urb[i]); | ||
64 | else | ||
65 | usb_unlink_urb(dev->adev.urb[i]); | ||
66 | |||
67 | usb_free_urb(dev->adev.urb[i]); | ||
68 | dev->adev.urb[i] = NULL; | ||
69 | |||
70 | kfree(dev->adev.transfer_buffer[i]); | ||
71 | dev->adev.transfer_buffer[i] = NULL; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static int cx231xx_bulk_audio_deinit(struct cx231xx *dev) | ||
79 | { | ||
80 | int i; | ||
81 | |||
82 | dprintk("Stopping bulk\n"); | ||
83 | |||
84 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
85 | if (dev->adev.urb[i]) { | ||
86 | if (!irqs_disabled()) | ||
87 | usb_kill_urb(dev->adev.urb[i]); | ||
88 | else | ||
89 | usb_unlink_urb(dev->adev.urb[i]); | ||
90 | |||
91 | usb_free_urb(dev->adev.urb[i]); | ||
92 | dev->adev.urb[i] = NULL; | ||
93 | |||
94 | kfree(dev->adev.transfer_buffer[i]); | ||
95 | dev->adev.transfer_buffer[i] = NULL; | ||
96 | } | ||
97 | } | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static void cx231xx_audio_isocirq(struct urb *urb) | ||
103 | { | ||
104 | struct cx231xx *dev = urb->context; | ||
105 | int i; | ||
106 | unsigned int oldptr; | ||
107 | int period_elapsed = 0; | ||
108 | int status; | ||
109 | unsigned char *cp; | ||
110 | unsigned int stride; | ||
111 | struct snd_pcm_substream *substream; | ||
112 | struct snd_pcm_runtime *runtime; | ||
113 | |||
114 | if (dev->state & DEV_DISCONNECTED) | ||
115 | return; | ||
116 | |||
117 | switch (urb->status) { | ||
118 | case 0: /* success */ | ||
119 | case -ETIMEDOUT: /* NAK */ | ||
120 | break; | ||
121 | case -ECONNRESET: /* kill */ | ||
122 | case -ENOENT: | ||
123 | case -ESHUTDOWN: | ||
124 | return; | ||
125 | default: /* error */ | ||
126 | dprintk("urb completition error %d.\n", urb->status); | ||
127 | break; | ||
128 | } | ||
129 | |||
130 | if (atomic_read(&dev->stream_started) == 0) | ||
131 | return; | ||
132 | |||
133 | if (dev->adev.capture_pcm_substream) { | ||
134 | substream = dev->adev.capture_pcm_substream; | ||
135 | runtime = substream->runtime; | ||
136 | stride = runtime->frame_bits >> 3; | ||
137 | |||
138 | for (i = 0; i < urb->number_of_packets; i++) { | ||
139 | int length = urb->iso_frame_desc[i].actual_length / | ||
140 | stride; | ||
141 | cp = (unsigned char *)urb->transfer_buffer + | ||
142 | urb->iso_frame_desc[i].offset; | ||
143 | |||
144 | if (!length) | ||
145 | continue; | ||
146 | |||
147 | oldptr = dev->adev.hwptr_done_capture; | ||
148 | if (oldptr + length >= runtime->buffer_size) { | ||
149 | unsigned int cnt; | ||
150 | |||
151 | cnt = runtime->buffer_size - oldptr; | ||
152 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
153 | cnt * stride); | ||
154 | memcpy(runtime->dma_area, cp + cnt * stride, | ||
155 | length * stride - cnt * stride); | ||
156 | } else { | ||
157 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
158 | length * stride); | ||
159 | } | ||
160 | |||
161 | snd_pcm_stream_lock(substream); | ||
162 | |||
163 | dev->adev.hwptr_done_capture += length; | ||
164 | if (dev->adev.hwptr_done_capture >= | ||
165 | runtime->buffer_size) | ||
166 | dev->adev.hwptr_done_capture -= | ||
167 | runtime->buffer_size; | ||
168 | |||
169 | dev->adev.capture_transfer_done += length; | ||
170 | if (dev->adev.capture_transfer_done >= | ||
171 | runtime->period_size) { | ||
172 | dev->adev.capture_transfer_done -= | ||
173 | runtime->period_size; | ||
174 | period_elapsed = 1; | ||
175 | } | ||
176 | snd_pcm_stream_unlock(substream); | ||
177 | } | ||
178 | if (period_elapsed) | ||
179 | snd_pcm_period_elapsed(substream); | ||
180 | } | ||
181 | urb->status = 0; | ||
182 | |||
183 | status = usb_submit_urb(urb, GFP_ATOMIC); | ||
184 | if (status < 0) { | ||
185 | cx231xx_errdev("resubmit of audio urb failed (error=%i)\n", | ||
186 | status); | ||
187 | } | ||
188 | return; | ||
189 | } | ||
190 | |||
191 | static void cx231xx_audio_bulkirq(struct urb *urb) | ||
192 | { | ||
193 | struct cx231xx *dev = urb->context; | ||
194 | unsigned int oldptr; | ||
195 | int period_elapsed = 0; | ||
196 | int status; | ||
197 | unsigned char *cp; | ||
198 | unsigned int stride; | ||
199 | struct snd_pcm_substream *substream; | ||
200 | struct snd_pcm_runtime *runtime; | ||
201 | |||
202 | if (dev->state & DEV_DISCONNECTED) | ||
203 | return; | ||
204 | |||
205 | switch (urb->status) { | ||
206 | case 0: /* success */ | ||
207 | case -ETIMEDOUT: /* NAK */ | ||
208 | break; | ||
209 | case -ECONNRESET: /* kill */ | ||
210 | case -ENOENT: | ||
211 | case -ESHUTDOWN: | ||
212 | return; | ||
213 | default: /* error */ | ||
214 | dprintk("urb completition error %d.\n", urb->status); | ||
215 | break; | ||
216 | } | ||
217 | |||
218 | if (atomic_read(&dev->stream_started) == 0) | ||
219 | return; | ||
220 | |||
221 | if (dev->adev.capture_pcm_substream) { | ||
222 | substream = dev->adev.capture_pcm_substream; | ||
223 | runtime = substream->runtime; | ||
224 | stride = runtime->frame_bits >> 3; | ||
225 | |||
226 | if (1) { | ||
227 | int length = urb->actual_length / | ||
228 | stride; | ||
229 | cp = (unsigned char *)urb->transfer_buffer; | ||
230 | |||
231 | oldptr = dev->adev.hwptr_done_capture; | ||
232 | if (oldptr + length >= runtime->buffer_size) { | ||
233 | unsigned int cnt; | ||
234 | |||
235 | cnt = runtime->buffer_size - oldptr; | ||
236 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
237 | cnt * stride); | ||
238 | memcpy(runtime->dma_area, cp + cnt * stride, | ||
239 | length * stride - cnt * stride); | ||
240 | } else { | ||
241 | memcpy(runtime->dma_area + oldptr * stride, cp, | ||
242 | length * stride); | ||
243 | } | ||
244 | |||
245 | snd_pcm_stream_lock(substream); | ||
246 | |||
247 | dev->adev.hwptr_done_capture += length; | ||
248 | if (dev->adev.hwptr_done_capture >= | ||
249 | runtime->buffer_size) | ||
250 | dev->adev.hwptr_done_capture -= | ||
251 | runtime->buffer_size; | ||
252 | |||
253 | dev->adev.capture_transfer_done += length; | ||
254 | if (dev->adev.capture_transfer_done >= | ||
255 | runtime->period_size) { | ||
256 | dev->adev.capture_transfer_done -= | ||
257 | runtime->period_size; | ||
258 | period_elapsed = 1; | ||
259 | } | ||
260 | snd_pcm_stream_unlock(substream); | ||
261 | } | ||
262 | if (period_elapsed) | ||
263 | snd_pcm_period_elapsed(substream); | ||
264 | } | ||
265 | urb->status = 0; | ||
266 | |||
267 | status = usb_submit_urb(urb, GFP_ATOMIC); | ||
268 | if (status < 0) { | ||
269 | cx231xx_errdev("resubmit of audio urb failed (error=%i)\n", | ||
270 | status); | ||
271 | } | ||
272 | return; | ||
273 | } | ||
274 | |||
275 | static int cx231xx_init_audio_isoc(struct cx231xx *dev) | ||
276 | { | ||
277 | int i, errCode; | ||
278 | int sb_size; | ||
279 | |||
280 | cx231xx_info("%s: Starting ISO AUDIO transfers\n", __func__); | ||
281 | |||
282 | if (dev->state & DEV_DISCONNECTED) | ||
283 | return -ENODEV; | ||
284 | |||
285 | sb_size = CX231XX_ISO_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size; | ||
286 | |||
287 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
288 | struct urb *urb; | ||
289 | int j, k; | ||
290 | |||
291 | dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC); | ||
292 | if (!dev->adev.transfer_buffer[i]) | ||
293 | return -ENOMEM; | ||
294 | |||
295 | memset(dev->adev.transfer_buffer[i], 0x80, sb_size); | ||
296 | urb = usb_alloc_urb(CX231XX_ISO_NUM_AUDIO_PACKETS, GFP_ATOMIC); | ||
297 | if (!urb) { | ||
298 | cx231xx_errdev("usb_alloc_urb failed!\n"); | ||
299 | for (j = 0; j < i; j++) { | ||
300 | usb_free_urb(dev->adev.urb[j]); | ||
301 | kfree(dev->adev.transfer_buffer[j]); | ||
302 | } | ||
303 | return -ENOMEM; | ||
304 | } | ||
305 | |||
306 | urb->dev = dev->udev; | ||
307 | urb->context = dev; | ||
308 | urb->pipe = usb_rcvisocpipe(dev->udev, | ||
309 | dev->adev.end_point_addr); | ||
310 | urb->transfer_flags = URB_ISO_ASAP; | ||
311 | urb->transfer_buffer = dev->adev.transfer_buffer[i]; | ||
312 | urb->interval = 1; | ||
313 | urb->complete = cx231xx_audio_isocirq; | ||
314 | urb->number_of_packets = CX231XX_ISO_NUM_AUDIO_PACKETS; | ||
315 | urb->transfer_buffer_length = sb_size; | ||
316 | |||
317 | for (j = k = 0; j < CX231XX_ISO_NUM_AUDIO_PACKETS; | ||
318 | j++, k += dev->adev.max_pkt_size) { | ||
319 | urb->iso_frame_desc[j].offset = k; | ||
320 | urb->iso_frame_desc[j].length = dev->adev.max_pkt_size; | ||
321 | } | ||
322 | dev->adev.urb[i] = urb; | ||
323 | } | ||
324 | |||
325 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
326 | errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC); | ||
327 | if (errCode < 0) { | ||
328 | cx231xx_isoc_audio_deinit(dev); | ||
329 | return errCode; | ||
330 | } | ||
331 | } | ||
332 | |||
333 | return errCode; | ||
334 | } | ||
335 | |||
336 | static int cx231xx_init_audio_bulk(struct cx231xx *dev) | ||
337 | { | ||
338 | int i, errCode; | ||
339 | int sb_size; | ||
340 | |||
341 | cx231xx_info("%s: Starting BULK AUDIO transfers\n", __func__); | ||
342 | |||
343 | if (dev->state & DEV_DISCONNECTED) | ||
344 | return -ENODEV; | ||
345 | |||
346 | sb_size = CX231XX_NUM_AUDIO_PACKETS * dev->adev.max_pkt_size; | ||
347 | |||
348 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
349 | struct urb *urb; | ||
350 | int j; | ||
351 | |||
352 | dev->adev.transfer_buffer[i] = kmalloc(sb_size, GFP_ATOMIC); | ||
353 | if (!dev->adev.transfer_buffer[i]) | ||
354 | return -ENOMEM; | ||
355 | |||
356 | memset(dev->adev.transfer_buffer[i], 0x80, sb_size); | ||
357 | urb = usb_alloc_urb(CX231XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); | ||
358 | if (!urb) { | ||
359 | cx231xx_errdev("usb_alloc_urb failed!\n"); | ||
360 | for (j = 0; j < i; j++) { | ||
361 | usb_free_urb(dev->adev.urb[j]); | ||
362 | kfree(dev->adev.transfer_buffer[j]); | ||
363 | } | ||
364 | return -ENOMEM; | ||
365 | } | ||
366 | |||
367 | urb->dev = dev->udev; | ||
368 | urb->context = dev; | ||
369 | urb->pipe = usb_rcvbulkpipe(dev->udev, | ||
370 | dev->adev.end_point_addr); | ||
371 | urb->transfer_flags = 0; | ||
372 | urb->transfer_buffer = dev->adev.transfer_buffer[i]; | ||
373 | urb->complete = cx231xx_audio_bulkirq; | ||
374 | urb->transfer_buffer_length = sb_size; | ||
375 | |||
376 | dev->adev.urb[i] = urb; | ||
377 | |||
378 | } | ||
379 | |||
380 | for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { | ||
381 | errCode = usb_submit_urb(dev->adev.urb[i], GFP_ATOMIC); | ||
382 | if (errCode < 0) { | ||
383 | cx231xx_bulk_audio_deinit(dev); | ||
384 | return errCode; | ||
385 | } | ||
386 | } | ||
387 | |||
388 | return errCode; | ||
389 | } | ||
390 | |||
391 | static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, | ||
392 | size_t size) | ||
393 | { | ||
394 | struct snd_pcm_runtime *runtime = subs->runtime; | ||
395 | |||
396 | dprintk("Allocating vbuffer\n"); | ||
397 | if (runtime->dma_area) { | ||
398 | if (runtime->dma_bytes > size) | ||
399 | return 0; | ||
400 | |||
401 | vfree(runtime->dma_area); | ||
402 | } | ||
403 | runtime->dma_area = vmalloc(size); | ||
404 | if (!runtime->dma_area) | ||
405 | return -ENOMEM; | ||
406 | |||
407 | runtime->dma_bytes = size; | ||
408 | |||
409 | return 0; | ||
410 | } | ||
411 | |||
412 | static struct snd_pcm_hardware snd_cx231xx_hw_capture = { | ||
413 | .info = SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
414 | SNDRV_PCM_INFO_MMAP | | ||
415 | SNDRV_PCM_INFO_INTERLEAVED | | ||
416 | SNDRV_PCM_INFO_MMAP_VALID, | ||
417 | |||
418 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | ||
419 | |||
420 | .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_KNOT, | ||
421 | |||
422 | .rate_min = 48000, | ||
423 | .rate_max = 48000, | ||
424 | .channels_min = 2, | ||
425 | .channels_max = 2, | ||
426 | .buffer_bytes_max = 62720 * 8, /* just about the value in usbaudio.c */ | ||
427 | .period_bytes_min = 64, /* 12544/2, */ | ||
428 | .period_bytes_max = 12544, | ||
429 | .periods_min = 2, | ||
430 | .periods_max = 98, /* 12544, */ | ||
431 | }; | ||
432 | |||
433 | static int snd_cx231xx_capture_open(struct snd_pcm_substream *substream) | ||
434 | { | ||
435 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
436 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
437 | int ret = 0; | ||
438 | |||
439 | dprintk("opening device and trying to acquire exclusive lock\n"); | ||
440 | |||
441 | if (!dev) { | ||
442 | cx231xx_errdev("BUG: cx231xx can't find device struct." | ||
443 | " Can't proceed with open\n"); | ||
444 | return -ENODEV; | ||
445 | } | ||
446 | |||
447 | if (dev->state & DEV_DISCONNECTED) { | ||
448 | cx231xx_errdev("Can't open. the device was removed.\n"); | ||
449 | return -ENODEV; | ||
450 | } | ||
451 | |||
452 | /* Sets volume, mute, etc */ | ||
453 | dev->mute = 0; | ||
454 | |||
455 | /* set alternate setting for audio interface */ | ||
456 | /* 1 - 48000 samples per sec */ | ||
457 | mutex_lock(&dev->lock); | ||
458 | if (dev->USE_ISO) | ||
459 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 1); | ||
460 | else | ||
461 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); | ||
462 | mutex_unlock(&dev->lock); | ||
463 | if (ret < 0) { | ||
464 | cx231xx_errdev("failed to set alternate setting !\n"); | ||
465 | |||
466 | return ret; | ||
467 | } | ||
468 | |||
469 | runtime->hw = snd_cx231xx_hw_capture; | ||
470 | |||
471 | mutex_lock(&dev->lock); | ||
472 | /* inform hardware to start streaming */ | ||
473 | ret = cx231xx_capture_start(dev, 1, Audio); | ||
474 | |||
475 | dev->adev.users++; | ||
476 | mutex_unlock(&dev->lock); | ||
477 | |||
478 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | ||
479 | dev->adev.capture_pcm_substream = substream; | ||
480 | runtime->private_data = dev; | ||
481 | |||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream) | ||
486 | { | ||
487 | int ret; | ||
488 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
489 | |||
490 | dprintk("closing device\n"); | ||
491 | |||
492 | /* inform hardware to stop streaming */ | ||
493 | mutex_lock(&dev->lock); | ||
494 | ret = cx231xx_capture_start(dev, 0, Audio); | ||
495 | |||
496 | /* set alternate setting for audio interface */ | ||
497 | /* 1 - 48000 samples per sec */ | ||
498 | ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); | ||
499 | if (ret < 0) { | ||
500 | cx231xx_errdev("failed to set alternate setting !\n"); | ||
501 | |||
502 | mutex_unlock(&dev->lock); | ||
503 | return ret; | ||
504 | } | ||
505 | |||
506 | dev->mute = 1; | ||
507 | dev->adev.users--; | ||
508 | mutex_unlock(&dev->lock); | ||
509 | |||
510 | if (dev->adev.users == 0 && dev->adev.shutdown == 1) { | ||
511 | dprintk("audio users: %d\n", dev->adev.users); | ||
512 | dprintk("disabling audio stream!\n"); | ||
513 | dev->adev.shutdown = 0; | ||
514 | dprintk("released lock\n"); | ||
515 | if (atomic_read(&dev->stream_started) > 0) { | ||
516 | atomic_set(&dev->stream_started, 0); | ||
517 | schedule_work(&dev->wq_trigger); | ||
518 | } | ||
519 | } | ||
520 | return 0; | ||
521 | } | ||
522 | |||
523 | static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream, | ||
524 | struct snd_pcm_hw_params *hw_params) | ||
525 | { | ||
526 | int ret; | ||
527 | |||
528 | dprintk("Setting capture parameters\n"); | ||
529 | |||
530 | ret = snd_pcm_alloc_vmalloc_buffer(substream, | ||
531 | params_buffer_bytes(hw_params)); | ||
532 | #if 0 | ||
533 | /* TODO: set up cx231xx audio chip to deliver the correct audio format, | ||
534 | current default is 48000hz multiplexed => 96000hz mono | ||
535 | which shouldn't matter since analogue TV only supports mono */ | ||
536 | unsigned int channels, rate, format; | ||
537 | |||
538 | format = params_format(hw_params); | ||
539 | rate = params_rate(hw_params); | ||
540 | channels = params_channels(hw_params); | ||
541 | #endif | ||
542 | |||
543 | return ret; | ||
544 | } | ||
545 | |||
546 | static int snd_cx231xx_hw_capture_free(struct snd_pcm_substream *substream) | ||
547 | { | ||
548 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
549 | |||
550 | dprintk("Stop capture, if needed\n"); | ||
551 | |||
552 | if (atomic_read(&dev->stream_started) > 0) { | ||
553 | atomic_set(&dev->stream_started, 0); | ||
554 | schedule_work(&dev->wq_trigger); | ||
555 | } | ||
556 | |||
557 | return 0; | ||
558 | } | ||
559 | |||
560 | static int snd_cx231xx_prepare(struct snd_pcm_substream *substream) | ||
561 | { | ||
562 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
563 | |||
564 | dev->adev.hwptr_done_capture = 0; | ||
565 | dev->adev.capture_transfer_done = 0; | ||
566 | |||
567 | return 0; | ||
568 | } | ||
569 | |||
570 | static void audio_trigger(struct work_struct *work) | ||
571 | { | ||
572 | struct cx231xx *dev = container_of(work, struct cx231xx, wq_trigger); | ||
573 | |||
574 | if (atomic_read(&dev->stream_started)) { | ||
575 | dprintk("starting capture"); | ||
576 | if (is_fw_load(dev) == 0) | ||
577 | cx25840_call(dev, core, load_fw); | ||
578 | if (dev->USE_ISO) | ||
579 | cx231xx_init_audio_isoc(dev); | ||
580 | else | ||
581 | cx231xx_init_audio_bulk(dev); | ||
582 | } else { | ||
583 | dprintk("stopping capture"); | ||
584 | cx231xx_isoc_audio_deinit(dev); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | static int snd_cx231xx_capture_trigger(struct snd_pcm_substream *substream, | ||
589 | int cmd) | ||
590 | { | ||
591 | struct cx231xx *dev = snd_pcm_substream_chip(substream); | ||
592 | int retval = 0; | ||
593 | |||
594 | if (dev->state & DEV_DISCONNECTED) | ||
595 | return -ENODEV; | ||
596 | |||
597 | spin_lock(&dev->adev.slock); | ||
598 | switch (cmd) { | ||
599 | case SNDRV_PCM_TRIGGER_START: | ||
600 | atomic_set(&dev->stream_started, 1); | ||
601 | break; | ||
602 | case SNDRV_PCM_TRIGGER_STOP: | ||
603 | atomic_set(&dev->stream_started, 0); | ||
604 | break; | ||
605 | default: | ||
606 | retval = -EINVAL; | ||
607 | break; | ||
608 | } | ||
609 | spin_unlock(&dev->adev.slock); | ||
610 | |||
611 | schedule_work(&dev->wq_trigger); | ||
612 | |||
613 | return retval; | ||
614 | } | ||
615 | |||
616 | static snd_pcm_uframes_t snd_cx231xx_capture_pointer(struct snd_pcm_substream | ||
617 | *substream) | ||
618 | { | ||
619 | struct cx231xx *dev; | ||
620 | unsigned long flags; | ||
621 | snd_pcm_uframes_t hwptr_done; | ||
622 | |||
623 | dev = snd_pcm_substream_chip(substream); | ||
624 | |||
625 | spin_lock_irqsave(&dev->adev.slock, flags); | ||
626 | hwptr_done = dev->adev.hwptr_done_capture; | ||
627 | spin_unlock_irqrestore(&dev->adev.slock, flags); | ||
628 | |||
629 | return hwptr_done; | ||
630 | } | ||
631 | |||
632 | static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, | ||
633 | unsigned long offset) | ||
634 | { | ||
635 | void *pageptr = subs->runtime->dma_area + offset; | ||
636 | |||
637 | return vmalloc_to_page(pageptr); | ||
638 | } | ||
639 | |||
640 | static struct snd_pcm_ops snd_cx231xx_pcm_capture = { | ||
641 | .open = snd_cx231xx_capture_open, | ||
642 | .close = snd_cx231xx_pcm_close, | ||
643 | .ioctl = snd_pcm_lib_ioctl, | ||
644 | .hw_params = snd_cx231xx_hw_capture_params, | ||
645 | .hw_free = snd_cx231xx_hw_capture_free, | ||
646 | .prepare = snd_cx231xx_prepare, | ||
647 | .trigger = snd_cx231xx_capture_trigger, | ||
648 | .pointer = snd_cx231xx_capture_pointer, | ||
649 | .page = snd_pcm_get_vmalloc_page, | ||
650 | }; | ||
651 | |||
652 | static int cx231xx_audio_init(struct cx231xx *dev) | ||
653 | { | ||
654 | struct cx231xx_audio *adev = &dev->adev; | ||
655 | struct snd_pcm *pcm; | ||
656 | struct snd_card *card; | ||
657 | static int devnr; | ||
658 | int err; | ||
659 | struct usb_interface *uif; | ||
660 | int i, isoc_pipe = 0; | ||
661 | |||
662 | if (dev->has_alsa_audio != 1) { | ||
663 | /* This device does not support the extension (in this case | ||
664 | the device is expecting the snd-usb-audio module or | ||
665 | doesn't have analog audio support at all) */ | ||
666 | return 0; | ||
667 | } | ||
668 | |||
669 | cx231xx_info("cx231xx-audio.c: probing for cx231xx " | ||
670 | "non standard usbaudio\n"); | ||
671 | |||
672 | err = snd_card_create(index[devnr], "Cx231xx Audio", THIS_MODULE, | ||
673 | 0, &card); | ||
674 | if (err < 0) | ||
675 | return err; | ||
676 | |||
677 | spin_lock_init(&adev->slock); | ||
678 | err = snd_pcm_new(card, "Cx231xx Audio", 0, 0, 1, &pcm); | ||
679 | if (err < 0) { | ||
680 | snd_card_free(card); | ||
681 | return err; | ||
682 | } | ||
683 | |||
684 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | ||
685 | &snd_cx231xx_pcm_capture); | ||
686 | pcm->info_flags = 0; | ||
687 | pcm->private_data = dev; | ||
688 | strcpy(pcm->name, "Conexant cx231xx Capture"); | ||
689 | snd_card_set_dev(card, &dev->udev->dev); | ||
690 | strcpy(card->driver, "Cx231xx-Audio"); | ||
691 | strcpy(card->shortname, "Cx231xx Audio"); | ||
692 | strcpy(card->longname, "Conexant cx231xx Audio"); | ||
693 | |||
694 | INIT_WORK(&dev->wq_trigger, audio_trigger); | ||
695 | |||
696 | err = snd_card_register(card); | ||
697 | if (err < 0) { | ||
698 | snd_card_free(card); | ||
699 | return err; | ||
700 | } | ||
701 | adev->sndcard = card; | ||
702 | adev->udev = dev->udev; | ||
703 | |||
704 | /* compute alternate max packet sizes for Audio */ | ||
705 | uif = | ||
706 | dev->udev->actconfig->interface[dev->current_pcb_config. | ||
707 | hs_config_info[0].interface_info. | ||
708 | audio_index + 1]; | ||
709 | |||
710 | adev->end_point_addr = | ||
711 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | ||
712 | bEndpointAddress); | ||
713 | |||
714 | adev->num_alt = uif->num_altsetting; | ||
715 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
716 | adev->end_point_addr, adev->num_alt); | ||
717 | adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); | ||
718 | |||
719 | if (adev->alt_max_pkt_size == NULL) { | ||
720 | cx231xx_errdev("out of memory!\n"); | ||
721 | return -ENOMEM; | ||
722 | } | ||
723 | |||
724 | for (i = 0; i < adev->num_alt; i++) { | ||
725 | u16 tmp = | ||
726 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc. | ||
727 | wMaxPacketSize); | ||
728 | adev->alt_max_pkt_size[i] = | ||
729 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
730 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
731 | adev->alt_max_pkt_size[i]); | ||
732 | } | ||
733 | |||
734 | return 0; | ||
735 | } | ||
736 | |||
737 | static int cx231xx_audio_fini(struct cx231xx *dev) | ||
738 | { | ||
739 | if (dev == NULL) | ||
740 | return 0; | ||
741 | |||
742 | if (dev->has_alsa_audio != 1) { | ||
743 | /* This device does not support the extension (in this case | ||
744 | the device is expecting the snd-usb-audio module or | ||
745 | doesn't have analog audio support at all) */ | ||
746 | return 0; | ||
747 | } | ||
748 | |||
749 | if (dev->adev.sndcard) { | ||
750 | snd_card_free(dev->adev.sndcard); | ||
751 | kfree(dev->adev.alt_max_pkt_size); | ||
752 | dev->adev.sndcard = NULL; | ||
753 | } | ||
754 | |||
755 | return 0; | ||
756 | } | ||
757 | |||
758 | static struct cx231xx_ops audio_ops = { | ||
759 | .id = CX231XX_AUDIO, | ||
760 | .name = "Cx231xx Audio Extension", | ||
761 | .init = cx231xx_audio_init, | ||
762 | .fini = cx231xx_audio_fini, | ||
763 | }; | ||
764 | |||
765 | static int __init cx231xx_alsa_register(void) | ||
766 | { | ||
767 | return cx231xx_register_extension(&audio_ops); | ||
768 | } | ||
769 | |||
770 | static void __exit cx231xx_alsa_unregister(void) | ||
771 | { | ||
772 | cx231xx_unregister_extension(&audio_ops); | ||
773 | } | ||
774 | |||
775 | MODULE_LICENSE("GPL"); | ||
776 | MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>"); | ||
777 | MODULE_DESCRIPTION("Cx231xx Audio driver"); | ||
778 | |||
779 | module_init(cx231xx_alsa_register); | ||
780 | module_exit(cx231xx_alsa_unregister); | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c b/drivers/media/usb/cx231xx/cx231xx-avcore.c new file mode 100644 index 000000000000..447148eff958 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c | |||
@@ -0,0 +1,3087 @@ | |||
1 | /* | ||
2 | cx231xx_avcore.c - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program contains the specific code to control the avdecoder chip and | ||
8 | other related usb control functions for cx231xx based chipset. | ||
9 | |||
10 | This program is free software; you can redistribute it and/or modify | ||
11 | it under the terms of the GNU General Public License as published by | ||
12 | the Free Software Foundation; either version 2 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program; if not, write to the Free Software | ||
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | #include <linux/init.h> | ||
26 | #include <linux/list.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/bitmap.h> | ||
30 | #include <linux/usb.h> | ||
31 | #include <linux/i2c.h> | ||
32 | #include <linux/mm.h> | ||
33 | #include <linux/mutex.h> | ||
34 | #include <media/tuner.h> | ||
35 | |||
36 | #include <media/v4l2-common.h> | ||
37 | #include <media/v4l2-ioctl.h> | ||
38 | #include <media/v4l2-chip-ident.h> | ||
39 | |||
40 | #include "cx231xx.h" | ||
41 | #include "cx231xx-dif.h" | ||
42 | |||
43 | #define TUNER_MODE_FM_RADIO 0 | ||
44 | /****************************************************************************** | ||
45 | -: BLOCK ARRANGEMENT :- | ||
46 | I2S block ----------------------| | ||
47 | [I2S audio] | | ||
48 | | | ||
49 | Analog Front End --> Direct IF -|-> Cx25840 --> Audio | ||
50 | [video & audio] | [Audio] | ||
51 | | | ||
52 | |-> Cx25840 --> Video | ||
53 | [Video] | ||
54 | |||
55 | *******************************************************************************/ | ||
56 | /****************************************************************************** | ||
57 | * VERVE REGISTER * | ||
58 | * * | ||
59 | ******************************************************************************/ | ||
60 | static int verve_write_byte(struct cx231xx *dev, u8 saddr, u8 data) | ||
61 | { | ||
62 | return cx231xx_write_i2c_data(dev, VERVE_I2C_ADDRESS, | ||
63 | saddr, 1, data, 1); | ||
64 | } | ||
65 | |||
66 | static int verve_read_byte(struct cx231xx *dev, u8 saddr, u8 *data) | ||
67 | { | ||
68 | int status; | ||
69 | u32 temp = 0; | ||
70 | |||
71 | status = cx231xx_read_i2c_data(dev, VERVE_I2C_ADDRESS, | ||
72 | saddr, 1, &temp, 1); | ||
73 | *data = (u8) temp; | ||
74 | return status; | ||
75 | } | ||
76 | void initGPIO(struct cx231xx *dev) | ||
77 | { | ||
78 | u32 _gpio_direction = 0; | ||
79 | u32 value = 0; | ||
80 | u8 val = 0; | ||
81 | |||
82 | _gpio_direction = _gpio_direction & 0xFC0003FF; | ||
83 | _gpio_direction = _gpio_direction | 0x03FDFC00; | ||
84 | cx231xx_send_gpio_cmd(dev, _gpio_direction, (u8 *)&value, 4, 0, 0); | ||
85 | |||
86 | verve_read_byte(dev, 0x07, &val); | ||
87 | cx231xx_info(" verve_read_byte address0x07=0x%x\n", val); | ||
88 | verve_write_byte(dev, 0x07, 0xF4); | ||
89 | verve_read_byte(dev, 0x07, &val); | ||
90 | cx231xx_info(" verve_read_byte address0x07=0x%x\n", val); | ||
91 | |||
92 | cx231xx_capture_start(dev, 1, Vbi); | ||
93 | |||
94 | cx231xx_mode_register(dev, EP_MODE_SET, 0x0500FE00); | ||
95 | cx231xx_mode_register(dev, GBULK_BIT_EN, 0xFFFDFFFF); | ||
96 | |||
97 | } | ||
98 | void uninitGPIO(struct cx231xx *dev) | ||
99 | { | ||
100 | u8 value[4] = { 0, 0, 0, 0 }; | ||
101 | |||
102 | cx231xx_capture_start(dev, 0, Vbi); | ||
103 | verve_write_byte(dev, 0x07, 0x14); | ||
104 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
105 | 0x68, value, 4); | ||
106 | } | ||
107 | |||
108 | /****************************************************************************** | ||
109 | * A F E - B L O C K C O N T R O L functions * | ||
110 | * [ANALOG FRONT END] * | ||
111 | ******************************************************************************/ | ||
112 | static int afe_write_byte(struct cx231xx *dev, u16 saddr, u8 data) | ||
113 | { | ||
114 | return cx231xx_write_i2c_data(dev, AFE_DEVICE_ADDRESS, | ||
115 | saddr, 2, data, 1); | ||
116 | } | ||
117 | |||
118 | static int afe_read_byte(struct cx231xx *dev, u16 saddr, u8 *data) | ||
119 | { | ||
120 | int status; | ||
121 | u32 temp = 0; | ||
122 | |||
123 | status = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, | ||
124 | saddr, 2, &temp, 1); | ||
125 | *data = (u8) temp; | ||
126 | return status; | ||
127 | } | ||
128 | |||
129 | int cx231xx_afe_init_super_block(struct cx231xx *dev, u32 ref_count) | ||
130 | { | ||
131 | int status = 0; | ||
132 | u8 temp = 0; | ||
133 | u8 afe_power_status = 0; | ||
134 | int i = 0; | ||
135 | |||
136 | /* super block initialize */ | ||
137 | temp = (u8) (ref_count & 0xff); | ||
138 | status = afe_write_byte(dev, SUP_BLK_TUNE2, temp); | ||
139 | if (status < 0) | ||
140 | return status; | ||
141 | |||
142 | status = afe_read_byte(dev, SUP_BLK_TUNE2, &afe_power_status); | ||
143 | if (status < 0) | ||
144 | return status; | ||
145 | |||
146 | temp = (u8) ((ref_count & 0x300) >> 8); | ||
147 | temp |= 0x40; | ||
148 | status = afe_write_byte(dev, SUP_BLK_TUNE1, temp); | ||
149 | if (status < 0) | ||
150 | return status; | ||
151 | |||
152 | status = afe_write_byte(dev, SUP_BLK_PLL2, 0x0f); | ||
153 | if (status < 0) | ||
154 | return status; | ||
155 | |||
156 | /* enable pll */ | ||
157 | while (afe_power_status != 0x18) { | ||
158 | status = afe_write_byte(dev, SUP_BLK_PWRDN, 0x18); | ||
159 | if (status < 0) { | ||
160 | cx231xx_info( | ||
161 | ": Init Super Block failed in send cmd\n"); | ||
162 | break; | ||
163 | } | ||
164 | |||
165 | status = afe_read_byte(dev, SUP_BLK_PWRDN, &afe_power_status); | ||
166 | afe_power_status &= 0xff; | ||
167 | if (status < 0) { | ||
168 | cx231xx_info( | ||
169 | ": Init Super Block failed in receive cmd\n"); | ||
170 | break; | ||
171 | } | ||
172 | i++; | ||
173 | if (i == 10) { | ||
174 | cx231xx_info( | ||
175 | ": Init Super Block force break in loop !!!!\n"); | ||
176 | status = -1; | ||
177 | break; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | if (status < 0) | ||
182 | return status; | ||
183 | |||
184 | /* start tuning filter */ | ||
185 | status = afe_write_byte(dev, SUP_BLK_TUNE3, 0x40); | ||
186 | if (status < 0) | ||
187 | return status; | ||
188 | |||
189 | msleep(5); | ||
190 | |||
191 | /* exit tuning */ | ||
192 | status = afe_write_byte(dev, SUP_BLK_TUNE3, 0x00); | ||
193 | |||
194 | return status; | ||
195 | } | ||
196 | |||
197 | int cx231xx_afe_init_channels(struct cx231xx *dev) | ||
198 | { | ||
199 | int status = 0; | ||
200 | |||
201 | /* power up all 3 channels, clear pd_buffer */ | ||
202 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, 0x00); | ||
203 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, 0x00); | ||
204 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, 0x00); | ||
205 | |||
206 | /* Enable quantizer calibration */ | ||
207 | status = afe_write_byte(dev, ADC_COM_QUANT, 0x02); | ||
208 | |||
209 | /* channel initialize, force modulator (fb) reset */ | ||
210 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH1, 0x17); | ||
211 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH2, 0x17); | ||
212 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH3, 0x17); | ||
213 | |||
214 | /* start quantilizer calibration */ | ||
215 | status = afe_write_byte(dev, ADC_CAL_ATEST_CH1, 0x10); | ||
216 | status = afe_write_byte(dev, ADC_CAL_ATEST_CH2, 0x10); | ||
217 | status = afe_write_byte(dev, ADC_CAL_ATEST_CH3, 0x10); | ||
218 | msleep(5); | ||
219 | |||
220 | /* exit modulator (fb) reset */ | ||
221 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH1, 0x07); | ||
222 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH2, 0x07); | ||
223 | status = afe_write_byte(dev, ADC_FB_FRCRST_CH3, 0x07); | ||
224 | |||
225 | /* enable the pre_clamp in each channel for single-ended input */ | ||
226 | status = afe_write_byte(dev, ADC_NTF_PRECLMP_EN_CH1, 0xf0); | ||
227 | status = afe_write_byte(dev, ADC_NTF_PRECLMP_EN_CH2, 0xf0); | ||
228 | status = afe_write_byte(dev, ADC_NTF_PRECLMP_EN_CH3, 0xf0); | ||
229 | |||
230 | /* use diode instead of resistor, so set term_en to 0, res_en to 0 */ | ||
231 | status = cx231xx_reg_mask_write(dev, AFE_DEVICE_ADDRESS, 8, | ||
232 | ADC_QGAIN_RES_TRM_CH1, 3, 7, 0x00); | ||
233 | status = cx231xx_reg_mask_write(dev, AFE_DEVICE_ADDRESS, 8, | ||
234 | ADC_QGAIN_RES_TRM_CH2, 3, 7, 0x00); | ||
235 | status = cx231xx_reg_mask_write(dev, AFE_DEVICE_ADDRESS, 8, | ||
236 | ADC_QGAIN_RES_TRM_CH3, 3, 7, 0x00); | ||
237 | |||
238 | /* dynamic element matching off */ | ||
239 | status = afe_write_byte(dev, ADC_DCSERVO_DEM_CH1, 0x03); | ||
240 | status = afe_write_byte(dev, ADC_DCSERVO_DEM_CH2, 0x03); | ||
241 | status = afe_write_byte(dev, ADC_DCSERVO_DEM_CH3, 0x03); | ||
242 | |||
243 | return status; | ||
244 | } | ||
245 | |||
246 | int cx231xx_afe_setup_AFE_for_baseband(struct cx231xx *dev) | ||
247 | { | ||
248 | u8 c_value = 0; | ||
249 | int status = 0; | ||
250 | |||
251 | status = afe_read_byte(dev, ADC_PWRDN_CLAMP_CH2, &c_value); | ||
252 | c_value &= (~(0x50)); | ||
253 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, c_value); | ||
254 | |||
255 | return status; | ||
256 | } | ||
257 | |||
258 | /* | ||
259 | The Analog Front End in Cx231xx has 3 channels. These | ||
260 | channels are used to share between different inputs | ||
261 | like tuner, s-video and composite inputs. | ||
262 | |||
263 | channel 1 ----- pin 1 to pin4(in reg is 1-4) | ||
264 | channel 2 ----- pin 5 to pin8(in reg is 5-8) | ||
265 | channel 3 ----- pin 9 to pin 12(in reg is 9-11) | ||
266 | */ | ||
267 | int cx231xx_afe_set_input_mux(struct cx231xx *dev, u32 input_mux) | ||
268 | { | ||
269 | u8 ch1_setting = (u8) input_mux; | ||
270 | u8 ch2_setting = (u8) (input_mux >> 8); | ||
271 | u8 ch3_setting = (u8) (input_mux >> 16); | ||
272 | int status = 0; | ||
273 | u8 value = 0; | ||
274 | |||
275 | if (ch1_setting != 0) { | ||
276 | status = afe_read_byte(dev, ADC_INPUT_CH1, &value); | ||
277 | value &= ~INPUT_SEL_MASK; | ||
278 | value |= (ch1_setting - 1) << 4; | ||
279 | value &= 0xff; | ||
280 | status = afe_write_byte(dev, ADC_INPUT_CH1, value); | ||
281 | } | ||
282 | |||
283 | if (ch2_setting != 0) { | ||
284 | status = afe_read_byte(dev, ADC_INPUT_CH2, &value); | ||
285 | value &= ~INPUT_SEL_MASK; | ||
286 | value |= (ch2_setting - 1) << 4; | ||
287 | value &= 0xff; | ||
288 | status = afe_write_byte(dev, ADC_INPUT_CH2, value); | ||
289 | } | ||
290 | |||
291 | /* For ch3_setting, the value to put in the register is | ||
292 | 7 less than the input number */ | ||
293 | if (ch3_setting != 0) { | ||
294 | status = afe_read_byte(dev, ADC_INPUT_CH3, &value); | ||
295 | value &= ~INPUT_SEL_MASK; | ||
296 | value |= (ch3_setting - 1) << 4; | ||
297 | value &= 0xff; | ||
298 | status = afe_write_byte(dev, ADC_INPUT_CH3, value); | ||
299 | } | ||
300 | |||
301 | return status; | ||
302 | } | ||
303 | |||
304 | int cx231xx_afe_set_mode(struct cx231xx *dev, enum AFE_MODE mode) | ||
305 | { | ||
306 | int status = 0; | ||
307 | |||
308 | /* | ||
309 | * FIXME: We need to implement the AFE code for LOW IF and for HI IF. | ||
310 | * Currently, only baseband works. | ||
311 | */ | ||
312 | |||
313 | switch (mode) { | ||
314 | case AFE_MODE_LOW_IF: | ||
315 | cx231xx_Setup_AFE_for_LowIF(dev); | ||
316 | break; | ||
317 | case AFE_MODE_BASEBAND: | ||
318 | status = cx231xx_afe_setup_AFE_for_baseband(dev); | ||
319 | break; | ||
320 | case AFE_MODE_EU_HI_IF: | ||
321 | /* SetupAFEforEuHiIF(); */ | ||
322 | break; | ||
323 | case AFE_MODE_US_HI_IF: | ||
324 | /* SetupAFEforUsHiIF(); */ | ||
325 | break; | ||
326 | case AFE_MODE_JAPAN_HI_IF: | ||
327 | /* SetupAFEforJapanHiIF(); */ | ||
328 | break; | ||
329 | } | ||
330 | |||
331 | if ((mode != dev->afe_mode) && | ||
332 | (dev->video_input == CX231XX_VMUX_TELEVISION)) | ||
333 | status = cx231xx_afe_adjust_ref_count(dev, | ||
334 | CX231XX_VMUX_TELEVISION); | ||
335 | |||
336 | dev->afe_mode = mode; | ||
337 | |||
338 | return status; | ||
339 | } | ||
340 | |||
341 | int cx231xx_afe_update_power_control(struct cx231xx *dev, | ||
342 | enum AV_MODE avmode) | ||
343 | { | ||
344 | u8 afe_power_status = 0; | ||
345 | int status = 0; | ||
346 | |||
347 | switch (dev->model) { | ||
348 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
349 | case CX231XX_BOARD_CNXT_RDE_250: | ||
350 | case CX231XX_BOARD_CNXT_SHELBY: | ||
351 | case CX231XX_BOARD_CNXT_RDU_250: | ||
352 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
353 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
354 | case CX231XX_BOARD_CNXT_VIDEO_GRABBER: | ||
355 | case CX231XX_BOARD_HAUPPAUGE_EXETER: | ||
356 | case CX231XX_BOARD_HAUPPAUGE_USBLIVE2: | ||
357 | case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: | ||
358 | case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: | ||
359 | case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: | ||
360 | if (avmode == POLARIS_AVMODE_ANALOGT_TV) { | ||
361 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | ||
362 | FLD_PWRDN_ENABLE_PLL)) { | ||
363 | status = afe_write_byte(dev, SUP_BLK_PWRDN, | ||
364 | FLD_PWRDN_TUNING_BIAS | | ||
365 | FLD_PWRDN_ENABLE_PLL); | ||
366 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
367 | &afe_power_status); | ||
368 | if (status < 0) | ||
369 | break; | ||
370 | } | ||
371 | |||
372 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
373 | 0x00); | ||
374 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
375 | 0x00); | ||
376 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
377 | 0x00); | ||
378 | } else if (avmode == POLARIS_AVMODE_DIGITAL) { | ||
379 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
380 | 0x70); | ||
381 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
382 | 0x70); | ||
383 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
384 | 0x70); | ||
385 | |||
386 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
387 | &afe_power_status); | ||
388 | afe_power_status |= FLD_PWRDN_PD_BANDGAP | | ||
389 | FLD_PWRDN_PD_BIAS | | ||
390 | FLD_PWRDN_PD_TUNECK; | ||
391 | status |= afe_write_byte(dev, SUP_BLK_PWRDN, | ||
392 | afe_power_status); | ||
393 | } else if (avmode == POLARIS_AVMODE_ENXTERNAL_AV) { | ||
394 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | ||
395 | FLD_PWRDN_ENABLE_PLL)) { | ||
396 | status = afe_write_byte(dev, SUP_BLK_PWRDN, | ||
397 | FLD_PWRDN_TUNING_BIAS | | ||
398 | FLD_PWRDN_ENABLE_PLL); | ||
399 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
400 | &afe_power_status); | ||
401 | if (status < 0) | ||
402 | break; | ||
403 | } | ||
404 | |||
405 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
406 | 0x00); | ||
407 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
408 | 0x00); | ||
409 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
410 | 0x00); | ||
411 | } else { | ||
412 | cx231xx_info("Invalid AV mode input\n"); | ||
413 | status = -1; | ||
414 | } | ||
415 | break; | ||
416 | default: | ||
417 | if (avmode == POLARIS_AVMODE_ANALOGT_TV) { | ||
418 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | ||
419 | FLD_PWRDN_ENABLE_PLL)) { | ||
420 | status = afe_write_byte(dev, SUP_BLK_PWRDN, | ||
421 | FLD_PWRDN_TUNING_BIAS | | ||
422 | FLD_PWRDN_ENABLE_PLL); | ||
423 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
424 | &afe_power_status); | ||
425 | if (status < 0) | ||
426 | break; | ||
427 | } | ||
428 | |||
429 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
430 | 0x40); | ||
431 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
432 | 0x40); | ||
433 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
434 | 0x00); | ||
435 | } else if (avmode == POLARIS_AVMODE_DIGITAL) { | ||
436 | status = afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
437 | 0x70); | ||
438 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
439 | 0x70); | ||
440 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
441 | 0x70); | ||
442 | |||
443 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
444 | &afe_power_status); | ||
445 | afe_power_status |= FLD_PWRDN_PD_BANDGAP | | ||
446 | FLD_PWRDN_PD_BIAS | | ||
447 | FLD_PWRDN_PD_TUNECK; | ||
448 | status |= afe_write_byte(dev, SUP_BLK_PWRDN, | ||
449 | afe_power_status); | ||
450 | } else if (avmode == POLARIS_AVMODE_ENXTERNAL_AV) { | ||
451 | while (afe_power_status != (FLD_PWRDN_TUNING_BIAS | | ||
452 | FLD_PWRDN_ENABLE_PLL)) { | ||
453 | status = afe_write_byte(dev, SUP_BLK_PWRDN, | ||
454 | FLD_PWRDN_TUNING_BIAS | | ||
455 | FLD_PWRDN_ENABLE_PLL); | ||
456 | status |= afe_read_byte(dev, SUP_BLK_PWRDN, | ||
457 | &afe_power_status); | ||
458 | if (status < 0) | ||
459 | break; | ||
460 | } | ||
461 | |||
462 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH1, | ||
463 | 0x00); | ||
464 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH2, | ||
465 | 0x00); | ||
466 | status |= afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, | ||
467 | 0x40); | ||
468 | } else { | ||
469 | cx231xx_info("Invalid AV mode input\n"); | ||
470 | status = -1; | ||
471 | } | ||
472 | } /* switch */ | ||
473 | |||
474 | return status; | ||
475 | } | ||
476 | |||
477 | int cx231xx_afe_adjust_ref_count(struct cx231xx *dev, u32 video_input) | ||
478 | { | ||
479 | u8 input_mode = 0; | ||
480 | u8 ntf_mode = 0; | ||
481 | int status = 0; | ||
482 | |||
483 | dev->video_input = video_input; | ||
484 | |||
485 | if (video_input == CX231XX_VMUX_TELEVISION) { | ||
486 | status = afe_read_byte(dev, ADC_INPUT_CH3, &input_mode); | ||
487 | status = afe_read_byte(dev, ADC_NTF_PRECLMP_EN_CH3, | ||
488 | &ntf_mode); | ||
489 | } else { | ||
490 | status = afe_read_byte(dev, ADC_INPUT_CH1, &input_mode); | ||
491 | status = afe_read_byte(dev, ADC_NTF_PRECLMP_EN_CH1, | ||
492 | &ntf_mode); | ||
493 | } | ||
494 | |||
495 | input_mode = (ntf_mode & 0x3) | ((input_mode & 0x6) << 1); | ||
496 | |||
497 | switch (input_mode) { | ||
498 | case SINGLE_ENDED: | ||
499 | dev->afe_ref_count = 0x23C; | ||
500 | break; | ||
501 | case LOW_IF: | ||
502 | dev->afe_ref_count = 0x24C; | ||
503 | break; | ||
504 | case EU_IF: | ||
505 | dev->afe_ref_count = 0x258; | ||
506 | break; | ||
507 | case US_IF: | ||
508 | dev->afe_ref_count = 0x260; | ||
509 | break; | ||
510 | default: | ||
511 | break; | ||
512 | } | ||
513 | |||
514 | status = cx231xx_afe_init_super_block(dev, dev->afe_ref_count); | ||
515 | |||
516 | return status; | ||
517 | } | ||
518 | |||
519 | /****************************************************************************** | ||
520 | * V I D E O / A U D I O D E C O D E R C O N T R O L functions * | ||
521 | ******************************************************************************/ | ||
522 | static int vid_blk_write_byte(struct cx231xx *dev, u16 saddr, u8 data) | ||
523 | { | ||
524 | return cx231xx_write_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
525 | saddr, 2, data, 1); | ||
526 | } | ||
527 | |||
528 | static int vid_blk_read_byte(struct cx231xx *dev, u16 saddr, u8 *data) | ||
529 | { | ||
530 | int status; | ||
531 | u32 temp = 0; | ||
532 | |||
533 | status = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
534 | saddr, 2, &temp, 1); | ||
535 | *data = (u8) temp; | ||
536 | return status; | ||
537 | } | ||
538 | |||
539 | static int vid_blk_write_word(struct cx231xx *dev, u16 saddr, u32 data) | ||
540 | { | ||
541 | return cx231xx_write_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
542 | saddr, 2, data, 4); | ||
543 | } | ||
544 | |||
545 | static int vid_blk_read_word(struct cx231xx *dev, u16 saddr, u32 *data) | ||
546 | { | ||
547 | return cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
548 | saddr, 2, data, 4); | ||
549 | } | ||
550 | int cx231xx_check_fw(struct cx231xx *dev) | ||
551 | { | ||
552 | u8 temp = 0; | ||
553 | int status = 0; | ||
554 | status = vid_blk_read_byte(dev, DL_CTL_ADDRESS_LOW, &temp); | ||
555 | if (status < 0) | ||
556 | return status; | ||
557 | else | ||
558 | return temp; | ||
559 | |||
560 | } | ||
561 | |||
562 | int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input) | ||
563 | { | ||
564 | int status = 0; | ||
565 | |||
566 | switch (INPUT(input)->type) { | ||
567 | case CX231XX_VMUX_COMPOSITE1: | ||
568 | case CX231XX_VMUX_SVIDEO: | ||
569 | if ((dev->current_pcb_config.type == USB_BUS_POWER) && | ||
570 | (dev->power_mode != POLARIS_AVMODE_ENXTERNAL_AV)) { | ||
571 | /* External AV */ | ||
572 | status = cx231xx_set_power_mode(dev, | ||
573 | POLARIS_AVMODE_ENXTERNAL_AV); | ||
574 | if (status < 0) { | ||
575 | cx231xx_errdev("%s: set_power_mode : Failed to" | ||
576 | " set Power - errCode [%d]!\n", | ||
577 | __func__, status); | ||
578 | return status; | ||
579 | } | ||
580 | } | ||
581 | status = cx231xx_set_decoder_video_input(dev, | ||
582 | INPUT(input)->type, | ||
583 | INPUT(input)->vmux); | ||
584 | break; | ||
585 | case CX231XX_VMUX_TELEVISION: | ||
586 | case CX231XX_VMUX_CABLE: | ||
587 | if ((dev->current_pcb_config.type == USB_BUS_POWER) && | ||
588 | (dev->power_mode != POLARIS_AVMODE_ANALOGT_TV)) { | ||
589 | /* Tuner */ | ||
590 | status = cx231xx_set_power_mode(dev, | ||
591 | POLARIS_AVMODE_ANALOGT_TV); | ||
592 | if (status < 0) { | ||
593 | cx231xx_errdev("%s: set_power_mode:Failed" | ||
594 | " to set Power - errCode [%d]!\n", | ||
595 | __func__, status); | ||
596 | return status; | ||
597 | } | ||
598 | } | ||
599 | if (dev->tuner_type == TUNER_NXP_TDA18271) | ||
600 | status = cx231xx_set_decoder_video_input(dev, | ||
601 | CX231XX_VMUX_TELEVISION, | ||
602 | INPUT(input)->vmux); | ||
603 | else | ||
604 | status = cx231xx_set_decoder_video_input(dev, | ||
605 | CX231XX_VMUX_COMPOSITE1, | ||
606 | INPUT(input)->vmux); | ||
607 | |||
608 | break; | ||
609 | default: | ||
610 | cx231xx_errdev("%s: set_power_mode : Unknown Input %d !\n", | ||
611 | __func__, INPUT(input)->type); | ||
612 | break; | ||
613 | } | ||
614 | |||
615 | /* save the selection */ | ||
616 | dev->video_input = input; | ||
617 | |||
618 | return status; | ||
619 | } | ||
620 | |||
621 | int cx231xx_set_decoder_video_input(struct cx231xx *dev, | ||
622 | u8 pin_type, u8 input) | ||
623 | { | ||
624 | int status = 0; | ||
625 | u32 value = 0; | ||
626 | |||
627 | if (pin_type != dev->video_input) { | ||
628 | status = cx231xx_afe_adjust_ref_count(dev, pin_type); | ||
629 | if (status < 0) { | ||
630 | cx231xx_errdev("%s: adjust_ref_count :Failed to set" | ||
631 | "AFE input mux - errCode [%d]!\n", | ||
632 | __func__, status); | ||
633 | return status; | ||
634 | } | ||
635 | } | ||
636 | |||
637 | /* call afe block to set video inputs */ | ||
638 | status = cx231xx_afe_set_input_mux(dev, input); | ||
639 | if (status < 0) { | ||
640 | cx231xx_errdev("%s: set_input_mux :Failed to set" | ||
641 | " AFE input mux - errCode [%d]!\n", | ||
642 | __func__, status); | ||
643 | return status; | ||
644 | } | ||
645 | |||
646 | switch (pin_type) { | ||
647 | case CX231XX_VMUX_COMPOSITE1: | ||
648 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
649 | value |= (0 << 13) | (1 << 4); | ||
650 | value &= ~(1 << 5); | ||
651 | |||
652 | /* set [24:23] [22:15] to 0 */ | ||
653 | value &= (~(0x1ff8000)); | ||
654 | /* set FUNC_MODE[24:23] = 2 IF_MOD[22:15] = 0 */ | ||
655 | value |= 0x1000000; | ||
656 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
657 | |||
658 | status = vid_blk_read_word(dev, OUT_CTRL1, &value); | ||
659 | value |= (1 << 7); | ||
660 | status = vid_blk_write_word(dev, OUT_CTRL1, value); | ||
661 | |||
662 | /* Set output mode */ | ||
663 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
664 | VID_BLK_I2C_ADDRESS, | ||
665 | OUT_CTRL1, | ||
666 | FLD_OUT_MODE, | ||
667 | dev->board.output_mode); | ||
668 | |||
669 | /* Tell DIF object to go to baseband mode */ | ||
670 | status = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | ||
671 | if (status < 0) { | ||
672 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | ||
673 | " mode- errCode [%d]!\n", | ||
674 | __func__, status); | ||
675 | return status; | ||
676 | } | ||
677 | |||
678 | /* Read the DFE_CTRL1 register */ | ||
679 | status = vid_blk_read_word(dev, DFE_CTRL1, &value); | ||
680 | |||
681 | /* enable the VBI_GATE_EN */ | ||
682 | value |= FLD_VBI_GATE_EN; | ||
683 | |||
684 | /* Enable the auto-VGA enable */ | ||
685 | value |= FLD_VGA_AUTO_EN; | ||
686 | |||
687 | /* Write it back */ | ||
688 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
689 | |||
690 | /* Disable auto config of registers */ | ||
691 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
692 | VID_BLK_I2C_ADDRESS, | ||
693 | MODE_CTRL, FLD_ACFG_DIS, | ||
694 | cx231xx_set_field(FLD_ACFG_DIS, 1)); | ||
695 | |||
696 | /* Set CVBS input mode */ | ||
697 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
698 | VID_BLK_I2C_ADDRESS, | ||
699 | MODE_CTRL, FLD_INPUT_MODE, | ||
700 | cx231xx_set_field(FLD_INPUT_MODE, INPUT_MODE_CVBS_0)); | ||
701 | break; | ||
702 | case CX231XX_VMUX_SVIDEO: | ||
703 | /* Disable the use of DIF */ | ||
704 | |||
705 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
706 | |||
707 | /* set [24:23] [22:15] to 0 */ | ||
708 | value &= (~(0x1ff8000)); | ||
709 | /* set FUNC_MODE[24:23] = 2 | ||
710 | IF_MOD[22:15] = 0 DCR_BYP_CH2[4:4] = 1; */ | ||
711 | value |= 0x1000010; | ||
712 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
713 | |||
714 | /* Tell DIF object to go to baseband mode */ | ||
715 | status = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | ||
716 | if (status < 0) { | ||
717 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | ||
718 | " mode- errCode [%d]!\n", | ||
719 | __func__, status); | ||
720 | return status; | ||
721 | } | ||
722 | |||
723 | /* Read the DFE_CTRL1 register */ | ||
724 | status = vid_blk_read_word(dev, DFE_CTRL1, &value); | ||
725 | |||
726 | /* enable the VBI_GATE_EN */ | ||
727 | value |= FLD_VBI_GATE_EN; | ||
728 | |||
729 | /* Enable the auto-VGA enable */ | ||
730 | value |= FLD_VGA_AUTO_EN; | ||
731 | |||
732 | /* Write it back */ | ||
733 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
734 | |||
735 | /* Disable auto config of registers */ | ||
736 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
737 | VID_BLK_I2C_ADDRESS, | ||
738 | MODE_CTRL, FLD_ACFG_DIS, | ||
739 | cx231xx_set_field(FLD_ACFG_DIS, 1)); | ||
740 | |||
741 | /* Set YC input mode */ | ||
742 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
743 | VID_BLK_I2C_ADDRESS, | ||
744 | MODE_CTRL, | ||
745 | FLD_INPUT_MODE, | ||
746 | cx231xx_set_field(FLD_INPUT_MODE, INPUT_MODE_YC_1)); | ||
747 | |||
748 | /* Chroma to ADC2 */ | ||
749 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
750 | value |= FLD_CHROMA_IN_SEL; /* set the chroma in select */ | ||
751 | |||
752 | /* Clear VGA_SEL_CH2 and VGA_SEL_CH3 (bits 7 and 8) | ||
753 | This sets them to use video | ||
754 | rather than audio. Only one of the two will be in use. */ | ||
755 | value &= ~(FLD_VGA_SEL_CH2 | FLD_VGA_SEL_CH3); | ||
756 | |||
757 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
758 | |||
759 | status = cx231xx_afe_set_mode(dev, AFE_MODE_BASEBAND); | ||
760 | break; | ||
761 | case CX231XX_VMUX_TELEVISION: | ||
762 | case CX231XX_VMUX_CABLE: | ||
763 | default: | ||
764 | /* TODO: Test if this is also needed for xc2028/xc3028 */ | ||
765 | if (dev->board.tuner_type == TUNER_XC5000) { | ||
766 | /* Disable the use of DIF */ | ||
767 | |||
768 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
769 | value |= (0 << 13) | (1 << 4); | ||
770 | value &= ~(1 << 5); | ||
771 | |||
772 | /* set [24:23] [22:15] to 0 */ | ||
773 | value &= (~(0x1FF8000)); | ||
774 | /* set FUNC_MODE[24:23] = 2 IF_MOD[22:15] = 0 */ | ||
775 | value |= 0x1000000; | ||
776 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
777 | |||
778 | status = vid_blk_read_word(dev, OUT_CTRL1, &value); | ||
779 | value |= (1 << 7); | ||
780 | status = vid_blk_write_word(dev, OUT_CTRL1, value); | ||
781 | |||
782 | /* Set output mode */ | ||
783 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
784 | VID_BLK_I2C_ADDRESS, | ||
785 | OUT_CTRL1, FLD_OUT_MODE, | ||
786 | dev->board.output_mode); | ||
787 | |||
788 | /* Tell DIF object to go to baseband mode */ | ||
789 | status = cx231xx_dif_set_standard(dev, | ||
790 | DIF_USE_BASEBAND); | ||
791 | if (status < 0) { | ||
792 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | ||
793 | " mode- errCode [%d]!\n", | ||
794 | __func__, status); | ||
795 | return status; | ||
796 | } | ||
797 | |||
798 | /* Read the DFE_CTRL1 register */ | ||
799 | status = vid_blk_read_word(dev, DFE_CTRL1, &value); | ||
800 | |||
801 | /* enable the VBI_GATE_EN */ | ||
802 | value |= FLD_VBI_GATE_EN; | ||
803 | |||
804 | /* Enable the auto-VGA enable */ | ||
805 | value |= FLD_VGA_AUTO_EN; | ||
806 | |||
807 | /* Write it back */ | ||
808 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
809 | |||
810 | /* Disable auto config of registers */ | ||
811 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
812 | VID_BLK_I2C_ADDRESS, | ||
813 | MODE_CTRL, FLD_ACFG_DIS, | ||
814 | cx231xx_set_field(FLD_ACFG_DIS, 1)); | ||
815 | |||
816 | /* Set CVBS input mode */ | ||
817 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
818 | VID_BLK_I2C_ADDRESS, | ||
819 | MODE_CTRL, FLD_INPUT_MODE, | ||
820 | cx231xx_set_field(FLD_INPUT_MODE, | ||
821 | INPUT_MODE_CVBS_0)); | ||
822 | } else { | ||
823 | /* Enable the DIF for the tuner */ | ||
824 | |||
825 | /* Reinitialize the DIF */ | ||
826 | status = cx231xx_dif_set_standard(dev, dev->norm); | ||
827 | if (status < 0) { | ||
828 | cx231xx_errdev("%s: cx231xx_dif set to By pass" | ||
829 | " mode- errCode [%d]!\n", | ||
830 | __func__, status); | ||
831 | return status; | ||
832 | } | ||
833 | |||
834 | /* Make sure bypass is cleared */ | ||
835 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, &value); | ||
836 | |||
837 | /* Clear the bypass bit */ | ||
838 | value &= ~FLD_DIF_DIF_BYPASS; | ||
839 | |||
840 | /* Enable the use of the DIF block */ | ||
841 | status = vid_blk_write_word(dev, DIF_MISC_CTRL, value); | ||
842 | |||
843 | /* Read the DFE_CTRL1 register */ | ||
844 | status = vid_blk_read_word(dev, DFE_CTRL1, &value); | ||
845 | |||
846 | /* Disable the VBI_GATE_EN */ | ||
847 | value &= ~FLD_VBI_GATE_EN; | ||
848 | |||
849 | /* Enable the auto-VGA enable, AGC, and | ||
850 | set the skip count to 2 */ | ||
851 | value |= FLD_VGA_AUTO_EN | FLD_AGC_AUTO_EN | 0x00200000; | ||
852 | |||
853 | /* Write it back */ | ||
854 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
855 | |||
856 | /* Wait until AGC locks up */ | ||
857 | msleep(1); | ||
858 | |||
859 | /* Disable the auto-VGA enable AGC */ | ||
860 | value &= ~(FLD_VGA_AUTO_EN); | ||
861 | |||
862 | /* Write it back */ | ||
863 | status = vid_blk_write_word(dev, DFE_CTRL1, value); | ||
864 | |||
865 | /* Enable Polaris B0 AGC output */ | ||
866 | status = vid_blk_read_word(dev, PIN_CTRL, &value); | ||
867 | value |= (FLD_OEF_AGC_RF) | | ||
868 | (FLD_OEF_AGC_IFVGA) | | ||
869 | (FLD_OEF_AGC_IF); | ||
870 | status = vid_blk_write_word(dev, PIN_CTRL, value); | ||
871 | |||
872 | /* Set output mode */ | ||
873 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
874 | VID_BLK_I2C_ADDRESS, | ||
875 | OUT_CTRL1, FLD_OUT_MODE, | ||
876 | dev->board.output_mode); | ||
877 | |||
878 | /* Disable auto config of registers */ | ||
879 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
880 | VID_BLK_I2C_ADDRESS, | ||
881 | MODE_CTRL, FLD_ACFG_DIS, | ||
882 | cx231xx_set_field(FLD_ACFG_DIS, 1)); | ||
883 | |||
884 | /* Set CVBS input mode */ | ||
885 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
886 | VID_BLK_I2C_ADDRESS, | ||
887 | MODE_CTRL, FLD_INPUT_MODE, | ||
888 | cx231xx_set_field(FLD_INPUT_MODE, | ||
889 | INPUT_MODE_CVBS_0)); | ||
890 | |||
891 | /* Set some bits in AFE_CTRL so that channel 2 or 3 | ||
892 | * is ready to receive audio */ | ||
893 | /* Clear clamp for channels 2 and 3 (bit 16-17) */ | ||
894 | /* Clear droop comp (bit 19-20) */ | ||
895 | /* Set VGA_SEL (for audio control) (bit 7-8) */ | ||
896 | status = vid_blk_read_word(dev, AFE_CTRL, &value); | ||
897 | |||
898 | /*Set Func mode:01-DIF 10-baseband 11-YUV*/ | ||
899 | value &= (~(FLD_FUNC_MODE)); | ||
900 | value |= 0x800000; | ||
901 | |||
902 | value |= FLD_VGA_SEL_CH3 | FLD_VGA_SEL_CH2; | ||
903 | |||
904 | status = vid_blk_write_word(dev, AFE_CTRL, value); | ||
905 | |||
906 | if (dev->tuner_type == TUNER_NXP_TDA18271) { | ||
907 | status = vid_blk_read_word(dev, PIN_CTRL, | ||
908 | &value); | ||
909 | status = vid_blk_write_word(dev, PIN_CTRL, | ||
910 | (value & 0xFFFFFFEF)); | ||
911 | } | ||
912 | |||
913 | break; | ||
914 | |||
915 | } | ||
916 | break; | ||
917 | } | ||
918 | |||
919 | /* Set raw VBI mode */ | ||
920 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
921 | VID_BLK_I2C_ADDRESS, | ||
922 | OUT_CTRL1, FLD_VBIHACTRAW_EN, | ||
923 | cx231xx_set_field(FLD_VBIHACTRAW_EN, 1)); | ||
924 | |||
925 | status = vid_blk_read_word(dev, OUT_CTRL1, &value); | ||
926 | if (value & 0x02) { | ||
927 | value |= (1 << 19); | ||
928 | status = vid_blk_write_word(dev, OUT_CTRL1, value); | ||
929 | } | ||
930 | |||
931 | return status; | ||
932 | } | ||
933 | |||
934 | void cx231xx_enable656(struct cx231xx *dev) | ||
935 | { | ||
936 | u8 temp = 0; | ||
937 | /*enable TS1 data[0:7] as output to export 656*/ | ||
938 | |||
939 | vid_blk_write_byte(dev, TS1_PIN_CTL0, 0xFF); | ||
940 | |||
941 | /*enable TS1 clock as output to export 656*/ | ||
942 | |||
943 | vid_blk_read_byte(dev, TS1_PIN_CTL1, &temp); | ||
944 | temp = temp|0x04; | ||
945 | |||
946 | vid_blk_write_byte(dev, TS1_PIN_CTL1, temp); | ||
947 | } | ||
948 | EXPORT_SYMBOL_GPL(cx231xx_enable656); | ||
949 | |||
950 | void cx231xx_disable656(struct cx231xx *dev) | ||
951 | { | ||
952 | u8 temp = 0; | ||
953 | |||
954 | vid_blk_write_byte(dev, TS1_PIN_CTL0, 0x00); | ||
955 | |||
956 | vid_blk_read_byte(dev, TS1_PIN_CTL1, &temp); | ||
957 | temp = temp&0xFB; | ||
958 | |||
959 | vid_blk_write_byte(dev, TS1_PIN_CTL1, temp); | ||
960 | } | ||
961 | EXPORT_SYMBOL_GPL(cx231xx_disable656); | ||
962 | |||
963 | /* | ||
964 | * Handle any video-mode specific overrides that are different | ||
965 | * on a per video standards basis after touching the MODE_CTRL | ||
966 | * register which resets many values for autodetect | ||
967 | */ | ||
968 | int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev) | ||
969 | { | ||
970 | int status = 0; | ||
971 | |||
972 | cx231xx_info("do_mode_ctrl_overrides : 0x%x\n", | ||
973 | (unsigned int)dev->norm); | ||
974 | |||
975 | /* Change the DFE_CTRL3 bp_percent to fix flagging */ | ||
976 | status = vid_blk_write_word(dev, DFE_CTRL3, 0xCD3F0280); | ||
977 | |||
978 | if (dev->norm & (V4L2_STD_NTSC | V4L2_STD_PAL_M)) { | ||
979 | cx231xx_info("do_mode_ctrl_overrides NTSC\n"); | ||
980 | |||
981 | /* Move the close caption lines out of active video, | ||
982 | adjust the active video start point */ | ||
983 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
984 | VID_BLK_I2C_ADDRESS, | ||
985 | VERT_TIM_CTRL, | ||
986 | FLD_VBLANK_CNT, 0x18); | ||
987 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
988 | VID_BLK_I2C_ADDRESS, | ||
989 | VERT_TIM_CTRL, | ||
990 | FLD_VACTIVE_CNT, | ||
991 | 0x1E7000); | ||
992 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
993 | VID_BLK_I2C_ADDRESS, | ||
994 | VERT_TIM_CTRL, | ||
995 | FLD_V656BLANK_CNT, | ||
996 | 0x1C000000); | ||
997 | |||
998 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
999 | VID_BLK_I2C_ADDRESS, | ||
1000 | HORIZ_TIM_CTRL, | ||
1001 | FLD_HBLANK_CNT, | ||
1002 | cx231xx_set_field | ||
1003 | (FLD_HBLANK_CNT, 0x79)); | ||
1004 | |||
1005 | } else if (dev->norm & V4L2_STD_SECAM) { | ||
1006 | cx231xx_info("do_mode_ctrl_overrides SECAM\n"); | ||
1007 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1008 | VID_BLK_I2C_ADDRESS, | ||
1009 | VERT_TIM_CTRL, | ||
1010 | FLD_VBLANK_CNT, 0x20); | ||
1011 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1012 | VID_BLK_I2C_ADDRESS, | ||
1013 | VERT_TIM_CTRL, | ||
1014 | FLD_VACTIVE_CNT, | ||
1015 | cx231xx_set_field | ||
1016 | (FLD_VACTIVE_CNT, | ||
1017 | 0x244)); | ||
1018 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1019 | VID_BLK_I2C_ADDRESS, | ||
1020 | VERT_TIM_CTRL, | ||
1021 | FLD_V656BLANK_CNT, | ||
1022 | cx231xx_set_field | ||
1023 | (FLD_V656BLANK_CNT, | ||
1024 | 0x24)); | ||
1025 | /* Adjust the active video horizontal start point */ | ||
1026 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1027 | VID_BLK_I2C_ADDRESS, | ||
1028 | HORIZ_TIM_CTRL, | ||
1029 | FLD_HBLANK_CNT, | ||
1030 | cx231xx_set_field | ||
1031 | (FLD_HBLANK_CNT, 0x85)); | ||
1032 | } else { | ||
1033 | cx231xx_info("do_mode_ctrl_overrides PAL\n"); | ||
1034 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1035 | VID_BLK_I2C_ADDRESS, | ||
1036 | VERT_TIM_CTRL, | ||
1037 | FLD_VBLANK_CNT, 0x20); | ||
1038 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1039 | VID_BLK_I2C_ADDRESS, | ||
1040 | VERT_TIM_CTRL, | ||
1041 | FLD_VACTIVE_CNT, | ||
1042 | cx231xx_set_field | ||
1043 | (FLD_VACTIVE_CNT, | ||
1044 | 0x244)); | ||
1045 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1046 | VID_BLK_I2C_ADDRESS, | ||
1047 | VERT_TIM_CTRL, | ||
1048 | FLD_V656BLANK_CNT, | ||
1049 | cx231xx_set_field | ||
1050 | (FLD_V656BLANK_CNT, | ||
1051 | 0x24)); | ||
1052 | /* Adjust the active video horizontal start point */ | ||
1053 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1054 | VID_BLK_I2C_ADDRESS, | ||
1055 | HORIZ_TIM_CTRL, | ||
1056 | FLD_HBLANK_CNT, | ||
1057 | cx231xx_set_field | ||
1058 | (FLD_HBLANK_CNT, 0x85)); | ||
1059 | |||
1060 | } | ||
1061 | |||
1062 | return status; | ||
1063 | } | ||
1064 | |||
1065 | int cx231xx_unmute_audio(struct cx231xx *dev) | ||
1066 | { | ||
1067 | return vid_blk_write_byte(dev, PATH1_VOL_CTL, 0x24); | ||
1068 | } | ||
1069 | EXPORT_SYMBOL_GPL(cx231xx_unmute_audio); | ||
1070 | |||
1071 | int stopAudioFirmware(struct cx231xx *dev) | ||
1072 | { | ||
1073 | return vid_blk_write_byte(dev, DL_CTL_CONTROL, 0x03); | ||
1074 | } | ||
1075 | |||
1076 | int restartAudioFirmware(struct cx231xx *dev) | ||
1077 | { | ||
1078 | return vid_blk_write_byte(dev, DL_CTL_CONTROL, 0x13); | ||
1079 | } | ||
1080 | |||
1081 | int cx231xx_set_audio_input(struct cx231xx *dev, u8 input) | ||
1082 | { | ||
1083 | int status = 0; | ||
1084 | enum AUDIO_INPUT ainput = AUDIO_INPUT_LINE; | ||
1085 | |||
1086 | switch (INPUT(input)->amux) { | ||
1087 | case CX231XX_AMUX_VIDEO: | ||
1088 | ainput = AUDIO_INPUT_TUNER_TV; | ||
1089 | break; | ||
1090 | case CX231XX_AMUX_LINE_IN: | ||
1091 | status = cx231xx_i2s_blk_set_audio_input(dev, input); | ||
1092 | ainput = AUDIO_INPUT_LINE; | ||
1093 | break; | ||
1094 | default: | ||
1095 | break; | ||
1096 | } | ||
1097 | |||
1098 | status = cx231xx_set_audio_decoder_input(dev, ainput); | ||
1099 | |||
1100 | return status; | ||
1101 | } | ||
1102 | |||
1103 | int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | ||
1104 | enum AUDIO_INPUT audio_input) | ||
1105 | { | ||
1106 | u32 dwval; | ||
1107 | int status; | ||
1108 | u8 gen_ctrl; | ||
1109 | u32 value = 0; | ||
1110 | |||
1111 | /* Put it in soft reset */ | ||
1112 | status = vid_blk_read_byte(dev, GENERAL_CTL, &gen_ctrl); | ||
1113 | gen_ctrl |= 1; | ||
1114 | status = vid_blk_write_byte(dev, GENERAL_CTL, gen_ctrl); | ||
1115 | |||
1116 | switch (audio_input) { | ||
1117 | case AUDIO_INPUT_LINE: | ||
1118 | /* setup AUD_IO control from Merlin paralle output */ | ||
1119 | value = cx231xx_set_field(FLD_AUD_CHAN1_SRC, | ||
1120 | AUD_CHAN_SRC_PARALLEL); | ||
1121 | status = vid_blk_write_word(dev, AUD_IO_CTRL, value); | ||
1122 | |||
1123 | /* setup input to Merlin, SRC2 connect to AC97 | ||
1124 | bypass upsample-by-2, slave mode, sony mode, left justify | ||
1125 | adr 091c, dat 01000000 */ | ||
1126 | status = vid_blk_read_word(dev, AC97_CTL, &dwval); | ||
1127 | |||
1128 | status = vid_blk_write_word(dev, AC97_CTL, | ||
1129 | (dwval | FLD_AC97_UP2X_BYPASS)); | ||
1130 | |||
1131 | /* select the parallel1 and SRC3 */ | ||
1132 | status = vid_blk_write_word(dev, BAND_OUT_SEL, | ||
1133 | cx231xx_set_field(FLD_SRC3_IN_SEL, 0x0) | | ||
1134 | cx231xx_set_field(FLD_SRC3_CLK_SEL, 0x0) | | ||
1135 | cx231xx_set_field(FLD_PARALLEL1_SRC_SEL, 0x0)); | ||
1136 | |||
1137 | /* unmute all, AC97 in, independence mode | ||
1138 | adr 08d0, data 0x00063073 */ | ||
1139 | status = vid_blk_write_word(dev, DL_CTL, 0x3000001); | ||
1140 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x00063073); | ||
1141 | |||
1142 | /* set AVC maximum threshold, adr 08d4, dat ffff0024 */ | ||
1143 | status = vid_blk_read_word(dev, PATH1_VOL_CTL, &dwval); | ||
1144 | status = vid_blk_write_word(dev, PATH1_VOL_CTL, | ||
1145 | (dwval | FLD_PATH1_AVC_THRESHOLD)); | ||
1146 | |||
1147 | /* set SC maximum threshold, adr 08ec, dat ffffb3a3 */ | ||
1148 | status = vid_blk_read_word(dev, PATH1_SC_CTL, &dwval); | ||
1149 | status = vid_blk_write_word(dev, PATH1_SC_CTL, | ||
1150 | (dwval | FLD_PATH1_SC_THRESHOLD)); | ||
1151 | break; | ||
1152 | |||
1153 | case AUDIO_INPUT_TUNER_TV: | ||
1154 | default: | ||
1155 | status = stopAudioFirmware(dev); | ||
1156 | /* Setup SRC sources and clocks */ | ||
1157 | status = vid_blk_write_word(dev, BAND_OUT_SEL, | ||
1158 | cx231xx_set_field(FLD_SRC6_IN_SEL, 0x00) | | ||
1159 | cx231xx_set_field(FLD_SRC6_CLK_SEL, 0x01) | | ||
1160 | cx231xx_set_field(FLD_SRC5_IN_SEL, 0x00) | | ||
1161 | cx231xx_set_field(FLD_SRC5_CLK_SEL, 0x02) | | ||
1162 | cx231xx_set_field(FLD_SRC4_IN_SEL, 0x02) | | ||
1163 | cx231xx_set_field(FLD_SRC4_CLK_SEL, 0x03) | | ||
1164 | cx231xx_set_field(FLD_SRC3_IN_SEL, 0x00) | | ||
1165 | cx231xx_set_field(FLD_SRC3_CLK_SEL, 0x00) | | ||
1166 | cx231xx_set_field(FLD_BASEBAND_BYPASS_CTL, 0x00) | | ||
1167 | cx231xx_set_field(FLD_AC97_SRC_SEL, 0x03) | | ||
1168 | cx231xx_set_field(FLD_I2S_SRC_SEL, 0x00) | | ||
1169 | cx231xx_set_field(FLD_PARALLEL2_SRC_SEL, 0x02) | | ||
1170 | cx231xx_set_field(FLD_PARALLEL1_SRC_SEL, 0x01)); | ||
1171 | |||
1172 | /* Setup the AUD_IO control */ | ||
1173 | status = vid_blk_write_word(dev, AUD_IO_CTRL, | ||
1174 | cx231xx_set_field(FLD_I2S_PORT_DIR, 0x00) | | ||
1175 | cx231xx_set_field(FLD_I2S_OUT_SRC, 0x00) | | ||
1176 | cx231xx_set_field(FLD_AUD_CHAN3_SRC, 0x00) | | ||
1177 | cx231xx_set_field(FLD_AUD_CHAN2_SRC, 0x00) | | ||
1178 | cx231xx_set_field(FLD_AUD_CHAN1_SRC, 0x03)); | ||
1179 | |||
1180 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x1F063870); | ||
1181 | |||
1182 | /* setAudioStandard(_audio_standard); */ | ||
1183 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x00063870); | ||
1184 | |||
1185 | status = restartAudioFirmware(dev); | ||
1186 | |||
1187 | switch (dev->board.tuner_type) { | ||
1188 | case TUNER_XC5000: | ||
1189 | /* SIF passthrough at 28.6363 MHz sample rate */ | ||
1190 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1191 | VID_BLK_I2C_ADDRESS, | ||
1192 | CHIP_CTRL, | ||
1193 | FLD_SIF_EN, | ||
1194 | cx231xx_set_field(FLD_SIF_EN, 1)); | ||
1195 | break; | ||
1196 | case TUNER_NXP_TDA18271: | ||
1197 | /* Normal mode: SIF passthrough at 14.32 MHz */ | ||
1198 | status = cx231xx_read_modify_write_i2c_dword(dev, | ||
1199 | VID_BLK_I2C_ADDRESS, | ||
1200 | CHIP_CTRL, | ||
1201 | FLD_SIF_EN, | ||
1202 | cx231xx_set_field(FLD_SIF_EN, 0)); | ||
1203 | break; | ||
1204 | default: | ||
1205 | /* This is just a casual suggestion to people adding | ||
1206 | new boards in case they use a tuner type we don't | ||
1207 | currently know about */ | ||
1208 | printk(KERN_INFO "Unknown tuner type configuring SIF"); | ||
1209 | break; | ||
1210 | } | ||
1211 | break; | ||
1212 | |||
1213 | case AUDIO_INPUT_TUNER_FM: | ||
1214 | /* use SIF for FM radio | ||
1215 | setupFM(); | ||
1216 | setAudioStandard(_audio_standard); | ||
1217 | */ | ||
1218 | break; | ||
1219 | |||
1220 | case AUDIO_INPUT_MUTE: | ||
1221 | status = vid_blk_write_word(dev, PATH1_CTL1, 0x1F011012); | ||
1222 | break; | ||
1223 | } | ||
1224 | |||
1225 | /* Take it out of soft reset */ | ||
1226 | status = vid_blk_read_byte(dev, GENERAL_CTL, &gen_ctrl); | ||
1227 | gen_ctrl &= ~1; | ||
1228 | status = vid_blk_write_byte(dev, GENERAL_CTL, gen_ctrl); | ||
1229 | |||
1230 | return status; | ||
1231 | } | ||
1232 | |||
1233 | /****************************************************************************** | ||
1234 | * C H I P Specific C O N T R O L functions * | ||
1235 | ******************************************************************************/ | ||
1236 | int cx231xx_init_ctrl_pin_status(struct cx231xx *dev) | ||
1237 | { | ||
1238 | u32 value; | ||
1239 | int status = 0; | ||
1240 | |||
1241 | status = vid_blk_read_word(dev, PIN_CTRL, &value); | ||
1242 | value |= (~dev->board.ctl_pin_status_mask); | ||
1243 | status = vid_blk_write_word(dev, PIN_CTRL, value); | ||
1244 | |||
1245 | return status; | ||
1246 | } | ||
1247 | |||
1248 | int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, | ||
1249 | u8 analog_or_digital) | ||
1250 | { | ||
1251 | int status = 0; | ||
1252 | |||
1253 | /* first set the direction to output */ | ||
1254 | status = cx231xx_set_gpio_direction(dev, | ||
1255 | dev->board. | ||
1256 | agc_analog_digital_select_gpio, 1); | ||
1257 | |||
1258 | /* 0 - demod ; 1 - Analog mode */ | ||
1259 | status = cx231xx_set_gpio_value(dev, | ||
1260 | dev->board.agc_analog_digital_select_gpio, | ||
1261 | analog_or_digital); | ||
1262 | |||
1263 | return status; | ||
1264 | } | ||
1265 | |||
1266 | int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3) | ||
1267 | { | ||
1268 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1269 | int status = 0; | ||
1270 | bool current_is_port_3; | ||
1271 | |||
1272 | if (dev->board.dont_use_port_3) | ||
1273 | is_port_3 = false; | ||
1274 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, | ||
1275 | PWR_CTL_EN, value, 4); | ||
1276 | if (status < 0) | ||
1277 | return status; | ||
1278 | |||
1279 | current_is_port_3 = value[0] & I2C_DEMOD_EN ? true : false; | ||
1280 | |||
1281 | /* Just return, if already using the right port */ | ||
1282 | if (current_is_port_3 == is_port_3) | ||
1283 | return 0; | ||
1284 | |||
1285 | if (is_port_3) | ||
1286 | value[0] |= I2C_DEMOD_EN; | ||
1287 | else | ||
1288 | value[0] &= ~I2C_DEMOD_EN; | ||
1289 | |||
1290 | cx231xx_info("Changing the i2c master port to %d\n", | ||
1291 | is_port_3 ? 3 : 1); | ||
1292 | |||
1293 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1294 | PWR_CTL_EN, value, 4); | ||
1295 | |||
1296 | return status; | ||
1297 | |||
1298 | } | ||
1299 | EXPORT_SYMBOL_GPL(cx231xx_enable_i2c_port_3); | ||
1300 | |||
1301 | void update_HH_register_after_set_DIF(struct cx231xx *dev) | ||
1302 | { | ||
1303 | /* | ||
1304 | u8 status = 0; | ||
1305 | u32 value = 0; | ||
1306 | |||
1307 | vid_blk_write_word(dev, PIN_CTRL, 0xA0FFF82F); | ||
1308 | vid_blk_write_word(dev, DIF_MISC_CTRL, 0x0A203F11); | ||
1309 | vid_blk_write_word(dev, DIF_SRC_PHASE_INC, 0x1BEFBF06); | ||
1310 | |||
1311 | status = vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | ||
1312 | vid_blk_write_word(dev, AFE_CTRL_C2HH_SRC_CTRL, 0x4485D390); | ||
1313 | status = vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | ||
1314 | */ | ||
1315 | } | ||
1316 | |||
1317 | void cx231xx_dump_HH_reg(struct cx231xx *dev) | ||
1318 | { | ||
1319 | u32 value = 0; | ||
1320 | u16 i = 0; | ||
1321 | |||
1322 | value = 0x45005390; | ||
1323 | vid_blk_write_word(dev, 0x104, value); | ||
1324 | |||
1325 | for (i = 0x100; i < 0x140; i++) { | ||
1326 | vid_blk_read_word(dev, i, &value); | ||
1327 | cx231xx_info("reg0x%x=0x%x\n", i, value); | ||
1328 | i = i+3; | ||
1329 | } | ||
1330 | |||
1331 | for (i = 0x300; i < 0x400; i++) { | ||
1332 | vid_blk_read_word(dev, i, &value); | ||
1333 | cx231xx_info("reg0x%x=0x%x\n", i, value); | ||
1334 | i = i+3; | ||
1335 | } | ||
1336 | |||
1337 | for (i = 0x400; i < 0x440; i++) { | ||
1338 | vid_blk_read_word(dev, i, &value); | ||
1339 | cx231xx_info("reg0x%x=0x%x\n", i, value); | ||
1340 | i = i+3; | ||
1341 | } | ||
1342 | |||
1343 | vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | ||
1344 | cx231xx_info("AFE_CTRL_C2HH_SRC_CTRL=0x%x\n", value); | ||
1345 | vid_blk_write_word(dev, AFE_CTRL_C2HH_SRC_CTRL, 0x4485D390); | ||
1346 | vid_blk_read_word(dev, AFE_CTRL_C2HH_SRC_CTRL, &value); | ||
1347 | cx231xx_info("AFE_CTRL_C2HH_SRC_CTRL=0x%x\n", value); | ||
1348 | } | ||
1349 | |||
1350 | void cx231xx_dump_SC_reg(struct cx231xx *dev) | ||
1351 | { | ||
1352 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1353 | cx231xx_info("cx231xx_dump_SC_reg!\n"); | ||
1354 | |||
1355 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, | ||
1356 | value, 4); | ||
1357 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", BOARD_CFG_STAT, value[0], | ||
1358 | value[1], value[2], value[3]); | ||
1359 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS_MODE_REG, | ||
1360 | value, 4); | ||
1361 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS_MODE_REG, value[0], | ||
1362 | value[1], value[2], value[3]); | ||
1363 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS1_CFG_REG, | ||
1364 | value, 4); | ||
1365 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS1_CFG_REG, value[0], | ||
1366 | value[1], value[2], value[3]); | ||
1367 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS1_LENGTH_REG, | ||
1368 | value, 4); | ||
1369 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS1_LENGTH_REG, value[0], | ||
1370 | value[1], value[2], value[3]); | ||
1371 | |||
1372 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS2_CFG_REG, | ||
1373 | value, 4); | ||
1374 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS2_CFG_REG, value[0], | ||
1375 | value[1], value[2], value[3]); | ||
1376 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, TS2_LENGTH_REG, | ||
1377 | value, 4); | ||
1378 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", TS2_LENGTH_REG, value[0], | ||
1379 | value[1], value[2], value[3]); | ||
1380 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, | ||
1381 | value, 4); | ||
1382 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", EP_MODE_SET, value[0], | ||
1383 | value[1], value[2], value[3]); | ||
1384 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN1, | ||
1385 | value, 4); | ||
1386 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN1, value[0], | ||
1387 | value[1], value[2], value[3]); | ||
1388 | |||
1389 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN2, | ||
1390 | value, 4); | ||
1391 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN2, value[0], | ||
1392 | value[1], value[2], value[3]); | ||
1393 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_PTN3, | ||
1394 | value, 4); | ||
1395 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_PTN3, value[0], | ||
1396 | value[1], value[2], value[3]); | ||
1397 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK0, | ||
1398 | value, 4); | ||
1399 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK0, value[0], | ||
1400 | value[1], value[2], value[3]); | ||
1401 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK1, | ||
1402 | value, 4); | ||
1403 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK1, value[0], | ||
1404 | value[1], value[2], value[3]); | ||
1405 | |||
1406 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_PWR_MASK2, | ||
1407 | value, 4); | ||
1408 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_PWR_MASK2, value[0], | ||
1409 | value[1], value[2], value[3]); | ||
1410 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_GAIN, | ||
1411 | value, 4); | ||
1412 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_GAIN, value[0], | ||
1413 | value[1], value[2], value[3]); | ||
1414 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_CAR_REG, | ||
1415 | value, 4); | ||
1416 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_CAR_REG, value[0], | ||
1417 | value[1], value[2], value[3]); | ||
1418 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_OT_CFG1, | ||
1419 | value, 4); | ||
1420 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_OT_CFG1, value[0], | ||
1421 | value[1], value[2], value[3]); | ||
1422 | |||
1423 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, CIR_OT_CFG2, | ||
1424 | value, 4); | ||
1425 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", CIR_OT_CFG2, value[0], | ||
1426 | value[1], value[2], value[3]); | ||
1427 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, | ||
1428 | value, 4); | ||
1429 | cx231xx_info("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", PWR_CTL_EN, value[0], | ||
1430 | value[1], value[2], value[3]); | ||
1431 | |||
1432 | |||
1433 | } | ||
1434 | |||
1435 | void cx231xx_Setup_AFE_for_LowIF(struct cx231xx *dev) | ||
1436 | |||
1437 | { | ||
1438 | u8 value = 0; | ||
1439 | |||
1440 | afe_read_byte(dev, ADC_STATUS2_CH3, &value); | ||
1441 | value = (value & 0xFE)|0x01; | ||
1442 | afe_write_byte(dev, ADC_STATUS2_CH3, value); | ||
1443 | |||
1444 | afe_read_byte(dev, ADC_STATUS2_CH3, &value); | ||
1445 | value = (value & 0xFE)|0x00; | ||
1446 | afe_write_byte(dev, ADC_STATUS2_CH3, value); | ||
1447 | |||
1448 | |||
1449 | /* | ||
1450 | config colibri to lo-if mode | ||
1451 | |||
1452 | FIXME: ntf_mode = 2'b00 by default. But set 0x1 would reduce | ||
1453 | the diff IF input by half, | ||
1454 | |||
1455 | for low-if agc defect | ||
1456 | */ | ||
1457 | |||
1458 | afe_read_byte(dev, ADC_NTF_PRECLMP_EN_CH3, &value); | ||
1459 | value = (value & 0xFC)|0x00; | ||
1460 | afe_write_byte(dev, ADC_NTF_PRECLMP_EN_CH3, value); | ||
1461 | |||
1462 | afe_read_byte(dev, ADC_INPUT_CH3, &value); | ||
1463 | value = (value & 0xF9)|0x02; | ||
1464 | afe_write_byte(dev, ADC_INPUT_CH3, value); | ||
1465 | |||
1466 | afe_read_byte(dev, ADC_FB_FRCRST_CH3, &value); | ||
1467 | value = (value & 0xFB)|0x04; | ||
1468 | afe_write_byte(dev, ADC_FB_FRCRST_CH3, value); | ||
1469 | |||
1470 | afe_read_byte(dev, ADC_DCSERVO_DEM_CH3, &value); | ||
1471 | value = (value & 0xFC)|0x03; | ||
1472 | afe_write_byte(dev, ADC_DCSERVO_DEM_CH3, value); | ||
1473 | |||
1474 | afe_read_byte(dev, ADC_CTRL_DAC1_CH3, &value); | ||
1475 | value = (value & 0xFB)|0x04; | ||
1476 | afe_write_byte(dev, ADC_CTRL_DAC1_CH3, value); | ||
1477 | |||
1478 | afe_read_byte(dev, ADC_CTRL_DAC23_CH3, &value); | ||
1479 | value = (value & 0xF8)|0x06; | ||
1480 | afe_write_byte(dev, ADC_CTRL_DAC23_CH3, value); | ||
1481 | |||
1482 | afe_read_byte(dev, ADC_CTRL_DAC23_CH3, &value); | ||
1483 | value = (value & 0x8F)|0x40; | ||
1484 | afe_write_byte(dev, ADC_CTRL_DAC23_CH3, value); | ||
1485 | |||
1486 | afe_read_byte(dev, ADC_PWRDN_CLAMP_CH3, &value); | ||
1487 | value = (value & 0xDF)|0x20; | ||
1488 | afe_write_byte(dev, ADC_PWRDN_CLAMP_CH3, value); | ||
1489 | } | ||
1490 | |||
1491 | void cx231xx_set_Colibri_For_LowIF(struct cx231xx *dev, u32 if_freq, | ||
1492 | u8 spectral_invert, u32 mode) | ||
1493 | { | ||
1494 | u32 colibri_carrier_offset = 0; | ||
1495 | u32 func_mode = 0x01; /* Device has a DIF if this function is called */ | ||
1496 | u32 standard = 0; | ||
1497 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1498 | |||
1499 | cx231xx_info("Enter cx231xx_set_Colibri_For_LowIF()\n"); | ||
1500 | value[0] = (u8) 0x6F; | ||
1501 | value[1] = (u8) 0x6F; | ||
1502 | value[2] = (u8) 0x6F; | ||
1503 | value[3] = (u8) 0x6F; | ||
1504 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1505 | PWR_CTL_EN, value, 4); | ||
1506 | |||
1507 | /*Set colibri for low IF*/ | ||
1508 | cx231xx_afe_set_mode(dev, AFE_MODE_LOW_IF); | ||
1509 | |||
1510 | /* Set C2HH for low IF operation.*/ | ||
1511 | standard = dev->norm; | ||
1512 | cx231xx_dif_configure_C2HH_for_low_IF(dev, dev->active_mode, | ||
1513 | func_mode, standard); | ||
1514 | |||
1515 | /* Get colibri offsets.*/ | ||
1516 | colibri_carrier_offset = cx231xx_Get_Colibri_CarrierOffset(mode, | ||
1517 | standard); | ||
1518 | |||
1519 | cx231xx_info("colibri_carrier_offset=%d, standard=0x%x\n", | ||
1520 | colibri_carrier_offset, standard); | ||
1521 | |||
1522 | /* Set the band Pass filter for DIF*/ | ||
1523 | cx231xx_set_DIF_bandpass(dev, (if_freq+colibri_carrier_offset), | ||
1524 | spectral_invert, mode); | ||
1525 | } | ||
1526 | |||
1527 | u32 cx231xx_Get_Colibri_CarrierOffset(u32 mode, u32 standerd) | ||
1528 | { | ||
1529 | u32 colibri_carrier_offset = 0; | ||
1530 | |||
1531 | if (mode == TUNER_MODE_FM_RADIO) { | ||
1532 | colibri_carrier_offset = 1100000; | ||
1533 | } else if (standerd & (V4L2_STD_MN | V4L2_STD_NTSC_M_JP)) { | ||
1534 | colibri_carrier_offset = 4832000; /*4.83MHz */ | ||
1535 | } else if (standerd & (V4L2_STD_PAL_B | V4L2_STD_PAL_G)) { | ||
1536 | colibri_carrier_offset = 2700000; /*2.70MHz */ | ||
1537 | } else if (standerd & (V4L2_STD_PAL_D | V4L2_STD_PAL_I | ||
1538 | | V4L2_STD_SECAM)) { | ||
1539 | colibri_carrier_offset = 2100000; /*2.10MHz */ | ||
1540 | } | ||
1541 | |||
1542 | return colibri_carrier_offset; | ||
1543 | } | ||
1544 | |||
1545 | void cx231xx_set_DIF_bandpass(struct cx231xx *dev, u32 if_freq, | ||
1546 | u8 spectral_invert, u32 mode) | ||
1547 | { | ||
1548 | unsigned long pll_freq_word; | ||
1549 | u32 dif_misc_ctrl_value = 0; | ||
1550 | u64 pll_freq_u64 = 0; | ||
1551 | u32 i = 0; | ||
1552 | |||
1553 | cx231xx_info("if_freq=%d;spectral_invert=0x%x;mode=0x%x\n", | ||
1554 | if_freq, spectral_invert, mode); | ||
1555 | |||
1556 | |||
1557 | if (mode == TUNER_MODE_FM_RADIO) { | ||
1558 | pll_freq_word = 0x905A1CAC; | ||
1559 | vid_blk_write_word(dev, DIF_PLL_FREQ_WORD, pll_freq_word); | ||
1560 | |||
1561 | } else /*KSPROPERTY_TUNER_MODE_TV*/{ | ||
1562 | /* Calculate the PLL frequency word based on the adjusted if_freq*/ | ||
1563 | pll_freq_word = if_freq; | ||
1564 | pll_freq_u64 = (u64)pll_freq_word << 28L; | ||
1565 | do_div(pll_freq_u64, 50000000); | ||
1566 | pll_freq_word = (u32)pll_freq_u64; | ||
1567 | /*pll_freq_word = 0x3463497;*/ | ||
1568 | vid_blk_write_word(dev, DIF_PLL_FREQ_WORD, pll_freq_word); | ||
1569 | |||
1570 | if (spectral_invert) { | ||
1571 | if_freq -= 400000; | ||
1572 | /* Enable Spectral Invert*/ | ||
1573 | vid_blk_read_word(dev, DIF_MISC_CTRL, | ||
1574 | &dif_misc_ctrl_value); | ||
1575 | dif_misc_ctrl_value = dif_misc_ctrl_value | 0x00200000; | ||
1576 | vid_blk_write_word(dev, DIF_MISC_CTRL, | ||
1577 | dif_misc_ctrl_value); | ||
1578 | } else { | ||
1579 | if_freq += 400000; | ||
1580 | /* Disable Spectral Invert*/ | ||
1581 | vid_blk_read_word(dev, DIF_MISC_CTRL, | ||
1582 | &dif_misc_ctrl_value); | ||
1583 | dif_misc_ctrl_value = dif_misc_ctrl_value & 0xFFDFFFFF; | ||
1584 | vid_blk_write_word(dev, DIF_MISC_CTRL, | ||
1585 | dif_misc_ctrl_value); | ||
1586 | } | ||
1587 | |||
1588 | if_freq = (if_freq/100000)*100000; | ||
1589 | |||
1590 | if (if_freq < 3000000) | ||
1591 | if_freq = 3000000; | ||
1592 | |||
1593 | if (if_freq > 16000000) | ||
1594 | if_freq = 16000000; | ||
1595 | } | ||
1596 | |||
1597 | cx231xx_info("Enter IF=%zd\n", | ||
1598 | ARRAY_SIZE(Dif_set_array)); | ||
1599 | for (i = 0; i < ARRAY_SIZE(Dif_set_array); i++) { | ||
1600 | if (Dif_set_array[i].if_freq == if_freq) { | ||
1601 | vid_blk_write_word(dev, | ||
1602 | Dif_set_array[i].register_address, Dif_set_array[i].value); | ||
1603 | } | ||
1604 | } | ||
1605 | } | ||
1606 | |||
1607 | /****************************************************************************** | ||
1608 | * D I F - B L O C K C O N T R O L functions * | ||
1609 | ******************************************************************************/ | ||
1610 | int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode, | ||
1611 | u32 function_mode, u32 standard) | ||
1612 | { | ||
1613 | int status = 0; | ||
1614 | |||
1615 | |||
1616 | if (mode == V4L2_TUNER_RADIO) { | ||
1617 | /* C2HH */ | ||
1618 | /* lo if big signal */ | ||
1619 | status = cx231xx_reg_mask_write(dev, | ||
1620 | VID_BLK_I2C_ADDRESS, 32, | ||
1621 | AFE_CTRL_C2HH_SRC_CTRL, 30, 31, 0x1); | ||
1622 | /* FUNC_MODE = DIF */ | ||
1623 | status = cx231xx_reg_mask_write(dev, | ||
1624 | VID_BLK_I2C_ADDRESS, 32, | ||
1625 | AFE_CTRL_C2HH_SRC_CTRL, 23, 24, function_mode); | ||
1626 | /* IF_MODE */ | ||
1627 | status = cx231xx_reg_mask_write(dev, | ||
1628 | VID_BLK_I2C_ADDRESS, 32, | ||
1629 | AFE_CTRL_C2HH_SRC_CTRL, 15, 22, 0xFF); | ||
1630 | /* no inv */ | ||
1631 | status = cx231xx_reg_mask_write(dev, | ||
1632 | VID_BLK_I2C_ADDRESS, 32, | ||
1633 | AFE_CTRL_C2HH_SRC_CTRL, 9, 9, 0x1); | ||
1634 | } else if (standard != DIF_USE_BASEBAND) { | ||
1635 | if (standard & V4L2_STD_MN) { | ||
1636 | /* lo if big signal */ | ||
1637 | status = cx231xx_reg_mask_write(dev, | ||
1638 | VID_BLK_I2C_ADDRESS, 32, | ||
1639 | AFE_CTRL_C2HH_SRC_CTRL, 30, 31, 0x1); | ||
1640 | /* FUNC_MODE = DIF */ | ||
1641 | status = cx231xx_reg_mask_write(dev, | ||
1642 | VID_BLK_I2C_ADDRESS, 32, | ||
1643 | AFE_CTRL_C2HH_SRC_CTRL, 23, 24, | ||
1644 | function_mode); | ||
1645 | /* IF_MODE */ | ||
1646 | status = cx231xx_reg_mask_write(dev, | ||
1647 | VID_BLK_I2C_ADDRESS, 32, | ||
1648 | AFE_CTRL_C2HH_SRC_CTRL, 15, 22, 0xb); | ||
1649 | /* no inv */ | ||
1650 | status = cx231xx_reg_mask_write(dev, | ||
1651 | VID_BLK_I2C_ADDRESS, 32, | ||
1652 | AFE_CTRL_C2HH_SRC_CTRL, 9, 9, 0x1); | ||
1653 | /* 0x124, AUD_CHAN1_SRC = 0x3 */ | ||
1654 | status = cx231xx_reg_mask_write(dev, | ||
1655 | VID_BLK_I2C_ADDRESS, 32, | ||
1656 | AUD_IO_CTRL, 0, 31, 0x00000003); | ||
1657 | } else if ((standard == V4L2_STD_PAL_I) | | ||
1658 | (standard & V4L2_STD_PAL_D) | | ||
1659 | (standard & V4L2_STD_SECAM)) { | ||
1660 | /* C2HH setup */ | ||
1661 | /* lo if big signal */ | ||
1662 | status = cx231xx_reg_mask_write(dev, | ||
1663 | VID_BLK_I2C_ADDRESS, 32, | ||
1664 | AFE_CTRL_C2HH_SRC_CTRL, 30, 31, 0x1); | ||
1665 | /* FUNC_MODE = DIF */ | ||
1666 | status = cx231xx_reg_mask_write(dev, | ||
1667 | VID_BLK_I2C_ADDRESS, 32, | ||
1668 | AFE_CTRL_C2HH_SRC_CTRL, 23, 24, | ||
1669 | function_mode); | ||
1670 | /* IF_MODE */ | ||
1671 | status = cx231xx_reg_mask_write(dev, | ||
1672 | VID_BLK_I2C_ADDRESS, 32, | ||
1673 | AFE_CTRL_C2HH_SRC_CTRL, 15, 22, 0xF); | ||
1674 | /* no inv */ | ||
1675 | status = cx231xx_reg_mask_write(dev, | ||
1676 | VID_BLK_I2C_ADDRESS, 32, | ||
1677 | AFE_CTRL_C2HH_SRC_CTRL, 9, 9, 0x1); | ||
1678 | } else { | ||
1679 | /* default PAL BG */ | ||
1680 | /* C2HH setup */ | ||
1681 | /* lo if big signal */ | ||
1682 | status = cx231xx_reg_mask_write(dev, | ||
1683 | VID_BLK_I2C_ADDRESS, 32, | ||
1684 | AFE_CTRL_C2HH_SRC_CTRL, 30, 31, 0x1); | ||
1685 | /* FUNC_MODE = DIF */ | ||
1686 | status = cx231xx_reg_mask_write(dev, | ||
1687 | VID_BLK_I2C_ADDRESS, 32, | ||
1688 | AFE_CTRL_C2HH_SRC_CTRL, 23, 24, | ||
1689 | function_mode); | ||
1690 | /* IF_MODE */ | ||
1691 | status = cx231xx_reg_mask_write(dev, | ||
1692 | VID_BLK_I2C_ADDRESS, 32, | ||
1693 | AFE_CTRL_C2HH_SRC_CTRL, 15, 22, 0xE); | ||
1694 | /* no inv */ | ||
1695 | status = cx231xx_reg_mask_write(dev, | ||
1696 | VID_BLK_I2C_ADDRESS, 32, | ||
1697 | AFE_CTRL_C2HH_SRC_CTRL, 9, 9, 0x1); | ||
1698 | } | ||
1699 | } | ||
1700 | |||
1701 | return status; | ||
1702 | } | ||
1703 | |||
1704 | int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard) | ||
1705 | { | ||
1706 | int status = 0; | ||
1707 | u32 dif_misc_ctrl_value = 0; | ||
1708 | u32 func_mode = 0; | ||
1709 | |||
1710 | cx231xx_info("%s: setStandard to %x\n", __func__, standard); | ||
1711 | |||
1712 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, &dif_misc_ctrl_value); | ||
1713 | if (standard != DIF_USE_BASEBAND) | ||
1714 | dev->norm = standard; | ||
1715 | |||
1716 | switch (dev->model) { | ||
1717 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
1718 | case CX231XX_BOARD_CNXT_RDE_250: | ||
1719 | case CX231XX_BOARD_CNXT_SHELBY: | ||
1720 | case CX231XX_BOARD_CNXT_RDU_250: | ||
1721 | case CX231XX_BOARD_CNXT_VIDEO_GRABBER: | ||
1722 | case CX231XX_BOARD_HAUPPAUGE_EXETER: | ||
1723 | func_mode = 0x03; | ||
1724 | break; | ||
1725 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
1726 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
1727 | case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: | ||
1728 | case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: | ||
1729 | func_mode = 0x01; | ||
1730 | break; | ||
1731 | default: | ||
1732 | func_mode = 0x01; | ||
1733 | } | ||
1734 | |||
1735 | status = cx231xx_dif_configure_C2HH_for_low_IF(dev, dev->active_mode, | ||
1736 | func_mode, standard); | ||
1737 | |||
1738 | if (standard == DIF_USE_BASEBAND) { /* base band */ | ||
1739 | /* There is a different SRC_PHASE_INC value | ||
1740 | for baseband vs. DIF */ | ||
1741 | status = vid_blk_write_word(dev, DIF_SRC_PHASE_INC, 0xDF7DF83); | ||
1742 | status = vid_blk_read_word(dev, DIF_MISC_CTRL, | ||
1743 | &dif_misc_ctrl_value); | ||
1744 | dif_misc_ctrl_value |= FLD_DIF_DIF_BYPASS; | ||
1745 | status = vid_blk_write_word(dev, DIF_MISC_CTRL, | ||
1746 | dif_misc_ctrl_value); | ||
1747 | } else if (standard & V4L2_STD_PAL_D) { | ||
1748 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1749 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1750 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1751 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1752 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1753 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1754 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1755 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1756 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1757 | DIF_AGC_IF_REF, 0, 31, 0x444C1380); | ||
1758 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1759 | DIF_AGC_CTRL_IF, 0, 31, 0xDA302600); | ||
1760 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1761 | DIF_AGC_CTRL_INT, 0, 31, 0xDA261700); | ||
1762 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1763 | DIF_AGC_CTRL_RF, 0, 31, 0xDA262600); | ||
1764 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1765 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1766 | 0x26001700); | ||
1767 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1768 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1769 | 0x00002660); | ||
1770 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1771 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1772 | 0x72500800); | ||
1773 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1774 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1775 | 0x27000100); | ||
1776 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1777 | DIF_AV_SEP_CTRL, 0, 31, 0x3F3934EA); | ||
1778 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1779 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1780 | 0x00000000); | ||
1781 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1782 | DIF_SRC_PHASE_INC, 0, 31, | ||
1783 | 0x1befbf06); | ||
1784 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1785 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1786 | 0x000035e8); | ||
1787 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1788 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1789 | /* Save the Spec Inversion value */ | ||
1790 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1791 | dif_misc_ctrl_value |= 0x3a023F11; | ||
1792 | } else if (standard & V4L2_STD_PAL_I) { | ||
1793 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1794 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1795 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1796 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1797 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1798 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1799 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1800 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1801 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1802 | DIF_AGC_IF_REF, 0, 31, 0x444C1380); | ||
1803 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1804 | DIF_AGC_CTRL_IF, 0, 31, 0xDA302600); | ||
1805 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1806 | DIF_AGC_CTRL_INT, 0, 31, 0xDA261700); | ||
1807 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1808 | DIF_AGC_CTRL_RF, 0, 31, 0xDA262600); | ||
1809 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1810 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1811 | 0x26001700); | ||
1812 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1813 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1814 | 0x00002660); | ||
1815 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1816 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1817 | 0x72500800); | ||
1818 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1819 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1820 | 0x27000100); | ||
1821 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1822 | DIF_AV_SEP_CTRL, 0, 31, 0x5F39A934); | ||
1823 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1824 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1825 | 0x00000000); | ||
1826 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1827 | DIF_SRC_PHASE_INC, 0, 31, | ||
1828 | 0x1befbf06); | ||
1829 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1830 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1831 | 0x000035e8); | ||
1832 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1833 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1834 | /* Save the Spec Inversion value */ | ||
1835 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1836 | dif_misc_ctrl_value |= 0x3a033F11; | ||
1837 | } else if (standard & V4L2_STD_PAL_M) { | ||
1838 | /* improved Low Frequency Phase Noise */ | ||
1839 | status = vid_blk_write_word(dev, DIF_PLL_CTRL, 0xFF01FF0C); | ||
1840 | status = vid_blk_write_word(dev, DIF_PLL_CTRL1, 0xbd038c85); | ||
1841 | status = vid_blk_write_word(dev, DIF_PLL_CTRL2, 0x1db4640a); | ||
1842 | status = vid_blk_write_word(dev, DIF_PLL_CTRL3, 0x00008800); | ||
1843 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, 0x444C1380); | ||
1844 | status = vid_blk_write_word(dev, DIF_AGC_IF_INT_CURRENT, | ||
1845 | 0x26001700); | ||
1846 | status = vid_blk_write_word(dev, DIF_AGC_RF_CURRENT, | ||
1847 | 0x00002660); | ||
1848 | status = vid_blk_write_word(dev, DIF_VIDEO_AGC_CTRL, | ||
1849 | 0x72500800); | ||
1850 | status = vid_blk_write_word(dev, DIF_VID_AUD_OVERRIDE, | ||
1851 | 0x27000100); | ||
1852 | status = vid_blk_write_word(dev, DIF_AV_SEP_CTRL, 0x012c405d); | ||
1853 | status = vid_blk_write_word(dev, DIF_COMP_FLT_CTRL, | ||
1854 | 0x009f50c1); | ||
1855 | status = vid_blk_write_word(dev, DIF_SRC_PHASE_INC, | ||
1856 | 0x1befbf06); | ||
1857 | status = vid_blk_write_word(dev, DIF_SRC_GAIN_CONTROL, | ||
1858 | 0x000035e8); | ||
1859 | status = vid_blk_write_word(dev, DIF_SOFT_RST_CTRL_REVB, | ||
1860 | 0x00000000); | ||
1861 | /* Save the Spec Inversion value */ | ||
1862 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1863 | dif_misc_ctrl_value |= 0x3A0A3F10; | ||
1864 | } else if (standard & (V4L2_STD_PAL_N | V4L2_STD_PAL_Nc)) { | ||
1865 | /* improved Low Frequency Phase Noise */ | ||
1866 | status = vid_blk_write_word(dev, DIF_PLL_CTRL, 0xFF01FF0C); | ||
1867 | status = vid_blk_write_word(dev, DIF_PLL_CTRL1, 0xbd038c85); | ||
1868 | status = vid_blk_write_word(dev, DIF_PLL_CTRL2, 0x1db4640a); | ||
1869 | status = vid_blk_write_word(dev, DIF_PLL_CTRL3, 0x00008800); | ||
1870 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, 0x444C1380); | ||
1871 | status = vid_blk_write_word(dev, DIF_AGC_IF_INT_CURRENT, | ||
1872 | 0x26001700); | ||
1873 | status = vid_blk_write_word(dev, DIF_AGC_RF_CURRENT, | ||
1874 | 0x00002660); | ||
1875 | status = vid_blk_write_word(dev, DIF_VIDEO_AGC_CTRL, | ||
1876 | 0x72500800); | ||
1877 | status = vid_blk_write_word(dev, DIF_VID_AUD_OVERRIDE, | ||
1878 | 0x27000100); | ||
1879 | status = vid_blk_write_word(dev, DIF_AV_SEP_CTRL, | ||
1880 | 0x012c405d); | ||
1881 | status = vid_blk_write_word(dev, DIF_COMP_FLT_CTRL, | ||
1882 | 0x009f50c1); | ||
1883 | status = vid_blk_write_word(dev, DIF_SRC_PHASE_INC, | ||
1884 | 0x1befbf06); | ||
1885 | status = vid_blk_write_word(dev, DIF_SRC_GAIN_CONTROL, | ||
1886 | 0x000035e8); | ||
1887 | status = vid_blk_write_word(dev, DIF_SOFT_RST_CTRL_REVB, | ||
1888 | 0x00000000); | ||
1889 | /* Save the Spec Inversion value */ | ||
1890 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1891 | dif_misc_ctrl_value = 0x3A093F10; | ||
1892 | } else if (standard & | ||
1893 | (V4L2_STD_SECAM_B | V4L2_STD_SECAM_D | V4L2_STD_SECAM_G | | ||
1894 | V4L2_STD_SECAM_K | V4L2_STD_SECAM_K1)) { | ||
1895 | |||
1896 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1897 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1898 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1899 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1900 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1901 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1902 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1903 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1904 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1905 | DIF_AGC_IF_REF, 0, 31, 0x888C0380); | ||
1906 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1907 | DIF_AGC_CTRL_IF, 0, 31, 0xe0262600); | ||
1908 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1909 | DIF_AGC_CTRL_INT, 0, 31, 0xc2171700); | ||
1910 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1911 | DIF_AGC_CTRL_RF, 0, 31, 0xc2262600); | ||
1912 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1913 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1914 | 0x26001700); | ||
1915 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1916 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1917 | 0x00002660); | ||
1918 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1919 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1920 | 0x27000100); | ||
1921 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1922 | DIF_AV_SEP_CTRL, 0, 31, 0x3F3530ec); | ||
1923 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1924 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1925 | 0x00000000); | ||
1926 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1927 | DIF_SRC_PHASE_INC, 0, 31, | ||
1928 | 0x1befbf06); | ||
1929 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1930 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1931 | 0x000035e8); | ||
1932 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1933 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1934 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1935 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1936 | 0xf4000000); | ||
1937 | |||
1938 | /* Save the Spec Inversion value */ | ||
1939 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1940 | dif_misc_ctrl_value |= 0x3a023F11; | ||
1941 | } else if (standard & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) { | ||
1942 | /* Is it SECAM_L1? */ | ||
1943 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1944 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
1945 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1946 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
1947 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1948 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
1949 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1950 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
1951 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1952 | DIF_AGC_IF_REF, 0, 31, 0x888C0380); | ||
1953 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1954 | DIF_AGC_CTRL_IF, 0, 31, 0xe0262600); | ||
1955 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1956 | DIF_AGC_CTRL_INT, 0, 31, 0xc2171700); | ||
1957 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1958 | DIF_AGC_CTRL_RF, 0, 31, 0xc2262600); | ||
1959 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1960 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
1961 | 0x26001700); | ||
1962 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1963 | DIF_AGC_RF_CURRENT, 0, 31, | ||
1964 | 0x00002660); | ||
1965 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1966 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
1967 | 0x27000100); | ||
1968 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1969 | DIF_AV_SEP_CTRL, 0, 31, 0x3F3530ec); | ||
1970 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1971 | DIF_COMP_FLT_CTRL, 0, 31, | ||
1972 | 0x00000000); | ||
1973 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1974 | DIF_SRC_PHASE_INC, 0, 31, | ||
1975 | 0x1befbf06); | ||
1976 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1977 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
1978 | 0x000035e8); | ||
1979 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1980 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
1981 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
1982 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
1983 | 0xf2560000); | ||
1984 | |||
1985 | /* Save the Spec Inversion value */ | ||
1986 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
1987 | dif_misc_ctrl_value |= 0x3a023F11; | ||
1988 | |||
1989 | } else if (standard & V4L2_STD_NTSC_M) { | ||
1990 | /* V4L2_STD_NTSC_M (75 IRE Setup) Or | ||
1991 | V4L2_STD_NTSC_M_JP (Japan, 0 IRE Setup) */ | ||
1992 | |||
1993 | /* For NTSC the centre frequency of video coming out of | ||
1994 | sidewinder is around 7.1MHz or 3.6MHz depending on the | ||
1995 | spectral inversion. so for a non spectrally inverted channel | ||
1996 | the pll freq word is 0x03420c49 | ||
1997 | */ | ||
1998 | |||
1999 | status = vid_blk_write_word(dev, DIF_PLL_CTRL, 0x6503BC0C); | ||
2000 | status = vid_blk_write_word(dev, DIF_PLL_CTRL1, 0xBD038C85); | ||
2001 | status = vid_blk_write_word(dev, DIF_PLL_CTRL2, 0x1DB4640A); | ||
2002 | status = vid_blk_write_word(dev, DIF_PLL_CTRL3, 0x00008800); | ||
2003 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, 0x444C0380); | ||
2004 | status = vid_blk_write_word(dev, DIF_AGC_IF_INT_CURRENT, | ||
2005 | 0x26001700); | ||
2006 | status = vid_blk_write_word(dev, DIF_AGC_RF_CURRENT, | ||
2007 | 0x00002660); | ||
2008 | status = vid_blk_write_word(dev, DIF_VIDEO_AGC_CTRL, | ||
2009 | 0x04000800); | ||
2010 | status = vid_blk_write_word(dev, DIF_VID_AUD_OVERRIDE, | ||
2011 | 0x27000100); | ||
2012 | status = vid_blk_write_word(dev, DIF_AV_SEP_CTRL, 0x01296e1f); | ||
2013 | |||
2014 | status = vid_blk_write_word(dev, DIF_COMP_FLT_CTRL, | ||
2015 | 0x009f50c1); | ||
2016 | status = vid_blk_write_word(dev, DIF_SRC_PHASE_INC, | ||
2017 | 0x1befbf06); | ||
2018 | status = vid_blk_write_word(dev, DIF_SRC_GAIN_CONTROL, | ||
2019 | 0x000035e8); | ||
2020 | |||
2021 | status = vid_blk_write_word(dev, DIF_AGC_CTRL_IF, 0xC2262600); | ||
2022 | status = vid_blk_write_word(dev, DIF_AGC_CTRL_INT, | ||
2023 | 0xC2262600); | ||
2024 | status = vid_blk_write_word(dev, DIF_AGC_CTRL_RF, 0xC2262600); | ||
2025 | |||
2026 | /* Save the Spec Inversion value */ | ||
2027 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
2028 | dif_misc_ctrl_value |= 0x3a003F10; | ||
2029 | } else { | ||
2030 | /* default PAL BG */ | ||
2031 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2032 | DIF_PLL_CTRL, 0, 31, 0x6503bc0c); | ||
2033 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2034 | DIF_PLL_CTRL1, 0, 31, 0xbd038c85); | ||
2035 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2036 | DIF_PLL_CTRL2, 0, 31, 0x1db4640a); | ||
2037 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2038 | DIF_PLL_CTRL3, 0, 31, 0x00008800); | ||
2039 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2040 | DIF_AGC_IF_REF, 0, 31, 0x444C1380); | ||
2041 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2042 | DIF_AGC_CTRL_IF, 0, 31, 0xDA302600); | ||
2043 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2044 | DIF_AGC_CTRL_INT, 0, 31, 0xDA261700); | ||
2045 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2046 | DIF_AGC_CTRL_RF, 0, 31, 0xDA262600); | ||
2047 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2048 | DIF_AGC_IF_INT_CURRENT, 0, 31, | ||
2049 | 0x26001700); | ||
2050 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2051 | DIF_AGC_RF_CURRENT, 0, 31, | ||
2052 | 0x00002660); | ||
2053 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2054 | DIF_VIDEO_AGC_CTRL, 0, 31, | ||
2055 | 0x72500800); | ||
2056 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2057 | DIF_VID_AUD_OVERRIDE, 0, 31, | ||
2058 | 0x27000100); | ||
2059 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2060 | DIF_AV_SEP_CTRL, 0, 31, 0x3F3530EC); | ||
2061 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2062 | DIF_COMP_FLT_CTRL, 0, 31, | ||
2063 | 0x00A653A8); | ||
2064 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2065 | DIF_SRC_PHASE_INC, 0, 31, | ||
2066 | 0x1befbf06); | ||
2067 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2068 | DIF_SRC_GAIN_CONTROL, 0, 31, | ||
2069 | 0x000035e8); | ||
2070 | status = cx231xx_reg_mask_write(dev, VID_BLK_I2C_ADDRESS, 32, | ||
2071 | DIF_RPT_VARIANCE, 0, 31, 0x00000000); | ||
2072 | /* Save the Spec Inversion value */ | ||
2073 | dif_misc_ctrl_value &= FLD_DIF_SPEC_INV; | ||
2074 | dif_misc_ctrl_value |= 0x3a013F11; | ||
2075 | } | ||
2076 | |||
2077 | /* The AGC values should be the same for all standards, | ||
2078 | AUD_SRC_SEL[19] should always be disabled */ | ||
2079 | dif_misc_ctrl_value &= ~FLD_DIF_AUD_SRC_SEL; | ||
2080 | |||
2081 | /* It is still possible to get Set Standard calls even when we | ||
2082 | are in FM mode. | ||
2083 | This is done to override the value for FM. */ | ||
2084 | if (dev->active_mode == V4L2_TUNER_RADIO) | ||
2085 | dif_misc_ctrl_value = 0x7a080000; | ||
2086 | |||
2087 | /* Write the calculated value for misc ontrol register */ | ||
2088 | status = vid_blk_write_word(dev, DIF_MISC_CTRL, dif_misc_ctrl_value); | ||
2089 | |||
2090 | return status; | ||
2091 | } | ||
2092 | |||
2093 | int cx231xx_tuner_pre_channel_change(struct cx231xx *dev) | ||
2094 | { | ||
2095 | int status = 0; | ||
2096 | u32 dwval; | ||
2097 | |||
2098 | /* Set the RF and IF k_agc values to 3 */ | ||
2099 | status = vid_blk_read_word(dev, DIF_AGC_IF_REF, &dwval); | ||
2100 | dwval &= ~(FLD_DIF_K_AGC_RF | FLD_DIF_K_AGC_IF); | ||
2101 | dwval |= 0x33000000; | ||
2102 | |||
2103 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, dwval); | ||
2104 | |||
2105 | return status; | ||
2106 | } | ||
2107 | |||
2108 | int cx231xx_tuner_post_channel_change(struct cx231xx *dev) | ||
2109 | { | ||
2110 | int status = 0; | ||
2111 | u32 dwval; | ||
2112 | cx231xx_info("cx231xx_tuner_post_channel_change dev->tuner_type =0%d\n", | ||
2113 | dev->tuner_type); | ||
2114 | /* Set the RF and IF k_agc values to 4 for PAL/NTSC and 8 for | ||
2115 | * SECAM L/B/D standards */ | ||
2116 | status = vid_blk_read_word(dev, DIF_AGC_IF_REF, &dwval); | ||
2117 | dwval &= ~(FLD_DIF_K_AGC_RF | FLD_DIF_K_AGC_IF); | ||
2118 | |||
2119 | if (dev->norm & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_B | | ||
2120 | V4L2_STD_SECAM_D)) { | ||
2121 | if (dev->tuner_type == TUNER_NXP_TDA18271) { | ||
2122 | dwval &= ~FLD_DIF_IF_REF; | ||
2123 | dwval |= 0x88000300; | ||
2124 | } else | ||
2125 | dwval |= 0x88000000; | ||
2126 | } else { | ||
2127 | if (dev->tuner_type == TUNER_NXP_TDA18271) { | ||
2128 | dwval &= ~FLD_DIF_IF_REF; | ||
2129 | dwval |= 0xCC000300; | ||
2130 | } else | ||
2131 | dwval |= 0x44000000; | ||
2132 | } | ||
2133 | |||
2134 | status = vid_blk_write_word(dev, DIF_AGC_IF_REF, dwval); | ||
2135 | |||
2136 | return status; | ||
2137 | } | ||
2138 | |||
2139 | /****************************************************************************** | ||
2140 | * I 2 S - B L O C K C O N T R O L functions * | ||
2141 | ******************************************************************************/ | ||
2142 | int cx231xx_i2s_blk_initialize(struct cx231xx *dev) | ||
2143 | { | ||
2144 | int status = 0; | ||
2145 | u32 value; | ||
2146 | |||
2147 | status = cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
2148 | CH_PWR_CTRL1, 1, &value, 1); | ||
2149 | /* enables clock to delta-sigma and decimation filter */ | ||
2150 | value |= 0x80; | ||
2151 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
2152 | CH_PWR_CTRL1, 1, value, 1); | ||
2153 | /* power up all channel */ | ||
2154 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
2155 | CH_PWR_CTRL2, 1, 0x00, 1); | ||
2156 | |||
2157 | return status; | ||
2158 | } | ||
2159 | |||
2160 | int cx231xx_i2s_blk_update_power_control(struct cx231xx *dev, | ||
2161 | enum AV_MODE avmode) | ||
2162 | { | ||
2163 | int status = 0; | ||
2164 | u32 value = 0; | ||
2165 | |||
2166 | if (avmode != POLARIS_AVMODE_ENXTERNAL_AV) { | ||
2167 | status = cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
2168 | CH_PWR_CTRL2, 1, &value, 1); | ||
2169 | value |= 0xfe; | ||
2170 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
2171 | CH_PWR_CTRL2, 1, value, 1); | ||
2172 | } else { | ||
2173 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
2174 | CH_PWR_CTRL2, 1, 0x00, 1); | ||
2175 | } | ||
2176 | |||
2177 | return status; | ||
2178 | } | ||
2179 | |||
2180 | /* set i2s_blk for audio input types */ | ||
2181 | int cx231xx_i2s_blk_set_audio_input(struct cx231xx *dev, u8 audio_input) | ||
2182 | { | ||
2183 | int status = 0; | ||
2184 | |||
2185 | switch (audio_input) { | ||
2186 | case CX231XX_AMUX_LINE_IN: | ||
2187 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
2188 | CH_PWR_CTRL2, 1, 0x00, 1); | ||
2189 | status = cx231xx_write_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
2190 | CH_PWR_CTRL1, 1, 0x80, 1); | ||
2191 | break; | ||
2192 | case CX231XX_AMUX_VIDEO: | ||
2193 | default: | ||
2194 | break; | ||
2195 | } | ||
2196 | |||
2197 | dev->ctl_ainput = audio_input; | ||
2198 | |||
2199 | return status; | ||
2200 | } | ||
2201 | |||
2202 | /****************************************************************************** | ||
2203 | * P O W E R C O N T R O L functions * | ||
2204 | ******************************************************************************/ | ||
2205 | int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | ||
2206 | { | ||
2207 | u8 value[4] = { 0, 0, 0, 0 }; | ||
2208 | u32 tmp = 0; | ||
2209 | int status = 0; | ||
2210 | |||
2211 | if (dev->power_mode != mode) | ||
2212 | dev->power_mode = mode; | ||
2213 | else { | ||
2214 | cx231xx_info(" setPowerMode::mode = %d, No Change req.\n", | ||
2215 | mode); | ||
2216 | return 0; | ||
2217 | } | ||
2218 | |||
2219 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, | ||
2220 | 4); | ||
2221 | if (status < 0) | ||
2222 | return status; | ||
2223 | |||
2224 | tmp = *((u32 *) value); | ||
2225 | |||
2226 | switch (mode) { | ||
2227 | case POLARIS_AVMODE_ENXTERNAL_AV: | ||
2228 | |||
2229 | tmp &= (~PWR_MODE_MASK); | ||
2230 | |||
2231 | tmp |= PWR_AV_EN; | ||
2232 | value[0] = (u8) tmp; | ||
2233 | value[1] = (u8) (tmp >> 8); | ||
2234 | value[2] = (u8) (tmp >> 16); | ||
2235 | value[3] = (u8) (tmp >> 24); | ||
2236 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2237 | PWR_CTL_EN, value, 4); | ||
2238 | msleep(PWR_SLEEP_INTERVAL); | ||
2239 | |||
2240 | tmp |= PWR_ISO_EN; | ||
2241 | value[0] = (u8) tmp; | ||
2242 | value[1] = (u8) (tmp >> 8); | ||
2243 | value[2] = (u8) (tmp >> 16); | ||
2244 | value[3] = (u8) (tmp >> 24); | ||
2245 | status = | ||
2246 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, PWR_CTL_EN, | ||
2247 | value, 4); | ||
2248 | msleep(PWR_SLEEP_INTERVAL); | ||
2249 | |||
2250 | tmp |= POLARIS_AVMODE_ENXTERNAL_AV; | ||
2251 | value[0] = (u8) tmp; | ||
2252 | value[1] = (u8) (tmp >> 8); | ||
2253 | value[2] = (u8) (tmp >> 16); | ||
2254 | value[3] = (u8) (tmp >> 24); | ||
2255 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2256 | PWR_CTL_EN, value, 4); | ||
2257 | |||
2258 | /* reset state of xceive tuner */ | ||
2259 | dev->xc_fw_load_done = 0; | ||
2260 | break; | ||
2261 | |||
2262 | case POLARIS_AVMODE_ANALOGT_TV: | ||
2263 | |||
2264 | tmp |= PWR_DEMOD_EN; | ||
2265 | tmp |= (I2C_DEMOD_EN); | ||
2266 | value[0] = (u8) tmp; | ||
2267 | value[1] = (u8) (tmp >> 8); | ||
2268 | value[2] = (u8) (tmp >> 16); | ||
2269 | value[3] = (u8) (tmp >> 24); | ||
2270 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2271 | PWR_CTL_EN, value, 4); | ||
2272 | msleep(PWR_SLEEP_INTERVAL); | ||
2273 | |||
2274 | if (!(tmp & PWR_TUNER_EN)) { | ||
2275 | tmp |= (PWR_TUNER_EN); | ||
2276 | value[0] = (u8) tmp; | ||
2277 | value[1] = (u8) (tmp >> 8); | ||
2278 | value[2] = (u8) (tmp >> 16); | ||
2279 | value[3] = (u8) (tmp >> 24); | ||
2280 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2281 | PWR_CTL_EN, value, 4); | ||
2282 | msleep(PWR_SLEEP_INTERVAL); | ||
2283 | } | ||
2284 | |||
2285 | if (!(tmp & PWR_AV_EN)) { | ||
2286 | tmp |= PWR_AV_EN; | ||
2287 | value[0] = (u8) tmp; | ||
2288 | value[1] = (u8) (tmp >> 8); | ||
2289 | value[2] = (u8) (tmp >> 16); | ||
2290 | value[3] = (u8) (tmp >> 24); | ||
2291 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2292 | PWR_CTL_EN, value, 4); | ||
2293 | msleep(PWR_SLEEP_INTERVAL); | ||
2294 | } | ||
2295 | if (!(tmp & PWR_ISO_EN)) { | ||
2296 | tmp |= PWR_ISO_EN; | ||
2297 | value[0] = (u8) tmp; | ||
2298 | value[1] = (u8) (tmp >> 8); | ||
2299 | value[2] = (u8) (tmp >> 16); | ||
2300 | value[3] = (u8) (tmp >> 24); | ||
2301 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2302 | PWR_CTL_EN, value, 4); | ||
2303 | msleep(PWR_SLEEP_INTERVAL); | ||
2304 | } | ||
2305 | |||
2306 | if (!(tmp & POLARIS_AVMODE_ANALOGT_TV)) { | ||
2307 | tmp |= POLARIS_AVMODE_ANALOGT_TV; | ||
2308 | value[0] = (u8) tmp; | ||
2309 | value[1] = (u8) (tmp >> 8); | ||
2310 | value[2] = (u8) (tmp >> 16); | ||
2311 | value[3] = (u8) (tmp >> 24); | ||
2312 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2313 | PWR_CTL_EN, value, 4); | ||
2314 | msleep(PWR_SLEEP_INTERVAL); | ||
2315 | } | ||
2316 | |||
2317 | if (dev->board.tuner_type != TUNER_ABSENT) { | ||
2318 | /* Enable tuner */ | ||
2319 | cx231xx_enable_i2c_port_3(dev, true); | ||
2320 | |||
2321 | /* reset the Tuner */ | ||
2322 | if (dev->board.tuner_gpio) | ||
2323 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | ||
2324 | |||
2325 | if (dev->cx231xx_reset_analog_tuner) | ||
2326 | dev->cx231xx_reset_analog_tuner(dev); | ||
2327 | } | ||
2328 | |||
2329 | break; | ||
2330 | |||
2331 | case POLARIS_AVMODE_DIGITAL: | ||
2332 | if (!(tmp & PWR_TUNER_EN)) { | ||
2333 | tmp |= (PWR_TUNER_EN); | ||
2334 | value[0] = (u8) tmp; | ||
2335 | value[1] = (u8) (tmp >> 8); | ||
2336 | value[2] = (u8) (tmp >> 16); | ||
2337 | value[3] = (u8) (tmp >> 24); | ||
2338 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2339 | PWR_CTL_EN, value, 4); | ||
2340 | msleep(PWR_SLEEP_INTERVAL); | ||
2341 | } | ||
2342 | if (!(tmp & PWR_AV_EN)) { | ||
2343 | tmp |= PWR_AV_EN; | ||
2344 | value[0] = (u8) tmp; | ||
2345 | value[1] = (u8) (tmp >> 8); | ||
2346 | value[2] = (u8) (tmp >> 16); | ||
2347 | value[3] = (u8) (tmp >> 24); | ||
2348 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2349 | PWR_CTL_EN, value, 4); | ||
2350 | msleep(PWR_SLEEP_INTERVAL); | ||
2351 | } | ||
2352 | if (!(tmp & PWR_ISO_EN)) { | ||
2353 | tmp |= PWR_ISO_EN; | ||
2354 | value[0] = (u8) tmp; | ||
2355 | value[1] = (u8) (tmp >> 8); | ||
2356 | value[2] = (u8) (tmp >> 16); | ||
2357 | value[3] = (u8) (tmp >> 24); | ||
2358 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2359 | PWR_CTL_EN, value, 4); | ||
2360 | msleep(PWR_SLEEP_INTERVAL); | ||
2361 | } | ||
2362 | |||
2363 | tmp &= (~PWR_AV_MODE); | ||
2364 | tmp |= POLARIS_AVMODE_DIGITAL | I2C_DEMOD_EN; | ||
2365 | value[0] = (u8) tmp; | ||
2366 | value[1] = (u8) (tmp >> 8); | ||
2367 | value[2] = (u8) (tmp >> 16); | ||
2368 | value[3] = (u8) (tmp >> 24); | ||
2369 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2370 | PWR_CTL_EN, value, 4); | ||
2371 | msleep(PWR_SLEEP_INTERVAL); | ||
2372 | |||
2373 | if (!(tmp & PWR_DEMOD_EN)) { | ||
2374 | tmp |= PWR_DEMOD_EN; | ||
2375 | value[0] = (u8) tmp; | ||
2376 | value[1] = (u8) (tmp >> 8); | ||
2377 | value[2] = (u8) (tmp >> 16); | ||
2378 | value[3] = (u8) (tmp >> 24); | ||
2379 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2380 | PWR_CTL_EN, value, 4); | ||
2381 | msleep(PWR_SLEEP_INTERVAL); | ||
2382 | } | ||
2383 | |||
2384 | if (dev->board.tuner_type != TUNER_ABSENT) { | ||
2385 | /* | ||
2386 | * Enable tuner | ||
2387 | * Hauppauge Exeter seems to need to do something different! | ||
2388 | */ | ||
2389 | if (dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER) | ||
2390 | cx231xx_enable_i2c_port_3(dev, false); | ||
2391 | else | ||
2392 | cx231xx_enable_i2c_port_3(dev, true); | ||
2393 | |||
2394 | /* reset the Tuner */ | ||
2395 | if (dev->board.tuner_gpio) | ||
2396 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | ||
2397 | |||
2398 | if (dev->cx231xx_reset_analog_tuner) | ||
2399 | dev->cx231xx_reset_analog_tuner(dev); | ||
2400 | } | ||
2401 | break; | ||
2402 | |||
2403 | default: | ||
2404 | break; | ||
2405 | } | ||
2406 | |||
2407 | msleep(PWR_SLEEP_INTERVAL); | ||
2408 | |||
2409 | /* For power saving, only enable Pwr_resetout_n | ||
2410 | when digital TV is selected. */ | ||
2411 | if (mode == POLARIS_AVMODE_DIGITAL) { | ||
2412 | tmp |= PWR_RESETOUT_EN; | ||
2413 | value[0] = (u8) tmp; | ||
2414 | value[1] = (u8) (tmp >> 8); | ||
2415 | value[2] = (u8) (tmp >> 16); | ||
2416 | value[3] = (u8) (tmp >> 24); | ||
2417 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2418 | PWR_CTL_EN, value, 4); | ||
2419 | msleep(PWR_SLEEP_INTERVAL); | ||
2420 | } | ||
2421 | |||
2422 | /* update power control for afe */ | ||
2423 | status = cx231xx_afe_update_power_control(dev, mode); | ||
2424 | |||
2425 | /* update power control for i2s_blk */ | ||
2426 | status = cx231xx_i2s_blk_update_power_control(dev, mode); | ||
2427 | |||
2428 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, value, | ||
2429 | 4); | ||
2430 | |||
2431 | return status; | ||
2432 | } | ||
2433 | |||
2434 | int cx231xx_power_suspend(struct cx231xx *dev) | ||
2435 | { | ||
2436 | u8 value[4] = { 0, 0, 0, 0 }; | ||
2437 | u32 tmp = 0; | ||
2438 | int status = 0; | ||
2439 | |||
2440 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, | ||
2441 | value, 4); | ||
2442 | if (status > 0) | ||
2443 | return status; | ||
2444 | |||
2445 | tmp = *((u32 *) value); | ||
2446 | tmp &= (~PWR_MODE_MASK); | ||
2447 | |||
2448 | value[0] = (u8) tmp; | ||
2449 | value[1] = (u8) (tmp >> 8); | ||
2450 | value[2] = (u8) (tmp >> 16); | ||
2451 | value[3] = (u8) (tmp >> 24); | ||
2452 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, PWR_CTL_EN, | ||
2453 | value, 4); | ||
2454 | |||
2455 | return status; | ||
2456 | } | ||
2457 | |||
2458 | /****************************************************************************** | ||
2459 | * S T R E A M C O N T R O L functions * | ||
2460 | ******************************************************************************/ | ||
2461 | int cx231xx_start_stream(struct cx231xx *dev, u32 ep_mask) | ||
2462 | { | ||
2463 | u8 value[4] = { 0x0, 0x0, 0x0, 0x0 }; | ||
2464 | u32 tmp = 0; | ||
2465 | int status = 0; | ||
2466 | |||
2467 | cx231xx_info("cx231xx_start_stream():: ep_mask = %x\n", ep_mask); | ||
2468 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, | ||
2469 | value, 4); | ||
2470 | if (status < 0) | ||
2471 | return status; | ||
2472 | |||
2473 | tmp = *((u32 *) value); | ||
2474 | tmp |= ep_mask; | ||
2475 | value[0] = (u8) tmp; | ||
2476 | value[1] = (u8) (tmp >> 8); | ||
2477 | value[2] = (u8) (tmp >> 16); | ||
2478 | value[3] = (u8) (tmp >> 24); | ||
2479 | |||
2480 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, EP_MODE_SET, | ||
2481 | value, 4); | ||
2482 | |||
2483 | return status; | ||
2484 | } | ||
2485 | |||
2486 | int cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask) | ||
2487 | { | ||
2488 | u8 value[4] = { 0x0, 0x0, 0x0, 0x0 }; | ||
2489 | u32 tmp = 0; | ||
2490 | int status = 0; | ||
2491 | |||
2492 | cx231xx_info("cx231xx_stop_stream():: ep_mask = %x\n", ep_mask); | ||
2493 | status = | ||
2494 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, EP_MODE_SET, value, 4); | ||
2495 | if (status < 0) | ||
2496 | return status; | ||
2497 | |||
2498 | tmp = *((u32 *) value); | ||
2499 | tmp &= (~ep_mask); | ||
2500 | value[0] = (u8) tmp; | ||
2501 | value[1] = (u8) (tmp >> 8); | ||
2502 | value[2] = (u8) (tmp >> 16); | ||
2503 | value[3] = (u8) (tmp >> 24); | ||
2504 | |||
2505 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, EP_MODE_SET, | ||
2506 | value, 4); | ||
2507 | |||
2508 | return status; | ||
2509 | } | ||
2510 | |||
2511 | int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type) | ||
2512 | { | ||
2513 | int status = 0; | ||
2514 | u32 value = 0; | ||
2515 | u8 val[4] = { 0, 0, 0, 0 }; | ||
2516 | |||
2517 | if (dev->udev->speed == USB_SPEED_HIGH) { | ||
2518 | switch (media_type) { | ||
2519 | case Audio: | ||
2520 | cx231xx_info("%s: Audio enter HANC\n", __func__); | ||
2521 | status = | ||
2522 | cx231xx_mode_register(dev, TS_MODE_REG, 0x9300); | ||
2523 | break; | ||
2524 | |||
2525 | case Vbi: | ||
2526 | cx231xx_info("%s: set vanc registers\n", __func__); | ||
2527 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x300); | ||
2528 | break; | ||
2529 | |||
2530 | case Sliced_cc: | ||
2531 | cx231xx_info("%s: set hanc registers\n", __func__); | ||
2532 | status = | ||
2533 | cx231xx_mode_register(dev, TS_MODE_REG, 0x1300); | ||
2534 | break; | ||
2535 | |||
2536 | case Raw_Video: | ||
2537 | cx231xx_info("%s: set video registers\n", __func__); | ||
2538 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); | ||
2539 | break; | ||
2540 | |||
2541 | case TS1_serial_mode: | ||
2542 | cx231xx_info("%s: set ts1 registers", __func__); | ||
2543 | |||
2544 | if (dev->board.has_417) { | ||
2545 | cx231xx_info(" MPEG\n"); | ||
2546 | value &= 0xFFFFFFFC; | ||
2547 | value |= 0x3; | ||
2548 | |||
2549 | status = cx231xx_mode_register(dev, TS_MODE_REG, value); | ||
2550 | |||
2551 | val[0] = 0x04; | ||
2552 | val[1] = 0xA3; | ||
2553 | val[2] = 0x3B; | ||
2554 | val[3] = 0x00; | ||
2555 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2556 | TS1_CFG_REG, val, 4); | ||
2557 | |||
2558 | val[0] = 0x00; | ||
2559 | val[1] = 0x08; | ||
2560 | val[2] = 0x00; | ||
2561 | val[3] = 0x08; | ||
2562 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
2563 | TS1_LENGTH_REG, val, 4); | ||
2564 | |||
2565 | } else { | ||
2566 | cx231xx_info(" BDA\n"); | ||
2567 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x101); | ||
2568 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x010); | ||
2569 | } | ||
2570 | break; | ||
2571 | |||
2572 | case TS1_parallel_mode: | ||
2573 | cx231xx_info("%s: set ts1 parallel mode registers\n", | ||
2574 | __func__); | ||
2575 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x100); | ||
2576 | status = cx231xx_mode_register(dev, TS1_CFG_REG, 0x400); | ||
2577 | break; | ||
2578 | } | ||
2579 | } else { | ||
2580 | status = cx231xx_mode_register(dev, TS_MODE_REG, 0x101); | ||
2581 | } | ||
2582 | |||
2583 | return status; | ||
2584 | } | ||
2585 | |||
2586 | int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type) | ||
2587 | { | ||
2588 | int rc = -1; | ||
2589 | u32 ep_mask = -1; | ||
2590 | struct pcb_config *pcb_config; | ||
2591 | |||
2592 | /* get EP for media type */ | ||
2593 | pcb_config = (struct pcb_config *)&dev->current_pcb_config; | ||
2594 | |||
2595 | if (pcb_config->config_num) { | ||
2596 | switch (media_type) { | ||
2597 | case Raw_Video: | ||
2598 | ep_mask = ENABLE_EP4; /* ep4 [00:1000] */ | ||
2599 | break; | ||
2600 | case Audio: | ||
2601 | ep_mask = ENABLE_EP3; /* ep3 [00:0100] */ | ||
2602 | break; | ||
2603 | case Vbi: | ||
2604 | ep_mask = ENABLE_EP5; /* ep5 [01:0000] */ | ||
2605 | break; | ||
2606 | case Sliced_cc: | ||
2607 | ep_mask = ENABLE_EP6; /* ep6 [10:0000] */ | ||
2608 | break; | ||
2609 | case TS1_serial_mode: | ||
2610 | case TS1_parallel_mode: | ||
2611 | ep_mask = ENABLE_EP1; /* ep1 [00:0001] */ | ||
2612 | break; | ||
2613 | case TS2: | ||
2614 | ep_mask = ENABLE_EP2; /* ep2 [00:0010] */ | ||
2615 | break; | ||
2616 | } | ||
2617 | } | ||
2618 | |||
2619 | if (start) { | ||
2620 | rc = cx231xx_initialize_stream_xfer(dev, media_type); | ||
2621 | |||
2622 | if (rc < 0) | ||
2623 | return rc; | ||
2624 | |||
2625 | /* enable video capture */ | ||
2626 | if (ep_mask > 0) | ||
2627 | rc = cx231xx_start_stream(dev, ep_mask); | ||
2628 | } else { | ||
2629 | /* disable video capture */ | ||
2630 | if (ep_mask > 0) | ||
2631 | rc = cx231xx_stop_stream(dev, ep_mask); | ||
2632 | } | ||
2633 | |||
2634 | if (dev->mode == CX231XX_ANALOG_MODE) | ||
2635 | ;/* do any in Analog mode */ | ||
2636 | else | ||
2637 | ;/* do any in digital mode */ | ||
2638 | |||
2639 | return rc; | ||
2640 | } | ||
2641 | EXPORT_SYMBOL_GPL(cx231xx_capture_start); | ||
2642 | |||
2643 | /***************************************************************************** | ||
2644 | * G P I O B I T control functions * | ||
2645 | ******************************************************************************/ | ||
2646 | int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val) | ||
2647 | { | ||
2648 | int status = 0; | ||
2649 | |||
2650 | status = cx231xx_send_gpio_cmd(dev, gpio_bit, gpio_val, 4, 0, 0); | ||
2651 | |||
2652 | return status; | ||
2653 | } | ||
2654 | |||
2655 | int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val) | ||
2656 | { | ||
2657 | int status = 0; | ||
2658 | |||
2659 | status = cx231xx_send_gpio_cmd(dev, gpio_bit, gpio_val, 4, 0, 1); | ||
2660 | |||
2661 | return status; | ||
2662 | } | ||
2663 | |||
2664 | /* | ||
2665 | * cx231xx_set_gpio_direction | ||
2666 | * Sets the direction of the GPIO pin to input or output | ||
2667 | * | ||
2668 | * Parameters : | ||
2669 | * pin_number : The GPIO Pin number to program the direction for | ||
2670 | * from 0 to 31 | ||
2671 | * pin_value : The Direction of the GPIO Pin under reference. | ||
2672 | * 0 = Input direction | ||
2673 | * 1 = Output direction | ||
2674 | */ | ||
2675 | int cx231xx_set_gpio_direction(struct cx231xx *dev, | ||
2676 | int pin_number, int pin_value) | ||
2677 | { | ||
2678 | int status = 0; | ||
2679 | u32 value = 0; | ||
2680 | |||
2681 | /* Check for valid pin_number - if 32 , bail out */ | ||
2682 | if (pin_number >= 32) | ||
2683 | return -EINVAL; | ||
2684 | |||
2685 | /* input */ | ||
2686 | if (pin_value == 0) | ||
2687 | value = dev->gpio_dir & (~(1 << pin_number)); /* clear */ | ||
2688 | else | ||
2689 | value = dev->gpio_dir | (1 << pin_number); | ||
2690 | |||
2691 | status = cx231xx_set_gpio_bit(dev, value, (u8 *) &dev->gpio_val); | ||
2692 | |||
2693 | /* cache the value for future */ | ||
2694 | dev->gpio_dir = value; | ||
2695 | |||
2696 | return status; | ||
2697 | } | ||
2698 | |||
2699 | /* | ||
2700 | * cx231xx_set_gpio_value | ||
2701 | * Sets the value of the GPIO pin to Logic high or low. The Pin under | ||
2702 | * reference should ALREADY BE SET IN OUTPUT MODE !!!!!!!!! | ||
2703 | * | ||
2704 | * Parameters : | ||
2705 | * pin_number : The GPIO Pin number to program the direction for | ||
2706 | * pin_value : The value of the GPIO Pin under reference. | ||
2707 | * 0 = set it to 0 | ||
2708 | * 1 = set it to 1 | ||
2709 | */ | ||
2710 | int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value) | ||
2711 | { | ||
2712 | int status = 0; | ||
2713 | u32 value = 0; | ||
2714 | |||
2715 | /* Check for valid pin_number - if 0xFF , bail out */ | ||
2716 | if (pin_number >= 32) | ||
2717 | return -EINVAL; | ||
2718 | |||
2719 | /* first do a sanity check - if the Pin is not output, make it output */ | ||
2720 | if ((dev->gpio_dir & (1 << pin_number)) == 0x00) { | ||
2721 | /* It was in input mode */ | ||
2722 | value = dev->gpio_dir | (1 << pin_number); | ||
2723 | dev->gpio_dir = value; | ||
2724 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2725 | (u8 *) &dev->gpio_val); | ||
2726 | value = 0; | ||
2727 | } | ||
2728 | |||
2729 | if (pin_value == 0) | ||
2730 | value = dev->gpio_val & (~(1 << pin_number)); | ||
2731 | else | ||
2732 | value = dev->gpio_val | (1 << pin_number); | ||
2733 | |||
2734 | /* store the value */ | ||
2735 | dev->gpio_val = value; | ||
2736 | |||
2737 | /* toggle bit0 of GP_IO */ | ||
2738 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2739 | |||
2740 | return status; | ||
2741 | } | ||
2742 | |||
2743 | /***************************************************************************** | ||
2744 | * G P I O I2C related functions * | ||
2745 | ******************************************************************************/ | ||
2746 | int cx231xx_gpio_i2c_start(struct cx231xx *dev) | ||
2747 | { | ||
2748 | int status = 0; | ||
2749 | |||
2750 | /* set SCL to output 1 ; set SDA to output 1 */ | ||
2751 | dev->gpio_dir |= 1 << dev->board.tuner_scl_gpio; | ||
2752 | dev->gpio_dir |= 1 << dev->board.tuner_sda_gpio; | ||
2753 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2754 | dev->gpio_val |= 1 << dev->board.tuner_sda_gpio; | ||
2755 | |||
2756 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2757 | if (status < 0) | ||
2758 | return -EINVAL; | ||
2759 | |||
2760 | /* set SCL to output 1; set SDA to output 0 */ | ||
2761 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2762 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2763 | |||
2764 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2765 | if (status < 0) | ||
2766 | return -EINVAL; | ||
2767 | |||
2768 | /* set SCL to output 0; set SDA to output 0 */ | ||
2769 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2770 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2771 | |||
2772 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2773 | if (status < 0) | ||
2774 | return -EINVAL; | ||
2775 | |||
2776 | return status; | ||
2777 | } | ||
2778 | |||
2779 | int cx231xx_gpio_i2c_end(struct cx231xx *dev) | ||
2780 | { | ||
2781 | int status = 0; | ||
2782 | |||
2783 | /* set SCL to output 0; set SDA to output 0 */ | ||
2784 | dev->gpio_dir |= 1 << dev->board.tuner_scl_gpio; | ||
2785 | dev->gpio_dir |= 1 << dev->board.tuner_sda_gpio; | ||
2786 | |||
2787 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2788 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2789 | |||
2790 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2791 | if (status < 0) | ||
2792 | return -EINVAL; | ||
2793 | |||
2794 | /* set SCL to output 1; set SDA to output 0 */ | ||
2795 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2796 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2797 | |||
2798 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2799 | if (status < 0) | ||
2800 | return -EINVAL; | ||
2801 | |||
2802 | /* set SCL to input ,release SCL cable control | ||
2803 | set SDA to input ,release SDA cable control */ | ||
2804 | dev->gpio_dir &= ~(1 << dev->board.tuner_scl_gpio); | ||
2805 | dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio); | ||
2806 | |||
2807 | status = | ||
2808 | cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2809 | if (status < 0) | ||
2810 | return -EINVAL; | ||
2811 | |||
2812 | return status; | ||
2813 | } | ||
2814 | |||
2815 | int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data) | ||
2816 | { | ||
2817 | int status = 0; | ||
2818 | u8 i; | ||
2819 | |||
2820 | /* set SCL to output ; set SDA to output */ | ||
2821 | dev->gpio_dir |= 1 << dev->board.tuner_scl_gpio; | ||
2822 | dev->gpio_dir |= 1 << dev->board.tuner_sda_gpio; | ||
2823 | |||
2824 | for (i = 0; i < 8; i++) { | ||
2825 | if (((data << i) & 0x80) == 0) { | ||
2826 | /* set SCL to output 0; set SDA to output 0 */ | ||
2827 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2828 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2829 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2830 | (u8 *)&dev->gpio_val); | ||
2831 | |||
2832 | /* set SCL to output 1; set SDA to output 0 */ | ||
2833 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2834 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2835 | (u8 *)&dev->gpio_val); | ||
2836 | |||
2837 | /* set SCL to output 0; set SDA to output 0 */ | ||
2838 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2839 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2840 | (u8 *)&dev->gpio_val); | ||
2841 | } else { | ||
2842 | /* set SCL to output 0; set SDA to output 1 */ | ||
2843 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2844 | dev->gpio_val |= 1 << dev->board.tuner_sda_gpio; | ||
2845 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2846 | (u8 *)&dev->gpio_val); | ||
2847 | |||
2848 | /* set SCL to output 1; set SDA to output 1 */ | ||
2849 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2850 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2851 | (u8 *)&dev->gpio_val); | ||
2852 | |||
2853 | /* set SCL to output 0; set SDA to output 1 */ | ||
2854 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2855 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2856 | (u8 *)&dev->gpio_val); | ||
2857 | } | ||
2858 | } | ||
2859 | return status; | ||
2860 | } | ||
2861 | |||
2862 | int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 *buf) | ||
2863 | { | ||
2864 | u8 value = 0; | ||
2865 | int status = 0; | ||
2866 | u32 gpio_logic_value = 0; | ||
2867 | u8 i; | ||
2868 | |||
2869 | /* read byte */ | ||
2870 | for (i = 0; i < 8; i++) { /* send write I2c addr */ | ||
2871 | |||
2872 | /* set SCL to output 0; set SDA to input */ | ||
2873 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2874 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2875 | (u8 *)&dev->gpio_val); | ||
2876 | |||
2877 | /* set SCL to output 1; set SDA to input */ | ||
2878 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2879 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, | ||
2880 | (u8 *)&dev->gpio_val); | ||
2881 | |||
2882 | /* get SDA data bit */ | ||
2883 | gpio_logic_value = dev->gpio_val; | ||
2884 | status = cx231xx_get_gpio_bit(dev, dev->gpio_dir, | ||
2885 | (u8 *)&dev->gpio_val); | ||
2886 | if ((dev->gpio_val & (1 << dev->board.tuner_sda_gpio)) != 0) | ||
2887 | value |= (1 << (8 - i - 1)); | ||
2888 | |||
2889 | dev->gpio_val = gpio_logic_value; | ||
2890 | } | ||
2891 | |||
2892 | /* set SCL to output 0,finish the read latest SCL signal. | ||
2893 | !!!set SDA to input, never to modify SDA direction at | ||
2894 | the same times */ | ||
2895 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2896 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2897 | |||
2898 | /* store the value */ | ||
2899 | *buf = value & 0xff; | ||
2900 | |||
2901 | return status; | ||
2902 | } | ||
2903 | |||
2904 | int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev) | ||
2905 | { | ||
2906 | int status = 0; | ||
2907 | u32 gpio_logic_value = 0; | ||
2908 | int nCnt = 10; | ||
2909 | int nInit = nCnt; | ||
2910 | |||
2911 | /* clock stretch; set SCL to input; set SDA to input; | ||
2912 | get SCL value till SCL = 1 */ | ||
2913 | dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio); | ||
2914 | dev->gpio_dir &= ~(1 << dev->board.tuner_scl_gpio); | ||
2915 | |||
2916 | gpio_logic_value = dev->gpio_val; | ||
2917 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2918 | |||
2919 | do { | ||
2920 | msleep(2); | ||
2921 | status = cx231xx_get_gpio_bit(dev, dev->gpio_dir, | ||
2922 | (u8 *)&dev->gpio_val); | ||
2923 | nCnt--; | ||
2924 | } while (((dev->gpio_val & | ||
2925 | (1 << dev->board.tuner_scl_gpio)) == 0) && | ||
2926 | (nCnt > 0)); | ||
2927 | |||
2928 | if (nCnt == 0) | ||
2929 | cx231xx_info("No ACK after %d msec -GPIO I2C failed!", | ||
2930 | nInit * 10); | ||
2931 | |||
2932 | /* | ||
2933 | * readAck | ||
2934 | * through clock stretch, slave has given a SCL signal, | ||
2935 | * so the SDA data can be directly read. | ||
2936 | */ | ||
2937 | status = cx231xx_get_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2938 | |||
2939 | if ((dev->gpio_val & 1 << dev->board.tuner_sda_gpio) == 0) { | ||
2940 | dev->gpio_val = gpio_logic_value; | ||
2941 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2942 | status = 0; | ||
2943 | } else { | ||
2944 | dev->gpio_val = gpio_logic_value; | ||
2945 | dev->gpio_val |= (1 << dev->board.tuner_sda_gpio); | ||
2946 | } | ||
2947 | |||
2948 | /* read SDA end, set the SCL to output 0, after this operation, | ||
2949 | SDA direction can be changed. */ | ||
2950 | dev->gpio_val = gpio_logic_value; | ||
2951 | dev->gpio_dir |= (1 << dev->board.tuner_scl_gpio); | ||
2952 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2953 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2954 | |||
2955 | return status; | ||
2956 | } | ||
2957 | |||
2958 | int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev) | ||
2959 | { | ||
2960 | int status = 0; | ||
2961 | |||
2962 | /* set SDA to ouput */ | ||
2963 | dev->gpio_dir |= 1 << dev->board.tuner_sda_gpio; | ||
2964 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2965 | |||
2966 | /* set SCL = 0 (output); set SDA = 0 (output) */ | ||
2967 | dev->gpio_val &= ~(1 << dev->board.tuner_sda_gpio); | ||
2968 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2969 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2970 | |||
2971 | /* set SCL = 1 (output); set SDA = 0 (output) */ | ||
2972 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
2973 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2974 | |||
2975 | /* set SCL = 0 (output); set SDA = 0 (output) */ | ||
2976 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2977 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2978 | |||
2979 | /* set SDA to input,and then the slave will read data from SDA. */ | ||
2980 | dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio); | ||
2981 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2982 | |||
2983 | return status; | ||
2984 | } | ||
2985 | |||
2986 | int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev) | ||
2987 | { | ||
2988 | int status = 0; | ||
2989 | |||
2990 | /* set scl to output ; set sda to input */ | ||
2991 | dev->gpio_dir |= 1 << dev->board.tuner_scl_gpio; | ||
2992 | dev->gpio_dir &= ~(1 << dev->board.tuner_sda_gpio); | ||
2993 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2994 | |||
2995 | /* set scl to output 0; set sda to input */ | ||
2996 | dev->gpio_val &= ~(1 << dev->board.tuner_scl_gpio); | ||
2997 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
2998 | |||
2999 | /* set scl to output 1; set sda to input */ | ||
3000 | dev->gpio_val |= 1 << dev->board.tuner_scl_gpio; | ||
3001 | status = cx231xx_set_gpio_bit(dev, dev->gpio_dir, (u8 *)&dev->gpio_val); | ||
3002 | |||
3003 | return status; | ||
3004 | } | ||
3005 | |||
3006 | /***************************************************************************** | ||
3007 | * G P I O I2C related functions * | ||
3008 | ******************************************************************************/ | ||
3009 | /* cx231xx_gpio_i2c_read | ||
3010 | * Function to read data from gpio based I2C interface | ||
3011 | */ | ||
3012 | int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len) | ||
3013 | { | ||
3014 | int status = 0; | ||
3015 | int i = 0; | ||
3016 | |||
3017 | /* get the lock */ | ||
3018 | mutex_lock(&dev->gpio_i2c_lock); | ||
3019 | |||
3020 | /* start */ | ||
3021 | status = cx231xx_gpio_i2c_start(dev); | ||
3022 | |||
3023 | /* write dev_addr */ | ||
3024 | status = cx231xx_gpio_i2c_write_byte(dev, (dev_addr << 1) + 1); | ||
3025 | |||
3026 | /* readAck */ | ||
3027 | status = cx231xx_gpio_i2c_read_ack(dev); | ||
3028 | |||
3029 | /* read data */ | ||
3030 | for (i = 0; i < len; i++) { | ||
3031 | /* read data */ | ||
3032 | buf[i] = 0; | ||
3033 | status = cx231xx_gpio_i2c_read_byte(dev, &buf[i]); | ||
3034 | |||
3035 | if ((i + 1) != len) { | ||
3036 | /* only do write ack if we more length */ | ||
3037 | status = cx231xx_gpio_i2c_write_ack(dev); | ||
3038 | } | ||
3039 | } | ||
3040 | |||
3041 | /* write NAK - inform reads are complete */ | ||
3042 | status = cx231xx_gpio_i2c_write_nak(dev); | ||
3043 | |||
3044 | /* write end */ | ||
3045 | status = cx231xx_gpio_i2c_end(dev); | ||
3046 | |||
3047 | /* release the lock */ | ||
3048 | mutex_unlock(&dev->gpio_i2c_lock); | ||
3049 | |||
3050 | return status; | ||
3051 | } | ||
3052 | |||
3053 | /* cx231xx_gpio_i2c_write | ||
3054 | * Function to write data to gpio based I2C interface | ||
3055 | */ | ||
3056 | int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len) | ||
3057 | { | ||
3058 | int i = 0; | ||
3059 | |||
3060 | /* get the lock */ | ||
3061 | mutex_lock(&dev->gpio_i2c_lock); | ||
3062 | |||
3063 | /* start */ | ||
3064 | cx231xx_gpio_i2c_start(dev); | ||
3065 | |||
3066 | /* write dev_addr */ | ||
3067 | cx231xx_gpio_i2c_write_byte(dev, dev_addr << 1); | ||
3068 | |||
3069 | /* read Ack */ | ||
3070 | cx231xx_gpio_i2c_read_ack(dev); | ||
3071 | |||
3072 | for (i = 0; i < len; i++) { | ||
3073 | /* Write data */ | ||
3074 | cx231xx_gpio_i2c_write_byte(dev, buf[i]); | ||
3075 | |||
3076 | /* read Ack */ | ||
3077 | cx231xx_gpio_i2c_read_ack(dev); | ||
3078 | } | ||
3079 | |||
3080 | /* write End */ | ||
3081 | cx231xx_gpio_i2c_end(dev); | ||
3082 | |||
3083 | /* release the lock */ | ||
3084 | mutex_unlock(&dev->gpio_i2c_lock); | ||
3085 | |||
3086 | return 0; | ||
3087 | } | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c new file mode 100644 index 000000000000..02d4d36735d3 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c | |||
@@ -0,0 +1,1370 @@ | |||
1 | /* | ||
2 | cx231xx-cards.c - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | Based on em28xx driver | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/i2c.h> | ||
28 | #include <linux/usb.h> | ||
29 | #include <media/tuner.h> | ||
30 | #include <media/tveeprom.h> | ||
31 | #include <media/v4l2-common.h> | ||
32 | #include <media/v4l2-chip-ident.h> | ||
33 | |||
34 | #include <media/cx25840.h> | ||
35 | #include "dvb-usb-ids.h" | ||
36 | #include "xc5000.h" | ||
37 | #include "tda18271.h" | ||
38 | |||
39 | #include "cx231xx.h" | ||
40 | |||
41 | static int tuner = -1; | ||
42 | module_param(tuner, int, 0444); | ||
43 | MODULE_PARM_DESC(tuner, "tuner type"); | ||
44 | |||
45 | static int transfer_mode = 1; | ||
46 | module_param(transfer_mode, int, 0444); | ||
47 | MODULE_PARM_DESC(transfer_mode, "transfer mode (1-ISO or 0-BULK)"); | ||
48 | |||
49 | static unsigned int disable_ir; | ||
50 | module_param(disable_ir, int, 0444); | ||
51 | MODULE_PARM_DESC(disable_ir, "disable infrared remote support"); | ||
52 | |||
53 | /* Bitmask marking allocated devices from 0 to CX231XX_MAXBOARDS */ | ||
54 | static unsigned long cx231xx_devused; | ||
55 | |||
56 | /* | ||
57 | * Reset sequences for analog/digital modes | ||
58 | */ | ||
59 | |||
60 | static struct cx231xx_reg_seq RDE250_XCV_TUNER[] = { | ||
61 | {0x03, 0x01, 10}, | ||
62 | {0x03, 0x00, 30}, | ||
63 | {0x03, 0x01, 10}, | ||
64 | {-1, -1, -1}, | ||
65 | }; | ||
66 | |||
67 | /* | ||
68 | * Board definitions | ||
69 | */ | ||
70 | struct cx231xx_board cx231xx_boards[] = { | ||
71 | [CX231XX_BOARD_UNKNOWN] = { | ||
72 | .name = "Unknown CX231xx video grabber", | ||
73 | .tuner_type = TUNER_ABSENT, | ||
74 | .input = {{ | ||
75 | .type = CX231XX_VMUX_TELEVISION, | ||
76 | .vmux = CX231XX_VIN_3_1, | ||
77 | .amux = CX231XX_AMUX_VIDEO, | ||
78 | .gpio = NULL, | ||
79 | }, { | ||
80 | .type = CX231XX_VMUX_COMPOSITE1, | ||
81 | .vmux = CX231XX_VIN_2_1, | ||
82 | .amux = CX231XX_AMUX_LINE_IN, | ||
83 | .gpio = NULL, | ||
84 | }, { | ||
85 | .type = CX231XX_VMUX_SVIDEO, | ||
86 | .vmux = CX231XX_VIN_1_1 | | ||
87 | (CX231XX_VIN_1_2 << 8) | | ||
88 | CX25840_SVIDEO_ON, | ||
89 | .amux = CX231XX_AMUX_LINE_IN, | ||
90 | .gpio = NULL, | ||
91 | } | ||
92 | }, | ||
93 | }, | ||
94 | [CX231XX_BOARD_CNXT_CARRAERA] = { | ||
95 | .name = "Conexant Hybrid TV - CARRAERA", | ||
96 | .tuner_type = TUNER_XC5000, | ||
97 | .tuner_addr = 0x61, | ||
98 | .tuner_gpio = RDE250_XCV_TUNER, | ||
99 | .tuner_sif_gpio = 0x05, | ||
100 | .tuner_scl_gpio = 0x1a, | ||
101 | .tuner_sda_gpio = 0x1b, | ||
102 | .decoder = CX231XX_AVDECODER, | ||
103 | .output_mode = OUT_MODE_VIP11, | ||
104 | .demod_xfer_mode = 0, | ||
105 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
106 | .agc_analog_digital_select_gpio = 0x0c, | ||
107 | .gpio_pin_status_mask = 0x4001000, | ||
108 | .tuner_i2c_master = 1, | ||
109 | .demod_i2c_master = 2, | ||
110 | .has_dvb = 1, | ||
111 | .demod_addr = 0x02, | ||
112 | .norm = V4L2_STD_PAL, | ||
113 | |||
114 | .input = {{ | ||
115 | .type = CX231XX_VMUX_TELEVISION, | ||
116 | .vmux = CX231XX_VIN_3_1, | ||
117 | .amux = CX231XX_AMUX_VIDEO, | ||
118 | .gpio = NULL, | ||
119 | }, { | ||
120 | .type = CX231XX_VMUX_COMPOSITE1, | ||
121 | .vmux = CX231XX_VIN_2_1, | ||
122 | .amux = CX231XX_AMUX_LINE_IN, | ||
123 | .gpio = NULL, | ||
124 | }, { | ||
125 | .type = CX231XX_VMUX_SVIDEO, | ||
126 | .vmux = CX231XX_VIN_1_1 | | ||
127 | (CX231XX_VIN_1_2 << 8) | | ||
128 | CX25840_SVIDEO_ON, | ||
129 | .amux = CX231XX_AMUX_LINE_IN, | ||
130 | .gpio = NULL, | ||
131 | } | ||
132 | }, | ||
133 | }, | ||
134 | [CX231XX_BOARD_CNXT_SHELBY] = { | ||
135 | .name = "Conexant Hybrid TV - SHELBY", | ||
136 | .tuner_type = TUNER_XC5000, | ||
137 | .tuner_addr = 0x61, | ||
138 | .tuner_gpio = RDE250_XCV_TUNER, | ||
139 | .tuner_sif_gpio = 0x05, | ||
140 | .tuner_scl_gpio = 0x1a, | ||
141 | .tuner_sda_gpio = 0x1b, | ||
142 | .decoder = CX231XX_AVDECODER, | ||
143 | .output_mode = OUT_MODE_VIP11, | ||
144 | .demod_xfer_mode = 0, | ||
145 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
146 | .agc_analog_digital_select_gpio = 0x0c, | ||
147 | .gpio_pin_status_mask = 0x4001000, | ||
148 | .tuner_i2c_master = 1, | ||
149 | .demod_i2c_master = 2, | ||
150 | .has_dvb = 1, | ||
151 | .demod_addr = 0x32, | ||
152 | .norm = V4L2_STD_NTSC, | ||
153 | |||
154 | .input = {{ | ||
155 | .type = CX231XX_VMUX_TELEVISION, | ||
156 | .vmux = CX231XX_VIN_3_1, | ||
157 | .amux = CX231XX_AMUX_VIDEO, | ||
158 | .gpio = NULL, | ||
159 | }, { | ||
160 | .type = CX231XX_VMUX_COMPOSITE1, | ||
161 | .vmux = CX231XX_VIN_2_1, | ||
162 | .amux = CX231XX_AMUX_LINE_IN, | ||
163 | .gpio = NULL, | ||
164 | }, { | ||
165 | .type = CX231XX_VMUX_SVIDEO, | ||
166 | .vmux = CX231XX_VIN_1_1 | | ||
167 | (CX231XX_VIN_1_2 << 8) | | ||
168 | CX25840_SVIDEO_ON, | ||
169 | .amux = CX231XX_AMUX_LINE_IN, | ||
170 | .gpio = NULL, | ||
171 | } | ||
172 | }, | ||
173 | }, | ||
174 | [CX231XX_BOARD_CNXT_RDE_253S] = { | ||
175 | .name = "Conexant Hybrid TV - RDE253S", | ||
176 | .tuner_type = TUNER_NXP_TDA18271, | ||
177 | .tuner_addr = 0x60, | ||
178 | .tuner_gpio = RDE250_XCV_TUNER, | ||
179 | .tuner_sif_gpio = 0x05, | ||
180 | .tuner_scl_gpio = 0x1a, | ||
181 | .tuner_sda_gpio = 0x1b, | ||
182 | .decoder = CX231XX_AVDECODER, | ||
183 | .output_mode = OUT_MODE_VIP11, | ||
184 | .demod_xfer_mode = 0, | ||
185 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
186 | .agc_analog_digital_select_gpio = 0x1c, | ||
187 | .gpio_pin_status_mask = 0x4001000, | ||
188 | .tuner_i2c_master = 1, | ||
189 | .demod_i2c_master = 2, | ||
190 | .has_dvb = 1, | ||
191 | .demod_addr = 0x02, | ||
192 | .norm = V4L2_STD_PAL, | ||
193 | |||
194 | .input = {{ | ||
195 | .type = CX231XX_VMUX_TELEVISION, | ||
196 | .vmux = CX231XX_VIN_3_1, | ||
197 | .amux = CX231XX_AMUX_VIDEO, | ||
198 | .gpio = NULL, | ||
199 | }, { | ||
200 | .type = CX231XX_VMUX_COMPOSITE1, | ||
201 | .vmux = CX231XX_VIN_2_1, | ||
202 | .amux = CX231XX_AMUX_LINE_IN, | ||
203 | .gpio = NULL, | ||
204 | }, { | ||
205 | .type = CX231XX_VMUX_SVIDEO, | ||
206 | .vmux = CX231XX_VIN_1_1 | | ||
207 | (CX231XX_VIN_1_2 << 8) | | ||
208 | CX25840_SVIDEO_ON, | ||
209 | .amux = CX231XX_AMUX_LINE_IN, | ||
210 | .gpio = NULL, | ||
211 | } | ||
212 | }, | ||
213 | }, | ||
214 | |||
215 | [CX231XX_BOARD_CNXT_RDU_253S] = { | ||
216 | .name = "Conexant Hybrid TV - RDU253S", | ||
217 | .tuner_type = TUNER_NXP_TDA18271, | ||
218 | .tuner_addr = 0x60, | ||
219 | .tuner_gpio = RDE250_XCV_TUNER, | ||
220 | .tuner_sif_gpio = 0x05, | ||
221 | .tuner_scl_gpio = 0x1a, | ||
222 | .tuner_sda_gpio = 0x1b, | ||
223 | .decoder = CX231XX_AVDECODER, | ||
224 | .output_mode = OUT_MODE_VIP11, | ||
225 | .demod_xfer_mode = 0, | ||
226 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
227 | .agc_analog_digital_select_gpio = 0x1c, | ||
228 | .gpio_pin_status_mask = 0x4001000, | ||
229 | .tuner_i2c_master = 1, | ||
230 | .demod_i2c_master = 2, | ||
231 | .has_dvb = 1, | ||
232 | .demod_addr = 0x02, | ||
233 | .norm = V4L2_STD_PAL, | ||
234 | |||
235 | .input = {{ | ||
236 | .type = CX231XX_VMUX_TELEVISION, | ||
237 | .vmux = CX231XX_VIN_3_1, | ||
238 | .amux = CX231XX_AMUX_VIDEO, | ||
239 | .gpio = NULL, | ||
240 | }, { | ||
241 | .type = CX231XX_VMUX_COMPOSITE1, | ||
242 | .vmux = CX231XX_VIN_2_1, | ||
243 | .amux = CX231XX_AMUX_LINE_IN, | ||
244 | .gpio = NULL, | ||
245 | }, { | ||
246 | .type = CX231XX_VMUX_SVIDEO, | ||
247 | .vmux = CX231XX_VIN_1_1 | | ||
248 | (CX231XX_VIN_1_2 << 8) | | ||
249 | CX25840_SVIDEO_ON, | ||
250 | .amux = CX231XX_AMUX_LINE_IN, | ||
251 | .gpio = NULL, | ||
252 | } | ||
253 | }, | ||
254 | }, | ||
255 | [CX231XX_BOARD_CNXT_VIDEO_GRABBER] = { | ||
256 | .name = "Conexant VIDEO GRABBER", | ||
257 | .tuner_type = TUNER_ABSENT, | ||
258 | .decoder = CX231XX_AVDECODER, | ||
259 | .output_mode = OUT_MODE_VIP11, | ||
260 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
261 | .agc_analog_digital_select_gpio = 0x1c, | ||
262 | .gpio_pin_status_mask = 0x4001000, | ||
263 | .norm = V4L2_STD_PAL, | ||
264 | .no_alt_vanc = 1, | ||
265 | .external_av = 1, | ||
266 | .has_417 = 1, | ||
267 | |||
268 | .input = {{ | ||
269 | .type = CX231XX_VMUX_COMPOSITE1, | ||
270 | .vmux = CX231XX_VIN_2_1, | ||
271 | .amux = CX231XX_AMUX_LINE_IN, | ||
272 | .gpio = NULL, | ||
273 | }, { | ||
274 | .type = CX231XX_VMUX_SVIDEO, | ||
275 | .vmux = CX231XX_VIN_1_1 | | ||
276 | (CX231XX_VIN_1_2 << 8) | | ||
277 | CX25840_SVIDEO_ON, | ||
278 | .amux = CX231XX_AMUX_LINE_IN, | ||
279 | .gpio = NULL, | ||
280 | } | ||
281 | }, | ||
282 | }, | ||
283 | [CX231XX_BOARD_CNXT_RDE_250] = { | ||
284 | .name = "Conexant Hybrid TV - rde 250", | ||
285 | .tuner_type = TUNER_XC5000, | ||
286 | .tuner_addr = 0x61, | ||
287 | .tuner_gpio = RDE250_XCV_TUNER, | ||
288 | .tuner_sif_gpio = 0x05, | ||
289 | .tuner_scl_gpio = 0x1a, | ||
290 | .tuner_sda_gpio = 0x1b, | ||
291 | .decoder = CX231XX_AVDECODER, | ||
292 | .output_mode = OUT_MODE_VIP11, | ||
293 | .demod_xfer_mode = 0, | ||
294 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
295 | .agc_analog_digital_select_gpio = 0x0c, | ||
296 | .gpio_pin_status_mask = 0x4001000, | ||
297 | .tuner_i2c_master = 1, | ||
298 | .demod_i2c_master = 2, | ||
299 | .has_dvb = 1, | ||
300 | .demod_addr = 0x02, | ||
301 | .norm = V4L2_STD_PAL, | ||
302 | |||
303 | .input = {{ | ||
304 | .type = CX231XX_VMUX_TELEVISION, | ||
305 | .vmux = CX231XX_VIN_2_1, | ||
306 | .amux = CX231XX_AMUX_VIDEO, | ||
307 | .gpio = NULL, | ||
308 | } | ||
309 | }, | ||
310 | }, | ||
311 | [CX231XX_BOARD_CNXT_RDU_250] = { | ||
312 | .name = "Conexant Hybrid TV - RDU 250", | ||
313 | .tuner_type = TUNER_XC5000, | ||
314 | .tuner_addr = 0x61, | ||
315 | .tuner_gpio = RDE250_XCV_TUNER, | ||
316 | .tuner_sif_gpio = 0x05, | ||
317 | .tuner_scl_gpio = 0x1a, | ||
318 | .tuner_sda_gpio = 0x1b, | ||
319 | .decoder = CX231XX_AVDECODER, | ||
320 | .output_mode = OUT_MODE_VIP11, | ||
321 | .demod_xfer_mode = 0, | ||
322 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
323 | .agc_analog_digital_select_gpio = 0x0c, | ||
324 | .gpio_pin_status_mask = 0x4001000, | ||
325 | .tuner_i2c_master = 1, | ||
326 | .demod_i2c_master = 2, | ||
327 | .has_dvb = 1, | ||
328 | .demod_addr = 0x32, | ||
329 | .norm = V4L2_STD_NTSC, | ||
330 | |||
331 | .input = {{ | ||
332 | .type = CX231XX_VMUX_TELEVISION, | ||
333 | .vmux = CX231XX_VIN_2_1, | ||
334 | .amux = CX231XX_AMUX_VIDEO, | ||
335 | .gpio = NULL, | ||
336 | } | ||
337 | }, | ||
338 | }, | ||
339 | [CX231XX_BOARD_HAUPPAUGE_EXETER] = { | ||
340 | .name = "Hauppauge EXETER", | ||
341 | .tuner_type = TUNER_NXP_TDA18271, | ||
342 | .tuner_addr = 0x60, | ||
343 | .tuner_gpio = RDE250_XCV_TUNER, | ||
344 | .tuner_sif_gpio = 0x05, | ||
345 | .tuner_scl_gpio = 0x1a, | ||
346 | .tuner_sda_gpio = 0x1b, | ||
347 | .decoder = CX231XX_AVDECODER, | ||
348 | .output_mode = OUT_MODE_VIP11, | ||
349 | .demod_xfer_mode = 0, | ||
350 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
351 | .agc_analog_digital_select_gpio = 0x0c, | ||
352 | .gpio_pin_status_mask = 0x4001000, | ||
353 | .tuner_i2c_master = 1, | ||
354 | .demod_i2c_master = 2, | ||
355 | .has_dvb = 1, | ||
356 | .demod_addr = 0x0e, | ||
357 | .norm = V4L2_STD_NTSC, | ||
358 | |||
359 | .input = {{ | ||
360 | .type = CX231XX_VMUX_TELEVISION, | ||
361 | .vmux = CX231XX_VIN_3_1, | ||
362 | .amux = CX231XX_AMUX_VIDEO, | ||
363 | .gpio = NULL, | ||
364 | }, { | ||
365 | .type = CX231XX_VMUX_COMPOSITE1, | ||
366 | .vmux = CX231XX_VIN_2_1, | ||
367 | .amux = CX231XX_AMUX_LINE_IN, | ||
368 | .gpio = NULL, | ||
369 | }, { | ||
370 | .type = CX231XX_VMUX_SVIDEO, | ||
371 | .vmux = CX231XX_VIN_1_1 | | ||
372 | (CX231XX_VIN_1_2 << 8) | | ||
373 | CX25840_SVIDEO_ON, | ||
374 | .amux = CX231XX_AMUX_LINE_IN, | ||
375 | .gpio = NULL, | ||
376 | } }, | ||
377 | }, | ||
378 | [CX231XX_BOARD_HAUPPAUGE_USBLIVE2] = { | ||
379 | .name = "Hauppauge USB Live 2", | ||
380 | .tuner_type = TUNER_ABSENT, | ||
381 | .decoder = CX231XX_AVDECODER, | ||
382 | .output_mode = OUT_MODE_VIP11, | ||
383 | .demod_xfer_mode = 0, | ||
384 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
385 | .agc_analog_digital_select_gpio = 0x0c, | ||
386 | .gpio_pin_status_mask = 0x4001000, | ||
387 | .norm = V4L2_STD_NTSC, | ||
388 | .no_alt_vanc = 1, | ||
389 | .external_av = 1, | ||
390 | .dont_use_port_3 = 1, | ||
391 | .input = {{ | ||
392 | .type = CX231XX_VMUX_COMPOSITE1, | ||
393 | .vmux = CX231XX_VIN_2_1, | ||
394 | .amux = CX231XX_AMUX_LINE_IN, | ||
395 | .gpio = NULL, | ||
396 | }, { | ||
397 | .type = CX231XX_VMUX_SVIDEO, | ||
398 | .vmux = CX231XX_VIN_1_1 | | ||
399 | (CX231XX_VIN_1_2 << 8) | | ||
400 | CX25840_SVIDEO_ON, | ||
401 | .amux = CX231XX_AMUX_LINE_IN, | ||
402 | .gpio = NULL, | ||
403 | } }, | ||
404 | }, | ||
405 | [CX231XX_BOARD_KWORLD_UB430_USB_HYBRID] = { | ||
406 | .name = "Kworld UB430 USB Hybrid", | ||
407 | .tuner_type = TUNER_NXP_TDA18271, | ||
408 | .tuner_addr = 0x60, | ||
409 | .decoder = CX231XX_AVDECODER, | ||
410 | .output_mode = OUT_MODE_VIP11, | ||
411 | .demod_xfer_mode = 0, | ||
412 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
413 | .agc_analog_digital_select_gpio = 0x11, /* According with PV cxPolaris.inf file */ | ||
414 | .tuner_sif_gpio = -1, | ||
415 | .tuner_scl_gpio = -1, | ||
416 | .tuner_sda_gpio = -1, | ||
417 | .gpio_pin_status_mask = 0x4001000, | ||
418 | .tuner_i2c_master = 2, | ||
419 | .demod_i2c_master = 1, | ||
420 | .ir_i2c_master = 2, | ||
421 | .has_dvb = 1, | ||
422 | .demod_addr = 0x10, | ||
423 | .norm = V4L2_STD_PAL_M, | ||
424 | .input = {{ | ||
425 | .type = CX231XX_VMUX_TELEVISION, | ||
426 | .vmux = CX231XX_VIN_3_1, | ||
427 | .amux = CX231XX_AMUX_VIDEO, | ||
428 | .gpio = NULL, | ||
429 | }, { | ||
430 | .type = CX231XX_VMUX_COMPOSITE1, | ||
431 | .vmux = CX231XX_VIN_2_1, | ||
432 | .amux = CX231XX_AMUX_LINE_IN, | ||
433 | .gpio = NULL, | ||
434 | }, { | ||
435 | .type = CX231XX_VMUX_SVIDEO, | ||
436 | .vmux = CX231XX_VIN_1_1 | | ||
437 | (CX231XX_VIN_1_2 << 8) | | ||
438 | CX25840_SVIDEO_ON, | ||
439 | .amux = CX231XX_AMUX_LINE_IN, | ||
440 | .gpio = NULL, | ||
441 | } }, | ||
442 | }, | ||
443 | [CX231XX_BOARD_PV_PLAYTV_USB_HYBRID] = { | ||
444 | .name = "Pixelview PlayTV USB Hybrid", | ||
445 | .tuner_type = TUNER_NXP_TDA18271, | ||
446 | .tuner_addr = 0x60, | ||
447 | .decoder = CX231XX_AVDECODER, | ||
448 | .output_mode = OUT_MODE_VIP11, | ||
449 | .demod_xfer_mode = 0, | ||
450 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
451 | .agc_analog_digital_select_gpio = 0x00, /* According with PV cxPolaris.inf file */ | ||
452 | .tuner_sif_gpio = -1, | ||
453 | .tuner_scl_gpio = -1, | ||
454 | .tuner_sda_gpio = -1, | ||
455 | .gpio_pin_status_mask = 0x4001000, | ||
456 | .tuner_i2c_master = 2, | ||
457 | .demod_i2c_master = 1, | ||
458 | .ir_i2c_master = 2, | ||
459 | .rc_map_name = RC_MAP_PIXELVIEW_002T, | ||
460 | .has_dvb = 1, | ||
461 | .demod_addr = 0x10, | ||
462 | .norm = V4L2_STD_PAL_M, | ||
463 | .input = {{ | ||
464 | .type = CX231XX_VMUX_TELEVISION, | ||
465 | .vmux = CX231XX_VIN_3_1, | ||
466 | .amux = CX231XX_AMUX_VIDEO, | ||
467 | .gpio = NULL, | ||
468 | }, { | ||
469 | .type = CX231XX_VMUX_COMPOSITE1, | ||
470 | .vmux = CX231XX_VIN_2_1, | ||
471 | .amux = CX231XX_AMUX_LINE_IN, | ||
472 | .gpio = NULL, | ||
473 | }, { | ||
474 | .type = CX231XX_VMUX_SVIDEO, | ||
475 | .vmux = CX231XX_VIN_1_1 | | ||
476 | (CX231XX_VIN_1_2 << 8) | | ||
477 | CX25840_SVIDEO_ON, | ||
478 | .amux = CX231XX_AMUX_LINE_IN, | ||
479 | .gpio = NULL, | ||
480 | } }, | ||
481 | }, | ||
482 | [CX231XX_BOARD_PV_XCAPTURE_USB] = { | ||
483 | .name = "Pixelview Xcapture USB", | ||
484 | .tuner_type = TUNER_ABSENT, | ||
485 | .decoder = CX231XX_AVDECODER, | ||
486 | .output_mode = OUT_MODE_VIP11, | ||
487 | .demod_xfer_mode = 0, | ||
488 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
489 | .agc_analog_digital_select_gpio = 0x0c, | ||
490 | .gpio_pin_status_mask = 0x4001000, | ||
491 | .norm = V4L2_STD_NTSC, | ||
492 | .no_alt_vanc = 1, | ||
493 | .external_av = 1, | ||
494 | .dont_use_port_3 = 1, | ||
495 | |||
496 | .input = {{ | ||
497 | .type = CX231XX_VMUX_COMPOSITE1, | ||
498 | .vmux = CX231XX_VIN_2_1, | ||
499 | .amux = CX231XX_AMUX_LINE_IN, | ||
500 | .gpio = NULL, | ||
501 | }, { | ||
502 | .type = CX231XX_VMUX_SVIDEO, | ||
503 | .vmux = CX231XX_VIN_1_1 | | ||
504 | (CX231XX_VIN_1_2 << 8) | | ||
505 | CX25840_SVIDEO_ON, | ||
506 | .amux = CX231XX_AMUX_LINE_IN, | ||
507 | .gpio = NULL, | ||
508 | } | ||
509 | }, | ||
510 | }, | ||
511 | |||
512 | [CX231XX_BOARD_ICONBIT_U100] = { | ||
513 | .name = "Iconbit Analog Stick U100 FM", | ||
514 | .tuner_type = TUNER_ABSENT, | ||
515 | .decoder = CX231XX_AVDECODER, | ||
516 | .output_mode = OUT_MODE_VIP11, | ||
517 | .demod_xfer_mode = 0, | ||
518 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
519 | .agc_analog_digital_select_gpio = 0x1C, | ||
520 | .gpio_pin_status_mask = 0x4001000, | ||
521 | |||
522 | .input = {{ | ||
523 | .type = CX231XX_VMUX_COMPOSITE1, | ||
524 | .vmux = CX231XX_VIN_2_1, | ||
525 | .amux = CX231XX_AMUX_LINE_IN, | ||
526 | .gpio = NULL, | ||
527 | }, { | ||
528 | .type = CX231XX_VMUX_SVIDEO, | ||
529 | .vmux = CX231XX_VIN_1_1 | | ||
530 | (CX231XX_VIN_1_2 << 8) | | ||
531 | CX25840_SVIDEO_ON, | ||
532 | .amux = CX231XX_AMUX_LINE_IN, | ||
533 | .gpio = NULL, | ||
534 | } }, | ||
535 | }, | ||
536 | [CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL] = { | ||
537 | .name = "Hauppauge WinTV USB2 FM (PAL)", | ||
538 | .tuner_type = TUNER_NXP_TDA18271, | ||
539 | .tuner_addr = 0x60, | ||
540 | .tuner_gpio = RDE250_XCV_TUNER, | ||
541 | .tuner_sif_gpio = 0x05, | ||
542 | .tuner_scl_gpio = 0x1a, | ||
543 | .tuner_sda_gpio = 0x1b, | ||
544 | .decoder = CX231XX_AVDECODER, | ||
545 | .output_mode = OUT_MODE_VIP11, | ||
546 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
547 | .agc_analog_digital_select_gpio = 0x0c, | ||
548 | .gpio_pin_status_mask = 0x4001000, | ||
549 | .tuner_i2c_master = 1, | ||
550 | .norm = V4L2_STD_PAL, | ||
551 | |||
552 | .input = {{ | ||
553 | .type = CX231XX_VMUX_TELEVISION, | ||
554 | .vmux = CX231XX_VIN_3_1, | ||
555 | .amux = CX231XX_AMUX_VIDEO, | ||
556 | .gpio = NULL, | ||
557 | }, { | ||
558 | .type = CX231XX_VMUX_COMPOSITE1, | ||
559 | .vmux = CX231XX_VIN_2_1, | ||
560 | .amux = CX231XX_AMUX_LINE_IN, | ||
561 | .gpio = NULL, | ||
562 | }, { | ||
563 | .type = CX231XX_VMUX_SVIDEO, | ||
564 | .vmux = CX231XX_VIN_1_1 | | ||
565 | (CX231XX_VIN_1_2 << 8) | | ||
566 | CX25840_SVIDEO_ON, | ||
567 | .amux = CX231XX_AMUX_LINE_IN, | ||
568 | .gpio = NULL, | ||
569 | } }, | ||
570 | }, | ||
571 | [CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC] = { | ||
572 | .name = "Hauppauge WinTV USB2 FM (NTSC)", | ||
573 | .tuner_type = TUNER_NXP_TDA18271, | ||
574 | .tuner_addr = 0x60, | ||
575 | .tuner_gpio = RDE250_XCV_TUNER, | ||
576 | .tuner_sif_gpio = 0x05, | ||
577 | .tuner_scl_gpio = 0x1a, | ||
578 | .tuner_sda_gpio = 0x1b, | ||
579 | .decoder = CX231XX_AVDECODER, | ||
580 | .output_mode = OUT_MODE_VIP11, | ||
581 | .ctl_pin_status_mask = 0xFFFFFFC4, | ||
582 | .agc_analog_digital_select_gpio = 0x0c, | ||
583 | .gpio_pin_status_mask = 0x4001000, | ||
584 | .tuner_i2c_master = 1, | ||
585 | .norm = V4L2_STD_NTSC, | ||
586 | |||
587 | .input = {{ | ||
588 | .type = CX231XX_VMUX_TELEVISION, | ||
589 | .vmux = CX231XX_VIN_3_1, | ||
590 | .amux = CX231XX_AMUX_VIDEO, | ||
591 | .gpio = NULL, | ||
592 | }, { | ||
593 | .type = CX231XX_VMUX_COMPOSITE1, | ||
594 | .vmux = CX231XX_VIN_2_1, | ||
595 | .amux = CX231XX_AMUX_LINE_IN, | ||
596 | .gpio = NULL, | ||
597 | }, { | ||
598 | .type = CX231XX_VMUX_SVIDEO, | ||
599 | .vmux = CX231XX_VIN_1_1 | | ||
600 | (CX231XX_VIN_1_2 << 8) | | ||
601 | CX25840_SVIDEO_ON, | ||
602 | .amux = CX231XX_AMUX_LINE_IN, | ||
603 | .gpio = NULL, | ||
604 | } }, | ||
605 | }, | ||
606 | }; | ||
607 | const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards); | ||
608 | |||
609 | /* table of devices that work with this driver */ | ||
610 | struct usb_device_id cx231xx_id_table[] = { | ||
611 | {USB_DEVICE(0x0572, 0x5A3C), | ||
612 | .driver_info = CX231XX_BOARD_UNKNOWN}, | ||
613 | {USB_DEVICE(0x0572, 0x58A2), | ||
614 | .driver_info = CX231XX_BOARD_CNXT_CARRAERA}, | ||
615 | {USB_DEVICE(0x0572, 0x58A1), | ||
616 | .driver_info = CX231XX_BOARD_CNXT_SHELBY}, | ||
617 | {USB_DEVICE(0x0572, 0x58A4), | ||
618 | .driver_info = CX231XX_BOARD_CNXT_RDE_253S}, | ||
619 | {USB_DEVICE(0x0572, 0x58A5), | ||
620 | .driver_info = CX231XX_BOARD_CNXT_RDU_253S}, | ||
621 | {USB_DEVICE(0x0572, 0x58A6), | ||
622 | .driver_info = CX231XX_BOARD_CNXT_VIDEO_GRABBER}, | ||
623 | {USB_DEVICE(0x0572, 0x589E), | ||
624 | .driver_info = CX231XX_BOARD_CNXT_RDE_250}, | ||
625 | {USB_DEVICE(0x0572, 0x58A0), | ||
626 | .driver_info = CX231XX_BOARD_CNXT_RDU_250}, | ||
627 | {USB_DEVICE(0x2040, 0xb110), | ||
628 | .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL}, | ||
629 | {USB_DEVICE(0x2040, 0xb111), | ||
630 | .driver_info = CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC}, | ||
631 | {USB_DEVICE(0x2040, 0xb120), | ||
632 | .driver_info = CX231XX_BOARD_HAUPPAUGE_EXETER}, | ||
633 | {USB_DEVICE(0x2040, 0xb140), | ||
634 | .driver_info = CX231XX_BOARD_HAUPPAUGE_EXETER}, | ||
635 | {USB_DEVICE(0x2040, 0xc200), | ||
636 | .driver_info = CX231XX_BOARD_HAUPPAUGE_USBLIVE2}, | ||
637 | {USB_DEVICE_VER(USB_VID_PIXELVIEW, USB_PID_PIXELVIEW_SBTVD, 0x4000, 0x4001), | ||
638 | .driver_info = CX231XX_BOARD_PV_PLAYTV_USB_HYBRID}, | ||
639 | {USB_DEVICE(USB_VID_PIXELVIEW, 0x5014), | ||
640 | .driver_info = CX231XX_BOARD_PV_XCAPTURE_USB}, | ||
641 | {USB_DEVICE(0x1b80, 0xe424), | ||
642 | .driver_info = CX231XX_BOARD_KWORLD_UB430_USB_HYBRID}, | ||
643 | {USB_DEVICE(0x1f4d, 0x0237), | ||
644 | .driver_info = CX231XX_BOARD_ICONBIT_U100}, | ||
645 | {}, | ||
646 | }; | ||
647 | |||
648 | MODULE_DEVICE_TABLE(usb, cx231xx_id_table); | ||
649 | |||
650 | /* cx231xx_tuner_callback | ||
651 | * will be used to reset XC5000 tuner using GPIO pin | ||
652 | */ | ||
653 | |||
654 | int cx231xx_tuner_callback(void *ptr, int component, int command, int arg) | ||
655 | { | ||
656 | int rc = 0; | ||
657 | struct cx231xx *dev = ptr; | ||
658 | |||
659 | if (dev->tuner_type == TUNER_XC5000) { | ||
660 | if (command == XC5000_TUNER_RESET) { | ||
661 | cx231xx_info | ||
662 | ("Tuner CB: RESET: cmd %d : tuner type %d \n", | ||
663 | command, dev->tuner_type); | ||
664 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, | ||
665 | 1); | ||
666 | msleep(10); | ||
667 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, | ||
668 | 0); | ||
669 | msleep(330); | ||
670 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, | ||
671 | 1); | ||
672 | msleep(10); | ||
673 | } | ||
674 | } else if (dev->tuner_type == TUNER_NXP_TDA18271) { | ||
675 | switch (command) { | ||
676 | case TDA18271_CALLBACK_CMD_AGC_ENABLE: | ||
677 | if (dev->model == CX231XX_BOARD_PV_PLAYTV_USB_HYBRID) | ||
678 | rc = cx231xx_set_agc_analog_digital_mux_select(dev, arg); | ||
679 | break; | ||
680 | default: | ||
681 | rc = -EINVAL; | ||
682 | break; | ||
683 | } | ||
684 | } | ||
685 | return rc; | ||
686 | } | ||
687 | EXPORT_SYMBOL_GPL(cx231xx_tuner_callback); | ||
688 | |||
689 | void cx231xx_reset_out(struct cx231xx *dev) | ||
690 | { | ||
691 | cx231xx_set_gpio_value(dev, CX23417_RESET, 1); | ||
692 | msleep(200); | ||
693 | cx231xx_set_gpio_value(dev, CX23417_RESET, 0); | ||
694 | msleep(200); | ||
695 | cx231xx_set_gpio_value(dev, CX23417_RESET, 1); | ||
696 | } | ||
697 | void cx231xx_enable_OSC(struct cx231xx *dev) | ||
698 | { | ||
699 | cx231xx_set_gpio_value(dev, CX23417_OSC_EN, 1); | ||
700 | } | ||
701 | void cx231xx_sleep_s5h1432(struct cx231xx *dev) | ||
702 | { | ||
703 | cx231xx_set_gpio_value(dev, SLEEP_S5H1432, 0); | ||
704 | } | ||
705 | |||
706 | static inline void cx231xx_set_model(struct cx231xx *dev) | ||
707 | { | ||
708 | memcpy(&dev->board, &cx231xx_boards[dev->model], sizeof(dev->board)); | ||
709 | } | ||
710 | |||
711 | /* Since cx231xx_pre_card_setup() requires a proper dev->model, | ||
712 | * this won't work for boards with generic PCI IDs | ||
713 | */ | ||
714 | void cx231xx_pre_card_setup(struct cx231xx *dev) | ||
715 | { | ||
716 | |||
717 | cx231xx_set_model(dev); | ||
718 | |||
719 | cx231xx_info("Identified as %s (card=%d)\n", | ||
720 | dev->board.name, dev->model); | ||
721 | |||
722 | /* set the direction for GPIO pins */ | ||
723 | if (dev->board.tuner_gpio) { | ||
724 | cx231xx_set_gpio_direction(dev, dev->board.tuner_gpio->bit, 1); | ||
725 | cx231xx_set_gpio_value(dev, dev->board.tuner_gpio->bit, 1); | ||
726 | } | ||
727 | if (dev->board.tuner_sif_gpio >= 0) | ||
728 | cx231xx_set_gpio_direction(dev, dev->board.tuner_sif_gpio, 1); | ||
729 | |||
730 | /* request some modules if any required */ | ||
731 | |||
732 | /* set the mode to Analog mode initially */ | ||
733 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | ||
734 | |||
735 | /* Unlock device */ | ||
736 | /* cx231xx_set_mode(dev, CX231XX_SUSPEND); */ | ||
737 | |||
738 | } | ||
739 | |||
740 | static void cx231xx_config_tuner(struct cx231xx *dev) | ||
741 | { | ||
742 | struct tuner_setup tun_setup; | ||
743 | struct v4l2_frequency f; | ||
744 | |||
745 | if (dev->tuner_type == TUNER_ABSENT) | ||
746 | return; | ||
747 | |||
748 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; | ||
749 | tun_setup.type = dev->tuner_type; | ||
750 | tun_setup.addr = dev->tuner_addr; | ||
751 | tun_setup.tuner_callback = cx231xx_tuner_callback; | ||
752 | |||
753 | tuner_call(dev, tuner, s_type_addr, &tun_setup); | ||
754 | |||
755 | #if 0 | ||
756 | if (tun_setup.type == TUNER_XC5000) { | ||
757 | static struct xc2028_ctrl ctrl = { | ||
758 | .fname = XC5000_DEFAULT_FIRMWARE, | ||
759 | .max_len = 64, | ||
760 | .demod = 0; | ||
761 | }; | ||
762 | struct v4l2_priv_tun_config cfg = { | ||
763 | .tuner = dev->tuner_type, | ||
764 | .priv = &ctrl, | ||
765 | }; | ||
766 | tuner_call(dev, tuner, s_config, &cfg); | ||
767 | } | ||
768 | #endif | ||
769 | /* configure tuner */ | ||
770 | f.tuner = 0; | ||
771 | f.type = V4L2_TUNER_ANALOG_TV; | ||
772 | f.frequency = 9076; /* just a magic number */ | ||
773 | dev->ctl_freq = f.frequency; | ||
774 | call_all(dev, tuner, s_frequency, &f); | ||
775 | |||
776 | } | ||
777 | |||
778 | void cx231xx_card_setup(struct cx231xx *dev) | ||
779 | { | ||
780 | |||
781 | cx231xx_set_model(dev); | ||
782 | |||
783 | dev->tuner_type = cx231xx_boards[dev->model].tuner_type; | ||
784 | if (cx231xx_boards[dev->model].tuner_addr) | ||
785 | dev->tuner_addr = cx231xx_boards[dev->model].tuner_addr; | ||
786 | |||
787 | /* request some modules */ | ||
788 | if (dev->board.decoder == CX231XX_AVDECODER) { | ||
789 | dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, | ||
790 | &dev->i2c_bus[0].i2c_adap, | ||
791 | "cx25840", 0x88 >> 1, NULL); | ||
792 | if (dev->sd_cx25840 == NULL) | ||
793 | cx231xx_info("cx25840 subdev registration failure\n"); | ||
794 | cx25840_call(dev, core, load_fw); | ||
795 | |||
796 | } | ||
797 | |||
798 | /* Initialize the tuner */ | ||
799 | if (dev->board.tuner_type != TUNER_ABSENT) { | ||
800 | dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, | ||
801 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | ||
802 | "tuner", | ||
803 | dev->tuner_addr, NULL); | ||
804 | if (dev->sd_tuner == NULL) | ||
805 | cx231xx_info("tuner subdev registration failure\n"); | ||
806 | else | ||
807 | cx231xx_config_tuner(dev); | ||
808 | } | ||
809 | } | ||
810 | |||
811 | /* | ||
812 | * cx231xx_config() | ||
813 | * inits registers with sane defaults | ||
814 | */ | ||
815 | int cx231xx_config(struct cx231xx *dev) | ||
816 | { | ||
817 | /* TBD need to add cx231xx specific code */ | ||
818 | dev->mute = 1; /* maybe not the right place... */ | ||
819 | dev->volume = 0x1f; | ||
820 | |||
821 | return 0; | ||
822 | } | ||
823 | |||
824 | /* | ||
825 | * cx231xx_config_i2c() | ||
826 | * configure i2c attached devices | ||
827 | */ | ||
828 | void cx231xx_config_i2c(struct cx231xx *dev) | ||
829 | { | ||
830 | /* u32 input = INPUT(dev->video_input)->vmux; */ | ||
831 | |||
832 | call_all(dev, video, s_stream, 1); | ||
833 | } | ||
834 | |||
835 | /* | ||
836 | * cx231xx_realease_resources() | ||
837 | * unregisters the v4l2,i2c and usb devices | ||
838 | * called when the device gets disconected or at module unload | ||
839 | */ | ||
840 | void cx231xx_release_resources(struct cx231xx *dev) | ||
841 | { | ||
842 | cx231xx_release_analog_resources(dev); | ||
843 | |||
844 | cx231xx_remove_from_devlist(dev); | ||
845 | |||
846 | cx231xx_ir_exit(dev); | ||
847 | |||
848 | /* Release I2C buses */ | ||
849 | cx231xx_dev_uninit(dev); | ||
850 | |||
851 | /* delete v4l2 device */ | ||
852 | v4l2_device_unregister(&dev->v4l2_dev); | ||
853 | |||
854 | usb_put_dev(dev->udev); | ||
855 | |||
856 | /* Mark device as unused */ | ||
857 | clear_bit(dev->devno, &cx231xx_devused); | ||
858 | |||
859 | kfree(dev->video_mode.alt_max_pkt_size); | ||
860 | kfree(dev->vbi_mode.alt_max_pkt_size); | ||
861 | kfree(dev->sliced_cc_mode.alt_max_pkt_size); | ||
862 | kfree(dev->ts1_mode.alt_max_pkt_size); | ||
863 | kfree(dev); | ||
864 | } | ||
865 | |||
866 | /* | ||
867 | * cx231xx_init_dev() | ||
868 | * allocates and inits the device structs, registers i2c bus and v4l device | ||
869 | */ | ||
870 | static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, | ||
871 | int minor) | ||
872 | { | ||
873 | int retval = -ENOMEM; | ||
874 | int errCode; | ||
875 | unsigned int maxh, maxw; | ||
876 | |||
877 | dev->udev = udev; | ||
878 | mutex_init(&dev->lock); | ||
879 | mutex_init(&dev->ctrl_urb_lock); | ||
880 | mutex_init(&dev->gpio_i2c_lock); | ||
881 | mutex_init(&dev->i2c_lock); | ||
882 | |||
883 | spin_lock_init(&dev->video_mode.slock); | ||
884 | spin_lock_init(&dev->vbi_mode.slock); | ||
885 | spin_lock_init(&dev->sliced_cc_mode.slock); | ||
886 | |||
887 | init_waitqueue_head(&dev->open); | ||
888 | init_waitqueue_head(&dev->wait_frame); | ||
889 | init_waitqueue_head(&dev->wait_stream); | ||
890 | |||
891 | dev->cx231xx_read_ctrl_reg = cx231xx_read_ctrl_reg; | ||
892 | dev->cx231xx_write_ctrl_reg = cx231xx_write_ctrl_reg; | ||
893 | dev->cx231xx_send_usb_command = cx231xx_send_usb_command; | ||
894 | dev->cx231xx_gpio_i2c_read = cx231xx_gpio_i2c_read; | ||
895 | dev->cx231xx_gpio_i2c_write = cx231xx_gpio_i2c_write; | ||
896 | |||
897 | /* Query cx231xx to find what pcb config it is related to */ | ||
898 | initialize_cx231xx(dev); | ||
899 | |||
900 | /*To workaround error number=-71 on EP0 for VideoGrabber, | ||
901 | need set alt here.*/ | ||
902 | if (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER || | ||
903 | dev->model == CX231XX_BOARD_HAUPPAUGE_USBLIVE2) { | ||
904 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 3); | ||
905 | cx231xx_set_alt_setting(dev, INDEX_VANC, 1); | ||
906 | } | ||
907 | /* Cx231xx pre card setup */ | ||
908 | cx231xx_pre_card_setup(dev); | ||
909 | |||
910 | errCode = cx231xx_config(dev); | ||
911 | if (errCode) { | ||
912 | cx231xx_errdev("error configuring device\n"); | ||
913 | return -ENOMEM; | ||
914 | } | ||
915 | |||
916 | /* set default norm */ | ||
917 | dev->norm = dev->board.norm; | ||
918 | |||
919 | /* register i2c bus */ | ||
920 | errCode = cx231xx_dev_init(dev); | ||
921 | if (errCode < 0) { | ||
922 | cx231xx_dev_uninit(dev); | ||
923 | cx231xx_errdev("%s: cx231xx_i2c_register - errCode [%d]!\n", | ||
924 | __func__, errCode); | ||
925 | return errCode; | ||
926 | } | ||
927 | |||
928 | /* Do board specific init */ | ||
929 | cx231xx_card_setup(dev); | ||
930 | |||
931 | /* configure the device */ | ||
932 | cx231xx_config_i2c(dev); | ||
933 | |||
934 | maxw = norm_maxw(dev); | ||
935 | maxh = norm_maxh(dev); | ||
936 | |||
937 | /* set default image size */ | ||
938 | dev->width = maxw; | ||
939 | dev->height = maxh; | ||
940 | dev->interlaced = 0; | ||
941 | dev->video_input = 0; | ||
942 | |||
943 | errCode = cx231xx_config(dev); | ||
944 | if (errCode < 0) { | ||
945 | cx231xx_errdev("%s: cx231xx_config - errCode [%d]!\n", | ||
946 | __func__, errCode); | ||
947 | return errCode; | ||
948 | } | ||
949 | |||
950 | /* init video dma queues */ | ||
951 | INIT_LIST_HEAD(&dev->video_mode.vidq.active); | ||
952 | INIT_LIST_HEAD(&dev->video_mode.vidq.queued); | ||
953 | |||
954 | /* init vbi dma queues */ | ||
955 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.active); | ||
956 | INIT_LIST_HEAD(&dev->vbi_mode.vidq.queued); | ||
957 | |||
958 | /* Reset other chips required if they are tied up with GPIO pins */ | ||
959 | cx231xx_add_into_devlist(dev); | ||
960 | |||
961 | if (dev->board.has_417) { | ||
962 | printk(KERN_INFO "attach 417 %d\n", dev->model); | ||
963 | if (cx231xx_417_register(dev) < 0) { | ||
964 | printk(KERN_ERR | ||
965 | "%s() Failed to register 417 on VID_B\n", | ||
966 | __func__); | ||
967 | } | ||
968 | } | ||
969 | |||
970 | retval = cx231xx_register_analog_devices(dev); | ||
971 | if (retval < 0) { | ||
972 | cx231xx_release_resources(dev); | ||
973 | return retval; | ||
974 | } | ||
975 | |||
976 | cx231xx_ir_init(dev); | ||
977 | |||
978 | cx231xx_init_extension(dev); | ||
979 | |||
980 | return 0; | ||
981 | } | ||
982 | |||
983 | #if defined(CONFIG_MODULES) && defined(MODULE) | ||
984 | static void request_module_async(struct work_struct *work) | ||
985 | { | ||
986 | struct cx231xx *dev = container_of(work, | ||
987 | struct cx231xx, request_module_wk); | ||
988 | |||
989 | if (dev->has_alsa_audio) | ||
990 | request_module("cx231xx-alsa"); | ||
991 | |||
992 | if (dev->board.has_dvb) | ||
993 | request_module("cx231xx-dvb"); | ||
994 | |||
995 | } | ||
996 | |||
997 | static void request_modules(struct cx231xx *dev) | ||
998 | { | ||
999 | INIT_WORK(&dev->request_module_wk, request_module_async); | ||
1000 | schedule_work(&dev->request_module_wk); | ||
1001 | } | ||
1002 | |||
1003 | static void flush_request_modules(struct cx231xx *dev) | ||
1004 | { | ||
1005 | flush_work_sync(&dev->request_module_wk); | ||
1006 | } | ||
1007 | #else | ||
1008 | #define request_modules(dev) | ||
1009 | #define flush_request_modules(dev) | ||
1010 | #endif /* CONFIG_MODULES */ | ||
1011 | |||
1012 | /* | ||
1013 | * cx231xx_usb_probe() | ||
1014 | * checks for supported devices | ||
1015 | */ | ||
1016 | static int cx231xx_usb_probe(struct usb_interface *interface, | ||
1017 | const struct usb_device_id *id) | ||
1018 | { | ||
1019 | struct usb_device *udev; | ||
1020 | struct usb_interface *uif; | ||
1021 | struct cx231xx *dev = NULL; | ||
1022 | int retval = -ENODEV; | ||
1023 | int nr = 0, ifnum; | ||
1024 | int i, isoc_pipe = 0; | ||
1025 | char *speed; | ||
1026 | struct usb_interface_assoc_descriptor *assoc_desc; | ||
1027 | |||
1028 | udev = usb_get_dev(interface_to_usbdev(interface)); | ||
1029 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; | ||
1030 | |||
1031 | /* | ||
1032 | * Interface number 0 - IR interface (handled by mceusb driver) | ||
1033 | * Interface number 1 - AV interface (handled by this driver) | ||
1034 | */ | ||
1035 | if (ifnum != 1) | ||
1036 | return -ENODEV; | ||
1037 | |||
1038 | /* Check to see next free device and mark as used */ | ||
1039 | do { | ||
1040 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); | ||
1041 | if (nr >= CX231XX_MAXBOARDS) { | ||
1042 | /* No free device slots */ | ||
1043 | cx231xx_err(DRIVER_NAME ": Supports only %i devices.\n", | ||
1044 | CX231XX_MAXBOARDS); | ||
1045 | return -ENOMEM; | ||
1046 | } | ||
1047 | } while (test_and_set_bit(nr, &cx231xx_devused)); | ||
1048 | |||
1049 | /* allocate memory for our device state and initialize it */ | ||
1050 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
1051 | if (dev == NULL) { | ||
1052 | cx231xx_err(DRIVER_NAME ": out of memory!\n"); | ||
1053 | clear_bit(nr, &cx231xx_devused); | ||
1054 | return -ENOMEM; | ||
1055 | } | ||
1056 | |||
1057 | snprintf(dev->name, 29, "cx231xx #%d", nr); | ||
1058 | dev->devno = nr; | ||
1059 | dev->model = id->driver_info; | ||
1060 | dev->video_mode.alt = -1; | ||
1061 | |||
1062 | dev->interface_count++; | ||
1063 | /* reset gpio dir and value */ | ||
1064 | dev->gpio_dir = 0; | ||
1065 | dev->gpio_val = 0; | ||
1066 | dev->xc_fw_load_done = 0; | ||
1067 | dev->has_alsa_audio = 1; | ||
1068 | dev->power_mode = -1; | ||
1069 | atomic_set(&dev->devlist_count, 0); | ||
1070 | |||
1071 | /* 0 - vbi ; 1 -sliced cc mode */ | ||
1072 | dev->vbi_or_sliced_cc_mode = 0; | ||
1073 | |||
1074 | /* get maximum no.of IAD interfaces */ | ||
1075 | assoc_desc = udev->actconfig->intf_assoc[0]; | ||
1076 | dev->max_iad_interface_count = assoc_desc->bInterfaceCount; | ||
1077 | |||
1078 | /* init CIR module TBD */ | ||
1079 | |||
1080 | /*mode_tv: digital=1 or analog=0*/ | ||
1081 | dev->mode_tv = 0; | ||
1082 | |||
1083 | dev->USE_ISO = transfer_mode; | ||
1084 | |||
1085 | switch (udev->speed) { | ||
1086 | case USB_SPEED_LOW: | ||
1087 | speed = "1.5"; | ||
1088 | break; | ||
1089 | case USB_SPEED_UNKNOWN: | ||
1090 | case USB_SPEED_FULL: | ||
1091 | speed = "12"; | ||
1092 | break; | ||
1093 | case USB_SPEED_HIGH: | ||
1094 | speed = "480"; | ||
1095 | break; | ||
1096 | default: | ||
1097 | speed = "unknown"; | ||
1098 | } | ||
1099 | |||
1100 | cx231xx_info("New device %s %s @ %s Mbps " | ||
1101 | "(%04x:%04x) with %d interfaces\n", | ||
1102 | udev->manufacturer ? udev->manufacturer : "", | ||
1103 | udev->product ? udev->product : "", | ||
1104 | speed, | ||
1105 | le16_to_cpu(udev->descriptor.idVendor), | ||
1106 | le16_to_cpu(udev->descriptor.idProduct), | ||
1107 | dev->max_iad_interface_count); | ||
1108 | |||
1109 | /* increment interface count */ | ||
1110 | dev->interface_count++; | ||
1111 | |||
1112 | /* get device number */ | ||
1113 | nr = dev->devno; | ||
1114 | |||
1115 | assoc_desc = udev->actconfig->intf_assoc[0]; | ||
1116 | if (assoc_desc->bFirstInterface != ifnum) { | ||
1117 | cx231xx_err(DRIVER_NAME ": Not found " | ||
1118 | "matching IAD interface\n"); | ||
1119 | clear_bit(dev->devno, &cx231xx_devused); | ||
1120 | kfree(dev); | ||
1121 | dev = NULL; | ||
1122 | return -ENODEV; | ||
1123 | } | ||
1124 | |||
1125 | cx231xx_info("registering interface %d\n", ifnum); | ||
1126 | |||
1127 | /* save our data pointer in this interface device */ | ||
1128 | usb_set_intfdata(interface, dev); | ||
1129 | |||
1130 | /* | ||
1131 | * AV device initialization - only done at the last interface | ||
1132 | */ | ||
1133 | |||
1134 | /* Create v4l2 device */ | ||
1135 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); | ||
1136 | if (retval) { | ||
1137 | cx231xx_errdev("v4l2_device_register failed\n"); | ||
1138 | clear_bit(dev->devno, &cx231xx_devused); | ||
1139 | kfree(dev); | ||
1140 | dev = NULL; | ||
1141 | return -EIO; | ||
1142 | } | ||
1143 | /* allocate device struct */ | ||
1144 | retval = cx231xx_init_dev(dev, udev, nr); | ||
1145 | if (retval) { | ||
1146 | clear_bit(dev->devno, &cx231xx_devused); | ||
1147 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1148 | kfree(dev); | ||
1149 | dev = NULL; | ||
1150 | usb_set_intfdata(interface, NULL); | ||
1151 | |||
1152 | return retval; | ||
1153 | } | ||
1154 | |||
1155 | /* compute alternate max packet sizes for video */ | ||
1156 | uif = udev->actconfig->interface[dev->current_pcb_config. | ||
1157 | hs_config_info[0].interface_info.video_index + 1]; | ||
1158 | |||
1159 | dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0]. | ||
1160 | endpoint[isoc_pipe].desc.bEndpointAddress); | ||
1161 | |||
1162 | dev->video_mode.num_alt = uif->num_altsetting; | ||
1163 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
1164 | dev->video_mode.end_point_addr, | ||
1165 | dev->video_mode.num_alt); | ||
1166 | dev->video_mode.alt_max_pkt_size = | ||
1167 | kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL); | ||
1168 | |||
1169 | if (dev->video_mode.alt_max_pkt_size == NULL) { | ||
1170 | cx231xx_errdev("out of memory!\n"); | ||
1171 | clear_bit(dev->devno, &cx231xx_devused); | ||
1172 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1173 | kfree(dev); | ||
1174 | dev = NULL; | ||
1175 | return -ENOMEM; | ||
1176 | } | ||
1177 | |||
1178 | for (i = 0; i < dev->video_mode.num_alt; i++) { | ||
1179 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | ||
1180 | desc.wMaxPacketSize); | ||
1181 | dev->video_mode.alt_max_pkt_size[i] = | ||
1182 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
1183 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
1184 | dev->video_mode.alt_max_pkt_size[i]); | ||
1185 | } | ||
1186 | |||
1187 | /* compute alternate max packet sizes for vbi */ | ||
1188 | uif = udev->actconfig->interface[dev->current_pcb_config. | ||
1189 | hs_config_info[0].interface_info. | ||
1190 | vanc_index + 1]; | ||
1191 | |||
1192 | dev->vbi_mode.end_point_addr = | ||
1193 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | ||
1194 | bEndpointAddress); | ||
1195 | |||
1196 | dev->vbi_mode.num_alt = uif->num_altsetting; | ||
1197 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
1198 | dev->vbi_mode.end_point_addr, | ||
1199 | dev->vbi_mode.num_alt); | ||
1200 | dev->vbi_mode.alt_max_pkt_size = | ||
1201 | kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL); | ||
1202 | |||
1203 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { | ||
1204 | cx231xx_errdev("out of memory!\n"); | ||
1205 | clear_bit(dev->devno, &cx231xx_devused); | ||
1206 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1207 | kfree(dev); | ||
1208 | dev = NULL; | ||
1209 | return -ENOMEM; | ||
1210 | } | ||
1211 | |||
1212 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { | ||
1213 | u16 tmp = | ||
1214 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | ||
1215 | desc.wMaxPacketSize); | ||
1216 | dev->vbi_mode.alt_max_pkt_size[i] = | ||
1217 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
1218 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
1219 | dev->vbi_mode.alt_max_pkt_size[i]); | ||
1220 | } | ||
1221 | |||
1222 | /* compute alternate max packet sizes for sliced CC */ | ||
1223 | uif = udev->actconfig->interface[dev->current_pcb_config. | ||
1224 | hs_config_info[0].interface_info. | ||
1225 | hanc_index + 1]; | ||
1226 | |||
1227 | dev->sliced_cc_mode.end_point_addr = | ||
1228 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | ||
1229 | bEndpointAddress); | ||
1230 | |||
1231 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; | ||
1232 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
1233 | dev->sliced_cc_mode.end_point_addr, | ||
1234 | dev->sliced_cc_mode.num_alt); | ||
1235 | dev->sliced_cc_mode.alt_max_pkt_size = | ||
1236 | kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL); | ||
1237 | |||
1238 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { | ||
1239 | cx231xx_errdev("out of memory!\n"); | ||
1240 | clear_bit(dev->devno, &cx231xx_devused); | ||
1241 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1242 | kfree(dev); | ||
1243 | dev = NULL; | ||
1244 | return -ENOMEM; | ||
1245 | } | ||
1246 | |||
1247 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { | ||
1248 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | ||
1249 | desc.wMaxPacketSize); | ||
1250 | dev->sliced_cc_mode.alt_max_pkt_size[i] = | ||
1251 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
1252 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
1253 | dev->sliced_cc_mode.alt_max_pkt_size[i]); | ||
1254 | } | ||
1255 | |||
1256 | if (dev->current_pcb_config.ts1_source != 0xff) { | ||
1257 | /* compute alternate max packet sizes for TS1 */ | ||
1258 | uif = udev->actconfig->interface[dev->current_pcb_config. | ||
1259 | hs_config_info[0]. | ||
1260 | interface_info. | ||
1261 | ts1_index + 1]; | ||
1262 | |||
1263 | dev->ts1_mode.end_point_addr = | ||
1264 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe]. | ||
1265 | desc.bEndpointAddress); | ||
1266 | |||
1267 | dev->ts1_mode.num_alt = uif->num_altsetting; | ||
1268 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
1269 | dev->ts1_mode.end_point_addr, | ||
1270 | dev->ts1_mode.num_alt); | ||
1271 | dev->ts1_mode.alt_max_pkt_size = | ||
1272 | kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL); | ||
1273 | |||
1274 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { | ||
1275 | cx231xx_errdev("out of memory!\n"); | ||
1276 | clear_bit(dev->devno, &cx231xx_devused); | ||
1277 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1278 | kfree(dev); | ||
1279 | dev = NULL; | ||
1280 | return -ENOMEM; | ||
1281 | } | ||
1282 | |||
1283 | for (i = 0; i < dev->ts1_mode.num_alt; i++) { | ||
1284 | u16 tmp = le16_to_cpu(uif->altsetting[i]. | ||
1285 | endpoint[isoc_pipe].desc. | ||
1286 | wMaxPacketSize); | ||
1287 | dev->ts1_mode.alt_max_pkt_size[i] = | ||
1288 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
1289 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
1290 | dev->ts1_mode.alt_max_pkt_size[i]); | ||
1291 | } | ||
1292 | } | ||
1293 | |||
1294 | if (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) { | ||
1295 | cx231xx_enable_OSC(dev); | ||
1296 | cx231xx_reset_out(dev); | ||
1297 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 3); | ||
1298 | } | ||
1299 | |||
1300 | if (dev->model == CX231XX_BOARD_CNXT_RDE_253S) | ||
1301 | cx231xx_sleep_s5h1432(dev); | ||
1302 | |||
1303 | /* load other modules required */ | ||
1304 | request_modules(dev); | ||
1305 | |||
1306 | return 0; | ||
1307 | } | ||
1308 | |||
1309 | /* | ||
1310 | * cx231xx_usb_disconnect() | ||
1311 | * called when the device gets diconencted | ||
1312 | * video device will be unregistered on v4l2_close in case it is still open | ||
1313 | */ | ||
1314 | static void cx231xx_usb_disconnect(struct usb_interface *interface) | ||
1315 | { | ||
1316 | struct cx231xx *dev; | ||
1317 | |||
1318 | dev = usb_get_intfdata(interface); | ||
1319 | usb_set_intfdata(interface, NULL); | ||
1320 | |||
1321 | if (!dev) | ||
1322 | return; | ||
1323 | |||
1324 | if (!dev->udev) | ||
1325 | return; | ||
1326 | |||
1327 | dev->state |= DEV_DISCONNECTED; | ||
1328 | |||
1329 | flush_request_modules(dev); | ||
1330 | |||
1331 | /* wait until all current v4l2 io is finished then deallocate | ||
1332 | resources */ | ||
1333 | mutex_lock(&dev->lock); | ||
1334 | |||
1335 | wake_up_interruptible_all(&dev->open); | ||
1336 | |||
1337 | if (dev->users) { | ||
1338 | cx231xx_warn | ||
1339 | ("device %s is open! Deregistration and memory " | ||
1340 | "deallocation are deferred on close.\n", | ||
1341 | video_device_node_name(dev->vdev)); | ||
1342 | |||
1343 | /* Even having users, it is safe to remove the RC i2c driver */ | ||
1344 | cx231xx_ir_exit(dev); | ||
1345 | |||
1346 | if (dev->USE_ISO) | ||
1347 | cx231xx_uninit_isoc(dev); | ||
1348 | else | ||
1349 | cx231xx_uninit_bulk(dev); | ||
1350 | wake_up_interruptible(&dev->wait_frame); | ||
1351 | wake_up_interruptible(&dev->wait_stream); | ||
1352 | } else { | ||
1353 | } | ||
1354 | |||
1355 | cx231xx_close_extension(dev); | ||
1356 | |||
1357 | mutex_unlock(&dev->lock); | ||
1358 | |||
1359 | if (!dev->users) | ||
1360 | cx231xx_release_resources(dev); | ||
1361 | } | ||
1362 | |||
1363 | static struct usb_driver cx231xx_usb_driver = { | ||
1364 | .name = "cx231xx", | ||
1365 | .probe = cx231xx_usb_probe, | ||
1366 | .disconnect = cx231xx_usb_disconnect, | ||
1367 | .id_table = cx231xx_id_table, | ||
1368 | }; | ||
1369 | |||
1370 | module_usb_driver(cx231xx_usb_driver); | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-conf-reg.h b/drivers/media/usb/cx231xx/cx231xx-conf-reg.h new file mode 100644 index 000000000000..25593f212abf --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-conf-reg.h | |||
@@ -0,0 +1,495 @@ | |||
1 | /* | ||
2 | cx231xx_conf-reg.h - driver for Conexant Cx23100/101/102 USB | ||
3 | video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _POLARIS_REG_H_ | ||
23 | #define _POLARIS_REG_H_ | ||
24 | |||
25 | #define BOARD_CFG_STAT 0x0 | ||
26 | #define TS_MODE_REG 0x4 | ||
27 | #define TS1_CFG_REG 0x8 | ||
28 | #define TS1_LENGTH_REG 0xc | ||
29 | #define TS2_CFG_REG 0x10 | ||
30 | #define TS2_LENGTH_REG 0x14 | ||
31 | #define EP_MODE_SET 0x18 | ||
32 | #define CIR_PWR_PTN1 0x1c | ||
33 | #define CIR_PWR_PTN2 0x20 | ||
34 | #define CIR_PWR_PTN3 0x24 | ||
35 | #define CIR_PWR_MASK0 0x28 | ||
36 | #define CIR_PWR_MASK1 0x2c | ||
37 | #define CIR_PWR_MASK2 0x30 | ||
38 | #define CIR_GAIN 0x34 | ||
39 | #define CIR_CAR_REG 0x38 | ||
40 | #define CIR_OT_CFG1 0x40 | ||
41 | #define CIR_OT_CFG2 0x44 | ||
42 | #define GBULK_BIT_EN 0x68 | ||
43 | #define PWR_CTL_EN 0x74 | ||
44 | |||
45 | /* Polaris Endpoints capture mask for register EP_MODE_SET */ | ||
46 | #define ENABLE_EP1 0x01 /* Bit[0]=1 */ | ||
47 | #define ENABLE_EP2 0x02 /* Bit[1]=1 */ | ||
48 | #define ENABLE_EP3 0x04 /* Bit[2]=1 */ | ||
49 | #define ENABLE_EP4 0x08 /* Bit[3]=1 */ | ||
50 | #define ENABLE_EP5 0x10 /* Bit[4]=1 */ | ||
51 | #define ENABLE_EP6 0x20 /* Bit[5]=1 */ | ||
52 | |||
53 | /* Bit definition for register PWR_CTL_EN */ | ||
54 | #define PWR_MODE_MASK 0x17f | ||
55 | #define PWR_AV_EN 0x08 /* bit3 */ | ||
56 | #define PWR_ISO_EN 0x40 /* bit6 */ | ||
57 | #define PWR_AV_MODE 0x30 /* bit4,5 */ | ||
58 | #define PWR_TUNER_EN 0x04 /* bit2 */ | ||
59 | #define PWR_DEMOD_EN 0x02 /* bit1 */ | ||
60 | #define I2C_DEMOD_EN 0x01 /* bit0 */ | ||
61 | #define PWR_RESETOUT_EN 0x100 /* bit8 */ | ||
62 | |||
63 | enum AV_MODE{ | ||
64 | POLARIS_AVMODE_DEFAULT = 0, | ||
65 | POLARIS_AVMODE_DIGITAL = 0x10, | ||
66 | POLARIS_AVMODE_ANALOGT_TV = 0x20, | ||
67 | POLARIS_AVMODE_ENXTERNAL_AV = 0x30, | ||
68 | |||
69 | }; | ||
70 | |||
71 | /* Colibri Registers */ | ||
72 | |||
73 | #define SINGLE_ENDED 0x0 | ||
74 | #define LOW_IF 0x4 | ||
75 | #define EU_IF 0x9 | ||
76 | #define US_IF 0xa | ||
77 | |||
78 | #define SUP_BLK_TUNE1 0x00 | ||
79 | #define SUP_BLK_TUNE2 0x01 | ||
80 | #define SUP_BLK_TUNE3 0x02 | ||
81 | #define SUP_BLK_XTAL 0x03 | ||
82 | #define SUP_BLK_PLL1 0x04 | ||
83 | #define SUP_BLK_PLL2 0x05 | ||
84 | #define SUP_BLK_PLL3 0x06 | ||
85 | #define SUP_BLK_REF 0x07 | ||
86 | #define SUP_BLK_PWRDN 0x08 | ||
87 | #define SUP_BLK_TESTPAD 0x09 | ||
88 | #define ADC_COM_INT5_STAB_REF 0x0a | ||
89 | #define ADC_COM_QUANT 0x0b | ||
90 | #define ADC_COM_BIAS1 0x0c | ||
91 | #define ADC_COM_BIAS2 0x0d | ||
92 | #define ADC_COM_BIAS3 0x0e | ||
93 | #define TESTBUS_CTRL 0x12 | ||
94 | |||
95 | #define FLD_PWRDN_TUNING_BIAS 0x10 | ||
96 | #define FLD_PWRDN_ENABLE_PLL 0x08 | ||
97 | #define FLD_PWRDN_PD_BANDGAP 0x04 | ||
98 | #define FLD_PWRDN_PD_BIAS 0x02 | ||
99 | #define FLD_PWRDN_PD_TUNECK 0x01 | ||
100 | |||
101 | |||
102 | #define ADC_STATUS_CH1 0x20 | ||
103 | #define ADC_STATUS_CH2 0x40 | ||
104 | #define ADC_STATUS_CH3 0x60 | ||
105 | |||
106 | #define ADC_STATUS2_CH1 0x21 | ||
107 | #define ADC_STATUS2_CH2 0x41 | ||
108 | #define ADC_STATUS2_CH3 0x61 | ||
109 | |||
110 | #define ADC_CAL_ATEST_CH1 0x22 | ||
111 | #define ADC_CAL_ATEST_CH2 0x42 | ||
112 | #define ADC_CAL_ATEST_CH3 0x62 | ||
113 | |||
114 | #define ADC_PWRDN_CLAMP_CH1 0x23 | ||
115 | #define ADC_PWRDN_CLAMP_CH2 0x43 | ||
116 | #define ADC_PWRDN_CLAMP_CH3 0x63 | ||
117 | |||
118 | #define ADC_CTRL_DAC23_CH1 0x24 | ||
119 | #define ADC_CTRL_DAC23_CH2 0x44 | ||
120 | #define ADC_CTRL_DAC23_CH3 0x64 | ||
121 | |||
122 | #define ADC_CTRL_DAC1_CH1 0x25 | ||
123 | #define ADC_CTRL_DAC1_CH2 0x45 | ||
124 | #define ADC_CTRL_DAC1_CH3 0x65 | ||
125 | |||
126 | #define ADC_DCSERVO_DEM_CH1 0x26 | ||
127 | #define ADC_DCSERVO_DEM_CH2 0x46 | ||
128 | #define ADC_DCSERVO_DEM_CH3 0x66 | ||
129 | |||
130 | #define ADC_FB_FRCRST_CH1 0x27 | ||
131 | #define ADC_FB_FRCRST_CH2 0x47 | ||
132 | #define ADC_FB_FRCRST_CH3 0x67 | ||
133 | |||
134 | #define ADC_INPUT_CH1 0x28 | ||
135 | #define ADC_INPUT_CH2 0x48 | ||
136 | #define ADC_INPUT_CH3 0x68 | ||
137 | #define INPUT_SEL_MASK 0x30 /* [5:4] in_sel */ | ||
138 | |||
139 | #define ADC_NTF_PRECLMP_EN_CH1 0x29 | ||
140 | #define ADC_NTF_PRECLMP_EN_CH2 0x49 | ||
141 | #define ADC_NTF_PRECLMP_EN_CH3 0x69 | ||
142 | |||
143 | #define ADC_QGAIN_RES_TRM_CH1 0x2a | ||
144 | #define ADC_QGAIN_RES_TRM_CH2 0x4a | ||
145 | #define ADC_QGAIN_RES_TRM_CH3 0x6a | ||
146 | |||
147 | #define ADC_SOC_PRECLMP_TERM_CH1 0x2b | ||
148 | #define ADC_SOC_PRECLMP_TERM_CH2 0x4b | ||
149 | #define ADC_SOC_PRECLMP_TERM_CH3 0x6b | ||
150 | |||
151 | #define TESTBUS_CTRL_CH1 0x32 | ||
152 | #define TESTBUS_CTRL_CH2 0x52 | ||
153 | #define TESTBUS_CTRL_CH3 0x72 | ||
154 | |||
155 | /****************************************************************************** | ||
156 | * DIF registers * | ||
157 | ******************************************************************************/ | ||
158 | #define DIRECT_IF_REVB_BASE 0x00300 | ||
159 | |||
160 | /*****************************************************************************/ | ||
161 | #define DIF_PLL_FREQ_WORD (DIRECT_IF_REVB_BASE + 0x00000000) | ||
162 | /*****************************************************************************/ | ||
163 | #define FLD_DIF_PLL_LOCK 0x80000000 | ||
164 | /* Reserved [30:29] */ | ||
165 | #define FLD_DIF_PLL_FREE_RUN 0x10000000 | ||
166 | #define FLD_DIF_PLL_FREQ 0x0fffffff | ||
167 | |||
168 | /*****************************************************************************/ | ||
169 | #define DIF_PLL_CTRL (DIRECT_IF_REVB_BASE + 0x00000004) | ||
170 | /*****************************************************************************/ | ||
171 | #define FLD_DIF_KD_PD 0xff000000 | ||
172 | /* Reserved [23:20] */ | ||
173 | #define FLD_DIF_KDS_PD 0x000f0000 | ||
174 | #define FLD_DIF_KI_PD 0x0000ff00 | ||
175 | /* Reserved [7:4] */ | ||
176 | #define FLD_DIF_KIS_PD 0x0000000f | ||
177 | |||
178 | /*****************************************************************************/ | ||
179 | #define DIF_PLL_CTRL1 (DIRECT_IF_REVB_BASE + 0x00000008) | ||
180 | /*****************************************************************************/ | ||
181 | #define FLD_DIF_KD_FD 0xff000000 | ||
182 | /* Reserved [23:20] */ | ||
183 | #define FLD_DIF_KDS_FD 0x000f0000 | ||
184 | #define FLD_DIF_KI_FD 0x0000ff00 | ||
185 | #define FLD_DIF_SIG_PROP_SZ 0x000000f0 | ||
186 | #define FLD_DIF_KIS_FD 0x0000000f | ||
187 | |||
188 | /*****************************************************************************/ | ||
189 | #define DIF_PLL_CTRL2 (DIRECT_IF_REVB_BASE + 0x0000000c) | ||
190 | /*****************************************************************************/ | ||
191 | #define FLD_DIF_PLL_AGC_REF 0xfff00000 | ||
192 | #define FLD_DIF_PLL_AGC_KI 0x000f0000 | ||
193 | /* Reserved [15] */ | ||
194 | #define FLD_DIF_FREQ_LIMIT 0x00007000 | ||
195 | #define FLD_DIF_K_FD 0x00000f00 | ||
196 | #define FLD_DIF_DOWNSMPL_FD 0x000000ff | ||
197 | |||
198 | /*****************************************************************************/ | ||
199 | #define DIF_PLL_CTRL3 (DIRECT_IF_REVB_BASE + 0x00000010) | ||
200 | /*****************************************************************************/ | ||
201 | /* Reserved [31:16] */ | ||
202 | #define FLD_DIF_PLL_AGC_EN 0x00008000 | ||
203 | /* Reserved [14:12] */ | ||
204 | #define FLD_DIF_PLL_MAN_GAIN 0x00000fff | ||
205 | |||
206 | /*****************************************************************************/ | ||
207 | #define DIF_AGC_IF_REF (DIRECT_IF_REVB_BASE + 0x00000014) | ||
208 | /*****************************************************************************/ | ||
209 | #define FLD_DIF_K_AGC_RF 0xf0000000 | ||
210 | #define FLD_DIF_K_AGC_IF 0x0f000000 | ||
211 | #define FLD_DIF_K_AGC_INT 0x00f00000 | ||
212 | /* Reserved [19:12] */ | ||
213 | #define FLD_DIF_IF_REF 0x00000fff | ||
214 | |||
215 | /*****************************************************************************/ | ||
216 | #define DIF_AGC_CTRL_IF (DIRECT_IF_REVB_BASE + 0x00000018) | ||
217 | /*****************************************************************************/ | ||
218 | #define FLD_DIF_IF_MAX 0xff000000 | ||
219 | #define FLD_DIF_IF_MIN 0x00ff0000 | ||
220 | #define FLD_DIF_IF_AGC 0x0000ffff | ||
221 | |||
222 | /*****************************************************************************/ | ||
223 | #define DIF_AGC_CTRL_INT (DIRECT_IF_REVB_BASE + 0x0000001c) | ||
224 | /*****************************************************************************/ | ||
225 | #define FLD_DIF_INT_MAX 0xff000000 | ||
226 | #define FLD_DIF_INT_MIN 0x00ff0000 | ||
227 | #define FLD_DIF_INT_AGC 0x0000ffff | ||
228 | |||
229 | /*****************************************************************************/ | ||
230 | #define DIF_AGC_CTRL_RF (DIRECT_IF_REVB_BASE + 0x00000020) | ||
231 | /*****************************************************************************/ | ||
232 | #define FLD_DIF_RF_MAX 0xff000000 | ||
233 | #define FLD_DIF_RF_MIN 0x00ff0000 | ||
234 | #define FLD_DIF_RF_AGC 0x0000ffff | ||
235 | |||
236 | /*****************************************************************************/ | ||
237 | #define DIF_AGC_IF_INT_CURRENT (DIRECT_IF_REVB_BASE + 0x00000024) | ||
238 | /*****************************************************************************/ | ||
239 | #define FLD_DIF_IF_AGC_IN 0xffff0000 | ||
240 | #define FLD_DIF_INT_AGC_IN 0x0000ffff | ||
241 | |||
242 | /*****************************************************************************/ | ||
243 | #define DIF_AGC_RF_CURRENT (DIRECT_IF_REVB_BASE + 0x00000028) | ||
244 | /*****************************************************************************/ | ||
245 | /* Reserved [31:16] */ | ||
246 | #define FLD_DIF_RF_AGC_IN 0x0000ffff | ||
247 | |||
248 | /*****************************************************************************/ | ||
249 | #define DIF_VIDEO_AGC_CTRL (DIRECT_IF_REVB_BASE + 0x0000002c) | ||
250 | /*****************************************************************************/ | ||
251 | #define FLD_DIF_AFD 0xc0000000 | ||
252 | #define FLD_DIF_K_VID_AGC 0x30000000 | ||
253 | #define FLD_DIF_LINE_LENGTH 0x0fff0000 | ||
254 | #define FLD_DIF_AGC_GAIN 0x0000ffff | ||
255 | |||
256 | /*****************************************************************************/ | ||
257 | #define DIF_VID_AUD_OVERRIDE (DIRECT_IF_REVB_BASE + 0x00000030) | ||
258 | /*****************************************************************************/ | ||
259 | #define FLD_DIF_AUDIO_AGC_OVERRIDE 0x80000000 | ||
260 | /* Reserved [30:30] */ | ||
261 | #define FLD_DIF_AUDIO_MAN_GAIN 0x3f000000 | ||
262 | /* Reserved [23:17] */ | ||
263 | #define FLD_DIF_VID_AGC_OVERRIDE 0x00010000 | ||
264 | #define FLD_DIF_VID_MAN_GAIN 0x0000ffff | ||
265 | |||
266 | /*****************************************************************************/ | ||
267 | #define DIF_AV_SEP_CTRL (DIRECT_IF_REVB_BASE + 0x00000034) | ||
268 | /*****************************************************************************/ | ||
269 | #define FLD_DIF_LPF_FREQ 0xc0000000 | ||
270 | #define FLD_DIF_AV_PHASE_INC 0x3f000000 | ||
271 | #define FLD_DIF_AUDIO_FREQ 0x00ffffff | ||
272 | |||
273 | /*****************************************************************************/ | ||
274 | #define DIF_COMP_FLT_CTRL (DIRECT_IF_REVB_BASE + 0x00000038) | ||
275 | /*****************************************************************************/ | ||
276 | /* Reserved [31:24] */ | ||
277 | #define FLD_DIF_IIR23_R2 0x00ff0000 | ||
278 | #define FLD_DIF_IIR23_R1 0x0000ff00 | ||
279 | #define FLD_DIF_IIR1_R1 0x000000ff | ||
280 | |||
281 | /*****************************************************************************/ | ||
282 | #define DIF_MISC_CTRL (DIRECT_IF_REVB_BASE + 0x0000003c) | ||
283 | /*****************************************************************************/ | ||
284 | #define FLD_DIF_DIF_BYPASS 0x80000000 | ||
285 | #define FLD_DIF_FM_NYQ_GAIN 0x40000000 | ||
286 | #define FLD_DIF_RF_AGC_ENA 0x20000000 | ||
287 | #define FLD_DIF_INT_AGC_ENA 0x10000000 | ||
288 | #define FLD_DIF_IF_AGC_ENA 0x08000000 | ||
289 | #define FLD_DIF_FORCE_RF_IF_LOCK 0x04000000 | ||
290 | #define FLD_DIF_VIDEO_AGC_ENA 0x02000000 | ||
291 | #define FLD_DIF_RF_AGC_INV 0x01000000 | ||
292 | #define FLD_DIF_INT_AGC_INV 0x00800000 | ||
293 | #define FLD_DIF_IF_AGC_INV 0x00400000 | ||
294 | #define FLD_DIF_SPEC_INV 0x00200000 | ||
295 | #define FLD_DIF_AUD_FULL_BW 0x00100000 | ||
296 | #define FLD_DIF_AUD_SRC_SEL 0x00080000 | ||
297 | /* Reserved [18] */ | ||
298 | #define FLD_DIF_IF_FREQ 0x00030000 | ||
299 | /* Reserved [15:14] */ | ||
300 | #define FLD_DIF_TIP_OFFSET 0x00003f00 | ||
301 | /* Reserved [7:5] */ | ||
302 | #define FLD_DIF_DITHER_ENA 0x00000010 | ||
303 | /* Reserved [3:1] */ | ||
304 | #define FLD_DIF_RF_IF_LOCK 0x00000001 | ||
305 | |||
306 | /*****************************************************************************/ | ||
307 | #define DIF_SRC_PHASE_INC (DIRECT_IF_REVB_BASE + 0x00000040) | ||
308 | /*****************************************************************************/ | ||
309 | /* Reserved [31:29] */ | ||
310 | #define FLD_DIF_PHASE_INC 0x1fffffff | ||
311 | |||
312 | /*****************************************************************************/ | ||
313 | #define DIF_SRC_GAIN_CONTROL (DIRECT_IF_REVB_BASE + 0x00000044) | ||
314 | /*****************************************************************************/ | ||
315 | /* Reserved [31:16] */ | ||
316 | #define FLD_DIF_SRC_KI 0x0000ff00 | ||
317 | #define FLD_DIF_SRC_KD 0x000000ff | ||
318 | |||
319 | /*****************************************************************************/ | ||
320 | #define DIF_BPF_COEFF01 (DIRECT_IF_REVB_BASE + 0x00000048) | ||
321 | /*****************************************************************************/ | ||
322 | /* Reserved [31:19] */ | ||
323 | #define FLD_DIF_BPF_COEFF_0 0x00070000 | ||
324 | /* Reserved [15:4] */ | ||
325 | #define FLD_DIF_BPF_COEFF_1 0x0000000f | ||
326 | |||
327 | /*****************************************************************************/ | ||
328 | #define DIF_BPF_COEFF23 (DIRECT_IF_REVB_BASE + 0x0000004c) | ||
329 | /*****************************************************************************/ | ||
330 | /* Reserved [31:22] */ | ||
331 | #define FLD_DIF_BPF_COEFF_2 0x003f0000 | ||
332 | /* Reserved [15:7] */ | ||
333 | #define FLD_DIF_BPF_COEFF_3 0x0000007f | ||
334 | |||
335 | /*****************************************************************************/ | ||
336 | #define DIF_BPF_COEFF45 (DIRECT_IF_REVB_BASE + 0x00000050) | ||
337 | /*****************************************************************************/ | ||
338 | /* Reserved [31:24] */ | ||
339 | #define FLD_DIF_BPF_COEFF_4 0x00ff0000 | ||
340 | /* Reserved [15:8] */ | ||
341 | #define FLD_DIF_BPF_COEFF_5 0x000000ff | ||
342 | |||
343 | /*****************************************************************************/ | ||
344 | #define DIF_BPF_COEFF67 (DIRECT_IF_REVB_BASE + 0x00000054) | ||
345 | /*****************************************************************************/ | ||
346 | /* Reserved [31:25] */ | ||
347 | #define FLD_DIF_BPF_COEFF_6 0x01ff0000 | ||
348 | /* Reserved [15:9] */ | ||
349 | #define FLD_DIF_BPF_COEFF_7 0x000001ff | ||
350 | |||
351 | /*****************************************************************************/ | ||
352 | #define DIF_BPF_COEFF89 (DIRECT_IF_REVB_BASE + 0x00000058) | ||
353 | /*****************************************************************************/ | ||
354 | /* Reserved [31:26] */ | ||
355 | #define FLD_DIF_BPF_COEFF_8 0x03ff0000 | ||
356 | /* Reserved [15:10] */ | ||
357 | #define FLD_DIF_BPF_COEFF_9 0x000003ff | ||
358 | |||
359 | /*****************************************************************************/ | ||
360 | #define DIF_BPF_COEFF1011 (DIRECT_IF_REVB_BASE + 0x0000005c) | ||
361 | /*****************************************************************************/ | ||
362 | /* Reserved [31:27] */ | ||
363 | #define FLD_DIF_BPF_COEFF_10 0x07ff0000 | ||
364 | /* Reserved [15:11] */ | ||
365 | #define FLD_DIF_BPF_COEFF_11 0x000007ff | ||
366 | |||
367 | /*****************************************************************************/ | ||
368 | #define DIF_BPF_COEFF1213 (DIRECT_IF_REVB_BASE + 0x00000060) | ||
369 | /*****************************************************************************/ | ||
370 | /* Reserved [31:27] */ | ||
371 | #define FLD_DIF_BPF_COEFF_12 0x07ff0000 | ||
372 | /* Reserved [15:12] */ | ||
373 | #define FLD_DIF_BPF_COEFF_13 0x00000fff | ||
374 | |||
375 | /*****************************************************************************/ | ||
376 | #define DIF_BPF_COEFF1415 (DIRECT_IF_REVB_BASE + 0x00000064) | ||
377 | /*****************************************************************************/ | ||
378 | /* Reserved [31:28] */ | ||
379 | #define FLD_DIF_BPF_COEFF_14 0x0fff0000 | ||
380 | /* Reserved [15:12] */ | ||
381 | #define FLD_DIF_BPF_COEFF_15 0x00000fff | ||
382 | |||
383 | /*****************************************************************************/ | ||
384 | #define DIF_BPF_COEFF1617 (DIRECT_IF_REVB_BASE + 0x00000068) | ||
385 | /*****************************************************************************/ | ||
386 | /* Reserved [31:29] */ | ||
387 | #define FLD_DIF_BPF_COEFF_16 0x1fff0000 | ||
388 | /* Reserved [15:13] */ | ||
389 | #define FLD_DIF_BPF_COEFF_17 0x00001fff | ||
390 | |||
391 | /*****************************************************************************/ | ||
392 | #define DIF_BPF_COEFF1819 (DIRECT_IF_REVB_BASE + 0x0000006c) | ||
393 | /*****************************************************************************/ | ||
394 | /* Reserved [31:29] */ | ||
395 | #define FLD_DIF_BPF_COEFF_18 0x1fff0000 | ||
396 | /* Reserved [15:13] */ | ||
397 | #define FLD_DIF_BPF_COEFF_19 0x00001fff | ||
398 | |||
399 | /*****************************************************************************/ | ||
400 | #define DIF_BPF_COEFF2021 (DIRECT_IF_REVB_BASE + 0x00000070) | ||
401 | /*****************************************************************************/ | ||
402 | /* Reserved [31:29] */ | ||
403 | #define FLD_DIF_BPF_COEFF_20 0x1fff0000 | ||
404 | /* Reserved [15:14] */ | ||
405 | #define FLD_DIF_BPF_COEFF_21 0x00003fff | ||
406 | |||
407 | /*****************************************************************************/ | ||
408 | #define DIF_BPF_COEFF2223 (DIRECT_IF_REVB_BASE + 0x00000074) | ||
409 | /*****************************************************************************/ | ||
410 | /* Reserved [31:30] */ | ||
411 | #define FLD_DIF_BPF_COEFF_22 0x3fff0000 | ||
412 | /* Reserved [15:14] */ | ||
413 | #define FLD_DIF_BPF_COEFF_23 0x00003fff | ||
414 | |||
415 | /*****************************************************************************/ | ||
416 | #define DIF_BPF_COEFF2425 (DIRECT_IF_REVB_BASE + 0x00000078) | ||
417 | /*****************************************************************************/ | ||
418 | /* Reserved [31:30] */ | ||
419 | #define FLD_DIF_BPF_COEFF_24 0x3fff0000 | ||
420 | /* Reserved [15:14] */ | ||
421 | #define FLD_DIF_BPF_COEFF_25 0x00003fff | ||
422 | |||
423 | /*****************************************************************************/ | ||
424 | #define DIF_BPF_COEFF2627 (DIRECT_IF_REVB_BASE + 0x0000007c) | ||
425 | /*****************************************************************************/ | ||
426 | /* Reserved [31:30] */ | ||
427 | #define FLD_DIF_BPF_COEFF_26 0x3fff0000 | ||
428 | /* Reserved [15:14] */ | ||
429 | #define FLD_DIF_BPF_COEFF_27 0x00003fff | ||
430 | |||
431 | /*****************************************************************************/ | ||
432 | #define DIF_BPF_COEFF2829 (DIRECT_IF_REVB_BASE + 0x00000080) | ||
433 | /*****************************************************************************/ | ||
434 | /* Reserved [31:30] */ | ||
435 | #define FLD_DIF_BPF_COEFF_28 0x3fff0000 | ||
436 | /* Reserved [15:14] */ | ||
437 | #define FLD_DIF_BPF_COEFF_29 0x00003fff | ||
438 | |||
439 | /*****************************************************************************/ | ||
440 | #define DIF_BPF_COEFF3031 (DIRECT_IF_REVB_BASE + 0x00000084) | ||
441 | /*****************************************************************************/ | ||
442 | /* Reserved [31:30] */ | ||
443 | #define FLD_DIF_BPF_COEFF_30 0x3fff0000 | ||
444 | /* Reserved [15:14] */ | ||
445 | #define FLD_DIF_BPF_COEFF_31 0x00003fff | ||
446 | |||
447 | /*****************************************************************************/ | ||
448 | #define DIF_BPF_COEFF3233 (DIRECT_IF_REVB_BASE + 0x00000088) | ||
449 | /*****************************************************************************/ | ||
450 | /* Reserved [31:30] */ | ||
451 | #define FLD_DIF_BPF_COEFF_32 0x3fff0000 | ||
452 | /* Reserved [15:14] */ | ||
453 | #define FLD_DIF_BPF_COEFF_33 0x00003fff | ||
454 | |||
455 | /*****************************************************************************/ | ||
456 | #define DIF_BPF_COEFF3435 (DIRECT_IF_REVB_BASE + 0x0000008c) | ||
457 | /*****************************************************************************/ | ||
458 | /* Reserved [31:30] */ | ||
459 | #define FLD_DIF_BPF_COEFF_34 0x3fff0000 | ||
460 | /* Reserved [15:14] */ | ||
461 | #define FLD_DIF_BPF_COEFF_35 0x00003fff | ||
462 | |||
463 | /*****************************************************************************/ | ||
464 | #define DIF_BPF_COEFF36 (DIRECT_IF_REVB_BASE + 0x00000090) | ||
465 | /*****************************************************************************/ | ||
466 | /* Reserved [31:30] */ | ||
467 | #define FLD_DIF_BPF_COEFF_36 0x3fff0000 | ||
468 | /* Reserved [15:0] */ | ||
469 | |||
470 | /*****************************************************************************/ | ||
471 | #define DIF_RPT_VARIANCE (DIRECT_IF_REVB_BASE + 0x00000094) | ||
472 | /*****************************************************************************/ | ||
473 | /* Reserved [31:20] */ | ||
474 | #define FLD_DIF_RPT_VARIANCE 0x000fffff | ||
475 | |||
476 | /*****************************************************************************/ | ||
477 | #define DIF_SOFT_RST_CTRL_REVB (DIRECT_IF_REVB_BASE + 0x00000098) | ||
478 | /*****************************************************************************/ | ||
479 | /* Reserved [31:8] */ | ||
480 | #define FLD_DIF_DIF_SOFT_RST 0x00000080 | ||
481 | #define FLD_DIF_DIF_REG_RST_MSK 0x00000040 | ||
482 | #define FLD_DIF_AGC_RST_MSK 0x00000020 | ||
483 | #define FLD_DIF_CMP_RST_MSK 0x00000010 | ||
484 | #define FLD_DIF_AVS_RST_MSK 0x00000008 | ||
485 | #define FLD_DIF_NYQ_RST_MSK 0x00000004 | ||
486 | #define FLD_DIF_DIF_SRC_RST_MSK 0x00000002 | ||
487 | #define FLD_DIF_PLL_RST_MSK 0x00000001 | ||
488 | |||
489 | /*****************************************************************************/ | ||
490 | #define DIF_PLL_FREQ_ERR (DIRECT_IF_REVB_BASE + 0x0000009c) | ||
491 | /*****************************************************************************/ | ||
492 | /* Reserved [31:25] */ | ||
493 | #define FLD_DIF_CTL_IP 0x01ffffff | ||
494 | |||
495 | #endif | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c new file mode 100644 index 000000000000..05358d486135 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-core.c | |||
@@ -0,0 +1,1736 @@ | |||
1 | /* | ||
2 | cx231xx-core.c - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | Based on em28xx driver | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/init.h> | ||
24 | #include <linux/list.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/usb.h> | ||
28 | #include <linux/vmalloc.h> | ||
29 | #include <media/v4l2-common.h> | ||
30 | #include <media/tuner.h> | ||
31 | |||
32 | #include "cx231xx.h" | ||
33 | #include "cx231xx-reg.h" | ||
34 | |||
35 | /* #define ENABLE_DEBUG_ISOC_FRAMES */ | ||
36 | |||
37 | static unsigned int core_debug; | ||
38 | module_param(core_debug, int, 0644); | ||
39 | MODULE_PARM_DESC(core_debug, "enable debug messages [core]"); | ||
40 | |||
41 | #define cx231xx_coredbg(fmt, arg...) do {\ | ||
42 | if (core_debug) \ | ||
43 | printk(KERN_INFO "%s %s :"fmt, \ | ||
44 | dev->name, __func__ , ##arg); } while (0) | ||
45 | |||
46 | static unsigned int reg_debug; | ||
47 | module_param(reg_debug, int, 0644); | ||
48 | MODULE_PARM_DESC(reg_debug, "enable debug messages [URB reg]"); | ||
49 | |||
50 | static int alt = CX231XX_PINOUT; | ||
51 | module_param(alt, int, 0644); | ||
52 | MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); | ||
53 | |||
54 | #define cx231xx_isocdbg(fmt, arg...) do {\ | ||
55 | if (core_debug) \ | ||
56 | printk(KERN_INFO "%s %s :"fmt, \ | ||
57 | dev->name, __func__ , ##arg); } while (0) | ||
58 | |||
59 | /***************************************************************** | ||
60 | * Device control list functions * | ||
61 | ******************************************************************/ | ||
62 | |||
63 | LIST_HEAD(cx231xx_devlist); | ||
64 | static DEFINE_MUTEX(cx231xx_devlist_mutex); | ||
65 | |||
66 | /* | ||
67 | * cx231xx_realease_resources() | ||
68 | * unregisters the v4l2,i2c and usb devices | ||
69 | * called when the device gets disconected or at module unload | ||
70 | */ | ||
71 | void cx231xx_remove_from_devlist(struct cx231xx *dev) | ||
72 | { | ||
73 | if (dev == NULL) | ||
74 | return; | ||
75 | if (dev->udev == NULL) | ||
76 | return; | ||
77 | |||
78 | if (atomic_read(&dev->devlist_count) > 0) { | ||
79 | mutex_lock(&cx231xx_devlist_mutex); | ||
80 | list_del(&dev->devlist); | ||
81 | atomic_dec(&dev->devlist_count); | ||
82 | mutex_unlock(&cx231xx_devlist_mutex); | ||
83 | } | ||
84 | }; | ||
85 | |||
86 | void cx231xx_add_into_devlist(struct cx231xx *dev) | ||
87 | { | ||
88 | mutex_lock(&cx231xx_devlist_mutex); | ||
89 | list_add_tail(&dev->devlist, &cx231xx_devlist); | ||
90 | atomic_inc(&dev->devlist_count); | ||
91 | mutex_unlock(&cx231xx_devlist_mutex); | ||
92 | }; | ||
93 | |||
94 | static LIST_HEAD(cx231xx_extension_devlist); | ||
95 | |||
96 | int cx231xx_register_extension(struct cx231xx_ops *ops) | ||
97 | { | ||
98 | struct cx231xx *dev = NULL; | ||
99 | |||
100 | mutex_lock(&cx231xx_devlist_mutex); | ||
101 | list_add_tail(&ops->next, &cx231xx_extension_devlist); | ||
102 | list_for_each_entry(dev, &cx231xx_devlist, devlist) | ||
103 | ops->init(dev); | ||
104 | |||
105 | printk(KERN_INFO DRIVER_NAME ": %s initialized\n", ops->name); | ||
106 | mutex_unlock(&cx231xx_devlist_mutex); | ||
107 | return 0; | ||
108 | } | ||
109 | EXPORT_SYMBOL(cx231xx_register_extension); | ||
110 | |||
111 | void cx231xx_unregister_extension(struct cx231xx_ops *ops) | ||
112 | { | ||
113 | struct cx231xx *dev = NULL; | ||
114 | |||
115 | mutex_lock(&cx231xx_devlist_mutex); | ||
116 | list_for_each_entry(dev, &cx231xx_devlist, devlist) | ||
117 | ops->fini(dev); | ||
118 | |||
119 | |||
120 | printk(KERN_INFO DRIVER_NAME ": %s removed\n", ops->name); | ||
121 | list_del(&ops->next); | ||
122 | mutex_unlock(&cx231xx_devlist_mutex); | ||
123 | } | ||
124 | EXPORT_SYMBOL(cx231xx_unregister_extension); | ||
125 | |||
126 | void cx231xx_init_extension(struct cx231xx *dev) | ||
127 | { | ||
128 | struct cx231xx_ops *ops = NULL; | ||
129 | |||
130 | mutex_lock(&cx231xx_devlist_mutex); | ||
131 | if (!list_empty(&cx231xx_extension_devlist)) { | ||
132 | list_for_each_entry(ops, &cx231xx_extension_devlist, next) { | ||
133 | if (ops->init) | ||
134 | ops->init(dev); | ||
135 | } | ||
136 | } | ||
137 | mutex_unlock(&cx231xx_devlist_mutex); | ||
138 | } | ||
139 | |||
140 | void cx231xx_close_extension(struct cx231xx *dev) | ||
141 | { | ||
142 | struct cx231xx_ops *ops = NULL; | ||
143 | |||
144 | mutex_lock(&cx231xx_devlist_mutex); | ||
145 | if (!list_empty(&cx231xx_extension_devlist)) { | ||
146 | list_for_each_entry(ops, &cx231xx_extension_devlist, next) { | ||
147 | if (ops->fini) | ||
148 | ops->fini(dev); | ||
149 | } | ||
150 | } | ||
151 | mutex_unlock(&cx231xx_devlist_mutex); | ||
152 | } | ||
153 | |||
154 | /**************************************************************** | ||
155 | * U S B related functions * | ||
156 | *****************************************************************/ | ||
157 | int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, | ||
158 | struct cx231xx_i2c_xfer_data *req_data) | ||
159 | { | ||
160 | int status = 0; | ||
161 | struct cx231xx *dev = i2c_bus->dev; | ||
162 | struct VENDOR_REQUEST_IN ven_req; | ||
163 | |||
164 | u8 saddr_len = 0; | ||
165 | u8 _i2c_period = 0; | ||
166 | u8 _i2c_nostop = 0; | ||
167 | u8 _i2c_reserve = 0; | ||
168 | |||
169 | if (dev->state & DEV_DISCONNECTED) | ||
170 | return -ENODEV; | ||
171 | |||
172 | /* Get the I2C period, nostop and reserve parameters */ | ||
173 | _i2c_period = i2c_bus->i2c_period; | ||
174 | _i2c_nostop = i2c_bus->i2c_nostop; | ||
175 | _i2c_reserve = i2c_bus->i2c_reserve; | ||
176 | |||
177 | saddr_len = req_data->saddr_len; | ||
178 | |||
179 | /* Set wValue */ | ||
180 | if (saddr_len == 1) /* need check saddr_len == 0 */ | ||
181 | ven_req.wValue = | ||
182 | req_data-> | ||
183 | dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 | | ||
184 | _i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6; | ||
185 | else | ||
186 | ven_req.wValue = | ||
187 | req_data-> | ||
188 | dev_addr << 9 | _i2c_period << 4 | saddr_len << 2 | | ||
189 | _i2c_nostop << 1 | I2C_SYNC | _i2c_reserve << 6; | ||
190 | |||
191 | /* set channel number */ | ||
192 | if (req_data->direction & I2C_M_RD) { | ||
193 | /* channel number, for read,spec required channel_num +4 */ | ||
194 | ven_req.bRequest = i2c_bus->nr + 4; | ||
195 | } else | ||
196 | ven_req.bRequest = i2c_bus->nr; /* channel number, */ | ||
197 | |||
198 | /* set index value */ | ||
199 | switch (saddr_len) { | ||
200 | case 0: | ||
201 | ven_req.wIndex = 0; /* need check */ | ||
202 | break; | ||
203 | case 1: | ||
204 | ven_req.wIndex = (req_data->saddr_dat & 0xff); | ||
205 | break; | ||
206 | case 2: | ||
207 | ven_req.wIndex = req_data->saddr_dat; | ||
208 | break; | ||
209 | } | ||
210 | |||
211 | /* set wLength value */ | ||
212 | ven_req.wLength = req_data->buf_size; | ||
213 | |||
214 | /* set bData value */ | ||
215 | ven_req.bData = 0; | ||
216 | |||
217 | /* set the direction */ | ||
218 | if (req_data->direction) { | ||
219 | ven_req.direction = USB_DIR_IN; | ||
220 | memset(req_data->p_buffer, 0x00, ven_req.wLength); | ||
221 | } else | ||
222 | ven_req.direction = USB_DIR_OUT; | ||
223 | |||
224 | /* set the buffer for read / write */ | ||
225 | ven_req.pBuff = req_data->p_buffer; | ||
226 | |||
227 | |||
228 | /* call common vendor command request */ | ||
229 | status = cx231xx_send_vendor_cmd(dev, &ven_req); | ||
230 | if (status < 0) { | ||
231 | cx231xx_info | ||
232 | ("UsbInterface::sendCommand, failed with status -%d\n", | ||
233 | status); | ||
234 | } | ||
235 | |||
236 | return status; | ||
237 | } | ||
238 | EXPORT_SYMBOL_GPL(cx231xx_send_usb_command); | ||
239 | |||
240 | /* | ||
241 | * Sends/Receives URB control messages, assuring to use a kalloced buffer | ||
242 | * for all operations (dev->urb_buf), to avoid using stacked buffers, as | ||
243 | * they aren't safe for usage with USB, due to DMA restrictions. | ||
244 | * Also implements the debug code for control URB's. | ||
245 | */ | ||
246 | static int __usb_control_msg(struct cx231xx *dev, unsigned int pipe, | ||
247 | __u8 request, __u8 requesttype, __u16 value, __u16 index, | ||
248 | void *data, __u16 size, int timeout) | ||
249 | { | ||
250 | int rc, i; | ||
251 | |||
252 | if (reg_debug) { | ||
253 | printk(KERN_DEBUG "%s: (pipe 0x%08x): " | ||
254 | "%s: %02x %02x %02x %02x %02x %02x %02x %02x ", | ||
255 | dev->name, | ||
256 | pipe, | ||
257 | (requesttype & USB_DIR_IN) ? "IN" : "OUT", | ||
258 | requesttype, | ||
259 | request, | ||
260 | value & 0xff, value >> 8, | ||
261 | index & 0xff, index >> 8, | ||
262 | size & 0xff, size >> 8); | ||
263 | if (!(requesttype & USB_DIR_IN)) { | ||
264 | printk(KERN_CONT ">>>"); | ||
265 | for (i = 0; i < size; i++) | ||
266 | printk(KERN_CONT " %02x", | ||
267 | ((unsigned char *)data)[i]); | ||
268 | } | ||
269 | } | ||
270 | |||
271 | /* Do the real call to usb_control_msg */ | ||
272 | mutex_lock(&dev->ctrl_urb_lock); | ||
273 | if (!(requesttype & USB_DIR_IN) && size) | ||
274 | memcpy(dev->urb_buf, data, size); | ||
275 | rc = usb_control_msg(dev->udev, pipe, request, requesttype, value, | ||
276 | index, dev->urb_buf, size, timeout); | ||
277 | if ((requesttype & USB_DIR_IN) && size) | ||
278 | memcpy(data, dev->urb_buf, size); | ||
279 | mutex_unlock(&dev->ctrl_urb_lock); | ||
280 | |||
281 | if (reg_debug) { | ||
282 | if (unlikely(rc < 0)) { | ||
283 | printk(KERN_CONT "FAILED!\n"); | ||
284 | return rc; | ||
285 | } | ||
286 | |||
287 | if ((requesttype & USB_DIR_IN)) { | ||
288 | printk(KERN_CONT "<<<"); | ||
289 | for (i = 0; i < size; i++) | ||
290 | printk(KERN_CONT " %02x", | ||
291 | ((unsigned char *)data)[i]); | ||
292 | } | ||
293 | printk(KERN_CONT "\n"); | ||
294 | } | ||
295 | |||
296 | return rc; | ||
297 | } | ||
298 | |||
299 | |||
300 | /* | ||
301 | * cx231xx_read_ctrl_reg() | ||
302 | * reads data from the usb device specifying bRequest and wValue | ||
303 | */ | ||
304 | int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, | ||
305 | char *buf, int len) | ||
306 | { | ||
307 | u8 val = 0; | ||
308 | int ret; | ||
309 | int pipe = usb_rcvctrlpipe(dev->udev, 0); | ||
310 | |||
311 | if (dev->state & DEV_DISCONNECTED) | ||
312 | return -ENODEV; | ||
313 | |||
314 | if (len > URB_MAX_CTRL_SIZE) | ||
315 | return -EINVAL; | ||
316 | |||
317 | switch (len) { | ||
318 | case 1: | ||
319 | val = ENABLE_ONE_BYTE; | ||
320 | break; | ||
321 | case 2: | ||
322 | val = ENABLE_TWE_BYTE; | ||
323 | break; | ||
324 | case 3: | ||
325 | val = ENABLE_THREE_BYTE; | ||
326 | break; | ||
327 | case 4: | ||
328 | val = ENABLE_FOUR_BYTE; | ||
329 | break; | ||
330 | default: | ||
331 | val = 0xFF; /* invalid option */ | ||
332 | } | ||
333 | |||
334 | if (val == 0xFF) | ||
335 | return -EINVAL; | ||
336 | |||
337 | ret = __usb_control_msg(dev, pipe, req, | ||
338 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
339 | val, reg, buf, len, HZ); | ||
340 | return ret; | ||
341 | } | ||
342 | |||
343 | int cx231xx_send_vendor_cmd(struct cx231xx *dev, | ||
344 | struct VENDOR_REQUEST_IN *ven_req) | ||
345 | { | ||
346 | int ret; | ||
347 | int pipe = 0; | ||
348 | int unsend_size = 0; | ||
349 | u8 *pdata; | ||
350 | |||
351 | if (dev->state & DEV_DISCONNECTED) | ||
352 | return -ENODEV; | ||
353 | |||
354 | if ((ven_req->wLength > URB_MAX_CTRL_SIZE)) | ||
355 | return -EINVAL; | ||
356 | |||
357 | if (ven_req->direction) | ||
358 | pipe = usb_rcvctrlpipe(dev->udev, 0); | ||
359 | else | ||
360 | pipe = usb_sndctrlpipe(dev->udev, 0); | ||
361 | |||
362 | /* | ||
363 | * If the cx23102 read more than 4 bytes with i2c bus, | ||
364 | * need chop to 4 byte per request | ||
365 | */ | ||
366 | if ((ven_req->wLength > 4) && ((ven_req->bRequest == 0x4) || | ||
367 | (ven_req->bRequest == 0x5) || | ||
368 | (ven_req->bRequest == 0x6))) { | ||
369 | unsend_size = 0; | ||
370 | pdata = ven_req->pBuff; | ||
371 | |||
372 | |||
373 | unsend_size = ven_req->wLength; | ||
374 | |||
375 | /* the first package */ | ||
376 | ven_req->wValue = ven_req->wValue & 0xFFFB; | ||
377 | ven_req->wValue = (ven_req->wValue & 0xFFBD) | 0x2; | ||
378 | ret = __usb_control_msg(dev, pipe, ven_req->bRequest, | ||
379 | ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
380 | ven_req->wValue, ven_req->wIndex, pdata, | ||
381 | 0x0004, HZ); | ||
382 | unsend_size = unsend_size - 4; | ||
383 | |||
384 | /* the middle package */ | ||
385 | ven_req->wValue = (ven_req->wValue & 0xFFBD) | 0x42; | ||
386 | while (unsend_size - 4 > 0) { | ||
387 | pdata = pdata + 4; | ||
388 | ret = __usb_control_msg(dev, pipe, | ||
389 | ven_req->bRequest, | ||
390 | ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
391 | ven_req->wValue, ven_req->wIndex, pdata, | ||
392 | 0x0004, HZ); | ||
393 | unsend_size = unsend_size - 4; | ||
394 | } | ||
395 | |||
396 | /* the last package */ | ||
397 | ven_req->wValue = (ven_req->wValue & 0xFFBD) | 0x40; | ||
398 | pdata = pdata + 4; | ||
399 | ret = __usb_control_msg(dev, pipe, ven_req->bRequest, | ||
400 | ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
401 | ven_req->wValue, ven_req->wIndex, pdata, | ||
402 | unsend_size, HZ); | ||
403 | } else { | ||
404 | ret = __usb_control_msg(dev, pipe, ven_req->bRequest, | ||
405 | ven_req->direction | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
406 | ven_req->wValue, ven_req->wIndex, | ||
407 | ven_req->pBuff, ven_req->wLength, HZ); | ||
408 | } | ||
409 | |||
410 | return ret; | ||
411 | } | ||
412 | |||
413 | /* | ||
414 | * cx231xx_write_ctrl_reg() | ||
415 | * sends data to the usb device, specifying bRequest | ||
416 | */ | ||
417 | int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, char *buf, | ||
418 | int len) | ||
419 | { | ||
420 | u8 val = 0; | ||
421 | int ret; | ||
422 | int pipe = usb_sndctrlpipe(dev->udev, 0); | ||
423 | |||
424 | if (dev->state & DEV_DISCONNECTED) | ||
425 | return -ENODEV; | ||
426 | |||
427 | if ((len < 1) || (len > URB_MAX_CTRL_SIZE)) | ||
428 | return -EINVAL; | ||
429 | |||
430 | switch (len) { | ||
431 | case 1: | ||
432 | val = ENABLE_ONE_BYTE; | ||
433 | break; | ||
434 | case 2: | ||
435 | val = ENABLE_TWE_BYTE; | ||
436 | break; | ||
437 | case 3: | ||
438 | val = ENABLE_THREE_BYTE; | ||
439 | break; | ||
440 | case 4: | ||
441 | val = ENABLE_FOUR_BYTE; | ||
442 | break; | ||
443 | default: | ||
444 | val = 0xFF; /* invalid option */ | ||
445 | } | ||
446 | |||
447 | if (val == 0xFF) | ||
448 | return -EINVAL; | ||
449 | |||
450 | if (reg_debug) { | ||
451 | int byte; | ||
452 | |||
453 | cx231xx_isocdbg("(pipe 0x%08x): " | ||
454 | "OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>", | ||
455 | pipe, | ||
456 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
457 | req, 0, val, reg & 0xff, | ||
458 | reg >> 8, len & 0xff, len >> 8); | ||
459 | |||
460 | for (byte = 0; byte < len; byte++) | ||
461 | cx231xx_isocdbg(" %02x", (unsigned char)buf[byte]); | ||
462 | cx231xx_isocdbg("\n"); | ||
463 | } | ||
464 | |||
465 | ret = __usb_control_msg(dev, pipe, req, | ||
466 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
467 | val, reg, buf, len, HZ); | ||
468 | |||
469 | return ret; | ||
470 | } | ||
471 | |||
472 | /**************************************************************** | ||
473 | * USB Alternate Setting functions * | ||
474 | *****************************************************************/ | ||
475 | |||
476 | int cx231xx_set_video_alternate(struct cx231xx *dev) | ||
477 | { | ||
478 | int errCode, prev_alt = dev->video_mode.alt; | ||
479 | unsigned int min_pkt_size = dev->width * 2 + 4; | ||
480 | u32 usb_interface_index = 0; | ||
481 | |||
482 | /* When image size is bigger than a certain value, | ||
483 | the frame size should be increased, otherwise, only | ||
484 | green screen will be received. | ||
485 | */ | ||
486 | if (dev->width * 2 * dev->height > 720 * 240 * 2) | ||
487 | min_pkt_size *= 2; | ||
488 | |||
489 | if (dev->width > 360) { | ||
490 | /* resolutions: 720,704,640 */ | ||
491 | dev->video_mode.alt = 3; | ||
492 | } else if (dev->width > 180) { | ||
493 | /* resolutions: 360,352,320,240 */ | ||
494 | dev->video_mode.alt = 2; | ||
495 | } else if (dev->width > 0) { | ||
496 | /* resolutions: 180,176,160,128,88 */ | ||
497 | dev->video_mode.alt = 1; | ||
498 | } else { | ||
499 | /* Change to alt0 BULK to release USB bandwidth */ | ||
500 | dev->video_mode.alt = 0; | ||
501 | } | ||
502 | |||
503 | if (dev->USE_ISO == 0) | ||
504 | dev->video_mode.alt = 0; | ||
505 | |||
506 | cx231xx_coredbg("dev->video_mode.alt= %d\n", dev->video_mode.alt); | ||
507 | |||
508 | /* Get the correct video interface Index */ | ||
509 | usb_interface_index = | ||
510 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
511 | video_index + 1; | ||
512 | |||
513 | if (dev->video_mode.alt != prev_alt) { | ||
514 | cx231xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", | ||
515 | min_pkt_size, dev->video_mode.alt); | ||
516 | |||
517 | if (dev->video_mode.alt_max_pkt_size != NULL) | ||
518 | dev->video_mode.max_pkt_size = | ||
519 | dev->video_mode.alt_max_pkt_size[dev->video_mode.alt]; | ||
520 | cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", | ||
521 | dev->video_mode.alt, | ||
522 | dev->video_mode.max_pkt_size); | ||
523 | errCode = | ||
524 | usb_set_interface(dev->udev, usb_interface_index, | ||
525 | dev->video_mode.alt); | ||
526 | if (errCode < 0) { | ||
527 | cx231xx_errdev | ||
528 | ("cannot change alt number to %d (error=%i)\n", | ||
529 | dev->video_mode.alt, errCode); | ||
530 | return errCode; | ||
531 | } | ||
532 | } | ||
533 | return 0; | ||
534 | } | ||
535 | |||
536 | int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt) | ||
537 | { | ||
538 | int status = 0; | ||
539 | u32 usb_interface_index = 0; | ||
540 | u32 max_pkt_size = 0; | ||
541 | |||
542 | switch (index) { | ||
543 | case INDEX_TS1: | ||
544 | usb_interface_index = | ||
545 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
546 | ts1_index + 1; | ||
547 | dev->ts1_mode.alt = alt; | ||
548 | if (dev->ts1_mode.alt_max_pkt_size != NULL) | ||
549 | max_pkt_size = dev->ts1_mode.max_pkt_size = | ||
550 | dev->ts1_mode.alt_max_pkt_size[dev->ts1_mode.alt]; | ||
551 | break; | ||
552 | case INDEX_TS2: | ||
553 | usb_interface_index = | ||
554 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
555 | ts2_index + 1; | ||
556 | break; | ||
557 | case INDEX_AUDIO: | ||
558 | usb_interface_index = | ||
559 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
560 | audio_index + 1; | ||
561 | dev->adev.alt = alt; | ||
562 | if (dev->adev.alt_max_pkt_size != NULL) | ||
563 | max_pkt_size = dev->adev.max_pkt_size = | ||
564 | dev->adev.alt_max_pkt_size[dev->adev.alt]; | ||
565 | break; | ||
566 | case INDEX_VIDEO: | ||
567 | usb_interface_index = | ||
568 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
569 | video_index + 1; | ||
570 | dev->video_mode.alt = alt; | ||
571 | if (dev->video_mode.alt_max_pkt_size != NULL) | ||
572 | max_pkt_size = dev->video_mode.max_pkt_size = | ||
573 | dev->video_mode.alt_max_pkt_size[dev->video_mode. | ||
574 | alt]; | ||
575 | break; | ||
576 | case INDEX_VANC: | ||
577 | if (dev->board.no_alt_vanc) | ||
578 | return 0; | ||
579 | usb_interface_index = | ||
580 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
581 | vanc_index + 1; | ||
582 | dev->vbi_mode.alt = alt; | ||
583 | if (dev->vbi_mode.alt_max_pkt_size != NULL) | ||
584 | max_pkt_size = dev->vbi_mode.max_pkt_size = | ||
585 | dev->vbi_mode.alt_max_pkt_size[dev->vbi_mode.alt]; | ||
586 | break; | ||
587 | case INDEX_HANC: | ||
588 | usb_interface_index = | ||
589 | dev->current_pcb_config.hs_config_info[0].interface_info. | ||
590 | hanc_index + 1; | ||
591 | dev->sliced_cc_mode.alt = alt; | ||
592 | if (dev->sliced_cc_mode.alt_max_pkt_size != NULL) | ||
593 | max_pkt_size = dev->sliced_cc_mode.max_pkt_size = | ||
594 | dev->sliced_cc_mode.alt_max_pkt_size[dev-> | ||
595 | sliced_cc_mode. | ||
596 | alt]; | ||
597 | break; | ||
598 | default: | ||
599 | break; | ||
600 | } | ||
601 | |||
602 | if (alt > 0 && max_pkt_size == 0) { | ||
603 | cx231xx_errdev | ||
604 | ("can't change interface %d alt no. to %d: Max. Pkt size = 0\n", | ||
605 | usb_interface_index, alt); | ||
606 | /*To workaround error number=-71 on EP0 for videograbber, | ||
607 | need add following codes.*/ | ||
608 | if (dev->board.no_alt_vanc) | ||
609 | return -1; | ||
610 | } | ||
611 | |||
612 | cx231xx_coredbg("setting alternate %d with wMaxPacketSize=%u," | ||
613 | "Interface = %d\n", alt, max_pkt_size, | ||
614 | usb_interface_index); | ||
615 | |||
616 | if (usb_interface_index > 0) { | ||
617 | status = usb_set_interface(dev->udev, usb_interface_index, alt); | ||
618 | if (status < 0) { | ||
619 | cx231xx_errdev | ||
620 | ("can't change interface %d alt no. to %d (err=%i)\n", | ||
621 | usb_interface_index, alt, status); | ||
622 | return status; | ||
623 | } | ||
624 | } | ||
625 | |||
626 | return status; | ||
627 | } | ||
628 | EXPORT_SYMBOL_GPL(cx231xx_set_alt_setting); | ||
629 | |||
630 | int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio) | ||
631 | { | ||
632 | int rc = 0; | ||
633 | |||
634 | if (!gpio) | ||
635 | return rc; | ||
636 | |||
637 | /* Send GPIO reset sequences specified at board entry */ | ||
638 | while (gpio->sleep >= 0) { | ||
639 | rc = cx231xx_set_gpio_value(dev, gpio->bit, gpio->val); | ||
640 | if (rc < 0) | ||
641 | return rc; | ||
642 | |||
643 | if (gpio->sleep > 0) | ||
644 | msleep(gpio->sleep); | ||
645 | |||
646 | gpio++; | ||
647 | } | ||
648 | return rc; | ||
649 | } | ||
650 | |||
651 | int cx231xx_demod_reset(struct cx231xx *dev) | ||
652 | { | ||
653 | |||
654 | u8 status = 0; | ||
655 | u8 value[4] = { 0, 0, 0, 0 }; | ||
656 | |||
657 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, | ||
658 | value, 4); | ||
659 | |||
660 | cx231xx_coredbg("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", PWR_CTL_EN, | ||
661 | value[0], value[1], value[2], value[3]); | ||
662 | |||
663 | cx231xx_coredbg("Enter cx231xx_demod_reset()\n"); | ||
664 | |||
665 | value[1] = (u8) 0x3; | ||
666 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
667 | PWR_CTL_EN, value, 4); | ||
668 | msleep(10); | ||
669 | |||
670 | value[1] = (u8) 0x0; | ||
671 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
672 | PWR_CTL_EN, value, 4); | ||
673 | msleep(10); | ||
674 | |||
675 | value[1] = (u8) 0x3; | ||
676 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
677 | PWR_CTL_EN, value, 4); | ||
678 | msleep(10); | ||
679 | |||
680 | |||
681 | |||
682 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, PWR_CTL_EN, | ||
683 | value, 4); | ||
684 | |||
685 | cx231xx_coredbg("reg0x%x=0x%x 0x%x 0x%x 0x%x\n", PWR_CTL_EN, | ||
686 | value[0], value[1], value[2], value[3]); | ||
687 | |||
688 | return status; | ||
689 | } | ||
690 | EXPORT_SYMBOL_GPL(cx231xx_demod_reset); | ||
691 | int is_fw_load(struct cx231xx *dev) | ||
692 | { | ||
693 | return cx231xx_check_fw(dev); | ||
694 | } | ||
695 | EXPORT_SYMBOL_GPL(is_fw_load); | ||
696 | |||
697 | int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode) | ||
698 | { | ||
699 | int errCode = 0; | ||
700 | |||
701 | if (dev->mode == set_mode) | ||
702 | return 0; | ||
703 | |||
704 | if (set_mode == CX231XX_SUSPEND) { | ||
705 | /* Set the chip in power saving mode */ | ||
706 | dev->mode = set_mode; | ||
707 | } | ||
708 | |||
709 | /* Resource is locked */ | ||
710 | if (dev->mode != CX231XX_SUSPEND) | ||
711 | return -EINVAL; | ||
712 | |||
713 | dev->mode = set_mode; | ||
714 | |||
715 | if (dev->mode == CX231XX_DIGITAL_MODE)/* Set Digital power mode */ { | ||
716 | /* set AGC mode to Digital */ | ||
717 | switch (dev->model) { | ||
718 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
719 | case CX231XX_BOARD_CNXT_RDE_250: | ||
720 | case CX231XX_BOARD_CNXT_SHELBY: | ||
721 | case CX231XX_BOARD_CNXT_RDU_250: | ||
722 | errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0); | ||
723 | break; | ||
724 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
725 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
726 | errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); | ||
727 | break; | ||
728 | case CX231XX_BOARD_HAUPPAUGE_EXETER: | ||
729 | errCode = cx231xx_set_power_mode(dev, | ||
730 | POLARIS_AVMODE_DIGITAL); | ||
731 | break; | ||
732 | default: | ||
733 | break; | ||
734 | } | ||
735 | } else/* Set Analog Power mode */ { | ||
736 | /* set AGC mode to Analog */ | ||
737 | switch (dev->model) { | ||
738 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
739 | case CX231XX_BOARD_CNXT_RDE_250: | ||
740 | case CX231XX_BOARD_CNXT_SHELBY: | ||
741 | case CX231XX_BOARD_CNXT_RDU_250: | ||
742 | errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); | ||
743 | break; | ||
744 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
745 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
746 | case CX231XX_BOARD_HAUPPAUGE_EXETER: | ||
747 | case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: | ||
748 | case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: | ||
749 | case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: | ||
750 | errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0); | ||
751 | break; | ||
752 | default: | ||
753 | break; | ||
754 | } | ||
755 | } | ||
756 | |||
757 | return errCode ? -EINVAL : 0; | ||
758 | } | ||
759 | EXPORT_SYMBOL_GPL(cx231xx_set_mode); | ||
760 | |||
761 | int cx231xx_ep5_bulkout(struct cx231xx *dev, u8 *firmware, u16 size) | ||
762 | { | ||
763 | int errCode = 0; | ||
764 | int actlen, ret = -ENOMEM; | ||
765 | u32 *buffer; | ||
766 | |||
767 | buffer = kzalloc(4096, GFP_KERNEL); | ||
768 | if (buffer == NULL) { | ||
769 | cx231xx_info("out of mem\n"); | ||
770 | return -ENOMEM; | ||
771 | } | ||
772 | memcpy(&buffer[0], firmware, 4096); | ||
773 | |||
774 | ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 5), | ||
775 | buffer, 4096, &actlen, 2000); | ||
776 | |||
777 | if (ret) | ||
778 | cx231xx_info("bulk message failed: %d (%d/%d)", ret, | ||
779 | size, actlen); | ||
780 | else { | ||
781 | errCode = actlen != size ? -1 : 0; | ||
782 | } | ||
783 | kfree(buffer); | ||
784 | return errCode; | ||
785 | } | ||
786 | |||
787 | /***************************************************************** | ||
788 | * URB Streaming functions * | ||
789 | ******************************************************************/ | ||
790 | |||
791 | /* | ||
792 | * IRQ callback, called by URB callback | ||
793 | */ | ||
794 | static void cx231xx_isoc_irq_callback(struct urb *urb) | ||
795 | { | ||
796 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
797 | struct cx231xx_video_mode *vmode = | ||
798 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
799 | struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); | ||
800 | int i; | ||
801 | |||
802 | switch (urb->status) { | ||
803 | case 0: /* success */ | ||
804 | case -ETIMEDOUT: /* NAK */ | ||
805 | break; | ||
806 | case -ECONNRESET: /* kill */ | ||
807 | case -ENOENT: | ||
808 | case -ESHUTDOWN: | ||
809 | return; | ||
810 | default: /* error */ | ||
811 | cx231xx_isocdbg("urb completition error %d.\n", urb->status); | ||
812 | break; | ||
813 | } | ||
814 | |||
815 | /* Copy data from URB */ | ||
816 | spin_lock(&dev->video_mode.slock); | ||
817 | dev->video_mode.isoc_ctl.isoc_copy(dev, urb); | ||
818 | spin_unlock(&dev->video_mode.slock); | ||
819 | |||
820 | /* Reset urb buffers */ | ||
821 | for (i = 0; i < urb->number_of_packets; i++) { | ||
822 | urb->iso_frame_desc[i].status = 0; | ||
823 | urb->iso_frame_desc[i].actual_length = 0; | ||
824 | } | ||
825 | |||
826 | urb->status = usb_submit_urb(urb, GFP_ATOMIC); | ||
827 | if (urb->status) { | ||
828 | cx231xx_isocdbg("urb resubmit failed (error=%i)\n", | ||
829 | urb->status); | ||
830 | } | ||
831 | } | ||
832 | /***************************************************************** | ||
833 | * URB Streaming functions * | ||
834 | ******************************************************************/ | ||
835 | |||
836 | /* | ||
837 | * IRQ callback, called by URB callback | ||
838 | */ | ||
839 | static void cx231xx_bulk_irq_callback(struct urb *urb) | ||
840 | { | ||
841 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
842 | struct cx231xx_video_mode *vmode = | ||
843 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
844 | struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); | ||
845 | |||
846 | switch (urb->status) { | ||
847 | case 0: /* success */ | ||
848 | case -ETIMEDOUT: /* NAK */ | ||
849 | break; | ||
850 | case -ECONNRESET: /* kill */ | ||
851 | case -ENOENT: | ||
852 | case -ESHUTDOWN: | ||
853 | return; | ||
854 | default: /* error */ | ||
855 | cx231xx_isocdbg("urb completition error %d.\n", urb->status); | ||
856 | break; | ||
857 | } | ||
858 | |||
859 | /* Copy data from URB */ | ||
860 | spin_lock(&dev->video_mode.slock); | ||
861 | dev->video_mode.bulk_ctl.bulk_copy(dev, urb); | ||
862 | spin_unlock(&dev->video_mode.slock); | ||
863 | |||
864 | /* Reset urb buffers */ | ||
865 | urb->status = usb_submit_urb(urb, GFP_ATOMIC); | ||
866 | if (urb->status) { | ||
867 | cx231xx_isocdbg("urb resubmit failed (error=%i)\n", | ||
868 | urb->status); | ||
869 | } | ||
870 | } | ||
871 | /* | ||
872 | * Stop and Deallocate URBs | ||
873 | */ | ||
874 | void cx231xx_uninit_isoc(struct cx231xx *dev) | ||
875 | { | ||
876 | struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; | ||
877 | struct urb *urb; | ||
878 | int i; | ||
879 | |||
880 | cx231xx_isocdbg("cx231xx: called cx231xx_uninit_isoc\n"); | ||
881 | |||
882 | dev->video_mode.isoc_ctl.nfields = -1; | ||
883 | for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { | ||
884 | urb = dev->video_mode.isoc_ctl.urb[i]; | ||
885 | if (urb) { | ||
886 | if (!irqs_disabled()) | ||
887 | usb_kill_urb(urb); | ||
888 | else | ||
889 | usb_unlink_urb(urb); | ||
890 | |||
891 | if (dev->video_mode.isoc_ctl.transfer_buffer[i]) { | ||
892 | usb_free_coherent(dev->udev, | ||
893 | urb->transfer_buffer_length, | ||
894 | dev->video_mode.isoc_ctl. | ||
895 | transfer_buffer[i], | ||
896 | urb->transfer_dma); | ||
897 | } | ||
898 | usb_free_urb(urb); | ||
899 | dev->video_mode.isoc_ctl.urb[i] = NULL; | ||
900 | } | ||
901 | dev->video_mode.isoc_ctl.transfer_buffer[i] = NULL; | ||
902 | } | ||
903 | |||
904 | kfree(dev->video_mode.isoc_ctl.urb); | ||
905 | kfree(dev->video_mode.isoc_ctl.transfer_buffer); | ||
906 | kfree(dma_q->p_left_data); | ||
907 | |||
908 | dev->video_mode.isoc_ctl.urb = NULL; | ||
909 | dev->video_mode.isoc_ctl.transfer_buffer = NULL; | ||
910 | dev->video_mode.isoc_ctl.num_bufs = 0; | ||
911 | dma_q->p_left_data = NULL; | ||
912 | |||
913 | if (dev->mode_tv == 0) | ||
914 | cx231xx_capture_start(dev, 0, Raw_Video); | ||
915 | else | ||
916 | cx231xx_capture_start(dev, 0, TS1_serial_mode); | ||
917 | |||
918 | |||
919 | } | ||
920 | EXPORT_SYMBOL_GPL(cx231xx_uninit_isoc); | ||
921 | |||
922 | /* | ||
923 | * Stop and Deallocate URBs | ||
924 | */ | ||
925 | void cx231xx_uninit_bulk(struct cx231xx *dev) | ||
926 | { | ||
927 | struct urb *urb; | ||
928 | int i; | ||
929 | |||
930 | cx231xx_isocdbg("cx231xx: called cx231xx_uninit_bulk\n"); | ||
931 | |||
932 | dev->video_mode.bulk_ctl.nfields = -1; | ||
933 | for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { | ||
934 | urb = dev->video_mode.bulk_ctl.urb[i]; | ||
935 | if (urb) { | ||
936 | if (!irqs_disabled()) | ||
937 | usb_kill_urb(urb); | ||
938 | else | ||
939 | usb_unlink_urb(urb); | ||
940 | |||
941 | if (dev->video_mode.bulk_ctl.transfer_buffer[i]) { | ||
942 | usb_free_coherent(dev->udev, | ||
943 | urb->transfer_buffer_length, | ||
944 | dev->video_mode.isoc_ctl. | ||
945 | transfer_buffer[i], | ||
946 | urb->transfer_dma); | ||
947 | } | ||
948 | usb_free_urb(urb); | ||
949 | dev->video_mode.bulk_ctl.urb[i] = NULL; | ||
950 | } | ||
951 | dev->video_mode.bulk_ctl.transfer_buffer[i] = NULL; | ||
952 | } | ||
953 | |||
954 | kfree(dev->video_mode.bulk_ctl.urb); | ||
955 | kfree(dev->video_mode.bulk_ctl.transfer_buffer); | ||
956 | |||
957 | dev->video_mode.bulk_ctl.urb = NULL; | ||
958 | dev->video_mode.bulk_ctl.transfer_buffer = NULL; | ||
959 | dev->video_mode.bulk_ctl.num_bufs = 0; | ||
960 | |||
961 | if (dev->mode_tv == 0) | ||
962 | cx231xx_capture_start(dev, 0, Raw_Video); | ||
963 | else | ||
964 | cx231xx_capture_start(dev, 0, TS1_serial_mode); | ||
965 | |||
966 | |||
967 | } | ||
968 | EXPORT_SYMBOL_GPL(cx231xx_uninit_bulk); | ||
969 | |||
970 | /* | ||
971 | * Allocate URBs and start IRQ | ||
972 | */ | ||
973 | int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | ||
974 | int num_bufs, int max_pkt_size, | ||
975 | int (*isoc_copy) (struct cx231xx *dev, struct urb *urb)) | ||
976 | { | ||
977 | struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; | ||
978 | int i; | ||
979 | int sb_size, pipe; | ||
980 | struct urb *urb; | ||
981 | int j, k; | ||
982 | int rc; | ||
983 | |||
984 | /* De-allocates all pending stuff */ | ||
985 | cx231xx_uninit_isoc(dev); | ||
986 | |||
987 | dma_q->p_left_data = kzalloc(4096, GFP_KERNEL); | ||
988 | if (dma_q->p_left_data == NULL) { | ||
989 | cx231xx_info("out of mem\n"); | ||
990 | return -ENOMEM; | ||
991 | } | ||
992 | |||
993 | |||
994 | |||
995 | dev->video_mode.isoc_ctl.isoc_copy = isoc_copy; | ||
996 | dev->video_mode.isoc_ctl.num_bufs = num_bufs; | ||
997 | dma_q->pos = 0; | ||
998 | dma_q->is_partial_line = 0; | ||
999 | dma_q->last_sav = 0; | ||
1000 | dma_q->current_field = -1; | ||
1001 | dma_q->field1_done = 0; | ||
1002 | dma_q->lines_per_field = dev->height / 2; | ||
1003 | dma_q->bytes_left_in_line = dev->width << 1; | ||
1004 | dma_q->lines_completed = 0; | ||
1005 | dma_q->mpeg_buffer_done = 0; | ||
1006 | dma_q->left_data_count = 0; | ||
1007 | dma_q->mpeg_buffer_completed = 0; | ||
1008 | dma_q->add_ps_package_head = CX231XX_NEED_ADD_PS_PACKAGE_HEAD; | ||
1009 | dma_q->ps_head[0] = 0x00; | ||
1010 | dma_q->ps_head[1] = 0x00; | ||
1011 | dma_q->ps_head[2] = 0x01; | ||
1012 | dma_q->ps_head[3] = 0xBA; | ||
1013 | for (i = 0; i < 8; i++) | ||
1014 | dma_q->partial_buf[i] = 0; | ||
1015 | |||
1016 | dev->video_mode.isoc_ctl.urb = | ||
1017 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | ||
1018 | if (!dev->video_mode.isoc_ctl.urb) { | ||
1019 | cx231xx_errdev("cannot alloc memory for usb buffers\n"); | ||
1020 | return -ENOMEM; | ||
1021 | } | ||
1022 | |||
1023 | dev->video_mode.isoc_ctl.transfer_buffer = | ||
1024 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | ||
1025 | if (!dev->video_mode.isoc_ctl.transfer_buffer) { | ||
1026 | cx231xx_errdev("cannot allocate memory for usbtransfer\n"); | ||
1027 | kfree(dev->video_mode.isoc_ctl.urb); | ||
1028 | return -ENOMEM; | ||
1029 | } | ||
1030 | |||
1031 | dev->video_mode.isoc_ctl.max_pkt_size = max_pkt_size; | ||
1032 | dev->video_mode.isoc_ctl.buf = NULL; | ||
1033 | |||
1034 | sb_size = max_packets * dev->video_mode.isoc_ctl.max_pkt_size; | ||
1035 | |||
1036 | if (dev->mode_tv == 1) | ||
1037 | dev->video_mode.end_point_addr = 0x81; | ||
1038 | else | ||
1039 | dev->video_mode.end_point_addr = 0x84; | ||
1040 | |||
1041 | |||
1042 | /* allocate urbs and transfer buffers */ | ||
1043 | for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { | ||
1044 | urb = usb_alloc_urb(max_packets, GFP_KERNEL); | ||
1045 | if (!urb) { | ||
1046 | cx231xx_err("cannot alloc isoc_ctl.urb %i\n", i); | ||
1047 | cx231xx_uninit_isoc(dev); | ||
1048 | return -ENOMEM; | ||
1049 | } | ||
1050 | dev->video_mode.isoc_ctl.urb[i] = urb; | ||
1051 | |||
1052 | dev->video_mode.isoc_ctl.transfer_buffer[i] = | ||
1053 | usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, | ||
1054 | &urb->transfer_dma); | ||
1055 | if (!dev->video_mode.isoc_ctl.transfer_buffer[i]) { | ||
1056 | cx231xx_err("unable to allocate %i bytes for transfer" | ||
1057 | " buffer %i%s\n", | ||
1058 | sb_size, i, | ||
1059 | in_interrupt() ? " while in int" : ""); | ||
1060 | cx231xx_uninit_isoc(dev); | ||
1061 | return -ENOMEM; | ||
1062 | } | ||
1063 | memset(dev->video_mode.isoc_ctl.transfer_buffer[i], 0, sb_size); | ||
1064 | |||
1065 | pipe = | ||
1066 | usb_rcvisocpipe(dev->udev, dev->video_mode.end_point_addr); | ||
1067 | |||
1068 | usb_fill_int_urb(urb, dev->udev, pipe, | ||
1069 | dev->video_mode.isoc_ctl.transfer_buffer[i], | ||
1070 | sb_size, cx231xx_isoc_irq_callback, dma_q, 1); | ||
1071 | |||
1072 | urb->number_of_packets = max_packets; | ||
1073 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; | ||
1074 | |||
1075 | k = 0; | ||
1076 | for (j = 0; j < max_packets; j++) { | ||
1077 | urb->iso_frame_desc[j].offset = k; | ||
1078 | urb->iso_frame_desc[j].length = | ||
1079 | dev->video_mode.isoc_ctl.max_pkt_size; | ||
1080 | k += dev->video_mode.isoc_ctl.max_pkt_size; | ||
1081 | } | ||
1082 | } | ||
1083 | |||
1084 | init_waitqueue_head(&dma_q->wq); | ||
1085 | |||
1086 | /* submit urbs and enables IRQ */ | ||
1087 | for (i = 0; i < dev->video_mode.isoc_ctl.num_bufs; i++) { | ||
1088 | rc = usb_submit_urb(dev->video_mode.isoc_ctl.urb[i], | ||
1089 | GFP_ATOMIC); | ||
1090 | if (rc) { | ||
1091 | cx231xx_err("submit of urb %i failed (error=%i)\n", i, | ||
1092 | rc); | ||
1093 | cx231xx_uninit_isoc(dev); | ||
1094 | return rc; | ||
1095 | } | ||
1096 | } | ||
1097 | |||
1098 | if (dev->mode_tv == 0) | ||
1099 | cx231xx_capture_start(dev, 1, Raw_Video); | ||
1100 | else | ||
1101 | cx231xx_capture_start(dev, 1, TS1_serial_mode); | ||
1102 | |||
1103 | return 0; | ||
1104 | } | ||
1105 | EXPORT_SYMBOL_GPL(cx231xx_init_isoc); | ||
1106 | |||
1107 | /* | ||
1108 | * Allocate URBs and start IRQ | ||
1109 | */ | ||
1110 | int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, | ||
1111 | int num_bufs, int max_pkt_size, | ||
1112 | int (*bulk_copy) (struct cx231xx *dev, struct urb *urb)) | ||
1113 | { | ||
1114 | struct cx231xx_dmaqueue *dma_q = &dev->video_mode.vidq; | ||
1115 | int i; | ||
1116 | int sb_size, pipe; | ||
1117 | struct urb *urb; | ||
1118 | int rc; | ||
1119 | |||
1120 | dev->video_input = dev->video_input > 2 ? 2 : dev->video_input; | ||
1121 | |||
1122 | cx231xx_coredbg("Setting Video mux to %d\n", dev->video_input); | ||
1123 | |||
1124 | video_mux(dev, dev->video_input); | ||
1125 | |||
1126 | /* De-allocates all pending stuff */ | ||
1127 | cx231xx_uninit_bulk(dev); | ||
1128 | |||
1129 | dev->video_mode.bulk_ctl.bulk_copy = bulk_copy; | ||
1130 | dev->video_mode.bulk_ctl.num_bufs = num_bufs; | ||
1131 | dma_q->pos = 0; | ||
1132 | dma_q->is_partial_line = 0; | ||
1133 | dma_q->last_sav = 0; | ||
1134 | dma_q->current_field = -1; | ||
1135 | dma_q->field1_done = 0; | ||
1136 | dma_q->lines_per_field = dev->height / 2; | ||
1137 | dma_q->bytes_left_in_line = dev->width << 1; | ||
1138 | dma_q->lines_completed = 0; | ||
1139 | dma_q->mpeg_buffer_done = 0; | ||
1140 | dma_q->left_data_count = 0; | ||
1141 | dma_q->mpeg_buffer_completed = 0; | ||
1142 | dma_q->ps_head[0] = 0x00; | ||
1143 | dma_q->ps_head[1] = 0x00; | ||
1144 | dma_q->ps_head[2] = 0x01; | ||
1145 | dma_q->ps_head[3] = 0xBA; | ||
1146 | for (i = 0; i < 8; i++) | ||
1147 | dma_q->partial_buf[i] = 0; | ||
1148 | |||
1149 | dev->video_mode.bulk_ctl.urb = | ||
1150 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | ||
1151 | if (!dev->video_mode.bulk_ctl.urb) { | ||
1152 | cx231xx_errdev("cannot alloc memory for usb buffers\n"); | ||
1153 | return -ENOMEM; | ||
1154 | } | ||
1155 | |||
1156 | dev->video_mode.bulk_ctl.transfer_buffer = | ||
1157 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | ||
1158 | if (!dev->video_mode.bulk_ctl.transfer_buffer) { | ||
1159 | cx231xx_errdev("cannot allocate memory for usbtransfer\n"); | ||
1160 | kfree(dev->video_mode.bulk_ctl.urb); | ||
1161 | return -ENOMEM; | ||
1162 | } | ||
1163 | |||
1164 | dev->video_mode.bulk_ctl.max_pkt_size = max_pkt_size; | ||
1165 | dev->video_mode.bulk_ctl.buf = NULL; | ||
1166 | |||
1167 | sb_size = max_packets * dev->video_mode.bulk_ctl.max_pkt_size; | ||
1168 | |||
1169 | if (dev->mode_tv == 1) | ||
1170 | dev->video_mode.end_point_addr = 0x81; | ||
1171 | else | ||
1172 | dev->video_mode.end_point_addr = 0x84; | ||
1173 | |||
1174 | |||
1175 | /* allocate urbs and transfer buffers */ | ||
1176 | for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { | ||
1177 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
1178 | if (!urb) { | ||
1179 | cx231xx_err("cannot alloc bulk_ctl.urb %i\n", i); | ||
1180 | cx231xx_uninit_bulk(dev); | ||
1181 | return -ENOMEM; | ||
1182 | } | ||
1183 | dev->video_mode.bulk_ctl.urb[i] = urb; | ||
1184 | urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; | ||
1185 | |||
1186 | dev->video_mode.bulk_ctl.transfer_buffer[i] = | ||
1187 | usb_alloc_coherent(dev->udev, sb_size, GFP_KERNEL, | ||
1188 | &urb->transfer_dma); | ||
1189 | if (!dev->video_mode.bulk_ctl.transfer_buffer[i]) { | ||
1190 | cx231xx_err("unable to allocate %i bytes for transfer" | ||
1191 | " buffer %i%s\n", | ||
1192 | sb_size, i, | ||
1193 | in_interrupt() ? " while in int" : ""); | ||
1194 | cx231xx_uninit_bulk(dev); | ||
1195 | return -ENOMEM; | ||
1196 | } | ||
1197 | memset(dev->video_mode.bulk_ctl.transfer_buffer[i], 0, sb_size); | ||
1198 | |||
1199 | pipe = usb_rcvbulkpipe(dev->udev, | ||
1200 | dev->video_mode.end_point_addr); | ||
1201 | usb_fill_bulk_urb(urb, dev->udev, pipe, | ||
1202 | dev->video_mode.bulk_ctl.transfer_buffer[i], | ||
1203 | sb_size, cx231xx_bulk_irq_callback, dma_q); | ||
1204 | } | ||
1205 | |||
1206 | init_waitqueue_head(&dma_q->wq); | ||
1207 | |||
1208 | /* submit urbs and enables IRQ */ | ||
1209 | for (i = 0; i < dev->video_mode.bulk_ctl.num_bufs; i++) { | ||
1210 | rc = usb_submit_urb(dev->video_mode.bulk_ctl.urb[i], | ||
1211 | GFP_ATOMIC); | ||
1212 | if (rc) { | ||
1213 | cx231xx_err("submit of urb %i failed (error=%i)\n", i, | ||
1214 | rc); | ||
1215 | cx231xx_uninit_bulk(dev); | ||
1216 | return rc; | ||
1217 | } | ||
1218 | } | ||
1219 | |||
1220 | if (dev->mode_tv == 0) | ||
1221 | cx231xx_capture_start(dev, 1, Raw_Video); | ||
1222 | else | ||
1223 | cx231xx_capture_start(dev, 1, TS1_serial_mode); | ||
1224 | |||
1225 | return 0; | ||
1226 | } | ||
1227 | EXPORT_SYMBOL_GPL(cx231xx_init_bulk); | ||
1228 | void cx231xx_stop_TS1(struct cx231xx *dev) | ||
1229 | { | ||
1230 | u8 val[4] = { 0, 0, 0, 0 }; | ||
1231 | |||
1232 | val[0] = 0x00; | ||
1233 | val[1] = 0x03; | ||
1234 | val[2] = 0x00; | ||
1235 | val[3] = 0x00; | ||
1236 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1237 | TS_MODE_REG, val, 4); | ||
1238 | |||
1239 | val[0] = 0x00; | ||
1240 | val[1] = 0x70; | ||
1241 | val[2] = 0x04; | ||
1242 | val[3] = 0x00; | ||
1243 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1244 | TS1_CFG_REG, val, 4); | ||
1245 | } | ||
1246 | /* EXPORT_SYMBOL_GPL(cx231xx_stop_TS1); */ | ||
1247 | void cx231xx_start_TS1(struct cx231xx *dev) | ||
1248 | { | ||
1249 | u8 val[4] = { 0, 0, 0, 0 }; | ||
1250 | |||
1251 | val[0] = 0x03; | ||
1252 | val[1] = 0x03; | ||
1253 | val[2] = 0x00; | ||
1254 | val[3] = 0x00; | ||
1255 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1256 | TS_MODE_REG, val, 4); | ||
1257 | |||
1258 | val[0] = 0x04; | ||
1259 | val[1] = 0xA3; | ||
1260 | val[2] = 0x3B; | ||
1261 | val[3] = 0x00; | ||
1262 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1263 | TS1_CFG_REG, val, 4); | ||
1264 | } | ||
1265 | /* EXPORT_SYMBOL_GPL(cx231xx_start_TS1); */ | ||
1266 | /***************************************************************** | ||
1267 | * Device Init/UnInit functions * | ||
1268 | ******************************************************************/ | ||
1269 | int cx231xx_dev_init(struct cx231xx *dev) | ||
1270 | { | ||
1271 | int errCode = 0; | ||
1272 | |||
1273 | /* Initialize I2C bus */ | ||
1274 | |||
1275 | /* External Master 1 Bus */ | ||
1276 | dev->i2c_bus[0].nr = 0; | ||
1277 | dev->i2c_bus[0].dev = dev; | ||
1278 | dev->i2c_bus[0].i2c_period = I2C_SPEED_100K; /* 100 KHz */ | ||
1279 | dev->i2c_bus[0].i2c_nostop = 0; | ||
1280 | dev->i2c_bus[0].i2c_reserve = 0; | ||
1281 | |||
1282 | /* External Master 2 Bus */ | ||
1283 | dev->i2c_bus[1].nr = 1; | ||
1284 | dev->i2c_bus[1].dev = dev; | ||
1285 | dev->i2c_bus[1].i2c_period = I2C_SPEED_100K; /* 100 KHz */ | ||
1286 | dev->i2c_bus[1].i2c_nostop = 0; | ||
1287 | dev->i2c_bus[1].i2c_reserve = 0; | ||
1288 | |||
1289 | /* Internal Master 3 Bus */ | ||
1290 | dev->i2c_bus[2].nr = 2; | ||
1291 | dev->i2c_bus[2].dev = dev; | ||
1292 | dev->i2c_bus[2].i2c_period = I2C_SPEED_100K; /* 100kHz */ | ||
1293 | dev->i2c_bus[2].i2c_nostop = 0; | ||
1294 | dev->i2c_bus[2].i2c_reserve = 0; | ||
1295 | |||
1296 | /* register I2C buses */ | ||
1297 | cx231xx_i2c_register(&dev->i2c_bus[0]); | ||
1298 | cx231xx_i2c_register(&dev->i2c_bus[1]); | ||
1299 | cx231xx_i2c_register(&dev->i2c_bus[2]); | ||
1300 | |||
1301 | /* init hardware */ | ||
1302 | /* Note : with out calling set power mode function, | ||
1303 | afe can not be set up correctly */ | ||
1304 | if (dev->board.external_av) { | ||
1305 | errCode = cx231xx_set_power_mode(dev, | ||
1306 | POLARIS_AVMODE_ENXTERNAL_AV); | ||
1307 | if (errCode < 0) { | ||
1308 | cx231xx_errdev | ||
1309 | ("%s: Failed to set Power - errCode [%d]!\n", | ||
1310 | __func__, errCode); | ||
1311 | return errCode; | ||
1312 | } | ||
1313 | } else { | ||
1314 | errCode = cx231xx_set_power_mode(dev, | ||
1315 | POLARIS_AVMODE_ANALOGT_TV); | ||
1316 | if (errCode < 0) { | ||
1317 | cx231xx_errdev | ||
1318 | ("%s: Failed to set Power - errCode [%d]!\n", | ||
1319 | __func__, errCode); | ||
1320 | return errCode; | ||
1321 | } | ||
1322 | } | ||
1323 | |||
1324 | /* reset the Tuner, if it is a Xceive tuner */ | ||
1325 | if ((dev->board.tuner_type == TUNER_XC5000) || | ||
1326 | (dev->board.tuner_type == TUNER_XC2028)) | ||
1327 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | ||
1328 | |||
1329 | /* initialize Colibri block */ | ||
1330 | errCode = cx231xx_afe_init_super_block(dev, 0x23c); | ||
1331 | if (errCode < 0) { | ||
1332 | cx231xx_errdev | ||
1333 | ("%s: cx231xx_afe init super block - errCode [%d]!\n", | ||
1334 | __func__, errCode); | ||
1335 | return errCode; | ||
1336 | } | ||
1337 | errCode = cx231xx_afe_init_channels(dev); | ||
1338 | if (errCode < 0) { | ||
1339 | cx231xx_errdev | ||
1340 | ("%s: cx231xx_afe init channels - errCode [%d]!\n", | ||
1341 | __func__, errCode); | ||
1342 | return errCode; | ||
1343 | } | ||
1344 | |||
1345 | /* Set DIF in By pass mode */ | ||
1346 | errCode = cx231xx_dif_set_standard(dev, DIF_USE_BASEBAND); | ||
1347 | if (errCode < 0) { | ||
1348 | cx231xx_errdev | ||
1349 | ("%s: cx231xx_dif set to By pass mode - errCode [%d]!\n", | ||
1350 | __func__, errCode); | ||
1351 | return errCode; | ||
1352 | } | ||
1353 | |||
1354 | /* I2S block related functions */ | ||
1355 | errCode = cx231xx_i2s_blk_initialize(dev); | ||
1356 | if (errCode < 0) { | ||
1357 | cx231xx_errdev | ||
1358 | ("%s: cx231xx_i2s block initialize - errCode [%d]!\n", | ||
1359 | __func__, errCode); | ||
1360 | return errCode; | ||
1361 | } | ||
1362 | |||
1363 | /* init control pins */ | ||
1364 | errCode = cx231xx_init_ctrl_pin_status(dev); | ||
1365 | if (errCode < 0) { | ||
1366 | cx231xx_errdev("%s: cx231xx_init ctrl pins - errCode [%d]!\n", | ||
1367 | __func__, errCode); | ||
1368 | return errCode; | ||
1369 | } | ||
1370 | |||
1371 | /* set AGC mode to Analog */ | ||
1372 | switch (dev->model) { | ||
1373 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
1374 | case CX231XX_BOARD_CNXT_RDE_250: | ||
1375 | case CX231XX_BOARD_CNXT_SHELBY: | ||
1376 | case CX231XX_BOARD_CNXT_RDU_250: | ||
1377 | errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 1); | ||
1378 | break; | ||
1379 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
1380 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
1381 | case CX231XX_BOARD_HAUPPAUGE_EXETER: | ||
1382 | case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: | ||
1383 | case CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL: | ||
1384 | case CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC: | ||
1385 | errCode = cx231xx_set_agc_analog_digital_mux_select(dev, 0); | ||
1386 | break; | ||
1387 | default: | ||
1388 | break; | ||
1389 | } | ||
1390 | if (errCode < 0) { | ||
1391 | cx231xx_errdev | ||
1392 | ("%s: cx231xx_AGC mode to Analog - errCode [%d]!\n", | ||
1393 | __func__, errCode); | ||
1394 | return errCode; | ||
1395 | } | ||
1396 | |||
1397 | /* set all alternate settings to zero initially */ | ||
1398 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0); | ||
1399 | cx231xx_set_alt_setting(dev, INDEX_VANC, 0); | ||
1400 | cx231xx_set_alt_setting(dev, INDEX_HANC, 0); | ||
1401 | if (dev->board.has_dvb) | ||
1402 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); | ||
1403 | |||
1404 | /* set the I2C master port to 3 on channel 1 */ | ||
1405 | errCode = cx231xx_enable_i2c_port_3(dev, true); | ||
1406 | |||
1407 | return errCode; | ||
1408 | } | ||
1409 | EXPORT_SYMBOL_GPL(cx231xx_dev_init); | ||
1410 | |||
1411 | void cx231xx_dev_uninit(struct cx231xx *dev) | ||
1412 | { | ||
1413 | /* Un Initialize I2C bus */ | ||
1414 | cx231xx_i2c_unregister(&dev->i2c_bus[2]); | ||
1415 | cx231xx_i2c_unregister(&dev->i2c_bus[1]); | ||
1416 | cx231xx_i2c_unregister(&dev->i2c_bus[0]); | ||
1417 | } | ||
1418 | EXPORT_SYMBOL_GPL(cx231xx_dev_uninit); | ||
1419 | |||
1420 | /***************************************************************** | ||
1421 | * G P I O related functions * | ||
1422 | ******************************************************************/ | ||
1423 | int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val, | ||
1424 | u8 len, u8 request, u8 direction) | ||
1425 | { | ||
1426 | int status = 0; | ||
1427 | struct VENDOR_REQUEST_IN ven_req; | ||
1428 | |||
1429 | /* Set wValue */ | ||
1430 | ven_req.wValue = (u16) (gpio_bit >> 16 & 0xffff); | ||
1431 | |||
1432 | /* set request */ | ||
1433 | if (!request) { | ||
1434 | if (direction) | ||
1435 | ven_req.bRequest = VRT_GET_GPIO; /* 0x8 gpio */ | ||
1436 | else | ||
1437 | ven_req.bRequest = VRT_SET_GPIO; /* 0x9 gpio */ | ||
1438 | } else { | ||
1439 | if (direction) | ||
1440 | ven_req.bRequest = VRT_GET_GPIE; /* 0xa gpie */ | ||
1441 | else | ||
1442 | ven_req.bRequest = VRT_SET_GPIE; /* 0xb gpie */ | ||
1443 | } | ||
1444 | |||
1445 | /* set index value */ | ||
1446 | ven_req.wIndex = (u16) (gpio_bit & 0xffff); | ||
1447 | |||
1448 | /* set wLength value */ | ||
1449 | ven_req.wLength = len; | ||
1450 | |||
1451 | /* set bData value */ | ||
1452 | ven_req.bData = 0; | ||
1453 | |||
1454 | /* set the buffer for read / write */ | ||
1455 | ven_req.pBuff = gpio_val; | ||
1456 | |||
1457 | /* set the direction */ | ||
1458 | if (direction) { | ||
1459 | ven_req.direction = USB_DIR_IN; | ||
1460 | memset(ven_req.pBuff, 0x00, ven_req.wLength); | ||
1461 | } else | ||
1462 | ven_req.direction = USB_DIR_OUT; | ||
1463 | |||
1464 | |||
1465 | /* call common vendor command request */ | ||
1466 | status = cx231xx_send_vendor_cmd(dev, &ven_req); | ||
1467 | if (status < 0) { | ||
1468 | cx231xx_info | ||
1469 | ("UsbInterface::sendCommand, failed with status -%d\n", | ||
1470 | status); | ||
1471 | } | ||
1472 | |||
1473 | return status; | ||
1474 | } | ||
1475 | EXPORT_SYMBOL_GPL(cx231xx_send_gpio_cmd); | ||
1476 | |||
1477 | /***************************************************************** | ||
1478 | * C O N T R O L - Register R E A D / W R I T E functions * | ||
1479 | *****************************************************************/ | ||
1480 | int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode) | ||
1481 | { | ||
1482 | u8 value[4] = { 0x0, 0x0, 0x0, 0x0 }; | ||
1483 | u32 tmp = 0; | ||
1484 | int status = 0; | ||
1485 | |||
1486 | status = | ||
1487 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, address, value, 4); | ||
1488 | if (status < 0) | ||
1489 | return status; | ||
1490 | |||
1491 | tmp = *((u32 *) value); | ||
1492 | tmp |= mode; | ||
1493 | |||
1494 | value[0] = (u8) tmp; | ||
1495 | value[1] = (u8) (tmp >> 8); | ||
1496 | value[2] = (u8) (tmp >> 16); | ||
1497 | value[3] = (u8) (tmp >> 24); | ||
1498 | |||
1499 | status = | ||
1500 | cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, address, value, 4); | ||
1501 | |||
1502 | return status; | ||
1503 | } | ||
1504 | |||
1505 | /***************************************************************** | ||
1506 | * I 2 C Internal C O N T R O L functions * | ||
1507 | *****************************************************************/ | ||
1508 | int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, | ||
1509 | u8 saddr_len, u32 *data, u8 data_len, int master) | ||
1510 | { | ||
1511 | int status = 0; | ||
1512 | struct cx231xx_i2c_xfer_data req_data; | ||
1513 | u8 value[64] = "0"; | ||
1514 | |||
1515 | if (saddr_len == 0) | ||
1516 | saddr = 0; | ||
1517 | else if (saddr_len == 1) | ||
1518 | saddr &= 0xff; | ||
1519 | |||
1520 | /* prepare xfer_data struct */ | ||
1521 | req_data.dev_addr = dev_addr >> 1; | ||
1522 | req_data.direction = I2C_M_RD; | ||
1523 | req_data.saddr_len = saddr_len; | ||
1524 | req_data.saddr_dat = saddr; | ||
1525 | req_data.buf_size = data_len; | ||
1526 | req_data.p_buffer = (u8 *) value; | ||
1527 | |||
1528 | /* usb send command */ | ||
1529 | if (master == 0) | ||
1530 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], | ||
1531 | &req_data); | ||
1532 | else if (master == 1) | ||
1533 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[1], | ||
1534 | &req_data); | ||
1535 | else if (master == 2) | ||
1536 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[2], | ||
1537 | &req_data); | ||
1538 | |||
1539 | if (status >= 0) { | ||
1540 | /* Copy the data read back to main buffer */ | ||
1541 | if (data_len == 1) | ||
1542 | *data = value[0]; | ||
1543 | else if (data_len == 4) | ||
1544 | *data = | ||
1545 | value[0] | value[1] << 8 | value[2] << 16 | value[3] | ||
1546 | << 24; | ||
1547 | else if (data_len > 4) | ||
1548 | *data = value[saddr]; | ||
1549 | } | ||
1550 | |||
1551 | return status; | ||
1552 | } | ||
1553 | |||
1554 | int cx231xx_write_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, | ||
1555 | u8 saddr_len, u32 data, u8 data_len, int master) | ||
1556 | { | ||
1557 | int status = 0; | ||
1558 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1559 | struct cx231xx_i2c_xfer_data req_data; | ||
1560 | |||
1561 | value[0] = (u8) data; | ||
1562 | value[1] = (u8) (data >> 8); | ||
1563 | value[2] = (u8) (data >> 16); | ||
1564 | value[3] = (u8) (data >> 24); | ||
1565 | |||
1566 | if (saddr_len == 0) | ||
1567 | saddr = 0; | ||
1568 | else if (saddr_len == 1) | ||
1569 | saddr &= 0xff; | ||
1570 | |||
1571 | /* prepare xfer_data struct */ | ||
1572 | req_data.dev_addr = dev_addr >> 1; | ||
1573 | req_data.direction = 0; | ||
1574 | req_data.saddr_len = saddr_len; | ||
1575 | req_data.saddr_dat = saddr; | ||
1576 | req_data.buf_size = data_len; | ||
1577 | req_data.p_buffer = value; | ||
1578 | |||
1579 | /* usb send command */ | ||
1580 | if (master == 0) | ||
1581 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], | ||
1582 | &req_data); | ||
1583 | else if (master == 1) | ||
1584 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[1], | ||
1585 | &req_data); | ||
1586 | else if (master == 2) | ||
1587 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[2], | ||
1588 | &req_data); | ||
1589 | |||
1590 | return status; | ||
1591 | } | ||
1592 | |||
1593 | int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, | ||
1594 | u8 saddr_len, u32 *data, u8 data_len) | ||
1595 | { | ||
1596 | int status = 0; | ||
1597 | struct cx231xx_i2c_xfer_data req_data; | ||
1598 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1599 | |||
1600 | if (saddr_len == 0) | ||
1601 | saddr = 0; | ||
1602 | else if (saddr_len == 1) | ||
1603 | saddr &= 0xff; | ||
1604 | |||
1605 | /* prepare xfer_data struct */ | ||
1606 | req_data.dev_addr = dev_addr >> 1; | ||
1607 | req_data.direction = I2C_M_RD; | ||
1608 | req_data.saddr_len = saddr_len; | ||
1609 | req_data.saddr_dat = saddr; | ||
1610 | req_data.buf_size = data_len; | ||
1611 | req_data.p_buffer = (u8 *) value; | ||
1612 | |||
1613 | /* usb send command */ | ||
1614 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); | ||
1615 | |||
1616 | if (status >= 0) { | ||
1617 | /* Copy the data read back to main buffer */ | ||
1618 | if (data_len == 1) | ||
1619 | *data = value[0]; | ||
1620 | else | ||
1621 | *data = | ||
1622 | value[0] | value[1] << 8 | value[2] << 16 | value[3] | ||
1623 | << 24; | ||
1624 | } | ||
1625 | |||
1626 | return status; | ||
1627 | } | ||
1628 | |||
1629 | int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, | ||
1630 | u8 saddr_len, u32 data, u8 data_len) | ||
1631 | { | ||
1632 | int status = 0; | ||
1633 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1634 | struct cx231xx_i2c_xfer_data req_data; | ||
1635 | |||
1636 | value[0] = (u8) data; | ||
1637 | value[1] = (u8) (data >> 8); | ||
1638 | value[2] = (u8) (data >> 16); | ||
1639 | value[3] = (u8) (data >> 24); | ||
1640 | |||
1641 | if (saddr_len == 0) | ||
1642 | saddr = 0; | ||
1643 | else if (saddr_len == 1) | ||
1644 | saddr &= 0xff; | ||
1645 | |||
1646 | /* prepare xfer_data struct */ | ||
1647 | req_data.dev_addr = dev_addr >> 1; | ||
1648 | req_data.direction = 0; | ||
1649 | req_data.saddr_len = saddr_len; | ||
1650 | req_data.saddr_dat = saddr; | ||
1651 | req_data.buf_size = data_len; | ||
1652 | req_data.p_buffer = value; | ||
1653 | |||
1654 | /* usb send command */ | ||
1655 | status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); | ||
1656 | |||
1657 | return status; | ||
1658 | } | ||
1659 | |||
1660 | int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, | ||
1661 | u16 register_address, u8 bit_start, u8 bit_end, | ||
1662 | u32 value) | ||
1663 | { | ||
1664 | int status = 0; | ||
1665 | u32 tmp; | ||
1666 | u32 mask = 0; | ||
1667 | int i; | ||
1668 | |||
1669 | if (bit_start > (size - 1) || bit_end > (size - 1)) | ||
1670 | return -1; | ||
1671 | |||
1672 | if (size == 8) { | ||
1673 | status = | ||
1674 | cx231xx_read_i2c_data(dev, dev_addr, register_address, 2, | ||
1675 | &tmp, 1); | ||
1676 | } else { | ||
1677 | status = | ||
1678 | cx231xx_read_i2c_data(dev, dev_addr, register_address, 2, | ||
1679 | &tmp, 4); | ||
1680 | } | ||
1681 | |||
1682 | if (status < 0) | ||
1683 | return status; | ||
1684 | |||
1685 | mask = 1 << bit_end; | ||
1686 | for (i = bit_end; i > bit_start && i > 0; i--) | ||
1687 | mask = mask + (1 << (i - 1)); | ||
1688 | |||
1689 | value <<= bit_start; | ||
1690 | |||
1691 | if (size == 8) { | ||
1692 | tmp &= ~mask; | ||
1693 | tmp |= value; | ||
1694 | tmp &= 0xff; | ||
1695 | status = | ||
1696 | cx231xx_write_i2c_data(dev, dev_addr, register_address, 2, | ||
1697 | tmp, 1); | ||
1698 | } else { | ||
1699 | tmp &= ~mask; | ||
1700 | tmp |= value; | ||
1701 | status = | ||
1702 | cx231xx_write_i2c_data(dev, dev_addr, register_address, 2, | ||
1703 | tmp, 4); | ||
1704 | } | ||
1705 | |||
1706 | return status; | ||
1707 | } | ||
1708 | |||
1709 | int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, | ||
1710 | u16 saddr, u32 mask, u32 value) | ||
1711 | { | ||
1712 | u32 temp; | ||
1713 | int status = 0; | ||
1714 | |||
1715 | status = cx231xx_read_i2c_data(dev, dev_addr, saddr, 2, &temp, 4); | ||
1716 | |||
1717 | if (status < 0) | ||
1718 | return status; | ||
1719 | |||
1720 | temp &= ~mask; | ||
1721 | temp |= value; | ||
1722 | |||
1723 | status = cx231xx_write_i2c_data(dev, dev_addr, saddr, 2, temp, 4); | ||
1724 | |||
1725 | return status; | ||
1726 | } | ||
1727 | |||
1728 | u32 cx231xx_set_field(u32 field_mask, u32 data) | ||
1729 | { | ||
1730 | u32 temp; | ||
1731 | |||
1732 | for (temp = field_mask; (temp & 1) == 0; temp >>= 1) | ||
1733 | data <<= 1; | ||
1734 | |||
1735 | return data; | ||
1736 | } | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-dif.h b/drivers/media/usb/cx231xx/cx231xx-dif.h new file mode 100644 index 000000000000..2b63c2f6d3b0 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-dif.h | |||
@@ -0,0 +1,3178 @@ | |||
1 | /* | ||
2 | * cx231xx-dif.h - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | * | ||
4 | * Copyright {C} 2009 <Bill.Liu@conexant.com> | ||
5 | * | ||
6 | * This program is free software, you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation, either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY, without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program, if not, write to the Free Software | ||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef _CX231XX_DIF_H | ||
22 | #define _CX231XX_DIF_H | ||
23 | |||
24 | #include "cx231xx-reg.h" | ||
25 | |||
26 | struct dif_settings{ | ||
27 | u32 if_freq; | ||
28 | u32 register_address; | ||
29 | u32 value; | ||
30 | }; | ||
31 | |||
32 | static struct dif_settings Dif_set_array[] = { | ||
33 | |||
34 | /*case 3000000:*/ | ||
35 | /* BEGIN - DIF BPF register values from 30_quant.dat*/ | ||
36 | {3000000, DIF_BPF_COEFF01, 0x00000002}, | ||
37 | {3000000, DIF_BPF_COEFF23, 0x00080012}, | ||
38 | {3000000, DIF_BPF_COEFF45, 0x001e0024}, | ||
39 | {3000000, DIF_BPF_COEFF67, 0x001bfff8}, | ||
40 | {3000000, DIF_BPF_COEFF89, 0xffb4ff50}, | ||
41 | {3000000, DIF_BPF_COEFF1011, 0xfed8fe68}, | ||
42 | {3000000, DIF_BPF_COEFF1213, 0xfe24fe34}, | ||
43 | {3000000, DIF_BPF_COEFF1415, 0xfebaffc7}, | ||
44 | {3000000, DIF_BPF_COEFF1617, 0x014d031f}, | ||
45 | {3000000, DIF_BPF_COEFF1819, 0x04f0065d}, | ||
46 | {3000000, DIF_BPF_COEFF2021, 0x07010688}, | ||
47 | {3000000, DIF_BPF_COEFF2223, 0x04c901d6}, | ||
48 | {3000000, DIF_BPF_COEFF2425, 0xfe00f9d3}, | ||
49 | {3000000, DIF_BPF_COEFF2627, 0xf600f342}, | ||
50 | {3000000, DIF_BPF_COEFF2829, 0xf235f337}, | ||
51 | {3000000, DIF_BPF_COEFF3031, 0xf64efb22}, | ||
52 | {3000000, DIF_BPF_COEFF3233, 0x0105070f}, | ||
53 | {3000000, DIF_BPF_COEFF3435, 0x0c460fce}, | ||
54 | {3000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
55 | /* END - DIF BPF register values from 30_quant.dat*/ | ||
56 | |||
57 | |||
58 | /*case 3100000:*/ | ||
59 | /* BEGIN - DIF BPF register values from 31_quant.dat*/ | ||
60 | {3100000, DIF_BPF_COEFF01, 0x00000001}, | ||
61 | {3100000, DIF_BPF_COEFF23, 0x00070012}, | ||
62 | {3100000, DIF_BPF_COEFF45, 0x00220032}, | ||
63 | {3100000, DIF_BPF_COEFF67, 0x00370026}, | ||
64 | {3100000, DIF_BPF_COEFF89, 0xfff0ff91}, | ||
65 | {3100000, DIF_BPF_COEFF1011, 0xff0efe7c}, | ||
66 | {3100000, DIF_BPF_COEFF1213, 0xfe01fdcc}, | ||
67 | {3100000, DIF_BPF_COEFF1415, 0xfe0afedb}, | ||
68 | {3100000, DIF_BPF_COEFF1617, 0x00440224}, | ||
69 | {3100000, DIF_BPF_COEFF1819, 0x0434060c}, | ||
70 | {3100000, DIF_BPF_COEFF2021, 0x0738074e}, | ||
71 | {3100000, DIF_BPF_COEFF2223, 0x06090361}, | ||
72 | {3100000, DIF_BPF_COEFF2425, 0xff99fb39}, | ||
73 | {3100000, DIF_BPF_COEFF2627, 0xf6fef3b6}, | ||
74 | {3100000, DIF_BPF_COEFF2829, 0xf21af2a5}, | ||
75 | {3100000, DIF_BPF_COEFF3031, 0xf573fa33}, | ||
76 | {3100000, DIF_BPF_COEFF3233, 0x0034067d}, | ||
77 | {3100000, DIF_BPF_COEFF3435, 0x0bfb0fb9}, | ||
78 | {3100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
79 | /* END - DIF BPF register values from 31_quant.dat*/ | ||
80 | |||
81 | |||
82 | /*case 3200000:*/ | ||
83 | /* BEGIN - DIF BPF register values from 32_quant.dat*/ | ||
84 | {3200000, DIF_BPF_COEFF01, 0x00000000}, | ||
85 | {3200000, DIF_BPF_COEFF23, 0x0004000e}, | ||
86 | {3200000, DIF_BPF_COEFF45, 0x00200038}, | ||
87 | {3200000, DIF_BPF_COEFF67, 0x004c004f}, | ||
88 | {3200000, DIF_BPF_COEFF89, 0x002fffdf}, | ||
89 | {3200000, DIF_BPF_COEFF1011, 0xff5cfeb6}, | ||
90 | {3200000, DIF_BPF_COEFF1213, 0xfe0dfd92}, | ||
91 | {3200000, DIF_BPF_COEFF1415, 0xfd7ffe03}, | ||
92 | {3200000, DIF_BPF_COEFF1617, 0xff36010a}, | ||
93 | {3200000, DIF_BPF_COEFF1819, 0x03410575}, | ||
94 | {3200000, DIF_BPF_COEFF2021, 0x072607d2}, | ||
95 | {3200000, DIF_BPF_COEFF2223, 0x071804d5}, | ||
96 | {3200000, DIF_BPF_COEFF2425, 0x0134fcb7}, | ||
97 | {3200000, DIF_BPF_COEFF2627, 0xf81ff451}, | ||
98 | {3200000, DIF_BPF_COEFF2829, 0xf223f22e}, | ||
99 | {3200000, DIF_BPF_COEFF3031, 0xf4a7f94b}, | ||
100 | {3200000, DIF_BPF_COEFF3233, 0xff6405e8}, | ||
101 | {3200000, DIF_BPF_COEFF3435, 0x0bae0fa4}, | ||
102 | {3200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
103 | /* END - DIF BPF register values from 32_quant.dat*/ | ||
104 | |||
105 | |||
106 | /*case 3300000:*/ | ||
107 | /* BEGIN - DIF BPF register values from 33_quant.dat*/ | ||
108 | {3300000, DIF_BPF_COEFF01, 0x0000ffff}, | ||
109 | {3300000, DIF_BPF_COEFF23, 0x00000008}, | ||
110 | {3300000, DIF_BPF_COEFF45, 0x001a0036}, | ||
111 | {3300000, DIF_BPF_COEFF67, 0x0056006d}, | ||
112 | {3300000, DIF_BPF_COEFF89, 0x00670030}, | ||
113 | {3300000, DIF_BPF_COEFF1011, 0xffbdff10}, | ||
114 | {3300000, DIF_BPF_COEFF1213, 0xfe46fd8d}, | ||
115 | {3300000, DIF_BPF_COEFF1415, 0xfd25fd4f}, | ||
116 | {3300000, DIF_BPF_COEFF1617, 0xfe35ffe0}, | ||
117 | {3300000, DIF_BPF_COEFF1819, 0x0224049f}, | ||
118 | {3300000, DIF_BPF_COEFF2021, 0x06c9080e}, | ||
119 | {3300000, DIF_BPF_COEFF2223, 0x07ef0627}, | ||
120 | {3300000, DIF_BPF_COEFF2425, 0x02c9fe45}, | ||
121 | {3300000, DIF_BPF_COEFF2627, 0xf961f513}, | ||
122 | {3300000, DIF_BPF_COEFF2829, 0xf250f1d2}, | ||
123 | {3300000, DIF_BPF_COEFF3031, 0xf3ecf869}, | ||
124 | {3300000, DIF_BPF_COEFF3233, 0xfe930552}, | ||
125 | {3300000, DIF_BPF_COEFF3435, 0x0b5f0f8f}, | ||
126 | {3300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
127 | /* END - DIF BPF register values from 33_quant.dat*/ | ||
128 | |||
129 | |||
130 | /*case 3400000:*/ | ||
131 | /* BEGIN - DIF BPF register values from 34_quant.dat*/ | ||
132 | {3400000, DIF_BPF_COEFF01, 0xfffffffe}, | ||
133 | {3400000, DIF_BPF_COEFF23, 0xfffd0001}, | ||
134 | {3400000, DIF_BPF_COEFF45, 0x000f002c}, | ||
135 | {3400000, DIF_BPF_COEFF67, 0x0054007d}, | ||
136 | {3400000, DIF_BPF_COEFF89, 0x0093007c}, | ||
137 | {3400000, DIF_BPF_COEFF1011, 0x0024ff82}, | ||
138 | {3400000, DIF_BPF_COEFF1213, 0xfea6fdbb}, | ||
139 | {3400000, DIF_BPF_COEFF1415, 0xfd03fcca}, | ||
140 | {3400000, DIF_BPF_COEFF1617, 0xfd51feb9}, | ||
141 | {3400000, DIF_BPF_COEFF1819, 0x00eb0392}, | ||
142 | {3400000, DIF_BPF_COEFF2021, 0x06270802}, | ||
143 | {3400000, DIF_BPF_COEFF2223, 0x08880750}, | ||
144 | {3400000, DIF_BPF_COEFF2425, 0x044dffdb}, | ||
145 | {3400000, DIF_BPF_COEFF2627, 0xfabdf5f8}, | ||
146 | {3400000, DIF_BPF_COEFF2829, 0xf2a0f193}, | ||
147 | {3400000, DIF_BPF_COEFF3031, 0xf342f78f}, | ||
148 | {3400000, DIF_BPF_COEFF3233, 0xfdc404b9}, | ||
149 | {3400000, DIF_BPF_COEFF3435, 0x0b0e0f78}, | ||
150 | {3400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
151 | /* END - DIF BPF register values from 34_quant.dat*/ | ||
152 | |||
153 | |||
154 | /*case 3500000:*/ | ||
155 | /* BEGIN - DIF BPF register values from 35_quant.dat*/ | ||
156 | {3500000, DIF_BPF_COEFF01, 0xfffffffd}, | ||
157 | {3500000, DIF_BPF_COEFF23, 0xfffafff9}, | ||
158 | {3500000, DIF_BPF_COEFF45, 0x0002001b}, | ||
159 | {3500000, DIF_BPF_COEFF67, 0x0046007d}, | ||
160 | {3500000, DIF_BPF_COEFF89, 0x00ad00ba}, | ||
161 | {3500000, DIF_BPF_COEFF1011, 0x00870000}, | ||
162 | {3500000, DIF_BPF_COEFF1213, 0xff26fe1a}, | ||
163 | {3500000, DIF_BPF_COEFF1415, 0xfd1bfc7e}, | ||
164 | {3500000, DIF_BPF_COEFF1617, 0xfc99fda4}, | ||
165 | {3500000, DIF_BPF_COEFF1819, 0xffa5025c}, | ||
166 | {3500000, DIF_BPF_COEFF2021, 0x054507ad}, | ||
167 | {3500000, DIF_BPF_COEFF2223, 0x08dd0847}, | ||
168 | {3500000, DIF_BPF_COEFF2425, 0x05b80172}, | ||
169 | {3500000, DIF_BPF_COEFF2627, 0xfc2ef6ff}, | ||
170 | {3500000, DIF_BPF_COEFF2829, 0xf313f170}, | ||
171 | {3500000, DIF_BPF_COEFF3031, 0xf2abf6bd}, | ||
172 | {3500000, DIF_BPF_COEFF3233, 0xfcf6041f}, | ||
173 | {3500000, DIF_BPF_COEFF3435, 0x0abc0f61}, | ||
174 | {3500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
175 | /* END - DIF BPF register values from 35_quant.dat*/ | ||
176 | |||
177 | |||
178 | /*case 3600000:*/ | ||
179 | /* BEGIN - DIF BPF register values from 36_quant.dat*/ | ||
180 | {3600000, DIF_BPF_COEFF01, 0xfffffffd}, | ||
181 | {3600000, DIF_BPF_COEFF23, 0xfff8fff3}, | ||
182 | {3600000, DIF_BPF_COEFF45, 0xfff50006}, | ||
183 | {3600000, DIF_BPF_COEFF67, 0x002f006c}, | ||
184 | {3600000, DIF_BPF_COEFF89, 0x00b200e3}, | ||
185 | {3600000, DIF_BPF_COEFF1011, 0x00dc007e}, | ||
186 | {3600000, DIF_BPF_COEFF1213, 0xffb9fea0}, | ||
187 | {3600000, DIF_BPF_COEFF1415, 0xfd6bfc71}, | ||
188 | {3600000, DIF_BPF_COEFF1617, 0xfc17fcb1}, | ||
189 | {3600000, DIF_BPF_COEFF1819, 0xfe65010b}, | ||
190 | {3600000, DIF_BPF_COEFF2021, 0x042d0713}, | ||
191 | {3600000, DIF_BPF_COEFF2223, 0x08ec0906}, | ||
192 | {3600000, DIF_BPF_COEFF2425, 0x07020302}, | ||
193 | {3600000, DIF_BPF_COEFF2627, 0xfdaff823}, | ||
194 | {3600000, DIF_BPF_COEFF2829, 0xf3a7f16a}, | ||
195 | {3600000, DIF_BPF_COEFF3031, 0xf228f5f5}, | ||
196 | {3600000, DIF_BPF_COEFF3233, 0xfc2a0384}, | ||
197 | {3600000, DIF_BPF_COEFF3435, 0x0a670f4a}, | ||
198 | {3600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
199 | /* END - DIF BPF register values from 36_quant.dat*/ | ||
200 | |||
201 | |||
202 | /*case 3700000:*/ | ||
203 | /* BEGIN - DIF BPF register values from 37_quant.dat*/ | ||
204 | {3700000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
205 | {3700000, DIF_BPF_COEFF23, 0xfff7ffef}, | ||
206 | {3700000, DIF_BPF_COEFF45, 0xffe9fff1}, | ||
207 | {3700000, DIF_BPF_COEFF67, 0x0010004d}, | ||
208 | {3700000, DIF_BPF_COEFF89, 0x00a100f2}, | ||
209 | {3700000, DIF_BPF_COEFF1011, 0x011a00f0}, | ||
210 | {3700000, DIF_BPF_COEFF1213, 0x0053ff44}, | ||
211 | {3700000, DIF_BPF_COEFF1415, 0xfdedfca2}, | ||
212 | {3700000, DIF_BPF_COEFF1617, 0xfbd3fbef}, | ||
213 | {3700000, DIF_BPF_COEFF1819, 0xfd39ffae}, | ||
214 | {3700000, DIF_BPF_COEFF2021, 0x02ea0638}, | ||
215 | {3700000, DIF_BPF_COEFF2223, 0x08b50987}, | ||
216 | {3700000, DIF_BPF_COEFF2425, 0x08230483}, | ||
217 | {3700000, DIF_BPF_COEFF2627, 0xff39f960}, | ||
218 | {3700000, DIF_BPF_COEFF2829, 0xf45bf180}, | ||
219 | {3700000, DIF_BPF_COEFF3031, 0xf1b8f537}, | ||
220 | {3700000, DIF_BPF_COEFF3233, 0xfb6102e7}, | ||
221 | {3700000, DIF_BPF_COEFF3435, 0x0a110f32}, | ||
222 | {3700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
223 | /* END - DIF BPF register values from 37_quant.dat*/ | ||
224 | |||
225 | |||
226 | /*case 3800000:*/ | ||
227 | /* BEGIN - DIF BPF register values from 38_quant.dat*/ | ||
228 | {3800000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
229 | {3800000, DIF_BPF_COEFF23, 0xfff9ffee}, | ||
230 | {3800000, DIF_BPF_COEFF45, 0xffe1ffdd}, | ||
231 | {3800000, DIF_BPF_COEFF67, 0xfff00024}, | ||
232 | {3800000, DIF_BPF_COEFF89, 0x007c00e5}, | ||
233 | {3800000, DIF_BPF_COEFF1011, 0x013a014a}, | ||
234 | {3800000, DIF_BPF_COEFF1213, 0x00e6fff8}, | ||
235 | {3800000, DIF_BPF_COEFF1415, 0xfe98fd0f}, | ||
236 | {3800000, DIF_BPF_COEFF1617, 0xfbd3fb67}, | ||
237 | {3800000, DIF_BPF_COEFF1819, 0xfc32fe54}, | ||
238 | {3800000, DIF_BPF_COEFF2021, 0x01880525}, | ||
239 | {3800000, DIF_BPF_COEFF2223, 0x083909c7}, | ||
240 | {3800000, DIF_BPF_COEFF2425, 0x091505ee}, | ||
241 | {3800000, DIF_BPF_COEFF2627, 0x00c7fab3}, | ||
242 | {3800000, DIF_BPF_COEFF2829, 0xf52df1b4}, | ||
243 | {3800000, DIF_BPF_COEFF3031, 0xf15df484}, | ||
244 | {3800000, DIF_BPF_COEFF3233, 0xfa9b0249}, | ||
245 | {3800000, DIF_BPF_COEFF3435, 0x09ba0f19}, | ||
246 | {3800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
247 | /* END - DIF BPF register values from 38_quant.dat*/ | ||
248 | |||
249 | |||
250 | /*case 3900000:*/ | ||
251 | /* BEGIN - DIF BPF register values from 39_quant.dat*/ | ||
252 | {3900000, DIF_BPF_COEFF01, 0x00000000}, | ||
253 | {3900000, DIF_BPF_COEFF23, 0xfffbfff0}, | ||
254 | {3900000, DIF_BPF_COEFF45, 0xffdeffcf}, | ||
255 | {3900000, DIF_BPF_COEFF67, 0xffd1fff6}, | ||
256 | {3900000, DIF_BPF_COEFF89, 0x004800be}, | ||
257 | {3900000, DIF_BPF_COEFF1011, 0x01390184}, | ||
258 | {3900000, DIF_BPF_COEFF1213, 0x016300ac}, | ||
259 | {3900000, DIF_BPF_COEFF1415, 0xff5efdb1}, | ||
260 | {3900000, DIF_BPF_COEFF1617, 0xfc17fb23}, | ||
261 | {3900000, DIF_BPF_COEFF1819, 0xfb5cfd0d}, | ||
262 | {3900000, DIF_BPF_COEFF2021, 0x001703e4}, | ||
263 | {3900000, DIF_BPF_COEFF2223, 0x077b09c4}, | ||
264 | {3900000, DIF_BPF_COEFF2425, 0x09d2073c}, | ||
265 | {3900000, DIF_BPF_COEFF2627, 0x0251fc18}, | ||
266 | {3900000, DIF_BPF_COEFF2829, 0xf61cf203}, | ||
267 | {3900000, DIF_BPF_COEFF3031, 0xf118f3dc}, | ||
268 | {3900000, DIF_BPF_COEFF3233, 0xf9d801aa}, | ||
269 | {3900000, DIF_BPF_COEFF3435, 0x09600eff}, | ||
270 | {3900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
271 | /* END - DIF BPF register values from 39_quant.dat*/ | ||
272 | |||
273 | |||
274 | /*case 4000000:*/ | ||
275 | /* BEGIN - DIF BPF register values from 40_quant.dat*/ | ||
276 | {4000000, DIF_BPF_COEFF01, 0x00000001}, | ||
277 | {4000000, DIF_BPF_COEFF23, 0xfffefff4}, | ||
278 | {4000000, DIF_BPF_COEFF45, 0xffe1ffc8}, | ||
279 | {4000000, DIF_BPF_COEFF67, 0xffbaffca}, | ||
280 | {4000000, DIF_BPF_COEFF89, 0x000b0082}, | ||
281 | {4000000, DIF_BPF_COEFF1011, 0x01170198}, | ||
282 | {4000000, DIF_BPF_COEFF1213, 0x01c10152}, | ||
283 | {4000000, DIF_BPF_COEFF1415, 0x0030fe7b}, | ||
284 | {4000000, DIF_BPF_COEFF1617, 0xfc99fb24}, | ||
285 | {4000000, DIF_BPF_COEFF1819, 0xfac3fbe9}, | ||
286 | {4000000, DIF_BPF_COEFF2021, 0xfea5027f}, | ||
287 | {4000000, DIF_BPF_COEFF2223, 0x0683097f}, | ||
288 | {4000000, DIF_BPF_COEFF2425, 0x0a560867}, | ||
289 | {4000000, DIF_BPF_COEFF2627, 0x03d2fd89}, | ||
290 | {4000000, DIF_BPF_COEFF2829, 0xf723f26f}, | ||
291 | {4000000, DIF_BPF_COEFF3031, 0xf0e8f341}, | ||
292 | {4000000, DIF_BPF_COEFF3233, 0xf919010a}, | ||
293 | {4000000, DIF_BPF_COEFF3435, 0x09060ee5}, | ||
294 | {4000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
295 | /* END - DIF BPF register values from 40_quant.dat*/ | ||
296 | |||
297 | |||
298 | /*case 4100000:*/ | ||
299 | /* BEGIN - DIF BPF register values from 41_quant.dat*/ | ||
300 | {4100000, DIF_BPF_COEFF01, 0x00010002}, | ||
301 | {4100000, DIF_BPF_COEFF23, 0x0002fffb}, | ||
302 | {4100000, DIF_BPF_COEFF45, 0xffe8ffca}, | ||
303 | {4100000, DIF_BPF_COEFF67, 0xffacffa4}, | ||
304 | {4100000, DIF_BPF_COEFF89, 0xffcd0036}, | ||
305 | {4100000, DIF_BPF_COEFF1011, 0x00d70184}, | ||
306 | {4100000, DIF_BPF_COEFF1213, 0x01f601dc}, | ||
307 | {4100000, DIF_BPF_COEFF1415, 0x00ffff60}, | ||
308 | {4100000, DIF_BPF_COEFF1617, 0xfd51fb6d}, | ||
309 | {4100000, DIF_BPF_COEFF1819, 0xfa6efaf5}, | ||
310 | {4100000, DIF_BPF_COEFF2021, 0xfd410103}, | ||
311 | {4100000, DIF_BPF_COEFF2223, 0x055708f9}, | ||
312 | {4100000, DIF_BPF_COEFF2425, 0x0a9e0969}, | ||
313 | {4100000, DIF_BPF_COEFF2627, 0x0543ff02}, | ||
314 | {4100000, DIF_BPF_COEFF2829, 0xf842f2f5}, | ||
315 | {4100000, DIF_BPF_COEFF3031, 0xf0cef2b2}, | ||
316 | {4100000, DIF_BPF_COEFF3233, 0xf85e006b}, | ||
317 | {4100000, DIF_BPF_COEFF3435, 0x08aa0ecb}, | ||
318 | {4100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
319 | /* END - DIF BPF register values from 41_quant.dat*/ | ||
320 | |||
321 | |||
322 | /*case 4200000:*/ | ||
323 | /* BEGIN - DIF BPF register values from 42_quant.dat*/ | ||
324 | {4200000, DIF_BPF_COEFF01, 0x00010003}, | ||
325 | {4200000, DIF_BPF_COEFF23, 0x00050003}, | ||
326 | {4200000, DIF_BPF_COEFF45, 0xfff3ffd3}, | ||
327 | {4200000, DIF_BPF_COEFF67, 0xffaaff8b}, | ||
328 | {4200000, DIF_BPF_COEFF89, 0xff95ffe5}, | ||
329 | {4200000, DIF_BPF_COEFF1011, 0x0080014a}, | ||
330 | {4200000, DIF_BPF_COEFF1213, 0x01fe023f}, | ||
331 | {4200000, DIF_BPF_COEFF1415, 0x01ba0050}, | ||
332 | {4200000, DIF_BPF_COEFF1617, 0xfe35fbf8}, | ||
333 | {4200000, DIF_BPF_COEFF1819, 0xfa62fa3b}, | ||
334 | {4200000, DIF_BPF_COEFF2021, 0xfbf9ff7e}, | ||
335 | {4200000, DIF_BPF_COEFF2223, 0x04010836}, | ||
336 | {4200000, DIF_BPF_COEFF2425, 0x0aa90a3d}, | ||
337 | {4200000, DIF_BPF_COEFF2627, 0x069f007f}, | ||
338 | {4200000, DIF_BPF_COEFF2829, 0xf975f395}, | ||
339 | {4200000, DIF_BPF_COEFF3031, 0xf0cbf231}, | ||
340 | {4200000, DIF_BPF_COEFF3233, 0xf7a9ffcb}, | ||
341 | {4200000, DIF_BPF_COEFF3435, 0x084c0eaf}, | ||
342 | {4200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
343 | /* END - DIF BPF register values from 42_quant.dat*/ | ||
344 | |||
345 | |||
346 | /*case 4300000:*/ | ||
347 | /* BEGIN - DIF BPF register values from 43_quant.dat*/ | ||
348 | {4300000, DIF_BPF_COEFF01, 0x00010003}, | ||
349 | {4300000, DIF_BPF_COEFF23, 0x0008000a}, | ||
350 | {4300000, DIF_BPF_COEFF45, 0x0000ffe4}, | ||
351 | {4300000, DIF_BPF_COEFF67, 0xffb4ff81}, | ||
352 | {4300000, DIF_BPF_COEFF89, 0xff6aff96}, | ||
353 | {4300000, DIF_BPF_COEFF1011, 0x001c00f0}, | ||
354 | {4300000, DIF_BPF_COEFF1213, 0x01d70271}, | ||
355 | {4300000, DIF_BPF_COEFF1415, 0x0254013b}, | ||
356 | {4300000, DIF_BPF_COEFF1617, 0xff36fcbd}, | ||
357 | {4300000, DIF_BPF_COEFF1819, 0xfa9ff9c5}, | ||
358 | {4300000, DIF_BPF_COEFF2021, 0xfadbfdfe}, | ||
359 | {4300000, DIF_BPF_COEFF2223, 0x028c073b}, | ||
360 | {4300000, DIF_BPF_COEFF2425, 0x0a750adf}, | ||
361 | {4300000, DIF_BPF_COEFF2627, 0x07e101fa}, | ||
362 | {4300000, DIF_BPF_COEFF2829, 0xfab8f44e}, | ||
363 | {4300000, DIF_BPF_COEFF3031, 0xf0ddf1be}, | ||
364 | {4300000, DIF_BPF_COEFF3233, 0xf6f9ff2b}, | ||
365 | {4300000, DIF_BPF_COEFF3435, 0x07ed0e94}, | ||
366 | {4300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
367 | /* END - DIF BPF register values from 43_quant.dat*/ | ||
368 | |||
369 | |||
370 | /*case 4400000:*/ | ||
371 | /* BEGIN - DIF BPF register values from 44_quant.dat*/ | ||
372 | {4400000, DIF_BPF_COEFF01, 0x00000003}, | ||
373 | {4400000, DIF_BPF_COEFF23, 0x0009000f}, | ||
374 | {4400000, DIF_BPF_COEFF45, 0x000efff8}, | ||
375 | {4400000, DIF_BPF_COEFF67, 0xffc9ff87}, | ||
376 | {4400000, DIF_BPF_COEFF89, 0xff52ff54}, | ||
377 | {4400000, DIF_BPF_COEFF1011, 0xffb5007e}, | ||
378 | {4400000, DIF_BPF_COEFF1213, 0x01860270}, | ||
379 | {4400000, DIF_BPF_COEFF1415, 0x02c00210}, | ||
380 | {4400000, DIF_BPF_COEFF1617, 0x0044fdb2}, | ||
381 | {4400000, DIF_BPF_COEFF1819, 0xfb22f997}, | ||
382 | {4400000, DIF_BPF_COEFF2021, 0xf9f2fc90}, | ||
383 | {4400000, DIF_BPF_COEFF2223, 0x0102060f}, | ||
384 | {4400000, DIF_BPF_COEFF2425, 0x0a050b4c}, | ||
385 | {4400000, DIF_BPF_COEFF2627, 0x0902036e}, | ||
386 | {4400000, DIF_BPF_COEFF2829, 0xfc0af51e}, | ||
387 | {4400000, DIF_BPF_COEFF3031, 0xf106f15a}, | ||
388 | {4400000, DIF_BPF_COEFF3233, 0xf64efe8b}, | ||
389 | {4400000, DIF_BPF_COEFF3435, 0x078d0e77}, | ||
390 | {4400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
391 | /* END - DIF BPF register values from 44_quant.dat*/ | ||
392 | |||
393 | |||
394 | /*case 4500000:*/ | ||
395 | /* BEGIN - DIF BPF register values from 45_quant.dat*/ | ||
396 | {4500000, DIF_BPF_COEFF01, 0x00000002}, | ||
397 | {4500000, DIF_BPF_COEFF23, 0x00080012}, | ||
398 | {4500000, DIF_BPF_COEFF45, 0x0019000e}, | ||
399 | {4500000, DIF_BPF_COEFF67, 0xffe5ff9e}, | ||
400 | {4500000, DIF_BPF_COEFF89, 0xff4fff25}, | ||
401 | {4500000, DIF_BPF_COEFF1011, 0xff560000}, | ||
402 | {4500000, DIF_BPF_COEFF1213, 0x0112023b}, | ||
403 | {4500000, DIF_BPF_COEFF1415, 0x02f702c0}, | ||
404 | {4500000, DIF_BPF_COEFF1617, 0x014dfec8}, | ||
405 | {4500000, DIF_BPF_COEFF1819, 0xfbe5f9b3}, | ||
406 | {4500000, DIF_BPF_COEFF2021, 0xf947fb41}, | ||
407 | {4500000, DIF_BPF_COEFF2223, 0xff7004b9}, | ||
408 | {4500000, DIF_BPF_COEFF2425, 0x095a0b81}, | ||
409 | {4500000, DIF_BPF_COEFF2627, 0x0a0004d8}, | ||
410 | {4500000, DIF_BPF_COEFF2829, 0xfd65f603}, | ||
411 | {4500000, DIF_BPF_COEFF3031, 0xf144f104}, | ||
412 | {4500000, DIF_BPF_COEFF3233, 0xf5aafdec}, | ||
413 | {4500000, DIF_BPF_COEFF3435, 0x072b0e5a}, | ||
414 | {4500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
415 | /* END - DIF BPF register values from 45_quant.dat*/ | ||
416 | |||
417 | |||
418 | /*case 4600000:*/ | ||
419 | /* BEGIN - DIF BPF register values from 46_quant.dat*/ | ||
420 | {4600000, DIF_BPF_COEFF01, 0x00000001}, | ||
421 | {4600000, DIF_BPF_COEFF23, 0x00060012}, | ||
422 | {4600000, DIF_BPF_COEFF45, 0x00200022}, | ||
423 | {4600000, DIF_BPF_COEFF67, 0x0005ffc1}, | ||
424 | {4600000, DIF_BPF_COEFF89, 0xff61ff10}, | ||
425 | {4600000, DIF_BPF_COEFF1011, 0xff09ff82}, | ||
426 | {4600000, DIF_BPF_COEFF1213, 0x008601d7}, | ||
427 | {4600000, DIF_BPF_COEFF1415, 0x02f50340}, | ||
428 | {4600000, DIF_BPF_COEFF1617, 0x0241fff0}, | ||
429 | {4600000, DIF_BPF_COEFF1819, 0xfcddfa19}, | ||
430 | {4600000, DIF_BPF_COEFF2021, 0xf8e2fa1e}, | ||
431 | {4600000, DIF_BPF_COEFF2223, 0xfde30343}, | ||
432 | {4600000, DIF_BPF_COEFF2425, 0x08790b7f}, | ||
433 | {4600000, DIF_BPF_COEFF2627, 0x0ad50631}, | ||
434 | {4600000, DIF_BPF_COEFF2829, 0xfec7f6fc}, | ||
435 | {4600000, DIF_BPF_COEFF3031, 0xf198f0bd}, | ||
436 | {4600000, DIF_BPF_COEFF3233, 0xf50dfd4e}, | ||
437 | {4600000, DIF_BPF_COEFF3435, 0x06c90e3d}, | ||
438 | {4600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
439 | /* END - DIF BPF register values from 46_quant.dat*/ | ||
440 | |||
441 | |||
442 | /*case 4700000:*/ | ||
443 | /* BEGIN - DIF BPF register values from 47_quant.dat*/ | ||
444 | {4700000, DIF_BPF_COEFF01, 0x0000ffff}, | ||
445 | {4700000, DIF_BPF_COEFF23, 0x0003000f}, | ||
446 | {4700000, DIF_BPF_COEFF45, 0x00220030}, | ||
447 | {4700000, DIF_BPF_COEFF67, 0x0025ffed}, | ||
448 | {4700000, DIF_BPF_COEFF89, 0xff87ff15}, | ||
449 | {4700000, DIF_BPF_COEFF1011, 0xfed6ff10}, | ||
450 | {4700000, DIF_BPF_COEFF1213, 0xffed014c}, | ||
451 | {4700000, DIF_BPF_COEFF1415, 0x02b90386}, | ||
452 | {4700000, DIF_BPF_COEFF1617, 0x03110119}, | ||
453 | {4700000, DIF_BPF_COEFF1819, 0xfdfefac4}, | ||
454 | {4700000, DIF_BPF_COEFF2021, 0xf8c6f92f}, | ||
455 | {4700000, DIF_BPF_COEFF2223, 0xfc6701b7}, | ||
456 | {4700000, DIF_BPF_COEFF2425, 0x07670b44}, | ||
457 | {4700000, DIF_BPF_COEFF2627, 0x0b7e0776}, | ||
458 | {4700000, DIF_BPF_COEFF2829, 0x002df807}, | ||
459 | {4700000, DIF_BPF_COEFF3031, 0xf200f086}, | ||
460 | {4700000, DIF_BPF_COEFF3233, 0xf477fcb1}, | ||
461 | {4700000, DIF_BPF_COEFF3435, 0x06650e1e}, | ||
462 | {4700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
463 | /* END - DIF BPF register values from 47_quant.dat*/ | ||
464 | |||
465 | |||
466 | /*case 4800000:*/ | ||
467 | /* BEGIN - DIF BPF register values from 48_quant.dat*/ | ||
468 | {4800000, DIF_BPF_COEFF01, 0xfffffffe}, | ||
469 | {4800000, DIF_BPF_COEFF23, 0xffff0009}, | ||
470 | {4800000, DIF_BPF_COEFF45, 0x001e0038}, | ||
471 | {4800000, DIF_BPF_COEFF67, 0x003f001b}, | ||
472 | {4800000, DIF_BPF_COEFF89, 0xffbcff36}, | ||
473 | {4800000, DIF_BPF_COEFF1011, 0xfec2feb6}, | ||
474 | {4800000, DIF_BPF_COEFF1213, 0xff5600a5}, | ||
475 | {4800000, DIF_BPF_COEFF1415, 0x0248038d}, | ||
476 | {4800000, DIF_BPF_COEFF1617, 0x03b00232}, | ||
477 | {4800000, DIF_BPF_COEFF1819, 0xff39fbab}, | ||
478 | {4800000, DIF_BPF_COEFF2021, 0xf8f4f87f}, | ||
479 | {4800000, DIF_BPF_COEFF2223, 0xfb060020}, | ||
480 | {4800000, DIF_BPF_COEFF2425, 0x062a0ad2}, | ||
481 | {4800000, DIF_BPF_COEFF2627, 0x0bf908a3}, | ||
482 | {4800000, DIF_BPF_COEFF2829, 0x0192f922}, | ||
483 | {4800000, DIF_BPF_COEFF3031, 0xf27df05e}, | ||
484 | {4800000, DIF_BPF_COEFF3233, 0xf3e8fc14}, | ||
485 | {4800000, DIF_BPF_COEFF3435, 0x06000e00}, | ||
486 | {4800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
487 | /* END - DIF BPF register values from 48_quant.dat*/ | ||
488 | |||
489 | |||
490 | /*case 4900000:*/ | ||
491 | /* BEGIN - DIF BPF register values from 49_quant.dat*/ | ||
492 | {4900000, DIF_BPF_COEFF01, 0xfffffffd}, | ||
493 | {4900000, DIF_BPF_COEFF23, 0xfffc0002}, | ||
494 | {4900000, DIF_BPF_COEFF45, 0x00160037}, | ||
495 | {4900000, DIF_BPF_COEFF67, 0x00510046}, | ||
496 | {4900000, DIF_BPF_COEFF89, 0xfff9ff6d}, | ||
497 | {4900000, DIF_BPF_COEFF1011, 0xfed0fe7c}, | ||
498 | {4900000, DIF_BPF_COEFF1213, 0xfecefff0}, | ||
499 | {4900000, DIF_BPF_COEFF1415, 0x01aa0356}, | ||
500 | {4900000, DIF_BPF_COEFF1617, 0x0413032b}, | ||
501 | {4900000, DIF_BPF_COEFF1819, 0x007ffcc5}, | ||
502 | {4900000, DIF_BPF_COEFF2021, 0xf96cf812}, | ||
503 | {4900000, DIF_BPF_COEFF2223, 0xf9cefe87}, | ||
504 | {4900000, DIF_BPF_COEFF2425, 0x04c90a2c}, | ||
505 | {4900000, DIF_BPF_COEFF2627, 0x0c4309b4}, | ||
506 | {4900000, DIF_BPF_COEFF2829, 0x02f3fa4a}, | ||
507 | {4900000, DIF_BPF_COEFF3031, 0xf30ef046}, | ||
508 | {4900000, DIF_BPF_COEFF3233, 0xf361fb7a}, | ||
509 | {4900000, DIF_BPF_COEFF3435, 0x059b0de0}, | ||
510 | {4900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
511 | /* END - DIF BPF register values from 49_quant.dat*/ | ||
512 | |||
513 | |||
514 | /*case 5000000:*/ | ||
515 | /* BEGIN - DIF BPF register values from 50_quant.dat*/ | ||
516 | {5000000, DIF_BPF_COEFF01, 0xfffffffd}, | ||
517 | {5000000, DIF_BPF_COEFF23, 0xfff9fffa}, | ||
518 | {5000000, DIF_BPF_COEFF45, 0x000a002d}, | ||
519 | {5000000, DIF_BPF_COEFF67, 0x00570067}, | ||
520 | {5000000, DIF_BPF_COEFF89, 0x0037ffb5}, | ||
521 | {5000000, DIF_BPF_COEFF1011, 0xfefffe68}, | ||
522 | {5000000, DIF_BPF_COEFF1213, 0xfe62ff3d}, | ||
523 | {5000000, DIF_BPF_COEFF1415, 0x00ec02e3}, | ||
524 | {5000000, DIF_BPF_COEFF1617, 0x043503f6}, | ||
525 | {5000000, DIF_BPF_COEFF1819, 0x01befe05}, | ||
526 | {5000000, DIF_BPF_COEFF2021, 0xfa27f7ee}, | ||
527 | {5000000, DIF_BPF_COEFF2223, 0xf8c6fcf8}, | ||
528 | {5000000, DIF_BPF_COEFF2425, 0x034c0954}, | ||
529 | {5000000, DIF_BPF_COEFF2627, 0x0c5c0aa4}, | ||
530 | {5000000, DIF_BPF_COEFF2829, 0x044cfb7e}, | ||
531 | {5000000, DIF_BPF_COEFF3031, 0xf3b1f03f}, | ||
532 | {5000000, DIF_BPF_COEFF3233, 0xf2e2fae1}, | ||
533 | {5000000, DIF_BPF_COEFF3435, 0x05340dc0}, | ||
534 | {5000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
535 | /* END - DIF BPF register values from 50_quant.dat*/ | ||
536 | |||
537 | |||
538 | /*case 5100000:*/ | ||
539 | /* BEGIN - DIF BPF register values from 51_quant.dat*/ | ||
540 | {5100000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
541 | {5100000, DIF_BPF_COEFF23, 0xfff8fff4}, | ||
542 | {5100000, DIF_BPF_COEFF45, 0xfffd001e}, | ||
543 | {5100000, DIF_BPF_COEFF67, 0x0051007b}, | ||
544 | {5100000, DIF_BPF_COEFF89, 0x006e0006}, | ||
545 | {5100000, DIF_BPF_COEFF1011, 0xff48fe7c}, | ||
546 | {5100000, DIF_BPF_COEFF1213, 0xfe1bfe9a}, | ||
547 | {5100000, DIF_BPF_COEFF1415, 0x001d023e}, | ||
548 | {5100000, DIF_BPF_COEFF1617, 0x04130488}, | ||
549 | {5100000, DIF_BPF_COEFF1819, 0x02e6ff5b}, | ||
550 | {5100000, DIF_BPF_COEFF2021, 0xfb1ef812}, | ||
551 | {5100000, DIF_BPF_COEFF2223, 0xf7f7fb7f}, | ||
552 | {5100000, DIF_BPF_COEFF2425, 0x01bc084e}, | ||
553 | {5100000, DIF_BPF_COEFF2627, 0x0c430b72}, | ||
554 | {5100000, DIF_BPF_COEFF2829, 0x059afcba}, | ||
555 | {5100000, DIF_BPF_COEFF3031, 0xf467f046}, | ||
556 | {5100000, DIF_BPF_COEFF3233, 0xf26cfa4a}, | ||
557 | {5100000, DIF_BPF_COEFF3435, 0x04cd0da0}, | ||
558 | {5100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
559 | /* END - DIF BPF register values from 51_quant.dat*/ | ||
560 | |||
561 | |||
562 | /*case 5200000:*/ | ||
563 | /* BEGIN - DIF BPF register values from 52_quant.dat*/ | ||
564 | {5200000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
565 | {5200000, DIF_BPF_COEFF23, 0xfff8ffef}, | ||
566 | {5200000, DIF_BPF_COEFF45, 0xfff00009}, | ||
567 | {5200000, DIF_BPF_COEFF67, 0x003f007f}, | ||
568 | {5200000, DIF_BPF_COEFF89, 0x00980056}, | ||
569 | {5200000, DIF_BPF_COEFF1011, 0xffa5feb6}, | ||
570 | {5200000, DIF_BPF_COEFF1213, 0xfe00fe15}, | ||
571 | {5200000, DIF_BPF_COEFF1415, 0xff4b0170}, | ||
572 | {5200000, DIF_BPF_COEFF1617, 0x03b004d7}, | ||
573 | {5200000, DIF_BPF_COEFF1819, 0x03e800b9}, | ||
574 | {5200000, DIF_BPF_COEFF2021, 0xfc48f87f}, | ||
575 | {5200000, DIF_BPF_COEFF2223, 0xf768fa23}, | ||
576 | {5200000, DIF_BPF_COEFF2425, 0x0022071f}, | ||
577 | {5200000, DIF_BPF_COEFF2627, 0x0bf90c1b}, | ||
578 | {5200000, DIF_BPF_COEFF2829, 0x06dafdfd}, | ||
579 | {5200000, DIF_BPF_COEFF3031, 0xf52df05e}, | ||
580 | {5200000, DIF_BPF_COEFF3233, 0xf1fef9b5}, | ||
581 | {5200000, DIF_BPF_COEFF3435, 0x04640d7f}, | ||
582 | {5200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
583 | /* END - DIF BPF register values from 52_quant.dat*/ | ||
584 | |||
585 | |||
586 | /*case 5300000:*/ | ||
587 | /* BEGIN - DIF BPF register values from 53_quant.dat*/ | ||
588 | {5300000, DIF_BPF_COEFF01, 0x0000ffff}, | ||
589 | {5300000, DIF_BPF_COEFF23, 0xfff9ffee}, | ||
590 | {5300000, DIF_BPF_COEFF45, 0xffe6fff3}, | ||
591 | {5300000, DIF_BPF_COEFF67, 0x00250072}, | ||
592 | {5300000, DIF_BPF_COEFF89, 0x00af009c}, | ||
593 | {5300000, DIF_BPF_COEFF1011, 0x000cff10}, | ||
594 | {5300000, DIF_BPF_COEFF1213, 0xfe13fdb8}, | ||
595 | {5300000, DIF_BPF_COEFF1415, 0xfe870089}, | ||
596 | {5300000, DIF_BPF_COEFF1617, 0x031104e1}, | ||
597 | {5300000, DIF_BPF_COEFF1819, 0x04b8020f}, | ||
598 | {5300000, DIF_BPF_COEFF2021, 0xfd98f92f}, | ||
599 | {5300000, DIF_BPF_COEFF2223, 0xf71df8f0}, | ||
600 | {5300000, DIF_BPF_COEFF2425, 0xfe8805ce}, | ||
601 | {5300000, DIF_BPF_COEFF2627, 0x0b7e0c9c}, | ||
602 | {5300000, DIF_BPF_COEFF2829, 0x0808ff44}, | ||
603 | {5300000, DIF_BPF_COEFF3031, 0xf603f086}, | ||
604 | {5300000, DIF_BPF_COEFF3233, 0xf19af922}, | ||
605 | {5300000, DIF_BPF_COEFF3435, 0x03fb0d5e}, | ||
606 | {5300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
607 | /* END - DIF BPF register values from 53_quant.dat*/ | ||
608 | |||
609 | |||
610 | /*case 5400000:*/ | ||
611 | /* BEGIN - DIF BPF register values from 54_quant.dat*/ | ||
612 | {5400000, DIF_BPF_COEFF01, 0x00000001}, | ||
613 | {5400000, DIF_BPF_COEFF23, 0xfffcffef}, | ||
614 | {5400000, DIF_BPF_COEFF45, 0xffe0ffe0}, | ||
615 | {5400000, DIF_BPF_COEFF67, 0x00050056}, | ||
616 | {5400000, DIF_BPF_COEFF89, 0x00b000d1}, | ||
617 | {5400000, DIF_BPF_COEFF1011, 0x0071ff82}, | ||
618 | {5400000, DIF_BPF_COEFF1213, 0xfe53fd8c}, | ||
619 | {5400000, DIF_BPF_COEFF1415, 0xfddfff99}, | ||
620 | {5400000, DIF_BPF_COEFF1617, 0x024104a3}, | ||
621 | {5400000, DIF_BPF_COEFF1819, 0x054a034d}, | ||
622 | {5400000, DIF_BPF_COEFF2021, 0xff01fa1e}, | ||
623 | {5400000, DIF_BPF_COEFF2223, 0xf717f7ed}, | ||
624 | {5400000, DIF_BPF_COEFF2425, 0xfcf50461}, | ||
625 | {5400000, DIF_BPF_COEFF2627, 0x0ad50cf4}, | ||
626 | {5400000, DIF_BPF_COEFF2829, 0x0921008d}, | ||
627 | {5400000, DIF_BPF_COEFF3031, 0xf6e7f0bd}, | ||
628 | {5400000, DIF_BPF_COEFF3233, 0xf13ff891}, | ||
629 | {5400000, DIF_BPF_COEFF3435, 0x03920d3b}, | ||
630 | {5400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
631 | /* END - DIF BPF register values from 54_quant.dat*/ | ||
632 | |||
633 | |||
634 | /*case 5500000:*/ | ||
635 | /* BEGIN - DIF BPF register values from 55_quant.dat*/ | ||
636 | {5500000, DIF_BPF_COEFF01, 0x00010002}, | ||
637 | {5500000, DIF_BPF_COEFF23, 0xfffffff3}, | ||
638 | {5500000, DIF_BPF_COEFF45, 0xffdeffd1}, | ||
639 | {5500000, DIF_BPF_COEFF67, 0xffe5002f}, | ||
640 | {5500000, DIF_BPF_COEFF89, 0x009c00ed}, | ||
641 | {5500000, DIF_BPF_COEFF1011, 0x00cb0000}, | ||
642 | {5500000, DIF_BPF_COEFF1213, 0xfebafd94}, | ||
643 | {5500000, DIF_BPF_COEFF1415, 0xfd61feb0}, | ||
644 | {5500000, DIF_BPF_COEFF1617, 0x014d0422}, | ||
645 | {5500000, DIF_BPF_COEFF1819, 0x05970464}, | ||
646 | {5500000, DIF_BPF_COEFF2021, 0x0074fb41}, | ||
647 | {5500000, DIF_BPF_COEFF2223, 0xf759f721}, | ||
648 | {5500000, DIF_BPF_COEFF2425, 0xfb7502de}, | ||
649 | {5500000, DIF_BPF_COEFF2627, 0x0a000d21}, | ||
650 | {5500000, DIF_BPF_COEFF2829, 0x0a2201d4}, | ||
651 | {5500000, DIF_BPF_COEFF3031, 0xf7d9f104}, | ||
652 | {5500000, DIF_BPF_COEFF3233, 0xf0edf804}, | ||
653 | {5500000, DIF_BPF_COEFF3435, 0x03280d19}, | ||
654 | {5500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
655 | /* END - DIF BPF register values from 55_quant.dat*/ | ||
656 | |||
657 | |||
658 | /*case 5600000:*/ | ||
659 | /* BEGIN - DIF BPF register values from 56_quant.dat*/ | ||
660 | {5600000, DIF_BPF_COEFF01, 0x00010003}, | ||
661 | {5600000, DIF_BPF_COEFF23, 0x0003fffa}, | ||
662 | {5600000, DIF_BPF_COEFF45, 0xffe3ffc9}, | ||
663 | {5600000, DIF_BPF_COEFF67, 0xffc90002}, | ||
664 | {5600000, DIF_BPF_COEFF89, 0x007500ef}, | ||
665 | {5600000, DIF_BPF_COEFF1011, 0x010e007e}, | ||
666 | {5600000, DIF_BPF_COEFF1213, 0xff3dfdcf}, | ||
667 | {5600000, DIF_BPF_COEFF1415, 0xfd16fddd}, | ||
668 | {5600000, DIF_BPF_COEFF1617, 0x00440365}, | ||
669 | {5600000, DIF_BPF_COEFF1819, 0x059b0548}, | ||
670 | {5600000, DIF_BPF_COEFF2021, 0x01e3fc90}, | ||
671 | {5600000, DIF_BPF_COEFF2223, 0xf7dff691}, | ||
672 | {5600000, DIF_BPF_COEFF2425, 0xfa0f014d}, | ||
673 | {5600000, DIF_BPF_COEFF2627, 0x09020d23}, | ||
674 | {5600000, DIF_BPF_COEFF2829, 0x0b0a0318}, | ||
675 | {5600000, DIF_BPF_COEFF3031, 0xf8d7f15a}, | ||
676 | {5600000, DIF_BPF_COEFF3233, 0xf0a5f779}, | ||
677 | {5600000, DIF_BPF_COEFF3435, 0x02bd0cf6}, | ||
678 | {5600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
679 | /* END - DIF BPF register values from 56_quant.dat*/ | ||
680 | |||
681 | |||
682 | /*case 5700000:*/ | ||
683 | /* BEGIN - DIF BPF register values from 57_quant.dat*/ | ||
684 | {5700000, DIF_BPF_COEFF01, 0x00010003}, | ||
685 | {5700000, DIF_BPF_COEFF23, 0x00060001}, | ||
686 | {5700000, DIF_BPF_COEFF45, 0xffecffc9}, | ||
687 | {5700000, DIF_BPF_COEFF67, 0xffb4ffd4}, | ||
688 | {5700000, DIF_BPF_COEFF89, 0x004000d5}, | ||
689 | {5700000, DIF_BPF_COEFF1011, 0x013600f0}, | ||
690 | {5700000, DIF_BPF_COEFF1213, 0xffd3fe39}, | ||
691 | {5700000, DIF_BPF_COEFF1415, 0xfd04fd31}, | ||
692 | {5700000, DIF_BPF_COEFF1617, 0xff360277}, | ||
693 | {5700000, DIF_BPF_COEFF1819, 0x055605ef}, | ||
694 | {5700000, DIF_BPF_COEFF2021, 0x033efdfe}, | ||
695 | {5700000, DIF_BPF_COEFF2223, 0xf8a5f642}, | ||
696 | {5700000, DIF_BPF_COEFF2425, 0xf8cbffb6}, | ||
697 | {5700000, DIF_BPF_COEFF2627, 0x07e10cfb}, | ||
698 | {5700000, DIF_BPF_COEFF2829, 0x0bd50456}, | ||
699 | {5700000, DIF_BPF_COEFF3031, 0xf9dff1be}, | ||
700 | {5700000, DIF_BPF_COEFF3233, 0xf067f6f2}, | ||
701 | {5700000, DIF_BPF_COEFF3435, 0x02520cd2}, | ||
702 | {5700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
703 | /* END - DIF BPF register values from 57_quant.dat*/ | ||
704 | |||
705 | |||
706 | /*case 5800000:*/ | ||
707 | /* BEGIN - DIF BPF register values from 58_quant.dat*/ | ||
708 | {5800000, DIF_BPF_COEFF01, 0x00000003}, | ||
709 | {5800000, DIF_BPF_COEFF23, 0x00080009}, | ||
710 | {5800000, DIF_BPF_COEFF45, 0xfff8ffd2}, | ||
711 | {5800000, DIF_BPF_COEFF67, 0xffaaffac}, | ||
712 | {5800000, DIF_BPF_COEFF89, 0x000200a3}, | ||
713 | {5800000, DIF_BPF_COEFF1011, 0x013c014a}, | ||
714 | {5800000, DIF_BPF_COEFF1213, 0x006dfec9}, | ||
715 | {5800000, DIF_BPF_COEFF1415, 0xfd2bfcb7}, | ||
716 | {5800000, DIF_BPF_COEFF1617, 0xfe350165}, | ||
717 | {5800000, DIF_BPF_COEFF1819, 0x04cb0651}, | ||
718 | {5800000, DIF_BPF_COEFF2021, 0x0477ff7e}, | ||
719 | {5800000, DIF_BPF_COEFF2223, 0xf9a5f635}, | ||
720 | {5800000, DIF_BPF_COEFF2425, 0xf7b1fe20}, | ||
721 | {5800000, DIF_BPF_COEFF2627, 0x069f0ca8}, | ||
722 | {5800000, DIF_BPF_COEFF2829, 0x0c81058b}, | ||
723 | {5800000, DIF_BPF_COEFF3031, 0xfaf0f231}, | ||
724 | {5800000, DIF_BPF_COEFF3233, 0xf033f66d}, | ||
725 | {5800000, DIF_BPF_COEFF3435, 0x01e60cae}, | ||
726 | {5800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
727 | /* END - DIF BPF register values from 58_quant.dat*/ | ||
728 | |||
729 | |||
730 | /*case 5900000:*/ | ||
731 | /* BEGIN - DIF BPF register values from 59_quant.dat*/ | ||
732 | {5900000, DIF_BPF_COEFF01, 0x00000002}, | ||
733 | {5900000, DIF_BPF_COEFF23, 0x0009000e}, | ||
734 | {5900000, DIF_BPF_COEFF45, 0x0005ffe1}, | ||
735 | {5900000, DIF_BPF_COEFF67, 0xffacff90}, | ||
736 | {5900000, DIF_BPF_COEFF89, 0xffc5005f}, | ||
737 | {5900000, DIF_BPF_COEFF1011, 0x01210184}, | ||
738 | {5900000, DIF_BPF_COEFF1213, 0x00fcff72}, | ||
739 | {5900000, DIF_BPF_COEFF1415, 0xfd8afc77}, | ||
740 | {5900000, DIF_BPF_COEFF1617, 0xfd51003f}, | ||
741 | {5900000, DIF_BPF_COEFF1819, 0x04020669}, | ||
742 | {5900000, DIF_BPF_COEFF2021, 0x05830103}, | ||
743 | {5900000, DIF_BPF_COEFF2223, 0xfad7f66b}, | ||
744 | {5900000, DIF_BPF_COEFF2425, 0xf6c8fc93}, | ||
745 | {5900000, DIF_BPF_COEFF2627, 0x05430c2b}, | ||
746 | {5900000, DIF_BPF_COEFF2829, 0x0d0d06b5}, | ||
747 | {5900000, DIF_BPF_COEFF3031, 0xfc08f2b2}, | ||
748 | {5900000, DIF_BPF_COEFF3233, 0xf00af5ec}, | ||
749 | {5900000, DIF_BPF_COEFF3435, 0x017b0c89}, | ||
750 | {5900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
751 | /* END - DIF BPF register values from 59_quant.dat*/ | ||
752 | |||
753 | |||
754 | /*case 6000000:*/ | ||
755 | /* BEGIN - DIF BPF register values from 60_quant.dat*/ | ||
756 | {6000000, DIF_BPF_COEFF01, 0x00000001}, | ||
757 | {6000000, DIF_BPF_COEFF23, 0x00070012}, | ||
758 | {6000000, DIF_BPF_COEFF45, 0x0012fff5}, | ||
759 | {6000000, DIF_BPF_COEFF67, 0xffbaff82}, | ||
760 | {6000000, DIF_BPF_COEFF89, 0xff8e000f}, | ||
761 | {6000000, DIF_BPF_COEFF1011, 0x00e80198}, | ||
762 | {6000000, DIF_BPF_COEFF1213, 0x01750028}, | ||
763 | {6000000, DIF_BPF_COEFF1415, 0xfe18fc75}, | ||
764 | {6000000, DIF_BPF_COEFF1617, 0xfc99ff15}, | ||
765 | {6000000, DIF_BPF_COEFF1819, 0x03050636}, | ||
766 | {6000000, DIF_BPF_COEFF2021, 0x0656027f}, | ||
767 | {6000000, DIF_BPF_COEFF2223, 0xfc32f6e2}, | ||
768 | {6000000, DIF_BPF_COEFF2425, 0xf614fb17}, | ||
769 | {6000000, DIF_BPF_COEFF2627, 0x03d20b87}, | ||
770 | {6000000, DIF_BPF_COEFF2829, 0x0d7707d2}, | ||
771 | {6000000, DIF_BPF_COEFF3031, 0xfd26f341}, | ||
772 | {6000000, DIF_BPF_COEFF3233, 0xefeaf56f}, | ||
773 | {6000000, DIF_BPF_COEFF3435, 0x010f0c64}, | ||
774 | {6000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
775 | /* END - DIF BPF register values from 60_quant.dat*/ | ||
776 | |||
777 | |||
778 | /*case 6100000:*/ | ||
779 | /* BEGIN - DIF BPF register values from 61_quant.dat*/ | ||
780 | {6100000, DIF_BPF_COEFF01, 0xffff0000}, | ||
781 | {6100000, DIF_BPF_COEFF23, 0x00050012}, | ||
782 | {6100000, DIF_BPF_COEFF45, 0x001c000b}, | ||
783 | {6100000, DIF_BPF_COEFF67, 0xffd1ff84}, | ||
784 | {6100000, DIF_BPF_COEFF89, 0xff66ffbe}, | ||
785 | {6100000, DIF_BPF_COEFF1011, 0x00960184}, | ||
786 | {6100000, DIF_BPF_COEFF1213, 0x01cd00da}, | ||
787 | {6100000, DIF_BPF_COEFF1415, 0xfeccfcb2}, | ||
788 | {6100000, DIF_BPF_COEFF1617, 0xfc17fdf9}, | ||
789 | {6100000, DIF_BPF_COEFF1819, 0x01e005bc}, | ||
790 | {6100000, DIF_BPF_COEFF2021, 0x06e703e4}, | ||
791 | {6100000, DIF_BPF_COEFF2223, 0xfdabf798}, | ||
792 | {6100000, DIF_BPF_COEFF2425, 0xf599f9b3}, | ||
793 | {6100000, DIF_BPF_COEFF2627, 0x02510abd}, | ||
794 | {6100000, DIF_BPF_COEFF2829, 0x0dbf08df}, | ||
795 | {6100000, DIF_BPF_COEFF3031, 0xfe48f3dc}, | ||
796 | {6100000, DIF_BPF_COEFF3233, 0xefd5f4f6}, | ||
797 | {6100000, DIF_BPF_COEFF3435, 0x00a20c3e}, | ||
798 | {6100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
799 | /* END - DIF BPF register values from 61_quant.dat*/ | ||
800 | |||
801 | |||
802 | /*case 6200000:*/ | ||
803 | /* BEGIN - DIF BPF register values from 62_quant.dat*/ | ||
804 | {6200000, DIF_BPF_COEFF01, 0xfffffffe}, | ||
805 | {6200000, DIF_BPF_COEFF23, 0x0002000f}, | ||
806 | {6200000, DIF_BPF_COEFF45, 0x0021001f}, | ||
807 | {6200000, DIF_BPF_COEFF67, 0xfff0ff97}, | ||
808 | {6200000, DIF_BPF_COEFF89, 0xff50ff74}, | ||
809 | {6200000, DIF_BPF_COEFF1011, 0x0034014a}, | ||
810 | {6200000, DIF_BPF_COEFF1213, 0x01fa0179}, | ||
811 | {6200000, DIF_BPF_COEFF1415, 0xff97fd2a}, | ||
812 | {6200000, DIF_BPF_COEFF1617, 0xfbd3fcfa}, | ||
813 | {6200000, DIF_BPF_COEFF1819, 0x00a304fe}, | ||
814 | {6200000, DIF_BPF_COEFF2021, 0x07310525}, | ||
815 | {6200000, DIF_BPF_COEFF2223, 0xff37f886}, | ||
816 | {6200000, DIF_BPF_COEFF2425, 0xf55cf86e}, | ||
817 | {6200000, DIF_BPF_COEFF2627, 0x00c709d0}, | ||
818 | {6200000, DIF_BPF_COEFF2829, 0x0de209db}, | ||
819 | {6200000, DIF_BPF_COEFF3031, 0xff6df484}, | ||
820 | {6200000, DIF_BPF_COEFF3233, 0xefcbf481}, | ||
821 | {6200000, DIF_BPF_COEFF3435, 0x00360c18}, | ||
822 | {6200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
823 | /* END - DIF BPF register values from 62_quant.dat*/ | ||
824 | |||
825 | |||
826 | /*case 6300000:*/ | ||
827 | /* BEGIN - DIF BPF register values from 63_quant.dat*/ | ||
828 | {6300000, DIF_BPF_COEFF01, 0xfffffffd}, | ||
829 | {6300000, DIF_BPF_COEFF23, 0xfffe000a}, | ||
830 | {6300000, DIF_BPF_COEFF45, 0x0021002f}, | ||
831 | {6300000, DIF_BPF_COEFF67, 0x0010ffb8}, | ||
832 | {6300000, DIF_BPF_COEFF89, 0xff50ff3b}, | ||
833 | {6300000, DIF_BPF_COEFF1011, 0xffcc00f0}, | ||
834 | {6300000, DIF_BPF_COEFF1213, 0x01fa01fa}, | ||
835 | {6300000, DIF_BPF_COEFF1415, 0x0069fdd4}, | ||
836 | {6300000, DIF_BPF_COEFF1617, 0xfbd3fc26}, | ||
837 | {6300000, DIF_BPF_COEFF1819, 0xff5d0407}, | ||
838 | {6300000, DIF_BPF_COEFF2021, 0x07310638}, | ||
839 | {6300000, DIF_BPF_COEFF2223, 0x00c9f9a8}, | ||
840 | {6300000, DIF_BPF_COEFF2425, 0xf55cf74e}, | ||
841 | {6300000, DIF_BPF_COEFF2627, 0xff3908c3}, | ||
842 | {6300000, DIF_BPF_COEFF2829, 0x0de20ac3}, | ||
843 | {6300000, DIF_BPF_COEFF3031, 0x0093f537}, | ||
844 | {6300000, DIF_BPF_COEFF3233, 0xefcbf410}, | ||
845 | {6300000, DIF_BPF_COEFF3435, 0xffca0bf2}, | ||
846 | {6300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
847 | /* END - DIF BPF register values from 63_quant.dat*/ | ||
848 | |||
849 | |||
850 | /*case 6400000:*/ | ||
851 | /* BEGIN - DIF BPF register values from 64_quant.dat*/ | ||
852 | {6400000, DIF_BPF_COEFF01, 0xfffffffd}, | ||
853 | {6400000, DIF_BPF_COEFF23, 0xfffb0003}, | ||
854 | {6400000, DIF_BPF_COEFF45, 0x001c0037}, | ||
855 | {6400000, DIF_BPF_COEFF67, 0x002fffe2}, | ||
856 | {6400000, DIF_BPF_COEFF89, 0xff66ff17}, | ||
857 | {6400000, DIF_BPF_COEFF1011, 0xff6a007e}, | ||
858 | {6400000, DIF_BPF_COEFF1213, 0x01cd0251}, | ||
859 | {6400000, DIF_BPF_COEFF1415, 0x0134fea5}, | ||
860 | {6400000, DIF_BPF_COEFF1617, 0xfc17fb8b}, | ||
861 | {6400000, DIF_BPF_COEFF1819, 0xfe2002e0}, | ||
862 | {6400000, DIF_BPF_COEFF2021, 0x06e70713}, | ||
863 | {6400000, DIF_BPF_COEFF2223, 0x0255faf5}, | ||
864 | {6400000, DIF_BPF_COEFF2425, 0xf599f658}, | ||
865 | {6400000, DIF_BPF_COEFF2627, 0xfdaf0799}, | ||
866 | {6400000, DIF_BPF_COEFF2829, 0x0dbf0b96}, | ||
867 | {6400000, DIF_BPF_COEFF3031, 0x01b8f5f5}, | ||
868 | {6400000, DIF_BPF_COEFF3233, 0xefd5f3a3}, | ||
869 | {6400000, DIF_BPF_COEFF3435, 0xff5e0bca}, | ||
870 | {6400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
871 | /* END - DIF BPF register values from 64_quant.dat*/ | ||
872 | |||
873 | |||
874 | /*case 6500000:*/ | ||
875 | /* BEGIN - DIF BPF register values from 65_quant.dat*/ | ||
876 | {6500000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
877 | {6500000, DIF_BPF_COEFF23, 0xfff9fffb}, | ||
878 | {6500000, DIF_BPF_COEFF45, 0x00120037}, | ||
879 | {6500000, DIF_BPF_COEFF67, 0x00460010}, | ||
880 | {6500000, DIF_BPF_COEFF89, 0xff8eff0f}, | ||
881 | {6500000, DIF_BPF_COEFF1011, 0xff180000}, | ||
882 | {6500000, DIF_BPF_COEFF1213, 0x01750276}, | ||
883 | {6500000, DIF_BPF_COEFF1415, 0x01e8ff8d}, | ||
884 | {6500000, DIF_BPF_COEFF1617, 0xfc99fb31}, | ||
885 | {6500000, DIF_BPF_COEFF1819, 0xfcfb0198}, | ||
886 | {6500000, DIF_BPF_COEFF2021, 0x065607ad}, | ||
887 | {6500000, DIF_BPF_COEFF2223, 0x03cefc64}, | ||
888 | {6500000, DIF_BPF_COEFF2425, 0xf614f592}, | ||
889 | {6500000, DIF_BPF_COEFF2627, 0xfc2e0656}, | ||
890 | {6500000, DIF_BPF_COEFF2829, 0x0d770c52}, | ||
891 | {6500000, DIF_BPF_COEFF3031, 0x02daf6bd}, | ||
892 | {6500000, DIF_BPF_COEFF3233, 0xefeaf33b}, | ||
893 | {6500000, DIF_BPF_COEFF3435, 0xfef10ba3}, | ||
894 | {6500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
895 | /* END - DIF BPF register values from 65_quant.dat*/ | ||
896 | |||
897 | |||
898 | /*case 6600000:*/ | ||
899 | /* BEGIN - DIF BPF register values from 66_quant.dat*/ | ||
900 | {6600000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
901 | {6600000, DIF_BPF_COEFF23, 0xfff7fff5}, | ||
902 | {6600000, DIF_BPF_COEFF45, 0x0005002f}, | ||
903 | {6600000, DIF_BPF_COEFF67, 0x0054003c}, | ||
904 | {6600000, DIF_BPF_COEFF89, 0xffc5ff22}, | ||
905 | {6600000, DIF_BPF_COEFF1011, 0xfedfff82}, | ||
906 | {6600000, DIF_BPF_COEFF1213, 0x00fc0267}, | ||
907 | {6600000, DIF_BPF_COEFF1415, 0x0276007e}, | ||
908 | {6600000, DIF_BPF_COEFF1617, 0xfd51fb1c}, | ||
909 | {6600000, DIF_BPF_COEFF1819, 0xfbfe003e}, | ||
910 | {6600000, DIF_BPF_COEFF2021, 0x05830802}, | ||
911 | {6600000, DIF_BPF_COEFF2223, 0x0529fdec}, | ||
912 | {6600000, DIF_BPF_COEFF2425, 0xf6c8f4fe}, | ||
913 | {6600000, DIF_BPF_COEFF2627, 0xfabd04ff}, | ||
914 | {6600000, DIF_BPF_COEFF2829, 0x0d0d0cf6}, | ||
915 | {6600000, DIF_BPF_COEFF3031, 0x03f8f78f}, | ||
916 | {6600000, DIF_BPF_COEFF3233, 0xf00af2d7}, | ||
917 | {6600000, DIF_BPF_COEFF3435, 0xfe850b7b}, | ||
918 | {6600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
919 | /* END - DIF BPF register values from 66_quant.dat*/ | ||
920 | |||
921 | |||
922 | /*case 6700000:*/ | ||
923 | /* BEGIN - DIF BPF register values from 67_quant.dat*/ | ||
924 | {6700000, DIF_BPF_COEFF01, 0x0000ffff}, | ||
925 | {6700000, DIF_BPF_COEFF23, 0xfff8fff0}, | ||
926 | {6700000, DIF_BPF_COEFF45, 0xfff80020}, | ||
927 | {6700000, DIF_BPF_COEFF67, 0x00560060}, | ||
928 | {6700000, DIF_BPF_COEFF89, 0x0002ff4e}, | ||
929 | {6700000, DIF_BPF_COEFF1011, 0xfec4ff10}, | ||
930 | {6700000, DIF_BPF_COEFF1213, 0x006d0225}, | ||
931 | {6700000, DIF_BPF_COEFF1415, 0x02d50166}, | ||
932 | {6700000, DIF_BPF_COEFF1617, 0xfe35fb4e}, | ||
933 | {6700000, DIF_BPF_COEFF1819, 0xfb35fee1}, | ||
934 | {6700000, DIF_BPF_COEFF2021, 0x0477080e}, | ||
935 | {6700000, DIF_BPF_COEFF2223, 0x065bff82}, | ||
936 | {6700000, DIF_BPF_COEFF2425, 0xf7b1f4a0}, | ||
937 | {6700000, DIF_BPF_COEFF2627, 0xf9610397}, | ||
938 | {6700000, DIF_BPF_COEFF2829, 0x0c810d80}, | ||
939 | {6700000, DIF_BPF_COEFF3031, 0x0510f869}, | ||
940 | {6700000, DIF_BPF_COEFF3233, 0xf033f278}, | ||
941 | {6700000, DIF_BPF_COEFF3435, 0xfe1a0b52}, | ||
942 | {6700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
943 | /* END - DIF BPF register values from 67_quant.dat*/ | ||
944 | |||
945 | |||
946 | /*case 6800000:*/ | ||
947 | /* BEGIN - DIF BPF register values from 68_quant.dat*/ | ||
948 | {6800000, DIF_BPF_COEFF01, 0x00010000}, | ||
949 | {6800000, DIF_BPF_COEFF23, 0xfffaffee}, | ||
950 | {6800000, DIF_BPF_COEFF45, 0xffec000c}, | ||
951 | {6800000, DIF_BPF_COEFF67, 0x004c0078}, | ||
952 | {6800000, DIF_BPF_COEFF89, 0x0040ff8e}, | ||
953 | {6800000, DIF_BPF_COEFF1011, 0xfecafeb6}, | ||
954 | {6800000, DIF_BPF_COEFF1213, 0xffd301b6}, | ||
955 | {6800000, DIF_BPF_COEFF1415, 0x02fc0235}, | ||
956 | {6800000, DIF_BPF_COEFF1617, 0xff36fbc5}, | ||
957 | {6800000, DIF_BPF_COEFF1819, 0xfaaafd90}, | ||
958 | {6800000, DIF_BPF_COEFF2021, 0x033e07d2}, | ||
959 | {6800000, DIF_BPF_COEFF2223, 0x075b011b}, | ||
960 | {6800000, DIF_BPF_COEFF2425, 0xf8cbf47a}, | ||
961 | {6800000, DIF_BPF_COEFF2627, 0xf81f0224}, | ||
962 | {6800000, DIF_BPF_COEFF2829, 0x0bd50def}, | ||
963 | {6800000, DIF_BPF_COEFF3031, 0x0621f94b}, | ||
964 | {6800000, DIF_BPF_COEFF3233, 0xf067f21e}, | ||
965 | {6800000, DIF_BPF_COEFF3435, 0xfdae0b29}, | ||
966 | {6800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
967 | /* END - DIF BPF register values from 68_quant.dat*/ | ||
968 | |||
969 | |||
970 | /*case 6900000:*/ | ||
971 | /* BEGIN - DIF BPF register values from 69_quant.dat*/ | ||
972 | {6900000, DIF_BPF_COEFF01, 0x00010001}, | ||
973 | {6900000, DIF_BPF_COEFF23, 0xfffdffef}, | ||
974 | {6900000, DIF_BPF_COEFF45, 0xffe3fff6}, | ||
975 | {6900000, DIF_BPF_COEFF67, 0x0037007f}, | ||
976 | {6900000, DIF_BPF_COEFF89, 0x0075ffdc}, | ||
977 | {6900000, DIF_BPF_COEFF1011, 0xfef2fe7c}, | ||
978 | {6900000, DIF_BPF_COEFF1213, 0xff3d0122}, | ||
979 | {6900000, DIF_BPF_COEFF1415, 0x02ea02dd}, | ||
980 | {6900000, DIF_BPF_COEFF1617, 0x0044fc79}, | ||
981 | {6900000, DIF_BPF_COEFF1819, 0xfa65fc5d}, | ||
982 | {6900000, DIF_BPF_COEFF2021, 0x01e3074e}, | ||
983 | {6900000, DIF_BPF_COEFF2223, 0x082102ad}, | ||
984 | {6900000, DIF_BPF_COEFF2425, 0xfa0ff48c}, | ||
985 | {6900000, DIF_BPF_COEFF2627, 0xf6fe00a9}, | ||
986 | {6900000, DIF_BPF_COEFF2829, 0x0b0a0e43}, | ||
987 | {6900000, DIF_BPF_COEFF3031, 0x0729fa33}, | ||
988 | {6900000, DIF_BPF_COEFF3233, 0xf0a5f1c9}, | ||
989 | {6900000, DIF_BPF_COEFF3435, 0xfd430b00}, | ||
990 | {6900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
991 | /* END - DIF BPF register values from 69_quant.dat*/ | ||
992 | |||
993 | |||
994 | /*case 7000000:*/ | ||
995 | /* BEGIN - DIF BPF register values from 70_quant.dat*/ | ||
996 | {7000000, DIF_BPF_COEFF01, 0x00010002}, | ||
997 | {7000000, DIF_BPF_COEFF23, 0x0001fff3}, | ||
998 | {7000000, DIF_BPF_COEFF45, 0xffdeffe2}, | ||
999 | {7000000, DIF_BPF_COEFF67, 0x001b0076}, | ||
1000 | {7000000, DIF_BPF_COEFF89, 0x009c002d}, | ||
1001 | {7000000, DIF_BPF_COEFF1011, 0xff35fe68}, | ||
1002 | {7000000, DIF_BPF_COEFF1213, 0xfeba0076}, | ||
1003 | {7000000, DIF_BPF_COEFF1415, 0x029f0352}, | ||
1004 | {7000000, DIF_BPF_COEFF1617, 0x014dfd60}, | ||
1005 | {7000000, DIF_BPF_COEFF1819, 0xfa69fb53}, | ||
1006 | {7000000, DIF_BPF_COEFF2021, 0x00740688}, | ||
1007 | {7000000, DIF_BPF_COEFF2223, 0x08a7042d}, | ||
1008 | {7000000, DIF_BPF_COEFF2425, 0xfb75f4d6}, | ||
1009 | {7000000, DIF_BPF_COEFF2627, 0xf600ff2d}, | ||
1010 | {7000000, DIF_BPF_COEFF2829, 0x0a220e7a}, | ||
1011 | {7000000, DIF_BPF_COEFF3031, 0x0827fb22}, | ||
1012 | {7000000, DIF_BPF_COEFF3233, 0xf0edf17a}, | ||
1013 | {7000000, DIF_BPF_COEFF3435, 0xfcd80ad6}, | ||
1014 | {7000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1015 | /* END - DIF BPF register values from 70_quant.dat*/ | ||
1016 | |||
1017 | |||
1018 | /*case 7100000:*/ | ||
1019 | /* BEGIN - DIF BPF register values from 71_quant.dat*/ | ||
1020 | {7100000, DIF_BPF_COEFF01, 0x00000003}, | ||
1021 | {7100000, DIF_BPF_COEFF23, 0x0004fff9}, | ||
1022 | {7100000, DIF_BPF_COEFF45, 0xffe0ffd2}, | ||
1023 | {7100000, DIF_BPF_COEFF67, 0xfffb005e}, | ||
1024 | {7100000, DIF_BPF_COEFF89, 0x00b0007a}, | ||
1025 | {7100000, DIF_BPF_COEFF1011, 0xff8ffe7c}, | ||
1026 | {7100000, DIF_BPF_COEFF1213, 0xfe53ffc1}, | ||
1027 | {7100000, DIF_BPF_COEFF1415, 0x0221038c}, | ||
1028 | {7100000, DIF_BPF_COEFF1617, 0x0241fe6e}, | ||
1029 | {7100000, DIF_BPF_COEFF1819, 0xfab6fa80}, | ||
1030 | {7100000, DIF_BPF_COEFF2021, 0xff010587}, | ||
1031 | {7100000, DIF_BPF_COEFF2223, 0x08e90590}, | ||
1032 | {7100000, DIF_BPF_COEFF2425, 0xfcf5f556}, | ||
1033 | {7100000, DIF_BPF_COEFF2627, 0xf52bfdb3}, | ||
1034 | {7100000, DIF_BPF_COEFF2829, 0x09210e95}, | ||
1035 | {7100000, DIF_BPF_COEFF3031, 0x0919fc15}, | ||
1036 | {7100000, DIF_BPF_COEFF3233, 0xf13ff12f}, | ||
1037 | {7100000, DIF_BPF_COEFF3435, 0xfc6e0aab}, | ||
1038 | {7100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1039 | /* END - DIF BPF register values from 71_quant.dat*/ | ||
1040 | |||
1041 | |||
1042 | /*case 7200000:*/ | ||
1043 | /* BEGIN - DIF BPF register values from 72_quant.dat*/ | ||
1044 | {7200000, DIF_BPF_COEFF01, 0x00000003}, | ||
1045 | {7200000, DIF_BPF_COEFF23, 0x00070000}, | ||
1046 | {7200000, DIF_BPF_COEFF45, 0xffe6ffc9}, | ||
1047 | {7200000, DIF_BPF_COEFF67, 0xffdb0039}, | ||
1048 | {7200000, DIF_BPF_COEFF89, 0x00af00b8}, | ||
1049 | {7200000, DIF_BPF_COEFF1011, 0xfff4feb6}, | ||
1050 | {7200000, DIF_BPF_COEFF1213, 0xfe13ff10}, | ||
1051 | {7200000, DIF_BPF_COEFF1415, 0x01790388}, | ||
1052 | {7200000, DIF_BPF_COEFF1617, 0x0311ff92}, | ||
1053 | {7200000, DIF_BPF_COEFF1819, 0xfb48f9ed}, | ||
1054 | {7200000, DIF_BPF_COEFF2021, 0xfd980453}, | ||
1055 | {7200000, DIF_BPF_COEFF2223, 0x08e306cd}, | ||
1056 | {7200000, DIF_BPF_COEFF2425, 0xfe88f60a}, | ||
1057 | {7200000, DIF_BPF_COEFF2627, 0xf482fc40}, | ||
1058 | {7200000, DIF_BPF_COEFF2829, 0x08080e93}, | ||
1059 | {7200000, DIF_BPF_COEFF3031, 0x09fdfd0c}, | ||
1060 | {7200000, DIF_BPF_COEFF3233, 0xf19af0ea}, | ||
1061 | {7200000, DIF_BPF_COEFF3435, 0xfc050a81}, | ||
1062 | {7200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1063 | /* END - DIF BPF register values from 72_quant.dat*/ | ||
1064 | |||
1065 | |||
1066 | /*case 7300000:*/ | ||
1067 | /* BEGIN - DIF BPF register values from 73_quant.dat*/ | ||
1068 | {7300000, DIF_BPF_COEFF01, 0x00000002}, | ||
1069 | {7300000, DIF_BPF_COEFF23, 0x00080008}, | ||
1070 | {7300000, DIF_BPF_COEFF45, 0xfff0ffc9}, | ||
1071 | {7300000, DIF_BPF_COEFF67, 0xffc1000d}, | ||
1072 | {7300000, DIF_BPF_COEFF89, 0x009800e2}, | ||
1073 | {7300000, DIF_BPF_COEFF1011, 0x005bff10}, | ||
1074 | {7300000, DIF_BPF_COEFF1213, 0xfe00fe74}, | ||
1075 | {7300000, DIF_BPF_COEFF1415, 0x00b50345}, | ||
1076 | {7300000, DIF_BPF_COEFF1617, 0x03b000bc}, | ||
1077 | {7300000, DIF_BPF_COEFF1819, 0xfc18f9a1}, | ||
1078 | {7300000, DIF_BPF_COEFF2021, 0xfc4802f9}, | ||
1079 | {7300000, DIF_BPF_COEFF2223, 0x089807dc}, | ||
1080 | {7300000, DIF_BPF_COEFF2425, 0x0022f6f0}, | ||
1081 | {7300000, DIF_BPF_COEFF2627, 0xf407fada}, | ||
1082 | {7300000, DIF_BPF_COEFF2829, 0x06da0e74}, | ||
1083 | {7300000, DIF_BPF_COEFF3031, 0x0ad3fe06}, | ||
1084 | {7300000, DIF_BPF_COEFF3233, 0xf1fef0ab}, | ||
1085 | {7300000, DIF_BPF_COEFF3435, 0xfb9c0a55}, | ||
1086 | {7300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1087 | /* END - DIF BPF register values from 73_quant.dat*/ | ||
1088 | |||
1089 | |||
1090 | /*case 7400000:*/ | ||
1091 | /* BEGIN - DIF BPF register values from 74_quant.dat*/ | ||
1092 | {7400000, DIF_BPF_COEFF01, 0x00000001}, | ||
1093 | {7400000, DIF_BPF_COEFF23, 0x0008000e}, | ||
1094 | {7400000, DIF_BPF_COEFF45, 0xfffdffd0}, | ||
1095 | {7400000, DIF_BPF_COEFF67, 0xffafffdf}, | ||
1096 | {7400000, DIF_BPF_COEFF89, 0x006e00f2}, | ||
1097 | {7400000, DIF_BPF_COEFF1011, 0x00b8ff82}, | ||
1098 | {7400000, DIF_BPF_COEFF1213, 0xfe1bfdf8}, | ||
1099 | {7400000, DIF_BPF_COEFF1415, 0xffe302c8}, | ||
1100 | {7400000, DIF_BPF_COEFF1617, 0x041301dc}, | ||
1101 | {7400000, DIF_BPF_COEFF1819, 0xfd1af99e}, | ||
1102 | {7400000, DIF_BPF_COEFF2021, 0xfb1e0183}, | ||
1103 | {7400000, DIF_BPF_COEFF2223, 0x080908b5}, | ||
1104 | {7400000, DIF_BPF_COEFF2425, 0x01bcf801}, | ||
1105 | {7400000, DIF_BPF_COEFF2627, 0xf3bdf985}, | ||
1106 | {7400000, DIF_BPF_COEFF2829, 0x059a0e38}, | ||
1107 | {7400000, DIF_BPF_COEFF3031, 0x0b99ff03}, | ||
1108 | {7400000, DIF_BPF_COEFF3233, 0xf26cf071}, | ||
1109 | {7400000, DIF_BPF_COEFF3435, 0xfb330a2a}, | ||
1110 | {7400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1111 | /* END - DIF BPF register values from 74_quant.dat*/ | ||
1112 | |||
1113 | |||
1114 | /*case 7500000:*/ | ||
1115 | /* BEGIN - DIF BPF register values from 75_quant.dat*/ | ||
1116 | {7500000, DIF_BPF_COEFF01, 0xffff0000}, | ||
1117 | {7500000, DIF_BPF_COEFF23, 0x00070011}, | ||
1118 | {7500000, DIF_BPF_COEFF45, 0x000affdf}, | ||
1119 | {7500000, DIF_BPF_COEFF67, 0xffa9ffb5}, | ||
1120 | {7500000, DIF_BPF_COEFF89, 0x003700e6}, | ||
1121 | {7500000, DIF_BPF_COEFF1011, 0x01010000}, | ||
1122 | {7500000, DIF_BPF_COEFF1213, 0xfe62fda8}, | ||
1123 | {7500000, DIF_BPF_COEFF1415, 0xff140219}, | ||
1124 | {7500000, DIF_BPF_COEFF1617, 0x043502e1}, | ||
1125 | {7500000, DIF_BPF_COEFF1819, 0xfe42f9e6}, | ||
1126 | {7500000, DIF_BPF_COEFF2021, 0xfa270000}, | ||
1127 | {7500000, DIF_BPF_COEFF2223, 0x073a0953}, | ||
1128 | {7500000, DIF_BPF_COEFF2425, 0x034cf939}, | ||
1129 | {7500000, DIF_BPF_COEFF2627, 0xf3a4f845}, | ||
1130 | {7500000, DIF_BPF_COEFF2829, 0x044c0de1}, | ||
1131 | {7500000, DIF_BPF_COEFF3031, 0x0c4f0000}, | ||
1132 | {7500000, DIF_BPF_COEFF3233, 0xf2e2f03c}, | ||
1133 | {7500000, DIF_BPF_COEFF3435, 0xfacc09fe}, | ||
1134 | {7500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1135 | /* END - DIF BPF register values from 75_quant.dat*/ | ||
1136 | |||
1137 | |||
1138 | /*case 7600000:*/ | ||
1139 | /* BEGIN - DIF BPF register values from 76_quant.dat*/ | ||
1140 | {7600000, DIF_BPF_COEFF01, 0xffffffff}, | ||
1141 | {7600000, DIF_BPF_COEFF23, 0x00040012}, | ||
1142 | {7600000, DIF_BPF_COEFF45, 0x0016fff3}, | ||
1143 | {7600000, DIF_BPF_COEFF67, 0xffafff95}, | ||
1144 | {7600000, DIF_BPF_COEFF89, 0xfff900c0}, | ||
1145 | {7600000, DIF_BPF_COEFF1011, 0x0130007e}, | ||
1146 | {7600000, DIF_BPF_COEFF1213, 0xfecefd89}, | ||
1147 | {7600000, DIF_BPF_COEFF1415, 0xfe560146}, | ||
1148 | {7600000, DIF_BPF_COEFF1617, 0x041303bc}, | ||
1149 | {7600000, DIF_BPF_COEFF1819, 0xff81fa76}, | ||
1150 | {7600000, DIF_BPF_COEFF2021, 0xf96cfe7d}, | ||
1151 | {7600000, DIF_BPF_COEFF2223, 0x063209b1}, | ||
1152 | {7600000, DIF_BPF_COEFF2425, 0x04c9fa93}, | ||
1153 | {7600000, DIF_BPF_COEFF2627, 0xf3bdf71e}, | ||
1154 | {7600000, DIF_BPF_COEFF2829, 0x02f30d6e}, | ||
1155 | {7600000, DIF_BPF_COEFF3031, 0x0cf200fd}, | ||
1156 | {7600000, DIF_BPF_COEFF3233, 0xf361f00e}, | ||
1157 | {7600000, DIF_BPF_COEFF3435, 0xfa6509d1}, | ||
1158 | {7600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1159 | /* END - DIF BPF register values from 76_quant.dat*/ | ||
1160 | |||
1161 | |||
1162 | /*case 7700000:*/ | ||
1163 | /* BEGIN - DIF BPF register values from 77_quant.dat*/ | ||
1164 | {7700000, DIF_BPF_COEFF01, 0xfffffffe}, | ||
1165 | {7700000, DIF_BPF_COEFF23, 0x00010010}, | ||
1166 | {7700000, DIF_BPF_COEFF45, 0x001e0008}, | ||
1167 | {7700000, DIF_BPF_COEFF67, 0xffc1ff84}, | ||
1168 | {7700000, DIF_BPF_COEFF89, 0xffbc0084}, | ||
1169 | {7700000, DIF_BPF_COEFF1011, 0x013e00f0}, | ||
1170 | {7700000, DIF_BPF_COEFF1213, 0xff56fd9f}, | ||
1171 | {7700000, DIF_BPF_COEFF1415, 0xfdb8005c}, | ||
1172 | {7700000, DIF_BPF_COEFF1617, 0x03b00460}, | ||
1173 | {7700000, DIF_BPF_COEFF1819, 0x00c7fb45}, | ||
1174 | {7700000, DIF_BPF_COEFF2021, 0xf8f4fd07}, | ||
1175 | {7700000, DIF_BPF_COEFF2223, 0x04fa09ce}, | ||
1176 | {7700000, DIF_BPF_COEFF2425, 0x062afc07}, | ||
1177 | {7700000, DIF_BPF_COEFF2627, 0xf407f614}, | ||
1178 | {7700000, DIF_BPF_COEFF2829, 0x01920ce0}, | ||
1179 | {7700000, DIF_BPF_COEFF3031, 0x0d8301fa}, | ||
1180 | {7700000, DIF_BPF_COEFF3233, 0xf3e8efe5}, | ||
1181 | {7700000, DIF_BPF_COEFF3435, 0xfa0009a4}, | ||
1182 | {7700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1183 | /* END - DIF BPF register values from 77_quant.dat*/ | ||
1184 | |||
1185 | |||
1186 | /*case 7800000:*/ | ||
1187 | /* BEGIN - DIF BPF register values from 78_quant.dat*/ | ||
1188 | {7800000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
1189 | {7800000, DIF_BPF_COEFF23, 0xfffd000b}, | ||
1190 | {7800000, DIF_BPF_COEFF45, 0x0022001d}, | ||
1191 | {7800000, DIF_BPF_COEFF67, 0xffdbff82}, | ||
1192 | {7800000, DIF_BPF_COEFF89, 0xff870039}, | ||
1193 | {7800000, DIF_BPF_COEFF1011, 0x012a014a}, | ||
1194 | {7800000, DIF_BPF_COEFF1213, 0xffedfde7}, | ||
1195 | {7800000, DIF_BPF_COEFF1415, 0xfd47ff6b}, | ||
1196 | {7800000, DIF_BPF_COEFF1617, 0x031104c6}, | ||
1197 | {7800000, DIF_BPF_COEFF1819, 0x0202fc4c}, | ||
1198 | {7800000, DIF_BPF_COEFF2021, 0xf8c6fbad}, | ||
1199 | {7800000, DIF_BPF_COEFF2223, 0x039909a7}, | ||
1200 | {7800000, DIF_BPF_COEFF2425, 0x0767fd8e}, | ||
1201 | {7800000, DIF_BPF_COEFF2627, 0xf482f52b}, | ||
1202 | {7800000, DIF_BPF_COEFF2829, 0x002d0c39}, | ||
1203 | {7800000, DIF_BPF_COEFF3031, 0x0e0002f4}, | ||
1204 | {7800000, DIF_BPF_COEFF3233, 0xf477efc2}, | ||
1205 | {7800000, DIF_BPF_COEFF3435, 0xf99b0977}, | ||
1206 | {7800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1207 | /* END - DIF BPF register values from 78_quant.dat*/ | ||
1208 | |||
1209 | |||
1210 | /*case 7900000:*/ | ||
1211 | /* BEGIN - DIF BPF register values from 79_quant.dat*/ | ||
1212 | {7900000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
1213 | {7900000, DIF_BPF_COEFF23, 0xfffa0004}, | ||
1214 | {7900000, DIF_BPF_COEFF45, 0x0020002d}, | ||
1215 | {7900000, DIF_BPF_COEFF67, 0xfffbff91}, | ||
1216 | {7900000, DIF_BPF_COEFF89, 0xff61ffe8}, | ||
1217 | {7900000, DIF_BPF_COEFF1011, 0x00f70184}, | ||
1218 | {7900000, DIF_BPF_COEFF1213, 0x0086fe5c}, | ||
1219 | {7900000, DIF_BPF_COEFF1415, 0xfd0bfe85}, | ||
1220 | {7900000, DIF_BPF_COEFF1617, 0x024104e5}, | ||
1221 | {7900000, DIF_BPF_COEFF1819, 0x0323fd7d}, | ||
1222 | {7900000, DIF_BPF_COEFF2021, 0xf8e2fa79}, | ||
1223 | {7900000, DIF_BPF_COEFF2223, 0x021d093f}, | ||
1224 | {7900000, DIF_BPF_COEFF2425, 0x0879ff22}, | ||
1225 | {7900000, DIF_BPF_COEFF2627, 0xf52bf465}, | ||
1226 | {7900000, DIF_BPF_COEFF2829, 0xfec70b79}, | ||
1227 | {7900000, DIF_BPF_COEFF3031, 0x0e6803eb}, | ||
1228 | {7900000, DIF_BPF_COEFF3233, 0xf50defa5}, | ||
1229 | {7900000, DIF_BPF_COEFF3435, 0xf937094a}, | ||
1230 | {7900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1231 | /* END - DIF BPF register values from 79_quant.dat*/ | ||
1232 | |||
1233 | |||
1234 | /*case 8000000:*/ | ||
1235 | /* BEGIN - DIF BPF register values from 80_quant.dat*/ | ||
1236 | {8000000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
1237 | {8000000, DIF_BPF_COEFF23, 0xfff8fffd}, | ||
1238 | {8000000, DIF_BPF_COEFF45, 0x00190036}, | ||
1239 | {8000000, DIF_BPF_COEFF67, 0x001bffaf}, | ||
1240 | {8000000, DIF_BPF_COEFF89, 0xff4fff99}, | ||
1241 | {8000000, DIF_BPF_COEFF1011, 0x00aa0198}, | ||
1242 | {8000000, DIF_BPF_COEFF1213, 0x0112fef3}, | ||
1243 | {8000000, DIF_BPF_COEFF1415, 0xfd09fdb9}, | ||
1244 | {8000000, DIF_BPF_COEFF1617, 0x014d04be}, | ||
1245 | {8000000, DIF_BPF_COEFF1819, 0x041bfecc}, | ||
1246 | {8000000, DIF_BPF_COEFF2021, 0xf947f978}, | ||
1247 | {8000000, DIF_BPF_COEFF2223, 0x00900897}, | ||
1248 | {8000000, DIF_BPF_COEFF2425, 0x095a00b9}, | ||
1249 | {8000000, DIF_BPF_COEFF2627, 0xf600f3c5}, | ||
1250 | {8000000, DIF_BPF_COEFF2829, 0xfd650aa3}, | ||
1251 | {8000000, DIF_BPF_COEFF3031, 0x0ebc04de}, | ||
1252 | {8000000, DIF_BPF_COEFF3233, 0xf5aaef8e}, | ||
1253 | {8000000, DIF_BPF_COEFF3435, 0xf8d5091c}, | ||
1254 | {8000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1255 | /* END - DIF BPF register values from 80_quant.dat*/ | ||
1256 | |||
1257 | |||
1258 | /*case 8100000:*/ | ||
1259 | /* BEGIN - DIF BPF register values from 81_quant.dat*/ | ||
1260 | {8100000, DIF_BPF_COEFF01, 0x0000ffff}, | ||
1261 | {8100000, DIF_BPF_COEFF23, 0xfff7fff6}, | ||
1262 | {8100000, DIF_BPF_COEFF45, 0x000e0038}, | ||
1263 | {8100000, DIF_BPF_COEFF67, 0x0037ffd7}, | ||
1264 | {8100000, DIF_BPF_COEFF89, 0xff52ff56}, | ||
1265 | {8100000, DIF_BPF_COEFF1011, 0x004b0184}, | ||
1266 | {8100000, DIF_BPF_COEFF1213, 0x0186ffa1}, | ||
1267 | {8100000, DIF_BPF_COEFF1415, 0xfd40fd16}, | ||
1268 | {8100000, DIF_BPF_COEFF1617, 0x00440452}, | ||
1269 | {8100000, DIF_BPF_COEFF1819, 0x04de0029}, | ||
1270 | {8100000, DIF_BPF_COEFF2021, 0xf9f2f8b2}, | ||
1271 | {8100000, DIF_BPF_COEFF2223, 0xfefe07b5}, | ||
1272 | {8100000, DIF_BPF_COEFF2425, 0x0a05024d}, | ||
1273 | {8100000, DIF_BPF_COEFF2627, 0xf6fef34d}, | ||
1274 | {8100000, DIF_BPF_COEFF2829, 0xfc0a09b8}, | ||
1275 | {8100000, DIF_BPF_COEFF3031, 0x0efa05cd}, | ||
1276 | {8100000, DIF_BPF_COEFF3233, 0xf64eef7d}, | ||
1277 | {8100000, DIF_BPF_COEFF3435, 0xf87308ed}, | ||
1278 | {8100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1279 | /* END - DIF BPF register values from 81_quant.dat*/ | ||
1280 | |||
1281 | |||
1282 | /*case 8200000:*/ | ||
1283 | /* BEGIN - DIF BPF register values from 82_quant.dat*/ | ||
1284 | {8200000, DIF_BPF_COEFF01, 0x00010000}, | ||
1285 | {8200000, DIF_BPF_COEFF23, 0xfff8fff0}, | ||
1286 | {8200000, DIF_BPF_COEFF45, 0x00000031}, | ||
1287 | {8200000, DIF_BPF_COEFF67, 0x004c0005}, | ||
1288 | {8200000, DIF_BPF_COEFF89, 0xff6aff27}, | ||
1289 | {8200000, DIF_BPF_COEFF1011, 0xffe4014a}, | ||
1290 | {8200000, DIF_BPF_COEFF1213, 0x01d70057}, | ||
1291 | {8200000, DIF_BPF_COEFF1415, 0xfdacfca6}, | ||
1292 | {8200000, DIF_BPF_COEFF1617, 0xff3603a7}, | ||
1293 | {8200000, DIF_BPF_COEFF1819, 0x05610184}, | ||
1294 | {8200000, DIF_BPF_COEFF2021, 0xfadbf82e}, | ||
1295 | {8200000, DIF_BPF_COEFF2223, 0xfd74069f}, | ||
1296 | {8200000, DIF_BPF_COEFF2425, 0x0a7503d6}, | ||
1297 | {8200000, DIF_BPF_COEFF2627, 0xf81ff2ff}, | ||
1298 | {8200000, DIF_BPF_COEFF2829, 0xfab808b9}, | ||
1299 | {8200000, DIF_BPF_COEFF3031, 0x0f2306b5}, | ||
1300 | {8200000, DIF_BPF_COEFF3233, 0xf6f9ef72}, | ||
1301 | {8200000, DIF_BPF_COEFF3435, 0xf81308bf}, | ||
1302 | {8200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1303 | /* END - DIF BPF register values from 82_quant.dat*/ | ||
1304 | |||
1305 | |||
1306 | /*case 8300000:*/ | ||
1307 | /* BEGIN - DIF BPF register values from 83_quant.dat*/ | ||
1308 | {8300000, DIF_BPF_COEFF01, 0x00010001}, | ||
1309 | {8300000, DIF_BPF_COEFF23, 0xfffbffee}, | ||
1310 | {8300000, DIF_BPF_COEFF45, 0xfff30022}, | ||
1311 | {8300000, DIF_BPF_COEFF67, 0x00560032}, | ||
1312 | {8300000, DIF_BPF_COEFF89, 0xff95ff10}, | ||
1313 | {8300000, DIF_BPF_COEFF1011, 0xff8000f0}, | ||
1314 | {8300000, DIF_BPF_COEFF1213, 0x01fe0106}, | ||
1315 | {8300000, DIF_BPF_COEFF1415, 0xfe46fc71}, | ||
1316 | {8300000, DIF_BPF_COEFF1617, 0xfe3502c7}, | ||
1317 | {8300000, DIF_BPF_COEFF1819, 0x059e02ce}, | ||
1318 | {8300000, DIF_BPF_COEFF2021, 0xfbf9f7f2}, | ||
1319 | {8300000, DIF_BPF_COEFF2223, 0xfbff055b}, | ||
1320 | {8300000, DIF_BPF_COEFF2425, 0x0aa9054c}, | ||
1321 | {8300000, DIF_BPF_COEFF2627, 0xf961f2db}, | ||
1322 | {8300000, DIF_BPF_COEFF2829, 0xf97507aa}, | ||
1323 | {8300000, DIF_BPF_COEFF3031, 0x0f350797}, | ||
1324 | {8300000, DIF_BPF_COEFF3233, 0xf7a9ef6d}, | ||
1325 | {8300000, DIF_BPF_COEFF3435, 0xf7b40890}, | ||
1326 | {8300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1327 | /* END - DIF BPF register values from 83_quant.dat*/ | ||
1328 | |||
1329 | |||
1330 | /*case 8400000:*/ | ||
1331 | /* BEGIN - DIF BPF register values from 84_quant.dat*/ | ||
1332 | {8400000, DIF_BPF_COEFF01, 0x00010002}, | ||
1333 | {8400000, DIF_BPF_COEFF23, 0xfffeffee}, | ||
1334 | {8400000, DIF_BPF_COEFF45, 0xffe8000f}, | ||
1335 | {8400000, DIF_BPF_COEFF67, 0x00540058}, | ||
1336 | {8400000, DIF_BPF_COEFF89, 0xffcdff14}, | ||
1337 | {8400000, DIF_BPF_COEFF1011, 0xff29007e}, | ||
1338 | {8400000, DIF_BPF_COEFF1213, 0x01f6019e}, | ||
1339 | {8400000, DIF_BPF_COEFF1415, 0xff01fc7c}, | ||
1340 | {8400000, DIF_BPF_COEFF1617, 0xfd5101bf}, | ||
1341 | {8400000, DIF_BPF_COEFF1819, 0x059203f6}, | ||
1342 | {8400000, DIF_BPF_COEFF2021, 0xfd41f7fe}, | ||
1343 | {8400000, DIF_BPF_COEFF2223, 0xfaa903f3}, | ||
1344 | {8400000, DIF_BPF_COEFF2425, 0x0a9e06a9}, | ||
1345 | {8400000, DIF_BPF_COEFF2627, 0xfabdf2e2}, | ||
1346 | {8400000, DIF_BPF_COEFF2829, 0xf842068b}, | ||
1347 | {8400000, DIF_BPF_COEFF3031, 0x0f320871}, | ||
1348 | {8400000, DIF_BPF_COEFF3233, 0xf85eef6e}, | ||
1349 | {8400000, DIF_BPF_COEFF3435, 0xf7560860}, | ||
1350 | {8400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1351 | /* END - DIF BPF register values from 84_quant.dat*/ | ||
1352 | |||
1353 | |||
1354 | /*case 8500000:*/ | ||
1355 | /* BEGIN - DIF BPF register values from 85_quant.dat*/ | ||
1356 | {8500000, DIF_BPF_COEFF01, 0x00000003}, | ||
1357 | {8500000, DIF_BPF_COEFF23, 0x0002fff2}, | ||
1358 | {8500000, DIF_BPF_COEFF45, 0xffe1fff9}, | ||
1359 | {8500000, DIF_BPF_COEFF67, 0x00460073}, | ||
1360 | {8500000, DIF_BPF_COEFF89, 0x000bff34}, | ||
1361 | {8500000, DIF_BPF_COEFF1011, 0xfee90000}, | ||
1362 | {8500000, DIF_BPF_COEFF1213, 0x01c10215}, | ||
1363 | {8500000, DIF_BPF_COEFF1415, 0xffd0fcc5}, | ||
1364 | {8500000, DIF_BPF_COEFF1617, 0xfc99009d}, | ||
1365 | {8500000, DIF_BPF_COEFF1819, 0x053d04f1}, | ||
1366 | {8500000, DIF_BPF_COEFF2021, 0xfea5f853}, | ||
1367 | {8500000, DIF_BPF_COEFF2223, 0xf97d0270}, | ||
1368 | {8500000, DIF_BPF_COEFF2425, 0x0a5607e4}, | ||
1369 | {8500000, DIF_BPF_COEFF2627, 0xfc2ef314}, | ||
1370 | {8500000, DIF_BPF_COEFF2829, 0xf723055f}, | ||
1371 | {8500000, DIF_BPF_COEFF3031, 0x0f180943}, | ||
1372 | {8500000, DIF_BPF_COEFF3233, 0xf919ef75}, | ||
1373 | {8500000, DIF_BPF_COEFF3435, 0xf6fa0830}, | ||
1374 | {8500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1375 | /* END - DIF BPF register values from 85_quant.dat*/ | ||
1376 | |||
1377 | |||
1378 | /*case 8600000:*/ | ||
1379 | /* BEGIN - DIF BPF register values from 86_quant.dat*/ | ||
1380 | {8600000, DIF_BPF_COEFF01, 0x00000003}, | ||
1381 | {8600000, DIF_BPF_COEFF23, 0x0005fff8}, | ||
1382 | {8600000, DIF_BPF_COEFF45, 0xffdeffe4}, | ||
1383 | {8600000, DIF_BPF_COEFF67, 0x002f007f}, | ||
1384 | {8600000, DIF_BPF_COEFF89, 0x0048ff6b}, | ||
1385 | {8600000, DIF_BPF_COEFF1011, 0xfec7ff82}, | ||
1386 | {8600000, DIF_BPF_COEFF1213, 0x0163025f}, | ||
1387 | {8600000, DIF_BPF_COEFF1415, 0x00a2fd47}, | ||
1388 | {8600000, DIF_BPF_COEFF1617, 0xfc17ff73}, | ||
1389 | {8600000, DIF_BPF_COEFF1819, 0x04a405b2}, | ||
1390 | {8600000, DIF_BPF_COEFF2021, 0x0017f8ed}, | ||
1391 | {8600000, DIF_BPF_COEFF2223, 0xf88500dc}, | ||
1392 | {8600000, DIF_BPF_COEFF2425, 0x09d208f9}, | ||
1393 | {8600000, DIF_BPF_COEFF2627, 0xfdaff370}, | ||
1394 | {8600000, DIF_BPF_COEFF2829, 0xf61c0429}, | ||
1395 | {8600000, DIF_BPF_COEFF3031, 0x0ee80a0b}, | ||
1396 | {8600000, DIF_BPF_COEFF3233, 0xf9d8ef82}, | ||
1397 | {8600000, DIF_BPF_COEFF3435, 0xf6a00800}, | ||
1398 | {8600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1399 | /* END - DIF BPF register values from 86_quant.dat*/ | ||
1400 | |||
1401 | |||
1402 | /*case 8700000:*/ | ||
1403 | /* BEGIN - DIF BPF register values from 87_quant.dat*/ | ||
1404 | {8700000, DIF_BPF_COEFF01, 0x00000003}, | ||
1405 | {8700000, DIF_BPF_COEFF23, 0x0007ffff}, | ||
1406 | {8700000, DIF_BPF_COEFF45, 0xffe1ffd4}, | ||
1407 | {8700000, DIF_BPF_COEFF67, 0x0010007a}, | ||
1408 | {8700000, DIF_BPF_COEFF89, 0x007cffb2}, | ||
1409 | {8700000, DIF_BPF_COEFF1011, 0xfec6ff10}, | ||
1410 | {8700000, DIF_BPF_COEFF1213, 0x00e60277}, | ||
1411 | {8700000, DIF_BPF_COEFF1415, 0x0168fdf9}, | ||
1412 | {8700000, DIF_BPF_COEFF1617, 0xfbd3fe50}, | ||
1413 | {8700000, DIF_BPF_COEFF1819, 0x03ce0631}, | ||
1414 | {8700000, DIF_BPF_COEFF2021, 0x0188f9c8}, | ||
1415 | {8700000, DIF_BPF_COEFF2223, 0xf7c7ff43}, | ||
1416 | {8700000, DIF_BPF_COEFF2425, 0x091509e3}, | ||
1417 | {8700000, DIF_BPF_COEFF2627, 0xff39f3f6}, | ||
1418 | {8700000, DIF_BPF_COEFF2829, 0xf52d02ea}, | ||
1419 | {8700000, DIF_BPF_COEFF3031, 0x0ea30ac9}, | ||
1420 | {8700000, DIF_BPF_COEFF3233, 0xfa9bef95}, | ||
1421 | {8700000, DIF_BPF_COEFF3435, 0xf64607d0}, | ||
1422 | {8700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1423 | /* END - DIF BPF register values from 87_quant.dat*/ | ||
1424 | |||
1425 | |||
1426 | /*case 8800000:*/ | ||
1427 | /* BEGIN - DIF BPF register values from 88_quant.dat*/ | ||
1428 | {8800000, DIF_BPF_COEFF01, 0x00000002}, | ||
1429 | {8800000, DIF_BPF_COEFF23, 0x00090007}, | ||
1430 | {8800000, DIF_BPF_COEFF45, 0xffe9ffca}, | ||
1431 | {8800000, DIF_BPF_COEFF67, 0xfff00065}, | ||
1432 | {8800000, DIF_BPF_COEFF89, 0x00a10003}, | ||
1433 | {8800000, DIF_BPF_COEFF1011, 0xfee6feb6}, | ||
1434 | {8800000, DIF_BPF_COEFF1213, 0x0053025b}, | ||
1435 | {8800000, DIF_BPF_COEFF1415, 0x0213fed0}, | ||
1436 | {8800000, DIF_BPF_COEFF1617, 0xfbd3fd46}, | ||
1437 | {8800000, DIF_BPF_COEFF1819, 0x02c70668}, | ||
1438 | {8800000, DIF_BPF_COEFF2021, 0x02eafadb}, | ||
1439 | {8800000, DIF_BPF_COEFF2223, 0xf74bfdae}, | ||
1440 | {8800000, DIF_BPF_COEFF2425, 0x08230a9c}, | ||
1441 | {8800000, DIF_BPF_COEFF2627, 0x00c7f4a3}, | ||
1442 | {8800000, DIF_BPF_COEFF2829, 0xf45b01a6}, | ||
1443 | {8800000, DIF_BPF_COEFF3031, 0x0e480b7c}, | ||
1444 | {8800000, DIF_BPF_COEFF3233, 0xfb61efae}, | ||
1445 | {8800000, DIF_BPF_COEFF3435, 0xf5ef079f}, | ||
1446 | {8800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1447 | /* END - DIF BPF register values from 88_quant.dat*/ | ||
1448 | |||
1449 | |||
1450 | /*case 8900000:*/ | ||
1451 | /* BEGIN - DIF BPF register values from 89_quant.dat*/ | ||
1452 | {8900000, DIF_BPF_COEFF01, 0xffff0000}, | ||
1453 | {8900000, DIF_BPF_COEFF23, 0x0008000d}, | ||
1454 | {8900000, DIF_BPF_COEFF45, 0xfff5ffc8}, | ||
1455 | {8900000, DIF_BPF_COEFF67, 0xffd10043}, | ||
1456 | {8900000, DIF_BPF_COEFF89, 0x00b20053}, | ||
1457 | {8900000, DIF_BPF_COEFF1011, 0xff24fe7c}, | ||
1458 | {8900000, DIF_BPF_COEFF1213, 0xffb9020c}, | ||
1459 | {8900000, DIF_BPF_COEFF1415, 0x0295ffbb}, | ||
1460 | {8900000, DIF_BPF_COEFF1617, 0xfc17fc64}, | ||
1461 | {8900000, DIF_BPF_COEFF1819, 0x019b0654}, | ||
1462 | {8900000, DIF_BPF_COEFF2021, 0x042dfc1c}, | ||
1463 | {8900000, DIF_BPF_COEFF2223, 0xf714fc2a}, | ||
1464 | {8900000, DIF_BPF_COEFF2425, 0x07020b21}, | ||
1465 | {8900000, DIF_BPF_COEFF2627, 0x0251f575}, | ||
1466 | {8900000, DIF_BPF_COEFF2829, 0xf3a7005e}, | ||
1467 | {8900000, DIF_BPF_COEFF3031, 0x0dd80c24}, | ||
1468 | {8900000, DIF_BPF_COEFF3233, 0xfc2aefcd}, | ||
1469 | {8900000, DIF_BPF_COEFF3435, 0xf599076e}, | ||
1470 | {8900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1471 | /* END - DIF BPF register values from 89_quant.dat*/ | ||
1472 | |||
1473 | |||
1474 | /*case 9000000:*/ | ||
1475 | /* BEGIN - DIF BPF register values from 90_quant.dat*/ | ||
1476 | {9000000, DIF_BPF_COEFF01, 0xffffffff}, | ||
1477 | {9000000, DIF_BPF_COEFF23, 0x00060011}, | ||
1478 | {9000000, DIF_BPF_COEFF45, 0x0002ffcf}, | ||
1479 | {9000000, DIF_BPF_COEFF67, 0xffba0018}, | ||
1480 | {9000000, DIF_BPF_COEFF89, 0x00ad009a}, | ||
1481 | {9000000, DIF_BPF_COEFF1011, 0xff79fe68}, | ||
1482 | {9000000, DIF_BPF_COEFF1213, 0xff260192}, | ||
1483 | {9000000, DIF_BPF_COEFF1415, 0x02e500ab}, | ||
1484 | {9000000, DIF_BPF_COEFF1617, 0xfc99fbb6}, | ||
1485 | {9000000, DIF_BPF_COEFF1819, 0x005b05f7}, | ||
1486 | {9000000, DIF_BPF_COEFF2021, 0x0545fd81}, | ||
1487 | {9000000, DIF_BPF_COEFF2223, 0xf723fabf}, | ||
1488 | {9000000, DIF_BPF_COEFF2425, 0x05b80b70}, | ||
1489 | {9000000, DIF_BPF_COEFF2627, 0x03d2f669}, | ||
1490 | {9000000, DIF_BPF_COEFF2829, 0xf313ff15}, | ||
1491 | {9000000, DIF_BPF_COEFF3031, 0x0d550cbf}, | ||
1492 | {9000000, DIF_BPF_COEFF3233, 0xfcf6eff2}, | ||
1493 | {9000000, DIF_BPF_COEFF3435, 0xf544073d}, | ||
1494 | {9000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1495 | /* END - DIF BPF register values from 90_quant.dat*/ | ||
1496 | |||
1497 | |||
1498 | /*case 9100000:*/ | ||
1499 | /* BEGIN - DIF BPF register values from 91_quant.dat*/ | ||
1500 | {9100000, DIF_BPF_COEFF01, 0xfffffffe}, | ||
1501 | {9100000, DIF_BPF_COEFF23, 0x00030012}, | ||
1502 | {9100000, DIF_BPF_COEFF45, 0x000fffdd}, | ||
1503 | {9100000, DIF_BPF_COEFF67, 0xffacffea}, | ||
1504 | {9100000, DIF_BPF_COEFF89, 0x009300cf}, | ||
1505 | {9100000, DIF_BPF_COEFF1011, 0xffdcfe7c}, | ||
1506 | {9100000, DIF_BPF_COEFF1213, 0xfea600f7}, | ||
1507 | {9100000, DIF_BPF_COEFF1415, 0x02fd0190}, | ||
1508 | {9100000, DIF_BPF_COEFF1617, 0xfd51fb46}, | ||
1509 | {9100000, DIF_BPF_COEFF1819, 0xff150554}, | ||
1510 | {9100000, DIF_BPF_COEFF2021, 0x0627fefd}, | ||
1511 | {9100000, DIF_BPF_COEFF2223, 0xf778f978}, | ||
1512 | {9100000, DIF_BPF_COEFF2425, 0x044d0b87}, | ||
1513 | {9100000, DIF_BPF_COEFF2627, 0x0543f77d}, | ||
1514 | {9100000, DIF_BPF_COEFF2829, 0xf2a0fdcf}, | ||
1515 | {9100000, DIF_BPF_COEFF3031, 0x0cbe0d4e}, | ||
1516 | {9100000, DIF_BPF_COEFF3233, 0xfdc4f01d}, | ||
1517 | {9100000, DIF_BPF_COEFF3435, 0xf4f2070b}, | ||
1518 | {9100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1519 | /* END - DIF BPF register values from 91_quant.dat*/ | ||
1520 | |||
1521 | |||
1522 | /*case 9200000:*/ | ||
1523 | /* BEGIN - DIF BPF register values from 92_quant.dat*/ | ||
1524 | {9200000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
1525 | {9200000, DIF_BPF_COEFF23, 0x00000010}, | ||
1526 | {9200000, DIF_BPF_COEFF45, 0x001afff0}, | ||
1527 | {9200000, DIF_BPF_COEFF67, 0xffaaffbf}, | ||
1528 | {9200000, DIF_BPF_COEFF89, 0x006700ed}, | ||
1529 | {9200000, DIF_BPF_COEFF1011, 0x0043feb6}, | ||
1530 | {9200000, DIF_BPF_COEFF1213, 0xfe460047}, | ||
1531 | {9200000, DIF_BPF_COEFF1415, 0x02db0258}, | ||
1532 | {9200000, DIF_BPF_COEFF1617, 0xfe35fb1b}, | ||
1533 | {9200000, DIF_BPF_COEFF1819, 0xfddc0473}, | ||
1534 | {9200000, DIF_BPF_COEFF2021, 0x06c90082}, | ||
1535 | {9200000, DIF_BPF_COEFF2223, 0xf811f85e}, | ||
1536 | {9200000, DIF_BPF_COEFF2425, 0x02c90b66}, | ||
1537 | {9200000, DIF_BPF_COEFF2627, 0x069ff8ad}, | ||
1538 | {9200000, DIF_BPF_COEFF2829, 0xf250fc8d}, | ||
1539 | {9200000, DIF_BPF_COEFF3031, 0x0c140dcf}, | ||
1540 | {9200000, DIF_BPF_COEFF3233, 0xfe93f04d}, | ||
1541 | {9200000, DIF_BPF_COEFF3435, 0xf4a106d9}, | ||
1542 | {9200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1543 | /* END - DIF BPF register values from 92_quant.dat*/ | ||
1544 | |||
1545 | |||
1546 | /*case 9300000:*/ | ||
1547 | /* BEGIN - DIF BPF register values from 93_quant.dat*/ | ||
1548 | {9300000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
1549 | {9300000, DIF_BPF_COEFF23, 0xfffc000c}, | ||
1550 | {9300000, DIF_BPF_COEFF45, 0x00200006}, | ||
1551 | {9300000, DIF_BPF_COEFF67, 0xffb4ff9c}, | ||
1552 | {9300000, DIF_BPF_COEFF89, 0x002f00ef}, | ||
1553 | {9300000, DIF_BPF_COEFF1011, 0x00a4ff10}, | ||
1554 | {9300000, DIF_BPF_COEFF1213, 0xfe0dff92}, | ||
1555 | {9300000, DIF_BPF_COEFF1415, 0x028102f7}, | ||
1556 | {9300000, DIF_BPF_COEFF1617, 0xff36fb37}, | ||
1557 | {9300000, DIF_BPF_COEFF1819, 0xfcbf035e}, | ||
1558 | {9300000, DIF_BPF_COEFF2021, 0x07260202}, | ||
1559 | {9300000, DIF_BPF_COEFF2223, 0xf8e8f778}, | ||
1560 | {9300000, DIF_BPF_COEFF2425, 0x01340b0d}, | ||
1561 | {9300000, DIF_BPF_COEFF2627, 0x07e1f9f4}, | ||
1562 | {9300000, DIF_BPF_COEFF2829, 0xf223fb51}, | ||
1563 | {9300000, DIF_BPF_COEFF3031, 0x0b590e42}, | ||
1564 | {9300000, DIF_BPF_COEFF3233, 0xff64f083}, | ||
1565 | {9300000, DIF_BPF_COEFF3435, 0xf45206a7}, | ||
1566 | {9300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1567 | /* END - DIF BPF register values from 93_quant.dat*/ | ||
1568 | |||
1569 | |||
1570 | /*case 9400000:*/ | ||
1571 | /* BEGIN - DIF BPF register values from 94_quant.dat*/ | ||
1572 | {9400000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
1573 | {9400000, DIF_BPF_COEFF23, 0xfff90005}, | ||
1574 | {9400000, DIF_BPF_COEFF45, 0x0022001a}, | ||
1575 | {9400000, DIF_BPF_COEFF67, 0xffc9ff86}, | ||
1576 | {9400000, DIF_BPF_COEFF89, 0xfff000d7}, | ||
1577 | {9400000, DIF_BPF_COEFF1011, 0x00f2ff82}, | ||
1578 | {9400000, DIF_BPF_COEFF1213, 0xfe01fee5}, | ||
1579 | {9400000, DIF_BPF_COEFF1415, 0x01f60362}, | ||
1580 | {9400000, DIF_BPF_COEFF1617, 0x0044fb99}, | ||
1581 | {9400000, DIF_BPF_COEFF1819, 0xfbcc0222}, | ||
1582 | {9400000, DIF_BPF_COEFF2021, 0x07380370}, | ||
1583 | {9400000, DIF_BPF_COEFF2223, 0xf9f7f6cc}, | ||
1584 | {9400000, DIF_BPF_COEFF2425, 0xff990a7e}, | ||
1585 | {9400000, DIF_BPF_COEFF2627, 0x0902fb50}, | ||
1586 | {9400000, DIF_BPF_COEFF2829, 0xf21afa1f}, | ||
1587 | {9400000, DIF_BPF_COEFF3031, 0x0a8d0ea6}, | ||
1588 | {9400000, DIF_BPF_COEFF3233, 0x0034f0bf}, | ||
1589 | {9400000, DIF_BPF_COEFF3435, 0xf4050675}, | ||
1590 | {9400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1591 | /* END - DIF BPF register values from 94_quant.dat*/ | ||
1592 | |||
1593 | |||
1594 | /*case 9500000:*/ | ||
1595 | /* BEGIN - DIF BPF register values from 95_quant.dat*/ | ||
1596 | {9500000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
1597 | {9500000, DIF_BPF_COEFF23, 0xfff8fffe}, | ||
1598 | {9500000, DIF_BPF_COEFF45, 0x001e002b}, | ||
1599 | {9500000, DIF_BPF_COEFF67, 0xffe5ff81}, | ||
1600 | {9500000, DIF_BPF_COEFF89, 0xffb400a5}, | ||
1601 | {9500000, DIF_BPF_COEFF1011, 0x01280000}, | ||
1602 | {9500000, DIF_BPF_COEFF1213, 0xfe24fe50}, | ||
1603 | {9500000, DIF_BPF_COEFF1415, 0x01460390}, | ||
1604 | {9500000, DIF_BPF_COEFF1617, 0x014dfc3a}, | ||
1605 | {9500000, DIF_BPF_COEFF1819, 0xfb1000ce}, | ||
1606 | {9500000, DIF_BPF_COEFF2021, 0x070104bf}, | ||
1607 | {9500000, DIF_BPF_COEFF2223, 0xfb37f65f}, | ||
1608 | {9500000, DIF_BPF_COEFF2425, 0xfe0009bc}, | ||
1609 | {9500000, DIF_BPF_COEFF2627, 0x0a00fcbb}, | ||
1610 | {9500000, DIF_BPF_COEFF2829, 0xf235f8f8}, | ||
1611 | {9500000, DIF_BPF_COEFF3031, 0x09b20efc}, | ||
1612 | {9500000, DIF_BPF_COEFF3233, 0x0105f101}, | ||
1613 | {9500000, DIF_BPF_COEFF3435, 0xf3ba0642}, | ||
1614 | {9500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1615 | /* END - DIF BPF register values from 95_quant.dat*/ | ||
1616 | |||
1617 | |||
1618 | /*case 9600000:*/ | ||
1619 | /* BEGIN - DIF BPF register values from 96_quant.dat*/ | ||
1620 | {9600000, DIF_BPF_COEFF01, 0x0001ffff}, | ||
1621 | {9600000, DIF_BPF_COEFF23, 0xfff8fff7}, | ||
1622 | {9600000, DIF_BPF_COEFF45, 0x00150036}, | ||
1623 | {9600000, DIF_BPF_COEFF67, 0x0005ff8c}, | ||
1624 | {9600000, DIF_BPF_COEFF89, 0xff810061}, | ||
1625 | {9600000, DIF_BPF_COEFF1011, 0x013d007e}, | ||
1626 | {9600000, DIF_BPF_COEFF1213, 0xfe71fddf}, | ||
1627 | {9600000, DIF_BPF_COEFF1415, 0x007c0380}, | ||
1628 | {9600000, DIF_BPF_COEFF1617, 0x0241fd13}, | ||
1629 | {9600000, DIF_BPF_COEFF1819, 0xfa94ff70}, | ||
1630 | {9600000, DIF_BPF_COEFF2021, 0x068005e2}, | ||
1631 | {9600000, DIF_BPF_COEFF2223, 0xfc9bf633}, | ||
1632 | {9600000, DIF_BPF_COEFF2425, 0xfc7308ca}, | ||
1633 | {9600000, DIF_BPF_COEFF2627, 0x0ad5fe30}, | ||
1634 | {9600000, DIF_BPF_COEFF2829, 0xf274f7e0}, | ||
1635 | {9600000, DIF_BPF_COEFF3031, 0x08c90f43}, | ||
1636 | {9600000, DIF_BPF_COEFF3233, 0x01d4f147}, | ||
1637 | {9600000, DIF_BPF_COEFF3435, 0xf371060f}, | ||
1638 | {9600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1639 | /* END - DIF BPF register values from 96_quant.dat*/ | ||
1640 | |||
1641 | |||
1642 | /*case 9700000:*/ | ||
1643 | /* BEGIN - DIF BPF register values from 97_quant.dat*/ | ||
1644 | {9700000, DIF_BPF_COEFF01, 0x00010001}, | ||
1645 | {9700000, DIF_BPF_COEFF23, 0xfff9fff1}, | ||
1646 | {9700000, DIF_BPF_COEFF45, 0x00090038}, | ||
1647 | {9700000, DIF_BPF_COEFF67, 0x0025ffa7}, | ||
1648 | {9700000, DIF_BPF_COEFF89, 0xff5e0012}, | ||
1649 | {9700000, DIF_BPF_COEFF1011, 0x013200f0}, | ||
1650 | {9700000, DIF_BPF_COEFF1213, 0xfee3fd9b}, | ||
1651 | {9700000, DIF_BPF_COEFF1415, 0xffaa0331}, | ||
1652 | {9700000, DIF_BPF_COEFF1617, 0x0311fe15}, | ||
1653 | {9700000, DIF_BPF_COEFF1819, 0xfa60fe18}, | ||
1654 | {9700000, DIF_BPF_COEFF2021, 0x05bd06d1}, | ||
1655 | {9700000, DIF_BPF_COEFF2223, 0xfe1bf64a}, | ||
1656 | {9700000, DIF_BPF_COEFF2425, 0xfafa07ae}, | ||
1657 | {9700000, DIF_BPF_COEFF2627, 0x0b7effab}, | ||
1658 | {9700000, DIF_BPF_COEFF2829, 0xf2d5f6d7}, | ||
1659 | {9700000, DIF_BPF_COEFF3031, 0x07d30f7a}, | ||
1660 | {9700000, DIF_BPF_COEFF3233, 0x02a3f194}, | ||
1661 | {9700000, DIF_BPF_COEFF3435, 0xf32905dc}, | ||
1662 | {9700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1663 | /* END - DIF BPF register values from 97_quant.dat*/ | ||
1664 | |||
1665 | |||
1666 | /*case 9800000:*/ | ||
1667 | /* BEGIN - DIF BPF register values from 98_quant.dat*/ | ||
1668 | {9800000, DIF_BPF_COEFF01, 0x00010002}, | ||
1669 | {9800000, DIF_BPF_COEFF23, 0xfffcffee}, | ||
1670 | {9800000, DIF_BPF_COEFF45, 0xfffb0032}, | ||
1671 | {9800000, DIF_BPF_COEFF67, 0x003fffcd}, | ||
1672 | {9800000, DIF_BPF_COEFF89, 0xff4effc1}, | ||
1673 | {9800000, DIF_BPF_COEFF1011, 0x0106014a}, | ||
1674 | {9800000, DIF_BPF_COEFF1213, 0xff6efd8a}, | ||
1675 | {9800000, DIF_BPF_COEFF1415, 0xfedd02aa}, | ||
1676 | {9800000, DIF_BPF_COEFF1617, 0x03b0ff34}, | ||
1677 | {9800000, DIF_BPF_COEFF1819, 0xfa74fcd7}, | ||
1678 | {9800000, DIF_BPF_COEFF2021, 0x04bf0781}, | ||
1679 | {9800000, DIF_BPF_COEFF2223, 0xffaaf6a3}, | ||
1680 | {9800000, DIF_BPF_COEFF2425, 0xf99e066b}, | ||
1681 | {9800000, DIF_BPF_COEFF2627, 0x0bf90128}, | ||
1682 | {9800000, DIF_BPF_COEFF2829, 0xf359f5e1}, | ||
1683 | {9800000, DIF_BPF_COEFF3031, 0x06d20fa2}, | ||
1684 | {9800000, DIF_BPF_COEFF3233, 0x0370f1e5}, | ||
1685 | {9800000, DIF_BPF_COEFF3435, 0xf2e405a8}, | ||
1686 | {9800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1687 | /* END - DIF BPF register values from 98_quant.dat*/ | ||
1688 | |||
1689 | |||
1690 | /*case 9900000:*/ | ||
1691 | /* BEGIN - DIF BPF register values from 99_quant.dat*/ | ||
1692 | {9900000, DIF_BPF_COEFF01, 0x00000003}, | ||
1693 | {9900000, DIF_BPF_COEFF23, 0xffffffee}, | ||
1694 | {9900000, DIF_BPF_COEFF45, 0xffef0024}, | ||
1695 | {9900000, DIF_BPF_COEFF67, 0x0051fffa}, | ||
1696 | {9900000, DIF_BPF_COEFF89, 0xff54ff77}, | ||
1697 | {9900000, DIF_BPF_COEFF1011, 0x00be0184}, | ||
1698 | {9900000, DIF_BPF_COEFF1213, 0x0006fdad}, | ||
1699 | {9900000, DIF_BPF_COEFF1415, 0xfe2701f3}, | ||
1700 | {9900000, DIF_BPF_COEFF1617, 0x0413005e}, | ||
1701 | {9900000, DIF_BPF_COEFF1819, 0xfad1fbba}, | ||
1702 | {9900000, DIF_BPF_COEFF2021, 0x039007ee}, | ||
1703 | {9900000, DIF_BPF_COEFF2223, 0x013bf73d}, | ||
1704 | {9900000, DIF_BPF_COEFF2425, 0xf868050a}, | ||
1705 | {9900000, DIF_BPF_COEFF2627, 0x0c4302a1}, | ||
1706 | {9900000, DIF_BPF_COEFF2829, 0xf3fdf4fe}, | ||
1707 | {9900000, DIF_BPF_COEFF3031, 0x05c70fba}, | ||
1708 | {9900000, DIF_BPF_COEFF3233, 0x043bf23c}, | ||
1709 | {9900000, DIF_BPF_COEFF3435, 0xf2a10575}, | ||
1710 | {9900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1711 | /* END - DIF BPF register values from 99_quant.dat*/ | ||
1712 | |||
1713 | |||
1714 | /*case 10000000:*/ | ||
1715 | /* BEGIN - DIF BPF register values from 100_quant.dat*/ | ||
1716 | {10000000, DIF_BPF_COEFF01, 0x00000003}, | ||
1717 | {10000000, DIF_BPF_COEFF23, 0x0003fff1}, | ||
1718 | {10000000, DIF_BPF_COEFF45, 0xffe50011}, | ||
1719 | {10000000, DIF_BPF_COEFF67, 0x00570027}, | ||
1720 | {10000000, DIF_BPF_COEFF89, 0xff70ff3c}, | ||
1721 | {10000000, DIF_BPF_COEFF1011, 0x00620198}, | ||
1722 | {10000000, DIF_BPF_COEFF1213, 0x009efe01}, | ||
1723 | {10000000, DIF_BPF_COEFF1415, 0xfd95011a}, | ||
1724 | {10000000, DIF_BPF_COEFF1617, 0x04350183}, | ||
1725 | {10000000, DIF_BPF_COEFF1819, 0xfb71fad0}, | ||
1726 | {10000000, DIF_BPF_COEFF2021, 0x023c0812}, | ||
1727 | {10000000, DIF_BPF_COEFF2223, 0x02c3f811}, | ||
1728 | {10000000, DIF_BPF_COEFF2425, 0xf75e0390}, | ||
1729 | {10000000, DIF_BPF_COEFF2627, 0x0c5c0411}, | ||
1730 | {10000000, DIF_BPF_COEFF2829, 0xf4c1f432}, | ||
1731 | {10000000, DIF_BPF_COEFF3031, 0x04b30fc1}, | ||
1732 | {10000000, DIF_BPF_COEFF3233, 0x0503f297}, | ||
1733 | {10000000, DIF_BPF_COEFF3435, 0xf2610541}, | ||
1734 | {10000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1735 | /* END - DIF BPF register values from 100_quant.dat*/ | ||
1736 | |||
1737 | |||
1738 | /*case 10100000:*/ | ||
1739 | /* BEGIN - DIF BPF register values from 101_quant.dat*/ | ||
1740 | {10100000, DIF_BPF_COEFF01, 0x00000003}, | ||
1741 | {10100000, DIF_BPF_COEFF23, 0x0006fff7}, | ||
1742 | {10100000, DIF_BPF_COEFF45, 0xffdffffc}, | ||
1743 | {10100000, DIF_BPF_COEFF67, 0x00510050}, | ||
1744 | {10100000, DIF_BPF_COEFF89, 0xff9dff18}, | ||
1745 | {10100000, DIF_BPF_COEFF1011, 0xfffc0184}, | ||
1746 | {10100000, DIF_BPF_COEFF1213, 0x0128fe80}, | ||
1747 | {10100000, DIF_BPF_COEFF1415, 0xfd32002e}, | ||
1748 | {10100000, DIF_BPF_COEFF1617, 0x04130292}, | ||
1749 | {10100000, DIF_BPF_COEFF1819, 0xfc4dfa21}, | ||
1750 | {10100000, DIF_BPF_COEFF2021, 0x00d107ee}, | ||
1751 | {10100000, DIF_BPF_COEFF2223, 0x0435f91c}, | ||
1752 | {10100000, DIF_BPF_COEFF2425, 0xf6850205}, | ||
1753 | {10100000, DIF_BPF_COEFF2627, 0x0c430573}, | ||
1754 | {10100000, DIF_BPF_COEFF2829, 0xf5a1f37d}, | ||
1755 | {10100000, DIF_BPF_COEFF3031, 0x03990fba}, | ||
1756 | {10100000, DIF_BPF_COEFF3233, 0x05c7f2f8}, | ||
1757 | {10100000, DIF_BPF_COEFF3435, 0xf222050d}, | ||
1758 | {10100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1759 | /* END - DIF BPF register values from 101_quant.dat*/ | ||
1760 | |||
1761 | |||
1762 | /*case 10200000:*/ | ||
1763 | /* BEGIN - DIF BPF register values from 102_quant.dat*/ | ||
1764 | {10200000, DIF_BPF_COEFF01, 0x00000002}, | ||
1765 | {10200000, DIF_BPF_COEFF23, 0x0008fffe}, | ||
1766 | {10200000, DIF_BPF_COEFF45, 0xffdfffe7}, | ||
1767 | {10200000, DIF_BPF_COEFF67, 0x003f006e}, | ||
1768 | {10200000, DIF_BPF_COEFF89, 0xffd6ff0f}, | ||
1769 | {10200000, DIF_BPF_COEFF1011, 0xff96014a}, | ||
1770 | {10200000, DIF_BPF_COEFF1213, 0x0197ff1f}, | ||
1771 | {10200000, DIF_BPF_COEFF1415, 0xfd05ff3e}, | ||
1772 | {10200000, DIF_BPF_COEFF1617, 0x03b0037c}, | ||
1773 | {10200000, DIF_BPF_COEFF1819, 0xfd59f9b7}, | ||
1774 | {10200000, DIF_BPF_COEFF2021, 0xff5d0781}, | ||
1775 | {10200000, DIF_BPF_COEFF2223, 0x0585fa56}, | ||
1776 | {10200000, DIF_BPF_COEFF2425, 0xf5e4006f}, | ||
1777 | {10200000, DIF_BPF_COEFF2627, 0x0bf906c4}, | ||
1778 | {10200000, DIF_BPF_COEFF2829, 0xf69df2e0}, | ||
1779 | {10200000, DIF_BPF_COEFF3031, 0x02790fa2}, | ||
1780 | {10200000, DIF_BPF_COEFF3233, 0x0688f35d}, | ||
1781 | {10200000, DIF_BPF_COEFF3435, 0xf1e604d8}, | ||
1782 | {10200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1783 | /* END - DIF BPF register values from 102_quant.dat*/ | ||
1784 | |||
1785 | |||
1786 | /*case 10300000:*/ | ||
1787 | /* BEGIN - DIF BPF register values from 103_quant.dat*/ | ||
1788 | {10300000, DIF_BPF_COEFF01, 0xffff0001}, | ||
1789 | {10300000, DIF_BPF_COEFF23, 0x00090005}, | ||
1790 | {10300000, DIF_BPF_COEFF45, 0xffe4ffd6}, | ||
1791 | {10300000, DIF_BPF_COEFF67, 0x0025007e}, | ||
1792 | {10300000, DIF_BPF_COEFF89, 0x0014ff20}, | ||
1793 | {10300000, DIF_BPF_COEFF1011, 0xff3c00f0}, | ||
1794 | {10300000, DIF_BPF_COEFF1213, 0x01e1ffd0}, | ||
1795 | {10300000, DIF_BPF_COEFF1415, 0xfd12fe5c}, | ||
1796 | {10300000, DIF_BPF_COEFF1617, 0x03110433}, | ||
1797 | {10300000, DIF_BPF_COEFF1819, 0xfe88f996}, | ||
1798 | {10300000, DIF_BPF_COEFF2021, 0xfdf106d1}, | ||
1799 | {10300000, DIF_BPF_COEFF2223, 0x06aafbb7}, | ||
1800 | {10300000, DIF_BPF_COEFF2425, 0xf57efed8}, | ||
1801 | {10300000, DIF_BPF_COEFF2627, 0x0b7e07ff}, | ||
1802 | {10300000, DIF_BPF_COEFF2829, 0xf7b0f25e}, | ||
1803 | {10300000, DIF_BPF_COEFF3031, 0x01560f7a}, | ||
1804 | {10300000, DIF_BPF_COEFF3233, 0x0745f3c7}, | ||
1805 | {10300000, DIF_BPF_COEFF3435, 0xf1ac04a4}, | ||
1806 | {10300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1807 | /* END - DIF BPF register values from 103_quant.dat*/ | ||
1808 | |||
1809 | |||
1810 | /*case 10400000:*/ | ||
1811 | /* BEGIN - DIF BPF register values from 104_quant.dat*/ | ||
1812 | {10400000, DIF_BPF_COEFF01, 0xffffffff}, | ||
1813 | {10400000, DIF_BPF_COEFF23, 0x0008000c}, | ||
1814 | {10400000, DIF_BPF_COEFF45, 0xffedffcb}, | ||
1815 | {10400000, DIF_BPF_COEFF67, 0x0005007d}, | ||
1816 | {10400000, DIF_BPF_COEFF89, 0x0050ff4c}, | ||
1817 | {10400000, DIF_BPF_COEFF1011, 0xfef6007e}, | ||
1818 | {10400000, DIF_BPF_COEFF1213, 0x01ff0086}, | ||
1819 | {10400000, DIF_BPF_COEFF1415, 0xfd58fd97}, | ||
1820 | {10400000, DIF_BPF_COEFF1617, 0x024104ad}, | ||
1821 | {10400000, DIF_BPF_COEFF1819, 0xffcaf9c0}, | ||
1822 | {10400000, DIF_BPF_COEFF2021, 0xfc9905e2}, | ||
1823 | {10400000, DIF_BPF_COEFF2223, 0x079afd35}, | ||
1824 | {10400000, DIF_BPF_COEFF2425, 0xf555fd46}, | ||
1825 | {10400000, DIF_BPF_COEFF2627, 0x0ad50920}, | ||
1826 | {10400000, DIF_BPF_COEFF2829, 0xf8d9f1f6}, | ||
1827 | {10400000, DIF_BPF_COEFF3031, 0x00310f43}, | ||
1828 | {10400000, DIF_BPF_COEFF3233, 0x07fdf435}, | ||
1829 | {10400000, DIF_BPF_COEFF3435, 0xf174046f}, | ||
1830 | {10400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1831 | /* END - DIF BPF register values from 104_quant.dat*/ | ||
1832 | |||
1833 | |||
1834 | /*case 10500000:*/ | ||
1835 | /* BEGIN - DIF BPF register values from 105_quant.dat*/ | ||
1836 | {10500000, DIF_BPF_COEFF01, 0xfffffffe}, | ||
1837 | {10500000, DIF_BPF_COEFF23, 0x00050011}, | ||
1838 | {10500000, DIF_BPF_COEFF45, 0xfffaffc8}, | ||
1839 | {10500000, DIF_BPF_COEFF67, 0xffe5006b}, | ||
1840 | {10500000, DIF_BPF_COEFF89, 0x0082ff8c}, | ||
1841 | {10500000, DIF_BPF_COEFF1011, 0xfecc0000}, | ||
1842 | {10500000, DIF_BPF_COEFF1213, 0x01f00130}, | ||
1843 | {10500000, DIF_BPF_COEFF1415, 0xfdd2fcfc}, | ||
1844 | {10500000, DIF_BPF_COEFF1617, 0x014d04e3}, | ||
1845 | {10500000, DIF_BPF_COEFF1819, 0x010efa32}, | ||
1846 | {10500000, DIF_BPF_COEFF2021, 0xfb6404bf}, | ||
1847 | {10500000, DIF_BPF_COEFF2223, 0x084efec5}, | ||
1848 | {10500000, DIF_BPF_COEFF2425, 0xf569fbc2}, | ||
1849 | {10500000, DIF_BPF_COEFF2627, 0x0a000a23}, | ||
1850 | {10500000, DIF_BPF_COEFF2829, 0xfa15f1ab}, | ||
1851 | {10500000, DIF_BPF_COEFF3031, 0xff0b0efc}, | ||
1852 | {10500000, DIF_BPF_COEFF3233, 0x08b0f4a7}, | ||
1853 | {10500000, DIF_BPF_COEFF3435, 0xf13f043a}, | ||
1854 | {10500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1855 | /* END - DIF BPF register values from 105_quant.dat*/ | ||
1856 | |||
1857 | |||
1858 | /*case 10600000:*/ | ||
1859 | /* BEGIN - DIF BPF register values from 106_quant.dat*/ | ||
1860 | {10600000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
1861 | {10600000, DIF_BPF_COEFF23, 0x00020012}, | ||
1862 | {10600000, DIF_BPF_COEFF45, 0x0007ffcd}, | ||
1863 | {10600000, DIF_BPF_COEFF67, 0xffc9004c}, | ||
1864 | {10600000, DIF_BPF_COEFF89, 0x00a4ffd9}, | ||
1865 | {10600000, DIF_BPF_COEFF1011, 0xfec3ff82}, | ||
1866 | {10600000, DIF_BPF_COEFF1213, 0x01b401c1}, | ||
1867 | {10600000, DIF_BPF_COEFF1415, 0xfe76fc97}, | ||
1868 | {10600000, DIF_BPF_COEFF1617, 0x004404d2}, | ||
1869 | {10600000, DIF_BPF_COEFF1819, 0x0245fae8}, | ||
1870 | {10600000, DIF_BPF_COEFF2021, 0xfa5f0370}, | ||
1871 | {10600000, DIF_BPF_COEFF2223, 0x08c1005f}, | ||
1872 | {10600000, DIF_BPF_COEFF2425, 0xf5bcfa52}, | ||
1873 | {10600000, DIF_BPF_COEFF2627, 0x09020b04}, | ||
1874 | {10600000, DIF_BPF_COEFF2829, 0xfb60f17b}, | ||
1875 | {10600000, DIF_BPF_COEFF3031, 0xfde70ea6}, | ||
1876 | {10600000, DIF_BPF_COEFF3233, 0x095df51e}, | ||
1877 | {10600000, DIF_BPF_COEFF3435, 0xf10c0405}, | ||
1878 | {10600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1879 | /* END - DIF BPF register values from 106_quant.dat*/ | ||
1880 | |||
1881 | |||
1882 | /*case 10700000:*/ | ||
1883 | /* BEGIN - DIF BPF register values from 107_quant.dat*/ | ||
1884 | {10700000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
1885 | {10700000, DIF_BPF_COEFF23, 0xffff0011}, | ||
1886 | {10700000, DIF_BPF_COEFF45, 0x0014ffdb}, | ||
1887 | {10700000, DIF_BPF_COEFF67, 0xffb40023}, | ||
1888 | {10700000, DIF_BPF_COEFF89, 0x00b2002a}, | ||
1889 | {10700000, DIF_BPF_COEFF1011, 0xfedbff10}, | ||
1890 | {10700000, DIF_BPF_COEFF1213, 0x0150022d}, | ||
1891 | {10700000, DIF_BPF_COEFF1415, 0xff38fc6f}, | ||
1892 | {10700000, DIF_BPF_COEFF1617, 0xff36047b}, | ||
1893 | {10700000, DIF_BPF_COEFF1819, 0x035efbda}, | ||
1894 | {10700000, DIF_BPF_COEFF2021, 0xf9940202}, | ||
1895 | {10700000, DIF_BPF_COEFF2223, 0x08ee01f5}, | ||
1896 | {10700000, DIF_BPF_COEFF2425, 0xf649f8fe}, | ||
1897 | {10700000, DIF_BPF_COEFF2627, 0x07e10bc2}, | ||
1898 | {10700000, DIF_BPF_COEFF2829, 0xfcb6f169}, | ||
1899 | {10700000, DIF_BPF_COEFF3031, 0xfcc60e42}, | ||
1900 | {10700000, DIF_BPF_COEFF3233, 0x0a04f599}, | ||
1901 | {10700000, DIF_BPF_COEFF3435, 0xf0db03d0}, | ||
1902 | {10700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1903 | /* END - DIF BPF register values from 107_quant.dat*/ | ||
1904 | |||
1905 | |||
1906 | /*case 10800000:*/ | ||
1907 | /* BEGIN - DIF BPF register values from 108_quant.dat*/ | ||
1908 | {10800000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
1909 | {10800000, DIF_BPF_COEFF23, 0xfffb000d}, | ||
1910 | {10800000, DIF_BPF_COEFF45, 0x001dffed}, | ||
1911 | {10800000, DIF_BPF_COEFF67, 0xffaafff5}, | ||
1912 | {10800000, DIF_BPF_COEFF89, 0x00aa0077}, | ||
1913 | {10800000, DIF_BPF_COEFF1011, 0xff13feb6}, | ||
1914 | {10800000, DIF_BPF_COEFF1213, 0x00ce026b}, | ||
1915 | {10800000, DIF_BPF_COEFF1415, 0x000afc85}, | ||
1916 | {10800000, DIF_BPF_COEFF1617, 0xfe3503e3}, | ||
1917 | {10800000, DIF_BPF_COEFF1819, 0x044cfcfb}, | ||
1918 | {10800000, DIF_BPF_COEFF2021, 0xf90c0082}, | ||
1919 | {10800000, DIF_BPF_COEFF2223, 0x08d5037f}, | ||
1920 | {10800000, DIF_BPF_COEFF2425, 0xf710f7cc}, | ||
1921 | {10800000, DIF_BPF_COEFF2627, 0x069f0c59}, | ||
1922 | {10800000, DIF_BPF_COEFF2829, 0xfe16f173}, | ||
1923 | {10800000, DIF_BPF_COEFF3031, 0xfbaa0dcf}, | ||
1924 | {10800000, DIF_BPF_COEFF3233, 0x0aa5f617}, | ||
1925 | {10800000, DIF_BPF_COEFF3435, 0xf0ad039b}, | ||
1926 | {10800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1927 | /* END - DIF BPF register values from 108_quant.dat*/ | ||
1928 | |||
1929 | |||
1930 | /*case 10900000:*/ | ||
1931 | /* BEGIN - DIF BPF register values from 109_quant.dat*/ | ||
1932 | {10900000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
1933 | {10900000, DIF_BPF_COEFF23, 0xfff90006}, | ||
1934 | {10900000, DIF_BPF_COEFF45, 0x00210003}, | ||
1935 | {10900000, DIF_BPF_COEFF67, 0xffacffc8}, | ||
1936 | {10900000, DIF_BPF_COEFF89, 0x008e00b6}, | ||
1937 | {10900000, DIF_BPF_COEFF1011, 0xff63fe7c}, | ||
1938 | {10900000, DIF_BPF_COEFF1213, 0x003a0275}, | ||
1939 | {10900000, DIF_BPF_COEFF1415, 0x00dafcda}, | ||
1940 | {10900000, DIF_BPF_COEFF1617, 0xfd510313}, | ||
1941 | {10900000, DIF_BPF_COEFF1819, 0x0501fe40}, | ||
1942 | {10900000, DIF_BPF_COEFF2021, 0xf8cbfefd}, | ||
1943 | {10900000, DIF_BPF_COEFF2223, 0x087604f0}, | ||
1944 | {10900000, DIF_BPF_COEFF2425, 0xf80af6c2}, | ||
1945 | {10900000, DIF_BPF_COEFF2627, 0x05430cc8}, | ||
1946 | {10900000, DIF_BPF_COEFF2829, 0xff7af19a}, | ||
1947 | {10900000, DIF_BPF_COEFF3031, 0xfa940d4e}, | ||
1948 | {10900000, DIF_BPF_COEFF3233, 0x0b3ff699}, | ||
1949 | {10900000, DIF_BPF_COEFF3435, 0xf0810365}, | ||
1950 | {10900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1951 | /* END - DIF BPF register values from 109_quant.dat*/ | ||
1952 | |||
1953 | |||
1954 | /*case 11000000:*/ | ||
1955 | /* BEGIN - DIF BPF register values from 110_quant.dat*/ | ||
1956 | {11000000, DIF_BPF_COEFF01, 0x0001ffff}, | ||
1957 | {11000000, DIF_BPF_COEFF23, 0xfff8ffff}, | ||
1958 | {11000000, DIF_BPF_COEFF45, 0x00210018}, | ||
1959 | {11000000, DIF_BPF_COEFF67, 0xffbaffa3}, | ||
1960 | {11000000, DIF_BPF_COEFF89, 0x006000e1}, | ||
1961 | {11000000, DIF_BPF_COEFF1011, 0xffc4fe68}, | ||
1962 | {11000000, DIF_BPF_COEFF1213, 0xffa0024b}, | ||
1963 | {11000000, DIF_BPF_COEFF1415, 0x019afd66}, | ||
1964 | {11000000, DIF_BPF_COEFF1617, 0xfc990216}, | ||
1965 | {11000000, DIF_BPF_COEFF1819, 0x0575ff99}, | ||
1966 | {11000000, DIF_BPF_COEFF2021, 0xf8d4fd81}, | ||
1967 | {11000000, DIF_BPF_COEFF2223, 0x07d40640}, | ||
1968 | {11000000, DIF_BPF_COEFF2425, 0xf932f5e6}, | ||
1969 | {11000000, DIF_BPF_COEFF2627, 0x03d20d0d}, | ||
1970 | {11000000, DIF_BPF_COEFF2829, 0x00dff1de}, | ||
1971 | {11000000, DIF_BPF_COEFF3031, 0xf9860cbf}, | ||
1972 | {11000000, DIF_BPF_COEFF3233, 0x0bd1f71e}, | ||
1973 | {11000000, DIF_BPF_COEFF3435, 0xf058032f}, | ||
1974 | {11000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1975 | /* END - DIF BPF register values from 110_quant.dat*/ | ||
1976 | |||
1977 | |||
1978 | /*case 11100000:*/ | ||
1979 | /* BEGIN - DIF BPF register values from 111_quant.dat*/ | ||
1980 | {11100000, DIF_BPF_COEFF01, 0x00010000}, | ||
1981 | {11100000, DIF_BPF_COEFF23, 0xfff8fff8}, | ||
1982 | {11100000, DIF_BPF_COEFF45, 0x001b0029}, | ||
1983 | {11100000, DIF_BPF_COEFF67, 0xffd1ff8a}, | ||
1984 | {11100000, DIF_BPF_COEFF89, 0x002600f2}, | ||
1985 | {11100000, DIF_BPF_COEFF1011, 0x002cfe7c}, | ||
1986 | {11100000, DIF_BPF_COEFF1213, 0xff0f01f0}, | ||
1987 | {11100000, DIF_BPF_COEFF1415, 0x023bfe20}, | ||
1988 | {11100000, DIF_BPF_COEFF1617, 0xfc1700fa}, | ||
1989 | {11100000, DIF_BPF_COEFF1819, 0x05a200f7}, | ||
1990 | {11100000, DIF_BPF_COEFF2021, 0xf927fc1c}, | ||
1991 | {11100000, DIF_BPF_COEFF2223, 0x06f40765}, | ||
1992 | {11100000, DIF_BPF_COEFF2425, 0xfa82f53b}, | ||
1993 | {11100000, DIF_BPF_COEFF2627, 0x02510d27}, | ||
1994 | {11100000, DIF_BPF_COEFF2829, 0x0243f23d}, | ||
1995 | {11100000, DIF_BPF_COEFF3031, 0xf8810c24}, | ||
1996 | {11100000, DIF_BPF_COEFF3233, 0x0c5cf7a7}, | ||
1997 | {11100000, DIF_BPF_COEFF3435, 0xf03102fa}, | ||
1998 | {11100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
1999 | /* END - DIF BPF register values from 111_quant.dat*/ | ||
2000 | |||
2001 | |||
2002 | /*case 11200000:*/ | ||
2003 | /* BEGIN - DIF BPF register values from 112_quant.dat*/ | ||
2004 | {11200000, DIF_BPF_COEFF01, 0x00010002}, | ||
2005 | {11200000, DIF_BPF_COEFF23, 0xfffafff2}, | ||
2006 | {11200000, DIF_BPF_COEFF45, 0x00110035}, | ||
2007 | {11200000, DIF_BPF_COEFF67, 0xfff0ff81}, | ||
2008 | {11200000, DIF_BPF_COEFF89, 0xffe700e7}, | ||
2009 | {11200000, DIF_BPF_COEFF1011, 0x008ffeb6}, | ||
2010 | {11200000, DIF_BPF_COEFF1213, 0xfe94016d}, | ||
2011 | {11200000, DIF_BPF_COEFF1415, 0x02b0fefb}, | ||
2012 | {11200000, DIF_BPF_COEFF1617, 0xfbd3ffd1}, | ||
2013 | {11200000, DIF_BPF_COEFF1819, 0x05850249}, | ||
2014 | {11200000, DIF_BPF_COEFF2021, 0xf9c1fadb}, | ||
2015 | {11200000, DIF_BPF_COEFF2223, 0x05de0858}, | ||
2016 | {11200000, DIF_BPF_COEFF2425, 0xfbf2f4c4}, | ||
2017 | {11200000, DIF_BPF_COEFF2627, 0x00c70d17}, | ||
2018 | {11200000, DIF_BPF_COEFF2829, 0x03a0f2b8}, | ||
2019 | {11200000, DIF_BPF_COEFF3031, 0xf7870b7c}, | ||
2020 | {11200000, DIF_BPF_COEFF3233, 0x0cdff833}, | ||
2021 | {11200000, DIF_BPF_COEFF3435, 0xf00d02c4}, | ||
2022 | {11200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2023 | /* END - DIF BPF register values from 112_quant.dat*/ | ||
2024 | |||
2025 | |||
2026 | /*case 11300000:*/ | ||
2027 | /* BEGIN - DIF BPF register values from 113_quant.dat*/ | ||
2028 | {11300000, DIF_BPF_COEFF01, 0x00000003}, | ||
2029 | {11300000, DIF_BPF_COEFF23, 0xfffdffee}, | ||
2030 | {11300000, DIF_BPF_COEFF45, 0x00040038}, | ||
2031 | {11300000, DIF_BPF_COEFF67, 0x0010ff88}, | ||
2032 | {11300000, DIF_BPF_COEFF89, 0xffac00c2}, | ||
2033 | {11300000, DIF_BPF_COEFF1011, 0x00e2ff10}, | ||
2034 | {11300000, DIF_BPF_COEFF1213, 0xfe3900cb}, | ||
2035 | {11300000, DIF_BPF_COEFF1415, 0x02f1ffe9}, | ||
2036 | {11300000, DIF_BPF_COEFF1617, 0xfbd3feaa}, | ||
2037 | {11300000, DIF_BPF_COEFF1819, 0x05210381}, | ||
2038 | {11300000, DIF_BPF_COEFF2021, 0xfa9cf9c8}, | ||
2039 | {11300000, DIF_BPF_COEFF2223, 0x04990912}, | ||
2040 | {11300000, DIF_BPF_COEFF2425, 0xfd7af484}, | ||
2041 | {11300000, DIF_BPF_COEFF2627, 0xff390cdb}, | ||
2042 | {11300000, DIF_BPF_COEFF2829, 0x04f4f34d}, | ||
2043 | {11300000, DIF_BPF_COEFF3031, 0xf69a0ac9}, | ||
2044 | {11300000, DIF_BPF_COEFF3233, 0x0d5af8c1}, | ||
2045 | {11300000, DIF_BPF_COEFF3435, 0xefec028e}, | ||
2046 | {11300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2047 | /* END - DIF BPF register values from 113_quant.dat*/ | ||
2048 | |||
2049 | |||
2050 | /*case 11400000:*/ | ||
2051 | /* BEGIN - DIF BPF register values from 114_quant.dat*/ | ||
2052 | {11400000, DIF_BPF_COEFF01, 0x00000003}, | ||
2053 | {11400000, DIF_BPF_COEFF23, 0x0000ffee}, | ||
2054 | {11400000, DIF_BPF_COEFF45, 0xfff60033}, | ||
2055 | {11400000, DIF_BPF_COEFF67, 0x002fff9f}, | ||
2056 | {11400000, DIF_BPF_COEFF89, 0xff7b0087}, | ||
2057 | {11400000, DIF_BPF_COEFF1011, 0x011eff82}, | ||
2058 | {11400000, DIF_BPF_COEFF1213, 0xfe080018}, | ||
2059 | {11400000, DIF_BPF_COEFF1415, 0x02f900d8}, | ||
2060 | {11400000, DIF_BPF_COEFF1617, 0xfc17fd96}, | ||
2061 | {11400000, DIF_BPF_COEFF1819, 0x04790490}, | ||
2062 | {11400000, DIF_BPF_COEFF2021, 0xfbadf8ed}, | ||
2063 | {11400000, DIF_BPF_COEFF2223, 0x032f098e}, | ||
2064 | {11400000, DIF_BPF_COEFF2425, 0xff10f47d}, | ||
2065 | {11400000, DIF_BPF_COEFF2627, 0xfdaf0c75}, | ||
2066 | {11400000, DIF_BPF_COEFF2829, 0x063cf3fc}, | ||
2067 | {11400000, DIF_BPF_COEFF3031, 0xf5ba0a0b}, | ||
2068 | {11400000, DIF_BPF_COEFF3233, 0x0dccf952}, | ||
2069 | {11400000, DIF_BPF_COEFF3435, 0xefcd0258}, | ||
2070 | {11400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2071 | /* END - DIF BPF register values from 114_quant.dat*/ | ||
2072 | |||
2073 | |||
2074 | /*case 11500000:*/ | ||
2075 | /* BEGIN - DIF BPF register values from 115_quant.dat*/ | ||
2076 | {11500000, DIF_BPF_COEFF01, 0x00000003}, | ||
2077 | {11500000, DIF_BPF_COEFF23, 0x0004fff1}, | ||
2078 | {11500000, DIF_BPF_COEFF45, 0xffea0026}, | ||
2079 | {11500000, DIF_BPF_COEFF67, 0x0046ffc3}, | ||
2080 | {11500000, DIF_BPF_COEFF89, 0xff5a003c}, | ||
2081 | {11500000, DIF_BPF_COEFF1011, 0x013b0000}, | ||
2082 | {11500000, DIF_BPF_COEFF1213, 0xfe04ff63}, | ||
2083 | {11500000, DIF_BPF_COEFF1415, 0x02c801b8}, | ||
2084 | {11500000, DIF_BPF_COEFF1617, 0xfc99fca6}, | ||
2085 | {11500000, DIF_BPF_COEFF1819, 0x0397056a}, | ||
2086 | {11500000, DIF_BPF_COEFF2021, 0xfcecf853}, | ||
2087 | {11500000, DIF_BPF_COEFF2223, 0x01ad09c9}, | ||
2088 | {11500000, DIF_BPF_COEFF2425, 0x00acf4ad}, | ||
2089 | {11500000, DIF_BPF_COEFF2627, 0xfc2e0be7}, | ||
2090 | {11500000, DIF_BPF_COEFF2829, 0x0773f4c2}, | ||
2091 | {11500000, DIF_BPF_COEFF3031, 0xf4e90943}, | ||
2092 | {11500000, DIF_BPF_COEFF3233, 0x0e35f9e6}, | ||
2093 | {11500000, DIF_BPF_COEFF3435, 0xefb10221}, | ||
2094 | {11500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2095 | /* END - DIF BPF register values from 115_quant.dat*/ | ||
2096 | |||
2097 | |||
2098 | /*case 11600000:*/ | ||
2099 | /* BEGIN - DIF BPF register values from 116_quant.dat*/ | ||
2100 | {11600000, DIF_BPF_COEFF01, 0x00000002}, | ||
2101 | {11600000, DIF_BPF_COEFF23, 0x0007fff6}, | ||
2102 | {11600000, DIF_BPF_COEFF45, 0xffe20014}, | ||
2103 | {11600000, DIF_BPF_COEFF67, 0x0054ffee}, | ||
2104 | {11600000, DIF_BPF_COEFF89, 0xff4effeb}, | ||
2105 | {11600000, DIF_BPF_COEFF1011, 0x0137007e}, | ||
2106 | {11600000, DIF_BPF_COEFF1213, 0xfe2efebb}, | ||
2107 | {11600000, DIF_BPF_COEFF1415, 0x0260027a}, | ||
2108 | {11600000, DIF_BPF_COEFF1617, 0xfd51fbe6}, | ||
2109 | {11600000, DIF_BPF_COEFF1819, 0x02870605}, | ||
2110 | {11600000, DIF_BPF_COEFF2021, 0xfe4af7fe}, | ||
2111 | {11600000, DIF_BPF_COEFF2223, 0x001d09c1}, | ||
2112 | {11600000, DIF_BPF_COEFF2425, 0x0243f515}, | ||
2113 | {11600000, DIF_BPF_COEFF2627, 0xfabd0b32}, | ||
2114 | {11600000, DIF_BPF_COEFF2829, 0x0897f59e}, | ||
2115 | {11600000, DIF_BPF_COEFF3031, 0xf4280871}, | ||
2116 | {11600000, DIF_BPF_COEFF3233, 0x0e95fa7c}, | ||
2117 | {11600000, DIF_BPF_COEFF3435, 0xef9701eb}, | ||
2118 | {11600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2119 | /* END - DIF BPF register values from 116_quant.dat*/ | ||
2120 | |||
2121 | |||
2122 | /*case 11700000:*/ | ||
2123 | /* BEGIN - DIF BPF register values from 117_quant.dat*/ | ||
2124 | {11700000, DIF_BPF_COEFF01, 0xffff0001}, | ||
2125 | {11700000, DIF_BPF_COEFF23, 0x0008fffd}, | ||
2126 | {11700000, DIF_BPF_COEFF45, 0xffdeffff}, | ||
2127 | {11700000, DIF_BPF_COEFF67, 0x0056001d}, | ||
2128 | {11700000, DIF_BPF_COEFF89, 0xff57ff9c}, | ||
2129 | {11700000, DIF_BPF_COEFF1011, 0x011300f0}, | ||
2130 | {11700000, DIF_BPF_COEFF1213, 0xfe82fe2e}, | ||
2131 | {11700000, DIF_BPF_COEFF1415, 0x01ca0310}, | ||
2132 | {11700000, DIF_BPF_COEFF1617, 0xfe35fb62}, | ||
2133 | {11700000, DIF_BPF_COEFF1819, 0x0155065a}, | ||
2134 | {11700000, DIF_BPF_COEFF2021, 0xffbaf7f2}, | ||
2135 | {11700000, DIF_BPF_COEFF2223, 0xfe8c0977}, | ||
2136 | {11700000, DIF_BPF_COEFF2425, 0x03cef5b2}, | ||
2137 | {11700000, DIF_BPF_COEFF2627, 0xf9610a58}, | ||
2138 | {11700000, DIF_BPF_COEFF2829, 0x09a5f68f}, | ||
2139 | {11700000, DIF_BPF_COEFF3031, 0xf3790797}, | ||
2140 | {11700000, DIF_BPF_COEFF3233, 0x0eebfb14}, | ||
2141 | {11700000, DIF_BPF_COEFF3435, 0xef8001b5}, | ||
2142 | {11700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2143 | /* END - DIF BPF register values from 117_quant.dat*/ | ||
2144 | |||
2145 | |||
2146 | /*case 11800000:*/ | ||
2147 | /* BEGIN - DIF BPF register values from 118_quant.dat*/ | ||
2148 | {11800000, DIF_BPF_COEFF01, 0xffff0000}, | ||
2149 | {11800000, DIF_BPF_COEFF23, 0x00080004}, | ||
2150 | {11800000, DIF_BPF_COEFF45, 0xffe0ffe9}, | ||
2151 | {11800000, DIF_BPF_COEFF67, 0x004c0047}, | ||
2152 | {11800000, DIF_BPF_COEFF89, 0xff75ff58}, | ||
2153 | {11800000, DIF_BPF_COEFF1011, 0x00d1014a}, | ||
2154 | {11800000, DIF_BPF_COEFF1213, 0xfef9fdc8}, | ||
2155 | {11800000, DIF_BPF_COEFF1415, 0x0111036f}, | ||
2156 | {11800000, DIF_BPF_COEFF1617, 0xff36fb21}, | ||
2157 | {11800000, DIF_BPF_COEFF1819, 0x00120665}, | ||
2158 | {11800000, DIF_BPF_COEFF2021, 0x012df82e}, | ||
2159 | {11800000, DIF_BPF_COEFF2223, 0xfd0708ec}, | ||
2160 | {11800000, DIF_BPF_COEFF2425, 0x0542f682}, | ||
2161 | {11800000, DIF_BPF_COEFF2627, 0xf81f095c}, | ||
2162 | {11800000, DIF_BPF_COEFF2829, 0x0a9af792}, | ||
2163 | {11800000, DIF_BPF_COEFF3031, 0xf2db06b5}, | ||
2164 | {11800000, DIF_BPF_COEFF3233, 0x0f38fbad}, | ||
2165 | {11800000, DIF_BPF_COEFF3435, 0xef6c017e}, | ||
2166 | {11800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2167 | /* END - DIF BPF register values from 118_quant.dat*/ | ||
2168 | |||
2169 | |||
2170 | /*case 11900000:*/ | ||
2171 | /* BEGIN - DIF BPF register values from 119_quant.dat*/ | ||
2172 | {11900000, DIF_BPF_COEFF01, 0xffffffff}, | ||
2173 | {11900000, DIF_BPF_COEFF23, 0x0007000b}, | ||
2174 | {11900000, DIF_BPF_COEFF45, 0xffe7ffd8}, | ||
2175 | {11900000, DIF_BPF_COEFF67, 0x00370068}, | ||
2176 | {11900000, DIF_BPF_COEFF89, 0xffa4ff28}, | ||
2177 | {11900000, DIF_BPF_COEFF1011, 0x00790184}, | ||
2178 | {11900000, DIF_BPF_COEFF1213, 0xff87fd91}, | ||
2179 | {11900000, DIF_BPF_COEFF1415, 0x00430392}, | ||
2180 | {11900000, DIF_BPF_COEFF1617, 0x0044fb26}, | ||
2181 | {11900000, DIF_BPF_COEFF1819, 0xfece0626}, | ||
2182 | {11900000, DIF_BPF_COEFF2021, 0x0294f8b2}, | ||
2183 | {11900000, DIF_BPF_COEFF2223, 0xfb990825}, | ||
2184 | {11900000, DIF_BPF_COEFF2425, 0x0698f77f}, | ||
2185 | {11900000, DIF_BPF_COEFF2627, 0xf6fe0842}, | ||
2186 | {11900000, DIF_BPF_COEFF2829, 0x0b73f8a7}, | ||
2187 | {11900000, DIF_BPF_COEFF3031, 0xf25105cd}, | ||
2188 | {11900000, DIF_BPF_COEFF3233, 0x0f7bfc48}, | ||
2189 | {11900000, DIF_BPF_COEFF3435, 0xef5a0148}, | ||
2190 | {11900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2191 | /* END - DIF BPF register values from 119_quant.dat*/ | ||
2192 | |||
2193 | |||
2194 | /*case 12000000:*/ | ||
2195 | /* BEGIN - DIF BPF register values from 120_quant.dat*/ | ||
2196 | {12000000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
2197 | {12000000, DIF_BPF_COEFF23, 0x00050010}, | ||
2198 | {12000000, DIF_BPF_COEFF45, 0xfff2ffcc}, | ||
2199 | {12000000, DIF_BPF_COEFF67, 0x001b007b}, | ||
2200 | {12000000, DIF_BPF_COEFF89, 0xffdfff10}, | ||
2201 | {12000000, DIF_BPF_COEFF1011, 0x00140198}, | ||
2202 | {12000000, DIF_BPF_COEFF1213, 0x0020fd8e}, | ||
2203 | {12000000, DIF_BPF_COEFF1415, 0xff710375}, | ||
2204 | {12000000, DIF_BPF_COEFF1617, 0x014dfb73}, | ||
2205 | {12000000, DIF_BPF_COEFF1819, 0xfd9a059f}, | ||
2206 | {12000000, DIF_BPF_COEFF2021, 0x03e0f978}, | ||
2207 | {12000000, DIF_BPF_COEFF2223, 0xfa4e0726}, | ||
2208 | {12000000, DIF_BPF_COEFF2425, 0x07c8f8a7}, | ||
2209 | {12000000, DIF_BPF_COEFF2627, 0xf600070c}, | ||
2210 | {12000000, DIF_BPF_COEFF2829, 0x0c2ff9c9}, | ||
2211 | {12000000, DIF_BPF_COEFF3031, 0xf1db04de}, | ||
2212 | {12000000, DIF_BPF_COEFF3233, 0x0fb4fce5}, | ||
2213 | {12000000, DIF_BPF_COEFF3435, 0xef4b0111}, | ||
2214 | {12000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2215 | /* END - DIF BPF register values from 120_quant.dat*/ | ||
2216 | |||
2217 | |||
2218 | /*case 12100000:*/ | ||
2219 | /* BEGIN - DIF BPF register values from 121_quant.dat*/ | ||
2220 | {12100000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
2221 | {12100000, DIF_BPF_COEFF23, 0x00010012}, | ||
2222 | {12100000, DIF_BPF_COEFF45, 0xffffffc8}, | ||
2223 | {12100000, DIF_BPF_COEFF67, 0xfffb007e}, | ||
2224 | {12100000, DIF_BPF_COEFF89, 0x001dff14}, | ||
2225 | {12100000, DIF_BPF_COEFF1011, 0xffad0184}, | ||
2226 | {12100000, DIF_BPF_COEFF1213, 0x00b7fdbe}, | ||
2227 | {12100000, DIF_BPF_COEFF1415, 0xfea9031b}, | ||
2228 | {12100000, DIF_BPF_COEFF1617, 0x0241fc01}, | ||
2229 | {12100000, DIF_BPF_COEFF1819, 0xfc8504d6}, | ||
2230 | {12100000, DIF_BPF_COEFF2021, 0x0504fa79}, | ||
2231 | {12100000, DIF_BPF_COEFF2223, 0xf93005f6}, | ||
2232 | {12100000, DIF_BPF_COEFF2425, 0x08caf9f2}, | ||
2233 | {12100000, DIF_BPF_COEFF2627, 0xf52b05c0}, | ||
2234 | {12100000, DIF_BPF_COEFF2829, 0x0ccbfaf9}, | ||
2235 | {12100000, DIF_BPF_COEFF3031, 0xf17903eb}, | ||
2236 | {12100000, DIF_BPF_COEFF3233, 0x0fe3fd83}, | ||
2237 | {12100000, DIF_BPF_COEFF3435, 0xef3f00db}, | ||
2238 | {12100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2239 | /* END - DIF BPF register values from 121_quant.dat*/ | ||
2240 | |||
2241 | |||
2242 | /*case 12200000:*/ | ||
2243 | /* BEGIN - DIF BPF register values from 122_quant.dat*/ | ||
2244 | {12200000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
2245 | {12200000, DIF_BPF_COEFF23, 0xfffe0011}, | ||
2246 | {12200000, DIF_BPF_COEFF45, 0x000cffcc}, | ||
2247 | {12200000, DIF_BPF_COEFF67, 0xffdb0071}, | ||
2248 | {12200000, DIF_BPF_COEFF89, 0x0058ff32}, | ||
2249 | {12200000, DIF_BPF_COEFF1011, 0xff4f014a}, | ||
2250 | {12200000, DIF_BPF_COEFF1213, 0x013cfe1f}, | ||
2251 | {12200000, DIF_BPF_COEFF1415, 0xfdfb028a}, | ||
2252 | {12200000, DIF_BPF_COEFF1617, 0x0311fcc9}, | ||
2253 | {12200000, DIF_BPF_COEFF1819, 0xfb9d03d6}, | ||
2254 | {12200000, DIF_BPF_COEFF2021, 0x05f4fbad}, | ||
2255 | {12200000, DIF_BPF_COEFF2223, 0xf848049d}, | ||
2256 | {12200000, DIF_BPF_COEFF2425, 0x0999fb5b}, | ||
2257 | {12200000, DIF_BPF_COEFF2627, 0xf4820461}, | ||
2258 | {12200000, DIF_BPF_COEFF2829, 0x0d46fc32}, | ||
2259 | {12200000, DIF_BPF_COEFF3031, 0xf12d02f4}, | ||
2260 | {12200000, DIF_BPF_COEFF3233, 0x1007fe21}, | ||
2261 | {12200000, DIF_BPF_COEFF3435, 0xef3600a4}, | ||
2262 | {12200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2263 | /* END - DIF BPF register values from 122_quant.dat*/ | ||
2264 | |||
2265 | |||
2266 | /*case 12300000:*/ | ||
2267 | /* BEGIN - DIF BPF register values from 123_quant.dat*/ | ||
2268 | {12300000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
2269 | {12300000, DIF_BPF_COEFF23, 0xfffa000e}, | ||
2270 | {12300000, DIF_BPF_COEFF45, 0x0017ffd9}, | ||
2271 | {12300000, DIF_BPF_COEFF67, 0xffc10055}, | ||
2272 | {12300000, DIF_BPF_COEFF89, 0x0088ff68}, | ||
2273 | {12300000, DIF_BPF_COEFF1011, 0xff0400f0}, | ||
2274 | {12300000, DIF_BPF_COEFF1213, 0x01a6fea7}, | ||
2275 | {12300000, DIF_BPF_COEFF1415, 0xfd7501cc}, | ||
2276 | {12300000, DIF_BPF_COEFF1617, 0x03b0fdc0}, | ||
2277 | {12300000, DIF_BPF_COEFF1819, 0xfaef02a8}, | ||
2278 | {12300000, DIF_BPF_COEFF2021, 0x06a7fd07}, | ||
2279 | {12300000, DIF_BPF_COEFF2223, 0xf79d0326}, | ||
2280 | {12300000, DIF_BPF_COEFF2425, 0x0a31fcda}, | ||
2281 | {12300000, DIF_BPF_COEFF2627, 0xf40702f3}, | ||
2282 | {12300000, DIF_BPF_COEFF2829, 0x0d9ffd72}, | ||
2283 | {12300000, DIF_BPF_COEFF3031, 0xf0f601fa}, | ||
2284 | {12300000, DIF_BPF_COEFF3233, 0x1021fec0}, | ||
2285 | {12300000, DIF_BPF_COEFF3435, 0xef2f006d}, | ||
2286 | {12300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2287 | /* END - DIF BPF register values from 123_quant.dat*/ | ||
2288 | |||
2289 | |||
2290 | /*case 12400000:*/ | ||
2291 | /* BEGIN - DIF BPF register values from 124_quant.dat*/ | ||
2292 | {12400000, DIF_BPF_COEFF01, 0x0001ffff}, | ||
2293 | {12400000, DIF_BPF_COEFF23, 0xfff80007}, | ||
2294 | {12400000, DIF_BPF_COEFF45, 0x001fffeb}, | ||
2295 | {12400000, DIF_BPF_COEFF67, 0xffaf002d}, | ||
2296 | {12400000, DIF_BPF_COEFF89, 0x00a8ffb0}, | ||
2297 | {12400000, DIF_BPF_COEFF1011, 0xfed3007e}, | ||
2298 | {12400000, DIF_BPF_COEFF1213, 0x01e9ff4c}, | ||
2299 | {12400000, DIF_BPF_COEFF1415, 0xfd2000ee}, | ||
2300 | {12400000, DIF_BPF_COEFF1617, 0x0413fed8}, | ||
2301 | {12400000, DIF_BPF_COEFF1819, 0xfa82015c}, | ||
2302 | {12400000, DIF_BPF_COEFF2021, 0x0715fe7d}, | ||
2303 | {12400000, DIF_BPF_COEFF2223, 0xf7340198}, | ||
2304 | {12400000, DIF_BPF_COEFF2425, 0x0a8dfe69}, | ||
2305 | {12400000, DIF_BPF_COEFF2627, 0xf3bd017c}, | ||
2306 | {12400000, DIF_BPF_COEFF2829, 0x0dd5feb8}, | ||
2307 | {12400000, DIF_BPF_COEFF3031, 0xf0d500fd}, | ||
2308 | {12400000, DIF_BPF_COEFF3233, 0x1031ff60}, | ||
2309 | {12400000, DIF_BPF_COEFF3435, 0xef2b0037}, | ||
2310 | {12400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2311 | /* END - DIF BPF register values from 124_quant.dat*/ | ||
2312 | |||
2313 | |||
2314 | /*case 12500000:*/ | ||
2315 | /* BEGIN - DIF BPF register values from 125_quant.dat*/ | ||
2316 | {12500000, DIF_BPF_COEFF01, 0x00010000}, | ||
2317 | {12500000, DIF_BPF_COEFF23, 0xfff70000}, | ||
2318 | {12500000, DIF_BPF_COEFF45, 0x00220000}, | ||
2319 | {12500000, DIF_BPF_COEFF67, 0xffa90000}, | ||
2320 | {12500000, DIF_BPF_COEFF89, 0x00b30000}, | ||
2321 | {12500000, DIF_BPF_COEFF1011, 0xfec20000}, | ||
2322 | {12500000, DIF_BPF_COEFF1213, 0x02000000}, | ||
2323 | {12500000, DIF_BPF_COEFF1415, 0xfd030000}, | ||
2324 | {12500000, DIF_BPF_COEFF1617, 0x04350000}, | ||
2325 | {12500000, DIF_BPF_COEFF1819, 0xfa5e0000}, | ||
2326 | {12500000, DIF_BPF_COEFF2021, 0x073b0000}, | ||
2327 | {12500000, DIF_BPF_COEFF2223, 0xf7110000}, | ||
2328 | {12500000, DIF_BPF_COEFF2425, 0x0aac0000}, | ||
2329 | {12500000, DIF_BPF_COEFF2627, 0xf3a40000}, | ||
2330 | {12500000, DIF_BPF_COEFF2829, 0x0de70000}, | ||
2331 | {12500000, DIF_BPF_COEFF3031, 0xf0c90000}, | ||
2332 | {12500000, DIF_BPF_COEFF3233, 0x10360000}, | ||
2333 | {12500000, DIF_BPF_COEFF3435, 0xef290000}, | ||
2334 | {12500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2335 | /* END - DIF BPF register values from 125_quant.dat*/ | ||
2336 | |||
2337 | |||
2338 | /*case 12600000:*/ | ||
2339 | /* BEGIN - DIF BPF register values from 126_quant.dat*/ | ||
2340 | {12600000, DIF_BPF_COEFF01, 0x00010001}, | ||
2341 | {12600000, DIF_BPF_COEFF23, 0xfff8fff9}, | ||
2342 | {12600000, DIF_BPF_COEFF45, 0x001f0015}, | ||
2343 | {12600000, DIF_BPF_COEFF67, 0xffafffd3}, | ||
2344 | {12600000, DIF_BPF_COEFF89, 0x00a80050}, | ||
2345 | {12600000, DIF_BPF_COEFF1011, 0xfed3ff82}, | ||
2346 | {12600000, DIF_BPF_COEFF1213, 0x01e900b4}, | ||
2347 | {12600000, DIF_BPF_COEFF1415, 0xfd20ff12}, | ||
2348 | {12600000, DIF_BPF_COEFF1617, 0x04130128}, | ||
2349 | {12600000, DIF_BPF_COEFF1819, 0xfa82fea4}, | ||
2350 | {12600000, DIF_BPF_COEFF2021, 0x07150183}, | ||
2351 | {12600000, DIF_BPF_COEFF2223, 0xf734fe68}, | ||
2352 | {12600000, DIF_BPF_COEFF2425, 0x0a8d0197}, | ||
2353 | {12600000, DIF_BPF_COEFF2627, 0xf3bdfe84}, | ||
2354 | {12600000, DIF_BPF_COEFF2829, 0x0dd50148}, | ||
2355 | {12600000, DIF_BPF_COEFF3031, 0xf0d5ff03}, | ||
2356 | {12600000, DIF_BPF_COEFF3233, 0x103100a0}, | ||
2357 | {12600000, DIF_BPF_COEFF3435, 0xef2bffc9}, | ||
2358 | {12600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2359 | /* END - DIF BPF register values from 126_quant.dat*/ | ||
2360 | |||
2361 | |||
2362 | /*case 12700000:*/ | ||
2363 | /* BEGIN - DIF BPF register values from 127_quant.dat*/ | ||
2364 | {12700000, DIF_BPF_COEFF01, 0x00000002}, | ||
2365 | {12700000, DIF_BPF_COEFF23, 0xfffafff2}, | ||
2366 | {12700000, DIF_BPF_COEFF45, 0x00170027}, | ||
2367 | {12700000, DIF_BPF_COEFF67, 0xffc1ffab}, | ||
2368 | {12700000, DIF_BPF_COEFF89, 0x00880098}, | ||
2369 | {12700000, DIF_BPF_COEFF1011, 0xff04ff10}, | ||
2370 | {12700000, DIF_BPF_COEFF1213, 0x01a60159}, | ||
2371 | {12700000, DIF_BPF_COEFF1415, 0xfd75fe34}, | ||
2372 | {12700000, DIF_BPF_COEFF1617, 0x03b00240}, | ||
2373 | {12700000, DIF_BPF_COEFF1819, 0xfaeffd58}, | ||
2374 | {12700000, DIF_BPF_COEFF2021, 0x06a702f9}, | ||
2375 | {12700000, DIF_BPF_COEFF2223, 0xf79dfcda}, | ||
2376 | {12700000, DIF_BPF_COEFF2425, 0x0a310326}, | ||
2377 | {12700000, DIF_BPF_COEFF2627, 0xf407fd0d}, | ||
2378 | {12700000, DIF_BPF_COEFF2829, 0x0d9f028e}, | ||
2379 | {12700000, DIF_BPF_COEFF3031, 0xf0f6fe06}, | ||
2380 | {12700000, DIF_BPF_COEFF3233, 0x10210140}, | ||
2381 | {12700000, DIF_BPF_COEFF3435, 0xef2fff93}, | ||
2382 | {12700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2383 | /* END - DIF BPF register values from 127_quant.dat*/ | ||
2384 | |||
2385 | |||
2386 | /*case 12800000:*/ | ||
2387 | /* BEGIN - DIF BPF register values from 128_quant.dat*/ | ||
2388 | {12800000, DIF_BPF_COEFF01, 0x00000003}, | ||
2389 | {12800000, DIF_BPF_COEFF23, 0xfffeffef}, | ||
2390 | {12800000, DIF_BPF_COEFF45, 0x000c0034}, | ||
2391 | {12800000, DIF_BPF_COEFF67, 0xffdbff8f}, | ||
2392 | {12800000, DIF_BPF_COEFF89, 0x005800ce}, | ||
2393 | {12800000, DIF_BPF_COEFF1011, 0xff4ffeb6}, | ||
2394 | {12800000, DIF_BPF_COEFF1213, 0x013c01e1}, | ||
2395 | {12800000, DIF_BPF_COEFF1415, 0xfdfbfd76}, | ||
2396 | {12800000, DIF_BPF_COEFF1617, 0x03110337}, | ||
2397 | {12800000, DIF_BPF_COEFF1819, 0xfb9dfc2a}, | ||
2398 | {12800000, DIF_BPF_COEFF2021, 0x05f40453}, | ||
2399 | {12800000, DIF_BPF_COEFF2223, 0xf848fb63}, | ||
2400 | {12800000, DIF_BPF_COEFF2425, 0x099904a5}, | ||
2401 | {12800000, DIF_BPF_COEFF2627, 0xf482fb9f}, | ||
2402 | {12800000, DIF_BPF_COEFF2829, 0x0d4603ce}, | ||
2403 | {12800000, DIF_BPF_COEFF3031, 0xf12dfd0c}, | ||
2404 | {12800000, DIF_BPF_COEFF3233, 0x100701df}, | ||
2405 | {12800000, DIF_BPF_COEFF3435, 0xef36ff5c}, | ||
2406 | {12800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2407 | /* END - DIF BPF register values from 128_quant.dat*/ | ||
2408 | |||
2409 | |||
2410 | /*case 12900000:*/ | ||
2411 | /* BEGIN - DIF BPF register values from 129_quant.dat*/ | ||
2412 | {12900000, DIF_BPF_COEFF01, 0x00000003}, | ||
2413 | {12900000, DIF_BPF_COEFF23, 0x0001ffee}, | ||
2414 | {12900000, DIF_BPF_COEFF45, 0xffff0038}, | ||
2415 | {12900000, DIF_BPF_COEFF67, 0xfffbff82}, | ||
2416 | {12900000, DIF_BPF_COEFF89, 0x001d00ec}, | ||
2417 | {12900000, DIF_BPF_COEFF1011, 0xffadfe7c}, | ||
2418 | {12900000, DIF_BPF_COEFF1213, 0x00b70242}, | ||
2419 | {12900000, DIF_BPF_COEFF1415, 0xfea9fce5}, | ||
2420 | {12900000, DIF_BPF_COEFF1617, 0x024103ff}, | ||
2421 | {12900000, DIF_BPF_COEFF1819, 0xfc85fb2a}, | ||
2422 | {12900000, DIF_BPF_COEFF2021, 0x05040587}, | ||
2423 | {12900000, DIF_BPF_COEFF2223, 0xf930fa0a}, | ||
2424 | {12900000, DIF_BPF_COEFF2425, 0x08ca060e}, | ||
2425 | {12900000, DIF_BPF_COEFF2627, 0xf52bfa40}, | ||
2426 | {12900000, DIF_BPF_COEFF2829, 0x0ccb0507}, | ||
2427 | {12900000, DIF_BPF_COEFF3031, 0xf179fc15}, | ||
2428 | {12900000, DIF_BPF_COEFF3233, 0x0fe3027d}, | ||
2429 | {12900000, DIF_BPF_COEFF3435, 0xef3fff25}, | ||
2430 | {12900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2431 | /* END - DIF BPF register values from 129_quant.dat*/ | ||
2432 | |||
2433 | |||
2434 | /*case 113000000:*/ | ||
2435 | /* BEGIN - DIF BPF register values from 130_quant.dat*/ | ||
2436 | {13000000, DIF_BPF_COEFF01, 0x00000002}, | ||
2437 | {13000000, DIF_BPF_COEFF23, 0x0005fff0}, | ||
2438 | {13000000, DIF_BPF_COEFF45, 0xfff20034}, | ||
2439 | {13000000, DIF_BPF_COEFF67, 0x001bff85}, | ||
2440 | {13000000, DIF_BPF_COEFF89, 0xffdf00f0}, | ||
2441 | {13000000, DIF_BPF_COEFF1011, 0x0014fe68}, | ||
2442 | {13000000, DIF_BPF_COEFF1213, 0x00200272}, | ||
2443 | {13000000, DIF_BPF_COEFF1415, 0xff71fc8b}, | ||
2444 | {13000000, DIF_BPF_COEFF1617, 0x014d048d}, | ||
2445 | {13000000, DIF_BPF_COEFF1819, 0xfd9afa61}, | ||
2446 | {13000000, DIF_BPF_COEFF2021, 0x03e00688}, | ||
2447 | {13000000, DIF_BPF_COEFF2223, 0xfa4ef8da}, | ||
2448 | {13000000, DIF_BPF_COEFF2425, 0x07c80759}, | ||
2449 | {13000000, DIF_BPF_COEFF2627, 0xf600f8f4}, | ||
2450 | {13000000, DIF_BPF_COEFF2829, 0x0c2f0637}, | ||
2451 | {13000000, DIF_BPF_COEFF3031, 0xf1dbfb22}, | ||
2452 | {13000000, DIF_BPF_COEFF3233, 0x0fb4031b}, | ||
2453 | {13000000, DIF_BPF_COEFF3435, 0xef4bfeef}, | ||
2454 | {13000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2455 | /* END - DIF BPF register values from 130_quant.dat*/ | ||
2456 | |||
2457 | |||
2458 | /*case 13100000:*/ | ||
2459 | /* BEGIN - DIF BPF register values from 131_quant.dat*/ | ||
2460 | {13100000, DIF_BPF_COEFF01, 0xffff0001}, | ||
2461 | {13100000, DIF_BPF_COEFF23, 0x0007fff5}, | ||
2462 | {13100000, DIF_BPF_COEFF45, 0xffe70028}, | ||
2463 | {13100000, DIF_BPF_COEFF67, 0x0037ff98}, | ||
2464 | {13100000, DIF_BPF_COEFF89, 0xffa400d8}, | ||
2465 | {13100000, DIF_BPF_COEFF1011, 0x0079fe7c}, | ||
2466 | {13100000, DIF_BPF_COEFF1213, 0xff87026f}, | ||
2467 | {13100000, DIF_BPF_COEFF1415, 0x0043fc6e}, | ||
2468 | {13100000, DIF_BPF_COEFF1617, 0x004404da}, | ||
2469 | {13100000, DIF_BPF_COEFF1819, 0xfecef9da}, | ||
2470 | {13100000, DIF_BPF_COEFF2021, 0x0294074e}, | ||
2471 | {13100000, DIF_BPF_COEFF2223, 0xfb99f7db}, | ||
2472 | {13100000, DIF_BPF_COEFF2425, 0x06980881}, | ||
2473 | {13100000, DIF_BPF_COEFF2627, 0xf6fef7be}, | ||
2474 | {13100000, DIF_BPF_COEFF2829, 0x0b730759}, | ||
2475 | {13100000, DIF_BPF_COEFF3031, 0xf251fa33}, | ||
2476 | {13100000, DIF_BPF_COEFF3233, 0x0f7b03b8}, | ||
2477 | {13100000, DIF_BPF_COEFF3435, 0xef5afeb8}, | ||
2478 | {13100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2479 | /* END - DIF BPF register values from 131_quant.dat*/ | ||
2480 | |||
2481 | |||
2482 | /*case 13200000:*/ | ||
2483 | /* BEGIN - DIF BPF register values from 132_quant.dat*/ | ||
2484 | {13200000, DIF_BPF_COEFF01, 0xffff0000}, | ||
2485 | {13200000, DIF_BPF_COEFF23, 0x0008fffc}, | ||
2486 | {13200000, DIF_BPF_COEFF45, 0xffe00017}, | ||
2487 | {13200000, DIF_BPF_COEFF67, 0x004cffb9}, | ||
2488 | {13200000, DIF_BPF_COEFF89, 0xff7500a8}, | ||
2489 | {13200000, DIF_BPF_COEFF1011, 0x00d1feb6}, | ||
2490 | {13200000, DIF_BPF_COEFF1213, 0xfef90238}, | ||
2491 | {13200000, DIF_BPF_COEFF1415, 0x0111fc91}, | ||
2492 | {13200000, DIF_BPF_COEFF1617, 0xff3604df}, | ||
2493 | {13200000, DIF_BPF_COEFF1819, 0x0012f99b}, | ||
2494 | {13200000, DIF_BPF_COEFF2021, 0x012d07d2}, | ||
2495 | {13200000, DIF_BPF_COEFF2223, 0xfd07f714}, | ||
2496 | {13200000, DIF_BPF_COEFF2425, 0x0542097e}, | ||
2497 | {13200000, DIF_BPF_COEFF2627, 0xf81ff6a4}, | ||
2498 | {13200000, DIF_BPF_COEFF2829, 0x0a9a086e}, | ||
2499 | {13200000, DIF_BPF_COEFF3031, 0xf2dbf94b}, | ||
2500 | {13200000, DIF_BPF_COEFF3233, 0x0f380453}, | ||
2501 | {13200000, DIF_BPF_COEFF3435, 0xef6cfe82}, | ||
2502 | {13200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2503 | /* END - DIF BPF register values from 132_quant.dat*/ | ||
2504 | |||
2505 | |||
2506 | /*case 13300000:*/ | ||
2507 | /* BEGIN - DIF BPF register values from 133_quant.dat*/ | ||
2508 | {13300000, DIF_BPF_COEFF01, 0xffffffff}, | ||
2509 | {13300000, DIF_BPF_COEFF23, 0x00080003}, | ||
2510 | {13300000, DIF_BPF_COEFF45, 0xffde0001}, | ||
2511 | {13300000, DIF_BPF_COEFF67, 0x0056ffe3}, | ||
2512 | {13300000, DIF_BPF_COEFF89, 0xff570064}, | ||
2513 | {13300000, DIF_BPF_COEFF1011, 0x0113ff10}, | ||
2514 | {13300000, DIF_BPF_COEFF1213, 0xfe8201d2}, | ||
2515 | {13300000, DIF_BPF_COEFF1415, 0x01cafcf0}, | ||
2516 | {13300000, DIF_BPF_COEFF1617, 0xfe35049e}, | ||
2517 | {13300000, DIF_BPF_COEFF1819, 0x0155f9a6}, | ||
2518 | {13300000, DIF_BPF_COEFF2021, 0xffba080e}, | ||
2519 | {13300000, DIF_BPF_COEFF2223, 0xfe8cf689}, | ||
2520 | {13300000, DIF_BPF_COEFF2425, 0x03ce0a4e}, | ||
2521 | {13300000, DIF_BPF_COEFF2627, 0xf961f5a8}, | ||
2522 | {13300000, DIF_BPF_COEFF2829, 0x09a50971}, | ||
2523 | {13300000, DIF_BPF_COEFF3031, 0xf379f869}, | ||
2524 | {13300000, DIF_BPF_COEFF3233, 0x0eeb04ec}, | ||
2525 | {13300000, DIF_BPF_COEFF3435, 0xef80fe4b}, | ||
2526 | {13300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2527 | /* END - DIF BPF register values from 133_quant.dat*/ | ||
2528 | |||
2529 | |||
2530 | /*case 13400000:*/ | ||
2531 | /* BEGIN - DIF BPF register values from 134_quant.dat*/ | ||
2532 | {13400000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
2533 | {13400000, DIF_BPF_COEFF23, 0x0007000a}, | ||
2534 | {13400000, DIF_BPF_COEFF45, 0xffe2ffec}, | ||
2535 | {13400000, DIF_BPF_COEFF67, 0x00540012}, | ||
2536 | {13400000, DIF_BPF_COEFF89, 0xff4e0015}, | ||
2537 | {13400000, DIF_BPF_COEFF1011, 0x0137ff82}, | ||
2538 | {13400000, DIF_BPF_COEFF1213, 0xfe2e0145}, | ||
2539 | {13400000, DIF_BPF_COEFF1415, 0x0260fd86}, | ||
2540 | {13400000, DIF_BPF_COEFF1617, 0xfd51041a}, | ||
2541 | {13400000, DIF_BPF_COEFF1819, 0x0287f9fb}, | ||
2542 | {13400000, DIF_BPF_COEFF2021, 0xfe4a0802}, | ||
2543 | {13400000, DIF_BPF_COEFF2223, 0x001df63f}, | ||
2544 | {13400000, DIF_BPF_COEFF2425, 0x02430aeb}, | ||
2545 | {13400000, DIF_BPF_COEFF2627, 0xfabdf4ce}, | ||
2546 | {13400000, DIF_BPF_COEFF2829, 0x08970a62}, | ||
2547 | {13400000, DIF_BPF_COEFF3031, 0xf428f78f}, | ||
2548 | {13400000, DIF_BPF_COEFF3233, 0x0e950584}, | ||
2549 | {13400000, DIF_BPF_COEFF3435, 0xef97fe15}, | ||
2550 | {13400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2551 | /* END - DIF BPF register values from 134_quant.dat*/ | ||
2552 | |||
2553 | |||
2554 | /*case 13500000:*/ | ||
2555 | /* BEGIN - DIF BPF register values from 135_quant.dat*/ | ||
2556 | {13500000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
2557 | {13500000, DIF_BPF_COEFF23, 0x0004000f}, | ||
2558 | {13500000, DIF_BPF_COEFF45, 0xffeaffda}, | ||
2559 | {13500000, DIF_BPF_COEFF67, 0x0046003d}, | ||
2560 | {13500000, DIF_BPF_COEFF89, 0xff5affc4}, | ||
2561 | {13500000, DIF_BPF_COEFF1011, 0x013b0000}, | ||
2562 | {13500000, DIF_BPF_COEFF1213, 0xfe04009d}, | ||
2563 | {13500000, DIF_BPF_COEFF1415, 0x02c8fe48}, | ||
2564 | {13500000, DIF_BPF_COEFF1617, 0xfc99035a}, | ||
2565 | {13500000, DIF_BPF_COEFF1819, 0x0397fa96}, | ||
2566 | {13500000, DIF_BPF_COEFF2021, 0xfcec07ad}, | ||
2567 | {13500000, DIF_BPF_COEFF2223, 0x01adf637}, | ||
2568 | {13500000, DIF_BPF_COEFF2425, 0x00ac0b53}, | ||
2569 | {13500000, DIF_BPF_COEFF2627, 0xfc2ef419}, | ||
2570 | {13500000, DIF_BPF_COEFF2829, 0x07730b3e}, | ||
2571 | {13500000, DIF_BPF_COEFF3031, 0xf4e9f6bd}, | ||
2572 | {13500000, DIF_BPF_COEFF3233, 0x0e35061a}, | ||
2573 | {13500000, DIF_BPF_COEFF3435, 0xefb1fddf}, | ||
2574 | {13500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2575 | /* END - DIF BPF register values from 135_quant.dat*/ | ||
2576 | |||
2577 | |||
2578 | /*case 13600000:*/ | ||
2579 | /* BEGIN - DIF BPF register values from 136_quant.dat*/ | ||
2580 | {13600000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
2581 | {13600000, DIF_BPF_COEFF23, 0x00000012}, | ||
2582 | {13600000, DIF_BPF_COEFF45, 0xfff6ffcd}, | ||
2583 | {13600000, DIF_BPF_COEFF67, 0x002f0061}, | ||
2584 | {13600000, DIF_BPF_COEFF89, 0xff7bff79}, | ||
2585 | {13600000, DIF_BPF_COEFF1011, 0x011e007e}, | ||
2586 | {13600000, DIF_BPF_COEFF1213, 0xfe08ffe8}, | ||
2587 | {13600000, DIF_BPF_COEFF1415, 0x02f9ff28}, | ||
2588 | {13600000, DIF_BPF_COEFF1617, 0xfc17026a}, | ||
2589 | {13600000, DIF_BPF_COEFF1819, 0x0479fb70}, | ||
2590 | {13600000, DIF_BPF_COEFF2021, 0xfbad0713}, | ||
2591 | {13600000, DIF_BPF_COEFF2223, 0x032ff672}, | ||
2592 | {13600000, DIF_BPF_COEFF2425, 0xff100b83}, | ||
2593 | {13600000, DIF_BPF_COEFF2627, 0xfdaff38b}, | ||
2594 | {13600000, DIF_BPF_COEFF2829, 0x063c0c04}, | ||
2595 | {13600000, DIF_BPF_COEFF3031, 0xf5baf5f5}, | ||
2596 | {13600000, DIF_BPF_COEFF3233, 0x0dcc06ae}, | ||
2597 | {13600000, DIF_BPF_COEFF3435, 0xefcdfda8}, | ||
2598 | {13600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2599 | /* END - DIF BPF register values from 136_quant.dat*/ | ||
2600 | |||
2601 | |||
2602 | /*case 13700000:*/ | ||
2603 | /* BEGIN - DIF BPF register values from 137_quant.dat*/ | ||
2604 | {13700000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
2605 | {13700000, DIF_BPF_COEFF23, 0xfffd0012}, | ||
2606 | {13700000, DIF_BPF_COEFF45, 0x0004ffc8}, | ||
2607 | {13700000, DIF_BPF_COEFF67, 0x00100078}, | ||
2608 | {13700000, DIF_BPF_COEFF89, 0xffacff3e}, | ||
2609 | {13700000, DIF_BPF_COEFF1011, 0x00e200f0}, | ||
2610 | {13700000, DIF_BPF_COEFF1213, 0xfe39ff35}, | ||
2611 | {13700000, DIF_BPF_COEFF1415, 0x02f10017}, | ||
2612 | {13700000, DIF_BPF_COEFF1617, 0xfbd30156}, | ||
2613 | {13700000, DIF_BPF_COEFF1819, 0x0521fc7f}, | ||
2614 | {13700000, DIF_BPF_COEFF2021, 0xfa9c0638}, | ||
2615 | {13700000, DIF_BPF_COEFF2223, 0x0499f6ee}, | ||
2616 | {13700000, DIF_BPF_COEFF2425, 0xfd7a0b7c}, | ||
2617 | {13700000, DIF_BPF_COEFF2627, 0xff39f325}, | ||
2618 | {13700000, DIF_BPF_COEFF2829, 0x04f40cb3}, | ||
2619 | {13700000, DIF_BPF_COEFF3031, 0xf69af537}, | ||
2620 | {13700000, DIF_BPF_COEFF3233, 0x0d5a073f}, | ||
2621 | {13700000, DIF_BPF_COEFF3435, 0xefecfd72}, | ||
2622 | {13700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2623 | /* END - DIF BPF register values from 137_quant.dat*/ | ||
2624 | |||
2625 | |||
2626 | /*case 13800000:*/ | ||
2627 | /* BEGIN - DIF BPF register values from 138_quant.dat*/ | ||
2628 | {13800000, DIF_BPF_COEFF01, 0x0001fffe}, | ||
2629 | {13800000, DIF_BPF_COEFF23, 0xfffa000e}, | ||
2630 | {13800000, DIF_BPF_COEFF45, 0x0011ffcb}, | ||
2631 | {13800000, DIF_BPF_COEFF67, 0xfff0007f}, | ||
2632 | {13800000, DIF_BPF_COEFF89, 0xffe7ff19}, | ||
2633 | {13800000, DIF_BPF_COEFF1011, 0x008f014a}, | ||
2634 | {13800000, DIF_BPF_COEFF1213, 0xfe94fe93}, | ||
2635 | {13800000, DIF_BPF_COEFF1415, 0x02b00105}, | ||
2636 | {13800000, DIF_BPF_COEFF1617, 0xfbd3002f}, | ||
2637 | {13800000, DIF_BPF_COEFF1819, 0x0585fdb7}, | ||
2638 | {13800000, DIF_BPF_COEFF2021, 0xf9c10525}, | ||
2639 | {13800000, DIF_BPF_COEFF2223, 0x05def7a8}, | ||
2640 | {13800000, DIF_BPF_COEFF2425, 0xfbf20b3c}, | ||
2641 | {13800000, DIF_BPF_COEFF2627, 0x00c7f2e9}, | ||
2642 | {13800000, DIF_BPF_COEFF2829, 0x03a00d48}, | ||
2643 | {13800000, DIF_BPF_COEFF3031, 0xf787f484}, | ||
2644 | {13800000, DIF_BPF_COEFF3233, 0x0cdf07cd}, | ||
2645 | {13800000, DIF_BPF_COEFF3435, 0xf00dfd3c}, | ||
2646 | {13800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2647 | /* END - DIF BPF register values from 138_quant.dat*/ | ||
2648 | |||
2649 | |||
2650 | /*case 13900000:*/ | ||
2651 | /* BEGIN - DIF BPF register values from 139_quant.dat*/ | ||
2652 | {13900000, DIF_BPF_COEFF01, 0x00010000}, | ||
2653 | {13900000, DIF_BPF_COEFF23, 0xfff80008}, | ||
2654 | {13900000, DIF_BPF_COEFF45, 0x001bffd7}, | ||
2655 | {13900000, DIF_BPF_COEFF67, 0xffd10076}, | ||
2656 | {13900000, DIF_BPF_COEFF89, 0x0026ff0e}, | ||
2657 | {13900000, DIF_BPF_COEFF1011, 0x002c0184}, | ||
2658 | {13900000, DIF_BPF_COEFF1213, 0xff0ffe10}, | ||
2659 | {13900000, DIF_BPF_COEFF1415, 0x023b01e0}, | ||
2660 | {13900000, DIF_BPF_COEFF1617, 0xfc17ff06}, | ||
2661 | {13900000, DIF_BPF_COEFF1819, 0x05a2ff09}, | ||
2662 | {13900000, DIF_BPF_COEFF2021, 0xf92703e4}, | ||
2663 | {13900000, DIF_BPF_COEFF2223, 0x06f4f89b}, | ||
2664 | {13900000, DIF_BPF_COEFF2425, 0xfa820ac5}, | ||
2665 | {13900000, DIF_BPF_COEFF2627, 0x0251f2d9}, | ||
2666 | {13900000, DIF_BPF_COEFF2829, 0x02430dc3}, | ||
2667 | {13900000, DIF_BPF_COEFF3031, 0xf881f3dc}, | ||
2668 | {13900000, DIF_BPF_COEFF3233, 0x0c5c0859}, | ||
2669 | {13900000, DIF_BPF_COEFF3435, 0xf031fd06}, | ||
2670 | {13900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2671 | /* END - DIF BPF register values from 139_quant.dat*/ | ||
2672 | |||
2673 | |||
2674 | /*case 14000000:*/ | ||
2675 | /* BEGIN - DIF BPF register values from 140_quant.dat*/ | ||
2676 | {14000000, DIF_BPF_COEFF01, 0x00010001}, | ||
2677 | {14000000, DIF_BPF_COEFF23, 0xfff80001}, | ||
2678 | {14000000, DIF_BPF_COEFF45, 0x0021ffe8}, | ||
2679 | {14000000, DIF_BPF_COEFF67, 0xffba005d}, | ||
2680 | {14000000, DIF_BPF_COEFF89, 0x0060ff1f}, | ||
2681 | {14000000, DIF_BPF_COEFF1011, 0xffc40198}, | ||
2682 | {14000000, DIF_BPF_COEFF1213, 0xffa0fdb5}, | ||
2683 | {14000000, DIF_BPF_COEFF1415, 0x019a029a}, | ||
2684 | {14000000, DIF_BPF_COEFF1617, 0xfc99fdea}, | ||
2685 | {14000000, DIF_BPF_COEFF1819, 0x05750067}, | ||
2686 | {14000000, DIF_BPF_COEFF2021, 0xf8d4027f}, | ||
2687 | {14000000, DIF_BPF_COEFF2223, 0x07d4f9c0}, | ||
2688 | {14000000, DIF_BPF_COEFF2425, 0xf9320a1a}, | ||
2689 | {14000000, DIF_BPF_COEFF2627, 0x03d2f2f3}, | ||
2690 | {14000000, DIF_BPF_COEFF2829, 0x00df0e22}, | ||
2691 | {14000000, DIF_BPF_COEFF3031, 0xf986f341}, | ||
2692 | {14000000, DIF_BPF_COEFF3233, 0x0bd108e2}, | ||
2693 | {14000000, DIF_BPF_COEFF3435, 0xf058fcd1}, | ||
2694 | {14000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2695 | /* END - DIF BPF register values from 140_quant.dat*/ | ||
2696 | |||
2697 | |||
2698 | /*case 14100000:*/ | ||
2699 | /* BEGIN - DIF BPF register values from 141_quant.dat*/ | ||
2700 | {14100000, DIF_BPF_COEFF01, 0x00000002}, | ||
2701 | {14100000, DIF_BPF_COEFF23, 0xfff9fffa}, | ||
2702 | {14100000, DIF_BPF_COEFF45, 0x0021fffd}, | ||
2703 | {14100000, DIF_BPF_COEFF67, 0xffac0038}, | ||
2704 | {14100000, DIF_BPF_COEFF89, 0x008eff4a}, | ||
2705 | {14100000, DIF_BPF_COEFF1011, 0xff630184}, | ||
2706 | {14100000, DIF_BPF_COEFF1213, 0x003afd8b}, | ||
2707 | {14100000, DIF_BPF_COEFF1415, 0x00da0326}, | ||
2708 | {14100000, DIF_BPF_COEFF1617, 0xfd51fced}, | ||
2709 | {14100000, DIF_BPF_COEFF1819, 0x050101c0}, | ||
2710 | {14100000, DIF_BPF_COEFF2021, 0xf8cb0103}, | ||
2711 | {14100000, DIF_BPF_COEFF2223, 0x0876fb10}, | ||
2712 | {14100000, DIF_BPF_COEFF2425, 0xf80a093e}, | ||
2713 | {14100000, DIF_BPF_COEFF2627, 0x0543f338}, | ||
2714 | {14100000, DIF_BPF_COEFF2829, 0xff7a0e66}, | ||
2715 | {14100000, DIF_BPF_COEFF3031, 0xfa94f2b2}, | ||
2716 | {14100000, DIF_BPF_COEFF3233, 0x0b3f0967}, | ||
2717 | {14100000, DIF_BPF_COEFF3435, 0xf081fc9b}, | ||
2718 | {14100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2719 | /* END - DIF BPF register values from 141_quant.dat*/ | ||
2720 | |||
2721 | |||
2722 | /*case 14200000:*/ | ||
2723 | /* BEGIN - DIF BPF register values from 142_quant.dat*/ | ||
2724 | {14200000, DIF_BPF_COEFF01, 0x00000003}, | ||
2725 | {14200000, DIF_BPF_COEFF23, 0xfffbfff3}, | ||
2726 | {14200000, DIF_BPF_COEFF45, 0x001d0013}, | ||
2727 | {14200000, DIF_BPF_COEFF67, 0xffaa000b}, | ||
2728 | {14200000, DIF_BPF_COEFF89, 0x00aaff89}, | ||
2729 | {14200000, DIF_BPF_COEFF1011, 0xff13014a}, | ||
2730 | {14200000, DIF_BPF_COEFF1213, 0x00cefd95}, | ||
2731 | {14200000, DIF_BPF_COEFF1415, 0x000a037b}, | ||
2732 | {14200000, DIF_BPF_COEFF1617, 0xfe35fc1d}, | ||
2733 | {14200000, DIF_BPF_COEFF1819, 0x044c0305}, | ||
2734 | {14200000, DIF_BPF_COEFF2021, 0xf90cff7e}, | ||
2735 | {14200000, DIF_BPF_COEFF2223, 0x08d5fc81}, | ||
2736 | {14200000, DIF_BPF_COEFF2425, 0xf7100834}, | ||
2737 | {14200000, DIF_BPF_COEFF2627, 0x069ff3a7}, | ||
2738 | {14200000, DIF_BPF_COEFF2829, 0xfe160e8d}, | ||
2739 | {14200000, DIF_BPF_COEFF3031, 0xfbaaf231}, | ||
2740 | {14200000, DIF_BPF_COEFF3233, 0x0aa509e9}, | ||
2741 | {14200000, DIF_BPF_COEFF3435, 0xf0adfc65}, | ||
2742 | {14200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2743 | /* END - DIF BPF register values from 142_quant.dat*/ | ||
2744 | |||
2745 | |||
2746 | /*case 14300000:*/ | ||
2747 | /* BEGIN - DIF BPF register values from 143_quant.dat*/ | ||
2748 | {14300000, DIF_BPF_COEFF01, 0x00000003}, | ||
2749 | {14300000, DIF_BPF_COEFF23, 0xffffffef}, | ||
2750 | {14300000, DIF_BPF_COEFF45, 0x00140025}, | ||
2751 | {14300000, DIF_BPF_COEFF67, 0xffb4ffdd}, | ||
2752 | {14300000, DIF_BPF_COEFF89, 0x00b2ffd6}, | ||
2753 | {14300000, DIF_BPF_COEFF1011, 0xfedb00f0}, | ||
2754 | {14300000, DIF_BPF_COEFF1213, 0x0150fdd3}, | ||
2755 | {14300000, DIF_BPF_COEFF1415, 0xff380391}, | ||
2756 | {14300000, DIF_BPF_COEFF1617, 0xff36fb85}, | ||
2757 | {14300000, DIF_BPF_COEFF1819, 0x035e0426}, | ||
2758 | {14300000, DIF_BPF_COEFF2021, 0xf994fdfe}, | ||
2759 | {14300000, DIF_BPF_COEFF2223, 0x08eefe0b}, | ||
2760 | {14300000, DIF_BPF_COEFF2425, 0xf6490702}, | ||
2761 | {14300000, DIF_BPF_COEFF2627, 0x07e1f43e}, | ||
2762 | {14300000, DIF_BPF_COEFF2829, 0xfcb60e97}, | ||
2763 | {14300000, DIF_BPF_COEFF3031, 0xfcc6f1be}, | ||
2764 | {14300000, DIF_BPF_COEFF3233, 0x0a040a67}, | ||
2765 | {14300000, DIF_BPF_COEFF3435, 0xf0dbfc30}, | ||
2766 | {14300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2767 | /* END - DIF BPF register values from 143_quant.dat*/ | ||
2768 | |||
2769 | |||
2770 | /*case 14400000:*/ | ||
2771 | /* BEGIN - DIF BPF register values from 144_quant.dat*/ | ||
2772 | {14400000, DIF_BPF_COEFF01, 0x00000003}, | ||
2773 | {14400000, DIF_BPF_COEFF23, 0x0002ffee}, | ||
2774 | {14400000, DIF_BPF_COEFF45, 0x00070033}, | ||
2775 | {14400000, DIF_BPF_COEFF67, 0xffc9ffb4}, | ||
2776 | {14400000, DIF_BPF_COEFF89, 0x00a40027}, | ||
2777 | {14400000, DIF_BPF_COEFF1011, 0xfec3007e}, | ||
2778 | {14400000, DIF_BPF_COEFF1213, 0x01b4fe3f}, | ||
2779 | {14400000, DIF_BPF_COEFF1415, 0xfe760369}, | ||
2780 | {14400000, DIF_BPF_COEFF1617, 0x0044fb2e}, | ||
2781 | {14400000, DIF_BPF_COEFF1819, 0x02450518}, | ||
2782 | {14400000, DIF_BPF_COEFF2021, 0xfa5ffc90}, | ||
2783 | {14400000, DIF_BPF_COEFF2223, 0x08c1ffa1}, | ||
2784 | {14400000, DIF_BPF_COEFF2425, 0xf5bc05ae}, | ||
2785 | {14400000, DIF_BPF_COEFF2627, 0x0902f4fc}, | ||
2786 | {14400000, DIF_BPF_COEFF2829, 0xfb600e85}, | ||
2787 | {14400000, DIF_BPF_COEFF3031, 0xfde7f15a}, | ||
2788 | {14400000, DIF_BPF_COEFF3233, 0x095d0ae2}, | ||
2789 | {14400000, DIF_BPF_COEFF3435, 0xf10cfbfb}, | ||
2790 | {14400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2791 | /* END - DIF BPF register values from 144_quant.dat*/ | ||
2792 | |||
2793 | |||
2794 | /*case 14500000:*/ | ||
2795 | /* BEGIN - DIF BPF register values from 145_quant.dat*/ | ||
2796 | {14500000, DIF_BPF_COEFF01, 0xffff0002}, | ||
2797 | {14500000, DIF_BPF_COEFF23, 0x0005ffef}, | ||
2798 | {14500000, DIF_BPF_COEFF45, 0xfffa0038}, | ||
2799 | {14500000, DIF_BPF_COEFF67, 0xffe5ff95}, | ||
2800 | {14500000, DIF_BPF_COEFF89, 0x00820074}, | ||
2801 | {14500000, DIF_BPF_COEFF1011, 0xfecc0000}, | ||
2802 | {14500000, DIF_BPF_COEFF1213, 0x01f0fed0}, | ||
2803 | {14500000, DIF_BPF_COEFF1415, 0xfdd20304}, | ||
2804 | {14500000, DIF_BPF_COEFF1617, 0x014dfb1d}, | ||
2805 | {14500000, DIF_BPF_COEFF1819, 0x010e05ce}, | ||
2806 | {14500000, DIF_BPF_COEFF2021, 0xfb64fb41}, | ||
2807 | {14500000, DIF_BPF_COEFF2223, 0x084e013b}, | ||
2808 | {14500000, DIF_BPF_COEFF2425, 0xf569043e}, | ||
2809 | {14500000, DIF_BPF_COEFF2627, 0x0a00f5dd}, | ||
2810 | {14500000, DIF_BPF_COEFF2829, 0xfa150e55}, | ||
2811 | {14500000, DIF_BPF_COEFF3031, 0xff0bf104}, | ||
2812 | {14500000, DIF_BPF_COEFF3233, 0x08b00b59}, | ||
2813 | {14500000, DIF_BPF_COEFF3435, 0xf13ffbc6}, | ||
2814 | {14500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2815 | /* END - DIF BPF register values from 145_quant.dat*/ | ||
2816 | |||
2817 | |||
2818 | /*case 14600000:*/ | ||
2819 | /* BEGIN - DIF BPF register values from 146_quant.dat*/ | ||
2820 | {14600000, DIF_BPF_COEFF01, 0xffff0001}, | ||
2821 | {14600000, DIF_BPF_COEFF23, 0x0008fff4}, | ||
2822 | {14600000, DIF_BPF_COEFF45, 0xffed0035}, | ||
2823 | {14600000, DIF_BPF_COEFF67, 0x0005ff83}, | ||
2824 | {14600000, DIF_BPF_COEFF89, 0x005000b4}, | ||
2825 | {14600000, DIF_BPF_COEFF1011, 0xfef6ff82}, | ||
2826 | {14600000, DIF_BPF_COEFF1213, 0x01ffff7a}, | ||
2827 | {14600000, DIF_BPF_COEFF1415, 0xfd580269}, | ||
2828 | {14600000, DIF_BPF_COEFF1617, 0x0241fb53}, | ||
2829 | {14600000, DIF_BPF_COEFF1819, 0xffca0640}, | ||
2830 | {14600000, DIF_BPF_COEFF2021, 0xfc99fa1e}, | ||
2831 | {14600000, DIF_BPF_COEFF2223, 0x079a02cb}, | ||
2832 | {14600000, DIF_BPF_COEFF2425, 0xf55502ba}, | ||
2833 | {14600000, DIF_BPF_COEFF2627, 0x0ad5f6e0}, | ||
2834 | {14600000, DIF_BPF_COEFF2829, 0xf8d90e0a}, | ||
2835 | {14600000, DIF_BPF_COEFF3031, 0x0031f0bd}, | ||
2836 | {14600000, DIF_BPF_COEFF3233, 0x07fd0bcb}, | ||
2837 | {14600000, DIF_BPF_COEFF3435, 0xf174fb91}, | ||
2838 | {14600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2839 | /* END - DIF BPF register values from 146_quant.dat*/ | ||
2840 | |||
2841 | |||
2842 | /*case 14700000:*/ | ||
2843 | /* BEGIN - DIF BPF register values from 147_quant.dat*/ | ||
2844 | {14700000, DIF_BPF_COEFF01, 0xffffffff}, | ||
2845 | {14700000, DIF_BPF_COEFF23, 0x0009fffb}, | ||
2846 | {14700000, DIF_BPF_COEFF45, 0xffe4002a}, | ||
2847 | {14700000, DIF_BPF_COEFF67, 0x0025ff82}, | ||
2848 | {14700000, DIF_BPF_COEFF89, 0x001400e0}, | ||
2849 | {14700000, DIF_BPF_COEFF1011, 0xff3cff10}, | ||
2850 | {14700000, DIF_BPF_COEFF1213, 0x01e10030}, | ||
2851 | {14700000, DIF_BPF_COEFF1415, 0xfd1201a4}, | ||
2852 | {14700000, DIF_BPF_COEFF1617, 0x0311fbcd}, | ||
2853 | {14700000, DIF_BPF_COEFF1819, 0xfe88066a}, | ||
2854 | {14700000, DIF_BPF_COEFF2021, 0xfdf1f92f}, | ||
2855 | {14700000, DIF_BPF_COEFF2223, 0x06aa0449}, | ||
2856 | {14700000, DIF_BPF_COEFF2425, 0xf57e0128}, | ||
2857 | {14700000, DIF_BPF_COEFF2627, 0x0b7ef801}, | ||
2858 | {14700000, DIF_BPF_COEFF2829, 0xf7b00da2}, | ||
2859 | {14700000, DIF_BPF_COEFF3031, 0x0156f086}, | ||
2860 | {14700000, DIF_BPF_COEFF3233, 0x07450c39}, | ||
2861 | {14700000, DIF_BPF_COEFF3435, 0xf1acfb5c}, | ||
2862 | {14700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2863 | /* END - DIF BPF register values from 147_quant.dat*/ | ||
2864 | |||
2865 | |||
2866 | /*case 14800000:*/ | ||
2867 | /* BEGIN - DIF BPF register values from 148_quant.dat*/ | ||
2868 | {14800000, DIF_BPF_COEFF01, 0x0000fffe}, | ||
2869 | {14800000, DIF_BPF_COEFF23, 0x00080002}, | ||
2870 | {14800000, DIF_BPF_COEFF45, 0xffdf0019}, | ||
2871 | {14800000, DIF_BPF_COEFF67, 0x003fff92}, | ||
2872 | {14800000, DIF_BPF_COEFF89, 0xffd600f1}, | ||
2873 | {14800000, DIF_BPF_COEFF1011, 0xff96feb6}, | ||
2874 | {14800000, DIF_BPF_COEFF1213, 0x019700e1}, | ||
2875 | {14800000, DIF_BPF_COEFF1415, 0xfd0500c2}, | ||
2876 | {14800000, DIF_BPF_COEFF1617, 0x03b0fc84}, | ||
2877 | {14800000, DIF_BPF_COEFF1819, 0xfd590649}, | ||
2878 | {14800000, DIF_BPF_COEFF2021, 0xff5df87f}, | ||
2879 | {14800000, DIF_BPF_COEFF2223, 0x058505aa}, | ||
2880 | {14800000, DIF_BPF_COEFF2425, 0xf5e4ff91}, | ||
2881 | {14800000, DIF_BPF_COEFF2627, 0x0bf9f93c}, | ||
2882 | {14800000, DIF_BPF_COEFF2829, 0xf69d0d20}, | ||
2883 | {14800000, DIF_BPF_COEFF3031, 0x0279f05e}, | ||
2884 | {14800000, DIF_BPF_COEFF3233, 0x06880ca3}, | ||
2885 | {14800000, DIF_BPF_COEFF3435, 0xf1e6fb28}, | ||
2886 | {14800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2887 | /* END - DIF BPF register values from 148_quant.dat*/ | ||
2888 | |||
2889 | |||
2890 | /*case 14900000:*/ | ||
2891 | /* BEGIN - DIF BPF register values from 149_quant.dat*/ | ||
2892 | {14900000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
2893 | {14900000, DIF_BPF_COEFF23, 0x00060009}, | ||
2894 | {14900000, DIF_BPF_COEFF45, 0xffdf0004}, | ||
2895 | {14900000, DIF_BPF_COEFF67, 0x0051ffb0}, | ||
2896 | {14900000, DIF_BPF_COEFF89, 0xff9d00e8}, | ||
2897 | {14900000, DIF_BPF_COEFF1011, 0xfffcfe7c}, | ||
2898 | {14900000, DIF_BPF_COEFF1213, 0x01280180}, | ||
2899 | {14900000, DIF_BPF_COEFF1415, 0xfd32ffd2}, | ||
2900 | {14900000, DIF_BPF_COEFF1617, 0x0413fd6e}, | ||
2901 | {14900000, DIF_BPF_COEFF1819, 0xfc4d05df}, | ||
2902 | {14900000, DIF_BPF_COEFF2021, 0x00d1f812}, | ||
2903 | {14900000, DIF_BPF_COEFF2223, 0x043506e4}, | ||
2904 | {14900000, DIF_BPF_COEFF2425, 0xf685fdfb}, | ||
2905 | {14900000, DIF_BPF_COEFF2627, 0x0c43fa8d}, | ||
2906 | {14900000, DIF_BPF_COEFF2829, 0xf5a10c83}, | ||
2907 | {14900000, DIF_BPF_COEFF3031, 0x0399f046}, | ||
2908 | {14900000, DIF_BPF_COEFF3233, 0x05c70d08}, | ||
2909 | {14900000, DIF_BPF_COEFF3435, 0xf222faf3}, | ||
2910 | {14900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2911 | /* END - DIF BPF register values from 149_quant.dat*/ | ||
2912 | |||
2913 | |||
2914 | /*case 15000000:*/ | ||
2915 | /* BEGIN - DIF BPF register values from 150_quant.dat*/ | ||
2916 | {15000000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
2917 | {15000000, DIF_BPF_COEFF23, 0x0003000f}, | ||
2918 | {15000000, DIF_BPF_COEFF45, 0xffe5ffef}, | ||
2919 | {15000000, DIF_BPF_COEFF67, 0x0057ffd9}, | ||
2920 | {15000000, DIF_BPF_COEFF89, 0xff7000c4}, | ||
2921 | {15000000, DIF_BPF_COEFF1011, 0x0062fe68}, | ||
2922 | {15000000, DIF_BPF_COEFF1213, 0x009e01ff}, | ||
2923 | {15000000, DIF_BPF_COEFF1415, 0xfd95fee6}, | ||
2924 | {15000000, DIF_BPF_COEFF1617, 0x0435fe7d}, | ||
2925 | {15000000, DIF_BPF_COEFF1819, 0xfb710530}, | ||
2926 | {15000000, DIF_BPF_COEFF2021, 0x023cf7ee}, | ||
2927 | {15000000, DIF_BPF_COEFF2223, 0x02c307ef}, | ||
2928 | {15000000, DIF_BPF_COEFF2425, 0xf75efc70}, | ||
2929 | {15000000, DIF_BPF_COEFF2627, 0x0c5cfbef}, | ||
2930 | {15000000, DIF_BPF_COEFF2829, 0xf4c10bce}, | ||
2931 | {15000000, DIF_BPF_COEFF3031, 0x04b3f03f}, | ||
2932 | {15000000, DIF_BPF_COEFF3233, 0x05030d69}, | ||
2933 | {15000000, DIF_BPF_COEFF3435, 0xf261fabf}, | ||
2934 | {15000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2935 | /* END - DIF BPF register values from 150_quant.dat*/ | ||
2936 | |||
2937 | |||
2938 | /*case 15100000:*/ | ||
2939 | /* BEGIN - DIF BPF register values from 151_quant.dat*/ | ||
2940 | {15100000, DIF_BPF_COEFF01, 0x0000fffd}, | ||
2941 | {15100000, DIF_BPF_COEFF23, 0xffff0012}, | ||
2942 | {15100000, DIF_BPF_COEFF45, 0xffefffdc}, | ||
2943 | {15100000, DIF_BPF_COEFF67, 0x00510006}, | ||
2944 | {15100000, DIF_BPF_COEFF89, 0xff540089}, | ||
2945 | {15100000, DIF_BPF_COEFF1011, 0x00befe7c}, | ||
2946 | {15100000, DIF_BPF_COEFF1213, 0x00060253}, | ||
2947 | {15100000, DIF_BPF_COEFF1415, 0xfe27fe0d}, | ||
2948 | {15100000, DIF_BPF_COEFF1617, 0x0413ffa2}, | ||
2949 | {15100000, DIF_BPF_COEFF1819, 0xfad10446}, | ||
2950 | {15100000, DIF_BPF_COEFF2021, 0x0390f812}, | ||
2951 | {15100000, DIF_BPF_COEFF2223, 0x013b08c3}, | ||
2952 | {15100000, DIF_BPF_COEFF2425, 0xf868faf6}, | ||
2953 | {15100000, DIF_BPF_COEFF2627, 0x0c43fd5f}, | ||
2954 | {15100000, DIF_BPF_COEFF2829, 0xf3fd0b02}, | ||
2955 | {15100000, DIF_BPF_COEFF3031, 0x05c7f046}, | ||
2956 | {15100000, DIF_BPF_COEFF3233, 0x043b0dc4}, | ||
2957 | {15100000, DIF_BPF_COEFF3435, 0xf2a1fa8b}, | ||
2958 | {15100000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2959 | /* END - DIF BPF register values from 151_quant.dat*/ | ||
2960 | |||
2961 | |||
2962 | /*case 15200000:*/ | ||
2963 | /* BEGIN - DIF BPF register values from 152_quant.dat*/ | ||
2964 | {15200000, DIF_BPF_COEFF01, 0x0001fffe}, | ||
2965 | {15200000, DIF_BPF_COEFF23, 0xfffc0012}, | ||
2966 | {15200000, DIF_BPF_COEFF45, 0xfffbffce}, | ||
2967 | {15200000, DIF_BPF_COEFF67, 0x003f0033}, | ||
2968 | {15200000, DIF_BPF_COEFF89, 0xff4e003f}, | ||
2969 | {15200000, DIF_BPF_COEFF1011, 0x0106feb6}, | ||
2970 | {15200000, DIF_BPF_COEFF1213, 0xff6e0276}, | ||
2971 | {15200000, DIF_BPF_COEFF1415, 0xfeddfd56}, | ||
2972 | {15200000, DIF_BPF_COEFF1617, 0x03b000cc}, | ||
2973 | {15200000, DIF_BPF_COEFF1819, 0xfa740329}, | ||
2974 | {15200000, DIF_BPF_COEFF2021, 0x04bff87f}, | ||
2975 | {15200000, DIF_BPF_COEFF2223, 0xffaa095d}, | ||
2976 | {15200000, DIF_BPF_COEFF2425, 0xf99ef995}, | ||
2977 | {15200000, DIF_BPF_COEFF2627, 0x0bf9fed8}, | ||
2978 | {15200000, DIF_BPF_COEFF2829, 0xf3590a1f}, | ||
2979 | {15200000, DIF_BPF_COEFF3031, 0x06d2f05e}, | ||
2980 | {15200000, DIF_BPF_COEFF3233, 0x03700e1b}, | ||
2981 | {15200000, DIF_BPF_COEFF3435, 0xf2e4fa58}, | ||
2982 | {15200000, DIF_BPF_COEFF36, 0x110d0000}, | ||
2983 | /* END - DIF BPF register values from 152_quant.dat*/ | ||
2984 | |||
2985 | |||
2986 | /*case 115300000:*/ | ||
2987 | /* BEGIN - DIF BPF register values from 153_quant.dat*/ | ||
2988 | {15300000, DIF_BPF_COEFF01, 0x0001ffff}, | ||
2989 | {15300000, DIF_BPF_COEFF23, 0xfff9000f}, | ||
2990 | {15300000, DIF_BPF_COEFF45, 0x0009ffc8}, | ||
2991 | {15300000, DIF_BPF_COEFF67, 0x00250059}, | ||
2992 | {15300000, DIF_BPF_COEFF89, 0xff5effee}, | ||
2993 | {15300000, DIF_BPF_COEFF1011, 0x0132ff10}, | ||
2994 | {15300000, DIF_BPF_COEFF1213, 0xfee30265}, | ||
2995 | {15300000, DIF_BPF_COEFF1415, 0xffaafccf}, | ||
2996 | {15300000, DIF_BPF_COEFF1617, 0x031101eb}, | ||
2997 | {15300000, DIF_BPF_COEFF1819, 0xfa6001e8}, | ||
2998 | {15300000, DIF_BPF_COEFF2021, 0x05bdf92f}, | ||
2999 | {15300000, DIF_BPF_COEFF2223, 0xfe1b09b6}, | ||
3000 | {15300000, DIF_BPF_COEFF2425, 0xfafaf852}, | ||
3001 | {15300000, DIF_BPF_COEFF2627, 0x0b7e0055}, | ||
3002 | {15300000, DIF_BPF_COEFF2829, 0xf2d50929}, | ||
3003 | {15300000, DIF_BPF_COEFF3031, 0x07d3f086}, | ||
3004 | {15300000, DIF_BPF_COEFF3233, 0x02a30e6c}, | ||
3005 | {15300000, DIF_BPF_COEFF3435, 0xf329fa24}, | ||
3006 | {15300000, DIF_BPF_COEFF36, 0x110d0000}, | ||
3007 | /* END - DIF BPF register values from 153_quant.dat*/ | ||
3008 | |||
3009 | |||
3010 | /*case 115400000:*/ | ||
3011 | /* BEGIN - DIF BPF register values from 154_quant.dat*/ | ||
3012 | {15400000, DIF_BPF_COEFF01, 0x00010001}, | ||
3013 | {15400000, DIF_BPF_COEFF23, 0xfff80009}, | ||
3014 | {15400000, DIF_BPF_COEFF45, 0x0015ffca}, | ||
3015 | {15400000, DIF_BPF_COEFF67, 0x00050074}, | ||
3016 | {15400000, DIF_BPF_COEFF89, 0xff81ff9f}, | ||
3017 | {15400000, DIF_BPF_COEFF1011, 0x013dff82}, | ||
3018 | {15400000, DIF_BPF_COEFF1213, 0xfe710221}, | ||
3019 | {15400000, DIF_BPF_COEFF1415, 0x007cfc80}, | ||
3020 | {15400000, DIF_BPF_COEFF1617, 0x024102ed}, | ||
3021 | {15400000, DIF_BPF_COEFF1819, 0xfa940090}, | ||
3022 | {15400000, DIF_BPF_COEFF2021, 0x0680fa1e}, | ||
3023 | {15400000, DIF_BPF_COEFF2223, 0xfc9b09cd}, | ||
3024 | {15400000, DIF_BPF_COEFF2425, 0xfc73f736}, | ||
3025 | {15400000, DIF_BPF_COEFF2627, 0x0ad501d0}, | ||
3026 | {15400000, DIF_BPF_COEFF2829, 0xf2740820}, | ||
3027 | {15400000, DIF_BPF_COEFF3031, 0x08c9f0bd}, | ||
3028 | {15400000, DIF_BPF_COEFF3233, 0x01d40eb9}, | ||
3029 | {15400000, DIF_BPF_COEFF3435, 0xf371f9f1}, | ||
3030 | {15400000, DIF_BPF_COEFF36, 0x110d0000}, | ||
3031 | /* END - DIF BPF register values from 154_quant.dat*/ | ||
3032 | |||
3033 | |||
3034 | /*case 115500000:*/ | ||
3035 | /* BEGIN - DIF BPF register values from 155_quant.dat*/ | ||
3036 | {15500000, DIF_BPF_COEFF01, 0x00000002}, | ||
3037 | {15500000, DIF_BPF_COEFF23, 0xfff80002}, | ||
3038 | {15500000, DIF_BPF_COEFF45, 0x001effd5}, | ||
3039 | {15500000, DIF_BPF_COEFF67, 0xffe5007f}, | ||
3040 | {15500000, DIF_BPF_COEFF89, 0xffb4ff5b}, | ||
3041 | {15500000, DIF_BPF_COEFF1011, 0x01280000}, | ||
3042 | {15500000, DIF_BPF_COEFF1213, 0xfe2401b0}, | ||
3043 | {15500000, DIF_BPF_COEFF1415, 0x0146fc70}, | ||
3044 | {15500000, DIF_BPF_COEFF1617, 0x014d03c6}, | ||
3045 | {15500000, DIF_BPF_COEFF1819, 0xfb10ff32}, | ||
3046 | {15500000, DIF_BPF_COEFF2021, 0x0701fb41}, | ||
3047 | {15500000, DIF_BPF_COEFF2223, 0xfb3709a1}, | ||
3048 | {15500000, DIF_BPF_COEFF2425, 0xfe00f644}, | ||
3049 | {15500000, DIF_BPF_COEFF2627, 0x0a000345}, | ||
3050 | {15500000, DIF_BPF_COEFF2829, 0xf2350708}, | ||
3051 | {15500000, DIF_BPF_COEFF3031, 0x09b2f104}, | ||
3052 | {15500000, DIF_BPF_COEFF3233, 0x01050eff}, | ||
3053 | {15500000, DIF_BPF_COEFF3435, 0xf3baf9be}, | ||
3054 | {15500000, DIF_BPF_COEFF36, 0x110d0000}, | ||
3055 | /* END - DIF BPF register values from 155_quant.dat*/ | ||
3056 | |||
3057 | |||
3058 | /*case 115600000:*/ | ||
3059 | /* BEGIN - DIF BPF register values from 156_quant.dat*/ | ||
3060 | {15600000, DIF_BPF_COEFF01, 0x00000003}, | ||
3061 | {15600000, DIF_BPF_COEFF23, 0xfff9fffb}, | ||
3062 | {15600000, DIF_BPF_COEFF45, 0x0022ffe6}, | ||
3063 | {15600000, DIF_BPF_COEFF67, 0xffc9007a}, | ||
3064 | {15600000, DIF_BPF_COEFF89, 0xfff0ff29}, | ||
3065 | {15600000, DIF_BPF_COEFF1011, 0x00f2007e}, | ||
3066 | {15600000, DIF_BPF_COEFF1213, 0xfe01011b}, | ||
3067 | {15600000, DIF_BPF_COEFF1415, 0x01f6fc9e}, | ||
3068 | {15600000, DIF_BPF_COEFF1617, 0x00440467}, | ||
3069 | {15600000, DIF_BPF_COEFF1819, 0xfbccfdde}, | ||
3070 | {15600000, DIF_BPF_COEFF2021, 0x0738fc90}, | ||
3071 | {15600000, DIF_BPF_COEFF2223, 0xf9f70934}, | ||
3072 | {15600000, DIF_BPF_COEFF2425, 0xff99f582}, | ||
3073 | {15600000, DIF_BPF_COEFF2627, 0x090204b0}, | ||
3074 | {15600000, DIF_BPF_COEFF2829, 0xf21a05e1}, | ||
3075 | {15600000, DIF_BPF_COEFF3031, 0x0a8df15a}, | ||
3076 | {15600000, DIF_BPF_COEFF3233, 0x00340f41}, | ||
3077 | {15600000, DIF_BPF_COEFF3435, 0xf405f98b}, | ||
3078 | {15600000, DIF_BPF_COEFF36, 0x110d0000}, | ||
3079 | /* END - DIF BPF register values from 156_quant.dat*/ | ||
3080 | |||
3081 | |||
3082 | /*case 115700000:*/ | ||
3083 | /* BEGIN - DIF BPF register values from 157_quant.dat*/ | ||
3084 | {15700000, DIF_BPF_COEFF01, 0x00000003}, | ||
3085 | {15700000, DIF_BPF_COEFF23, 0xfffcfff4}, | ||
3086 | {15700000, DIF_BPF_COEFF45, 0x0020fffa}, | ||
3087 | {15700000, DIF_BPF_COEFF67, 0xffb40064}, | ||
3088 | {15700000, DIF_BPF_COEFF89, 0x002fff11}, | ||
3089 | {15700000, DIF_BPF_COEFF1011, 0x00a400f0}, | ||
3090 | {15700000, DIF_BPF_COEFF1213, 0xfe0d006e}, | ||
3091 | {15700000, DIF_BPF_COEFF1415, 0x0281fd09}, | ||
3092 | {15700000, DIF_BPF_COEFF1617, 0xff3604c9}, | ||
3093 | {15700000, DIF_BPF_COEFF1819, 0xfcbffca2}, | ||
3094 | {15700000, DIF_BPF_COEFF2021, 0x0726fdfe}, | ||
3095 | {15700000, DIF_BPF_COEFF2223, 0xf8e80888}, | ||
3096 | {15700000, DIF_BPF_COEFF2425, 0x0134f4f3}, | ||
3097 | {15700000, DIF_BPF_COEFF2627, 0x07e1060c}, | ||
3098 | {15700000, DIF_BPF_COEFF2829, 0xf22304af}, | ||
3099 | {15700000, DIF_BPF_COEFF3031, 0x0b59f1be}, | ||
3100 | {15700000, DIF_BPF_COEFF3233, 0xff640f7d}, | ||
3101 | {15700000, DIF_BPF_COEFF3435, 0xf452f959}, | ||
3102 | {15700000, DIF_BPF_COEFF36, 0x110d0000}, | ||
3103 | /* END - DIF BPF register values from 157_quant.dat*/ | ||
3104 | |||
3105 | |||
3106 | /*case 115800000:*/ | ||
3107 | /* BEGIN - DIF BPF register values from 158_quant.dat*/ | ||
3108 | {15800000, DIF_BPF_COEFF01, 0x00000003}, | ||
3109 | {15800000, DIF_BPF_COEFF23, 0x0000fff0}, | ||
3110 | {15800000, DIF_BPF_COEFF45, 0x001a0010}, | ||
3111 | {15800000, DIF_BPF_COEFF67, 0xffaa0041}, | ||
3112 | {15800000, DIF_BPF_COEFF89, 0x0067ff13}, | ||
3113 | {15800000, DIF_BPF_COEFF1011, 0x0043014a}, | ||
3114 | {15800000, DIF_BPF_COEFF1213, 0xfe46ffb9}, | ||
3115 | {15800000, DIF_BPF_COEFF1415, 0x02dbfda8}, | ||
3116 | {15800000, DIF_BPF_COEFF1617, 0xfe3504e5}, | ||
3117 | {15800000, DIF_BPF_COEFF1819, 0xfddcfb8d}, | ||
3118 | {15800000, DIF_BPF_COEFF2021, 0x06c9ff7e}, | ||
3119 | {15800000, DIF_BPF_COEFF2223, 0xf81107a2}, | ||
3120 | {15800000, DIF_BPF_COEFF2425, 0x02c9f49a}, | ||
3121 | {15800000, DIF_BPF_COEFF2627, 0x069f0753}, | ||
3122 | {15800000, DIF_BPF_COEFF2829, 0xf2500373}, | ||
3123 | {15800000, DIF_BPF_COEFF3031, 0x0c14f231}, | ||
3124 | {15800000, DIF_BPF_COEFF3233, 0xfe930fb3}, | ||
3125 | {15800000, DIF_BPF_COEFF3435, 0xf4a1f927}, | ||
3126 | {15800000, DIF_BPF_COEFF36, 0x110d0000}, | ||
3127 | /* END - DIF BPF register values from 158_quant.dat*/ | ||
3128 | |||
3129 | |||
3130 | /*case 115900000:*/ | ||
3131 | /* BEGIN - DIF BPF register values from 159_quant.dat*/ | ||
3132 | {15900000, DIF_BPF_COEFF01, 0xffff0002}, | ||
3133 | {15900000, DIF_BPF_COEFF23, 0x0003ffee}, | ||
3134 | {15900000, DIF_BPF_COEFF45, 0x000f0023}, | ||
3135 | {15900000, DIF_BPF_COEFF67, 0xffac0016}, | ||
3136 | {15900000, DIF_BPF_COEFF89, 0x0093ff31}, | ||
3137 | {15900000, DIF_BPF_COEFF1011, 0xffdc0184}, | ||
3138 | {15900000, DIF_BPF_COEFF1213, 0xfea6ff09}, | ||
3139 | {15900000, DIF_BPF_COEFF1415, 0x02fdfe70}, | ||
3140 | {15900000, DIF_BPF_COEFF1617, 0xfd5104ba}, | ||
3141 | {15900000, DIF_BPF_COEFF1819, 0xff15faac}, | ||
3142 | {15900000, DIF_BPF_COEFF2021, 0x06270103}, | ||
3143 | {15900000, DIF_BPF_COEFF2223, 0xf7780688}, | ||
3144 | {15900000, DIF_BPF_COEFF2425, 0x044df479}, | ||
3145 | {15900000, DIF_BPF_COEFF2627, 0x05430883}, | ||
3146 | {15900000, DIF_BPF_COEFF2829, 0xf2a00231}, | ||
3147 | {15900000, DIF_BPF_COEFF3031, 0x0cbef2b2}, | ||
3148 | {15900000, DIF_BPF_COEFF3233, 0xfdc40fe3}, | ||
3149 | {15900000, DIF_BPF_COEFF3435, 0xf4f2f8f5}, | ||
3150 | {15900000, DIF_BPF_COEFF36, 0x110d0000}, | ||
3151 | /* END - DIF BPF register values from 159_quant.dat*/ | ||
3152 | |||
3153 | |||
3154 | /*case 116000000:*/ | ||
3155 | /* BEGIN - DIF BPF register values from 160_quant.dat*/ | ||
3156 | {16000000, DIF_BPF_COEFF01, 0xffff0001}, | ||
3157 | {16000000, DIF_BPF_COEFF23, 0x0006ffef}, | ||
3158 | {16000000, DIF_BPF_COEFF45, 0x00020031}, | ||
3159 | {16000000, DIF_BPF_COEFF67, 0xffbaffe8}, | ||
3160 | {16000000, DIF_BPF_COEFF89, 0x00adff66}, | ||
3161 | {16000000, DIF_BPF_COEFF1011, 0xff790198}, | ||
3162 | {16000000, DIF_BPF_COEFF1213, 0xff26fe6e}, | ||
3163 | {16000000, DIF_BPF_COEFF1415, 0x02e5ff55}, | ||
3164 | {16000000, DIF_BPF_COEFF1617, 0xfc99044a}, | ||
3165 | {16000000, DIF_BPF_COEFF1819, 0x005bfa09}, | ||
3166 | {16000000, DIF_BPF_COEFF2021, 0x0545027f}, | ||
3167 | {16000000, DIF_BPF_COEFF2223, 0xf7230541}, | ||
3168 | {16000000, DIF_BPF_COEFF2425, 0x05b8f490}, | ||
3169 | {16000000, DIF_BPF_COEFF2627, 0x03d20997}, | ||
3170 | {16000000, DIF_BPF_COEFF2829, 0xf31300eb}, | ||
3171 | {16000000, DIF_BPF_COEFF3031, 0x0d55f341}, | ||
3172 | {16000000, DIF_BPF_COEFF3233, 0xfcf6100e}, | ||
3173 | {16000000, DIF_BPF_COEFF3435, 0xf544f8c3}, | ||
3174 | {16000000, DIF_BPF_COEFF36, 0x110d0000}, | ||
3175 | /* END - DIF BPF register values from 160_quant.dat*/ | ||
3176 | }; | ||
3177 | |||
3178 | #endif | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c new file mode 100644 index 000000000000..7c4e360ba9bc --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c | |||
@@ -0,0 +1,796 @@ | |||
1 | /* | ||
2 | DVB device driver for cx231xx | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on em28xx driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/usb.h> | ||
25 | |||
26 | #include "cx231xx.h" | ||
27 | #include <media/v4l2-common.h> | ||
28 | #include <media/videobuf-vmalloc.h> | ||
29 | |||
30 | #include "xc5000.h" | ||
31 | #include "s5h1432.h" | ||
32 | #include "tda18271.h" | ||
33 | #include "s5h1411.h" | ||
34 | #include "lgdt3305.h" | ||
35 | #include "mb86a20s.h" | ||
36 | |||
37 | MODULE_DESCRIPTION("driver for cx231xx based DVB cards"); | ||
38 | MODULE_AUTHOR("Srinivasa Deevi <srinivasa.deevi@conexant.com>"); | ||
39 | MODULE_LICENSE("GPL"); | ||
40 | |||
41 | static unsigned int debug; | ||
42 | module_param(debug, int, 0644); | ||
43 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | ||
44 | |||
45 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
46 | |||
47 | #define dprintk(level, fmt, arg...) do { \ | ||
48 | if (debug >= level) \ | ||
49 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ | ||
50 | } while (0) | ||
51 | |||
52 | #define CX231XX_DVB_NUM_BUFS 5 | ||
53 | #define CX231XX_DVB_MAX_PACKETSIZE 564 | ||
54 | #define CX231XX_DVB_MAX_PACKETS 64 | ||
55 | |||
56 | struct cx231xx_dvb { | ||
57 | struct dvb_frontend *frontend; | ||
58 | |||
59 | /* feed count management */ | ||
60 | struct mutex lock; | ||
61 | int nfeeds; | ||
62 | |||
63 | /* general boilerplate stuff */ | ||
64 | struct dvb_adapter adapter; | ||
65 | struct dvb_demux demux; | ||
66 | struct dmxdev dmxdev; | ||
67 | struct dmx_frontend fe_hw; | ||
68 | struct dmx_frontend fe_mem; | ||
69 | struct dvb_net net; | ||
70 | }; | ||
71 | |||
72 | static struct s5h1432_config dvico_s5h1432_config = { | ||
73 | .output_mode = S5H1432_SERIAL_OUTPUT, | ||
74 | .gpio = S5H1432_GPIO_ON, | ||
75 | .qam_if = S5H1432_IF_4000, | ||
76 | .vsb_if = S5H1432_IF_4000, | ||
77 | .inversion = S5H1432_INVERSION_OFF, | ||
78 | .status_mode = S5H1432_DEMODLOCKING, | ||
79 | .mpeg_timing = S5H1432_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | ||
80 | }; | ||
81 | |||
82 | static struct tda18271_std_map cnxt_rde253s_tda18271_std_map = { | ||
83 | .dvbt_6 = { .if_freq = 4000, .agc_mode = 3, .std = 4, | ||
84 | .if_lvl = 1, .rfagc_top = 0x37, }, | ||
85 | .dvbt_7 = { .if_freq = 4000, .agc_mode = 3, .std = 5, | ||
86 | .if_lvl = 1, .rfagc_top = 0x37, }, | ||
87 | .dvbt_8 = { .if_freq = 4000, .agc_mode = 3, .std = 6, | ||
88 | .if_lvl = 1, .rfagc_top = 0x37, }, | ||
89 | }; | ||
90 | |||
91 | static struct tda18271_std_map mb86a20s_tda18271_config = { | ||
92 | .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4, | ||
93 | .if_lvl = 7, .rfagc_top = 0x37, }, | ||
94 | }; | ||
95 | |||
96 | static struct tda18271_config cnxt_rde253s_tunerconfig = { | ||
97 | .std_map = &cnxt_rde253s_tda18271_std_map, | ||
98 | .gate = TDA18271_GATE_ANALOG, | ||
99 | }; | ||
100 | |||
101 | static struct s5h1411_config tda18271_s5h1411_config = { | ||
102 | .output_mode = S5H1411_SERIAL_OUTPUT, | ||
103 | .gpio = S5H1411_GPIO_OFF, | ||
104 | .vsb_if = S5H1411_IF_3250, | ||
105 | .qam_if = S5H1411_IF_4000, | ||
106 | .inversion = S5H1411_INVERSION_ON, | ||
107 | .status_mode = S5H1411_DEMODLOCKING, | ||
108 | .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | ||
109 | }; | ||
110 | static struct s5h1411_config xc5000_s5h1411_config = { | ||
111 | .output_mode = S5H1411_SERIAL_OUTPUT, | ||
112 | .gpio = S5H1411_GPIO_OFF, | ||
113 | .vsb_if = S5H1411_IF_3250, | ||
114 | .qam_if = S5H1411_IF_3250, | ||
115 | .inversion = S5H1411_INVERSION_OFF, | ||
116 | .status_mode = S5H1411_DEMODLOCKING, | ||
117 | .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | ||
118 | }; | ||
119 | |||
120 | static struct lgdt3305_config hcw_lgdt3305_config = { | ||
121 | .i2c_addr = 0x0e, | ||
122 | .mpeg_mode = LGDT3305_MPEG_SERIAL, | ||
123 | .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE, | ||
124 | .tpvalid_polarity = LGDT3305_TP_VALID_HIGH, | ||
125 | .deny_i2c_rptr = 1, | ||
126 | .spectral_inversion = 1, | ||
127 | .qam_if_khz = 4000, | ||
128 | .vsb_if_khz = 3250, | ||
129 | }; | ||
130 | |||
131 | static struct tda18271_std_map hauppauge_tda18271_std_map = { | ||
132 | .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4, | ||
133 | .if_lvl = 1, .rfagc_top = 0x58, }, | ||
134 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5, | ||
135 | .if_lvl = 1, .rfagc_top = 0x58, }, | ||
136 | }; | ||
137 | |||
138 | static struct tda18271_config hcw_tda18271_config = { | ||
139 | .std_map = &hauppauge_tda18271_std_map, | ||
140 | .gate = TDA18271_GATE_DIGITAL, | ||
141 | }; | ||
142 | |||
143 | static const struct mb86a20s_config pv_mb86a20s_config = { | ||
144 | .demod_address = 0x10, | ||
145 | .is_serial = true, | ||
146 | }; | ||
147 | |||
148 | static struct tda18271_config pv_tda18271_config = { | ||
149 | .std_map = &mb86a20s_tda18271_config, | ||
150 | .gate = TDA18271_GATE_DIGITAL, | ||
151 | .small_i2c = TDA18271_03_BYTE_CHUNK_INIT, | ||
152 | }; | ||
153 | |||
154 | static inline void print_err_status(struct cx231xx *dev, int packet, int status) | ||
155 | { | ||
156 | char *errmsg = "Unknown"; | ||
157 | |||
158 | switch (status) { | ||
159 | case -ENOENT: | ||
160 | errmsg = "unlinked synchronuously"; | ||
161 | break; | ||
162 | case -ECONNRESET: | ||
163 | errmsg = "unlinked asynchronuously"; | ||
164 | break; | ||
165 | case -ENOSR: | ||
166 | errmsg = "Buffer error (overrun)"; | ||
167 | break; | ||
168 | case -EPIPE: | ||
169 | errmsg = "Stalled (device not responding)"; | ||
170 | break; | ||
171 | case -EOVERFLOW: | ||
172 | errmsg = "Babble (bad cable?)"; | ||
173 | break; | ||
174 | case -EPROTO: | ||
175 | errmsg = "Bit-stuff error (bad cable?)"; | ||
176 | break; | ||
177 | case -EILSEQ: | ||
178 | errmsg = "CRC/Timeout (could be anything)"; | ||
179 | break; | ||
180 | case -ETIME: | ||
181 | errmsg = "Device does not respond"; | ||
182 | break; | ||
183 | } | ||
184 | if (packet < 0) { | ||
185 | dprintk(1, "URB status %d [%s].\n", status, errmsg); | ||
186 | } else { | ||
187 | dprintk(1, "URB packet %d, status %d [%s].\n", | ||
188 | packet, status, errmsg); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | static inline int dvb_isoc_copy(struct cx231xx *dev, struct urb *urb) | ||
193 | { | ||
194 | int i; | ||
195 | |||
196 | if (!dev) | ||
197 | return 0; | ||
198 | |||
199 | if (dev->state & DEV_DISCONNECTED) | ||
200 | return 0; | ||
201 | |||
202 | if (urb->status < 0) { | ||
203 | print_err_status(dev, -1, urb->status); | ||
204 | if (urb->status == -ENOENT) | ||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | for (i = 0; i < urb->number_of_packets; i++) { | ||
209 | int status = urb->iso_frame_desc[i].status; | ||
210 | |||
211 | if (status < 0) { | ||
212 | print_err_status(dev, i, status); | ||
213 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
214 | continue; | ||
215 | } | ||
216 | |||
217 | dvb_dmx_swfilter(&dev->dvb->demux, | ||
218 | urb->transfer_buffer + | ||
219 | urb->iso_frame_desc[i].offset, | ||
220 | urb->iso_frame_desc[i].actual_length); | ||
221 | } | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static inline int dvb_bulk_copy(struct cx231xx *dev, struct urb *urb) | ||
227 | { | ||
228 | if (!dev) | ||
229 | return 0; | ||
230 | |||
231 | if (dev->state & DEV_DISCONNECTED) | ||
232 | return 0; | ||
233 | |||
234 | if (urb->status < 0) { | ||
235 | print_err_status(dev, -1, urb->status); | ||
236 | if (urb->status == -ENOENT) | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | /* Feed the transport payload into the kernel demux */ | ||
241 | dvb_dmx_swfilter(&dev->dvb->demux, | ||
242 | urb->transfer_buffer, urb->actual_length); | ||
243 | |||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static int start_streaming(struct cx231xx_dvb *dvb) | ||
248 | { | ||
249 | int rc; | ||
250 | struct cx231xx *dev = dvb->adapter.priv; | ||
251 | |||
252 | if (dev->USE_ISO) { | ||
253 | cx231xx_info("DVB transfer mode is ISO.\n"); | ||
254 | mutex_lock(&dev->i2c_lock); | ||
255 | cx231xx_enable_i2c_port_3(dev, false); | ||
256 | cx231xx_set_alt_setting(dev, INDEX_TS1, 4); | ||
257 | cx231xx_enable_i2c_port_3(dev, true); | ||
258 | mutex_unlock(&dev->i2c_lock); | ||
259 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
260 | if (rc < 0) | ||
261 | return rc; | ||
262 | dev->mode_tv = 1; | ||
263 | return cx231xx_init_isoc(dev, CX231XX_DVB_MAX_PACKETS, | ||
264 | CX231XX_DVB_NUM_BUFS, | ||
265 | dev->ts1_mode.max_pkt_size, | ||
266 | dvb_isoc_copy); | ||
267 | } else { | ||
268 | cx231xx_info("DVB transfer mode is BULK.\n"); | ||
269 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); | ||
270 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
271 | if (rc < 0) | ||
272 | return rc; | ||
273 | dev->mode_tv = 1; | ||
274 | return cx231xx_init_bulk(dev, CX231XX_DVB_MAX_PACKETS, | ||
275 | CX231XX_DVB_NUM_BUFS, | ||
276 | dev->ts1_mode.max_pkt_size, | ||
277 | dvb_bulk_copy); | ||
278 | } | ||
279 | |||
280 | } | ||
281 | |||
282 | static int stop_streaming(struct cx231xx_dvb *dvb) | ||
283 | { | ||
284 | struct cx231xx *dev = dvb->adapter.priv; | ||
285 | |||
286 | if (dev->USE_ISO) | ||
287 | cx231xx_uninit_isoc(dev); | ||
288 | else | ||
289 | cx231xx_uninit_bulk(dev); | ||
290 | |||
291 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
292 | |||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | static int start_feed(struct dvb_demux_feed *feed) | ||
297 | { | ||
298 | struct dvb_demux *demux = feed->demux; | ||
299 | struct cx231xx_dvb *dvb = demux->priv; | ||
300 | int rc, ret; | ||
301 | |||
302 | if (!demux->dmx.frontend) | ||
303 | return -EINVAL; | ||
304 | |||
305 | mutex_lock(&dvb->lock); | ||
306 | dvb->nfeeds++; | ||
307 | rc = dvb->nfeeds; | ||
308 | |||
309 | if (dvb->nfeeds == 1) { | ||
310 | ret = start_streaming(dvb); | ||
311 | if (ret < 0) | ||
312 | rc = ret; | ||
313 | } | ||
314 | |||
315 | mutex_unlock(&dvb->lock); | ||
316 | return rc; | ||
317 | } | ||
318 | |||
319 | static int stop_feed(struct dvb_demux_feed *feed) | ||
320 | { | ||
321 | struct dvb_demux *demux = feed->demux; | ||
322 | struct cx231xx_dvb *dvb = demux->priv; | ||
323 | int err = 0; | ||
324 | |||
325 | mutex_lock(&dvb->lock); | ||
326 | dvb->nfeeds--; | ||
327 | |||
328 | if (0 == dvb->nfeeds) | ||
329 | err = stop_streaming(dvb); | ||
330 | |||
331 | mutex_unlock(&dvb->lock); | ||
332 | return err; | ||
333 | } | ||
334 | |||
335 | /* ------------------------------------------------------------------ */ | ||
336 | static int cx231xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) | ||
337 | { | ||
338 | struct cx231xx *dev = fe->dvb->priv; | ||
339 | |||
340 | if (acquire) | ||
341 | return cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
342 | else | ||
343 | return cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
344 | } | ||
345 | |||
346 | /* ------------------------------------------------------------------ */ | ||
347 | |||
348 | static struct xc5000_config cnxt_rde250_tunerconfig = { | ||
349 | .i2c_address = 0x61, | ||
350 | .if_khz = 4000, | ||
351 | }; | ||
352 | static struct xc5000_config cnxt_rdu250_tunerconfig = { | ||
353 | .i2c_address = 0x61, | ||
354 | .if_khz = 3250, | ||
355 | }; | ||
356 | |||
357 | /* ------------------------------------------------------------------ */ | ||
358 | #if 0 | ||
359 | static int attach_xc5000(u8 addr, struct cx231xx *dev) | ||
360 | { | ||
361 | |||
362 | struct dvb_frontend *fe; | ||
363 | struct xc5000_config cfg; | ||
364 | |||
365 | memset(&cfg, 0, sizeof(cfg)); | ||
366 | cfg.i2c_adap = &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap; | ||
367 | cfg.i2c_addr = addr; | ||
368 | |||
369 | if (!dev->dvb->frontend) { | ||
370 | printk(KERN_ERR "%s/2: dvb frontend not attached. " | ||
371 | "Can't attach xc5000\n", dev->name); | ||
372 | return -EINVAL; | ||
373 | } | ||
374 | |||
375 | fe = dvb_attach(xc5000_attach, dev->dvb->frontend, &cfg); | ||
376 | if (!fe) { | ||
377 | printk(KERN_ERR "%s/2: xc5000 attach failed\n", dev->name); | ||
378 | dvb_frontend_detach(dev->dvb->frontend); | ||
379 | dev->dvb->frontend = NULL; | ||
380 | return -EINVAL; | ||
381 | } | ||
382 | |||
383 | printk(KERN_INFO "%s/2: xc5000 attached\n", dev->name); | ||
384 | |||
385 | return 0; | ||
386 | } | ||
387 | #endif | ||
388 | |||
389 | int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq) | ||
390 | { | ||
391 | int status = 0; | ||
392 | |||
393 | if ((dev->dvb != NULL) && (dev->dvb->frontend != NULL)) { | ||
394 | |||
395 | struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops; | ||
396 | |||
397 | if (dops->set_analog_params != NULL) { | ||
398 | struct analog_parameters params; | ||
399 | |||
400 | params.frequency = freq; | ||
401 | params.std = dev->norm; | ||
402 | params.mode = 0; /* 0- Air; 1 - cable */ | ||
403 | /*params.audmode = ; */ | ||
404 | |||
405 | /* Set the analog parameters to set the frequency */ | ||
406 | dops->set_analog_params(dev->dvb->frontend, ¶ms); | ||
407 | } | ||
408 | |||
409 | } | ||
410 | |||
411 | return status; | ||
412 | } | ||
413 | |||
414 | int cx231xx_reset_analog_tuner(struct cx231xx *dev) | ||
415 | { | ||
416 | int status = 0; | ||
417 | |||
418 | if ((dev->dvb != NULL) && (dev->dvb->frontend != NULL)) { | ||
419 | |||
420 | struct dvb_tuner_ops *dops = &dev->dvb->frontend->ops.tuner_ops; | ||
421 | |||
422 | if (dops->init != NULL && !dev->xc_fw_load_done) { | ||
423 | |||
424 | cx231xx_info("Reloading firmware for XC5000\n"); | ||
425 | status = dops->init(dev->dvb->frontend); | ||
426 | if (status == 0) { | ||
427 | dev->xc_fw_load_done = 1; | ||
428 | cx231xx_info | ||
429 | ("XC5000 firmware download completed\n"); | ||
430 | } else { | ||
431 | dev->xc_fw_load_done = 0; | ||
432 | cx231xx_info | ||
433 | ("XC5000 firmware download failed !!!\n"); | ||
434 | } | ||
435 | } | ||
436 | |||
437 | } | ||
438 | |||
439 | return status; | ||
440 | } | ||
441 | |||
442 | /* ------------------------------------------------------------------ */ | ||
443 | |||
444 | static int register_dvb(struct cx231xx_dvb *dvb, | ||
445 | struct module *module, | ||
446 | struct cx231xx *dev, struct device *device) | ||
447 | { | ||
448 | int result; | ||
449 | |||
450 | mutex_init(&dvb->lock); | ||
451 | |||
452 | /* register adapter */ | ||
453 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, | ||
454 | adapter_nr); | ||
455 | if (result < 0) { | ||
456 | printk(KERN_WARNING | ||
457 | "%s: dvb_register_adapter failed (errno = %d)\n", | ||
458 | dev->name, result); | ||
459 | goto fail_adapter; | ||
460 | } | ||
461 | |||
462 | /* Ensure all frontends negotiate bus access */ | ||
463 | dvb->frontend->ops.ts_bus_ctrl = cx231xx_dvb_bus_ctrl; | ||
464 | |||
465 | dvb->adapter.priv = dev; | ||
466 | |||
467 | /* register frontend */ | ||
468 | result = dvb_register_frontend(&dvb->adapter, dvb->frontend); | ||
469 | if (result < 0) { | ||
470 | printk(KERN_WARNING | ||
471 | "%s: dvb_register_frontend failed (errno = %d)\n", | ||
472 | dev->name, result); | ||
473 | goto fail_frontend; | ||
474 | } | ||
475 | |||
476 | /* register demux stuff */ | ||
477 | dvb->demux.dmx.capabilities = | ||
478 | DMX_TS_FILTERING | DMX_SECTION_FILTERING | | ||
479 | DMX_MEMORY_BASED_FILTERING; | ||
480 | dvb->demux.priv = dvb; | ||
481 | dvb->demux.filternum = 256; | ||
482 | dvb->demux.feednum = 256; | ||
483 | dvb->demux.start_feed = start_feed; | ||
484 | dvb->demux.stop_feed = stop_feed; | ||
485 | |||
486 | result = dvb_dmx_init(&dvb->demux); | ||
487 | if (result < 0) { | ||
488 | printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", | ||
489 | dev->name, result); | ||
490 | goto fail_dmx; | ||
491 | } | ||
492 | |||
493 | dvb->dmxdev.filternum = 256; | ||
494 | dvb->dmxdev.demux = &dvb->demux.dmx; | ||
495 | dvb->dmxdev.capabilities = 0; | ||
496 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); | ||
497 | if (result < 0) { | ||
498 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", | ||
499 | dev->name, result); | ||
500 | goto fail_dmxdev; | ||
501 | } | ||
502 | |||
503 | dvb->fe_hw.source = DMX_FRONTEND_0; | ||
504 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
505 | if (result < 0) { | ||
506 | printk(KERN_WARNING | ||
507 | "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", | ||
508 | dev->name, result); | ||
509 | goto fail_fe_hw; | ||
510 | } | ||
511 | |||
512 | dvb->fe_mem.source = DMX_MEMORY_FE; | ||
513 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
514 | if (result < 0) { | ||
515 | printk(KERN_WARNING | ||
516 | "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", | ||
517 | dev->name, result); | ||
518 | goto fail_fe_mem; | ||
519 | } | ||
520 | |||
521 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
522 | if (result < 0) { | ||
523 | printk(KERN_WARNING | ||
524 | "%s: connect_frontend failed (errno = %d)\n", dev->name, | ||
525 | result); | ||
526 | goto fail_fe_conn; | ||
527 | } | ||
528 | |||
529 | /* register network adapter */ | ||
530 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); | ||
531 | return 0; | ||
532 | |||
533 | fail_fe_conn: | ||
534 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
535 | fail_fe_mem: | ||
536 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
537 | fail_fe_hw: | ||
538 | dvb_dmxdev_release(&dvb->dmxdev); | ||
539 | fail_dmxdev: | ||
540 | dvb_dmx_release(&dvb->demux); | ||
541 | fail_dmx: | ||
542 | dvb_unregister_frontend(dvb->frontend); | ||
543 | fail_frontend: | ||
544 | dvb_frontend_detach(dvb->frontend); | ||
545 | dvb_unregister_adapter(&dvb->adapter); | ||
546 | fail_adapter: | ||
547 | return result; | ||
548 | } | ||
549 | |||
550 | static void unregister_dvb(struct cx231xx_dvb *dvb) | ||
551 | { | ||
552 | dvb_net_release(&dvb->net); | ||
553 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
554 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
555 | dvb_dmxdev_release(&dvb->dmxdev); | ||
556 | dvb_dmx_release(&dvb->demux); | ||
557 | dvb_unregister_frontend(dvb->frontend); | ||
558 | dvb_frontend_detach(dvb->frontend); | ||
559 | dvb_unregister_adapter(&dvb->adapter); | ||
560 | } | ||
561 | |||
562 | static int dvb_init(struct cx231xx *dev) | ||
563 | { | ||
564 | int result = 0; | ||
565 | struct cx231xx_dvb *dvb; | ||
566 | |||
567 | if (!dev->board.has_dvb) { | ||
568 | /* This device does not support the extension */ | ||
569 | return 0; | ||
570 | } | ||
571 | |||
572 | dvb = kzalloc(sizeof(struct cx231xx_dvb), GFP_KERNEL); | ||
573 | |||
574 | if (dvb == NULL) { | ||
575 | printk(KERN_INFO "cx231xx_dvb: memory allocation failed\n"); | ||
576 | return -ENOMEM; | ||
577 | } | ||
578 | dev->dvb = dvb; | ||
579 | dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq; | ||
580 | dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner; | ||
581 | |||
582 | mutex_lock(&dev->lock); | ||
583 | cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | ||
584 | cx231xx_demod_reset(dev); | ||
585 | /* init frontend */ | ||
586 | switch (dev->model) { | ||
587 | case CX231XX_BOARD_CNXT_CARRAERA: | ||
588 | case CX231XX_BOARD_CNXT_RDE_250: | ||
589 | |||
590 | dev->dvb->frontend = dvb_attach(s5h1432_attach, | ||
591 | &dvico_s5h1432_config, | ||
592 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | ||
593 | |||
594 | if (dev->dvb->frontend == NULL) { | ||
595 | printk(DRIVER_NAME | ||
596 | ": Failed to attach s5h1432 front end\n"); | ||
597 | result = -EINVAL; | ||
598 | goto out_free; | ||
599 | } | ||
600 | |||
601 | /* define general-purpose callback pointer */ | ||
602 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
603 | |||
604 | if (!dvb_attach(xc5000_attach, dev->dvb->frontend, | ||
605 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | ||
606 | &cnxt_rde250_tunerconfig)) { | ||
607 | result = -EINVAL; | ||
608 | goto out_free; | ||
609 | } | ||
610 | |||
611 | break; | ||
612 | case CX231XX_BOARD_CNXT_SHELBY: | ||
613 | case CX231XX_BOARD_CNXT_RDU_250: | ||
614 | |||
615 | dev->dvb->frontend = dvb_attach(s5h1411_attach, | ||
616 | &xc5000_s5h1411_config, | ||
617 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | ||
618 | |||
619 | if (dev->dvb->frontend == NULL) { | ||
620 | printk(DRIVER_NAME | ||
621 | ": Failed to attach s5h1411 front end\n"); | ||
622 | result = -EINVAL; | ||
623 | goto out_free; | ||
624 | } | ||
625 | |||
626 | /* define general-purpose callback pointer */ | ||
627 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
628 | |||
629 | if (!dvb_attach(xc5000_attach, dev->dvb->frontend, | ||
630 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | ||
631 | &cnxt_rdu250_tunerconfig)) { | ||
632 | result = -EINVAL; | ||
633 | goto out_free; | ||
634 | } | ||
635 | break; | ||
636 | case CX231XX_BOARD_CNXT_RDE_253S: | ||
637 | |||
638 | dev->dvb->frontend = dvb_attach(s5h1432_attach, | ||
639 | &dvico_s5h1432_config, | ||
640 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | ||
641 | |||
642 | if (dev->dvb->frontend == NULL) { | ||
643 | printk(DRIVER_NAME | ||
644 | ": Failed to attach s5h1432 front end\n"); | ||
645 | result = -EINVAL; | ||
646 | goto out_free; | ||
647 | } | ||
648 | |||
649 | /* define general-purpose callback pointer */ | ||
650 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
651 | |||
652 | if (!dvb_attach(tda18271_attach, dev->dvb->frontend, | ||
653 | 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | ||
654 | &cnxt_rde253s_tunerconfig)) { | ||
655 | result = -EINVAL; | ||
656 | goto out_free; | ||
657 | } | ||
658 | break; | ||
659 | case CX231XX_BOARD_CNXT_RDU_253S: | ||
660 | |||
661 | dev->dvb->frontend = dvb_attach(s5h1411_attach, | ||
662 | &tda18271_s5h1411_config, | ||
663 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | ||
664 | |||
665 | if (dev->dvb->frontend == NULL) { | ||
666 | printk(DRIVER_NAME | ||
667 | ": Failed to attach s5h1411 front end\n"); | ||
668 | result = -EINVAL; | ||
669 | goto out_free; | ||
670 | } | ||
671 | |||
672 | /* define general-purpose callback pointer */ | ||
673 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
674 | |||
675 | if (!dvb_attach(tda18271_attach, dev->dvb->frontend, | ||
676 | 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | ||
677 | &cnxt_rde253s_tunerconfig)) { | ||
678 | result = -EINVAL; | ||
679 | goto out_free; | ||
680 | } | ||
681 | break; | ||
682 | case CX231XX_BOARD_HAUPPAUGE_EXETER: | ||
683 | |||
684 | printk(KERN_INFO "%s: looking for tuner / demod on i2c bus: %d\n", | ||
685 | __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap)); | ||
686 | |||
687 | dev->dvb->frontend = dvb_attach(lgdt3305_attach, | ||
688 | &hcw_lgdt3305_config, | ||
689 | &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap); | ||
690 | |||
691 | if (dev->dvb->frontend == NULL) { | ||
692 | printk(DRIVER_NAME | ||
693 | ": Failed to attach LG3305 front end\n"); | ||
694 | result = -EINVAL; | ||
695 | goto out_free; | ||
696 | } | ||
697 | |||
698 | /* define general-purpose callback pointer */ | ||
699 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
700 | |||
701 | dvb_attach(tda18271_attach, dev->dvb->frontend, | ||
702 | 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | ||
703 | &hcw_tda18271_config); | ||
704 | break; | ||
705 | |||
706 | case CX231XX_BOARD_PV_PLAYTV_USB_HYBRID: | ||
707 | case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID: | ||
708 | |||
709 | printk(KERN_INFO "%s: looking for demod on i2c bus: %d\n", | ||
710 | __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap)); | ||
711 | |||
712 | dev->dvb->frontend = dvb_attach(mb86a20s_attach, | ||
713 | &pv_mb86a20s_config, | ||
714 | &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap); | ||
715 | |||
716 | if (dev->dvb->frontend == NULL) { | ||
717 | printk(DRIVER_NAME | ||
718 | ": Failed to attach mb86a20s demod\n"); | ||
719 | result = -EINVAL; | ||
720 | goto out_free; | ||
721 | } | ||
722 | |||
723 | /* define general-purpose callback pointer */ | ||
724 | dvb->frontend->callback = cx231xx_tuner_callback; | ||
725 | |||
726 | dvb_attach(tda18271_attach, dev->dvb->frontend, | ||
727 | 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap, | ||
728 | &pv_tda18271_config); | ||
729 | break; | ||
730 | |||
731 | default: | ||
732 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" | ||
733 | " isn't supported yet\n", dev->name); | ||
734 | break; | ||
735 | } | ||
736 | if (NULL == dvb->frontend) { | ||
737 | printk(KERN_ERR | ||
738 | "%s/2: frontend initialization failed\n", dev->name); | ||
739 | result = -EINVAL; | ||
740 | goto out_free; | ||
741 | } | ||
742 | |||
743 | /* register everything */ | ||
744 | result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); | ||
745 | |||
746 | if (result < 0) | ||
747 | goto out_free; | ||
748 | |||
749 | |||
750 | printk(KERN_INFO "Successfully loaded cx231xx-dvb\n"); | ||
751 | |||
752 | ret: | ||
753 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
754 | mutex_unlock(&dev->lock); | ||
755 | return result; | ||
756 | |||
757 | out_free: | ||
758 | kfree(dvb); | ||
759 | dev->dvb = NULL; | ||
760 | goto ret; | ||
761 | } | ||
762 | |||
763 | static int dvb_fini(struct cx231xx *dev) | ||
764 | { | ||
765 | if (!dev->board.has_dvb) { | ||
766 | /* This device does not support the extension */ | ||
767 | return 0; | ||
768 | } | ||
769 | |||
770 | if (dev->dvb) { | ||
771 | unregister_dvb(dev->dvb); | ||
772 | dev->dvb = NULL; | ||
773 | } | ||
774 | |||
775 | return 0; | ||
776 | } | ||
777 | |||
778 | static struct cx231xx_ops dvb_ops = { | ||
779 | .id = CX231XX_DVB, | ||
780 | .name = "Cx231xx dvb Extension", | ||
781 | .init = dvb_init, | ||
782 | .fini = dvb_fini, | ||
783 | }; | ||
784 | |||
785 | static int __init cx231xx_dvb_register(void) | ||
786 | { | ||
787 | return cx231xx_register_extension(&dvb_ops); | ||
788 | } | ||
789 | |||
790 | static void __exit cx231xx_dvb_unregister(void) | ||
791 | { | ||
792 | cx231xx_unregister_extension(&dvb_ops); | ||
793 | } | ||
794 | |||
795 | module_init(cx231xx_dvb_register); | ||
796 | module_exit(cx231xx_dvb_unregister); | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c new file mode 100644 index 000000000000..781feed406f7 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c | |||
@@ -0,0 +1,532 @@ | |||
1 | /* | ||
2 | cx231xx-i2c.c - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on em28xx driver | ||
6 | Based on Cx23885 driver | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/usb.h> | ||
26 | #include <linux/i2c.h> | ||
27 | #include <media/v4l2-common.h> | ||
28 | #include <media/tuner.h> | ||
29 | |||
30 | #include "cx231xx.h" | ||
31 | |||
32 | /* ----------------------------------------------------------- */ | ||
33 | |||
34 | static unsigned int i2c_scan; | ||
35 | module_param(i2c_scan, int, 0444); | ||
36 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); | ||
37 | |||
38 | static unsigned int i2c_debug; | ||
39 | module_param(i2c_debug, int, 0644); | ||
40 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | ||
41 | |||
42 | #define dprintk1(lvl, fmt, args...) \ | ||
43 | do { \ | ||
44 | if (i2c_debug >= lvl) { \ | ||
45 | printk(fmt, ##args); \ | ||
46 | } \ | ||
47 | } while (0) | ||
48 | |||
49 | #define dprintk2(lvl, fmt, args...) \ | ||
50 | do { \ | ||
51 | if (i2c_debug >= lvl) { \ | ||
52 | printk(KERN_DEBUG "%s at %s: " fmt, \ | ||
53 | dev->name, __func__ , ##args); \ | ||
54 | } \ | ||
55 | } while (0) | ||
56 | |||
57 | static inline bool is_tuner(struct cx231xx *dev, struct cx231xx_i2c *bus, | ||
58 | const struct i2c_msg *msg, int tuner_type) | ||
59 | { | ||
60 | if (bus->nr != dev->board.tuner_i2c_master) | ||
61 | return false; | ||
62 | |||
63 | if (msg->addr != dev->board.tuner_addr) | ||
64 | return false; | ||
65 | |||
66 | if (dev->tuner_type != tuner_type) | ||
67 | return false; | ||
68 | |||
69 | return true; | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | * cx231xx_i2c_send_bytes() | ||
74 | */ | ||
75 | int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, | ||
76 | const struct i2c_msg *msg) | ||
77 | { | ||
78 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
79 | struct cx231xx *dev = bus->dev; | ||
80 | struct cx231xx_i2c_xfer_data req_data; | ||
81 | int status = 0; | ||
82 | u16 size = 0; | ||
83 | u8 loop = 0; | ||
84 | u8 saddr_len = 1; | ||
85 | u8 *buf_ptr = NULL; | ||
86 | u16 saddr = 0; | ||
87 | u8 need_gpio = 0; | ||
88 | |||
89 | if (is_tuner(dev, bus, msg, TUNER_XC5000)) { | ||
90 | size = msg->len; | ||
91 | |||
92 | if (size == 2) { /* register write sub addr */ | ||
93 | /* Just writing sub address will cause problem | ||
94 | * to XC5000. So ignore the request */ | ||
95 | return 0; | ||
96 | } else if (size == 4) { /* register write with sub addr */ | ||
97 | if (msg->len >= 2) | ||
98 | saddr = msg->buf[0] << 8 | msg->buf[1]; | ||
99 | else if (msg->len == 1) | ||
100 | saddr = msg->buf[0]; | ||
101 | |||
102 | switch (saddr) { | ||
103 | case 0x0000: /* start tuner calibration mode */ | ||
104 | need_gpio = 1; | ||
105 | /* FW Loading is done */ | ||
106 | dev->xc_fw_load_done = 1; | ||
107 | break; | ||
108 | case 0x000D: /* Set signal source */ | ||
109 | case 0x0001: /* Set TV standard - Video */ | ||
110 | case 0x0002: /* Set TV standard - Audio */ | ||
111 | case 0x0003: /* Set RF Frequency */ | ||
112 | need_gpio = 1; | ||
113 | break; | ||
114 | default: | ||
115 | if (dev->xc_fw_load_done) | ||
116 | need_gpio = 1; | ||
117 | break; | ||
118 | } | ||
119 | |||
120 | if (need_gpio) { | ||
121 | dprintk1(1, | ||
122 | "GPIO WRITE: addr 0x%x, len %d, saddr 0x%x\n", | ||
123 | msg->addr, msg->len, saddr); | ||
124 | |||
125 | return dev->cx231xx_gpio_i2c_write(dev, | ||
126 | msg->addr, | ||
127 | msg->buf, | ||
128 | msg->len); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /* special case for Xc5000 tuner case */ | ||
133 | saddr_len = 1; | ||
134 | |||
135 | /* adjust the length to correct length */ | ||
136 | size -= saddr_len; | ||
137 | buf_ptr = (u8 *) (msg->buf + 1); | ||
138 | |||
139 | do { | ||
140 | /* prepare xfer_data struct */ | ||
141 | req_data.dev_addr = msg->addr; | ||
142 | req_data.direction = msg->flags; | ||
143 | req_data.saddr_len = saddr_len; | ||
144 | req_data.saddr_dat = msg->buf[0]; | ||
145 | req_data.buf_size = size > 16 ? 16 : size; | ||
146 | req_data.p_buffer = (u8 *) (buf_ptr + loop * 16); | ||
147 | |||
148 | bus->i2c_nostop = (size > 16) ? 1 : 0; | ||
149 | bus->i2c_reserve = (loop == 0) ? 0 : 1; | ||
150 | |||
151 | /* usb send command */ | ||
152 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
153 | loop++; | ||
154 | |||
155 | if (size >= 16) | ||
156 | size -= 16; | ||
157 | else | ||
158 | size = 0; | ||
159 | |||
160 | } while (size > 0); | ||
161 | |||
162 | bus->i2c_nostop = 0; | ||
163 | bus->i2c_reserve = 0; | ||
164 | |||
165 | } else { /* regular case */ | ||
166 | |||
167 | /* prepare xfer_data struct */ | ||
168 | req_data.dev_addr = msg->addr; | ||
169 | req_data.direction = msg->flags; | ||
170 | req_data.saddr_len = 0; | ||
171 | req_data.saddr_dat = 0; | ||
172 | req_data.buf_size = msg->len; | ||
173 | req_data.p_buffer = msg->buf; | ||
174 | |||
175 | /* usb send command */ | ||
176 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
177 | } | ||
178 | |||
179 | return status < 0 ? status : 0; | ||
180 | } | ||
181 | |||
182 | /* | ||
183 | * cx231xx_i2c_recv_bytes() | ||
184 | * read a byte from the i2c device | ||
185 | */ | ||
186 | static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap, | ||
187 | const struct i2c_msg *msg) | ||
188 | { | ||
189 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
190 | struct cx231xx *dev = bus->dev; | ||
191 | struct cx231xx_i2c_xfer_data req_data; | ||
192 | int status = 0; | ||
193 | u16 saddr = 0; | ||
194 | u8 need_gpio = 0; | ||
195 | |||
196 | if (is_tuner(dev, bus, msg, TUNER_XC5000)) { | ||
197 | if (msg->len == 2) | ||
198 | saddr = msg->buf[0] << 8 | msg->buf[1]; | ||
199 | else if (msg->len == 1) | ||
200 | saddr = msg->buf[0]; | ||
201 | |||
202 | if (dev->xc_fw_load_done) { | ||
203 | |||
204 | switch (saddr) { | ||
205 | case 0x0009: /* BUSY check */ | ||
206 | dprintk1(1, | ||
207 | "GPIO R E A D: Special case BUSY check \n"); | ||
208 | /*Try read BUSY register, just set it to zero*/ | ||
209 | msg->buf[0] = 0; | ||
210 | if (msg->len == 2) | ||
211 | msg->buf[1] = 0; | ||
212 | return 0; | ||
213 | case 0x0004: /* read Lock status */ | ||
214 | need_gpio = 1; | ||
215 | break; | ||
216 | |||
217 | } | ||
218 | |||
219 | if (need_gpio) { | ||
220 | /* this is a special case to handle Xceive tuner | ||
221 | clock stretch issue with gpio based I2C */ | ||
222 | |||
223 | dprintk1(1, | ||
224 | "GPIO R E A D: addr 0x%x, len %d, saddr 0x%x\n", | ||
225 | msg->addr, msg->len, | ||
226 | msg->buf[0] << 8 | msg->buf[1]); | ||
227 | |||
228 | status = | ||
229 | dev->cx231xx_gpio_i2c_write(dev, msg->addr, | ||
230 | msg->buf, | ||
231 | msg->len); | ||
232 | status = | ||
233 | dev->cx231xx_gpio_i2c_read(dev, msg->addr, | ||
234 | msg->buf, | ||
235 | msg->len); | ||
236 | return status; | ||
237 | } | ||
238 | } | ||
239 | |||
240 | /* prepare xfer_data struct */ | ||
241 | req_data.dev_addr = msg->addr; | ||
242 | req_data.direction = msg->flags; | ||
243 | req_data.saddr_len = msg->len; | ||
244 | req_data.saddr_dat = msg->buf[0] << 8 | msg->buf[1]; | ||
245 | req_data.buf_size = msg->len; | ||
246 | req_data.p_buffer = msg->buf; | ||
247 | |||
248 | /* usb send command */ | ||
249 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
250 | |||
251 | } else { | ||
252 | |||
253 | /* prepare xfer_data struct */ | ||
254 | req_data.dev_addr = msg->addr; | ||
255 | req_data.direction = msg->flags; | ||
256 | req_data.saddr_len = 0; | ||
257 | req_data.saddr_dat = 0; | ||
258 | req_data.buf_size = msg->len; | ||
259 | req_data.p_buffer = msg->buf; | ||
260 | |||
261 | /* usb send command */ | ||
262 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
263 | } | ||
264 | |||
265 | return status < 0 ? status : 0; | ||
266 | } | ||
267 | |||
268 | /* | ||
269 | * cx231xx_i2c_recv_bytes_with_saddr() | ||
270 | * read a byte from the i2c device | ||
271 | */ | ||
272 | static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap, | ||
273 | const struct i2c_msg *msg1, | ||
274 | const struct i2c_msg *msg2) | ||
275 | { | ||
276 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
277 | struct cx231xx *dev = bus->dev; | ||
278 | struct cx231xx_i2c_xfer_data req_data; | ||
279 | int status = 0; | ||
280 | u16 saddr = 0; | ||
281 | u8 need_gpio = 0; | ||
282 | |||
283 | if (msg1->len == 2) | ||
284 | saddr = msg1->buf[0] << 8 | msg1->buf[1]; | ||
285 | else if (msg1->len == 1) | ||
286 | saddr = msg1->buf[0]; | ||
287 | |||
288 | if (is_tuner(dev, bus, msg2, TUNER_XC5000)) { | ||
289 | if ((msg2->len < 16)) { | ||
290 | |||
291 | dprintk1(1, | ||
292 | "i2c_read: addr 0x%x, len %d, saddr 0x%x, len %d\n", | ||
293 | msg2->addr, msg2->len, saddr, msg1->len); | ||
294 | |||
295 | switch (saddr) { | ||
296 | case 0x0008: /* read FW load status */ | ||
297 | need_gpio = 1; | ||
298 | break; | ||
299 | case 0x0004: /* read Lock status */ | ||
300 | need_gpio = 1; | ||
301 | break; | ||
302 | } | ||
303 | |||
304 | if (need_gpio) { | ||
305 | status = | ||
306 | dev->cx231xx_gpio_i2c_write(dev, msg1->addr, | ||
307 | msg1->buf, | ||
308 | msg1->len); | ||
309 | status = | ||
310 | dev->cx231xx_gpio_i2c_read(dev, msg2->addr, | ||
311 | msg2->buf, | ||
312 | msg2->len); | ||
313 | return status; | ||
314 | } | ||
315 | } | ||
316 | } | ||
317 | |||
318 | /* prepare xfer_data struct */ | ||
319 | req_data.dev_addr = msg2->addr; | ||
320 | req_data.direction = msg2->flags; | ||
321 | req_data.saddr_len = msg1->len; | ||
322 | req_data.saddr_dat = saddr; | ||
323 | req_data.buf_size = msg2->len; | ||
324 | req_data.p_buffer = msg2->buf; | ||
325 | |||
326 | /* usb send command */ | ||
327 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
328 | |||
329 | return status < 0 ? status : 0; | ||
330 | } | ||
331 | |||
332 | /* | ||
333 | * cx231xx_i2c_check_for_device() | ||
334 | * check if there is a i2c_device at the supplied address | ||
335 | */ | ||
336 | static int cx231xx_i2c_check_for_device(struct i2c_adapter *i2c_adap, | ||
337 | const struct i2c_msg *msg) | ||
338 | { | ||
339 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
340 | struct cx231xx *dev = bus->dev; | ||
341 | struct cx231xx_i2c_xfer_data req_data; | ||
342 | int status = 0; | ||
343 | |||
344 | /* prepare xfer_data struct */ | ||
345 | req_data.dev_addr = msg->addr; | ||
346 | req_data.direction = msg->flags; | ||
347 | req_data.saddr_len = 0; | ||
348 | req_data.saddr_dat = 0; | ||
349 | req_data.buf_size = 0; | ||
350 | req_data.p_buffer = NULL; | ||
351 | |||
352 | /* usb send command */ | ||
353 | status = dev->cx231xx_send_usb_command(bus, &req_data); | ||
354 | |||
355 | return status < 0 ? status : 0; | ||
356 | } | ||
357 | |||
358 | /* | ||
359 | * cx231xx_i2c_xfer() | ||
360 | * the main i2c transfer function | ||
361 | */ | ||
362 | static int cx231xx_i2c_xfer(struct i2c_adapter *i2c_adap, | ||
363 | struct i2c_msg msgs[], int num) | ||
364 | { | ||
365 | struct cx231xx_i2c *bus = i2c_adap->algo_data; | ||
366 | struct cx231xx *dev = bus->dev; | ||
367 | int addr, rc, i, byte; | ||
368 | |||
369 | if (num <= 0) | ||
370 | return 0; | ||
371 | mutex_lock(&dev->i2c_lock); | ||
372 | for (i = 0; i < num; i++) { | ||
373 | |||
374 | addr = msgs[i].addr >> 1; | ||
375 | |||
376 | dprintk2(2, "%s %s addr=%x len=%d:", | ||
377 | (msgs[i].flags & I2C_M_RD) ? "read" : "write", | ||
378 | i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); | ||
379 | if (!msgs[i].len) { | ||
380 | /* no len: check only for device presence */ | ||
381 | rc = cx231xx_i2c_check_for_device(i2c_adap, &msgs[i]); | ||
382 | if (rc < 0) { | ||
383 | dprintk2(2, " no device\n"); | ||
384 | mutex_unlock(&dev->i2c_lock); | ||
385 | return rc; | ||
386 | } | ||
387 | |||
388 | } else if (msgs[i].flags & I2C_M_RD) { | ||
389 | /* read bytes */ | ||
390 | rc = cx231xx_i2c_recv_bytes(i2c_adap, &msgs[i]); | ||
391 | if (i2c_debug >= 2) { | ||
392 | for (byte = 0; byte < msgs[i].len; byte++) | ||
393 | printk(" %02x", msgs[i].buf[byte]); | ||
394 | } | ||
395 | } else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && | ||
396 | msgs[i].addr == msgs[i + 1].addr | ||
397 | && (msgs[i].len <= 2) && (bus->nr < 3)) { | ||
398 | /* read bytes */ | ||
399 | rc = cx231xx_i2c_recv_bytes_with_saddr(i2c_adap, | ||
400 | &msgs[i], | ||
401 | &msgs[i + 1]); | ||
402 | if (i2c_debug >= 2) { | ||
403 | for (byte = 0; byte < msgs[i].len; byte++) | ||
404 | printk(" %02x", msgs[i].buf[byte]); | ||
405 | } | ||
406 | i++; | ||
407 | } else { | ||
408 | /* write bytes */ | ||
409 | if (i2c_debug >= 2) { | ||
410 | for (byte = 0; byte < msgs[i].len; byte++) | ||
411 | printk(" %02x", msgs[i].buf[byte]); | ||
412 | } | ||
413 | rc = cx231xx_i2c_send_bytes(i2c_adap, &msgs[i]); | ||
414 | } | ||
415 | if (rc < 0) | ||
416 | goto err; | ||
417 | if (i2c_debug >= 2) | ||
418 | printk("\n"); | ||
419 | } | ||
420 | mutex_unlock(&dev->i2c_lock); | ||
421 | return num; | ||
422 | err: | ||
423 | dprintk2(2, " ERROR: %i\n", rc); | ||
424 | mutex_unlock(&dev->i2c_lock); | ||
425 | return rc; | ||
426 | } | ||
427 | |||
428 | /* ----------------------------------------------------------- */ | ||
429 | |||
430 | /* | ||
431 | * functionality() | ||
432 | */ | ||
433 | static u32 functionality(struct i2c_adapter *adap) | ||
434 | { | ||
435 | return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C; | ||
436 | } | ||
437 | |||
438 | static struct i2c_algorithm cx231xx_algo = { | ||
439 | .master_xfer = cx231xx_i2c_xfer, | ||
440 | .functionality = functionality, | ||
441 | }; | ||
442 | |||
443 | static struct i2c_adapter cx231xx_adap_template = { | ||
444 | .owner = THIS_MODULE, | ||
445 | .name = "cx231xx", | ||
446 | .algo = &cx231xx_algo, | ||
447 | }; | ||
448 | |||
449 | static struct i2c_client cx231xx_client_template = { | ||
450 | .name = "cx231xx internal", | ||
451 | }; | ||
452 | |||
453 | /* ----------------------------------------------------------- */ | ||
454 | |||
455 | /* | ||
456 | * i2c_devs | ||
457 | * incomplete list of known devices | ||
458 | */ | ||
459 | static char *i2c_devs[128] = { | ||
460 | [0x60 >> 1] = "colibri", | ||
461 | [0x88 >> 1] = "hammerhead", | ||
462 | [0x8e >> 1] = "CIR", | ||
463 | [0x32 >> 1] = "GeminiIII", | ||
464 | [0x02 >> 1] = "Aquarius", | ||
465 | [0xa0 >> 1] = "eeprom", | ||
466 | [0xc0 >> 1] = "tuner", | ||
467 | [0xc2 >> 1] = "tuner", | ||
468 | }; | ||
469 | |||
470 | /* | ||
471 | * cx231xx_do_i2c_scan() | ||
472 | * check i2c address range for devices | ||
473 | */ | ||
474 | void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c) | ||
475 | { | ||
476 | unsigned char buf; | ||
477 | int i, rc; | ||
478 | |||
479 | cx231xx_info(": Checking for I2C devices ..\n"); | ||
480 | for (i = 0; i < 128; i++) { | ||
481 | c->addr = i; | ||
482 | rc = i2c_master_recv(c, &buf, 0); | ||
483 | if (rc < 0) | ||
484 | continue; | ||
485 | cx231xx_info("%s: i2c scan: found device @ 0x%x [%s]\n", | ||
486 | dev->name, i << 1, | ||
487 | i2c_devs[i] ? i2c_devs[i] : "???"); | ||
488 | } | ||
489 | cx231xx_info(": Completed Checking for I2C devices.\n"); | ||
490 | } | ||
491 | |||
492 | /* | ||
493 | * cx231xx_i2c_register() | ||
494 | * register i2c bus | ||
495 | */ | ||
496 | int cx231xx_i2c_register(struct cx231xx_i2c *bus) | ||
497 | { | ||
498 | struct cx231xx *dev = bus->dev; | ||
499 | |||
500 | BUG_ON(!dev->cx231xx_send_usb_command); | ||
501 | |||
502 | bus->i2c_adap = cx231xx_adap_template; | ||
503 | bus->i2c_client = cx231xx_client_template; | ||
504 | bus->i2c_adap.dev.parent = &dev->udev->dev; | ||
505 | |||
506 | strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name)); | ||
507 | |||
508 | bus->i2c_adap.algo_data = bus; | ||
509 | i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev); | ||
510 | i2c_add_adapter(&bus->i2c_adap); | ||
511 | |||
512 | bus->i2c_client.adapter = &bus->i2c_adap; | ||
513 | |||
514 | if (0 == bus->i2c_rc) { | ||
515 | if (i2c_scan) | ||
516 | cx231xx_do_i2c_scan(dev, &bus->i2c_client); | ||
517 | } else | ||
518 | cx231xx_warn("%s: i2c bus %d register FAILED\n", | ||
519 | dev->name, bus->nr); | ||
520 | |||
521 | return bus->i2c_rc; | ||
522 | } | ||
523 | |||
524 | /* | ||
525 | * cx231xx_i2c_unregister() | ||
526 | * unregister i2c_bus | ||
527 | */ | ||
528 | int cx231xx_i2c_unregister(struct cx231xx_i2c *bus) | ||
529 | { | ||
530 | i2c_del_adapter(&bus->i2c_adap); | ||
531 | return 0; | ||
532 | } | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c new file mode 100644 index 000000000000..96176e9db5a2 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-input.c | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | * cx231xx IR glue driver | ||
3 | * | ||
4 | * Copyright (C) 2010 Mauro Carvalho Chehab <mchehab@redhat.com> | ||
5 | * | ||
6 | * Polaris (cx231xx) has its support for IR's with a design close to MCE. | ||
7 | * however, a few designs are using an external I2C chip for IR, instead | ||
8 | * of using the one provided by the chip. | ||
9 | * This driver provides support for those extra devices | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or | ||
12 | * modify it under the terms of the GNU General Public License as | ||
13 | * published by the Free Software Foundation version 2. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 | * General Public License for more details. | ||
19 | */ | ||
20 | |||
21 | #include "cx231xx.h" | ||
22 | #include <linux/usb.h> | ||
23 | #include <linux/slab.h> | ||
24 | |||
25 | #define MODULE_NAME "cx231xx-input" | ||
26 | |||
27 | static int get_key_isdbt(struct IR_i2c *ir, u32 *ir_key, | ||
28 | u32 *ir_raw) | ||
29 | { | ||
30 | int rc; | ||
31 | u8 cmd, scancode; | ||
32 | |||
33 | dev_dbg(&ir->rc->input_dev->dev, "%s\n", __func__); | ||
34 | |||
35 | /* poll IR chip */ | ||
36 | rc = i2c_master_recv(ir->c, &cmd, 1); | ||
37 | if (rc < 0) | ||
38 | return rc; | ||
39 | if (rc != 1) | ||
40 | return -EIO; | ||
41 | |||
42 | /* it seems that 0xFE indicates that a button is still hold | ||
43 | down, while 0xff indicates that no button is hold | ||
44 | down. 0xfe sequences are sometimes interrupted by 0xFF */ | ||
45 | |||
46 | if (cmd == 0xff) | ||
47 | return 0; | ||
48 | |||
49 | scancode = | ||
50 | ((cmd & 0x01) ? 0x80 : 0) | | ||
51 | ((cmd & 0x02) ? 0x40 : 0) | | ||
52 | ((cmd & 0x04) ? 0x20 : 0) | | ||
53 | ((cmd & 0x08) ? 0x10 : 0) | | ||
54 | ((cmd & 0x10) ? 0x08 : 0) | | ||
55 | ((cmd & 0x20) ? 0x04 : 0) | | ||
56 | ((cmd & 0x40) ? 0x02 : 0) | | ||
57 | ((cmd & 0x80) ? 0x01 : 0); | ||
58 | |||
59 | dev_dbg(&ir->rc->input_dev->dev, "cmd %02x, scan = %02x\n", | ||
60 | cmd, scancode); | ||
61 | |||
62 | *ir_key = scancode; | ||
63 | *ir_raw = scancode; | ||
64 | return 1; | ||
65 | } | ||
66 | |||
67 | int cx231xx_ir_init(struct cx231xx *dev) | ||
68 | { | ||
69 | struct i2c_board_info info; | ||
70 | u8 ir_i2c_bus; | ||
71 | |||
72 | dev_dbg(&dev->udev->dev, "%s\n", __func__); | ||
73 | |||
74 | /* Only initialize if a rc keycode map is defined */ | ||
75 | if (!cx231xx_boards[dev->model].rc_map_name) | ||
76 | return -ENODEV; | ||
77 | |||
78 | request_module("ir-kbd-i2c"); | ||
79 | |||
80 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
81 | memset(&dev->init_data, 0, sizeof(dev->init_data)); | ||
82 | dev->init_data.rc_dev = rc_allocate_device(); | ||
83 | if (!dev->init_data.rc_dev) | ||
84 | return -ENOMEM; | ||
85 | |||
86 | dev->init_data.name = cx231xx_boards[dev->model].name; | ||
87 | |||
88 | strlcpy(info.type, "ir_video", I2C_NAME_SIZE); | ||
89 | info.platform_data = &dev->init_data; | ||
90 | |||
91 | /* | ||
92 | * Board-dependent values | ||
93 | * | ||
94 | * For now, there's just one type of hardware design using | ||
95 | * an i2c device. | ||
96 | */ | ||
97 | dev->init_data.get_key = get_key_isdbt; | ||
98 | dev->init_data.ir_codes = cx231xx_boards[dev->model].rc_map_name; | ||
99 | /* The i2c micro-controller only outputs the cmd part of NEC protocol */ | ||
100 | dev->init_data.rc_dev->scanmask = 0xff; | ||
101 | dev->init_data.rc_dev->driver_name = "cx231xx"; | ||
102 | dev->init_data.type = RC_TYPE_NEC; | ||
103 | info.addr = 0x30; | ||
104 | |||
105 | /* Load and bind ir-kbd-i2c */ | ||
106 | ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master; | ||
107 | dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n", | ||
108 | ir_i2c_bus, info.addr); | ||
109 | dev->ir_i2c_client = i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info); | ||
110 | |||
111 | return 0; | ||
112 | } | ||
113 | |||
114 | void cx231xx_ir_exit(struct cx231xx *dev) | ||
115 | { | ||
116 | if (dev->ir_i2c_client) | ||
117 | i2c_unregister_device(dev->ir_i2c_client); | ||
118 | dev->ir_i2c_client = NULL; | ||
119 | } | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c new file mode 100644 index 000000000000..7473c33e823e --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c | |||
@@ -0,0 +1,795 @@ | |||
1 | /* | ||
2 | cx231xx-pcb-config.c - driver for Conexant | ||
3 | Cx23100/101/102 USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include "cx231xx.h" | ||
23 | #include "cx231xx-conf-reg.h" | ||
24 | |||
25 | static unsigned int pcb_debug; | ||
26 | module_param(pcb_debug, int, 0644); | ||
27 | MODULE_PARM_DESC(pcb_debug, "enable pcb config debug messages [video]"); | ||
28 | |||
29 | /******************************************************************************/ | ||
30 | |||
31 | struct pcb_config cx231xx_Scenario[] = { | ||
32 | { | ||
33 | INDEX_SELFPOWER_DIGITAL_ONLY, /* index */ | ||
34 | USB_SELF_POWER, /* power_type */ | ||
35 | 0, /* speed , not decide yet */ | ||
36 | MOD_DIGITAL, /* mode */ | ||
37 | SOURCE_TS_BDA, /* ts1_source, digital tv only */ | ||
38 | NOT_SUPPORTED, /* ts2_source */ | ||
39 | NOT_SUPPORTED, /* analog source */ | ||
40 | |||
41 | 0, /* digital_index */ | ||
42 | 0, /* analog index */ | ||
43 | 0, /* dif_index */ | ||
44 | 0, /* external_index */ | ||
45 | |||
46 | 1, /* only one configuration */ | ||
47 | { | ||
48 | { | ||
49 | 0, /* config index */ | ||
50 | { | ||
51 | 0, /* interrupt ep index */ | ||
52 | 1, /* ts1 index */ | ||
53 | NOT_SUPPORTED, /* TS2 index */ | ||
54 | NOT_SUPPORTED, /* AUDIO */ | ||
55 | NOT_SUPPORTED, /* VIDEO */ | ||
56 | NOT_SUPPORTED, /* VANC */ | ||
57 | NOT_SUPPORTED, /* HANC */ | ||
58 | NOT_SUPPORTED /* ir_index */ | ||
59 | } | ||
60 | , | ||
61 | } | ||
62 | , | ||
63 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
64 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
65 | NOT_SUPPORTED} | ||
66 | } | ||
67 | , | ||
68 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
69 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
70 | NOT_SUPPORTED} | ||
71 | } | ||
72 | } | ||
73 | , | ||
74 | /* full-speed config */ | ||
75 | { | ||
76 | { | ||
77 | 0, /* config index */ | ||
78 | { | ||
79 | 0, /* interrupt ep index */ | ||
80 | 1, /* ts1 index */ | ||
81 | NOT_SUPPORTED, /* TS2 index */ | ||
82 | NOT_SUPPORTED, /* AUDIO */ | ||
83 | NOT_SUPPORTED, /* VIDEO */ | ||
84 | NOT_SUPPORTED, /* VANC */ | ||
85 | NOT_SUPPORTED, /* HANC */ | ||
86 | NOT_SUPPORTED /* ir_index */ | ||
87 | } | ||
88 | } | ||
89 | , | ||
90 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
91 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
92 | NOT_SUPPORTED} | ||
93 | } | ||
94 | , | ||
95 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
96 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
97 | NOT_SUPPORTED} | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | , | ||
102 | |||
103 | { | ||
104 | INDEX_SELFPOWER_DUAL_DIGITAL, /* index */ | ||
105 | USB_SELF_POWER, /* power_type */ | ||
106 | 0, /* speed , not decide yet */ | ||
107 | MOD_DIGITAL, /* mode */ | ||
108 | SOURCE_TS_BDA, /* ts1_source, digital tv only */ | ||
109 | 0, /* ts2_source,need update from register */ | ||
110 | NOT_SUPPORTED, /* analog source */ | ||
111 | 0, /* digital_index */ | ||
112 | 0, /* analog index */ | ||
113 | 0, /* dif_index */ | ||
114 | 0, /* external_index */ | ||
115 | |||
116 | 1, /* only one configuration */ | ||
117 | { | ||
118 | { | ||
119 | 0, /* config index */ | ||
120 | { | ||
121 | 0, /* interrupt ep index */ | ||
122 | 1, /* ts1 index */ | ||
123 | 2, /* TS2 index */ | ||
124 | NOT_SUPPORTED, /* AUDIO */ | ||
125 | NOT_SUPPORTED, /* VIDEO */ | ||
126 | NOT_SUPPORTED, /* VANC */ | ||
127 | NOT_SUPPORTED, /* HANC */ | ||
128 | NOT_SUPPORTED /* ir_index */ | ||
129 | } | ||
130 | } | ||
131 | , | ||
132 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
133 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
134 | NOT_SUPPORTED} | ||
135 | } | ||
136 | , | ||
137 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
138 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
139 | NOT_SUPPORTED} | ||
140 | } | ||
141 | } | ||
142 | , | ||
143 | /* full-speed */ | ||
144 | { | ||
145 | { | ||
146 | 0, /* config index */ | ||
147 | { | ||
148 | 0, /* interrupt ep index */ | ||
149 | 1, /* ts1 index */ | ||
150 | 2, /* TS2 index */ | ||
151 | NOT_SUPPORTED, /* AUDIO */ | ||
152 | NOT_SUPPORTED, /* VIDEO */ | ||
153 | NOT_SUPPORTED, /* VANC */ | ||
154 | NOT_SUPPORTED, /* HANC */ | ||
155 | NOT_SUPPORTED /* ir_index */ | ||
156 | } | ||
157 | } | ||
158 | , | ||
159 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
160 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
161 | NOT_SUPPORTED} | ||
162 | } | ||
163 | , | ||
164 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
165 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
166 | NOT_SUPPORTED} | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | , | ||
171 | |||
172 | { | ||
173 | INDEX_SELFPOWER_ANALOG_ONLY, /* index */ | ||
174 | USB_SELF_POWER, /* power_type */ | ||
175 | 0, /* speed , not decide yet */ | ||
176 | MOD_ANALOG | MOD_DIF | MOD_EXTERNAL, /* mode ,analog tv only */ | ||
177 | NOT_SUPPORTED, /* ts1_source, NOT SUPPORT */ | ||
178 | NOT_SUPPORTED, /* ts2_source,NOT SUPPORT */ | ||
179 | 0, /* analog source, need update */ | ||
180 | |||
181 | 0, /* digital_index */ | ||
182 | 0, /* analog index */ | ||
183 | 0, /* dif_index */ | ||
184 | 0, /* external_index */ | ||
185 | |||
186 | 1, /* only one configuration */ | ||
187 | { | ||
188 | { | ||
189 | 0, /* config index */ | ||
190 | { | ||
191 | 0, /* interrupt ep index */ | ||
192 | NOT_SUPPORTED, /* ts1 index */ | ||
193 | NOT_SUPPORTED, /* TS2 index */ | ||
194 | 1, /* AUDIO */ | ||
195 | 2, /* VIDEO */ | ||
196 | 3, /* VANC */ | ||
197 | 4, /* HANC */ | ||
198 | NOT_SUPPORTED /* ir_index */ | ||
199 | } | ||
200 | } | ||
201 | , | ||
202 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
203 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
204 | NOT_SUPPORTED} | ||
205 | } | ||
206 | , | ||
207 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
208 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
209 | NOT_SUPPORTED} | ||
210 | } | ||
211 | } | ||
212 | , | ||
213 | /* full-speed */ | ||
214 | { | ||
215 | { | ||
216 | 0, /* config index */ | ||
217 | { | ||
218 | 0, /* interrupt ep index */ | ||
219 | NOT_SUPPORTED, /* ts1 index */ | ||
220 | NOT_SUPPORTED, /* TS2 index */ | ||
221 | 1, /* AUDIO */ | ||
222 | 2, /* VIDEO */ | ||
223 | NOT_SUPPORTED, /* VANC */ | ||
224 | NOT_SUPPORTED, /* HANC */ | ||
225 | NOT_SUPPORTED /* ir_index */ | ||
226 | } | ||
227 | } | ||
228 | , | ||
229 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
230 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
231 | NOT_SUPPORTED} | ||
232 | } | ||
233 | , | ||
234 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
235 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
236 | NOT_SUPPORTED} | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | , | ||
241 | |||
242 | { | ||
243 | INDEX_SELFPOWER_DUAL, /* index */ | ||
244 | USB_SELF_POWER, /* power_type */ | ||
245 | 0, /* speed , not decide yet */ | ||
246 | /* mode ,analog tv and digital path */ | ||
247 | MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL, | ||
248 | 0, /* ts1_source,will update in register */ | ||
249 | NOT_SUPPORTED, /* ts2_source,NOT SUPPORT */ | ||
250 | 0, /* analog source need update */ | ||
251 | 0, /* digital_index */ | ||
252 | 0, /* analog index */ | ||
253 | 0, /* dif_index */ | ||
254 | 0, /* external_index */ | ||
255 | 1, /* only one configuration */ | ||
256 | { | ||
257 | { | ||
258 | 0, /* config index */ | ||
259 | { | ||
260 | 0, /* interrupt ep index */ | ||
261 | 1, /* ts1 index */ | ||
262 | NOT_SUPPORTED, /* TS2 index */ | ||
263 | 2, /* AUDIO */ | ||
264 | 3, /* VIDEO */ | ||
265 | 4, /* VANC */ | ||
266 | 5, /* HANC */ | ||
267 | NOT_SUPPORTED /* ir_index */ | ||
268 | } | ||
269 | } | ||
270 | , | ||
271 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
272 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
273 | NOT_SUPPORTED} | ||
274 | } | ||
275 | , | ||
276 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
277 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
278 | NOT_SUPPORTED} | ||
279 | } | ||
280 | } | ||
281 | , | ||
282 | /* full-speed */ | ||
283 | { | ||
284 | { | ||
285 | 0, /* config index */ | ||
286 | { | ||
287 | 0, /* interrupt ep index */ | ||
288 | 1, /* ts1 index */ | ||
289 | NOT_SUPPORTED, /* TS2 index */ | ||
290 | 2, /* AUDIO */ | ||
291 | 3, /* VIDEO */ | ||
292 | NOT_SUPPORTED, /* VANC */ | ||
293 | NOT_SUPPORTED, /* HANC */ | ||
294 | NOT_SUPPORTED /* ir_index */ | ||
295 | } | ||
296 | } | ||
297 | , | ||
298 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
299 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
300 | NOT_SUPPORTED} | ||
301 | } | ||
302 | , | ||
303 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
304 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
305 | NOT_SUPPORTED} | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | , | ||
310 | |||
311 | { | ||
312 | INDEX_SELFPOWER_TRIPLE, /* index */ | ||
313 | USB_SELF_POWER, /* power_type */ | ||
314 | 0, /* speed , not decide yet */ | ||
315 | /* mode ,analog tv and digital path */ | ||
316 | MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL, | ||
317 | 0, /* ts1_source, update in register */ | ||
318 | 0, /* ts2_source,update in register */ | ||
319 | 0, /* analog source, need update */ | ||
320 | |||
321 | 0, /* digital_index */ | ||
322 | 0, /* analog index */ | ||
323 | 0, /* dif_index */ | ||
324 | 0, /* external_index */ | ||
325 | 1, /* only one configuration */ | ||
326 | { | ||
327 | { | ||
328 | 0, /* config index */ | ||
329 | { | ||
330 | 0, /* interrupt ep index */ | ||
331 | 1, /* ts1 index */ | ||
332 | 2, /* TS2 index */ | ||
333 | 3, /* AUDIO */ | ||
334 | 4, /* VIDEO */ | ||
335 | 5, /* VANC */ | ||
336 | 6, /* HANC */ | ||
337 | NOT_SUPPORTED /* ir_index */ | ||
338 | } | ||
339 | } | ||
340 | , | ||
341 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
342 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
343 | NOT_SUPPORTED} | ||
344 | } | ||
345 | , | ||
346 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
347 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
348 | NOT_SUPPORTED} | ||
349 | } | ||
350 | } | ||
351 | , | ||
352 | /* full-speed */ | ||
353 | { | ||
354 | { | ||
355 | 0, /* config index */ | ||
356 | { | ||
357 | 0, /* interrupt ep index */ | ||
358 | 1, /* ts1 index */ | ||
359 | 2, /* TS2 index */ | ||
360 | 3, /* AUDIO */ | ||
361 | 4, /* VIDEO */ | ||
362 | NOT_SUPPORTED, /* VANC */ | ||
363 | NOT_SUPPORTED, /* HANC */ | ||
364 | NOT_SUPPORTED /* ir_index */ | ||
365 | } | ||
366 | } | ||
367 | , | ||
368 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
369 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
370 | NOT_SUPPORTED} | ||
371 | } | ||
372 | , | ||
373 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
374 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
375 | NOT_SUPPORTED} | ||
376 | } | ||
377 | } | ||
378 | } | ||
379 | , | ||
380 | |||
381 | { | ||
382 | INDEX_SELFPOWER_COMPRESSOR, /* index */ | ||
383 | USB_SELF_POWER, /* power_type */ | ||
384 | 0, /* speed , not decide yet */ | ||
385 | /* mode ,analog tv AND DIGITAL path */ | ||
386 | MOD_ANALOG | MOD_DIF | MOD_DIGITAL | MOD_EXTERNAL, | ||
387 | NOT_SUPPORTED, /* ts1_source, disable */ | ||
388 | SOURCE_TS_BDA, /* ts2_source */ | ||
389 | 0, /* analog source,need update */ | ||
390 | 0, /* digital_index */ | ||
391 | 0, /* analog index */ | ||
392 | 0, /* dif_index */ | ||
393 | 0, /* external_index */ | ||
394 | 1, /* only one configuration */ | ||
395 | { | ||
396 | { | ||
397 | 0, /* config index */ | ||
398 | { | ||
399 | 0, /* interrupt ep index */ | ||
400 | NOT_SUPPORTED, /* ts1 index */ | ||
401 | 1, /* TS2 index */ | ||
402 | 2, /* AUDIO */ | ||
403 | 3, /* VIDEO */ | ||
404 | 4, /* VANC */ | ||
405 | 5, /* HANC */ | ||
406 | NOT_SUPPORTED /* ir_index */ | ||
407 | } | ||
408 | } | ||
409 | , | ||
410 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
411 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
412 | NOT_SUPPORTED} | ||
413 | } | ||
414 | , | ||
415 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
416 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
417 | NOT_SUPPORTED} | ||
418 | } | ||
419 | } | ||
420 | , | ||
421 | /* full-speed */ | ||
422 | { | ||
423 | { | ||
424 | 0, /* config index */ | ||
425 | { | ||
426 | 0, /* interrupt ep index */ | ||
427 | NOT_SUPPORTED, /* ts1 index */ | ||
428 | 1, /* TS2 index */ | ||
429 | 2, /* AUDIO */ | ||
430 | 3, /* VIDEO */ | ||
431 | NOT_SUPPORTED, /* VANC */ | ||
432 | NOT_SUPPORTED, /* HANC */ | ||
433 | NOT_SUPPORTED /* ir_index */ | ||
434 | } | ||
435 | } | ||
436 | , | ||
437 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
438 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
439 | NOT_SUPPORTED} | ||
440 | } | ||
441 | , | ||
442 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
443 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
444 | NOT_SUPPORTED} | ||
445 | } | ||
446 | } | ||
447 | } | ||
448 | , | ||
449 | |||
450 | { | ||
451 | INDEX_BUSPOWER_DIGITAL_ONLY, /* index */ | ||
452 | USB_BUS_POWER, /* power_type */ | ||
453 | 0, /* speed , not decide yet */ | ||
454 | MOD_DIGITAL, /* mode ,analog tv AND DIGITAL path */ | ||
455 | SOURCE_TS_BDA, /* ts1_source, disable */ | ||
456 | NOT_SUPPORTED, /* ts2_source */ | ||
457 | NOT_SUPPORTED, /* analog source */ | ||
458 | |||
459 | 0, /* digital_index */ | ||
460 | 0, /* analog index */ | ||
461 | 0, /* dif_index */ | ||
462 | 0, /* external_index */ | ||
463 | |||
464 | 1, /* only one configuration */ | ||
465 | { | ||
466 | { | ||
467 | 0, /* config index */ | ||
468 | { | ||
469 | 0, /* interrupt ep index = 2 */ | ||
470 | 1, /* ts1 index */ | ||
471 | NOT_SUPPORTED, /* TS2 index */ | ||
472 | NOT_SUPPORTED, /* AUDIO */ | ||
473 | NOT_SUPPORTED, /* VIDEO */ | ||
474 | NOT_SUPPORTED, /* VANC */ | ||
475 | NOT_SUPPORTED, /* HANC */ | ||
476 | NOT_SUPPORTED /* ir_index */ | ||
477 | } | ||
478 | } | ||
479 | , | ||
480 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
481 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
482 | NOT_SUPPORTED} | ||
483 | } | ||
484 | , | ||
485 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
486 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
487 | NOT_SUPPORTED} | ||
488 | } | ||
489 | } | ||
490 | , | ||
491 | /* full-speed */ | ||
492 | { | ||
493 | { | ||
494 | 0, /* config index */ | ||
495 | { | ||
496 | 0, /* interrupt ep index = 2 */ | ||
497 | 1, /* ts1 index */ | ||
498 | NOT_SUPPORTED, /* TS2 index */ | ||
499 | NOT_SUPPORTED, /* AUDIO */ | ||
500 | NOT_SUPPORTED, /* VIDEO */ | ||
501 | NOT_SUPPORTED, /* VANC */ | ||
502 | NOT_SUPPORTED, /* HANC */ | ||
503 | NOT_SUPPORTED /* ir_index */ | ||
504 | } | ||
505 | } | ||
506 | , | ||
507 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
508 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
509 | NOT_SUPPORTED} | ||
510 | } | ||
511 | , | ||
512 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
513 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
514 | NOT_SUPPORTED} | ||
515 | } | ||
516 | } | ||
517 | } | ||
518 | , | ||
519 | { | ||
520 | INDEX_BUSPOWER_ANALOG_ONLY, /* index */ | ||
521 | USB_BUS_POWER, /* power_type */ | ||
522 | 0, /* speed , not decide yet */ | ||
523 | MOD_ANALOG, /* mode ,analog tv AND DIGITAL path */ | ||
524 | NOT_SUPPORTED, /* ts1_source, disable */ | ||
525 | NOT_SUPPORTED, /* ts2_source */ | ||
526 | SOURCE_ANALOG, /* analog source--analog */ | ||
527 | 0, /* digital_index */ | ||
528 | 0, /* analog index */ | ||
529 | 0, /* dif_index */ | ||
530 | 0, /* external_index */ | ||
531 | 1, /* only one configuration */ | ||
532 | { | ||
533 | { | ||
534 | 0, /* config index */ | ||
535 | { | ||
536 | 0, /* interrupt ep index */ | ||
537 | NOT_SUPPORTED, /* ts1 index */ | ||
538 | NOT_SUPPORTED, /* TS2 index */ | ||
539 | 1, /* AUDIO */ | ||
540 | 2, /* VIDEO */ | ||
541 | 3, /* VANC */ | ||
542 | 4, /* HANC */ | ||
543 | NOT_SUPPORTED /* ir_index */ | ||
544 | } | ||
545 | } | ||
546 | , | ||
547 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
548 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
549 | NOT_SUPPORTED} | ||
550 | } | ||
551 | , | ||
552 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
553 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
554 | NOT_SUPPORTED} | ||
555 | } | ||
556 | } | ||
557 | , | ||
558 | { /* full-speed */ | ||
559 | { | ||
560 | 0, /* config index */ | ||
561 | { | ||
562 | 0, /* interrupt ep index */ | ||
563 | NOT_SUPPORTED, /* ts1 index */ | ||
564 | NOT_SUPPORTED, /* TS2 index */ | ||
565 | 1, /* AUDIO */ | ||
566 | 2, /* VIDEO */ | ||
567 | NOT_SUPPORTED, /* VANC */ | ||
568 | NOT_SUPPORTED, /* HANC */ | ||
569 | NOT_SUPPORTED /* ir_index */ | ||
570 | } | ||
571 | } | ||
572 | , | ||
573 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
574 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
575 | NOT_SUPPORTED} | ||
576 | } | ||
577 | , | ||
578 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
579 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
580 | NOT_SUPPORTED} | ||
581 | } | ||
582 | } | ||
583 | } | ||
584 | , | ||
585 | { | ||
586 | INDEX_BUSPOWER_DIF_ONLY, /* index */ | ||
587 | USB_BUS_POWER, /* power_type */ | ||
588 | 0, /* speed , not decide yet */ | ||
589 | /* mode ,analog tv AND DIGITAL path */ | ||
590 | MOD_DIF | MOD_ANALOG | MOD_DIGITAL | MOD_EXTERNAL, | ||
591 | SOURCE_TS_BDA, /* ts1_source, disable */ | ||
592 | NOT_SUPPORTED, /* ts2_source */ | ||
593 | SOURCE_DIF | SOURCE_ANALOG | SOURCE_EXTERNAL, /* analog source, dif */ | ||
594 | 0, /* digital_index */ | ||
595 | 0, /* analog index */ | ||
596 | 0, /* dif_index */ | ||
597 | 0, /* external_index */ | ||
598 | 1, /* only one configuration */ | ||
599 | { | ||
600 | { | ||
601 | 0, /* config index */ | ||
602 | { | ||
603 | 0, /* interrupt ep index */ | ||
604 | 1, /* ts1 index */ | ||
605 | NOT_SUPPORTED, /* TS2 index */ | ||
606 | 2, /* AUDIO */ | ||
607 | 3, /* VIDEO */ | ||
608 | 4, /* VANC */ | ||
609 | 5, /* HANC */ | ||
610 | NOT_SUPPORTED /* ir_index */ | ||
611 | } | ||
612 | } | ||
613 | , | ||
614 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
615 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
616 | NOT_SUPPORTED} | ||
617 | } | ||
618 | , | ||
619 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
620 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
621 | NOT_SUPPORTED} | ||
622 | } | ||
623 | } | ||
624 | , | ||
625 | { /* full speed */ | ||
626 | { | ||
627 | 0, /* config index */ | ||
628 | { | ||
629 | 0, /* interrupt ep index */ | ||
630 | 1, /* ts1 index */ | ||
631 | NOT_SUPPORTED, /* TS2 index */ | ||
632 | 2, /* AUDIO */ | ||
633 | 3, /* VIDEO */ | ||
634 | NOT_SUPPORTED, /* VANC */ | ||
635 | NOT_SUPPORTED, /* HANC */ | ||
636 | NOT_SUPPORTED /* ir_index */ | ||
637 | } | ||
638 | } | ||
639 | , | ||
640 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
641 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
642 | NOT_SUPPORTED} | ||
643 | } | ||
644 | , | ||
645 | {NOT_SUPPORTED, {NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
646 | NOT_SUPPORTED, NOT_SUPPORTED, NOT_SUPPORTED, | ||
647 | NOT_SUPPORTED} | ||
648 | } | ||
649 | } | ||
650 | } | ||
651 | , | ||
652 | |||
653 | }; | ||
654 | |||
655 | /*****************************************************************/ | ||
656 | |||
657 | u32 initialize_cx231xx(struct cx231xx *dev) | ||
658 | { | ||
659 | u32 config_info = 0; | ||
660 | struct pcb_config *p_pcb_info; | ||
661 | u8 usb_speed = 1; /* from register,1--HS, 0--FS */ | ||
662 | u8 data[4] = { 0, 0, 0, 0 }; | ||
663 | u32 ts1_source = 0; | ||
664 | u32 ts2_source = 0; | ||
665 | u32 analog_source = 0; | ||
666 | u8 _current_scenario_idx = 0xff; | ||
667 | |||
668 | ts1_source = SOURCE_TS_BDA; | ||
669 | ts2_source = SOURCE_TS_BDA; | ||
670 | |||
671 | /* read board config register to find out which | ||
672 | pcb config it is related to */ | ||
673 | cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, BOARD_CFG_STAT, data, 4); | ||
674 | |||
675 | config_info = *((u32 *) data); | ||
676 | usb_speed = (u8) (config_info & 0x1); | ||
677 | |||
678 | /* Verify this device belongs to Bus power or Self power device */ | ||
679 | if (config_info & BUS_POWER) { /* bus-power */ | ||
680 | switch (config_info & BUSPOWER_MASK) { | ||
681 | case TS1_PORT | BUS_POWER: | ||
682 | cx231xx_Scenario[INDEX_BUSPOWER_DIGITAL_ONLY].speed = | ||
683 | usb_speed; | ||
684 | p_pcb_info = | ||
685 | &cx231xx_Scenario[INDEX_BUSPOWER_DIGITAL_ONLY]; | ||
686 | _current_scenario_idx = INDEX_BUSPOWER_DIGITAL_ONLY; | ||
687 | break; | ||
688 | case AVDEC_ENABLE | BUS_POWER: | ||
689 | cx231xx_Scenario[INDEX_BUSPOWER_ANALOG_ONLY].speed = | ||
690 | usb_speed; | ||
691 | p_pcb_info = | ||
692 | &cx231xx_Scenario[INDEX_BUSPOWER_ANALOG_ONLY]; | ||
693 | _current_scenario_idx = INDEX_BUSPOWER_ANALOG_ONLY; | ||
694 | break; | ||
695 | case AVDEC_ENABLE | BUS_POWER | TS1_PORT: | ||
696 | cx231xx_Scenario[INDEX_BUSPOWER_DIF_ONLY].speed = | ||
697 | usb_speed; | ||
698 | p_pcb_info = &cx231xx_Scenario[INDEX_BUSPOWER_DIF_ONLY]; | ||
699 | _current_scenario_idx = INDEX_BUSPOWER_DIF_ONLY; | ||
700 | break; | ||
701 | default: | ||
702 | cx231xx_info("bad config in buspower!!!!\n"); | ||
703 | cx231xx_info("config_info=%x\n", | ||
704 | (config_info & BUSPOWER_MASK)); | ||
705 | return 1; | ||
706 | } | ||
707 | } else { /* self-power */ | ||
708 | |||
709 | switch (config_info & SELFPOWER_MASK) { | ||
710 | case TS1_PORT | SELF_POWER: | ||
711 | cx231xx_Scenario[INDEX_SELFPOWER_DIGITAL_ONLY].speed = | ||
712 | usb_speed; | ||
713 | p_pcb_info = | ||
714 | &cx231xx_Scenario[INDEX_SELFPOWER_DIGITAL_ONLY]; | ||
715 | _current_scenario_idx = INDEX_SELFPOWER_DIGITAL_ONLY; | ||
716 | break; | ||
717 | case TS1_TS2_PORT | SELF_POWER: | ||
718 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL].speed = | ||
719 | usb_speed; | ||
720 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL]. | ||
721 | ts2_source = ts2_source; | ||
722 | p_pcb_info = | ||
723 | &cx231xx_Scenario[INDEX_SELFPOWER_DUAL_DIGITAL]; | ||
724 | _current_scenario_idx = INDEX_SELFPOWER_DUAL_DIGITAL; | ||
725 | break; | ||
726 | case AVDEC_ENABLE | SELF_POWER: | ||
727 | cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY].speed = | ||
728 | usb_speed; | ||
729 | cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY]. | ||
730 | analog_source = analog_source; | ||
731 | p_pcb_info = | ||
732 | &cx231xx_Scenario[INDEX_SELFPOWER_ANALOG_ONLY]; | ||
733 | _current_scenario_idx = INDEX_SELFPOWER_ANALOG_ONLY; | ||
734 | break; | ||
735 | case AVDEC_ENABLE | TS1_PORT | SELF_POWER: | ||
736 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL].speed = | ||
737 | usb_speed; | ||
738 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL].ts1_source = | ||
739 | ts1_source; | ||
740 | cx231xx_Scenario[INDEX_SELFPOWER_DUAL].analog_source = | ||
741 | analog_source; | ||
742 | p_pcb_info = &cx231xx_Scenario[INDEX_SELFPOWER_DUAL]; | ||
743 | _current_scenario_idx = INDEX_SELFPOWER_DUAL; | ||
744 | break; | ||
745 | case AVDEC_ENABLE | TS1_TS2_PORT | SELF_POWER: | ||
746 | cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].speed = | ||
747 | usb_speed; | ||
748 | cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].ts1_source = | ||
749 | ts1_source; | ||
750 | cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].ts2_source = | ||
751 | ts2_source; | ||
752 | cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE].analog_source = | ||
753 | analog_source; | ||
754 | p_pcb_info = &cx231xx_Scenario[INDEX_SELFPOWER_TRIPLE]; | ||
755 | _current_scenario_idx = INDEX_SELFPOWER_TRIPLE; | ||
756 | break; | ||
757 | case AVDEC_ENABLE | TS1VIP_TS2_PORT | SELF_POWER: | ||
758 | cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR].speed = | ||
759 | usb_speed; | ||
760 | cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR]. | ||
761 | analog_source = analog_source; | ||
762 | p_pcb_info = | ||
763 | &cx231xx_Scenario[INDEX_SELFPOWER_COMPRESSOR]; | ||
764 | _current_scenario_idx = INDEX_SELFPOWER_COMPRESSOR; | ||
765 | break; | ||
766 | default: | ||
767 | cx231xx_info("bad senario!!!!!\n"); | ||
768 | cx231xx_info("config_info=%x\n", | ||
769 | (config_info & SELFPOWER_MASK)); | ||
770 | return 1; | ||
771 | } | ||
772 | } | ||
773 | |||
774 | dev->current_scenario_idx = _current_scenario_idx; | ||
775 | |||
776 | memcpy(&dev->current_pcb_config, p_pcb_info, | ||
777 | sizeof(struct pcb_config)); | ||
778 | |||
779 | if (pcb_debug) { | ||
780 | cx231xx_info("SC(0x00) register = 0x%x\n", config_info); | ||
781 | cx231xx_info("scenario %d\n", | ||
782 | (dev->current_pcb_config.index) + 1); | ||
783 | cx231xx_info("type=%x\n", dev->current_pcb_config.type); | ||
784 | cx231xx_info("mode=%x\n", dev->current_pcb_config.mode); | ||
785 | cx231xx_info("speed=%x\n", dev->current_pcb_config.speed); | ||
786 | cx231xx_info("ts1_source=%x\n", | ||
787 | dev->current_pcb_config.ts1_source); | ||
788 | cx231xx_info("ts2_source=%x\n", | ||
789 | dev->current_pcb_config.ts2_source); | ||
790 | cx231xx_info("analog_source=%x\n", | ||
791 | dev->current_pcb_config.analog_source); | ||
792 | } | ||
793 | |||
794 | return 0; | ||
795 | } | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h new file mode 100644 index 000000000000..f5e46e89f3ab --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | cx231xx-pcb-cfg.h - driver for Conexant | ||
3 | Cx23100/101/102 USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _PCB_CONFIG_H_ | ||
23 | #define _PCB_CONFIG_H_ | ||
24 | |||
25 | #include <linux/init.h> | ||
26 | #include <linux/module.h> | ||
27 | |||
28 | /*************************************************************************** | ||
29 | * Class Information * | ||
30 | ***************************************************************************/ | ||
31 | #define CLASS_DEFAULT 0xFF | ||
32 | |||
33 | enum VENDOR_REQUEST_TYPE { | ||
34 | /* Set/Get I2C */ | ||
35 | VRT_SET_I2C0 = 0x0, | ||
36 | VRT_SET_I2C1 = 0x1, | ||
37 | VRT_SET_I2C2 = 0x2, | ||
38 | VRT_GET_I2C0 = 0x4, | ||
39 | VRT_GET_I2C1 = 0x5, | ||
40 | VRT_GET_I2C2 = 0x6, | ||
41 | |||
42 | /* Set/Get GPIO */ | ||
43 | VRT_SET_GPIO = 0x8, | ||
44 | VRT_GET_GPIO = 0x9, | ||
45 | |||
46 | /* Set/Get GPIE */ | ||
47 | VRT_SET_GPIE = 0xA, | ||
48 | VRT_GET_GPIE = 0xB, | ||
49 | |||
50 | /* Set/Get Register Control/Status */ | ||
51 | VRT_SET_REGISTER = 0xC, | ||
52 | VRT_GET_REGISTER = 0xD, | ||
53 | |||
54 | /* Get Extended Compat ID Descriptor */ | ||
55 | VRT_GET_EXTCID_DESC = 0xFF, | ||
56 | }; | ||
57 | |||
58 | enum BYTE_ENABLE_MASK { | ||
59 | ENABLE_ONE_BYTE = 0x1, | ||
60 | ENABLE_TWE_BYTE = 0x3, | ||
61 | ENABLE_THREE_BYTE = 0x7, | ||
62 | ENABLE_FOUR_BYTE = 0xF, | ||
63 | }; | ||
64 | |||
65 | #define SPEED_MASK 0x1 | ||
66 | enum USB_SPEED{ | ||
67 | FULL_SPEED = 0x0, /* 0: full speed */ | ||
68 | HIGH_SPEED = 0x1 /* 1: high speed */ | ||
69 | }; | ||
70 | |||
71 | enum _true_false{ | ||
72 | FALSE = 0, | ||
73 | TRUE = 1 | ||
74 | }; | ||
75 | |||
76 | #define TS_MASK 0x6 | ||
77 | enum TS_PORT{ | ||
78 | NO_TS_PORT = 0x0, /* 2'b00: Neither port used. PCB not a Hybrid, | ||
79 | only offers Analog TV or Video */ | ||
80 | TS1_PORT = 0x4, /* 2'b10: TS1 Input (Hybrid mode : | ||
81 | Digital or External Analog/Compressed source) */ | ||
82 | TS1_TS2_PORT = 0x6, /* 2'b11: TS1 & TS2 Inputs | ||
83 | (Dual inputs from Digital and/or | ||
84 | External Analog/Compressed sources) */ | ||
85 | TS1_EXT_CLOCK = 0x6, /* 2'b11: TS1 & TS2 as selector | ||
86 | to external clock */ | ||
87 | TS1VIP_TS2_PORT = 0x2 /* 2'b01: TS1 used as 656/VIP Output, | ||
88 | TS2 Input (from Compressor) */ | ||
89 | }; | ||
90 | |||
91 | #define EAVP_MASK 0x8 | ||
92 | enum EAV_PRESENT{ | ||
93 | NO_EXTERNAL_AV = 0x0, /* 0: No External A/V inputs | ||
94 | (no need for i2s blcok), | ||
95 | Analog Tuner must be present */ | ||
96 | EXTERNAL_AV = 0x8 /* 1: External A/V inputs | ||
97 | present (requires i2s blk) */ | ||
98 | }; | ||
99 | |||
100 | #define ATM_MASK 0x30 | ||
101 | enum AT_MODE{ | ||
102 | DIF_TUNER = 0x30, /* 2'b11: IF Tuner (requires use of DIF) */ | ||
103 | BASEBAND_SOUND = 0x20, /* 2'b10: Baseband Composite & | ||
104 | Sound-IF Signals present */ | ||
105 | NO_TUNER = 0x10 /* 2'b0x: No Analog Tuner present */ | ||
106 | }; | ||
107 | |||
108 | #define PWR_SEL_MASK 0x40 | ||
109 | enum POWE_TYPE{ | ||
110 | SELF_POWER = 0x0, /* 0: self power */ | ||
111 | BUS_POWER = 0x40 /* 1: bus power */ | ||
112 | }; | ||
113 | |||
114 | enum USB_POWE_TYPE{ | ||
115 | USB_SELF_POWER = 0, | ||
116 | USB_BUS_POWER | ||
117 | }; | ||
118 | |||
119 | #define BO_0_MASK 0x80 | ||
120 | enum AVDEC_STATUS{ | ||
121 | AVDEC_DISABLE = 0x0, /* 0: A/V Decoder Disabled */ | ||
122 | AVDEC_ENABLE = 0x80 /* 1: A/V Decoder Enabled */ | ||
123 | }; | ||
124 | |||
125 | #define BO_1_MASK 0x100 | ||
126 | |||
127 | #define BUSPOWER_MASK 0xC4 /* for Polaris spec 0.8 */ | ||
128 | #define SELFPOWER_MASK 0x86 | ||
129 | |||
130 | /***************************************************************************/ | ||
131 | #define NOT_DECIDE_YET 0xFE | ||
132 | #define NOT_SUPPORTED 0xFF | ||
133 | |||
134 | /*************************************************************************** | ||
135 | * for mod field use * | ||
136 | ***************************************************************************/ | ||
137 | #define MOD_DIGITAL 0x1 | ||
138 | #define MOD_ANALOG 0x2 | ||
139 | #define MOD_DIF 0x4 | ||
140 | #define MOD_EXTERNAL 0x8 | ||
141 | #define CAP_ALL_MOD 0x0f | ||
142 | |||
143 | /*************************************************************************** | ||
144 | * source define * | ||
145 | ***************************************************************************/ | ||
146 | #define SOURCE_DIGITAL 0x1 | ||
147 | #define SOURCE_ANALOG 0x2 | ||
148 | #define SOURCE_DIF 0x4 | ||
149 | #define SOURCE_EXTERNAL 0x8 | ||
150 | #define SOURCE_TS_BDA 0x10 | ||
151 | #define SOURCE_TS_ENCODE 0x20 | ||
152 | #define SOURCE_TS_EXTERNAL 0x40 | ||
153 | |||
154 | /*************************************************************************** | ||
155 | * interface information define * | ||
156 | ***************************************************************************/ | ||
157 | struct INTERFACE_INFO { | ||
158 | u8 interrupt_index; | ||
159 | u8 ts1_index; | ||
160 | u8 ts2_index; | ||
161 | u8 audio_index; | ||
162 | u8 video_index; | ||
163 | u8 vanc_index; /* VBI */ | ||
164 | u8 hanc_index; /* Sliced CC */ | ||
165 | u8 ir_index; | ||
166 | }; | ||
167 | |||
168 | enum INDEX_INTERFACE_INFO{ | ||
169 | INDEX_INTERRUPT = 0x0, | ||
170 | INDEX_TS1, | ||
171 | INDEX_TS2, | ||
172 | INDEX_AUDIO, | ||
173 | INDEX_VIDEO, | ||
174 | INDEX_VANC, | ||
175 | INDEX_HANC, | ||
176 | INDEX_IR, | ||
177 | }; | ||
178 | |||
179 | /*************************************************************************** | ||
180 | * configuration information define * | ||
181 | ***************************************************************************/ | ||
182 | struct CONFIG_INFO { | ||
183 | u8 config_index; | ||
184 | struct INTERFACE_INFO interface_info; | ||
185 | }; | ||
186 | |||
187 | struct pcb_config { | ||
188 | u8 index; | ||
189 | u8 type; /* bus power or self power, | ||
190 | self power--0, bus_power--1 */ | ||
191 | u8 speed; /* usb speed, 2.0--1, 1.1--0 */ | ||
192 | u8 mode; /* digital , anlog, dif or external A/V */ | ||
193 | u32 ts1_source; /* three source -- BDA,External,encode */ | ||
194 | u32 ts2_source; | ||
195 | u32 analog_source; | ||
196 | u8 digital_index; /* bus-power used */ | ||
197 | u8 analog_index; /* bus-power used */ | ||
198 | u8 dif_index; /* bus-power used */ | ||
199 | u8 external_index; /* bus-power used */ | ||
200 | u8 config_num; /* current config num, 0,1,2, | ||
201 | for self-power, always 0 */ | ||
202 | struct CONFIG_INFO hs_config_info[3]; | ||
203 | struct CONFIG_INFO fs_config_info[3]; | ||
204 | }; | ||
205 | |||
206 | enum INDEX_PCB_CONFIG{ | ||
207 | INDEX_SELFPOWER_DIGITAL_ONLY = 0x0, | ||
208 | INDEX_SELFPOWER_DUAL_DIGITAL, | ||
209 | INDEX_SELFPOWER_ANALOG_ONLY, | ||
210 | INDEX_SELFPOWER_DUAL, | ||
211 | INDEX_SELFPOWER_TRIPLE, | ||
212 | INDEX_SELFPOWER_COMPRESSOR, | ||
213 | INDEX_BUSPOWER_DIGITAL_ONLY, | ||
214 | INDEX_BUSPOWER_ANALOG_ONLY, | ||
215 | INDEX_BUSPOWER_DIF_ONLY, | ||
216 | INDEX_BUSPOWER_EXTERNAL_ONLY, | ||
217 | INDEX_BUSPOWER_EXTERNAL_ANALOG, | ||
218 | INDEX_BUSPOWER_EXTERNAL_DIF, | ||
219 | INDEX_BUSPOWER_EXTERNAL_DIGITAL, | ||
220 | INDEX_BUSPOWER_DIGITAL_ANALOG, | ||
221 | INDEX_BUSPOWER_DIGITAL_DIF, | ||
222 | INDEX_BUSPOWER_DIGITAL_ANALOG_EXTERNAL, | ||
223 | INDEX_BUSPOWER_DIGITAL_DIF_EXTERNAL, | ||
224 | }; | ||
225 | |||
226 | /***************************************************************************/ | ||
227 | struct cx231xx; | ||
228 | |||
229 | u32 initialize_cx231xx(struct cx231xx *p_dev); | ||
230 | |||
231 | #endif | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-reg.h b/drivers/media/usb/cx231xx/cx231xx-reg.h new file mode 100644 index 000000000000..750c5d37d569 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-reg.h | |||
@@ -0,0 +1,1564 @@ | |||
1 | /* | ||
2 | cx231xx-reg.h - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _CX231XX_REG_H | ||
23 | #define _CX231XX_REG_H | ||
24 | |||
25 | /***************************************************************************** | ||
26 | * VBI codes * | ||
27 | *****************************************************************************/ | ||
28 | |||
29 | #define SAV_ACTIVE_VIDEO_FIELD1 0x80 | ||
30 | #define EAV_ACTIVE_VIDEO_FIELD1 0x90 | ||
31 | |||
32 | #define SAV_ACTIVE_VIDEO_FIELD2 0xc0 | ||
33 | #define EAV_ACTIVE_VIDEO_FIELD2 0xd0 | ||
34 | |||
35 | #define SAV_VBLANK_FIELD1 0xa0 | ||
36 | #define EAV_VBLANK_FIELD1 0xb0 | ||
37 | |||
38 | #define SAV_VBLANK_FIELD2 0xe0 | ||
39 | #define EAV_VBLANK_FIELD2 0xf0 | ||
40 | |||
41 | #define SAV_VBI_FIELD1 0x20 | ||
42 | #define EAV_VBI_FIELD1 0x30 | ||
43 | |||
44 | #define SAV_VBI_FIELD2 0x60 | ||
45 | #define EAV_VBI_FIELD2 0x70 | ||
46 | |||
47 | /*****************************************************************************/ | ||
48 | /* Audio ADC Registers */ | ||
49 | #define CH_PWR_CTRL1 0x0000000e | ||
50 | #define CH_PWR_CTRL2 0x0000000f | ||
51 | /*****************************************************************************/ | ||
52 | |||
53 | #define HOST_REG1 0x000 | ||
54 | #define FLD_FORCE_CHIP_SEL 0x80 | ||
55 | #define FLD_AUTO_INC_DIS 0x20 | ||
56 | #define FLD_PREFETCH_EN 0x10 | ||
57 | /* Reserved [2:3] */ | ||
58 | #define FLD_DIGITAL_PWR_DN 0x02 | ||
59 | #define FLD_SLEEP 0x01 | ||
60 | |||
61 | /*****************************************************************************/ | ||
62 | #define HOST_REG2 0x001 | ||
63 | |||
64 | /*****************************************************************************/ | ||
65 | #define HOST_REG3 0x002 | ||
66 | |||
67 | /*****************************************************************************/ | ||
68 | /* added for polaris */ | ||
69 | #define GPIO_PIN_CTL0 0x3 | ||
70 | #define GPIO_PIN_CTL1 0x4 | ||
71 | #define GPIO_PIN_CTL2 0x5 | ||
72 | #define GPIO_PIN_CTL3 0x6 | ||
73 | #define TS1_PIN_CTL0 0x7 | ||
74 | #define TS1_PIN_CTL1 0x8 | ||
75 | /*****************************************************************************/ | ||
76 | |||
77 | #define FLD_CLK_IN_EN 0x80 | ||
78 | #define FLD_XTAL_CTRL 0x70 | ||
79 | #define FLD_BB_CLK_MODE 0x0C | ||
80 | #define FLD_REF_DIV_PLL 0x02 | ||
81 | #define FLD_REF_SEL_PLL1 0x01 | ||
82 | |||
83 | /*****************************************************************************/ | ||
84 | #define CHIP_CTRL 0x100 | ||
85 | /* Reserved [27] */ | ||
86 | /* Reserved [31:21] */ | ||
87 | #define FLD_CHIP_ACFG_DIS 0x00100000 | ||
88 | /* Reserved [19] */ | ||
89 | #define FLD_DUAL_MODE_ADC2 0x00040000 | ||
90 | #define FLD_SIF_EN 0x00020000 | ||
91 | #define FLD_SOFT_RST 0x00010000 | ||
92 | #define FLD_DEVICE_ID 0x0000ffff | ||
93 | |||
94 | /*****************************************************************************/ | ||
95 | #define AFE_CTRL 0x104 | ||
96 | #define AFE_CTRL_C2HH_SRC_CTRL 0x104 | ||
97 | #define FLD_DIF_OUT_SEL 0xc0000000 | ||
98 | #define FLD_AUX_PLL_CLK_ALT_SEL 0x3c000000 | ||
99 | #define FLD_UV_ORDER_MODE 0x02000000 | ||
100 | #define FLD_FUNC_MODE 0x01800000 | ||
101 | #define FLD_ROT1_PHASE_CTL 0x007f8000 | ||
102 | #define FLD_AUD_IN_SEL 0x00004000 | ||
103 | #define FLD_LUMA_IN_SEL 0x00002000 | ||
104 | #define FLD_CHROMA_IN_SEL 0x00001000 | ||
105 | /* reserve [11:10] */ | ||
106 | #define FLD_INV_SPEC_DIS 0x00000200 | ||
107 | #define FLD_VGA_SEL_CH3 0x00000100 | ||
108 | #define FLD_VGA_SEL_CH2 0x00000080 | ||
109 | #define FLD_VGA_SEL_CH1 0x00000040 | ||
110 | #define FLD_DCR_BYP_CH1 0x00000020 | ||
111 | #define FLD_DCR_BYP_CH2 0x00000010 | ||
112 | #define FLD_DCR_BYP_CH3 0x00000008 | ||
113 | #define FLD_EN_12DB_CH3 0x00000004 | ||
114 | #define FLD_EN_12DB_CH2 0x00000002 | ||
115 | #define FLD_EN_12DB_CH1 0x00000001 | ||
116 | |||
117 | /* redefine in Cx231xx */ | ||
118 | /*****************************************************************************/ | ||
119 | #define DC_CTRL1 0x108 | ||
120 | /* reserve [31:30] */ | ||
121 | #define FLD_CLAMP_LVL_CH1 0x3fff8000 | ||
122 | #define FLD_CLAMP_LVL_CH2 0x00007fff | ||
123 | /*****************************************************************************/ | ||
124 | |||
125 | /*****************************************************************************/ | ||
126 | #define DC_CTRL2 0x10c | ||
127 | /* reserve [31:28] */ | ||
128 | #define FLD_CLAMP_LVL_CH3 0x00fffe00 | ||
129 | #define FLD_CLAMP_WIND_LENTH 0x000001e0 | ||
130 | #define FLD_C2HH_SAT_MIN 0x0000001e | ||
131 | #define FLD_FLT_BYP_SEL 0x00000001 | ||
132 | /*****************************************************************************/ | ||
133 | |||
134 | /*****************************************************************************/ | ||
135 | #define DC_CTRL3 0x110 | ||
136 | /* reserve [31:16] */ | ||
137 | #define FLD_ERR_GAIN_CTL 0x00070000 | ||
138 | #define FLD_LPF_MIN 0x0000ffff | ||
139 | /*****************************************************************************/ | ||
140 | |||
141 | /*****************************************************************************/ | ||
142 | #define DC_CTRL4 0x114 | ||
143 | /* reserve [31:31] */ | ||
144 | #define FLD_INTG_CH1 0x7fffffff | ||
145 | /*****************************************************************************/ | ||
146 | |||
147 | /*****************************************************************************/ | ||
148 | #define DC_CTRL5 0x118 | ||
149 | /* reserve [31:31] */ | ||
150 | #define FLD_INTG_CH2 0x7fffffff | ||
151 | /*****************************************************************************/ | ||
152 | |||
153 | /*****************************************************************************/ | ||
154 | #define DC_CTRL6 0x11c | ||
155 | /* reserve [31:31] */ | ||
156 | #define FLD_INTG_CH3 0x7fffffff | ||
157 | /*****************************************************************************/ | ||
158 | |||
159 | /*****************************************************************************/ | ||
160 | #define PIN_CTRL 0x120 | ||
161 | #define FLD_OEF_AGC_RF 0x00000001 | ||
162 | #define FLD_OEF_AGC_IFVGA 0x00000002 | ||
163 | #define FLD_OEF_AGC_IF 0x00000004 | ||
164 | #define FLD_REG_BO_PUD 0x80000000 | ||
165 | #define FLD_IR_IRQ_STAT 0x40000000 | ||
166 | #define FLD_AUD_IRQ_STAT 0x20000000 | ||
167 | #define FLD_VID_IRQ_STAT 0x10000000 | ||
168 | /* Reserved [27:26] */ | ||
169 | #define FLD_IRQ_N_OUT_EN 0x02000000 | ||
170 | #define FLD_IRQ_N_POLAR 0x01000000 | ||
171 | /* Reserved [23:6] */ | ||
172 | #define FLD_OE_AUX_PLL_CLK 0x00000020 | ||
173 | #define FLD_OE_I2S_BCLK 0x00000010 | ||
174 | #define FLD_OE_I2S_WCLK 0x00000008 | ||
175 | #define FLD_OE_AGC_IF 0x00000004 | ||
176 | #define FLD_OE_AGC_IFVGA 0x00000002 | ||
177 | #define FLD_OE_AGC_RF 0x00000001 | ||
178 | |||
179 | /*****************************************************************************/ | ||
180 | #define AUD_IO_CTRL 0x124 | ||
181 | /* Reserved [31:8] */ | ||
182 | #define FLD_I2S_PORT_DIR 0x00000080 | ||
183 | #define FLD_I2S_OUT_SRC 0x00000040 | ||
184 | #define FLD_AUD_CHAN3_SRC 0x00000030 | ||
185 | #define FLD_AUD_CHAN2_SRC 0x0000000c | ||
186 | #define FLD_AUD_CHAN1_SRC 0x00000003 | ||
187 | |||
188 | /*****************************************************************************/ | ||
189 | #define AUD_LOCK1 0x128 | ||
190 | #define FLD_AUD_LOCK_KI_SHIFT 0xc0000000 | ||
191 | #define FLD_AUD_LOCK_KD_SHIFT 0x30000000 | ||
192 | /* Reserved [27:25] */ | ||
193 | #define FLD_EN_AV_LOCK 0x01000000 | ||
194 | #define FLD_VID_COUNT 0x00ffffff | ||
195 | |||
196 | /*****************************************************************************/ | ||
197 | #define AUD_LOCK2 0x12c | ||
198 | #define FLD_AUD_LOCK_KI_MULT 0xf0000000 | ||
199 | #define FLD_AUD_LOCK_KD_MULT 0x0F000000 | ||
200 | /* Reserved [23:22] */ | ||
201 | #define FLD_AUD_LOCK_FREQ_SHIFT 0x00300000 | ||
202 | #define FLD_AUD_COUNT 0x000fffff | ||
203 | |||
204 | /*****************************************************************************/ | ||
205 | #define AFE_DIAG_CTRL1 0x134 | ||
206 | /* Reserved [31:16] */ | ||
207 | #define FLD_CUV_DLY_LENGTH 0x0000ff00 | ||
208 | #define FLD_YC_DLY_LENGTH 0x000000ff | ||
209 | |||
210 | /*****************************************************************************/ | ||
211 | /* Poalris redefine */ | ||
212 | #define AFE_DIAG_CTRL3 0x138 | ||
213 | /* Reserved [31:26] */ | ||
214 | #define FLD_AUD_DUAL_FLAG_POL 0x02000000 | ||
215 | #define FLD_VID_DUAL_FLAG_POL 0x01000000 | ||
216 | /* Reserved [23:23] */ | ||
217 | #define FLD_COL_CLAMP_DIS_CH1 0x00400000 | ||
218 | #define FLD_COL_CLAMP_DIS_CH2 0x00200000 | ||
219 | #define FLD_COL_CLAMP_DIS_CH3 0x00100000 | ||
220 | |||
221 | #define TEST_CTRL1 0x144 | ||
222 | /* Reserved [31:29] */ | ||
223 | #define FLD_LBIST_EN 0x10000000 | ||
224 | /* Reserved [27:10] */ | ||
225 | #define FLD_FI_BIST_INTR_R 0x0000200 | ||
226 | #define FLD_FI_BIST_INTR_L 0x0000100 | ||
227 | #define FLD_BIST_FAIL_AUD_PLL 0x0000080 | ||
228 | #define FLD_BIST_INTR_AUD_PLL 0x0000040 | ||
229 | #define FLD_BIST_FAIL_VID_PLL 0x0000020 | ||
230 | #define FLD_BIST_INTR_VID_PLL 0x0000010 | ||
231 | /* Reserved [3:1] */ | ||
232 | #define FLD_CIR_TEST_DIS 0x00000001 | ||
233 | |||
234 | /*****************************************************************************/ | ||
235 | #define TEST_CTRL2 0x148 | ||
236 | #define FLD_TSXCLK_POL_CTL 0x80000000 | ||
237 | #define FLD_ISO_CTL_SEL 0x40000000 | ||
238 | #define FLD_ISO_CTL_EN 0x20000000 | ||
239 | #define FLD_BIST_DEBUGZ 0x10000000 | ||
240 | #define FLD_AUD_BIST_TEST_H 0x0f000000 | ||
241 | /* Reserved [23:22] */ | ||
242 | #define FLD_FLTRN_BIST_TEST_H 0x00020000 | ||
243 | #define FLD_VID_BIST_TEST_H 0x00010000 | ||
244 | /* Reserved [19:17] */ | ||
245 | #define FLD_BIST_TEST_H 0x00010000 | ||
246 | /* Reserved [15:13] */ | ||
247 | #define FLD_TAB_EN 0x00001000 | ||
248 | /* Reserved [11:0] */ | ||
249 | |||
250 | /*****************************************************************************/ | ||
251 | #define BIST_STAT 0x14c | ||
252 | #define FLD_AUD_BIST_FAIL_H 0xfff00000 | ||
253 | #define FLD_FLTRN_BIST_FAIL_H 0x00180000 | ||
254 | #define FLD_VID_BIST_FAIL_H 0x00070000 | ||
255 | #define FLD_AUD_BIST_TST_DONE 0x0000fff0 | ||
256 | #define FLD_FLTRN_BIST_TST_DONE 0x00000008 | ||
257 | #define FLD_VID_BIST_TST_DONE 0x00000007 | ||
258 | |||
259 | /*****************************************************************************/ | ||
260 | /* DirectIF registers definition have been moved to DIF_reg.h */ | ||
261 | /*****************************************************************************/ | ||
262 | #define MODE_CTRL 0x400 | ||
263 | #define FLD_AFD_PAL60_DIS 0x20000000 | ||
264 | #define FLD_AFD_FORCE_SECAM 0x10000000 | ||
265 | #define FLD_AFD_FORCE_PALNC 0x08000000 | ||
266 | #define FLD_AFD_FORCE_PAL 0x04000000 | ||
267 | #define FLD_AFD_PALM_SEL 0x03000000 | ||
268 | #define FLD_CKILL_MODE 0x00300000 | ||
269 | #define FLD_COMB_NOTCH_MODE 0x00c00000 /* bit[19:18] */ | ||
270 | #define FLD_CLR_LOCK_STAT 0x00020000 | ||
271 | #define FLD_FAST_LOCK_MD 0x00010000 | ||
272 | #define FLD_WCEN 0x00008000 | ||
273 | #define FLD_CAGCEN 0x00004000 | ||
274 | #define FLD_CKILLEN 0x00002000 | ||
275 | #define FLD_AUTO_SC_LOCK 0x00001000 | ||
276 | #define FLD_MAN_SC_FAST_LOCK 0x00000800 | ||
277 | #define FLD_INPUT_MODE 0x00000600 | ||
278 | #define FLD_AFD_ACQUIRE 0x00000100 | ||
279 | #define FLD_AFD_NTSC_SEL 0x00000080 | ||
280 | #define FLD_AFD_PAL_SEL 0x00000040 | ||
281 | #define FLD_ACFG_DIS 0x00000020 | ||
282 | #define FLD_SQ_PIXEL 0x00000010 | ||
283 | #define FLD_VID_FMT_SEL 0x0000000f | ||
284 | |||
285 | /*****************************************************************************/ | ||
286 | #define OUT_CTRL1 0x404 | ||
287 | #define FLD_POLAR 0x7f000000 | ||
288 | /* Reserved [23] */ | ||
289 | #define FLD_RND_MODE 0x00600000 | ||
290 | #define FLD_VIPCLAMP_EN 0x00100000 | ||
291 | #define FLD_VIPBLANK_EN 0x00080000 | ||
292 | #define FLD_VIP_OPT_AL 0x00040000 | ||
293 | #define FLD_IDID0_SOURCE 0x00020000 | ||
294 | #define FLD_DCMODE 0x00010000 | ||
295 | #define FLD_CLK_GATING 0x0000c000 | ||
296 | #define FLD_CLK_INVERT 0x00002000 | ||
297 | #define FLD_HSFMT 0x00001000 | ||
298 | #define FLD_VALIDFMT 0x00000800 | ||
299 | #define FLD_ACTFMT 0x00000400 | ||
300 | #define FLD_SWAPRAW 0x00000200 | ||
301 | #define FLD_CLAMPRAW_EN 0x00000100 | ||
302 | #define FLD_BLUE_FIELD_EN 0x00000080 | ||
303 | #define FLD_BLUE_FIELD_ACT 0x00000040 | ||
304 | #define FLD_TASKBIT_VAL 0x00000020 | ||
305 | #define FLD_ANC_DATA_EN 0x00000010 | ||
306 | #define FLD_VBIHACTRAW_EN 0x00000008 | ||
307 | #define FLD_MODE10B 0x00000004 | ||
308 | #define FLD_OUT_MODE 0x00000003 | ||
309 | |||
310 | /*****************************************************************************/ | ||
311 | #define OUT_CTRL2 0x408 | ||
312 | #define FLD_AUD_GRP 0xc0000000 | ||
313 | #define FLD_SAMPLE_RATE 0x30000000 | ||
314 | #define FLD_AUD_ANC_EN 0x08000000 | ||
315 | #define FLD_EN_C 0x04000000 | ||
316 | #define FLD_EN_B 0x02000000 | ||
317 | #define FLD_EN_A 0x01000000 | ||
318 | /* Reserved [23:20] */ | ||
319 | #define FLD_IDID1_LSB 0x000c0000 | ||
320 | #define FLD_IDID0_LSB 0x00030000 | ||
321 | #define FLD_IDID1_MSB 0x0000ff00 | ||
322 | #define FLD_IDID0_MSB 0x000000ff | ||
323 | |||
324 | /*****************************************************************************/ | ||
325 | #define GEN_STAT 0x40c | ||
326 | #define FLD_VCR_DETECT 0x00800000 | ||
327 | #define FLD_SPECIAL_PLAY_N 0x00400000 | ||
328 | #define FLD_VPRES 0x00200000 | ||
329 | #define FLD_AGC_LOCK 0x00100000 | ||
330 | #define FLD_CSC_LOCK 0x00080000 | ||
331 | #define FLD_VLOCK 0x00040000 | ||
332 | #define FLD_SRC_LOCK 0x00020000 | ||
333 | #define FLD_HLOCK 0x00010000 | ||
334 | #define FLD_VSYNC_N 0x00008000 | ||
335 | #define FLD_SRC_FIFO_UFLOW 0x00004000 | ||
336 | #define FLD_SRC_FIFO_OFLOW 0x00002000 | ||
337 | #define FLD_FIELD 0x00001000 | ||
338 | #define FLD_AFD_FMT_STAT 0x00000f00 | ||
339 | #define FLD_MV_TYPE2_PAIR 0x00000080 | ||
340 | #define FLD_MV_T3CS 0x00000040 | ||
341 | #define FLD_MV_CS 0x00000020 | ||
342 | #define FLD_MV_PSP 0x00000010 | ||
343 | /* Reserved [3] */ | ||
344 | #define FLD_MV_CDAT 0x00000003 | ||
345 | |||
346 | /*****************************************************************************/ | ||
347 | #define INT_STAT_MASK 0x410 | ||
348 | #define FLD_COMB_3D_FIFO_MSK 0x80000000 | ||
349 | #define FLD_WSS_DAT_AVAIL_MSK 0x40000000 | ||
350 | #define FLD_GS2_DAT_AVAIL_MSK 0x20000000 | ||
351 | #define FLD_GS1_DAT_AVAIL_MSK 0x10000000 | ||
352 | #define FLD_CC_DAT_AVAIL_MSK 0x08000000 | ||
353 | #define FLD_VPRES_CHANGE_MSK 0x04000000 | ||
354 | #define FLD_MV_CHANGE_MSK 0x02000000 | ||
355 | #define FLD_END_VBI_EVEN_MSK 0x01000000 | ||
356 | #define FLD_END_VBI_ODD_MSK 0x00800000 | ||
357 | #define FLD_FMT_CHANGE_MSK 0x00400000 | ||
358 | #define FLD_VSYNC_TRAIL_MSK 0x00200000 | ||
359 | #define FLD_HLOCK_CHANGE_MSK 0x00100000 | ||
360 | #define FLD_VLOCK_CHANGE_MSK 0x00080000 | ||
361 | #define FLD_CSC_LOCK_CHANGE_MSK 0x00040000 | ||
362 | #define FLD_SRC_FIFO_UFLOW_MSK 0x00020000 | ||
363 | #define FLD_SRC_FIFO_OFLOW_MSK 0x00010000 | ||
364 | #define FLD_COMB_3D_FIFO_STAT 0x00008000 | ||
365 | #define FLD_WSS_DAT_AVAIL_STAT 0x00004000 | ||
366 | #define FLD_GS2_DAT_AVAIL_STAT 0x00002000 | ||
367 | #define FLD_GS1_DAT_AVAIL_STAT 0x00001000 | ||
368 | #define FLD_CC_DAT_AVAIL_STAT 0x00000800 | ||
369 | #define FLD_VPRES_CHANGE_STAT 0x00000400 | ||
370 | #define FLD_MV_CHANGE_STAT 0x00000200 | ||
371 | #define FLD_END_VBI_EVEN_STAT 0x00000100 | ||
372 | #define FLD_END_VBI_ODD_STAT 0x00000080 | ||
373 | #define FLD_FMT_CHANGE_STAT 0x00000040 | ||
374 | #define FLD_VSYNC_TRAIL_STAT 0x00000020 | ||
375 | #define FLD_HLOCK_CHANGE_STAT 0x00000010 | ||
376 | #define FLD_VLOCK_CHANGE_STAT 0x00000008 | ||
377 | #define FLD_CSC_LOCK_CHANGE_STAT 0x00000004 | ||
378 | #define FLD_SRC_FIFO_UFLOW_STAT 0x00000002 | ||
379 | #define FLD_SRC_FIFO_OFLOW_STAT 0x00000001 | ||
380 | |||
381 | /*****************************************************************************/ | ||
382 | #define LUMA_CTRL 0x414 | ||
383 | #define BRIGHTNESS_CTRL_BYTE 0x414 | ||
384 | #define CONTRAST_CTRL_BYTE 0x415 | ||
385 | #define LUMA_CTRL_BYTE_3 0x416 | ||
386 | #define FLD_LUMA_CORE_SEL 0x00c00000 | ||
387 | #define FLD_RANGE 0x00300000 | ||
388 | /* Reserved [19] */ | ||
389 | #define FLD_PEAK_EN 0x00040000 | ||
390 | #define FLD_PEAK_SEL 0x00030000 | ||
391 | #define FLD_CNTRST 0x0000ff00 | ||
392 | #define FLD_BRITE 0x000000ff | ||
393 | |||
394 | /*****************************************************************************/ | ||
395 | #define HSCALE_CTRL 0x418 | ||
396 | #define FLD_HFILT 0x03000000 | ||
397 | #define FLD_HSCALE 0x00ffffff | ||
398 | |||
399 | /*****************************************************************************/ | ||
400 | #define VSCALE_CTRL 0x41c | ||
401 | #define FLD_LINE_AVG_DIS 0x01000000 | ||
402 | /* Reserved [23:20] */ | ||
403 | #define FLD_VS_INTRLACE 0x00080000 | ||
404 | #define FLD_VFILT 0x00070000 | ||
405 | /* Reserved [15:13] */ | ||
406 | #define FLD_VSCALE 0x00001fff | ||
407 | |||
408 | /*****************************************************************************/ | ||
409 | #define CHROMA_CTRL 0x420 | ||
410 | #define USAT_CTRL_BYTE 0x420 | ||
411 | #define VSAT_CTRL_BYTE 0x421 | ||
412 | #define HUE_CTRL_BYTE 0x422 | ||
413 | #define FLD_C_LPF_EN 0x20000000 | ||
414 | #define FLD_CHR_DELAY 0x1c000000 | ||
415 | #define FLD_C_CORE_SEL 0x03000000 | ||
416 | #define FLD_HUE 0x00ff0000 | ||
417 | #define FLD_VSAT 0x0000ff00 | ||
418 | #define FLD_USAT 0x000000ff | ||
419 | |||
420 | /*****************************************************************************/ | ||
421 | #define VBI_LINE_CTRL1 0x424 | ||
422 | #define FLD_VBI_MD_LINE4 0xff000000 | ||
423 | #define FLD_VBI_MD_LINE3 0x00ff0000 | ||
424 | #define FLD_VBI_MD_LINE2 0x0000ff00 | ||
425 | #define FLD_VBI_MD_LINE1 0x000000ff | ||
426 | |||
427 | /*****************************************************************************/ | ||
428 | #define VBI_LINE_CTRL2 0x428 | ||
429 | #define FLD_VBI_MD_LINE8 0xff000000 | ||
430 | #define FLD_VBI_MD_LINE7 0x00ff0000 | ||
431 | #define FLD_VBI_MD_LINE6 0x0000ff00 | ||
432 | #define FLD_VBI_MD_LINE5 0x000000ff | ||
433 | |||
434 | /*****************************************************************************/ | ||
435 | #define VBI_LINE_CTRL3 0x42c | ||
436 | #define FLD_VBI_MD_LINE12 0xff000000 | ||
437 | #define FLD_VBI_MD_LINE11 0x00ff0000 | ||
438 | #define FLD_VBI_MD_LINE10 0x0000ff00 | ||
439 | #define FLD_VBI_MD_LINE9 0x000000ff | ||
440 | |||
441 | /*****************************************************************************/ | ||
442 | #define VBI_LINE_CTRL4 0x430 | ||
443 | #define FLD_VBI_MD_LINE16 0xff000000 | ||
444 | #define FLD_VBI_MD_LINE15 0x00ff0000 | ||
445 | #define FLD_VBI_MD_LINE14 0x0000ff00 | ||
446 | #define FLD_VBI_MD_LINE13 0x000000ff | ||
447 | |||
448 | /*****************************************************************************/ | ||
449 | #define VBI_LINE_CTRL5 0x434 | ||
450 | #define FLD_VBI_MD_LINE17 0x000000ff | ||
451 | |||
452 | /*****************************************************************************/ | ||
453 | #define VBI_FC_CFG 0x438 | ||
454 | #define FLD_FC_ALT2 0xff000000 | ||
455 | #define FLD_FC_ALT1 0x00ff0000 | ||
456 | #define FLD_FC_ALT2_TYPE 0x0000f000 | ||
457 | #define FLD_FC_ALT1_TYPE 0x00000f00 | ||
458 | /* Reserved [7:1] */ | ||
459 | #define FLD_FC_SEARCH_MODE 0x00000001 | ||
460 | |||
461 | /*****************************************************************************/ | ||
462 | #define VBI_MISC_CFG1 0x43c | ||
463 | #define FLD_TTX_PKTADRU 0xfff00000 | ||
464 | #define FLD_TTX_PKTADRL 0x000fff00 | ||
465 | /* Reserved [7:6] */ | ||
466 | #define FLD_MOJI_PACK_DIS 0x00000020 | ||
467 | #define FLD_VPS_DEC_DIS 0x00000010 | ||
468 | #define FLD_CRI_MARG_SCALE 0x0000000c | ||
469 | #define FLD_EDGE_RESYNC_EN 0x00000002 | ||
470 | #define FLD_ADAPT_SLICE_DIS 0x00000001 | ||
471 | |||
472 | /*****************************************************************************/ | ||
473 | #define VBI_MISC_CFG2 0x440 | ||
474 | #define FLD_HAMMING_TYPE 0x0f000000 | ||
475 | /* Reserved [23:20] */ | ||
476 | #define FLD_WSS_FIFO_RST 0x00080000 | ||
477 | #define FLD_GS2_FIFO_RST 0x00040000 | ||
478 | #define FLD_GS1_FIFO_RST 0x00020000 | ||
479 | #define FLD_CC_FIFO_RST 0x00010000 | ||
480 | /* Reserved [15:12] */ | ||
481 | #define FLD_VBI3_SDID 0x00000f00 | ||
482 | #define FLD_VBI2_SDID 0x000000f0 | ||
483 | #define FLD_VBI1_SDID 0x0000000f | ||
484 | |||
485 | /*****************************************************************************/ | ||
486 | #define VBI_PAY1 0x444 | ||
487 | #define FLD_GS1_FIFO_DAT 0xFF000000 | ||
488 | #define FLD_GS1_STAT 0x00FF0000 | ||
489 | #define FLD_CC_FIFO_DAT 0x0000FF00 | ||
490 | #define FLD_CC_STAT 0x000000FF | ||
491 | |||
492 | /*****************************************************************************/ | ||
493 | #define VBI_PAY2 0x448 | ||
494 | #define FLD_WSS_FIFO_DAT 0xff000000 | ||
495 | #define FLD_WSS_STAT 0x00ff0000 | ||
496 | #define FLD_GS2_FIFO_DAT 0x0000ff00 | ||
497 | #define FLD_GS2_STAT 0x000000ff | ||
498 | |||
499 | /*****************************************************************************/ | ||
500 | #define VBI_CUST1_CFG1 0x44c | ||
501 | /* Reserved [31] */ | ||
502 | #define FLD_VBI1_CRIWIN 0x7f000000 | ||
503 | #define FLD_VBI1_SLICE_DIST 0x00f00000 | ||
504 | #define FLD_VBI1_BITINC 0x000fff00 | ||
505 | #define FLD_VBI1_HDELAY 0x000000ff | ||
506 | |||
507 | /*****************************************************************************/ | ||
508 | #define VBI_CUST1_CFG2 0x450 | ||
509 | #define FLD_VBI1_FC_LENGTH 0x1f000000 | ||
510 | #define FLD_VBI1_FRAME_CODE 0x00ffffff | ||
511 | |||
512 | /*****************************************************************************/ | ||
513 | #define VBI_CUST1_CFG3 0x454 | ||
514 | #define FLD_VBI1_HAM_EN 0x80000000 | ||
515 | #define FLD_VBI1_FIFO_MODE 0x70000000 | ||
516 | #define FLD_VBI1_FORMAT_TYPE 0x0f000000 | ||
517 | #define FLD_VBI1_PAYLD_LENGTH 0x00ff0000 | ||
518 | #define FLD_VBI1_CRI_LENGTH 0x0000f000 | ||
519 | #define FLD_VBI1_CRI_MARGIN 0x00000f00 | ||
520 | #define FLD_VBI1_CRI_TIME 0x000000ff | ||
521 | |||
522 | /*****************************************************************************/ | ||
523 | #define VBI_CUST2_CFG1 0x458 | ||
524 | /* Reserved [31] */ | ||
525 | #define FLD_VBI2_CRIWIN 0x7f000000 | ||
526 | #define FLD_VBI2_SLICE_DIST 0x00f00000 | ||
527 | #define FLD_VBI2_BITINC 0x000fff00 | ||
528 | #define FLD_VBI2_HDELAY 0x000000ff | ||
529 | |||
530 | /*****************************************************************************/ | ||
531 | #define VBI_CUST2_CFG2 0x45c | ||
532 | #define FLD_VBI2_FC_LENGTH 0x1f000000 | ||
533 | #define FLD_VBI2_FRAME_CODE 0x00ffffff | ||
534 | |||
535 | /*****************************************************************************/ | ||
536 | #define VBI_CUST2_CFG3 0x460 | ||
537 | #define FLD_VBI2_HAM_EN 0x80000000 | ||
538 | #define FLD_VBI2_FIFO_MODE 0x70000000 | ||
539 | #define FLD_VBI2_FORMAT_TYPE 0x0f000000 | ||
540 | #define FLD_VBI2_PAYLD_LENGTH 0x00ff0000 | ||
541 | #define FLD_VBI2_CRI_LENGTH 0x0000f000 | ||
542 | #define FLD_VBI2_CRI_MARGIN 0x00000f00 | ||
543 | #define FLD_VBI2_CRI_TIME 0x000000ff | ||
544 | |||
545 | /*****************************************************************************/ | ||
546 | #define VBI_CUST3_CFG1 0x464 | ||
547 | /* Reserved [31] */ | ||
548 | #define FLD_VBI3_CRIWIN 0x7f000000 | ||
549 | #define FLD_VBI3_SLICE_DIST 0x00f00000 | ||
550 | #define FLD_VBI3_BITINC 0x000fff00 | ||
551 | #define FLD_VBI3_HDELAY 0x000000ff | ||
552 | |||
553 | /*****************************************************************************/ | ||
554 | #define VBI_CUST3_CFG2 0x468 | ||
555 | #define FLD_VBI3_FC_LENGTH 0x1f000000 | ||
556 | #define FLD_VBI3_FRAME_CODE 0x00ffffff | ||
557 | |||
558 | /*****************************************************************************/ | ||
559 | #define VBI_CUST3_CFG3 0x46c | ||
560 | #define FLD_VBI3_HAM_EN 0x80000000 | ||
561 | #define FLD_VBI3_FIFO_MODE 0x70000000 | ||
562 | #define FLD_VBI3_FORMAT_TYPE 0x0f000000 | ||
563 | #define FLD_VBI3_PAYLD_LENGTH 0x00ff0000 | ||
564 | #define FLD_VBI3_CRI_LENGTH 0x0000f000 | ||
565 | #define FLD_VBI3_CRI_MARGIN 0x00000f00 | ||
566 | #define FLD_VBI3_CRI_TIME 0x000000ff | ||
567 | |||
568 | /*****************************************************************************/ | ||
569 | #define HORIZ_TIM_CTRL 0x470 | ||
570 | #define FLD_BGDEL_CNT 0xff000000 | ||
571 | /* Reserved [23:22] */ | ||
572 | #define FLD_HACTIVE_CNT 0x003ff000 | ||
573 | /* Reserved [11:10] */ | ||
574 | #define FLD_HBLANK_CNT 0x000003ff | ||
575 | |||
576 | /*****************************************************************************/ | ||
577 | #define VERT_TIM_CTRL 0x474 | ||
578 | #define FLD_V656BLANK_CNT 0xff000000 | ||
579 | /* Reserved [23:22] */ | ||
580 | #define FLD_VACTIVE_CNT 0x003ff000 | ||
581 | /* Reserved [11:10] */ | ||
582 | #define FLD_VBLANK_CNT 0x000003ff | ||
583 | |||
584 | /*****************************************************************************/ | ||
585 | #define SRC_COMB_CFG 0x478 | ||
586 | #define FLD_CCOMB_2LN_CHECK 0x80000000 | ||
587 | #define FLD_CCOMB_3LN_EN 0x40000000 | ||
588 | #define FLD_CCOMB_2LN_EN 0x20000000 | ||
589 | #define FLD_CCOMB_3D_EN 0x10000000 | ||
590 | /* Reserved [27] */ | ||
591 | #define FLD_LCOMB_3LN_EN 0x04000000 | ||
592 | #define FLD_LCOMB_2LN_EN 0x02000000 | ||
593 | #define FLD_LCOMB_3D_EN 0x01000000 | ||
594 | #define FLD_LUMA_LPF_SEL 0x00c00000 | ||
595 | #define FLD_UV_LPF_SEL 0x00300000 | ||
596 | #define FLD_BLEND_SLOPE 0x000f0000 | ||
597 | #define FLD_CCOMB_REDUCE_EN 0x00008000 | ||
598 | /* Reserved [14:10] */ | ||
599 | #define FLD_SRC_DECIM_RATIO 0x000003ff | ||
600 | |||
601 | /*****************************************************************************/ | ||
602 | #define CHROMA_VBIOFF_CFG 0x47c | ||
603 | #define FLD_VBI_VOFFSET 0x1f000000 | ||
604 | /* Reserved [23:20] */ | ||
605 | #define FLD_SC_STEP 0x000fffff | ||
606 | |||
607 | /*****************************************************************************/ | ||
608 | #define FIELD_COUNT 0x480 | ||
609 | #define FLD_FIELD_COUNT_FLD 0x000003ff | ||
610 | |||
611 | /*****************************************************************************/ | ||
612 | #define MISC_TIM_CTRL 0x484 | ||
613 | #define FLD_DEBOUNCE_COUNT 0xc0000000 | ||
614 | #define FLD_VT_LINE_CNT_HYST 0x30000000 | ||
615 | /* Reserved [27] */ | ||
616 | #define FLD_AFD_STAT 0x07ff0000 | ||
617 | #define FLD_VPRES_VERT_EN 0x00008000 | ||
618 | /* Reserved [14:12] */ | ||
619 | #define FLD_HR32 0x00000800 | ||
620 | #define FLD_TDALGN 0x00000400 | ||
621 | #define FLD_TDFIELD 0x00000200 | ||
622 | /* Reserved [8:6] */ | ||
623 | #define FLD_TEMPDEC 0x0000003f | ||
624 | |||
625 | /*****************************************************************************/ | ||
626 | #define DFE_CTRL1 0x488 | ||
627 | #define FLD_CLAMP_AUTO_EN 0x80000000 | ||
628 | #define FLD_AGC_AUTO_EN 0x40000000 | ||
629 | #define FLD_VGA_CRUSH_EN 0x20000000 | ||
630 | #define FLD_VGA_AUTO_EN 0x10000000 | ||
631 | #define FLD_VBI_GATE_EN 0x08000000 | ||
632 | #define FLD_CLAMP_LEVEL 0x07000000 | ||
633 | /* Reserved [23:22] */ | ||
634 | #define FLD_CLAMP_SKIP_CNT 0x00300000 | ||
635 | #define FLD_AGC_GAIN 0x000fff00 | ||
636 | /* Reserved [7:6] */ | ||
637 | #define FLD_VGA_GAIN 0x0000003f | ||
638 | |||
639 | /*****************************************************************************/ | ||
640 | #define DFE_CTRL2 0x48c | ||
641 | #define FLD_VGA_ACQUIRE_RANGE 0x00ff0000 | ||
642 | #define FLD_VGA_TRACK_RANGE 0x0000ff00 | ||
643 | #define FLD_VGA_SYNC 0x000000ff | ||
644 | |||
645 | /*****************************************************************************/ | ||
646 | #define DFE_CTRL3 0x490 | ||
647 | #define FLD_BP_PERCENT 0xff000000 | ||
648 | #define FLD_DFT_THRESHOLD 0x00ff0000 | ||
649 | /* Reserved [15:12] */ | ||
650 | #define FLD_SYNC_WIDTH_SEL 0x00000600 | ||
651 | #define FLD_BP_LOOP_GAIN 0x00000300 | ||
652 | #define FLD_SYNC_LOOP_GAIN 0x000000c0 | ||
653 | /* Reserved [5:4] */ | ||
654 | #define FLD_AGC_LOOP_GAIN 0x0000000c | ||
655 | #define FLD_DCC_LOOP_GAIN 0x00000003 | ||
656 | |||
657 | /*****************************************************************************/ | ||
658 | #define PLL_CTRL 0x494 | ||
659 | #define FLD_PLL_KD 0xff000000 | ||
660 | #define FLD_PLL_KI 0x00ff0000 | ||
661 | #define FLD_PLL_MAX_OFFSET 0x0000ffff | ||
662 | |||
663 | /*****************************************************************************/ | ||
664 | #define HTL_CTRL 0x498 | ||
665 | /* Reserved [31:24] */ | ||
666 | #define FLD_AUTO_LOCK_SPD 0x00080000 | ||
667 | #define FLD_MAN_FAST_LOCK 0x00040000 | ||
668 | #define FLD_HTL_15K_EN 0x00020000 | ||
669 | #define FLD_HTL_500K_EN 0x00010000 | ||
670 | #define FLD_HTL_KD 0x0000ff00 | ||
671 | #define FLD_HTL_KI 0x000000ff | ||
672 | |||
673 | /*****************************************************************************/ | ||
674 | #define COMB_CTRL 0x49c | ||
675 | #define FLD_COMB_PHASE_LIMIT 0xff000000 | ||
676 | #define FLD_CCOMB_ERR_LIMIT 0x00ff0000 | ||
677 | #define FLD_LUMA_THRESHOLD 0x0000ff00 | ||
678 | #define FLD_LCOMB_ERR_LIMIT 0x000000ff | ||
679 | |||
680 | /*****************************************************************************/ | ||
681 | #define CRUSH_CTRL 0x4a0 | ||
682 | #define FLD_WTW_EN 0x00400000 | ||
683 | #define FLD_CRUSH_FREQ 0x00200000 | ||
684 | #define FLD_MAJ_SEL_EN 0x00100000 | ||
685 | #define FLD_MAJ_SEL 0x000c0000 | ||
686 | /* Reserved [17:15] */ | ||
687 | #define FLD_SYNC_TIP_REDUCE 0x00007e00 | ||
688 | /* Reserved [8:6] */ | ||
689 | #define FLD_SYNC_TIP_INC 0x0000003f | ||
690 | |||
691 | /*****************************************************************************/ | ||
692 | #define SOFT_RST_CTRL 0x4a4 | ||
693 | #define FLD_VD_SOFT_RST 0x00008000 | ||
694 | /* Reserved [14:12] */ | ||
695 | #define FLD_REG_RST_MSK 0x00000800 | ||
696 | #define FLD_VOF_RST_MSK 0x00000400 | ||
697 | #define FLD_MVDET_RST_MSK 0x00000200 | ||
698 | #define FLD_VBI_RST_MSK 0x00000100 | ||
699 | #define FLD_SCALE_RST_MSK 0x00000080 | ||
700 | #define FLD_CHROMA_RST_MSK 0x00000040 | ||
701 | #define FLD_LUMA_RST_MSK 0x00000020 | ||
702 | #define FLD_VTG_RST_MSK 0x00000010 | ||
703 | #define FLD_YCSEP_RST_MSK 0x00000008 | ||
704 | #define FLD_SRC_RST_MSK 0x00000004 | ||
705 | #define FLD_DFE_RST_MSK 0x00000002 | ||
706 | /* Reserved [0] */ | ||
707 | |||
708 | /*****************************************************************************/ | ||
709 | #define MV_DT_CTRL1 0x4a8 | ||
710 | /* Reserved [31:29] */ | ||
711 | #define FLD_PSP_STOP_LINE 0x1f000000 | ||
712 | /* Reserved [23:21] */ | ||
713 | #define FLD_PSP_STRT_LINE 0x001f0000 | ||
714 | /* Reserved [15] */ | ||
715 | #define FLD_PSP_LLIMW 0x00007f00 | ||
716 | /* Reserved [7] */ | ||
717 | #define FLD_PSP_ULIMW 0x0000007f | ||
718 | |||
719 | /*****************************************************************************/ | ||
720 | #define MV_DT_CTRL2 0x4aC | ||
721 | #define FLD_CS_STOPWIN 0xff000000 | ||
722 | #define FLD_CS_STRTWIN 0x00ff0000 | ||
723 | #define FLD_CS_WIDTH 0x0000ff00 | ||
724 | #define FLD_PSP_SPEC_VAL 0x000000ff | ||
725 | |||
726 | /*****************************************************************************/ | ||
727 | #define MV_DT_CTRL3 0x4B0 | ||
728 | #define FLD_AUTO_RATE_DIS 0x80000000 | ||
729 | #define FLD_HLOCK_DIS 0x40000000 | ||
730 | #define FLD_SEL_FIELD_CNT 0x20000000 | ||
731 | #define FLD_CS_TYPE2_SEL 0x10000000 | ||
732 | #define FLD_CS_LINE_THRSH_SEL 0x08000000 | ||
733 | #define FLD_CS_ATHRESH_SEL 0x04000000 | ||
734 | #define FLD_PSP_SPEC_SEL 0x02000000 | ||
735 | #define FLD_PSP_LINES_SEL 0x01000000 | ||
736 | #define FLD_FIELD_CNT 0x00f00000 | ||
737 | #define FLD_CS_TYPE2_CNT 0x000fc000 | ||
738 | #define FLD_CS_LINE_CNT 0x00003f00 | ||
739 | #define FLD_CS_ATHRESH_LEV 0x000000ff | ||
740 | |||
741 | /*****************************************************************************/ | ||
742 | #define CHIP_VERSION 0x4b4 | ||
743 | /* Cx231xx redefine */ | ||
744 | #define VERSION 0x4b4 | ||
745 | #define FLD_REV_ID 0x000000ff | ||
746 | |||
747 | /*****************************************************************************/ | ||
748 | #define MISC_DIAG_CTRL 0x4b8 | ||
749 | /* Reserved [31:24] */ | ||
750 | #define FLD_SC_CONVERGE_THRESH 0x00ff0000 | ||
751 | #define FLD_CCOMB_ERR_LIMIT_3D 0x0000ff00 | ||
752 | #define FLD_LCOMB_ERR_LIMIT_3D 0x000000ff | ||
753 | |||
754 | /*****************************************************************************/ | ||
755 | #define VBI_PASS_CTRL 0x4bc | ||
756 | #define FLD_VBI_PASS_MD 0x00200000 | ||
757 | #define FLD_VBI_SETUP_DIS 0x00100000 | ||
758 | #define FLD_PASS_LINE_CTRL 0x000fffff | ||
759 | |||
760 | /*****************************************************************************/ | ||
761 | /* Cx231xx redefine */ | ||
762 | #define VCR_DET_CTRL 0x4c0 | ||
763 | #define FLD_EN_FIELD_PHASE_DET 0x80000000 | ||
764 | #define FLD_EN_HEAD_SW_DET 0x40000000 | ||
765 | #define FLD_FIELD_PHASE_LENGTH 0x01ff0000 | ||
766 | /* Reserved [29:25] */ | ||
767 | #define FLD_FIELD_PHASE_DELAY 0x0000ff00 | ||
768 | #define FLD_FIELD_PHASE_LIMIT 0x000000f0 | ||
769 | #define FLD_HEAD_SW_DET_LIMIT 0x0000000f | ||
770 | |||
771 | /*****************************************************************************/ | ||
772 | #define DL_CTL 0x800 | ||
773 | #define DL_CTL_ADDRESS_LOW 0x800 /* Byte 1 in DL_CTL */ | ||
774 | #define DL_CTL_ADDRESS_HIGH 0x801 /* Byte 2 in DL_CTL */ | ||
775 | #define DL_CTL_DATA 0x802 /* Byte 3 in DL_CTL */ | ||
776 | #define DL_CTL_CONTROL 0x803 /* Byte 4 in DL_CTL */ | ||
777 | /* Reserved [31:5] */ | ||
778 | #define FLD_START_8051 0x10000000 | ||
779 | #define FLD_DL_ENABLE 0x08000000 | ||
780 | #define FLD_DL_AUTO_INC 0x04000000 | ||
781 | #define FLD_DL_MAP 0x03000000 | ||
782 | |||
783 | /*****************************************************************************/ | ||
784 | #define STD_DET_STATUS 0x804 | ||
785 | #define FLD_SPARE_STATUS1 0xff000000 | ||
786 | #define FLD_SPARE_STATUS0 0x00ff0000 | ||
787 | #define FLD_MOD_DET_STATUS1 0x0000ff00 | ||
788 | #define FLD_MOD_DET_STATUS0 0x000000ff | ||
789 | |||
790 | /*****************************************************************************/ | ||
791 | #define AUD_BUILD_NUM 0x806 | ||
792 | #define AUD_VER_NUM 0x807 | ||
793 | #define STD_DET_CTL 0x808 | ||
794 | #define STD_DET_CTL_AUD_CTL 0x808 /* Byte 1 in STD_DET_CTL */ | ||
795 | #define STD_DET_CTL_PREF_MODE 0x809 /* Byte 2 in STD_DET_CTL */ | ||
796 | #define FLD_SPARE_CTL0 0xff000000 | ||
797 | #define FLD_DIS_DBX 0x00800000 | ||
798 | #define FLD_DIS_BTSC 0x00400000 | ||
799 | #define FLD_DIS_NICAM_A2 0x00200000 | ||
800 | #define FLD_VIDEO_PRESENT 0x00100000 | ||
801 | #define FLD_DW8051_VIDEO_FORMAT 0x000f0000 | ||
802 | #define FLD_PREF_DEC_MODE 0x0000ff00 | ||
803 | #define FLD_AUD_CONFIG 0x000000ff | ||
804 | |||
805 | /*****************************************************************************/ | ||
806 | #define DW8051_INT 0x80c | ||
807 | #define FLD_VIDEO_PRESENT_CHANGE 0x80000000 | ||
808 | #define FLD_VIDEO_CHANGE 0x40000000 | ||
809 | #define FLD_RDS_READY 0x20000000 | ||
810 | #define FLD_AC97_INT 0x10000000 | ||
811 | #define FLD_NICAM_BIT_ERROR_TOO_HIGH 0x08000000 | ||
812 | #define FLD_NICAM_LOCK 0x04000000 | ||
813 | #define FLD_NICAM_UNLOCK 0x02000000 | ||
814 | #define FLD_DFT4_TH_CMP 0x01000000 | ||
815 | /* Reserved [23:22] */ | ||
816 | #define FLD_LOCK_IND_INT 0x00200000 | ||
817 | #define FLD_DFT3_TH_CMP 0x00100000 | ||
818 | #define FLD_DFT2_TH_CMP 0x00080000 | ||
819 | #define FLD_DFT1_TH_CMP 0x00040000 | ||
820 | #define FLD_FM2_DFT_TH_CMP 0x00020000 | ||
821 | #define FLD_FM1_DFT_TH_CMP 0x00010000 | ||
822 | #define FLD_VIDEO_PRESENT_EN 0x00008000 | ||
823 | #define FLD_VIDEO_CHANGE_EN 0x00004000 | ||
824 | #define FLD_RDS_READY_EN 0x00002000 | ||
825 | #define FLD_AC97_INT_EN 0x00001000 | ||
826 | #define FLD_NICAM_BIT_ERROR_TOO_HIGH_EN 0x00000800 | ||
827 | #define FLD_NICAM_LOCK_EN 0x00000400 | ||
828 | #define FLD_NICAM_UNLOCK_EN 0x00000200 | ||
829 | #define FLD_DFT4_TH_CMP_EN 0x00000100 | ||
830 | /* Reserved [7] */ | ||
831 | #define FLD_DW8051_INT6_CTL1 0x00000040 | ||
832 | #define FLD_DW8051_INT5_CTL1 0x00000020 | ||
833 | #define FLD_DW8051_INT4_CTL1 0x00000010 | ||
834 | #define FLD_DW8051_INT3_CTL1 0x00000008 | ||
835 | #define FLD_DW8051_INT2_CTL1 0x00000004 | ||
836 | #define FLD_DW8051_INT1_CTL1 0x00000002 | ||
837 | #define FLD_DW8051_INT0_CTL1 0x00000001 | ||
838 | |||
839 | /*****************************************************************************/ | ||
840 | #define GENERAL_CTL 0x810 | ||
841 | #define FLD_RDS_INT 0x80000000 | ||
842 | #define FLD_NBER_INT 0x40000000 | ||
843 | #define FLD_NLL_INT 0x20000000 | ||
844 | #define FLD_IFL_INT 0x10000000 | ||
845 | #define FLD_FDL_INT 0x08000000 | ||
846 | #define FLD_AFC_INT 0x04000000 | ||
847 | #define FLD_AMC_INT 0x02000000 | ||
848 | #define FLD_AC97_INT_CTL 0x01000000 | ||
849 | #define FLD_RDS_INT_DIS 0x00800000 | ||
850 | #define FLD_NBER_INT_DIS 0x00400000 | ||
851 | #define FLD_NLL_INT_DIS 0x00200000 | ||
852 | #define FLD_IFL_INT_DIS 0x00100000 | ||
853 | #define FLD_FDL_INT_DIS 0x00080000 | ||
854 | #define FLD_FC_INT_DIS 0x00040000 | ||
855 | #define FLD_AMC_INT_DIS 0x00020000 | ||
856 | #define FLD_AC97_INT_DIS 0x00010000 | ||
857 | #define FLD_REV_NUM 0x0000ff00 | ||
858 | /* Reserved [7:5] */ | ||
859 | #define FLD_DBX_SOFT_RESET_REG 0x00000010 | ||
860 | #define FLD_AD_SOFT_RESET_REG 0x00000008 | ||
861 | #define FLD_SRC_SOFT_RESET_REG 0x00000004 | ||
862 | #define FLD_CDMOD_SOFT_RESET 0x00000002 | ||
863 | #define FLD_8051_SOFT_RESET 0x00000001 | ||
864 | |||
865 | /*****************************************************************************/ | ||
866 | #define AAGC_CTL 0x814 | ||
867 | #define FLD_AFE_12DB_EN 0x80000000 | ||
868 | #define FLD_AAGC_DEFAULT_EN 0x40000000 | ||
869 | #define FLD_AAGC_DEFAULT 0x3f000000 | ||
870 | /* Reserved [23] */ | ||
871 | #define FLD_AAGC_GAIN 0x00600000 | ||
872 | #define FLD_AAGC_TH 0x001f0000 | ||
873 | /* Reserved [15:14] */ | ||
874 | #define FLD_AAGC_HYST2 0x00003f00 | ||
875 | /* Reserved [7:6] */ | ||
876 | #define FLD_AAGC_HYST1 0x0000003f | ||
877 | |||
878 | /*****************************************************************************/ | ||
879 | #define IF_SRC_CTL 0x818 | ||
880 | #define FLD_DBX_BYPASS 0x80000000 | ||
881 | /* Reserved [30:25] */ | ||
882 | #define FLD_IF_SRC_MODE 0x01000000 | ||
883 | /* Reserved [23:18] */ | ||
884 | #define FLD_IF_SRC_PHASE_INC 0x0001ffff | ||
885 | |||
886 | /*****************************************************************************/ | ||
887 | #define ANALOG_DEMOD_CTL 0x81c | ||
888 | #define FLD_ROT1_PHACC_PROG 0xffff0000 | ||
889 | /* Reserved [15] */ | ||
890 | #define FLD_FM1_DELAY_FIX 0x00007000 | ||
891 | #define FLD_PDF4_SHIFT 0x00000c00 | ||
892 | #define FLD_PDF3_SHIFT 0x00000300 | ||
893 | #define FLD_PDF2_SHIFT 0x000000c0 | ||
894 | #define FLD_PDF1_SHIFT 0x00000030 | ||
895 | #define FLD_FMBYPASS_MODE2 0x00000008 | ||
896 | #define FLD_FMBYPASS_MODE1 0x00000004 | ||
897 | #define FLD_NICAM_MODE 0x00000002 | ||
898 | #define FLD_BTSC_FMRADIO_MODE 0x00000001 | ||
899 | |||
900 | /*****************************************************************************/ | ||
901 | #define ROT_FREQ_CTL 0x820 | ||
902 | #define FLD_ROT3_PHACC_PROG 0xffff0000 | ||
903 | #define FLD_ROT2_PHACC_PROG 0x0000ffff | ||
904 | |||
905 | /*****************************************************************************/ | ||
906 | #define FM_CTL 0x824 | ||
907 | #define FLD_FM2_DC_FB_SHIFT 0xf0000000 | ||
908 | #define FLD_FM2_DC_INT_SHIFT 0x0f000000 | ||
909 | #define FLD_FM2_AFC_RESET 0x00800000 | ||
910 | #define FLD_FM2_DC_PASS_IN 0x00400000 | ||
911 | #define FLD_FM2_DAGC_SHIFT 0x00380000 | ||
912 | #define FLD_FM2_CORDIC_SHIFT 0x00070000 | ||
913 | #define FLD_FM1_DC_FB_SHIFT 0x0000f000 | ||
914 | #define FLD_FM1_DC_INT_SHIFT 0x00000f00 | ||
915 | #define FLD_FM1_AFC_RESET 0x00000080 | ||
916 | #define FLD_FM1_DC_PASS_IN 0x00000040 | ||
917 | #define FLD_FM1_DAGC_SHIFT 0x00000038 | ||
918 | #define FLD_FM1_CORDIC_SHIFT 0x00000007 | ||
919 | |||
920 | /*****************************************************************************/ | ||
921 | #define LPF_PDF_CTL 0x828 | ||
922 | /* Reserved [31:30] */ | ||
923 | #define FLD_LPF32_SHIFT1 0x30000000 | ||
924 | #define FLD_LPF32_SHIFT2 0x0c000000 | ||
925 | #define FLD_LPF160_SHIFTA 0x03000000 | ||
926 | #define FLD_LPF160_SHIFTB 0x00c00000 | ||
927 | #define FLD_LPF160_SHIFTC 0x00300000 | ||
928 | #define FLD_LPF32_COEF_SEL2 0x000c0000 | ||
929 | #define FLD_LPF32_COEF_SEL1 0x00030000 | ||
930 | #define FLD_LPF160_COEF_SELC 0x0000c000 | ||
931 | #define FLD_LPF160_COEF_SELB 0x00003000 | ||
932 | #define FLD_LPF160_COEF_SELA 0x00000c00 | ||
933 | #define FLD_LPF160_IN_EN_REG 0x00000300 | ||
934 | #define FLD_PDF4_PDF_SEL 0x000000c0 | ||
935 | #define FLD_PDF3_PDF_SEL 0x00000030 | ||
936 | #define FLD_PDF2_PDF_SEL 0x0000000c | ||
937 | #define FLD_PDF1_PDF_SEL 0x00000003 | ||
938 | |||
939 | /*****************************************************************************/ | ||
940 | #define DFT1_CTL1 0x82c | ||
941 | #define FLD_DFT1_DWELL 0xffff0000 | ||
942 | #define FLD_DFT1_FREQ 0x0000ffff | ||
943 | |||
944 | /*****************************************************************************/ | ||
945 | #define DFT1_CTL2 0x830 | ||
946 | #define FLD_DFT1_THRESHOLD 0xffffff00 | ||
947 | #define FLD_DFT1_CMP_CTL 0x00000080 | ||
948 | #define FLD_DFT1_AVG 0x00000070 | ||
949 | /* Reserved [3:1] */ | ||
950 | #define FLD_DFT1_START 0x00000001 | ||
951 | |||
952 | /*****************************************************************************/ | ||
953 | #define DFT1_STATUS 0x834 | ||
954 | #define FLD_DFT1_DONE 0x80000000 | ||
955 | #define FLD_DFT1_TH_CMP_STAT 0x40000000 | ||
956 | #define FLD_DFT1_RESULT 0x3fffffff | ||
957 | |||
958 | /*****************************************************************************/ | ||
959 | #define DFT2_CTL1 0x838 | ||
960 | #define FLD_DFT2_DWELL 0xffff0000 | ||
961 | #define FLD_DFT2_FREQ 0x0000ffff | ||
962 | |||
963 | /*****************************************************************************/ | ||
964 | #define DFT2_CTL2 0x83C | ||
965 | #define FLD_DFT2_THRESHOLD 0xffffff00 | ||
966 | #define FLD_DFT2_CMP_CTL 0x00000080 | ||
967 | #define FLD_DFT2_AVG 0x00000070 | ||
968 | /* Reserved [3:1] */ | ||
969 | #define FLD_DFT2_START 0x00000001 | ||
970 | |||
971 | /*****************************************************************************/ | ||
972 | #define DFT2_STATUS 0x840 | ||
973 | #define FLD_DFT2_DONE 0x80000000 | ||
974 | #define FLD_DFT2_TH_CMP_STAT 0x40000000 | ||
975 | #define FLD_DFT2_RESULT 0x3fffffff | ||
976 | |||
977 | /*****************************************************************************/ | ||
978 | #define DFT3_CTL1 0x844 | ||
979 | #define FLD_DFT3_DWELL 0xffff0000 | ||
980 | #define FLD_DFT3_FREQ 0x0000ffff | ||
981 | |||
982 | /*****************************************************************************/ | ||
983 | #define DFT3_CTL2 0x848 | ||
984 | #define FLD_DFT3_THRESHOLD 0xffffff00 | ||
985 | #define FLD_DFT3_CMP_CTL 0x00000080 | ||
986 | #define FLD_DFT3_AVG 0x00000070 | ||
987 | /* Reserved [3:1] */ | ||
988 | #define FLD_DFT3_START 0x00000001 | ||
989 | |||
990 | /*****************************************************************************/ | ||
991 | #define DFT3_STATUS 0x84c | ||
992 | #define FLD_DFT3_DONE 0x80000000 | ||
993 | #define FLD_DFT3_TH_CMP_STAT 0x40000000 | ||
994 | #define FLD_DFT3_RESULT 0x3fffffff | ||
995 | |||
996 | /*****************************************************************************/ | ||
997 | #define DFT4_CTL1 0x850 | ||
998 | #define FLD_DFT4_DWELL 0xffff0000 | ||
999 | #define FLD_DFT4_FREQ 0x0000ffff | ||
1000 | |||
1001 | /*****************************************************************************/ | ||
1002 | #define DFT4_CTL2 0x854 | ||
1003 | #define FLD_DFT4_THRESHOLD 0xffffff00 | ||
1004 | #define FLD_DFT4_CMP_CTL 0x00000080 | ||
1005 | #define FLD_DFT4_AVG 0x00000070 | ||
1006 | /* Reserved [3:1] */ | ||
1007 | #define FLD_DFT4_START 0x00000001 | ||
1008 | |||
1009 | /*****************************************************************************/ | ||
1010 | #define DFT4_STATUS 0x858 | ||
1011 | #define FLD_DFT4_DONE 0x80000000 | ||
1012 | #define FLD_DFT4_TH_CMP_STAT 0x40000000 | ||
1013 | #define FLD_DFT4_RESULT 0x3fffffff | ||
1014 | |||
1015 | /*****************************************************************************/ | ||
1016 | #define AM_MTS_DET 0x85c | ||
1017 | #define FLD_AM_MTS_MODE 0x80000000 | ||
1018 | /* Reserved [30:26] */ | ||
1019 | #define FLD_AM_SUB 0x02000000 | ||
1020 | #define FLD_AM_GAIN_EN 0x01000000 | ||
1021 | /* Reserved [23:16] */ | ||
1022 | #define FLD_AMMTS_GAIN_SCALE 0x0000e000 | ||
1023 | #define FLD_MTS_PDF_SHIFT 0x00001800 | ||
1024 | #define FLD_AM_REG_GAIN 0x00000700 | ||
1025 | #define FLD_AGC_REF 0x000000ff | ||
1026 | |||
1027 | /*****************************************************************************/ | ||
1028 | #define ANALOG_MUX_CTL 0x860 | ||
1029 | /* Reserved [31:29] */ | ||
1030 | #define FLD_MUX21_SEL 0x10000000 | ||
1031 | #define FLD_MUX20_SEL 0x08000000 | ||
1032 | #define FLD_MUX19_SEL 0x04000000 | ||
1033 | #define FLD_MUX18_SEL 0x02000000 | ||
1034 | #define FLD_MUX17_SEL 0x01000000 | ||
1035 | #define FLD_MUX16_SEL 0x00800000 | ||
1036 | #define FLD_MUX15_SEL 0x00400000 | ||
1037 | #define FLD_MUX14_SEL 0x00300000 | ||
1038 | #define FLD_MUX13_SEL 0x000C0000 | ||
1039 | #define FLD_MUX12_SEL 0x00020000 | ||
1040 | #define FLD_MUX11_SEL 0x00018000 | ||
1041 | #define FLD_MUX10_SEL 0x00004000 | ||
1042 | #define FLD_MUX9_SEL 0x00002000 | ||
1043 | #define FLD_MUX8_SEL 0x00001000 | ||
1044 | #define FLD_MUX7_SEL 0x00000800 | ||
1045 | #define FLD_MUX6_SEL 0x00000600 | ||
1046 | #define FLD_MUX5_SEL 0x00000100 | ||
1047 | #define FLD_MUX4_SEL 0x000000c0 | ||
1048 | #define FLD_MUX3_SEL 0x00000030 | ||
1049 | #define FLD_MUX2_SEL 0x0000000c | ||
1050 | #define FLD_MUX1_SEL 0x00000003 | ||
1051 | |||
1052 | /*****************************************************************************/ | ||
1053 | /* Cx231xx redefine */ | ||
1054 | #define DPLL_CTRL1 0x864 | ||
1055 | #define DIG_PLL_CTL1 0x864 | ||
1056 | |||
1057 | #define FLD_PLL_STATUS 0x07000000 | ||
1058 | #define FLD_BANDWIDTH_SELECT 0x00030000 | ||
1059 | #define FLD_PLL_SHIFT_REG 0x00007000 | ||
1060 | #define FLD_PHASE_SHIFT 0x000007ff | ||
1061 | |||
1062 | /*****************************************************************************/ | ||
1063 | /* Cx231xx redefine */ | ||
1064 | #define DPLL_CTRL2 0x868 | ||
1065 | #define DIG_PLL_CTL2 0x868 | ||
1066 | #define FLD_PLL_UNLOCK_THR 0xff000000 | ||
1067 | #define FLD_PLL_LOCK_THR 0x00ff0000 | ||
1068 | /* Reserved [15:8] */ | ||
1069 | #define FLD_AM_PDF_SEL2 0x000000c0 | ||
1070 | #define FLD_AM_PDF_SEL1 0x00000030 | ||
1071 | #define FLD_DPLL_FSM_CTRL 0x0000000c | ||
1072 | /* Reserved [1] */ | ||
1073 | #define FLD_PLL_PILOT_DET 0x00000001 | ||
1074 | |||
1075 | /*****************************************************************************/ | ||
1076 | /* Cx231xx redefine */ | ||
1077 | #define DPLL_CTRL3 0x86c | ||
1078 | #define DIG_PLL_CTL3 0x86c | ||
1079 | #define FLD_DISABLE_LOOP 0x01000000 | ||
1080 | #define FLD_A1_DS1_SEL 0x000c0000 | ||
1081 | #define FLD_A1_DS2_SEL 0x00030000 | ||
1082 | #define FLD_A1_KI 0x0000ff00 | ||
1083 | #define FLD_A1_KD 0x000000ff | ||
1084 | |||
1085 | /*****************************************************************************/ | ||
1086 | /* Cx231xx redefine */ | ||
1087 | #define DPLL_CTRL4 0x870 | ||
1088 | #define DIG_PLL_CTL4 0x870 | ||
1089 | #define FLD_A2_DS1_SEL 0x000c0000 | ||
1090 | #define FLD_A2_DS2_SEL 0x00030000 | ||
1091 | #define FLD_A2_KI 0x0000ff00 | ||
1092 | #define FLD_A2_KD 0x000000ff | ||
1093 | |||
1094 | /*****************************************************************************/ | ||
1095 | /* Cx231xx redefine */ | ||
1096 | #define DPLL_CTRL5 0x874 | ||
1097 | #define DIG_PLL_CTL5 0x874 | ||
1098 | #define FLD_TRK_DS1_SEL 0x000c0000 | ||
1099 | #define FLD_TRK_DS2_SEL 0x00030000 | ||
1100 | #define FLD_TRK_KI 0x0000ff00 | ||
1101 | #define FLD_TRK_KD 0x000000ff | ||
1102 | |||
1103 | /*****************************************************************************/ | ||
1104 | #define DEEMPH_GAIN_CTL 0x878 | ||
1105 | #define FLD_DEEMPH2_GAIN 0xFFFF0000 | ||
1106 | #define FLD_DEEMPH1_GAIN 0x0000FFFF | ||
1107 | |||
1108 | /*****************************************************************************/ | ||
1109 | /* Cx231xx redefine */ | ||
1110 | #define DEEMPH_COEFF1 0x87c | ||
1111 | #define DEEMPH_COEF1 0x87c | ||
1112 | #define FLD_DEEMPH_B0 0xffff0000 | ||
1113 | #define FLD_DEEMPH_A0 0x0000ffff | ||
1114 | |||
1115 | /*****************************************************************************/ | ||
1116 | /* Cx231xx redefine */ | ||
1117 | #define DEEMPH_COEFF2 0x880 | ||
1118 | #define DEEMPH_COEF2 0x880 | ||
1119 | #define FLD_DEEMPH_B1 0xFFFF0000 | ||
1120 | #define FLD_DEEMPH_A1 0x0000FFFF | ||
1121 | |||
1122 | /*****************************************************************************/ | ||
1123 | #define DBX1_CTL1 0x884 | ||
1124 | #define FLD_DBX1_WBE_GAIN 0xffff0000 | ||
1125 | #define FLD_DBX1_IN_GAIN 0x0000ffff | ||
1126 | |||
1127 | /*****************************************************************************/ | ||
1128 | #define DBX1_CTL2 0x888 | ||
1129 | #define FLD_DBX1_SE_BYPASS 0xffff0000 | ||
1130 | #define FLD_DBX1_SE_GAIN 0x0000ffff | ||
1131 | |||
1132 | /*****************************************************************************/ | ||
1133 | #define DBX1_RMS_SE 0x88C | ||
1134 | #define FLD_DBX1_RMS_WBE 0xffff0000 | ||
1135 | #define FLD_DBX1_RMS_SE_FLD 0x0000ffff | ||
1136 | |||
1137 | /*****************************************************************************/ | ||
1138 | #define DBX2_CTL1 0x890 | ||
1139 | #define FLD_DBX2_WBE_GAIN 0xffff0000 | ||
1140 | #define FLD_DBX2_IN_GAIN 0x0000ffff | ||
1141 | |||
1142 | /*****************************************************************************/ | ||
1143 | #define DBX2_CTL2 0x894 | ||
1144 | #define FLD_DBX2_SE_BYPASS 0xffff0000 | ||
1145 | #define FLD_DBX2_SE_GAIN 0x0000ffff | ||
1146 | |||
1147 | /*****************************************************************************/ | ||
1148 | #define DBX2_RMS_SE 0x898 | ||
1149 | #define FLD_DBX2_RMS_WBE 0xffff0000 | ||
1150 | #define FLD_DBX2_RMS_SE_FLD 0x0000ffff | ||
1151 | |||
1152 | /*****************************************************************************/ | ||
1153 | #define AM_FM_DIFF 0x89c | ||
1154 | /* Reserved [31] */ | ||
1155 | #define FLD_FM_DIFF_OUT 0x7fff0000 | ||
1156 | /* Reserved [15] */ | ||
1157 | #define FLD_AM_DIFF_OUT 0x00007fff | ||
1158 | |||
1159 | /*****************************************************************************/ | ||
1160 | #define NICAM_FAW 0x8a0 | ||
1161 | #define FLD_FAWDETWINEND 0xFc000000 | ||
1162 | #define FLD_FAWDETWINSTR 0x03ff0000 | ||
1163 | /* Reserved [15:12] */ | ||
1164 | #define FLD_FAWDETTHRSHLD3 0x00000f00 | ||
1165 | #define FLD_FAWDETTHRSHLD2 0x000000f0 | ||
1166 | #define FLD_FAWDETTHRSHLD1 0x0000000f | ||
1167 | |||
1168 | /*****************************************************************************/ | ||
1169 | /* Cx231xx redefine */ | ||
1170 | #define DEEMPH_GAIN 0x8a4 | ||
1171 | #define NICAM_DEEMPHGAIN 0x8a4 | ||
1172 | /* Reserved [31:18] */ | ||
1173 | #define FLD_DEEMPHGAIN 0x0003ffff | ||
1174 | |||
1175 | /*****************************************************************************/ | ||
1176 | /* Cx231xx redefine */ | ||
1177 | #define DEEMPH_NUMER1 0x8a8 | ||
1178 | #define NICAM_DEEMPHNUMER1 0x8a8 | ||
1179 | /* Reserved [31:18] */ | ||
1180 | #define FLD_DEEMPHNUMER1 0x0003ffff | ||
1181 | |||
1182 | /*****************************************************************************/ | ||
1183 | /* Cx231xx redefine */ | ||
1184 | #define DEEMPH_NUMER2 0x8ac | ||
1185 | #define NICAM_DEEMPHNUMER2 0x8ac | ||
1186 | /* Reserved [31:18] */ | ||
1187 | #define FLD_DEEMPHNUMER2 0x0003ffff | ||
1188 | |||
1189 | /*****************************************************************************/ | ||
1190 | /* Cx231xx redefine */ | ||
1191 | #define DEEMPH_DENOM1 0x8b0 | ||
1192 | #define NICAM_DEEMPHDENOM1 0x8b0 | ||
1193 | /* Reserved [31:18] */ | ||
1194 | #define FLD_DEEMPHDENOM1 0x0003ffff | ||
1195 | |||
1196 | /*****************************************************************************/ | ||
1197 | /* Cx231xx redefine */ | ||
1198 | #define DEEMPH_DENOM2 0x8b4 | ||
1199 | #define NICAM_DEEMPHDENOM2 0x8b4 | ||
1200 | /* Reserved [31:18] */ | ||
1201 | #define FLD_DEEMPHDENOM2 0x0003ffff | ||
1202 | |||
1203 | /*****************************************************************************/ | ||
1204 | #define NICAM_ERRLOG_CTL1 0x8B8 | ||
1205 | /* Reserved [31:28] */ | ||
1206 | #define FLD_ERRINTRPTTHSHLD1 0x0fff0000 | ||
1207 | /* Reserved [15:12] */ | ||
1208 | #define FLD_ERRLOGPERIOD 0x00000fff | ||
1209 | |||
1210 | /*****************************************************************************/ | ||
1211 | #define NICAM_ERRLOG_CTL2 0x8bc | ||
1212 | /* Reserved [31:28] */ | ||
1213 | #define FLD_ERRINTRPTTHSHLD3 0x0fff0000 | ||
1214 | /* Reserved [15:12] */ | ||
1215 | #define FLD_ERRINTRPTTHSHLD2 0x00000fff | ||
1216 | |||
1217 | /*****************************************************************************/ | ||
1218 | #define NICAM_ERRLOG_STS1 0x8c0 | ||
1219 | /* Reserved [31:28] */ | ||
1220 | #define FLD_ERRLOG2 0x0fff0000 | ||
1221 | /* Reserved [15:12] */ | ||
1222 | #define FLD_ERRLOG1 0x00000fff | ||
1223 | |||
1224 | /*****************************************************************************/ | ||
1225 | #define NICAM_ERRLOG_STS2 0x8c4 | ||
1226 | /* Reserved [31:12] */ | ||
1227 | #define FLD_ERRLOG3 0x00000fff | ||
1228 | |||
1229 | /*****************************************************************************/ | ||
1230 | #define NICAM_STATUS 0x8c8 | ||
1231 | /* Reserved [31:20] */ | ||
1232 | #define FLD_NICAM_CIB 0x000c0000 | ||
1233 | #define FLD_NICAM_LOCK_STAT 0x00020000 | ||
1234 | #define FLD_NICAM_MUTE 0x00010000 | ||
1235 | #define FLD_NICAMADDIT_DATA 0x0000ffe0 | ||
1236 | #define FLD_NICAMCNTRL 0x0000001f | ||
1237 | |||
1238 | /*****************************************************************************/ | ||
1239 | #define DEMATRIX_CTL 0x8cc | ||
1240 | #define FLD_AC97_IN_SHIFT 0xf0000000 | ||
1241 | #define FLD_I2S_IN_SHIFT 0x0f000000 | ||
1242 | #define FLD_DEMATRIX_SEL_CTL 0x00ff0000 | ||
1243 | /* Reserved [15:11] */ | ||
1244 | #define FLD_DMTRX_BYPASS 0x00000400 | ||
1245 | #define FLD_DEMATRIX_MODE 0x00000300 | ||
1246 | /* Reserved [7:6] */ | ||
1247 | #define FLD_PH_DBX_SEL 0x00000020 | ||
1248 | #define FLD_PH_CH_SEL 0x00000010 | ||
1249 | #define FLD_PHASE_FIX 0x0000000f | ||
1250 | |||
1251 | /*****************************************************************************/ | ||
1252 | #define PATH1_CTL1 0x8d0 | ||
1253 | /* Reserved [31:29] */ | ||
1254 | #define FLD_PATH1_MUTE_CTL 0x1f000000 | ||
1255 | /* Reserved [23:22] */ | ||
1256 | #define FLD_PATH1_AVC_CG 0x00300000 | ||
1257 | #define FLD_PATH1_AVC_RT 0x000f0000 | ||
1258 | #define FLD_PATH1_AVC_AT 0x0000f000 | ||
1259 | #define FLD_PATH1_AVC_STEREO 0x00000800 | ||
1260 | #define FLD_PATH1_AVC_CR 0x00000700 | ||
1261 | #define FLD_PATH1_AVC_RMS_CON 0x000000f0 | ||
1262 | #define FLD_PATH1_SEL_CTL 0x0000000f | ||
1263 | |||
1264 | /*****************************************************************************/ | ||
1265 | #define PATH1_VOL_CTL 0x8d4 | ||
1266 | #define FLD_PATH1_AVC_THRESHOLD 0x7fff0000 | ||
1267 | #define FLD_PATH1_BAL_LEFT 0x00008000 | ||
1268 | #define FLD_PATH1_BAL_LEVEL 0x00007f00 | ||
1269 | #define FLD_PATH1_VOLUME 0x000000ff | ||
1270 | |||
1271 | /*****************************************************************************/ | ||
1272 | #define PATH1_EQ_CTL 0x8d8 | ||
1273 | /* Reserved [31:30] */ | ||
1274 | #define FLD_PATH1_EQ_TREBLE_VOL 0x3f000000 | ||
1275 | /* Reserved [23:22] */ | ||
1276 | #define FLD_PATH1_EQ_MID_VOL 0x003f0000 | ||
1277 | /* Reserved [15:14] */ | ||
1278 | #define FLD_PATH1_EQ_BASS_VOL 0x00003f00 | ||
1279 | /* Reserved [7:1] */ | ||
1280 | #define FLD_PATH1_EQ_BAND_SEL 0x00000001 | ||
1281 | |||
1282 | /*****************************************************************************/ | ||
1283 | #define PATH1_SC_CTL 0x8dc | ||
1284 | #define FLD_PATH1_SC_THRESHOLD 0x7fff0000 | ||
1285 | #define FLD_PATH1_SC_RT 0x0000f000 | ||
1286 | #define FLD_PATH1_SC_AT 0x00000f00 | ||
1287 | #define FLD_PATH1_SC_STEREO 0x00000080 | ||
1288 | #define FLD_PATH1_SC_CR 0x00000070 | ||
1289 | #define FLD_PATH1_SC_RMS_CON 0x0000000f | ||
1290 | |||
1291 | /*****************************************************************************/ | ||
1292 | #define PATH2_CTL1 0x8e0 | ||
1293 | /* Reserved [31:26] */ | ||
1294 | #define FLD_PATH2_MUTE_CTL 0x03000000 | ||
1295 | /* Reserved [23:22] */ | ||
1296 | #define FLD_PATH2_AVC_CG 0x00300000 | ||
1297 | #define FLD_PATH2_AVC_RT 0x000f0000 | ||
1298 | #define FLD_PATH2_AVC_AT 0x0000f000 | ||
1299 | #define FLD_PATH2_AVC_STEREO 0x00000800 | ||
1300 | #define FLD_PATH2_AVC_CR 0x00000700 | ||
1301 | #define FLD_PATH2_AVC_RMS_CON 0x000000f0 | ||
1302 | #define FLD_PATH2_SEL_CTL 0x0000000f | ||
1303 | |||
1304 | /*****************************************************************************/ | ||
1305 | #define PATH2_VOL_CTL 0x8e4 | ||
1306 | #define FLD_PATH2_AVC_THRESHOLD 0xffff0000 | ||
1307 | #define FLD_PATH2_BAL_LEFT 0x00008000 | ||
1308 | #define FLD_PATH2_BAL_LEVEL 0x00007f00 | ||
1309 | #define FLD_PATH2_VOLUME 0x000000ff | ||
1310 | |||
1311 | /*****************************************************************************/ | ||
1312 | #define PATH2_EQ_CTL 0x8e8 | ||
1313 | /* Reserved [31:30] */ | ||
1314 | #define FLD_PATH2_EQ_TREBLE_VOL 0x3f000000 | ||
1315 | /* Reserved [23:22] */ | ||
1316 | #define FLD_PATH2_EQ_MID_VOL 0x003f0000 | ||
1317 | /* Reserved [15:14] */ | ||
1318 | #define FLD_PATH2_EQ_BASS_VOL 0x00003f00 | ||
1319 | /* Reserved [7:1] */ | ||
1320 | #define FLD_PATH2_EQ_BAND_SEL 0x00000001 | ||
1321 | |||
1322 | /*****************************************************************************/ | ||
1323 | #define PATH2_SC_CTL 0x8eC | ||
1324 | #define FLD_PATH2_SC_THRESHOLD 0xffff0000 | ||
1325 | #define FLD_PATH2_SC_RT 0x0000f000 | ||
1326 | #define FLD_PATH2_SC_AT 0x00000f00 | ||
1327 | #define FLD_PATH2_SC_STEREO 0x00000080 | ||
1328 | #define FLD_PATH2_SC_CR 0x00000070 | ||
1329 | #define FLD_PATH2_SC_RMS_CON 0x0000000f | ||
1330 | |||
1331 | /*****************************************************************************/ | ||
1332 | #define SRC_CTL 0x8f0 | ||
1333 | #define FLD_SRC_STATUS 0xffffff00 | ||
1334 | #define FLD_FIFO_LF_EN 0x000000fc | ||
1335 | #define FLD_BYPASS_LI 0x00000002 | ||
1336 | #define FLD_BYPASS_PF 0x00000001 | ||
1337 | |||
1338 | /*****************************************************************************/ | ||
1339 | #define SRC_LF_COEF 0x8f4 | ||
1340 | #define FLD_LOOP_FILTER_COEF2 0xffff0000 | ||
1341 | #define FLD_LOOP_FILTER_COEF1 0x0000ffff | ||
1342 | |||
1343 | /*****************************************************************************/ | ||
1344 | #define SRC1_CTL 0x8f8 | ||
1345 | /* Reserved [31:28] */ | ||
1346 | #define FLD_SRC1_FIFO_RD_TH 0x0f000000 | ||
1347 | /* Reserved [23:18] */ | ||
1348 | #define FLD_SRC1_PHASE_INC 0x0003ffff | ||
1349 | |||
1350 | /*****************************************************************************/ | ||
1351 | #define SRC2_CTL 0x8fc | ||
1352 | /* Reserved [31:28] */ | ||
1353 | #define FLD_SRC2_FIFO_RD_TH 0x0f000000 | ||
1354 | /* Reserved [23:18] */ | ||
1355 | #define FLD_SRC2_PHASE_INC 0x0003ffff | ||
1356 | |||
1357 | /*****************************************************************************/ | ||
1358 | #define SRC3_CTL 0x900 | ||
1359 | /* Reserved [31:28] */ | ||
1360 | #define FLD_SRC3_FIFO_RD_TH 0x0f000000 | ||
1361 | /* Reserved [23:18] */ | ||
1362 | #define FLD_SRC3_PHASE_INC 0x0003ffff | ||
1363 | |||
1364 | /*****************************************************************************/ | ||
1365 | #define SRC4_CTL 0x904 | ||
1366 | /* Reserved [31:28] */ | ||
1367 | #define FLD_SRC4_FIFO_RD_TH 0x0f000000 | ||
1368 | /* Reserved [23:18] */ | ||
1369 | #define FLD_SRC4_PHASE_INC 0x0003ffff | ||
1370 | |||
1371 | /*****************************************************************************/ | ||
1372 | #define SRC5_CTL 0x908 | ||
1373 | /* Reserved [31:28] */ | ||
1374 | #define FLD_SRC5_FIFO_RD_TH 0x0f000000 | ||
1375 | /* Reserved [23:18] */ | ||
1376 | #define FLD_SRC5_PHASE_INC 0x0003ffff | ||
1377 | |||
1378 | /*****************************************************************************/ | ||
1379 | #define SRC6_CTL 0x90c | ||
1380 | /* Reserved [31:28] */ | ||
1381 | #define FLD_SRC6_FIFO_RD_TH 0x0f000000 | ||
1382 | /* Reserved [23:18] */ | ||
1383 | #define FLD_SRC6_PHASE_INC 0x0003ffff | ||
1384 | |||
1385 | /*****************************************************************************/ | ||
1386 | #define BAND_OUT_SEL 0x910 | ||
1387 | #define FLD_SRC6_IN_SEL 0xc0000000 | ||
1388 | #define FLD_SRC6_CLK_SEL 0x30000000 | ||
1389 | #define FLD_SRC5_IN_SEL 0x0c000000 | ||
1390 | #define FLD_SRC5_CLK_SEL 0x03000000 | ||
1391 | #define FLD_SRC4_IN_SEL 0x00c00000 | ||
1392 | #define FLD_SRC4_CLK_SEL 0x00300000 | ||
1393 | #define FLD_SRC3_IN_SEL 0x000c0000 | ||
1394 | #define FLD_SRC3_CLK_SEL 0x00030000 | ||
1395 | #define FLD_BASEBAND_BYPASS_CTL 0x0000ff00 | ||
1396 | #define FLD_AC97_SRC_SEL 0x000000c0 | ||
1397 | #define FLD_I2S_SRC_SEL 0x00000030 | ||
1398 | #define FLD_PARALLEL2_SRC_SEL 0x0000000c | ||
1399 | #define FLD_PARALLEL1_SRC_SEL 0x00000003 | ||
1400 | |||
1401 | /*****************************************************************************/ | ||
1402 | #define I2S_IN_CTL 0x914 | ||
1403 | /* Reserved [31:11] */ | ||
1404 | #define FLD_I2S_UP2X_BW20K 0x00000400 | ||
1405 | #define FLD_I2S_UP2X_BYPASS 0x00000200 | ||
1406 | #define FLD_I2S_IN_MASTER_MODE 0x00000100 | ||
1407 | #define FLD_I2S_IN_SONY_MODE 0x00000080 | ||
1408 | #define FLD_I2S_IN_RIGHT_JUST 0x00000040 | ||
1409 | #define FLD_I2S_IN_WS_SEL 0x00000020 | ||
1410 | #define FLD_I2S_IN_BCN_DEL 0x0000001f | ||
1411 | |||
1412 | /*****************************************************************************/ | ||
1413 | #define I2S_OUT_CTL 0x918 | ||
1414 | /* Reserved [31:17] */ | ||
1415 | #define FLD_I2S_OUT_SOFT_RESET_EN 0x00010000 | ||
1416 | /* Reserved [15:9] */ | ||
1417 | #define FLD_I2S_OUT_MASTER_MODE 0x00000100 | ||
1418 | #define FLD_I2S_OUT_SONY_MODE 0x00000080 | ||
1419 | #define FLD_I2S_OUT_RIGHT_JUST 0x00000040 | ||
1420 | #define FLD_I2S_OUT_WS_SEL 0x00000020 | ||
1421 | #define FLD_I2S_OUT_BCN_DEL 0x0000001f | ||
1422 | |||
1423 | /*****************************************************************************/ | ||
1424 | #define AC97_CTL 0x91c | ||
1425 | /* Reserved [31:26] */ | ||
1426 | #define FLD_AC97_UP2X_BW20K 0x02000000 | ||
1427 | #define FLD_AC97_UP2X_BYPASS 0x01000000 | ||
1428 | /* Reserved [23:17] */ | ||
1429 | #define FLD_AC97_RST_ACL 0x00010000 | ||
1430 | /* Reserved [15:9] */ | ||
1431 | #define FLD_AC97_WAKE_UP_SYNC 0x00000100 | ||
1432 | /* Reserved [7:1] */ | ||
1433 | #define FLD_AC97_SHUTDOWN 0x00000001 | ||
1434 | |||
1435 | /* Cx231xx redefine */ | ||
1436 | #define QPSK_IAGC_CTL1 0x94c | ||
1437 | #define QPSK_IAGC_CTL2 0x950 | ||
1438 | #define QPSK_FEPR_FREQ 0x954 | ||
1439 | #define QPSK_BTL_CTL1 0x958 | ||
1440 | #define QPSK_BTL_CTL2 0x95c | ||
1441 | #define QPSK_CTL_CTL1 0x960 | ||
1442 | #define QPSK_CTL_CTL2 0x964 | ||
1443 | #define QPSK_MF_FAGC_CTL 0x968 | ||
1444 | #define QPSK_EQ_CTL 0x96c | ||
1445 | #define QPSK_LOCK_CTL 0x970 | ||
1446 | |||
1447 | /*****************************************************************************/ | ||
1448 | #define FM1_DFT_CTL 0x9a8 | ||
1449 | #define FLD_FM1_DFT_THRESHOLD 0xffff0000 | ||
1450 | /* Reserved [15:8] */ | ||
1451 | #define FLD_FM1_DFT_CMP_CTL 0x00000080 | ||
1452 | #define FLD_FM1_DFT_AVG 0x00000070 | ||
1453 | /* Reserved [3:1] */ | ||
1454 | #define FLD_FM1_DFT_START 0x00000001 | ||
1455 | |||
1456 | /*****************************************************************************/ | ||
1457 | #define FM1_DFT_STATUS 0x9ac | ||
1458 | #define FLD_FM1_DFT_DONE 0x80000000 | ||
1459 | /* Reserved [30:19] */ | ||
1460 | #define FLD_FM_DFT_TH_CMP 0x00040000 | ||
1461 | #define FLD_FM1_DFT 0x0003ffff | ||
1462 | |||
1463 | /*****************************************************************************/ | ||
1464 | #define FM2_DFT_CTL 0x9b0 | ||
1465 | #define FLD_FM2_DFT_THRESHOLD 0xffff0000 | ||
1466 | /* Reserved [15:8] */ | ||
1467 | #define FLD_FM2_DFT_CMP_CTL 0x00000080 | ||
1468 | #define FLD_FM2_DFT_AVG 0x00000070 | ||
1469 | /* Reserved [3:1] */ | ||
1470 | #define FLD_FM2_DFT_START 0x00000001 | ||
1471 | |||
1472 | /*****************************************************************************/ | ||
1473 | #define FM2_DFT_STATUS 0x9b4 | ||
1474 | #define FLD_FM2_DFT_DONE 0x80000000 | ||
1475 | /* Reserved [30:19] */ | ||
1476 | #define FLD_FM2_DFT_TH_CMP_STAT 0x00040000 | ||
1477 | #define FLD_FM2_DFT 0x0003ffff | ||
1478 | |||
1479 | /*****************************************************************************/ | ||
1480 | /* Cx231xx redefine */ | ||
1481 | #define AAGC_STATUS_REG 0x9b8 | ||
1482 | #define AAGC_STATUS 0x9b8 | ||
1483 | /* Reserved [31:27] */ | ||
1484 | #define FLD_FM2_DAGC_OUT 0x07000000 | ||
1485 | /* Reserved [23:19] */ | ||
1486 | #define FLD_FM1_DAGC_OUT 0x00070000 | ||
1487 | /* Reserved [15:6] */ | ||
1488 | #define FLD_AFE_VGA_OUT 0x0000003f | ||
1489 | |||
1490 | /*****************************************************************************/ | ||
1491 | #define MTS_GAIN_STATUS 0x9bc | ||
1492 | /* Reserved [31:14] */ | ||
1493 | #define FLD_MTS_GAIN 0x00003fff | ||
1494 | |||
1495 | #define RDS_OUT 0x9c0 | ||
1496 | #define FLD_RDS_Q 0xffff0000 | ||
1497 | #define FLD_RDS_I 0x0000ffff | ||
1498 | |||
1499 | /*****************************************************************************/ | ||
1500 | #define AUTOCONFIG_REG 0x9c4 | ||
1501 | /* Reserved [31:4] */ | ||
1502 | #define FLD_AUTOCONFIG_MODE 0x0000000f | ||
1503 | |||
1504 | #define FM_AFC 0x9c8 | ||
1505 | #define FLD_FM2_AFC 0xffff0000 | ||
1506 | #define FLD_FM1_AFC 0x0000ffff | ||
1507 | |||
1508 | /*****************************************************************************/ | ||
1509 | /* Cx231xx redefine */ | ||
1510 | #define NEW_SPARE 0x9cc | ||
1511 | #define NEW_SPARE_REG 0x9cc | ||
1512 | |||
1513 | /*****************************************************************************/ | ||
1514 | #define DBX_ADJ 0x9d0 | ||
1515 | /* Reserved [31:28] */ | ||
1516 | #define FLD_DBX2_ADJ 0x0fff0000 | ||
1517 | /* Reserved [15:12] */ | ||
1518 | #define FLD_DBX1_ADJ 0x00000fff | ||
1519 | |||
1520 | #define VID_FMT_AUTO 0 | ||
1521 | #define VID_FMT_NTSC_M 1 | ||
1522 | #define VID_FMT_NTSC_J 2 | ||
1523 | #define VID_FMT_NTSC_443 3 | ||
1524 | #define VID_FMT_PAL_BDGHI 4 | ||
1525 | #define VID_FMT_PAL_M 5 | ||
1526 | #define VID_FMT_PAL_N 6 | ||
1527 | #define VID_FMT_PAL_NC 7 | ||
1528 | #define VID_FMT_PAL_60 8 | ||
1529 | #define VID_FMT_SECAM 12 | ||
1530 | #define VID_FMT_SECAM_60 13 | ||
1531 | |||
1532 | #define INPUT_MODE_CVBS_0 0 /* INPUT_MODE_VALUE(0) */ | ||
1533 | #define INPUT_MODE_YC_1 1 /* INPUT_MODE_VALUE(1) */ | ||
1534 | #define INPUT_MODE_YC2_2 2 /* INPUT_MODE_VALUE(2) */ | ||
1535 | #define INPUT_MODE_YUV_3 3 /* INPUT_MODE_VALUE(3) */ | ||
1536 | |||
1537 | #define LUMA_LPF_LOW_BANDPASS 0 /* 0.6Mhz LPF BW */ | ||
1538 | #define LUMA_LPF_MEDIUM_BANDPASS 1 /* 1.0Mhz LPF BW */ | ||
1539 | #define LUMA_LPF_HIGH_BANDPASS 2 /* 1.5Mhz LPF BW */ | ||
1540 | |||
1541 | #define UV_LPF_LOW_BANDPASS 0 /* 0.6Mhz LPF BW */ | ||
1542 | #define UV_LPF_MEDIUM_BANDPASS 1 /* 1.0Mhz LPF BW */ | ||
1543 | #define UV_LPF_HIGH_BANDPASS 2 /* 1.5Mhz LPF BW */ | ||
1544 | |||
1545 | #define TWO_TAP_FILT 0 | ||
1546 | #define THREE_TAP_FILT 1 | ||
1547 | #define FOUR_TAP_FILT 2 | ||
1548 | #define FIVE_TAP_FILT 3 | ||
1549 | |||
1550 | #define AUD_CHAN_SRC_PARALLEL 0 | ||
1551 | #define AUD_CHAN_SRC_I2S_INPUT 1 | ||
1552 | #define AUD_CHAN_SRC_FLATIRON 2 | ||
1553 | #define AUD_CHAN_SRC_PARALLEL3 3 | ||
1554 | |||
1555 | #define OUT_MODE_601 0 | ||
1556 | #define OUT_MODE_656 1 | ||
1557 | #define OUT_MODE_VIP11 2 | ||
1558 | #define OUT_MODE_VIP20 3 | ||
1559 | |||
1560 | #define PHASE_INC_49MHZ 0x0df22 | ||
1561 | #define PHASE_INC_56MHZ 0x0fa5b | ||
1562 | #define PHASE_INC_28MHZ 0x010000 | ||
1563 | |||
1564 | #endif | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.c b/drivers/media/usb/cx231xx/cx231xx-vbi.c new file mode 100644 index 000000000000..ac7db52f404f --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-vbi.c | |||
@@ -0,0 +1,710 @@ | |||
1 | /* | ||
2 | cx231xx_vbi.c - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on cx88 driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #include <linux/init.h> | ||
23 | #include <linux/list.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/bitmap.h> | ||
27 | #include <linux/usb.h> | ||
28 | #include <linux/i2c.h> | ||
29 | #include <linux/mm.h> | ||
30 | #include <linux/mutex.h> | ||
31 | #include <linux/slab.h> | ||
32 | |||
33 | #include <media/v4l2-common.h> | ||
34 | #include <media/v4l2-ioctl.h> | ||
35 | #include <media/v4l2-chip-ident.h> | ||
36 | #include <media/msp3400.h> | ||
37 | #include <media/tuner.h> | ||
38 | |||
39 | #include "cx231xx.h" | ||
40 | #include "cx231xx-vbi.h" | ||
41 | |||
42 | static inline void print_err_status(struct cx231xx *dev, int packet, int status) | ||
43 | { | ||
44 | char *errmsg = "Unknown"; | ||
45 | |||
46 | switch (status) { | ||
47 | case -ENOENT: | ||
48 | errmsg = "unlinked synchronuously"; | ||
49 | break; | ||
50 | case -ECONNRESET: | ||
51 | errmsg = "unlinked asynchronuously"; | ||
52 | break; | ||
53 | case -ENOSR: | ||
54 | errmsg = "Buffer error (overrun)"; | ||
55 | break; | ||
56 | case -EPIPE: | ||
57 | errmsg = "Stalled (device not responding)"; | ||
58 | break; | ||
59 | case -EOVERFLOW: | ||
60 | errmsg = "Babble (bad cable?)"; | ||
61 | break; | ||
62 | case -EPROTO: | ||
63 | errmsg = "Bit-stuff error (bad cable?)"; | ||
64 | break; | ||
65 | case -EILSEQ: | ||
66 | errmsg = "CRC/Timeout (could be anything)"; | ||
67 | break; | ||
68 | case -ETIME: | ||
69 | errmsg = "Device does not respond"; | ||
70 | break; | ||
71 | } | ||
72 | if (packet < 0) { | ||
73 | cx231xx_err(DRIVER_NAME "URB status %d [%s].\n", status, | ||
74 | errmsg); | ||
75 | } else { | ||
76 | cx231xx_err(DRIVER_NAME "URB packet %d, status %d [%s].\n", | ||
77 | packet, status, errmsg); | ||
78 | } | ||
79 | } | ||
80 | |||
81 | /* | ||
82 | * Controls the isoc copy of each urb packet | ||
83 | */ | ||
84 | static inline int cx231xx_isoc_vbi_copy(struct cx231xx *dev, struct urb *urb) | ||
85 | { | ||
86 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
87 | int rc = 1; | ||
88 | unsigned char *p_buffer; | ||
89 | u32 bytes_parsed = 0, buffer_size = 0; | ||
90 | u8 sav_eav = 0; | ||
91 | |||
92 | if (!dev) | ||
93 | return 0; | ||
94 | |||
95 | if (dev->state & DEV_DISCONNECTED) | ||
96 | return 0; | ||
97 | |||
98 | if (urb->status < 0) { | ||
99 | print_err_status(dev, -1, urb->status); | ||
100 | if (urb->status == -ENOENT) | ||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | /* get buffer pointer and length */ | ||
105 | p_buffer = urb->transfer_buffer; | ||
106 | buffer_size = urb->actual_length; | ||
107 | |||
108 | if (buffer_size > 0) { | ||
109 | bytes_parsed = 0; | ||
110 | |||
111 | if (dma_q->is_partial_line) { | ||
112 | /* Handle the case where we were working on a partial | ||
113 | line */ | ||
114 | sav_eav = dma_q->last_sav; | ||
115 | } else { | ||
116 | /* Check for a SAV/EAV overlapping the | ||
117 | buffer boundary */ | ||
118 | |||
119 | sav_eav = cx231xx_find_boundary_SAV_EAV(p_buffer, | ||
120 | dma_q->partial_buf, | ||
121 | &bytes_parsed); | ||
122 | } | ||
123 | |||
124 | sav_eav &= 0xF0; | ||
125 | /* Get the first line if we have some portion of an SAV/EAV from | ||
126 | the last buffer or a partial line */ | ||
127 | if (sav_eav) { | ||
128 | bytes_parsed += cx231xx_get_vbi_line(dev, dma_q, | ||
129 | sav_eav, /* SAV/EAV */ | ||
130 | p_buffer + bytes_parsed, /* p_buffer */ | ||
131 | buffer_size - bytes_parsed); /* buffer size */ | ||
132 | } | ||
133 | |||
134 | /* Now parse data that is completely in this buffer */ | ||
135 | dma_q->is_partial_line = 0; | ||
136 | |||
137 | while (bytes_parsed < buffer_size) { | ||
138 | u32 bytes_used = 0; | ||
139 | |||
140 | sav_eav = cx231xx_find_next_SAV_EAV( | ||
141 | p_buffer + bytes_parsed, /* p_buffer */ | ||
142 | buffer_size - bytes_parsed, /* buffer size */ | ||
143 | &bytes_used); /* bytes used to get SAV/EAV */ | ||
144 | |||
145 | bytes_parsed += bytes_used; | ||
146 | |||
147 | sav_eav &= 0xF0; | ||
148 | if (sav_eav && (bytes_parsed < buffer_size)) { | ||
149 | bytes_parsed += cx231xx_get_vbi_line(dev, | ||
150 | dma_q, sav_eav, /* SAV/EAV */ | ||
151 | p_buffer+bytes_parsed, /* p_buffer */ | ||
152 | buffer_size-bytes_parsed);/*buf size*/ | ||
153 | } | ||
154 | } | ||
155 | |||
156 | /* Save the last four bytes of the buffer so we can | ||
157 | check the buffer boundary condition next time */ | ||
158 | memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4); | ||
159 | bytes_parsed = 0; | ||
160 | } | ||
161 | |||
162 | return rc; | ||
163 | } | ||
164 | |||
165 | /* ------------------------------------------------------------------ | ||
166 | Vbi buf operations | ||
167 | ------------------------------------------------------------------*/ | ||
168 | |||
169 | static int | ||
170 | vbi_buffer_setup(struct videobuf_queue *vq, unsigned int *count, | ||
171 | unsigned int *size) | ||
172 | { | ||
173 | struct cx231xx_fh *fh = vq->priv_data; | ||
174 | struct cx231xx *dev = fh->dev; | ||
175 | u32 height = 0; | ||
176 | |||
177 | height = ((dev->norm & V4L2_STD_625_50) ? | ||
178 | PAL_VBI_LINES : NTSC_VBI_LINES); | ||
179 | |||
180 | *size = (dev->width * height * 2 * 2); | ||
181 | if (0 == *count) | ||
182 | *count = CX231XX_DEF_VBI_BUF; | ||
183 | |||
184 | if (*count < CX231XX_MIN_BUF) | ||
185 | *count = CX231XX_MIN_BUF; | ||
186 | |||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | /* This is called *without* dev->slock held; please keep it that way */ | ||
191 | static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) | ||
192 | { | ||
193 | struct cx231xx_fh *fh = vq->priv_data; | ||
194 | struct cx231xx *dev = fh->dev; | ||
195 | unsigned long flags = 0; | ||
196 | if (in_interrupt()) | ||
197 | BUG(); | ||
198 | |||
199 | /* We used to wait for the buffer to finish here, but this didn't work | ||
200 | because, as we were keeping the state as VIDEOBUF_QUEUED, | ||
201 | videobuf_queue_cancel marked it as finished for us. | ||
202 | (Also, it could wedge forever if the hardware was misconfigured.) | ||
203 | |||
204 | This should be safe; by the time we get here, the buffer isn't | ||
205 | queued anymore. If we ever start marking the buffers as | ||
206 | VIDEOBUF_ACTIVE, it won't be, though. | ||
207 | */ | ||
208 | spin_lock_irqsave(&dev->vbi_mode.slock, flags); | ||
209 | if (dev->vbi_mode.bulk_ctl.buf == buf) | ||
210 | dev->vbi_mode.bulk_ctl.buf = NULL; | ||
211 | spin_unlock_irqrestore(&dev->vbi_mode.slock, flags); | ||
212 | |||
213 | videobuf_vmalloc_free(&buf->vb); | ||
214 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
215 | } | ||
216 | |||
217 | static int | ||
218 | vbi_buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | ||
219 | enum v4l2_field field) | ||
220 | { | ||
221 | struct cx231xx_fh *fh = vq->priv_data; | ||
222 | struct cx231xx_buffer *buf = | ||
223 | container_of(vb, struct cx231xx_buffer, vb); | ||
224 | struct cx231xx *dev = fh->dev; | ||
225 | int rc = 0, urb_init = 0; | ||
226 | u32 height = 0; | ||
227 | |||
228 | height = ((dev->norm & V4L2_STD_625_50) ? | ||
229 | PAL_VBI_LINES : NTSC_VBI_LINES); | ||
230 | buf->vb.size = ((dev->width << 1) * height * 2); | ||
231 | |||
232 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | ||
233 | return -EINVAL; | ||
234 | |||
235 | buf->vb.width = dev->width; | ||
236 | buf->vb.height = height; | ||
237 | buf->vb.field = field; | ||
238 | buf->vb.field = V4L2_FIELD_SEQ_TB; | ||
239 | |||
240 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
241 | rc = videobuf_iolock(vq, &buf->vb, NULL); | ||
242 | if (rc < 0) | ||
243 | goto fail; | ||
244 | } | ||
245 | |||
246 | if (!dev->vbi_mode.bulk_ctl.num_bufs) | ||
247 | urb_init = 1; | ||
248 | |||
249 | if (urb_init) { | ||
250 | rc = cx231xx_init_vbi_isoc(dev, CX231XX_NUM_VBI_PACKETS, | ||
251 | CX231XX_NUM_VBI_BUFS, | ||
252 | dev->vbi_mode.alt_max_pkt_size[0], | ||
253 | cx231xx_isoc_vbi_copy); | ||
254 | if (rc < 0) | ||
255 | goto fail; | ||
256 | } | ||
257 | |||
258 | buf->vb.state = VIDEOBUF_PREPARED; | ||
259 | return 0; | ||
260 | |||
261 | fail: | ||
262 | free_buffer(vq, buf); | ||
263 | return rc; | ||
264 | } | ||
265 | |||
266 | static void | ||
267 | vbi_buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | ||
268 | { | ||
269 | struct cx231xx_buffer *buf = | ||
270 | container_of(vb, struct cx231xx_buffer, vb); | ||
271 | struct cx231xx_fh *fh = vq->priv_data; | ||
272 | struct cx231xx *dev = fh->dev; | ||
273 | struct cx231xx_dmaqueue *vidq = &dev->vbi_mode.vidq; | ||
274 | |||
275 | buf->vb.state = VIDEOBUF_QUEUED; | ||
276 | list_add_tail(&buf->vb.queue, &vidq->active); | ||
277 | |||
278 | } | ||
279 | |||
280 | static void vbi_buffer_release(struct videobuf_queue *vq, | ||
281 | struct videobuf_buffer *vb) | ||
282 | { | ||
283 | struct cx231xx_buffer *buf = | ||
284 | container_of(vb, struct cx231xx_buffer, vb); | ||
285 | |||
286 | |||
287 | free_buffer(vq, buf); | ||
288 | } | ||
289 | |||
290 | struct videobuf_queue_ops cx231xx_vbi_qops = { | ||
291 | .buf_setup = vbi_buffer_setup, | ||
292 | .buf_prepare = vbi_buffer_prepare, | ||
293 | .buf_queue = vbi_buffer_queue, | ||
294 | .buf_release = vbi_buffer_release, | ||
295 | }; | ||
296 | |||
297 | /* ------------------------------------------------------------------ | ||
298 | URB control | ||
299 | ------------------------------------------------------------------*/ | ||
300 | |||
301 | /* | ||
302 | * IRQ callback, called by URB callback | ||
303 | */ | ||
304 | static void cx231xx_irq_vbi_callback(struct urb *urb) | ||
305 | { | ||
306 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
307 | struct cx231xx_video_mode *vmode = | ||
308 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
309 | struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); | ||
310 | |||
311 | switch (urb->status) { | ||
312 | case 0: /* success */ | ||
313 | case -ETIMEDOUT: /* NAK */ | ||
314 | break; | ||
315 | case -ECONNRESET: /* kill */ | ||
316 | case -ENOENT: | ||
317 | case -ESHUTDOWN: | ||
318 | return; | ||
319 | default: /* error */ | ||
320 | cx231xx_err(DRIVER_NAME "urb completition error %d.\n", | ||
321 | urb->status); | ||
322 | break; | ||
323 | } | ||
324 | |||
325 | /* Copy data from URB */ | ||
326 | spin_lock(&dev->vbi_mode.slock); | ||
327 | dev->vbi_mode.bulk_ctl.bulk_copy(dev, urb); | ||
328 | spin_unlock(&dev->vbi_mode.slock); | ||
329 | |||
330 | /* Reset status */ | ||
331 | urb->status = 0; | ||
332 | |||
333 | urb->status = usb_submit_urb(urb, GFP_ATOMIC); | ||
334 | if (urb->status) { | ||
335 | cx231xx_err(DRIVER_NAME "urb resubmit failed (error=%i)\n", | ||
336 | urb->status); | ||
337 | } | ||
338 | } | ||
339 | |||
340 | /* | ||
341 | * Stop and Deallocate URBs | ||
342 | */ | ||
343 | void cx231xx_uninit_vbi_isoc(struct cx231xx *dev) | ||
344 | { | ||
345 | struct urb *urb; | ||
346 | int i; | ||
347 | |||
348 | cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_uninit_vbi_isoc\n"); | ||
349 | |||
350 | dev->vbi_mode.bulk_ctl.nfields = -1; | ||
351 | for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) { | ||
352 | urb = dev->vbi_mode.bulk_ctl.urb[i]; | ||
353 | if (urb) { | ||
354 | if (!irqs_disabled()) | ||
355 | usb_kill_urb(urb); | ||
356 | else | ||
357 | usb_unlink_urb(urb); | ||
358 | |||
359 | if (dev->vbi_mode.bulk_ctl.transfer_buffer[i]) { | ||
360 | |||
361 | kfree(dev->vbi_mode.bulk_ctl. | ||
362 | transfer_buffer[i]); | ||
363 | dev->vbi_mode.bulk_ctl.transfer_buffer[i] = | ||
364 | NULL; | ||
365 | } | ||
366 | usb_free_urb(urb); | ||
367 | dev->vbi_mode.bulk_ctl.urb[i] = NULL; | ||
368 | } | ||
369 | dev->vbi_mode.bulk_ctl.transfer_buffer[i] = NULL; | ||
370 | } | ||
371 | |||
372 | kfree(dev->vbi_mode.bulk_ctl.urb); | ||
373 | kfree(dev->vbi_mode.bulk_ctl.transfer_buffer); | ||
374 | |||
375 | dev->vbi_mode.bulk_ctl.urb = NULL; | ||
376 | dev->vbi_mode.bulk_ctl.transfer_buffer = NULL; | ||
377 | dev->vbi_mode.bulk_ctl.num_bufs = 0; | ||
378 | |||
379 | cx231xx_capture_start(dev, 0, Vbi); | ||
380 | } | ||
381 | EXPORT_SYMBOL_GPL(cx231xx_uninit_vbi_isoc); | ||
382 | |||
383 | /* | ||
384 | * Allocate URBs and start IRQ | ||
385 | */ | ||
386 | int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | ||
387 | int num_bufs, int max_pkt_size, | ||
388 | int (*bulk_copy) (struct cx231xx *dev, | ||
389 | struct urb *urb)) | ||
390 | { | ||
391 | struct cx231xx_dmaqueue *dma_q = &dev->vbi_mode.vidq; | ||
392 | int i; | ||
393 | int sb_size, pipe; | ||
394 | struct urb *urb; | ||
395 | int rc; | ||
396 | |||
397 | cx231xx_info(DRIVER_NAME "cx231xx: called cx231xx_prepare_isoc\n"); | ||
398 | |||
399 | /* De-allocates all pending stuff */ | ||
400 | cx231xx_uninit_vbi_isoc(dev); | ||
401 | |||
402 | /* clear if any halt */ | ||
403 | usb_clear_halt(dev->udev, | ||
404 | usb_rcvbulkpipe(dev->udev, | ||
405 | dev->vbi_mode.end_point_addr)); | ||
406 | |||
407 | dev->vbi_mode.bulk_ctl.bulk_copy = bulk_copy; | ||
408 | dev->vbi_mode.bulk_ctl.num_bufs = num_bufs; | ||
409 | dma_q->pos = 0; | ||
410 | dma_q->is_partial_line = 0; | ||
411 | dma_q->last_sav = 0; | ||
412 | dma_q->current_field = -1; | ||
413 | dma_q->bytes_left_in_line = dev->width << 1; | ||
414 | dma_q->lines_per_field = ((dev->norm & V4L2_STD_625_50) ? | ||
415 | PAL_VBI_LINES : NTSC_VBI_LINES); | ||
416 | dma_q->lines_completed = 0; | ||
417 | for (i = 0; i < 8; i++) | ||
418 | dma_q->partial_buf[i] = 0; | ||
419 | |||
420 | dev->vbi_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs, | ||
421 | GFP_KERNEL); | ||
422 | if (!dev->vbi_mode.bulk_ctl.urb) { | ||
423 | cx231xx_errdev("cannot alloc memory for usb buffers\n"); | ||
424 | return -ENOMEM; | ||
425 | } | ||
426 | |||
427 | dev->vbi_mode.bulk_ctl.transfer_buffer = | ||
428 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | ||
429 | if (!dev->vbi_mode.bulk_ctl.transfer_buffer) { | ||
430 | cx231xx_errdev("cannot allocate memory for usbtransfer\n"); | ||
431 | kfree(dev->vbi_mode.bulk_ctl.urb); | ||
432 | return -ENOMEM; | ||
433 | } | ||
434 | |||
435 | dev->vbi_mode.bulk_ctl.max_pkt_size = max_pkt_size; | ||
436 | dev->vbi_mode.bulk_ctl.buf = NULL; | ||
437 | |||
438 | sb_size = max_packets * dev->vbi_mode.bulk_ctl.max_pkt_size; | ||
439 | |||
440 | /* allocate urbs and transfer buffers */ | ||
441 | for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) { | ||
442 | |||
443 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
444 | if (!urb) { | ||
445 | cx231xx_err(DRIVER_NAME | ||
446 | ": cannot alloc bulk_ctl.urb %i\n", i); | ||
447 | cx231xx_uninit_vbi_isoc(dev); | ||
448 | return -ENOMEM; | ||
449 | } | ||
450 | dev->vbi_mode.bulk_ctl.urb[i] = urb; | ||
451 | urb->transfer_flags = 0; | ||
452 | |||
453 | dev->vbi_mode.bulk_ctl.transfer_buffer[i] = | ||
454 | kzalloc(sb_size, GFP_KERNEL); | ||
455 | if (!dev->vbi_mode.bulk_ctl.transfer_buffer[i]) { | ||
456 | cx231xx_err(DRIVER_NAME | ||
457 | ": unable to allocate %i bytes for transfer" | ||
458 | " buffer %i%s\n", sb_size, i, | ||
459 | in_interrupt() ? " while in int" : ""); | ||
460 | cx231xx_uninit_vbi_isoc(dev); | ||
461 | return -ENOMEM; | ||
462 | } | ||
463 | |||
464 | pipe = usb_rcvbulkpipe(dev->udev, dev->vbi_mode.end_point_addr); | ||
465 | usb_fill_bulk_urb(urb, dev->udev, pipe, | ||
466 | dev->vbi_mode.bulk_ctl.transfer_buffer[i], | ||
467 | sb_size, cx231xx_irq_vbi_callback, dma_q); | ||
468 | } | ||
469 | |||
470 | init_waitqueue_head(&dma_q->wq); | ||
471 | |||
472 | /* submit urbs and enables IRQ */ | ||
473 | for (i = 0; i < dev->vbi_mode.bulk_ctl.num_bufs; i++) { | ||
474 | rc = usb_submit_urb(dev->vbi_mode.bulk_ctl.urb[i], GFP_ATOMIC); | ||
475 | if (rc) { | ||
476 | cx231xx_err(DRIVER_NAME | ||
477 | ": submit of urb %i failed (error=%i)\n", i, | ||
478 | rc); | ||
479 | cx231xx_uninit_vbi_isoc(dev); | ||
480 | return rc; | ||
481 | } | ||
482 | } | ||
483 | |||
484 | cx231xx_capture_start(dev, 1, Vbi); | ||
485 | |||
486 | return 0; | ||
487 | } | ||
488 | EXPORT_SYMBOL_GPL(cx231xx_init_vbi_isoc); | ||
489 | |||
490 | u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
491 | u8 sav_eav, u8 *p_buffer, u32 buffer_size) | ||
492 | { | ||
493 | u32 bytes_copied = 0; | ||
494 | int current_field = -1; | ||
495 | |||
496 | switch (sav_eav) { | ||
497 | |||
498 | case SAV_VBI_FIELD1: | ||
499 | current_field = 1; | ||
500 | break; | ||
501 | |||
502 | case SAV_VBI_FIELD2: | ||
503 | current_field = 2; | ||
504 | break; | ||
505 | default: | ||
506 | break; | ||
507 | } | ||
508 | |||
509 | if (current_field < 0) | ||
510 | return bytes_copied; | ||
511 | |||
512 | dma_q->last_sav = sav_eav; | ||
513 | |||
514 | bytes_copied = | ||
515 | cx231xx_copy_vbi_line(dev, dma_q, p_buffer, buffer_size, | ||
516 | current_field); | ||
517 | |||
518 | return bytes_copied; | ||
519 | } | ||
520 | |||
521 | /* | ||
522 | * Announces that a buffer were filled and request the next | ||
523 | */ | ||
524 | static inline void vbi_buffer_filled(struct cx231xx *dev, | ||
525 | struct cx231xx_dmaqueue *dma_q, | ||
526 | struct cx231xx_buffer *buf) | ||
527 | { | ||
528 | /* Advice that buffer was filled */ | ||
529 | /* cx231xx_info(DRIVER_NAME "[%p/%d] wakeup\n", buf, buf->vb.i); */ | ||
530 | |||
531 | buf->vb.state = VIDEOBUF_DONE; | ||
532 | buf->vb.field_count++; | ||
533 | do_gettimeofday(&buf->vb.ts); | ||
534 | |||
535 | dev->vbi_mode.bulk_ctl.buf = NULL; | ||
536 | |||
537 | list_del(&buf->vb.queue); | ||
538 | wake_up(&buf->vb.done); | ||
539 | } | ||
540 | |||
541 | u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
542 | u8 *p_line, u32 length, int field_number) | ||
543 | { | ||
544 | u32 bytes_to_copy; | ||
545 | struct cx231xx_buffer *buf; | ||
546 | u32 _line_size = dev->width * 2; | ||
547 | |||
548 | if (dma_q->current_field == -1) { | ||
549 | /* Just starting up */ | ||
550 | cx231xx_reset_vbi_buffer(dev, dma_q); | ||
551 | } | ||
552 | |||
553 | if (dma_q->current_field != field_number) | ||
554 | dma_q->lines_completed = 0; | ||
555 | |||
556 | /* get the buffer pointer */ | ||
557 | buf = dev->vbi_mode.bulk_ctl.buf; | ||
558 | |||
559 | /* Remember the field number for next time */ | ||
560 | dma_q->current_field = field_number; | ||
561 | |||
562 | bytes_to_copy = dma_q->bytes_left_in_line; | ||
563 | if (bytes_to_copy > length) | ||
564 | bytes_to_copy = length; | ||
565 | |||
566 | if (dma_q->lines_completed >= dma_q->lines_per_field) { | ||
567 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
568 | dma_q->is_partial_line = | ||
569 | (dma_q->bytes_left_in_line == 0) ? 0 : 1; | ||
570 | return 0; | ||
571 | } | ||
572 | |||
573 | dma_q->is_partial_line = 1; | ||
574 | |||
575 | /* If we don't have a buffer, just return the number of bytes we would | ||
576 | have copied if we had a buffer. */ | ||
577 | if (!buf) { | ||
578 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
579 | dma_q->is_partial_line = | ||
580 | (dma_q->bytes_left_in_line == 0) ? 0 : 1; | ||
581 | return bytes_to_copy; | ||
582 | } | ||
583 | |||
584 | /* copy the data to video buffer */ | ||
585 | cx231xx_do_vbi_copy(dev, dma_q, p_line, bytes_to_copy); | ||
586 | |||
587 | dma_q->pos += bytes_to_copy; | ||
588 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
589 | |||
590 | if (dma_q->bytes_left_in_line == 0) { | ||
591 | |||
592 | dma_q->bytes_left_in_line = _line_size; | ||
593 | dma_q->lines_completed++; | ||
594 | dma_q->is_partial_line = 0; | ||
595 | |||
596 | if (cx231xx_is_vbi_buffer_done(dev, dma_q) && buf) { | ||
597 | |||
598 | vbi_buffer_filled(dev, dma_q, buf); | ||
599 | |||
600 | dma_q->pos = 0; | ||
601 | dma_q->lines_completed = 0; | ||
602 | cx231xx_reset_vbi_buffer(dev, dma_q); | ||
603 | } | ||
604 | } | ||
605 | |||
606 | return bytes_to_copy; | ||
607 | } | ||
608 | |||
609 | /* | ||
610 | * video-buf generic routine to get the next available buffer | ||
611 | */ | ||
612 | static inline void get_next_vbi_buf(struct cx231xx_dmaqueue *dma_q, | ||
613 | struct cx231xx_buffer **buf) | ||
614 | { | ||
615 | struct cx231xx_video_mode *vmode = | ||
616 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
617 | struct cx231xx *dev = container_of(vmode, struct cx231xx, vbi_mode); | ||
618 | char *outp; | ||
619 | |||
620 | if (list_empty(&dma_q->active)) { | ||
621 | cx231xx_err(DRIVER_NAME ": No active queue to serve\n"); | ||
622 | dev->vbi_mode.bulk_ctl.buf = NULL; | ||
623 | *buf = NULL; | ||
624 | return; | ||
625 | } | ||
626 | |||
627 | /* Get the next buffer */ | ||
628 | *buf = list_entry(dma_q->active.next, struct cx231xx_buffer, vb.queue); | ||
629 | |||
630 | /* Cleans up buffer - Useful for testing for frame/URB loss */ | ||
631 | outp = videobuf_to_vmalloc(&(*buf)->vb); | ||
632 | memset(outp, 0, (*buf)->vb.size); | ||
633 | |||
634 | dev->vbi_mode.bulk_ctl.buf = *buf; | ||
635 | |||
636 | return; | ||
637 | } | ||
638 | |||
639 | void cx231xx_reset_vbi_buffer(struct cx231xx *dev, | ||
640 | struct cx231xx_dmaqueue *dma_q) | ||
641 | { | ||
642 | struct cx231xx_buffer *buf; | ||
643 | |||
644 | buf = dev->vbi_mode.bulk_ctl.buf; | ||
645 | |||
646 | if (buf == NULL) { | ||
647 | /* first try to get the buffer */ | ||
648 | get_next_vbi_buf(dma_q, &buf); | ||
649 | |||
650 | dma_q->pos = 0; | ||
651 | dma_q->current_field = -1; | ||
652 | } | ||
653 | |||
654 | dma_q->bytes_left_in_line = dev->width << 1; | ||
655 | dma_q->lines_completed = 0; | ||
656 | } | ||
657 | |||
658 | int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
659 | u8 *p_buffer, u32 bytes_to_copy) | ||
660 | { | ||
661 | u8 *p_out_buffer = NULL; | ||
662 | u32 current_line_bytes_copied = 0; | ||
663 | struct cx231xx_buffer *buf; | ||
664 | u32 _line_size = dev->width << 1; | ||
665 | void *startwrite; | ||
666 | int offset, lencopy; | ||
667 | |||
668 | buf = dev->vbi_mode.bulk_ctl.buf; | ||
669 | |||
670 | if (buf == NULL) | ||
671 | return -EINVAL; | ||
672 | |||
673 | p_out_buffer = videobuf_to_vmalloc(&buf->vb); | ||
674 | |||
675 | if (dma_q->bytes_left_in_line != _line_size) { | ||
676 | current_line_bytes_copied = | ||
677 | _line_size - dma_q->bytes_left_in_line; | ||
678 | } | ||
679 | |||
680 | offset = (dma_q->lines_completed * _line_size) + | ||
681 | current_line_bytes_copied; | ||
682 | |||
683 | if (dma_q->current_field == 2) { | ||
684 | /* Populate the second half of the frame */ | ||
685 | offset += (dev->width * 2 * dma_q->lines_per_field); | ||
686 | } | ||
687 | |||
688 | /* prepare destination address */ | ||
689 | startwrite = p_out_buffer + offset; | ||
690 | |||
691 | lencopy = dma_q->bytes_left_in_line > bytes_to_copy ? | ||
692 | bytes_to_copy : dma_q->bytes_left_in_line; | ||
693 | |||
694 | memcpy(startwrite, p_buffer, lencopy); | ||
695 | |||
696 | return 0; | ||
697 | } | ||
698 | |||
699 | u8 cx231xx_is_vbi_buffer_done(struct cx231xx *dev, | ||
700 | struct cx231xx_dmaqueue *dma_q) | ||
701 | { | ||
702 | u32 height = 0; | ||
703 | |||
704 | height = ((dev->norm & V4L2_STD_625_50) ? | ||
705 | PAL_VBI_LINES : NTSC_VBI_LINES); | ||
706 | if (dma_q->lines_completed == height && dma_q->current_field == 2) | ||
707 | return 1; | ||
708 | else | ||
709 | return 0; | ||
710 | } | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.h b/drivers/media/usb/cx231xx/cx231xx-vbi.h new file mode 100644 index 000000000000..16c7d20a22a4 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-vbi.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | cx231xx_vbi.h - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on cx88 driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _CX231XX_VBI_H | ||
23 | #define _CX231XX_VBI_H | ||
24 | |||
25 | extern struct videobuf_queue_ops cx231xx_vbi_qops; | ||
26 | |||
27 | #define NTSC_VBI_START_LINE 10 /* line 10 - 21 */ | ||
28 | #define NTSC_VBI_END_LINE 21 | ||
29 | #define NTSC_VBI_LINES (NTSC_VBI_END_LINE-NTSC_VBI_START_LINE+1) | ||
30 | |||
31 | #define PAL_VBI_START_LINE 6 | ||
32 | #define PAL_VBI_END_LINE 23 | ||
33 | #define PAL_VBI_LINES (PAL_VBI_END_LINE-PAL_VBI_START_LINE+1) | ||
34 | |||
35 | #define VBI_STRIDE 1440 | ||
36 | #define VBI_SAMPLES_PER_LINE 1440 | ||
37 | |||
38 | #define CX231XX_NUM_VBI_PACKETS 4 | ||
39 | #define CX231XX_NUM_VBI_BUFS 5 | ||
40 | |||
41 | /* stream functions */ | ||
42 | int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | ||
43 | int num_bufs, int max_pkt_size, | ||
44 | int (*bulk_copy) (struct cx231xx *dev, | ||
45 | struct urb *urb)); | ||
46 | |||
47 | void cx231xx_uninit_vbi_isoc(struct cx231xx *dev); | ||
48 | |||
49 | /* vbi data copy functions */ | ||
50 | u32 cx231xx_get_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
51 | u8 sav_eav, u8 *p_buffer, u32 buffer_size); | ||
52 | |||
53 | u32 cx231xx_copy_vbi_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
54 | u8 *p_line, u32 length, int field_number); | ||
55 | |||
56 | void cx231xx_reset_vbi_buffer(struct cx231xx *dev, | ||
57 | struct cx231xx_dmaqueue *dma_q); | ||
58 | |||
59 | int cx231xx_do_vbi_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
60 | u8 *p_buffer, u32 bytes_to_copy); | ||
61 | |||
62 | u8 cx231xx_is_vbi_buffer_done(struct cx231xx *dev, | ||
63 | struct cx231xx_dmaqueue *dma_q); | ||
64 | |||
65 | #endif | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c new file mode 100644 index 000000000000..790b28d7f764 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx-video.c | |||
@@ -0,0 +1,2670 @@ | |||
1 | /* | ||
2 | cx231xx-video.c - driver for Conexant Cx23100/101/102 | ||
3 | USB video capture devices | ||
4 | |||
5 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
6 | Based on em28xx driver | ||
7 | Based on cx23885 driver | ||
8 | Based on cx88 driver | ||
9 | |||
10 | This program is free software; you can redistribute it and/or modify | ||
11 | it under the terms of the GNU General Public License as published by | ||
12 | the Free Software Foundation; either version 2 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program; if not, write to the Free Software | ||
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | #include <linux/init.h> | ||
26 | #include <linux/list.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/kernel.h> | ||
29 | #include <linux/bitmap.h> | ||
30 | #include <linux/usb.h> | ||
31 | #include <linux/i2c.h> | ||
32 | #include <linux/mm.h> | ||
33 | #include <linux/mutex.h> | ||
34 | #include <linux/slab.h> | ||
35 | |||
36 | #include <media/v4l2-common.h> | ||
37 | #include <media/v4l2-ioctl.h> | ||
38 | #include <media/v4l2-chip-ident.h> | ||
39 | #include <media/msp3400.h> | ||
40 | #include <media/tuner.h> | ||
41 | |||
42 | #include "dvb_frontend.h" | ||
43 | |||
44 | #include "cx231xx.h" | ||
45 | #include "cx231xx-vbi.h" | ||
46 | |||
47 | #define CX231XX_VERSION "0.0.2" | ||
48 | |||
49 | #define DRIVER_AUTHOR "Srinivasa Deevi <srinivasa.deevi@conexant.com>" | ||
50 | #define DRIVER_DESC "Conexant cx231xx based USB video device driver" | ||
51 | |||
52 | #define cx231xx_videodbg(fmt, arg...) do {\ | ||
53 | if (video_debug) \ | ||
54 | printk(KERN_INFO "%s %s :"fmt, \ | ||
55 | dev->name, __func__ , ##arg); } while (0) | ||
56 | |||
57 | static unsigned int isoc_debug; | ||
58 | module_param(isoc_debug, int, 0644); | ||
59 | MODULE_PARM_DESC(isoc_debug, "enable debug messages [isoc transfers]"); | ||
60 | |||
61 | #define cx231xx_isocdbg(fmt, arg...) \ | ||
62 | do {\ | ||
63 | if (isoc_debug) { \ | ||
64 | printk(KERN_INFO "%s %s :"fmt, \ | ||
65 | dev->name, __func__ , ##arg); \ | ||
66 | } \ | ||
67 | } while (0) | ||
68 | |||
69 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
70 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
71 | MODULE_LICENSE("GPL"); | ||
72 | MODULE_VERSION(CX231XX_VERSION); | ||
73 | |||
74 | static unsigned int card[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; | ||
75 | static unsigned int video_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; | ||
76 | static unsigned int vbi_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; | ||
77 | static unsigned int radio_nr[] = {[0 ... (CX231XX_MAXBOARDS - 1)] = UNSET }; | ||
78 | |||
79 | module_param_array(card, int, NULL, 0444); | ||
80 | module_param_array(video_nr, int, NULL, 0444); | ||
81 | module_param_array(vbi_nr, int, NULL, 0444); | ||
82 | module_param_array(radio_nr, int, NULL, 0444); | ||
83 | |||
84 | MODULE_PARM_DESC(card, "card type"); | ||
85 | MODULE_PARM_DESC(video_nr, "video device numbers"); | ||
86 | MODULE_PARM_DESC(vbi_nr, "vbi device numbers"); | ||
87 | MODULE_PARM_DESC(radio_nr, "radio device numbers"); | ||
88 | |||
89 | static unsigned int video_debug; | ||
90 | module_param(video_debug, int, 0644); | ||
91 | MODULE_PARM_DESC(video_debug, "enable debug messages [video]"); | ||
92 | |||
93 | /* supported video standards */ | ||
94 | static struct cx231xx_fmt format[] = { | ||
95 | { | ||
96 | .name = "16bpp YUY2, 4:2:2, packed", | ||
97 | .fourcc = V4L2_PIX_FMT_YUYV, | ||
98 | .depth = 16, | ||
99 | .reg = 0, | ||
100 | }, | ||
101 | }; | ||
102 | |||
103 | /* supported controls */ | ||
104 | /* Common to all boards */ | ||
105 | |||
106 | /* ------------------------------------------------------------------- */ | ||
107 | |||
108 | static const struct v4l2_queryctrl no_ctl = { | ||
109 | .name = "42", | ||
110 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
111 | }; | ||
112 | |||
113 | static struct cx231xx_ctrl cx231xx_ctls[] = { | ||
114 | /* --- video --- */ | ||
115 | { | ||
116 | .v = { | ||
117 | .id = V4L2_CID_BRIGHTNESS, | ||
118 | .name = "Brightness", | ||
119 | .minimum = 0x00, | ||
120 | .maximum = 0xff, | ||
121 | .step = 1, | ||
122 | .default_value = 0x7f, | ||
123 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
124 | }, | ||
125 | .off = 128, | ||
126 | .reg = LUMA_CTRL, | ||
127 | .mask = 0x00ff, | ||
128 | .shift = 0, | ||
129 | }, { | ||
130 | .v = { | ||
131 | .id = V4L2_CID_CONTRAST, | ||
132 | .name = "Contrast", | ||
133 | .minimum = 0, | ||
134 | .maximum = 0xff, | ||
135 | .step = 1, | ||
136 | .default_value = 0x3f, | ||
137 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
138 | }, | ||
139 | .off = 0, | ||
140 | .reg = LUMA_CTRL, | ||
141 | .mask = 0xff00, | ||
142 | .shift = 8, | ||
143 | }, { | ||
144 | .v = { | ||
145 | .id = V4L2_CID_HUE, | ||
146 | .name = "Hue", | ||
147 | .minimum = 0, | ||
148 | .maximum = 0xff, | ||
149 | .step = 1, | ||
150 | .default_value = 0x7f, | ||
151 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
152 | }, | ||
153 | .off = 128, | ||
154 | .reg = CHROMA_CTRL, | ||
155 | .mask = 0xff0000, | ||
156 | .shift = 16, | ||
157 | }, { | ||
158 | /* strictly, this only describes only U saturation. | ||
159 | * V saturation is handled specially through code. | ||
160 | */ | ||
161 | .v = { | ||
162 | .id = V4L2_CID_SATURATION, | ||
163 | .name = "Saturation", | ||
164 | .minimum = 0, | ||
165 | .maximum = 0xff, | ||
166 | .step = 1, | ||
167 | .default_value = 0x7f, | ||
168 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
169 | }, | ||
170 | .off = 0, | ||
171 | .reg = CHROMA_CTRL, | ||
172 | .mask = 0x00ff, | ||
173 | .shift = 0, | ||
174 | }, { | ||
175 | /* --- audio --- */ | ||
176 | .v = { | ||
177 | .id = V4L2_CID_AUDIO_MUTE, | ||
178 | .name = "Mute", | ||
179 | .minimum = 0, | ||
180 | .maximum = 1, | ||
181 | .default_value = 1, | ||
182 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
183 | }, | ||
184 | .reg = PATH1_CTL1, | ||
185 | .mask = (0x1f << 24), | ||
186 | .shift = 24, | ||
187 | }, { | ||
188 | .v = { | ||
189 | .id = V4L2_CID_AUDIO_VOLUME, | ||
190 | .name = "Volume", | ||
191 | .minimum = 0, | ||
192 | .maximum = 0x3f, | ||
193 | .step = 1, | ||
194 | .default_value = 0x3f, | ||
195 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
196 | }, | ||
197 | .reg = PATH1_VOL_CTL, | ||
198 | .mask = 0xff, | ||
199 | .shift = 0, | ||
200 | } | ||
201 | }; | ||
202 | static const int CX231XX_CTLS = ARRAY_SIZE(cx231xx_ctls); | ||
203 | |||
204 | static const u32 cx231xx_user_ctrls[] = { | ||
205 | V4L2_CID_USER_CLASS, | ||
206 | V4L2_CID_BRIGHTNESS, | ||
207 | V4L2_CID_CONTRAST, | ||
208 | V4L2_CID_SATURATION, | ||
209 | V4L2_CID_HUE, | ||
210 | V4L2_CID_AUDIO_VOLUME, | ||
211 | #if 0 | ||
212 | V4L2_CID_AUDIO_BALANCE, | ||
213 | #endif | ||
214 | V4L2_CID_AUDIO_MUTE, | ||
215 | 0 | ||
216 | }; | ||
217 | |||
218 | static const u32 *ctrl_classes[] = { | ||
219 | cx231xx_user_ctrls, | ||
220 | NULL | ||
221 | }; | ||
222 | |||
223 | /* ------------------------------------------------------------------ | ||
224 | Video buffer and parser functions | ||
225 | ------------------------------------------------------------------*/ | ||
226 | |||
227 | /* | ||
228 | * Announces that a buffer were filled and request the next | ||
229 | */ | ||
230 | static inline void buffer_filled(struct cx231xx *dev, | ||
231 | struct cx231xx_dmaqueue *dma_q, | ||
232 | struct cx231xx_buffer *buf) | ||
233 | { | ||
234 | /* Advice that buffer was filled */ | ||
235 | cx231xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); | ||
236 | buf->vb.state = VIDEOBUF_DONE; | ||
237 | buf->vb.field_count++; | ||
238 | do_gettimeofday(&buf->vb.ts); | ||
239 | |||
240 | if (dev->USE_ISO) | ||
241 | dev->video_mode.isoc_ctl.buf = NULL; | ||
242 | else | ||
243 | dev->video_mode.bulk_ctl.buf = NULL; | ||
244 | |||
245 | list_del(&buf->vb.queue); | ||
246 | wake_up(&buf->vb.done); | ||
247 | } | ||
248 | |||
249 | static inline void print_err_status(struct cx231xx *dev, int packet, int status) | ||
250 | { | ||
251 | char *errmsg = "Unknown"; | ||
252 | |||
253 | switch (status) { | ||
254 | case -ENOENT: | ||
255 | errmsg = "unlinked synchronuously"; | ||
256 | break; | ||
257 | case -ECONNRESET: | ||
258 | errmsg = "unlinked asynchronuously"; | ||
259 | break; | ||
260 | case -ENOSR: | ||
261 | errmsg = "Buffer error (overrun)"; | ||
262 | break; | ||
263 | case -EPIPE: | ||
264 | errmsg = "Stalled (device not responding)"; | ||
265 | break; | ||
266 | case -EOVERFLOW: | ||
267 | errmsg = "Babble (bad cable?)"; | ||
268 | break; | ||
269 | case -EPROTO: | ||
270 | errmsg = "Bit-stuff error (bad cable?)"; | ||
271 | break; | ||
272 | case -EILSEQ: | ||
273 | errmsg = "CRC/Timeout (could be anything)"; | ||
274 | break; | ||
275 | case -ETIME: | ||
276 | errmsg = "Device does not respond"; | ||
277 | break; | ||
278 | } | ||
279 | if (packet < 0) { | ||
280 | cx231xx_isocdbg("URB status %d [%s].\n", status, errmsg); | ||
281 | } else { | ||
282 | cx231xx_isocdbg("URB packet %d, status %d [%s].\n", | ||
283 | packet, status, errmsg); | ||
284 | } | ||
285 | } | ||
286 | |||
287 | /* | ||
288 | * video-buf generic routine to get the next available buffer | ||
289 | */ | ||
290 | static inline void get_next_buf(struct cx231xx_dmaqueue *dma_q, | ||
291 | struct cx231xx_buffer **buf) | ||
292 | { | ||
293 | struct cx231xx_video_mode *vmode = | ||
294 | container_of(dma_q, struct cx231xx_video_mode, vidq); | ||
295 | struct cx231xx *dev = container_of(vmode, struct cx231xx, video_mode); | ||
296 | |||
297 | char *outp; | ||
298 | |||
299 | if (list_empty(&dma_q->active)) { | ||
300 | cx231xx_isocdbg("No active queue to serve\n"); | ||
301 | if (dev->USE_ISO) | ||
302 | dev->video_mode.isoc_ctl.buf = NULL; | ||
303 | else | ||
304 | dev->video_mode.bulk_ctl.buf = NULL; | ||
305 | *buf = NULL; | ||
306 | return; | ||
307 | } | ||
308 | |||
309 | /* Get the next buffer */ | ||
310 | *buf = list_entry(dma_q->active.next, struct cx231xx_buffer, vb.queue); | ||
311 | |||
312 | /* Cleans up buffer - Useful for testing for frame/URB loss */ | ||
313 | outp = videobuf_to_vmalloc(&(*buf)->vb); | ||
314 | memset(outp, 0, (*buf)->vb.size); | ||
315 | |||
316 | if (dev->USE_ISO) | ||
317 | dev->video_mode.isoc_ctl.buf = *buf; | ||
318 | else | ||
319 | dev->video_mode.bulk_ctl.buf = *buf; | ||
320 | |||
321 | return; | ||
322 | } | ||
323 | |||
324 | /* | ||
325 | * Controls the isoc copy of each urb packet | ||
326 | */ | ||
327 | static inline int cx231xx_isoc_copy(struct cx231xx *dev, struct urb *urb) | ||
328 | { | ||
329 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
330 | int i, rc = 1; | ||
331 | unsigned char *p_buffer; | ||
332 | u32 bytes_parsed = 0, buffer_size = 0; | ||
333 | u8 sav_eav = 0; | ||
334 | |||
335 | if (!dev) | ||
336 | return 0; | ||
337 | |||
338 | if (dev->state & DEV_DISCONNECTED) | ||
339 | return 0; | ||
340 | |||
341 | if (urb->status < 0) { | ||
342 | print_err_status(dev, -1, urb->status); | ||
343 | if (urb->status == -ENOENT) | ||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | for (i = 0; i < urb->number_of_packets; i++) { | ||
348 | int status = urb->iso_frame_desc[i].status; | ||
349 | |||
350 | if (status < 0) { | ||
351 | print_err_status(dev, i, status); | ||
352 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
353 | continue; | ||
354 | } | ||
355 | |||
356 | if (urb->iso_frame_desc[i].actual_length <= 0) { | ||
357 | /* cx231xx_isocdbg("packet %d is empty",i); - spammy */ | ||
358 | continue; | ||
359 | } | ||
360 | if (urb->iso_frame_desc[i].actual_length > | ||
361 | dev->video_mode.max_pkt_size) { | ||
362 | cx231xx_isocdbg("packet bigger than packet size"); | ||
363 | continue; | ||
364 | } | ||
365 | |||
366 | /* get buffer pointer and length */ | ||
367 | p_buffer = urb->transfer_buffer + urb->iso_frame_desc[i].offset; | ||
368 | buffer_size = urb->iso_frame_desc[i].actual_length; | ||
369 | bytes_parsed = 0; | ||
370 | |||
371 | if (dma_q->is_partial_line) { | ||
372 | /* Handle the case of a partial line */ | ||
373 | sav_eav = dma_q->last_sav; | ||
374 | } else { | ||
375 | /* Check for a SAV/EAV overlapping | ||
376 | the buffer boundary */ | ||
377 | sav_eav = | ||
378 | cx231xx_find_boundary_SAV_EAV(p_buffer, | ||
379 | dma_q->partial_buf, | ||
380 | &bytes_parsed); | ||
381 | } | ||
382 | |||
383 | sav_eav &= 0xF0; | ||
384 | /* Get the first line if we have some portion of an SAV/EAV from | ||
385 | the last buffer or a partial line */ | ||
386 | if (sav_eav) { | ||
387 | bytes_parsed += cx231xx_get_video_line(dev, dma_q, | ||
388 | sav_eav, /* SAV/EAV */ | ||
389 | p_buffer + bytes_parsed, /* p_buffer */ | ||
390 | buffer_size - bytes_parsed);/* buf size */ | ||
391 | } | ||
392 | |||
393 | /* Now parse data that is completely in this buffer */ | ||
394 | /* dma_q->is_partial_line = 0; */ | ||
395 | |||
396 | while (bytes_parsed < buffer_size) { | ||
397 | u32 bytes_used = 0; | ||
398 | |||
399 | sav_eav = cx231xx_find_next_SAV_EAV( | ||
400 | p_buffer + bytes_parsed, /* p_buffer */ | ||
401 | buffer_size - bytes_parsed, /* buf size */ | ||
402 | &bytes_used);/* bytes used to get SAV/EAV */ | ||
403 | |||
404 | bytes_parsed += bytes_used; | ||
405 | |||
406 | sav_eav &= 0xF0; | ||
407 | if (sav_eav && (bytes_parsed < buffer_size)) { | ||
408 | bytes_parsed += cx231xx_get_video_line(dev, | ||
409 | dma_q, sav_eav, /* SAV/EAV */ | ||
410 | p_buffer + bytes_parsed,/* p_buffer */ | ||
411 | buffer_size - bytes_parsed);/*buf size*/ | ||
412 | } | ||
413 | } | ||
414 | |||
415 | /* Save the last four bytes of the buffer so we can check the | ||
416 | buffer boundary condition next time */ | ||
417 | memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4); | ||
418 | bytes_parsed = 0; | ||
419 | |||
420 | } | ||
421 | return rc; | ||
422 | } | ||
423 | |||
424 | static inline int cx231xx_bulk_copy(struct cx231xx *dev, struct urb *urb) | ||
425 | { | ||
426 | struct cx231xx_dmaqueue *dma_q = urb->context; | ||
427 | int rc = 1; | ||
428 | unsigned char *p_buffer; | ||
429 | u32 bytes_parsed = 0, buffer_size = 0; | ||
430 | u8 sav_eav = 0; | ||
431 | |||
432 | if (!dev) | ||
433 | return 0; | ||
434 | |||
435 | if (dev->state & DEV_DISCONNECTED) | ||
436 | return 0; | ||
437 | |||
438 | if (urb->status < 0) { | ||
439 | print_err_status(dev, -1, urb->status); | ||
440 | if (urb->status == -ENOENT) | ||
441 | return 0; | ||
442 | } | ||
443 | |||
444 | if (1) { | ||
445 | |||
446 | /* get buffer pointer and length */ | ||
447 | p_buffer = urb->transfer_buffer; | ||
448 | buffer_size = urb->actual_length; | ||
449 | bytes_parsed = 0; | ||
450 | |||
451 | if (dma_q->is_partial_line) { | ||
452 | /* Handle the case of a partial line */ | ||
453 | sav_eav = dma_q->last_sav; | ||
454 | } else { | ||
455 | /* Check for a SAV/EAV overlapping | ||
456 | the buffer boundary */ | ||
457 | sav_eav = | ||
458 | cx231xx_find_boundary_SAV_EAV(p_buffer, | ||
459 | dma_q->partial_buf, | ||
460 | &bytes_parsed); | ||
461 | } | ||
462 | |||
463 | sav_eav &= 0xF0; | ||
464 | /* Get the first line if we have some portion of an SAV/EAV from | ||
465 | the last buffer or a partial line */ | ||
466 | if (sav_eav) { | ||
467 | bytes_parsed += cx231xx_get_video_line(dev, dma_q, | ||
468 | sav_eav, /* SAV/EAV */ | ||
469 | p_buffer + bytes_parsed, /* p_buffer */ | ||
470 | buffer_size - bytes_parsed);/* buf size */ | ||
471 | } | ||
472 | |||
473 | /* Now parse data that is completely in this buffer */ | ||
474 | /* dma_q->is_partial_line = 0; */ | ||
475 | |||
476 | while (bytes_parsed < buffer_size) { | ||
477 | u32 bytes_used = 0; | ||
478 | |||
479 | sav_eav = cx231xx_find_next_SAV_EAV( | ||
480 | p_buffer + bytes_parsed, /* p_buffer */ | ||
481 | buffer_size - bytes_parsed, /* buf size */ | ||
482 | &bytes_used);/* bytes used to get SAV/EAV */ | ||
483 | |||
484 | bytes_parsed += bytes_used; | ||
485 | |||
486 | sav_eav &= 0xF0; | ||
487 | if (sav_eav && (bytes_parsed < buffer_size)) { | ||
488 | bytes_parsed += cx231xx_get_video_line(dev, | ||
489 | dma_q, sav_eav, /* SAV/EAV */ | ||
490 | p_buffer + bytes_parsed,/* p_buffer */ | ||
491 | buffer_size - bytes_parsed);/*buf size*/ | ||
492 | } | ||
493 | } | ||
494 | |||
495 | /* Save the last four bytes of the buffer so we can check the | ||
496 | buffer boundary condition next time */ | ||
497 | memcpy(dma_q->partial_buf, p_buffer + buffer_size - 4, 4); | ||
498 | bytes_parsed = 0; | ||
499 | |||
500 | } | ||
501 | return rc; | ||
502 | } | ||
503 | |||
504 | |||
505 | u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, | ||
506 | u32 *p_bytes_used) | ||
507 | { | ||
508 | u32 bytes_used; | ||
509 | u8 boundary_bytes[8]; | ||
510 | u8 sav_eav = 0; | ||
511 | |||
512 | *p_bytes_used = 0; | ||
513 | |||
514 | /* Create an array of the last 4 bytes of the last buffer and the first | ||
515 | 4 bytes of the current buffer. */ | ||
516 | |||
517 | memcpy(boundary_bytes, partial_buf, 4); | ||
518 | memcpy(boundary_bytes + 4, p_buffer, 4); | ||
519 | |||
520 | /* Check for the SAV/EAV in the boundary buffer */ | ||
521 | sav_eav = cx231xx_find_next_SAV_EAV((u8 *)&boundary_bytes, 8, | ||
522 | &bytes_used); | ||
523 | |||
524 | if (sav_eav) { | ||
525 | /* found a boundary SAV/EAV. Updates the bytes used to reflect | ||
526 | only those used in the new buffer */ | ||
527 | *p_bytes_used = bytes_used - 4; | ||
528 | } | ||
529 | |||
530 | return sav_eav; | ||
531 | } | ||
532 | |||
533 | u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, u32 *p_bytes_used) | ||
534 | { | ||
535 | u32 i; | ||
536 | u8 sav_eav = 0; | ||
537 | |||
538 | /* | ||
539 | * Don't search if the buffer size is less than 4. It causes a page | ||
540 | * fault since buffer_size - 4 evaluates to a large number in that | ||
541 | * case. | ||
542 | */ | ||
543 | if (buffer_size < 4) { | ||
544 | *p_bytes_used = buffer_size; | ||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | for (i = 0; i < (buffer_size - 3); i++) { | ||
549 | |||
550 | if ((p_buffer[i] == 0xFF) && | ||
551 | (p_buffer[i + 1] == 0x00) && (p_buffer[i + 2] == 0x00)) { | ||
552 | |||
553 | *p_bytes_used = i + 4; | ||
554 | sav_eav = p_buffer[i + 3]; | ||
555 | return sav_eav; | ||
556 | } | ||
557 | } | ||
558 | |||
559 | *p_bytes_used = buffer_size; | ||
560 | return 0; | ||
561 | } | ||
562 | |||
563 | u32 cx231xx_get_video_line(struct cx231xx *dev, | ||
564 | struct cx231xx_dmaqueue *dma_q, u8 sav_eav, | ||
565 | u8 *p_buffer, u32 buffer_size) | ||
566 | { | ||
567 | u32 bytes_copied = 0; | ||
568 | int current_field = -1; | ||
569 | |||
570 | switch (sav_eav) { | ||
571 | case SAV_ACTIVE_VIDEO_FIELD1: | ||
572 | /* looking for skipped line which occurred in PAL 720x480 mode. | ||
573 | In this case, there will be no active data contained | ||
574 | between the SAV and EAV */ | ||
575 | if ((buffer_size > 3) && (p_buffer[0] == 0xFF) && | ||
576 | (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) && | ||
577 | ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) || | ||
578 | (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) || | ||
579 | (p_buffer[3] == EAV_VBLANK_FIELD1) || | ||
580 | (p_buffer[3] == EAV_VBLANK_FIELD2))) | ||
581 | return bytes_copied; | ||
582 | current_field = 1; | ||
583 | break; | ||
584 | |||
585 | case SAV_ACTIVE_VIDEO_FIELD2: | ||
586 | /* looking for skipped line which occurred in PAL 720x480 mode. | ||
587 | In this case, there will be no active data contained between | ||
588 | the SAV and EAV */ | ||
589 | if ((buffer_size > 3) && (p_buffer[0] == 0xFF) && | ||
590 | (p_buffer[1] == 0x00) && (p_buffer[2] == 0x00) && | ||
591 | ((p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD1) || | ||
592 | (p_buffer[3] == EAV_ACTIVE_VIDEO_FIELD2) || | ||
593 | (p_buffer[3] == EAV_VBLANK_FIELD1) || | ||
594 | (p_buffer[3] == EAV_VBLANK_FIELD2))) | ||
595 | return bytes_copied; | ||
596 | current_field = 2; | ||
597 | break; | ||
598 | } | ||
599 | |||
600 | dma_q->last_sav = sav_eav; | ||
601 | |||
602 | bytes_copied = cx231xx_copy_video_line(dev, dma_q, p_buffer, | ||
603 | buffer_size, current_field); | ||
604 | |||
605 | return bytes_copied; | ||
606 | } | ||
607 | |||
608 | u32 cx231xx_copy_video_line(struct cx231xx *dev, | ||
609 | struct cx231xx_dmaqueue *dma_q, u8 *p_line, | ||
610 | u32 length, int field_number) | ||
611 | { | ||
612 | u32 bytes_to_copy; | ||
613 | struct cx231xx_buffer *buf; | ||
614 | u32 _line_size = dev->width * 2; | ||
615 | |||
616 | if (dma_q->current_field != field_number) | ||
617 | cx231xx_reset_video_buffer(dev, dma_q); | ||
618 | |||
619 | /* get the buffer pointer */ | ||
620 | if (dev->USE_ISO) | ||
621 | buf = dev->video_mode.isoc_ctl.buf; | ||
622 | else | ||
623 | buf = dev->video_mode.bulk_ctl.buf; | ||
624 | |||
625 | /* Remember the field number for next time */ | ||
626 | dma_q->current_field = field_number; | ||
627 | |||
628 | bytes_to_copy = dma_q->bytes_left_in_line; | ||
629 | if (bytes_to_copy > length) | ||
630 | bytes_to_copy = length; | ||
631 | |||
632 | if (dma_q->lines_completed >= dma_q->lines_per_field) { | ||
633 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
634 | dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) ? | ||
635 | 0 : 1; | ||
636 | return 0; | ||
637 | } | ||
638 | |||
639 | dma_q->is_partial_line = 1; | ||
640 | |||
641 | /* If we don't have a buffer, just return the number of bytes we would | ||
642 | have copied if we had a buffer. */ | ||
643 | if (!buf) { | ||
644 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
645 | dma_q->is_partial_line = (dma_q->bytes_left_in_line == 0) | ||
646 | ? 0 : 1; | ||
647 | return bytes_to_copy; | ||
648 | } | ||
649 | |||
650 | /* copy the data to video buffer */ | ||
651 | cx231xx_do_copy(dev, dma_q, p_line, bytes_to_copy); | ||
652 | |||
653 | dma_q->pos += bytes_to_copy; | ||
654 | dma_q->bytes_left_in_line -= bytes_to_copy; | ||
655 | |||
656 | if (dma_q->bytes_left_in_line == 0) { | ||
657 | dma_q->bytes_left_in_line = _line_size; | ||
658 | dma_q->lines_completed++; | ||
659 | dma_q->is_partial_line = 0; | ||
660 | |||
661 | if (cx231xx_is_buffer_done(dev, dma_q) && buf) { | ||
662 | buffer_filled(dev, dma_q, buf); | ||
663 | |||
664 | dma_q->pos = 0; | ||
665 | buf = NULL; | ||
666 | dma_q->lines_completed = 0; | ||
667 | } | ||
668 | } | ||
669 | |||
670 | return bytes_to_copy; | ||
671 | } | ||
672 | |||
673 | void cx231xx_reset_video_buffer(struct cx231xx *dev, | ||
674 | struct cx231xx_dmaqueue *dma_q) | ||
675 | { | ||
676 | struct cx231xx_buffer *buf; | ||
677 | |||
678 | /* handle the switch from field 1 to field 2 */ | ||
679 | if (dma_q->current_field == 1) { | ||
680 | if (dma_q->lines_completed >= dma_q->lines_per_field) | ||
681 | dma_q->field1_done = 1; | ||
682 | else | ||
683 | dma_q->field1_done = 0; | ||
684 | } | ||
685 | |||
686 | if (dev->USE_ISO) | ||
687 | buf = dev->video_mode.isoc_ctl.buf; | ||
688 | else | ||
689 | buf = dev->video_mode.bulk_ctl.buf; | ||
690 | |||
691 | if (buf == NULL) { | ||
692 | /* first try to get the buffer */ | ||
693 | get_next_buf(dma_q, &buf); | ||
694 | |||
695 | dma_q->pos = 0; | ||
696 | dma_q->field1_done = 0; | ||
697 | dma_q->current_field = -1; | ||
698 | } | ||
699 | |||
700 | /* reset the counters */ | ||
701 | dma_q->bytes_left_in_line = dev->width << 1; | ||
702 | dma_q->lines_completed = 0; | ||
703 | } | ||
704 | |||
705 | int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
706 | u8 *p_buffer, u32 bytes_to_copy) | ||
707 | { | ||
708 | u8 *p_out_buffer = NULL; | ||
709 | u32 current_line_bytes_copied = 0; | ||
710 | struct cx231xx_buffer *buf; | ||
711 | u32 _line_size = dev->width << 1; | ||
712 | void *startwrite; | ||
713 | int offset, lencopy; | ||
714 | |||
715 | if (dev->USE_ISO) | ||
716 | buf = dev->video_mode.isoc_ctl.buf; | ||
717 | else | ||
718 | buf = dev->video_mode.bulk_ctl.buf; | ||
719 | |||
720 | if (buf == NULL) | ||
721 | return -1; | ||
722 | |||
723 | p_out_buffer = videobuf_to_vmalloc(&buf->vb); | ||
724 | |||
725 | current_line_bytes_copied = _line_size - dma_q->bytes_left_in_line; | ||
726 | |||
727 | /* Offset field 2 one line from the top of the buffer */ | ||
728 | offset = (dma_q->current_field == 1) ? 0 : _line_size; | ||
729 | |||
730 | /* Offset for field 2 */ | ||
731 | startwrite = p_out_buffer + offset; | ||
732 | |||
733 | /* lines already completed in the current field */ | ||
734 | startwrite += (dma_q->lines_completed * _line_size * 2); | ||
735 | |||
736 | /* bytes already completed in the current line */ | ||
737 | startwrite += current_line_bytes_copied; | ||
738 | |||
739 | lencopy = dma_q->bytes_left_in_line > bytes_to_copy ? | ||
740 | bytes_to_copy : dma_q->bytes_left_in_line; | ||
741 | |||
742 | if ((u8 *)(startwrite + lencopy) > (u8 *)(p_out_buffer + buf->vb.size)) | ||
743 | return 0; | ||
744 | |||
745 | /* The below copies the UYVY data straight into video buffer */ | ||
746 | cx231xx_swab((u16 *) p_buffer, (u16 *) startwrite, (u16) lencopy); | ||
747 | |||
748 | return 0; | ||
749 | } | ||
750 | |||
751 | void cx231xx_swab(u16 *from, u16 *to, u16 len) | ||
752 | { | ||
753 | u16 i; | ||
754 | |||
755 | if (len <= 0) | ||
756 | return; | ||
757 | |||
758 | for (i = 0; i < len / 2; i++) | ||
759 | to[i] = (from[i] << 8) | (from[i] >> 8); | ||
760 | } | ||
761 | |||
762 | u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q) | ||
763 | { | ||
764 | u8 buffer_complete = 0; | ||
765 | |||
766 | /* Dual field stream */ | ||
767 | buffer_complete = ((dma_q->current_field == 2) && | ||
768 | (dma_q->lines_completed >= dma_q->lines_per_field) && | ||
769 | dma_q->field1_done); | ||
770 | |||
771 | return buffer_complete; | ||
772 | } | ||
773 | |||
774 | /* ------------------------------------------------------------------ | ||
775 | Videobuf operations | ||
776 | ------------------------------------------------------------------*/ | ||
777 | |||
778 | static int | ||
779 | buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | ||
780 | { | ||
781 | struct cx231xx_fh *fh = vq->priv_data; | ||
782 | struct cx231xx *dev = fh->dev; | ||
783 | |||
784 | *size = (fh->dev->width * fh->dev->height * dev->format->depth + 7)>>3; | ||
785 | if (0 == *count) | ||
786 | *count = CX231XX_DEF_BUF; | ||
787 | |||
788 | if (*count < CX231XX_MIN_BUF) | ||
789 | *count = CX231XX_MIN_BUF; | ||
790 | |||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | /* This is called *without* dev->slock held; please keep it that way */ | ||
795 | static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf) | ||
796 | { | ||
797 | struct cx231xx_fh *fh = vq->priv_data; | ||
798 | struct cx231xx *dev = fh->dev; | ||
799 | unsigned long flags = 0; | ||
800 | |||
801 | if (in_interrupt()) | ||
802 | BUG(); | ||
803 | |||
804 | /* We used to wait for the buffer to finish here, but this didn't work | ||
805 | because, as we were keeping the state as VIDEOBUF_QUEUED, | ||
806 | videobuf_queue_cancel marked it as finished for us. | ||
807 | (Also, it could wedge forever if the hardware was misconfigured.) | ||
808 | |||
809 | This should be safe; by the time we get here, the buffer isn't | ||
810 | queued anymore. If we ever start marking the buffers as | ||
811 | VIDEOBUF_ACTIVE, it won't be, though. | ||
812 | */ | ||
813 | spin_lock_irqsave(&dev->video_mode.slock, flags); | ||
814 | if (dev->USE_ISO) { | ||
815 | if (dev->video_mode.isoc_ctl.buf == buf) | ||
816 | dev->video_mode.isoc_ctl.buf = NULL; | ||
817 | } else { | ||
818 | if (dev->video_mode.bulk_ctl.buf == buf) | ||
819 | dev->video_mode.bulk_ctl.buf = NULL; | ||
820 | } | ||
821 | spin_unlock_irqrestore(&dev->video_mode.slock, flags); | ||
822 | |||
823 | videobuf_vmalloc_free(&buf->vb); | ||
824 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
825 | } | ||
826 | |||
827 | static int | ||
828 | buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | ||
829 | enum v4l2_field field) | ||
830 | { | ||
831 | struct cx231xx_fh *fh = vq->priv_data; | ||
832 | struct cx231xx_buffer *buf = | ||
833 | container_of(vb, struct cx231xx_buffer, vb); | ||
834 | struct cx231xx *dev = fh->dev; | ||
835 | int rc = 0, urb_init = 0; | ||
836 | |||
837 | /* The only currently supported format is 16 bits/pixel */ | ||
838 | buf->vb.size = (fh->dev->width * fh->dev->height * dev->format->depth | ||
839 | + 7) >> 3; | ||
840 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | ||
841 | return -EINVAL; | ||
842 | |||
843 | buf->vb.width = dev->width; | ||
844 | buf->vb.height = dev->height; | ||
845 | buf->vb.field = field; | ||
846 | |||
847 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
848 | rc = videobuf_iolock(vq, &buf->vb, NULL); | ||
849 | if (rc < 0) | ||
850 | goto fail; | ||
851 | } | ||
852 | |||
853 | if (dev->USE_ISO) { | ||
854 | if (!dev->video_mode.isoc_ctl.num_bufs) | ||
855 | urb_init = 1; | ||
856 | } else { | ||
857 | if (!dev->video_mode.bulk_ctl.num_bufs) | ||
858 | urb_init = 1; | ||
859 | } | ||
860 | /*cx231xx_info("urb_init=%d dev->video_mode.max_pkt_size=%d\n", | ||
861 | urb_init, dev->video_mode.max_pkt_size);*/ | ||
862 | if (urb_init) { | ||
863 | dev->mode_tv = 0; | ||
864 | if (dev->USE_ISO) | ||
865 | rc = cx231xx_init_isoc(dev, CX231XX_NUM_PACKETS, | ||
866 | CX231XX_NUM_BUFS, | ||
867 | dev->video_mode.max_pkt_size, | ||
868 | cx231xx_isoc_copy); | ||
869 | else | ||
870 | rc = cx231xx_init_bulk(dev, CX231XX_NUM_PACKETS, | ||
871 | CX231XX_NUM_BUFS, | ||
872 | dev->video_mode.max_pkt_size, | ||
873 | cx231xx_bulk_copy); | ||
874 | if (rc < 0) | ||
875 | goto fail; | ||
876 | } | ||
877 | |||
878 | buf->vb.state = VIDEOBUF_PREPARED; | ||
879 | return 0; | ||
880 | |||
881 | fail: | ||
882 | free_buffer(vq, buf); | ||
883 | return rc; | ||
884 | } | ||
885 | |||
886 | static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | ||
887 | { | ||
888 | struct cx231xx_buffer *buf = | ||
889 | container_of(vb, struct cx231xx_buffer, vb); | ||
890 | struct cx231xx_fh *fh = vq->priv_data; | ||
891 | struct cx231xx *dev = fh->dev; | ||
892 | struct cx231xx_dmaqueue *vidq = &dev->video_mode.vidq; | ||
893 | |||
894 | buf->vb.state = VIDEOBUF_QUEUED; | ||
895 | list_add_tail(&buf->vb.queue, &vidq->active); | ||
896 | |||
897 | } | ||
898 | |||
899 | static void buffer_release(struct videobuf_queue *vq, | ||
900 | struct videobuf_buffer *vb) | ||
901 | { | ||
902 | struct cx231xx_buffer *buf = | ||
903 | container_of(vb, struct cx231xx_buffer, vb); | ||
904 | struct cx231xx_fh *fh = vq->priv_data; | ||
905 | struct cx231xx *dev = (struct cx231xx *)fh->dev; | ||
906 | |||
907 | cx231xx_isocdbg("cx231xx: called buffer_release\n"); | ||
908 | |||
909 | free_buffer(vq, buf); | ||
910 | } | ||
911 | |||
912 | static struct videobuf_queue_ops cx231xx_video_qops = { | ||
913 | .buf_setup = buffer_setup, | ||
914 | .buf_prepare = buffer_prepare, | ||
915 | .buf_queue = buffer_queue, | ||
916 | .buf_release = buffer_release, | ||
917 | }; | ||
918 | |||
919 | /********************* v4l2 interface **************************************/ | ||
920 | |||
921 | void video_mux(struct cx231xx *dev, int index) | ||
922 | { | ||
923 | dev->video_input = index; | ||
924 | dev->ctl_ainput = INPUT(index)->amux; | ||
925 | |||
926 | cx231xx_set_video_input_mux(dev, index); | ||
927 | |||
928 | cx25840_call(dev, video, s_routing, INPUT(index)->vmux, 0, 0); | ||
929 | |||
930 | cx231xx_set_audio_input(dev, dev->ctl_ainput); | ||
931 | |||
932 | cx231xx_info("video_mux : %d\n", index); | ||
933 | |||
934 | /* do mode control overrides if required */ | ||
935 | cx231xx_do_mode_ctrl_overrides(dev); | ||
936 | } | ||
937 | |||
938 | /* Usage lock check functions */ | ||
939 | static int res_get(struct cx231xx_fh *fh) | ||
940 | { | ||
941 | struct cx231xx *dev = fh->dev; | ||
942 | int rc = 0; | ||
943 | |||
944 | /* This instance already has stream_on */ | ||
945 | if (fh->stream_on) | ||
946 | return rc; | ||
947 | |||
948 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { | ||
949 | if (dev->stream_on) | ||
950 | return -EBUSY; | ||
951 | dev->stream_on = 1; | ||
952 | } else if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
953 | if (dev->vbi_stream_on) | ||
954 | return -EBUSY; | ||
955 | dev->vbi_stream_on = 1; | ||
956 | } else | ||
957 | return -EINVAL; | ||
958 | |||
959 | fh->stream_on = 1; | ||
960 | |||
961 | return rc; | ||
962 | } | ||
963 | |||
964 | static int res_check(struct cx231xx_fh *fh) | ||
965 | { | ||
966 | return fh->stream_on; | ||
967 | } | ||
968 | |||
969 | static void res_free(struct cx231xx_fh *fh) | ||
970 | { | ||
971 | struct cx231xx *dev = fh->dev; | ||
972 | |||
973 | fh->stream_on = 0; | ||
974 | |||
975 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
976 | dev->stream_on = 0; | ||
977 | if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) | ||
978 | dev->vbi_stream_on = 0; | ||
979 | } | ||
980 | |||
981 | static int check_dev(struct cx231xx *dev) | ||
982 | { | ||
983 | if (dev->state & DEV_DISCONNECTED) { | ||
984 | cx231xx_errdev("v4l2 ioctl: device not present\n"); | ||
985 | return -ENODEV; | ||
986 | } | ||
987 | return 0; | ||
988 | } | ||
989 | |||
990 | /* ------------------------------------------------------------------ | ||
991 | IOCTL vidioc handling | ||
992 | ------------------------------------------------------------------*/ | ||
993 | |||
994 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | ||
995 | struct v4l2_format *f) | ||
996 | { | ||
997 | struct cx231xx_fh *fh = priv; | ||
998 | struct cx231xx *dev = fh->dev; | ||
999 | |||
1000 | f->fmt.pix.width = dev->width; | ||
1001 | f->fmt.pix.height = dev->height; | ||
1002 | f->fmt.pix.pixelformat = dev->format->fourcc; | ||
1003 | f->fmt.pix.bytesperline = (dev->width * dev->format->depth + 7) >> 3; | ||
1004 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height; | ||
1005 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
1006 | |||
1007 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; | ||
1008 | |||
1009 | return 0; | ||
1010 | } | ||
1011 | |||
1012 | static struct cx231xx_fmt *format_by_fourcc(unsigned int fourcc) | ||
1013 | { | ||
1014 | unsigned int i; | ||
1015 | |||
1016 | for (i = 0; i < ARRAY_SIZE(format); i++) | ||
1017 | if (format[i].fourcc == fourcc) | ||
1018 | return &format[i]; | ||
1019 | |||
1020 | return NULL; | ||
1021 | } | ||
1022 | |||
1023 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | ||
1024 | struct v4l2_format *f) | ||
1025 | { | ||
1026 | struct cx231xx_fh *fh = priv; | ||
1027 | struct cx231xx *dev = fh->dev; | ||
1028 | unsigned int width = f->fmt.pix.width; | ||
1029 | unsigned int height = f->fmt.pix.height; | ||
1030 | unsigned int maxw = norm_maxw(dev); | ||
1031 | unsigned int maxh = norm_maxh(dev); | ||
1032 | struct cx231xx_fmt *fmt; | ||
1033 | |||
1034 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | ||
1035 | if (!fmt) { | ||
1036 | cx231xx_videodbg("Fourcc format (%08x) invalid.\n", | ||
1037 | f->fmt.pix.pixelformat); | ||
1038 | return -EINVAL; | ||
1039 | } | ||
1040 | |||
1041 | /* width must even because of the YUYV format | ||
1042 | height must be even because of interlacing */ | ||
1043 | v4l_bound_align_image(&width, 48, maxw, 1, &height, 32, maxh, 1, 0); | ||
1044 | |||
1045 | f->fmt.pix.width = width; | ||
1046 | f->fmt.pix.height = height; | ||
1047 | f->fmt.pix.pixelformat = fmt->fourcc; | ||
1048 | f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3; | ||
1049 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; | ||
1050 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | ||
1051 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; | ||
1052 | |||
1053 | return 0; | ||
1054 | } | ||
1055 | |||
1056 | static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | ||
1057 | struct v4l2_format *f) | ||
1058 | { | ||
1059 | struct cx231xx_fh *fh = priv; | ||
1060 | struct cx231xx *dev = fh->dev; | ||
1061 | int rc; | ||
1062 | struct cx231xx_fmt *fmt; | ||
1063 | struct v4l2_mbus_framefmt mbus_fmt; | ||
1064 | |||
1065 | rc = check_dev(dev); | ||
1066 | if (rc < 0) | ||
1067 | return rc; | ||
1068 | |||
1069 | vidioc_try_fmt_vid_cap(file, priv, f); | ||
1070 | |||
1071 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | ||
1072 | if (!fmt) | ||
1073 | return -EINVAL; | ||
1074 | |||
1075 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { | ||
1076 | cx231xx_errdev("%s queue busy\n", __func__); | ||
1077 | return -EBUSY; | ||
1078 | } | ||
1079 | |||
1080 | if (dev->stream_on && !fh->stream_on) { | ||
1081 | cx231xx_errdev("%s device in use by another fh\n", __func__); | ||
1082 | return -EBUSY; | ||
1083 | } | ||
1084 | |||
1085 | /* set new image size */ | ||
1086 | dev->width = f->fmt.pix.width; | ||
1087 | dev->height = f->fmt.pix.height; | ||
1088 | dev->format = fmt; | ||
1089 | |||
1090 | v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); | ||
1091 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); | ||
1092 | v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); | ||
1093 | |||
1094 | return rc; | ||
1095 | } | ||
1096 | |||
1097 | static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *id) | ||
1098 | { | ||
1099 | struct cx231xx_fh *fh = priv; | ||
1100 | struct cx231xx *dev = fh->dev; | ||
1101 | |||
1102 | *id = dev->norm; | ||
1103 | return 0; | ||
1104 | } | ||
1105 | |||
1106 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | ||
1107 | { | ||
1108 | struct cx231xx_fh *fh = priv; | ||
1109 | struct cx231xx *dev = fh->dev; | ||
1110 | struct v4l2_mbus_framefmt mbus_fmt; | ||
1111 | struct v4l2_format f; | ||
1112 | int rc; | ||
1113 | |||
1114 | rc = check_dev(dev); | ||
1115 | if (rc < 0) | ||
1116 | return rc; | ||
1117 | |||
1118 | cx231xx_info("vidioc_s_std : 0x%x\n", (unsigned int)*norm); | ||
1119 | |||
1120 | dev->norm = *norm; | ||
1121 | |||
1122 | /* Adjusts width/height, if needed */ | ||
1123 | f.fmt.pix.width = dev->width; | ||
1124 | f.fmt.pix.height = dev->height; | ||
1125 | vidioc_try_fmt_vid_cap(file, priv, &f); | ||
1126 | |||
1127 | call_all(dev, core, s_std, dev->norm); | ||
1128 | |||
1129 | /* We need to reset basic properties in the decoder related to | ||
1130 | resolution (since a standard change effects things like the number | ||
1131 | of lines in VACT, etc) */ | ||
1132 | v4l2_fill_mbus_format(&mbus_fmt, &f.fmt.pix, V4L2_MBUS_FMT_FIXED); | ||
1133 | call_all(dev, video, s_mbus_fmt, &mbus_fmt); | ||
1134 | v4l2_fill_pix_format(&f.fmt.pix, &mbus_fmt); | ||
1135 | |||
1136 | /* set new image size */ | ||
1137 | dev->width = f.fmt.pix.width; | ||
1138 | dev->height = f.fmt.pix.height; | ||
1139 | |||
1140 | /* do mode control overrides */ | ||
1141 | cx231xx_do_mode_ctrl_overrides(dev); | ||
1142 | |||
1143 | return 0; | ||
1144 | } | ||
1145 | |||
1146 | static const char *iname[] = { | ||
1147 | [CX231XX_VMUX_COMPOSITE1] = "Composite1", | ||
1148 | [CX231XX_VMUX_SVIDEO] = "S-Video", | ||
1149 | [CX231XX_VMUX_TELEVISION] = "Television", | ||
1150 | [CX231XX_VMUX_CABLE] = "Cable TV", | ||
1151 | [CX231XX_VMUX_DVB] = "DVB", | ||
1152 | [CX231XX_VMUX_DEBUG] = "for debug only", | ||
1153 | }; | ||
1154 | |||
1155 | static int vidioc_enum_input(struct file *file, void *priv, | ||
1156 | struct v4l2_input *i) | ||
1157 | { | ||
1158 | struct cx231xx_fh *fh = priv; | ||
1159 | struct cx231xx *dev = fh->dev; | ||
1160 | u32 gen_stat; | ||
1161 | unsigned int ret, n; | ||
1162 | |||
1163 | n = i->index; | ||
1164 | if (n >= MAX_CX231XX_INPUT) | ||
1165 | return -EINVAL; | ||
1166 | if (0 == INPUT(n)->type) | ||
1167 | return -EINVAL; | ||
1168 | |||
1169 | i->index = n; | ||
1170 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
1171 | |||
1172 | strcpy(i->name, iname[INPUT(n)->type]); | ||
1173 | |||
1174 | if ((CX231XX_VMUX_TELEVISION == INPUT(n)->type) || | ||
1175 | (CX231XX_VMUX_CABLE == INPUT(n)->type)) | ||
1176 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
1177 | |||
1178 | i->std = dev->vdev->tvnorms; | ||
1179 | |||
1180 | /* If they are asking about the active input, read signal status */ | ||
1181 | if (n == dev->video_input) { | ||
1182 | ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
1183 | GEN_STAT, 2, &gen_stat, 4); | ||
1184 | if (ret > 0) { | ||
1185 | if ((gen_stat & FLD_VPRES) == 0x00) | ||
1186 | i->status |= V4L2_IN_ST_NO_SIGNAL; | ||
1187 | if ((gen_stat & FLD_HLOCK) == 0x00) | ||
1188 | i->status |= V4L2_IN_ST_NO_H_LOCK; | ||
1189 | } | ||
1190 | } | ||
1191 | |||
1192 | return 0; | ||
1193 | } | ||
1194 | |||
1195 | static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) | ||
1196 | { | ||
1197 | struct cx231xx_fh *fh = priv; | ||
1198 | struct cx231xx *dev = fh->dev; | ||
1199 | |||
1200 | *i = dev->video_input; | ||
1201 | |||
1202 | return 0; | ||
1203 | } | ||
1204 | |||
1205 | static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | ||
1206 | { | ||
1207 | struct cx231xx_fh *fh = priv; | ||
1208 | struct cx231xx *dev = fh->dev; | ||
1209 | int rc; | ||
1210 | |||
1211 | dev->mode_tv = 0; | ||
1212 | rc = check_dev(dev); | ||
1213 | if (rc < 0) | ||
1214 | return rc; | ||
1215 | |||
1216 | if (i >= MAX_CX231XX_INPUT) | ||
1217 | return -EINVAL; | ||
1218 | if (0 == INPUT(i)->type) | ||
1219 | return -EINVAL; | ||
1220 | |||
1221 | video_mux(dev, i); | ||
1222 | |||
1223 | if (INPUT(i)->type == CX231XX_VMUX_TELEVISION || | ||
1224 | INPUT(i)->type == CX231XX_VMUX_CABLE) { | ||
1225 | /* There's a tuner, so reset the standard and put it on the | ||
1226 | last known frequency (since it was probably powered down | ||
1227 | until now */ | ||
1228 | call_all(dev, core, s_std, dev->norm); | ||
1229 | } | ||
1230 | |||
1231 | return 0; | ||
1232 | } | ||
1233 | |||
1234 | static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
1235 | { | ||
1236 | struct cx231xx_fh *fh = priv; | ||
1237 | struct cx231xx *dev = fh->dev; | ||
1238 | |||
1239 | switch (a->index) { | ||
1240 | case CX231XX_AMUX_VIDEO: | ||
1241 | strcpy(a->name, "Television"); | ||
1242 | break; | ||
1243 | case CX231XX_AMUX_LINE_IN: | ||
1244 | strcpy(a->name, "Line In"); | ||
1245 | break; | ||
1246 | default: | ||
1247 | return -EINVAL; | ||
1248 | } | ||
1249 | |||
1250 | a->index = dev->ctl_ainput; | ||
1251 | a->capability = V4L2_AUDCAP_STEREO; | ||
1252 | |||
1253 | return 0; | ||
1254 | } | ||
1255 | |||
1256 | static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
1257 | { | ||
1258 | struct cx231xx_fh *fh = priv; | ||
1259 | struct cx231xx *dev = fh->dev; | ||
1260 | int status = 0; | ||
1261 | |||
1262 | /* Doesn't allow manual routing */ | ||
1263 | if (a->index != dev->ctl_ainput) | ||
1264 | return -EINVAL; | ||
1265 | |||
1266 | dev->ctl_ainput = INPUT(a->index)->amux; | ||
1267 | status = cx231xx_set_audio_input(dev, dev->ctl_ainput); | ||
1268 | |||
1269 | return status; | ||
1270 | } | ||
1271 | |||
1272 | static int vidioc_queryctrl(struct file *file, void *priv, | ||
1273 | struct v4l2_queryctrl *qc) | ||
1274 | { | ||
1275 | struct cx231xx_fh *fh = priv; | ||
1276 | struct cx231xx *dev = fh->dev; | ||
1277 | int id = qc->id; | ||
1278 | int i; | ||
1279 | int rc; | ||
1280 | |||
1281 | rc = check_dev(dev); | ||
1282 | if (rc < 0) | ||
1283 | return rc; | ||
1284 | |||
1285 | qc->id = v4l2_ctrl_next(ctrl_classes, qc->id); | ||
1286 | if (unlikely(qc->id == 0)) | ||
1287 | return -EINVAL; | ||
1288 | |||
1289 | memset(qc, 0, sizeof(*qc)); | ||
1290 | |||
1291 | qc->id = id; | ||
1292 | |||
1293 | if (qc->id < V4L2_CID_BASE || qc->id >= V4L2_CID_LASTP1) | ||
1294 | return -EINVAL; | ||
1295 | |||
1296 | for (i = 0; i < CX231XX_CTLS; i++) | ||
1297 | if (cx231xx_ctls[i].v.id == qc->id) | ||
1298 | break; | ||
1299 | |||
1300 | if (i == CX231XX_CTLS) { | ||
1301 | *qc = no_ctl; | ||
1302 | return 0; | ||
1303 | } | ||
1304 | *qc = cx231xx_ctls[i].v; | ||
1305 | |||
1306 | call_all(dev, core, queryctrl, qc); | ||
1307 | |||
1308 | if (qc->type) | ||
1309 | return 0; | ||
1310 | else | ||
1311 | return -EINVAL; | ||
1312 | } | ||
1313 | |||
1314 | static int vidioc_g_ctrl(struct file *file, void *priv, | ||
1315 | struct v4l2_control *ctrl) | ||
1316 | { | ||
1317 | struct cx231xx_fh *fh = priv; | ||
1318 | struct cx231xx *dev = fh->dev; | ||
1319 | int rc; | ||
1320 | |||
1321 | rc = check_dev(dev); | ||
1322 | if (rc < 0) | ||
1323 | return rc; | ||
1324 | |||
1325 | call_all(dev, core, g_ctrl, ctrl); | ||
1326 | return rc; | ||
1327 | } | ||
1328 | |||
1329 | static int vidioc_s_ctrl(struct file *file, void *priv, | ||
1330 | struct v4l2_control *ctrl) | ||
1331 | { | ||
1332 | struct cx231xx_fh *fh = priv; | ||
1333 | struct cx231xx *dev = fh->dev; | ||
1334 | int rc; | ||
1335 | |||
1336 | rc = check_dev(dev); | ||
1337 | if (rc < 0) | ||
1338 | return rc; | ||
1339 | |||
1340 | call_all(dev, core, s_ctrl, ctrl); | ||
1341 | return rc; | ||
1342 | } | ||
1343 | |||
1344 | static int vidioc_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
1345 | { | ||
1346 | struct cx231xx_fh *fh = priv; | ||
1347 | struct cx231xx *dev = fh->dev; | ||
1348 | int rc; | ||
1349 | |||
1350 | rc = check_dev(dev); | ||
1351 | if (rc < 0) | ||
1352 | return rc; | ||
1353 | |||
1354 | if (0 != t->index) | ||
1355 | return -EINVAL; | ||
1356 | |||
1357 | strcpy(t->name, "Tuner"); | ||
1358 | |||
1359 | t->type = V4L2_TUNER_ANALOG_TV; | ||
1360 | t->capability = V4L2_TUNER_CAP_NORM; | ||
1361 | t->rangehigh = 0xffffffffUL; | ||
1362 | t->signal = 0xffff; /* LOCKED */ | ||
1363 | |||
1364 | return 0; | ||
1365 | } | ||
1366 | |||
1367 | static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
1368 | { | ||
1369 | struct cx231xx_fh *fh = priv; | ||
1370 | struct cx231xx *dev = fh->dev; | ||
1371 | int rc; | ||
1372 | |||
1373 | rc = check_dev(dev); | ||
1374 | if (rc < 0) | ||
1375 | return rc; | ||
1376 | |||
1377 | if (0 != t->index) | ||
1378 | return -EINVAL; | ||
1379 | #if 0 | ||
1380 | call_all(dev, tuner, s_tuner, t); | ||
1381 | #endif | ||
1382 | return 0; | ||
1383 | } | ||
1384 | |||
1385 | static int vidioc_g_frequency(struct file *file, void *priv, | ||
1386 | struct v4l2_frequency *f) | ||
1387 | { | ||
1388 | struct cx231xx_fh *fh = priv; | ||
1389 | struct cx231xx *dev = fh->dev; | ||
1390 | |||
1391 | f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
1392 | f->frequency = dev->ctl_freq; | ||
1393 | |||
1394 | call_all(dev, tuner, g_frequency, f); | ||
1395 | |||
1396 | return 0; | ||
1397 | } | ||
1398 | |||
1399 | static int vidioc_s_frequency(struct file *file, void *priv, | ||
1400 | struct v4l2_frequency *f) | ||
1401 | { | ||
1402 | struct cx231xx_fh *fh = priv; | ||
1403 | struct cx231xx *dev = fh->dev; | ||
1404 | int rc; | ||
1405 | u32 if_frequency = 5400000; | ||
1406 | |||
1407 | cx231xx_info("Enter vidioc_s_frequency()f->frequency=%d;f->type=%d\n", | ||
1408 | f->frequency, f->type); | ||
1409 | /*cx231xx_info("f->type: 1-radio 2-analogTV 3-digitalTV\n");*/ | ||
1410 | |||
1411 | rc = check_dev(dev); | ||
1412 | if (rc < 0) | ||
1413 | return rc; | ||
1414 | |||
1415 | if (0 != f->tuner) | ||
1416 | return -EINVAL; | ||
1417 | |||
1418 | if (unlikely(0 == fh->radio && f->type != V4L2_TUNER_ANALOG_TV)) | ||
1419 | return -EINVAL; | ||
1420 | if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO)) | ||
1421 | return -EINVAL; | ||
1422 | |||
1423 | /* set pre channel change settings in DIF first */ | ||
1424 | rc = cx231xx_tuner_pre_channel_change(dev); | ||
1425 | |||
1426 | dev->ctl_freq = f->frequency; | ||
1427 | call_all(dev, tuner, s_frequency, f); | ||
1428 | |||
1429 | /* set post channel change settings in DIF first */ | ||
1430 | rc = cx231xx_tuner_post_channel_change(dev); | ||
1431 | |||
1432 | if (dev->tuner_type == TUNER_NXP_TDA18271) { | ||
1433 | if (dev->norm & (V4L2_STD_MN | V4L2_STD_NTSC_443)) | ||
1434 | if_frequency = 5400000; /*5.4MHz */ | ||
1435 | else if (dev->norm & V4L2_STD_B) | ||
1436 | if_frequency = 6000000; /*6.0MHz */ | ||
1437 | else if (dev->norm & (V4L2_STD_PAL_DK | V4L2_STD_SECAM_DK)) | ||
1438 | if_frequency = 6900000; /*6.9MHz */ | ||
1439 | else if (dev->norm & V4L2_STD_GH) | ||
1440 | if_frequency = 7100000; /*7.1MHz */ | ||
1441 | else if (dev->norm & V4L2_STD_PAL_I) | ||
1442 | if_frequency = 7250000; /*7.25MHz */ | ||
1443 | else if (dev->norm & V4L2_STD_SECAM_L) | ||
1444 | if_frequency = 6900000; /*6.9MHz */ | ||
1445 | else if (dev->norm & V4L2_STD_SECAM_LC) | ||
1446 | if_frequency = 1250000; /*1.25MHz */ | ||
1447 | |||
1448 | cx231xx_info("if_frequency is set to %d\n", if_frequency); | ||
1449 | cx231xx_set_Colibri_For_LowIF(dev, if_frequency, 1, 1); | ||
1450 | |||
1451 | update_HH_register_after_set_DIF(dev); | ||
1452 | } | ||
1453 | |||
1454 | cx231xx_info("Set New FREQUENCY to %d\n", f->frequency); | ||
1455 | |||
1456 | return rc; | ||
1457 | } | ||
1458 | |||
1459 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
1460 | |||
1461 | /* | ||
1462 | -R, --list-registers=type=<host/i2cdrv/i2caddr>, | ||
1463 | chip=<chip>[,min=<addr>,max=<addr>] | ||
1464 | dump registers from <min> to <max> [VIDIOC_DBG_G_REGISTER] | ||
1465 | -r, --set-register=type=<host/i2cdrv/i2caddr>, | ||
1466 | chip=<chip>,reg=<addr>,val=<val> | ||
1467 | set the register [VIDIOC_DBG_S_REGISTER] | ||
1468 | |||
1469 | if type == host, then <chip> is the hosts chip ID (default 0) | ||
1470 | if type == i2cdrv (default), then <chip> is the I2C driver name or ID | ||
1471 | if type == i2caddr, then <chip> is the 7-bit I2C address | ||
1472 | */ | ||
1473 | |||
1474 | static int vidioc_g_register(struct file *file, void *priv, | ||
1475 | struct v4l2_dbg_register *reg) | ||
1476 | { | ||
1477 | struct cx231xx_fh *fh = priv; | ||
1478 | struct cx231xx *dev = fh->dev; | ||
1479 | int ret = 0; | ||
1480 | u8 value[4] = { 0, 0, 0, 0 }; | ||
1481 | u32 data = 0; | ||
1482 | |||
1483 | switch (reg->match.type) { | ||
1484 | case V4L2_CHIP_MATCH_HOST: | ||
1485 | switch (reg->match.addr) { | ||
1486 | case 0: /* Cx231xx - internal registers */ | ||
1487 | ret = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, | ||
1488 | (u16)reg->reg, value, 4); | ||
1489 | reg->val = value[0] | value[1] << 8 | | ||
1490 | value[2] << 16 | value[3] << 24; | ||
1491 | break; | ||
1492 | case 1: /* AFE - read byte */ | ||
1493 | ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, | ||
1494 | (u16)reg->reg, 2, &data, 1); | ||
1495 | reg->val = le32_to_cpu(data & 0xff); | ||
1496 | break; | ||
1497 | case 14: /* AFE - read dword */ | ||
1498 | ret = cx231xx_read_i2c_data(dev, AFE_DEVICE_ADDRESS, | ||
1499 | (u16)reg->reg, 2, &data, 4); | ||
1500 | reg->val = le32_to_cpu(data); | ||
1501 | break; | ||
1502 | case 2: /* Video Block - read byte */ | ||
1503 | ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
1504 | (u16)reg->reg, 2, &data, 1); | ||
1505 | reg->val = le32_to_cpu(data & 0xff); | ||
1506 | break; | ||
1507 | case 24: /* Video Block - read dword */ | ||
1508 | ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, | ||
1509 | (u16)reg->reg, 2, &data, 4); | ||
1510 | reg->val = le32_to_cpu(data); | ||
1511 | break; | ||
1512 | case 3: /* I2S block - read byte */ | ||
1513 | ret = cx231xx_read_i2c_data(dev, | ||
1514 | I2S_BLK_DEVICE_ADDRESS, | ||
1515 | (u16)reg->reg, 1, | ||
1516 | &data, 1); | ||
1517 | reg->val = le32_to_cpu(data & 0xff); | ||
1518 | break; | ||
1519 | case 34: /* I2S Block - read dword */ | ||
1520 | ret = | ||
1521 | cx231xx_read_i2c_data(dev, I2S_BLK_DEVICE_ADDRESS, | ||
1522 | (u16)reg->reg, 1, &data, 4); | ||
1523 | reg->val = le32_to_cpu(data); | ||
1524 | break; | ||
1525 | } | ||
1526 | return ret < 0 ? ret : 0; | ||
1527 | |||
1528 | case V4L2_CHIP_MATCH_I2C_DRIVER: | ||
1529 | call_all(dev, core, g_register, reg); | ||
1530 | return 0; | ||
1531 | case V4L2_CHIP_MATCH_I2C_ADDR:/*for register debug*/ | ||
1532 | switch (reg->match.addr) { | ||
1533 | case 0: /* Cx231xx - internal registers */ | ||
1534 | ret = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, | ||
1535 | (u16)reg->reg, value, 4); | ||
1536 | reg->val = value[0] | value[1] << 8 | | ||
1537 | value[2] << 16 | value[3] << 24; | ||
1538 | |||
1539 | break; | ||
1540 | case 0x600:/* AFE - read byte */ | ||
1541 | ret = cx231xx_read_i2c_master(dev, AFE_DEVICE_ADDRESS, | ||
1542 | (u16)reg->reg, 2, | ||
1543 | &data, 1 , 0); | ||
1544 | reg->val = le32_to_cpu(data & 0xff); | ||
1545 | break; | ||
1546 | |||
1547 | case 0x880:/* Video Block - read byte */ | ||
1548 | if (reg->reg < 0x0b) { | ||
1549 | ret = cx231xx_read_i2c_master(dev, | ||
1550 | VID_BLK_I2C_ADDRESS, | ||
1551 | (u16)reg->reg, 2, | ||
1552 | &data, 1 , 0); | ||
1553 | reg->val = le32_to_cpu(data & 0xff); | ||
1554 | } else { | ||
1555 | ret = cx231xx_read_i2c_master(dev, | ||
1556 | VID_BLK_I2C_ADDRESS, | ||
1557 | (u16)reg->reg, 2, | ||
1558 | &data, 4 , 0); | ||
1559 | reg->val = le32_to_cpu(data); | ||
1560 | } | ||
1561 | break; | ||
1562 | case 0x980: | ||
1563 | ret = cx231xx_read_i2c_master(dev, | ||
1564 | I2S_BLK_DEVICE_ADDRESS, | ||
1565 | (u16)reg->reg, 1, | ||
1566 | &data, 1 , 0); | ||
1567 | reg->val = le32_to_cpu(data & 0xff); | ||
1568 | break; | ||
1569 | case 0x400: | ||
1570 | ret = | ||
1571 | cx231xx_read_i2c_master(dev, 0x40, | ||
1572 | (u16)reg->reg, 1, | ||
1573 | &data, 1 , 0); | ||
1574 | reg->val = le32_to_cpu(data & 0xff); | ||
1575 | break; | ||
1576 | case 0xc01: | ||
1577 | ret = | ||
1578 | cx231xx_read_i2c_master(dev, 0xc0, | ||
1579 | (u16)reg->reg, 2, | ||
1580 | &data, 38, 1); | ||
1581 | reg->val = le32_to_cpu(data); | ||
1582 | break; | ||
1583 | case 0x022: | ||
1584 | ret = | ||
1585 | cx231xx_read_i2c_master(dev, 0x02, | ||
1586 | (u16)reg->reg, 1, | ||
1587 | &data, 1, 2); | ||
1588 | reg->val = le32_to_cpu(data & 0xff); | ||
1589 | break; | ||
1590 | case 0x322: | ||
1591 | ret = cx231xx_read_i2c_master(dev, | ||
1592 | 0x32, | ||
1593 | (u16)reg->reg, 1, | ||
1594 | &data, 4 , 2); | ||
1595 | reg->val = le32_to_cpu(data); | ||
1596 | break; | ||
1597 | case 0x342: | ||
1598 | ret = cx231xx_read_i2c_master(dev, | ||
1599 | 0x34, | ||
1600 | (u16)reg->reg, 1, | ||
1601 | &data, 4 , 2); | ||
1602 | reg->val = le32_to_cpu(data); | ||
1603 | break; | ||
1604 | |||
1605 | default: | ||
1606 | cx231xx_info("no match device address!!\n"); | ||
1607 | break; | ||
1608 | } | ||
1609 | return ret < 0 ? ret : 0; | ||
1610 | /*return -EINVAL;*/ | ||
1611 | default: | ||
1612 | if (!v4l2_chip_match_host(®->match)) | ||
1613 | return -EINVAL; | ||
1614 | } | ||
1615 | |||
1616 | call_all(dev, core, g_register, reg); | ||
1617 | |||
1618 | return ret; | ||
1619 | } | ||
1620 | |||
1621 | static int vidioc_s_register(struct file *file, void *priv, | ||
1622 | struct v4l2_dbg_register *reg) | ||
1623 | { | ||
1624 | struct cx231xx_fh *fh = priv; | ||
1625 | struct cx231xx *dev = fh->dev; | ||
1626 | int ret = 0; | ||
1627 | __le64 buf; | ||
1628 | u32 value; | ||
1629 | u8 data[4] = { 0, 0, 0, 0 }; | ||
1630 | |||
1631 | buf = cpu_to_le64(reg->val); | ||
1632 | |||
1633 | switch (reg->match.type) { | ||
1634 | case V4L2_CHIP_MATCH_HOST: | ||
1635 | { | ||
1636 | value = (u32) buf & 0xffffffff; | ||
1637 | |||
1638 | switch (reg->match.addr) { | ||
1639 | case 0: /* cx231xx internal registers */ | ||
1640 | data[0] = (u8) value; | ||
1641 | data[1] = (u8) (value >> 8); | ||
1642 | data[2] = (u8) (value >> 16); | ||
1643 | data[3] = (u8) (value >> 24); | ||
1644 | ret = cx231xx_write_ctrl_reg(dev, | ||
1645 | VRT_SET_REGISTER, | ||
1646 | (u16)reg->reg, data, | ||
1647 | 4); | ||
1648 | break; | ||
1649 | case 1: /* AFE - read byte */ | ||
1650 | ret = cx231xx_write_i2c_data(dev, | ||
1651 | AFE_DEVICE_ADDRESS, | ||
1652 | (u16)reg->reg, 2, | ||
1653 | value, 1); | ||
1654 | break; | ||
1655 | case 14: /* AFE - read dword */ | ||
1656 | ret = cx231xx_write_i2c_data(dev, | ||
1657 | AFE_DEVICE_ADDRESS, | ||
1658 | (u16)reg->reg, 2, | ||
1659 | value, 4); | ||
1660 | break; | ||
1661 | case 2: /* Video Block - read byte */ | ||
1662 | ret = | ||
1663 | cx231xx_write_i2c_data(dev, | ||
1664 | VID_BLK_I2C_ADDRESS, | ||
1665 | (u16)reg->reg, 2, | ||
1666 | value, 1); | ||
1667 | break; | ||
1668 | case 24: /* Video Block - read dword */ | ||
1669 | ret = | ||
1670 | cx231xx_write_i2c_data(dev, | ||
1671 | VID_BLK_I2C_ADDRESS, | ||
1672 | (u16)reg->reg, 2, | ||
1673 | value, 4); | ||
1674 | break; | ||
1675 | case 3: /* I2S block - read byte */ | ||
1676 | ret = | ||
1677 | cx231xx_write_i2c_data(dev, | ||
1678 | I2S_BLK_DEVICE_ADDRESS, | ||
1679 | (u16)reg->reg, 1, | ||
1680 | value, 1); | ||
1681 | break; | ||
1682 | case 34: /* I2S block - read dword */ | ||
1683 | ret = | ||
1684 | cx231xx_write_i2c_data(dev, | ||
1685 | I2S_BLK_DEVICE_ADDRESS, | ||
1686 | (u16)reg->reg, 1, | ||
1687 | value, 4); | ||
1688 | break; | ||
1689 | } | ||
1690 | } | ||
1691 | return ret < 0 ? ret : 0; | ||
1692 | case V4L2_CHIP_MATCH_I2C_ADDR: | ||
1693 | { | ||
1694 | value = (u32) buf & 0xffffffff; | ||
1695 | |||
1696 | switch (reg->match.addr) { | ||
1697 | case 0:/*cx231xx internal registers*/ | ||
1698 | data[0] = (u8) value; | ||
1699 | data[1] = (u8) (value >> 8); | ||
1700 | data[2] = (u8) (value >> 16); | ||
1701 | data[3] = (u8) (value >> 24); | ||
1702 | ret = cx231xx_write_ctrl_reg(dev, | ||
1703 | VRT_SET_REGISTER, | ||
1704 | (u16)reg->reg, data, | ||
1705 | 4); | ||
1706 | break; | ||
1707 | case 0x600:/* AFE - read byte */ | ||
1708 | ret = cx231xx_write_i2c_master(dev, | ||
1709 | AFE_DEVICE_ADDRESS, | ||
1710 | (u16)reg->reg, 2, | ||
1711 | value, 1 , 0); | ||
1712 | break; | ||
1713 | |||
1714 | case 0x880:/* Video Block - read byte */ | ||
1715 | if (reg->reg < 0x0b) | ||
1716 | cx231xx_write_i2c_master(dev, | ||
1717 | VID_BLK_I2C_ADDRESS, | ||
1718 | (u16)reg->reg, 2, | ||
1719 | value, 1, 0); | ||
1720 | else | ||
1721 | cx231xx_write_i2c_master(dev, | ||
1722 | VID_BLK_I2C_ADDRESS, | ||
1723 | (u16)reg->reg, 2, | ||
1724 | value, 4, 0); | ||
1725 | break; | ||
1726 | case 0x980: | ||
1727 | ret = | ||
1728 | cx231xx_write_i2c_master(dev, | ||
1729 | I2S_BLK_DEVICE_ADDRESS, | ||
1730 | (u16)reg->reg, 1, | ||
1731 | value, 1, 0); | ||
1732 | break; | ||
1733 | case 0x400: | ||
1734 | ret = | ||
1735 | cx231xx_write_i2c_master(dev, | ||
1736 | 0x40, | ||
1737 | (u16)reg->reg, 1, | ||
1738 | value, 1, 0); | ||
1739 | break; | ||
1740 | case 0xc01: | ||
1741 | ret = | ||
1742 | cx231xx_write_i2c_master(dev, | ||
1743 | 0xc0, | ||
1744 | (u16)reg->reg, 1, | ||
1745 | value, 1, 1); | ||
1746 | break; | ||
1747 | |||
1748 | case 0x022: | ||
1749 | ret = | ||
1750 | cx231xx_write_i2c_master(dev, | ||
1751 | 0x02, | ||
1752 | (u16)reg->reg, 1, | ||
1753 | value, 1, 2); | ||
1754 | case 0x322: | ||
1755 | ret = | ||
1756 | cx231xx_write_i2c_master(dev, | ||
1757 | 0x32, | ||
1758 | (u16)reg->reg, 1, | ||
1759 | value, 4, 2); | ||
1760 | break; | ||
1761 | |||
1762 | case 0x342: | ||
1763 | ret = | ||
1764 | cx231xx_write_i2c_master(dev, | ||
1765 | 0x34, | ||
1766 | (u16)reg->reg, 1, | ||
1767 | value, 4, 2); | ||
1768 | break; | ||
1769 | default: | ||
1770 | cx231xx_info("no match device address, " | ||
1771 | "the value is %x\n", reg->match.addr); | ||
1772 | break; | ||
1773 | |||
1774 | } | ||
1775 | |||
1776 | } | ||
1777 | default: | ||
1778 | break; | ||
1779 | } | ||
1780 | |||
1781 | call_all(dev, core, s_register, reg); | ||
1782 | |||
1783 | return ret; | ||
1784 | } | ||
1785 | #endif | ||
1786 | |||
1787 | static int vidioc_cropcap(struct file *file, void *priv, | ||
1788 | struct v4l2_cropcap *cc) | ||
1789 | { | ||
1790 | struct cx231xx_fh *fh = priv; | ||
1791 | struct cx231xx *dev = fh->dev; | ||
1792 | |||
1793 | if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1794 | return -EINVAL; | ||
1795 | |||
1796 | cc->bounds.left = 0; | ||
1797 | cc->bounds.top = 0; | ||
1798 | cc->bounds.width = dev->width; | ||
1799 | cc->bounds.height = dev->height; | ||
1800 | cc->defrect = cc->bounds; | ||
1801 | cc->pixelaspect.numerator = 54; /* 4:3 FIXME: remove magic numbers */ | ||
1802 | cc->pixelaspect.denominator = 59; | ||
1803 | |||
1804 | return 0; | ||
1805 | } | ||
1806 | |||
1807 | static int vidioc_streamon(struct file *file, void *priv, | ||
1808 | enum v4l2_buf_type type) | ||
1809 | { | ||
1810 | struct cx231xx_fh *fh = priv; | ||
1811 | struct cx231xx *dev = fh->dev; | ||
1812 | int rc; | ||
1813 | |||
1814 | rc = check_dev(dev); | ||
1815 | if (rc < 0) | ||
1816 | return rc; | ||
1817 | |||
1818 | rc = res_get(fh); | ||
1819 | |||
1820 | if (likely(rc >= 0)) | ||
1821 | rc = videobuf_streamon(&fh->vb_vidq); | ||
1822 | |||
1823 | call_all(dev, video, s_stream, 1); | ||
1824 | |||
1825 | return rc; | ||
1826 | } | ||
1827 | |||
1828 | static int vidioc_streamoff(struct file *file, void *priv, | ||
1829 | enum v4l2_buf_type type) | ||
1830 | { | ||
1831 | struct cx231xx_fh *fh = priv; | ||
1832 | struct cx231xx *dev = fh->dev; | ||
1833 | int rc; | ||
1834 | |||
1835 | rc = check_dev(dev); | ||
1836 | if (rc < 0) | ||
1837 | return rc; | ||
1838 | |||
1839 | if ((fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) && | ||
1840 | (fh->type != V4L2_BUF_TYPE_VBI_CAPTURE)) | ||
1841 | return -EINVAL; | ||
1842 | if (type != fh->type) | ||
1843 | return -EINVAL; | ||
1844 | |||
1845 | cx25840_call(dev, video, s_stream, 0); | ||
1846 | |||
1847 | videobuf_streamoff(&fh->vb_vidq); | ||
1848 | res_free(fh); | ||
1849 | |||
1850 | return 0; | ||
1851 | } | ||
1852 | |||
1853 | static int vidioc_querycap(struct file *file, void *priv, | ||
1854 | struct v4l2_capability *cap) | ||
1855 | { | ||
1856 | struct cx231xx_fh *fh = priv; | ||
1857 | struct cx231xx *dev = fh->dev; | ||
1858 | |||
1859 | strlcpy(cap->driver, "cx231xx", sizeof(cap->driver)); | ||
1860 | strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card)); | ||
1861 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); | ||
1862 | |||
1863 | cap->capabilities = V4L2_CAP_VBI_CAPTURE | | ||
1864 | #if 0 | ||
1865 | V4L2_CAP_SLICED_VBI_CAPTURE | | ||
1866 | #endif | ||
1867 | V4L2_CAP_VIDEO_CAPTURE | | ||
1868 | V4L2_CAP_AUDIO | | ||
1869 | V4L2_CAP_READWRITE | | ||
1870 | V4L2_CAP_STREAMING; | ||
1871 | |||
1872 | if (dev->tuner_type != TUNER_ABSENT) | ||
1873 | cap->capabilities |= V4L2_CAP_TUNER; | ||
1874 | |||
1875 | return 0; | ||
1876 | } | ||
1877 | |||
1878 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, | ||
1879 | struct v4l2_fmtdesc *f) | ||
1880 | { | ||
1881 | if (unlikely(f->index >= ARRAY_SIZE(format))) | ||
1882 | return -EINVAL; | ||
1883 | |||
1884 | strlcpy(f->description, format[f->index].name, sizeof(f->description)); | ||
1885 | f->pixelformat = format[f->index].fourcc; | ||
1886 | |||
1887 | return 0; | ||
1888 | } | ||
1889 | |||
1890 | /* Sliced VBI ioctls */ | ||
1891 | static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv, | ||
1892 | struct v4l2_format *f) | ||
1893 | { | ||
1894 | struct cx231xx_fh *fh = priv; | ||
1895 | struct cx231xx *dev = fh->dev; | ||
1896 | int rc; | ||
1897 | |||
1898 | rc = check_dev(dev); | ||
1899 | if (rc < 0) | ||
1900 | return rc; | ||
1901 | |||
1902 | f->fmt.sliced.service_set = 0; | ||
1903 | |||
1904 | call_all(dev, vbi, g_sliced_fmt, &f->fmt.sliced); | ||
1905 | |||
1906 | if (f->fmt.sliced.service_set == 0) | ||
1907 | rc = -EINVAL; | ||
1908 | |||
1909 | return rc; | ||
1910 | } | ||
1911 | |||
1912 | static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv, | ||
1913 | struct v4l2_format *f) | ||
1914 | { | ||
1915 | struct cx231xx_fh *fh = priv; | ||
1916 | struct cx231xx *dev = fh->dev; | ||
1917 | int rc; | ||
1918 | |||
1919 | rc = check_dev(dev); | ||
1920 | if (rc < 0) | ||
1921 | return rc; | ||
1922 | |||
1923 | call_all(dev, vbi, g_sliced_fmt, &f->fmt.sliced); | ||
1924 | |||
1925 | if (f->fmt.sliced.service_set == 0) | ||
1926 | return -EINVAL; | ||
1927 | |||
1928 | return 0; | ||
1929 | } | ||
1930 | |||
1931 | /* RAW VBI ioctls */ | ||
1932 | |||
1933 | static int vidioc_g_fmt_vbi_cap(struct file *file, void *priv, | ||
1934 | struct v4l2_format *f) | ||
1935 | { | ||
1936 | struct cx231xx_fh *fh = priv; | ||
1937 | struct cx231xx *dev = fh->dev; | ||
1938 | f->fmt.vbi.sampling_rate = 6750000 * 4; | ||
1939 | f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH; | ||
1940 | f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | ||
1941 | f->fmt.vbi.offset = 0; | ||
1942 | f->fmt.vbi.start[0] = (dev->norm & V4L2_STD_625_50) ? | ||
1943 | PAL_VBI_START_LINE : NTSC_VBI_START_LINE; | ||
1944 | f->fmt.vbi.count[0] = (dev->norm & V4L2_STD_625_50) ? | ||
1945 | PAL_VBI_LINES : NTSC_VBI_LINES; | ||
1946 | f->fmt.vbi.start[1] = (dev->norm & V4L2_STD_625_50) ? | ||
1947 | PAL_VBI_START_LINE + 312 : NTSC_VBI_START_LINE + 263; | ||
1948 | f->fmt.vbi.count[1] = f->fmt.vbi.count[0]; | ||
1949 | |||
1950 | return 0; | ||
1951 | |||
1952 | } | ||
1953 | |||
1954 | static int vidioc_try_fmt_vbi_cap(struct file *file, void *priv, | ||
1955 | struct v4l2_format *f) | ||
1956 | { | ||
1957 | struct cx231xx_fh *fh = priv; | ||
1958 | struct cx231xx *dev = fh->dev; | ||
1959 | |||
1960 | if (dev->vbi_stream_on && !fh->stream_on) { | ||
1961 | cx231xx_errdev("%s device in use by another fh\n", __func__); | ||
1962 | return -EBUSY; | ||
1963 | } | ||
1964 | |||
1965 | f->type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
1966 | f->fmt.vbi.sampling_rate = 6750000 * 4; | ||
1967 | f->fmt.vbi.samples_per_line = VBI_LINE_LENGTH; | ||
1968 | f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | ||
1969 | f->fmt.vbi.offset = 0; | ||
1970 | f->fmt.vbi.flags = 0; | ||
1971 | f->fmt.vbi.start[0] = (dev->norm & V4L2_STD_625_50) ? | ||
1972 | PAL_VBI_START_LINE : NTSC_VBI_START_LINE; | ||
1973 | f->fmt.vbi.count[0] = (dev->norm & V4L2_STD_625_50) ? | ||
1974 | PAL_VBI_LINES : NTSC_VBI_LINES; | ||
1975 | f->fmt.vbi.start[1] = (dev->norm & V4L2_STD_625_50) ? | ||
1976 | PAL_VBI_START_LINE + 312 : NTSC_VBI_START_LINE + 263; | ||
1977 | f->fmt.vbi.count[1] = f->fmt.vbi.count[0]; | ||
1978 | |||
1979 | return 0; | ||
1980 | |||
1981 | } | ||
1982 | |||
1983 | static int vidioc_reqbufs(struct file *file, void *priv, | ||
1984 | struct v4l2_requestbuffers *rb) | ||
1985 | { | ||
1986 | struct cx231xx_fh *fh = priv; | ||
1987 | struct cx231xx *dev = fh->dev; | ||
1988 | int rc; | ||
1989 | |||
1990 | rc = check_dev(dev); | ||
1991 | if (rc < 0) | ||
1992 | return rc; | ||
1993 | |||
1994 | return videobuf_reqbufs(&fh->vb_vidq, rb); | ||
1995 | } | ||
1996 | |||
1997 | static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
1998 | { | ||
1999 | struct cx231xx_fh *fh = priv; | ||
2000 | struct cx231xx *dev = fh->dev; | ||
2001 | int rc; | ||
2002 | |||
2003 | rc = check_dev(dev); | ||
2004 | if (rc < 0) | ||
2005 | return rc; | ||
2006 | |||
2007 | return videobuf_querybuf(&fh->vb_vidq, b); | ||
2008 | } | ||
2009 | |||
2010 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
2011 | { | ||
2012 | struct cx231xx_fh *fh = priv; | ||
2013 | struct cx231xx *dev = fh->dev; | ||
2014 | int rc; | ||
2015 | |||
2016 | rc = check_dev(dev); | ||
2017 | if (rc < 0) | ||
2018 | return rc; | ||
2019 | |||
2020 | return videobuf_qbuf(&fh->vb_vidq, b); | ||
2021 | } | ||
2022 | |||
2023 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
2024 | { | ||
2025 | struct cx231xx_fh *fh = priv; | ||
2026 | struct cx231xx *dev = fh->dev; | ||
2027 | int rc; | ||
2028 | |||
2029 | rc = check_dev(dev); | ||
2030 | if (rc < 0) | ||
2031 | return rc; | ||
2032 | |||
2033 | return videobuf_dqbuf(&fh->vb_vidq, b, file->f_flags & O_NONBLOCK); | ||
2034 | } | ||
2035 | |||
2036 | /* ----------------------------------------------------------- */ | ||
2037 | /* RADIO ESPECIFIC IOCTLS */ | ||
2038 | /* ----------------------------------------------------------- */ | ||
2039 | |||
2040 | static int radio_querycap(struct file *file, void *priv, | ||
2041 | struct v4l2_capability *cap) | ||
2042 | { | ||
2043 | struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev; | ||
2044 | |||
2045 | strlcpy(cap->driver, "cx231xx", sizeof(cap->driver)); | ||
2046 | strlcpy(cap->card, cx231xx_boards[dev->model].name, sizeof(cap->card)); | ||
2047 | usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); | ||
2048 | |||
2049 | cap->capabilities = V4L2_CAP_TUNER; | ||
2050 | return 0; | ||
2051 | } | ||
2052 | |||
2053 | static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
2054 | { | ||
2055 | struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev; | ||
2056 | |||
2057 | if (unlikely(t->index > 0)) | ||
2058 | return -EINVAL; | ||
2059 | |||
2060 | strcpy(t->name, "Radio"); | ||
2061 | t->type = V4L2_TUNER_RADIO; | ||
2062 | |||
2063 | call_all(dev, tuner, s_tuner, t); | ||
2064 | |||
2065 | return 0; | ||
2066 | } | ||
2067 | |||
2068 | static int radio_enum_input(struct file *file, void *priv, struct v4l2_input *i) | ||
2069 | { | ||
2070 | if (i->index != 0) | ||
2071 | return -EINVAL; | ||
2072 | strcpy(i->name, "Radio"); | ||
2073 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
2074 | |||
2075 | return 0; | ||
2076 | } | ||
2077 | |||
2078 | static int radio_g_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
2079 | { | ||
2080 | if (unlikely(a->index)) | ||
2081 | return -EINVAL; | ||
2082 | |||
2083 | strcpy(a->name, "Radio"); | ||
2084 | return 0; | ||
2085 | } | ||
2086 | |||
2087 | static int radio_s_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
2088 | { | ||
2089 | struct cx231xx *dev = ((struct cx231xx_fh *)priv)->dev; | ||
2090 | |||
2091 | if (0 != t->index) | ||
2092 | return -EINVAL; | ||
2093 | |||
2094 | call_all(dev, tuner, s_tuner, t); | ||
2095 | |||
2096 | return 0; | ||
2097 | } | ||
2098 | |||
2099 | static int radio_s_audio(struct file *file, void *fh, struct v4l2_audio *a) | ||
2100 | { | ||
2101 | return 0; | ||
2102 | } | ||
2103 | |||
2104 | static int radio_s_input(struct file *file, void *fh, unsigned int i) | ||
2105 | { | ||
2106 | return 0; | ||
2107 | } | ||
2108 | |||
2109 | static int radio_queryctrl(struct file *file, void *priv, | ||
2110 | struct v4l2_queryctrl *c) | ||
2111 | { | ||
2112 | int i; | ||
2113 | |||
2114 | if (c->id < V4L2_CID_BASE || c->id >= V4L2_CID_LASTP1) | ||
2115 | return -EINVAL; | ||
2116 | if (c->id == V4L2_CID_AUDIO_MUTE) { | ||
2117 | for (i = 0; i < CX231XX_CTLS; i++) { | ||
2118 | if (cx231xx_ctls[i].v.id == c->id) | ||
2119 | break; | ||
2120 | } | ||
2121 | if (i == CX231XX_CTLS) | ||
2122 | return -EINVAL; | ||
2123 | *c = cx231xx_ctls[i].v; | ||
2124 | } else | ||
2125 | *c = no_ctl; | ||
2126 | return 0; | ||
2127 | } | ||
2128 | |||
2129 | /* | ||
2130 | * cx231xx_v4l2_open() | ||
2131 | * inits the device and starts isoc transfer | ||
2132 | */ | ||
2133 | static int cx231xx_v4l2_open(struct file *filp) | ||
2134 | { | ||
2135 | int errCode = 0, radio = 0; | ||
2136 | struct video_device *vdev = video_devdata(filp); | ||
2137 | struct cx231xx *dev = video_drvdata(filp); | ||
2138 | struct cx231xx_fh *fh; | ||
2139 | enum v4l2_buf_type fh_type = 0; | ||
2140 | |||
2141 | switch (vdev->vfl_type) { | ||
2142 | case VFL_TYPE_GRABBER: | ||
2143 | fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
2144 | break; | ||
2145 | case VFL_TYPE_VBI: | ||
2146 | fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
2147 | break; | ||
2148 | case VFL_TYPE_RADIO: | ||
2149 | radio = 1; | ||
2150 | break; | ||
2151 | } | ||
2152 | |||
2153 | cx231xx_videodbg("open dev=%s type=%s users=%d\n", | ||
2154 | video_device_node_name(vdev), v4l2_type_names[fh_type], | ||
2155 | dev->users); | ||
2156 | |||
2157 | #if 0 | ||
2158 | errCode = cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | ||
2159 | if (errCode < 0) { | ||
2160 | cx231xx_errdev | ||
2161 | ("Device locked on digital mode. Can't open analog\n"); | ||
2162 | return -EBUSY; | ||
2163 | } | ||
2164 | #endif | ||
2165 | |||
2166 | fh = kzalloc(sizeof(struct cx231xx_fh), GFP_KERNEL); | ||
2167 | if (!fh) { | ||
2168 | cx231xx_errdev("cx231xx-video.c: Out of memory?!\n"); | ||
2169 | return -ENOMEM; | ||
2170 | } | ||
2171 | if (mutex_lock_interruptible(&dev->lock)) { | ||
2172 | kfree(fh); | ||
2173 | return -ERESTARTSYS; | ||
2174 | } | ||
2175 | fh->dev = dev; | ||
2176 | fh->radio = radio; | ||
2177 | fh->type = fh_type; | ||
2178 | filp->private_data = fh; | ||
2179 | |||
2180 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { | ||
2181 | dev->width = norm_maxw(dev); | ||
2182 | dev->height = norm_maxh(dev); | ||
2183 | |||
2184 | /* Power up in Analog TV mode */ | ||
2185 | if (dev->board.external_av) | ||
2186 | cx231xx_set_power_mode(dev, | ||
2187 | POLARIS_AVMODE_ENXTERNAL_AV); | ||
2188 | else | ||
2189 | cx231xx_set_power_mode(dev, POLARIS_AVMODE_ANALOGT_TV); | ||
2190 | |||
2191 | #if 0 | ||
2192 | cx231xx_set_mode(dev, CX231XX_ANALOG_MODE); | ||
2193 | #endif | ||
2194 | |||
2195 | /* set video alternate setting */ | ||
2196 | cx231xx_set_video_alternate(dev); | ||
2197 | |||
2198 | /* Needed, since GPIO might have disabled power of | ||
2199 | some i2c device */ | ||
2200 | cx231xx_config_i2c(dev); | ||
2201 | |||
2202 | /* device needs to be initialized before isoc transfer */ | ||
2203 | dev->video_input = dev->video_input > 2 ? 2 : dev->video_input; | ||
2204 | |||
2205 | } | ||
2206 | if (fh->radio) { | ||
2207 | cx231xx_videodbg("video_open: setting radio device\n"); | ||
2208 | |||
2209 | /* cx231xx_start_radio(dev); */ | ||
2210 | |||
2211 | call_all(dev, tuner, s_radio); | ||
2212 | } | ||
2213 | |||
2214 | dev->users++; | ||
2215 | |||
2216 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
2217 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_video_qops, | ||
2218 | NULL, &dev->video_mode.slock, | ||
2219 | fh->type, V4L2_FIELD_INTERLACED, | ||
2220 | sizeof(struct cx231xx_buffer), | ||
2221 | fh, &dev->lock); | ||
2222 | if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
2223 | /* Set the required alternate setting VBI interface works in | ||
2224 | Bulk mode only */ | ||
2225 | cx231xx_set_alt_setting(dev, INDEX_VANC, 0); | ||
2226 | |||
2227 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &cx231xx_vbi_qops, | ||
2228 | NULL, &dev->vbi_mode.slock, | ||
2229 | fh->type, V4L2_FIELD_SEQ_TB, | ||
2230 | sizeof(struct cx231xx_buffer), | ||
2231 | fh, &dev->lock); | ||
2232 | } | ||
2233 | mutex_unlock(&dev->lock); | ||
2234 | |||
2235 | return errCode; | ||
2236 | } | ||
2237 | |||
2238 | /* | ||
2239 | * cx231xx_realease_resources() | ||
2240 | * unregisters the v4l2,i2c and usb devices | ||
2241 | * called when the device gets disconected or at module unload | ||
2242 | */ | ||
2243 | void cx231xx_release_analog_resources(struct cx231xx *dev) | ||
2244 | { | ||
2245 | |||
2246 | /*FIXME: I2C IR should be disconnected */ | ||
2247 | |||
2248 | if (dev->radio_dev) { | ||
2249 | if (video_is_registered(dev->radio_dev)) | ||
2250 | video_unregister_device(dev->radio_dev); | ||
2251 | else | ||
2252 | video_device_release(dev->radio_dev); | ||
2253 | dev->radio_dev = NULL; | ||
2254 | } | ||
2255 | if (dev->vbi_dev) { | ||
2256 | cx231xx_info("V4L2 device %s deregistered\n", | ||
2257 | video_device_node_name(dev->vbi_dev)); | ||
2258 | if (video_is_registered(dev->vbi_dev)) | ||
2259 | video_unregister_device(dev->vbi_dev); | ||
2260 | else | ||
2261 | video_device_release(dev->vbi_dev); | ||
2262 | dev->vbi_dev = NULL; | ||
2263 | } | ||
2264 | if (dev->vdev) { | ||
2265 | cx231xx_info("V4L2 device %s deregistered\n", | ||
2266 | video_device_node_name(dev->vdev)); | ||
2267 | |||
2268 | if (dev->board.has_417) | ||
2269 | cx231xx_417_unregister(dev); | ||
2270 | |||
2271 | if (video_is_registered(dev->vdev)) | ||
2272 | video_unregister_device(dev->vdev); | ||
2273 | else | ||
2274 | video_device_release(dev->vdev); | ||
2275 | dev->vdev = NULL; | ||
2276 | } | ||
2277 | } | ||
2278 | |||
2279 | /* | ||
2280 | * cx231xx_close() | ||
2281 | * stops streaming and deallocates all resources allocated by the v4l2 | ||
2282 | * calls and ioctls | ||
2283 | */ | ||
2284 | static int cx231xx_close(struct file *filp) | ||
2285 | { | ||
2286 | struct cx231xx_fh *fh = filp->private_data; | ||
2287 | struct cx231xx *dev = fh->dev; | ||
2288 | |||
2289 | cx231xx_videodbg("users=%d\n", dev->users); | ||
2290 | |||
2291 | cx231xx_videodbg("users=%d\n", dev->users); | ||
2292 | if (res_check(fh)) | ||
2293 | res_free(fh); | ||
2294 | |||
2295 | /* | ||
2296 | * To workaround error number=-71 on EP0 for VideoGrabber, | ||
2297 | * need exclude following. | ||
2298 | * FIXME: It is probably safe to remove most of these, as we're | ||
2299 | * now avoiding the alternate setting for INDEX_VANC | ||
2300 | */ | ||
2301 | if (!dev->board.no_alt_vanc) | ||
2302 | if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | ||
2303 | videobuf_stop(&fh->vb_vidq); | ||
2304 | videobuf_mmap_free(&fh->vb_vidq); | ||
2305 | |||
2306 | /* the device is already disconnect, | ||
2307 | free the remaining resources */ | ||
2308 | if (dev->state & DEV_DISCONNECTED) { | ||
2309 | if (atomic_read(&dev->devlist_count) > 0) { | ||
2310 | cx231xx_release_resources(dev); | ||
2311 | fh->dev = NULL; | ||
2312 | return 0; | ||
2313 | } | ||
2314 | return 0; | ||
2315 | } | ||
2316 | |||
2317 | /* do this before setting alternate! */ | ||
2318 | cx231xx_uninit_vbi_isoc(dev); | ||
2319 | |||
2320 | /* set alternate 0 */ | ||
2321 | if (!dev->vbi_or_sliced_cc_mode) | ||
2322 | cx231xx_set_alt_setting(dev, INDEX_VANC, 0); | ||
2323 | else | ||
2324 | cx231xx_set_alt_setting(dev, INDEX_HANC, 0); | ||
2325 | |||
2326 | kfree(fh); | ||
2327 | dev->users--; | ||
2328 | wake_up_interruptible_nr(&dev->open, 1); | ||
2329 | return 0; | ||
2330 | } | ||
2331 | |||
2332 | dev->users--; | ||
2333 | if (!dev->users) { | ||
2334 | videobuf_stop(&fh->vb_vidq); | ||
2335 | videobuf_mmap_free(&fh->vb_vidq); | ||
2336 | |||
2337 | /* the device is already disconnect, | ||
2338 | free the remaining resources */ | ||
2339 | if (dev->state & DEV_DISCONNECTED) { | ||
2340 | cx231xx_release_resources(dev); | ||
2341 | fh->dev = NULL; | ||
2342 | return 0; | ||
2343 | } | ||
2344 | |||
2345 | /* Save some power by putting tuner to sleep */ | ||
2346 | call_all(dev, core, s_power, 0); | ||
2347 | |||
2348 | /* do this before setting alternate! */ | ||
2349 | if (dev->USE_ISO) | ||
2350 | cx231xx_uninit_isoc(dev); | ||
2351 | else | ||
2352 | cx231xx_uninit_bulk(dev); | ||
2353 | cx231xx_set_mode(dev, CX231XX_SUSPEND); | ||
2354 | |||
2355 | /* set alternate 0 */ | ||
2356 | cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0); | ||
2357 | } | ||
2358 | kfree(fh); | ||
2359 | wake_up_interruptible_nr(&dev->open, 1); | ||
2360 | return 0; | ||
2361 | } | ||
2362 | |||
2363 | static int cx231xx_v4l2_close(struct file *filp) | ||
2364 | { | ||
2365 | struct cx231xx_fh *fh = filp->private_data; | ||
2366 | struct cx231xx *dev = fh->dev; | ||
2367 | int rc; | ||
2368 | |||
2369 | mutex_lock(&dev->lock); | ||
2370 | rc = cx231xx_close(filp); | ||
2371 | mutex_unlock(&dev->lock); | ||
2372 | return rc; | ||
2373 | } | ||
2374 | |||
2375 | /* | ||
2376 | * cx231xx_v4l2_read() | ||
2377 | * will allocate buffers when called for the first time | ||
2378 | */ | ||
2379 | static ssize_t | ||
2380 | cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count, | ||
2381 | loff_t *pos) | ||
2382 | { | ||
2383 | struct cx231xx_fh *fh = filp->private_data; | ||
2384 | struct cx231xx *dev = fh->dev; | ||
2385 | int rc; | ||
2386 | |||
2387 | rc = check_dev(dev); | ||
2388 | if (rc < 0) | ||
2389 | return rc; | ||
2390 | |||
2391 | if ((fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) || | ||
2392 | (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)) { | ||
2393 | rc = res_get(fh); | ||
2394 | |||
2395 | if (unlikely(rc < 0)) | ||
2396 | return rc; | ||
2397 | |||
2398 | if (mutex_lock_interruptible(&dev->lock)) | ||
2399 | return -ERESTARTSYS; | ||
2400 | rc = videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0, | ||
2401 | filp->f_flags & O_NONBLOCK); | ||
2402 | mutex_unlock(&dev->lock); | ||
2403 | return rc; | ||
2404 | } | ||
2405 | return 0; | ||
2406 | } | ||
2407 | |||
2408 | /* | ||
2409 | * cx231xx_v4l2_poll() | ||
2410 | * will allocate buffers when called for the first time | ||
2411 | */ | ||
2412 | static unsigned int cx231xx_v4l2_poll(struct file *filp, poll_table *wait) | ||
2413 | { | ||
2414 | struct cx231xx_fh *fh = filp->private_data; | ||
2415 | struct cx231xx *dev = fh->dev; | ||
2416 | int rc; | ||
2417 | |||
2418 | rc = check_dev(dev); | ||
2419 | if (rc < 0) | ||
2420 | return rc; | ||
2421 | |||
2422 | rc = res_get(fh); | ||
2423 | |||
2424 | if (unlikely(rc < 0)) | ||
2425 | return POLLERR; | ||
2426 | |||
2427 | if ((V4L2_BUF_TYPE_VIDEO_CAPTURE == fh->type) || | ||
2428 | (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type)) { | ||
2429 | unsigned int res; | ||
2430 | |||
2431 | mutex_lock(&dev->lock); | ||
2432 | res = videobuf_poll_stream(filp, &fh->vb_vidq, wait); | ||
2433 | mutex_unlock(&dev->lock); | ||
2434 | return res; | ||
2435 | } | ||
2436 | return POLLERR; | ||
2437 | } | ||
2438 | |||
2439 | /* | ||
2440 | * cx231xx_v4l2_mmap() | ||
2441 | */ | ||
2442 | static int cx231xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | ||
2443 | { | ||
2444 | struct cx231xx_fh *fh = filp->private_data; | ||
2445 | struct cx231xx *dev = fh->dev; | ||
2446 | int rc; | ||
2447 | |||
2448 | rc = check_dev(dev); | ||
2449 | if (rc < 0) | ||
2450 | return rc; | ||
2451 | |||
2452 | rc = res_get(fh); | ||
2453 | |||
2454 | if (unlikely(rc < 0)) | ||
2455 | return rc; | ||
2456 | |||
2457 | if (mutex_lock_interruptible(&dev->lock)) | ||
2458 | return -ERESTARTSYS; | ||
2459 | rc = videobuf_mmap_mapper(&fh->vb_vidq, vma); | ||
2460 | mutex_unlock(&dev->lock); | ||
2461 | |||
2462 | cx231xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n", | ||
2463 | (unsigned long)vma->vm_start, | ||
2464 | (unsigned long)vma->vm_end - | ||
2465 | (unsigned long)vma->vm_start, rc); | ||
2466 | |||
2467 | return rc; | ||
2468 | } | ||
2469 | |||
2470 | static const struct v4l2_file_operations cx231xx_v4l_fops = { | ||
2471 | .owner = THIS_MODULE, | ||
2472 | .open = cx231xx_v4l2_open, | ||
2473 | .release = cx231xx_v4l2_close, | ||
2474 | .read = cx231xx_v4l2_read, | ||
2475 | .poll = cx231xx_v4l2_poll, | ||
2476 | .mmap = cx231xx_v4l2_mmap, | ||
2477 | .unlocked_ioctl = video_ioctl2, | ||
2478 | }; | ||
2479 | |||
2480 | static const struct v4l2_ioctl_ops video_ioctl_ops = { | ||
2481 | .vidioc_querycap = vidioc_querycap, | ||
2482 | .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap, | ||
2483 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | ||
2484 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | ||
2485 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | ||
2486 | .vidioc_g_fmt_vbi_cap = vidioc_g_fmt_vbi_cap, | ||
2487 | .vidioc_try_fmt_vbi_cap = vidioc_try_fmt_vbi_cap, | ||
2488 | .vidioc_s_fmt_vbi_cap = vidioc_try_fmt_vbi_cap, | ||
2489 | .vidioc_g_audio = vidioc_g_audio, | ||
2490 | .vidioc_s_audio = vidioc_s_audio, | ||
2491 | .vidioc_cropcap = vidioc_cropcap, | ||
2492 | .vidioc_g_fmt_sliced_vbi_cap = vidioc_g_fmt_sliced_vbi_cap, | ||
2493 | .vidioc_try_fmt_sliced_vbi_cap = vidioc_try_set_sliced_vbi_cap, | ||
2494 | .vidioc_reqbufs = vidioc_reqbufs, | ||
2495 | .vidioc_querybuf = vidioc_querybuf, | ||
2496 | .vidioc_qbuf = vidioc_qbuf, | ||
2497 | .vidioc_dqbuf = vidioc_dqbuf, | ||
2498 | .vidioc_s_std = vidioc_s_std, | ||
2499 | .vidioc_g_std = vidioc_g_std, | ||
2500 | .vidioc_enum_input = vidioc_enum_input, | ||
2501 | .vidioc_g_input = vidioc_g_input, | ||
2502 | .vidioc_s_input = vidioc_s_input, | ||
2503 | .vidioc_queryctrl = vidioc_queryctrl, | ||
2504 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
2505 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
2506 | .vidioc_streamon = vidioc_streamon, | ||
2507 | .vidioc_streamoff = vidioc_streamoff, | ||
2508 | .vidioc_g_tuner = vidioc_g_tuner, | ||
2509 | .vidioc_s_tuner = vidioc_s_tuner, | ||
2510 | .vidioc_g_frequency = vidioc_g_frequency, | ||
2511 | .vidioc_s_frequency = vidioc_s_frequency, | ||
2512 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
2513 | .vidioc_g_register = vidioc_g_register, | ||
2514 | .vidioc_s_register = vidioc_s_register, | ||
2515 | #endif | ||
2516 | }; | ||
2517 | |||
2518 | static struct video_device cx231xx_vbi_template; | ||
2519 | |||
2520 | static const struct video_device cx231xx_video_template = { | ||
2521 | .fops = &cx231xx_v4l_fops, | ||
2522 | .release = video_device_release, | ||
2523 | .ioctl_ops = &video_ioctl_ops, | ||
2524 | .tvnorms = V4L2_STD_ALL, | ||
2525 | .current_norm = V4L2_STD_PAL, | ||
2526 | }; | ||
2527 | |||
2528 | static const struct v4l2_file_operations radio_fops = { | ||
2529 | .owner = THIS_MODULE, | ||
2530 | .open = cx231xx_v4l2_open, | ||
2531 | .release = cx231xx_v4l2_close, | ||
2532 | .ioctl = video_ioctl2, | ||
2533 | }; | ||
2534 | |||
2535 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | ||
2536 | .vidioc_querycap = radio_querycap, | ||
2537 | .vidioc_g_tuner = radio_g_tuner, | ||
2538 | .vidioc_enum_input = radio_enum_input, | ||
2539 | .vidioc_g_audio = radio_g_audio, | ||
2540 | .vidioc_s_tuner = radio_s_tuner, | ||
2541 | .vidioc_s_audio = radio_s_audio, | ||
2542 | .vidioc_s_input = radio_s_input, | ||
2543 | .vidioc_queryctrl = radio_queryctrl, | ||
2544 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
2545 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
2546 | .vidioc_g_frequency = vidioc_g_frequency, | ||
2547 | .vidioc_s_frequency = vidioc_s_frequency, | ||
2548 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
2549 | .vidioc_g_register = vidioc_g_register, | ||
2550 | .vidioc_s_register = vidioc_s_register, | ||
2551 | #endif | ||
2552 | }; | ||
2553 | |||
2554 | static struct video_device cx231xx_radio_template = { | ||
2555 | .name = "cx231xx-radio", | ||
2556 | .fops = &radio_fops, | ||
2557 | .ioctl_ops = &radio_ioctl_ops, | ||
2558 | }; | ||
2559 | |||
2560 | /******************************** usb interface ******************************/ | ||
2561 | |||
2562 | static struct video_device *cx231xx_vdev_init(struct cx231xx *dev, | ||
2563 | const struct video_device | ||
2564 | *template, const char *type_name) | ||
2565 | { | ||
2566 | struct video_device *vfd; | ||
2567 | |||
2568 | vfd = video_device_alloc(); | ||
2569 | if (NULL == vfd) | ||
2570 | return NULL; | ||
2571 | |||
2572 | *vfd = *template; | ||
2573 | vfd->v4l2_dev = &dev->v4l2_dev; | ||
2574 | vfd->release = video_device_release; | ||
2575 | vfd->debug = video_debug; | ||
2576 | vfd->lock = &dev->lock; | ||
2577 | |||
2578 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); | ||
2579 | |||
2580 | video_set_drvdata(vfd, dev); | ||
2581 | return vfd; | ||
2582 | } | ||
2583 | |||
2584 | int cx231xx_register_analog_devices(struct cx231xx *dev) | ||
2585 | { | ||
2586 | int ret; | ||
2587 | |||
2588 | cx231xx_info("%s: v4l2 driver version %s\n", | ||
2589 | dev->name, CX231XX_VERSION); | ||
2590 | |||
2591 | /* set default norm */ | ||
2592 | /*dev->norm = cx231xx_video_template.current_norm; */ | ||
2593 | dev->width = norm_maxw(dev); | ||
2594 | dev->height = norm_maxh(dev); | ||
2595 | dev->interlaced = 0; | ||
2596 | |||
2597 | /* Analog specific initialization */ | ||
2598 | dev->format = &format[0]; | ||
2599 | |||
2600 | /* Set the initial input */ | ||
2601 | video_mux(dev, dev->video_input); | ||
2602 | |||
2603 | /* Audio defaults */ | ||
2604 | dev->mute = 1; | ||
2605 | dev->volume = 0x1f; | ||
2606 | |||
2607 | /* enable vbi capturing */ | ||
2608 | /* write code here... */ | ||
2609 | |||
2610 | /* allocate and fill video video_device struct */ | ||
2611 | dev->vdev = cx231xx_vdev_init(dev, &cx231xx_video_template, "video"); | ||
2612 | if (!dev->vdev) { | ||
2613 | cx231xx_errdev("cannot allocate video_device.\n"); | ||
2614 | return -ENODEV; | ||
2615 | } | ||
2616 | |||
2617 | /* register v4l2 video video_device */ | ||
2618 | ret = video_register_device(dev->vdev, VFL_TYPE_GRABBER, | ||
2619 | video_nr[dev->devno]); | ||
2620 | if (ret) { | ||
2621 | cx231xx_errdev("unable to register video device (error=%i).\n", | ||
2622 | ret); | ||
2623 | return ret; | ||
2624 | } | ||
2625 | |||
2626 | cx231xx_info("%s/0: registered device %s [v4l2]\n", | ||
2627 | dev->name, video_device_node_name(dev->vdev)); | ||
2628 | |||
2629 | /* Initialize VBI template */ | ||
2630 | memcpy(&cx231xx_vbi_template, &cx231xx_video_template, | ||
2631 | sizeof(cx231xx_vbi_template)); | ||
2632 | strcpy(cx231xx_vbi_template.name, "cx231xx-vbi"); | ||
2633 | |||
2634 | /* Allocate and fill vbi video_device struct */ | ||
2635 | dev->vbi_dev = cx231xx_vdev_init(dev, &cx231xx_vbi_template, "vbi"); | ||
2636 | |||
2637 | /* register v4l2 vbi video_device */ | ||
2638 | ret = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, | ||
2639 | vbi_nr[dev->devno]); | ||
2640 | if (ret < 0) { | ||
2641 | cx231xx_errdev("unable to register vbi device\n"); | ||
2642 | return ret; | ||
2643 | } | ||
2644 | |||
2645 | cx231xx_info("%s/0: registered device %s\n", | ||
2646 | dev->name, video_device_node_name(dev->vbi_dev)); | ||
2647 | |||
2648 | if (cx231xx_boards[dev->model].radio.type == CX231XX_RADIO) { | ||
2649 | dev->radio_dev = cx231xx_vdev_init(dev, &cx231xx_radio_template, | ||
2650 | "radio"); | ||
2651 | if (!dev->radio_dev) { | ||
2652 | cx231xx_errdev("cannot allocate video_device.\n"); | ||
2653 | return -ENODEV; | ||
2654 | } | ||
2655 | ret = video_register_device(dev->radio_dev, VFL_TYPE_RADIO, | ||
2656 | radio_nr[dev->devno]); | ||
2657 | if (ret < 0) { | ||
2658 | cx231xx_errdev("can't register radio device\n"); | ||
2659 | return ret; | ||
2660 | } | ||
2661 | cx231xx_info("Registered radio device as %s\n", | ||
2662 | video_device_node_name(dev->radio_dev)); | ||
2663 | } | ||
2664 | |||
2665 | cx231xx_info("V4L2 device registered as %s and %s\n", | ||
2666 | video_device_node_name(dev->vdev), | ||
2667 | video_device_node_name(dev->vbi_dev)); | ||
2668 | |||
2669 | return 0; | ||
2670 | } | ||
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h new file mode 100644 index 000000000000..a89d020de948 --- /dev/null +++ b/drivers/media/usb/cx231xx/cx231xx.h | |||
@@ -0,0 +1,1012 @@ | |||
1 | /* | ||
2 | cx231xx.h - driver for Conexant Cx23100/101/102 USB video capture devices | ||
3 | |||
4 | Copyright (C) 2008 <srinivasa.deevi at conexant dot com> | ||
5 | Based on em28xx driver | ||
6 | |||
7 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | ||
11 | |||
12 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program; if not, write to the Free Software | ||
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | |||
22 | #ifndef _CX231XX_H | ||
23 | #define _CX231XX_H | ||
24 | |||
25 | #include <linux/videodev2.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/ioctl.h> | ||
28 | #include <linux/i2c.h> | ||
29 | #include <linux/workqueue.h> | ||
30 | #include <linux/mutex.h> | ||
31 | |||
32 | #include <media/cx2341x.h> | ||
33 | |||
34 | #include <media/videobuf-vmalloc.h> | ||
35 | #include <media/v4l2-device.h> | ||
36 | #include <media/rc-core.h> | ||
37 | #include <media/ir-kbd-i2c.h> | ||
38 | #include <media/videobuf-dvb.h> | ||
39 | |||
40 | #include "cx231xx-reg.h" | ||
41 | #include "cx231xx-pcb-cfg.h" | ||
42 | #include "cx231xx-conf-reg.h" | ||
43 | |||
44 | #define DRIVER_NAME "cx231xx" | ||
45 | #define PWR_SLEEP_INTERVAL 10 | ||
46 | |||
47 | /* I2C addresses for control block in Cx231xx */ | ||
48 | #define AFE_DEVICE_ADDRESS 0x60 | ||
49 | #define I2S_BLK_DEVICE_ADDRESS 0x98 | ||
50 | #define VID_BLK_I2C_ADDRESS 0x88 | ||
51 | #define VERVE_I2C_ADDRESS 0x40 | ||
52 | #define DIF_USE_BASEBAND 0xFFFFFFFF | ||
53 | |||
54 | /* Boards supported by driver */ | ||
55 | #define CX231XX_BOARD_UNKNOWN 0 | ||
56 | #define CX231XX_BOARD_CNXT_CARRAERA 1 | ||
57 | #define CX231XX_BOARD_CNXT_SHELBY 2 | ||
58 | #define CX231XX_BOARD_CNXT_RDE_253S 3 | ||
59 | #define CX231XX_BOARD_CNXT_RDU_253S 4 | ||
60 | #define CX231XX_BOARD_CNXT_VIDEO_GRABBER 5 | ||
61 | #define CX231XX_BOARD_CNXT_RDE_250 6 | ||
62 | #define CX231XX_BOARD_CNXT_RDU_250 7 | ||
63 | #define CX231XX_BOARD_HAUPPAUGE_EXETER 8 | ||
64 | #define CX231XX_BOARD_HAUPPAUGE_USBLIVE2 9 | ||
65 | #define CX231XX_BOARD_PV_PLAYTV_USB_HYBRID 10 | ||
66 | #define CX231XX_BOARD_PV_XCAPTURE_USB 11 | ||
67 | #define CX231XX_BOARD_KWORLD_UB430_USB_HYBRID 12 | ||
68 | #define CX231XX_BOARD_ICONBIT_U100 13 | ||
69 | #define CX231XX_BOARD_HAUPPAUGE_USB2_FM_PAL 14 | ||
70 | #define CX231XX_BOARD_HAUPPAUGE_USB2_FM_NTSC 15 | ||
71 | |||
72 | /* Limits minimum and default number of buffers */ | ||
73 | #define CX231XX_MIN_BUF 4 | ||
74 | #define CX231XX_DEF_BUF 12 | ||
75 | #define CX231XX_DEF_VBI_BUF 6 | ||
76 | |||
77 | #define VBI_LINE_COUNT 17 | ||
78 | #define VBI_LINE_LENGTH 1440 | ||
79 | |||
80 | /*Limits the max URB message size */ | ||
81 | #define URB_MAX_CTRL_SIZE 80 | ||
82 | |||
83 | /* Params for validated field */ | ||
84 | #define CX231XX_BOARD_NOT_VALIDATED 1 | ||
85 | #define CX231XX_BOARD_VALIDATED 0 | ||
86 | |||
87 | /* maximum number of cx231xx boards */ | ||
88 | #define CX231XX_MAXBOARDS 8 | ||
89 | |||
90 | /* maximum number of frames that can be queued */ | ||
91 | #define CX231XX_NUM_FRAMES 5 | ||
92 | |||
93 | /* number of buffers for isoc transfers */ | ||
94 | #define CX231XX_NUM_BUFS 8 | ||
95 | |||
96 | /* number of packets for each buffer | ||
97 | windows requests only 40 packets .. so we better do the same | ||
98 | this is what I found out for all alternate numbers there! | ||
99 | */ | ||
100 | #define CX231XX_NUM_PACKETS 40 | ||
101 | |||
102 | /* default alternate; 0 means choose the best */ | ||
103 | #define CX231XX_PINOUT 0 | ||
104 | |||
105 | #define CX231XX_INTERLACED_DEFAULT 1 | ||
106 | |||
107 | /* time to wait when stopping the isoc transfer */ | ||
108 | #define CX231XX_URB_TIMEOUT \ | ||
109 | msecs_to_jiffies(CX231XX_NUM_BUFS * CX231XX_NUM_PACKETS) | ||
110 | |||
111 | #define CX231xx_NORMS (\ | ||
112 | V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443 | \ | ||
113 | V4L2_STD_PAL_BG | V4L2_STD_PAL_DK | V4L2_STD_PAL_I | \ | ||
114 | V4L2_STD_PAL_M | V4L2_STD_PAL_N | V4L2_STD_PAL_Nc | \ | ||
115 | V4L2_STD_PAL_60 | V4L2_STD_SECAM_L | V4L2_STD_SECAM_DK) | ||
116 | |||
117 | #define SLEEP_S5H1432 30 | ||
118 | #define CX23417_OSC_EN 8 | ||
119 | #define CX23417_RESET 9 | ||
120 | |||
121 | struct cx23417_fmt { | ||
122 | char *name; | ||
123 | u32 fourcc; /* v4l2 format id */ | ||
124 | int depth; | ||
125 | int flags; | ||
126 | u32 cxformat; | ||
127 | }; | ||
128 | enum cx231xx_mode { | ||
129 | CX231XX_SUSPEND, | ||
130 | CX231XX_ANALOG_MODE, | ||
131 | CX231XX_DIGITAL_MODE, | ||
132 | }; | ||
133 | |||
134 | enum cx231xx_std_mode { | ||
135 | CX231XX_TV_AIR = 0, | ||
136 | CX231XX_TV_CABLE | ||
137 | }; | ||
138 | |||
139 | enum cx231xx_stream_state { | ||
140 | STREAM_OFF, | ||
141 | STREAM_INTERRUPT, | ||
142 | STREAM_ON, | ||
143 | }; | ||
144 | |||
145 | struct cx231xx; | ||
146 | |||
147 | struct cx231xx_isoc_ctl { | ||
148 | /* max packet size of isoc transaction */ | ||
149 | int max_pkt_size; | ||
150 | |||
151 | /* number of allocated urbs */ | ||
152 | int num_bufs; | ||
153 | |||
154 | /* urb for isoc transfers */ | ||
155 | struct urb **urb; | ||
156 | |||
157 | /* transfer buffers for isoc transfer */ | ||
158 | char **transfer_buffer; | ||
159 | |||
160 | /* Last buffer command and region */ | ||
161 | u8 cmd; | ||
162 | int pos, size, pktsize; | ||
163 | |||
164 | /* Last field: ODD or EVEN? */ | ||
165 | int field; | ||
166 | |||
167 | /* Stores incomplete commands */ | ||
168 | u32 tmp_buf; | ||
169 | int tmp_buf_len; | ||
170 | |||
171 | /* Stores already requested buffers */ | ||
172 | struct cx231xx_buffer *buf; | ||
173 | |||
174 | /* Stores the number of received fields */ | ||
175 | int nfields; | ||
176 | |||
177 | /* isoc urb callback */ | ||
178 | int (*isoc_copy) (struct cx231xx *dev, struct urb *urb); | ||
179 | }; | ||
180 | |||
181 | struct cx231xx_bulk_ctl { | ||
182 | /* max packet size of bulk transaction */ | ||
183 | int max_pkt_size; | ||
184 | |||
185 | /* number of allocated urbs */ | ||
186 | int num_bufs; | ||
187 | |||
188 | /* urb for bulk transfers */ | ||
189 | struct urb **urb; | ||
190 | |||
191 | /* transfer buffers for bulk transfer */ | ||
192 | char **transfer_buffer; | ||
193 | |||
194 | /* Last buffer command and region */ | ||
195 | u8 cmd; | ||
196 | int pos, size, pktsize; | ||
197 | |||
198 | /* Last field: ODD or EVEN? */ | ||
199 | int field; | ||
200 | |||
201 | /* Stores incomplete commands */ | ||
202 | u32 tmp_buf; | ||
203 | int tmp_buf_len; | ||
204 | |||
205 | /* Stores already requested buffers */ | ||
206 | struct cx231xx_buffer *buf; | ||
207 | |||
208 | /* Stores the number of received fields */ | ||
209 | int nfields; | ||
210 | |||
211 | /* bulk urb callback */ | ||
212 | int (*bulk_copy) (struct cx231xx *dev, struct urb *urb); | ||
213 | }; | ||
214 | |||
215 | struct cx231xx_fmt { | ||
216 | char *name; | ||
217 | u32 fourcc; /* v4l2 format id */ | ||
218 | int depth; | ||
219 | int reg; | ||
220 | }; | ||
221 | |||
222 | /* buffer for one video frame */ | ||
223 | struct cx231xx_buffer { | ||
224 | /* common v4l buffer stuff -- must be first */ | ||
225 | struct videobuf_buffer vb; | ||
226 | |||
227 | struct list_head frame; | ||
228 | int top_field; | ||
229 | int receiving; | ||
230 | }; | ||
231 | |||
232 | enum ps_package_head { | ||
233 | CX231XX_NEED_ADD_PS_PACKAGE_HEAD = 0, | ||
234 | CX231XX_NONEED_PS_PACKAGE_HEAD | ||
235 | }; | ||
236 | |||
237 | struct cx231xx_dmaqueue { | ||
238 | struct list_head active; | ||
239 | struct list_head queued; | ||
240 | |||
241 | wait_queue_head_t wq; | ||
242 | |||
243 | /* Counters to control buffer fill */ | ||
244 | int pos; | ||
245 | u8 is_partial_line; | ||
246 | u8 partial_buf[8]; | ||
247 | u8 last_sav; | ||
248 | int current_field; | ||
249 | u32 bytes_left_in_line; | ||
250 | u32 lines_completed; | ||
251 | u8 field1_done; | ||
252 | u32 lines_per_field; | ||
253 | |||
254 | /*Mpeg2 control buffer*/ | ||
255 | u8 *p_left_data; | ||
256 | u32 left_data_count; | ||
257 | u8 mpeg_buffer_done; | ||
258 | u32 mpeg_buffer_completed; | ||
259 | enum ps_package_head add_ps_package_head; | ||
260 | char ps_head[10]; | ||
261 | }; | ||
262 | |||
263 | /* inputs */ | ||
264 | |||
265 | #define MAX_CX231XX_INPUT 4 | ||
266 | |||
267 | enum cx231xx_itype { | ||
268 | CX231XX_VMUX_COMPOSITE1 = 1, | ||
269 | CX231XX_VMUX_SVIDEO, | ||
270 | CX231XX_VMUX_TELEVISION, | ||
271 | CX231XX_VMUX_CABLE, | ||
272 | CX231XX_RADIO, | ||
273 | CX231XX_VMUX_DVB, | ||
274 | CX231XX_VMUX_DEBUG | ||
275 | }; | ||
276 | |||
277 | enum cx231xx_v_input { | ||
278 | CX231XX_VIN_1_1 = 0x1, | ||
279 | CX231XX_VIN_2_1, | ||
280 | CX231XX_VIN_3_1, | ||
281 | CX231XX_VIN_4_1, | ||
282 | CX231XX_VIN_1_2 = 0x01, | ||
283 | CX231XX_VIN_2_2, | ||
284 | CX231XX_VIN_3_2, | ||
285 | CX231XX_VIN_1_3 = 0x1, | ||
286 | CX231XX_VIN_2_3, | ||
287 | CX231XX_VIN_3_3, | ||
288 | }; | ||
289 | |||
290 | /* cx231xx has two audio inputs: tuner and line in */ | ||
291 | enum cx231xx_amux { | ||
292 | /* This is the only entry for cx231xx tuner input */ | ||
293 | CX231XX_AMUX_VIDEO, /* cx231xx tuner */ | ||
294 | CX231XX_AMUX_LINE_IN, /* Line In */ | ||
295 | }; | ||
296 | |||
297 | struct cx231xx_reg_seq { | ||
298 | unsigned char bit; | ||
299 | unsigned char val; | ||
300 | int sleep; | ||
301 | }; | ||
302 | |||
303 | struct cx231xx_input { | ||
304 | enum cx231xx_itype type; | ||
305 | unsigned int vmux; | ||
306 | enum cx231xx_amux amux; | ||
307 | struct cx231xx_reg_seq *gpio; | ||
308 | }; | ||
309 | |||
310 | #define INPUT(nr) (&cx231xx_boards[dev->model].input[nr]) | ||
311 | |||
312 | enum cx231xx_decoder { | ||
313 | CX231XX_NODECODER, | ||
314 | CX231XX_AVDECODER | ||
315 | }; | ||
316 | |||
317 | enum CX231XX_I2C_MASTER_PORT { | ||
318 | I2C_0 = 0, | ||
319 | I2C_1 = 1, | ||
320 | I2C_2 = 2, | ||
321 | I2C_3 = 3 | ||
322 | }; | ||
323 | |||
324 | struct cx231xx_board { | ||
325 | char *name; | ||
326 | int vchannels; | ||
327 | int tuner_type; | ||
328 | int tuner_addr; | ||
329 | v4l2_std_id norm; /* tv norm */ | ||
330 | |||
331 | /* demod related */ | ||
332 | int demod_addr; | ||
333 | u8 demod_xfer_mode; /* 0 - Serial; 1 - parallel */ | ||
334 | |||
335 | /* GPIO Pins */ | ||
336 | struct cx231xx_reg_seq *dvb_gpio; | ||
337 | struct cx231xx_reg_seq *suspend_gpio; | ||
338 | struct cx231xx_reg_seq *tuner_gpio; | ||
339 | /* Negative means don't use it */ | ||
340 | s8 tuner_sif_gpio; | ||
341 | s8 tuner_scl_gpio; | ||
342 | s8 tuner_sda_gpio; | ||
343 | |||
344 | /* PIN ctrl */ | ||
345 | u32 ctl_pin_status_mask; | ||
346 | u8 agc_analog_digital_select_gpio; | ||
347 | u32 gpio_pin_status_mask; | ||
348 | |||
349 | /* i2c masters */ | ||
350 | u8 tuner_i2c_master; | ||
351 | u8 demod_i2c_master; | ||
352 | u8 ir_i2c_master; | ||
353 | |||
354 | /* for devices with I2C chips for IR */ | ||
355 | char *rc_map_name; | ||
356 | |||
357 | unsigned int max_range_640_480:1; | ||
358 | unsigned int has_dvb:1; | ||
359 | unsigned int has_417:1; | ||
360 | unsigned int valid:1; | ||
361 | unsigned int no_alt_vanc:1; | ||
362 | unsigned int external_av:1; | ||
363 | unsigned int dont_use_port_3:1; | ||
364 | |||
365 | unsigned char xclk, i2c_speed; | ||
366 | |||
367 | enum cx231xx_decoder decoder; | ||
368 | int output_mode; | ||
369 | |||
370 | struct cx231xx_input input[MAX_CX231XX_INPUT]; | ||
371 | struct cx231xx_input radio; | ||
372 | struct rc_map *ir_codes; | ||
373 | }; | ||
374 | |||
375 | /* device states */ | ||
376 | enum cx231xx_dev_state { | ||
377 | DEV_INITIALIZED = 0x01, | ||
378 | DEV_DISCONNECTED = 0x02, | ||
379 | }; | ||
380 | |||
381 | enum AFE_MODE { | ||
382 | AFE_MODE_LOW_IF, | ||
383 | AFE_MODE_BASEBAND, | ||
384 | AFE_MODE_EU_HI_IF, | ||
385 | AFE_MODE_US_HI_IF, | ||
386 | AFE_MODE_JAPAN_HI_IF | ||
387 | }; | ||
388 | |||
389 | enum AUDIO_INPUT { | ||
390 | AUDIO_INPUT_MUTE, | ||
391 | AUDIO_INPUT_LINE, | ||
392 | AUDIO_INPUT_TUNER_TV, | ||
393 | AUDIO_INPUT_SPDIF, | ||
394 | AUDIO_INPUT_TUNER_FM | ||
395 | }; | ||
396 | |||
397 | #define CX231XX_AUDIO_BUFS 5 | ||
398 | #define CX231XX_NUM_AUDIO_PACKETS 16 | ||
399 | #define CX231XX_ISO_NUM_AUDIO_PACKETS 64 | ||
400 | |||
401 | /* cx231xx extensions */ | ||
402 | #define CX231XX_AUDIO 0x10 | ||
403 | #define CX231XX_DVB 0x20 | ||
404 | |||
405 | struct cx231xx_audio { | ||
406 | char name[50]; | ||
407 | char *transfer_buffer[CX231XX_AUDIO_BUFS]; | ||
408 | struct urb *urb[CX231XX_AUDIO_BUFS]; | ||
409 | struct usb_device *udev; | ||
410 | unsigned int capture_transfer_done; | ||
411 | struct snd_pcm_substream *capture_pcm_substream; | ||
412 | |||
413 | unsigned int hwptr_done_capture; | ||
414 | struct snd_card *sndcard; | ||
415 | |||
416 | int users, shutdown; | ||
417 | /* locks */ | ||
418 | spinlock_t slock; | ||
419 | |||
420 | int alt; /* alternate */ | ||
421 | int max_pkt_size; /* max packet size of isoc transaction */ | ||
422 | int num_alt; /* Number of alternative settings */ | ||
423 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ | ||
424 | u16 end_point_addr; | ||
425 | }; | ||
426 | |||
427 | struct cx231xx; | ||
428 | |||
429 | struct cx231xx_fh { | ||
430 | struct cx231xx *dev; | ||
431 | unsigned int stream_on:1; /* Locks streams */ | ||
432 | int radio; | ||
433 | |||
434 | struct videobuf_queue vb_vidq; | ||
435 | |||
436 | enum v4l2_buf_type type; | ||
437 | |||
438 | |||
439 | |||
440 | /*following is copyed from cx23885.h*/ | ||
441 | u32 resources; | ||
442 | |||
443 | /* video overlay */ | ||
444 | struct v4l2_window win; | ||
445 | struct v4l2_clip *clips; | ||
446 | unsigned int nclips; | ||
447 | |||
448 | /* video capture */ | ||
449 | struct cx23417_fmt *fmt; | ||
450 | unsigned int width, height; | ||
451 | |||
452 | /* vbi capture */ | ||
453 | struct videobuf_queue vidq; | ||
454 | struct videobuf_queue vbiq; | ||
455 | |||
456 | /* MPEG Encoder specifics ONLY */ | ||
457 | |||
458 | atomic_t v4l_reading; | ||
459 | }; | ||
460 | |||
461 | /*****************************************************************/ | ||
462 | /* set/get i2c */ | ||
463 | /* 00--1Mb/s, 01-400kb/s, 10--100kb/s, 11--5Mb/s */ | ||
464 | #define I2C_SPEED_1M 0x0 | ||
465 | #define I2C_SPEED_400K 0x1 | ||
466 | #define I2C_SPEED_100K 0x2 | ||
467 | #define I2C_SPEED_5M 0x3 | ||
468 | |||
469 | /* 0-- STOP transaction */ | ||
470 | #define I2C_STOP 0x0 | ||
471 | /* 1-- do not transmit STOP at end of transaction */ | ||
472 | #define I2C_NOSTOP 0x1 | ||
473 | /* 1--allow slave to insert clock wait states */ | ||
474 | #define I2C_SYNC 0x1 | ||
475 | |||
476 | struct cx231xx_i2c { | ||
477 | struct cx231xx *dev; | ||
478 | |||
479 | int nr; | ||
480 | |||
481 | /* i2c i/o */ | ||
482 | struct i2c_adapter i2c_adap; | ||
483 | struct i2c_client i2c_client; | ||
484 | u32 i2c_rc; | ||
485 | |||
486 | /* different settings for each bus */ | ||
487 | u8 i2c_period; | ||
488 | u8 i2c_nostop; | ||
489 | u8 i2c_reserve; | ||
490 | }; | ||
491 | |||
492 | struct cx231xx_i2c_xfer_data { | ||
493 | u8 dev_addr; | ||
494 | u8 direction; /* 1 - IN, 0 - OUT */ | ||
495 | u8 saddr_len; /* sub address len */ | ||
496 | u16 saddr_dat; /* sub addr data */ | ||
497 | u8 buf_size; /* buffer size */ | ||
498 | u8 *p_buffer; /* pointer to the buffer */ | ||
499 | }; | ||
500 | |||
501 | struct VENDOR_REQUEST_IN { | ||
502 | u8 bRequest; | ||
503 | u16 wValue; | ||
504 | u16 wIndex; | ||
505 | u16 wLength; | ||
506 | u8 direction; | ||
507 | u8 bData; | ||
508 | u8 *pBuff; | ||
509 | }; | ||
510 | |||
511 | struct cx231xx_tvnorm { | ||
512 | char *name; | ||
513 | v4l2_std_id id; | ||
514 | u32 cxiformat; | ||
515 | u32 cxoformat; | ||
516 | }; | ||
517 | |||
518 | struct cx231xx_ctrl { | ||
519 | struct v4l2_queryctrl v; | ||
520 | u32 off; | ||
521 | u32 reg; | ||
522 | u32 mask; | ||
523 | u32 shift; | ||
524 | }; | ||
525 | |||
526 | enum TRANSFER_TYPE { | ||
527 | Raw_Video = 0, | ||
528 | Audio, | ||
529 | Vbi, /* VANC */ | ||
530 | Sliced_cc, /* HANC */ | ||
531 | TS1_serial_mode, | ||
532 | TS2, | ||
533 | TS1_parallel_mode | ||
534 | } ; | ||
535 | |||
536 | struct cx231xx_video_mode { | ||
537 | /* Isoc control struct */ | ||
538 | struct cx231xx_dmaqueue vidq; | ||
539 | struct cx231xx_isoc_ctl isoc_ctl; | ||
540 | struct cx231xx_bulk_ctl bulk_ctl; | ||
541 | /* locks */ | ||
542 | spinlock_t slock; | ||
543 | |||
544 | /* usb transfer */ | ||
545 | int alt; /* alternate */ | ||
546 | int max_pkt_size; /* max packet size of isoc transaction */ | ||
547 | int num_alt; /* Number of alternative settings */ | ||
548 | unsigned int *alt_max_pkt_size; /* array of wMaxPacketSize */ | ||
549 | u16 end_point_addr; | ||
550 | }; | ||
551 | /* | ||
552 | struct cx23885_dmaqueue { | ||
553 | struct list_head active; | ||
554 | struct list_head queued; | ||
555 | struct timer_list timeout; | ||
556 | struct btcx_riscmem stopper; | ||
557 | u32 count; | ||
558 | }; | ||
559 | */ | ||
560 | struct cx231xx_tsport { | ||
561 | struct cx231xx *dev; | ||
562 | |||
563 | int nr; | ||
564 | int sram_chno; | ||
565 | |||
566 | struct videobuf_dvb_frontends frontends; | ||
567 | |||
568 | /* dma queues */ | ||
569 | |||
570 | u32 ts_packet_size; | ||
571 | u32 ts_packet_count; | ||
572 | |||
573 | int width; | ||
574 | int height; | ||
575 | |||
576 | /* locks */ | ||
577 | spinlock_t slock; | ||
578 | |||
579 | /* registers */ | ||
580 | u32 reg_gpcnt; | ||
581 | u32 reg_gpcnt_ctl; | ||
582 | u32 reg_dma_ctl; | ||
583 | u32 reg_lngth; | ||
584 | u32 reg_hw_sop_ctrl; | ||
585 | u32 reg_gen_ctrl; | ||
586 | u32 reg_bd_pkt_status; | ||
587 | u32 reg_sop_status; | ||
588 | u32 reg_fifo_ovfl_stat; | ||
589 | u32 reg_vld_misc; | ||
590 | u32 reg_ts_clk_en; | ||
591 | u32 reg_ts_int_msk; | ||
592 | u32 reg_ts_int_stat; | ||
593 | u32 reg_src_sel; | ||
594 | |||
595 | /* Default register vals */ | ||
596 | int pci_irqmask; | ||
597 | u32 dma_ctl_val; | ||
598 | u32 ts_int_msk_val; | ||
599 | u32 gen_ctrl_val; | ||
600 | u32 ts_clk_en_val; | ||
601 | u32 src_sel_val; | ||
602 | u32 vld_misc_val; | ||
603 | u32 hw_sop_ctrl_val; | ||
604 | |||
605 | /* Allow a single tsport to have multiple frontends */ | ||
606 | u32 num_frontends; | ||
607 | void *port_priv; | ||
608 | }; | ||
609 | |||
610 | /* main device struct */ | ||
611 | struct cx231xx { | ||
612 | /* generic device properties */ | ||
613 | char name[30]; /* name (including minor) of the device */ | ||
614 | int model; /* index in the device_data struct */ | ||
615 | int devno; /* marks the number of this device */ | ||
616 | |||
617 | struct cx231xx_board board; | ||
618 | |||
619 | /* For I2C IR support */ | ||
620 | struct IR_i2c_init_data init_data; | ||
621 | struct i2c_client *ir_i2c_client; | ||
622 | |||
623 | unsigned int stream_on:1; /* Locks streams */ | ||
624 | unsigned int vbi_stream_on:1; /* Locks streams for VBI */ | ||
625 | unsigned int has_audio_class:1; | ||
626 | unsigned int has_alsa_audio:1; | ||
627 | |||
628 | struct cx231xx_fmt *format; | ||
629 | |||
630 | struct v4l2_device v4l2_dev; | ||
631 | struct v4l2_subdev *sd_cx25840; | ||
632 | struct v4l2_subdev *sd_tuner; | ||
633 | |||
634 | struct work_struct wq_trigger; /* Trigger to start/stop audio for alsa module */ | ||
635 | atomic_t stream_started; /* stream should be running if true */ | ||
636 | |||
637 | struct list_head devlist; | ||
638 | |||
639 | int tuner_type; /* type of the tuner */ | ||
640 | int tuner_addr; /* tuner address */ | ||
641 | |||
642 | /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */ | ||
643 | struct cx231xx_i2c i2c_bus[3]; | ||
644 | unsigned int xc_fw_load_done:1; | ||
645 | /* locks */ | ||
646 | struct mutex gpio_i2c_lock; | ||
647 | struct mutex i2c_lock; | ||
648 | |||
649 | /* video for linux */ | ||
650 | int users; /* user count for exclusive use */ | ||
651 | struct video_device *vdev; /* video for linux device struct */ | ||
652 | v4l2_std_id norm; /* selected tv norm */ | ||
653 | int ctl_freq; /* selected frequency */ | ||
654 | unsigned int ctl_ainput; /* selected audio input */ | ||
655 | int mute; | ||
656 | int volume; | ||
657 | |||
658 | /* frame properties */ | ||
659 | int width; /* current frame width */ | ||
660 | int height; /* current frame height */ | ||
661 | int interlaced; /* 1=interlace fileds, 0=just top fileds */ | ||
662 | |||
663 | struct cx231xx_audio adev; | ||
664 | |||
665 | /* states */ | ||
666 | enum cx231xx_dev_state state; | ||
667 | |||
668 | struct work_struct request_module_wk; | ||
669 | |||
670 | /* locks */ | ||
671 | struct mutex lock; | ||
672 | struct mutex ctrl_urb_lock; /* protects urb_buf */ | ||
673 | struct list_head inqueue, outqueue; | ||
674 | wait_queue_head_t open, wait_frame, wait_stream; | ||
675 | struct video_device *vbi_dev; | ||
676 | struct video_device *radio_dev; | ||
677 | |||
678 | unsigned char eedata[256]; | ||
679 | |||
680 | struct cx231xx_video_mode video_mode; | ||
681 | struct cx231xx_video_mode vbi_mode; | ||
682 | struct cx231xx_video_mode sliced_cc_mode; | ||
683 | struct cx231xx_video_mode ts1_mode; | ||
684 | |||
685 | atomic_t devlist_count; | ||
686 | |||
687 | struct usb_device *udev; /* the usb device */ | ||
688 | char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ | ||
689 | |||
690 | /* helper funcs that call usb_control_msg */ | ||
691 | int (*cx231xx_read_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg, | ||
692 | char *buf, int len); | ||
693 | int (*cx231xx_write_ctrl_reg) (struct cx231xx *dev, u8 req, u16 reg, | ||
694 | char *buf, int len); | ||
695 | int (*cx231xx_send_usb_command) (struct cx231xx_i2c *i2c_bus, | ||
696 | struct cx231xx_i2c_xfer_data *req_data); | ||
697 | int (*cx231xx_gpio_i2c_read) (struct cx231xx *dev, u8 dev_addr, | ||
698 | u8 *buf, u8 len); | ||
699 | int (*cx231xx_gpio_i2c_write) (struct cx231xx *dev, u8 dev_addr, | ||
700 | u8 *buf, u8 len); | ||
701 | |||
702 | int (*cx231xx_set_analog_freq) (struct cx231xx *dev, u32 freq); | ||
703 | int (*cx231xx_reset_analog_tuner) (struct cx231xx *dev); | ||
704 | |||
705 | enum cx231xx_mode mode; | ||
706 | |||
707 | struct cx231xx_dvb *dvb; | ||
708 | |||
709 | /* Cx231xx supported PCB config's */ | ||
710 | struct pcb_config current_pcb_config; | ||
711 | u8 current_scenario_idx; | ||
712 | u8 interface_count; | ||
713 | u8 max_iad_interface_count; | ||
714 | |||
715 | /* GPIO related register direction and values */ | ||
716 | u32 gpio_dir; | ||
717 | u32 gpio_val; | ||
718 | |||
719 | /* Power Modes */ | ||
720 | int power_mode; | ||
721 | |||
722 | /* afe parameters */ | ||
723 | enum AFE_MODE afe_mode; | ||
724 | u32 afe_ref_count; | ||
725 | |||
726 | /* video related parameters */ | ||
727 | u32 video_input; | ||
728 | u32 active_mode; | ||
729 | u8 vbi_or_sliced_cc_mode; /* 0 - vbi ; 1 - sliced cc mode */ | ||
730 | enum cx231xx_std_mode std_mode; /* 0 - Air; 1 - cable */ | ||
731 | |||
732 | /*mode: digital=1 or analog=0*/ | ||
733 | u8 mode_tv; | ||
734 | |||
735 | u8 USE_ISO; | ||
736 | struct cx231xx_tvnorm encodernorm; | ||
737 | struct cx231xx_tsport ts1, ts2; | ||
738 | struct cx2341x_mpeg_params mpeg_params; | ||
739 | struct video_device *v4l_device; | ||
740 | atomic_t v4l_reader_count; | ||
741 | u32 freq; | ||
742 | unsigned int input; | ||
743 | u32 cx23417_mailbox; | ||
744 | u32 __iomem *lmmio; | ||
745 | u8 __iomem *bmmio; | ||
746 | }; | ||
747 | |||
748 | extern struct list_head cx231xx_devlist; | ||
749 | |||
750 | #define cx25840_call(cx231xx, o, f, args...) \ | ||
751 | v4l2_subdev_call(cx231xx->sd_cx25840, o, f, ##args) | ||
752 | #define tuner_call(cx231xx, o, f, args...) \ | ||
753 | v4l2_subdev_call(cx231xx->sd_tuner, o, f, ##args) | ||
754 | #define call_all(dev, o, f, args...) \ | ||
755 | v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args) | ||
756 | |||
757 | struct cx231xx_ops { | ||
758 | struct list_head next; | ||
759 | char *name; | ||
760 | int id; | ||
761 | int (*init) (struct cx231xx *); | ||
762 | int (*fini) (struct cx231xx *); | ||
763 | }; | ||
764 | |||
765 | /* call back functions in dvb module */ | ||
766 | int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq); | ||
767 | int cx231xx_reset_analog_tuner(struct cx231xx *dev); | ||
768 | |||
769 | /* Provided by cx231xx-i2c.c */ | ||
770 | void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c); | ||
771 | int cx231xx_i2c_register(struct cx231xx_i2c *bus); | ||
772 | int cx231xx_i2c_unregister(struct cx231xx_i2c *bus); | ||
773 | |||
774 | /* Internal block control functions */ | ||
775 | int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, | ||
776 | u8 saddr_len, u32 *data, u8 data_len, int master); | ||
777 | int cx231xx_write_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr, | ||
778 | u8 saddr_len, u32 data, u8 data_len, int master); | ||
779 | int cx231xx_read_i2c_data(struct cx231xx *dev, u8 dev_addr, | ||
780 | u16 saddr, u8 saddr_len, u32 *data, u8 data_len); | ||
781 | int cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, | ||
782 | u16 saddr, u8 saddr_len, u32 data, u8 data_len); | ||
783 | int cx231xx_reg_mask_write(struct cx231xx *dev, u8 dev_addr, u8 size, | ||
784 | u16 register_address, u8 bit_start, u8 bit_end, | ||
785 | u32 value); | ||
786 | int cx231xx_read_modify_write_i2c_dword(struct cx231xx *dev, u8 dev_addr, | ||
787 | u16 saddr, u32 mask, u32 value); | ||
788 | u32 cx231xx_set_field(u32 field_mask, u32 data); | ||
789 | |||
790 | /*verve r/w*/ | ||
791 | void initGPIO(struct cx231xx *dev); | ||
792 | void uninitGPIO(struct cx231xx *dev); | ||
793 | /* afe related functions */ | ||
794 | int cx231xx_afe_init_super_block(struct cx231xx *dev, u32 ref_count); | ||
795 | int cx231xx_afe_init_channels(struct cx231xx *dev); | ||
796 | int cx231xx_afe_setup_AFE_for_baseband(struct cx231xx *dev); | ||
797 | int cx231xx_afe_set_input_mux(struct cx231xx *dev, u32 input_mux); | ||
798 | int cx231xx_afe_set_mode(struct cx231xx *dev, enum AFE_MODE mode); | ||
799 | int cx231xx_afe_update_power_control(struct cx231xx *dev, | ||
800 | enum AV_MODE avmode); | ||
801 | int cx231xx_afe_adjust_ref_count(struct cx231xx *dev, u32 video_input); | ||
802 | |||
803 | /* i2s block related functions */ | ||
804 | int cx231xx_i2s_blk_initialize(struct cx231xx *dev); | ||
805 | int cx231xx_i2s_blk_update_power_control(struct cx231xx *dev, | ||
806 | enum AV_MODE avmode); | ||
807 | int cx231xx_i2s_blk_set_audio_input(struct cx231xx *dev, u8 audio_input); | ||
808 | |||
809 | /* DIF related functions */ | ||
810 | int cx231xx_dif_configure_C2HH_for_low_IF(struct cx231xx *dev, u32 mode, | ||
811 | u32 function_mode, u32 standard); | ||
812 | void cx231xx_set_Colibri_For_LowIF(struct cx231xx *dev, u32 if_freq, | ||
813 | u8 spectral_invert, u32 mode); | ||
814 | u32 cx231xx_Get_Colibri_CarrierOffset(u32 mode, u32 standerd); | ||
815 | void cx231xx_set_DIF_bandpass(struct cx231xx *dev, u32 if_freq, | ||
816 | u8 spectral_invert, u32 mode); | ||
817 | void cx231xx_Setup_AFE_for_LowIF(struct cx231xx *dev); | ||
818 | void reset_s5h1432_demod(struct cx231xx *dev); | ||
819 | void cx231xx_dump_HH_reg(struct cx231xx *dev); | ||
820 | void update_HH_register_after_set_DIF(struct cx231xx *dev); | ||
821 | void cx231xx_dump_SC_reg(struct cx231xx *dev); | ||
822 | |||
823 | |||
824 | |||
825 | int cx231xx_dif_set_standard(struct cx231xx *dev, u32 standard); | ||
826 | int cx231xx_tuner_pre_channel_change(struct cx231xx *dev); | ||
827 | int cx231xx_tuner_post_channel_change(struct cx231xx *dev); | ||
828 | |||
829 | /* video parser functions */ | ||
830 | u8 cx231xx_find_next_SAV_EAV(u8 *p_buffer, u32 buffer_size, | ||
831 | u32 *p_bytes_used); | ||
832 | u8 cx231xx_find_boundary_SAV_EAV(u8 *p_buffer, u8 *partial_buf, | ||
833 | u32 *p_bytes_used); | ||
834 | int cx231xx_do_copy(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
835 | u8 *p_buffer, u32 bytes_to_copy); | ||
836 | void cx231xx_reset_video_buffer(struct cx231xx *dev, | ||
837 | struct cx231xx_dmaqueue *dma_q); | ||
838 | u8 cx231xx_is_buffer_done(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q); | ||
839 | u32 cx231xx_copy_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
840 | u8 *p_line, u32 length, int field_number); | ||
841 | u32 cx231xx_get_video_line(struct cx231xx *dev, struct cx231xx_dmaqueue *dma_q, | ||
842 | u8 sav_eav, u8 *p_buffer, u32 buffer_size); | ||
843 | void cx231xx_swab(u16 *from, u16 *to, u16 len); | ||
844 | |||
845 | /* Provided by cx231xx-core.c */ | ||
846 | |||
847 | u32 cx231xx_request_buffers(struct cx231xx *dev, u32 count); | ||
848 | void cx231xx_queue_unusedframes(struct cx231xx *dev); | ||
849 | void cx231xx_release_buffers(struct cx231xx *dev); | ||
850 | |||
851 | /* read from control pipe */ | ||
852 | int cx231xx_read_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, | ||
853 | char *buf, int len); | ||
854 | |||
855 | /* write to control pipe */ | ||
856 | int cx231xx_write_ctrl_reg(struct cx231xx *dev, u8 req, u16 reg, | ||
857 | char *buf, int len); | ||
858 | int cx231xx_mode_register(struct cx231xx *dev, u16 address, u32 mode); | ||
859 | |||
860 | int cx231xx_send_vendor_cmd(struct cx231xx *dev, | ||
861 | struct VENDOR_REQUEST_IN *ven_req); | ||
862 | int cx231xx_send_usb_command(struct cx231xx_i2c *i2c_bus, | ||
863 | struct cx231xx_i2c_xfer_data *req_data); | ||
864 | |||
865 | /* Gpio related functions */ | ||
866 | int cx231xx_send_gpio_cmd(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val, | ||
867 | u8 len, u8 request, u8 direction); | ||
868 | int cx231xx_set_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val); | ||
869 | int cx231xx_get_gpio_bit(struct cx231xx *dev, u32 gpio_bit, u8 *gpio_val); | ||
870 | int cx231xx_set_gpio_value(struct cx231xx *dev, int pin_number, int pin_value); | ||
871 | int cx231xx_set_gpio_direction(struct cx231xx *dev, int pin_number, | ||
872 | int pin_value); | ||
873 | |||
874 | int cx231xx_gpio_i2c_start(struct cx231xx *dev); | ||
875 | int cx231xx_gpio_i2c_end(struct cx231xx *dev); | ||
876 | int cx231xx_gpio_i2c_write_byte(struct cx231xx *dev, u8 data); | ||
877 | int cx231xx_gpio_i2c_read_byte(struct cx231xx *dev, u8 *buf); | ||
878 | int cx231xx_gpio_i2c_read_ack(struct cx231xx *dev); | ||
879 | int cx231xx_gpio_i2c_write_ack(struct cx231xx *dev); | ||
880 | int cx231xx_gpio_i2c_write_nak(struct cx231xx *dev); | ||
881 | |||
882 | int cx231xx_gpio_i2c_read(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len); | ||
883 | int cx231xx_gpio_i2c_write(struct cx231xx *dev, u8 dev_addr, u8 *buf, u8 len); | ||
884 | |||
885 | /* audio related functions */ | ||
886 | int cx231xx_set_audio_decoder_input(struct cx231xx *dev, | ||
887 | enum AUDIO_INPUT audio_input); | ||
888 | |||
889 | int cx231xx_capture_start(struct cx231xx *dev, int start, u8 media_type); | ||
890 | int cx231xx_set_video_alternate(struct cx231xx *dev); | ||
891 | int cx231xx_set_alt_setting(struct cx231xx *dev, u8 index, u8 alt); | ||
892 | int is_fw_load(struct cx231xx *dev); | ||
893 | int cx231xx_check_fw(struct cx231xx *dev); | ||
894 | int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | ||
895 | int num_bufs, int max_pkt_size, | ||
896 | int (*isoc_copy) (struct cx231xx *dev, | ||
897 | struct urb *urb)); | ||
898 | int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, | ||
899 | int num_bufs, int max_pkt_size, | ||
900 | int (*bulk_copy) (struct cx231xx *dev, | ||
901 | struct urb *urb)); | ||
902 | void cx231xx_stop_TS1(struct cx231xx *dev); | ||
903 | void cx231xx_start_TS1(struct cx231xx *dev); | ||
904 | void cx231xx_uninit_isoc(struct cx231xx *dev); | ||
905 | void cx231xx_uninit_bulk(struct cx231xx *dev); | ||
906 | int cx231xx_set_mode(struct cx231xx *dev, enum cx231xx_mode set_mode); | ||
907 | int cx231xx_unmute_audio(struct cx231xx *dev); | ||
908 | int cx231xx_ep5_bulkout(struct cx231xx *dev, u8 *firmware, u16 size); | ||
909 | void cx231xx_disable656(struct cx231xx *dev); | ||
910 | void cx231xx_enable656(struct cx231xx *dev); | ||
911 | int cx231xx_demod_reset(struct cx231xx *dev); | ||
912 | int cx231xx_gpio_set(struct cx231xx *dev, struct cx231xx_reg_seq *gpio); | ||
913 | |||
914 | /* Device list functions */ | ||
915 | void cx231xx_release_resources(struct cx231xx *dev); | ||
916 | void cx231xx_release_analog_resources(struct cx231xx *dev); | ||
917 | int cx231xx_register_analog_devices(struct cx231xx *dev); | ||
918 | void cx231xx_remove_from_devlist(struct cx231xx *dev); | ||
919 | void cx231xx_add_into_devlist(struct cx231xx *dev); | ||
920 | void cx231xx_init_extension(struct cx231xx *dev); | ||
921 | void cx231xx_close_extension(struct cx231xx *dev); | ||
922 | |||
923 | /* hardware init functions */ | ||
924 | int cx231xx_dev_init(struct cx231xx *dev); | ||
925 | void cx231xx_dev_uninit(struct cx231xx *dev); | ||
926 | void cx231xx_config_i2c(struct cx231xx *dev); | ||
927 | int cx231xx_config(struct cx231xx *dev); | ||
928 | |||
929 | /* Stream control functions */ | ||
930 | int cx231xx_start_stream(struct cx231xx *dev, u32 ep_mask); | ||
931 | int cx231xx_stop_stream(struct cx231xx *dev, u32 ep_mask); | ||
932 | |||
933 | int cx231xx_initialize_stream_xfer(struct cx231xx *dev, u32 media_type); | ||
934 | |||
935 | /* Power control functions */ | ||
936 | int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode); | ||
937 | int cx231xx_power_suspend(struct cx231xx *dev); | ||
938 | |||
939 | /* chip specific control functions */ | ||
940 | int cx231xx_init_ctrl_pin_status(struct cx231xx *dev); | ||
941 | int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, | ||
942 | u8 analog_or_digital); | ||
943 | int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3); | ||
944 | |||
945 | /* video audio decoder related functions */ | ||
946 | void video_mux(struct cx231xx *dev, int index); | ||
947 | int cx231xx_set_video_input_mux(struct cx231xx *dev, u8 input); | ||
948 | int cx231xx_set_decoder_video_input(struct cx231xx *dev, u8 pin_type, u8 input); | ||
949 | int cx231xx_do_mode_ctrl_overrides(struct cx231xx *dev); | ||
950 | int cx231xx_set_audio_input(struct cx231xx *dev, u8 input); | ||
951 | |||
952 | /* Provided by cx231xx-video.c */ | ||
953 | int cx231xx_register_extension(struct cx231xx_ops *dev); | ||
954 | void cx231xx_unregister_extension(struct cx231xx_ops *dev); | ||
955 | void cx231xx_init_extension(struct cx231xx *dev); | ||
956 | void cx231xx_close_extension(struct cx231xx *dev); | ||
957 | |||
958 | /* Provided by cx231xx-cards.c */ | ||
959 | extern void cx231xx_pre_card_setup(struct cx231xx *dev); | ||
960 | extern void cx231xx_card_setup(struct cx231xx *dev); | ||
961 | extern struct cx231xx_board cx231xx_boards[]; | ||
962 | extern struct usb_device_id cx231xx_id_table[]; | ||
963 | extern const unsigned int cx231xx_bcount; | ||
964 | int cx231xx_tuner_callback(void *ptr, int component, int command, int arg); | ||
965 | |||
966 | /* cx23885-417.c */ | ||
967 | extern int cx231xx_417_register(struct cx231xx *dev); | ||
968 | extern void cx231xx_417_unregister(struct cx231xx *dev); | ||
969 | |||
970 | /* cx23885-input.c */ | ||
971 | |||
972 | #if defined(CONFIG_VIDEO_CX231XX_RC) | ||
973 | int cx231xx_ir_init(struct cx231xx *dev); | ||
974 | void cx231xx_ir_exit(struct cx231xx *dev); | ||
975 | #else | ||
976 | #define cx231xx_ir_init(dev) (0) | ||
977 | #define cx231xx_ir_exit(dev) (0) | ||
978 | #endif | ||
979 | |||
980 | |||
981 | /* printk macros */ | ||
982 | |||
983 | #define cx231xx_err(fmt, arg...) do {\ | ||
984 | printk(KERN_ERR fmt , ##arg); } while (0) | ||
985 | |||
986 | #define cx231xx_errdev(fmt, arg...) do {\ | ||
987 | printk(KERN_ERR "%s: "fmt,\ | ||
988 | dev->name , ##arg); } while (0) | ||
989 | |||
990 | #define cx231xx_info(fmt, arg...) do {\ | ||
991 | printk(KERN_INFO "%s: "fmt,\ | ||
992 | dev->name , ##arg); } while (0) | ||
993 | #define cx231xx_warn(fmt, arg...) do {\ | ||
994 | printk(KERN_WARNING "%s: "fmt,\ | ||
995 | dev->name , ##arg); } while (0) | ||
996 | |||
997 | static inline unsigned int norm_maxw(struct cx231xx *dev) | ||
998 | { | ||
999 | if (dev->board.max_range_640_480) | ||
1000 | return 640; | ||
1001 | else | ||
1002 | return 720; | ||
1003 | } | ||
1004 | |||
1005 | static inline unsigned int norm_maxh(struct cx231xx *dev) | ||
1006 | { | ||
1007 | if (dev->board.max_range_640_480) | ||
1008 | return 480; | ||
1009 | else | ||
1010 | return (dev->norm & V4L2_STD_625_50) ? 576 : 480; | ||
1011 | } | ||
1012 | #endif | ||