Commit 4a982034 authored by Maíra Canal's avatar Maíra Canal Committed by Maíra Canal

drm/vkms: add rotate-0 and reflect-x property

Currently, vkms doesn't support any reflection property. Therefore, add
the reflect-x property to vkms through a software implementation of the
operation. This is possible by reverse reading the x axis during the
blending.

Tested with igt@kms_rotation_crc@primary-reflect-x [1] and
igt@kms_rotation_crc@sprite-reflect-x [1].

[1] https://patchwork.freedesktop.org/series/116025/Signed-off-by: default avatarMaíra Canal <mcanal@igalia.com>
Reviewed-by: default avatarMelissa Wen <mwen@igalia.com>
Signed-off-by: default avatarMaíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20230418130525.128733-3-mcanal@igalia.com
parent b8e39224
...@@ -55,7 +55,7 @@ static void pre_mul_alpha_blend(struct vkms_frame_info *frame_info, ...@@ -55,7 +55,7 @@ static void pre_mul_alpha_blend(struct vkms_frame_info *frame_info,
static bool check_y_limit(struct vkms_frame_info *frame_info, int y) static bool check_y_limit(struct vkms_frame_info *frame_info, int y)
{ {
if (y >= frame_info->dst.y1 && y < frame_info->dst.y2) if (y >= frame_info->rotated.y1 && y < frame_info->rotated.y2)
return true; return true;
return false; return false;
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
struct vkms_frame_info { struct vkms_frame_info {
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
struct drm_rect src, dst; struct drm_rect src, dst;
struct drm_rect rotated;
struct iosys_map map[DRM_FORMAT_MAX_PLANES]; struct iosys_map map[DRM_FORMAT_MAX_PLANES];
unsigned int rotation;
unsigned int offset; unsigned int offset;
unsigned int pitch; unsigned int pitch;
unsigned int cpp; unsigned int cpp;
......
...@@ -37,11 +37,18 @@ static void *packed_pixels_addr(const struct vkms_frame_info *frame_info, ...@@ -37,11 +37,18 @@ static void *packed_pixels_addr(const struct vkms_frame_info *frame_info,
static void *get_packed_src_addr(const struct vkms_frame_info *frame_info, int y) static void *get_packed_src_addr(const struct vkms_frame_info *frame_info, int y)
{ {
int x_src = frame_info->src.x1 >> 16; int x_src = frame_info->src.x1 >> 16;
int y_src = y - frame_info->dst.y1 + (frame_info->src.y1 >> 16); int y_src = y - frame_info->rotated.y1 + (frame_info->src.y1 >> 16);
return packed_pixels_addr(frame_info, x_src, y_src); return packed_pixels_addr(frame_info, x_src, y_src);
} }
static int get_x_position(const struct vkms_frame_info *frame_info, int limit, int x)
{
if (frame_info->rotation & DRM_MODE_REFLECT_X)
return limit - x - 1;
return x;
}
static void ARGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) static void ARGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel)
{ {
/* /*
...@@ -109,8 +116,11 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state ...@@ -109,8 +116,11 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state
u8 *src_pixels = get_packed_src_addr(frame_info, y); u8 *src_pixels = get_packed_src_addr(frame_info, y);
int limit = min_t(size_t, drm_rect_width(&frame_info->dst), stage_buffer->n_pixels); int limit = min_t(size_t, drm_rect_width(&frame_info->dst), stage_buffer->n_pixels);
for (size_t x = 0; x < limit; x++, src_pixels += frame_info->cpp) for (size_t x = 0; x < limit; x++, src_pixels += frame_info->cpp) {
plane->pixel_read(src_pixels, &out_pixels[x]); int x_pos = get_x_position(frame_info, limit, x);
plane->pixel_read(src_pixels, &out_pixels[x_pos]);
}
} }
/* /*
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <drm/drm_atomic.h> #include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h> #include <drm/drm_atomic_helper.h>
#include <drm/drm_blend.h>
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include <drm/drm_gem_atomic_helper.h> #include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
...@@ -111,9 +112,16 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, ...@@ -111,9 +112,16 @@ static void vkms_plane_atomic_update(struct drm_plane *plane,
frame_info = vkms_plane_state->frame_info; frame_info = vkms_plane_state->frame_info;
memcpy(&frame_info->src, &new_state->src, sizeof(struct drm_rect)); memcpy(&frame_info->src, &new_state->src, sizeof(struct drm_rect));
memcpy(&frame_info->dst, &new_state->dst, sizeof(struct drm_rect)); memcpy(&frame_info->dst, &new_state->dst, sizeof(struct drm_rect));
memcpy(&frame_info->rotated, &new_state->dst, sizeof(struct drm_rect));
frame_info->fb = fb; frame_info->fb = fb;
memcpy(&frame_info->map, &shadow_plane_state->data, sizeof(frame_info->map)); memcpy(&frame_info->map, &shadow_plane_state->data, sizeof(frame_info->map));
drm_framebuffer_get(frame_info->fb); drm_framebuffer_get(frame_info->fb);
frame_info->rotation = drm_rotation_simplify(new_state->rotation, DRM_MODE_ROTATE_0 |
DRM_MODE_REFLECT_X);
drm_rect_rotate(&frame_info->rotated, drm_rect_width(&frame_info->rotated),
drm_rect_height(&frame_info->rotated), frame_info->rotation);
frame_info->offset = fb->offsets[0]; frame_info->offset = fb->offsets[0];
frame_info->pitch = fb->pitches[0]; frame_info->pitch = fb->pitches[0];
frame_info->cpp = fb->format->cpp[0]; frame_info->cpp = fb->format->cpp[0];
...@@ -201,5 +209,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, ...@@ -201,5 +209,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
drm_plane_helper_add(&plane->base, &vkms_plane_helper_funcs); drm_plane_helper_add(&plane->base, &vkms_plane_helper_funcs);
drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0,
DRM_MODE_ROTATE_0 |
DRM_MODE_REFLECT_X);
return plane; return plane;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment