public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH FOR 3.2 FIX] af9015: limit I2C access to keep FW happy
@ 2011-11-13 19:05 Antti Palosaari
  2011-11-13 19:19 ` Antti Palosaari
  0 siblings, 1 reply; 6+ messages in thread
From: Antti Palosaari @ 2011-11-13 19:05 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: Malcolm Priestley

AF9015 firmware does not like if it gets interrupted by I2C adapter
request on some critical phases. During normal operation I2C adapter
is used only 2nd demodulator and tuner on dual tuner devices.

Override demodulator callbacks and use mutex for limit access to
those "critical" paths to keep AF9015 happy.

Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 drivers/media/dvb/dvb-usb/af9015.c |   97 ++++++++++++++++++++++++++++++++++++
 drivers/media/dvb/dvb-usb/af9015.h |    7 +++
 2 files changed, 104 insertions(+), 0 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index c6c275b..033aa8a 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -1093,9 +1093,80 @@ error:
 	return ret;
 }
 
+/* override demod callbacks for resource locking */
+static int af9015_af9013_set_frontend(struct dvb_frontend *fe,
+	struct dvb_frontend_parameters *params)
+{
+	int ret;
+	struct dvb_usb_adapter *adap = fe->dvb->priv;
+	struct af9015_state *priv = adap->dev->priv;
+
+	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
+		return -EAGAIN;
+
+	ret = priv->set_frontend[adap->id](fe, params);
+
+	mutex_unlock(&adap->dev->usb_mutex);
+
+	return ret;
+}
+
+/* override demod callbacks for resource locking */
+static int af9015_af9013_read_status(struct dvb_frontend *fe,
+	fe_status_t *status)
+{
+	int ret;
+	struct dvb_usb_adapter *adap = fe->dvb->priv;
+	struct af9015_state *priv = adap->dev->priv;
+
+	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
+		return -EAGAIN;
+
+	ret = priv->read_status[adap->id](fe, status);
+
+	mutex_unlock(&adap->dev->usb_mutex);
+
+	return ret;
+}
+
+/* override demod callbacks for resource locking */
+static int af9015_af9013_init(struct dvb_frontend *fe)
+{
+	int ret;
+	struct dvb_usb_adapter *adap = fe->dvb->priv;
+	struct af9015_state *priv = adap->dev->priv;
+
+	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
+		return -EAGAIN;
+
+	ret = priv->init[adap->id](fe);
+
+	mutex_unlock(&adap->dev->usb_mutex);
+
+	return ret;
+}
+
+/* override demod callbacks for resource locking */
+static int af9015_af9013_sleep(struct dvb_frontend *fe)
+{
+	int ret;
+	struct dvb_usb_adapter *adap = fe->dvb->priv;
+	struct af9015_state *priv = adap->dev->priv;
+
+	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
+		return -EAGAIN;
+
+	ret = priv->init[adap->id](fe);
+
+	mutex_unlock(&adap->dev->usb_mutex);
+
+	return ret;
+}
+
 static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
 {
 	int ret;
+	struct af9015_state *state = adap->dev->priv;
 
 	if (adap->id == 1) {
 		/* copy firmware to 2nd demodulator */
@@ -1116,6 +1187,32 @@ static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
 	adap->fe_adap[0].fe = dvb_attach(af9013_attach, &af9015_af9013_config[adap->id],
 		&adap->dev->i2c_adap);
 
+	/*
+	 * AF9015 firmware does not like if it gets interrupted by I2C adapter
+	 * request on some critical phases. During normal operation I2C adapter
+	 * is used only 2nd demodulator and tuner on dual tuner devices.
+	 * Override demodulator callbacks and use mutex for limit access to
+	 * those "critical" paths to keep AF9015 happy.
+	 * Note: we abuse unused usb_mutex here.
+	 */
+	if (adap->fe_adap[0].fe) {
+		state->set_frontend[adap->id] =
+			adap->fe_adap[0].fe->ops.set_frontend;
+		adap->fe_adap[0].fe->ops.set_frontend =
+			af9015_af9013_set_frontend;
+
+		state->read_status[adap->id] =
+			adap->fe_adap[0].fe->ops.read_status;
+		adap->fe_adap[0].fe->ops.read_status =
+			af9015_af9013_read_status;
+
+		state->init[adap->id] = adap->fe_adap[0].fe->ops.init;
+		adap->fe_adap[0].fe->ops.init = af9015_af9013_init;
+
+		state->sleep[adap->id] = adap->fe_adap[0].fe->ops.sleep;
+		adap->fe_adap[0].fe->ops.sleep = af9015_af9013_sleep;
+	}
+
 	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
 }
 
diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h
index 6252ea6..4a12617 100644
--- a/drivers/media/dvb/dvb-usb/af9015.h
+++ b/drivers/media/dvb/dvb-usb/af9015.h
@@ -102,6 +102,13 @@ struct af9015_state {
 	u8 rc_repeat;
 	u32 rc_keycode;
 	u8 rc_last[4];
+
+	/* for demod callback override */
+	int (*set_frontend[2]) (struct dvb_frontend *fe,
+		struct dvb_frontend_parameters *params);
+	int (*read_status[2]) (struct dvb_frontend *fe, fe_status_t *status);
+	int (*init[2]) (struct dvb_frontend *fe);
+	int (*sleep[2]) (struct dvb_frontend *fe);
 };
 
 struct af9015_config {
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH FOR 3.2 FIX] af9015: limit I2C access to keep FW happy
  2011-11-13 19:05 [PATCH FOR 3.2 FIX] af9015: limit I2C access to keep FW happy Antti Palosaari
@ 2011-11-13 19:19 ` Antti Palosaari
  2011-11-14 22:25   ` Malcolm Priestley
  0 siblings, 1 reply; 6+ messages in thread
From: Antti Palosaari @ 2011-11-13 19:19 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, Malcolm Priestley

Mauro,
Don't still but that to the 3.2 as fix. It is not much tested and not 
critical so better put it master for some more testing.

regards
Antti

On 11/13/2011 09:05 PM, Antti Palosaari wrote:
> AF9015 firmware does not like if it gets interrupted by I2C adapter
> request on some critical phases. During normal operation I2C adapter
> is used only 2nd demodulator and tuner on dual tuner devices.
>
> Override demodulator callbacks and use mutex for limit access to
> those "critical" paths to keep AF9015 happy.
>
> Signed-off-by: Antti Palosaari<crope@iki.fi>
> ---
>   drivers/media/dvb/dvb-usb/af9015.c |   97 ++++++++++++++++++++++++++++++++++++
>   drivers/media/dvb/dvb-usb/af9015.h |    7 +++
>   2 files changed, 104 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
> index c6c275b..033aa8a 100644
> --- a/drivers/media/dvb/dvb-usb/af9015.c
> +++ b/drivers/media/dvb/dvb-usb/af9015.c
> @@ -1093,9 +1093,80 @@ error:
>   	return ret;
>   }
>
> +/* override demod callbacks for resource locking */
> +static int af9015_af9013_set_frontend(struct dvb_frontend *fe,
> +	struct dvb_frontend_parameters *params)
> +{
> +	int ret;
> +	struct dvb_usb_adapter *adap = fe->dvb->priv;
> +	struct af9015_state *priv = adap->dev->priv;
> +
> +	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
> +		return -EAGAIN;
> +
> +	ret = priv->set_frontend[adap->id](fe, params);
> +
> +	mutex_unlock(&adap->dev->usb_mutex);
> +
> +	return ret;
> +}
> +
> +/* override demod callbacks for resource locking */
> +static int af9015_af9013_read_status(struct dvb_frontend *fe,
> +	fe_status_t *status)
> +{
> +	int ret;
> +	struct dvb_usb_adapter *adap = fe->dvb->priv;
> +	struct af9015_state *priv = adap->dev->priv;
> +
> +	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
> +		return -EAGAIN;
> +
> +	ret = priv->read_status[adap->id](fe, status);
> +
> +	mutex_unlock(&adap->dev->usb_mutex);
> +
> +	return ret;
> +}
> +
> +/* override demod callbacks for resource locking */
> +static int af9015_af9013_init(struct dvb_frontend *fe)
> +{
> +	int ret;
> +	struct dvb_usb_adapter *adap = fe->dvb->priv;
> +	struct af9015_state *priv = adap->dev->priv;
> +
> +	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
> +		return -EAGAIN;
> +
> +	ret = priv->init[adap->id](fe);
> +
> +	mutex_unlock(&adap->dev->usb_mutex);
> +
> +	return ret;
> +}
> +
> +/* override demod callbacks for resource locking */
> +static int af9015_af9013_sleep(struct dvb_frontend *fe)
> +{
> +	int ret;
> +	struct dvb_usb_adapter *adap = fe->dvb->priv;
> +	struct af9015_state *priv = adap->dev->priv;
> +
> +	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
> +		return -EAGAIN;
> +
> +	ret = priv->init[adap->id](fe);
> +
> +	mutex_unlock(&adap->dev->usb_mutex);
> +
> +	return ret;
> +}
> +
>   static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
>   {
>   	int ret;
> +	struct af9015_state *state = adap->dev->priv;
>
>   	if (adap->id == 1) {
>   		/* copy firmware to 2nd demodulator */
> @@ -1116,6 +1187,32 @@ static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
>   	adap->fe_adap[0].fe = dvb_attach(af9013_attach,&af9015_af9013_config[adap->id],
>   		&adap->dev->i2c_adap);
>
> +	/*
> +	 * AF9015 firmware does not like if it gets interrupted by I2C adapter
> +	 * request on some critical phases. During normal operation I2C adapter
> +	 * is used only 2nd demodulator and tuner on dual tuner devices.
> +	 * Override demodulator callbacks and use mutex for limit access to
> +	 * those "critical" paths to keep AF9015 happy.
> +	 * Note: we abuse unused usb_mutex here.
> +	 */
> +	if (adap->fe_adap[0].fe) {
> +		state->set_frontend[adap->id] =
> +			adap->fe_adap[0].fe->ops.set_frontend;
> +		adap->fe_adap[0].fe->ops.set_frontend =
> +			af9015_af9013_set_frontend;
> +
> +		state->read_status[adap->id] =
> +			adap->fe_adap[0].fe->ops.read_status;
> +		adap->fe_adap[0].fe->ops.read_status =
> +			af9015_af9013_read_status;
> +
> +		state->init[adap->id] = adap->fe_adap[0].fe->ops.init;
> +		adap->fe_adap[0].fe->ops.init = af9015_af9013_init;
> +
> +		state->sleep[adap->id] = adap->fe_adap[0].fe->ops.sleep;
> +		adap->fe_adap[0].fe->ops.sleep = af9015_af9013_sleep;
> +	}
> +
>   	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
>   }
>
> diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h
> index 6252ea6..4a12617 100644
> --- a/drivers/media/dvb/dvb-usb/af9015.h
> +++ b/drivers/media/dvb/dvb-usb/af9015.h
> @@ -102,6 +102,13 @@ struct af9015_state {
>   	u8 rc_repeat;
>   	u32 rc_keycode;
>   	u8 rc_last[4];
> +
> +	/* for demod callback override */
> +	int (*set_frontend[2]) (struct dvb_frontend *fe,
> +		struct dvb_frontend_parameters *params);
> +	int (*read_status[2]) (struct dvb_frontend *fe, fe_status_t *status);
> +	int (*init[2]) (struct dvb_frontend *fe);
> +	int (*sleep[2]) (struct dvb_frontend *fe);
>   };
>
>   struct af9015_config {


-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH FOR 3.2 FIX] af9015: limit I2C access to keep FW happy
  2011-11-13 19:19 ` Antti Palosaari
