From patchwork Mon Apr 17 12:10: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: 13213739 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 835E8C77B72 for ; Mon, 17 Apr 2023 12:11:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 13ACB10E47F; Mon, 17 Apr 2023 12:11:40 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id B77ED10E47B for ; Mon, 17 Apr 2023 12:11:35 +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=E/Zq4w4P4yuCbRG8FNDh9YYCwU31IuWjCc+M7K+kdKs=; b=qjGjy+FIGHk94VrjdqO4beIj1C HsRebnNoxjzZr2XSyFsp3bTWe5qDg7Fx4LpDUTyZOAgmU89aRNaKDOB0k997wZyFrvaPXH4qZaNiE KUbZOJzQzA8noIj+LaWI3XTniznCxgo8u3VrrVaLFBsWhhr/KZYYZ3GLL952B4yhUhJx4ndqaLh6c DQDBzWZAchismIQ7BAsAkgLb7M5H2B/5+/iWuJdyebgc6EHWOj2EmjXpHdXlBxZ91ke1TKwQ9dlq3 M4ZNrXFLaFfV5PIIwVdRWcXUJwVVJ2HngCDwGJt+Oe7nckgQdAXj3BlwuiGtm4VsOUp457STyz67O BWi3pSXg==; 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 1poNhc-003OAC-7o; Mon, 17 Apr 2023 14:11: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 , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Subject: [PATCH v3 1/6] drm/vkms: isolate pixel conversion functionality Date: Mon, 17 Apr 2023 09:10:51 -0300 Message-Id: <20230417121056.63917-2-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417121056.63917-1-mcanal@igalia.com> References: <20230417121056.63917-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 Reviewed-by: Arthur Grillo --- drivers/gpu/drm/vkms/vkms_composer.c | 4 +- drivers/gpu/drm/vkms/vkms_drv.h | 4 +- drivers/gpu/drm/vkms/vkms_formats.c | 125 +++++++++++---------------- drivers/gpu/drm/vkms/vkms_formats.h | 2 +- drivers/gpu/drm/vkms/vkms_plane.c | 2 +- 5 files changed, 56 insertions(+), 81 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..f152d54baf76 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)(u8 *src_buffer, struct pixel_argb_u16 *out_pixel); }; 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..bd542fd00698 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -42,100 +42,75 @@ 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(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { - 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; - } + /* + * 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_pixel->a = (u16)src_pixels[3] * 257; + out_pixel->r = (u16)src_pixels[2] * 257; + out_pixel->g = (u16)src_pixels[1] * 257; + out_pixel->b = (u16)src_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(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { - 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) { - 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_pixel->a = (u16)0xffff; + out_pixel->r = (u16)src_pixels[2] * 257; + out_pixel->g = (u16)src_pixels[1] * 257; + out_pixel->b = (u16)src_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(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { - 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); + u16 *pixels = (u16 *)src_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_pixel->a = le16_to_cpu(pixels[3]); + out_pixel->r = le16_to_cpu(pixels[2]); + out_pixel->g = le16_to_cpu(pixels[1]); + out_pixel->b = le16_to_cpu(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(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { - 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); + u16 *pixels = (u16 *)src_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_pixel->a = (u16)0xffff; + out_pixel->r = le16_to_cpu(pixels[2]); + out_pixel->g = le16_to_cpu(pixels[1]); + out_pixel->b = le16_to_cpu(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(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { - 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); + u16 *pixels = (u16 *)src_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(*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_pixel->a = (u16)0xffff; + out_pixel->r = drm_fixp2int(drm_fixp_mul(fp_r, fp_rb_ratio)); + out_pixel->g = drm_fixp2int(drm_fixp_mul(fp_g, fp_g_ratio)); + out_pixel->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; + u8 *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); + + for (size_t x = 0; x < limit; x++, src_pixels += plane->frame_info->cpp) + plane->pixel_read(src_pixels, &out_pixels[x]); } /* @@ -249,7 +224,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 Mon Apr 17 12:10:52 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: 13213738 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 3BF64C77B70 for ; Mon, 17 Apr 2023 12:11:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 45E5D10E47B; Mon, 17 Apr 2023 12:11:36 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id DDF2E10E47B for ; Mon, 17 Apr 2023 12:11:34 +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=eRqjKKG18QTIqDCVmI1dj2n0Rr0vqDkvgDlNU9ShCAI=; b=iY2w1NDExN84CDF79z+TS1EXEb /+AvKJzXF+GgcrEPaB7HAGCbozHJv8wYKZ2iDGavy6AqGfw+SDqe+vzax7DmelMvxJzVoclZbImKz 1NUUqrDdxTU62B334piMQBZ3OM4H5cqZKMq7WVmMAD1hK8mpnHNLDCPlzP37Q9T0MV3p31MXXJ9Xb IXyzHO3mDUu2ZS4+MNCRbqNHT8hFcG/Y30Snx/Ccg3AGrbOTi8DGfSghHSDMT3N3oBMbSKrV8Llv+ 362RwzaRC2xIedlFfvtiWdN9uE8PJv3WTM4l0mwwLOhrffSG9G50yLSnHJlD3sDlagdOmsFuwFhhY 4yYbOoLA==; 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 1poNhg-003OAC-4k; Mon, 17 Apr 2023 14:11: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 , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Subject: [PATCH v3 2/6] drm/vkms: add rotate-0 and reflect-x property Date: Mon, 17 Apr 2023 09:10:52 -0300 Message-Id: <20230417121056.63917-3-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417121056.63917-1-mcanal@igalia.com> References: <20230417121056.63917-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_composer.c | 14 ++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 1 + drivers/gpu/drm/vkms/vkms_formats.c | 14 ++++++++++++-- drivers/gpu/drm/vkms/vkms_plane.c | 11 +++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 80164e79af00..0f65c8c2e85e 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -11,6 +11,17 @@ #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; + + if (frame_info->rotation & DRM_MODE_REFLECT_X) + return out - frame_info->dst.x1; + + return out + frame_info->dst.x1; +} + static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) { u32 new_color; @@ -39,8 +50,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); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index f152d54baf76..21627cdea025 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 bd542fd00698..42076df864ec 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 limit, int x) +{ + if (frame_info->rotation & DRM_MODE_REFLECT_X) + return limit - x - 1; + return x; +} + static void ARGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { /* @@ -109,8 +116,11 @@ 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); - for (size_t x = 0; x < limit; x++, src_pixels += plane->frame_info->cpp) - plane->pixel_read(src_pixels, &out_pixels[x]); + for (size_t x = 0; x < limit; x++, src_pixels += plane->frame_info->cpp) { + int 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..729ea7ce2ad3 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,12 @@ 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_REFLECT_X); + + 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 +236,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_REFLECT_X); + return plane; } From patchwork Mon Apr 17 12:10:53 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: 13213742 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 9670DC77B70 for ; Mon, 17 Apr 2023 12:11:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B97E10E488; Mon, 17 Apr 2023 12:11:50 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id C5D1510E47F for ; Mon, 17 Apr 2023 12:11:38 +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=02QiWHuuetES8shmh8njcRkJDQMn1lUi7WscOtFz8EA=; b=keX2tVfpG5wQkFjsZ6LtU3GIn9 CfcUBxb1ojl6/ivWYdxw/H1+WFGpXijr/T7olX2hQE8F2z5UlYTQ+v+FdilHU+MWXE7J6jSl8koyJ D13cNzUzOFvUQTfm989kVoc3pOQi7vo4pOLggjIU6jtB2Ero0dyTYoBRF0Uzz5VGzkKj/jv/y7yOi /S9YYEbc7w9GAdVcrCj7vS/eF/o+fL1Uodu0zx5rpO0ffL7/R0yxvBPpXg7WdnAbvVz5ZLCQGEwg6 WM/G/h+sM/1i1GLLofopX9AEPqExfDWutqogpuDRYmoMo1mXndgaOl1X3sF1qUtn7hSgs17Z7SOUx MjKfYirQ==; 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 1poNhk-003OAC-0l; Mon, 17 Apr 2023 14:11: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 , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Subject: [PATCH v3 3/6] drm/vkms: add reflect-y and rotate-180 property Date: Mon, 17 Apr 2023 09:10:53 -0300 Message-Id: <20230417121056.63917-4-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417121056.63917-1-mcanal@igalia.com> References: <20230417121056.63917-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 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. Note that, by implementing the reflect-x and reflect-y properties, it is also possible to add the rotate-180 property, as it is a combination of those two properties. Tested with igt@kms_rotation_crc@primary-reflect-y [1], igt@kms_rotation_crc@sprite-reflect-y [1], 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 | 16 +++++++++++++--- drivers/gpu/drm/vkms/vkms_plane.c | 7 +++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 0f65c8c2e85e..c6e2f046c1f9 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -63,6 +63,13 @@ 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) +{ + if (frame_info->rotation & DRM_MODE_REFLECT_Y) + return drm_rect_height(&frame_info->dst) - y - 1; + 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) @@ -96,6 +103,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 }; @@ -106,10 +114,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); } @@ -117,7 +127,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_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 729ea7ce2ad3..020d098f710e 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -122,7 +122,8 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, memcpy(&frame_info->map, &shadow_plane_state->data, sizeof(frame_info->map)); drm_framebuffer_get(frame_info->fb); frame_info->rotation = drm_rotation_simplify(new_state->rotation, DRM_MODE_ROTATE_0 | - DRM_MODE_REFLECT_X); + DRM_MODE_REFLECT_X | + DRM_MODE_REFLECT_Y); drm_rect_rotate(&frame_info->dst, drm_rect_width(&frame_info->dst), drm_rect_height(&frame_info->dst), frame_info->rotation); @@ -238,7 +239,9 @@ 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_REFLECT_X); + DRM_MODE_ROTATE_180 | + DRM_MODE_REFLECT_X | + DRM_MODE_REFLECT_Y); return plane; } From patchwork Mon Apr 17 12:10:54 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: 13213743 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 744DAC77B72 for ; Mon, 17 Apr 2023 12:12:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9AF5A10E491; Mon, 17 Apr 2023 12:11:59 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id C723410E485 for ; Mon, 17 Apr 2023 12:11:41 +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=sADe04wwWZszY1CGbC6v3amZ7OvJh4+Qfe74/FIjaSE=; b=SFIVyPaL+BlK9bQB7SSMpwOdwd CTrexelLjzSNrnw8j+VS/fYH8+jc0QGiNamb4aODARg00mQIlQx/seu5Zqtzwy5y9uE7YHdJhQXnk 9JBcZv5bXjS3ClMgeVydrTSSkNqAeo+JiGycUkdTStjnT76Qp3a4j4fT5B5AFOsNj9YHzgc9dIBRm ql3CYKIX3uCG13D04CGt0Gv2oUdq8gWta5zsPhnflBKMO/aZ4fvCKxBiX7fwKm97KQRFH/fcOFykW kJ6tVdbOrGolcZy3iqeCuNwali3IeUkBFC6nfGjAXd6BcHCzvtiMtgHUAsboQ5h5n2Ck6DETezc/o +bQAAy1Q==; 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 1poNhn-003OAC-QG; Mon, 17 Apr 2023 14:11:36 +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 , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Subject: [PATCH v3 4/6] drm/vkms: add rotate-90 property Date: Mon, 17 Apr 2023 09:10:54 -0300 Message-Id: <20230417121056.63917-5-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417121056.63917-1-mcanal@igalia.com> References: <20230417121056.63917-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, reflect-x and reflect-y properties. Therefore, improve the vkms IGT test coverage by adding the rotate-90 property to vkms. The rotation was implement by software: rotate the way the blending occurs by making the source x axis be the destination y axis and the source y axis be the destination x axis. Tested with igt@kms_rotation_crc@primary-rotation-90, 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 | 38 +++++++++++++++++++++------- drivers/gpu/drm/vkms/vkms_formats.c | 15 +++++++++-- drivers/gpu/drm/vkms/vkms_plane.c | 2 ++ 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index c6e2f046c1f9..eb07344b7621 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -19,7 +19,12 @@ static struct pixel_argb_u16 *get_out_buffer(const struct vkms_frame_info *frame if (frame_info->rotation & DRM_MODE_REFLECT_X) return out - frame_info->dst.x1; - return out + frame_info->dst.x1; + switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) { + case DRM_MODE_ROTATE_90: + return out - frame_info->dst.y1; + default: + return out + frame_info->dst.x1; + } } static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) @@ -52,10 +57,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); @@ -67,13 +74,26 @@ static int get_y_pos(struct vkms_frame_info *frame_info, int y) { if (frame_info->rotation & DRM_MODE_REFLECT_Y) return drm_rect_height(&frame_info->dst) - y - 1; - return 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; + default: + return y; + } } -static bool check_y_limit(struct vkms_frame_info *frame_info, int y) +static bool check_limit(struct vkms_frame_info *frame_info, int pos) { - if (y >= frame_info->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; } @@ -116,7 +136,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 42076df864ec..4bf18447c58d 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -49,6 +49,13 @@ static int get_x_position(const struct vkms_frame_info *frame_info, int limit, i 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 ARGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { /* @@ -113,12 +120,16 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state { struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; u8 *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); for (size_t x = 0; x < limit; x++, src_pixels += plane->frame_info->cpp) { int x_pos = get_x_position(plane->frame_info, limit, x); + if (plane->frame_info->rotation & DRM_MODE_ROTATE_90) + src_pixels = get_packed_src_addr(plane->frame_info, x + + plane->frame_info->dst.y1) + + plane->frame_info->cpp * y; + plane->pixel_read(src_pixels, &out_pixels[x_pos]); } } diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 020d098f710e..bb7cf4db0888 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -122,6 +122,7 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, memcpy(&frame_info->map, &shadow_plane_state->data, sizeof(frame_info->map)); drm_framebuffer_get(frame_info->fb); frame_info->rotation = drm_rotation_simplify(new_state->rotation, DRM_MODE_ROTATE_0 | + DRM_MODE_ROTATE_90 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y); @@ -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 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y); From patchwork Mon Apr 17 12:10:55 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: 13213741 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 C170EC77B70 for ; Mon, 17 Apr 2023 12:11:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E33810E485; Mon, 17 Apr 2023 12:11:48 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0A4CC10E485 for ; Mon, 17 Apr 2023 12:11:46 +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=qB7f0OxpjeLSdwGu6NC3ZHUTZud7vtOMw2iq1I8ObgU=; b=WrzfAl24Vtw4kthy1KDK/8pnMU HuYRHS5ALlydPzxh6iwGqKdxNN3aBu1SwZcBY3+CvQsdW1KbLmaL3r69MaZsgoKZXee8XQkEjYcRP Z33HZegAl9zKB9Nh7TRdK6oHlt9Xg0trcu+jMcLR/jVgMyo3YJNb6LiNNnYNfR+B8BaUcsL+Tmar4 Bt3V0pLcPjI08tQVnQwpAwKa3NQMYYnK+/jA0IneBv+7J4GLbYgMg3ft67vJ+OUZ+QtbZ2LMuYjUo 6gX9V1S3eONWRwj5oCD+iiapTveayXYSytXN71tKuOi6I/J7fK4GO/r6q+FweYi2QjPqr1iyzUq6I NxLAJL9g==; 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 1poNhr-003OAC-TJ; Mon, 17 Apr 2023 14:11:40 +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 , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Subject: [PATCH v3 5/6] drm/vkms: add rotate-270 property Date: Mon, 17 Apr 2023 09:10:55 -0300 Message-Id: <20230417121056.63917-6-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417121056.63917-1-mcanal@igalia.com> References: <20230417121056.63917-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 supports the rotate-90, rotate-180, reflect-x and reflect-y properties. Therefore, improve the vkms IGT test coverage by adding the rotate-270 property to vkms. The rotation was implement by software: rotate the way the blending occurs by making the source x axis be the destination y axis and the source y axis be the destination x axis and reverse-read the axis. Now, vkms supports all possible rotation values. Tested with igt@kms_rotation_crc@primary-rotation-270, and igt@kms_rotation_crc@sprite-rotation-270. Signed-off-by: Maíra Canal --- drivers/gpu/drm/vkms/vkms_composer.c | 11 +++++++++-- drivers/gpu/drm/vkms/vkms_formats.c | 8 +++++--- drivers/gpu/drm/vkms/vkms_plane.c | 7 ++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index eb07344b7621..0b36b66419cb 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 @@ -22,6 +23,8 @@ static struct pixel_argb_u16 *get_out_buffer(const struct vkms_frame_info *frame switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) { case DRM_MODE_ROTATE_90: return out - frame_info->dst.y1; + case DRM_MODE_ROTATE_270: + return out + frame_info->dst.y1; default: return out + frame_info->dst.x1; } @@ -59,7 +62,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++) { @@ -80,6 +83,10 @@ static int get_y_pos(struct vkms_frame_info *frame_info, int y) if (y - frame_info->dst.x1 < 0) return -1; return frame_info->dst.x2 - 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; } @@ -87,7 +94,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 4bf18447c58d..6877299007d8 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -2,6 +2,8 @@ #include #include + +#include #include #include @@ -44,14 +46,14 @@ 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 limit, int x) { - if (frame_info->rotation & DRM_MODE_REFLECT_X) + if (frame_info->rotation & (DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_270)) return 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); } @@ -125,7 +127,7 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state for (size_t x = 0; x < limit; x++, src_pixels += plane->frame_info->cpp) { int x_pos = get_x_position(plane->frame_info, limit, x); - if (plane->frame_info->rotation & DRM_MODE_ROTATE_90) + if (drm_rotation_90_or_270(plane->frame_info->rotation)) src_pixels = get_packed_src_addr(plane->frame_info, x + plane->frame_info->dst.y1) + plane->frame_info->cpp * y; diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index bb7cf4db0888..9ee5de7ef8dd 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_270 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y); @@ -239,11 +240,7 @@ 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_REFLECT_X | - DRM_MODE_REFLECT_Y); + DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK); return plane; } From patchwork Mon Apr 17 12:10:56 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: 13213744 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 CEAAEC77B70 for ; Mon, 17 Apr 2023 12:12:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB35B10E493; Mon, 17 Apr 2023 12:12:05 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id E582710E489 for ; Mon, 17 Apr 2023 12:11:49 +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=sNFqIdP/7p1B0XSg01uiUy+YwT NaIWdkoB53BBiKflNHuT9qG8xkoFvpWDjfsRCRHjmpwKYjEjgCtD0VA8j6ZDNTn+vFFG1NrvPtjjE cDqFXUPXydSunSy8vVz/YqKwBLCWAuBYXEsc68kHYggjVBqoRxuYy3P6WmE6aPAd0WugaxmeOq2EQ xato8USY5re5SdIzhAuUscr96QoctUbN2MaLBNNRnd0K7Waa5vlxBh7LToS5r5fSnQBZJgw5Fd+D4 GUm5Bo/14RTQqMi/1YGsEQitftCBOul6IiLXb30eqv6tk9MpboXCs+tQGvxLB/IW8ihmeRtLW2bvf olDNaszw==; 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 1poNhv-003OAC-T6; Mon, 17 Apr 2023 14:11:44 +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 , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= Subject: [PATCH v3 6/6] drm/vkms: drop "Rotation" TODO Date: Mon, 17 Apr 2023 09:10:56 -0300 Message-Id: <20230417121056.63917-7-mcanal@igalia.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417121056.63917-1-mcanal@igalia.com> References: <20230417121056.63917-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.