From: Antti Palosaari <crope@iki.fi>
To: Matthias Schwarzott <zzam@gentoo.org>,
linux-media@vger.kernel.org, mchehab@osg.samsung.com
Subject: Re: [PATCH 10/12] cx231xx: register i2c mux adapters for master1 and use as I2C_1 and I2C_3
Date: Thu, 25 Sep 2014 18:25:28 +0300 [thread overview]
Message-ID: <542433E8.9020504@iki.fi> (raw)
In-Reply-To: <1411621684-8295-10-git-send-email-zzam@gentoo.org>
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/
next prev parent reply other threads:[~2014-09-25 15:25 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=542433E8.9020504@iki.fi \
--to=crope@iki.fi \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
--cc=zzam@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).