drivers/media/dvb-frontends/mt352.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/mt352.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/mt352.c- Extension
.c- Size
- 13639 bytes
- Lines
- 597
- 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/delay.hlinux/string.hlinux/slab.hmedia/dvb_frontend.hmt352_priv.hmt352.h
Detected Declarations
struct mt352_statefunction mt352_single_writefunction _mt352_writefunction mt352_read_registerfunction mt352_sleepfunction mt352_calc_nominal_ratefunction mt352_calc_input_freqfunction mt352_set_parametersfunction mt352_get_parametersfunction mt352_read_statusfunction mt352_read_berfunction mt352_read_signal_strengthfunction mt352_read_snrfunction mt352_read_ucblocksfunction mt352_get_tune_settingsfunction mt352_initfunction mt352_releasefunction mt352_attachexport mt352_attach
Annotated Snippet
struct mt352_state {
struct i2c_adapter* i2c;
struct dvb_frontend frontend;
/* configuration settings */
struct mt352_config config;
};
static int debug;
#define dprintk(args...) \
do { \
if (debug) printk(KERN_DEBUG "mt352: " args); \
} while (0)
static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
{
struct mt352_state* state = fe->demodulator_priv;
u8 buf[2] = { reg, val };
struct i2c_msg msg = { .addr = state->config.demod_address, .flags = 0,
.buf = buf, .len = 2 };
int err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) {
printk("mt352_write() to reg %x failed (err = %d)!\n", reg, err);
return err;
}
return 0;
}
static int _mt352_write(struct dvb_frontend* fe, const u8 ibuf[], int ilen)
{
int err,i;
for (i=0; i < ilen-1; i++)
if ((err = mt352_single_write(fe,ibuf[0]+i,ibuf[i+1])))
return err;
return 0;
}
static int mt352_read_register(struct mt352_state* state, u8 reg)
{
int ret;
u8 b0 [] = { reg };
u8 b1 [] = { 0 };
struct i2c_msg msg [] = { { .addr = state->config.demod_address,
.flags = 0,
.buf = b0, .len = 1 },
{ .addr = state->config.demod_address,
.flags = I2C_M_RD,
.buf = b1, .len = 1 } };
ret = i2c_transfer(state->i2c, msg, 2);
if (ret != 2) {
printk("%s: readreg error (reg=%d, ret==%i)\n",
__func__, reg, ret);
return ret;
}
return b1[0];
}
static int mt352_sleep(struct dvb_frontend* fe)
{
static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 };
_mt352_write(fe, mt352_softdown, sizeof(mt352_softdown));
return 0;
}
static void mt352_calc_nominal_rate(struct mt352_state* state,
u32 bandwidth,
unsigned char *buf)
{
u32 adc_clock = 20480; /* 20.340 MHz */
u32 bw,value;
switch (bandwidth) {
case 6000000:
bw = 6;
break;
case 7000000:
bw = 7;
break;
case 8000000:
default:
bw = 8;
break;
}
if (state->config.adc_clock)
adc_clock = state->config.adc_clock;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/delay.h`, `linux/string.h`, `linux/slab.h`, `media/dvb_frontend.h`, `mt352_priv.h`.
- Detected declarations: `struct mt352_state`, `function mt352_single_write`, `function _mt352_write`, `function mt352_read_register`, `function mt352_sleep`, `function mt352_calc_nominal_rate`, `function mt352_calc_input_freq`, `function mt352_set_parameters`, `function mt352_get_parameters`, `function mt352_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.