drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c- Extension
.c- Size
- 2945 bytes
- Lines
- 130
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/media-bus-format.hlinux/of.hlinux/of_graph.hdrm/drm_bridge.hdrm/drm_encoder.hdrm/drm_of.hdrm/drm_print.hdrm/drm_simple_kms_helper.hatmel_hlcdc_dc.h
Detected Declarations
struct atmel_hlcdc_rgb_outputfunction atmel_hlcdc_encoder_to_rgb_outputfunction atmel_hlcdc_encoder_get_bus_fmtfunction atmel_hlcdc_of_bus_fmtfunction atmel_hlcdc_attach_endpointfunction atmel_hlcdc_create_outputs
Annotated Snippet
struct atmel_hlcdc_rgb_output {
struct drm_encoder encoder;
int bus_fmt;
};
static struct atmel_hlcdc_rgb_output *
atmel_hlcdc_encoder_to_rgb_output(struct drm_encoder *encoder)
{
return container_of(encoder, struct atmel_hlcdc_rgb_output, encoder);
}
int atmel_hlcdc_encoder_get_bus_fmt(struct drm_encoder *encoder)
{
struct atmel_hlcdc_rgb_output *output;
output = atmel_hlcdc_encoder_to_rgb_output(encoder);
return output->bus_fmt;
}
static int atmel_hlcdc_of_bus_fmt(const struct device_node *ep)
{
u32 bus_width;
int ret;
ret = of_property_read_u32(ep, "bus-width", &bus_width);
if (ret == -EINVAL)
return 0;
if (ret)
return ret;
switch (bus_width) {
case 12:
return MEDIA_BUS_FMT_RGB444_1X12;
case 16:
return MEDIA_BUS_FMT_RGB565_1X16;
case 18:
return MEDIA_BUS_FMT_RGB666_1X18;
case 24:
return MEDIA_BUS_FMT_RGB888_1X24;
default:
return -EINVAL;
}
}
static int atmel_hlcdc_attach_endpoint(struct drm_device *dev, int endpoint)
{
struct atmel_hlcdc_rgb_output *output;
struct device_node *ep;
struct drm_bridge *bridge;
struct atmel_hlcdc_dc *dc = dev->dev_private;
struct drm_crtc *crtc = dc->crtc;
int ret = 0;
bridge = devm_drm_of_get_bridge(dev->dev, dev->dev->of_node, 0, endpoint);
if (IS_ERR(bridge))
return PTR_ERR(bridge);
output = drmm_simple_encoder_alloc(dev, struct atmel_hlcdc_rgb_output,
encoder, DRM_MODE_ENCODER_NONE);
if (IS_ERR(output))
return PTR_ERR(output);
ep = of_graph_get_endpoint_by_regs(dev->dev->of_node, 0, endpoint);
if (!ep)
return -ENODEV;
output->bus_fmt = atmel_hlcdc_of_bus_fmt(ep);
of_node_put(ep);
if (output->bus_fmt < 0) {
drm_err(dev, "endpoint %d: invalid bus width\n", endpoint);
return -EINVAL;
}
output->encoder.possible_crtcs = drm_crtc_mask(crtc);
if (bridge)
ret = drm_bridge_attach(&output->encoder, bridge, NULL, 0);
return ret;
}
int atmel_hlcdc_create_outputs(struct drm_device *dev)
{
int endpoint, ret = 0;
int attached = 0;
/*
* Always scan the first few endpoints even if we get -ENODEV,
Annotation
- Immediate include surface: `linux/media-bus-format.h`, `linux/of.h`, `linux/of_graph.h`, `drm/drm_bridge.h`, `drm/drm_encoder.h`, `drm/drm_of.h`, `drm/drm_print.h`, `drm/drm_simple_kms_helper.h`.
- Detected declarations: `struct atmel_hlcdc_rgb_output`, `function atmel_hlcdc_encoder_to_rgb_output`, `function atmel_hlcdc_encoder_get_bus_fmt`, `function atmel_hlcdc_of_bus_fmt`, `function atmel_hlcdc_attach_endpoint`, `function atmel_hlcdc_create_outputs`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.