drivers/gpu/drm/verisilicon/vs_cursor_plane.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/verisilicon/vs_cursor_plane.c- Extension
.c- Size
- 8181 bytes
- Lines
- 273
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/log2.hlinux/regmap.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_crtc.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_atomic_helper.hdrm/drm_modeset_helper_vtables.hdrm/drm_plane.hdrm/drm_print.hvs_crtc.hvs_plane.hvs_dc.hvs_hwdb.hvs_cursor_plane_regs.h
Detected Declarations
function Copyrightfunction vs_cursor_plane_atomic_checkfunction vs_cursor_plane_commitfunction vs_cursor_plane_atomic_enablefunction vs_cursor_plane_atomic_disablefunction vs_cursor_plane_atomic_update
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2026 Institute of Software, Chinese Academy of Sciences (ISCAS)
*
* Authors:
* Icenowy Zheng <zhengxingda@iscas.ac.cn>
*/
#include <linux/log2.h>
#include <linux/regmap.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_plane.h>
#include <drm/drm_print.h>
#include "vs_crtc.h"
#include "vs_plane.h"
#include "vs_dc.h"
#include "vs_hwdb.h"
#include "vs_cursor_plane_regs.h"
#define VSDC_MIN_CURSOR_SIZE 32
#define VSDC_MAX_CURSOR_SIZE 256
#define VSDC_CURSOR_LOCATION_MAX_POSITIVE BIT_MASK(15)
#define VSDC_CURSOR_LOCATION_MAX_NEGATIVE BIT_MASK(5)
static bool vs_cursor_plane_check_coord(int32_t coord)
{
if (coord >= 0)
return coord <= VSDC_CURSOR_LOCATION_MAX_POSITIVE;
else
return (-coord) <= VSDC_CURSOR_LOCATION_MAX_NEGATIVE;
}
static int vs_cursor_plane_atomic_check(struct drm_plane *plane,
struct drm_atomic_commit *state)
{
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
plane);
struct drm_crtc *crtc = new_plane_state->crtc;
struct drm_framebuffer *fb = new_plane_state->fb;
struct drm_crtc_state *crtc_state = NULL;
struct vs_crtc *vcrtc;
struct vs_dc *dc;
int ret;
if (crtc)
crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
ret = drm_atomic_helper_check_plane_state(new_plane_state,
crtc_state,
DRM_PLANE_NO_SCALING,
DRM_PLANE_NO_SCALING,
true, true);
if (ret)
return ret;
if (!new_plane_state->visible)
return 0; /* Skip validity check */
vcrtc = drm_crtc_to_vs_crtc(crtc);
dc = vcrtc->dc;
/* Only certain PoT square sizes is supported. */
if (!is_power_of_2(new_plane_state->crtc_w) ||
new_plane_state->crtc_w < VSDC_MIN_CURSOR_SIZE ||
new_plane_state->crtc_w > dc->identity.max_cursor_size)
return -EINVAL;
if (new_plane_state->crtc_w != new_plane_state->crtc_h)
return -EINVAL;
/* Check if the cursor is inside the register fields' range */
if (!vs_cursor_plane_check_coord(new_plane_state->crtc_x) ||
!vs_cursor_plane_check_coord(new_plane_state->crtc_y))
return -EINVAL;
/* Extra line padding isn't supported */
if (fb->pitches[0] !=
drm_format_info_min_pitch(fb->format, 0, new_plane_state->crtc_w))
return -EINVAL;
return 0;
Annotation
- Immediate include surface: `linux/log2.h`, `linux/regmap.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_crtc.h`, `drm/drm_fourcc.h`, `drm/drm_framebuffer.h`, `drm/drm_gem_atomic_helper.h`.
- Detected declarations: `function Copyright`, `function vs_cursor_plane_atomic_check`, `function vs_cursor_plane_commit`, `function vs_cursor_plane_atomic_enable`, `function vs_cursor_plane_atomic_disable`, `function vs_cursor_plane_atomic_update`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.