aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_crtc.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2014-07-08 01:01:56 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-07-11 17:44:20 -0400
commit3c9855f6dc1c68f7c4028f49bd8e3df7e4faae67 (patch)
tree498d4cdc426a6ec39cbc3da562f75c3d20cbef25 /drivers/gpu/drm/drm_crtc.c
parent07074006cd951f7a952512c57d60788ee7ea18db (diff)
drm: Add drm_rotation_simplify()
drm_rotation_simplify() can be used to eliminate unsupported rotation flags. It will check if any unsupported flags are present, and if so it will modify the rotation to an alternate form by adding 180 degrees to rotation angle, and flipping the reflect x and y bits. The hope is that this identity transform will eliminate the unsupported flags. Of course that might not result in any more supported rotation, so the caller is still responsible for checking the result afterwards. Cc: dri-devel@lists.freedesktop.org Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Imre Deak <imre.deak@intel.com> Acked-by: Dave Airlie <airlied@linux.ie> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r--drivers/gpu/drm/drm_crtc.c30
1 files changed, 30 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 *