Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <abhinavk@codeaurora.org>
Link: https://lore.kernel.org/r/1626922232-29105-2-git-send-email-abhinavk@codeaurora.org
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>

authored by

Abhinav Kumar and committed by
Rob Clark
5e2a72d4 24a5993e

+77
+3
drivers/gpu/drm/msm/dsi/dsi.h
··· 84 84 int msm_dsi_manager_register(struct msm_dsi *msm_dsi); 85 85 void msm_dsi_manager_unregister(struct msm_dsi *msm_dsi); 86 86 bool msm_dsi_manager_validate_current_config(u8 id); 87 + void msm_dsi_manager_tpg_enable(void); 87 88 88 89 /* msm dsi */ 89 90 static inline bool msm_dsi_device_connected(struct msm_dsi *msm_dsi) ··· 149 148 int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_dual_dsi); 150 149 int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_dual_dsi); 151 150 void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host); 151 + void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host); 152 + 152 153 /* dsi phy */ 153 154 struct msm_dsi_phy; 154 155 struct msm_dsi_phy_shared_timings {
+61
drivers/gpu/drm/msm/dsi/dsi_host.c
··· 2505 2505 2506 2506 pm_runtime_put_sync(&msm_host->pdev->dev); 2507 2507 } 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 + }
+13
drivers/gpu/drm/msm/dsi/dsi_manager.c
··· 440 440 return; 441 441 } 442 442 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 + 443 456 static void dsi_mgr_bridge_enable(struct drm_bridge *bridge) 444 457 { 445 458 int id = dsi_mgr_bridge_get_id(bridge);