Skip to content

Commit

Permalink
[media] xc5000: support 32MHz & 31.875MHz xtal using the 41.024.5 fir…
Browse files Browse the repository at this point in the history
…mware

Rather than loading firmware specific for the xtal frequency, just use
the standard firmware and set the xtal frequency after firmware upload.

The modified firmware will never be released, so we're better off
merging this now rather than waiting for v3.5.

Signed-off-by: Michael Krufky <mkrufky@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Michael Krufky authored and Mauro Carvalho Chehab committed Apr 19, 2012
1 parent 18311c5 commit e631f57
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
39 changes: 35 additions & 4 deletions drivers/media/common/tuners/xc5000.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct xc5000_priv {
struct list_head hybrid_tuner_instance_list;

u32 if_khz;
u32 xtal_khz;
u32 freq_hz;
u32 bandwidth;
u8 video_standard;
Expand Down Expand Up @@ -214,9 +215,9 @@ static const struct xc5000_fw_cfg xc5000a_1_6_114 = {
.size = 12401,
};

static const struct xc5000_fw_cfg xc5000c_41_024_5_31875 = {
.name = "dvb-fe-xc5000c-41.024.5-31875.fw",
.size = 16503,
static const struct xc5000_fw_cfg xc5000c_41_024_5 = {
.name = "dvb-fe-xc5000c-41.024.5.fw",
.size = 16497,
};

static inline const struct xc5000_fw_cfg *xc5000_assign_firmware(int chip_id)
Expand All @@ -226,7 +227,7 @@ static inline const struct xc5000_fw_cfg *xc5000_assign_firmware(int chip_id)
case XC5000A:
return &xc5000a_1_6_114;
case XC5000C:
return &xc5000c_41_024_5_31875;
return &xc5000c_41_024_5;
}
}

Expand Down Expand Up @@ -572,6 +573,31 @@ static int xc_tune_channel(struct xc5000_priv *priv, u32 freq_hz, int mode)
return found;
}

static int xc_set_xtal(struct dvb_frontend *fe)
{
struct xc5000_priv *priv = fe->tuner_priv;
int ret = XC_RESULT_SUCCESS;

switch (priv->chip_id) {
default:
case XC5000A:
/* 32.000 MHz xtal is default */
break;
case XC5000C:
switch (priv->xtal_khz) {
default:
case 32000:
/* 32.000 MHz xtal is default */
break;
case 31875:
/* 31.875 MHz xtal configuration */
ret = xc_write_reg(priv, 0x000f, 0x8081);
break;
}
break;
}
return ret;
}

static int xc5000_fwupload(struct dvb_frontend *fe)
{
Expand Down Expand Up @@ -603,6 +629,8 @@ static int xc5000_fwupload(struct dvb_frontend *fe)
} else {
printk(KERN_INFO "xc5000: firmware uploading...\n");
ret = xc_load_i2c_sequence(fe, fw->data);
if (XC_RESULT_SUCCESS == ret)
ret = xc_set_xtal(fe);
printk(KERN_INFO "xc5000: firmware upload complete...\n");
}

Expand Down Expand Up @@ -1164,6 +1192,9 @@ struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
priv->if_khz = cfg->if_khz;
}

if (priv->xtal_khz == 0)
priv->xtal_khz = cfg->xtal_khz;

if (priv->radio_input == 0)
priv->radio_input = cfg->radio_input;

Expand Down
1 change: 1 addition & 0 deletions drivers/media/common/tuners/xc5000.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct xc5000_config {
u8 i2c_address;
u32 if_khz;
u8 radio_input;
u32 xtal_khz;

int chip_id;
};
Expand Down

0 comments on commit e631f57

Please sign in to comment.