drivers/staging/media/av7110/sp8870.c
Source file repositories/reference/linux-study-clean/drivers/staging/media/av7110/sp8870.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/media/av7110/sp8870.c- Extension
.c- Size
- 14100 bytes
- Lines
- 626
- Domain
- Driver Families
- Bucket
- drivers/staging
- 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/init.hlinux/module.hlinux/device.hlinux/firmware.hlinux/delay.hlinux/string.hlinux/slab.hmedia/dvb_frontend.hsp8870.h
Detected Declarations
struct sp8870_statefunction sp8870_writeregfunction sp8870_readregfunction sp8870_firmware_uploadfunction sp8870_microcontroller_stopfunction sp8870_microcontroller_startfunction sp8870_read_data_valid_signalfunction configure_reg0xc05function sp8870_wake_upfunction sp8870_set_frontend_parametersfunction sp8870_initfunction sp8870_read_statusfunction sp8870_read_berfunction sp8870_read_signal_strengthfunction sp8870_read_uncorrected_blocksfunction sp8870_set_frontendfunction sp8870_sleepfunction sp8870_get_tune_settingsfunction sp8870_i2c_gate_ctrlfunction sp8870_releaseexport sp8870_attach
Annotated Snippet
struct sp8870_state {
struct i2c_adapter *i2c;
const struct sp8870_config *config;
struct dvb_frontend frontend;
/* demodulator private data */
u8 initialised:1;
};
static int debug;
#define dprintk(fmt, arg...) \
do { \
if (debug) \
pr_info("%s(): " fmt, __func__, ##arg); \
} while (0)
/* firmware size for sp8870 */
#define SP8870_FIRMWARE_SIZE 16382
/* starting point for firmware in file 'Sc_main.mc' */
#define SP8870_FIRMWARE_OFFSET 0x0A
static int sp8870_writereg(struct sp8870_state *state, u16 reg, u16 data)
{
u8 buf[] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff };
struct i2c_msg msg = {
.addr = state->config->demod_address,
.flags = 0,
.buf = buf,
.len = 4
};
int err;
err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) {
dprintk("writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", err, reg, data);
return -EREMOTEIO;
}
return 0;
}
static int sp8870_readreg(struct sp8870_state *state, u16 reg)
{
int ret;
u8 b0[] = { reg >> 8, reg & 0xff };
u8 b1[] = { 0, 0 };
struct i2c_msg msg[] = {
{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }
};
ret = i2c_transfer(state->i2c, msg, 2);
if (ret != 2) {
dprintk("readreg error (ret == %i)\n", ret);
return -1;
}
return (b1[0] << 8 | b1[1]);
}
static int sp8870_firmware_upload(struct sp8870_state *state, const struct firmware *fw)
{
struct i2c_msg msg;
const char *fw_buf = fw->data;
int fw_pos;
u8 tx_buf[255];
int tx_len;
int err = 0;
dprintk("start firmware upload...\n");
if (fw->size < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET)
return -EINVAL;
// system controller stop
sp8870_writereg(state, 0x0F00, 0x0000);
// instruction RAM register hiword
sp8870_writereg(state, 0x8F08, ((SP8870_FIRMWARE_SIZE / 2) & 0xFFFF));
// instruction RAM MWR
sp8870_writereg(state, 0x8F0A, ((SP8870_FIRMWARE_SIZE / 2) >> 16));
// do firmware upload
fw_pos = SP8870_FIRMWARE_OFFSET;
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/device.h`, `linux/firmware.h`, `linux/delay.h`, `linux/string.h`, `linux/slab.h`, `media/dvb_frontend.h`.
- Detected declarations: `struct sp8870_state`, `function sp8870_writereg`, `function sp8870_readreg`, `function sp8870_firmware_upload`, `function sp8870_microcontroller_stop`, `function sp8870_microcontroller_start`, `function sp8870_read_data_valid_signal`, `function configure_reg0xc05`, `function sp8870_wake_up`, `function sp8870_set_frontend_parameters`.
- Atlas domain: Driver Families / drivers/staging.
- 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.