drivers/soc/mediatek/mtk-mmsys.c
Source file repositories/reference/linux-study-clean/drivers/soc/mediatek/mtk-mmsys.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/mediatek/mtk-mmsys.c- Extension
.c- Size
- 15902 bytes
- Lines
- 499
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/delay.hlinux/device.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/reset-controller.hlinux/soc/mediatek/mtk-mmsys.hmtk-mmsys.hmt8167-mmsys.hmt8173-mmsys.hmt8183-mmsys.hmt8186-mmsys.hmt8188-mmsys.hmt8192-mmsys.hmt8195-mmsys.hmt8365-mmsys.h
Detected Declarations
struct mtk_mmsysfunction mtk_mmsys_update_bitsfunction mtk_mmsys_ddp_connectfunction mtk_mmsys_ddp_disconnectfunction mtk_mmsys_merge_async_configfunction mtk_mmsys_hdr_configfunction mtk_mmsys_mixer_in_configfunction mtk_mmsys_mixer_in_channel_swapfunction mtk_mmsys_ddp_dpi_fmt_configfunction mtk_mmsys_vpp_rsz_merge_configfunction mtk_mmsys_vpp_rsz_dcm_configfunction mtk_mmsys_reset_updatefunction mtk_mmsys_reset_assertfunction mtk_mmsys_reset_deassertfunction mtk_mmsys_resetfunction mtk_mmsys_probefunction mtk_mmsys_removeexport mtk_mmsys_ddp_connectexport mtk_mmsys_ddp_disconnectexport mtk_mmsys_merge_async_configexport mtk_mmsys_hdr_configexport mtk_mmsys_mixer_in_configexport mtk_mmsys_mixer_in_channel_swapexport mtk_mmsys_ddp_dpi_fmt_configexport mtk_mmsys_vpp_rsz_merge_configexport mtk_mmsys_vpp_rsz_dcm_config
Annotated Snippet
struct mtk_mmsys {
void __iomem *regs;
const struct mtk_mmsys_driver_data *data;
struct platform_device *clks_pdev;
struct platform_device *drm_pdev;
spinlock_t lock; /* protects mmsys_sw_rst_b reg */
struct reset_controller_dev rcdev;
struct cmdq_client_reg cmdq_base;
};
static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val,
struct cmdq_pkt *cmdq_pkt)
{
int ret;
u32 tmp;
if (mmsys->cmdq_base.size && cmdq_pkt) {
ret = mmsys->cmdq_base.pkt_write_mask(cmdq_pkt,
mmsys->cmdq_base.subsys,
mmsys->cmdq_base.pa_base,
mmsys->cmdq_base.offset + offset,
val, mask);
if (ret)
pr_debug("CMDQ unavailable: using CPU write\n");
else
return;
}
tmp = readl_relaxed(mmsys->regs + offset);
tmp = (tmp & ~mask) | (val & mask);
writel_relaxed(tmp, mmsys->regs + offset);
}
void mtk_mmsys_ddp_connect(struct device *dev,
enum mtk_ddp_comp_id cur,
enum mtk_ddp_comp_id next)
{
struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
const struct mtk_mmsys_routes *routes = mmsys->data->routes;
int i;
for (i = 0; i < mmsys->data->num_routes; i++)
if (cur == routes[i].from_comp && next == routes[i].to_comp)
mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask,
routes[i].val, NULL);
if (mmsys->data->vsync_len)
mtk_mmsys_update_bits(mmsys, MT8188_VDO1_MIXER_VSYNC_LEN, GENMASK(31, 0),
mmsys->data->vsync_len, NULL);
}
EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_connect);
void mtk_mmsys_ddp_disconnect(struct device *dev,
enum mtk_ddp_comp_id cur,
enum mtk_ddp_comp_id next)
{
struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
const struct mtk_mmsys_routes *routes = mmsys->data->routes;
int i;
for (i = 0; i < mmsys->data->num_routes; i++)
if (cur == routes[i].from_comp && next == routes[i].to_comp)
mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask, 0, NULL);
}
EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width, int height,
struct cmdq_pkt *cmdq_pkt)
{
mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_MERGE0_ASYNC_CFG_WD + 0x10 * idx,
~0, height << 16 | width, cmdq_pkt);
}
EXPORT_SYMBOL_GPL(mtk_mmsys_merge_async_config);
void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height,
struct cmdq_pkt *cmdq_pkt)
{
mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_HDRBE_ASYNC_CFG_WD, ~0,
be_height << 16 | be_width, cmdq_pkt);
}
EXPORT_SYMBOL_GPL(mtk_mmsys_hdr_config);
void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 alpha,
u8 mode, u32 biwidth, struct cmdq_pkt *cmdq_pkt)
{
struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_ALPHA + (idx - 1) * 4, ~0,
alpha << 16 | alpha, cmdq_pkt);
mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(15 + idx), 0, cmdq_pkt);
mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(19 + idx),
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/reset-controller.h`, `linux/soc/mediatek/mtk-mmsys.h`.
- Detected declarations: `struct mtk_mmsys`, `function mtk_mmsys_update_bits`, `function mtk_mmsys_ddp_connect`, `function mtk_mmsys_ddp_disconnect`, `function mtk_mmsys_merge_async_config`, `function mtk_mmsys_hdr_config`, `function mtk_mmsys_mixer_in_config`, `function mtk_mmsys_mixer_in_channel_swap`, `function mtk_mmsys_ddp_dpi_fmt_config`, `function mtk_mmsys_vpp_rsz_merge_config`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: integration 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.