diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-09-26 19:38:24 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-20 23:17:41 -0400 |
commit | a6f6fb9c86aa202cbc04796efe9187b698b9b225 (patch) | |
tree | 7ef56f8db0d7525ee367bad7ccca9fa6f2c63b2b /drivers/media/video/cx231xx | |
parent | 1a4aa920d0b49af2c0d9bbedb3bb75be4e174218 (diff) |
[media] cx231xx: better handle the master port enable command
Improves the logic, for it to be clearer and to avoid having
board-dependent config there.
Acked-by: Sri Deevi <Srinivasa.Deevi@conexant.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx231xx')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-avcore.c | 89 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-core.c | 4 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-dvb.c | 8 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx.h | 2 |
4 files changed, 42 insertions, 61 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-avcore.c b/drivers/media/video/cx231xx/cx231xx-avcore.c index ab9fbf82b4d2..2d773b31da1e 100644 --- a/drivers/media/video/cx231xx/cx231xx-avcore.c +++ b/drivers/media/video/cx231xx/cx231xx-avcore.c | |||
@@ -1268,36 +1268,39 @@ int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, | |||
1268 | return status; | 1268 | return status; |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex) | 1271 | int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3) |
1272 | { | 1272 | { |
1273 | u8 value[4] = { 0, 0, 0, 0 }; | 1273 | u8 value[4] = { 0, 0, 0, 0 }; |
1274 | int status = 0; | 1274 | int status = 0; |
1275 | 1275 | bool current_is_port_3; | |
1276 | cx231xx_info("Changing the i2c port for tuner to %d\n", I2CIndex); | ||
1277 | 1276 | ||
1278 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, | 1277 | status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, |
1279 | PWR_CTL_EN, value, 4); | 1278 | PWR_CTL_EN, value, 4); |
1280 | if (status < 0) | 1279 | if (status < 0) |
1281 | return status; | 1280 | return status; |
1282 | 1281 | ||
1283 | if (I2CIndex == I2C_1) { | 1282 | current_is_port_3 = value[0] & I2C_DEMOD_EN ? true : false; |
1284 | if (value[0] & I2C_DEMOD_EN) { | 1283 | |
1285 | value[0] &= ~I2C_DEMOD_EN; | 1284 | /* Just return, if already using the right port */ |
1286 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | 1285 | if (current_is_port_3 == is_port_3) |
1287 | PWR_CTL_EN, value, 4); | 1286 | return 0; |
1288 | } | 1287 | |
1289 | } else { | 1288 | if (is_port_3) |
1290 | if (!(value[0] & I2C_DEMOD_EN)) { | 1289 | value[0] |= I2C_DEMOD_EN; |
1291 | value[0] |= I2C_DEMOD_EN; | 1290 | else |
1292 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | 1291 | value[0] &= ~I2C_DEMOD_EN; |
1293 | PWR_CTL_EN, value, 4); | 1292 | |
1294 | } | 1293 | cx231xx_info("Changing the i2c master port to %d\n", |
1295 | } | 1294 | is_port_3 ? 3 : 1); |
1295 | |||
1296 | status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, | ||
1297 | PWR_CTL_EN, value, 4); | ||
1296 | 1298 | ||
1297 | return status; | 1299 | return status; |
1298 | 1300 | ||
1299 | } | 1301 | } |
1300 | EXPORT_SYMBOL_GPL(cx231xx_enable_i2c_for_tuner); | 1302 | EXPORT_SYMBOL_GPL(cx231xx_enable_i2c_port_3); |
1303 | |||
1301 | void update_HH_register_after_set_DIF(struct cx231xx *dev) | 1304 | void update_HH_register_after_set_DIF(struct cx231xx *dev) |
1302 | { | 1305 | { |
1303 | /* | 1306 | /* |
@@ -2324,26 +2327,16 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
2324 | msleep(PWR_SLEEP_INTERVAL); | 2327 | msleep(PWR_SLEEP_INTERVAL); |
2325 | } | 2328 | } |
2326 | 2329 | ||
2327 | if ((dev->model == CX231XX_BOARD_CNXT_CARRAERA) || | 2330 | if (dev->board.tuner_type != TUNER_ABSENT) { |
2328 | (dev->model == CX231XX_BOARD_CNXT_RDE_250) || | 2331 | /* Enable tuner */ |
2329 | (dev->model == CX231XX_BOARD_CNXT_SHELBY) || | 2332 | cx231xx_enable_i2c_port_3(dev, true); |
2330 | (dev->model == CX231XX_BOARD_CNXT_RDU_250)) { | ||
2331 | /* tuner path to channel 1 from port 3 */ | ||
2332 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
2333 | 2333 | ||
2334 | /* reset the Tuner */ | 2334 | /* reset the Tuner */ |
2335 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | 2335 | if (dev->board.tuner_gpio) |
2336 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | ||
2336 | 2337 | ||
2337 | if (dev->cx231xx_reset_analog_tuner) | 2338 | if (dev->cx231xx_reset_analog_tuner) |
2338 | dev->cx231xx_reset_analog_tuner(dev); | 2339 | dev->cx231xx_reset_analog_tuner(dev); |
2339 | } else if ((dev->model == CX231XX_BOARD_CNXT_RDE_253S) || | ||
2340 | (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) || | ||
2341 | (dev->model == CX231XX_BOARD_CNXT_RDU_253S) || | ||
2342 | (dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER)) { | ||
2343 | /* tuner path to channel 1 from port 3 */ | ||
2344 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
2345 | if (dev->cx231xx_reset_analog_tuner) | ||
2346 | dev->cx231xx_reset_analog_tuner(dev); | ||
2347 | } | 2340 | } |
2348 | 2341 | ||
2349 | break; | 2342 | break; |
@@ -2401,33 +2394,23 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) | |||
2401 | msleep(PWR_SLEEP_INTERVAL); | 2394 | msleep(PWR_SLEEP_INTERVAL); |
2402 | } | 2395 | } |
2403 | 2396 | ||
2404 | if ((dev->model == CX231XX_BOARD_CNXT_CARRAERA) || | 2397 | if (dev->board.tuner_type != TUNER_ABSENT) { |
2405 | (dev->model == CX231XX_BOARD_CNXT_RDE_250) || | 2398 | /* |
2406 | (dev->model == CX231XX_BOARD_CNXT_SHELBY) || | 2399 | * Enable tuner |
2407 | (dev->model == CX231XX_BOARD_CNXT_RDU_250)) { | 2400 | * Hauppauge Exeter seems to need to do something different! |
2408 | /* tuner path to channel 1 from port 3 */ | 2401 | */ |
2409 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | 2402 | if (dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER) |
2403 | cx231xx_enable_i2c_port_3(dev, false); | ||
2404 | else | ||
2405 | cx231xx_enable_i2c_port_3(dev, true); | ||
2410 | 2406 | ||
2411 | /* reset the Tuner */ | 2407 | /* reset the Tuner */ |
2412 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | 2408 | if (dev->board.tuner_gpio) |
2413 | 2409 | cx231xx_gpio_set(dev, dev->board.tuner_gpio); | |
2414 | if (dev->cx231xx_reset_analog_tuner) | ||
2415 | dev->cx231xx_reset_analog_tuner(dev); | ||
2416 | } else if ((dev->model == CX231XX_BOARD_CNXT_RDE_253S) || | ||
2417 | (dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) || | ||
2418 | (dev->model == CX231XX_BOARD_CNXT_RDU_253S)) { | ||
2419 | /* tuner path to channel 1 from port 3 */ | ||
2420 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
2421 | if (dev->cx231xx_reset_analog_tuner) | ||
2422 | dev->cx231xx_reset_analog_tuner(dev); | ||
2423 | } else if (dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER) { | ||
2424 | /* tuner path to channel 1 from port 1 ?? */ | ||
2425 | cx231xx_enable_i2c_for_tuner(dev, I2C_1); | ||
2426 | 2410 | ||
2427 | if (dev->cx231xx_reset_analog_tuner) | 2411 | if (dev->cx231xx_reset_analog_tuner) |
2428 | dev->cx231xx_reset_analog_tuner(dev); | 2412 | dev->cx231xx_reset_analog_tuner(dev); |
2429 | } | 2413 | } |
2430 | |||
2431 | break; | 2414 | break; |
2432 | 2415 | ||
2433 | default: | 2416 | default: |
diff --git a/drivers/media/video/cx231xx/cx231xx-core.c b/drivers/media/video/cx231xx/cx231xx-core.c index 983b120cf1ef..4af46fca9b0a 100644 --- a/drivers/media/video/cx231xx/cx231xx-core.c +++ b/drivers/media/video/cx231xx/cx231xx-core.c | |||
@@ -1401,9 +1401,7 @@ int cx231xx_dev_init(struct cx231xx *dev) | |||
1401 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); | 1401 | cx231xx_set_alt_setting(dev, INDEX_TS1, 0); |
1402 | 1402 | ||
1403 | /* set the I2C master port to 3 on channel 1 */ | 1403 | /* set the I2C master port to 3 on channel 1 */ |
1404 | if (dev->model != CX231XX_BOARD_CNXT_VIDEO_GRABBER && | 1404 | errCode = cx231xx_enable_i2c_port_3(dev, true); |
1405 | dev->model != CX231XX_BOARD_HAUPPAUGE_USBLIVE2) | ||
1406 | errCode = cx231xx_enable_i2c_for_tuner(dev, I2C_3); | ||
1407 | 1405 | ||
1408 | return errCode; | 1406 | return errCode; |
1409 | } | 1407 | } |
diff --git a/drivers/media/video/cx231xx/cx231xx-dvb.c b/drivers/media/video/cx231xx/cx231xx-dvb.c index 4efd3d3a6a73..5feb3ee640d9 100644 --- a/drivers/media/video/cx231xx/cx231xx-dvb.c +++ b/drivers/media/video/cx231xx/cx231xx-dvb.c | |||
@@ -235,11 +235,11 @@ static int start_streaming(struct cx231xx_dvb *dvb) | |||
235 | 235 | ||
236 | if (dev->USE_ISO) { | 236 | if (dev->USE_ISO) { |
237 | cx231xx_info("DVB transfer mode is ISO.\n"); | 237 | cx231xx_info("DVB transfer mode is ISO.\n"); |
238 | mutex_lock(&dev->i2c_lock); | 238 | mutex_lock(&dev->i2c_lock); |
239 | cx231xx_enable_i2c_for_tuner(dev, I2C_1); | 239 | cx231xx_enable_i2c_port_3(dev, false); |
240 | cx231xx_set_alt_setting(dev, INDEX_TS1, 4); | 240 | cx231xx_set_alt_setting(dev, INDEX_TS1, 4); |
241 | cx231xx_enable_i2c_for_tuner(dev, I2C_3); | 241 | cx231xx_enable_i2c_port_3(dev, true); |
242 | mutex_unlock(&dev->i2c_lock); | 242 | mutex_unlock(&dev->i2c_lock); |
243 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); | 243 | rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); |
244 | if (rc < 0) | 244 | if (rc < 0) |
245 | return rc; | 245 | return rc; |
diff --git a/drivers/media/video/cx231xx/cx231xx.h b/drivers/media/video/cx231xx/cx231xx.h index 5ffdd36a1185..b4859a0afd8c 100644 --- a/drivers/media/video/cx231xx/cx231xx.h +++ b/drivers/media/video/cx231xx/cx231xx.h | |||
@@ -929,7 +929,7 @@ int cx231xx_power_suspend(struct cx231xx *dev); | |||
929 | int cx231xx_init_ctrl_pin_status(struct cx231xx *dev); | 929 | int cx231xx_init_ctrl_pin_status(struct cx231xx *dev); |
930 | int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, | 930 | int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, |
931 | u8 analog_or_digital); | 931 | u8 analog_or_digital); |
932 | int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex); | 932 | int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3); |
933 | 933 | ||
934 | /* video audio decoder related functions */ | 934 | /* video audio decoder related functions */ |
935 | void video_mux(struct cx231xx *dev, int index); | 935 | void video_mux(struct cx231xx *dev, int index); |