Commit ab166050 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (6785): tda8290: remove dependency on struct tuner

- remove dependency of tda8290 module on struct tuner
- move tuner_foo printk macros from tuner-driver.h into tuner-core.c
- clean up #includes of tuner-i2c.h / tuner-driver.h
Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent fa746aee
...@@ -23,12 +23,14 @@ ...@@ -23,12 +23,14 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/videodev.h> #include <linux/videodev.h>
#include "tuner-driver.h"
#include "tuner-i2c.h"
#include "tda8290.h" #include "tda8290.h"
#include "tda827x.h" #include "tda827x.h"
#include "tda18271.h" #include "tda18271.h"
static int tuner_debug; static int debug;
module_param_named(debug, tuner_debug, int, 0644); module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "enable verbose debug messages"); MODULE_PARM_DESC(debug, "enable verbose debug messages");
#define PREFIX "tda8290" #define PREFIX "tda8290"
...@@ -50,8 +52,6 @@ struct tda8290_priv { ...@@ -50,8 +52,6 @@ struct tda8290_priv {
#define TDA18271 16 #define TDA18271 16
struct tda827x_config cfg; struct tda827x_config cfg;
struct tuner *t;
}; };
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
...@@ -114,7 +114,6 @@ static void set_audio(struct dvb_frontend *fe, ...@@ -114,7 +114,6 @@ static void set_audio(struct dvb_frontend *fe,
struct analog_parameters *params) struct analog_parameters *params)
{ {
struct tda8290_priv *priv = fe->analog_demod_priv; struct tda8290_priv *priv = fe->analog_demod_priv;
struct tuner *t = priv->t;
char* mode; char* mode;
if (params->std & V4L2_STD_MN) { if (params->std & V4L2_STD_MN) {
...@@ -150,7 +149,6 @@ static void tda8290_set_params(struct dvb_frontend *fe, ...@@ -150,7 +149,6 @@ static void tda8290_set_params(struct dvb_frontend *fe,
struct analog_parameters *params) struct analog_parameters *params)
{ {
struct tda8290_priv *priv = fe->analog_demod_priv; struct tda8290_priv *priv = fe->analog_demod_priv;
struct tuner *t = priv->t;
unsigned char soft_reset[] = { 0x00, 0x00 }; unsigned char soft_reset[] = { 0x00, 0x00 };
unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode }; unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode };
...@@ -176,7 +174,8 @@ static void tda8290_set_params(struct dvb_frontend *fe, ...@@ -176,7 +174,8 @@ static void tda8290_set_params(struct dvb_frontend *fe,
set_audio(fe, params); set_audio(fe, params);
tuner_dbg("tda827xa config is 0x%02x\n", t->config); if (priv->cfg.config)
tuner_dbg("tda827xa config is 0x%02x\n", *priv->cfg.config);
tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2);
tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2); tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2);
tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2); tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2);
...@@ -362,7 +361,6 @@ static void tda8295_set_params(struct dvb_frontend *fe, ...@@ -362,7 +361,6 @@ static void tda8295_set_params(struct dvb_frontend *fe,
struct analog_parameters *params) struct analog_parameters *params)
{ {
struct tda8290_priv *priv = fe->analog_demod_priv; struct tda8290_priv *priv = fe->analog_demod_priv;
struct tuner *t = priv->t;
unsigned char blanking_mode[] = { 0x1d, 0x00 }; unsigned char blanking_mode[] = { 0x1d, 0x00 };
...@@ -442,13 +440,13 @@ static void tda8295_standby(struct dvb_frontend *fe) ...@@ -442,13 +440,13 @@ static void tda8295_standby(struct dvb_frontend *fe)
static void tda8290_init_if(struct dvb_frontend *fe) static void tda8290_init_if(struct dvb_frontend *fe)
{ {
struct tda8290_priv *priv = fe->analog_demod_priv; struct tda8290_priv *priv = fe->analog_demod_priv;
struct tuner *t = priv->t;
unsigned char set_VS[] = { 0x30, 0x6F }; unsigned char set_VS[] = { 0x30, 0x6F };
unsigned char set_GP00_CF[] = { 0x20, 0x01 }; unsigned char set_GP00_CF[] = { 0x20, 0x01 };
unsigned char set_GP01_CF[] = { 0x20, 0x0B }; unsigned char set_GP01_CF[] = { 0x20, 0x0B };
if ((t->config == 1) || (t->config == 2)) if ((priv->cfg.config) &&
((*priv->cfg.config == 1) || (*priv->cfg.config == 2)))
tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2); tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2);
else else
tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2); tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2);
...@@ -516,7 +514,6 @@ static int tda829x_find_tuner(struct dvb_frontend *fe) ...@@ -516,7 +514,6 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
{ {
struct tda8290_priv *priv = fe->analog_demod_priv; struct tda8290_priv *priv = fe->analog_demod_priv;
struct analog_tuner_ops *ops = fe->ops.analog_demod_ops; struct analog_tuner_ops *ops = fe->ops.analog_demod_ops;
struct tuner *t = priv->t;
int i, ret, tuners_found; int i, ret, tuners_found;
u32 tuner_addrs; u32 tuner_addrs;
u8 data; u8 data;
...@@ -595,29 +592,6 @@ static int tda829x_find_tuner(struct dvb_frontend *fe) ...@@ -595,29 +592,6 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
ops->i2c_gate_ctrl(fe, 0); ops->i2c_gate_ctrl(fe, 0);
switch (priv->ver) {
case TDA8290 | TDA8275:
strlcpy(t->i2c->name, "tda8290+75", sizeof(t->i2c->name));
break;
case TDA8295 | TDA8275:
strlcpy(t->i2c->name, "tda8295+75", sizeof(t->i2c->name));
break;
case TDA8290 | TDA8275A:
strlcpy(t->i2c->name, "tda8290+75a", sizeof(t->i2c->name));
break;
case TDA8295 | TDA8275A:
strlcpy(t->i2c->name, "tda8295+75a", sizeof(t->i2c->name));
break;
case TDA8290 | TDA18271:
strlcpy(t->i2c->name, "tda8290+18271", sizeof(t->i2c->name));
break;
case TDA8295 | TDA18271:
strlcpy(t->i2c->name, "tda8295+18271", sizeof(t->i2c->name));
break;
default:
return -EINVAL;
}
return 0; return 0;
} }
...@@ -631,7 +605,7 @@ static int tda8290_probe(struct tuner_i2c_props *i2c_props) ...@@ -631,7 +605,7 @@ static int tda8290_probe(struct tuner_i2c_props *i2c_props)
tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1); tuner_i2c_xfer_recv(i2c_props, &tda8290_id[1], 1);
if (tda8290_id[1] == TDA8290_ID) { if (tda8290_id[1] == TDA8290_ID) {
if (tuner_debug) if (debug)
printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n", printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n",
__FUNCTION__, i2c_adapter_id(i2c_props->adap), __FUNCTION__, i2c_adapter_id(i2c_props->adap),
i2c_props->addr); i2c_props->addr);
...@@ -651,7 +625,7 @@ static int tda8295_probe(struct tuner_i2c_props *i2c_props) ...@@ -651,7 +625,7 @@ static int tda8295_probe(struct tuner_i2c_props *i2c_props)
tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1); tuner_i2c_xfer_recv(i2c_props, &tda8295_id[1], 1);
if (tda8295_id[1] == TDA8295_ID) { if (tda8295_id[1] == TDA8295_ID) {
if (tuner_debug) if (debug)
printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n", printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n",
__FUNCTION__, i2c_adapter_id(i2c_props->adap), __FUNCTION__, i2c_adapter_id(i2c_props->adap),
i2c_props->addr); i2c_props->addr);
...@@ -677,21 +651,24 @@ static struct analog_tuner_ops tda8295_tuner_ops = { ...@@ -677,21 +651,24 @@ static struct analog_tuner_ops tda8295_tuner_ops = {
.i2c_gate_ctrl = tda8295_i2c_bridge, .i2c_gate_ctrl = tda8295_i2c_bridge,
}; };
int tda829x_attach(struct tuner *t) struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
struct i2c_adapter *i2c_adap, u8 i2c_addr,
struct tda829x_config *cfg)
{ {
struct dvb_frontend *fe = &t->fe;
struct tda8290_priv *priv = NULL; struct tda8290_priv *priv = NULL;
char *name;
priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL); priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
if (priv == NULL) if (priv == NULL)
return -ENOMEM; return NULL;
fe->analog_demod_priv = priv; fe->analog_demod_priv = priv;
priv->i2c_props.addr = t->i2c->addr; priv->i2c_props.addr = i2c_addr;
priv->i2c_props.adap = t->i2c->adapter; priv->i2c_props.adap = i2c_adap;
priv->cfg.config = &t->config; if (cfg) {
priv->cfg.tuner_callback = t->tuner_callback; priv->cfg.config = cfg->lna_cfg;
priv->t = t; priv->cfg.tuner_callback = cfg->tuner_callback;
}
if (tda8290_probe(&priv->i2c_props) == 0) { if (tda8290_probe(&priv->i2c_props) == 0) {
priv->ver = TDA8290; priv->ver = TDA8290;
...@@ -706,30 +683,50 @@ int tda829x_attach(struct tuner *t) ...@@ -706,30 +683,50 @@ int tda829x_attach(struct tuner *t)
if (tda829x_find_tuner(fe) < 0) if (tda829x_find_tuner(fe) < 0)
goto fail; goto fail;
switch (priv->ver) {
case TDA8290 | TDA8275:
name = "tda8290+75";
break;
case TDA8295 | TDA8275:
name = "tda8295+75";
break;
case TDA8290 | TDA8275A:
name = "tda8290+75a";
break;
case TDA8295 | TDA8275A:
name = "tda8295+75a";
break;
case TDA8290 | TDA18271:
name = "tda8290+18271";
break;
case TDA8295 | TDA18271:
name = "tda8295+18271";
break;
default:
goto fail;
}
tuner_info("type set to %s\n", name);
if (priv->ver & TDA8290) { if (priv->ver & TDA8290) {
tda8290_init_tuner(fe); tda8290_init_tuner(fe);
tda8290_init_if(fe); tda8290_init_if(fe);
} else if (priv->ver & TDA8295) } else if (priv->ver & TDA8295)
tda8295_init_if(fe); tda8295_init_if(fe);
tuner_info("type set to %s\n", t->i2c->name); return fe;
t->mode = V4L2_TUNER_ANALOG_TV;
return 0;
fail: fail:
tda829x_release(fe); tda829x_release(fe);
fe->ops.analog_demod_ops = NULL; fe->ops.analog_demod_ops = NULL;
return -EINVAL; return NULL;
} }
EXPORT_SYMBOL_GPL(tda829x_attach); EXPORT_SYMBOL_GPL(tda829x_attach);
int tda829x_probe(struct tuner *t) int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr)
{ {
struct tuner_i2c_props i2c_props = { struct tuner_i2c_props i2c_props = {
.adap = t->i2c->adapter, .adap = i2c_adap,
.addr = t->i2c->addr .addr = i2c_addr,
}; };
unsigned char soft_reset[] = { 0x00, 0x00 }; unsigned char soft_reset[] = { 0x00, 0x00 };
......
...@@ -18,24 +18,36 @@ ...@@ -18,24 +18,36 @@
#define __TDA8290_H__ #define __TDA8290_H__
#include <linux/i2c.h> #include <linux/i2c.h>
#include "tuner-driver.h" #include "dvb_frontend.h"
struct tda829x_config
{
unsigned int *lna_cfg;
int (*tuner_callback) (void *dev, int command, int arg);
};
#if defined(CONFIG_TUNER_TDA8290) || (defined(CONFIG_TUNER_TDA8290_MODULE) && defined(MODULE)) #if defined(CONFIG_TUNER_TDA8290) || (defined(CONFIG_TUNER_TDA8290_MODULE) && defined(MODULE))
extern int tda829x_probe(struct tuner *t); extern int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr);
extern int tda829x_attach(struct tuner *t); extern struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
struct i2c_adapter *i2c_adap,
u8 i2c_addr,
struct tda829x_config *cfg);
#else #else
static inline int tda829x_probe(struct tuner *t) static inline int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr)
{ {
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
return -EINVAL; return -EINVAL;
} }
static inline int tda829x_attach(struct tuner *t) static inline struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
struct i2c_adapter *i2c_adap,
u8 i2c_addr,
struct tda829x_config *cfg)
{ {
printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n",
__FUNCTION__); __FUNCTION__);
return -EINVAL; return NULL;
} }
#endif #endif
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/videodev.h> #include <linux/videodev.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/tuner.h> #include <media/tuner.h>
#include "tuner-i2c.h"
#include "tda9887.h" #include "tda9887.h"
......
...@@ -52,7 +52,34 @@ static unsigned int no_autodetect = 0; ...@@ -52,7 +52,34 @@ static unsigned int no_autodetect = 0;
static unsigned int show_i2c = 0; static unsigned int show_i2c = 0;
/* insmod options used at runtime => read/write */ /* insmod options used at runtime => read/write */
int tuner_debug = 0; static int tuner_debug;
#define tuner_warn(fmt, arg...) do { \
printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), \
t->i2c->addr, ##arg); \
} while (0)
#define tuner_info(fmt, arg...) do { \
printk(KERN_INFO "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), \
t->i2c->addr, ##arg); \
} while (0)
#define tuner_err(fmt, arg...) do { \
printk(KERN_ERR "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), \
t->i2c->addr, ##arg); \
} while (0)
#define tuner_dbg(fmt, arg...) do { \
if (tuner_debug) \
printk(KERN_DEBUG "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), \
t->i2c->addr, ##arg); \
} while (0)
/* ------------------------------------------------------------------------ */
static unsigned int tv_range[2] = { 44, 958 }; static unsigned int tv_range[2] = { 44, 958 };
static unsigned int radio_range[2] = { 65, 108 }; static unsigned int radio_range[2] = { 65, 108 };
...@@ -261,6 +288,15 @@ static void attach_simple_tuner(struct tuner *t) ...@@ -261,6 +288,15 @@ static void attach_simple_tuner(struct tuner *t)
simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg); simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg);
} }
static void attach_tda829x(struct tuner *t)
{
struct tda829x_config cfg = {
.lna_cfg = &t->config,
.tuner_callback = t->tuner_callback,
};
tda829x_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg);
}
static void set_type(struct i2c_client *c, unsigned int type, static void set_type(struct i2c_client *c, unsigned int type,
unsigned int new_mode_mask, unsigned int new_config, unsigned int new_mode_mask, unsigned int new_config,
int (*tuner_callback) (void *dev, int command,int arg)) int (*tuner_callback) (void *dev, int command,int arg))
...@@ -303,7 +339,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -303,7 +339,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
break; break;
case TUNER_PHILIPS_TDA8290: case TUNER_PHILIPS_TDA8290:
{ {
tda829x_attach(t); attach_tda829x(t);
break; break;
} }
case TUNER_TEA5767: case TUNER_TEA5767:
...@@ -1045,7 +1081,8 @@ static int tuner_probe(struct i2c_client *client) ...@@ -1045,7 +1081,8 @@ static int tuner_probe(struct i2c_client *client)
case 0x4b: case 0x4b:
/* If chip is not tda8290, don't register. /* If chip is not tda8290, don't register.
since it can be tda9887*/ since it can be tda9887*/
if (tda829x_probe(t) == 0) { if (tda829x_probe(t->i2c->adapter,
t->i2c->addr) == 0) {
tuner_dbg("tda829x detected\n"); tuner_dbg("tda829x detected\n");
} else { } else {
/* Default is being tda9887 */ /* Default is being tda9887 */
......
...@@ -24,13 +24,10 @@ ...@@ -24,13 +24,10 @@
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include "tuner-i2c.h"
#include "dvb_frontend.h" #include "dvb_frontend.h"
extern unsigned const int tuner_count; extern unsigned const int tuner_count;
struct tuner;
struct analog_tuner_ops { struct analog_tuner_ops {
void (*set_params)(struct dvb_frontend *fe, void (*set_params)(struct dvb_frontend *fe,
struct analog_parameters *params); struct analog_parameters *params);
...@@ -69,28 +66,4 @@ struct tuner { ...@@ -69,28 +66,4 @@ struct tuner {
int (*tuner_callback) (void *dev, int command,int arg); int (*tuner_callback) (void *dev, int command,int arg);
}; };
/* ------------------------------------------------------------------------ */
#define tuner_warn(fmt, arg...) do { \
printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), t->i2c->addr, ##arg); \
} while (0)
#define tuner_info(fmt, arg...) do { \
printk(KERN_INFO "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); \
} while (0)
#define tuner_err(fmt, arg...) do { \
printk(KERN_ERR "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); \
} while (0)
#define tuner_dbg(fmt, arg...) do { \
extern int tuner_debug; \
if (tuner_debug) \
printk(KERN_DEBUG "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); \
} while (0)
#endif /* __TUNER_DRIVER_H__ */ #endif /* __TUNER_DRIVER_H__ */
...@@ -59,7 +59,6 @@ static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props, ...@@ -59,7 +59,6 @@ static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
return (ret == 2) ? ilen : ret; return (ret == 2) ? ilen : ret;
} }
#ifndef __TUNER_DRIVER_H__
#define tuner_warn(fmt, arg...) do { \ #define tuner_warn(fmt, arg...) do { \
printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \ printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \
i2c_adapter_id(priv->i2c_props.adap), \ i2c_adapter_id(priv->i2c_props.adap), \
...@@ -84,6 +83,5 @@ static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props, ...@@ -84,6 +83,5 @@ static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
i2c_adapter_id(priv->i2c_props.adap), \ i2c_adapter_id(priv->i2c_props.adap), \
priv->i2c_props.addr , ##arg); \ priv->i2c_props.addr , ##arg); \
} while (0) } while (0)
#endif /* __TUNER_DRIVER_H__ */
#endif /* __TUNER_I2C_H__ */ #endif /* __TUNER_I2C_H__ */
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
#include <linux/videodev2.h> #include <linux/videodev2.h>
extern int tuner_debug;
#define ADDR_UNSET (255) #define ADDR_UNSET (255)
#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ #define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment