Re: [Freedreno] [PATCH 05/11] drm/msm/dpu: move dpu_hw_pipe_cfg out of struct dpu_plane

2021-10-21 Thread abhinavk

On 2021-09-30 06:59, Dmitry Baryshkov wrote:

struct dpu_hw_pipe_cfg represents an interim state during atomic
update/color fill, so move it out of struct dpu_plane.

Signed-off-by: Dmitry Baryshkov 

Reviewed-by: Abhinav Kumar 

---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 104 --
 1 file changed, 57 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index ef3737642b0c..5288b5b824f8 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -104,7 +104,6 @@ struct dpu_plane {
uint32_t features;  /* capabilities from catalog */

struct dpu_hw_pipe *pipe_hw;
-   struct dpu_hw_pipe_cfg pipe_cfg;
uint32_t color_fill;
bool is_error;
bool is_rt_pipe;
@@ -143,14 +142,15 @@ static struct dpu_kms *_dpu_plane_get_kms(struct
drm_plane *plane)
  * _dpu_plane_calc_bw - calculate bandwidth required for a plane
  * @plane: Pointer to drm plane.
  * @fb:   Pointer to framebuffer associated with the given plane
+ * @pipe_cfg: Pointer to pipe configuration
  * Result: Updates calculated bandwidth in the plane state.
  * BW Equation: src_w * src_h * bpp * fps * (v_total / v_dest)
  * Prefill BW Equation: line src bytes * line_time
  */
 static void _dpu_plane_calc_bw(struct drm_plane *plane,
-   struct drm_framebuffer *fb)
+   struct drm_framebuffer *fb,
+   struct dpu_hw_pipe_cfg *pipe_cfg)
 {
-   struct dpu_plane *pdpu = to_dpu_plane(plane);
struct dpu_plane_state *pstate;
struct drm_display_mode *mode;
const struct dpu_format *fmt = NULL;
@@ -167,9 +167,9 @@ static void _dpu_plane_calc_bw(struct drm_plane 
*plane,


fmt = dpu_get_dpu_format_ext(fb->format->format, fb->modifier);

-   src_width = drm_rect_width(>pipe_cfg.src_rect);
-   src_height = drm_rect_height(>pipe_cfg.src_rect);
-   dst_height = drm_rect_height(>pipe_cfg.dst_rect);
+   src_width = drm_rect_width(_cfg->src_rect);
+   src_height = drm_rect_height(_cfg->src_rect);
+   dst_height = drm_rect_height(_cfg->dst_rect);
fps = drm_mode_vrefresh(mode);
vbp = mode->vtotal - mode->vsync_end;
vpw = mode->vsync_end - mode->vsync_start;
@@ -200,12 +200,12 @@ static void _dpu_plane_calc_bw(struct drm_plane 
*plane,

 /**
  * _dpu_plane_calc_clk - calculate clock required for a plane
  * @plane: Pointer to drm plane.
+ * @pipe_cfg: Pointer to pipe configuration
  * Result: Updates calculated clock in the plane state.
  * Clock equation: dst_w * v_total * fps * (src_h / dst_h)
  */
-static void _dpu_plane_calc_clk(struct drm_plane *plane)
+static void _dpu_plane_calc_clk(struct drm_plane *plane, struct
dpu_hw_pipe_cfg *pipe_cfg)
 {
-   struct dpu_plane *pdpu = to_dpu_plane(plane);
struct dpu_plane_state *pstate;
struct drm_display_mode *mode;
int dst_width, src_height, dst_height, fps;
@@ -213,9 +213,9 @@ static void _dpu_plane_calc_clk(struct drm_plane 
*plane)

pstate = to_dpu_plane_state(plane->state);
mode = >state->crtc->mode;

-   src_height = drm_rect_height(>pipe_cfg.src_rect);
-   dst_width = drm_rect_width(>pipe_cfg.dst_rect);
-   dst_height = drm_rect_height(>pipe_cfg.dst_rect);
+   src_height = drm_rect_height(_cfg->src_rect);
+   dst_width = drm_rect_width(_cfg->dst_rect);
+   dst_height = drm_rect_height(_cfg->dst_rect);
fps = drm_mode_vrefresh(mode);

pstate->plane_clk =
@@ -252,14 +252,17 @@ static int _dpu_plane_calc_fill_level(struct
drm_plane *plane,
fixed_buff_size = pdpu->catalog->caps->pixel_ram_size;

list_for_each_entry(tmp, >mplane_list, mplane_list) {
+   u32 tmp_width;
+
if (!tmp->base.state->visible)
continue;
+   tmp_width = drm_rect_width(>base.state->src) >> 16;
DPU_DEBUG("plane%d/%d src_width:%d/%d\n",
pdpu->base.base.id, tmp->base.base.id,
src_width,
-   drm_rect_width(>pipe_cfg.src_rect));
+   tmp_width);
src_width = max_t(u32, src_width,
- drm_rect_width(>pipe_cfg.src_rect));
+ tmp_width);
}

if (fmt->fetch_planes == DPU_PLANE_PSEUDO_PLANAR) {
@@ -319,9 +322,10 @@ static u64 _dpu_plane_get_qos_lut(const struct
dpu_qos_lut_tbl *tbl,
  * _dpu_plane_set_qos_lut - set QoS LUT of the given plane
  * @plane: Pointer to drm plane
  * @fb:Pointer to framebuffer associated with the 
given plane
+ * @pipe_cfg:  Pointer to pipe configuration
  */
 static void _dpu_plane_set_qos_lut(struct drm_plane *plane,
-   struct drm_framebuffer *fb)
+   struct drm_framebuffer *fb, struct dpu_hw_pipe_cfg 

[Freedreno] [PATCH 05/11] drm/msm/dpu: move dpu_hw_pipe_cfg out of struct dpu_plane

2021-09-30 Thread Dmitry Baryshkov
struct dpu_hw_pipe_cfg represents an interim state during atomic
update/color fill, so move it out of struct dpu_plane.

Signed-off-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 104 --
 1 file changed, 57 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index ef3737642b0c..5288b5b824f8 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -104,7 +104,6 @@ struct dpu_plane {
uint32_t features;  /* capabilities from catalog */
 
struct dpu_hw_pipe *pipe_hw;
-   struct dpu_hw_pipe_cfg pipe_cfg;
uint32_t color_fill;
bool is_error;
bool is_rt_pipe;
@@ -143,14 +142,15 @@ static struct dpu_kms *_dpu_plane_get_kms(struct 
drm_plane *plane)
  * _dpu_plane_calc_bw - calculate bandwidth required for a plane
  * @plane: Pointer to drm plane.
  * @fb:   Pointer to framebuffer associated with the given plane
+ * @pipe_cfg: Pointer to pipe configuration
  * Result: Updates calculated bandwidth in the plane state.
  * BW Equation: src_w * src_h * bpp * fps * (v_total / v_dest)
  * Prefill BW Equation: line src bytes * line_time
  */
 static void _dpu_plane_calc_bw(struct drm_plane *plane,
-   struct drm_framebuffer *fb)
+   struct drm_framebuffer *fb,
+   struct dpu_hw_pipe_cfg *pipe_cfg)
 {
-   struct dpu_plane *pdpu = to_dpu_plane(plane);
struct dpu_plane_state *pstate;
struct drm_display_mode *mode;
const struct dpu_format *fmt = NULL;
@@ -167,9 +167,9 @@ static void _dpu_plane_calc_bw(struct drm_plane *plane,
 
fmt = dpu_get_dpu_format_ext(fb->format->format, fb->modifier);
 
-   src_width = drm_rect_width(>pipe_cfg.src_rect);
-   src_height = drm_rect_height(>pipe_cfg.src_rect);
-   dst_height = drm_rect_height(>pipe_cfg.dst_rect);
+   src_width = drm_rect_width(_cfg->src_rect);
+   src_height = drm_rect_height(_cfg->src_rect);
+   dst_height = drm_rect_height(_cfg->dst_rect);
fps = drm_mode_vrefresh(mode);
vbp = mode->vtotal - mode->vsync_end;
vpw = mode->vsync_end - mode->vsync_start;
@@ -200,12 +200,12 @@ static void _dpu_plane_calc_bw(struct drm_plane *plane,
 /**
  * _dpu_plane_calc_clk - calculate clock required for a plane
  * @plane: Pointer to drm plane.
+ * @pipe_cfg: Pointer to pipe configuration
  * Result: Updates calculated clock in the plane state.
  * Clock equation: dst_w * v_total * fps * (src_h / dst_h)
  */
-static void _dpu_plane_calc_clk(struct drm_plane *plane)
+static void _dpu_plane_calc_clk(struct drm_plane *plane, struct 
dpu_hw_pipe_cfg *pipe_cfg)
 {
-   struct dpu_plane *pdpu = to_dpu_plane(plane);
struct dpu_plane_state *pstate;
struct drm_display_mode *mode;
int dst_width, src_height, dst_height, fps;
@@ -213,9 +213,9 @@ static void _dpu_plane_calc_clk(struct drm_plane *plane)
pstate = to_dpu_plane_state(plane->state);
mode = >state->crtc->mode;
 
-   src_height = drm_rect_height(>pipe_cfg.src_rect);
-   dst_width = drm_rect_width(>pipe_cfg.dst_rect);
-   dst_height = drm_rect_height(>pipe_cfg.dst_rect);
+   src_height = drm_rect_height(_cfg->src_rect);
+   dst_width = drm_rect_width(_cfg->dst_rect);
+   dst_height = drm_rect_height(_cfg->dst_rect);
fps = drm_mode_vrefresh(mode);
 
pstate->plane_clk =
@@ -252,14 +252,17 @@ static int _dpu_plane_calc_fill_level(struct drm_plane 
*plane,
fixed_buff_size = pdpu->catalog->caps->pixel_ram_size;
 
list_for_each_entry(tmp, >mplane_list, mplane_list) {
+   u32 tmp_width;
+
if (!tmp->base.state->visible)
continue;
+   tmp_width = drm_rect_width(>base.state->src) >> 16;
DPU_DEBUG("plane%d/%d src_width:%d/%d\n",
pdpu->base.base.id, tmp->base.base.id,
src_width,
-   drm_rect_width(>pipe_cfg.src_rect));
+   tmp_width);
src_width = max_t(u32, src_width,
- drm_rect_width(>pipe_cfg.src_rect));
+ tmp_width);
}
 
if (fmt->fetch_planes == DPU_PLANE_PSEUDO_PLANAR) {
@@ -319,9 +322,10 @@ static u64 _dpu_plane_get_qos_lut(const struct 
dpu_qos_lut_tbl *tbl,
  * _dpu_plane_set_qos_lut - set QoS LUT of the given plane
  * @plane: Pointer to drm plane
  * @fb:Pointer to framebuffer associated with the 
given plane
+ * @pipe_cfg:  Pointer to pipe configuration
  */
 static void _dpu_plane_set_qos_lut(struct drm_plane *plane,
-   struct drm_framebuffer *fb)
+   struct drm_framebuffer *fb, struct dpu_hw_pipe_cfg *pipe_cfg)
 {
struct dpu_plane *pdpu = to_dpu_plane(plane);