drivers/media/dvb-frontends/tua6100.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/tua6100.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/tua6100.c- Extension
.c- Size
- 4769 bytes
- Lines
- 194
- 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.
- 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/module.hlinux/dvb/frontend.hasm/types.htua6100.h
Detected Declarations
struct tua6100_privfunction tua6100_releasefunction tua6100_sleepfunction tua6100_set_paramsfunction tua6100_get_frequencyexport tua6100_attach
Annotated Snippet
struct tua6100_priv {
/* i2c details */
int i2c_address;
struct i2c_adapter *i2c;
u32 frequency;
};
static void tua6100_release(struct dvb_frontend *fe)
{
kfree(fe->tuner_priv);
fe->tuner_priv = NULL;
}
static int tua6100_sleep(struct dvb_frontend *fe)
{
struct tua6100_priv *priv = fe->tuner_priv;
int ret;
u8 reg0[] = { 0x00, 0x00 };
struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = reg0, .len = 2 };
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) {
printk("%s: i2c error\n", __func__);
}
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 0);
return (ret == 1) ? 0 : ret;
}
static int tua6100_set_params(struct dvb_frontend *fe)
{
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
struct tua6100_priv *priv = fe->tuner_priv;
u32 div;
u32 prediv;
u8 reg0[] = { 0x00, 0x00 };
u8 reg1[] = { 0x01, 0x00, 0x00, 0x00 };
u8 reg2[] = { 0x02, 0x00, 0x00 };
struct i2c_msg msg0 = { .addr = priv->i2c_address, .flags = 0, .buf = reg0, .len = 2 };
struct i2c_msg msg1 = { .addr = priv->i2c_address, .flags = 0, .buf = reg1, .len = 4 };
struct i2c_msg msg2 = { .addr = priv->i2c_address, .flags = 0, .buf = reg2, .len = 3 };
#define _R_VAL 4
#define _P_VAL 32
#define _ri 4000000
// setup register 0
if (c->frequency < 2000000)
reg0[1] = 0x03;
else
reg0[1] = 0x07;
// setup register 1
if (c->frequency < 1630000)
reg1[1] = 0x2c;
else
reg1[1] = 0x0c;
if (_P_VAL == 64)
reg1[1] |= 0x40;
if (c->frequency >= 1525000)
reg1[1] |= 0x80;
// register 2
reg2[1] = (_R_VAL >> 8) & 0x03;
reg2[2] = _R_VAL;
if (c->frequency < 1455000)
reg2[1] |= 0x1c;
else if (c->frequency < 1630000)
reg2[1] |= 0x0c;
else
reg2[1] |= 0x1c;
/*
* The N divisor ratio (note: c->frequency is in kHz, but we
* need it in Hz)
*/
prediv = (c->frequency * _R_VAL) / (_ri / 1000);
div = prediv / _P_VAL;
reg1[1] |= (div >> 9) & 0x03;
reg1[2] = div >> 1;
reg1[3] = (div << 7);
priv->frequency = ((div * _P_VAL) * (_ri / 1000)) / _R_VAL;
// Finally, calculate and store the value for A
reg1[3] |= (prediv - (div*_P_VAL)) & 0x7f;
#undef _R_VAL
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `linux/dvb/frontend.h`, `asm/types.h`, `tua6100.h`.
- Detected declarations: `struct tua6100_priv`, `function tua6100_release`, `function tua6100_sleep`, `function tua6100_set_params`, `function tua6100_get_frequency`, `export tua6100_attach`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
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.