drivers/media/dvb-frontends/s5h1420.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/s5h1420.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/s5h1420.c- Extension
.c- Size
- 24913 bytes
- Lines
- 965
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
linux/kernel.hlinux/module.hlinux/init.hlinux/string.hlinux/slab.hlinux/delay.hlinux/jiffies.hasm/div64.hlinux/i2c.hmedia/dvb_frontend.hs5h1420.hs5h1420_priv.h
Detected Declarations
struct s5h1420_statefunction s5h1420_readregfunction s5h1420_writeregfunction s5h1420_set_voltagefunction s5h1420_set_tonefunction s5h1420_send_master_cmdfunction s5h1420_recv_slave_replyfunction s5h1420_send_burstfunction s5h1420_get_status_bitsfunction s5h1420_read_statusfunction s5h1420_read_berfunction s5h1420_read_signal_strengthfunction s5h1420_read_ucblocksfunction s5h1420_resetfunction s5h1420_setsymbolratefunction s5h1420_getsymbolratefunction s5h1420_setfreqoffsetfunction s5h1420_getfreqoffsetfunction s5h1420_setfec_inversionfunction s5h1420_getfecfunction s5h1420_getinversionfunction s5h1420_set_frontendfunction s5h1420_get_frontendfunction s5h1420_get_tune_settingsfunction s5h1420_i2c_gate_ctrlfunction s5h1420_initfunction s5h1420_sleepfunction s5h1420_releasefunction s5h1420_tuner_i2c_funcfunction s5h1420_tuner_i2c_tuner_xferexport s5h1420_get_tuner_i2c_adapterexport s5h1420_attach
Annotated Snippet
struct s5h1420_state {
struct i2c_adapter* i2c;
const struct s5h1420_config* config;
struct dvb_frontend frontend;
struct i2c_adapter tuner_i2c_adapter;
u8 CON_1_val;
u8 postlocked:1;
u32 fclk;
u32 tunedfreq;
enum fe_code_rate fec_inner;
u32 symbol_rate;
/* FIXME: ugly workaround for flexcop's incapable i2c-controller
* it does not support repeated-start, workaround: write addr-1
* and then read
*/
u8 shadow[256];
};
static u32 s5h1420_getsymbolrate(struct s5h1420_state* state);
static int s5h1420_get_tune_settings(struct dvb_frontend* fe,
struct dvb_frontend_tune_settings* fesettings);
static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "enable debugging");
#define dprintk(x...) do { \
if (debug) \
printk(KERN_DEBUG "S5H1420: " x); \
} while (0)
static u8 s5h1420_readreg(struct s5h1420_state *state, u8 reg)
{
int ret;
u8 b[2];
struct i2c_msg msg[] = {
{ .addr = state->config->demod_address, .flags = 0, .buf = b, .len = 2 },
{ .addr = state->config->demod_address, .flags = 0, .buf = ®, .len = 1 },
{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = 1 },
};
b[0] = (reg - 1) & 0xff;
b[1] = state->shadow[(reg - 1) & 0xff];
if (state->config->repeated_start_workaround) {
ret = i2c_transfer(state->i2c, msg, 3);
if (ret != 3)
return ret;
} else {
ret = i2c_transfer(state->i2c, &msg[1], 1);
if (ret != 1)
return ret;
ret = i2c_transfer(state->i2c, &msg[2], 1);
if (ret != 1)
return ret;
}
/* dprintk("rd(%02x): %02x %02x\n", state->config->demod_address, reg, b[0]); */
return b[0];
}
static int s5h1420_writereg (struct s5h1420_state* state, u8 reg, u8 data)
{
u8 buf[] = { reg, data };
struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
int err;
/* dprintk("wr(%02x): %02x %02x\n", state->config->demod_address, reg, data); */
err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) {
dprintk("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __func__, err, reg, data);
return -EREMOTEIO;
}
state->shadow[reg] = data;
return 0;
}
static int s5h1420_set_voltage(struct dvb_frontend *fe,
enum fe_sec_voltage voltage)
{
struct s5h1420_state* state = fe->demodulator_priv;
dprintk("enter %s\n", __func__);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/string.h`, `linux/slab.h`, `linux/delay.h`, `linux/jiffies.h`, `asm/div64.h`.
- Detected declarations: `struct s5h1420_state`, `function s5h1420_readreg`, `function s5h1420_writereg`, `function s5h1420_set_voltage`, `function s5h1420_set_tone`, `function s5h1420_send_master_cmd`, `function s5h1420_recv_slave_reply`, `function s5h1420_send_burst`, `function s5h1420_get_status_bits`, `function s5h1420_read_status`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
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.