drivers/media/platform/renesas/vsp1/vsp1_video.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/renesas/vsp1/vsp1_video.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/renesas/vsp1/vsp1_video.c- Extension
.c- Size
- 33862 bytes
- Lines
- 1292
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/list.hlinux/module.hlinux/mutex.hlinux/slab.hlinux/v4l2-mediabus.hlinux/videodev2.hlinux/wait.hmedia/media-entity.hmedia/v4l2-dev.hmedia/v4l2-fh.hmedia/v4l2-ioctl.hmedia/v4l2-subdev.hmedia/videobuf2-v4l2.hmedia/videobuf2-dma-contig.hvsp1.hvsp1_brx.hvsp1_dl.hvsp1_entity.hvsp1_hgo.hvsp1_hgt.hvsp1_pipe.hvsp1_rwpf.hvsp1_uds.hvsp1_video.h
Detected Declarations
function Copyrightfunction vsp1_video_verify_formatfunction __vsp1_video_try_formatfunction vsp1_video_complete_bufferfunction scoped_guardfunction vsp1_video_frame_endfunction vsp1_video_pipeline_run_partitionfunction vsp1_video_pipeline_runfunction vsp1_video_pipeline_frame_endfunction vsp1_video_pipeline_build_branchfunction vsp1_video_pipeline_buildfunction vsp1_video_pipeline_initfunction vsp1_video_pipeline_releasefunction vsp1_video_pipeline_putfunction vsp1_video_queue_setupfunction vsp1_video_buffer_preparefunction vsp1_video_buffer_queuefunction scoped_guardfunction vsp1_video_pipeline_setup_partitionsfunction list_for_each_entryfunction vsp1_video_setup_pipelinefunction list_for_each_entryfunction vsp1_video_release_buffersfunction vsp1_video_cleanup_pipelinefunction vsp1_video_start_streamingfunction scoped_guardfunction vsp1_video_stop_streamingfunction scoped_guardfunction vsp1_video_querycapfunction vsp1_video_enum_formatfunction vsp1_video_get_formatfunction vsp1_video_try_formatfunction vsp1_video_set_formatfunction vsp1_video_streamonfunction vsp1_video_openfunction vsp1_video_releasefunction vsp1_video_link_validatefunction vsp1_video_suspendfunction scoped_guardfunction vsp1_video_resumefunction scoped_guardfunction vsp1_video_cleanup
Annotated Snippet
if (xrgb_formats[i][0] == pix->pixelformat) {
pix->pixelformat = xrgb_formats[i][1];
break;
}
}
/*
* Retrieve format information and select the default format if the
* requested format isn't supported.
*/
info = vsp1_get_format_info(video->vsp1, pix->pixelformat);
if (info == NULL)
info = vsp1_get_format_info(video->vsp1, VSP1_VIDEO_DEF_FORMAT);
pix->pixelformat = info->fourcc;
pix->field = V4L2_FIELD_NONE;
/*
* Adjust the colour space fields. On capture devices, userspace needs
* to set the V4L2_PIX_FMT_FLAG_SET_CSC to override the defaults. Reset
* all fields to *_DEFAULT if the flag isn't set, to then handle
* capture and output devices in the same way.
*/
if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
!(pix->flags & V4L2_PIX_FMT_FLAG_SET_CSC)) {
pix->colorspace = V4L2_COLORSPACE_DEFAULT;
pix->xfer_func = V4L2_XFER_FUNC_DEFAULT;
pix->ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
pix->quantization = V4L2_QUANTIZATION_DEFAULT;
}
vsp1_adjust_color_space(info->mbus, &pix->colorspace, &pix->xfer_func,
&pix->ycbcr_enc, &pix->quantization);
memset(pix->reserved, 0, sizeof(pix->reserved));
/* Align the width and height for YUV 4:2:2 and 4:2:0 formats. */
width = round_down(width, info->hsub);
height = round_down(height, info->vsub);
/* Clamp the width and height. */
pix->width = clamp(width, info->hsub, VSP1_VIDEO_MAX_WIDTH);
pix->height = clamp(height, info->vsub, VSP1_VIDEO_MAX_HEIGHT);
/*
* Compute and clamp the stride and image size. While not documented in
* the datasheet, strides not aligned to a multiple of 128 bytes result
* in image corruption.
*/
for (i = 0; i < min(info->planes, 2U); ++i) {
unsigned int hsub = i > 0 ? info->hsub : 1;
unsigned int vsub = i > 0 ? info->vsub : 1;
unsigned int align = 128;
unsigned int bpl;
bpl = clamp_t(unsigned int, pix->plane_fmt[i].bytesperline,
pix->width / hsub * info->bpp[i] / 8,
round_down(65535U, align));
pix->plane_fmt[i].bytesperline = round_up(bpl, align);
pix->plane_fmt[i].sizeimage = pix->plane_fmt[i].bytesperline
* pix->height / vsub;
}
if (info->planes == 3) {
/* The second and third planes must have the same stride. */
pix->plane_fmt[2].bytesperline = pix->plane_fmt[1].bytesperline;
pix->plane_fmt[2].sizeimage = pix->plane_fmt[1].sizeimage;
}
pix->num_planes = info->planes;
if (fmtinfo)
*fmtinfo = info;
return 0;
}
/* -----------------------------------------------------------------------------
* Pipeline Management
*/
/*
* vsp1_video_complete_buffer - Complete the current buffer
* @video: the video node
*
* This function completes the current buffer by filling its sequence number,
* time stamp and payload size, and hands it back to the vb2 core.
*
* Return the next queued buffer or NULL if the queue is empty.
Annotation
- Immediate include surface: `linux/list.h`, `linux/module.h`, `linux/mutex.h`, `linux/slab.h`, `linux/v4l2-mediabus.h`, `linux/videodev2.h`, `linux/wait.h`, `media/media-entity.h`.
- Detected declarations: `function Copyright`, `function vsp1_video_verify_format`, `function __vsp1_video_try_format`, `function vsp1_video_complete_buffer`, `function scoped_guard`, `function vsp1_video_frame_end`, `function vsp1_video_pipeline_run_partition`, `function vsp1_video_pipeline_run`, `function vsp1_video_pipeline_frame_end`, `function vsp1_video_pipeline_build_branch`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source 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.