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

[media] xc5000: drivers should specify chip revision rather than firmware

Specify chip revision at attach time rather than a firmware image.
This is a better way to ensure that the correct firmware is loaded
for the correct revision of the chip.
Signed-off-by: default avatarMichael Krufky <mkrufky@kernellabs.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent ddea427f
...@@ -60,7 +60,7 @@ struct xc5000_priv { ...@@ -60,7 +60,7 @@ struct xc5000_priv {
u8 rf_mode; u8 rf_mode;
u8 radio_input; u8 radio_input;
struct xc5000_fw_cfg *fw; int chip_id;
}; };
/* Misc Defines */ /* Misc Defines */
...@@ -219,13 +219,13 @@ static struct xc5000_fw_cfg xc5000c_41_024_5_31875 = { ...@@ -219,13 +219,13 @@ static struct xc5000_fw_cfg xc5000c_41_024_5_31875 = {
.size = 16503, .size = 16503,
}; };
static inline struct xc5000_fw_cfg *xc5000_assign_firmware(int fw) static inline struct xc5000_fw_cfg *xc5000_assign_firmware(int chip_id)
{ {
switch (fw) { switch (chip_id) {
default: default:
case XC5000_FW_A_1_6_114: case XC5000A:
return &xc5000a_1_6_114; return &xc5000a_1_6_114;
case XC5000_FW_C_41_024_5_31875: case XC5000C:
return &xc5000c_41_024_5_31875; return &xc5000c_41_024_5_31875;
} }
} }
...@@ -578,12 +578,13 @@ static int xc5000_fwupload(struct dvb_frontend *fe) ...@@ -578,12 +578,13 @@ static int xc5000_fwupload(struct dvb_frontend *fe)
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
const struct firmware *fw; const struct firmware *fw;
int ret; int ret;
struct xc5000_fw_cfg *desired_fw = xc5000_assign_firmware(priv->chip_id);
/* request the firmware, this will block and timeout */ /* request the firmware, this will block and timeout */
printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n",
priv->fw->name); desired_fw->name);
ret = request_firmware(&fw, priv->fw->name, ret = request_firmware(&fw, desired_fw->name,
priv->i2c_props.adap->dev.parent); priv->i2c_props.adap->dev.parent);
if (ret) { if (ret) {
printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n");
...@@ -595,7 +596,7 @@ static int xc5000_fwupload(struct dvb_frontend *fe) ...@@ -595,7 +596,7 @@ static int xc5000_fwupload(struct dvb_frontend *fe)
ret = XC_RESULT_SUCCESS; ret = XC_RESULT_SUCCESS;
} }
if (fw->size != priv->fw->size) { if (fw->size != desired_fw->size) {
printk(KERN_ERR "xc5000: firmware incorrect size\n"); printk(KERN_ERR "xc5000: firmware incorrect size\n");
ret = XC_RESULT_RESET_FAILURE; ret = XC_RESULT_RESET_FAILURE;
} else { } else {
...@@ -1165,12 +1166,12 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, ...@@ -1165,12 +1166,12 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
if (priv->radio_input == 0) if (priv->radio_input == 0)
priv->radio_input = cfg->radio_input; priv->radio_input = cfg->radio_input;
/* don't override firmware filename if it's already been set /* don't override chip id if it's already been set
unless explicitly specified */ unless explicitly specified */
if ((priv->fw == NULL) || (cfg->fw)) if ((priv->chip_id == 0) || (cfg->chip_id))
/* use default firmware if none specified */ /* use default chip id if none specified, set to 0 so
priv->fw = xc5000_assign_firmware((cfg->fw) ? it can be overridden if this is a hybrid driver */
cfg->fw : XC5000_DEFAULT_FIRMWARE); priv->chip_id = (cfg->chip_id) ? cfg->chip_id : 0;
/* Check if firmware has been loaded. It is possible that another /* Check if firmware has been loaded. It is possible that another
instance of the driver has loaded the firmware. instance of the driver has loaded the firmware.
......
...@@ -27,18 +27,15 @@ ...@@ -27,18 +27,15 @@
struct dvb_frontend; struct dvb_frontend;
struct i2c_adapter; struct i2c_adapter;
#define XC5000_FW_A_1_6_114 1 #define XC5000A 1
#define XC5000_FW_C_41_024_5_31875 2 #define XC5000C 2
#define XC5000_DEFAULT_FIRMWARE XC5000_FW_A_1_6_114
#define XC5000C_DEFAULT_FIRMWARE XC5000_FW_C_41_024_5_31875
struct xc5000_config { struct xc5000_config {
u8 i2c_address; u8 i2c_address;
u32 if_khz; u32 if_khz;
u8 radio_input; u8 radio_input;
int fw; int chip_id;
}; };
/* xc5000 callback command */ /* xc5000 callback command */
......
...@@ -386,7 +386,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -386,7 +386,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
.i2c_address = t->i2c->addr, .i2c_address = t->i2c->addr,
/* if_khz will be set at dvb_attach() */ /* if_khz will be set at dvb_attach() */
.if_khz = 0, .if_khz = 0,
.fw = XC5000C_DEFAULT_FIRMWARE, .chip_id = XC5000C,
}; };
if (!dvb_attach(xc5000_attach, if (!dvb_attach(xc5000_attach,
......
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