40 #include <linux/kernel.h>
41 #include <linux/module.h>
42 #include <linux/slab.h>
43 #include <linux/videodev2.h>
44 #include <linux/i2c.h>
54 MODULE_AUTHOR(
"Ulf Eklund, Chris Kennedy, Hans Verkuil, Tyler Trafford");
57 #define CX25840_VID_INT_STAT_REG 0x410
58 #define CX25840_VID_INT_STAT_BITS 0x0000ffff
59 #define CX25840_VID_INT_MASK_BITS 0xffff0000
60 #define CX25840_VID_INT_MASK_SHFT 16
61 #define CX25840_VID_INT_MASK_REG 0x412
63 #define CX23885_AUD_MC_INT_MASK_REG 0x80c
64 #define CX23885_AUD_MC_INT_STAT_BITS 0xffff0000
65 #define CX23885_AUD_MC_INT_CTRL_BITS 0x0000ffff
66 #define CX23885_AUD_MC_INT_STAT_SHFT 16
68 #define CX25840_AUD_INT_CTRL_REG 0x812
69 #define CX25840_AUD_INT_STAT_REG 0x813
71 #define CX23885_PIN_CTRL_IRQ_REG 0x123
72 #define CX23885_PIN_CTRL_IRQ_IR_STAT 0x40
73 #define CX23885_PIN_CTRL_IRQ_AUD_STAT 0x20
74 #define CX23885_PIN_CTRL_IRQ_VID_STAT 0x10
76 #define CX25840_IR_STATS_REG 0x210
77 #define CX25840_IR_IRQEN_REG 0x214
79 static int cx25840_debug;
92 buffer[0] = addr >> 8;
93 buffer[1] = addr & 0xff;
101 buffer[0] = addr >> 8;
102 buffer[1] = addr & 0xff;
103 buffer[2] = value & 0xff;
104 buffer[3] = (value >> 8) & 0xff;
105 buffer[4] = (value >> 16) & 0xff;
106 buffer[5] = value >> 24;
116 tx_buf[0] = addr >> 8;
117 tx_buf[1] = addr & 0xff;
121 msgs[0].
buf = (
char *) tx_buf;
127 msgs[1].
buf = (
char *) rx_buf;
141 tx_buf[0] = addr >> 8;
142 tx_buf[1] = addr & 0xff;
146 msgs[0].
buf = (
char *) tx_buf;
152 msgs[1].
buf = (
char *) rx_buf;
157 return (rx_buf[3] << 24) | (rx_buf[2] << 16) | (rx_buf[1] << 8) |
184 static int cx23885_s_io_pin_config(
struct v4l2_subdev *
sd,
size_t n,
190 u8 gpio_oe, gpio_data, strength;
196 for (i = 0; i <
n; i++) {
205 pin_ctrl &= ~(0x1 << 25);
211 pin_ctrl &= ~(0x1 << 25);
213 pin_ctrl |= (0x1 << 25);
217 pin_ctrl &= ~(0x1 << 24);
219 pin_ctrl |= (0x1 << 24);
226 gpio_oe |= (0x1 << 0);
227 pin_ctrl &= ~(0x3 << 18);
228 pin_ctrl |= (strength << 18);
231 gpio_oe &= ~(0x1 << 0);
233 gpio_data &= ~(0x1 << 0);
234 gpio_data |= ((p[
i].
value & 0x1) << 0);
236 pin_ctrl &= ~(0x3 << 12);
237 pin_ctrl |= (strength << 12);
243 gpio_oe |= (0x1 << 1);
245 pin_ctrl &= ~(0x1 << 10);
247 pin_ctrl |= (0x1 << 10);
248 pin_ctrl &= ~(0x3 << 18);
249 pin_ctrl |= (strength << 18);
252 gpio_oe &= ~(0x1 << 1);
254 gpio_data &= ~(0x1 << 1);
255 gpio_data |= ((p[
i].
value & 0x1) << 1);
257 pin_ctrl &= ~(0x3 << 12);
258 pin_ctrl |= (strength << 12);
265 gpio_oe |= (0x1 << 2);
266 pin_ctrl &= ~(0x3 << 22);
267 pin_ctrl |= (strength << 22);
270 gpio_oe &= ~(0x1 << 2);
272 gpio_data &= ~(0x1 << 2);
273 gpio_data |= ((p[
i].
value & 0x1) << 2);
275 pin_ctrl &= ~(0x3 << 12);
276 pin_ctrl |= (strength << 12);
283 gpio_oe |= (0x1 << 3);
284 pin_ctrl &= ~(0x3 << 22);
285 pin_ctrl |= (strength << 22);
288 gpio_oe &= ~(0x1 << 3);
290 gpio_data &= ~(0x1 << 3);
291 gpio_data |= ((p[
i].
value & 0x1) << 3);
293 pin_ctrl &= ~(0x3 << 12);
294 pin_ctrl |= (strength << 12);
301 gpio_oe |= (0x1 << 4);
302 pin_ctrl &= ~(0x3 << 22);
303 pin_ctrl |= (strength << 22);
306 gpio_oe &= ~(0x1 << 4);
308 gpio_data &= ~(0x1 << 4);
309 gpio_data |= ((p[
i].
value & 0x1) << 4);
311 pin_ctrl &= ~(0x3 << 12);
312 pin_ctrl |= (strength << 12);
324 static int common_s_io_pin_config(
struct v4l2_subdev *sd,
size_t n,
329 if (is_cx2388x(state))
330 return cx23885_s_io_pin_config(sd, n, pincfg);
336 static void init_dll1(
struct i2c_client *client)
352 static void init_dll2(
struct i2c_client *client)
365 static void cx25836_initialize(
struct i2c_client *client)
397 static void cx25840_initialize(
struct i2c_client *client)
400 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
465 static void cx23885_initialize(
struct i2c_client *client)
468 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
644 if (is_cx23888(state))
645 cx23888_std_setup(client);
696 static void cx231xx_initialize(
struct i2c_client *client)
699 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
776 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
778 int hblank, hactive, burst, vblank, vactive,
sc;
779 int vblank656, src_decimation;
780 int luma_lpf, uv_lpf, comb;
781 u32 pll_int, pll_frac, pll_post;
796 src_decimation = 0x21f;
819 src_decimation = 0x21f;
843 if (!is_cx231xx(state)) {
847 v4l_dbg(1, cx25840_debug, client,
848 "PLL regs = int: %u, frac: %u, post: %u\n",
849 pll_int, pll_frac, pll_post);
853 int pll = (28636363
L * ((((
u64)pll_int) << 25
L) + pll_frac)) >> 25
L;
856 v4l_dbg(1, cx25840_debug, client,
"PLL = %d.%06d MHz\n",
857 pll / 1000000, pll % 1000000);
858 v4l_dbg(1, cx25840_debug, client,
"PLL/8 = %d.%06d MHz\n",
859 pll / 8000000, (pll / 8) % 1000000);
861 fin = ((
u64)src_decimation * pll) >> 12;
862 v4l_dbg(1, cx25840_debug, client,
863 "ADC Sampling freq = %d.%06d MHz\n",
864 fin / 1000000, fin % 1000000);
866 fsc = (((
u64)sc) *
pll) >> 24
L;
867 v4l_dbg(1, cx25840_debug, client,
868 "Chroma sub-carrier freq = %d.%06d MHz\n",
869 fsc / 1000000, fsc % 1000000);
871 v4l_dbg(1, cx25840_debug, client,
"hblank %i, hactive %i, "
872 "vblank %i, vactive %i, vblank656 %i, src_dec %i, "
873 "burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x, "
875 hblank, hactive, vblank, vactive, vblank656,
876 src_decimation, burst, luma_lpf, uv_lpf, comb, sc);
883 0xff & (((hblank >> 8) & 0x3) | (hactive << 4)));
892 0xff & (((vblank >> 8) & 0x3) | (vactive << 4)));
901 cx25840_write(client, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30));
912 if (std & V4L2_STD_625_50) {
923 static void input_change(
struct i2c_client *client)
925 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
940 if (is_cx2583x(state))
976 }
else if (std & V4L2_STD_SECAM) {
985 }
else if (!(std & V4L2_STD_SECAM_DK) &&
1001 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1010 int luma = vid_input & 0xf0;
1011 int chroma = vid_input & 0xf00;
1015 v4l_dbg(1, cx25840_debug, client,
1016 "decoder set video input %d, audio input %d\n",
1017 vid_input, aud_input);
1020 v4l_dbg(1, cx25840_debug, client,
"vid_input 0x%x\n",
1022 reg = vid_input & 0xff;
1023 is_composite = !is_component &&
1026 v4l_dbg(1, cx25840_debug, client,
"mux cfg 0x%x comp=%d\n",
1028 }
else if (is_composite) {
1031 if ((vid_input & ~0xff0) ||
1034 v4l_err(client,
"0x%04x is not a valid video input!\n",
1052 if (!is_cx2388x(state) && !is_cx231xx(state)) {
1053 switch (aud_input) {
1064 v4l_err(client,
"0x%04x is not a valid audio input!\n",
1078 if (is_cx2388x(state)) {
1112 if (is_cx23888(state))
1121 if (is_cx23888(state))
1152 if (!is_cx2388x(state) && !is_cx231xx(state)) {
1156 if ((reg & 0xc0) != 0xc0 && (reg & 0x30) != 0x30)
1166 }
else if (!is_component) {
1178 if (is_cx2388x(state) && is_svideo) {
1179 #define AFE_CTRL (0x104)
1180 #define MODE_CTRL (0x400)
1208 input_change(client);
1210 if (is_cx2388x(state)) {
1226 }
else if (is_cx231xx(state)) {
1253 if (is_cx23888(state)) {
1275 static int set_v4lstd(
struct i2c_client *client)
1277 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1299 else if (state->
std & V4L2_STD_PAL)
1301 else if (state->
std & V4L2_STD_SECAM)
1305 v4l_dbg(1, cx25840_debug, client,
"changing video std to fmt %i\n",fmt);
1310 if (fmt >= 4 && fmt < 8) {
1318 if (is_cx23888(state))
1319 cx23888_std_setup(client);
1322 if (!is_cx2583x(state))
1323 input_change(client);
1333 struct i2c_client *client = v4l2_get_subdevdata(sd);
1345 if (is_cx23888(state)) {
1355 if (is_cx23888(state))
1370 static int cx25840_s_mbus_fmt(
struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *fmt)
1373 struct i2c_client *client = v4l2_get_subdevdata(sd);
1374 int HSC, VSC, Vsrc, Hsrc,
filter, Vlines;
1383 if (is_cx23888(state)) {
1391 if (is_cx23888(state)) {
1399 Vlines = fmt->height + (is_50Hz ? 4 : 7);
1401 if ((fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) ||
1402 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {
1403 v4l_err(client,
"%dx%d is not a valid size!\n",
1404 fmt->width, fmt->height);
1408 HSC = (Hsrc * (1 << 20)) / fmt->width - (1 << 20);
1409 VSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9));
1412 if (fmt->width >= 385)
1414 else if (fmt->width > 192)
1416 else if (fmt->width > 96)
1421 v4l_dbg(1, cx25840_debug, client,
"decoder set size %dx%d -> scale %ux%u\n",
1422 fmt->width, fmt->height, HSC, VSC);
1438 static void log_video_status(
struct i2c_client *client)
1440 static const char *
const fmt_strs[] = {
1442 "NTSC-M",
"NTSC-J",
"NTSC-4.43",
1443 "PAL-BDGHI",
"PAL-M",
"PAL-N",
"PAL-Nc",
"PAL-60",
1444 "0x9",
"0xA",
"0xB",
1449 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1455 v4l_info(client,
"Video signal: %spresent\n",
1456 (gen_stat2 & 0x20) ?
"" :
"not ");
1457 v4l_info(client,
"Detected format: %s\n",
1458 fmt_strs[gen_stat1 & 0xf]);
1460 v4l_info(client,
"Specified standard: %s\n",
1461 vidfmt_sel ? fmt_strs[vidfmt_sel] :
"automatic detection");
1465 v4l_info(client,
"Specified video input: Composite %d\n",
1468 v4l_info(client,
"Specified video input: S-Video (Luma In%d, Chroma In%d)\n",
1469 (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8);
1477 static void log_audio_status(
struct i2c_client *client)
1479 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
1490 switch (mod_det_stat0) {
1491 case 0x00: p =
"mono";
break;
1492 case 0x01: p =
"stereo";
break;
1493 case 0x02: p =
"dual";
break;
1494 case 0x04: p =
"tri";
break;
1495 case 0x10: p =
"mono with SAP";
break;
1496 case 0x11: p =
"stereo with SAP";
break;
1497 case 0x12: p =
"dual with SAP";
break;
1498 case 0x14: p =
"tri with SAP";
break;
1499 case 0xfe: p =
"forced mode";
break;
1500 default: p =
"not defined";
1502 v4l_info(client,
"Detected audio mode: %s\n", p);
1504 switch (mod_det_stat1) {
1505 case 0x00: p =
"not defined";
break;
1506 case 0x01: p =
"EIAJ";
break;
1507 case 0x02: p =
"A2-M";
break;
1508 case 0x03: p =
"A2-BG";
break;
1509 case 0x04: p =
"A2-DK1";
break;
1510 case 0x05: p =
"A2-DK2";
break;
1511 case 0x06: p =
"A2-DK3";
break;
1512 case 0x07: p =
"A1 (6.0 MHz FM Mono)";
break;
1513 case 0x08: p =
"AM-L";
break;
1514 case 0x09: p =
"NICAM-BG";
break;
1515 case 0x0a: p =
"NICAM-DK";
break;
1516 case 0x0b: p =
"NICAM-I";
break;
1517 case 0x0c: p =
"NICAM-L";
break;
1518 case 0x0d: p =
"BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)";
break;
1519 case 0x0e: p =
"IF FM Radio";
break;
1520 case 0x0f: p =
"BTSC";
break;
1521 case 0x10: p =
"high-deviation FM";
break;
1522 case 0x11: p =
"very high-deviation FM";
break;
1523 case 0xfd: p =
"unknown audio standard";
break;
1524 case 0xfe: p =
"forced audio standard";
break;
1525 case 0xff: p =
"no detected audio standard";
break;
1526 default: p =
"not defined";
1528 v4l_info(client,
"Detected audio standard: %s\n", p);
1529 v4l_info(client,
"Audio microcontroller: %s\n",
1530 (download_ctl & 0x10) ?
1531 ((mute_ctl & 0x2) ?
"detecting" :
"running") :
"stopped");
1533 switch (audio_config >> 4) {
1534 case 0x00: p =
"undefined";
break;
1535 case 0x01: p =
"BTSC";
break;
1536 case 0x02: p =
"EIAJ";
break;
1537 case 0x03: p =
"A2-M";
break;
1538 case 0x04: p =
"A2-BG";
break;
1539 case 0x05: p =
"A2-DK1";
break;
1540 case 0x06: p =
"A2-DK2";
break;
1541 case 0x07: p =
"A2-DK3";
break;
1542 case 0x08: p =
"A1 (6.0 MHz FM Mono)";
break;
1543 case 0x09: p =
"AM-L";
break;
1544 case 0x0a: p =
"NICAM-BG";
break;
1545 case 0x0b: p =
"NICAM-DK";
break;
1546 case 0x0c: p =
"NICAM-I";
break;
1547 case 0x0d: p =
"NICAM-L";
break;
1548 case 0x0e: p =
"FM radio";
break;
1549 case 0x0f: p =
"automatic detection";
break;
1550 default: p =
"undefined";
1552 v4l_info(client,
"Configured audio standard: %s\n", p);
1554 if ((audio_config >> 4) < 0xF) {
1555 switch (audio_config & 0xF) {
1556 case 0x00: p =
"MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)";
break;
1557 case 0x01: p =
"MONO2 (LANGUAGE B)";
break;
1558 case 0x02: p =
"MONO3 (STEREO forced MONO)";
break;
1559 case 0x03: p =
"MONO4 (NICAM ANALOG-Language C/Analog Fallback)";
break;
1560 case 0x04: p =
"STEREO";
break;
1561 case 0x05: p =
"DUAL1 (AB)";
break;
1562 case 0x06: p =
"DUAL2 (AC) (FM)";
break;
1563 case 0x07: p =
"DUAL3 (BC) (FM)";
break;
1564 case 0x08: p =
"DUAL4 (AC) (AM)";
break;
1565 case 0x09: p =
"DUAL5 (BC) (AM)";
break;
1566 case 0x0a: p =
"SAP";
break;
1567 default: p =
"undefined";
1569 v4l_info(client,
"Configured audio mode: %s\n", p);
1571 switch (audio_config & 0xF) {
1572 case 0x00: p =
"BG";
break;
1573 case 0x01: p =
"DK1";
break;
1574 case 0x02: p =
"DK2";
break;
1575 case 0x03: p =
"DK3";
break;
1576 case 0x04: p =
"I";
break;
1577 case 0x05: p =
"L";
break;
1578 case 0x06: p =
"BTSC";
break;
1579 case 0x07: p =
"EIAJ";
break;
1580 case 0x08: p =
"A2-M";
break;
1581 case 0x09: p =
"FM Radio";
break;
1582 case 0x0f: p =
"automatic standard and mode detection";
break;
1583 default: p =
"undefined";
1585 v4l_info(client,
"Configured audio system: %s\n", p);
1589 v4l_info(client,
"Specified audio input: Tuner (In%d)\n", aud_input);
1591 v4l_info(client,
"Specified audio input: External\n");
1594 switch (pref_mode & 0xf) {
1595 case 0: p =
"mono/language A";
break;
1596 case 1: p =
"language B";
break;
1597 case 2: p =
"language C";
break;
1598 case 3: p =
"analog fallback";
break;
1599 case 4: p =
"stereo";
break;
1600 case 5: p =
"language AC";
break;
1601 case 6: p =
"language BC";
break;
1602 case 7: p =
"language AB";
break;
1603 default: p =
"undefined";
1605 v4l_info(client,
"Preferred audio mode: %s\n", p);
1607 if ((audio_config & 0xf) == 0xf) {
1608 switch ((afc0 >> 3) & 0x3) {
1609 case 0: p =
"system DK";
break;
1610 case 1: p =
"system L";
break;
1611 case 2: p =
"autodetect";
break;
1612 default: p =
"undefined";
1614 v4l_info(client,
"Selected 65 MHz format: %s\n", p);
1616 switch (afc0 & 0x7) {
1617 case 0: p =
"chroma";
break;
1618 case 1: p =
"BTSC";
break;
1619 case 2: p =
"EIAJ";
break;
1620 case 3: p =
"A2-M";
break;
1621 case 4: p =
"autodetect";
break;
1622 default: p =
"undefined";
1624 v4l_info(client,
"Selected 45 MHz format: %s\n", p);
1640 static int cx25840_load_fw(
struct v4l2_subdev *sd)
1643 struct i2c_client *client = v4l2_get_subdevdata(sd);
1648 if (is_cx2583x(state))
1649 cx25836_initialize(client);
1650 else if (is_cx2388x(state))
1651 cx23885_initialize(client);
1652 else if (is_cx231xx(state))
1653 cx231xx_initialize(client);
1655 cx25840_initialize(client);
1660 #ifdef CONFIG_VIDEO_ADV_DEBUG
1663 struct i2c_client *client = v4l2_get_subdevdata(sd);
1676 struct i2c_client *client = v4l2_get_subdevdata(sd);
1690 struct i2c_client *client = v4l2_get_subdevdata(sd);
1693 if (is_cx2583x(state) || is_cx2388x(state) || is_cx231xx(state))
1696 v4l_dbg(1, cx25840_debug, client,
"%s audio output\n",
1697 enable ?
"enable" :
"disable");
1713 static int cx25840_s_stream(
struct v4l2_subdev *sd,
int enable)
1716 struct i2c_client *client = v4l2_get_subdevdata(sd);
1719 v4l_dbg(1, cx25840_debug, client,
"%s video output\n",
1720 enable ?
"enable" :
"disable");
1722 if (is_cx2388x(state) || is_cx231xx(state)) {
1732 if (is_cx2388x(state) || is_cx231xx(state)) {
1748 struct i2c_client *client = v4l2_get_subdevdata(sd);
1774 v4l_dbg(1, cx25840_debug, client,
"g_std fmt = %x, v4l2_std_id = 0x%x\n",
1775 fmt, (
unsigned int)stds[ fmt ]);
1782 struct i2c_client *client = v4l2_get_subdevdata(sd);
1798 struct i2c_client *client = v4l2_get_subdevdata(sd);
1800 if (state->
radio == 0 && state->
std == std)
1804 return set_v4lstd(client);
1807 static int cx25840_s_radio(
struct v4l2_subdev *sd)
1815 static int cx25840_s_video_routing(
struct v4l2_subdev *sd,
1819 struct i2c_client *client = v4l2_get_subdevdata(sd);
1821 if (is_cx23888(state))
1822 cx23888_std_setup(client);
1824 return set_input(client, input, state->
aud_input);
1827 static int cx25840_s_audio_routing(
struct v4l2_subdev *sd,
1831 struct i2c_client *client = v4l2_get_subdevdata(sd);
1833 if (is_cx23888(state))
1834 cx23888_std_setup(client);
1835 return set_input(client, state->
vid_input, input);
1840 struct i2c_client *client = v4l2_get_subdevdata(sd);
1842 input_change(client);
1849 struct i2c_client *client = v4l2_get_subdevdata(sd);
1857 vt->
signal = vpres ? 0xffff : 0x0;
1858 if (is_cx2583x(state))
1868 if ((mode & 0xf) == 1)
1873 if (mode == 2 || mode == 4)
1887 struct i2c_client *client = v4l2_get_subdevdata(sd);
1889 if (state->
radio || is_cx2583x(state))
1928 struct i2c_client *client = v4l2_get_subdevdata(sd);
1930 if (is_cx2583x(state))
1931 cx25836_initialize(client);
1932 else if (is_cx2388x(state))
1933 cx23885_initialize(client);
1934 else if (is_cx231xx(state))
1935 cx231xx_initialize(client);
1937 cx25840_initialize(client);
1944 struct i2c_client *client = v4l2_get_subdevdata(sd);
1949 static int cx25840_log_status(
struct v4l2_subdev *sd)
1952 struct i2c_client *client = v4l2_get_subdevdata(sd);
1954 log_video_status(client);
1955 if (!is_cx2583x(state))
1956 log_audio_status(client);
1962 static int cx23885_irq_handler(
struct v4l2_subdev *sd,
u32 status,
1967 u8 irq_stat, aud_stat, aud_en, ir_stat, ir_en;
1968 u32 vid_stat, aud_mc_stat;
1973 v4l_dbg(2, cx25840_debug, c,
"AV Core IRQ status (entry): %s %s %s\n",
1978 if ((is_cx23885(state) || is_cx23887(state))) {
1982 "AV Core ir IRQ status: %#04x disables: %#04x\n",
1985 block_handled =
false;
1987 status, &block_handled);
1996 "AV Core audio IRQ status: %#04x disables: %#04x\n",
2000 "AV Core audio MC IRQ status: %#06x enables: %#06x\n",
2012 "AV Core video IRQ status: %#06x disables: %#06x\n",
2023 v4l_dbg(2, cx25840_debug, c,
"AV Core IRQ status (exit): %s %s %s\n",
2024 irq_stat & CX23885_PIN_CTRL_IRQ_IR_STAT ?
"ir" :
" ",
2025 irq_stat & CX23885_PIN_CTRL_IRQ_AUD_STAT ?
"aud" :
" ",
2026 irq_stat & CX23885_PIN_CTRL_IRQ_VID_STAT ?
"vid" :
" ");
2031 static int cx25840_irq_handler(
struct v4l2_subdev *sd,
u32 status,
2039 if (is_cx2388x(state))
2040 return cx23885_irq_handler(sd, status, handled);
2047 #define DIF_PLL_FREQ_WORD (0x300)
2048 #define DIF_BPF_COEFF01 (0x348)
2049 #define DIF_BPF_COEFF23 (0x34c)
2050 #define DIF_BPF_COEFF45 (0x350)
2051 #define DIF_BPF_COEFF67 (0x354)
2052 #define DIF_BPF_COEFF89 (0x358)
2053 #define DIF_BPF_COEFF1011 (0x35c)
2054 #define DIF_BPF_COEFF1213 (0x360)
2055 #define DIF_BPF_COEFF1415 (0x364)
2056 #define DIF_BPF_COEFF1617 (0x368)
2057 #define DIF_BPF_COEFF1819 (0x36c)
2058 #define DIF_BPF_COEFF2021 (0x370)
2059 #define DIF_BPF_COEFF2223 (0x374)
2060 #define DIF_BPF_COEFF2425 (0x378)
2061 #define DIF_BPF_COEFF2627 (0x37c)
2062 #define DIF_BPF_COEFF2829 (0x380)
2063 #define DIF_BPF_COEFF3031 (0x384)
2064 #define DIF_BPF_COEFF3233 (0x388)
2065 #define DIF_BPF_COEFF3435 (0x38c)
2066 #define DIF_BPF_COEFF36 (0x390)
2073 v4l_dbg(1, cx25840_debug, client,
"%s(%d)\n", __func__, ifHz);
2077 pll_freq = div_u64((
u64)ifHz * 268435456, 50000000);
2078 pll_freq_word = (
u32)pll_freq;
2083 ifHz = (ifHz / 100000) * 100000;
2088 if (ifHz > 16000000)
2091 v4l_dbg(1, cx25840_debug, client,
"%s(%d) again\n", __func__, ifHz);
4978 static void cx23888_std_setup(
struct i2c_client *client)
4980 struct cx25840_state *state = to_state(i2c_get_clientdata(client));
4990 v4l_dbg(1, cx25840_debug, client,
"%s() Selecting NTSC",
5014 v4l_dbg(1, cx25840_debug, client,
"%s() Selecting PAL-BG",
5049 .s_ctrl = cx25840_s_ctrl,
5053 .log_status = cx25840_log_status,
5054 .g_chip_ident = cx25840_g_chip_ident,
5062 .s_std = cx25840_s_std,
5063 .g_std = cx25840_g_std,
5064 .reset = cx25840_reset,
5065 .load_fw = cx25840_load_fw,
5066 .s_io_pin_config = common_s_io_pin_config,
5067 #ifdef CONFIG_VIDEO_ADV_DEBUG
5068 .g_register = cx25840_g_register,
5069 .s_register = cx25840_s_register,
5071 .interrupt_service_routine = cx25840_irq_handler,
5075 .s_frequency = cx25840_s_frequency,
5076 .s_radio = cx25840_s_radio,
5077 .g_tuner = cx25840_g_tuner,
5078 .s_tuner = cx25840_s_tuner,
5083 .s_routing = cx25840_s_audio_routing,
5084 .s_stream = cx25840_s_audio_stream,
5088 .s_routing = cx25840_s_video_routing,
5089 .s_mbus_fmt = cx25840_s_mbus_fmt,
5090 .s_stream = cx25840_s_stream,
5091 .g_input_status = cx25840_g_input_status,
5102 .core = &cx25840_core_ops,
5103 .tuner = &cx25840_tuner_ops,
5104 .audio = &cx25840_audio_ops,
5105 .video = &cx25840_video_ops,
5106 .vbi = &cx25840_vbi_ops,
5129 if (((ret & 0xffff0000) >> 16) == (ret & 0xffff)) {
5141 v4l_err(client,
"Unable to detect h/w, assuming cx23887\n");
5150 static int cx25840_probe(
struct i2c_client *client,
5163 v4l_dbg(1, cx25840_debug, client,
"detecting cx25840 client on address 0x%x\n", client->
addr << 1);
5167 v4l_dbg(1, cx25840_debug, client,
"device_id = 0x%04x\n", device_id);
5171 if ((device_id & 0xff00) == 0x8300) {
5173 }
else if ((device_id & 0xff00) == 0x8400) {
5175 }
else if (device_id == 0x0000) {
5176 id = get_cx2388x_ident(client);
5177 }
else if ((device_id & 0xfff0) == 0x5A30) {
5180 }
else if ((device_id & 0xff) == (device_id >> 8)) {
5182 "likely a confused/unresponsive cx2388[578] A/V decoder"
5183 " found @ 0x%x (%s)\n",
5185 v4l_err(client,
"A method to reset it from the cx25840 driver"
5186 " software is not known at this time\n");
5189 v4l_dbg(1, cx25840_debug, client,
"cx25840 not found\n");
5202 v4l_info(client,
"cx23885 A/V decoder found @ 0x%x (%s)\n",
5206 v4l_info(client,
"cx23887 A/V decoder found @ 0x%x (%s)\n",
5210 v4l_info(client,
"cx23888 A/V decoder found @ 0x%x (%s)\n",
5214 v4l_info(client,
"cx%d A/V decoder found @ 0x%x (%s)\n",
5215 device_id, client->
addr << 1, client->
adapter->name);
5223 v4l_info(client,
"cx25%3x-2%x found @ 0x%x (%s)\n",
5224 (device_id & 0xfff0) >> 4,
5225 (device_id & 0x0f) < 3 ? (device_id & 0x0f) + 1
5226 : (device_id & 0x0f),
5232 v4l_info(client,
"cx25%3x-%x found @ 0x%x (%s)\n",
5233 (device_id & 0xfff0) >> 4, device_id & 0x0f,
5255 if (!is_cx2583x(state)) {
5262 if (default_volume > 228) {
5264 default_volume = 228;
5267 else if (default_volume < 20) {
5269 default_volume = 20;
5272 default_volume = (((228 - default_volume) >> 1) + 23) << 9;
5276 0, 65535, 65535 / 100, default_volume);
5282 0, 65535, 65535 / 100, 32768);
5285 0, 65535, 65535 / 100, 32768);
5288 0, 65535, 65535 / 100, 32768);
5291 if (state->
hdl.error) {
5292 int err = state->
hdl.error;
5298 if (!is_cx2583x(state))
5302 if (client->
dev.platform_data) {
5312 static int cx25840_remove(
struct i2c_client *client)
5314 struct v4l2_subdev *sd = i2c_get_clientdata(client);
5335 .probe = cx25840_probe,
5336 .remove = cx25840_remove,
5337 .id_table = cx25840_id,