drivers/gpu/drm/mediatek/mtk_padding.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_padding.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/mediatek/mtk_padding.c- Extension
.c- Size
- 3865 bytes
- Lines
- 155
- 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_device.hlinux/platform_device.hlinux/pm_runtime.hlinux/soc/mediatek/mtk-cmdq.hmtk_crtc.hmtk_ddp_comp.hmtk_disp_drv.h
Detected Declarations
struct mtk_paddingfunction mtk_padding_clk_enablefunction mtk_padding_clk_disablefunction mtk_padding_startfunction mtk_padding_stopfunction mtk_padding_bindfunction mtk_padding_unbindfunction mtk_padding_probefunction mtk_padding_remove
Annotated Snippet
struct mtk_padding {
struct clk *clk;
void __iomem *reg;
struct cmdq_client_reg cmdq_reg;
};
int mtk_padding_clk_enable(struct device *dev)
{
struct mtk_padding *padding = dev_get_drvdata(dev);
return clk_prepare_enable(padding->clk);
}
void mtk_padding_clk_disable(struct device *dev)
{
struct mtk_padding *padding = dev_get_drvdata(dev);
clk_disable_unprepare(padding->clk);
}
void mtk_padding_start(struct device *dev)
{
struct mtk_padding *padding = dev_get_drvdata(dev);
writel(PADDING_ENABLE | PADDING_BYPASS,
padding->reg + PADDING_CONTROL_REG);
/*
* Notice that even the padding is in bypass mode,
* all the settings must be cleared to 0 or
* undefined behaviors could happen
*/
writel(0, padding->reg + PADDING_PIC_SIZE_REG);
writel(0, padding->reg + PADDING_H_REG);
writel(0, padding->reg + PADDING_V_REG);
writel(0, padding->reg + PADDING_COLOR_REG);
}
void mtk_padding_stop(struct device *dev)
{
struct mtk_padding *padding = dev_get_drvdata(dev);
writel(0, padding->reg + PADDING_CONTROL_REG);
}
static int mtk_padding_bind(struct device *dev, struct device *master, void *data)
{
return 0;
}
static void mtk_padding_unbind(struct device *dev, struct device *master, void *data)
{
}
static const struct component_ops mtk_padding_component_ops = {
.bind = mtk_padding_bind,
.unbind = mtk_padding_unbind,
};
static int mtk_padding_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct mtk_padding *priv;
struct resource *res;
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 clk\n");
priv->reg = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(priv->reg))
return dev_err_probe(dev, PTR_ERR(priv->reg),
"failed to do ioremap\n");
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0);
if (ret)
return dev_err_probe(dev, ret, "failed to get gce client reg\n");
#endif
platform_set_drvdata(pdev, priv);
ret = devm_pm_runtime_enable(dev);
if (ret)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/component.h`, `linux/module.h`, `linux/of_device.h`, `linux/platform_device.h`, `linux/pm_runtime.h`, `linux/soc/mediatek/mtk-cmdq.h`, `mtk_crtc.h`.
- Detected declarations: `struct mtk_padding`, `function mtk_padding_clk_enable`, `function mtk_padding_clk_disable`, `function mtk_padding_start`, `function mtk_padding_stop`, `function mtk_padding_bind`, `function mtk_padding_unbind`, `function mtk_padding_probe`, `function mtk_padding_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.