drivers/media/dvb-frontends/cxd2099.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/cxd2099.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/cxd2099.c- Extension
.c- Size
- 14175 bytes
- Lines
- 694
- 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
linux/slab.hlinux/kernel.hlinux/module.hlinux/i2c.hlinux/regmap.hlinux/wait.hlinux/delay.hlinux/mutex.hlinux/io.hcxd2099.h
Detected Declarations
struct cxdfunction read_blockfunction read_regfunction read_pccardfunction write_pccardfunction read_iofunction write_iofunction write_regmfunction write_regfunction write_blockfunction set_modefunction cam_modefunction initfunction read_attribute_memfunction write_attribute_memfunction read_cam_controlfunction write_cam_controlfunction slot_resetfunction slot_shutdownfunction slot_ts_enablefunction campollfunction poll_slot_statusfunction read_datafunction write_datafunction cxd2099_probefunction cxd2099_remove
Annotated Snippet
struct cxd {
struct dvb_ca_en50221 en;
struct cxd2099_cfg cfg;
struct i2c_client *client;
struct regmap *regmap;
u8 regs[0x23];
u8 lastaddress;
u8 clk_reg_f;
u8 clk_reg_b;
int mode;
int ready;
int dr;
int write_busy;
int slot_stat;
u8 amem[1024];
int amem_read;
int cammode;
struct mutex lock; /* device access lock */
u8 rbuf[1028];
u8 wbuf[1028];
};
static int read_block(struct cxd *ci, u8 adr, u8 *data, u16 n)
{
int status = 0;
if (ci->lastaddress != adr)
status = regmap_write(ci->regmap, 0, adr);
if (!status) {
ci->lastaddress = adr;
while (n) {
int len = n;
if (ci->cfg.max_i2c && len > ci->cfg.max_i2c)
len = ci->cfg.max_i2c;
status = regmap_raw_read(ci->regmap, 1, data, len);
if (status)
return status;
data += len;
n -= len;
}
}
return status;
}
static int read_reg(struct cxd *ci, u8 reg, u8 *val)
{
return read_block(ci, reg, val, 1);
}
static int read_pccard(struct cxd *ci, u16 address, u8 *data, u8 n)
{
int status;
u8 addr[2] = {address & 0xff, address >> 8};
status = regmap_raw_write(ci->regmap, 2, addr, 2);
if (!status)
status = regmap_raw_read(ci->regmap, 3, data, n);
return status;
}
static int write_pccard(struct cxd *ci, u16 address, u8 *data, u8 n)
{
int status;
u8 addr[2] = {address & 0xff, address >> 8};
status = regmap_raw_write(ci->regmap, 2, addr, 2);
if (!status) {
u8 buf[256];
memcpy(buf, data, n);
status = regmap_raw_write(ci->regmap, 3, buf, n);
}
return status;
}
static int read_io(struct cxd *ci, u16 address, unsigned int *val)
{
int status;
u8 addr[2] = {address & 0xff, address >> 8};
status = regmap_raw_write(ci->regmap, 2, addr, 2);
if (!status)
status = regmap_read(ci->regmap, 3, val);
Annotation
- Immediate include surface: `linux/slab.h`, `linux/kernel.h`, `linux/module.h`, `linux/i2c.h`, `linux/regmap.h`, `linux/wait.h`, `linux/delay.h`, `linux/mutex.h`.
- Detected declarations: `struct cxd`, `function read_block`, `function read_reg`, `function read_pccard`, `function write_pccard`, `function read_io`, `function write_io`, `function write_regm`, `function write_reg`, `function write_block`.
- 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.