Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 76412
b: refs/heads/master
c: f380e1d
h: refs/heads/master
v: v3
  • Loading branch information
Mauro Carvalho Chehab committed Jan 25, 2008
1 parent 602fb86 commit 00ed42f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 43efe70253dd13b2d22ee51bb474ece25b3b41b1
refs/heads/master: f380e1d2c9a1ff82a89ec68850ce53094359000e
98 changes: 77 additions & 21 deletions trunk/drivers/media/video/tuner-xc2028.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ void dump_firm_type(unsigned int type)
{
if (type & BASE)
printk("BASE ");
if (type & INIT1)
printk("INIT1 ");
if (type & F8MHZ)
printk("F8MHZ ");
if (type & MTS)
Expand Down Expand Up @@ -201,7 +203,7 @@ static int load_all_firmwares(struct dvb_frontend *fe)

tuner_info("%s called\n", __FUNCTION__);

tuner_info("Loading firmware %s\n", priv->ctrl.fname);
tuner_info("Reading firmware %s\n", priv->ctrl.fname);
rc = request_firmware(&fw, priv->ctrl.fname, priv->dev);
if (rc < 0) {
if (rc == -ENOENT)
Expand Down Expand Up @@ -325,12 +327,11 @@ static int load_all_firmwares(struct dvb_frontend *fe)
return rc;
}

static int load_firmware(struct dvb_frontend *fe, unsigned int type,
v4l2_std_id * id)
static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
v4l2_std_id *id)
{
struct xc2028_data *priv = fe->tuner_priv;
int i, rc;
unsigned char *p, *endp, buf[priv->max_len];
int i;

tuner_info("%s called\n", __FUNCTION__);

Expand All @@ -339,7 +340,7 @@ static int load_firmware(struct dvb_frontend *fe, unsigned int type,
return -EINVAL;
}

if ((type == 0) && (*id == 0))
if (((type & ~SCODE) == 0) && (*id == 0))
*id = V4L2_STD_PAL;

/* Seek for exact match */
Expand All @@ -356,21 +357,40 @@ static int load_firmware(struct dvb_frontend *fe, unsigned int type,

/*FIXME: Would make sense to seek for type "hint" match ? */

tuner_info("Can't find firmware for type=%x, id=%lx\n", type,
(long int)*id);
return -EINVAL;
i = -EINVAL;
goto ret;

found:
*id = priv->firm[i].id;
tuner_info("Found firmware for type=%x, id=%lx\n", type, (long int)*id);

p = priv->firm[i].ptr;
ret:
tuner_info("%s firmware for type=", (i < 0)? "Can't find": "Found");
dump_firm_type(type);
printk("(%x), id %08lx.\n", type, (unsigned long)*id);

return i;
}

static int load_firmware(struct dvb_frontend *fe, unsigned int type,
v4l2_std_id *id)
{
struct xc2028_data *priv = fe->tuner_priv;
int pos, rc;
unsigned char *p, *endp, buf[priv->max_len];

tuner_info("%s called\n", __FUNCTION__);

pos = seek_firmware(fe, type, id);
if (pos < 0)
return pos;

p = priv->firm[pos].ptr;

if (!p) {
printk(KERN_ERR PREFIX "Firmware pointer were freed!");
return -EINVAL;
}
endp = p + priv->firm[i].size;
endp = p + priv->firm[pos].size;

while (p < endp) {
__u16 size;
Expand Down Expand Up @@ -435,6 +455,42 @@ static int load_firmware(struct dvb_frontend *fe, unsigned int type,
return 0;
}

static int load_scode(struct dvb_frontend *fe, unsigned int type,
v4l2_std_id *id, int scode)
{
struct xc2028_data *priv = fe->tuner_priv;
int pos, rc;
unsigned char *p;

tuner_info("%s called\n", __FUNCTION__);

pos = seek_firmware(fe, type, id);
if (pos < 0)
return pos;

p = priv->firm[pos].ptr;

if (!p) {
printk(KERN_ERR PREFIX "Firmware pointer were freed!");
return -EINVAL;
}

if ((priv->firm[pos].size != 12 * 16) || (scode >= 16))
return -EINVAL;

if (priv->version < 0x0202) {
send_seq(priv, {0x20, 0x00, 0x00, 0x00});
} else {
send_seq(priv, {0xa0, 0x00, 0x00, 0x00});
}

i2c_send(rc, priv, p + 12 * scode, 12);

send_seq(priv, {0x00, 0x8c});

return 0;
}

static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode,
v4l2_std_id std, fe_bandwidth_t bandwidth)
{
Expand Down Expand Up @@ -527,8 +583,8 @@ static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode,
}

/* Load INIT1, if needed */
tuner_info("Trying to load init1 firmware\n");
type0 = BASE | INIT1 | priv->ctrl.type;
tuner_info("Load init1 firmware, if exists\n");
type0 = BASE | INIT1;
if (priv->ctrl.type == XC2028_FIRM_MTS)
type0 |= MTS;

Expand All @@ -541,21 +597,21 @@ static int check_firmware(struct dvb_frontend *fe, enum tuner_mode new_mode,
if (priv->ctrl.type == XC2028_FIRM_MTS)
type |= MTS;

tuner_info("firmware standard to load: %08lx\n", (unsigned long)std);
tuner_info("Firmware standard to load: %08lx\n", (unsigned long)std);
if (priv->firm_type & std) {
tuner_info("no need to load a std-specific firmware.\n");
tuner_info("Std-specific firmware already loaded.\n");
return 0;
}

rc = load_firmware(fe, type, &std);
if (rc < 0)
return rc;

/* Load SCODE firmware, if needed */
tuner_info("Trying to load scode firmware\n");
type0 = SCODE | priv->ctrl.type;
if (priv->ctrl.type == XC2028_FIRM_MTS)
type0 |= MTS;
/* Load SCODE firmware, if exists */
tuner_info("Trying to load scode 0\n");
type |= SCODE;

rc = load_scode(fe, type, &std, 0);

version = xc2028_get_reg(priv, 0x0004);
hwmodel = xc2028_get_reg(priv, 0x0008);
Expand Down

0 comments on commit 00ed42f

Please sign in to comment.