drivers/media/usb/dvb-usb/pctv452e.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb/pctv452e.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/dvb-usb/pctv452e.c- Extension
.c- Size
- 25644 bytes
- Lines
- 1114
- 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
dvb-usb.hstb0899_drv.hstb0899_reg.hstb0899_cfg.hstb6100.hstb6100_cfg.hisl6423.hlnbp22.hmedia/dvb_ca_en50221.httpci-eeprom.hlinux/etherdevice.h
Detected Declarations
struct pctv452e_statefunction tt3650_ci_msgfunction tt3650_ci_msg_lockedfunction tt3650_ci_read_attribute_memfunction tt3650_ci_write_attribute_memfunction tt3650_ci_read_cam_controlfunction tt3650_ci_write_cam_controlfunction tt3650_ci_set_video_portfunction tt3650_ci_slot_shutdownfunction tt3650_ci_slot_ts_enablefunction tt3650_ci_slot_resetfunction tt3650_ci_poll_slot_statusfunction tt3650_ci_uninitfunction tt3650_ci_initfunction pctv452e_i2c_msgfunction pctv452e_i2c_xferfunction pctv452e_i2c_funcfunction pctv452e_power_ctrlfunction pctv452e_rc_queryfunction pctv452e_read_mac_addressfunction pctv452e_frontend_attachfunction pctv452e_tuner_attachfunction pctv452e_usb_disconnectfunction pctv452e_usb_probe
Annotated Snippet
struct pctv452e_state {
struct dvb_ca_en50221 ca;
struct mutex ca_mutex;
u8 c; /* transaction counter, wraps around... */
u8 initialized; /* set to 1 if 0x15 has been sent */
u16 last_rc_key;
};
static int tt3650_ci_msg(struct dvb_usb_device *d, u8 cmd, u8 *data,
unsigned int write_len, unsigned int read_len)
{
struct pctv452e_state *state = d->priv;
u8 *buf;
u8 id;
unsigned int rlen;
int ret;
if (!data || (write_len > 64 - 4) || (read_len > 64 - 4)) {
err("%s: transfer data invalid", __func__);
return -EIO;
}
buf = kmalloc(64, GFP_KERNEL);
if (!buf)
return -ENOMEM;
id = state->c++;
buf[0] = SYNC_BYTE_OUT;
buf[1] = id;
buf[2] = cmd;
buf[3] = write_len;
memcpy(buf + 4, data, write_len);
rlen = (read_len > 0) ? 64 : 0;
ret = dvb_usb_generic_rw(d, buf, 4 + write_len,
buf, rlen, /* delay_ms */ 0);
if (0 != ret)
goto failed;
ret = -EIO;
if (SYNC_BYTE_IN != buf[0] || id != buf[1])
goto failed;
memcpy(data, buf + 4, read_len);
kfree(buf);
return 0;
failed:
err("CI error %d; %02X %02X %02X -> %*ph.",
ret, SYNC_BYTE_OUT, id, cmd, 3, buf);
kfree(buf);
return ret;
}
static int tt3650_ci_msg_locked(struct dvb_ca_en50221 *ca,
u8 cmd, u8 *data, unsigned int write_len,
unsigned int read_len)
{
struct dvb_usb_device *d = ca->data;
struct pctv452e_state *state = d->priv;
int ret;
mutex_lock(&state->ca_mutex);
ret = tt3650_ci_msg(d, cmd, data, write_len, read_len);
mutex_unlock(&state->ca_mutex);
return ret;
}
static int tt3650_ci_read_attribute_mem(struct dvb_ca_en50221 *ca,
int slot, int address)
{
u8 buf[3];
int ret;
if (0 != slot)
return -EINVAL;
buf[0] = (address >> 8) & 0x0F;
buf[1] = address;
ret = tt3650_ci_msg_locked(ca, TT3650_CMD_CI_RD_ATTR, buf, 2, 3);
ci_dbg("%s %04x -> %d 0x%02x",
__func__, address, ret, buf[2]);
Annotation
- Immediate include surface: `dvb-usb.h`, `stb0899_drv.h`, `stb0899_reg.h`, `stb0899_cfg.h`, `stb6100.h`, `stb6100_cfg.h`, `isl6423.h`, `lnbp22.h`.
- Detected declarations: `struct pctv452e_state`, `function tt3650_ci_msg`, `function tt3650_ci_msg_locked`, `function tt3650_ci_read_attribute_mem`, `function tt3650_ci_write_attribute_mem`, `function tt3650_ci_read_cam_control`, `function tt3650_ci_write_cam_control`, `function tt3650_ci_set_video_port`, `function tt3650_ci_slot_shutdown`, `function tt3650_ci_slot_ts_enable`.
- 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.