Skip to content

Commit f2f4559

Browse files
gcarlos64Thomas Zimmermann
authored andcommitted
drm: Remove plane hsub/vsub alignment requirement for core helpers
The drm_format_info_plane_{height,width} functions was implemented using regular division for the plane size calculation, which cause issues [1][2] when used on contexts where the dimensions are misaligned with relation to the subsampling factors. So, replace the regular division by the DIV_ROUND_UP macro. This allows these functions to be used in more drivers, making further work to bring more core presence on them possible. [1] http://patchwork.freedesktop.org/patch/msgid/[email protected] [2] https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Carlos Eduardo Gallo Filho <[email protected]> Reviewed-by: André Almeida <[email protected]> Signed-off-by: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 052ddf7 commit f2f4559

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/drm/drm_fourcc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#ifndef __DRM_FOURCC_H__
2323
#define __DRM_FOURCC_H__
2424

25+
#include <linux/math.h>
2526
#include <linux/types.h>
2627
#include <uapi/drm/drm_fourcc.h>
2728

@@ -279,7 +280,7 @@ int drm_format_info_plane_width(const struct drm_format_info *info, int width,
279280
if (plane == 0)
280281
return width;
281282

282-
return width / info->hsub;
283+
return DIV_ROUND_UP(width, info->hsub);
283284
}
284285

285286
/**
@@ -301,7 +302,7 @@ int drm_format_info_plane_height(const struct drm_format_info *info, int height,
301302
if (plane == 0)
302303
return height;
303304

304-
return height / info->vsub;
305+
return DIV_ROUND_UP(height, info->vsub);
305306
}
306307

307308
const struct drm_format_info *__drm_format_info(u32 format);

0 commit comments

Comments
 (0)