drivers/media/usb/cx231xx/cx231xx-i2c.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/cx231xx/cx231xx-i2c.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/cx231xx/cx231xx-i2c.c- Extension
.c- Size
- 14015 bytes
- Lines
- 596
- 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.
- 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
cx231xx.hlinux/module.hlinux/kernel.hlinux/i2c.hlinux/i2c-mux.hmedia/v4l2-common.hmedia/tuner.h
Detected Declarations
function get_real_i2c_portfunction is_tunerfunction cx231xx_i2c_send_bytesfunction cx231xx_i2c_recv_bytesfunction cx231xx_i2c_recv_bytes_with_saddrfunction cx231xx_i2c_check_for_devicefunction cx231xx_i2c_xferfunction functionalityfunction cx231xx_do_i2c_scanfunction cx231xx_i2c_registerfunction cx231xx_i2c_unregisterfunction cx231xx_i2c_mux_selectfunction cx231xx_i2c_mux_createfunction cx231xx_i2c_mux_registerfunction cx231xx_i2c_mux_unregisterexport cx231xx_get_i2c_adap
Annotated Snippet
if (size == 2) { /* register write sub addr */
/* Just writing sub address will cause problem
* to XC5000. So ignore the request */
return 0;
} else if (size == 4) { /* register write with sub addr */
if (msg->len >= 2)
saddr = msg->buf[0] << 8 | msg->buf[1];
else if (msg->len == 1)
saddr = msg->buf[0];
switch (saddr) {
case 0x0000: /* start tuner calibration mode */
need_gpio = 1;
/* FW Loading is done */
dev->xc_fw_load_done = 1;
break;
case 0x000D: /* Set signal source */
case 0x0001: /* Set TV standard - Video */
case 0x0002: /* Set TV standard - Audio */
case 0x0003: /* Set RF Frequency */
need_gpio = 1;
break;
default:
if (dev->xc_fw_load_done)
need_gpio = 1;
break;
}
if (need_gpio) {
dprintk1(1,
"GPIO WRITE: addr 0x%x, len %d, saddr 0x%x\n",
msg->addr, msg->len, saddr);
return dev->cx231xx_gpio_i2c_write(dev,
msg->addr,
msg->buf,
msg->len);
}
}
/* special case for Xc5000 tuner case */
saddr_len = 1;
/* adjust the length to correct length */
size -= saddr_len;
buf_ptr = (u8 *) (msg->buf + 1);
do {
/* prepare xfer_data struct */
req_data.dev_addr = msg->addr;
req_data.direction = msg->flags;
req_data.saddr_len = saddr_len;
req_data.saddr_dat = msg->buf[0];
req_data.buf_size = size > 16 ? 16 : size;
req_data.p_buffer = (u8 *) (buf_ptr + loop * 16);
bus->i2c_nostop = (size > 16) ? 1 : 0;
bus->i2c_reserve = (loop == 0) ? 0 : 1;
/* usb send command */
status = dev->cx231xx_send_usb_command(bus, &req_data);
loop++;
if (size >= 16)
size -= 16;
else
size = 0;
} while (size > 0);
bus->i2c_nostop = 0;
bus->i2c_reserve = 0;
} else { /* regular case */
/* prepare xfer_data struct */
req_data.dev_addr = msg->addr;
req_data.direction = msg->flags;
req_data.saddr_len = 0;
req_data.saddr_dat = 0;
req_data.buf_size = msg->len;
req_data.p_buffer = msg->buf;
/* usb send command */
status = dev->cx231xx_send_usb_command(bus, &req_data);
}
return status < 0 ? status : 0;
}
Annotation
- Immediate include surface: `cx231xx.h`, `linux/module.h`, `linux/kernel.h`, `linux/i2c.h`, `linux/i2c-mux.h`, `media/v4l2-common.h`, `media/tuner.h`.
- Detected declarations: `function get_real_i2c_port`, `function is_tuner`, `function cx231xx_i2c_send_bytes`, `function cx231xx_i2c_recv_bytes`, `function cx231xx_i2c_recv_bytes_with_saddr`, `function cx231xx_i2c_check_for_device`, `function cx231xx_i2c_xfer`, `function functionality`, `function cx231xx_do_i2c_scan`, `function cx231xx_i2c_register`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.