Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1980006rdd; Thu, 11 Jan 2024 15:54:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhdM9On732IYx92roCIfoMOWtfQ6PfBlVhyuQCxIzgC9LcbQAaU74VZ42egSuorNJPl/aK X-Received: by 2002:a17:902:694b:b0:1d3:ee8d:25db with SMTP id k11-20020a170902694b00b001d3ee8d25dbmr70684plt.117.1705017280908; Thu, 11 Jan 2024 15:54:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705017280; cv=none; d=google.com; s=arc-20160816; b=bXdThjctQs6F0ZLe9kwPefGMryDvVCp1pg7xwejz6c0ptDrjKplQs7u0eKt1nIIXJ0 jgPjhviwpdHu8I81R6mDopi8MtaQpPezafxryYCaJSMDGicSWxFIbhlKS6AAOzkGcx4V h5YMiL0SjYa7+lSG2Ma/ek8NMPL5WDWessiPMXZvBsgu2/qVM0asBggkvptgNSdLIFFj YCU5uq9G58Znaj/oAvCJ3xZ9jqnMczKq9Bf42wK92d8z87z2GN3bWa77Sm/CSc9Vns9h 2qx84OUj5VzBcr+eqBpnYq62TqVbj95GToA9GUC1+8fGAs/mjdAUPtpWMuOjCYcEeNSf mJHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=y3IfLCse3UJcBLmJvnzPNY6fFxZA/lm8oP7csgqnKhM=; fh=s3xh8pfuoj+mz/09Ogsd0/AQ653x1LHEr+Pzfc/rE1U=; b=mArQLZQw15DmzvtwtS5FzS+QInnPhWlGlqUwu0eMP2lp/78J7wfUSZ3j/Sy0ceJyiA ep+pN5Y+0w0i4RkGMJk2+N3kSN4pIRmHnJ+qmnIneRF0+hEfd/auo+N7GOg4cArdnFCC GosShYNcRWmy+O9u5i+nsURgTJ1g+oxBaNkTL5YKK00+c4AQVWU8GQVXPELPULAM4XLD g+zRsYvj5brjEloJKQMcn0ILvd0ul7ZVSEGOMwbgCiKq2JxhsKkTZec99l1sLi2Xt1ov S111it8yyntzkYk0fydlaYXow613CzxoFRU9NiWYBP8RUW1rjHBvRvoBuwGbkv/+sEtl Pt7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxedocomputers.com header.s=default header.b=U7gPxWWb; spf=pass (google.com: domain of linux-kernel+bounces-24150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tuxedocomputers.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id kw16-20020a170902f91000b001d595dcd662si1500109plb.463.2024.01.11.15.54.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 15:54:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxedocomputers.com header.s=default header.b=U7gPxWWb; spf=pass (google.com: domain of linux-kernel+bounces-24150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tuxedocomputers.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8AAC7283BBA for ; Thu, 11 Jan 2024 23:54:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DFF85A0E9; Thu, 11 Jan 2024 23:54:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=tuxedocomputers.com header.i=@tuxedocomputers.com header.b="U7gPxWWb" Received: from mail.tuxedocomputers.com (mail.tuxedocomputers.com [157.90.84.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B9555A0E1 for ; Thu, 11 Jan 2024 23:54:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=tuxedocomputers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxedocomputers.com Received: from [192.168.42.20] (p5de453e7.dip0.t-ipconnect.de [93.228.83.231]) (Authenticated sender: wse@tuxedocomputers.com) by mail.tuxedocomputers.com (Postfix) with ESMTPSA id ED4E52FC004D; Fri, 12 Jan 2024 00:54:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxedocomputers.com; s=default; t=1705017262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y3IfLCse3UJcBLmJvnzPNY6fFxZA/lm8oP7csgqnKhM=; b=U7gPxWWbUFgN6lR9PsCx7iFIS7VaYhSRtvW7k9kPEBaiN4r3yiJwU4qffqhS9RcYXp3ZN/ mHzpt5VeY5o7vPpbpXc+ErHgvQLLYXqpY0PuH9eMMmC/6gUpiGjAWAl7mItLea8tk/IXDj hO7qEu4WW/MNPC5ofwyVgOofQIJu00Q= Authentication-Results: mail.tuxedocomputers.com; auth=pass smtp.auth=wse@tuxedocomputers.com smtp.mailfrom=wse@tuxedocomputers.com Message-ID: <2a74b609-1f75-4179-8e63-7825a0d39166@tuxedocomputers.com> Date: Fri, 12 Jan 2024 00:54:21 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/7] drm/amd/display: Add handling for new "active color format" property To: Andri Yngvason Cc: Tvrtko Ursulin , Joonas Lahtinen , Thomas Zimmermann , intel-gfx@lists.freedesktop.org, Leo Li , David Airlie , dri-devel@lists.freedesktop.org, "Pan, Xinhui" , Rodrigo Siqueira , linux-kernel@vger.kernel.org, Maxime Ripard , Jani Nikula , Daniel Vetter , Rodrigo Vivi , Alex Deucher , Maarten Lankhorst , Simon Ser , amd-gfx@lists.freedesktop.org, Harry Wentland , =?UTF-8?Q?Christian_K=C3=B6nig?= References: <20240109181104.1670304-1-andri@yngvason.is> <20240109181104.1670304-4-andri@yngvason.is> <67808818-ee34-4d04-ad90-cd5c6eb9bb26@tuxedocomputers.com> Content-Language: en-US From: Werner Sembach In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Am 10.01.24 um 18:15 schrieb Andri Yngvason: > Hi Werner, > > mið., 10. jan. 2024 kl. 13:14 skrifaði Werner Sembach : >> Hi, >> >> Am 10.01.24 um 14:09 schrieb Daniel Vetter: >>> On Wed, 10 Jan 2024 at 13:53, Andri Yngvason wrote: >>>> mið., 10. jan. 2024 kl. 11:10 skrifaði Daniel Vetter : >>>>> On Tue, Jan 09, 2024 at 06:11:00PM +0000, Andri Yngvason wrote: >>>>>> + /* Extract information from crtc to communicate it to userspace as connector properties */ >>>>>> + for_each_new_connector_in_state(state, connector, new_con_state, i) { >>>>>> + struct drm_crtc *crtc = new_con_state->crtc; >>>>>> + struct dc_stream_state *stream; >>>>>> + >>>>>> + if (crtc) { >>>>>> + new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc); >>>>>> + dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); >>>>>> + stream = dm_new_crtc_state->stream; >>>>>> + >>>>>> + if (stream) { >>>>>> + drm_connector_set_active_color_format_property(connector, >>>>>> + convert_dc_pixel_encoding_into_drm_color_format( >>>>>> + dm_new_crtc_state->stream->timing.pixel_encoding)); >>>>>> + } >>>>>> + } else { >>>>>> + drm_connector_set_active_color_format_property(connector, 0); >>>>> Just realized an even bigger reason why your current design doesn't work: >>>>> You don't have locking here. >>>>> >>>>> And you cannot grab the required lock, which is >>>>> drm_dev->mode_config.mutex, because that would result in deadlocks. So >>>>> this really needs to use the atomic state based design I've described. >>>>> >>>> Maybe we should just drop "actual color format" and instead fail the >>>> modeset if the "preferred color format" property cannot be satisfied? >>>> It seems like the simplest thing to do here, though it is perhaps less >>>> convenient for userspace. In that case, the "preferred color format" >>>> property should just be called "color format". >>> Yeah that's more in line with how other atomic properties work. This >>> way userspace can figure out what works with a TEST_ONLY commit too. >>> And for this to work you probably want to have an "automatic" setting >>> too. >>> -Sima >> The problem with TEST_ONLY probing is that color format settings are >> interdependent: https://gitlab.freedesktop.org/drm/amd/-/issues/476#note_966634 >> >> So changing any other setting may require every color format to be TEST_ONLY >> probed again. >> > If we put a bit map containing the possible color formats into > drm_mode_mode_info (I'm thinking that it could go into flags), we'd be > able to eliminate a bunch of combinations early on. Do you think that > would make things more bearable? That would eliminate some, but note that for example YCBCR444 needs a faster pixel clock then YCBCR420, so it's interdependent with everything else that changes the required pixel clock like bpc, resolution and refresh rate. So the config space is n-dimensional with no "right angle box" clearly separating working from non working combinations. But I just had the idea: Currently in KDE and Gnome UI you first select the resolution, to then wee what refresh rates are available. So I guess this concept could be appended to color properties -> Define a sequence for the different properties to be applied across all drivers and as soon as you select one, the next property in the sequence is TEST_ONLYed. e.g.: 1. Select resolution -> Available refresh rates are updated 2. Select refresh rate -> Available color formats are updated 3. Select color format -> Available bpc are updated etc. So you can't select a bpc that doesn't fit your current color format. Changing color format can change the available bpc. One maybe counter intuitive thing here is that color format "auto" might not have all bpc settings available, as auto will for example actually be RGB which has higher pixel clock requirements then ycbcr420. And in this model, color format is always decided first. Or vice versa if bpc is decided to be before color format in the sequence. > > I'm thinking, something like this: > diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h > index 128d09138ceb3..59980803cb89e 100644 > --- a/include/uapi/drm/drm_mode.h > +++ b/include/uapi/drm/drm_mode.h > @@ -124,6 +124,13 @@ extern "C" { > #define DRM_MODE_FLAG_PIC_AR_256_135 \ > (DRM_MODE_PICTURE_ASPECT_256_135<<19) > > +/* Possible color formats (4 bits) */ > +#define DRM_MODE_FLAG_COLOR_FORMAT_MASK (0x0f << 22) > +#define DRM_MODE_FLAG_COLOR_FORMAT_RGB (1 << 22) > +#define DRM_MODE_FLAG_COLOR_FORMAT_YCBCR444 (1 << 23) > +#define DRM_MODE_FLAG_COLOR_FORMAT_YCBCR422 (1 << 24) > +#define DRM_MODE_FLAG_COLOR_FORMAT_YCBCR420 (1 << 25) > + > #define DRM_MODE_FLAG_ALL (DRM_MODE_FLAG_PHSYNC | \ > DRM_MODE_FLAG_NHSYNC | \ > DRM_MODE_FLAG_PVSYNC | \ > @@ -136,7 +143,8 @@ extern "C" { > DRM_MODE_FLAG_HSKEW | \ > DRM_MODE_FLAG_DBLCLK | \ > DRM_MODE_FLAG_CLKDIV2 | \ > - DRM_MODE_FLAG_3D_MASK) > + DRM_MODE_FLAG_3D_MASK | \ > + DRM_MODE_FLAG_COLOR_FORMAT_MASK) > > /* DPMS flags */ > /* bit compatible with the xorg definitions. */