aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@bootlin.com>2019-05-16 06:31:49 -0400
committerMaxime Ripard <maxime.ripard@bootlin.com>2019-05-20 07:33:46 -0400
commit24c478ead0bf50a758e9dbecc7356e9eebf20271 (patch)
tree98e211adb76be84c41021cddc20e40e718500f2e
parentf3e9632cb6241a6c098427510ad3ee041365ae64 (diff)
drm/fourcc: Pass the format_info pointer to drm_format_plane_cpp
So far, the drm_format_plane_cpp function was operating on the format's fourcc and was doing a lookup to retrieve the drm_format_info structure and return the cpp. However, this is inefficient since in most cases, we will have the drm_format_info pointer already available so we shouldn't have to perform a new lookup. Some drm_fourcc functions also already operate on the drm_format_info pointer for that reason, so the API is quite inconsistent there. Let's follow the latter pattern and remove the extra lookup while being a bit more consistent. In order to be extra consistent, also rename that function to drm_format_info_plane_cpp and to a static function in the header to match the current policy. Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/32aa13e53dbc98a90207fd290aa8e79f785fb11e.1558002671.git-series.maxime.ripard@bootlin.com
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c4
-rw-r--r--drivers/gpu/drm/arm/malidp_hw.c3
-rw-r--r--drivers/gpu/drm/arm/malidp_planes.c2
-rw-r--r--drivers/gpu/drm/drm_client.c3
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c2
-rw-r--r--drivers/gpu/drm/drm_format_helper.c4
-rw-r--r--drivers/gpu/drm/drm_fourcc.c20
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c3
-rw-r--r--drivers/gpu/drm/mediatek/mtk_drm_fb.c2
-rw-r--r--drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c3
-rw-r--r--drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c2
-rw-r--r--drivers/gpu/drm/msm/msm_fb.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_fb.c4
-rw-r--r--drivers/gpu/drm/rockchip/rockchip_drm_fb.c2
-rw-r--r--drivers/gpu/drm/stm/ltdc.c2
-rw-r--r--drivers/gpu/drm/tegra/fb.c2
-rw-r--r--drivers/gpu/drm/zte/zx_plane.c2
-rw-r--r--include/drm/drm_fourcc.h18
18 files changed, 42 insertions, 38 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index e47609218839..06e73a343724 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -121,6 +121,8 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
121 struct drm_mode_fb_cmd2 *mode_cmd, 121 struct drm_mode_fb_cmd2 *mode_cmd,
122 struct drm_gem_object **gobj_p) 122 struct drm_gem_object **gobj_p)
123{ 123{
124 const struct drm_format_info *info = drm_get_format_info(dev,
125 mode_cmd);
124 struct amdgpu_device *adev = rfbdev->adev; 126 struct amdgpu_device *adev = rfbdev->adev;
125 struct drm_gem_object *gobj = NULL; 127 struct drm_gem_object *gobj = NULL;
126 struct amdgpu_bo *abo = NULL; 128 struct amdgpu_bo *abo = NULL;
@@ -131,7 +133,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
131 int height = mode_cmd->height; 133 int height = mode_cmd->height;
132 u32 cpp; 134 u32 cpp;
133 135
134 cpp = drm_format_plane_cpp(mode_cmd->pixel_format, 0); 136 cpp = drm_format_info_plane_cpp(info, 0);
135 137
136 /* need to align pitch with crtc limits */ 138 /* need to align pitch with crtc limits */
137 mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp, 139 mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
diff --git a/drivers/gpu/drm/arm/malidp_hw.c b/drivers/gpu/drm/arm/malidp_hw.c
index 8df12e9a33bb..1c9e869f4c52 100644
--- a/drivers/gpu/drm/arm/malidp_hw.c
+++ b/drivers/gpu/drm/arm/malidp_hw.c
@@ -382,7 +382,8 @@ static void malidp500_modeset(struct malidp_hw_device *hwdev, struct videomode *
382 382
383int malidp_format_get_bpp(u32 fmt) 383int malidp_format_get_bpp(u32 fmt)
384{ 384{
385 int bpp = drm_format_plane_cpp(fmt, 0) * 8; 385 const struct drm_format_info *info = drm_format_info(fmt);
386 int bpp = drm_format_info_plane_cpp(info, 0) * 8;
386 387
387 if (bpp == 0) { 388 if (bpp == 0) {
388 switch (fmt) { 389 switch (fmt) {
diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index 8f89813d08c1..361c02988375 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -227,7 +227,7 @@ bool malidp_format_mod_supported(struct drm_device *drm,
227 227
228 if (modifier & AFBC_SPLIT) { 228 if (modifier & AFBC_SPLIT) {
229 if (!info->is_yuv) { 229 if (!info->is_yuv) {
230 if (drm_format_plane_cpp(format, 0) <= 2) { 230 if (drm_format_info_plane_cpp(info, 0) <= 2) {
231 DRM_DEBUG_KMS("RGB formats <= 16bpp are not supported with SPLIT\n"); 231 DRM_DEBUG_KMS("RGB formats <= 16bpp are not supported with SPLIT\n");
232 return false; 232 return false;
233 } 233 }
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index f20d1dda3961..169d8eeaa662 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -243,6 +243,7 @@ static void drm_client_buffer_delete(struct drm_client_buffer *buffer)
243static struct drm_client_buffer * 243static struct drm_client_buffer *
244drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format) 244drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format)
245{ 245{
246 const struct drm_format_info *info = drm_format_info(format);
246 struct drm_mode_create_dumb dumb_args = { }; 247 struct drm_mode_create_dumb dumb_args = { };
247 struct drm_device *dev = client->dev; 248 struct drm_device *dev = client->dev;
248 struct drm_client_buffer *buffer; 249 struct drm_client_buffer *buffer;
@@ -258,7 +259,7 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height, u
258 259
259 dumb_args.width = width; 260 dumb_args.width = width;
260 dumb_args.height = height; 261 dumb_args.height = height;
261 dumb_args.bpp = drm_format_plane_cpp(format, 0) * 8; 262 dumb_args.bpp = drm_format_info_plane_cpp(info, 0) * 8;
262 ret = drm_mode_create_dumb(dev, &dumb_args, client->file); 263 ret = drm_mode_create_dumb(dev, &dumb_args, client->file);
263 if (ret) 264 if (ret)
264 goto err_delete; 265 goto err_delete;
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index a52b48fafbd7..e2d9a6da14a5 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -813,7 +813,7 @@ static void drm_fb_helper_dirty_blit_real(struct drm_fb_helper *fb_helper,
813 struct drm_clip_rect *clip) 813 struct drm_clip_rect *clip)
814{ 814{
815 struct drm_framebuffer *fb = fb_helper->fb; 815 struct drm_framebuffer *fb = fb_helper->fb;
816 unsigned int cpp = drm_format_plane_cpp(fb->format->format, 0); 816 unsigned int cpp = drm_format_info_plane_cpp(fb->format, 0);
817 size_t offset = clip->y1 * fb->pitches[0] + clip->x1 * cpp; 817 size_t offset = clip->y1 * fb->pitches[0] + clip->x1 * cpp;
818 void *src = fb_helper->fbdev->screen_buffer + offset; 818 void *src = fb_helper->fbdev->screen_buffer + offset;
819 void *dst = fb_helper->buffer->vaddr + offset; 819 void *dst = fb_helper->buffer->vaddr + offset;
diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c
index a18da35145b7..8ad66aa1362a 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -36,7 +36,7 @@ static unsigned int clip_offset(struct drm_rect *clip,
36void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb, 36void drm_fb_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb,
37 struct drm_rect *clip) 37 struct drm_rect *clip)
38{ 38{
39 unsigned int cpp = drm_format_plane_cpp(fb->format->format, 0); 39 unsigned int cpp = drm_format_info_plane_cpp(fb->format, 0);
40 size_t len = (clip->x2 - clip->x1) * cpp; 40 size_t len = (clip->x2 - clip->x1) * cpp;
41 unsigned int y, lines = clip->y2 - clip->y1; 41 unsigned int y, lines = clip->y2 - clip->y1;
42 42
@@ -63,7 +63,7 @@ void drm_fb_memcpy_dstclip(void __iomem *dst, void *vaddr,
63 struct drm_framebuffer *fb, 63 struct drm_framebuffer *fb,
64 struct drm_rect *clip) 64 struct drm_rect *clip)
65{ 65{
66 unsigned int cpp = drm_format_plane_cpp(fb->format->format, 0); 66 unsigned int cpp = drm_format_info_plane_cpp(fb->format, 0);
67 unsigned int offset = clip_offset(clip, fb->pitches[0], cpp); 67 unsigned int offset = clip_offset(clip, fb->pitches[0], cpp);
68 size_t len = (clip->x2 - clip->x1) * cpp; 68 size_t len = (clip->x2 - clip->x1) * cpp;
69 unsigned int y, lines = clip->y2 - clip->y1; 69 unsigned int y, lines = clip->y2 - clip->y1;
diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index e4a2c8372c8b..5f63fc74e265 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -333,26 +333,6 @@ drm_get_format_info(struct drm_device *dev,
333EXPORT_SYMBOL(drm_get_format_info); 333EXPORT_SYMBOL(drm_get_format_info);
334 334
335/** 335/**
336 * drm_format_plane_cpp - determine the bytes per pixel value
337 * @format: pixel format (DRM_FORMAT_*)
338 * @plane: plane index
339 *
340 * Returns:
341 * The bytes per pixel value for the specified plane.
342 */
343int drm_format_plane_cpp(uint32_t format, int plane)
344{
345 const struct drm_format_info *info;
346
347 info = drm_format_info(format);
348 if (!info || plane >= info->num_planes)
349 return 0;
350
351 return info->cpp[plane];
352}
353EXPORT_SYMBOL(drm_format_plane_cpp);
354
355/**
356 * drm_format_plane_width - width of the plane given the first plane 336 * drm_format_plane_width - width of the plane given the first plane
357 * @width: width of the first plane 337 * @width: width of the first plane
358 * @format: pixel format 338 * @format: pixel format
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 2913e89280d7..e35601b1f878 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -325,7 +325,8 @@ skl_plane_max_stride(struct intel_plane *plane,
325 u32 pixel_format, u64 modifier, 325 u32 pixel_format, u64 modifier,
326 unsigned int rotation) 326 unsigned int rotation)
327{ 327{
328 int cpp = drm_format_plane_cpp(pixel_format, 0); 328 const struct drm_format_info *info = drm_format_info(pixel_format);
329 int cpp = drm_format_info_plane_cpp(info, 0);
329 330
330 /* 331 /*
331 * "The stride in bytes must not exceed the 332 * "The stride in bytes must not exceed the
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_fb.c b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
index 68fdef8b12bd..0d5334a5a9a7 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_fb.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_fb.c
@@ -104,7 +104,7 @@ struct drm_framebuffer *mtk_drm_mode_fb_create(struct drm_device *dev,
104 if (!gem) 104 if (!gem)
105 return ERR_PTR(-ENOENT); 105 return ERR_PTR(-ENOENT);
106 106
107 bpp = drm_format_plane_cpp(cmd->pixel_format, 0); 107 bpp = drm_format_info_plane_cpp(info, 0);
108 size = (height - 1) * cmd->pitches[0] + width * bpp; 108 size = (height - 1) * cmd->pitches[0] + width * bpp;
109 size += cmd->offsets[0]; 109 size += cmd->offsets[0];
110 110
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index f33d7007e830..59b24e0c5070 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -782,6 +782,7 @@ static void get_roi(struct drm_crtc *crtc, uint32_t *roi_w, uint32_t *roi_h)
782 782
783static void mdp5_crtc_restore_cursor(struct drm_crtc *crtc) 783static void mdp5_crtc_restore_cursor(struct drm_crtc *crtc)
784{ 784{
785 const struct drm_format_info *info = drm_format_info(DRM_FORMAT_ARGB8888);
785 struct mdp5_crtc_state *mdp5_cstate = to_mdp5_crtc_state(crtc->state); 786 struct mdp5_crtc_state *mdp5_cstate = to_mdp5_crtc_state(crtc->state);
786 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc); 787 struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
787 struct mdp5_kms *mdp5_kms = get_kms(crtc); 788 struct mdp5_kms *mdp5_kms = get_kms(crtc);
@@ -800,7 +801,7 @@ static void mdp5_crtc_restore_cursor(struct drm_crtc *crtc)
800 width = mdp5_crtc->cursor.width; 801 width = mdp5_crtc->cursor.width;
801 height = mdp5_crtc->cursor.height; 802 height = mdp5_crtc->cursor.height;
802 803
803 stride = width * drm_format_plane_cpp(DRM_FORMAT_ARGB8888, 0); 804 stride = width * drm_format_info_plane_cpp(info, 0);
804 805
805 get_roi(crtc, &roi_w, &roi_h); 806 get_roi(crtc, &roi_w, &roi_h);
806 807
diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
index b30b2f4efc60..1ca294694597 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
@@ -158,7 +158,7 @@ uint32_t mdp5_smp_calculate(struct mdp5_smp *smp,
158 for (i = 0; i < nplanes; i++) { 158 for (i = 0; i < nplanes; i++) {
159 int n, fetch_stride, cpp; 159 int n, fetch_stride, cpp;
160 160
161 cpp = drm_format_plane_cpp(fmt, i); 161 cpp = drm_format_info_plane_cpp(info, i);
162 fetch_stride = width * cpp / (i ? hsub : 1); 162 fetch_stride = width * cpp / (i ? hsub : 1);
163 163
164 n = DIV_ROUND_UP(fetch_stride * nlines, smp->blk_size); 164 n = DIV_ROUND_UP(fetch_stride * nlines, smp->blk_size);
diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
index f69c0afd6ec6..29e45f2144b5 100644
--- a/drivers/gpu/drm/msm/msm_fb.c
+++ b/drivers/gpu/drm/msm/msm_fb.c
@@ -181,7 +181,7 @@ static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
181 unsigned int min_size; 181 unsigned int min_size;
182 182
183 min_size = (height - 1) * mode_cmd->pitches[i] 183 min_size = (height - 1) * mode_cmd->pitches[i]
184 + width * drm_format_plane_cpp(mode_cmd->pixel_format, i) 184 + width * drm_format_info_plane_cpp(info, i)
185 + mode_cmd->offsets[i]; 185 + mode_cmd->offsets[i];
186 186
187 if (bos[i]->size < min_size) { 187 if (bos[i]->size < min_size) {
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 1298b84cb1c7..dbf596fc4339 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -125,6 +125,7 @@ static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev,
125 struct drm_mode_fb_cmd2 *mode_cmd, 125 struct drm_mode_fb_cmd2 *mode_cmd,
126 struct drm_gem_object **gobj_p) 126 struct drm_gem_object **gobj_p)
127{ 127{
128 const struct drm_format_info *info;
128 struct radeon_device *rdev = rfbdev->rdev; 129 struct radeon_device *rdev = rfbdev->rdev;
129 struct drm_gem_object *gobj = NULL; 130 struct drm_gem_object *gobj = NULL;
130 struct radeon_bo *rbo = NULL; 131 struct radeon_bo *rbo = NULL;
@@ -135,7 +136,8 @@ static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev,
135 int height = mode_cmd->height; 136 int height = mode_cmd->height;
136 u32 cpp; 137 u32 cpp;
137 138
138 cpp = drm_format_plane_cpp(mode_cmd->pixel_format, 0); 139 info = drm_get_format_info(rdev->ddev, mode_cmd);
140 cpp = drm_format_info_plane_cpp(info, 0);
139 141
140 /* need to align pitch with crtc limits */ 142 /* need to align pitch with crtc limits */
141 mode_cmd->pitches[0] = radeon_align_pitch(rdev, mode_cmd->width, cpp, 143 mode_cmd->pitches[0] = radeon_align_pitch(rdev, mode_cmd->width, cpp,
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
index c318fae28581..57873c99ae29 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
@@ -98,7 +98,7 @@ rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
98 98
99 min_size = (height - 1) * mode_cmd->pitches[i] + 99 min_size = (height - 1) * mode_cmd->pitches[i] +
100 mode_cmd->offsets[i] + 100 mode_cmd->offsets[i] +
101 width * drm_format_plane_cpp(mode_cmd->pixel_format, i); 101 width * drm_format_info_plane_cpp(info, i);
102 102
103 if (obj->size < min_size) { 103 if (obj->size < min_size) {
104 drm_gem_object_put_unlocked(obj); 104 drm_gem_object_put_unlocked(obj);
diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
index 97912e2c663d..e7abe54b9746 100644
--- a/drivers/gpu/drm/stm/ltdc.c
+++ b/drivers/gpu/drm/stm/ltdc.c
@@ -784,7 +784,7 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,
784 784
785 /* Configures the color frame buffer pitch in bytes & line length */ 785 /* Configures the color frame buffer pitch in bytes & line length */
786 pitch_in_bytes = fb->pitches[0]; 786 pitch_in_bytes = fb->pitches[0];
787 line_length = drm_format_plane_cpp(fb->format->format, 0) * 787 line_length = drm_format_info_plane_cpp(fb->format, 0) *
788 (x1 - x0 + 1) + (ldev->caps.bus_width >> 3) - 1; 788 (x1 - x0 + 1) + (ldev->caps.bus_width >> 3) - 1;
789 val = ((pitch_in_bytes << 16) | line_length); 789 val = ((pitch_in_bytes << 16) | line_length);
790 reg_update_bits(ldev->regs, LTDC_L1CFBLR + lofs, 790 reg_update_bits(ldev->regs, LTDC_L1CFBLR + lofs,
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 94fb75089d87..d1042196a30f 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -149,7 +149,7 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
149 goto unreference; 149 goto unreference;
150 } 150 }
151 151
152 bpp = drm_format_plane_cpp(cmd->pixel_format, i); 152 bpp = drm_format_info_plane_cpp(info, i);
153 153
154 size = (height - 1) * cmd->pitches[i] + 154 size = (height - 1) * cmd->pitches[i] +
155 width * bpp + cmd->offsets[i]; 155 width * bpp + cmd->offsets[i];
diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
index c6a8be444300..d97a4dff515d 100644
--- a/drivers/gpu/drm/zte/zx_plane.c
+++ b/drivers/gpu/drm/zte/zx_plane.c
@@ -222,7 +222,7 @@ static void zx_vl_plane_atomic_update(struct drm_plane *plane,
222 cma_obj = drm_fb_cma_get_gem_obj(fb, i); 222 cma_obj = drm_fb_cma_get_gem_obj(fb, i);
223 paddr = cma_obj->paddr + fb->offsets[i]; 223 paddr = cma_obj->paddr + fb->offsets[i];
224 paddr += src_y * fb->pitches[i]; 224 paddr += src_y * fb->pitches[i];
225 paddr += src_x * drm_format_plane_cpp(format, i); 225 paddr += src_x * drm_format_info_plane_cpp(fb->format, i);
226 zx_writel(paddr_reg, paddr); 226 zx_writel(paddr_reg, paddr);
227 paddr_reg += 4; 227 paddr_reg += 4;
228 } 228 }
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index eeec449d6c6a..6b5a82b31bc4 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -260,6 +260,23 @@ drm_format_info_is_yuv_sampling_444(const struct drm_format_info *info)
260 return info->is_yuv && info->hsub == 1 && info->vsub == 1; 260 return info->is_yuv && info->hsub == 1 && info->vsub == 1;
261} 261}
262 262
263/**
264 * drm_format_info_plane_cpp - determine the bytes per pixel value
265 * @format: pixel format info
266 * @plane: plane index
267 *
268 * Returns:
269 * The bytes per pixel value for the specified plane.
270 */
271static inline
272int drm_format_info_plane_cpp(const struct drm_format_info *info, int plane)
273{
274 if (!info || plane >= info->num_planes)
275 return 0;
276
277 return info->cpp[plane];
278}
279
263const struct drm_format_info *__drm_format_info(u32 format); 280const struct drm_format_info *__drm_format_info(u32 format);
264const struct drm_format_info *drm_format_info(u32 format); 281const struct drm_format_info *drm_format_info(u32 format);
265const struct drm_format_info * 282const struct drm_format_info *
@@ -268,7 +285,6 @@ drm_get_format_info(struct drm_device *dev,
268uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); 285uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
269uint32_t drm_driver_legacy_fb_format(struct drm_device *dev, 286uint32_t drm_driver_legacy_fb_format(struct drm_device *dev,
270 uint32_t bpp, uint32_t depth); 287 uint32_t bpp, uint32_t depth);
271int drm_format_plane_cpp(uint32_t format, int plane);
272int drm_format_plane_width(int width, uint32_t format, int plane); 288int drm_format_plane_width(int width, uint32_t format, int plane);
273int drm_format_plane_height(int height, uint32_t format, int plane); 289int drm_format_plane_height(int height, uint32_t format, int plane);
274unsigned int drm_format_info_block_width(const struct drm_format_info *info, 290unsigned int drm_format_info_block_width(const struct drm_format_info *info,