From patchwork Fri Jan 24 21:47:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 859657 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 174CB1D90BE for ; Fri, 24 Jan 2025 21:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755274; cv=none; b=uk7v2RE0WxEmjAapOCgO/g/1/Mzboo9x5lztkCEUeGlqTdjRc6ZbRb8KtfEOhXZ557mznaXApSdpRMRfDTll1cNRTvc68EiFEmpoR0R7FbZzHA9pQYPIBJrdPvwrKYDB0+sndD/nvCPlEho1Q3/mwqdcwdmN+nTSDZ9Bh3Xozms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755274; c=relaxed/simple; bh=f0rJpJCum+b7lqaI4sn4V9SXHt/v6K6WBKvJft3vbro=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VIqA5OsDefBfQYwvfKum42VKiVGlitgt8TreHIjjiVjRl/UcOmlKW6OaO3BpY1oC+lv5mWV/rA7aJEWJ6N2SwRmoKAgEv6EjCLcvlAeDLgn4v4ye5CItjHa+ChZtsjRVpXsQPfUU7vx27wMUgDuWf48/+AW70uo3Tlphdz044tk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=RD+shECl; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RD+shECl" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-543cc81ddebso869030e87.1 for ; Fri, 24 Jan 2025 13:47:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737755269; x=1738360069; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=lJeDvmYfwTrdzYlRuhgm/ygX8U3uOitNLlW6Q4NvxDE=; b=RD+shEClw80FvadE5kOB0iOOMpLknKg/gk+JUIWQjgjN8NvVrrPfDZNSZbfftZQzhk tlf1NOGG2TX1sS+QSYCGSBWxdmUqBehoKD8JFWe1DVsxDc7uAK0yO6JQOfpsr7808Wmn bPlmsoonSwe3EJd9zmIhCZVY2nBEC5MFale6yQsJFGsIqdXDJjKYv4mrsSFenMnO3LCg ZILJUOTEb5ihRRzcTNB/V3xe6+0VqBJZrj6hvcJvyVKcYaeDTYaZ73zEEE9riUTdZ4Ky 31F3CWAulPrh3EQBn5AgV1xZtpIGzrF5Uc81w5h7ISIZOwO5/e+SYezR7hEArI7WLpXy RtVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737755269; x=1738360069; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lJeDvmYfwTrdzYlRuhgm/ygX8U3uOitNLlW6Q4NvxDE=; b=e7+9yiXtdgIf/X3LVf+KtH2Zl8XKGxQIMsfFBpobvb7hENgUowrKZxio8SyIUtn4dF 1xTH7XUVgXh0OaqsXSxEBQavjJ/pkZt7aKGIwAGV50mxOJPpTuBtpcad+nRrkc6Qmva0 g5QDMZ2hpeae60IEF+zFjcfjnqzRGAlaYuJlu9MLLObHKO8vTuv8jMtfUoE9qJP3G7bw fH3Ysl9M8BYcggLBza3cyvVXDh/y94K5FDkMGu66AsdZ3S+f67bxQjRbiD3NQk+vE8+T LolWnF5iVT+Ontq8Bfm5f0xN+sAVBJp490GxalwKhw7rPVehDpQaDiIYd6hnbVDe2T0a PKDw== X-Forwarded-Encrypted: i=1; AJvYcCXev+6JDBjPcOYsjjD5ANynCxOcTAOOeO46+BUKIZVub8pWU0v3Tld4ol65PAjucmZIRCKRXmJY+tMabzEH@vger.kernel.org X-Gm-Message-State: AOJu0YyD4xg17SjN4PVO4bOl3jNX+dd7l0a3O0yCRVWt9DELOqhfEHaP bl6gdzg5cptrXLh2SgV/4ZrZLB7yv3ArxBXD7QXc/9fwuf0SvqnYuZcYCWJM498= X-Gm-Gg: ASbGncsuWSn/R0EoaJsCfJD1EJ5/VMqmxDPVGJwsAyFrP+cv4/bPGIRTYRHnE+airHg +gzoqjueUdV6z56d8K55wLWzvgMgp8L2AevXj7Yjuis4HVeRy5PJW/52qcQhCdrxlcC7tt/JsQE kjDoyAd9e8F5HRqLr1t7u5CpTmmnrXoJ3sDKp3fmmbWWeq9i7sv2OhKLAT7W8n6L9RLvPUuc7z/ pvm1bdMz7+DdESCUAHkzzijymcl2pNqII5n6GTBB8cJKifQR8Drxg5/uWGVjbpGaW+nb7CPAcbV C3dZmgudVk0L X-Google-Smtp-Source: AGHT+IGJDQ9mSugKQZZ3KeFdwIuuaaqj2SllE9hV97+PVfAvcbglZCBMGD3C20lS0dPX4nkJyJimsQ== X-Received: by 2002:a05:6512:3e28:b0:540:1f7d:8b9c with SMTP id 2adb3069b0e04-5439c286bbdmr12191243e87.45.1737755269106; Fri, 24 Jan 2025 13:47:49 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543c8237491sm425014e87.104.2025.01.24.13.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 13:47:47 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 24 Jan 2025 23:47:41 +0200 Subject: [PATCH v6 1/7] drm/msm/hdmi: switch to atomic bridge callbacks Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-bridge-hdmi-connector-v6-1-1592632327f7@linaro.org> References: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> In-Reply-To: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2282; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=f0rJpJCum+b7lqaI4sn4V9SXHt/v6K6WBKvJft3vbro=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnlAp/CPIUj4LeEmIPRORlPDyZcs3XDPvrjZ11L /nuK2A19+eJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5QKfwAKCRCLPIo+Aiko 1TDNB/9NOcxhekHC4IsoI7M3QERK0DG9Vnm0SR5ncGHN/OUyl5B0J9eIJPes/ZrryYDnvsOHr8t NxyEH+6stBInVmV1huGI/REL1IWnJvm8mO9xhgCiXr7PZDlmt2r4FIkJ1xM0p0kc4TKph7+G+S/ PTpxS3hRcz9TQezjn0McN9oGURK71gvevdY7KeJTTJfrx+/KtGp62sEcLxjDNS44gxyJDyQory7 VsZ0eXltI5K49TZs9waOwWinp9cYCxzlodypi8UJq2MBSvKDLdKym8UESfZ+bIL5s0rcoPgEIuR mivCOoVb8H0WbavKHR+362v/B8EDAA1tDpeFM8OGYFFkkGwL X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Change MSM HDMI bridge to use atomic_* callbacks in preparation to enablign the HDMI connector support. Acked-by: Maxime Ripard Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c index 4a5b5112227f516dfc4279d0f319ec1e5b17f240..d839c71091dcdc3b020fcbba8d698d58ee7fc749 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -126,7 +126,8 @@ static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); } -static void msm_hdmi_bridge_pre_enable(struct drm_bridge *bridge) +static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); struct hdmi *hdmi = hdmi_bridge->hdmi; @@ -152,7 +153,8 @@ static void msm_hdmi_bridge_pre_enable(struct drm_bridge *bridge) msm_hdmi_hdcp_on(hdmi->hdcp_ctrl); } -static void msm_hdmi_bridge_post_disable(struct drm_bridge *bridge) +static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); struct hdmi *hdmi = hdmi_bridge->hdmi; @@ -299,8 +301,11 @@ static enum drm_mode_status msm_hdmi_bridge_mode_valid(struct drm_bridge *bridge } static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = { - .pre_enable = msm_hdmi_bridge_pre_enable, - .post_disable = msm_hdmi_bridge_post_disable, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, + .atomic_pre_enable = msm_hdmi_bridge_atomic_pre_enable, + .atomic_post_disable = msm_hdmi_bridge_atomic_post_disable, .mode_set = msm_hdmi_bridge_mode_set, .mode_valid = msm_hdmi_bridge_mode_valid, .edid_read = msm_hdmi_bridge_edid_read, From patchwork Fri Jan 24 21:47:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 860031 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF96C1E1C1B for ; Fri, 24 Jan 2025 21:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755274; cv=none; b=GivKPt2O/bruJW1rk+dI+0UNNco8gprzNtB13f7Yz/qROAh0pb/uXuJY7EypzEyqI0EQJF06oL21VqICwoEQ07gboNH8w6UVXmWODH+DFlblUL1XG67Fn+5txk/eI/8Oc9KCsvey0jl0S8edt/w2catAY4SMCg40djhnfrApZRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755274; c=relaxed/simple; bh=kSze1JGUTOGCYF8m3i4MYZAmp4xJmoIk6UQOajOdpeU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tOC1XqMZbPSn9clCktvwQY5oG2Un7KoV520yrvJDAOPoxqYny9rpt42BMGTutHAhsDNuImibqeu4342bqHaFArBjvvZGfq3fzBboR3AgsbNqO1+ASUIOOMOi0V3DsriF77Qp/bSyf8Hh4wOJHW7shW0V5DKZeqncVX/egzVhFEU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=KXx/QFd4; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KXx/QFd4" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-540218726d5so2765668e87.2 for ; Fri, 24 Jan 2025 13:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737755271; x=1738360071; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JhgOYJOSO/9HW8pwqjPKCM7ncfLkuDOo3BKPxNB2SGk=; b=KXx/QFd4kbH76u+zJQMLGYyhxjjlabTw1rSIwJgkj+9qUbVlTPGMGVv7ERuC1ww+js dvHAhXQCqvjls5qd15/R6fp/xq15IOtqNl47M6drUa3qYJDPnWU6L/TfmRu8eVBUSc21 Y6+ujIpxzYNY+Vh18LolkLCeMzgLiTpRSuQXEdhz99YGVzmiN7d7ylahQWk9gantRQjC F6IoyTChmCHQNAK969Akz3/Np5bWNs8wbmfxBPbx3xW8qMcnUNVcvEcDhpoD/6eGldaL VUKWUF3ByfAesU2k+tG9/NeFaxKT5t/JXuRWDN8SA5aJDyC3pHDxgjvUoSCjQdAq0cKg ugfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737755271; x=1738360071; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JhgOYJOSO/9HW8pwqjPKCM7ncfLkuDOo3BKPxNB2SGk=; b=Uf7qwMJsWTcbPx/ovUUtRQt0UBCukFUzBAxcw6ZrogUALQji8D9+4DT/HGOmN2XKZk BtoHLjnu944Yaujt/ldkWjJ/WUyhcB2+NoZ8934fiRWtEs5ftEjDqVL32B9skB1LjxD2 0BkAxpz4u1Bof3EJj8mlPtx9jytKkFIJy4EDvRHQpa3GRkSxY8zSY6Z4FX0c1Oo97e61 Io/UkDI7Yw0w3KZTAxHh5M/TJiwvdPkfTnMo2Yk4pee8xxeFni7Ei/5gXxxO1klXOqkO Jvy/p0pEQjDnEw57Wnrbey3YA72WQwlc3hJ9GSwk64+lTXBoiNjw+YPOaHDj22IeIlJ9 4Ydg== X-Forwarded-Encrypted: i=1; AJvYcCUm6h2EgXJycy2mvrXn7bpvkd4OM3dnoMPPu8cXVjwIFuQg9Mhb75gEr5nFCu/KalLiVQ/nggW/bEfyfn5I@vger.kernel.org X-Gm-Message-State: AOJu0YxF8vY8mrrSg12UozWZD4iZiSgbBzwzwhEB9GurolIwrW4FwTdz GQwz7BXat+lhbcbi4L0qw7l/BWFX6T5YBXOq7OTwX/1klmCkM7HXJHpQdKAqqwM= X-Gm-Gg: ASbGncu/w2hHg893UfepDp7Us8kvhsVGjOXb8LXOPf/bJidpoIrIC2XqarbL05Q1v+g VhlzMscdglvYpOaYZrDKoJ6WCFBFd/RSudxj2tBczW124s1jVguerCcGKIzBbXZfoAuLUM3CXiQ IsYTY/V/6OtArddBK/f0caGPEa8kAFEBUdjh2I04nQa/6G+l505igs6WTgcWfQ/MPPErd6mQO1D 2caYwSaGPYWGvutRjTIBfesgsGB4c1afKogFwNOkQu1ht/WogOpflNTNS+jtzsxuHyCBDIFdStY m5A+w1nKE3Iu X-Google-Smtp-Source: AGHT+IG3aO38brRrPH4wfS/ESF1jDMyHBbkUhw38gLmmUNsh6Y0+nVc1isQgg/XzuGkki5VpcQLIEA== X-Received: by 2002:a05:6512:33cf:b0:540:202f:4955 with SMTP id 2adb3069b0e04-5439c287371mr10458923e87.46.1737755270703; Fri, 24 Jan 2025 13:47:50 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543c8237491sm425014e87.104.2025.01.24.13.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 13:47:49 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 24 Jan 2025 23:47:42 +0200 Subject: [PATCH v6 2/7] drm/msm/hdmi: program HDMI timings during atomic_pre_enable Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-bridge-hdmi-connector-v6-2-1592632327f7@linaro.org> References: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> In-Reply-To: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3301; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=kSze1JGUTOGCYF8m3i4MYZAmp4xJmoIk6UQOajOdpeU=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnlAp/oXLWfpEl1f2La3MXrLoICQDHEdQlVqJGS Hgv35KeEmuJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5QKfwAKCRCLPIo+Aiko 1ZuSB/9DaAKzIUw5clYrcanQGnGX9s9BZCzORMBcPpZTGFMZKIJKxqmI9pCa2ex2sDnjak/OPfg NCfGVtGE5BYeOSgfgwCO82Pk09Ied3no7INTtYIVVnLooa7Z2DTUhOJc26H1V3qwhHz1/4K3LVM WoHbtgpGyBUseefhJoX8mJy1nHHAdH1mfyzRT1DoPwuwDHDg5y+rAbpS1zegi9slnm0kO5yCjaJ gaYi6y0C5K6UQY8SFawJRHAJz6d9GDSHvAoycThmdjKhV7v1BPW3gqGiZoYet6InKQmngG3cT2C vKaFFC87Be6XJgM71aJisvBbNbz4hdqIANRYkHj8bnceCFIz X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A The mode_set callback is deprecated, it doesn't get the drm_bridge_state, just mode-related argumetns. Also Abhinav pointed out that HDMI timings should be programmed after setting up HDMI PHY and PLL. Rework the code to program HDMI timings at the end of atomic_pre_enable(). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c index d839c71091dcdc3b020fcbba8d698d58ee7fc749..d5ab1f74c0e6f47dc59872c016104e9a84d85e9e 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -126,15 +126,26 @@ static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); } +static void msm_hdmi_bridge_atomic_set_timings(struct hdmi *hdmi, + const struct drm_display_mode *mode); static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, struct drm_bridge_state *old_bridge_state) { + struct drm_atomic_state *state = old_bridge_state->base.state; struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); struct hdmi *hdmi = hdmi_bridge->hdmi; struct hdmi_phy *phy = hdmi->phy; + struct drm_encoder *encoder = bridge->encoder; + struct drm_connector *connector; + struct drm_connector_state *conn_state; + struct drm_crtc_state *crtc_state; DBG("power up"); + connector = drm_atomic_get_new_connector_for_encoder(state, encoder); + conn_state = drm_atomic_get_new_connector_state(state, connector); + crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc); + if (!hdmi->power_on) { msm_hdmi_phy_resource_enable(phy); msm_hdmi_power_on(bridge); @@ -151,6 +162,8 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, if (hdmi->hdcp_ctrl) msm_hdmi_hdcp_on(hdmi->hdcp_ctrl); + + msm_hdmi_bridge_atomic_set_timings(hdmi, &crtc_state->adjusted_mode); } static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge, @@ -177,17 +190,12 @@ static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge, } } -static void msm_hdmi_bridge_mode_set(struct drm_bridge *bridge, - const struct drm_display_mode *mode, - const struct drm_display_mode *adjusted_mode) +static void msm_hdmi_bridge_atomic_set_timings(struct hdmi *hdmi, + const struct drm_display_mode *mode) { - struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); - struct hdmi *hdmi = hdmi_bridge->hdmi; int hstart, hend, vstart, vend; uint32_t frame_ctrl; - mode = adjusted_mode; - hdmi->pixclock = mode->clock * 1000; hstart = mode->htotal - mode->hsync_start; @@ -306,7 +314,6 @@ static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = { .atomic_reset = drm_atomic_helper_bridge_reset, .atomic_pre_enable = msm_hdmi_bridge_atomic_pre_enable, .atomic_post_disable = msm_hdmi_bridge_atomic_post_disable, - .mode_set = msm_hdmi_bridge_mode_set, .mode_valid = msm_hdmi_bridge_mode_valid, .edid_read = msm_hdmi_bridge_edid_read, .detect = msm_hdmi_bridge_detect, From patchwork Fri Jan 24 21:47:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 859656 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82CF51E98EF for ; Fri, 24 Jan 2025 21:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755277; cv=none; b=cDlMdKETxzByrB+qx7Pmr65L8p/a/48iZH62nKoMs6XQ9rTT1LHVoNDlTtNmOTFU4xuDxBWg2/aWc99P7KcDQaRp6rc6E1mTucdL4W122PJJX+JisyM//Q5jjAqE3Ez3wUa0RpmBWstyQZP31A3ymPfO9h35w/Ke4+6JpXxbkd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755277; c=relaxed/simple; bh=aUFnzCOLwI3rcPXFc0KGTqsfg1fNX73fbcUmk4iVIWw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C+/OVC8zK93YKjkNBe7BSRVnwel1L0hS/3J6EXH564r8Sw6bpyuNIj3Xcreg/OqR6rFH0vFSt2HnqDMJzB2rB1voL6XUqdQa+LF8AF+7ugxiHCRql58D+dgICtVdVUaZ+t7t23JiaeUumHAbTtLtlqucvXRfm+G+SgIE5XyeR0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=EWnh5BXA; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EWnh5BXA" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5401bd6cdb7so2705864e87.2 for ; Fri, 24 Jan 2025 13:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737755272; x=1738360072; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=218UCCirz0adWycPKYaSzNsLxEvuZWNW6UJ0wiWvVao=; b=EWnh5BXARFAbikLnwg82JT+Cqb14HsJqBPDpWkZz76HWumCzgLLgkmVdXk1JCCHxn3 EdJcDbv0uZitUdiPZB/JpSuwAIajiaesSNnI58/7wN54QE2e7Japm1xUr21C/xGq27x5 ISFzxkB7YtNoBhFg9IhCt5fUDgFaqJcFdhfPNofJyG3iwHxiC66/V7w606A+ODsC51Ji HSLyExT19AHMVnnNVlEUG5xvyGk0wu/wZfOxMbHsj58nBQxEGH/1mAKQC4APnlAbXpZT cEn1ewcq/Ly3FmHSw213hZGSqP3zHASCDzGjsNNZhjTERM6MAOegdxgiEcEvwewI/g1u WAvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737755272; x=1738360072; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=218UCCirz0adWycPKYaSzNsLxEvuZWNW6UJ0wiWvVao=; b=KrFAJH8Y1AqxpKmJLAljRX5QZSRJmdnLSLC+lDKY5LdH0BuVDH4u1B13urFbdqtfsM gadFtyDc/CkONdBm/+gAg1KnhfjgrZOJKt4gDjAfR+KhaOrF42UWYB2+WdGMQRcOfjt4 8ThAqM2bKFqP58orQwAjsqRG3MjopL90fE54N+pNO80u/5sIVF5SsAiPLLj1hobGW3Bm wQeGNDPb/NBYIOEotqqbz9UetscOtS6tntXW3GN1ocL5bWO32fKeQ7/JszP3anzGOAvk PtEzsl/lxtCduQqQaNuPhYTC7zcvAWzvVLwtoeo9TutsN0FkIT7vdAYhfUNrWbmulAir Ilbg== X-Forwarded-Encrypted: i=1; AJvYcCX6odHxntUXzkAKm3IeXnuusSX2JwGNqE8Olgx0twiP0CBLLZ+MIzIC0+nczoiloNnMcUtEzt9lLrYUgA0i@vger.kernel.org X-Gm-Message-State: AOJu0YzTwfTLFZFGXZLxfl8NHWwUXtpXG0gutkz3Cpt4xugCWTu7coXE eeWIBt8DW0FiwmlBi0sNJIqAyru3KNSP2AAmR+BwBeuZj7/kM0HZzpCnFpfKRh0= X-Gm-Gg: ASbGnct0+AVyPrj21T0Mw8/bFeP8WYMW6AYgcWvKrl+zL2BoNYESWkQI4Vdf4mspq83 bBz0iwNy8nDZItGv1Us2Ufe9MhFcOtptahnvJMM36uBLX93bw/lJLTjTmgJZhh8hx8lqeXGuLRH J+YSVD5zuwlWakOBZPV9QMS5dRsshKzx4uC6nA3f7xdoVDEAPOG8mYck2mF1vti6w8Lwk4OedUg aPACNFlJNbCKfYRHP1p5/dpbUxEoU3pDlP9MIqTFgKhFYcdAenxFy2nbEzYxlufKTaLTlmWTVNt 6lcHmBc0xWVA X-Google-Smtp-Source: AGHT+IElm/Asqb946d6xfMLis2dYG51U1RwpV5Sj+GUiw/PxhvdBh4k319aX8D8tg9lEDQjFrOnHMg== X-Received: by 2002:a05:6512:1104:b0:53e:df2b:df25 with SMTP id 2adb3069b0e04-5439c228ceemr12330422e87.16.1737755272340; Fri, 24 Jan 2025 13:47:52 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543c8237491sm425014e87.104.2025.01.24.13.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 13:47:51 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 24 Jan 2025 23:47:43 +0200 Subject: [PATCH v6 3/7] drm/msm/hdmi: make use of the drm_connector_hdmi framework Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-bridge-hdmi-connector-v6-3-1592632327f7@linaro.org> References: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> In-Reply-To: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=21579; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=aUFnzCOLwI3rcPXFc0KGTqsfg1fNX73fbcUmk4iVIWw=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnlAqAiK4haZBE3v7FWCPHryoNjLDbgaTaj1Z7m bPjuR8IxJOJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5QKgAAKCRCLPIo+Aiko 1RpNB/0Wu0eu6UMmXd7eKGqlxEJKkNkSAGqyj/UY0BTXdXSE7i2la3cSi+TQ6IzG8Spl+ntamaM 3TFQ1WUyh85R5kl7BY1gFt2Icio+wdQ5bIm9uusvKPNRsmRpcuUlbTeXbcXifhmzEbicTQnxSkR 6mA3reHLJt+yLgj1Kezh7P5el4NszXLk0M2u0/i68fjSxHZLiwo9e1ulBY80eQfbKpup4aTjMxx fPWUyoT0z4mW9dVGR69Sx4s49xZim5JZc33LXOeIT8PhGFajZQS88f2KdHdTeKR8EcUdYRlQVsG 9I2eaivvse5LQGn8fmqSYf88V0vasuQDbKvDVSofPu/cA603 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Setup the HDMI connector on the MSM HDMI outputs. Make use of atomic_check hook and of the provided Infoframe infrastructure. Acked-by: Maxime Ripard Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/Kconfig | 2 + drivers/gpu/drm/msm/hdmi/hdmi.c | 45 ++------- drivers/gpu/drm/msm/hdmi/hdmi.h | 16 +-- drivers/gpu/drm/msm/hdmi/hdmi_audio.c | 74 ++++---------- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 180 +++++++++++++++++++++++---------- 5 files changed, 162 insertions(+), 155 deletions(-) diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig index 7ec833b6d8292f8cb26cfe5582812f2754cd4d35..974bc7c0ea761147d3326bdce9039d6f26f290d0 100644 --- a/drivers/gpu/drm/msm/Kconfig +++ b/drivers/gpu/drm/msm/Kconfig @@ -170,6 +170,8 @@ config DRM_MSM_HDMI bool "Enable HDMI support in MSM DRM driver" depends on DRM_MSM default y + select DRM_DISPLAY_HDMI_HELPER + select DRM_DISPLAY_HDMI_STATE_HELPER help Compile in support for the HDMI output MSM DRM driver. It can be a primary or a secondary display on device. Note that this is used diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 37b3809c6bdd7c35aca6b475cb1f41c0ab4d3e6d..b14205cb9e977edd0d849e0eafe9b69c0da594bd 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -12,6 +12,7 @@ #include #include +#include #include #include "hdmi.h" @@ -165,8 +166,6 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, hdmi->dev = dev; hdmi->encoder = encoder; - hdmi_audio_infoframe_init(&hdmi->audio.infoframe); - ret = msm_hdmi_bridge_init(hdmi); if (ret) { DRM_DEV_ERROR(dev->dev, "failed to create HDMI bridge: %d\n", ret); @@ -254,40 +253,12 @@ static int msm_hdmi_audio_hw_params(struct device *dev, void *data, struct hdmi_codec_params *params) { struct hdmi *hdmi = dev_get_drvdata(dev); - unsigned int chan; - unsigned int channel_allocation = 0; unsigned int rate; - unsigned int level_shift = 0; /* 0dB */ - bool down_mix = false; + int ret; DRM_DEV_DEBUG(dev, "%u Hz, %d bit, %d channels\n", params->sample_rate, params->sample_width, params->cea.channels); - switch (params->cea.channels) { - case 2: - /* FR and FL speakers */ - channel_allocation = 0; - chan = MSM_HDMI_AUDIO_CHANNEL_2; - break; - case 4: - /* FC, LFE, FR and FL speakers */ - channel_allocation = 0x3; - chan = MSM_HDMI_AUDIO_CHANNEL_4; - break; - case 6: - /* RR, RL, FC, LFE, FR and FL speakers */ - channel_allocation = 0x0B; - chan = MSM_HDMI_AUDIO_CHANNEL_6; - break; - case 8: - /* FRC, FLC, RR, RL, FC, LFE, FR and FL speakers */ - channel_allocation = 0x1F; - chan = MSM_HDMI_AUDIO_CHANNEL_8; - break; - default: - return -EINVAL; - } - switch (params->sample_rate) { case 32000: rate = HDMI_SAMPLE_RATE_32KHZ; @@ -316,9 +287,12 @@ static int msm_hdmi_audio_hw_params(struct device *dev, void *data, return -EINVAL; } - msm_hdmi_audio_set_sample_rate(hdmi, rate); - msm_hdmi_audio_info_setup(hdmi, 1, chan, channel_allocation, - level_shift, down_mix); + ret = drm_atomic_helper_connector_hdmi_update_audio_infoframe(hdmi->connector, + ¶ms->cea); + if (ret) + return ret; + + msm_hdmi_audio_info_setup(hdmi, rate, params->cea.channels); return 0; } @@ -327,7 +301,8 @@ static void msm_hdmi_audio_shutdown(struct device *dev, void *data) { struct hdmi *hdmi = dev_get_drvdata(dev); - msm_hdmi_audio_info_setup(hdmi, 0, 0, 0, 0, 0); + drm_atomic_helper_connector_hdmi_clear_audio_infoframe(hdmi->connector); + msm_hdmi_audio_disable(hdmi); } static const struct hdmi_codec_ops msm_hdmi_audio_codec_ops = { diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.h b/drivers/gpu/drm/msm/hdmi/hdmi.h index a62d2aedfbb7239d37c826c4f96762f100a2be4a..53b52351d0eddf4a5c87a5290016bb53ed4d29f7 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.h +++ b/drivers/gpu/drm/msm/hdmi/hdmi.h @@ -24,8 +24,8 @@ struct hdmi_platform_config; struct hdmi_audio { bool enabled; - struct hdmi_audio_infoframe infoframe; int rate; + int channels; }; struct hdmi_hdcp_ctrl; @@ -207,12 +207,6 @@ static inline int msm_hdmi_pll_8998_init(struct platform_device *pdev) /* * audio: */ -/* Supported HDMI Audio channels and rates */ -#define MSM_HDMI_AUDIO_CHANNEL_2 0 -#define MSM_HDMI_AUDIO_CHANNEL_4 1 -#define MSM_HDMI_AUDIO_CHANNEL_6 2 -#define MSM_HDMI_AUDIO_CHANNEL_8 3 - #define HDMI_SAMPLE_RATE_32KHZ 0 #define HDMI_SAMPLE_RATE_44_1KHZ 1 #define HDMI_SAMPLE_RATE_48KHZ 2 @@ -221,12 +215,8 @@ static inline int msm_hdmi_pll_8998_init(struct platform_device *pdev) #define HDMI_SAMPLE_RATE_176_4KHZ 5 #define HDMI_SAMPLE_RATE_192KHZ 6 -int msm_hdmi_audio_update(struct hdmi *hdmi); -int msm_hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled, - uint32_t num_of_channels, uint32_t channel_allocation, - uint32_t level_shift, bool down_mix); -void msm_hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate); - +int msm_hdmi_audio_info_setup(struct hdmi *hdmi, int rate, int channels); +int msm_hdmi_audio_disable(struct hdmi *hdmi); /* * hdmi bridge: diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_audio.c b/drivers/gpu/drm/msm/hdmi/hdmi_audio.c index 4c2058c4adc1001a12e10f35e88a6d58f3bd2fdc..924654bfb48cf17feadea1c0661ee6ee4e1b4589 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_audio.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_audio.c @@ -7,9 +7,6 @@ #include #include "hdmi.h" -/* maps MSM_HDMI_AUDIO_CHANNEL_n consts used by audio driver to # of channels: */ -static int nchannels[] = { 2, 4, 6, 8 }; - /* Supported HDMI Audio sample rates */ #define MSM_HDMI_SAMPLE_RATE_32KHZ 0 #define MSM_HDMI_SAMPLE_RATE_44_1KHZ 1 @@ -71,19 +68,20 @@ static const struct hdmi_msm_audio_arcs *get_arcs(unsigned long int pixclock) return NULL; } -int msm_hdmi_audio_update(struct hdmi *hdmi) +static int msm_hdmi_audio_update(struct hdmi *hdmi) { struct hdmi_audio *audio = &hdmi->audio; - struct hdmi_audio_infoframe *info = &audio->infoframe; const struct hdmi_msm_audio_arcs *arcs = NULL; bool enabled = audio->enabled; uint32_t acr_pkt_ctrl, vbi_pkt_ctrl, aud_pkt_ctrl; - uint32_t infofrm_ctrl, audio_config; + uint32_t audio_config; + + if (!hdmi->connector->display_info.is_hdmi) + return -EINVAL; + + DBG("audio: enabled=%d, channels=%d, rate=%d", + audio->enabled, audio->channels, audio->rate); - DBG("audio: enabled=%d, channels=%d, channel_allocation=0x%x, " - "level_shift_value=%d, downmix_inhibit=%d, rate=%d", - audio->enabled, info->channels, info->channel_allocation, - info->level_shift_value, info->downmix_inhibit, audio->rate); DBG("video: power_on=%d, pixclock=%lu", hdmi->power_on, hdmi->pixclock); if (enabled && !(hdmi->power_on && hdmi->pixclock)) { @@ -104,7 +102,6 @@ int msm_hdmi_audio_update(struct hdmi *hdmi) acr_pkt_ctrl = hdmi_read(hdmi, REG_HDMI_ACR_PKT_CTRL); vbi_pkt_ctrl = hdmi_read(hdmi, REG_HDMI_VBI_PKT_CTRL); aud_pkt_ctrl = hdmi_read(hdmi, REG_HDMI_AUDIO_PKT_CTRL1); - infofrm_ctrl = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL0); audio_config = hdmi_read(hdmi, REG_HDMI_AUDIO_CFG); /* Clear N/CTS selection bits */ @@ -113,7 +110,6 @@ int msm_hdmi_audio_update(struct hdmi *hdmi) if (enabled) { uint32_t n, cts, multiplier; enum hdmi_acr_cts select; - uint8_t buf[14]; n = arcs->lut[audio->rate].n; cts = arcs->lut[audio->rate].cts; @@ -155,20 +151,12 @@ int msm_hdmi_audio_update(struct hdmi *hdmi) HDMI_ACR_1_N(n)); hdmi_write(hdmi, REG_HDMI_AUDIO_PKT_CTRL2, - COND(info->channels != 2, HDMI_AUDIO_PKT_CTRL2_LAYOUT) | + COND(audio->channels != 2, HDMI_AUDIO_PKT_CTRL2_LAYOUT) | HDMI_AUDIO_PKT_CTRL2_OVERRIDE); acr_pkt_ctrl |= HDMI_ACR_PKT_CTRL_CONT; acr_pkt_ctrl |= HDMI_ACR_PKT_CTRL_SEND; - /* configure infoframe: */ - hdmi_audio_infoframe_pack(info, buf, sizeof(buf)); - hdmi_write(hdmi, REG_HDMI_AUDIO_INFO0, - (buf[3] << 0) | (buf[4] << 8) | - (buf[5] << 16) | (buf[6] << 24)); - hdmi_write(hdmi, REG_HDMI_AUDIO_INFO1, - (buf[7] << 0) | (buf[8] << 8)); - hdmi_write(hdmi, REG_HDMI_GC, 0); vbi_pkt_ctrl |= HDMI_VBI_PKT_CTRL_GC_ENABLE; @@ -176,11 +164,6 @@ int msm_hdmi_audio_update(struct hdmi *hdmi) aud_pkt_ctrl |= HDMI_AUDIO_PKT_CTRL1_AUDIO_SAMPLE_SEND; - infofrm_ctrl |= HDMI_INFOFRAME_CTRL0_AUDIO_INFO_SEND; - infofrm_ctrl |= HDMI_INFOFRAME_CTRL0_AUDIO_INFO_CONT; - infofrm_ctrl |= HDMI_INFOFRAME_CTRL0_AUDIO_INFO_SOURCE; - infofrm_ctrl |= HDMI_INFOFRAME_CTRL0_AUDIO_INFO_UPDATE; - audio_config &= ~HDMI_AUDIO_CFG_FIFO_WATERMARK__MASK; audio_config |= HDMI_AUDIO_CFG_FIFO_WATERMARK(4); audio_config |= HDMI_AUDIO_CFG_ENGINE_ENABLE; @@ -190,17 +173,12 @@ int msm_hdmi_audio_update(struct hdmi *hdmi) vbi_pkt_ctrl &= ~HDMI_VBI_PKT_CTRL_GC_ENABLE; vbi_pkt_ctrl &= ~HDMI_VBI_PKT_CTRL_GC_EVERY_FRAME; aud_pkt_ctrl &= ~HDMI_AUDIO_PKT_CTRL1_AUDIO_SAMPLE_SEND; - infofrm_ctrl &= ~HDMI_INFOFRAME_CTRL0_AUDIO_INFO_SEND; - infofrm_ctrl &= ~HDMI_INFOFRAME_CTRL0_AUDIO_INFO_CONT; - infofrm_ctrl &= ~HDMI_INFOFRAME_CTRL0_AUDIO_INFO_SOURCE; - infofrm_ctrl &= ~HDMI_INFOFRAME_CTRL0_AUDIO_INFO_UPDATE; audio_config &= ~HDMI_AUDIO_CFG_ENGINE_ENABLE; } hdmi_write(hdmi, REG_HDMI_ACR_PKT_CTRL, acr_pkt_ctrl); hdmi_write(hdmi, REG_HDMI_VBI_PKT_CTRL, vbi_pkt_ctrl); hdmi_write(hdmi, REG_HDMI_AUDIO_PKT_CTRL1, aud_pkt_ctrl); - hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, infofrm_ctrl); hdmi_write(hdmi, REG_HDMI_AUD_INT, COND(enabled, HDMI_AUD_INT_AUD_FIFO_URUN_INT) | @@ -214,41 +192,29 @@ int msm_hdmi_audio_update(struct hdmi *hdmi) return 0; } -int msm_hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled, - uint32_t num_of_channels, uint32_t channel_allocation, - uint32_t level_shift, bool down_mix) +int msm_hdmi_audio_info_setup(struct hdmi *hdmi, int rate, int channels) { - struct hdmi_audio *audio; - if (!hdmi) return -ENXIO; - audio = &hdmi->audio; - - if (num_of_channels >= ARRAY_SIZE(nchannels)) + if ((rate < 0) || (rate >= MSM_HDMI_SAMPLE_RATE_MAX)) return -EINVAL; - audio->enabled = enabled; - audio->infoframe.channels = nchannels[num_of_channels]; - audio->infoframe.channel_allocation = channel_allocation; - audio->infoframe.level_shift_value = level_shift; - audio->infoframe.downmix_inhibit = down_mix; + hdmi->audio.rate = rate; + hdmi->audio.channels = channels; + hdmi->audio.enabled = true; return msm_hdmi_audio_update(hdmi); } -void msm_hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate) +int msm_hdmi_audio_disable(struct hdmi *hdmi) { - struct hdmi_audio *audio; - if (!hdmi) - return; - - audio = &hdmi->audio; + return -ENXIO; - if ((rate < 0) || (rate >= MSM_HDMI_SAMPLE_RATE_MAX)) - return; + hdmi->audio.rate = 0; + hdmi->audio.channels = 2; + hdmi->audio.enabled = false; - audio->rate = rate; - msm_hdmi_audio_update(hdmi); + return msm_hdmi_audio_update(hdmi); } diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c index d5ab1f74c0e6f47dc59872c016104e9a84d85e9e..168b4104e705e8217f5d7ca5f902d7557c55ae24 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "msm_kms.h" #include "hdmi.h" @@ -68,23 +70,17 @@ static void power_off(struct drm_bridge *bridge) #define AVI_IFRAME_LINE_NUMBER 1 -static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) +static int msm_hdmi_config_avi_infoframe(struct hdmi *hdmi, + const u8 *buffer, size_t len) { - struct drm_crtc *crtc = hdmi->encoder->crtc; - const struct drm_display_mode *mode = &crtc->state->adjusted_mode; - union hdmi_infoframe frame; - u8 buffer[HDMI_INFOFRAME_SIZE(AVI)]; + u32 buf[4] = {}; u32 val; - int len; + int i; - drm_hdmi_avi_infoframe_from_display_mode(&frame.avi, - hdmi->connector, mode); - - len = hdmi_infoframe_pack(&frame, buffer, sizeof(buffer)); - if (len < 0) { + if (len != HDMI_INFOFRAME_SIZE(AVI) || len - 3 > sizeof(buf)) { DRM_DEV_ERROR(&hdmi->pdev->dev, "failed to configure avi infoframe\n"); - return; + return -EINVAL; } /* @@ -93,37 +89,118 @@ static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) * written to the LSB byte of AVI_INFO0 and the version is written to * the third byte from the LSB of AVI_INFO3 */ - hdmi_write(hdmi, REG_HDMI_AVI_INFO(0), + memcpy(buf, &buffer[3], len - 3); + + buf[3] |= buffer[1] << 24; + + for (i = 0; i < ARRAY_SIZE(buf); i++) + hdmi_write(hdmi, REG_HDMI_AVI_INFO(i), buf[i]); + + val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); + val |= HDMI_INFOFRAME_CTRL0_AVI_SEND | + HDMI_INFOFRAME_CTRL0_AVI_CONT; + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, val); + + val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); + val &= ~HDMI_INFOFRAME_CTRL1_AVI_INFO_LINE__MASK; + val |= HDMI_INFOFRAME_CTRL1_AVI_INFO_LINE(AVI_IFRAME_LINE_NUMBER); + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); + + return 0; +} + +static int msm_hdmi_config_audio_infoframe(struct hdmi *hdmi, + const u8 *buffer, size_t len) +{ + u32 val; + + if (len != HDMI_INFOFRAME_SIZE(AUDIO)) { + DRM_DEV_ERROR(&hdmi->pdev->dev, + "failed to configure audio infoframe\n"); + return -EINVAL; + } + + hdmi_write(hdmi, REG_HDMI_AUDIO_INFO0, buffer[3] | buffer[4] << 8 | buffer[5] << 16 | buffer[6] << 24); - hdmi_write(hdmi, REG_HDMI_AVI_INFO(1), + hdmi_write(hdmi, REG_HDMI_AUDIO_INFO1, buffer[7] | buffer[8] << 8 | buffer[9] << 16 | buffer[10] << 24); - hdmi_write(hdmi, REG_HDMI_AVI_INFO(2), - buffer[11] | - buffer[12] << 8 | - buffer[13] << 16 | - buffer[14] << 24); + val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); + val |= HDMI_INFOFRAME_CTRL0_AUDIO_INFO_SEND | + HDMI_INFOFRAME_CTRL0_AUDIO_INFO_CONT | + HDMI_INFOFRAME_CTRL0_AUDIO_INFO_SOURCE | + HDMI_INFOFRAME_CTRL0_AUDIO_INFO_UPDATE; + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, val); + + return 0; +} + +static int msm_hdmi_bridge_clear_infoframe(struct drm_bridge *bridge, + enum hdmi_infoframe_type type) +{ + struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); + struct hdmi *hdmi = hdmi_bridge->hdmi; + u32 val; + + switch (type) { + case HDMI_INFOFRAME_TYPE_AVI: + val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL0); + val &= ~(HDMI_INFOFRAME_CTRL0_AVI_SEND | + HDMI_INFOFRAME_CTRL0_AVI_CONT); + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, val); - hdmi_write(hdmi, REG_HDMI_AVI_INFO(3), - buffer[15] | - buffer[16] << 8 | - buffer[1] << 24); + val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); + val &= ~HDMI_INFOFRAME_CTRL1_AVI_INFO_LINE__MASK; + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); - hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, - HDMI_INFOFRAME_CTRL0_AVI_SEND | - HDMI_INFOFRAME_CTRL0_AVI_CONT); + break; - val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); - val &= ~HDMI_INFOFRAME_CTRL1_AVI_INFO_LINE__MASK; - val |= HDMI_INFOFRAME_CTRL1_AVI_INFO_LINE(AVI_IFRAME_LINE_NUMBER); - hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); + case HDMI_INFOFRAME_TYPE_AUDIO: + val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL0); + val &= ~(HDMI_INFOFRAME_CTRL0_AUDIO_INFO_SEND | + HDMI_INFOFRAME_CTRL0_AUDIO_INFO_CONT | + HDMI_INFOFRAME_CTRL0_AUDIO_INFO_SOURCE | + HDMI_INFOFRAME_CTRL0_AUDIO_INFO_UPDATE); + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, val); + + val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); + val &= ~HDMI_INFOFRAME_CTRL1_AUDIO_INFO_LINE__MASK; + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); + + break; + + default: + drm_dbg_driver(hdmi_bridge->base.dev, "Unsupported infoframe type %x\n", type); + } + + return 0; +} + +static int msm_hdmi_bridge_write_infoframe(struct drm_bridge *bridge, + enum hdmi_infoframe_type type, + const u8 *buffer, size_t len) +{ + struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); + struct hdmi *hdmi = hdmi_bridge->hdmi; + + msm_hdmi_bridge_clear_infoframe(bridge, type); + + switch (type) { + case HDMI_INFOFRAME_TYPE_AVI: + return msm_hdmi_config_avi_infoframe(hdmi, buffer, len); + case HDMI_INFOFRAME_TYPE_AUDIO: + return msm_hdmi_config_audio_infoframe(hdmi, buffer, len); + default: + drm_dbg_driver(hdmi_bridge->base.dev, "Unsupported infoframe type %x\n", type); + return 0; + } } static void msm_hdmi_bridge_atomic_set_timings(struct hdmi *hdmi, @@ -146,16 +223,16 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, conn_state = drm_atomic_get_new_connector_state(state, connector); crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc); + hdmi->pixclock = conn_state->hdmi.tmds_char_rate; + if (!hdmi->power_on) { msm_hdmi_phy_resource_enable(phy); msm_hdmi_power_on(bridge); hdmi->power_on = true; - if (hdmi->hdmi_mode) { - msm_hdmi_config_avi_infoframe(hdmi); - msm_hdmi_audio_update(hdmi); - } } + drm_atomic_helper_connector_hdmi_update_infoframes(connector, state); + msm_hdmi_phy_powerup(phy, hdmi->pixclock); msm_hdmi_set_mode(hdmi, true); @@ -184,8 +261,6 @@ static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge, if (hdmi->power_on) { power_off(bridge); hdmi->power_on = false; - if (hdmi->hdmi_mode) - msm_hdmi_audio_update(hdmi); msm_hdmi_phy_resource_disable(phy); } } @@ -196,8 +271,6 @@ static void msm_hdmi_bridge_atomic_set_timings(struct hdmi *hdmi, int hstart, hend, vstart, vend; uint32_t frame_ctrl; - hdmi->pixclock = mode->clock * 1000; - hstart = mode->htotal - mode->hsync_start; hend = mode->htotal - mode->hsync_start + mode->hdisplay; @@ -241,9 +314,6 @@ static void msm_hdmi_bridge_atomic_set_timings(struct hdmi *hdmi, frame_ctrl |= HDMI_FRAME_CTRL_INTERLACED_EN; DBG("frame_ctrl=%08x", frame_ctrl); hdmi_write(hdmi, REG_HDMI_FRAME_CTRL, frame_ctrl); - - if (hdmi->hdmi_mode) - msm_hdmi_audio_update(hdmi); } static const struct drm_edid *msm_hdmi_bridge_edid_read(struct drm_bridge *bridge, @@ -275,18 +345,16 @@ static const struct drm_edid *msm_hdmi_bridge_edid_read(struct drm_bridge *bridg return drm_edid; } -static enum drm_mode_status msm_hdmi_bridge_mode_valid(struct drm_bridge *bridge, - const struct drm_display_info *info, - const struct drm_display_mode *mode) +static enum drm_mode_status msm_hdmi_bridge_tmds_char_rate_valid(const struct drm_bridge *bridge, + const struct drm_display_mode *mode, + unsigned long long tmds_rate) { struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); struct hdmi *hdmi = hdmi_bridge->hdmi; const struct hdmi_platform_config *config = hdmi->config; struct msm_drm_private *priv = bridge->dev->dev_private; struct msm_kms *kms = priv->kms; - long actual, requested; - - requested = 1000 * mode->clock; + long actual; /* for mdp5/apq8074, we manage our own pixel clk (as opposed to * mdp4/dtv stuff where pixel clk is assigned to mdp/encoder @@ -294,15 +362,16 @@ static enum drm_mode_status msm_hdmi_bridge_mode_valid(struct drm_bridge *bridge */ if (kms->funcs->round_pixclk) actual = kms->funcs->round_pixclk(kms, - requested, hdmi_bridge->hdmi->encoder); + tmds_rate, + hdmi_bridge->hdmi->encoder); else if (config->pwr_clk_cnt > 0) - actual = clk_round_rate(hdmi->pwr_clks[0], requested); + actual = clk_round_rate(hdmi->pwr_clks[0], tmds_rate); else - actual = requested; + actual = tmds_rate; - DBG("requested=%ld, actual=%ld", requested, actual); + DBG("requested=%lld, actual=%ld", tmds_rate, actual); - if (actual != requested) + if (actual != tmds_rate) return MODE_CLOCK_RANGE; return 0; @@ -314,9 +383,11 @@ static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = { .atomic_reset = drm_atomic_helper_bridge_reset, .atomic_pre_enable = msm_hdmi_bridge_atomic_pre_enable, .atomic_post_disable = msm_hdmi_bridge_atomic_post_disable, - .mode_valid = msm_hdmi_bridge_mode_valid, .edid_read = msm_hdmi_bridge_edid_read, .detect = msm_hdmi_bridge_detect, + .hdmi_tmds_char_rate_valid = msm_hdmi_bridge_tmds_char_rate_valid, + .hdmi_clear_infoframe = msm_hdmi_bridge_clear_infoframe, + .hdmi_write_infoframe = msm_hdmi_bridge_write_infoframe, }; static void @@ -348,8 +419,11 @@ int msm_hdmi_bridge_init(struct hdmi *hdmi) bridge->funcs = &msm_hdmi_bridge_funcs; bridge->ddc = hdmi->i2c; bridge->type = DRM_MODE_CONNECTOR_HDMIA; + bridge->vendor = "Qualcomm"; + bridge->product = "Snapdragon"; bridge->ops = DRM_BRIDGE_OP_HPD | DRM_BRIDGE_OP_DETECT | + DRM_BRIDGE_OP_HDMI | DRM_BRIDGE_OP_EDID; ret = devm_drm_bridge_add(hdmi->dev->dev, bridge); From patchwork Fri Jan 24 21:47:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 860030 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0084D1EE7CF for ; Fri, 24 Jan 2025 21:47:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755278; cv=none; b=NmtV1Sq/i9JfjO9CZ0CsNl1n5GtIlJMn6KU07tOlJR6sgHCqxHyO6GftCu+ZlN9lQHLdAkKeDAMqazaRc/LHkqKHKd33ol3emVO8OTYPLMVYJUt6OKT/jeS9DJL4ouklUJzLLGpeCZoMcFa/aWzwlrQK/kS7lvCGptlnlJRemfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755278; c=relaxed/simple; bh=aou3NZ2IsnAD5iGdPhnxU9pcbpVRM8SciayIVBJPtQw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gM1sdjoUlN9+1+VHLOnGsja/Y9raAk/WIbfLYWLHy8gSwfXAwdDucXzr0Hj8p6pKX7FWrxXdF7g7uj+AlqWZplltvHMyTD10wvqXFiZuIvf9QVnSfmaW7e656dzNXKTP3AWCAWnLuQ6V+lFFBM2scnA/J/4BSJJaZyfpuUjl0AQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oYrz/4wQ; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oYrz/4wQ" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-53f757134cdso2938631e87.2 for ; Fri, 24 Jan 2025 13:47:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737755274; x=1738360074; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IlR9NecrQCHXfPm/fpyP+/Z9eRiAzSSG5PW1LZdxCBM=; b=oYrz/4wQLHpQND0oJ1bXklDueEnvj/brcA87U89Jyuf8Ttifp8zVe2N9zvUaa9oL/q TIz66Nx8LyTIleeIiNvpJOT0n0VuqofyFn/4Pmc6eodtVN2CM4tx7ZMC+jUygGpPKFAZ XkFKNzqgPQZkN77P2ATrPw/yjmfmPpxngfOzAMsbcG2EAIB1rhUwqewfKBFl20j99RnM iYY/VIkfOnazFCFYPA4V7Wpl98TPM8iB/pgepZXtYZll+Tv3f+8A77hPQmsCw7eo5ETV /5aD5Os/MZFOmZ9s6ElOarw713L646img970lF9UeDTDQeePW0IURM8ABxO7oe1C3jOA 2Sfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737755274; x=1738360074; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IlR9NecrQCHXfPm/fpyP+/Z9eRiAzSSG5PW1LZdxCBM=; b=H95un51/rPlC887HipDToR8SOSKY+W0oe6l/EXGwhVYRZBn5zjjpNeAwTxOd9Ubw6i sHSg1MqeOd8JZMdkexAqillrLYh1EYU6dFMcc8B+73/v89DasfVp+w/r+wQ+vlJ0OKk7 m31AMqlC3OJIAeZhDeGO3wwqGS90kVC46MFbjdD8qh6j3LuMCufEBUOViiI7es0R0BSm wdJMuNO4cZug9JEMq048ITvj2BXtY0W5UT0cSTOv7wL0O3rQkFdLc2eOy6MNoZ5QN/0F sNYZBDXJVPuIHDWO2FikdpqYFJ/Z4UfZjtZqU3gbS2wA2Op6CDHXiWtt8vzG6zdgNwUA tSuw== X-Forwarded-Encrypted: i=1; AJvYcCX647zUplQWm9JxkGu7OfCIvQ7UoJXhXfpy7uyH+953aE0BJ4Tapkd6L89dsksEUNEs/2SQztVRK97IXEQG@vger.kernel.org X-Gm-Message-State: AOJu0YzeEB37BpVbGKGHCUZHZa0eYnIOQ6SQw8kYi9ysAUXYKKcyCIhF GMZ0w8ciXB91pK/3BkZHpJSoO8oSwXSNs3Ud9q04A7Z4++Zar4G6fu8ySMtDVPk= X-Gm-Gg: ASbGncsqGiPPz9jgN8kjL9mWb+BU2cy7NOGblbZ6uKPfRjmO58mKF9dRuFeTbXHjSso 8al9Obbt+lp9ijd+LpXLdHESwj6Xp+HlUlLiv1Eytirl6aNY4nLkVGQvRXS/6py6gbS03fNnnVa o2hxB/5EtGS9vzL9gBi97rKLznWuM7DXBiz4vZOgokeOszllslwqxZ5sjgfIJbS7s6OD278S6hQ BX7fr30ouRCs/J6SUp+UIOgTVHJDkj5NBKYhILRV8XSXy40NNolW8VSZ7+Zzh2Lu/tW166THHiv vy0kx9Hy+8/l X-Google-Smtp-Source: AGHT+IGXL+mj9oYDRst1LN9GviPtKEUadsXKdC3ORUDf96ArRikq4g85LQu+uRln0PDevFa/gzjLMA== X-Received: by 2002:a05:6512:281c:b0:542:2ef4:4884 with SMTP id 2adb3069b0e04-5439c224ab8mr11127686e87.19.1737755273958; Fri, 24 Jan 2025 13:47:53 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543c8237491sm425014e87.104.2025.01.24.13.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 13:47:53 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 24 Jan 2025 23:47:44 +0200 Subject: [PATCH v6 4/7] drm/msm/hdmi: get rid of hdmi_mode Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-bridge-hdmi-connector-v6-4-1592632327f7@linaro.org> References: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> In-Reply-To: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2361; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=aou3NZ2IsnAD5iGdPhnxU9pcbpVRM8SciayIVBJPtQw=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ/oUrgbxWJ55MZdkS9mnekqdLJHVbzTZveFtmTCLsqCqW aRXgGsnozELAyMXg6yYIotPQcvUmE3JYR92TK2HGcTKBDKFgYtTACbSd5SDYYH05YleLerx68uc rGSavuRH8H3hNTjz6f+BcO5bOnt8FMs2CC9nvvJo9V+PN6UXEy+y+vx45cMiJHdXw231FinJQ// Pvf28Mvana49Sv8YZzxWF29S8tqktdbo48f7W1wcOi/vVfo3c9nVR1/bMfS3OEV/y6oLerNfRj+ DKO9wz5cfcOQ8iCg57267yWlYmUV6nLTbj05bFm2eabNnWr5tervRhZnvcEw4+O46Dj5PO5rw42 7HvX4awX3iUSHR/lHLY0awM5g1GZtHTkw+uldlzqeeB2PLW5Q66H65wtRfLfPi4ecbO4hKxcqMZ jx1z+yV/PcjVD41rYe3z1JWOF1j1uzcoOf4q8yTlb6rsAA== X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Use connector->display_info.is_hdmi instead of manually using drm_detect_hdmi_monitor(). Acked-by: Maxime Ripard Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi.c | 2 +- drivers/gpu/drm/msm/hdmi/hdmi.h | 2 -- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 11 ----------- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index b14205cb9e977edd0d849e0eafe9b69c0da594bd..6b77e0fb8d5ec218dfbf58215e2e12ad1dfb1b85 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -25,7 +25,7 @@ void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on) spin_lock_irqsave(&hdmi->reg_lock, flags); if (power_on) { ctrl |= HDMI_CTRL_ENABLE; - if (!hdmi->hdmi_mode) { + if (!hdmi->connector->display_info.is_hdmi) { ctrl |= HDMI_CTRL_HDMI; hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); ctrl &= ~HDMI_CTRL_HDMI; diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.h b/drivers/gpu/drm/msm/hdmi/hdmi.h index 53b52351d0eddf4a5c87a5290016bb53ed4d29f7..ab169b77377097dc22c0c718f65024cb8ad1d317 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.h +++ b/drivers/gpu/drm/msm/hdmi/hdmi.h @@ -67,8 +67,6 @@ struct hdmi { /* the encoder we are hooked to (outside of hdmi block) */ struct drm_encoder *encoder; - bool hdmi_mode; /* are we in hdmi mode? */ - int irq; struct workqueue_struct *workq; diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c index 168b4104e705e8217f5d7ca5f902d7557c55ae24..d2b25bcd8eb8f5cf4623e11c87ac5eea6e4b363d 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -331,17 +331,6 @@ static const struct drm_edid *msm_hdmi_bridge_edid_read(struct drm_bridge *bridg hdmi_write(hdmi, REG_HDMI_CTRL, hdmi_ctrl); - if (drm_edid) { - /* - * FIXME: This should use connector->display_info.is_hdmi from a - * path that has read the EDID and called - * drm_edid_connector_update(). - */ - const struct edid *edid = drm_edid_raw(drm_edid); - - hdmi->hdmi_mode = drm_detect_hdmi_monitor(edid); - } - return drm_edid; } From patchwork Fri Jan 24 21:47:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 859655 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 992601EEA31 for ; Fri, 24 Jan 2025 21:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755279; cv=none; b=HGisXbbzwI+ZwSBg3HEIWMPerFXOpBMOrJu+mba75WYEC6ti2JamumlldnUNzofBJ0IdXZRk1mqq+zGpnS/NoIYDgl9IHpJNclAiG6ayDl/owCPier/LtUoci9IASCZkDg0TbxDTtFFiMf2CO/DiTRmqpBFRpHk67GsvXG7zphE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755279; c=relaxed/simple; bh=KlCjBmWN3HQI30P1/iEnVtV7zXNb45CFcF9NRTzfcWY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KufkqKP2ThkwjQSO9skScc+hf+q29Ga8Zgc7m9h5hZYIlqufrHXCiGU5aFgsyf5CkToCHo6xGfpmZ/N8HmLaQRFD5tz31ivxYon0VSiEBv/Dw5drcxzrddi4j90/YkO3vg6pMznve8RO8jV26D62/9YIv2BVpQzpI4S3nd1y8VY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=RzwKftkM; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RzwKftkM" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-53ff1f7caaeso2632923e87.0 for ; Fri, 24 Jan 2025 13:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737755276; x=1738360076; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CHcNOzm1hcrclCZti3P3V9XcVq0n02C20x1XRNCo8a4=; b=RzwKftkMECaCFtRCv8VZ/Msx7thz4McxxHsX+zPeF3Y2pdlNVW9GruELNjJtgSL6bP q6IMPOnKAgaif8//SBGBNy//uViOLIVDRn0Sma6FIRt/97eTOcNGQzvwmSvPCFTZ3rCR ROgrGIS4OCy7ACkIKz+A7xBwtzPtJGSV2Y+zfmgR8Kq54snjrervtmsp+m9WzjdK9Tdz T3TZwtuX2FBP0GkB18eFNY7MegHBsxl2HWx+CwZnwnahig82Suy5Jxb7bhw5prHsFSv8 PAZh9YwzPagPf0bXCmAR02+shldp6e/QoYDnv4oumzqIsQepKvRGNtSXlfARL8nzzoI5 M8VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737755276; x=1738360076; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CHcNOzm1hcrclCZti3P3V9XcVq0n02C20x1XRNCo8a4=; b=mvKkf1LDbaw+CGTWSP8fkfky3q8NKgNZi67ttxhe9lWXPZLFxWARv6gVUCZTXIukCm rITAKwdTaCqJO6gm2spKQly9+AI1KF8EqJIR42itcpcqZeV6POwB7IDVfEdv6jXJVSFb MdfH41hWPnkn3XXNuYLpDCoyRTa+E9It+R5HUMrDV0RekGQ7xxkeAVXy2337H3j1kx45 /+bYGN2ZPbThE7Ez7SzL34/tvaaaLuhlRHIK4zl/59R+LJ29GJ5+Gi5QNHlzzKoMNDjQ 0Ayh6Q8C6180gherFNZ03syrCyQ1+7R/9O+eSk3oSROACQS05GDYy+FqF+ZPfHHgSB3n +Evg== X-Forwarded-Encrypted: i=1; AJvYcCUjZQNZVnnzLlxamdInLBYADMdV92JeGxky64CVI4VdoFzjuI8nfMIVgvuHt2iXkk3ehL7k31ZK3t8RcNhw@vger.kernel.org X-Gm-Message-State: AOJu0YwLNKZkfBgAzf80urHqxD75xgwAn4jcyOIVfs80LvPgJg7dgCVm TuETsnBz+CDBx1xDB/jxsK35467SN354aVgIZx41+FwmOw2JP85nmyYULp2KmUs= X-Gm-Gg: ASbGncu6JYwaWxYRsI1uQx9enwKT+iVVmbhgJOhlBryHuq4dInEGWxusBaQVUdBVF5W Ux02lTIoZEJKvX4XLYS9Hlvfe62TwplLyek9sSm2E/7ufwwzF3rAa33Pr5/sC2qhKWIX/pU/5Im BRpUyIg7jJ51KaxTpyntLFlJlxfOsBJsVZCJOSvx8HoBkVIu5Xihtz+IH1pqblKXcgD0wCnqt0h mdNA4k2G/k+Bpwfn76rTsG/G7GYZaLBFhLbkjr/fZx8SBGsk83SmqhedWRHMsLBmFImsVziWU2C F3J92/UHov7T X-Google-Smtp-Source: AGHT+IFpny/zo/QvD2GXtlBH9/Wtg+ovbNpfKxp+xQf1OkquKUpDU3+qItxFEm0+BjAibqtxEpoQgQ== X-Received: by 2002:ac2:442e:0:b0:540:1d37:e79 with SMTP id 2adb3069b0e04-5439c249e27mr10731792e87.27.1737755275629; Fri, 24 Jan 2025 13:47:55 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543c8237491sm425014e87.104.2025.01.24.13.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 13:47:55 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 24 Jan 2025 23:47:45 +0200 Subject: [PATCH v6 5/7] drm/msm/hdmi: update HDMI_GEN_PKT_CTRL_GENERIC0_UPDATE definition Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-bridge-hdmi-connector-v6-5-1592632327f7@linaro.org> References: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> In-Reply-To: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1225; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=KlCjBmWN3HQI30P1/iEnVtV7zXNb45CFcF9NRTzfcWY=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnlAqAj2Ty2fi86x5S8vz38vRE9W/qq6R3Kx+j8 s6w/jwMhVyJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5QKgAAKCRCLPIo+Aiko 1XyOB/sH/E/XcX6vWytKMOGonps4x1gxBkl4bp3Jc6yHxcVJse0xCsVLRWkTZmGH8H4pTNGlvjw 0lh0iM1h749lSc96XOQQ8YIZhoKyEy5VXPbZNbO+bXx4U+VLRjN2N7ISWrn49lk7ewlg+DaJ9i7 fWcbAteWQMWfcNlIE1llxXe66A2T1RZ/P8hohJIwgl8w7Xqw9BPp5oLgqW2XZazB94IRjNxz/w5 FrMw4/ngqacRX786m4IcsJUIc2+v7SYRgg5QzK/DbiHMa30YHHAIjD1mEp4blSC514ctkr43TWB nre1TR8wD6n6w+1y+Z5YqHm+00nzHwYB/eRWUjKRZGsMKH3b X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A The GENERIC0_UPDATE field is a single bit. Redefine it as boolean to simplify its usage in the driver. Reviewed-by: Abhinav Kumar Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/registers/display/hdmi.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/registers/display/hdmi.xml b/drivers/gpu/drm/msm/registers/display/hdmi.xml index 1cf1b14fbd919e041fd7ac8a0731d554d4468f4f..0ebb96297dae80940dc8a918d26cd58ff2e6f81a 100644 --- a/drivers/gpu/drm/msm/registers/display/hdmi.xml +++ b/drivers/gpu/drm/msm/registers/display/hdmi.xml @@ -131,7 +131,7 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> --> - + From patchwork Fri Jan 24 21:47:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 860029 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50CB11EEA50 for ; Fri, 24 Jan 2025 21:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755281; cv=none; b=oR/t+Ya39d1YVezWVYFnbo2GXpzj970IiOBcXVrLb9Dc/QgB+sYEl/zwP4xaFlZJqqJipjezNWzT2P8ZZxApR5u0KjM22yVnwkueiAdII7Ij9JusGDUEIXZO0hpIf3l0b4odzz3Hj9YNfZq4nAgTyqNloN45p2ZsWsRyAO0K8PQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755281; c=relaxed/simple; bh=ypMfUVcMuV2bxzV5D0UKlQ7W+VdrRVJ3N05XywV7S44=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WzuEUvmYKG810dmckiIIUcI6eZeZ3/Oc7MqQmzY4Vaguv4xb9nEAvbc0TAkEl7LSKfMbjsMkPgTfoRJlA+cq/Fe8RSKfgoS02+GtwLcPFyaCKNEjvDXi0bTFe++jnTmazTOzMfq+ToWnamH3EpmDjHi7FdJjZSgrEF+B6TEHqOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=JxSgnn0+; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="JxSgnn0+" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-30737db1ab1so23384151fa.1 for ; Fri, 24 Jan 2025 13:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737755277; x=1738360077; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iuIjI45U/dcDaX1yFgwDNBXncmV9p95867dXyO4Ck/I=; b=JxSgnn0+fqgWrlQ1nRIE6qhBySkdOwWrdrxUi81gNPBEwmsHQF+gfDkVxYZFmwP7iw /aoeO2+LW+pkYPUalVy25Sfpq4emFEmIfySKaJHfOv34x6X6gu1N458/gCgmj2gB/L/n B1eDLzll800IYHgDItsMG8QzQ7D4gyTVDtgpu9UNBdpHTcY9Fe5QNUM10Mpxq4eavhdG MIx1XfjatRiKGw7FiXOTYSaHuPb/zxUphCYZCdxLKb/wTLwBGvgVxPPWInnJZdq790dh E5xGa42TjZdSm+fE9EH+ihGnB9OqTgxJ/gRkFnAEepdjkX7/gU1fwHMZ2BaQFZMpV569 LCWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737755277; x=1738360077; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iuIjI45U/dcDaX1yFgwDNBXncmV9p95867dXyO4Ck/I=; b=YpDiqpAt//ak691R+P1FeiUqlBWKDWKK+W4EvU/hD0EBdgExD6LBimeL1Or07SF1ZR eC8e2e3PUVKnq7Ox1rukN6b44+mTcTy/T0t/okxaTOQqrfy4aFCSfMqqJyEbZOLDamg3 YZ628wj81Rs3Y5yNPngz7Big99Ls5mY06+PqBcxZhq3fz5cmP+7Ax4Sxa90/YP5GKSVw fZwNzaxFACoX+VUWKUqFDmIYM+AhnuSzDZ/j66A9TbcGbox4h+gcsAKO61FXsIcD4u4X iJ2x7NMz6GHe4nVcf6TYoQeNaYEKv6Ppg7/HUd4YSiHYGlZsdHgzh6RxVxYCynp6fUkP lGSA== X-Forwarded-Encrypted: i=1; AJvYcCVQ3cCXJs+6/qVZ/lQ2F4rdHuaxsr/my+naW1UUl12+mDa3p3LA5FhOOURp5uHjkuq1sFs8/x4ClxferGOJ@vger.kernel.org X-Gm-Message-State: AOJu0YzO0hI3/slFvs3vGqciDamQyU7kt1e+MNshnAiu9icaUZkOkNlQ dTXX5WDhaY51NYHN60WRdBQWSiOIBNN/lhbcQ2TbPwF70H6Cxruw43dtoYlC5Z0= X-Gm-Gg: ASbGncuNjyw7Yg3F2PCCZJyNKmzM+pVPggUa71Sa1wcpcZ19rxnexZ7vQ7mreZtqGyF q8CKjY959D9vrI3F9gHju59B2JIGae1vyF7CvpdGPK1BDbzhMlBTbLnuWFzE87RYlZJySSuL+5W IEhfflZqd4ShUnu1ALMuW/QqscY64M5ZDJ5jLxh99dkBNt6ms71G70m25sF/0HHxXtLDEdayBwm uhx0qwsYXgngFhJgJDgah1JykLvecm+I/agpEGfUhim/DtghVJpGTEuWd1iK58bZiOSPatCS4hq KUF9oEwNVyd7DrJEQZZEfKI= X-Google-Smtp-Source: AGHT+IH2PCxvWSi1I49WChIFLkDY5kjEE00ne3Y+IYzLaQPymzEuXvp0HTsrYDjW9kcThlu1z9dCDg== X-Received: by 2002:a05:6512:2346:b0:53e:23ec:b2e7 with SMTP id 2adb3069b0e04-5439c2805f9mr12813973e87.34.1737755277237; Fri, 24 Jan 2025 13:47:57 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543c8237491sm425014e87.104.2025.01.24.13.47.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 13:47:56 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 24 Jan 2025 23:47:46 +0200 Subject: [PATCH v6 6/7] drm/msm/hdmi: also send the SPD and HDMI Vendor Specific InfoFrames Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-bridge-hdmi-connector-v6-6-1592632327f7@linaro.org> References: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> In-Reply-To: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4721; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=ypMfUVcMuV2bxzV5D0UKlQ7W+VdrRVJ3N05XywV7S44=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnlAqA0lig50t0scgDkH3CmByQC7DMPRWpV5iNn czXL6JL372JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5QKgAAKCRCLPIo+Aiko 1Um7CACk7HhG0jg5KrovBcPX1eeON3Y3nXPBU5xQ8yf/WfdB/qcyiFqj/9VGY7Y+kT7MZDRCyds xsBCgvI1q888B61e/8U9C0S2fwFHGqTnnVxqP9Kl4XCtzxOCiXpe8x1SfQd+olVZK5Yrn6FtbUN JEhIWS03k1LGKpZ8gI/hgTXyMvyfBKJbg3kFCYqdAAMaQ8pQDe3PxOdtztSo5H0giL3IuFpKhj5 +EL5qnxutchW8fFGTbhgvbEWWowZJWKPWE2IITtOyH+mopsza0+xecr9N82q6A6z8azHT9fjiuw VnyYuRdr0dnmsYtwaWVKnyztEP1Azo3McbYuYYvSEEE0hCNb X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Extend the driver to send SPD and HDMI Vendor Specific InfoFrames. While the HDMI block has special block to send HVS InfoFrame, use GENERIC0 block instead. VENSPEC_INFO registers pack frame data in a way that requires manual repacking in the driver, while GENERIC0 doesn't have such format requirements. The msm-4.4 kernel uses GENERIC0 to send HDR InfoFrame which we do not at this point anyway. Acked-by: Maxime Ripard Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 93 ++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c index d2b25bcd8eb8f5cf4623e11c87ac5eea6e4b363d..c31e1d33593de6480c0c2b7cb322a85e645ff332 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -69,6 +69,8 @@ static void power_off(struct drm_bridge *bridge) } #define AVI_IFRAME_LINE_NUMBER 1 +#define SPD_IFRAME_LINE_NUMBER 1 +#define VENSPEC_IFRAME_LINE_NUMBER 3 static int msm_hdmi_config_avi_infoframe(struct hdmi *hdmi, const u8 *buffer, size_t len) @@ -142,6 +144,74 @@ static int msm_hdmi_config_audio_infoframe(struct hdmi *hdmi, return 0; } +static int msm_hdmi_config_spd_infoframe(struct hdmi *hdmi, + const u8 *buffer, size_t len) +{ + u32 buf[7] = {}; + u32 val; + int i; + + if (len != HDMI_INFOFRAME_SIZE(SPD) || len - 3 > sizeof(buf)) { + DRM_DEV_ERROR(&hdmi->pdev->dev, + "failed to configure SPD infoframe\n"); + return -EINVAL; + } + + /* checksum gets written together with the body of the frame */ + hdmi_write(hdmi, REG_HDMI_GENERIC1_HDR, + buffer[0] | + buffer[1] << 8 | + buffer[2] << 16); + + memcpy(buf, &buffer[3], len - 3); + + for (i = 0; i < ARRAY_SIZE(buf); i++) + hdmi_write(hdmi, REG_HDMI_GENERIC1(i), buf[i]); + + val = hdmi_read(hdmi, REG_HDMI_GEN_PKT_CTRL); + val |= HDMI_GEN_PKT_CTRL_GENERIC1_SEND | + HDMI_GEN_PKT_CTRL_GENERIC1_CONT | + HDMI_GEN_PKT_CTRL_GENERIC1_LINE(SPD_IFRAME_LINE_NUMBER); + hdmi_write(hdmi, REG_HDMI_GEN_PKT_CTRL, val); + + return 0; +} + +static int msm_hdmi_config_hdmi_infoframe(struct hdmi *hdmi, + const u8 *buffer, size_t len) +{ + u32 buf[7] = {}; + u32 val; + int i; + + if (len < HDMI_INFOFRAME_HEADER_SIZE + HDMI_VENDOR_INFOFRAME_SIZE || + len - 3 > sizeof(buf)) { + DRM_DEV_ERROR(&hdmi->pdev->dev, + "failed to configure HDMI infoframe\n"); + return -EINVAL; + } + + /* checksum gets written together with the body of the frame */ + hdmi_write(hdmi, REG_HDMI_GENERIC0_HDR, + buffer[0] | + buffer[1] << 8 | + buffer[2] << 16); + + memcpy(buf, &buffer[3], len - 3); + + for (i = 0; i < ARRAY_SIZE(buf); i++) + hdmi_write(hdmi, REG_HDMI_GENERIC0(i), buf[i]); + + val = hdmi_read(hdmi, REG_HDMI_GEN_PKT_CTRL); + val |= HDMI_GEN_PKT_CTRL_GENERIC0_SEND | + HDMI_GEN_PKT_CTRL_GENERIC0_CONT | + HDMI_GEN_PKT_CTRL_GENERIC0_UPDATE | + HDMI_GEN_PKT_CTRL_GENERIC0_LINE(VENSPEC_IFRAME_LINE_NUMBER); + hdmi_write(hdmi, REG_HDMI_GEN_PKT_CTRL, val); + + return 0; +} + static int msm_hdmi_bridge_clear_infoframe(struct drm_bridge *bridge, enum hdmi_infoframe_type type) { @@ -176,6 +246,25 @@ static int msm_hdmi_bridge_clear_infoframe(struct drm_bridge *bridge, break; + case HDMI_INFOFRAME_TYPE_SPD: + val = hdmi_read(hdmi, REG_HDMI_GEN_PKT_CTRL); + val &= ~(HDMI_GEN_PKT_CTRL_GENERIC1_SEND | + HDMI_GEN_PKT_CTRL_GENERIC1_CONT | + HDMI_GEN_PKT_CTRL_GENERIC1_LINE__MASK); + hdmi_write(hdmi, REG_HDMI_GEN_PKT_CTRL, val); + + break; + + case HDMI_INFOFRAME_TYPE_VENDOR: + val = hdmi_read(hdmi, REG_HDMI_GEN_PKT_CTRL); + val &= ~(HDMI_GEN_PKT_CTRL_GENERIC0_SEND | + HDMI_GEN_PKT_CTRL_GENERIC0_CONT | + HDMI_GEN_PKT_CTRL_GENERIC0_UPDATE | + HDMI_GEN_PKT_CTRL_GENERIC0_LINE__MASK); + hdmi_write(hdmi, REG_HDMI_GEN_PKT_CTRL, val); + + break; + default: drm_dbg_driver(hdmi_bridge->base.dev, "Unsupported infoframe type %x\n", type); } @@ -197,6 +286,10 @@ static int msm_hdmi_bridge_write_infoframe(struct drm_bridge *bridge, return msm_hdmi_config_avi_infoframe(hdmi, buffer, len); case HDMI_INFOFRAME_TYPE_AUDIO: return msm_hdmi_config_audio_infoframe(hdmi, buffer, len); + case HDMI_INFOFRAME_TYPE_SPD: + return msm_hdmi_config_spd_infoframe(hdmi, buffer, len); + case HDMI_INFOFRAME_TYPE_VENDOR: + return msm_hdmi_config_hdmi_infoframe(hdmi, buffer, len); default: drm_dbg_driver(hdmi_bridge->base.dev, "Unsupported infoframe type %x\n", type); return 0; From patchwork Fri Jan 24 21:47:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 859654 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4FF41F37DB for ; Fri, 24 Jan 2025 21:48:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755283; cv=none; b=kJIywhiMmtyQGU/1iF2jvHPwfQGxthDRIGFdoRuNsNsGf1SbQE6TFqpSH4p7wHs1Tw1K4yI8y637zDJa6Z6dV+wyiyyLtLOZcjdd+RGjLuOLU94vkwyGjtK/NYzVVX1XPgxcjbJNnw3si0ZPz/iYY2clZ6f8jy2CMrtlsU4Ed9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737755283; c=relaxed/simple; bh=6A5aCLP00sWata8KRfqPQ5CnVO9JUTbJd1uu3Qp6jAs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a4p87oPEM96tww49yCa9NbJfjfrHMc5mxH7SAbGeZgZL0bXLII5/VAAWL2t2bVVLPVXx8yXIouAawkXy4GKrpovB86tzC1DtLBTtf2HHA+t/8M5cktyQVYCGvC1MJhUyivzuupJX31MGDfsf87ih/TKvjDBuaIK+w0m+BAH/Cls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=E5NC60qj; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="E5NC60qj" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-54020b0dcd2so4238867e87.1 for ; Fri, 24 Jan 2025 13:48:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737755280; x=1738360080; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=jaIXZ620c8SPNqR/EOcjeZxHQVhRhL3PSxW+/q8xH8Y=; b=E5NC60qjHhmV6DiD+R0lu6LSVoHCHE3WSU+v/MC4V2C5iqiV9yG82iRodgzEwdaKif SCOAoQfjenBiO0w/zhShRSHs5EyhtTrKwwOm3cmwd1ZC5gAsxifnlkRghezjPH3xhfp+ I2KzOWLmqApRfJmKVcaOFR4NKjDCHn+5n6AmCjq1lCeen9V3XuWL2n34nQonLhKvF7gE pBB/h3yA/PYFtdQwbQNUA8KAwxOuCZzWRNTqsSTKcwdEYZdz3bct2xcGPkEi+t6t7nuC 8j67Zbq9FYZTn3fJWpWvsoL0TTZFNCjatLWMWmIuoI/OHBctpBkTsiujhB85amxfbHCs 30KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737755280; x=1738360080; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jaIXZ620c8SPNqR/EOcjeZxHQVhRhL3PSxW+/q8xH8Y=; b=uo9x9QZeVqdMULv9i77/dswlIC17riFkpvuCk3qHVGKpUO8WiQ+snaAUUPNnw5g56H JxyhP5AIVN6q9zvXGFnEYGpmBlnNuREfMQfClPy8bV2E6QrxtR7xGHBq4gWtJRg7JaHg IATdoeDG9TauEb3qsUdzwjfKkzoqYQ33t8RvGCrGciu3uDxe/vfZKUxdqNEUi+TzZn0x IDjwS7efMqzPyX/ivDyZM/OgDw9RLCMGOqhBqgI7Z4sAZL5pyYj3FkkYxVE1fG+xv+AY Twn8VVXwdKV6JtjUxo0UtU3nHSoxIQL6v+k9QPImTAPvbKec0L57jf0OmOr1EhcNOCNt +a7Q== X-Forwarded-Encrypted: i=1; AJvYcCUS7S1Q7p/4fm6pxEHEszDuOraoxu5ZxsKxONFRtIcc7lhi/DEKIh5Q3IbudkATTZIfJE/jGn0EtSEXU8yk@vger.kernel.org X-Gm-Message-State: AOJu0YxgWLMjZo9zkP/u8ENhprtTPBiY6nPrPOd9QZaYDK6OU63sHg6Q 16dk01ihbHg0tVvOZ5B8oym+3vNoJxuPMHBK9xZ+cRGxvzumSwrHFg/BO+rMpdM= X-Gm-Gg: ASbGncu4KTmlajTrtkM/UDKPs4ZEVw8HxL9/0y8cqFRS2ywZCFNqZRmtcmyfa1pJjH2 iGZ/kBisUsJ0YTlMGob0njf+IN4y1UhDeQz9IYoro9zkKByXK5aUfoYhnVTY7Niv9g8yV7CqTOU NsrzasDrQjs6m4L97i9zASlIGE+f8+u8G7Z/9AMDqsL0DxfDc9Z98gIqm6xNbxgBFn0w+Sz26u8 4D6tStWcPL7Eka9iuNFR/D5XKIU/iBjUAhL9FVCnw31Xn/xhke3KNO/Y5pf88LG2RQzC8mmSSyl dCxOd6Th38ai X-Google-Smtp-Source: AGHT+IEmwBFQTTopeGcaCwwyWTXN2DhizvSViHjXm/kfxIMxd8HWEBRaoukAypMxXebY6h/olO6r+g== X-Received: by 2002:a05:6512:3d0b:b0:542:21f8:d6bd with SMTP id 2adb3069b0e04-543c7dab41fmr1968649e87.22.1737755279688; Fri, 24 Jan 2025 13:47:59 -0800 (PST) Received: from umbar.lan ([192.130.178.90]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-543c8237491sm425014e87.104.2025.01.24.13.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 13:47:58 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 24 Jan 2025 23:47:47 +0200 Subject: [PATCH v6 7/7] drm/msm/hdmi: use DRM HDMI Audio framework Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250124-bridge-hdmi-connector-v6-7-1592632327f7@linaro.org> References: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> In-Reply-To: <20250124-bridge-hdmi-connector-v6-0-1592632327f7@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , Simona Vetter , Simona Vetter Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=9947; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=6A5aCLP00sWata8KRfqPQ5CnVO9JUTbJd1uu3Qp6jAs=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBnlAqAxeZ6YSaN8+dfdt7IoI//rQ2ZAxV9zfeRs UpqIcCteOyJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZ5QKgAAKCRCLPIo+Aiko 1QwVB/9dMKxRddY8I5MDYek73fiBn9x3ZEFQd0JfxtaRF/VgkVHFrFKbjIrBV+z1Rg2KAwJNxy4 7QYFARie061bIx6cVjcWiIamSx3+K8lUJxIz4ceJO8tmTEx2Lj+HtskYjna5a3REaCPH7xAhKiY t3thqpF2kD1adjT8v1Cxl5Tn6ld9iX0f7P5Wk2WitB+G6z56ydKEGGddvPcyNMLK+/mKEppRwQ7 otiWSqZYHnN8FUB1ojTJ0Knm71zxHNShGEmpawiJX5sOuz8SBN56hYcDE2lA6l48Ly23yP3Qemv RuQ062QkO9/3LHRtlXxXyCjt4gvBBtbLOAVO/dPK2ozlU2oC X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A In order to simplify the driver even further and to remove the boilerplate code, rewrite the audio interface to use the DRM HDMI Audio framework. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi.c | 91 ---------------------------------- drivers/gpu/drm/msm/hdmi/hdmi.h | 20 ++++---- drivers/gpu/drm/msm/hdmi/hdmi_audio.c | 75 +++++++++++++++++++++++----- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 5 ++ 4 files changed, 76 insertions(+), 115 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index 6b77e0fb8d5ec218dfbf58215e2e12ad1dfb1b85..248541ff449204c72cd444458dadb9ae4a0a53d1 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -14,7 +14,6 @@ #include #include -#include #include "hdmi.h" void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on) @@ -245,87 +244,6 @@ static const struct hdmi_platform_config hdmi_tx_8974_config = { .hpd_freq = hpd_clk_freq_8x74, }; -/* - * HDMI audio codec callbacks - */ -static int msm_hdmi_audio_hw_params(struct device *dev, void *data, - struct hdmi_codec_daifmt *daifmt, - struct hdmi_codec_params *params) -{ - struct hdmi *hdmi = dev_get_drvdata(dev); - unsigned int rate; - int ret; - - DRM_DEV_DEBUG(dev, "%u Hz, %d bit, %d channels\n", params->sample_rate, - params->sample_width, params->cea.channels); - - switch (params->sample_rate) { - case 32000: - rate = HDMI_SAMPLE_RATE_32KHZ; - break; - case 44100: - rate = HDMI_SAMPLE_RATE_44_1KHZ; - break; - case 48000: - rate = HDMI_SAMPLE_RATE_48KHZ; - break; - case 88200: - rate = HDMI_SAMPLE_RATE_88_2KHZ; - break; - case 96000: - rate = HDMI_SAMPLE_RATE_96KHZ; - break; - case 176400: - rate = HDMI_SAMPLE_RATE_176_4KHZ; - break; - case 192000: - rate = HDMI_SAMPLE_RATE_192KHZ; - break; - default: - DRM_DEV_ERROR(dev, "rate[%d] not supported!\n", - params->sample_rate); - return -EINVAL; - } - - ret = drm_atomic_helper_connector_hdmi_update_audio_infoframe(hdmi->connector, - ¶ms->cea); - if (ret) - return ret; - - msm_hdmi_audio_info_setup(hdmi, rate, params->cea.channels); - - return 0; -} - -static void msm_hdmi_audio_shutdown(struct device *dev, void *data) -{ - struct hdmi *hdmi = dev_get_drvdata(dev); - - drm_atomic_helper_connector_hdmi_clear_audio_infoframe(hdmi->connector); - msm_hdmi_audio_disable(hdmi); -} - -static const struct hdmi_codec_ops msm_hdmi_audio_codec_ops = { - .hw_params = msm_hdmi_audio_hw_params, - .audio_shutdown = msm_hdmi_audio_shutdown, -}; - -static struct hdmi_codec_pdata codec_data = { - .ops = &msm_hdmi_audio_codec_ops, - .max_i2s_channels = 8, - .i2s = 1, -}; - -static int msm_hdmi_register_audio_driver(struct hdmi *hdmi, struct device *dev) -{ - hdmi->audio_pdev = platform_device_register_data(dev, - HDMI_CODEC_DRV_NAME, - PLATFORM_DEVID_AUTO, - &codec_data, - sizeof(codec_data)); - return PTR_ERR_OR_ZERO(hdmi->audio_pdev); -} - static int msm_hdmi_bind(struct device *dev, struct device *master, void *data) { struct msm_drm_private *priv = dev_get_drvdata(master); @@ -337,12 +255,6 @@ static int msm_hdmi_bind(struct device *dev, struct device *master, void *data) return err; priv->hdmi = hdmi; - err = msm_hdmi_register_audio_driver(hdmi, dev); - if (err) { - DRM_ERROR("Failed to attach an audio codec %d\n", err); - hdmi->audio_pdev = NULL; - } - return 0; } @@ -352,9 +264,6 @@ static void msm_hdmi_unbind(struct device *dev, struct device *master, struct msm_drm_private *priv = dev_get_drvdata(master); if (priv->hdmi) { - if (priv->hdmi->audio_pdev) - platform_device_unregister(priv->hdmi->audio_pdev); - if (priv->hdmi->bridge) msm_hdmi_hpd_disable(priv->hdmi); diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.h b/drivers/gpu/drm/msm/hdmi/hdmi.h index ab169b77377097dc22c0c718f65024cb8ad1d317..88a41be7c6fc2f878a1c372a0c75b3277f24f893 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.h +++ b/drivers/gpu/drm/msm/hdmi/hdmi.h @@ -33,7 +33,6 @@ struct hdmi_hdcp_ctrl; struct hdmi { struct drm_device *dev; struct platform_device *pdev; - struct platform_device *audio_pdev; const struct hdmi_platform_config *config; @@ -205,16 +204,15 @@ static inline int msm_hdmi_pll_8998_init(struct platform_device *pdev) /* * audio: */ -#define HDMI_SAMPLE_RATE_32KHZ 0 -#define HDMI_SAMPLE_RATE_44_1KHZ 1 -#define HDMI_SAMPLE_RATE_48KHZ 2 -#define HDMI_SAMPLE_RATE_88_2KHZ 3 -#define HDMI_SAMPLE_RATE_96KHZ 4 -#define HDMI_SAMPLE_RATE_176_4KHZ 5 -#define HDMI_SAMPLE_RATE_192KHZ 6 - -int msm_hdmi_audio_info_setup(struct hdmi *hdmi, int rate, int channels); -int msm_hdmi_audio_disable(struct hdmi *hdmi); +struct hdmi_codec_daifmt; +struct hdmi_codec_params; + +int msm_hdmi_bridge_audio_prepare(struct drm_connector *connector, + struct drm_bridge *bridge, + struct hdmi_codec_daifmt *daifmt, + struct hdmi_codec_params *params); +void msm_hdmi_bridge_audio_shutdown(struct drm_connector *connector, + struct drm_bridge *bridge); /* * hdmi bridge: diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_audio.c b/drivers/gpu/drm/msm/hdmi/hdmi_audio.c index 924654bfb48cf17feadea1c0661ee6ee4e1b4589..9c5b5310bfeb54902d7d0687909afc79e320f560 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_audio.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_audio.c @@ -4,7 +4,12 @@ * Author: Rob Clark */ +#include + #include + +#include + #include "hdmi.h" /* Supported HDMI Audio sample rates */ @@ -68,7 +73,8 @@ static const struct hdmi_msm_audio_arcs *get_arcs(unsigned long int pixclock) return NULL; } -static int msm_hdmi_audio_update(struct hdmi *hdmi) +static int msm_hdmi_audio_update(struct hdmi *hdmi, + struct drm_connector *connector) { struct hdmi_audio *audio = &hdmi->audio; const struct hdmi_msm_audio_arcs *arcs = NULL; @@ -76,7 +82,7 @@ static int msm_hdmi_audio_update(struct hdmi *hdmi) uint32_t acr_pkt_ctrl, vbi_pkt_ctrl, aud_pkt_ctrl; uint32_t audio_config; - if (!hdmi->connector->display_info.is_hdmi) + if (!connector->display_info.is_hdmi) return -EINVAL; DBG("audio: enabled=%d, channels=%d, rate=%d", @@ -192,29 +198,72 @@ static int msm_hdmi_audio_update(struct hdmi *hdmi) return 0; } -int msm_hdmi_audio_info_setup(struct hdmi *hdmi, int rate, int channels) +int msm_hdmi_bridge_audio_prepare(struct drm_connector *connector, + struct drm_bridge *bridge, + struct hdmi_codec_daifmt *daifmt, + struct hdmi_codec_params *params) { - if (!hdmi) - return -ENXIO; - - if ((rate < 0) || (rate >= MSM_HDMI_SAMPLE_RATE_MAX)) + struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); + struct hdmi *hdmi = hdmi_bridge->hdmi; + unsigned int rate; + int ret; + + drm_dbg_driver(bridge->dev, "%u Hz, %d bit, %d channels\n", + params->sample_rate, + params->sample_width, + params->cea.channels); + + switch (params->sample_rate) { + case 32000: + rate = MSM_HDMI_SAMPLE_RATE_32KHZ; + break; + case 44100: + rate = MSM_HDMI_SAMPLE_RATE_44_1KHZ; + break; + case 48000: + rate = MSM_HDMI_SAMPLE_RATE_48KHZ; + break; + case 88200: + rate = MSM_HDMI_SAMPLE_RATE_88_2KHZ; + break; + case 96000: + rate = MSM_HDMI_SAMPLE_RATE_96KHZ; + break; + case 176400: + rate = MSM_HDMI_SAMPLE_RATE_176_4KHZ; + break; + case 192000: + rate = MSM_HDMI_SAMPLE_RATE_192KHZ; + break; + default: + drm_err(bridge->dev, "rate[%d] not supported!\n", + params->sample_rate); return -EINVAL; + } + + ret = drm_atomic_helper_connector_hdmi_update_audio_infoframe(connector, + ¶ms->cea); + if (ret) + return ret; hdmi->audio.rate = rate; - hdmi->audio.channels = channels; + hdmi->audio.channels = params->cea.channels; hdmi->audio.enabled = true; - return msm_hdmi_audio_update(hdmi); + return msm_hdmi_audio_update(hdmi, connector); } -int msm_hdmi_audio_disable(struct hdmi *hdmi) +void msm_hdmi_bridge_audio_shutdown(struct drm_connector *connector, + struct drm_bridge *bridge) { - if (!hdmi) - return -ENXIO; + struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); + struct hdmi *hdmi = hdmi_bridge->hdmi; + + drm_atomic_helper_connector_hdmi_clear_audio_infoframe(connector); hdmi->audio.rate = 0; hdmi->audio.channels = 2; hdmi->audio.enabled = false; - return msm_hdmi_audio_update(hdmi); + msm_hdmi_audio_update(hdmi, connector); } diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c index c31e1d33593de6480c0c2b7cb322a85e645ff332..8a1bbcf578b0749480799d9e5b2baf3778322edc 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -470,6 +470,8 @@ static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = { .hdmi_tmds_char_rate_valid = msm_hdmi_bridge_tmds_char_rate_valid, .hdmi_clear_infoframe = msm_hdmi_bridge_clear_infoframe, .hdmi_write_infoframe = msm_hdmi_bridge_write_infoframe, + .hdmi_audio_prepare = msm_hdmi_bridge_audio_prepare, + .hdmi_audio_shutdown = msm_hdmi_bridge_audio_shutdown, }; static void @@ -507,6 +509,9 @@ int msm_hdmi_bridge_init(struct hdmi *hdmi) DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_HDMI | DRM_BRIDGE_OP_EDID; + bridge->hdmi_audio_max_i2s_playback_channels = 8; + bridge->hdmi_audio_dev = &hdmi->pdev->dev; + bridge->hdmi_audio_dai_port = -1; ret = devm_drm_bridge_add(hdmi->dev->dev, bridge); if (ret)