From 7b0ac9cdd42b254ae2ec0f6c1cc6389655e4ba96 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Fri, 13 Jan 2006 14:10:25 -0200 Subject: V4L/DVB (3359): Redesign tuners struct for maximum flexibility - Tunertype struct redefined to allow one or more tuner_params structs per tuner definition, one for each video standard. - Each tuner_params struct has an element containing an arbitrary amount of tuner_ranges. (this is needed for dvb tuners - to be handled later) - A tuner_range may be referenced by multiple tuner_params structs. There are many duplicates in here. Reusing tuner_range structs, rather than defining new ones for each tuner, will cut down on memory usage, and is preferred when possible. - tunertype struct contains an element, has_tda988x. We must set this for all tunertypes that contain a tda988x chip, and then we can remove this setting from the various card structs. - Improves tuners array memory usage efficiency. - Right now, all tuners are using the first tuner_params[] array element for analog mode. In the future, we will be merging similar tuner definitions together, such that each tuner definition will have a tuner_params struct for each available video standard. At that point, the tuner_params[] array element will be chosen based on the video standard in use. Signed-off-by: Michael Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/tuner-simple.c | 750 ++----------------------------------- 1 file changed, 24 insertions(+), 726 deletions(-) (limited to 'drivers/media/video/tuner-simple.c') diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index e5fb7436583..3879262cf4c 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -79,722 +79,16 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); #define TUNER_PLL_LOCKED 0x40 #define TUNER_STEREO_MK3 0x04 -#define TUNER_MAX_RANGES 3 - -/* ---------------------------------------------------------------------- */ - -struct tunertype -{ - char *name; - - int count; - struct { - unsigned short thresh; - unsigned char cb; - } ranges[TUNER_MAX_RANGES]; - unsigned char config; -}; - -/* - * The floats in the tuner struct are computed at compile time - * by gcc and cast back to integers. Thus we don't violate the - * "no float in kernel" rule. +#define TUNER_PARAM_ANALOG 0 /* to be removed */ +/* FIXME: + * Right now, all tuners are using the first tuner_params[] array element + * for analog mode. In the future, we will be merging similar tuner + * definitions together, such that each tuner definition will have a + * tuner_params struct for each available video standard. At that point, + * TUNER_PARAM_ANALOG will be removed, and the tuner_params[] array + * element will be chosen based on the video standard in use. + * */ -static struct tunertype tuners[] = { - /* 0-9 */ - [TUNER_TEMIC_PAL] = { /* TEMIC PAL */ - .name = "Temic PAL (4002 FH5)", - .count = 3, - .ranges = { - { 16 * 140.25 /*MHz*/, 0x02, }, - { 16 * 463.25 /*MHz*/, 0x04, }, - { 16 * 999.99 , 0x01, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_PAL_I] = { /* Philips PAL_I */ - .name = "Philips PAL_I (FI1246 and compatibles)", - .count = 3, - .ranges = { - { 16 * 140.25 /*MHz*/, 0xa0, }, - { 16 * 463.25 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_NTSC] = { /* Philips NTSC */ - .name = "Philips NTSC (FI1236,FM1236 and compatibles)", - .count = 3, - .ranges = { - { 16 * 157.25 /*MHz*/, 0xa0, }, - { 16 * 451.25 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_SECAM] = { /* Philips SECAM */ - .name = "Philips (SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)", - .count = 3, - .ranges = { - { 16 * 168.25 /*MHz*/, 0xa7, }, - { 16 * 447.25 /*MHz*/, 0x97, }, - { 16 * 999.99 , 0x37, }, - }, - .config = 0x8e, - }, - [TUNER_ABSENT] = { /* Tuner Absent */ - .name = "NoTuner", - .count = 1, - .ranges = { - { 0, 0x00, }, - }, - .config = 0x00, - }, - [TUNER_PHILIPS_PAL] = { /* Philips PAL */ - .name = "Philips PAL_BG (FI1216 and compatibles)", - .count = 3, - .ranges = { - { 16 * 168.25 /*MHz*/, 0xa0, }, - { 16 * 447.25 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_NTSC] = { /* TEMIC NTSC */ - .name = "Temic NTSC (4032 FY5)", - .count = 3, - .ranges = { - { 16 * 157.25 /*MHz*/, 0x02, }, - { 16 * 463.25 /*MHz*/, 0x04, }, - { 16 * 999.99 , 0x01, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_PAL_I] = { /* TEMIC PAL_I */ - .name = "Temic PAL_I (4062 FY5)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0x02, }, - { 16 * 450.00 /*MHz*/, 0x04, }, - { 16 * 999.99 , 0x01, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_4036FY5_NTSC] = { /* TEMIC NTSC */ - .name = "Temic NTSC (4036 FY5)", - .count = 3, - .ranges = { - { 16 * 157.25 /*MHz*/, 0xa0, }, - { 16 * 463.25 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_ALPS_TSBH1_NTSC] = { /* TEMIC NTSC */ - .name = "Alps HSBH1", - .count = 3, - .ranges = { - { 16 * 137.25 /*MHz*/, 0x01, }, - { 16 * 385.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - - /* 10-19 */ - [TUNER_ALPS_TSBE1_PAL] = { /* TEMIC PAL */ - .name = "Alps TSBE1", - .count = 3, - .ranges = { - { 16 * 137.25 /*MHz*/, 0x01, }, - { 16 * 385.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_ALPS_TSBB5_PAL_I] = { /* Alps PAL_I */ - .name = "Alps TSBB5", - .count = 3, - .ranges = { - { 16 * 133.25 /*MHz*/, 0x01, }, - { 16 * 351.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_ALPS_TSBE5_PAL] = { /* Alps PAL */ - .name = "Alps TSBE5", - .count = 3, - .ranges = { - { 16 * 133.25 /*MHz*/, 0x01, }, - { 16 * 351.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_ALPS_TSBC5_PAL] = { /* Alps PAL */ - .name = "Alps TSBC5", - .count = 3, - .ranges = { - { 16 * 133.25 /*MHz*/, 0x01, }, - { 16 * 351.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_4006FH5_PAL] = { /* TEMIC PAL */ - .name = "Temic PAL_BG (4006FH5)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0xa0, }, - { 16 * 450.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_ALPS_TSHC6_NTSC] = { /* Alps NTSC */ - .name = "Alps TSCH6", - .count = 3, - .ranges = { - { 16 * 137.25 /*MHz*/, 0x14, }, - { 16 * 385.25 /*MHz*/, 0x12, }, - { 16 * 999.99 , 0x11, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_PAL_DK] = { /* TEMIC PAL */ - .name = "Temic PAL_DK (4016 FY5)", - .count = 3, - .ranges = { - { 16 * 168.25 /*MHz*/, 0xa0, }, - { 16 * 456.25 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_NTSC_M] = { /* Philips NTSC */ - .name = "Philips NTSC_M (MK2)", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0xa0, }, - { 16 * 454.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_4066FY5_PAL_I] = { /* TEMIC PAL_I */ - .name = "Temic PAL_I (4066 FY5)", - .count = 3, - .ranges = { - { 16 * 169.00 /*MHz*/, 0xa0, }, - { 16 * 454.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_4006FN5_MULTI_PAL] = { /* TEMIC PAL */ - .name = "Temic PAL* auto (4006 FN5)", - .count = 3, - .ranges = { - { 16 * 169.00 /*MHz*/, 0xa0, }, - { 16 * 454.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - - /* 20-29 */ - [TUNER_TEMIC_4009FR5_PAL] = { /* TEMIC PAL */ - .name = "Temic PAL_BG (4009 FR5) or PAL_I (4069 FR5)", - .count = 3, - .ranges = { - { 16 * 141.00 /*MHz*/, 0xa0, }, - { 16 * 464.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_4039FR5_NTSC] = { /* TEMIC NTSC */ - .name = "Temic NTSC (4039 FR5)", - .count = 3, - .ranges = { - { 16 * 158.00 /*MHz*/, 0xa0, }, - { 16 * 453.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_4046FM5] = { /* TEMIC PAL */ - .name = "Temic PAL/SECAM multi (4046 FM5)", - .count = 3, - .ranges = { - { 16 * 169.00 /*MHz*/, 0xa0, }, - { 16 * 454.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_PAL_DK] = { /* Philips PAL */ - .name = "Philips PAL_DK (FI1256 and compatibles)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0xa0, }, - { 16 * 450.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_FQ1216ME] = { /* Philips PAL */ - .name = "Philips PAL/SECAM multi (FQ1216ME)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0xa0, }, - { 16 * 450.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_LG_PAL_I_FM] = { /* LGINNOTEK PAL_I */ - .name = "LG PAL_I+FM (TAPC-I001D)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0xa0, }, - { 16 * 450.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_LG_PAL_I] = { /* LGINNOTEK PAL_I */ - .name = "LG PAL_I (TAPC-I701D)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0xa0, }, - { 16 * 450.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_LG_NTSC_FM] = { /* LGINNOTEK NTSC */ - .name = "LG NTSC+FM (TPI8NSR01F)", - .count = 3, - .ranges = { - { 16 * 210.00 /*MHz*/, 0xa0, }, - { 16 * 497.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_LG_PAL_FM] = { /* LGINNOTEK PAL */ - .name = "LG PAL_BG+FM (TPI8PSB01D)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0xa0, }, - { 16 * 450.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_LG_PAL] = { /* LGINNOTEK PAL */ - .name = "LG PAL_BG (TPI8PSB11D)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0xa0, }, - { 16 * 450.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - - /* 30-39 */ - [TUNER_TEMIC_4009FN5_MULTI_PAL_FM] = { /* TEMIC PAL */ - .name = "Temic PAL* auto + FM (4009 FN5)", - .count = 3, - .ranges = { - { 16 * 141.00 /*MHz*/, 0xa0, }, - { 16 * 464.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_SHARP_2U5JF5540_NTSC] = { /* SHARP NTSC */ - .name = "SHARP NTSC_JP (2U5JF5540)", - .count = 3, - .ranges = { - { 16 * 137.25 /*MHz*/, 0x01, }, - { 16 * 317.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_Samsung_PAL_TCPM9091PD27] = { /* Samsung PAL */ - .name = "Samsung PAL TCPM9091PD27", - .count = 3, - .ranges = { - { 16 * 169 /*MHz*/, 0xa0, }, - { 16 * 464 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_MT2032] = { /* Microtune PAL|NTSC */ - .name = "MT20xx universal", - /* see mt20xx.c for details */ }, - [TUNER_TEMIC_4106FH5] = { /* TEMIC PAL */ - .name = "Temic PAL_BG (4106 FH5)", - .count = 3, - .ranges = { - { 16 * 141.00 /*MHz*/, 0xa0, }, - { 16 * 464.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_4012FY5] = { /* TEMIC PAL */ - .name = "Temic PAL_DK/SECAM_L (4012 FY5)", - .count = 3, - .ranges = { - { 16 * 140.25 /*MHz*/, 0x02, }, - { 16 * 463.25 /*MHz*/, 0x04, }, - { 16 * 999.99 , 0x01, }, - }, - .config = 0x8e, - }, - [TUNER_TEMIC_4136FY5] = { /* TEMIC NTSC */ - .name = "Temic NTSC (4136 FY5)", - .count = 3, - .ranges = { - { 16 * 158.00 /*MHz*/, 0xa0, }, - { 16 * 453.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_LG_PAL_NEW_TAPC] = { /* LGINNOTEK PAL */ - .name = "LG PAL (newer TAPC series)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0x01, }, - { 16 * 450.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_FM1216ME_MK3] = { /* Philips PAL */ - .name = "Philips PAL/SECAM multi (FM1216ME MK3)", - .count = 3, - .ranges = { - { 16 * 158.00 /*MHz*/, 0x01, }, - { 16 * 442.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - [TUNER_LG_NTSC_NEW_TAPC] = { /* LGINNOTEK NTSC */ - .name = "LG NTSC (newer TAPC series)", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0x01, }, - { 16 * 450.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - - /* 40-49 */ - [TUNER_HITACHI_NTSC] = { /* HITACHI NTSC */ - .name = "HITACHI V7-J180AT", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0x01, }, - { 16 * 450.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_PAL_MK] = { /* Philips PAL */ - .name = "Philips PAL_MK (FI1216 MK)", - .count = 3, - .ranges = { - { 16 * 140.25 /*MHz*/, 0x01, }, - { 16 * 463.25 /*MHz*/, 0xc2, }, - { 16 * 999.99 , 0xcf, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_ATSC] = { /* Philips ATSC */ - .name = "Philips 1236D ATSC/NTSC dual in", - .count = 3, - .ranges = { - { 16 * 157.25 /*MHz*/, 0xa0, }, - { 16 * 454.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_FM1236_MK3] = { /* Philips NTSC */ - .name = "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01, }, - { 16 * 442.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_4IN1] = { /* Philips NTSC */ - .name = "Philips 4 in 1 (ATI TV Wonder Pro/Conexant)", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01, }, - { 16 * 442.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - [TUNER_MICROTUNE_4049FM5] = { /* Microtune PAL */ - .name = "Microtune 4049 FM5", - .count = 3, - .ranges = { - { 16 * 141.00 /*MHz*/, 0xa0, }, - { 16 * 464.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_PANASONIC_VP27] = { /* Panasonic NTSC */ - .name = "Panasonic VP27s/ENGE4324D", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01, }, - { 16 * 454.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0xce, - }, - [TUNER_LG_NTSC_TAPE] = { /* LGINNOTEK NTSC */ - .name = "LG NTSC (TAPE series)", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01, }, - { 16 * 442.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - [TUNER_TNF_8831BGFF] = { /* Philips PAL */ - .name = "Tenna TNF 8831 BGFF)", - .count = 3, - .ranges = { - { 16 * 161.25 /*MHz*/, 0xa0, }, - { 16 * 463.25 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_MICROTUNE_4042FI5] = { /* Microtune NTSC */ - .name = "Microtune 4042 FI5 ATSC/NTSC dual in", - .count = 3, - .ranges = { - { 16 * 162.00 /*MHz*/, 0xa2, }, - { 16 * 457.00 /*MHz*/, 0x94, }, - { 16 * 999.99 , 0x31, }, - }, - .config = 0x8e, - }, - - /* 50-59 */ - [TUNER_TCL_2002N] = { /* TCL NTSC */ - .name = "TCL 2002N", - .count = 3, - .ranges = { - { 16 * 172.00 /*MHz*/, 0x01, }, - { 16 * 448.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_FM1256_IH3] = { /* Philips PAL */ - .name = "Philips PAL/SECAM_D (FM 1256 I-H3)", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01, }, - { 16 * 442.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - [TUNER_THOMSON_DTT7610] = { /* THOMSON ATSC */ - .name = "Thomson DTT 7610 (ATSC/NTSC)", - .count = 3, - .ranges = { - { 16 * 157.25 /*MHz*/, 0x39, }, - { 16 * 454.00 /*MHz*/, 0x3a, }, - { 16 * 999.99 , 0x3c, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_FQ1286] = { /* Philips NTSC */ - .name = "Philips FQ1286", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x41, }, - { 16 * 454.00 /*MHz*/, 0x42, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_TDA8290] = { /* Philips PAL|NTSC */ - .name = "tda8290+75", - /* see tda8290.c for details */ }, - [TUNER_TCL_2002MB] = { /* TCL PAL */ - .name = "TCL 2002MB", - .count = 3, - .ranges = { - { 16 * 170.00 /*MHz*/, 0x01, }, - { 16 * 450.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0xce, - }, - [TUNER_PHILIPS_FQ1216AME_MK4] = { /* Philips PAL */ - .name = "Philips PAL/SECAM multi (FQ1216AME MK4)", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01, }, - { 16 * 442.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0xce, - }, - [TUNER_PHILIPS_FQ1236A_MK4] = { /* Philips NTSC */ - .name = "Philips FQ1236A MK4", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01, }, - { 16 * 442.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - [TUNER_YMEC_TVF_8531MF] = { /* Philips NTSC */ - .name = "Ymec TVision TVF-8531MF/8831MF/8731MF", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0xa0, }, - { 16 * 454.00 /*MHz*/, 0x90, }, - { 16 * 999.99 , 0x30, }, - }, - .config = 0x8e, - }, - [TUNER_YMEC_TVF_5533MF] = { /* Philips NTSC */ - .name = "Ymec TVision TVF-5533MF", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01, }, - { 16 * 454.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - - /* 60-69 */ - [TUNER_THOMSON_DTT761X] = { /* THOMSON ATSC */ - /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */ - .name = "Thomson DTT 761X (ATSC/NTSC)", - .count = 3, - .ranges = { - { 16 * 145.25 /*MHz*/, 0x39, }, - { 16 * 415.25 /*MHz*/, 0x3a, }, - { 16 * 999.99 , 0x3c, }, - }, - .config = 0x8e, - }, - [TUNER_TENA_9533_DI] = { /* Philips PAL */ - .name = "Tena TNF9533-D/IF/TNF9533-B/DF", - .count = 3, - .ranges = { - { 16 * 160.25 /*MHz*/, 0x01, }, - { 16 * 464.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, - [TUNER_TEA5767] = { /* Philips RADIO */ - .name = "Philips TEA5767HN FM Radio", - /* see tea5767.c for details */}, - [TUNER_PHILIPS_FMD1216ME_MK3] = { /* Philips PAL */ - .name = "Philips FMD1216ME MK3 Hybrid Tuner", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x51, }, - { 16 * 442.00 /*MHz*/, 0x52, }, - { 16 * 999.99 , 0x54, }, - }, - .config = 0x86, - }, - [TUNER_LG_TDVS_H062F] = { /* LGINNOTEK ATSC */ - .name = "LG TDVS-H062F/TUA6034", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0x01 }, - { 16 * 455.00 /*MHz*/, 0x02 }, - { 16 * 999.99 , 0x04 }, - }, - .config = 0x8e, - }, - [TUNER_YMEC_TVF66T5_B_DFF] = { /* Philips PAL */ - .name = "Ymec TVF66T5-B/DFF", - .count = 3, - .ranges = { - { 16 * 160.25 /*MHz*/, 0x01, }, - { 16 * 464.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_LG_NTSC_TALN_MINI] = { /* LGINNOTEK NTSC */ - .name = "LG NTSC (TALN mini series)", - .count = 3, - .ranges = { - { 16 * 137.25 /*MHz*/, 0x01, }, - { 16 * 373.25 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x08, }, - }, - .config = 0x8e, - }, - [TUNER_PHILIPS_TD1316] = { /* Philips PAL */ - .name = "Philips TD1316 Hybrid Tuner", - .count = 3, - .ranges = { - { 16 * 160.00 /*MHz*/, 0xa1, }, - { 16 * 442.00 /*MHz*/, 0xa2, }, - { 16 * 999.99 , 0xa4, }, - }, - .config = 0xc8, - }, - [TUNER_PHILIPS_TUV1236D] = { /* Philips ATSC */ - .name = "Philips TUV1236D ATSC/NTSC dual in", - .count = 3, - .ranges = { - { 16 * 157.25 /*MHz*/, 0x01, }, - { 16 * 454.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0xce, - }, - [TUNER_TNF_5335MF] = { /* Philips NTSC */ - .name = "Tena TNF 5335 MF", - .count = 3, - .ranges = { - { 16 * 157.25 /*MHz*/, 0x01, }, - { 16 * 454.00 /*MHz*/, 0x02, }, - { 16 * 999.99 , 0x04, }, - }, - .config = 0x8e, - }, -}; - -unsigned const int tuner_count = ARRAY_SIZE(tuners); /* ---------------------------------------------------------------------- */ @@ -843,15 +137,17 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) u16 div; struct tunertype *tun; unsigned char buffer[4]; - int rc, IFPCoff, i; + int rc, IFPCoff, i, j; tun = &tuners[t->type]; - for (i = 0; i < tun->count; i++) { - if (freq > tun->ranges[i].thresh) + j = TUNER_PARAM_ANALOG; + + for (i = 0; i < tun->params[j].count; i++) { + if (freq > tun->params[j].ranges[i].limit) continue; break; } - config = tun->ranges[i].cb; + config = tun->params[j].ranges[i].cb; /* i == 0 -> VHF_LO */ /* i == 1 -> VHF_HI */ /* i == 2 -> UHF */ @@ -914,7 +210,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) case TUNER_MICROTUNE_4042FI5: /* Set the charge pump for fast tuning */ - tun->config |= TUNER_CHARGE_PUMP; + tun->params[j].config |= TUNER_CHARGE_PUMP; break; case TUNER_PHILIPS_TUV1236D: @@ -989,14 +285,14 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) div); if (t->type == TUNER_PHILIPS_SECAM && freq < t->freq) { - buffer[0] = tun->config; + buffer[0] = tun->params[j].config; buffer[1] = config; buffer[2] = (div>>8) & 0x7f; buffer[3] = div & 0xff; } else { buffer[0] = (div>>8) & 0x7f; buffer[1] = div & 0xff; - buffer[2] = tun->config; + buffer[2] = tun->params[j].config; buffer[3] = config; } tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", @@ -1024,10 +320,10 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) } /* Set the charge pump for optimized phase noise figure */ - tun->config &= ~TUNER_CHARGE_PUMP; + tun->params[j].config &= ~TUNER_CHARGE_PUMP; buffer[0] = (div>>8) & 0x7f; buffer[1] = div & 0xff; - buffer[2] = tun->config; + buffer[2] = tun->params[j].config; buffer[3] = config; tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", buffer[0],buffer[1],buffer[2],buffer[3]); @@ -1043,11 +339,13 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) struct tuner *t = i2c_get_clientdata(c); unsigned char buffer[4]; unsigned div; - int rc; + int rc, j; tun = &tuners[t->type]; + j = TUNER_PARAM_ANALOG; + div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */ - buffer[2] = (tun->config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */ + buffer[2] = (tun->params[j].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */ switch (t->type) { case TUNER_TENA_9533_DI: -- cgit v1.2.3 From 27487d44712aaa37710cc508d5bd6119f5e9f976 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sun, 15 Jan 2006 15:04:52 -0200 Subject: V4L/DVB (3384): Separate tv & radio freqs, fix cb/freq transmit order for tuners that need this. - Moved MSP_SET_MATRIX to v4l2-common.h - Fix typos and integer overflows in tea5767.c - Split old freq field into a tv_freq and a radio_freq. Prevents that a radio tuner is initialized with a tv frequency or vice versa. - When switching to radio mode initialize the tuner with the last used radio frequency (this was already done for the TV mode). As a result of these changes the tuner module now remembers the last set radio and TV frequencies, which is what you would expect to happen. - Move out of range frequencies to the closest valid frequency as per v4l2 API spec. - Fix incorrect initial radio frequency (multiplier is 16000, not 16) - Add boundary check for out of range frequencies. - Use new flag to check if the order of the CB and freq. depends on the last set frequency. That is needed for some tuners or you can get static as a result. The flag is added for those tuners where I know that the datasheet indicates that this is necessary. - For this new check use the last set div value, not the last frequency as radio frequencies are always much higher due to the 16000 multiplier. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/video/msp3400.h | 8 ---- drivers/media/video/mt20xx.c | 12 +++--- drivers/media/video/tda8290.c | 4 +- drivers/media/video/tea5767.c | 18 ++++---- drivers/media/video/tuner-core.c | 85 +++++++++++++++++++++++--------------- drivers/media/video/tuner-simple.c | 44 ++++++++++---------- drivers/media/video/tuner-types.c | 6 +++ drivers/media/video/v4l2-common.c | 1 + include/media/tuner-types.h | 18 ++++++++ include/media/tuner.h | 8 ++-- include/media/v4l2-common.h | 7 ++++ 11 files changed, 129 insertions(+), 82 deletions(-) (limited to 'drivers/media/video/tuner-simple.c') diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400.h index 70a5ef8ba01..a9ac57d0700 100644 --- a/drivers/media/video/msp3400.h +++ b/drivers/media/video/msp3400.h @@ -6,14 +6,6 @@ /* ---------------------------------------------------------------------- */ -struct msp_matrix { - int input; - int output; -}; - -/* ioctl for MSP_SET_MATRIX will have to be registered */ -#define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix) - /* This macro is allowed for *constants* only, gcc must calculate it at compile time. Remember -- no floats in kernel mode */ #define MSP_CARRIER(freq) ((int)((float)(freq / 18.432) * (1 << 24))) diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c index 0bf1caac588..c7c9f3f8715 100644 --- a/drivers/media/video/mt20xx.c +++ b/drivers/media/video/mt20xx.c @@ -353,8 +353,8 @@ static int mt2032_init(struct i2c_client *c) } while (xok != 1 ); t->xogc=xogc; - t->tv_freq = mt2032_set_tv_freq; - t->radio_freq = mt2032_set_radio_freq; + t->set_tv_freq = mt2032_set_tv_freq; + t->set_radio_freq = mt2032_set_radio_freq; return(1); } @@ -481,8 +481,8 @@ static int mt2050_init(struct i2c_client *c) i2c_master_recv(c,buf,1); tuner_dbg("mt2050: sro is %x\n",buf[0]); - t->tv_freq = mt2050_set_tv_freq; - t->radio_freq = mt2050_set_radio_freq; + t->set_tv_freq = mt2050_set_tv_freq; + t->set_radio_freq = mt2050_set_radio_freq; return 0; } @@ -494,8 +494,8 @@ int microtune_init(struct i2c_client *c) int company_code; memset(buf,0,sizeof(buf)); - t->tv_freq = NULL; - t->radio_freq = NULL; + t->set_tv_freq = NULL; + t->set_radio_freq = NULL; t->standby = NULL; if (t->std & V4L2_STD_525_60) { tuner_dbg("pinnacle ntsc\n"); diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index 2498b76df42..7b4fb282ac8 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c @@ -567,8 +567,8 @@ int tda8290_init(struct i2c_client *c) } tuner_info("tuner: type set to %s\n", c->name); - t->tv_freq = set_tv_freq; - t->radio_freq = set_radio_freq; + t->set_tv_freq = set_tv_freq; + t->set_radio_freq = set_radio_freq; t->has_signal = has_signal; t->standby = standby; t->tda827x_lpsel = 0; diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c index 921fe72f23d..c2b98f81c19 100644 --- a/drivers/media/video/tea5767.c +++ b/drivers/media/video/tea5767.c @@ -62,7 +62,7 @@ extern int tuner_debug; #define TEA5767_PORT1_HIGH 0x01 -/* Forth register */ +/* Fourth register */ #define TEA5767_PORT2_HIGH 0x80 /* Chips stops working. Only I2C bus remains on */ #define TEA5767_STDBY 0x40 @@ -85,7 +85,7 @@ extern int tuner_debug; /* If activate PORT 1 indicates SEARCH or else it is used as PORT1 */ #define TEA5767_SRCH_IND 0x01 -/* Fiveth register */ +/* Fifth register */ /* By activating, it will use Xtal at 13 MHz as reference for divider */ #define TEA5767_PLLREF_ENABLE 0x80 @@ -109,13 +109,13 @@ extern int tuner_debug; #define TEA5767_STEREO_MASK 0x80 #define TEA5767_IF_CNTR_MASK 0x7f -/* Four register */ +/* Fourth register */ #define TEA5767_ADC_LEVEL_MASK 0xf0 /* should be 0 */ #define TEA5767_CHIP_ID_MASK 0x0f -/* Fiveth register */ +/* Fifth register */ /* Reserved for future extensions */ #define TEA5767_RESERVED_MASK 0xff @@ -220,19 +220,19 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n"); buffer[2] |= TEA5767_HIGH_LO_INJECT; buffer[4] |= TEA5767_PLLREF_ENABLE; - div = (frq * 4000 / 16 + 700000 + 225000 + 25000) / 50000; + div = (frq * (4000 / 16) + 700000 + 225000 + 25000) / 50000; break; case TEA5767_LOW_LO_13MHz: tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 13 MHz\n"); buffer[4] |= TEA5767_PLLREF_ENABLE; - div = (frq * 4000 / 16 - 700000 - 225000 + 25000) / 50000; + div = (frq * (4000 / 16) - 700000 - 225000 + 25000) / 50000; break; case TEA5767_LOW_LO_32768: tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n"); buffer[3] |= TEA5767_XTAL_32768; /* const 700=4000*175 Khz - to adjust freq to right value */ - div = ((frq * 4000 / 16 - 700000 - 225000) + 16384) >> 15; + div = ((frq * (4000 / 16) - 700000 - 225000) + 16384) >> 15; break; case TEA5767_HIGH_LO_32768: default: @@ -350,8 +350,8 @@ int tea5767_tuner_init(struct i2c_client *c) tuner_info("type set to %d (%s)\n", t->type, "Philips TEA5767HN FM Radio"); strlcpy(c->name, "tea5767", sizeof(c->name)); - t->tv_freq = set_tv_freq; - t->radio_freq = set_radio_freq; + t->set_tv_freq = set_tv_freq; + t->set_radio_freq = set_radio_freq; t->has_signal = tea5767_signal; t->is_stereo = tea5767_stereo; t->standby = tea5767_standby; diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index f30ef79d795..2995b22acb4 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -82,7 +82,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) tuner_warn ("tuner type not set\n"); return; } - if (NULL == t->tv_freq) { + if (NULL == t->set_tv_freq) { tuner_warn ("Tuner has no way to set tv freq\n"); return; } @@ -90,8 +90,14 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) tuner_dbg ("TV freq (%d.%02d) out of range (%d-%d)\n", freq / 16, freq % 16 * 100 / 16, tv_range[0], tv_range[1]); + /* V4L2 spec: if the freq is not possible then the closest + possible value should be selected */ + if (freq < tv_range[0] * 16) + freq = tv_range[0] * 16; + else + freq = tv_range[1] * 16; } - t->tv_freq(c, freq); + t->set_tv_freq(c, freq); } static void set_radio_freq(struct i2c_client *c, unsigned int freq) @@ -102,18 +108,23 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) tuner_warn ("tuner type not set\n"); return; } - if (NULL == t->radio_freq) { + if (NULL == t->set_radio_freq) { tuner_warn ("tuner has no way to set radio frequency\n"); return; } - if (freq <= radio_range[0] * 16000 || freq >= radio_range[1] * 16000) { + if (freq < radio_range[0] * 16000 || freq > radio_range[1] * 16000) { tuner_dbg ("radio freq (%d.%02d) out of range (%d-%d)\n", freq / 16000, freq % 16000 * 100 / 16000, radio_range[0], radio_range[1]); + /* V4L2 spec: if the freq is not possible then the closest + possible value should be selected */ + if (freq < radio_range[0] * 16000) + freq = radio_range[0] * 16000; + else + freq = radio_range[1] * 16000; } - t->radio_freq(c, freq); - return; + t->set_radio_freq(c, freq); } static void set_freq(struct i2c_client *c, unsigned long freq) @@ -125,15 +136,16 @@ static void set_freq(struct i2c_client *c, unsigned long freq) tuner_dbg("radio freq set to %lu.%02lu\n", freq / 16000, freq % 16000 * 100 / 16000); set_radio_freq(c, freq); + t->radio_freq = freq; break; case V4L2_TUNER_ANALOG_TV: case V4L2_TUNER_DIGITAL_TV: tuner_dbg("tv freq set to %lu.%02lu\n", freq / 16, freq % 16 * 100 / 16); set_tv_freq(c, freq); + t->tv_freq = freq; break; } - t->freq = freq; } static void set_type(struct i2c_client *c, unsigned int type, @@ -212,7 +224,7 @@ static void set_type(struct i2c_client *c, unsigned int type, if (t->mode_mask == T_UNINITIALIZED) t->mode_mask = new_mode_mask; - set_freq(c, t->freq); + set_freq(c, (V4L2_TUNER_RADIO == t->mode) ? t->radio_freq : t->tv_freq); tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", c->adapter->name, c->driver->driver.name, c->addr << 1, type, t->mode_mask); @@ -377,11 +389,11 @@ static void tuner_status(struct i2c_client *client) default: p = "undefined"; break; } if (t->mode == V4L2_TUNER_RADIO) { - freq = t->freq / 16000; - freq_fraction = (t->freq % 16000) * 100 / 16000; + freq = t->radio_freq / 16000; + freq_fraction = (t->radio_freq % 16000) * 100 / 16000; } else { - freq = t->freq / 16; - freq_fraction = (t->freq % 16) * 100 / 16; + freq = t->tv_freq / 16; + freq_fraction = (t->tv_freq % 16) * 100 / 16; } tuner_info("Tuner mode: %s\n", p); tuner_info("Frequency: %lu.%02lu MHz\n", freq, freq_fraction); @@ -456,7 +468,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) t->type = TUNER_TEA5767; t->mode_mask = T_RADIO; t->mode = T_STANDBY; - t->freq = 87.5 * 16; /* Sets freq to FM range */ + t->radio_freq = 87.5 * 16000; /* Sets freq to FM range */ default_mode_mask &= ~T_RADIO; goto register_client; @@ -469,7 +481,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) if (default_mode_mask != T_UNINITIALIZED) { tuner_dbg ("Setting mode_mask to 0x%02x\n", default_mode_mask); t->mode_mask = default_mode_mask; - t->freq = 400 * 16; /* Sets freq to VHF High */ + t->tv_freq = 400 * 16; /* Sets freq to VHF High */ + t->radio_freq = 87.5 * 16000; /* Sets freq to FM range */ default_mode_mask = T_UNINITIALIZED; } @@ -565,16 +578,18 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) set_addr(client, (struct tuner_setup *)arg); break; case AUDC_SET_RADIO: - set_mode(client,t,V4L2_TUNER_RADIO, "AUDC_SET_RADIO"); + if (set_mode(client, t, V4L2_TUNER_RADIO, "AUDC_SET_RADIO") + == EINVAL) + return 0; + if (t->radio_freq) + set_freq(client, t->radio_freq); break; case TUNER_SET_STANDBY: - { - if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) - return 0; - if (t->standby) - t->standby (client); - break; - } + if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) + return 0; + if (t->standby) + t->standby (client); + break; case VIDIOCSAUDIO: if (check_mode(t, "VIDIOCSAUDIO") == EINVAL) return 0; @@ -583,7 +598,6 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) /* Should be implemented, since bttv calls it */ tuner_dbg("VIDIOCSAUDIO not implemented.\n"); - break; /* --- v4l ioctls --- */ /* take care: bttv does userspace copying, we'll get a @@ -609,8 +623,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (vc->norm < ARRAY_SIZE(map)) t->std = map[vc->norm]; tuner_fixup_std(t); - if (t->freq) - set_tv_freq(client, t->freq); + if (t->tv_freq) + set_tv_freq(client, t->tv_freq); return 0; } case VIDIOCSFREQ: @@ -684,15 +698,14 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) t->std = *id; tuner_fixup_std(t); - if (t->freq) - set_freq(client, t->freq); + if (t->tv_freq) + set_freq(client, t->tv_freq); break; } case VIDIOC_S_FREQUENCY: { struct v4l2_frequency *f = arg; - t->freq = f->frequency; switch_v4l2(); if (V4L2_TUNER_RADIO == f->type && V4L2_TUNER_RADIO != t->mode) { @@ -700,7 +713,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) == EINVAL) return 0; } - set_freq(client,t->freq); + set_freq(client,f->frequency); break; } @@ -712,7 +725,8 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) return 0; switch_v4l2(); f->type = t->mode; - f->frequency = t->freq; + f->frequency = (V4L2_TUNER_RADIO == t->mode) ? + t->radio_freq : t->tv_freq; break; } case VIDIOC_G_TUNER: @@ -763,7 +777,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) if (V4L2_TUNER_RADIO == t->mode) { t->audmode = tuner->audmode; - set_radio_freq(client, t->freq); + set_radio_freq(client, t->radio_freq); } break; } @@ -791,8 +805,13 @@ static int tuner_resume(struct device *dev) struct tuner *t = i2c_get_clientdata (c); tuner_dbg ("resume\n"); - if (t->freq) - set_freq(c, t->freq); + if (V4L2_TUNER_RADIO == t->mode) { + if (t->radio_freq) + set_freq(c, t->radio_freq); + } else { + if (t->tv_freq) + set_freq(c, t->tv_freq); + } return 0; } diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index 3879262cf4c..37977ff4978 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c @@ -136,7 +136,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) u8 config, tuneraddr; u16 div; struct tunertype *tun; - unsigned char buffer[4]; + u8 buffer[4]; int rc, IFPCoff, i, j; tun = &tuners[t->type]; @@ -147,6 +147,11 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) continue; break; } + if (i == tun->params[j].count) { + tuner_dbg("TV frequency out of range (%d > %d)", + freq, tun->params[j].ranges[i - 1].limit); + freq = tun->params[j].ranges[--i].limit; + } config = tun->params[j].ranges[i].cb; /* i == 0 -> VHF_LO */ /* i == 1 -> VHF_HI */ @@ -239,20 +244,6 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) break; } - /* - * Philips FI1216MK2 remark from specification : - * for channel selection involving band switching, and to ensure - * smooth tuning to the desired channel without causing - * unnecessary charge pump action, it is recommended to consider - * the difference between wanted channel frequency and the - * current channel frequency. Unnecessary charge pump action - * will result in very low tuning voltage which may drive the - * oscillator to extreme conditions. - * - * Progfou: specification says to send config data before - * frequency in case (wanted frequency < current frequency). - */ - /* IFPCoff = Video Intermediate Frequency - Vif: 940 =16*58.75 NTSC/J (Japan) 732 =16*45.75 M/N STD @@ -284,7 +275,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) offset / 16, offset % 16 * 100 / 16, div); - if (t->type == TUNER_PHILIPS_SECAM && freq < t->freq) { + if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) { buffer[0] = tun->params[j].config; buffer[1] = config; buffer[2] = (div>>8) & 0x7f; @@ -295,6 +286,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) buffer[2] = tun->params[j].config; buffer[3] = config; } + t->last_div = div; tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", buffer[0],buffer[1],buffer[2],buffer[3]); @@ -337,8 +329,8 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) { struct tunertype *tun; struct tuner *t = i2c_get_clientdata(c); - unsigned char buffer[4]; - unsigned div; + u8 buffer[4]; + u16 div; int rc, j; tun = &tuners[t->type]; @@ -374,9 +366,19 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq) } buffer[0] = (div>>8) & 0x7f; buffer[1] = div & 0xff; + if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) { + buffer[0] = buffer[2]; + buffer[1] = buffer[3]; + buffer[2] = (div>>8) & 0x7f; + buffer[3] = div & 0xff; + } else { + buffer[0] = (div>>8) & 0x7f; + buffer[1] = div & 0xff; + } tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n", buffer[0],buffer[1],buffer[2],buffer[3]); + t->last_div = div; if (4 != (rc = i2c_master_send(c,buffer,4))) tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); @@ -390,10 +392,10 @@ int default_tuner_init(struct i2c_client *c) t->type, tuners[t->type].name); strlcpy(c->name, tuners[t->type].name, sizeof(c->name)); - t->tv_freq = default_set_tv_freq; - t->radio_freq = default_set_radio_freq; + t->set_tv_freq = default_set_tv_freq; + t->set_radio_freq = default_set_radio_freq; t->has_signal = tuner_signal; - t->is_stereo = tuner_stereo; + t->is_stereo = tuner_stereo; t->standby = NULL; return 0; diff --git a/drivers/media/video/tuner-types.c b/drivers/media/video/tuner-types.c index 32c9be4c5ca..6fe781798d8 100644 --- a/drivers/media/video/tuner-types.c +++ b/drivers/media/video/tuner-types.c @@ -81,6 +81,7 @@ static struct tuner_params tuner_philips_ntsc_params[] = { .ranges = tuner_philips_ntsc_ranges, .count = ARRAY_SIZE(tuner_philips_ntsc_ranges), .config = 0x8e, + .cb_first_if_lower_freq = 1, }, }; @@ -98,6 +99,7 @@ static struct tuner_params tuner_philips_secam_params[] = { .ranges = tuner_philips_secam_ranges, .count = ARRAY_SIZE(tuner_philips_secam_ranges), .config = 0x8e, + .cb_first_if_lower_freq = 1, }, }; @@ -115,6 +117,7 @@ static struct tuner_params tuner_philips_pal_params[] = { .ranges = tuner_philips_pal_ranges, .count = ARRAY_SIZE(tuner_philips_pal_ranges), .config = 0x8e, + .cb_first_if_lower_freq = 1, }, }; @@ -596,6 +599,7 @@ static struct tuner_params tuner_fm1216me_mk3_params[] = { .ranges = tuner_fm1216me_mk3_pal_ranges, .count = ARRAY_SIZE(tuner_fm1216me_mk3_pal_ranges), .config = 0x8e, + .cb_first_if_lower_freq = 1, }, }; @@ -670,6 +674,7 @@ static struct tuner_params tuner_fm1236_mk3_params[] = { .ranges = tuner_fm1236_mk3_ntsc_ranges, .count = ARRAY_SIZE(tuner_fm1236_mk3_ntsc_ranges), .config = 0x8e, + .cb_first_if_lower_freq = 1, }, }; @@ -784,6 +789,7 @@ static struct tuner_params tuner_tcl_2002n_params[] = { .ranges = tuner_tcl_2002n_ntsc_ranges, .count = ARRAY_SIZE(tuner_tcl_2002n_ntsc_ranges), .config = 0x8e, + .cb_first_if_lower_freq = 1, }, }; diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 5dbd7c1b362..cd2c4475525 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c @@ -306,6 +306,7 @@ static const char *v4l2_int_ioctls[] = { #endif [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO", [_IOC_NR(AUDC_SET_INPUT)] = "AUDC_SET_INPUT", + [_IOC_NR(MSP_SET_MATRIX)] = "MSP_SET_MATRIX", [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR", [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", diff --git a/include/media/tuner-types.h b/include/media/tuner-types.h index 75669318899..b37d59d5a10 100644 --- a/include/media/tuner-types.h +++ b/include/media/tuner-types.h @@ -20,6 +20,24 @@ struct tuner_range { struct tuner_params { enum param_type type; unsigned int tda988x; + /* Many Philips based tuners have a comment like this in their + * datasheet: + * + * For channel selection involving band switching, and to ensure + * smooth tuning to the desired channel without causing + * unnecessary charge pump action, it is recommended to consider + * the difference between wanted channel frequency and the + * current channel frequency. Unnecessary charge pump action + * will result in very low tuning voltage which may drive the + * oscillator to extreme conditions. + * + * Set this flag to 1 if this tuner needs this check. + * + * I tested this for PAL by first setting the TV frequency to + * 203 MHz and then switching to 96.6 MHz FM radio. The result was + * static unless the control byte was sent first. + */ + unsigned int cb_first_if_lower_freq:1; unsigned char config; /* to be moved into struct tuner_range for dvb-pll merge */ unsigned int count; diff --git a/include/media/tuner.h b/include/media/tuner.h index a1d63787bc0..a5beeac495c 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -179,7 +179,9 @@ struct tuner { unsigned int mode; unsigned int mode_mask; /* Combination of allowable modes */ - unsigned int freq; /* keep track of the current settings */ + unsigned int tv_freq; /* keep track of the current settings */ + unsigned int radio_freq; + u16 last_div; unsigned int audmode; v4l2_std_id std; @@ -197,8 +199,8 @@ struct tuner { unsigned int sgIF; /* function ptrs */ - void (*tv_freq)(struct i2c_client *c, unsigned int freq); - void (*radio_freq)(struct i2c_client *c, unsigned int freq); + void (*set_tv_freq)(struct i2c_client *c, unsigned int freq); + void (*set_radio_freq)(struct i2c_client *c, unsigned int freq); int (*has_signal)(struct i2c_client *c); int (*is_stereo)(struct i2c_client *c); void (*standby)(struct i2c_client *c); diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index c74052abb18..d4030a7e16e 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -120,6 +120,13 @@ enum v4l2_chip_ident { /* select from TV,radio,extern,MUTE */ #define AUDC_SET_INPUT _IOW('d',89,int) +/* msp3400 ioctl: will be removed in the near future */ +struct msp_matrix { + int input; + int output; +}; +#define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix) + /* tuner ioctls */ /* Sets tuner type and its I2C addr */ #define TUNER_SET_TYPE_ADDR _IOW('d',90,int) -- cgit v1.2.3