diff options
author | Michael Krufky <mkrufky@kernellabs.com> | 2012-02-08 12:57:39 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-02-14 14:22:32 -0500 |
commit | 6fab81dfdc7b48c2e30ab05e9b30afb0c418bbbe (patch) | |
tree | 631b431735204d07bd2d683be8a1e6c2f8de3129 /drivers | |
parent | ddea427fb3e64d817d4432e5efd2abbfc4ddb02e (diff) |
[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: Michael Krufky <mkrufky@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/common/tuners/xc5000.c | 27 | ||||
-rw-r--r-- | drivers/media/common/tuners/xc5000.h | 9 | ||||
-rw-r--r-- | drivers/media/video/tuner-core.c | 2 |
3 files changed, 18 insertions, 20 deletions
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c index 2c71ee7dcb1e..07fd80f4508e 100644 --- a/drivers/media/common/tuners/xc5000.c +++ b/drivers/media/common/tuners/xc5000.c | |||
@@ -60,7 +60,7 @@ struct xc5000_priv { | |||
60 | u8 rf_mode; | 60 | u8 rf_mode; |
61 | u8 radio_input; | 61 | u8 radio_input; |
62 | 62 | ||
63 | struct xc5000_fw_cfg *fw; | 63 | int chip_id; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | /* Misc Defines */ | 66 | /* Misc Defines */ |
@@ -219,13 +219,13 @@ static struct xc5000_fw_cfg xc5000c_41_024_5_31875 = { | |||
219 | .size = 16503, | 219 | .size = 16503, |
220 | }; | 220 | }; |
221 | 221 | ||
222 | static inline struct xc5000_fw_cfg *xc5000_assign_firmware(int fw) | 222 | static inline struct xc5000_fw_cfg *xc5000_assign_firmware(int chip_id) |
223 | { | 223 | { |
224 | switch (fw) { | 224 | switch (chip_id) { |
225 | default: | 225 | default: |
226 | case XC5000_FW_A_1_6_114: | 226 | case XC5000A: |
227 | return &xc5000a_1_6_114; | 227 | return &xc5000a_1_6_114; |
228 | case XC5000_FW_C_41_024_5_31875: | 228 | case XC5000C: |
229 | return &xc5000c_41_024_5_31875; | 229 | return &xc5000c_41_024_5_31875; |
230 | } | 230 | } |
231 | } | 231 | } |
@@ -578,12 +578,13 @@ static int xc5000_fwupload(struct dvb_frontend *fe) | |||
578 | struct xc5000_priv *priv = fe->tuner_priv; | 578 | struct xc5000_priv *priv = fe->tuner_priv; |
579 | const struct firmware *fw; | 579 | const struct firmware *fw; |
580 | int ret; | 580 | int ret; |
581 | struct xc5000_fw_cfg *desired_fw = xc5000_assign_firmware(priv->chip_id); | ||
581 | 582 | ||
582 | /* request the firmware, this will block and timeout */ | 583 | /* request the firmware, this will block and timeout */ |
583 | printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", | 584 | printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", |
584 | priv->fw->name); | 585 | desired_fw->name); |
585 | 586 | ||
586 | ret = request_firmware(&fw, priv->fw->name, | 587 | ret = request_firmware(&fw, desired_fw->name, |
587 | priv->i2c_props.adap->dev.parent); | 588 | priv->i2c_props.adap->dev.parent); |
588 | if (ret) { | 589 | if (ret) { |
589 | printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); | 590 | printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); |
@@ -595,7 +596,7 @@ static int xc5000_fwupload(struct dvb_frontend *fe) | |||
595 | ret = XC_RESULT_SUCCESS; | 596 | ret = XC_RESULT_SUCCESS; |
596 | } | 597 | } |
597 | 598 | ||
598 | if (fw->size != priv->fw->size) { | 599 | if (fw->size != desired_fw->size) { |
599 | printk(KERN_ERR "xc5000: firmware incorrect size\n"); | 600 | printk(KERN_ERR "xc5000: firmware incorrect size\n"); |
600 | ret = XC_RESULT_RESET_FAILURE; | 601 | ret = XC_RESULT_RESET_FAILURE; |
601 | } else { | 602 | } else { |
@@ -1165,12 +1166,12 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe, | |||
1165 | if (priv->radio_input == 0) | 1166 | if (priv->radio_input == 0) |
1166 | priv->radio_input = cfg->radio_input; | 1167 | priv->radio_input = cfg->radio_input; |
1167 | 1168 | ||
1168 | /* don't override firmware filename if it's already been set | 1169 | /* don't override chip id if it's already been set |
1169 | unless explicitly specified */ | 1170 | unless explicitly specified */ |
1170 | if ((priv->fw == NULL) || (cfg->fw)) | 1171 | if ((priv->chip_id == 0) || (cfg->chip_id)) |
1171 | /* use default firmware if none specified */ | 1172 | /* use default chip id if none specified, set to 0 so |
1172 | priv->fw = xc5000_assign_firmware((cfg->fw) ? | 1173 | it can be overridden if this is a hybrid driver */ |
1173 | cfg->fw : XC5000_DEFAULT_FIRMWARE); | 1174 | priv->chip_id = (cfg->chip_id) ? cfg->chip_id : 0; |
1174 | 1175 | ||
1175 | /* Check if firmware has been loaded. It is possible that another | 1176 | /* Check if firmware has been loaded. It is possible that another |
1176 | instance of the driver has loaded the firmware. | 1177 | instance of the driver has loaded the firmware. |
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h index c003af5322a0..3396f8e02b40 100644 --- a/drivers/media/common/tuners/xc5000.h +++ b/drivers/media/common/tuners/xc5000.h | |||
@@ -27,18 +27,15 @@ | |||
27 | struct dvb_frontend; | 27 | struct dvb_frontend; |
28 | struct i2c_adapter; | 28 | struct i2c_adapter; |
29 | 29 | ||
30 | #define XC5000_FW_A_1_6_114 1 | 30 | #define XC5000A 1 |
31 | #define XC5000_FW_C_41_024_5_31875 2 | 31 | #define XC5000C 2 |
32 | |||
33 | #define XC5000_DEFAULT_FIRMWARE XC5000_FW_A_1_6_114 | ||
34 | #define XC5000C_DEFAULT_FIRMWARE XC5000_FW_C_41_024_5_31875 | ||
35 | 32 | ||
36 | struct xc5000_config { | 33 | struct xc5000_config { |
37 | u8 i2c_address; | 34 | u8 i2c_address; |
38 | u32 if_khz; | 35 | u32 if_khz; |
39 | u8 radio_input; | 36 | u8 radio_input; |
40 | 37 | ||
41 | int fw; | 38 | int chip_id; |
42 | }; | 39 | }; |
43 | 40 | ||
44 | /* xc5000 callback command */ | 41 | /* xc5000 callback command */ |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 0628a0ae9da5..89a123dee14d 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -386,7 +386,7 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
386 | .i2c_address = t->i2c->addr, | 386 | .i2c_address = t->i2c->addr, |
387 | /* if_khz will be set at dvb_attach() */ | 387 | /* if_khz will be set at dvb_attach() */ |
388 | .if_khz = 0, | 388 | .if_khz = 0, |
389 | .fw = XC5000C_DEFAULT_FIRMWARE, | 389 | .chip_id = XC5000C, |
390 | }; | 390 | }; |
391 | 391 | ||
392 | if (!dvb_attach(xc5000_attach, | 392 | if (!dvb_attach(xc5000_attach, |