1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* cx25840 - Conexant CX25840 audio/video decoder driver
3 *
4 * Copyright (C) 2004 Ulf Eklund
5 *
6 * Based on the saa7115 driver and on the first version of Chris Kennedy's
7 * cx25840 driver.
8 *
9 * Changes by Tyler Trafford <tatrafford@comcast.net>
10 * - cleanup/rewrite for V4L2 API (2005)
11 *
12 * VBI support by Hans Verkuil <hverkuil@xs4all.nl>.
13 *
14 * NTSC sliced VBI support by Christopher Neufeld <television@cneufeld.ca>
15 * with additional fixes by Hans Verkuil <hverkuil@xs4all.nl>.
16 *
17 * CX23885 support by Steven Toth <stoth@linuxtv.org>.
18 *
19 * CX2388[578] IRQ handling, IO Pin mux configuration and other small fixes are
20 * Copyright (C) 2010 Andy Walls <awalls@md.metrocast.net>
21 *
22 * CX23888 DIF support for the HVR1850
23 * Copyright (C) 2011 Steven Toth <stoth@kernellabs.com>
24 *
25 * CX2584x pin to pad mapping and output format configuration support are
26 * Copyright (C) 2011 Maciej S. Szmigiero <mail@maciej.szmigiero.name>
27 */
28
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/slab.h>
32 #include <linux/videodev2.h>
33 #include <linux/i2c.h>
34 #include <linux/delay.h>
35 #include <linux/math64.h>
36 #include <media/v4l2-common.h>
37 #include <media/drv-intf/cx25840.h>
38
39 #include "cx25840-core.h"
40
41 MODULE_DESCRIPTION("Conexant CX25840 audio/video decoder driver");
42 MODULE_AUTHOR("Ulf Eklund, Chris Kennedy, Hans Verkuil, Tyler Trafford");
43 MODULE_LICENSE("GPL");
44
45 #define CX25840_VID_INT_STAT_REG 0x410
46 #define CX25840_VID_INT_STAT_BITS 0x0000ffff
47 #define CX25840_VID_INT_MASK_BITS 0xffff0000
48 #define CX25840_VID_INT_MASK_SHFT 16
49 #define CX25840_VID_INT_MASK_REG 0x412
50
51 #define CX23885_AUD_MC_INT_MASK_REG 0x80c
52 #define CX23885_AUD_MC_INT_STAT_BITS 0xffff0000
53 #define CX23885_AUD_MC_INT_CTRL_BITS 0x0000ffff
54 #define CX23885_AUD_MC_INT_STAT_SHFT 16
55
56 #define CX25840_AUD_INT_CTRL_REG 0x812
57 #define CX25840_AUD_INT_STAT_REG 0x813
58
59 #define CX23885_PIN_CTRL_IRQ_REG 0x123
60 #define CX23885_PIN_CTRL_IRQ_IR_STAT 0x40
61 #define CX23885_PIN_CTRL_IRQ_AUD_STAT 0x20
62 #define CX23885_PIN_CTRL_IRQ_VID_STAT 0x10
63
64 #define CX25840_IR_STATS_REG 0x210
65 #define CX25840_IR_IRQEN_REG 0x214
66
67 static int cx25840_debug;
68
69 module_param_named(debug, cx25840_debug, int, 0644);
70
71 MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]");
72
73 /* ----------------------------------------------------------------------- */
74 static void cx23888_std_setup(struct i2c_client *client);
75
cx25840_write(struct i2c_client * client,u16 addr,u8 value)76 int cx25840_write(struct i2c_client *client, u16 addr, u8 value)
77 {
78 u8 buffer[3];
79
80 buffer[0] = addr >> 8;
81 buffer[1] = addr & 0xff;
82 buffer[2] = value;
83 return i2c_master_send(client, buffer, 3);
84 }
85
cx25840_write4(struct i2c_client * client,u16 addr,u32 value)86 int cx25840_write4(struct i2c_client *client, u16 addr, u32 value)
87 {
88 u8 buffer[6];
89
90 buffer[0] = addr >> 8;
91 buffer[1] = addr & 0xff;
92 buffer[2] = value & 0xff;
93 buffer[3] = (value >> 8) & 0xff;
94 buffer[4] = (value >> 16) & 0xff;
95 buffer[5] = value >> 24;
96 return i2c_master_send(client, buffer, 6);
97 }
98
cx25840_read(struct i2c_client * client,u16 addr)99 u8 cx25840_read(struct i2c_client *client, u16 addr)
100 {
101 struct i2c_msg msgs[2];
102 u8 tx_buf[2], rx_buf[1];
103
104 /* Write register address */
105 tx_buf[0] = addr >> 8;
106 tx_buf[1] = addr & 0xff;
107 msgs[0].addr = client->addr;
108 msgs[0].flags = 0;
109 msgs[0].len = 2;
110 msgs[0].buf = (char *)tx_buf;
111
112 /* Read data from register */
113 msgs[1].addr = client->addr;
114 msgs[1].flags = I2C_M_RD;
115 msgs[1].len = 1;
116 msgs[1].buf = (char *)rx_buf;
117
118 if (i2c_transfer(client->adapter, msgs, 2) < 2)
119 return 0;
120
121 return rx_buf[0];
122 }
123
cx25840_read4(struct i2c_client * client,u16 addr)124 u32 cx25840_read4(struct i2c_client *client, u16 addr)
125 {
126 struct i2c_msg msgs[2];
127 u8 tx_buf[2], rx_buf[4];
128
129 /* Write register address */
130 tx_buf[0] = addr >> 8;
131 tx_buf[1] = addr & 0xff;
132 msgs[0].addr = client->addr;
133 msgs[0].flags = 0;
134 msgs[0].len = 2;
135 msgs[0].buf = (char *)tx_buf;
136
137 /* Read data from registers */
138 msgs[1].addr = client->addr;
139 msgs[1].flags = I2C_M_RD;
140 msgs[1].len = 4;
141 msgs[1].buf = (char *)rx_buf;
142
143 if (i2c_transfer(client->adapter, msgs, 2) < 2)
144 return 0;
145
146 return (rx_buf[3] << 24) | (rx_buf[2] << 16) | (rx_buf[1] << 8) |
147 rx_buf[0];
148 }
149
cx25840_and_or(struct i2c_client * client,u16 addr,unsigned int and_mask,u8 or_value)150 int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned int and_mask,
151 u8 or_value)
152 {
153 return cx25840_write(client, addr,
154 (cx25840_read(client, addr) & and_mask) |
155 or_value);
156 }
157
cx25840_and_or4(struct i2c_client * client,u16 addr,u32 and_mask,u32 or_value)158 int cx25840_and_or4(struct i2c_client *client, u16 addr, u32 and_mask,
159 u32 or_value)
160 {
161 return cx25840_write4(client, addr,
162 (cx25840_read4(client, addr) & and_mask) |
163 or_value);
164 }
165
166 /* ----------------------------------------------------------------------- */
167
168 static int set_input(struct i2c_client *client,
169 enum cx25840_video_input vid_input,
170 enum cx25840_audio_input aud_input);
171
172 /* ----------------------------------------------------------------------- */
173
cx23885_s_io_pin_config(struct v4l2_subdev * sd,size_t n,struct v4l2_subdev_io_pin_config * p)174 static int cx23885_s_io_pin_config(struct v4l2_subdev *sd, size_t n,
175 struct v4l2_subdev_io_pin_config *p)
176 {
177 struct i2c_client *client = v4l2_get_subdevdata(sd);
178 int i;
179 u32 pin_ctrl;
180 u8 gpio_oe, gpio_data, strength;
181
182 pin_ctrl = cx25840_read4(client, 0x120);
183 gpio_oe = cx25840_read(client, 0x160);
184 gpio_data = cx25840_read(client, 0x164);
185
186 for (i = 0; i < n; i++) {
187 strength = p[i].strength;
188 if (strength > CX25840_PIN_DRIVE_FAST)
189 strength = CX25840_PIN_DRIVE_FAST;
190
191 switch (p[i].pin) {
192 case CX23885_PIN_IRQ_N_GPIO16:
193 if (p[i].function != CX23885_PAD_IRQ_N) {
194 /* GPIO16 */
195 pin_ctrl &= ~(0x1 << 25);
196 } else {
197 /* IRQ_N */
198 if (p[i].flags &
199 (BIT(V4L2_SUBDEV_IO_PIN_DISABLE) |
200 BIT(V4L2_SUBDEV_IO_PIN_INPUT))) {
201 pin_ctrl &= ~(0x1 << 25);
202 } else {
203 pin_ctrl |= (0x1 << 25);
204 }
205 if (p[i].flags &
206 BIT(V4L2_SUBDEV_IO_PIN_ACTIVE_LOW)) {
207 pin_ctrl &= ~(0x1 << 24);
208 } else {
209 pin_ctrl |= (0x1 << 24);
210 }
211 }
212 break;
213 case CX23885_PIN_IR_RX_GPIO19:
214 if (p[i].function != CX23885_PAD_GPIO19) {
215 /* IR_RX */
216 gpio_oe |= (0x1 << 0);
217 pin_ctrl &= ~(0x3 << 18);
218 pin_ctrl |= (strength << 18);
219 } else {
220 /* GPIO19 */
221 gpio_oe &= ~(0x1 << 0);
222 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_SET_VALUE)) {
223 gpio_data &= ~(0x1 << 0);
224 gpio_data |= ((p[i].value & 0x1) << 0);
225 }
226 pin_ctrl &= ~(0x3 << 12);
227 pin_ctrl |= (strength << 12);
228 }
229 break;
230 case CX23885_PIN_IR_TX_GPIO20:
231 if (p[i].function != CX23885_PAD_GPIO20) {
232 /* IR_TX */
233 gpio_oe |= (0x1 << 1);
234 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_DISABLE))
235 pin_ctrl &= ~(0x1 << 10);
236 else
237 pin_ctrl |= (0x1 << 10);
238 pin_ctrl &= ~(0x3 << 18);
239 pin_ctrl |= (strength << 18);
240 } else {
241 /* GPIO20 */
242 gpio_oe &= ~(0x1 << 1);
243 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_SET_VALUE)) {
244 gpio_data &= ~(0x1 << 1);
245 gpio_data |= ((p[i].value & 0x1) << 1);
246 }
247 pin_ctrl &= ~(0x3 << 12);
248 pin_ctrl |= (strength << 12);
249 }
250 break;
251 case CX23885_PIN_I2S_SDAT_GPIO21:
252 if (p[i].function != CX23885_PAD_GPIO21) {
253 /* I2S_SDAT */
254 /* TODO: Input or Output config */
255 gpio_oe |= (0x1 << 2);
256 pin_ctrl &= ~(0x3 << 22);
257 pin_ctrl |= (strength << 22);
258 } else {
259 /* GPIO21 */
260 gpio_oe &= ~(0x1 << 2);
261 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_SET_VALUE)) {
262 gpio_data &= ~(0x1 << 2);
263 gpio_data |= ((p[i].value & 0x1) << 2);
264 }
265 pin_ctrl &= ~(0x3 << 12);
266 pin_ctrl |= (strength << 12);
267 }
268 break;
269 case CX23885_PIN_I2S_WCLK_GPIO22:
270 if (p[i].function != CX23885_PAD_GPIO22) {
271 /* I2S_WCLK */
272 /* TODO: Input or Output config */
273 gpio_oe |= (0x1 << 3);
274 pin_ctrl &= ~(0x3 << 22);
275 pin_ctrl |= (strength << 22);
276 } else {
277 /* GPIO22 */
278 gpio_oe &= ~(0x1 << 3);
279 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_SET_VALUE)) {
280 gpio_data &= ~(0x1 << 3);
281 gpio_data |= ((p[i].value & 0x1) << 3);
282 }
283 pin_ctrl &= ~(0x3 << 12);
284 pin_ctrl |= (strength << 12);
285 }
286 break;
287 case CX23885_PIN_I2S_BCLK_GPIO23:
288 if (p[i].function != CX23885_PAD_GPIO23) {
289 /* I2S_BCLK */
290 /* TODO: Input or Output config */
291 gpio_oe |= (0x1 << 4);
292 pin_ctrl &= ~(0x3 << 22);
293 pin_ctrl |= (strength << 22);
294 } else {
295 /* GPIO23 */
296 gpio_oe &= ~(0x1 << 4);
297 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_SET_VALUE)) {
298 gpio_data &= ~(0x1 << 4);
299 gpio_data |= ((p[i].value & 0x1) << 4);
300 }
301 pin_ctrl &= ~(0x3 << 12);
302 pin_ctrl |= (strength << 12);
303 }
304 break;
305 }
306 }
307
308 cx25840_write(client, 0x164, gpio_data);
309 cx25840_write(client, 0x160, gpio_oe);
310 cx25840_write4(client, 0x120, pin_ctrl);
311 return 0;
312 }
313
cx25840_function_to_pad(struct i2c_client * client,u8 function)314 static u8 cx25840_function_to_pad(struct i2c_client *client, u8 function)
315 {
316 if (function > CX25840_PAD_VRESET) {
317 v4l_err(client, "invalid function %u, assuming default\n",
318 (unsigned int)function);
319 return 0;
320 }
321
322 return function;
323 }
324
cx25840_set_invert(u8 * pinctrl3,u8 * voutctrl4,u8 function,u8 pin,bool invert)325 static void cx25840_set_invert(u8 *pinctrl3, u8 *voutctrl4, u8 function,
326 u8 pin, bool invert)
327 {
328 switch (function) {
329 case CX25840_PAD_IRQ_N:
330 if (invert)
331 *pinctrl3 &= ~2;
332 else
333 *pinctrl3 |= 2;
334 break;
335
336 case CX25840_PAD_ACTIVE:
337 if (invert)
338 *voutctrl4 |= BIT(2);
339 else
340 *voutctrl4 &= ~BIT(2);
341 break;
342
343 case CX25840_PAD_VACTIVE:
344 if (invert)
345 *voutctrl4 |= BIT(5);
346 else
347 *voutctrl4 &= ~BIT(5);
348 break;
349
350 case CX25840_PAD_CBFLAG:
351 if (invert)
352 *voutctrl4 |= BIT(4);
353 else
354 *voutctrl4 &= ~BIT(4);
355 break;
356
357 case CX25840_PAD_VRESET:
358 if (invert)
359 *voutctrl4 |= BIT(0);
360 else
361 *voutctrl4 &= ~BIT(0);
362 break;
363 }
364
365 if (function != CX25840_PAD_DEFAULT)
366 return;
367
368 switch (pin) {
369 case CX25840_PIN_DVALID_PRGM0:
370 if (invert)
371 *voutctrl4 |= BIT(6);
372 else
373 *voutctrl4 &= ~BIT(6);
374 break;
375
376 case CX25840_PIN_HRESET_PRGM2:
377 if (invert)
378 *voutctrl4 |= BIT(1);
379 else
380 *voutctrl4 &= ~BIT(1);
381 break;
382 }
383 }
384
cx25840_s_io_pin_config(struct v4l2_subdev * sd,size_t n,struct v4l2_subdev_io_pin_config * p)385 static int cx25840_s_io_pin_config(struct v4l2_subdev *sd, size_t n,
386 struct v4l2_subdev_io_pin_config *p)
387 {
388 struct i2c_client *client = v4l2_get_subdevdata(sd);
389 unsigned int i;
390 u8 pinctrl[6], pinconf[10], voutctrl4;
391
392 for (i = 0; i < 6; i++)
393 pinctrl[i] = cx25840_read(client, 0x114 + i);
394
395 for (i = 0; i < 10; i++)
396 pinconf[i] = cx25840_read(client, 0x11c + i);
397
398 voutctrl4 = cx25840_read(client, 0x407);
399
400 for (i = 0; i < n; i++) {
401 u8 strength = p[i].strength;
402
403 if (strength != CX25840_PIN_DRIVE_SLOW &&
404 strength != CX25840_PIN_DRIVE_MEDIUM &&
405 strength != CX25840_PIN_DRIVE_FAST) {
406 v4l_err(client,
407 "invalid drive speed for pin %u (%u), assuming fast\n",
408 (unsigned int)p[i].pin,
409 (unsigned int)strength);
410
411 strength = CX25840_PIN_DRIVE_FAST;
412 }
413
414 switch (p[i].pin) {
415 case CX25840_PIN_DVALID_PRGM0:
416 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_DISABLE))
417 pinctrl[0] &= ~BIT(6);
418 else
419 pinctrl[0] |= BIT(6);
420
421 pinconf[3] &= 0xf0;
422 pinconf[3] |= cx25840_function_to_pad(client,
423 p[i].function);
424
425 cx25840_set_invert(&pinctrl[3], &voutctrl4,
426 p[i].function,
427 CX25840_PIN_DVALID_PRGM0,
428 p[i].flags &
429 BIT(V4L2_SUBDEV_IO_PIN_ACTIVE_LOW));
430
431 pinctrl[4] &= ~(3 << 2); /* CX25840_PIN_DRIVE_MEDIUM */
432 switch (strength) {
433 case CX25840_PIN_DRIVE_SLOW:
434 pinctrl[4] |= 1 << 2;
435 break;
436
437 case CX25840_PIN_DRIVE_FAST:
438 pinctrl[4] |= 2 << 2;
439 break;
440 }
441
442 break;
443
444 case CX25840_PIN_HRESET_PRGM2:
445 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_DISABLE))
446 pinctrl[1] &= ~BIT(0);
447 else
448 pinctrl[1] |= BIT(0);
449
450 pinconf[4] &= 0xf0;
451 pinconf[4] |= cx25840_function_to_pad(client,
452 p[i].function);
453
454 cx25840_set_invert(&pinctrl[3], &voutctrl4,
455 p[i].function,
456 CX25840_PIN_HRESET_PRGM2,
457 p[i].flags &
458 BIT(V4L2_SUBDEV_IO_PIN_ACTIVE_LOW));
459
460 pinctrl[4] &= ~(3 << 2); /* CX25840_PIN_DRIVE_MEDIUM */
461 switch (strength) {
462 case CX25840_PIN_DRIVE_SLOW:
463 pinctrl[4] |= 1 << 2;
464 break;
465
466 case CX25840_PIN_DRIVE_FAST:
467 pinctrl[4] |= 2 << 2;
468 break;
469 }
470
471 break;
472
473 case CX25840_PIN_PLL_CLK_PRGM7:
474 if (p[i].flags & BIT(V4L2_SUBDEV_IO_PIN_DISABLE))
475 pinctrl[2] &= ~BIT(2);
476 else
477 pinctrl[2] |= BIT(2);
478
479 switch (p[i].function) {
480 case CX25840_PAD_XTI_X5_DLL:
481 pinconf[6] = 0;
482 break;
483
484 case CX25840_PAD_AUX_PLL:
485 pinconf[6] = 1;
486 break;
487
488 case CX25840_PAD_VID_PLL:
489 pinconf[6] = 5;
490 break;
491
492 case CX25840_PAD_XTI:
493 pinconf[6] = 2;
494 break;
495
496 default:
497 pinconf[6] = 3;
498 pinconf[6] |=
499 cx25840_function_to_pad(client,
500 p[i].function)
501 << 4;
502 }
503
504 break;
505
506 default:
507 v4l_err(client, "invalid or unsupported pin %u\n",
508 (unsigned int)p[i].pin);
509 break;
510 }
511 }
512
513 cx25840_write(client, 0x407, voutctrl4);
514
515 for (i = 0; i < 6; i++)
516 cx25840_write(client, 0x114 + i, pinctrl[i]);
517
518 for (i = 0; i < 10; i++)
519 cx25840_write(client, 0x11c + i, pinconf[i]);
520
521 return 0;
522 }
523
common_s_io_pin_config(struct v4l2_subdev * sd,size_t n,struct v4l2_subdev_io_pin_config * pincfg)524 static int common_s_io_pin_config(struct v4l2_subdev *sd, size_t n,
525 struct v4l2_subdev_io_pin_config *pincfg)
526 {
527 struct cx25840_state *state = to_state(sd);
528
529 if (is_cx2388x(state))
530 return cx23885_s_io_pin_config(sd, n, pincfg);
531 else if (is_cx2584x(state))
532 return cx25840_s_io_pin_config(sd, n, pincfg);
533 return 0;
534 }
535
536 /* ----------------------------------------------------------------------- */
537
init_dll1(struct i2c_client * client)538 static void init_dll1(struct i2c_client *client)
539 {
540 /*
541 * This is the Hauppauge sequence used to
542 * initialize the Delay Lock Loop 1 (ADC DLL).
543 */
544 cx25840_write(client, 0x159, 0x23);
545 cx25840_write(client, 0x15a, 0x87);
546 cx25840_write(client, 0x15b, 0x06);
547 udelay(10);
548 cx25840_write(client, 0x159, 0xe1);
549 udelay(10);
550 cx25840_write(client, 0x15a, 0x86);
551 cx25840_write(client, 0x159, 0xe0);
552 cx25840_write(client, 0x159, 0xe1);
553 cx25840_write(client, 0x15b, 0x10);
554 }
555
init_dll2(struct i2c_client * client)556 static void init_dll2(struct i2c_client *client)
557 {
558 /*
559 * This is the Hauppauge sequence used to
560 * initialize the Delay Lock Loop 2 (ADC DLL).
561 */
562 cx25840_write(client, 0x15d, 0xe3);
563 cx25840_write(client, 0x15e, 0x86);
564 cx25840_write(client, 0x15f, 0x06);
565 udelay(10);
566 cx25840_write(client, 0x15d, 0xe1);
567 cx25840_write(client, 0x15d, 0xe0);
568 cx25840_write(client, 0x15d, 0xe1);
569 }
570
cx25836_initialize(struct i2c_client * client)571 static void cx25836_initialize(struct i2c_client *client)
572 {
573 /*
574 *reset configuration is described on page 3-77
575 * of the CX25836 datasheet
576 */
577
578 /* 2. */
579 cx25840_and_or(client, 0x000, ~0x01, 0x01);
580 cx25840_and_or(client, 0x000, ~0x01, 0x00);
581 /* 3a. */
582 cx25840_and_or(client, 0x15a, ~0x70, 0x00);
583 /* 3b. */
584 cx25840_and_or(client, 0x15b, ~0x1e, 0x06);
585 /* 3c. */
586 cx25840_and_or(client, 0x159, ~0x02, 0x02);
587 /* 3d. */
588 udelay(10);
589 /* 3e. */
590 cx25840_and_or(client, 0x159, ~0x02, 0x00);
591 /* 3f. */
592 cx25840_and_or(client, 0x159, ~0xc0, 0xc0);
593 /* 3g. */
594 cx25840_and_or(client, 0x159, ~0x01, 0x00);
595 cx25840_and_or(client, 0x159, ~0x01, 0x01);
596 /* 3h. */
597 cx25840_and_or(client, 0x15b, ~0x1e, 0x10);
598 }
599
cx25840_work_handler(struct work_struct * work)600 static void cx25840_work_handler(struct work_struct *work)
601 {
602 struct cx25840_state *state = container_of(work, struct cx25840_state, fw_work);
603
604 cx25840_loadfw(state->c);
605 wake_up(&state->fw_wait);
606 }
607
608 #define CX25840_VCONFIG_SET_BIT(state, opt_msk, voc, idx, bit, oneval) \
609 do { \
610 if ((state)->vid_config & (opt_msk)) { \
611 if (((state)->vid_config & (opt_msk)) == \
612 (oneval)) \
613 (voc)[idx] |= BIT(bit); \
614 else \
615 (voc)[idx] &= ~BIT(bit); \
616 } \
617 } while (0)
618
619 /* apply current vconfig to hardware regs */
cx25840_vconfig_apply(struct i2c_client * client)620 static void cx25840_vconfig_apply(struct i2c_client *client)
621 {
622 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
623 u8 voutctrl[3];
624 unsigned int i;
625
626 for (i = 0; i < 3; i++)
627 voutctrl[i] = cx25840_read(client, 0x404 + i);
628
629 if (state->vid_config & CX25840_VCONFIG_FMT_MASK)
630 voutctrl[0] &= ~3;
631 switch (state->vid_config & CX25840_VCONFIG_FMT_MASK) {
632 case CX25840_VCONFIG_FMT_BT656:
633 voutctrl[0] |= 1;
634 break;
635
636 case CX25840_VCONFIG_FMT_VIP11:
637 voutctrl[0] |= 2;
638 break;
639
640 case CX25840_VCONFIG_FMT_VIP2:
641 voutctrl[0] |= 3;
642 break;
643
644 case CX25840_VCONFIG_FMT_BT601:
645 /* zero */
646 default:
647 break;
648 }
649
650 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_RES_MASK, voutctrl,
651 0, 2, CX25840_VCONFIG_RES_10BIT);
652 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_VBIRAW_MASK, voutctrl,
653 0, 3, CX25840_VCONFIG_VBIRAW_ENABLED);
654 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_ANCDATA_MASK, voutctrl,
655 0, 4, CX25840_VCONFIG_ANCDATA_ENABLED);
656 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_TASKBIT_MASK, voutctrl,
657 0, 5, CX25840_VCONFIG_TASKBIT_ONE);
658 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_ACTIVE_MASK, voutctrl,
659 1, 2, CX25840_VCONFIG_ACTIVE_HORIZONTAL);
660 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_VALID_MASK, voutctrl,
661 1, 3, CX25840_VCONFIG_VALID_ANDACTIVE);
662 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_HRESETW_MASK, voutctrl,
663 1, 4, CX25840_VCONFIG_HRESETW_PIXCLK);
664
665 if (state->vid_config & CX25840_VCONFIG_CLKGATE_MASK)
666 voutctrl[1] &= ~(3 << 6);
667 switch (state->vid_config & CX25840_VCONFIG_CLKGATE_MASK) {
668 case CX25840_VCONFIG_CLKGATE_VALID:
669 voutctrl[1] |= 2;
670 break;
671
672 case CX25840_VCONFIG_CLKGATE_VALIDACTIVE:
673 voutctrl[1] |= 3;
674 break;
675
676 case CX25840_VCONFIG_CLKGATE_NONE:
677 /* zero */
678 default:
679 break;
680 }
681
682 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_DCMODE_MASK, voutctrl,
683 2, 0, CX25840_VCONFIG_DCMODE_BYTES);
684 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_IDID0S_MASK, voutctrl,
685 2, 1, CX25840_VCONFIG_IDID0S_LINECNT);
686 CX25840_VCONFIG_SET_BIT(state, CX25840_VCONFIG_VIPCLAMP_MASK, voutctrl,
687 2, 4, CX25840_VCONFIG_VIPCLAMP_ENABLED);
688
689 for (i = 0; i < 3; i++)
690 cx25840_write(client, 0x404 + i, voutctrl[i]);
691 }
692
cx25840_initialize(struct i2c_client * client)693 static void cx25840_initialize(struct i2c_client *client)
694 {
695 DEFINE_WAIT(wait);
696 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
697 struct workqueue_struct *q;
698
699 /* datasheet startup in numbered steps, refer to page 3-77 */
700 /* 2. */
701 cx25840_and_or(client, 0x803, ~0x10, 0x00);
702 /*
703 * The default of this register should be 4, but I get 0 instead.
704 * Set this register to 4 manually.
705 */
706 cx25840_write(client, 0x000, 0x04);
707 /* 3. */
708 init_dll1(client);
709 init_dll2(client);
710 cx25840_write(client, 0x136, 0x0a);
711 /* 4. */
712 cx25840_write(client, 0x13c, 0x01);
713 cx25840_write(client, 0x13c, 0x00);
714 /* 5. */
715 /*
716 * Do the firmware load in a work handler to prevent.
717 * Otherwise the kernel is blocked waiting for the
718 * bit-banging i2c interface to finish uploading the
719 * firmware.
720 */
721 INIT_WORK(&state->fw_work, cx25840_work_handler);
722 init_waitqueue_head(&state->fw_wait);
723 q = create_singlethread_workqueue("cx25840_fw");
724 if (q) {
725 prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
726 queue_work(q, &state->fw_work);
727 schedule();
728 finish_wait(&state->fw_wait, &wait);
729 destroy_workqueue(q);
730 }
731
732 /* 6. */
733 cx25840_write(client, 0x115, 0x8c);
734 cx25840_write(client, 0x116, 0x07);
735 cx25840_write(client, 0x118, 0x02);
736 /* 7. */
737 cx25840_write(client, 0x4a5, 0x80);
738 cx25840_write(client, 0x4a5, 0x00);
739 cx25840_write(client, 0x402, 0x00);
740 /* 8. */
741 cx25840_and_or(client, 0x401, ~0x18, 0);
742 cx25840_and_or(client, 0x4a2, ~0x10, 0x10);
743 /* steps 8c and 8d are done in change_input() */
744 /* 10. */
745 cx25840_write(client, 0x8d3, 0x1f);
746 cx25840_write(client, 0x8e3, 0x03);
747
748 cx25840_std_setup(client);
749
750 /* trial and error says these are needed to get audio */
751 cx25840_write(client, 0x914, 0xa0);
752 cx25840_write(client, 0x918, 0xa0);
753 cx25840_write(client, 0x919, 0x01);
754
755 /* stereo preferred */
756 cx25840_write(client, 0x809, 0x04);
757 /* AC97 shift */
758 cx25840_write(client, 0x8cf, 0x0f);
759
760 /* (re)set input */
761 set_input(client, state->vid_input, state->aud_input);
762
763 if (state->generic_mode)
764 cx25840_vconfig_apply(client);
765
766 /* start microcontroller */
767 cx25840_and_or(client, 0x803, ~0x10, 0x10);
768 }
769
cx23885_initialize(struct i2c_client * client)770 static void cx23885_initialize(struct i2c_client *client)
771 {
772 DEFINE_WAIT(wait);
773 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
774 u32 clk_freq = 0;
775 struct workqueue_struct *q;
776
777 /* cx23885 sets hostdata to clk_freq pointer */
778 if (v4l2_get_subdev_hostdata(&state->sd))
779 clk_freq = *((u32 *)v4l2_get_subdev_hostdata(&state->sd));
780
781 /*
782 * Come out of digital power down
783 * The CX23888, at least, needs this, otherwise registers aside from
784 * 0x0-0x2 can't be read or written.
785 */
786 cx25840_write(client, 0x000, 0);
787
788 /* Internal Reset */
789 cx25840_and_or(client, 0x102, ~0x01, 0x01);
790 cx25840_and_or(client, 0x102, ~0x01, 0x00);
791
792 /* Stop microcontroller */
793 cx25840_and_or(client, 0x803, ~0x10, 0x00);
794
795 /* DIF in reset? */
796 cx25840_write(client, 0x398, 0);
797
798 /*
799 * Trust the default xtal, no division
800 * '885: 28.636363... MHz
801 * '887: 25.000000 MHz
802 * '888: 50.000000 MHz
803 */
804 cx25840_write(client, 0x2, 0x76);
805
806 /* Power up all the PLL's and DLL */
807 cx25840_write(client, 0x1, 0x40);
808
809 /* Sys PLL */
810 switch (state->id) {
811 case CX23888_AV:
812 /*
813 * 50.0 MHz * (0xb + 0xe8ba26/0x2000000)/4 = 5 * 28.636363 MHz
814 * 572.73 MHz before post divide
815 */
816 if (clk_freq == 25000000) {
817 /* 888/ImpactVCBe or 25Mhz xtal */
818 ; /* nothing to do */
819 } else {
820 /* HVR1850 or 50MHz xtal */
821 cx25840_write(client, 0x2, 0x71);
822 }
823 cx25840_write4(client, 0x11c, 0x01d1744c);
824 cx25840_write4(client, 0x118, 0x00000416);
825 cx25840_write4(client, 0x404, 0x0010253e);
826 cx25840_write4(client, 0x42c, 0x42600000);
827 cx25840_write4(client, 0x44c, 0x161f1000);
828 break;
829 case CX23887_AV:
830 /*
831 * 25.0 MHz * (0x16 + 0x1d1744c/0x2000000)/4 = 5 * 28.636363 MHz
832 * 572.73 MHz before post divide
833 */
834 cx25840_write4(client, 0x11c, 0x01d1744c);
835 cx25840_write4(client, 0x118, 0x00000416);
836 break;
837 case CX23885_AV:
838 default:
839 /*
840 * 28.636363 MHz * (0x14 + 0x0/0x2000000)/4 = 5 * 28.636363 MHz
841 * 572.73 MHz before post divide
842 */
843 cx25840_write4(client, 0x11c, 0x00000000);
844 cx25840_write4(client, 0x118, 0x00000414);
845 break;
846 }
847
848 /* Disable DIF bypass */
849 cx25840_write4(client, 0x33c, 0x00000001);
850
851 /* DIF Src phase inc */
852 cx25840_write4(client, 0x340, 0x0df7df83);
853
854 /*
855 * Vid PLL
856 * Setup for a BT.656 pixel clock of 13.5 Mpixels/second
857 *
858 * 28.636363 MHz * (0xf + 0x02be2c9/0x2000000)/4 = 8 * 13.5 MHz
859 * 432.0 MHz before post divide
860 */
861
862 /* HVR1850 */
863 switch (state->id) {
864 case CX23888_AV:
865 if (clk_freq == 25000000) {
866 /* 888/ImpactVCBe or 25MHz xtal */
867 cx25840_write4(client, 0x10c, 0x01b6db7b);
868 cx25840_write4(client, 0x108, 0x00000512);
869 } else {
870 /* 888/HVR1250 or 50MHz xtal */
871 cx25840_write4(client, 0x10c, 0x13333333);
872 cx25840_write4(client, 0x108, 0x00000515);
873 }
874 break;
875 default:
876 cx25840_write4(client, 0x10c, 0x002be2c9);
877 cx25840_write4(client, 0x108, 0x0000040f);
878 }
879
880 /* Luma */
881 cx25840_write4(client, 0x414, 0x00107d12);
882
883 /* Chroma */
884 if (is_cx23888(state))
885 cx25840_write4(client, 0x418, 0x1d008282);
886 else
887 cx25840_write4(client, 0x420, 0x3d008282);
888
889 /*
890 * Aux PLL
891 * Initial setup for audio sample clock:
892 * 48 ksps, 16 bits/sample, x160 multiplier = 122.88 MHz
893 * Initial I2S output/master clock(?):
894 * 48 ksps, 16 bits/sample, x16 multiplier = 12.288 MHz
895 */
896 switch (state->id) {
897 case CX23888_AV:
898 /*
899 * 50.0 MHz * (0x7 + 0x0bedfa4/0x2000000)/3 = 122.88 MHz
900 * 368.64 MHz before post divide
901 * 122.88 MHz / 0xa = 12.288 MHz
902 */
903 /* HVR1850 or 50MHz xtal or 25MHz xtal */
904 cx25840_write4(client, 0x114, 0x017dbf48);
905 cx25840_write4(client, 0x110, 0x000a030e);
906 break;
907 case CX23887_AV:
908 /*
909 * 25.0 MHz * (0xe + 0x17dbf48/0x2000000)/3 = 122.88 MHz
910 * 368.64 MHz before post divide
911 * 122.88 MHz / 0xa = 12.288 MHz
912 */
913 cx25840_write4(client, 0x114, 0x017dbf48);
914 cx25840_write4(client, 0x110, 0x000a030e);
915 break;
916 case CX23885_AV:
917 default:
918 /*
919 * 28.636363 MHz * (0xc + 0x1bf0c9e/0x2000000)/3 = 122.88 MHz
920 * 368.64 MHz before post divide
921 * 122.88 MHz / 0xa = 12.288 MHz
922 */
923 cx25840_write4(client, 0x114, 0x01bf0c9e);
924 cx25840_write4(client, 0x110, 0x000a030c);
925 break;
926 }
927
928 /* ADC2 input select */
929 cx25840_write(client, 0x102, 0x10);
930
931 /* VIN1 & VIN5 */
932 cx25840_write(client, 0x103, 0x11);
933
934 /* Enable format auto detect */
935 cx25840_write(client, 0x400, 0);
936 /* Fast subchroma lock */
937 /* White crush, Chroma AGC & Chroma Killer enabled */
938 cx25840_write(client, 0x401, 0xe8);
939
940 /* Select AFE clock pad output source */
941 cx25840_write(client, 0x144, 0x05);
942
943 /* Drive GPIO2 direction and values for HVR1700
944 * where an onboard mux selects the output of demodulator
945 * vs the 417. Failure to set this results in no DTV.
946 * It's safe to set this across all Hauppauge boards
947 * currently, regardless of the board type.
948 */
949 cx25840_write(client, 0x160, 0x1d);
950 cx25840_write(client, 0x164, 0x00);
951
952 /*
953 * Do the firmware load in a work handler to prevent.
954 * Otherwise the kernel is blocked waiting for the
955 * bit-banging i2c interface to finish uploading the
956 * firmware.
957 */
958 INIT_WORK(&state->fw_work, cx25840_work_handler);
959 init_waitqueue_head(&state->fw_wait);
960 q = create_singlethread_workqueue("cx25840_fw");
961 if (q) {
962 prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
963 queue_work(q, &state->fw_work);
964 schedule();
965 finish_wait(&state->fw_wait, &wait);
966 destroy_workqueue(q);
967 }
968
969 /*
970 * Call the cx23888 specific std setup func, we no longer rely on
971 * the generic cx24840 func.
972 */
973 if (is_cx23888(state))
974 cx23888_std_setup(client);
975 else
976 cx25840_std_setup(client);
977
978 /* (re)set input */
979 set_input(client, state->vid_input, state->aud_input);
980
981 /* start microcontroller */
982 cx25840_and_or(client, 0x803, ~0x10, 0x10);
983
984 /* Disable and clear video interrupts - we don't use them */
985 cx25840_write4(client, CX25840_VID_INT_STAT_REG, 0xffffffff);
986
987 /* Disable and clear audio interrupts - we don't use them */
988 cx25840_write(client, CX25840_AUD_INT_CTRL_REG, 0xff);
989 cx25840_write(client, CX25840_AUD_INT_STAT_REG, 0xff);
990
991 /* CC raw enable */
992
993 /*
994 * - VIP 1.1 control codes - 10bit, blue field enable.
995 * - enable raw data during vertical blanking.
996 * - enable ancillary Data insertion for 656 or VIP.
997 */
998 cx25840_write4(client, 0x404, 0x0010253e);
999
1000 /* CC on - Undocumented Register */
1001 cx25840_write(client, state->vbi_regs_offset + 0x42f, 0x66);
1002
1003 /* HVR-1250 / HVR1850 DIF related */
1004 /* Power everything up */
1005 cx25840_write4(client, 0x130, 0x0);
1006
1007 /* Undocumented */
1008 if (is_cx23888(state))
1009 cx25840_write4(client, 0x454, 0x6628021F);
1010 else
1011 cx25840_write4(client, 0x478, 0x6628021F);
1012
1013 /* AFE_CLK_OUT_CTRL - Select the clock output source as output */
1014 cx25840_write4(client, 0x144, 0x5);
1015
1016 /* I2C_OUT_CTL - I2S output configuration as
1017 * Master, Sony, Left justified, left sample on WS=1
1018 */
1019 cx25840_write4(client, 0x918, 0x1a0);
1020
1021 /* AFE_DIAG_CTRL1 */
1022 cx25840_write4(client, 0x134, 0x000a1800);
1023
1024 /* AFE_DIAG_CTRL3 - Inverted Polarity for Audio and Video */
1025 cx25840_write4(client, 0x13c, 0x00310000);
1026 }
1027
1028 /* ----------------------------------------------------------------------- */
1029
cx231xx_initialize(struct i2c_client * client)1030 static void cx231xx_initialize(struct i2c_client *client)
1031 {
1032 DEFINE_WAIT(wait);
1033 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1034 struct workqueue_struct *q;
1035
1036 /* Internal Reset */
1037 cx25840_and_or(client, 0x102, ~0x01, 0x01);
1038 cx25840_and_or(client, 0x102, ~0x01, 0x00);
1039
1040 /* Stop microcontroller */
1041 cx25840_and_or(client, 0x803, ~0x10, 0x00);
1042
1043 /* DIF in reset? */
1044 cx25840_write(client, 0x398, 0);
1045
1046 /* Trust the default xtal, no division */
1047 /* This changes for the cx23888 products */
1048 cx25840_write(client, 0x2, 0x76);
1049
1050 /* Bring down the regulator for AUX clk */
1051 cx25840_write(client, 0x1, 0x40);
1052
1053 /* Disable DIF bypass */
1054 cx25840_write4(client, 0x33c, 0x00000001);
1055
1056 /* DIF Src phase inc */
1057 cx25840_write4(client, 0x340, 0x0df7df83);
1058
1059 /* Luma */
1060 cx25840_write4(client, 0x414, 0x00107d12);
1061
1062 /* Chroma */
1063 cx25840_write4(client, 0x420, 0x3d008282);
1064
1065 /* ADC2 input select */
1066 cx25840_write(client, 0x102, 0x10);
1067
1068 /* VIN1 & VIN5 */
1069 cx25840_write(client, 0x103, 0x11);
1070
1071 /* Enable format auto detect */
1072 cx25840_write(client, 0x400, 0);
1073 /* Fast subchroma lock */
1074 /* White crush, Chroma AGC & Chroma Killer enabled */
1075 cx25840_write(client, 0x401, 0xe8);
1076
1077 /*
1078 * Do the firmware load in a work handler to prevent.
1079 * Otherwise the kernel is blocked waiting for the
1080 * bit-banging i2c interface to finish uploading the
1081 * firmware.
1082 */
1083 INIT_WORK(&state->fw_work, cx25840_work_handler);
1084 init_waitqueue_head(&state->fw_wait);
1085 q = create_singlethread_workqueue("cx25840_fw");
1086 if (q) {
1087 prepare_to_wait(&state->fw_wait, &wait, TASK_UNINTERRUPTIBLE);
1088 queue_work(q, &state->fw_work);
1089 schedule();
1090 finish_wait(&state->fw_wait, &wait);
1091 destroy_workqueue(q);
1092 }
1093
1094 cx25840_std_setup(client);
1095
1096 /* (re)set input */
1097 set_input(client, state->vid_input, state->aud_input);
1098
1099 /* start microcontroller */
1100 cx25840_and_or(client, 0x803, ~0x10, 0x10);
1101
1102 /* CC raw enable */
1103 cx25840_write(client, 0x404, 0x0b);
1104
1105 /* CC on */
1106 cx25840_write(client, 0x42f, 0x66);
1107 cx25840_write4(client, 0x474, 0x1e1e601a);
1108 }
1109
1110 /* ----------------------------------------------------------------------- */
1111
cx25840_std_setup(struct i2c_client * client)1112 void cx25840_std_setup(struct i2c_client *client)
1113 {
1114 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1115 v4l2_std_id std = state->std;
1116 int hblank, hactive, burst, vblank, vactive, sc;
1117 int vblank656, src_decimation;
1118 int luma_lpf, uv_lpf, comb;
1119 u32 pll_int, pll_frac, pll_post;
1120
1121 /* datasheet startup, step 8d */
1122 if (std & ~V4L2_STD_NTSC)
1123 cx25840_write(client, 0x49f, 0x11);
1124 else
1125 cx25840_write(client, 0x49f, 0x14);
1126
1127 /* generic mode uses the values that the chip autoconfig would set */
1128 if (std & V4L2_STD_625_50) {
1129 hblank = 132;
1130 hactive = 720;
1131 burst = 93;
1132 if (state->generic_mode) {
1133 vblank = 34;
1134 vactive = 576;
1135 vblank656 = 38;
1136 } else {
1137 vblank = 36;
1138 vactive = 580;
1139 vblank656 = 40;
1140 }
1141 src_decimation = 0x21f;
1142 luma_lpf = 2;
1143
1144 if (std & V4L2_STD_SECAM) {
1145 uv_lpf = 0;
1146 comb = 0;
1147 sc = 0x0a425f;
1148 } else if (std == V4L2_STD_PAL_Nc) {
1149 if (state->generic_mode) {
1150 burst = 95;
1151 luma_lpf = 1;
1152 }
1153 uv_lpf = 1;
1154 comb = 0x20;
1155 sc = 556453;
1156 } else {
1157 uv_lpf = 1;
1158 comb = 0x20;
1159 sc = 688739;
1160 }
1161 } else {
1162 hactive = 720;
1163 hblank = 122;
1164 vactive = 487;
1165 luma_lpf = 1;
1166 uv_lpf = 1;
1167 if (state->generic_mode) {
1168 vblank = 20;
1169 vblank656 = 24;
1170 }
1171
1172 src_decimation = 0x21f;
1173 if (std == V4L2_STD_PAL_60) {
1174 if (!state->generic_mode) {
1175 vblank = 26;
1176 vblank656 = 26;
1177 burst = 0x5b;
1178 } else {
1179 burst = 0x59;
1180 }
1181 luma_lpf = 2;
1182 comb = 0x20;
1183 sc = 688739;
1184 } else if (std == V4L2_STD_PAL_M) {
1185 vblank = 20;
1186 vblank656 = 24;
1187 burst = 0x61;
1188 comb = 0x20;
1189 sc = 555452;
1190 } else {
1191 if (!state->generic_mode) {
1192 vblank = 26;
1193 vblank656 = 26;
1194 }
1195 burst = 0x5b;
1196 comb = 0x66;
1197 sc = 556063;
1198 }
1199 }
1200
1201 /* DEBUG: Displays configured PLL frequency */
1202 if (!is_cx231xx(state)) {
1203 pll_int = cx25840_read(client, 0x108);
1204 pll_frac = cx25840_read4(client, 0x10c) & 0x1ffffff;
1205 pll_post = cx25840_read(client, 0x109);
1206 v4l_dbg(1, cx25840_debug, client,
1207 "PLL regs = int: %u, frac: %u, post: %u\n",
1208 pll_int, pll_frac, pll_post);
1209
1210 if (pll_post) {
1211 int fin, fsc;
1212 int pll = (28636363L * ((((u64)pll_int) << 25L) + pll_frac)) >> 25L;
1213
1214 pll /= pll_post;
1215 v4l_dbg(1, cx25840_debug, client,
1216 "PLL = %d.%06d MHz\n",
1217 pll / 1000000, pll % 1000000);
1218 v4l_dbg(1, cx25840_debug, client,
1219 "PLL/8 = %d.%06d MHz\n",
1220 pll / 8000000, (pll / 8) % 1000000);
1221
1222 fin = ((u64)src_decimation * pll) >> 12;
1223 v4l_dbg(1, cx25840_debug, client,
1224 "ADC Sampling freq = %d.%06d MHz\n",
1225 fin / 1000000, fin % 1000000);
1226
1227 fsc = (((u64)sc) * pll) >> 24L;
1228 v4l_dbg(1, cx25840_debug, client,
1229 "Chroma sub-carrier freq = %d.%06d MHz\n",
1230 fsc / 1000000, fsc % 1000000);
1231
1232 v4l_dbg(1, cx25840_debug, client,
1233 "hblank %i, hactive %i, vblank %i, vactive %i, vblank656 %i, src_dec %i, burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x, sc 0x%06x\n",
1234 hblank, hactive, vblank, vactive, vblank656,
1235 src_decimation, burst, luma_lpf, uv_lpf,
1236 comb, sc);
1237 }
1238 }
1239
1240 /* Sets horizontal blanking delay and active lines */
1241 cx25840_write(client, 0x470, hblank);
1242 cx25840_write(client, 0x471,
1243 (((hblank >> 8) & 0x3) | (hactive << 4)) & 0xff);
1244 cx25840_write(client, 0x472, hactive >> 4);
1245
1246 /* Sets burst gate delay */
1247 cx25840_write(client, 0x473, burst);
1248
1249 /* Sets vertical blanking delay and active duration */
1250 cx25840_write(client, 0x474, vblank);
1251 cx25840_write(client, 0x475,
1252 (((vblank >> 8) & 0x3) | (vactive << 4)) & 0xff);
1253 cx25840_write(client, 0x476, vactive >> 4);
1254 cx25840_write(client, 0x477, vblank656);
1255
1256 /* Sets src decimation rate */
1257 cx25840_write(client, 0x478, src_decimation & 0xff);
1258 cx25840_write(client, 0x479, (src_decimation >> 8) & 0xff);
1259
1260 /* Sets Luma and UV Low pass filters */
1261 cx25840_write(client, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30));
1262
1263 /* Enables comb filters */
1264 cx25840_write(client, 0x47b, comb);
1265
1266 /* Sets SC Step*/
1267 cx25840_write(client, 0x47c, sc);
1268 cx25840_write(client, 0x47d, (sc >> 8) & 0xff);
1269 cx25840_write(client, 0x47e, (sc >> 16) & 0xff);
1270
1271 /* Sets VBI parameters */
1272 if (std & V4L2_STD_625_50) {
1273 cx25840_write(client, 0x47f, 0x01);
1274 state->vbi_line_offset = 5;
1275 } else {
1276 cx25840_write(client, 0x47f, 0x00);
1277 state->vbi_line_offset = 8;
1278 }
1279 }
1280
1281 /* ----------------------------------------------------------------------- */
1282
input_change(struct i2c_client * client)1283 static void input_change(struct i2c_client *client)
1284 {
1285 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1286 v4l2_std_id std = state->std;
1287
1288 /* Follow step 8c and 8d of section 3.16 in the cx25840 datasheet */
1289 if (std & V4L2_STD_SECAM) {
1290 cx25840_write(client, 0x402, 0);
1291 } else {
1292 cx25840_write(client, 0x402, 0x04);
1293 cx25840_write(client, 0x49f,
1294 (std & V4L2_STD_NTSC) ? 0x14 : 0x11);
1295 }
1296 cx25840_and_or(client, 0x401, ~0x60, 0);
1297 cx25840_and_or(client, 0x401, ~0x60, 0x60);
1298
1299 /* Don't write into audio registers on cx2583x chips */
1300 if (is_cx2583x(state))
1301 return;
1302
1303 cx25840_and_or(client, 0x810, ~0x01, 1);
1304
1305 if (state->radio) {
1306 cx25840_write(client, 0x808, 0xf9);
1307 cx25840_write(client, 0x80b, 0x00);
1308 } else if (std & V4L2_STD_525_60) {
1309 /*
1310 * Certain Hauppauge PVR150 models have a hardware bug
1311 * that causes audio to drop out. For these models the
1312 * audio standard must be set explicitly.
1313 * To be precise: it affects cards with tuner models
1314 * 85, 99 and 112 (model numbers from tveeprom).
1315 */
1316 int hw_fix = state->pvr150_workaround;
1317
1318 if (std == V4L2_STD_NTSC_M_JP) {
1319 /* Japan uses EIAJ audio standard */
1320 cx25840_write(client, 0x808, hw_fix ? 0x2f : 0xf7);
1321 } else if (std == V4L2_STD_NTSC_M_KR) {
1322 /* South Korea uses A2 audio standard */
1323 cx25840_write(client, 0x808, hw_fix ? 0x3f : 0xf8);
1324 } else {
1325 /* Others use the BTSC audio standard */
1326 cx25840_write(client, 0x808, hw_fix ? 0x1f : 0xf6);
1327 }
1328 cx25840_write(client, 0x80b, 0x00);
1329 } else if (std & V4L2_STD_PAL) {
1330 /* Autodetect audio standard and audio system */
1331 cx25840_write(client, 0x808, 0xff);
1332 /*
1333 * Since system PAL-L is pretty much non-existent and
1334 * not used by any public broadcast network, force
1335 * 6.5 MHz carrier to be interpreted as System DK,
1336 * this avoids DK audio detection instability
1337 */
1338 cx25840_write(client, 0x80b, 0x00);
1339 } else if (std & V4L2_STD_SECAM) {
1340 /* Autodetect audio standard and audio system */
1341 cx25840_write(client, 0x808, 0xff);
1342 /*
1343 * If only one of SECAM-DK / SECAM-L is required, then force
1344 * 6.5MHz carrier, else autodetect it
1345 */
1346 if ((std & V4L2_STD_SECAM_DK) &&
1347 !(std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) {
1348 /* 6.5 MHz carrier to be interpreted as System DK */
1349 cx25840_write(client, 0x80b, 0x00);
1350 } else if (!(std & V4L2_STD_SECAM_DK) &&
1351 (std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) {
1352 /* 6.5 MHz carrier to be interpreted as System L */
1353 cx25840_write(client, 0x80b, 0x08);
1354 } else {
1355 /* 6.5 MHz carrier to be autodetected */
1356 cx25840_write(client, 0x80b, 0x10);
1357 }
1358 }
1359
1360 cx25840_and_or(client, 0x810, ~0x01, 0);
1361 }
1362
set_input(struct i2c_client * client,enum cx25840_video_input vid_input,enum cx25840_audio_input aud_input)1363 static int set_input(struct i2c_client *client,
1364 enum cx25840_video_input vid_input,
1365 enum cx25840_audio_input aud_input)
1366 {
1367 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1368 u8 is_composite = (vid_input >= CX25840_COMPOSITE1 &&
1369 vid_input <= CX25840_COMPOSITE8);
1370 u8 is_component = (vid_input & CX25840_COMPONENT_ON) ==
1371 CX25840_COMPONENT_ON;
1372 u8 is_dif = (vid_input & CX25840_DIF_ON) ==
1373 CX25840_DIF_ON;
1374 u8 is_svideo = (vid_input & CX25840_SVIDEO_ON) ==
1375 CX25840_SVIDEO_ON;
1376 int luma = vid_input & 0xf0;
1377 int chroma = vid_input & 0xf00;
1378 u8 reg;
1379 u32 val;
1380
1381 v4l_dbg(1, cx25840_debug, client,
1382 "decoder set video input %d, audio input %d\n",
1383 vid_input, aud_input);
1384
1385 if (vid_input >= CX25840_VIN1_CH1) {
1386 v4l_dbg(1, cx25840_debug, client, "vid_input 0x%x\n",
1387 vid_input);
1388 reg = vid_input & 0xff;
1389 is_composite = !is_component &&
1390 ((vid_input & CX25840_SVIDEO_ON) != CX25840_SVIDEO_ON);
1391
1392 v4l_dbg(1, cx25840_debug, client, "mux cfg 0x%x comp=%d\n",
1393 reg, is_composite);
1394 } else if (is_composite) {
1395 reg = 0xf0 + (vid_input - CX25840_COMPOSITE1);
1396 } else {
1397 if ((vid_input & ~0xff0) ||
1398 luma < CX25840_SVIDEO_LUMA1 ||
1399 luma > CX25840_SVIDEO_LUMA8 ||
1400 chroma < CX25840_SVIDEO_CHROMA4 ||
1401 chroma > CX25840_SVIDEO_CHROMA8) {
1402 v4l_err(client, "0x%04x is not a valid video input!\n",
1403 vid_input);
1404 return -EINVAL;
1405 }
1406 reg = 0xf0 + ((luma - CX25840_SVIDEO_LUMA1) >> 4);
1407 if (chroma >= CX25840_SVIDEO_CHROMA7) {
1408 reg &= 0x3f;
1409 reg |= (chroma - CX25840_SVIDEO_CHROMA7) >> 2;
1410 } else {
1411 reg &= 0xcf;
1412 reg |= (chroma - CX25840_SVIDEO_CHROMA4) >> 4;
1413 }
1414 }
1415
1416 /* The caller has previously prepared the correct routing
1417 * configuration in reg (for the cx23885) so we have no
1418 * need to attempt to flip bits for earlier av decoders.
1419 */
1420 if (!is_cx2388x(state) && !is_cx231xx(state)) {
1421 switch (aud_input) {
1422 case CX25840_AUDIO_SERIAL:
1423 /* do nothing, use serial audio input */
1424 break;
1425 case CX25840_AUDIO4:
1426 reg &= ~0x30;
1427 break;
1428 case CX25840_AUDIO5:
1429 reg &= ~0x30;
1430 reg |= 0x10;
1431 break;
1432 case CX25840_AUDIO6:
1433 reg &= ~0x30;
1434 reg |= 0x20;
1435 break;
1436 case CX25840_AUDIO7:
1437 reg &= ~0xc0;
1438 break;
1439 case CX25840_AUDIO8:
1440 reg &= ~0xc0;
1441 reg |= 0x40;
1442 break;
1443 default:
1444 v4l_err(client, "0x%04x is not a valid audio input!\n",
1445 aud_input);
1446 return -EINVAL;
1447 }
1448 }
1449
1450 cx25840_write(client, 0x103, reg);
1451
1452 /* Set INPUT_MODE to Composite, S-Video or Component */
1453 if (is_component)
1454 cx25840_and_or(client, 0x401, ~0x6, 0x6);
1455 else
1456 cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02);
1457
1458 if (is_cx2388x(state)) {
1459 /* Enable or disable the DIF for tuner use */
1460 if (is_dif) {
1461 cx25840_and_or(client, 0x102, ~0x80, 0x80);
1462
1463 /* Set of defaults for NTSC and PAL */
1464 cx25840_write4(client, 0x31c, 0xc2262600);
1465 cx25840_write4(client, 0x320, 0xc2262600);
1466
1467 /* 18271 IF - Nobody else yet uses a different
1468 * tuner with the DIF, so these are reasonable
1469 * assumptions (HVR1250 and HVR1850 specific).
1470 */
1471 cx25840_write4(client, 0x318, 0xda262600);
1472 cx25840_write4(client, 0x33c, 0x2a24c800);
1473 cx25840_write4(client, 0x104, 0x0704dd00);
1474 } else {
1475 cx25840_write4(client, 0x300, 0x015c28f5);
1476
1477 cx25840_and_or(client, 0x102, ~0x80, 0);
1478 cx25840_write4(client, 0x340, 0xdf7df83);
1479 cx25840_write4(client, 0x104, 0x0704dd80);
1480 cx25840_write4(client, 0x314, 0x22400600);
1481 cx25840_write4(client, 0x318, 0x40002600);
1482 cx25840_write4(client, 0x324, 0x40002600);
1483 cx25840_write4(client, 0x32c, 0x0250e620);
1484 cx25840_write4(client, 0x39c, 0x01FF0B00);
1485
1486 cx25840_write4(client, 0x410, 0xffff0dbf);
1487 cx25840_write4(client, 0x414, 0x00137d03);
1488
1489 cx25840_write4(client, state->vbi_regs_offset + 0x42c,
1490 0x42600000);
1491 cx25840_write4(client, state->vbi_regs_offset + 0x430,
1492 0x0000039b);
1493 cx25840_write4(client, state->vbi_regs_offset + 0x438,
1494 0x00000000);
1495
1496 cx25840_write4(client, state->vbi_regs_offset + 0x440,
1497 0xF8E3E824);
1498 cx25840_write4(client, state->vbi_regs_offset + 0x444,
1499 0x401040dc);
1500 cx25840_write4(client, state->vbi_regs_offset + 0x448,
1501 0xcd3f02a0);
1502 cx25840_write4(client, state->vbi_regs_offset + 0x44c,
1503 0x161f1000);
1504 cx25840_write4(client, state->vbi_regs_offset + 0x450,
1505 0x00000802);
1506
1507 cx25840_write4(client, 0x91c, 0x01000000);
1508 cx25840_write4(client, 0x8e0, 0x03063870);
1509 cx25840_write4(client, 0x8d4, 0x7FFF0024);
1510 cx25840_write4(client, 0x8d0, 0x00063073);
1511
1512 cx25840_write4(client, 0x8c8, 0x00010000);
1513 cx25840_write4(client, 0x8cc, 0x00080023);
1514
1515 /* DIF BYPASS */
1516 cx25840_write4(client, 0x33c, 0x2a04c800);
1517 }
1518
1519 /* Reset the DIF */
1520 cx25840_write4(client, 0x398, 0);
1521 }
1522
1523 if (!is_cx2388x(state) && !is_cx231xx(state)) {
1524 /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */
1525 cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0);
1526 /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2&CH3 */
1527 if ((reg & 0xc0) != 0xc0 && (reg & 0x30) != 0x30)
1528 cx25840_and_or(client, 0x102, ~0x4, 4);
1529 else
1530 cx25840_and_or(client, 0x102, ~0x4, 0);
1531 } else {
1532 /* Set DUAL_MODE_ADC2 to 1 if component*/
1533 cx25840_and_or(client, 0x102, ~0x4, is_component ? 0x4 : 0x0);
1534 if (is_composite) {
1535 /* ADC2 input select channel 2 */
1536 cx25840_and_or(client, 0x102, ~0x2, 0);
1537 } else if (!is_component) {
1538 /* S-Video */
1539 if (chroma >= CX25840_SVIDEO_CHROMA7) {
1540 /* ADC2 input select channel 3 */
1541 cx25840_and_or(client, 0x102, ~0x2, 2);
1542 } else {
1543 /* ADC2 input select channel 2 */
1544 cx25840_and_or(client, 0x102, ~0x2, 0);
1545 }
1546 }
1547
1548 /* cx23885 / SVIDEO */
1549 if (is_cx2388x(state) && is_svideo) {
1550 #define AFE_CTRL (0x104)
1551 #define MODE_CTRL (0x400)
1552 cx25840_and_or(client, 0x102, ~0x2, 0x2);
1553
1554 val = cx25840_read4(client, MODE_CTRL);
1555 val &= 0xFFFFF9FF;
1556
1557 /* YC */
1558 val |= 0x00000200;
1559 val &= ~0x2000;
1560 cx25840_write4(client, MODE_CTRL, val);
1561
1562 val = cx25840_read4(client, AFE_CTRL);
1563
1564 /* Chroma in select */
1565 val |= 0x00001000;
1566 val &= 0xfffffe7f;
1567 /* Clear VGA_SEL_CH2 and VGA_SEL_CH3 (bits 7 and 8).
1568 * This sets them to use video rather than audio.
1569 * Only one of the two will be in use.
1570 */
1571 cx25840_write4(client, AFE_CTRL, val);
1572 } else {
1573 cx25840_and_or(client, 0x102, ~0x2, 0);
1574 }
1575 }
1576
1577 state->vid_input = vid_input;
1578 state->aud_input = aud_input;
1579 cx25840_audio_set_path(client);
1580 input_change(client);
1581
1582 if (is_cx2388x(state)) {
1583 /* Audio channel 1 src : Parallel 1 */
1584 cx25840_write(client, 0x124, 0x03);
1585
1586 /* Select AFE clock pad output source */
1587 cx25840_write(client, 0x144, 0x05);
1588
1589 /* I2S_IN_CTL: I2S_IN_SONY_MODE, LEFT SAMPLE on WS=1 */
1590 cx25840_write(client, 0x914, 0xa0);
1591
1592 /* I2S_OUT_CTL:
1593 * I2S_IN_SONY_MODE, LEFT SAMPLE on WS=1
1594 * I2S_OUT_MASTER_MODE = Master
1595 */
1596 cx25840_write(client, 0x918, 0xa0);
1597 cx25840_write(client, 0x919, 0x01);
1598 } else if (is_cx231xx(state)) {
1599 /* Audio channel 1 src : Parallel 1 */
1600 cx25840_write(client, 0x124, 0x03);
1601
1602 /* I2S_IN_CTL: I2S_IN_SONY_MODE, LEFT SAMPLE on WS=1 */
1603 cx25840_write(client, 0x914, 0xa0);
1604
1605 /* I2S_OUT_CTL:
1606 * I2S_IN_SONY_MODE, LEFT SAMPLE on WS=1
1607 * I2S_OUT_MASTER_MODE = Master
1608 */
1609 cx25840_write(client, 0x918, 0xa0);
1610 cx25840_write(client, 0x919, 0x01);
1611 }
1612
1613 if (is_cx2388x(state) &&
1614 ((aud_input == CX25840_AUDIO7) || (aud_input == CX25840_AUDIO6))) {
1615 /* Configure audio from LR1 or LR2 input */
1616 cx25840_write4(client, 0x910, 0);
1617 cx25840_write4(client, 0x8d0, 0x63073);
1618 } else if (is_cx2388x(state) && (aud_input == CX25840_AUDIO8)) {
1619 /* Configure audio from tuner/sif input */
1620 cx25840_write4(client, 0x910, 0x12b000c9);
1621 cx25840_write4(client, 0x8d0, 0x1f063870);
1622 }
1623
1624 if (is_cx23888(state)) {
1625 /*
1626 * HVR1850
1627 *
1628 * AUD_IO_CTRL - I2S Input, Parallel1
1629 * - Channel 1 src - Parallel1 (Merlin out)
1630 * - Channel 2 src - Parallel2 (Merlin out)
1631 * - Channel 3 src - Parallel3 (Merlin AC97 out)
1632 * - I2S source and dir - Merlin, output
1633 */
1634 cx25840_write4(client, 0x124, 0x100);
1635
1636 if (!is_dif) {
1637 /*
1638 * Stop microcontroller if we don't need it
1639 * to avoid audio popping on svideo/composite use.
1640 */
1641 cx25840_and_or(client, 0x803, ~0x10, 0x00);
1642 }
1643 }
1644
1645 return 0;
1646 }
1647
1648 /* ----------------------------------------------------------------------- */
1649
set_v4lstd(struct i2c_client * client)1650 static int set_v4lstd(struct i2c_client *client)
1651 {
1652 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1653 u8 fmt = 0; /* zero is autodetect */
1654 u8 pal_m = 0;
1655
1656 /* First tests should be against specific std */
1657 if (state->std == V4L2_STD_NTSC_M_JP) {
1658 fmt = 0x2;
1659 } else if (state->std == V4L2_STD_NTSC_443) {
1660 fmt = 0x3;
1661 } else if (state->std == V4L2_STD_PAL_M) {
1662 pal_m = 1;
1663 fmt = 0x5;
1664 } else if (state->std == V4L2_STD_PAL_N) {
1665 fmt = 0x6;
1666 } else if (state->std == V4L2_STD_PAL_Nc) {
1667 fmt = 0x7;
1668 } else if (state->std == V4L2_STD_PAL_60) {
1669 fmt = 0x8;
1670 } else {
1671 /* Then, test against generic ones */
1672 if (state->std & V4L2_STD_NTSC)
1673 fmt = 0x1;
1674 else if (state->std & V4L2_STD_PAL)
1675 fmt = 0x4;
1676 else if (state->std & V4L2_STD_SECAM)
1677 fmt = 0xc;
1678 }
1679
1680 v4l_dbg(1, cx25840_debug, client,
1681 "changing video std to fmt %i\n", fmt);
1682
1683 /*
1684 * Follow step 9 of section 3.16 in the cx25840 datasheet.
1685 * Without this PAL may display a vertical ghosting effect.
1686 * This happens for example with the Yuan MPC622.
1687 */
1688 if (fmt >= 4 && fmt < 8) {
1689 /* Set format to NTSC-M */
1690 cx25840_and_or(client, 0x400, ~0xf, 1);
1691 /* Turn off LCOMB */
1692 cx25840_and_or(client, 0x47b, ~6, 0);
1693 }
1694 cx25840_and_or(client, 0x400, ~0xf, fmt);
1695 cx25840_and_or(client, 0x403, ~0x3, pal_m);
1696 if (is_cx23888(state))
1697 cx23888_std_setup(client);
1698 else
1699 cx25840_std_setup(client);
1700 if (!is_cx2583x(state))
1701 input_change(client);
1702 return 0;
1703 }
1704
1705 /* ----------------------------------------------------------------------- */
1706
cx25840_s_ctrl(struct v4l2_ctrl * ctrl)1707 static int cx25840_s_ctrl(struct v4l2_ctrl *ctrl)
1708 {
1709 struct v4l2_subdev *sd = to_sd(ctrl);
1710 struct cx25840_state *state = to_state(sd);
1711 struct i2c_client *client = v4l2_get_subdevdata(sd);
1712
1713 switch (ctrl->id) {
1714 case V4L2_CID_BRIGHTNESS:
1715 cx25840_write(client, 0x414, ctrl->val - 128);
1716 break;
1717
1718 case V4L2_CID_CONTRAST:
1719 cx25840_write(client, 0x415, ctrl->val << 1);
1720 break;
1721
1722 case V4L2_CID_SATURATION:
1723 if (is_cx23888(state)) {
1724 cx25840_write(client, 0x418, ctrl->val << 1);
1725 cx25840_write(client, 0x419, ctrl->val << 1);
1726 } else {
1727 cx25840_write(client, 0x420, ctrl->val << 1);
1728 cx25840_write(client, 0x421, ctrl->val << 1);
1729 }
1730 break;
1731
1732 case V4L2_CID_HUE:
1733 if (is_cx23888(state))
1734 cx25840_write(client, 0x41a, ctrl->val);
1735 else
1736 cx25840_write(client, 0x422, ctrl->val);
1737 break;
1738
1739 default:
1740 return -EINVAL;
1741 }
1742
1743 return 0;
1744 }
1745
1746 /* ----------------------------------------------------------------------- */
1747
cx25840_set_fmt(struct v4l2_subdev * sd,struct v4l2_subdev_pad_config * cfg,struct v4l2_subdev_format * format)1748 static int cx25840_set_fmt(struct v4l2_subdev *sd,
1749 struct v4l2_subdev_pad_config *cfg,
1750 struct v4l2_subdev_format *format)
1751 {
1752 struct v4l2_mbus_framefmt *fmt = &format->format;
1753 struct cx25840_state *state = to_state(sd);
1754 struct i2c_client *client = v4l2_get_subdevdata(sd);
1755 u32 hsc, vsc, v_src, h_src, v_add;
1756 int filter;
1757 int is_50hz = !(state->std & V4L2_STD_525_60);
1758
1759 if (format->pad || fmt->code != MEDIA_BUS_FMT_FIXED)
1760 return -EINVAL;
1761
1762 fmt->field = V4L2_FIELD_INTERLACED;
1763 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
1764
1765 if (is_cx23888(state)) {
1766 v_src = (cx25840_read(client, 0x42a) & 0x3f) << 4;
1767 v_src |= (cx25840_read(client, 0x429) & 0xf0) >> 4;
1768 } else {
1769 v_src = (cx25840_read(client, 0x476) & 0x3f) << 4;
1770 v_src |= (cx25840_read(client, 0x475) & 0xf0) >> 4;
1771 }
1772
1773 if (is_cx23888(state)) {
1774 h_src = (cx25840_read(client, 0x426) & 0x3f) << 4;
1775 h_src |= (cx25840_read(client, 0x425) & 0xf0) >> 4;
1776 } else {
1777 h_src = (cx25840_read(client, 0x472) & 0x3f) << 4;
1778 h_src |= (cx25840_read(client, 0x471) & 0xf0) >> 4;
1779 }
1780
1781 if (!state->generic_mode) {
1782 v_add = is_50hz ? 4 : 7;
1783
1784 /*
1785 * cx23888 in 525-line mode is programmed for 486 active lines
1786 * while other chips use 487 active lines.
1787 *
1788 * See reg 0x428 bits [21:12] in cx23888_std_setup() vs
1789 * vactive in cx25840_std_setup().
1790 */
1791 if (is_cx23888(state) && !is_50hz)
1792 v_add--;
1793 } else {
1794 v_add = 0;
1795 }
1796
1797 if (h_src == 0 ||
1798 v_src <= v_add) {
1799 v4l_err(client,
1800 "chip reported picture size (%u x %u) is far too small\n",
1801 (unsigned int)h_src, (unsigned int)v_src);
1802 /*
1803 * that's the best we can do since the output picture
1804 * size is completely unknown in this case
1805 */
1806 return -EINVAL;
1807 }
1808
1809 fmt->width = clamp(fmt->width, (h_src + 15) / 16, h_src);
1810
1811 if (v_add * 8 >= v_src)
1812 fmt->height = clamp(fmt->height, (u32)1, v_src - v_add);
1813 else
1814 fmt->height = clamp(fmt->height, (v_src - v_add * 8 + 7) / 8,
1815 v_src - v_add);
1816
1817 if (format->which == V4L2_SUBDEV_FORMAT_TRY)
1818 return 0;
1819
1820 hsc = (h_src * (1 << 20)) / fmt->width - (1 << 20);
1821 vsc = (1 << 16) - (v_src * (1 << 9) / (fmt->height + v_add) - (1 << 9));
1822 vsc &= 0x1fff;
1823
1824 if (fmt->width >= 385)
1825 filter = 0;
1826 else if (fmt->width > 192)
1827 filter = 1;
1828 else if (fmt->width > 96)
1829 filter = 2;
1830 else
1831 filter = 3;
1832
1833 v4l_dbg(1, cx25840_debug, client,
1834 "decoder set size %u x %u with scale %x x %x\n",
1835 (unsigned int)fmt->width, (unsigned int)fmt->height,
1836 (unsigned int)hsc, (unsigned int)vsc);
1837
1838 /* HSCALE=hsc */
1839 if (is_cx23888(state)) {
1840 cx25840_write4(client, 0x434, hsc | (1 << 24));
1841 /* VSCALE=vsc VS_INTRLACE=1 VFILT=filter */
1842 cx25840_write4(client, 0x438, vsc | (1 << 19) | (filter << 16));
1843 } else {
1844 cx25840_write(client, 0x418, hsc & 0xff);
1845 cx25840_write(client, 0x419, (hsc >> 8) & 0xff);
1846 cx25840_write(client, 0x41a, hsc >> 16);
1847 /* VSCALE=vsc */
1848 cx25840_write(client, 0x41c, vsc & 0xff);
1849 cx25840_write(client, 0x41d, vsc >> 8);
1850 /* VS_INTRLACE=1 VFILT=filter */
1851 cx25840_write(client, 0x41e, 0x8 | filter);
1852 }
1853 return 0;
1854 }
1855
1856 /* ----------------------------------------------------------------------- */
1857
log_video_status(struct i2c_client * client)1858 static void log_video_status(struct i2c_client *client)
1859 {
1860 static const char *const fmt_strs[] = {
1861 "0x0",
1862 "NTSC-M", "NTSC-J", "NTSC-4.43",
1863 "PAL-BDGHI", "PAL-M", "PAL-N", "PAL-Nc", "PAL-60",
1864 "0x9", "0xA", "0xB",
1865 "SECAM",
1866 "0xD", "0xE", "0xF"
1867 };
1868
1869 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1870 u8 vidfmt_sel = cx25840_read(client, 0x400) & 0xf;
1871 u8 gen_stat1 = cx25840_read(client, 0x40d);
1872 u8 gen_stat2 = cx25840_read(client, 0x40e);
1873 int vid_input = state->vid_input;
1874
1875 v4l_info(client, "Video signal: %spresent\n",
1876 (gen_stat2 & 0x20) ? "" : "not ");
1877 v4l_info(client, "Detected format: %s\n",
1878 fmt_strs[gen_stat1 & 0xf]);
1879
1880 v4l_info(client, "Specified standard: %s\n",
1881 vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection");
1882
1883 if (vid_input >= CX25840_COMPOSITE1 &&
1884 vid_input <= CX25840_COMPOSITE8) {
1885 v4l_info(client, "Specified video input: Composite %d\n",
1886 vid_input - CX25840_COMPOSITE1 + 1);
1887 } else {
1888 v4l_info(client,
1889 "Specified video input: S-Video (Luma In%d, Chroma In%d)\n",
1890 (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8);
1891 }
1892
1893 v4l_info(client, "Specified audioclock freq: %d Hz\n",
1894 state->audclk_freq);
1895 }
1896
1897 /* ----------------------------------------------------------------------- */
1898
log_audio_status(struct i2c_client * client)1899 static void log_audio_status(struct i2c_client *client)
1900 {
1901 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1902 u8 download_ctl = cx25840_read(client, 0x803);
1903 u8 mod_det_stat0 = cx25840_read(client, 0x804);
1904 u8 mod_det_stat1 = cx25840_read(client, 0x805);
1905 u8 audio_config = cx25840_read(client, 0x808);
1906 u8 pref_mode = cx25840_read(client, 0x809);
1907 u8 afc0 = cx25840_read(client, 0x80b);
1908 u8 mute_ctl = cx25840_read(client, 0x8d3);
1909 int aud_input = state->aud_input;
1910 char *p;
1911
1912 switch (mod_det_stat0) {
1913 case 0x00:
1914 p = "mono";
1915 break;
1916 case 0x01:
1917 p = "stereo";
1918 break;
1919 case 0x02:
1920 p = "dual";
1921 break;
1922 case 0x04:
1923 p = "tri";
1924 break;
1925 case 0x10:
1926 p = "mono with SAP";
1927 break;
1928 case 0x11:
1929 p = "stereo with SAP";
1930 break;
1931 case 0x12:
1932 p = "dual with SAP";
1933 break;
1934 case 0x14:
1935 p = "tri with SAP";
1936 break;
1937 case 0xfe:
1938 p = "forced mode";
1939 break;
1940 default:
1941 p = "not defined";
1942 }
1943 v4l_info(client, "Detected audio mode: %s\n", p);
1944
1945 switch (mod_det_stat1) {
1946 case 0x00:
1947 p = "not defined";
1948 break;
1949 case 0x01:
1950 p = "EIAJ";
1951 break;
1952 case 0x02:
1953 p = "A2-M";
1954 break;
1955 case 0x03:
1956 p = "A2-BG";
1957 break;
1958 case 0x04:
1959 p = "A2-DK1";
1960 break;
1961 case 0x05:
1962 p = "A2-DK2";
1963 break;
1964 case 0x06:
1965 p = "A2-DK3";
1966 break;
1967 case 0x07:
1968 p = "A1 (6.0 MHz FM Mono)";
1969 break;
1970 case 0x08:
1971 p = "AM-L";
1972 break;
1973 case 0x09:
1974 p = "NICAM-BG";
1975 break;
1976 case 0x0a:
1977 p = "NICAM-DK";
1978 break;
1979 case 0x0b:
1980 p = "NICAM-I";
1981 break;
1982 case 0x0c:
1983 p = "NICAM-L";
1984 break;
1985 case 0x0d:
1986 p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)";
1987 break;
1988 case 0x0e:
1989 p = "IF FM Radio";
1990 break;
1991 case 0x0f:
1992 p = "BTSC";
1993 break;
1994 case 0x10:
1995 p = "high-deviation FM";
1996 break;
1997 case 0x11:
1998 p = "very high-deviation FM";
1999 break;
2000 case 0xfd:
2001 p = "unknown audio standard";
2002 break;
2003 case 0xfe:
2004 p = "forced audio standard";
2005 break;
2006 case 0xff:
2007 p = "no detected audio standard";
2008 break;
2009 default:
2010 p = "not defined";
2011 }
2012 v4l_info(client, "Detected audio standard: %s\n", p);
2013 v4l_info(client, "Audio microcontroller: %s\n",
2014 (download_ctl & 0x10) ?
2015 ((mute_ctl & 0x2) ? "detecting" : "running") : "stopped");
2016
2017 switch (audio_config >> 4) {
2018 case 0x00:
2019 p = "undefined";
2020 break;
2021 case 0x01:
2022 p = "BTSC";
2023 break;
2024 case 0x02:
2025 p = "EIAJ";
2026 break;
2027 case 0x03:
2028 p = "A2-M";
2029 break;
2030 case 0x04:
2031 p = "A2-BG";
2032 break;
2033 case 0x05:
2034 p = "A2-DK1";
2035 break;
2036 case 0x06:
2037 p = "A2-DK2";
2038 break;
2039 case 0x07:
2040 p = "A2-DK3";
2041 break;
2042 case 0x08:
2043 p = "A1 (6.0 MHz FM Mono)";
2044 break;
2045 case 0x09:
2046 p = "AM-L";
2047 break;
2048 case 0x0a:
2049 p = "NICAM-BG";
2050 break;
2051 case 0x0b:
2052 p = "NICAM-DK";
2053 break;
2054 case 0x0c:
2055 p = "NICAM-I";
2056 break;
2057 case 0x0d:
2058 p = "NICAM-L";
2059 break;
2060 case 0x0e:
2061 p = "FM radio";
2062 break;
2063 case 0x0f:
2064 p = "automatic detection";
2065 break;
2066 default:
2067 p = "undefined";
2068 }
2069 v4l_info(client, "Configured audio standard: %s\n", p);
2070
2071 if ((audio_config >> 4) < 0xF) {
2072 switch (audio_config & 0xF) {
2073 case 0x00:
2074 p = "MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)";
2075 break;
2076 case 0x01:
2077 p = "MONO2 (LANGUAGE B)";
2078 break;
2079 case 0x02:
2080 p = "MONO3 (STEREO forced MONO)";
2081 break;
2082 case 0x03:
2083 p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)";
2084 break;
2085 case 0x04:
2086 p = "STEREO";
2087 break;
2088 case 0x05:
2089 p = "DUAL1 (AB)";
2090 break;
2091 case 0x06:
2092 p = "DUAL2 (AC) (FM)";
2093 break;
2094 case 0x07:
2095 p = "DUAL3 (BC) (FM)";
2096 break;
2097 case 0x08:
2098 p = "DUAL4 (AC) (AM)";
2099 break;
2100 case 0x09:
2101 p = "DUAL5 (BC) (AM)";
2102 break;
2103 case 0x0a:
2104 p = "SAP";
2105 break;
2106 default:
2107 p = "undefined";
2108 }
2109 v4l_info(client, "Configured audio mode: %s\n", p);
2110 } else {
2111 switch (audio_config & 0xF) {
2112 case 0x00:
2113 p = "BG";
2114 break;
2115 case 0x01:
2116 p = "DK1";
2117 break;
2118 case 0x02:
2119 p = "DK2";
2120 break;
2121 case 0x03:
2122 p = "DK3";
2123 break;
2124 case 0x04:
2125 p = "I";
2126 break;
2127 case 0x05:
2128 p = "L";
2129 break;
2130 case 0x06:
2131 p = "BTSC";
2132 break;
2133 case 0x07:
2134 p = "EIAJ";
2135 break;
2136 case 0x08:
2137 p = "A2-M";
2138 break;
2139 case 0x09:
2140 p = "FM Radio";
2141 break;
2142 case 0x0f:
2143 p = "automatic standard and mode detection";
2144 break;
2145 default:
2146 p = "undefined";
2147 }
2148 v4l_info(client, "Configured audio system: %s\n", p);
2149 }
2150
2151 if (aud_input) {
2152 v4l_info(client, "Specified audio input: Tuner (In%d)\n",
2153 aud_input);
2154 } else {
2155 v4l_info(client, "Specified audio input: External\n");
2156 }
2157
2158 switch (pref_mode & 0xf) {
2159 case 0:
2160 p = "mono/language A";
2161 break;
2162 case 1:
2163 p = "language B";
2164 break;
2165 case 2:
2166 p = "language C";
2167 break;
2168 case 3:
2169 p = "analog fallback";
2170 break;
2171 case 4:
2172 p = "stereo";
2173 break;
2174 case 5:
2175 p = "language AC";
2176 break;
2177 case 6:
2178 p = "language BC";
2179 break;
2180 case 7:
2181 p = "language AB";
2182 break;
2183 default:
2184 p = "undefined";
2185 }
2186 v4l_info(client, "Preferred audio mode: %s\n", p);
2187
2188 if ((audio_config & 0xf) == 0xf) {
2189 switch ((afc0 >> 3) & 0x3) {
2190 case 0:
2191 p = "system DK";
2192 break;
2193 case 1:
2194 p = "system L";
2195 break;
2196 case 2:
2197 p = "autodetect";
2198 break;
2199 default:
2200 p = "undefined";
2201 }
2202 v4l_info(client, "Selected 65 MHz format: %s\n", p);
2203
2204 switch (afc0 & 0x7) {
2205 case 0:
2206 p = "chroma";
2207 break;
2208 case 1:
2209 p = "BTSC";
2210 break;
2211 case 2:
2212 p = "EIAJ";
2213 break;
2214 case 3:
2215 p = "A2-M";
2216 break;
2217 case 4:
2218 p = "autodetect";
2219 break;
2220 default:
2221 p = "undefined";
2222 }
2223 v4l_info(client, "Selected 45 MHz format: %s\n", p);
2224 }
2225 }
2226
2227 #define CX25840_VCONFIG_OPTION(state, cfg_in, opt_msk) \
2228 do { \
2229 if ((cfg_in) & (opt_msk)) { \
2230 (state)->vid_config &= ~(opt_msk); \
2231 (state)->vid_config |= (cfg_in) & (opt_msk); \
2232 } \
2233 } while (0)
2234
2235 /* apply incoming options to the current vconfig */
cx25840_vconfig_add(struct cx25840_state * state,u32 cfg_in)2236 static void cx25840_vconfig_add(struct cx25840_state *state, u32 cfg_in)
2237 {
2238 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_FMT_MASK);
2239 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_RES_MASK);
2240 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_VBIRAW_MASK);
2241 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_ANCDATA_MASK);
2242 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_TASKBIT_MASK);
2243 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_ACTIVE_MASK);
2244 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_VALID_MASK);
2245 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_HRESETW_MASK);
2246 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_CLKGATE_MASK);
2247 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_DCMODE_MASK);
2248 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_IDID0S_MASK);
2249 CX25840_VCONFIG_OPTION(state, cfg_in, CX25840_VCONFIG_VIPCLAMP_MASK);
2250 }
2251
2252 /* ----------------------------------------------------------------------- */
2253
2254 /*
2255 * Initializes the device in the generic mode.
2256 * For cx2584x chips also adds additional video output settings provided
2257 * in @val parameter (CX25840_VCONFIG_*).
2258 *
2259 * The generic mode disables some of the ivtv-related hacks in this driver.
2260 * For cx2584x chips it also enables setting video output configuration while
2261 * setting it according to datasheet defaults by default.
2262 */
cx25840_init(struct v4l2_subdev * sd,u32 val)2263 static int cx25840_init(struct v4l2_subdev *sd, u32 val)
2264 {
2265 struct cx25840_state *state = to_state(sd);
2266
2267 state->generic_mode = true;
2268
2269 if (is_cx2584x(state)) {
2270 /* set datasheet video output defaults */
2271 state->vid_config = CX25840_VCONFIG_FMT_BT656 |
2272 CX25840_VCONFIG_RES_8BIT |
2273 CX25840_VCONFIG_VBIRAW_DISABLED |
2274 CX25840_VCONFIG_ANCDATA_ENABLED |
2275 CX25840_VCONFIG_TASKBIT_ONE |
2276 CX25840_VCONFIG_ACTIVE_HORIZONTAL |
2277 CX25840_VCONFIG_VALID_NORMAL |
2278 CX25840_VCONFIG_HRESETW_NORMAL |
2279 CX25840_VCONFIG_CLKGATE_NONE |
2280 CX25840_VCONFIG_DCMODE_DWORDS |
2281 CX25840_VCONFIG_IDID0S_NORMAL |
2282 CX25840_VCONFIG_VIPCLAMP_DISABLED;
2283
2284 /* add additional settings */
2285 cx25840_vconfig_add(state, val);
2286 } else {
2287 /* TODO: generic mode needs to be developed for other chips */
2288 WARN_ON(1);
2289 }
2290
2291 return 0;
2292 }
2293
cx25840_reset(struct v4l2_subdev * sd,u32 val)2294 static int cx25840_reset(struct v4l2_subdev *sd, u32 val)
2295 {
2296 struct cx25840_state *state = to_state(sd);
2297 struct i2c_client *client = v4l2_get_subdevdata(sd);
2298
2299 if (is_cx2583x(state))
2300 cx25836_initialize(client);
2301 else if (is_cx2388x(state))
2302 cx23885_initialize(client);
2303 else if (is_cx231xx(state))
2304 cx231xx_initialize(client);
2305 else
2306 cx25840_initialize(client);
2307
2308 state->is_initialized = 1;
2309
2310 return 0;
2311 }
2312
2313 /*
2314 * This load_fw operation must be called to load the driver's firmware.
2315 * This will load the firmware on the first invocation (further ones are NOP).
2316 * Without this the audio standard detection will fail and you will
2317 * only get mono.
2318 * Alternatively, you can call the reset operation instead of this one.
2319 *
2320 * Since loading the firmware is often problematic when the driver is
2321 * compiled into the kernel I recommend postponing calling this function
2322 * until the first open of the video device. Another reason for
2323 * postponing it is that loading this firmware takes a long time (seconds)
2324 * due to the slow i2c bus speed. So it will speed up the boot process if
2325 * you can avoid loading the fw as long as the video device isn't used.
2326 */
cx25840_load_fw(struct v4l2_subdev * sd)2327 static int cx25840_load_fw(struct v4l2_subdev *sd)
2328 {
2329 struct cx25840_state *state = to_state(sd);
2330
2331 if (!state->is_initialized) {
2332 /* initialize and load firmware */
2333 cx25840_reset(sd, 0);
2334 }
2335 return 0;
2336 }
2337
2338 #ifdef CONFIG_VIDEO_ADV_DEBUG
cx25840_g_register(struct v4l2_subdev * sd,struct v4l2_dbg_register * reg)2339 static int cx25840_g_register(struct v4l2_subdev *sd,
2340 struct v4l2_dbg_register *reg)
2341 {
2342 struct i2c_client *client = v4l2_get_subdevdata(sd);
2343
2344 reg->size = 1;
2345 reg->val = cx25840_read(client, reg->reg & 0x0fff);
2346 return 0;
2347 }
2348
cx25840_s_register(struct v4l2_subdev * sd,const struct v4l2_dbg_register * reg)2349 static int cx25840_s_register(struct v4l2_subdev *sd,
2350 const struct v4l2_dbg_register *reg)
2351 {
2352 struct i2c_client *client = v4l2_get_subdevdata(sd);
2353
2354 cx25840_write(client, reg->reg & 0x0fff, reg->val & 0xff);
2355 return 0;
2356 }
2357 #endif
2358
cx25840_s_audio_stream(struct v4l2_subdev * sd,int enable)2359 static int cx25840_s_audio_stream(struct v4l2_subdev *sd, int enable)
2360 {
2361 struct cx25840_state *state = to_state(sd);
2362 struct i2c_client *client = v4l2_get_subdevdata(sd);
2363 u8 v;
2364
2365 if (is_cx2583x(state) || is_cx2388x(state) || is_cx231xx(state))
2366 return 0;
2367
2368 v4l_dbg(1, cx25840_debug, client, "%s audio output\n",
2369 enable ? "enable" : "disable");
2370
2371 if (enable) {
2372 v = cx25840_read(client, 0x115) | 0x80;
2373 cx25840_write(client, 0x115, v);
2374 v = cx25840_read(client, 0x116) | 0x03;
2375 cx25840_write(client, 0x116, v);
2376 } else {
2377 v = cx25840_read(client, 0x115) & ~(0x80);
2378 cx25840_write(client, 0x115, v);
2379 v = cx25840_read(client, 0x116) & ~(0x03);
2380 cx25840_write(client, 0x116, v);
2381 }
2382 return 0;
2383 }
2384
cx25840_s_stream(struct v4l2_subdev * sd,int enable)2385 static int cx25840_s_stream(struct v4l2_subdev *sd, int enable)
2386 {
2387 struct cx25840_state *state = to_state(sd);
2388 struct i2c_client *client = v4l2_get_subdevdata(sd);
2389 u8 v;
2390
2391 v4l_dbg(1, cx25840_debug, client, "%s video output\n",
2392 enable ? "enable" : "disable");
2393
2394 /*
2395 * It's not clear what should be done for these devices.
2396 * The original code used the same addresses as for the cx25840, but
2397 * those addresses do something else entirely on the cx2388x and
2398 * cx231xx. Since it never did anything in the first place, just do
2399 * nothing.
2400 */
2401 if (is_cx2388x(state) || is_cx231xx(state))
2402 return 0;
2403
2404 if (enable) {
2405 v = cx25840_read(client, 0x115) | 0x0c;
2406 cx25840_write(client, 0x115, v);
2407 v = cx25840_read(client, 0x116) | 0x04;
2408 cx25840_write(client, 0x116, v);
2409 } else {
2410 v = cx25840_read(client, 0x115) & ~(0x0c);
2411 cx25840_write(client, 0x115, v);
2412 v = cx25840_read(client, 0x116) & ~(0x04);
2413 cx25840_write(client, 0x116, v);
2414 }
2415 return 0;
2416 }
2417
2418 /* Query the current detected video format */
cx25840_querystd(struct v4l2_subdev * sd,v4l2_std_id * std)2419 static int cx25840_querystd(struct v4l2_subdev *sd, v4l2_std_id *std)
2420 {
2421 struct i2c_client *client = v4l2_get_subdevdata(sd);
2422
2423 static const v4l2_std_id stds[] = {
2424 /* 0000 */ V4L2_STD_UNKNOWN,
2425
2426 /* 0001 */ V4L2_STD_NTSC_M,
2427 /* 0010 */ V4L2_STD_NTSC_M_JP,
2428 /* 0011 */ V4L2_STD_NTSC_443,
2429 /* 0100 */ V4L2_STD_PAL,
2430 /* 0101 */ V4L2_STD_PAL_M,
2431 /* 0110 */ V4L2_STD_PAL_N,
2432 /* 0111 */ V4L2_STD_PAL_Nc,
2433 /* 1000 */ V4L2_STD_PAL_60,
2434
2435 /* 1001 */ V4L2_STD_UNKNOWN,
2436 /* 1010 */ V4L2_STD_UNKNOWN,
2437 /* 1011 */ V4L2_STD_UNKNOWN,
2438 /* 1100 */ V4L2_STD_SECAM,
2439 /* 1101 */ V4L2_STD_UNKNOWN,
2440 /* 1110 */ V4L2_STD_UNKNOWN,
2441 /* 1111 */ V4L2_STD_UNKNOWN
2442 };
2443
2444 u32 fmt = (cx25840_read4(client, 0x40c) >> 8) & 0xf;
2445 *std = stds[fmt];
2446
2447 v4l_dbg(1, cx25840_debug, client,
2448 "querystd fmt = %x, v4l2_std_id = 0x%x\n",
2449 fmt, (unsigned int)stds[fmt]);
2450
2451 return 0;
2452 }
2453
cx25840_g_input_status(struct v4l2_subdev * sd,u32 * status)2454 static int cx25840_g_input_status(struct v4l2_subdev *sd, u32 *status)
2455 {
2456 struct i2c_client *client = v4l2_get_subdevdata(sd);
2457
2458 /*
2459 * A limited function that checks for signal status and returns
2460 * the state.
2461 */
2462
2463 /* Check for status of Horizontal lock (SRC lock isn't reliable) */
2464 if ((cx25840_read4(client, 0x40c) & 0x00010000) == 0)
2465 *status |= V4L2_IN_ST_NO_SIGNAL;
2466
2467 return 0;
2468 }
2469
cx25840_g_std(struct v4l2_subdev * sd,v4l2_std_id * std)2470 static int cx25840_g_std(struct v4l2_subdev *sd, v4l2_std_id *std)
2471 {
2472 struct cx25840_state *state = to_state(sd);
2473
2474 *std = state->std;
2475
2476 return 0;
2477 }
2478
cx25840_s_std(struct v4l2_subdev * sd,v4l2_std_id std)2479 static int cx25840_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
2480 {
2481 struct cx25840_state *state = to_state(sd);
2482 struct i2c_client *client = v4l2_get_subdevdata(sd);
2483
2484 if (state->radio == 0 && state->std == std)
2485 return 0;
2486 state->radio = 0;
2487 state->std = std;
2488 return set_v4lstd(client);
2489 }
2490
cx25840_s_radio(struct v4l2_subdev * sd)2491 static int cx25840_s_radio(struct v4l2_subdev *sd)
2492 {
2493 struct cx25840_state *state = to_state(sd);
2494
2495 state->radio = 1;
2496 return 0;
2497 }
2498
cx25840_s_video_routing(struct v4l2_subdev * sd,u32 input,u32 output,u32 config)2499 static int cx25840_s_video_routing(struct v4l2_subdev *sd,
2500 u32 input, u32 output, u32 config)
2501 {
2502 struct cx25840_state *state = to_state(sd);
2503 struct i2c_client *client = v4l2_get_subdevdata(sd);
2504
2505 if (is_cx23888(state))
2506 cx23888_std_setup(client);
2507
2508 if (is_cx2584x(state) && state->generic_mode && config) {
2509 cx25840_vconfig_add(state, config);
2510 cx25840_vconfig_apply(client);
2511 }
2512
2513 return set_input(client, input, state->aud_input);
2514 }
2515
cx25840_s_audio_routing(struct v4l2_subdev * sd,u32 input,u32 output,u32 config)2516 static int cx25840_s_audio_routing(struct v4l2_subdev *sd,
2517 u32 input, u32 output, u32 config)
2518 {
2519 struct cx25840_state *state = to_state(sd);
2520 struct i2c_client *client = v4l2_get_subdevdata(sd);
2521
2522 if (is_cx23888(state))
2523 cx23888_std_setup(client);
2524 return set_input(client, state->vid_input, input);
2525 }
2526
cx25840_s_frequency(struct v4l2_subdev * sd,const struct v4l2_frequency * freq)2527 static int cx25840_s_frequency(struct v4l2_subdev *sd,
2528 const struct v4l2_frequency *freq)
2529 {
2530 struct i2c_client *client = v4l2_get_subdevdata(sd);
2531
2532 input_change(client);
2533 return 0;
2534 }
2535
cx25840_g_tuner(struct v4l2_subdev * sd,struct v4l2_tuner * vt)2536 static int cx25840_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
2537 {
2538 struct cx25840_state *state = to_state(sd);
2539 struct i2c_client *client = v4l2_get_subdevdata(sd);
2540 u8 vpres = cx25840_read(client, 0x40e) & 0x20;
2541 u8 mode;
2542 int val = 0;
2543
2544 if (state->radio)
2545 return 0;
2546
2547 vt->signal = vpres ? 0xffff : 0x0;
2548 if (is_cx2583x(state))
2549 return 0;
2550
2551 vt->capability |= V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 |
2552 V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
2553
2554 mode = cx25840_read(client, 0x804);
2555
2556 /* get rxsubchans and audmode */
2557 if ((mode & 0xf) == 1)
2558 val |= V4L2_TUNER_SUB_STEREO;
2559 else
2560 val |= V4L2_TUNER_SUB_MONO;
2561
2562 if (mode == 2 || mode == 4)
2563 val = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
2564
2565 if (mode & 0x10)
2566 val |= V4L2_TUNER_SUB_SAP;
2567
2568 vt->rxsubchans = val;
2569 vt->audmode = state->audmode;
2570 return 0;
2571 }
2572
cx25840_s_tuner(struct v4l2_subdev * sd,const struct v4l2_tuner * vt)2573 static int cx25840_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *vt)
2574 {
2575 struct cx25840_state *state = to_state(sd);
2576 struct i2c_client *client = v4l2_get_subdevdata(sd);
2577
2578 if (state->radio || is_cx2583x(state))
2579 return 0;
2580
2581 switch (vt->audmode) {
2582 case V4L2_TUNER_MODE_MONO:
2583 /*
2584 * mono -> mono
2585 * stereo -> mono
2586 * bilingual -> lang1
2587 */
2588 cx25840_and_or(client, 0x809, ~0xf, 0x00);
2589 break;
2590 case V4L2_TUNER_MODE_STEREO:
2591 case V4L2_TUNER_MODE_LANG1:
2592 /*
2593 * mono -> mono
2594 * stereo -> stereo
2595 * bilingual -> lang1
2596 */
2597 cx25840_and_or(client, 0x809, ~0xf, 0x04);
2598 break;
2599 case V4L2_TUNER_MODE_LANG1_LANG2:
2600 /*
2601 * mono -> mono
2602 * stereo -> stereo
2603 * bilingual -> lang1/lang2
2604 */
2605 cx25840_and_or(client, 0x809, ~0xf, 0x07);
2606 break;
2607 case V4L2_TUNER_MODE_LANG2:
2608 /*
2609 * mono -> mono
2610 * stereo -> stereo
2611 * bilingual -> lang2
2612 */
2613 cx25840_and_or(client, 0x809, ~0xf, 0x01);
2614 break;
2615 default:
2616 return -EINVAL;
2617 }
2618 state->audmode = vt->audmode;
2619 return 0;
2620 }
2621
cx25840_log_status(struct v4l2_subdev * sd)2622 static int cx25840_log_status(struct v4l2_subdev *sd)
2623 {
2624 struct cx25840_state *state = to_state(sd);
2625 struct i2c_client *client = v4l2_get_subdevdata(sd);
2626
2627 log_video_status(client);
2628 if (!is_cx2583x(state))
2629 log_audio_status(client);
2630 cx25840_ir_log_status(sd);
2631 v4l2_ctrl_handler_log_status(&state->hdl, sd->name);
2632 return 0;
2633 }
2634
cx23885_irq_handler(struct v4l2_subdev * sd,u32 status,bool * handled)2635 static int cx23885_irq_handler(struct v4l2_subdev *sd, u32 status,
2636 bool *handled)
2637 {
2638 struct cx25840_state *state = to_state(sd);
2639 struct i2c_client *c = v4l2_get_subdevdata(sd);
2640 u8 irq_stat, aud_stat, aud_en, ir_stat, ir_en;
2641 u32 vid_stat, aud_mc_stat;
2642 bool block_handled;
2643 int ret = 0;
2644
2645 irq_stat = cx25840_read(c, CX23885_PIN_CTRL_IRQ_REG);
2646 v4l_dbg(2, cx25840_debug, c, "AV Core IRQ status (entry): %s %s %s\n",
2647 irq_stat & CX23885_PIN_CTRL_IRQ_IR_STAT ? "ir" : " ",
2648 irq_stat & CX23885_PIN_CTRL_IRQ_AUD_STAT ? "aud" : " ",
2649 irq_stat & CX23885_PIN_CTRL_IRQ_VID_STAT ? "vid" : " ");
2650
2651 if ((is_cx23885(state) || is_cx23887(state))) {
2652 ir_stat = cx25840_read(c, CX25840_IR_STATS_REG);
2653 ir_en = cx25840_read(c, CX25840_IR_IRQEN_REG);
2654 v4l_dbg(2, cx25840_debug, c,
2655 "AV Core ir IRQ status: %#04x disables: %#04x\n",
2656 ir_stat, ir_en);
2657 if (irq_stat & CX23885_PIN_CTRL_IRQ_IR_STAT) {
2658 block_handled = false;
2659 ret = cx25840_ir_irq_handler(sd,
2660 status, &block_handled);
2661 if (block_handled)
2662 *handled = true;
2663 }
2664 }
2665
2666 aud_stat = cx25840_read(c, CX25840_AUD_INT_STAT_REG);
2667 aud_en = cx25840_read(c, CX25840_AUD_INT_CTRL_REG);
2668 v4l_dbg(2, cx25840_debug, c,
2669 "AV Core audio IRQ status: %#04x disables: %#04x\n",
2670 aud_stat, aud_en);
2671 aud_mc_stat = cx25840_read4(c, CX23885_AUD_MC_INT_MASK_REG);
2672 v4l_dbg(2, cx25840_debug, c,
2673 "AV Core audio MC IRQ status: %#06x enables: %#06x\n",
2674 aud_mc_stat >> CX23885_AUD_MC_INT_STAT_SHFT,
2675 aud_mc_stat & CX23885_AUD_MC_INT_CTRL_BITS);
2676 if (irq_stat & CX23885_PIN_CTRL_IRQ_AUD_STAT) {
2677 if (aud_stat) {
2678 cx25840_write(c, CX25840_AUD_INT_STAT_REG, aud_stat);
2679 *handled = true;
2680 }
2681 }
2682
2683 vid_stat = cx25840_read4(c, CX25840_VID_INT_STAT_REG);
2684 v4l_dbg(2, cx25840_debug, c,
2685 "AV Core video IRQ status: %#06x disables: %#06x\n",
2686 vid_stat & CX25840_VID_INT_STAT_BITS,
2687 vid_stat >> CX25840_VID_INT_MASK_SHFT);
2688 if (irq_stat & CX23885_PIN_CTRL_IRQ_VID_STAT) {
2689 if (vid_stat & CX25840_VID_INT_STAT_BITS) {
2690 cx25840_write4(c, CX25840_VID_INT_STAT_REG, vid_stat);
2691 *handled = true;
2692 }
2693 }
2694
2695 irq_stat = cx25840_read(c, CX23885_PIN_CTRL_IRQ_REG);
2696 v4l_dbg(2, cx25840_debug, c, "AV Core IRQ status (exit): %s %s %s\n",
2697 irq_stat & CX23885_PIN_CTRL_IRQ_IR_STAT ? "ir" : " ",
2698 irq_stat & CX23885_PIN_CTRL_IRQ_AUD_STAT ? "aud" : " ",
2699 irq_stat & CX23885_PIN_CTRL_IRQ_VID_STAT ? "vid" : " ");
2700
2701 return ret;
2702 }
2703
cx25840_irq_handler(struct v4l2_subdev * sd,u32 status,bool * handled)2704 static int cx25840_irq_handler(struct v4l2_subdev *sd, u32 status,
2705 bool *handled)
2706 {
2707 struct cx25840_state *state = to_state(sd);
2708
2709 *handled = false;
2710
2711 /* Only support the CX2388[578] AV Core for now */
2712 if (is_cx2388x(state))
2713 return cx23885_irq_handler(sd, status, handled);
2714
2715 return -ENODEV;
2716 }
2717
2718 /* ----------------------------------------------------------------------- */
2719
2720 #define DIF_PLL_FREQ_WORD (0x300)
2721 #define DIF_BPF_COEFF01 (0x348)
2722 #define DIF_BPF_COEFF23 (0x34c)
2723 #define DIF_BPF_COEFF45 (0x350)
2724 #define DIF_BPF_COEFF67 (0x354)
2725 #define DIF_BPF_COEFF89 (0x358)
2726 #define DIF_BPF_COEFF1011 (0x35c)
2727 #define DIF_BPF_COEFF1213 (0x360)
2728 #define DIF_BPF_COEFF1415 (0x364)
2729 #define DIF_BPF_COEFF1617 (0x368)
2730 #define DIF_BPF_COEFF1819 (0x36c)
2731 #define DIF_BPF_COEFF2021 (0x370)
2732 #define DIF_BPF_COEFF2223 (0x374)
2733 #define DIF_BPF_COEFF2425 (0x378)
2734 #define DIF_BPF_COEFF2627 (0x37c)
2735 #define DIF_BPF_COEFF2829 (0x380)
2736 #define DIF_BPF_COEFF3031 (0x384)
2737 #define DIF_BPF_COEFF3233 (0x388)
2738 #define DIF_BPF_COEFF3435 (0x38c)
2739 #define DIF_BPF_COEFF36 (0x390)
2740
cx23885_dif_setup(struct i2c_client * client,u32 ifHz)2741 static void cx23885_dif_setup(struct i2c_client *client, u32 ifHz)
2742 {
2743 u64 pll_freq;
2744 u32 pll_freq_word;
2745
2746 v4l_dbg(1, cx25840_debug, client, "%s(%d)\n", __func__, ifHz);
2747
2748 /* Assuming TV */
2749 /* Calculate the PLL frequency word based on the adjusted ifHz */
2750 pll_freq = div_u64((u64)ifHz * 268435456, 50000000);
2751 pll_freq_word = (u32)pll_freq;
2752
2753 cx25840_write4(client, DIF_PLL_FREQ_WORD, pll_freq_word);
2754
2755 /* Round down to the nearest 100KHz */
2756 ifHz = (ifHz / 100000) * 100000;
2757
2758 if (ifHz < 3000000)
2759 ifHz = 3000000;
2760
2761 if (ifHz > 16000000)
2762 ifHz = 16000000;
2763
2764 v4l_dbg(1, cx25840_debug, client, "%s(%d) again\n", __func__, ifHz);
2765
2766 switch (ifHz) {
2767 case 3000000:
2768 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
2769 cx25840_write4(client, DIF_BPF_COEFF23, 0x00080012);
2770 cx25840_write4(client, DIF_BPF_COEFF45, 0x001e0024);
2771 cx25840_write4(client, DIF_BPF_COEFF67, 0x001bfff8);
2772 cx25840_write4(client, DIF_BPF_COEFF89, 0xffb4ff50);
2773 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfed8fe68);
2774 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe24fe34);
2775 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfebaffc7);
2776 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014d031f);
2777 cx25840_write4(client, DIF_BPF_COEFF1819, 0x04f0065d);
2778 cx25840_write4(client, DIF_BPF_COEFF2021, 0x07010688);
2779 cx25840_write4(client, DIF_BPF_COEFF2223, 0x04c901d6);
2780 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfe00f9d3);
2781 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf600f342);
2782 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf235f337);
2783 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf64efb22);
2784 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0105070f);
2785 cx25840_write4(client, DIF_BPF_COEFF3435, 0x0c460fce);
2786 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2787 break;
2788
2789 case 3100000:
2790 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000001);
2791 cx25840_write4(client, DIF_BPF_COEFF23, 0x00070012);
2792 cx25840_write4(client, DIF_BPF_COEFF45, 0x00220032);
2793 cx25840_write4(client, DIF_BPF_COEFF67, 0x00370026);
2794 cx25840_write4(client, DIF_BPF_COEFF89, 0xfff0ff91);
2795 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff0efe7c);
2796 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe01fdcc);
2797 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe0afedb);
2798 cx25840_write4(client, DIF_BPF_COEFF1617, 0x00440224);
2799 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0434060c);
2800 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0738074e);
2801 cx25840_write4(client, DIF_BPF_COEFF2223, 0x06090361);
2802 cx25840_write4(client, DIF_BPF_COEFF2425, 0xff99fb39);
2803 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf6fef3b6);
2804 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf21af2a5);
2805 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf573fa33);
2806 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0034067d);
2807 cx25840_write4(client, DIF_BPF_COEFF3435, 0x0bfb0fb9);
2808 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2809 break;
2810
2811 case 3200000:
2812 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000000);
2813 cx25840_write4(client, DIF_BPF_COEFF23, 0x0004000e);
2814 cx25840_write4(client, DIF_BPF_COEFF45, 0x00200038);
2815 cx25840_write4(client, DIF_BPF_COEFF67, 0x004c004f);
2816 cx25840_write4(client, DIF_BPF_COEFF89, 0x002fffdf);
2817 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff5cfeb6);
2818 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe0dfd92);
2819 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd7ffe03);
2820 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff36010a);
2821 cx25840_write4(client, DIF_BPF_COEFF1819, 0x03410575);
2822 cx25840_write4(client, DIF_BPF_COEFF2021, 0x072607d2);
2823 cx25840_write4(client, DIF_BPF_COEFF2223, 0x071804d5);
2824 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0134fcb7);
2825 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf81ff451);
2826 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf223f22e);
2827 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf4a7f94b);
2828 cx25840_write4(client, DIF_BPF_COEFF3233, 0xff6405e8);
2829 cx25840_write4(client, DIF_BPF_COEFF3435, 0x0bae0fa4);
2830 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2831 break;
2832
2833 case 3300000:
2834 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000ffff);
2835 cx25840_write4(client, DIF_BPF_COEFF23, 0x00000008);
2836 cx25840_write4(client, DIF_BPF_COEFF45, 0x001a0036);
2837 cx25840_write4(client, DIF_BPF_COEFF67, 0x0056006d);
2838 cx25840_write4(client, DIF_BPF_COEFF89, 0x00670030);
2839 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffbdff10);
2840 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe46fd8d);
2841 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd25fd4f);
2842 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe35ffe0);
2843 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0224049f);
2844 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06c9080e);
2845 cx25840_write4(client, DIF_BPF_COEFF2223, 0x07ef0627);
2846 cx25840_write4(client, DIF_BPF_COEFF2425, 0x02c9fe45);
2847 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf961f513);
2848 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf250f1d2);
2849 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf3ecf869);
2850 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfe930552);
2851 cx25840_write4(client, DIF_BPF_COEFF3435, 0x0b5f0f8f);
2852 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2853 break;
2854
2855 case 3400000:
2856 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffe);
2857 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffd0001);
2858 cx25840_write4(client, DIF_BPF_COEFF45, 0x000f002c);
2859 cx25840_write4(client, DIF_BPF_COEFF67, 0x0054007d);
2860 cx25840_write4(client, DIF_BPF_COEFF89, 0x0093007c);
2861 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0024ff82);
2862 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfea6fdbb);
2863 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd03fcca);
2864 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd51feb9);
2865 cx25840_write4(client, DIF_BPF_COEFF1819, 0x00eb0392);
2866 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06270802);
2867 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08880750);
2868 cx25840_write4(client, DIF_BPF_COEFF2425, 0x044dffdb);
2869 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfabdf5f8);
2870 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf2a0f193);
2871 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf342f78f);
2872 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfdc404b9);
2873 cx25840_write4(client, DIF_BPF_COEFF3435, 0x0b0e0f78);
2874 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2875 break;
2876
2877 case 3500000:
2878 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffd);
2879 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffafff9);
2880 cx25840_write4(client, DIF_BPF_COEFF45, 0x0002001b);
2881 cx25840_write4(client, DIF_BPF_COEFF67, 0x0046007d);
2882 cx25840_write4(client, DIF_BPF_COEFF89, 0x00ad00ba);
2883 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00870000);
2884 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff26fe1a);
2885 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd1bfc7e);
2886 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99fda4);
2887 cx25840_write4(client, DIF_BPF_COEFF1819, 0xffa5025c);
2888 cx25840_write4(client, DIF_BPF_COEFF2021, 0x054507ad);
2889 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08dd0847);
2890 cx25840_write4(client, DIF_BPF_COEFF2425, 0x05b80172);
2891 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfc2ef6ff);
2892 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf313f170);
2893 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf2abf6bd);
2894 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfcf6041f);
2895 cx25840_write4(client, DIF_BPF_COEFF3435, 0x0abc0f61);
2896 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2897 break;
2898
2899 case 3600000:
2900 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffd);
2901 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fff3);
2902 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff50006);
2903 cx25840_write4(client, DIF_BPF_COEFF67, 0x002f006c);
2904 cx25840_write4(client, DIF_BPF_COEFF89, 0x00b200e3);
2905 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00dc007e);
2906 cx25840_write4(client, DIF_BPF_COEFF1213, 0xffb9fea0);
2907 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd6bfc71);
2908 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17fcb1);
2909 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfe65010b);
2910 cx25840_write4(client, DIF_BPF_COEFF2021, 0x042d0713);
2911 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08ec0906);
2912 cx25840_write4(client, DIF_BPF_COEFF2425, 0x07020302);
2913 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfdaff823);
2914 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf3a7f16a);
2915 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf228f5f5);
2916 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfc2a0384);
2917 cx25840_write4(client, DIF_BPF_COEFF3435, 0x0a670f4a);
2918 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2919 break;
2920
2921 case 3700000:
2922 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
2923 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff7ffef);
2924 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe9fff1);
2925 cx25840_write4(client, DIF_BPF_COEFF67, 0x0010004d);
2926 cx25840_write4(client, DIF_BPF_COEFF89, 0x00a100f2);
2927 cx25840_write4(client, DIF_BPF_COEFF1011, 0x011a00f0);
2928 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0053ff44);
2929 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfdedfca2);
2930 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3fbef);
2931 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfd39ffae);
2932 cx25840_write4(client, DIF_BPF_COEFF2021, 0x02ea0638);
2933 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08b50987);
2934 cx25840_write4(client, DIF_BPF_COEFF2425, 0x08230483);
2935 cx25840_write4(client, DIF_BPF_COEFF2627, 0xff39f960);
2936 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf45bf180);
2937 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf1b8f537);
2938 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfb6102e7);
2939 cx25840_write4(client, DIF_BPF_COEFF3435, 0x0a110f32);
2940 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2941 break;
2942
2943 case 3800000:
2944 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
2945 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff9ffee);
2946 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe1ffdd);
2947 cx25840_write4(client, DIF_BPF_COEFF67, 0xfff00024);
2948 cx25840_write4(client, DIF_BPF_COEFF89, 0x007c00e5);
2949 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013a014a);
2950 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00e6fff8);
2951 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe98fd0f);
2952 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3fb67);
2953 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfc32fe54);
2954 cx25840_write4(client, DIF_BPF_COEFF2021, 0x01880525);
2955 cx25840_write4(client, DIF_BPF_COEFF2223, 0x083909c7);
2956 cx25840_write4(client, DIF_BPF_COEFF2425, 0x091505ee);
2957 cx25840_write4(client, DIF_BPF_COEFF2627, 0x00c7fab3);
2958 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf52df1b4);
2959 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf15df484);
2960 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfa9b0249);
2961 cx25840_write4(client, DIF_BPF_COEFF3435, 0x09ba0f19);
2962 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2963 break;
2964
2965 case 3900000:
2966 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000000);
2967 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffbfff0);
2968 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdeffcf);
2969 cx25840_write4(client, DIF_BPF_COEFF67, 0xffd1fff6);
2970 cx25840_write4(client, DIF_BPF_COEFF89, 0x004800be);
2971 cx25840_write4(client, DIF_BPF_COEFF1011, 0x01390184);
2972 cx25840_write4(client, DIF_BPF_COEFF1213, 0x016300ac);
2973 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff5efdb1);
2974 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17fb23);
2975 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb5cfd0d);
2976 cx25840_write4(client, DIF_BPF_COEFF2021, 0x001703e4);
2977 cx25840_write4(client, DIF_BPF_COEFF2223, 0x077b09c4);
2978 cx25840_write4(client, DIF_BPF_COEFF2425, 0x09d2073c);
2979 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0251fc18);
2980 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf61cf203);
2981 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf118f3dc);
2982 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf9d801aa);
2983 cx25840_write4(client, DIF_BPF_COEFF3435, 0x09600eff);
2984 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
2985 break;
2986
2987 case 4000000:
2988 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000001);
2989 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffefff4);
2990 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe1ffc8);
2991 cx25840_write4(client, DIF_BPF_COEFF67, 0xffbaffca);
2992 cx25840_write4(client, DIF_BPF_COEFF89, 0x000b0082);
2993 cx25840_write4(client, DIF_BPF_COEFF1011, 0x01170198);
2994 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01c10152);
2995 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0030fe7b);
2996 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99fb24);
2997 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfac3fbe9);
2998 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfea5027f);
2999 cx25840_write4(client, DIF_BPF_COEFF2223, 0x0683097f);
3000 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a560867);
3001 cx25840_write4(client, DIF_BPF_COEFF2627, 0x03d2fd89);
3002 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf723f26f);
3003 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0e8f341);
3004 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf919010a);
3005 cx25840_write4(client, DIF_BPF_COEFF3435, 0x09060ee5);
3006 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3007 break;
3008
3009 case 4100000:
3010 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010002);
3011 cx25840_write4(client, DIF_BPF_COEFF23, 0x0002fffb);
3012 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe8ffca);
3013 cx25840_write4(client, DIF_BPF_COEFF67, 0xffacffa4);
3014 cx25840_write4(client, DIF_BPF_COEFF89, 0xffcd0036);
3015 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00d70184);
3016 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01f601dc);
3017 cx25840_write4(client, DIF_BPF_COEFF1415, 0x00ffff60);
3018 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd51fb6d);
3019 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa6efaf5);
3020 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfd410103);
3021 cx25840_write4(client, DIF_BPF_COEFF2223, 0x055708f9);
3022 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a9e0969);
3023 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0543ff02);
3024 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf842f2f5);
3025 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0cef2b2);
3026 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf85e006b);
3027 cx25840_write4(client, DIF_BPF_COEFF3435, 0x08aa0ecb);
3028 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3029 break;
3030
3031 case 4200000:
3032 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010003);
3033 cx25840_write4(client, DIF_BPF_COEFF23, 0x00050003);
3034 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff3ffd3);
3035 cx25840_write4(client, DIF_BPF_COEFF67, 0xffaaff8b);
3036 cx25840_write4(client, DIF_BPF_COEFF89, 0xff95ffe5);
3037 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0080014a);
3038 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01fe023f);
3039 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01ba0050);
3040 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe35fbf8);
3041 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa62fa3b);
3042 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfbf9ff7e);
3043 cx25840_write4(client, DIF_BPF_COEFF2223, 0x04010836);
3044 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0aa90a3d);
3045 cx25840_write4(client, DIF_BPF_COEFF2627, 0x069f007f);
3046 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf975f395);
3047 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0cbf231);
3048 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf7a9ffcb);
3049 cx25840_write4(client, DIF_BPF_COEFF3435, 0x084c0eaf);
3050 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3051 break;
3052
3053 case 4300000:
3054 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010003);
3055 cx25840_write4(client, DIF_BPF_COEFF23, 0x0008000a);
3056 cx25840_write4(client, DIF_BPF_COEFF45, 0x0000ffe4);
3057 cx25840_write4(client, DIF_BPF_COEFF67, 0xffb4ff81);
3058 cx25840_write4(client, DIF_BPF_COEFF89, 0xff6aff96);
3059 cx25840_write4(client, DIF_BPF_COEFF1011, 0x001c00f0);
3060 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01d70271);
3061 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0254013b);
3062 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff36fcbd);
3063 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa9ff9c5);
3064 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfadbfdfe);
3065 cx25840_write4(client, DIF_BPF_COEFF2223, 0x028c073b);
3066 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a750adf);
3067 cx25840_write4(client, DIF_BPF_COEFF2627, 0x07e101fa);
3068 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfab8f44e);
3069 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0ddf1be);
3070 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf6f9ff2b);
3071 cx25840_write4(client, DIF_BPF_COEFF3435, 0x07ed0e94);
3072 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3073 break;
3074
3075 case 4400000:
3076 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
3077 cx25840_write4(client, DIF_BPF_COEFF23, 0x0009000f);
3078 cx25840_write4(client, DIF_BPF_COEFF45, 0x000efff8);
3079 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc9ff87);
3080 cx25840_write4(client, DIF_BPF_COEFF89, 0xff52ff54);
3081 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffb5007e);
3082 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01860270);
3083 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02c00210);
3084 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0044fdb2);
3085 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb22f997);
3086 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf9f2fc90);
3087 cx25840_write4(client, DIF_BPF_COEFF2223, 0x0102060f);
3088 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a050b4c);
3089 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0902036e);
3090 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfc0af51e);
3091 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf106f15a);
3092 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf64efe8b);
3093 cx25840_write4(client, DIF_BPF_COEFF3435, 0x078d0e77);
3094 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3095 break;
3096
3097 case 4500000:
3098 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
3099 cx25840_write4(client, DIF_BPF_COEFF23, 0x00080012);
3100 cx25840_write4(client, DIF_BPF_COEFF45, 0x0019000e);
3101 cx25840_write4(client, DIF_BPF_COEFF67, 0xffe5ff9e);
3102 cx25840_write4(client, DIF_BPF_COEFF89, 0xff4fff25);
3103 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff560000);
3104 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0112023b);
3105 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02f702c0);
3106 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014dfec8);
3107 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfbe5f9b3);
3108 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf947fb41);
3109 cx25840_write4(client, DIF_BPF_COEFF2223, 0xff7004b9);
3110 cx25840_write4(client, DIF_BPF_COEFF2425, 0x095a0b81);
3111 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0a0004d8);
3112 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfd65f603);
3113 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf144f104);
3114 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf5aafdec);
3115 cx25840_write4(client, DIF_BPF_COEFF3435, 0x072b0e5a);
3116 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3117 break;
3118
3119 case 4600000:
3120 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000001);
3121 cx25840_write4(client, DIF_BPF_COEFF23, 0x00060012);
3122 cx25840_write4(client, DIF_BPF_COEFF45, 0x00200022);
3123 cx25840_write4(client, DIF_BPF_COEFF67, 0x0005ffc1);
3124 cx25840_write4(client, DIF_BPF_COEFF89, 0xff61ff10);
3125 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff09ff82);
3126 cx25840_write4(client, DIF_BPF_COEFF1213, 0x008601d7);
3127 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02f50340);
3128 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0241fff0);
3129 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfcddfa19);
3130 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8e2fa1e);
3131 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfde30343);
3132 cx25840_write4(client, DIF_BPF_COEFF2425, 0x08790b7f);
3133 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0ad50631);
3134 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfec7f6fc);
3135 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf198f0bd);
3136 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf50dfd4e);
3137 cx25840_write4(client, DIF_BPF_COEFF3435, 0x06c90e3d);
3138 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3139 break;
3140
3141 case 4700000:
3142 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000ffff);
3143 cx25840_write4(client, DIF_BPF_COEFF23, 0x0003000f);
3144 cx25840_write4(client, DIF_BPF_COEFF45, 0x00220030);
3145 cx25840_write4(client, DIF_BPF_COEFF67, 0x0025ffed);
3146 cx25840_write4(client, DIF_BPF_COEFF89, 0xff87ff15);
3147 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfed6ff10);
3148 cx25840_write4(client, DIF_BPF_COEFF1213, 0xffed014c);
3149 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02b90386);
3150 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03110119);
3151 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfdfefac4);
3152 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8c6f92f);
3153 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfc6701b7);
3154 cx25840_write4(client, DIF_BPF_COEFF2425, 0x07670b44);
3155 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0b7e0776);
3156 cx25840_write4(client, DIF_BPF_COEFF2829, 0x002df807);
3157 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf200f086);
3158 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf477fcb1);
3159 cx25840_write4(client, DIF_BPF_COEFF3435, 0x06650e1e);
3160 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3161 break;
3162
3163 case 4800000:
3164 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffe);
3165 cx25840_write4(client, DIF_BPF_COEFF23, 0xffff0009);
3166 cx25840_write4(client, DIF_BPF_COEFF45, 0x001e0038);
3167 cx25840_write4(client, DIF_BPF_COEFF67, 0x003f001b);
3168 cx25840_write4(client, DIF_BPF_COEFF89, 0xffbcff36);
3169 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfec2feb6);
3170 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff5600a5);
3171 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0248038d);
3172 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b00232);
3173 cx25840_write4(client, DIF_BPF_COEFF1819, 0xff39fbab);
3174 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8f4f87f);
3175 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfb060020);
3176 cx25840_write4(client, DIF_BPF_COEFF2425, 0x062a0ad2);
3177 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0bf908a3);
3178 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0192f922);
3179 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf27df05e);
3180 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf3e8fc14);
3181 cx25840_write4(client, DIF_BPF_COEFF3435, 0x06000e00);
3182 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3183 break;
3184
3185 case 4900000:
3186 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffd);
3187 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffc0002);
3188 cx25840_write4(client, DIF_BPF_COEFF45, 0x00160037);
3189 cx25840_write4(client, DIF_BPF_COEFF67, 0x00510046);
3190 cx25840_write4(client, DIF_BPF_COEFF89, 0xfff9ff6d);
3191 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfed0fe7c);
3192 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfecefff0);
3193 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01aa0356);
3194 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0413032b);
3195 cx25840_write4(client, DIF_BPF_COEFF1819, 0x007ffcc5);
3196 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf96cf812);
3197 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf9cefe87);
3198 cx25840_write4(client, DIF_BPF_COEFF2425, 0x04c90a2c);
3199 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c4309b4);
3200 cx25840_write4(client, DIF_BPF_COEFF2829, 0x02f3fa4a);
3201 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf30ef046);
3202 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf361fb7a);
3203 cx25840_write4(client, DIF_BPF_COEFF3435, 0x059b0de0);
3204 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3205 break;
3206
3207 case 5000000:
3208 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffd);
3209 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff9fffa);
3210 cx25840_write4(client, DIF_BPF_COEFF45, 0x000a002d);
3211 cx25840_write4(client, DIF_BPF_COEFF67, 0x00570067);
3212 cx25840_write4(client, DIF_BPF_COEFF89, 0x0037ffb5);
3213 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfefffe68);
3214 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe62ff3d);
3215 cx25840_write4(client, DIF_BPF_COEFF1415, 0x00ec02e3);
3216 cx25840_write4(client, DIF_BPF_COEFF1617, 0x043503f6);
3217 cx25840_write4(client, DIF_BPF_COEFF1819, 0x01befe05);
3218 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfa27f7ee);
3219 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf8c6fcf8);
3220 cx25840_write4(client, DIF_BPF_COEFF2425, 0x034c0954);
3221 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c5c0aa4);
3222 cx25840_write4(client, DIF_BPF_COEFF2829, 0x044cfb7e);
3223 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf3b1f03f);
3224 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf2e2fae1);
3225 cx25840_write4(client, DIF_BPF_COEFF3435, 0x05340dc0);
3226 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3227 break;
3228
3229 case 5100000:
3230 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
3231 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fff4);
3232 cx25840_write4(client, DIF_BPF_COEFF45, 0xfffd001e);
3233 cx25840_write4(client, DIF_BPF_COEFF67, 0x0051007b);
3234 cx25840_write4(client, DIF_BPF_COEFF89, 0x006e0006);
3235 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff48fe7c);
3236 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe1bfe9a);
3237 cx25840_write4(client, DIF_BPF_COEFF1415, 0x001d023e);
3238 cx25840_write4(client, DIF_BPF_COEFF1617, 0x04130488);
3239 cx25840_write4(client, DIF_BPF_COEFF1819, 0x02e6ff5b);
3240 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfb1ef812);
3241 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf7f7fb7f);
3242 cx25840_write4(client, DIF_BPF_COEFF2425, 0x01bc084e);
3243 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c430b72);
3244 cx25840_write4(client, DIF_BPF_COEFF2829, 0x059afcba);
3245 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf467f046);
3246 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf26cfa4a);
3247 cx25840_write4(client, DIF_BPF_COEFF3435, 0x04cd0da0);
3248 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3249 break;
3250
3251 case 5200000:
3252 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
3253 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8ffef);
3254 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff00009);
3255 cx25840_write4(client, DIF_BPF_COEFF67, 0x003f007f);
3256 cx25840_write4(client, DIF_BPF_COEFF89, 0x00980056);
3257 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffa5feb6);
3258 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe00fe15);
3259 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff4b0170);
3260 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b004d7);
3261 cx25840_write4(client, DIF_BPF_COEFF1819, 0x03e800b9);
3262 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfc48f87f);
3263 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf768fa23);
3264 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0022071f);
3265 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0bf90c1b);
3266 cx25840_write4(client, DIF_BPF_COEFF2829, 0x06dafdfd);
3267 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf52df05e);
3268 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf1fef9b5);
3269 cx25840_write4(client, DIF_BPF_COEFF3435, 0x04640d7f);
3270 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3271 break;
3272
3273 case 5300000:
3274 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000ffff);
3275 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff9ffee);
3276 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe6fff3);
3277 cx25840_write4(client, DIF_BPF_COEFF67, 0x00250072);
3278 cx25840_write4(client, DIF_BPF_COEFF89, 0x00af009c);
3279 cx25840_write4(client, DIF_BPF_COEFF1011, 0x000cff10);
3280 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe13fdb8);
3281 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe870089);
3282 cx25840_write4(client, DIF_BPF_COEFF1617, 0x031104e1);
3283 cx25840_write4(client, DIF_BPF_COEFF1819, 0x04b8020f);
3284 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfd98f92f);
3285 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf71df8f0);
3286 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfe8805ce);
3287 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0b7e0c9c);
3288 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0808ff44);
3289 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf603f086);
3290 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf19af922);
3291 cx25840_write4(client, DIF_BPF_COEFF3435, 0x03fb0d5e);
3292 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3293 break;
3294
3295 case 5400000:
3296 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000001);
3297 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffcffef);
3298 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe0ffe0);
3299 cx25840_write4(client, DIF_BPF_COEFF67, 0x00050056);
3300 cx25840_write4(client, DIF_BPF_COEFF89, 0x00b000d1);
3301 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0071ff82);
3302 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe53fd8c);
3303 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfddfff99);
3304 cx25840_write4(client, DIF_BPF_COEFF1617, 0x024104a3);
3305 cx25840_write4(client, DIF_BPF_COEFF1819, 0x054a034d);
3306 cx25840_write4(client, DIF_BPF_COEFF2021, 0xff01fa1e);
3307 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf717f7ed);
3308 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfcf50461);
3309 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0ad50cf4);
3310 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0921008d);
3311 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf6e7f0bd);
3312 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf13ff891);
3313 cx25840_write4(client, DIF_BPF_COEFF3435, 0x03920d3b);
3314 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3315 break;
3316
3317 case 5500000:
3318 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010002);
3319 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffffff3);
3320 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdeffd1);
3321 cx25840_write4(client, DIF_BPF_COEFF67, 0xffe5002f);
3322 cx25840_write4(client, DIF_BPF_COEFF89, 0x009c00ed);
3323 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00cb0000);
3324 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfebafd94);
3325 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd61feb0);
3326 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014d0422);
3327 cx25840_write4(client, DIF_BPF_COEFF1819, 0x05970464);
3328 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0074fb41);
3329 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf759f721);
3330 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfb7502de);
3331 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0a000d21);
3332 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0a2201d4);
3333 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf7d9f104);
3334 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf0edf804);
3335 cx25840_write4(client, DIF_BPF_COEFF3435, 0x03280d19);
3336 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3337 break;
3338
3339 case 5600000:
3340 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010003);
3341 cx25840_write4(client, DIF_BPF_COEFF23, 0x0003fffa);
3342 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe3ffc9);
3343 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc90002);
3344 cx25840_write4(client, DIF_BPF_COEFF89, 0x007500ef);
3345 cx25840_write4(client, DIF_BPF_COEFF1011, 0x010e007e);
3346 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff3dfdcf);
3347 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd16fddd);
3348 cx25840_write4(client, DIF_BPF_COEFF1617, 0x00440365);
3349 cx25840_write4(client, DIF_BPF_COEFF1819, 0x059b0548);
3350 cx25840_write4(client, DIF_BPF_COEFF2021, 0x01e3fc90);
3351 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf7dff691);
3352 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfa0f014d);
3353 cx25840_write4(client, DIF_BPF_COEFF2627, 0x09020d23);
3354 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0b0a0318);
3355 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf8d7f15a);
3356 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf0a5f779);
3357 cx25840_write4(client, DIF_BPF_COEFF3435, 0x02bd0cf6);
3358 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3359 break;
3360
3361 case 5700000:
3362 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010003);
3363 cx25840_write4(client, DIF_BPF_COEFF23, 0x00060001);
3364 cx25840_write4(client, DIF_BPF_COEFF45, 0xffecffc9);
3365 cx25840_write4(client, DIF_BPF_COEFF67, 0xffb4ffd4);
3366 cx25840_write4(client, DIF_BPF_COEFF89, 0x004000d5);
3367 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013600f0);
3368 cx25840_write4(client, DIF_BPF_COEFF1213, 0xffd3fe39);
3369 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd04fd31);
3370 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff360277);
3371 cx25840_write4(client, DIF_BPF_COEFF1819, 0x055605ef);
3372 cx25840_write4(client, DIF_BPF_COEFF2021, 0x033efdfe);
3373 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf8a5f642);
3374 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf8cbffb6);
3375 cx25840_write4(client, DIF_BPF_COEFF2627, 0x07e10cfb);
3376 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0bd50456);
3377 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf9dff1be);
3378 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf067f6f2);
3379 cx25840_write4(client, DIF_BPF_COEFF3435, 0x02520cd2);
3380 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3381 break;
3382
3383 case 5800000:
3384 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
3385 cx25840_write4(client, DIF_BPF_COEFF23, 0x00080009);
3386 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff8ffd2);
3387 cx25840_write4(client, DIF_BPF_COEFF67, 0xffaaffac);
3388 cx25840_write4(client, DIF_BPF_COEFF89, 0x000200a3);
3389 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013c014a);
3390 cx25840_write4(client, DIF_BPF_COEFF1213, 0x006dfec9);
3391 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd2bfcb7);
3392 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe350165);
3393 cx25840_write4(client, DIF_BPF_COEFF1819, 0x04cb0651);
3394 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0477ff7e);
3395 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf9a5f635);
3396 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf7b1fe20);
3397 cx25840_write4(client, DIF_BPF_COEFF2627, 0x069f0ca8);
3398 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0c81058b);
3399 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfaf0f231);
3400 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf033f66d);
3401 cx25840_write4(client, DIF_BPF_COEFF3435, 0x01e60cae);
3402 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3403 break;
3404
3405 case 5900000:
3406 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
3407 cx25840_write4(client, DIF_BPF_COEFF23, 0x0009000e);
3408 cx25840_write4(client, DIF_BPF_COEFF45, 0x0005ffe1);
3409 cx25840_write4(client, DIF_BPF_COEFF67, 0xffacff90);
3410 cx25840_write4(client, DIF_BPF_COEFF89, 0xffc5005f);
3411 cx25840_write4(client, DIF_BPF_COEFF1011, 0x01210184);
3412 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00fcff72);
3413 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd8afc77);
3414 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd51003f);
3415 cx25840_write4(client, DIF_BPF_COEFF1819, 0x04020669);
3416 cx25840_write4(client, DIF_BPF_COEFF2021, 0x05830103);
3417 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfad7f66b);
3418 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf6c8fc93);
3419 cx25840_write4(client, DIF_BPF_COEFF2627, 0x05430c2b);
3420 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0d0d06b5);
3421 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfc08f2b2);
3422 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf00af5ec);
3423 cx25840_write4(client, DIF_BPF_COEFF3435, 0x017b0c89);
3424 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3425 break;
3426
3427 case 6000000:
3428 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000001);
3429 cx25840_write4(client, DIF_BPF_COEFF23, 0x00070012);
3430 cx25840_write4(client, DIF_BPF_COEFF45, 0x0012fff5);
3431 cx25840_write4(client, DIF_BPF_COEFF67, 0xffbaff82);
3432 cx25840_write4(client, DIF_BPF_COEFF89, 0xff8e000f);
3433 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00e80198);
3434 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01750028);
3435 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe18fc75);
3436 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99ff15);
3437 cx25840_write4(client, DIF_BPF_COEFF1819, 0x03050636);
3438 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0656027f);
3439 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfc32f6e2);
3440 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf614fb17);
3441 cx25840_write4(client, DIF_BPF_COEFF2627, 0x03d20b87);
3442 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0d7707d2);
3443 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfd26f341);
3444 cx25840_write4(client, DIF_BPF_COEFF3233, 0xefeaf56f);
3445 cx25840_write4(client, DIF_BPF_COEFF3435, 0x010f0c64);
3446 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3447 break;
3448
3449 case 6100000:
3450 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0000);
3451 cx25840_write4(client, DIF_BPF_COEFF23, 0x00050012);
3452 cx25840_write4(client, DIF_BPF_COEFF45, 0x001c000b);
3453 cx25840_write4(client, DIF_BPF_COEFF67, 0xffd1ff84);
3454 cx25840_write4(client, DIF_BPF_COEFF89, 0xff66ffbe);
3455 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00960184);
3456 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01cd00da);
3457 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfeccfcb2);
3458 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17fdf9);
3459 cx25840_write4(client, DIF_BPF_COEFF1819, 0x01e005bc);
3460 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06e703e4);
3461 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfdabf798);
3462 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf599f9b3);
3463 cx25840_write4(client, DIF_BPF_COEFF2627, 0x02510abd);
3464 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0dbf08df);
3465 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfe48f3dc);
3466 cx25840_write4(client, DIF_BPF_COEFF3233, 0xefd5f4f6);
3467 cx25840_write4(client, DIF_BPF_COEFF3435, 0x00a20c3e);
3468 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3469 break;
3470
3471 case 6200000:
3472 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffe);
3473 cx25840_write4(client, DIF_BPF_COEFF23, 0x0002000f);
3474 cx25840_write4(client, DIF_BPF_COEFF45, 0x0021001f);
3475 cx25840_write4(client, DIF_BPF_COEFF67, 0xfff0ff97);
3476 cx25840_write4(client, DIF_BPF_COEFF89, 0xff50ff74);
3477 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0034014a);
3478 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01fa0179);
3479 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff97fd2a);
3480 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3fcfa);
3481 cx25840_write4(client, DIF_BPF_COEFF1819, 0x00a304fe);
3482 cx25840_write4(client, DIF_BPF_COEFF2021, 0x07310525);
3483 cx25840_write4(client, DIF_BPF_COEFF2223, 0xff37f886);
3484 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf55cf86e);
3485 cx25840_write4(client, DIF_BPF_COEFF2627, 0x00c709d0);
3486 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0de209db);
3487 cx25840_write4(client, DIF_BPF_COEFF3031, 0xff6df484);
3488 cx25840_write4(client, DIF_BPF_COEFF3233, 0xefcbf481);
3489 cx25840_write4(client, DIF_BPF_COEFF3435, 0x00360c18);
3490 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3491 break;
3492
3493 case 6300000:
3494 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffd);
3495 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffe000a);
3496 cx25840_write4(client, DIF_BPF_COEFF45, 0x0021002f);
3497 cx25840_write4(client, DIF_BPF_COEFF67, 0x0010ffb8);
3498 cx25840_write4(client, DIF_BPF_COEFF89, 0xff50ff3b);
3499 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffcc00f0);
3500 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01fa01fa);
3501 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0069fdd4);
3502 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3fc26);
3503 cx25840_write4(client, DIF_BPF_COEFF1819, 0xff5d0407);
3504 cx25840_write4(client, DIF_BPF_COEFF2021, 0x07310638);
3505 cx25840_write4(client, DIF_BPF_COEFF2223, 0x00c9f9a8);
3506 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf55cf74e);
3507 cx25840_write4(client, DIF_BPF_COEFF2627, 0xff3908c3);
3508 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0de20ac3);
3509 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0093f537);
3510 cx25840_write4(client, DIF_BPF_COEFF3233, 0xefcbf410);
3511 cx25840_write4(client, DIF_BPF_COEFF3435, 0xffca0bf2);
3512 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3513 break;
3514
3515 case 6400000:
3516 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffd);
3517 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffb0003);
3518 cx25840_write4(client, DIF_BPF_COEFF45, 0x001c0037);
3519 cx25840_write4(client, DIF_BPF_COEFF67, 0x002fffe2);
3520 cx25840_write4(client, DIF_BPF_COEFF89, 0xff66ff17);
3521 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff6a007e);
3522 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01cd0251);
3523 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0134fea5);
3524 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17fb8b);
3525 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfe2002e0);
3526 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06e70713);
3527 cx25840_write4(client, DIF_BPF_COEFF2223, 0x0255faf5);
3528 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf599f658);
3529 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfdaf0799);
3530 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0dbf0b96);
3531 cx25840_write4(client, DIF_BPF_COEFF3031, 0x01b8f5f5);
3532 cx25840_write4(client, DIF_BPF_COEFF3233, 0xefd5f3a3);
3533 cx25840_write4(client, DIF_BPF_COEFF3435, 0xff5e0bca);
3534 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3535 break;
3536
3537 case 6500000:
3538 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
3539 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff9fffb);
3540 cx25840_write4(client, DIF_BPF_COEFF45, 0x00120037);
3541 cx25840_write4(client, DIF_BPF_COEFF67, 0x00460010);
3542 cx25840_write4(client, DIF_BPF_COEFF89, 0xff8eff0f);
3543 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff180000);
3544 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01750276);
3545 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01e8ff8d);
3546 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99fb31);
3547 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfcfb0198);
3548 cx25840_write4(client, DIF_BPF_COEFF2021, 0x065607ad);
3549 cx25840_write4(client, DIF_BPF_COEFF2223, 0x03cefc64);
3550 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf614f592);
3551 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfc2e0656);
3552 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0d770c52);
3553 cx25840_write4(client, DIF_BPF_COEFF3031, 0x02daf6bd);
3554 cx25840_write4(client, DIF_BPF_COEFF3233, 0xefeaf33b);
3555 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfef10ba3);
3556 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3557 break;
3558
3559 case 6600000:
3560 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
3561 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff7fff5);
3562 cx25840_write4(client, DIF_BPF_COEFF45, 0x0005002f);
3563 cx25840_write4(client, DIF_BPF_COEFF67, 0x0054003c);
3564 cx25840_write4(client, DIF_BPF_COEFF89, 0xffc5ff22);
3565 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfedfff82);
3566 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00fc0267);
3567 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0276007e);
3568 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd51fb1c);
3569 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfbfe003e);
3570 cx25840_write4(client, DIF_BPF_COEFF2021, 0x05830802);
3571 cx25840_write4(client, DIF_BPF_COEFF2223, 0x0529fdec);
3572 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf6c8f4fe);
3573 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfabd04ff);
3574 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0d0d0cf6);
3575 cx25840_write4(client, DIF_BPF_COEFF3031, 0x03f8f78f);
3576 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf00af2d7);
3577 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfe850b7b);
3578 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3579 break;
3580
3581 case 6700000:
3582 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000ffff);
3583 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fff0);
3584 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff80020);
3585 cx25840_write4(client, DIF_BPF_COEFF67, 0x00560060);
3586 cx25840_write4(client, DIF_BPF_COEFF89, 0x0002ff4e);
3587 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfec4ff10);
3588 cx25840_write4(client, DIF_BPF_COEFF1213, 0x006d0225);
3589 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02d50166);
3590 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe35fb4e);
3591 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb35fee1);
3592 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0477080e);
3593 cx25840_write4(client, DIF_BPF_COEFF2223, 0x065bff82);
3594 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf7b1f4a0);
3595 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf9610397);
3596 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0c810d80);
3597 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0510f869);
3598 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf033f278);
3599 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfe1a0b52);
3600 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3601 break;
3602
3603 case 6800000:
3604 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010000);
3605 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffaffee);
3606 cx25840_write4(client, DIF_BPF_COEFF45, 0xffec000c);
3607 cx25840_write4(client, DIF_BPF_COEFF67, 0x004c0078);
3608 cx25840_write4(client, DIF_BPF_COEFF89, 0x0040ff8e);
3609 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfecafeb6);
3610 cx25840_write4(client, DIF_BPF_COEFF1213, 0xffd301b6);
3611 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02fc0235);
3612 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff36fbc5);
3613 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfaaafd90);
3614 cx25840_write4(client, DIF_BPF_COEFF2021, 0x033e07d2);
3615 cx25840_write4(client, DIF_BPF_COEFF2223, 0x075b011b);
3616 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf8cbf47a);
3617 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf81f0224);
3618 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0bd50def);
3619 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0621f94b);
3620 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf067f21e);
3621 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfdae0b29);
3622 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3623 break;
3624
3625 case 6900000:
3626 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010001);
3627 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffdffef);
3628 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe3fff6);
3629 cx25840_write4(client, DIF_BPF_COEFF67, 0x0037007f);
3630 cx25840_write4(client, DIF_BPF_COEFF89, 0x0075ffdc);
3631 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfef2fe7c);
3632 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff3d0122);
3633 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02ea02dd);
3634 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0044fc79);
3635 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa65fc5d);
3636 cx25840_write4(client, DIF_BPF_COEFF2021, 0x01e3074e);
3637 cx25840_write4(client, DIF_BPF_COEFF2223, 0x082102ad);
3638 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfa0ff48c);
3639 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf6fe00a9);
3640 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0b0a0e43);
3641 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0729fa33);
3642 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf0a5f1c9);
3643 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfd430b00);
3644 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3645 break;
3646
3647 case 7000000:
3648 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010002);
3649 cx25840_write4(client, DIF_BPF_COEFF23, 0x0001fff3);
3650 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdeffe2);
3651 cx25840_write4(client, DIF_BPF_COEFF67, 0x001b0076);
3652 cx25840_write4(client, DIF_BPF_COEFF89, 0x009c002d);
3653 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff35fe68);
3654 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfeba0076);
3655 cx25840_write4(client, DIF_BPF_COEFF1415, 0x029f0352);
3656 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014dfd60);
3657 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa69fb53);
3658 cx25840_write4(client, DIF_BPF_COEFF2021, 0x00740688);
3659 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08a7042d);
3660 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfb75f4d6);
3661 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf600ff2d);
3662 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0a220e7a);
3663 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0827fb22);
3664 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf0edf17a);
3665 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfcd80ad6);
3666 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3667 break;
3668
3669 case 7100000:
3670 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
3671 cx25840_write4(client, DIF_BPF_COEFF23, 0x0004fff9);
3672 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe0ffd2);
3673 cx25840_write4(client, DIF_BPF_COEFF67, 0xfffb005e);
3674 cx25840_write4(client, DIF_BPF_COEFF89, 0x00b0007a);
3675 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff8ffe7c);
3676 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe53ffc1);
3677 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0221038c);
3678 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0241fe6e);
3679 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfab6fa80);
3680 cx25840_write4(client, DIF_BPF_COEFF2021, 0xff010587);
3681 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08e90590);
3682 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfcf5f556);
3683 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf52bfdb3);
3684 cx25840_write4(client, DIF_BPF_COEFF2829, 0x09210e95);
3685 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0919fc15);
3686 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf13ff12f);
3687 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfc6e0aab);
3688 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3689 break;
3690
3691 case 7200000:
3692 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
3693 cx25840_write4(client, DIF_BPF_COEFF23, 0x00070000);
3694 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe6ffc9);
3695 cx25840_write4(client, DIF_BPF_COEFF67, 0xffdb0039);
3696 cx25840_write4(client, DIF_BPF_COEFF89, 0x00af00b8);
3697 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfff4feb6);
3698 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe13ff10);
3699 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01790388);
3700 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0311ff92);
3701 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb48f9ed);
3702 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfd980453);
3703 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08e306cd);
3704 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfe88f60a);
3705 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf482fc40);
3706 cx25840_write4(client, DIF_BPF_COEFF2829, 0x08080e93);
3707 cx25840_write4(client, DIF_BPF_COEFF3031, 0x09fdfd0c);
3708 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf19af0ea);
3709 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfc050a81);
3710 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3711 break;
3712
3713 case 7300000:
3714 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
3715 cx25840_write4(client, DIF_BPF_COEFF23, 0x00080008);
3716 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff0ffc9);
3717 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc1000d);
3718 cx25840_write4(client, DIF_BPF_COEFF89, 0x009800e2);
3719 cx25840_write4(client, DIF_BPF_COEFF1011, 0x005bff10);
3720 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe00fe74);
3721 cx25840_write4(client, DIF_BPF_COEFF1415, 0x00b50345);
3722 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b000bc);
3723 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfc18f9a1);
3724 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfc4802f9);
3725 cx25840_write4(client, DIF_BPF_COEFF2223, 0x089807dc);
3726 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0022f6f0);
3727 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf407fada);
3728 cx25840_write4(client, DIF_BPF_COEFF2829, 0x06da0e74);
3729 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0ad3fe06);
3730 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf1fef0ab);
3731 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfb9c0a55);
3732 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3733 break;
3734
3735 case 7400000:
3736 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000001);
3737 cx25840_write4(client, DIF_BPF_COEFF23, 0x0008000e);
3738 cx25840_write4(client, DIF_BPF_COEFF45, 0xfffdffd0);
3739 cx25840_write4(client, DIF_BPF_COEFF67, 0xffafffdf);
3740 cx25840_write4(client, DIF_BPF_COEFF89, 0x006e00f2);
3741 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00b8ff82);
3742 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe1bfdf8);
3743 cx25840_write4(client, DIF_BPF_COEFF1415, 0xffe302c8);
3744 cx25840_write4(client, DIF_BPF_COEFF1617, 0x041301dc);
3745 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfd1af99e);
3746 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfb1e0183);
3747 cx25840_write4(client, DIF_BPF_COEFF2223, 0x080908b5);
3748 cx25840_write4(client, DIF_BPF_COEFF2425, 0x01bcf801);
3749 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf3bdf985);
3750 cx25840_write4(client, DIF_BPF_COEFF2829, 0x059a0e38);
3751 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0b99ff03);
3752 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf26cf071);
3753 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfb330a2a);
3754 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3755 break;
3756
3757 case 7500000:
3758 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0000);
3759 cx25840_write4(client, DIF_BPF_COEFF23, 0x00070011);
3760 cx25840_write4(client, DIF_BPF_COEFF45, 0x000affdf);
3761 cx25840_write4(client, DIF_BPF_COEFF67, 0xffa9ffb5);
3762 cx25840_write4(client, DIF_BPF_COEFF89, 0x003700e6);
3763 cx25840_write4(client, DIF_BPF_COEFF1011, 0x01010000);
3764 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe62fda8);
3765 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff140219);
3766 cx25840_write4(client, DIF_BPF_COEFF1617, 0x043502e1);
3767 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfe42f9e6);
3768 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfa270000);
3769 cx25840_write4(client, DIF_BPF_COEFF2223, 0x073a0953);
3770 cx25840_write4(client, DIF_BPF_COEFF2425, 0x034cf939);
3771 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf3a4f845);
3772 cx25840_write4(client, DIF_BPF_COEFF2829, 0x044c0de1);
3773 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0c4f0000);
3774 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf2e2f03c);
3775 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfacc09fe);
3776 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3777 break;
3778
3779 case 7600000:
3780 cx25840_write4(client, DIF_BPF_COEFF01, 0xffffffff);
3781 cx25840_write4(client, DIF_BPF_COEFF23, 0x00040012);
3782 cx25840_write4(client, DIF_BPF_COEFF45, 0x0016fff3);
3783 cx25840_write4(client, DIF_BPF_COEFF67, 0xffafff95);
3784 cx25840_write4(client, DIF_BPF_COEFF89, 0xfff900c0);
3785 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0130007e);
3786 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfecefd89);
3787 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe560146);
3788 cx25840_write4(client, DIF_BPF_COEFF1617, 0x041303bc);
3789 cx25840_write4(client, DIF_BPF_COEFF1819, 0xff81fa76);
3790 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf96cfe7d);
3791 cx25840_write4(client, DIF_BPF_COEFF2223, 0x063209b1);
3792 cx25840_write4(client, DIF_BPF_COEFF2425, 0x04c9fa93);
3793 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf3bdf71e);
3794 cx25840_write4(client, DIF_BPF_COEFF2829, 0x02f30d6e);
3795 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0cf200fd);
3796 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf361f00e);
3797 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfa6509d1);
3798 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3799 break;
3800
3801 case 7700000:
3802 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffe);
3803 cx25840_write4(client, DIF_BPF_COEFF23, 0x00010010);
3804 cx25840_write4(client, DIF_BPF_COEFF45, 0x001e0008);
3805 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc1ff84);
3806 cx25840_write4(client, DIF_BPF_COEFF89, 0xffbc0084);
3807 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013e00f0);
3808 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff56fd9f);
3809 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfdb8005c);
3810 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b00460);
3811 cx25840_write4(client, DIF_BPF_COEFF1819, 0x00c7fb45);
3812 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8f4fd07);
3813 cx25840_write4(client, DIF_BPF_COEFF2223, 0x04fa09ce);
3814 cx25840_write4(client, DIF_BPF_COEFF2425, 0x062afc07);
3815 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf407f614);
3816 cx25840_write4(client, DIF_BPF_COEFF2829, 0x01920ce0);
3817 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0d8301fa);
3818 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf3e8efe5);
3819 cx25840_write4(client, DIF_BPF_COEFF3435, 0xfa0009a4);
3820 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3821 break;
3822
3823 case 7800000:
3824 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
3825 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffd000b);
3826 cx25840_write4(client, DIF_BPF_COEFF45, 0x0022001d);
3827 cx25840_write4(client, DIF_BPF_COEFF67, 0xffdbff82);
3828 cx25840_write4(client, DIF_BPF_COEFF89, 0xff870039);
3829 cx25840_write4(client, DIF_BPF_COEFF1011, 0x012a014a);
3830 cx25840_write4(client, DIF_BPF_COEFF1213, 0xffedfde7);
3831 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd47ff6b);
3832 cx25840_write4(client, DIF_BPF_COEFF1617, 0x031104c6);
3833 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0202fc4c);
3834 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8c6fbad);
3835 cx25840_write4(client, DIF_BPF_COEFF2223, 0x039909a7);
3836 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0767fd8e);
3837 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf482f52b);
3838 cx25840_write4(client, DIF_BPF_COEFF2829, 0x002d0c39);
3839 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0e0002f4);
3840 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf477efc2);
3841 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf99b0977);
3842 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3843 break;
3844
3845 case 7900000:
3846 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
3847 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffa0004);
3848 cx25840_write4(client, DIF_BPF_COEFF45, 0x0020002d);
3849 cx25840_write4(client, DIF_BPF_COEFF67, 0xfffbff91);
3850 cx25840_write4(client, DIF_BPF_COEFF89, 0xff61ffe8);
3851 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00f70184);
3852 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0086fe5c);
3853 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd0bfe85);
3854 cx25840_write4(client, DIF_BPF_COEFF1617, 0x024104e5);
3855 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0323fd7d);
3856 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8e2fa79);
3857 cx25840_write4(client, DIF_BPF_COEFF2223, 0x021d093f);
3858 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0879ff22);
3859 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf52bf465);
3860 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfec70b79);
3861 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0e6803eb);
3862 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf50defa5);
3863 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf937094a);
3864 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3865 break;
3866
3867 case 8000000:
3868 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
3869 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fffd);
3870 cx25840_write4(client, DIF_BPF_COEFF45, 0x00190036);
3871 cx25840_write4(client, DIF_BPF_COEFF67, 0x001bffaf);
3872 cx25840_write4(client, DIF_BPF_COEFF89, 0xff4fff99);
3873 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00aa0198);
3874 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0112fef3);
3875 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd09fdb9);
3876 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014d04be);
3877 cx25840_write4(client, DIF_BPF_COEFF1819, 0x041bfecc);
3878 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf947f978);
3879 cx25840_write4(client, DIF_BPF_COEFF2223, 0x00900897);
3880 cx25840_write4(client, DIF_BPF_COEFF2425, 0x095a00b9);
3881 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf600f3c5);
3882 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfd650aa3);
3883 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0ebc04de);
3884 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf5aaef8e);
3885 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf8d5091c);
3886 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3887 break;
3888
3889 case 8100000:
3890 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000ffff);
3891 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff7fff6);
3892 cx25840_write4(client, DIF_BPF_COEFF45, 0x000e0038);
3893 cx25840_write4(client, DIF_BPF_COEFF67, 0x0037ffd7);
3894 cx25840_write4(client, DIF_BPF_COEFF89, 0xff52ff56);
3895 cx25840_write4(client, DIF_BPF_COEFF1011, 0x004b0184);
3896 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0186ffa1);
3897 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd40fd16);
3898 cx25840_write4(client, DIF_BPF_COEFF1617, 0x00440452);
3899 cx25840_write4(client, DIF_BPF_COEFF1819, 0x04de0029);
3900 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf9f2f8b2);
3901 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfefe07b5);
3902 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a05024d);
3903 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf6fef34d);
3904 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfc0a09b8);
3905 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0efa05cd);
3906 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf64eef7d);
3907 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf87308ed);
3908 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3909 break;
3910
3911 case 8200000:
3912 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010000);
3913 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fff0);
3914 cx25840_write4(client, DIF_BPF_COEFF45, 0x00000031);
3915 cx25840_write4(client, DIF_BPF_COEFF67, 0x004c0005);
3916 cx25840_write4(client, DIF_BPF_COEFF89, 0xff6aff27);
3917 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffe4014a);
3918 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01d70057);
3919 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfdacfca6);
3920 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff3603a7);
3921 cx25840_write4(client, DIF_BPF_COEFF1819, 0x05610184);
3922 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfadbf82e);
3923 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfd74069f);
3924 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a7503d6);
3925 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf81ff2ff);
3926 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfab808b9);
3927 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0f2306b5);
3928 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf6f9ef72);
3929 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf81308bf);
3930 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3931 break;
3932
3933 case 8300000:
3934 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010001);
3935 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffbffee);
3936 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff30022);
3937 cx25840_write4(client, DIF_BPF_COEFF67, 0x00560032);
3938 cx25840_write4(client, DIF_BPF_COEFF89, 0xff95ff10);
3939 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff8000f0);
3940 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01fe0106);
3941 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe46fc71);
3942 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe3502c7);
3943 cx25840_write4(client, DIF_BPF_COEFF1819, 0x059e02ce);
3944 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfbf9f7f2);
3945 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfbff055b);
3946 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0aa9054c);
3947 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf961f2db);
3948 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf97507aa);
3949 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0f350797);
3950 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf7a9ef6d);
3951 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf7b40890);
3952 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3953 break;
3954
3955 case 8400000:
3956 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010002);
3957 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffeffee);
3958 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe8000f);
3959 cx25840_write4(client, DIF_BPF_COEFF67, 0x00540058);
3960 cx25840_write4(client, DIF_BPF_COEFF89, 0xffcdff14);
3961 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff29007e);
3962 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01f6019e);
3963 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff01fc7c);
3964 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd5101bf);
3965 cx25840_write4(client, DIF_BPF_COEFF1819, 0x059203f6);
3966 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfd41f7fe);
3967 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfaa903f3);
3968 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a9e06a9);
3969 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfabdf2e2);
3970 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf842068b);
3971 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0f320871);
3972 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf85eef6e);
3973 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf7560860);
3974 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3975 break;
3976
3977 case 8500000:
3978 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
3979 cx25840_write4(client, DIF_BPF_COEFF23, 0x0002fff2);
3980 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe1fff9);
3981 cx25840_write4(client, DIF_BPF_COEFF67, 0x00460073);
3982 cx25840_write4(client, DIF_BPF_COEFF89, 0x000bff34);
3983 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfee90000);
3984 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01c10215);
3985 cx25840_write4(client, DIF_BPF_COEFF1415, 0xffd0fcc5);
3986 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99009d);
3987 cx25840_write4(client, DIF_BPF_COEFF1819, 0x053d04f1);
3988 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfea5f853);
3989 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf97d0270);
3990 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a5607e4);
3991 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfc2ef314);
3992 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf723055f);
3993 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0f180943);
3994 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf919ef75);
3995 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf6fa0830);
3996 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
3997 break;
3998
3999 case 8600000:
4000 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4001 cx25840_write4(client, DIF_BPF_COEFF23, 0x0005fff8);
4002 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdeffe4);
4003 cx25840_write4(client, DIF_BPF_COEFF67, 0x002f007f);
4004 cx25840_write4(client, DIF_BPF_COEFF89, 0x0048ff6b);
4005 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfec7ff82);
4006 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0163025f);
4007 cx25840_write4(client, DIF_BPF_COEFF1415, 0x00a2fd47);
4008 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17ff73);
4009 cx25840_write4(client, DIF_BPF_COEFF1819, 0x04a405b2);
4010 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0017f8ed);
4011 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf88500dc);
4012 cx25840_write4(client, DIF_BPF_COEFF2425, 0x09d208f9);
4013 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfdaff370);
4014 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf61c0429);
4015 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0ee80a0b);
4016 cx25840_write4(client, DIF_BPF_COEFF3233, 0xf9d8ef82);
4017 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf6a00800);
4018 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4019 break;
4020
4021 case 8700000:
4022 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4023 cx25840_write4(client, DIF_BPF_COEFF23, 0x0007ffff);
4024 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe1ffd4);
4025 cx25840_write4(client, DIF_BPF_COEFF67, 0x0010007a);
4026 cx25840_write4(client, DIF_BPF_COEFF89, 0x007cffb2);
4027 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfec6ff10);
4028 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00e60277);
4029 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0168fdf9);
4030 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3fe50);
4031 cx25840_write4(client, DIF_BPF_COEFF1819, 0x03ce0631);
4032 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0188f9c8);
4033 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf7c7ff43);
4034 cx25840_write4(client, DIF_BPF_COEFF2425, 0x091509e3);
4035 cx25840_write4(client, DIF_BPF_COEFF2627, 0xff39f3f6);
4036 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf52d02ea);
4037 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0ea30ac9);
4038 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfa9bef95);
4039 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf64607d0);
4040 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4041 break;
4042
4043 case 8800000:
4044 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
4045 cx25840_write4(client, DIF_BPF_COEFF23, 0x00090007);
4046 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe9ffca);
4047 cx25840_write4(client, DIF_BPF_COEFF67, 0xfff00065);
4048 cx25840_write4(client, DIF_BPF_COEFF89, 0x00a10003);
4049 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfee6feb6);
4050 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0053025b);
4051 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0213fed0);
4052 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3fd46);
4053 cx25840_write4(client, DIF_BPF_COEFF1819, 0x02c70668);
4054 cx25840_write4(client, DIF_BPF_COEFF2021, 0x02eafadb);
4055 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf74bfdae);
4056 cx25840_write4(client, DIF_BPF_COEFF2425, 0x08230a9c);
4057 cx25840_write4(client, DIF_BPF_COEFF2627, 0x00c7f4a3);
4058 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf45b01a6);
4059 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0e480b7c);
4060 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfb61efae);
4061 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf5ef079f);
4062 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4063 break;
4064
4065 case 8900000:
4066 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0000);
4067 cx25840_write4(client, DIF_BPF_COEFF23, 0x0008000d);
4068 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff5ffc8);
4069 cx25840_write4(client, DIF_BPF_COEFF67, 0xffd10043);
4070 cx25840_write4(client, DIF_BPF_COEFF89, 0x00b20053);
4071 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff24fe7c);
4072 cx25840_write4(client, DIF_BPF_COEFF1213, 0xffb9020c);
4073 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0295ffbb);
4074 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17fc64);
4075 cx25840_write4(client, DIF_BPF_COEFF1819, 0x019b0654);
4076 cx25840_write4(client, DIF_BPF_COEFF2021, 0x042dfc1c);
4077 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf714fc2a);
4078 cx25840_write4(client, DIF_BPF_COEFF2425, 0x07020b21);
4079 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0251f575);
4080 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf3a7005e);
4081 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0dd80c24);
4082 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfc2aefcd);
4083 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf599076e);
4084 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4085 break;
4086
4087 case 9000000:
4088 cx25840_write4(client, DIF_BPF_COEFF01, 0xffffffff);
4089 cx25840_write4(client, DIF_BPF_COEFF23, 0x00060011);
4090 cx25840_write4(client, DIF_BPF_COEFF45, 0x0002ffcf);
4091 cx25840_write4(client, DIF_BPF_COEFF67, 0xffba0018);
4092 cx25840_write4(client, DIF_BPF_COEFF89, 0x00ad009a);
4093 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff79fe68);
4094 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff260192);
4095 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02e500ab);
4096 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99fbb6);
4097 cx25840_write4(client, DIF_BPF_COEFF1819, 0x005b05f7);
4098 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0545fd81);
4099 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf723fabf);
4100 cx25840_write4(client, DIF_BPF_COEFF2425, 0x05b80b70);
4101 cx25840_write4(client, DIF_BPF_COEFF2627, 0x03d2f669);
4102 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf313ff15);
4103 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0d550cbf);
4104 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfcf6eff2);
4105 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf544073d);
4106 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4107 break;
4108
4109 case 9100000:
4110 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffe);
4111 cx25840_write4(client, DIF_BPF_COEFF23, 0x00030012);
4112 cx25840_write4(client, DIF_BPF_COEFF45, 0x000fffdd);
4113 cx25840_write4(client, DIF_BPF_COEFF67, 0xffacffea);
4114 cx25840_write4(client, DIF_BPF_COEFF89, 0x009300cf);
4115 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffdcfe7c);
4116 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfea600f7);
4117 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02fd0190);
4118 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd51fb46);
4119 cx25840_write4(client, DIF_BPF_COEFF1819, 0xff150554);
4120 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0627fefd);
4121 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf778f978);
4122 cx25840_write4(client, DIF_BPF_COEFF2425, 0x044d0b87);
4123 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0543f77d);
4124 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf2a0fdcf);
4125 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0cbe0d4e);
4126 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfdc4f01d);
4127 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf4f2070b);
4128 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4129 break;
4130
4131 case 9200000:
4132 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
4133 cx25840_write4(client, DIF_BPF_COEFF23, 0x00000010);
4134 cx25840_write4(client, DIF_BPF_COEFF45, 0x001afff0);
4135 cx25840_write4(client, DIF_BPF_COEFF67, 0xffaaffbf);
4136 cx25840_write4(client, DIF_BPF_COEFF89, 0x006700ed);
4137 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0043feb6);
4138 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe460047);
4139 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02db0258);
4140 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe35fb1b);
4141 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfddc0473);
4142 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06c90082);
4143 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf811f85e);
4144 cx25840_write4(client, DIF_BPF_COEFF2425, 0x02c90b66);
4145 cx25840_write4(client, DIF_BPF_COEFF2627, 0x069ff8ad);
4146 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf250fc8d);
4147 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0c140dcf);
4148 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfe93f04d);
4149 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf4a106d9);
4150 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4151 break;
4152
4153 case 9300000:
4154 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
4155 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffc000c);
4156 cx25840_write4(client, DIF_BPF_COEFF45, 0x00200006);
4157 cx25840_write4(client, DIF_BPF_COEFF67, 0xffb4ff9c);
4158 cx25840_write4(client, DIF_BPF_COEFF89, 0x002f00ef);
4159 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00a4ff10);
4160 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe0dff92);
4161 cx25840_write4(client, DIF_BPF_COEFF1415, 0x028102f7);
4162 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff36fb37);
4163 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfcbf035e);
4164 cx25840_write4(client, DIF_BPF_COEFF2021, 0x07260202);
4165 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf8e8f778);
4166 cx25840_write4(client, DIF_BPF_COEFF2425, 0x01340b0d);
4167 cx25840_write4(client, DIF_BPF_COEFF2627, 0x07e1f9f4);
4168 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf223fb51);
4169 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0b590e42);
4170 cx25840_write4(client, DIF_BPF_COEFF3233, 0xff64f083);
4171 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf45206a7);
4172 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4173 break;
4174
4175 case 9400000:
4176 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
4177 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff90005);
4178 cx25840_write4(client, DIF_BPF_COEFF45, 0x0022001a);
4179 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc9ff86);
4180 cx25840_write4(client, DIF_BPF_COEFF89, 0xfff000d7);
4181 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00f2ff82);
4182 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe01fee5);
4183 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01f60362);
4184 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0044fb99);
4185 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfbcc0222);
4186 cx25840_write4(client, DIF_BPF_COEFF2021, 0x07380370);
4187 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf9f7f6cc);
4188 cx25840_write4(client, DIF_BPF_COEFF2425, 0xff990a7e);
4189 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0902fb50);
4190 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf21afa1f);
4191 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0a8d0ea6);
4192 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0034f0bf);
4193 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf4050675);
4194 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4195 break;
4196
4197 case 9500000:
4198 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
4199 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fffe);
4200 cx25840_write4(client, DIF_BPF_COEFF45, 0x001e002b);
4201 cx25840_write4(client, DIF_BPF_COEFF67, 0xffe5ff81);
4202 cx25840_write4(client, DIF_BPF_COEFF89, 0xffb400a5);
4203 cx25840_write4(client, DIF_BPF_COEFF1011, 0x01280000);
4204 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe24fe50);
4205 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01460390);
4206 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014dfc3a);
4207 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb1000ce);
4208 cx25840_write4(client, DIF_BPF_COEFF2021, 0x070104bf);
4209 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfb37f65f);
4210 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfe0009bc);
4211 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0a00fcbb);
4212 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf235f8f8);
4213 cx25840_write4(client, DIF_BPF_COEFF3031, 0x09b20efc);
4214 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0105f101);
4215 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf3ba0642);
4216 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4217 break;
4218
4219 case 9600000:
4220 cx25840_write4(client, DIF_BPF_COEFF01, 0x0001ffff);
4221 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fff7);
4222 cx25840_write4(client, DIF_BPF_COEFF45, 0x00150036);
4223 cx25840_write4(client, DIF_BPF_COEFF67, 0x0005ff8c);
4224 cx25840_write4(client, DIF_BPF_COEFF89, 0xff810061);
4225 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013d007e);
4226 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe71fddf);
4227 cx25840_write4(client, DIF_BPF_COEFF1415, 0x007c0380);
4228 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0241fd13);
4229 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa94ff70);
4230 cx25840_write4(client, DIF_BPF_COEFF2021, 0x068005e2);
4231 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfc9bf633);
4232 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfc7308ca);
4233 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0ad5fe30);
4234 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf274f7e0);
4235 cx25840_write4(client, DIF_BPF_COEFF3031, 0x08c90f43);
4236 cx25840_write4(client, DIF_BPF_COEFF3233, 0x01d4f147);
4237 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf371060f);
4238 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4239 break;
4240
4241 case 9700000:
4242 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010001);
4243 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff9fff1);
4244 cx25840_write4(client, DIF_BPF_COEFF45, 0x00090038);
4245 cx25840_write4(client, DIF_BPF_COEFF67, 0x0025ffa7);
4246 cx25840_write4(client, DIF_BPF_COEFF89, 0xff5e0012);
4247 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013200f0);
4248 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfee3fd9b);
4249 cx25840_write4(client, DIF_BPF_COEFF1415, 0xffaa0331);
4250 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0311fe15);
4251 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa60fe18);
4252 cx25840_write4(client, DIF_BPF_COEFF2021, 0x05bd06d1);
4253 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfe1bf64a);
4254 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfafa07ae);
4255 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0b7effab);
4256 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf2d5f6d7);
4257 cx25840_write4(client, DIF_BPF_COEFF3031, 0x07d30f7a);
4258 cx25840_write4(client, DIF_BPF_COEFF3233, 0x02a3f194);
4259 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf32905dc);
4260 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4261 break;
4262
4263 case 9800000:
4264 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010002);
4265 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffcffee);
4266 cx25840_write4(client, DIF_BPF_COEFF45, 0xfffb0032);
4267 cx25840_write4(client, DIF_BPF_COEFF67, 0x003fffcd);
4268 cx25840_write4(client, DIF_BPF_COEFF89, 0xff4effc1);
4269 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0106014a);
4270 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff6efd8a);
4271 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfedd02aa);
4272 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b0ff34);
4273 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa74fcd7);
4274 cx25840_write4(client, DIF_BPF_COEFF2021, 0x04bf0781);
4275 cx25840_write4(client, DIF_BPF_COEFF2223, 0xffaaf6a3);
4276 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf99e066b);
4277 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0bf90128);
4278 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf359f5e1);
4279 cx25840_write4(client, DIF_BPF_COEFF3031, 0x06d20fa2);
4280 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0370f1e5);
4281 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf2e405a8);
4282 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4283 break;
4284
4285 case 9900000:
4286 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4287 cx25840_write4(client, DIF_BPF_COEFF23, 0xffffffee);
4288 cx25840_write4(client, DIF_BPF_COEFF45, 0xffef0024);
4289 cx25840_write4(client, DIF_BPF_COEFF67, 0x0051fffa);
4290 cx25840_write4(client, DIF_BPF_COEFF89, 0xff54ff77);
4291 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00be0184);
4292 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0006fdad);
4293 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe2701f3);
4294 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0413005e);
4295 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfad1fbba);
4296 cx25840_write4(client, DIF_BPF_COEFF2021, 0x039007ee);
4297 cx25840_write4(client, DIF_BPF_COEFF2223, 0x013bf73d);
4298 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf868050a);
4299 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c4302a1);
4300 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf3fdf4fe);
4301 cx25840_write4(client, DIF_BPF_COEFF3031, 0x05c70fba);
4302 cx25840_write4(client, DIF_BPF_COEFF3233, 0x043bf23c);
4303 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf2a10575);
4304 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4305 break;
4306
4307 case 10000000:
4308 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4309 cx25840_write4(client, DIF_BPF_COEFF23, 0x0003fff1);
4310 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe50011);
4311 cx25840_write4(client, DIF_BPF_COEFF67, 0x00570027);
4312 cx25840_write4(client, DIF_BPF_COEFF89, 0xff70ff3c);
4313 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00620198);
4314 cx25840_write4(client, DIF_BPF_COEFF1213, 0x009efe01);
4315 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd95011a);
4316 cx25840_write4(client, DIF_BPF_COEFF1617, 0x04350183);
4317 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb71fad0);
4318 cx25840_write4(client, DIF_BPF_COEFF2021, 0x023c0812);
4319 cx25840_write4(client, DIF_BPF_COEFF2223, 0x02c3f811);
4320 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf75e0390);
4321 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c5c0411);
4322 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf4c1f432);
4323 cx25840_write4(client, DIF_BPF_COEFF3031, 0x04b30fc1);
4324 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0503f297);
4325 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf2610541);
4326 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4327 break;
4328
4329 case 10100000:
4330 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4331 cx25840_write4(client, DIF_BPF_COEFF23, 0x0006fff7);
4332 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdffffc);
4333 cx25840_write4(client, DIF_BPF_COEFF67, 0x00510050);
4334 cx25840_write4(client, DIF_BPF_COEFF89, 0xff9dff18);
4335 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfffc0184);
4336 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0128fe80);
4337 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd32002e);
4338 cx25840_write4(client, DIF_BPF_COEFF1617, 0x04130292);
4339 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfc4dfa21);
4340 cx25840_write4(client, DIF_BPF_COEFF2021, 0x00d107ee);
4341 cx25840_write4(client, DIF_BPF_COEFF2223, 0x0435f91c);
4342 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf6850205);
4343 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c430573);
4344 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf5a1f37d);
4345 cx25840_write4(client, DIF_BPF_COEFF3031, 0x03990fba);
4346 cx25840_write4(client, DIF_BPF_COEFF3233, 0x05c7f2f8);
4347 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf222050d);
4348 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4349 break;
4350
4351 case 10200000:
4352 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
4353 cx25840_write4(client, DIF_BPF_COEFF23, 0x0008fffe);
4354 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdfffe7);
4355 cx25840_write4(client, DIF_BPF_COEFF67, 0x003f006e);
4356 cx25840_write4(client, DIF_BPF_COEFF89, 0xffd6ff0f);
4357 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff96014a);
4358 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0197ff1f);
4359 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd05ff3e);
4360 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b0037c);
4361 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfd59f9b7);
4362 cx25840_write4(client, DIF_BPF_COEFF2021, 0xff5d0781);
4363 cx25840_write4(client, DIF_BPF_COEFF2223, 0x0585fa56);
4364 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf5e4006f);
4365 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0bf906c4);
4366 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf69df2e0);
4367 cx25840_write4(client, DIF_BPF_COEFF3031, 0x02790fa2);
4368 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0688f35d);
4369 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf1e604d8);
4370 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4371 break;
4372
4373 case 10300000:
4374 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0001);
4375 cx25840_write4(client, DIF_BPF_COEFF23, 0x00090005);
4376 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe4ffd6);
4377 cx25840_write4(client, DIF_BPF_COEFF67, 0x0025007e);
4378 cx25840_write4(client, DIF_BPF_COEFF89, 0x0014ff20);
4379 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff3c00f0);
4380 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01e1ffd0);
4381 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd12fe5c);
4382 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03110433);
4383 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfe88f996);
4384 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfdf106d1);
4385 cx25840_write4(client, DIF_BPF_COEFF2223, 0x06aafbb7);
4386 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf57efed8);
4387 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0b7e07ff);
4388 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf7b0f25e);
4389 cx25840_write4(client, DIF_BPF_COEFF3031, 0x01560f7a);
4390 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0745f3c7);
4391 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf1ac04a4);
4392 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4393 break;
4394
4395 case 10400000:
4396 cx25840_write4(client, DIF_BPF_COEFF01, 0xffffffff);
4397 cx25840_write4(client, DIF_BPF_COEFF23, 0x0008000c);
4398 cx25840_write4(client, DIF_BPF_COEFF45, 0xffedffcb);
4399 cx25840_write4(client, DIF_BPF_COEFF67, 0x0005007d);
4400 cx25840_write4(client, DIF_BPF_COEFF89, 0x0050ff4c);
4401 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfef6007e);
4402 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01ff0086);
4403 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd58fd97);
4404 cx25840_write4(client, DIF_BPF_COEFF1617, 0x024104ad);
4405 cx25840_write4(client, DIF_BPF_COEFF1819, 0xffcaf9c0);
4406 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfc9905e2);
4407 cx25840_write4(client, DIF_BPF_COEFF2223, 0x079afd35);
4408 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf555fd46);
4409 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0ad50920);
4410 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf8d9f1f6);
4411 cx25840_write4(client, DIF_BPF_COEFF3031, 0x00310f43);
4412 cx25840_write4(client, DIF_BPF_COEFF3233, 0x07fdf435);
4413 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf174046f);
4414 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4415 break;
4416
4417 case 10500000:
4418 cx25840_write4(client, DIF_BPF_COEFF01, 0xfffffffe);
4419 cx25840_write4(client, DIF_BPF_COEFF23, 0x00050011);
4420 cx25840_write4(client, DIF_BPF_COEFF45, 0xfffaffc8);
4421 cx25840_write4(client, DIF_BPF_COEFF67, 0xffe5006b);
4422 cx25840_write4(client, DIF_BPF_COEFF89, 0x0082ff8c);
4423 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfecc0000);
4424 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01f00130);
4425 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfdd2fcfc);
4426 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014d04e3);
4427 cx25840_write4(client, DIF_BPF_COEFF1819, 0x010efa32);
4428 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfb6404bf);
4429 cx25840_write4(client, DIF_BPF_COEFF2223, 0x084efec5);
4430 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf569fbc2);
4431 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0a000a23);
4432 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfa15f1ab);
4433 cx25840_write4(client, DIF_BPF_COEFF3031, 0xff0b0efc);
4434 cx25840_write4(client, DIF_BPF_COEFF3233, 0x08b0f4a7);
4435 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf13f043a);
4436 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4437 break;
4438
4439 case 10600000:
4440 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
4441 cx25840_write4(client, DIF_BPF_COEFF23, 0x00020012);
4442 cx25840_write4(client, DIF_BPF_COEFF45, 0x0007ffcd);
4443 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc9004c);
4444 cx25840_write4(client, DIF_BPF_COEFF89, 0x00a4ffd9);
4445 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfec3ff82);
4446 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01b401c1);
4447 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe76fc97);
4448 cx25840_write4(client, DIF_BPF_COEFF1617, 0x004404d2);
4449 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0245fae8);
4450 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfa5f0370);
4451 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08c1005f);
4452 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf5bcfa52);
4453 cx25840_write4(client, DIF_BPF_COEFF2627, 0x09020b04);
4454 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfb60f17b);
4455 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfde70ea6);
4456 cx25840_write4(client, DIF_BPF_COEFF3233, 0x095df51e);
4457 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf10c0405);
4458 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4459 break;
4460
4461 case 10700000:
4462 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
4463 cx25840_write4(client, DIF_BPF_COEFF23, 0xffff0011);
4464 cx25840_write4(client, DIF_BPF_COEFF45, 0x0014ffdb);
4465 cx25840_write4(client, DIF_BPF_COEFF67, 0xffb40023);
4466 cx25840_write4(client, DIF_BPF_COEFF89, 0x00b2002a);
4467 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfedbff10);
4468 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0150022d);
4469 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff38fc6f);
4470 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff36047b);
4471 cx25840_write4(client, DIF_BPF_COEFF1819, 0x035efbda);
4472 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf9940202);
4473 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08ee01f5);
4474 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf649f8fe);
4475 cx25840_write4(client, DIF_BPF_COEFF2627, 0x07e10bc2);
4476 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfcb6f169);
4477 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfcc60e42);
4478 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0a04f599);
4479 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf0db03d0);
4480 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4481 break;
4482
4483 case 10800000:
4484 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
4485 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffb000d);
4486 cx25840_write4(client, DIF_BPF_COEFF45, 0x001dffed);
4487 cx25840_write4(client, DIF_BPF_COEFF67, 0xffaafff5);
4488 cx25840_write4(client, DIF_BPF_COEFF89, 0x00aa0077);
4489 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff13feb6);
4490 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00ce026b);
4491 cx25840_write4(client, DIF_BPF_COEFF1415, 0x000afc85);
4492 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe3503e3);
4493 cx25840_write4(client, DIF_BPF_COEFF1819, 0x044cfcfb);
4494 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf90c0082);
4495 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08d5037f);
4496 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf710f7cc);
4497 cx25840_write4(client, DIF_BPF_COEFF2627, 0x069f0c59);
4498 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfe16f173);
4499 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfbaa0dcf);
4500 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0aa5f617);
4501 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf0ad039b);
4502 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4503 break;
4504
4505 case 10900000:
4506 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
4507 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff90006);
4508 cx25840_write4(client, DIF_BPF_COEFF45, 0x00210003);
4509 cx25840_write4(client, DIF_BPF_COEFF67, 0xffacffc8);
4510 cx25840_write4(client, DIF_BPF_COEFF89, 0x008e00b6);
4511 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff63fe7c);
4512 cx25840_write4(client, DIF_BPF_COEFF1213, 0x003a0275);
4513 cx25840_write4(client, DIF_BPF_COEFF1415, 0x00dafcda);
4514 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd510313);
4515 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0501fe40);
4516 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8cbfefd);
4517 cx25840_write4(client, DIF_BPF_COEFF2223, 0x087604f0);
4518 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf80af6c2);
4519 cx25840_write4(client, DIF_BPF_COEFF2627, 0x05430cc8);
4520 cx25840_write4(client, DIF_BPF_COEFF2829, 0xff7af19a);
4521 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfa940d4e);
4522 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0b3ff699);
4523 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf0810365);
4524 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4525 break;
4526
4527 case 11000000:
4528 cx25840_write4(client, DIF_BPF_COEFF01, 0x0001ffff);
4529 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8ffff);
4530 cx25840_write4(client, DIF_BPF_COEFF45, 0x00210018);
4531 cx25840_write4(client, DIF_BPF_COEFF67, 0xffbaffa3);
4532 cx25840_write4(client, DIF_BPF_COEFF89, 0x006000e1);
4533 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffc4fe68);
4534 cx25840_write4(client, DIF_BPF_COEFF1213, 0xffa0024b);
4535 cx25840_write4(client, DIF_BPF_COEFF1415, 0x019afd66);
4536 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc990216);
4537 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0575ff99);
4538 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8d4fd81);
4539 cx25840_write4(client, DIF_BPF_COEFF2223, 0x07d40640);
4540 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf932f5e6);
4541 cx25840_write4(client, DIF_BPF_COEFF2627, 0x03d20d0d);
4542 cx25840_write4(client, DIF_BPF_COEFF2829, 0x00dff1de);
4543 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf9860cbf);
4544 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0bd1f71e);
4545 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf058032f);
4546 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4547 break;
4548
4549 case 11100000:
4550 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010000);
4551 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fff8);
4552 cx25840_write4(client, DIF_BPF_COEFF45, 0x001b0029);
4553 cx25840_write4(client, DIF_BPF_COEFF67, 0xffd1ff8a);
4554 cx25840_write4(client, DIF_BPF_COEFF89, 0x002600f2);
4555 cx25840_write4(client, DIF_BPF_COEFF1011, 0x002cfe7c);
4556 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff0f01f0);
4557 cx25840_write4(client, DIF_BPF_COEFF1415, 0x023bfe20);
4558 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc1700fa);
4559 cx25840_write4(client, DIF_BPF_COEFF1819, 0x05a200f7);
4560 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf927fc1c);
4561 cx25840_write4(client, DIF_BPF_COEFF2223, 0x06f40765);
4562 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfa82f53b);
4563 cx25840_write4(client, DIF_BPF_COEFF2627, 0x02510d27);
4564 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0243f23d);
4565 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf8810c24);
4566 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0c5cf7a7);
4567 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf03102fa);
4568 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4569 break;
4570
4571 case 11200000:
4572 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010002);
4573 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffafff2);
4574 cx25840_write4(client, DIF_BPF_COEFF45, 0x00110035);
4575 cx25840_write4(client, DIF_BPF_COEFF67, 0xfff0ff81);
4576 cx25840_write4(client, DIF_BPF_COEFF89, 0xffe700e7);
4577 cx25840_write4(client, DIF_BPF_COEFF1011, 0x008ffeb6);
4578 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe94016d);
4579 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02b0fefb);
4580 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3ffd1);
4581 cx25840_write4(client, DIF_BPF_COEFF1819, 0x05850249);
4582 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf9c1fadb);
4583 cx25840_write4(client, DIF_BPF_COEFF2223, 0x05de0858);
4584 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfbf2f4c4);
4585 cx25840_write4(client, DIF_BPF_COEFF2627, 0x00c70d17);
4586 cx25840_write4(client, DIF_BPF_COEFF2829, 0x03a0f2b8);
4587 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf7870b7c);
4588 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0cdff833);
4589 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf00d02c4);
4590 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4591 break;
4592
4593 case 11300000:
4594 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4595 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffdffee);
4596 cx25840_write4(client, DIF_BPF_COEFF45, 0x00040038);
4597 cx25840_write4(client, DIF_BPF_COEFF67, 0x0010ff88);
4598 cx25840_write4(client, DIF_BPF_COEFF89, 0xffac00c2);
4599 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00e2ff10);
4600 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe3900cb);
4601 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02f1ffe9);
4602 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3feaa);
4603 cx25840_write4(client, DIF_BPF_COEFF1819, 0x05210381);
4604 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfa9cf9c8);
4605 cx25840_write4(client, DIF_BPF_COEFF2223, 0x04990912);
4606 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfd7af484);
4607 cx25840_write4(client, DIF_BPF_COEFF2627, 0xff390cdb);
4608 cx25840_write4(client, DIF_BPF_COEFF2829, 0x04f4f34d);
4609 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf69a0ac9);
4610 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0d5af8c1);
4611 cx25840_write4(client, DIF_BPF_COEFF3435, 0xefec028e);
4612 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4613 break;
4614
4615 case 11400000:
4616 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4617 cx25840_write4(client, DIF_BPF_COEFF23, 0x0000ffee);
4618 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff60033);
4619 cx25840_write4(client, DIF_BPF_COEFF67, 0x002fff9f);
4620 cx25840_write4(client, DIF_BPF_COEFF89, 0xff7b0087);
4621 cx25840_write4(client, DIF_BPF_COEFF1011, 0x011eff82);
4622 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe080018);
4623 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02f900d8);
4624 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17fd96);
4625 cx25840_write4(client, DIF_BPF_COEFF1819, 0x04790490);
4626 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfbadf8ed);
4627 cx25840_write4(client, DIF_BPF_COEFF2223, 0x032f098e);
4628 cx25840_write4(client, DIF_BPF_COEFF2425, 0xff10f47d);
4629 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfdaf0c75);
4630 cx25840_write4(client, DIF_BPF_COEFF2829, 0x063cf3fc);
4631 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf5ba0a0b);
4632 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0dccf952);
4633 cx25840_write4(client, DIF_BPF_COEFF3435, 0xefcd0258);
4634 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4635 break;
4636
4637 case 11500000:
4638 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4639 cx25840_write4(client, DIF_BPF_COEFF23, 0x0004fff1);
4640 cx25840_write4(client, DIF_BPF_COEFF45, 0xffea0026);
4641 cx25840_write4(client, DIF_BPF_COEFF67, 0x0046ffc3);
4642 cx25840_write4(client, DIF_BPF_COEFF89, 0xff5a003c);
4643 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013b0000);
4644 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe04ff63);
4645 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02c801b8);
4646 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99fca6);
4647 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0397056a);
4648 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfcecf853);
4649 cx25840_write4(client, DIF_BPF_COEFF2223, 0x01ad09c9);
4650 cx25840_write4(client, DIF_BPF_COEFF2425, 0x00acf4ad);
4651 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfc2e0be7);
4652 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0773f4c2);
4653 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf4e90943);
4654 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0e35f9e6);
4655 cx25840_write4(client, DIF_BPF_COEFF3435, 0xefb10221);
4656 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4657 break;
4658
4659 case 11600000:
4660 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
4661 cx25840_write4(client, DIF_BPF_COEFF23, 0x0007fff6);
4662 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe20014);
4663 cx25840_write4(client, DIF_BPF_COEFF67, 0x0054ffee);
4664 cx25840_write4(client, DIF_BPF_COEFF89, 0xff4effeb);
4665 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0137007e);
4666 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe2efebb);
4667 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0260027a);
4668 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd51fbe6);
4669 cx25840_write4(client, DIF_BPF_COEFF1819, 0x02870605);
4670 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfe4af7fe);
4671 cx25840_write4(client, DIF_BPF_COEFF2223, 0x001d09c1);
4672 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0243f515);
4673 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfabd0b32);
4674 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0897f59e);
4675 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf4280871);
4676 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0e95fa7c);
4677 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef9701eb);
4678 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4679 break;
4680
4681 case 11700000:
4682 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0001);
4683 cx25840_write4(client, DIF_BPF_COEFF23, 0x0008fffd);
4684 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdeffff);
4685 cx25840_write4(client, DIF_BPF_COEFF67, 0x0056001d);
4686 cx25840_write4(client, DIF_BPF_COEFF89, 0xff57ff9c);
4687 cx25840_write4(client, DIF_BPF_COEFF1011, 0x011300f0);
4688 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe82fe2e);
4689 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01ca0310);
4690 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe35fb62);
4691 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0155065a);
4692 cx25840_write4(client, DIF_BPF_COEFF2021, 0xffbaf7f2);
4693 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfe8c0977);
4694 cx25840_write4(client, DIF_BPF_COEFF2425, 0x03cef5b2);
4695 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf9610a58);
4696 cx25840_write4(client, DIF_BPF_COEFF2829, 0x09a5f68f);
4697 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf3790797);
4698 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0eebfb14);
4699 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef8001b5);
4700 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4701 break;
4702
4703 case 11800000:
4704 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0000);
4705 cx25840_write4(client, DIF_BPF_COEFF23, 0x00080004);
4706 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe0ffe9);
4707 cx25840_write4(client, DIF_BPF_COEFF67, 0x004c0047);
4708 cx25840_write4(client, DIF_BPF_COEFF89, 0xff75ff58);
4709 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00d1014a);
4710 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfef9fdc8);
4711 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0111036f);
4712 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff36fb21);
4713 cx25840_write4(client, DIF_BPF_COEFF1819, 0x00120665);
4714 cx25840_write4(client, DIF_BPF_COEFF2021, 0x012df82e);
4715 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfd0708ec);
4716 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0542f682);
4717 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf81f095c);
4718 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0a9af792);
4719 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf2db06b5);
4720 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0f38fbad);
4721 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef6c017e);
4722 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4723 break;
4724
4725 case 11900000:
4726 cx25840_write4(client, DIF_BPF_COEFF01, 0xffffffff);
4727 cx25840_write4(client, DIF_BPF_COEFF23, 0x0007000b);
4728 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe7ffd8);
4729 cx25840_write4(client, DIF_BPF_COEFF67, 0x00370068);
4730 cx25840_write4(client, DIF_BPF_COEFF89, 0xffa4ff28);
4731 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00790184);
4732 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff87fd91);
4733 cx25840_write4(client, DIF_BPF_COEFF1415, 0x00430392);
4734 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0044fb26);
4735 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfece0626);
4736 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0294f8b2);
4737 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfb990825);
4738 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0698f77f);
4739 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf6fe0842);
4740 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0b73f8a7);
4741 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf25105cd);
4742 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0f7bfc48);
4743 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef5a0148);
4744 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4745 break;
4746
4747 case 12000000:
4748 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
4749 cx25840_write4(client, DIF_BPF_COEFF23, 0x00050010);
4750 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff2ffcc);
4751 cx25840_write4(client, DIF_BPF_COEFF67, 0x001b007b);
4752 cx25840_write4(client, DIF_BPF_COEFF89, 0xffdfff10);
4753 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00140198);
4754 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0020fd8e);
4755 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff710375);
4756 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014dfb73);
4757 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfd9a059f);
4758 cx25840_write4(client, DIF_BPF_COEFF2021, 0x03e0f978);
4759 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfa4e0726);
4760 cx25840_write4(client, DIF_BPF_COEFF2425, 0x07c8f8a7);
4761 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf600070c);
4762 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0c2ff9c9);
4763 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf1db04de);
4764 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0fb4fce5);
4765 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef4b0111);
4766 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4767 break;
4768
4769 case 12100000:
4770 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
4771 cx25840_write4(client, DIF_BPF_COEFF23, 0x00010012);
4772 cx25840_write4(client, DIF_BPF_COEFF45, 0xffffffc8);
4773 cx25840_write4(client, DIF_BPF_COEFF67, 0xfffb007e);
4774 cx25840_write4(client, DIF_BPF_COEFF89, 0x001dff14);
4775 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffad0184);
4776 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00b7fdbe);
4777 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfea9031b);
4778 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0241fc01);
4779 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfc8504d6);
4780 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0504fa79);
4781 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf93005f6);
4782 cx25840_write4(client, DIF_BPF_COEFF2425, 0x08caf9f2);
4783 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf52b05c0);
4784 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0ccbfaf9);
4785 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf17903eb);
4786 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0fe3fd83);
4787 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef3f00db);
4788 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4789 break;
4790
4791 case 12200000:
4792 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
4793 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffe0011);
4794 cx25840_write4(client, DIF_BPF_COEFF45, 0x000cffcc);
4795 cx25840_write4(client, DIF_BPF_COEFF67, 0xffdb0071);
4796 cx25840_write4(client, DIF_BPF_COEFF89, 0x0058ff32);
4797 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff4f014a);
4798 cx25840_write4(client, DIF_BPF_COEFF1213, 0x013cfe1f);
4799 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfdfb028a);
4800 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0311fcc9);
4801 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb9d03d6);
4802 cx25840_write4(client, DIF_BPF_COEFF2021, 0x05f4fbad);
4803 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf848049d);
4804 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0999fb5b);
4805 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf4820461);
4806 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0d46fc32);
4807 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf12d02f4);
4808 cx25840_write4(client, DIF_BPF_COEFF3233, 0x1007fe21);
4809 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef3600a4);
4810 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4811 break;
4812
4813 case 12300000:
4814 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
4815 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffa000e);
4816 cx25840_write4(client, DIF_BPF_COEFF45, 0x0017ffd9);
4817 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc10055);
4818 cx25840_write4(client, DIF_BPF_COEFF89, 0x0088ff68);
4819 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff0400f0);
4820 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01a6fea7);
4821 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd7501cc);
4822 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b0fdc0);
4823 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfaef02a8);
4824 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06a7fd07);
4825 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf79d0326);
4826 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a31fcda);
4827 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf40702f3);
4828 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0d9ffd72);
4829 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0f601fa);
4830 cx25840_write4(client, DIF_BPF_COEFF3233, 0x1021fec0);
4831 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef2f006d);
4832 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4833 break;
4834
4835 case 12400000:
4836 cx25840_write4(client, DIF_BPF_COEFF01, 0x0001ffff);
4837 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff80007);
4838 cx25840_write4(client, DIF_BPF_COEFF45, 0x001fffeb);
4839 cx25840_write4(client, DIF_BPF_COEFF67, 0xffaf002d);
4840 cx25840_write4(client, DIF_BPF_COEFF89, 0x00a8ffb0);
4841 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfed3007e);
4842 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01e9ff4c);
4843 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd2000ee);
4844 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0413fed8);
4845 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa82015c);
4846 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0715fe7d);
4847 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf7340198);
4848 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a8dfe69);
4849 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf3bd017c);
4850 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0dd5feb8);
4851 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0d500fd);
4852 cx25840_write4(client, DIF_BPF_COEFF3233, 0x1031ff60);
4853 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef2b0037);
4854 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4855 break;
4856
4857 case 12500000:
4858 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010000);
4859 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff70000);
4860 cx25840_write4(client, DIF_BPF_COEFF45, 0x00220000);
4861 cx25840_write4(client, DIF_BPF_COEFF67, 0xffa90000);
4862 cx25840_write4(client, DIF_BPF_COEFF89, 0x00b30000);
4863 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfec20000);
4864 cx25840_write4(client, DIF_BPF_COEFF1213, 0x02000000);
4865 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd030000);
4866 cx25840_write4(client, DIF_BPF_COEFF1617, 0x04350000);
4867 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa5e0000);
4868 cx25840_write4(client, DIF_BPF_COEFF2021, 0x073b0000);
4869 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf7110000);
4870 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0aac0000);
4871 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf3a40000);
4872 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0de70000);
4873 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0c90000);
4874 cx25840_write4(client, DIF_BPF_COEFF3233, 0x10360000);
4875 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef290000);
4876 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4877 break;
4878
4879 case 12600000:
4880 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010001);
4881 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff8fff9);
4882 cx25840_write4(client, DIF_BPF_COEFF45, 0x001f0015);
4883 cx25840_write4(client, DIF_BPF_COEFF67, 0xffafffd3);
4884 cx25840_write4(client, DIF_BPF_COEFF89, 0x00a80050);
4885 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfed3ff82);
4886 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01e900b4);
4887 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd20ff12);
4888 cx25840_write4(client, DIF_BPF_COEFF1617, 0x04130128);
4889 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa82fea4);
4890 cx25840_write4(client, DIF_BPF_COEFF2021, 0x07150183);
4891 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf734fe68);
4892 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a8d0197);
4893 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf3bdfe84);
4894 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0dd50148);
4895 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0d5ff03);
4896 cx25840_write4(client, DIF_BPF_COEFF3233, 0x103100a0);
4897 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef2bffc9);
4898 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4899 break;
4900
4901 case 12700000:
4902 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
4903 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffafff2);
4904 cx25840_write4(client, DIF_BPF_COEFF45, 0x00170027);
4905 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc1ffab);
4906 cx25840_write4(client, DIF_BPF_COEFF89, 0x00880098);
4907 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff04ff10);
4908 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01a60159);
4909 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd75fe34);
4910 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b00240);
4911 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfaeffd58);
4912 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06a702f9);
4913 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf79dfcda);
4914 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0a310326);
4915 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf407fd0d);
4916 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0d9f028e);
4917 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf0f6fe06);
4918 cx25840_write4(client, DIF_BPF_COEFF3233, 0x10210140);
4919 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef2fff93);
4920 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4921 break;
4922
4923 case 12800000:
4924 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4925 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffeffef);
4926 cx25840_write4(client, DIF_BPF_COEFF45, 0x000c0034);
4927 cx25840_write4(client, DIF_BPF_COEFF67, 0xffdbff8f);
4928 cx25840_write4(client, DIF_BPF_COEFF89, 0x005800ce);
4929 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff4ffeb6);
4930 cx25840_write4(client, DIF_BPF_COEFF1213, 0x013c01e1);
4931 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfdfbfd76);
4932 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03110337);
4933 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb9dfc2a);
4934 cx25840_write4(client, DIF_BPF_COEFF2021, 0x05f40453);
4935 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf848fb63);
4936 cx25840_write4(client, DIF_BPF_COEFF2425, 0x099904a5);
4937 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf482fb9f);
4938 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0d4603ce);
4939 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf12dfd0c);
4940 cx25840_write4(client, DIF_BPF_COEFF3233, 0x100701df);
4941 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef36ff5c);
4942 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4943 break;
4944
4945 case 12900000:
4946 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
4947 cx25840_write4(client, DIF_BPF_COEFF23, 0x0001ffee);
4948 cx25840_write4(client, DIF_BPF_COEFF45, 0xffff0038);
4949 cx25840_write4(client, DIF_BPF_COEFF67, 0xfffbff82);
4950 cx25840_write4(client, DIF_BPF_COEFF89, 0x001d00ec);
4951 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffadfe7c);
4952 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00b70242);
4953 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfea9fce5);
4954 cx25840_write4(client, DIF_BPF_COEFF1617, 0x024103ff);
4955 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfc85fb2a);
4956 cx25840_write4(client, DIF_BPF_COEFF2021, 0x05040587);
4957 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf930fa0a);
4958 cx25840_write4(client, DIF_BPF_COEFF2425, 0x08ca060e);
4959 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf52bfa40);
4960 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0ccb0507);
4961 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf179fc15);
4962 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0fe3027d);
4963 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef3fff25);
4964 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4965 break;
4966
4967 case 13000000:
4968 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
4969 cx25840_write4(client, DIF_BPF_COEFF23, 0x0005fff0);
4970 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff20034);
4971 cx25840_write4(client, DIF_BPF_COEFF67, 0x001bff85);
4972 cx25840_write4(client, DIF_BPF_COEFF89, 0xffdf00f0);
4973 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0014fe68);
4974 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00200272);
4975 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff71fc8b);
4976 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014d048d);
4977 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfd9afa61);
4978 cx25840_write4(client, DIF_BPF_COEFF2021, 0x03e00688);
4979 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfa4ef8da);
4980 cx25840_write4(client, DIF_BPF_COEFF2425, 0x07c80759);
4981 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf600f8f4);
4982 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0c2f0637);
4983 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf1dbfb22);
4984 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0fb4031b);
4985 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef4bfeef);
4986 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
4987 break;
4988
4989 case 13100000:
4990 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0001);
4991 cx25840_write4(client, DIF_BPF_COEFF23, 0x0007fff5);
4992 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe70028);
4993 cx25840_write4(client, DIF_BPF_COEFF67, 0x0037ff98);
4994 cx25840_write4(client, DIF_BPF_COEFF89, 0xffa400d8);
4995 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0079fe7c);
4996 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff87026f);
4997 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0043fc6e);
4998 cx25840_write4(client, DIF_BPF_COEFF1617, 0x004404da);
4999 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfecef9da);
5000 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0294074e);
5001 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfb99f7db);
5002 cx25840_write4(client, DIF_BPF_COEFF2425, 0x06980881);
5003 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf6fef7be);
5004 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0b730759);
5005 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf251fa33);
5006 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0f7b03b8);
5007 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef5afeb8);
5008 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5009 break;
5010
5011 case 13200000:
5012 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0000);
5013 cx25840_write4(client, DIF_BPF_COEFF23, 0x0008fffc);
5014 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe00017);
5015 cx25840_write4(client, DIF_BPF_COEFF67, 0x004cffb9);
5016 cx25840_write4(client, DIF_BPF_COEFF89, 0xff7500a8);
5017 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00d1feb6);
5018 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfef90238);
5019 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0111fc91);
5020 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff3604df);
5021 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0012f99b);
5022 cx25840_write4(client, DIF_BPF_COEFF2021, 0x012d07d2);
5023 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfd07f714);
5024 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0542097e);
5025 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf81ff6a4);
5026 cx25840_write4(client, DIF_BPF_COEFF2829, 0x0a9a086e);
5027 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf2dbf94b);
5028 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0f380453);
5029 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef6cfe82);
5030 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5031 break;
5032
5033 case 13300000:
5034 cx25840_write4(client, DIF_BPF_COEFF01, 0xffffffff);
5035 cx25840_write4(client, DIF_BPF_COEFF23, 0x00080003);
5036 cx25840_write4(client, DIF_BPF_COEFF45, 0xffde0001);
5037 cx25840_write4(client, DIF_BPF_COEFF67, 0x0056ffe3);
5038 cx25840_write4(client, DIF_BPF_COEFF89, 0xff570064);
5039 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0113ff10);
5040 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe8201d2);
5041 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01cafcf0);
5042 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe35049e);
5043 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0155f9a6);
5044 cx25840_write4(client, DIF_BPF_COEFF2021, 0xffba080e);
5045 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfe8cf689);
5046 cx25840_write4(client, DIF_BPF_COEFF2425, 0x03ce0a4e);
5047 cx25840_write4(client, DIF_BPF_COEFF2627, 0xf961f5a8);
5048 cx25840_write4(client, DIF_BPF_COEFF2829, 0x09a50971);
5049 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf379f869);
5050 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0eeb04ec);
5051 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef80fe4b);
5052 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5053 break;
5054
5055 case 13400000:
5056 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
5057 cx25840_write4(client, DIF_BPF_COEFF23, 0x0007000a);
5058 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe2ffec);
5059 cx25840_write4(client, DIF_BPF_COEFF67, 0x00540012);
5060 cx25840_write4(client, DIF_BPF_COEFF89, 0xff4e0015);
5061 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0137ff82);
5062 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe2e0145);
5063 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0260fd86);
5064 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd51041a);
5065 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0287f9fb);
5066 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfe4a0802);
5067 cx25840_write4(client, DIF_BPF_COEFF2223, 0x001df63f);
5068 cx25840_write4(client, DIF_BPF_COEFF2425, 0x02430aeb);
5069 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfabdf4ce);
5070 cx25840_write4(client, DIF_BPF_COEFF2829, 0x08970a62);
5071 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf428f78f);
5072 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0e950584);
5073 cx25840_write4(client, DIF_BPF_COEFF3435, 0xef97fe15);
5074 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5075 break;
5076
5077 case 13500000:
5078 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
5079 cx25840_write4(client, DIF_BPF_COEFF23, 0x0004000f);
5080 cx25840_write4(client, DIF_BPF_COEFF45, 0xffeaffda);
5081 cx25840_write4(client, DIF_BPF_COEFF67, 0x0046003d);
5082 cx25840_write4(client, DIF_BPF_COEFF89, 0xff5affc4);
5083 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013b0000);
5084 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe04009d);
5085 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02c8fe48);
5086 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99035a);
5087 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0397fa96);
5088 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfcec07ad);
5089 cx25840_write4(client, DIF_BPF_COEFF2223, 0x01adf637);
5090 cx25840_write4(client, DIF_BPF_COEFF2425, 0x00ac0b53);
5091 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfc2ef419);
5092 cx25840_write4(client, DIF_BPF_COEFF2829, 0x07730b3e);
5093 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf4e9f6bd);
5094 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0e35061a);
5095 cx25840_write4(client, DIF_BPF_COEFF3435, 0xefb1fddf);
5096 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5097 break;
5098
5099 case 13600000:
5100 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
5101 cx25840_write4(client, DIF_BPF_COEFF23, 0x00000012);
5102 cx25840_write4(client, DIF_BPF_COEFF45, 0xfff6ffcd);
5103 cx25840_write4(client, DIF_BPF_COEFF67, 0x002f0061);
5104 cx25840_write4(client, DIF_BPF_COEFF89, 0xff7bff79);
5105 cx25840_write4(client, DIF_BPF_COEFF1011, 0x011e007e);
5106 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe08ffe8);
5107 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02f9ff28);
5108 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17026a);
5109 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0479fb70);
5110 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfbad0713);
5111 cx25840_write4(client, DIF_BPF_COEFF2223, 0x032ff672);
5112 cx25840_write4(client, DIF_BPF_COEFF2425, 0xff100b83);
5113 cx25840_write4(client, DIF_BPF_COEFF2627, 0xfdaff38b);
5114 cx25840_write4(client, DIF_BPF_COEFF2829, 0x063c0c04);
5115 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf5baf5f5);
5116 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0dcc06ae);
5117 cx25840_write4(client, DIF_BPF_COEFF3435, 0xefcdfda8);
5118 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5119 break;
5120
5121 case 13700000:
5122 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
5123 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffd0012);
5124 cx25840_write4(client, DIF_BPF_COEFF45, 0x0004ffc8);
5125 cx25840_write4(client, DIF_BPF_COEFF67, 0x00100078);
5126 cx25840_write4(client, DIF_BPF_COEFF89, 0xffacff3e);
5127 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00e200f0);
5128 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe39ff35);
5129 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02f10017);
5130 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd30156);
5131 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0521fc7f);
5132 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfa9c0638);
5133 cx25840_write4(client, DIF_BPF_COEFF2223, 0x0499f6ee);
5134 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfd7a0b7c);
5135 cx25840_write4(client, DIF_BPF_COEFF2627, 0xff39f325);
5136 cx25840_write4(client, DIF_BPF_COEFF2829, 0x04f40cb3);
5137 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf69af537);
5138 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0d5a073f);
5139 cx25840_write4(client, DIF_BPF_COEFF3435, 0xefecfd72);
5140 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5141 break;
5142
5143 case 13800000:
5144 cx25840_write4(client, DIF_BPF_COEFF01, 0x0001fffe);
5145 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffa000e);
5146 cx25840_write4(client, DIF_BPF_COEFF45, 0x0011ffcb);
5147 cx25840_write4(client, DIF_BPF_COEFF67, 0xfff0007f);
5148 cx25840_write4(client, DIF_BPF_COEFF89, 0xffe7ff19);
5149 cx25840_write4(client, DIF_BPF_COEFF1011, 0x008f014a);
5150 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe94fe93);
5151 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02b00105);
5152 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfbd3002f);
5153 cx25840_write4(client, DIF_BPF_COEFF1819, 0x0585fdb7);
5154 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf9c10525);
5155 cx25840_write4(client, DIF_BPF_COEFF2223, 0x05def7a8);
5156 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfbf20b3c);
5157 cx25840_write4(client, DIF_BPF_COEFF2627, 0x00c7f2e9);
5158 cx25840_write4(client, DIF_BPF_COEFF2829, 0x03a00d48);
5159 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf787f484);
5160 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0cdf07cd);
5161 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf00dfd3c);
5162 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5163 break;
5164
5165 case 13900000:
5166 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010000);
5167 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff80008);
5168 cx25840_write4(client, DIF_BPF_COEFF45, 0x001bffd7);
5169 cx25840_write4(client, DIF_BPF_COEFF67, 0xffd10076);
5170 cx25840_write4(client, DIF_BPF_COEFF89, 0x0026ff0e);
5171 cx25840_write4(client, DIF_BPF_COEFF1011, 0x002c0184);
5172 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff0ffe10);
5173 cx25840_write4(client, DIF_BPF_COEFF1415, 0x023b01e0);
5174 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc17ff06);
5175 cx25840_write4(client, DIF_BPF_COEFF1819, 0x05a2ff09);
5176 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf92703e4);
5177 cx25840_write4(client, DIF_BPF_COEFF2223, 0x06f4f89b);
5178 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfa820ac5);
5179 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0251f2d9);
5180 cx25840_write4(client, DIF_BPF_COEFF2829, 0x02430dc3);
5181 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf881f3dc);
5182 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0c5c0859);
5183 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf031fd06);
5184 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5185 break;
5186
5187 case 14000000:
5188 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010001);
5189 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff80001);
5190 cx25840_write4(client, DIF_BPF_COEFF45, 0x0021ffe8);
5191 cx25840_write4(client, DIF_BPF_COEFF67, 0xffba005d);
5192 cx25840_write4(client, DIF_BPF_COEFF89, 0x0060ff1f);
5193 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffc40198);
5194 cx25840_write4(client, DIF_BPF_COEFF1213, 0xffa0fdb5);
5195 cx25840_write4(client, DIF_BPF_COEFF1415, 0x019a029a);
5196 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99fdea);
5197 cx25840_write4(client, DIF_BPF_COEFF1819, 0x05750067);
5198 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8d4027f);
5199 cx25840_write4(client, DIF_BPF_COEFF2223, 0x07d4f9c0);
5200 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf9320a1a);
5201 cx25840_write4(client, DIF_BPF_COEFF2627, 0x03d2f2f3);
5202 cx25840_write4(client, DIF_BPF_COEFF2829, 0x00df0e22);
5203 cx25840_write4(client, DIF_BPF_COEFF3031, 0xf986f341);
5204 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0bd108e2);
5205 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf058fcd1);
5206 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5207 break;
5208
5209 case 14100000:
5210 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
5211 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff9fffa);
5212 cx25840_write4(client, DIF_BPF_COEFF45, 0x0021fffd);
5213 cx25840_write4(client, DIF_BPF_COEFF67, 0xffac0038);
5214 cx25840_write4(client, DIF_BPF_COEFF89, 0x008eff4a);
5215 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff630184);
5216 cx25840_write4(client, DIF_BPF_COEFF1213, 0x003afd8b);
5217 cx25840_write4(client, DIF_BPF_COEFF1415, 0x00da0326);
5218 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd51fced);
5219 cx25840_write4(client, DIF_BPF_COEFF1819, 0x050101c0);
5220 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf8cb0103);
5221 cx25840_write4(client, DIF_BPF_COEFF2223, 0x0876fb10);
5222 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf80a093e);
5223 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0543f338);
5224 cx25840_write4(client, DIF_BPF_COEFF2829, 0xff7a0e66);
5225 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfa94f2b2);
5226 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0b3f0967);
5227 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf081fc9b);
5228 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5229 break;
5230
5231 case 14200000:
5232 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
5233 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffbfff3);
5234 cx25840_write4(client, DIF_BPF_COEFF45, 0x001d0013);
5235 cx25840_write4(client, DIF_BPF_COEFF67, 0xffaa000b);
5236 cx25840_write4(client, DIF_BPF_COEFF89, 0x00aaff89);
5237 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff13014a);
5238 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00cefd95);
5239 cx25840_write4(client, DIF_BPF_COEFF1415, 0x000a037b);
5240 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe35fc1d);
5241 cx25840_write4(client, DIF_BPF_COEFF1819, 0x044c0305);
5242 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf90cff7e);
5243 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08d5fc81);
5244 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf7100834);
5245 cx25840_write4(client, DIF_BPF_COEFF2627, 0x069ff3a7);
5246 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfe160e8d);
5247 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfbaaf231);
5248 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0aa509e9);
5249 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf0adfc65);
5250 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5251 break;
5252
5253 case 14300000:
5254 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
5255 cx25840_write4(client, DIF_BPF_COEFF23, 0xffffffef);
5256 cx25840_write4(client, DIF_BPF_COEFF45, 0x00140025);
5257 cx25840_write4(client, DIF_BPF_COEFF67, 0xffb4ffdd);
5258 cx25840_write4(client, DIF_BPF_COEFF89, 0x00b2ffd6);
5259 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfedb00f0);
5260 cx25840_write4(client, DIF_BPF_COEFF1213, 0x0150fdd3);
5261 cx25840_write4(client, DIF_BPF_COEFF1415, 0xff380391);
5262 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff36fb85);
5263 cx25840_write4(client, DIF_BPF_COEFF1819, 0x035e0426);
5264 cx25840_write4(client, DIF_BPF_COEFF2021, 0xf994fdfe);
5265 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08eefe0b);
5266 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf6490702);
5267 cx25840_write4(client, DIF_BPF_COEFF2627, 0x07e1f43e);
5268 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfcb60e97);
5269 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfcc6f1be);
5270 cx25840_write4(client, DIF_BPF_COEFF3233, 0x0a040a67);
5271 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf0dbfc30);
5272 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5273 break;
5274
5275 case 14400000:
5276 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
5277 cx25840_write4(client, DIF_BPF_COEFF23, 0x0002ffee);
5278 cx25840_write4(client, DIF_BPF_COEFF45, 0x00070033);
5279 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc9ffb4);
5280 cx25840_write4(client, DIF_BPF_COEFF89, 0x00a40027);
5281 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfec3007e);
5282 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01b4fe3f);
5283 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe760369);
5284 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0044fb2e);
5285 cx25840_write4(client, DIF_BPF_COEFF1819, 0x02450518);
5286 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfa5ffc90);
5287 cx25840_write4(client, DIF_BPF_COEFF2223, 0x08c1ffa1);
5288 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf5bc05ae);
5289 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0902f4fc);
5290 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfb600e85);
5291 cx25840_write4(client, DIF_BPF_COEFF3031, 0xfde7f15a);
5292 cx25840_write4(client, DIF_BPF_COEFF3233, 0x095d0ae2);
5293 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf10cfbfb);
5294 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5295 break;
5296
5297 case 14500000:
5298 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0002);
5299 cx25840_write4(client, DIF_BPF_COEFF23, 0x0005ffef);
5300 cx25840_write4(client, DIF_BPF_COEFF45, 0xfffa0038);
5301 cx25840_write4(client, DIF_BPF_COEFF67, 0xffe5ff95);
5302 cx25840_write4(client, DIF_BPF_COEFF89, 0x00820074);
5303 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfecc0000);
5304 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01f0fed0);
5305 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfdd20304);
5306 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014dfb1d);
5307 cx25840_write4(client, DIF_BPF_COEFF1819, 0x010e05ce);
5308 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfb64fb41);
5309 cx25840_write4(client, DIF_BPF_COEFF2223, 0x084e013b);
5310 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf569043e);
5311 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0a00f5dd);
5312 cx25840_write4(client, DIF_BPF_COEFF2829, 0xfa150e55);
5313 cx25840_write4(client, DIF_BPF_COEFF3031, 0xff0bf104);
5314 cx25840_write4(client, DIF_BPF_COEFF3233, 0x08b00b59);
5315 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf13ffbc6);
5316 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5317 break;
5318
5319 case 14600000:
5320 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0001);
5321 cx25840_write4(client, DIF_BPF_COEFF23, 0x0008fff4);
5322 cx25840_write4(client, DIF_BPF_COEFF45, 0xffed0035);
5323 cx25840_write4(client, DIF_BPF_COEFF67, 0x0005ff83);
5324 cx25840_write4(client, DIF_BPF_COEFF89, 0x005000b4);
5325 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfef6ff82);
5326 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01ffff7a);
5327 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd580269);
5328 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0241fb53);
5329 cx25840_write4(client, DIF_BPF_COEFF1819, 0xffca0640);
5330 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfc99fa1e);
5331 cx25840_write4(client, DIF_BPF_COEFF2223, 0x079a02cb);
5332 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf55502ba);
5333 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0ad5f6e0);
5334 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf8d90e0a);
5335 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0031f0bd);
5336 cx25840_write4(client, DIF_BPF_COEFF3233, 0x07fd0bcb);
5337 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf174fb91);
5338 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5339 break;
5340
5341 case 14700000:
5342 cx25840_write4(client, DIF_BPF_COEFF01, 0xffffffff);
5343 cx25840_write4(client, DIF_BPF_COEFF23, 0x0009fffb);
5344 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe4002a);
5345 cx25840_write4(client, DIF_BPF_COEFF67, 0x0025ff82);
5346 cx25840_write4(client, DIF_BPF_COEFF89, 0x001400e0);
5347 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff3cff10);
5348 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01e10030);
5349 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd1201a4);
5350 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0311fbcd);
5351 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfe88066a);
5352 cx25840_write4(client, DIF_BPF_COEFF2021, 0xfdf1f92f);
5353 cx25840_write4(client, DIF_BPF_COEFF2223, 0x06aa0449);
5354 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf57e0128);
5355 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0b7ef801);
5356 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf7b00da2);
5357 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0156f086);
5358 cx25840_write4(client, DIF_BPF_COEFF3233, 0x07450c39);
5359 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf1acfb5c);
5360 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5361 break;
5362
5363 case 14800000:
5364 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffe);
5365 cx25840_write4(client, DIF_BPF_COEFF23, 0x00080002);
5366 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdf0019);
5367 cx25840_write4(client, DIF_BPF_COEFF67, 0x003fff92);
5368 cx25840_write4(client, DIF_BPF_COEFF89, 0xffd600f1);
5369 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff96feb6);
5370 cx25840_write4(client, DIF_BPF_COEFF1213, 0x019700e1);
5371 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd0500c2);
5372 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b0fc84);
5373 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfd590649);
5374 cx25840_write4(client, DIF_BPF_COEFF2021, 0xff5df87f);
5375 cx25840_write4(client, DIF_BPF_COEFF2223, 0x058505aa);
5376 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf5e4ff91);
5377 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0bf9f93c);
5378 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf69d0d20);
5379 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0279f05e);
5380 cx25840_write4(client, DIF_BPF_COEFF3233, 0x06880ca3);
5381 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf1e6fb28);
5382 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5383 break;
5384
5385 case 14900000:
5386 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
5387 cx25840_write4(client, DIF_BPF_COEFF23, 0x00060009);
5388 cx25840_write4(client, DIF_BPF_COEFF45, 0xffdf0004);
5389 cx25840_write4(client, DIF_BPF_COEFF67, 0x0051ffb0);
5390 cx25840_write4(client, DIF_BPF_COEFF89, 0xff9d00e8);
5391 cx25840_write4(client, DIF_BPF_COEFF1011, 0xfffcfe7c);
5392 cx25840_write4(client, DIF_BPF_COEFF1213, 0x01280180);
5393 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd32ffd2);
5394 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0413fd6e);
5395 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfc4d05df);
5396 cx25840_write4(client, DIF_BPF_COEFF2021, 0x00d1f812);
5397 cx25840_write4(client, DIF_BPF_COEFF2223, 0x043506e4);
5398 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf685fdfb);
5399 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c43fa8d);
5400 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf5a10c83);
5401 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0399f046);
5402 cx25840_write4(client, DIF_BPF_COEFF3233, 0x05c70d08);
5403 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf222faf3);
5404 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5405 break;
5406
5407 case 15000000:
5408 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
5409 cx25840_write4(client, DIF_BPF_COEFF23, 0x0003000f);
5410 cx25840_write4(client, DIF_BPF_COEFF45, 0xffe5ffef);
5411 cx25840_write4(client, DIF_BPF_COEFF67, 0x0057ffd9);
5412 cx25840_write4(client, DIF_BPF_COEFF89, 0xff7000c4);
5413 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0062fe68);
5414 cx25840_write4(client, DIF_BPF_COEFF1213, 0x009e01ff);
5415 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfd95fee6);
5416 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0435fe7d);
5417 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb710530);
5418 cx25840_write4(client, DIF_BPF_COEFF2021, 0x023cf7ee);
5419 cx25840_write4(client, DIF_BPF_COEFF2223, 0x02c307ef);
5420 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf75efc70);
5421 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c5cfbef);
5422 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf4c10bce);
5423 cx25840_write4(client, DIF_BPF_COEFF3031, 0x04b3f03f);
5424 cx25840_write4(client, DIF_BPF_COEFF3233, 0x05030d69);
5425 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf261fabf);
5426 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5427 break;
5428
5429 case 15100000:
5430 cx25840_write4(client, DIF_BPF_COEFF01, 0x0000fffd);
5431 cx25840_write4(client, DIF_BPF_COEFF23, 0xffff0012);
5432 cx25840_write4(client, DIF_BPF_COEFF45, 0xffefffdc);
5433 cx25840_write4(client, DIF_BPF_COEFF67, 0x00510006);
5434 cx25840_write4(client, DIF_BPF_COEFF89, 0xff540089);
5435 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00befe7c);
5436 cx25840_write4(client, DIF_BPF_COEFF1213, 0x00060253);
5437 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfe27fe0d);
5438 cx25840_write4(client, DIF_BPF_COEFF1617, 0x0413ffa2);
5439 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfad10446);
5440 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0390f812);
5441 cx25840_write4(client, DIF_BPF_COEFF2223, 0x013b08c3);
5442 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf868faf6);
5443 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0c43fd5f);
5444 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf3fd0b02);
5445 cx25840_write4(client, DIF_BPF_COEFF3031, 0x05c7f046);
5446 cx25840_write4(client, DIF_BPF_COEFF3233, 0x043b0dc4);
5447 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf2a1fa8b);
5448 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5449 break;
5450
5451 case 15200000:
5452 cx25840_write4(client, DIF_BPF_COEFF01, 0x0001fffe);
5453 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffc0012);
5454 cx25840_write4(client, DIF_BPF_COEFF45, 0xfffbffce);
5455 cx25840_write4(client, DIF_BPF_COEFF67, 0x003f0033);
5456 cx25840_write4(client, DIF_BPF_COEFF89, 0xff4e003f);
5457 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0106feb6);
5458 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff6e0276);
5459 cx25840_write4(client, DIF_BPF_COEFF1415, 0xfeddfd56);
5460 cx25840_write4(client, DIF_BPF_COEFF1617, 0x03b000cc);
5461 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa740329);
5462 cx25840_write4(client, DIF_BPF_COEFF2021, 0x04bff87f);
5463 cx25840_write4(client, DIF_BPF_COEFF2223, 0xffaa095d);
5464 cx25840_write4(client, DIF_BPF_COEFF2425, 0xf99ef995);
5465 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0bf9fed8);
5466 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf3590a1f);
5467 cx25840_write4(client, DIF_BPF_COEFF3031, 0x06d2f05e);
5468 cx25840_write4(client, DIF_BPF_COEFF3233, 0x03700e1b);
5469 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf2e4fa58);
5470 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5471 break;
5472
5473 case 15300000:
5474 cx25840_write4(client, DIF_BPF_COEFF01, 0x0001ffff);
5475 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff9000f);
5476 cx25840_write4(client, DIF_BPF_COEFF45, 0x0009ffc8);
5477 cx25840_write4(client, DIF_BPF_COEFF67, 0x00250059);
5478 cx25840_write4(client, DIF_BPF_COEFF89, 0xff5effee);
5479 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0132ff10);
5480 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfee30265);
5481 cx25840_write4(client, DIF_BPF_COEFF1415, 0xffaafccf);
5482 cx25840_write4(client, DIF_BPF_COEFF1617, 0x031101eb);
5483 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa6001e8);
5484 cx25840_write4(client, DIF_BPF_COEFF2021, 0x05bdf92f);
5485 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfe1b09b6);
5486 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfafaf852);
5487 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0b7e0055);
5488 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf2d50929);
5489 cx25840_write4(client, DIF_BPF_COEFF3031, 0x07d3f086);
5490 cx25840_write4(client, DIF_BPF_COEFF3233, 0x02a30e6c);
5491 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf329fa24);
5492 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5493 break;
5494
5495 case 15400000:
5496 cx25840_write4(client, DIF_BPF_COEFF01, 0x00010001);
5497 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff80009);
5498 cx25840_write4(client, DIF_BPF_COEFF45, 0x0015ffca);
5499 cx25840_write4(client, DIF_BPF_COEFF67, 0x00050074);
5500 cx25840_write4(client, DIF_BPF_COEFF89, 0xff81ff9f);
5501 cx25840_write4(client, DIF_BPF_COEFF1011, 0x013dff82);
5502 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe710221);
5503 cx25840_write4(client, DIF_BPF_COEFF1415, 0x007cfc80);
5504 cx25840_write4(client, DIF_BPF_COEFF1617, 0x024102ed);
5505 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfa940090);
5506 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0680fa1e);
5507 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfc9b09cd);
5508 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfc73f736);
5509 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0ad501d0);
5510 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf2740820);
5511 cx25840_write4(client, DIF_BPF_COEFF3031, 0x08c9f0bd);
5512 cx25840_write4(client, DIF_BPF_COEFF3233, 0x01d40eb9);
5513 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf371f9f1);
5514 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5515 break;
5516
5517 case 15500000:
5518 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000002);
5519 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff80002);
5520 cx25840_write4(client, DIF_BPF_COEFF45, 0x001effd5);
5521 cx25840_write4(client, DIF_BPF_COEFF67, 0xffe5007f);
5522 cx25840_write4(client, DIF_BPF_COEFF89, 0xffb4ff5b);
5523 cx25840_write4(client, DIF_BPF_COEFF1011, 0x01280000);
5524 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe2401b0);
5525 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0146fc70);
5526 cx25840_write4(client, DIF_BPF_COEFF1617, 0x014d03c6);
5527 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfb10ff32);
5528 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0701fb41);
5529 cx25840_write4(client, DIF_BPF_COEFF2223, 0xfb3709a1);
5530 cx25840_write4(client, DIF_BPF_COEFF2425, 0xfe00f644);
5531 cx25840_write4(client, DIF_BPF_COEFF2627, 0x0a000345);
5532 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf2350708);
5533 cx25840_write4(client, DIF_BPF_COEFF3031, 0x09b2f104);
5534 cx25840_write4(client, DIF_BPF_COEFF3233, 0x01050eff);
5535 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf3baf9be);
5536 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5537 break;
5538
5539 case 15600000:
5540 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
5541 cx25840_write4(client, DIF_BPF_COEFF23, 0xfff9fffb);
5542 cx25840_write4(client, DIF_BPF_COEFF45, 0x0022ffe6);
5543 cx25840_write4(client, DIF_BPF_COEFF67, 0xffc9007a);
5544 cx25840_write4(client, DIF_BPF_COEFF89, 0xfff0ff29);
5545 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00f2007e);
5546 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe01011b);
5547 cx25840_write4(client, DIF_BPF_COEFF1415, 0x01f6fc9e);
5548 cx25840_write4(client, DIF_BPF_COEFF1617, 0x00440467);
5549 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfbccfdde);
5550 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0738fc90);
5551 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf9f70934);
5552 cx25840_write4(client, DIF_BPF_COEFF2425, 0xff99f582);
5553 cx25840_write4(client, DIF_BPF_COEFF2627, 0x090204b0);
5554 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf21a05e1);
5555 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0a8df15a);
5556 cx25840_write4(client, DIF_BPF_COEFF3233, 0x00340f41);
5557 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf405f98b);
5558 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5559 break;
5560
5561 case 15700000:
5562 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
5563 cx25840_write4(client, DIF_BPF_COEFF23, 0xfffcfff4);
5564 cx25840_write4(client, DIF_BPF_COEFF45, 0x0020fffa);
5565 cx25840_write4(client, DIF_BPF_COEFF67, 0xffb40064);
5566 cx25840_write4(client, DIF_BPF_COEFF89, 0x002fff11);
5567 cx25840_write4(client, DIF_BPF_COEFF1011, 0x00a400f0);
5568 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe0d006e);
5569 cx25840_write4(client, DIF_BPF_COEFF1415, 0x0281fd09);
5570 cx25840_write4(client, DIF_BPF_COEFF1617, 0xff3604c9);
5571 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfcbffca2);
5572 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0726fdfe);
5573 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf8e80888);
5574 cx25840_write4(client, DIF_BPF_COEFF2425, 0x0134f4f3);
5575 cx25840_write4(client, DIF_BPF_COEFF2627, 0x07e1060c);
5576 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf22304af);
5577 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0b59f1be);
5578 cx25840_write4(client, DIF_BPF_COEFF3233, 0xff640f7d);
5579 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf452f959);
5580 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5581 break;
5582
5583 case 15800000:
5584 cx25840_write4(client, DIF_BPF_COEFF01, 0x00000003);
5585 cx25840_write4(client, DIF_BPF_COEFF23, 0x0000fff0);
5586 cx25840_write4(client, DIF_BPF_COEFF45, 0x001a0010);
5587 cx25840_write4(client, DIF_BPF_COEFF67, 0xffaa0041);
5588 cx25840_write4(client, DIF_BPF_COEFF89, 0x0067ff13);
5589 cx25840_write4(client, DIF_BPF_COEFF1011, 0x0043014a);
5590 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfe46ffb9);
5591 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02dbfda8);
5592 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfe3504e5);
5593 cx25840_write4(client, DIF_BPF_COEFF1819, 0xfddcfb8d);
5594 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06c9ff7e);
5595 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf81107a2);
5596 cx25840_write4(client, DIF_BPF_COEFF2425, 0x02c9f49a);
5597 cx25840_write4(client, DIF_BPF_COEFF2627, 0x069f0753);
5598 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf2500373);
5599 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0c14f231);
5600 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfe930fb3);
5601 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf4a1f927);
5602 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5603 break;
5604
5605 case 15900000:
5606 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0002);
5607 cx25840_write4(client, DIF_BPF_COEFF23, 0x0003ffee);
5608 cx25840_write4(client, DIF_BPF_COEFF45, 0x000f0023);
5609 cx25840_write4(client, DIF_BPF_COEFF67, 0xffac0016);
5610 cx25840_write4(client, DIF_BPF_COEFF89, 0x0093ff31);
5611 cx25840_write4(client, DIF_BPF_COEFF1011, 0xffdc0184);
5612 cx25840_write4(client, DIF_BPF_COEFF1213, 0xfea6ff09);
5613 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02fdfe70);
5614 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfd5104ba);
5615 cx25840_write4(client, DIF_BPF_COEFF1819, 0xff15faac);
5616 cx25840_write4(client, DIF_BPF_COEFF2021, 0x06270103);
5617 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf7780688);
5618 cx25840_write4(client, DIF_BPF_COEFF2425, 0x044df479);
5619 cx25840_write4(client, DIF_BPF_COEFF2627, 0x05430883);
5620 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf2a00231);
5621 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0cbef2b2);
5622 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfdc40fe3);
5623 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf4f2f8f5);
5624 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5625 break;
5626
5627 case 16000000:
5628 cx25840_write4(client, DIF_BPF_COEFF01, 0xffff0001);
5629 cx25840_write4(client, DIF_BPF_COEFF23, 0x0006ffef);
5630 cx25840_write4(client, DIF_BPF_COEFF45, 0x00020031);
5631 cx25840_write4(client, DIF_BPF_COEFF67, 0xffbaffe8);
5632 cx25840_write4(client, DIF_BPF_COEFF89, 0x00adff66);
5633 cx25840_write4(client, DIF_BPF_COEFF1011, 0xff790198);
5634 cx25840_write4(client, DIF_BPF_COEFF1213, 0xff26fe6e);
5635 cx25840_write4(client, DIF_BPF_COEFF1415, 0x02e5ff55);
5636 cx25840_write4(client, DIF_BPF_COEFF1617, 0xfc99044a);
5637 cx25840_write4(client, DIF_BPF_COEFF1819, 0x005bfa09);
5638 cx25840_write4(client, DIF_BPF_COEFF2021, 0x0545027f);
5639 cx25840_write4(client, DIF_BPF_COEFF2223, 0xf7230541);
5640 cx25840_write4(client, DIF_BPF_COEFF2425, 0x05b8f490);
5641 cx25840_write4(client, DIF_BPF_COEFF2627, 0x03d20997);
5642 cx25840_write4(client, DIF_BPF_COEFF2829, 0xf31300eb);
5643 cx25840_write4(client, DIF_BPF_COEFF3031, 0x0d55f341);
5644 cx25840_write4(client, DIF_BPF_COEFF3233, 0xfcf6100e);
5645 cx25840_write4(client, DIF_BPF_COEFF3435, 0xf544f8c3);
5646 cx25840_write4(client, DIF_BPF_COEFF36, 0x110d0000);
5647 break;
5648 }
5649 }
5650
cx23888_std_setup(struct i2c_client * client)5651 static void cx23888_std_setup(struct i2c_client *client)
5652 {
5653 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
5654 v4l2_std_id std = state->std;
5655 u32 ifHz;
5656
5657 cx25840_write4(client, 0x478, 0x6628021F);
5658 cx25840_write4(client, 0x400, 0x0);
5659 cx25840_write4(client, 0x4b4, 0x20524030);
5660 cx25840_write4(client, 0x47c, 0x010a8263);
5661
5662 if (std & V4L2_STD_525_60) {
5663 v4l_dbg(1, cx25840_debug, client, "%s() Selecting NTSC",
5664 __func__);
5665
5666 /* Horiz / vert timing */
5667 cx25840_write4(client, 0x428, 0x1e1e601a);
5668 cx25840_write4(client, 0x424, 0x5b2d007a);
5669
5670 /* DIF NTSC */
5671 cx25840_write4(client, 0x304, 0x6503bc0c);
5672 cx25840_write4(client, 0x308, 0xbd038c85);
5673 cx25840_write4(client, 0x30c, 0x1db4640a);
5674 cx25840_write4(client, 0x310, 0x00008800);
5675 cx25840_write4(client, 0x314, 0x44400400);
5676 cx25840_write4(client, 0x32c, 0x0c800800);
5677 cx25840_write4(client, 0x330, 0x27000100);
5678 cx25840_write4(client, 0x334, 0x1f296e1f);
5679 cx25840_write4(client, 0x338, 0x009f50c1);
5680 cx25840_write4(client, 0x340, 0x1befbf06);
5681 cx25840_write4(client, 0x344, 0x000035e8);
5682
5683 /* DIF I/F */
5684 ifHz = 5400000;
5685
5686 } else {
5687 v4l_dbg(1, cx25840_debug, client, "%s() Selecting PAL-BG",
5688 __func__);
5689
5690 /* Horiz / vert timing */
5691 cx25840_write4(client, 0x428, 0x28244024);
5692 cx25840_write4(client, 0x424, 0x5d2d0084);
5693
5694 /* DIF */
5695 cx25840_write4(client, 0x304, 0x6503bc0c);
5696 cx25840_write4(client, 0x308, 0xbd038c85);
5697 cx25840_write4(client, 0x30c, 0x1db4640a);
5698 cx25840_write4(client, 0x310, 0x00008800);
5699 cx25840_write4(client, 0x314, 0x44400600);
5700 cx25840_write4(client, 0x32c, 0x0c800800);
5701 cx25840_write4(client, 0x330, 0x27000100);
5702 cx25840_write4(client, 0x334, 0x213530ec);
5703 cx25840_write4(client, 0x338, 0x00a65ba8);
5704 cx25840_write4(client, 0x340, 0x1befbf06);
5705 cx25840_write4(client, 0x344, 0x000035e8);
5706
5707 /* DIF I/F */
5708 ifHz = 6000000;
5709 }
5710
5711 cx23885_dif_setup(client, ifHz);
5712
5713 /* Explicitly ensure the inputs are reconfigured after
5714 * a standard change.
5715 */
5716 set_input(client, state->vid_input, state->aud_input);
5717 }
5718
5719 /* ----------------------------------------------------------------------- */
5720
5721 static const struct v4l2_ctrl_ops cx25840_ctrl_ops = {
5722 .s_ctrl = cx25840_s_ctrl,
5723 };
5724
5725 static const struct v4l2_subdev_core_ops cx25840_core_ops = {
5726 .log_status = cx25840_log_status,
5727 .reset = cx25840_reset,
5728 /* calling the (optional) init op will turn on the generic mode */
5729 .init = cx25840_init,
5730 .load_fw = cx25840_load_fw,
5731 .s_io_pin_config = common_s_io_pin_config,
5732 #ifdef CONFIG_VIDEO_ADV_DEBUG
5733 .g_register = cx25840_g_register,
5734 .s_register = cx25840_s_register,
5735 #endif
5736 .interrupt_service_routine = cx25840_irq_handler,
5737 };
5738
5739 static const struct v4l2_subdev_tuner_ops cx25840_tuner_ops = {
5740 .s_frequency = cx25840_s_frequency,
5741 .s_radio = cx25840_s_radio,
5742 .g_tuner = cx25840_g_tuner,
5743 .s_tuner = cx25840_s_tuner,
5744 };
5745
5746 static const struct v4l2_subdev_audio_ops cx25840_audio_ops = {
5747 .s_clock_freq = cx25840_s_clock_freq,
5748 .s_routing = cx25840_s_audio_routing,
5749 .s_stream = cx25840_s_audio_stream,
5750 };
5751
5752 static const struct v4l2_subdev_video_ops cx25840_video_ops = {
5753 .g_std = cx25840_g_std,
5754 .s_std = cx25840_s_std,
5755 .querystd = cx25840_querystd,
5756 .s_routing = cx25840_s_video_routing,
5757 .s_stream = cx25840_s_stream,
5758 .g_input_status = cx25840_g_input_status,
5759 };
5760
5761 static const struct v4l2_subdev_vbi_ops cx25840_vbi_ops = {
5762 .decode_vbi_line = cx25840_decode_vbi_line,
5763 .s_raw_fmt = cx25840_s_raw_fmt,
5764 .s_sliced_fmt = cx25840_s_sliced_fmt,
5765 .g_sliced_fmt = cx25840_g_sliced_fmt,
5766 };
5767
5768 static const struct v4l2_subdev_pad_ops cx25840_pad_ops = {
5769 .set_fmt = cx25840_set_fmt,
5770 };
5771
5772 static const struct v4l2_subdev_ops cx25840_ops = {
5773 .core = &cx25840_core_ops,
5774 .tuner = &cx25840_tuner_ops,
5775 .audio = &cx25840_audio_ops,
5776 .video = &cx25840_video_ops,
5777 .vbi = &cx25840_vbi_ops,
5778 .pad = &cx25840_pad_ops,
5779 .ir = &cx25840_ir_ops,
5780 };
5781
5782 /* ----------------------------------------------------------------------- */
5783
get_cx2388x_ident(struct i2c_client * client)5784 static u32 get_cx2388x_ident(struct i2c_client *client)
5785 {
5786 u32 ret;
5787
5788 /* Come out of digital power down */
5789 cx25840_write(client, 0x000, 0);
5790
5791 /*
5792 * Detecting whether the part is cx23885/7/8 is more
5793 * difficult than it needs to be. No ID register. Instead we
5794 * probe certain registers indicated in the datasheets to look
5795 * for specific defaults that differ between the silicon designs.
5796 */
5797
5798 /* It's either 885/7 if the IR Tx Clk Divider register exists */
5799 if (cx25840_read4(client, 0x204) & 0xffff) {
5800 /*
5801 * CX23885 returns bogus repetitive byte values for the DIF,
5802 * which doesn't exist for it. (Ex. 8a8a8a8a or 31313131)
5803 */
5804 ret = cx25840_read4(client, 0x300);
5805 if (((ret & 0xffff0000) >> 16) == (ret & 0xffff)) {
5806 /* No DIF */
5807 ret = CX23885_AV;
5808 } else {
5809 /*
5810 * CX23887 has a broken DIF, but the registers
5811 * appear valid (but unused), good enough to detect.
5812 */
5813 ret = CX23887_AV;
5814 }
5815 } else if (cx25840_read4(client, 0x300) & 0x0fffffff) {
5816 /* DIF PLL Freq Word reg exists; chip must be a CX23888 */
5817 ret = CX23888_AV;
5818 } else {
5819 v4l_err(client, "Unable to detect h/w, assuming cx23887\n");
5820 ret = CX23887_AV;
5821 }
5822
5823 /* Back into digital power down */
5824 cx25840_write(client, 0x000, 2);
5825 return ret;
5826 }
5827
cx25840_probe(struct i2c_client * client,const struct i2c_device_id * did)5828 static int cx25840_probe(struct i2c_client *client,
5829 const struct i2c_device_id *did)
5830 {
5831 struct cx25840_state *state;
5832 struct v4l2_subdev *sd;
5833 int default_volume;
5834 u32 id;
5835 u16 device_id;
5836 #if defined(CONFIG_MEDIA_CONTROLLER)
5837 int ret;
5838 #endif
5839
5840 /* Check if the adapter supports the needed features */
5841 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
5842 return -EIO;
5843
5844 v4l_dbg(1, cx25840_debug, client,
5845 "detecting cx25840 client on address 0x%x\n",
5846 client->addr << 1);
5847
5848 device_id = cx25840_read(client, 0x101) << 8;
5849 device_id |= cx25840_read(client, 0x100);
5850 v4l_dbg(1, cx25840_debug, client, "device_id = 0x%04x\n", device_id);
5851
5852 /*
5853 * The high byte of the device ID should be
5854 * 0x83 for the cx2583x and 0x84 for the cx2584x
5855 */
5856 if ((device_id & 0xff00) == 0x8300) {
5857 id = CX25836 + ((device_id >> 4) & 0xf) - 6;
5858 } else if ((device_id & 0xff00) == 0x8400) {
5859 id = CX25840 + ((device_id >> 4) & 0xf);
5860 } else if (device_id == 0x0000) {
5861 id = get_cx2388x_ident(client);
5862 } else if ((device_id & 0xfff0) == 0x5A30) {
5863 /* The CX23100 (0x5A3C = 23100) doesn't have an A/V decoder */
5864 id = CX2310X_AV;
5865 } else if ((device_id & 0xff) == (device_id >> 8)) {
5866 v4l_err(client,
5867 "likely a confused/unresponsive cx2388[578] A/V decoder found @ 0x%x (%s)\n",
5868 client->addr << 1, client->adapter->name);
5869 v4l_err(client,
5870 "A method to reset it from the cx25840 driver software is not known at this time\n");
5871 return -ENODEV;
5872 } else {
5873 v4l_dbg(1, cx25840_debug, client, "cx25840 not found\n");
5874 return -ENODEV;
5875 }
5876
5877 state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
5878 if (!state)
5879 return -ENOMEM;
5880
5881 sd = &state->sd;
5882 v4l2_i2c_subdev_init(sd, client, &cx25840_ops);
5883 #if defined(CONFIG_MEDIA_CONTROLLER)
5884 /*
5885 * TODO: add media controller support for analog video inputs like
5886 * composite, svideo, etc.
5887 * A real input pad for this analog demod would be like:
5888 * ___________
5889 * TUNER --------> | |
5890 * | |
5891 * SVIDEO .......> | cx25840 |
5892 * | |
5893 * COMPOSITE1 ...> |_________|
5894 *
5895 * However, at least for now, there's no much gain on modelling
5896 * those extra inputs. So, let's add it only when needed.
5897 */
5898 state->pads[CX25840_PAD_INPUT].flags = MEDIA_PAD_FL_SINK;
5899 state->pads[CX25840_PAD_INPUT].sig_type = PAD_SIGNAL_ANALOG;
5900 state->pads[CX25840_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
5901 state->pads[CX25840_PAD_VID_OUT].sig_type = PAD_SIGNAL_DV;
5902 sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
5903
5904 ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads),
5905 state->pads);
5906 if (ret < 0) {
5907 v4l_info(client, "failed to initialize media entity!\n");
5908 return ret;
5909 }
5910 #endif
5911
5912 switch (id) {
5913 case CX23885_AV:
5914 v4l_info(client, "cx23885 A/V decoder found @ 0x%x (%s)\n",
5915 client->addr << 1, client->adapter->name);
5916 break;
5917 case CX23887_AV:
5918 v4l_info(client, "cx23887 A/V decoder found @ 0x%x (%s)\n",
5919 client->addr << 1, client->adapter->name);
5920 break;
5921 case CX23888_AV:
5922 v4l_info(client, "cx23888 A/V decoder found @ 0x%x (%s)\n",
5923 client->addr << 1, client->adapter->name);
5924 break;
5925 case CX2310X_AV:
5926 v4l_info(client, "cx%d A/V decoder found @ 0x%x (%s)\n",
5927 device_id, client->addr << 1, client->adapter->name);
5928 break;
5929 case CX25840:
5930 case CX25841:
5931 case CX25842:
5932 case CX25843:
5933 /*
5934 * Note: revision '(device_id & 0x0f) == 2' was never built.
5935 * The marking skips from 0x1 == 22 to 0x3 == 23.
5936 */
5937 v4l_info(client, "cx25%3x-2%x found @ 0x%x (%s)\n",
5938 (device_id & 0xfff0) >> 4,
5939 (device_id & 0x0f) < 3 ? (device_id & 0x0f) + 1
5940 : (device_id & 0x0f),
5941 client->addr << 1, client->adapter->name);
5942 break;
5943 case CX25836:
5944 case CX25837:
5945 default:
5946 v4l_info(client, "cx25%3x-%x found @ 0x%x (%s)\n",
5947 (device_id & 0xfff0) >> 4, device_id & 0x0f,
5948 client->addr << 1, client->adapter->name);
5949 break;
5950 }
5951
5952 state->c = client;
5953 state->vid_input = CX25840_COMPOSITE7;
5954 state->aud_input = CX25840_AUDIO8;
5955 state->audclk_freq = 48000;
5956 state->audmode = V4L2_TUNER_MODE_LANG1;
5957 state->vbi_line_offset = 8;
5958 state->id = id;
5959 state->rev = device_id;
5960 state->vbi_regs_offset = id == CX23888_AV ? 0x500 - 0x424 : 0;
5961 state->std = V4L2_STD_NTSC_M;
5962 v4l2_ctrl_handler_init(&state->hdl, 9);
5963 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops,
5964 V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
5965 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops,
5966 V4L2_CID_CONTRAST, 0, 127, 1, 64);
5967 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops,
5968 V4L2_CID_SATURATION, 0, 127, 1, 64);
5969 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops,
5970 V4L2_CID_HUE, -128, 127, 1, 0);
5971 if (!is_cx2583x(state)) {
5972 default_volume = cx25840_read(client, 0x8d4);
5973 /*
5974 * Enforce the legacy PVR-350/MSP3400 to PVR-150/CX25843 volume
5975 * scale mapping limits to avoid -ERANGE errors when
5976 * initializing the volume control
5977 */
5978 if (default_volume > 228) {
5979 /* Bottom out at -96 dB, v4l2 vol range 0x2e00-0x2fff */
5980 default_volume = 228;
5981 cx25840_write(client, 0x8d4, 228);
5982 } else if (default_volume < 20) {
5983 /* Top out at + 8 dB, v4l2 vol range 0xfe00-0xffff */
5984 default_volume = 20;
5985 cx25840_write(client, 0x8d4, 20);
5986 }
5987 default_volume = (((228 - default_volume) >> 1) + 23) << 9;
5988
5989 state->volume = v4l2_ctrl_new_std(&state->hdl,
5990 &cx25840_audio_ctrl_ops,
5991 V4L2_CID_AUDIO_VOLUME,
5992 0, 65535, 65535 / 100,
5993 default_volume);
5994 state->mute = v4l2_ctrl_new_std(&state->hdl,
5995 &cx25840_audio_ctrl_ops,
5996 V4L2_CID_AUDIO_MUTE,
5997 0, 1, 1, 0);
5998 v4l2_ctrl_new_std(&state->hdl, &cx25840_audio_ctrl_ops,
5999 V4L2_CID_AUDIO_BALANCE,
6000 0, 65535, 65535 / 100, 32768);
6001 v4l2_ctrl_new_std(&state->hdl, &cx25840_audio_ctrl_ops,
6002 V4L2_CID_AUDIO_BASS,
6003 0, 65535, 65535 / 100, 32768);
6004 v4l2_ctrl_new_std(&state->hdl, &cx25840_audio_ctrl_ops,
6005 V4L2_CID_AUDIO_TREBLE,
6006 0, 65535, 65535 / 100, 32768);
6007 }
6008 sd->ctrl_handler = &state->hdl;
6009 if (state->hdl.error) {
6010 int err = state->hdl.error;
6011
6012 v4l2_ctrl_handler_free(&state->hdl);
6013 return err;
6014 }
6015 if (!is_cx2583x(state))
6016 v4l2_ctrl_cluster(2, &state->volume);
6017 v4l2_ctrl_handler_setup(&state->hdl);
6018
6019 if (client->dev.platform_data) {
6020 struct cx25840_platform_data *pdata = client->dev.platform_data;
6021
6022 state->pvr150_workaround = pdata->pvr150_workaround;
6023 }
6024
6025 cx25840_ir_probe(sd);
6026 return 0;
6027 }
6028
cx25840_remove(struct i2c_client * client)6029 static int cx25840_remove(struct i2c_client *client)
6030 {
6031 struct v4l2_subdev *sd = i2c_get_clientdata(client);
6032 struct cx25840_state *state = to_state(sd);
6033
6034 cx25840_ir_remove(sd);
6035 v4l2_device_unregister_subdev(sd);
6036 v4l2_ctrl_handler_free(&state->hdl);
6037 return 0;
6038 }
6039
6040 static const struct i2c_device_id cx25840_id[] = {
6041 { "cx25840", 0 },
6042 { }
6043 };
6044 MODULE_DEVICE_TABLE(i2c, cx25840_id);
6045
6046 static struct i2c_driver cx25840_driver = {
6047 .driver = {
6048 .name = "cx25840",
6049 },
6050 .probe = cx25840_probe,
6051 .remove = cx25840_remove,
6052 .id_table = cx25840_id,
6053 };
6054
6055 module_i2c_driver(cx25840_driver);
6056