From nobody Sat Jul 25 01:34:40 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 EB4A641737C for ; Tue, 21 Jul 2026 06:41:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616093; cv=none; b=lekNpRBeajYf8CVdvQ24I0nJf+wL7D6fJHlo2WGjN03tZ1/pd70HM+6H/XNEQdCa2ociEXCFqJpB1k6NbBOs/ZIhpzeLraUSZfJAXIWQ1uoG/buoQZgKieneqeOgNfdeYkX+KjOBzkspp93eaYygHn/GCvkKU+rSo+2PGtHZ4rg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616093; c=relaxed/simple; bh=RAHefaXglt+Txkz0duK6/2S/HGE7LcBt0LhyGHHFfkI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cZBEG4KS3poGr53czAygEEYJJAAAxpZhNo+rxuXunMoNHJknJEg34wQJHg9Frpm5+MBbgERKma2OmRDeumtzgGMTux/QCFJJLh9rmM/tU4fK4AxtWEFvGuKUFpnjJ/mamD9mk6G08jvd8dzgOI4ZxIoZE8/0MAEcEHRLOe/hITQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AyIfiwIB; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AyIfiwIB" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-47df6a5655aso589844f8f.1 for ; Mon, 20 Jul 2026 23:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784616090; x=1785220890; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=A6arKxt/pKAK4HvJvMnbtdBhQ+d77oJa3U99lYSiiAM=; b=AyIfiwIB3wU1RvzGOwsF+81XhK5MKiiCIWUJOhlvcsfHX2mNVKqhGPl9X7JZ72cugw MDIFJxE+QTDoRoZ551fyes6b4ag6mlbf9xMYdUVWv7iPhpoiSh/XI2+QhsmbShZwFq+J H+5CgGwQe+LTBjcUdb/V8h+T26xEev7cnxFGDtXo2vaH6cE3LoaehiNp0qoWa277SAjX 6PjgxnP2+puWFgwJ/tBBTsIj9CIm7Y3Elf0gygWrcwMJgRRM8Onr5CzB6TjFOHKbot5N cqNd7OULhei7hs1IT3lNTQ1Ncht6Rw18/HKSYL9pE0xlaGZa4JiB7Wwsu4EFQaj/jRqn K08Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784616090; x=1785220890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=A6arKxt/pKAK4HvJvMnbtdBhQ+d77oJa3U99lYSiiAM=; b=HLUnobOXRLJBo7ztmGAegZ5X2QVTcXqNKsy5n1SmY2NbTtbCSjfQeUtfTSvZoKMfyT rSIKcU7pKGkOaDdUtq4MRgUdM+G4LzZMUXHqyl3h7hYr0Q9oB6rCRE589jpSvzyh4yLi GaQL6HtbBhTzFlEp7+wVgWmw54JWRkytyf8QgRjQCxkrtHKOLF7mf3xDj2uDy+IVZCjn Euxv8EXr2MIQIVSp7wAnQwEgbEBlr6XWqz1YE89+ZI6Wau2jig2JO97q7ZznRUsysCIQ O4cuCM51Tm1aPYeAKff4MojLzFz1AvY6sr2L6l+u7PZguYIcGUvksFI1RBKb9ozAS5Lo EWRQ== X-Forwarded-Encrypted: i=1; AHgh+RpS2Z177bw2Wb461/3O2FO+p/0USSx5Jxf2MWmEXSo4IdDIt8/6NEYr6JocrYF70pnm9FiZLBaYBfrWGTg=@vger.kernel.org X-Gm-Message-State: AOJu0YzzH6awG+ErWY2F9IRnnGM2AnvhO7R/kTUoKe3Q05UUhY4JHUm0 cinp87be42Lppqyr3o9kFXHk3v8uHE4DLZaX1YcynDogjCIucigAxy5K X-Gm-Gg: AR+sD10+oF5cbnp/ipxKLfmbXzeeFfKZ3537g7H558b0ZGPN6OxcaI4UK5a0wQBF7K1 kjvlGRQC8td9QkL9qme3Bn6Q56STrJVGhBugRoumj7w9LqDvGVfDL3j4rG8TMluPsIvM9NSMG5+ ux9LjBqe4OK3mLJ7s5kSDyxvcdBCO3UgXYkxFTNZV9EP8vjvNz8jcyQcCoC3OBEP50Pwb893zcz nbr7mtDAarCCDSQKHJ1np6RLRGBCPsT9vcqwrxaszP23ofZS/dGbibrOqgd/Vp8GTrdUJa8rfbr 3/p8oQzy8Rtq9C5aKKlLK4aF2MPlP33vlXbVS9SBw5/ojQW8UC3NAlm/dzVYMNH2OSalUllIu/6 YjwduLhByn+GWHQm4Qa903lg5CtqgiLKZODx9olAZCAkyLqHRR7SN0sYdIc5CjEOVZw2qjWIxWc SoJkT4RGdfTy05HYUyjajN5/xKvYS8kjHADirVPmbmSj8TGHTKvYC0qFt3gwx6ayWY1EiNE4fxh qtF73Y9SgYzm7YxZV4zPA== X-Received: by 2002:a05:6000:238a:b0:475:3a97:8e2a with SMTP id ffacd0b85a97d-47f6233d4ecmr10721512f8f.7.1784616089904; Mon, 20 Jul 2026 23:41:29 -0700 (PDT) Received: from OrangePi5-Plus.BB-HOME (20014C4E1B88AD00DA0BF9DB4519DBD6.dsl.pool.telekom.hu. [2001:4c4e:1b88:ad00:da0b:f9db:4519:dbd6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63ed1911sm38837951f8f.22.2026.07.20.23.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 23:41:29 -0700 (PDT) From: Igor Paunovic To: Dmitry Osipenko , Mauro Carvalho Chehab Cc: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Paunovic Subject: [PATCH v4 1/4] dt-bindings: media: snps,dw-hdmi-rx: add #sound-dai-cells Date: Tue, 21 Jul 2026 08:41:12 +0200 Message-ID: <20260721064115.64809-2-royalnet026@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260721064115.64809-1-royalnet026@gmail.com> References: <20260721064115.64809-1-royalnet026@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The HDMI RX controller can expose the audio embedded in the incoming HDMI stream as an ALSA capture device. Document the #sound-dai-cells property so that a sound card can reference the HDMI RX audio DAI. Signed-off-by: Igor Paunovic Reviewed-by: Dmitry Osipenko Reviewed-by: Krzysztof Kozlowski Reviewed-by: Sebastian Reichel --- Changes in v4 (both suggested by Krzysztof Kozlowski): - reference dai-common.yaml and switch additionalProperties to unevaluatedProperties: false - drop the consumer comment from the binding example Changes in v3: - no changes Changes in v2 (all suggested by Sebastian Reichel): - reworded the commit message to describe the hardware - property description now documents the DAI indexes (0 =3D I2S, 1 =3D S/PDIF) - moved the consumer reference into the binding example .../devicetree/bindings/media/snps,dw-hdmi-rx.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.yaml b= /Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.yaml index b7f6c87..b80660d 100644 --- a/Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.yaml +++ b/Documentation/devicetree/bindings/media/snps,dw-hdmi-rx.yaml @@ -78,6 +78,13 @@ properties: The phandle of the syscon node for the Video Output GRF register to enable EDID transfer through SDAIN and SCLIN. =20 + "#sound-dai-cells": + const: 1 + description: + The HDMI RX controller has two digital audio interfaces, one for + I2S and one for S/PDIF. The DAI cell selects the interface, 0 for + I2S and 1 for S/PDIF. + required: - compatible - reg @@ -90,7 +97,10 @@ required: - pinctrl-0 - hpd-gpios =20 -additionalProperties: false +allOf: + - $ref: /schemas/sound/dai-common.yaml# + +unevaluatedProperties: false =20 examples: - | @@ -129,4 +139,5 @@ examples: pinctrl-0 =3D <&hdmim1_rx_cec &hdmim1_rx_hpdin &hdmim1_rx_scl &hdmim= 1_rx_sda &hdmirx_5v_detection>; pinctrl-names =3D "default"; hpd-gpios =3D <&gpio1 22 GPIO_ACTIVE_LOW>; + #sound-dai-cells =3D <1>; }; --=20 2.53.0 From nobody Sat Jul 25 01:34:40 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 5AD623C4B93 for ; Tue, 21 Jul 2026 06:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616098; cv=none; b=WRCCTVYrUiUv/TdY5LRgpQekE/GZEoViGzXrWR/A35lLhAZo08SAA7lqJa0AOLGeRllQDJXzoUSkVyKkx5vCSGbKaz9rpWpJHULClR6fSK7IZQs1TSpaWXTwLTup5UExBWksT5J6/FLD3VCueQJ3YXnegbR97qcbs3Ch4Fr3XT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616098; c=relaxed/simple; bh=MXjAjd8sRElI+aV/CUjVTdNf+EGWGqK8GflWB9yrfMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QTdyVZV5jrzL75xldEIUY+YkA1E8+EAiHFuwkF3eQSW9dUGD5wVl7sPaA1gq3v07C5XhUe1TNG3CyzoB9UBIgxmkIZkogI7x8iTzMRFpr9PVpYb8GyJzsESOjFGuTD4z+ljAVyCQZuUMo+m7e1w6vSFLx06N15S4GOh776BSJgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=om9P7tEQ; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="om9P7tEQ" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-494049206c6so4264665e9.2 for ; Mon, 20 Jul 2026 23:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784616091; x=1785220891; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=eQnHLvdc7lNWNCnmtODCYn1qxmvdct2JXkNun+6bK/A=; b=om9P7tEQbRRAHlJlwspOtmA7ZkzB4p+GNvVSYcdOsGcrtcP2O7NRt2t+iMDScujXbd t/4sg2F1QKaoP2lRSA1HZgbGOlFQCXJ0AvWUWIsJzXr6NAeX3N1mFyxG3+ocf8RQG3Qc cKzPgW3CabkxoIp/OafISEEEDisK2pc55gtCd7oDXGZlf5z9cN+kdLjRZfl99rplhLK9 IJyQ4QaDUNcGJbAxMvJMON9C4PwGVUKTGLL3ADKSqObA+cqz/qK1YvKm5APIIj2XZ3uH dTQnkud5r7XbZt4B5/nD6kJcRfdMHMZuCNKTeIaN1atsnIneY6ILCLnjnlPks5QGlW3E n1Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784616091; x=1785220891; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=eQnHLvdc7lNWNCnmtODCYn1qxmvdct2JXkNun+6bK/A=; b=LNks2J2rUdpjQ9JIn7LVMCkVywozRYD718+MpZ6eae1qlWFzoxcADI04JKG3LXM3Xg UEN7EbzBJkwZbBkyQLnwaQuz53wcMh+OvZIpgS1OO5anVBPaHt9d00j/XDPN1ICzXFjt /PBax/TzL8ztsG7ytVbmdSL8QY7uGVFvPxfB038lA8uw4gXYdaJGlRC6HD6jI+8BFXNO 85x/BCt6d319tihC5DebQNcNY+OhtkNLixhMrX1+lXhqkA4J336XcW1szi1LgXoe19Qx sGpsZbUHQvU1klBcquvSkGXp9Y9fMtwMFQy3TeeDxnPRBy8BNzkBRyyUhjrS0HSS6F3j L17w== X-Forwarded-Encrypted: i=1; AHgh+RqFvTuuoBcJ4GrhJyp8GYRHNX2U8fgQvKR/t14EeLPVkhnufNXoHhhZMWgnoELBS15SsI+O9BqheDrHfn8=@vger.kernel.org X-Gm-Message-State: AOJu0YxHG0TizGPcMybkglt0UOZWzzPePvOrAx3TsmQ6jfnp80qJB6d0 c1UJPPhidTk2xa8vGZspG4HfdBVIPTdGRVPUq7SJCjgLWj4QwIBnM7Nb X-Gm-Gg: AR+sD132db/L7AJFgCoBVNzi5I5Dpmac+++LZGZweuU6dUgtOyWMwG2cTMMz6xqo8Qo vfwkR9UDyz/T69mpdotCYlWW1vcCJoYKhB74d8azIl3h++AORT08Tqy4CIt4XY9cW87gA3Cl9LK EHTEUXykQNSzepc4WAplwiIUw37u6PxmCNw2WXhp64H57poO6zFz310zTgJbOHVrI3vb25PrZoN C8KqAY3T1taZd38PgiSLsh503gQErRvW5nTFvtM12y5BxsvqqnWN4avuWhxTcySIbT/KV9m090z IpRj0KjkBDGP0xO8c9S8lAqA9XdgZdfv7/89Zc2vKh7ookQ2w9mpdTZn2bgMZkfDklqZPtkS2RJ 4DsPtxbbQb3YRwyXaicDTQSnJPpAB5pRy3fFwz1T6NdS/y/nwB5do6emwFNdIEgOoJ0AnaR3SaU RxHWduFBha8m5qYh8Ts7wID/36VbE4NqB0uiMjO0BeEQ/NZVysbtAOr48HVTh/SiVTP7/ELgLEg BQx/WCjkt5eZpgA2PCjh2IP3PdNl6qp X-Received: by 2002:a05:6000:3ca:b0:47f:6fbd:f23e with SMTP id ffacd0b85a97d-47f7fe30db7mr970614f8f.4.1784616091281; Mon, 20 Jul 2026 23:41:31 -0700 (PDT) Received: from OrangePi5-Plus.BB-HOME (20014C4E1B88AD00DA0BF9DB4519DBD6.dsl.pool.telekom.hu. [2001:4c4e:1b88:ad00:da0b:f9db:4519:dbd6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63ed1911sm38837951f8f.22.2026.07.20.23.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 23:41:30 -0700 (PDT) From: Igor Paunovic To: Dmitry Osipenko , Mauro Carvalho Chehab Cc: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Paunovic Subject: [PATCH v4 2/4] media: synopsys: hdmirx: add HDMI audio capture support Date: Tue, 21 Jul 2026 08:41:13 +0200 Message-ID: <20260721064115.64809-3-royalnet026@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260721064115.64809-1-royalnet026@gmail.com> References: <20260721064115.64809-1-royalnet026@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Synopsys DesignWare HDMI RX controller extracts the audio stream embedded in the incoming HDMI signal and feeds it to an on-SoC I2S controller. Expose it as an ALSA capture device by registering the generic hdmi-codec as a child of the controller, so that a simple-audio-card in the device tree can bind the HDMI RX audio DAI. The sample rate is recovered from the ACR N/CTS values together with the measured TMDS character rate. A periodic worker keeps the local audio reference clock locked to the source by nudging it in small ppm steps to hold the audio FIFO fill level near its target, which avoids FIFO under/overflow and the resulting dropped samples. Across system suspend the worker is stopped before the controller clocks are gated. Resume fully resets the controller, wiping the audio configuration, so when a capture stream is active it re-programs the audio path from the last known sample rate and re-arms the worker, whose rate change and FIFO error paths resynchronize once the source delivers audio again. Signed-off-by: Igor Paunovic Reviewed-by: Dmitry Osipenko Tested-by: Dmitry Osipenko --- Changes in v4: - use swab32() for the ACR word reversal: readl() already abstracts bus endianness, so the reversal must be unconditional (be32_to_cpu is a no-op on big-endian) - support system suspend: stop the worker in suspend before the clocks are gated; resume fully resets the controller, so re-program the audio path and re-arm the worker while a capture stream is active, through a hdmirx_audio_setup() helper shared with hw_params() (Dmitry Osipenko; validated with an active capture stream across suspend/resume) Changes in v3: - restore the v1 audio teardown in remove(): audio_shutdown() already stops the worker when the stream closes, so the extra flag clear and trailing cancel added in v2 were redundant (Dmitry Osipenko) - rename the ACR read locals and add a comment documenting the register byte packing - drop the get_dai_id stub so OF-graph cards resolve the DAI index from the reg property Changes in v2: - register the S/PDIF DAI so the indexes match the binding and reject it with -EOPNOTSUPP until wired up (Sebastian Reichel) - use platform_device_register_data() and drop the fixed 32-bit DMA mask (Dmitry Osipenko) - don't leave an ERR_PTR in audio_pdev on registration failure - fix teardown ordering in remove() - stop the worker before reprogramming shared state in hw_params() - look up the "audio" clock by name instead of indexing clks[1] - keep the worker on system_unbound_wq when re-arming .../platform/synopsys/hdmirx/snps_hdmirx.c | 306 ++++++++++++++++++ .../platform/synopsys/hdmirx/snps_hdmirx.h | 8 + 2 files changed, 314 insertions(+) diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers= /media/platform/synopsys/hdmirx/snps_hdmirx.c index 9cceffa..99ad621 100644 --- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c +++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c @@ -41,6 +41,8 @@ #include #include =20 +#include + #include "snps_hdmirx.h" #include "snps_hdmirx_cec.h" =20 @@ -132,6 +134,13 @@ struct snps_hdmirx_dev { struct delayed_work delayed_work_hotplug; struct delayed_work delayed_work_res_change; struct hdmirx_cec *cec; + struct platform_device *audio_pdev; + struct clk *audio_clk; + struct delayed_work audio_work; + u32 audio_clkrate; + u32 audio_fs; + int audio_pre_state; + bool audio_streaming; struct mutex phy_rw_lock; /* to protect phy r/w configuration */ struct mutex stream_lock; /* to lock video stream capture */ struct mutex work_lock; /* to lock the critical section of hotplug event = */ @@ -2283,6 +2292,13 @@ static int hdmirx_parse_dt(struct snps_hdmirx_dev *h= dmirx_dev) if (hdmirx_dev->num_clks < 1) return -ENODEV; =20 + for (int i =3D 0; i < hdmirx_dev->num_clks; i++) { + if (!strcmp(hdmirx_dev->clks[i].id, "audio")) { + hdmirx_dev->audio_clk =3D hdmirx_dev->clks[i].clk; + break; + } + } + hdmirx_dev->resets[HDMIRX_RST_A].id =3D "axi"; hdmirx_dev->resets[HDMIRX_RST_P].id =3D "apb"; hdmirx_dev->resets[HDMIRX_RST_REF].id =3D "ref"; @@ -2527,10 +2543,19 @@ static void hdmirx_enable_irq(struct device *dev) msecs_to_jiffies(110)); } =20 +static void hdmirx_audio_setup(struct snps_hdmirx_dev *hdmirx_dev, u32 fs); + static __maybe_unused int hdmirx_suspend(struct device *dev) { struct snps_hdmirx_dev *hdmirx_dev =3D dev_get_drvdata(dev); =20 + /* + * Stop the audio worker before the controller clocks are gated; + * the audio path is restored and the worker re-armed from + * resume() while a capture stream is active. + */ + cancel_delayed_work_sync(&hdmirx_dev->audio_work); + hdmirx_disable_irq(dev); =20 /* TODO store CEC HW state */ @@ -2553,6 +2578,19 @@ static __maybe_unused int hdmirx_resume(struct devic= e *dev) hdmirx_hpd_ctrl(hdmirx_dev, true); } =20 + /* + * hdmirx_enable() fully reset the controller, wiping the audio + * configuration. If a capture stream is active across suspend, + * re-program the audio path with the last known sample rate and + * restart the worker; its rate change and FIFO error paths + * resynchronize once the source delivers audio again. + */ + if (READ_ONCE(hdmirx_dev->audio_streaming)) { + hdmirx_audio_setup(hdmirx_dev, hdmirx_dev->audio_fs); + mod_delayed_work(system_unbound_wq, &hdmirx_dev->audio_work, + msecs_to_jiffies(200)); + } + /* TODO restore CEC HW state */ enable_irq(hdmirx_dev->cec->irq); =20 @@ -2650,6 +2688,266 @@ static int hdmirx_register_cec(struct snps_hdmirx_d= ev *hdmirx_dev, return 0; } =20 +#define HDMIRX_AUDIO_INIT_FIFO_STATE 128 +#define HDMIRX_AUDIO_INIT_STATE (HDMIRX_AUDIO_INIT_FIFO_STATE * 4) + +static const int hdmirx_supported_fs[] =3D { + 32000, 44100, 48000, 88200, 96000, 176400, 192000, 768000, -1 +}; + +static int hdmirx_audio_closest_fs(int fs) +{ + int i =3D 0, fs_t =3D hdmirx_supported_fs[0]; + + while (fs_t > 0) { + if (abs(fs - fs_t) <=3D 2000) + return fs_t; + fs_t =3D hdmirx_supported_fs[++i]; + } + return 0; +} + +/* Recover the incoming audio sample rate from the ACR N/CTS + TMDS clock.= */ +static u32 hdmirx_audio_fs(struct snps_hdmirx_dev *hdmirx_dev) +{ + u64 tmds_clk, fs_audio =3D 0; + u32 acr_cts, acr_n, tmdsqpclk_freq; + u32 acr_pb3_0, acr_pb7_4; + + tmdsqpclk_freq =3D hdmirx_readl(hdmirx_dev, CMU_TMDSQPCLK_FREQ); + hdmirx_readl(hdmirx_dev, PKTDEC_ACR_PH2_1); + acr_pb3_0 =3D hdmirx_readl(hdmirx_dev, PKTDEC_ACR_PB3_0); + acr_pb7_4 =3D hdmirx_readl(hdmirx_dev, PKTDEC_ACR_PB7_4); + /* + * The packet decoder stores the ACR subpacket bytes with packet byte + * 0 in register bits [7:0], so byte-reverse each word to line the + * bytes up: CTS is packet bytes 1-3 (PKTDEC_ACR_PB3_0) and N is + * packet bytes 4-6 (PKTDEC_ACR_PB7_4), 20 bits each. readl() + * already abstracts the bus endianness, so the reversal is + * unconditional. + */ + acr_cts =3D swab32(acr_pb3_0) & 0xfffff; + acr_n =3D (swab32(acr_pb7_4) & 0x0fffff00) >> 8; + tmds_clk =3D tmdsqpclk_freq * 4 * 1000U; + if (acr_cts !=3D 0) { + fs_audio =3D div_u64((tmds_clk * acr_n), acr_cts); + fs_audio /=3D 128; + fs_audio =3D hdmirx_audio_closest_fs(fs_audio); + } + return (u32)fs_audio; +} + +/* Nudge the audio reference clock by +/- ppm to keep the FIFO balanced. */ +static void hdmirx_audio_clk_ppm_inc(struct snps_hdmirx_dev *hdmirx_dev, i= nt ppm) +{ + int delta, inc; + long rate =3D hdmirx_dev->audio_clkrate; + + if (ppm < 0) { + ppm =3D -ppm; + inc =3D -1; + } else { + inc =3D 1; + } + delta =3D (int)div64_u64((u64)rate * ppm + 500000, 1000000); + delta *=3D inc; + rate =3D hdmirx_dev->audio_clkrate + delta; + clk_set_rate(hdmirx_dev->audio_clk, rate); + hdmirx_dev->audio_clkrate =3D rate; +} + +static int hdmirx_audio_clk_adjust(struct snps_hdmirx_dev *hdmirx_dev, + int total_offset, int single_offset) +{ + int schedule_time =3D 500; + int ppm =3D 10; + u32 offset_abs =3D abs(total_offset); + + if (offset_abs > 200) { + ppm +=3D 200; + schedule_time -=3D 100; + } + if (offset_abs > 100) { + ppm +=3D 200; + schedule_time -=3D 100; + } + if (offset_abs > 32) { + ppm +=3D 20; + schedule_time -=3D 100; + } + if (offset_abs > 16) + ppm +=3D 20; + if (total_offset > 16 && single_offset > 0) + hdmirx_audio_clk_ppm_inc(hdmirx_dev, ppm); + else if (total_offset < -16 && single_offset < 0) + hdmirx_audio_clk_ppm_inc(hdmirx_dev, -ppm); + return schedule_time; +} + +static void hdmirx_audio_fifo_reinit(struct snps_hdmirx_dev *hdmirx_dev) +{ + hdmirx_writel(hdmirx_dev, AUDIO_FIFO_CONTROL, 1); + usleep_range(200, 210); + hdmirx_writel(hdmirx_dev, AUDIO_FIFO_CONTROL, 0); +} + +/* + * Program the audio clock, FIFO thresholds and enables for the given + * sample rate. Shared by hw_params and system resume: the controller is + * fully reset on resume, so the whole configuration must be re-applied. + */ +static void hdmirx_audio_setup(struct snps_hdmirx_dev *hdmirx_dev, u32 fs) +{ + hdmirx_dev->audio_fs =3D fs; + hdmirx_dev->audio_clkrate =3D fs * 128; + clk_set_rate(hdmirx_dev->audio_clk, hdmirx_dev->audio_clkrate); + + hdmirx_audio_fifo_reinit(hdmirx_dev); + hdmirx_writel(hdmirx_dev, AUDIO_FIFO_THR_PASS, HDMIRX_AUDIO_INIT_FIFO_STA= TE); + hdmirx_writel(hdmirx_dev, AUDIO_FIFO_THR, + AFIFO_THR_LOW_QST(0x20) | AFIFO_THR_HIGH_QST(0x160)); + hdmirx_writel(hdmirx_dev, AUDIO_FIFO_MUTE_THR, + AFIFO_THR_MUTE_LOW_QST(0x8) | AFIFO_THR_MUTE_HIGH_QST(0x178)); + + hdmirx_update_bits(hdmirx_dev, AUDIO_PROC_CONFIG0, I2S_EN, I2S_EN); + hdmirx_update_bits(hdmirx_dev, GLOBAL_SWENABLE, AUDIO_ENABLE, AUDIO_ENABL= E); + + hdmirx_dev->audio_pre_state =3D 0; +} + +/* + * Periodic worker that locks the local audio clock to the source by keepi= ng + * the audio FIFO fill level close to its target, avoiding under/overflow. + */ +static void hdmirx_audio_work(struct work_struct *work) +{ + struct snps_hdmirx_dev *hdmirx_dev =3D + container_of(to_delayed_work(work), struct snps_hdmirx_dev, audio_work); + unsigned long delay =3D 200; + int cur, total, single; + u32 fifo, fs; + + fs =3D hdmirx_audio_fs(hdmirx_dev); + fifo =3D hdmirx_readl(hdmirx_dev, AUDIO_FIFO_STATUS2); + + if (fifo & (AFIFO_UNDERFLOW_ST | AFIFO_OVERFLOW_ST)) { + if (fs) { + clk_set_rate(hdmirx_dev->audio_clk, fs * 128); + hdmirx_dev->audio_clkrate =3D fs * 128; + hdmirx_dev->audio_fs =3D fs; + } + hdmirx_audio_fifo_reinit(hdmirx_dev); + hdmirx_dev->audio_pre_state =3D 0; + goto out; + } + + cur =3D fifo & 0xffff; + total =3D cur - HDMIRX_AUDIO_INIT_STATE; + single =3D cur - hdmirx_dev->audio_pre_state; + + if (fs && abs((int)fs - (int)hdmirx_dev->audio_fs) > 1000) { + clk_set_rate(hdmirx_dev->audio_clk, fs * 128); + hdmirx_dev->audio_clkrate =3D fs * 128; + hdmirx_dev->audio_fs =3D fs; + hdmirx_audio_fifo_reinit(hdmirx_dev); + hdmirx_dev->audio_pre_state =3D 0; + goto out; + } + + if (cur !=3D 0) + delay =3D hdmirx_audio_clk_adjust(hdmirx_dev, total, single); + hdmirx_dev->audio_pre_state =3D cur; +out: + /* Only re-arm while streaming; avoids a self-reschedule race with + * the cancel_delayed_work_sync() callers (hw_params and + * audio_shutdown). + */ + if (READ_ONCE(hdmirx_dev->audio_streaming)) + queue_delayed_work(system_unbound_wq, &hdmirx_dev->audio_work, + msecs_to_jiffies(delay)); +} + +static int hdmirx_audio_hw_params(struct device *dev, void *data, + struct hdmi_codec_daifmt *fmt, + struct hdmi_codec_params *hparms) +{ + struct snps_hdmirx_dev *hdmirx_dev =3D dev_get_drvdata(dev); + u32 fs; + + /* Only the I2S interface (DAI 0) is wired up so far. */ + if (fmt->fmt =3D=3D HDMI_SPDIF) + return -EOPNOTSUPP; + + /* + * Stop the worker before touching the shared audio state; it is + * re-armed below once the new parameters are in place. + */ + WRITE_ONCE(hdmirx_dev->audio_streaming, false); + cancel_delayed_work_sync(&hdmirx_dev->audio_work); + + fs =3D hdmirx_audio_fs(hdmirx_dev); + if (!fs) + fs =3D hparms ? hparms->sample_rate : 48000; + if (!fs) + fs =3D 48000; + + hdmirx_audio_setup(hdmirx_dev, fs); + + WRITE_ONCE(hdmirx_dev->audio_streaming, true); + mod_delayed_work(system_unbound_wq, &hdmirx_dev->audio_work, + msecs_to_jiffies(200)); + + dev_dbg(dev, "audio hw_params: fs=3D%u\n", fs); + return 0; +} + +static void hdmirx_audio_shutdown(struct device *dev, void *data) +{ + struct snps_hdmirx_dev *hdmirx_dev =3D dev_get_drvdata(dev); + + WRITE_ONCE(hdmirx_dev->audio_streaming, false); + cancel_delayed_work_sync(&hdmirx_dev->audio_work); + hdmirx_update_bits(hdmirx_dev, GLOBAL_SWENABLE, AUDIO_ENABLE, 0); +} + +static const struct hdmi_codec_ops hdmirx_audio_codec_ops =3D { + .hw_params =3D hdmirx_audio_hw_params, + .audio_shutdown =3D hdmirx_audio_shutdown, +}; + +static int hdmirx_register_audio_device(struct snps_hdmirx_dev *hdmirx_dev) +{ + struct hdmi_codec_pdata codec_data =3D { + .ops =3D &hdmirx_audio_codec_ops, + .i2s =3D 1, + .no_i2s_playback =3D 1, + .max_i2s_channels =3D 8, + /* + * The controller also has an S/PDIF audio interface (DAI 1 in + * the binding). Register it so DAI indexes match the binding, + * but reject its use in hw_params() until it is wired up. + */ + .spdif =3D 1, + .no_spdif_playback =3D 1, + .data =3D hdmirx_dev, + }; + struct platform_device *audio_pdev; + + if (!hdmirx_dev->audio_clk) + return -ENODEV; + + audio_pdev =3D platform_device_register_data(hdmirx_dev->dev, + HDMI_CODEC_DRV_NAME, + PLATFORM_DEVID_AUTO, + &codec_data, sizeof(codec_data)); + if (IS_ERR(audio_pdev)) + return PTR_ERR(audio_pdev); + + hdmirx_dev->audio_pdev =3D audio_pdev; + + return 0; +} + static int hdmirx_probe(struct platform_device *pdev) { struct snps_hdmirx_dev *hdmirx_dev; @@ -2701,6 +2999,7 @@ static int hdmirx_probe(struct platform_device *pdev) hdmirx_delayed_work_hotplug); INIT_DELAYED_WORK(&hdmirx_dev->delayed_work_res_change, hdmirx_delayed_work_res_change); + INIT_DELAYED_WORK(&hdmirx_dev->audio_work, hdmirx_audio_work); =20 hdmirx_dev->cur_fmt_fourcc =3D V4L2_PIX_FMT_BGR24; hdmirx_dev->timings =3D cea640x480; @@ -2769,6 +3068,10 @@ static int hdmirx_probe(struct platform_device *pdev) V4L2_DEBUGFS_IF_AVI, hdmirx_dev, hdmirx_debugfs_if_read); =20 + ret =3D hdmirx_register_audio_device(hdmirx_dev); + if (ret) + dev_warn(dev, "failed to register HDMI audio codec: %d\n", ret); + return 0; =20 err_unreg_video_dev: @@ -2788,6 +3091,9 @@ static void hdmirx_remove(struct platform_device *pde= v) struct device *dev =3D &pdev->dev; struct snps_hdmirx_dev *hdmirx_dev =3D dev_get_drvdata(dev); =20 + if (hdmirx_dev->audio_pdev) + platform_device_unregister(hdmirx_dev->audio_pdev); + v4l2_debugfs_if_free(hdmirx_dev->infoframes); debugfs_remove_recursive(hdmirx_dev->debugfs_dir); =20 diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h b/drivers= /media/platform/synopsys/hdmirx/snps_hdmirx.h index 31b887e..a99f54f 100644 --- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h +++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.h @@ -81,6 +81,7 @@ #define DATAPATH_ENABLE BIT(12) #define PKTFIFO_ENABLE BIT(11) #define AVPUNIT_ENABLE BIT(8) +#define AUDIO_ENABLE BIT(9) #define MAIN_ENABLE BIT(0) #define GLOBAL_TIMER_REF_BASE 0x0028 #define CORE_CONFIG 0x0050 @@ -177,20 +178,27 @@ #define VPROC_FMT_OVR_VALUE(x) UPDATE(x, 6, 4) #define VPROC_FMT_OVR_EN BIT(0) =20 +#define AUDIO_FIFO_CONFIG 0x0460 #define AFIFO_FILL_RESTART BIT(0) +#define AUDIO_FIFO_CONTROL 0x0464 #define AFIFO_INIT_P BIT(0) +#define AUDIO_FIFO_THR_PASS 0x0468 +#define AUDIO_FIFO_THR 0x046c #define AFIFO_THR_LOW_QST_MASK GENMASK(25, 16) #define AFIFO_THR_LOW_QST(x) UPDATE(x, 25, 16) #define AFIFO_THR_HIGH_QST_MASK GENMASK(9, 0) #define AFIFO_THR_HIGH_QST(x) UPDATE(x, 9, 0) +#define AUDIO_FIFO_MUTE_THR 0x0470 #define AFIFO_THR_MUTE_LOW_QST_MASK GENMASK(25, 16) #define AFIFO_THR_MUTE_LOW_QST(x) UPDATE(x, 25, 16) #define AFIFO_THR_MUTE_HIGH_QST_MASK GENMASK(9, 0) #define AFIFO_THR_MUTE_HIGH_QST(x) UPDATE(x, 9, 0) =20 +#define AUDIO_FIFO_STATUS2 0x0478 #define AFIFO_UNDERFLOW_ST BIT(25) #define AFIFO_OVERFLOW_ST BIT(24) =20 +#define AUDIO_PROC_CONFIG0 0x0480 #define SPEAKER_ALLOC_OVR_EN BIT(16) #define I2S_BPCUV_EN BIT(4) #define SPDIF_EN BIT(2) --=20 2.53.0 From nobody Sat Jul 25 01:34:40 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85663417BD9 for ; Tue, 21 Jul 2026 06:41:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616096; cv=none; b=btFwwS8Gnxj6lmWHDg5RbbnyUjNQJuqiQegSyT9N+gvdjrO+hJsixpF4i/eIdQ/enNKbxGQDflUgBdn9v3zP+mStbp/0JBaecvcdXRokMomCVBMimU/WuSTmgw0vPPDwvbYo03Gj6FtuHRFhflaJMAqN47TUn6bkTjG4I0EoysQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616096; c=relaxed/simple; bh=YA4t/FQ4Wsu7AcE6Lw32+kLJsSTSk39Et8195aKjZpo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nRiQ7Zg0claTTg7XMInyDq9/KEiURgKsXAmNuwfC9BojPRY9wV4k0bfYymI7b7WDp+8qp9OCt0sUb0QFq6KqFggRwXW6IvRggnZWiUUdZ2gB90vLxvbbrvmIjG6Q012cfVA/NuutrrRJAqD20ka3LCNzPflB/xMfQldyvQSgxE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fMB+JZvH; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fMB+JZvH" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-49552f516beso992975e9.1 for ; Mon, 20 Jul 2026 23:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784616093; x=1785220893; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gxBcoaYqqWn7DDfCE+l3ErfQKRET5iv1Y4ILak6MpwQ=; b=fMB+JZvHQlmDCFJsuDxpEZovCxbEogIqc6CLwtb/zwyg1IwLktD099wczHkODxeeaL YyFMJ8sFnotIguDqz4KimdSEPpVG4/10SW4x6Wd4R9nLxoUQwORcMx4FkGTYc6i32DXB siK3YUluyKNrYQl3gMLJzsUwz3pX7Hjs/YSq4Kt+vrW8hpdKYpMgh5dZMZjdffDMWNja JP0KBOBHjyqIWIJoMcF94sLanW959hvRHQUJKuhyUfnR8Xir1wYIzKjZcchn/SIMN/Pe X6xAtDr4vIEto6v6T7PC+m2Gmp/oqhN/RylmnNQ+1W98w6OaqzzgH1bew909q4b2eEft LC+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784616093; x=1785220893; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=gxBcoaYqqWn7DDfCE+l3ErfQKRET5iv1Y4ILak6MpwQ=; b=CGvfAes8x1Rlt0+1NwWad/XRzfnI9ILv7U6dP9/IgRiJ85I/N5H7LZYkIB4EFCPcMK oHsqxwe5FtUVoyXpZ0LqCnq2q6cxUcmuXOAK5gbMbu2yrxA+X87wp7Gbcr+DtdJL9Ay7 4K4dnuZAb5b7vwPcHhdTSkK8tSwsXR+iG+/u7EtbhfmghCYTAHttG86/Xi0dMyNKX06d +cGMms4biXR6rdUkRrh7cmqbBCfxaxynX+70rVzTG1VntX56n5WxNlj7XSbiHImGProt Z1fq5bt44D7ON7Fo+H1FerFm02RiBZSzR/y6/dbmHgPMf+sZX6+sAh8mr52GjU4yDOzD DYJw== X-Forwarded-Encrypted: i=1; AHgh+Rp9Z+PJoM0TlnGVAOB+wH4TAq5hlz1R+criJLvBVXiVhl1LF0h0ayvb74717e/drMYngjBT2qEADmseY/E=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9nvOYKJ35BgpPyPSAK7a4wV4tr8E5ymE4Cp+BgbQXn2aAFLTU c/dKRJdu8A3rsqPOUE/fh+4l5qVrnQsZbdkdSFphCQKK4SViMR6scP5g X-Gm-Gg: AfdE7clYBoSZWxJ87SmUQEsWVHHlQQfZGIg67CFVUG80+BXVdJAuPnepk5/hZgXspNp SEsFR7kXwCBEhZI/JlFi3ES0tZXhLh4DejHWxlARM9ZTuZkdBTolJXDLVOgY/PywVr/ZzrMvO+p I05UO3mwYhRWNIxIpYTUraHAkap7uudycnWeTC3VlnHp0N3RfbYtIHq0shCyObLnLwKM6GThhkj So5BCCKuK9PSgLMsDbvlgPToocvYvQJhyAYaFJPuGV2cmlb6bjmpJ1bgrDQxUEaoFK7q8/7WG/r iAk13VkhS30UEimQrLACuCdKyaz6xnZ01gUm5nBNdbSNR37tUKatUSkyezPbktGepGOULYU2gt0 znz9NQfKSCqogoz/BlDBzIONahKJxVJzpZRm9Z0o1razeOQUHFGxHCJNoCLjiureo4veO+kLHJC yk/bWS3JPwXfAefI53zq8NOlwlzwh38Tz11SAOybq+l6Mf7aqAlPKIR5qNZ8IIJTzCRcUVe+bYx C4nICLLHjM= X-Received: by 2002:a05:600c:4584:b0:495:6713:9a62 with SMTP id 5b1f17b1804b1-49567139f63mr6189235e9.1.1784616092535; Mon, 20 Jul 2026 23:41:32 -0700 (PDT) Received: from OrangePi5-Plus.BB-HOME (20014C4E1B88AD00DA0BF9DB4519DBD6.dsl.pool.telekom.hu. [2001:4c4e:1b88:ad00:da0b:f9db:4519:dbd6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63ed1911sm38837951f8f.22.2026.07.20.23.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 23:41:32 -0700 (PDT) From: Igor Paunovic To: Dmitry Osipenko , Mauro Carvalho Chehab Cc: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Paunovic Subject: [PATCH v4 3/4] arm64: dts: rockchip: add HDMI RX audio on RK3588 Date: Tue, 21 Jul 2026 08:41:14 +0200 Message-ID: <20260721064115.64809-4-royalnet026@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260721064115.64809-1-royalnet026@gmail.com> References: <20260721064115.64809-1-royalnet026@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Synopsys HDMI RX controller exposes two digital audio interfaces, one for I2S (0) and one for S/PDIF (1). Add the #sound-dai-cells property so audio cards can reference them as a codec, as documented by the snps,dw-hdmi-rx binding. Add a shared simple-audio-card routing the receiver I2S DAI to i2s7_8ch, the receive-only I2S interface dedicated to HDMI RX, with the receiver as bitclock and frame master. The card is named "RK3588 HDMI-IN", which is what users see in alsamixer and what ALSA UCM matches on. It mirrors the existing HDMI TX sound cards in this file and is disabled by default, since not every RK3588 board routes HDMI RX audio; boards that do only need to flip its status. Signed-off-by: Igor Paunovic Reviewed-by: Dmitry Osipenko Reviewed-by: Sebastian Reichel --- Changes in v4 (both suggested by Sebastian Reichel): - define the whole sound card here as a shared, disabled-by-default node mirroring the HDMI TX cards, instead of per board - name the card "RK3588 HDMI-IN": the name is user-visible in alsamixer and matched by ALSA UCM New in v3 (as "add #sound-dai-cells to the RK3588 HDMI receiver"). arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi b/arch/arm64/bo= ot/dts/rockchip/rk3588-extra.dtsi index a264001..e0dce15 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi @@ -23,6 +23,23 @@ }; }; =20 + hdmi_receiver_sound: hdmi-receiver-sound { + compatible =3D "simple-audio-card"; + simple-audio-card,format =3D "i2s"; + simple-audio-card,name =3D "RK3588 HDMI-IN"; + simple-audio-card,bitclock-master =3D <&hdmiin_codec>; + simple-audio-card,frame-master =3D <&hdmiin_codec>; + status =3D "disabled"; + + hdmiin_codec: simple-audio-card,codec { + sound-dai =3D <&hdmi_receiver 0>; + }; + + simple-audio-card,cpu { + sound-dai =3D <&i2s7_8ch>; + }; + }; + reserved-memory { #address-cells =3D <2>; #size-cells =3D <2>; @@ -338,6 +355,7 @@ reset-names =3D "axi", "apb", "ref", "biu"; rockchip,grf =3D <&sys_grf>; rockchip,vo1-grf =3D <&vo1_grf>; + #sound-dai-cells =3D <1>; status =3D "disabled"; }; =20 --=20 2.53.0 From nobody Sat Jul 25 01:34:40 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 9F80A41DE0E for ; Tue, 21 Jul 2026 06:41:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616097; cv=none; b=iO+dNEVSAbpQSMxhmarFz3nztAIMkUzdkowRbv+bpoq1Q/uZ3pwMesRHy1UCH4qS4HeafMG/9pJlEoLaXZMdAt0+9JLi0cRSMyJksMyKzaGF9uq3PuTQOrUFSOuSoi5jR4udl1GrLCtTboX6pSP19dfKD0loFlt6ELhik3KkIQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784616097; c=relaxed/simple; bh=9Drvmm6eZgZJWLuFZTzhkGMZGn+ydW2PC/MLrOA5jQE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iiCJ2TGTmibPjQt5lR39U+qOQhviwtavV1nQToweFZbytybHaVfCh031mntEoYLhD1TVPGOrtxYWhHGfPUG11tX7ErEdWTwm9MAr0K2PbzoT38TEUTCZgvI8jf7VJKXxC380bLFF+//klJOLrW/S8JNP1mzBkVxsBH5QFULP0WU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=oTJqU97z; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oTJqU97z" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49253e951cdso6285215e9.1 for ; Mon, 20 Jul 2026 23:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784616094; x=1785220894; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ulPEDLH/C//NrEG8Ra6a2W7BH2SJyZZBWy1vtB32mys=; b=oTJqU97zLjEeGzs1OmJHVgwmpUnMBs0oH8EnVHnLQBB8iSGOT1IeJDXMOv/rvAmsm9 AN/LAiCvnKAOuW0mAMqLovfDT37nHrT3YQPBUMKwXHjjQKIWUQ1/Es/lDYjdNU7kIhIz k0+NYqgeNs/778scsao7qx4PRVIGM/PfjSocnC1eJ1CfH1sjjaILu3F/1p8ehPyTtEi/ UjbQcTgD8yL5eTrmJfLTeW/IBB9592EXUda1MgtsxXVtBMYN3zzDIFhf2CGABb0lWvda LaZwLztyRXhQhQv9ICv4s2qgXm6ZtX3Cgueb+eLXloUJB4rCrd8zjJOxDXMORQznOKpj 6wnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784616094; x=1785220894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ulPEDLH/C//NrEG8Ra6a2W7BH2SJyZZBWy1vtB32mys=; b=LqqKwzb2Kw2Kfu78EfWH8xrwwpQgi1krejPLxuZXN/i0SVtZTfIkN3GRsw95tbim3a Goj96hpmjvIarO4+FEb+uEU6+2wZ3JkAjQ3+orQlMzaoEUlZ0c/Q94cFQxs79uuV060R j8IEuBQ5sSoIBBCWOI4nfLU1uSlQP8YlwWyOFtu4fd3hJc+kWtG51oMU1J5doIA7mXtj aTOTH+n3+jB8PLxKvaLImGOnf+94fq3xDeKfyyP6XeJl4zJcxGiB/uJRjmYqGRokuF2w 0I8Es86JRCLhTA339U/4jyYTAtT0a3RKOiK06o3ByC0mQzWk+2Gf557A2bKcVBAx5OaN tYPg== X-Forwarded-Encrypted: i=1; AHgh+RrDWVuL9xmpP94lEJUESZDlYuVkghRoiLK+swldBthIhfCphdqHNU1xnAY/MBfINlUPUEwxoWpAegSxF44=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9PnlAm0sQIartJjYzy6Zk8sihOg6BTDxV6g0WnHhh2COZQZ9x rRTHSq8rF4kAZDIMiUz3C9SdnUxCI3ZA6iKT/kALE2jiOIV4ZzhMwKvW6WO0uKl8 X-Gm-Gg: AfdE7cmqxuH9hcteKkQUZjoCc4xbugv44F2p6iJliVc0LXOEIJfXZPLXiv9e+ttyKFo 7qzNOQLfK454u6LsaFLzZBCcXZ4QYPbqx46XG42vHiwRM35p5mJosG/93epL9qbq71E3tqJRqrL w0BvzoVqwimnmbfSCrJK+W0Zfi4L87hPlI569zeXtfLOHE6bYBolGQTmpcEHPADAGv3DGHXzciU o3M/+y8ovdSLvdnvU2hEq6gzP1lf6HSt109R1eKBfSr/sEZyS0O0m6MIzDaWcbozGH3N1fHS/CZ r9ZRHxB/gzsuNBTT+2V+G+Yh0Sb2FkgnuTqNu4qqymRliL+R//pPuCX9CWPePW5kxKXws84PYQk 2a4VuH/KpYc5QESqcT3RtHC0DqM7Doo2VSpHURes0S1PFYCXQdqNP9qogedgu0lVUDRS2Wd+qOl is3e3LL2FZpz+DEbYZytG5sWmFjFBy8W68IGrgBO4apcKMo8+TBDWqSlHEYFd5Z+dHPm/ZsnbpN 7kVfDfby08= X-Received: by 2002:a05:600c:1911:b0:495:59af:7a5e with SMTP id 5b1f17b1804b1-4956598fb80mr11601215e9.5.1784616093905; Mon, 20 Jul 2026 23:41:33 -0700 (PDT) Received: from OrangePi5-Plus.BB-HOME (20014C4E1B88AD00DA0BF9DB4519DBD6.dsl.pool.telekom.hu. [2001:4c4e:1b88:ad00:da0b:f9db:4519:dbd6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63ed1911sm38837951f8f.22.2026.07.20.23.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 23:41:33 -0700 (PDT) From: Igor Paunovic To: Dmitry Osipenko , Mauro Carvalho Chehab Cc: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Paunovic Subject: [PATCH v4 4/4] arm64: dts: rockchip: enable HDMI RX audio capture on Orange Pi 5 Plus Date: Tue, 21 Jul 2026 08:41:15 +0200 Message-ID: <20260721064115.64809-5-royalnet026@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260721064115.64809-1-royalnet026@gmail.com> References: <20260721064115.64809-1-royalnet026@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enable the shared HDMI RX sound card and the i2s7_8ch interface it uses. Together with the audio capture support in the snps_hdmirx driver this exposes a capture-only ALSA card fed by the HDMI input. Tested on the Orange Pi 5 Plus with multiple HDMI sources: capture follows the source sample rate and stays in sync via the FIFO-level clock tracking in the driver. Signed-off-by: Igor Paunovic Reviewed-by: Dmitry Osipenko Reviewed-by: Sebastian Reichel --- Changes in v4: - only enable the shared hdmi_receiver_sound card and i2s7_8ch, now that the card definition lives in rk3588-extra.dtsi (Sebastian Reichel) New in v3. arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts b/arch= /arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts index 9950d11..9f9a303 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts +++ b/arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-plus.dts @@ -171,6 +171,10 @@ status =3D "okay"; }; =20 +&hdmi_receiver_sound { + status =3D "okay"; +}; + &hdptxphy0 { status =3D "okay"; }; @@ -247,6 +251,10 @@ status =3D "okay"; }; =20 +&i2s7_8ch { + status =3D "okay"; +}; + &led_blue_gpio { gpios =3D <&gpio3 RK_PA6 GPIO_ACTIVE_HIGH>; status =3D "okay"; --=20 2.53.0