@ 2011-11-14 22:25   ` Malcolm Priestley
  2011-11-14 22:56     ` Antti Palosaari
  2011-11-29  0:09     ` Antti Palosaari
  0 siblings, 2 replies; 6+ messages in thread
From: Malcolm Priestley @ 2011-11-14 22:25 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Mauro Carvalho Chehab, linux-media

On Sun, 2011-11-13 at 21:19 +0200, Antti Palosaari wrote:
> Mauro,
> Don't still but that to the 3.2 as fix. It is not much tested and not 
> critical so better put it master for some more testing.
> 
> regards
> Antti
> 
> On 11/13/2011 09:05 PM, Antti Palosaari wrote:
> > AF9015 firmware does not like if it gets interrupted by I2C adapter
> > request on some critical phases. During normal operation I2C adapter
> > is used only 2nd demodulator and tuner on dual tuner devices.
> >
> > Override demodulator callbacks and use mutex for limit access to
> > those "critical" paths to keep AF9015 happy.
> >
> > Signed-off-by: Antti Palosaari<crope@iki.fi>
> > ---
> >   drivers/media/dvb/dvb-usb/af9015.c |   97 ++++++++++++++++++++++++++++++++++++
> >   drivers/media/dvb/dvb-usb/af9015.h |    7 +++
> >   2 files changed, 104 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
> > index c6c275b..033aa8a 100644
> > --- a/drivers/media/dvb/dvb-usb/af9015.c
> > +++ b/drivers/media/dvb/dvb-usb/af9015.c
> > @@ -1093,9 +1093,80 @@ error:
> >   	return ret;
> >   }
> >
> > +/* override demod callbacks for resource locking */
> > +static int af9015_af9013_set_frontend(struct dvb_frontend *fe,
> > +	struct dvb_frontend_parameters *params)
> > +{
> > +	int ret;
> > +	struct dvb_usb_adapter *adap = fe->dvb->priv;
> > +	struct af9015_state *priv = adap->dev->priv;
> > +
> > +	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
> > +		return -EAGAIN;
> > +
> > +	ret = priv->set_frontend[adap->id](fe, params);
> > +
> > +	mutex_unlock(&adap->dev->usb_mutex);
> > +
> > +	return ret;
> > +}
> > +
> > +/* override demod callbacks for resource locking */
> > +static int af9015_af9013_read_status(struct dvb_frontend *fe,
> > +	fe_status_t *status)
> > +{
> > +	int ret;
> > +	struct dvb_usb_adapter *adap = fe->dvb->priv;
> > +	struct af9015_state *priv = adap->dev->priv;
> > +
> > +	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
> > +		return -EAGAIN;
> > +
> > +	ret = priv->read_status[adap->id](fe, status);
> > +
> > +	mutex_unlock(&adap->dev->usb_mutex);
> > +
> > +	return ret;
> > +}
> > +
> > +/* override demod callbacks for resource locking */
> > +static int af9015_af9013_init(struct dvb_frontend *fe)
> > +{
> > +	int ret;
> > +	struct dvb_usb_adapter *adap = fe->dvb->priv;
> > +	struct af9015_state *priv = adap->dev->priv;
> > +
> > +	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
> > +		return -EAGAIN;
> > +
> > +	ret = priv->init[adap->id](fe);
> > +
> > +	mutex_unlock(&adap->dev->usb_mutex);
> > +
> > +	return ret;
> > +}
> > +
> > +/* override demod callbacks for resource locking */
> > +static int af9015_af9013_sleep(struct dvb_frontend *fe)
> > +{
> > +	int ret;
> > +	struct dvb_usb_adapter *adap = fe->dvb->priv;
> > +	struct af9015_state *priv = adap->dev->priv;
> > +
> > +	if (mutex_lock_interruptible(&adap->dev->usb_mutex))
> > +		return -EAGAIN;
> > +
> > +	ret = priv->init[adap->id](fe);
> > +
> > +	mutex_unlock(&adap->dev->usb_mutex);
> > +
> > +	return ret;
> > +}
> > +
> >   static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
> >   {
> >   	int ret;
> > +	struct af9015_state *state = adap->dev->priv;
> >
> >   	if (adap->id == 1) {
> >   		/* copy firmware to 2nd demodulator */
> > @@ -1116,6 +1187,32 @@ static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)
> >   	adap->fe_adap[0].fe = dvb_attach(af9013_attach,&af9015_af9013_config[adap->id],
> >   		&adap->dev->i2c_adap);
> >
> > +	/*
> > +	 * AF9015 firmware does not like if it gets interrupted by I2C adapter
> > +	 * request on some critical phases. During normal operation I2C adapter
> > +	 * is used only 2nd demodulator and tuner on dual tuner devices.
> > +	 * Override demodulator callbacks and use mutex for limit access to
> > +	 * those "critical" paths to keep AF9015 happy.
> > +	 * Note: we abuse unused usb_mutex here.
> > +	 */
> > +	if (adap->fe_adap[0].fe) {
> > +		state->set_frontend[adap->id] =
> > +			adap->fe_adap[0].fe->ops.set_frontend;
> > +		adap->fe_adap[0].fe->ops.set_frontend =
> > +			af9015_af9013_set_frontend;
> > +
> > +		state->read_status[adap->id] =
> > +			adap->fe_adap[0].fe->ops.read_status;
> > +		adap->fe_adap[0].fe->ops.read_status =
> > +			af9015_af9013_read_status;
> > +
> > +		state->init[adap->id] = adap->fe_adap[0].fe->ops.init;
> > +		adap->fe_adap[0].fe->ops.init = af9015_af9013_init;
> > +
> > +		state->sleep[adap->id] = adap->fe_adap[0].fe->ops.sleep;
> > +		adap->fe_adap[0].fe->ops.sleep = af9015_af9013_sleep;
> > +	}
> > +
> >   	return adap->fe_adap[0].fe == NULL ? -ENODEV : 0;
> >   }
> >

I have tried this patch, while it initially got MythTV working, there is
too many call backs and some failed to acquire the lock. The device
became unstable on both single and dual devices. 

The callbacks

af9015_af9013_read_status, 
af9015_af9013_init
af9015_af9013_sleep

had to be removed.

I take your point, a call back can be an alternative.

The patch didn't stop the firmware fails either.

The af9015 usb bridge on the whole is so unstable in its early stages,
especially on a cold boot and when the USB controller has another device
on it, such as card reader or wifi device.

I am, at the moment looking to see if the fails are due to interface 1
being claimed by HID.

Regards

Malcolm


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH FOR 3.2 FIX] af9015: limit I2C access to keep FW happy
  2011-11-14 22:25   ` Malcolm Priestley
