drivers/media/pci/saa7134/saa7134-video.c
Source file repositories/reference/linux-study-clean/drivers/media/pci/saa7134/saa7134-video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/pci/saa7134/saa7134-video.c- Extension
.c- Size
- 50686 bytes
- Lines
- 1878
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/slab.hlinux/sort.hmedia/v4l2-common.hmedia/v4l2-event.hmedia/i2c/saa6588.h
Detected Declarations
function format_by_fourccfunction set_tvnormfunction video_muxfunction saa7134_set_decoderfunction saa7134_set_tvnorm_hwfunction set_h_prescalefunction set_v_scalefunction set_sizefunction saa7134_enable_analog_tunerfunction buffer_activatefunction buffer_initfunction buffer_preparefunction queue_setupfunction saa7134_vb2_buffer_queuefunction saa7134_vb2_start_streamingfunction list_for_each_entry_safefunction saa7134_vb2_stop_streamingfunction saa7134_s_ctrlfunction video_openfunction video_releasefunction radio_readfunction radio_pollfunction saa7134_try_get_set_fmt_vbi_capfunction saa7134_g_fmt_vid_capfunction saa7134_try_fmt_vid_capfunction saa7134_s_fmt_vid_capfunction saa7134_enum_inputfunction saa7134_g_inputfunction saa7134_s_inputfunction saa7134_querycapfunction saa7134_s_stdfunction saa7134_g_stdfunction saa7134_read_stdfunction saa7134_querystdfunction saa7134_g_pixelaspectfunction saa7134_g_selectionfunction saa7134_s_selectionfunction saa7134_g_tunerfunction saa7134_s_tunerfunction saa7134_g_frequencyfunction saa7134_s_frequencyfunction saa7134_enum_fmt_vid_capfunction vidioc_g_registerfunction vidioc_s_registerfunction radio_g_tunerfunction radio_s_tunerfunction saa7134_video_init1function saa7134_video_fini
Annotated Snippet
if (link->sink->entity == dev->decoder) {
found_link = link;
if (link->flags & MEDIA_LNK_FL_ENABLED)
active_links++;
break;
}
}
if (active_links == 1 || !found_link)
return 0;
source = found_link->source->entity;
list_for_each_entry(link, &source->links, list) {
struct media_entity *sink;
int flags = 0;
sink = link->sink->entity;
if (sink == dev->decoder)
flags = MEDIA_LNK_FL_ENABLED;
ret = media_entity_setup_link(link, flags);
if (ret) {
pr_err("Couldn't change link %s->%s to %s. Error %d\n",
source->name, sink->name,
flags ? "enabled" : "disabled",
ret);
return ret;
}
}
#endif
return 0;
}
/* ------------------------------------------------------------------ */
static int buffer_activate(struct saa7134_dev *dev,
struct saa7134_buf *buf,
struct saa7134_buf *next)
{
struct saa7134_dmaqueue *dmaq = buf->vb2.vb2_buf.vb2_queue->drv_priv;
unsigned long base,control,bpl;
unsigned long bpl_uv, lines_uv, base2, base3; /* planar */
video_dbg("buffer_activate buf=%p\n", buf);
buf->top_seen = 0;
set_size(dev, TASK_A, dev->width, dev->height,
V4L2_FIELD_HAS_BOTH(dev->field));
if (dev->fmt->yuv)
saa_andorb(SAA7134_DATA_PATH(TASK_A), 0x3f, 0x03);
else
saa_andorb(SAA7134_DATA_PATH(TASK_A), 0x3f, 0x01);
saa_writeb(SAA7134_OFMT_VIDEO_A, dev->fmt->pm);
/* DMA: setup channel 0 (= Video Task A0) */
base = saa7134_buffer_base(buf);
if (dev->fmt->planar)
bpl = dev->width;
else
bpl = (dev->width * dev->fmt->depth) / 8;
control = SAA7134_RS_CONTROL_BURST_16 |
SAA7134_RS_CONTROL_ME |
(dmaq->pt.dma >> 12);
if (dev->fmt->bswap)
control |= SAA7134_RS_CONTROL_BSWAP;
if (dev->fmt->wswap)
control |= SAA7134_RS_CONTROL_WSWAP;
if (V4L2_FIELD_HAS_BOTH(dev->field)) {
/* interlaced */
saa_writel(SAA7134_RS_BA1(0),base);
saa_writel(SAA7134_RS_BA2(0),base+bpl);
saa_writel(SAA7134_RS_PITCH(0),bpl*2);
} else {
/* non-interlaced */
saa_writel(SAA7134_RS_BA1(0),base);
saa_writel(SAA7134_RS_BA2(0),base);
saa_writel(SAA7134_RS_PITCH(0),bpl);
}
saa_writel(SAA7134_RS_CONTROL(0),control);
if (dev->fmt->planar) {
/* DMA: setup channel 4+5 (= planar task A) */
bpl_uv = bpl >> dev->fmt->hshift;
lines_uv = dev->height >> dev->fmt->vshift;
base2 = base + bpl * dev->height;
base3 = base2 + bpl_uv * lines_uv;
if (dev->fmt->uvswap)
swap(base2, base3);
video_dbg("uv: bpl=%ld lines=%ld base2/3=%ld/%ld\n",
Annotation
- Immediate include surface: `saa7134.h`, `saa7134-reg.h`, `linux/init.h`, `linux/list.h`, `linux/module.h`, `linux/kernel.h`, `linux/slab.h`, `linux/sort.h`.
- Detected declarations: `function format_by_fourcc`, `function set_tvnorm`, `function video_mux`, `function saa7134_set_decoder`, `function saa7134_set_tvnorm_hw`, `function set_h_prescale`, `function set_v_scale`, `function set_size`, `function saa7134_enable_analog_tuner`, `function buffer_activate`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.