#include <linux/videodev.h>
#include <linux/delay.h>
#include <media/tuner.h>
+#include <linux/mutex.h>
#include "tuner-driver.h"
#include "tuner-xc2028.h"
were loaded? */
enum tuner_mode mode;
struct i2c_client *i2c_client;
+
+ struct mutex lock;
};
#define i2c_send(rc,c,buf,size) \
static int xc2028_signal(struct i2c_client *c)
{
- int lock, signal;
+ struct tuner *t = i2c_get_clientdata(c);
+ struct xc2028_data *xc2028 = t->priv;
+ int frq_lock, signal=0;
+
+ mutex_lock(&xc2028->lock);
printk(KERN_INFO "xc2028: %s called\n", __FUNCTION__);
- lock = xc2028_get_reg(c, 0x2);
- if (lock<=0)
- return lock;
+ frq_lock = xc2028_get_reg(c, 0x2);
+ if (frq_lock<=0)
+ goto ret;
/* Frequency is locked. Return signal quality */
signal = xc2028_get_reg(c, 0x40);
- if(signal<=0)
- return lock;
+ if(signal<=0) {
+ signal=frq_lock;
+ }
+
+ret:
+ mutex_unlock(&xc2028->lock);
return signal;
}
when freq is changed */
struct xc2028_data *xc2028 = t->priv;
+ mutex_lock(&xc2028->lock);
+
xc2028->firm_type=0;
/* Reset GPIO 1 */
rc = t->tuner_callback( c->adapter->algo_data,
XC2028_TUNER_RESET, 0);
if (rc<0)
- return;
+ goto ret;
}
msleep(10);
printk("xc3028: should set frequency %d kHz)\n", freq / 1000);
if (check_firmware(c, new_mode, bandwidth)<0)
- return;
+ goto ret;
if(new_mode == T_DIGITAL_TV)
offset = 2750000;
rc = t->tuner_callback( c->adapter->algo_data,
XC2028_RESET_CLK, 1);
if (rc<0)
- return;
+ goto ret;
}
msleep(10);
i2c_send(rc, c, buf, sizeof(buf));
if (rc<0)
- return;
+ goto ret;
msleep(100);
printk("divider= %02x %02x %02x %02x (freq=%d.%02d)\n",
buf[1],buf[2],buf[3],buf[4],
freq / 16, freq % 16 * 100 / 16);
+
+ret:
+ mutex_unlock(&xc2028->lock);
}
xc2028->need_load_generic=1;
xc2028->mode = T_UNINITIALIZED;
+ mutex_init(&xc2028->lock);
+
/* FIXME: Check where t->priv will be freed */
if (version<0)
return 0;
}
+
+
EXPORT_SYMBOL(xc2028_attach);