drivers/media/pci/cx23885/cx23885-i2c.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/cx23885/cx23885-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/cx23885/cx23885-i2c.c- Extension
.c- Size
- 8771 bytes
- Lines
- 375
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
cx23885.hlinux/module.hlinux/init.hlinux/delay.hasm/io.hmedia/v4l2-common.h
Detected Declarations
function i2c_slave_did_ackfunction i2c_is_busyfunction i2c_wait_donefunction i2c_sendbytesfunction i2c_readbytesfunction i2c_xferfunction cx23885_functionalityfunction do_i2c_scanfunction cx23885_i2c_registerfunction cx23885_i2c_unregisterfunction cx23885_av_clk
Annotated Snippet
if (i2c_debug) {
pr_cont(" %02x", msg->buf[cnt]);
if (!(ctrl & I2C_NOSTOP))
pr_cont(" >\n");
}
}
return msg->len;
eio:
retval = -EIO;
if (i2c_debug)
pr_err(" ERR: %d\n", retval);
return retval;
}
static int i2c_readbytes(struct i2c_adapter *i2c_adap,
const struct i2c_msg *msg, int joined)
{
struct cx23885_i2c *bus = i2c_adap->algo_data;
struct cx23885_dev *dev = bus->dev;
u32 ctrl, cnt;
int retval;
if (i2c_debug && !joined)
dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len);
/* Deal with i2c probe functions with zero payload */
if (msg->len == 0) {
cx_write(bus->reg_addr, msg->addr << 25);
cx_write(bus->reg_ctrl, bus->i2c_period | (1 << 2) | 1);
if (!i2c_wait_done(i2c_adap))
return -EIO;
if (!i2c_slave_did_ack(i2c_adap))
return -ENXIO;
dprintk(1, "%s() returns 0\n", __func__);
return 0;
}
if (i2c_debug) {
if (joined)
dprintk(1, " R");
else
dprintk(1, " <R %02x", (msg->addr << 1) + 1);
}
for (cnt = 0; cnt < msg->len; cnt++) {
ctrl = bus->i2c_period | (1 << 12) | (1 << 2) | 1;
if (cnt < msg->len - 1)
ctrl |= I2C_NOSTOP | I2C_EXTEND;
cx_write(bus->reg_addr, msg->addr << 25);
cx_write(bus->reg_ctrl, ctrl);
if (!i2c_wait_done(i2c_adap))
goto eio;
msg->buf[cnt] = cx_read(bus->reg_rdata) & 0xff;
if (i2c_debug) {
dprintk(1, " %02x", msg->buf[cnt]);
if (!(ctrl & I2C_NOSTOP))
dprintk(1, " >\n");
}
}
return msg->len;
eio:
retval = -EIO;
if (i2c_debug)
pr_err(" ERR: %d\n", retval);
return retval;
}
static int i2c_xfer(struct i2c_adapter *i2c_adap,
struct i2c_msg *msgs, int num)
{
int i, retval = 0;
dprintk(1, "%s(num = %d)\n", __func__, num);
for (i = 0 ; i < num; i++) {
dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n",
__func__, num, msgs[i].addr, msgs[i].len);
if (msgs[i].flags & I2C_M_RD) {
/* read */
retval = i2c_readbytes(i2c_adap, &msgs[i], 0);
} else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) &&
Annotation
- Immediate include surface: `cx23885.h`, `linux/module.h`, `linux/init.h`, `linux/delay.h`, `asm/io.h`, `media/v4l2-common.h`.
- Detected declarations: `function i2c_slave_did_ack`, `function i2c_is_busy`, `function i2c_wait_done`, `function i2c_sendbytes`, `function i2c_readbytes`, `function i2c_xfer`, `function cx23885_functionality`, `function do_i2c_scan`, `function cx23885_i2c_register`, `function cx23885_i2c_unregister`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.