Skip to content

Commit

Permalink
[media] cx231xx: Use a generic check for TUNER_XC5000
Browse files Browse the repository at this point in the history
The check for xc5000 assumes that the tuner will always
be using the same bus and will have the same address.
As those are configurable via dev->board, it should use,
instead, the values defined there.

Also, a similar type of test will be needed by other
tuners (for example, for TUNER_XC2028)

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab committed Mar 21, 2011
1 parent 8bb8422 commit 3f25ffa
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions drivers/media/video/cx231xx/cx231xx-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ do { \
} \
} while (0)

static inline bool is_tuner(struct cx231xx *dev, struct cx231xx_i2c *bus,
const struct i2c_msg *msg, int tuner_type)
{
if (bus->nr != dev->board.tuner_i2c_master)
return false;

if (msg->addr != dev->board.tuner_addr)
return false;

if (dev->tuner_type != tuner_type)
return false;

return true;
}

/*
* cx231xx_i2c_send_bytes()
*/
Expand All @@ -71,9 +86,7 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap,
u16 saddr = 0;
u8 need_gpio = 0;

if ((bus->nr == 1) && (msg->addr == 0x61)
&& (dev->tuner_type == TUNER_XC5000)) {

if (is_tuner(dev, bus, msg, TUNER_XC5000)) {
size = msg->len;

if (size == 2) { /* register write sub addr */
Expand Down Expand Up @@ -180,9 +193,7 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap,
u16 saddr = 0;
u8 need_gpio = 0;

if ((bus->nr == 1) && (msg->addr == 0x61)
&& dev->tuner_type == TUNER_XC5000) {

if (is_tuner(dev, bus, msg, TUNER_XC5000)) {
if (msg->len == 2)
saddr = msg->buf[0] << 8 | msg->buf[1];
else if (msg->len == 1)
Expand Down Expand Up @@ -274,9 +285,7 @@ static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap,
else if (msg1->len == 1)
saddr = msg1->buf[0];

if ((bus->nr == 1) && (msg2->addr == 0x61)
&& dev->tuner_type == TUNER_XC5000) {

if (is_tuner(dev, bus, msg2, TUNER_XC5000)) {
if ((msg2->len < 16)) {

dprintk1(1,
Expand Down Expand Up @@ -454,8 +463,8 @@ static char *i2c_devs[128] = {
[0x32 >> 1] = "GeminiIII",
[0x02 >> 1] = "Aquarius",
[0xa0 >> 1] = "eeprom",
[0xc0 >> 1] = "tuner/XC3028",
[0xc2 >> 1] = "tuner/XC5000",
[0xc0 >> 1] = "tuner",
[0xc2 >> 1] = "tuner",
};

/*
Expand Down

0 comments on commit 3f25ffa

Please sign in to comment.