Skip to content

Commit

Permalink
[media] cx231xx: attach si2165 driver via i2c_client
Browse files Browse the repository at this point in the history
Use new style attach.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
  • Loading branch information
Matthias Schwarzott authored and Mauro Carvalho Chehab committed Sep 22, 2016
1 parent d28d7f8 commit 773028f
Showing 1 changed file with 48 additions and 25 deletions.
73 changes: 48 additions & 25 deletions drivers/media/usb/cx231xx/cx231xx-dvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,6 @@ static struct tda18271_config pv_tda18271_config = {
.small_i2c = TDA18271_03_BYTE_CHUNK_INIT,
};

static const struct si2165_config hauppauge_930C_HD_1113xx_si2165_config = {
.i2c_addr = 0x64,
.chip_mode = SI2165_MODE_PLL_XTAL,
.ref_freq_Hz = 16000000,
};

static const struct si2165_config pctv_quatro_stick_1114xx_si2165_config = {
.i2c_addr = 0x64,
.chip_mode = SI2165_MODE_PLL_EXT,
.ref_freq_Hz = 24000000,
};

static struct lgdt3306a_config hauppauge_955q_lgdt3306a_config = {
.i2c_addr = 0x59,
.qam_if_khz = 4000,
Expand Down Expand Up @@ -756,19 +744,38 @@ static int dvb_init(struct cx231xx *dev)
break;

case CX231XX_BOARD_HAUPPAUGE_930C_HD_1113xx:
{
struct i2c_client *client;
struct i2c_board_info info;
struct si2165_platform_data si2165_pdata;

dev->dvb->frontend = dvb_attach(si2165_attach,
&hauppauge_930C_HD_1113xx_si2165_config,
demod_i2c
);
/* attach demod */
memset(&si2165_pdata, 0, sizeof(si2165_pdata));
si2165_pdata.fe = &dev->dvb->frontend;
si2165_pdata.chip_mode = SI2165_MODE_PLL_XTAL,
si2165_pdata.ref_freq_Hz = 16000000,

if (dev->dvb->frontend == NULL) {
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2165", I2C_NAME_SIZE);
info.addr = 0x64;
info.platform_data = &si2165_pdata;
request_module(info.type);
client = i2c_new_device(demod_i2c, &info);
if (client == NULL || client->dev.driver == NULL || dev->dvb->frontend == NULL) {
dev_err(dev->dev,
"Failed to attach SI2165 front end\n");
result = -EINVAL;
goto out_free;
}

if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
result = -ENODEV;
goto out_free;
}

dvb->i2c_client_demod = client;

dev->dvb->frontend->ops.i2c_gate_ctrl = NULL;

/* define general-purpose callback pointer */
Expand All @@ -781,27 +788,43 @@ static int dvb_init(struct cx231xx *dev)

dev->cx231xx_reset_analog_tuner = NULL;
break;

}
case CX231XX_BOARD_HAUPPAUGE_930C_HD_1114xx:
{
struct i2c_client *client;
struct i2c_board_info info;
struct si2165_platform_data si2165_pdata;
struct si2157_config si2157_config;

memset(&info, 0, sizeof(struct i2c_board_info));
/* attach demod */
memset(&si2165_pdata, 0, sizeof(si2165_pdata));
si2165_pdata.fe = &dev->dvb->frontend;
si2165_pdata.chip_mode = SI2165_MODE_PLL_EXT,
si2165_pdata.ref_freq_Hz = 24000000,

dev->dvb->frontend = dvb_attach(si2165_attach,
&pctv_quatro_stick_1114xx_si2165_config,
demod_i2c
);

if (dev->dvb->frontend == NULL) {
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2165", I2C_NAME_SIZE);
info.addr = 0x64;
info.platform_data = &si2165_pdata;
request_module(info.type);
client = i2c_new_device(demod_i2c, &info);
if (client == NULL || client->dev.driver == NULL || dev->dvb->frontend == NULL) {
dev_err(dev->dev,
"Failed to attach SI2165 front end\n");
result = -EINVAL;
goto out_free;
}

if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
result = -ENODEV;
goto out_free;
}

dvb->i2c_client_demod = client;

memset(&info, 0, sizeof(struct i2c_board_info));

dev->dvb->frontend->ops.i2c_gate_ctrl = NULL;

/* define general-purpose callback pointer */
Expand Down

0 comments on commit 773028f

Please sign in to comment.