diff options
Diffstat (limited to 'drivers/media/video/tvaudio.c')
-rw-r--r-- | drivers/media/video/tvaudio.c | 81 |
1 files changed, 34 insertions, 47 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index fec620073aa3..9f6b6d855f00 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -47,19 +47,6 @@ MODULE_LICENSE("GPL"); | |||
47 | 47 | ||
48 | #define UNSET (-1U) | 48 | #define UNSET (-1U) |
49 | 49 | ||
50 | #define tvaudio_info(fmt, arg...) do { \ | ||
51 | printk(KERN_INFO "%s %d-%04x: " fmt, chip->c.driver->name, \ | ||
52 | i2c_adapter_id(chip->c.adapter), chip->c.addr , ## arg); } while (0) | ||
53 | #define tvaudio_warn(fmt, arg...) do { \ | ||
54 | printk(KERN_WARNING "%s %d-%04x: " fmt, chip->c.driver->name, \ | ||
55 | i2c_adapter_id(chip->c.adapter), chip->c.addr , ## arg); } while (0) | ||
56 | #define tvaudio_dbg(fmt, arg...) \ | ||
57 | do { \ | ||
58 | if (debug) \ | ||
59 | printk(KERN_INFO "%s debug %d-%04x: " fmt, chip->c.driver->name, \ | ||
60 | i2c_adapter_id(chip->c.adapter), chip->c.addr , ## arg); \ | ||
61 | } while (0) | ||
62 | |||
63 | /* ---------------------------------------------------------------------- */ | 50 | /* ---------------------------------------------------------------------- */ |
64 | /* our structs */ | 51 | /* our structs */ |
65 | 52 | ||
@@ -172,23 +159,23 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) | |||
172 | unsigned char buffer[2]; | 159 | unsigned char buffer[2]; |
173 | 160 | ||
174 | if (-1 == subaddr) { | 161 | if (-1 == subaddr) { |
175 | tvaudio_dbg("%s: chip_write: 0x%x\n", | 162 | v4l_dbg(1, &chip->c, "%s: chip_write: 0x%x\n", |
176 | chip->c.name, val); | 163 | chip->c.name, val); |
177 | chip->shadow.bytes[1] = val; | 164 | chip->shadow.bytes[1] = val; |
178 | buffer[0] = val; | 165 | buffer[0] = val; |
179 | if (1 != i2c_master_send(&chip->c,buffer,1)) { | 166 | if (1 != i2c_master_send(&chip->c,buffer,1)) { |
180 | tvaudio_warn("%s: I/O error (write 0x%x)\n", | 167 | v4l_warn(&chip->c, "%s: I/O error (write 0x%x)\n", |
181 | chip->c.name, val); | 168 | chip->c.name, val); |
182 | return -1; | 169 | return -1; |
183 | } | 170 | } |
184 | } else { | 171 | } else { |
185 | tvaudio_dbg("%s: chip_write: reg%d=0x%x\n", | 172 | v4l_dbg(1, &chip->c, "%s: chip_write: reg%d=0x%x\n", |
186 | chip->c.name, subaddr, val); | 173 | chip->c.name, subaddr, val); |
187 | chip->shadow.bytes[subaddr+1] = val; | 174 | chip->shadow.bytes[subaddr+1] = val; |
188 | buffer[0] = subaddr; | 175 | buffer[0] = subaddr; |
189 | buffer[1] = val; | 176 | buffer[1] = val; |
190 | if (2 != i2c_master_send(&chip->c,buffer,2)) { | 177 | if (2 != i2c_master_send(&chip->c,buffer,2)) { |
191 | tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n", | 178 | v4l_warn(&chip->c, "%s: I/O error (write reg%d=0x%x)\n", |
192 | chip->c.name, subaddr, val); | 179 | chip->c.name, subaddr, val); |
193 | return -1; | 180 | return -1; |
194 | } | 181 | } |
@@ -213,11 +200,11 @@ static int chip_read(struct CHIPSTATE *chip) | |||
213 | unsigned char buffer; | 200 | unsigned char buffer; |
214 | 201 | ||
215 | if (1 != i2c_master_recv(&chip->c,&buffer,1)) { | 202 | if (1 != i2c_master_recv(&chip->c,&buffer,1)) { |
216 | tvaudio_warn("%s: I/O error (read)\n", | 203 | v4l_warn(&chip->c, "%s: I/O error (read)\n", |
217 | chip->c.name); | 204 | chip->c.name); |
218 | return -1; | 205 | return -1; |
219 | } | 206 | } |
220 | tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name, buffer); | 207 | v4l_dbg(1, &chip->c, "%s: chip_read: 0x%x\n",chip->c.name, buffer); |
221 | return buffer; | 208 | return buffer; |
222 | } | 209 | } |
223 | 210 | ||
@@ -232,10 +219,10 @@ static int chip_read2(struct CHIPSTATE *chip, int subaddr) | |||
232 | write[0] = subaddr; | 219 | write[0] = subaddr; |
233 | 220 | ||
234 | if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { | 221 | if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { |
235 | tvaudio_warn("%s: I/O error (read2)\n", chip->c.name); | 222 | v4l_warn(&chip->c, "%s: I/O error (read2)\n", chip->c.name); |
236 | return -1; | 223 | return -1; |
237 | } | 224 | } |
238 | tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n", | 225 | v4l_dbg(1, &chip->c, "%s: chip_read2: reg%d=0x%x\n", |
239 | chip->c.name, subaddr,read[0]); | 226 | chip->c.name, subaddr,read[0]); |
240 | return read[0]; | 227 | return read[0]; |
241 | } | 228 | } |
@@ -248,7 +235,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) | |||
248 | return 0; | 235 | return 0; |
249 | 236 | ||
250 | /* update our shadow register set; print bytes if (debug > 0) */ | 237 | /* update our shadow register set; print bytes if (debug > 0) */ |
251 | tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:", | 238 | v4l_dbg(1, &chip->c, "%s: chip_cmd(%s): reg=%d, data:", |
252 | chip->c.name, name,cmd->bytes[0]); | 239 | chip->c.name, name,cmd->bytes[0]); |
253 | for (i = 1; i < cmd->count; i++) { | 240 | for (i = 1; i < cmd->count; i++) { |
254 | if (debug) | 241 | if (debug) |
@@ -260,7 +247,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) | |||
260 | 247 | ||
261 | /* send data to the chip */ | 248 | /* send data to the chip */ |
262 | if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { | 249 | if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { |
263 | tvaudio_warn("%s: I/O error (%s)\n", chip->c.name, name); | 250 | v4l_warn(&chip->c, "%s: I/O error (%s)\n", chip->c.name, name); |
264 | return -1; | 251 | return -1; |
265 | } | 252 | } |
266 | return 0; | 253 | return 0; |
@@ -287,7 +274,7 @@ static int chip_thread(void *data) | |||
287 | 274 | ||
288 | daemonize("%s", chip->c.name); | 275 | daemonize("%s", chip->c.name); |
289 | allow_signal(SIGTERM); | 276 | allow_signal(SIGTERM); |
290 | tvaudio_dbg("%s: thread started\n", chip->c.name); | 277 | v4l_dbg(1, &chip->c, "%s: thread started\n", chip->c.name); |
291 | 278 | ||
292 | for (;;) { | 279 | for (;;) { |
293 | add_wait_queue(&chip->wq, &wait); | 280 | add_wait_queue(&chip->wq, &wait); |
@@ -299,7 +286,7 @@ static int chip_thread(void *data) | |||
299 | try_to_freeze(); | 286 | try_to_freeze(); |
300 | if (chip->done || signal_pending(current)) | 287 | if (chip->done || signal_pending(current)) |
301 | break; | 288 | break; |
302 | tvaudio_dbg("%s: thread wakeup\n", chip->c.name); | 289 | v4l_dbg(1, &chip->c, "%s: thread wakeup\n", chip->c.name); |
303 | 290 | ||
304 | /* don't do anything for radio or if mode != auto */ | 291 | /* don't do anything for radio or if mode != auto */ |
305 | if (chip->radio || chip->mode != 0) | 292 | if (chip->radio || chip->mode != 0) |
@@ -312,7 +299,7 @@ static int chip_thread(void *data) | |||
312 | mod_timer(&chip->wt, jiffies+2*HZ); | 299 | mod_timer(&chip->wt, jiffies+2*HZ); |
313 | } | 300 | } |
314 | 301 | ||
315 | tvaudio_dbg("%s: thread exiting\n", chip->c.name); | 302 | v4l_dbg(1, &chip->c, "%s: thread exiting\n", chip->c.name); |
316 | complete_and_exit(&chip->texit, 0); | 303 | complete_and_exit(&chip->texit, 0); |
317 | return 0; | 304 | return 0; |
318 | } | 305 | } |
@@ -325,7 +312,7 @@ static void generic_checkmode(struct CHIPSTATE *chip) | |||
325 | if (mode == chip->prevmode) | 312 | if (mode == chip->prevmode) |
326 | return; | 313 | return; |
327 | 314 | ||
328 | tvaudio_dbg("%s: thread checkmode\n", chip->c.name); | 315 | v4l_dbg(1, &chip->c, "%s: thread checkmode\n", chip->c.name); |
329 | chip->prevmode = mode; | 316 | chip->prevmode = mode; |
330 | 317 | ||
331 | if (mode & VIDEO_SOUND_STEREO) | 318 | if (mode & VIDEO_SOUND_STEREO) |
@@ -372,7 +359,7 @@ static int tda9840_getmode(struct CHIPSTATE *chip) | |||
372 | if (val & TDA9840_ST_STEREO) | 359 | if (val & TDA9840_ST_STEREO) |
373 | mode |= VIDEO_SOUND_STEREO; | 360 | mode |= VIDEO_SOUND_STEREO; |
374 | 361 | ||
375 | tvaudio_dbg ("tda9840_getmode(): raw chip read: %d, return: %d\n", | 362 | v4l_dbg(1, &chip->c, "tda9840_getmode(): raw chip read: %d, return: %d\n", |
376 | val, mode); | 363 | val, mode); |
377 | return mode; | 364 | return mode; |
378 | } | 365 | } |
@@ -668,7 +655,7 @@ static int tda9873_getmode(struct CHIPSTATE *chip) | |||
668 | mode |= VIDEO_SOUND_STEREO; | 655 | mode |= VIDEO_SOUND_STEREO; |
669 | if (val & TDA9873_DUAL) | 656 | if (val & TDA9873_DUAL) |
670 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 657 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; |
671 | tvaudio_dbg ("tda9873_getmode(): raw chip read: %d, return: %d\n", | 658 | v4l_dbg(1, &chip->c, "tda9873_getmode(): raw chip read: %d, return: %d\n", |
672 | val, mode); | 659 | val, mode); |
673 | return mode; | 660 | return mode; |
674 | } | 661 | } |
@@ -679,12 +666,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) | |||
679 | /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ | 666 | /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ |
680 | 667 | ||
681 | if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { | 668 | if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { |
682 | tvaudio_dbg("tda9873_setmode(): external input\n"); | 669 | v4l_dbg(1, &chip->c, "tda9873_setmode(): external input\n"); |
683 | return; | 670 | return; |
684 | } | 671 | } |
685 | 672 | ||
686 | tvaudio_dbg("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); | 673 | v4l_dbg(1, &chip->c, "tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); |
687 | tvaudio_dbg("tda9873_setmode(): sw_data = %d\n", sw_data); | 674 | v4l_dbg(1, &chip->c, "tda9873_setmode(): sw_data = %d\n", sw_data); |
688 | 675 | ||
689 | switch (mode) { | 676 | switch (mode) { |
690 | case VIDEO_SOUND_MONO: | 677 | case VIDEO_SOUND_MONO: |
@@ -705,7 +692,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) | |||
705 | } | 692 | } |
706 | 693 | ||
707 | chip_write(chip, TDA9873_SW, sw_data); | 694 | chip_write(chip, TDA9873_SW, sw_data); |
708 | tvaudio_dbg("tda9873_setmode(): req. mode %d; chip_write: %d\n", | 695 | v4l_dbg(1, &chip->c, "tda9873_setmode(): req. mode %d; chip_write: %d\n", |
709 | mode, sw_data); | 696 | mode, sw_data); |
710 | } | 697 | } |
711 | 698 | ||
@@ -844,7 +831,7 @@ static int tda9874a_setup(struct CHIPSTATE *chip) | |||
844 | chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); | 831 | chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); |
845 | chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ | 832 | chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ |
846 | } | 833 | } |
847 | tvaudio_dbg("tda9874a_setup(): %s [0x%02X].\n", | 834 | v4l_dbg(1, &chip->c, "tda9874a_setup(): %s [0x%02X].\n", |
848 | tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); | 835 | tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); |
849 | return 1; | 836 | return 1; |
850 | } | 837 | } |
@@ -887,7 +874,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) | |||
887 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 874 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; |
888 | } | 875 | } |
889 | 876 | ||
890 | tvaudio_dbg("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", | 877 | v4l_dbg(1, &chip->c, "tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", |
891 | dsr, nsr, necr, mode); | 878 | dsr, nsr, necr, mode); |
892 | return mode; | 879 | return mode; |
893 | } | 880 | } |
@@ -933,7 +920,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
933 | chip_write(chip, TDA9874A_AOSR, aosr); | 920 | chip_write(chip, TDA9874A_AOSR, aosr); |
934 | chip_write(chip, TDA9874A_MDACOSR, mdacosr); | 921 | chip_write(chip, TDA9874A_MDACOSR, mdacosr); |
935 | 922 | ||
936 | tvaudio_dbg("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", | 923 | v4l_dbg(1, &chip->c, "tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", |
937 | mode, aosr, mdacosr); | 924 | mode, aosr, mdacosr); |
938 | 925 | ||
939 | } else { /* dic == 0x07 */ | 926 | } else { /* dic == 0x07 */ |
@@ -968,7 +955,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
968 | chip_write(chip, TDA9874A_FMMR, fmmr); | 955 | chip_write(chip, TDA9874A_FMMR, fmmr); |
969 | chip_write(chip, TDA9874A_AOSR, aosr); | 956 | chip_write(chip, TDA9874A_AOSR, aosr); |
970 | 957 | ||
971 | tvaudio_dbg("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", | 958 | v4l_dbg(1, &chip->c, "tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", |
972 | mode, fmmr, aosr); | 959 | mode, fmmr, aosr); |
973 | } | 960 | } |
974 | } | 961 | } |
@@ -982,10 +969,10 @@ static int tda9874a_checkit(struct CHIPSTATE *chip) | |||
982 | if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) | 969 | if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) |
983 | return 0; | 970 | return 0; |
984 | 971 | ||
985 | tvaudio_dbg("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); | 972 | v4l_dbg(1, &chip->c, "tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); |
986 | 973 | ||
987 | if((dic == 0x11)||(dic == 0x07)) { | 974 | if((dic == 0x11)||(dic == 0x07)) { |
988 | tvaudio_info("found tda9874%s.\n", (dic == 0x11) ? "a":"h"); | 975 | v4l_info(&chip->c, "found tda9874%s.\n", (dic == 0x11) ? "a":"h"); |
989 | tda9874a_dic = dic; /* remember device id. */ | 976 | tda9874a_dic = dic; /* remember device id. */ |
990 | return 1; | 977 | return 1; |
991 | } | 978 | } |
@@ -1197,7 +1184,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip) | |||
1197 | }else if (!(val & TA8874Z_B0)){ | 1184 | }else if (!(val & TA8874Z_B0)){ |
1198 | mode |= VIDEO_SOUND_STEREO; | 1185 | mode |= VIDEO_SOUND_STEREO; |
1199 | } | 1186 | } |
1200 | /* tvaudio_dbg ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ | 1187 | /* v4l_dbg(1, &chip->c, "ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ |
1201 | return mode; | 1188 | return mode; |
1202 | } | 1189 | } |
1203 | 1190 | ||
@@ -1210,7 +1197,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) | |||
1210 | { | 1197 | { |
1211 | int update = 1; | 1198 | int update = 1; |
1212 | audiocmd *t = NULL; | 1199 | audiocmd *t = NULL; |
1213 | tvaudio_dbg("ta8874z_setmode(): mode: 0x%02x\n", mode); | 1200 | v4l_dbg(1, &chip->c, "ta8874z_setmode(): mode: 0x%02x\n", mode); |
1214 | 1201 | ||
1215 | switch(mode){ | 1202 | switch(mode){ |
1216 | case VIDEO_SOUND_MONO: | 1203 | case VIDEO_SOUND_MONO: |
@@ -1491,7 +1478,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1491 | i2c_set_clientdata(&chip->c, chip); | 1478 | i2c_set_clientdata(&chip->c, chip); |
1492 | 1479 | ||
1493 | /* find description for the chip */ | 1480 | /* find description for the chip */ |
1494 | tvaudio_dbg("chip found @ 0x%x\n", addr<<1); | 1481 | v4l_dbg(1, &chip->c, "chip found @ 0x%x\n", addr<<1); |
1495 | for (desc = chiplist; desc->name != NULL; desc++) { | 1482 | for (desc = chiplist; desc->name != NULL; desc++) { |
1496 | if (0 == *(desc->insmodopt)) | 1483 | if (0 == *(desc->insmodopt)) |
1497 | continue; | 1484 | continue; |
@@ -1503,12 +1490,12 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1503 | break; | 1490 | break; |
1504 | } | 1491 | } |
1505 | if (desc->name == NULL) { | 1492 | if (desc->name == NULL) { |
1506 | tvaudio_dbg("no matching chip description found\n"); | 1493 | v4l_dbg(1, &chip->c, "no matching chip description found\n"); |
1507 | return -EIO; | 1494 | return -EIO; |
1508 | } | 1495 | } |
1509 | tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); | 1496 | v4l_info(&chip->c, "%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); |
1510 | if (desc->flags) { | 1497 | if (desc->flags) { |
1511 | tvaudio_dbg("matches:%s%s%s.\n", | 1498 | v4l_dbg(1, &chip->c, "matches:%s%s%s.\n", |
1512 | (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", | 1499 | (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", |
1513 | (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", | 1500 | (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", |
1514 | (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); | 1501 | (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); |
@@ -1551,7 +1538,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1551 | init_completion(&chip->texit); | 1538 | init_completion(&chip->texit); |
1552 | chip->tpid = kernel_thread(chip_thread,(void *)chip,0); | 1539 | chip->tpid = kernel_thread(chip_thread,(void *)chip,0); |
1553 | if (chip->tpid < 0) | 1540 | if (chip->tpid < 0) |
1554 | tvaudio_warn("%s: kernel_thread() failed\n", | 1541 | v4l_warn(&chip->c, "%s: kernel_thread() failed\n", |
1555 | chip->c.name); | 1542 | chip->c.name); |
1556 | wake_up_interruptible(&chip->wq); | 1543 | wake_up_interruptible(&chip->wq); |
1557 | } | 1544 | } |
@@ -1596,7 +1583,7 @@ static int chip_command(struct i2c_client *client, | |||
1596 | struct CHIPSTATE *chip = i2c_get_clientdata(client); | 1583 | struct CHIPSTATE *chip = i2c_get_clientdata(client); |
1597 | struct CHIPDESC *desc = chiplist + chip->type; | 1584 | struct CHIPDESC *desc = chiplist + chip->type; |
1598 | 1585 | ||
1599 | tvaudio_dbg("%s: chip_command 0x%x\n", chip->c.name, cmd); | 1586 | v4l_dbg(1, &chip->c, "%s: chip_command 0x%x\n", chip->c.name, cmd); |
1600 | 1587 | ||
1601 | switch (cmd) { | 1588 | switch (cmd) { |
1602 | case AUDC_SET_INPUT: | 1589 | case AUDC_SET_INPUT: |