Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2804020lqp; Mon, 25 Mar 2024 09:36:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmQqPesC/vLD9Gm+m/sFGs19sIuD2sNHwryYuYptWBr9FkQNRRZYLFytJpZY1lfCvvfFfGsnEOb1BEzGL//UFIyQzNmbd73QjFFsADtg== X-Google-Smtp-Source: AGHT+IHvjhlPp3kYMASUYUk8WuMAaOs55feZ1fqMju3E+6TuTjmCXv7KyY8WlQQUz8lqgg693mkI X-Received: by 2002:a05:6e02:e10:b0:366:abec:b3f2 with SMTP id a16-20020a056e020e1000b00366abecb3f2mr148486ilk.31.1711384617449; Mon, 25 Mar 2024 09:36:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711384617; cv=pass; d=google.com; s=arc-20160816; b=jej+Vwz9qYOQRxT11n+eiVP0sTD5j1/uSmMu7LKKQiprmHFrI2G7n3jsGF7K+ONL0d U5Z+8Kyd9+XrgLhOMWsb2vGL2MyBD4Mi6J9+VGTHX8mIjvIOikbZG/pSuZZtWu0yBtni 9fn4RxXDwCqC/7Ej8wxRxvc1y2uwA4KIrih3v21+mJBAhcjDjsBsJb02mAsH1QmyC/pb KdqclPng6DOv5XD7ruTga7QJdSMAmKE+dsIXt+uWQVEzg1XKkwp3piIh73jbsqHRmbIZ zI8YEN3Xa6aCb6KvviGajk2nSOhSTiG0DkubVnmhxubkCs9jPWkxZbFZgfFs5+y/eIVA eWNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=Yd9+S3XxenHqQanmkoRWCDO8d3X3+DCs7dRSrWF3pvk=; fh=LEGVttrEe3EZzL8pWHKr59dCooiiMJK7UIxJnC6gzwU=; b=yMj1l7WLAZXvfldlrG1P3ouFeC/dK6XVlEVgmcCr0P/iXJYKrlkjLhUCl7H9EMDN7q tXYS6mNUo/Tv4iap9EyKEUvjem4Idm4LpZW4qiswsU0ibOrSezTYav0DpPKPL+rZj0B8 RWf5l2encAHRauEX6LUIlnTvMzoiizrfKe4EGy1OiqyQB+Cb/pw2+TZUhaNwUEA9bxeh 5GAc9EqsGFbeHL3PA03iy9pL71QeVqZ2qEgVYKZ/t+ri9zC15QkoBMKLmKV+4ysMS/pt 2rO1dQ3DFo4tVtqpkVg7/lx8tg71yha3nd+per476bTAwI33gROK62M7KMk5vQGSapzv q7pA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b="kNi/YcM8"; arc=pass (i=1 spf=pass spfdomain=igalia.com dkim=pass dkdomain=igalia.com); spf=pass (google.com: domain of linux-kernel+bounces-117204-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117204-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s2-20020a635242000000b005cd8486d5ccsi7621251pgl.65.2024.03.25.09.36.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 09:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117204-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b="kNi/YcM8"; arc=pass (i=1 spf=pass spfdomain=igalia.com dkim=pass dkdomain=igalia.com); spf=pass (google.com: domain of linux-kernel+bounces-117204-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117204-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 88D6C3400FF for ; Mon, 25 Mar 2024 16:14:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A2E2129E67; Mon, 25 Mar 2024 14:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="kNi/YcM8" Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 449CC6D1D2 for ; Mon, 25 Mar 2024 14:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711375651; cv=none; b=FwWlSj9FSMOo3AEE4DXRsBBKf9MdpMCI9yiYyO1iBuSojEAusIpHMqqaf1bF0EN9DNjHtNx61dP02VI3ZoGvqzmJnQ6qNgF5CFjvuIT8NYez+w6L3tu+D7eVfEUzUoZldpDkeQGy7RYLUkEmfJoOJQQUDxlghJrvZLEWZuMObr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711375651; c=relaxed/simple; bh=Ink/2BscmiKlDhlTWbHjHvB+RPygPPtsUUeS7CTpqh4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=scGqx1+IxQ6iKybUxkJ8JyCJWEGjJ2uVt50qjFPjbk18DpNzFFXwnoANDEl3Z2Lc2Xf+QZfCvj+lQ1+Ae5nnVSAcs3k8AF4FewrcIMz3rPaGItW+GiR5Dd8Ke+5wzvTD1aTXvOVRYdYrXAqrFg9EJ1IzQhQZ0ljHVMPQks1lJB4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=kNi/YcM8; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID: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=Yd9+S3XxenHqQanmkoRWCDO8d3X3+DCs7dRSrWF3pvk=; b=kNi/YcM8gsGT02869qrcozocD9 0tdtdl2SMnXU50FgZnNk9MUPj4deYmQWRt1MYa2bkGIsW6q7VpTYRUq9cr9oC5TRG6jqcs8nC6ZVc vOstY/fooRU32lPrefNsfF8Ds21+ZNiYV23EmmtVL4hPXqgjzwI1M1ht6AhwScQSrJ2e1wXoh57qc GSHPEfTbIJO6tTiDI/bRs4LEABafq/Cx61xyA9ype2dglSagTOL3wkpxSh18hKeTfdQZ5iPJLqUYF 6qvOwYMW9GnJv4SX1OnSj0hC/jA5JK49SuH7U3GprlQYMm8Jo3TV1CxRAAJUOVECcmQHwvRbLOLPM xV02CkjA==; Received: from [177.34.169.255] (helo=[192.168.0.139]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1rokyn-00F5UY-S2; Mon, 25 Mar 2024 15:07:14 +0100 Message-ID: Date: Mon, 25 Mar 2024 11:07:04 -0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 09/16] drm/vkms: Introduce pixel_read_direction enum To: Louis Chauvet , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , arthurgrillo@riseup.net, Jonathan Corbet , pekka.paalanen@haloniitty.fi Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com References: <20240313-yuv-v5-0-e610cbd03f52@bootlin.com> <20240313-yuv-v5-9-e610cbd03f52@bootlin.com> Content-Language: en-US From: =?UTF-8?Q?Ma=C3=ADra_Canal?= Autocrypt: addr=mcanal@igalia.com; keydata= xjMEZIsaeRYJKwYBBAHaRw8BAQdAGU6aY8oojw61KS5rGGMrlcilFqR6p6ID45IZ6ovX0h3N H01haXJhIENhbmFsIDxtY2FuYWxAaWdhbGlhLmNvbT7CjwQTFggANxYhBDMCqFtIvFKVRJZQ hDSPnHLaGFVuBQJkixp5BQkFo5qAAhsDBAsJCAcFFQgJCgsFFgIDAQAACgkQNI+cctoYVW5u GAEAwpaC5rI3wD8zqETKwGVoXd6+AbmGfZuVD40xepy7z/8BAM5w95/oyPsHUqOsg/xUTlNp rlbhA+WWoaOXA3XgR+wCzjgEZIsaeRIKKwYBBAGXVQEFAQEHQGoOK0jgh0IorMAacx6WUUWb s3RLiJYWUU6iNrk5wWUbAwEIB8J+BBgWCAAmFiEEMwKoW0i8UpVEllCENI+cctoYVW4FAmSL GnkFCQWjmoACGwwACgkQNI+cctoYVW6cqwD/Q9R98msvkhgRvi18fzUPFDwwogn+F+gQJJ6o pwpgFkAA/R2zOfla3IT6G3SBoV5ucdpdCpnIXFpQLbmfHK7dXsAC In-Reply-To: <20240313-yuv-v5-9-e610cbd03f52@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/13/24 14:45, Louis Chauvet wrote: > The pixel_read_direction enum is useful to describe the reading direction > in a plane. It avoids using the rotation property of DRM, which not > practical to know the direction of reading. > This patch also introduce two helpers, one to compute the > pixel_read_direction from the DRM rotation property, and one to compute > the step, in byte, between two successive pixel in a specific direction. > > Signed-off-by: Louis Chauvet > --- > drivers/gpu/drm/vkms/vkms_composer.c | 36 ++++++++++++++++++++++++++++++++++++ > drivers/gpu/drm/vkms/vkms_drv.h | 11 +++++++++++ > drivers/gpu/drm/vkms/vkms_formats.c | 30 ++++++++++++++++++++++++++++++ > 3 files changed, 77 insertions(+) > > diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c > index 9254086f23ff..989bcf59f375 100644 > --- a/drivers/gpu/drm/vkms/vkms_composer.c > +++ b/drivers/gpu/drm/vkms/vkms_composer.c > @@ -159,6 +159,42 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff > } > } > > +/** > + * direction_for_rotation() - Get the correct reading direction for a given rotation > + * > + * This function will use the @rotation setting of a source plane to compute the reading > + * direction in this plane which correspond to a "left to right writing" in the CRTC. > + * For example, if the buffer is reflected on X axis, the pixel must be read from right to left > + * to be written from left to right on the CRTC. > + * > + * @rotation: Rotation to analyze. It correspond the field @frame_info.rotation. A bit unusual to see arguments after the description. > + */ > +static enum pixel_read_direction direction_for_rotation(unsigned int rotation) > +{ > + if (rotation & DRM_MODE_ROTATE_0) { > + if (rotation & DRM_MODE_REFLECT_X) > + return READ_RIGHT_TO_LEFT; > + else > + return READ_LEFT_TO_RIGHT; > + } else if (rotation & DRM_MODE_ROTATE_90) { > + if (rotation & DRM_MODE_REFLECT_Y) > + return READ_BOTTOM_TO_TOP; > + else > + return READ_TOP_TO_BOTTOM; > + } else if (rotation & DRM_MODE_ROTATE_180) { > + if (rotation & DRM_MODE_REFLECT_X) > + return READ_LEFT_TO_RIGHT; > + else > + return READ_RIGHT_TO_LEFT; > + } else if (rotation & DRM_MODE_ROTATE_270) { > + if (rotation & DRM_MODE_REFLECT_Y) > + return READ_TOP_TO_BOTTOM; > + else > + return READ_BOTTOM_TO_TOP; > + } > + return READ_LEFT_TO_RIGHT; > +} > + > /** > * blend - blend the pixels from all planes and compute crc > * @wb: The writeback frame buffer metadata > diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h > index 3ead8b39af4a..985e7a92b7bc 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.h > +++ b/drivers/gpu/drm/vkms/vkms_drv.h > @@ -69,6 +69,17 @@ struct vkms_writeback_job { > pixel_write_t pixel_write; > }; > > +/** > + * enum pixel_read_direction - Enum used internaly by VKMS to represent a reading direction in a > + * plane. > + */ > +enum pixel_read_direction { > + READ_BOTTOM_TO_TOP, > + READ_TOP_TO_BOTTOM, > + READ_RIGHT_TO_LEFT, > + READ_LEFT_TO_RIGHT > +}; > + > /** > * typedef pixel_read_t - These functions are used to read a pixel in the source frame, > * convert it to `struct pixel_argb_u16` and write it to @out_pixel. > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > index 649d75d05b1f..743b6fd06db5 100644 > --- a/drivers/gpu/drm/vkms/vkms_formats.c > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > @@ -75,6 +75,36 @@ static void packed_pixels_addr(const struct vkms_frame_info *frame_info, > *addr = (u8 *)frame_info->map[0].vaddr + offset; > } > > +/** > + * get_step_next_block() - Common helper to compute the correct step value between each pixel block > + * to read in a certain direction. > + * > + * As the returned offset is the number of bytes between two consecutive blocks in a direction, > + * the caller may have to read multiple pixel before using the next one (for example, to read from > + * left to right in a DRM_FORMAT_R1 plane, each block contains 8 pixels, so the step must be used > + * only every 8 pixels. > + * > + * @fb: Framebuffer to iter on > + * @direction: Direction of the reading > + * @plane_index: Plane to get the step from Same. Best Regards, - MaĆ­ra > + */ > +static int get_step_next_block(struct drm_framebuffer *fb, enum pixel_read_direction direction, > + int plane_index) > +{ > + switch (direction) { > + case READ_LEFT_TO_RIGHT: > + return fb->format->char_per_block[plane_index]; > + case READ_RIGHT_TO_LEFT: > + return -fb->format->char_per_block[plane_index]; > + case READ_TOP_TO_BOTTOM: > + return (int)fb->pitches[plane_index]; > + case READ_BOTTOM_TO_TOP: > + return -(int)fb->pitches[plane_index]; > + } > + > + return 0; > +} > + > static void *get_packed_src_addr(const struct vkms_frame_info *frame_info, int y, > int plane_index) > { >