[Letux-kernel] (Letux/Alpha 400: small progress with sound) - CI20 sound

H. Nikolaus Schaller hns at goldelico.com
Sat May 1 21:31:29 CEST 2021

Hi Paul and Maarten,

> Am 01.05.2021 um 08:51 schrieb H. Nikolaus Schaller <hns at goldelico.com>:
> Hi Paul,
>> Am 30.04.2021 um 00:20 schrieb Paul Boddie <paul at boddie.org.uk>:
>> Yes, this is very strange. Although there are device tree nodes in the 3.18 
>> kernel files, I don't find the corresponding drivers. There is audio support 
>> in the HDMI driver, but since I use a DVI monitor, I never tried to use the 
>> audio on the CI20 since the cable won't be passing on any audio signal. But I 
>> imagine that there must be HDMI audio support because there was some effort to 
>> get video playback working with a special version of MPlayer, as I recall.
> I have looked through the 3.18 kernel and there is an "old style sound board file":
> sound/soc/jz4780/ci20.c
> which is compatible = "ingenic,ci20-audio"
> This defines two dai links. Apparently one which is called "headphones" and one
> called "hdmi". Both seem to use the jz4780-i2s. Difference is in the codecs:
> dw-hdmi-audio vs. jz4780-codec.
> So the hdmi audio seems to be part of a more general ci20 audio driver than
> "simple-audio-card". This raises another question: should we forward port
> the ci20-audio.c driver or try to make simple-audio-card work?
> Anyways the codec driver can be found in sound/soc/codecs/jz4780.c
> So I will replace the attempt to modify the jz4770 driver to use the one
> from the 3.18 kernel...

Ok, that was easier than it initially looked. I had to cross-port some
minor improvements from the jz4770 driver to the jz4780 and the main task was
to change the soc_codec etc. to soc_component and track how to get the
struct pointer dereferencing right again.

One major observation is that the jz4780 codec driver turns on clocks before
reading/writing the ragmap backed up registers. This is not part of the jz4770
code and may be the reason why my initial attempts with that driver failed.

The more challenging part was to make the ci20-audio (board) driver work since
it initializes both channels for the headset and HDMI audio of the CI20.

Fortunately, the dw-hdmi-i2s-audio driver is already upstream so I only had to
configure and compile it.

I haven't tried if I really get sound (have to find a 2.5mm headset first and
my HDMI monitor has no speakers), but this is what I can see:

root at letux:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ci20 [ci20], device 0: headphones 100200a4.audio-codec-0 [headphones 100200a4.audio-codec-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: ci20 [ci20], device 1: hdmi i2s-hifi-1 [hdmi i2s-hifi-1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
root at letux:~# amixer 
Simple mixer control 'Master',0
  Capabilities: pvolume cvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: Playback 0 - 31 Capture 0 - 63
  Front Left: Playback 25 [81%] [on] Capture 51 [81%]
  Front Right: Playback 25 [81%] [on] Capture 51 [81%]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Front Left: Playback 22 [71%] [on]
  Front Right: Playback 22 [71%] [on]
Simple mixer control 'Mic',0
  Capabilities: cvolume cvolume-joined cswitch cswitch-joined
  Capture channels: Mono
  Limits: Capture 0 - 7
  Mono: Capture 0 [0%] [off]
Simple mixer control 'ADC',0
  Capabilities: cenum
  Items: 'AIP1' 'AIP2'
  Item0: 'AIP1'
root at letux:~#

There is also a headset detect in /dev/input/event*.

From an architecture point if view a key question will be if we want
to have the CI20 board file or if we can replace it by the simple-audio-card
driver like the lb60 did a while ago:

	91c7db5e7c652 "ASoC: jz4740: Drop lb60 board code"

I'll consolidate these changes a little and post them here for all CI20
users. Maybe someone wants to volunteer to help upstreaming (defining the
DAI links should IMHO be done better through device tree) ...

But it looks as if I can now (maybe after fixing some smaller bugs)
compare CI20 sound to Alpha 400 sound and find out differences in
i2s and DMA which seem the blocking components for Alpha 400.


More information about the Letux-kernel mailing list