A20 mainline kernel questions

406 views
Skip to first unread message

Alexis Jeandet

unread,
Aug 23, 2015, 7:25:06 AM8/23/15
to linux-sunxi
Hi,

I wonder if I can and how to use a olinuxino lime 2 on LCD(via LVDS) with mainline kernel. I'm using fedora since it shows a good upstream policy(I feel) and I use it everywhere.
From what I understand, for now u-boot is supposed to init the screen and then kernel just use simple-fb, is it correct? I just need to search on uboot side how to switch from hdmi to LCD?

Then would a UDA1380 work? I need to add sound. What I saw is that UDA driver exist but needs i2c bus so i need to tweak the dts file for lime2. Does somebody have some lights to give me on this topic?

I got really impress by the huge upstream effort done by the sunxi community! It's really nice to be able to boot a standard distrib and do kernel updates transparently, the graphic boot loader was also a big surprise for me!

Best regards,
Alexis.

Alexis Jeandet

unread,
Aug 23, 2015, 11:50:19 AM8/23/15
to linux-sunxi
I received one answer by mail, init of lcd screen is done by u-boot, I found useful informations by looking in u-boot/configs/ folder and with some grep and looking tablets defconfig files. At least it works on my "no-name" a20 tablet I will try later on lime2, I didn't received the lcd cable yet.

useful options for lcd(in my case):
CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:45,ri:209,up:22,lo:22,hs:1,vs:1,sync:3,vmode:0"
CONFIG_VIDEO_LCD_POWER="PH8"
CONFIG_VIDEO_LCD_BL_EN="PH7"
CONFIG_VIDEO_LCD_BL_PWM="PB2"

Alexis.

Andrea Venturi

unread,
Aug 24, 2015, 9:40:05 AM8/24/15
to linux-sunxi


Il giorno domenica 23 agosto 2015 13:25:06 UTC+2, Alexis Jeandet ha scritto:
Hi,

...

Then would a UDA1380 work?


hello,

on mainline, you can patch a kernel source code then the I2S device and the UDA1380 codec "someway" work, at least for audio playing
you'll find the relevant patches here, actually:


anyway a more polished development tree is on-going at least for the I2S side, so that source could be outdated shortly..

then, the UDA1380 codec, AFAICS, will still need the aforementioned patch so it can be loaded and configured through the DTS.

i'll need to work out the patch prior of a proper motivated submission to alsa-soc because as it is, it's more or less a proof of concept.

if you want to play with it, you are of course welcome. 

I need to add sound. What I saw is that UDA driver exist but needs i2c bus so i need to tweak the dts file for lime2. Does somebody have some lights to give me on this topic?

enabling a I2C bus on the A20, should just a matter  of a dts line. 

at least for me it was as simple as adding this stuff in the DTS:

....
&i2c1 { 
        pinctrl-names = "default";
        pinctrl-0 = <&i2c1_pins_a>;
        status = "okay";

        /* added for test with I2S waveshare codec board based on UDA1380 */
        ext_codec: uda1380@18 {
                #sound-dai-cells = <0>; /* added for dmesg err: "could not get #sound-dai-cells for " */
                compatible = "nxp,uda1380";
                reg = <0x18>;
                /* reset-gpio = <&pio 7 3 GPIO_ACTIVE_HIGH>; */
                /* 
                 * commented out so uda1380_probe move forward..
                 * otherwise get: asoc-simple-card sound: ASoC: failed to instantiate card -16
                 * power-gpio = <&pio 7 11 GPIO_ACTIVE_HIGH>; 
                 */
                dac-clk = <1>; // SYSCLK=0, WSPLL=1
        };

};

feel free to write here about any issues, if you test something..

bye

andrea

Alexis Jeandet

unread,
Aug 24, 2015, 3:34:37 PM8/24/15
to linux-sunxi
Hi Andrea,

Thank you for your answer, I also got one from code keeper with a link to his git repo here.
After some tweaks(uboot scripts and kernel config for systemd) I successfully booted his kernel.
Now I need to do some soldering to connect the uda board to the lime2, I will do that tomorrow and give some results.

Best regards,
Alexis.

Alexis Jeandet

unread,
Aug 25, 2015, 5:00:36 PM8/25/15
to linux-sunxi

Hi,

I did the connections today, it doesn't work yet here is the kernel output:

[    1.603394] asoc-simple-card sound: uda1380-hifi <-> 1c22400.i2s mapping ok
[    1.610467] uda1380-codec 1-0018: ASoC: mux Capture Mux has no paths
[    1.616961] uda1380-codec 1-0018: ASoC: Failed to create Playback debugfs file
[    1.624212] uda1380-codec 1-0018: ASoC: Failed to create Capture debugfs file
[    1.631831] uda1380-codec 1-0018: uda1380_sync_cache: write to reg 0x1 failed
[    1.639054] uda1380-codec 1-0018: uda1380_sync_cache: write to reg 0x2 failed
[    1.646291] i2c i2c-1: mv64xxx_i2c_fsm: Ctlr Error -- state: 0x6, status: 0x38, addr: 0x18, flags: 0x0
[    1.651912] ata1: SATA link down (SStatus 0 SControl 300)
[    1.660989] uda1380-codec 1-0018: uda1380_sync_cache: write to reg 0x3 failed
[    1.681903] usb 1-1: new high-speed USB device number 2 using ehci-platform
[    3.191912] cfg80211: Calling CRDA to update world regulatory domain
[    3.661900] i2c i2c-1: mv64xxx: I2C bus locked, block: 1, time_left: 0
[    3.668428] uda1380-codec 1-0018: uda1380_sync_cache: write to reg 0x4 failed

looks like an i2c connection problem, my pinout is this one:
A20 Side                    |   UDA side
PB5     I2S0_MCLK  -> TXMCLK
PB6     I2S0_BCLK   -> TXCLK
PB7     I2S0_LRCK   -> TXWS
PB8     I2S0_D0       -> TXDA
PB12  I2S0_DI         -> RXDA

PB18 I2C1_SCK -> SCL
PB19 I2C1_SDA    -> SDA

I will try to look more in details tomorrow.

Best regards,
Alexis.

Alexis Jeandet

unread,
Aug 26, 2015, 11:45:45 AM8/26/15
to linux-sunxi
Now I2C works :), I can see 2 sound cards in /proc/asound,
Here is the output of  sudo aplay -l :
**** List of PLAYBACK Hardware Devices ****
card 0: sunxicodec [sunxi-codec], device 0: CDC PCM Codec-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sunxii2sdaiuda1 [sunxi-i2s-dai-uda1380-hifi], device 0: sunxi
-i2s-dai-uda1380-hifi uda1380-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I use this to switch from card 0 to 1
sudo  amixer -c 1 -- sset Master Playback 0dB

I play with this:
sudo aplay -vv someWaveFile.wav

But I still don't get any sound, any hint?

Best regards,
Alexis.

Andrea Venturi

unread,
Aug 27, 2015, 2:56:22 AM8/27/15
to linux-sunxi


Il giorno mercoledì 26 agosto 2015 17:45:45 UTC+2, Alexis Jeandet ha scritto:
Now I2C works :), I can see 2 sound cards in /proc/asound,
....

I use this to switch from card 0 to 1
sudo  amixer -c 1 -- sset Master Playback 0dB

I play with this:
sudo aplay -vv someWaveFile.wav

But I still don't get any sound, any hint?

greati. 

i suppose it's a matter of "alsamixer" and some UDA controls..

if you tweak some regs on the far right, IIRC some with "double" "quadruple" and other option, you'll hear music.

the MCLK link is not used anyway in my setup, as with WSPLL=1 the UDA synths the system clock from the WS clock.
with a LA you should see the WS clocked at fs frequency (44K1 or 48K)

BTW i noticed the UDA volume controls are not working on my side, but again it could a problem of "fragile" I2C link as it's a wire on the fly.. (as i suppose it were your first issues on I2C setup, right?)

bye


 

Best regards,
Alexis.

Alexis Jeandet

unread,
Aug 27, 2015, 3:42:39 AM8/27/15
to linux-sunxi
Ok thanks for your answer, I don't any screen yet(I'm still waiting for the lime LCD ribbon) so I will play with alsa mixer later. For now I think it may be interesting to play in userspace with i2c and try to speak with the UDA, at least to see if it behaves as expected.

I also have a DSLogic analyser, if you need some captures, just tell me.

Best regards,
Alexis.

Alexis Jeandet

unread,
Aug 27, 2015, 5:53:04 AM8/27/15
to linux-sunxi
Hi Andrea,

I got slightly better results, I played with alsa and some GUI mixers like qashctl over ssh, now I can hear a click when playing a sound but, still no sound.

I also noticed that a 3 minutes sound is played in 5 seconds, here is my asound.conf to get the default output on sunxii2sdaiuda1:
=============================
pcm.!default {
    type hw
    card 1
    device 0
}

ctl.!default {
    type hw          
    card 1
}
============================

aplay also complains about 32 bits wav files, it says that this device is only compatible with 16bits signed data.
Have you seen similar behaviour?

Then last question, do you know if GUI mixers like qashctl read the dac config? If yes i means that the volume control works on my side. Anyway I can hear some clik in the headphone when playing with some parameters on qashctl.

Best reagards,
Alexis.

Andrea Venturi

