drivers/gpu/drm/mediatek/mtk_dsi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mediatek/mtk_dsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/mediatek/mtk_dsi.c- Extension
.c- Size
- 35135 bytes
- Lines
- 1331
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/clk.hlinux/component.hlinux/iopoll.hlinux/irq.hlinux/of.hlinux/of_platform.hlinux/phy/phy.hlinux/platform_device.hlinux/reset.hlinux/units.hvideo/mipi_display.hvideo/videomode.hdrm/drm_atomic_helper.hdrm/drm_bridge.hdrm/drm_bridge_connector.hdrm/drm_mipi_dsi.hdrm/drm_of.hdrm/drm_panel.hdrm/drm_print.hdrm/drm_probe_helper.hdrm/drm_simple_kms_helper.hmtk_ddp_comp.hmtk_disp_drv.hmtk_drm_drv.h
Detected Declarations
struct mtk_phy_timingstruct phystruct mtk_dsi_driver_datastruct mtk_dsifunction mtk_dsi_maskfunction mtk_dsi_phy_timconfigfunction mtk_dsi_enablefunction mtk_dsi_disablefunction mtk_dsi_reset_enginefunction mtk_dsi_reset_dphyfunction mtk_dsi_clk_ulp_mode_enterfunction mtk_dsi_clk_ulp_mode_leavefunction mtk_dsi_lane0_ulp_mode_enterfunction mtk_dsi_lane0_ulp_mode_leavefunction mtk_dsi_clk_hs_statefunction mtk_dsi_clk_hs_modefunction mtk_dsi_set_modefunction mtk_dsi_set_vm_cmdfunction mtk_dsi_rxtx_controlfunction mtk_dsi_ps_controlfunction mtk_dsi_config_vdo_timing_per_frame_lpfunction mtk_dsi_config_vdo_timing_per_line_lpfunction mtk_dsi_config_vdo_timingfunction mtk_dsi_startfunction mtk_dsi_stopfunction mtk_dsi_set_cmd_modefunction mtk_dsi_set_interrupt_enablefunction mtk_dsi_irq_data_setfunction mtk_dsi_irq_data_clearfunction mtk_dsi_wait_for_irq_donefunction mtk_dsi_irqfunction mtk_dsi_switch_to_cmd_modefunction mtk_dsi_lane_readyfunction mtk_dsi_poweronfunction mtk_dsi_powerofffunction mtk_output_dsi_enablefunction mtk_output_dsi_disablefunction mtk_dsi_bridge_attachfunction mtk_dsi_bridge_mode_setfunction mtk_dsi_bridge_atomic_disablefunction mtk_dsi_bridge_atomic_enablefunction mtk_dsi_bridge_atomic_pre_enablefunction mtk_dsi_bridge_atomic_post_disablefunction mtk_dsi_bridge_mode_validfunction mtk_dsi_ddp_startfunction mtk_dsi_ddp_stopfunction mtk_dsi_encoder_initfunction mtk_dsi_encoder_index
Annotated Snippet
struct mtk_phy_timing {
u32 lpx;
u32 da_hs_prepare;
u32 da_hs_zero;
u32 da_hs_trail;
u32 ta_go;
u32 ta_sure;
u32 ta_get;
u32 da_hs_exit;
u32 clk_hs_zero;
u32 clk_hs_trail;
u32 clk_hs_prepare;
u32 clk_hs_post;
u32 clk_hs_exit;
};
struct phy;
struct mtk_dsi_driver_data {
const u32 reg_cmdq_off;
const u32 reg_vm_cmd_off;
const u32 reg_shadow_dbg_off;
bool has_shadow_ctl;
bool has_size_ctl;
bool cmdq_long_packet_ctl;
bool support_per_frame_lp;
};
struct mtk_dsi {
struct device *dev;
struct mipi_dsi_host host;
struct drm_encoder encoder;
struct drm_bridge bridge;
struct drm_bridge *next_bridge;
struct drm_connector *connector;
struct phy *phy;
void __iomem *regs;
struct clk *engine_clk;
struct clk *digital_clk;
struct clk *hs_clk;
u32 data_rate;
unsigned long mode_flags;
enum mipi_dsi_pixel_format format;
unsigned int lanes;
struct videomode vm;
struct mtk_phy_timing phy_timing;
int refcount;
bool enabled;
bool lanes_ready;
u32 irq_data;
wait_queue_head_t irq_wait_queue;
const struct mtk_dsi_driver_data *driver_data;
};
static inline struct mtk_dsi *bridge_to_dsi(struct drm_bridge *b)
{
return container_of(b, struct mtk_dsi, bridge);
}
static inline struct mtk_dsi *host_to_dsi(struct mipi_dsi_host *h)
{
return container_of(h, struct mtk_dsi, host);
}
static void mtk_dsi_mask(struct mtk_dsi *dsi, u32 offset, u32 mask, u32 data)
{
u32 temp = readl(dsi->regs + offset);
writel((temp & ~mask) | (data & mask), dsi->regs + offset);
}
static void mtk_dsi_phy_timconfig(struct mtk_dsi *dsi)
{
u32 timcon0, timcon1, timcon2, timcon3;
u32 data_rate_mhz = DIV_ROUND_UP(dsi->data_rate, HZ_PER_MHZ);
struct mtk_phy_timing *timing = &dsi->phy_timing;
timing->lpx = (60 * data_rate_mhz / (8 * 1000)) + 1;
timing->da_hs_prepare = (80 * data_rate_mhz + 4 * 1000) / 8000;
timing->da_hs_zero = (170 * data_rate_mhz + 10 * 1000) / 8000 + 1 -
timing->da_hs_prepare;
timing->da_hs_trail = timing->da_hs_prepare + 1;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/component.h`, `linux/iopoll.h`, `linux/irq.h`, `linux/of.h`, `linux/of_platform.h`, `linux/phy/phy.h`.
- Detected declarations: `struct mtk_phy_timing`, `struct phy`, `struct mtk_dsi_driver_data`, `struct mtk_dsi`, `function mtk_dsi_mask`, `function mtk_dsi_phy_timconfig`, `function mtk_dsi_enable`, `function mtk_dsi_disable`, `function mtk_dsi_reset_engine`, `function mtk_dsi_reset_dphy`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.