Skip to content

Commit 4c61716

Browse files
vsyrjaladanvet
authored andcommitted
drm: Add drm_format_plane_width() and drm_format_plane_height()
Add a few helpers to get the dimensions of the chroma plane(s). v2: Add kernel-doc (Daniel) v3: Fix kerneldoc "Returns:" style (Daniel) Uninline the functions and check for num_planes (Daniel) v4: Add the required EXPORT_SYMBOL()s Cc: [email protected] Signed-off-by: Ville Syrjälä <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e9f8250 commit 4c61716

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5737,6 +5737,48 @@ int drm_format_vert_chroma_subsampling(uint32_t format)
57375737
}
57385738
EXPORT_SYMBOL(drm_format_vert_chroma_subsampling);
57395739

5740+
/**
5741+
* drm_format_plane_width - width of the plane given the first plane
5742+
* @width: width of the first plane
5743+
* @format: pixel format
5744+
* @plane: plane index
5745+
*
5746+
* Returns:
5747+
* The width of @plane, given that the width of the first plane is @width.
5748+
*/
5749+
int drm_format_plane_width(int width, uint32_t format, int plane)
5750+
{
5751+
if (plane >= drm_format_num_planes(format))
5752+
return 0;
5753+
5754+
if (plane == 0)
5755+
return width;
5756+
5757+
return width / drm_format_horz_chroma_subsampling(format);
5758+
}
5759+
EXPORT_SYMBOL(drm_format_plane_width);
5760+
5761+
/**
5762+
* drm_format_plane_height - height of the plane given the first plane
5763+
* @height: height of the first plane
5764+
* @format: pixel format
5765+
* @plane: plane index
5766+
*
5767+
* Returns:
5768+
* The height of @plane, given that the height of the first plane is @height.
5769+
*/
5770+
int drm_format_plane_height(int height, uint32_t format, int plane)
5771+
{
5772+
if (plane >= drm_format_num_planes(format))
5773+
return 0;
5774+
5775+
if (plane == 0)
5776+
return height;
5777+
5778+
return height / drm_format_vert_chroma_subsampling(format);
5779+
}
5780+
EXPORT_SYMBOL(drm_format_plane_height);
5781+
57405782
/**
57415783
* drm_rotation_simplify() - Try to simplify the rotation
57425784
* @rotation: Rotation to be simplified

include/drm/drm_crtc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,6 +2498,8 @@ extern int drm_format_num_planes(uint32_t format);
24982498
extern int drm_format_plane_cpp(uint32_t format, int plane);
24992499
extern int drm_format_horz_chroma_subsampling(uint32_t format);
25002500
extern int drm_format_vert_chroma_subsampling(uint32_t format);
2501+
extern int drm_format_plane_width(int width, uint32_t format, int plane);
2502+
extern int drm_format_plane_height(int height, uint32_t format, int plane);
25012503
extern const char *drm_get_format_name(uint32_t format);
25022504
extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
25032505
unsigned int supported_rotations);

0 commit comments

Comments
 (0)