From patchwork Sat Mar 9 10:31: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: 779511 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 597F3134BC for ; Sat, 9 Mar 2024 10:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980300; cv=none; b=JTLfwrtTLv9GCCnWi8A4mGiPMD5YhxFHxITSWhXrHRFvj4IGl+CjPnonDbxlt4LfVKFH+wcaM0taFDVWVRy6lstjnSgp51H1HL4chq4k/QLRgPITJ3YHEKfyFnOo3t4POZoev9AuDcqK4tE+8wFlGrRZ4ybBYMbytTcvUGcadnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980300; c=relaxed/simple; bh=dyCSthHHzXNg2FtPHnjXI29ZKEgPZ2Wv/z/Xo615dDI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BnK9Kqbs9cEkdwGuDP3tN1qYLYZ0w0SSPnria04baxtTEyjh34ADkuAnLP6N9kGo3qPNdMZBoshLvmdpmrzjyjSqUDOw6QXu0z2ak8vwJC1KL+ljeYCZz4jBWop1Qy3kIt4liwVxaiG06JzRQ0sutVzuHwiZf/t5idtRO8e6YrE= 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=ceQgNIbQ; arc=none smtp.client-ip=209.85.208.176 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="ceQgNIbQ" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2d269b2ff48so42529391fa.3 for ; Sat, 09 Mar 2024 02:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709980296; x=1710585096; 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=n2dgZRE3P9NOEAlgbf/KlOXvvwjZtbyPVzKly5b3fGk=; b=ceQgNIbQHbrK/kI11hXh4WyhLB4tJqWAa2fPP1YGiwNMWrgUNs+UJbCZltUTuvqjAM r9pWuSnMjUGm982l7vt/z4aEwZRRVZ1nLgJM7+ZeY/9KY4IAgJhcyfrrnyCh27VI2Jqh g/HqXkDLuz53jvLOZwz9mK5xY8YDm1ooiHuaC/onv2egI6l3/u8BZHAYNBoWSgoJTawx uq65UpXESM9m32JeOP4UssF/i7R3XESZg+21BoOFG2x1Asm55DaiTYyjQuwLDb0+LzCk inbm1anRoLuv6YDM2cQSNIZk4xkicLqAdclxuooRyid6ydxZcf+8UzRPfhOhPYrS/6CO Fi1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709980296; x=1710585096; 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=n2dgZRE3P9NOEAlgbf/KlOXvvwjZtbyPVzKly5b3fGk=; b=rLUhByJgQ6OyfrUGqLkHujh9EgC5aMuTJ7jOYol0pTMytB3GgCGAsLnb0b73M+EFDV hNjmF5NmsMMsO1e9W7dAZSEjdlge38vBRRUiZMkgLcBSW/0bqwzuj95TvvfIiD9e9ch6 YlXgI7u4EoG3ctNegLnVGcqeIEajfbsrBuF7PkTA7NCLeDu073pKyKbPxroLIAvrzdLf aGfWebRva2NlTfuaOW2qpiqV5+O/s0lymJOg3qdeIrbkval3prD1uz4dsuZMj3gRztWi f/DiYSjTdDDuXOKIdUK21Y+qUzZUdFzO6zjCBhB2+d7L/UPEC4MrA1KHokXv3QzpiYT6 onxg== X-Forwarded-Encrypted: i=1; AJvYcCV5xSP5qhPjyT0RM5JUjeD/5MXe7rzn0TESJNYRnXyjQkn3Jd3mneQk5vXm6B150RhM3PXBsJqL+mFya30LQrqByRUOFV/O+Wav/uM5EA== X-Gm-Message-State: AOJu0Yxl8WjfL7Je5uapYEM0cPGE0g1BvBG1m1lOy2Oe5Uvj+uhk9Fha cz+NtBvd6DieoiDfg+I54QZ5uYfpLQlKizH3N+TF7dwP+SdPGk02AEOTYCyl774= X-Google-Smtp-Source: AGHT+IEWta587d42WaCMYz46CSqPTHmEYD0eNxzIJJaMFlLh0oXM0SDdOGUY4Uh4KVlxx8+DOKsBNg== X-Received: by 2002:a2e:b609:0:b0:2d3:25d1:f33 with SMTP id r9-20020a2eb609000000b002d325d10f33mr887304ljn.15.1709980296358; Sat, 09 Mar 2024 02:31:36 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id y5-20020a2e3205000000b002d31953bc30sm245301ljy.55.2024.03.09.02.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 02:31:35 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 09 Mar 2024 12:31:28 +0200 Subject: [PATCH RFC v2 1/5] drm/connector: hdmi: fix Infoframes generation Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240309-bridge-hdmi-connector-v2-1-1380bea3ee70@linaro.org> References: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@linaro.org> In-Reply-To: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@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, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2340; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=dyCSthHHzXNg2FtPHnjXI29ZKEgPZ2Wv/z/Xo615dDI=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ+obq9bLzqLR2wPVZL8XtPe83J2Xlj+X83NNpbvWxSbez htFLBc6GY1ZGBi5GGTFFFl8ClqmxmxKDvuwY2o9zCBWJpApDFycAjCRDxzs/71DpZ73B+huV++p E+W3yNPIvsEtfJHh/sP0cz/yC7LL5h9LNnjmU7DsRk3c21kccYy96ge6N56+vu6u66tp+e17b8U m9h+/e7hFvcitR/jM56A/Una9h8/zGF1x7NVbscY63CTp5CHWhpjsuz98P8e827LEVc+yT6hZ5w XPnUxN1/OuptKPV1ze4xcU3rX5inmrBb/qCoMQyxVTNbrjbl/7OTXrqG/zhVLTW/tfP44wcqyxP 673r3CyxsTZr5/tfz45w2q+banGTq/y4NWce1q470rnxn7j8djGsGOZW97p3bVbmR30vzwJOGAe 6a6y3qhVr+qptVFr0PTH7xncHrbxyz0+IXF52x1Bo8r1AA== X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Gate only HDMI Vendor Infoframe generation on the info->has_hdmi_infoframe. All other infoframes were defined in earlier HDMI specs and should be generated by default. Fixes: 000000000000 ("drm/connector: hdmi: Add Infoframes generation") Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_atomic_state_helper.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index 46d9fd2ea8fa..691efce9661a 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -1025,9 +1025,6 @@ hdmi_generate_infoframes(const struct drm_connector *connector, if (!info->is_hdmi) return 0; - if (!info->has_hdmi_infoframe) - return 0; - ret = hdmi_generate_avi_infoframe(connector, state); if (ret) return ret; @@ -1045,9 +1042,11 @@ hdmi_generate_infoframes(const struct drm_connector *connector, if (ret) return ret; - ret = hdmi_generate_hdmi_vendor_infoframe(connector, state); - if (ret) - return ret; + if (info->has_hdmi_infoframe) { + ret = hdmi_generate_hdmi_vendor_infoframe(connector, state); + if (ret) + return ret; + } return 0; } @@ -1208,9 +1207,6 @@ int drm_atomic_helper_connector_hdmi_update_infoframes(struct drm_connector *con if (!info->is_hdmi) return 0; - if (!info->has_hdmi_infoframe) - return 0; - mutex_lock(&connector->hdmi.infoframes.lock); ret = UPDATE_INFOFRAME(connector, old_state, new_state, avi); @@ -1233,9 +1229,11 @@ int drm_atomic_helper_connector_hdmi_update_infoframes(struct drm_connector *con if (ret) goto out; - ret = UPDATE_INFOFRAME(connector, old_state, new_state, hdmi); - if (ret) - goto out; + if (info->has_hdmi_infoframe) { + ret = UPDATE_INFOFRAME(connector, old_state, new_state, hdmi); + if (ret) + goto out; + } out: mutex_unlock(&connector->hdmi.infoframes.lock); @@ -1269,9 +1267,6 @@ drm_atomic_helper_connector_hdmi_update_audio_infoframe(struct drm_connector *co if (!info->is_hdmi) return 0; - if (!info->has_hdmi_infoframe) - return 0; - memcpy(&infoframe.data, frame, sizeof(infoframe.data)); infoframe.set = true; From patchwork Sat Mar 9 10:31: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: 779217 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 EFE9F1D69E for ; Sat, 9 Mar 2024 10:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980300; cv=none; b=mpLbklc7dHo7XGZk9fhmCcvD2zwmK1y3p3T0gm05JvwWB7SkDrlKBBCYdk5M9S6lFI3JSe21pFO3Iidok0zC/RMVD4HNQ3kYTNJTk7MesFwrh6XDQMmMVBwp1w+7lYMk5LxYfuIgtdJG/J/6r67M5CXyCK/qVbosAX6U2LOzgdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980300; c=relaxed/simple; bh=TOTF8wEm+pn2aC2XeccwUCkVYk78cnNW5mkygODDCJU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g3YI2ZDfhIkBJw9gUlkKpoDJOoK+73OD1V/IPVvEotsStkCAkiPmrxMWi9/mjfBFWj95snFc03SZaZPoR//Qcpl/IABBwG26g2pLGgVLtJ4K/NXCM4RFqyuxksQIUo+W0IEF7Totyg3Sa6KMg7YtG/wuqUmLsgScBDTDPcYiWps= 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=xDzvyIAa; arc=none smtp.client-ip=209.85.208.181 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="xDzvyIAa" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d21cdbc85bso39130371fa.2 for ; Sat, 09 Mar 2024 02:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709980297; x=1710585097; 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=hyi2QAnNjyFXYN+N8eHamuXjGZsyue9nPfokclWOSHQ=; b=xDzvyIAa+Bp3qYxR/QQcK/6Wu3y3fttaZflja8xkdBDRvNpynTVuTDVY46JBvz8lhP WOIxufR0EPYcaZqpKHLKJAmTv7dOEZ+SpO8DdJG5UNElsegoOt0Mjd/7a1TyheNigz5Z bEGa8We5gELj4GMSXQbUN35UchL9k5D2Kv2S2dBiph/CcM8rjnK7SsgRruz7jdnAXtMx XBnqe0bONa4F+Ru/7qFpwVTgGfUEtkwcTQqKn6/sTBHw0dxRRdSAEN8DqCM1uFh1z026 LOkKwJGsPlo1yXdFotvzJLUEdLH3CYmuzTPK24o6b341HouRBJm4NxsJaSG75ch+QE4N 2yCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709980297; x=1710585097; 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=hyi2QAnNjyFXYN+N8eHamuXjGZsyue9nPfokclWOSHQ=; b=jOXjf48RCDGhnrk2bLd93kvL9n8PaTMFOnt2vQKKVmUS1GB0D1g4MwFLrdENglfQkc wFcpT/s0i0r26zVMjDDWYfwKtAJ4nIVk5nneZLWMCsj04qV6+keoicb3Oly3CFPxwVmP pj8yw2TEJuRGgXGSfCZV+QDkGd0WLcRnEMLurO7SxSJGyf6QgTK8SAB3sApxqA/Dn+Cx cRVQA22Go+eHSAWlMFhp/NMSRTzobkV4li/MIjC7pI1G37uh2+Su90OTP4BgHbIt1RBK c8gknquLmEF5top1mFlaMDyatAEOo4TUKYjp/jbgVsaY7prB8gwQZiJLvfoErSXyVmqE 09Iw== X-Forwarded-Encrypted: i=1; AJvYcCVHtLeXqHiw0Q/pOrfz1PF1q8wlZ40FuKzWLWrsm7j0jarAot4c9+TC+vo7Jjxr1cllZzkN1jqclE/k8GMld3iDo5OUgv8M2BAlRmML1w== X-Gm-Message-State: AOJu0YzzRH1cIa1IDvKHap+FffKjeyHfldUbs5770rb/RlgAPRDiCj8K 2LpSuBOSZrbUH/+/yxMrhd02jNrQyG1P+DgrGC1xL88pS3qYFZLozupA1OqSQVA= X-Google-Smtp-Source: AGHT+IH0wB7tIe5qs41vlrt+Gu8llz2cUWH9bjqPwDCtDbfZ2V7QVdE0L+S1IuYPpbgE54ngituFNA== X-Received: by 2002:a2e:3314:0:b0:2d4:236e:4026 with SMTP id d20-20020a2e3314000000b002d4236e4026mr871679ljc.53.1709980297147; Sat, 09 Mar 2024 02:31:37 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id y5-20020a2e3205000000b002d31953bc30sm245301ljy.55.2024.03.09.02.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 02:31:36 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 09 Mar 2024 12:31:29 +0200 Subject: [PATCH RFC v2 2/5] drm/connector: hdmi: add drm_connector_hdmi_init Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240309-bridge-hdmi-connector-v2-2-1380bea3ee70@linaro.org> References: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@linaro.org> In-Reply-To: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@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, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7655; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=TOTF8wEm+pn2aC2XeccwUCkVYk78cnNW5mkygODDCJU=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBl7DqFwlNpVVpgyKST97JjgY7ycbVtY/HwH8O8O fsDOx2EETGJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZew6hQAKCRCLPIo+Aiko 1QehB/9qQF3yZRna6aS+Bm9dZO43L79j4oI1UnT8UGU2P9RYLYDBzofqZidQXbWLfxbc8srIm0l aW4iJ0EGqPPxDvzmMQPKu5gTVtau5T2g9jTJt3k+Rgr510huIZspPcT65ODwWwI/5rYbbTOUlib XIVfx/J0w3j75A+VYbNS/Mubn334+h+9Jyvm6SCACNWfV+hOzn0qNiObjsjVgFneM6x7Qukkv7P 4fbHD8x41HvyLYc5TSWhCMSicRzI1Pp98ToEz8tpyetEe4/rAAILNWuNtmCwIMmF813ozklFpRU YpKZ7BXl8LIF5v88NPHoG5/NmxjrgNsa4V/7GkW+AUPRugs+ X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A To support connectors which do all the management on their own (like drm_bridge_connector), add drm_connector_hdmi_init() in addition to drmm_connector_hdmi_init(). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/drm_connector.c | 143 ++++++++++++++++++++++++++++++---------- include/drm/drm_connector.h | 9 +++ 2 files changed, 118 insertions(+), 34 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 427816239038..d7c0e237f9c5 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -453,39 +453,15 @@ int drmm_connector_init(struct drm_device *dev, } EXPORT_SYMBOL(drmm_connector_init); -/** - * drmm_connector_hdmi_init - Init a preallocated HDMI connector - * @dev: DRM device - * @connector: A pointer to the HDMI connector to init - * @vendor: HDMI Controller Vendor name - * @product: HDMI Controller Product name - * @funcs: callbacks for this connector - * @hdmi_funcs: HDMI-related callbacks for this connector - * @connector_type: user visible type of the connector - * @ddc: optional pointer to the associated ddc adapter - * @supported_formats: Bitmask of @hdmi_colorspace listing supported output formats - * @max_bpc: Maximum bits per char the HDMI connector supports - * - * Initialises a preallocated HDMI connector. Connectors can be - * subclassed as part of driver connector objects. - * - * Cleanup is automatically handled with a call to - * drm_connector_cleanup() in a DRM-managed action. - * - * The connector structure should be allocated with drmm_kzalloc(). - * - * Returns: - * Zero on success, error code on failure. - */ -int drmm_connector_hdmi_init(struct drm_device *dev, - struct drm_connector *connector, - const char *vendor, const char *product, - const struct drm_connector_funcs *funcs, - const struct drm_connector_hdmi_funcs *hdmi_funcs, - int connector_type, - struct i2c_adapter *ddc, - unsigned long supported_formats, - unsigned int max_bpc) +static int __drm_connector_hdmi_init(struct drm_device *dev, + struct drm_connector *connector, + const char *vendor, const char *product, + const struct drm_connector_funcs *funcs, + const struct drm_connector_hdmi_funcs *hdmi_funcs, + int connector_type, + struct i2c_adapter *ddc, + unsigned long supported_formats, + unsigned int max_bpc) { int ret; @@ -506,7 +482,7 @@ int drmm_connector_hdmi_init(struct drm_device *dev, if (!(max_bpc == 8 || max_bpc == 10 || max_bpc == 12)) return -EINVAL; - ret = drmm_connector_init(dev, connector, funcs, connector_type, ddc); + ret = __drm_connector_init(dev, connector, funcs, connector_type, ddc); if (ret) return ret; @@ -531,6 +507,105 @@ int drmm_connector_hdmi_init(struct drm_device *dev, return 0; } + +/** + * drm_connector_hdmi_init - Init a preallocated HDMI connector + * @dev: DRM device + * @connector: A pointer to the HDMI connector to init + * @vendor: HDMI Controller Vendor name + * @product: HDMI Controller Product name + * @funcs: callbacks for this connector + * @hdmi_funcs: HDMI-related callbacks for this connector + * @connector_type: user visible type of the connector + * @ddc: optional pointer to the associated ddc adapter + * @supported_formats: Bitmask of @hdmi_colorspace listing supported output formats + * @max_bpc: Maximum bits per char the HDMI connector supports + * + * Initialises a preallocated HDMI connector. Connectors can be + * subclassed as part of driver connector objects. + * + * At driver unload time the driver's &drm_connector_funcs.destroy hook + * should call drm_connector_cleanup() and free the connector structure. + * The connector structure should not be allocated with devm_kzalloc(). + * + * Note: consider using drmm_connector_hdmi_init() instead of + * drm_connector_hdmi_init() to let the DRM managed resource infrastructure + * take care of cleanup and deallocation. + * + * Returns: + * Zero on success, error code on failure. + */ +int drm_connector_hdmi_init(struct drm_device *dev, + struct drm_connector *connector, + const char *vendor, const char *product, + const struct drm_connector_funcs *funcs, + const struct drm_connector_hdmi_funcs *hdmi_funcs, + int connector_type, + struct i2c_adapter *ddc, + unsigned long supported_formats, + unsigned int max_bpc) +{ + if (drm_WARN_ON(dev, !(funcs && funcs->destroy))) + return -EINVAL; + + return __drm_connector_hdmi_init(dev, connector, vendor, product, + funcs, hdmi_funcs, connector_type, ddc, + supported_formats, max_bpc); +} +EXPORT_SYMBOL(drm_connector_hdmi_init); + +/** + * drmm_connector_hdmi_init - Init a preallocated HDMI connector + * @dev: DRM device + * @connector: A pointer to the HDMI connector to init + * @vendor: HDMI Controller Vendor name + * @product: HDMI Controller Product name + * @funcs: callbacks for this connector + * @hdmi_funcs: HDMI-related callbacks for this connector + * @connector_type: user visible type of the connector + * @ddc: optional pointer to the associated ddc adapter + * @supported_formats: Bitmask of @hdmi_colorspace listing supported output formats + * @max_bpc: Maximum bits per char the HDMI connector supports + * + * Initialises a preallocated HDMI connector. Connectors can be + * subclassed as part of driver connector objects. + * + * Cleanup is automatically handled with a call to + * drm_connector_cleanup() in a DRM-managed action. + * + * The connector structure should be allocated with drmm_kzalloc(). + * + * Returns: + * Zero on success, error code on failure. + */ +int drmm_connector_hdmi_init(struct drm_device *dev, + struct drm_connector *connector, + const char *vendor, const char *product, + const struct drm_connector_funcs *funcs, + const struct drm_connector_hdmi_funcs *hdmi_funcs, + int connector_type, + struct i2c_adapter *ddc, + unsigned long supported_formats, + unsigned int max_bpc) +{ + int ret; + + if (drm_WARN_ON(dev, funcs && funcs->destroy)) + return -EINVAL; + + ret = __drm_connector_hdmi_init(dev, connector, vendor, product, + funcs, hdmi_funcs, connector_type, ddc, + supported_formats, max_bpc); + if (ret) + return ret; + + ret = drmm_add_action_or_reset(dev, drm_connector_cleanup_action, + connector); + if (ret) + return ret; + + return 0; +} EXPORT_SYMBOL(drmm_connector_hdmi_init); /** diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 5964ef283022..a97de8255e04 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -2147,6 +2147,15 @@ int drmm_connector_init(struct drm_device *dev, const struct drm_connector_funcs *funcs, int connector_type, struct i2c_adapter *ddc); +int drm_connector_hdmi_init(struct drm_device *dev, + struct drm_connector *connector, + const char *vendor, const char *product, + const struct drm_connector_funcs *funcs, + const struct drm_connector_hdmi_funcs *hdmi_funcs, + int connector_type, + struct i2c_adapter *ddc, + unsigned long supported_formats, + unsigned int max_bpc); int drmm_connector_hdmi_init(struct drm_device *dev, struct drm_connector *connector, const char *vendor, const char *product, From patchwork Sat Mar 9 10:31: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: 779510 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 0520E5C8B for ; Sat, 9 Mar 2024 10:31:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980302; cv=none; b=CwobkQHHfXub5ym2zZ2BH29shF5wsV5yvOVnFwgkh6YkwBX3o676HKl2K9BeNdv975zIwD8Rt/J3uXONLmLsAgr2P6ktWiV5k4F6jUSMdMYPX9qmzJcA59rd8iI0WnesywdaMJu/GobrjSu39nArw0wCTHyHVZleDqRPhk/m9w0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980302; c=relaxed/simple; bh=kABJHt3RkZZjsjZbUvVv96tWTAHBfq9FCIJhBeojd+4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=e4x0Sjvc8x9VbRU3itPWuvBazREzPxcmHL7n/D8UPr0+YT1bqnR8YcpWxPUzX0vnTrR7te0kSFUjtSo43tw0phyDTszkx01FtgIVncE5qsXyvMTPhvdfCGPkEo0uDGFyyrHghAY7TrEOU/3skPdUi2DwoFeVfRuztBZwybViqpY= 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=s3on1tmD; arc=none smtp.client-ip=209.85.208.171 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="s3on1tmD" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2d220e39907so42920761fa.1 for ; Sat, 09 Mar 2024 02:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709980298; x=1710585098; 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=/gKCRuHfTeAAN6eYp0daDO9DyP00Nw++DM0spECkWyc=; b=s3on1tmDr8ixJPTLyuihCZNTopOlr4FYcoS+vscVMhqXZx2SJnkk4cJR5gkIURDv/v Y5gKW9BrKpwwohnhiuU6MA9wfyrtQ2Xm+mIy0kcR2+Sxwe7kzRaWYu3KFomepyir6mKT tNftsOHfpohbSEyyRsdPkYSmyqE0lvFtwX4xVZwAdBuuwnXUcz58dZoF/DNeSg4bqhBs 4uC62cMTJhqilIIppKxcoQ1sT62QYb+s2+6C5vxE31sesoERoDI8raupVJ4kDCvbu2oS CJ6sMBgPMxiaWkEec3xE8zZSdEiUiwZy6gtDXt2x8gL/+u4DigPyc4h6B5QOaAqGGPPp iE2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709980298; x=1710585098; 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=/gKCRuHfTeAAN6eYp0daDO9DyP00Nw++DM0spECkWyc=; b=Lm80eMs18c4+s2Y3cKmipLx6VM21v1kt7UTcE/h3vbEIi+zu4BZfRE+BAXtX+9QNXb iOZuu5xBvLvg2/SIpGTh5v5C+cF+lDE4363auOYPj4/tqKbCZmkhaEQdqPbpGtlwtrNg +kqJTYkFf8dzQhFR7d65xWcCzZbwDqSaQ+cbJDRGzzzZAviGUcKTEhHWriF8eBhUZ3M6 n92vEJpCtFni32vWCIpg4waOoezFbuD4mfDsRrC9dHrYP09tetvheSj5OZQuDH+MvMQm 6vP7ESBL9ON/K2Cqc4Y5mSVONa8/at3kMWuHfJ/xGL5ocSe148kVn9J4TYB0zrNurMr+ 438g== X-Forwarded-Encrypted: i=1; AJvYcCV8ovjsYSIyDCwDFnbUt2uWZ55K6mZol2nh/m4lKjaYbK14hPpvclO3jekKK96IHX9qDH15ICFN3PZ8mP/xipmvVAOXrFKu4EyNULOYVA== X-Gm-Message-State: AOJu0YwXG+RYIPsY2Nvs5TuZWKgpmdxqzkftgLfN0s689p+iYEMwbMCX CETnfBH5izOkcRT0zT4Wo92xFyo9qQfNRlUHPu88cJNtroximBBJcbyEjD7/Ccc= X-Google-Smtp-Source: AGHT+IFAeh7KMVDugqewP6Hm8fZs7sNjILj2gnOP3VJmIZIk48bVzJBy/qeUGzU7+NB6uljOxaltIQ== X-Received: by 2002:a2e:9043:0:b0:2d2:8ad9:a667 with SMTP id n3-20020a2e9043000000b002d28ad9a667mr1085321ljg.17.1709980298244; Sat, 09 Mar 2024 02:31:38 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id y5-20020a2e3205000000b002d31953bc30sm245301ljy.55.2024.03.09.02.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 02:31:37 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 09 Mar 2024 12:31:30 +0200 Subject: [PATCH RFC v2 3/5] 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: <20240309-bridge-hdmi-connector-v2-3-1380bea3ee70@linaro.org> References: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@linaro.org> In-Reply-To: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@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, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9464; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=kABJHt3RkZZjsjZbUvVv96tWTAHBfq9FCIJhBeojd+4=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ+obq9amHD3mzdPeWXB8WcCrffVmKneGJaPljf3SQscn9 jyezJXYyWjMwsDIxSArpsjiU9AyNWZTctiHHVPrYQaxMoFMYeDiFICJLFFj/1/1dLI+i9581RaB Ypuc9z7X3wetEv6zq/Xm3Onu4QV72QKuyy05pDF3Tq5zzFuDawsyZR3vb2G8I/r8jqDivGO/182 6FT/dVOLKdY2YrpM6cy32N6Y+PbleWDZi6or+x8qzrEvlck8eqNL6rvtbc/GTY00LApL2qXBEM8 yeG3vIWPNy5ZGKuIcc//o2nI09rN6Volxb6SzIfoNjg6qOKONOJXHDD15L2dPaw0JvMrJn54nuM nEsbGH5paFyQvHr0bncTWwRstM1z5tuDXIKVdo28/0ZaaHSO7Uds2J4VKq067x15CbZ8ipUeT8+ FZ3urSS5jNNPbMeklh+xd/0fqD8zfBQR1PZko1si/zlmAA== 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 | 118 ++++++++++++++++++++++++++++++++- include/drm/drm_bridge.h | 82 +++++++++++++++++++++++ 2 files changed, 197 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge_connector.c b/drivers/gpu/drm/drm_bridge_connector.c index 982552c9f92c..514dbb38dfed 100644 --- a/drivers/gpu/drm/drm_bridge_connector.c +++ b/drivers/gpu/drm/drm_bridge_connector.c @@ -86,6 +86,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) \ @@ -293,11 +300,86 @@ static int drm_bridge_connector_get_modes(struct drm_connector *connector) return 0; } +static int drm_bridge_connector_atomic_check(struct drm_connector *connector, + struct drm_atomic_state *state) +{ + struct drm_bridge_connector *bridge_connector = + to_drm_bridge_connector(connector); + struct drm_bridge *bridge; + int ret; + + bridge = bridge_connector->bridge_hdmi; + if (bridge) { + ret = drm_atomic_helper_connector_hdmi_check(connector, state); + + if (ret) + return ret; + } + + return 0; +} + static const struct drm_connector_helper_funcs drm_bridge_connector_helper_funcs = { .get_modes = drm_bridge_connector_get_modes, /* No need for .mode_valid(), the bridges are checked by the core. */ .enable_hpd = drm_bridge_connector_enable_hpd, .disable_hpd = drm_bridge_connector_disable_hpd, + .atomic_check = drm_bridge_connector_atomic_check, +}; + +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 bridge->funcs->tmds_char_rate_valid ? + bridge->funcs->tmds_char_rate_valid(bridge, mode, tmds_rate) : + MODE_OK; + + return MODE_ERROR; +} + +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 bridge->funcs->clear_infoframe ? + bridge->funcs->clear_infoframe(bridge, type) : + 0; + + return -EINVAL; +} + +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 bridge->funcs->write_infoframe(bridge, type, buffer, len); + + return -EINVAL; +} + +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, }; /* ----------------------------------------------------------------------------- @@ -325,6 +407,10 @@ 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; + const char *vendor = "Unknown"; + const char *product = "Unknown"; + unsigned int supported_formats = BIT(HDMI_COLORSPACE_RGB); + unsigned int max_bpc = 8; int connector_type; int ret; @@ -361,6 +447,23 @@ 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); + + bridge_connector->bridge_hdmi = bridge; + + if (bridge->supported_formats) + supported_formats = bridge->supported_formats; + if (bridge->max_bpc) + max_bpc = bridge->max_bpc; + } + + if (bridge->vendor) + vendor = bridge->vendor; + + if (bridge->product) + product = bridge->product; if (!drm_bridge_get_next_bridge(bridge)) connector_type = bridge->type; @@ -383,9 +486,18 @@ 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); + if (bridge_connector->bridge_hdmi) + ret = drm_connector_hdmi_init(drm, connector, + vendor, product, + &drm_bridge_connector_funcs, + &drm_bridge_connector_hdmi_funcs, + connector_type, ddc, + supported_formats, + max_bpc); + else + ret = drm_connector_init_with_ddc(drm, connector, + &drm_bridge_connector_funcs, + connector_type, ddc); if (ret) { kfree(bridge_connector); return ERR_PTR(ret); diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 3606e1a7f965..f44f32b182b8 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); + /** + * @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 + (*tmds_char_rate_valid)(const struct drm_bridge *bridge, + const struct drm_display_mode *mode, + unsigned long long tmds_rate); + + /** + * @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 (*clear_infoframe)(struct drm_bridge *bridge, + enum hdmi_infoframe_type type); + /** + * @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 (*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,30 @@ struct drm_bridge { * @hpd_cb. */ void *hpd_data; + + /** + * @vendor: Vendor of the product to be used for the SPD InfoFrame + * generation. + */ + const char *vendor; + + /** + * @product: Name of the product to be used for the SPD InfoFrame + * generation. + */ + 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. This is + * only relevant if @DRM_BRIDGE_OP_HDMI is set. + */ + unsigned int max_bpc; }; static inline struct drm_bridge * From patchwork Sat Mar 9 10:31: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: 779216 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 C1567134BC for ; Sat, 9 Mar 2024 10:31:40 +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=1709980302; cv=none; b=cKT2EmRPSBinoQDG/igp6j8/1cWdg5kjzU9HxA3m5rax5vmT78zllB2FCL1Th0x+P6mbKy9rYki4yuQLLv5CMwrwbxAtQwRd2xcy+dHXvgeRoqYSE/J/a2ER/OzOfyaFO8UQg+/+yP924xmDUJbMmzQVUm5B6UPyNHaMzFBH6/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980302; c=relaxed/simple; bh=BLTMrmfRiYz+a4tS74ezbT2hZO40I+AiAHfNW/m4HPQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t0jaOFSaSpG5y8vJFBKa4l4yZTmOYSUb71Mmqfzx4eRB7BzdMnkSBrk1drOGbQ/lUgvu8a8eJ6fcGDEhwc5AV5sK8omyZKc6ZDQMU6a9V5XE0fH4mYRGesNv2GVjxeoQlj2tOESUH9fFXoYM/3l1qOYOxi9Rj5x//k3IOshSdl0= 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=Tu1gU/CP; 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="Tu1gU/CP" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2d2505352e6so38741691fa.3 for ; Sat, 09 Mar 2024 02:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709980299; x=1710585099; 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=oSCLgDYohNznRCwnS8tfo5EB4gMkp+kuVZWS1xIx1Q0=; b=Tu1gU/CP4V/fydl+hJCxVU3w2QcibdQtSai0raJDsvuUeOLcQAAY383qAHtvgvlTqH wYiLWBjddQ6KCAsQbAO6c0eIhzVCOPFeal4l/sOTn+XXw/s1C1umVJiu1YAMKiiT+DEP Ouv5DWmAWF6NZQW47/Ul49j8jV9b0E63lkbYvzGih2mTiygRVKST6vSahl+M1TZT3Sol ApxkT4pp69dE7C35JXgfxc+IF7Y5ATnOlloUNI6EexFTtasJaAQ6K7KCDurmxqKv9i8g WTeAfIUBdt4nSIJUuRKqDy5UqUzQP3QGTUymmwg4luJlePEpJd+1SdtHnsRsO+dDl+JF ONpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709980299; x=1710585099; 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=oSCLgDYohNznRCwnS8tfo5EB4gMkp+kuVZWS1xIx1Q0=; b=TatijOczE9QJ05RoM8gccqGVSgTm85h6HO6Kdm+H9nW7mwHh8hWN09uup4jgXErMU7 lzRmHFOoMNhj/PCOC+QVZ7QbjavrU2WM5J1phsq3ipFH0gZBlKYnnMW48AotXf5VvSne 7LsHBtEgQfh8iFlVY9fP8LyASrMllayoN9mUELdhTPE19Scx/uEgPsO0P4nsQAU07uAJ JVGGd2AW/kcu+sqBKs8GNuv6iGpqDfnoYOyCdOU9sNhKQYCZoL5yaHf4Rc4FMOH5t1CO GKvnTfcNE4BUwaeaVJvouKxyND8W8QDX2mchBfmUq0uG6uO8jcAlfBjVADFOvIi3XTJz aMjw== X-Forwarded-Encrypted: i=1; AJvYcCVikXw8Q343AY5IO1b04PP2bqZJ3M75tJE0iI243Ns8FpypMoo45RPPFDPMy0YCE6MlDUYD/BfLxUImsEJyVX0z462dICXG2zNKkBe6qg== X-Gm-Message-State: AOJu0YxvLXWwSgvZiqhOlgBZBOhhLGaXPTTYetglwIBNmRx/kB8Trejw VOoVR5hnIw1D8p5nvhU+TghHFB7FYct/xnhE2a7hRCZ7p5eiW8v9GUwxvh129ZM= X-Google-Smtp-Source: AGHT+IFYa94bngGFzQOCUhe0OG7K+D07/qG54fBuSnLETIBSl6pH9ixQUJZwS83iaWnnsgmtLotQcA== X-Received: by 2002:a2e:9dc3:0:b0:2d4:299c:cebb with SMTP id x3-20020a2e9dc3000000b002d4299ccebbmr712199ljj.47.1709980299060; Sat, 09 Mar 2024 02:31:39 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id y5-20020a2e3205000000b002d31953bc30sm245301ljy.55.2024.03.09.02.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 02:31:38 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 09 Mar 2024 12:31:31 +0200 Subject: [PATCH RFC v2 4/5] 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: <20240309-bridge-hdmi-connector-v2-4-1380bea3ee70@linaro.org> References: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@linaro.org> In-Reply-To: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@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, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2124; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=BLTMrmfRiYz+a4tS74ezbT2hZO40I+AiAHfNW/m4HPQ=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBl7DqGE6KpSJMtgdjFpsRWlaeLRIWqF1vIFOcRN I9e4hcazsSJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZew6hgAKCRCLPIo+Aiko 1cVSB/9Rj3Ikfz0XPJS6p4SkADr8C8YFbP7BIYx7v/y/yt7rd88LFwx74uNziqmBM7gRTPe6NH/ wwp3QcXhEjaF9Nhi2trwz+5nNKE9l2V/ido9ESa48WyYEwW580ws8hyhbR6HTLJ4KEvzbwCyg9C zO68Z6uqN2eo4112kJfHqc7e148nAqQJrIAvveh9147FipL1g2NvVKQW2y48TF9Brdesi3MXR1g zTUePwAcG4q8B1wQGSUH+Xanpw8YcIy/x4XdF99K0gE89Dsglko3gy3HdGOFLtbSS9fONuqC3vZ pDcoj1ti8obYPA8UaWsG3iJ72vKeYDXtPRUgGgFlRhTSAcap 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. 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 Sat Mar 9 10:31: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: 779509 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 96EB31D69E for ; Sat, 9 Mar 2024 10:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980303; cv=none; b=H6uvqnqWvcg4IdYljZVtHszE7i/D38tFiaSXGKD6bh10NYKT2AIpDWnex5o3DpLh43xrKCYeI8G1X3I0FMpnYo43PmHsQUDDfz2Tv7JB4+Bwm0IIGv+Bp64nqspgp0UBCcGZOKbaEvQXuA64Lmbg/F6CpWEZUl/fEGQjHFRswVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709980303; c=relaxed/simple; bh=7zA/N8KAt1DsVzqE/w0UCroDP54Ugww4O7l/KrsTO+o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aBPn04ghCJsC7QMfMBN0N7oXbYsUQtZnhp5l7yZwMVxauyfRcT8r+ZBue64jYdoxUBXZZMGUxcYrve1acGAQIcTIFEv2q1JdzmXNbbXaGafMa/ovP/12oKCpn2PvUd+BSLQEvMmgQBdogpDrn0qlt7aZPlkfg3ETA9J+oRccZvg= 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=gmX26m1w; arc=none smtp.client-ip=209.85.208.173 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="gmX26m1w" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2d28051376eso18109481fa.0 for ; Sat, 09 Mar 2024 02:31:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709980300; x=1710585100; 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=hVak1J+o3ONy3vnRUIeVq/ARZN3J0EKCCHw4ehmpquA=; b=gmX26m1wbQlPI6t+z7CTTlstFNQVu/NbDWFFpAojkdAExfp7r08Q9LGzSZuEHqr/jW KKJrfd/SwcD+R+msTl3YgGHGNyPxBWZx1oAi12pgSp2358Zz7LAE9vuhdAulK8ObRo+p UbWzuLX9oa5isW1oaoMoUlpoF0qD9jOzQ0RzBd2CeK9C1ZJIYXwJm1JWW7GLbs//CiPj GOQMi3Q9uLUCg9zFCOFdj7cMrCiu47i1+cc6eK5GiMyhcNBb0xpw/Mgku5WhTMK0QDey 0k1cghuH9BWrDOci4vwMjtM/AnIlkMssaz7h8gfrHOBrDF0VLR1kf69LgXeOt5fX7b7P w40w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709980300; x=1710585100; 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=hVak1J+o3ONy3vnRUIeVq/ARZN3J0EKCCHw4ehmpquA=; b=pxSWqgNc9PfARxTqALouciIUGke+TUAICenDCkhKZzaFY2IDkm2tz+NCmlKfGBngJQ 2AB4ayBvlXlJsXaNzyDvLw/bTRpM+erHgBVyGPyI353t2Y/dj7sf1fpC+Fdw0QZTTvtp X8y72edn7WWuN9kOFe+trjR4N11pbGnz8noi87GEKTBiz9NqbeFEQqb6ZGaW8BOHcrCP hZXkfKr5XXM1CN+n3z1YyaBjUhZvTtV3Jugg/kOhZXm/UCSbQ+D/AN/6F3DxaAZvtxMr pfopyg4vCoWqOQLI1t0YucuaUs9CtKzpEdv+ERHAmdSfcJ0aV1vxFgDS2h6mPbjuXzFQ bVeA== X-Forwarded-Encrypted: i=1; AJvYcCWs9zd2MPnupf358UfKeVRPM3yEJbfcO6FO+i3xHtHAJGZsFcSgFScpyxUGX8fcIUDwRtWKAxq3844Cnr1KkuO7gtCiXQsaS3BZn6OMsw== X-Gm-Message-State: AOJu0YwVbCPBnRBt90jgyzGXQxHhu7n1+uYbZAVnX4oGSmZ/0WZEUVe9 5fKZrKIuUR6WNE93nIR3kI3A6IXaj54o9+YUtWgJ7wwrn2xpXxSp/6yi87NVLQc= X-Google-Smtp-Source: AGHT+IHnYzJfbpL84RxZcdOa/oxj01C/8c/YNEBwKCgUivP4PqO5a9ifcxqYB4JLN1UpUrB8URx7HA== X-Received: by 2002:a2e:9644:0:b0:2d2:2cff:fc49 with SMTP id z4-20020a2e9644000000b002d22cfffc49mr1116763ljh.18.1709980299872; Sat, 09 Mar 2024 02:31:39 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id y5-20020a2e3205000000b002d31953bc30sm245301ljy.55.2024.03.09.02.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 02:31:39 -0800 (PST) From: Dmitry Baryshkov Date: Sat, 09 Mar 2024 12:31:32 +0200 Subject: [PATCH RFC v2 5/5] 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: <20240309-bridge-hdmi-connector-v2-5-1380bea3ee70@linaro.org> References: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@linaro.org> In-Reply-To: <20240309-bridge-hdmi-connector-v2-0-1380bea3ee70@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, Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5077; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=7zA/N8KAt1DsVzqE/w0UCroDP54Ugww4O7l/KrsTO+o=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBl7DqGKpmWQ7UnQyki0wyQsaptJlMWh9rU2kk5L aZGOtVRGdSJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZew6hgAKCRCLPIo+Aiko 1eIiCACmOhghs05XCA5tDfxfgOdmf3vaQaIYVk6LHpSFsRPOh1brfx5fXfxruxfRS7/nqN/sdC4 +mSDPvMUiRS6fn5GPl35BHtxA3MF4lMr2PoSfLDNv5zLPFXURvbZCjAT9Tv4nMUjvud62sP1P3n Ur2l6mXBmA6ktMBbsIp+1d2EvVVtj8avJEFK73UsgU4sO9vUnfjdhTcXjGJYZnADtTtu2DREHoy q2PfWlC9ZbpwvKx3E4FsMmURpf9Squ9UWXPKnzwfRBq4tOmEvkO5XrIHFiFHM8q9FNqsQUV8BBo LMqh7Kcck2nGQIXhzi0yr3/WPryuflywGqtWrF36c6vYrpG/ 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. Note: for now only AVI Infoframes are enabled. Audio Infoframes are currenly handled separately. This will be fixed for the final version. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 83 +++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c index d839c71091dc..26c847f42522 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_bridge.c @@ -68,23 +68,15 @@ 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 val; - int len; - 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)) { DRM_DEV_ERROR(&hdmi->pdev->dev, "failed to configure avi infoframe\n"); - return; + return -EINVAL; } /* @@ -124,6 +116,55 @@ static void msm_hdmi_config_avi_infoframe(struct hdmi *hdmi) 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_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_CTRL0); + + switch (type) { + case HDMI_INFOFRAME_TYPE_AVI: + val &= ~(HDMI_INFOFRAME_CTRL0_AVI_SEND | + HDMI_INFOFRAME_CTRL0_AVI_CONT); + break; + case HDMI_INFOFRAME_TYPE_AUDIO: + 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); + break; + default: + drm_dbg_driver(hdmi_bridge->base.dev, "Unsupported infoframe type %x\n", type); + } + + hdmi_write(hdmi, REG_HDMI_INFOFRAME_CTRL0, val); + + 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); + default: + drm_dbg_driver(hdmi_bridge->base.dev, "Unsupported infoframe type %x\n", type); + return 0; + } } static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, @@ -132,6 +173,10 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, 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_atomic_state *state = old_bridge_state->base.state; + struct drm_connector *connector = + drm_atomic_get_new_connector_for_encoder(state, encoder); DBG("power up"); @@ -139,12 +184,13 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge, 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); + + if (hdmi->hdmi_mode) + msm_hdmi_audio_update(hdmi); + msm_hdmi_phy_powerup(phy, hdmi->pixclock); msm_hdmi_set_mode(hdmi, true); @@ -310,6 +356,8 @@ static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = { .mode_valid = msm_hdmi_bridge_mode_valid, .edid_read = msm_hdmi_bridge_edid_read, .detect = msm_hdmi_bridge_detect, + .clear_infoframe = msm_hdmi_bridge_clear_infoframe, + .write_infoframe = msm_hdmi_bridge_write_infoframe, }; static void @@ -341,8 +389,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);