drivers/media/dvb-frontends/ds3000.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/ds3000.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/ds3000.c- Extension
.c- Size
- 26118 bytes
- Lines
- 1131
- 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/slab.hlinux/kernel.hlinux/module.hlinux/moduleparam.hlinux/init.hlinux/firmware.hmedia/dvb_frontend.hts2020.hds3000.h
Detected Declarations
struct ds3000_statefunction ds3000_writeregfunction ds3000_i2c_gate_ctrlfunction ds3000_writeFWfunction ds3000_readregfunction ds3000_firmware_ondemandfunction ds3000_load_firmwarefunction ds3000_set_voltagefunction ds3000_read_statusfunction ds3000_read_berfunction ds3000_read_signal_strengthfunction ds3000_read_snrfunction ds3000_read_ucblocksfunction ds3000_set_tonefunction ds3000_send_diseqc_msgfunction ds3000_diseqc_send_burstfunction ds3000_releasefunction ds3000_set_carrier_offsetfunction ds3000_set_frontendfunction ds3000_tunefunction ds3000_get_algofunction ds3000_initfeexport ds3000_attach
Annotated Snippet
struct ds3000_state {
struct i2c_adapter *i2c;
const struct ds3000_config *config;
struct dvb_frontend frontend;
/* previous uncorrected block counter for DVB-S2 */
u16 prevUCBS2;
};
static int ds3000_writereg(struct ds3000_state *state, int reg, int data)
{
u8 buf[] = { reg, data };
struct i2c_msg msg = { .addr = state->config->demod_address,
.flags = 0, .buf = buf, .len = 2 };
int err;
dprintk("%s: write reg 0x%02x, value 0x%02x\n", __func__, reg, data);
err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) {
printk(KERN_ERR "%s: writereg error(err == %i, reg == 0x%02x, value == 0x%02x)\n",
__func__, err, reg, data);
return -EREMOTEIO;
}
return 0;
}
static int ds3000_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
{
struct ds3000_state *state = fe->demodulator_priv;
if (enable)
ds3000_writereg(state, 0x03, 0x12);
else
ds3000_writereg(state, 0x03, 0x02);
return 0;
}
/* I2C write for 8k firmware load */
static int ds3000_writeFW(struct ds3000_state *state, int reg,
const u8 *data, u16 len)
{
int i, ret = 0;
struct i2c_msg msg;
u8 *buf;
buf = kmalloc(33, GFP_KERNEL);
if (!buf)
return -ENOMEM;
*(buf) = reg;
msg.addr = state->config->demod_address;
msg.flags = 0;
msg.buf = buf;
msg.len = 33;
for (i = 0; i < len; i += 32) {
memcpy(buf + 1, data + i, 32);
dprintk("%s: write reg 0x%02x, len = %d\n", __func__, reg, len);
ret = i2c_transfer(state->i2c, &msg, 1);
if (ret != 1) {
printk(KERN_ERR "%s: write error(err == %i, reg == 0x%02x\n",
__func__, ret, reg);
ret = -EREMOTEIO;
goto error;
}
}
ret = 0;
error:
kfree(buf);
return ret;
}
static int ds3000_readreg(struct ds3000_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
Annotation
- Immediate include surface: `linux/slab.h`, `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/firmware.h`, `media/dvb_frontend.h`, `ts2020.h`.
- Detected declarations: `struct ds3000_state`, `function ds3000_writereg`, `function ds3000_i2c_gate_ctrl`, `function ds3000_writeFW`, `function ds3000_readreg`, `function ds3000_firmware_ondemand`, `function ds3000_load_firmware`, `function ds3000_set_voltage`, `function ds3000_read_status`, `function ds3000_read_ber`.
- 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.