Commit 8edeb6eb authored by istvan_v@mailbox.hu's avatar istvan_v@mailbox.hu Committed by Mauro Carvalho Chehab

[media] xc4000: removed card_type

Removed the use of 'card_type' from the tuner configuration structure, and
replaced it with separate parameters to set board-specific configuration.
Signed-off-by: default avatarIstvan Varga <istvan_v@mailbox.hu>
Cc: Patrick Boettcher <pboettcher@kernellabs.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 09f46342
...@@ -92,14 +92,16 @@ struct xc4000_priv { ...@@ -92,14 +92,16 @@ struct xc4000_priv {
struct list_head hybrid_tuner_instance_list; struct list_head hybrid_tuner_instance_list;
struct firmware_description *firm; struct firmware_description *firm;
int firm_size; int firm_size;
__u16 firm_version;
u32 if_khz; u32 if_khz;
u32 freq_hz; u32 freq_hz;
u32 bandwidth; u32 bandwidth;
u8 video_standard; u8 video_standard;
u8 rf_mode; u8 rf_mode;
u8 card_type; u8 default_pm;
u8 dvb_amplitude;
u8 set_smoothedcvbs;
u8 ignore_i2c_write_errors; u8 ignore_i2c_write_errors;
__u16 firm_version;
struct firmware_properties cur_fw; struct firmware_properties cur_fw;
__u16 hwmodel; __u16 hwmodel;
__u16 hwvers; __u16 hwvers;
...@@ -1226,19 +1228,22 @@ static int xc4000_set_params(struct dvb_frontend *fe, ...@@ -1226,19 +1228,22 @@ static int xc4000_set_params(struct dvb_frontend *fe,
} }
} }
if (priv->card_type == XC4000_CARD_WINFAST_CX88) { if (xc_write_reg(priv, XREG_D_CODE, 0) == 0)
if (xc_write_reg(priv, XREG_D_CODE, 0) == 0) ret = 0;
ret = 0; if (priv->dvb_amplitude != 0) {
if (xc_write_reg(priv, XREG_AMPLITUDE, if (xc_write_reg(priv, XREG_AMPLITUDE,
(priv->firm_version == 0x0102 ? 132 : 134)) (priv->firm_version != 0x0102 ||
!= 0) priv->dvb_amplitude != 134 ?
priv->dvb_amplitude : 132)) != 0)
ret = -EREMOTEIO; ret = -EREMOTEIO;
}
if (priv->set_smoothedcvbs != 0) {
if (xc_write_reg(priv, XREG_SMOOTHEDCVBS, 1) != 0) if (xc_write_reg(priv, XREG_SMOOTHEDCVBS, 1) != 0)
ret = -EREMOTEIO; ret = -EREMOTEIO;
if (ret != 0) { }
printk(KERN_ERR "xc4000: setting registers failed\n"); if (ret != 0) {
/* goto fail; */ printk(KERN_ERR "xc4000: setting registers failed\n");
} /* goto fail; */
} }
xc_tune_channel(priv, priv->freq_hz); xc_tune_channel(priv, priv->freq_hz);
...@@ -1412,8 +1417,7 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe, ...@@ -1412,8 +1417,7 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe,
if (type & NOGD) if (type & NOGD)
video_mode &= 0xFF7F; video_mode &= 0xFF7F;
} else if (priv->video_standard < XC4000_I_PAL_NICAM) { } else if (priv->video_standard < XC4000_I_PAL_NICAM) {
if (priv->card_type == XC4000_CARD_WINFAST_CX88 && if (priv->firm_version == 0x0102)
priv->firm_version == 0x0102)
video_mode &= 0xFEFF; video_mode &= 0xFEFF;
if (audio_std & XC4000_AUDIO_STD_B) if (audio_std & XC4000_AUDIO_STD_B)
video_mode |= 0x0080; video_mode |= 0x0080;
...@@ -1425,17 +1429,17 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe, ...@@ -1425,17 +1429,17 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe,
} }
} }
if (priv->card_type == XC4000_CARD_WINFAST_CX88) { if (xc_write_reg(priv, XREG_D_CODE, 0) == 0)
if (xc_write_reg(priv, XREG_D_CODE, 0) == 0) ret = 0;
ret = 0; if (xc_write_reg(priv, XREG_AMPLITUDE, 1) != 0)
if (xc_write_reg(priv, XREG_AMPLITUDE, 1) != 0) ret = -EREMOTEIO;
ret = -EREMOTEIO; if (priv->set_smoothedcvbs != 0) {
if (xc_write_reg(priv, XREG_SMOOTHEDCVBS, 1) != 0) if (xc_write_reg(priv, XREG_SMOOTHEDCVBS, 1) != 0)
ret = -EREMOTEIO; ret = -EREMOTEIO;
if (ret != 0) { }
printk(KERN_ERR "xc4000: setting registers failed\n"); if (ret != 0) {
goto fail; printk(KERN_ERR "xc4000: setting registers failed\n");
} goto fail;
} }
xc_tune_channel(priv, priv->freq_hz); xc_tune_channel(priv, priv->freq_hz);
...@@ -1516,8 +1520,7 @@ static int xc4000_sleep(struct dvb_frontend *fe) ...@@ -1516,8 +1520,7 @@ static int xc4000_sleep(struct dvb_frontend *fe)
/* Avoid firmware reload on slow devices */ /* Avoid firmware reload on slow devices */
if ((no_poweroff == 2 || if ((no_poweroff == 2 ||
(no_poweroff == 0 && (no_poweroff == 0 && priv->default_pm != 0)) &&
priv->card_type != XC4000_CARD_WINFAST_CX88)) &&
(priv->cur_fw.type & BASE) != 0) { (priv->cur_fw.type & BASE) != 0) {
/* force reset and firmware reload */ /* force reset and firmware reload */
priv->cur_fw.type = XC_POWERED_DOWN; priv->cur_fw.type = XC_POWERED_DOWN;
...@@ -1588,16 +1591,6 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe, ...@@ -1588,16 +1591,6 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe,
int instance; int instance;
u16 id = 0; u16 id = 0;
if (cfg->card_type != XC4000_CARD_GENERIC) {
if (cfg->card_type == XC4000_CARD_WINFAST_CX88) {
cfg->i2c_address = 0x61;
cfg->if_khz = 4560;
} else { /* default to PCTV 340E */
cfg->i2c_address = 0x61;
cfg->if_khz = 5400;
}
}
dprintk(1, "%s(%d-%04x)\n", __func__, dprintk(1, "%s(%d-%04x)\n", __func__,
i2c ? i2c_adapter_id(i2c) : -1, i2c ? i2c_adapter_id(i2c) : -1,
cfg ? cfg->i2c_address : -1); cfg ? cfg->i2c_address : -1);
...@@ -1607,8 +1600,6 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe, ...@@ -1607,8 +1600,6 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe,
instance = hybrid_tuner_request_state(struct xc4000_priv, priv, instance = hybrid_tuner_request_state(struct xc4000_priv, priv,
hybrid_tuner_instance_list, hybrid_tuner_instance_list,
i2c, cfg->i2c_address, "xc4000"); i2c, cfg->i2c_address, "xc4000");
if (cfg->card_type != XC4000_CARD_GENERIC)
priv->card_type = cfg->card_type;
switch (instance) { switch (instance) {
case 0: case 0:
goto fail; goto fail;
...@@ -1616,6 +1607,11 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe, ...@@ -1616,6 +1607,11 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe,
case 1: case 1:
/* new tuner instance */ /* new tuner instance */
priv->bandwidth = BANDWIDTH_6_MHZ; priv->bandwidth = BANDWIDTH_6_MHZ;
/* set default configuration */
priv->if_khz = 4560;
priv->default_pm = 0;
priv->dvb_amplitude = 134;
priv->set_smoothedcvbs = 1;
mutex_init(&priv->lock); mutex_init(&priv->lock);
fe->tuner_priv = priv; fe->tuner_priv = priv;
break; break;
...@@ -1626,10 +1622,11 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe, ...@@ -1626,10 +1622,11 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe,
} }
if (cfg->if_khz != 0) { if (cfg->if_khz != 0) {
/* If the IF hasn't been set yet, use the value provided by /* copy configuration if provided by the caller */
the caller (occurs in hybrid devices where the analog
call to xc4000_attach occurs before the digital side) */
priv->if_khz = cfg->if_khz; priv->if_khz = cfg->if_khz;
priv->default_pm = cfg->default_pm;
priv->dvb_amplitude = cfg->dvb_amplitude;
priv->set_smoothedcvbs = cfg->set_smoothedcvbs;
} }
/* Check if firmware has been loaded. It is possible that another /* Check if firmware has been loaded. It is possible that another
......
...@@ -27,13 +27,15 @@ ...@@ -27,13 +27,15 @@
struct dvb_frontend; struct dvb_frontend;
struct i2c_adapter; struct i2c_adapter;
#define XC4000_CARD_GENERIC 0
#define XC4000_CARD_PCTV_340E 1
#define XC4000_CARD_WINFAST_CX88 2
struct xc4000_config { struct xc4000_config {
u8 card_type; /* if card type is not generic, all other */ u8 i2c_address;
u8 i2c_address; /* parameters are automatically set */ /* if non-zero, power management is enabled by default */
u8 default_pm;
/* value to be written to XREG_AMPLITUDE in DVB-T mode (0: no write) */
u8 dvb_amplitude;
/* if non-zero, register 0x0E is set to filter analog TV video output */
u8 set_smoothedcvbs;
/* IF for DVB-T */
u32 if_khz; u32 if_khz;
}; };
......
...@@ -2778,10 +2778,12 @@ static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap) ...@@ -2778,10 +2778,12 @@ static int pctv340e_frontend_attach(struct dvb_usb_adapter *adap)
return adap->fe == NULL ? -ENODEV : 0; return adap->fe == NULL ? -ENODEV : 0;
} }
static struct xc4000_config dib7000p_xc4000_tunerconfig = { static struct xc4000_config dib7000p_xc4000_tunerconfig = {
.i2c_address = 0x61, .i2c_address = 0x61,
.if_khz = 5400, .default_pm = 1,
.dvb_amplitude = 0,
.set_smoothedcvbs = 0,
.if_khz = 5400
}; };
static int xc4000_tuner_attach(struct dvb_usb_adapter *adap) static int xc4000_tuner_attach(struct dvb_usb_adapter *adap)
......
...@@ -396,8 +396,12 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -396,8 +396,12 @@ static void set_type(struct i2c_client *c, unsigned int type,
{ {
struct xc4000_config xc4000_cfg = { struct xc4000_config xc4000_cfg = {
.i2c_address = t->i2c->addr, .i2c_address = t->i2c->addr,
/* if_khz will be set when the digital dvb_attach() occurs */ /* FIXME: the correct parameters will be set */
.if_khz = 0, /* only when the digital dvb_attach() occurs */
.default_pm = 0,
.dvb_amplitude = 0,
.set_smoothedcvbs = 0,
.if_khz = 0
}; };
if (!dvb_attach(xc4000_attach, if (!dvb_attach(xc4000_attach,
&t->fe, t->i2c->adapter, &xc4000_cfg)) &t->fe, t->i2c->adapter, &xc4000_cfg))
......
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