Commit dcafb6de authored by Volokh Konstantin's avatar Volokh Konstantin Committed by Mauro Carvalho Chehab

[media] go7007: i2c initialization changes for tw2804

Do i2c initialization via struct item as tw2804 has a 0x00 i2c address,
so we need to use the I2C_CLIENT_TEN flag for validity.
Signed-off-by: default avatarVolokh Konstantin <volokh84@gmail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 523a4f7f
...@@ -196,18 +196,22 @@ int go7007_reset_encoder(struct go7007 *go) ...@@ -196,18 +196,22 @@ int go7007_reset_encoder(struct go7007 *go)
/* /*
* Attempt to instantiate an I2C client by ID, probably loading a module. * Attempt to instantiate an I2C client by ID, probably loading a module.
*/ */
static int init_i2c_module(struct i2c_adapter *adapter, const char *type, static int init_i2c_module(struct i2c_adapter *adapter, const struct go_i2c *const i2c)
int addr)
{ {
struct go7007 *go = i2c_get_adapdata(adapter); struct go7007 *go = i2c_get_adapdata(adapter);
struct v4l2_device *v4l2_dev = &go->v4l2_dev; struct v4l2_device *v4l2_dev = &go->v4l2_dev;
struct i2c_board_info info;
if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, addr, NULL)) memset(&info, 0, sizeof(info));
strlcpy(info.type, i2c->type, sizeof(info.type));
info.addr = i2c->addr;
info.flags = i2c->flags;
if (v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, NULL))
return 0; return 0;
dev_info(&adapter->dev, printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", i2c->type);
"go7007: probing for module i2c:%s failed\n", type); return -EINVAL;
return -1;
} }
/* /*
...@@ -243,9 +247,7 @@ int go7007_register_encoder(struct go7007 *go) ...@@ -243,9 +247,7 @@ int go7007_register_encoder(struct go7007 *go)
} }
if (go->i2c_adapter_online) { if (go->i2c_adapter_online) {
for (i = 0; i < go->board_info->num_i2c_devs; ++i) for (i = 0; i < go->board_info->num_i2c_devs; ++i)
init_i2c_module(&go->i2c_adapter, init_i2c_module(&go->i2c_adapter, &go->board_info->i2c_devs[i]);
go->board_info->i2c_devs[i].type,
go->board_info->i2c_devs[i].addr);
if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
i2c_clients_command(&go->i2c_adapter, i2c_clients_command(&go->i2c_adapter,
DECODER_SET_CHANNEL, &go->channel_number); DECODER_SET_CHANNEL, &go->channel_number);
......
...@@ -88,10 +88,11 @@ struct go7007_board_info { ...@@ -88,10 +88,11 @@ struct go7007_board_info {
int audio_bclk_div; int audio_bclk_div;
int audio_main_div; int audio_main_div;
int num_i2c_devs; int num_i2c_devs;
struct { struct go_i2c {
const char *type; const char *type;
int id; int id;
int addr; int addr;
u32 flags;
} i2c_devs[4]; } i2c_devs[4];
int num_inputs; int num_inputs;
struct { struct {
......
...@@ -398,6 +398,7 @@ static struct go7007_usb_board board_adlink_mpg24 = { ...@@ -398,6 +398,7 @@ static struct go7007_usb_board board_adlink_mpg24 = {
.type = "wis_tw2804", .type = "wis_tw2804",
.id = I2C_DRIVERID_WIS_TW2804, .id = I2C_DRIVERID_WIS_TW2804,
.addr = 0x00, /* yes, really */ .addr = 0x00, /* yes, really */
.flags = I2C_CLIENT_TEN,
}, },
}, },
.num_inputs = 1, .num_inputs = 1,
......
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