drm/msm/dpu: rework static color fill code
authorDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Thu, 16 Mar 2023 16:16:46 +0000 (19:16 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Thu, 6 Apr 2023 17:29:42 +0000 (20:29 +0300)
Rework static color fill code to separate the pipe / pipe_cfg handling.
This is a preparation for the r_pipe support.

Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Tested-by: Abhinav Kumar <quic_abhinavk@quicinc.com> # sc7280
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Patchwork: https://patchwork.freedesktop.org/patch/527340/
Link: https://lore.kernel.org/r/20230316161653.4106395-26-dmitry.baryshkov@linaro.org
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c

index b8084c2..8a66261 100644 (file)
@@ -641,20 +641,52 @@ static void _dpu_plane_setup_scaler(struct dpu_sw_pipe *pipe,
                                fmt);
 }
 
+static void _dpu_plane_color_fill_pipe(struct dpu_plane_state *pstate,
+                                      struct dpu_sw_pipe *pipe,
+                                      struct drm_rect *dst_rect,
+                                      u32 fill_color,
+                                      const struct dpu_format *fmt)
+{
+       struct dpu_sw_pipe_cfg pipe_cfg;
+
+       /* update sspp */
+       if (!pipe->sspp->ops.setup_solidfill)
+               return;
+
+       pipe->sspp->ops.setup_solidfill(pipe, fill_color);
+
+       /* override scaler/decimation if solid fill */
+       pipe_cfg.dst_rect = *dst_rect;
+
+       pipe_cfg.src_rect.x1 = 0;
+       pipe_cfg.src_rect.y1 = 0;
+       pipe_cfg.src_rect.x2 =
+               drm_rect_width(&pipe_cfg.dst_rect);
+       pipe_cfg.src_rect.y2 =
+               drm_rect_height(&pipe_cfg.dst_rect);
+
+       if (pipe->sspp->ops.setup_format)
+               pipe->sspp->ops.setup_format(pipe, fmt, DPU_SSPP_SOLID_FILL);
+
+       if (pipe->sspp->ops.setup_rects)
+               pipe->sspp->ops.setup_rects(pipe, &pipe_cfg);
+
+       _dpu_plane_setup_scaler(pipe, fmt, true, &pipe_cfg, pstate->rotation);
+}
+
 /**
  * _dpu_plane_color_fill - enables color fill on plane
  * @pdpu:   Pointer to DPU plane object
  * @color:  RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red
  * @alpha:  8-bit fill alpha value, 255 selects 100% alpha
- * Returns: 0 on success
  */
-static int _dpu_plane_color_fill(struct dpu_plane *pdpu,
+static void _dpu_plane_color_fill(struct dpu_plane *pdpu,
                uint32_t color, uint32_t alpha)
 {
        const struct dpu_format *fmt;
        const struct drm_plane *plane = &pdpu->base;
        struct dpu_plane_state *pstate = to_dpu_plane_state(plane->state);
-       struct dpu_sw_pipe_cfg pipe_cfg;
+       u32 fill_color = (color & 0xFFFFFF) | ((alpha & 0xFF) << 24);
 
        DPU_DEBUG_PLANE(pdpu, "\n");
 
@@ -663,34 +695,13 @@ static int _dpu_plane_color_fill(struct dpu_plane *pdpu,
         * h/w only supports RGB variants
         */
        fmt = dpu_get_dpu_format(DRM_FORMAT_ABGR8888);
+       /* should not happen ever */
+       if (!fmt)
+               return;
 
        /* update sspp */
-       if (fmt && pstate->pipe.sspp->ops.setup_solidfill) {
-               pstate->pipe.sspp->ops.setup_solidfill(&pstate->pipe,
-                               (color & 0xFFFFFF) | ((alpha & 0xFF) << 24));
-
-               /* override scaler/decimation if solid fill */
-               pipe_cfg.dst_rect = pstate->base.dst;
-
-               pipe_cfg.src_rect.x1 = 0;
-               pipe_cfg.src_rect.y1 = 0;
-               pipe_cfg.src_rect.x2 =
-                       drm_rect_width(&pipe_cfg.dst_rect);
-               pipe_cfg.src_rect.y2 =
-                       drm_rect_height(&pipe_cfg.dst_rect);
-
-               if (pstate->pipe.sspp->ops.setup_format)
-                       pstate->pipe.sspp->ops.setup_format(&pstate->pipe,
-                                       fmt, DPU_SSPP_SOLID_FILL);
-
-               if (pstate->pipe.sspp->ops.setup_rects)
-                       pstate->pipe.sspp->ops.setup_rects(&pstate->pipe,
-                                       &pipe_cfg);
-
-               _dpu_plane_setup_scaler(&pstate->pipe, fmt, true, &pipe_cfg, pstate->rotation);
-       }
-
-       return 0;
+       _dpu_plane_color_fill_pipe(pstate, &pstate->pipe, &pstate->pipe_cfg.dst_rect,
+                                  fill_color, fmt);
 }
 
 int dpu_plane_validate_multirect_v2(struct dpu_multirect_plane_states *plane)