[PATCH] V4L: Add workaround for Hauppauge PVR150 with certain NTSC tuner models

Add workaround for Hauppauge PVR150 hardware problem with tuner models 85, 99
and 112 (model numbers as reported by tveeprom). The audio standard
autodetection does not always work correctly for these models.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Hans Verkuil and committed by
Linus Torvalds
f95006f8 0fe22865

+45 -3
+32 -2
drivers/media/video/cx25840/cx25840-core.c
··· 208 208 209 209 static void input_change(struct i2c_client *client) 210 210 { 211 + struct cx25840_state *state = i2c_get_clientdata(client); 211 212 v4l2_std_id std = cx25840_get_v4lstd(client); 212 213 214 + /* Note: perhaps V4L2_STD_PAL_M should be handled as V4L2_STD_NTSC 215 + instead of V4L2_STD_PAL. Someone needs to test this. */ 213 216 if (std & V4L2_STD_PAL) { 214 217 /* Follow tuner change procedure for PAL */ 215 218 cx25840_write(client, 0x808, 0xff); ··· 223 220 cx25840_write(client, 0x80b, 0x10); 224 221 } else if (std & V4L2_STD_NTSC) { 225 222 /* NTSC */ 226 - cx25840_write(client, 0x808, 0xf6); 223 + if (state->cardtype == CARDTYPE_PVR150_WORKAROUND) { 224 + /* Certain Hauppauge PVR150 models have a hardware bug 225 + that causes audio to drop out. For these models the 226 + audio standard must be set explicitly. 227 + To be precise: it affects cards with tuner models 228 + 85, 99 and 112 (model numbers from tveeprom). */ 229 + if (std == V4L2_STD_NTSC_M_JP) { 230 + /* Japan uses EIAJ audio standard */ 231 + cx25840_write(client, 0x808, 0x2f); 232 + } else { 233 + /* Others use the BTSC audio standard */ 234 + cx25840_write(client, 0x808, 0x1f); 235 + } 236 + /* South Korea uses the A2-M (aka Zweiton M) audio 237 + standard, and should set 0x808 to 0x3f, but I don't 238 + know how to detect this. */ 239 + } else if (std == V4L2_STD_NTSC_M_JP) { 240 + /* Japan uses EIAJ audio standard */ 241 + cx25840_write(client, 0x808, 0xf7); 242 + } else { 243 + /* Others use the BTSC audio standard */ 244 + cx25840_write(client, 0x808, 0xf6); 245 + } 246 + /* South Korea uses the A2-M (aka Zweiton M) audio standard, 247 + and should set 0x808 to 0xf8, but I don't know how to 248 + detect this. */ 227 249 cx25840_write(client, 0x80b, 0x00); 228 250 } 229 251 ··· 269 241 case CX25840_TUNER: 270 242 cx25840_dbg("now setting Tuner input\n"); 271 243 272 - if (state->cardtype == CARDTYPE_PVR150) { 244 + if (state->cardtype == CARDTYPE_PVR150 || 245 + state->cardtype == CARDTYPE_PVR150_WORKAROUND) { 273 246 /* CH_SEL_ADC2=1 */ 274 247 cx25840_and_or(client, 0x102, ~0x2, 0x02); 275 248 } ··· 392 363 case CX25840_CID_CARDTYPE: 393 364 switch (ctrl->value) { 394 365 case CARDTYPE_PVR150: 366 + case CARDTYPE_PVR150_WORKAROUND: 395 367 case CARDTYPE_PG600: 396 368 state->cardtype = ctrl->value; 397 369 break;
+8 -1
drivers/media/video/cx25840/cx25840.h
··· 40 40 41 41 #define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0) 42 42 43 + /* The CARDTYPE_PVR150_WORKAROUND cardtype activates a workaround for a 44 + hardware bug that is present in PVR150 (and possible PVR500) cards that 45 + have certain NTSC tuners (tveeprom model numbers 85, 99 and 112). The 46 + audio autodetect fails on some channels for these models and the workaround 47 + is to select the audio standard explicitly. Many thanks to Hauppauge for 48 + providing this information. */ 43 49 enum cx25840_cardtype { 44 50 CARDTYPE_PVR150, 45 - CARDTYPE_PG600 51 + CARDTYPE_PG600, 52 + CARDTYPE_PVR150_WORKAROUND, 46 53 }; 47 54 48 55 enum cx25840_input {
+3
drivers/media/video/tveeprom.c
··· 339 339 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM: 340 340 case 89: //PNPEnv_TUNER_TCL_MFPE05_2: 341 341 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4: 342 + case 105: 342 343 return 1; 343 344 } 344 345 return 0; ··· 597 596 t_name2 = "unknown"; 598 597 } 599 598 599 + tvee->tuner_hauppauge_model = tuner1; 600 + tvee->tuner2_hauppauge_model = tuner2; 600 601 tvee->tuner_formats = 0; 601 602 tvee->tuner2_formats = 0; 602 603 for (i = j = 0; i < 8; i++) {
+2
include/media/tveeprom.h
··· 8 8 9 9 u32 tuner_type; 10 10 u32 tuner_formats; 11 + u32 tuner_hauppauge_model; 11 12 12 13 u32 tuner2_type; 13 14 u32 tuner2_formats; 15 + u32 tuner2_hauppauge_model; 14 16 15 17 u32 digitizer; 16 18 u32 digitizer_formats;