drivers/gpu/drm/mediatek/mtk_dpi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_dpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/mediatek/mtk_dpi.c- Extension
.c- Size
- 37533 bytes
- Lines
- 1362
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/clk.hlinux/component.hlinux/debugfs.hlinux/interrupt.hlinux/kernel.hlinux/media-bus-format.hlinux/of.hlinux/of_graph.hlinux/pinctrl/consumer.hlinux/platform_device.hlinux/soc/mediatek/mtk-mmsys.hlinux/types.hvideo/videomode.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_bridge_connector.hdrm/drm_crtc.hdrm/drm_edid.hdrm/drm_encoder.hdrm/drm_of.hmtk_ddp_comp.hmtk_disp_drv.hmtk_dpi_regs.hmtk_drm_drv.h
Detected Declarations
struct mtk_dpistruct mtk_dpi_polaritiesstruct mtk_dpi_sync_paramstruct mtk_dpi_yc_limitstruct mtk_dpi_factorstruct mtk_dpi_confenum mtk_dpi_out_bit_numenum mtk_dpi_out_yc_mapenum mtk_dpi_out_channel_swapenum mtk_dpi_out_color_formatenum mtk_dpi_polarityfunction mtk_dpi_maskfunction mtk_dpi_test_pattern_enfunction mtk_dpi_sw_resetfunction mtk_dpi_enablefunction mtk_dpi_disablefunction mtk_dpi_config_hsyncfunction mtk_dpi_config_vsyncfunction mtk_dpi_config_vsync_loddfunction mtk_dpi_config_vsync_levenfunction mtk_dpi_config_vsync_roddfunction mtk_dpi_config_vsync_revenfunction mtk_dpi_config_polfunction mtk_dpi_config_3dfunction mtk_dpi_config_interfacefunction mtk_dpi_config_fb_sizefunction mtk_dpi_config_channel_limitfunction mtk_dpi_config_bit_numfunction mtk_dpi_config_yc_mapfunction mtk_dpi_config_channel_swapfunction mtk_dpi_config_yuv422_enablefunction mtk_dpi_config_csc_enablefunction mtk_dpi_config_swap_inputfunction mtk_dpi_config_2n_h_frefunction mtk_dpi_config_disable_edgefunction mtk_dpi_config_color_formatfunction mtk_dpi_dual_edgefunction mtk_dpi_power_offfunction mtk_dpi_power_onfunction mtk_dpi_calculate_factorfunction mtk_dpi_set_pixel_clkfunction mtk_dpi_set_display_modefunction mtk_dpi_bus_fmt_bit_numfunction mtk_dpi_bus_fmt_channel_swapfunction mtk_dpi_bus_fmt_color_formatfunction mtk_dpi_bridge_atomic_checkfunction mtk_dpi_bridge_attachfunction mtk_dpi_bridge_mode_set
Annotated Snippet
static const struct file_operations mtk_dpi_debug_tp_fops = {
.owner = THIS_MODULE,
.open = mtk_dpi_debug_tp_open,
.read = seq_read,
.write = mtk_dpi_debug_tp_write,
.llseek = seq_lseek,
.release = single_release,
};
static void mtk_dpi_debugfs_init(struct drm_bridge *bridge, struct dentry *root)
{
struct mtk_dpi *dpi = bridge_to_dpi(bridge);
debugfs_create_file("dpi_test_pattern", 0640, root, dpi, &mtk_dpi_debug_tp_fops);
}
static const struct drm_bridge_funcs mtk_dpi_bridge_funcs = {
.attach = mtk_dpi_bridge_attach,
.mode_set = mtk_dpi_bridge_mode_set,
.mode_valid = mtk_dpi_bridge_mode_valid,
.disable = mtk_dpi_bridge_disable,
.enable = mtk_dpi_bridge_enable,
.atomic_check = mtk_dpi_bridge_atomic_check,
.atomic_get_output_bus_fmts = mtk_dpi_bridge_atomic_get_output_bus_fmts,
.atomic_get_input_bus_fmts = mtk_dpi_bridge_atomic_get_input_bus_fmts,
.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
.atomic_reset = drm_atomic_helper_bridge_reset,
.debugfs_init = mtk_dpi_debugfs_init,
};
static const struct drm_encoder_funcs mtk_dpi_encoder_funcs = {
.destroy = drm_encoder_cleanup,
};
void mtk_dpi_start(struct device *dev)
{
struct mtk_dpi *dpi = dev_get_drvdata(dev);
if (!dpi->conf->clocked_by_hdmi)
mtk_dpi_power_on(dpi);
}
void mtk_dpi_stop(struct device *dev)
{
struct mtk_dpi *dpi = dev_get_drvdata(dev);
if (!dpi->conf->clocked_by_hdmi)
mtk_dpi_power_off(dpi);
}
unsigned int mtk_dpi_encoder_index(struct device *dev)
{
struct mtk_dpi *dpi = dev_get_drvdata(dev);
unsigned int encoder_index = drm_encoder_index(&dpi->encoder);
dev_dbg(dev, "encoder index:%d\n", encoder_index);
return encoder_index;
}
static int mtk_dpi_bind(struct device *dev, struct device *master, void *data)
{
struct mtk_dpi *dpi = dev_get_drvdata(dev);
struct drm_device *drm_dev = data;
struct mtk_drm_private *priv = drm_dev->dev_private;
int ret;
dpi->mmsys_dev = priv->mmsys_dev;
ret = drm_encoder_init(drm_dev, &dpi->encoder, &mtk_dpi_encoder_funcs,
DRM_MODE_ENCODER_TMDS, NULL);
if (ret) {
dev_err(dev, "Failed to initialize decoder: %d\n", ret);
return ret;
}
ret = mtk_find_possible_crtcs(drm_dev, dpi->dev);
if (ret < 0)
goto err_cleanup;
dpi->encoder.possible_crtcs = ret;
ret = drm_bridge_attach(&dpi->encoder, &dpi->bridge, NULL,
DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret)
goto err_cleanup;
dpi->connector = drm_bridge_connector_init(drm_dev, &dpi->encoder);
if (IS_ERR(dpi->connector)) {
dev_err(dev, "Unable to create bridge connector\n");
ret = PTR_ERR(dpi->connector);
goto err_cleanup;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/component.h`, `linux/debugfs.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/media-bus-format.h`, `linux/of.h`.
- Detected declarations: `struct mtk_dpi`, `struct mtk_dpi_polarities`, `struct mtk_dpi_sync_param`, `struct mtk_dpi_yc_limit`, `struct mtk_dpi_factor`, `struct mtk_dpi_conf`, `enum mtk_dpi_out_bit_num`, `enum mtk_dpi_out_yc_map`, `enum mtk_dpi_out_channel_swap`, `enum mtk_dpi_out_color_format`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.