Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp482461ybv; Fri, 7 Feb 2020 03:05:12 -0800 (PST) X-Google-Smtp-Source: APXvYqw7kT9gWk6fV8AAT7DtIVNfxNQCBUeraMX1obgKu6DDCDI79OgIwbc3NIRB2N22xOkv8b+L X-Received: by 2002:a05:6830:1d59:: with SMTP id p25mr2302172oth.308.1581073511761; Fri, 07 Feb 2020 03:05:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581073511; cv=none; d=google.com; s=arc-20160816; b=yPMsuJ9FVJJnKMrS0/g6mzmfwcnWCXXb9jIpr6L9hSrMU9V+ZKAbkUt08Kt/fHrvnd TSHHDeHSoISC2YtNNo3awmtjcSWzcSwg6PeOJAtCmv0UXw8bweo8BOcd7++MK4Jw5uq2 jUVQhWq8/lKb2/1ybwq2D80FcxyOwk3DfhQ2A1LwQmleodfB9HHCj4iMJ6jpH30EFmnP okO+c8kgA5zVmXE1bmHHn2/2DvMsIGE4x4UJ+BVuF5/PT6ASVL+3+8zWRzHT4feQqAPL /BaCc/EfSF3ZmZXpwIb2GKABhJOnuGVg8411DZ5543gNDVTOalB/votEWXcN/GhfjZ8O lxwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=zSoGBAkjPuVlSCyGlNFU9LIFIlnW7u1YHwqX4QqufCg=; b=pt7nJYvjUnqzEPmQcuFaQQ2msQ84k2O6qbFiRLCRPPc7OJGvgYIIrVK6mi03oYqIbm +IXytXpeoe+MGJVYfZaCFpLG+3ZXy7+QdI+25vn1BYngfiPjjk2Wyf/MyHfnrBCdnvwP xB4+KLIgEdlwnKIvDjKORhg4+I19LC5OEYd2778GCnuiB371AXBAjgWJpEOcNDV0vH04 IzH9+fHyZUdSkxLLoAuJUtaBrzMXCNXWz8XIVXo9bgutucl3BPD9AfWQC1vUxltuhmv0 5ywpdrDjb6pH8Envym4xPbqDyAsmUpTIYgD5+nOq0mAdZ58z7VGUAF2S003/7mEz2Tve Iw/Q== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si1609299otk.2.2020.02.07.03.04.52; Fri, 07 Feb 2020 03:05:11 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727129AbgBGLCa (ORCPT + 99 others); Fri, 7 Feb 2020 06:02:30 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:51800 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbgBGLCa (ORCPT ); Fri, 7 Feb 2020 06:02:30 -0500 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id CBA35295B59; Fri, 7 Feb 2020 11:02:28 +0000 (GMT) Date: Fri, 7 Feb 2020 12:02:25 +0100 From: Boris Brezillon To: Neil Armstrong Cc: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, linux-amlogic@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 04/11] drm/bridge: synopsys: dw-hdmi: add bus format negociation Message-ID: <20200207120225.2ea76016@collabora.com> In-Reply-To: <20200206191834.6125-5-narmstrong@baylibre.com> References: <20200206191834.6125-1-narmstrong@baylibre.com> <20200206191834.6125-5-narmstrong@baylibre.com> Organization: Collabora X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 Feb 2020 20:18:27 +0100 Neil Armstrong wrote: > Add the atomic_get_output_bus_fmts, atomic_get_input_bus_fmts to negociate ^ hooks? > the possible output and input formats for the current mode and monitor, > and use the negotiated formats in a basic atomic_check callback. > > Signed-off-by: Neil Armstrong > --- > + > +/* Can return a maximum of 4 possible input formats for an output format */ > +#define MAX_INPUT_SEL_FORMATS 4 It seems to only be 3 in practice (based on the code) unless I missed something. > + > +static u32 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge, > + struct drm_bridge_state *bridge_state, > + struct drm_crtc_state *crtc_state, > + struct drm_connector_state *conn_state, > + u32 output_fmt, > + unsigned int *num_input_fmts) > +{ > + u32 *input_fmts; > + int i = 0; > + > + *num_input_fmts = 0; > + > + input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts), > + GFP_KERNEL); > + if (!input_fmts) > + return NULL; > + > + switch (output_fmt) { > + /* 8bit */ > + case MEDIA_BUS_FMT_RGB888_1X24: > + input_fmts[i++] = MEDIA_BUS_FMT_RGB888_1X24; > + input_fmts[i++] = MEDIA_BUS_FMT_YUV8_1X24; > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY8_1X16; > + break; > + case MEDIA_BUS_FMT_YUV8_1X24: > + input_fmts[i++] = MEDIA_BUS_FMT_YUV8_1X24; > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY8_1X16; > + input_fmts[i++] = MEDIA_BUS_FMT_RGB888_1X24; > + break; > + case MEDIA_BUS_FMT_UYVY8_1X16: > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY8_1X16; > + input_fmts[i++] = MEDIA_BUS_FMT_YUV8_1X24; > + input_fmts[i++] = MEDIA_BUS_FMT_RGB888_1X24; > + break; > + > + /* 10bit */ > + case MEDIA_BUS_FMT_RGB101010_1X30: > + input_fmts[i++] = MEDIA_BUS_FMT_RGB101010_1X30; > + input_fmts[i++] = MEDIA_BUS_FMT_YUV10_1X30; > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY10_1X20; > + break; > + case MEDIA_BUS_FMT_YUV10_1X30: > + input_fmts[i++] = MEDIA_BUS_FMT_YUV10_1X30; > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY10_1X20; > + input_fmts[i++] = MEDIA_BUS_FMT_RGB101010_1X30; > + break; > + case MEDIA_BUS_FMT_UYVY10_1X20: > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY10_1X20; > + input_fmts[i++] = MEDIA_BUS_FMT_YUV10_1X30; > + input_fmts[i++] = MEDIA_BUS_FMT_RGB101010_1X30; > + break; > + > + /* 12bit */ > + case MEDIA_BUS_FMT_RGB121212_1X36: > + input_fmts[i++] = MEDIA_BUS_FMT_RGB121212_1X36; > + input_fmts[i++] = MEDIA_BUS_FMT_YUV12_1X36; > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY12_1X24; > + break; > + case MEDIA_BUS_FMT_YUV12_1X36: > + input_fmts[i++] = MEDIA_BUS_FMT_YUV12_1X36; > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY12_1X24; > + input_fmts[i++] = MEDIA_BUS_FMT_RGB121212_1X36; > + break; > + case MEDIA_BUS_FMT_UYVY12_1X24: > + input_fmts[i++] = MEDIA_BUS_FMT_UYVY12_1X24; > + input_fmts[i++] = MEDIA_BUS_FMT_YUV12_1X36; > + input_fmts[i++] = MEDIA_BUS_FMT_RGB121212_1X36; > + break; > + > + /* 16bit */ > + case MEDIA_BUS_FMT_RGB161616_1X48: > + input_fmts[i++] = MEDIA_BUS_FMT_RGB161616_1X48; > + input_fmts[i++] = MEDIA_BUS_FMT_YUV16_1X48; > + break; > + case MEDIA_BUS_FMT_YUV16_1X48: > + input_fmts[i++] = MEDIA_BUS_FMT_YUV16_1X48; > + input_fmts[i++] = MEDIA_BUS_FMT_RGB161616_1X48; > + break; > + > + /* 420 */ > + case MEDIA_BUS_FMT_UYYVYY8_0_5X24: > + case MEDIA_BUS_FMT_UYYVYY10_0_5X30: > + case MEDIA_BUS_FMT_UYYVYY12_0_5X36: > + case MEDIA_BUS_FMT_UYYVYY16_0_5X48: > + input_fmts[i++] = output_fmt; > + break; > + } > + > + *num_input_fmts = i; > + > + if (*num_input_fmts == 0) { > + kfree(input_fmts); > + input_fmts = NULL; > + } > + > + return input_fmts; > +} > + > +static int dw_hdmi_bridge_atomic_check(struct drm_bridge *bridge, > + struct drm_bridge_state *bridge_state, > + struct drm_crtc_state *crtc_state, > + struct drm_connector_state *conn_state) > +{ > + struct dw_hdmi *hdmi = bridge->driver_private; > + > + dev_dbg(hdmi->dev, "selected output format %x\n", > + bridge_state->output_bus_cfg.format); Nit: not aligned on the open parens. > + > + hdmi->hdmi_data.enc_out_bus_format = > + bridge_state->output_bus_cfg.format; > + > + dev_dbg(hdmi->dev, "selected input format %x\n", > + bridge_state->input_bus_cfg.format); > + > + hdmi->hdmi_data.enc_in_bus_format = > + bridge_state->input_bus_cfg.format; > + > + return 0; > +} > + > static int dw_hdmi_bridge_attach(struct drm_bridge *bridge) > { > struct dw_hdmi *hdmi = bridge->driver_private; > @@ -2499,6 +2759,9 @@ static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = { > .atomic_reset = drm_atomic_helper_bridge_reset, > .attach = dw_hdmi_bridge_attach, > .detach = dw_hdmi_bridge_detach, > + .atomic_check = dw_hdmi_bridge_atomic_check, > + .atomic_get_output_bus_fmts = dw_hdmi_bridge_atomic_get_output_bus_fmts, > + .atomic_get_input_bus_fmts = dw_hdmi_bridge_atomic_get_input_bus_fmts, > .enable = dw_hdmi_bridge_enable, > .disable = dw_hdmi_bridge_disable, > .mode_set = dw_hdmi_bridge_mode_set, > @@ -2963,6 +3226,7 @@ __dw_hdmi_probe(struct platform_device *pdev, > > hdmi->bridge.driver_private = hdmi; > hdmi->bridge.funcs = &dw_hdmi_bridge_funcs; > + Nit: not sure this has to be part of that patch. Looks good otherwise. Reviewed-by: Boris Brezillon > #ifdef CONFIG_OF > hdmi->bridge.of_node = pdev->dev.of_node; > #endif