unread,
Aug 27, 2015, 11:16:47 AM8/27/15
to linux-sunxi


Il giorno giovedì 27 agosto 2015 11:53:04 UTC+2, Alexis Jeandet ha scritto:
Hi Andrea,

I got slightly better results, I played with alsa and some GUI mixers like qashctl over ssh, now I can hear a click when playing a sound but, still no sound.


umhh.. i feel you are quite there.. let me check again my HW setup, where i have only tested playback working.

me, i have, SDA, SDCL then RXWS, RXCLK and RXSDA connected to relevant pins of A20 SOM EVB

don't know if 32bit WAV works..

me i know it's working with mplayer and a sample called Equinox coming from here:

 http://www0.cs.ucl.ac.uk/teaching/GZ05/samples/equinox-48KHz.wav
 http://www0.cs.ucl.ac.uk/teaching/GZ05/samples/

===
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
===

hope it helps..

Alexis Jeandet

unread,
Aug 28, 2015, 9:11:47 AM8/28/15
to linux-sunxi
Hi Andrea,

Good news! I can hear some sounds :). After some discussions with Marcus I've checked I2S pins with logic analyser, the data where at the output but really fast (340kS/s). I decided to replace the I2S driver from Marcus repo  with your code(only sunxi-i2s.c plus sunxi.h). At least I can hear sound, it still refuse to play 32 bits wave file(with aply) and my sample is read at twice the speed(looks like mickey mouse) but it works! With the sample you provided it works at nominal speed, I think(not easy to say).
If you are interested here are the screenshots of what I saw with Marcus patch:
https://www.dropbox.com/s/t2cn38hl5aywwiz/Capture%20d%27%C3%A9cran%20de%202015-08-27%2014-18-08.png?dl=0

As a conclusion, on Marcus repo I2C works but something broke on I2S code.

Best regards,
Alexis.

Andrea Venturi

unread,
Aug 30, 2015, 4:41:42 AM8/30/15
to linux-sunxi


Il giorno venerdì 28 agosto 2015 15:11:47 UTC+2, Alexis Jeandet ha scritto:
Hi Andrea,

Good news! I can hear some sounds :).

good!
 
After some discussions with Marcus I've checked I2S pins with logic analyser, the data where at the output but really fast (340kS/s). I decided to replace the I2S driver from Marcus repo  with your code(only sunxi-i2s.c plus sunxi.h). At least I can hear sound, it still refuse to play 32 bits wave file(with aply) and my sample is read at twice the speed(looks like mickey mouse) but it works!

is your sample a mono (single channel) one?

i had the "speed doubling" when i tested a mono wav file. i suppose there's a bug as it's still sending samples to two channels. so the speed is doubled..
  
With the sample you provided it works at nominal speed, I think(not easy to say).

you are right. my sample indeed has no "words spoken" so it's not easy to say... but if you feel good and inspired listening to it, so it's working ok ! :-)

bye

andrea

Alexis Jeandet

unread,
Aug 30, 2015, 7:55:14 AM8/30/15
to linux-sunxi
Hi Andrea,

Indeed my song is mono, so that may explain the issue.

I also continued to investigate the code from Marcus, which if I understood correctly, is based on your code. I got some successful results also with this code. I think that Marcus wanted to merge the two structures sunxi_priv and sunxi_i2s_info and remove the sunxi_iis instance.

There is still some points I don't get yet, if I understand correctly the UDA is supposed to generate the sysclock with it's own PLL from bclk? Then you have to set the multiplication factor on the UDA? For each song? Or you just set it to 256 or 128fs and then just focus on i2s interface? In this case 24 bits resolution wouldn't be possible? Don't understand yet what ALSA does exactly, and I didn't check what is done on i2c side.

Best regards,
Alexis.

Andrea Venturi

unread,
Aug 31, 2015, 2:31:44 AM8/31/15
to linux-sunxi


Il giorno domenica 30 agosto 2015 13:55:14 UTC+2, Alexis Jeandet ha scritto:
Hi Andrea,

Indeed my song is mono, so that may explain the issue.


ok
 
I also continued to investigate the code from Marcus, which if I understood correctly, is based on your code. I got some successful results also with this code. I think that Marcus wanted to merge the two structures sunxi_priv and sunxi_i2s_info and remove the sunxi_iis instance.


yes; the sunxi_iis is a leftover of the original legacy AW driver and the useful fields should be folded into the "private" data structure of the relevant  alsa module.


There is still some points I don't get yet, if I understand correctly the UDA is supposed to generate the sysclock with it's own PLL from bclk?

IIRC it's a PLL from the "left right" clock (ie frame rate 44.1 or 48 KHz) and the proper UDA register is set when there's WSPLL=1 on device tree..
 
Then you have to set the multiplication factor on the UDA? For each song?

