drivers/media/dvb-frontends/dib0070.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/dib0070.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/dib0070.c- Extension
.c- Size
- 20487 bytes
- Lines
- 770
- 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.
- 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
linux/kernel.hlinux/slab.hlinux/i2c.hlinux/mutex.hmedia/dvb_frontend.hdib0070.hdibx000_common.h
Detected Declarations
struct dib0070_statestruct dib0070_tuningstruct dib0070_lna_matchfunction dib0070_read_regfunction dib0070_write_regfunction dib0070_set_bandwidthfunction dib0070_captrimfunction dib0070_set_ctrl_lo5function dib0070_ctrl_agc_filterfunction dib0070_tune_digitalfunction dib0070_tunefunction dib0070_wakeupfunction dib0070_sleepfunction dib0070_get_rf_outputfunction dib0070_set_rf_outputfunction dib0070_read_wbd_offsetfunction dib0070_wbd_offset_calibrationfunction dib0070_wbd_offsetfunction dib0070_resetfunction dib0070_get_frequencyfunction dib0070_releaseexport dib0070_ctrl_agc_filterexport dib0070_get_rf_outputexport dib0070_set_rf_outputexport dib0070_wbd_offsetexport dib0070_attach
Annotated Snippet
struct dib0070_state {
struct i2c_adapter *i2c;
struct dvb_frontend *fe;
const struct dib0070_config *cfg;
u16 wbd_ff_offset;
u8 revision;
enum frontend_tune_state tune_state;
u32 current_rf;
/* for the captrim binary search */
s8 step;
u16 adc_diff;
s8 captrim;
s8 fcaptrim;
u16 lo4;
const struct dib0070_tuning *current_tune_table_index;
const struct dib0070_lna_match *lna_match;
u8 wbd_gain_current;
u16 wbd_offset_3_3[2];
/* for the I2C transfer */
struct i2c_msg msg[2];
u8 i2c_write_buffer[3];
u8 i2c_read_buffer[2];
struct mutex i2c_buffer_lock;
};
static u16 dib0070_read_reg(struct dib0070_state *state, u8 reg)
{
u16 ret;
if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
dprintk("could not acquire lock\n");
return 0;
}
state->i2c_write_buffer[0] = reg;
memset(state->msg, 0, 2 * sizeof(struct i2c_msg));
state->msg[0].addr = state->cfg->i2c_address;
state->msg[0].flags = 0;
state->msg[0].buf = state->i2c_write_buffer;
state->msg[0].len = 1;
state->msg[1].addr = state->cfg->i2c_address;
state->msg[1].flags = I2C_M_RD;
state->msg[1].buf = state->i2c_read_buffer;
state->msg[1].len = 2;
if (i2c_transfer(state->i2c, state->msg, 2) != 2) {
pr_warn("DiB0070 I2C read failed\n");
ret = 0;
} else
ret = (state->i2c_read_buffer[0] << 8)
| state->i2c_read_buffer[1];
mutex_unlock(&state->i2c_buffer_lock);
return ret;
}
static int dib0070_write_reg(struct dib0070_state *state, u8 reg, u16 val)
{
int ret;
if (mutex_lock_interruptible(&state->i2c_buffer_lock) < 0) {
dprintk("could not acquire lock\n");
return -EINVAL;
}
state->i2c_write_buffer[0] = reg;
state->i2c_write_buffer[1] = val >> 8;
state->i2c_write_buffer[2] = val & 0xff;
memset(state->msg, 0, sizeof(struct i2c_msg));
state->msg[0].addr = state->cfg->i2c_address;
state->msg[0].flags = 0;
state->msg[0].buf = state->i2c_write_buffer;
state->msg[0].len = 3;
if (i2c_transfer(state->i2c, state->msg, 1) != 1) {
pr_warn("DiB0070 I2C write failed\n");
ret = -EREMOTEIO;
} else
ret = 0;
mutex_unlock(&state->i2c_buffer_lock);
return ret;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/i2c.h`, `linux/mutex.h`, `media/dvb_frontend.h`, `dib0070.h`, `dibx000_common.h`.
- Detected declarations: `struct dib0070_state`, `struct dib0070_tuning`, `struct dib0070_lna_match`, `function dib0070_read_reg`, `function dib0070_write_reg`, `function dib0070_set_bandwidth`, `function dib0070_captrim`, `function dib0070_set_ctrl_lo5`, `function dib0070_ctrl_agc_filter`, `function dib0070_tune_digital`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.