diff options
author | Mauro Carvalho Chehab <devnull@localhost> | 2005-06-08 01:28:09 +0000 |
---|---|---|
committer | Mauro Carvalho Chehab <devnull@localhost> | 2005-06-08 01:28:09 +0000 |
commit | b32a9aff0d1360cb3beb9e3c0f91c84f39b95679 (patch) | |
tree | 94b7baa93e855b05f735a89b6ff45e7035833067 | |
parent | 874f203c1669f752eeb477bf980cb060b135dc13 (diff) | |
download | mediapointer-dvb-s2-b32a9aff0d1360cb3beb9e3c0f91c84f39b95679.tar.gz mediapointer-dvb-s2-b32a9aff0d1360cb3beb9e3c0f91c84f39b95679.tar.bz2 |
Lots of change to provide an elegant way to select radio I2C address.
It should be better tested and expanded to other *-cards.c.
* cx88-cards.c, cx88-core.c, cx88-i2c.c, cx88-video.c, cx88.h, tea5767.c, tuner-core.c,
tuner-simple.c, tuner.h:
- Improved radio tuner support.
- There is a new option to cx88 radio=xxx,xxx,xxx for radio adapters;
- cx88-boards now specifies radio_type, tuner_addr and radio_addr
- ADDR_UNSET macro means find default radio/video tuner
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-cards.c | 97 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-core.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-i2c.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88-video.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/video/cx88/cx88.h | 8 | ||||
-rw-r--r-- | linux/drivers/media/video/tea5767.c | 38 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-core.c | 93 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-simple.c | 24 | ||||
-rw-r--r-- | linux/include/media/tuner.h | 22 | ||||
-rw-r--r-- | v4l/ChangeLog | 11 |
10 files changed, 240 insertions, 107 deletions
diff --git a/linux/drivers/media/video/cx88/cx88-cards.c b/linux/drivers/media/video/cx88/cx88-cards.c index 4ecb24d16..98ccd9aab 100644 --- a/linux/drivers/media/video/cx88/cx88-cards.c +++ b/linux/drivers/media/video/cx88/cx88-cards.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-cards.c,v 1.75 2005/06/03 18:00:42 mchehab Exp $ + * $Id: cx88-cards.c,v 1.76 2005/06/08 01:28:09 mchehab Exp $ * * device driver for Conexant 2388x based TV cards * card-specific stuff. @@ -35,6 +35,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_UNKNOWN] = { .name = "UNKNOWN/GENERIC", .tuner_type = UNSET, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_COMPOSITE1, .vmux = 0, @@ -52,6 +55,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_HAUPPAUGE] = { .name = "Hauppauge WinTV 34xxx models", .tuner_type = UNSET, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -78,6 +84,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_GDI] = { .name = "GDI Black Gold", .tuner_type = UNSET, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -86,6 +95,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_PIXELVIEW] = { .name = "PixelView", .tuner_type = TUNER_PHILIPS_PAL, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -105,6 +117,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_ATI_WONDER_PRO] = { .name = "ATI TV Wonder Pro", .tuner_type = TUNER_PHILIPS_4IN1, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -123,6 +138,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_WINFAST2000XP_EXPERT] = { .name = "Leadtek Winfast 2000XP Expert", .tuner_type = TUNER_PHILIPS_4IN1, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -157,6 +175,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_AVERTV_303] = { .name = "AverTV Studio 303 (M126)", .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -180,6 +201,9 @@ struct cx88_board cx88_boards[] = { // values for PAL from DScaler .name = "MSI TV-@nywhere Master", .tuner_type = TUNER_MT2032, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -207,6 +231,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_WINFAST_DV2000] = { .name = "Leadtek Winfast DV2000", .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -243,6 +270,9 @@ struct cx88_board cx88_boards[] = { // gpio values for PAL version from regspy by DScaler .name = "Leadtek PVR 2000", .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -266,7 +296,10 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_IODATA_GVVCP3PCI] = { .name = "IODATA GV-VCP3/PCI", .tuner_type = TUNER_ABSENT, - .input = {{ + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, + .input = {{ .type = CX88_VMUX_COMPOSITE1, .vmux = 0, },{ @@ -280,6 +313,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_PROLINK_PLAYTVPVR] = { .name = "Prolink PlayTV PVR", .tuner_type = TUNER_PHILIPS_FM1236_MK3, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -302,7 +338,10 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_ASUS_PVR_416] = { .name = "ASUS PVR-416", .tuner_type = TUNER_PHILIPS_FM1236_MK3, - .tda9887_conf = TDA9887_PRESENT, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, + .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -321,6 +360,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_MSI_TVANYWHERE] = { .name = "MSI TV-@nywhere", .tuner_type = TUNER_MT2032, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -342,6 +384,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_KWORLD_DVB_T] = { .name = "KWorld/VStream XPert DVB-T", .tuner_type = TUNER_ABSENT, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, @@ -358,6 +403,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = { .name = "DVICO FusionHDTV DVB-T1", .tuner_type = TUNER_ABSENT, /* No analog tuner */ + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, @@ -371,7 +419,10 @@ struct cx88_board cx88_boards[] = { }, [CX88_BOARD_KWORLD_LTV883] = { .name = "KWorld LTV883RF", - .tuner_type = TUNER_TNF_8831BGFF, + .tuner_type = TUNER_TNF_8831BGFF, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -397,6 +448,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD] = { .name = "DViCO - FusionHDTV 3 Gold", .tuner_type = TUNER_MICROTUNE_4042FI5, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, /* GPIO[0] resets DT3302 DTV receiver 0 - reset asserted @@ -432,6 +486,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_HAUPPAUGE_DVB_T1] = { .name = "Hauppauge Nova-T DVB-T", .tuner_type = TUNER_ABSENT, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_DVB, .vmux = 0, @@ -441,6 +498,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_CONEXANT_DVB_T1] = { .name = "Conexant DVB-T reference design", .tuner_type = TUNER_ABSENT, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_DVB, .vmux = 0, @@ -450,6 +510,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_PROVIDEO_PV259] = { .name = "Provideo PV259", .tuner_type = TUNER_PHILIPS_FQ1216ME, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -459,6 +522,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = { .name = "DVICO FusionHDTV DVB-T Plus", .tuner_type = TUNER_ABSENT, /* No analog tuner */ + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, @@ -473,6 +539,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_DNTV_LIVE_DVB_T] = { .name = "digitalnow DNTV Live! DVB-T", .tuner_type = TUNER_ABSENT, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_COMPOSITE1, .vmux = 1, @@ -489,6 +558,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_PCHDTV_HD3000] = { .name = "pcHDTV HD3000 HDTV", .tuner_type = TUNER_THOMSON_DTT7610, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -526,6 +598,9 @@ struct cx88_board cx88_boards[] = { // GPIO values obtained from regspy, courtesy Sean Covel .name = "Hauppauge WinTV 28xxx (Roslyn) models", .tuner_type = UNSET, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -555,6 +630,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_DIGITALLOGIC_MEC] = { .name = "Digital-Logic MICROSPACE Entertainment Center (MEC)", .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -578,6 +656,9 @@ struct cx88_board cx88_boards[] = { [CX88_BOARD_IODATA_GVBCTV7E] = { .name = "IODATA GV/BCTV7E", .tuner_type = TUNER_PHILIPS_FQ1286, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, .tda9887_conf = TDA9887_PRESENT, .input = {{ .type = CX88_VMUX_TELEVISION, @@ -597,6 +678,9 @@ struct cx88_board cx88_boards[] = { .name = "PixelView PlayTV Ultra Pro (Stereo)", /* May be also TUNER_YMEC_TVF_5533MF for NTSC/M or PAL/M */ .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, + .radio_type = TUNER_TEA5767, + .tuner_addr = 0xc2>>1, + .radio_addr = 0xc0>>1, .input = {{ .type = CX88_VMUX_TELEVISION, .vmux = 0, @@ -617,7 +701,10 @@ struct cx88_board cx88_boards[] = { }, [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T] = { .name = "DViCO - FusionHDTV 3 Gold-T", - .tuner_type = TUNER_THOMSON_DTT7611, + .tuner_type = TUNER_THOMSON_DTT7611, + .radio_type = UNSET, + .tuner_addr = ADDR_UNSET, + .radio_addr = ADDR_UNSET, /* See DViCO FusionHDTV 3 Gold for GPIO documentation. */ .input = {{ .type = CX88_VMUX_TELEVISION, diff --git a/linux/drivers/media/video/cx88/cx88-core.c b/linux/drivers/media/video/cx88/cx88-core.c index 09efd73ac..e7d623dc4 100644 --- a/linux/drivers/media/video/cx88/cx88-core.c +++ b/linux/drivers/media/video/cx88/cx88-core.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-core.c,v 1.26 2005/06/01 03:33:05 mchehab Exp $ + * $Id: cx88-core.c,v 1.27 2005/06/08 01:28:09 mchehab Exp $ * * device driver for Conexant 2388x based TV cards * driver core @@ -51,18 +51,22 @@ module_param(latency,int,0444); MODULE_PARM_DESC(latency,"pci latency timer"); static unsigned int tuner[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; +static unsigned int radio[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; static unsigned int card[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) static int dummy; module_param_array(tuner, int, dummy, 0444); +module_param_array(radio, int, dummy, 0444); module_param_array(card, int, dummy, 0444); #else module_param_array(tuner, int, NULL, 0444); +module_param_array(radio, int, NULL, 0444); module_param_array(card, int, NULL, 0444); #endif MODULE_PARM_DESC(tuner,"tuner type"); +MODULE_PARM_DESC(radio,"radio tuner type"); MODULE_PARM_DESC(card,"card type"); static unsigned int nicam = 0; @@ -1181,8 +1185,20 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) "insmod option" : "autodetected"); core->tuner_type = tuner[core->nr]; + core->radio_type = radio[core->nr]; if (UNSET == core->tuner_type) core->tuner_type = cx88_boards[core->board].tuner_type; + if (UNSET == core->radio_type) + core->radio_type = cx88_boards[core->board].radio_type; + if (!core->tuner_addr) + core->tuner_addr = cx88_boards[core->board].tuner_addr; + if (!core->radio_addr) + core->radio_addr = cx88_boards[core->board].radio_addr; + + printk(KERN_INFO "TV tuner %d at 0x%02x, Radio tuner %d at 0x%02x\n", + core->tuner_type, core->tuner_addr<<1, + core->radio_type, core->radio_addr<<1); + core->tda9887_conf = cx88_boards[core->board].tda9887_conf; /* init hardware */ diff --git a/linux/drivers/media/video/cx88/cx88-i2c.c b/linux/drivers/media/video/cx88/cx88-i2c.c index d15eae3ff..012ab1c5b 100644 --- a/linux/drivers/media/video/cx88/cx88-i2c.c +++ b/linux/drivers/media/video/cx88/cx88-i2c.c @@ -1,5 +1,5 @@ /* - $Id: cx88-i2c.c,v 1.20 2005/02/15 15:59:35 kraxel Exp $ + $Id: cx88-i2c.c,v 1.21 2005/06/08 01:28:09 mchehab Exp $ cx88-i2c.c -- all the i2c code is here @@ -91,6 +91,7 @@ static int cx8800_bit_getsda(void *data) static int attach_inform(struct i2c_client *client) { + struct tuner_addr tun_addr; struct cx88_core *core = i2c_get_adapdata(client->adapter); dprintk(1, "i2c attach [addr=0x%x,client=%s]\n", @@ -98,8 +99,19 @@ static int attach_inform(struct i2c_client *client) if (!client->driver->command) return 0; - if (core->tuner_type != UNSET) - client->driver->command(client, TUNER_SET_TYPE, &core->tuner_type); + if (core->radio_type != UNSET) { + tun_addr.v4l2_tuner = V4L2_TUNER_RADIO; + tun_addr.type = core->radio_type; + tun_addr.addr = core->radio_addr; + client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr); + } + if (core->tuner_type != UNSET) { + tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV; + tun_addr.type = core->tuner_type; + tun_addr.addr = core->tuner_addr; + client->driver->command(client,TUNER_SET_TYPE_ADDR, &tun_addr); + } + if (core->tda9887_conf) client->driver->command(client, TDA9887_SET_CONFIG, &core->tda9887_conf); return 0; diff --git a/linux/drivers/media/video/cx88/cx88-video.c b/linux/drivers/media/video/cx88/cx88-video.c index 16a11afd2..a1e40f6f3 100644 --- a/linux/drivers/media/video/cx88/cx88-video.c +++ b/linux/drivers/media/video/cx88/cx88-video.c @@ -1,5 +1,5 @@ /* - * $Id: cx88-video.c,v 1.59 2005/06/03 13:31:51 mchehab Exp $ + * $Id: cx88-video.c,v 1.60 2005/06/08 01:28:09 mchehab Exp $ * * device driver for Conexant 2388x based TV cards * video4linux video interface @@ -2014,6 +2014,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, { struct cx8800_dev *dev; struct cx88_core *core; + struct tuner_addr tun_addr; int err; dev = kmalloc(sizeof(*dev),GFP_KERNEL); @@ -2087,8 +2088,19 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, request_module("tuner"); if (core->tda9887_conf) request_module("tda9887"); - if (core->tuner_type != UNSET) - cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE,&core->tuner_type); + if (core->radio_type != UNSET) { + tun_addr.v4l2_tuner = V4L2_TUNER_RADIO; + tun_addr.type = core->radio_type; + tun_addr.addr = core->radio_addr; + cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE_ADDR, &tun_addr); + } + if (core->tuner_type != UNSET) { + tun_addr.v4l2_tuner = V4L2_TUNER_ANALOG_TV; + tun_addr.type = core->tuner_type; + tun_addr.addr = core->tuner_addr; + cx88_call_i2c_clients(dev->core,TUNER_SET_TYPE_ADDR, &tun_addr); + } + if (core->tda9887_conf) cx88_call_i2c_clients(dev->core,TDA9887_SET_CONFIG,&core->tda9887_conf); diff --git a/linux/drivers/media/video/cx88/cx88.h b/linux/drivers/media/video/cx88/cx88.h index 4984f035c..5f16f42e9 100644 --- a/linux/drivers/media/video/cx88/cx88.h +++ b/linux/drivers/media/video/cx88/cx88.h @@ -1,5 +1,5 @@ /* - * $Id: cx88.h,v 1.60 2005/06/05 05:53:45 mchehab Exp $ + * $Id: cx88.h,v 1.61 2005/06/08 01:28:09 mchehab Exp $ * * v4l2 device driver for cx2388x based TV cards * @@ -195,6 +195,9 @@ struct cx88_input { struct cx88_board { char *name; unsigned int tuner_type; + unsigned int radio_type; + unsigned char tuner_addr; + unsigned char radio_addr; int tda9887_conf; struct cx88_input input[8]; struct cx88_input radio; @@ -265,6 +268,9 @@ struct cx88_core { /* config info -- analog */ unsigned int board; unsigned int tuner_type; + unsigned int radio_type; + unsigned char tuner_addr; + unsigned char radio_addr; unsigned int tda9887_conf; unsigned int has_radio; diff --git a/linux/drivers/media/video/tea5767.c b/linux/drivers/media/video/tea5767.c index 94b69fb43..3539babce 100644 --- a/linux/drivers/media/video/tea5767.c +++ b/linux/drivers/media/video/tea5767.c @@ -2,7 +2,7 @@ * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview * I2C address is allways 0xC0. * - * $Id: tea5767.c,v 1.4 2005/06/07 18:02:26 nsh Exp $ + * $Id: tea5767.c,v 1.5 2005/06/08 01:28:09 mchehab Exp $ * * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) * This code is placed under the terms of the GNU General Public License @@ -120,14 +120,6 @@ #define TEA5767_RESERVED_MASK 0xff -enum v4l_radio_tuner { - RADIO_TUNER_UNSET = 0, - TEA5767_HIGH_LO_32768 = 1, - TEA5767_LOW_LO_32768 = 2, - TEA5767_HIGH_LO_13MHz = 3, - TEA5767_LOW_LO_13MHz = 4, -}; - static void set_tv_freq(struct i2c_client *c, unsigned int freq) { struct tuner *t = i2c_get_clientdata(c); @@ -158,7 +150,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) frq = 20*(frq/16)+radio_frq[frq%16]; buffer[2] = TEA5767_PORT1_HIGH; - buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL | TEA5767_ST_NOISE_CTL; + buffer[3] = TEA5767_PORT2_HIGH | TEA5767_HIGH_CUT_CTRL | TEA5767_ST_NOISE_CTL | TEA5767_JAPAN_BAND; buffer[4]=0; switch (t->type) { @@ -186,7 +178,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq) buffer[2] |= TEA5767_HIGH_LO_INJECT; buffer[3] |= TEA5767_XTAL_32768; - div = (1000*(frq*4000/20+225)+16384)/32768; + div = (1000*(frq*4000/20+700+225)+16384)/32768; break; } buffer[0] = (div>>8) & 0x3f; @@ -271,28 +263,16 @@ static int tea5767_stereo(struct i2c_client *c) int tea5767_tuner_init(struct i2c_client *c) { - /* TEA5767 is always on 0xC0, according with Philips datasheet */ - struct tuner_addr tun_addr = { V4L2_TUNER_RADIO, 0xc0>>1 }; - struct tuner *t = i2c_get_clientdata(c); - /*************************************************************************** - HACKING FOR TESTING PURPOSES ONLY. Should have an option to configure - ***************************************************************************/ - t->type= TEA5767_LOW_LO_32768; - strlcpy(c->name, "TEA5767", sizeof("TEA5767")); - tuner_info("type set to TEA5797\n"); - - if (c->driver->command) { - c->driver->command(c, TUNER_SET_ADDR, &tun_addr); - } else { - tuner_warn("TAE5797 Couldn't set Radio tuner I2C address to 0xc0\n"); - return -1; - } - + tuner_info("type set to %d (%s)\n", + t->type, TEA5767_TUNER_NAME); + strlcpy(c->name, TEA5767_TUNER_NAME, sizeof(c->name)); + t->tv_freq = set_tv_freq; t->radio_freq = set_radio_freq; t->has_signal = tea5767_signal; t->is_stereo = tea5767_stereo; - return 0; + + return (0); } diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index 9b449b954..a33e64481 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -1,5 +1,5 @@ /* - * $Id: tuner-core.c,v 1.10 2005/06/06 04:59:29 mchehab Exp $ + * $Id: tuner-core.c,v 1.11 2005/06/08 01:28:09 mchehab Exp $ * * i2c tv tuner chip device driver * core core, i.e. kernel interfaces, registering and so on @@ -68,7 +68,7 @@ MODULE_LICENSE("GPL"); static int this_adap; #ifdef CONFIG_TUNER_MULTI_I2C -static unsigned short tv_tuner, radio_tuner; +static unsigned short first_tuner, tv_tuner, radio_tuner; #endif static struct i2c_driver driver; @@ -76,7 +76,7 @@ static struct i2c_client client_template; /* ---------------------------------------------------------------------- */ -// Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz +/* Set tuner frequency, freq in Units of 62.5kHz = 1/16MHz */ static void set_tv_freq(struct i2c_client *c, unsigned int freq) { struct tuner *t = i2c_get_clientdata(c); @@ -142,33 +142,12 @@ static void set_freq(struct i2c_client *c, unsigned long freq) t->freq = freq; } -#ifdef CONFIG_TUNER_MULTI_I2C -static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr) -{ - struct tuner *t = i2c_get_clientdata(c); - - switch (tun_addr->type) { - case V4L2_TUNER_RADIO: - radio_tuner=tun_addr->addr; - tuner_dbg("radio tuner set to I2C address 0x%02x\n",radio_tuner<<1); - - break; - default: - tv_tuner=tun_addr->addr; - tuner_dbg("TV tuner set to I2C address 0x%02x\n",tv_tuner<<1); - break; - } -} -#else -#define set_addr(c,tun_addr) -#endif - static void set_type(struct i2c_client *c, unsigned int type) { struct tuner *t = i2c_get_clientdata(c); /* sanity check */ - if (type == UNSET || type == TUNER_ABSENT) + if (type == UNSET || type == TUNER_ABSENT) return; if (type >= tuner_count) return; @@ -192,8 +171,7 @@ static void set_type(struct i2c_client *c, unsigned int type) case TUNER_PHILIPS_TDA8290: tda8290_init(c); break; - case TUNER_TEA5797: - tuner_dbg("TEA5767 selected."); + case TUNER_TEA5767: tea5767_tuner_init(c); break; default: @@ -202,6 +180,50 @@ static void set_type(struct i2c_client *c, unsigned int type) } } +#ifdef CONFIG_TUNER_MULTI_I2C +#define CHECK_ADDR(tp,cmd) if (client->addr!=tp) { \ + tuner_info ("Cmd %s to addr 0x%02x rejected.\n",cmd,client->addr<<1); \ + return 0; } +#define CHECK_MODE(cmd) if (t->mode == V4L2_TUNER_RADIO) { \ + CHECK_ADDR(radio_tuner,cmd) } else { CHECK_ADDR(tv_tuner,cmd); } +#else +#define CHECK_ADDR(tp,cmd) +#define CHECK_MODE(cmd) +#endif + +#ifdef CONFIG_TUNER_MULTI_I2C + +static void set_addr(struct i2c_client *c, struct tuner_addr *tun_addr) +{ + /* ADDR_UNSET defaults to first available tuner */ + if ( tun_addr->addr == ADDR_UNSET ) { + if (first_tuner != c->addr) + return; + switch (tun_addr->v4l2_tuner) { + case V4L2_TUNER_RADIO: + radio_tuner=c->addr; + break; + default: + tv_tuner=c->addr; + break; + } + } else { + /* Sets tuner to its configured value */ + switch (tun_addr->v4l2_tuner) { + case V4L2_TUNER_RADIO: + radio_tuner=tun_addr->addr; + break; + default: + tv_tuner=tun_addr->addr; + break; + } + } + set_type(c,tun_addr->type); +} +#else +#define set_addr(c,tun_addr) set_type(c,tun_addr->type) +#endif + static char pal[] = "-"; module_param_string(pal, pal, sizeof(pal), 0644); @@ -246,6 +268,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) #else /* by default, first I2C card is both tv and radio tuner */ if (this_adap == 0) { + first_tuner = addr; tv_tuner = addr; radio_tuner = addr; } @@ -262,7 +285,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) memcpy(&t->i2c,&client_template,sizeof(struct i2c_client)); i2c_set_clientdata(&t->i2c, t); t->type = UNSET; - t->radio_if2 = 10700*1000; // 10.7MHz - FM radio + t->radio_if2 = 10700*1000; /* 10.7MHz - FM radio */ i2c_attach_client(&t->i2c); tuner_info("chip found @ 0x%x (%s)\n", @@ -282,6 +305,7 @@ static int tuner_probe(struct i2c_adapter *adap) this_adap = 0; #ifdef CONFIG_TUNER_MULTI_I2C + first_tuner = 0; tv_tuner = 0; radio_tuner = 0; #endif @@ -313,17 +337,6 @@ static int tuner_detach(struct i2c_client *client) tuner_info("ignore v4l1 call\n"); \ return 0; } -#ifdef CONFIG_TUNER_MULTI_I2C -#define CHECK_ADDR(tp,cmd) if (client->addr!=tp) { \ - tuner_info ("Cmd %s to addr 0x%02x rejected.\n",cmd,client->addr<<1); \ - return 0; } -#define CHECK_MODE(cmd) if (t->mode == V4L2_TUNER_RADIO) { \ - CHECK_ADDR(radio_tuner,cmd) } else { CHECK_ADDR(tv_tuner,cmd); } -#else -#define CHECK_ADDR(tp,cmd) -#define CHECK_MODE(cmd) -#endif - static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) { @@ -335,7 +348,7 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) case TUNER_SET_TYPE: set_type(client,*iarg); break; - case TUNER_SET_ADDR: + case TUNER_SET_TYPE_ADDR: set_addr(client,(struct tuner_addr *)arg); break; case AUDC_SET_RADIO: diff --git a/linux/drivers/media/video/tuner-simple.c b/linux/drivers/media/video/tuner-simple.c index e33ae6ebe..a43ac3553 100644 --- a/linux/drivers/media/video/tuner-simple.c +++ b/linux/drivers/media/video/tuner-simple.c @@ -1,5 +1,5 @@ /* - * $Id: tuner-simple.c,v 1.19 2005/06/07 19:00:38 nsh Exp $ + * $Id: tuner-simple.c,v 1.20 2005/06/08 01:28:09 mchehab Exp $ * * i2c tv tuner chip device driver * controls all those simple 4-control-bytes style tuners. @@ -222,6 +222,10 @@ static struct tunertype tuners[] = { 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, { "Tena TNF9533-D/IF", LGINNOTEK, PAL, 16*160.25, 16*464.25, 0x01,0x02,0x08,0x8e,623}, + + /* This entry is for TEA5767 FM radio only chip used on several boards w/TV tuner */ + { TEA5767_TUNER_NAME, Philips, RADIO, + -1, -1, 0, 0, 0, TEA5767_LOW_LO_32768,0}, }; unsigned const int tuner_count = ARRAY_SIZE(tuners); @@ -474,24 +478,6 @@ int default_tuner_init(struct i2c_client *c) { struct tuner *t = i2c_get_clientdata(c); - switch (t->type) { - case TUNER_YMEC_TVF_5533MF: - { - struct tuner_addr tun_addr = { V4L2_TUNER_ANALOG_TV, 0xc2>>1 }; - - if (c->driver->command) { - c->driver->command(c, TUNER_SET_ADDR, &tun_addr); - if (c->addr==0xC0>>1) { - tea5767_tuner_init(c); - return (0); - } - } else { - tuner_warn("Couldn't set TV tuner I2C address to 0x%02x\n",tun_addr.addr<<1); - } - break; - } - } - tuner_info("type set to %d (%s)\n", t->type, tuners[t->type].name); strlcpy(c->name, tuners[t->type].name, sizeof(c->name)); diff --git a/linux/include/media/tuner.h b/linux/include/media/tuner.h index 0ee14b325..03647c73d 100644 --- a/linux/include/media/tuner.h +++ b/linux/include/media/tuner.h @@ -25,8 +25,7 @@ #include "id.h" -/* Negative numbers reserved for radio tuners on TV cards */ -#define TUNER_TEA5797 -1 +#define ADDR_UNSET (255) #define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ #define TUNER_PHILIPS_PAL_I 1 @@ -105,6 +104,9 @@ #define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */ #define TUNER_THOMSON_DTT7611 60 #define TUNER_TENA_9533_DI 61 +#define TUNER_TEA5767 62 /* Only FM Radio Tuner */ + +#define TEA5767_TUNER_NAME "Philips TEA5767HN FM Radio" #define NOTUNER 0 #define PAL 1 /* PAL_BG */ @@ -112,6 +114,7 @@ #define NTSC 3 #define SECAM 4 #define ATSC 5 +#define RADIO 6 #define NoTuner 0 #define Philips 1 @@ -127,9 +130,17 @@ #define TCL 11 #define THOMSON 12 +enum v4l_radio_tuner { + TEA5767_LOW_LO_32768 = 0, + TEA5767_HIGH_LO_32768 = 1, + TEA5767_LOW_LO_13MHz = 2, + TEA5767_HIGH_LO_13MHz = 3, +}; + + #define TUNER_SET_TYPE _IOW('t',1,int) /* set tuner type */ #define TUNER_SET_TVFREQ _IOW('t',2,int) /* set tv freq */ -#define TUNER_SET_ADDR _IOW('T',3,int) /* Chooses tuner I2C address */ +#define TUNER_SET_TYPE_ADDR _IOW('T',3,int) /* set tuner type and I2C addr */ #define TDA9887_SET_CONFIG _IOW('t',5,int) @@ -154,8 +165,9 @@ #define I2C_ADDR_TDA8275 0x61 struct tuner_addr { - enum v4l2_tuner_type type; - unsigned short addr; + enum v4l2_tuner_type v4l2_tuner; + unsigned int type; + unsigned short addr; }; struct tuner { diff --git a/v4l/ChangeLog b/v4l/ChangeLog index 0024425cb..43c564818 100644 --- a/v4l/ChangeLog +++ b/v4l/ChangeLog @@ -1,3 +1,12 @@ +2005-06-08 01:25 mchehab + * cx88-cards.c, cx88-core.c, cx88-i2c.c, cx88-video.c, cx88.h, tea5767.c, tuner-core.c, + tuner-simple.c, tuner.h: + + - Improved radio tuner support. + - There is a new option to cx88 radio=xxx,xxx,xxx for radio adapters; + - cx88-boards now specifies radio_type, tuner_addr and radio_addr + - ADDR_UNSET macro means find default radio/video tuner + 2005-06-07 22:55 nsh * v4l1-compat, tuner-core.c, tuner-simple.c, tda9887.c: @@ -1211,7 +1220,7 @@ saa7134-reg.h, saa7134-ts.c, saa7134-tvaudio.c, saa7134-vbi.c, saa7134-video.c, saa7134.h, video-buf.c, video-buf.h: - - added a bunch of $Id: ChangeLog,v 1.27 2005/06/07 19:00:38 nsh Exp $ tags. + - added a bunch of Id tags. 2004-09-15 17:35 kraxel |