aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx25840/cx25840-core.c
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2009-09-26 22:47:21 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:40:17 -0500
commit2a03f03471d3232037e656570ccaf3ff2ffd01e8 (patch)
treeaeb169037d4323ec62b1d3362f784e5072242f5d /drivers/media/video/cx25840/cx25840-core.c
parentc7dd1ecdc0112b9700ed6ad20a6e4e07d125044b (diff)
V4L/DVB (13088): cx25840: Convert chip/core family checks to static inline functions
Change logic to check for various chip or core families to inline functions. Checks for specific chips should be made against the state->id field now. This is in preparation for chip/core specific code for setting up PLLs for the CX2388[578] family of cores, that all run with different crystal frequencies. Signed-off-by: Andy Walls <awalls@radix.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx25840/cx25840-core.c')
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index e83656729991..a6446e637f17 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -494,7 +494,7 @@ void cx25840_std_setup(struct i2c_client *client)
494 } 494 }
495 495
496 /* DEBUG: Displays configured PLL frequency */ 496 /* DEBUG: Displays configured PLL frequency */
497 if (!state->is_cx231xx) { 497 if (!is_cx231xx(state)) {
498 pll_int = cx25840_read(client, 0x108); 498 pll_int = cx25840_read(client, 0x108);
499 pll_frac = cx25840_read4(client, 0x10c) & 0x1ffffff; 499 pll_frac = cx25840_read4(client, 0x10c) & 0x1ffffff;
500 pll_post = cx25840_read(client, 0x109); 500 pll_post = cx25840_read(client, 0x109);
@@ -678,7 +678,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
678 * configuration in reg (for the cx23885) so we have no 678 * configuration in reg (for the cx23885) so we have no
679 * need to attempt to flip bits for earlier av decoders. 679 * need to attempt to flip bits for earlier av decoders.
680 */ 680 */
681 if (!state->is_cx23885 && !state->is_cx231xx) { 681 if (!is_cx2388x(state) && !is_cx231xx(state)) {
682 switch (aud_input) { 682 switch (aud_input) {
683 case CX25840_AUDIO_SERIAL: 683 case CX25840_AUDIO_SERIAL:
684 /* do nothing, use serial audio input */ 684 /* do nothing, use serial audio input */
@@ -701,7 +701,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
701 /* Set INPUT_MODE to Composite (0) or S-Video (1) */ 701 /* Set INPUT_MODE to Composite (0) or S-Video (1) */
702 cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02); 702 cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02);
703 703
704 if (!state->is_cx23885 && !state->is_cx231xx) { 704 if (!is_cx2388x(state) && !is_cx231xx(state)) {
705 /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */ 705 /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */
706 cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0); 706 cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0);
707 /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2&CH3 */ 707 /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2&CH3 */
@@ -720,12 +720,12 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
720 720
721 state->vid_input = vid_input; 721 state->vid_input = vid_input;
722 state->aud_input = aud_input; 722 state->aud_input = aud_input;
723 if (!state->is_cx25836) { 723 if (!is_cx2583x(state)) {
724 cx25840_audio_set_path(client); 724 cx25840_audio_set_path(client);
725 input_change(client); 725 input_change(client);
726 } 726 }
727 727
728 if (state->is_cx23885) { 728 if (is_cx2388x(state)) {
729 /* Audio channel 1 src : Parallel 1 */ 729 /* Audio channel 1 src : Parallel 1 */
730 cx25840_write(client, 0x124, 0x03); 730 cx25840_write(client, 0x124, 0x03);
731 731
@@ -741,7 +741,7 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp
741 */ 741 */
742 cx25840_write(client, 0x918, 0xa0); 742 cx25840_write(client, 0x918, 0xa0);
743 cx25840_write(client, 0x919, 0x01); 743 cx25840_write(client, 0x919, 0x01);
744 } else if (state->is_cx231xx) { 744 } else if (is_cx231xx(state)) {
745 /* Audio channel 1 src : Parallel 1 */ 745 /* Audio channel 1 src : Parallel 1 */
746 cx25840_write(client, 0x124, 0x03); 746 cx25840_write(client, 0x124, 0x03);
747 747
@@ -805,7 +805,7 @@ static int set_v4lstd(struct i2c_client *client)
805 cx25840_and_or(client, 0x400, ~0xf, fmt); 805 cx25840_and_or(client, 0x400, ~0xf, fmt);
806 cx25840_and_or(client, 0x403, ~0x3, pal_m); 806 cx25840_and_or(client, 0x403, ~0x3, pal_m);
807 cx25840_std_setup(client); 807 cx25840_std_setup(client);
808 if (!state->is_cx25836) 808 if (!is_cx2583x(state))
809 input_change(client); 809 input_change(client);
810 return 0; 810 return 0;
811} 811}
@@ -868,7 +868,7 @@ static int cx25840_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
868 case V4L2_CID_AUDIO_TREBLE: 868 case V4L2_CID_AUDIO_TREBLE:
869 case V4L2_CID_AUDIO_BALANCE: 869 case V4L2_CID_AUDIO_BALANCE:
870 case V4L2_CID_AUDIO_MUTE: 870 case V4L2_CID_AUDIO_MUTE:
871 if (state->is_cx25836) 871 if (is_cx2583x(state))
872 return -EINVAL; 872 return -EINVAL;
873 return cx25840_audio_s_ctrl(sd, ctrl); 873 return cx25840_audio_s_ctrl(sd, ctrl);
874 874
@@ -905,7 +905,7 @@ static int cx25840_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
905 case V4L2_CID_AUDIO_TREBLE: 905 case V4L2_CID_AUDIO_TREBLE:
906 case V4L2_CID_AUDIO_BALANCE: 906 case V4L2_CID_AUDIO_BALANCE:
907 case V4L2_CID_AUDIO_MUTE: 907 case V4L2_CID_AUDIO_MUTE:
908 if (state->is_cx25836) 908 if (is_cx2583x(state))
909 return -EINVAL; 909 return -EINVAL;
910 return cx25840_audio_g_ctrl(sd, ctrl); 910 return cx25840_audio_g_ctrl(sd, ctrl);
911 default: 911 default:
@@ -1209,11 +1209,11 @@ static int cx25840_load_fw(struct v4l2_subdev *sd)
1209 if (!state->is_initialized) { 1209 if (!state->is_initialized) {
1210 /* initialize and load firmware */ 1210 /* initialize and load firmware */
1211 state->is_initialized = 1; 1211 state->is_initialized = 1;
1212 if (state->is_cx25836) 1212 if (is_cx2583x(state))
1213 cx25836_initialize(client); 1213 cx25836_initialize(client);
1214 else if (state->is_cx23885) 1214 else if (is_cx2388x(state))
1215 cx23885_initialize(client); 1215 cx23885_initialize(client);
1216 else if (state->is_cx231xx) 1216 else if (is_cx231xx(state))
1217 cx231xx_initialize(client); 1217 cx231xx_initialize(client);
1218 else 1218 else
1219 cx25840_initialize(client); 1219 cx25840_initialize(client);
@@ -1256,17 +1256,17 @@ static int cx25840_s_stream(struct v4l2_subdev *sd, int enable)
1256 v4l_dbg(1, cx25840_debug, client, "%s output\n", 1256 v4l_dbg(1, cx25840_debug, client, "%s output\n",
1257 enable ? "enable" : "disable"); 1257 enable ? "enable" : "disable");
1258 if (enable) { 1258 if (enable) {
1259 if (state->is_cx23885 || state->is_cx231xx) { 1259 if (is_cx2388x(state) || is_cx231xx(state)) {
1260 u8 v = (cx25840_read(client, 0x421) | 0x0b); 1260 u8 v = (cx25840_read(client, 0x421) | 0x0b);
1261 cx25840_write(client, 0x421, v); 1261 cx25840_write(client, 0x421, v);
1262 } else { 1262 } else {
1263 cx25840_write(client, 0x115, 1263 cx25840_write(client, 0x115,
1264 state->is_cx25836 ? 0x0c : 0x8c); 1264 is_cx2583x(state) ? 0x0c : 0x8c);
1265 cx25840_write(client, 0x116, 1265 cx25840_write(client, 0x116,
1266 state->is_cx25836 ? 0x04 : 0x07); 1266 is_cx2583x(state) ? 0x04 : 0x07);
1267 } 1267 }
1268 } else { 1268 } else {
1269 if (state->is_cx23885 || state->is_cx231xx) { 1269 if (is_cx2388x(state) || is_cx231xx(state)) {
1270 u8 v = cx25840_read(client, 0x421) & ~(0x0b); 1270 u8 v = cx25840_read(client, 0x421) & ~(0x0b);
1271 cx25840_write(client, 0x421, v); 1271 cx25840_write(client, 0x421, v);
1272 } else { 1272 } else {
@@ -1292,7 +1292,7 @@ static int cx25840_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
1292 default: 1292 default:
1293 break; 1293 break;
1294 } 1294 }
1295 if (state->is_cx25836) 1295 if (is_cx2583x(state))
1296 return -EINVAL; 1296 return -EINVAL;
1297 1297
1298 switch (qc->id) { 1298 switch (qc->id) {
@@ -1346,7 +1346,7 @@ static int cx25840_s_audio_routing(struct v4l2_subdev *sd,
1346 struct cx25840_state *state = to_state(sd); 1346 struct cx25840_state *state = to_state(sd);
1347 struct i2c_client *client = v4l2_get_subdevdata(sd); 1347 struct i2c_client *client = v4l2_get_subdevdata(sd);
1348 1348
1349 if (state->is_cx25836) 1349 if (is_cx2583x(state))
1350 return -EINVAL; 1350 return -EINVAL;
1351 return set_input(client, state->vid_input, input); 1351 return set_input(client, state->vid_input, input);
1352} 1352}
@@ -1356,7 +1356,7 @@ static int cx25840_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr
1356 struct cx25840_state *state = to_state(sd); 1356 struct cx25840_state *state = to_state(sd);
1357 struct i2c_client *client = v4l2_get_subdevdata(sd); 1357 struct i2c_client *client = v4l2_get_subdevdata(sd);
1358 1358
1359 if (!state->is_cx25836) 1359 if (!is_cx2583x(state))
1360 input_change(client); 1360 input_change(client);
1361 return 0; 1361 return 0;
1362} 1362}
@@ -1373,7 +1373,7 @@ static int cx25840_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
1373 return 0; 1373 return 0;
1374 1374
1375 vt->signal = vpres ? 0xffff : 0x0; 1375 vt->signal = vpres ? 0xffff : 0x0;
1376 if (state->is_cx25836) 1376 if (is_cx2583x(state))
1377 return 0; 1377 return 0;
1378 1378
1379 vt->capability |= 1379 vt->capability |=
@@ -1404,7 +1404,7 @@ static int cx25840_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
1404 struct cx25840_state *state = to_state(sd); 1404 struct cx25840_state *state = to_state(sd);
1405 struct i2c_client *client = v4l2_get_subdevdata(sd); 1405 struct i2c_client *client = v4l2_get_subdevdata(sd);
1406 1406
1407 if (state->radio || state->is_cx25836) 1407 if (state->radio || is_cx2583x(state))
1408 return 0; 1408 return 0;
1409 1409
1410 switch (vt->audmode) { 1410 switch (vt->audmode) {
@@ -1445,11 +1445,11 @@ static int cx25840_reset(struct v4l2_subdev *sd, u32 val)
1445 struct cx25840_state *state = to_state(sd); 1445 struct cx25840_state *state = to_state(sd);
1446 struct i2c_client *client = v4l2_get_subdevdata(sd); 1446 struct i2c_client *client = v4l2_get_subdevdata(sd);
1447 1447
1448 if (state->is_cx25836) 1448 if (is_cx2583x(state))
1449 cx25836_initialize(client); 1449 cx25836_initialize(client);
1450 else if (state->is_cx23885) 1450 else if (is_cx2388x(state))
1451 cx23885_initialize(client); 1451 cx23885_initialize(client);
1452 else if (state->is_cx231xx) 1452 else if (is_cx231xx(state))
1453 cx231xx_initialize(client); 1453 cx231xx_initialize(client);
1454 else 1454 else
1455 cx25840_initialize(client); 1455 cx25840_initialize(client);
@@ -1470,7 +1470,7 @@ static int cx25840_log_status(struct v4l2_subdev *sd)
1470 struct i2c_client *client = v4l2_get_subdevdata(sd); 1470 struct i2c_client *client = v4l2_get_subdevdata(sd);
1471 1471
1472 log_video_status(client); 1472 log_video_status(client);
1473 if (!state->is_cx25836) 1473 if (!is_cx2583x(state))
1474 log_audio_status(client); 1474 log_audio_status(client);
1475 return 0; 1475 return 0;
1476} 1476}
@@ -1594,22 +1594,18 @@ static int cx25840_probe(struct i2c_client *client,
1594 v4l2_i2c_subdev_init(sd, client, &cx25840_ops); 1594 v4l2_i2c_subdev_init(sd, client, &cx25840_ops);
1595 switch (id) { 1595 switch (id) {
1596 case V4L2_IDENT_CX23885_AV: 1596 case V4L2_IDENT_CX23885_AV:
1597 state->is_cx23885 = 1;
1598 v4l_info(client, "cx23885 A/V decoder found @ 0x%x (%s)\n", 1597 v4l_info(client, "cx23885 A/V decoder found @ 0x%x (%s)\n",
1599 client->addr << 1, client->adapter->name); 1598 client->addr << 1, client->adapter->name);
1600 break; 1599 break;
1601 case V4L2_IDENT_CX23887_AV: 1600 case V4L2_IDENT_CX23887_AV:
1602 state->is_cx23885 = 1;
1603 v4l_info(client, "cx23887 A/V decoder found @ 0x%x (%s)\n", 1601 v4l_info(client, "cx23887 A/V decoder found @ 0x%x (%s)\n",
1604 client->addr << 1, client->adapter->name); 1602 client->addr << 1, client->adapter->name);
1605 break; 1603 break;
1606 case V4L2_IDENT_CX23888_AV: 1604 case V4L2_IDENT_CX23888_AV:
1607 state->is_cx23885 = 1;
1608 v4l_info(client, "cx23888 A/V decoder found @ 0x%x (%s)\n", 1605 v4l_info(client, "cx23888 A/V decoder found @ 0x%x (%s)\n",
1609 client->addr << 1, client->adapter->name); 1606 client->addr << 1, client->adapter->name);
1610 break; 1607 break;
1611 case V4L2_IDENT_CX2310X_AV: 1608 case V4L2_IDENT_CX2310X_AV:
1612 state->is_cx231xx = 1;
1613 v4l_info(client, "cx%d A/V decoder found @ 0x%x (%s)\n", 1609 v4l_info(client, "cx%d A/V decoder found @ 0x%x (%s)\n",
1614 device_id, client->addr << 1, client->adapter->name); 1610 device_id, client->addr << 1, client->adapter->name);
1615 break; 1611 break;
@@ -1627,7 +1623,6 @@ static int cx25840_probe(struct i2c_client *client,
1627 break; 1623 break;
1628 case V4L2_IDENT_CX25836: 1624 case V4L2_IDENT_CX25836:
1629 case V4L2_IDENT_CX25837: 1625 case V4L2_IDENT_CX25837:
1630 state->is_cx25836 = 1;
1631 default: 1626 default:
1632 v4l_info(client, "cx25%3x-%x found @ 0x%x (%s)\n", 1627 v4l_info(client, "cx25%3x-%x found @ 0x%x (%s)\n",
1633 (device_id & 0xfff0) >> 4, device_id & 0x0f, 1628 (device_id & 0xfff0) >> 4, device_id & 0x0f,