for earch sample rate.. 
 
Or you just set it to 256 or 128fs and then just focus on i2s interface? In this case 24 bits resolution wouldn't be possible?

the bit clock is a multiple of the FS changing when you have different bit resolutions.

Code Kipper

unread,
Aug 31, 2015, 3:38:29 PM8/31/15
to Andrea Venturi, linux-sunxi
On 31 August 2015 at 08:31, Andrea Venturi <ennesim...@gmail.com> wrote:
>
>
> Il giorno domenica 30 agosto 2015 13:55:14 UTC+2, Alexis Jeandet ha scritto:
>>
>> Hi Andrea,
>>
>> Indeed my song is mono, so that may explain the issue.
>>
>
> ok
>
>>
>> I also continued to investigate the code from Marcus, which if I
>> understood correctly, is based on your code. I got some successful results
>> also with this code. I think that Marcus wanted to merge the two structures
>> sunxi_priv and sunxi_i2s_info and remove the sunxi_iis instance.
>
>
>
> yes; the sunxi_iis is a leftover of the original legacy AW driver and the
> useful fields should be folded into the "private" data structure of the
> relevant alsa module.
>
>>
>> There is still some points I don't get yet, if I understand correctly the
>> UDA is supposed to generate the sysclock with it's own PLL from bclk?
>
Hi All,
I've now joined the working i2s club...managed to get my uda1380
singing but there are a few quirks that I will need to look at. For
example my audio test file of choice doesn't output audio(it's
44.1KHz) and skips through the file quickly. If I play a 48KHz file I
get audio and then if I go back to the original audio file then it
works. It looks like none of the clock divisors are being set up
correctly..and I will check the logs tomorrow. I've also been able to
play 192KHz files but then if I play them again then it plays slow.
BR,
CK
>
> IIRC it's a PLL from the "left right" clock (ie frame rate 44.1 or 48 KHz)
> and the proper UDA register is set when there's WSPLL=1 on device tree..
>
>>
>> Then you have to set the multiplication factor on the UDA? For each song?
>
>
> for earch sample rate..
>
>>
>> Or you just set it to 256 or 128fs and then just focus on i2s interface?
>> In this case 24 bits resolution wouldn't be possible?
>
>
> the bit clock is a multiple of the FS changing when you have different bit
> resolutions.
>
>>
>> Don't understand yet what ALSA does exactly, and I didn't check what is
>> done on i2c side.
>>
>> Best regards,
>> Alexis.
>
> --
> You received this message because you are subscribed to the Google Groups
> "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to linux-sunxi...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Alexis Jeandet

unread,
Aug 31, 2015, 3:38:41 PM8/31/15
to linux-sunxi
Hi,

I put this link here, it's a good aditionnal doc for alsa:
http://processors.wiki.ti.com/index.php/AM335x_Audio_Driver's_Guide

I was looking the uda code today and I wonder if the driver doesn't need some love also, I'm not totally sure that the I2c reg cache is correctly synchronised with the chip register. It may come from my alsa/pulseaudio setup but I need to tweak the volume some times and retry several times to play a file before I get correctly some sound. It looks like the chip isn't correctly configured after boot.

Alexis.

On Monday, August 31, 2015 at 8:31:44 AM UTC+2, Andrea Venturi wrote:


Il giorno domenica 30 agosto 2015 13:55:14 UTC+2, Alexis Jeandet ha scritto:
Hi Andrea,

Indeed my song is mono, so that may explain the issue.


ok
 
I also continued to investigate the code from Marcus, which if I understood correctly, is based on your code. I got some successful results also with this code. I think that Marcus wanted to merge the two structures sunxi_priv and sunxi_i2s_info and remove the sunxi_iis instance.


yes; the sunxi_iis is a leftover of the original legacy AW driver and the useful fields should be folded into the "private" data structure of the relevant  alsa module.
I did this, and seems to work, sent this modifications to Marcus.


There is still some points I don't get yet, if I understand correctly the UDA is supposed to generate the sysclock with it's own PLL from bclk?

IIRC it's a PLL from the "left right" clock (ie frame rate 44.1 or 48 KHz) and the proper UDA register is set when there's WSPLL=1 on device tree..
Yes I saw that, thanks for the clarification.

Alexis Jeandet

unread,
Sep 1, 2015, 4:42:58 AM9/1/15
to linux-sunxi, ennesim...@gmail.com
I saw this behaviour also, If you play 3 time the same file it will also work. First I thought it may come from the uda driver because of i2c registers cache but it seems ok. It looks like a problem with the order the things are done, maybe some register should be set in a different order on i2s side? In more elaborated datasheet you usually get some procedure to initialise the device and to configure it.
Reply all
Reply to author
Forward
0 new messages