linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Heiko Stuebner <heiko@sntech.de>
Cc: kernel@collabora.com, linux-input@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org
Subject: Re: [PATCH 3/4] arm64: dts: rockchip: add analog audio to ROCK 4D
Date: Wed, 2 Jul 2025 12:49:29 +0300	[thread overview]
Message-ID: <422d8ca6-00b6-4c69-b261-b0399d12c9d8@collabora.com> (raw)
In-Reply-To: <20250630-rock4d-audio-v1-3-0b3c8e8fda9c@collabora.com>

On 6/30/25 1:19 PM, Nicolas Frattaroli wrote:
> The RADXA ROCK 4D, like many other Rockchip-based boards, uses an ES8388
> analog audio codec. On the production version of the board, the codec's
> LOUT1 and ROUT1 pins are tied to the headphone jack, whereas pins LOUT2
> and ROUT2 lead to a non-populated speaker amplifier that itself leads to
> a non-populated speaker jack. The schematic is still haunted by the
> ghosts of those symbols, but it clearly marks them as "NC".
> 
> The 3.5mm TRRS jack has its microphone ring (and ground ring) wired to
> the codec's LINPUT1 and RINPUT1 pins for differential signalling.
> 
> Furthermore, it uses the SoCs ADC to detect whether the inserted cable
> is of headphones (i.e., no microphone), or a headset (i.e., with
> microphone). The way this is done is that the ADC input taps the output
> of a 100K/100K resistor divider that divides the microphone ring pin
> that's pulled up to 3.3V.
> 
> There is no ADC level difference between a completely empty jack and one
> with a set of headphones (i.e., ones that don't have a microphone)
> connected. Consequently headphone insertion detection isn't something
> that can be done.
> 
> Add the necessary codec and audio card nodes. The non-populated parts,
> i.e. LOUT2 and ROUT2, are not modeled at all, as they are not present on
> the hardware.
> 
> Also, add an adc-keys node for the headset detection, which uses an
> input type of EV_SW with the SW_MICROPHONE_INSERT keycode. Below the
> 220mV pressed voltage level of our SW_MICROPHONE_INSERT switch, we also
> define a button that emits a KEY_RESERVED code, which is there to model
> this part of the voltage range as not just being extra legroom for the
> button above it, but actually a state that is encountered in the real
> world, and should be recognised as a valid state for the ADC range to be
> in so that no "closer" ADC button is chosen.
> 
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>

Enabled CONFIG_SND_SOC_ES8328_I2C and confirm playback works fine:

    $ speaker-test -D hw:ES8388,0 -F S16_LE -c 2 -t wav

Unfortunately the recording doesn't seem to be functional:

    $ arecord -D hw:ES8388,0 -f S16_LE -c 2 -r 48000 -d 5 -V stereo /tmp/test.wav
    Recording WAVE '/tmp/test.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
                                    +00%|00%+

    $ aplay -D hw:ES8388,0 /tmp/test.wav

However, the headset plug detection works correctly:

    $ evtest
    No device specified, trying to scan all of /dev/input/event*
    Available devices:
    /dev/input/event0:	Logitech USB Receiver
    /dev/input/event1:	Logitech USB Receiver Mouse
    /dev/input/event2:	Logitech USB Receiver Consumer Control
    /dev/input/event3:	Logitech USB Receiver System Control
    /dev/input/event4:	adc-keys
    Select the device event number [0-4]: 4
    Input driver version is 1.0.1
    Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
    Input device name: "adc-keys"
    Supported events:
      Event type 0 (EV_SYN)
      Event type 1 (EV_KEY)
      Event type 5 (EV_SW)
        Event code 4 (SW_MICROPHONE_INSERT) state 0
    Properties:
    Testing ... (interrupt to exit)
    Event: time 1751449448.185340, type 5 (EV_SW), code 4 (SW_MICROPHONE_INSERT), value 1
    Event: time 1751449448.185340, -------------- SYN_REPORT ------------
    Event: time 1751449448.289477, type 5 (EV_SW), code 4 (SW_MICROPHONE_INSERT), value 0
    Event: time 1751449448.289477, -------------- SYN_REPORT ------------
    Event: time 1751449449.329482, type 5 (EV_SW), code 4 (SW_MICROPHONE_INSERT), value 1
    Event: time 1751449449.329482, -------------- SYN_REPORT ------------

Tested-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>


  reply	other threads:[~2025-07-02  9:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30 10:19 [PATCH 0/4] ROCK 4D audio enablement Nicolas Frattaroli
2025-06-30 10:19 ` [PATCH 1/4] dt-bindings: input: adc-keys: allow linux,input-type property Nicolas Frattaroli
2025-06-30 11:37   ` Heiko Stübner
2025-06-30 10:19 ` [PATCH 2/4] Input: adc-keys - support types that aren't just keyboard keys Nicolas Frattaroli
2025-06-30 11:49   ` Heiko Stübner
2025-06-30 10:19 ` [PATCH 3/4] arm64: dts: rockchip: add analog audio to ROCK 4D Nicolas Frattaroli
2025-07-02  9:49   ` Cristian Ciocaltea [this message]
2025-06-30 10:19 ` [PATCH 4/4] arm64: dts: rockchip: add HDMI audio on " Nicolas Frattaroli
2025-07-02  8:57   ` Cristian Ciocaltea
2025-07-10  9:27 ` (subset) [PATCH 0/4] ROCK 4D audio enablement Heiko Stuebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=422d8ca6-00b6-4c69-b261-b0399d12c9d8@collabora.com \
    --to=cristian.ciocaltea@collabora.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=nicolas.frattaroli@collabora.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).