Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp28434pxh; Thu, 7 Apr 2022 13:00:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAxpdMpr9UwHkFZPKBKeIkBlwmJex8qPNXys7oiVEqueLAiqZDHO6zZ0dqUOgTawzn0SEw X-Received: by 2002:a17:90b:1811:b0:1c7:832a:3388 with SMTP id lw17-20020a17090b181100b001c7832a3388mr17826454pjb.40.1649361638432; Thu, 07 Apr 2022 13:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649361638; cv=none; d=google.com; s=arc-20160816; b=YVhFNAaMntIO/YXwNM0tJM5viDG4K/dL1m1ZUAqXDKzOr/sTnLW+eiWtwVCvb99R/r 2jaR9FldYyp39HRp87LvBQTkPn5zPdWh1McoiVirHlxHdtlP0LcTATgJr96IQ1T7cza/ 2lXccZKbRSqb+Yd0bEO1KGgzv4VHlNJql5Vxf4c3TCh2yMNfRO2XROY8J7gd7NhL2RlG zeTwjzDnQFYyFDCwx66lrWtdNpZyPl02PK1KMAV2Urq0+jg3f4tA942eZ0ZXuUcboLLe 0dFT3SO82VSXS89YWbf4Q/4nTVsAWEdQocbSbhFR7NgBcCXyZxvGUdpZXDvMwZOHSrPw RFPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=HiSVc0ytRqP1ZR3LiiFmgC32MkGIQ9+sLPFAabHsH64=; b=h+fSKJnd6gc0UF6ujJ3TnFy5ipEa39/bjb9+AmgyR1A/WwwqbXealIKLVGmZguvVIo Xr4uUTQWDboquS4cSHe8Vl9Ksu6GarbMzUiBTcvvbK9ZQm349nFyfHXfLRbeWqWv6G47 9yaW4iHis1zhADGAjfUsv/D6Vg1vAqYXlYDH19RAVep3bASW3brDK4XvXI/HW/1vmaET PoY3r4oSgTIxy64tQNBmvb1JeGTNN9wbh7CQ7J+UxgHtEKqd0qNbjg/OVrEF1SgrrpBl StkloZB1GqXUuIh5fQhfKwCtO6LcjTm4QVPaB0XAWu1zKB9J6oGeArYjcFX3/WV5tn6w ifpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@goldelico.com header.s=strato-dkim-0002 header.b=MhhqRxpQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n12-20020a170903404c00b00153f463a7e2si490775pla.126.2022.04.07.13.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:00:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@goldelico.com header.s=strato-dkim-0002 header.b=MhhqRxpQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AB7FF286F6D; Thu, 7 Apr 2022 12:26:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238300AbiDGLSj (ORCPT + 99 others); Thu, 7 Apr 2022 07:18:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244773AbiDGLSI (ORCPT ); Thu, 7 Apr 2022 07:18:08 -0400 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [81.169.146.167]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 396B55D19C; Thu, 7 Apr 2022 04:16:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1649330147; s=strato-dkim-0002; d=goldelico.com; h=To:References:Message-Id:Cc:Date:In-Reply-To:From:Subject:Cc:Date: From:Subject:Sender; bh=HiSVc0ytRqP1ZR3LiiFmgC32MkGIQ9+sLPFAabHsH64=; b=MhhqRxpQgrGpuKy6t/DDwUDbj44Y9UGf9+tq9+E1aLIJNo99vBMaJtlsOBflf32q24 CxMrQn2TVBi943FcTKdwHxFOegQk21tTFQETYsQRv/9fN95NGlZI7QWNB7ua9OrA+dYY lgVFnNTJEtLWmIC4/tClzYIxs0XDPUH5CkAHUXiLQb9zlKor5ZHFYFwKFXiBzP3L+hV8 SxI9uZHqjy4LTAvdaZ/kCXpR/Z/MpScDn8N/rhtpqeCCsj0B6DGQqRsv7hjHqabUouF0 py4HCPZ5ab92OQm7hd6r9f4nuQgxSIw2AVvYpgmrSkJuZGe9wbyHL1QmaRhQrvXkdUAr ZfQA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":JGIXVUS7cutRB/49FwqZ7WcJeFKiMgPgp8VKxflSZ1P34KBj7gpw91N5y2S3i8MRqg==" X-RZG-CLASS-ID: mo00 Received: from imac.fritz.box by smtp.strato.de (RZmta 47.42.2 DYNA|AUTH) with ESMTPSA id k708cfy37BFjjwz (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Thu, 7 Apr 2022 13:15:45 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.21\)) Subject: Re: [PATCH v17 4/6] drm/bridge: dw-hdmi: handle unusable or non-configured CSC module From: "H. Nikolaus Schaller" In-Reply-To: <0a8e4e32-cc86-e901-364b-d1e6e2bd37b5@baylibre.com> Date: Thu, 7 Apr 2022 13:15:44 +0200 Cc: Andrzej Hajda , Robert Foss , Paul Boddie , Laurent Pinchart , Jernej Skrabec , David Airlie , Daniel Vetter , Paul Cercueil , Maxime Ripard , Kieran Bingham , letux-kernel@openphoenux.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jonas Karlman Content-Transfer-Encoding: quoted-printable Message-Id: <0AB1B9C7-3FCC-4466-91FC-71A63D2376DF@goldelico.com> References: <8de76ca2b478016f4dbed84e37db231e7810e56c.1649262368.git.hns@goldelico.com> <0a8e4e32-cc86-e901-364b-d1e6e2bd37b5@baylibre.com> To: Neil Armstrong X-Mailer: Apple Mail (2.3445.104.21) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 Hi Neil, > Am 07.04.2022 um 10:28 schrieb Neil Armstrong = : >=20 > Hi, >=20 > On 06/04/2022 18:26, H. Nikolaus Schaller wrote: >> From: Neil Armstrong >> The dw-hdmi integrates an optional Color Space Conversion feature = used >> to handle color-space conversions. >> On some platforms, the CSC isn't built-in or non-functional. >> This adds the necessary code to disable the CSC functionality >> and limit the bus format negotiation to force using the same >> input bus format as the output bus format. >> Signed-off-by: Neil Armstrong >> Signed-off-by: H. Nikolaus Schaller >> --- >> drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 100 = +++++++++++++++------- >> drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 1 + >> include/drm/bridge/dw_hdmi.h | 1 + >> 3 files changed, 71 insertions(+), 31 deletions(-) >> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c = b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c >> index f50af40e10340..b5a665c5e406e 100644 >> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c >> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c >> @@ -158,6 +158,8 @@ struct dw_hdmi { >> struct hdmi_data_info hdmi_data; >> const struct dw_hdmi_plat_data *plat_data; >> + bool csc_available; /* indicates if the CSC engine = is usable */ >> + >> int vic; >> u8 edid[HDMI_EDID_LEN]; >> @@ -1009,9 +1011,10 @@ static int is_color_space_interpolation(struct = dw_hdmi *hdmi) >> static bool is_csc_needed(struct dw_hdmi *hdmi) >> { >> - return is_color_space_conversion(hdmi) || >> - is_color_space_decimation(hdmi) || >> - is_color_space_interpolation(hdmi); >> + return hdmi->csc_available && >> + (is_color_space_conversion(hdmi) || >> + is_color_space_decimation(hdmi) || >> + is_color_space_interpolation(hdmi)); >> } >> static void dw_hdmi_update_csc_coeffs(struct dw_hdmi *hdmi) >> @@ -1064,6 +1067,9 @@ static void hdmi_video_csc(struct dw_hdmi = *hdmi) >> int interpolation =3D HDMI_CSC_CFG_INTMODE_DISABLE; >> int decimation =3D 0; >> + if (!hdmi->csc_available) >> + return; >> + >> /* YCC422 interpolation to 444 mode */ >> if (is_color_space_interpolation(hdmi)) >> interpolation =3D = HDMI_CSC_CFG_INTMODE_CHROMA_INT_FORMULA1; >> @@ -2665,6 +2671,7 @@ static u32 = *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge, >> u32 output_fmt, >> unsigned int *num_input_fmts) >> { >> + struct dw_hdmi *hdmi =3D bridge->driver_private; >> u32 *input_fmts; >> unsigned int i =3D 0; >> @@ -2683,62 +2690,81 @@ static u32 = *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge, >> /* 8bit */ >> case MEDIA_BUS_FMT_RGB888_1X24: >> input_fmts[i++] =3D MEDIA_BUS_FMT_RGB888_1X24; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_YUV8_1X24; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY8_1X16; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_YUV8_1X24; >> + input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY8_1X16; >> + } >> break; >> case MEDIA_BUS_FMT_YUV8_1X24: >> input_fmts[i++] =3D MEDIA_BUS_FMT_YUV8_1X24; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY8_1X16; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_RGB888_1X24; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY8_1X16; >> + input_fmts[i++] =3D MEDIA_BUS_FMT_RGB888_1X24; >> + } >> break; >> case MEDIA_BUS_FMT_UYVY8_1X16: >> input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY8_1X16; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_YUV8_1X24; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_RGB888_1X24; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_YUV8_1X24; >> + input_fmts[i++] =3D MEDIA_BUS_FMT_RGB888_1X24; >> + } >> break; >> /* 10bit */ >> case MEDIA_BUS_FMT_RGB101010_1X30: >> input_fmts[i++] =3D MEDIA_BUS_FMT_RGB101010_1X30; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_YUV10_1X30; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY10_1X20; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_YUV10_1X30; >> + input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY10_1X20; >> + } >> break; >> case MEDIA_BUS_FMT_YUV10_1X30: >> input_fmts[i++] =3D MEDIA_BUS_FMT_YUV10_1X30; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY10_1X20; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_RGB101010_1X30; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY10_1X20; >> + input_fmts[i++] =3D = MEDIA_BUS_FMT_RGB101010_1X30; >> + } >> break; >> case MEDIA_BUS_FMT_UYVY10_1X20: >> input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY10_1X20; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_YUV10_1X30; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_RGB101010_1X30; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_YUV10_1X30; >> + input_fmts[i++] =3D = MEDIA_BUS_FMT_RGB101010_1X30; >> + } >> break; >> /* 12bit */ >> case MEDIA_BUS_FMT_RGB121212_1X36: >> input_fmts[i++] =3D MEDIA_BUS_FMT_RGB121212_1X36; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_YUV12_1X36; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY12_1X24; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_YUV12_1X36; >> + input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY12_1X24; >> + } >> break; >> case MEDIA_BUS_FMT_YUV12_1X36: >> input_fmts[i++] =3D MEDIA_BUS_FMT_YUV12_1X36; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY12_1X24; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_RGB121212_1X36; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY12_1X24; >> + input_fmts[i++] =3D = MEDIA_BUS_FMT_RGB121212_1X36; >> + } >> break; >> case MEDIA_BUS_FMT_UYVY12_1X24: >> input_fmts[i++] =3D MEDIA_BUS_FMT_UYVY12_1X24; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_YUV12_1X36; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_RGB121212_1X36; >> + if (hdmi->csc_available) { >> + input_fmts[i++] =3D MEDIA_BUS_FMT_YUV12_1X36; >> + input_fmts[i++] =3D = MEDIA_BUS_FMT_RGB121212_1X36; >> + } >> break; >> /* 16bit */ >> case MEDIA_BUS_FMT_RGB161616_1X48: >> input_fmts[i++] =3D MEDIA_BUS_FMT_RGB161616_1X48; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_YUV16_1X48; >> + if (hdmi->csc_available) >> + input_fmts[i++] =3D MEDIA_BUS_FMT_YUV16_1X48; >> break; >> case MEDIA_BUS_FMT_YUV16_1X48: >> - input_fmts[i++] =3D MEDIA_BUS_FMT_YUV16_1X48; >> - input_fmts[i++] =3D MEDIA_BUS_FMT_RGB161616_1X48; >> + if (hdmi->csc_available) >> + input_fmts[i++] =3D MEDIA_BUS_FMT_YUV16_1X48; >> break; >> /*YUV 4:2:0 */ >> @@ -2767,15 +2793,24 @@ static int dw_hdmi_bridge_atomic_check(struct = drm_bridge *bridge, >> { >> struct dw_hdmi *hdmi =3D bridge->driver_private; >> - hdmi->hdmi_data.enc_out_bus_format =3D >> - bridge_state->output_bus_cfg.format; >> + if (!hdmi->csc_available && >> + bridge_state->output_bus_cfg.format !=3D = bridge_state->input_bus_cfg.format) { >> + dev_warn(hdmi->dev, "different input format 0x%04x & = output format 0x%04x while CSC isn't usable, fallback to safe format\n", >> + bridge_state->input_bus_cfg.format, >> + bridge_state->output_bus_cfg.format); >> + hdmi->hdmi_data.enc_out_bus_format =3D = MEDIA_BUS_FMT_FIXED; >> + hdmi->hdmi_data.enc_in_bus_format =3D = MEDIA_BUS_FMT_FIXED; >> + } else { >> + hdmi->hdmi_data.enc_out_bus_format =3D >> + bridge_state->output_bus_cfg.format; >> - hdmi->hdmi_data.enc_in_bus_format =3D >> - bridge_state->input_bus_cfg.format; >> + hdmi->hdmi_data.enc_in_bus_format =3D >> + bridge_state->input_bus_cfg.format; >> - dev_dbg(hdmi->dev, "input format 0x%04x, output format = 0x%04x\n", >> - bridge_state->input_bus_cfg.format, >> - bridge_state->output_bus_cfg.format); >> + dev_dbg(hdmi->dev, "input format 0x%04x, output format = 0x%04x\n", >> + bridge_state->input_bus_cfg.format, >> + bridge_state->output_bus_cfg.format); >> + } >> return 0; >> } >> @@ -3481,6 +3516,9 @@ struct dw_hdmi *dw_hdmi_probe(struct = platform_device *pdev, >> hdmi->cec =3D platform_device_register_full(&pdevinfo); >> } >> + /* Get CSC useability from config0 register and permit override = for platforms */ >> + hdmi->csc_available =3D !plat_data->disable_csc || (config0 & = HDMI_CONFIG0_CSC); >> + >> drm_bridge_add(&hdmi->bridge); >> return hdmi; >> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h = b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h >> index 1999db05bc3b2..279722e4d1898 100644 >> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h >> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h >> @@ -541,6 +541,7 @@ enum { >> /* CONFIG0_ID field values */ >> HDMI_CONFIG0_I2S =3D 0x10, >> + HDMI_CONFIG0_CSC =3D 0x04, >> HDMI_CONFIG0_CEC =3D 0x02, >> /* CONFIG1_ID field values */ >> diff --git a/include/drm/bridge/dw_hdmi.h = b/include/drm/bridge/dw_hdmi.h >> index 2a1f85f9a8a3f..b2f689cbe864c 100644 >> --- a/include/drm/bridge/dw_hdmi.h >> +++ b/include/drm/bridge/dw_hdmi.h >> @@ -157,6 +157,7 @@ struct dw_hdmi_plat_data { >> unsigned long mpixelclock); >> unsigned int disable_cec : 1; >> + unsigned int disable_csc : 1; >> }; >> struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, >=20 > Is this really still needed now you filter correctly the possible > modes in patch 1 ? I had not tried to remove them because they were needed in [PATCH v16] but indeed they are no longer needed. Something (which I personally don't understand) may have blocked it so far, but it is not worth further analyses. So we can shrink the series and no need to touch drm/bridge: dw-hdmi: any more! I'll now post a new v18. BR and thanks for review, Nikolaus