From patchwork Fri May 31 20:07:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800958 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 95FA417D341 for ; Fri, 31 May 2024 20:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186054; cv=none; b=EE+839mIB6s/4QOFHp9Sg4M84tRNPuY8nkoLwabodUx1baISFaueNi9fwJ2i5GEiEyAuEIeKzl21fvRVCkNqmjo6pDzraC0eCP01r7UVxGhI4mO7Ubbac53ykb3iSqDzDUEJW0AjAN9bOtuVlIQJXrvvYOG+nntY6cjvQGcYgto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186054; c=relaxed/simple; bh=AXQkgT8bLCi+J4VLmDhYURPEkLAsLkNbwsYyTx65pa0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qNg5SRAU75yP8QfbVNyK+i53d+A+gzgEhm0uI+70Eq/DIEMwzOjHVyYeXdPa68U7rrtWZhNGuqXHhl8VQueD1qw+Dvt4iM6ZOCZitwxecWog7fHpkUa0V7QlEVmY7NWUbVVot7WP3dTFRdpU6ZMRnARjWdIiNCSkVl8DNFdUQxw= 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=hJg4jqYM; arc=none smtp.client-ip=209.85.208.169 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="hJg4jqYM" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e96f29884dso27960201fa.0 for ; Fri, 31 May 2024 13:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186051; x=1717790851; 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=xsWyvZJ7smsYEwcJt3QXuB4RboSifhUzN4Y/+3fVgYs=; b=hJg4jqYMRB6/OPS0xylEDzORAYAiZe/o9aK4L2Oei4zja0XlbQtcDYCmic0ha+X4Wz c5AxPPoeAHlS98yU253OKF9uCWFCdu1FaWPK9EajjnsBENTVpiyIwsrh1zvAsNhIGaZt hefq/wk96DeCDV0RPs+dYSr1fu/+iw5g7k5f6wQUL6BWeIP9kKQ8OL1QDf1i7Rn+frvR /waFBOdpMNfXSMKvgypd02uOxdhe/JbTt6oYl9peKYA2Jhi2Rti4LW7tb0yf+AnPcuLB uhnK9CGtylUGGVKnSRr27p6DmnFnXx0995nvVztC0Anz3dCbECzHzpy8VES788sps/03 6isw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186051; x=1717790851; 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=xsWyvZJ7smsYEwcJt3QXuB4RboSifhUzN4Y/+3fVgYs=; b=vYNHuctswhBAOr/EB/B9S2sEeH5UTYfJAhk74doMkX4qWAhLuXOfZOe87DempxhQCb eQhdbmYt61k6AoX8s5qVma9ocftgLe/Kl3EHKtQOhz2eILy9J7O6Q+1ncA1M/M8KX2Ks K36Nj8BIZJJo9t2JOe448lCN3Qe5iwdf7YMyF7Fe6VWDU7FYj4QKSzwtJVUiYFeU9rg1 5DQCct4MRTBTUVaGaax749af8L8aRqGu+06IKQBUjAxbBr6ZPMkzjn7avBOTYM6vj0LB NuRaKq9WaWj5Vsf+Z502Q/C3OqOy2X3sPaTVCSinxU5TRAem9R+d+gJ80bIzUooZhGOz 8ndg== X-Forwarded-Encrypted: i=1; AJvYcCW+oZfH1x13etTjAAgpnS6LIXZ5q9reuTpy9rjyO+vtSraChotiK5cDFwK/88pgM8j6y37Mg1WaYTI6K46GBaBe/EnMYZ5rst18AdpXbQ== X-Gm-Message-State: AOJu0YysfT7oRJ/ISSr/T5H7L511myVnOvZXi7UCqbxkrkf2juLMWNV6 nAfkk4Hbx9G3qf9gMd1Dru1UPki0E+u9kCYm+5DG1MB/p+WXXvfN48XoRurxCoM= X-Google-Smtp-Source: AGHT+IG1DN5+DBzFiRuDTYEQSvzREpoKSfY1gAB8eFQNpo82N+Nkll6VfEl6SAftfhSSjQ8BLG2yWw== X-Received: by 2002:a05:651c:1a28:b0:2e1:cb22:a4d with SMTP id 38308e7fff4ca-2ea951e0c9cmr24442131fa.36.1717186050858; Fri, 31 May 2024 13:07:30 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:30 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:24 +0300 Subject: [PATCH v4 1/9] drm/connector: hdmi: accept NULL for Audio Infoframe Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240531-bridge-hdmi-connector-v4-1-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1693; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=AXQkgT8bLCi+J4VLmDhYURPEkLAsLkNbwsYyTx65pa0=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmWi4A4mslqnmrqRRzX6aSZEDOT1WCm1EzeG9wr U/QUtoki1qJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlouAAAKCRCLPIo+Aiko 1SUjB/0e2GTfiChGvovX7efLQ0j2ffZdGrlSDSwGrLLZc+B6/ZbDne/yndL1jZu8s9RmnWztqwB gyZSl06x0cl55ESAcn+6WVktsGPpk8dZKMqFe1OQT25lqL3uyPrIhuigQ64W/EX8+9+KLn2wn08 9hTe/0RG1CmTUWbzzYL0AiCvqkaU19lt1SvNH3x3XULdutaam97jjHCbJhbwpvIDL/TSCltQ4tY mPl51o4WSuBlaVIcumVOiCYt/lpmn1dywPMY31gJl6e+eTGqZFOa9TfDdA86+YHdhQo+CuadVd2 JaOYarn+U4myQ9cBkESIesfM8s8SMqUBofMb2JCj2rwpgoou X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Allow passing NULL as audio infoframe as a way to disable Audio Infoframe generation. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/display/drm_hdmi_state_helper.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index ce96837eea65..5356723d21f5 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -681,7 +681,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_hdmi_update_infoframes); /** * drm_atomic_helper_connector_hdmi_update_audio_infoframe - Update the Audio Infoframe * @connector: A pointer to the HDMI connector - * @frame: A pointer to the audio infoframe to write + * @frame: A pointer to the audio infoframe to write or NULL to disable sending the frame * * This function is meant for HDMI connector drivers to update their * audio infoframe. It will typically be used in one of the ALSA hooks @@ -704,10 +704,16 @@ drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *co mutex_lock(&connector->hdmi.infoframes.lock); - memcpy(&infoframe->data, frame, sizeof(infoframe->data)); - infoframe->set = true; + if (frame) { + memcpy(&infoframe->data, frame, sizeof(infoframe->data)); + infoframe->set = true; + + ret = write_infoframe(connector, infoframe); + } else { + infoframe->set = false; - ret = write_infoframe(connector, infoframe); + ret = clear_infoframe(connector, infoframe); + } mutex_unlock(&connector->hdmi.infoframes.lock); From patchwork Fri May 31 20:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800582 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 A8C6A17D354 for ; Fri, 31 May 2024 20:07:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186056; cv=none; b=uzdh4xYARfxjJJkW94dse3ucAACyW3ahq0xQANl1e8apwpE2XHo1LZWZczQSdjWpobXgqVifW/5j1ZEaYMjWDnVK6tNLmlx1SYZKIT/i4f1s7SMlgfp1gr42aY6EG+4fA8tu1gtQmC+fMM1oygKJ/YCzcr3k3h81GiaVKH5UF4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186056; c=relaxed/simple; bh=Qg+Km5t2/ArhCtvDRW1AVt6NXCcPflkwptIdi/Y9plc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ThHGZRISARzW2mtftt012zT+mIY4ZpGFxnadr2x359Er9rdszKPYTWgeMpDHK6ZzJecFYZDr65q1tD+UNWUDGGrLWf1DUdKK0/D6D5rZ2ImWwX7JBbjtYADeF8tyM+jihURYZTvlM1kyQx5K15GqqhNsb80pLHvoArchsb8gmc4= 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=IYpYHfzt; arc=none smtp.client-ip=209.85.208.182 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="IYpYHfzt" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2e6f51f9de4so34626431fa.3 for ; Fri, 31 May 2024 13:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186052; x=1717790852; 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=cHgcqHgkcrLMv81hwxP8kq1FxOWEk1MfcSrxFYUTu+0=; b=IYpYHfztJLHUOrXXXgJLjY0iRDMMrf0qZVbdSQStMWrmvE9Ng2/dRS5RoDfomg1W/f m7wnJrgDnGV/lZm+rszJNyqF1MnRIqw0bWrCmKS3F6YwjEt4l1Wqpv5FwPkwMl/jKE/8 PVfn4x51Mc5yOAMHnl5pS+KmZ9RjsVOOd6Osl70JZeb31ApFpSd7IuCyQf1h5TDFtX8q d6Uy0hBDybOLRW2//1Z/lu0wXp+sBEDvFdJPw/0rLRYkD2yBLj+znOo2yXc1VWxkvURV Ll767bmYhfjdMXctiIsJSCNdVMEwjnC2iC/y92tdMZ8SqQpIKxsBvx0kU9bSXQHlA3g1 uyOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186052; x=1717790852; 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=cHgcqHgkcrLMv81hwxP8kq1FxOWEk1MfcSrxFYUTu+0=; b=WAzTdSAqzX7h7yVDGOx64skSS3jI0oubUmBILVpTs93zx0oiKkE62yB3Th95Sf5uw0 17EiUl4ak5WSKQMLpxCfWOS8xeEgbGhx3FT+mK7DJPieWeL2kqx95I8uRGwOIuuQWzic t+eer3HCQNq19b/k/tdWJ+GBQkCV9cLe5LHpVWlgOgT/Y5NE+jPHBGqn8IPtfe6e+dHQ 3nGp6So3oDsNlfqRXzySsGE4gTuEwo1/3RSYQRci9w+HHMLecaxsqOZlfXcFnYAX8BBz mANUGG8dhJCBpgi7Ggb1gOJ7ent7tkpXN8oyC3CKs1giV1cvYywJ3Qpouurm0dDOzORk ITFg== X-Forwarded-Encrypted: i=1; AJvYcCWMSWqC905FGYgULdkl798DgXJ+BFILpRrGsUHsvNtKGCJxgIZY/IlWCavqRttOEMaNENEoba0hj9bLV8ZCb7hkQ9oJXUlt+TzaFo4zDA== X-Gm-Message-State: AOJu0YyIFBVy+e+mLv/wBi/Eq02n8GCoAEmf2YBTQEx48yKZ6kTRs7pE PMz7GfftSiY8hKwih/JOvJYCK90/YEzBuMBbmgkXUJG0akftM5J0VA63jOi8dOI= X-Google-Smtp-Source: AGHT+IGNtOTguaZ9leRqag0CaFzD23hl8t7r4pTG52EkCyMJnsoMnRLC07C3OfPKTkhSCTVQomW3ww== X-Received: by 2002:a2e:2d02:0:b0:2ea:830f:9a89 with SMTP id 38308e7fff4ca-2ea951de46cmr22755071fa.38.1717186051788; Fri, 31 May 2024 13:07:31 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:31 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:25 +0300 Subject: [PATCH v4 2/9] drm/bridge-connector: switch to using drmm allocations Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240531-bridge-hdmi-connector-v4-2-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2786; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=Qg+Km5t2/ArhCtvDRW1AVt6NXCcPflkwptIdi/Y9plc=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmWi4A+k/wFAlNad1mkNnD2hKb7PCQmsOnilAgQ ae2aBefN4SJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlouAAAKCRCLPIo+Aiko 1chPB/wOEOQQ16ukqgtPL72Fsk3cDKv9fUVqks4W09fqE/QlJIzv89myxSDCF961MXZQC7CKJxq gUi/e45v3m3rINjmtqDmQn0CKzsxnr6By6QKcT4YeqWzViOo7OVFUeH/9nHeetRsIo1d7mYJTcr szPFZpoDu5Nuu6YJE7ayUq7LK7anRBizmgkApSUxScpHluXZp4Gf11iXxLmZDc1pHLF6unzOSH8 U8QpuYzZtbrBCS6vXMQnmQrFA5h6OaZcunljIXaBCUPYaDtc0egkwKMfsYUZCw2JWGs9RZm+GMC 6Wcifh0/wjJtyBpu4viwKVRZRNQ4OGPgt1KN1DxXlAOrm7z8 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Turn drm_bridge_connector to using drmm_kzalloc() and drmm_connector_init() and drop the custom destroy function. The drm_connector_unregister() and fwnode_handle_put() are already handled by the drm_connector_cleanup() and so are safe to be dropped. Acked-by: Maxime Ripard Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_bridge_connector.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index 982552c9f92c..e093fc8928dc 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -193,19 +194,6 @@ drm_bridge_connector_detect(struct drm_connector *connector, bool force) return status; } -static void drm_bridge_connector_destroy(struct drm_connector *connector) -{ - struct drm_bridge_connector *bridge_connector = - to_drm_bridge_connector(connector); - - drm_connector_unregister(connector); - drm_connector_cleanup(connector); - - fwnode_handle_put(connector->fwnode); - - kfree(bridge_connector); -} - static void drm_bridge_connector_debugfs_init(struct drm_connector *connector, struct dentry *root) { @@ -224,7 +212,6 @@ static const struct drm_connector_funcs drm_bridge_connector_funcs = { .reset = drm_atomic_helper_connector_reset, .detect = drm_bridge_connector_detect, .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = drm_bridge_connector_destroy, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, .debugfs_init = drm_bridge_connector_debugfs_init, @@ -328,7 +315,7 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, int connector_type; int ret; - bridge_connector = kzalloc(sizeof(*bridge_connector), GFP_KERNEL); + bridge_connector = drmm_kzalloc(drm, sizeof(*bridge_connector), GFP_KERNEL); if (!bridge_connector) return ERR_PTR(-ENOMEM); @@ -383,9 +370,9 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, return ERR_PTR(-EINVAL); } - ret = drm_connector_init_with_ddc(drm, connector, - &drm_bridge_connector_funcs, - connector_type, ddc); + ret = drmm_connector_init(drm, connector, + &drm_bridge_connector_funcs, + connector_type, ddc); if (ret) { kfree(bridge_connector); return ERR_PTR(ret); From patchwork Fri May 31 20:07:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800957 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 7780F1946F for ; Fri, 31 May 2024 20:07:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186056; cv=none; b=dLT+sC0D2b+hEzyo13HtNMX+nL+L7lAP8YwwKNIrSF0V+GZ2gAhacLSFKRGKN3KlIdS4k6IpOPN4x1hVJ3GP6s0IPaGUA6SsfwVTNwtS8bsnS+/D5gKQ4h0e2Eqvin/74UehYLzhPbbLaXLi7pFigQ7BPsLCYEZtmGPeXpUVAH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186056; c=relaxed/simple; bh=cqCdor0KJlbsJ87CXjTFhRdAs763FYhaLzSStx5DE/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=THjj3715x2r+swyHPwGASepM42bri33HsXY4jTICLNvoixg1oSpQhDy2fnNh6Wz+vBmfwOEmb9dnj0/DGSrTdq5kQ4mfau01fAtku09kA4aGMKYM8ZT++9Buhrfb/RdOnUwaOo+a/w5U1kVRBzFOquO1xlPe6cVMKrIZYsrkdms= 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=YSv3bPOG; arc=none smtp.client-ip=209.85.208.169 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="YSv3bPOG" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e974857588so26836311fa.3 for ; Fri, 31 May 2024 13:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186053; x=1717790853; 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=foy6JQDzCRlndu2wDkMW+/KfxEQHtUuSgLRAcEoN4C0=; b=YSv3bPOGEBUQOELydeNnI8BZo2ExIhu0Tcqmq5rlo+f6q57X5wUEFQj3vQ5SX+/qtl zFVD1udNnNcf7Sg+mvscuMdJkPyhW+TRpDWj/mE6NBHzLEDX6lNDs5zA9lvi0rj2D1po Sqf94c2HwBoiWpxp1O/JQ0uTwZhO2LFBvLQgcP1nIyOfvPybOZuZNpbxlGRIG9siUgi9 54kjtqgVFSOvfrORUhwswoARv7gYHIE/6xI/ByEYr0Sc4QtayNO35+2291s/5MRRRSzh YTXwkon1qu9uRy4iChoR5tul+d+pkiVD0x8vUnkd8D2O5ZX7X0mEhDKmQW1Np37Uqgbj bJKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186053; x=1717790853; 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=foy6JQDzCRlndu2wDkMW+/KfxEQHtUuSgLRAcEoN4C0=; b=m3Z9t1JwWAvraPfLRKLjiY6XxzpKlap2mTrhZcMq9oDfqR6Qf/6utnHt2VXtsimQUk 8p6q1cYiAsVDZS9BQrvxuIyxS1H1nwuFSEc43otO0dLpVxC65vr7ReO0pCginPNyowb8 ZF/TcTlt2CTr7mhjEElXu5KNDsYf/uOrFrPwIHViN3PDNijb8gcodp93afXCbw+gazaa 7jEMRdIXPLnDvPVHNxk8zUhJ7xAH17MM85Yusqx8lrH7O6qk5OXBGMBgXa7K0FIy0QE8 Nkv4XAYd2iN3TssnxcnFrFbfS4seGGpX4A06yVJu+I2IoeXnOMrYvb7AodR+0F8gnEjm 780Q== X-Forwarded-Encrypted: i=1; AJvYcCUoB8s9NeF5QVmrSeqjBd6XeTU28T6xC6VEeDj/5ov0zZHE19vnk2F/RK/7it//erstuB5PkNtEatMo+3ggv1j1AEhnU+ySLDJZGyW8ow== X-Gm-Message-State: AOJu0YznJkyhPwSCs+QbSeXuQRDhMr245kxd0DYRp6Dmo4tWxugLNRgj mebJZH2dhtNw5O0p8DLjzEwPblSrybEDCtK43oSX263LEZpifV8R7KHcQtjJcZU= X-Google-Smtp-Source: AGHT+IHe08TPzRwu8QJpB+XlF9UFkX4BM6/WRN6Xrq2DzKyEX+hm+4hCpcrc/wdSno18d3D2NGT4xw== X-Received: by 2002:a2e:a99b:0:b0:2e0:37be:b70f with SMTP id 38308e7fff4ca-2ea95160333mr22535721fa.26.1717186052632; Fri, 31 May 2024 13:07:32 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:32 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:26 +0300 Subject: [PATCH v4 3/9] drm/bridge-connector: implement glue code for HDMI connector Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240531-bridge-hdmi-connector-v4-3-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9637; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=cqCdor0KJlbsJ87CXjTFhRdAs763FYhaLzSStx5DE/w=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmWi4AlEFNoNujj5XVYXq2skTWjPqicVVG7XXx7 DFHgfkY++mJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlouAAAKCRCLPIo+Aiko 1ZynCACJC6aYfwTMqIXQVEPf/+vDvVuJvSFIKAKY9BsMpSSF0aHRQqoZfgfOPwNuHDtVDJrImNF WeycDKKG3J4huOXpcWnVVzCUqQ6Rq7WX3QBE+Aj/HQdvn6bl8WiwDU72wS0Lx4icdt9u5/6u/VE MClLhBpcVl3QPDFF3Ozg8UFF1k1mXs1ZTPMGqDGJ1/2NDTCRISzU+KzGUR3QC49Rxh/EMzb57rB CqCIbWIqBHbnhYMas+wj6uuvkn4QyaCmp6uOKtTibuN7iEDZTjr8ARGEHuTdBz03bdhTBgYtmBT l1dRUhj9kwHsrLTLcePFMmOo1LQchQMGFZL7I6azopuE48fv X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A In order to let bridge chains implement HDMI connector infrastructure, add necessary glue code to the drm_bridge_connector. In case there is a bridge that sets DRM_BRIDGE_OP_HDMI, drm_bridge_connector will register itself as a HDMI connector and provide proxy drm_connector_hdmi_funcs implementation. Note, to simplify implementation, there can be only one bridge in a chain that sets DRM_BRIDGE_OP_HDMI. Setting more than one is considered an error. This limitation can be lifted later, if the need arises. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_bridge_connector.c | 96 ++++++++++++++++++++++++++++++++-- drivers/gpu/drm/drm_debugfs.c | 2 + include/drm/drm_bridge.h | 83 +++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index e093fc8928dc..95af857b271d 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -18,6 +18,7 @@ #include #include #include +#include /** * DOC: overview @@ -87,6 +88,13 @@ struct drm_bridge_connector { * connector modes detection, if any (see &DRM_BRIDGE_OP_MODES). */ struct drm_bridge *bridge_modes; + /** + * @bridge_hdmi: + * + * The bridge in the chain that implements necessary support for the + * HDMI connector infrastructure, if any (see &DRM_BRIDGE_OP_HDMI). + */ + struct drm_bridge *bridge_hdmi; }; #define to_drm_bridge_connector(x) \ @@ -287,6 +295,63 @@ static const struct drm_connector_helper_funcs drm_bridge_connector_helper_funcs .disable_hpd = drm_bridge_connector_disable_hpd, }; +static enum drm_mode_status +drm_bridge_connector_tmds_char_rate_valid(const struct drm_connector *connector, + const struct drm_display_mode *mode, + unsigned long long tmds_rate) +{ + struct drm_bridge_connector *bridge_connector = + to_drm_bridge_connector(connector); + struct drm_bridge *bridge; + + bridge = bridge_connector->bridge_hdmi; + if (!bridge) + return MODE_ERROR; + + if (bridge->funcs->hdmi_tmds_char_rate_valid) + return bridge->funcs->hdmi_tmds_char_rate_valid(bridge, mode, tmds_rate); + else + return MODE_OK; +} + +static int drm_bridge_connector_clear_infoframe(struct drm_connector *connector, + enum hdmi_infoframe_type type) +{ + struct drm_bridge_connector *bridge_connector = + to_drm_bridge_connector(connector); + struct drm_bridge *bridge; + + bridge = bridge_connector->bridge_hdmi; + if (!bridge) + return -EINVAL; + + if (bridge->funcs->hdmi_clear_infoframe) + return bridge->funcs->hdmi_clear_infoframe(bridge, type); + else + return 0; +} + +static int drm_bridge_connector_write_infoframe(struct drm_connector *connector, + enum hdmi_infoframe_type type, + const u8 *buffer, size_t len) +{ + struct drm_bridge_connector *bridge_connector = + to_drm_bridge_connector(connector); + struct drm_bridge *bridge; + + bridge = bridge_connector->bridge_hdmi; + if (!bridge) + return -EINVAL; + + return bridge->funcs->hdmi_write_infoframe(bridge, type, buffer, len); +} + +static const struct drm_connector_hdmi_funcs drm_bridge_connector_hdmi_funcs = { + .tmds_char_rate_valid = drm_bridge_connector_tmds_char_rate_valid, + .clear_infoframe = drm_bridge_connector_clear_infoframe, + .write_infoframe = drm_bridge_connector_write_infoframe, +}; + /* ----------------------------------------------------------------------------- * Bridge Connector Initialisation */ @@ -312,6 +377,8 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, struct drm_connector *connector; struct i2c_adapter *ddc = NULL; struct drm_bridge *bridge, *panel_bridge = NULL; + unsigned int supported_formats = BIT(HDMI_COLORSPACE_RGB); + unsigned int max_bpc = 8; int connector_type; int ret; @@ -348,6 +415,19 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, bridge_connector->bridge_detect = bridge; if (bridge->ops & DRM_BRIDGE_OP_MODES) bridge_connector->bridge_modes = bridge; + if (bridge->ops & DRM_BRIDGE_OP_HDMI) { + if (bridge_connector->bridge_hdmi) + return ERR_PTR(-EBUSY); + if (!bridge->funcs->hdmi_write_infoframe) + return ERR_PTR(-EINVAL); + + bridge_connector->bridge_hdmi = bridge; + + if (bridge->supported_formats) + supported_formats = bridge->supported_formats; + if (bridge->max_bpc) + max_bpc = bridge->max_bpc; + } if (!drm_bridge_get_next_bridge(bridge)) connector_type = bridge->type; @@ -370,9 +450,19 @@ struct drm_connector *drm_bridge_connector_init(struct drm_device *drm, return ERR_PTR(-EINVAL); } - ret = drmm_connector_init(drm, connector, - &drm_bridge_connector_funcs, - connector_type, ddc); + if (bridge_connector->bridge_hdmi) + ret = drmm_connector_hdmi_init(drm, connector, + bridge_connector->bridge_hdmi->vendor, + bridge_connector->bridge_hdmi->product, + &drm_bridge_connector_funcs, + &drm_bridge_connector_hdmi_funcs, + connector_type, ddc, + supported_formats, + max_bpc); + else + ret = drmm_connector_init(drm, connector, + &drm_bridge_connector_funcs, + connector_type, ddc); if (ret) { kfree(bridge_connector); return ERR_PTR(ret); diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index dd39a5b7a711..e385d90ef893 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -762,6 +762,8 @@ static int bridges_show(struct seq_file *m, void *data) drm_puts(&p, " hpd"); if (bridge->ops & DRM_BRIDGE_OP_MODES) drm_puts(&p, " modes"); + if (bridge->ops & DRM_BRIDGE_OP_HDMI) + drm_puts(&p, " hdmi"); drm_puts(&p, "\n"); } diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 4baca0d9107b..3e86bb07eaa7 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -630,6 +630,54 @@ struct drm_bridge_funcs { */ void (*hpd_disable)(struct drm_bridge *bridge); + /** + * @hdmi_tmds_char_rate_valid: + * + * Check whether a particular TMDS character rate is supported by the + * driver. + * + * This callback is optional and should only be implemented by the + * bridges that take part in the HDMI connector implementation. Bridges + * that implement it shall set set the DRM_BRIDGE_OP_HDMI flag in their + * &drm_bridge->ops. + * + * Returns: + * + * Either &drm_mode_status.MODE_OK or one of the failure reasons + * in &enum drm_mode_status. + */ + enum drm_mode_status + (*hdmi_tmds_char_rate_valid)(const struct drm_bridge *bridge, + const struct drm_display_mode *mode, + unsigned long long tmds_rate); + + /** + * @hdmi_clear_infoframe: + * + * This callback clears the infoframes in the hardware during commit. + * It will be called multiple times, once for every disabled infoframe + * type. + * + * This callback is optional and should only be implemented by the + * bridges that take part in the HDMI connector implementation. Bridges + * that implement it shall set set the DRM_BRIDGE_OP_HDMI flag in their + * &drm_bridge->ops. + */ + int (*hdmi_clear_infoframe)(struct drm_bridge *bridge, + enum hdmi_infoframe_type type); + /** + * @hdmi_write_infoframe: + * + * Program the infoframe into the hardware. It will be called multiple + * times, once for every updated infoframe type. + * + * This callback is optional but it must be implemented by bridges that + * set the DRM_BRIDGE_OP_HDMI flag in their &drm_bridge->ops. + */ + int (*hdmi_write_infoframe)(struct drm_bridge *bridge, + enum hdmi_infoframe_type type, + const u8 *buffer, size_t len); + /** * @debugfs_init: * @@ -705,6 +753,16 @@ enum drm_bridge_ops { * this flag shall implement the &drm_bridge_funcs->get_modes callback. */ DRM_BRIDGE_OP_MODES = BIT(3), + /** + * @DRM_BRIDGE_OP_HDMI: The bridge provides HDMI connector operations, + * including infoframes support. Bridges that set this flag must + * implement the &drm_bridge_funcs->write_infoframe callback. + * + * Note: currently there can be at most one bridge in a chain that sets + * this bit. This is to simplify corresponding glue code in connector + * drivers. + */ + DRM_BRIDGE_OP_HDMI = BIT(4), }; /** @@ -773,6 +831,31 @@ struct drm_bridge { * @hpd_cb. */ void *hpd_data; + + /** + * @vendor: Vendor of the product to be used for the SPD InfoFrame + * generation. This is required if @DRM_BRIDGE_OP_HDMI is set. + */ + const char *vendor; + + /** + * @product: Name of the product to be used for the SPD InfoFrame + * generation. This is required if @DRM_BRIDGE_OP_HDMI is set. + */ + const char *product; + + /** + * @supported_formats: Bitmask of @hdmi_colorspace listing supported + * output formats. This is only relevant if @DRM_BRIDGE_OP_HDMI is set. + */ + unsigned int supported_formats; + + /** + * @max_bpc: Maximum bits per char the HDMI bridge supports. Allowed + * values are 8, 10 and 12. This is only relevant if + * @DRM_BRIDGE_OP_HDMI is set. + */ + unsigned int max_bpc; }; static inline struct drm_bridge * From patchwork Fri May 31 20:07:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800581 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 3F64C17E46B for ; Fri, 31 May 2024 20:07:35 +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=1717186056; cv=none; b=Hsj0Sm/eG0F9xOfrRWVY+rS1RBtF7xhmuTdrdqJa04oE4IEbl4RE4MAEJcK/yLYy2Ph+RwgP/NzJuJ9JmtKfkm1ImG+jhoJKLymEBS25howvNWkuhGuJY9I7YWI4z2DjIv2cnXSKiXP1Qf/bPhaf/IUhdZzSRE9KrQia9yv6kC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186056; c=relaxed/simple; bh=ATNJtCzOXDVp1OKwxiEV9jk7WYH4jasM/bHZPYZfo4g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G8WJ8vyDfqIzBVR1TRzJuNTmvXb4IF6n41xOwiVKU7H0EiuK0fu5QRAMU+RY2aciEP/bsv8XGFH+uFvdp+M53nZasTIh+mKPk022Ezu4T+RMOfzPdOGVhpytXcTRs7vWh0IQUaQ5aRJg2/fsdWHxhrzThXKPrAUx5vVQMEKyEC0= 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=nkR9A2AX; 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="nkR9A2AX" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2e78fe9fc2bso32944751fa.3 for ; Fri, 31 May 2024 13:07:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186053; x=1717790853; 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=d6C2WBjw85TMMZ9GIIugc3NhLWza5ZaClpp5YdwIj3Y=; b=nkR9A2AXVdWqCkpoMxWX47aj3H3FdZGg1qcU13F3gL62tS/CNwPoUVgxm1uGq6cDsg tS+bN+wlv9G7X4RXN3O7+/k10OfbH6pUoYPR9N5d+3mjVuLB6OaxOoqHjs48gRv2yNq5 TUqF96tSWQgB8JjflN9Gdrex2yeWYYH95OD2lSOX2Kji/V1spTaQdsXUeY/Q2VG0Ue+J wbd+AC6YEIrM1eWJsj1mwKegJxX3nfbGWx9WxcvJxv4WIpg7ln1v8ZwS5LmfpXKg+Y5I 9obw6gpotn9jDQ7WEGAlU7ZljMtmSZ1wtp2VOcWZkd6UiKZK8lNouRlgyRsjtVItrcR/ HeRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186053; x=1717790853; 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=d6C2WBjw85TMMZ9GIIugc3NhLWza5ZaClpp5YdwIj3Y=; b=VPtU+w1xMYeeat4M25ikT6omaMY/wR5jvOg+TLIb4qYRCtBuS0QlWHWYME0sfuugI/ v1ofyaCThMRrwjiSSv5WgbQTGUh3sDEv+vYNf2iIRqvIwZHuBtzW8w/ZQ/btQjTt8tqQ AYa/Qt6LmHFYLoOkC6yg17S+E+2r7yXPg3aCYvL64P3PdZzngkxRDV0WR03FD3Oia9hn ICdwQ9b3U62KTBEV3OBKdpGUbq3QddNTr7YkAXI6eume1Ga8iajkKJpduC9RIvO4YvyH w8wIhSKiYOtkKsZ2dE0GF71SOLukYwgQ6M3+kLJMRsusbaycvR+z9B02GlN5lfmuIbkM L3IA== X-Forwarded-Encrypted: i=1; AJvYcCWt60u152no4/z4wR7Vmx0IPu+s0vk9RX4UipGJLegLjb0vISgmym/U9yBsBSdEsWTYrTWnCn3zi6dYR16cvihPB+y08JnT3hIClrZbuQ== X-Gm-Message-State: AOJu0YwwPo4Ehn3tgtKZrXA1k/yYgrxVGwpQZ/x7KYqtNYpjqMXVXKCZ dceXUyBPbN4A7GB0e+BwhnU7EwZUnT8zAAF8RvuwxZd6SX11fhAWtT54nbWYVUA= X-Google-Smtp-Source: AGHT+IFEbGsurUQqegm0dR4iZcKkdLohi5tdSQtO24nzPhBAHnIn6wJq6gBZuF0+VUHo38IC2u3gKA== X-Received: by 2002:a2e:3517:0:b0:2e5:61f8:db58 with SMTP id 38308e7fff4ca-2ea950fd531mr19016881fa.11.1717186053514; Fri, 31 May 2024 13:07:33 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:32 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:27 +0300 Subject: [PATCH v4 4/9] 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: <20240531-bridge-hdmi-connector-v4-4-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2170; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=ATNJtCzOXDVp1OKwxiEV9jk7WYH4jasM/bHZPYZfo4g=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmWi4AMWQQW3Gm/ic5snixj31M57cTzkXCz1Z9e 9X5rwFblCyJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlouAAAKCRCLPIo+Aiko 1UGXB/9frTF1MzeSGRB/G97BiMJwkvfUeL8Hu4DM85QkmNl6gMMTDOIMaet+aTodn+4H5ZvFBNq 7kZOfWDezgACnMCRWH+/QPv9IgQFgUk6tcYIwn++ETDnnpJJgACy/JBpINpWOfd3W+qtfiNOTDI g/vbKMoWEUqZg3u4O/0MUm/6fOyTUcseXHp1GZqI038siGvihfCZzHWDGJnZxZGDZ/W1+bNwyEL gqqMwm38yyd82GDE6mmD73qkXc5wJiFkcOBNBVcqiaXa9kYs3I/JLL1lQOHTj7C34jIPBBREVQZ 1msY9c4lFy/x6Gxd09VDiBe4TDFWPIQUGyIhmXyOgzezAdkN 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 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 4a5b5112227f..d839c71091dc 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 May 31 20:07:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800956 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 AFF0417F4FF for ; Fri, 31 May 2024 20:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186058; cv=none; b=iz/hCs+wq36zXLt4uhwLOO/Jq1/7z95Pd9r3P1G//puzJLUbakKYbQdfYMtysPcmXvBrlrrXA7Au57G0r98wfLKrB2+mOIJ1UXekL33wZ5hdQVWpOCthH7nqhRWpQXHKJ6oMpmRJn4YQ1WiKs9PFNAPlbqWxKlj8d4pGhxmMwtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186058; c=relaxed/simple; bh=UWUILZSKKGNyx193zjImsEEpRTHfS6fkYYigZ43zbQc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bvljf3jcn/OwJPzrG2XIMU2kv1R85z2wTLFGkmkf+orczZUV3sxMS/WDkK3L/IrGDAPamQHpD11Qe7tIcWvNHiy0aFUxe9vZxDBkN6DOC65PzbGdeSPPFU8yqSawGvcVlzz+ttFy6Df71rmHewfmpRK5odNAkdKM2NALH93vv9Q= 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=it+qPrXF; arc=none smtp.client-ip=209.85.208.178 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="it+qPrXF" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2e95a1eff78so32217831fa.0 for ; Fri, 31 May 2024 13:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186055; x=1717790855; 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=FiLWZR73FzG1cBUuGAjbn5LfyouiORitTo/38HE0+Xs=; b=it+qPrXFtIC1z2FD4D+sO+YkW5HpRl+kGY6XtMEsjmM7u2ZZDNs+ZxsJ1UsDtRx812 KB+zhrgeUgxARWK2ayA2aoWqkaWO0lcGTTxl+RtMhwlosufOeFWoMR+CyCj5auM+a6Bn hnfjMMnJi+Tvfs/S1pLe+pVBNbLQo/dkQfNY3nsfvAm53qA169pAsT0XH0bIL6YjYYO0 HXekAQTzad4IjBh/miTZr18XruULvZDIOFpIwCwawkofyOsnFi6g3EoJUsDVFn5KfBM9 sbTy1gqfnM7gzC6jF73gGW8TWxXHpabSvtq4bHgS5ONNpquOWkVnCuN1RPWrf7CXrckd 5PWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186055; x=1717790855; 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=FiLWZR73FzG1cBUuGAjbn5LfyouiORitTo/38HE0+Xs=; b=o4/43zqpdZl53/bmJLeAZbxISg24vp3hKd1OF9CVA03sdeYYLHUsBbX15ezgO+w6Va TNj21LLZmK/Q6QBrWme4CB757zSjlUsEZszmlaoKQt7R17pgcsxrUoPnklEX+fZfLiyj Hl0gKSns2L9P+nkWYV2PpCyqa1+x4/QKqdbDFZUDaBqIAuKqMWIeb6rav7J/qKFFIHa+ rNOvlQUchJhNiimhkewVhUKuhqaTXoKxeSaZcYKk7nVcubA6WgrzetPQ5qUziSKwwc1E 3gfWYpWahNjp5pMsH5jzAHIUdQmtRcFgPlqhJ6n0Rs+psY0/2jWixlq5VjNGSUI4v3gR K6Yg== X-Forwarded-Encrypted: i=1; AJvYcCUU/G8lzOp+ZEY8fo52oLjd8fxzL1HyhNwoF3NZDykVxM0OaMGUC2x6xK533ILBfDWyEL4jhZXrdPZWyS7a2yrEjopQaEX26RlQOAUkZQ== X-Gm-Message-State: AOJu0Yy21w23eJVRbCvciwiIwXKrQ6R2g8zEHwlwgfQXQBioTE47pVMa tcmaYk0tZspFEgOqOYu4dpyNg80A7bWEl7svMilC1hapgdi2UpIPyqEDgwzMRPcL5AQa2QPD8jV V X-Google-Smtp-Source: AGHT+IGV3cCszJL2Evl8iyDXheyiC6hOTx+o95E4nNadmsnYln85PmjclchsS6VnyRMmAvINPl2LPw== X-Received: by 2002:a2e:b693:0:b0:2e9:8852:3d20 with SMTP id 38308e7fff4ca-2ea951e4c52mr23923571fa.41.1717186054220; Fri, 31 May 2024 13:07:34 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:33 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:28 +0300 Subject: [PATCH v4 5/9] drm/msm/hdmi: turn mode_set into atomic_enable Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240531-bridge-hdmi-connector-v4-5-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3487; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=UWUILZSKKGNyx193zjImsEEpRTHfS6fkYYigZ43zbQc=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmWi4A5VAxSNzIvkri0KCvCvKC+3PtYIkHbBwQf Y+oSMDUI96JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlouAAAKCRCLPIo+Aiko 1W3/B/9hxuzoStd2MFOr27dsWDaQLvdDfDKq6OitbAFUenCZ+yoDz5INHgYLgNAFKeLcQY97zk7 oi/xQrziuDyC8cYUzfBovdERtp6AbdklpswZ+qzOXYDBDmE62EDkfOTTf4JLYKS/Gmkny+96+6J uWPoLmdWkj7jT1ndF3RNxt4hE+HU/PkBp8A8s67dkotwqviDsyUpG7UqzVZflZ2cvMNMXkdTgsN SVneGeLuMUXeDLryp0nZwyspdFGdySGkKqSAlQisz1ZQf6X2NBbgeDg4Nob6bvmCn8s0w2bV2zE AKSxqnDsWh1Dk0Bzlfe9s+lWijwVpfzA0OPpeBulpM9dheKA 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. Turn it into the atomic_enable callback as suggested by the documentation. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c index d839c71091dc..f259d6268c0f 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -129,12 +129,25 @@ static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) 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; + const struct drm_display_mode *mode; 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); + mode = &crtc_state->adjusted_mode; + + hdmi->pixclock = mode->clock * 1000; + if (!hdmi->power_on) { msm_hdmi_phy_resource_enable(phy); msm_hdmi_power_on(bridge); @@ -177,18 +190,24 @@ 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_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 drm_encoder *encoder = bridge->encoder; + struct drm_connector *connector; + struct drm_connector_state *conn_state; + struct drm_crtc_state *crtc_state; + const struct drm_display_mode *mode; int hstart, hend, vstart, vend; uint32_t frame_ctrl; - mode = adjusted_mode; - - hdmi->pixclock = mode->clock * 1000; + 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); + mode = &crtc_state->adjusted_mode; hstart = mode->htotal - mode->hsync_start; hend = mode->htotal - mode->hsync_start + mode->hdisplay; @@ -305,8 +324,8 @@ static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = { .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_enable = msm_hdmi_bridge_atomic_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 May 31 20:07:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800955 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (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 E340E17F51F for ; Fri, 31 May 2024 20:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186059; cv=none; b=AtMfau5tq9dRzPm5O6/UDT81uj22PoTw60/M/DtO2yQ6WW8C3TzxwcPwa8Do8kW7asFCi4XcHxA2paYaBizkFh5Jt60dJke01c4iJxNaGpKJm7wWBzmDK0QEwS7YF0R4YTXmIAiDm9H1T9vkEsGcCbQevQOGdsWbDrLcPCeoutg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186059; c=relaxed/simple; bh=IMq2crKsuBYNlo9xas/69WjPLZ/VdRH6PKTig5R7CWc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cM0boPtIrVVGE5KumH/7MKLEDfn/8qIsWHAwuFfBhQ4Xoi6Ez9IoHxXTQ93hvFNRPvVhQ6fCyf1iIoJKa56cM/AVae61LNCGW1O9WwVrmezD/XPZOsOuUBAXRT5eDjcX/P2HNHvR4afr0slhhuN3GZw1Lu2baJqdQREDy14RLpg= 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=U9bOdn6H; arc=none smtp.client-ip=209.85.208.177 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="U9bOdn6H" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2e6f33150bcso26254931fa.2 for ; Fri, 31 May 2024 13:07:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186055; x=1717790855; 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=jmej/DF9YJfH8W8QcD0M+jwkejFWEE9lxubXYx3Dz7s=; b=U9bOdn6H4MsffjxxnH6Mrbbz2/ICq7TByxabYvcxQHt4kuY+3lSG0YoqQu5L0Ey/GA xTIpaUjQasQwVarW6T2S2/GvyhgPKQf25nGCz6h+ReJRrfnERoZCbnLja8AwgttFJZCZ RqcmfqGQxMf1Ehys7B6rXAInVjdnGMtaCnVnuBWTuVz9SSgYzdO7FUG7dDaz3lK2skTf 1tgXUTmtbrIEAO/5NBQJxamCInqQKMz0Wu80MlAVXRhTIJadQLFT6rKJPzEbWgB5Xkdz l2ddOixHmulum/Elp2oqSYDrewOh0SL3sjmSe6tvcAYtOJBHKxOlEmsruSSSd9fCywcz K2TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186055; x=1717790855; 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=jmej/DF9YJfH8W8QcD0M+jwkejFWEE9lxubXYx3Dz7s=; b=iUd1+iaS5pXbr79+h4vG9tBvlWpSOqwvPaT/b/9gXYuhC6kS+djfViN4PfPHxmOkhL VIcU4SQDye1kgZiDEuR8Y9t19OpAISqRb4+cwKuLnxe0C7cJV7UtXpEJ4L29HJnzADTA vxMpGp5tEXNnPZU7j46lqoWzIfLETjw9RAlMz6TDdO+At1afx5hlX2ymQXyWuk7fPxWv iG3u4JwE3PZ7EC9z3YMDle+qXm3bxmh3PxIVHJ1sPBGzyx8IESfCiSpxaiCzh1ELJrCy YPN6ibpfUVQMp988+fcKFuodBJ8TciT8lhaX6uGAKDREnYXICKR3Jk1O2OzYnvnYkXKo NzkQ== X-Forwarded-Encrypted: i=1; AJvYcCVyj9QmJHeumEcozgBTRtp+p2p4dQNrMnF7XexjEaoacqKsJ2PlsHW8chPUatUGyltbtZnr/BpWQSQbVFJMw92fiBSsn7XvYHTCLcC9sA== X-Gm-Message-State: AOJu0YzijbppuM3k2yO7ezs/1TJi59DnOmEW8dzbc00aqBLtBotu+UO6 3uSJuNL2MZk/kn5JBPrAJtNaFRU6RQQNt22gev3LgHbN7HqKEkHc5bjILLljWns= X-Google-Smtp-Source: AGHT+IEtf48+du57sHfdCS8lsJJjO+0/TgLiY8W/2/PC5e2BSb5AoHcbC9r4iWY2Kn7OSaIE13SNPA== X-Received: by 2002:a2e:9149:0:b0:2e4:14a0:4d15 with SMTP id 38308e7fff4ca-2ea951d59f4mr19264141fa.51.1717186055058; Fri, 31 May 2024 13:07:35 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:34 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:29 +0300 Subject: [PATCH v4 6/9] 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: <20240531-bridge-hdmi-connector-v4-6-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=20473; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=IMq2crKsuBYNlo9xas/69WjPLZ/VdRH6PKTig5R7CWc=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmWi4A+nlwUfVvaXqwsffujsjgJvRAWq9RjDVx/ /vK4ilpPS+JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlouAAAKCRCLPIo+Aiko 1ct+B/0bmxaaC0hoA84+h16IYRpJP6VyEFEZ81sRg+nkCOFwbte3iZDg47dHGhMZ0O5yltfv3Ot QhwuP4xKlyZ9xqzhudP5S2oToI8x0luIa2qfAxXxNeGwJ9Mknr2V4yDy83aB087sb6IQyx69tcg OFekkT3cIxT07DiYIDHs7s4EPkPbruQlIn8hgCos5nFUMOczJ+5L3N9uLjbgwknzziUATuSZwXL IpaRqKccDrLxo6VLJZUMe/q4VZt3U3lpGclWZZ+XKS0rXhIgPaQqfi4aSe6Ubt7zB3kE5c25aIl yCFrdLJbK/4JoiZyz2QXrUVxfyx/vr5YEXC1etfYu1lKmenC 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. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/Kconfig | 2 + drivers/gpu/drm/msm/hdmi/hdmi.c | 44 ++------- 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 | 170 ++++++++++++++++++++++++--------- 5 files changed, 159 insertions(+), 147 deletions(-) diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig index 1931ecf73e32..b5c78c1dd744 100644 --- a/drivers/gpu/drm/msm/Kconfig +++ b/drivers/gpu/drm/msm/Kconfig @@ -164,6 +164,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 24abcb7254cc..179da72f8f70 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,7 @@ 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); + 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 4586baf36415..0ac034eaaf0f 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; @@ -199,12 +199,6 @@ static inline int msm_hdmi_pll_8996_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 @@ -213,12 +207,8 @@ static inline int msm_hdmi_pll_8996_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 4c2058c4adc1..924654bfb48c 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 f259d6268c0f..9eecc9960e75 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,126 @@ 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); - hdmi_write(hdmi, REG_HDMI_AVI_INFO(3), - buffer[15] | - buffer[16] << 8 | - buffer[1] << 24); + return 0; +} - hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, - HDMI_INFOFRAME_CTRL0_AVI_SEND | - HDMI_INFOFRAME_CTRL0_AVI_CONT); +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; - 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); + 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); + + val = hdmi_read(hdmi, REG_HDMI_INFOFRAME_CTRL1); + val &= ~HDMI_INFOFRAME_CTRL1_AVI_INFO_LINE__MASK; + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL1, val); + + break; + + 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 int msm_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) +{ + return drm_atomic_helper_connector_hdmi_check(conn_state->connector, conn_state->state); } static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, @@ -136,28 +221,22 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, struct drm_encoder *encoder = bridge->encoder; struct drm_connector *connector; struct drm_connector_state *conn_state; - struct drm_crtc_state *crtc_state; - const struct drm_display_mode *mode; 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); - mode = &crtc_state->adjusted_mode; - hdmi->pixclock = mode->clock * 1000; + 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 +263,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); } } @@ -252,9 +329,6 @@ static void msm_hdmi_bridge_atomic_enable(struct drm_bridge *bridge, 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, @@ -297,7 +371,7 @@ static enum drm_mode_status msm_hdmi_bridge_mode_valid(struct drm_bridge *bridge struct msm_kms *kms = priv->kms; long actual, requested; - requested = 1000 * mode->clock; + requested = drm_hdmi_compute_mode_clock(mode, 8, HDMI_COLORSPACE_RGB); /* for mdp5/apq8074, we manage our own pixel clk (as opposed to * mdp4/dtv stuff where pixel clk is assigned to mdp/encoder @@ -323,12 +397,15 @@ static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = { .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_check = msm_hdmi_bridge_atomic_check, .atomic_pre_enable = msm_hdmi_bridge_atomic_pre_enable, .atomic_enable = msm_hdmi_bridge_atomic_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_clear_infoframe = msm_hdmi_bridge_clear_infoframe, + .hdmi_write_infoframe = msm_hdmi_bridge_write_infoframe, }; static void @@ -360,8 +437,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 May 31 20:07:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800580 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 8A6AC17FACB for ; Fri, 31 May 2024 20:07:37 +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=1717186059; cv=none; b=KWGO7WwBEazutKaH0LejT/dkcZgf3y3D0QhwmkeCE7gvUkk1ZAEgd0S1syMmFegqarzguCuzxfkiyNBJdELIbYOqkMkPqdKCp1REPshFbzwOwN65sHeo9uyysuFQLzrIIS04iI7FLFyZgau5PwOhj16rlmDVSiQLlu0udSeM3f4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186059; c=relaxed/simple; bh=YU3BlXVbC2sxyz2PPZCCSUqtcJVpgJv63N0Ddf7f0rw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GYw9QbBAPqMfOOK5LNQm2MNQpx797RaO16Myeqa2b/CKwIm/GYD9hXWBbaOB2SDtU8spgu5IrKCiCMsHt0+RKbda0E7erOcO1mPiGtw63Lbv5MA8sUgeVZFQM7M1xjlDvTGChbYI+Hd1zhvDlhFCLB6ubrzGbk8o2jpFt738UEs= 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=sLeWBTbP; 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="sLeWBTbP" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2e716e302bdso24073791fa.1 for ; Fri, 31 May 2024 13:07:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186056; x=1717790856; 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=fyQFsCbfAwoMIv3tWG4MkDjXNMbuJRe63fpfFnOR1dY=; b=sLeWBTbP/IT7kn1+cAAyxW0+8gieoIuqHiJqREmNF8kMrtRlPP64bhMshadodwRyNf WD8zzmuW61+ZS2c7/b1YK99Fhnw90NSoS9ft9G1PaQnFN4z2NKv5jlXxOGDZekav6mxr FYZq2stl5e3IEBcwTLc+wZLaQtCMyojdLhtrl4Ji/p5qzO02K6n6nBUX1Hs2sOPa8sbb PeBpFmV8IJmHDoHXpxHmSUeLaT/SulMJ+JhTzRt/m/vAWv5HX0XcMsOy3hIX/Xi9Kinz pgTeXke+joqeSwb6acLRg2Mm+uxZmR6y3SnzZzCiB254qmDmMNWO7EvYe3FGifrhYWvx +BdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186056; x=1717790856; 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=fyQFsCbfAwoMIv3tWG4MkDjXNMbuJRe63fpfFnOR1dY=; b=afaqhadJZPDAvxNDVcmhTcSJZ1TfnYDUM3Vj03YTcwXnihsxll7fCHEMyLl7RgPg4F EmaziYDRmbRZIZ0jYPgGpbCVk8wHdUjabhkt6+RFLL24mPPdFknC8OvN55LDZZiE8pjn /ycdcLkuX/s/EHqd6/8noB5OBP1U+yaAnM4P3VnNbZXhB7MfZvADPq/5X7T4yxSKOaYf zL2f7LK7T2ze2CEl7a7jNftg9yWBjoJ2tTJmn82BnbHRuMTHSa3Ks5fEJPSux36yJXFd osihheeFd/Xc+UkyolWcE9svLRN+Hg2f1jr4Jgq+/GT6aRYCjqdM9QaZYAhls/ybz/MQ 2GkQ== X-Forwarded-Encrypted: i=1; AJvYcCWHDPpQH9V2/pU5zyKGVmkLsFJjw9djLwTw06AgQcKDG+op78YStXGyfWhPxkdLjvcgpIrUDYN/wE789fXe+1+HSrji3v8LKAYPBjNQ0Q== X-Gm-Message-State: AOJu0YybaeHKnBhq+zlfEcEGbCZOaBWKSJF3EeyWV0cFsgttMbdRWV3/ m8MC+ohGhyXMpFMF88OfZ/1gGBUUchRBkctynN7IBkwOgOpUsDveETnzIpoNPo0= X-Google-Smtp-Source: AGHT+IG8WKuvGdyXdl/w5pEmXWOdKQMXIjLeMy0WFBbgze9CMqtMG7e1bNR/WlANpKFq7SOK+v+ikw== X-Received: by 2002:a2e:a787:0:b0:2ea:7e51:5166 with SMTP id 38308e7fff4ca-2ea951e7dedmr23294901fa.41.1717186055760; Fri, 31 May 2024 13:07:35 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:35 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:30 +0300 Subject: [PATCH v4 7/9] 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: <20240531-bridge-hdmi-connector-v4-7-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2091; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=YU3BlXVbC2sxyz2PPZCCSUqtcJVpgJv63N0Ddf7f0rw=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmWi4BHrqnztSl/bf+yajDn9vgYH4mqH0Y53sGo OoRBr924/SJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlouAQAKCRCLPIo+Aiko 1Xh5B/9zouH68B/F8qgbHAklwaF8yiIgh7VTIvtswpeCMmZLV2PjfKonuGoa7WMjbjwa1MrRxuf uMHblZllej3vHkYrPZXm1m7R34tnOWxMFrftxZpH0N9XUb2LRJ1iC5MmXv+kkLNBxAqrJcfdRp8 BDLXB//GNhc8L2wreI+17e15dskv9NFqKM2PBiWkDv0BI1+TZ5783H/WqzJ8qGPG2ZBUc3HrOvS 2vID35dnc5jwtgpP5l4HDLUxqS95aGxjiG9XJBbT1Asxjss6TYMpAYjlc6oOOT8eERXtBV5JSoL 2MOfphPuAaCuwn2mPD6tFm7UcVwXHnhi2hJkIdXN3UUXupU4 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(). 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 179da72f8f70..2e2883b9229b 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 0ac034eaaf0f..b7fc1c5f1d1e 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 9eecc9960e75..9258d3100042 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -346,17 +346,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 May 31 20:07:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800579 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 69C9F181CEE for ; Fri, 31 May 2024 20:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186060; cv=none; b=ukhicdQngfe3gXSz8z7m8eB8KwV12vMWfSiDmZFeQ2lvHWGNMm1CqTf7VEpNGC/DlBPVtE5B9BJeNCph9YVPmqca7kD81WSPiEiPye1tXie56opoZW3vNOrTL8JzwAOH7b9YDuhOvjA75+Ym+oCY7oFAeTgcAWFHIMSWOpWSf58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186060; c=relaxed/simple; bh=JXbaAkUfXwOLePC7VJ3jRbdq5WguoXJxRCdZfMDCGD0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NPbkr9nkBaQcZuZU633LoJlqPLyp0dp5RasgO4UIupdiG0rUU/juasCKaI6NG3PZF+EXI8pXby371tax+JAqGJV0J8H9YlKQV2xhhMLTsHxpkr8epEdBIc11cpaye8mOugnn5+h5Oe4SW5jSFA4moJxQClr2U0xjmeEb0KOzMuY= 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=uOpvlwrJ; arc=none smtp.client-ip=209.85.208.169 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="uOpvlwrJ" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e95a74d51fso37298011fa.2 for ; Fri, 31 May 2024 13:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186056; x=1717790856; 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=TkMzRYwH0rVG++I7PNZai1lbvWhZpzJwskrcS26a0W8=; b=uOpvlwrJVhBo25LF41YKDPeEv/T6lO4ZpXieYs7iVKYKt0uGHQLbUHjSJjaqGqKUw5 CO1v9BrycAuMWNebLv4iPJJVGaXt1ZzyPIJrVA8Qi2szSvvvFJ4rB+gq+1uSSiMaTSTj gjtRt7tskohh0bdxYKOu/RKfPUa/MPl16raL8uJIALzp/wTrKGthsjwHWMljtcu2h+Bl e7/ibVLN4AmuRl1LlGSXQ8RwjUVuYgUFkn9w/Gwslhg9gE25t9HINeG4Zf+laSOdtYa9 cYPRZKcDGYKOpopxA0AQrNe+Cs3LZFzcNm4ogf2ytk9pqhnjZITmyBKzoz7Qmtw2eAO8 Xfvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186056; x=1717790856; 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=TkMzRYwH0rVG++I7PNZai1lbvWhZpzJwskrcS26a0W8=; b=YFbOXgGcqQdOYEwzczOOEp72PK9kRwnxn+XofwSg7TA73P2Kwcq1q0irjPAxWh/91F pE6I9yYBOImcRBlyHKvxElqKfPYxJcon+Rh3AlDjTUGwN0ytidRRKGW/O1Duo6HxG9Gl hd4u7w/allzXdd3ZhnfFMBmHIHejXngM0dbghYnHiqy4w10y6eb8PiGDKNnv9kXvAR9V WsJLNcEgtzIHYdG7Hajw50e6TlLDIoE0unfywHSKuS5vHhp/cOtknySpi9RLh+zNKVrH vEa9oBCzOhC/gMQenBTbjMv6ocb81PX/3vqTqga9vbxemH6azKn/cLpU7JW57ALMoxVR lK7A== X-Forwarded-Encrypted: i=1; AJvYcCV6HP9toRqtS4WcFtBRe0hWGjOkJHYFALallKuJQiBACwHPymRbhvYgyacuVzGIWC6JgcToAfBx49YVtzj4fGpoxOwsXuEt+5ZIGV0nLw== X-Gm-Message-State: AOJu0YyOXdCObXmhKK9J+kroycdVJvkqlvxqALkcmFy6muoKv2qIFb14 sFWafZYxiPQ3/pUvZGPdAyXILU5wu8LM23/J978acQziojnnruiQ4/jJfBUZqeI= X-Google-Smtp-Source: AGHT+IGIMq/02fN9VaMxPRgQS9gadWvjnFmtbHVzXgej6CyCQ5quwaOEwoTQOwiyLNKP/eeCiAydgw== X-Received: by 2002:a05:651c:2112:b0:2ea:7dc3:bdc with SMTP id 38308e7fff4ca-2ea951ddecfmr30202261fa.40.1717186056564; Fri, 31 May 2024 13:07:36 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:36 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:31 +0300 Subject: [PATCH v4 8/9] 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: <20240531-bridge-hdmi-connector-v4-8-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1113; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=JXbaAkUfXwOLePC7VJ3jRbdq5WguoXJxRCdZfMDCGD0=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmWi4B4ZlhVOmXUjUHCWOqtnSa7ILwA7r/cU3H9 cpqQSneAaOJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlouAQAKCRCLPIo+Aiko 1VmSB/47l6orxp3up1rfCwe6PSVlP9Jfe6KD6YbCaGQ1HbSxcOEBCOUor73qVPIK1d5jN61Sk0b 6/vcmaA/8ip6UhoS2yfneatbS9yUOksIQeJqN1rqAqTCUGYFKKtesmzdo4v9g6lCOlsoE64l+SC dlXfxHwBOx3h0RV3kvTrmSU75ugnl1LnjLsEYGgbapjupaQK6rKrmC88/mdjK++P+gh5fKSKgKD 0SKf4IPVIr50Pu4lJVZh/HKgrzNF/ubBRVMhQXARdw60pShnSL8PTMsbcMb6WjoXwhTus/tjbJ+ dBdzTv8eYSbgRDv/3FMYPp+5dpdbUQLsKSOfR4INxPEgf+xr 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. 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 6c81581016c7..fc711a842363 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 May 31 20:07:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 800954 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 07CF21822DD for ; Fri, 31 May 2024 20:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186061; cv=none; b=afNAYG/pwuG8l5sXuV7Ha8aUXh0o1r1X1pJ7zc8mc6PkEc9qub0Ccl/I4vwnSovcZ/9junzwPjydmKXHcdf84qhwkN11vJb4Om1sTUCvh0GKtRlg5ROLqV9IZLllwWSve2Vy+8+up8hedySBMSrMBx7B+S/TclNW9fqSuwjJ3Gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717186061; c=relaxed/simple; bh=OmtXhjZ3Qtpb8oKDdME4LcvLFljKS2x7aDOlRaG8IZU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kL4Kre78h1z1u/+bq4CqXID5edS4Md6NxGLYtdWdcARfv0xpMH2jw15jXzaKSXhU4WOJN8qf4YSs5u9Yl/Sb+Vt8QIUTpERr0hfQv7s06J2f8QS/8nonZF0czqMTjg7DnKAkjV0u5GxePTKsNtlgr38Q2ua+AsNfz9J+SO3LP54= 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=DBN3lU2x; arc=none smtp.client-ip=209.85.208.169 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="DBN3lU2x" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e95a74d51fso37298161fa.2 for ; Fri, 31 May 2024 13:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717186057; x=1717790857; 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=Xk2JZtrRtwrwL4+NkRD4qshhppX0yY2US+tv9P72R1s=; b=DBN3lU2xzAY9akukVQ6gRcISPxTuTOycnlSGfDI2dvp6WLt8W/fnyKPqAsH0uFAmaQ IGkxLgxS55DpdfAOLnffjzxE7u/BPSIev4PYCvnEErtd6kmsprXxKCb7jxi52aFoO5EF Bg5KqZVMWv57pAscWjPCRlzeBxEcVsYrr+Onqo5BzsJoHOF5cQx6Tw19Rv8rGepfQSx6 eCAiwBJ3uFJQimUURRvdAiKsmXcQLlWSe9a75D0dLPnQASoZBRdrNq/981dVnIBOJ/W5 XyqiH1U5IZgVVvLmb3JDm9YGTpMHQX/kWbBppNA7bnLDcslskQo+1hGsu0SQqJWbrJpv ng4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717186057; x=1717790857; 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=Xk2JZtrRtwrwL4+NkRD4qshhppX0yY2US+tv9P72R1s=; b=Jf1tDwgjfHZoXMNlScFQQNWN1xVfljSqQ/fA6wwjOOYE5ptKtQUqsfZCePlSGjBCwu JIWS1i7vPkT4bOqGdsqFMMkcqjzwqpCuJreXRt3d7JYqE1os4tA5JB0uASdl6G5Kgxza s1U3oGCunL620gKp6XcNadpRg2gKj/Wa+fMYTp27V1PGJaw58RpI5OkmLXdIvHua8Udy fOJ67b2Z75slb11ZN1In6cT11pi/FkjqS4d8LQ8Y287DD91gQ9AsavJcOXpqYLE6roeR eizLKAUkkzfMP27SxR0kV/43kSh2zcA1twxmlGeUC5G8YjvBZATQxqcGNpLuUHPOC468 yGhg== X-Forwarded-Encrypted: i=1; AJvYcCUm9EzGUDNiVx0yo/M6S7jwa13d+OsQ4gGXhTwX4dq6GIV1KerLBEWD8zRQfxC2cz/F9QXXeBX+9+uBNFnSmb9C1Bq8iBnvyOXKbpibDA== X-Gm-Message-State: AOJu0YxiYQ+xl3XfpP9k2pDtRQxv+xR2ny3tdQyiQaEVVqTGzbIWM0PV eP9sQbD91v5veKW1wD+z6McFBmf5L8odTy/DsVprL8LC1Upls/BWuAMbdDY2xNA= X-Google-Smtp-Source: AGHT+IFRD2RAUhETt5GmKj4NUTgPNO1iLEY35FHrVeaC1n8sq/OEOXGOfyA8SqPqfUwlY1OycDWcuQ== X-Received: by 2002:a05:651c:1059:b0:2e6:be3c:9d4d with SMTP id 38308e7fff4ca-2ea9510e113mr26142781fa.12.1717186057247; Fri, 31 May 2024 13:07:37 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ea91cf0b83sm4022111fa.116.2024.05.31.13.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 13:07:36 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 31 May 2024 23:07:32 +0300 Subject: [PATCH v4 9/9] 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: <20240531-bridge-hdmi-connector-v4-9-5110f7943622@linaro.org> References: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> In-Reply-To: <20240531-bridge-hdmi-connector-v4-0-5110f7943622@linaro.org> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4619; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=OmtXhjZ3Qtpb8oKDdME4LcvLFljKS2x7aDOlRaG8IZU=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ1qUHmOs3zv3HzrSh5vv6Puem/94qpnJQncHH45k58lcP b/5FyzoZDRmYWDkYpAVU2TxKWiZGrMpOezDjqn1MINYmUCmMHBxCsBEOI3Z/7vpsxyRLTr613x2 u5rT+gslhbZs9UuMrO8JJieIPHY6ED798pnW2JcXZwk8We4XWX327m5/Fu0fBW9utD5wOuAww7L Bx4bX94nQgdOSczSXJPkb2vjfu7smniPkbVJ0V8MiJjdGtx3CxSceXNeOz9HaIKmR/KHH90h02l njeAl/1pOFl/r6GBv2nxHdEWHA+zhXQfnY+h8H9+sJTlRIs3zhUZhVktHGHKa7bsdPD58q4YNff v7L+XJtkl5QXz5PNfPvfY3KM7pY50/N5+t5/iVcK8aa98uPOvELymrPm42UT/xbWSg285bLitWd vu+9potFTylyO1b59dZTr3YHzquf5iuXCqRkv9bW19oBAA== 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. 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 9258d3100042..ad6258a2017a 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;