Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vkms: add rotate-270 property

Currently, vkms supports the rotate-90, rotate-180, reflect-x and
reflect-y properties. Therefore, improve the vkms IGT test coverage by
adding the rotate-270 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 and reverse-read the axis.

Now, vkms supports all possible rotation values.

Tested with igt@kms_rotation_crc@primary-rotation-270 [1],
and igt@kms_rotation_crc@sprite-rotation-270 [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-6-mcanal@igalia.com

authored by

Maíra Canal and committed by
Maíra Canal
cd075550 cf7f8c67

+10 -8
+4 -1
drivers/gpu/drm/vkms/vkms_composer.c
··· 4 4 5 5 #include <drm/drm_atomic.h> 6 6 #include <drm/drm_atomic_helper.h> 7 + #include <drm/drm_blend.h> 7 8 #include <drm/drm_fourcc.h> 8 9 #include <drm/drm_gem_framebuffer_helper.h> 9 10 #include <drm/drm_vblank.h> ··· 62 61 switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) { 63 62 case DRM_MODE_ROTATE_90: 64 63 return frame_info->rotated.x2 - y - 1; 64 + case DRM_MODE_ROTATE_270: 65 + return y + frame_info->rotated.x1; 65 66 default: 66 67 return y; 67 68 } ··· 71 68 72 69 static bool check_limit(struct vkms_frame_info *frame_info, int pos) 73 70 { 74 - if (frame_info->rotation & DRM_MODE_ROTATE_90) { 71 + if (drm_rotation_90_or_270(frame_info->rotation)) { 75 72 if (pos >= 0 && pos < drm_rect_width(&frame_info->rotated)) 76 73 return true; 77 74 } else {
+4 -2
drivers/gpu/drm/vkms/vkms_formats.c
··· 2 2 3 3 #include <linux/kernel.h> 4 4 #include <linux/minmax.h> 5 + 6 + #include <drm/drm_blend.h> 5 7 #include <drm/drm_rect.h> 6 8 #include <drm/drm_fixed.h> 7 9 ··· 46 44 47 45 static int get_x_position(const struct vkms_frame_info *frame_info, int limit, int x) 48 46 { 49 - if (frame_info->rotation & DRM_MODE_REFLECT_X) 47 + if (frame_info->rotation & (DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_270)) 50 48 return limit - x - 1; 51 49 return x; 52 50 } ··· 121 119 for (size_t x = 0; x < limit; x++, src_pixels += frame_info->cpp) { 122 120 int x_pos = get_x_position(frame_info, limit, x); 123 121 124 - if (frame_info->rotation & DRM_MODE_ROTATE_90) 122 + if (drm_rotation_90_or_270(frame_info->rotation)) 125 123 src_pixels = get_packed_src_addr(frame_info, x + frame_info->rotated.y1) 126 124 + frame_info->cpp * y; 127 125
+2 -5
drivers/gpu/drm/vkms/vkms_plane.c
··· 118 118 drm_framebuffer_get(frame_info->fb); 119 119 frame_info->rotation = drm_rotation_simplify(new_state->rotation, DRM_MODE_ROTATE_0 | 120 120 DRM_MODE_ROTATE_90 | 121 + DRM_MODE_ROTATE_270 | 121 122 DRM_MODE_REFLECT_X | 122 123 DRM_MODE_REFLECT_Y); 123 124 ··· 213 212 drm_plane_helper_add(&plane->base, &vkms_plane_helper_funcs); 214 213 215 214 drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, 216 - DRM_MODE_ROTATE_0 | 217 - DRM_MODE_ROTATE_90 | 218 - DRM_MODE_ROTATE_180 | 219 - DRM_MODE_REFLECT_X | 220 - DRM_MODE_REFLECT_Y); 215 + DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK); 221 216 222 217 return plane; 223 218 }