From patchwork Tue Aug 27 08:14:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11116279 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D892214DB for ; Tue, 27 Aug 2019 08:14:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3FA5206BF for ; Tue, 27 Aug 2019 08:14:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ojoeaMs2"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="C9GqNB7Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3FA5206BF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=94koFlFaqCiGApuIxLII/j4jwdI8mc3c7pOMTofRMNg=; b=ojoeaMs2jCMekj YIf1VHAert6Fqzf9YQYMjO0SEUj9DALDr2g3R4s3wxbYZb1pbyL31JNV0ie6YN6Z3KsU+rHsiDPWq s+AYPGzuZLh7ig4LtqJZGp8RW7+rH/mJwuvBNfUSNQeIkZ96bb7Br8OPH2hb3ukKitBp5WZ1xeUI4 7u8oVbRh281sP7h773qazCPuc+D4sa1YyTXmxDnjNWXKpfn0TOGFHfGPQqin6uL37Gz3ks9iOxHzR c7UWjCxgfTDmeie63wtCySqJjHA8xukJvMEGBk8ap0my0JwuZvIFVaji2qu5dWBw9WiI6mTSSzyal jpIB/d3kr/sNeMGBwXkw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wce-0003o5-Av; Tue, 27 Aug 2019 08:14:36 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wca-0003lo-SF for linux-amlogic@lists.infradead.org; Tue, 27 Aug 2019 08:14:34 +0000 Received: by mail-wr1-x443.google.com with SMTP id z11so17833467wrt.4 for ; Tue, 27 Aug 2019 01:14:30 -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=3fwLgPt/sy0VRW5cHDJyRotay9sWSMyISJ5IvQ5QQMA=; b=C9GqNB7Zx2gcvaVzTdzCbkKaigQKRB7taaAM92mqpg588P/+1/L5odJieFPNb0LTwN 8RczG1CjJ/RyL5OyJlcfTqSew2yax0JYZJh/l4Y+UzzRSp+ANIfP7SuSkrWustPY4+Hn 6RV1d5TbNu7JaqsqYlY6hA8inCmFL8gan4+a+SNE0xAC7sYznX0dy3LZPVLvgtfu1YOf Nm9n7/2lm6kIyvnOk45RNmGIvQKdiozzb6wQDVoBIvrcdt9EbEoNaJ6Rv1wXxZ8eSLBq 9qktKeEvuLDRO2wI+b/aPcWoljP8SN7KpIkah35+Ca945fvXDNHjsexq3DlTPS0lUDnE S/ig== 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=3fwLgPt/sy0VRW5cHDJyRotay9sWSMyISJ5IvQ5QQMA=; b=s9mhD9DWiNRfiTF6a3psGG40oIrDXMbyLWDxWsdiJOMbda6ZF4C01EWVt/BE+cALJd 1gs78cTVOElLtjjfG8zxopvHIAZrq+rFamK0rC9q5OhcCESHMJa5nWMblkaGQzJv2oAX Wy3D2jH8dczriKw3Khw+0yQ03V1i/Tp5RQeHr4bbHurK4vUPuPeRL/s9EVT6shlo5QBe 8vCq49MzE3qOj1HZKqh4oIW3XHbdeGgGEw1W9Sj5MjLUPn4QIH1yf+5L4ysRYWIgVALe g/YsakCcbkulrp2MYRObX5yLf0dH281LFYfryw5zw6RnzIq/46ExMAyd3PjNSDUylGfE R+vg== X-Gm-Message-State: APjAAAXokAi/ktt54WRcCwuGHHfp0vVqLlk1Un1Ac6WW6uk4tUCjRVW1 j4A6tI4ArVVG90wuzci4Rl9FKg== X-Google-Smtp-Source: APXvYqztWS6qzctrIjcT+AV41CNogqI+Ep6+I+AnpQFdQmvtAHxf1STFdqtf+tvOdN6+ooP8EYCImA== X-Received: by 2002:a5d:658b:: with SMTP id q11mr2210567wru.211.1566893669171; Tue, 27 Aug 2019 01:14:29 -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 f18sm11911792wrx.85.2019.08.27.01.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:14:28 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Subject: [PATCH RFC v2 1/8] drm/meson: venc: make drm_display_mode const Date: Tue, 27 Aug 2019 10:14:18 +0200 Message-Id: <20190827081425.15011-2-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827081425.15011-1-narmstrong@baylibre.com> References: <20190827081425.15011-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190827_011433_055807_60D39FEF X-CRM114-Status: UNSURE ( 9.10 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org Before switching to bridge funcs, make sure drm_display_mode is passed as const to the venc functions. Signed-off-by: Neil Armstrong Reviewed-by: Boris Brezillon --- drivers/gpu/drm/meson/meson_venc.c | 2 +- drivers/gpu/drm/meson/meson_venc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_venc.c b/drivers/gpu/drm/meson/meson_venc.c index 679d2274531c..d2d4c3ebf46b 100644 --- a/drivers/gpu/drm/meson/meson_venc.c +++ b/drivers/gpu/drm/meson/meson_venc.c @@ -946,7 +946,7 @@ 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, - struct drm_display_mode *mode) + const struct drm_display_mode *mode) { union meson_hdmi_venc_mode *vmode = NULL; union meson_hdmi_venc_mode vmode_dmt; diff --git a/drivers/gpu/drm/meson/meson_venc.h b/drivers/gpu/drm/meson/meson_venc.h index 576768bdd08d..1abdcbdf51c0 100644 --- a/drivers/gpu/drm/meson/meson_venc.h +++ b/drivers/gpu/drm/meson/meson_venc.h @@ -60,7 +60,7 @@ 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, - struct drm_display_mode *mode); + const struct drm_display_mode *mode); unsigned int meson_venci_get_field(struct meson_drm *priv); void meson_venc_enable_vsync(struct meson_drm *priv); From patchwork Tue Aug 27 08:14:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11116291 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CFF516B1 for ; Tue, 27 Aug 2019 08:14:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A97322CED for ; Tue, 27 Aug 2019 08:14:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Gyat8wpd"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="tHMHiMgS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A97322CED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=eMg2j4ZyrB8Tm3Dcs9oPkVmVP9HxdRK5MAHSqAxCvMc=; b=Gyat8wpdxgz/bl ND+bygeRwPV+8HjJTdWSbdkra78wFFgJbEu+wi+YWBij5YS+vWuOomALRh2sLgXVadDwOCzJQUoEe geiI1c2NJNVlYaOSXQZyn/SDZD1MQC8DxsPxeuupIj1e8bROzabUuRg6hgVsTVIHmH8RLcts+MjFX a0UyUJASR1iq4sWqkeDIvZymlUA60y3ldf2wzPJYB5Ubykaaseew0Hfki557so2gpPhJHMwN824bG HOX7MKS1/OoE+oZjcGHuT0DT9xwk7vrFVBuUWSdYM2zEXDNBkZdkBxo6u2JSfa1AicMPgfTgakQTe Lj008XLHNxbMA+vtEtZA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcl-0003v9-Hs; Tue, 27 Aug 2019 08:14:43 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wca-0003m0-SG for linux-amlogic@lists.infradead.org; Tue, 27 Aug 2019 08:14:36 +0000 Received: by mail-wr1-x443.google.com with SMTP id t16so17820965wra.6 for ; Tue, 27 Aug 2019 01:14:31 -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=P263Nz8GEJ4vmRFoF7UucI5AUC0r0zMRf0rnaRk+enY=; b=tHMHiMgSk47lpDEmrla9XXBM90OwrHN+lkL+/xh2RCq0cro5bbtsH/H12lBK+XQyPE Qkwk0TTJbfPh8pWIshAMztu+Kg7TiV2UFJnczaOAFCUC4w5TV7G1gSoKPC0nBMgnBMhG nUZqfwbwWeMOuARUiXgDZuIjYnqL2NOzdPHrmKHGYnsVH4eFXmeOcHIXlv2iIO+eOK/V te9YSmTZTbpJkXfnaqOgrxN4nnVDClGTXNj8cSUV920GwkyQwd+KnoUjhATe/5YC0G4p omwlvu9weNOdnFgeNFaKFEv894XlPbYCrB2/l01w3iBL+c0JBvedmUjvraTrgHBYF9h0 w5pQ== 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=P263Nz8GEJ4vmRFoF7UucI5AUC0r0zMRf0rnaRk+enY=; b=jm4hSxUMCGrvvD4HF0sFSiybhQO+PKvn5YNyVXJizv4Oa+VNKXZlyn6kOGZ8ez8zGz cRFjzo+lwsAxajE75za9nO9qlaDXvNTwynhgASM25CHN/IEzEgstoQBhM7qeZNX2h/yM SZg0rHUE4sGeHiiEDNMJffAkCJ7wVPYpTBeI4z9jw/BpNBgkV/8t9hDqzA73TneGMgFv 73J29ClcGdO+XiRd9h5ylHEHrd4Zlf7YGJ1fYQivruesCAkz2XpIkgk5JS6AZ8Kb2fu4 KOEWmPh09le/yK5b5sZwpcbl++2PfZ61n7Ovp/oFe7K+ViWlbdKjiLqqHFZwXRrUFR/E BoXA== X-Gm-Message-State: APjAAAWJ+AoJXsDHH2Eyiva8ltSC9ZH7bjP7m1smE+f3iUuPcnK7jm+M ID6iYvr4DguFwq30Nj4MDZm1ww== X-Google-Smtp-Source: APXvYqwpvbZyC/pu+tVMvm17ws3ojExWy0ldiSpgNaiDeRPVrh1zPmuhZG2aTGT2a9jcu4lVoorn0w== X-Received: by 2002:a5d:4446:: with SMTP id x6mr27380733wrr.11.1566893669899; Tue, 27 Aug 2019 01:14:29 -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 f18sm11911792wrx.85.2019.08.27.01.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:14:29 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Subject: [PATCH RFC v2 2/8] drm/meson: meson_dw_hdmi: switch to drm_bridge_funcs Date: Tue, 27 Aug 2019 10:14:19 +0200 Message-Id: <20190827081425.15011-3-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827081425.15011-1-narmstrong@baylibre.com> References: <20190827081425.15011-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190827_011433_056362_3FFB20FD X-CRM114-Status: GOOD ( 12.36 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org Switch the dw-hdmi driver to drm_bridge_funcs, and implement the atomic_get_input_bus_fmts/atomic_get_output_bus_fmts. Signed-off-by: Neil Armstrong Reviewed-by: Boris Brezillon --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 67 +++++++++++++++++++++------ 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index f893ebd0b799..333583ef3ab9 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -368,7 +368,7 @@ static inline void meson_dw_hdmi_phy_reset(struct meson_dw_hdmi *dw_hdmi) } static void dw_hdmi_set_vclk(struct meson_dw_hdmi *dw_hdmi, - struct drm_display_mode *mode) + const struct drm_display_mode *mode) { struct meson_drm *priv = dw_hdmi->priv; int vic = drm_match_cea_mode(mode); @@ -663,6 +663,10 @@ dw_hdmi_mode_valid(struct drm_connector *connector, /* Encoder */ +static const u32 meson_dw_hdmi_out_bus_fmts[] = { + MEDIA_BUS_FMT_YUV8_1X24, +}; + static void meson_venc_hdmi_encoder_destroy(struct drm_encoder *encoder) { drm_encoder_cleanup(encoder); @@ -672,15 +676,50 @@ static const struct drm_encoder_funcs meson_venc_hdmi_encoder_funcs = { .destroy = meson_venc_hdmi_encoder_destroy, }; -static int meson_venc_hdmi_encoder_atomic_check(struct drm_encoder *encoder, +static void +meson_venc_hdmi_encoder_get_out_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + unsigned int *num_output_fmts, + u32 *output_fmts) +{ + *num_output_fmts = ARRAY_SIZE(meson_dw_hdmi_out_bus_fmts); + + if (output_fmts) + memcpy(output_fmts, meson_dw_hdmi_out_bus_fmts, + ARRAY_SIZE(meson_dw_hdmi_out_bus_fmts)); +} + +static void +meson_venc_hdmi_encoder_get_inp_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) +{ + if (output_fmt == meson_dw_hdmi_out_bus_fmts[0]) { + *num_input_fmts = 1; + if (input_fmts) + input_fmts[0] = output_fmt; + } + else + *num_input_fmts = 0; +} + +static int meson_venc_hdmi_encoder_atomic_check(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { return 0; } -static void meson_venc_hdmi_encoder_disable(struct drm_encoder *encoder) +static void meson_venc_hdmi_encoder_disable(struct drm_bridge *bridge) { + struct drm_encoder *encoder = bridge_to_encoder(bridge); struct meson_dw_hdmi *dw_hdmi = encoder_to_meson_dw_hdmi(encoder); struct meson_drm *priv = dw_hdmi->priv; @@ -693,8 +732,9 @@ static void meson_venc_hdmi_encoder_disable(struct drm_encoder *encoder) writel_relaxed(0, priv->io_base + _REG(ENCP_VIDEO_EN)); } -static void meson_venc_hdmi_encoder_enable(struct drm_encoder *encoder) +static void meson_venc_hdmi_encoder_enable(struct drm_bridge *bridge) { + struct drm_encoder *encoder = bridge_to_encoder(bridge); struct meson_dw_hdmi *dw_hdmi = encoder_to_meson_dw_hdmi(encoder); struct meson_drm *priv = dw_hdmi->priv; @@ -706,10 +746,11 @@ static void meson_venc_hdmi_encoder_enable(struct drm_encoder *encoder) writel_relaxed(1, priv->io_base + _REG(ENCP_VIDEO_EN)); } -static void meson_venc_hdmi_encoder_mode_set(struct drm_encoder *encoder, - struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) +static void meson_venc_hdmi_encoder_mode_set(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + const struct drm_display_mode *adjusted_mode) { + struct drm_encoder *encoder = bridge_to_encoder(bridge); 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); @@ -726,11 +767,12 @@ static void meson_venc_hdmi_encoder_mode_set(struct drm_encoder *encoder, writel_relaxed(0, priv->io_base + _REG(VPU_HDMI_FMT_CTRL)); } -static const struct drm_encoder_helper_funcs - meson_venc_hdmi_encoder_helper_funcs = { - .atomic_check = meson_venc_hdmi_encoder_atomic_check, - .disable = meson_venc_hdmi_encoder_disable, +static const struct drm_bridge_funcs meson_venc_hdmi_encoder_bridge_funcs = { .enable = meson_venc_hdmi_encoder_enable, + .disable = meson_venc_hdmi_encoder_disable, + .atomic_check = meson_venc_hdmi_encoder_atomic_check, + .atomic_get_output_bus_fmts = meson_venc_hdmi_encoder_get_out_bus_fmts, + .atomic_get_input_bus_fmts = meson_venc_hdmi_encoder_get_inp_bus_fmts, .mode_set = meson_venc_hdmi_encoder_mode_set, }; @@ -912,8 +954,7 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, /* Encoder */ - drm_encoder_helper_add(encoder, &meson_venc_hdmi_encoder_helper_funcs); - + encoder->bridge.funcs = &meson_venc_hdmi_encoder_bridge_funcs; ret = drm_encoder_init(drm, encoder, &meson_venc_hdmi_encoder_funcs, DRM_MODE_ENCODER_TMDS, "meson_hdmi"); if (ret) { From patchwork Tue Aug 27 08:14:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11116303 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6A2914F7 for ; Tue, 27 Aug 2019 08:14:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81151206BF for ; Tue, 27 Aug 2019 08:14:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Nsh4MyU6"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="KWmJrIF5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81151206BF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=XXK9R+lrIrW4WjjH+GqvGQklacc/wVXmNYdMOdJb3sQ=; b=Nsh4MyU6MYgFKL 97RmkWDKrwQHLlvZVqAJAGHC7TPhp9pfYQbP6cr3liWGmuxhik/pZhU7BJ1/IHQhmYu6/7TS98NsW uEApm7KnwEC3znFkErsSAFXV2j62ZKGa9Va4dyYSjIEfqU565yNPwhVEN7A75o2fsp+RofkD0WMMA mXA7kvSADnxjZ8gkwcniAsdFIE4AKrJcb6jK4Pvhz/hddO5z2Em6PCICie5LTB57Z1/j+eEaBDV/o svU4qdHoqoleVDJztzFnpEF6YeBUxgXfb9hOdLHjmt43sYo49cUnIyBCgPQ9bYxw0ej1Lp5ly1RMc 99xDjg6M/3hs9X52pXVA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcu-000456-4n; Tue, 27 Aug 2019 08:14:52 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcb-0003m1-NL for linux-amlogic@lists.infradead.org; Tue, 27 Aug 2019 08:14:37 +0000 Received: by mail-wm1-x341.google.com with SMTP id g67so2004754wme.1 for ; Tue, 27 Aug 2019 01:14:32 -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=D4e7iGHsnMCj/mwiWKJTzKLUGfzuq+WR9rmN1dnOPAE=; b=KWmJrIF5DhACxVfxJuxqoiBamz86vy3kyWZvsEo2ZlNlEFVsiGIFodSwTWpLcX6Fdx 2VTUDNOipJSYOFR1VAQfxpxk9pGhaat/NPalWshlriMRzGHXauhgP9Wprs6gVW/OS2VB YfYrq+8zaQ8mwTufZOC0JrVP3i2RjQZRiBUa5ul3DdUIBra/NTzCZzalP9zNpuE1OJyq AKW5d5tq2dQlfXcLHn8DbO7oTNh840c3KKgo2moHwZqjCI6IuL5b05V5Aw/5x/LcNvLd 90U+TMMR/B61z9ZJZ/tp9q6Kt+dlKFBi9qZcHqZtjFxubtEPajNniiknzSiu6VsapRyJ 76jA== 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=D4e7iGHsnMCj/mwiWKJTzKLUGfzuq+WR9rmN1dnOPAE=; b=f9EY3WYOHflDs0+qiP+SxzXKFQ+IzIu9Cy4oxAH7OqJJC+ylr3wuI8YaZ3lFOlb2s2 YMC6Nu63YPuao4HM/o+iaX7r7lRvhhG/8G+N9usNWpQm687jc7/Fl2PmM8LFE5ZVGmZY s/vcycmGLp5ItO4CodkkMWr97dINfD7ihA8qYTHffzUzCnvpIXnoIL5uYL4dezYk8o2/ IC5XvlyrRARruw2ge8HK6MKSnTS8NTpB0QJPX1+VXITLUkozGTMVAEIKncJXsgluTvjp jjA72qLV2BKLidgMgVClE4AtBG6YWjakujwLX63H5c4iyxjC0ohevA2AL+0pFPapRbq5 8kbA== X-Gm-Message-State: APjAAAWfHYuEgdpmK0Q+K8+sFkadlW1BjkDoXDgHqGgNe7HU6pL5ozEt uzJk0RgWe0ftJpMZqfKPs5a03g== X-Google-Smtp-Source: APXvYqzLXBigLBi2lvRnCuJqjyc4AYPGhWY6lt0F37CPz03pQQSr11lfP/riguLWT7NS8aD1+lTn4w== X-Received: by 2002:a1c:a514:: with SMTP id o20mr27565979wme.149.1566893670659; Tue, 27 Aug 2019 01:14:30 -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 f18sm11911792wrx.85.2019.08.27.01.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:14:30 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Subject: [PATCH RFC v2 3/8] drm/bridge: synopsys: dw-hdmi: add bus format negociation Date: Tue, 27 Aug 2019 10:14:20 +0200 Message-Id: <20190827081425.15011-4-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827081425.15011-1-narmstrong@baylibre.com> References: <20190827081425.15011-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190827_011433_770231_868C2B1C X-CRM114-Status: GOOD ( 14.92 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org Add the atomic_get_output_bus_fmts, atomic_get_input_bus_fmts to negociate the possible output and input formats for the current mode and monitor, and use the negociated formats in a basic atomic_check callback. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 245 +++++++++++++++++++++- 1 file changed, 241 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index bd65d0479683..00aacad51e29 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -1987,11 +1987,10 @@ 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) hdmi->hdmi_data.enc_in_bus_format = hdmi->plat_data->input_bus_format; - else + else if (hdmi->hdmi_data.enc_in_bus_format == MEDIA_BUS_FMT_FIXED) hdmi->hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_RGB888_1X24; /* TOFIX: Get input encoding from plat data or fallback to none */ @@ -2001,8 +2000,8 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode) 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 (hdmi->hdmi_data.enc_out_bus_format == MEDIA_BUS_FMT_FIXED) + hdmi->hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24; hdmi->hdmi_data.pix_repet_factor = 0; hdmi->hdmi_data.hdcp_enable = 0; @@ -2227,6 +2226,240 @@ static const struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = .get_modes = dw_hdmi_connector_get_modes, }; +static void dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + unsigned int *num_output_fmts, + u32 *output_fmts) +{ + struct drm_connector *conn = conn_state->connector; + struct drm_display_info *info = &conn->display_info; + struct drm_display_mode *mode = &crtc_state->mode; + bool is_hdmi2_sink = info->hdmi.scdc.supported; + int i = 0; + + /* + * If the current mode enforces 4:2:0, force the output but format + * to 4:2:0 and do not add the YUV422/444/RGB formats + */ + if (drm_mode_is_420_only(info, mode) || + (!is_hdmi2_sink && drm_mode_is_420_also(info, mode))) { + + /* Order bus formats from 16bit to 8bit if supported */ + if (info->bpc == 16 && + (info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_48)) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_UYYVYY16_0_5X48; + ++i; + } + + if (info->bpc >= 12 && + (info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_36)) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_UYYVYY12_0_5X36; + ++i; + } + + if (info->bpc >= 10 && + (info->hdmi.y420_dc_modes & DRM_EDID_YCBCR420_DC_30)) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_UYYVYY10_0_5X30; + ++i; + } + + /* Default 8bit fallback */ + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_UYYVYY8_0_5X24; + ++i; + + *num_output_fmts = i; + + return; + } + + /* + * Order bus formats from 16bit to 8bit and from YUV422 to RGB + * if supported. In any case the default RGB888 format is added + */ + + if (info->bpc == 16) { + if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_YUV16_1X48; + ++i; + } + + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_RGB161616_1X48; + ++i; + } + + if (info->bpc >= 12) { + if (info->color_formats & DRM_COLOR_FORMAT_YCRCB422) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_UYVY12_1X24; + ++i; + } + + if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_YUV12_1X36; + ++i; + } + + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_RGB121212_1X36; + ++i; + } + + if (info->bpc >= 10) { + if (info->color_formats & DRM_COLOR_FORMAT_YCRCB422) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_UYVY10_1X20; + ++i; + } + + if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_YUV10_1X30; + ++i; + } + + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_RGB101010_1X30; + ++i; + } + + if (info->color_formats & DRM_COLOR_FORMAT_YCRCB422) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_UYVY8_1X16; + ++i; + } + + if (info->color_formats & DRM_COLOR_FORMAT_YCRCB444) { + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_YUV8_1X24; + ++i; + } + + /* Default 8bit RGB fallback */ + if (output_fmts) + output_fmts[i] = MEDIA_BUS_FMT_RGB888_1X24; + ++i; + + *num_output_fmts = i; +} + +static void 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; + + switch (output_fmt) { + /* 8bit */ + case MEDIA_BUS_FMT_RGB888_1X24: + if (input_fmts) + input_fmts[i] = MEDIA_BUS_FMT_RGB888_1X24; + ++i; + /* Fallthrought */ + case MEDIA_BUS_FMT_YUV8_1X24: + if (input_fmts) + input_fmts[i] = MEDIA_BUS_FMT_YUV8_1X24; + ++i; + break; + case MEDIA_BUS_FMT_UYVY8_1X16: + /* Fallthrought */ + case MEDIA_BUS_FMT_UYYVYY8_0_5X24: + if (input_fmts) + input_fmts[i] = output_fmt; + ++i; + break; + + /* 10bit */ + case MEDIA_BUS_FMT_RGB101010_1X30: + if (input_fmts) + input_fmts[i] = output_fmt; + ++i; + /* Fallthrought */ + case MEDIA_BUS_FMT_YUV10_1X30: + if (input_fmts) + input_fmts[i] = MEDIA_BUS_FMT_YUV10_1X30; + ++i; + break; + case MEDIA_BUS_FMT_UYVY10_1X20: + /* Fallthrought */ + case MEDIA_BUS_FMT_UYYVYY10_0_5X30: + if (input_fmts) + input_fmts[i] = output_fmt; + ++i; + break; + + /* 12bit */ + case MEDIA_BUS_FMT_RGB121212_1X36: + if (input_fmts) + input_fmts[i] = output_fmt; + ++i; + /* Fallthrought */ + case MEDIA_BUS_FMT_YUV12_1X36: + if (input_fmts) + input_fmts[i] = MEDIA_BUS_FMT_YUV12_1X36; + ++i; + break; + case MEDIA_BUS_FMT_UYVY12_1X24: + /* Fallthrought */ + case MEDIA_BUS_FMT_UYYVYY12_0_5X36: + if (input_fmts) + input_fmts[i] = output_fmt; + ++i; + break; + + /* 16bit */ + case MEDIA_BUS_FMT_RGB161616_1X48: + if (input_fmts) + input_fmts[i] = output_fmt; + ++i; + /* Fallthrought */ + case MEDIA_BUS_FMT_YUV16_1X48: + if (input_fmts) + input_fmts[i] = MEDIA_BUS_FMT_YUV16_1X48; + ++i; + break; + case MEDIA_BUS_FMT_UYYVYY16_0_5X48: + if (input_fmts) + input_fmts[i] = output_fmt; + ++i; + break; + } + + *num_input_fmts = i; +} + +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.fmt); + + hdmi->hdmi_data.enc_out_bus_format = bridge_state->output_bus_cfg.fmt; + + dev_dbg(hdmi->dev, "selected input format %x\n", + bridge_state->input_bus_cfg.fmt); + + hdmi->hdmi_data.enc_in_bus_format = bridge_state->input_bus_cfg.fmt; + + return 0; +} + static int dw_hdmi_bridge_attach(struct drm_bridge *bridge) { struct dw_hdmi *hdmi = bridge->driver_private; @@ -2327,6 +2560,9 @@ static void dw_hdmi_bridge_enable(struct drm_bridge *bridge) static const struct drm_bridge_funcs dw_hdmi_bridge_funcs = { .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, @@ -2790,6 +3026,7 @@ __dw_hdmi_probe(struct platform_device *pdev, hdmi->bridge.driver_private = hdmi; hdmi->bridge.funcs = &dw_hdmi_bridge_funcs; + #ifdef CONFIG_OF hdmi->bridge.of_node = pdev->dev.of_node; #endif From patchwork Tue Aug 27 08:14:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11116293 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE3E614F7 for ; Tue, 27 Aug 2019 08:14:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB9C02173E for ; Tue, 27 Aug 2019 08:14:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o7p3tUCq"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="MTLfRB14" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB9C02173E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=qv7Jn38fSjVoTYAQztpDUxUjZOaZy7crk9Kr59x2044=; b=o7p3tUCqdeeuf/ 5RvohYQgJgtojk2GOttMyR8dEedyzzGVsG+iwjkF4sESocs4wnMkMIr6vpo4334s31TMr9AD0M8n3 x3WhaJdgyfBoqnaRYIHjO3QVf54VFkm9uv1Jexs6EiI9SOXo3scKpIEi+5j6jmPtnjMJ5NvzevvlS vy7mepjTKjfYViPOSjo9ZELZ4uLXAAOyYNNke4nwntHPDk4MRQC98FHbm53s103csGjTLP8bKunEo vEQhaR8kYzL2w/5HiWA5QQCk+UA+ulG1LUUAxM5e4F2uPo3W02WqYQV2fQI6fdM5POrsw4LU5T8z0 ADPbSUrnwgsCGUXzlP/g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wco-0003yR-Da; Tue, 27 Aug 2019 08:14:46 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcb-0003m2-NM for linux-amlogic@lists.infradead.org; Tue, 27 Aug 2019 08:14:36 +0000 Received: by mail-wm1-x341.google.com with SMTP id k1so2071876wmi.1 for ; Tue, 27 Aug 2019 01:14:32 -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=vESqQdKKmtjJu0iF9bZQdLNZv1Sk8fyWyDEwOtz2JiU=; b=MTLfRB14y+Jjwbv24sKyqUJ2bNmWeIKurBYz/VL9f2aDLLCwuvDlny5d9hxfbjVCkw 97dN0mB0D2XtfkKwbZ7DxuA//5S+FnGHZD0dHBsS6aXhepStpMj8+RQetHiWvhNJRNxK Xgwby2bxMPoETHjhng1TYYPoW1gceWkfmrFbsqIRIh/eQak0m+8d65qSMWj23WF3A7X2 PTrkIW92lGHMd6NGkfxkHR4EpkhT5Lm7QLAfB51Qs0Pyq275LyepBiOteR3Ec9O58lSV dQ6lV/nk3DqPUUQeSt+LTtawdfDTkZDkbTsxamymatQZH6XIXtLDsbxjGPR1f9ZE713l yBWA== 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=vESqQdKKmtjJu0iF9bZQdLNZv1Sk8fyWyDEwOtz2JiU=; b=GpMPOr5Bl8d7WYO0h1G1pVCcMFjIA73iOB8+LhbESdsTQrnkE+vFoGHMsnYy7irsnd 3peZ8OFyBKS2SfZQF7dBgl5Bw7e7DUh0lfgGXyW2sDmiUKDtJp0u4aDTMQk2XimUV7Wj 9sjG7/AbXfIwolRKK2+JG1R7nSab1PmV2RmcPaAevcsRxTqUv0ylzS7wpDPhVEUVlJjq ijUeKvmAOM2orSQ2J2kCT+Vjm8uFh5iB5XidHZts8vq0X+qPyp0JTip1nyfjbrfe03WV 9qHEUDFAPK+mpyqd0TRdLDkUIIU0uubjecKZg/5SRPFuqfAtx2WOGJ4JbCw0/89rprdL tL2A== X-Gm-Message-State: APjAAAV5VaXyIbvmd6pTfWlQWp8MIagZHSMBkaCk4WVirgBo6rw25E3j oVAMH7ZWVspmhJnIsJXvZ1cb/w== X-Google-Smtp-Source: APXvYqxTGusXca11jahXo+oITqWlzpLMh6fmhYKtqYvBOkcJ/84U7plQRFYWEGH2K3ihPVh6YMaQ4g== X-Received: by 2002:a7b:cd17:: with SMTP id f23mr27433268wmj.177.1566893671411; Tue, 27 Aug 2019 01:14:31 -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 f18sm11911792wrx.85.2019.08.27.01.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:14:30 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Subject: [PATCH RFC v2 4/8] drm/meson: dw-hdmi: stop enforcing input_bus_format Date: Tue, 27 Aug 2019 10:14:21 +0200 Message-Id: <20190827081425.15011-5-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827081425.15011-1-narmstrong@baylibre.com> References: <20190827081425.15011-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190827_011433_767878_28B19252 X-CRM114-Status: UNSURE ( 7.86 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org To allow using formats from negociation, stop enforcing input_bus_format in the private dw-plat-data struct. Signed-off-by: Neil Armstrong Reviewed-by: Boris Brezillon --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 333583ef3ab9..9ae24cc5faa2 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -1007,7 +1007,6 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, dw_plat_data->phy_ops = &meson_dw_hdmi_phy_ops; dw_plat_data->phy_name = "meson_dw_hdmi_phy"; 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; platform_set_drvdata(pdev, meson_dw_hdmi); From patchwork Tue Aug 27 08:14:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11116299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A67B716B1 for ; Tue, 27 Aug 2019 08:14:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83C6D22CBB for ; Tue, 27 Aug 2019 08:14:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WJjvTGgD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="zvmHQrGr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83C6D22CBB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=Zs+USwcN5TcxGkMG/FgoePej0/ctw0sPN6SGJWbDvZU=; b=WJjvTGgDs9WWxr A6tMz7NvvaT9XT6krg+bYf8BiJ3DNTdxE/1fdYfeGvHFNXyZ3BHo5tfMK7fEdYYUFRtxSd/E9zTZB Avs13/ArD6486YEBbpCB4cYLKvLpi9Vx3KR46j+ZjZmoQIehmZjInz7Mt/FwFx4acQ1RLwKSz5fVM gHN8fEbWJSbRrjVShj4V0VHrsDfLpkaCJp1XUe9Q0+hY6+iAEddxci0UjMv2K7wk/Stu57nAf0994 nFXmxSiJypTA8RcjPOcohbeY4StMmr60ciSld+FoAVX/9WObF02hVtnMb9PiWuUih6J/0YxInnzXR M8oxZD7qOsIawQLdd1UA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcq-00041M-R7; Tue, 27 Aug 2019 08:14:49 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcd-0003mc-IV for linux-amlogic@lists.infradead.org; Tue, 27 Aug 2019 08:14:36 +0000 Received: by mail-wm1-x343.google.com with SMTP id o4so2066191wmh.2 for ; Tue, 27 Aug 2019 01:14:34 -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=rf+Fb/D78w3i+4TzbVehqskNNypv9unv9HAaSJpdWso=; b=zvmHQrGrjBcBUwpMSCUNi+a3SsH9bq0JxEVQOK2M1WTophp7K27yBvua8SlTjR97dG H76O2lQXPtJ05fdxZE83rOAWcCAWejxNKSZl0WP58qnWYTNqZGqU7qCLz7lwzjJTzF/T y7ya6fU2g/k8KDTPviATtF06/s3SkeUjaHrMLNmvQUXj/cHId5awbMeUIQ99/auC23u5 ppt77F0MrskDvGO5EC7yAD23nU49wSX7E/wF6EoTPvhpDncRjwnpmxisNUf0JoUpd4tB CdytHWJVU0KrnNo29sSCEwqd9VWFVQAEErfRyE3ApYfUQ9o1bLnMoKt2d0NEqkkU7S3v lLqQ== 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=rf+Fb/D78w3i+4TzbVehqskNNypv9unv9HAaSJpdWso=; b=feH2pSPrDewm5jUyolWI6AJ6NZHI/t7qLegS6Ox8Gc91b2A7MlP6byKYYYorC8GXhU dcRSoOUGkpPKVdEnnM6u4Q2IXX4srpDQcgygN2s9fLddXz+7e8n/hPUQ/NY+URmXMGEa AjSvGIeIIiGx0LeabjpII8l3zfE90hgSMDGBaxzQXmnWf3zzdSb7jk3AIW1DluZROoW1 Pn6LfkTSl8lQEnhuVI0SxjN7+HJYt+26tWzRfkM1jdEdrvSouiJT29NrlJCNlNFN3wz9 cMIGaD4LdXzz0Tc27ySmN3lLtNtL60kQEwHspQ1ojmE1M6Rt/+vm1dNOEni7ggBgayot Qs3Q== X-Gm-Message-State: APjAAAWiNsBGodIgYBWVMcEXodlzxtw4x7CsBsB1kjS0eO30TdDBaNUv EhJMnx07FDSF02H7/NnvnUtX1GUEDSIk2A== X-Google-Smtp-Source: APXvYqzcST9C+Gwl8FfR3pGgo1a/ClAEBtAiPLNyZuPithhFN+DiiyD1q11WoQix3UFPCREYue4UNw== X-Received: by 2002:a7b:cf11:: with SMTP id l17mr26068073wmg.158.1566893672720; Tue, 27 Aug 2019 01:14:32 -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 f18sm11911792wrx.85.2019.08.27.01.14.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:14:31 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Subject: [PATCH RFC v2 5/8] drm/bridge: dw-hdmi: allow ycbcr420 modes for >= 0x200a Date: Tue, 27 Aug 2019 10:14:22 +0200 Message-Id: <20190827081425.15011-6-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827081425.15011-1-narmstrong@baylibre.com> References: <20190827081425.15011-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190827_011435_625288_A2716C37 X-CRM114-Status: UNSURE ( 9.15 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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 --- 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 00aacad51e29..048409af13d2 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -3031,6 +3031,12 @@ __dw_hdmi_probe(struct platform_device *pdev, hdmi->bridge.of_node = pdev->dev.of_node; #endif + 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 cf528c289857..25a884523b45 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -126,6 +126,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 Tue Aug 27 08:14:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11116287 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12B8416B1 for ; Tue, 27 Aug 2019 08:14:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E48DF206BA for ; Tue, 27 Aug 2019 08:14:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jlOSF0qQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="jwq4busv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E48DF206BA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=EloL6AHRjsa3dEFyXh4pITnT5poFR40rjyHeQlcyZpI=; b=jlOSF0qQ/ZRCYW 8tqXYtA9+nI6WsuUFn2e/qFtna8WhNJzzPZQXH7umTZWMl3n8WkCp3S4lEf+YpJGXGWBaFHrzabPY EVQEWpYRd7GvosVZrUjngF9Zva0bOd3SFdTBJceHrEAxaOA/XOR6TZ6VJcpNytMTPZv52f2eKpenQ 1O8an22l3ZLeygTZDajY572hGF+mFq97M7nuDchEKuMs3qc2lyXEwrc8wv7tYnVH24Pb8mNO7UIC6 vh6BT80SNxBjMpGeG/k/VHUDpMMf11bDwTaRGkRJMQI1ymNSMMasma5frpyrkTzM5LgrtTTdHu1GY FH75aRRyjSksG/qxlD3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcj-0003sn-Di; Tue, 27 Aug 2019 08:14:41 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcc-0003n2-PI for linux-amlogic@lists.infradead.org; Tue, 27 Aug 2019 08:14:36 +0000 Received: by mail-wm1-x341.google.com with SMTP id k1so2072020wmi.1 for ; Tue, 27 Aug 2019 01:14:34 -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=NHmY8pxEcNdhvGFCmnE/5DGDKeL3pKczVPiHriBHsDc=; b=jwq4busvYotbATUX25Jrg9zhdC3QfcvMCXHpyn1j80JhduMKwxdP9ZOtml83XfPubY B1+oM52yDCWmWx+ud7fOQ+LXO1/33wW/7MxWDxehokqCXSFdUhOByah6A9NsHd/7vbyc rfkwvDz/TMJX2CZYQDyqaTAKaJX9ZjWVT9bnHSu85IDYNlF7l0vXRYtO3pXXAKC9+mPK UwzM8R8R6RHfz+9PxRpgrRsw4J84FPNE32+4JOpvnqjh8PItCd3Y3U8p2GPXfqcCwcqn wUWvwITuucTmb7HXFSRrUHeXgNpaWqlxhcG163ZFP5ZxZgJ9phy4YZ2ozR+juhu0LUhb ryWQ== 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=NHmY8pxEcNdhvGFCmnE/5DGDKeL3pKczVPiHriBHsDc=; b=uLveZnw45vZCfphh+PnQyXXTicm6/Dt/AVk+H66uYA9g8M4RY66LVHhFBVLKmAJu0R C0yK2jxkRSQYqfcDgYruHCjTnOVXTWGEPipGHn+Pc4NdXrPYwGxVzr3pCMxbfXC41Vqf x8A7K08W93Q6hnnOB0XYdVHZDHBkkexJ0QAsntLK53kSX54BtuNxwV9g518h+CjkXk8m KYVqng1w0+SObjAK+3AZmZkkGsUetsEfQLdSBxMGB1CLX/AfSx10AN2VzUJ3wzTxWY3d KUCrAnR6zUVKfh9RmHNVDYLIMqq0+jMDlzglLyKplLvnK7oYFu2py6CLImizbfL4rPNn /nFA== X-Gm-Message-State: APjAAAUu2h/PXqKAXI+X0/5qyItfR/KaukwExY96OSUVmWw7DSehH70X RT7ZmNgE/WzlcwDiVYlvdc2ISA== X-Google-Smtp-Source: APXvYqwQCFhuEkIldrSpk+reMaSAS12NfRiuafCS3NYofTZVdHef/iSfRYZqvq3vcQKqXQ2NDSy6bQ== X-Received: by 2002:a05:600c:21d3:: with SMTP id x19mr26083979wmj.45.1566893673444; Tue, 27 Aug 2019 01:14:33 -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 f18sm11911792wrx.85.2019.08.27.01.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:14:33 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Subject: [PATCH RFC v2 6/8] drm/meson: venc: add support for YUV420 setup Date: Tue, 27 Aug 2019 10:14:23 +0200 Message-Id: <20190827081425.15011-7-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827081425.15011-1-narmstrong@baylibre.com> References: <20190827081425.15011-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190827_011434_816626_039C775F X-CRM114-Status: GOOD ( 12.24 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org This patch adds encoding 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. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 3 ++- drivers/gpu/drm/meson/meson_venc.c | 8 +++++--- drivers/gpu/drm/meson/meson_venc.h | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 9ae24cc5faa2..2c69024e5bcf 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -758,7 +758,8 @@ static void meson_venc_hdmi_encoder_mode_set(struct drm_bridge *bridge, DRM_DEBUG_DRIVER("\"%s\" vic %d\n", mode->name, vic); /* VENC + VENC-DVI Mode setup */ - meson_venc_hdmi_mode_set(priv, vic, mode); + meson_venc_hdmi_mode_set(priv, vic, ycrcb_map, false, + VPU_HDMI_OUTPUT_CBYCR); /* VCLK Set clock */ dw_hdmi_set_vclk(dw_hdmi, mode); diff --git a/drivers/gpu/drm/meson/meson_venc.c b/drivers/gpu/drm/meson/meson_venc.c index d2d4c3ebf46b..be1fb08a80f5 100644 --- a/drivers/gpu/drm/meson/meson_venc.c +++ b/drivers/gpu/drm/meson/meson_venc.c @@ -946,6 +946,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, const struct drm_display_mode *mode) { union meson_hdmi_venc_mode *vmode = NULL; @@ -1528,14 +1530,14 @@ void meson_venc_hdmi_mode_set(struct meson_drm *priv, int vic, if (mode->flags & DRM_MODE_FLAG_PVSYNC) reg |= VPU_HDMI_INV_VSYNC; - /* Output data format: CbYCr */ - reg |= VPU_HDMI_OUTPUT_CBYCR; + /* Output data format */ + reg |= ycrcb_map; /* * Write rate to the async FIFO between VENC and HDMI. * One write every 2 wr_clk. */ - if (venc_repeat) + if (venc_repeat || yuv420_mode) reg |= VPU_HDMI_WR_RATE(2); /* diff --git a/drivers/gpu/drm/meson/meson_venc.h b/drivers/gpu/drm/meson/meson_venc.h index 1abdcbdf51c0..9138255ffc9e 100644 --- a/drivers/gpu/drm/meson/meson_venc.h +++ b/drivers/gpu/drm/meson/meson_venc.h @@ -60,6 +60,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, const struct drm_display_mode *mode); unsigned int meson_venci_get_field(struct meson_drm *priv); From patchwork Tue Aug 27 08:14:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11116307 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4D9114F7 for ; Tue, 27 Aug 2019 08:14:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFE5F206BF for ; Tue, 27 Aug 2019 08:14:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tXqPkl3L"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="dKf+hYqW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFE5F206BF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=WlH/HSt7HnoiBKQh+bsb+7o9MAftcQS0ZjGwFCf16lo=; b=tXqPkl3Ls5qqU1 AnlFlqUU+9kI734eScVK+OPUX3i8aPRBQDoTkY/e40qsDFlRZLaB1s5636S5avbYao/xJa6Omez0J oA6lVLf9wujRzU4QKU6xIB3uJfx0cMY8XeE1t5NqTiNDoIJf/XsRcPm4e2JkF/TeJnKInauRQNQsl zHjvAO4XYlefi9Qj+0d5dWSOWGUVYT0pe3KZDe9Rbz7pbbjAIAwDXXsvqe+hBGha5/fGuwEdRXSa6 sCHz/y1r+GPIcP6EfK+PPE1gZ9B9LShOuJhtLDwv3GLp8GfGkGOpF/khSTBoeNR7atNbHHPwsgYCl qcqT3kQWwnw4leFE8tzA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcw-00047X-8z; Tue, 27 Aug 2019 08:14:54 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wce-0003ni-J3 for linux-amlogic@lists.infradead.org; Tue, 27 Aug 2019 08:14:38 +0000 Received: by mail-wm1-x342.google.com with SMTP id i63so1982399wmg.4 for ; Tue, 27 Aug 2019 01:14:35 -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=AHSCP8eF6R66zBKuoLdUdIg9WzlUKOlPH86Fd6tbhWo=; b=dKf+hYqW55ms2Fszjnk+WqnXaINcywJjgX6BKG6QUkaklf7//doHDj75pZ/1HsTgj6 n7MEZf/VNHTv/IswknNw1al/HnBrMNX+NpEKMTn91vdli4zfnnB7V73bIL69Nf/NV/PF /138gumu+DGgweyinkT0YjsPYqfV02VEJIpKFvL2jl8bIPjXMijcMjJhUtLJJs7/DABU vtkP87S4tmgmzMPx/oSGhgsWNbL8FnwwBaWT70KUl3+R5f+6EFyBOuS6vWtoOIyR6VX/ aQfUuqrOsQ0mHERnSL5xGa46GAxjAJL2mHf1h1YuBlDQwrBBkmmtysr3mU7Xkr9bPi6q vwYw== 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=AHSCP8eF6R66zBKuoLdUdIg9WzlUKOlPH86Fd6tbhWo=; b=boCFxXBNaM9Nm+5BvE9dJdkJYbDu6aECCApA6Q/oX2CumkaamUp7PIdizIujAuNdIh 2k19NIYsROGmNyyCWzcWDUzZVQixeM3AnQXD0DX8ABS02VaHiAmxAI5DVAg+wgj4K35P jQ0/PGZH3Uz+SrvAfw7Tt9nN2QHiH4YKo+Fleyld1pAEX4dp+1sNCMyM8Rk+dqqjtC6U sJMCMhNm3/rhgGYLaFDsZwxQvcGmZbOsoASWI1tLj48bGU7bYsh4krADT8oLpABNyEc8 M4idZk7WBrmbN5srO7mayNL975KzU/QKteQHbNQkJTrY4trRV6TECXHAECmJ65k8XQJz 3Mxg== X-Gm-Message-State: APjAAAUlZcJ673VaLBncoMud9EwdGNy+Qai3XoMpYRpjOl0pazrVfqE1 XyyNPOgb8S96BwAV4UezX8Oypw== X-Google-Smtp-Source: APXvYqyczMkD3BCWCKbqBKK2Epk+8BKX1eKSbZkdVuqz7gSEUlx6nyzrmOicXiNWRsP4gnuS1RSAcw== X-Received: by 2002:a05:600c:389:: with SMTP id w9mr26156481wmd.119.1566893674449; Tue, 27 Aug 2019 01:14:34 -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 f18sm11911792wrx.85.2019.08.27.01.14.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:14:33 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Subject: [PATCH RFC v2 7/8] drm/meson: vclk: add support for YUV420 setup Date: Tue, 27 Aug 2019 10:14:24 +0200 Message-Id: <20190827081425.15011-8-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827081425.15011-1-narmstrong@baylibre.com> References: <20190827081425.15011-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190827_011436_721446_CB78568D X-CRM114-Status: GOOD ( 17.54 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:342 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org This patch adds clocking 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. This mode needs a different clock generation scheme since the TMDS PHY clock must match the 10x ratio 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. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 24 ++++--- drivers/gpu/drm/meson/meson_vclk.c | 93 +++++++++++++++++++------ drivers/gpu/drm/meson/meson_vclk.h | 7 +- drivers/gpu/drm/meson/meson_venc_cvbs.c | 3 +- 4 files changed, 93 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 2c69024e5bcf..38316c6cac26 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -372,15 +372,19 @@ 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; + /* 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; } @@ -398,11 +402,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); } @@ -613,6 +617,7 @@ dw_hdmi_mode_valid(struct drm_connector *connector, const struct drm_display_mode *mode) { struct meson_drm *priv = connector->dev->dev_private; + unsigned int phy_freq; unsigned int vclk_freq; unsigned int venc_freq; unsigned int hdmi_freq; @@ -639,6 +644,9 @@ dw_hdmi_mode_valid(struct drm_connector *connector, vclk_freq = mode->clock; + /* 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,10 +663,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 */ diff --git a/drivers/gpu/drm/meson/meson_vclk.c b/drivers/gpu/drm/meson/meson_vclk.c index 869231c93617..a7cbbc75ef1b 100644 --- a/drivers/gpu/drm/meson/meson_vclk.c +++ b/drivers/gpu/drm/meson/meson_vclk.c @@ -354,12 +354,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; @@ -367,8 +372,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, @@ -376,8 +384,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, @@ -385,8 +396,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, @@ -394,8 +408,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, @@ -403,8 +420,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, @@ -412,8 +432,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, @@ -421,14 +444,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; @@ -981,7 +1028,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; } @@ -1003,9 +1050,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; @@ -1034,7 +1083,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 b62125540aef..aed0ab2efa71 100644 --- a/drivers/gpu/drm/meson/meson_vclk.h +++ b/drivers/gpu/drm/meson/meson_vclk.h @@ -25,10 +25,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_cvbs.c b/drivers/gpu/drm/meson/meson_venc_cvbs.c index 6dc130a24070..564def4d0b04 100644 --- a/drivers/gpu/drm/meson/meson_venc_cvbs.c +++ b/drivers/gpu/drm/meson/meson_venc_cvbs.c @@ -206,7 +206,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 Tue Aug 27 08:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 11116309 X-Patchwork-Delegate: neil.armstrong@linaro.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7560214F7 for ; Tue, 27 Aug 2019 08:14:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 509AB21883 for ; Tue, 27 Aug 2019 08:14:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eGcxzssY"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="nLlf//Ni" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 509AB21883 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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=QMx/3r4OmWoEbR2nkq8wwyJdpDv+oRwjW33ksjlrRD4=; b=eGcxzssYVVIbYl wjLj0EEaJ+iTEe2cWbs+AB7l+BUmCbQhG9aerqhbI5oOSPsCSIMxZPrNuCPzZuJQ6K0tRn98HgPYu xAmqxSbQLq85rYGkQYj6gJWqfH4mHpISiUotXdKWv4t58sZA/UHqrdsGpwAIicFXR0MppqbCOL1uQ gMS3fK5ECaGNDiwTOlFKCZbHgYFzTbM4/+p0sfrYEOeXn00lPr/kkGjV4oQ2gxgrqyS2TABkNannM x/mWLk1spW0vwQGwsERLWgnK1o0YvhWaDtLx5V872LuHGtJ0fXPTHsDWb5YJJ3GFqT2lF3k7OqM1x HoIKUoe5xf/Zl1aZgQzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcy-0004AJ-Lg; Tue, 27 Aug 2019 08:14:56 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i2Wcf-0003o1-Bp for linux-amlogic@lists.infradead.org; Tue, 27 Aug 2019 08:14:39 +0000 Received: by mail-wr1-x442.google.com with SMTP id k2so17829676wrq.2 for ; Tue, 27 Aug 2019 01:14:36 -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=XlAPuwfMX1K7TzaZ6rYnkrkcwMJ84axgoy/tibVraho=; b=nLlf//Ni6jo2mEfmXX3t38EOU3L2gqea0aZyOJhBDtUMhzmTfiMQ1JdSpUsrZc/z0I Ir4+xupvw/G1VUEI60axwlTmXATRJhrY0POFJAmsMXv56dXuJLyKPZNXdrnDOkaglErR 5knX4qsRqJMxXFbHAsLIWC9piloJPcyCJKeG6p3Ub0RrlayGbekus6+6UYzu4eLcnpJ3 0m4ziy1zPBADal5YSIQ3O2Hq8r/OVh7EL/Dknzt+5HcG4sO06mOMa7iTBdtc4fgJJe5N Txuqpoqpw+M7uzyT7/NQYACTqXyuZddvqSxRwwXLDeLPDi9GBvRR/SY7ysz9kIyZ2Vw8 GhQQ== 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=XlAPuwfMX1K7TzaZ6rYnkrkcwMJ84axgoy/tibVraho=; b=tuIwDuHFYmIMSPJUgOMdPOlB7mScG9CiBZWNn4iV5WcFPKNkq+2zQ3IGaphm4e3o8k 3/d1VSWSNwse9jf2XQGc3zXgsCWwxMAzwDwPAjRXWvWA7Wf+7lcTTTa74PowObGjrP/I lfAM/GA7+RVL+amxBJcKJRKlHJVDVYfBPoje1NKAPyH7q5j8lZ+7K8UKEbacV+GvawWX /bpBJZP0fmUE1K/hXfPVP137RNaY/PlDrbVWv9v562cWbfxR2/cgH89ozlJNMPx5pYnE VBxTQ7ws3qSq3h+BwxNKR+Cd7R0FXilfufz/+WGl8SjIvSpjpVMG1WKwHW59fr/CSiGS 4z4A== X-Gm-Message-State: APjAAAVP/uZw02Ak4mtwrGA89+bUnjJAEaTrLZGPICssZGSZF5XucXpU /t9vi+rKD0oaCimTLlnW7AcDmw== X-Google-Smtp-Source: APXvYqwHWrMCp1ng0x0o7m3OtPe4uRFkxR4G1C6ujkdvYjBOjuttPUoO9xulod/cq/8CwYNkl950vQ== X-Received: by 2002:a05:6000:110f:: with SMTP id z15mr26219779wrw.162.1566893675175; Tue, 27 Aug 2019 01:14:35 -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 f18sm11911792wrx.85.2019.08.27.01.14.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2019 01:14:34 -0700 (PDT) From: Neil Armstrong To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Subject: [PATCH RFC v2 8/8] drm/meson: Add YUV420 output support Date: Tue, 27 Aug 2019 10:14:25 +0200 Message-Id: <20190827081425.15011-9-narmstrong@baylibre.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827081425.15011-1-narmstrong@baylibre.com> References: <20190827081425.15011-1-narmstrong@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190827_011437_457686_10EAD20C X-CRM114-Status: GOOD ( 18.53 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Neil Armstrong Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org 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 enables the bridge bus format negociation, and handles the YUV420 case if selected by the negociation. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 85 +++++++++++++++++++++------ 1 file changed, 68 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c index 38316c6cac26..10223aa27f7c 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -148,6 +148,7 @@ struct meson_dw_hdmi { struct regulator *hdmi_supply; u32 irq_stat; struct dw_hdmi *hdmi; + unsigned long output_bus_fmt; }; #define encoder_to_meson_dw_hdmi(x) \ container_of(x, struct meson_dw_hdmi, encoder) @@ -297,6 +298,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->output_bus_fmt == 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) { @@ -379,6 +384,10 @@ static void dw_hdmi_set_vclk(struct meson_dw_hdmi *dw_hdmi, vclk_freq = mode->clock; + /* For 420, pixel clock is half unlike venc clock */ + if (dw_hdmi->output_bus_fmt == MEDIA_BUS_FMT_UYYVYY8_0_5X24) + vclk_freq /= 2; + /* TMDS clock is pixel_clock * 10 */ phy_freq = vclk_freq * 10; @@ -388,13 +397,16 @@ static void dw_hdmi_set_vclk(struct meson_dw_hdmi *dw_hdmi, 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->output_bus_fmt == MEDIA_BUS_FMT_UYYVYY8_0_5X24) venc_freq *= 2; vclk_freq = max(venc_freq, hdmi_freq); @@ -441,8 +453,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->output_bus_fmt == 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, @@ -617,6 +630,7 @@ 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; @@ -626,9 +640,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 */ @@ -644,6 +660,12 @@ 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; @@ -654,8 +676,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); @@ -673,6 +698,7 @@ dw_hdmi_mode_valid(struct drm_connector *connector, static const u32 meson_dw_hdmi_out_bus_fmts[] = { MEDIA_BUS_FMT_YUV8_1X24, + MEDIA_BUS_FMT_UYYVYY8_0_5X24, }; static void meson_venc_hdmi_encoder_destroy(struct drm_encoder *encoder) @@ -708,13 +734,19 @@ meson_venc_hdmi_encoder_get_inp_bus_fmts(struct drm_bridge *bridge, unsigned int *num_input_fmts, u32 *input_fmts) { - if (output_fmt == meson_dw_hdmi_out_bus_fmts[0]) { - *num_input_fmts = 1; - if (input_fmts) - input_fmts[0] = output_fmt; + int i; + + *num_input_fmts = 0; + + for (i = 0 ; i < ARRAY_SIZE(meson_dw_hdmi_out_bus_fmts) ; ++i) { + if (output_fmt == meson_dw_hdmi_out_bus_fmts[i]) { + *num_input_fmts = 1; + if (input_fmts) + input_fmts[0] = output_fmt; + + break; + } } - else - *num_input_fmts = 0; } static int meson_venc_hdmi_encoder_atomic_check(struct drm_bridge *bridge, @@ -722,6 +754,13 @@ static int meson_venc_hdmi_encoder_atomic_check(struct drm_bridge *bridge, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + struct drm_encoder *encoder = bridge_to_encoder(bridge); + struct meson_dw_hdmi *dw_hdmi = encoder_to_meson_dw_hdmi(encoder); + + dw_hdmi->output_bus_fmt = bridge_state->output_bus_cfg.fmt; + + DRM_DEBUG_DRIVER("output_bus_fmt %lx\n", dw_hdmi->output_bus_fmt); + return 0; } @@ -762,18 +801,29 @@ static void meson_venc_hdmi_encoder_mode_set(struct drm_bridge *bridge, 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 = VPU_HDMI_OUTPUT_CBYCR; + bool yuv420_mode = false; DRM_DEBUG_DRIVER("\"%s\" vic %d\n", mode->name, vic); + if (dw_hdmi->output_bus_fmt == MEDIA_BUS_FMT_UYYVYY8_0_5X24) { + ycrcb_map = VPU_HDMI_OUTPUT_CRYCB; + yuv420_mode = true; + } + /* VENC + VENC-DVI Mode setup */ - meson_venc_hdmi_mode_set(priv, vic, ycrcb_map, false, - VPU_HDMI_OUTPUT_CBYCR); + 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->output_bus_fmt == 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_bridge_funcs meson_venc_hdmi_encoder_bridge_funcs = { @@ -1017,6 +1067,7 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master, dw_plat_data->phy_name = "meson_dw_hdmi_phy"; dw_plat_data->phy_data = meson_dw_hdmi; dw_plat_data->input_bus_encoding = V4L2_YCBCR_ENC_709; + dw_plat_data->ycbcr_420_allowed = true; platform_set_drvdata(pdev, meson_dw_hdmi);