diff options
Diffstat (limited to 'drivers/media/video/tvaudio.c')
-rw-r--r-- | drivers/media/video/tvaudio.c | 177 |
1 files changed, 110 insertions, 67 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 0292c5abf14a..b582943a0d3e 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/smp_lock.h> | 31 | #include <linux/smp_lock.h> |
32 | 32 | ||
33 | #include <media/audiochip.h> | 33 | #include <media/audiochip.h> |
34 | #include <media/v4l2-common.h> | ||
34 | 35 | ||
35 | #include "tvaudio.h" | 36 | #include "tvaudio.h" |
36 | 37 | ||
@@ -46,17 +47,6 @@ MODULE_LICENSE("GPL"); | |||
46 | 47 | ||
47 | #define UNSET (-1U) | 48 | #define UNSET (-1U) |
48 | 49 | ||
49 | #define tvaudio_info(fmt, arg...) do {\ | ||
50 | printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ | ||
51 | chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) | ||
52 | #define tvaudio_warn(fmt, arg...) do {\ | ||
53 | printk(KERN_WARNING "tvaudio %d-%04x: " fmt, \ | ||
54 | chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) | ||
55 | #define tvaudio_dbg(fmt, arg...) do {\ | ||
56 | if (debug) \ | ||
57 | printk(KERN_INFO "tvaudio %d-%04x: " fmt, \ | ||
58 | chip->c.adapter->nr, chip->c.addr , ##arg); } while (0) | ||
59 | |||
60 | /* ---------------------------------------------------------------------- */ | 50 | /* ---------------------------------------------------------------------- */ |
61 | /* our structs */ | 51 | /* our structs */ |
62 | 52 | ||
@@ -131,7 +121,7 @@ struct CHIPSTATE { | |||
131 | /* current settings */ | 121 | /* current settings */ |
132 | __u16 left,right,treble,bass,mode; | 122 | __u16 left,right,treble,bass,mode; |
133 | int prevmode; | 123 | int prevmode; |
134 | int norm; | 124 | int radio; |
135 | 125 | ||
136 | /* thread */ | 126 | /* thread */ |
137 | pid_t tpid; | 127 | pid_t tpid; |
@@ -142,8 +132,6 @@ struct CHIPSTATE { | |||
142 | int watch_stereo; | 132 | int watch_stereo; |
143 | }; | 133 | }; |
144 | 134 | ||
145 | #define VIDEO_MODE_RADIO 16 /* norm magic for radio mode */ | ||
146 | |||
147 | /* ---------------------------------------------------------------------- */ | 135 | /* ---------------------------------------------------------------------- */ |
148 | /* i2c addresses */ | 136 | /* i2c addresses */ |
149 | 137 | ||
@@ -171,23 +159,23 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val) | |||
171 | unsigned char buffer[2]; | 159 | unsigned char buffer[2]; |
172 | 160 | ||
173 | if (-1 == subaddr) { | 161 | if (-1 == subaddr) { |
174 | tvaudio_dbg("%s: chip_write: 0x%x\n", | 162 | v4l_dbg(1, &chip->c, "%s: chip_write: 0x%x\n", |
175 | chip->c.name, val); | 163 | chip->c.name, val); |
176 | chip->shadow.bytes[1] = val; | 164 | chip->shadow.bytes[1] = val; |
177 | buffer[0] = val; | 165 | buffer[0] = val; |
178 | if (1 != i2c_master_send(&chip->c,buffer,1)) { | 166 | if (1 != i2c_master_send(&chip->c,buffer,1)) { |
179 | tvaudio_warn("%s: I/O error (write 0x%x)\n", | 167 | v4l_warn(&chip->c, "%s: I/O error (write 0x%x)\n", |
180 | chip->c.name, val); | 168 | chip->c.name, val); |
181 | return -1; | 169 | return -1; |
182 | } | 170 | } |
183 | } else { | 171 | } else { |
184 | tvaudio_dbg("%s: chip_write: reg%d=0x%x\n", | 172 | v4l_dbg(1, &chip->c, "%s: chip_write: reg%d=0x%x\n", |
185 | chip->c.name, subaddr, val); | 173 | chip->c.name, subaddr, val); |
186 | chip->shadow.bytes[subaddr+1] = val; | 174 | chip->shadow.bytes[subaddr+1] = val; |
187 | buffer[0] = subaddr; | 175 | buffer[0] = subaddr; |
188 | buffer[1] = val; | 176 | buffer[1] = val; |
189 | if (2 != i2c_master_send(&chip->c,buffer,2)) { | 177 | if (2 != i2c_master_send(&chip->c,buffer,2)) { |
190 | 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", |
191 | chip->c.name, subaddr, val); | 179 | chip->c.name, subaddr, val); |
192 | return -1; | 180 | return -1; |
193 | } | 181 | } |
@@ -212,11 +200,11 @@ static int chip_read(struct CHIPSTATE *chip) | |||
212 | unsigned char buffer; | 200 | unsigned char buffer; |
213 | 201 | ||
214 | if (1 != i2c_master_recv(&chip->c,&buffer,1)) { | 202 | if (1 != i2c_master_recv(&chip->c,&buffer,1)) { |
215 | tvaudio_warn("%s: I/O error (read)\n", | 203 | v4l_warn(&chip->c, "%s: I/O error (read)\n", |
216 | chip->c.name); | 204 | chip->c.name); |
217 | return -1; | 205 | return -1; |
218 | } | 206 | } |
219 | 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); |
220 | return buffer; | 208 | return buffer; |
221 | } | 209 | } |
222 | 210 | ||
@@ -231,10 +219,10 @@ static int chip_read2(struct CHIPSTATE *chip, int subaddr) | |||
231 | write[0] = subaddr; | 219 | write[0] = subaddr; |
232 | 220 | ||
233 | if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { | 221 | if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { |
234 | 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); |
235 | return -1; | 223 | return -1; |
236 | } | 224 | } |
237 | tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n", | 225 | v4l_dbg(1, &chip->c, "%s: chip_read2: reg%d=0x%x\n", |
238 | chip->c.name, subaddr,read[0]); | 226 | chip->c.name, subaddr,read[0]); |
239 | return read[0]; | 227 | return read[0]; |
240 | } | 228 | } |
@@ -247,7 +235,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) | |||
247 | return 0; | 235 | return 0; |
248 | 236 | ||
249 | /* update our shadow register set; print bytes if (debug > 0) */ | 237 | /* update our shadow register set; print bytes if (debug > 0) */ |
250 | tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:", | 238 | v4l_dbg(1, &chip->c, "%s: chip_cmd(%s): reg=%d, data:", |
251 | chip->c.name, name,cmd->bytes[0]); | 239 | chip->c.name, name,cmd->bytes[0]); |
252 | for (i = 1; i < cmd->count; i++) { | 240 | for (i = 1; i < cmd->count; i++) { |
253 | if (debug) | 241 | if (debug) |
@@ -259,7 +247,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd) | |||
259 | 247 | ||
260 | /* send data to the chip */ | 248 | /* send data to the chip */ |
261 | 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)) { |
262 | 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); |
263 | return -1; | 251 | return -1; |
264 | } | 252 | } |
265 | return 0; | 253 | return 0; |
@@ -286,7 +274,7 @@ static int chip_thread(void *data) | |||
286 | 274 | ||
287 | daemonize("%s", chip->c.name); | 275 | daemonize("%s", chip->c.name); |
288 | allow_signal(SIGTERM); | 276 | allow_signal(SIGTERM); |
289 | tvaudio_dbg("%s: thread started\n", chip->c.name); | 277 | v4l_dbg(1, &chip->c, "%s: thread started\n", chip->c.name); |
290 | 278 | ||
291 | for (;;) { | 279 | for (;;) { |
292 | add_wait_queue(&chip->wq, &wait); | 280 | add_wait_queue(&chip->wq, &wait); |
@@ -298,10 +286,10 @@ static int chip_thread(void *data) | |||
298 | try_to_freeze(); | 286 | try_to_freeze(); |
299 | if (chip->done || signal_pending(current)) | 287 | if (chip->done || signal_pending(current)) |
300 | break; | 288 | break; |
301 | tvaudio_dbg("%s: thread wakeup\n", chip->c.name); | 289 | v4l_dbg(1, &chip->c, "%s: thread wakeup\n", chip->c.name); |
302 | 290 | ||
303 | /* don't do anything for radio or if mode != auto */ | 291 | /* don't do anything for radio or if mode != auto */ |
304 | if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) | 292 | if (chip->radio || chip->mode != 0) |
305 | continue; | 293 | continue; |
306 | 294 | ||
307 | /* have a look what's going on */ | 295 | /* have a look what's going on */ |
@@ -311,7 +299,7 @@ static int chip_thread(void *data) | |||
311 | mod_timer(&chip->wt, jiffies+2*HZ); | 299 | mod_timer(&chip->wt, jiffies+2*HZ); |
312 | } | 300 | } |
313 | 301 | ||
314 | tvaudio_dbg("%s: thread exiting\n", chip->c.name); | 302 | v4l_dbg(1, &chip->c, "%s: thread exiting\n", chip->c.name); |
315 | complete_and_exit(&chip->texit, 0); | 303 | complete_and_exit(&chip->texit, 0); |
316 | return 0; | 304 | return 0; |
317 | } | 305 | } |
@@ -324,7 +312,7 @@ static void generic_checkmode(struct CHIPSTATE *chip) | |||
324 | if (mode == chip->prevmode) | 312 | if (mode == chip->prevmode) |
325 | return; | 313 | return; |
326 | 314 | ||
327 | tvaudio_dbg("%s: thread checkmode\n", chip->c.name); | 315 | v4l_dbg(1, &chip->c, "%s: thread checkmode\n", chip->c.name); |
328 | chip->prevmode = mode; | 316 | chip->prevmode = mode; |
329 | 317 | ||
330 | if (mode & VIDEO_SOUND_STEREO) | 318 | if (mode & VIDEO_SOUND_STEREO) |
@@ -371,7 +359,7 @@ static int tda9840_getmode(struct CHIPSTATE *chip) | |||
371 | if (val & TDA9840_ST_STEREO) | 359 | if (val & TDA9840_ST_STEREO) |
372 | mode |= VIDEO_SOUND_STEREO; | 360 | mode |= VIDEO_SOUND_STEREO; |
373 | 361 | ||
374 | 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", |
375 | val, mode); | 363 | val, mode); |
376 | return mode; | 364 | return mode; |
377 | } | 365 | } |
@@ -667,7 +655,7 @@ static int tda9873_getmode(struct CHIPSTATE *chip) | |||
667 | mode |= VIDEO_SOUND_STEREO; | 655 | mode |= VIDEO_SOUND_STEREO; |
668 | if (val & TDA9873_DUAL) | 656 | if (val & TDA9873_DUAL) |
669 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 657 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; |
670 | 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", |
671 | val, mode); | 659 | val, mode); |
672 | return mode; | 660 | return mode; |
673 | } | 661 | } |
@@ -678,12 +666,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) | |||
678 | /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ | 666 | /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ |
679 | 667 | ||
680 | if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { | 668 | if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { |
681 | tvaudio_dbg("tda9873_setmode(): external input\n"); | 669 | v4l_dbg(1, &chip->c, "tda9873_setmode(): external input\n"); |
682 | return; | 670 | return; |
683 | } | 671 | } |
684 | 672 | ||
685 | 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]); |
686 | tvaudio_dbg("tda9873_setmode(): sw_data = %d\n", sw_data); | 674 | v4l_dbg(1, &chip->c, "tda9873_setmode(): sw_data = %d\n", sw_data); |
687 | 675 | ||
688 | switch (mode) { | 676 | switch (mode) { |
689 | case VIDEO_SOUND_MONO: | 677 | case VIDEO_SOUND_MONO: |
@@ -704,7 +692,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) | |||
704 | } | 692 | } |
705 | 693 | ||
706 | chip_write(chip, TDA9873_SW, sw_data); | 694 | chip_write(chip, TDA9873_SW, sw_data); |
707 | 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", |
708 | mode, sw_data); | 696 | mode, sw_data); |
709 | } | 697 | } |
710 | 698 | ||
@@ -843,7 +831,7 @@ static int tda9874a_setup(struct CHIPSTATE *chip) | |||
843 | chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); | 831 | chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); |
844 | chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ | 832 | chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */ |
845 | } | 833 | } |
846 | tvaudio_dbg("tda9874a_setup(): %s [0x%02X].\n", | 834 | v4l_dbg(1, &chip->c, "tda9874a_setup(): %s [0x%02X].\n", |
847 | tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); | 835 | tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); |
848 | return 1; | 836 | return 1; |
849 | } | 837 | } |
@@ -886,7 +874,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) | |||
886 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 874 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; |
887 | } | 875 | } |
888 | 876 | ||
889 | 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", |
890 | dsr, nsr, necr, mode); | 878 | dsr, nsr, necr, mode); |
891 | return mode; | 879 | return mode; |
892 | } | 880 | } |
@@ -932,7 +920,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
932 | chip_write(chip, TDA9874A_AOSR, aosr); | 920 | chip_write(chip, TDA9874A_AOSR, aosr); |
933 | chip_write(chip, TDA9874A_MDACOSR, mdacosr); | 921 | chip_write(chip, TDA9874A_MDACOSR, mdacosr); |
934 | 922 | ||
935 | 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", |
936 | mode, aosr, mdacosr); | 924 | mode, aosr, mdacosr); |
937 | 925 | ||
938 | } else { /* dic == 0x07 */ | 926 | } else { /* dic == 0x07 */ |
@@ -967,7 +955,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
967 | chip_write(chip, TDA9874A_FMMR, fmmr); | 955 | chip_write(chip, TDA9874A_FMMR, fmmr); |
968 | chip_write(chip, TDA9874A_AOSR, aosr); | 956 | chip_write(chip, TDA9874A_AOSR, aosr); |
969 | 957 | ||
970 | 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", |
971 | mode, fmmr, aosr); | 959 | mode, fmmr, aosr); |
972 | } | 960 | } |
973 | } | 961 | } |
@@ -981,10 +969,10 @@ static int tda9874a_checkit(struct CHIPSTATE *chip) | |||
981 | if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) | 969 | if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) |
982 | return 0; | 970 | return 0; |
983 | 971 | ||
984 | 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); |
985 | 973 | ||
986 | if((dic == 0x11)||(dic == 0x07)) { | 974 | if((dic == 0x11)||(dic == 0x07)) { |
987 | tvaudio_info("found tda9874%s.\n", (dic == 0x11) ? "a":"h"); | 975 | v4l_info(&chip->c, "found tda9874%s.\n", (dic == 0x11) ? "a":"h"); |
988 | tda9874a_dic = dic; /* remember device id. */ | 976 | tda9874a_dic = dic; /* remember device id. */ |
989 | return 1; | 977 | return 1; |
990 | } | 978 | } |
@@ -1196,7 +1184,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip) | |||
1196 | }else if (!(val & TA8874Z_B0)){ | 1184 | }else if (!(val & TA8874Z_B0)){ |
1197 | mode |= VIDEO_SOUND_STEREO; | 1185 | mode |= VIDEO_SOUND_STEREO; |
1198 | } | 1186 | } |
1199 | /* 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); */ |
1200 | return mode; | 1188 | return mode; |
1201 | } | 1189 | } |
1202 | 1190 | ||
@@ -1209,7 +1197,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) | |||
1209 | { | 1197 | { |
1210 | int update = 1; | 1198 | int update = 1; |
1211 | audiocmd *t = NULL; | 1199 | audiocmd *t = NULL; |
1212 | tvaudio_dbg("ta8874z_setmode(): mode: 0x%02x\n", mode); | 1200 | v4l_dbg(1, &chip->c, "ta8874z_setmode(): mode: 0x%02x\n", mode); |
1213 | 1201 | ||
1214 | switch(mode){ | 1202 | switch(mode){ |
1215 | case VIDEO_SOUND_MONO: | 1203 | case VIDEO_SOUND_MONO: |
@@ -1490,7 +1478,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1490 | i2c_set_clientdata(&chip->c, chip); | 1478 | i2c_set_clientdata(&chip->c, chip); |
1491 | 1479 | ||
1492 | /* find description for the chip */ | 1480 | /* find description for the chip */ |
1493 | tvaudio_dbg("chip found @ 0x%x\n", addr<<1); | 1481 | v4l_dbg(1, &chip->c, "chip found @ 0x%x\n", addr<<1); |
1494 | for (desc = chiplist; desc->name != NULL; desc++) { | 1482 | for (desc = chiplist; desc->name != NULL; desc++) { |
1495 | if (0 == *(desc->insmodopt)) | 1483 | if (0 == *(desc->insmodopt)) |
1496 | continue; | 1484 | continue; |
@@ -1502,12 +1490,12 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1502 | break; | 1490 | break; |
1503 | } | 1491 | } |
1504 | if (desc->name == NULL) { | 1492 | if (desc->name == NULL) { |
1505 | tvaudio_dbg("no matching chip description found\n"); | 1493 | v4l_dbg(1, &chip->c, "no matching chip description found\n"); |
1506 | return -EIO; | 1494 | return -EIO; |
1507 | } | 1495 | } |
1508 | 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); |
1509 | if (desc->flags) { | 1497 | if (desc->flags) { |
1510 | tvaudio_dbg("matches:%s%s%s.\n", | 1498 | v4l_dbg(1, &chip->c, "matches:%s%s%s.\n", |
1511 | (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", | 1499 | (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", |
1512 | (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", | 1500 | (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", |
1513 | (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); | 1501 | (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); |
@@ -1550,7 +1538,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) | |||
1550 | init_completion(&chip->texit); | 1538 | init_completion(&chip->texit); |
1551 | chip->tpid = kernel_thread(chip_thread,(void *)chip,0); | 1539 | chip->tpid = kernel_thread(chip_thread,(void *)chip,0); |
1552 | if (chip->tpid < 0) | 1540 | if (chip->tpid < 0) |
1553 | tvaudio_warn("%s: kernel_thread() failed\n", | 1541 | v4l_warn(&chip->c, "%s: kernel_thread() failed\n", |
1554 | chip->c.name); | 1542 | chip->c.name); |
1555 | wake_up_interruptible(&chip->wq); | 1543 | wake_up_interruptible(&chip->wq); |
1556 | } | 1544 | } |
@@ -1563,17 +1551,8 @@ static int chip_probe(struct i2c_adapter *adap) | |||
1563 | because dedicated drivers are used */ | 1551 | because dedicated drivers are used */ |
1564 | if ((adap->id == I2C_HW_SAA7146)) | 1552 | if ((adap->id == I2C_HW_SAA7146)) |
1565 | return 0; | 1553 | return 0; |
1566 | #ifdef I2C_CLASS_TV_ANALOG | ||
1567 | if (adap->class & I2C_CLASS_TV_ANALOG) | 1554 | if (adap->class & I2C_CLASS_TV_ANALOG) |
1568 | return i2c_probe(adap, &addr_data, chip_attach); | 1555 | return i2c_probe(adap, &addr_data, chip_attach); |
1569 | #else | ||
1570 | switch (adap->id) { | ||
1571 | case I2C_HW_B_BT848: | ||
1572 | case I2C_HW_B_RIVA: | ||
1573 | case I2C_HW_SAA7134: | ||
1574 | return i2c_probe(adap, &addr_data, chip_attach); | ||
1575 | } | ||
1576 | #endif | ||
1577 | return 0; | 1556 | return 0; |
1578 | } | 1557 | } |
1579 | 1558 | ||
@@ -1604,7 +1583,7 @@ static int chip_command(struct i2c_client *client, | |||
1604 | struct CHIPSTATE *chip = i2c_get_clientdata(client); | 1583 | struct CHIPSTATE *chip = i2c_get_clientdata(client); |
1605 | struct CHIPDESC *desc = chiplist + chip->type; | 1584 | struct CHIPDESC *desc = chiplist + chip->type; |
1606 | 1585 | ||
1607 | 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); |
1608 | 1587 | ||
1609 | switch (cmd) { | 1588 | switch (cmd) { |
1610 | case AUDC_SET_INPUT: | 1589 | case AUDC_SET_INPUT: |
@@ -1617,7 +1596,7 @@ static int chip_command(struct i2c_client *client, | |||
1617 | break; | 1596 | break; |
1618 | 1597 | ||
1619 | case AUDC_SET_RADIO: | 1598 | case AUDC_SET_RADIO: |
1620 | chip->norm = VIDEO_MODE_RADIO; | 1599 | chip->radio = 1; |
1621 | chip->watch_stereo = 0; | 1600 | chip->watch_stereo = 0; |
1622 | /* del_timer(&chip->wt); */ | 1601 | /* del_timer(&chip->wt); */ |
1623 | break; | 1602 | break; |
@@ -1643,7 +1622,7 @@ static int chip_command(struct i2c_client *client, | |||
1643 | va->bass = chip->bass; | 1622 | va->bass = chip->bass; |
1644 | va->treble = chip->treble; | 1623 | va->treble = chip->treble; |
1645 | } | 1624 | } |
1646 | if (chip->norm != VIDEO_MODE_RADIO) { | 1625 | if (!chip->radio) { |
1647 | if (desc->getmode) | 1626 | if (desc->getmode) |
1648 | va->mode = desc->getmode(chip); | 1627 | va->mode = desc->getmode(chip); |
1649 | else | 1628 | else |
@@ -1678,15 +1657,80 @@ static int chip_command(struct i2c_client *client, | |||
1678 | } | 1657 | } |
1679 | break; | 1658 | break; |
1680 | } | 1659 | } |
1681 | case VIDIOCSCHAN: | 1660 | |
1661 | case VIDIOC_S_TUNER: | ||
1682 | { | 1662 | { |
1683 | struct video_channel *vc = arg; | 1663 | struct v4l2_tuner *vt = arg; |
1664 | int mode = 0; | ||
1684 | 1665 | ||
1685 | chip->norm = vc->norm; | 1666 | switch (vt->audmode) { |
1667 | case V4L2_TUNER_MODE_MONO: | ||
1668 | mode = VIDEO_SOUND_MONO; | ||
1669 | break; | ||
1670 | case V4L2_TUNER_MODE_STEREO: | ||
1671 | mode = VIDEO_SOUND_STEREO; | ||
1672 | break; | ||
1673 | case V4L2_TUNER_MODE_LANG1: | ||
1674 | mode = VIDEO_SOUND_LANG1; | ||
1675 | break; | ||
1676 | case V4L2_TUNER_MODE_LANG2: | ||
1677 | mode = VIDEO_SOUND_LANG2; | ||
1678 | break; | ||
1679 | default: | ||
1680 | break; | ||
1681 | } | ||
1682 | |||
1683 | if (desc->setmode && mode) { | ||
1684 | chip->watch_stereo = 0; | ||
1685 | /* del_timer(&chip->wt); */ | ||
1686 | chip->mode = mode; | ||
1687 | desc->setmode(chip, mode); | ||
1688 | } | ||
1686 | break; | 1689 | break; |
1687 | } | 1690 | } |
1688 | case VIDIOCSFREQ: | 1691 | |
1692 | case VIDIOC_G_TUNER: | ||
1689 | { | 1693 | { |
1694 | struct v4l2_tuner *vt = arg; | ||
1695 | int mode = VIDEO_SOUND_MONO; | ||
1696 | |||
1697 | if (chip->radio) | ||
1698 | break; | ||
1699 | vt->audmode = 0; | ||
1700 | vt->rxsubchans = 0; | ||
1701 | vt->capability = V4L2_TUNER_CAP_STEREO | | ||
1702 | V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; | ||
1703 | |||
1704 | if (desc->getmode) | ||
1705 | mode = desc->getmode(chip); | ||
1706 | |||
1707 | if (mode & VIDEO_SOUND_MONO) | ||
1708 | vt->rxsubchans |= V4L2_TUNER_SUB_MONO; | ||
1709 | if (mode & VIDEO_SOUND_STEREO) | ||
1710 | vt->rxsubchans |= V4L2_TUNER_SUB_STEREO; | ||
1711 | if (mode & VIDEO_SOUND_LANG1) | ||
1712 | vt->rxsubchans |= V4L2_TUNER_SUB_LANG1 | | ||
1713 | V4L2_TUNER_SUB_LANG2; | ||
1714 | |||
1715 | mode = chip->mode; | ||
1716 | if (mode & VIDEO_SOUND_MONO) | ||
1717 | vt->audmode = V4L2_TUNER_MODE_MONO; | ||
1718 | if (mode & VIDEO_SOUND_STEREO) | ||
1719 | vt->audmode = V4L2_TUNER_MODE_STEREO; | ||
1720 | if (mode & VIDEO_SOUND_LANG1) | ||
1721 | vt->audmode = V4L2_TUNER_MODE_LANG1; | ||
1722 | if (mode & VIDEO_SOUND_LANG2) | ||
1723 | vt->audmode = V4L2_TUNER_MODE_LANG2; | ||
1724 | break; | ||
1725 | } | ||
1726 | |||
1727 | case VIDIOCSCHAN: | ||
1728 | case VIDIOC_S_STD: | ||
1729 | chip->radio = 0; | ||
1730 | break; | ||
1731 | |||
1732 | case VIDIOCSFREQ: | ||
1733 | case VIDIOC_S_FREQUENCY: | ||
1690 | chip->mode = 0; /* automatic */ | 1734 | chip->mode = 0; /* automatic */ |
1691 | if (desc->checkmode) { | 1735 | if (desc->checkmode) { |
1692 | desc->setmode(chip,VIDEO_SOUND_MONO); | 1736 | desc->setmode(chip,VIDEO_SOUND_MONO); |
@@ -1695,15 +1739,14 @@ static int chip_command(struct i2c_client *client, | |||
1695 | mod_timer(&chip->wt, jiffies+2*HZ); | 1739 | mod_timer(&chip->wt, jiffies+2*HZ); |
1696 | /* the thread will call checkmode() later */ | 1740 | /* the thread will call checkmode() later */ |
1697 | } | 1741 | } |
1698 | } | 1742 | break; |
1699 | } | 1743 | } |
1700 | return 0; | 1744 | return 0; |
1701 | } | 1745 | } |
1702 | 1746 | ||
1703 | |||
1704 | static struct i2c_driver driver = { | 1747 | static struct i2c_driver driver = { |
1705 | .driver = { | 1748 | .driver = { |
1706 | .name = "generic i2c audio driver", | 1749 | .name = "tvaudio", |
1707 | }, | 1750 | }, |
1708 | .id = I2C_DRIVERID_TVAUDIO, | 1751 | .id = I2C_DRIVERID_TVAUDIO, |
1709 | .attach_adapter = chip_probe, | 1752 | .attach_adapter = chip_probe, |