diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-01-30 07:03:24 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 19:31:59 -0400 |
commit | 3f25ffa2cd946333d29a668993f5aa78e9b56a02 (patch) | |
tree | 754e562ba17c6c4ab5a0d10ab341f0b914567c1a | |
parent | 8bb84227d1ba41d6c1ec9350a4424ece5fe00e33 (diff) |
[media] cx231xx: Use a generic check for TUNER_XC5000
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>
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-i2c.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-i2c.c b/drivers/media/video/cx231xx/cx231xx-i2c.c index 835670623dfb..925f3a04e53c 100644 --- a/drivers/media/video/cx231xx/cx231xx-i2c.c +++ b/drivers/media/video/cx231xx/cx231xx-i2c.c | |||
@@ -54,6 +54,21 @@ do { \ | |||
54 | } \ | 54 | } \ |
55 | } while (0) | 55 | } while (0) |
56 | 56 | ||
57 | static inline bool is_tuner(struct cx231xx *dev, struct cx231xx_i2c *bus, | ||
58 | const struct i2c_msg *msg, int tuner_type) | ||
59 | { | ||
60 | if (bus->nr != dev->board.tuner_i2c_master) | ||
61 | return false; | ||
62 | |||
63 | if (msg->addr != dev->board.tuner_addr) | ||
64 | return false; | ||
65 | |||
66 | if (dev->tuner_type != tuner_type) | ||
67 | return false; | ||
68 | |||
69 | return true; | ||
70 | } | ||
71 | |||
57 | /* | 72 | /* |
58 | * cx231xx_i2c_send_bytes() | 73 | * cx231xx_i2c_send_bytes() |
59 | */ | 74 | */ |
@@ -71,9 +86,7 @@ int cx231xx_i2c_send_bytes(struct i2c_adapter *i2c_adap, | |||
71 | u16 saddr = 0; | 86 | u16 saddr = 0; |
72 | u8 need_gpio = 0; | 87 | u8 need_gpio = 0; |
73 | 88 | ||
74 | if ((bus->nr == 1) && (msg->addr == 0x61) | 89 | if (is_tuner(dev, bus, msg, TUNER_XC5000)) { |
75 | && (dev->tuner_type == TUNER_XC5000)) { | ||
76 | |||
77 | size = msg->len; | 90 | size = msg->len; |
78 | 91 | ||
79 | if (size == 2) { /* register write sub addr */ | 92 | if (size == 2) { /* register write sub addr */ |
@@ -180,9 +193,7 @@ static int cx231xx_i2c_recv_bytes(struct i2c_adapter *i2c_adap, | |||
180 | u16 saddr = 0; | 193 | u16 saddr = 0; |
181 | u8 need_gpio = 0; | 194 | u8 need_gpio = 0; |
182 | 195 | ||
183 | if ((bus->nr == 1) && (msg->addr == 0x61) | 196 | if (is_tuner(dev, bus, msg, TUNER_XC5000)) { |
184 | && dev->tuner_type == TUNER_XC5000) { | ||
185 | |||
186 | if (msg->len == 2) | 197 | if (msg->len == 2) |
187 | saddr = msg->buf[0] << 8 | msg->buf[1]; | 198 | saddr = msg->buf[0] << 8 | msg->buf[1]; |
188 | else if (msg->len == 1) | 199 | else if (msg->len == 1) |
@@ -274,9 +285,7 @@ static int cx231xx_i2c_recv_bytes_with_saddr(struct i2c_adapter *i2c_adap, | |||
274 | else if (msg1->len == 1) | 285 | else if (msg1->len == 1) |
275 | saddr = msg1->buf[0]; | 286 | saddr = msg1->buf[0]; |
276 | 287 | ||
277 | if ((bus->nr == 1) && (msg2->addr == 0x61) | 288 | if (is_tuner(dev, bus, msg2, TUNER_XC5000)) { |
278 | && dev->tuner_type == TUNER_XC5000) { | ||
279 | |||
280 | if ((msg2->len < 16)) { | 289 | if ((msg2->len < 16)) { |
281 | 290 | ||
282 | dprintk1(1, | 291 | dprintk1(1, |
@@ -454,8 +463,8 @@ static char *i2c_devs[128] = { | |||
454 | [0x32 >> 1] = "GeminiIII", | 463 | [0x32 >> 1] = "GeminiIII", |
455 | [0x02 >> 1] = "Aquarius", | 464 | [0x02 >> 1] = "Aquarius", |
456 | [0xa0 >> 1] = "eeprom", | 465 | [0xa0 >> 1] = "eeprom", |
457 | [0xc0 >> 1] = "tuner/XC3028", | 466 | [0xc0 >> 1] = "tuner", |
458 | [0xc2 >> 1] = "tuner/XC5000", | 467 | [0xc2 >> 1] = "tuner", |
459 | }; | 468 | }; |
460 | 469 | ||
461 | /* | 470 | /* |