drivers/media/tuners/fc2580.c
Source file repositories/reference/linux-study-clean/drivers/media/tuners/fc2580.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/tuners/fc2580.c- Extension
.c- Size
- 15445 bytes
- Lines
- 623
- 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.
- 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
fc2580_priv.h
Detected Declarations
function Copyrightfunction fc2580_set_paramsfunction fc2580_initfunction fc2580_sleepfunction fc2580_dvb_set_paramsfunction fc2580_dvb_initfunction fc2580_dvb_sleepfunction fc2580_dvb_get_if_frequencyfunction fc2580_standbyfunction fc2580_g_tunerfunction fc2580_s_tunerfunction fc2580_g_frequencyfunction fc2580_s_frequencyfunction fc2580_enum_freq_bandsfunction fc2580_s_ctrlfunction fc2580_probefunction fc2580_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* FCI FC2580 silicon tuner driver
*
* Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
*/
#include "fc2580_priv.h"
/*
* TODO:
* I2C write and read works only for one single register. Multiple registers
* could not be accessed using normal register address auto-increment.
* There could be (very likely) register to change that behavior....
*/
/* write single register conditionally only when value differs from 0xff
* XXX: This is special routine meant only for writing fc2580_freq_regs_lut[]
* values. Do not use for the other purposes. */
static int fc2580_wr_reg_ff(struct fc2580_dev *dev, u8 reg, u8 val)
{
if (val == 0xff)
return 0;
else
return regmap_write(dev->regmap, reg, val);
}
static int fc2580_set_params(struct fc2580_dev *dev)
{
struct i2c_client *client = dev->client;
int ret, i;
unsigned int uitmp, div_ref, div_ref_val, div_n, k, k_cw, div_out;
u64 f_vco;
u8 synth_config;
unsigned long timeout;
if (!dev->active) {
dev_dbg(&client->dev, "tuner is sleeping\n");
return 0;
}
/*
* Fractional-N synthesizer
*
* +---------------------------------------+
* v |
* Fref +----+ +----+ +-------+ +----+ +------+ +---+
* ------> | /R | --> | PD | --> | VCO | ------> | /2 | --> | /N.F | <-- | K |
* +----+ +----+ +-------+ +----+ +------+ +---+
* |
* |
* v
* +-------+ Fout
* | /Rout | ------>
* +-------+
*/
for (i = 0; i < ARRAY_SIZE(fc2580_pll_lut); i++) {
if (dev->f_frequency <= fc2580_pll_lut[i].freq)
break;
}
if (i == ARRAY_SIZE(fc2580_pll_lut)) {
ret = -EINVAL;
goto err;
}
#define DIV_PRE_N 2
#define F_REF dev->clk
div_out = fc2580_pll_lut[i].div_out;
f_vco = (u64) dev->f_frequency * div_out;
synth_config = fc2580_pll_lut[i].band;
if (f_vco < 2600000000ULL)
synth_config |= 0x06;
else
synth_config |= 0x0e;
/* select reference divider R (keep PLL div N in valid range) */
#define DIV_N_MIN 76
if (f_vco >= div_u64((u64) DIV_PRE_N * DIV_N_MIN * F_REF, 1)) {
div_ref = 1;
div_ref_val = 0x00;
} else if (f_vco >= div_u64((u64) DIV_PRE_N * DIV_N_MIN * F_REF, 2)) {
div_ref = 2;
div_ref_val = 0x10;
} else {
div_ref = 4;
div_ref_val = 0x20;
}
/* calculate PLL integer and fractional control word */
uitmp = DIV_PRE_N * F_REF / div_ref;
Annotation
- Immediate include surface: `fc2580_priv.h`.
- Detected declarations: `function Copyright`, `function fc2580_set_params`, `function fc2580_init`, `function fc2580_sleep`, `function fc2580_dvb_set_params`, `function fc2580_dvb_init`, `function fc2580_dvb_sleep`, `function fc2580_dvb_get_if_frequency`, `function fc2580_standby`, `function fc2580_g_tuner`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.