Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp377544lqt; Mon, 18 Mar 2024 10:16:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUGy2Wf+R8+bb/eALyDcsq3G20wWc1DEi2LYT2ZK080969FdHFjVkqVDxagdSNqJIHSWqjIid2Nv3kmRhcFfRBs0mt5/VVnjXhRlEVRlg== X-Google-Smtp-Source: AGHT+IFf8t8aWfzCGA4YdndDKVHgI0jqol8uP/zGjQap5g5zb8YBOec55wuUp63G6+er97rOopgJ X-Received: by 2002:a05:620a:1094:b0:788:70fc:3a22 with SMTP id g20-20020a05620a109400b0078870fc3a22mr13947369qkk.10.1710782182722; Mon, 18 Mar 2024 10:16:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710782182; cv=pass; d=google.com; s=arc-20160816; b=a5GiLdfkjLIu7AXPwE/PceOUDNcb8WjWREVLKf63y1dGP8/e3m3nG6K+J+QqNLVsSp rGh9Z5PdifnTpKyC8yEWsjfhI5/4vkD6bILYfJsvE0aAaAMzCd9GGoovTyJA9KOsnjRv /gGE9ekFzxfeSDHDIfi9yH45bMDoAlkVRbOCksctbjvLa5Qjla+0eghyo/JLc7x1cFzO /u8Rka0t4razm9BElrI3GHfy7WbT0FsL7CaZjqAINY2BjkrZloeKDnm6IySf9e6gkI6+ /Ouej00FY5EhFRf7rZ7VPUGvp+NZcwh0PwkuW3q5KGQ7vM1UnGBkM1ORyuSLspyTzpcO oZjg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mK2diCqsvlQRKgeuUFRF4/WmHsBJ702zUryCkHm1yok=; fh=CC7FhhwwMBMjPdovXTVgsJePqVPx8TrpVildsGj6+bE=; b=z/1Clhb3y/AHW+ILCF3oHoOZ+ROxv1UACk8QQSNQBH0gk3d/7k+3KGjUXGqwbzHCOw fvm4+JbhSVI6+Aofl2npdfxPXPZVqvgP+Qk7bR6AZC5lBOdTaeLK9KXgIwojJJSo/pXv 0Vh37xB4sz9OUaB2jKZ44OnIkzxFtw3peYW6Aoq2NRLKInT/y4DN1QkwCy9quDwS7I4c mdqYMkzrT6pBpenzw6KwK+4LKE6MncPz/Nark7d6Eutdh85ItoXul1eDmsF3sqZOaKyy VENZtZWyKXBPfrnfLbMAnxpoewpY5Oz0IEblVOglHh8sRW2I/4y8gvRJh/Q539adsUYJ zYiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=My2kqKgz; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-106172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bp30-20020a05620a459e00b007885a2d38d2si10577254qkb.483.2024.03.18.10.16.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 10:16:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=My2kqKgz; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-106172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 523761C2160B for ; Mon, 18 Mar 2024 13:37:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2DED487A5; Mon, 18 Mar 2024 13:37:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="My2kqKgz" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 F3F24249EB; Mon, 18 Mar 2024 13:37:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710769035; cv=none; b=U0oK0LOk6CsnVgA0gcpRzxQyRB5Bt8BpCHyY7lohzGYKPTZSSfKcjzgn/5JYO2HFr1PcloV/TmRgN5B1P5aHq8qxlV7W5vYjcY7Hi/Qz5rYTj6AWh4kUOUKHK6X7nV6VWOA09AJxsEiZP/3F3YW4WYZG9F8x+bJUgrUK/XWlfj8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710769035; c=relaxed/simple; bh=u82l/MBNpObPyrd/rtRsi0HOp2zPMN16KTaVMbMuxec=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IidW6vmMreQBLmlS2H7cLrzNPbUB/bOETcu9xQ5Y+VDFU5FBsljsJ+3Ch1O0oCqEUOJMeNp+Vx6KqsLfawjGzCZlAq/WpxnwCYc+0Uq9LiMQ5o7iHeg7sZNMu94jBx8oB2UPnSKiWiT+YUGCr5SipiaXNMTwyc0nV9bkTChACKM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=My2kqKgz; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710769033; x=1742305033; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=u82l/MBNpObPyrd/rtRsi0HOp2zPMN16KTaVMbMuxec=; b=My2kqKgzCby75PAglA0ekpm/4P/BvPQa+JWj8bg0RY2SrMo1JhEtgwf6 edj2rLD82aDKLfXvURsIVX82mfYSorzHvgnuy6aiQE30+1vD6dINk+KX/ +7odyFkjYWggJwFAunpKJPii96roj8DAvnqyrpSgPYeQc2yDCpCiD/SR7 4IWKA+WhizlGr4uiFRDVVOJirE+VR3gOz2Ah7brafR+BAfsZWWyy82a3w ImwbohvLcoPHnxdsXABayGgAlT8ZjbiwdOzqkmXlEiSprH0oRFtOlkKmp GO0o0woBJ9xSN5bKUtXJkfZgOObQ1L5YHwc04jB2siRoGsPfiensOzLXv w==; X-IronPort-AV: E=McAfee;i="6600,9927,11016"; a="5765138" X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="5765138" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2024 06:37:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11016"; a="827781787" X-IronPort-AV: E=Sophos;i="6.07,134,1708416000"; d="scan'208";a="827781787" Received: from stinkpipe.fi.intel.com (HELO stinkbox) ([10.237.72.74]) by orsmga001.jf.intel.com with SMTP; 18 Mar 2024 06:37:05 -0700 Received: by stinkbox (sSMTP sendmail emulation); Mon, 18 Mar 2024 15:37:05 +0200 Date: Mon, 18 Mar 2024 15:37:05 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Maxime Ripard Cc: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Sandy Huang , Heiko =?iso-8859-1?Q?St=FCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Hans Verkuil , Sebastian Wick , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v9 14/27] drm/connector: hdmi: Compute bpc and format automatically Message-ID: References: <20240311-kms-hdmi-connector-state-v9-0-d45890323344@kernel.org> <20240311-kms-hdmi-connector-state-v9-14-d45890323344@kernel.org> <20240318-organic-debonair-beetle-b2817b@houat> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240318-organic-debonair-beetle-b2817b@houat> X-Patchwork-Hint: comment On Mon, Mar 18, 2024 at 01:05:22PM +0100, Maxime Ripard wrote: > Hi Ville, > > Thanks for your review ! > > On Fri, Mar 15, 2024 at 10:05:16AM +0200, Ville Syrjälä wrote: > > On Mon, Mar 11, 2024 at 03:49:42PM +0100, Maxime Ripard wrote: > > > +static bool > > > +sink_supports_format_bpc(const struct drm_connector *connector, > > > + const struct drm_display_info *info, > > > + const struct drm_display_mode *mode, > > > + unsigned int format, unsigned int bpc) > > > +{ > > > + struct drm_device *dev = connector->dev; > > > + u8 vic = drm_match_cea_mode(mode); > > > + > > > + if (vic == 1 && bpc != 8) { > > > + drm_dbg(dev, "VIC1 requires a bpc of 8, got %u\n", bpc); > > > > Use of drm_dbg() for kms stuff is surprising. > > > > > + return false; > > > + } > > > > I don't think we have this in i915. My original impression was that you > > can use higher color depth if you can determine the sink capabilities, > > but all sinks are required to accept 640x480@8bpc as a fallback. > > > > but CTA-861-H says: > > "5.4 Color Coding & Quantization > > Component Depth: The coding shall be N-bit, where N = 8, 10, 12, or 16 > > bits/component — except in the case of the default 640x480 Video Timing 1, > > where the value of N shall be 8." > > > > So that does seem to imply that you're supposed to use exactly 8bpc. > > Though the word "default" in there is confusing. Are they specifically > > using that to indicate that this is about the fallback behaviour, or > > is it just indicating that it is a "default mode that always has to > > be supported". Dunno. I guess no real harm in forcing 8bpc for 640x480 > > since no one is likely to use that for any high fidelity stuff. > > My understanding was that CTA-861 mandates that 640x480@60Hz is > supported, and mentions it being the default timing on a few occurences, > like in section 4 - Video Formats and Waveform Timings that states "This > section describes the default IT 640x480 Video Timing as well as all of > the standard CE Video Timings.", or Section 6.2 - Describing Video > Formats in EDID "The 640x480@60Hz flag, in the Established Timings area, > shall always be set, since the 640x480p format is a mandatory default > timing." > > So my understanding is that default here applies to the timing itself, > and not the bpc, and is thus the second interpretation you suggested. > > I'll add a comment to make it clearer. > > > > +static int > > > +hdmi_compute_format(const struct drm_connector *connector, > > > + struct drm_connector_state *state, > > > + const struct drm_display_mode *mode, > > > + unsigned int bpc) > > > +{ > > > + struct drm_device *dev = connector->dev; > > > + > > > + if (hdmi_try_format_bpc(connector, state, mode, bpc, HDMI_COLORSPACE_RGB)) { > > > + state->hdmi.output_format = HDMI_COLORSPACE_RGB; > > > + return 0; > > > + } > > > + > > > + if (hdmi_try_format_bpc(connector, state, mode, bpc, HDMI_COLORSPACE_YUV422)) { > > > + state->hdmi.output_format = HDMI_COLORSPACE_YUV422; > > > + return 0; > > > + } > > > > Looks like you're preferring YCbCr 4:2:2 over RGB 8bpc. Not sure > > if that's a good tradeoff to make. > > Yeah, indeed. I guess it's a judgement call on whether we prioritise > lowering the bpc over selecting YUV422, but I guess I can try all > available RGB bpc before falling back to YUV422. > > > In i915 we don't currently expose 4:2:2 at all because it doesn't > > help in getting a working display, and we have no uapi for the > > user to force it if they really want 4:2:2 over RGB. > > I guess if the priority is given to lowering bpc, then it indeed doesn't > make sense to support YUV422, since the limiting factor is likely to be > the TMDS char rate and YUV422 12 bpc is equivalent to RGB 8bpc there. > > dw-hdmi on the other hand will always put YUV422 and YUV444 before RGB > for a given bpc, which is weird to me: > https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c#L2696 > > What is even weirder to me is that YUV422 is explicitly stated to be > 12bpc only, so there's some invalid configurations there (8 and 10 bpc). > > And given that it's order by decreasing order of preference, I'm pretty > sure it'll never actually pick any YUV or RGB > 8bpc format since RGB > 8bpc is super likely to be always available and thus picked first. 8bpc RGB is in fact mandatory. > > If we want to converge, I think we should amend this code to support > YUV420 for YUV420-only modes first, and then the RGB options like i915 > is doing. And then if someone is interested in more, we can always > expand it to other formats. > > > > + > > > + drm_dbg(dev, "Failed. No Format Supported for that bpc count.\n"); > > > + > > > + return -EINVAL; > > > +} > > > + > > > +static int > > > +hdmi_compute_config(const struct drm_connector *connector, > > > + struct drm_connector_state *state, > > > + const struct drm_display_mode *mode) > > > +{ > > > + struct drm_device *dev = connector->dev; > > > + unsigned int max_bpc = clamp_t(unsigned int, > > > + state->max_bpc, > > > + 8, connector->max_bpc); > > > + unsigned int bpc; > > > + int ret; > > > + > > > + for (bpc = max_bpc; bpc >= 8; bpc -= 2) { > > > + drm_dbg(dev, "Trying with a %d bpc output\n", bpc); > > > + > > > + ret = hdmi_compute_format(connector, state, mode, bpc); > > > > Hmm. Actually I'm not sure your 4:2:2 stuff even works since you > > check for bpc==12 in there and only call this based on the max_bpc. > > I'm not convinced max_bpc would actually be 12 for a sink that > > supports YCbCr 4:2:2 but not 12bpc RGB. > > It's another discussion we had in an earlier version, but yeah we lack > the infrastructure to support those for now. I still believe it would > require an increased max_bpc to select YUV422, otherwise things would be > pretty inconsistent with other YUV formats. Ideally I'd like to know the actual color depth of the panel independently of the supported signal color depths. Unfortunately I don't think EDID gives us that. Can't recall if DisplayID might have something a bit more sensible. Given how info->bpc works right now, I suppose it would make sense to bump it up to 12 when 4:2:2 is supported. But I've not thought through the actual implications such a change. > But yeah, we need to provide a hook to report we don't support RGB > > 8bpc for HDMI 1.4 devices. Which goes back to the previous question > actually, I believe it would still provide value to support YUV422 on > those devices, with something like: > > for (bpc = max_bpc; bpc >= 8; bpc -= 2) { > if (!connector->hdmi->funcs->validate_config(mode, RGB, bpc)) > continue; > > // Select RGB with bpc > ... > } > > if (connector->hdmi->funcs->validate_config(mode, YUV) && > hdmi_try_format_bpc(..., mode, 12, YUV422) { > // Select YUV422, 12 bpc > ... > } > > What do you think? Since 8bpc RGB must always be supported this looks like dead code to me. -- Ville Syrjälä Intel