drivers/media/tuners/si2157.c
Source file repositories/reference/linux-study-clean/drivers/media/tuners/si2157.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/tuners/si2157.c- Extension
.c- Size
- 28968 bytes
- Lines
- 1136
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
si2157_priv.h
Detected Declarations
function si2157_cmd_executefunction si2157_load_firmwarefunction si2157_find_and_load_firmwarefunction si2157_initfunction si2157_sleepfunction si2157_tune_waitfunction si2157_set_paramsfunction si2157_set_analog_paramsfunction si2157_get_frequencyfunction si2157_get_bandwidthfunction si2157_get_if_frequencyfunction si2157_get_rf_strengthfunction si2157_stat_workfunction si2157_probefunction si2157_remove
Annotated Snippet
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->wlen) {
ret = -EREMOTEIO;
goto err_mutex_unlock;
}
}
if (cmd->rlen) {
/* wait cmd execution terminate */
#define TIMEOUT 80
timeout = jiffies + msecs_to_jiffies(TIMEOUT);
while (!time_after(jiffies, timeout)) {
ret = i2c_master_recv(client, cmd->args, cmd->rlen);
if (ret < 0) {
goto err_mutex_unlock;
} else if (ret != cmd->rlen) {
ret = -EREMOTEIO;
goto err_mutex_unlock;
}
/* firmware ready? */
if ((cmd->args[0] >> 7) & 0x01)
break;
}
dev_dbg(&client->dev, "cmd execution took %d ms, status=%x\n",
jiffies_to_msecs(jiffies) -
(jiffies_to_msecs(timeout) - TIMEOUT),
cmd->args[0]);
if (!((cmd->args[0] >> 7) & 0x01)) {
ret = -ETIMEDOUT;
goto err_mutex_unlock;
}
/* check error status bit */
if (cmd->args[0] & 0x40) {
ret = -EAGAIN;
goto err_mutex_unlock;
}
}
mutex_unlock(&dev->i2c_mutex);
return 0;
err_mutex_unlock:
mutex_unlock(&dev->i2c_mutex);
dev_dbg(&client->dev, "failed=%d\n", ret);
return ret;
}
static const struct si2157_tuner_info si2157_tuners[] = {
{ SI2141, 0x60, false, SI2141_60_FIRMWARE, SI2141_A10_FIRMWARE },
{ SI2141, 0x61, false, SI2141_61_FIRMWARE, SI2141_A10_FIRMWARE },
{ SI2146, 0x11, false, SI2146_11_FIRMWARE, NULL },
{ SI2147, 0x50, false, SI2147_50_FIRMWARE, NULL },
{ SI2148, 0x32, true, SI2148_32_FIRMWARE, SI2158_A20_FIRMWARE },
{ SI2148, 0x33, true, SI2148_33_FIRMWARE, SI2158_A20_FIRMWARE },
{ SI2157, 0x50, false, SI2157_50_FIRMWARE, SI2157_A30_FIRMWARE },
{ SI2158, 0x50, false, SI2158_50_FIRMWARE, SI2158_A20_FIRMWARE },
{ SI2158, 0x51, false, SI2158_51_FIRMWARE, SI2158_A20_FIRMWARE },
{ SI2177, 0x50, false, SI2177_50_FIRMWARE, SI2157_A30_FIRMWARE },
};
static int si2157_load_firmware(struct dvb_frontend *fe,
const char *fw_name)
{
struct i2c_client *client = fe->tuner_priv;
const struct firmware *fw;
int ret, len, remaining;
struct si2157_cmd cmd;
/* request the firmware, this will block and timeout */
ret = firmware_request_nowarn(&fw, fw_name, &client->dev);
if (ret)
return ret;
/* firmware should be n chunks of 17 bytes */
if (fw->size % 17 != 0) {
dev_err(&client->dev, "firmware file '%s' is invalid\n",
fw_name);
ret = -EINVAL;
goto err_release_firmware;
}
dev_info(&client->dev, "downloading firmware from file '%s'\n",
fw_name);
for (remaining = fw->size; remaining > 0; remaining -= 17) {
len = fw->data[fw->size - remaining];
Annotation
- Immediate include surface: `si2157_priv.h`.
- Detected declarations: `function si2157_cmd_execute`, `function si2157_load_firmware`, `function si2157_find_and_load_firmware`, `function si2157_init`, `function si2157_sleep`, `function si2157_tune_wait`, `function si2157_set_params`, `function si2157_set_analog_params`, `function si2157_get_frequency`, `function si2157_get_bandwidth`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.