@ 2011-11-14 22:56     ` Antti Palosaari
  2011-11-29  0:09     ` Antti Palosaari
  1 sibling, 0 replies; 6+ messages in thread
From: Antti Palosaari @ 2011-11-14 22:56 UTC (permalink / raw)
  To: Malcolm Priestley; +Cc: linux-media

[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]

On 11/15/2011 12:25 AM, Malcolm Priestley wrote:
>> On 11/13/2011 09:05 PM, Antti Palosaari wrote:
>>> AF9015 firmware does not like if it gets interrupted by I2C adapter
>>> request on some critical phases. During normal operation I2C adapter
>>> is used only 2nd demodulator and tuner on dual tuner devices.
>>>
>>> Override demodulator callbacks and use mutex for limit access to
>>> those "critical" paths to keep AF9015 happy.

> I have tried this patch, while it initially got MythTV working, there is
> too many call backs and some failed to acquire the lock. The device
> became unstable on both single and dual devices.
>
> The callbacks
>
> af9015_af9013_read_status,
> af9015_af9013_init
> af9015_af9013_sleep
>
> had to be removed.

init and sleep are called very rarely, only when open or close device. 
If that mutex locking cause problems it is most likely high I2C I/O + 
some waiting due to mux => we have more I/O than we can handle.

