Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp130203lqi; Wed, 6 Mar 2024 12:04:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXoDdMYRl1fUP+fKLVD3fGHWtofOpQnwtuldUAUTQhhoIP8eq8WGZvTwjY7eBhe2cualT2euUoxAGmKCiNRF+E9U6PTan+0GwcGCK12Eg== X-Google-Smtp-Source: AGHT+IE3uBu68WqlKo9P0qmRgegS1uYMnN1g3Xi0zYiJxv1UrpimQiIOGmZB/KvTBNAjVghVXgYV X-Received: by 2002:a05:620a:4728:b0:788:3d93:9332 with SMTP id bs40-20020a05620a472800b007883d939332mr4880528qkb.20.1709755458137; Wed, 06 Mar 2024 12:04:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709755458; cv=pass; d=google.com; s=arc-20160816; b=XpEFYhcquvWdfd7cPoLlFKLsn81epKcZgvn6K9YVTMr9NIq+Mu5zyOjJXYlyK1WUkN dAKKpGPOtErNz82HCrmcGFHsImAjOQetWWeymlczzgclk8RIiN/ao2PaLeW18cVqAbl3 6olQJ5UeG68nvHDetuAt5ltwb5IYC1xS7eol+4ZfQaYvYIXIPKzVmzyLLlHpl8Tvs8Q0 53aMeyl9hnLNPYx64cfH5qlQ6KHpfPYZCl7fwceBW2u61uBIlCwoHtpppFvqNUY5cgK5 /AZVOHEteE+1bW1p24ERW9+CHRdK2o55GK/TPb/SHlz+LXeUA85Zhg/fNKbLlFZpwBzy PWbA== 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=0vhKe9gtGAvUA+WTNQWAqz6jCppMT1ZqPwgJ29IRvMc=; fh=4CsK72aiJy+h/EShV5QBE7/0hoTm6C2hvI6ysn6ZfMM=; b=gJhQYgnM2mY0PNDLp+/EfCfcZajo5kQRYU+JgPY/7MSe0kjAwxqirY+Y1pS2HTjtkv VjCbYfZDuVgrFvffTbNIWInKmkiR/PcGwxjf4dXERm3qCweYEdIpdwaPiKf8TroDt5J+ 9e6LwnVYS6+m0mpl3zlB4TKWOwHwRW6hcCpr6Ry1LCg4+/89voQK5Ul5KGcDteBRX6Bz 9lo59Rbkhq1HkITIu9EHRj6f2kxrUw1NGu/HxntCQDrWWfZ/CSKtmb0eSELgdcVwgEV0 TjVlF03F0YCunssNSuel4wNRThWa3Xbv3RXK9fIoXANgJuQ6bfaxyZg8Mn3CLf92s6ec vL2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=mP0AE+Hq; arc=pass (i=1 spf=pass spfdomain=riseup.net dkim=pass dkdomain=riseup.net dmarc=pass fromdomain=riseup.net); spf=pass (google.com: domain of linux-kernel+bounces-94524-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94524-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g10-20020a67e20a000000b00472eb10b846si424414vsa.294.2024.03.06.12.04.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:04:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94524-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=mP0AE+Hq; arc=pass (i=1 spf=pass spfdomain=riseup.net dkim=pass dkdomain=riseup.net dmarc=pass fromdomain=riseup.net); spf=pass (google.com: domain of linux-kernel+bounces-94524-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94524-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C59C41C21D4D for ; Wed, 6 Mar 2024 20:04:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF5481428E5; Wed, 6 Mar 2024 20:03:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=riseup.net header.i=@riseup.net header.b="mP0AE+Hq" Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6]) (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 A0680140386 for ; Wed, 6 Mar 2024 20:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.252.153.6 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709755429; cv=none; b=rygOAasGqSQs9gn6i+C6EFk8h5mH0PYsntNHzahlP6XPEHK6fuolLBB7p6OwjJJ41SZMGBNZiQ7ftE/Fma1yK+/KepxXXq/nM9prag/DPMrfvuOKAAQSiStsZV43wvwKdLFaY3fMD7AvjxiMse2SF6qmzriENHbm9bY3aZtT+gM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709755429; c=relaxed/simple; bh=h0PodFS5qCsCyCWWmRwb25OxPxljdoN865Ax2gcERF0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W1PM8r/CElea7sa4VpI0gjuiHaR2rHzneOdEm/PylTY13OjALTkQN2ld88/12KwTXtsPoAWiphCaomr7lMjhZa9LOPgn9xadsbftSj+a43o5L+WUagGW4WzqAqWoq7ioypbICC4lGlkKbCjHUbjQlSV+rTPBAPD+3Q8KaZWVpbo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riseup.net; spf=pass smtp.mailfrom=riseup.net; dkim=pass (1024-bit key) header.d=riseup.net header.i=@riseup.net header.b=mP0AE+Hq; arc=none smtp.client-ip=198.252.153.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=riseup.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=riseup.net Received: from fews02-sea.riseup.net (fews02-sea-pn.riseup.net [10.0.1.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx0.riseup.net (Postfix) with ESMTPS id 4Tqjzw02wBz9wM4; Wed, 6 Mar 2024 20:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1709755420; bh=h0PodFS5qCsCyCWWmRwb25OxPxljdoN865Ax2gcERF0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mP0AE+HqWm0eUi+j3N/Wu3jiqQoq/TVRhdxuYjQCy+At5EB+lJElGd69IZfSDsJ6d PEcw7wJMidM6niyzA+lEU3owS0wTQbnIvKZbmwQGxZGx9izmjWbRuauZRYPLpekMHB 0QOcInocEFyxirvBg7jbcl4iUrqrymFArYdywH20= X-Riseup-User-ID: 4C21D9B088B280759A744A19E3AD30C66DC2FF9F68FF7EEE6FD7EEE672255839 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews02-sea.riseup.net (Postfix) with ESMTPSA id 4Tqjzp2fpVzFvsm; Wed, 6 Mar 2024 20:03:34 +0000 (UTC) From: Arthur Grillo Date: Wed, 06 Mar 2024 17:03:09 -0300 Subject: [PATCH 2/7] drm/vkms: Add comments Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240306-louis-vkms-conv-v1-2-5bfe7d129fdd@riseup.net> References: <20240306-louis-vkms-conv-v1-0-5bfe7d129fdd@riseup.net> In-Reply-To: <20240306-louis-vkms-conv-v1-0-5bfe7d129fdd@riseup.net> 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, Louis Chauvet 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 Signed-off-by: Arthur Grillo --- drivers/gpu/drm/vkms/vkms_formats.c | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c index 44d9b9b3bdc3..55ed3f598bd7 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -577,6 +577,18 @@ get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, }, .y_offset = 0, }; + + /* + * Those matrixies were generated using the colour python framework + * + * Below are the function calls used to generate eac matrix, go to + * https://colour.readthedocs.io/en/develop/generated/colour.matrix_YCbCr.html + * for more info: + * + * numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.601"], + * is_legal = False, + * bits = 8) * 2**32).astype(int) + */ static struct conversion_matrix yuv_bt601_full = { .matrix = { { 4294967296, 0, 6021544149 }, @@ -585,6 +597,12 @@ get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, }, .y_offset = 0, }; + + /* + * numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.601"], + * is_legal = True, + * bits = 8) * 2**32).astype(int) + */ static struct conversion_matrix yuv_bt601_limited = { .matrix = { { 5020601039, 0, 6881764740 }, @@ -593,6 +611,12 @@ get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, }, .y_offset = 16, }; + + /* + * numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.709"], + * is_legal = False, + * bits = 8) * 2**32).astype(int) + */ static struct conversion_matrix yuv_bt709_full = { .matrix = { { 4294967296, 0, 6763714498 }, @@ -601,6 +625,12 @@ get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, }, .y_offset = 0, }; + + /* + * numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.709"], + * is_legal = True, + * bits = 8) * 2**32).astype(int) + */ static struct conversion_matrix yuv_bt709_limited = { .matrix = { { 5020601039, 0, 7729959424 }, @@ -609,6 +639,12 @@ get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, }, .y_offset = 16, }; + + /* + * numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.2020"], + * is_legal = False, + * bits = 8) * 2**32).astype(int) + */ static struct conversion_matrix yuv_bt2020_full = { .matrix = { { 4294967296, 0, 6333358775 }, @@ -617,6 +653,12 @@ get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, }, .y_offset = 0, }; + + /* + * numpy.around(colour.matrix_YCbCr(K=colour.WEIGHTS_YCBCR["ITU-R BT.2020"], + * is_legal = True, + * bits = 8) * 2**32).astype(int) + */ static struct conversion_matrix yuv_bt2020_limited = { .matrix = { { 5020601039, 0, 7238124312 }, @@ -625,6 +667,11 @@ get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, }, .y_offset = 16, }; + + /* + * The next matrices are just the previous ones, but with the first and + * second columns swapped + */ static struct conversion_matrix yvu_bt601_full = { .matrix = { { 4294967296, 6021544149, 0 }, -- 2.43.0