CreatorDev / lede-source

Ci40 LEDE port (pre-alpha)
GNU General Public License v2.0
1 stars 2 forks source link

Add audio support #9

Open Ham22 opened 7 years ago

Ham22 commented 7 years ago

Port over all the audio patches including synchronisation features: CreatorDev/openwrt#237 and CreatorDev/openwrt#242 were closed down after cleanup but the work was just pushed to a temporary branch for now TODO-put-link-to-branch-here in order to simplify upstreaming.

Main considerations are:

Acceptance criteria:

ghost commented 7 years ago

It seems that there is a bug within binutils-2.25. I managed building speaker-test with binutil-2.27. Also, to avoid the CPU DAI (null) not registered error at boot, I had to load some modules before pistachio.ko:

diff --git a/target/linux/pistachio/modules.mk b/target/linux/pistachio/modules.mk
index 3e69c3997ccf..a85e8cfda8e1 100644
--- a/target/linux/pistachio/modules.mk
+++ b/target/linux/pistachio/modules.mk
@@ -30,7 +30,7 @@ define KernelPackage/sound-pistachio-soc
        $(LINUX_DIR)/sound/soc/img/pistachio-internal-dac.ko \
        $(LINUX_DIR)/sound/soc/img/pistachio-event-timer.ko \
        $(LINUX_DIR)/sound/soc/img/pistachio-event-timer-atu.ko
-  AUTOLOAD:=$(call AutoLoad,68,pistachio pistachio-internal-dac pistachio-event-timer-atu)
+  AUTOLOAD:=$(call AutoLoad,68,img-i2s-in img-i2s-out img-parallel-out img-spdif-in img-spdif-out pistachio-internal-dac pistachio-event-timer-atu pistachio)
   $(call AddDepends/sound)
 endef
ghost commented 7 years ago

Adding packages I enabled by default for audio support:

diff --git a/target/linux/pistachio/profiles/00-default.mk b/target/linux/pistachio/profiles/00-default.mk
index f40be3d66774..2776c04d8923 100644
--- a/target/linux/pistachio/profiles/00-default.mk
+++ b/target/linux/pistachio/profiles/00-default.mk
@@ -8,7 +8,7 @@
 define Profile/Default
   NAME:=Default Profile
   PRIORITY:=1
-  PACKAGES:=
+  PACKAGES:=kmod-sound-pistachio-soc alsa-lib alsa-utils alsa-utils-tests
 endef

 define Profile/Default/Description
Ham22 commented 7 years ago

With above changes and the dts changed to include the following config this has been seen to work using speaker-test -D hw:0,2 -F S32_LE -c 2 as a test vector but all the code hasn't yet been added to a nice commit.

pistachio_audio_card {             
        img,i2s-clk-loopback;      
        i2s-out {                  
                continuous-clock;  
        };                         
};                                 
&gpio4 {                                        
        hp_amp_en {                             
                gpio-hog;                       
                gpios = <15 GPIO_ACTIVE_LOW>;   
                output-high;                    
                line-name = "hp-amp-en";        
        };                                      
};   
Ham22 commented 7 years ago

The current issues so far have been down to porting the sound card to kernel 4.9 hence have created a ticket in the linux repo to track that work. This task is blocked on completing it https://github.com/CreatorDev/linux/issues/5 .