aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tveeprom.c
diff options
context:
space:
mode:
authorJames Bottomley <jejb@titanic.(none)>2005-11-10 09:29:07 -0500
committerJames Bottomley <jejb@titanic.(none)>2005-11-10 09:29:07 -0500
commit8a87a0b6313109d2fea87b1271d497c954ce2ca8 (patch)
tree1b7ae51ff681e27118590e9cab4bf0ce38f5d80e /drivers/media/video/tveeprom.c
parente6a04466ba965875a6132700fabb2f2c0249c41a (diff)
parent3b44f137b9a846c5452d9e6e1271b79b1dbcc942 (diff)
Merge by hand (whitespace conflicts in libata.h)
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/media/video/tveeprom.c')
-rw-r--r--drivers/media/video/tveeprom.c458
1 files changed, 261 insertions, 197 deletions
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 5344d5592199..72e8741e8b59 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -6,12 +6,12 @@
6 * which are: 6 * which are:
7 7
8 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) 8 Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de)
9 & Marcus Metzler (mocm@thp.uni-koeln.de) 9 & Marcus Metzler (mocm@thp.uni-koeln.de)
10 (c) 1999-2001 Gerd Knorr <kraxel@goldbach.in-berlin.de> 10 (c) 1999-2001 Gerd Knorr <kraxel@goldbach.in-berlin.de>
11 11
12 * Adjustments to fit a more general model and all bugs: 12 * Adjustments to fit a more general model and all bugs:
13 13
14 Copyright (C) 2003 John Klar <linpvr at projectplasma.com> 14 Copyright (C) 2003 John Klar <linpvr at projectplasma.com>
15 15
16 * This program is free software; you can redistribute it and/or modify 16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by 17 * it under the terms of the GNU General Public License as published by
@@ -40,6 +40,7 @@
40 40
41#include <media/tuner.h> 41#include <media/tuner.h>
42#include <media/tveeprom.h> 42#include <media/tveeprom.h>
43#include <media/audiochip.h>
43 44
44MODULE_DESCRIPTION("i2c Hauppauge eeprom decoder driver"); 45MODULE_DESCRIPTION("i2c Hauppauge eeprom decoder driver");
45MODULE_AUTHOR("John Klar"); 46MODULE_AUTHOR("John Klar");
@@ -53,14 +54,14 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
53 54
54#define tveeprom_info(fmt, arg...) do {\ 55#define tveeprom_info(fmt, arg...) do {\
55 printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ 56 printk(KERN_INFO "tveeprom %d-%04x: " fmt, \
56 c->adapter->nr, c->addr , ##arg); } while (0) 57 c->adapter->nr, c->addr , ##arg); } while (0)
57#define tveeprom_warn(fmt, arg...) do {\ 58#define tveeprom_warn(fmt, arg...) do {\
58 printk(KERN_WARNING "tveeprom %d-%04x: " fmt, \ 59 printk(KERN_WARNING "tveeprom %d-%04x: " fmt, \
59 c->adapter->nr, c->addr , ##arg); } while (0) 60 c->adapter->nr, c->addr , ##arg); } while (0)
60#define tveeprom_dbg(fmt, arg...) do {\ 61#define tveeprom_dbg(fmt, arg...) do {\
61 if (debug) \ 62 if (debug) \
62 printk(KERN_INFO "tveeprom %d-%04x: " fmt, \ 63 printk(KERN_INFO "tveeprom %d-%04x: " fmt, \
63 c->adapter->nr, c->addr , ##arg); } while (0) 64 c->adapter->nr, c->addr , ##arg); } while (0)
64 65
65 66
66/* ----------------------------------------------------------------------- */ 67/* ----------------------------------------------------------------------- */
@@ -134,8 +135,8 @@ hauppauge_tuner[] =
134 { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" }, 135 { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" },
135 { TUNER_PHILIPS_FQ1216ME, "Philips FQ1216 ME" }, 136 { TUNER_PHILIPS_FQ1216ME, "Philips FQ1216 ME" },
136 { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" }, 137 { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" },
137 { TUNER_PHILIPS_NTSC, "Philips TD1536" }, 138 { TUNER_PHILIPS_NTSC, "Philips TD1536" },
138 { TUNER_PHILIPS_NTSC, "Philips TD1536D" }, 139 { TUNER_PHILIPS_NTSC, "Philips TD1536D" },
139 { TUNER_PHILIPS_NTSC, "Philips FMR1236" }, /* mono radio */ 140 { TUNER_PHILIPS_NTSC, "Philips FMR1236" }, /* mono radio */
140 { TUNER_ABSENT, "Philips FI1256MP" }, 141 { TUNER_ABSENT, "Philips FI1256MP" },
141 /* 40-49 */ 142 /* 40-49 */
@@ -189,7 +190,7 @@ hauppauge_tuner[] =
189 { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MB 3"}, 190 { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MB 3"},
190 { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MI 3"}, 191 { TUNER_LG_PAL_NEW_TAPC, "TCL 2002MI 3"},
191 { TUNER_TCL_2002N, "TCL 2002N 6A"}, 192 { TUNER_TCL_2002N, "TCL 2002N 6A"},
192 { TUNER_ABSENT, "Philips FQ1236 MK3"}, 193 { TUNER_PHILIPS_FM1236_MK3, "Philips FQ1236 MK3"},
193 { TUNER_ABSENT, "Samsung TCPN 2121P30A"}, 194 { TUNER_ABSENT, "Samsung TCPN 2121P30A"},
194 { TUNER_ABSENT, "Samsung TCPE 4121P30A"}, 195 { TUNER_ABSENT, "Samsung TCPE 4121P30A"},
195 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MFPE05 2"}, 196 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MFPE05 2"},
@@ -200,95 +201,137 @@ hauppauge_tuner[] =
200 { TUNER_ABSENT, "Philips FQ1286A MK4"}, 201 { TUNER_ABSENT, "Philips FQ1286A MK4"},
201 { TUNER_ABSENT, "Philips FQ1216ME MK5"}, 202 { TUNER_ABSENT, "Philips FQ1216ME MK5"},
202 { TUNER_ABSENT, "Philips FQ1236 MK5"}, 203 { TUNER_ABSENT, "Philips FQ1236 MK5"},
203 { TUNER_ABSENT, "Unspecified"}, 204 { TUNER_ABSENT, "Samsung TCPG_6121P30A"},
204 { TUNER_LG_PAL_TAPE, "LG PAL (TAPE Series)"}, 205 { TUNER_TCL_2002MB, "TCL 2002MB_3H"},
205 { TUNER_ABSENT, "Unspecified"}, 206 { TUNER_ABSENT, "TCL 2002MI_3H"},
206 { TUNER_TCL_2002N, "TCL 2002N 5H"}, 207 { TUNER_TCL_2002N, "TCL 2002N 5H"},
207 /* 100-103 */ 208 /* 100-109 */
208 { TUNER_ABSENT, "Unspecified"}, 209 { TUNER_ABSENT, "Philips FMD1216ME"},
209 { TUNER_TEA5767, "Philips TEA5767HN FM Radio"}, 210 { TUNER_TEA5767, "Philips TEA5768HL FM Radio"},
210 { TUNER_ABSENT, "Unspecified"}, 211 { TUNER_ABSENT, "Panasonic ENV57H12D5"},
211 { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05 4"}, 212 { TUNER_ABSENT, "TCL MFNM05-4"},
213 { TUNER_ABSENT, "TCL MNM05-4"},
214 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MPE05-2"},
215 { TUNER_ABSENT, "TCL MQNM05-4"},
216 { TUNER_ABSENT, "LG TAPC-W701D"},
217 { TUNER_ABSENT, "TCL 9886P-WM"},
218 { TUNER_ABSENT, "TCL 1676NM-WM"},
212}; 219};
213 220
214/* This list is supplied by Hauppauge. Thanks! */ 221static struct HAUPPAUGE_AUDIOIC
215static const char *audioIC[] = { 222{
216 /* 0-4 */ 223 enum audiochip id;
217 "None", "TEA6300", "TEA6320", "TDA9850", "MSP3400C", 224 char *name;
218 /* 5-9 */ 225}
219 "MSP3410D", "MSP3415", "MSP3430", "MSP3438", "CS5331", 226audioIC[] =
220 /* 10-14 */ 227{
221 "MSP3435", "MSP3440", "MSP3445", "MSP3411", "MSP3416", 228 /* 0-4 */
222 /* 15-19 */ 229 {AUDIO_CHIP_NONE, "None"},
223 "MSP3425", "MSP3451", "MSP3418", "Type 0x12", "OKI7716", 230 {AUDIO_CHIP_TEA6300, "TEA6300"},
224 /* 20-24 */ 231 {AUDIO_CHIP_TEA6300, "TEA6320"},
225 "MSP4410", "MSP4420", "MSP4440", "MSP4450", "MSP4408", 232 {AUDIO_CHIP_TDA985X, "TDA9850"},
226 /* 25-29 */ 233 {AUDIO_CHIP_MSP34XX, "MSP3400C"},
227 "MSP4418", "MSP4428", "MSP4448", "MSP4458", "Type 0x1d", 234 /* 5-9 */
228 /* 30-34 */ 235 {AUDIO_CHIP_MSP34XX, "MSP3410D"},
229 "CX880", "CX881", "CX883", "CX882", "CX25840", 236 {AUDIO_CHIP_MSP34XX, "MSP3415"},
230 /* 35-38 */ 237 {AUDIO_CHIP_MSP34XX, "MSP3430"},
231 "CX25841", "CX25842", "CX25843", "CX23418", 238 {AUDIO_CHIP_UNKNOWN, "MSP3438"},
239 {AUDIO_CHIP_UNKNOWN, "CS5331"},
240 /* 10-14 */
241 {AUDIO_CHIP_MSP34XX, "MSP3435"},
242 {AUDIO_CHIP_MSP34XX, "MSP3440"},
243 {AUDIO_CHIP_MSP34XX, "MSP3445"},
244 {AUDIO_CHIP_UNKNOWN, "MSP3411"},
245 {AUDIO_CHIP_UNKNOWN, "MSP3416"},
246 /* 15-19 */
247 {AUDIO_CHIP_MSP34XX, "MSP3425"},
248 {AUDIO_CHIP_UNKNOWN, "MSP3451"},
249 {AUDIO_CHIP_UNKNOWN, "MSP3418"},
250 {AUDIO_CHIP_UNKNOWN, "Type 0x12"},
251 {AUDIO_CHIP_UNKNOWN, "OKI7716"},
252 /* 20-24 */
253 {AUDIO_CHIP_UNKNOWN, "MSP4410"},
254 {AUDIO_CHIP_UNKNOWN, "MSP4420"},
255 {AUDIO_CHIP_UNKNOWN, "MSP4440"},
256 {AUDIO_CHIP_UNKNOWN, "MSP4450"},
257 {AUDIO_CHIP_UNKNOWN, "MSP4408"},
258 /* 25-29 */
259 {AUDIO_CHIP_UNKNOWN, "MSP4418"},
260 {AUDIO_CHIP_UNKNOWN, "MSP4428"},
261 {AUDIO_CHIP_UNKNOWN, "MSP4448"},
262 {AUDIO_CHIP_UNKNOWN, "MSP4458"},
263 {AUDIO_CHIP_UNKNOWN, "Type 0x1d"},
264 /* 30-34 */
265 {AUDIO_CHIP_INTERNAL, "CX880"},
266 {AUDIO_CHIP_INTERNAL, "CX881"},
267 {AUDIO_CHIP_INTERNAL, "CX883"},
268 {AUDIO_CHIP_INTERNAL, "CX882"},
269 {AUDIO_CHIP_INTERNAL, "CX25840"},
270 /* 35-38 */
271 {AUDIO_CHIP_INTERNAL, "CX25841"},
272 {AUDIO_CHIP_INTERNAL, "CX25842"},
273 {AUDIO_CHIP_INTERNAL, "CX25843"},
274 {AUDIO_CHIP_INTERNAL, "CX23418"},
232}; 275};
233 276
234/* This list is supplied by Hauppauge. Thanks! */ 277/* This list is supplied by Hauppauge. Thanks! */
235static const char *decoderIC[] = { 278static const char *decoderIC[] = {
236 /* 0-4 */ 279 /* 0-4 */
237 "None", "BT815", "BT817", "BT819", "BT815A", 280 "None", "BT815", "BT817", "BT819", "BT815A",
238 /* 5-9 */ 281 /* 5-9 */
239 "BT817A", "BT819A", "BT827", "BT829", "BT848", 282 "BT817A", "BT819A", "BT827", "BT829", "BT848",
240 /* 10-14 */ 283 /* 10-14 */
241 "BT848A", "BT849A", "BT829A", "BT827A", "BT878", 284 "BT848A", "BT849A", "BT829A", "BT827A", "BT878",
242 /* 15-19 */ 285 /* 15-19 */
243 "BT879", "BT880", "VPX3226E", "SAA7114", "SAA7115", 286 "BT879", "BT880", "VPX3226E", "SAA7114", "SAA7115",
244 /* 20-24 */ 287 /* 20-24 */
245 "CX880", "CX881", "CX883", "SAA7111", "SAA7113", 288 "CX880", "CX881", "CX883", "SAA7111", "SAA7113",
246 /* 25-29 */ 289 /* 25-29 */
247 "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", 290 "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842",
248 /* 30-31 */ 291 /* 30-31 */
249 "CX25843", "CX23418", 292 "CX25843", "CX23418",
250}; 293};
251 294
252static int hasRadioTuner(int tunerType) 295static int hasRadioTuner(int tunerType)
253{ 296{
254 switch (tunerType) { 297 switch (tunerType) {
255 case 18: //PNPEnv_TUNER_FR1236_MK2: 298 case 18: //PNPEnv_TUNER_FR1236_MK2:
256 case 23: //PNPEnv_TUNER_FM1236: 299 case 23: //PNPEnv_TUNER_FM1236:
257 case 38: //PNPEnv_TUNER_FMR1236: 300 case 38: //PNPEnv_TUNER_FMR1236:
258 case 16: //PNPEnv_TUNER_FR1216_MK2: 301 case 16: //PNPEnv_TUNER_FR1216_MK2:
259 case 19: //PNPEnv_TUNER_FR1246_MK2: 302 case 19: //PNPEnv_TUNER_FR1246_MK2:
260 case 21: //PNPEnv_TUNER_FM1216: 303 case 21: //PNPEnv_TUNER_FM1216:
261 case 24: //PNPEnv_TUNER_FM1246: 304 case 24: //PNPEnv_TUNER_FM1246:
262 case 17: //PNPEnv_TUNER_FR1216MF_MK2: 305 case 17: //PNPEnv_TUNER_FR1216MF_MK2:
263 case 22: //PNPEnv_TUNER_FM1216MF: 306 case 22: //PNPEnv_TUNER_FM1216MF:
264 case 20: //PNPEnv_TUNER_FR1256_MK2: 307 case 20: //PNPEnv_TUNER_FR1256_MK2:
265 case 25: //PNPEnv_TUNER_FM1256: 308 case 25: //PNPEnv_TUNER_FM1256:
266 case 33: //PNPEnv_TUNER_4039FR5: 309 case 33: //PNPEnv_TUNER_4039FR5:
267 case 42: //PNPEnv_TUNER_4009FR5: 310 case 42: //PNPEnv_TUNER_4009FR5:
268 case 52: //PNPEnv_TUNER_4049FM5: 311 case 52: //PNPEnv_TUNER_4049FM5:
269 case 54: //PNPEnv_TUNER_4049FM5_AltI2C: 312 case 54: //PNPEnv_TUNER_4049FM5_AltI2C:
270 case 44: //PNPEnv_TUNER_4009FN5: 313 case 44: //PNPEnv_TUNER_4009FN5:
271 case 31: //PNPEnv_TUNER_TCPB9085P: 314 case 31: //PNPEnv_TUNER_TCPB9085P:
272 case 30: //PNPEnv_TUNER_TCPN9085D: 315 case 30: //PNPEnv_TUNER_TCPN9085D:
273 case 46: //PNPEnv_TUNER_TP18NSR01F: 316 case 46: //PNPEnv_TUNER_TP18NSR01F:
274 case 47: //PNPEnv_TUNER_TP18PSB01D: 317 case 47: //PNPEnv_TUNER_TP18PSB01D:
275 case 49: //PNPEnv_TUNER_TAPC_I001D: 318 case 49: //PNPEnv_TUNER_TAPC_I001D:
276 case 60: //PNPEnv_TUNER_TAPE_S001D_MK3: 319 case 60: //PNPEnv_TUNER_TAPE_S001D_MK3:
277 case 57: //PNPEnv_TUNER_FM1216ME_MK3: 320 case 57: //PNPEnv_TUNER_FM1216ME_MK3:
278 case 59: //PNPEnv_TUNER_FM1216MP_MK3: 321 case 59: //PNPEnv_TUNER_FM1216MP_MK3:
279 case 58: //PNPEnv_TUNER_FM1236_MK3: 322 case 58: //PNPEnv_TUNER_FM1236_MK3:
280 case 68: //PNPEnv_TUNER_TAPE_H001F_MK3: 323 case 68: //PNPEnv_TUNER_TAPE_H001F_MK3:
281 case 61: //PNPEnv_TUNER_TAPE_M001D_MK3: 324 case 61: //PNPEnv_TUNER_TAPE_M001D_MK3:
282 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM: 325 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM:
283 case 89: //PNPEnv_TUNER_TCL_MFPE05_2: 326 case 89: //PNPEnv_TUNER_TCL_MFPE05_2:
284 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4: 327 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4:
285 return 1; 328 return 1;
286 } 329 }
287 return 0; 330 return 0;
288} 331}
289 332
290void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee, 333void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
291 unsigned char *eeprom_data) 334 unsigned char *eeprom_data)
292{ 335{
293 /* ---------------------------------------------- 336 /* ----------------------------------------------
294 ** The hauppauge eeprom format is tagged 337 ** The hauppauge eeprom format is tagged
@@ -312,19 +355,27 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
312 ** # of inputs/outputs ??? 355 ** # of inputs/outputs ???
313 */ 356 */
314 357
315 int i, j, len, done, beenhere, tag; 358 int i, j, len, done, beenhere, tag,start;
316 359
317 int tuner1 = 0, t_format1 = 0; 360 int tuner1 = 0, t_format1 = 0, audioic=-1;
318 char *t_name1 = NULL; 361 char *t_name1 = NULL;
319 const char *t_fmt_name1[8] = { " none", "", "", "", "", "", "", "" }; 362 const char *t_fmt_name1[8] = { " none", "", "", "", "", "", "", "" };
320 363
321 int tuner2 = 0, t_format2 = 0; 364 int tuner2 = 0, t_format2 = 0;
322 char *t_name2 = NULL; 365 char *t_name2 = NULL;
323 const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" }; 366 const char *t_fmt_name2[8] = { " none", "", "", "", "", "", "", "" };
324 367
325 memset(tvee, 0, sizeof(*tvee)); 368 memset(tvee, 0, sizeof(*tvee));
326 done = len = beenhere = 0; 369 done = len = beenhere = 0;
327 for (i = 0; !done && i < 256; i += len) { 370
371 /* Hack for processing eeprom for em28xx */
372 if ((eeprom_data[0]==0x1a)&&(eeprom_data[1]==0xeb)&&
373 (eeprom_data[2]==0x67)&&(eeprom_data[3]==0x95))
374 start=0xa0;
375 else
376 start=0;
377
378 for (i = start; !done && i < 256; i += len) {
328 if (eeprom_data[i] == 0x84) { 379 if (eeprom_data[i] == 0x84) {
329 len = eeprom_data[i + 1] + (eeprom_data[i + 2] << 8); 380 len = eeprom_data[i + 1] + (eeprom_data[i + 2] << 8);
330 i += 3; 381 i += 3;
@@ -338,28 +389,28 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
338 ++i; 389 ++i;
339 } else { 390 } else {
340 tveeprom_warn("Encountered bad packet header [%02x]. " 391 tveeprom_warn("Encountered bad packet header [%02x]. "
341 "Corrupt or not a Hauppauge eeprom.\n", eeprom_data[i]); 392 "Corrupt or not a Hauppauge eeprom.\n", eeprom_data[i]);
342 return; 393 return;
343 } 394 }
344 395
345 if (debug) { 396 if (debug) {
346 tveeprom_info("Tag [%02x] + %d bytes:", eeprom_data[i], len - 1); 397 tveeprom_info("Tag [%02x] + %d bytes:", eeprom_data[i], len - 1);
347 for(j = 1; j < len; j++) { 398 for(j = 1; j < len; j++) {
348 printk(" %02x", eeprom_data[i + j]); 399 printk(" %02x", eeprom_data[i + j]);
349 } 400 }
350 printk("\n"); 401 printk("\n");
351 } 402 }
352 403
353 /* process by tag */ 404 /* process by tag */
354 tag = eeprom_data[i]; 405 tag = eeprom_data[i];
355 switch (tag) { 406 switch (tag) {
356 case 0x00: 407 case 0x00:
357 /* tag: 'Comprehensive' */ 408 /* tag: 'Comprehensive' */
358 tuner1 = eeprom_data[i+6]; 409 tuner1 = eeprom_data[i+6];
359 t_format1 = eeprom_data[i+5]; 410 t_format1 = eeprom_data[i+5];
360 tvee->has_radio = eeprom_data[i+len-1]; 411 tvee->has_radio = eeprom_data[i+len-1];
361 /* old style tag, don't know how to detect 412 /* old style tag, don't know how to detect
362 IR presence, mark as unknown. */ 413 IR presence, mark as unknown. */
363 tvee->has_ir = 2; 414 tvee->has_ir = 2;
364 tvee->model = 415 tvee->model =
365 eeprom_data[i+8] + 416 eeprom_data[i+8] +
@@ -370,7 +421,7 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
370 break; 421 break;
371 422
372 case 0x01: 423 case 0x01:
373 /* tag: 'SerialID' */ 424 /* tag: 'SerialID' */
374 tvee->serial_number = 425 tvee->serial_number =
375 eeprom_data[i+6] + 426 eeprom_data[i+6] +
376 (eeprom_data[i+7] << 8) + 427 (eeprom_data[i+7] << 8) +
@@ -378,17 +429,21 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
378 break; 429 break;
379 430
380 case 0x02: 431 case 0x02:
381 /* tag 'AudioInfo' 432 /* tag 'AudioInfo'
382 Note mask with 0x7F, high bit used on some older models 433 Note mask with 0x7F, high bit used on some older models
383 to indicate 4052 mux was removed in favor of using MSP 434 to indicate 4052 mux was removed in favor of using MSP
384 inputs directly. */ 435 inputs directly. */
385 tvee->audio_processor = eeprom_data[i+2] & 0x7f; 436 audioic = eeprom_data[i+2] & 0x7f;
437 if (audioic < sizeof(audioIC)/sizeof(*audioIC))
438 tvee->audio_processor = audioIC[audioic].id;
439 else
440 tvee->audio_processor = AUDIO_CHIP_UNKNOWN;
386 break; 441 break;
387 442
388 /* case 0x03: tag 'EEInfo' */ 443 /* case 0x03: tag 'EEInfo' */
389 444
390 case 0x04: 445 case 0x04:
391 /* tag 'SerialID2' */ 446 /* tag 'SerialID2' */
392 tvee->serial_number = 447 tvee->serial_number =
393 eeprom_data[i+5] + 448 eeprom_data[i+5] +
394 (eeprom_data[i+6] << 8) + 449 (eeprom_data[i+6] << 8) +
@@ -396,15 +451,20 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
396 break; 451 break;
397 452
398 case 0x05: 453 case 0x05:
399 /* tag 'Audio2' 454 /* tag 'Audio2'
400 Note mask with 0x7F, high bit used on some older models 455 Note mask with 0x7F, high bit used on some older models
401 to indicate 4052 mux was removed in favor of using MSP 456 to indicate 4052 mux was removed in favor of using MSP
402 inputs directly. */ 457 inputs directly. */
403 tvee->audio_processor = eeprom_data[i+1] & 0x7f; 458 audioic = eeprom_data[i+1] & 0x7f;
459 if (audioic < sizeof(audioIC)/sizeof(*audioIC))
460 tvee->audio_processor = audioIC[audioic].id;
461 else
462 tvee->audio_processor = AUDIO_CHIP_UNKNOWN;
463
404 break; 464 break;
405 465
406 case 0x06: 466 case 0x06:
407 /* tag 'ModelRev' */ 467 /* tag 'ModelRev' */
408 tvee->model = 468 tvee->model =
409 eeprom_data[i+1] + 469 eeprom_data[i+1] +
410 (eeprom_data[i+2] << 8); 470 (eeprom_data[i+2] << 8);
@@ -414,55 +474,55 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
414 break; 474 break;
415 475
416 case 0x07: 476 case 0x07:
417 /* tag 'Details': according to Hauppauge not interesting 477 /* tag 'Details': according to Hauppauge not interesting
418 on any PCI-era or later boards. */ 478 on any PCI-era or later boards. */
419 break; 479 break;
420 480
421 /* there is no tag 0x08 defined */ 481 /* there is no tag 0x08 defined */
422 482
423 case 0x09: 483 case 0x09:
424 /* tag 'Video' */ 484 /* tag 'Video' */
425 tvee->decoder_processor = eeprom_data[i + 1]; 485 tvee->decoder_processor = eeprom_data[i + 1];
426 break; 486 break;
427 487
428 case 0x0a: 488 case 0x0a:
429 /* tag 'Tuner' */ 489 /* tag 'Tuner' */
430 if (beenhere == 0) { 490 if (beenhere == 0) {
431 tuner1 = eeprom_data[i+2]; 491 tuner1 = eeprom_data[i+2];
432 t_format1 = eeprom_data[i+1]; 492 t_format1 = eeprom_data[i+1];
433 beenhere = 1; 493 beenhere = 1;
434 } else { 494 } else {
435 /* a second (radio) tuner may be present */ 495 /* a second (radio) tuner may be present */
436 tuner2 = eeprom_data[i+2]; 496 tuner2 = eeprom_data[i+2];
437 t_format2 = eeprom_data[i+1]; 497 t_format2 = eeprom_data[i+1];
438 if (t_format2 == 0) { /* not a TV tuner? */ 498 if (t_format2 == 0) { /* not a TV tuner? */
439 tvee->has_radio = 1; /* must be radio */ 499 tvee->has_radio = 1; /* must be radio */
440 } 500 }
441 } 501 }
442 break; 502 break;
443 503
444 case 0x0b: 504 case 0x0b:
445 /* tag 'Inputs': according to Hauppauge this is specific 505 /* tag 'Inputs': according to Hauppauge this is specific
446 to each driver family, so no good assumptions can be 506 to each driver family, so no good assumptions can be
447 made. */ 507 made. */
448 break; 508 break;
449 509
450 /* case 0x0c: tag 'Balun' */ 510 /* case 0x0c: tag 'Balun' */
451 /* case 0x0d: tag 'Teletext' */ 511 /* case 0x0d: tag 'Teletext' */
452 512
453 case 0x0e: 513 case 0x0e:
454 /* tag: 'Radio' */ 514 /* tag: 'Radio' */
455 tvee->has_radio = eeprom_data[i+1]; 515 tvee->has_radio = eeprom_data[i+1];
456 break; 516 break;
457 517
458 case 0x0f: 518 case 0x0f:
459 /* tag 'IRInfo' */ 519 /* tag 'IRInfo' */
460 tvee->has_ir = eeprom_data[i+1]; 520 tvee->has_ir = eeprom_data[i+1];
461 break; 521 break;
462 522
463 /* case 0x10: tag 'VBIInfo' */ 523 /* case 0x10: tag 'VBIInfo' */
464 /* case 0x11: tag 'QCInfo' */ 524 /* case 0x11: tag 'QCInfo' */
465 /* case 0x12: tag 'InfoBits' */ 525 /* case 0x12: tag 'InfoBits' */
466 526
467 default: 527 default:
468 tveeprom_dbg("Not sure what to do with tag [%02x]\n", tag); 528 tveeprom_dbg("Not sure what to do with tag [%02x]\n", tag);
@@ -483,11 +543,11 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
483 tvee->rev_str[4] = 0; 543 tvee->rev_str[4] = 0;
484 } 544 }
485 545
486 if (hasRadioTuner(tuner1) && !tvee->has_radio) { 546 if (hasRadioTuner(tuner1) && !tvee->has_radio) {
487 tveeprom_info("The eeprom says no radio is present, but the tuner type\n"); 547 tveeprom_info("The eeprom says no radio is present, but the tuner type\n");
488 tveeprom_info("indicates otherwise. I will assume that radio is present.\n"); 548 tveeprom_info("indicates otherwise. I will assume that radio is present.\n");
489 tvee->has_radio = 1; 549 tvee->has_radio = 1;
490 } 550 }
491 551
492 if (tuner1 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) { 552 if (tuner1 < sizeof(hauppauge_tuner)/sizeof(struct HAUPPAUGE_TUNER)) {
493 tvee->tuner_type = hauppauge_tuner[tuner1].id; 553 tvee->tuner_type = hauppauge_tuner[tuner1].id;
@@ -510,45 +570,53 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
510 tvee->tuner_formats |= hauppauge_tuner_fmt[i].id; 570 tvee->tuner_formats |= hauppauge_tuner_fmt[i].id;
511 t_fmt_name1[j++] = hauppauge_tuner_fmt[i].name; 571 t_fmt_name1[j++] = hauppauge_tuner_fmt[i].name;
512 } 572 }
513 if (t_format2 & (1 << i)) { 573 if (t_format2 & (1 << i)) {
514 tvee->tuner2_formats |= hauppauge_tuner_fmt[i].id; 574 tvee->tuner2_formats |= hauppauge_tuner_fmt[i].id;
515 t_fmt_name2[j++] = hauppauge_tuner_fmt[i].name; 575 t_fmt_name2[j++] = hauppauge_tuner_fmt[i].name;
516 } 576 }
517 } 577 }
518 578
519 tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n", 579 tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n",
520 tvee->model, tvee->rev_str, tvee->serial_number); 580 tvee->model, tvee->rev_str, tvee->serial_number);
521 tveeprom_info("tuner model is %s (idx %d, type %d)\n", 581 tveeprom_info("tuner model is %s (idx %d, type %d)\n",
522 t_name1, tuner1, tvee->tuner_type); 582 t_name1, tuner1, tvee->tuner_type);
523 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", 583 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n",
524 t_fmt_name1[0], t_fmt_name1[1], t_fmt_name1[2], t_fmt_name1[3], 584 t_fmt_name1[0], t_fmt_name1[1], t_fmt_name1[2], t_fmt_name1[3],
525 t_fmt_name1[4], t_fmt_name1[5], t_fmt_name1[6], t_fmt_name1[7], 585 t_fmt_name1[4], t_fmt_name1[5], t_fmt_name1[6], t_fmt_name1[7],
526 t_format1); 586 t_format1);
527 if (tuner2) { 587 if (tuner2) {
528 tveeprom_info("second tuner model is %s (idx %d, type %d)\n", 588 tveeprom_info("second tuner model is %s (idx %d, type %d)\n",
529 t_name2, tuner2, tvee->tuner2_type); 589 t_name2, tuner2, tvee->tuner2_type);
530 } 590 }
531 if (t_format2) { 591 if (t_format2) {
532 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", 592 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n",
533 t_fmt_name2[0], t_fmt_name2[1], t_fmt_name2[2], t_fmt_name2[3], 593 t_fmt_name2[0], t_fmt_name2[1], t_fmt_name2[2], t_fmt_name2[3],
534 t_fmt_name2[4], t_fmt_name2[5], t_fmt_name2[6], t_fmt_name2[7], 594 t_fmt_name2[4], t_fmt_name2[5], t_fmt_name2[6], t_fmt_name2[7],
535 t_format2); 595 t_format2);
536 } 596 }
537 tveeprom_info("audio processor is %s (idx %d)\n", 597 if (audioic<0) {
538 STRM(audioIC, tvee->audio_processor), 598 tveeprom_info("audio processor is unknown (no idx)\n");
539 tvee->audio_processor); 599 tvee->audio_processor=AUDIO_CHIP_UNKNOWN;
540 if (tvee->decoder_processor) { 600 } else {
541 tveeprom_info("decoder processor is %s (idx %d)\n", 601 if (audioic < sizeof(audioIC)/sizeof(*audioIC))
542 STRM(decoderIC, tvee->decoder_processor), 602 tveeprom_info("audio processor is %s (idx %d)\n",
543 tvee->decoder_processor); 603 audioIC[audioic].name,audioic);
544 } 604 else
545 if (tvee->has_ir == 2) 605 tveeprom_info("audio processor is unknown (idx %d)\n",
546 tveeprom_info("has %sradio\n", 606 audioic);
547 tvee->has_radio ? "" : "no "); 607 }
548 else 608 if (tvee->decoder_processor) {
549 tveeprom_info("has %sradio, has %sIR remote\n", 609 tveeprom_info("decoder processor is %s (idx %d)\n",
550 tvee->has_radio ? "" : "no ", 610 STRM(decoderIC, tvee->decoder_processor),
551 tvee->has_ir ? "" : "no "); 611 tvee->decoder_processor);
612 }
613 if (tvee->has_ir == 2)
614 tveeprom_info("has %sradio\n",
615 tvee->has_radio ? "" : "no ");
616 else
617 tveeprom_info("has %sradio, has %sIR remote\n",
618 tvee->has_radio ? "" : "no ",
619 tvee->has_ir ? "" : "no ");
552} 620}
553EXPORT_SYMBOL(tveeprom_hauppauge_analog); 621EXPORT_SYMBOL(tveeprom_hauppauge_analog);
554 622
@@ -569,18 +637,18 @@ int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len)
569 tveeprom_warn("i2c eeprom read error (err=%d)\n", err); 637 tveeprom_warn("i2c eeprom read error (err=%d)\n", err);
570 return -1; 638 return -1;
571 } 639 }
572 if (debug) { 640 if (debug) {
573 int i; 641 int i;
574 642
575 tveeprom_info("full 256-byte eeprom dump:\n"); 643 tveeprom_info("full 256-byte eeprom dump:\n");
576 for (i = 0; i < len; i++) { 644 for (i = 0; i < len; i++) {
577 if (0 == (i % 16)) 645 if (0 == (i % 16))
578 tveeprom_info("%02x:", i); 646 tveeprom_info("%02x:", i);
579 printk(" %02x", eedata[i]); 647 printk(" %02x", eedata[i]);
580 if (15 == (i % 16)) 648 if (15 == (i % 16))
581 printk("\n"); 649 printk("\n");
582 } 650 }
583 } 651 }
584 return 0; 652 return 0;
585} 653}
586EXPORT_SYMBOL(tveeprom_read); 654EXPORT_SYMBOL(tveeprom_read);
@@ -590,10 +658,6 @@ EXPORT_SYMBOL(tveeprom_read);
590/* run, just call the exported tveeprom_* directly, there is no point in */ 658/* run, just call the exported tveeprom_* directly, there is no point in */
591/* using the indirect way via i2c_driver->command() */ 659/* using the indirect way via i2c_driver->command() */
592 660
593#ifndef I2C_DRIVERID_TVEEPROM
594# define I2C_DRIVERID_TVEEPROM I2C_DRIVERID_EXP2
595#endif
596
597static unsigned short normal_i2c[] = { 661static unsigned short normal_i2c[] = {
598 0xa0 >> 1, 662 0xa0 >> 1,
599 I2C_CLIENT_END, 663 I2C_CLIENT_END,