From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-pp-g121.zoho.com (sender4-pp-g121.zoho.com [136.143.188.121]) (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 B2F8A1E32D6 for ; Fri, 13 Feb 2026 14:35:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.121 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770993341; cv=pass; b=tHl/J7FavvGTLhK2MEiD0jl49Tsu/jg+eSYRZ/VIWhn0r8Wtj7KHYcdNFVV99KMaXpCoq9OJBa9w+houMfZUklWgDnXihjQ6tGy8mSb06gm7DK9uXYYhNiPdfiGySg+5OjdO2KRj6pOY/YFXYlyk9FaK98MbIeKx1OZBfHu3Rm4= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770993341; c=relaxed/simple; bh=0y9/OtDJADT+D+V2FTSq05SvY7NA/ABbsQ5MlReIneM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rnhWnTKHDQcs1HmIwQ7iyMeswuNZg2jhbXBGHJKF6ZQ/jDBwgzhPhNjCoZRMgCIDNVDeV6JLL2hB/LEUHx8TdgVtDuJ8Fmf8WDPyXHS7Li1GO5dQXKLSL9hp2ujAFpiMy4/LSHPHGFt2KoSYsIAjO4s98vwfc4eTsCN4gS8jyEQ= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=ariel.dalessandro@collabora.com header.b=alD5FjzE; arc=pass smtp.client-ip=136.143.188.121 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=ariel.dalessandro@collabora.com header.b="alD5FjzE" ARC-Seal: i=1; a=rsa-sha256; t=1770993310; cv=none; d=zohomail.com; s=zohoarc; b=JpYdjEv2gvi8W9Seb/fuHIy6SMzZPVY+FqybyP9Z7eElr6gomgcVijDJfbrd4J0AJuDSnhNOpQUq5+l8AENC1cI32wKD9Mpt00c9kv0VIgqfc57mFmvCRe/hN7Fja1Yy8OE0qT9Mk2EgAe0nLZ8vlYVCf9CoMPZ1ajqOC8hGh7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770993310; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=yQd6Fuc3Syg5OF2rcjj2wLQjupFgjMVUbdgXsLVzFrM=; b=SOuk7CtVgJigzrmjraAvJ8jzExOqKaTD2C8nIkwOGA55SgBaCN6zZKWOLbwbA2b7HiuGQ4cSOm+tvMIJOXbIXqtMQ2efV23mQREtPTBG0kQvw/uSBHfEhWadFs725sX+fH2JakyL8zqy/bBDChA2kaxOywywcOgKdAKcMsfJMYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=ariel.dalessandro@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1770993310; s=zohomail; d=collabora.com; i=ariel.dalessandro@collabora.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=yQd6Fuc3Syg5OF2rcjj2wLQjupFgjMVUbdgXsLVzFrM=; b=alD5FjzE84hTDUUvk3Awlx9Q/noQlUS14dJRTqCkydAYNUL6SiYCrGEqDK5hezZi SPOnEvb4PX/5EU6QjdSNl+CYqfzX90eBpdXTr4ZXSbY0kmPbFaGLD7pE+hbjnXHdEOu vn39EGFl3+nf0eWTi0c8PBrUmWmdzZ3id6zUe9ZM= Received: by mx.zohomail.com with SMTPS id 1770993307837496.13412221074225; Fri, 13 Feb 2026 06:35:07 -0800 (PST) Message-ID: <89b9eba0-0c65-4f75-9815-49f17afa2e0f@collabora.com> Date: Fri, 13 Feb 2026 11:34:57 -0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] drm/vkms: Fix bad matrix offset component multiplication To: Pekka Paalanen Cc: Louis Chauvet , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, nfraprado@collabora.com, daniels@collabora.com, kernel@collabora.com References: <20260210-vkms-composer-fix-matrix-v2-0-d1ed09cb23e8@collabora.com> <20260210-vkms-composer-fix-matrix-v2-1-d1ed09cb23e8@collabora.com> <20260212133723.1ef95fd2@eldfell> Content-Language: en-US From: Ariel D'Alessandro In-Reply-To: <20260212133723.1ef95fd2@eldfell> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ZohoMailClient: External Hi Pekka, On 2/12/26 8:37 AM, Pekka Paalanen wrote: > On Tue, 10 Feb 2026 14:44:00 -0300 > Ariel D'Alessandro wrote: > >> Pixels values are packed as 16-bit UNORM values, so the matrix offset >> components must be multiplied properly by the idempotent element -i.e. >> number 1 encoded as 16-bit UNORM-. >> >> Signed-off-by: Ariel D'Alessandro >> --- >> drivers/gpu/drm/vkms/vkms_composer.c | 13 ++++++++++--- >> 1 file changed, 10 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c >> index cd85de4ffd03d..d53ea4189c97b 100644 >> --- a/drivers/gpu/drm/vkms/vkms_composer.c >> +++ b/drivers/gpu/drm/vkms/vkms_composer.c >> @@ -17,6 +17,8 @@ >> #include "vkms_composer.h" >> #include "vkms_luts.h" >> >> +#define UNORM_16BIT_ONE (1ULL << 16) > > Hi, > > shouldn't this be 0xffff instead? Indeed, you're right, 1.0 is encoded as 0xffff. > >> + >> static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) >> { >> u32 new_color; >> @@ -139,20 +141,25 @@ VISIBLE_IF_KUNIT void apply_3x4_matrix(struct pixel_argb_s32 *pixel, >> g = drm_int2fixp(pixel->g); >> b = drm_int2fixp(pixel->b); >> >> + /* >> + * Pixels values are packed as 16-bit UNORM values, so the matrix offset >> + * components must be multiplied properly by the idempotent element -i.e. >> + * number 1 encoded as 16-bit UNORM-. >> + */ >> rf = drm_fixp_mul(drm_sm2fixp(matrix->matrix[0]), r) + >> drm_fixp_mul(drm_sm2fixp(matrix->matrix[1]), g) + >> drm_fixp_mul(drm_sm2fixp(matrix->matrix[2]), b) + >> - drm_sm2fixp(matrix->matrix[3]); >> + drm_fixp_mul(drm_sm2fixp(matrix->matrix[3]), drm_int2fixp(UNORM_16BIT_ONE)); >> >> gf = drm_fixp_mul(drm_sm2fixp(matrix->matrix[4]), r) + >> drm_fixp_mul(drm_sm2fixp(matrix->matrix[5]), g) + >> drm_fixp_mul(drm_sm2fixp(matrix->matrix[6]), b) + >> - drm_sm2fixp(matrix->matrix[7]); >> + drm_fixp_mul(drm_sm2fixp(matrix->matrix[7]), drm_int2fixp(UNORM_16BIT_ONE)); >> >> bf = drm_fixp_mul(drm_sm2fixp(matrix->matrix[8]), r) + >> drm_fixp_mul(drm_sm2fixp(matrix->matrix[9]), g) + >> drm_fixp_mul(drm_sm2fixp(matrix->matrix[10]), b) + >> - drm_sm2fixp(matrix->matrix[11]); >> + drm_fixp_mul(drm_sm2fixp(matrix->matrix[11]), drm_int2fixp(UNORM_16BIT_ONE)); >> >> pixel->r = drm_fixp2int_round(rf); >> pixel->g = drm_fixp2int_round(gf); >> > > Ok, so this is because r, g, b have the integer pixel value [0, 65535]. > A casual reader would expect them to be normalized [0.0, 1.0] (as is > possible without any loss of precision). But since they are not > normalized, multiplication by normalized 1.0 must be carried out > explicitly. > > If UNORM_16BIT_ONE was 0xffff, you would have my > Reviewed-by: Pekka Paalanen Ack, will fix in v3 and add your Reviewed-by tag then. Thanks a lot! -- Ariel D'Alessandro Software Engineer Collabora Ltd. Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK Registered in England & Wales, no. 5513718