aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa7134-cards.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-02-08 07:33:15 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:43 -0400
commitb9348353a7520073ea57ed937730a70986932fe3 (patch)
treedc626c8200dc430aed8ebc58a6a9ad5e9fe4960b /drivers/media/video/saa7134/saa7134-cards.c
parent18b1ae7dd83e4ec5ab28711e4b28e4b2e1c0b53c (diff)
V4L/DVB (10507): saa7134: Fix analog mode on devices that need to open an i2c gate
Some saa7134 devices require to open an i2c gate before tuning. This patch fix the initialization for those devices. The nxt200x_gate_ctrl() logic were returned back to the old place, since we don't know how to close the gate. A future pacth could revert that change and provide the proper close gate control, to avoid keeping it open forever. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-cards.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c147
1 files changed, 77 insertions, 70 deletions
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 99450cbd42bd..3192ccb5fcfe 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -5896,32 +5896,6 @@ static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data)
5896 5896
5897/* ----------------------------------------------------------- */ 5897/* ----------------------------------------------------------- */
5898 5898
5899static void nxt200x_gate_ctrl(struct saa7134_dev *dev, int open)
5900{
5901 /* enable tuner */
5902 int i;
5903 static const u8 buffer [][2] = {
5904 { 0x10, 0x12 },
5905 { 0x13, 0x04 },
5906 { 0x16, 0x00 },
5907 { 0x14, 0x04 },
5908 { 0x17, 0x00 },
5909 };
5910
5911 dev->i2c_client.addr = 0x0a;
5912
5913 /* FIXME: don't know how to close the i2c gate on NXT200x */
5914 if (!open)
5915 return;
5916
5917 for (i = 0; i < ARRAY_SIZE(buffer); i++)
5918 if (2 != i2c_master_send(&dev->i2c_client,
5919 &buffer[i][0], ARRAY_SIZE(buffer[0])))
5920 printk(KERN_WARNING
5921 "%s: Unable to enable tuner(%i).\n",
5922 dev->name, i);
5923}
5924
5925int saa7134_board_init1(struct saa7134_dev *dev) 5899int saa7134_board_init1(struct saa7134_dev *dev)
5926{ 5900{
5927 /* Always print gpio, often manufacturers encode tuner type and other info. */ 5901 /* Always print gpio, often manufacturers encode tuner type and other info. */
@@ -6115,10 +6089,6 @@ int saa7134_board_init1(struct saa7134_dev *dev)
6115 "are supported for now.\n", 6089 "are supported for now.\n",
6116 dev->name, card(dev).name, dev->name); 6090 dev->name, card(dev).name, dev->name);
6117 break; 6091 break;
6118 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
6119 case SAA7134_BOARD_KWORLD_ATSC110:
6120 dev->gate_ctrl = nxt200x_gate_ctrl;
6121 break;
6122 } 6092 }
6123 return 0; 6093 return 0;
6124} 6094}
@@ -6197,33 +6167,20 @@ int saa7134_board_init2(struct saa7134_dev *dev)
6197 unsigned char buf; 6167 unsigned char buf;
6198 int board; 6168 int board;
6199 6169
6200 /* initialize hardware #2 */ 6170 /* Put here the code that enables the chips that are needed
6201 if (TUNER_ABSENT != dev->tuner_type) { 6171 for analog mode and doesn't depend on the tuner attachment.
6202 int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); 6172 It is also a good idea to get tuner type from eeprom, etc before
6203 6173 initializing tuner, since we can avoid loading tuner driver
6204 /* Note: radio tuner address is always filled in, 6174 on devices that has TUNER_ABSENT
6205 so we do not need to probe for a radio tuner device. */ 6175 */
6206 if (dev->radio_type != UNSET)
6207 v4l2_i2c_new_subdev(&dev->i2c_adap,
6208 "tuner", "tuner", dev->radio_addr);
6209 if (has_demod)
6210 v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner",
6211 "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
6212 if (dev->tuner_addr == ADDR_UNSET) {
6213 enum v4l2_i2c_tuner_type type =
6214 has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
6215
6216 v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner",
6217 "tuner", v4l2_i2c_tuner_addrs(type));
6218 } else {
6219 v4l2_i2c_new_subdev(&dev->i2c_adap,
6220 "tuner", "tuner", dev->tuner_addr);
6221 }
6222 }
6223
6224 switch (dev->board) { 6176 switch (dev->board) {
6225 case SAA7134_BOARD_BMK_MPEX_NOTUNER: 6177 case SAA7134_BOARD_BMK_MPEX_NOTUNER:
6226 case SAA7134_BOARD_BMK_MPEX_TUNER: 6178 case SAA7134_BOARD_BMK_MPEX_TUNER:
6179 /* Checks if the device has a tuner at 0x60 addr
6180 If the device doesn't have a tuner, TUNER_ABSENT
6181 will be used at tuner_type, avoiding loading tuner
6182 without needing it
6183 */
6227 dev->i2c_client.addr = 0x60; 6184 dev->i2c_client.addr = 0x60;
6228 board = (i2c_master_recv(&dev->i2c_client, &buf, 0) < 0) 6185 board = (i2c_master_recv(&dev->i2c_client, &buf, 0) < 0)
6229 ? SAA7134_BOARD_BMK_MPEX_NOTUNER 6186 ? SAA7134_BOARD_BMK_MPEX_NOTUNER
@@ -6241,11 +6198,15 @@ int saa7134_board_init2(struct saa7134_dev *dev)
6241 u8 subaddr; 6198 u8 subaddr;
6242 u8 data[3]; 6199 u8 data[3];
6243 int ret, tuner_t; 6200 int ret, tuner_t;
6244
6245 struct i2c_msg msg[] = {{.addr=0x50, .flags=0, .buf=&subaddr, .len = 1}, 6201 struct i2c_msg msg[] = {{.addr=0x50, .flags=0, .buf=&subaddr, .len = 1},
6246 {.addr=0x50, .flags=I2C_M_RD, .buf=data, .len = 3}}; 6202 {.addr=0x50, .flags=I2C_M_RD, .buf=data, .len = 3}};
6203
6247 subaddr= 0x14; 6204 subaddr= 0x14;
6248 tuner_t = 0; 6205 tuner_t = 0;
6206
6207 /* Retrieve device data from eeprom, checking for the
6208 proper tuner_type.
6209 */
6249 ret = i2c_transfer(&dev->i2c_adap, msg, 2); 6210 ret = i2c_transfer(&dev->i2c_adap, msg, 2);
6250 if (ret != 2) { 6211 if (ret != 2) {
6251 printk(KERN_ERR "EEPROM read failure\n"); 6212 printk(KERN_ERR "EEPROM read failure\n");
@@ -6301,12 +6262,14 @@ int saa7134_board_init2(struct saa7134_dev *dev)
6301 dev->name, saa7134_boards[dev->board].name); 6262 dev->name, saa7134_boards[dev->board].name);
6302 break; 6263 break;
6303 } 6264 }
6265 /* break intentionally omitted */
6304 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 6266 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
6305 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: 6267 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
6306 { 6268 {
6307 6269
6308 /* The Philips EUROPA based hybrid boards have the tuner connected through 6270 /* The Philips EUROPA based hybrid boards have the tuner
6309 * the channel decoder. We have to make it transparent to find it 6271 connected through the channel decoder. We have to make it
6272 transparent to find it
6310 */ 6273 */
6311 u8 data[] = { 0x07, 0x02}; 6274 u8 data[] = { 0x07, 0x02};
6312 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)}; 6275 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
@@ -6327,21 +6290,15 @@ int saa7134_board_init2(struct saa7134_dev *dev)
6327 if (dev->board == SAA7134_BOARD_PHILIPS_TIGER_S) { 6290 if (dev->board == SAA7134_BOARD_PHILIPS_TIGER_S) {
6328 dev->tuner_type = TUNER_PHILIPS_TDA8290; 6291 dev->tuner_type = TUNER_PHILIPS_TDA8290;
6329 6292
6330 saa7134_tuner_setup(dev);
6331
6332 data[2] = 0x68; 6293 data[2] = 0x68;
6333 i2c_transfer(&dev->i2c_adap, &msg, 1); 6294 i2c_transfer(&dev->i2c_adap, &msg, 1);
6334 6295 break;
6335 /* Tuner setup is handled before I2C transfer.
6336 Due to that, there's no need to do it later
6337 */
6338 return 0;
6339 } 6296 }
6340 i2c_transfer(&dev->i2c_adap, &msg, 1); 6297 i2c_transfer(&dev->i2c_adap, &msg, 1);
6341 break; 6298 break;
6342 } 6299 }
6343 case SAA7134_BOARD_ASUSTeK_TVFM7135: 6300 case SAA7134_BOARD_ASUSTeK_TVFM7135:
6344 /* The card below is detected as card=53, but is different */ 6301 /* The card below is detected as card=53, but is different */
6345 if (dev->autodetected && (dev->eedata[0x27] == 0x03)) { 6302 if (dev->autodetected && (dev->eedata[0x27] == 0x03)) {
6346 dev->board = SAA7134_BOARD_ASUSTeK_P7131_ANALOG; 6303 dev->board = SAA7134_BOARD_ASUSTeK_P7131_ANALOG;
6347 printk(KERN_INFO "%s: P7131 analog only, using " 6304 printk(KERN_INFO "%s: P7131 analog only, using "
@@ -6412,9 +6369,9 @@ int saa7134_board_init2(struct saa7134_dev *dev)
6412 6369
6413 /* Don't do this if the board was specifically selected with an 6370 /* Don't do this if the board was specifically selected with an
6414 * insmod option or if we have the default configuration T200*/ 6371 * insmod option or if we have the default configuration T200*/
6415 if(!dev->autodetected || (dev->eedata[0x41] == 0xd0)) 6372 if (!dev->autodetected || (dev->eedata[0x41] == 0xd0))
6416 break; 6373 break;
6417 if(dev->eedata[0x41] == 0x02) { 6374 if (dev->eedata[0x41] == 0x02) {
6418 /* Reconfigure board as T200A */ 6375 /* Reconfigure board as T200A */
6419 dev->board = SAA7134_BOARD_VIDEOMATE_DVBT_200A; 6376 dev->board = SAA7134_BOARD_VIDEOMATE_DVBT_200A;
6420 dev->tuner_type = saa7134_boards[dev->board].tuner_type; 6377 dev->tuner_type = saa7134_boards[dev->board].tuner_type;
@@ -6427,6 +6384,58 @@ int saa7134_board_init2(struct saa7134_dev *dev)
6427 break; 6384 break;
6428 } 6385 }
6429 break; 6386 break;
6387 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
6388 case SAA7134_BOARD_KWORLD_ATSC110:
6389 {
6390 struct i2c_msg msg = { .addr = 0x0a, .flags = 0 };
6391 int i;
6392 static u8 buffer[][2] = {
6393 { 0x10, 0x12 },
6394 { 0x13, 0x04 },
6395 { 0x16, 0x00 },
6396 { 0x14, 0x04 },
6397 { 0x17, 0x00 },
6398 };
6399
6400 for (i = 0; i < ARRAY_SIZE(buffer); i++) {
6401 msg.buf = &buffer[i][0];
6402 msg.len = ARRAY_SIZE(buffer[0]);
6403 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
6404 printk(KERN_WARNING
6405 "%s: Unable to enable tuner(%i).\n",
6406 dev->name, i);
6407 }
6408 break;
6409 }
6410 } /* switch() */
6411
6412 /* initialize tuner */
6413 if (TUNER_ABSENT != dev->tuner_type) {
6414 int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);
6415
6416 /* Note: radio tuner address is always filled in,
6417 so we do not need to probe for a radio tuner device. */
6418 if (dev->radio_type != UNSET)
6419 v4l2_i2c_new_subdev(&dev->i2c_adap,
6420 "tuner", "tuner", dev->radio_addr);
6421 if (has_demod)
6422 v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner",
6423 "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
6424 if (dev->tuner_addr == ADDR_UNSET) {
6425 enum v4l2_i2c_tuner_type type =
6426 has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
6427
6428 v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner",
6429 "tuner", v4l2_i2c_tuner_addrs(type));
6430 } else {
6431 v4l2_i2c_new_subdev(&dev->i2c_adap,
6432 "tuner", "tuner", dev->tuner_addr);
6433 }
6434 }
6435
6436 saa7134_tuner_setup(dev);
6437
6438 switch (dev->board) {
6430 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: 6439 case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
6431 { 6440 {
6432 struct v4l2_priv_tun_config tea5767_cfg; 6441 struct v4l2_priv_tun_config tea5767_cfg;
@@ -6443,7 +6452,5 @@ int saa7134_board_init2(struct saa7134_dev *dev)
6443 } 6452 }
6444 } /* switch() */ 6453 } /* switch() */
6445 6454
6446 saa7134_tuner_setup(dev);
6447
6448 return 0; 6455 return 0;
6449} 6456}