drivers/gpu/drm/mediatek/mtk_ddp_comp.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/mediatek/mtk_ddp_comp.c- Extension
.c- Size
- 21006 bytes
- Lines
- 711
- 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/of.hlinux/of_address.hlinux/of_platform.hlinux/platform_device.hlinux/soc/mediatek/mtk-cmdq.hdrm/drm_print.hmtk_crtc.hmtk_ddp_comp.hmtk_disp_drv.hmtk_drm_drv.hmtk_plane.h
Detected Declarations
struct mtk_ddp_comp_devstruct mtk_ddp_comp_matchfunction mtk_ddp_writefunction mtk_ddp_write_relaxedfunction mtk_ddp_write_maskfunction mtk_ddp_clk_enablefunction mtk_ddp_clk_disablefunction mtk_dither_set_commonfunction mtk_dither_configfunction mtk_dither_startfunction mtk_dither_stopfunction mtk_dither_setfunction mtk_dsc_configfunction mtk_dsc_startfunction mtk_dsc_stopfunction mtk_od_configfunction mtk_od_startfunction mtk_postmask_configfunction mtk_postmask_startfunction mtk_postmask_stopfunction mtk_ufoe_startfunction mtk_ddp_comp_findfunction mtk_ddp_comp_find_in_routefunction mtk_ddp_path_availablefunction mtk_ddp_comp_get_idfunction mtk_find_possible_crtcsfunction mtk_ddp_comp_put_devicefunction mtk_ddp_comp_clk_putfunction mtk_ddp_comp_init
Annotated Snippet
struct mtk_ddp_comp_dev {
struct clk *clk;
void __iomem *regs;
struct cmdq_client_reg cmdq_reg;
};
void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,
struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
unsigned int offset)
{
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (cmdq_pkt)
cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys,
cmdq_reg->offset + offset, value);
else
#endif
writel(value, regs + offset);
}
void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, unsigned int value,
struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
unsigned int offset)
{
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (cmdq_pkt)
cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys,
cmdq_reg->offset + offset, value);
else
#endif
writel_relaxed(value, regs + offset);
}
void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value,
struct cmdq_client_reg *cmdq_reg, void __iomem *regs,
unsigned int offset, unsigned int mask)
{
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
if (cmdq_pkt) {
cmdq_pkt_write_mask(cmdq_pkt, cmdq_reg->subsys,
cmdq_reg->offset + offset, value, mask);
} else {
#endif
u32 tmp = readl(regs + offset);
tmp = (tmp & ~mask) | (value & mask);
writel(tmp, regs + offset);
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
}
#endif
}
static int mtk_ddp_clk_enable(struct device *dev)
{
struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev);
return clk_prepare_enable(priv->clk);
}
static void mtk_ddp_clk_disable(struct device *dev)
{
struct mtk_ddp_comp_dev *priv = dev_get_drvdata(dev);
clk_disable_unprepare(priv->clk);
}
void mtk_dither_set_common(void __iomem *regs, struct cmdq_client_reg *cmdq_reg,
unsigned int bpc, unsigned int cfg,
unsigned int dither_en, struct cmdq_pkt *cmdq_pkt)
{
/* If bpc equal to 0, the dithering function didn't be enabled */
if (bpc == 0)
return;
if (bpc >= MTK_MIN_BPC) {
mtk_ddp_write(cmdq_pkt, 0, cmdq_reg, regs, DISP_REG_DITHER_5);
mtk_ddp_write(cmdq_pkt, 0, cmdq_reg, regs, DISP_REG_DITHER_7);
mtk_ddp_write(cmdq_pkt,
DITHER_LSB_ERR_SHIFT_R(MTK_MAX_BPC - bpc) |
DITHER_ADD_LSHIFT_R(MTK_MAX_BPC - bpc) |
DITHER_NEW_BIT_MODE,
cmdq_reg, regs, DISP_REG_DITHER_15);
mtk_ddp_write(cmdq_pkt,
DITHER_LSB_ERR_SHIFT_B(MTK_MAX_BPC - bpc) |
DITHER_ADD_LSHIFT_B(MTK_MAX_BPC - bpc) |
DITHER_LSB_ERR_SHIFT_G(MTK_MAX_BPC - bpc) |
DITHER_ADD_LSHIFT_G(MTK_MAX_BPC - bpc),
cmdq_reg, regs, DISP_REG_DITHER_16);
mtk_ddp_write(cmdq_pkt, dither_en, cmdq_reg, regs, cfg);
}
}
Annotation
- Immediate include surface: `linux/clk.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/soc/mediatek/mtk-cmdq.h`, `drm/drm_print.h`, `mtk_crtc.h`.
- Detected declarations: `struct mtk_ddp_comp_dev`, `struct mtk_ddp_comp_match`, `function mtk_ddp_write`, `function mtk_ddp_write_relaxed`, `function mtk_ddp_write_mask`, `function mtk_ddp_clk_enable`, `function mtk_ddp_clk_disable`, `function mtk_dither_set_common`, `function mtk_dither_config`, `function mtk_dither_start`.
- 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.