summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMaíra Canal <mcanal@igalia.com>2023-04-18 16:05:24 +0300
committerMaíra Canal <mairacanal@riseup.net>2023-05-08 15:46:13 +0300
commitcf7f8c671c830302bd382ac640591ee3d6381ad3 (patch)
tree55877cd28e4695d1d675058d4196bb1017ba5da5 /drivers
parent1ce76fae2bc14dd776b0c237456d8bd117c0e617 (diff)
downloadlinux-cf7f8c671c830302bd382ac640591ee3d6381ad3.tar.xz
drm/vkms: add rotate-90 property
Currently, vkms only supports the rotate-180, reflect-x and reflect-y properties. Therefore, improve the vkms IGT test coverage by adding the rotate-90 property to vkms. The rotation was implement by software: rotate the way the blending occurs by making the source x axis be the destination y axis and the source y axis be the destination x axis. Tested with igt@kms_rotation_crc@primary-rotation-90 [1], igt@kms_rotation_crc@sprite-rotation-90 [1], and igt@kms_rotation_crc@sprite-rotation-90-pos-100-0 [1]. [1] https://patchwork.freedesktop.org/series/116025/ Signed-off-by: Maíra Canal <mcanal@igalia.com> Reviewed-by: Melissa Wen <mwen@igalia.com> Signed-off-by: Maíra Canal <mairacanal@riseup.net> Link: https://patchwork.freedesktop.org/patch/msgid/20230418130525.128733-5-mcanal@igalia.com
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/vkms/vkms_composer.c21
-rw-r--r--drivers/gpu/drm/vkms/vkms_formats.c4
-rw-r--r--drivers/gpu/drm/vkms/vkms_plane.c2
3 files changed, 22 insertions, 5 deletions
diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 6c5ef11b3943..491850ffeac9 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -57,13 +57,24 @@ static int get_y_pos(struct vkms_frame_info *frame_info, int y)
{
if (frame_info->rotation & DRM_MODE_REFLECT_Y)
return drm_rect_height(&frame_info->rotated) - y - 1;
- return y;
+
+ switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) {
+ case DRM_MODE_ROTATE_90:
+ return frame_info->rotated.x2 - y - 1;
+ default:
+ return y;
+ }
}
-static bool check_y_limit(struct vkms_frame_info *frame_info, int y)
+static bool check_limit(struct vkms_frame_info *frame_info, int pos)
{
- if (y >= frame_info->rotated.y1 && y < frame_info->rotated.y2)
- return true;
+ if (frame_info->rotation & DRM_MODE_ROTATE_90) {
+ if (pos >= 0 && pos < drm_rect_width(&frame_info->rotated))
+ return true;
+ } else {
+ if (pos >= frame_info->rotated.y1 && pos < frame_info->rotated.y2)
+ return true;
+ }
return false;
}
@@ -106,7 +117,7 @@ static void blend(struct vkms_writeback_job *wb,
for (size_t i = 0; i < n_active_planes; i++) {
y_pos = get_y_pos(plane[i]->frame_info, y);
- if (!check_y_limit(plane[i]->frame_info, y_pos))
+ if (!check_limit(plane[i]->frame_info, y_pos))
continue;
vkms_compose_row(stage_buffer, plane[i], y_pos);
diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c
index f59b1c48a563..f56f359e0d2d 100644
--- a/drivers/gpu/drm/vkms/vkms_formats.c
+++ b/drivers/gpu/drm/vkms/vkms_formats.c
@@ -119,6 +119,10 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state
for (size_t x = 0; x < limit; x++, src_pixels += frame_info->cpp) {
int x_pos = get_x_position(frame_info, limit, x);
+ if (frame_info->rotation & DRM_MODE_ROTATE_90)
+ src_pixels = get_packed_src_addr(frame_info, x + frame_info->rotated.y1)
+ + frame_info->cpp * y;
+
plane->pixel_read(src_pixels, &out_pixels[x_pos]);
}
}
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
index 074b9c067d06..1186c00de391 100644
--- a/drivers/gpu/drm/vkms/vkms_plane.c
+++ b/drivers/gpu/drm/vkms/vkms_plane.c
@@ -117,6 +117,7 @@ static void vkms_plane_atomic_update(struct drm_plane *plane,
memcpy(&frame_info->map, &shadow_plane_state->data, sizeof(frame_info->map));
drm_framebuffer_get(frame_info->fb);
frame_info->rotation = drm_rotation_simplify(new_state->rotation, DRM_MODE_ROTATE_0 |
+ DRM_MODE_ROTATE_90 |
DRM_MODE_REFLECT_X |
DRM_MODE_REFLECT_Y);
@@ -212,6 +213,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0,
DRM_MODE_ROTATE_0 |
+ DRM_MODE_ROTATE_90 |
DRM_MODE_ROTATE_180 |
DRM_MODE_REFLECT_X |
DRM_MODE_REFLECT_Y);