drivers/gpu/drm/mediatek/mtk_disp_color.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_disp_color.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/mediatek/mtk_disp_color.c- Extension
.c- Size
- 4459 bytes
- Lines
- 166
- 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.
- 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/component.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/soc/mediatek/mtk-cmdq.hmtk_crtc.hmtk_ddp_comp.hmtk_disp_drv.hmtk_drm_drv.h
Detected Declarations
struct mtk_disp_color_datastruct mtk_disp_colorfunction mtk_color_clk_enablefunction mtk_color_clk_disablefunction mtk_color_configfunction mtk_color_startfunction mtk_disp_color_bindfunction mtk_disp_color_unbindfunction mtk_disp_color_probefunction mtk_disp_color_remove
Annotated Snippet
struct mtk_disp_color_data {
unsigned int color_offset;
};
/*
* struct mtk_disp_color - DISP_COLOR driver structure
* @crtc: associated crtc to report irq events to
* @data: platform colour driver data
*/
struct mtk_disp_color {
struct drm_crtc *crtc;
struct clk *clk;
void __iomem *regs;
struct cmdq_client_reg cmdq_reg;
const struct mtk_disp_color_data *data;
};
int mtk_color_clk_enable(struct device *dev)
{
struct mtk_disp_color *color = dev_get_drvdata(dev);
return clk_prepare_enable(color->clk);
}
void mtk_color_clk_disable(struct device *dev)
{
struct mtk_disp_color *color = dev_get_drvdata(dev);
clk_disable_unprepare(color->clk);
}
void mtk_color_config(struct device *dev, unsigned int w,
unsigned int h, unsigned int vrefresh,
unsigned int bpc, struct cmdq_pkt *cmdq_pkt)
{
struct mtk_disp_color *color = dev_get_drvdata(dev);
mtk_ddp_write(cmdq_pkt, w, &color->cmdq_reg, color->regs, DISP_COLOR_WIDTH(color));
mtk_ddp_write(cmdq_pkt, h, &color->cmdq_reg, color->regs, DISP_COLOR_HEIGHT(color));
}
void mtk_color_start(struct device *dev)
{
struct mtk_disp_color *color = dev_get_drvdata(dev);
writel(COLOR_BYPASS_ALL | COLOR_SEQ_SEL,
color->regs + DISP_COLOR_CFG_MAIN);
writel(0x1, color->regs + DISP_COLOR_START(color));
}
static int mtk_disp_color_bind(struct device *dev, struct device *master,
void *data)
{
return 0;
}
static void mtk_disp_color_unbind(struct device *dev, struct device *master,
void *data)
{
}
static const struct component_ops mtk_disp_color_component_ops = {
.bind = mtk_disp_color_bind,
.unbind = mtk_disp_color_unbind,
};
static int mtk_disp_color_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct mtk_disp_color *priv;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->clk = devm_clk_get(dev, NULL);
if (IS_ERR(priv->clk))
return dev_err_probe(dev, PTR_ERR(priv->clk),
"failed to get color clk\n");
priv->regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->regs))
return dev_err_probe(dev, PTR_ERR(priv->regs),
"failed to ioremap color\n");
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
dev_dbg(dev, "get mediatek,gce-client-reg fail!\n");
#endif
Annotation
- Immediate include surface: `linux/clk.h`, `linux/component.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/soc/mediatek/mtk-cmdq.h`, `mtk_crtc.h`, `mtk_ddp_comp.h`.
- Detected declarations: `struct mtk_disp_color_data`, `struct mtk_disp_color`, `function mtk_color_clk_enable`, `function mtk_color_clk_disable`, `function mtk_color_config`, `function mtk_color_start`, `function mtk_disp_color_bind`, `function mtk_disp_color_unbind`, `function mtk_disp_color_probe`, `function mtk_disp_color_remove`.
- 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.