drivers/gpu/drm/verisilicon/vs_crtc.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/verisilicon/vs_crtc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/verisilicon/vs_crtc.c- Extension
.c- Size
- 5561 bytes
- Lines
- 199
- 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.
- 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/clk.hlinux/regmap.hlinux/units.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_print.hdrm/drm_managed.hdrm/drm_vblank_helper.hvs_crtc_regs.hvs_crtc.hvs_dc.hvs_dc_top_regs.hvs_drm.hvs_plane.h
Detected Declarations
function Copyrightfunction vs_crtc_atomic_enablefunction vs_crtc_mode_set_nofbfunction vs_crtc_mode_validfunction vs_crtc_mode_fixupfunction vs_crtc_enable_vblankfunction vs_crtc_disable_vblank
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2025 Icenowy Zheng <uwu@icenowy.me>
*/
#include <linux/clk.h>
#include <linux/regmap.h>
#include <linux/units.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_print.h>
#include <drm/drm_managed.h>
#include <drm/drm_vblank_helper.h>
#include "vs_crtc_regs.h"
#include "vs_crtc.h"
#include "vs_dc.h"
#include "vs_dc_top_regs.h"
#include "vs_drm.h"
#include "vs_plane.h"
static void vs_crtc_atomic_disable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
struct vs_dc *dc = vcrtc->dc;
unsigned int output = vcrtc->id;
drm_crtc_vblank_off(crtc);
clk_disable_unprepare(dc->pix_clk[output]);
}
static void vs_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
struct vs_dc *dc = vcrtc->dc;
unsigned int output = vcrtc->id;
drm_WARN_ON(&dc->drm_dev->base,
clk_prepare_enable(dc->pix_clk[output]));
drm_crtc_vblank_on(crtc);
}
static void vs_crtc_mode_set_nofb(struct drm_crtc *crtc)
{
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
struct vs_dc *dc = vcrtc->dc;
unsigned int output = vcrtc->id;
regmap_write(dc->regs, VSDC_DISP_HSIZE(output),
VSDC_DISP_HSIZE_DISP(mode->hdisplay) |
VSDC_DISP_HSIZE_TOTAL(mode->htotal));
regmap_write(dc->regs, VSDC_DISP_VSIZE(output),
VSDC_DISP_VSIZE_DISP(mode->vdisplay) |
VSDC_DISP_VSIZE_TOTAL(mode->vtotal));
regmap_write(dc->regs, VSDC_DISP_HSYNC(output),
VSDC_DISP_HSYNC_START(mode->hsync_start) |
VSDC_DISP_HSYNC_END(mode->hsync_end) |
VSDC_DISP_HSYNC_EN);
if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
regmap_set_bits(dc->regs, VSDC_DISP_HSYNC(output),
VSDC_DISP_HSYNC_POL);
regmap_write(dc->regs, VSDC_DISP_VSYNC(output),
VSDC_DISP_VSYNC_START(mode->vsync_start) |
VSDC_DISP_VSYNC_END(mode->vsync_end) |
VSDC_DISP_VSYNC_EN);
if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
regmap_set_bits(dc->regs, VSDC_DISP_VSYNC(output),
VSDC_DISP_VSYNC_POL);
WARN_ON(clk_set_rate(dc->pix_clk[output], mode->crtc_clock * 1000));
}
static enum drm_mode_status
vs_crtc_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode *mode)
{
struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
struct vs_dc *dc = vcrtc->dc;
unsigned int output = vcrtc->id;
long rate;
if (mode->htotal > VSDC_DISP_TIMING_VALUE_MAX)
return MODE_BAD_HVALUE;
if (mode->vtotal > VSDC_DISP_TIMING_VALUE_MAX)
return MODE_BAD_VVALUE;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/regmap.h`, `linux/units.h`, `drm/drm_atomic.h`, `drm/drm_atomic_helper.h`, `drm/drm_print.h`, `drm/drm_managed.h`, `drm/drm_vblank_helper.h`.
- Detected declarations: `function Copyright`, `function vs_crtc_atomic_enable`, `function vs_crtc_mode_set_nofb`, `function vs_crtc_mode_valid`, `function vs_crtc_mode_fixup`, `function vs_crtc_enable_vblank`, `function vs_crtc_disable_vblank`.
- 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.