drivers/media/usb/dvb-usb/dw2102.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/dvb-usb/dw2102.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/dvb-usb/dw2102.c- Extension
.c- Size
- 63074 bytes
- Lines
- 2662
- 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
media/dvb-usb-ids.hdw2102.hsi21xx.hstv0299.hz0194a.hstv0288.hstb6000.heds1547.hcx24116.htda1002x.hmt312.hzl10039.hts2020.hds3000.hstv0900.hstv6110.hstb6100.hstb6100_proc.hm88rs2000.htda18271.hcxd2820r.hm88ds3103.h
Detected Declarations
struct dw2102_stateenum dw2102_table_entryfunction dw210x_op_rwfunction dw2102_i2c_transferfunction dw2102_serit_i2c_transferfunction dw2102_earda_i2c_transferfunction dw2104_i2c_transferfunction dw3101_i2c_transferfunction s6x0_i2c_transferfunction su3000_i2c_transferfunction dw210x_i2c_funcfunction dw210x_read_mac_addressfunction s6x0_read_mac_addressfunction su3000_streaming_ctrlfunction su3000_power_ctrlfunction su3000_read_mac_addressfunction su3000_identify_statefunction dw210x_set_voltagefunction s660_set_voltagefunction dw210x_led_ctrlfunction tt_s2_4600_read_statusfunction dw2104_frontend_attachfunction dw2102_frontend_attachfunction dw3101_frontend_attachfunction zl100313_frontend_attachfunction stv0288_frontend_attachfunction ds3000_frontend_attachfunction prof_7500_frontend_attachfunction su3000_frontend_attachfunction t220_frontend_attachfunction m88rs2000_frontend_attachfunction tt_s2_4600_frontend_attach_probe_demodfunction tt_s2_4600_frontend_attachfunction dw2102_tuner_attachfunction dw3101_tuner_attachfunction dw2102_rc_queryfunction prof_rc_queryfunction su3000_rc_queryfunction dw2102_load_firmwarefunction dw2102_probefunction dw2102_disconnect
Annotated Snippet
struct dw2102_state {
u8 initialized;
u8 last_lock;
u8 data[MAX_XFER_SIZE + 4];
struct i2c_client *i2c_client_demod;
struct i2c_client *i2c_client_tuner;
/* fe hook functions*/
int (*old_set_voltage)(struct dvb_frontend *f, enum fe_sec_voltage v);
int (*fe_read_status)(struct dvb_frontend *fe,
enum fe_status *status);
};
/* debug */
static int dvb_usb_dw2102_debug;
module_param_named(debug, dvb_usb_dw2102_debug, int, 0644);
MODULE_PARM_DESC(debug, "set debugging level (1=info 2=xfer 4=rc(or-able))."
DVB_USB_DEBUG_STATUS);
/* demod probe */
static int demod_probe = 1;
module_param_named(demod, demod_probe, int, 0644);
MODULE_PARM_DESC(demod, "demod to probe (1=cx24116 2=stv0903+stv6110 4=stv0903+stb6100(or-able)).");
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
u16 index, u8 *data, u16 len, int flags)
{
int ret;
u8 *u8buf;
unsigned int pipe = (flags == DW210X_READ_MSG) ?
usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
u8buf = kmalloc(len, GFP_KERNEL);
if (!u8buf)
return -ENOMEM;
if (flags == DW210X_WRITE_MSG)
memcpy(u8buf, data, len);
ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
value, index, u8buf, len, 2000);
if (flags == DW210X_READ_MSG)
memcpy(data, u8buf, len);
kfree(u8buf);
return ret;
}
/* I2C */
static int dw2102_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
int num)
{
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int i = 0;
u8 buf6[] = {0x2c, 0x05, 0xc0, 0, 0, 0, 0};
u16 value;
if (!d)
return -ENODEV;
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
switch (num) {
case 2:
if (msg[0].len < 1) {
num = -EOPNOTSUPP;
break;
}
/* read stv0299 register */
value = msg[0].buf[0];/* register */
for (i = 0; i < msg[1].len; i++) {
dw210x_op_rw(d->udev, 0xb5, value + i, 0,
buf6, 2, DW210X_READ_MSG);
msg[1].buf[i] = buf6[0];
}
break;
case 1:
switch (msg[0].addr) {
case 0x68:
if (msg[0].len < 2) {
num = -EOPNOTSUPP;
break;
}
/* write to stv0299 register */
buf6[0] = 0x2a;
buf6[1] = msg[0].buf[0];
buf6[2] = msg[0].buf[1];
Annotation
- Immediate include surface: `media/dvb-usb-ids.h`, `dw2102.h`, `si21xx.h`, `stv0299.h`, `z0194a.h`, `stv0288.h`, `stb6000.h`, `eds1547.h`.
- Detected declarations: `struct dw2102_state`, `enum dw2102_table_entry`, `function dw210x_op_rw`, `function dw2102_i2c_transfer`, `function dw2102_serit_i2c_transfer`, `function dw2102_earda_i2c_transfer`, `function dw2104_i2c_transfer`, `function dw3101_i2c_transfer`, `function s6x0_i2c_transfer`, `function su3000_i2c_transfer`.
- 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.