> I take your point, a call back can be an alternative.
>
> The patch didn't stop the firmware fails either.

You mean the loading fw to 2nd FE? I didn't done nothing for that.

> The af9015 usb bridge on the whole is so unstable in its early stages,
> especially on a cold boot and when the USB controller has another device
> on it, such as card reader or wifi device.
>
> I am, at the moment looking to see if the fails are due to interface 1
> being claimed by HID.

I still suspect corruptions to stream are coming from too high I2C 
traffic. I have feeling those who always squawk are just MythTV users, 
so maybe it is MythTV that does some very much polls and channel changes.

I added patch I tested reducing I2C I/O. Feel free to test.

I can try to optimize af9013 next weekend if we found it is one stream 
corruption cause.


Antti


-- 
http://palosaari.fi/

[-- Attachment #2: af9013_reduce_i2c.patch --]
[-- Type: text/plain, Size: 3587 bytes --]

diff --git a/drivers/media/dvb/frontends/af9013.c b/drivers/media/dvb/frontends/af9013.c
index f4276e4..4694f4b 100644
--- a/drivers/media/dvb/frontends/af9013.c
+++ b/drivers/media/dvb/frontends/af9013.c
@@ -50,6 +50,8 @@ struct af9013_state {
 	u16 snr;
 	u32 frequency;
 	unsigned long next_statistics_check;
+
+	u8 fe_set;
 };
 
 static u8 regmask[8] = { 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
@@ -606,19 +608,29 @@ static int af9013_set_frontend(struct dvb_frontend *fe,
 
 	state->frequency = params->frequency;
 
+	/* Stop OFSM */ // from Malcom
+	ret = af9013_write_reg(state, 0xffff, 1);
+	if (ret)
+		goto error;
+
 	/* program tuner */
 	if (fe->ops.tuner_ops.set_params)
 		fe->ops.tuner_ops.set_params(fe, params);
 
-	/* program CFOE coefficients */
-	ret = af9013_set_coeff(state, params->u.ofdm.bandwidth);
-	if (ret)
-		goto error;
+	if (!state->fe_set) {
 
-	/* program frequency control */
-	ret = af9013_set_freq_ctrl(state, fe);
-	if (ret)
-		goto error;
+		/* program CFOE coefficients */
+		ret = af9013_set_coeff(state, params->u.ofdm.bandwidth);
+		if (ret)
+			goto error;
+
+		/* program frequency control */
+		ret = af9013_set_freq_ctrl(state, fe);
+		if (ret)
+			goto error;
+
+		state->fe_set = 1;
+	}
 
 	/* clear TPS lock flag (inverted flag) */
 	ret = af9013_write_reg_bits(state, 0xd330, 3, 1, 1);
@@ -917,6 +929,7 @@ static int af9013_update_snr(struct dvb_frontend *fe)
 		if (ret)
 			goto error;
 
+#if 0
 		/* check quantizer availability */
 		for (i = 0; i < 10; i++) {
 			msleep(10);
@@ -927,7 +940,7 @@ static int af9013_update_snr(struct dvb_frontend *fe)
 			if (!buf[0])
 				break;
 		}
-
+#endif
 		/* reset quantizer */
 		ret = af9013_write_reg_bits(state, 0xd2e1, 3, 1, 1);
 		if (ret)
@@ -978,6 +991,8 @@ static int af9013_update_statistics(struct dvb_frontend *fe)
 	struct af9013_state *state = fe->demodulator_priv;
 	int ret;
 
+	return 0;
+
 	if (time_before(jiffies, state->next_statistics_check))
 		return 0;
 
@@ -1015,6 +1030,15 @@ static int af9013_read_status(struct dvb_frontend *fe, fe_status_t *status)
 	u8 tmp;
 	*status = 0;
 
+
+	if (state->config.output_mode == AF9013_OUTPUT_MODE_USB) {
+		*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+	} else {
+		*status |= FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
+//		*status = 0;
+	}
+
+#if 0
 	/* MPEG2 lock */
 	ret = af9013_read_reg_bits(state, 0xd507, 6, 1, &tmp);
 	if (ret)
@@ -1061,6 +1085,7 @@ static int af9013_read_status(struct dvb_frontend *fe, fe_status_t *status)
 	}
 
 	ret = af9013_update_statistics(fe);
+#endif
 
 error:
 	return ret;
@@ -1109,11 +1134,14 @@ static int af9013_sleep(struct dvb_frontend *fe)
 	int ret;
 	deb_info("%s\n", __func__);
 
+	state->fe_set = 0;
+
 	ret = af9013_lock_led(state, 0);
 	if (ret)
 		goto error;
 
 	ret = af9013_power_ctrl(state, 0);
+
 error:
 	return ret;
 }
@@ -1126,6 +1154,9 @@ static int af9013_init(struct dvb_frontend *fe)
 	struct regdesc *init;
 	deb_info("%s\n", __func__);
 
+	state->fe_set = 0;
+
+
 	/* reset OFDM */
 	ret = af9013_reset(state, 0);
 	if (ret)
@@ -1292,6 +1323,8 @@ static int af9013_init(struct dvb_frontend *fe)
 			goto error;
 	}
 
