* [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client
@ 2014-09-25 5:07 Matthias Schwarzott
2014-09-25 5:07 ` [PATCH 02/12] cx231xx: use own i2c_client for eeprom access Matthias Schwarzott
` (11 more replies)
0 siblings, 12 replies; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:07 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-i2c.c | 17 +++++++++++------
drivers/media/usb/cx231xx/cx231xx.h | 2 +-
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 7c0f797..67a1391 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -480,22 +480,27 @@ static char *i2c_devs[128] = {
* cx231xx_do_i2c_scan()
* check i2c address range for devices
*/
-void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c)
+void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
{
unsigned char buf;
int i, rc;
+ struct i2c_client client;
- cx231xx_info(": Checking for I2C devices ..\n");
+ memset(&client, 0, sizeof(client));
+ client.adapter = &dev->i2c_bus[i2c_port].i2c_adap;
+
+ cx231xx_info(": Checking for I2C devices on port=%d ..\n", i2c_port);
for (i = 0; i < 128; i++) {
- c->addr = i;
- rc = i2c_master_recv(c, &buf, 0);
+ client.addr = i;
+ rc = i2c_master_recv(&client, &buf, 0);
if (rc < 0)
continue;
cx231xx_info("%s: i2c scan: found device @ 0x%x [%s]\n",
dev->name, i << 1,
i2c_devs[i] ? i2c_devs[i] : "???");
}
- cx231xx_info(": Completed Checking for I2C devices.\n");
+ cx231xx_info(": Completed Checking for I2C devices on port=%d.\n",
+ i2c_port);
}
/*
@@ -522,7 +527,7 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
if (0 == bus->i2c_rc) {
if (i2c_scan)
- cx231xx_do_i2c_scan(dev, &bus->i2c_client);
+ cx231xx_do_i2c_scan(dev, bus->nr);
} else
cx231xx_warn("%s: i2c bus %d register FAILED\n",
dev->name, bus->nr);
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index aeb1bf4..5efc93e 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -751,7 +751,7 @@ int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq);
int cx231xx_reset_analog_tuner(struct cx231xx *dev);
/* Provided by cx231xx-i2c.c */
-void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c);
+void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port);
int cx231xx_i2c_register(struct cx231xx_i2c *bus);
int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 02/12] cx231xx: use own i2c_client for eeprom access
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
@ 2014-09-25 5:07 ` Matthias Schwarzott
2014-09-25 14:58 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 03/12] cx231xx: delete i2c_client per bus Matthias Schwarzott
` (10 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:07 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-cards.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 791f00c..092fb85 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -980,23 +980,20 @@ static void cx231xx_config_tuner(struct cx231xx *dev)
}
-static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len)
+static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
+ u8 *eedata, int len)
{
int ret = 0;
- u8 addr = 0xa0 >> 1;
u8 start_offset = 0;
int len_todo = len;
u8 *eedata_cur = eedata;
int i;
- struct i2c_msg msg_write = { .addr = addr, .flags = 0,
+ struct i2c_msg msg_write = { .addr = client->addr, .flags = 0,
.buf = &start_offset, .len = 1 };
- struct i2c_msg msg_read = { .addr = addr, .flags = I2C_M_RD };
-
- /* mutex_lock(&dev->i2c_lock); */
- cx231xx_enable_i2c_port_3(dev, false);
+ struct i2c_msg msg_read = { .addr = client->addr, .flags = I2C_M_RD };
/* start reading at offset 0 */
- ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_write, 1);
+ ret = i2c_transfer(client->adapter, &msg_write, 1);
if (ret < 0) {
cx231xx_err("Can't read eeprom\n");
return ret;
@@ -1006,7 +1003,7 @@ static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len)
msg_read.len = (len_todo > 64) ? 64 : len_todo;
msg_read.buf = eedata_cur;
- ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_read, 1);
+ ret = i2c_transfer(client->adapter, &msg_read, 1);
if (ret < 0) {
cx231xx_err("Can't read eeprom\n");
return ret;
@@ -1062,9 +1059,14 @@ void cx231xx_card_setup(struct cx231xx *dev)
{
struct tveeprom tvee;
static u8 eeprom[256];
+ struct i2c_client client;
+
+ memset(&client, 0, sizeof(client));
+ client.adapter = &dev->i2c_bus[1].i2c_adap;
+ client.addr = 0xa0 >> 1;
- read_eeprom(dev, eeprom, sizeof(eeprom));
- tveeprom_hauppauge_analog(&dev->i2c_bus[1].i2c_client,
+ read_eeprom(dev, &client, eeprom, sizeof(eeprom));
+ tveeprom_hauppauge_analog(&client,
&tvee, eeprom + 0xc0);
break;
}
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 03/12] cx231xx: delete i2c_client per bus
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
2014-09-25 5:07 ` [PATCH 02/12] cx231xx: use own i2c_client for eeprom access Matthias Schwarzott
@ 2014-09-25 5:07 ` Matthias Schwarzott
2014-09-25 15:00 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 04/12] cx231xx: give each master i2c bus a seperate name Matthias Schwarzott
` (9 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:07 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-i2c.c | 7 -------
drivers/media/usb/cx231xx/cx231xx.h | 1 -
2 files changed, 8 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 67a1391..a30d400 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -455,10 +455,6 @@ static struct i2c_adapter cx231xx_adap_template = {
.algo = &cx231xx_algo,
};
-static struct i2c_client cx231xx_client_template = {
- .name = "cx231xx internal",
-};
-
/* ----------------------------------------------------------- */
/*
@@ -514,7 +510,6 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
BUG_ON(!dev->cx231xx_send_usb_command);
bus->i2c_adap = cx231xx_adap_template;
- bus->i2c_client = cx231xx_client_template;
bus->i2c_adap.dev.parent = &dev->udev->dev;
strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name));
@@ -523,8 +518,6 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
i2c_add_adapter(&bus->i2c_adap);
- bus->i2c_client.adapter = &bus->i2c_adap;
-
if (0 == bus->i2c_rc) {
if (i2c_scan)
cx231xx_do_i2c_scan(dev, bus->nr);
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 5efc93e..c92382f 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -472,7 +472,6 @@ struct cx231xx_i2c {
/* i2c i/o */
struct i2c_adapter i2c_adap;
- struct i2c_client i2c_client;
u32 i2c_rc;
/* different settings for each bus */
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 04/12] cx231xx: give each master i2c bus a seperate name
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
2014-09-25 5:07 ` [PATCH 02/12] cx231xx: use own i2c_client for eeprom access Matthias Schwarzott
2014-09-25 5:07 ` [PATCH 03/12] cx231xx: delete i2c_client per bus Matthias Schwarzott
@ 2014-09-25 5:07 ` Matthias Schwarzott
2014-09-25 15:04 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 05/12] cx231xx: Use symbolic constants for i2c ports Matthias Schwarzott
` (8 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:07 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-i2c.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index a30d400..178fa48 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -506,6 +506,7 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
int cx231xx_i2c_register(struct cx231xx_i2c *bus)
{
struct cx231xx *dev = bus->dev;
+ char bus_name[3];
BUG_ON(!dev->cx231xx_send_usb_command);
@@ -513,6 +514,10 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
bus->i2c_adap.dev.parent = &dev->udev->dev;
strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name));
+ bus_name[0] = '-';
+ bus_name[1] = '0' + bus->nr;
+ bus_name[2] = '\0';
+ strlcat(bus->i2c_adap.name, bus_name, sizeof(bus->i2c_adap.name));
bus->i2c_adap.algo_data = bus;
i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 05/12] cx231xx: Use symbolic constants for i2c ports
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (2 preceding siblings ...)
2014-09-25 5:07 ` [PATCH 04/12] cx231xx: give each master i2c bus a seperate name Matthias Schwarzott
@ 2014-09-25 5:07 ` Matthias Schwarzott
2014-09-25 15:06 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 06/12] cx231xx: add wrapper to get the i2c_adapter pointer Matthias Schwarzott
` (7 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:07 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
use already existing I2C_0 ... I2C_3
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-cards.c | 62 +++++++++++++++----------------
drivers/media/usb/cx231xx/cx231xx.h | 8 ++--
2 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 092fb85..2f027c7 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -104,8 +104,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x02,
.norm = V4L2_STD_PAL,
@@ -144,8 +144,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x32,
.norm = V4L2_STD_NTSC,
@@ -184,8 +184,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x1c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x02,
.norm = V4L2_STD_PAL,
@@ -225,8 +225,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x1c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x02,
.norm = V4L2_STD_PAL,
@@ -297,8 +297,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x02,
.norm = V4L2_STD_PAL,
@@ -325,8 +325,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x32,
.norm = V4L2_STD_NTSC,
@@ -353,8 +353,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x0e,
.norm = V4L2_STD_NTSC,
@@ -418,9 +418,9 @@ struct cx231xx_board cx231xx_boards[] = {
.tuner_scl_gpio = -1,
.tuner_sda_gpio = -1,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 2,
- .demod_i2c_master = 1,
- .ir_i2c_master = 2,
+ .tuner_i2c_master = I2C_2,
+ .demod_i2c_master = I2C_1,
+ .ir_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x10,
.norm = V4L2_STD_PAL_M,
@@ -456,9 +456,9 @@ struct cx231xx_board cx231xx_boards[] = {
.tuner_scl_gpio = -1,
.tuner_sda_gpio = -1,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 2,
- .demod_i2c_master = 1,
- .ir_i2c_master = 2,
+ .tuner_i2c_master = I2C_2,
+ .demod_i2c_master = I2C_1,
+ .ir_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x10,
.norm = V4L2_STD_NTSC_M,
@@ -494,9 +494,9 @@ struct cx231xx_board cx231xx_boards[] = {
.tuner_scl_gpio = -1,
.tuner_sda_gpio = -1,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 2,
- .demod_i2c_master = 1,
- .ir_i2c_master = 2,
+ .tuner_i2c_master = I2C_2,
+ .demod_i2c_master = I2C_1,
+ .ir_i2c_master = I2C_2,
.rc_map_name = RC_MAP_PIXELVIEW_002T,
.has_dvb = 1,
.demod_addr = 0x10,
@@ -587,7 +587,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
+ .tuner_i2c_master = I2C_1,
.norm = V4L2_STD_PAL,
.input = {{
@@ -622,7 +622,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
+ .tuner_i2c_master = I2C_1,
.norm = V4L2_STD_NTSC,
.input = {{
@@ -718,8 +718,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x0e,
.norm = V4L2_STD_PAL,
@@ -757,8 +757,8 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = 1,
- .demod_i2c_master = 2,
+ .tuner_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x0e,
.norm = V4L2_STD_PAL,
@@ -1033,7 +1033,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
/* request some modules */
if (dev->board.decoder == CX231XX_AVDECODER) {
dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
- &dev->i2c_bus[0].i2c_adap,
+ &dev->i2c_bus[I2C_0].i2c_adap,
"cx25840", 0x88 >> 1, NULL);
if (dev->sd_cx25840 == NULL)
cx231xx_info("cx25840 subdev registration failure\n");
@@ -1062,7 +1062,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
struct i2c_client client;
memset(&client, 0, sizeof(client));
- client.adapter = &dev->i2c_bus[1].i2c_adap;
+ client.adapter = &dev->i2c_bus[I2C_1].i2c_adap;
client.addr = 0xa0 >> 1;
read_eeprom(dev, &client, eeprom, sizeof(eeprom));
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index c92382f..3ab107a 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -322,10 +322,10 @@ enum cx231xx_decoder {
};
enum CX231XX_I2C_MASTER_PORT {
- I2C_0 = 0,
- I2C_1 = 1,
- I2C_2 = 2,
- I2C_3 = 3
+ I2C_0 = 0, /* master 0 - internal connection */
+ I2C_1 = 1, /* master 1 - I2C_DEMOD_EN = 0 */
+ I2C_2 = 2, /* master 2 */
+ I2C_3 = 3 /* master 1 - I2C_DEMOD_EN = 1 */
};
struct cx231xx_board {
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 06/12] cx231xx: add wrapper to get the i2c_adapter pointer
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (3 preceding siblings ...)
2014-09-25 5:07 ` [PATCH 05/12] cx231xx: Use symbolic constants for i2c ports Matthias Schwarzott
@ 2014-09-25 5:07 ` Matthias Schwarzott
2014-09-25 15:13 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 07/12] cx231xx: remember status of port_3 switch Matthias Schwarzott
` (6 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:07 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
Already map unused I2C_3 to adapter number 1 to prepare for switching.
Add local variables for i2c_adapters in dvb_init to get line lengths
shorter.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-cards.c | 8 +++---
drivers/media/usb/cx231xx/cx231xx-dvb.c | 42 +++++++++++++++++--------------
drivers/media/usb/cx231xx/cx231xx-i2c.c | 19 +++++++++++++-
drivers/media/usb/cx231xx/cx231xx-input.c | 3 ++-
drivers/media/usb/cx231xx/cx231xx.h | 1 +
5 files changed, 49 insertions(+), 24 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 2f027c7..330fe39 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1033,7 +1033,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
/* request some modules */
if (dev->board.decoder == CX231XX_AVDECODER) {
dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
- &dev->i2c_bus[I2C_0].i2c_adap,
+ cx231xx_get_i2c_adap(dev, I2C_0),
"cx25840", 0x88 >> 1, NULL);
if (dev->sd_cx25840 == NULL)
cx231xx_info("cx25840 subdev registration failure\n");
@@ -1043,8 +1043,10 @@ void cx231xx_card_setup(struct cx231xx *dev)
/* Initialize the tuner */
if (dev->board.tuner_type != TUNER_ABSENT) {
+ struct tuner_i2c = cx231xx_get_i2c_adap(dev,
+ dev->board.tuner_i2c_master);
dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev,
- &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ tuner_i2c,
"tuner",
dev->tuner_addr, NULL);
if (dev->sd_tuner == NULL)
@@ -1062,7 +1064,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
struct i2c_client client;
memset(&client, 0, sizeof(client));
- client.adapter = &dev->i2c_bus[I2C_1].i2c_adap;
+ client.adapter = cx231xx_get_i2c_adap(dev, I2C_1);
client.addr = 0xa0 >> 1;
read_eeprom(dev, &client, eeprom, sizeof(eeprom));
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 6c7b5e2..869c433 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -378,7 +378,7 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev)
struct xc5000_config cfg;
memset(&cfg, 0, sizeof(cfg));
- cfg.i2c_adap = &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap;
+ cfg.i2c_adap = cx231xx_get_i2c_adap(dev, dev->board.tuner_i2c_master);
cfg.i2c_addr = addr;
if (!dev->dvb->frontend) {
@@ -583,6 +583,8 @@ static int dvb_init(struct cx231xx *dev)
{
int result = 0;
struct cx231xx_dvb *dvb;
+ struct i2c_adapter *tuner_i2c;
+ struct i2c_adapter *demod_i2c;
if (!dev->board.has_dvb) {
/* This device does not support the extension */
@@ -599,6 +601,8 @@ static int dvb_init(struct cx231xx *dev)
dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq;
dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner;
+ tuner_i2c = cx231xx_get_i2c_adap(dev, dev->board.tuner_i2c_master);
+ demod_i2c = cx231xx_get_i2c_adap(dev, dev->board.demod_i2c_master);
mutex_lock(&dev->lock);
cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE);
cx231xx_demod_reset(dev);
@@ -609,7 +613,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(s5h1432_attach,
&dvico_s5h1432_config,
- &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
+ demod_i2c);
if (dev->dvb->frontend == NULL) {
printk(DRIVER_NAME
@@ -622,7 +626,7 @@ static int dvb_init(struct cx231xx *dev)
dvb->frontend->callback = cx231xx_tuner_callback;
if (!dvb_attach(xc5000_attach, dev->dvb->frontend,
- &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ tuner_i2c,
&cnxt_rde250_tunerconfig)) {
result = -EINVAL;
goto out_free;
@@ -634,7 +638,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(s5h1411_attach,
&xc5000_s5h1411_config,
- &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
+ demod_i2c);
if (dev->dvb->frontend == NULL) {
printk(DRIVER_NAME
@@ -647,7 +651,7 @@ static int dvb_init(struct cx231xx *dev)
dvb->frontend->callback = cx231xx_tuner_callback;
if (!dvb_attach(xc5000_attach, dev->dvb->frontend,
- &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ tuner_i2c,
&cnxt_rdu250_tunerconfig)) {
result = -EINVAL;
goto out_free;
@@ -657,7 +661,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(s5h1432_attach,
&dvico_s5h1432_config,
- &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
+ demod_i2c);
if (dev->dvb->frontend == NULL) {
printk(DRIVER_NAME
@@ -670,7 +674,7 @@ static int dvb_init(struct cx231xx *dev)
dvb->frontend->callback = cx231xx_tuner_callback;
if (!dvb_attach(tda18271_attach, dev->dvb->frontend,
- 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ 0x60, tuner_i2c,
&cnxt_rde253s_tunerconfig)) {
result = -EINVAL;
goto out_free;
@@ -681,7 +685,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(s5h1411_attach,
&tda18271_s5h1411_config,
- &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
+ demod_i2c);
if (dev->dvb->frontend == NULL) {
printk(DRIVER_NAME
@@ -694,7 +698,7 @@ static int dvb_init(struct cx231xx *dev)
dvb->frontend->callback = cx231xx_tuner_callback;
if (!dvb_attach(tda18271_attach, dev->dvb->frontend,
- 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ 0x60, tuner_i2c,
&cnxt_rde253s_tunerconfig)) {
result = -EINVAL;
goto out_free;
@@ -703,11 +707,11 @@ static int dvb_init(struct cx231xx *dev)
case CX231XX_BOARD_HAUPPAUGE_EXETER:
printk(KERN_INFO "%s: looking for tuner / demod on i2c bus: %d\n",
- __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap));
+ __func__, i2c_adapter_id(tuner_i2c));
dev->dvb->frontend = dvb_attach(lgdt3305_attach,
&hcw_lgdt3305_config,
- &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap);
+ tuner_i2c);
if (dev->dvb->frontend == NULL) {
printk(DRIVER_NAME
@@ -720,7 +724,7 @@ static int dvb_init(struct cx231xx *dev)
dvb->frontend->callback = cx231xx_tuner_callback;
dvb_attach(tda18271_attach, dev->dvb->frontend,
- 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ 0x60, tuner_i2c,
&hcw_tda18271_config);
break;
@@ -728,7 +732,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(si2165_attach,
&hauppauge_930C_HD_1113xx_si2165_config,
- &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap
+ tuner_i2c
);
if (dev->dvb->frontend == NULL) {
@@ -745,7 +749,7 @@ static int dvb_init(struct cx231xx *dev)
dvb_attach(tda18271_attach, dev->dvb->frontend,
0x60,
- &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ tuner_i2c,
&hcw_tda18271_config);
dev->cx231xx_reset_analog_tuner = NULL;
@@ -761,7 +765,7 @@ static int dvb_init(struct cx231xx *dev)
dev->dvb->frontend = dvb_attach(si2165_attach,
&pctv_quatro_stick_1114xx_si2165_config,
- &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap
+ tuner_i2c
);
if (dev->dvb->frontend == NULL) {
@@ -786,7 +790,7 @@ static int dvb_init(struct cx231xx *dev)
request_module("si2157");
client = i2c_new_device(
- &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ tuner_i2c,
&info);
if (client == NULL || client->dev.driver == NULL) {
dvb_frontend_detach(dev->dvb->frontend);
@@ -811,11 +815,11 @@ static int dvb_init(struct cx231xx *dev)
case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID:
printk(KERN_INFO "%s: looking for demod on i2c bus: %d\n",
- __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap));
+ __func__, i2c_adapter_id(tuner_i2c));
dev->dvb->frontend = dvb_attach(mb86a20s_attach,
&pv_mb86a20s_config,
- &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
+ demod_i2c);
if (dev->dvb->frontend == NULL) {
printk(DRIVER_NAME
@@ -828,7 +832,7 @@ static int dvb_init(struct cx231xx *dev)
dvb->frontend->callback = cx231xx_tuner_callback;
dvb_attach(tda18271_attach, dev->dvb->frontend,
- 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
+ 0x60, tuner_i2c,
&pv_tda18271_config);
break;
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 178fa48..86f90c0 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -483,7 +483,7 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
struct i2c_client client;
memset(&client, 0, sizeof(client));
- client.adapter = &dev->i2c_bus[i2c_port].i2c_adap;
+ client.adapter = cx231xx_get_i2c_adap(dev, i2c_port);
cx231xx_info(": Checking for I2C devices on port=%d ..\n", i2c_port);
for (i = 0; i < 128; i++) {
@@ -542,3 +542,20 @@ int cx231xx_i2c_unregister(struct cx231xx_i2c *bus)
i2c_del_adapter(&bus->i2c_adap);
return 0;
}
+
+struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port)
+{
+ switch (i2c_port) {
+ case I2C_0:
+ return &dev->i2c_bus[0].i2c_adap;
+ case I2C_1:
+ return &dev->i2c_bus[1].i2c_adap;
+ case I2C_2:
+ return &dev->i2c_bus[2].i2c_adap;
+ case I2C_3:
+ return &dev->i2c_bus[1].i2c_adap;
+ default:
+ return NULL;
+ }
+}
+EXPORT_SYMBOL_GPL(cx231xx_get_i2c_adap);
diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c
index 05f0434..5ae2ce3 100644
--- a/drivers/media/usb/cx231xx/cx231xx-input.c
+++ b/drivers/media/usb/cx231xx/cx231xx-input.c
@@ -100,7 +100,8 @@ int cx231xx_ir_init(struct cx231xx *dev)
ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master;
dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n",
ir_i2c_bus, info.addr);
- dev->ir_i2c_client = i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info);
+ dev->ir_i2c_client = i2c_new_device(
+ cx231xx_get_i2c_adap(dev, ir_i2c_bus), &info);
return 0;
}
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 3ab107a..2118d00 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -753,6 +753,7 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev);
void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port);
int cx231xx_i2c_register(struct cx231xx_i2c *bus);
int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
+struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port);
/* Internal block control functions */
int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr,
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 07/12] cx231xx: remember status of port_3 switch
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (4 preceding siblings ...)
2014-09-25 5:07 ` [PATCH 06/12] cx231xx: add wrapper to get the i2c_adapter pointer Matthias Schwarzott
@ 2014-09-25 5:07 ` Matthias Schwarzott
2014-09-25 5:08 ` [PATCH 08/12] cx231xx: let is_tuner check the real i2c port and not the i2c master number Matthias Schwarzott
` (5 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:07 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
Is remembering stable enough, or must this state be queried from the register when needed.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-avcore.c | 3 +++
drivers/media/usb/cx231xx/cx231xx.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c b/drivers/media/usb/cx231xx/cx231xx-avcore.c
index 51872b9..d31ea57 100644
--- a/drivers/media/usb/cx231xx/cx231xx-avcore.c
+++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c
@@ -1294,6 +1294,9 @@ int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3)
status = cx231xx_write_ctrl_reg(dev, VRT_SET_REGISTER,
PWR_CTL_EN, value, 4);
+ if (status >= 0)
+ dev->port_3_switch_enabled = is_port_3;
+
return status;
}
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 2118d00..cefeb30 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -628,6 +628,7 @@ struct cx231xx {
/* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */
struct cx231xx_i2c i2c_bus[3];
unsigned int xc_fw_load_done:1;
+ unsigned int port_3_switch_enabled:1;
/* locks */
struct mutex gpio_i2c_lock;
struct mutex i2c_lock;
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 08/12] cx231xx: let is_tuner check the real i2c port and not the i2c master number
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (5 preceding siblings ...)
2014-09-25 5:07 ` [PATCH 07/12] cx231xx: remember status of port_3 switch Matthias Schwarzott
@ 2014-09-25 5:08 ` Matthias Schwarzott
2014-09-25 5:08 ` [PATCH 09/12] cx231xx: change usage of I2C_1 to the real i2c port Matthias Schwarzott
` (4 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:08 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
get used i2c port from bus_nr and status of port_3 switch
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-i2c.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 86f90c0..a8c0f90 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -54,10 +54,19 @@ do { \
} \
} while (0)
+static inline int get_real_i2c_port(struct cx231xx *dev, int bus_nr)
+{
+ if (bus_nr == 1)
+ return dev->port_3_switch_enabled ? I2C_3 : I2C_1;
+ return bus_nr;
+}
+
static inline bool is_tuner(struct cx231xx *dev, struct cx231xx_i2c *bus,
const struct i2c_msg *msg, int tuner_type)
{
- if (bus->nr != dev->board.tuner_i2c_master)
+ int i2c_port = get_real_i2c_port(dev, bus->nr);
+
+ if (i2c_port != dev->board.tuner_i2c_master)
return false;
if (msg->addr != dev->board.tuner_addr)
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 09/12] cx231xx: change usage of I2C_1 to the real i2c port
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (6 preceding siblings ...)
2014-09-25 5:08 ` [PATCH 08/12] cx231xx: let is_tuner check the real i2c port and not the i2c master number Matthias Schwarzott
@ 2014-09-25 5:08 ` Matthias Schwarzott
2014-09-25 5:08 ` [PATCH 10/12] cx231xx: register i2c mux adapters for master1 and use as I2C_1 and I2C_3 Matthias Schwarzott
` (3 subsequent siblings)
11 siblings, 0 replies; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:08 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
change almost all instances of I2C_1 to I2C_3
Keep I2C_1 for these cases:
* All that have dont_use_port_3 set.
* CX231XX_BOARD_HAUPPAUGE_EXETER, old code did explicitly not switch to port3.
* eeprom access for 930C
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-cards.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index 330fe39..a6fdb6f 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -104,7 +104,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x02,
@@ -144,7 +144,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x32,
@@ -184,7 +184,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x1c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x02,
@@ -225,7 +225,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x1c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x02,
@@ -297,7 +297,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x02,
@@ -325,7 +325,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x32,
@@ -419,7 +419,7 @@ struct cx231xx_board cx231xx_boards[] = {
.tuner_sda_gpio = -1,
.gpio_pin_status_mask = 0x4001000,
.tuner_i2c_master = I2C_2,
- .demod_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_3,
.ir_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x10,
@@ -457,7 +457,7 @@ struct cx231xx_board cx231xx_boards[] = {
.tuner_sda_gpio = -1,
.gpio_pin_status_mask = 0x4001000,
.tuner_i2c_master = I2C_2,
- .demod_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_3,
.ir_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x10,
@@ -495,7 +495,7 @@ struct cx231xx_board cx231xx_boards[] = {
.tuner_sda_gpio = -1,
.gpio_pin_status_mask = 0x4001000,
.tuner_i2c_master = I2C_2,
- .demod_i2c_master = I2C_1,
+ .demod_i2c_master = I2C_3,
.ir_i2c_master = I2C_2,
.rc_map_name = RC_MAP_PIXELVIEW_002T,
.has_dvb = 1,
@@ -587,7 +587,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.norm = V4L2_STD_PAL,
.input = {{
@@ -622,7 +622,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.norm = V4L2_STD_NTSC,
.input = {{
@@ -718,7 +718,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x0e,
@@ -757,7 +757,7 @@ struct cx231xx_board cx231xx_boards[] = {
.ctl_pin_status_mask = 0xFFFFFFC4,
.agc_analog_digital_select_gpio = 0x0c,
.gpio_pin_status_mask = 0x4001000,
- .tuner_i2c_master = I2C_1,
+ .tuner_i2c_master = I2C_3,
.demod_i2c_master = I2C_2,
.has_dvb = 1,
.demod_addr = 0x0e,
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 10/12] cx231xx: register i2c mux adapters for master1 and use as I2C_1 and I2C_3
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (7 preceding siblings ...)
2014-09-25 5:08 ` [PATCH 09/12] cx231xx: change usage of I2C_1 to the real i2c port Matthias Schwarzott
@ 2014-09-25 5:08 ` Matthias Schwarzott
2014-09-25 15:25 ` Antti Palosaari
2014-09-25 5:08 ` [PATCH 11/12] cx231xx: drop unconditional port3 switching Matthias Schwarzott
` (2 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:08 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/Kconfig | 1 +
drivers/media/usb/cx231xx/cx231xx-core.c | 5 ++++
drivers/media/usb/cx231xx/cx231xx-i2c.c | 45 ++++++++++++++++++++++++++++++--
drivers/media/usb/cx231xx/cx231xx.h | 4 +++
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/drivers/media/usb/cx231xx/Kconfig b/drivers/media/usb/cx231xx/Kconfig
index 569aa29..173c0e2 100644
--- a/drivers/media/usb/cx231xx/Kconfig
+++ b/drivers/media/usb/cx231xx/Kconfig
@@ -7,6 +7,7 @@ config VIDEO_CX231XX
select VIDEOBUF_VMALLOC
select VIDEO_CX25840
select VIDEO_CX2341X
+ select I2C_MUX
---help---
This is a video4linux driver for Conexant 231xx USB based TV cards.
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
index 180103e..c8a6d20 100644
--- a/drivers/media/usb/cx231xx/cx231xx-core.c
+++ b/drivers/media/usb/cx231xx/cx231xx-core.c
@@ -1300,6 +1300,9 @@ int cx231xx_dev_init(struct cx231xx *dev)
cx231xx_i2c_register(&dev->i2c_bus[1]);
cx231xx_i2c_register(&dev->i2c_bus[2]);
+ cx231xx_i2c_mux_register(dev, 0);
+ cx231xx_i2c_mux_register(dev, 1);
+
/* init hardware */
/* Note : with out calling set power mode function,
afe can not be set up correctly */
@@ -1414,6 +1417,8 @@ EXPORT_SYMBOL_GPL(cx231xx_dev_init);
void cx231xx_dev_uninit(struct cx231xx *dev)
{
/* Un Initialize I2C bus */
+ cx231xx_i2c_mux_unregister(dev, 1);
+ cx231xx_i2c_mux_unregister(dev, 0);
cx231xx_i2c_unregister(&dev->i2c_bus[2]);
cx231xx_i2c_unregister(&dev->i2c_bus[1]);
cx231xx_i2c_unregister(&dev->i2c_bus[0]);
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index a8c0f90..848aec2 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -24,6 +24,7 @@
#include <linux/kernel.h>
#include <linux/usb.h>
#include <linux/i2c.h>
+#include <linux/i2c-mux.h>
#include <media/v4l2-common.h>
#include <media/tuner.h>
@@ -552,17 +553,57 @@ int cx231xx_i2c_unregister(struct cx231xx_i2c *bus)
return 0;
}
+/*
+ * cx231xx_i2c_mux_select()
+ * switch i2c master number 1 between port1 and port3
+ */
+static int cx231xx_i2c_mux_select(struct i2c_adapter *adap,
+ void *mux_priv, u32 chan_id)
+{
+ struct cx231xx *dev = mux_priv;
+
+ return cx231xx_enable_i2c_port_3(dev, chan_id);
+}
+
+int cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no)
+{
+ struct i2c_adapter *i2c_parent = &dev->i2c_bus[1].i2c_adap;
+ /* what is the correct mux_dev? */
+ struct device *mux_dev = &dev->udev->dev;
+
+ dev->i2c_mux_adap[mux_no] = i2c_add_mux_adapter(i2c_parent,
+ mux_dev,
+ dev /* mux_priv */,
+ 0,
+ mux_no /* chan_id */,
+ 0 /* class */,
+ &cx231xx_i2c_mux_select,
+ NULL);
+
+ if (!dev->i2c_mux_adap[mux_no])
+ cx231xx_warn("%s: i2c mux %d register FAILED\n",
+ dev->name, mux_no);
+
+ return 0;
+}
+
+void cx231xx_i2c_mux_unregister(struct cx231xx *dev, int mux_no)
+{
+ i2c_del_mux_adapter(dev->i2c_mux_adap[mux_no]);
+ dev->i2c_mux_adap[mux_no] = NULL;
+}
+
struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port)
{
switch (i2c_port) {
case I2C_0:
return &dev->i2c_bus[0].i2c_adap;
case I2C_1:
- return &dev->i2c_bus[1].i2c_adap;
+ return dev->i2c_mux_adap[0];
case I2C_2:
return &dev->i2c_bus[2].i2c_adap;
case I2C_3:
- return &dev->i2c_bus[1].i2c_adap;
+ return dev->i2c_mux_adap[1];
default:
return NULL;
}
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index cefeb30..9234cd7 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -627,6 +627,8 @@ struct cx231xx {
/* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */
struct cx231xx_i2c i2c_bus[3];
+ struct i2c_adapter *i2c_mux_adap[2];
+
unsigned int xc_fw_load_done:1;
unsigned int port_3_switch_enabled:1;
/* locks */
@@ -754,6 +756,8 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev);
void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port);
int cx231xx_i2c_register(struct cx231xx_i2c *bus);
int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
+int cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no);
+void cx231xx_i2c_mux_unregister(struct cx231xx *dev, int mux_no);
struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port);
/* Internal block control functions */
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 11/12] cx231xx: drop unconditional port3 switching
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (8 preceding siblings ...)
2014-09-25 5:08 ` [PATCH 10/12] cx231xx: register i2c mux adapters for master1 and use as I2C_1 and I2C_3 Matthias Schwarzott
@ 2014-09-25 5:08 ` Matthias Schwarzott
2014-09-25 15:26 ` Antti Palosaari
2014-09-25 5:08 ` [PATCH 12/12] cx231xx: scan all four existing i2c busses instead of the 3 masters Matthias Schwarzott
2014-09-25 14:50 ` [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Antti Palosaari
11 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:08 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
All switching should be done by i2c mux adapters.
Drop explicit dont_use_port_3 flag.
Drop info message about switch.
Only the removed code in start_streaming is questionable:
It did switch the port_3 flag without accessing i2c in between.
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-avcore.c | 17 -----------------
drivers/media/usb/cx231xx/cx231xx-cards.c | 8 --------
drivers/media/usb/cx231xx/cx231xx-core.c | 4 +---
drivers/media/usb/cx231xx/cx231xx-dvb.c | 4 ----
drivers/media/usb/cx231xx/cx231xx.h | 1 -
5 files changed, 1 insertion(+), 33 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c b/drivers/media/usb/cx231xx/cx231xx-avcore.c
index d31ea57..138ee5e 100644
--- a/drivers/media/usb/cx231xx/cx231xx-avcore.c
+++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c
@@ -1270,8 +1270,6 @@ int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3)
int status = 0;
bool current_is_port_3;
- if (dev->board.dont_use_port_3)
- is_port_3 = false;
status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER,
PWR_CTL_EN, value, 4);
if (status < 0)
@@ -1288,9 +1286,6 @@ int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3)
else
value[0] &= ~I2C_DEMOD_EN;
- 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);
@@ -2320,9 +2315,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode)
}
if (dev->board.tuner_type != TUNER_ABSENT) {
- /* Enable tuner */
- cx231xx_enable_i2c_port_3(dev, true);
-
/* reset the Tuner */
if (dev->board.tuner_gpio)
cx231xx_gpio_set(dev, dev->board.tuner_gpio);
@@ -2387,15 +2379,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode)
}
if (dev->board.tuner_type != TUNER_ABSENT) {
- /*
- * Enable tuner
- * Hauppauge Exeter seems to need to do something different!
- */
- 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 */
if (dev->board.tuner_gpio)
cx231xx_gpio_set(dev, dev->board.tuner_gpio);
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index a6fdb6f..0a0a4e9 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -262,7 +262,6 @@ struct cx231xx_board cx231xx_boards[] = {
.norm = V4L2_STD_PAL,
.no_alt_vanc = 1,
.external_av = 1,
- .dont_use_port_3 = 1,
/* Actually, it has a 417, but it isn't working correctly.
* So set to 0 for now until someone can manage to get this
* to work reliably. */
@@ -390,7 +389,6 @@ struct cx231xx_board cx231xx_boards[] = {
.norm = V4L2_STD_NTSC,
.no_alt_vanc = 1,
.external_av = 1,
- .dont_use_port_3 = 1,
.input = {{
.type = CX231XX_VMUX_COMPOSITE1,
.vmux = CX231XX_VIN_2_1,
@@ -532,7 +530,6 @@ struct cx231xx_board cx231xx_boards[] = {
.norm = V4L2_STD_NTSC,
.no_alt_vanc = 1,
.external_av = 1,
- .dont_use_port_3 = 1,
.input = {{
.type = CX231XX_VMUX_COMPOSITE1,
@@ -656,7 +653,6 @@ struct cx231xx_board cx231xx_boards[] = {
.norm = V4L2_STD_NTSC,
.no_alt_vanc = 1,
.external_av = 1,
- .dont_use_port_3 = 1,
.input = {{
.type = CX231XX_VMUX_COMPOSITE1,
.vmux = CX231XX_VIN_2_1,
@@ -683,7 +679,6 @@ struct cx231xx_board cx231xx_boards[] = {
.norm = V4L2_STD_NTSC,
.no_alt_vanc = 1,
.external_av = 1,
- .dont_use_port_3 = 1,
/*.has_417 = 1, */
/* This board is believed to have a hardware encoding chip
* supporting mpeg1/2/4, but as the 417 is apparently not
@@ -1012,9 +1007,6 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
len_todo -= msg_read.len;
}
- cx231xx_enable_i2c_port_3(dev, true);
- /* mutex_unlock(&dev->i2c_lock); */
-
for (i = 0; i + 15 < len; i += 16)
cx231xx_info("i2c eeprom %02x: %*ph\n", i, 16, &eedata[i]);
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
index c8a6d20..c49022f 100644
--- a/drivers/media/usb/cx231xx/cx231xx-core.c
+++ b/drivers/media/usb/cx231xx/cx231xx-core.c
@@ -1407,9 +1407,7 @@ int cx231xx_dev_init(struct cx231xx *dev)
if (dev->board.has_dvb)
cx231xx_set_alt_setting(dev, INDEX_TS1, 0);
- /* set the I2C master port to 3 on channel 1 */
- errCode = cx231xx_enable_i2c_port_3(dev, true);
-
+ errCode = 0;
return errCode;
}
EXPORT_SYMBOL_GPL(cx231xx_dev_init);
diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
index 869c433..2ea6946 100644
--- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
+++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
@@ -266,11 +266,7 @@ static int start_streaming(struct cx231xx_dvb *dvb)
if (dev->USE_ISO) {
cx231xx_info("DVB transfer mode is ISO.\n");
- mutex_lock(&dev->i2c_lock);
- cx231xx_enable_i2c_port_3(dev, false);
cx231xx_set_alt_setting(dev, INDEX_TS1, 4);
- cx231xx_enable_i2c_port_3(dev, true);
- mutex_unlock(&dev->i2c_lock);
rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE);
if (rc < 0)
return rc;
diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
index 9234cd7..b8daff6 100644
--- a/drivers/media/usb/cx231xx/cx231xx.h
+++ b/drivers/media/usb/cx231xx/cx231xx.h
@@ -367,7 +367,6 @@ struct cx231xx_board {
unsigned int valid:1;
unsigned int no_alt_vanc:1;
unsigned int external_av:1;
- unsigned int dont_use_port_3:1;
unsigned char xclk, i2c_speed;
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [PATCH 12/12] cx231xx: scan all four existing i2c busses instead of the 3 masters
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (9 preceding siblings ...)
2014-09-25 5:08 ` [PATCH 11/12] cx231xx: drop unconditional port3 switching Matthias Schwarzott
@ 2014-09-25 5:08 ` Matthias Schwarzott
2014-09-25 15:30 ` Antti Palosaari
2014-09-25 14:50 ` [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Antti Palosaari
11 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-25 5:08 UTC (permalink / raw)
To: linux-media, mchehab; +Cc: Matthias Schwarzott
Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
---
drivers/media/usb/cx231xx/cx231xx-core.c | 6 ++++++
drivers/media/usb/cx231xx/cx231xx-i2c.c | 8 ++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
index c49022f..f6b6d26 100644
--- a/drivers/media/usb/cx231xx/cx231xx-core.c
+++ b/drivers/media/usb/cx231xx/cx231xx-core.c
@@ -1303,6 +1303,12 @@ int cx231xx_dev_init(struct cx231xx *dev)
cx231xx_i2c_mux_register(dev, 0);
cx231xx_i2c_mux_register(dev, 1);
+ /* scan the real bus segments */
+ cx231xx_do_i2c_scan(dev, I2C_0);
+ cx231xx_do_i2c_scan(dev, I2C_1);
+ cx231xx_do_i2c_scan(dev, I2C_2);
+ cx231xx_do_i2c_scan(dev, I2C_3);
+
/* init hardware */
/* Note : with out calling set power mode function,
afe can not be set up correctly */
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index 848aec2..13c476c 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -492,6 +492,9 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
int i, rc;
struct i2c_client client;
+ if (!i2c_scan)
+ return;
+
memset(&client, 0, sizeof(client));
client.adapter = cx231xx_get_i2c_adap(dev, i2c_port);
@@ -533,10 +536,7 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
i2c_add_adapter(&bus->i2c_adap);
- if (0 == bus->i2c_rc) {
- if (i2c_scan)
- cx231xx_do_i2c_scan(dev, bus->nr);
- } else
+ if (0 != bus->i2c_rc)
cx231xx_warn("%s: i2c bus %d register FAILED\n",
dev->name, bus->nr);
--
2.1.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
` (10 preceding siblings ...)
2014-09-25 5:08 ` [PATCH 12/12] cx231xx: scan all four existing i2c busses instead of the 3 masters Matthias Schwarzott
@ 2014-09-25 14:50 ` Antti Palosaari
11 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 14:50 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
Reviewed-by: Antti Palosaari <crope@iki.fi>
Antti
On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/cx231xx-i2c.c | 17 +++++++++++------
> drivers/media/usb/cx231xx/cx231xx.h | 2 +-
> 2 files changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> index 7c0f797..67a1391 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> @@ -480,22 +480,27 @@ static char *i2c_devs[128] = {
> * cx231xx_do_i2c_scan()
> * check i2c address range for devices
> */
> -void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c)
> +void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
> {
> unsigned char buf;
> int i, rc;
> + struct i2c_client client;
>
> - cx231xx_info(": Checking for I2C devices ..\n");
> + memset(&client, 0, sizeof(client));
> + client.adapter = &dev->i2c_bus[i2c_port].i2c_adap;
> +
> + cx231xx_info(": Checking for I2C devices on port=%d ..\n", i2c_port);
> for (i = 0; i < 128; i++) {
> - c->addr = i;
> - rc = i2c_master_recv(c, &buf, 0);
> + client.addr = i;
> + rc = i2c_master_recv(&client, &buf, 0);
> if (rc < 0)
> continue;
> cx231xx_info("%s: i2c scan: found device @ 0x%x [%s]\n",
> dev->name, i << 1,
> i2c_devs[i] ? i2c_devs[i] : "???");
> }
> - cx231xx_info(": Completed Checking for I2C devices.\n");
> + cx231xx_info(": Completed Checking for I2C devices on port=%d.\n",
> + i2c_port);
> }
>
> /*
> @@ -522,7 +527,7 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
>
> if (0 == bus->i2c_rc) {
> if (i2c_scan)
> - cx231xx_do_i2c_scan(dev, &bus->i2c_client);
> + cx231xx_do_i2c_scan(dev, bus->nr);
> } else
> cx231xx_warn("%s: i2c bus %d register FAILED\n",
> dev->name, bus->nr);
> diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
> index aeb1bf4..5efc93e 100644
> --- a/drivers/media/usb/cx231xx/cx231xx.h
> +++ b/drivers/media/usb/cx231xx/cx231xx.h
> @@ -751,7 +751,7 @@ int cx231xx_set_analog_freq(struct cx231xx *dev, u32 freq);
> int cx231xx_reset_analog_tuner(struct cx231xx *dev);
>
> /* Provided by cx231xx-i2c.c */
> -void cx231xx_do_i2c_scan(struct cx231xx *dev, struct i2c_client *c);
> +void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port);
> int cx231xx_i2c_register(struct cx231xx_i2c *bus);
> int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
>
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 02/12] cx231xx: use own i2c_client for eeprom access
2014-09-25 5:07 ` [PATCH 02/12] cx231xx: use own i2c_client for eeprom access Matthias Schwarzott
@ 2014-09-25 14:58 ` Antti Palosaari
2014-09-26 4:30 ` Matthias Schwarzott
0 siblings, 1 reply; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 14:58 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
Reviewed-by: Antti Palosaari <crope@iki.fi>
Please add commit description (why and how).
Some notes for further development:
It sends single messages, so you could (or even should) use
i2c_master_send/i2c_master_recv (i2c_transfer is aimed for sending
multiple messages using REPEATED START condition).
I am not sure though if these eeprom chips uses REPEATED START condition
for reads (means it could be broken even now).
regards
Antti
On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/cx231xx-cards.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index 791f00c..092fb85 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -980,23 +980,20 @@ static void cx231xx_config_tuner(struct cx231xx *dev)
>
> }
>
> -static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len)
> +static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
> + u8 *eedata, int len)
> {
> int ret = 0;
> - u8 addr = 0xa0 >> 1;
> u8 start_offset = 0;
> int len_todo = len;
> u8 *eedata_cur = eedata;
> int i;
> - struct i2c_msg msg_write = { .addr = addr, .flags = 0,
> + struct i2c_msg msg_write = { .addr = client->addr, .flags = 0,
> .buf = &start_offset, .len = 1 };
> - struct i2c_msg msg_read = { .addr = addr, .flags = I2C_M_RD };
> -
> - /* mutex_lock(&dev->i2c_lock); */
> - cx231xx_enable_i2c_port_3(dev, false);
> + struct i2c_msg msg_read = { .addr = client->addr, .flags = I2C_M_RD };
>
> /* start reading at offset 0 */
> - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_write, 1);
> + ret = i2c_transfer(client->adapter, &msg_write, 1);
> if (ret < 0) {
> cx231xx_err("Can't read eeprom\n");
> return ret;
> @@ -1006,7 +1003,7 @@ static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len)
> msg_read.len = (len_todo > 64) ? 64 : len_todo;
> msg_read.buf = eedata_cur;
>
> - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_read, 1);
> + ret = i2c_transfer(client->adapter, &msg_read, 1);
> if (ret < 0) {
> cx231xx_err("Can't read eeprom\n");
> return ret;
> @@ -1062,9 +1059,14 @@ void cx231xx_card_setup(struct cx231xx *dev)
> {
> struct tveeprom tvee;
> static u8 eeprom[256];
> + struct i2c_client client;
> +
> + memset(&client, 0, sizeof(client));
> + client.adapter = &dev->i2c_bus[1].i2c_adap;
> + client.addr = 0xa0 >> 1;
>
> - read_eeprom(dev, eeprom, sizeof(eeprom));
> - tveeprom_hauppauge_analog(&dev->i2c_bus[1].i2c_client,
> + read_eeprom(dev, &client, eeprom, sizeof(eeprom));
> + tveeprom_hauppauge_analog(&client,
> &tvee, eeprom + 0xc0);
> break;
> }
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 03/12] cx231xx: delete i2c_client per bus
2014-09-25 5:07 ` [PATCH 03/12] cx231xx: delete i2c_client per bus Matthias Schwarzott
@ 2014-09-25 15:00 ` Antti Palosaari
0 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 15:00 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
Reviewed-by: Antti Palosaari <crope@iki.fi>
Good catch, certainly pointless to add "dummy" I2C client per adapter.
Just wastes memory.
Missing patch description.
regards
Antti
On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/cx231xx-i2c.c | 7 -------
> drivers/media/usb/cx231xx/cx231xx.h | 1 -
> 2 files changed, 8 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> index 67a1391..a30d400 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> @@ -455,10 +455,6 @@ static struct i2c_adapter cx231xx_adap_template = {
> .algo = &cx231xx_algo,
> };
>
> -static struct i2c_client cx231xx_client_template = {
> - .name = "cx231xx internal",
> -};
> -
> /* ----------------------------------------------------------- */
>
> /*
> @@ -514,7 +510,6 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
> BUG_ON(!dev->cx231xx_send_usb_command);
>
> bus->i2c_adap = cx231xx_adap_template;
> - bus->i2c_client = cx231xx_client_template;
> bus->i2c_adap.dev.parent = &dev->udev->dev;
>
> strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name));
> @@ -523,8 +518,6 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
> i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
> i2c_add_adapter(&bus->i2c_adap);
>
> - bus->i2c_client.adapter = &bus->i2c_adap;
> -
> if (0 == bus->i2c_rc) {
> if (i2c_scan)
> cx231xx_do_i2c_scan(dev, bus->nr);
> diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
> index 5efc93e..c92382f 100644
> --- a/drivers/media/usb/cx231xx/cx231xx.h
> +++ b/drivers/media/usb/cx231xx/cx231xx.h
> @@ -472,7 +472,6 @@ struct cx231xx_i2c {
>
> /* i2c i/o */
> struct i2c_adapter i2c_adap;
> - struct i2c_client i2c_client;
> u32 i2c_rc;
>
> /* different settings for each bus */
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 04/12] cx231xx: give each master i2c bus a seperate name
2014-09-25 5:07 ` [PATCH 04/12] cx231xx: give each master i2c bus a seperate name Matthias Schwarzott
@ 2014-09-25 15:04 ` Antti Palosaari
2014-09-26 4:34 ` Matthias Schwarzott
0 siblings, 1 reply; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 15:04 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
So this patch adds bus number to adapter name as postfix?
"cx231xx" => "cx231xx-1"
I have no clear opinion for that. I think name should be given when
adapter is crated, not afterwards.
regards
Antti
On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/cx231xx-i2c.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> index a30d400..178fa48 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> @@ -506,6 +506,7 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
> int cx231xx_i2c_register(struct cx231xx_i2c *bus)
> {
> struct cx231xx *dev = bus->dev;
> + char bus_name[3];
>
> BUG_ON(!dev->cx231xx_send_usb_command);
>
> @@ -513,6 +514,10 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
> bus->i2c_adap.dev.parent = &dev->udev->dev;
>
> strlcpy(bus->i2c_adap.name, bus->dev->name, sizeof(bus->i2c_adap.name));
> + bus_name[0] = '-';
> + bus_name[1] = '0' + bus->nr;
> + bus_name[2] = '\0';
> + strlcat(bus->i2c_adap.name, bus_name, sizeof(bus->i2c_adap.name));
>
> bus->i2c_adap.algo_data = bus;
> i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 05/12] cx231xx: Use symbolic constants for i2c ports
2014-09-25 5:07 ` [PATCH 05/12] cx231xx: Use symbolic constants for i2c ports Matthias Schwarzott
@ 2014-09-25 15:06 ` Antti Palosaari
0 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 15:06 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
Reviewed-by: Antti Palosaari <crope@iki.fi>
regards
Antti
On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
> use already existing I2C_0 ... I2C_3
>
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/cx231xx-cards.c | 62 +++++++++++++++----------------
> drivers/media/usb/cx231xx/cx231xx.h | 8 ++--
> 2 files changed, 35 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index 092fb85..2f027c7 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -104,8 +104,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x02,
> .norm = V4L2_STD_PAL,
> @@ -144,8 +144,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x32,
> .norm = V4L2_STD_NTSC,
> @@ -184,8 +184,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x1c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x02,
> .norm = V4L2_STD_PAL,
> @@ -225,8 +225,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x1c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x02,
> .norm = V4L2_STD_PAL,
> @@ -297,8 +297,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x02,
> .norm = V4L2_STD_PAL,
> @@ -325,8 +325,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x32,
> .norm = V4L2_STD_NTSC,
> @@ -353,8 +353,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x0e,
> .norm = V4L2_STD_NTSC,
> @@ -418,9 +418,9 @@ struct cx231xx_board cx231xx_boards[] = {
> .tuner_scl_gpio = -1,
> .tuner_sda_gpio = -1,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 2,
> - .demod_i2c_master = 1,
> - .ir_i2c_master = 2,
> + .tuner_i2c_master = I2C_2,
> + .demod_i2c_master = I2C_1,
> + .ir_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x10,
> .norm = V4L2_STD_PAL_M,
> @@ -456,9 +456,9 @@ struct cx231xx_board cx231xx_boards[] = {
> .tuner_scl_gpio = -1,
> .tuner_sda_gpio = -1,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 2,
> - .demod_i2c_master = 1,
> - .ir_i2c_master = 2,
> + .tuner_i2c_master = I2C_2,
> + .demod_i2c_master = I2C_1,
> + .ir_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x10,
> .norm = V4L2_STD_NTSC_M,
> @@ -494,9 +494,9 @@ struct cx231xx_board cx231xx_boards[] = {
> .tuner_scl_gpio = -1,
> .tuner_sda_gpio = -1,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 2,
> - .demod_i2c_master = 1,
> - .ir_i2c_master = 2,
> + .tuner_i2c_master = I2C_2,
> + .demod_i2c_master = I2C_1,
> + .ir_i2c_master = I2C_2,
> .rc_map_name = RC_MAP_PIXELVIEW_002T,
> .has_dvb = 1,
> .demod_addr = 0x10,
> @@ -587,7 +587,7 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> + .tuner_i2c_master = I2C_1,
> .norm = V4L2_STD_PAL,
>
> .input = {{
> @@ -622,7 +622,7 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> + .tuner_i2c_master = I2C_1,
> .norm = V4L2_STD_NTSC,
>
> .input = {{
> @@ -718,8 +718,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x0e,
> .norm = V4L2_STD_PAL,
> @@ -757,8 +757,8 @@ struct cx231xx_board cx231xx_boards[] = {
> .ctl_pin_status_mask = 0xFFFFFFC4,
> .agc_analog_digital_select_gpio = 0x0c,
> .gpio_pin_status_mask = 0x4001000,
> - .tuner_i2c_master = 1,
> - .demod_i2c_master = 2,
> + .tuner_i2c_master = I2C_1,
> + .demod_i2c_master = I2C_2,
> .has_dvb = 1,
> .demod_addr = 0x0e,
> .norm = V4L2_STD_PAL,
> @@ -1033,7 +1033,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
> /* request some modules */
> if (dev->board.decoder == CX231XX_AVDECODER) {
> dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
> - &dev->i2c_bus[0].i2c_adap,
> + &dev->i2c_bus[I2C_0].i2c_adap,
> "cx25840", 0x88 >> 1, NULL);
> if (dev->sd_cx25840 == NULL)
> cx231xx_info("cx25840 subdev registration failure\n");
> @@ -1062,7 +1062,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
> struct i2c_client client;
>
> memset(&client, 0, sizeof(client));
> - client.adapter = &dev->i2c_bus[1].i2c_adap;
> + client.adapter = &dev->i2c_bus[I2C_1].i2c_adap;
> client.addr = 0xa0 >> 1;
>
> read_eeprom(dev, &client, eeprom, sizeof(eeprom));
> diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
> index c92382f..3ab107a 100644
> --- a/drivers/media/usb/cx231xx/cx231xx.h
> +++ b/drivers/media/usb/cx231xx/cx231xx.h
> @@ -322,10 +322,10 @@ enum cx231xx_decoder {
> };
>
> enum CX231XX_I2C_MASTER_PORT {
> - I2C_0 = 0,
> - I2C_1 = 1,
> - I2C_2 = 2,
> - I2C_3 = 3
> + I2C_0 = 0, /* master 0 - internal connection */
> + I2C_1 = 1, /* master 1 - I2C_DEMOD_EN = 0 */
> + I2C_2 = 2, /* master 2 */
> + I2C_3 = 3 /* master 1 - I2C_DEMOD_EN = 1 */
> };
>
> struct cx231xx_board {
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 06/12] cx231xx: add wrapper to get the i2c_adapter pointer
2014-09-25 5:07 ` [PATCH 06/12] cx231xx: add wrapper to get the i2c_adapter pointer Matthias Schwarzott
@ 2014-09-25 15:13 ` Antti Palosaari
0 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 15:13 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
I have to say I don't see very necessary to define function which
returns given adapter by adapter number.
*adapter = cx231xx_get_i2c_adap(I2C_1);
vs.
*adapter = dev->i2c_bus[I2C_1].i2c_adap;
not big difference. Anyhow, I didn't saw any bugs.
regards
Antti
On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
> Already map unused I2C_3 to adapter number 1 to prepare for switching.
>
> Add local variables for i2c_adapters in dvb_init to get line lengths
> shorter.
>
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/cx231xx-cards.c | 8 +++---
> drivers/media/usb/cx231xx/cx231xx-dvb.c | 42 +++++++++++++++++--------------
> drivers/media/usb/cx231xx/cx231xx-i2c.c | 19 +++++++++++++-
> drivers/media/usb/cx231xx/cx231xx-input.c | 3 ++-
> drivers/media/usb/cx231xx/cx231xx.h | 1 +
> 5 files changed, 49 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index 2f027c7..330fe39 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -1033,7 +1033,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
> /* request some modules */
> if (dev->board.decoder == CX231XX_AVDECODER) {
> dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
> - &dev->i2c_bus[I2C_0].i2c_adap,
> + cx231xx_get_i2c_adap(dev, I2C_0),
> "cx25840", 0x88 >> 1, NULL);
> if (dev->sd_cx25840 == NULL)
> cx231xx_info("cx25840 subdev registration failure\n");
> @@ -1043,8 +1043,10 @@ void cx231xx_card_setup(struct cx231xx *dev)
>
> /* Initialize the tuner */
> if (dev->board.tuner_type != TUNER_ABSENT) {
> + struct tuner_i2c = cx231xx_get_i2c_adap(dev,
> + dev->board.tuner_i2c_master);
> dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev,
> - &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + tuner_i2c,
> "tuner",
> dev->tuner_addr, NULL);
> if (dev->sd_tuner == NULL)
> @@ -1062,7 +1064,7 @@ void cx231xx_card_setup(struct cx231xx *dev)
> struct i2c_client client;
>
> memset(&client, 0, sizeof(client));
> - client.adapter = &dev->i2c_bus[I2C_1].i2c_adap;
> + client.adapter = cx231xx_get_i2c_adap(dev, I2C_1);
> client.addr = 0xa0 >> 1;
>
> read_eeprom(dev, &client, eeprom, sizeof(eeprom));
> diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> index 6c7b5e2..869c433 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> @@ -378,7 +378,7 @@ static int attach_xc5000(u8 addr, struct cx231xx *dev)
> struct xc5000_config cfg;
>
> memset(&cfg, 0, sizeof(cfg));
> - cfg.i2c_adap = &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap;
> + cfg.i2c_adap = cx231xx_get_i2c_adap(dev, dev->board.tuner_i2c_master);
> cfg.i2c_addr = addr;
>
> if (!dev->dvb->frontend) {
> @@ -583,6 +583,8 @@ static int dvb_init(struct cx231xx *dev)
> {
> int result = 0;
> struct cx231xx_dvb *dvb;
> + struct i2c_adapter *tuner_i2c;
> + struct i2c_adapter *demod_i2c;
>
> if (!dev->board.has_dvb) {
> /* This device does not support the extension */
> @@ -599,6 +601,8 @@ static int dvb_init(struct cx231xx *dev)
> dev->cx231xx_set_analog_freq = cx231xx_set_analog_freq;
> dev->cx231xx_reset_analog_tuner = cx231xx_reset_analog_tuner;
>
> + tuner_i2c = cx231xx_get_i2c_adap(dev, dev->board.tuner_i2c_master);
> + demod_i2c = cx231xx_get_i2c_adap(dev, dev->board.demod_i2c_master);
> mutex_lock(&dev->lock);
> cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE);
> cx231xx_demod_reset(dev);
> @@ -609,7 +613,7 @@ static int dvb_init(struct cx231xx *dev)
>
> dev->dvb->frontend = dvb_attach(s5h1432_attach,
> &dvico_s5h1432_config,
> - &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
> + demod_i2c);
>
> if (dev->dvb->frontend == NULL) {
> printk(DRIVER_NAME
> @@ -622,7 +626,7 @@ static int dvb_init(struct cx231xx *dev)
> dvb->frontend->callback = cx231xx_tuner_callback;
>
> if (!dvb_attach(xc5000_attach, dev->dvb->frontend,
> - &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + tuner_i2c,
> &cnxt_rde250_tunerconfig)) {
> result = -EINVAL;
> goto out_free;
> @@ -634,7 +638,7 @@ static int dvb_init(struct cx231xx *dev)
>
> dev->dvb->frontend = dvb_attach(s5h1411_attach,
> &xc5000_s5h1411_config,
> - &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
> + demod_i2c);
>
> if (dev->dvb->frontend == NULL) {
> printk(DRIVER_NAME
> @@ -647,7 +651,7 @@ static int dvb_init(struct cx231xx *dev)
> dvb->frontend->callback = cx231xx_tuner_callback;
>
> if (!dvb_attach(xc5000_attach, dev->dvb->frontend,
> - &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + tuner_i2c,
> &cnxt_rdu250_tunerconfig)) {
> result = -EINVAL;
> goto out_free;
> @@ -657,7 +661,7 @@ static int dvb_init(struct cx231xx *dev)
>
> dev->dvb->frontend = dvb_attach(s5h1432_attach,
> &dvico_s5h1432_config,
> - &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
> + demod_i2c);
>
> if (dev->dvb->frontend == NULL) {
> printk(DRIVER_NAME
> @@ -670,7 +674,7 @@ static int dvb_init(struct cx231xx *dev)
> dvb->frontend->callback = cx231xx_tuner_callback;
>
> if (!dvb_attach(tda18271_attach, dev->dvb->frontend,
> - 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + 0x60, tuner_i2c,
> &cnxt_rde253s_tunerconfig)) {
> result = -EINVAL;
> goto out_free;
> @@ -681,7 +685,7 @@ static int dvb_init(struct cx231xx *dev)
>
> dev->dvb->frontend = dvb_attach(s5h1411_attach,
> &tda18271_s5h1411_config,
> - &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
> + demod_i2c);
>
> if (dev->dvb->frontend == NULL) {
> printk(DRIVER_NAME
> @@ -694,7 +698,7 @@ static int dvb_init(struct cx231xx *dev)
> dvb->frontend->callback = cx231xx_tuner_callback;
>
> if (!dvb_attach(tda18271_attach, dev->dvb->frontend,
> - 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + 0x60, tuner_i2c,
> &cnxt_rde253s_tunerconfig)) {
> result = -EINVAL;
> goto out_free;
> @@ -703,11 +707,11 @@ static int dvb_init(struct cx231xx *dev)
> case CX231XX_BOARD_HAUPPAUGE_EXETER:
>
> printk(KERN_INFO "%s: looking for tuner / demod on i2c bus: %d\n",
> - __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap));
> + __func__, i2c_adapter_id(tuner_i2c));
>
> dev->dvb->frontend = dvb_attach(lgdt3305_attach,
> &hcw_lgdt3305_config,
> - &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap);
> + tuner_i2c);
>
> if (dev->dvb->frontend == NULL) {
> printk(DRIVER_NAME
> @@ -720,7 +724,7 @@ static int dvb_init(struct cx231xx *dev)
> dvb->frontend->callback = cx231xx_tuner_callback;
>
> dvb_attach(tda18271_attach, dev->dvb->frontend,
> - 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + 0x60, tuner_i2c,
> &hcw_tda18271_config);
> break;
>
> @@ -728,7 +732,7 @@ static int dvb_init(struct cx231xx *dev)
>
> dev->dvb->frontend = dvb_attach(si2165_attach,
> &hauppauge_930C_HD_1113xx_si2165_config,
> - &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap
> + tuner_i2c
> );
>
> if (dev->dvb->frontend == NULL) {
> @@ -745,7 +749,7 @@ static int dvb_init(struct cx231xx *dev)
>
> dvb_attach(tda18271_attach, dev->dvb->frontend,
> 0x60,
> - &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + tuner_i2c,
> &hcw_tda18271_config);
>
> dev->cx231xx_reset_analog_tuner = NULL;
> @@ -761,7 +765,7 @@ static int dvb_init(struct cx231xx *dev)
>
> dev->dvb->frontend = dvb_attach(si2165_attach,
> &pctv_quatro_stick_1114xx_si2165_config,
> - &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap
> + tuner_i2c
> );
>
> if (dev->dvb->frontend == NULL) {
> @@ -786,7 +790,7 @@ static int dvb_init(struct cx231xx *dev)
> request_module("si2157");
>
> client = i2c_new_device(
> - &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + tuner_i2c,
> &info);
> if (client == NULL || client->dev.driver == NULL) {
> dvb_frontend_detach(dev->dvb->frontend);
> @@ -811,11 +815,11 @@ static int dvb_init(struct cx231xx *dev)
> case CX231XX_BOARD_KWORLD_UB430_USB_HYBRID:
>
> printk(KERN_INFO "%s: looking for demod on i2c bus: %d\n",
> - __func__, i2c_adapter_id(&dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap));
> + __func__, i2c_adapter_id(tuner_i2c));
>
> dev->dvb->frontend = dvb_attach(mb86a20s_attach,
> &pv_mb86a20s_config,
> - &dev->i2c_bus[dev->board.demod_i2c_master].i2c_adap);
> + demod_i2c);
>
> if (dev->dvb->frontend == NULL) {
> printk(DRIVER_NAME
> @@ -828,7 +832,7 @@ static int dvb_init(struct cx231xx *dev)
> dvb->frontend->callback = cx231xx_tuner_callback;
>
> dvb_attach(tda18271_attach, dev->dvb->frontend,
> - 0x60, &dev->i2c_bus[dev->board.tuner_i2c_master].i2c_adap,
> + 0x60, tuner_i2c,
> &pv_tda18271_config);
> break;
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> index 178fa48..86f90c0 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> @@ -483,7 +483,7 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
> struct i2c_client client;
>
> memset(&client, 0, sizeof(client));
> - client.adapter = &dev->i2c_bus[i2c_port].i2c_adap;
> + client.adapter = cx231xx_get_i2c_adap(dev, i2c_port);
>
> cx231xx_info(": Checking for I2C devices on port=%d ..\n", i2c_port);
> for (i = 0; i < 128; i++) {
> @@ -542,3 +542,20 @@ int cx231xx_i2c_unregister(struct cx231xx_i2c *bus)
> i2c_del_adapter(&bus->i2c_adap);
> return 0;
> }
> +
> +struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port)
> +{
> + switch (i2c_port) {
> + case I2C_0:
> + return &dev->i2c_bus[0].i2c_adap;
> + case I2C_1:
> + return &dev->i2c_bus[1].i2c_adap;
> + case I2C_2:
> + return &dev->i2c_bus[2].i2c_adap;
> + case I2C_3:
> + return &dev->i2c_bus[1].i2c_adap;
> + default:
> + return NULL;
> + }
> +}
> +EXPORT_SYMBOL_GPL(cx231xx_get_i2c_adap);
> diff --git a/drivers/media/usb/cx231xx/cx231xx-input.c b/drivers/media/usb/cx231xx/cx231xx-input.c
> index 05f0434..5ae2ce3 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-input.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-input.c
> @@ -100,7 +100,8 @@ int cx231xx_ir_init(struct cx231xx *dev)
> ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master;
> dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n",
> ir_i2c_bus, info.addr);
> - dev->ir_i2c_client = i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info);
> + dev->ir_i2c_client = i2c_new_device(
> + cx231xx_get_i2c_adap(dev, ir_i2c_bus), &info);
>
> return 0;
> }
> diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
> index 3ab107a..2118d00 100644
> --- a/drivers/media/usb/cx231xx/cx231xx.h
> +++ b/drivers/media/usb/cx231xx/cx231xx.h
> @@ -753,6 +753,7 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev);
> void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port);
> int cx231xx_i2c_register(struct cx231xx_i2c *bus);
> int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
> +struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port);
>
> /* Internal block control functions */
> int cx231xx_read_i2c_master(struct cx231xx *dev, u8 dev_addr, u16 saddr,
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 10/12] cx231xx: register i2c mux adapters for master1 and use as I2C_1 and I2C_3
2014-09-25 5:08 ` [PATCH 10/12] cx231xx: register i2c mux adapters for master1 and use as I2C_1 and I2C_3 Matthias Schwarzott
@ 2014-09-25 15:25 ` Antti Palosaari
0 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 15:25 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
Reviewed-by: Antti Palosaari <crope@iki.fi>
I2C adapter naming is the thing here I ask you consider. After that
patch, you have 2 muxed I2C segments named I2C_1 and I2C_3. Real adapter
having these muxed adapter is I2C_1. So you reuse I2C_1 for muxed
adapter, which is possible as you don't need real adapter anywhere. I
would still like to see:
I2C_1 (real adapter, mux parent)
I2C_1_MUX_0 (I2C adapter1, mux segment 0)
I2C_1_MUX_1 (I2C adapter1, mux segment 1)
regards
Antti
On 09/25/2014 08:08 AM, Matthias Schwarzott wrote:
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/Kconfig | 1 +
> drivers/media/usb/cx231xx/cx231xx-core.c | 5 ++++
> drivers/media/usb/cx231xx/cx231xx-i2c.c | 45 ++++++++++++++++++++++++++++++--
> drivers/media/usb/cx231xx/cx231xx.h | 4 +++
> 4 files changed, 53 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/Kconfig b/drivers/media/usb/cx231xx/Kconfig
> index 569aa29..173c0e2 100644
> --- a/drivers/media/usb/cx231xx/Kconfig
> +++ b/drivers/media/usb/cx231xx/Kconfig
> @@ -7,6 +7,7 @@ config VIDEO_CX231XX
> select VIDEOBUF_VMALLOC
> select VIDEO_CX25840
> select VIDEO_CX2341X
> + select I2C_MUX
>
> ---help---
> This is a video4linux driver for Conexant 231xx USB based TV cards.
> diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
> index 180103e..c8a6d20 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-core.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-core.c
> @@ -1300,6 +1300,9 @@ int cx231xx_dev_init(struct cx231xx *dev)
> cx231xx_i2c_register(&dev->i2c_bus[1]);
> cx231xx_i2c_register(&dev->i2c_bus[2]);
>
> + cx231xx_i2c_mux_register(dev, 0);
> + cx231xx_i2c_mux_register(dev, 1);
> +
> /* init hardware */
> /* Note : with out calling set power mode function,
> afe can not be set up correctly */
> @@ -1414,6 +1417,8 @@ EXPORT_SYMBOL_GPL(cx231xx_dev_init);
> void cx231xx_dev_uninit(struct cx231xx *dev)
> {
> /* Un Initialize I2C bus */
> + cx231xx_i2c_mux_unregister(dev, 1);
> + cx231xx_i2c_mux_unregister(dev, 0);
> cx231xx_i2c_unregister(&dev->i2c_bus[2]);
> cx231xx_i2c_unregister(&dev->i2c_bus[1]);
> cx231xx_i2c_unregister(&dev->i2c_bus[0]);
> diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> index a8c0f90..848aec2 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> @@ -24,6 +24,7 @@
> #include <linux/kernel.h>
> #include <linux/usb.h>
> #include <linux/i2c.h>
> +#include <linux/i2c-mux.h>
> #include <media/v4l2-common.h>
> #include <media/tuner.h>
>
> @@ -552,17 +553,57 @@ int cx231xx_i2c_unregister(struct cx231xx_i2c *bus)
> return 0;
> }
>
> +/*
> + * cx231xx_i2c_mux_select()
> + * switch i2c master number 1 between port1 and port3
> + */
> +static int cx231xx_i2c_mux_select(struct i2c_adapter *adap,
> + void *mux_priv, u32 chan_id)
> +{
> + struct cx231xx *dev = mux_priv;
> +
> + return cx231xx_enable_i2c_port_3(dev, chan_id);
> +}
> +
> +int cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no)
> +{
> + struct i2c_adapter *i2c_parent = &dev->i2c_bus[1].i2c_adap;
> + /* what is the correct mux_dev? */
> + struct device *mux_dev = &dev->udev->dev;
> +
> + dev->i2c_mux_adap[mux_no] = i2c_add_mux_adapter(i2c_parent,
> + mux_dev,
> + dev /* mux_priv */,
> + 0,
> + mux_no /* chan_id */,
> + 0 /* class */,
> + &cx231xx_i2c_mux_select,
> + NULL);
> +
> + if (!dev->i2c_mux_adap[mux_no])
> + cx231xx_warn("%s: i2c mux %d register FAILED\n",
> + dev->name, mux_no);
> +
> + return 0;
> +}
> +
> +void cx231xx_i2c_mux_unregister(struct cx231xx *dev, int mux_no)
> +{
> + i2c_del_mux_adapter(dev->i2c_mux_adap[mux_no]);
> + dev->i2c_mux_adap[mux_no] = NULL;
> +}
> +
> struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port)
> {
> switch (i2c_port) {
> case I2C_0:
> return &dev->i2c_bus[0].i2c_adap;
> case I2C_1:
> - return &dev->i2c_bus[1].i2c_adap;
> + return dev->i2c_mux_adap[0];
> case I2C_2:
> return &dev->i2c_bus[2].i2c_adap;
> case I2C_3:
> - return &dev->i2c_bus[1].i2c_adap;
> + return dev->i2c_mux_adap[1];
> default:
> return NULL;
> }
> diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
> index cefeb30..9234cd7 100644
> --- a/drivers/media/usb/cx231xx/cx231xx.h
> +++ b/drivers/media/usb/cx231xx/cx231xx.h
> @@ -627,6 +627,8 @@ struct cx231xx {
>
> /* I2C adapters: Master 1 & 2 (External) & Master 3 (Internal only) */
> struct cx231xx_i2c i2c_bus[3];
> + struct i2c_adapter *i2c_mux_adap[2];
> +
> unsigned int xc_fw_load_done:1;
> unsigned int port_3_switch_enabled:1;
> /* locks */
> @@ -754,6 +756,8 @@ int cx231xx_reset_analog_tuner(struct cx231xx *dev);
> void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port);
> int cx231xx_i2c_register(struct cx231xx_i2c *bus);
> int cx231xx_i2c_unregister(struct cx231xx_i2c *bus);
> +int cx231xx_i2c_mux_register(struct cx231xx *dev, int mux_no);
> +void cx231xx_i2c_mux_unregister(struct cx231xx *dev, int mux_no);
> struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port);
>
> /* Internal block control functions */
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 11/12] cx231xx: drop unconditional port3 switching
2014-09-25 5:08 ` [PATCH 11/12] cx231xx: drop unconditional port3 switching Matthias Schwarzott
@ 2014-09-25 15:26 ` Antti Palosaari
0 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 15:26 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
Reviewed-by: Antti Palosaari <crope@iki.fi>
Antti
On 09/25/2014 08:08 AM, Matthias Schwarzott wrote:
> All switching should be done by i2c mux adapters.
> Drop explicit dont_use_port_3 flag.
> Drop info message about switch.
>
> Only the removed code in start_streaming is questionable:
> It did switch the port_3 flag without accessing i2c in between.
>
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/cx231xx-avcore.c | 17 -----------------
> drivers/media/usb/cx231xx/cx231xx-cards.c | 8 --------
> drivers/media/usb/cx231xx/cx231xx-core.c | 4 +---
> drivers/media/usb/cx231xx/cx231xx-dvb.c | 4 ----
> drivers/media/usb/cx231xx/cx231xx.h | 1 -
> 5 files changed, 1 insertion(+), 33 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-avcore.c b/drivers/media/usb/cx231xx/cx231xx-avcore.c
> index d31ea57..138ee5e 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-avcore.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-avcore.c
> @@ -1270,8 +1270,6 @@ int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3)
> int status = 0;
> bool current_is_port_3;
>
> - if (dev->board.dont_use_port_3)
> - is_port_3 = false;
> status = cx231xx_read_ctrl_reg(dev, VRT_GET_REGISTER,
> PWR_CTL_EN, value, 4);
> if (status < 0)
> @@ -1288,9 +1286,6 @@ int cx231xx_enable_i2c_port_3(struct cx231xx *dev, bool is_port_3)
> else
> value[0] &= ~I2C_DEMOD_EN;
>
> - 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);
>
> @@ -2320,9 +2315,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode)
> }
>
> if (dev->board.tuner_type != TUNER_ABSENT) {
> - /* Enable tuner */
> - cx231xx_enable_i2c_port_3(dev, true);
> -
> /* reset the Tuner */
> if (dev->board.tuner_gpio)
> cx231xx_gpio_set(dev, dev->board.tuner_gpio);
> @@ -2387,15 +2379,6 @@ int cx231xx_set_power_mode(struct cx231xx *dev, enum AV_MODE mode)
> }
>
> if (dev->board.tuner_type != TUNER_ABSENT) {
> - /*
> - * Enable tuner
> - * Hauppauge Exeter seems to need to do something different!
> - */
> - 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 */
> if (dev->board.tuner_gpio)
> cx231xx_gpio_set(dev, dev->board.tuner_gpio);
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index a6fdb6f..0a0a4e9 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -262,7 +262,6 @@ struct cx231xx_board cx231xx_boards[] = {
> .norm = V4L2_STD_PAL,
> .no_alt_vanc = 1,
> .external_av = 1,
> - .dont_use_port_3 = 1,
> /* Actually, it has a 417, but it isn't working correctly.
> * So set to 0 for now until someone can manage to get this
> * to work reliably. */
> @@ -390,7 +389,6 @@ struct cx231xx_board cx231xx_boards[] = {
> .norm = V4L2_STD_NTSC,
> .no_alt_vanc = 1,
> .external_av = 1,
> - .dont_use_port_3 = 1,
> .input = {{
> .type = CX231XX_VMUX_COMPOSITE1,
> .vmux = CX231XX_VIN_2_1,
> @@ -532,7 +530,6 @@ struct cx231xx_board cx231xx_boards[] = {
> .norm = V4L2_STD_NTSC,
> .no_alt_vanc = 1,
> .external_av = 1,
> - .dont_use_port_3 = 1,
>
> .input = {{
> .type = CX231XX_VMUX_COMPOSITE1,
> @@ -656,7 +653,6 @@ struct cx231xx_board cx231xx_boards[] = {
> .norm = V4L2_STD_NTSC,
> .no_alt_vanc = 1,
> .external_av = 1,
> - .dont_use_port_3 = 1,
> .input = {{
> .type = CX231XX_VMUX_COMPOSITE1,
> .vmux = CX231XX_VIN_2_1,
> @@ -683,7 +679,6 @@ struct cx231xx_board cx231xx_boards[] = {
> .norm = V4L2_STD_NTSC,
> .no_alt_vanc = 1,
> .external_av = 1,
> - .dont_use_port_3 = 1,
> /*.has_417 = 1, */
> /* This board is believed to have a hardware encoding chip
> * supporting mpeg1/2/4, but as the 417 is apparently not
> @@ -1012,9 +1007,6 @@ static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
> len_todo -= msg_read.len;
> }
>
> - cx231xx_enable_i2c_port_3(dev, true);
> - /* mutex_unlock(&dev->i2c_lock); */
> -
> for (i = 0; i + 15 < len; i += 16)
> cx231xx_info("i2c eeprom %02x: %*ph\n", i, 16, &eedata[i]);
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
> index c8a6d20..c49022f 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-core.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-core.c
> @@ -1407,9 +1407,7 @@ int cx231xx_dev_init(struct cx231xx *dev)
> if (dev->board.has_dvb)
> cx231xx_set_alt_setting(dev, INDEX_TS1, 0);
>
> - /* set the I2C master port to 3 on channel 1 */
> - errCode = cx231xx_enable_i2c_port_3(dev, true);
> -
> + errCode = 0;
> return errCode;
> }
> EXPORT_SYMBOL_GPL(cx231xx_dev_init);
> diff --git a/drivers/media/usb/cx231xx/cx231xx-dvb.c b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> index 869c433..2ea6946 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-dvb.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-dvb.c
> @@ -266,11 +266,7 @@ static int start_streaming(struct cx231xx_dvb *dvb)
>
> if (dev->USE_ISO) {
> cx231xx_info("DVB transfer mode is ISO.\n");
> - mutex_lock(&dev->i2c_lock);
> - cx231xx_enable_i2c_port_3(dev, false);
> cx231xx_set_alt_setting(dev, INDEX_TS1, 4);
> - cx231xx_enable_i2c_port_3(dev, true);
> - mutex_unlock(&dev->i2c_lock);
> rc = cx231xx_set_mode(dev, CX231XX_DIGITAL_MODE);
> if (rc < 0)
> return rc;
> diff --git a/drivers/media/usb/cx231xx/cx231xx.h b/drivers/media/usb/cx231xx/cx231xx.h
> index 9234cd7..b8daff6 100644
> --- a/drivers/media/usb/cx231xx/cx231xx.h
> +++ b/drivers/media/usb/cx231xx/cx231xx.h
> @@ -367,7 +367,6 @@ struct cx231xx_board {
> unsigned int valid:1;
> unsigned int no_alt_vanc:1;
> unsigned int external_av:1;
> - unsigned int dont_use_port_3:1;
>
> unsigned char xclk, i2c_speed;
>
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 12/12] cx231xx: scan all four existing i2c busses instead of the 3 masters
2014-09-25 5:08 ` [PATCH 12/12] cx231xx: scan all four existing i2c busses instead of the 3 masters Matthias Schwarzott
@ 2014-09-25 15:30 ` Antti Palosaari
0 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-25 15:30 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
Reviewed-by: Antti Palosaari <crope@iki.fi>
Here is example naming those muxed adapters differently (as I mentioned
earlier patch), would make clear people who reads that code which
adapters are real and which are muxed. Now you do i2c scan for adapter
0, 1, 2, 3, without knowing 1 and 3 are actually mux segments on
physical adapter 1.
regards
Antti
On 09/25/2014 08:08 AM, Matthias Schwarzott wrote:
> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
> ---
> drivers/media/usb/cx231xx/cx231xx-core.c | 6 ++++++
> drivers/media/usb/cx231xx/cx231xx-i2c.c | 8 ++++----
> 2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c
> index c49022f..f6b6d26 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-core.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-core.c
> @@ -1303,6 +1303,12 @@ int cx231xx_dev_init(struct cx231xx *dev)
> cx231xx_i2c_mux_register(dev, 0);
> cx231xx_i2c_mux_register(dev, 1);
>
> + /* scan the real bus segments */
> + cx231xx_do_i2c_scan(dev, I2C_0);
> + cx231xx_do_i2c_scan(dev, I2C_1);
> + cx231xx_do_i2c_scan(dev, I2C_2);
> + cx231xx_do_i2c_scan(dev, I2C_3);
> +
> /* init hardware */
> /* Note : with out calling set power mode function,
> afe can not be set up correctly */
> diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> index 848aec2..13c476c 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
> @@ -492,6 +492,9 @@ void cx231xx_do_i2c_scan(struct cx231xx *dev, int i2c_port)
> int i, rc;
> struct i2c_client client;
>
> + if (!i2c_scan)
> + return;
> +
> memset(&client, 0, sizeof(client));
> client.adapter = cx231xx_get_i2c_adap(dev, i2c_port);
>
> @@ -533,10 +536,7 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus)
> i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
> i2c_add_adapter(&bus->i2c_adap);
>
> - if (0 == bus->i2c_rc) {
> - if (i2c_scan)
> - cx231xx_do_i2c_scan(dev, bus->nr);
> - } else
> + if (0 != bus->i2c_rc)
> cx231xx_warn("%s: i2c bus %d register FAILED\n",
> dev->name, bus->nr);
>
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 02/12] cx231xx: use own i2c_client for eeprom access
2014-09-25 14:58 ` Antti Palosaari
@ 2014-09-26 4:30 ` Matthias Schwarzott
2014-09-26 12:31 ` Antti Palosaari
0 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-26 4:30 UTC (permalink / raw)
To: Antti Palosaari, linux-media, mchehab
Hi Antti,
I think that i2c_transfer sens no repeated start when sending only one
message per call.
At least the received eeprom content looks correct.
Regards
Matthias
On 25.09.2014 16:58, Antti Palosaari wrote:
> Reviewed-by: Antti Palosaari <crope@iki.fi>
>
> Please add commit description (why and how).
>
> Some notes for further development:
> It sends single messages, so you could (or even should) use
> i2c_master_send/i2c_master_recv (i2c_transfer is aimed for sending
> multiple messages using REPEATED START condition).
>
> I am not sure though if these eeprom chips uses REPEATED START condition
> for reads (means it could be broken even now).
>
> regards
> Antti
>
> On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
>> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
>> ---
>> drivers/media/usb/cx231xx/cx231xx-cards.c | 24 +++++++++++++-----------
>> 1 file changed, 13 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c
>> b/drivers/media/usb/cx231xx/cx231xx-cards.c
>> index 791f00c..092fb85 100644
>> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
>> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
>> @@ -980,23 +980,20 @@ static void cx231xx_config_tuner(struct cx231xx
>> *dev)
>>
>> }
>>
>> -static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len)
>> +static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
>> + u8 *eedata, int len)
>> {
>> int ret = 0;
>> - u8 addr = 0xa0 >> 1;
>> u8 start_offset = 0;
>> int len_todo = len;
>> u8 *eedata_cur = eedata;
>> int i;
>> - struct i2c_msg msg_write = { .addr = addr, .flags = 0,
>> + struct i2c_msg msg_write = { .addr = client->addr, .flags = 0,
>> .buf = &start_offset, .len = 1 };
>> - struct i2c_msg msg_read = { .addr = addr, .flags = I2C_M_RD };
>> -
>> - /* mutex_lock(&dev->i2c_lock); */
>> - cx231xx_enable_i2c_port_3(dev, false);
>> + struct i2c_msg msg_read = { .addr = client->addr, .flags =
>> I2C_M_RD };
>>
>> /* start reading at offset 0 */
>> - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_write, 1);
>> + ret = i2c_transfer(client->adapter, &msg_write, 1);
>> if (ret < 0) {
>> cx231xx_err("Can't read eeprom\n");
>> return ret;
>> @@ -1006,7 +1003,7 @@ static int read_eeprom(struct cx231xx *dev, u8
>> *eedata, int len)
>> msg_read.len = (len_todo > 64) ? 64 : len_todo;
>> msg_read.buf = eedata_cur;
>>
>> - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_read, 1);
>> + ret = i2c_transfer(client->adapter, &msg_read, 1);
>> if (ret < 0) {
>> cx231xx_err("Can't read eeprom\n");
>> return ret;
>> @@ -1062,9 +1059,14 @@ void cx231xx_card_setup(struct cx231xx *dev)
>> {
>> struct tveeprom tvee;
>> static u8 eeprom[256];
>> + struct i2c_client client;
>> +
>> + memset(&client, 0, sizeof(client));
>> + client.adapter = &dev->i2c_bus[1].i2c_adap;
>> + client.addr = 0xa0 >> 1;
>>
>> - read_eeprom(dev, eeprom, sizeof(eeprom));
>> - tveeprom_hauppauge_analog(&dev->i2c_bus[1].i2c_client,
>> + read_eeprom(dev, &client, eeprom, sizeof(eeprom));
>> + tveeprom_hauppauge_analog(&client,
>> &tvee, eeprom + 0xc0);
>> break;
>> }
>>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 04/12] cx231xx: give each master i2c bus a seperate name
2014-09-25 15:04 ` Antti Palosaari
@ 2014-09-26 4:34 ` Matthias Schwarzott
2014-09-26 12:32 ` Antti Palosaari
0 siblings, 1 reply; 26+ messages in thread
From: Matthias Schwarzott @ 2014-09-26 4:34 UTC (permalink / raw)
To: Antti Palosaari, linux-media, mchehab
On 25.09.2014 17:04, Antti Palosaari wrote:
> So this patch adds bus number to adapter name as postfix?
>
> "cx231xx" => "cx231xx-1"
>
Yes, it is attached, and the result looks like
* cx231xx #0-0
* cx231xx #0-1
* cx231xx #0-2
> I have no clear opinion for that. I think name should be given when
> adapter is crated, not afterwards.
>
It is written to the i2c_adapter before calling i2c_add_adapter. Is this
good enough?
Regards
Matthias
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 02/12] cx231xx: use own i2c_client for eeprom access
2014-09-26 4:30 ` Matthias Schwarzott
@ 2014-09-26 12:31 ` Antti Palosaari
2014-09-26 13:00 ` Antti Palosaari
0 siblings, 1 reply; 26+ messages in thread
From: Antti Palosaari @ 2014-09-26 12:31 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
yes, of course :) If you has only one message, there is nothing to start
again. Sending one message using i2c_transfer() means same than using
i2c_master_send(), but the later one is just aimed to send single
message and it cannot be used to send multiple messages at once.
Code is correct, but it triggered my sensors when reading it and I have
to check it many times whats going there.
regards
Antti
On 09/26/2014 07:30 AM, Matthias Schwarzott wrote:
> Hi Antti,
>
> I think that i2c_transfer sens no repeated start when sending only one
> message per call.
>
> At least the received eeprom content looks correct.
>
> Regards
> Matthias
>
> On 25.09.2014 16:58, Antti Palosaari wrote:
>> Reviewed-by: Antti Palosaari <crope@iki.fi>
>>
>> Please add commit description (why and how).
>>
>> Some notes for further development:
>> It sends single messages, so you could (or even should) use
>> i2c_master_send/i2c_master_recv (i2c_transfer is aimed for sending
>> multiple messages using REPEATED START condition).
>>
>> I am not sure though if these eeprom chips uses REPEATED START condition
>> for reads (means it could be broken even now).
>>
>> regards
>> Antti
>>
>> On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
>>> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
>>> ---
>>> drivers/media/usb/cx231xx/cx231xx-cards.c | 24 +++++++++++++-----------
>>> 1 file changed, 13 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c
>>> b/drivers/media/usb/cx231xx/cx231xx-cards.c
>>> index 791f00c..092fb85 100644
>>> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
>>> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
>>> @@ -980,23 +980,20 @@ static void cx231xx_config_tuner(struct cx231xx
>>> *dev)
>>>
>>> }
>>>
>>> -static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len)
>>> +static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
>>> + u8 *eedata, int len)
>>> {
>>> int ret = 0;
>>> - u8 addr = 0xa0 >> 1;
>>> u8 start_offset = 0;
>>> int len_todo = len;
>>> u8 *eedata_cur = eedata;
>>> int i;
>>> - struct i2c_msg msg_write = { .addr = addr, .flags = 0,
>>> + struct i2c_msg msg_write = { .addr = client->addr, .flags = 0,
>>> .buf = &start_offset, .len = 1 };
>>> - struct i2c_msg msg_read = { .addr = addr, .flags = I2C_M_RD };
>>> -
>>> - /* mutex_lock(&dev->i2c_lock); */
>>> - cx231xx_enable_i2c_port_3(dev, false);
>>> + struct i2c_msg msg_read = { .addr = client->addr, .flags =
>>> I2C_M_RD };
>>>
>>> /* start reading at offset 0 */
>>> - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_write, 1);
>>> + ret = i2c_transfer(client->adapter, &msg_write, 1);
>>> if (ret < 0) {
>>> cx231xx_err("Can't read eeprom\n");
>>> return ret;
>>> @@ -1006,7 +1003,7 @@ static int read_eeprom(struct cx231xx *dev, u8
>>> *eedata, int len)
>>> msg_read.len = (len_todo > 64) ? 64 : len_todo;
>>> msg_read.buf = eedata_cur;
>>>
>>> - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_read, 1);
>>> + ret = i2c_transfer(client->adapter, &msg_read, 1);
>>> if (ret < 0) {
>>> cx231xx_err("Can't read eeprom\n");
>>> return ret;
>>> @@ -1062,9 +1059,14 @@ void cx231xx_card_setup(struct cx231xx *dev)
>>> {
>>> struct tveeprom tvee;
>>> static u8 eeprom[256];
>>> + struct i2c_client client;
>>> +
>>> + memset(&client, 0, sizeof(client));
>>> + client.adapter = &dev->i2c_bus[1].i2c_adap;
>>> + client.addr = 0xa0 >> 1;
>>>
>>> - read_eeprom(dev, eeprom, sizeof(eeprom));
>>> - tveeprom_hauppauge_analog(&dev->i2c_bus[1].i2c_client,
>>> + read_eeprom(dev, &client, eeprom, sizeof(eeprom));
>>> + tveeprom_hauppauge_analog(&client,
>>> &tvee, eeprom + 0xc0);
>>> break;
>>> }
>>>
>>
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 04/12] cx231xx: give each master i2c bus a seperate name
2014-09-26 4:34 ` Matthias Schwarzott
@ 2014-09-26 12:32 ` Antti Palosaari
0 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-26 12:32 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
On 09/26/2014 07:34 AM, Matthias Schwarzott wrote:
> On 25.09.2014 17:04, Antti Palosaari wrote:
>> So this patch adds bus number to adapter name as postfix?
>>
>> "cx231xx" => "cx231xx-1"
>>
> Yes, it is attached, and the result looks like
> * cx231xx #0-0
> * cx231xx #0-1
> * cx231xx #0-2
>
>> I have no clear opinion for that. I think name should be given when
>> adapter is crated, not afterwards.
>>
> It is written to the i2c_adapter before calling i2c_add_adapter. Is this
> good enough?
ah, OK, yes.
Antti
>
> Regards
> Matthias
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 02/12] cx231xx: use own i2c_client for eeprom access
2014-09-26 12:31 ` Antti Palosaari
@ 2014-09-26 13:00 ` Antti Palosaari
0 siblings, 0 replies; 26+ messages in thread
From: Antti Palosaari @ 2014-09-26 13:00 UTC (permalink / raw)
To: Matthias Schwarzott, linux-media, mchehab
I decided to check how eeprom I2C interface works from datasheet. Chip
keeps internally current address value and read operations are done for
that. Basically both reads works, as chip keeps count of current read
address internally.
That datasheet has nice figures from use cases:
http://www.atmel.com/Images/doc8700.pdf
Figure 9-1. Byte Write
Figure 9-2. Page Write
Figure 9-3. Current Address Read
Figure 9-4. Random Read
Figure 9-5. Sequential Read
regards
Antti
On 09/26/2014 03:31 PM, Antti Palosaari wrote:
> yes, of course :) If you has only one message, there is nothing to start
> again. Sending one message using i2c_transfer() means same than using
> i2c_master_send(), but the later one is just aimed to send single
> message and it cannot be used to send multiple messages at once.
>
> Code is correct, but it triggered my sensors when reading it and I have
> to check it many times whats going there.
>
> regards
> Antti
>
> On 09/26/2014 07:30 AM, Matthias Schwarzott wrote:
>> Hi Antti,
>>
>> I think that i2c_transfer sens no repeated start when sending only one
>> message per call.
>>
>> At least the received eeprom content looks correct.
>>
>> Regards
>> Matthias
>>
>> On 25.09.2014 16:58, Antti Palosaari wrote:
>>> Reviewed-by: Antti Palosaari <crope@iki.fi>
>>>
>>> Please add commit description (why and how).
>>>
>>> Some notes for further development:
>>> It sends single messages, so you could (or even should) use
>>> i2c_master_send/i2c_master_recv (i2c_transfer is aimed for sending
>>> multiple messages using REPEATED START condition).
>>>
>>> I am not sure though if these eeprom chips uses REPEATED START condition
>>> for reads (means it could be broken even now).
>>>
>>> regards
>>> Antti
>>>
>>> On 09/25/2014 08:07 AM, Matthias Schwarzott wrote:
>>>> Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
>>>> ---
>>>> drivers/media/usb/cx231xx/cx231xx-cards.c | 24
>>>> +++++++++++++-----------
>>>> 1 file changed, 13 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c
>>>> b/drivers/media/usb/cx231xx/cx231xx-cards.c
>>>> index 791f00c..092fb85 100644
>>>> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
>>>> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
>>>> @@ -980,23 +980,20 @@ static void cx231xx_config_tuner(struct cx231xx
>>>> *dev)
>>>>
>>>> }
>>>>
>>>> -static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len)
>>>> +static int read_eeprom(struct cx231xx *dev, struct i2c_client *client,
>>>> + u8 *eedata, int len)
>>>> {
>>>> int ret = 0;
>>>> - u8 addr = 0xa0 >> 1;
>>>> u8 start_offset = 0;
>>>> int len_todo = len;
>>>> u8 *eedata_cur = eedata;
>>>> int i;
>>>> - struct i2c_msg msg_write = { .addr = addr, .flags = 0,
>>>> + struct i2c_msg msg_write = { .addr = client->addr, .flags = 0,
>>>> .buf = &start_offset, .len = 1 };
>>>> - struct i2c_msg msg_read = { .addr = addr, .flags = I2C_M_RD };
>>>> -
>>>> - /* mutex_lock(&dev->i2c_lock); */
>>>> - cx231xx_enable_i2c_port_3(dev, false);
>>>> + struct i2c_msg msg_read = { .addr = client->addr, .flags =
>>>> I2C_M_RD };
>>>>
>>>> /* start reading at offset 0 */
>>>> - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_write, 1);
>>>> + ret = i2c_transfer(client->adapter, &msg_write, 1);
>>>> if (ret < 0) {
>>>> cx231xx_err("Can't read eeprom\n");
>>>> return ret;
>>>> @@ -1006,7 +1003,7 @@ static int read_eeprom(struct cx231xx *dev, u8
>>>> *eedata, int len)
>>>> msg_read.len = (len_todo > 64) ? 64 : len_todo;
>>>> msg_read.buf = eedata_cur;
>>>>
>>>> - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_read, 1);
>>>> + ret = i2c_transfer(client->adapter, &msg_read, 1);
>>>> if (ret < 0) {
>>>> cx231xx_err("Can't read eeprom\n");
>>>> return ret;
>>>> @@ -1062,9 +1059,14 @@ void cx231xx_card_setup(struct cx231xx *dev)
>>>> {
>>>> struct tveeprom tvee;
>>>> static u8 eeprom[256];
>>>> + struct i2c_client client;
>>>> +
>>>> + memset(&client, 0, sizeof(client));
>>>> + client.adapter = &dev->i2c_bus[1].i2c_adap;
>>>> + client.addr = 0xa0 >> 1;
>>>>
>>>> - read_eeprom(dev, eeprom, sizeof(eeprom));
>>>> - tveeprom_hauppauge_analog(&dev->i2c_bus[1].i2c_client,
>>>> + read_eeprom(dev, &client, eeprom, sizeof(eeprom));
>>>> + tveeprom_hauppauge_analog(&client,
>>>> &tvee, eeprom + 0xc0);
>>>> break;
>>>> }
>>>>
>>>
>>
>
--
http://palosaari.fi/
^ permalink raw reply [flat|nested] 26+ messages in thread
end of thread, other threads:[~2014-09-26 13:00 UTC | newest]
Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25 5:07 [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Matthias Schwarzott
2014-09-25 5:07 ` [PATCH 02/12] cx231xx: use own i2c_client for eeprom access Matthias Schwarzott
2014-09-25 14:58 ` Antti Palosaari
2014-09-26 4:30 ` Matthias Schwarzott
2014-09-26 12:31 ` Antti Palosaari
2014-09-26 13:00 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 03/12] cx231xx: delete i2c_client per bus Matthias Schwarzott
2014-09-25 15:00 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 04/12] cx231xx: give each master i2c bus a seperate name Matthias Schwarzott
2014-09-25 15:04 ` Antti Palosaari
2014-09-26 4:34 ` Matthias Schwarzott
2014-09-26 12:32 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 05/12] cx231xx: Use symbolic constants for i2c ports Matthias Schwarzott
2014-09-25 15:06 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 06/12] cx231xx: add wrapper to get the i2c_adapter pointer Matthias Schwarzott
2014-09-25 15:13 ` Antti Palosaari
2014-09-25 5:07 ` [PATCH 07/12] cx231xx: remember status of port_3 switch Matthias Schwarzott
2014-09-25 5:08 ` [PATCH 08/12] cx231xx: let is_tuner check the real i2c port and not the i2c master number Matthias Schwarzott
2014-09-25 5:08 ` [PATCH 09/12] cx231xx: change usage of I2C_1 to the real i2c port Matthias Schwarzott
2014-09-25 5:08 ` [PATCH 10/12] cx231xx: register i2c mux adapters for master1 and use as I2C_1 and I2C_3 Matthias Schwarzott
2014-09-25 15:25 ` Antti Palosaari
2014-09-25 5:08 ` [PATCH 11/12] cx231xx: drop unconditional port3 switching Matthias Schwarzott
2014-09-25 15:26 ` Antti Palosaari
2014-09-25 5:08 ` [PATCH 12/12] cx231xx: scan all four existing i2c busses instead of the 3 masters Matthias Schwarzott
2014-09-25 15:30 ` Antti Palosaari
2014-09-25 14:50 ` [PATCH 01/12] cx231xx: let i2c bus scanning use its own i2c_client Antti Palosaari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).