drivers/gpu/drm/sun4i/sun4i_backend.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/sun4i/sun4i_backend.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/sun4i/sun4i_backend.c- Extension
.c- Size
- 30127 bytes
- Lines
- 1050
- 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/component.hlinux/list.hlinux/module.hlinux/of_device.hlinux/of_graph.hlinux/dma-mapping.hlinux/platform_device.hlinux/reset.hdrm/drm_atomic.hdrm/drm_atomic_helper.hdrm/drm_blend.hdrm/drm_crtc.hdrm/drm_fb_dma_helper.hdrm/drm_fourcc.hdrm/drm_framebuffer.hdrm/drm_gem_dma_helper.hdrm/drm_print.hdrm/drm_probe_helper.hsun4i_backend.hsun4i_drv.hsun4i_frontend.hsun4i_layer.hsunxi_engine.h
Detected Declarations
struct sun4i_backend_quirksfunction sun4i_backend_apply_color_correctionfunction sun4i_backend_disable_color_correctionfunction sun4i_backend_commitfunction sun4i_backend_layer_enablefunction sun4i_backend_drm_format_to_layerfunction sun4i_backend_format_is_supportedfunction sun4i_backend_update_layer_coordfunction sun4i_backend_update_yuv_formatfunction sun4i_backend_update_layer_formatsfunction sun4i_backend_update_layer_frontendfunction sun4i_backend_update_yuv_bufferfunction sun4i_backend_update_layer_bufferfunction sun4i_backend_update_layer_zposfunction sun4i_backend_cleanup_layerfunction sun4i_backend_plane_uses_scalerfunction sun4i_backend_plane_uses_frontendfunction sun4i_backend_plane_is_supportedfunction sun4i_backend_atomic_beginfunction sun4i_backend_atomic_checkfunction drm_for_each_plane_maskfunction sun4i_backend_vblank_quirkfunction sun4i_backend_mode_setfunction sun4i_backend_init_satfunction sun4i_backend_free_satfunction sun4i_backend_of_get_idfunction for_each_available_child_of_nodefunction list_for_each_entryfunction sun4i_backend_bindfunction sun4i_backend_unbindfunction sun4i_backend_probefunction sun4i_backend_remove
Annotated Snippet
struct sun4i_backend_quirks {
/* backend <-> TCON muxing selection done in backend */
bool needs_output_muxing;
/* alpha at the lowest z position is not always supported */
bool supports_lowest_plane_alpha;
};
static const u32 sunxi_rgb2yuv_coef[12] = {
0x00000107, 0x00000204, 0x00000064, 0x00000108,
0x00003f69, 0x00003ed6, 0x000001c1, 0x00000808,
0x000001c1, 0x00003e88, 0x00003fb8, 0x00000808
};
static void sun4i_backend_apply_color_correction(struct sunxi_engine *engine)
{
int i;
DRM_DEBUG_DRIVER("Applying RGB to YUV color correction\n");
/* Set color correction */
regmap_write(engine->regs, SUN4I_BACKEND_OCCTL_REG,
SUN4I_BACKEND_OCCTL_ENABLE);
for (i = 0; i < 12; i++)
regmap_write(engine->regs, SUN4I_BACKEND_OCRCOEF_REG(i),
sunxi_rgb2yuv_coef[i]);
}
static void sun4i_backend_disable_color_correction(struct sunxi_engine *engine)
{
DRM_DEBUG_DRIVER("Disabling color correction\n");
/* Disable color correction */
regmap_update_bits(engine->regs, SUN4I_BACKEND_OCCTL_REG,
SUN4I_BACKEND_OCCTL_ENABLE, 0);
}
static void sun4i_backend_commit(struct sunxi_engine *engine,
struct drm_crtc *crtc,
struct drm_atomic_commit *state)
{
DRM_DEBUG_DRIVER("Committing changes\n");
regmap_write(engine->regs, SUN4I_BACKEND_REGBUFFCTL_REG,
SUN4I_BACKEND_REGBUFFCTL_AUTOLOAD_DIS |
SUN4I_BACKEND_REGBUFFCTL_LOADCTL);
}
void sun4i_backend_layer_enable(struct sun4i_backend *backend,
int layer, bool enable)
{
u32 val;
DRM_DEBUG_DRIVER("%sabling layer %d\n", enable ? "En" : "Dis",
layer);
if (enable)
val = SUN4I_BACKEND_MODCTL_LAY_EN(layer);
else
val = 0;
regmap_update_bits(backend->engine.regs, SUN4I_BACKEND_MODCTL_REG,
SUN4I_BACKEND_MODCTL_LAY_EN(layer), val);
}
static int sun4i_backend_drm_format_to_layer(u32 format, u32 *mode)
{
switch (format) {
case DRM_FORMAT_ARGB8888:
*mode = SUN4I_BACKEND_LAY_FBFMT_ARGB8888;
break;
case DRM_FORMAT_ARGB4444:
*mode = SUN4I_BACKEND_LAY_FBFMT_ARGB4444;
break;
case DRM_FORMAT_ARGB1555:
*mode = SUN4I_BACKEND_LAY_FBFMT_ARGB1555;
break;
case DRM_FORMAT_RGBA5551:
*mode = SUN4I_BACKEND_LAY_FBFMT_RGBA5551;
break;
case DRM_FORMAT_RGBA4444:
*mode = SUN4I_BACKEND_LAY_FBFMT_RGBA4444;
break;
case DRM_FORMAT_XRGB8888:
Annotation
- Immediate include surface: `linux/component.h`, `linux/list.h`, `linux/module.h`, `linux/of_device.h`, `linux/of_graph.h`, `linux/dma-mapping.h`, `linux/platform_device.h`, `linux/reset.h`.
- Detected declarations: `struct sun4i_backend_quirks`, `function sun4i_backend_apply_color_correction`, `function sun4i_backend_disable_color_correction`, `function sun4i_backend_commit`, `function sun4i_backend_layer_enable`, `function sun4i_backend_drm_format_to_layer`, `function sun4i_backend_format_is_supported`, `function sun4i_backend_update_layer_coord`, `function sun4i_backend_update_yuv_format`, `function sun4i_backend_update_layer_formats`.
- 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.