Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp258286ybi; Fri, 7 Jun 2019 07:37:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDjfBmMR71uDUNOD6wy8QAeq4hW48u7ZgF2a2JgrZic08+yZk0EoT2wdOa3GvNnvxekv+T X-Received: by 2002:a63:2bd1:: with SMTP id r200mr3010330pgr.202.1559918238006; Fri, 07 Jun 2019 07:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559918237; cv=none; d=google.com; s=arc-20160816; b=FhVj6l1jx6MnymjxTlHEPd8s5bmkk3t0kHuESJfsJVcafodskRse2cYZYmwAhFkK79 H/9xXWMQdSFhjwTcTgwYhL4kIQ8dzDPq1mg0dBcaptyUO+gQuX0z6Iun5xal3N8I4fEJ /x3L/xqCI9MN8Ludqx/YympYI4v6IYG3/Srg8Y3rj88WMCh7L+tYQlP85mjjhi1ioqq9 ZbU+KD34LmU7ymjCO725qkWXsbohDHO0NAklQLw2fOfCJjigGsvPC5N+0hHqooUbtrF9 8LnIdLNuFpmuptRKMydQ10/J+G/4o7+FIWq+dYpz/N4VNAdSmCr+TuZo6B9r/aBwtxlK tdkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6SGuAGnMLCbGMBsJLIQMQXrS0tapAdzerrM/PPHHLeI=; b=eBgBUIirpoYGgIXlgpZpKVQe+zBQTV8GLYJlU0MqEAqGTYy2hrUOrnohMIu07blJcb AVD+uMoluRzWShGCjnhHKWID8B1+hGv7ZmPwNBLj50dZBC63b+soIXELU1hHyYk4PJY+ f2GzfItA3pLDT8b0g1yVcebq0XtF8M3DtR7htkWYSxKwzUMx/E8FHoQn3wRkQIQyfUob LIhGhgY+ci3yDleK4LhPbD/zxtW7I9wM85/n3D4EhGyWQO4qTYC23LjvYvFnc0sc9Js7 /4fYCnzICmR/A3ub4pPhDY0eakJqQLa79/staFukpQ+XZ3CiOKjOieKIbhldS1B4v5W2 zycg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=ZO4rdF0c; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si1850849pgj.238.2019.06.07.07.37.00; Fri, 07 Jun 2019 07:37:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=ZO4rdF0c; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728809AbfFGNil (ORCPT + 99 others); Fri, 7 Jun 2019 09:38:41 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:41766 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727600AbfFGNik (ORCPT ); Fri, 7 Jun 2019 09:38:40 -0400 Received: from pendragon.ideasonboard.com (unknown [IPv6:2a02:a03f:44f0:8500:ca05:8177:199c:fed4]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F88E334; Fri, 7 Jun 2019 15:38:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559914718; bh=cZWJM1dGWVBJvNXv07QLU66jY8fTal7gs4kQKfSyIAw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZO4rdF0cZmRzSCRE2r/yzqMnESSU+RYfuDkWC5d0d9ZFpoTzj5PIr9xSnI0SsdqXl Qf7nRCBMJPzAk5ykLUE9R8QeUFQdvrXnyxb6Z46Nr4nBzNk2IX1NxzjZQDuCw8Mp3e mf5k1OAOoyidAQCAKMXgWF/m2rKG5dBXjLcyOnkU= Date: Fri, 7 Jun 2019 16:38:18 +0300 From: Laurent Pinchart To: Neil Armstrong Cc: a.hajda@samsung.com, jernej.skrabec@siol.net, maxime.ripard@bootlin.com, jonas@kwiboo.se, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, hverkuil@xs4all.nl, linux-amlogic@lists.infradead.org Subject: Re: [PATCH 2/5] drm/bridge: add encoder support to specify bridge input format Message-ID: <20190607133818.GM7593@pendragon.ideasonboard.com> References: <20190520133753.23871-1-narmstrong@baylibre.com> <20190520133753.23871-3-narmstrong@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190520133753.23871-3-narmstrong@baylibre.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Neil, Thank you for the patch. On Mon, May 20, 2019 at 03:37:50PM +0200, Neil Armstrong wrote: > This patch adds a new format_set() callback to the bridge ops permitting > the encoder to specify the new input format and encoding. > > This allows supporting the very specific HDMI2.0 YUV420 output mode > when the bridge cannot convert from RGB or YUV444 to YUV420. > > In this case, the encode must downsample before the bridge and must > specify the bridge the new input bus format differs. > > This will also help supporting the YUV420 mode where the bridge cannot > downsample, and also support 10bit, 12bit and 16bit output modes > when the bridge cannot convert between different bit depths. > > Signed-off-by: Neil Armstrong > --- > drivers/gpu/drm/drm_bridge.c | 35 +++++++++++++++++++++++++++++++++++ > include/drm/drm_bridge.h | 19 +++++++++++++++++++ > 2 files changed, 54 insertions(+) > > diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c > index 138b2711d389..33be74a977f7 100644 > --- a/drivers/gpu/drm/drm_bridge.c > +++ b/drivers/gpu/drm/drm_bridge.c > @@ -307,6 +307,41 @@ void drm_bridge_mode_set(struct drm_bridge *bridge, > } > EXPORT_SYMBOL(drm_bridge_mode_set); > > +/** > + * drm_bridge_format_set - setup with proposed input format and encoding for > + * all bridges in the encoder chain > + * @bridge: bridge control structure > + * @input_bus_format: proposed input bus format for the bridge > + * @input_encoding: proposed input encoding for this bridge > + * > + * Calls &drm_bridge_funcs.format_set op for all the bridges in the > + * encoder chain, starting from the first bridge to the last. > + * > + * Note: the bridge passed should be the one closest to the encoder > + * > + * RETURNS: > + * true on success, false if one of the bridge cannot handle the format I would return an int to propagate the failure reason upstream. It will reach the commit tail handler in any case, so will be dropped there, but could help debugging issues if we print it in the right place. > + */ > +bool drm_bridge_format_set(struct drm_bridge *bridge, > + const u32 input_bus_format, > + const u32 input_encoding) You don't need a const here. > +{ > + bool ret = true; > + > + if (!bridge) > + return true; > + > + if (bridge->funcs->format_set) > + ret = bridge->funcs->format_set(bridge, input_bus_format, > + input_encoding); > + if (!ret) > + return ret; > + > + return drm_bridge_format_set(bridge->next, input_bus_format, > + input_encoding); I don't think this will scale. It's not that uncommon for bridges to change the format (most likely converting from YUV to RGB or the other way around, or reducing the number of bits per sample) and the encoding. We thus can't propagate it from bridge to bridge and expect that to work. At the very least, the bridge should report its output bus format and encoding, to be applied to the next bridge, but this won't allow checking if the configuration can be applied ahead of time, resulting in possible failures of a commit tail handler. I wonder if this wouldn't be a good time to introduce bridge states... > +} > +EXPORT_SYMBOL(drm_bridge_format_set); > + > /** > * drm_bridge_pre_enable - prepares for enabling all > * bridges in the encoder chain > diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h > index d4428913a4e1..7a79e61b7825 100644 > --- a/include/drm/drm_bridge.h > +++ b/include/drm/drm_bridge.h > @@ -198,6 +198,22 @@ struct drm_bridge_funcs { > void (*mode_set)(struct drm_bridge *bridge, > const struct drm_display_mode *mode, > const struct drm_display_mode *adjusted_mode); > + > + /** > + * @format_set: > + * > + * This callback should configure the bridge for the given input bus > + * format and encoding. It is called after the @format_set callback > + * for the preceding element in the display pipeline has been called > + * already. If the bridge is the first element then this would be > + * &drm_encoder_helper_funcs.format_set. The display pipe (i.e. > + * clocks and timing signals) is off when this function is called. > + * > + * @returns: true in success, false is a bridge refuses the format > + */ > + bool (*format_set)(struct drm_bridge *bridge, > + const u32 input_bus_format, > + const u32 input_encoding); > /** > * @pre_enable: > * > @@ -311,6 +327,9 @@ void drm_bridge_post_disable(struct drm_bridge *bridge); > void drm_bridge_mode_set(struct drm_bridge *bridge, > const struct drm_display_mode *mode, > const struct drm_display_mode *adjusted_mode); > +bool drm_bridge_format_set(struct drm_bridge *bridge, > + const u32 input_bus_format, > + const u32 input_encoding); > void drm_bridge_pre_enable(struct drm_bridge *bridge); > void drm_bridge_enable(struct drm_bridge *bridge); > -- Regards, Laurent Pinchart