+	ret = af9013_write_reg(state, 0xd503, 0x0);
+
 error:
 	return ret;
 }
@@ -1530,7 +1563,7 @@ static struct dvb_frontend_ops af9013_ops = {
 	.i2c_gate_ctrl = af9013_i2c_gate_ctrl,
 
 	.set_frontend = af9013_set_frontend,
-	.get_frontend = af9013_get_frontend,
+//	.get_frontend = af9013_get_frontend,
 
 	.get_tune_settings = af9013_get_tune_settings,
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH FOR 3.2 FIX] af9015: limit I2C access to keep FW happy
  2011-11-14 22:25   ` Malcolm Priestley
  2011-11-14 22:56     ` Antti Palosaari
@ 2011-11-29  0:09     ` Antti Palosaari
  2011-11-30 21:31       ` Malcolm Priestley
  1 sibling, 1 reply; 6+ messages in thread
From: Antti Palosaari @ 2011-11-29  0:09 UTC (permalink / raw)
  To: Malcolm Priestley; +Cc: Mauro Carvalho Chehab, linux-media

On 11/15/2011 12:25 AM, Malcolm Priestley wrote:
> I have tried this patch, while it initially got MythTV working, there is
> too many call backs and some failed to acquire the lock. The device
> became unstable on both single and dual devices.
>
> The callbacks
>
> af9015_af9013_read_status,
> af9015_af9013_init
> af9015_af9013_sleep
>
> had to be removed.
>
> I take your point, a call back can be an alternative.
>
> The patch didn't stop the firmware fails either.
>
> The af9015 usb bridge on the whole is so unstable in its early stages,
> especially on a cold boot and when the USB controller has another device
> on it, such as card reader or wifi device.
>
> I am, at the moment looking to see if the fails are due to interface 1
> being claimed by HID.

