diff options
author | Thierry Reding <treding@nvidia.com> | 2018-03-19 12:20:46 -0400 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2018-05-18 15:56:21 -0400 |
commit | 995c5a509fb032ddd83eff4f3772c7fc8ff0b7ec (patch) | |
tree | a65253b7a7e110a7625fa1a5d64c60b02d954561 | |
parent | 4bd91a5b5dbb8b536208396c3d032cba8e3c3913 (diff) |
drm/tegra: dc: Support rotation property
Currently only the DRM_MODE_REFLECT_Y rotation is supported. The driver
already supports reflection on the Y axis via a custom flag which is not
very useful because it requires custom userspace. Add the standard
rotation property that supports 0 degree rotation and Y axis reflection
for primary and overlay planes to provide a better interface than the
custom flag.
v2: keep custom flag for ABI compatibility (Dmitry)
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r-- | drivers/gpu/drm/tegra/dc.c | 26 | ||||
-rw-r--r-- | drivers/gpu/drm/tegra/plane.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/tegra/plane.h | 2 |
3 files changed, 28 insertions, 1 deletions
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index 31e12a9dfcb8..c3afe7b2237e 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c | |||
@@ -596,6 +596,7 @@ static int tegra_plane_atomic_check(struct drm_plane *plane, | |||
596 | struct drm_plane_state *state) | 596 | struct drm_plane_state *state) |
597 | { | 597 | { |
598 | struct tegra_plane_state *plane_state = to_tegra_plane_state(state); | 598 | struct tegra_plane_state *plane_state = to_tegra_plane_state(state); |
599 | unsigned int rotation = DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y; | ||
599 | struct tegra_bo_tiling *tiling = &plane_state->tiling; | 600 | struct tegra_bo_tiling *tiling = &plane_state->tiling; |
600 | struct tegra_plane *tegra = to_tegra_plane(plane); | 601 | struct tegra_plane *tegra = to_tegra_plane(plane); |
601 | struct tegra_dc *dc = to_tegra_dc(state->crtc); | 602 | struct tegra_dc *dc = to_tegra_dc(state->crtc); |
@@ -633,6 +634,13 @@ static int tegra_plane_atomic_check(struct drm_plane *plane, | |||
633 | return -EINVAL; | 634 | return -EINVAL; |
634 | } | 635 | } |
635 | 636 | ||
637 | rotation = drm_rotation_simplify(state->rotation, rotation); | ||
638 | |||
639 | if (rotation & DRM_MODE_REFLECT_Y) | ||
640 | plane_state->bottom_up = true; | ||
641 | else | ||
642 | plane_state->bottom_up = false; | ||
643 | |||
636 | /* | 644 | /* |
637 | * Tegra doesn't support different strides for U and V planes so we | 645 | * Tegra doesn't support different strides for U and V planes so we |
638 | * error out if the user tries to display a framebuffer with such a | 646 | * error out if the user tries to display a framebuffer with such a |
@@ -693,7 +701,7 @@ static void tegra_plane_atomic_update(struct drm_plane *plane, | |||
693 | window.dst.w = drm_rect_width(&plane->state->dst); | 701 | window.dst.w = drm_rect_width(&plane->state->dst); |
694 | window.dst.h = drm_rect_height(&plane->state->dst); | 702 | window.dst.h = drm_rect_height(&plane->state->dst); |
695 | window.bits_per_pixel = fb->format->cpp[0] * 8; | 703 | window.bits_per_pixel = fb->format->cpp[0] * 8; |
696 | window.bottom_up = tegra_fb_is_bottom_up(fb); | 704 | window.bottom_up = tegra_fb_is_bottom_up(fb) || state->bottom_up; |
697 | 705 | ||
698 | /* copy from state */ | 706 | /* copy from state */ |
699 | window.zpos = plane->state->normalized_zpos; | 707 | window.zpos = plane->state->normalized_zpos; |
@@ -776,6 +784,14 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm, | |||
776 | drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs); | 784 | drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs); |
777 | drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255); | 785 | drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255); |
778 | 786 | ||
787 | err = drm_plane_create_rotation_property(&plane->base, | ||
788 | DRM_MODE_ROTATE_0, | ||
789 | DRM_MODE_ROTATE_0 | | ||
790 | DRM_MODE_REFLECT_Y); | ||
791 | if (err < 0) | ||
792 | dev_err(dc->dev, "failed to create rotation property: %d\n", | ||
793 | err); | ||
794 | |||
779 | return &plane->base; | 795 | return &plane->base; |
780 | } | 796 | } |
781 | 797 | ||
@@ -1053,6 +1069,14 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm, | |||
1053 | drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs); | 1069 | drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs); |
1054 | drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255); | 1070 | drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255); |
1055 | 1071 | ||
1072 | err = drm_plane_create_rotation_property(&plane->base, | ||
1073 | DRM_MODE_ROTATE_0, | ||
1074 | DRM_MODE_ROTATE_0 | | ||
1075 | DRM_MODE_REFLECT_Y); | ||
1076 | if (err < 0) | ||
1077 | dev_err(dc->dev, "failed to create rotation property: %d\n", | ||
1078 | err); | ||
1079 | |||
1056 | return &plane->base; | 1080 | return &plane->base; |
1057 | } | 1081 | } |
1058 | 1082 | ||
diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c index 0406c2ef432c..d068e8aa3553 100644 --- a/drivers/gpu/drm/tegra/plane.c +++ b/drivers/gpu/drm/tegra/plane.c | |||
@@ -56,6 +56,7 @@ tegra_plane_atomic_duplicate_state(struct drm_plane *plane) | |||
56 | copy->tiling = state->tiling; | 56 | copy->tiling = state->tiling; |
57 | copy->format = state->format; | 57 | copy->format = state->format; |
58 | copy->swap = state->swap; | 58 | copy->swap = state->swap; |
59 | copy->bottom_up = state->bottom_up; | ||
59 | copy->opaque = state->opaque; | 60 | copy->opaque = state->opaque; |
60 | 61 | ||
61 | for (i = 0; i < 2; i++) | 62 | for (i = 0; i < 2; i++) |
diff --git a/drivers/gpu/drm/tegra/plane.h b/drivers/gpu/drm/tegra/plane.h index 7360ddfafee8..e79e6b4a8e0a 100644 --- a/drivers/gpu/drm/tegra/plane.h +++ b/drivers/gpu/drm/tegra/plane.h | |||
@@ -46,6 +46,8 @@ struct tegra_plane_state { | |||
46 | u32 format; | 46 | u32 format; |
47 | u32 swap; | 47 | u32 swap; |
48 | 48 | ||
49 | bool bottom_up; | ||
50 | |||
49 | /* used for legacy blending support only */ | 51 | /* used for legacy blending support only */ |
50 | struct tegra_plane_legacy_blending_state blending[2]; | 52 | struct tegra_plane_legacy_blending_state blending[2]; |
51 | bool opaque; | 53 | bool opaque; |