drivers/gpu/drm/imx/dc/dc-kms.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/imx/dc/dc-kms.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/imx/dc/dc-kms.c- Extension
.c- Size
- 3189 bytes
- Lines
- 138
- 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/of.hlinux/of_graph.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_bridge_connector.hdrm/drm_connector.hdrm/drm_crtc.hdrm/drm_device.hdrm/drm_encoder.hdrm/drm_gem_framebuffer_helper.hdrm/drm_mode_config.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_simple_kms_helper.hdrm/drm_vblank.hdc-de.hdc-drv.hdc-kms.h
Detected Declarations
function dc_kms_init_encoder_per_crtcfunction dc_kms_initfunction dc_kms_uninit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2024 NXP
*/
#include <linux/of.h>
#include <linux/of_graph.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_bridge_connector.h>
#include <drm/drm_connector.h>
#include <drm/drm_crtc.h>
#include <drm/drm_device.h>
#include <drm/drm_encoder.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_mode_config.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h>
#include <drm/drm_vblank.h>
#include "dc-de.h"
#include "dc-drv.h"
#include "dc-kms.h"
static const struct drm_mode_config_funcs dc_drm_mode_config_funcs = {
.fb_create = drm_gem_fb_create,
.atomic_check = drm_atomic_helper_check,
.atomic_commit = drm_atomic_helper_commit,
};
static int dc_kms_init_encoder_per_crtc(struct dc_drm_device *dc_drm,
int crtc_index)
{
struct dc_crtc *dc_crtc = &dc_drm->dc_crtc[crtc_index];
struct drm_device *drm = &dc_drm->base;
struct drm_crtc *crtc = &dc_crtc->base;
struct drm_connector *connector;
struct device *dev = drm->dev;
struct drm_encoder *encoder;
struct drm_bridge *bridge;
int ret;
bridge = devm_drm_of_get_bridge(dev, dc_crtc->de->tc->dev->of_node,
0, 0);
if (IS_ERR(bridge)) {
ret = PTR_ERR(bridge);
if (ret == -ENODEV)
return 0;
return dev_err_probe(dev, ret,
"failed to find bridge for CRTC%u\n",
crtc->index);
}
encoder = &dc_drm->encoder[crtc_index];
ret = drm_simple_encoder_init(drm, encoder, DRM_MODE_ENCODER_NONE);
if (ret) {
dev_err(dev, "failed to initialize encoder for CRTC%u: %d\n",
crtc->index, ret);
return ret;
}
encoder->possible_crtcs = drm_crtc_mask(crtc);
ret = drm_bridge_attach(encoder, bridge, NULL,
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret) {
dev_err(dev,
"failed to attach bridge to encoder for CRTC%u: %d\n",
crtc->index, ret);
return ret;
}
connector = drm_bridge_connector_init(drm, encoder);
if (IS_ERR(connector)) {
ret = PTR_ERR(connector);
dev_err(dev, "failed to init bridge connector for CRTC%u: %d\n",
crtc->index, ret);
return ret;
}
return 0;
}
int dc_kms_init(struct dc_drm_device *dc_drm)
{
struct drm_device *drm = &dc_drm->base;
int ret, i;
Annotation
- Immediate include surface: `linux/of.h`, `linux/of_graph.h`, `drm/drm_atomic_helper.h`, `drm/drm_bridge.h`, `drm/drm_bridge_connector.h`, `drm/drm_connector.h`, `drm/drm_crtc.h`, `drm/drm_device.h`.
- Detected declarations: `function dc_kms_init_encoder_per_crtc`, `function dc_kms_init`, `function dc_kms_uninit`.
- 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.