Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4341187rwb; Mon, 31 Jul 2023 05:37:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlFn/W3JH8PIFlQ/aDQYRKRfipDM/YzKgpYvZObv0gfcJzxyHBkqVkEZiFaqNaTjX9KPoB6w X-Received: by 2002:a05:6402:2792:b0:51f:ef58:da87 with SMTP id b18-20020a056402279200b0051fef58da87mr14193490ede.2.1690807041426; Mon, 31 Jul 2023 05:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690807041; cv=none; d=google.com; s=arc-20160816; b=UQ9deQeOfQVpRe0d8Mbxj/GkAbQHzXuFpPnnAbk7/ZMvxOS4qx/n36MqDKeUd1aqpj 18xUM8xRlKS+LXDqsGEB5eJqxNkpHoqiSaL+iFrt2CoOZqPze8mUNweLD/fp+o9AtNF3 DXjOvDf93wQxJLwEMbn4kDy5/k/oF2KcfLETrUW7FvwBSi+Ilk/mYzmGwCjkF5yiduSu 9TLIhXbEbXk1F0SLaqsdoecoQZdJ2iJByGNm3na172jDj5oI7rxqEmugQ0OWcJEMkpVc Lm/6VnMDxe5IyhPUMyCgi16piBh5uPpE4vb03e/SFPIsFLGtNfWg+y6L//+/z+Mjt4oL fyEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=84p6LuV3kqjsQ38caNmFY0hjFJK8gje0eg9gedCk7+E=; fh=SNyvpGYrCFP3hHUrwZcmVFCERslokgMnpp4kiiNhfug=; b=NBpH9vlYuznpFWbvcGUAQ/z7muY4QhDznAkm99Cy2vqjAbwS5ALm9hR0gDlEiKi/6c NpyzWMIV+gP0r9CFXwN+Lq6Eg6zoNMXFfzcLfmSLTPCHvrfeV6dkNb4XQD4JI22zKC8I 5ry5rM1L1uGB4T01ltjiMpw9KUanA1x2+1b/JD+PMWnWA+HQZ/Q9p/3GhIwE0bHClOGC MNg31H2VZTuPh+eyAZfxSeO5ImWUmUhrCsuYf9/5Da8vRfVP74ABvoNRrrbXYuh17fp5 JdjtK8SqbAMExm/vm/WauuGH4gTlvRTIO0xLzxbUjaCv8CNgz2MCxn8v6PZSs65TSxUC Aogw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=GTz2z46r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020aa7d693000000b00522b10235f3si3520276edr.163.2023.07.31.05.36.56; Mon, 31 Jul 2023 05:37:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=GTz2z46r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231311AbjGaL5u (ORCPT + 99 others); Mon, 31 Jul 2023 07:57:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbjGaL5s (ORCPT ); Mon, 31 Jul 2023 07:57:48 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69091A2 for ; Mon, 31 Jul 2023 04:57:44 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fb4146e8fcso30403325e9.0 for ; Mon, 31 Jul 2023 04:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1690804663; x=1691409463; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=84p6LuV3kqjsQ38caNmFY0hjFJK8gje0eg9gedCk7+E=; b=GTz2z46rZqYVBJe9xcSwdI+7QtxocDHZoo1lTcR4gcdpTVNr5ydA/TjcdzI0hykclb L7disChATKsEVPF6u4hk7xRzikjXvpe7rgFduzn65xRa4llxH4UELN6kJHB1RsdqGlnC CYQOP6CdntIsoXUlK7fUHOyKLvYhRp4wp0YkCVk0X4cItoCIRXYN8BBD9ouZqBX/EY6P ixzwbtZ18fTtR0HzOLz+QOUfZJNH1nHp/u/H3fON9ulfoQlX83OtHvmyg23yYZ7s82Aa gIbAA0DTaGmlGjxGumCPYF0TYh0NOvda6E4bScxmSxtoLzgFpY17O2jwV1Ti8pqqvKuP 4BQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690804663; x=1691409463; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=84p6LuV3kqjsQ38caNmFY0hjFJK8gje0eg9gedCk7+E=; b=U6nvRbvqCQzYjbmKOxzitf9w6dYHgp4uEv67Y+EbyQJXBRtoglbS4F+Hh9ib7PFrL5 aCdnVoYij4Ar8MYg+d3EHkFGvWBTuUy1F0PXX2U6/gFnuRo+us06s/ibFp0eX8/PFqAu h5XRiGAD9/iudfW7KUKwe8VLSVrrK3RUO7xPNZlFFMp0zVyBhdiPjY/nsudBxZPohFqk LtByj++jhNy9pv7hrqfJ1ntCwT0r78Wm1zVwgMxpUqyB/HU4jiKvDdv4RyoEjUm6LVG9 w5CLetbo3gUQoT24UwHLdBvNqECj+BBDjbk+RizIiqO21TVyHM79hd6z4KJQNutKSi5Z N1Sg== X-Gm-Message-State: ABy/qLb8k8oE3f6y7ePOEeKfxZjyqcusWiwX9sUH38a7QKB7uuUbDp9v sCT6f19ORKwbzfDjuZAo6qE6iA== X-Received: by 2002:a05:600c:20c4:b0:3f7:e660:cdc5 with SMTP id y4-20020a05600c20c400b003f7e660cdc5mr7884275wmm.9.1690804662970; Mon, 31 Jul 2023 04:57:42 -0700 (PDT) Received: from [192.168.1.172] ([93.5.22.158]) by smtp.gmail.com with ESMTPSA id z19-20020a1c4c13000000b003fe20db88ebsm2894966wmf.31.2023.07.31.04.57.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Jul 2023 04:57:42 -0700 (PDT) Message-ID: <0de4d9fe-39ac-5efa-8344-428f0074adeb@baylibre.com> Date: Mon, 31 Jul 2023 13:57:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH RESEND v6 09/11] drm/mediatek: gamma: Add support for 12-bit LUT and MT8195 Content-Language: en-US To: AngeloGioacchino Del Regno , chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wenst@chromium.org, kernel@collabora.com, ehristev@collabora.com, "Jason-JH . Lin" References: <20230727094633.22505-1-angelogioacchino.delregno@collabora.com> <20230727094633.22505-10-angelogioacchino.delregno@collabora.com> <8b9769f3-8a7c-3607-ca9a-09443cfbc9d9@collabora.com> <0b9d62d0-5958-2b0f-03d7-9e91e026c33d@baylibre.com> <4e0bcb82-03f7-66de-19ec-9cc23f95ddad@collabora.com> From: Alexandre Mergnat In-Reply-To: <4e0bcb82-03f7-66de-19ec-9cc23f95ddad@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31/07/2023 12:27, AngeloGioacchino Del Regno wrote: > Il 28/07/23 14:58, Alexandre Mergnat ha scritto: >> Hi Angelo >> >> On 27/07/2023 15:06, AngeloGioacchino Del Regno wrote: >>>>> +/* For 10 bit LUT layout, R/G/B are in the same register */ >>>>>   #define DISP_GAMMA_LUT_10BIT_R            GENMASK(29, 20) >>>>>   #define DISP_GAMMA_LUT_10BIT_G            GENMASK(19, 10) >>>>>   #define DISP_GAMMA_LUT_10BIT_B            GENMASK(9, 0) >>>>> +/* For 12 bit LUT layout, R/G are in LUT, B is in LUT1 */ >>>> >>>> As I understood from the application processor registers (v0.4), R/G >>>> are in LUT, B is in LUT1 for 10bit and 12bit for MT8195. Can you >>>> check please to be sure ? >>>> >>> >>> That's right, but here I'm implying that 10-bit LUT is only for older >>> SoCs, and >>> all of them have got the same register layout with one LUT register >>> for R, G, B, >>> while all the new SoCs, which have got 12-bits LUT support, have got >>> the new >>> register layout with two LUT registers (and multiple banks). >>> Infact, the MT8195 SoC was added here with 12-bits LUT support only >>> (as the LUT >>> parameters extraction is easily handled by the >>> drm_color_lut_extract() function). >>> >>> The alternative would've been to add two compatibles, like >>> "mediatek,mt8195-disp-gamma-10bits" and >>> "mediatek,mt8195-disp-gamma-12bits", >>> or a boolean property like "mediatek,lut-12bits" which would appear >>> literally >>> everywhere starting from a certain point in time (since there's no >>> reason to >>> use 10-bits LUT on MT8195, that starts now!). >>> >>> Even then, consider the complication in code, where >>> mtk_gamma_set_common() >>> would have to handle: >>> - 10-bits, layout A >>> - 10-bits, layout B -> but fallback to layout A if this is AAL >>> - 12-bits layout >>> >>> is_aal = !(gamma && gamma->data); >>> >>> for_each_bank() >>> { >>>      if (num_lut_banks > 1) write_num_bank(); >>> >>>      for (i = 0; i < lut_bank_size; i++) { >>>          ....... >>> >>>          if (!lut_diff || (i % 2 == 0)) { >>>              if (lut_bits == 12 || (lut_bits == 10 && layout_b)) { >>>                  ... setup word[0],[1] ... >>>              } else if (layout_b && !is_aal) { >>>                  ...setup word[0],[1]... >>>              } else { >>>                  ...setup word[0] >>>              } >>>          } else { >>>               ^^^ almost repeat the same ^^^ >>>          } >>>          writel(word[0], (...)); >>>          if (lut_bits == 12 || (lut_bits == 10 && layout_b) && !is_aal) >>>              writel(word[i] (....)); >>>      } >>> } >>> >>> probe() { >>>      if (of_property_read_bool(dev->of_node, "mediatek,lut-12bits") || >>>          data->supports_only_12bits) >>>          priv->lut_bits = 12; >>>      else >>>          priv->lut_bits = 10; >>> } >>> >>> ...at least, that's the implementation that I would do to solve your >>> concern, >>> which isn't *too bad*, but still, a big question arises here... >>> >>> >>> Why should we care about supporting *both* 10-bit and 12-bit Gamma >>> LUTs on >>> the *same* SoC? >>> >>> >>> A 12-bit LUT gives us more precision and there's no penalty if we >>> want to >>> convert a 10-bit LUT to a 12-bits one, as we're simply "ignoring" the >>> value >>> of two bits per component (no expensive calculation involved)... >>> >>> Is there anything that I'm underestimating here? >> >> Thanks for you explanation ! >> I think your choice is not bad, but it's not clear that MT8195 10 bit >> LUT isn't supported at all. >> So, IMHO, the first solution is to support it like you explained it >> above, and the second solution is to add comment somewhere to clarify >> that driver doesn't support 10 bit LUT if the SoC is able to use 12 >> bit LUT, like MT8195 10 bit. >> >> Is that relevant ? :D >> > > Even though the same as whhat I'm doing here was already done before, as > the > current 10-bits LUT support ignores 9-bits LUT support, I can add a > comment to > the code: > > /* >  * SoCs supporting 12-bits LUTs are using a new register layout that does >  * always support (by HW) both 12-bits and 10-bits LUT but, on those, we >  * ignore the support for 10-bits in this driver and always use 12-bits. >  * >  * Summarizing: >  * - SoC HW support 9/10-bits LUT only >  *   - Old register layout >  *     - 10-bits LUT supported >  *     - 9-bits LUT not supported >  * - SoC HW support both 10/12bits LUT >  *   - New register layout >  *    - 12-bits LUT supported >  *    - 10-its LUT not supported >  */ > > Where the SoCs supporting 9-bits and 10-bits: mt6795, 8173, 8192,others and > 12-bits are 8195, 8186, others.. of course. > > Would that work for you? Sound good for me. After that: Reviewed-by: Alexandre Mergnat -- Regards, Alexandre