Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: cx25840: Address several coding style issues

As we did a major change on this file, let's take the moment
to cleanup several coding style issues on it.

This patch was partially done with the help of two tools:

./scripts/checkpatch.pl --fix-inplace --strict
astyle --indent=tab=8 --style=linux

But manually adjusted in order to fit our style.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

+618 -343
+590 -323
drivers/media/i2c/cx25840/cx25840-core.c
··· 35 35 * GNU General Public License for more details. 36 36 */ 37 37 38 - 39 38 #include <linux/kernel.h> 40 39 #include <linux/module.h> 41 40 #include <linux/slab.h> ··· 75 76 76 77 static int cx25840_debug; 77 78 78 - module_param_named(debug,cx25840_debug, int, 0644); 79 + module_param_named(debug, cx25840_debug, int, 0644); 79 80 80 81 MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]"); 81 - 82 82 83 83 /* ----------------------------------------------------------------------- */ 84 84 static void cx23888_std_setup(struct i2c_client *client); ··· 85 87 int cx25840_write(struct i2c_client *client, u16 addr, u8 value) 86 88 { 87 89 u8 buffer[3]; 90 + 88 91 buffer[0] = addr >> 8; 89 92 buffer[1] = addr & 0xff; 90 93 buffer[2] = value; ··· 95 96 int cx25840_write4(struct i2c_client *client, u16 addr, u32 value) 96 97 { 97 98 u8 buffer[6]; 99 + 98 100 buffer[0] = addr >> 8; 99 101 buffer[1] = addr & 0xff; 100 102 buffer[2] = value & 0xff; ··· 105 105 return i2c_master_send(client, buffer, 6); 106 106 } 107 107 108 - u8 cx25840_read(struct i2c_client * client, u16 addr) 108 + u8 cx25840_read(struct i2c_client *client, u16 addr) 109 109 { 110 110 struct i2c_msg msgs[2]; 111 111 u8 tx_buf[2], rx_buf[1]; ··· 116 116 msgs[0].addr = client->addr; 117 117 msgs[0].flags = 0; 118 118 msgs[0].len = 2; 119 - msgs[0].buf = (char *) tx_buf; 119 + msgs[0].buf = (char *)tx_buf; 120 120 121 121 /* Read data from register */ 122 122 msgs[1].addr = client->addr; 123 123 msgs[1].flags = I2C_M_RD; 124 124 msgs[1].len = 1; 125 - msgs[1].buf = (char *) rx_buf; 125 + msgs[1].buf = (char *)rx_buf; 126 126 127 127 if (i2c_transfer(client->adapter, msgs, 2) < 2) 128 128 return 0; ··· 130 130 return rx_buf[0]; 131 131 } 132 132 133 - u32 cx25840_read4(struct i2c_client * client, u16 addr) 133 + u32 cx25840_read4(struct i2c_client *client, u16 addr) 134 134 { 135 135 struct i2c_msg msgs[2]; 136 136 u8 tx_buf[2], rx_buf[4]; ··· 141 141 msgs[0].addr = client->addr; 142 142 msgs[0].flags = 0; 143 143 msgs[0].len = 2; 144 - msgs[0].buf = (char *) tx_buf; 144 + msgs[0].buf = (char *)tx_buf; 145 145 146 146 /* Read data from registers */ 147 147 msgs[1].addr = client->addr; 148 148 msgs[1].flags = I2C_M_RD; 149 149 msgs[1].len = 4; 150 - msgs[1].buf = (char *) rx_buf; 150 + msgs[1].buf = (char *)rx_buf; 151 151 152 152 if (i2c_transfer(client->adapter, msgs, 2) < 2) 153 153 return 0; ··· 156 156 rx_buf[0]; 157 157 } 158 158 159 - int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned and_mask, 159 + int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned int and_mask, 160 160 u8 or_value) 161 161 { 162 162 return cx25840_write(client, addr, ··· 174 174 175 175 /* ----------------------------------------------------------------------- */ 176 176 177 - static int set_input(struct i2c_client *client, enum cx25840_video_input vid_input, 178 - enum cx25840_audio_input aud_input); 177 + static int set_input(struct i2c_client *client, 178 + enum cx25840_video_input vid_input, 179 + enum cx25840_audio_input aud_input); 179 180 180 181 /* ----------------------------------------------------------------------- */ 181 182 182 183 static int cx23885_s_io_pin_config(struct v4l2_subdev *sd, size_t n, 183 - struct v4l2_subdev_io_pin_config *p) 184 + struct v4l2_subdev_io_pin_config *p) 184 185 { 185 186 struct i2c_client *client = v4l2_get_subdevdata(sd); 186 187 int i; ··· 412 411 if (strength != CX25840_PIN_DRIVE_SLOW && 413 412 strength != CX25840_PIN_DRIVE_MEDIUM && 414 413 strength != CX25840_PIN_DRIVE_FAST) { 415 - 416 414 v4l_err(client, 417 415 "invalid drive speed for pin %u (%u), assuming fast\n", 418 416 (unsigned int)p[i].pin, ··· 531 531 } 532 532 533 533 static int common_s_io_pin_config(struct v4l2_subdev *sd, size_t n, 534 - struct v4l2_subdev_io_pin_config *pincfg) 534 + struct v4l2_subdev_io_pin_config *pincfg) 535 535 { 536 536 struct cx25840_state *state = to_state(sd); 537 537 ··· 546 546 547 547 static void init_dll1(struct i2c_client *client) 548 548 { 549 - /* This is the Hauppauge sequence used to 550 - * initialize the Delay Lock Loop 1 (ADC DLL). */ 549 + /* 550 + * This is the Hauppauge sequence used to 551 + * initialize the Delay Lock Loop 1 (ADC DLL). 552 + */ 551 553 cx25840_write(client, 0x159, 0x23); 552 554 cx25840_write(client, 0x15a, 0x87); 553 555 cx25840_write(client, 0x15b, 0x06); ··· 564 562 565 563 static void init_dll2(struct i2c_client *client) 566 564 { 567 - /* This is the Hauppauge sequence used to 568 - * initialize the Delay Lock Loop 2 (ADC DLL). */ 565 + /* 566 + * This is the Hauppauge sequence used to 567 + * initialize the Delay Lock Loop 2 (ADC DLL). 568 + */ 569 569 cx25840_write(client, 0x15d, 0xe3); 570 570 cx25840_write(client, 0x15e, 0x86); 571 571 cx25840_write(client, 0x15f, 0x06); ··· 579 575 580 576 static void cx25836_initialize(struct i2c_client *client) 581 577 { 582 - /* reset configuration is described on page 3-77 of the CX25836 datasheet */ 578 + /* 579 + *reset configuration is described on page 3-77 580 + * of the CX25836 datasheet 581 + */ 582 + 583 583 /* 2. */ 584 584 cx25840_and_or(client, 0x000, ~0x01, 0x01); 585 585 cx25840_and_or(client, 0x000, ~0x01, 0x00); ··· 609 601 static void cx25840_work_handler(struct work_struct *work) 610 602 { 611 603 struct cx25840_state *state = container_of(work, struct cx25840_state, fw_work); 604 + 612 605 cx25840_loadfw(state->c); 613 606 wake_up(&state->fw_wait); 614 607 } ··· 708 699 /* datasheet startup in numbered steps, refer to page 3-77 */ 709 700 /* 2. */ 710 701 cx25840_and_or(client, 0x803, ~0x10, 0x00); 711 - /* The default of this register should be 4, but I get 0 instead. 712 - * Set this register to 4 manually. */ 702 + /* 703 + * The default of this register should be 4, but I get 0 instead. 704 + * Set this register to 4 manually. 705 + */ 713 706 cx25840_write(client, 0x000, 0x04); 714 707 /* 3. */ 715 708 init_dll1(client); ··· 721 710 cx25840_write(client, 0x13c, 0x01); 722 711 cx25840_write(client, 0x13c, 0x00); 723 712 /* 5. */ 724 - /* Do the firmware load in a work handler to prevent. 725 - Otherwise the kernel is blocked waiting for the 726 - bit-banging i2c interface to finish uploading the 727 - firmware. */ 713 + /* 714 + * Do the firmware load in a work handler to prevent. 715 + * Otherwise the kernel is blocked waiting for the 716 + * bit-banging i2c interface to finish uploading the 717 + * firmware. 718 + */ 728 719 INIT_WORK(&state->fw_work, cx25840_work_handler); 729 720 init_waitqueue_head(&state->fw_wait); 730 721 q = create_singlethread_workqueue("cx25840_fw"); ··· 958 945 cx25840_write(client, 0x160, 0x1d); 959 946 cx25840_write(client, 0x164, 0x00); 960 947 961 - /* Do the firmware load in a work handler to prevent. 962 - Otherwise the kernel is blocked waiting for the 963 - bit-banging i2c interface to finish uploading the 964 - firmware. */ 948 + /* 949 + * Do the firmware load in a work handler to prevent. 950 + * Otherwise the kernel is blocked waiting for the 951 + * bit-banging i2c interface to finish uploading the 952 + * firmware. 953 + */ 965 954 INIT_WORK(&state->fw_work, cx25840_work_handler); 966 955 init_waitqueue_head(&state->fw_wait); 967 956 q = create_singlethread_workqueue("cx25840_fw"); ··· 975 960 destroy_workqueue(q); 976 961 } 977 962 978 - /* Call the cx23888 specific std setup func, we no longer rely on 963 + /* 964 + * Call the cx23888 specific std setup func, we no longer rely on 979 965 * the generic cx24840 func. 980 966 */ 981 967 if (is_cx23888(state)) ··· 998 982 cx25840_write(client, CX25840_AUD_INT_STAT_REG, 0xff); 999 983 1000 984 /* CC raw enable */ 1001 - /* - VIP 1.1 control codes - 10bit, blue field enable. 985 + 986 + /* 987 + * - VIP 1.1 control codes - 10bit, blue field enable. 1002 988 * - enable raw data during vertical blanking. 1003 989 * - enable ancillary Data insertion for 656 or VIP. 1004 990 */ ··· 1083 1065 /* White crush, Chroma AGC & Chroma Killer enabled */ 1084 1066 cx25840_write(client, 0x401, 0xe8); 1085 1067 1086 - /* Do the firmware load in a work handler to prevent. 1087 - Otherwise the kernel is blocked waiting for the 1088 - bit-banging i2c interface to finish uploading the 1089 - firmware. */ 1068 + /* 1069 + * Do the firmware load in a work handler to prevent. 1070 + * Otherwise the kernel is blocked waiting for the 1071 + * bit-banging i2c interface to finish uploading the 1072 + * firmware. 1073 + */ 1090 1074 INIT_WORK(&state->fw_work, cx25840_work_handler); 1091 1075 init_waitqueue_head(&state->fw_wait); 1092 1076 q = create_singlethread_workqueue("cx25840_fw"); ··· 1184 1164 vblank = 26; 1185 1165 vblank656 = 26; 1186 1166 burst = 0x5b; 1187 - } else 1167 + } else { 1188 1168 burst = 0x59; 1169 + } 1189 1170 luma_lpf = 2; 1190 1171 comb = 0x20; 1191 1172 sc = 688739; ··· 1221 1200 int pll = (28636363L * ((((u64)pll_int) << 25L) + pll_frac)) >> 25L; 1222 1201 1223 1202 pll /= pll_post; 1224 - v4l_dbg(1, cx25840_debug, client, "PLL = %d.%06d MHz\n", 1225 - pll / 1000000, pll % 1000000); 1226 - v4l_dbg(1, cx25840_debug, client, "PLL/8 = %d.%06d MHz\n", 1227 - pll / 8000000, (pll / 8) % 1000000); 1203 + v4l_dbg(1, cx25840_debug, client, 1204 + "PLL = %d.%06d MHz\n", 1205 + pll / 1000000, pll % 1000000); 1206 + v4l_dbg(1, cx25840_debug, client, 1207 + "PLL/8 = %d.%06d MHz\n", 1208 + pll / 8000000, (pll / 8) % 1000000); 1228 1209 1229 1210 fin = ((u64)src_decimation * pll) >> 12; 1230 1211 v4l_dbg(1, cx25840_debug, client, 1231 - "ADC Sampling freq = %d.%06d MHz\n", 1232 - fin / 1000000, fin % 1000000); 1212 + "ADC Sampling freq = %d.%06d MHz\n", 1213 + fin / 1000000, fin % 1000000); 1233 1214 1234 1215 fsc = (((u64)sc) * pll) >> 24L; 1235 1216 v4l_dbg(1, cx25840_debug, client, 1236 - "Chroma sub-carrier freq = %d.%06d MHz\n", 1237 - fsc / 1000000, fsc % 1000000); 1217 + "Chroma sub-carrier freq = %d.%06d MHz\n", 1218 + fsc / 1000000, fsc % 1000000); 1238 1219 1239 - v4l_dbg(1, cx25840_debug, client, "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", 1220 + v4l_dbg(1, cx25840_debug, client, 1221 + "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", 1240 1222 hblank, hactive, vblank, vactive, vblank656, 1241 - src_decimation, burst, luma_lpf, uv_lpf, comb, sc); 1223 + src_decimation, burst, luma_lpf, uv_lpf, 1224 + comb, sc); 1242 1225 } 1243 1226 } 1244 1227 ··· 1297 1272 /* Follow step 8c and 8d of section 3.16 in the cx25840 datasheet */ 1298 1273 if (std & V4L2_STD_SECAM) { 1299 1274 cx25840_write(client, 0x402, 0); 1300 - } 1301 - else { 1275 + } else { 1302 1276 cx25840_write(client, 0x402, 0x04); 1303 - cx25840_write(client, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11); 1277 + cx25840_write(client, 0x49f, 1278 + (std & V4L2_STD_NTSC) ? 0x14 : 0x11); 1304 1279 } 1305 1280 cx25840_and_or(client, 0x401, ~0x60, 0); 1306 1281 cx25840_and_or(client, 0x401, ~0x60, 0x60); ··· 1314 1289 if (state->radio) { 1315 1290 cx25840_write(client, 0x808, 0xf9); 1316 1291 cx25840_write(client, 0x80b, 0x00); 1317 - } 1318 - else if (std & V4L2_STD_525_60) { 1319 - /* Certain Hauppauge PVR150 models have a hardware bug 1320 - that causes audio to drop out. For these models the 1321 - audio standard must be set explicitly. 1322 - To be precise: it affects cards with tuner models 1323 - 85, 99 and 112 (model numbers from tveeprom). */ 1292 + } else if (std & V4L2_STD_525_60) { 1293 + /* 1294 + * Certain Hauppauge PVR150 models have a hardware bug 1295 + * that causes audio to drop out. For these models the 1296 + * audio standard must be set explicitly. 1297 + * To be precise: it affects cards with tuner models 1298 + * 85, 99 and 112 (model numbers from tveeprom). 1299 + */ 1324 1300 int hw_fix = state->pvr150_workaround; 1325 1301 1326 1302 if (std == V4L2_STD_NTSC_M_JP) { ··· 1338 1312 } else if (std & V4L2_STD_PAL) { 1339 1313 /* Autodetect audio standard and audio system */ 1340 1314 cx25840_write(client, 0x808, 0xff); 1341 - /* Since system PAL-L is pretty much non-existent and 1342 - not used by any public broadcast network, force 1343 - 6.5 MHz carrier to be interpreted as System DK, 1344 - this avoids DK audio detection instability */ 1315 + /* 1316 + * Since system PAL-L is pretty much non-existent and 1317 + * not used by any public broadcast network, force 1318 + * 6.5 MHz carrier to be interpreted as System DK, 1319 + * this avoids DK audio detection instability 1320 + */ 1345 1321 cx25840_write(client, 0x80b, 0x00); 1346 1322 } else if (std & V4L2_STD_SECAM) { 1347 1323 /* Autodetect audio standard and audio system */ 1348 1324 cx25840_write(client, 0x808, 0xff); 1349 - /* If only one of SECAM-DK / SECAM-L is required, then force 1350 - 6.5MHz carrier, else autodetect it */ 1325 + /* 1326 + * If only one of SECAM-DK / SECAM-L is required, then force 1327 + * 6.5MHz carrier, else autodetect it 1328 + */ 1351 1329 if ((std & V4L2_STD_SECAM_DK) && 1352 1330 !(std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) { 1353 1331 /* 6.5 MHz carrier to be interpreted as System DK */ 1354 1332 cx25840_write(client, 0x80b, 0x00); 1355 - } else if (!(std & V4L2_STD_SECAM_DK) && 1356 - (std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) { 1333 + } else if (!(std & V4L2_STD_SECAM_DK) && 1334 + (std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) { 1357 1335 /* 6.5 MHz carrier to be interpreted as System L */ 1358 1336 cx25840_write(client, 0x80b, 0x08); 1359 - } else { 1337 + } else { 1360 1338 /* 6.5 MHz carrier to be autodetected */ 1361 1339 cx25840_write(client, 0x80b, 0x10); 1362 - } 1340 + } 1363 1341 } 1364 1342 1365 1343 cx25840_and_or(client, 0x810, ~0x01, 0); 1366 1344 } 1367 1345 1368 - static int set_input(struct i2c_client *client, enum cx25840_video_input vid_input, 1369 - enum cx25840_audio_input aud_input) 1346 + static int set_input(struct i2c_client *client, 1347 + enum cx25840_video_input vid_input, 1348 + enum cx25840_audio_input aud_input) 1370 1349 { 1371 1350 struct cx25840_state *state = to_state(i2c_get_clientdata(client)); 1372 1351 u8 is_composite = (vid_input >= CX25840_COMPOSITE1 && ··· 1396 1365 vid_input); 1397 1366 reg = vid_input & 0xff; 1398 1367 is_composite = !is_component && 1399 - ((vid_input & CX25840_SVIDEO_ON) != CX25840_SVIDEO_ON); 1368 + ((vid_input & CX25840_SVIDEO_ON) != CX25840_SVIDEO_ON); 1400 1369 1401 1370 v4l_dbg(1, cx25840_debug, client, "mux cfg 0x%x comp=%d\n", 1402 1371 reg, is_composite); ··· 1404 1373 reg = 0xf0 + (vid_input - CX25840_COMPOSITE1); 1405 1374 } else { 1406 1375 if ((vid_input & ~0xff0) || 1407 - luma < CX25840_SVIDEO_LUMA1 || luma > CX25840_SVIDEO_LUMA8 || 1408 - chroma < CX25840_SVIDEO_CHROMA4 || chroma > CX25840_SVIDEO_CHROMA8) { 1376 + luma < CX25840_SVIDEO_LUMA1 || 1377 + luma > CX25840_SVIDEO_LUMA8 || 1378 + chroma < CX25840_SVIDEO_CHROMA4 || 1379 + chroma > CX25840_SVIDEO_CHROMA8) { 1409 1380 v4l_err(client, "0x%04x is not a valid video input!\n", 1410 1381 vid_input); 1411 1382 return -EINVAL; ··· 1431 1398 case CX25840_AUDIO_SERIAL: 1432 1399 /* do nothing, use serial audio input */ 1433 1400 break; 1434 - case CX25840_AUDIO4: reg &= ~0x30; break; 1435 - case CX25840_AUDIO5: reg &= ~0x30; reg |= 0x10; break; 1436 - case CX25840_AUDIO6: reg &= ~0x30; reg |= 0x20; break; 1437 - case CX25840_AUDIO7: reg &= ~0xc0; break; 1438 - case CX25840_AUDIO8: reg &= ~0xc0; reg |= 0x40; break; 1439 - 1401 + case CX25840_AUDIO4: 1402 + reg &= ~0x30; 1403 + break; 1404 + case CX25840_AUDIO5: 1405 + reg &= ~0x30; 1406 + reg |= 0x10; 1407 + break; 1408 + case CX25840_AUDIO6: 1409 + reg &= ~0x30; 1410 + reg |= 0x20; 1411 + break; 1412 + case CX25840_AUDIO7: 1413 + reg &= ~0xc0; 1414 + break; 1415 + case CX25840_AUDIO8: 1416 + reg &= ~0xc0; 1417 + reg |= 0x40; 1418 + break; 1440 1419 default: 1441 1420 v4l_err(client, "0x%04x is not a valid audio input!\n", 1442 1421 aud_input); ··· 1465 1420 cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02); 1466 1421 1467 1422 if (is_cx2388x(state)) { 1468 - 1469 1423 /* Enable or disable the DIF for tuner use */ 1470 1424 if (is_dif) { 1471 1425 cx25840_and_or(client, 0x102, ~0x80, 0x80); ··· 1495 1451 cx25840_write4(client, 0x410, 0xffff0dbf); 1496 1452 cx25840_write4(client, 0x414, 0x00137d03); 1497 1453 1498 - cx25840_write4(client, state->vbi_regs_offset + 0x42c, 0x42600000); 1499 - cx25840_write4(client, state->vbi_regs_offset + 0x430, 0x0000039b); 1500 - cx25840_write4(client, state->vbi_regs_offset + 0x438, 0x00000000); 1454 + cx25840_write4(client, state->vbi_regs_offset + 0x42c, 1455 + 0x42600000); 1456 + cx25840_write4(client, state->vbi_regs_offset + 0x430, 1457 + 0x0000039b); 1458 + cx25840_write4(client, state->vbi_regs_offset + 0x438, 1459 + 0x00000000); 1501 1460 1502 - cx25840_write4(client, state->vbi_regs_offset + 0x440, 0xF8E3E824); 1503 - cx25840_write4(client, state->vbi_regs_offset + 0x444, 0x401040dc); 1504 - cx25840_write4(client, state->vbi_regs_offset + 0x448, 0xcd3f02a0); 1505 - cx25840_write4(client, state->vbi_regs_offset + 0x44c, 0x161f1000); 1506 - cx25840_write4(client, state->vbi_regs_offset + 0x450, 0x00000802); 1461 + cx25840_write4(client, state->vbi_regs_offset + 0x440, 1462 + 0xF8E3E824); 1463 + cx25840_write4(client, state->vbi_regs_offset + 0x444, 1464 + 0x401040dc); 1465 + cx25840_write4(client, state->vbi_regs_offset + 0x448, 1466 + 0xcd3f02a0); 1467 + cx25840_write4(client, state->vbi_regs_offset + 0x44c, 1468 + 0x161f1000); 1469 + cx25840_write4(client, state->vbi_regs_offset + 0x450, 1470 + 0x00000802); 1507 1471 1508 1472 cx25840_write4(client, 0x91c, 0x01000000); 1509 1473 cx25840_write4(client, 0x8e0, 0x03063870); ··· 1578 1526 * Only one of the two will be in use. 1579 1527 */ 1580 1528 cx25840_write4(client, AFE_CTRL, val); 1581 - } else 1529 + } else { 1582 1530 cx25840_and_or(client, 0x102, ~0x2, 0); 1531 + } 1583 1532 } 1584 1533 1585 1534 state->vid_input = vid_input; ··· 1619 1566 cx25840_write(client, 0x919, 0x01); 1620 1567 } 1621 1568 1622 - if (is_cx2388x(state) && ((aud_input == CX25840_AUDIO7) || 1623 - (aud_input == CX25840_AUDIO6))) { 1569 + if (is_cx2388x(state) && 1570 + ((aud_input == CX25840_AUDIO7) || (aud_input == CX25840_AUDIO6))) { 1624 1571 /* Configure audio from LR1 or LR2 input */ 1625 1572 cx25840_write4(client, 0x910, 0); 1626 1573 cx25840_write4(client, 0x8d0, 0x63073); 1627 - } else 1628 - if (is_cx2388x(state) && (aud_input == CX25840_AUDIO8)) { 1574 + } else if (is_cx2388x(state) && (aud_input == CX25840_AUDIO8)) { 1629 1575 /* Configure audio from tuner/sif input */ 1630 1576 cx25840_write4(client, 0x910, 0x12b000c9); 1631 1577 cx25840_write4(client, 0x8d0, 0x1f063870); 1632 1578 } 1633 1579 1634 1580 if (is_cx23888(state)) { 1635 - /* HVR1850 */ 1636 - /* AUD_IO_CTRL - I2S Input, Parallel1*/ 1637 - /* - Channel 1 src - Parallel1 (Merlin out) */ 1638 - /* - Channel 2 src - Parallel2 (Merlin out) */ 1639 - /* - Channel 3 src - Parallel3 (Merlin AC97 out) */ 1640 - /* - I2S source and dir - Merlin, output */ 1581 + /* 1582 + * HVR1850 1583 + * 1584 + * AUD_IO_CTRL - I2S Input, Parallel1 1585 + * - Channel 1 src - Parallel1 (Merlin out) 1586 + * - Channel 2 src - Parallel2 (Merlin out) 1587 + * - Channel 3 src - Parallel3 (Merlin AC97 out) 1588 + * - I2S source and dir - Merlin, output 1589 + */ 1641 1590 cx25840_write4(client, 0x124, 0x100); 1642 1591 1643 1592 if (!is_dif) { 1644 - /* Stop microcontroller if we don't need it 1593 + /* 1594 + * Stop microcontroller if we don't need it 1645 1595 * to avoid audio popping on svideo/composite use. 1646 1596 */ 1647 1597 cx25840_and_or(client, 0x803, ~0x10, 0x00); ··· 1686 1630 fmt = 0xc; 1687 1631 } 1688 1632 1689 - v4l_dbg(1, cx25840_debug, client, "changing video std to fmt %i\n",fmt); 1633 + v4l_dbg(1, cx25840_debug, client, 1634 + "changing video std to fmt %i\n", fmt); 1690 1635 1691 - /* Follow step 9 of section 3.16 in the cx25840 datasheet. 1692 - Without this PAL may display a vertical ghosting effect. 1693 - This happens for example with the Yuan MPC622. */ 1636 + /* 1637 + * Follow step 9 of section 3.16 in the cx25840 datasheet. 1638 + * Without this PAL may display a vertical ghosting effect. 1639 + * This happens for example with the Yuan MPC622. 1640 + */ 1694 1641 if (fmt >= 4 && fmt < 8) { 1695 1642 /* Set format to NTSC-M */ 1696 1643 cx25840_and_or(client, 0x400, ~0xf, 1); ··· 1755 1696 /* ----------------------------------------------------------------------- */ 1756 1697 1757 1698 static int cx25840_set_fmt(struct v4l2_subdev *sd, 1758 - struct v4l2_subdev_pad_config *cfg, 1759 - struct v4l2_subdev_format *format) 1699 + struct v4l2_subdev_pad_config *cfg, 1700 + struct v4l2_subdev_format *format) 1760 1701 { 1761 1702 struct v4l2_mbus_framefmt *fmt = &format->format; 1762 1703 struct cx25840_state *state = to_state(sd); 1763 1704 struct i2c_client *client = v4l2_get_subdevdata(sd); 1764 - u32 HSC, VSC, Vsrc, Hsrc, Vadd; 1705 + u32 hsc, vsc, v_src, h_src, v_add; 1765 1706 int filter; 1766 - int is_50Hz = !(state->std & V4L2_STD_525_60); 1707 + int is_50hz = !(state->std & V4L2_STD_525_60); 1767 1708 1768 1709 if (format->pad || fmt->code != MEDIA_BUS_FMT_FIXED) 1769 1710 return -EINVAL; ··· 1772 1713 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; 1773 1714 1774 1715 if (is_cx23888(state)) { 1775 - Vsrc = (cx25840_read(client, 0x42a) & 0x3f) << 4; 1776 - Vsrc |= (cx25840_read(client, 0x429) & 0xf0) >> 4; 1716 + v_src = (cx25840_read(client, 0x42a) & 0x3f) << 4; 1717 + v_src |= (cx25840_read(client, 0x429) & 0xf0) >> 4; 1777 1718 } else { 1778 - Vsrc = (cx25840_read(client, 0x476) & 0x3f) << 4; 1779 - Vsrc |= (cx25840_read(client, 0x475) & 0xf0) >> 4; 1719 + v_src = (cx25840_read(client, 0x476) & 0x3f) << 4; 1720 + v_src |= (cx25840_read(client, 0x475) & 0xf0) >> 4; 1780 1721 } 1781 1722 1782 1723 if (is_cx23888(state)) { 1783 - Hsrc = (cx25840_read(client, 0x426) & 0x3f) << 4; 1784 - Hsrc |= (cx25840_read(client, 0x425) & 0xf0) >> 4; 1724 + h_src = (cx25840_read(client, 0x426) & 0x3f) << 4; 1725 + h_src |= (cx25840_read(client, 0x425) & 0xf0) >> 4; 1785 1726 } else { 1786 - Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4; 1787 - Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4; 1727 + h_src = (cx25840_read(client, 0x472) & 0x3f) << 4; 1728 + h_src |= (cx25840_read(client, 0x471) & 0xf0) >> 4; 1788 1729 } 1789 1730 1790 1731 if (!state->generic_mode) { 1791 - Vadd = is_50Hz ? 4 : 7; 1732 + v_add = is_50hz ? 4 : 7; 1792 1733 1793 1734 /* 1794 1735 * cx23888 in 525-line mode is programmed for 486 active lines ··· 1797 1738 * See reg 0x428 bits [21:12] in cx23888_std_setup() vs 1798 1739 * vactive in cx25840_std_setup(). 1799 1740 */ 1800 - if (is_cx23888(state) && !is_50Hz) 1801 - Vadd--; 1802 - } else 1803 - Vadd = 0; 1741 + if (is_cx23888(state) && !is_50hz) 1742 + v_add--; 1743 + } else { 1744 + v_add = 0; 1745 + } 1804 1746 1805 - if (Hsrc == 0 || 1806 - Vsrc <= Vadd) { 1747 + if (h_src == 0 || 1748 + v_src <= v_add) { 1807 1749 v4l_err(client, 1808 1750 "chip reported picture size (%u x %u) is far too small\n", 1809 - (unsigned int)Hsrc, (unsigned int)Vsrc); 1751 + (unsigned int)h_src, (unsigned int)v_src); 1810 1752 /* 1811 1753 * that's the best we can do since the output picture 1812 1754 * size is completely unknown in this case ··· 1815 1755 return -EINVAL; 1816 1756 } 1817 1757 1818 - fmt->width = clamp(fmt->width, (Hsrc + 15) / 16, Hsrc); 1758 + fmt->width = clamp(fmt->width, (h_src + 15) / 16, h_src); 1819 1759 1820 - if (Vadd * 8 >= Vsrc) 1821 - fmt->height = clamp(fmt->height, (u32)1, Vsrc - Vadd); 1760 + if (v_add * 8 >= v_src) 1761 + fmt->height = clamp(fmt->height, (u32)1, v_src - v_add); 1822 1762 else 1823 - fmt->height = clamp(fmt->height, (Vsrc - Vadd * 8 + 7) / 8, 1824 - Vsrc - Vadd); 1763 + fmt->height = clamp(fmt->height, (v_src - v_add * 8 + 7) / 8, 1764 + v_src - v_add); 1825 1765 1826 1766 if (format->which == V4L2_SUBDEV_FORMAT_TRY) 1827 1767 return 0; 1828 1768 1829 - HSC = (Hsrc * (1 << 20)) / fmt->width - (1 << 20); 1830 - VSC = (1 << 16) - (Vsrc * (1 << 9) / (fmt->height + Vadd) - (1 << 9)); 1831 - VSC &= 0x1fff; 1769 + hsc = (h_src * (1 << 20)) / fmt->width - (1 << 20); 1770 + vsc = (1 << 16) - (v_src * (1 << 9) / (fmt->height + v_add) - (1 << 9)); 1771 + vsc &= 0x1fff; 1832 1772 1833 1773 if (fmt->width >= 385) 1834 1774 filter = 0; ··· 1842 1782 v4l_dbg(1, cx25840_debug, client, 1843 1783 "decoder set size %u x %u with scale %x x %x\n", 1844 1784 (unsigned int)fmt->width, (unsigned int)fmt->height, 1845 - (unsigned int)HSC, (unsigned int)VSC); 1785 + (unsigned int)hsc, (unsigned int)vsc); 1846 1786 1847 - /* HSCALE=HSC */ 1787 + /* HSCALE=hsc */ 1848 1788 if (is_cx23888(state)) { 1849 - cx25840_write4(client, 0x434, HSC | (1 << 24)); 1850 - /* VSCALE=VSC VS_INTRLACE=1 VFILT=filter */ 1851 - cx25840_write4(client, 0x438, VSC | (1 << 19) | (filter << 16)); 1789 + cx25840_write4(client, 0x434, hsc | (1 << 24)); 1790 + /* VSCALE=vsc VS_INTRLACE=1 VFILT=filter */ 1791 + cx25840_write4(client, 0x438, vsc | (1 << 19) | (filter << 16)); 1852 1792 } else { 1853 - cx25840_write(client, 0x418, HSC & 0xff); 1854 - cx25840_write(client, 0x419, (HSC >> 8) & 0xff); 1855 - cx25840_write(client, 0x41a, HSC >> 16); 1856 - /* VSCALE=VSC */ 1857 - cx25840_write(client, 0x41c, VSC & 0xff); 1858 - cx25840_write(client, 0x41d, VSC >> 8); 1793 + cx25840_write(client, 0x418, hsc & 0xff); 1794 + cx25840_write(client, 0x419, (hsc >> 8) & 0xff); 1795 + cx25840_write(client, 0x41a, hsc >> 16); 1796 + /* VSCALE=vsc */ 1797 + cx25840_write(client, 0x41c, vsc & 0xff); 1798 + cx25840_write(client, 0x41d, vsc >> 8); 1859 1799 /* VS_INTRLACE=1 VFILT=filter */ 1860 1800 cx25840_write(client, 0x41e, 0x8 | filter); 1861 1801 } ··· 1882 1822 int vid_input = state->vid_input; 1883 1823 1884 1824 v4l_info(client, "Video signal: %spresent\n", 1885 - (gen_stat2 & 0x20) ? "" : "not "); 1825 + (gen_stat2 & 0x20) ? "" : "not "); 1886 1826 v4l_info(client, "Detected format: %s\n", 1887 - fmt_strs[gen_stat1 & 0xf]); 1827 + fmt_strs[gen_stat1 & 0xf]); 1888 1828 1889 1829 v4l_info(client, "Specified standard: %s\n", 1890 - vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection"); 1830 + vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection"); 1891 1831 1892 1832 if (vid_input >= CX25840_COMPOSITE1 && 1893 1833 vid_input <= CX25840_COMPOSITE8) { 1894 1834 v4l_info(client, "Specified video input: Composite %d\n", 1895 - vid_input - CX25840_COMPOSITE1 + 1); 1835 + vid_input - CX25840_COMPOSITE1 + 1); 1896 1836 } else { 1897 - v4l_info(client, "Specified video input: S-Video (Luma In%d, Chroma In%d)\n", 1898 - (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8); 1837 + v4l_info(client, 1838 + "Specified video input: S-Video (Luma In%d, Chroma In%d)\n", 1839 + (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8); 1899 1840 } 1900 1841 1901 - v4l_info(client, "Specified audioclock freq: %d Hz\n", state->audclk_freq); 1842 + v4l_info(client, "Specified audioclock freq: %d Hz\n", 1843 + state->audclk_freq); 1902 1844 } 1903 1845 1904 1846 /* ----------------------------------------------------------------------- */ ··· 1919 1857 char *p; 1920 1858 1921 1859 switch (mod_det_stat0) { 1922 - case 0x00: p = "mono"; break; 1923 - case 0x01: p = "stereo"; break; 1924 - case 0x02: p = "dual"; break; 1925 - case 0x04: p = "tri"; break; 1926 - case 0x10: p = "mono with SAP"; break; 1927 - case 0x11: p = "stereo with SAP"; break; 1928 - case 0x12: p = "dual with SAP"; break; 1929 - case 0x14: p = "tri with SAP"; break; 1930 - case 0xfe: p = "forced mode"; break; 1931 - default: p = "not defined"; 1860 + case 0x00: 1861 + p = "mono"; 1862 + break; 1863 + case 0x01: 1864 + p = "stereo"; 1865 + break; 1866 + case 0x02: 1867 + p = "dual"; 1868 + break; 1869 + case 0x04: 1870 + p = "tri"; 1871 + break; 1872 + case 0x10: 1873 + p = "mono with SAP"; 1874 + break; 1875 + case 0x11: 1876 + p = "stereo with SAP"; 1877 + break; 1878 + case 0x12: 1879 + p = "dual with SAP"; 1880 + break; 1881 + case 0x14: 1882 + p = "tri with SAP"; 1883 + break; 1884 + case 0xfe: 1885 + p = "forced mode"; 1886 + break; 1887 + default: 1888 + p = "not defined"; 1932 1889 } 1933 1890 v4l_info(client, "Detected audio mode: %s\n", p); 1934 1891 1935 1892 switch (mod_det_stat1) { 1936 - case 0x00: p = "not defined"; break; 1937 - case 0x01: p = "EIAJ"; break; 1938 - case 0x02: p = "A2-M"; break; 1939 - case 0x03: p = "A2-BG"; break; 1940 - case 0x04: p = "A2-DK1"; break; 1941 - case 0x05: p = "A2-DK2"; break; 1942 - case 0x06: p = "A2-DK3"; break; 1943 - case 0x07: p = "A1 (6.0 MHz FM Mono)"; break; 1944 - case 0x08: p = "AM-L"; break; 1945 - case 0x09: p = "NICAM-BG"; break; 1946 - case 0x0a: p = "NICAM-DK"; break; 1947 - case 0x0b: p = "NICAM-I"; break; 1948 - case 0x0c: p = "NICAM-L"; break; 1949 - case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break; 1950 - case 0x0e: p = "IF FM Radio"; break; 1951 - case 0x0f: p = "BTSC"; break; 1952 - case 0x10: p = "high-deviation FM"; break; 1953 - case 0x11: p = "very high-deviation FM"; break; 1954 - case 0xfd: p = "unknown audio standard"; break; 1955 - case 0xfe: p = "forced audio standard"; break; 1956 - case 0xff: p = "no detected audio standard"; break; 1957 - default: p = "not defined"; 1893 + case 0x00: 1894 + p = "not defined"; 1895 + break; 1896 + case 0x01: 1897 + p = "EIAJ"; 1898 + break; 1899 + case 0x02: 1900 + p = "A2-M"; 1901 + break; 1902 + case 0x03: 1903 + p = "A2-BG"; 1904 + break; 1905 + case 0x04: 1906 + p = "A2-DK1"; 1907 + break; 1908 + case 0x05: 1909 + p = "A2-DK2"; 1910 + break; 1911 + case 0x06: 1912 + p = "A2-DK3"; 1913 + break; 1914 + case 0x07: 1915 + p = "A1 (6.0 MHz FM Mono)"; 1916 + break; 1917 + case 0x08: 1918 + p = "AM-L"; 1919 + break; 1920 + case 0x09: 1921 + p = "NICAM-BG"; 1922 + break; 1923 + case 0x0a: 1924 + p = "NICAM-DK"; 1925 + break; 1926 + case 0x0b: 1927 + p = "NICAM-I"; 1928 + break; 1929 + case 0x0c: 1930 + p = "NICAM-L"; 1931 + break; 1932 + case 0x0d: 1933 + p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; 1934 + break; 1935 + case 0x0e: 1936 + p = "IF FM Radio"; 1937 + break; 1938 + case 0x0f: 1939 + p = "BTSC"; 1940 + break; 1941 + case 0x10: 1942 + p = "high-deviation FM"; 1943 + break; 1944 + case 0x11: 1945 + p = "very high-deviation FM"; 1946 + break; 1947 + case 0xfd: 1948 + p = "unknown audio standard"; 1949 + break; 1950 + case 0xfe: 1951 + p = "forced audio standard"; 1952 + break; 1953 + case 0xff: 1954 + p = "no detected audio standard"; 1955 + break; 1956 + default: 1957 + p = "not defined"; 1958 1958 } 1959 1959 v4l_info(client, "Detected audio standard: %s\n", p); 1960 1960 v4l_info(client, "Audio microcontroller: %s\n", 1961 - (download_ctl & 0x10) ? 1962 - ((mute_ctl & 0x2) ? "detecting" : "running") : "stopped"); 1961 + (download_ctl & 0x10) ? 1962 + ((mute_ctl & 0x2) ? "detecting" : "running") : "stopped"); 1963 1963 1964 1964 switch (audio_config >> 4) { 1965 - case 0x00: p = "undefined"; break; 1966 - case 0x01: p = "BTSC"; break; 1967 - case 0x02: p = "EIAJ"; break; 1968 - case 0x03: p = "A2-M"; break; 1969 - case 0x04: p = "A2-BG"; break; 1970 - case 0x05: p = "A2-DK1"; break; 1971 - case 0x06: p = "A2-DK2"; break; 1972 - case 0x07: p = "A2-DK3"; break; 1973 - case 0x08: p = "A1 (6.0 MHz FM Mono)"; break; 1974 - case 0x09: p = "AM-L"; break; 1975 - case 0x0a: p = "NICAM-BG"; break; 1976 - case 0x0b: p = "NICAM-DK"; break; 1977 - case 0x0c: p = "NICAM-I"; break; 1978 - case 0x0d: p = "NICAM-L"; break; 1979 - case 0x0e: p = "FM radio"; break; 1980 - case 0x0f: p = "automatic detection"; break; 1981 - default: p = "undefined"; 1965 + case 0x00: 1966 + p = "undefined"; 1967 + break; 1968 + case 0x01: 1969 + p = "BTSC"; 1970 + break; 1971 + case 0x02: 1972 + p = "EIAJ"; 1973 + break; 1974 + case 0x03: 1975 + p = "A2-M"; 1976 + break; 1977 + case 0x04: 1978 + p = "A2-BG"; 1979 + break; 1980 + case 0x05: 1981 + p = "A2-DK1"; 1982 + break; 1983 + case 0x06: 1984 + p = "A2-DK2"; 1985 + break; 1986 + case 0x07: 1987 + p = "A2-DK3"; 1988 + break; 1989 + case 0x08: 1990 + p = "A1 (6.0 MHz FM Mono)"; 1991 + break; 1992 + case 0x09: 1993 + p = "AM-L"; 1994 + break; 1995 + case 0x0a: 1996 + p = "NICAM-BG"; 1997 + break; 1998 + case 0x0b: 1999 + p = "NICAM-DK"; 2000 + break; 2001 + case 0x0c: 2002 + p = "NICAM-I"; 2003 + break; 2004 + case 0x0d: 2005 + p = "NICAM-L"; 2006 + break; 2007 + case 0x0e: 2008 + p = "FM radio"; 2009 + break; 2010 + case 0x0f: 2011 + p = "automatic detection"; 2012 + break; 2013 + default: 2014 + p = "undefined"; 1982 2015 } 1983 2016 v4l_info(client, "Configured audio standard: %s\n", p); 1984 2017 1985 2018 if ((audio_config >> 4) < 0xF) { 1986 2019 switch (audio_config & 0xF) { 1987 - case 0x00: p = "MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)"; break; 1988 - case 0x01: p = "MONO2 (LANGUAGE B)"; break; 1989 - case 0x02: p = "MONO3 (STEREO forced MONO)"; break; 1990 - case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break; 1991 - case 0x04: p = "STEREO"; break; 1992 - case 0x05: p = "DUAL1 (AB)"; break; 1993 - case 0x06: p = "DUAL2 (AC) (FM)"; break; 1994 - case 0x07: p = "DUAL3 (BC) (FM)"; break; 1995 - case 0x08: p = "DUAL4 (AC) (AM)"; break; 1996 - case 0x09: p = "DUAL5 (BC) (AM)"; break; 1997 - case 0x0a: p = "SAP"; break; 1998 - default: p = "undefined"; 2020 + case 0x00: 2021 + p = "MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)"; 2022 + break; 2023 + case 0x01: 2024 + p = "MONO2 (LANGUAGE B)"; 2025 + break; 2026 + case 0x02: 2027 + p = "MONO3 (STEREO forced MONO)"; 2028 + break; 2029 + case 0x03: 2030 + p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; 2031 + break; 2032 + case 0x04: 2033 + p = "STEREO"; 2034 + break; 2035 + case 0x05: 2036 + p = "DUAL1 (AB)"; 2037 + break; 2038 + case 0x06: 2039 + p = "DUAL2 (AC) (FM)"; 2040 + break; 2041 + case 0x07: 2042 + p = "DUAL3 (BC) (FM)"; 2043 + break; 2044 + case 0x08: 2045 + p = "DUAL4 (AC) (AM)"; 2046 + break; 2047 + case 0x09: 2048 + p = "DUAL5 (BC) (AM)"; 2049 + break; 2050 + case 0x0a: 2051 + p = "SAP"; 2052 + break; 2053 + default: 2054 + p = "undefined"; 1999 2055 } 2000 2056 v4l_info(client, "Configured audio mode: %s\n", p); 2001 2057 } else { 2002 2058 switch (audio_config & 0xF) { 2003 - case 0x00: p = "BG"; break; 2004 - case 0x01: p = "DK1"; break; 2005 - case 0x02: p = "DK2"; break; 2006 - case 0x03: p = "DK3"; break; 2007 - case 0x04: p = "I"; break; 2008 - case 0x05: p = "L"; break; 2009 - case 0x06: p = "BTSC"; break; 2010 - case 0x07: p = "EIAJ"; break; 2011 - case 0x08: p = "A2-M"; break; 2012 - case 0x09: p = "FM Radio"; break; 2013 - case 0x0f: p = "automatic standard and mode detection"; break; 2014 - default: p = "undefined"; 2059 + case 0x00: 2060 + p = "BG"; 2061 + break; 2062 + case 0x01: 2063 + p = "DK1"; 2064 + break; 2065 + case 0x02: 2066 + p = "DK2"; 2067 + break; 2068 + case 0x03: 2069 + p = "DK3"; 2070 + break; 2071 + case 0x04: 2072 + p = "I"; 2073 + break; 2074 + case 0x05: 2075 + p = "L"; 2076 + break; 2077 + case 0x06: 2078 + p = "BTSC"; 2079 + break; 2080 + case 0x07: 2081 + p = "EIAJ"; 2082 + break; 2083 + case 0x08: 2084 + p = "A2-M"; 2085 + break; 2086 + case 0x09: 2087 + p = "FM Radio"; 2088 + break; 2089 + case 0x0f: 2090 + p = "automatic standard and mode detection"; 2091 + break; 2092 + default: 2093 + p = "undefined"; 2015 2094 } 2016 2095 v4l_info(client, "Configured audio system: %s\n", p); 2017 2096 } 2018 2097 2019 2098 if (aud_input) { 2020 - v4l_info(client, "Specified audio input: Tuner (In%d)\n", aud_input); 2099 + v4l_info(client, "Specified audio input: Tuner (In%d)\n", 2100 + aud_input); 2021 2101 } else { 2022 2102 v4l_info(client, "Specified audio input: External\n"); 2023 2103 } 2024 2104 2025 2105 switch (pref_mode & 0xf) { 2026 - case 0: p = "mono/language A"; break; 2027 - case 1: p = "language B"; break; 2028 - case 2: p = "language C"; break; 2029 - case 3: p = "analog fallback"; break; 2030 - case 4: p = "stereo"; break; 2031 - case 5: p = "language AC"; break; 2032 - case 6: p = "language BC"; break; 2033 - case 7: p = "language AB"; break; 2034 - default: p = "undefined"; 2106 + case 0: 2107 + p = "mono/language A"; 2108 + break; 2109 + case 1: 2110 + p = "language B"; 2111 + break; 2112 + case 2: 2113 + p = "language C"; 2114 + break; 2115 + case 3: 2116 + p = "analog fallback"; 2117 + break; 2118 + case 4: 2119 + p = "stereo"; 2120 + break; 2121 + case 5: 2122 + p = "language AC"; 2123 + break; 2124 + case 6: 2125 + p = "language BC"; 2126 + break; 2127 + case 7: 2128 + p = "language AB"; 2129 + break; 2130 + default: 2131 + p = "undefined"; 2035 2132 } 2036 2133 v4l_info(client, "Preferred audio mode: %s\n", p); 2037 2134 2038 2135 if ((audio_config & 0xf) == 0xf) { 2039 2136 switch ((afc0 >> 3) & 0x3) { 2040 - case 0: p = "system DK"; break; 2041 - case 1: p = "system L"; break; 2042 - case 2: p = "autodetect"; break; 2043 - default: p = "undefined"; 2137 + case 0: 2138 + p = "system DK"; 2139 + break; 2140 + case 1: 2141 + p = "system L"; 2142 + break; 2143 + case 2: 2144 + p = "autodetect"; 2145 + break; 2146 + default: 2147 + p = "undefined"; 2044 2148 } 2045 2149 v4l_info(client, "Selected 65 MHz format: %s\n", p); 2046 2150 2047 2151 switch (afc0 & 0x7) { 2048 - case 0: p = "chroma"; break; 2049 - case 1: p = "BTSC"; break; 2050 - case 2: p = "EIAJ"; break; 2051 - case 3: p = "A2-M"; break; 2052 - case 4: p = "autodetect"; break; 2053 - default: p = "undefined"; 2152 + case 0: 2153 + p = "chroma"; 2154 + break; 2155 + case 1: 2156 + p = "BTSC"; 2157 + break; 2158 + case 2: 2159 + p = "EIAJ"; 2160 + break; 2161 + case 3: 2162 + p = "A2-M"; 2163 + break; 2164 + case 4: 2165 + p = "autodetect"; 2166 + break; 2167 + default: 2168 + p = "undefined"; 2054 2169 } 2055 2170 v4l_info(client, "Selected 45 MHz format: %s\n", p); 2056 2171 } ··· 2278 2039 if (is_cx2584x(state)) { 2279 2040 /* set datasheet video output defaults */ 2280 2041 state->vid_config = CX25840_VCONFIG_FMT_BT656 | 2281 - CX25840_VCONFIG_RES_8BIT | 2282 - CX25840_VCONFIG_VBIRAW_DISABLED | 2283 - CX25840_VCONFIG_ANCDATA_ENABLED | 2284 - CX25840_VCONFIG_TASKBIT_ONE | 2285 - CX25840_VCONFIG_ACTIVE_HORIZONTAL | 2286 - CX25840_VCONFIG_VALID_NORMAL | 2287 - CX25840_VCONFIG_HRESETW_NORMAL | 2288 - CX25840_VCONFIG_CLKGATE_NONE | 2289 - CX25840_VCONFIG_DCMODE_DWORDS | 2290 - CX25840_VCONFIG_IDID0S_NORMAL | 2291 - CX25840_VCONFIG_VIPCLAMP_DISABLED; 2042 + CX25840_VCONFIG_RES_8BIT | 2043 + CX25840_VCONFIG_VBIRAW_DISABLED | 2044 + CX25840_VCONFIG_ANCDATA_ENABLED | 2045 + CX25840_VCONFIG_TASKBIT_ONE | 2046 + CX25840_VCONFIG_ACTIVE_HORIZONTAL | 2047 + CX25840_VCONFIG_VALID_NORMAL | 2048 + CX25840_VCONFIG_HRESETW_NORMAL | 2049 + CX25840_VCONFIG_CLKGATE_NONE | 2050 + CX25840_VCONFIG_DCMODE_DWORDS | 2051 + CX25840_VCONFIG_IDID0S_NORMAL | 2052 + CX25840_VCONFIG_VIPCLAMP_DISABLED; 2292 2053 2293 2054 /* add additional settings */ 2294 2055 cx25840_vconfig_add(state, val); 2295 - } else /* TODO: generic mode needs to be developed for other chips */ 2056 + } else { 2057 + /* TODO: generic mode needs to be developed for other chips */ 2296 2058 WARN_ON(1); 2059 + } 2297 2060 2298 2061 return 0; 2299 2062 } ··· 2345 2104 } 2346 2105 2347 2106 #ifdef CONFIG_VIDEO_ADV_DEBUG 2348 - static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) 2107 + static int cx25840_g_register(struct v4l2_subdev *sd, 2108 + struct v4l2_dbg_register *reg) 2349 2109 { 2350 2110 struct i2c_client *client = v4l2_get_subdevdata(sd); 2351 2111 ··· 2355 2113 return 0; 2356 2114 } 2357 2115 2358 - static int cx25840_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) 2116 + static int cx25840_s_register(struct v4l2_subdev *sd, 2117 + const struct v4l2_dbg_register *reg) 2359 2118 { 2360 2119 struct i2c_client *client = v4l2_get_subdevdata(sd); 2361 2120 ··· 2375 2132 return 0; 2376 2133 2377 2134 v4l_dbg(1, cx25840_debug, client, "%s audio output\n", 2378 - enable ? "enable" : "disable"); 2135 + enable ? "enable" : "disable"); 2379 2136 2380 2137 if (enable) { 2381 2138 v = cx25840_read(client, 0x115) | 0x80; ··· 2398 2155 u8 v; 2399 2156 2400 2157 v4l_dbg(1, cx25840_debug, client, "%s video output\n", 2401 - enable ? "enable" : "disable"); 2158 + enable ? "enable" : "disable"); 2402 2159 2403 2160 /* 2404 2161 * It's not clear what should be done for these devices. ··· 2451 2208 }; 2452 2209 2453 2210 u32 fmt = (cx25840_read4(client, 0x40c) >> 8) & 0xf; 2454 - *std = stds[ fmt ]; 2211 + *std = stds[fmt]; 2455 2212 2456 2213 v4l_dbg(1, cx25840_debug, client, 2457 2214 "querystd fmt = %x, v4l2_std_id = 0x%x\n", ··· 2464 2221 { 2465 2222 struct i2c_client *client = v4l2_get_subdevdata(sd); 2466 2223 2467 - /* A limited function that checks for signal status and returns 2224 + /* 2225 + * A limited function that checks for signal status and returns 2468 2226 * the state. 2469 2227 */ 2470 2228 ··· 2533 2289 return set_input(client, state->vid_input, input); 2534 2290 } 2535 2291 2536 - static int cx25840_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequency *freq) 2292 + static int cx25840_s_frequency(struct v4l2_subdev *sd, 2293 + const struct v4l2_frequency *freq) 2537 2294 { 2538 2295 struct i2c_client *client = v4l2_get_subdevdata(sd); 2539 2296 ··· 2557 2312 if (is_cx2583x(state)) 2558 2313 return 0; 2559 2314 2560 - vt->capability |= 2561 - V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 | 2562 - V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP; 2315 + vt->capability |= V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 | 2316 + V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP; 2563 2317 2564 2318 mode = cx25840_read(client, 0x804); 2565 2319 ··· 2588 2344 return 0; 2589 2345 2590 2346 switch (vt->audmode) { 2591 - case V4L2_TUNER_MODE_MONO: 2592 - /* mono -> mono 2593 - stereo -> mono 2594 - bilingual -> lang1 */ 2595 - cx25840_and_or(client, 0x809, ~0xf, 0x00); 2596 - break; 2597 - case V4L2_TUNER_MODE_STEREO: 2598 - case V4L2_TUNER_MODE_LANG1: 2599 - /* mono -> mono 2600 - stereo -> stereo 2601 - bilingual -> lang1 */ 2602 - cx25840_and_or(client, 0x809, ~0xf, 0x04); 2603 - break; 2604 - case V4L2_TUNER_MODE_LANG1_LANG2: 2605 - /* mono -> mono 2606 - stereo -> stereo 2607 - bilingual -> lang1/lang2 */ 2608 - cx25840_and_or(client, 0x809, ~0xf, 0x07); 2609 - break; 2610 - case V4L2_TUNER_MODE_LANG2: 2611 - /* mono -> mono 2612 - stereo -> stereo 2613 - bilingual -> lang2 */ 2614 - cx25840_and_or(client, 0x809, ~0xf, 0x01); 2615 - break; 2616 - default: 2617 - return -EINVAL; 2347 + case V4L2_TUNER_MODE_MONO: 2348 + /* 2349 + * mono -> mono 2350 + * stereo -> mono 2351 + * bilingual -> lang1 2352 + */ 2353 + cx25840_and_or(client, 0x809, ~0xf, 0x00); 2354 + break; 2355 + case V4L2_TUNER_MODE_STEREO: 2356 + case V4L2_TUNER_MODE_LANG1: 2357 + /* 2358 + * mono -> mono 2359 + * stereo -> stereo 2360 + * bilingual -> lang1 2361 + */ 2362 + cx25840_and_or(client, 0x809, ~0xf, 0x04); 2363 + break; 2364 + case V4L2_TUNER_MODE_LANG1_LANG2: 2365 + /* 2366 + * mono -> mono 2367 + * stereo -> stereo 2368 + * bilingual -> lang1/lang2 2369 + */ 2370 + cx25840_and_or(client, 0x809, ~0xf, 0x07); 2371 + break; 2372 + case V4L2_TUNER_MODE_LANG2: 2373 + /* 2374 + * mono -> mono 2375 + * stereo -> stereo 2376 + * bilingual -> lang2 2377 + */ 2378 + cx25840_and_or(client, 0x809, ~0xf, 0x01); 2379 + break; 2380 + default: 2381 + return -EINVAL; 2618 2382 } 2619 2383 state->audmode = vt->audmode; 2620 2384 return 0; ··· 5797 5545 /* Come out of digital power down */ 5798 5546 cx25840_write(client, 0x000, 0); 5799 5547 5800 - /* Detecting whether the part is cx23885/7/8 is more 5548 + /* 5549 + * Detecting whether the part is cx23885/7/8 is more 5801 5550 * difficult than it needs to be. No ID register. Instead we 5802 5551 * probe certain registers indicated in the datasheets to look 5803 - * for specific defaults that differ between the silicon designs. */ 5552 + * for specific defaults that differ between the silicon designs. 5553 + */ 5804 5554 5805 5555 /* It's either 885/7 if the IR Tx Clk Divider register exists */ 5806 5556 if (cx25840_read4(client, 0x204) & 0xffff) { 5807 - /* CX23885 returns bogus repetitive byte values for the DIF, 5808 - * which doesn't exist for it. (Ex. 8a8a8a8a or 31313131) */ 5557 + /* 5558 + * CX23885 returns bogus repetitive byte values for the DIF, 5559 + * which doesn't exist for it. (Ex. 8a8a8a8a or 31313131) 5560 + */ 5809 5561 ret = cx25840_read4(client, 0x300); 5810 5562 if (((ret & 0xffff0000) >> 16) == (ret & 0xffff)) { 5811 5563 /* No DIF */ 5812 5564 ret = CX23885_AV; 5813 5565 } else { 5814 - /* CX23887 has a broken DIF, but the registers 5815 - * appear valid (but unused), good enough to detect. */ 5566 + /* 5567 + * CX23887 has a broken DIF, but the registers 5568 + * appear valid (but unused), good enough to detect. 5569 + */ 5816 5570 ret = CX23887_AV; 5817 5571 } 5818 5572 } else if (cx25840_read4(client, 0x300) & 0x0fffffff) { ··· 5850 5592 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 5851 5593 return -EIO; 5852 5594 5853 - v4l_dbg(1, cx25840_debug, client, "detecting cx25840 client on address 0x%x\n", client->addr << 1); 5595 + v4l_dbg(1, cx25840_debug, client, 5596 + "detecting cx25840 client on address 0x%x\n", 5597 + client->addr << 1); 5854 5598 5855 5599 device_id = cx25840_read(client, 0x101) << 8; 5856 5600 device_id |= cx25840_read(client, 0x100); 5857 5601 v4l_dbg(1, cx25840_debug, client, "device_id = 0x%04x\n", device_id); 5858 5602 5859 - /* The high byte of the device ID should be 5860 - * 0x83 for the cx2583x and 0x84 for the cx2584x */ 5603 + /* 5604 + * The high byte of the device ID should be 5605 + * 0x83 for the cx2583x and 0x84 for the cx2584x 5606 + */ 5861 5607 if ((device_id & 0xff00) == 0x8300) { 5862 5608 id = CX25836 + ((device_id >> 4) & 0xf) - 6; 5863 5609 } else if ((device_id & 0xff00) == 0x8400) { ··· 5875 5613 v4l_err(client, 5876 5614 "likely a confused/unresponsive cx2388[578] A/V decoder found @ 0x%x (%s)\n", 5877 5615 client->addr << 1, client->adapter->name); 5878 - v4l_err(client, "A method to reset it from the cx25840 driver software is not known at this time\n"); 5616 + v4l_err(client, 5617 + "A method to reset it from the cx25840 driver software is not known at this time\n"); 5879 5618 return -ENODEV; 5880 5619 } else { 5881 5620 v4l_dbg(1, cx25840_debug, client, "cx25840 not found\n"); ··· 5884 5621 } 5885 5622 5886 5623 state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); 5887 - if (state == NULL) 5624 + if (!state) 5888 5625 return -ENOMEM; 5889 5626 5890 5627 sd = &state->sd; ··· 5911 5648 sd->entity.function = MEDIA_ENT_F_ATV_DECODER; 5912 5649 5913 5650 ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads), 5914 - state->pads); 5651 + state->pads); 5915 5652 if (ret < 0) { 5916 5653 v4l_info(client, "failed to initialize media entity!\n"); 5917 5654 return ret; ··· 5939 5676 case CX25841: 5940 5677 case CX25842: 5941 5678 case CX25843: 5942 - /* Note: revision '(device_id & 0x0f) == 2' was never built. The 5943 - marking skips from 0x1 == 22 to 0x3 == 23. */ 5679 + /* 5680 + * Note: revision '(device_id & 0x0f) == 2' was never built. 5681 + * The marking skips from 0x1 == 22 to 0x3 == 23. 5682 + */ 5944 5683 v4l_info(client, "cx25%3x-2%x found @ 0x%x (%s)\n", 5945 5684 (device_id & 0xfff0) >> 4, 5946 5685 (device_id & 0x0f) < 3 ? (device_id & 0x0f) + 1 ··· 5970 5705 state->std = V4L2_STD_NTSC_M; 5971 5706 v4l2_ctrl_handler_init(&state->hdl, 9); 5972 5707 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops, 5973 - V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); 5708 + V4L2_CID_BRIGHTNESS, 0, 255, 1, 128); 5974 5709 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops, 5975 - V4L2_CID_CONTRAST, 0, 127, 1, 64); 5710 + V4L2_CID_CONTRAST, 0, 127, 1, 64); 5976 5711 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops, 5977 - V4L2_CID_SATURATION, 0, 127, 1, 64); 5712 + V4L2_CID_SATURATION, 0, 127, 1, 64); 5978 5713 v4l2_ctrl_new_std(&state->hdl, &cx25840_ctrl_ops, 5979 - V4L2_CID_HUE, -128, 127, 1, 0); 5714 + V4L2_CID_HUE, -128, 127, 1, 0); 5980 5715 if (!is_cx2583x(state)) { 5981 5716 default_volume = cx25840_read(client, 0x8d4); 5982 5717 /* ··· 5988 5723 /* Bottom out at -96 dB, v4l2 vol range 0x2e00-0x2fff */ 5989 5724 default_volume = 228; 5990 5725 cx25840_write(client, 0x8d4, 228); 5991 - } 5992 - else if (default_volume < 20) { 5726 + } else if (default_volume < 20) { 5993 5727 /* Top out at + 8 dB, v4l2 vol range 0xfe00-0xffff */ 5994 5728 default_volume = 20; 5995 5729 cx25840_write(client, 0x8d4, 20); ··· 5996 5732 default_volume = (((228 - default_volume) >> 1) + 23) << 9; 5997 5733 5998 5734 state->volume = v4l2_ctrl_new_std(&state->hdl, 5999 - &cx25840_audio_ctrl_ops, V4L2_CID_AUDIO_VOLUME, 6000 - 0, 65535, 65535 / 100, default_volume); 5735 + &cx25840_audio_ctrl_ops, 5736 + V4L2_CID_AUDIO_VOLUME, 5737 + 0, 65535, 65535 / 100, 5738 + default_volume); 6001 5739 state->mute = v4l2_ctrl_new_std(&state->hdl, 6002 - &cx25840_audio_ctrl_ops, V4L2_CID_AUDIO_MUTE, 6003 - 0, 1, 1, 0); 5740 + &cx25840_audio_ctrl_ops, 5741 + V4L2_CID_AUDIO_MUTE, 5742 + 0, 1, 1, 0); 6004 5743 v4l2_ctrl_new_std(&state->hdl, &cx25840_audio_ctrl_ops, 6005 - V4L2_CID_AUDIO_BALANCE, 6006 - 0, 65535, 65535 / 100, 32768); 5744 + V4L2_CID_AUDIO_BALANCE, 5745 + 0, 65535, 65535 / 100, 32768); 6007 5746 v4l2_ctrl_new_std(&state->hdl, &cx25840_audio_ctrl_ops, 6008 - V4L2_CID_AUDIO_BASS, 6009 - 0, 65535, 65535 / 100, 32768); 5747 + V4L2_CID_AUDIO_BASS, 5748 + 0, 65535, 65535 / 100, 32768); 6010 5749 v4l2_ctrl_new_std(&state->hdl, &cx25840_audio_ctrl_ops, 6011 - V4L2_CID_AUDIO_TREBLE, 6012 - 0, 65535, 65535 / 100, 32768); 5750 + V4L2_CID_AUDIO_TREBLE, 5751 + 0, 65535, 65535 / 100, 32768); 6013 5752 } 6014 5753 sd->ctrl_handler = &state->hdl; 6015 5754 if (state->hdl.error) {
+9 -6
drivers/media/i2c/cx25840/cx25840-core.h
··· 16 16 #ifndef _CX25840_CORE_H_ 17 17 #define _CX25840_CORE_H_ 18 18 19 - 20 19 #include <linux/videodev2.h> 21 20 #include <media/v4l2-device.h> 22 21 #include <media/v4l2-ctrls.h> ··· 99 100 enum cx25840_model id; 100 101 u32 rev; 101 102 int is_initialized; 102 - unsigned vbi_regs_offset; 103 + unsigned int vbi_regs_offset; 103 104 wait_queue_head_t fw_wait; 104 105 struct work_struct fw_work; 105 106 struct cx25840_ir_state *ir_state; ··· 165 166 int cx25840_write4(struct i2c_client *client, u16 addr, u32 value); 166 167 u8 cx25840_read(struct i2c_client *client, u16 addr); 167 168 u32 cx25840_read4(struct i2c_client *client, u16 addr); 168 - int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned mask, u8 value); 169 + int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned int mask, 170 + u8 value); 169 171 int cx25840_and_or4(struct i2c_client *client, u16 addr, u32 and_mask, 170 172 u32 or_value); 171 173 void cx25840_std_setup(struct i2c_client *client); ··· 185 185 /* ----------------------------------------------------------------------- */ 186 186 /* cx25850-vbi.c */ 187 187 int cx25840_s_raw_fmt(struct v4l2_subdev *sd, struct v4l2_vbi_format *fmt); 188 - int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt); 189 - int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt); 190 - int cx25840_decode_vbi_line(struct v4l2_subdev *sd, struct v4l2_decode_vbi_line *vbi); 188 + int cx25840_s_sliced_fmt(struct v4l2_subdev *sd, 189 + struct v4l2_sliced_vbi_format *fmt); 190 + int cx25840_g_sliced_fmt(struct v4l2_subdev *sd, 191 + struct v4l2_sliced_vbi_format *fmt); 192 + int cx25840_decode_vbi_line(struct v4l2_subdev *sd, 193 + struct v4l2_decode_vbi_line *vbi); 191 194 192 195 /* ----------------------------------------------------------------------- */ 193 196 /* cx25850-ir.c */
+19 -14
include/media/drv-intf/cx25840.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 + 2 3 /* 3 - cx25840.h - definition for cx25840/1/2/3 inputs 4 - 5 - Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl) 6 - 7 - */ 4 + * cx25840.h - definition for cx25840/1/2/3 inputs 5 + * 6 + * Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl) 7 + */ 8 8 9 9 #ifndef _CX25840_H_ 10 10 #define _CX25840_H_ ··· 38 38 CX25840_COMPOSITE7, 39 39 CX25840_COMPOSITE8, 40 40 41 - /* S-Video inputs consist of one luma input (In1-In8) ORed with one 42 - chroma input (In5-In8) */ 41 + /* 42 + * S-Video inputs consist of one luma input (In1-In8) ORed with one 43 + * chroma input (In5-In8) 44 + */ 43 45 CX25840_SVIDEO_LUMA1 = 0x10, 44 46 CX25840_SVIDEO_LUMA2 = 0x20, 45 47 CX25840_SVIDEO_LUMA3 = 0x30, ··· 245 243 CX23885_PAD_GPIO16, 246 244 }; 247 245 248 - /* pvr150_workaround activates a workaround for a hardware bug that is 249 - present in Hauppauge PVR-150 (and possibly PVR-500) cards that have 250 - certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The 251 - audio autodetect fails on some channels for these models and the workaround 252 - is to select the audio standard explicitly. Many thanks to Hauppauge for 253 - providing this information. 254 - This platform data only needs to be supplied by the ivtv driver. */ 246 + /* 247 + * pvr150_workaround activates a workaround for a hardware bug that is 248 + * present in Hauppauge PVR-150 (and possibly PVR-500) cards that have 249 + * certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The 250 + * audio autodetect fails on some channels for these models and the workaround 251 + * is to select the audio standard explicitly. Many thanks to Hauppauge for 252 + * providing this information. 253 + * 254 + * This platform data only needs to be supplied by the ivtv driver. 255 + */ 255 256 struct cx25840_platform_data { 256 257 int pvr150_workaround; 257 258 };