diff mbox

[1/4] tda8290: Allow disabling I2C gate

Message ID 1358716939-2133-2-git-send-email-linux@rainbow-software.org (mailing list archive)
State New, archived
Headers show

Commit Message

Ondrej Zary Jan. 20, 2013, 9:22 p.m. UTC
Allow disabling I2C gate handling by external configuration.
This is required by cards that have all devices on a single I2C bus,
like AverMedia A706.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
---
 drivers/media/tuners/tda8290.c |   13 +++++++++++--
 drivers/media/tuners/tda8290.h |    1 +
 2 files changed, 12 insertions(+), 2 deletions(-)

Comments

Antti Palosaari Jan. 21, 2013, 8:06 a.m. UTC | #1
On 01/20/2013 11:22 PM, Ondrej Zary wrote:
> Allow disabling I2C gate handling by external configuration.
> This is required by cards that have all devices on a single I2C bus,
> like AverMedia A706.

My personal opinion is that I2C gate control should be disabled setting 
callback to NULL (same for the other unwanted callbacks too). There is 
checks for callback existence in DVB-core, it does not call callback if 
it is NULL.

regards
Antti

>
> Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> ---
>   drivers/media/tuners/tda8290.c |   13 +++++++++++--
>   drivers/media/tuners/tda8290.h |    1 +
>   2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
> index 8c48521..16dfbf2 100644
> --- a/drivers/media/tuners/tda8290.c
> +++ b/drivers/media/tuners/tda8290.c
> @@ -54,6 +54,7 @@ struct tda8290_priv {
>   #define TDA18271 16
>
>   	struct tda827x_config cfg;
> +	bool no_i2c_gate;
>   };
>
>   /*---------------------------------------------------------------------*/
> @@ -66,6 +67,9 @@ static int tda8290_i2c_bridge(struct dvb_frontend *fe, int close)
>   	unsigned char disable[2] = { 0x21, 0x00 };
>   	unsigned char *msg;
>
> +	if (priv->no_i2c_gate)
> +		return 0;
> +
>   	if (close) {
>   		msg = enable;
>   		tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
> @@ -88,6 +92,9 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close)
>   	unsigned char buf[3] = { 0x45, 0x01, 0x00 };
>   	unsigned char *msg;
>
> +	if (priv->no_i2c_gate)
> +		return 0;
> +
>   	if (close) {
>   		msg = enable;
>   		tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
> @@ -740,8 +747,10 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
>   	priv->i2c_props.addr     = i2c_addr;
>   	priv->i2c_props.adap     = i2c_adap;
>   	priv->i2c_props.name     = "tda829x";
> -	if (cfg)
> -		priv->cfg.config         = cfg->lna_cfg;
> +	if (cfg) {
> +		priv->cfg.config = cfg->lna_cfg;
> +		priv->no_i2c_gate = cfg->no_i2c_gate;
> +	}
>
>   	if (tda8290_probe(&priv->i2c_props) == 0) {
>   		priv->ver = TDA8290;
> diff --git a/drivers/media/tuners/tda8290.h b/drivers/media/tuners/tda8290.h
> index 7e288b2..9959cc8 100644
> --- a/drivers/media/tuners/tda8290.h
> +++ b/drivers/media/tuners/tda8290.h
> @@ -26,6 +26,7 @@ struct tda829x_config {
>   	unsigned int probe_tuner:1;
>   #define TDA829X_PROBE_TUNER 0
>   #define TDA829X_DONT_PROBE  1
> +	unsigned int no_i2c_gate:1;
>   };
>
>   #if defined(CONFIG_MEDIA_TUNER_TDA8290) || (defined(CONFIG_MEDIA_TUNER_TDA8290_MODULE) && defined(MODULE))
>
Ondrej Zary Jan. 21, 2013, 8:18 a.m. UTC | #2
On Monday 21 January 2013, Antti Palosaari wrote:
> On 01/20/2013 11:22 PM, Ondrej Zary wrote:
> > Allow disabling I2C gate handling by external configuration.
> > This is required by cards that have all devices on a single I2C bus,
> > like AverMedia A706.
>
> My personal opinion is that I2C gate control should be disabled setting
> callback to NULL (same for the other unwanted callbacks too). There is
> checks for callback existence in DVB-core, it does not call callback if
> it is NULL.

This is TDA8290 internal I2C gate which is used by tda8290 internally and also 
by tda827x or tda18271.


> regards
> Antti
>
> > Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
> > ---
> >   drivers/media/tuners/tda8290.c |   13 +++++++++++--
> >   drivers/media/tuners/tda8290.h |    1 +
> >   2 files changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/tuners/tda8290.c
> > b/drivers/media/tuners/tda8290.c index 8c48521..16dfbf2 100644
> > --- a/drivers/media/tuners/tda8290.c
> > +++ b/drivers/media/tuners/tda8290.c
> > @@ -54,6 +54,7 @@ struct tda8290_priv {
> >   #define TDA18271 16
> >
> >   	struct tda827x_config cfg;
> > +	bool no_i2c_gate;
> >   };
> >
> >  
> > /*---------------------------------------------------------------------*/
> > @@ -66,6 +67,9 @@ static int tda8290_i2c_bridge(struct dvb_frontend *fe,
> > int close) unsigned char disable[2] = { 0x21, 0x00 };
> >   	unsigned char *msg;
> >
> > +	if (priv->no_i2c_gate)
> > +		return 0;
> > +
> >   	if (close) {
> >   		msg = enable;
> >   		tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
> > @@ -88,6 +92,9 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe,
> > int close) unsigned char buf[3] = { 0x45, 0x01, 0x00 };
> >   	unsigned char *msg;
> >
> > +	if (priv->no_i2c_gate)
> > +		return 0;
> > +
> >   	if (close) {
> >   		msg = enable;
> >   		tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
> > @@ -740,8 +747,10 @@ struct dvb_frontend *tda829x_attach(struct
> > dvb_frontend *fe, priv->i2c_props.addr     = i2c_addr;
> >   	priv->i2c_props.adap     = i2c_adap;
> >   	priv->i2c_props.name     = "tda829x";
> > -	if (cfg)
> > -		priv->cfg.config         = cfg->lna_cfg;
> > +	if (cfg) {
> > +		priv->cfg.config = cfg->lna_cfg;
> > +		priv->no_i2c_gate = cfg->no_i2c_gate;
> > +	}
> >
> >   	if (tda8290_probe(&priv->i2c_props) == 0) {
> >   		priv->ver = TDA8290;
> > diff --git a/drivers/media/tuners/tda8290.h
> > b/drivers/media/tuners/tda8290.h index 7e288b2..9959cc8 100644
> > --- a/drivers/media/tuners/tda8290.h
> > +++ b/drivers/media/tuners/tda8290.h
> > @@ -26,6 +26,7 @@ struct tda829x_config {
> >   	unsigned int probe_tuner:1;
> >   #define TDA829X_PROBE_TUNER 0
> >   #define TDA829X_DONT_PROBE  1
> > +	unsigned int no_i2c_gate:1;
> >   };
> >
> >   #if defined(CONFIG_MEDIA_TUNER_TDA8290) ||
> > (defined(CONFIG_MEDIA_TUNER_TDA8290_MODULE) && defined(MODULE))
Antti Palosaari Jan. 21, 2013, 9:06 a.m. UTC | #3
On 01/21/2013 10:18 AM, Ondrej Zary wrote:
> On Monday 21 January 2013, Antti Palosaari wrote:
>> On 01/20/2013 11:22 PM, Ondrej Zary wrote:
>>> Allow disabling I2C gate handling by external configuration.
>>> This is required by cards that have all devices on a single I2C bus,
>>> like AverMedia A706.
>>
>> My personal opinion is that I2C gate control should be disabled setting
>> callback to NULL (same for the other unwanted callbacks too). There is
>> checks for callback existence in DVB-core, it does not call callback if
>> it is NULL.
>
> This is TDA8290 internal I2C gate which is used by tda8290 internally and also
> by tda827x or tda18271.

That sounds like there is some logical problems in the driver then, not 
split correctly?

What I think, scenario is tda8290 is analog decoder, tda18271 is silicon 
tuner, which is connected (usually) to the tda8290 I2C bus. tda18271 
calls tda8290 I2C-gate control when needed. Analog or digital demod 
should not call its own I2C gate directly - and if it was done in some 
weird reason then it should call own callback conditionally, checking 
whether or not it is NULL.

regards
Antti
diff mbox

Patch

diff --git a/drivers/media/tuners/tda8290.c b/drivers/media/tuners/tda8290.c
index 8c48521..16dfbf2 100644
--- a/drivers/media/tuners/tda8290.c
+++ b/drivers/media/tuners/tda8290.c
@@ -54,6 +54,7 @@  struct tda8290_priv {
 #define TDA18271 16
 
 	struct tda827x_config cfg;
+	bool no_i2c_gate;
 };
 
 /*---------------------------------------------------------------------*/
@@ -66,6 +67,9 @@  static int tda8290_i2c_bridge(struct dvb_frontend *fe, int close)
 	unsigned char disable[2] = { 0x21, 0x00 };
 	unsigned char *msg;
 
+	if (priv->no_i2c_gate)
+		return 0;
+
 	if (close) {
 		msg = enable;
 		tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
@@ -88,6 +92,9 @@  static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close)
 	unsigned char buf[3] = { 0x45, 0x01, 0x00 };
 	unsigned char *msg;
 
+	if (priv->no_i2c_gate)
+		return 0;
+
 	if (close) {
 		msg = enable;
 		tuner_i2c_xfer_send(&priv->i2c_props, msg, 2);
@@ -740,8 +747,10 @@  struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
 	priv->i2c_props.addr     = i2c_addr;
 	priv->i2c_props.adap     = i2c_adap;
 	priv->i2c_props.name     = "tda829x";
-	if (cfg)
-		priv->cfg.config         = cfg->lna_cfg;
+	if (cfg) {
+		priv->cfg.config = cfg->lna_cfg;
+		priv->no_i2c_gate = cfg->no_i2c_gate;
+	}
 
 	if (tda8290_probe(&priv->i2c_props) == 0) {
 		priv->ver = TDA8290;
diff --git a/drivers/media/tuners/tda8290.h b/drivers/media/tuners/tda8290.h
index 7e288b2..9959cc8 100644
--- a/drivers/media/tuners/tda8290.h
+++ b/drivers/media/tuners/tda8290.h
@@ -26,6 +26,7 @@  struct tda829x_config {
 	unsigned int probe_tuner:1;
 #define TDA829X_PROBE_TUNER 0
 #define TDA829X_DONT_PROBE  1
+	unsigned int no_i2c_gate:1;
 };
 
 #if defined(CONFIG_MEDIA_TUNER_TDA8290) || (defined(CONFIG_MEDIA_TUNER_TDA8290_MODULE) && defined(MODULE))