af9013 frontend tuner bus lock and gate changes v2
PATCH 4/7 af9013 frontend tuner bus lock and gate changes v2
Changes from version 1
Remove the bus lock from read status. Causing a lagging effect on some kernels < [2.6.38]
This does mean that noisy I2C traffic could be heard on the first frontend when its tuner gate is open.
--- drivers/media/dvb/dvb-usb/af9015.c | 7 ++++++- drivers/media/dvb/frontends/af9013.c | 9 ++++++++- drivers/media/dvb/frontends/af9013.h | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-)
drivers/media/dvb/dvb-usb/af9015.c +6 -1
@@ -46,6 +46,7 @@ module_param_named(no_pid, no_pid_filter, int, 0644);MODULE_PARM_DESC (no_pid,"set default 0=on 1=off" );static DEFINE_MUTEX (af9015_usb_mutex); +static DEFINE_MUTEX (af9015_fe_mutex);static struct af9015_config af9015_config;static struct dvb_usb_device_properties af9015_properties[3 ];
@@ -1147,7 +1148,7 @@ static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap)/* attach demodulator */ adap->fe_adap[0 ].fe =dvb_attach (af9013_attach, &af9015_af9013_config[adap->id], - &adap->dev->i2c_adap); + &adap->dev->i2c_adap, &af9015_fe_mutex);return adap->fe_adap[0 ].fe ==NULL ? -ENODEV :0 ; }
@@ -1220,6 +1221,9 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap)int ret;deb_info ("%s:\n" , __func__); +if (mutex_lock_interruptible (&af9015_fe_mutex) <0 ) +return -EAGAIN ; +switch (af9015_af9013_config[adap->id].tuner) {case AF9013_TUNER_MT2060 :case AF9013_TUNER_MT2060_2 :
@@ -1275,6 +1279,7 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap)err ("Unknown tuner id:%d" , af9015_af9013_config[adap->id].tuner); } +mutex_unlock (&af9015_fe_mutex);return ret; }
drivers/media/dvb/frontends/af9013.c +8 -1
@@ -50,6 +50,7 @@ struct af9013_state {u16 snr;u32 frequency;unsigned long next_statistics_check; +struct mutex *fe_mutex; };static u8 regmask[8 ] = {0x01 ,0x03 ,0x07 ,0x0f ,0x1f ,0x3f ,0x7f ,0xff };
@@ -630,9 +631,14 @@ static int af9013_set_frontend(struct dvb_frontend *fe, state->frequency = params->frequency;/* program tuner */ +if (mutex_lock_interruptible (state->fe_mutex) <0 ) +return -EAGAIN ; +if (fe->ops.tuner_ops.set_params) fe->ops.tuner_ops.set_params (fe, params); +mutex_unlock (state->fe_mutex); +/* program CFOE coefficients */ ret =af9013_set_coeff (state, params->u.ofdm.bandwidth);if (ret)
@@ -1446,7 +1452,7 @@ static void af9013_release(struct dvb_frontend *fe)static struct dvb_frontend_ops af9013_ops;struct dvb_frontend *af9013_attach (const struct af9013_config *config, -struct i2c_adapter *i2c) +struct i2c_adapter *i2c,struct mutex *fe_mutex) {int ret;struct af9013_state *state =NULL ;
@@ -1459,6 +1465,7 @@ struct dvb_frontend *af9013_attach(const struct af9013_config *config,/* setup the state */ state->i2c = i2c; + state->fe_mutex = fe_mutex;memcpy (&state->config, config,sizeof (struct af9013_config ));/* download firmware */
drivers/media/dvb/frontends/af9013.h +3 -2
@@ -96,10 +96,11 @@ struct af9013_config {#if defined(CONFIG_DVB_AF9013 ) || \ (defined(CONFIG_DVB_AF9013_MODULE ) && defined(MODULE ))extern struct dvb_frontend *af9013_attach (const struct af9013_config *config, -struct i2c_adapter *i2c); +struct i2c_adapter *i2c,struct mutex *fe_mutex);#else static inline struct dvb_frontend *af9013_attach ( -const struct af9013_config *config,struct i2c_adapter *i2c) +const struct af9013_config *config,struct i2c_adapter *i2, +struct mutex *fe_mutex) {printk (KERN_WARNING "%s: driver disabled by Kconfig\n" , __func__);return NULL ;
Signature · 1 line
1.7.5.4
Quoted 6 lines · Malcolm Priestley
Changes from version 1
Remove the bus lock from read status. Causing a lagging effect on some kernels< [2.6.38]This does mean that noisy I2C traffic could be heard on the first frontend when its tuner gate is open.
I think you want add locking for tuner set. But this seems to be now removing it.
* tuner gate is not normally open, it is only open very small period when tuner is programmed, init or sleep.
* I think gate is not reason for I2C errors seen in log
Finally I think, you want lock tuner set. Than is easiest to do locking whole .set_frontend(). I haven't tested it, but testing it have been on my TODO some time.
Antti
Signature · 1 line
http://palosaari.fi/