1
0
mirror of https://github.com/torvalds/linux.git synced 2024-12-12 22:23:55 +00:00

media: si2157: get rid of chiptype data

The driver should be capable of autodetecting its type, so no
need to pass it via device driver's data.

While here, improve documentation of some of the part_id
specific code.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab 2021-12-10 08:55:20 +01:00
parent 1c35ba3bf9
commit 805d5a0896
2 changed files with 28 additions and 24 deletions
drivers/media/tuners

View File

@ -185,6 +185,9 @@ static int si2157_find_and_load_firmware(struct dvb_frontend *fe)
return -EINVAL;
}
/* Update the part id based on device's report */
dev->part_id = part_id;
dev_info(&client->dev,
"found a 'Silicon Labs Si21%d-%c%c%c ROM 0x%02x'\n",
part_id, cmd.args[1], cmd.args[3], cmd.args[4], rom_id);
@ -235,10 +238,12 @@ static int si2157_init(struct dvb_frontend *fe)
dev->if_frequency = 0; /* we no longer know current tuner state */
/* power up */
if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
if (dev->part_id == SI2146) {
/* clock_mode = XTAL, clock_freq = 24MHz */
memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
cmd.wlen = 9;
} else if (dev->chiptype == SI2157_CHIPTYPE_SI2141) {
} else if (dev->part_id == SI2141) {
/* clock_mode: XTAL, xout enabled */
memcpy(cmd.args, "\xc0\x00\x0d\x0e\x00\x01\x01\x01\x01\x03", 10);
cmd.wlen = 10;
} else {
@ -247,11 +252,11 @@ static int si2157_init(struct dvb_frontend *fe)
}
cmd.rlen = 1;
ret = si2157_cmd_execute(client, &cmd);
if (ret && (dev->chiptype != SI2157_CHIPTYPE_SI2141 || ret != -EAGAIN))
if (ret && (dev->part_id != SI2141 || ret != -EAGAIN))
goto err;
/* Si2141 needs a second command before it answers the revision query */
if (dev->chiptype == SI2157_CHIPTYPE_SI2141) {
/* Si2141 needs a wake up command */
if (dev->part_id == SI2141) {
memcpy(cmd.args, "\xc0\x08\x01\x02\x00\x00\x01", 7);
cmd.wlen = 7;
ret = si2157_cmd_execute(client, &cmd);
@ -493,7 +498,8 @@ static int si2157_set_params(struct dvb_frontend *fe)
if (ret)
goto err;
if (dev->chiptype == SI2157_CHIPTYPE_SI2146)
/* On SI2146, set DTV AGC source to DLIF_AGC_3DB */
if (dev->part_id == SI2146)
memcpy(cmd.args, "\x14\x00\x02\x07\x00\x01", 6);
else
memcpy(cmd.args, "\x14\x00\x02\x07\x00\x00", 6);
@ -560,9 +566,9 @@ static int si2157_set_analog_params(struct dvb_frontend *fe,
u8 color = 0; /* 0=NTSC/PAL, 0x10=SECAM */
u8 invert_analog = 1; /* analog tuner spectrum; 0=normal, 1=inverted */
if (dev->chiptype != SI2157_CHIPTYPE_SI2157) {
dev_info(&client->dev, "Analog tuning not supported for chiptype=%u\n",
dev->chiptype);
if (dev->part_id != SI2157) {
dev_info(&client->dev, "Analog tuning not supported yet for Si21%d\n",
dev->part_id);
ret = -EINVAL;
goto err;
}
@ -874,7 +880,7 @@ static int si2157_probe(struct i2c_client *client,
dev->inversion = cfg->inversion;
dev->dont_load_firmware = cfg->dont_load_firmware;
dev->if_port = cfg->if_port;
dev->chiptype = (u8)id->driver_data;
dev->part_id = (u8)id->driver_data;
dev->if_frequency = 5000000; /* default value of property 0x0706 */
mutex_init(&dev->i2c_mutex);
INIT_DELAYED_WORK(&dev->stat_work, si2157_stat_work);
@ -917,10 +923,8 @@ static int si2157_probe(struct i2c_client *client,
}
#endif
dev_info(&client->dev, "Silicon Labs %s successfully attached\n",
dev->chiptype == SI2157_CHIPTYPE_SI2141 ? "Si2141" :
dev->chiptype == SI2157_CHIPTYPE_SI2146 ?
"Si2146" : "Si2147/2148/2157/2158");
dev_info(&client->dev, "Silicon Labs Si21%d successfully attached\n",
dev->part_id);
return 0;
@ -953,11 +957,16 @@ static int si2157_remove(struct i2c_client *client)
return 0;
}
/*
* The part_id used here will only be used on buggy devices that don't
* accept firmware uploads. Non-buggy devices should just use "si2157" for
* all SiLabs TER tuners, as the driver should auto-detect it.
*/
static const struct i2c_device_id si2157_id_table[] = {
{"si2157", SI2157_CHIPTYPE_SI2157},
{"si2146", SI2157_CHIPTYPE_SI2146},
{"si2141", SI2157_CHIPTYPE_SI2141},
{"si2177", SI2157_CHIPTYPE_SI2177},
{"si2157", SI2157},
{"si2146", SI2146},
{"si2141", SI2141},
{"si2177", SI2177},
{}
};
MODULE_DEVICE_TABLE(i2c, si2157_id_table);

View File

@ -26,7 +26,7 @@ struct si2157_dev {
unsigned int active:1;
unsigned int inversion:1;
unsigned int dont_load_firmware:1;
u8 chiptype;
u8 part_id;
u8 if_port;
u32 if_frequency;
u32 bandwidth;
@ -58,11 +58,6 @@ struct si2157_tuner_info {
const char *fw_name, *fw_alt_name;
};
#define SI2157_CHIPTYPE_SI2157 0
#define SI2157_CHIPTYPE_SI2146 1
#define SI2157_CHIPTYPE_SI2141 2
#define SI2157_CHIPTYPE_SI2177 3
/* firmware command struct */
#define SI2157_ARGLEN 30
struct si2157_cmd {