aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_crtc.c30
-rw-r--r--include/drm/drm_crtc.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index f224d4d1c0ed..89bab66558ef 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4842,6 +4842,36 @@ int drm_format_vert_chroma_subsampling(uint32_t format)
4842EXPORT_SYMBOL(drm_format_vert_chroma_subsampling); 4842EXPORT_SYMBOL(drm_format_vert_chroma_subsampling);
4843 4843
4844/** 4844/**
4845 * drm_rotation_simplify() - Try to simplify the rotation
4846 * @rotation: Rotation to be simplified
4847 * @supported_rotations: Supported rotations
4848 *
4849 * Attempt to simplify the rotation to a form that is supported.
4850 * Eg. if the hardware supports everything except DRM_REFLECT_X
4851 * one could call this function like this:
4852 *
4853 * drm_rotation_simplify(rotation, BIT(DRM_ROTATE_0) |
4854 * BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_180) |
4855 * BIT(DRM_ROTATE_270) | BIT(DRM_REFLECT_Y));
4856 *
4857 * to eliminate the DRM_ROTATE_X flag. Depending on what kind of
4858 * transforms the hardware supports, this function may not
4859 * be able to produce a supported transform, so the caller should
4860 * check the result afterwards.
4861 */
4862unsigned int drm_rotation_simplify(unsigned int rotation,
4863 unsigned int supported_rotations)
4864{
4865 if (rotation & ~supported_rotations) {
4866 rotation ^= BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y);
4867 rotation = (rotation & ~0xf) | BIT((ffs(rotation & 0xf) + 1) % 4);
4868 }
4869
4870 return rotation;
4871}
4872EXPORT_SYMBOL(drm_rotation_simplify);
4873
4874/**
4845 * drm_mode_config_init - initialize DRM mode_configuration structure 4875 * drm_mode_config_init - initialize DRM mode_configuration structure
4846 * @dev: DRM device 4876 * @dev: DRM device
4847 * 4877 *
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index f7b383bcb6b6..08ed55e02762 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1115,6 +1115,8 @@ extern int drm_format_vert_chroma_subsampling(uint32_t format);
1115extern const char *drm_get_format_name(uint32_t format); 1115extern const char *drm_get_format_name(uint32_t format);
1116extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, 1116extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
1117 unsigned int supported_rotations); 1117 unsigned int supported_rotations);
1118extern unsigned int drm_rotation_simplify(unsigned int rotation,
1119 unsigned int supported_rotations);
1118 1120
1119/* Helpers */ 1121/* Helpers */
1120 1122