drivers/media/dvb-frontends/ec100.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/ec100.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/ec100.c- Extension
.c- Size
- 6836 bytes
- Lines
- 332
- 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
media/dvb_frontend.hec100.h
Detected Declarations
struct ec100_statefunction ec100_write_regfunction ec100_read_regfunction ec100_set_frontendfunction ec100_get_tune_settingsfunction ec100_read_statusfunction ec100_read_berfunction ec100_read_signal_strengthfunction ec100_read_snrfunction ec100_read_ucblocksfunction ec100_releaseexport ec100_attach
Annotated Snippet
struct ec100_state {
struct i2c_adapter *i2c;
struct dvb_frontend frontend;
struct ec100_config config;
u16 ber;
};
/* write single register */
static int ec100_write_reg(struct ec100_state *state, u8 reg, u8 val)
{
int ret;
u8 buf[2] = {reg, val};
struct i2c_msg msg[1] = {
{
.addr = state->config.demod_address,
.flags = 0,
.len = sizeof(buf),
.buf = buf,
}
};
ret = i2c_transfer(state->i2c, msg, 1);
if (ret == 1) {
ret = 0;
} else {
dev_warn(&state->i2c->dev, "%s: i2c wr failed=%d reg=%02x\n",
KBUILD_MODNAME, ret, reg);
ret = -EREMOTEIO;
}
return ret;
}
/* read single register */
static int ec100_read_reg(struct ec100_state *state, u8 reg, u8 *val)
{
int ret;
struct i2c_msg msg[2] = {
{
.addr = state->config.demod_address,
.flags = 0,
.len = 1,
.buf = ®
}, {
.addr = state->config.demod_address,
.flags = I2C_M_RD,
.len = 1,
.buf = val
}
};
ret = i2c_transfer(state->i2c, msg, 2);
if (ret == 2) {
ret = 0;
} else {
dev_warn(&state->i2c->dev, "%s: i2c rd failed=%d reg=%02x\n",
KBUILD_MODNAME, ret, reg);
ret = -EREMOTEIO;
}
return ret;
}
static int ec100_set_frontend(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct ec100_state *state = fe->demodulator_priv;
int ret;
u8 tmp, tmp2;
dev_dbg(&state->i2c->dev, "%s: frequency=%d bandwidth_hz=%d\n",
__func__, c->frequency, c->bandwidth_hz);
/* program tuner */
if (fe->ops.tuner_ops.set_params)
fe->ops.tuner_ops.set_params(fe);
ret = ec100_write_reg(state, 0x04, 0x06);
if (ret)
goto error;
ret = ec100_write_reg(state, 0x67, 0x58);
if (ret)
goto error;
ret = ec100_write_reg(state, 0x05, 0x18);
if (ret)
goto error;
/* reg/bw | 6 | 7 | 8
-------+------+------+------
Annotation
- Immediate include surface: `media/dvb_frontend.h`, `ec100.h`.
- Detected declarations: `struct ec100_state`, `function ec100_write_reg`, `function ec100_read_reg`, `function ec100_set_frontend`, `function ec100_get_tune_settings`, `function ec100_read_status`, `function ec100_read_ber`, `function ec100_read_signal_strength`, `function ec100_read_snr`, `function ec100_read_ucblocks`.
- 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.