drivers/media/pci/saa7134/saa7134-tvaudio.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/saa7134/saa7134-tvaudio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/saa7134/saa7134-tvaudio.c- Extension
.c- Size
- 28580 bytes
- Lines
- 1069
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
saa7134.hsaa7134-reg.hlinux/init.hlinux/list.hlinux/module.hlinux/kernel.hlinux/kthread.hlinux/delay.hlinux/freezer.hasm/div64.h
Detected Declarations
function tvaudio_carr2regfunction tvaudio_setcarrierfunction mute_input_7134function tvaudio_setmodefunction tvaudio_sleepfunction tvaudio_checkcarrierfunction tvaudio_getstereofunction tvaudio_setstereofunction tvaudio_threadfunction saa_dsp_reset_error_bitfunction saa_dsp_wait_bitfunction saa_dsp_writelfunction getstereo_7133function mute_input_7133function tvaudio_thread_ddepfunction saa7134_enable_i2sfunction saa7134_tvaudio_rx2modefunction saa7134_tvaudio_setmutefunction saa7134_tvaudio_setinputfunction saa7134_tvaudio_setvolumefunction saa7134_tvaudio_getstereofunction saa7134_tvaudio_initfunction saa7134_tvaudio_init2function saa7134_tvaudio_closefunction saa7134_tvaudio_finifunction saa7134_tvaudio_do_scanexport saa_dsp_writelexport saa7134_tvaudio_setmute
Annotated Snippet
if (timeout < 0) {
set_current_state(TASK_INTERRUPTIBLE);
schedule();
} else {
schedule_timeout_interruptible
(msecs_to_jiffies(timeout));
}
}
return dev->thread.scan1 != dev->thread.scan2;
}
static int tvaudio_checkcarrier(struct saa7134_dev *dev, struct mainscan *scan)
{
__s32 left,right,value;
if (!(dev->tvnorm->id & scan->std)) {
audio_dbg(1, "skipping %d.%03d MHz [%4s]\n",
scan->carr / 1000, scan->carr % 1000, scan->name);
return 0;
}
if (audio_debug > 1) {
int i;
audio_dbg(1, "debug %d:", scan->carr);
for (i = -150; i <= 150; i += 30) {
tvaudio_setcarrier(dev,scan->carr+i,scan->carr+i);
saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
return -1;
value = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
if (0 == i)
pr_cont(" # %6d # ", value >> 16);
else
pr_cont(" %6d", value >> 16);
}
pr_cont("\n");
}
tvaudio_setcarrier(dev,scan->carr-90,scan->carr-90);
saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
return -1;
left = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
tvaudio_setcarrier(dev,scan->carr+90,scan->carr+90);
saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
if (tvaudio_sleep(dev,SCAN_SAMPLE_DELAY))
return -1;
right = saa_readl(SAA7134_LEVEL_READOUT1 >> 2);
left >>= 16;
right >>= 16;
value = left > right ? left - right : right - left;
audio_dbg(1, "scanning %d.%03d MHz [%4s] => dc is %5d [%d/%d]\n",
scan->carr / 1000, scan->carr % 1000,
scan->name, value, left, right);
return value;
}
static int tvaudio_getstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *audio)
{
__u32 idp, nicam, nicam_status;
int retval = -1;
switch (audio->mode) {
case TVAUDIO_FM_MONO:
return V4L2_TUNER_SUB_MONO;
case TVAUDIO_FM_K_STEREO:
case TVAUDIO_FM_BG_STEREO:
idp = (saa_readb(SAA7134_IDENT_SIF) & 0xe0) >> 5;
audio_dbg(1, "getstereo: fm/stereo: idp=0x%x\n", idp);
if (0x03 == (idp & 0x03))
retval = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
else if (0x05 == (idp & 0x05))
retval = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
else if (0x01 == (idp & 0x01))
retval = V4L2_TUNER_SUB_MONO;
break;
case TVAUDIO_FM_SAT_STEREO:
/* not implemented (yet) */
break;
case TVAUDIO_NICAM_FM:
case TVAUDIO_NICAM_AM:
nicam = saa_readb(SAA7134_AUDIO_STATUS);
audio_dbg(1, "getstereo: nicam=0x%x\n", nicam);
if (nicam & 0x1) {
nicam_status = saa_readb(SAA7134_NICAM_STATUS);
audio_dbg(1, "getstereo: nicam_status=0x%x\n",
nicam_status);
Annotation
- Immediate include surface: `saa7134.h`, `saa7134-reg.h`, `linux/init.h`, `linux/list.h`, `linux/module.h`, `linux/kernel.h`, `linux/kthread.h`, `linux/delay.h`.
- Detected declarations: `function tvaudio_carr2reg`, `function tvaudio_setcarrier`, `function mute_input_7134`, `function tvaudio_setmode`, `function tvaudio_sleep`, `function tvaudio_checkcarrier`, `function tvaudio_getstereo`, `function tvaudio_setstereo`, `function tvaudio_thread`, `function saa_dsp_reset_error_bit`.
- 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.