From patchwork Mon Feb 26 08:46:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1958913dyb; Mon, 26 Feb 2024 01:28:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW1heA7h/pQ8Kyvg4sl1CFhoyMydjjJtwNEkFg98KIiA3jBsHlqriOpbexg+gG6HZ1b01qF2WL7wU4Jk/uX8dulYygAzg== X-Google-Smtp-Source: AGHT+IEehGb5+x06DqmunW5Nl+vS45WUZABKNPt8KIpT5NB2dLSsdxieEjLBrYxjxR5DWKVeJnb0 X-Received: by 2002:a17:906:c307:b0:a43:1099:7e7b with SMTP id s7-20020a170906c30700b00a4310997e7bmr2504530ejz.54.1708939688589; Mon, 26 Feb 2024 01:28:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939688; cv=pass; d=google.com; s=arc-20160816; b=QmMWBty8VadinOC0tzXBn9Sztuo77wFZTyOfvpxmWFY1nQItR1AGtOupHkjzGfV+9E Nh1RdVGk6qfo3bxr5v5HcjABe41tppr8y+boM/5L/RFze1IhP8zM6lZPLaj6+ogHNOC+ smmUqEIRhEr0PRJmQ5VXIOJibWlqFIBik05jb7HyeosqBzP3IrgNZkm9IMWyLPPwFLjK 4+Q19NGW1vuOaW/j6iX8T4Zb2dc8WSIx6PGCMQUEzdML+nxGPslwN+NlQAdyVnCJz4oQ 9AGmVj16dHGAnsfXZJGuNhCKHluc7IXq/U7kzGyFGCNSkdy5CYAVr500LTd6zmrZ3pk9 ROPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=jauvlcf23xbsU6XgxRmSW75QVo1X7Eynq50wc19kNIg=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=dNV9/h3FfqiJnJpBqubC9Jfz7+CSaB34xDpd1eUzb4Ksr3JakORU5VWxiZqUW/ECpD epqEK4wdNjeqEJ2/GxRYrqXMoxJ7S0570P8F6hr/nCE7nDEV2i6tmBknZjM2TFsBMLki u/ZWZWRBr9ID6+SrpXBnvj/0vic0quf7ZQ8ZnOmfJEwEK9clpK0Mh5LrG82/h/1/N1BT blroqsGWUF5D5XszXvTChfRBzUj8AOCSvSGnX2Rb7oL8l227W1wLsFKwHEOoe9c/6YoY zsgHM1xj3cP7Qd/XP+DIvcw99G+sIQRtkTsruMgLvhx+0ybIr9J2tXrnWKQtPS9YrlZA oRgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PUYp7zlU; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80954-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80954-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id do21-20020a170906c11500b00a3f83e719c0si2048717ejc.563.2024.02.26.01.28.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:28:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80954-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=PUYp7zlU; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80954-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80954-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 03AAD1F225DB for ; Mon, 26 Feb 2024 09:28:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A2B45E224; Mon, 26 Feb 2024 08:48:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="PUYp7zlU" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 945885C90D for ; Mon, 26 Feb 2024 08:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937277; cv=none; b=MwgN8ISalpk2XqxEVdMn66Op1IywLXaGK4L950nGLTX/wB8E6tv1S0Ckbw04yhV9emm9FnV6tLgMS1WfqsCUHpboSUzyZKYe2caL05mOCBWt1f/EY7fEcC0VZMt76I69rddOB7M+ldjMQiCAx8ceOUj+X6Qj5jk7GFm7ImgmLdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937277; c=relaxed/simple; bh=ho5ra/+at2XzI2G+H45H5el5TvmKBhEa/PzPoOq31VQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=i40c3PgLr7KwhomIQNiF316SLlod92Jq7D2+Y571Tej4Fg4toMeje9jLSlCNeCURHgc8DZ73jYAbCwGKtpuWaUrCLzrH/r05XbdTd08DnVX+QASY+lmN21EJG8rWu55lgv1mO2iQ1n+xbemh1xOb6qtfyMVdJB0wCwLWcAUmf+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=PUYp7zlU; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 41ACAE0006; Mon, 26 Feb 2024 08:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937266; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jauvlcf23xbsU6XgxRmSW75QVo1X7Eynq50wc19kNIg=; b=PUYp7zlUPZTbE6N+tI67BbSMl+2kT/v1pekq+jT6ls4v8ufLzmRu7hvUlB5LKNz4swxqy4 yaP8u75/djkufGx2u9mR3vMreCUudmcdlysI0yXsesK/NVDLV4LhErJxUNHGEIvap9t9xr XfKnuIvb+u6HvH4xQxsoQOI+ZMSSMCaLgclyOX5ihal4XzMCwBbZ+8nfS+onp/uE8GDTKd pnvYBjJf5/ygaPL7HNgg4C2hLJz3ND6b86xXzEf7ZR9/YP8qIPujeGLFVvmR3kFnXLxlaM OYZQ2V/O7cOGQHQkt7WaDy7cmGgWQm2KZ+Xkw9aa+kSoxhPkq2UeY9aFqdC8+Q== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:31 +0100 Subject: [PATCH v3 1/9] drm/vkms: Code formatting Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-1-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5122; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=ho5ra/+at2XzI2G+H45H5el5TvmKBhEa/PzPoOq31VQ=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAte4zHYuK9KWpcrFdCuR6LLBDBCYaihh4ToMxt l9YvvjqJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLQAKCRAgrS7GWxAs4mAND/ 4s+05LVdwjC0khT96PaBh+cnib9EsdREFAJWJ5wI4DuIXYv7Zi7qPoBHeYzhM2QnSsNMa3o06vXxvG ocCR0oDkmNuwOiKTi+upM2SdDWs8HsNDooWM2+7/1GIT3t1YKW4UqLCuP9mCdHazKZL7JEPfJrLvZJ If5L2sSMWuLhTYb/6suIDZY/2oo+l7z1gtru5EFhKRvAA3myfW4iwHQAHtS55rIFgEckRQ1h7HvIos opwVxDQDCEvA0gQEUR4BI4zWzeEnAnOyJ2tRTYKNLDw+4NwHQsz31LMbKKjTfjsQ0BZIxxS7mE9/Ik JR4JSow3kYGauRC7V5sDMFHixlJ+PHFU3qguKlErH86W5/ZjbZDf4A1FM8/m7cnKy0t7fuP2Ini1zA i1mul5Xu68DepZWsL3b+k3CrjVaB/q50K0Rur2iw1xMRSRZJDeKHf7dK6PDGoqZjF4ISsLI3Mt3sTt S4TLxvYKEvFZKj2NYsCcMkzW/i7e0TWeE4YNsS8G+2p9+x3t7FDxZF/3JNVG7Hi95zhe/3GIBNMMjG LWSw/eHP/FbSDqJ2PFB47IAy6O85rS2thGKRH4Xku42mXe18PK0TESiW2GajFBgIbHlzPM2+pBxjUD Sdv1tn4l1WuuDOZUjg12MAyTL0pvQ8nIhp8PavDy0OtNR6T8Q9crnki5/lzw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791953143189263103 X-GMAIL-MSGID: 1791953143189263103 Few no-op changes to remove double spaces and fix wrong alignments. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_composer.c | 10 +++++----- drivers/gpu/drm/vkms/vkms_crtc.c | 6 ++---- drivers/gpu/drm/vkms/vkms_drv.c | 3 +-- drivers/gpu/drm/vkms/vkms_plane.c | 9 ++++----- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index e7441b227b3c..c6d9b4a65809 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -96,7 +96,7 @@ static u16 lerp_u16(u16 a, u16 b, s64 t) s64 a_fp = drm_int2fixp(a); s64 b_fp = drm_int2fixp(b); - s64 delta = drm_fixp_mul(b_fp - a_fp, t); + s64 delta = drm_fixp_mul(b_fp - a_fp, t); return drm_fixp2int(a_fp + delta); } @@ -302,8 +302,8 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb, void vkms_composer_worker(struct work_struct *work) { struct vkms_crtc_state *crtc_state = container_of(work, - struct vkms_crtc_state, - composer_work); + struct vkms_crtc_state, + composer_work); struct drm_crtc *crtc = crtc_state->base.crtc; struct vkms_writeback_job *active_wb = crtc_state->active_writeback; struct vkms_output *out = drm_crtc_to_vkms_output(crtc); @@ -328,7 +328,7 @@ void vkms_composer_worker(struct work_struct *work) crtc_state->gamma_lut.base = (struct drm_color_lut *)crtc->state->gamma_lut->data; crtc_state->gamma_lut.lut_length = crtc->state->gamma_lut->length / sizeof(struct drm_color_lut); - max_lut_index_fp = drm_int2fixp(crtc_state->gamma_lut.lut_length - 1); + max_lut_index_fp = drm_int2fixp(crtc_state->gamma_lut.lut_length - 1); crtc_state->gamma_lut.channel_value2index_ratio = drm_fixp_div(max_lut_index_fp, u16_max_fp); @@ -367,7 +367,7 @@ void vkms_composer_worker(struct work_struct *work) drm_crtc_add_crc_entry(crtc, true, frame_start++, &crc32); } -static const char * const pipe_crc_sources[] = {"auto"}; +static const char *const pipe_crc_sources[] = { "auto" }; const char *const *vkms_get_crc_sources(struct drm_crtc *crtc, size_t *count) diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c index 61e500b8c9da..7586ae2e1dd3 100644 --- a/drivers/gpu/drm/vkms/vkms_crtc.c +++ b/drivers/gpu/drm/vkms/vkms_crtc.c @@ -191,8 +191,7 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc, return ret; drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) { - plane_state = drm_atomic_get_existing_plane_state(crtc_state->state, - plane); + plane_state = drm_atomic_get_existing_plane_state(crtc_state->state, plane); WARN_ON(!plane_state); if (!plane_state->visible) @@ -208,8 +207,7 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc, i = 0; drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) { - plane_state = drm_atomic_get_existing_plane_state(crtc_state->state, - plane); + plane_state = drm_atomic_get_existing_plane_state(crtc_state->state, plane); if (!plane_state->visible) continue; diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index dd0af086e7fa..83e6c9b9ff46 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -81,8 +81,7 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) drm_atomic_helper_wait_for_flip_done(dev, old_state); for_each_old_crtc_in_state(old_state, crtc, old_crtc_state, i) { - struct vkms_crtc_state *vkms_state = - to_vkms_crtc_state(old_crtc_state); + struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(old_crtc_state); flush_work(&vkms_state->composer_work); } diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index e5c625ab8e3e..90c09046e0af 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -112,15 +112,14 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, frame_info = vkms_plane_state->frame_info; memcpy(&frame_info->src, &new_state->src, sizeof(struct drm_rect)); memcpy(&frame_info->dst, &new_state->dst, sizeof(struct drm_rect)); - memcpy(&frame_info->rotated, &new_state->dst, sizeof(struct drm_rect)); 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_270 | - DRM_MODE_REFLECT_X | - DRM_MODE_REFLECT_Y); + DRM_MODE_ROTATE_90 | + DRM_MODE_ROTATE_270 | + DRM_MODE_REFLECT_X | + DRM_MODE_REFLECT_Y); drm_rect_rotate(&frame_info->rotated, drm_rect_width(&frame_info->rotated), drm_rect_height(&frame_info->rotated), frame_info->rotation); From patchwork Mon Feb 26 08:46:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1958854dyb; Mon, 26 Feb 2024 01:28:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVpxo591nq88lbMzCqo/yLuxxccVkdfXSuNT787Xjm5odESDiL0I4r1ebgpaDHpefWJJ6BD+nb+dS0W3490VbYEmvjqew== X-Google-Smtp-Source: AGHT+IGNnumXffWJ0r5ZZyGyJ2fwp1q1px45dbH81YEP8YUXny9nFfHLoPygrIW1TV5u1fV4Ooyt X-Received: by 2002:a17:906:b7ce:b0:a3e:5ffa:d564 with SMTP id fy14-20020a170906b7ce00b00a3e5ffad564mr4083732ejb.8.1708939681941; Mon, 26 Feb 2024 01:28:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939681; cv=pass; d=google.com; s=arc-20160816; b=Vibfxf4EDyHjw8Yy8Mvg0S0bvPDinkdRDQ+wcPkgoFmfY3VnvkBynB7GApICq/2g29 +ue4LmYZA2jEB8vttYV5o96gK3LPWaDByh2k4ISMTt5ECHPaSx72zd22yH8wA5rMUDbW hM9SsvaZeZn9WSLjfZSfI22qEV/PRdv3I6akFoGkLGsPwqH6gUY0scvadZl+asO8Ecsn tBxilEFSQ2B56MiVgIl1vsW8BIu3W5mfJ8sNrtiOOv1fHy9NLJtU2O7CeybuW2roGcvU 3E5ZcWQ/M21hFYGnWYWwGbFhAVr1/DcMNh2Tzm4je7cilLFIsuPNrmcVMghSKsYHoCVt PjwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=H9vIAXwIOUIWcL2JXzqSsbjPwFVUBmSDwO7BEh2dBj4=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=z6O2Qhhyps29q44mdPYZ2BsYkeRCPnho7GdodT37EuwHnpoWsRYdG7UFUClNwrK29p eRMP0h+ZwWiJEjRBuWK9znjJIM3URPj3zWm35T++X9G5rjXyk+G2QaiK4n3z/5s0WLdv M3hRkaV9d8+NQ7G99QsAP368u/XM5S7i7qxAviD3Qq84dLsRxx5F//KqHKU50Qx9yZfm zUrTg3JuBNqMzUc5PAxWcTpLcDZJUj1n7u7v8qnBmWY4SqmmRgyG1wm5gS6TK1f+rcnS Fh9u6/7w6T0s4/jmsKEBPQuBr4mrWu9FtWQ58rTO+S/V+IjsCjpJRiKp8+f8pffpc22i R8+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=nN8TuUL6; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80952-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80952-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e11-20020a056402190b00b005660bf51f90si334327edz.508.2024.02.26.01.28.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:28:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80952-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=nN8TuUL6; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80952-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80952-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6185F1F2299C for ; Mon, 26 Feb 2024 09:28:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6F9B5DF30; Mon, 26 Feb 2024 08:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="nN8TuUL6" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 9F2F55B053 for ; Mon, 26 Feb 2024 08:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937276; cv=none; b=WbLpsWMKLZ0zSx5dnAWx9BWD+sShtZz4BtlOdWXcmAFT80GLm+vq0knXzwMbnzc+mpDcPNNtNTHqDUeR/HVQBx7S5WnOVmgahp0XzPDjHTfHw+eO9nkn5VgpXSJxJAqFND5QJX4NyAPcx1+QGC8L5Fm8qwROLTIZNx7M9oOQAsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937276; c=relaxed/simple; bh=52wWLXv52UxCcak1ee9ZxfQFyR67YA1n+FDOTYunbls=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DE8nMayZ6sTGUvtNvmkUbxHYi0YwBHfZNUdr1Xn3Faddyinr6UiIAGjlUAB64Tpu3hvdDCrm1FrqtWZzvdPeufBlUSkTlPiHEVmO66YzMqNuw9e3uYL+Wccrc2ZBxPCcx0yAzsQ9iHlQ2rSCNeRd64kE4cxqPUBTdQ9ryaibxno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=nN8TuUL6; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 77F77E0009; Mon, 26 Feb 2024 08:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H9vIAXwIOUIWcL2JXzqSsbjPwFVUBmSDwO7BEh2dBj4=; b=nN8TuUL6adz42hygbOVFWa4jgP7KBBogIYXA6S4gttnyqR8f1KSl2+QF9GZq0FlNLk7+N/ BmgWf0eBzwlbGm5NAuBfmETP5jFUvCTkR53QXAzoLXXwFMtIf/QtURKrUMeVOVB7x/yvUI v3hJ0xNMR9grs/13q4p01e4in7bD9FwCv/zVYNh7sX8GknqQP8BEovTZSWR9s5JNZJMGwe m3/rrKXkd/mkOWttOjNrfOc1liuqynTenGCw1zrm32Kulzx+NNPbFita9oPVKgywhcmsYx tT1mQc+pOZMkAxV90zug2UxjzhLyxTg+FAwQ3SnlLHhBKlSu99G/g3gZEfZA+A== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:32 +0100 Subject: [PATCH v3 2/9] drm/vkms: Use drm_frame directly Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-2-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4080; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=LCanIMOHanyMsqevo6fpwtNwvVAT/mqVTUFuxMtxwSE=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAtuiQ6jRmzYIPsTeKSZE8illNBYsEnwQ+gUreK zWIHgHaJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLQAKCRAgrS7GWxAs4u60EA CUaP/X34+cahIVRsIhdYkZI45wEqbIjim8CgMJfqBKAMArEQboSF06LAZgy2bnZqYIGMnaipJWPe6W hWtOXzCXalmQCpW3S5P9c+/5AraMUs743wICTWerTIfkiPelYBCIYMEUGCltJSuEcVjjcHfJ//wXqG dkVJS3l5S1iijWk8nOTaGxWAc2sMe7cDRSYtt+rrbKul0B0hAiNCUvxiEjbXinuVPOaiYR0+VMiU9s 3GXuAQwq69j54ABCgN5qDEtH/oyZVABLwaiQQClnXinqIsfmtTkVl89lKsRrX0ZWyPXPCG9rPbOy6+ g9ynWpzXtAsN8WdkcuCO2QLYcTYLXxQBYNEF0PQLRw6QrFhfdd/LJSBcCN/bLTAsgpwIjJsriwNcXL dvTlfkohhcPpUHKzr96+4Ebsm72lUZAsXl39sZEDOEciDyQR/SuJRWaxLzyPEcWWtGfVuvOEW21jtL 6g95Zd/fgOtiTS+sC+OBEo2PIQpq72olLG1fl1qDL52SCEbb0fTLv55F9V5hSaj9rq1ogBGJlI/eOW DbafjTZRa1Szk9H67gB3LUn/PB/JtGYP+r1rPlfVlczD3Rf0IPOSLobUa3CbgK/rf0/j0XGp4SNFN1 0Q3BJSFX7rcDUv8mzQXRO6Ot7Y54G/O4JaVyk9ypWP/VfLmmMb3kCLke7q9A== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791953135872317034 X-GMAIL-MSGID: 1791953135872317034 From: Arthur Grillo Remove intermidiary variables and access the variables directly from drm_frame. These changes should be noop. Signed-off-by: Arthur Grillo Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 3 --- drivers/gpu/drm/vkms/vkms_formats.c | 12 +++++++----- drivers/gpu/drm/vkms/vkms_plane.c | 3 --- drivers/gpu/drm/vkms/vkms_writeback.c | 5 ----- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 8f5710debb1e..b4b357447292 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -31,9 +31,6 @@ struct vkms_frame_info { struct drm_rect rotated; struct iosys_map map[DRM_FORMAT_MAX_PLANES]; unsigned int rotation; - unsigned int offset; - unsigned int pitch; - unsigned int cpp; }; struct pixel_argb_u16 { diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 36046b12f296..172830a3936a 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -11,8 +11,10 @@ static size_t pixel_offset(const struct vkms_frame_info *frame_info, int x, int y) { - return frame_info->offset + (y * frame_info->pitch) - + (x * frame_info->cpp); + struct drm_framebuffer *fb = frame_info->fb; + + return fb->offsets[0] + (y * fb->pitches[0]) + + (x * fb->format->cpp[0]); } /* @@ -131,12 +133,12 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state u8 *src_pixels = get_packed_src_addr(frame_info, y); int limit = min_t(size_t, drm_rect_width(&frame_info->dst), stage_buffer->n_pixels); - for (size_t x = 0; x < limit; x++, src_pixels += frame_info->cpp) { + for (size_t x = 0; x < limit; x++, src_pixels += frame_info->fb->format->cpp[0]) { int x_pos = get_x_position(frame_info, limit, x); if (drm_rotation_90_or_270(frame_info->rotation)) src_pixels = get_packed_src_addr(frame_info, x + frame_info->rotated.y1) - + frame_info->cpp * y; + + frame_info->fb->format->cpp[0] * y; plane->pixel_read(src_pixels, &out_pixels[x_pos]); } @@ -223,7 +225,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, struct pixel_argb_u16 *in_pixels = src_buffer->pixels; int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), src_buffer->n_pixels); - for (size_t x = 0; x < x_limit; x++, dst_pixels += frame_info->cpp) + for (size_t x = 0; x < x_limit; x++, dst_pixels += frame_info->fb->format->cpp[0]) wb->pixel_write(dst_pixels, &in_pixels[x]); } diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 90c09046e0af..d5203f531d96 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -124,9 +124,6 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, drm_rect_rotate(&frame_info->rotated, drm_rect_width(&frame_info->rotated), drm_rect_height(&frame_info->rotated), frame_info->rotation); - frame_info->offset = fb->offsets[0]; - frame_info->pitch = fb->pitches[0]; - frame_info->cpp = fb->format->cpp[0]; vkms_plane_state->pixel_read = get_pixel_conversion_function(fmt); } diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index bc724cbd5e3a..c8582df1f739 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -149,11 +149,6 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, crtc_state->active_writeback = active_wb; crtc_state->wb_pending = true; spin_unlock_irq(&output->composer_lock); - - wb_frame_info->offset = fb->offsets[0]; - wb_frame_info->pitch = fb->pitches[0]; - wb_frame_info->cpp = fb->format->cpp[0]; - drm_writeback_queue_job(wb_conn, connector_state); active_wb->pixel_write = get_pixel_write_function(wb_format); drm_rect_init(&wb_frame_info->src, 0, 0, crtc_width, crtc_height); From patchwork Mon Feb 26 08:46:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1959085dyb; Mon, 26 Feb 2024 01:28:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQIhUTilsqJzC1CW+ItxjycgapaS6bRNCvX0evcPTF4wyNSHcG3LgYBbKpufX7MkKe6o92W71VfhDeA/uhz6zcOmQk0w== X-Google-Smtp-Source: AGHT+IE/vNGvNkGqc4UC3qdeglgg3N00z4CAjJFxwsRtuj4kQGw8zE1zTkqq6uK+In0TDPYpSqGg X-Received: by 2002:a17:906:dfe9:b0:a3e:590f:6348 with SMTP id lc9-20020a170906dfe900b00a3e590f6348mr4501444ejc.41.1708939716588; Mon, 26 Feb 2024 01:28:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939716; cv=pass; d=google.com; s=arc-20160816; b=mfmVo/IGIitnnvCIPUz6kKLcg/AkzTlPGW6QM6dNxsARwDGB4gBXhvPiimtY45NBPo ZjNc+2M80V8JUsOVW3RouO62c06YLsLcppdSPcNvrSvZkSFfXyFAS6vsI4YnCbFmNo31 pjrGoGy4SAO3DgamV4+aMKhLUS2f0U/9Ilv8mfLB9tJnQSNDOomexsto4j0zucFkkueH FDg1+53J14QMLkAAmvwMTqvhJweyc3Ad60u03RAMlDZJLcixVXx9/7KCd59KqAlue71R QDOYymPhd4mal5ZAh7fP4Qthwzqvcw/KpUf+XcL4UkIA/nfJNnWUN/ZfyJUSl0Sx98NI GYGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=U5UinReH6vUXNxBJ97EG+ZqktERoBQAcu/k8mtlmiaY=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=Rh9UHPC6+kQx9xGBmjZwRK9LVx3Zha7zHe9ICwTjM6BXcbFBT8gLgVv8E+qvHDlr3T 50s4FgQjUwxE29l/VruE3oyWPYiiZoNtosTf6WGnMpBDiRtzuWo/nBAOEdku+ZMoMcll 0SO0Rwo8LpTbsS9Odpjs8hzSO83T02N+EjnKrLfjOA7NRUhssoESk6r8ji3yG5KV7+Y3 +0CiMA2cVnULLE2Hd7YgE3/TaCydhqHI1jdWx3B9MYTJQspaSKEwbrGwROKH2t8pWE5P VUZTCA59P8UUnhcHE/3X96qrL6VvKeqTUIk3lFq9yLqjVfsJFVMtM/IRoskxYMhDrgeb 5eow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XrP9z8jx; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80956-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80956-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c17-20020a17090603d100b00a3e5de68f28si1939822eja.855.2024.02.26.01.28.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:28:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80956-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XrP9z8jx; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80956-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80956-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0762E1F21A7F for ; Mon, 26 Feb 2024 09:28:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 365425F46B; Mon, 26 Feb 2024 08:48:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="XrP9z8jx" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 632A75D464 for ; Mon, 26 Feb 2024 08:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937278; cv=none; b=YYBOoQtVR7e6n9qoyEqvU4JoOkRwMARnOtB7rlfMlIfxldsJpGqaKUEWIBXXFUyKjwMsnJc6MRwwdKbjvG/qK00cPmcnk+yQpDDmY+44pC5BczmdaM9y4TI05AwEpQtkMsoSe+y//nhmgv95twjKQQxmNgh2Ty8/yst+2SZptNk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937278; c=relaxed/simple; bh=+DsmO8SGjkaXdS5jYLEBNm7wDQTKeBuOh6cIQzNvHU8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ay1N+EiVJIE3gM4/NyHuWy875Mo61+6ISEf0W2CqlwefBkFFRL+UYMjXlygD/J6rY1ec9qa7easKqjAz6jsLvPcN92D1qvF80mcESntNJn3b3fpVmtSab6OlDa0klhKwT6MHQve74Lu1YFnkO6Yee2YS23bvev05gSYPIKFZGu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=XrP9z8jx; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 983CEE0005; Mon, 26 Feb 2024 08:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937268; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U5UinReH6vUXNxBJ97EG+ZqktERoBQAcu/k8mtlmiaY=; b=XrP9z8jxMI5xCnX8l+KmyX/OJHsT/QmOU1KSAK+/DiaCAEyrVNuShux4U9dRUB54aVXAP7 l+qtq7YRMZgS8LUJE+fwPiKyLRahcb33HpqHFvVFTcjuCtYikwmrYQWThab2/VWNhvBDdf 7oqUxYO03+mnag3bgcCnQDfGbSsRu9hzfvY8AWVbAureTm8PuQRb2bQEeJZJUDgmykTNk3 J1EpKhc9k08onD+9a4CC/aH6zhrtY/EayYnDXwL0MKR9PRAzE+aeJPIQrcet7l119OMd13 DAW8v0ZM0+gsuby5I1kw602HA1YcXpqATY5I/zvR04Wxv3nwtr1RnbJNPP/xCQ== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:33 +0100 Subject: [PATCH v3 3/9] drm/vkms: write/update the documentation for pixel conversion and pixel write functions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-3-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6432; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=+DsmO8SGjkaXdS5jYLEBNm7wDQTKeBuOh6cIQzNvHU8=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAtv6lG5Spu+Fvdk7/o9Z0JtjYZu9Zbw5ykTQz0 4KgnyCmJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLQAKCRAgrS7GWxAs4lHMEA CTqOSIvqzWg5SOoLw9sntXeUH/2RgSp5S7nC3yjRZwTmKFiYwQuFeBqvHeF3s8Ox7W/wA8g2SIdyD8 LsciJq5x4mM2X7R6cbBw2z+C1SUlvBkmlNsNSsGTJiUGtcr1kc67uOa9MUdgUmA5VhaM+ArJpn6rGm cp5NYVDbNwGly5AmjhCdc5Xk/eGWs5SEp5GzA/6e4xcfc+/rRuj2kUZxnjhI+iRJp75UGWOaMBJvr3 Yj1HyvriKQEYXrhVur/OnfTg33SnQa1JsQYzJ0ZFvGLznh0y9tcOm2rZSgm2hrCIiBchWxMLZGlosh fOZLNevfHm/+Mt3BjqYgCE3gR5dyFK+eAwCdt5kAlsXIbez4HYg+FkAFRF6gkBGhwvZBoElT6wTgIO K/KojwFD80ueszTcsrjO6NiqRnXkEYmggk34KiSMnKoJOBy3FBVCPUEgA3fnNIcLb8xCebFSkT+Gaz Lr6p7Hor6TaFf/NnVfNLbU42PZ8qh3u3C98xHjczi3zS8o8irXPPem3MBJ3jAcCxryYVMocWd9KWut IS4ieNPzs8xqCohPwI1DsWfrgMLP+dB8zyUoRltaVNfk6ck/epwBPD6dIwRq+C0kxhPLR/dsrDa/mx uOLb1eK2orxzDdvG9EBOTIEYSD0sg6PLo/KwCo+kIGIclzva83HZtfekC9Gw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791953171870826537 X-GMAIL-MSGID: 1791953171870826537 Add some documentation on pixel conversion functions. Update of outdated comments for pixel_write functions. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_composer.c | 4 +++ drivers/gpu/drm/vkms/vkms_drv.h | 13 ++++++++ drivers/gpu/drm/vkms/vkms_formats.c | 58 ++++++++++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index c6d9b4a65809..5b341222d239 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -189,6 +189,10 @@ static void blend(struct vkms_writeback_job *wb, size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay; + /* + * The planes are composed line-by-line. It is a necessary complexity to avoid poor + * blending performance. + */ for (size_t y = 0; y < crtc_y_limit; y++) { fill_background(&background_color, output_buffer); diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index b4b357447292..18086423a3a7 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -25,6 +25,17 @@ #define VKMS_LUT_SIZE 256 +/** + * struct vkms_frame_info - structure to store the state of a frame + * + * @fb: backing drm framebuffer + * @src: source rectangle of this frame in the source framebuffer + * @dst: destination rectangle in the crtc buffer + * @map: see drm_shadow_plane_state@data + * @rotation: rotation applied to the source. + * + * @src and @dst should have the same size modulo the rotation. + */ struct vkms_frame_info { struct drm_framebuffer *fb; struct drm_rect src, dst; @@ -52,6 +63,8 @@ struct vkms_writeback_job { * vkms_plane_state - Driver specific plane state * @base: base plane state * @frame_info: data required for composing computation + * @pixel_read: function to read a pixel in this plane. The creator of a vkms_plane_state must + * ensure that this pointer is valid */ struct vkms_plane_state { struct drm_shadow_plane_state base; diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 172830a3936a..cb7a49b7c8e7 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -9,6 +9,17 @@ #include "vkms_formats.h" +/** + * packed_pixels_offset() - Get the offset of the block containing the pixel at coordinates x/y + * in the first plane + * + * @frame_info: Buffer metadata + * @x: The x coordinate of the wanted pixel in the buffer + * @y: The y coordinate of the wanted pixel in the buffer + * + * The caller must be aware that this offset is not always a pointer to a pixel. If individual + * pixel values are needed, they have to be extracted from the resulting block. + */ static size_t pixel_offset(const struct vkms_frame_info *frame_info, int x, int y) { struct drm_framebuffer *fb = frame_info->fb; @@ -17,12 +28,13 @@ static size_t pixel_offset(const struct vkms_frame_info *frame_info, int x, int + (x * fb->format->cpp[0]); } -/* - * packed_pixels_addr - Get the pointer to pixel of a given pair of coordinates +/** + * packed_pixels_addr() - Get the pointer to the block containing the pixel at the given + * coordinates * * @frame_info: Buffer metadata - * @x: The x(width) coordinate of the 2D buffer - * @y: The y(Heigth) coordinate of the 2D buffer + * @x: The x(width) coordinate inside the plane + * @y: The y(height) coordinate inside the plane * * Takes the information stored in the frame_info, a pair of coordinates, and * returns the address of the first color channel. @@ -53,6 +65,13 @@ static int get_x_position(const struct vkms_frame_info *frame_info, int limit, i return x; } +/* + * The following functions take pixel data from the buffer and convert them to the format + * ARGB16161616 in out_pixel. + * + * They are used in the `vkms_compose_row` function to handle multiple formats. + */ + static void ARGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) { /* @@ -145,12 +164,11 @@ void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state } /* - * The following functions take an line of argb_u16 pixels from the - * src_buffer, convert them to a specific format, and store them in the - * destination. + * The following functions take one argb_u16 pixel and convert it to a specific format. The + * result is stored in @dst_pixels. * - * They are used in the `compose_active_planes` to convert and store a line - * from the src_buffer to the writeback buffer. + * They are used in the `vkms_writeback_row` to convert and store a pixel from the src_buffer to + * the writeback buffer. */ static void argb_u16_to_ARGB8888(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) { @@ -216,6 +234,14 @@ static void argb_u16_to_RGB565(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel) *pixels = cpu_to_le16(r << 11 | g << 5 | b); } +/** + * Generic loop for all supported writeback format. It is executed just after the blending to + * write a line in the writeback buffer. + * + * @wb: Job where to insert the final image + * @src_buffer: Line to write + * @y: Row to write in the writeback buffer + */ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer *src_buffer, int y) { @@ -229,6 +255,13 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, wb->pixel_write(dst_pixels, &in_pixels[x]); } +/** + * Retrieve the correct read_pixel function for a specific format. + * The returned pointer is NULL for unsupported pixel formats. The caller must ensure that the + * pointer is valid before using it in a vkms_plane_state. + * + * @format: 4cc of the format + */ void *get_pixel_conversion_function(u32 format) { switch (format) { @@ -247,6 +280,13 @@ void *get_pixel_conversion_function(u32 format) } } +/** + * Retrieve the correct write_pixel function for a specific format. + * The returned pointer is NULL for unsupported pixel formats. The caller must ensure that the + * pointer is valid before using it in a vkms_writeback_job. + * + * @format: 4cc of the format + */ void *get_pixel_write_function(u32 format) { switch (format) { From patchwork Mon Feb 26 08:46:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1959140dyb; Mon, 26 Feb 2024 01:28:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUIZXk5llW7Fp6lmUUa+X+lAtSChKjhnGhljleDVEy2/C2GDwSQ4EQCAAbeT7llW40+P8XjAkgkpvsHfGg/8M8XJuJCZA== X-Google-Smtp-Source: AGHT+IGd2jG2/GWnPhKkFSX5xEnU3wefpGCrLWHrdQfZfMGEMs7h3lmAvredzSUpFRTbM7z0qFOo X-Received: by 2002:a05:6a00:14c8:b0:6e5:1320:f44 with SMTP id w8-20020a056a0014c800b006e513200f44mr3642799pfu.14.1708939726806; Mon, 26 Feb 2024 01:28:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939726; cv=pass; d=google.com; s=arc-20160816; b=wssJMKCWDiX6OqVuSZy3rTLfj82xUTPa8kNjbkzRaNQDb72gXPN0mjbogDJFMkd9zK bHpEz3TtCuhvp4l2IYgFMTvgnwNBbA1NXpANPpWYmdn3WmLWd4fUVQRi2ayIE+sW9Beu KaqXSNqc1EO+hPl6lZDTwVIT85lUCeiKiD8ALjjp/wk9r3FRf+i8PZ7xCFTLr0CSxIWK lN38AeD5+h7L701rpZA4YDjyO/nI+mnMBK+3G+u+aQUN9HEvk1RbIvI/9ECssD3JHukt Uum3h/FBNkGnR6M0EkWlwRIqoA6iKbiUN9IogWYTRhSyqRnpsRhm1afuc/pGm0Xktxe0 Xv9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=FNrV5eCxkdETUulcpe7tOcXgNVakjWdt073qLmEHzKs=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=Ex8w26a/TmafkkT6Ljw72GFAUqzYnJXDuC5E45REChCxR8VHtO2YofVtVAvuJk1knJ VwmuYN5GDnH5AFAM4RpbZPkF7urMOaLzbyPnxbyCl3iPNsLuGFHpWF0j1psGLq+EPuY7 t/7oKmkQzwtjcsQhAZMA16MOEJ7byxZ0XCS0TA9mytcvmrlwJzzRBi9YoG5iofzTQSZL dnYVJaeElve/V1bt3b2HIRxLZYvsUj6U5hIz23+JDO5Qsz64qz/utIjB00pZb68AEJTC BmrQ5tPkclooNic2ER9qXuEQSoqlP5ojgDG6MrWpdXYQt9SqXGwiOaIGeyoTxbQwkAcP EQdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=nnsvRHFM; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80957-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bw39-20020a056a0204a700b005dc85a7eb1dsi3495705pgb.299.2024.02.26.01.28.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:28:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80957-ouuuleilei=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=pass header.i=@bootlin.com header.s=gm1 header.b=nnsvRHFM; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80957-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 95A612841E3 for ; Mon, 26 Feb 2024 09:28:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8411A5F497; Mon, 26 Feb 2024 08:48:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="nnsvRHFM" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 5D5F55D720 for ; Mon, 26 Feb 2024 08:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937279; cv=none; b=NIWbPGWw5q2QQLxILb9GzFfGLUd89LTztwpFwWacE8Pp4tskqncyV/U3uOqviz2EkBaErs82McF0Lpqt9LgESc4NUxVKsM6BANBb8cQSsYqY1DvwvKWAXKciE+XMsk23hPFFAhZ+4ISXbZGX8heqFRUz9/daWZH77ajVoIedzhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937279; c=relaxed/simple; bh=D4TC7GfNKrDRx6FBTflEjIvY9r2R7Bzpo66QJhUPBxk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OiGCq9klhGCLSQtkSEIKwiLB0pnAhBtKaJ3umStUcHYL6VEpCyG994LgGFgsxpMpthrsVOWdlhIsgd0DC4oFJD3hfnGUs/Ahq2375S5PY0YP/QhPvmk4sNYkuaUS+5o+8d6jWAOhWrhUtXsFWdUoJLHmtn3L4CoPwDtypEw8hPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=nnsvRHFM; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id C7DCDE000E; Mon, 26 Feb 2024 08:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937269; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FNrV5eCxkdETUulcpe7tOcXgNVakjWdt073qLmEHzKs=; b=nnsvRHFMgEKRJoZyGAbi+AKZse9xv51B33lc1Z0J4zvaO782RYKUS7BMZifQk7d3TGKMwL iXTWxUeZHwROSFL1Vgi31G9A4MqX3u9VhyymSETq79LCPahB3fNOqoidt/QZIApbvtxdbI YLSmKNFHYTMDAe362bYGI3jT1KVIqncuKl9qdl9POP0L38Pv+q1KTZMivR8KI8vVTI18o8 Fw3NvWkdVv8AahYNsMpOiyOsDzns8hcB5VDXzZsbE4JZ+iRs5gV0VmuFvwY2HW+HbcCCuT iIC8jxf1ONbYURLK9JQy429ZFPneQeHAtBLKcSkXh8rrLKsa8xdhEbDAzza4vg== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:34 +0100 Subject: [PATCH v3 4/9] drm/vkms: Add typedef and documentation for pixel_read and pixel_write functions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-4-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6217; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=D4TC7GfNKrDRx6FBTflEjIvY9r2R7Bzpo66QJhUPBxk=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAuDkmkYvQPapjBzISBGHDQL2Jvr3QU1BL6VsCW Zw58MYqJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLgAKCRAgrS7GWxAs4gflD/ 94FqaSHUckFIQxcpQWwMc103UBvVqGmWjfAwMClvrGQjNN+AHPCdAcjl29zng0i73vvTLT72wjxsul vLcPgPgsIPsaLG5+2LGDeaBSWsU8knlzYAj/SQ4faimx1i3+EvhCSM0in2herV+j7nb9V0jpv6JfLJ fLQ/fuzbYSt5nRDvLOs6VFXrXFHbVg3jNSLcLiWnM21gkT1r+ykQFtpYvaMnRfUZjmo0NAYSToxeEr qvVS44T/FnMoBNDiqKc7dWo3HUj073HK2XwbXpiLNLm4U91mdT/qwtuuISeFInI6U7mBJDQzjuyGRi ++MIFuvtj6LfMeYCKXIA4NGFFX+o9rMaxKt3qupag7Rp/QI0poiwdbUzwkZv+tLKL0zPrS/7e7ahe/ 3QNHGhVMgMvOgHPO64YNzt22Fv3O+6biwFx7EHH/kFNeeRN3FZhotVpqj9nVcuuqGNfICbJknWvSL8 mutkG+beH4TiSCR/XDw4anoNi+MENO6S7EJZ8xjTDiqIo/uGyxY2+OMbeCjS4B6iAtKmmvvZ8idCJf b1dp/zzxZrV+Dhhs6AUwXpIFQe7bWaERBQJdY6TS/JeRKdxUn527LkDcQIddpssN+3EMH6vetvV0zC bkEVviHKwB1qh/k532LrfHAYLZA0zo0KaHxwdqyOeYIipxkT87TL7wz3v1mg== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791953182635090893 X-GMAIL-MSGID: 1791953182635090893 Introduce two typedefs: pixel_read_t and pixel_write_t. It allows the compiler to check if the passed functions take the correct arguments. Such typedefs will help ensuring consistency across the code base in case of update of these prototypes. Introduce a check around the get_pixel_*_functions to avoid using a nullptr as a function. Document for those typedefs. Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_drv.h | 23 +++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_formats.c | 8 ++++---- drivers/gpu/drm/vkms/vkms_formats.h | 4 ++-- drivers/gpu/drm/vkms/vkms_plane.c | 9 ++++++++- drivers/gpu/drm/vkms/vkms_writeback.c | 9 ++++++++- 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 18086423a3a7..886c885c8cf5 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -53,12 +53,31 @@ struct line_buffer { struct pixel_argb_u16 *pixels; }; +/** + * typedef pixel_write_t - These functions are used to read a pixel from a + * `struct pixel_argb_u16*`, convert it in a specific format and write it in the @dst_pixels + * buffer. + * + * @dst_pixel: destination address to write the pixel + * @in_pixel: pixel to write + */ +typedef void (*pixel_write_t)(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel); + struct vkms_writeback_job { struct iosys_map data[DRM_FORMAT_MAX_PLANES]; struct vkms_frame_info wb_frame_info; - void (*pixel_write)(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel); + pixel_write_t pixel_write; }; +/** + * 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. + * + * @src_pixels: Pointer to the pixel to read + * @out_pixel: Pointer to write the converted pixel + */ +typedef void (*pixel_read_t)(u8 *src_pixels, struct pixel_argb_u16 *out_pixel); + /** * vkms_plane_state - Driver specific plane state * @base: base plane state @@ -69,7 +88,7 @@ struct vkms_writeback_job { struct vkms_plane_state { struct drm_shadow_plane_state base; struct vkms_frame_info *frame_info; - void (*pixel_read)(u8 *src_buffer, struct pixel_argb_u16 *out_pixel); + pixel_read_t pixel_read; }; struct vkms_plane { diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index cb7a49b7c8e7..1f5aeba57ad6 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -262,7 +262,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, * * @format: 4cc of the format */ -void *get_pixel_conversion_function(u32 format) +pixel_read_t get_pixel_read_function(u32 format) { switch (format) { case DRM_FORMAT_ARGB8888: @@ -276,7 +276,7 @@ void *get_pixel_conversion_function(u32 format) case DRM_FORMAT_RGB565: return &RGB565_to_argb_u16; default: - return NULL; + return (pixel_read_t)NULL; } } @@ -287,7 +287,7 @@ void *get_pixel_conversion_function(u32 format) * * @format: 4cc of the format */ -void *get_pixel_write_function(u32 format) +pixel_write_t get_pixel_write_function(u32 format) { switch (format) { case DRM_FORMAT_ARGB8888: @@ -301,6 +301,6 @@ void *get_pixel_write_function(u32 format) case DRM_FORMAT_RGB565: return &argb_u16_to_RGB565; default: - return NULL; + return (pixel_write_t)NULL; } } diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index cf59c2ed8e9a..3ecea4563254 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -5,8 +5,8 @@ #include "vkms_drv.h" -void *get_pixel_conversion_function(u32 format); +pixel_read_t get_pixel_read_function(u32 format); -void *get_pixel_write_function(u32 format); +pixel_write_t get_pixel_write_function(u32 format); #endif /* _VKMS_FORMATS_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index d5203f531d96..f68b1b03d632 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -106,6 +106,13 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, return; fmt = fb->format->format; + pixel_read_t pixel_read = get_pixel_read_function(fmt); + + if (!pixel_read) { + DRM_WARN("Pixel format is not supported by VKMS planes. State is inchanged\n"); + return; + } + vkms_plane_state = to_vkms_plane_state(new_state); shadow_plane_state = &vkms_plane_state->base; @@ -124,7 +131,7 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, drm_rect_rotate(&frame_info->rotated, drm_rect_width(&frame_info->rotated), drm_rect_height(&frame_info->rotated), frame_info->rotation); - vkms_plane_state->pixel_read = get_pixel_conversion_function(fmt); + vkms_plane_state->pixel_read = pixel_read; } static int vkms_plane_atomic_check(struct drm_plane *plane, diff --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index c8582df1f739..c92b9f06c4a4 100644 --- a/drivers/gpu/drm/vkms/vkms_writeback.c +++ b/drivers/gpu/drm/vkms/vkms_writeback.c @@ -140,6 +140,13 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, if (!conn_state) return; + pixel_write_t pixel_write = get_pixel_write_function(wb_format); + + if (!pixel_write) { + DRM_WARN("Pixel format is not supported by VKMS writeback. State is inchanged\n"); + return; + } + vkms_set_composer(&vkmsdev->output, true); active_wb = conn_state->writeback_job->priv; @@ -150,7 +157,7 @@ static void vkms_wb_atomic_commit(struct drm_connector *conn, crtc_state->wb_pending = true; spin_unlock_irq(&output->composer_lock); drm_writeback_queue_job(wb_conn, connector_state); - active_wb->pixel_write = get_pixel_write_function(wb_format); + active_wb->pixel_write = pixel_write; drm_rect_init(&wb_frame_info->src, 0, 0, crtc_width, crtc_height); drm_rect_init(&wb_frame_info->dst, 0, 0, crtc_width, crtc_height); } From patchwork Mon Feb 26 08:46:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1966760dyb; Mon, 26 Feb 2024 01:50:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVA/Othy68AlvG1aoFhw7l7d1FTCCZ0Q53z6ssLZUCtAzy5pMSFkJnW6nM4zXU8g6UndnW5nNRORafXa5kV/bCdpvM8dw== X-Google-Smtp-Source: AGHT+IGnCe2iD61kdJCLiT92wg2tRqYZjtuks+z5q8HoJJvG6SRR2Q00k5x2ESU1nOhwwu4/VZpy X-Received: by 2002:a17:902:cccd:b0:1dc:affe:692c with SMTP id z13-20020a170902cccd00b001dcaffe692cmr475071ple.29.1708941058479; Mon, 26 Feb 2024 01:50:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708941058; cv=pass; d=google.com; s=arc-20160816; b=z8UvvcGSLa9k6rgT92CesAnukNsB/vkN1Ii8B5ih6ClWVpgrm9L/x0KM76j8uiHobj ReljRkoiN/bPdFpuAV3+lFmjRTzK5q9vnk3Lou+QKv3HwwS3nUSJQ5EYgCmKimfRas29 xLN//iOJHOMOmBW18r9aZkmdT4rt27tTr/sE36sVRrCIMAiZkkoCBHTnJw04xsunPCD3 wdljjXBHjPyXTjTSfqNtBHVhtE02BvW55gqChH3I2hRWeNOBqhELnnsEOC8cwM5Y6XFk 0aX/TTTsyeeN3xK8Rn+hVSPsL6fdYVhF05W3RqsPghQ3FPuWdOznzI0iq0a8OU0VcBEu LkUA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=AaSopywoa0gY1auqaJleQZMYLxfb/z9BRPiQwrHMnaU=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=hnaXN4HqZp+5uVbNBj9yKdaKRX5wYrdbfsbYaznLBg16O7xNdwfvLqtbG05YaZBQz0 wH7OfeW95w7v9Wd4jTZZVyJ4E4Z8C4e+JvCPLP9Xm/0EIglyo9qUGuIMGZnYPig5UKin 17GUSAzGvTOj6l5vphSdcUTNrWNYPN2IHsXHe8CpDxJL97ZByvtSigTGwrgs7iGiWZuq /RMkzjUlHObj8Dq6mEUq+jOlki92jXJ9Kf7XDem4GdKA1WYpFONmpvSWDJwhz/0CMBQK +EdNy/RuJR2rZaFhAuxljKwcMM1CGf7fe+rWCNFBjc7yUUJaw2Ll+MiZVrAP151+BxcD eQIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ULMut2Pg; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80950-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80950-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h7-20020a170902f54700b001dbde8f8b6bsi3460482plf.147.2024.02.26.01.50.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:50:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80950-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ULMut2Pg; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80950-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80950-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 8D4BAB217B5 for ; Mon, 26 Feb 2024 09:28:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D9C65F555; Mon, 26 Feb 2024 08:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ULMut2Pg" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 9C6EF5C8F8 for ; Mon, 26 Feb 2024 08:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937275; cv=none; b=fnxMICmzFDkZwzfn2L+/OyEI+jR5uxh1fpcJNvYP1+064KXBVBBAgPmQ4twfcnfKHMIk9QbLqNJgjZWra71c1ndYoCio3v4Q6657rKGa88vp/yMWUbQiQZBtliewfSzgR/O4s3eaVJGOjcXdW3E3bTV5hoc2gDHKgjxOxkwA+Mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937275; c=relaxed/simple; bh=yMPzym00FB2Wc5Dwa8wI9RZQ3CPrFsUJyeXrOlw2Z28=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aeoUQz49kHdqOQOaDOfenykitMAkFpOfJNkIzhzINRX41HyzV2r5l84QxYyJFMFgSg5jNRDSUi2jLXt9wC3kvnBA9SEdQqTSX59XEcmvDAEHb3MOMezWi1DUYcRq+YjABF5XZZsbiUCdUg7Sr3uAFJH98VhFhB3xjq8ijGY7B9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ULMut2Pg; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id DCF79E000D; Mon, 26 Feb 2024 08:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937270; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AaSopywoa0gY1auqaJleQZMYLxfb/z9BRPiQwrHMnaU=; b=ULMut2PgZ6S3p5DvX4SrYBlgrKBDTp/j3FMmuzz4iPupGkQCgIcnRL6r0pkUxW7xhGS2vU 7WFpXzBw1bvRZQEgnvJ2/AyBxYuvM7Bb+6yFdY5DiJzg8BZHqagF1gz0iYjvYa8PJmDErS yIUex18PNfFdVvWYJjYjDJu+BYfA6WknoQ8HgQgCcZXKOygQk4U/6V2zWhQ3cvaPH2WDAO izUjz0vSn9XUFq+IRoxomCA1uYMC9j9I9QCcK0PXaP6/a0+fp16K79rLuo22x6VrPLlreF L+APduVy/YB3lIyMR3i6k42Zvvwqh5AN6hIh//cy7KHiz3at7XbaOJkvrtr0FQ== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:35 +0100 Subject: [PATCH v3 5/9] drm/vkms: Re-introduce line-per-line composition algorithm Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-5-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=30033; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=yMPzym00FB2Wc5Dwa8wI9RZQ3CPrFsUJyeXrOlw2Z28=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAu5JKFZSMmcbLIQdGU0VhjLzvR8CyaJcMabJ4e 3BBh4D2JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLgAKCRAgrS7GWxAs4p/lEA CkBleWDzJLx7paYrPayt6vnI3k9wAZzcu8X0Zhkz6GDg1k5Wyr2J75Wl2GdsAA6C8ff4dfxWHzeoEb 9tXWlR24xZjVSfMbLnR94blAqGH3HPOUVtFhHJsxDrC+Suy87UPNwIm9NsZzAZ2wKC+FH8CgtDxOOc z7ZcecpqbPE4Ut92dalLeBUyirCN2Arvdr1Ks9c61Qtt3qINwNg7OZmgtKuAXKpnfwPBMWqhIsN7rW WQbYl9ZZyXUxBStJkCc2cQMuL0uKIBvIULh0LLgNw1H7VJWRgCM+2GZgxm0nZNTGLhoduzIL6Dv6ee y/cONZ4D64ykC6+oF5vNDb9d66XMlCdXYnVuZrjxhG2tUgRmMCDKTnWiw5RSIXhTK5sZc6DXFSmu6u ACszPJ75TJ7N7PlrMaShajaLDXaO3ApjxO943/2QIsaCyiH/FvUZRaiDHrhZhCAn8g53ozuaG9xoZb i2LGlZj/J/J3nq5LC+KNKhTD9vZ1LzTZkIo1I+mdC85Y7FwteLuHQiTscSHx3z307xx9Ha12YcmYln HBz2fzhEz2fI8EjNvut50SKNcfVI8fUAnZT4eqziS8hoYqr8Tw2VXMFQzcDnYi6Pef2Ok4+S6jBqWg mDyEDU5riPin1mAA3XN8tRYLTObwmwLjQ1Iay9HLd3tr4jgJ+MWmR5unPdkQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791954579072861462 X-GMAIL-MSGID: 1791954579072861462 Re-introduce a line-by-line composition algorithm for each pixel format. This allows more performance by not requiring an indirection per pixel read. This patch is focused on readability of the code. Line-by-line composition was introduced by [1] but rewritten back to pixel-by-pixel algorithm in [2]. At this time, nobody noticed the impact on performance, and it was merged. This patch is almost a revert of [2], but in addition efforts have been made to increase readability and maintainability of the rotation handling. The blend function is now divided in two parts: - Transformation of coordinates from the output referential to the source referential - Line conversion and blending Most of the complexity of the rotation management is avoided by using drm_rect_* helpers. The remaining complexity is around the clipping, to avoid reading/writing outside source/destination buffers. The pixel conversion is now done line-by-line, so the read_pixel_t was replaced with read_pixel_line_t callback. This way the indirection is only required once per line and per plane, instead of once per pixel and per plane. The read_line_t callbacks are very similar for most pixel format, but it is required to avoid performance impact. Some helpers were created to avoid code repetition: - get_step_1x1: get the step in byte to reach next pixel block in a certain direction - *_to_argb_u16: helpers to perform colors conversion. They should be inlined by the compiler, and they are used to avoid repetition between multiple variants of the same format (argb/xrgb and maybe in the future for formats like bgr formats). This new algorithm was tested with: - kms_plane (for color conversions) - kms_rotation_crc (for rotations of planes) - kms_cursor_crc (for translations of planes) The performance gain was mesured with: - kms_fb_stress [1]: commit 8ba1648567e2 ("drm: vkms: Refactor the plane composer to accept new formats") https://lore.kernel.org/all/20220905190811.25024-7-igormtorrente@gmail.com/ [2]: commit 322d716a3e8a ("drm/vkms: isolate pixel conversion functionality") https://lore.kernel.org/all/20230418130525.128733-2-mcanal@igalia.com/ Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_composer.c | 219 +++++++++++++++++++++++------- drivers/gpu/drm/vkms/vkms_drv.h | 24 +++- drivers/gpu/drm/vkms/vkms_formats.c | 253 ++++++++++++++++++++++------------- drivers/gpu/drm/vkms/vkms_formats.h | 2 +- drivers/gpu/drm/vkms/vkms_plane.c | 8 +- 5 files changed, 349 insertions(+), 157 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 5b341222d239..e555bf9c1aee 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -24,9 +24,10 @@ static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) /** * pre_mul_alpha_blend - alpha blending equation - * @frame_info: Source framebuffer's metadata * @stage_buffer: The line with the pixels from src_plane * @output_buffer: A line buffer that receives all the blends output + * @x_start: The start offset to avoid useless copy + * @count: The number of byte to copy * * Using the information from the `frame_info`, this blends only the * necessary pixels from the `stage_buffer` to the `output_buffer` @@ -37,51 +38,23 @@ static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) * drm_plane_create_blend_mode_property(). Also, this formula assumes a * completely opaque background. */ -static void pre_mul_alpha_blend(struct vkms_frame_info *frame_info, - struct line_buffer *stage_buffer, - struct line_buffer *output_buffer) +static void pre_mul_alpha_blend( + struct line_buffer *stage_buffer, + struct line_buffer *output_buffer, + int x_start, + int pixel_count) { - int x_dst = frame_info->dst.x1; - struct pixel_argb_u16 *out = output_buffer->pixels + x_dst; - 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); - - for (int x = 0; x < 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); - out[x].b = pre_mul_blend_channel(in[x].b, out[x].b, in[x].a); + struct pixel_argb_u16 *out = &output_buffer->pixels[x_start]; + struct pixel_argb_u16 *in = &stage_buffer->pixels[x_start]; + + for (int i = 0; i < pixel_count; i++) { + out[i].a = (u16)0xffff; + out[i].r = pre_mul_blend_channel(in[i].r, out[i].r, in[i].a); + out[i].g = pre_mul_blend_channel(in[i].g, out[i].g, in[i].a); + out[i].b = pre_mul_blend_channel(in[i].b, out[i].b, in[i].a); } } -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->rotated) - y - 1; - - switch (frame_info->rotation & DRM_MODE_ROTATE_MASK) { - case DRM_MODE_ROTATE_90: - return frame_info->rotated.x2 - y - 1; - case DRM_MODE_ROTATE_270: - return y + frame_info->rotated.x1; - default: - return y; - } -} - -static bool check_limit(struct vkms_frame_info *frame_info, int pos) -{ - if (drm_rotation_90_or_270(frame_info->rotation)) { - if (pos >= 0 && pos < drm_rect_width(&frame_info->rotated)) - return true; - } else { - if (pos >= frame_info->rotated.y1 && pos < frame_info->rotated.y2) - return true; - } - - return false; -} static void fill_background(const struct pixel_argb_u16 *background_color, struct line_buffer *output_buffer) @@ -163,6 +136,37 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } +/** + * direction_for_rotation() - Helper to get the correct reading direction for a specific rotation + * + * @rotation: rotation to analyze + */ +enum pixel_read_direction direction_for_rotation(unsigned int rotation) +{ + if (rotation & DRM_MODE_ROTATE_0) { + if (rotation & DRM_MODE_REFLECT_X) + return READ_LEFT; + else + return READ_RIGHT; + } else if (rotation & DRM_MODE_ROTATE_90) { + if (rotation & DRM_MODE_REFLECT_Y) + return READ_UP; + else + return READ_DOWN; + } else if (rotation & DRM_MODE_ROTATE_180) { + if (rotation & DRM_MODE_REFLECT_X) + return READ_RIGHT; + else + return READ_LEFT; + } else if (rotation & DRM_MODE_ROTATE_270) { + if (rotation & DRM_MODE_REFLECT_Y) + return READ_DOWN; + else + return READ_UP; + } + return READ_RIGHT; +} + /** * blend - blend the pixels from all planes and compute crc * @wb: The writeback frame buffer metadata @@ -183,11 +187,11 @@ 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 }; size_t crtc_y_limit = crtc_state->base.crtc->mode.vdisplay; + size_t crtc_x_limit = crtc_state->base.crtc->mode.hdisplay; /* * The planes are composed line-by-line. It is a necessary complexity to avoid poor @@ -198,22 +202,133 @@ 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++) { - y_pos = get_y_pos(plane[i]->frame_info, y); + struct vkms_plane_state *current_plane = plane[i]; - if (!check_limit(plane[i]->frame_info, y_pos)) + /* Avoid rendering useless lines */ + if (y < current_plane->frame_info->dst.y1 || + y >= current_plane->frame_info->dst.y2) { continue; - - vkms_compose_row(stage_buffer, plane[i], y_pos); - pre_mul_alpha_blend(plane[i]->frame_info, stage_buffer, - output_buffer); + } + + /* + * src_px is the line to copy. The initial coordinates are inside the + * destination framebuffer, and then drm_rect_* helpers are used to + * compute the correct position into the source framebuffer. + */ + struct drm_rect src_px = DRM_RECT_INIT( + current_plane->frame_info->dst.x1, y, + drm_rect_width(¤t_plane->frame_info->dst), 1); + struct drm_rect tmp_src; + + drm_rect_fp_to_int(&tmp_src, ¤t_plane->frame_info->src); + + /* + * [1]: Clamping src_px to the crtc_x_limit to avoid writing outside of the + * destination buffer + */ + src_px.x2 = min_t(int, src_px.x2, (int)crtc_x_limit); + + /* + * Transform the coordinate x/y from the crtc to coordinates into + * coordinates for the src buffer. + * + * - Cancel the offset of the dst buffer. + * - Invert the rotation. This assumes that + * dst = drm_rect_rotate(src, rotation) (dst and src have the + * same size, but can be rotated). + * - Apply the offset of the source rectangle to the coordinate. + */ + drm_rect_translate(&src_px, -current_plane->frame_info->dst.x1, + -current_plane->frame_info->dst.y1); + drm_rect_rotate_inv(&src_px, + drm_rect_width(&tmp_src), + drm_rect_height(&tmp_src), + current_plane->frame_info->rotation); + drm_rect_translate(&src_px, tmp_src.x1, tmp_src.y1); + + /* Get the correct reading direction in the source buffer. */ + + enum pixel_read_direction direction = + direction_for_rotation(current_plane->frame_info->rotation); + + int x_start = src_px.x1; + int y_start = src_px.y1; + int pixel_count; + /* [2]: Compute and clamp the number of pixel to read */ + if (direction == READ_RIGHT || direction == READ_LEFT) { + /* + * In horizontal reading, the src_px width is the number of pixel to + * read + */ + pixel_count = drm_rect_width(&src_px); + if (x_start < 0) { + pixel_count += x_start; + x_start = 0; + } + if (x_start + pixel_count > current_plane->frame_info->fb->width) { + pixel_count = + (int)current_plane->frame_info->fb->width - x_start; + } + } else { + /* + * In vertical reading, the src_px height is the number of pixel to + * read + */ + pixel_count = drm_rect_height(&src_px); + if (y_start < 0) { + pixel_count += y_start; + y_start = 0; + } + if (y_start + pixel_count > current_plane->frame_info->fb->height) { + pixel_count = + (int)current_plane->frame_info->fb->width - y_start; + } + } + + if (pixel_count <= 0) { + /* Nothing to read, so avoid multiple function calls for nothing */ + continue; + } + + /* + * Modify the starting point to take in account the rotation + * + * src_px is the top-left corner, so when reading READ_LEFT or READ_TOP, it + * must be changed to the top-right/bottom-left corner. + */ + if (direction == READ_LEFT) { + // x_start is now the right point + x_start += pixel_count - 1; + } else if (direction == READ_UP) { + // y_start is now the bottom point + y_start += pixel_count - 1; + } + + /* + * Perform the conversion and the blending + * + * Here we know that the read line (x_start, y_start, pixel_count) is + * inside the source buffer [2] and we don't write outside the stage + * buffer [1] + */ + current_plane->pixel_read_line( + current_plane->frame_info, + x_start, + y_start, + direction, + pixel_count, + &stage_buffer->pixels[current_plane->frame_info->dst.x1]); + + pre_mul_alpha_blend(stage_buffer, output_buffer, + current_plane->frame_info->dst.x1, + pixel_count); } apply_lut(crtc_state, output_buffer); *crc32 = crc32_le(*crc32, (void *)output_buffer->pixels, row_size); - if (wb) - vkms_writeback_row(wb, output_buffer, y_pos); + vkms_writeback_row(wb, output_buffer, y); } } @@ -224,7 +339,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]->pixel_read) + if (!planes[i]->pixel_read_line) return -1; if (active_wb && !active_wb->pixel_write) diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 886c885c8cf5..0bf49b3c435b 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -39,7 +39,6 @@ struct vkms_frame_info { struct drm_framebuffer *fb; struct drm_rect src, dst; - struct drm_rect rotated; struct iosys_map map[DRM_FORMAT_MAX_PLANES]; unsigned int rotation; }; @@ -69,14 +68,26 @@ struct vkms_writeback_job { pixel_write_t pixel_write; }; +enum pixel_read_direction { + READ_UP, + READ_DOWN, + READ_LEFT, + READ_RIGHT +}; + /** - * typedef pixel_read_t - These functions are used to read a pixel in the source frame, + * typedef pixel_read_line_t - These functions are used to read a pixel line in the source frame, * convert it to `struct pixel_argb_u16` and write it to @out_pixel. * - * @src_pixels: Pointer to the pixel to read - * @out_pixel: Pointer to write the converted pixel + * @frame_info: Frame used as source for the pixel value + * @y: Y (height) coordinate in the source buffer + * @x_start: X (width) coordinate of the first pixel to copy + * @x_end: X (width) coordinate of the last pixel to copy + * @out_pixel: Pointer where to write the pixel value. Pixels will be written between x_start and + * x_end. */ -typedef void (*pixel_read_t)(u8 *src_pixels, struct pixel_argb_u16 *out_pixel); +typedef void (*pixel_read_line_t)(struct vkms_frame_info *frame_info, int x_start, int y_start, enum + pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]); /** * vkms_plane_state - Driver specific plane state @@ -88,7 +99,7 @@ typedef void (*pixel_read_t)(u8 *src_pixels, struct pixel_argb_u16 *out_pixel); struct vkms_plane_state { struct drm_shadow_plane_state base; struct vkms_frame_info *frame_info; - pixel_read_t pixel_read; + pixel_read_line_t pixel_read_line; }; struct vkms_plane { @@ -193,7 +204,6 @@ 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); void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer *src_buffer, int y); /* Writeback */ diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 1f5aeba57ad6..46daea6d3ee9 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -11,21 +11,29 @@ /** * packed_pixels_offset() - Get the offset of the block containing the pixel at coordinates x/y - * in the first plane * * @frame_info: Buffer metadata * @x: The x coordinate of the wanted pixel in the buffer * @y: The y coordinate of the wanted pixel in the buffer + * @plane_index: The index of the plane to use * * The caller must be aware that this offset is not always a pointer to a pixel. If individual * pixel values are needed, they have to be extracted from the resulting block. */ -static size_t pixel_offset(const struct vkms_frame_info *frame_info, int x, int y) +static size_t packed_pixels_offset(const struct vkms_frame_info *frame_info, int x, int y, + size_t plane_index) { struct drm_framebuffer *fb = frame_info->fb; - - return fb->offsets[0] + (y * fb->pitches[0]) - + (x * fb->format->cpp[0]); + const struct drm_format_info *format = frame_info->fb->format; + /* Directly using x and y to multiply pitches and format->ccp is not sufficient because + * in some formats a block can represent multiple pixels. + * + * Dividing x and y by the block size allows to extract the correct offset of the block + * containing the pixel. + */ + return fb->offsets[plane_index] + + (y / drm_format_info_block_width(format, plane_index)) * fb->pitches[plane_index] + + (x / drm_format_info_block_height(format, plane_index)) * format->char_per_block[plane_index]; } /** @@ -35,44 +43,56 @@ static size_t pixel_offset(const struct vkms_frame_info *frame_info, int x, int * @frame_info: Buffer metadata * @x: The x(width) coordinate inside the plane * @y: The y(height) coordinate inside the plane + * @plane_index: The index of the plane * - * Takes the information stored in the frame_info, a pair of coordinates, and - * returns the address of the first color channel. - * This function assumes the channels are packed together, i.e. a color channel - * comes immediately after another in the memory. And therefore, this function - * doesn't work for YUV with chroma subsampling (e.g. YUV420 and NV21). + * Takes the information stored in the frame_info, a pair of coordinates, and returns the address + * of the block containing this pixel. + * The caller must be aware that this pointer is sometimes not directly a pixel, it needs some + * additional work to extract pixel color from this block. */ static void *packed_pixels_addr(const struct vkms_frame_info *frame_info, - int x, int y) + int x, int y, size_t plane_index) { - size_t offset = pixel_offset(frame_info, x, y); - - return (u8 *)frame_info->map[0].vaddr + offset; + return (u8 *)frame_info->map[0].vaddr + packed_pixels_offset(frame_info, x, y, plane_index); } -static void *get_packed_src_addr(const struct vkms_frame_info *frame_info, int y) +/** + * get_step_1x1() - Common helper to compute the correct step value between each pixel to read in a + * certain direction. + * This must be used only with format where blockh == blockw == 1. + * In the case when direction is not a valid pixel_read_direction, the returned step is 0, so you + * must not rely on this result to create a loop variant. + * + * @fb Framebuffer to iter on + * @direction Direction of the reading + */ +static int get_step_1x1(struct drm_framebuffer *fb, enum pixel_read_direction direction, + int plane_index) { - int x_src = frame_info->src.x1 >> 16; - int y_src = y - frame_info->rotated.y1 + (frame_info->src.y1 >> 16); - - return packed_pixels_addr(frame_info, x_src, y_src); + switch (direction) { + default: + DRM_ERROR("Invalid direction for pixel reading: %d\n", direction); + return 0; + case READ_RIGHT: + return fb->format->char_per_block[plane_index]; + case READ_LEFT: + return -fb->format->char_per_block[plane_index]; + case READ_DOWN: + return (int)fb->pitches[plane_index]; + case READ_UP: + return -(int)fb->pitches[plane_index]; + } } -static int get_x_position(const struct vkms_frame_info *frame_info, int limit, int x) -{ - if (frame_info->rotation & (DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_270)) - return limit - x - 1; - return x; -} /* - * The following functions take pixel data from the buffer and convert them to the format + * The following functions take pixel data (a, r, g, b, pixel, ...), convert them to the format * ARGB16161616 in out_pixel. * - * They are used in the `vkms_compose_row` function to handle multiple formats. + * They are used in the `read_line`s functions to avoid duplicate work for some pixel formats. */ -static void ARGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) +static void ARGB8888_to_argb_u16(struct pixel_argb_u16 *out_pixel, int a, int r, int g, int b) { /* * The 257 is the "conversion ratio". This number is obtained by the @@ -80,48 +100,26 @@ static void ARGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixe * 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(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) -{ - 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; + out_pixel->a = (u16)a * 257; + out_pixel->r = (u16)r * 257; + out_pixel->g = (u16)g * 257; + out_pixel->b = (u16)b * 257; } -static void ARGB16161616_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) +static void ARGB16161616_to_argb_u16(struct pixel_argb_u16 *out_pixel, int a, int r, int g, int b) { - u16 *pixels = (u16 *)src_pixels; - - 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(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) -{ - u16 *pixels = (u16 *)src_pixels; - - 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]); + out_pixel->a = le16_to_cpu(a); + out_pixel->r = le16_to_cpu(r); + out_pixel->g = le16_to_cpu(g); + out_pixel->b = le16_to_cpu(b); } -static void RGB565_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) +static void RGB565_to_argb_u16(struct pixel_argb_u16 *out_pixel, const u16 *pixel) { - 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)); - u16 rgb_565 = le16_to_cpu(*pixels); + u16 rgb_565 = le16_to_cpu(*pixel); 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); @@ -132,34 +130,105 @@ static void RGB565_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel) out_pixel->b = drm_fixp2int_round(drm_fixp_mul(fp_b, fp_rb_ratio)); } -/** - * vkms_compose_row - compose a single row of a plane - * @stage_buffer: output line with the composed pixels - * @plane: state of the plane that is being composed - * @y: y coordinate of the row +/* + * The following functions are read_line function for each pixel format supported by VKMS. * - * This function composes a single row of a plane. It gets the source pixels - * through the y coordinate (see get_packed_src_addr()) and goes linearly - * through the source pixel, reading the pixels and converting it to - * ARGB16161616 (see the pixel_read() callback). For rotate-90 and rotate-270, - * the source pixels are not traversed linearly. The source pixels are queried - * on each iteration in order to traverse the pixels vertically. + * They read a line starting at the point @x_start,@y_start following the @direction. The result + * is stored in @out_pixel and in the format ARGB16161616. + * + * Those function are very similar, but it is required for performance reason. In the past, some + * experiment were done, and with a generic loop the performance are very reduced [1]. + * + * [1]: https://lore.kernel.org/dri-devel/d258c8dc-78e9-4509-9037-a98f7f33b3a3@riseup.net/ */ -void vkms_compose_row(struct line_buffer *stage_buffer, struct vkms_plane_state *plane, int y) + +static void ARGB8888_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) +{ + u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + + int step = get_step_1x1(frame_info->fb, direction, 0); + + while (count) { + u8 *px = (u8 *)src_pixels; + + ARGB8888_to_argb_u16(out_pixel, px[3], px[2], px[1], px[0]); + out_pixel += 1; + src_pixels += step; + count--; + } +} + +static void XRGB8888_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) +{ + u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + + int step = get_step_1x1(frame_info->fb, direction, 0); + + while (count) { + u8 *px = (u8 *)src_pixels; + + ARGB8888_to_argb_u16(out_pixel, 255, px[2], px[1], px[0]); + out_pixel += 1; + src_pixels += step; + count--; + } +} + +static void ARGB16161616_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) +{ + u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + + int step = get_step_1x1(frame_info->fb, direction, 0); + + while (count) { + u16 *px = (u16 *)src_pixels; + + ARGB16161616_to_argb_u16(out_pixel, px[3], px[2], px[1], px[0]); + out_pixel += 1; + src_pixels += step; + count--; + } +} + +static void XRGB16161616_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) +{ + u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + + int step = get_step_1x1(frame_info->fb, direction, 0); + + while (count) { + u16 *px = (u16 *)src_pixels; + + ARGB16161616_to_argb_u16(out_pixel, 0xFFFF, px[2], px[1], px[0]); + out_pixel += 1; + src_pixels += step; + count--; + } +} + +static void RGB565_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) { - struct pixel_argb_u16 *out_pixels = stage_buffer->pixels; - struct vkms_frame_info *frame_info = plane->frame_info; - u8 *src_pixels = get_packed_src_addr(frame_info, y); - int limit = min_t(size_t, drm_rect_width(&frame_info->dst), stage_buffer->n_pixels); + u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); - for (size_t x = 0; x < limit; x++, src_pixels += frame_info->fb->format->cpp[0]) { - int x_pos = get_x_position(frame_info, limit, x); + int step = get_step_1x1(frame_info->fb, direction, 0); - if (drm_rotation_90_or_270(frame_info->rotation)) - src_pixels = get_packed_src_addr(frame_info, x + frame_info->rotated.y1) - + frame_info->fb->format->cpp[0] * y; + while (count) { + u16 *px = (u16 *)src_pixels; - plane->pixel_read(src_pixels, &out_pixels[x_pos]); + RGB565_to_argb_u16(out_pixel, px); + out_pixel += 1; + src_pixels += step; + count--; } } @@ -247,7 +316,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, { struct vkms_frame_info *frame_info = &wb->wb_frame_info; int x_dst = frame_info->dst.x1; - u8 *dst_pixels = packed_pixels_addr(frame_info, x_dst, y); + u8 *dst_pixels = packed_pixels_addr(frame_info, x_dst, y, 0); struct pixel_argb_u16 *in_pixels = src_buffer->pixels; int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), src_buffer->n_pixels); @@ -256,27 +325,27 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, } /** - * Retrieve the correct read_pixel function for a specific format. + * Retrieve the correct read_line function for a specific format. * The returned pointer is NULL for unsupported pixel formats. The caller must ensure that the * pointer is valid before using it in a vkms_plane_state. * * @format: 4cc of the format */ -pixel_read_t get_pixel_read_function(u32 format) +pixel_read_line_t get_pixel_read_line_function(u32 format) { switch (format) { case DRM_FORMAT_ARGB8888: - return &ARGB8888_to_argb_u16; + return &ARGB8888_read_line; case DRM_FORMAT_XRGB8888: - return &XRGB8888_to_argb_u16; + return &XRGB8888_read_line; case DRM_FORMAT_ARGB16161616: - return &ARGB16161616_to_argb_u16; + return &ARGB16161616_read_line; case DRM_FORMAT_XRGB16161616: - return &XRGB16161616_to_argb_u16; + return &XRGB16161616_read_line; case DRM_FORMAT_RGB565: - return &RGB565_to_argb_u16; + return &RGB565_read_line; default: - return (pixel_read_t)NULL; + return (pixel_read_line_t)NULL; } } diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index 3ecea4563254..8d2bef95ff79 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" -pixel_read_t get_pixel_read_function(u32 format); +pixel_read_line_t get_pixel_read_line_function(u32 format); pixel_write_t get_pixel_write_function(u32 format); diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index f68b1b03d632..58c1c74742b5 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -106,9 +106,9 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, return; fmt = fb->format->format; - pixel_read_t pixel_read = get_pixel_read_function(fmt); + pixel_read_line_t pixel_read_line = get_pixel_read_line_function(fmt); - if (!pixel_read) { + if (!pixel_read_line) { DRM_WARN("Pixel format is not supported by VKMS planes. State is inchanged\n"); return; } @@ -128,10 +128,8 @@ static void vkms_plane_atomic_update(struct drm_plane *plane, DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y); - drm_rect_rotate(&frame_info->rotated, drm_rect_width(&frame_info->rotated), - drm_rect_height(&frame_info->rotated), frame_info->rotation); - vkms_plane_state->pixel_read = pixel_read; + vkms_plane_state->pixel_read_line = pixel_read_line; } static int vkms_plane_atomic_check(struct drm_plane *plane, From patchwork Mon Feb 26 08:46:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1959075dyb; Mon, 26 Feb 2024 01:28:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW237GFbQAMkce9hWPF+4hDX4uVbbPqGaNjaguXU+qS+Cx1hRXp7BW8UdZwmVlGMxNZknUWh6WkoCTkMtdD9DaUTG1E9w== X-Google-Smtp-Source: AGHT+IGVf2/zEpgUQtov6BVrufr45LSgUbQ8rFWl6OV2VKjwXLmDbeBt/UzYRq24LMGy7ELfk/Ya X-Received: by 2002:a05:6402:5389:b0:563:c2e5:5289 with SMTP id ew9-20020a056402538900b00563c2e55289mr5083397edb.13.1708939715275; Mon, 26 Feb 2024 01:28:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939715; cv=pass; d=google.com; s=arc-20160816; b=vvBIfeOXFt+WnzZIhC50pYSdlmuYx8tpaW6NOaWZdRh5BHXvYvWJBlIVoFo3c4XZti CIwA0anGEz232irgZfT69FOGcw4iq3DdcSbNj7YhUzZqc9J/oXgIJcoj+imUwf3k25l9 MQJC6ZZuTO9pGi9ba2NoLxS/xZOy3HwItxUjM4B3gITOxoAvTfcub5J2INBjHp0rsagE cediHrdlb+PKDbziqueqjq9vmXjDO9Jirls1qBI72aq8F6eBIeBMy+SIgv1miU/mSIHv iXj0Ku492FivRwgP64fylU6KxtPiw55Tz+4NbNPuCfk6rROk3lJ4cRfcSE+G4bulMCDJ Yx6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=wqScyvz6BCmvQG/RS9vkAw9u6UNxlYfQ0HUcNvrYX88=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=NZsdiqTD3g0GXaJa7X04XRJjEiNYTILJ9fBBNrVW7AlDNCA7t3L6VHNhfBWoas8dL/ u3gihei7wNm83adoL4FwE4dFlTqtCOsASuFITiREV6Ov3+Uf2o34F59G2B1eAxtxFOwn S9ackBV5Os2PJKtYcAb5lAqUD87lfvwV53qWRv5ucILKKpoqv+aaokhHXn371tmcObLo Sa5GlrTqQioLhlzy2F97lDxpLUBkAo58Os9GlT4P4Y6yTSmMwtol39MFkO6I4o1EUN4h aBMEEdVapn3W1lCt+KL5SNt5cDdF++gsZm+cNVK44TdXqBzBgJ7ITMSTzxUfpnSgJNlX oKvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dajiUpSt; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80951-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80951-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w16-20020a50fa90000000b005617dbded52si1820073edr.497.2024.02.26.01.28.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:28:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80951-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dajiUpSt; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80951-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80951-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id AFD6C1F225DB for ; Mon, 26 Feb 2024 09:28:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E99C25F460; Mon, 26 Feb 2024 08:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dajiUpSt" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 B1C945C912 for ; Mon, 26 Feb 2024 08:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937276; cv=none; b=HU1N550Jg3u576q3XaA04C1/+fU4RPgt/pGv7ipzu2zmpN4Oq2TSCdwFPLs58+Q2iElFGySQyAhhvwbEf4PyZRsd28lxTdA5V/CzEN7BeqPOu/f0ulJxqbuRBOgyu+gTBMbWls/4SnTcfrMYA5j8fCKLvooogpRNC4d5XPBUBfU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937276; c=relaxed/simple; bh=JhVpHvcG1J7Op/Mz7EjpBz41y28ABTRWkm10DWpYe4s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MOhlqoQPAmaxgc3RYjm8NqRxLOFnfM/+yiZZZXeKDQm/ndjJj78h/s/ugD4xIiIwI1KqylbZaLIdSCwXol3BDleg7IaZ8NRhr4/tKKAkoDi+ZABR23Kp+vGem+6i9EqQYFYr3t0b1kiFidJdfsvXf5+UbYtXDgwInY39bVUYzXE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dajiUpSt; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 0EBFAE0015; Mon, 26 Feb 2024 08:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wqScyvz6BCmvQG/RS9vkAw9u6UNxlYfQ0HUcNvrYX88=; b=dajiUpSt8xq6QszajQz9nk4rNu0mjT18bGZMDy9SnbgzKOLQ0eVelLI7RXMKYZaJC314yj CVfz76tKbYY8SevcLJrg9w5b3Ov53rBJhNQ8jTg4iljA+MuD8nvPpT7E7Lv7IRd5X8247N swtrjoIZ+tGa88SUFd0K+Ei3V17x8GTJSpYGnVPQ9hHjjhbYHLCzCbWRFGqY1mXjbiDAsz 2+rQmYpBJO30Njw4u+RN3Ybly2jXsmeF0IGmhYIIhWGHxY13OGoKG7JkEUv/gSRdsoQ0bn ncJOIWB5EtgUZowPJhUVaCydPP7g2MiO0qfdtvbNm0ymgF8+4sUeehsj61kR7g== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:36 +0100 Subject: [PATCH v3 6/9] drm/vkms: Add YUV support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-6-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=17847; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=AStEcdCTEBrDLs4u73eNybrGuidbYmC4mJdbZbvu8Zk=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAuFAA64Tln4Nf39w/rPwVlGwC4/YLc/quMhSSQ 3m3Sj5SJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLgAKCRAgrS7GWxAs4voZEA CkhdDn37YlzwV7cd8/nqL9GaM1ERMdsat87SdP8H6UyjZ/XFaUa17OiE4yChd495C4XggO8tmSkj5p OQACQwgJ0XuuiJMVR1vtfYkTQd+yjzypJW2Ck8USyd8zz9QkkbgqJPCPYw6HpyxJ2UTa1n39jasjhl CfhDgRgfG3rSWXYOW5w4gmys5VVHPrTD57luYOyg+rrn2yv31TzUXMdaTxj+Z153+uHh7kSjlPwqDM gIU9X44Thkb2OHQ7Be7Zbj4kvs4zAhKrv4JscrxQsB5hzYSlba+6LAtR4cSxX5Jiq4i83LkKuKsQlu IYvAjeVQEnZJ0OmQyNV008rHfGB626UgdDWCAm/aWkG61vvCZi6nRb+97K5cap8O7KZ/fjt1lOovYN jylro5VPjV1Sld+qd1D3qJSFhigN8OOs9Wvj5lZLTcVQXX02T4L70t9ZJ2WiyjN5ap7y0ne1c+TVPF S5WZ5UnWdJNVLZARlBOzngYbMJZoHSgW7ukErRSuV47zje5O0cIlrggeOtsyeQc4o0BRq/AIc+O+co CFtrik1CFRoi7KjfpSJLr4RiUWnlEjiSIxTvsZU80wLaEd8Ok0GUNz1Jk8vO0ma2Pq+8lxwTxn2NbX mOLuMRGgpOJb/uKY+HwQkKejaLImu9jABK2hAw0ZcEUvd7QtdVI5GppaYicw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791953171010187323 X-GMAIL-MSGID: 1791953171010187323 From: Arthur Grillo Add support to the YUV formats bellow: - NV12 - NV16 - NV24 - NV21 - NV61 - NV42 - YUV420 - YUV422 - YUV444 - YVU420 - YVU422 - YVU444 The conversion matrices of each encoding and range were obtained by rounding the values of the original conversion matrices multiplied by 2^8. This is done to avoid the use of fixed point operations. Signed-off-by: Arthur Grillo [Louis Chauvet: Adapted Arthur's work and implemented the read_line_t callbacks for yuv formats] Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_composer.c | 2 +- drivers/gpu/drm/vkms/vkms_drv.h | 6 +- drivers/gpu/drm/vkms/vkms_formats.c | 289 +++++++++++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_formats.h | 4 + drivers/gpu/drm/vkms/vkms_plane.c | 14 +- 5 files changed, 295 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index e555bf9c1aee..54fc5161d565 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -312,7 +312,7 @@ static void blend(struct vkms_writeback_job *wb, * buffer [1] */ current_plane->pixel_read_line( - current_plane->frame_info, + current_plane, x_start, y_start, direction, diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index 0bf49b3c435b..a825c36d458f 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -75,6 +75,8 @@ enum pixel_read_direction { READ_RIGHT }; +struct vkms_plane_state; + /** * typedef pixel_read_line_t - These functions are used to read a pixel line in the source frame, * convert it to `struct pixel_argb_u16` and write it to @out_pixel. @@ -86,8 +88,8 @@ enum pixel_read_direction { * @out_pixel: Pointer where to write the pixel value. Pixels will be written between x_start and * x_end. */ -typedef void (*pixel_read_line_t)(struct vkms_frame_info *frame_info, int x_start, int y_start, enum - pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]); +typedef void (*pixel_read_line_t)(struct vkms_plane_state *frame_info, int x_start, int y_start, + enum pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]); /** * vkms_plane_state - Driver specific plane state diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 46daea6d3ee9..515c80866a58 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -33,7 +33,8 @@ static size_t packed_pixels_offset(const struct vkms_frame_info *frame_info, int */ return fb->offsets[plane_index] + (y / drm_format_info_block_width(format, plane_index)) * fb->pitches[plane_index] + - (x / drm_format_info_block_height(format, plane_index)) * format->char_per_block[plane_index]; + (x / drm_format_info_block_height(format, plane_index)) * + format->char_per_block[plane_index]; } /** @@ -84,6 +85,32 @@ static int get_step_1x1(struct drm_framebuffer *fb, enum pixel_read_direction di } } +/** + * get_subsampling() - Get the subsampling value on a specific direction + */ +static int get_subsampling(const struct drm_format_info *format, + enum pixel_read_direction direction) +{ + if (direction == READ_LEFT || direction == READ_RIGHT) + return format->hsub; + else if (direction == READ_DOWN || direction == READ_UP) + return format->vsub; + return 1; +} + +/** + * get_subsampling_offset() - Get the subsampling offset to use when incrementing the pixel counter + */ +static int get_subsampling_offset(const struct drm_format_info *format, + enum pixel_read_direction direction, int x_start, int y_start) +{ + if (direction == READ_RIGHT || direction == READ_LEFT) + return x_start; + else if (direction == READ_DOWN || direction == READ_UP) + return y_start; + return 0; +} + /* * The following functions take pixel data (a, r, g, b, pixel, ...), convert them to the format @@ -130,6 +157,87 @@ static void RGB565_to_argb_u16(struct pixel_argb_u16 *out_pixel, const u16 *pixe out_pixel->b = drm_fixp2int_round(drm_fixp_mul(fp_b, fp_rb_ratio)); } +static void ycbcr2rgb(const s16 m[3][3], u8 y, u8 cb, u8 cr, u8 y_offset, u8 *r, u8 *g, u8 *b) +{ + s32 y_16, cb_16, cr_16; + s32 r_16, g_16, b_16; + + y_16 = y - y_offset; + cb_16 = cb - 128; + cr_16 = cr - 128; + + r_16 = m[0][0] * y_16 + m[0][1] * cb_16 + m[0][2] * cr_16; + g_16 = m[1][0] * y_16 + m[1][1] * cb_16 + m[1][2] * cr_16; + b_16 = m[2][0] * y_16 + m[2][1] * cb_16 + m[2][2] * cr_16; + + *r = clamp(r_16, 0, 0xffff) >> 8; + *g = clamp(g_16, 0, 0xffff) >> 8; + *b = clamp(b_16, 0, 0xffff) >> 8; +} + +static void yuv_u8_to_argb_u16(struct pixel_argb_u16 *argb_u16, const struct pixel_yuv_u8 *yuv_u8, + enum drm_color_encoding encoding, enum drm_color_range range) +{ + static const s16 bt601_full[3][3] = { + { 256, 0, 359 }, + { 256, -88, -183 }, + { 256, 454, 0 }, + }; + static const s16 bt601[3][3] = { + { 298, 0, 409 }, + { 298, -100, -208 }, + { 298, 516, 0 }, + }; + static const s16 rec709_full[3][3] = { + { 256, 0, 408 }, + { 256, -48, -120 }, + { 256, 476, 0 }, + }; + static const s16 rec709[3][3] = { + { 298, 0, 459 }, + { 298, -55, -136 }, + { 298, 541, 0 }, + }; + static const s16 bt2020_full[3][3] = { + { 256, 0, 377 }, + { 256, -42, -146 }, + { 256, 482, 0 }, + }; + static const s16 bt2020[3][3] = { + { 298, 0, 430 }, + { 298, -48, -167 }, + { 298, 548, 0 }, + }; + + u8 r = 0; + u8 g = 0; + u8 b = 0; + bool full = range == DRM_COLOR_YCBCR_FULL_RANGE; + unsigned int y_offset = full ? 0 : 16; + + switch (encoding) { + case DRM_COLOR_YCBCR_BT601: + ycbcr2rgb(full ? bt601_full : bt601, + yuv_u8->y, yuv_u8->u, yuv_u8->v, y_offset, &r, &g, &b); + break; + case DRM_COLOR_YCBCR_BT709: + ycbcr2rgb(full ? rec709_full : rec709, + yuv_u8->y, yuv_u8->u, yuv_u8->v, y_offset, &r, &g, &b); + break; + case DRM_COLOR_YCBCR_BT2020: + ycbcr2rgb(full ? bt2020_full : bt2020, + yuv_u8->y, yuv_u8->u, yuv_u8->v, y_offset, &r, &g, &b); + break; + default: + pr_warn_once("Not supported color encoding\n"); + break; + } + + argb_u16->r = r * 257; + argb_u16->g = g * 257; + argb_u16->b = b * 257; +} + /* * The following functions are read_line function for each pixel format supported by VKMS. * @@ -142,13 +250,13 @@ static void RGB565_to_argb_u16(struct pixel_argb_u16 *out_pixel, const u16 *pixe * [1]: https://lore.kernel.org/dri-devel/d258c8dc-78e9-4509-9037-a98f7f33b3a3@riseup.net/ */ -static void ARGB8888_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, +static void ARGB8888_read_line(struct vkms_plane_state *plane, int x_start, int y_start, enum pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]) { - u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + u8 *src_pixels = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); - int step = get_step_1x1(frame_info->fb, direction, 0); + int step = get_step_1x1(plane->frame_info->fb, direction, 0); while (count) { u8 *px = (u8 *)src_pixels; @@ -160,13 +268,13 @@ static void ARGB8888_read_line(struct vkms_frame_info *frame_info, int x_start, } } -static void XRGB8888_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, +static void XRGB8888_read_line(struct vkms_plane_state *plane, int x_start, int y_start, enum pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]) { - u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + u8 *src_pixels = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); - int step = get_step_1x1(frame_info->fb, direction, 0); + int step = get_step_1x1(plane->frame_info->fb, direction, 0); while (count) { u8 *px = (u8 *)src_pixels; @@ -178,13 +286,13 @@ static void XRGB8888_read_line(struct vkms_frame_info *frame_info, int x_start, } } -static void ARGB16161616_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, +static void ARGB16161616_read_line(struct vkms_plane_state *plane, int x_start, int y_start, enum pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]) { - u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + u8 *src_pixels = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); - int step = get_step_1x1(frame_info->fb, direction, 0); + int step = get_step_1x1(plane->frame_info->fb, direction, 0); while (count) { u16 *px = (u16 *)src_pixels; @@ -196,13 +304,13 @@ static void ARGB16161616_read_line(struct vkms_frame_info *frame_info, int x_sta } } -static void XRGB16161616_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, +static void XRGB16161616_read_line(struct vkms_plane_state *plane, int x_start, int y_start, enum pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]) { - u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + u8 *src_pixels = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); - int step = get_step_1x1(frame_info->fb, direction, 0); + int step = get_step_1x1(plane->frame_info->fb, direction, 0); while (count) { u16 *px = (u16 *)src_pixels; @@ -214,13 +322,13 @@ static void XRGB16161616_read_line(struct vkms_frame_info *frame_info, int x_sta } } -static void RGB565_read_line(struct vkms_frame_info *frame_info, int x_start, int y_start, +static void RGB565_read_line(struct vkms_plane_state *plane, int x_start, int y_start, enum pixel_read_direction direction, int count, struct pixel_argb_u16 out_pixel[]) { - u8 *src_pixels = packed_pixels_addr(frame_info, x_start, y_start, 0); + u8 *src_pixels = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); - int step = get_step_1x1(frame_info->fb, direction, 0); + int step = get_step_1x1(plane->frame_info->fb, direction, 0); while (count) { u16 *px = (u16 *)src_pixels; @@ -232,6 +340,139 @@ static void RGB565_read_line(struct vkms_frame_info *frame_info, int x_start, in } } +static void semi_planar_yuv_read_line(struct vkms_plane_state *plane, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) +{ + u8 *y_plane = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); + u8 *uv_plane = packed_pixels_addr(plane->frame_info, + x_start / plane->frame_info->fb->format->hsub, + y_start / plane->frame_info->fb->format->vsub, + 1); + struct pixel_yuv_u8 yuv_u8; + int step_y = get_step_1x1(plane->frame_info->fb, direction, 0); + int step_uv = get_step_1x1(plane->frame_info->fb, direction, 1); + int subsampling = get_subsampling(plane->frame_info->fb->format, direction); + int subsampling_offset = get_subsampling_offset(plane->frame_info->fb->format, direction, + x_start, y_start); // 0 + + for (int i = 0; i < count; i++) { + yuv_u8.y = y_plane[0]; + yuv_u8.u = uv_plane[0]; + yuv_u8.v = uv_plane[1]; + + yuv_u8_to_argb_u16(out_pixel, &yuv_u8, plane->base.base.color_encoding, + plane->base.base.color_range); + out_pixel += 1; + y_plane += step_y; + if ((i + subsampling_offset + 1) % subsampling == 0) + uv_plane += step_uv; + } +} + +static void semi_planar_yvu_read_line(struct vkms_plane_state *plane, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) +{ + u8 *y_plane = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); + u8 *vu_plane = packed_pixels_addr(plane->frame_info, + x_start / plane->frame_info->fb->format->hsub, + y_start / plane->frame_info->fb->format->vsub, + 1); + struct pixel_yuv_u8 yuv_u8; + int step_y = get_step_1x1(plane->frame_info->fb, direction, 0); + int step_vu = get_step_1x1(plane->frame_info->fb, direction, 1); + int subsampling = get_subsampling(plane->frame_info->fb->format, direction); + int subsampling_offset = get_subsampling_offset(plane->frame_info->fb->format, direction, + x_start, y_start); + for (int i = 0; i < count; i++) { + yuv_u8.y = y_plane[0]; + yuv_u8.u = vu_plane[1]; + yuv_u8.v = vu_plane[0]; + + yuv_u8_to_argb_u16(out_pixel, &yuv_u8, plane->base.base.color_encoding, + plane->base.base.color_range); + out_pixel += 1; + y_plane += step_y; + if ((i + subsampling_offset + 1) % subsampling == 0) + vu_plane += step_vu; + } +} + +static void planar_yuv_read_line(struct vkms_plane_state *plane, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) +{ + u8 *y_plane = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); + u8 *u_plane = packed_pixels_addr(plane->frame_info, + x_start / plane->frame_info->fb->format->hsub, + y_start / plane->frame_info->fb->format->vsub, + 1); + u8 *v_plane = packed_pixels_addr(plane->frame_info, + x_start / plane->frame_info->fb->format->hsub, + y_start / plane->frame_info->fb->format->vsub, + 2); + struct pixel_yuv_u8 yuv_u8; + int step_y = get_step_1x1(plane->frame_info->fb, direction, 0); + int step_u = get_step_1x1(plane->frame_info->fb, direction, 1); + int step_v = get_step_1x1(plane->frame_info->fb, direction, 2); + int subsampling = get_subsampling(plane->frame_info->fb->format, direction); + int subsampling_offset = get_subsampling_offset(plane->frame_info->fb->format, direction, + x_start, y_start); + + for (int i = 0; i < count; i++) { + yuv_u8.y = *y_plane; + yuv_u8.u = *u_plane; + yuv_u8.v = *v_plane; + + yuv_u8_to_argb_u16(out_pixel, &yuv_u8, plane->base.base.color_encoding, + plane->base.base.color_range); + out_pixel += 1; + y_plane += step_y; + if ((i + subsampling_offset + 1) % subsampling == 0) { + u_plane += step_u; + v_plane += step_v; + } + } +} + +static void planar_yvu_read_line(struct vkms_plane_state *plane, int x_start, int y_start, + enum pixel_read_direction direction, int count, + struct pixel_argb_u16 out_pixel[]) +{ + u8 *y_plane = packed_pixels_addr(plane->frame_info, x_start, y_start, 0); + u8 *v_plane = packed_pixels_addr(plane->frame_info, + x_start / plane->frame_info->fb->format->hsub, + y_start / plane->frame_info->fb->format->vsub, + 1); + u8 *u_plane = packed_pixels_addr(plane->frame_info, + x_start / plane->frame_info->fb->format->hsub, + y_start / plane->frame_info->fb->format->vsub, + 2); + struct pixel_yuv_u8 yuv_u8; + int step_y = get_step_1x1(plane->frame_info->fb, direction, 0); + int step_u = get_step_1x1(plane->frame_info->fb, direction, 1); + int step_v = get_step_1x1(plane->frame_info->fb, direction, 2); + int subsampling = get_subsampling(plane->frame_info->fb->format, direction); + int subsampling_offset = get_subsampling_offset(plane->frame_info->fb->format, direction, + x_start, y_start); + + for (int i = 0; i < count; i++) { + yuv_u8.y = *y_plane; + yuv_u8.u = *u_plane; + yuv_u8.v = *v_plane; + + yuv_u8_to_argb_u16(out_pixel, &yuv_u8, plane->base.base.color_encoding, + plane->base.base.color_range); + out_pixel += 1; + y_plane += step_y; + if ((i + subsampling_offset + 1) % subsampling == 0) { + u_plane += step_u; + v_plane += step_v; + } + } +} + /* * The following functions take one argb_u16 pixel and convert it to a specific format. The * result is stored in @dst_pixels. @@ -344,6 +585,22 @@ pixel_read_line_t get_pixel_read_line_function(u32 format) return &XRGB16161616_read_line; case DRM_FORMAT_RGB565: return &RGB565_read_line; + case DRM_FORMAT_NV12: + case DRM_FORMAT_NV16: + case DRM_FORMAT_NV24: + return &semi_planar_yuv_read_line; + case DRM_FORMAT_NV21: + case DRM_FORMAT_NV61: + case DRM_FORMAT_NV42: + return &semi_planar_yvu_read_line; + case DRM_FORMAT_YUV420: + case DRM_FORMAT_YUV422: + case DRM_FORMAT_YUV444: + return &planar_yuv_read_line; + case DRM_FORMAT_YVU420: + case DRM_FORMAT_YVU422: + case DRM_FORMAT_YVU444: + return &planar_yvu_read_line; default: return (pixel_read_line_t)NULL; } diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index 8d2bef95ff79..5a3a9e1328d8 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -9,4 +9,8 @@ pixel_read_line_t get_pixel_read_line_function(u32 format); pixel_write_t get_pixel_write_function(u32 format); +struct pixel_yuv_u8 { + u8 y, u, v; +}; + #endif /* _VKMS_FORMATS_H_ */ diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 58c1c74742b5..427ca67c60ce 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -17,7 +17,19 @@ static const u32 vkms_formats[] = { DRM_FORMAT_XRGB8888, DRM_FORMAT_XRGB16161616, DRM_FORMAT_ARGB16161616, - DRM_FORMAT_RGB565 + DRM_FORMAT_RGB565, + DRM_FORMAT_NV12, + DRM_FORMAT_NV16, + DRM_FORMAT_NV24, + DRM_FORMAT_NV21, + DRM_FORMAT_NV61, + DRM_FORMAT_NV42, + DRM_FORMAT_YUV420, + DRM_FORMAT_YUV422, + DRM_FORMAT_YUV444, + DRM_FORMAT_YVU420, + DRM_FORMAT_YVU422, + DRM_FORMAT_YVU444 }; static struct drm_plane_state * From patchwork Mon Feb 26 08:46:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1958813dyb; Mon, 26 Feb 2024 01:27:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5df4ePYOQBfCk/aHRyGF8CnM385q1y86fAK8J8YOoYKwVPUW6rpUGK/ou5aUHxD55H8KSO/1TBgqecVgc+tF+5LnIpA== X-Google-Smtp-Source: AGHT+IF/5gIOul2mycJQEu5X2G/XusDUTL/4IhEJ1paHsp3ng3y3Ss4BSg2lSTwPECckPkOjIOpB X-Received: by 2002:a17:90a:f408:b0:29a:ad19:9591 with SMTP id ch8-20020a17090af40800b0029aad199591mr2155103pjb.39.1708939675599; Mon, 26 Feb 2024 01:27:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939675; cv=pass; d=google.com; s=arc-20160816; b=KYgUJ9P0In/7STG8UVLAm6nMW+bYrvB9sglUp+xwLOnO/tq8SPgsXDbIrmBmqISDjS Lun/ejgO7qiVllOHRxIJ6imtboTa7vV4HC5RISr5dnJzbTYIzqCRMUjGHut2KuRHotl4 2n8NGizAcpjrMDOZyZnDOUE1bVzJNdXy2oULpA75QXq03oAFFAJEse6x6bPGPxmzNbTq wxRoSvbwHOexNTusnHFwikluzCEnroH2e+FXqmP3zlbEvK5zstN11HF2jLUEmZEHKTs3 sRmboCm12yx92bUWVuDpuMqV5g5dnZa5M1vTpiFmW5LPP4B0Mjx1mNpU9/ghwhVUvvpH k6RA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=hFcELKdEH2CqVcdv8HdPB42K6t4+ILioqNSm5RowIZQ=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=TAUsY4uPSHg5YgvjwIdc+2OPs9KE5WS4B9b7qW1KzlHXsqMlPBAI1347DFT43tzvaC 7aoQkrLybfSgGQvLXXcQjjGEc75MFwEuKZD17OUp+OpJFbLMLcZLWw12TDyRVj7MfE5e +lppw3qY9tNlSW8at7z0Z8NLExsuWED+wd507/5LkXtDYBKnhPirK0i/p9hIsdoKBDhr 3QRIU7LYXs8ke9ehzRzdFG8/PQI8rhybMg2vkADGGorE5JC+BjYvgZk76CdS5EdNYDa1 Q/MlDWKqWK7s1mB5JEieHW6rX9QiejMbTkt2OvRvCLq4owzuSztTWt/L4uRiI9l2XFex ahRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=nAZWxsWy; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80953-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80953-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q23-20020a17090ad39700b0029a3b77d1cbsi5279032pju.3.2024.02.26.01.27.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:27:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80953-ouuuleilei=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=pass header.i=@bootlin.com header.s=gm1 header.b=nAZWxsWy; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80953-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80953-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 084392836C6 for ; Mon, 26 Feb 2024 09:27:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D8555DF1C; Mon, 26 Feb 2024 08:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="nAZWxsWy" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 F3E745C5F2 for ; Mon, 26 Feb 2024 08:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937276; cv=none; b=AYCrXPL1zRWNMf6KeVZ/MEDsppTTFXw8Ek76RTEgUZji3SZGHeAfQoOkTEgOn9cH3mPHWzFjJAIR4ze2LOfSWOpWXMSCCf+klC/db1MSpSpf1Q7CiEtHwf8EPFm6hf3+y/aFksp7MCt/LDQhZ0NYL91bZdzt+he2wuzphm9HqrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937276; c=relaxed/simple; bh=WtbjyPm53hzNlCoTEu2tMOVKVRGjW9BjcslmdMUrI3M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R9iurHpSt3dqKgTp/8HWSf3/NJJy6BEAh4uN7b70etyI83V93KDOHoeEcxQw5tEdxx0ZX7oS6bAQ2d4HkWvayobdpFgtuSZKcSgQNgQO48BNNEX0AvoeJxdYImJIaW0UCanodidTTQwsPTuMBXaK3tOLMtqZOROdpnTkiLiVec4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=nAZWxsWy; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 4B4DFE0016; Mon, 26 Feb 2024 08:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hFcELKdEH2CqVcdv8HdPB42K6t4+ILioqNSm5RowIZQ=; b=nAZWxsWyWy8iTA5GHKJyzVaWbQmel+ZWRgnuyrCc/8PgHYNNXsZPAdmwoxY61t2H3XLg+O 2JnSpzn3XASIQQ9iPKdhGZ7LOAr74/KIsBwd0tO3u3EqxLHPD6//WQ6cOFMVuC4gr4bQw2 MvpyS7Jy7B0kq70ltMDJ9gtuItgr7xQgZ6RLph9W/qiANF5GJLUBHBXC1Wm/TZB+5Qb6s6 6Z1PksbFMMubdkv0X7M4y6KlzkOhxFzYP0VpSQLI9OsD2taQXd4gc51c/U9tzFHrHd6aUO J05VU5gAun+jj9bfeeue+kOhvqQxKdTCWw/JQLu7H+6NMpi4Nb0TeyvqDcy9Wg== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:37 +0100 Subject: [PATCH v3 7/9] drm/vkms: Add range and encoding properties to pixel_read function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-7-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1160; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=vFKwJ9LvmL6TH9o/eb/NeXNgMqZMacWZ1OBVcb0LDIk=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAukzY8KaZO7FMrnXURFUQb3OqcogtEjW+Jtayr VMHCBb+JAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLgAKCRAgrS7GWxAs4gDZD/ 9KQ0ph+07NE94lo1zi5xUwN1JnjbzuPErCi9fwe04Xscm8paR3OegBCno8Znh2frrFqUuF+Sxn/y1g 7RFOJGME6nFyt+3hadE5D8CC2P+HPa7ZdiKGo85Vn+ETVfK15Iwn8OUkCoazpNus+yDiO6WbWGE7kh WPu30pjNyvs1z1/jZvKWEzHbfISFnOVT9qxNgIr+fDWRzRKboihgWZN91/jZeqQidama75nZmzuVUN eVGCYEcHzapsv9qTqS6iqm90NOQ9kQUxfW5Zh8NSOHajdJkIoMUb41hRNhIhx4vmuYBzOX5eGLyWSu SzglPYVkd4udTyDlfIeeuYdDrmqqd3leIXCm5MW1dfTpIYg/31u3a98L3ED0IahHlbHg+3M4O6tySJ FIGoUiHLtCbPwgPR5GhLrjx2q8n77vUAtxaLxtBkdA8lYLh12rdaTdQJRdV42alNZ851GSS30DNxHq Rh4niDXfL0u+OREdpJIOk5N427TWK3YT7YR2b4byvHByCe5gUFqrd6ApQ/HqHyeWHUQTiEjM0zIsoN JV0BlO2FeIItTCsGQ9zL3Ie8tbdeqE5+Mz+NP2KHLOGrbw5uZP/kMAspexquIcuFV8H09gdv6btrFb RCEgr561YMVP/AoD5Dz/bUlb7+FDnHyHL2FohJ8jEVFocmpsO2qZg+4tuQow== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791953129159585763 X-GMAIL-MSGID: 1791953129159585763 From: Arthur Grillo Create range and encoding properties. This should be noop, as none of the conversion functions need those properties. Signed-off-by: Arthur Grillo [Louis Chauvet: retained only relevant parts] Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/vkms_plane.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 427ca67c60ce..95dfde297377 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -228,5 +228,14 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK); + drm_plane_create_color_properties(&plane->base, + BIT(DRM_COLOR_YCBCR_BT601) | + BIT(DRM_COLOR_YCBCR_BT709) | + BIT(DRM_COLOR_YCBCR_BT2020), + BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | + BIT(DRM_COLOR_YCBCR_FULL_RANGE), + DRM_COLOR_YCBCR_BT601, + DRM_COLOR_YCBCR_FULL_RANGE); + return plane; } From patchwork Mon Feb 26 08:46:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1959012dyb; Mon, 26 Feb 2024 01:28:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMelNDGn++UNdK9v2+uUfxZTy2oeJgi6TU6AOenz5PL8sbeJ/emUZx3rd5I9EkgTJBi9VHfPcrmfmBHdIFmQTPqZdVcA== X-Google-Smtp-Source: AGHT+IG3gSTax7VE5jLveq2nqLwYC3OrGEDdXZACSpHFT2WC7qP8SH7PJv/JJyvR+cqgO1OdKOWW X-Received: by 2002:a05:6402:148d:b0:564:b832:ba90 with SMTP id e13-20020a056402148d00b00564b832ba90mr3856802edv.33.1708939702402; Mon, 26 Feb 2024 01:28:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939702; cv=pass; d=google.com; s=arc-20160816; b=gMd7oIsaBKf1DItgURRaSIkPIlB++3coWK4MV54fmITyJbydyCT+3zG5SYTGW4XSz7 BRzMYDqAlbmkFM0LFlZ6ptzQCqCRUY7HPvYP7YfL47mjelviSY8tZ2sNWINlX4/Sg6hr mKQ8o4ylEca3eU0N8b0hNuA5fv2obBuB8qsrMpy0VrIKG20O3WdoMc22ZVMaSsPRHxUS wMPDBOUFGDrjopa7U3qrsi3HT/aF4Q8PLlGDJtDOKZz96Ft7WetPeEq0/zCwcr+qSAFR lbRNCovKVHr61gtOYCJnOHPntKxhlzdeWWA/QJ43WQCSFRshPf+RiwVP05r8BenbD1i6 ErwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=1mJQirOrh5uVlCQFN4AJsimww+6ayqe/xDiVoFk4V7I=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=BVfCBsYy6nXGCYnDYHVZltDScnGbof/tuGDhAnheQ2ZkvGgdZdnpOSN134hhNrzAaW S+8jpMR4jlRRKzvCv4YT4FIhZTsHN8cWUd0grQ+GsgR8nNdV6cIntkDl93ZMsRMFudzL lGIaJoc7SyZ72yGcG5PrmeH5CmlHA09QmSd8v4yGMBy8KQZ2v++Z3rrc2kHK1viWc+fs zneEEF5447LPfHg2u78cWJuKqnHB5+zMn+Tk2DneaNQIjb+nMELyii8oIpcQbZ6qY8X9 DXAUT6oSGd+n3SNUee5UEfredIdOYZtEmU85MgU09S+DrEhe1qeekOhZfu4Adv+8cUs4 Gxqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CVuxn1my; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80955-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80955-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w16-20020a50fa90000000b005617dbded52si1820073edr.497.2024.02.26.01.28.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:28:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80955-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=CVuxn1my; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80955-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80955-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 049861F229BA for ; Mon, 26 Feb 2024 09:28:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A7FF5EE81; Mon, 26 Feb 2024 08:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="CVuxn1my" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 632ED5D46A for ; Mon, 26 Feb 2024 08:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937278; cv=none; b=fiiCkGZIBmgGa6XEgsvdRcW+D48IJZ5VB0hCdwrCCbVUVBM6z4WFGHqHVxrq1Y9ATp5JZxVP/9J5WkCkQZFpNzl68HrH+RT93UpgUzd9oLAAnWeInqUkveMlKQytVOUk4graOoO76Q2IJ1nFN4auNBwM51zs7DFMhv7VV6VIO8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937278; c=relaxed/simple; bh=WDAxkhzjtawKA8ibJoFIkQ/DkTdgQXrpylNOsCS8bTs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Uvy6QiAC5E74Ep3cTrmBEeHAPqdN1D1v1shGMo2F/uLsSXofcblDQpP7UNbwhxGkGRjJ8ZnN/Tul6G7Wcsb9bq466qWW+qclnSB1D/hEOtixA/X0czLObo/msUtwTD8mxur0ztTqfoGMgvs+7CC/41ZeLynC9V4bJ1HttXmt2BM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=CVuxn1my; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id A26D6E0017; Mon, 26 Feb 2024 08:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1mJQirOrh5uVlCQFN4AJsimww+6ayqe/xDiVoFk4V7I=; b=CVuxn1myfU3LPO3kH3trNGJMOwPFbT8wPap3ipJ7wly2E6Zp4lXXxWgy62jODYSjiHFi92 TrFwS/V8zP5tSUgZqHSBIkJDfHw7Qo8igxIh4C4GVp80chJClwxz1Tba20yLxz/89EHQIr ZJc+jA5fkaIberpmWnsjH21oE4ePyDwpYJlXCyA+d+yUczeQCRvEn992RtK9g9Nolh2UWW NgfOFEVVMYHZNV/cwK/zs7SQxc3oDsYJFyqNazx+TaTYr1nOVqI1yreTJhimmGp4FsTUVd mh8sMuvt2Yek1v3nW98MldkBil7DJJ2F5512W3W6tyCXAm8zNB+gbIV9QzDQYA== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:38 +0100 Subject: [PATCH v3 8/9] drm/vkms: Drop YUV formats TODO Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-8-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=881; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=cRkkP1b8eceTuEm0QTSGTTTnDinaYzDjRJLok06bIiI=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAu3/xcYIu2XAyaRI/irSXXd3yp6kz0cLwrVbyp 0xQKpeWJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLgAKCRAgrS7GWxAs4py2D/ 4oCJKYWdQ5WV+LIcdPmG3crkYWUByr39Mn+bDJCPeCOV1vmo34h/CzYxTmVCtbug32zjEBXJlmSOak G9hmdOjo7SyfibyQXn7WdpM5Vo8CKFW+7coN0KFrCCdxHYCiOZiHgA6Zu3JUv48i+woltLznIqFlkg R1+1Za/MBevfss2JwDRKMwkK9EvW5mHFhaJzD94H8EF9J70djpk6mzet9dxpotZafXhm8nvnlrkkkQ DXqKgLq9jImO6XKuNgvRlWgOZYOVu1F1wqYWuelXbOTxxwk7jRSbVMm4mY3oSqdKbgn08JALodn5Tl NJIAZ4hZJxJvg3VWm19TumirnP4uGP/v2eAqeeT9N5VvtMnKaUp8lAH3GhRl6C7eFqxddBAGzhhXcz cyWJXzoQVqZmWDsqOT05WuSCL0AYWvR5odfLjHvrv6utXqsk54GbimCsr04yY9uCm8/4uu1fSafYwR FLz6NHcsSV8zhkQH7aILKm7DRWbdrOD1UiietonzLCN2c619aFilI+/tcjnPHGobVtpMcoOkyGDY4b rpKAYQxTah8fK8YADYY/llu7TFyBQxJZMD2sR/tR+E9Jo9uFiIFweUE/GQkLGNeUAVC4xSnDu6Zk03 fpKLdfYom5S/iVYWHeM+K8Vs2x1V6+S/PacHfDQGausgla/IgjwIgV43JnyQ== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791953157437877556 X-GMAIL-MSGID: 1791953157437877556 From: Arthur Grillo VKMS has support for YUV formats now. Remove the task from the TODO list. Signed-off-by: Arthur Grillo Signed-off-by: Louis Chauvet --- Documentation/gpu/vkms.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index ba04ac7c2167..13b866c3617c 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -122,8 +122,7 @@ There's lots of plane features we could add support for: - Scaling. -- Additional buffer formats, especially YUV formats for video like NV12. - Low/high bpp RGB formats would also be interesting. +- Additional buffer formats. Low/high bpp RGB formats would be interesting. - Async updates (currently only possible on cursor plane using the legacy cursor api). From patchwork Mon Feb 26 08:46:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Chauvet X-Patchwork-Id: 206504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1959180dyb; Mon, 26 Feb 2024 01:28:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUugoqYVUGWlVYUoM+QGdw/0tl8GVQEyjarocsK94anHXEh4HhwZ61Gg5mf3PyATK1p3qAnlFx6v9E+VkGbQZbIT2i+8Q== X-Google-Smtp-Source: AGHT+IEIj15Phl+v9K1V/UAeXOXdJll2esTe9Rh1IK9aLGQG68dpa1fnzVuEB9AgylpyylrDGKFP X-Received: by 2002:a05:6870:55cd:b0:21e:e81e:36ef with SMTP id qk13-20020a05687055cd00b0021ee81e36efmr7944908oac.36.1708939731407; Mon, 26 Feb 2024 01:28:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708939731; cv=pass; d=google.com; s=arc-20160816; b=w0eQt1GuieOTNukwmOjzPTZH020nkWkAV3LNx3TdnCpsdJUU3vfGtL9H+QpJbx7P2x uzSz6J9S1fLZuQy6VEESXlVnhEmFj59i4WXZd0o6rrOaNI9BPhXXYBkaaefjAoXqrEbd jfORyVpXxUcsaLyWoGUkHqnL7Po8tiGzp+ewkeHJNVFkHPhlnRzVGYeoDTalggdmIpIa mcVQry5S8jKihvbPAY8WvqcnQ8eagcvh6I+gSrJ6Xj3v6KWN01lpktYErzRu69DZUwRY PGHn1SA+wmozz45nMVq6w9a8k+0S+BTbSR2TGEHUAb/m08OjFGldPYR3pjyH7VF0sB6A TXHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=6/uAsG5Jzk7tw7K+ro+IYvCPbIFvsjURySsIlhGEh+s=; fh=I1mDzpQ2i/fckVIeMd+WKWb14s85mMQWc3/wF4wbFPI=; b=nRx0l9oNQkmRkB2D6d9Ga+IlSeI4OkIFAj5gidgqgLcVdQaF2K8b9xgy+D4ETqTGTF 7GuvPp/46PojtGhap7oXumzOvXyctxVOMi8tfzRCHW6cSl7Mcc2Z6wFqggQbZ6XBeK3G 7RbZ+ns80Fow7bk089oWn+rAxQhDtKL6bFB23oTtqfiKuaouqvEehr1Y1gyZxKzc9e0C vag6OUNlEIbTrkDM8rp3ip6Q59RzCy1VhJuZphkB3+63Fg+vw8CsHAJRli7vyiyAT4yh hCIoVDGNm1tVYFU/KkMJjf+NLg7VHMQLeDN7G/+vBeF2wQhd7f08yTSXCbYjmRoIgIPL t5yA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dH0GSjK4; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80958-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80958-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bw14-20020a056a02048e00b005d8fdbbd5d7si3523553pgb.606.2024.02.26.01.28.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:28:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80958-ouuuleilei=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=pass header.i=@bootlin.com header.s=gm1 header.b=dH0GSjK4; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-80958-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80958-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 339CF286A55 for ; Mon, 26 Feb 2024 09:28:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 383B85F554; Mon, 26 Feb 2024 08:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dH0GSjK4" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 1D4765D74E for ; Mon, 26 Feb 2024 08:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937280; cv=none; b=ivt3s0QuyiMQkV0Jdmm4uwCDeQiUFq0iX9IofFFi/FkkIJVkzWrJ1V1R/eMaK/eTKkPkPB05lGVL31NNXxXdi2HNCcWDI+TQbmuOwiGBv/5jXU659kpBEQIySvyGJBXwfso9wghc5CLx4Z18OZBiRgdCspDSKIfM6yLXHZpDejk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708937280; c=relaxed/simple; bh=zLfCmB2cOAi+rHOF4QFtEGgN1NdsdG4phUDjzA77YMo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YncPZ4C1gWG0Me8WML/vtJzUvG08cOiyYEGTdlT0Wjt7b0Sh79urjtKCOkU7qr004CPYPOI0cQp6aW5XIrOnlOyeAA+vtiSLHDXUcCaiDKXYz4EPiBK5vMXrocCKi4LXXtHBl50J+rhI1W0vszCncilTv7GG6iUWx0EiJUw01Rw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dH0GSjK4; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 018E2E0004; Mon, 26 Feb 2024 08:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708937276; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6/uAsG5Jzk7tw7K+ro+IYvCPbIFvsjURySsIlhGEh+s=; b=dH0GSjK4e4fkWHZQ/bHSXXM3pLkW8TQNEEZwXAUNwiCPRmsaKm6p5WKm7X8+7sYxT1uxaC 5P82E9L0ADTNIbkBLZcZHrQ7J3EjScLOJ06sWfTaNrs0EaduIdlG+ulT1oQvGQim9l+ZRk RpEnHh2fJLFTtsa6FBCDN9FYtnWeFAakOSliyy7gmfpZSjq1RLORm0CF8NRFZTnL/4AaYe 4vYMnfvUD92CA0hThPulerMFhvAUSD7yUP0645ot0sjYpRq2AF2V6WJ7A250ptdGlllE2F gk3ZUR4EQDa3bxvl5tO4LO26mel8xu0o84RHbMwI3ijuxkE+FtGEfxqN9ZkL3g== From: Louis Chauvet Date: Mon, 26 Feb 2024 09:46:39 +0100 Subject: [PATCH v3 9/9] drm/vkms: Create KUnit tests for YUV conversions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240226-yuv-v3-9-ff662f0994db@bootlin.com> References: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> In-Reply-To: <20240226-yuv-v3-0-ff662f0994db@bootlin.com> To: Rodrigo Siqueira , Melissa Wen , =?utf-8?q?Ma=C3=ADra_Canal?= , 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, Louis Chauvet X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9589; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=6XGbmMJEqhgEJWTl1n4SZWXpBs90sgie29UDQGxwWdI=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBl3FAvEEnhg6zHcf91VHkxpZvnc+igqU9NvWEDOEU2 qmgridWJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZdxQLwAKCRAgrS7GWxAs4rYZD/ 9yRKyAKBE9mNJNDB9x+XcUj3pMp5hbsoHnwnVywLxWGdPWeWMyHpxewWET+xTTZovRHaqU9q5DT3d7 VtgU170wcbeh+fAVrAzU4xVS6DxpzyrPKn6r9/Rez4t3oZVlLef9MwrbroGFLQDcMcSpghKVPOIdy4 FbtBGTJjfXeIta/ktcOd0cT0O5NC8VbHQ3I8VA93ZRQuJ+3fGNYwdqsFoBAD/G6q7PMK/N2K177Y5P 3IT+I522WvYWzMN78ET0+GrK3SgedWAkUWVb2NnDWqXybg2IvwTr2FeGStn87SNoxgdjn+T88Cs+24 SEbbRwdPm87M53w0rW0BvZ07Xp3M/Uv226IcolFLZgyp+IJ+Zx5t/z57N46e+o46iEh4NeZ9+i+9eG jaQr0966oevFylG+LZENFbC+95vp6xtJtx2RIAFa0Qk/U3lHGHygrrHMU0fXitMLxAlsWSn/p1qkkV zaJ7H9n5Lo+JHZhcQqol8Kk42Mix3fBgsnK4p/X6GFAc37JfiHZz2A38oJqW48ROW7gnnPZNuLAYo2 07rvrfLp9tdZE6w4ag6NopAJAlvTQfX7P4RFqL2gc+r0UJclfaem60gmrPosuf9x+JHN0KRSPeN/Jo rewMUXOfiYl3yiEH4lDOIikqUAZ5w91Ag5UEr0qwzHMGi+wDSH9ZUE2OBsfw== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791953187470640004 X-GMAIL-MSGID: 1791953187470640004 From: Arthur Grillo Create KUnit tests to test the conversion between YUV and RGB. Test each conversion and range combination with some common colors. Signed-off-by: Arthur Grillo [Louis Chauvet: fix minor formating issues (whitespace, double line)] Signed-off-by: Louis Chauvet --- drivers/gpu/drm/vkms/Makefile | 1 + drivers/gpu/drm/vkms/tests/.kunitconfig | 4 + drivers/gpu/drm/vkms/tests/Makefile | 3 + drivers/gpu/drm/vkms/tests/vkms_format_test.c | 155 ++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_formats.c | 9 +- drivers/gpu/drm/vkms/vkms_formats.h | 5 + 6 files changed, 175 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile index 1b28a6a32948..8d3e46dde635 100644 --- a/drivers/gpu/drm/vkms/Makefile +++ b/drivers/gpu/drm/vkms/Makefile @@ -9,3 +9,4 @@ vkms-y := \ vkms_writeback.o obj-$(CONFIG_DRM_VKMS) += vkms.o +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += tests/ diff --git a/drivers/gpu/drm/vkms/tests/.kunitconfig b/drivers/gpu/drm/vkms/tests/.kunitconfig new file mode 100644 index 000000000000..70e378228cbd --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/.kunitconfig @@ -0,0 +1,4 @@ +CONFIG_KUNIT=y +CONFIG_DRM=y +CONFIG_DRM_VKMS=y +CONFIG_DRM_VKMS_KUNIT_TESTS=y diff --git a/drivers/gpu/drm/vkms/tests/Makefile b/drivers/gpu/drm/vkms/tests/Makefile new file mode 100644 index 000000000000..2d1df668569e --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += vkms_format_test.o diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c new file mode 100644 index 000000000000..cb6d32ff115d --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c @@ -0,0 +1,155 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include +#include +#include + +#include "../../drm_crtc_internal.h" + +#include "../vkms_drv.h" +#include "../vkms_formats.h" + +#define TEST_BUFF_SIZE 50 + +struct yuv_u8_to_argb_u16_case { + enum drm_color_encoding encoding; + enum drm_color_range range; + size_t n_colors; + struct format_pair { + char *name; + struct pixel_yuv_u8 yuv; + struct pixel_argb_u16 argb; + } colors[TEST_BUFF_SIZE]; +}; + +static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { + { + .encoding = DRM_COLOR_YCBCR_BT601, + .range = DRM_COLOR_YCBCR_FULL_RANGE, + .n_colors = 6, + .colors = { + {"white", {0xff, 0x80, 0x80}, {0x0000, 0xffff, 0xffff, 0xffff}}, + {"gray", {0x80, 0x80, 0x80}, {0x0000, 0x8000, 0x8000, 0x8000}}, + {"black", {0x00, 0x80, 0x80}, {0x0000, 0x0000, 0x0000, 0x0000}}, + {"red", {0x4c, 0x55, 0xff}, {0x0000, 0xffff, 0x0000, 0x0000}}, + {"green", {0x96, 0x2c, 0x15}, {0x0000, 0x0000, 0xffff, 0x0000}}, + {"blue", {0x1d, 0xff, 0x6b}, {0x0000, 0x0000, 0x0000, 0xffff}}, + }, + }, + { + .encoding = DRM_COLOR_YCBCR_BT601, + .range = DRM_COLOR_YCBCR_LIMITED_RANGE, + .n_colors = 6, + .colors = { + {"white", {0xeb, 0x80, 0x80}, {0x0000, 0xffff, 0xffff, 0xffff}}, + {"gray", {0x7e, 0x80, 0x80}, {0x0000, 0x8000, 0x8000, 0x8000}}, + {"black", {0x10, 0x80, 0x80}, {0x0000, 0x0000, 0x0000, 0x0000}}, + {"red", {0x51, 0x5a, 0xf0}, {0x0000, 0xffff, 0x0000, 0x0000}}, + {"green", {0x91, 0x36, 0x22}, {0x0000, 0x0000, 0xffff, 0x0000}}, + {"blue", {0x29, 0xf0, 0x6e}, {0x0000, 0x0000, 0x0000, 0xffff}}, + }, + }, + { + .encoding = DRM_COLOR_YCBCR_BT709, + .range = DRM_COLOR_YCBCR_FULL_RANGE, + .n_colors = 4, + .colors = { + {"white", {0xff, 0x80, 0x80}, {0x0000, 0xffff, 0xffff, 0xffff}}, + {"gray", {0x80, 0x80, 0x80}, {0x0000, 0x8000, 0x8000, 0x8000}}, + {"black", {0x00, 0x80, 0x80}, {0x0000, 0x0000, 0x0000, 0x0000}}, + {"red", {0x35, 0x63, 0xff}, {0x0000, 0xffff, 0x0000, 0x0000}}, + {"green", {0xb6, 0x1e, 0x0c}, {0x0000, 0x0000, 0xffff, 0x0000}}, + {"blue", {0x12, 0xff, 0x74}, {0x0000, 0x0000, 0x0000, 0xffff}}, + }, + }, + { + .encoding = DRM_COLOR_YCBCR_BT709, + .range = DRM_COLOR_YCBCR_LIMITED_RANGE, + .n_colors = 4, + .colors = { + {"white", {0xeb, 0x80, 0x80}, {0x0000, 0xffff, 0xffff, 0xffff}}, + {"gray", {0x7e, 0x80, 0x80}, {0x0000, 0x8000, 0x8000, 0x8000}}, + {"black", {0x10, 0x80, 0x80}, {0x0000, 0x0000, 0x0000, 0x0000}}, + {"red", {0x3f, 0x66, 0xf0}, {0x0000, 0xffff, 0x0000, 0x0000}}, + {"green", {0xad, 0x2a, 0x1a}, {0x0000, 0x0000, 0xffff, 0x0000}}, + {"blue", {0x20, 0xf0, 0x76}, {0x0000, 0x0000, 0x0000, 0xffff}}, + }, + }, + { + .encoding = DRM_COLOR_YCBCR_BT2020, + .range = DRM_COLOR_YCBCR_FULL_RANGE, + .n_colors = 4, + .colors = { + {"white", {0xff, 0x80, 0x80}, {0x0000, 0xffff, 0xffff, 0xffff}}, + {"gray", {0x80, 0x80, 0x80}, {0x0000, 0x8000, 0x8000, 0x8000}}, + {"black", {0x00, 0x80, 0x80}, {0x0000, 0x0000, 0x0000, 0x0000}}, + {"red", {0x43, 0x5c, 0xff}, {0x0000, 0xffff, 0x0000, 0x0000}}, + {"green", {0xad, 0x24, 0x0b}, {0x0000, 0x0000, 0xffff, 0x0000}}, + {"blue", {0x0f, 0xff, 0x76}, {0x0000, 0x0000, 0x0000, 0xffff}}, + }, + }, + { + .encoding = DRM_COLOR_YCBCR_BT2020, + .range = DRM_COLOR_YCBCR_LIMITED_RANGE, + .n_colors = 4, + .colors = { + {"white", {0xeb, 0x80, 0x80}, {0x0000, 0xffff, 0xffff, 0xffff}}, + {"gray", {0x7e, 0x80, 0x80}, {0x0000, 0x8000, 0x8000, 0x8000}}, + {"black", {0x10, 0x80, 0x80}, {0x0000, 0x0000, 0x0000, 0x0000}}, + {"red", {0x4a, 0x61, 0xf0}, {0x0000, 0xffff, 0x0000, 0x0000}}, + {"green", {0xa4, 0x2f, 0x19}, {0x0000, 0x0000, 0xffff, 0x0000}}, + {"blue", {0x1d, 0xf0, 0x77}, {0x0000, 0x0000, 0x0000, 0xffff}}, + }, + }, +}; + +static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test) +{ + const struct yuv_u8_to_argb_u16_case *param = test->param_value; + struct pixel_argb_u16 argb; + + for (size_t i = 0; i < param->n_colors; i++) { + const struct format_pair *color = ¶m->colors[i]; + + yuv_u8_to_argb_u16(&argb, &color->yuv, param->encoding, param->range); + + KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.a, color->argb.a), 257, + "On the A channel of the color %s expected 0x%04x, got 0x%04x", + color->name, color->argb.a, argb.a); + KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.r, color->argb.r), 257, + "On the R channel of the color %s expected 0x%04x, got 0x%04x", + color->name, color->argb.r, argb.r); + KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.g, color->argb.g), 257, + "On the G channel of the color %s expected 0x%04x, got 0x%04x", + color->name, color->argb.g, argb.g); + KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.b, color->argb.b), 257, + "On the B channel of the color %s expected 0x%04x, got 0x%04x", + color->name, color->argb.b, argb.b); + } +} + +static void vkms_format_test_yuv_u8_to_argb_u16_case_desc(struct yuv_u8_to_argb_u16_case *t, + char *desc) +{ + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s - %s", + drm_get_color_encoding_name(t->encoding), drm_get_color_range_name(t->range)); +} + +KUNIT_ARRAY_PARAM(yuv_u8_to_argb_u16, yuv_u8_to_argb_u16_cases, + vkms_format_test_yuv_u8_to_argb_u16_case_desc); + +static struct kunit_case vkms_format_test_cases[] = { + KUNIT_CASE_PARAM(vkms_format_test_yuv_u8_to_argb_u16, yuv_u8_to_argb_u16_gen_params), + {} +}; + +static struct kunit_suite vkms_format_test_suite = { + .name = "vkms-format", + .test_cases = vkms_format_test_cases, +}; + +kunit_test_suite(vkms_format_test_suite); + +MODULE_LICENSE("GPL"); diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 515c80866a58..20dd23ce9051 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -7,6 +7,8 @@ #include #include +#include + #include "vkms_formats.h" /** @@ -175,8 +177,10 @@ static void ycbcr2rgb(const s16 m[3][3], u8 y, u8 cb, u8 cr, u8 y_offset, u8 *r, *b = clamp(b_16, 0, 0xffff) >> 8; } -static void yuv_u8_to_argb_u16(struct pixel_argb_u16 *argb_u16, const struct pixel_yuv_u8 *yuv_u8, - enum drm_color_encoding encoding, enum drm_color_range range) +VISIBLE_IF_KUNIT void yuv_u8_to_argb_u16(struct pixel_argb_u16 *argb_u16, + const struct pixel_yuv_u8 *yuv_u8, + enum drm_color_encoding encoding, + enum drm_color_range range) { static const s16 bt601_full[3][3] = { { 256, 0, 359 }, @@ -237,6 +241,7 @@ static void yuv_u8_to_argb_u16(struct pixel_argb_u16 *argb_u16, const struct pix argb_u16->g = g * 257; argb_u16->b = b * 257; } +EXPORT_SYMBOL_IF_KUNIT(yuv_u8_to_argb_u16); /* * The following functions are read_line function for each pixel format supported by VKMS. diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h index 5a3a9e1328d8..4245a5c5e956 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -13,4 +13,9 @@ struct pixel_yuv_u8 { u8 y, u, v; }; +#if IS_ENABLED(CONFIG_KUNIT) +void yuv_u8_to_argb_u16(struct pixel_argb_u16 *argb_u16, const struct pixel_yuv_u8 *yuv_u8, + enum drm_color_encoding encoding, enum drm_color_range range); +#endif + #endif /* _VKMS_FORMATS_H_ */