aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/tvaudio.c206
1 files changed, 112 insertions, 94 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 258724b2d6d2..1c31ef52f863 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -46,7 +46,17 @@ MODULE_AUTHOR("Eric Sandeen, Steve VanDeBogart, Greg Alexander, Gerd Knorr");
46MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
47 47
48#define UNSET (-1U) 48#define UNSET (-1U)
49#define dprintk if (debug) printk 49
50#define tvaudio_info(fmt, arg...) do {\
51 printk(KERN_INFO "tvaudio %d-%04x: " fmt, \
52 chip->c.adapter->nr, chip->c.addr , ##arg); } while (0)
53#define tvaudio_warn(fmt, arg...) do {\
54 printk(KERN_WARNING "tvaudio %d-%04x: " fmt, \
55 chip->c.adapter->nr, chip->c.addr , ##arg); } while (0)
56#define tvaudio_dbg(fmt, arg...) do {\
57 if (debug) \
58 printk(KERN_INFO "tvaudio %d-%04x: " fmt, \
59 chip->c.adapter->nr, chip->c.addr , ##arg); } while (0)
50 60
51/* ---------------------------------------------------------------------- */ 61/* ---------------------------------------------------------------------- */
52/* our structs */ 62/* our structs */
@@ -162,23 +172,24 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
162 unsigned char buffer[2]; 172 unsigned char buffer[2];
163 173
164 if (-1 == subaddr) { 174 if (-1 == subaddr) {
165 dprintk("%s: chip_write: 0x%x\n", chip->c.name, val); 175 tvaudio_dbg("%s: chip_write: 0x%x\n",
176 chip->c.name, val);
166 chip->shadow.bytes[1] = val; 177 chip->shadow.bytes[1] = val;
167 buffer[0] = val; 178 buffer[0] = val;
168 if (1 != i2c_master_send(&chip->c,buffer,1)) { 179 if (1 != i2c_master_send(&chip->c,buffer,1)) {
169 printk(KERN_WARNING "%s: I/O error (write 0x%x)\n", 180 tvaudio_warn("%s: I/O error (write 0x%x)\n",
170 chip->c.name, val); 181 chip->c.name, val);
171 return -1; 182 return -1;
172 } 183 }
173 } else { 184 } else {
174 dprintk("%s: chip_write: reg%d=0x%x\n", 185 tvaudio_dbg("%s: chip_write: reg%d=0x%x\n",
175 chip->c.name, subaddr, val); 186 chip->c.name, subaddr, val);
176 chip->shadow.bytes[subaddr+1] = val; 187 chip->shadow.bytes[subaddr+1] = val;
177 buffer[0] = subaddr; 188 buffer[0] = subaddr;
178 buffer[1] = val; 189 buffer[1] = val;
179 if (2 != i2c_master_send(&chip->c,buffer,2)) { 190 if (2 != i2c_master_send(&chip->c,buffer,2)) {
180 printk(KERN_WARNING "%s: I/O error (write reg%d=0x%x)\n", 191 tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n",
181 chip->c.name, subaddr, val); 192 chip->c.name, subaddr, val);
182 return -1; 193 return -1;
183 } 194 }
184 } 195 }
@@ -202,29 +213,30 @@ static int chip_read(struct CHIPSTATE *chip)
202 unsigned char buffer; 213 unsigned char buffer;
203 214
204 if (1 != i2c_master_recv(&chip->c,&buffer,1)) { 215 if (1 != i2c_master_recv(&chip->c,&buffer,1)) {
205 printk(KERN_WARNING "%s: I/O error (read)\n", chip->c.name); 216 tvaudio_warn("%s: I/O error (read)\n",
217 chip->c.name);
206 return -1; 218 return -1;
207 } 219 }
208 dprintk("%s: chip_read: 0x%x\n", chip->c.name, buffer); 220 tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name,buffer);
209 return buffer; 221 return buffer;
210} 222}
211 223
212static int chip_read2(struct CHIPSTATE *chip, int subaddr) 224static int chip_read2(struct CHIPSTATE *chip, int subaddr)
213{ 225{
214 unsigned char write[1]; 226 unsigned char write[1];
215 unsigned char read[1]; 227 unsigned char read[1];
216 struct i2c_msg msgs[2] = { 228 struct i2c_msg msgs[2] = {
217 { chip->c.addr, 0, 1, write }, 229 { chip->c.addr, 0, 1, write },
218 { chip->c.addr, I2C_M_RD, 1, read } 230 { chip->c.addr, I2C_M_RD, 1, read }
219 }; 231 };
220 write[0] = subaddr; 232 write[0] = subaddr;
221 233
222 if (2 != i2c_transfer(chip->c.adapter,msgs,2)) { 234 if (2 != i2c_transfer(chip->c.adapter,msgs,2)) {
223 printk(KERN_WARNING "%s: I/O error (read2)\n", chip->c.name); 235 tvaudio_warn("%s: I/O error (read2)\n", chip->c.name);
224 return -1; 236 return -1;
225 } 237 }
226 dprintk("%s: chip_read2: reg%d=0x%x\n", 238 tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n",
227 chip->c.name, subaddr, read[0]); 239 chip->c.name,subaddr,read[0]);
228 return read[0]; 240 return read[0];
229} 241}
230 242
@@ -236,17 +248,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
236 return 0; 248 return 0;
237 249
238 /* update our shadow register set; print bytes if (debug > 0) */ 250 /* update our shadow register set; print bytes if (debug > 0) */
239 dprintk("%s: chip_cmd(%s): reg=%d, data:", 251 tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:",
240 chip->c.name, name, cmd->bytes[0]); 252 chip->c.name,name,cmd->bytes[0]);
241 for (i = 1; i < cmd->count; i++) { 253 for (i = 1; i < cmd->count; i++) {
242 dprintk(" 0x%x",cmd->bytes[i]); 254 if (debug)
255 printk(" 0x%x",cmd->bytes[i]);
243 chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i]; 256 chip->shadow.bytes[i+cmd->bytes[0]] = cmd->bytes[i];
244 } 257 }
245 dprintk("\n"); 258 if (debug)
259 printk("\n");
246 260
247 /* send data to the chip */ 261 /* send data to the chip */
248 if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) { 262 if (cmd->count != i2c_master_send(&chip->c,cmd->bytes,cmd->count)) {
249 printk(KERN_WARNING "%s: I/O error (%s)\n", chip->c.name, name); 263 tvaudio_warn("%s: I/O error (%s)\n", chip->c.name, name);
250 return -1; 264 return -1;
251 } 265 }
252 return 0; 266 return 0;
@@ -261,19 +275,19 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
261 275
262static void chip_thread_wake(unsigned long data) 276static void chip_thread_wake(unsigned long data)
263{ 277{
264 struct CHIPSTATE *chip = (struct CHIPSTATE*)data; 278 struct CHIPSTATE *chip = (struct CHIPSTATE*)data;
265 wake_up_interruptible(&chip->wq); 279 wake_up_interruptible(&chip->wq);
266} 280}
267 281
268static int chip_thread(void *data) 282static int chip_thread(void *data)
269{ 283{
270 DECLARE_WAITQUEUE(wait, current); 284 DECLARE_WAITQUEUE(wait, current);
271 struct CHIPSTATE *chip = data; 285 struct CHIPSTATE *chip = data;
272 struct CHIPDESC *desc = chiplist + chip->type; 286 struct CHIPDESC *desc = chiplist + chip->type;
273 287
274 daemonize("%s", chip->c.name); 288 daemonize("%s", chip->c.name);
275 allow_signal(SIGTERM); 289 allow_signal(SIGTERM);
276 dprintk("%s: thread started\n", chip->c.name); 290 tvaudio_dbg("%s: thread started\n", chip->c.name);
277 291
278 for (;;) { 292 for (;;) {
279 add_wait_queue(&chip->wq, &wait); 293 add_wait_queue(&chip->wq, &wait);
@@ -285,7 +299,7 @@ static int chip_thread(void *data)
285 try_to_freeze(); 299 try_to_freeze();
286 if (chip->done || signal_pending(current)) 300 if (chip->done || signal_pending(current))
287 break; 301 break;
288 dprintk("%s: thread wakeup\n", chip->c.name); 302 tvaudio_dbg("%s: thread wakeup\n", chip->c.name);
289 303
290 /* don't do anything for radio or if mode != auto */ 304 /* don't do anything for radio or if mode != auto */
291 if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0) 305 if (chip->norm == VIDEO_MODE_RADIO || chip->mode != 0)
@@ -298,8 +312,8 @@ static int chip_thread(void *data)
298 mod_timer(&chip->wt, jiffies+2*HZ); 312 mod_timer(&chip->wt, jiffies+2*HZ);
299 } 313 }
300 314
301 dprintk("%s: thread exiting\n", chip->c.name); 315 tvaudio_dbg("%s: thread exiting\n", chip->c.name);
302 complete_and_exit(&chip->texit, 0); 316 complete_and_exit(&chip->texit, 0);
303 return 0; 317 return 0;
304} 318}
305 319
@@ -309,9 +323,9 @@ static void generic_checkmode(struct CHIPSTATE *chip)
309 int mode = desc->getmode(chip); 323 int mode = desc->getmode(chip);
310 324
311 if (mode == chip->prevmode) 325 if (mode == chip->prevmode)
312 return; 326 return;
313 327
314 dprintk("%s: thread checkmode\n", chip->c.name); 328 tvaudio_dbg("%s: thread checkmode\n", chip->c.name);
315 chip->prevmode = mode; 329 chip->prevmode = mode;
316 330
317 if (mode & VIDEO_SOUND_STEREO) 331 if (mode & VIDEO_SOUND_STEREO)
@@ -358,8 +372,8 @@ static int tda9840_getmode(struct CHIPSTATE *chip)
358 if (val & TDA9840_ST_STEREO) 372 if (val & TDA9840_ST_STEREO)
359 mode |= VIDEO_SOUND_STEREO; 373 mode |= VIDEO_SOUND_STEREO;
360 374
361 dprintk ("tda9840_getmode(): raw chip read: %d, return: %d\n", 375 tvaudio_dbg ("tda9840_getmode(): raw chip read: %d, return: %d\n",
362 val, mode); 376 val, mode);
363 return mode; 377 return mode;
364} 378}
365 379
@@ -654,8 +668,8 @@ static int tda9873_getmode(struct CHIPSTATE *chip)
654 mode |= VIDEO_SOUND_STEREO; 668 mode |= VIDEO_SOUND_STEREO;
655 if (val & TDA9873_DUAL) 669 if (val & TDA9873_DUAL)
656 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; 670 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
657 dprintk ("tda9873_getmode(): raw chip read: %d, return: %d\n", 671 tvaudio_dbg ("tda9873_getmode(): raw chip read: %d, return: %d\n",
658 val, mode); 672 val, mode);
659 return mode; 673 return mode;
660} 674}
661 675
@@ -665,12 +679,12 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode)
665 /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */ 679 /* int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */
666 680
667 if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) { 681 if ((sw_data & TDA9873_INP_MASK) != TDA9873_INTERNAL) {
668 dprintk("tda9873_setmode(): external input\n"); 682 tvaudio_dbg("tda9873_setmode(): external input\n");
669 return; 683 return;
670 } 684 }
671 685
672 dprintk("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]); 686 tvaudio_dbg("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]);
673 dprintk("tda9873_setmode(): sw_data = %d\n", sw_data); 687 tvaudio_dbg("tda9873_setmode(): sw_data = %d\n", sw_data);
674 688
675 switch (mode) { 689 switch (mode) {
676 case VIDEO_SOUND_MONO: 690 case VIDEO_SOUND_MONO:
@@ -691,7 +705,7 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode)
691 } 705 }
692 706
693 chip_write(chip, TDA9873_SW, sw_data); 707 chip_write(chip, TDA9873_SW, sw_data);
694 dprintk("tda9873_setmode(): req. mode %d; chip_write: %d\n", 708 tvaudio_dbg("tda9873_setmode(): req. mode %d; chip_write: %d\n",
695 mode, sw_data); 709 mode, sw_data);
696} 710}
697 711
@@ -828,9 +842,9 @@ static int tda9874a_setup(struct CHIPSTATE *chip)
828 } else { /* dic == 0x07 */ 842 } else { /* dic == 0x07 */
829 chip_write(chip, TDA9874A_AMCONR, 0xfb); 843 chip_write(chip, TDA9874A_AMCONR, 0xfb);
830 chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80); 844 chip_write(chip, TDA9874A_SDACOSR, (tda9874a_mode) ? 0x81:0x80);
831 chip_write(chip, TDA9874A_AOSR, 0x00); // or 0x10 845 chip_write(chip, TDA9874A_AOSR, 0x00); /* or 0x10 */
832 } 846 }
833 dprintk("tda9874a_setup(): %s [0x%02X].\n", 847 tvaudio_dbg("tda9874a_setup(): %s [0x%02X].\n",
834 tda9874a_modelist[tda9874a_STD].name,tda9874a_STD); 848 tda9874a_modelist[tda9874a_STD].name,tda9874a_STD);
835 return 1; 849 return 1;
836} 850}
@@ -873,7 +887,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip)
873 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; 887 mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;
874 } 888 }
875 889
876 dprintk("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", 890 tvaudio_dbg("tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n",
877 dsr, nsr, necr, mode); 891 dsr, nsr, necr, mode);
878 return mode; 892 return mode;
879} 893}
@@ -919,7 +933,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
919 chip_write(chip, TDA9874A_AOSR, aosr); 933 chip_write(chip, TDA9874A_AOSR, aosr);
920 chip_write(chip, TDA9874A_MDACOSR, mdacosr); 934 chip_write(chip, TDA9874A_MDACOSR, mdacosr);
921 935
922 dprintk("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n", 936 tvaudio_dbg("tda9874a_setmode(): req. mode %d; AOSR=0x%X, MDACOSR=0x%X.\n",
923 mode, aosr, mdacosr); 937 mode, aosr, mdacosr);
924 938
925 } else { /* dic == 0x07 */ 939 } else { /* dic == 0x07 */
@@ -954,7 +968,7 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
954 chip_write(chip, TDA9874A_FMMR, fmmr); 968 chip_write(chip, TDA9874A_FMMR, fmmr);
955 chip_write(chip, TDA9874A_AOSR, aosr); 969 chip_write(chip, TDA9874A_AOSR, aosr);
956 970
957 dprintk("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n", 971 tvaudio_dbg("tda9874a_setmode(): req. mode %d; FMMR=0x%X, AOSR=0x%X.\n",
958 mode, fmmr, aosr); 972 mode, fmmr, aosr);
959 } 973 }
960} 974}
@@ -968,10 +982,10 @@ static int tda9874a_checkit(struct CHIPSTATE *chip)
968 if(-1 == (sic = chip_read2(chip,TDA9874A_SIC))) 982 if(-1 == (sic = chip_read2(chip,TDA9874A_SIC)))
969 return 0; 983 return 0;
970 984
971 dprintk("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic); 985 tvaudio_dbg("tda9874a_checkit(): DIC=0x%X, SIC=0x%X.\n", dic, sic);
972 986
973 if((dic == 0x11)||(dic == 0x07)) { 987 if((dic == 0x11)||(dic == 0x07)) {
974 printk("tvaudio: found tda9874%s.\n", (dic == 0x11) ? "a":"h"); 988 tvaudio_info("found tda9874%s.\n", (dic == 0x11) ? "a":"h");
975 tda9874a_dic = dic; /* remember device id. */ 989 tda9874a_dic = dic; /* remember device id. */
976 return 1; 990 return 1;
977 } 991 }
@@ -1146,7 +1160,7 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode)
1146/* ---------------------------------------------------------------------- */ 1160/* ---------------------------------------------------------------------- */
1147/* audio chip descriptions - defines+functions for TA8874Z */ 1161/* audio chip descriptions - defines+functions for TA8874Z */
1148 1162
1149// write 1st byte 1163/* write 1st byte */
1150#define TA8874Z_LED_STE 0x80 1164#define TA8874Z_LED_STE 0x80
1151#define TA8874Z_LED_BIL 0x40 1165#define TA8874Z_LED_BIL 0x40
1152#define TA8874Z_LED_EXT 0x20 1166#define TA8874Z_LED_EXT 0x20
@@ -1156,21 +1170,22 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode)
1156#define TA8874Z_MODE_SUB 0x02 1170#define TA8874Z_MODE_SUB 0x02
1157#define TA8874Z_MODE_MAIN 0x01 1171#define TA8874Z_MODE_MAIN 0x01
1158 1172
1159// write 2nd byte 1173/* write 2nd byte */
1160//#define TA8874Z_TI 0x80 // test mode 1174/*#define TA8874Z_TI 0x80 */ /* test mode */
1161#define TA8874Z_SEPARATION 0x3f 1175#define TA8874Z_SEPARATION 0x3f
1162#define TA8874Z_SEPARATION_DEFAULT 0x10 1176#define TA8874Z_SEPARATION_DEFAULT 0x10
1163 1177
1164// read 1178/* read */
1165#define TA8874Z_B1 0x80 1179#define TA8874Z_B1 0x80
1166#define TA8874Z_B0 0x40 1180#define TA8874Z_B0 0x40
1167#define TA8874Z_CHAG_FLAG 0x20 1181#define TA8874Z_CHAG_FLAG 0x20
1168 1182
1169// B1 B0 1183/*
1170// mono L H 1184 * B1 B0
1171// stereo L L 1185 * mono L H
1172// BIL H L 1186 * stereo L L
1173 1187 * BIL H L
1188 */
1174static int ta8874z_getmode(struct CHIPSTATE *chip) 1189static int ta8874z_getmode(struct CHIPSTATE *chip)
1175{ 1190{
1176 int val, mode; 1191 int val, mode;
@@ -1182,7 +1197,7 @@ static int ta8874z_getmode(struct CHIPSTATE *chip)
1182 }else if (!(val & TA8874Z_B0)){ 1197 }else if (!(val & TA8874Z_B0)){
1183 mode |= VIDEO_SOUND_STEREO; 1198 mode |= VIDEO_SOUND_STEREO;
1184 } 1199 }
1185 //dprintk ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); 1200 /* tvaudio_dbg ("ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */
1186 return mode; 1201 return mode;
1187} 1202}
1188 1203
@@ -1195,7 +1210,7 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode)
1195{ 1210{
1196 int update = 1; 1211 int update = 1;
1197 audiocmd *t = NULL; 1212 audiocmd *t = NULL;
1198 dprintk("ta8874z_setmode(): mode: 0x%02x\n", mode); 1213 tvaudio_dbg("ta8874z_setmode(): mode: 0x%02x\n", mode);
1199 1214
1200 switch(mode){ 1215 switch(mode){
1201 case VIDEO_SOUND_MONO: 1216 case VIDEO_SOUND_MONO:
@@ -1235,11 +1250,11 @@ static int tda9850 = 1;
1235static int tda9855 = 1; 1250static int tda9855 = 1;
1236static int tda9873 = 1; 1251static int tda9873 = 1;
1237static int tda9874a = 1; 1252static int tda9874a = 1;
1238static int tea6300 = 0; // address clash with msp34xx 1253static int tea6300 = 0; /* address clash with msp34xx */
1239static int tea6320 = 0; // address clash with msp34xx 1254static int tea6320 = 0; /* address clash with msp34xx */
1240static int tea6420 = 1; 1255static int tea6420 = 1;
1241static int pic16c54 = 1; 1256static int pic16c54 = 1;
1242static int ta8874z = 0; // address clash with tda9840 1257static int ta8874z = 0; /* address clash with tda9840 */
1243 1258
1244module_param(tda8425, int, 0444); 1259module_param(tda8425, int, 0444);
1245module_param(tda9840, int, 0444); 1260module_param(tda9840, int, 0444);
@@ -1441,7 +1456,7 @@ static struct CHIPDESC chiplist[] = {
1441 { 1456 {
1442 .name = "ta8874z", 1457 .name = "ta8874z",
1443 .id = -1, 1458 .id = -1,
1444 //.id = I2C_DRIVERID_TA8874Z, 1459 /*.id = I2C_DRIVERID_TA8874Z, */
1445 .checkit = ta8874z_checkit, 1460 .checkit = ta8874z_checkit,
1446 .insmodopt = &ta8874z, 1461 .insmodopt = &ta8874z,
1447 .addr_lo = I2C_TDA9840 >> 1, 1462 .addr_lo = I2C_TDA9840 >> 1,
@@ -1476,7 +1491,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1476 i2c_set_clientdata(&chip->c, chip); 1491 i2c_set_clientdata(&chip->c, chip);
1477 1492
1478 /* find description for the chip */ 1493 /* find description for the chip */
1479 dprintk("tvaudio: chip found @ i2c-addr=0x%x\n", addr<<1); 1494 tvaudio_dbg("chip found @ 0x%x\n", addr<<1);
1480 for (desc = chiplist; desc->name != NULL; desc++) { 1495 for (desc = chiplist; desc->name != NULL; desc++) {
1481 if (0 == *(desc->insmodopt)) 1496 if (0 == *(desc->insmodopt))
1482 continue; 1497 continue;
@@ -1488,17 +1503,19 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1488 break; 1503 break;
1489 } 1504 }
1490 if (desc->name == NULL) { 1505 if (desc->name == NULL) {
1491 dprintk("tvaudio: no matching chip description found\n"); 1506 tvaudio_dbg("no matching chip description found\n");
1492 return -EIO; 1507 return -EIO;
1493 } 1508 }
1494 printk("tvaudio: found %s @ 0x%x\n", desc->name, addr<<1); 1509 tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name);
1495 dprintk("tvaudio: matches:%s%s%s.\n", 1510 if (desc->flags) {
1496 (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", 1511 tvaudio_dbg("matches:%s%s%s.\n",
1497 (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", 1512 (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "",
1498 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); 1513 (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "",
1514 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : "");
1515 }
1499 1516
1500 /* fill required data structures */ 1517 /* fill required data structures */
1501 strcpy(chip->c.name, desc->name); 1518 strcpy(chip->c.name,desc->name);
1502 chip->type = desc-chiplist; 1519 chip->type = desc-chiplist;
1503 chip->shadow.count = desc->registers+1; 1520 chip->shadow.count = desc->registers+1;
1504 chip->prevmode = -1; 1521 chip->prevmode = -1;
@@ -1534,7 +1551,7 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1534 init_completion(&chip->texit); 1551 init_completion(&chip->texit);
1535 chip->tpid = kernel_thread(chip_thread,(void *)chip,0); 1552 chip->tpid = kernel_thread(chip_thread,(void *)chip,0);
1536 if (chip->tpid < 0) 1553 if (chip->tpid < 0)
1537 printk(KERN_WARNING "%s: kernel_thread() failed\n", 1554 tvaudio_warn("%s: kernel_thread() failed\n",
1538 chip->c.name); 1555 chip->c.name);
1539 wake_up_interruptible(&chip->wq); 1556 wake_up_interruptible(&chip->wq);
1540 } 1557 }
@@ -1545,7 +1562,7 @@ static int chip_probe(struct i2c_adapter *adap)
1545{ 1562{
1546 /* don't attach on saa7146 based cards, 1563 /* don't attach on saa7146 based cards,
1547 because dedicated drivers are used */ 1564 because dedicated drivers are used */
1548 if (adap->id == I2C_HW_SAA7146) 1565 if ((adap->id == I2C_HW_SAA7146))
1549 return 0; 1566 return 0;
1550#ifdef I2C_CLASS_TV_ANALOG 1567#ifdef I2C_CLASS_TV_ANALOG
1551 if (adap->class & I2C_CLASS_TV_ANALOG) 1568 if (adap->class & I2C_CLASS_TV_ANALOG)
@@ -1584,11 +1601,11 @@ static int chip_detach(struct i2c_client *client)
1584static int chip_command(struct i2c_client *client, 1601static int chip_command(struct i2c_client *client,
1585 unsigned int cmd, void *arg) 1602 unsigned int cmd, void *arg)
1586{ 1603{
1587 __u16 *sarg = arg; 1604 __u16 *sarg = arg;
1588 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1605 struct CHIPSTATE *chip = i2c_get_clientdata(client);
1589 struct CHIPDESC *desc = chiplist + chip->type; 1606 struct CHIPDESC *desc = chiplist + chip->type;
1590 1607
1591 dprintk("%s: chip_command 0x%x\n", chip->c.name, cmd); 1608 tvaudio_dbg("%s: chip_command 0x%x\n",chip->c.name,cmd);
1592 1609
1593 switch (cmd) { 1610 switch (cmd) {
1594 case AUDC_SET_INPUT: 1611 case AUDC_SET_INPUT:
@@ -1601,7 +1618,6 @@ static int chip_command(struct i2c_client *client,
1601 break; 1618 break;
1602 1619
1603 case AUDC_SET_RADIO: 1620 case AUDC_SET_RADIO:
1604 dprintk(KERN_DEBUG "tvaudio: AUDC_SET_RADIO\n");
1605 chip->norm = VIDEO_MODE_RADIO; 1621 chip->norm = VIDEO_MODE_RADIO;
1606 chip->watch_stereo = 0; 1622 chip->watch_stereo = 0;
1607 /* del_timer(&chip->wt); */ 1623 /* del_timer(&chip->wt); */
@@ -1609,7 +1625,7 @@ static int chip_command(struct i2c_client *client,
1609 1625
1610 /* --- v4l ioctls --- */ 1626 /* --- v4l ioctls --- */
1611 /* take care: bttv does userspace copying, we'll get a 1627 /* take care: bttv does userspace copying, we'll get a
1612 kernel pointer here... */ 1628 kernel pointer here... */
1613 case VIDIOCGAUDIO: 1629 case VIDIOCGAUDIO:
1614 { 1630 {
1615 struct video_audio *va = arg; 1631 struct video_audio *va = arg;
@@ -1643,9 +1659,9 @@ static int chip_command(struct i2c_client *client,
1643 1659
1644 if (desc->flags & CHIP_HAS_VOLUME) { 1660 if (desc->flags & CHIP_HAS_VOLUME) {
1645 chip->left = (min(65536 - va->balance,32768) * 1661 chip->left = (min(65536 - va->balance,32768) *
1646 va->volume) / 32768; 1662 va->volume) / 32768;
1647 chip->right = (min(va->balance,(__u16)32768) * 1663 chip->right = (min(va->balance,(__u16)32768) *
1648 va->volume) / 32768; 1664 va->volume) / 32768;
1649 chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); 1665 chip_write(chip,desc->leftreg,desc->volfunc(chip->left));
1650 chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); 1666 chip_write(chip,desc->rightreg,desc->volfunc(chip->right));
1651 } 1667 }
@@ -1667,17 +1683,16 @@ static int chip_command(struct i2c_client *client,
1667 { 1683 {
1668 struct video_channel *vc = arg; 1684 struct video_channel *vc = arg;
1669 1685
1670 dprintk(KERN_DEBUG "tvaudio: VIDIOCSCHAN\n");
1671 chip->norm = vc->norm; 1686 chip->norm = vc->norm;
1672 break; 1687 break;
1673 } 1688 }
1674 case VIDIOCSFREQ: 1689 case VIDIOCSFREQ:
1675 { 1690 {
1676 chip->mode = 0; /* automatic */ 1691 chip->mode = 0; /* automatic */
1677 if (desc->checkmode) { 1692 if (desc->checkmode) {
1678 desc->setmode(chip,VIDEO_SOUND_MONO); 1693 desc->setmode(chip,VIDEO_SOUND_MONO);
1679 if (chip->prevmode != VIDEO_SOUND_MONO) 1694 if (chip->prevmode != VIDEO_SOUND_MONO)
1680 chip->prevmode = -1; /* reset previous mode */ 1695 chip->prevmode = -1; /* reset previous mode */
1681 mod_timer(&chip->wt, jiffies+2*HZ); 1696 mod_timer(&chip->wt, jiffies+2*HZ);
1682 /* the thread will call checkmode() later */ 1697 /* the thread will call checkmode() later */
1683 } 1698 }
@@ -1689,29 +1704,32 @@ static int chip_command(struct i2c_client *client,
1689 1704
1690static struct i2c_driver driver = { 1705static struct i2c_driver driver = {
1691 .owner = THIS_MODULE, 1706 .owner = THIS_MODULE,
1692 .name = "generic i2c audio driver", 1707 .name = "generic i2c audio driver",
1693 .id = I2C_DRIVERID_TVAUDIO, 1708 .id = I2C_DRIVERID_TVAUDIO,
1694 .flags = I2C_DF_NOTIFY, 1709 .flags = I2C_DF_NOTIFY,
1695 .attach_adapter = chip_probe, 1710 .attach_adapter = chip_probe,
1696 .detach_client = chip_detach, 1711 .detach_client = chip_detach,
1697 .command = chip_command, 1712 .command = chip_command,
1698}; 1713};
1699 1714
1700static struct i2c_client client_template = 1715static struct i2c_client client_template =
1701{ 1716{
1702 .name = "(unset)", 1717 .name = "(unset)",
1703 .flags = I2C_CLIENT_ALLOW_USE, 1718 .flags = I2C_CLIENT_ALLOW_USE,
1704 .driver = &driver, 1719 .driver = &driver,
1705}; 1720};
1706 1721
1707static int __init audiochip_init_module(void) 1722static int __init audiochip_init_module(void)
1708{ 1723{
1709 struct CHIPDESC *desc; 1724 struct CHIPDESC *desc;
1710 printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n"); 1725
1711 printk(KERN_INFO "tvaudio: known chips: "); 1726 if (debug) {
1712 for (desc = chiplist; desc->name != NULL; desc++) 1727 printk(KERN_INFO "tvaudio: TV audio decoder + audio/video mux driver\n");
1713 printk("%s%s", (desc == chiplist) ? "" : ",",desc->name); 1728 printk(KERN_INFO "tvaudio: known chips: ");
1714 printk("\n"); 1729 for (desc = chiplist; desc->name != NULL; desc++)
1730 printk("%s%s", (desc == chiplist) ? "" : ", ", desc->name);
1731 printk("\n");
1732 }
1715 1733
1716 return i2c_add_driver(&driver); 1734 return i2c_add_driver(&driver);
1717} 1735}