nikkov Posted December 7, 2017 Share Posted December 7, 2017 If you want get just play function, you can use my Volumio image for NanoPi-Neo. But unfortunately I now don't have experience with overlays now Link to comment Share on other sites More sharing options...
codekipper Posted December 7, 2017 Share Posted December 7, 2017 (edited) It would make more sense to work with the mainline driver and fix issues with it over than working with this sun8i-i2s driver. So from what I read you have an external G-Dis DAC and some highly accurate clock board which you wish to clock both the dac and SoC with. What other connections do you have from the nanopi?, are the gpio's mentioned in the overlay used? Overlays should be fairly straight forward, can you try this?. // Definitions for G-Dis DAC /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-h3"; fragment@0 { target = <&i2s0>; __overlay__ { pinctrl-0 = <&i2s0_pins>; pinctrl-names = "default"; status = "okay"; }; }; fragment@1 { target-path = "/"; __overlay__ { i2s0_out: i2s0-out { #sound-dai-cells = <0>; compatible = "linux,spdif-dit"; }; sound_i2s { simple-audio-card,name = "G-Dis DAC"; compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,bitclock-master = <&codec_dai>; simple-audio-card,frame-master = <&codec_dai>; simple-audio-card,mclk-fs = <256>; status = "okay"; simple-audio-card,cpu { sound-dai = <&i2s0>; }; codec_dai: simple-audio-card,codec { sound-dai = <&i2s0_out>; }; }; }; }; }; What did you use to get it working with the Raspberry pi?, CK Edited December 7, 2017 by codekipper code update Link to comment Share on other sites More sharing options...
Georgios Fevgidis Posted December 10, 2017 Share Posted December 10, 2017 I must start saying thank you for trying helping me. I am back in Stockholm now and I will try your suggestion tomorrow. I am loading this overlay to RPi /dts-v1/; /plugin/; / { compatible = "brcm,bcm2708"; fragment@0 { target = <&i2s>; __overlay__ { status = "okay"; }; }; fragment@1 { target-path = "/"; __overlay__ { pcm1794a_codec: pcm1794a_codec { #sound-dai-cells = <0>; compatible = "ti,pcm1794a"; status = "okay"; }; }; }; fragment@2 { target = <&sound>; __overlay__ { compatible = "simple-audio-card"; simple-audio-card,name = "G-Dis-DAC"; simple-audio-card,format = "right_j"; simple-audio-card,bitclock-master = <&codec_dai>; simple-audio-card,frame-master = <&codec_dai>; status="okay"; cpu_dai: simple-audio-card,cpu { sound-dai = <&i2s>; dai-tdm-slot-num = <2>; dai-tdm-slot-width = <32>; }; codec_dai: simple-audio-card,codec { sound-dai = <&pcm1794a_codec>; }; }; }; }; I agree with you about using the mainline driver but according to some answers earlier in the thread I thought it didnt supported slave mode. I can post some pictures of my dac/reclocking board ao you can see how it looks like. Link to comment Share on other sites More sharing options...
codekipper Posted December 10, 2017 Share Posted December 10, 2017 OK, we can reuse most of the working overlay and adapt it for the h3. Slave mode should be supported by the mainline driver but I've not tested it, however I do have a master codec in the post which should get to me sometime this week. Do you have access to a logic analyser?, BR, CK Link to comment Share on other sites More sharing options...
nikkov Posted December 10, 2017 Share Posted December 10, 2017 6 minutes ago, codekipper said: OK, we can reuse most of the working overlay and adapt it for the h3. Slave mode should be supported by the mainline driver but I've not tested it, however I do have a master codec in the post which should get to me sometime this week. Do you have access to a logic analyser?, BR, CK Slave mode assume that externals source of the bit- and lr-clocks controls by driver, but I can't saw where is it. And as I see mainline driver support only 16 bit sample. I worked with friendlyarm's variant because it was most complete. Now I want modify mainline driver for support 16/24 bit master/slave and test it on nanopi neo (2, air) and cubietruck. Link to comment Share on other sites More sharing options...
codekipper Posted December 10, 2017 Share Posted December 10, 2017 mainline should support slave mode https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/sunxi/sun4i-i2s.c?h=v4.15-rc2#n502 there is also a few patches which I haven't delivered yet here https://github.com/codekipper/linux-sunxi/commits/sunxi-wip however I still need to test these properly before pushing for mainline. I'm also trying to come up with a cleaner solution for when the codec expects 32bits frame width. 1 Link to comment Share on other sites More sharing options...
nikkov Posted December 10, 2017 Share Posted December 10, 2017 3 minutes ago, codekipper said: mainline should support slave mode https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/sunxi/sun4i-i2s.c?h=v4.15-rc2#n502 there is also a few patches which I haven't delivered yet here https://github.com/codekipper/linux-sunxi/commits/sunxi-wip however I still need to test these properly before pushing for mainline. I'm also trying to come up with a cleaner solution for when the codec expects 32bits frame width. Thank you for information. I only now began to understand mainline driver. I have some hardware (cubietruck, nanopi neo and nanopi neo 2), clocks board (schematic attached) and simple logic analyzer. I can try testing your modification. neoclock - Project.pdf Link to comment Share on other sites More sharing options...
codekipper Posted December 10, 2017 Share Posted December 10, 2017 please do....I've currently got a logic analyser on my pcm5102a boards and I'm seeing issues with the clock division which I will address. It would be good to have someone testing on an older board as my A20 EVB is no longer booting. Link to comment Share on other sites More sharing options...
nikkov Posted December 10, 2017 Share Posted December 10, 2017 1 hour ago, codekipper said: please do....I've currently got a logic analyser on my pcm5102a boards and I'm seeing issues with the clock division which I will address. It would be good to have someone testing on an older board as my A20 EVB is no longer booting. OK, I'll built fresh armbian image for nanopi neo and can check your code. One question: why oversample rates started with 128 but not 64 (32 bit frame) or 32 (16 bit frame)? Link to comment Share on other sites More sharing options...
codekipper Posted December 10, 2017 Share Posted December 10, 2017 I guess we've just never had all the possible information, the oversample rates were documented in the A20 user manual (128 was the lowest)but not in the later iterations. Link to comment Share on other sites More sharing options...
nikkov Posted December 10, 2017 Share Posted December 10, 2017 Quick info about testing. - nanopi neo - armbian image builded from github sources - i2s module by codekipper - overlay from codekipper's post (but simple-audio-card,mclk-fs = <128>). Because my clock board without pins control works on 176400 all test with this sample rate: aplay -c 2 -f S16_LE -r 176400 /dev/urandom - working and I see some data on dout pinaplay -c 2 -f S24_LE -r 176400 /dev/urandom - aplay: pcm_write:2011: write error: Input/output erroraplay -c 2 -f S32_LE -r 176400 /dev/urandom - no error and zero data on dout pin Link to comment Share on other sites More sharing options...
codekipper Posted December 10, 2017 Share Posted December 10, 2017 Congratulations, this is the first time slave clock has been utilised on the mainline driver. Do you have my debug enabled?, it would be nice to see register settings during playback. I'll follow the same test procedures when I get my new codec. Link to comment Share on other sites More sharing options...
Georgios Fevgidis Posted December 10, 2017 Share Posted December 10, 2017 I did some testing today and I can tell that the overlay you suggested works just fine both as slave and right justified format. I only played 16/44 tracks (feeding nanopi neo with a 2.8224 MHz bitclock and a 44.1 KHz LRclock from my clockcard). My setup is almost identical as nikkov except for the external clock card I will do some more testing and report back. I have some small issues with pops and clicks when the nanopi is in pause state but I dont think it has something to do with the software. Link to comment Share on other sites More sharing options...
nikkov Posted December 11, 2017 Share Posted December 11, 2017 10 hours ago, codekipper said: Congratulations, this is the first time slave clock has been utilised on the mainline driver. Do you have my debug enabled?, it would be nice to see register settings during playback. I'll follow the same test procedures when I get my new codec. Yes, your debug output I see in kernel.log For full-fledged testing, I need to add a codec driver to specify the hardware modes for my clocks board: i2s mode; 32 bit frame size independents from sample size; divider for BCLK/LRCLK driven by GPIO. I'll try made this in near time. Link to comment Share on other sites More sharing options...
nikkov Posted December 11, 2017 Share Posted December 11, 2017 16 hours ago, codekipper said: I guess we've just never had all the possible information, the oversample rates were documented in the A20 user manual (128 was the lowest)but not in the later iterations. Yes, I found this values in A20 user manual. But it's related only for master mode i2s which clocked by PLL, and can't used for external clock and slave mode bus. So we must check oversample value only for master mode! Link to comment Share on other sites More sharing options...
Christos Posted December 23, 2017 Author Share Posted December 23, 2017 @codekipper @nikkov Hi, Is there any advancement in having 24/32bit, 192KHz, concurently playback and capture with I2S ? Any patch we could give it a try and test in 4.14? Season greetings to all. Link to comment Share on other sites More sharing options...
codekipper Posted December 23, 2017 Share Posted December 23, 2017 I've been distracted by the audioinjector codec of late and it's driven some changes that I'll push later once tested with other hardware https://github.com/codekipper/linux-sunxi/commits/audioinjector CK Link to comment Share on other sites More sharing options...
Christos Posted December 24, 2017 Author Share Posted December 24, 2017 @codekipper I hope if its not too much, can you or someone create a patch for Armbian. Link to comment Share on other sites More sharing options...
nikkov Posted January 3, 2018 Share Posted January 3, 2018 On 23.12.2017 at 8:57 PM, codekipper said: I've been distracted by the audioinjector codec of late and it's driven some changes that I'll push later once tested with other hardware https://github.com/codekipper/linux-sunxi/commits/audioinjector CK I checked your wip i2s driver code with my hardware and simple codec driver for my clock board. In function sun4i_i2s_set_clk_rate calculates lrck value as (clk_rate / rate / oversample_rate)*word_size and we have, eg (22579200 / 44100 / 128) * 16 = 64 of BCLKs within each channel. But in stereo i2s mode lrck value must be equal slot width. In stable version lrck fixed and equal 32. After I replace calculated value lrck to fixed 32 I successfully played 16/24 bit sample. Link to comment Share on other sites More sharing options...
Pavel Löbl Posted January 5, 2018 Share Posted January 5, 2018 (edited) I have PCM5102a DAC I would like to use with my OrangePI PC. I currently use latest mainline from armbian. Can someone guide me a little how to get it work? Do I need to additional kernel modules for DAC to work? Or all I need is to provide DT overlay? Something like it was done here: https://github.com/codekipper/linux-sunxi/commit/a2142b12269970daa1e3895a413a7e19230f9530 EDIT: Ups. I just noticed this thread is in devel section. So If nobody replies I will ask in support group. Edited January 5, 2018 by Pavel Löbl probably wrong board section Link to comment Share on other sites More sharing options...
guidol Posted March 20, 2018 Share Posted March 20, 2018 I decompiled the sun8i-h3-nanopi-neo.dts from FriendlyARM for the complete hardware in a mainline kernel to a .dts : dtc -I dtb -O dts -o ./sun8i-h3-nanopi-neo.dts ./sun8i-h3-nanopi-neo.dtb Is there any change to get from this .dts a working i2s0 overlay-dts for armbian mainline? I did try to cut out the i2s & pcm5102a parts..... but I think there is also a recompile of the kernel necessary? Iam a bit stuck what I can do with these parts The friendlyARM mainline image des disable i2c1 and does enable is20 like for we did here in the forum for the legacy kernel in the .fex file: sudo bin2fex script.bin script.fex sudo nano script.fex [twi1] twi_used = 1 ==> twi_used = 0 [pcm0] daudio_used = 0 ==> daudio_used = 1 sudo fex2bin script.fex script.bin i2s_parts_sun8i-h3-nanopi-neo.dts sun8i-h3-nanopi-neo.dts Link to comment Share on other sites More sharing options...
felipeduque Posted April 12, 2018 Share Posted April 12, 2018 Hi all. I'm still struggling to capture I2S audio on my OrangePi PC (H3), mainline kernel. I've followed all steps by @Valery Rezvyakov and was able to see the I2S input device with arecord -l, just like @Christos. However, audio is not captured properly: there is an annoying DC offset at about 99% of maximum output value, thus only downwards signal excursion is possible (in fact, they are captured, as I can see them with Audacity). I'm using Adafruit SPH0645 I2S microphone as the capture device, and it's not a hardware problem because it works perfectly with legacy kernel. Audio format in both cases (legacy and mainline) is S16_LE. My suspicion is that the adau7002 driver is not suitable for my mic, but I was not able to find out where to meddle with. Link to comment Share on other sites More sharing options...
burak Posted August 23, 2018 Share Posted August 23, 2018 On 4/12/2018 at 1:59 PM, felipeduque said: Hi all. I'm still struggling to capture I2S audio on my OrangePi PC (H3), mainline kernel. I've followed all steps by @Valery Rezvyakov and was able to see the I2S input device with arecord -l, just like @Christos. However, audio is not captured properly: there is an annoying DC offset at about 99% of maximum output value, thus only downwards signal excursion is possible (in fact, they are captured, as I can see them with Audacity). I'm using Adafruit SPH0645 I2S microphone as the capture device, and it's not a hardware problem because it works perfectly with legacy kernel. Audio format in both cases (legacy and mainline) is S16_LE. My suspicion is that the adau7002 driver is not suitable for my mic, but I was not able to find out where to meddle with. Can anyone help a poor soul? Yes it is not a hardware problem, or it is in an indirect way... Your legacy kernel works with it because it,kernel, does modify your settings on the ALSA layer probably. I don't want to go into details that I am not confident. However, I have used the same I2S microphone with NanoPi NEO which is another H3 board. Simply, your mic doesn't support S16_LE, if you read its datasheet you can see that it sends 24 bit data, last 6 bits are nulls. However, I couldn't manage to set my I2S driver to 24 bits, logic analyzer showed that clocks are not properly set for that mode -- since I am not a kernel expert, I couldn't dive into registers and fix this --. So, I modified my devicetree file as well as sun4i-i2s.c file with @codekipper 's patches and some others combined with my educated guesses. When I run `arecord` I do use `S16_LE`. However, on my devicetree file, there is a override for this and it is set to 32 bits. This way you can use your mics. Since you're trying to use 16-bit at the moment, alsa thinks there is a saturation on the data, mic sends 18 bit data in a 24bit package. This is the issue that you're facing. Link to comment Share on other sites More sharing options...
felipeduque Posted August 23, 2018 Share Posted August 23, 2018 @burak That's good to know. However, I'm struggling to make the proper changes to sun4i-i2s.c and device tree stuff. Would you be willing to share the files you had to change? Link to comment Share on other sites More sharing options...
guidol Posted September 21, 2018 Share Posted September 21, 2018 On 3/20/2018 at 10:06 PM, guidol said: sudo bin2fex script.bin script.fex sudo nano script.fex [twi1] twi_used = 1 ==> twi_used = 0 [pcm0] daudio_used = 0 ==> daudio_used = 1 sudo fex2bin script.fex script.bin today I udated my legacy NanoPi Neo to ARMBIAN 5.60 stable Debian GNU/Linux 8 (jessie) 3.4.113-sun8i Linux neo-pcm5102a 3.4.113-sun8i #68 SMP PREEMPT Wed Sep 19 10:23:30 CEST 2018 armv7l GNU/Linux and the pcm5102a Audio module didnt work anymore because of a new "script.bin" at /boot/bin/nanopineo.bin lrwxrwxrwx 1 root root 17 Nov 25 2017 script.bin -> bin/nanopineo.bin So I had to redo the changes to the .bin/.fex like before: cd /boot/bin bin2fex nanopineo.bin nanopineo.fex nano /boot/bin/nanopineo.fex : [twi1] twi_used = 0 [pcm0] daudio_used = 1 Spoiler [twi1] twi_used = 0 twi_scl = port:PA18<3><default><default><default> twi_sda = port:PA19<3><default><default><default> [pcm0] daudio_used = 1 daudio_master = 4 daudio_select = 1 audio_format = 1 signal_inversion = 1 mclk_fs = 128 sample_resolution = 16 slot_width_select = 32 pcm_lrck_period = 32 pcm_lrckr_period = 1 msb_lsb_first = 0 sign_extend = 0 slot_index = 0 slot_width = 32 frame_width = 0 tx_data_mode = 0 rx_data_mode = 0 i2s_mclk = port:PA18<2><1><default><default> i2s_bclk = port:PA19<2><1><default><default> i2s_dout0 = port:PA20<2><1><default><default> i2s_din = port:PA21<2><1><default><default> fex2bin nanopineo.fex nanopineo.bin reboot and the pcm5102a soundcard is available like before the update: root@neo-pcm5102a(addr:192.168.6.24):~# aplay -l **** List of PLAYBACK Hardware Devices **** card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sndcodec-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0card 1: snddaudio [snddaudio], device 0: SUNXI-TDM0 snddaudio-0 [] Subdevices: 0/1 Subdevice #0: subdevice #0 card 2: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 Link to comment Share on other sites More sharing options...
Georgios Fevgidis Posted September 29, 2018 Share Posted September 29, 2018 Hi I am using codekeppers suggested overlay in mainline kernel as I2S slave with my external clock board BUT after playing one or two tracks I notice that the channels swap. Do anyone else noticed that? Is there any solutions for that? Link to comment Share on other sites More sharing options...
dony71 Posted November 14, 2018 Share Posted November 14, 2018 On 11/13/2017 at 5:22 PM, Valery Rezvyakov said: make linux-menuconfig (by buildroot) Device Drivers ----->Sound card support ----->Advanced Linux Sound Archtecture ------>ALSA for Soc audio support --------->Allwinner Soc Audio support [*]Allwinner A10 I2S Support patch: diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig index 22408bc..7842de4 100644 --- a/sound/soc/sunxi/Kconfig +++ b/sound/soc/sunxi/Kconfig @@ -30,8 +30,10 @@ config SND_SUN8I_CODEC_ANALOG config SND_SUN4I_I2S tristate "Allwinner A10 I2S Support" + depends on OF select SND_SOC_GENERIC_DMAENGINE_PCM select REGMAP_MMIO + select SND_SOC_PCM5102A help Say Y or M if you want to add support for codecs attached to the Allwinner A10 I2S. You will also need to select the On the Orange: dpkg -i linux-headers-next-sunxi_5.34_armhf.deb file sun8i-h3-I2S-out.dts : armbian-add-overlay sun8i-h3-I2S-out.dts reboot results: root@orangepipc:~# uname -a Linux orangepipc 4.13.12-sunxi #6 SMP Tue Nov 14 02:58:07 MSK 2017 armv7l GNU/Linux root@orangepipc:~# cat /proc/asound/cards 0 [I2Smaster ]: I2S-master - I2S-master I2S-master 1 [Codec ]: H3_Audio_Codec - H3 Audio Codec H3 Audio Codec 2 [allwinnerhdmi ]: allwinner_hdmi - allwinner,hdmi allwinner,hdmi root@orangepipc:~# dmesg |grep i2s [ 9.529374] asoc-simple-card sound_i2s: pcm5102a-hifi <-> 1c22000.i2s mapping ok [ 10.406113] asoc-simple-card sound: i2s-hifi <-> 1c22800.i2s mapping ok root@orangepipc:~# aplay -l **** List of PLAYBACK Hardware Devices **** card 0: I2Smaster [I2S-master], device 0: 1c22000.i2s-pcm5102a-hifi pcm5102a-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Codec [H3 Audio Codec], device 0: CDC PCM Codec-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: allwinnerhdmi [allwinner,hdmi], device 0: 1c22800.i2s-i2s-hifi i2s-hifi-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 @Valery Rezvyakov I try released version Armbian 5.65 for Banana-Pi-M2+ and find out I2S and HDMI audio doesn't work aplay -l shows ----------------- root@bananapim2plus:/boot/overlay-user# aplay -l **** List of PLAYBACK Hardware Devices **** card 0: Codec [H3 Audio Codec], device 0: CDC PCM Codec-0 [] Subdevices: 1/1 Subdevice #0: subdevice #0 card 2: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio] Subdevices: 1/1 Subdevice #0: subdevice #0 So I follow your instruction above but I don't understand where you execute this "make linux-menuconfig (by buildroot)" ? I follow this cross-compile builing kernel https://docs.armbian.com/Developer-Guide_Build-Preparation/ But I cannot execute "make linux-menuconfig" Link to comment Share on other sites More sharing options...
felipeduque Posted November 14, 2018 Share Posted November 14, 2018 @dony71 The "make linux-menuconfig" stuff is just saying that you need to compile the kernel with the "Allwinner A10 I2S Support" option enabled. You can do it by several means, one of which is the "make linux-menuconfig", but I don't remember how to do it. However, you can compile the kernel using Vagrant. That's how I've always done. Link to comment Share on other sites More sharing options...
dony71 Posted November 15, 2018 Share Posted November 15, 2018 OK, I manage to compile kernel module and copy them into my Banana-Pi-M2+ However it gives me error below .... what's wrong? snd-soc-pcm5102a already copied into that directory root@bananapim2plus:/boot# modprobe snd-soc-pcm5102a modprobe: FATAL: Module snd-soc-pcm5102a not found in directory /lib/modules/4.14.78-sunxi Link to comment Share on other sites More sharing options...
markbirss Posted November 15, 2018 Share Posted November 15, 2018 On 11/20/2017 at 9:05 AM, nikkov said: Not related to armbian, but I made some work with friendlyarm kernel 4.11.2 for support i2s driver for h3/h5 with support 16/24 bit master/slave mode i2s (link) and build Volumio image for nanopi neo (link). In future I want to get same in mainline kernel. @nikkov also not armbian related, any chance you tried this or want to try ? NanoPi-NEO2 の I2SでMCLK出力 & 384kHz, 768kHz, 1536kHz, 8kHz https://qiita.com/blue-7/items/d643cc9e441ca594a01e http://www.single-ended.com/Nanopi-neo.htm Link to comment Share on other sites More sharing options...
Recommended Posts