aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa7134-cards.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-04-22 13:45:27 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:07:45 -0400
commitbc36a686a65dd9b941463ff894a3868c62851186 (patch)
treed7321c32ce3ac1173ad1dc6c431824db2cc8e4e5 /drivers/media/video/saa7134/saa7134-cards.c
parent446018d80736ab16a117ce0db5a20467c91a0f90 (diff)
V4L/DVB (7262): Add support for xc3028-based boards
This patch adds support for the following saa7134 xc3028 based boards: 132 -> AVerMedia Cardbus TV/Radio (E506R) [1461:f436] 133 -> AVerMedia Hybrid TV/Radio (A16D) [1461:f936] 134 -> Avermedia M115 [1461:a836] 135 -> Compro VideoMate T750 [185b:c900] This is based on a original patch thanks to Markus Rechberger that added xc3028 gpio init code for the above boards. This patch moves saa7134_tuner_callback to saa7134-cards, originally used only by tda8290 DVB-S boards. The callback was made more generic to support other tuners. Currently, it supports both tda8290 and xc2028/xc3028 tuners. Added also the basis for xc5000 tuner callback. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-cards.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c230
1 files changed, 217 insertions, 13 deletions
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index f9c85b7cba1a..6fde042ee317 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -22,9 +22,12 @@
22 22
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/i2c.h>
26#include <linux/i2c-algo-bit.h>
25 27
26#include "saa7134-reg.h" 28#include "saa7134-reg.h"
27#include "saa7134.h" 29#include "saa7134.h"
30#include "tuner-xc2028.h"
28#include <media/v4l2-common.h> 31#include <media/v4l2-common.h>
29#include <media/tveeprom.h> 32#include <media/tveeprom.h>
30 33
@@ -4064,6 +4067,97 @@ struct saa7134_board saa7134_boards[] = {
4064 .gpio = 0x0200000, 4067 .gpio = 0x0200000,
4065 }, 4068 },
4066 }, 4069 },
4070 [SAA7134_BOARD_AVERMEDIA_CARDBUS_506] = {
4071 .name = "AVerMedia Cardbus TV/Radio (E506R)",
4072 .audio_clock = 0x187de7,
4073 .tuner_type = TUNER_XC2028,
4074 /*
4075 TODO:
4076 .mpeg = SAA7134_MPEG_DVB,
4077 */
4078
4079 .inputs = {{
4080 .name = name_tv,
4081 .vmux = 1,
4082 .amux = TV,
4083 .tv = 1,
4084 }, {
4085 .name = name_comp1,
4086 .vmux = 3,
4087 .amux = LINE2,
4088 }, {
4089 .name = name_svideo,
4090 .vmux = 8,
4091 .amux = LINE1,
4092 } },
4093 .radio = {
4094 .name = name_radio,
4095 .amux = TV,
4096 },
4097 },
4098 [SAA7134_BOARD_AVERMEDIA_A16D] = {
4099 .name = "AVerMedia Hybrid TV/Radio (A16D)",
4100 .audio_clock = 0x187de7,
4101 .tuner_type = TUNER_XC2028,
4102 .inputs = {{
4103 .name = name_tv,
4104 .vmux = 1,
4105 .amux = TV,
4106 .tv = 1,
4107 }, {
4108 .name = name_svideo,
4109 .vmux = 8,
4110 .amux = LINE1,
4111 } },
4112 .radio = {
4113 .name = name_radio,
4114 .amux = LINE1,
4115 },
4116 },
4117 [SAA7134_BOARD_AVERMEDIA_M115] = {
4118 .name = "Avermedia M115",
4119 .audio_clock = 0x187de7,
4120 .tuner_type = TUNER_XC2028,
4121 .inputs = {{
4122 .name = name_tv,
4123 .vmux = 1,
4124 .amux = TV,
4125 .tv = 1,
4126 }, {
4127 .name = name_comp1,
4128 .vmux = 3,
4129 .amux = LINE1,
4130 }, {
4131 .name = name_svideo,
4132 .vmux = 8,
4133 .amux = LINE2,
4134 } },
4135 },
4136 [SAA7134_BOARD_VIDEOMATE_T750] = {
4137 /* John Newbigin <jn@it.swin.edu.au> */
4138 .name = "Compro VideoMate T750",
4139 .audio_clock = 0x00187de7,
4140 .tuner_type = TUNER_XC2028,
4141 .mpeg = SAA7134_MPEG_DVB,
4142 .inputs = {{
4143 .name = name_tv,
4144 .vmux = 3,
4145 .amux = TV,
4146 .tv = 1,
4147 }, {
4148 .name = name_comp1,
4149 .vmux = 1,
4150 .amux = LINE2,
4151 }, {
4152 .name = name_svideo,
4153 .vmux = 8,
4154 .amux = LINE2,
4155 } },
4156 .radio = {
4157 .name = name_radio,
4158 .amux = TV,
4159 }
4160 }
4067}; 4161};
4068 4162
4069const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 4163const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -5027,6 +5121,30 @@ struct pci_device_id saa7134_pci_tbl[] = {
5027 .subdevice = 0x8625, /* TV@nywhere A/D v1.1 */ 5121 .subdevice = 0x8625, /* TV@nywhere A/D v1.1 */
5028 .driver_data = SAA7134_BOARD_MSI_TVANYWHERE_AD11, 5122 .driver_data = SAA7134_BOARD_MSI_TVANYWHERE_AD11,
5029 },{ 5123 },{
5124 .vendor = PCI_VENDOR_ID_PHILIPS,
5125 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5126 .subvendor = 0x1461, /* Avermedia Technologies Inc */
5127 .subdevice = 0xf436,
5128 .driver_data = SAA7134_BOARD_AVERMEDIA_CARDBUS_506,
5129 }, {
5130 .vendor = PCI_VENDOR_ID_PHILIPS,
5131 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5132 .subvendor = 0x1461, /* Avermedia Technologies Inc */
5133 .subdevice = 0xf936,
5134 .driver_data = SAA7134_BOARD_AVERMEDIA_A16D,
5135 }, {
5136 .vendor = PCI_VENDOR_ID_PHILIPS,
5137 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5138 .subvendor = 0x1461, /* Avermedia Technologies Inc */
5139 .subdevice = 0xa836,
5140 .driver_data = SAA7134_BOARD_AVERMEDIA_M115,
5141 }, {
5142 .vendor = PCI_VENDOR_ID_PHILIPS,
5143 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5144 .subvendor = 0x185b,
5145 .subdevice = 0xc900,
5146 .driver_data = SAA7134_BOARD_VIDEOMATE_T750,
5147 }, {
5030 /* --- boards without eeprom + subsystem ID --- */ 5148 /* --- boards without eeprom + subsystem ID --- */
5031 .vendor = PCI_VENDOR_ID_PHILIPS, 5149 .vendor = PCI_VENDOR_ID_PHILIPS,
5032 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 5150 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
@@ -5082,6 +5200,67 @@ static void board_flyvideo(struct saa7134_dev *dev)
5082 dev->name, dev->name, dev->name); 5200 dev->name, dev->name, dev->name);
5083} 5201}
5084 5202
5203static int saa7134_xc2028_callback(struct saa7134_dev *dev,
5204 int command, int arg)
5205{
5206 switch (command) {
5207 case XC2028_TUNER_RESET:
5208 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x06e20000, 0x06e20000);
5209 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x06a20000, 0x06a20000);
5210 saa_andorl(SAA7133_ANALOG_IO_SELECT >> 2, 0x02, 0x02);
5211 saa_andorl(SAA7134_ANALOG_IN_CTRL1 >> 2, 0x81, 0x81);
5212 saa_andorl(SAA7134_AUDIO_CLOCK0 >> 2, 0x03187de7, 0x03187de7);
5213 saa_andorl(SAA7134_AUDIO_PLL_CTRL >> 2, 0x03, 0x03);
5214 saa_andorl(SAA7134_AUDIO_CLOCKS_PER_FIELD0 >> 2,
5215 0x0001e000, 0x0001e000);
5216 return 0;
5217 }
5218 return -EINVAL;
5219}
5220
5221
5222static int saa7134_tda8290_callback(struct saa7134_dev *dev,
5223 int command, int arg)
5224{
5225 u8 sync_control;
5226
5227 switch (command) {
5228 case 0: /* switch LNA gain through GPIO 22*/
5229 saa7134_set_gpio(dev, 22, arg) ;
5230 break;
5231 case 1: /* vsync output at GPIO22. 50 / 60Hz */
5232 saa_andorb(SAA7134_VIDEO_PORT_CTRL3, 0x80, 0x80);
5233 saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x03);
5234 if (arg == 1)
5235 sync_control = 11;
5236 else
5237 sync_control = 17;
5238 saa_writeb(SAA7134_VGATE_START, sync_control);
5239 saa_writeb(SAA7134_VGATE_STOP, sync_control + 1);
5240 saa_andorb(SAA7134_MISC_VGATE_MSB, 0x03, 0x00);
5241 break;
5242 default:
5243 return -EINVAL;
5244 }
5245
5246 return 0;
5247}
5248
5249int saa7134_tuner_callback(void *priv, int command, int arg)
5250{
5251 struct i2c_algo_bit_data *i2c_algo = priv;
5252 struct saa7134_dev *dev = i2c_algo->data;
5253
5254 switch (dev->tuner_type) {
5255 case TUNER_PHILIPS_TDA8290:
5256 return saa7134_tda8290_callback(dev, command, arg);
5257 case TUNER_XC2028:
5258 return saa7134_xc2028_callback(dev, command, arg);
5259 }
5260 return -EINVAL;
5261}
5262EXPORT_SYMBOL(saa7134_tuner_callback);
5263
5085/* ----------------------------------------------------------- */ 5264/* ----------------------------------------------------------- */
5086 5265
5087static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data) 5266static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data)
@@ -5151,6 +5330,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
5151 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 5330 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
5152 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 5331 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
5153 case SAA7134_BOARD_VIDEOMATE_DVBT_200A: 5332 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
5333 case SAA7134_BOARD_VIDEOMATE_T750:
5154 case SAA7134_BOARD_MANLI_MTV001: 5334 case SAA7134_BOARD_MANLI_MTV001:
5155 case SAA7134_BOARD_MANLI_MTV002: 5335 case SAA7134_BOARD_MANLI_MTV002:
5156 case SAA7134_BOARD_BEHOLD_409FM: 5336 case SAA7134_BOARD_BEHOLD_409FM:
@@ -5217,6 +5397,8 @@ int saa7134_board_init1(struct saa7134_dev *dev)
5217 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08000000, 0x00000000); 5397 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08000000, 0x00000000);
5218 break; 5398 break;
5219 case SAA7134_BOARD_AVERMEDIA_CARDBUS: 5399 case SAA7134_BOARD_AVERMEDIA_CARDBUS:
5400 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
5401 case SAA7134_BOARD_AVERMEDIA_M115:
5220 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: 5402 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
5221 /* power-up tuner chip */ 5403 /* power-up tuner chip */
5222 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff); 5404 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff);
@@ -5284,11 +5466,16 @@ int saa7134_board_init2(struct saa7134_dev *dev)
5284 dev->tuner_type = saa7134_boards[dev->board].tuner_type; 5466 dev->tuner_type = saa7134_boards[dev->board].tuner_type;
5285 5467
5286 if (TUNER_ABSENT != dev->tuner_type) { 5468 if (TUNER_ABSENT != dev->tuner_type) {
5287 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; 5469 tun_setup.mode_mask = T_RADIO |
5288 tun_setup.type = dev->tuner_type; 5470 T_ANALOG_TV |
5289 tun_setup.addr = ADDR_UNSET; 5471 T_DIGITAL_TV;
5472 tun_setup.type = dev->tuner_type;
5473 tun_setup.addr = ADDR_UNSET;
5474 tun_setup.tuner_callback = saa7134_tuner_callback;
5290 5475
5291 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup); 5476 saa7134_i2c_call_clients(dev,
5477 TUNER_SET_TYPE_ADDR,
5478 &tun_setup);
5292 } 5479 }
5293 break; 5480 break;
5294 case SAA7134_BOARD_MD7134: 5481 case SAA7134_BOARD_MD7134:
@@ -5359,11 +5546,14 @@ int saa7134_board_init2(struct saa7134_dev *dev)
5359 &tda9887_cfg); 5546 &tda9887_cfg);
5360 } 5547 }
5361 5548
5362 tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; 5549 tun_setup.mode_mask = T_RADIO |
5550 T_ANALOG_TV |
5551 T_DIGITAL_TV;
5363 tun_setup.type = dev->tuner_type; 5552 tun_setup.type = dev->tuner_type;
5364 tun_setup.addr = ADDR_UNSET; 5553 tun_setup.addr = ADDR_UNSET;
5365 5554
5366 saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); 5555 saa7134_i2c_call_clients(dev,
5556 TUNER_SET_TYPE_ADDR, &tun_setup);
5367 } 5557 }
5368 break; 5558 break;
5369 case SAA7134_BOARD_PHILIPS_EUROPA: 5559 case SAA7134_BOARD_PHILIPS_EUROPA:
@@ -5496,12 +5686,26 @@ int saa7134_board_init2(struct saa7134_dev *dev)
5496 } 5686 }
5497 break; 5687 break;
5498 } 5688 }
5689
5690 if (dev->tuner_type == TUNER_XC2028) {
5691 struct v4l2_priv_tun_config xc2028_cfg;
5692 struct xc2028_ctrl ctl;
5693
5694 memset(&xc2028_cfg, 0, sizeof(ctl));
5695 memset(&ctl, 0, sizeof(ctl));
5696
5697 ctl.fname = XC2028_DEFAULT_FIRMWARE;
5698 ctl.max_len = 64;
5699
5700 /* FIXME: This should be device-dependent */
5701 ctl.demod = XC3028_FE_OREN538;
5702 ctl.mts = 1;
5703
5704 xc2028_cfg.tuner = TUNER_XC2028;
5705 xc2028_cfg.priv = &ctl;
5706
5707 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
5708 }
5709
5499 return 0; 5710 return 0;
5500} 5711}
5501
5502/* ----------------------------------------------------------- */
5503/*
5504 * Local variables:
5505 * c-basic-offset: 8
5506 * End:
5507 */