I just got af9013 rewrite ready. Feel free to test.
http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/misc

It reduces typical statistics polling load maybe 1/4 from the original.

I see still small glitch when switching to channel. That seems to come 
from tuner driver I2C load. There is 3 tuners used for dual devices; 
MXL5005S, MXL5007T and TDA18271. I have only MXL5005S and MXL5007T dual 
devices here. MXL5005S is worse than MXL5007T but both makes still 
rather much I/O.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH FOR 3.2 FIX] af9015: limit I2C access to keep FW happy
  2011-11-29  0:09     ` Antti Palosaari
@ 2011-11-30 21:31       ` Malcolm Priestley
  0 siblings, 0 replies; 6+ messages in thread
From: Malcolm Priestley @ 2011-11-30 21:31 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

On Tue, 2011-11-29 at 02:09 +0200, Antti Palosaari wrote:
> On 11/15/2011 12:25 AM, Malcolm Priestley wrote:
> > I have tried this patch, while it initially got MythTV working, there is
> > too many call backs and some failed to acquire the lock. The device
> > became unstable on both single and dual devices.
> >
> > The callbacks
> >
> > af9015_af9013_read_status,
> > af9015_af9013_init
> > af9015_af9013_sleep
> >
> > had to be removed.
> >
> > I take your point, a call back can be an alternative.
> >
> > The patch didn't stop the firmware fails either.
> >
> > The af9015 usb bridge on the whole is so unstable in its early stages,
> > especially on a cold boot and when the USB controller has another device
> > on it, such as card reader or wifi device.
> >
> > I am, at the moment looking to see if the fails are due to interface 1
> > being claimed by HID.
> 
> I just got af9013 rewrite ready. Feel free to test.
> http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/misc
> 
> It reduces typical statistics polling load maybe 1/4 from the original.
> 
> I see still small glitch when switching to channel. That seems to come 
> from tuner driver I2C load. There is 3 tuners used for dual devices; 
> MXL5005S, MXL5007T and TDA18271. I have only MXL5005S and MXL5007T dual 
> devices here. MXL5005S is worse than MXL5007T but both makes still 
> rather much I/O.

I have had a quick test of this patch, it seems a lot better.

I will do more testing on my troublesome PC and Mythtv at the weekend.

Regards

Malcolm




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-11-30 21:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-13 19:05 [PATCH FOR 3.2 FIX] af9015: limit I2C access to keep FW happy Antti Palosaari
2011-11-13 19:19 ` Antti Palosaari
2011-11-14 22:25   ` Malcolm Priestley
2011-11-14 22:56     ` Antti Palosaari
2011-11-29  0:09     ` Antti Palosaari
2011-11-30 21:31       ` Malcolm Priestley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox