diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-02-13 06:24:34 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-02-17 07:43:08 -0500 |
commit | ef88f2b563275d156beebc9f76ed134f3f90f210 (patch) | |
tree | c65f979863e203cb4b32b61821230d85e0b125c4 | |
parent | f63145e28934a0b3ad8baf31adc195ec81423351 (diff) |
V4L/DVB (10527): tuner: fix TUV1236D analog/digital setup
As reported by David Engel <david@istwok.net>, ATSC115 doesn't work
fine with mythtv. This software opens both analog and dvb interfaces of
saa7134.
What happens is that some tuner commands are going to the wrong place,
as shown at the logs:
Feb 12 20:37:48 opus kernel: tuner-simple 1-0061: using tuner params #0 (ntsc)
Feb 12 20:37:48 opus kernel: tuner-simple 1-0061: freq = 67.25 (1076), range = 0, config = 0xce, cb = 0x01
Feb 12 20:37:48 opus kernel: tuner-simple 1-0061: Freq= 67.25 MHz, V_IF=45.75 MHz, Offset=0.00 MHz, div=1808
Feb 12 20:37:48 opus kernel: tuner 1-0061: tv freq set to 67.25
Feb 12 20:37:48 opus kernel: tuner-simple 1-000a: using tuner params #0 (ntsc)
Feb 12 20:37:48 opus kernel: tuner-simple 1-000a: freq = 67.25 (1076), range = 0, config = 0xce, cb = 0x01
Feb 12 20:37:48 opus kernel: tuner-simple 1-000a: Freq= 67.25 MHz, V_IF=45.75 MHz, Offset=0.00 MHz, div=1808
Feb 12 20:37:48 opus kernel: tuner-simple 1-000a: tv 0x07 0x10 0xce 0x01
Feb 12 20:37:48 opus kernel: tuner-simple 1-0061: tv 0x07 0x10 0xce 0x01
This happens due to a hack at TUV1236D analog setup, where it replaces
tuner address, at 0x61 for 0x0a, in order to save a few memory bytes.
The code assumes that nobody else would try to access the tuner during
that setup, but the point is that there's no lock to protect such
access. So, this opens the possibility of race conditions to happen.
Instead of hacking tuner address, this patch uses a temporary var with
the proper tuner value to be used during the setup. This should save
the issue, although we should consider to write some analog/digital
lock at saa7134 driver.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/common/tuners/tuner-simple.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c index de7adaf5fa5b..78412c9c424a 100644 --- a/drivers/media/common/tuners/tuner-simple.c +++ b/drivers/media/common/tuners/tuner-simple.c | |||
@@ -318,7 +318,6 @@ static int simple_std_setup(struct dvb_frontend *fe, | |||
318 | u8 *config, u8 *cb) | 318 | u8 *config, u8 *cb) |
319 | { | 319 | { |
320 | struct tuner_simple_priv *priv = fe->tuner_priv; | 320 | struct tuner_simple_priv *priv = fe->tuner_priv; |
321 | u8 tuneraddr; | ||
322 | int rc; | 321 | int rc; |
323 | 322 | ||
324 | /* tv norm specific stuff for multi-norm tuners */ | 323 | /* tv norm specific stuff for multi-norm tuners */ |
@@ -387,6 +386,7 @@ static int simple_std_setup(struct dvb_frontend *fe, | |||
387 | 386 | ||
388 | case TUNER_PHILIPS_TUV1236D: | 387 | case TUNER_PHILIPS_TUV1236D: |
389 | { | 388 | { |
389 | struct tuner_i2c_props i2c = priv->i2c_props; | ||
390 | /* 0x40 -> ATSC antenna input 1 */ | 390 | /* 0x40 -> ATSC antenna input 1 */ |
391 | /* 0x48 -> ATSC antenna input 2 */ | 391 | /* 0x48 -> ATSC antenna input 2 */ |
392 | /* 0x00 -> NTSC antenna input 1 */ | 392 | /* 0x00 -> NTSC antenna input 1 */ |
@@ -398,17 +398,15 @@ static int simple_std_setup(struct dvb_frontend *fe, | |||
398 | buffer[1] = 0x04; | 398 | buffer[1] = 0x04; |
399 | } | 399 | } |
400 | /* set to the correct mode (analog or digital) */ | 400 | /* set to the correct mode (analog or digital) */ |
401 | tuneraddr = priv->i2c_props.addr; | 401 | i2c.addr = 0x0a; |
402 | priv->i2c_props.addr = 0x0a; | 402 | rc = tuner_i2c_xfer_send(&i2c, &buffer[0], 2); |
403 | rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[0], 2); | ||
404 | if (2 != rc) | 403 | if (2 != rc) |
405 | tuner_warn("i2c i/o error: rc == %d " | 404 | tuner_warn("i2c i/o error: rc == %d " |
406 | "(should be 2)\n", rc); | 405 | "(should be 2)\n", rc); |
407 | rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[2], 2); | 406 | rc = tuner_i2c_xfer_send(&i2c, &buffer[2], 2); |
408 | if (2 != rc) | 407 | if (2 != rc) |
409 | tuner_warn("i2c i/o error: rc == %d " | 408 | tuner_warn("i2c i/o error: rc == %d " |
410 | "(should be 2)\n", rc); | 409 | "(should be 2)\n", rc); |
411 | priv->i2c_props.addr = tuneraddr; | ||
412 | break; | 410 | break; |
413 | } | 411 | } |
414 | } | 412 | } |