drivers/media/platform/renesas/vsp1/vsp1_histo.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/renesas/vsp1/vsp1_histo.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/renesas/vsp1/vsp1_histo.c- Extension
.c- Size
- 16236 bytes
- Lines
- 592
- 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/device.hlinux/gfp.hmedia/v4l2-ioctl.hmedia/v4l2-subdev.hmedia/videobuf2-vmalloc.hvsp1.hvsp1_histo.hvsp1_pipe.h
Detected Declarations
function Copyrightfunction vsp1_histogram_buffer_getfunction vsp1_histogram_buffer_completefunction histo_queue_setupfunction histo_buffer_preparefunction histo_buffer_queuefunction histo_start_streamingfunction histo_stop_streamingfunction histo_enum_mbus_codefunction histo_enum_frame_sizefunction histo_get_selectionfunction histo_set_cropfunction histo_set_composefunction histo_set_selectionfunction histo_set_formatfunction histo_v4l2_querycapfunction histo_v4l2_enum_formatfunction histo_v4l2_get_formatfunction vsp1_histogram_cleanupfunction vsp1_histogram_destroyfunction vsp1_histogram_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* vsp1_histo.c -- R-Car VSP1 Histogram API
*
* Copyright (C) 2016 Renesas Electronics Corporation
* Copyright (C) 2016 Laurent Pinchart
*
* Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
*/
#include <linux/device.h>
#include <linux/gfp.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-subdev.h>
#include <media/videobuf2-vmalloc.h>
#include "vsp1.h"
#include "vsp1_histo.h"
#include "vsp1_pipe.h"
#define HISTO_MIN_SIZE 4U
#define HISTO_MAX_SIZE 8192U
/* -----------------------------------------------------------------------------
* Buffer Operations
*/
static inline struct vsp1_histogram_buffer *
to_vsp1_histogram_buffer(struct vb2_v4l2_buffer *vbuf)
{
return container_of(vbuf, struct vsp1_histogram_buffer, buf);
}
struct vsp1_histogram_buffer *
vsp1_histogram_buffer_get(struct vsp1_histogram *histo)
{
struct vsp1_histogram_buffer *buf;
guard(spinlock)(&histo->irqlock);
if (list_empty(&histo->irqqueue))
return NULL;
buf = list_first_entry(&histo->irqqueue, struct vsp1_histogram_buffer,
queue);
list_del(&buf->queue);
histo->readout = true;
return buf;
}
void vsp1_histogram_buffer_complete(struct vsp1_histogram *histo,
struct vsp1_histogram_buffer *buf,
size_t size)
{
struct vsp1_pipeline *pipe = histo->entity.pipe;
/*
* The pipeline pointer is guaranteed to be valid as this function is
* called from the frame completion interrupt handler, which can only
* occur when video streaming is active.
*/
buf->buf.sequence = pipe->sequence;
buf->buf.vb2_buf.timestamp = ktime_get_ns();
vb2_set_plane_payload(&buf->buf.vb2_buf, 0, size);
vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_DONE);
guard(spinlock)(&histo->irqlock);
histo->readout = false;
wake_up(&histo->wait_queue);
}
/* -----------------------------------------------------------------------------
* videobuf2 Queue Operations
*/
static int histo_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
unsigned int *nplanes, unsigned int sizes[],
struct device *alloc_devs[])
{
struct vsp1_histogram *histo = vb2_get_drv_priv(vq);
if (*nplanes) {
if (*nplanes != 1)
return -EINVAL;
if (sizes[0] < histo->data_size)
return -EINVAL;
Annotation
- Immediate include surface: `linux/device.h`, `linux/gfp.h`, `media/v4l2-ioctl.h`, `media/v4l2-subdev.h`, `media/videobuf2-vmalloc.h`, `vsp1.h`, `vsp1_histo.h`, `vsp1_pipe.h`.
- Detected declarations: `function Copyright`, `function vsp1_histogram_buffer_get`, `function vsp1_histogram_buffer_complete`, `function histo_queue_setup`, `function histo_buffer_prepare`, `function histo_buffer_queue`, `function histo_start_streaming`, `function histo_stop_streaming`, `function histo_enum_mbus_code`, `function histo_enum_frame_size`.
- 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.