drivers/media/tuners/msi001.c
Source file repositories/reference/linux-study-clean/drivers/media/tuners/msi001.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/tuners/msi001.c- Extension
.c- Size
- 12556 bytes
- Lines
- 511
- 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
linux/module.hlinux/gcd.hmedia/v4l2-device.hmedia/v4l2-ctrls.h
Detected Declarations
struct msi001_devfunction msi001_wregfunction msi001_set_gainfunction msi001_set_tunerfunction msi001_standbyfunction msi001_g_tunerfunction msi001_s_tunerfunction msi001_g_frequencyfunction msi001_s_frequencyfunction msi001_enum_freq_bandsfunction msi001_s_ctrlfunction msi001_probefunction msi001_remove
Annotated Snippet
struct msi001_dev {
struct spi_device *spi;
struct v4l2_subdev sd;
/* Controls */
struct v4l2_ctrl_handler hdl;
struct v4l2_ctrl *bandwidth_auto;
struct v4l2_ctrl *bandwidth;
struct v4l2_ctrl *lna_gain;
struct v4l2_ctrl *mixer_gain;
struct v4l2_ctrl *if_gain;
unsigned int f_tuner;
};
static inline struct msi001_dev *sd_to_msi001_dev(struct v4l2_subdev *sd)
{
return container_of(sd, struct msi001_dev, sd);
}
static int msi001_wreg(struct msi001_dev *dev, u32 data)
{
/* Register format: 4 bits addr + 20 bits value */
return spi_write(dev->spi, &data, 3);
};
static int msi001_set_gain(struct msi001_dev *dev, int lna_gain, int mixer_gain,
int if_gain)
{
struct spi_device *spi = dev->spi;
int ret;
u32 reg;
dev_dbg(&spi->dev, "lna=%d mixer=%d if=%d\n",
lna_gain, mixer_gain, if_gain);
reg = 1 << 0;
reg |= (59 - if_gain) << 4;
reg |= 0 << 10;
reg |= (1 - mixer_gain) << 12;
reg |= (1 - lna_gain) << 13;
reg |= 4 << 14;
reg |= 0 << 17;
ret = msi001_wreg(dev, reg);
if (ret)
goto err;
return 0;
err:
dev_dbg(&spi->dev, "failed %d\n", ret);
return ret;
};
static int msi001_set_tuner(struct msi001_dev *dev)
{
struct spi_device *spi = dev->spi;
int ret, i;
unsigned int uitmp, div_n, k, k_thresh, k_frac, div_lo, f_if1;
u32 reg;
u64 f_vco;
u8 mode, filter_mode;
static const struct {
u32 rf;
u8 mode;
u8 div_lo;
} band_lut[] = {
{ 50000000, 0xe1, 16}, /* AM_MODE2, antenna 2 */
{108000000, 0x42, 32}, /* VHF_MODE */
{330000000, 0x44, 16}, /* B3_MODE */
{960000000, 0x48, 4}, /* B45_MODE */
{ ~0U, 0x50, 2}, /* BL_MODE */
};
static const struct {
u32 freq;
u8 filter_mode;
} if_freq_lut[] = {
{ 0, 0x03}, /* Zero IF */
{ 450000, 0x02}, /* 450 kHz IF */
{1620000, 0x01}, /* 1.62 MHz IF */
{2048000, 0x00}, /* 2.048 MHz IF */
};
static const struct {
u32 freq;
u8 val;
} bandwidth_lut[] = {
{ 200000, 0x00}, /* 200 kHz */
{ 300000, 0x01}, /* 300 kHz */
{ 600000, 0x02}, /* 600 kHz */
{1536000, 0x03}, /* 1.536 MHz */
Annotation
- Immediate include surface: `linux/module.h`, `linux/gcd.h`, `media/v4l2-device.h`, `media/v4l2-ctrls.h`.
- Detected declarations: `struct msi001_dev`, `function msi001_wreg`, `function msi001_set_gain`, `function msi001_set_tuner`, `function msi001_standby`, `function msi001_g_tuner`, `function msi001_s_tuner`, `function msi001_g_frequency`, `function msi001_s_frequency`, `function msi001_enum_freq_bands`.
- 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.