Skip to content

Commit 5e2a72d

Browse files
Abhinav Kumarrobclark
authored andcommitted
drm/msm/dsi: add support for dsi test pattern generator
During board bringups its useful to have a DSI test pattern generator to isolate a DPU vs a DSI issue and focus on the relevant hardware block. To facilitate this, add an API which triggers the DSI controller test pattern. The expected output is a rectangular checkered pattern. This has been validated on a single DSI video mode panel by calling it right after drm_panel_enable() which is also the ideal location to use this as the DSI host and the panel have been initialized by then. Further validation on dual DSI and command mode panel is pending. If there are any fix ups needed for those, it shall be applied on top of this change. Changes in v2: - generate the new dsi.xml.h and update the bitfield names Signed-off-by: Abhinav Kumar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Stephen Boyd <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Rob Clark <[email protected]>
1 parent 24a5993 commit 5e2a72d

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

drivers/gpu/drm/msm/dsi/dsi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ void msm_dsi_manager_setup_encoder(int id);
8484
int msm_dsi_manager_register(struct msm_dsi *msm_dsi);
8585
void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi);
8686
bool msm_dsi_manager_validate_current_config(u8 id);
87+
void msm_dsi_manager_tpg_enable(void);
8788

8889
/* msm dsi */
8990
static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi)
@@ -148,6 +149,8 @@ int dsi_clk_init_6g_v2(struct msm_dsi_host *msm_host);
148149
int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_dual_dsi);
149150
int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_dual_dsi);
150151
void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host);
152+
void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host);
153+
151154
/* dsi phy */
152155
struct msm_dsi_phy;
153156
struct msm_dsi_phy_shared_timings {

drivers/gpu/drm/msm/dsi/dsi_host.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,3 +2505,64 @@ void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_ho
25052505

25062506
pm_runtime_put_sync(&msm_host->pdev->dev);
25072507
}
2508+
2509+
static void msm_dsi_host_video_test_pattern_setup(struct msm_dsi_host *msm_host)
2510+
{
2511+
u32 reg;
2512+
2513+
reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL);
2514+
2515+
dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_VIDEO_INIT_VAL, 0xff);
2516+
/* draw checkered rectangle pattern */
2517+
dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL,
2518+
DSI_TPG_MAIN_CONTROL_CHECKERED_RECTANGLE_PATTERN);
2519+
/* use 24-bit RGB test pttern */
2520+
dsi_write(msm_host, REG_DSI_TPG_VIDEO_CONFIG,
2521+
DSI_TPG_VIDEO_CONFIG_BPP(VIDEO_CONFIG_24BPP) |
2522+
DSI_TPG_VIDEO_CONFIG_RGB);
2523+
2524+
reg |= DSI_TEST_PATTERN_GEN_CTRL_VIDEO_PATTERN_SEL(VID_MDSS_GENERAL_PATTERN);
2525+
dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg);
2526+
2527+
DBG("Video test pattern setup done\n");
2528+
}
2529+
2530+
static void msm_dsi_host_cmd_test_pattern_setup(struct msm_dsi_host *msm_host)
2531+
{
2532+
u32 reg;
2533+
2534+
reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL);
2535+
2536+
/* initial value for test pattern */
2537+
dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_MDP_INIT_VAL0, 0xff);
2538+
2539+
reg |= DSI_TEST_PATTERN_GEN_CTRL_CMD_MDP_STREAM0_PATTERN_SEL(CMD_MDP_MDSS_GENERAL_PATTERN);
2540+
2541+
dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, reg);
2542+
/* draw checkered rectangle pattern */
2543+
dsi_write(msm_host, REG_DSI_TPG_MAIN_CONTROL2,
2544+
DSI_TPG_MAIN_CONTROL2_CMD_MDP0_CHECKERED_RECTANGLE_PATTERN);
2545+
2546+
DBG("Cmd test pattern setup done\n");
2547+
}
2548+
2549+
void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host)
2550+
{
2551+
struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
2552+
bool is_video_mode = !!(msm_host->mode_flags & MIPI_DSI_MODE_VIDEO);
2553+
u32 reg;
2554+
2555+
if (is_video_mode)
2556+
msm_dsi_host_video_test_pattern_setup(msm_host);
2557+
else
2558+
msm_dsi_host_cmd_test_pattern_setup(msm_host);
2559+
2560+
reg = dsi_read(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL);
2561+
/* enable the test pattern generator */
2562+
dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CTRL, (reg | DSI_TEST_PATTERN_GEN_CTRL_EN));
2563+
2564+
/* for command mode need to trigger one frame from tpg */
2565+
if (!is_video_mode)
2566+
dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER,
2567+
DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER_SW_TRIGGER);
2568+
}

drivers/gpu/drm/msm/dsi/dsi_manager.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,19 @@ static void dsi_mgr_bridge_pre_enable(struct drm_bridge *bridge)
440440
return;
441441
}
442442

443+
void msm_dsi_manager_tpg_enable(void)
444+
{
445+
struct msm_dsi *m_dsi = dsi_mgr_get_dsi(DSI_0);
446+
struct msm_dsi *s_dsi = dsi_mgr_get_dsi(DSI_1);
447+
448+
/* if dual dsi, trigger tpg on master first then slave */
449+
if (m_dsi) {
450+
msm_dsi_host_test_pattern_en(m_dsi->host);
451+
if (IS_DUAL_DSI() && s_dsi)
452+
msm_dsi_host_test_pattern_en(s_dsi->host);
453+
}
454+
}
455+
443456
static void dsi_mgr_bridge_enable(struct drm_bridge *bridge)
444457
{
445458
int id = dsi_mgr_bridge_get_id(bridge);

0 commit comments

Comments
 (0)