Loading drivers/media/video/tuner-xc2028.c +168 −179 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ #include <linux/i2c.h> #include <asm/div64.h> #include <linux/firmware.h> #include <linux/videodev.h> #include <linux/videodev2.h> #include <linux/delay.h> #include <media/tuner.h> #include <linux/mutex.h> Loading Loading @@ -65,18 +65,22 @@ struct xc2028_data { struct mutex lock; }; #define i2c_send(rc, priv, buf, size) \ if (size != (rc = tuner_i2c_xfer_send(&priv->i2c_props, buf, size))) \ #define i2c_send(rc, priv, buf, size) do { \ rc = tuner_i2c_xfer_send(&priv->i2c_props, buf, size); \ if (size != rc) \ tuner_info("i2c output error: rc = %d (should be %d)\n",\ rc, (int)size); rc, (int)size); \ } while (0) #define i2c_rcv(rc, priv, buf, size) \ if (size != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size))) \ #define i2c_rcv(rc, priv, buf, size) do { \ rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size); \ if (size != rc) \ tuner_info("i2c input error: rc = %d (should be %d)\n", \ rc, (int)size); rc, (int)size); \ } while (0) #define send_seq(priv, data...) \ { int rc; \ #define send_seq(priv, data...) do { \ int rc; \ static u8 _val[] = data; \ if (sizeof(_val) != \ (rc = tuner_i2c_xfer_send(&priv->i2c_props, \ Loading @@ -85,7 +89,7 @@ if (size != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size))) \ return -EINVAL; \ } \ msleep(10); \ } } while (0) static int xc2028_get_reg(struct xc2028_data *priv, u16 reg) { Loading Loading @@ -114,10 +118,9 @@ static void free_firmware (struct xc2028_data *priv) if (!priv->firm) return; for (i=0;i<priv->firm_size;i++) { if (priv->firm[i].ptr) for (i = 0; i < priv->firm_size; i++) kfree(priv->firm[i].ptr); } kfree(priv->firm); priv->firm = NULL; Loading @@ -129,7 +132,8 @@ static int load_all_firmwares (struct dvb_frontend *fe) struct xc2028_data *priv = fe->tuner_priv; const struct firmware *fw = NULL; unsigned char *p, *endp; int rc=0, n, n_array; int rc = 0; int n, n_array; char name[33]; tuner_info("%s called\n", __FUNCTION__); Loading Loading @@ -273,8 +277,7 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, /* Seek for exact match */ for (i = 0; i < priv->firm_size; i++) { if ( (type == priv->firm[i].type) && (*id == priv->firm[i].id)) if ((type == priv->firm[i].type) && (*id == priv->firm[i].id)) goto found; } Loading @@ -292,8 +295,7 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, found: *id = priv->firm[i].id; tuner_info ("Found firmware for type=%x, id=%lx\n", type, (long int)*id); tuner_info("Found firmware for type=%x, id=%lx\n", type, (long int)*id); p = priv->firm[i].ptr; Loading @@ -312,7 +314,6 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, return -EINVAL; } size = le16_to_cpu(*(__u16 *) p); p += sizeof(size); Loading Loading @@ -349,7 +350,8 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, /* Sends message chunks */ while (size > 0) { int len = (size<priv->max_len-1)?size:priv->max_len-1; int len = (size < priv->max_len - 1) ? size : priv->max_len - 1; memcpy(buf + 1, p, len); Loading @@ -367,8 +369,7 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, } static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode, v4l2_std_id std, fe_bandwidth_t bandwidth) v4l2_std_id std, fe_bandwidth_t bandwidth) { struct xc2028_data *priv = fe->tuner_priv; int rc, version; Loading Loading @@ -427,13 +428,11 @@ static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode, priv->need_load_generic = 0; priv->firm_type = 0; if(priv->mode == T_DIGITAL_TV) { if (priv->mode == T_DIGITAL_TV) change_digital_bandwidth = 1; } } tuner_info("I should change bandwidth %u\n", change_digital_bandwidth); tuner_info("I should change bandwidth %u\n", change_digital_bandwidth); if (change_digital_bandwidth) { Loading Loading @@ -513,9 +512,8 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) signal = xc2028_get_reg(priv, 0x40); if(signal<=0) { if (signal <= 0) signal = frq_lock; } ret: mutex_unlock(&priv->lock); Loading @@ -529,8 +527,7 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) static int generic_set_tv_freq(struct dvb_frontend *fe, u32 freq /* in Hz */ , enum tuner_mode new_mode, v4l2_std_id std, fe_bandwidth_t bandwidth) v4l2_std_id std, fe_bandwidth_t bandwidth) { struct xc2028_data *priv = fe->tuner_priv; int rc = -EINVAL; Loading Loading @@ -609,8 +606,7 @@ static int xc2028_set_tv_freq(struct dvb_frontend *fe, tuner_info("%s called\n", __FUNCTION__); return generic_set_tv_freq(fe, 62500l * p->frequency, T_ANALOG_TV, p->std, BANDWIDTH_8_MHZ /* NOT USED */); p->std, BANDWIDTH_8_MHZ /* NOT USED */); } static int xc2028_set_params(struct dvb_frontend *fe, Loading @@ -627,7 +623,7 @@ static int xc2028_set_params(struct dvb_frontend *fe, } return generic_set_tv_freq(fe, p->frequency, T_DIGITAL_TV, 0, /* NOT USED */ 0 /* NOT USED */, p->u.ofdm.bandwidth); } Loading @@ -643,7 +639,6 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) if (!priv->count) { list_del(&priv->xc2028_list); if (priv->ctrl.fname) kfree(priv->ctrl.fname); free_firmware(priv); Loading Loading @@ -674,7 +669,6 @@ static int xc2028_set_config (struct dvb_frontend *fe, void *priv_cfg) priv->ctrl.type = p->type; if (p->fname) { if (priv->ctrl.fname) kfree(priv->ctrl.fname); priv->ctrl.fname = kmalloc(strlen(p->fname) + 1, GFP_KERNEL); Loading Loading @@ -708,9 +702,6 @@ static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = { .get_rf_strength = xc2028_signal, .set_params = xc2028_set_params, // int (*sleep)(struct dvb_frontend *fe); // int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth); // int (*get_status)(struct dvb_frontend *fe, u32 *status); }; int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, Loading @@ -733,10 +724,9 @@ int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap, } list_for_each_entry(priv, &xc2028_list, xc2028_list) { if (priv->dev == dev) { if (priv->dev == dev) dev = NULL; } } if (dev) { priv = kzalloc(sizeof(*priv), GFP_KERNEL); Loading Loading @@ -769,7 +759,6 @@ int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap, return 0; } EXPORT_SYMBOL(xc2028_attach); MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver"); Loading drivers/media/video/tuner-xc2028.h +7 −5 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap, #else static inline int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, u8 i2c_addr, struct device *dev, void *video_dev, int (*tuner_callback) (void *dev, int command,int arg)) u8 i2c_addr, struct device *dev, void *video_dev, int (*tuner_callback) (void *dev, int command, int arg)) { printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", __FUNCTION__); Loading Loading
drivers/media/video/tuner-xc2028.c +168 −179 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ #include <linux/i2c.h> #include <asm/div64.h> #include <linux/firmware.h> #include <linux/videodev.h> #include <linux/videodev2.h> #include <linux/delay.h> #include <media/tuner.h> #include <linux/mutex.h> Loading Loading @@ -65,18 +65,22 @@ struct xc2028_data { struct mutex lock; }; #define i2c_send(rc, priv, buf, size) \ if (size != (rc = tuner_i2c_xfer_send(&priv->i2c_props, buf, size))) \ #define i2c_send(rc, priv, buf, size) do { \ rc = tuner_i2c_xfer_send(&priv->i2c_props, buf, size); \ if (size != rc) \ tuner_info("i2c output error: rc = %d (should be %d)\n",\ rc, (int)size); rc, (int)size); \ } while (0) #define i2c_rcv(rc, priv, buf, size) \ if (size != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size))) \ #define i2c_rcv(rc, priv, buf, size) do { \ rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size); \ if (size != rc) \ tuner_info("i2c input error: rc = %d (should be %d)\n", \ rc, (int)size); rc, (int)size); \ } while (0) #define send_seq(priv, data...) \ { int rc; \ #define send_seq(priv, data...) do { \ int rc; \ static u8 _val[] = data; \ if (sizeof(_val) != \ (rc = tuner_i2c_xfer_send(&priv->i2c_props, \ Loading @@ -85,7 +89,7 @@ if (size != (rc = tuner_i2c_xfer_recv(&priv->i2c_props, buf, size))) \ return -EINVAL; \ } \ msleep(10); \ } } while (0) static int xc2028_get_reg(struct xc2028_data *priv, u16 reg) { Loading Loading @@ -114,10 +118,9 @@ static void free_firmware (struct xc2028_data *priv) if (!priv->firm) return; for (i=0;i<priv->firm_size;i++) { if (priv->firm[i].ptr) for (i = 0; i < priv->firm_size; i++) kfree(priv->firm[i].ptr); } kfree(priv->firm); priv->firm = NULL; Loading @@ -129,7 +132,8 @@ static int load_all_firmwares (struct dvb_frontend *fe) struct xc2028_data *priv = fe->tuner_priv; const struct firmware *fw = NULL; unsigned char *p, *endp; int rc=0, n, n_array; int rc = 0; int n, n_array; char name[33]; tuner_info("%s called\n", __FUNCTION__); Loading Loading @@ -273,8 +277,7 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, /* Seek for exact match */ for (i = 0; i < priv->firm_size; i++) { if ( (type == priv->firm[i].type) && (*id == priv->firm[i].id)) if ((type == priv->firm[i].type) && (*id == priv->firm[i].id)) goto found; } Loading @@ -292,8 +295,7 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, found: *id = priv->firm[i].id; tuner_info ("Found firmware for type=%x, id=%lx\n", type, (long int)*id); tuner_info("Found firmware for type=%x, id=%lx\n", type, (long int)*id); p = priv->firm[i].ptr; Loading @@ -312,7 +314,6 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, return -EINVAL; } size = le16_to_cpu(*(__u16 *) p); p += sizeof(size); Loading Loading @@ -349,7 +350,8 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, /* Sends message chunks */ while (size > 0) { int len = (size<priv->max_len-1)?size:priv->max_len-1; int len = (size < priv->max_len - 1) ? size : priv->max_len - 1; memcpy(buf + 1, p, len); Loading @@ -367,8 +369,7 @@ static int load_firmware (struct dvb_frontend *fe, unsigned int type, } static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode, v4l2_std_id std, fe_bandwidth_t bandwidth) v4l2_std_id std, fe_bandwidth_t bandwidth) { struct xc2028_data *priv = fe->tuner_priv; int rc, version; Loading Loading @@ -427,13 +428,11 @@ static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode, priv->need_load_generic = 0; priv->firm_type = 0; if(priv->mode == T_DIGITAL_TV) { if (priv->mode == T_DIGITAL_TV) change_digital_bandwidth = 1; } } tuner_info("I should change bandwidth %u\n", change_digital_bandwidth); tuner_info("I should change bandwidth %u\n", change_digital_bandwidth); if (change_digital_bandwidth) { Loading Loading @@ -513,9 +512,8 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) signal = xc2028_get_reg(priv, 0x40); if(signal<=0) { if (signal <= 0) signal = frq_lock; } ret: mutex_unlock(&priv->lock); Loading @@ -529,8 +527,7 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) static int generic_set_tv_freq(struct dvb_frontend *fe, u32 freq /* in Hz */ , enum tuner_mode new_mode, v4l2_std_id std, fe_bandwidth_t bandwidth) v4l2_std_id std, fe_bandwidth_t bandwidth) { struct xc2028_data *priv = fe->tuner_priv; int rc = -EINVAL; Loading Loading @@ -609,8 +606,7 @@ static int xc2028_set_tv_freq(struct dvb_frontend *fe, tuner_info("%s called\n", __FUNCTION__); return generic_set_tv_freq(fe, 62500l * p->frequency, T_ANALOG_TV, p->std, BANDWIDTH_8_MHZ /* NOT USED */); p->std, BANDWIDTH_8_MHZ /* NOT USED */); } static int xc2028_set_params(struct dvb_frontend *fe, Loading @@ -627,7 +623,7 @@ static int xc2028_set_params(struct dvb_frontend *fe, } return generic_set_tv_freq(fe, p->frequency, T_DIGITAL_TV, 0, /* NOT USED */ 0 /* NOT USED */, p->u.ofdm.bandwidth); } Loading @@ -643,7 +639,6 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) if (!priv->count) { list_del(&priv->xc2028_list); if (priv->ctrl.fname) kfree(priv->ctrl.fname); free_firmware(priv); Loading Loading @@ -674,7 +669,6 @@ static int xc2028_set_config (struct dvb_frontend *fe, void *priv_cfg) priv->ctrl.type = p->type; if (p->fname) { if (priv->ctrl.fname) kfree(priv->ctrl.fname); priv->ctrl.fname = kmalloc(strlen(p->fname) + 1, GFP_KERNEL); Loading Loading @@ -708,9 +702,6 @@ static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = { .get_rf_strength = xc2028_signal, .set_params = xc2028_set_params, // int (*sleep)(struct dvb_frontend *fe); // int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth); // int (*get_status)(struct dvb_frontend *fe, u32 *status); }; int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, Loading @@ -733,10 +724,9 @@ int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap, } list_for_each_entry(priv, &xc2028_list, xc2028_list) { if (priv->dev == dev) { if (priv->dev == dev) dev = NULL; } } if (dev) { priv = kzalloc(sizeof(*priv), GFP_KERNEL); Loading Loading @@ -769,7 +759,6 @@ int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap, return 0; } EXPORT_SYMBOL(xc2028_attach); MODULE_DESCRIPTION("Xceive xc2028/xc3028 tuner driver"); Loading
drivers/media/video/tuner-xc2028.h +7 −5 Original line number Diff line number Diff line Loading @@ -34,8 +34,10 @@ int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter* i2c_adap, #else static inline int xc2028_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c_adap, u8 i2c_addr, struct device *dev, void *video_dev, int (*tuner_callback) (void *dev, int command,int arg)) u8 i2c_addr, struct device *dev, void *video_dev, int (*tuner_callback) (void *dev, int command, int arg)) { printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", __FUNCTION__); Loading