From patchwork Fri Mar 29 10:42:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10876837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45027139A for ; Fri, 29 Mar 2019 10:42:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F51A28D1E for ; Fri, 29 Mar 2019 10:42:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 232E028E95; Fri, 29 Mar 2019 10:42:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C48C928D1E for ; Fri, 29 Mar 2019 10:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bZcEIw56LojeHi0NFGYszx9xKukWOMkhbDg0qC9uz2c=; b=CoB28izLFXKjHy P3BIzzznxW0sVHrygr5bxnR28+bskZzjR1OvqEOfoEaoQ2CldWSdlh0/5rkF7I1mErYuSwGNwhg5B KqVA35HIdzrITM7GFlhZeYaiBZup880hXfiJv1B7rjRC9+JXwMBsn5bjFAgXBfj9R4WeL71mFAI47 LnTi+dls9RAS66Eh4Taaqqtb/DTEf5ygvBWJ3xspcQ36d5xn5Cnt0GYvXfMvS7htqaWFO8Ijd/eWc iniBOtaAU3XylUJTIEOdE1qWDT8HzAeHVkQ3Tyn76HbH2ANYB1I/TMGFfyXEDUw1U+uRIB9PkD42n J1Xrgpvq+ALw9wcvkA1g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyM-00046n-El; Fri, 29 Mar 2019 10:42:54 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyD-0003vQ-RW for linux-amlogic@lists.infradead.org; Fri, 29 Mar 2019 10:42:47 +0000 Received: by mail-wm1-x342.google.com with SMTP id o10so9349504wmc.1 for ; Fri, 29 Mar 2019 03:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cbTqFTiH87EK1fVSxWqIYud8Aw5H13N60gUguYkEsk0=; b=JPrf9zlvQhyp189u10Vc5MOBLaMx8QgaDQakZorTeZo9OKJV3LcY/lhj7KxmBg962h /YqkRzf97dgrZVvLMLEQc2V7Fgk0TYSXil/mFu3XH1WsZTkk3XBitwhdF5lUrZxAQYC9 0BdEnERr2DC7a83r6zFYdN1QTgSyb+JNIIlB96rHW/fD+cdDZOjdmaxHOKdcd7dZqXSC v2swrWUj5A44rT+OoSq0NdxrKWD2jN6ZnZDvDARIFQDFTAb/qbGsqauiMHhu6g/ZLb2C P1TW+gM56pkpU8vJtPlYnYXAyESUvVqGO2ewQUwukqZ+BEsTiCBakQzzfML1U0veOjOz GIHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cbTqFTiH87EK1fVSxWqIYud8Aw5H13N60gUguYkEsk0=; b=U5OE5EpKSNot2qLc8eRqgrEzzEv0EVzc5r6v8zD+AlvkrEIrp/rwkfQTaaI60YrtQR vxMSk4lPsiuQkryVLD6YboZJ0ZOnVHBvH3rnOyt7f0CpJUKPGhCyZ+bIQJT6NBhu+fAO EpQ2HMfTy+cMDSKQ2Cg0OeUcfi633SjX3s/kdFvVRu4cU4BJtRif9pmaxLs6ts5KlqZr oDlTkWNRz+VydpharvHf9NSHu8b1FMcZ3detqkvAeCD3z14ipD83izOi2rfLIEG3JQAI VQQRKcZpdNoBnhDeaAQP+Feh0w/iS9vksyqhZtU4Hl2f7jaBFIm+FcFdr5KW3reXSboi KrKA== X-Gm-Message-State: APjAAAX7HCNRvBA2YWOets4MN9zb2xHIF3AV05pH7ELQlfvua/6hHlig RSxn1sNIiu605wBx/FSD5jeNDA== X-Google-Smtp-Source: APXvYqwrTe6pOJSGSIiBL2UrxW2af3HwetzllSOiVAGKLiCPwAdx/rNUEApZ5fP9Rc7rMc/QEtTPVA== X-Received: by 2002:a1c:6341:: with SMTP id x62mr3115737wmb.11.1553856164077; Fri, 29 Mar 2019 03:42:44 -0700 (PDT) Received: from bender.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id o15sm1632826wrj.59.2019.03.29.03.42.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Mar 2019 03:42:43 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com Subject: [PATCH RFC 1/5] drm/bridge: dw-hdmi: allow ycbcr420 modes for >= 0x200a Date: Fri, 29 Mar 2019 11:42:36 +0100 Message-Id: <20190329104240.29585-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190329104240.29585-1-narmstrong@baylibre.com> References: <20190329104240.29585-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_034245_883676_F41C31CA X-CRM114-Status: GOOD ( 10.79 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@siol.net, heiko@sntech.de, Neil Armstrong , maxime.ripard@bootlin.com, hjc@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Now the DW-HDMI Controller supports the HDMI2.0 modes, enable support for these modes in the connector if the platform supports them. We limit these modes to DW-HDMI IP version >= 0x200a which are designed to support HDMI2.0 display modes. Signed-off-by: Neil Armstrong Tested-by: Heiko Stuebner --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 6 ++++++ include/drm/bridge/dw_hdmi.h | 1 + 2 files changed, 7 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index db761329a1e3..325a87a82048 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -2621,6 +2621,12 @@ __dw_hdmi_probe(struct platform_device *pdev, if (hdmi->phy.ops->setup_hpd) hdmi->phy.ops->setup_hpd(hdmi, hdmi->phy.data); + if (hdmi->version >= 0x200a) + hdmi->connector.ycbcr_420_allowed = + hdmi->plat_data->ycbcr_420_allowed; + else + hdmi->connector.ycbcr_420_allowed = false; + memset(&pdevinfo, 0, sizeof(pdevinfo)); pdevinfo.parent = dev; pdevinfo.id = PLATFORM_DEVID_AUTO; diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index 66e70770cce5..0f0e82638fbe 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -130,6 +130,7 @@ struct dw_hdmi_plat_data { const struct drm_display_mode *mode); unsigned long input_bus_format; unsigned long input_bus_encoding; + bool ycbcr_420_allowed; /* Vendor PHY support */ const struct dw_hdmi_phy_ops *phy_ops; From patchwork Fri Mar 29 10:42:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10876841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC3FD186D for ; Fri, 29 Mar 2019 10:42:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A392E28CA1 for ; Fri, 29 Mar 2019 10:42:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9774328725; Fri, 29 Mar 2019 10:42:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 264F328CA1 for ; Fri, 29 Mar 2019 10:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OMxTY2CuuBQ6Zy2xwo3bAjprXdnVyi/9InJx9FKw0P8=; b=adjexrOb41ksgd SlrWvc+ZyK+cS2jmOxD35kL800pONOuUbEiYI5092aIvDSa75kNn+SUl2giGJuxLYU/qtxyPrEBRq 2oaqNCy5kAhmI4zp/8//i1AY7ol0UO4ns7oD1m64fHA0ajnH+ZrRcMriaHOUDlzOvUXA8P21gnn8n Zm1Le2XWIFfAeDNeDPBQyra81i+vLY/KHR1bhetkr7LDOGI5MCIPYLxRWOOx4rMIySketrquCUqGl uILJVy/S5R8mt2zBQKCqcXjra1dpRSV9UoFM/nVkLxMoIIO7v4fWl94LY69+lebRvWmvqoCPYxKl+ 5oaM+d5Udd7rtmbuLZFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyO-0004Aa-PJ; Fri, 29 Mar 2019 10:42:56 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyF-0003vu-0m for linux-amlogic@lists.infradead.org; Fri, 29 Mar 2019 10:42:51 +0000 Received: by mail-wm1-x343.google.com with SMTP id a184so2004745wma.2 for ; Fri, 29 Mar 2019 03:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qVVZM+F4bg9NburQNjeHoxpSPD/FS5oVjjumPmHKkFw=; b=oi+vNi0JHgy+MUNw6O7ROBazXPwy92e57mnf/YfCFF1H3aecRoAJ0zdwFUoyOTrHfH irzEzzn2o3el3fmhiIQia6H55YbYPuAb26HpSUMRhqZcTKZscMov+PUgOFr9R6q7CRto MgGeBX9xvXOfUo8ToK3rEneAEXXo9E+TarBNhFcOAwn7MPIKTiMpId7usnrA6UF5YUoS S8UzVGCuqjKz+5GJuUTU5ypsVCDMip/pIxgnC45QVBz4jZk8HTDZSmyzbuYq5h6icxgP cJrdSw7WHu7NUYToKggnKZjUqj2Ts0vbvsBAhg6H3hVUGNlb67RFYeiG/sngW19xDI69 Sajg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qVVZM+F4bg9NburQNjeHoxpSPD/FS5oVjjumPmHKkFw=; b=XdaH4CoZV4wpGCtoFvj/PNS5FWIBmxcX+yUrqUtFF3eHEx1eiXHkVQJg1FpmQSNhg3 Vx6VTldoyyjvBBsXtfZjiHWYK0T5RkEjrqZJHSHRXU3NOOW5IHhTDIo/N437nUDk9zOE dMLCZfMecSOWZEgeLPplm2ZEhlLdfh0+qXQFl7yPQ6ey8adkk7nNBb2cCV6qwKooxtNS Q5RJz3Kqn3w5amjZluHmcw6bQFmoVTcmiwtg2SqXQrICQqeW706keQu040HKdv8F/VgQ fdKFJKaIOlqNJDPGYI7Y04ixpe4BE28hpXNxlOtriWzdam19HYShah3NPC/o+0ZWpbXX RK9Q== X-Gm-Message-State: APjAAAV8ORY3AEn6WiFAGI25BQnZE+XsRBc8lko9OdlQjnOdwvw6zmtV dmoEdItumgYBTw3QoI5IzXa9eg== X-Google-Smtp-Source: APXvYqwOpYWG7/gxs6bSfdwHPwUiRszaTTdlpJxrzPKo79MbNEMLNsDIrRkg2I781r4ymOVU+vKVmQ== X-Received: by 2002:a1c:f204:: with SMTP id s4mr3198480wmc.51.1553856165258; Fri, 29 Mar 2019 03:42:45 -0700 (PDT) Received: from bender.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id o15sm1632826wrj.59.2019.03.29.03.42.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Mar 2019 03:42:44 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com Subject: [PATCH RFC 2/5] drm/bridge: add encoder support to specify bridge input format Date: Fri, 29 Mar 2019 11:42:37 +0100 Message-Id: <20190329104240.29585-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190329104240.29585-1-narmstrong@baylibre.com> References: <20190329104240.29585-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_034247_224815_D02FDD8D X-CRM114-Status: GOOD ( 13.69 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@siol.net, heiko@sntech.de, Neil Armstrong , maxime.ripard@bootlin.com, hjc@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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..b2ce2d3d070e 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 + */ +bool drm_bridge_format_set(struct drm_bridge *bridge, + const u32 input_bus_format, + const u32 input_encoding) +{ + 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); +} +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 9da8c93f7976..223253b15763 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: * @@ -312,6 +328,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); From patchwork Fri Mar 29 10:42:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10876845 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FB12139A for ; Fri, 29 Mar 2019 10:43:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6718D2870B for ; Fri, 29 Mar 2019 10:43:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A75128761; Fri, 29 Mar 2019 10:43:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C5E782870B for ; Fri, 29 Mar 2019 10:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UQ/UVZsbrF2C2v9OHbqAkyV8/Bo1bwZE4N3nd7O0ND4=; b=T9WYwbdVgP5fRZ Phlysyqgc1emRhM4XklAROPvdtW12z6dkoO9ZR/xoe4D22rrDqttOAo+H0bI2+eamgeNyeVtUPuvW Rpjx4w4bnATmj2ttCpuwx8QH1DeU/kMQERxWHmr+UMW6iIpcspK+JJPKLzSjIwRCbE0ibEhvRl2wo 5q6y59atRMxa6nwi0y7O3Aam4ONe3EXzj8ULG/AXcjrXdda4aLzMFPBUdgAqsZWFmUqCAFE+CKYAw v+NB5e4h9u+NjPIxF9lkIVmDrmeEaFN3aZg4nSulna8MvPykVPIpFW1LBACxBbUKZCIgFUevZrtLF 8GXbiY5sHtv/IlLD5jjw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyS-0004GO-F0; Fri, 29 Mar 2019 10:43:00 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyG-0003x5-EP for linux-amlogic@lists.infradead.org; Fri, 29 Mar 2019 10:42:54 +0000 Received: by mail-wm1-x342.google.com with SMTP id z24so2222076wmi.5 for ; Fri, 29 Mar 2019 03:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LYYL89nl7eawVXaDcC2Z0CCMgtJUjPZK9Iw2v8mdixE=; b=ZuqEJ34HRHG/bwL0h+SZl2XrQKjyCP2xstLz80Vq/+Y9oqdnIcx9KpctCbtHB8zC6y +6eeRhQGkssTjLL71pnQW6W/Jma7pWSVUlGJF3iS7YruBGhmtxj+l6blu9I8RT0Qu3ox 96DvMfPg/7Vvf/ftONKnCegz2fI9Udd9tRfSU8z7BqVTyt9IZYs8CtFGfTPNrhoNxJXE oOK2JVe3Y1irwo3KWzLXN9mX41Um7gbeC5hT162TkGxLVxAo8SBnPc/vuD5BMPouUFFu v/Y8h8xGwHltIBRUFv/SgedsDi4MEP8I3JB9G+AtPGx70quLMED3E/7bfwB/KuUcc1mk 1L3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LYYL89nl7eawVXaDcC2Z0CCMgtJUjPZK9Iw2v8mdixE=; b=F1efG99GzdiwsXGSk+ebgqPSVlC4AXipiYWBZcIOxLeuaflzb1ZCin/zYwZo+8zo0f B37t+AEFUNCkYVo6azgIrkVNKoUU6T6IcPNyhOmMSK6uhrqtifAZKvCbZ3go4mQG2jVc nPS6cInKb/S9japg/10ThdH8JxoeUtGoXgbbCwqDR1Bu3b11qno9EA/WRuoOGpETxp1E 83WCx3o4vc8mVofk7XnnhBpct/LHRAR3zK+SoWclrsEbo0qbYQjGxm3wSpatV7414MQ2 xSgJmdrI5FUstcGAmWyUt/NjuE9Ga7xL5d/thzT/xXR7K0RKHsg+tIhTrufzma2V45NM wAsQ== X-Gm-Message-State: APjAAAVeTopTiFtcruCCcXMApSgcGZ+VabE4k5F7xuB81L7YX+XLUiWF fCc0GgQpX9RdxPy5j4QAHgIfQA== X-Google-Smtp-Source: APXvYqyRXaNU6I3JeZoqiYGLoee7iet+HOwkcVOVrM3H+WY+axbZt9iyv3Tm/ojdv13G4sYRN75pSw== X-Received: by 2002:a1c:c013:: with SMTP id q19mr3101073wmf.148.1553856166735; Fri, 29 Mar 2019 03:42:46 -0700 (PDT) Received: from bender.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id o15sm1632826wrj.59.2019.03.29.03.42.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Mar 2019 03:42:45 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com Subject: [PATCH RFC 3/5] drm/bridge: dw-hdmi: Add support for dynamic output format setup Date: Fri, 29 Mar 2019 11:42:38 +0100 Message-Id: <20190329104240.29585-4-narmstrong@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190329104240.29585-1-narmstrong@baylibre.com> References: <20190329104240.29585-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_034248_827629_27DA567F X-CRM114-Status: GOOD ( 16.80 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@siol.net, heiko@sntech.de, Neil Armstrong , maxime.ripard@bootlin.com, hjc@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In order to support the HDMI2.0 YUV420, YUV422 and the 10bit, 12bit and 16bits outpu use cases, add support for the recently introduced bridge callback format_set(). This callback will setup the new input format and encoding from encoder, then these information will be used instead of the default ones in the dw_hdmi_setup() function. To determine the output bus format, has been added : - support for the connector display_info bus_formats, where a fixed output bus format can be enforced by the encoder - support for synami output bus format depending on the input format, especially the YUV420 input bus format, enforcing YUV420 as output with the correct bit depth Signed-off-by: Neil Armstrong --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 121 ++++++++++++++++++++-- 1 file changed, 112 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 325a87a82048..67f8788de213 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -103,6 +103,8 @@ struct hdmi_vmode { }; struct hdmi_data_info { + unsigned int bridge_in_bus_format; + unsigned int bridge_in_encoding; unsigned int enc_in_bus_format; unsigned int enc_out_bus_format; unsigned int enc_in_encoding; @@ -1830,8 +1832,51 @@ static void hdmi_disable_overflow_interrupts(struct dw_hdmi *hdmi) HDMI_IH_MUTE_FC_STAT2); } +/* + * The DW-HDMI CSC can only interpolate and decimate from 4:2:2 to 4:4:4/RGB + * and from 4:4:4/RGB to 4:2:2. + * Default to RGB output except if 4:2:0 as input, which CSC cannot convert. + */ +static unsigned long dw_hdmi_determine_output_bus_format(struct dw_hdmi *hdmi) +{ + unsigned int depth = hdmi_bus_fmt_color_depth( + hdmi->hdmi_data.enc_in_bus_format); + bool is_420 = hdmi_bus_fmt_is_yuv420(hdmi->hdmi_data.enc_in_bus_format); + unsigned long fmt = MEDIA_BUS_FMT_RGB888_1X24; + + switch (depth) { + case 8: + if (is_420) + fmt = MEDIA_BUS_FMT_UYYVYY8_0_5X24; + else + fmt = MEDIA_BUS_FMT_RGB888_1X24; + break; + case 10: + if (is_420) + fmt = MEDIA_BUS_FMT_UYYVYY10_0_5X30; + else + fmt = MEDIA_BUS_FMT_RGB101010_1X30; + break; + case 12: + if (is_420) + fmt = MEDIA_BUS_FMT_UYYVYY12_0_5X36; + else + fmt = MEDIA_BUS_FMT_RGB121212_1X36; + break; + case 16: + if (is_420) + fmt = MEDIA_BUS_FMT_UYYVYY16_0_5X48; + else + fmt = MEDIA_BUS_FMT_RGB161616_1X48; + break; + } + + return fmt; +} + static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) { + struct drm_display_info *display = &hdmi->connector.display_info; int ret; hdmi_disable_overflow_interrupts(hdmi); @@ -1845,9 +1890,9 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) } if ((hdmi->vic == 6) || (hdmi->vic == 7) || - (hdmi->vic == 21) || (hdmi->vic == 22) || - (hdmi->vic == 2) || (hdmi->vic == 3) || - (hdmi->vic == 17) || (hdmi->vic == 18)) + (hdmi->vic == 21) || (hdmi->vic == 22) || + (hdmi->vic == 2) || (hdmi->vic == 3) || + (hdmi->vic == 17) || (hdmi->vic == 18)) hdmi->hdmi_data.enc_out_encoding = V4L2_YCBCR_ENC_601; else hdmi->hdmi_data.enc_out_encoding = V4L2_YCBCR_ENC_709; @@ -1855,22 +1900,29 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0; hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0; - /* TOFIX: Get input format from plat data or fallback to RGB888 */ - if (hdmi->plat_data->input_bus_format) + if (hdmi->hdmi_data.bridge_in_bus_format) + hdmi->hdmi_data.enc_in_bus_format = + hdmi->hdmi_data.bridge_in_bus_format; + else if (hdmi->plat_data->input_bus_format) hdmi->hdmi_data.enc_in_bus_format = hdmi->plat_data->input_bus_format; else hdmi->hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_RGB888_1X24; - /* TOFIX: Get input encoding from plat data or fallback to none */ - if (hdmi->plat_data->input_bus_encoding) + if (hdmi->hdmi_data.bridge_in_encoding) + hdmi->hdmi_data.enc_in_encoding = + hdmi->hdmi_data.bridge_in_encoding; + else if (hdmi->plat_data->input_bus_encoding) hdmi->hdmi_data.enc_in_encoding = hdmi->plat_data->input_bus_encoding; else hdmi->hdmi_data.enc_in_encoding = V4L2_YCBCR_ENC_DEFAULT; - /* TOFIX: Default to RGB888 output format */ - hdmi->hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24; + if (display->num_bus_formats) + hdmi->hdmi_data.enc_out_bus_format = display->bus_formats[0]; + else + hdmi->hdmi_data.enc_out_bus_format = + dw_hdmi_determine_output_bus_format(hdmi); hdmi->hdmi_data.pix_repet_factor = 0; hdmi->hdmi_data.hdcp_enable = 0; @@ -2142,6 +2194,56 @@ dw_hdmi_bridge_mode_valid(struct drm_bridge *bridge, return mode_status; } +static bool dw_hdmi_drm_bridge_format_set(struct drm_bridge *bridge, + const u32 input_bus_format, + const u32 input_encoding) +{ + struct dw_hdmi *hdmi = bridge->driver_private; + + /* Filter supported input bus formats */ + switch (input_bus_format) { + case MEDIA_BUS_FMT_RGB888_1X24: + case MEDIA_BUS_FMT_RGB101010_1X30: + case MEDIA_BUS_FMT_RGB121212_1X36: + case MEDIA_BUS_FMT_RGB161616_1X48: + case MEDIA_BUS_FMT_YUV8_1X24: + case MEDIA_BUS_FMT_YUV10_1X30: + case MEDIA_BUS_FMT_YUV12_1X36: + case MEDIA_BUS_FMT_YUV16_1X48: + case MEDIA_BUS_FMT_UYVY8_1X16: + case MEDIA_BUS_FMT_UYVY10_1X20: + case MEDIA_BUS_FMT_UYVY12_1X24: + 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: + break; + default: + dev_dbg(hdmi->dev, "Unsupported Input bus format %x\n", + input_bus_format); + return false; + } + + /* Filter supported input bus encoding */ + switch (input_encoding) { + case V4L2_YCBCR_ENC_DEFAULT: + case V4L2_YCBCR_ENC_601: + case V4L2_YCBCR_ENC_709: + case V4L2_YCBCR_ENC_XV601: + case V4L2_YCBCR_ENC_XV709: + break; + default: + dev_dbg(hdmi->dev, "Unsupported Input encoding %x\n", + input_bus_format); + return false; + } + + hdmi->hdmi_data.bridge_in_bus_format = input_bus_format; + hdmi->hdmi_data.bridge_in_encoding = input_encoding; + + return true; +} + static void dw_hdmi_bridge_mode_set(struct drm_bridge *bridge, const struct drm_display_mode *orig_mode, const struct drm_display_mode *mode) @@ -2184,6 +2286,7 @@ static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = { .disable = dw_hdmi_bridge_disable, .mode_set = dw_hdmi_bridge_mode_set, .mode_valid = dw_hdmi_bridge_mode_valid, + .format_set = dw_hdmi_drm_bridge_format_set, }; static irqreturn_t dw_hdmi_i2c_irq(struct dw_hdmi *hdmi) From patchwork Fri Mar 29 10:42:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10876851 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA6CF139A for ; Fri, 29 Mar 2019 10:43:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C014D28725 for ; Fri, 29 Mar 2019 10:43:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B379328CA1; Fri, 29 Mar 2019 10:43:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 923AC28725 for ; Fri, 29 Mar 2019 10:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6OgtxzxszI4cDCg7auZQHe2m/3kfyVvHgSuoYdnWsmo=; b=DhxdSg/Oawm8fS ftg9ApKjbs89Cy25GbmfiFFjyMGLy566J/I59RNB54ZTuDpjCY2rfw17UNZfqNDuCWbwAs0PZVW5V clWw0jTalqBhHcCKDbcYUAkQBsQ34t6qY5M3Jv6yI0V5XHm++DTuf6v+a+7PijFtpYlDuX+N/FByu gzlwyCcnRK098I7lp4rsw0+xJZS7VRYVfoxbwIMKexoFMEPgVLMd8wcUCj3s98trexoFlcbkYnaFu zwIhhhL3iaqrHiezeLfQqdDqhIZiVHYznf3xUHtDgY/yRGwC/2H8J1I3Zjs44h/KjQKv6a7JO3XWx YwdDpaMi9TGdtYwbQYSQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyZ-0004Ow-HI; Fri, 29 Mar 2019 10:43:07 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyH-0003y2-B9 for linux-amlogic@lists.infradead.org; Fri, 29 Mar 2019 10:43:05 +0000 Received: by mail-wr1-x442.google.com with SMTP id s15so1946214wra.12 for ; Fri, 29 Mar 2019 03:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MZ9lTWI+Lc/C+oK4npZx3sJLpiEnZG/zd/AYB4si+t8=; b=y0UQX8epXLVgj1cwcX+NQoUxYvIH1MxhyaDAtH39DomETEKOpDVriaW6s1flRL239W TY8m/BybwlI4b+FgSZApCPmNaSfOndNR9UrWYAYifCvX3VjbBziCzW+z6m/Vh0pjW5qt Yb9XEX9+OhUPgr9RPCA7LkaC43080DaxgJl/olG4Ycoedn13wJR9c2nyOtdwggyQHW5v TasQGa0qjbkzVem5y9zysiSzHXgWAfoi7ISRdYzCu5sweWF2jIKxAFBBNvPnK8J6SjEr KqUIXpuBg10knBLTetM6DDExWnth2oOUy8iBVZdRZLunVD0TYuCDVr2Xzz/kzkSEZdmd KkkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MZ9lTWI+Lc/C+oK4npZx3sJLpiEnZG/zd/AYB4si+t8=; b=Rd8eqp/aK8SJoCV3nhGp2YjwThfgViBpb+jnForcbN6dggYTGPPehCBJKKrMMHNMh8 cSSBo6x5VEiwrwAyZasqxpw7jPK9XIfNEu3qdrQ+uADjRBk5Vt1SgF5DOjqV4J4jhuR2 kJEadho9O7k5ofqVpoSwwrF1ISz91fMFU40ubiGmX0BsEGSOwR56DZ38TDy/UPDXbzdG AKP0tAFOs8IRGRl+Eo0RjQfc85mlvXwFnzWWAeIawECftWLq19FiJZF8KCvPxmXH7OI6 INixejoJeF0x+kytwz0kmA1pDqlqC+PiWzjxJK3f/dknEdRPZ99ucZGpx2Fn29DfjZOv DVeQ== X-Gm-Message-State: APjAAAW/s6jK9k4vw8lW8Df6dEOGy90oDe5AcEW4AkdAjntplklW9X0L cahaJzOnLV3oncBUFaKQsrjUqg== X-Google-Smtp-Source: APXvYqyMdU4CHJOYuVDkXGPVlG5WC0zX8SiZkdWwqFMuFKSgmSBsBazSCs3ewV4BKfsjRtn3QvEHlQ== X-Received: by 2002:a5d:4606:: with SMTP id t6mr10560259wrq.43.1553856167701; Fri, 29 Mar 2019 03:42:47 -0700 (PDT) Received: from bender.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id o15sm1632826wrj.59.2019.03.29.03.42.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Mar 2019 03:42:47 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com Subject: [PATCH RFC 4/5] drm/meson: Add YUV420 output support Date: Fri, 29 Mar 2019 11:42:39 +0100 Message-Id: <20190329104240.29585-5-narmstrong@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190329104240.29585-1-narmstrong@baylibre.com> References: <20190329104240.29585-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_034249_862304_B63DCE51 X-CRM114-Status: GOOD ( 22.05 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@siol.net, heiko@sntech.de, Neil Armstrong , maxime.ripard@bootlin.com, hjc@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds support for the YUV420 output from the Amlogic Meson SoCs Video Processing Unit to the HDMI Controller. The YUV420 is obtained by generating a YUV444 pixel stream like the classic HDMI display modes, but then the Video Encoder output can be configured to down-sample the YUV444 pixel stream to a YUV420 stream. In addition if pixel stream down-sampling, the Y Cb Cr components must also be mapped differently to align with the HDMI2.0 specifications. This mode needs a different clock generation scheme since the TMDS PHY clock must match the 10x ration with the YUV420 pixel clock, but the video encoder must run at 2x the pixel clock. This patch adds the TMDS PHY clock value in all the video clock setup in order to better support these specific uses cases and switch to the Common Clock framework for clocks handling in the future. When 420 is needed, it calls drm_bridge_format_set() for notify the bridge the input format has changed to YUV420. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 100 +++++++++++++++++++----- drivers/gpu/drm/meson/meson_vclk.c | 93 ++++++++++++++++------ drivers/gpu/drm/meson/meson_vclk.h | 7 +- drivers/gpu/drm/meson/meson_venc.c | 6 +- drivers/gpu/drm/meson/meson_venc.h | 11 +++ drivers/gpu/drm/meson/meson_venc_cvbs.c | 3 +- 6 files changed, 174 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 779da21143b9..5d67e2beba58 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -159,6 +159,7 @@ struct meson_dw_hdmi { struct regulator *hdmi_supply; u32 irq_stat; struct dw_hdmi *hdmi; + unsigned long input_bus_format; }; #define encoder_to_meson_dw_hdmi(x) \ container_of(x, struct meson_dw_hdmi, encoder) @@ -308,6 +309,10 @@ static void meson_hdmi_phy_setup_mode(struct meson_dw_hdmi *dw_hdmi, struct meson_drm *priv = dw_hdmi->priv; unsigned int pixel_clock = mode->clock; + /* For 420, pixel clock is half unlike venc clock */ + if (dw_hdmi->input_bus_format == MEDIA_BUS_FMT_UYYVYY8_0_5X24) + pixel_clock /= 2; + if (dw_hdmi_is_compatible(dw_hdmi, "amlogic,meson-gxl-dw-hdmi") || dw_hdmi_is_compatible(dw_hdmi, "amlogic,meson-gxm-dw-hdmi")) { if (pixel_clock >= 371250) { @@ -383,25 +388,36 @@ static void dw_hdmi_set_vclk(struct meson_dw_hdmi *dw_hdmi, { struct meson_drm *priv = dw_hdmi->priv; int vic = drm_match_cea_mode(mode); + unsigned int phy_freq; unsigned int vclk_freq; unsigned int venc_freq; unsigned int hdmi_freq; vclk_freq = mode->clock; + /* For 420, pixel clock is half unlike venc clock */ + if (dw_hdmi->input_bus_format == MEDIA_BUS_FMT_UYYVYY8_0_5X24) + vclk_freq /= 2; + + /* TMDS clock is pixel_clock * 10 */ + phy_freq = vclk_freq * 10; + if (!vic) { - meson_vclk_setup(priv, MESON_VCLK_TARGET_DMT, vclk_freq, - vclk_freq, vclk_freq, false); + meson_vclk_setup(priv, MESON_VCLK_TARGET_DMT, phy_freq, + vclk_freq, vclk_freq, vclk_freq, false); return; } + /* 480i/576i needs global pixel doubling */ if (mode->flags & DRM_MODE_FLAG_DBLCLK) vclk_freq *= 2; venc_freq = vclk_freq; hdmi_freq = vclk_freq; - if (meson_venc_hdmi_venc_repeat(vic)) + /* VENC double pixels for 1080i, 720p and YUV420 modes */ + if (meson_venc_hdmi_venc_repeat(vic) || + dw_hdmi->input_bus_format == MEDIA_BUS_FMT_UYYVYY8_0_5X24) venc_freq *= 2; vclk_freq = max(venc_freq, hdmi_freq); @@ -409,11 +425,11 @@ static void dw_hdmi_set_vclk(struct meson_dw_hdmi *dw_hdmi, if (mode->flags & DRM_MODE_FLAG_DBLCLK) venc_freq /= 2; - DRM_DEBUG_DRIVER("vclk:%d venc=%d hdmi=%d enci=%d\n", - vclk_freq, venc_freq, hdmi_freq, + DRM_DEBUG_DRIVER("vclk:%d phy=%d venc=%d hdmi=%d enci=%d\n", + phy_freq, vclk_freq, venc_freq, hdmi_freq, priv->venc.hdmi_use_enci); - meson_vclk_setup(priv, MESON_VCLK_TARGET_HDMI, vclk_freq, + meson_vclk_setup(priv, MESON_VCLK_TARGET_HDMI, phy_freq, vclk_freq, venc_freq, hdmi_freq, priv->venc.hdmi_use_enci); } @@ -446,8 +462,9 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, /* Enable normal output to PHY */ dw_hdmi->data->top_write(dw_hdmi, HDMITX_TOP_BIST_CNTL, BIT(12)); - /* TMDS pattern setup (TOFIX Handle the YUV420 case) */ - if (mode->clock > 340000) { + /* TMDS pattern setup */ + if (mode->clock > 340000 && + dw_hdmi->input_bus_format == MEDIA_BUS_FMT_YUV8_1X24) { dw_hdmi->data->top_write(dw_hdmi, HDMITX_TOP_TMDS_CLK_PTTN_01, 0); dw_hdmi->data->top_write(dw_hdmi, HDMITX_TOP_TMDS_CLK_PTTN_23, @@ -622,6 +639,8 @@ dw_hdmi_mode_valid(struct drm_connector *connector, const struct drm_display_mode *mode) { struct meson_drm *priv = connector->dev->dev_private; + bool is_hdmi2_sink = connector->display_info.hdmi.scdc.supported; + unsigned int phy_freq; unsigned int vclk_freq; unsigned int venc_freq; unsigned int hdmi_freq; @@ -630,9 +649,11 @@ dw_hdmi_mode_valid(struct drm_connector *connector, DRM_DEBUG_DRIVER("Modeline " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode)); - /* If sink max TMDS clock, we reject the mode */ + /* If sink does not support 540MHz, reject the non-420 HDMI2 modes */ if (connector->display_info.max_tmds_clock && - mode->clock > connector->display_info.max_tmds_clock) + mode->clock > connector->display_info.max_tmds_clock && + !drm_mode_is_420_only(&connector->display_info, mode) && + !drm_mode_is_420_also(&connector->display_info, mode)) return MODE_BAD; /* Check against non-VIC supported modes */ @@ -648,6 +669,15 @@ dw_hdmi_mode_valid(struct drm_connector *connector, vclk_freq = mode->clock; + /* For 420, pixel clock is half unlike venc clock */ + if (drm_mode_is_420_only(&connector->display_info, mode) || + (!is_hdmi2_sink && + drm_mode_is_420_also(&connector->display_info, mode))) + vclk_freq /= 2; + + /* TMDS clock is pixel_clock * 10 */ + phy_freq = vclk_freq * 10; + /* 480i/576i needs global pixel doubling */ if (mode->flags & DRM_MODE_FLAG_DBLCLK) vclk_freq *= 2; @@ -655,8 +685,11 @@ dw_hdmi_mode_valid(struct drm_connector *connector, venc_freq = vclk_freq; hdmi_freq = vclk_freq; - /* VENC double pixels for 1080i and 720p modes */ - if (meson_venc_hdmi_venc_repeat(vic)) + /* VENC double pixels for 1080i, 720p and YUV420 modes */ + if (meson_venc_hdmi_venc_repeat(vic) || + drm_mode_is_420_only(&connector->display_info, mode) || + (!is_hdmi2_sink && + drm_mode_is_420_also(&connector->display_info, mode))) venc_freq *= 2; vclk_freq = max(venc_freq, hdmi_freq); @@ -664,10 +697,10 @@ dw_hdmi_mode_valid(struct drm_connector *connector, if (mode->flags & DRM_MODE_FLAG_DBLCLK) venc_freq /= 2; - dev_dbg(connector->dev->dev, "%s: vclk:%d venc=%d hdmi=%d\n", __func__, - vclk_freq, venc_freq, hdmi_freq); + dev_dbg(connector->dev->dev, "%s: vclk:%d phy=%d venc=%d hdmi=%d\n", + __func__, phy_freq, vclk_freq, venc_freq, hdmi_freq); - return meson_vclk_vic_supported_freq(vclk_freq); + return meson_vclk_vic_supported_freq(phy_freq, vclk_freq); } /* Encoder */ @@ -685,6 +718,24 @@ static int meson_venc_hdmi_encoder_atomic_check(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + struct meson_dw_hdmi *dw_hdmi = encoder_to_meson_dw_hdmi(encoder); + struct drm_display_info *info = &conn_state->connector->display_info; + struct drm_display_mode *mode = &crtc_state->mode; + bool is_hdmi2_sink = + conn_state->connector->display_info.hdmi.scdc.supported; + + if (drm_mode_is_420_only(info, mode) || + (!is_hdmi2_sink && drm_mode_is_420_also(info, mode))) + dw_hdmi->input_bus_format = MEDIA_BUS_FMT_UYYVYY8_0_5X24; + else + dw_hdmi->input_bus_format = MEDIA_BUS_FMT_YUV8_1X24; + + /* Specify the encoder output format to the bridge */ + if (!drm_bridge_format_set(encoder->bridge, + dw_hdmi->input_bus_format, + V4L2_YCBCR_ENC_709)) + return -EINVAL; + return 0; } @@ -722,17 +773,29 @@ static void meson_venc_hdmi_encoder_mode_set(struct drm_encoder *encoder, struct meson_dw_hdmi *dw_hdmi = encoder_to_meson_dw_hdmi(encoder); struct meson_drm *priv = dw_hdmi->priv; int vic = drm_match_cea_mode(mode); + unsigned int ycrcb_map = MESON_VENC_MAP_CB_Y_CR; + bool yuv420_mode = false; DRM_DEBUG_DRIVER("\"%s\" vic %d\n", mode->name, vic); + if (dw_hdmi->input_bus_format == MEDIA_BUS_FMT_UYYVYY8_0_5X24) { + ycrcb_map = MESON_VENC_MAP_CR_Y_CB; + yuv420_mode = true; + } + /* VENC + VENC-DVI Mode setup */ - meson_venc_hdmi_mode_set(priv, vic, mode); + meson_venc_hdmi_mode_set(priv, vic, ycrcb_map, yuv420_mode, mode); /* VCLK Set clock */ dw_hdmi_set_vclk(dw_hdmi, mode); - /* Setup YUV444 to HDMI-TX, no 10bit diphering */ - writel_relaxed(0, priv->io_base + _REG(VPU_HDMI_FMT_CTRL)); + if (dw_hdmi->input_bus_format == MEDIA_BUS_FMT_UYYVYY8_0_5X24) + /* Setup YUV420 to HDMI-TX, no 10bit diphering */ + writel_relaxed(2 | (2 << 2), + priv->io_base + _REG(VPU_HDMI_FMT_CTRL)); + else + /* Setup YUV444 to HDMI-TX, no 10bit diphering */ + writel_relaxed(0, priv->io_base + _REG(VPU_HDMI_FMT_CTRL)); } static const struct drm_encoder_helper_funcs @@ -977,6 +1040,7 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, dw_plat_data->phy_data = meson_dw_hdmi; dw_plat_data->input_bus_format = MEDIA_BUS_FMT_YUV8_1X24; dw_plat_data->input_bus_encoding = V4L2_YCBCR_ENC_709; + dw_plat_data->ycbcr_420_allowed = true; platform_set_drvdata(pdev, meson_dw_hdmi); diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c index b39034745444..44250eff8a3f 100644 --- a/drivers/gpu/drm/meson/meson_vclk.c +++ b/drivers/gpu/drm/meson/meson_vclk.c @@ -364,12 +364,17 @@ enum { /* 2970 /1 /1 /1 /5 /2 => /1 /1 */ MESON_VCLK_HDMI_297000, /* 5940 /1 /1 /2 /5 /1 => /1 /1 */ - MESON_VCLK_HDMI_594000 + MESON_VCLK_HDMI_594000, +/* 2970 /1 /1 /1 /5 /1 => /1 /2 */ + MESON_VCLK_HDMI_594000_YUV420, }; struct meson_vclk_params { + unsigned int pll_freq; + unsigned int phy_freq; + unsigned int vclk_freq; + unsigned int venc_freq; unsigned int pixel_freq; - unsigned int pll_base_freq; unsigned int pll_od1; unsigned int pll_od2; unsigned int pll_od3; @@ -377,8 +382,11 @@ struct meson_vclk_params { unsigned int vclk_div; } params[] = { [MESON_VCLK_HDMI_ENCI_54000] = { + .pll_freq = 4320000, + .phy_freq = 270000, + .vclk_freq = 54000, + .venc_freq = 54000, .pixel_freq = 54000, - .pll_base_freq = 4320000, .pll_od1 = 4, .pll_od2 = 4, .pll_od3 = 1, @@ -386,8 +394,11 @@ struct meson_vclk_params { .vclk_div = 1, }, [MESON_VCLK_HDMI_DDR_54000] = { - .pixel_freq = 54000, - .pll_base_freq = 4320000, + .pll_freq = 4320000, + .phy_freq = 270000, + .vclk_freq = 54000, + .venc_freq = 54000, + .pixel_freq = 27000, .pll_od1 = 4, .pll_od2 = 4, .pll_od3 = 1, @@ -395,8 +406,11 @@ struct meson_vclk_params { .vclk_div = 1, }, [MESON_VCLK_HDMI_DDR_148500] = { - .pixel_freq = 148500, - .pll_base_freq = 2970000, + .pll_freq = 2970000, + .phy_freq = 742500, + .vclk_freq = 148500, + .venc_freq = 148500, + .pixel_freq = 74250, .pll_od1 = 4, .pll_od2 = 1, .pll_od3 = 1, @@ -404,8 +418,11 @@ struct meson_vclk_params { .vclk_div = 1, }, [MESON_VCLK_HDMI_74250] = { + .pll_freq = 2970000, + .phy_freq = 742500, + .vclk_freq = 74250, + .venc_freq = 74250, .pixel_freq = 74250, - .pll_base_freq = 2970000, .pll_od1 = 2, .pll_od2 = 2, .pll_od3 = 2, @@ -413,8 +430,11 @@ struct meson_vclk_params { .vclk_div = 1, }, [MESON_VCLK_HDMI_148500] = { + .pll_freq = 2970000, + .phy_freq = 1485000, + .vclk_freq = 148500, + .venc_freq = 148500, .pixel_freq = 148500, - .pll_base_freq = 2970000, .pll_od1 = 1, .pll_od2 = 2, .pll_od3 = 2, @@ -422,8 +442,11 @@ struct meson_vclk_params { .vclk_div = 1, }, [MESON_VCLK_HDMI_297000] = { + .pll_freq = 5940000, + .phy_freq = 2970000, + .venc_freq = 297000, + .vclk_freq = 297000, .pixel_freq = 297000, - .pll_base_freq = 5940000, .pll_od1 = 2, .pll_od2 = 1, .pll_od3 = 1, @@ -431,14 +454,29 @@ struct meson_vclk_params { .vclk_div = 2, }, [MESON_VCLK_HDMI_594000] = { + .pll_freq = 5940000, + .phy_freq = 5940000, + .venc_freq = 594000, + .vclk_freq = 594000, .pixel_freq = 594000, - .pll_base_freq = 5940000, .pll_od1 = 1, .pll_od2 = 1, .pll_od3 = 2, .vid_pll_div = VID_PLL_DIV_5, .vclk_div = 1, }, + [MESON_VCLK_HDMI_594000_YUV420] = { + .pll_freq = 5940000, + .phy_freq = 2970000, + .venc_freq = 594000, + .vclk_freq = 594000, + .pixel_freq = 297000, + .pll_od1 = 2, + .pll_od2 = 1, + .pll_od3 = 1, + .vid_pll_div = VID_PLL_DIV_5, + .vclk_div = 1, + }, { /* sentinel */ }, }; @@ -696,6 +734,7 @@ static void meson_hdmi_pll_generic_set(struct meson_drm *priv, unsigned int od, m, frac, od1, od2, od3; if (meson_hdmi_pll_find_params(priv, pll_freq, &m, &frac, &od)) { + /* OD2 goes to the PHY, and needs to be *10, so keep OD3=1 */ od3 = 1; if (od < 4) { od1 = 2; @@ -718,21 +757,28 @@ static void meson_hdmi_pll_generic_set(struct meson_drm *priv, } enum drm_mode_status -meson_vclk_vic_supported_freq(unsigned int freq) +meson_vclk_vic_supported_freq(unsigned int phy_freq, + unsigned int vclk_freq) { int i; - DRM_DEBUG_DRIVER("freq = %d\n", freq); + DRM_DEBUG_DRIVER("phy_freq = %d vclk_freq = %d\n", + phy_freq, vclk_freq); for (i = 0 ; params[i].pixel_freq ; ++i) { DRM_DEBUG_DRIVER("i = %d pixel_freq = %d alt = %d\n", i, params[i].pixel_freq, FREQ_1000_1001(params[i].pixel_freq)); + DRM_DEBUG_DRIVER("i = %d phy_freq = %d alt = %d\n", + i, params[i].phy_freq, + FREQ_1000_1001(params[i].phy_freq/10)*10); /* Match strict frequency */ - if (freq == params[i].pixel_freq) + if (phy_freq == params[i].phy_freq && + vclk_freq == params[i].vclk_freq) return MODE_OK; /* Match 1000/1001 variant */ - if (freq == FREQ_1000_1001(params[i].pixel_freq)) + if (phy_freq == (FREQ_1000_1001(params[i].phy_freq/10)*10) && + vclk_freq == FREQ_1000_1001(params[i].vclk_freq)) return MODE_OK; } @@ -960,8 +1006,9 @@ static void meson_vclk_set(struct meson_drm *priv, unsigned int pll_base_freq, } void meson_vclk_setup(struct meson_drm *priv, unsigned int target, - unsigned int vclk_freq, unsigned int venc_freq, - unsigned int dac_freq, bool hdmi_use_enci) + unsigned int phy_freq, unsigned int vclk_freq, + unsigned int venc_freq, unsigned int dac_freq, + bool hdmi_use_enci) { bool vic_alternate_clock = false; unsigned int freq; @@ -980,7 +1027,7 @@ void meson_vclk_setup(struct meson_drm *priv, unsigned int target, * - venc_div = 1 * - encp encoder */ - meson_vclk_set(priv, vclk_freq * 10, 0, 0, 0, + meson_vclk_set(priv, phy_freq, 0, 0, 0, VID_PLL_DIV_5, 2, 1, 1, false, false); return; } @@ -1002,9 +1049,11 @@ void meson_vclk_setup(struct meson_drm *priv, unsigned int target, } for (freq = 0 ; params[freq].pixel_freq ; ++freq) { - if (vclk_freq == params[freq].pixel_freq || - vclk_freq == FREQ_1000_1001(params[freq].pixel_freq)) { - if (vclk_freq != params[freq].pixel_freq) + if ((phy_freq == params[freq].phy_freq || + phy_freq == FREQ_1000_1001(params[freq].phy_freq/10)*10) && + (vclk_freq == params[freq].vclk_freq || + vclk_freq == FREQ_1000_1001(params[freq].vclk_freq))) { + if (vclk_freq != params[freq].vclk_freq) vic_alternate_clock = true; else vic_alternate_clock = false; @@ -1033,7 +1082,7 @@ void meson_vclk_setup(struct meson_drm *priv, unsigned int target, return; } - meson_vclk_set(priv, params[freq].pll_base_freq, + meson_vclk_set(priv, params[freq].pll_freq, params[freq].pll_od1, params[freq].pll_od2, params[freq].pll_od3, params[freq].vid_pll_div, params[freq].vclk_div, hdmi_tx_div, venc_div, diff --git a/drivers/gpu/drm/meson/meson_vclk.h b/drivers/gpu/drm/meson/meson_vclk.h index 4bd8752da02a..c4d19ddfcd79 100644 --- a/drivers/gpu/drm/meson/meson_vclk.h +++ b/drivers/gpu/drm/meson/meson_vclk.h @@ -33,10 +33,11 @@ enum { enum drm_mode_status meson_vclk_dmt_supported_freq(struct meson_drm *priv, unsigned int freq); enum drm_mode_status -meson_vclk_vic_supported_freq(unsigned int freq); +meson_vclk_vic_supported_freq(unsigned int phy_freq, unsigned int vclk_freq); void meson_vclk_setup(struct meson_drm *priv, unsigned int target, - unsigned int vclk_freq, unsigned int venc_freq, - unsigned int dac_freq, bool hdmi_use_enci); + unsigned int phy_freq, unsigned int vclk_freq, + unsigned int venc_freq, unsigned int dac_freq, + bool hdmi_use_enci); #endif /* __MESON_VCLK_H */ diff --git a/drivers/gpu/drm/meson/meson_venc.c b/drivers/gpu/drm/meson/meson_venc.c index 6faca7313339..5460c4439612 100644 --- a/drivers/gpu/drm/meson/meson_venc.c +++ b/drivers/gpu/drm/meson/meson_venc.c @@ -958,6 +958,8 @@ bool meson_venc_hdmi_venc_repeat(int vic) EXPORT_SYMBOL_GPL(meson_venc_hdmi_venc_repeat); void meson_venc_hdmi_mode_set(struct meson_drm *priv, int vic, + unsigned int ycrcb_map, + bool yuv420_mode, struct drm_display_mode *mode) { union meson_hdmi_venc_mode *vmode = NULL; @@ -1508,8 +1510,8 @@ void meson_venc_hdmi_mode_set(struct meson_drm *priv, int vic, writel_relaxed((use_enci ? 1 : 2) | (mode->flags & DRM_MODE_FLAG_PHSYNC ? 1 << 2 : 0) | (mode->flags & DRM_MODE_FLAG_PVSYNC ? 1 << 3 : 0) | - 4 << 5 | - (venc_repeat ? 1 << 8 : 0) | + (ycrcb_map << 5) | + (venc_repeat || yuv420_mode ? 1 << 8 : 0) | (hdmi_repeat ? 1 << 12 : 0), priv->io_base + _REG(VPU_HDMI_SETTING)); diff --git a/drivers/gpu/drm/meson/meson_venc.h b/drivers/gpu/drm/meson/meson_venc.h index 97eaebbfa0c4..5580bf38e381 100644 --- a/drivers/gpu/drm/meson/meson_venc.h +++ b/drivers/gpu/drm/meson/meson_venc.h @@ -33,6 +33,15 @@ enum { MESON_VENC_MODE_HDMI, }; +enum { + MESON_VENC_MAP_CR_Y_CB = 0, + MESON_VENC_MAP_Y_CB_CR, + MESON_VENC_MAP_Y_CR_CB, + MESON_VENC_MAP_CB_CR_Y, + MESON_VENC_MAP_CB_Y_CR, + MESON_VENC_MAP_CR_CB_Y, +}; + struct meson_cvbs_enci_mode { unsigned int mode_tag; unsigned int hso_begin; /* HSO begin position */ @@ -70,6 +79,8 @@ extern struct meson_cvbs_enci_mode meson_cvbs_enci_ntsc; void meson_venci_cvbs_mode_set(struct meson_drm *priv, struct meson_cvbs_enci_mode *mode); void meson_venc_hdmi_mode_set(struct meson_drm *priv, int vic, + unsigned int ycrcb_map, + bool yuv420_mode, struct drm_display_mode *mode); unsigned int meson_venci_get_field(struct meson_drm *priv); diff --git a/drivers/gpu/drm/meson/meson_venc_cvbs.c b/drivers/gpu/drm/meson/meson_venc_cvbs.c index 2c5341c881c4..c1bbc601cf13 100644 --- a/drivers/gpu/drm/meson/meson_venc_cvbs.c +++ b/drivers/gpu/drm/meson/meson_venc_cvbs.c @@ -218,7 +218,8 @@ static void meson_venc_cvbs_encoder_mode_set(struct drm_encoder *encoder, /* Setup 27MHz vclk2 for ENCI and VDAC */ meson_vclk_setup(priv, MESON_VCLK_TARGET_CVBS, MESON_VCLK_CVBS, MESON_VCLK_CVBS, - MESON_VCLK_CVBS, true); + MESON_VCLK_CVBS, MESON_VCLK_CVBS, + true); break; } } From patchwork Fri Mar 29 10:42:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 10876849 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CD07186D for ; Fri, 29 Mar 2019 10:43:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 160052870B for ; Fri, 29 Mar 2019 10:43:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A76828761; Fri, 29 Mar 2019 10:43:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B27DE2870B for ; Fri, 29 Mar 2019 10:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=COCJL6NwwWsnQ8QJZvucYjM/9Pll4W2IwjTl5UAy9CY=; b=PC9qCiWqZkZM+9 3mbcEwxmpMwCl/IXBGr4Uzn+GkNfM99ODY58OT27LoGxuBv1j6kD9QWMwuBSahUggUSABGckLJ7Ef q4hCFnfZyeBBRbgDnHry6J0tT1z4WXTmGSqKZ/2hsV6nVIJnySyNd16pm+lvfBCVryEIiigx9XRB+ AT9iFs4F0qaxfJCPsLx37d0iCkMVM9/+RMfR3m20vnvN/o/PsMhiZrnqHqrnYqUttY1fbFqCtqXJS q1cJ7bd6PBBALJnRoQBdZkW1nGp4UObwXraVYiVds9+ZlR8EmOY477S9ibeTlbGOscPXpUn5qRDvi +alzCNge0fz4XeG18z5Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyU-0004Jw-RC; Fri, 29 Mar 2019 10:43:02 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9oyI-0003zC-0Z for linux-amlogic@lists.infradead.org; Fri, 29 Mar 2019 10:42:57 +0000 Received: by mail-wr1-x442.google.com with SMTP id k17so1955873wrx.10 for ; Fri, 29 Mar 2019 03:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9iPta9zPgZP3XWAC5lhX/snSUTynLHfLroArxcu7BWk=; b=eszOQgP58IP41nW+eG+b907BI8xIfNPpUC+HbKnK7kmgGWHJpTChTyC8wUX8H3mgur xfoA0acJK4EdmoXFh4WlyovylXqdyJ/s3anJGOgaJW5pUs/nl/nLTKTs4YqpLXd1VE8H ryhB4ryNo557UD/9U5Lf+3A0IZyZY9JNR9o/CS4xwbZcoNWZQ57UqLE/yTMtD7t1nyCN rqe0ZTRfh2KDfvWRaTr4PT5LIwlPKO1PWm9wkZD2iKIhuJ1ydJ8iKdPpSgIEszjnGpWH GJ7lyIl6hliguFtcCxVn5VMsNvlBHZAdF5exwYB0Qpj5vufJHQsc2bWA21HhOCgG7JR3 Akog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9iPta9zPgZP3XWAC5lhX/snSUTynLHfLroArxcu7BWk=; b=aN47pmA+Q6az6scvS/KSXEIohYTlj98aoHWO3sLkx92BX2Qyzs3NRl1sdcCE6cD2dP cj26cP5lUvaNrck54Nmk0ZsMMozhDQW/WPZD4Vtry2HCDT0AxSRboV4Lbo41ujlECZri O12Ag0Wo75P70/j0s/9kfxCOTf8Csn0ODXRZCl15yYlUcUS59g0U/XZtv9/RekdanUWO XOtQ/O2bfnntuY8/wBQbEYPTMf9xofVaiVAMFDsCWoz5QtEEcO3uTq5FbdS7gLV0p0PB nVn3fcBNWbYFAa8vyFhfYr5k1hp1qFfzSnNUATxz6s5sR1oFhIeSHhwGqA3yoNjYDw3H TgOg== X-Gm-Message-State: APjAAAXBc1dltsQA64fWcZ0td9xrkBgykoVPDmmiCvyA6a+W7+LltXM3 Ba0s4ETuzlGeTroH/nuQTRBAhg== X-Google-Smtp-Source: APXvYqxpswm5L4dzjRqq+BvpCEIouHIZ4JdfSZOysyc0i4t58OaeUknOQKivP42lH6oxGmsIJh1RVA== X-Received: by 2002:a5d:488d:: with SMTP id g13mr17463196wrq.119.1553856168573; Fri, 29 Mar 2019 03:42:48 -0700 (PDT) Received: from bender.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id o15sm1632826wrj.59.2019.03.29.03.42.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Mar 2019 03:42:48 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com Subject: [PATCH RFC 5/5] drm/meson: Output in YUV444 if sink supports it Date: Fri, 29 Mar 2019 11:42:40 +0100 Message-Id: <20190329104240.29585-6-narmstrong@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190329104240.29585-1-narmstrong@baylibre.com> References: <20190329104240.29585-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_034250_438465_B7A61626 X-CRM114-Status: GOOD ( 11.29 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jernej.skrabec@siol.net, heiko@sntech.de, Neil Armstrong , maxime.ripard@bootlin.com, hjc@rock-chips.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP With the YUV420 handling, we can dynamically setup the HDMI output pixel format depending on the mode and connector info. So now, we can output in YUV444, which is the native video pipeline format, directly to the HDMI Sink if it's supported without necessarily involving the HDMI Controller CSC. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 5d67e2beba58..8bf9db7f39a4 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -723,12 +723,23 @@ static int meson_venc_hdmi_encoder_atomic_check(struct drm_encoder *encoder, struct drm_display_mode *mode = &crtc_state->mode; bool is_hdmi2_sink = conn_state->connector->display_info.hdmi.scdc.supported; + bool specify_out_format = false; + u32 out_format; if (drm_mode_is_420_only(info, mode) || (!is_hdmi2_sink && drm_mode_is_420_also(info, mode))) dw_hdmi->input_bus_format = MEDIA_BUS_FMT_UYYVYY8_0_5X24; - else + else { dw_hdmi->input_bus_format = MEDIA_BUS_FMT_YUV8_1X24; + if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) { + out_format = MEDIA_BUS_FMT_YUV8_1X24; + specify_out_format = true; + } + } + + /* Set a connector bus format is required */ + drm_display_info_set_bus_formats(info, &out_format, + (specify_out_format ? 1 : 0)); /* Specify the encoder output format to the bridge */ if (!drm_bridge_format_set(encoder->bridge,