From patchwork Fri Apr 14 13:51:45 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: 13211515 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 C51BFC77B72 for ; Fri, 14 Apr 2023 13:52:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0FF8D10ED0E; Fri, 14 Apr 2023 13:52:15 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F07D10ED0E for ; Fri, 14 Apr 2023 13:52:12 +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=LfM+HIRJX3imjy+dkRaFJxXd5ISj7HhAw502bWnHh4U=; b=Kv8HkoZEpW30Wv7QfQQFSUuoDl 2TfgAYWbD8qwRf7HCjMP6L1FRcVzq3+1obbrtHcmxwzOH5tGwKdHHK4RZt+menVGB6WXM4F966/ul L6BxHyyyHMd2J98i71F+s4eYfy78K8o6R3zPFNvX7S83DG7ygAOFBNSWqTY5bFQR6AavKCSjib7AI oLXLnWnEYS9giFMGTmcv+aYX/+A983aWMZEd5rTk20O3dxGkMrgBe4/vqHwZveazQTZQibCy+3LOo rJ0xVKz7Kf8/eh0jxgEKBTlN+SS5Pvhuo8+WPxkRgUaSFb/uujwidFfX7A2fylYmrjeq5uX3d9Qlj 17yzW0IA==; Received: from [177.34.168.16] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pnJqS-0015Av-M5; Fri, 14 Apr 2023 15:52:09 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Igor Matheus Andrade Torrente , Arthur Grillo Subject: [PATCH v2 1/7] drm/vkms: isolate pixel conversion functionality Date: Fri, 14 Apr 2023 10:51:45 -0300 Message-Id: <20230414135151.75975-2-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414135151.75975-1-mcanal@igalia.com> References: <20230414135151.75975-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, the pixel conversion functions repeat the same loop to iterate the rows. Instead of repeating the same code for each pixel format, create a function to wrap the loop and isolate the pixel conversion functionality. Suggested-by: Arthur Grillo Signed-off-by: Maíra Canal --- drivers/gpu/drm/vkms/vkms_composer.c | 4 +- drivers/gpu/drm/vkms/vkms_drv.h | 4 +- drivers/gpu/drm/vkms/vkms_formats.c | 136 ++++++++++++--------------- drivers/gpu/drm/vkms/vkms_formats.h | 2 +- drivers/gpu/drm/vkms/vkms_plane.c | 2 +- 5 files changed, 65 insertions(+), 83 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 8e53fa80742b..80164e79af00 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -99,7 +99,7 @@ static void blend(struct vkms_writeback_job *wb, if (!check_y_limit(plane[i]->frame_info, y)) continue; - plane[i]->plane_read(stage_buffer, plane[i]->frame_info, y); + vkms_compose_row(stage_buffer, plane[i], y); pre_mul_alpha_blend(plane[i]->frame_info, stage_buffer, output_buffer); } @@ -118,7 +118,7 @@ static int check_format_funcs(struct vkms_crtc_state *crtc_state, u32 n_active_planes = crtc_state->num_active_planes; for (size_t i = 0; i < n_active_planes; i++) - if (!planes[i]->plane_read) + if (!planes[i]->pixel_read) return -1; if (active_wb && !active_wb->wb_write) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 4a248567efb2..d7ad813d7ae7 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -56,8 +56,7 @@ struct vkms_writeback_job { struct vkms_plane_state { struct drm_shadow_plane_state base; struct vkms_frame_info *frame_info; - void (*plane_read)(struct line_buffer *buffer, - const struct vkms_frame_info *frame_info, int y); + void (*pixel_read)(u16 *src_buffer, struct pixel_argb_u16 *out_pixels, int x); }; struct vkms_plane { @@ -155,6 +154,7 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, /* Composer Support */ void vkms_composer_worker(struct work_struct *work); void vkms_set_composer(struct vkms_output *out, bool enabled); +void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y); /* Writeback */ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index d4950688b3f1..02b0fc5a0839 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -42,100 +42,82 @@ 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 void ARGB8888_to_argb_u16(struct line_buffer *stage_buffer, - const struct vkms_frame_info *frame_info, int y) +static void ARGB8888_to_argb_u16(u16 *src_pixels, struct pixel_argb_u16 *out_pixels, int x) { - 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); - - for (size_t x = 0; x < x_limit; x++, src_pixels += 4) { - /* - * 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; - } + u8 *pixels = (u8 *)src_pixels; + + /* + * 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)pixels[3] * 257; + out_pixels[x].r = (u16)pixels[2] * 257; + out_pixels[x].g = (u16)pixels[1] * 257; + out_pixels[x].b = (u16)pixels[0] * 257; } -static void XRGB8888_to_argb_u16(struct line_buffer *stage_buffer, - const struct vkms_frame_info *frame_info, int y) +static void XRGB8888_to_argb_u16(u16 *src_pixels, struct pixel_argb_u16 *out_pixels, int x) { - 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); + u8 *pixels = (u8 *)src_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; - } + out_pixels[x].a = (u16)0xffff; + out_pixels[x].r = (u16)pixels[2] * 257; + out_pixels[x].g = (u16)pixels[1] * 257; + out_pixels[x].b = (u16)pixels[0] * 257; } -static void ARGB16161616_to_argb_u16(struct line_buffer *stage_buffer, - const struct vkms_frame_info *frame_info, - int y) +static void ARGB16161616_to_argb_u16(u16 *src_pixels, struct pixel_argb_u16 *out_pixels, int x) { - 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); - - 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]); - } + 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]); } -static void XRGB16161616_to_argb_u16(struct line_buffer *stage_buffer, - const struct vkms_frame_info *frame_info, - int y) +static void XRGB16161616_to_argb_u16(u16 *src_pixels, struct pixel_argb_u16 *out_pixels, int x) { - 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); - - 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]); - } + 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]); } -static void RGB565_to_argb_u16(struct line_buffer *stage_buffer, - const struct vkms_frame_info *frame_info, int y) +static void RGB565_to_argb_u16(u16 *src_pixels, struct pixel_argb_u16 *out_pixels, int x) { - 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); - 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++) { - 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); + 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].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)); +} + +void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y) +{ + struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; + u16 *src_pixels = get_packed_src_addr(plane->frame_info, y); + int limit = min_t(size_t, drm_rect_width(&plane->frame_info->dst), + stage_buffer->n_pixels); + int format = plane->frame_info->fb->format->format; + int pixel_size; + + if (format == DRM_FORMAT_RGB565) + pixel_size = 1; + else if (format == DRM_FORMAT_ARGB8888 || format == DRM_FORMAT_XRGB8888) + pixel_size = 2; + else + pixel_size = 4; + + for (size_t x = 0; x < limit; x++, src_pixels += pixel_size) + plane->pixel_read(src_pixels, out_pixels, x); } /* @@ -249,7 +231,7 @@ static void argb_u16_to_RGB565(struct vkms_frame_info *frame_info, } } -void *get_frame_to_line_function(u32 format) +void *get_pixel_conversion_function(u32 format) { switch (format) { case DRM_FORMAT_ARGB8888: diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index 43b7c1979018..c5b113495d0c 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -5,7 +5,7 @@ #include "vkms_drv.h" -void *get_frame_to_line_function(u32 format); +void *get_pixel_conversion_function(u32 format); void *get_line_to_frame_function(u32 format); diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index c41cec7dcb70..0a23875900ec 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -123,7 +123,7 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, frame_info->offset = fb->offsets[0]; frame_info->pitch = fb->pitches[0]; frame_info->cpp = fb->format->cpp[0]; - vkms_plane_state->plane_read = get_frame_to_line_function(fmt); + vkms_plane_state->pixel_read = get_pixel_conversion_function(fmt); } static int vkms_plane_atomic_check(struct drm_plane *plane, From patchwork Fri Apr 14 13:51:46 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: 13211517 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 2980DC77B76 for ; Fri, 14 Apr 2023 13:52:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3028E10ED54; Fri, 14 Apr 2023 13:52:20 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2968C10ED53 for ; Fri, 14 Apr 2023 13:52:18 +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=l3odwZxGyp2ETY5QW6pw+NrbbvIvMsItUKhMJ3bAxC4=; b=sn6jC6FtFgpZWwHKoVI/KfQ9X6 XVTfZymDCmeXm64EDmNtLmB6BXC1vyQcmj9LU2ir7MP2Y7FPiZrG71OczE5N9UiL71yO1FhXp73xf SI5MNE1xYOO9rXsZcQ9kkA4PcfJCPmuR6J0cXAT3L964bWR/v+OzuJAlfm68bCzVSVhd8jQR4C7Bk GeX41CJCoHIFpO3oSA/AA19w37gwyikxrqaJlday7j874jvxBxu9wKhC2CxnIJFPYP7LZ2XYE06Q0 PfqULVLxjKdrvgisg15YBlQys5mk0afio9gMYXVOkM5JrR1ErQHecGB6nsQg734xJQdrZkqTbuh+J L32WCddw==; Received: from [177.34.168.16] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pnJqW-0015Av-Lu; Fri, 14 Apr 2023 15:52:12 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Igor Matheus Andrade Torrente , Arthur Grillo Subject: [PATCH v2 2/7] drm/vkms: add rotate-0 and rotate-180 properties Date: Fri, 14 Apr 2023 10:51:46 -0300 Message-Id: <20230414135151.75975-3-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414135151.75975-1-mcanal@igalia.com> References: <20230414135151.75975-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 | 16 +++++++++--- drivers/gpu/drm/vkms/vkms_plane.c | 12 +++++++++ 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 80164e79af00..914d85ac1654 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; - vkms_compose_row(stage_buffer, plane[i], y); + vkms_compose_row(stage_buffer, plane[i], 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 d7ad813d7ae7..8344395d7745 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 02b0fc5a0839..7a98d4d75f17 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(u16 *src_pixels, struct pixel_argb_u16 *out_pixels, int x) { u8 *pixels = (u8 *)src_pixels; @@ -107,7 +114,7 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state int limit = min_t(size_t, drm_rect_width(&plane->frame_info->dst), stage_buffer->n_pixels); int format = plane->frame_info->fb->format->format; - int pixel_size; + int pixel_size, x_pos; if (format == DRM_FORMAT_RGB565) pixel_size = 1; @@ -116,8 +123,11 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state else pixel_size = 4; - for (size_t x = 0; x < limit; x++, src_pixels += pixel_size) - plane->pixel_read(src_pixels, out_pixels, x); + for (size_t x = 0; x < limit; x++, src_pixels += pixel_size) { + x_pos = get_x_position(plane->frame_info, limit, x); + + 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 0a23875900ec..f6a884b5872c 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 Fri Apr 14 13:51:47 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: 13211518 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 7AF7CC77B72 for ; Fri, 14 Apr 2023 13:52:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F37010ED47; Fri, 14 Apr 2023 13:52:24 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id ABAFD10ED47 for ; Fri, 14 Apr 2023 13:52:21 +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=EoZFHB7SCliV2xlgQKM1lEt9HiRQzrC/Y//4enoFB1U=; b=qXPWPizyF/+K0Ziz9nQ2utBCOI 4lA50atKfAVrQW4e4xzsbaZMl2xThRX1P7sEOE1Y/ylbe6wrVfehSIUSpDbGruV4bN3vi2fFJfYfY 5RjH0wL7K9C+BUNq59CbQsAgNZxWbDv/wa/7HvcLuM7cp3FHbPZhCLwAQ0n4e7uXwPQCxOP4v7s7s 1NJ7SN1myZfAiRb+p9RNUhVfdJ4gaxFwHdnwMXgQAPNWvXqTG5Id6YIC17Rbv5cK3sGhxLrHNlaV7 vgPHXHWDlo7Jt12jXJx13JyuqyRiQSk640dsTd2mjN9IBWJWVfFlRuj460pC8Dvi71loYt8gXZ2I8 BCgd2nrQ==; Received: from [177.34.168.16] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pnJqa-0015Av-F7; Fri, 14 Apr 2023 15:52:16 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Igor Matheus Andrade Torrente , Arthur Grillo Subject: [PATCH v2 3/7] drm/vkms: add rotate-90 property Date: Fri, 14 Apr 2023 10:51:47 -0300 Message-Id: <20230414135151.75975-4-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414135151.75975-1-mcanal@igalia.com> References: <20230414135151.75975-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 | 28 ++++++++++++++++++++------- drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 914d85ac1654..824bb65badb7 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; 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 7a98d4d75f17..90b72b0ff8c9 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -49,6 +49,20 @@ 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 void *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(u16 *src_pixels, struct pixel_argb_u16 *out_pixels, int x) { u8 *pixels = (u8 *)src_pixels; @@ -110,21 +124,21 @@ static void RGB565_to_argb_u16(u16 *src_pixels, struct pixel_argb_u16 *out_pixel void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y) { struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; - u16 *src_pixels = get_packed_src_addr(plane->frame_info, y); - int limit = min_t(size_t, drm_rect_width(&plane->frame_info->dst), - stage_buffer->n_pixels); + int limit = get_limit(plane->frame_info, stage_buffer); int format = plane->frame_info->fb->format->format; int pixel_size, x_pos; + u16 *src_pixels; if (format == DRM_FORMAT_RGB565) - pixel_size = 1; - else if (format == DRM_FORMAT_ARGB8888 || format == DRM_FORMAT_XRGB8888) pixel_size = 2; - else + else if (format == DRM_FORMAT_ARGB8888 || format == DRM_FORMAT_XRGB8888) pixel_size = 4; + else + pixel_size = 8; - for (size_t x = 0; x < limit; x++, src_pixels += pixel_size) { + for (size_t x = 0; x < limit; x++) { x_pos = get_x_position(plane->frame_info, limit, x); + src_pixels = get_src_pixels(plane->frame_info, x, y, pixel_size); 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 f6a884b5872c..ce2ebe56f6e4 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 Fri Apr 14 13:51:48 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: 13211519 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 83FDFC77B76 for ; Fri, 14 Apr 2023 13:52:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D7CF310ED56; Fri, 14 Apr 2023 13:52:27 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93E8E10ED56 for ; Fri, 14 Apr 2023 13:52:25 +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=gNYVlkAczHbDzPYI/y0i5Hq9cr7N4+Adhb4jfzmPQjU=; b=hiaGOYhq9FO4gd5mwOcqTj1c5I Gi6Phqa38sXtzujC4b+/1tEARGIr7j3MpSAirq2R3EfraCDB3jMecqWEwWibFKjlfLzr3WqZTWKNM 5RPFZzD2RwVyFq//nUKD7RuXJoUszhpg/JQgS3PGu6Hgq3rblqavPn4Q5Le3515E1pDqx2RREP6XL SY7GvGxWtu/cZ1uHSnqKW+CKKmBg8kcfWlEfEt6yyTXkLxHrwMGogGBzNuPz3tepwPgJeFmRwOjrC eEF6Ff9jotleXORwLMPKz+NATP6Z5m2IM9n0F+iaYwFfhK6Akgo7dW09vwMwq87kIkRsMxF4QemFn AhersgYw==; Received: from [177.34.168.16] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pnJqe-0015Av-Ba; Fri, 14 Apr 2023 15:52:20 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Igor Matheus Andrade Torrente , Arthur Grillo Subject: [PATCH v2 4/7] drm/vkms: add rotate-270 property Date: Fri, 14 Apr 2023 10:51:48 -0300 Message-Id: <20230414135151.75975-5-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414135151.75975-1-mcanal@igalia.com> References: <20230414135151.75975-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 824bb65badb7..b05bd008aeab 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 90b72b0ff8c9..c4513f3d6876 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 void *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 ce2ebe56f6e4..5f69e0efd85f 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 Fri Apr 14 13:51:49 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: 13211520 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 CAEFFC77B6E for ; Fri, 14 Apr 2023 13:52:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31B5110E184; Fri, 14 Apr 2023 13:52:31 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9592210ED58 for ; Fri, 14 Apr 2023 13:52:29 +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=VYDV1Na0Xwrbz5VhtxN218jviWiczoSbstrbnOW+PEI=; b=EYo/4I1C2lOX6FNl4r4CxttSB8 dzf6A/Tm6cg8GNazepf2NUooYczQ0cbhBjKLWQYfraUAzifyCXzB+l+X1YisV9zP3divNFNF/tIup yP27x3cmMjIo//xidgFZqUtA3f2m+E8HG7pi9bXv3k0vU/WKCodxxej6DHRX7vSSHmIcgwkXVy4H7 teDip2uVYm5cQ/SlKXpe3lj8gyaRYbmW8Co/TYXuof1ctlY5hPByw5t00p44sy0j80IPCoV5wms5T tSV1i00VwUk+iZgRwf1R85vN5C4nCcX9BZgbP6umcB72IeuDzFoe9eYjlNSNCXX6zzZMYDFXTLhiT 4mBQ5MJw==; Received: from [177.34.168.16] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pnJqi-0015Av-82; Fri, 14 Apr 2023 15:52:24 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Igor Matheus Andrade Torrente , Arthur Grillo Subject: [PATCH v2 5/7] drm/vkms: add reflect-x property Date: Fri, 14 Apr 2023 10:51:49 -0300 Message-Id: <20230414135151.75975-6-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414135151.75975-1-mcanal@igalia.com> References: <20230414135151.75975-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 c4513f3d6876..2f8b41bf9ff9 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 5f69e0efd85f..11662afa9fe4 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 Fri Apr 14 13:51:50 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: 13211521 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 3C5FCC77B76 for ; Fri, 14 Apr 2023 13:52:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 73A8E10ED58; Fri, 14 Apr 2023 13:52:35 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4924B10ED58 for ; Fri, 14 Apr 2023 13:52:33 +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=094L5f5WCBPZfzTO8UsZcIEKiunO/ad34q1icxwMEpM=; b=IYylu9m+TezHGIMBRqf5apGoPk kmyuo5DaGpT/uSb4wVakawUThuia9t6r4j2FAHTKD8O5Lsakok8kyJQa8FF8CoNbzMZirNtlljRpH zcmsG/NHAARx0sMhN176tLFw+yZ++pmLTMmPanMm/svPKviVV+TwCZV0eRgUbpbndzZiy1tbahajF 8xsgDWqt8BWy2ivHjYBsTpShOUXDoU8uuH0/sgmgm0r4gWi0sSKSVtllUdRtDnxgRgRpY6ROFsS06 oYr/sgpnz7d6G9g3PgcPv8Gz4xBSZWyaEhgIDrlltc8J/CxL4vbBHLIBMmLE/x58/MSGRR0vwmrn1 e0L/hMMg==; Received: from [177.34.168.16] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pnJqm-0015Av-1I; Fri, 14 Apr 2023 15:52:28 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Igor Matheus Andrade Torrente , Arthur Grillo Subject: [PATCH v2 6/7] drm/vkms: add reflect-y property Date: Fri, 14 Apr 2023 10:51:50 -0300 Message-Id: <20230414135151.75975-7-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414135151.75975-1-mcanal@igalia.com> References: <20230414135151.75975-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 b05bd008aeab..19d1078e9d34 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 11662afa9fe4..d08bda869a24 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 Fri Apr 14 13:51:51 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: 13211522 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 E6745C77B6E for ; Fri, 14 Apr 2023 13:52:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B96510ED5B; Fri, 14 Apr 2023 13:52:38 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE61210ED75 for ; Fri, 14 Apr 2023 13:52:36 +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=UGvP0sS8ZtaGvzo0gqN9lPo6oo /5qb0mRaH7OS24k31+yqapizYXiZ3TYwpXFLkHMZ0xSjkLXDxAuASqvrAMJFTdv1F40pN1J6Ptrhr U+TZUu1Bu9CE4NV6YoY5nGW+zXVkr3+0i4G/5tDr+/0kiRcqsDeQLhgHdpDCqyLXynnn74+Zjx+vC eLoM3cjMVfAS6g82HulgrhUGCy5h8Tw8K4Al6q/1/fk8SzJg31fLQsQ3yk28UTnGbs5PfRzuN9bEU SmTosEJiddIoQJQF4JXF2tjGItxETLmEA9zNVpvGGI26VoTmdRY/7dE80Zk7QPpPAhXpkxeHoU77M JRkzfgzA==; Received: from [177.34.168.16] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pnJqp-0015Av-NO; Fri, 14 Apr 2023 15:52:32 +0200 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: David Airlie , Daniel Vetter , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Igor Matheus Andrade Torrente , Arthur Grillo Subject: [PATCH v2 7/7] drm/vkms: drop "Rotation" TODO Date: Fri, 14 Apr 2023 10:51:51 -0300 Message-Id: <20230414135151.75975-8-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414135151.75975-1-mcanal@igalia.com> References: <20230414135151.75975-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.