drivers/media/usb/dvb-usb/ttusb2.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb/ttusb2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/dvb-usb/ttusb2.c- Extension
.c- Size
- 19006 bytes
- Lines
- 850
- 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.httusb2.htda826x.htda10086.htda1002x.htda10048.htda827x.hlnbp21.hmedia/dvb_ca_en50221.h
Detected Declarations
struct ttusb2_statefunction ttusb2_msgfunction 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 ttusb2_i2c_xferfunction ttusb2_i2c_funcfunction tt3650_rc_queryfunction ttusb2_identify_statefunction ttusb2_power_ctrlfunction ttusb2_frontend_tda10086_attachfunction ttusb2_ct3650_i2c_gate_ctrlfunction ttusb2_frontend_tda10023_attachfunction ttusb2_tuner_tda827x_attachfunction ttusb2_tuner_tda826x_attachfunction ttusb2_usb_disconnectfunction ttusb2_probe
Annotated Snippet
struct ttusb2_state {
struct dvb_ca_en50221 ca;
struct mutex ca_mutex;
u8 id;
u16 last_rc_key;
};
static int ttusb2_msg(struct dvb_usb_device *d, u8 cmd,
u8 *wbuf, int wlen, u8 *rbuf, int rlen)
{
struct ttusb2_state *st = d->priv;
u8 *s, *r = NULL;
int ret = 0;
if (4 + rlen > 64)
return -EIO;
s = kzalloc(wlen+4, GFP_KERNEL);
if (!s)
return -ENOMEM;
r = kzalloc(64, GFP_KERNEL);
if (!r) {
kfree(s);
return -ENOMEM;
}
s[0] = 0xaa;
s[1] = ++st->id;
s[2] = cmd;
s[3] = wlen;
memcpy(&s[4],wbuf,wlen);
ret = dvb_usb_generic_rw(d, s, wlen+4, r, 64, 0);
if (ret != 0 ||
r[0] != 0x55 ||
r[1] != s[1] ||
r[2] != cmd ||
(rlen > 0 && r[3] != rlen)) {
warn("there might have been an error during control message transfer. (rlen = %d, was %d)",rlen,r[3]);
kfree(s);
kfree(r);
return -EIO;
}
if (rlen > 0)
memcpy(rbuf, &r[4], rlen);
kfree(s);
kfree(r);
return 0;
}
/* ci */
static int tt3650_ci_msg(struct dvb_usb_device *d, u8 cmd, u8 *data, unsigned int write_len, unsigned int read_len)
{
int ret;
u8 rx[60];/* (64 -4) */
ret = ttusb2_msg(d, cmd, data, write_len, rx, read_len);
if (!ret)
memcpy(data, rx, read_len);
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 ttusb2_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 = 0;
if (slot)
return -EINVAL;
buf[0] = (address >> 8) & 0x0F;
buf[1] = address;
Annotation
- Immediate include surface: `dvb-usb.h`, `ttusb2.h`, `tda826x.h`, `tda10086.h`, `tda1002x.h`, `tda10048.h`, `tda827x.h`, `lnbp21.h`.
- Detected declarations: `struct ttusb2_state`, `function ttusb2_msg`, `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`.
- 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.