Skip to content

Commit d13445b

Browse files
committed
drm/msm/dpu: pass drm_framebuffer to _dpu_format_get_plane_sizes()
Instead of passing width / height / pitches, pass drm_framebuffer directly. This allows us to drop the useless check for !pitches, since an array can not be NULL. Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Patchwork: https://patchwork.freedesktop.org/patch/612248/ Link: https://lore.kernel.org/r/20240903-dpu-mode-config-width-v6-8-617e1ecc4b7a@linaro.org
1 parent 5e317a6 commit d13445b

1 file changed

Lines changed: 34 additions & 39 deletions

File tree

drivers/gpu/drm/msm/disp/dpu1/dpu_formats.c

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,16 @@ static int _dpu_format_get_media_color_ubwc(const struct msm_format *fmt)
9595

9696
static int _dpu_format_get_plane_sizes_ubwc(
9797
const struct msm_format *fmt,
98-
const uint32_t width,
99-
const uint32_t height,
98+
struct drm_framebuffer *fb,
10099
struct dpu_hw_fmt_layout *layout)
101100
{
102101
int i;
103102
int color;
104103
bool meta = MSM_FORMAT_IS_UBWC(fmt);
105104

106105
memset(layout, 0, sizeof(struct dpu_hw_fmt_layout));
107-
layout->width = width;
108-
layout->height = height;
106+
layout->width = fb->width;
107+
layout->height = fb->height;
109108
layout->num_planes = fmt->num_planes;
110109

111110
color = _dpu_format_get_media_color_ubwc(fmt);
@@ -121,27 +120,27 @@ static int _dpu_format_get_plane_sizes_ubwc(
121120
uint32_t uv_meta_scanlines = 0;
122121

123122
layout->num_planes = 2;
124-
layout->plane_pitch[0] = VENUS_Y_STRIDE(color, width);
125-
y_sclines = VENUS_Y_SCANLINES(color, height);
123+
layout->plane_pitch[0] = VENUS_Y_STRIDE(color, fb->width);
124+
y_sclines = VENUS_Y_SCANLINES(color, fb->height);
126125
layout->plane_size[0] = MSM_MEDIA_ALIGN(layout->plane_pitch[0] *
127126
y_sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
128127

129-
layout->plane_pitch[1] = VENUS_UV_STRIDE(color, width);
130-
uv_sclines = VENUS_UV_SCANLINES(color, height);
128+
layout->plane_pitch[1] = VENUS_UV_STRIDE(color, fb->width);
129+
uv_sclines = VENUS_UV_SCANLINES(color, fb->height);
131130
layout->plane_size[1] = MSM_MEDIA_ALIGN(layout->plane_pitch[1] *
132131
uv_sclines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
133132

134133
if (!meta)
135134
goto done;
136135

137136
layout->num_planes += 2;
138-
layout->plane_pitch[2] = VENUS_Y_META_STRIDE(color, width);
139-
y_meta_scanlines = VENUS_Y_META_SCANLINES(color, height);
137+
layout->plane_pitch[2] = VENUS_Y_META_STRIDE(color, fb->width);
138+
y_meta_scanlines = VENUS_Y_META_SCANLINES(color, fb->height);
140139
layout->plane_size[2] = MSM_MEDIA_ALIGN(layout->plane_pitch[2] *
141140
y_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
142141

143-
layout->plane_pitch[3] = VENUS_UV_META_STRIDE(color, width);
144-
uv_meta_scanlines = VENUS_UV_META_SCANLINES(color, height);
142+
layout->plane_pitch[3] = VENUS_UV_META_STRIDE(color, fb->width);
143+
uv_meta_scanlines = VENUS_UV_META_SCANLINES(color, fb->height);
145144
layout->plane_size[3] = MSM_MEDIA_ALIGN(layout->plane_pitch[3] *
146145
uv_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
147146

@@ -150,16 +149,16 @@ static int _dpu_format_get_plane_sizes_ubwc(
150149

151150
layout->num_planes = 1;
152151

153-
layout->plane_pitch[0] = VENUS_RGB_STRIDE(color, width);
154-
rgb_scanlines = VENUS_RGB_SCANLINES(color, height);
152+
layout->plane_pitch[0] = VENUS_RGB_STRIDE(color, fb->width);
153+
rgb_scanlines = VENUS_RGB_SCANLINES(color, fb->height);
155154
layout->plane_size[0] = MSM_MEDIA_ALIGN(layout->plane_pitch[0] *
156155
rgb_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
157156

158157
if (!meta)
159158
goto done;
160159
layout->num_planes += 2;
161-
layout->plane_pitch[2] = VENUS_RGB_META_STRIDE(color, width);
162-
rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color, height);
160+
layout->plane_pitch[2] = VENUS_RGB_META_STRIDE(color, fb->width);
161+
rgb_meta_scanlines = VENUS_RGB_META_SCANLINES(color, fb->height);
163162
layout->plane_size[2] = MSM_MEDIA_ALIGN(layout->plane_pitch[2] *
164163
rgb_meta_scanlines, DPU_UBWC_PLANE_SIZE_ALIGNMENT);
165164
}
@@ -173,23 +172,21 @@ static int _dpu_format_get_plane_sizes_ubwc(
173172

174173
static int _dpu_format_get_plane_sizes_linear(
175174
const struct msm_format *fmt,
176-
const uint32_t width,
177-
const uint32_t height,
178-
struct dpu_hw_fmt_layout *layout,
179-
const uint32_t *pitches)
175+
struct drm_framebuffer *fb,
176+
struct dpu_hw_fmt_layout *layout)
180177
{
181178
int i;
182179

183180
memset(layout, 0, sizeof(struct dpu_hw_fmt_layout));
184-
layout->width = width;
185-
layout->height = height;
181+
layout->width = fb->width;
182+
layout->height = fb->height;
186183
layout->num_planes = fmt->num_planes;
187184

188185
/* Due to memset above, only need to set planes of interest */
189186
if (fmt->fetch_type == MDP_PLANE_INTERLEAVED) {
190187
layout->num_planes = 1;
191-
layout->plane_size[0] = width * height * fmt->bpp;
192-
layout->plane_pitch[0] = width * fmt->bpp;
188+
layout->plane_size[0] = fb->width * fb->height * fmt->bpp;
189+
layout->plane_pitch[0] = fb->width * fmt->bpp;
193190
} else {
194191
uint32_t v_subsample, h_subsample;
195192
uint32_t chroma_samp;
@@ -199,19 +196,19 @@ static int _dpu_format_get_plane_sizes_linear(
199196
_dpu_get_v_h_subsample_rate(chroma_samp, &v_subsample,
200197
&h_subsample);
201198

202-
if (width % h_subsample || height % v_subsample) {
199+
if (fb->width % h_subsample || fb->height % v_subsample) {
203200
DRM_ERROR("mismatch in subsample vs dimensions\n");
204201
return -EINVAL;
205202
}
206203

207204
if ((fmt->pixel_format == DRM_FORMAT_NV12) &&
208205
(MSM_FORMAT_IS_DX(fmt)))
209206
bpp = 2;
210-
layout->plane_pitch[0] = width * bpp;
207+
layout->plane_pitch[0] = fb->width * bpp;
211208
layout->plane_pitch[1] = layout->plane_pitch[0] / h_subsample;
212-
layout->plane_size[0] = layout->plane_pitch[0] * height;
209+
layout->plane_size[0] = layout->plane_pitch[0] * fb->height;
213210
layout->plane_size[1] = layout->plane_pitch[1] *
214-
(height / v_subsample);
211+
(fb->height / v_subsample);
215212

216213
if (fmt->fetch_type == MDP_PLANE_PSEUDO_PLANAR) {
217214
layout->num_planes = 2;
@@ -232,8 +229,8 @@ static int _dpu_format_get_plane_sizes_linear(
232229
* all the components based on ubwc specifications.
233230
*/
234231
for (i = 0; i < layout->num_planes && i < DPU_MAX_PLANES; ++i) {
235-
if (pitches && layout->plane_pitch[i] < pitches[i])
236-
layout->plane_pitch[i] = pitches[i];
232+
if (layout->plane_pitch[i] < fb->pitches[i])
233+
layout->plane_pitch[i] = fb->pitches[i];
237234
}
238235

239236
for (i = 0; i < DPU_MAX_PLANES; i++)
@@ -244,25 +241,24 @@ static int _dpu_format_get_plane_sizes_linear(
244241

245242
static int dpu_format_get_plane_sizes(
246243
const struct msm_format *fmt,
247-
const uint32_t w,
248-
const uint32_t h,
249-
struct dpu_hw_fmt_layout *layout,
250-
const uint32_t *pitches)
244+
struct drm_framebuffer *fb,
245+
struct dpu_hw_fmt_layout *layout)
251246
{
252247
if (!layout || !fmt) {
253248
DRM_ERROR("invalid pointer\n");
254249
return -EINVAL;
255250
}
256251

257-
if ((w > DPU_MAX_IMG_WIDTH) || (h > DPU_MAX_IMG_HEIGHT)) {
252+
if (fb->width > DPU_MAX_IMG_WIDTH ||
253+
fb->height > DPU_MAX_IMG_HEIGHT) {
258254
DRM_ERROR("image dimensions outside max range\n");
259255
return -ERANGE;
260256
}
261257

262258
if (MSM_FORMAT_IS_UBWC(fmt) || MSM_FORMAT_IS_TILE(fmt))
263-
return _dpu_format_get_plane_sizes_ubwc(fmt, w, h, layout);
259+
return _dpu_format_get_plane_sizes_ubwc(fmt, fb, layout);
264260

265-
return _dpu_format_get_plane_sizes_linear(fmt, w, h, layout, pitches);
261+
return _dpu_format_get_plane_sizes_linear(fmt, fb, layout);
266262
}
267263

268264
static int _dpu_format_populate_addrs_ubwc(
@@ -407,8 +403,7 @@ int dpu_format_populate_layout(
407403
fmt = msm_framebuffer_format(fb);
408404

409405
/* Populate the plane sizes etc via get_format */
410-
ret = dpu_format_get_plane_sizes(fmt, fb->width, fb->height,
411-
layout, fb->pitches);
406+
ret = dpu_format_get_plane_sizes(fmt, fb, layout);
412407
if (ret)
413408
return ret;
414409

0 commit comments

Comments
 (0)