[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 209 static void input_change(struct i2c_client *client) 210 { 211 v4l2_std_id std = cx25840_get_v4lstd(client); 212 213 if (std & V4L2_STD_PAL) { 214 /* Follow tuner change procedure for PAL */ 215 cx25840_write(client, 0x808, 0xff); ··· 223 cx25840_write(client, 0x80b, 0x10); 224 } else if (std & V4L2_STD_NTSC) { 225 /* NTSC */ 226 - cx25840_write(client, 0x808, 0xf6); 227 cx25840_write(client, 0x80b, 0x00); 228 } 229 ··· 269 case CX25840_TUNER: 270 cx25840_dbg("now setting Tuner input\n"); 271 272 - if (state->cardtype == CARDTYPE_PVR150) { 273 /* CH_SEL_ADC2=1 */ 274 cx25840_and_or(client, 0x102, ~0x2, 0x02); 275 } ··· 392 case CX25840_CID_CARDTYPE: 393 switch (ctrl->value) { 394 case CARDTYPE_PVR150: 395 case CARDTYPE_PG600: 396 state->cardtype = ctrl->value; 397 break;
··· 208 209 static void input_change(struct i2c_client *client) 210 { 211 + struct cx25840_state *state = i2c_get_clientdata(client); 212 v4l2_std_id std = cx25840_get_v4lstd(client); 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. */ 216 if (std & V4L2_STD_PAL) { 217 /* Follow tuner change procedure for PAL */ 218 cx25840_write(client, 0x808, 0xff); ··· 220 cx25840_write(client, 0x80b, 0x10); 221 } else if (std & V4L2_STD_NTSC) { 222 /* NTSC */ 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. */ 249 cx25840_write(client, 0x80b, 0x00); 250 } 251 ··· 241 case CX25840_TUNER: 242 cx25840_dbg("now setting Tuner input\n"); 243 244 + if (state->cardtype == CARDTYPE_PVR150 || 245 + state->cardtype == CARDTYPE_PVR150_WORKAROUND) { 246 /* CH_SEL_ADC2=1 */ 247 cx25840_and_or(client, 0x102, ~0x2, 0x02); 248 } ··· 363 case CX25840_CID_CARDTYPE: 364 switch (ctrl->value) { 365 case CARDTYPE_PVR150: 366 + case CARDTYPE_PVR150_WORKAROUND: 367 case CARDTYPE_PG600: 368 state->cardtype = ctrl->value; 369 break;
+8 -1
drivers/media/video/cx25840/cx25840.h
··· 40 41 #define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0) 42 43 enum cx25840_cardtype { 44 CARDTYPE_PVR150, 45 - CARDTYPE_PG600 46 }; 47 48 enum cx25840_input {
··· 40 41 #define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0) 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. */ 49 enum cx25840_cardtype { 50 CARDTYPE_PVR150, 51 + CARDTYPE_PG600, 52 + CARDTYPE_PVR150_WORKAROUND, 53 }; 54 55 enum cx25840_input {
+3
drivers/media/video/tveeprom.c
··· 339 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM: 340 case 89: //PNPEnv_TUNER_TCL_MFPE05_2: 341 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4: 342 return 1; 343 } 344 return 0; ··· 597 t_name2 = "unknown"; 598 } 599 600 tvee->tuner_formats = 0; 601 tvee->tuner2_formats = 0; 602 for (i = j = 0; i < 8; i++) {
··· 339 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM: 340 case 89: //PNPEnv_TUNER_TCL_MFPE05_2: 341 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4: 342 + case 105: 343 return 1; 344 } 345 return 0; ··· 596 t_name2 = "unknown"; 597 } 598 599 + tvee->tuner_hauppauge_model = tuner1; 600 + tvee->tuner2_hauppauge_model = tuner2; 601 tvee->tuner_formats = 0; 602 tvee->tuner2_formats = 0; 603 for (i = j = 0; i < 8; i++) {
+2
include/media/tveeprom.h
··· 8 9 u32 tuner_type; 10 u32 tuner_formats; 11 12 u32 tuner2_type; 13 u32 tuner2_formats; 14 15 u32 digitizer; 16 u32 digitizer_formats;
··· 8 9 u32 tuner_type; 10 u32 tuner_formats; 11 + u32 tuner_hauppauge_model; 12 13 u32 tuner2_type; 14 u32 tuner2_formats; 15 + u32 tuner2_hauppauge_model; 16 17 u32 digitizer; 18 u32 digitizer_formats;