drivers/media/pci/cx23885/cimax2.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cx23885/cimax2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cx23885/cimax2.c- Extension
.c- Size
- 12633 bytes
- Lines
- 534
- 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.
- 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
cx23885.hcimax2.hmedia/dvb_ca_en50221.h
Detected Declarations
struct netup_ci_statefunction netup_read_i2cfunction netup_write_i2cfunction netup_ci_get_memfunction netup_ci_op_camfunction netup_ci_read_attribute_memfunction netup_ci_write_attribute_memfunction netup_ci_read_cam_ctlfunction netup_ci_write_cam_ctlfunction netup_ci_slot_resetfunction netup_ci_slot_shutdownfunction netup_ci_set_irqfunction netup_ci_slot_ts_ctlfunction netup_read_ci_statusfunction netup_ci_slot_statusfunction netup_poll_ci_slot_statusfunction netup_ci_initfunction netup_ci_exit
Annotated Snippet
struct netup_ci_state {
struct dvb_ca_en50221 ca;
struct mutex ca_mutex;
struct i2c_adapter *i2c_adap;
u8 ci_i2c_addr;
int status;
struct work_struct work;
void *priv;
u8 current_irq_mode;
int current_ci_flag;
unsigned long next_status_checked_time;
};
static int netup_read_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
u8 *buf, int len)
{
int ret;
struct i2c_msg msg[] = {
{
.addr = addr,
.flags = 0,
.buf = ®,
.len = 1
}, {
.addr = addr,
.flags = I2C_M_RD,
.buf = buf,
.len = len
}
};
ret = i2c_transfer(i2c_adap, msg, 2);
if (ret != 2) {
ci_dbg_print("%s: i2c read error, Reg = 0x%02x, Status = %d\n",
__func__, reg, ret);
return -1;
}
ci_dbg_print("%s: i2c read Addr=0x%04x, Reg = 0x%02x, data = %02x\n",
__func__, addr, reg, buf[0]);
return 0;
}
static int netup_write_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
u8 *buf, int len)
{
int ret;
u8 buffer[MAX_XFER_SIZE];
struct i2c_msg msg = {
.addr = addr,
.flags = 0,
.buf = &buffer[0],
.len = len + 1
};
if (1 + len > sizeof(buffer)) {
pr_warn("%s: i2c wr reg=%04x: len=%d is too big!\n",
KBUILD_MODNAME, reg, len);
return -EINVAL;
}
buffer[0] = reg;
memcpy(&buffer[1], buf, len);
ret = i2c_transfer(i2c_adap, &msg, 1);
if (ret != 1) {
ci_dbg_print("%s: i2c write error, Reg=[0x%02x], Status=%d\n",
__func__, reg, ret);
return -1;
}
return 0;
}
static int netup_ci_get_mem(struct cx23885_dev *dev)
{
int mem;
unsigned long timeout = jiffies + msecs_to_jiffies(1);
for (;;) {
mem = cx_read(MC417_RWD);
if ((mem & NETUP_ACK) == 0)
break;
if (time_after(jiffies, timeout))
Annotation
- Immediate include surface: `cx23885.h`, `cimax2.h`, `media/dvb_ca_en50221.h`.
- Detected declarations: `struct netup_ci_state`, `function netup_read_i2c`, `function netup_write_i2c`, `function netup_ci_get_mem`, `function netup_ci_op_cam`, `function netup_ci_read_attribute_mem`, `function netup_ci_write_attribute_mem`, `function netup_ci_read_cam_ctl`, `function netup_ci_write_cam_ctl`, `function netup_ci_slot_reset`.
- 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.