Commit 76b91be3 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] em28xx: PCTV 461e use I2C client for demod and SEC

Use I2C client binding for demod and SEC.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 478932b1
...@@ -1521,64 +1521,94 @@ static int em28xx_dvb_init(struct em28xx *dev) ...@@ -1521,64 +1521,94 @@ static int em28xx_dvb_init(struct em28xx *dev)
} }
} }
break; break;
case EM28178_BOARD_PCTV_461E: case EM28178_BOARD_PCTV_461E: {
{
/* demod I2C adapter */
struct i2c_adapter *i2c_adapter;
struct i2c_client *client; struct i2c_client *client;
struct i2c_board_info info; struct i2c_adapter *i2c_adapter;
struct ts2020_config ts2020_config = { struct i2c_board_info board_info;
}; struct m88ds3103_platform_data m88ds3103_pdata = {};
memset(&info, 0, sizeof(struct i2c_board_info)); struct ts2020_config ts2020_config = {};
struct a8293_platform_data a8293_pdata = {};
/* attach demod */ /* attach demod */
dvb->fe[0] = dvb_attach(m88ds3103_attach, m88ds3103_pdata.clk = 27000000;
&pctv_461e_m88ds3103_config, m88ds3103_pdata.i2c_wr_max = 33;
&dev->i2c_adap[dev->def_i2c_bus], m88ds3103_pdata.ts_mode = M88DS3103_TS_PARALLEL;
&i2c_adapter); m88ds3103_pdata.ts_clk = 16000;
if (dvb->fe[0] == NULL) { m88ds3103_pdata.ts_clk_pol = 1;
m88ds3103_pdata.agc = 0x99;
memset(&board_info, 0, sizeof(board_info));
strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE);
board_info.addr = 0x68;
board_info.platform_data = &m88ds3103_pdata;
request_module("m88ds3103");
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info);
if (client == NULL || client->dev.driver == NULL) {
result = -ENODEV; result = -ENODEV;
goto out_free; goto out_free;
} }
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
result = -ENODEV;
goto out_free;
}
dvb->fe[0] = m88ds3103_pdata.get_dvb_frontend(client);
i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client);
dvb->i2c_client_demod = client;
/* attach tuner */ /* attach tuner */
ts2020_config.fe = dvb->fe[0]; ts2020_config.fe = dvb->fe[0];
strlcpy(info.type, "ts2022", I2C_NAME_SIZE); memset(&board_info, 0, sizeof(board_info));
info.addr = 0x60; strlcpy(board_info.type, "ts2022", I2C_NAME_SIZE);
info.platform_data = &ts2020_config; board_info.addr = 0x60;
board_info.platform_data = &ts2020_config;
request_module("ts2020"); request_module("ts2020");
client = i2c_new_device(i2c_adapter, &info); client = i2c_new_device(i2c_adapter, &board_info);
if (client == NULL || client->dev.driver == NULL) { if (client == NULL || client->dev.driver == NULL) {
dvb_frontend_detach(dvb->fe[0]); module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV; result = -ENODEV;
goto out_free; goto out_free;
} }
if (!try_module_get(client->dev.driver->owner)) { if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client); i2c_unregister_device(client);
dvb_frontend_detach(dvb->fe[0]); module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV; result = -ENODEV;
goto out_free; goto out_free;
} }
dvb->i2c_client_tuner = client;
/* delegate signal strength measurement to tuner */ /* delegate signal strength measurement to tuner */
dvb->fe[0]->ops.read_signal_strength = dvb->fe[0]->ops.read_signal_strength =
dvb->fe[0]->ops.tuner_ops.get_rf_strength; dvb->fe[0]->ops.tuner_ops.get_rf_strength;
/* attach SEC */ /* attach SEC */
if (!dvb_attach(a8293_attach, dvb->fe[0], a8293_pdata.dvb_frontend = dvb->fe[0];
&dev->i2c_adap[dev->def_i2c_bus], memset(&board_info, 0, sizeof(board_info));
&em28xx_a8293_config)) { strlcpy(board_info.type, "a8293", I2C_NAME_SIZE);
module_put(client->dev.driver->owner); board_info.addr = 0x08;
i2c_unregister_device(client); board_info.platform_data = &a8293_pdata;
dvb_frontend_detach(dvb->fe[0]); request_module("a8293");
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info);
if (client == NULL || client->dev.driver == NULL) {
module_put(dvb->i2c_client_tuner->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_tuner);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV; result = -ENODEV;
goto out_free; goto out_free;
} }
if (!try_module_get(client->dev.driver->owner)) {
dvb->i2c_client_tuner = client; i2c_unregister_device(client);
module_put(dvb->i2c_client_tuner->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_tuner);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
} }
dvb->i2c_client_sec = client;
break; break;
}
case EM28178_BOARD_PCTV_292E: case EM28178_BOARD_PCTV_292E:
{ {
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
......
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