From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.11 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796048667; b=3gSNxmshAEIdRW/fI7KNawT2VAS+foVLRNSQ0TMebcBXN1zIkE+MPr+0XEVXdjlQBo24 oSi2GYlrV5GeaFTk6pD77Ku6dAIAK5pGHTLmb+r0E7oOIWO5+oOrJbqi1tCMt79smxwIm fxR9KtYspbK7T2olBNNSE3tTtqtbfh8DMQFArdA5r54KffcylljggP9e9cvy2zs7DoM7B +wTrEZLpIvb6fEZnCqCzG2Qo7PtDBzo+Qao/3OoDLHcDCj27iqmY0cq+XBTBane+IxtuL 8Bwv76woZ6C5mfwkurhSP3eOJxvd/cHb94FyiVnLB3Xt9DTVh/bYU5i5ZEPCeUtJPfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796048667; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=BejDXiQ5nBBJaMAFQdTClCKbcoNmFDfBZfFbukRXqas=; b=YdZIWJqwGRezM5gzdfiEnslQqD5BcWy3WufvowtDWEu+Nm4VLZjaQOd+g8C8zNvbyGU5 jgUFtAtxCdFXrB2KcwepZStqGUZq4n93L9tXUV5zMiXy8dx3s2hGmP15j1Qn/F4VruXNX Zec4PKsGHdtB4JMynMqt4/dq9FQJzQHJJT8zDwqH0zR8BvQWv6J2kYwO5LFAmUOFxONUH E8FRwUU026tOlfoWk0XCjCmR6sZ1hRCk3Riy8/Wa38LO7yf7tB2oyoy8nUEswAadEiaiU OKP/QX9UdFEPcKbihP8PG1pDVqMB4XHBlbf/24yXcMP6hih2PLFCfBKUb/4/e3505tg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=B+yyhsED; arc=none smtp.remote-ip=198.175.65.11 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0704B606A325; Mon, 30 Nov 2026 14:24:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0704B606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=B+yyhsED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796048667; x=1827584667; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BejDXiQ5nBBJaMAFQdTClCKbcoNmFDfBZfFbukRXqas=; b=B+yyhsEDep+7jEbkB83Q/i3/Xxh4GLSr6EKL8eWsWIS/pvILQM3pxRsQ iJuIOFha8kRk5JHcWZN/kglb7fl4mpK4qVT+7FN8phUSUWyJvvLeC7xAN n64fdGBz+worGTAv2kgKY9Um/n5vN/bMNvYBMGCoVC8u4oy0rQHUjDpJz lNZhT1IkDc3o6tgCS6gEGCgQM1HvLcYIlyKjmaVgii+yGYo2H6OE0Y+/Z Mn94FeqVc+lS8iDyxu9GTl7DLa13Dxnyqg3Gk15jrI7WjerikkL2CRKX0 jI2vzdWFc1sxggTfZTlKggXwQD5Wa0Irju/RTPmsI7rFFCOhXGW+f/DcW A==; X-CSE-ConnectionGUID: XI2Y4RVuT3KfOjhiBPrNpw== X-CSE-MsgGUID: dsrY2WMqQAuf3/pOY+Cdzw== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4769214" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4769214" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 06:24:20 -0800 X-CSE-ConnectionGUID: C+B8Hv8yT5+1Mn+9M6gmCQ== X-CSE-MsgGUID: Z9AGHLPvSwS6LqdgJzE4ew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="12943688" Received: from amilburn-desk.amilburn-desk (HELO kvehmane-desk1.ger.corp.intel.com) ([10.245.244.87]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 06:24:14 -0800 From: Kai Vehmanen To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: kai.vehmanen@linux.intel.com, Jani Nikula , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , Takashi Iwai , Jaroslav Kysela , linux-sound@vger.kernel.org, Harry Wentland , Leo Li , Alex Deucher , amd-gfx@lists.freedesktop.org, Lyude Paul , Danilo Krummrich , =?UTF-8?q?Tom=C3=A1=C5=A1=20Hnyk?= , Wim Taymans , nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, Takashi Iwai , Jani Nikula Subject: [PATCH v2 1/2] drm/eld: Add drm_eld_set_port_id() helper Date: Mon, 30 Nov 2026 16:23:51 +0200 Message-ID: <20261130142352.635531-2-kai.vehmanen@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261130142352.635531-1-kai.vehmanen@linux.intel.com> References: <20261130142352.635531-1-kai.vehmanen@linux.intel.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ELD baseline block reserves bytes 8..15 for a 64-bit Port_ID that identifies the source port of the audio endpoint. drm_edid_to_eld() leaves the field zero, and no driver fills it in, so it carries no information. When two identical monitors are connected, their ELDs are then byte-identical, and userspace has no passive way to tell which HDMI/DP PCM belongs to which DRM connector. The only workaround is to toggle the connector audio property and watch which ELD goes away, which disrupts the endpoint. Add a helper that drivers can use to fill in Port_ID with a common layout: bits 63:48 - PCI domain of the DRM device bits 47:32 - PCI bus/device/function of the DRM device bits 31:0 - DRM connector object ID Userspace can read the connector object ID directly from KMS, and the PCI address tells GPUs apart in multi-GPU systems. For non-PCI devices the upper half is left zero. The split between a 16-bit PCI BDF in the upper half and a per-device display identifier in the lower half follows the Port_ID layout documented for the AMD Azalia sink info registers in dce_audio.c. Reviewed-by: Ville Syrjälä Reviewed-by: Takashi Iwai Acked-by: Jani Nikula Signed-off-by: Kai Vehmanen --- drivers/gpu/drm/drm_eld.c | 42 +++++++++++++++++++++++++++++++++++++++ include/drm/drm_eld.h | 3 +++ 2 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/drm_eld.c b/drivers/gpu/drm/drm_eld.c index c0428d07de53..baebece7b4ed 100644 --- a/drivers/gpu/drm/drm_eld.c +++ b/drivers/gpu/drm/drm_eld.c @@ -4,7 +4,11 @@ */ #include +#include +#include +#include +#include #include #include @@ -55,3 +59,41 @@ int drm_eld_sad_set(u8 *eld, int sad_index, const struct cea_sad *cta_sad) return 0; } EXPORT_SYMBOL(drm_eld_sad_set); + +/** + * drm_eld_set_port_id - set the ELD Port_ID for a connector + * @eld: ELD buffer + * @connector: connector the ELD belongs to + * + * drm_edid_to_eld() leaves the 64-bit Port_ID field of the ELD baseline + * block zero. Drivers can use this helper to fill it in with a value + * that identifies the audio endpoint, so that userspace can associate an + * ELD, and the PCM device it belongs to, with a DRM connector, even when + * identical sinks are connected to multiple outputs. + * + * The Port_ID is stored in little-endian byte order, with the layout: + * + * - bits 63:48 - PCI domain of the DRM device, truncated to 16 bits + * - bits 47:32 - PCI bus/device/function of the DRM device + * - bits 31:0 - DRM connector object ID + * + * For non-PCI devices bits 63:32 are zero. + * + * The connector object ID is only stable for the lifetime of the + * connector, so userspace must look it up at runtime, and not store it. + */ +void drm_eld_set_port_id(u8 *eld, const struct drm_connector *connector) +{ + struct device *dev = connector->dev->dev; + u64 port_id = connector->base.id; + + if (dev && dev_is_pci(dev)) { + struct pci_dev *pdev = to_pci_dev(dev); + + port_id |= (u64)(pci_domain_nr(pdev->bus) & 0xffff) << 48 | + (u64)pci_dev_id(pdev) << 32; + } + + put_unaligned_le64(port_id, &eld[DRM_ELD_PORT_ID]); +} +EXPORT_SYMBOL(drm_eld_set_port_id); diff --git a/include/drm/drm_eld.h b/include/drm/drm_eld.h index 0a88d10b28b0..de0478720721 100644 --- a/include/drm/drm_eld.h +++ b/include/drm/drm_eld.h @@ -9,6 +9,7 @@ #include struct cea_sad; +struct drm_connector; /* ELD Header Block */ #define DRM_ELD_HEADER_BLOCK_SIZE 4 @@ -80,6 +81,8 @@ static inline int drm_eld_mnl(const u8 *eld) int drm_eld_sad_get(const u8 *eld, int sad_index, struct cea_sad *cta_sad); int drm_eld_sad_set(u8 *eld, int sad_index, const struct cea_sad *cta_sad); +void drm_eld_set_port_id(u8 *eld, const struct drm_connector *connector); + /** * drm_eld_sad - Get ELD SAD structures. * @eld: pointer to an eld memory structure with sad_count set -- 2.43.0