drivers/media/dvb-frontends/dib7000m.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/dib7000m.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/dib7000m.c- Extension
.c- Size
- 42141 bytes
- Lines
- 1475
- 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.hdib7000m.h
Detected Declarations
struct dib7000m_stateenum dib7000m_power_modefunction dib7000m_read_wordfunction dib7000m_write_wordfunction dib7000m_write_tabfunction dib7000m_set_output_modefunction dib7000m_set_power_modefunction dib7000m_set_adc_statefunction dib7000m_set_bandwidthfunction dib7000m_set_diversity_infunction dib7000m_sad_calibfunction dib7000m_reset_pll_commonfunction dib7000m_reset_pllfunction dib7000mc_reset_pllfunction dib7000m_reset_gpiofunction dib7000m_demod_resetfunction dib7000m_restart_agcfunction dib7000m_agc_soft_splitfunction dib7000m_update_lnafunction dib7000m_set_agc_configfunction dib7000m_update_timffunction dib7000m_agc_startupfunction dib7000m_set_channelfunction dib7000m_autosearch_startfunction dib7000m_autosearch_irqfunction dib7000m_autosearch_is_irqfunction dib7000m_tunefunction dib7000m_wakeupfunction dib7000m_sleepfunction dib7000m_identifyfunction dib7000m_get_frontendfunction dib7000m_set_frontendfunction dib7000m_read_statusfunction dib7000m_read_berfunction dib7000m_read_unc_blocksfunction dib7000m_read_signal_strengthfunction dib7000m_read_snrfunction dib7000m_fe_get_tune_settingsfunction dib7000m_releasefunction dib7000m_get_i2c_masterfunction dib7000m_pid_filter_ctrlfunction dib7000m_pid_filterfunction dib7000m_i2c_enumerationfunction dib7000m_attachexport dib7000m_get_i2c_masterexport dib7000m_pid_filter_ctrlexport dib7000m_pid_filterexport dib7000m_i2c_enumeration
Annotated Snippet
struct dib7000m_state {
struct dvb_frontend demod;
struct dib7000m_config cfg;
u8 i2c_addr;
struct i2c_adapter *i2c_adap;
struct dibx000_i2c_master i2c_master;
/* offset is 1 in case of the 7000MC */
u8 reg_offs;
u16 wbd_ref;
u8 current_band;
u32 current_bandwidth;
struct dibx000_agc_config *current_agc;
u32 timf;
u32 timf_default;
u32 internal_clk;
u8 div_force_off : 1;
u8 div_state : 1;
u16 div_sync_wait;
u16 revision;
u8 agc_state;
/* for the I2C transfer */
struct i2c_msg msg[2];
u8 i2c_write_buffer[4];
u8 i2c_read_buffer[2];
struct mutex i2c_buffer_lock;
};
enum dib7000m_power_mode {
DIB7000M_POWER_ALL = 0,
DIB7000M_POWER_NO,
DIB7000M_POWER_INTERF_ANALOG_AGC,
DIB7000M_POWER_COR4_DINTLV_ICIRM_EQUAL_CFROD,
DIB7000M_POWER_COR4_CRY_ESRAM_MOUT_NUD,
DIB7000M_POWER_INTERFACE_ONLY,
};
static u16 dib7000m_read_word(struct dib7000m_state *state, u16 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 >> 8) | 0x80;
state->i2c_write_buffer[1] = reg & 0xff;
memset(state->msg, 0, 2 * sizeof(struct i2c_msg));
state->msg[0].addr = state->i2c_addr >> 1;
state->msg[0].flags = 0;
state->msg[0].buf = state->i2c_write_buffer;
state->msg[0].len = 2;
state->msg[1].addr = state->i2c_addr >> 1;
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_adap, state->msg, 2) != 2)
dprintk("i2c read error on %d\n", reg);
ret = (state->i2c_read_buffer[0] << 8) | state->i2c_read_buffer[1];
mutex_unlock(&state->i2c_buffer_lock);
return ret;
}
static int dib7000m_write_word(struct dib7000m_state *state, u16 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 >> 8) & 0xff;
state->i2c_write_buffer[1] = reg & 0xff;
state->i2c_write_buffer[2] = (val >> 8) & 0xff;
state->i2c_write_buffer[3] = val & 0xff;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/i2c.h`, `linux/mutex.h`, `media/dvb_frontend.h`, `dib7000m.h`.
- Detected declarations: `struct dib7000m_state`, `enum dib7000m_power_mode`, `function dib7000m_read_word`, `function dib7000m_write_word`, `function dib7000m_write_tab`, `function dib7000m_set_output_mode`, `function dib7000m_set_power_mode`, `function dib7000m_set_adc_state`, `function dib7000m_set_bandwidth`, `function dib7000m_set_diversity_in`.
- 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.