Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2966179pxb; Mon, 17 Jan 2022 09:07:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEjRJJxtUOyG1jqZ70C1JyKQvYuh1fa2g4ZsIejIqVd0U46yg0U64rYe7PTrSnTcZoYoew X-Received: by 2002:a05:6a00:cc6:b0:4c3:b9cd:f088 with SMTP id b6-20020a056a000cc600b004c3b9cdf088mr8847282pfv.48.1642439279119; Mon, 17 Jan 2022 09:07:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642439279; cv=none; d=google.com; s=arc-20160816; b=C9HUJhP7NwGc4YlyNRO62fYlr1fBkBrcjE4GX3v96N59E5uCXN5hINAFTYMJrpEUL/ hSr+BhcutrCbyZY/OTRjvEVwhkyUGdsw5B+pYQAGstDTX56FrLOajAi07ICEPeOmV9n/ 5HUcGW/TPB+Q8O1Adm6caGUsF6WQPUOqTb/Z1m8OqAoyY11OQ11pMwjOZCwzjzxHFTAI lHXPhAANOZlU4U5+QCvvLQHQ6mYogI6dTmB6xZJWymQ/ZPDEibZVGEk7rbfhbvlGP1VU CLeWNaqKO/7toyvaTnh1y9BUOTE9nAcH8LXE634loyT0WKzCfNTSNDdJLBjnB2eQ5/a3 MkCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :references:cc:to:from:subject:dkim-signature; bh=IYRaNLgJ4yJzlec8LXTkLzqBlWzt7l+Bmtx38lvJCNM=; b=FAPhlOdsY2YN7oW0GRPJNfIA5WJQYr77KDZjsiMrezuAb0GA5Lp1yfnwSUziQhfiBp 30fJg2A9ttOKcea7Gksu8A3BKJhKm1p8itiO5drpyDh4J+G+69Z+EqOFIoyc470tj+D+ Jeo3dlS874h6m04sW594+WT4Ibdo575EoV9Kt0/Zfh2FPsUqPrqulQ48hJGPpclAVwaq RNE+SsviC7P/y6LxlufQ7YbmUGkY2jwwY2FYY03F6JzATDkx5r7XXgaPfXHp3rW7F9pF HWgaUcF1wOkaW8i+pOazzIbC7Hmrr8OGF0k2rj6nppRE3f4zg6o9bRGTkOWx2nAC0LKJ Io3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=eUbvF4VP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q13si16627171pfk.87.2022.01.17.09.07.44; Mon, 17 Jan 2022 09:07:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=eUbvF4VP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238482AbiAQKIl (ORCPT + 99 others); Mon, 17 Jan 2022 05:08:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236048AbiAQKIi (ORCPT ); Mon, 17 Jan 2022 05:08:38 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD55DC061574 for ; Mon, 17 Jan 2022 02:08:37 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id ay4-20020a05600c1e0400b0034a81a94607so20510311wmb.1 for ; Mon, 17 Jan 2022 02:08:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=subject:from:to:cc:references:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IYRaNLgJ4yJzlec8LXTkLzqBlWzt7l+Bmtx38lvJCNM=; b=eUbvF4VPlUlQEX3bl8gK08o8+fm2AeIL8rKeLwEm4Mgbbrcm7vUbI/1hbqHCudyrm5 dO7z6vFmeIpDI9bRVpmDfiK9h0pj7F/sZGpBjqjXtavBGd1RUJT12JzE3+noYuDFf5kO r0lorSytq3SLnxGkdYxVYiBD4JtT1A+SE6R18FcdCdKHS/rd2B5FGBsq6whtm0wrJcvn dC3UnEWaqI3qVCmJKlZYaTuk3ML9Rz1dmG2eEKZtCGEqnSz9p4QGlcPaa/diMfyXuhJS E8lowMVxN0ddv/2z+8hw8C5rCPA5nrf3qs1RxHvHt2duFF709NO7/8ez97w2h91nLzMC CEmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:from:to:cc:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=IYRaNLgJ4yJzlec8LXTkLzqBlWzt7l+Bmtx38lvJCNM=; b=jxwsuLNDlLIW2sDLii+zpzoY/yPTRJ7++P/di6kiAshPtmOUxS93J3bPoUAtaMrY1F PvccGGTpqzOXG0ZJASWKnhX9XPHMJUgAR7NFfYMGuswH/yZw+Im9ryxG6a4auNtLjN09 ppJj8+R+9kKUKlA3Zhsn78kD/iLi4HQuuDD2MnCY5zl27xjhDxuHr4Vv2+bCO9YYXs8B 1kaX3uTV08/o3mwg5vcSL8Wo2+3CmknVQKOobPwrz4ftnjsEvAo5pfycAmz9YHStuR4L TOlsjiIN53EFAIOwUJKxTIIj+rHtAfyMs6yxfb9PYndRoChJyAMKhUseAKYfzwhchtO9 VlJQ== X-Gm-Message-State: AOAM532tMG6z0w+9CBSN4VOyFFvUHJGoUUp6i+TZxlv69rqI6HAPbHcU Zk8SmJLpPXQDVJ1qA1L7bEmJcg== X-Received: by 2002:a05:600c:4fd4:: with SMTP id o20mr4478226wmq.155.1642414116397; Mon, 17 Jan 2022 02:08:36 -0800 (PST) Received: from ?IPv6:2001:861:44c0:66c0:c004:9fe1:fbda:2d0c? ([2001:861:44c0:66c0:c004:9fe1:fbda:2d0c]) by smtp.gmail.com with ESMTPSA id f17sm3458570wmq.28.2022.01.17.02.08.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jan 2022 02:08:35 -0800 (PST) Subject: Re: dw_hdmi is showing wrong colour after commit 7cd70656d1285b79("drm/bridge: display-connector: implement bus fmts callbacks") From: Neil Armstrong To: Biju Das , Fabio Estevam Cc: "daniel@ffwll.ch" , "Laurent.pinchart@ideasonboard.com" , "robert.foss@linaro.org" , "jonas@kwiboo.se" , "jernej.skrabec@gmail.com" , "martin.blumenstingl@googlemail.com" , "linux-amlogic@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" References: <502f3ec4-fea4-8e14-c7a9-39418fc05d6d@baylibre.com> <19dd6013-8a31-b2ed-29d5-93fc44193ce4@baylibre.com> <538b8da4-1201-5f45-2abf-ecd22c867358@baylibre.com> Organization: Baylibre Message-ID: <80fdc5a0-ddb8-5a0f-eb8c-ef7988ced638@baylibre.com> Date: Mon, 17 Jan 2022 11:08:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi again, On 14/01/2022 15:40, Neil Armstrong wrote: > Hi, > > On 14/01/2022 15:23, Biju Das wrote: >> >> >>> -----Original Message----- >>> From: Neil Armstrong >>> Sent: 14 January 2022 13:56 >>> To: Biju Das ; Fabio Estevam >>> >>> Cc: daniel@ffwll.ch; Laurent.pinchart@ideasonboard.com; >>> robert.foss@linaro.org; jonas@kwiboo.se; jernej.skrabec@gmail.com; >>> martin.blumenstingl@googlemail.com; linux-amlogic@lists.infradead.org; >>> linux-arm-kernel@lists.infradead.org; dri-devel@lists.freedesktop.org; >>> linux-kernel@vger.kernel.org; linux-renesas-soc@vger.kernel.org >>> Subject: Re: dw_hdmi is showing wrong colour after commit >>> 7cd70656d1285b79("drm/bridge: display-connector: implement bus fmts >>> callbacks") >>> >>> Hi, >>> >>> On 14/01/2022 12:08, Biju Das wrote: >>>> Hi Neil, >>>> >>>>> Subject: Re: dw_hdmi is showing wrong colour after commit >>>>> 7cd70656d1285b79("drm/bridge: display-connector: implement bus fmts >>>>> callbacks") >>>>> >>>>> On 14/01/2022 09:29, Biju Das wrote: >>>>>> Hi Neil, >>>>>> >>>>>> + renesas-soc >>>>>> >>>>>>> Subject: Re: dw_hdmi is showing wrong colour after commit >>>>>>> 7cd70656d1285b79("drm/bridge: display-connector: implement bus fmts >>>>>>> callbacks") >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> On 13/01/2022 21:01, Fabio Estevam wrote: >>>>>>>> Hi Biju, >>>>>>>> >>>>>>>> On Thu, Jan 13, 2022 at 2:45 PM Biju Das >>>>>>>> >>>>>>> wrote: >>>>>>>>> >>>>>>>>> Hi All, >>>>>>>>> >>>>>>>>> RZ/G2{H, M, N} SoC has dw_hdmi IP and it was working ok(colour) >>>>>>>>> till the commit >>>>>>>>> 7cd70656d1285b79("drm/bridge: display-connector: implement bus >>>>>>>>> fmts >>>>>>> callbacks"). >>>>>>>>> >>>>>>>>> After this patch, the screen becomes greenish(may be it is >>>>>>>>> setting it >>>>>>> into YUV format??). >>>>>>>>> >>>>>>>>> By checking the code, previously it used to call get_input_fmt >>>>>>>>> callback >>>>>>> and set colour as RGB24. >>>>>>>>> >>>>>>>>> After this commit, it calls get_output_fmt_callbck and returns 3 >>>>>>>>> outputformats(YUV16, YUV24 and RGB24) And get_input_fmt callback, >>>>>>>>> I see >>>>>>> the outputformat as YUV16 instead of RGB24. >>>>>>>>> >>>>>>>>> Not sure, I am the only one seeing this issue with dw_HDMI driver. >>>>>>> >>>>>>> This patch was introduced to maintain the bridge color format >>>>>>> negotiation after using DRM_BRIDGE_ATTACH_NO_CONNECTOR, but it >>>>>>> seems it behaves incorrectly if the first bridge doesn't implement >>>>>>> the negotiation callbacks. >>>>>>> >>>>>>> Let me check the code to see how to fix that. >>>>>> >>>>>> Thanks for the information, I am happy to test the patch/fix. >>>>>> >>>>>> Cheers, >>>>>> Biju >>>>>> >>>>>>> >>>>>>>> >>>>>>>> I have tested linux-next 20220112 on a imx6q-sabresd board, which >>>>> shows: >>>>>>>> >>>>>>>> dwhdmi-imx 120000.hdmi: Detected HDMI TX controller v1.30a with >>>>>>>> HDCP (DWC HDMI 3D TX PHY) >>>>>>>> >>>>>>>> The colors are shown correctly here. >>>>>>>> >>>>>>> >>>>>>> The imx doesn't use DRM_BRIDGE_ATTACH_NO_CONNECTOR so the >>>>>>> negotiation fails and use the RGB fallback input & output format. >>>>>>> >>>>>>> Anyway thanks for testing >>>>>>> >>>>>>> Neil >>>>> >>>>> Can you test : >>>>> >>>>> ==><=============================== >>>>> diff --git a/drivers/gpu/drm/drm_bridge.c >>>>> b/drivers/gpu/drm/drm_bridge.c index c96847fc0ebc..7019acd37716 >>>>> 100644 >>>>> --- a/drivers/gpu/drm/drm_bridge.c >>>>> +++ b/drivers/gpu/drm/drm_bridge.c >>>>> @@ -955,7 +955,14 @@ drm_atomic_bridge_chain_select_bus_fmts(struct >>>>> drm_bridge *bridge, >>>>> last_bridge_state = >>>>> drm_atomic_get_new_bridge_state(crtc_state- >>>>>> state, >>>>> >>>>> last_bridge); >>>>> >>>>> - if (last_bridge->funcs->atomic_get_output_bus_fmts) { >>>>> + /* >>>>> + * Only negociate with real values if both end of the bridge >>> chain >>>>> + * support negociation callbacks, otherwise you can end in a >>>>> situation >>>>> + * where the selected output format doesn't match with the >>>>> + first >>>>> bridge >>>>> + * output format. >>>>> + */ >>>>> + if (bridge->funcs->atomic_get_input_bus_fmts && >>>>> + last_bridge->funcs->atomic_get_output_bus_fmts) { >>>>> const struct drm_bridge_funcs *funcs = >>>>> last_bridge->funcs; >>>>> >>>>> /* >>>>> @@ -980,7 +987,12 @@ drm_atomic_bridge_chain_select_bus_fmts(struct >>>>> drm_bridge *bridge, >>>>> if (!out_bus_fmts) >>>>> return -ENOMEM; >>>>> >>>>> - if (conn->display_info.num_bus_formats && >>>>> + /* >>>>> + * If first bridge doesn't support negociation, use >>>>> MEDIA_BUS_FMT_FIXED >>>>> + * as a safe value for the whole bridge chain >>>>> + */ >>>>> + if (bridge->funcs->atomic_get_input_bus_fmts && >>>>> + conn->display_info.num_bus_formats && >>>>> conn->display_info.bus_formats) >>>>> out_bus_fmts[0] = conn- >>>>>> display_info.bus_formats[0]; >>>>> else >>>>> ==><=============================== >>>>> >>>>> This should exclude your situation where the first bridge doesn't >>>>> support negociation. >>>> >>>> I have tested this fix with Linux next-20220114. Still I see colour >>> issue. >>>> >>>> It is still negotiating and it is calling get_output_fmt_callbck >>>> >>>> [ 3.460155] ########dw_hdmi_bridge_atomic_get_output_bus_fmts >>> MEDIA_BUS_FMT_UYVY8_1X16=0######### >>>> [ 3.460180] ########dw_hdmi_bridge_atomic_get_output_bus_fmts >>> MEDIA_BUS_FMT_YUV8_1X24=1######### >>>> [ 3.460202] ########dw_hdmi_bridge_atomic_get_output_bus_fmts >>> MEDIA_BUS_FMT_RGB888_1X24=2######### >>>> >>>> And In get_input_fmt callback, I See the outputformat as YUV16 instead >>> of RGB24. >>>> >>>> [ 3.460319] ########dw_hdmi_bridge_atomic_get_input_bus_fmts >>> MEDIA_BUS_FMT_UYVY8_1X16######### >>>> [ 3.473644] ########hdmi_video_sample >>> MEDIA_BUS_FMT_UYVY8_1X16######### >>> >>> OK, looking at rcar-du, the dw-hdmi bridge is directly connected to the >>> encoder. >> >> Yep. >> >>> >>> Let me figure that out, no sure I can find a clean solution except putting >>> back RGB24 before YUV. >>> >>> Anyway please test that: >> >> It works now after reordering. >> >> [ 3.493302] ########dw_hdmi_bridge_atomic_get_output_bus_fmts MEDIA_BUS_FMT_RGB888_1X24=0######### >> [ 3.493326] ########dw_hdmi_bridge_atomic_get_output_bus_fmts MEDIA_BUS_FMT_YUV8_1X24=1######### >> [ 3.493348] ########dw_hdmi_bridge_atomic_get_output_bus_fmts MEDIA_BUS_FMT_UYVY8_1X16=2######### >> >> [ 3.493463] ########dw_hdmi_bridge_atomic_get_input_bus_fmts MEDIA_BUS_FMT_RGB888_1X24######### >> [ 3.506797] ########hdmi_video_sample MEDIA_BUS_FMT_RGB888_1X24######### >> >> Is it acceptable solution to the users of dw_hdmi driver? May be it is worth to post a patch. >> at least it is fixing the colour issue?? > > Yes, it gets back to default behavior before negociation, nevertheless we need to think > how to handle your use-case correctly at some point. > > I'll post this as a patch ASAP so it gets applied before landing in linus master. > > Neil > >> >> Regards, >> Biju >> >>> [...] I'm not happy with this version since it's merely a hack which makes it work. Can you test the following change instead, it's correctly handles your situation in a generic manner. ========================><============================= diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 54d8fdad395f..9f2e1cac0ae2 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -2551,8 +2551,9 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge, if (!output_fmts) return NULL; - /* If dw-hdmi is the only bridge, avoid negociating with ourselves */ - if (list_is_singular(&bridge->encoder->bridge_chain)) { + /* If dw-hdmi is the first or only bridge, avoid negociating with ourselves */ + if (list_is_singular(&bridge->encoder->bridge_chain) || + list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) { *num_output_fmts = 1; output_fmts[0] = MEDIA_BUS_FMT_FIXED; @@ -2673,6 +2674,10 @@ static u32 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge, if (!input_fmts) return NULL; + /* If dw-hdmi is the first bridge fall-back to safe output format */ + if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) + output_fmt = MEDIA_BUS_FMT_FIXED; + switch (output_fmt) { /* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */ case MEDIA_BUS_FMT_FIXED: ========================><============================= Thanks, Neil >>> >>> Neil >>> >>>> >>>> Regards, >>>> Biju >>>> >> >