drivers/media/tuners/mt20xx.c
Source file repositories/reference/linux-study-clean/drivers/media/tuners/mt20xx.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/tuners/mt20xx.c- Extension
.c- Size
- 15409 bytes
- Lines
- 651
- 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/delay.hlinux/i2c.hlinux/slab.hlinux/videodev2.htuner-i2c.hmt20xx.h
Detected Declarations
struct microtune_privfunction microtune_releasefunction microtune_get_frequencyfunction mt2032_spurcheckfunction mt2032_check_lo_lockfunction mt2032_optimize_vcofunction mt2032_set_if_freqfunction mt2032_set_tv_freqfunction mt2032_set_radio_freqfunction mt2032_set_paramsfunction mt2032_initfunction mt2050_set_antennafunction mt2050_set_if_freqfunction mt2050_set_tv_freqfunction mt2050_set_radio_freqfunction mt2050_set_paramsfunction mt2050_initexport microtune_attach
Annotated Snippet
struct microtune_priv {
struct tuner_i2c_props i2c_props;
unsigned int xogc;
//unsigned int radio_if2;
u32 frequency;
};
static void microtune_release(struct dvb_frontend *fe)
{
kfree(fe->tuner_priv);
fe->tuner_priv = NULL;
}
static int microtune_get_frequency(struct dvb_frontend *fe, u32 *frequency)
{
struct microtune_priv *priv = fe->tuner_priv;
*frequency = priv->frequency;
return 0;
}
// IsSpurInBand()?
static int mt2032_spurcheck(struct dvb_frontend *fe,
int f1, int f2, int spectrum_from,int spectrum_to)
{
struct microtune_priv *priv = fe->tuner_priv;
int n1=1,n2,f;
f1=f1/1000; //scale to kHz to avoid 32bit overflows
f2=f2/1000;
spectrum_from/=1000;
spectrum_to/=1000;
tuner_dbg("spurcheck f1=%d f2=%d from=%d to=%d\n",
f1,f2,spectrum_from,spectrum_to);
do {
n2=-n1;
f=n1*(f1-f2);
do {
n2--;
f=f-f2;
tuner_dbg("spurtest n1=%d n2=%d ftest=%d\n",n1,n2,f);
if( (f>spectrum_from) && (f<spectrum_to))
tuner_dbg("mt2032 spurcheck triggered: %d\n",n1);
} while ( (f>(f2-spectrum_to)) || (n2>-5));
n1++;
} while (n1<5);
return 1;
}
static int mt2032_compute_freq(struct dvb_frontend *fe,
unsigned int rfin,
unsigned int if1, unsigned int if2,
unsigned int spectrum_from,
unsigned int spectrum_to,
unsigned char *buf,
int *ret_sel,
unsigned int xogc) //all in Hz
{
struct microtune_priv *priv = fe->tuner_priv;
unsigned int fref,lo1,lo1n,lo1a,s,sel,lo1freq, desired_lo1,
desired_lo2,lo2,lo2n,lo2a,lo2num,lo2freq;
fref= 5250 *1000; //5.25MHz
desired_lo1=rfin+if1;
lo1=(2*(desired_lo1/1000)+(fref/1000)) / (2*fref/1000);
lo1n=lo1/8;
lo1a=lo1-(lo1n*8);
s=rfin/1000/1000+1090;
if(optimize_vco) {
if(s>1890) sel=0;
else if(s>1720) sel=1;
else if(s>1530) sel=2;
else if(s>1370) sel=3;
else sel=4; // >1090
}
else {
if(s>1790) sel=0; // <1958
else if(s>1617) sel=1;
else if(s>1449) sel=2;
else if(s>1291) sel=3;
else sel=4; // >1090
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/slab.h`, `linux/videodev2.h`, `tuner-i2c.h`, `mt20xx.h`.
- Detected declarations: `struct microtune_priv`, `function microtune_release`, `function microtune_get_frequency`, `function mt2032_spurcheck`, `function mt2032_check_lo_lock`, `function mt2032_optimize_vco`, `function mt2032_set_if_freq`, `function mt2032_set_tv_freq`, `function mt2032_set_radio_freq`, `function mt2032_set_params`.
- 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.