drm/msm/dsi: Pass DSC params to drm_panel
authorVinod Koul <vkoul@kernel.org>
Wed, 6 Apr 2022 09:40:19 +0000 (15:10 +0530)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Mon, 25 Apr 2022 21:50:47 +0000 (00:50 +0300)
When DSC is enabled, we need to get the DSC parameters from the panel
driver, so add a dsc parameter in panel to fetch and pass DSC
configuration for DSI panels to DPU encoder, which will enable and
then configure DSC hardware blocks accordingly.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Patchwork: https://patchwork.freedesktop.org/patch/480910/
Link: https://lore.kernel.org/r/20220406094031.1027376-3-vkoul@kernel.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
drivers/gpu/drm/msm/dsi/dsi.c
drivers/gpu/drm/msm/dsi/dsi.h
drivers/gpu/drm/msm/dsi/dsi_host.c
drivers/gpu/drm/msm/msm_drv.h
include/drm/drm_panel.h

index 1f39327..bf00b0a 100644 (file)
@@ -27,6 +27,7 @@
  *                      based on num_of_h_tiles
  * @is_te_using_watchdog_timer:  Boolean to indicate watchdog TE is
  *                              used instead of panel TE in cmd mode panels
+ * @dsc:               DSC configuration data for DSC-enabled displays
  */
 struct msm_display_info {
        int intf_type;
@@ -34,6 +35,7 @@ struct msm_display_info {
        uint32_t num_of_h_tiles;
        uint32_t h_tile_instance[MAX_H_TILES_PER_DISPLAY];
        bool is_te_using_watchdog_timer;
+       struct msm_display_dsc_config *dsc;
 };
 
 /**
index 8559727..da6a671 100644 (file)
@@ -584,6 +584,8 @@ static int _dpu_kms_initialize_dsi(struct drm_device *dev,
                        MSM_DISPLAY_CAP_CMD_MODE :
                        MSM_DISPLAY_CAP_VID_MODE;
 
+               info.dsc = msm_dsi_get_dsc_config(priv->dsi[i]);
+
                if (msm_dsi_is_bonded_dsi(priv->dsi[i]) && priv->dsi[other]) {
                        rc = msm_dsi_modeset_init(priv->dsi[other], dev, encoder);
                        if (rc) {
index 1fe020e..1625328 100644 (file)
@@ -21,6 +21,11 @@ bool msm_dsi_is_cmd_mode(struct msm_dsi *msm_dsi)
        return !(host_flags & MIPI_DSI_MODE_VIDEO);
 }
 
+struct msm_display_dsc_config *msm_dsi_get_dsc_config(struct msm_dsi *msm_dsi)
+{
+       return msm_dsi_host_get_dsc_config(msm_dsi->host);
+}
+
 static int dsi_get_phy(struct msm_dsi *msm_dsi)
 {
        struct platform_device *pdev = msm_dsi->pdev;
index c8dedc9..16cd9b2 100644 (file)
@@ -152,6 +152,7 @@ int dsi_calc_clk_rate_v2(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
 int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi);
 void msm_dsi_host_snapshot(struct msm_disp_state *disp_state, struct mipi_dsi_host *host);
 void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host);
+struct msm_display_dsc_config *msm_dsi_host_get_dsc_config(struct mipi_dsi_host *host);
 
 /* dsi phy */
 struct msm_dsi_phy;
index 4a8a9b3..1e8b6f0 100644 (file)
@@ -2061,9 +2061,24 @@ int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
 {
        struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
        const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd;
+       struct drm_panel *panel;
        int ret;
 
        msm_host->dev = dev;
+       panel = msm_dsi_host_get_panel(&msm_host->base);
+
+       if (!IS_ERR(panel) && panel->dsc) {
+               struct msm_display_dsc_config *dsc = msm_host->dsc;
+
+               if (!dsc) {
+                       dsc = devm_kzalloc(&msm_host->pdev->dev, sizeof(*dsc), GFP_KERNEL);
+                       if (!dsc)
+                               return -ENOMEM;
+                       dsc->drm = panel->dsc;
+                       msm_host->dsc = dsc;
+               }
+       }
+
        ret = cfg_hnd->ops->tx_buf_alloc(msm_host, SZ_4K);
        if (ret) {
                pr_err("%s: alloc tx gem obj failed, %d\n", __func__, ret);
@@ -2628,3 +2643,10 @@ void msm_dsi_host_test_pattern_en(struct mipi_dsi_host *host)
                dsi_write(msm_host, REG_DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER,
                                DSI_TEST_PATTERN_GEN_CMD_STREAM0_TRIGGER_SW_TRIGGER);
 }
+
+struct msm_display_dsc_config *msm_dsi_host_get_dsc_config(struct mipi_dsi_host *host)
+{
+       struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
+
+       return msm_host->dsc;
+}
index f07c722..5868862 100644 (file)
@@ -299,6 +299,7 @@ void msm_dsi_snapshot(struct msm_disp_state *disp_state, struct msm_dsi *msm_dsi
 bool msm_dsi_is_cmd_mode(struct msm_dsi *msm_dsi);
 bool msm_dsi_is_bonded_dsi(struct msm_dsi *msm_dsi);
 bool msm_dsi_is_master_dsi(struct msm_dsi *msm_dsi);
+struct msm_display_dsc_config *msm_dsi_get_dsc_config(struct msm_dsi *msm_dsi);
 #else
 static inline void __init msm_dsi_register(void)
 {
@@ -327,6 +328,11 @@ static inline bool msm_dsi_is_master_dsi(struct msm_dsi *msm_dsi)
 {
        return false;
 }
+
+static inline struct msm_display_dsc_config *msm_dsi_get_dsc_config(struct msm_dsi *msm_dsi)
+{
+       return NULL;
+}
 #endif
 
 #ifdef CONFIG_DRM_MSM_DP
index 1ba2d42..d279ee4 100644 (file)
@@ -179,6 +179,13 @@ struct drm_panel {
         * Panel entry in registry.
         */
        struct list_head list;
+
+       /**
+        * @dsc:
+        *
+        * Panel DSC pps payload to be sent
+        */
+       struct drm_dsc_config *dsc;
 };
 
 void drm_panel_init(struct drm_panel *panel, struct device *dev,