From patchwork Thu Apr 6 13:01:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13203297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEDD4C761A6 for ; Thu, 6 Apr 2023 13:02:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DE9A410E2B3; Thu, 6 Apr 2023 13:02:09 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id F1F6510E31F for ; Thu, 6 Apr 2023 13:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=B3jbdo12pDafd905LJGsQp4ubzxunPMw1TGmEuLdZAU=; b=YIPtUmiZlPmqGffVIRcWOY3AmG ppSW06p0udzwuyWHZtNPsCxNBt8dJ0BFlqF0pK9kMq8mtKXawjx8z9rk7iEQj9cq3B01iZZlPuN2z qXV20MZWv5ZhaCsYwqawGeyxmnz83ofzV6Hr3kQxKh4+DH+b6gpSEJpfaEzhQkyycX5fB3NqQPPFe O3a+4lyqMPuCfiP8MCdX4Ear85pSlzJowo+YKlUdS5y9P8hrYEvGhm4ogi0jYAAuhK6aKlaBD2z2M DuEy7BecVx84pfazsR+2Qhlzqpxc3bPg1pGopDJ6UWSS2zDkKNmmoGt8qh+qMlZVVK7pSWfjOWh1E MSR/gVjw==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pkPFb-0084OI-5v; Thu, 06 Apr 2023 15:02:03 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed Subject: [PATCH 1/6] drm/vkms: add rotate-0 and rotate-180 properties Date: Thu, 6 Apr 2023 10:01:33 -0300 Message-Id: <20230406130138.70752-2-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406130138.70752-1-mcanal@igalia.com> References: <20230406130138.70752-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, vkms doesn't support any rotation property. Therefore, improve the vkms IGT test coverage by adding the rotate-0 and rotate-180 properties to vkms. The rotation was implemented by software: invert the way the blending occurs by reverse reading the x and y axis. Tested with igt@kms_rotation_crc@primary-rotation-180, igt@kms_rotation_crc@sprite-rotation-180, and igt@kms_rotation_crc@cursor-rotation-180. Signed-off-by: Maíra Canal --- drivers/gpu/drm/vkms/vkms_composer.c | 39 ++++++++++++++++--- drivers/gpu/drm/vkms/vkms_drv.h | 1 + drivers/gpu/drm/vkms/vkms_formats.c | 56 ++++++++++++++++++---------- drivers/gpu/drm/vkms/vkms_plane.c | 12 ++++++ 4 files changed, 83 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 8e53fa80742b..b7fba786dc4f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -11,6 +11,23 @@ #include "vkms_drv.h" +static struct pixel_argb_u16 *get_out_buffer(const struct vkms_frame_info *frame_info, + struct line_buffer *output_buffer) +{ + struct pixel_argb_u16 *out = output_buffer->pixels; + + switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) { + case DRM_MODE_ROTATE_180: + out -= frame_info->dst.x1; + break; + default: + out += frame_info->dst.x1; + break; + } + + return out; +} + static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) { u32 new_color; @@ -39,8 +56,7 @@ static void pre_mul_alpha_blend(struct vkms_frame_info *frame_info, struct line_buffer *stage_buffer, struct line_buffer *output_buffer) { - int x_dst = frame_info->dst.x1; - struct pixel_argb_u16 *out = output_buffer->pixels + x_dst; + struct pixel_argb_u16 *out = get_out_buffer(frame_info, output_buffer); struct pixel_argb_u16 *in = stage_buffer->pixels; int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), stage_buffer->n_pixels); @@ -53,6 +69,16 @@ static void pre_mul_alpha_blend(struct vkms_frame_info *frame_info, } } +static int get_y_pos(struct vkms_frame_info *frame_info, int y) +{ + switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) { + case DRM_MODE_ROTATE_180: + return drm_rect_height(&frame_info->dst) - y - 1; + default: + return 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) @@ -86,6 +112,7 @@ static void blend(struct vkms_writeback_job *wb, { struct vkms_plane_state **plane = crtc_state->active_planes; u32 n_active_planes = crtc_state->num_active_planes; + int y_pos; const struct pixel_argb_u16 background_color = { .a = 0xffff }; @@ -96,10 +123,12 @@ static void blend(struct vkms_writeback_job *wb, /* The active planes are composed associatively in z-order. */ for (size_t i = 0; i < n_active_planes; i++) { - if (!check_y_limit(plane[i]->frame_info, y)) + y_pos = get_y_pos(plane[i]->frame_info, y); + + if (!check_y_limit(plane[i]->frame_info, y_pos)) continue; - plane[i]->plane_read(stage_buffer, plane[i]->frame_info, y); + plane[i]->plane_read(stage_buffer, plane[i]->frame_info, y_pos); pre_mul_alpha_blend(plane[i]->frame_info, stage_buffer, output_buffer); } @@ -107,7 +136,7 @@ static void blend(struct vkms_writeback_job *wb, *crc32 = crc32_le(*crc32, (void *)output_buffer->pixels, row_size); if (wb) - wb->wb_write(&wb->wb_frame_info, output_buffer, y); + wb->wb_write(&wb->wb_frame_info, output_buffer, y_pos); } } diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 4a248567efb2..be6ec2fe0b87 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -27,6 +27,7 @@ struct vkms_frame_info { struct drm_framebuffer *fb; struct drm_rect src, dst; struct iosys_map map[DRM_FORMAT_MAX_PLANES]; + unsigned int rotation; unsigned int offset; unsigned int pitch; unsigned int cpp; diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index d4950688b3f1..2f070c505b3b 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -42,6 +42,13 @@ static void *get_packed_src_addr(const struct vkms_frame_info *frame_info, int y return packed_pixels_addr(frame_info, x_src, y_src); } +static int get_x_position(const struct vkms_frame_info *frame_info, int x_limit, int x) +{ + if (frame_info->rotation & DRM_MODE_ROTATE_180) + return x_limit - x - 1; + return x; +} + static void ARGB8888_to_argb_u16(struct line_buffer *stage_buffer, const struct vkms_frame_info *frame_info, int y) { @@ -51,16 +58,17 @@ static void ARGB8888_to_argb_u16(struct line_buffer *stage_buffer, stage_buffer->n_pixels); for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { + int x_pos = get_x_position(frame_info, x_limit, x); /* * The 257 is the "conversion ratio". This number is obtained by the * (2^16 - 1) / (2^8 - 1) division. Which, in this case, tries to get * the best color value in a pixel format with more possibilities. * A similar idea applies to others RGB color conversions. */ - out_pixels[x].a = (u16)src_pixels[3] * 257; - out_pixels[x].r = (u16)src_pixels[2] * 257; - out_pixels[x].g = (u16)src_pixels[1] * 257; - out_pixels[x].b = (u16)src_pixels[0] * 257; + out_pixels[x_pos].a = (u16)src_pixels[3] * 257; + out_pixels[x_pos].r = (u16)src_pixels[2] * 257; + out_pixels[x_pos].g = (u16)src_pixels[1] * 257; + out_pixels[x_pos].b = (u16)src_pixels[0] * 257; } } @@ -73,10 +81,12 @@ static void XRGB8888_to_argb_u16(struct line_buffer *stage_buffer, stage_buffer->n_pixels); for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { - out_pixels[x].a = (u16)0xffff; - out_pixels[x].r = (u16)src_pixels[2] * 257; - out_pixels[x].g = (u16)src_pixels[1] * 257; - out_pixels[x].b = (u16)src_pixels[0] * 257; + int x_pos = get_x_position(frame_info, x_limit, x); + + out_pixels[x_pos].a = (u16)0xffff; + out_pixels[x_pos].r = (u16)src_pixels[2] * 257; + out_pixels[x_pos].g = (u16)src_pixels[1] * 257; + out_pixels[x_pos].b = (u16)src_pixels[0] * 257; } } @@ -90,10 +100,12 @@ static void ARGB16161616_to_argb_u16(struct line_buffer *stage_buffer, stage_buffer->n_pixels); for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { - out_pixels[x].a = le16_to_cpu(src_pixels[3]); - out_pixels[x].r = le16_to_cpu(src_pixels[2]); - out_pixels[x].g = le16_to_cpu(src_pixels[1]); - out_pixels[x].b = le16_to_cpu(src_pixels[0]); + int x_pos = get_x_position(frame_info, x_limit, x); + + out_pixels[x_pos].a = le16_to_cpu(src_pixels[3]); + out_pixels[x_pos].r = le16_to_cpu(src_pixels[2]); + out_pixels[x_pos].g = le16_to_cpu(src_pixels[1]); + out_pixels[x_pos].b = le16_to_cpu(src_pixels[0]); } } @@ -107,10 +119,12 @@ static void XRGB16161616_to_argb_u16(struct line_buffer *stage_buffer, stage_buffer->n_pixels); for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { - out_pixels[x].a = (u16)0xffff; - out_pixels[x].r = le16_to_cpu(src_pixels[2]); - out_pixels[x].g = le16_to_cpu(src_pixels[1]); - out_pixels[x].b = le16_to_cpu(src_pixels[0]); + int x_pos = get_x_position(frame_info, x_limit, x); + + out_pixels[x_pos].a = (u16)0xffff; + out_pixels[x_pos].r = le16_to_cpu(src_pixels[2]); + out_pixels[x_pos].g = le16_to_cpu(src_pixels[1]); + out_pixels[x_pos].b = le16_to_cpu(src_pixels[0]); } } @@ -126,15 +140,17 @@ static void RGB565_to_argb_u16(struct line_buffer *stage_buffer, s64 fp_g_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(63)); for (size_t x = 0; x < x_limit; x++, src_pixels++) { + int x_pos = get_x_position(frame_info, x_limit, x); + u16 rgb_565 = le16_to_cpu(*src_pixels); s64 fp_r = drm_int2fixp((rgb_565 >> 11) & 0x1f); s64 fp_g = drm_int2fixp((rgb_565 >> 5) & 0x3f); s64 fp_b = drm_int2fixp(rgb_565 & 0x1f); - out_pixels[x].a = (u16)0xffff; - out_pixels[x].r = drm_fixp2int(drm_fixp_mul(fp_r, fp_rb_ratio)); - out_pixels[x].g = drm_fixp2int(drm_fixp_mul(fp_g, fp_g_ratio)); - out_pixels[x].b = drm_fixp2int(drm_fixp_mul(fp_b, fp_rb_ratio)); + out_pixels[x_pos].a = (u16)0xffff; + out_pixels[x_pos].r = drm_fixp2int(drm_fixp_mul(fp_r, fp_rb_ratio)); + out_pixels[x_pos].g = drm_fixp2int(drm_fixp_mul(fp_g, fp_g_ratio)); + out_pixels[x_pos].b = drm_fixp2int(drm_fixp_mul(fp_b, fp_rb_ratio)); } } diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index c41cec7dcb70..1acf715389d6 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -120,6 +121,13 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, frame_info->fb = fb; 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_180); + + drm_rect_rotate(&frame_info->dst, drm_rect_width(&frame_info->dst), + drm_rect_height(&frame_info->dst), frame_info->rotation); + frame_info->offset = fb->offsets[0]; frame_info->pitch = fb->pitches[0]; frame_info->cpp = fb->format->cpp[0]; @@ -229,5 +237,9 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_helper_add(&plane->base, funcs); + drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, + DRM_MODE_ROTATE_0 | + DRM_MODE_ROTATE_180); + return plane; } From patchwork Thu Apr 6 13:01:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13203298 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 834EBC76196 for ; Thu, 6 Apr 2023 13:02:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C0E9710E31F; Thu, 6 Apr 2023 13:02:12 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6823C10E31F for ; Thu, 6 Apr 2023 13:02:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7+KJL2J4chUJBVwlkqU3Vt/Wzudt4km9ZFkpoqD5z2I=; b=WtgIoIxjjTB5n3Tg6a2qjzUrZ7 emkli+GajNb4qFwtBMSSB6oszncPqKxCuZ1t/1rj9HePYrk/kJevj6jlwHgwcKe55vmAiJUgRBswF AYq6jAcuIWWjkHoPkDEU6BBAG6tndN9Wz/fdURvhWeA3j0F2QTint9YXNrlyX75nMs+noTQFAMAQp UKa4j2K2Ci0jLSQ2F+lNqpbBzGtAONjEHpRLgIjJuHgnqDh+wlN9O9ze8qWAlu3CatHEuU7dSee3n Fe2h8wXIIrcurJOt+f+tVu0qd9tJmv6sILKITmCZAfxxKXn5wX4Gw1vg5NxKWu0J2zUtfUEn2EiHD hCVxE51g==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pkPFe-0084OI-P1; Thu, 06 Apr 2023 15:02:07 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed Subject: [PATCH 2/6] drm/vkms: add rotate-90 property Date: Thu, 6 Apr 2023 10:01:34 -0300 Message-Id: <20230406130138.70752-3-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406130138.70752-1-mcanal@igalia.com> References: <20230406130138.70752-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, vkms only supports the rotate-180 property. 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, igt@kms_rotation_crc@sprite-rotation-90, and igt@kms_rotation_crc@sprite-rotation-90-pos-100-0. Signed-off-by: Maíra Canal --- drivers/gpu/drm/vkms/vkms_composer.c | 29 ++++++++++---- drivers/gpu/drm/vkms/vkms_formats.c | 60 ++++++++++++++++------------ drivers/gpu/drm/vkms/vkms_plane.c | 2 + 3 files changed, 58 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index b7fba786dc4f..ef4e5181d512 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -17,6 +17,9 @@ static struct pixel_argb_u16 *get_out_buffer(const struct vkms_frame_info *frame struct pixel_argb_u16 *out = output_buffer->pixels; switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) { + case DRM_MODE_ROTATE_90: + out -= frame_info->dst.y1; + break; case DRM_MODE_ROTATE_180: out -= frame_info->dst.x1; break; @@ -58,10 +61,12 @@ static void pre_mul_alpha_blend(struct vkms_frame_info *frame_info, { struct pixel_argb_u16 *out = get_out_buffer(frame_info, output_buffer); struct pixel_argb_u16 *in = stage_buffer->pixels; - int x_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); + + if (frame_info->rotation & DRM_MODE_ROTATE_90) + limit = min_t(size_t, drm_rect_height(&frame_info->dst), stage_buffer->n_pixels); - for (int x = 0; x < x_limit; x++) { + for (int x = 0; x < limit; x++) { out[x].a = (u16)0xffff; out[x].r = pre_mul_blend_channel(in[x].r, out[x].r, in[x].a); out[x].g = pre_mul_blend_channel(in[x].g, out[x].g, in[x].a); @@ -72,6 +77,10 @@ static void pre_mul_alpha_blend(struct vkms_frame_info *frame_info, static int get_y_pos(struct vkms_frame_info *frame_info, int y) { switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) { + case DRM_MODE_ROTATE_90: + if (y - frame_info->dst.x1 < 0) + return -1; + return frame_info->dst.x2 - y - 1; case DRM_MODE_ROTATE_180: return drm_rect_height(&frame_info->dst) - y - 1; default: @@ -79,11 +88,15 @@ static int get_y_pos(struct vkms_frame_info *frame_info, int 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->dst.y1 && y < frame_info->dst.y2) - return true; - + if (frame_info->rotation & DRM_MODE_ROTATE_90) { + if (pos >= 0 && pos < drm_rect_width(&frame_info->dst)) + return true; + } else { + if (pos >= frame_info->dst.y1 && pos < frame_info->dst.y2) + return true; + } return false; } @@ -125,7 +138,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; plane[i]->plane_read(stage_buffer, plane[i]->frame_info, y_pos); diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 2f070c505b3b..b874786be6b1 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -49,16 +49,30 @@ static int get_x_position(const struct vkms_frame_info *frame_info, int x_limit, return x; } +static int get_limit(const struct vkms_frame_info *frame_info, struct line_buffer *stage_buffer) +{ + if (frame_info->rotation & DRM_MODE_ROTATE_90) + return min_t(size_t, drm_rect_height(&frame_info->dst), stage_buffer->n_pixels); + return min_t(size_t, drm_rect_width(&frame_info->dst), stage_buffer->n_pixels); +} + +static u8 *get_src_pixels(const struct vkms_frame_info *frame_info, int x, int y, int pixel_size) +{ + if (frame_info->rotation & DRM_MODE_ROTATE_90) + return get_packed_src_addr(frame_info, x + frame_info->dst.y1) + pixel_size * y; + return get_packed_src_addr(frame_info, y) + pixel_size * x; +} + static void ARGB8888_to_argb_u16(struct line_buffer *stage_buffer, const struct vkms_frame_info *frame_info, int y) { struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; - u8 *src_pixels = get_packed_src_addr(frame_info, y); - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - stage_buffer->n_pixels); + int limit = get_limit(frame_info, stage_buffer); + + for (size_t x = 0; x < limit; x++) { + int x_pos = get_x_position(frame_info, limit, x); + u8 *src_pixels = get_src_pixels(frame_info, x, y, 4); - for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { - int x_pos = get_x_position(frame_info, x_limit, x); /* * The 257 is the "conversion ratio". This number is obtained by the * (2^16 - 1) / (2^8 - 1) division. Which, in this case, tries to get @@ -76,12 +90,11 @@ static void XRGB8888_to_argb_u16(struct line_buffer *stage_buffer, const struct vkms_frame_info *frame_info, int y) { struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; - u8 *src_pixels = get_packed_src_addr(frame_info, y); - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - stage_buffer->n_pixels); + int limit = get_limit(frame_info, stage_buffer); - for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { - int x_pos = get_x_position(frame_info, x_limit, x); + for (size_t x = 0; x < limit; x++) { + int x_pos = get_x_position(frame_info, limit, x); + u8 *src_pixels = get_src_pixels(frame_info, x, y, 4); out_pixels[x_pos].a = (u16)0xffff; out_pixels[x_pos].r = (u16)src_pixels[2] * 257; @@ -95,12 +108,11 @@ static void ARGB16161616_to_argb_u16(struct line_buffer *stage_buffer, int y) { struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; - u16 *src_pixels = get_packed_src_addr(frame_info, y); - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - stage_buffer->n_pixels); + int limit = get_limit(frame_info, stage_buffer); - for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { - int x_pos = get_x_position(frame_info, x_limit, x); + for (size_t x = 0; x < limit; x++) { + int x_pos = get_x_position(frame_info, limit, x); + u8 *src_pixels = get_src_pixels(frame_info, x, y, 4); out_pixels[x_pos].a = le16_to_cpu(src_pixels[3]); out_pixels[x_pos].r = le16_to_cpu(src_pixels[2]); @@ -114,12 +126,11 @@ static void XRGB16161616_to_argb_u16(struct line_buffer *stage_buffer, int y) { struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; - u16 *src_pixels = get_packed_src_addr(frame_info, y); - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - stage_buffer->n_pixels); + int limit = get_limit(frame_info, stage_buffer); - for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { - int x_pos = get_x_position(frame_info, x_limit, x); + for (size_t x = 0; x < limit; x++) { + int x_pos = get_x_position(frame_info, limit, x); + u8 *src_pixels = get_src_pixels(frame_info, x, y, 4); out_pixels[x_pos].a = (u16)0xffff; out_pixels[x_pos].r = le16_to_cpu(src_pixels[2]); @@ -132,15 +143,14 @@ static void RGB565_to_argb_u16(struct line_buffer *stage_buffer, const struct vkms_frame_info *frame_info, int y) { struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; - u16 *src_pixels = get_packed_src_addr(frame_info, y); - int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), - stage_buffer->n_pixels); + int limit = get_limit(frame_info, stage_buffer); s64 fp_rb_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(31)); s64 fp_g_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(63)); - for (size_t x = 0; x < x_limit; x++, src_pixels++) { - int x_pos = get_x_position(frame_info, x_limit, x); + for (size_t x = 0; x < limit; x++) { + int x_pos = get_x_position(frame_info, limit, x); + u8 *src_pixels = get_src_pixels(frame_info, x, y, 1); u16 rgb_565 = le16_to_cpu(*src_pixels); s64 fp_r = drm_int2fixp((rgb_565 >> 11) & 0x1f); diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 1acf715389d6..94c1e5d891cc 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -123,6 +123,7 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, 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_ROTATE_180); drm_rect_rotate(&frame_info->dst, drm_rect_width(&frame_info->dst), @@ -239,6 +240,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); return plane; From patchwork Thu Apr 6 13:01:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13203299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8465AC76196 for ; Thu, 6 Apr 2023 13:02:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB4F310E327; Thu, 6 Apr 2023 13:02:17 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9AA1B10E327 for ; Thu, 6 Apr 2023 13:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=KZtzwbgRkPBAD2f5TyDUjsuO3SzbvI5CoR/uh0Sv7i4=; b=P1j11yIBQUSLU8/iL26kIDIqgE TFnLIzcgu82gX/rzQBYDBxt2wuJzeqBbx6dL+DD1kW5oNCBgTo0kNZ/aRbsfw9YnB9QOInqRgZZMK fq4mogm3gK1kNr07HVzt2fumKwDdETbuhlKoj9mtSqf/XBOD2zz0VRgHwwkXkM2F5QkqVIash6pBW VM9sH9mhErhyLt64T7oecJ7Pp948yO6dOQjfPum6u5PmdbTzGt15nYOewA9YtbvH/9HgWRZO7y3wH oE+j7Smc1CTeMexo31IoAlNzHRlRevsWEwOiq5b34cwPrzEV84uX/84HQSNSA+KMua3fI6Cs2hZdR jfKeozag==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pkPFh-0084OI-UN; Thu, 06 Apr 2023 15:02:10 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed Subject: [PATCH 3/6] drm/vkms: add rotate-270 property Date: Thu, 6 Apr 2023 10:01:35 -0300 Message-Id: <20230406130138.70752-4-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406130138.70752-1-mcanal@igalia.com> References: <20230406130138.70752-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, vkms only supports the rotate-90 and rotate-180 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. Tested with igt@kms_rotation_crc@primary-rotation-270, and igt@kms_rotation_crc@sprite-rotation-270. Signed-off-by: Maíra Canal --- drivers/gpu/drm/vkms/vkms_composer.c | 12 ++++++++++-- drivers/gpu/drm/vkms/vkms_formats.c | 7 ++++--- drivers/gpu/drm/vkms/vkms_plane.c | 6 ++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index ef4e5181d512..25d412f555ae 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -23,6 +24,9 @@ static struct pixel_argb_u16 *get_out_buffer(const struct vkms_frame_info *frame case DRM_MODE_ROTATE_180: out -= frame_info->dst.x1; break; + case DRM_MODE_ROTATE_270: + out += frame_info->dst.y1; + break; default: out += frame_info->dst.x1; break; @@ -63,7 +67,7 @@ static void pre_mul_alpha_blend(struct vkms_frame_info *frame_info, struct pixel_argb_u16 *in = stage_buffer->pixels; int limit = min_t(size_t, drm_rect_width(&frame_info->dst), stage_buffer->n_pixels); - if (frame_info->rotation & DRM_MODE_ROTATE_90) + if (drm_rotation_90_or_270(frame_info->rotation)) limit = min_t(size_t, drm_rect_height(&frame_info->dst), stage_buffer->n_pixels); for (int x = 0; x < limit; x++) { @@ -83,6 +87,10 @@ static int get_y_pos(struct vkms_frame_info *frame_info, int y) return frame_info->dst.x2 - y - 1; case DRM_MODE_ROTATE_180: return drm_rect_height(&frame_info->dst) - y - 1; + case DRM_MODE_ROTATE_270: + if (y + frame_info->dst.x1 < 0) + return -1; + return y + frame_info->dst.x1; default: return y; } @@ -90,7 +98,7 @@ static int get_y_pos(struct vkms_frame_info *frame_info, int y) static bool check_limit(struct vkms_frame_info *frame_info, int pos) { - if (frame_info->rotation & DRM_MODE_ROTATE_90) { + if (drm_rotation_90_or_270(frame_info->rotation)) { if (pos >= 0 && pos < drm_rect_width(&frame_info->dst)) return true; } else { diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index b874786be6b1..07976194882b 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -44,21 +45,21 @@ static void *get_packed_src_addr(const struct vkms_frame_info *frame_info, int y static int get_x_position(const struct vkms_frame_info *frame_info, int x_limit, int x) { - if (frame_info->rotation & DRM_MODE_ROTATE_180) + if (frame_info->rotation & (DRM_MODE_ROTATE_180 | DRM_MODE_ROTATE_270)) return x_limit - x - 1; return x; } static int get_limit(const struct vkms_frame_info *frame_info, struct line_buffer *stage_buffer) { - if (frame_info->rotation & DRM_MODE_ROTATE_90) + if (drm_rotation_90_or_270(frame_info->rotation)) return min_t(size_t, drm_rect_height(&frame_info->dst), stage_buffer->n_pixels); return min_t(size_t, drm_rect_width(&frame_info->dst), stage_buffer->n_pixels); } static u8 *get_src_pixels(const struct vkms_frame_info *frame_info, int x, int y, int pixel_size) { - if (frame_info->rotation & DRM_MODE_ROTATE_90) + if (drm_rotation_90_or_270(frame_info->rotation)) return get_packed_src_addr(frame_info, x + frame_info->dst.y1) + pixel_size * y; return get_packed_src_addr(frame_info, y) + pixel_size * x; } diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 94c1e5d891cc..abaacad3bef2 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -124,7 +124,8 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, frame_info->rotation = drm_rotation_simplify(new_state->rotation, DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | - DRM_MODE_ROTATE_180); + DRM_MODE_ROTATE_180 | + DRM_MODE_ROTATE_270); drm_rect_rotate(&frame_info->dst, drm_rect_width(&frame_info->dst), drm_rect_height(&frame_info->dst), frame_info->rotation); @@ -241,7 +242,8 @@ 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_ROTATE_180 | + DRM_MODE_ROTATE_270); return plane; } From patchwork Thu Apr 6 13:01:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13203300 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6B3EC7618D for ; Thu, 6 Apr 2023 13:02:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D931E10E370; Thu, 6 Apr 2023 13:02:21 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id D46A210E327 for ; Thu, 6 Apr 2023 13:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=aYSMUZld+qVDdtJ5aeTDhvwDtFXn4lMr2FsgVc381v0=; b=ooHXS0E+Yhid2Uh+qty+jGnNij plwXZo1HfuvtdHcpj/Bwgoax96iJDgWHbHTqY02oK1qUptmyEgVdqGhc31Zbukzeq4vcQwvZ4Equ+ q2iw3VHEZlKA1prxS6/g2txw74zHb405nTZ0hP5J7Ub8tdCq8PY2F4wdM1PIcTUHljom4xjXHd1a+ G2ydWdtmgDgPrxRzKu9j9lV0FJ18EB7KG8hDzeR5cuJV6F9Pr55PjZ6DdjLEoNoe5qBqbSN8iFR+5 8/calvO0Yy56R3SlDMjOUSsQGMph5FrZyUJRkMDSyoTZmvazowcQFyYmYddVnB+hYfQiiVfJdp0dZ QnYGZCxg==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pkPFl-0084OI-75; Thu, 06 Apr 2023 15:02:13 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed Subject: [PATCH 4/6] drm/vkms: add reflect-x property Date: Thu, 6 Apr 2023 10:01:36 -0300 Message-Id: <20230406130138.70752-5-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406130138.70752-1-mcanal@igalia.com> References: <20230406130138.70752-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 and igt@kms_rotation_crc@sprite-reflect-x [1]. [1] https://patchwork.freedesktop.org/series/116025/ Signed-off-by: Maíra Canal --- drivers/gpu/drm/vkms/vkms_formats.c | 2 +- drivers/gpu/drm/vkms/vkms_plane.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 07976194882b..72a57639e1e8 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -45,7 +45,7 @@ static void *get_packed_src_addr(const struct vkms_frame_info *frame_info, int y static int get_x_position(const struct vkms_frame_info *frame_info, int x_limit, int x) { - if (frame_info->rotation & (DRM_MODE_ROTATE_180 | DRM_MODE_ROTATE_270)) + if (frame_info->rotation & (DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_180 | DRM_MODE_ROTATE_270)) return x_limit - x - 1; return x; } diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index abaacad3bef2..e2bd2231fe4c 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -125,7 +125,8 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 | - DRM_MODE_ROTATE_270); + DRM_MODE_ROTATE_270 | + DRM_MODE_REFLECT_X); drm_rect_rotate(&frame_info->dst, drm_rect_width(&frame_info->dst), drm_rect_height(&frame_info->dst), frame_info->rotation); @@ -243,7 +244,8 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 | - DRM_MODE_ROTATE_270); + DRM_MODE_ROTATE_270 | + DRM_MODE_REFLECT_X); return plane; } From patchwork Thu Apr 6 13:01:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13203301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 55DD9C76196 for ; Thu, 6 Apr 2023 13:02:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75B2610E391; Thu, 6 Apr 2023 13:02:24 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 53CA010E370 for ; Thu, 6 Apr 2023 13:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mAXYJfVMl6MbhpO8q1jmwzjnQfk9vRmbQou0gYkg6Ds=; b=lWqmwW6fFvebc2pkw0xiqQtf2e a4fKK3lEOdYr5XixBX+MCyuOv2BBgPfV41HrhtXH5HeklV9GkAIP/YJ+PoC7aTqv2sw3KZ99ipVEb OxGbDMyFC5t4zNIV7FXS6l5+1qXhiMB+NZbnPPyKmCgd0gWxErAtoLoM2hYX0BmvUS/eo+zIL4G7i Zkb4Y+D92Mn+ex9sZ+PwldnEDzhtE6ISNDQuA6yTfp130gVQ1mOAr44IHGAHLFvbfiGFw7wtUWQwY hExJ4Pvoa/V3DoAzc+rMFoweROKHLfGkn9oM0zTwDWUqOXZ2dSheedSbXqiuXLZcwjSMD0xsFZ0pG S/oHWrnw==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pkPFo-0084OI-El; Thu, 06 Apr 2023 15:02:16 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed Subject: [PATCH 5/6] drm/vkms: add reflect-y property Date: Thu, 6 Apr 2023 10:01:37 -0300 Message-Id: <20230406130138.70752-6-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406130138.70752-1-mcanal@igalia.com> References: <20230406130138.70752-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently, vkms only support the reflect-x property. Therefore, add the reflect-y property to vkms through a software implementation of the operation. This is possible by reverse reading the y axis during the blending. Now, vkms support all possible rotation values. Tested with igt@kms_rotation_crc@primary-reflect-y and igt@kms_rotation_crc@sprite-reflect-y [1]. [1] https://patchwork.freedesktop.org/series/116025/ Signed-off-by: Maíra Canal --- drivers/gpu/drm/vkms/vkms_composer.c | 7 ++++++- drivers/gpu/drm/vkms/vkms_plane.c | 16 ++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 25d412f555ae..0566eb8e2dee 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -92,8 +92,13 @@ static int get_y_pos(struct vkms_frame_info *frame_info, int y) return -1; return y + frame_info->dst.x1; default: - return y; + break; } + + if (frame_info->rotation & DRM_MODE_REFLECT_Y) + return drm_rect_height(&frame_info->dst) - y - 1; + + return y; } static bool check_limit(struct vkms_frame_info *frame_info, int pos) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e2bd2231fe4c..3f82b5315fef 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -121,12 +121,8 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, frame_info->fb = fb; 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_ROTATE_180 | - DRM_MODE_ROTATE_270 | - DRM_MODE_REFLECT_X); + frame_info->rotation = drm_rotation_simplify(new_state->rotation, DRM_MODE_ROTATE_MASK | + DRM_MODE_REFLECT_MASK); drm_rect_rotate(&frame_info->dst, drm_rect_width(&frame_info->dst), drm_rect_height(&frame_info->dst), frame_info->rotation); @@ -240,12 +236,8 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_helper_add(&plane->base, funcs); - 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_ROTATE_270 | - DRM_MODE_REFLECT_X); + drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, DRM_MODE_ROTATE_MASK | + DRM_MODE_REFLECT_MASK); return plane; } From patchwork Thu Apr 6 13:01:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13203302 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9B07DC761A6 for ; Thu, 6 Apr 2023 13:02:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CE62210EB90; Thu, 6 Apr 2023 13:02:26 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id E63C510E391 for ; Thu, 6 Apr 2023 13:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HGSWzD8/tLZV+T56VOcM69YG1VcCQfm8Z6T3Bdgvjhc=; b=BsLl5kCQOO9Cbg+YAp3bqMf31J /mtdivcaPnJ/sRjtEyVj/aIwlnRIE+EA/goCGwSIm1gO2gm/59ekDNPlPWP94pQ6cNUIn9cM8yI2C PnqD4BGzHn6b7W6FPTkEHkAbKB4euG6XjFok8Cd4Yt4djoav9KyfXCfB3oK2L3nT/vE11M+vVbDFo nlBm2gxDDNhxF3QoscULvG55h4tMnx9kmI8kdJ+ImAlfc7ZhZxcusqLl2uPH3SPfCQ1y5ViiSP6c2 eF8AzCaCZeAscYc8MOZwHHvcUBP/zYCtTPrmPL8ESJRqtaUVPtu0f9lAUMYtkD9QWHFikYCx3hckt 2dqY5LMQ==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pkPFr-0084OI-Jv; Thu, 06 Apr 2023 15:02:19 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed Subject: [PATCH 6/6] drm/vkms: drop "Rotation" TODO Date: Thu, 6 Apr 2023 10:01:38 -0300 Message-Id: <20230406130138.70752-7-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406130138.70752-1-mcanal@igalia.com> References: <20230406130138.70752-1-mcanal@igalia.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Now that VKMS supports all values of rotation and reflection, drop the "Rotation" task from the TODO list. Signed-off-by: Maíra Canal --- Documentation/gpu/vkms.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index 49db221c0f52..413e6815b9bc 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -125,7 +125,7 @@ There's lots of plane features we could add support for: - Full alpha blending on all planes. -- Rotation, scaling. +- Scaling. - Additional buffer formats, especially YUV formats for video like NV12. Low/high bpp RGB formats would also be interesting.