drivers/media/platform/renesas/vsp1/vsp1_hgt.c
Source file repositories/reference/linux-study-clean/drivers/media/platform/renesas/vsp1/vsp1_hgt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/platform/renesas/vsp1/vsp1_hgt.c- Extension
.c- Size
- 5646 bytes
- Lines
- 214
- 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/device.hlinux/gfp.hmedia/v4l2-subdev.hmedia/videobuf2-vmalloc.hvsp1.hvsp1_dl.hvsp1_hgt.h
Detected Declarations
function Copyrightfunction vsp1_hgt_writefunction vsp1_hgt_frame_endfunction hgt_hue_areas_try_ctrlfunction hgt_hue_areas_s_ctrlfunction hgt_configure_streamfunction scoped_guard
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* vsp1_hgt.c -- R-Car VSP1 Histogram Generator 2D
*
* Copyright (C) 2016 Renesas Electronics Corporation
*
* Contact: Niklas Söderlund (niklas.soderlund@ragnatech.se)
*/
#include <linux/device.h>
#include <linux/gfp.h>
#include <media/v4l2-subdev.h>
#include <media/videobuf2-vmalloc.h>
#include "vsp1.h"
#include "vsp1_dl.h"
#include "vsp1_hgt.h"
#define HGT_DATA_SIZE ((2 + 6 * 32) * 4)
/* -----------------------------------------------------------------------------
* Device Access
*/
static inline u32 vsp1_hgt_read(struct vsp1_hgt *hgt, u32 reg)
{
return vsp1_read(hgt->histo.entity.vsp1, reg);
}
static inline void vsp1_hgt_write(struct vsp1_hgt *hgt,
struct vsp1_dl_body *dlb, u32 reg, u32 data)
{
vsp1_dl_body_write(dlb, reg, data);
}
/* -----------------------------------------------------------------------------
* Frame End Handler
*/
void vsp1_hgt_frame_end(struct vsp1_entity *entity)
{
struct vsp1_hgt *hgt = to_hgt(&entity->subdev);
struct vsp1_histogram_buffer *buf;
unsigned int m;
unsigned int n;
u32 *data;
buf = vsp1_histogram_buffer_get(&hgt->histo);
if (!buf)
return;
data = buf->addr;
*data++ = vsp1_hgt_read(hgt, VI6_HGT_MAXMIN);
*data++ = vsp1_hgt_read(hgt, VI6_HGT_SUM);
for (m = 0; m < 6; ++m)
for (n = 0; n < 32; ++n)
*data++ = vsp1_hgt_read(hgt, VI6_HGT_HISTO(m, n));
vsp1_histogram_buffer_complete(&hgt->histo, buf, HGT_DATA_SIZE);
}
/* -----------------------------------------------------------------------------
* Controls
*/
#define V4L2_CID_VSP1_HGT_HUE_AREAS (V4L2_CID_USER_BASE | 0x1001)
static int hgt_hue_areas_try_ctrl(struct v4l2_ctrl *ctrl)
{
const u8 *values = ctrl->p_new.p_u8;
unsigned int i;
/*
* The hardware has constraints on the hue area boundaries beyond the
* control min, max and step. The values must match one of the following
* expressions.
*
* 0L <= 0U <= 1L <= 1U <= 2L <= 2U <= 3L <= 3U <= 4L <= 4U <= 5L <= 5U
* 0U <= 1L <= 1U <= 2L <= 2U <= 3L <= 3U <= 4L <= 4U <= 5L <= 5U <= 0L
*
* Start by verifying the common part...
*/
for (i = 1; i < (HGT_NUM_HUE_AREAS * 2) - 1; ++i) {
if (values[i] > values[i+1])
return -EINVAL;
}
Annotation
- Immediate include surface: `linux/device.h`, `linux/gfp.h`, `media/v4l2-subdev.h`, `media/videobuf2-vmalloc.h`, `vsp1.h`, `vsp1_dl.h`, `vsp1_hgt.h`.
- Detected declarations: `function Copyright`, `function vsp1_hgt_write`, `function vsp1_hgt_frame_end`, `function hgt_hue_areas_try_ctrl`, `function hgt_hue_areas_s_ctrl`, `function hgt_configure_stream`, `function scoped_guard`.
- 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.