Commit a6f6fb9c authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[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: default avatarSri Deevi <Srinivasa.Deevi@conexant.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 1a4aa920
...@@ -1268,36 +1268,39 @@ int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, ...@@ -1268,36 +1268,39 @@ int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev,
return status; return status;
} }
int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex) int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3)
{ {
u8 value[4] = { 0, 0, 0, 0 }; u8 value[4] = { 0, 0, 0, 0 };
int status = 0; int status = 0;
bool current_is_port_3;
cx231xx_info("Changing the i2c port for tuner to %d\n", I2CIndex);
status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER, status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER,
PWR_CTL_EN, value, 4); PWR_CTL_EN, value, 4);
if (status < 0) if (status < 0)
return status; return status;
if (I2CIndex == I2C_1) { current_is_port_3 = value[0] & I2C_DEMOD_EN ? true : false;
if (value[0] & I2C_DEMOD_EN) {
value[0] &= ~I2C_DEMOD_EN; /* Just return, if already using the right port */
status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, if (current_is_port_3 == is_port_3)
PWR_CTL_EN, value, 4); return 0;
}
} else { if (is_port_3)
if (!(value[0] & I2C_DEMOD_EN)) { value[0] |= I2C_DEMOD_EN;
value[0] |= I2C_DEMOD_EN; else
status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER, value[0] &= ~I2C_DEMOD_EN;
PWR_CTL_EN, value, 4);
} cx231xx_info("Changing the i2c master port to %d\n",
} is_port_3 ? 3 : 1);
status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER,
PWR_CTL_EN, value, 4);
return status; return status;
} }
EXPORT_SYMBOL_GPL(cx231xx_enable_i2c_for_tuner); EXPORT_SYMBOL_GPL(cx231xx_enable_i2c_port_3);
void update_HH_register_after_set_DIF(struct cx231xx *dev) void update_HH_register_after_set_DIF(struct cx231xx *dev)
{ {
/* /*
...@@ -2324,24 +2327,14 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) ...@@ -2324,24 +2327,14 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode)
msleep(PWR_SLEEP_INTERVAL); msleep(PWR_SLEEP_INTERVAL);
} }
if ((dev->model == CX231XX_BOARD_CNXT_CARRAERA) || if (dev->board.tuner_type != TUNER_ABSENT) {
(dev->model == CX231XX_BOARD_CNXT_RDE_250) || /* Enable tuner */
(dev->model == CX231XX_BOARD_CNXT_SHELBY) || cx231xx_enable_i2c_port_3(dev, true);
(dev->model == CX231XX_BOARD_CNXT_RDU_250)) {
/* tuner path to channel 1 from port 3 */
cx231xx_enable_i2c_for_tuner(dev, I2C_3);
/* reset the Tuner */ /* reset the Tuner */
cx231xx_gpio_set(dev, dev->board.tuner_gpio); if (dev->board.tuner_gpio)
cx231xx_gpio_set(dev, dev->board.tuner_gpio);
if (dev->cx231xx_reset_analog_tuner)
dev->cx231xx_reset_analog_tuner(dev);
} else if ((dev->model == CX231XX_BOARD_CNXT_RDE_253S) ||
(dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) ||
(dev->model == CX231XX_BOARD_CNXT_RDU_253S) ||
(dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER)) {
/* tuner path to channel 1 from port 3 */
cx231xx_enable_i2c_for_tuner(dev, I2C_3);
if (dev->cx231xx_reset_analog_tuner) if (dev->cx231xx_reset_analog_tuner)
dev->cx231xx_reset_analog_tuner(dev); dev->cx231xx_reset_analog_tuner(dev);
} }
...@@ -2401,33 +2394,23 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode) ...@@ -2401,33 +2394,23 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode)
msleep(PWR_SLEEP_INTERVAL); msleep(PWR_SLEEP_INTERVAL);
} }
if ((dev->model == CX231XX_BOARD_CNXT_CARRAERA) || if (dev->board.tuner_type != TUNER_ABSENT) {
(dev->model == CX231XX_BOARD_CNXT_RDE_250) || /*
(dev->model == CX231XX_BOARD_CNXT_SHELBY) || * Enable tuner
(dev->model == CX231XX_BOARD_CNXT_RDU_250)) { * Hauppauge Exeter seems to need to do something different!
/* tuner path to channel 1 from port 3 */ */
cx231xx_enable_i2c_for_tuner(dev, I2C_3); if (dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER)
cx231xx_enable_i2c_port_3(dev, false);
else
cx231xx_enable_i2c_port_3(dev, true);
/* reset the Tuner */ /* reset the Tuner */
cx231xx_gpio_set(dev, dev->board.tuner_gpio); if (dev->board.tuner_gpio)
cx231xx_gpio_set(dev, dev->board.tuner_gpio);
if (dev->cx231xx_reset_analog_tuner)
dev->cx231xx_reset_analog_tuner(dev);
} else if ((dev->model == CX231XX_BOARD_CNXT_RDE_253S) ||
(dev->model == CX231XX_BOARD_CNXT_VIDEO_GRABBER) ||
(dev->model == CX231XX_BOARD_CNXT_RDU_253S)) {
/* tuner path to channel 1 from port 3 */
cx231xx_enable_i2c_for_tuner(dev, I2C_3);
if (dev->cx231xx_reset_analog_tuner)
dev->cx231xx_reset_analog_tuner(dev);
} else if (dev->model == CX231XX_BOARD_HAUPPAUGE_EXETER) {
/* tuner path to channel 1 from port 1 ?? */
cx231xx_enable_i2c_for_tuner(dev, I2C_1);
if (dev->cx231xx_reset_analog_tuner) if (dev->cx231xx_reset_analog_tuner)
dev->cx231xx_reset_analog_tuner(dev); dev->cx231xx_reset_analog_tuner(dev);
} }
break; break;
default: default:
......
...@@ -1401,9 +1401,7 @@ int cx231xx_dev_init(struct cx231xx *dev) ...@@ -1401,9 +1401,7 @@ int cx231xx_dev_init(struct cx231xx *dev)
cx231xx_set_alt_setting(dev, INDEX_TS1, 0); cx231xx_set_alt_setting(dev, INDEX_TS1, 0);
/* set the I2C master port to 3 on channel 1 */ /* set the I2C master port to 3 on channel 1 */
if (dev->model != CX231XX_BOARD_CNXT_VIDEO_GRABBER && errCode = cx231xx_enable_i2c_port_3(dev, true);
dev->model != CX231XX_BOARD_HAUPPAUGE_USBLIVE2)
errCode = cx231xx_enable_i2c_for_tuner(dev, I2C_3);
return errCode; return errCode;
} }
......
...@@ -235,11 +235,11 @@ static int start_streaming(struct cx231xx_dvb *dvb) ...@@ -235,11 +235,11 @@ static int start_streaming(struct cx231xx_dvb *dvb)
if (dev->USE_ISO) { if (dev->USE_ISO) {
cx231xx_info("DVB transfer mode is ISO.\n"); cx231xx_info("DVB transfer mode is ISO.\n");
mutex_lock(&dev->i2c_lock); mutex_lock(&dev->i2c_lock);
cx231xx_enable_i2c_for_tuner(dev, I2C_1); cx231xx_enable_i2c_port_3(dev, false);
cx231xx_set_alt_setting(dev, INDEX_TS1, 4); cx231xx_set_alt_setting(dev, INDEX_TS1, 4);
cx231xx_enable_i2c_for_tuner(dev, I2C_3); cx231xx_enable_i2c_port_3(dev, true);
mutex_unlock(&dev->i2c_lock); mutex_unlock(&dev->i2c_lock);
rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE); rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE);
if (rc < 0) if (rc < 0)
return rc; return rc;
......
...@@ -929,7 +929,7 @@ int cx231xx_power_suspend(struct cx231xx *dev); ...@@ -929,7 +929,7 @@ int cx231xx_power_suspend(struct cx231xx *dev);
int cx231xx_init_ctrl_pin_status(struct cx231xx *dev); int cx231xx_init_ctrl_pin_status(struct cx231xx *dev);
int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev, int cx231xx_set_agc_analog_digital_mux_select(struct cx231xx *dev,
u8 analog_or_digital); u8 analog_or_digital);
int cx231xx_enable_i2c_for_tuner(struct cx231xx *dev, u8 I2CIndex); int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3);
/* video audio decoder related functions */ /* video audio decoder related functions */
void video_mux(struct cx231xx *dev, int index); void video_mux(struct cx231xx *dev, int index);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment