drivers/media/usb/dvb-usb-v2/af9035.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb-v2/af9035.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/dvb-usb-v2/af9035.c- Extension
.c- Size
- 57406 bytes
- Lines
- 2204
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
af9035.h
Detected Declarations
function af9035_checksumfunction af9035_ctrl_msgfunction af9035_wr_regsfunction af9035_rd_regsfunction af9035_wr_regfunction af9035_rd_regfunction af9035_wr_reg_maskfunction af9035_add_i2c_devfunction af9035_del_i2c_devfunction af9035_i2c_master_xferfunction af9035_i2c_functionalityfunction af9035_identify_statefunction af9035_download_firmware_oldfunction af9035_download_firmware_newfunction af9035_download_firmwarefunction af9035_read_configfunction le16_to_cpufunction af9035_tua9001_tuner_callbackfunction af9035_fc0011_tuner_callbackfunction af9035_tuner_callbackfunction af9035_frontend_callbackfunction af9035_get_adapter_countfunction af9035_frontend_attachfunction it930x_frontend_attachfunction af9035_frontend_detachfunction af9035_tuner_attachfunction it930x_tuner_attachfunction it930x_tuner_detachfunction af9035_tuner_detachfunction af9035_initfunction it930x_initfunction af9035_rc_queryfunction af9035_get_rc_configfunction af9035_get_stream_configfunction af9035_pid_filter_ctrlfunction af9035_pid_filterfunction af9035_probe
Annotated Snippet
if (req->cmd == CMD_IR_GET || state->buf[2] == 1) {
ret = 1;
goto exit;
}
dev_dbg(&intf->dev, "command=%02x failed fw error=%d\n",
req->cmd, state->buf[2]);
ret = -EIO;
goto exit;
}
/* read request, copy returned data to return buf */
if (req->rlen)
memcpy(req->rbuf, &state->buf[ACK_HDR_LEN], req->rlen);
exit:
mutex_unlock(&d->usb_mutex);
return ret;
}
/* write multiple registers */
static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
{
struct usb_interface *intf = d->intf;
u8 wbuf[MAX_XFER_SIZE];
u8 mbox = (reg >> 16) & 0xff;
struct usb_req req = { CMD_MEM_WR, mbox, 6 + len, wbuf, 0, NULL };
if (6 + len > sizeof(wbuf)) {
dev_warn(&intf->dev, "i2c wr: len=%d is too big!\n", len);
return -EOPNOTSUPP;
}
wbuf[0] = len;
wbuf[1] = 2;
wbuf[2] = 0;
wbuf[3] = 0;
wbuf[4] = (reg >> 8) & 0xff;
wbuf[5] = (reg >> 0) & 0xff;
memcpy(&wbuf[6], val, len);
return af9035_ctrl_msg(d, &req);
}
/* read multiple registers */
static int af9035_rd_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
{
u8 wbuf[] = { len, 2, 0, 0, (reg >> 8) & 0xff, reg & 0xff };
u8 mbox = (reg >> 16) & 0xff;
struct usb_req req = { CMD_MEM_RD, mbox, sizeof(wbuf), wbuf, len, val };
return af9035_ctrl_msg(d, &req);
}
/* write single register */
static int af9035_wr_reg(struct dvb_usb_device *d, u32 reg, u8 val)
{
return af9035_wr_regs(d, reg, &val, 1);
}
/* read single register */
static int af9035_rd_reg(struct dvb_usb_device *d, u32 reg, u8 *val)
{
return af9035_rd_regs(d, reg, val, 1);
}
/* write single register with mask */
static int af9035_wr_reg_mask(struct dvb_usb_device *d, u32 reg, u8 val,
u8 mask)
{
int ret;
u8 tmp;
/* no need for read if whole reg is written */
if (mask != 0xff) {
ret = af9035_rd_regs(d, reg, &tmp, 1);
if (ret)
return ret;
val &= mask;
tmp &= ~mask;
val |= tmp;
}
return af9035_wr_regs(d, reg, &val, 1);
}
static int af9035_add_i2c_dev(struct dvb_usb_device *d, const char *type,
u8 addr, void *platform_data, struct i2c_adapter *adapter)
{
int ret, num;
Annotation
- Immediate include surface: `af9035.h`.
- Detected declarations: `function af9035_checksum`, `function af9035_ctrl_msg`, `function af9035_wr_regs`, `function af9035_rd_regs`, `function af9035_wr_reg`, `function af9035_rd_reg`, `function af9035_wr_reg_mask`, `function af9035_add_i2c_dev`, `function af9035_del_i2c_dev`, `function af9035_i2c_master_xfer`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.