KGL Unit + USB DAC SABRE ES9023

R4D3N

Senior Member
Dec 23, 2008
174
38
0
Following the instructions below, I managed to get my USB DAC to work. I will attach the drivers that worked for me.

So, I am glad to say, we have USB Audio (DACs) support now.
If you want to build a serious car sound system, you have to make a digital out to your amp (or DSP) instead of using our head units line outs.
I will try to write in more detail and more simply as to repeat it.
For the redirection of all sounds of the Android to your USB device (a sound card, DAC) it is necessary:
1. To be convinced that a system's kernel version is 3.0.36+ . The version of a firmware can be any. At me I was KLD-1.98 and 4.2.2. But despite it I pulled out driver modules from a tablet firmware on the Android 4.4.2.
2. Get root, root explorer and Android terminal emulator.
3. Copy by root explorer USB Audio support modules *.ko from the applied archive in /system/lib/modules/, and set them permissions to 0644.
4. It is obligatory to try loading modules manually from the terminal exactly in that order:
Code:
[email protected]:/ $ su
[email protected]:/ # insmod /system/lib/modules/snd-hwdep.ko
[email protected]:/ # insmod /system/lib/modules/snd-rawmidi.ko
[email protected]:/ # insmod /system/lib/modules/snd-usbmidi-lib.ko
[email protected]:/ # insmod /system/lib/modules/snd-usb-audio.ko
If the device reboots at execution of this commands, these drivers don't suit to you (though probability of it is small as our HU are identical)
If system silently swallowed your commands - everything normally, we go further.
5. Connect your USB device to one of the back USB ports intended for 3G/Wifi (as we surely need port with support of USB-host).
6. In the terminal enter the following commands and check your device, what number it was defined.
Code:
[email protected]:/ # ls dev/snd
controlC0
controlC1
controlC2
pcmC0D0c
pcmC0D0p
pcmC1D0p
[COLOR="Red"]pcmC2D0c
pcmC2D0p[/COLOR]
timer
[email protected]:/ # cat /proc/asound/cards
0 [RK29WM8731 ]: RK29_WM8731 - RK29_WM8731
RK29_WM8731
1 [RKHDMII2S ]: RK-HDMI-I2S - RK-HDMI-I2S
RK-HDMI-I2S
[COLOR="red"]2 [Headset ]: USB-Audio - Plantronics Headset
Plantronics Plantronics Headset at usb-usb20_host-1.3, full speed[/COLOR]
[email protected]:/ #
Apparently from replies of system, my test Plantronics headset received the address pcmC2D0p - that is Card 2 Device 0. Remembered these figures. Due to the identical architecture of our HU, I think, it will be similar for all of us.
7. To make modules *.ko were loaded at each start of a system, it is necessary to copy by root explorer install-recovery.sh script from archive to /system/etc/install-recovery.sh, set permissions 0755.
8. For providing the redirection of a sound to our USB device it is necessary to deceive system. For this purpose it is necessary to replace number of the device (card) in file /system/lib/hw/audio.primary.rk30board.so. You need find 'pcmC0D0p' string and change it to your remembered value (pcmC2D0p, I think so). It is best of all to make it on the computer by any binary files editor. But I put already my edition of the audio.primary.rk30board.so file with pcmC2D0p value. Don't forget to set it permission 0644. And it is obligatory to make a backup of the original file for ability to return to an initial state.

At step 7. my unit looses root capability, therefore I created a script that runs after boot with Script manager.

The script contains the following:

insmod /system/lib/modules/snd-hwdep.ko
insmod /system/lib/modules/snd-rawmidi.ko
insmod /system/lib/modules/snd-usbmidi-lib.ko
insmod /system/lib/modules/snd-usb-audio.ko

At step 8, I didn't find that PCM in my unit so I used another audio.primary.rk30board.so file. I will attach it below.


Problems:

After the sound was rerouted to the DAC, I discovered that I can't control the volume.

Therefore, I bought USB AUdio Player PRO. Now I can control volume, but only from the app, the buttons still doesn't work.

!!!!!! I want to change the tracks from the buttons + SWC and the volume too.

I tried Headunit app, but it doesn't do anything with this player.

PS: Viper4Android doesn't work with this app too.

Instead, Viper4Android works with stock musicplayer but I can't control the volume over HiFimeDIY Sabre USB DAC ES9023 96kHz/24bit


PS2: After I start the USB Audio Player PRO App, I get no sound in other applications. If I don't start that app, I get sound in stock Music Player, Youtube, PowerAmp, etc.
 

Attachments

Last edited:

R4D3N

Senior Member
Dec 23, 2008
174
38
0
I have found that I can control the volume with the following command:

alsa_amixer -c N cset numid=X Y

Where:
N is the number of the card
X is the option corresponding to the volume
y is the value of the volume

In my case, maximum volume is 110 and minimum is 0

Example of command in my case:

alsa_amixer -c 2 cset numid = 2 100

Can someone please make a widget/app or integrate it somehow in Headunit so that I can control the volume?

I would be very grateful.
 

aluver

Senior Member
Aug 30, 2014
150
35
0
I have found that I can control the volume with the following command:




Where:
N is the number of the card
X is the option corresponding to the volume
y is the value of the volume

In my case, maximum volume is 110 and minimum is 0

Example of command in my case:




Can someone please make a widget/app or integrate it somehow in Headunit so that I can control the volume?

I would be very grateful.
Here is my edition of last version (2.15) of RK3066-Headunit-service
My edition is able to change the volume levels of DAC and HU together - in same percentage.
DAC volume is changing by command:
Code:
alsa_amixer -c2 sset 'PCM' X%
where 2 - is a card number of DAC (for our HU is always 2)
PCM is the name of alsa volume simple control of Sabre U2 (and many others DACs too)
X% - the value of volume, % - always equal to internal volume of HU, that calculating from 0...30 to 0...100 "exponentialy" by microntek service.
And by the way it also can switch folders/albums in Poweramp through API-commands NEXT_IN_CAT / PREVIOUS_IN_CAT (my wheel buttons codes for it - 61, 62; yours may be different).
I wrote to petrows (developer of this RK3066-Headunit-service) about this modification and asked him to include this functionality to next versions.
 
Last edited:

R4D3N

Senior Member
Dec 23, 2008
174
38
0
Thank you very much. It works but now I have another problem.

After 10-15 minutes, the volume control stops working. It remains or at maximum volume or at the last volume that was set up.

Any ideas how to fix this?
 

R4D3N

Senior Member
Dec 23, 2008
174
38
0
Volume+ doesn't work over my DAC.


Headunit does, but after 15 minutes stops working, but if I clear data or restart the Headunit application it works again for 15 minutes.

Any ideas?


PS: SHould I give special permissions to Headunit app? Before it was 0777 and now I am trying with 0644 and I will get back with review.
 
Last edited:

aluver

Senior Member
Aug 30, 2014
150
35
0
Thank you very much. It works but now I have another problem.

After 10-15 minutes, the volume control stops working. It remains or at maximum volume or at the last volume that was set up.

Any ideas how to fix this?
I have had this problem, but only once. Not depends from time in my case. Fixed by reboot too. I think you need to check the direct capability of alsa_amixer to change the dac volume from terminal when it happened again.
Code:
su
alsa_amixer -c2 sset 'PCM' 50%
If it will work, i think the problem is your SU is only for 15 minutes for application. Check your root preferences.

---------- Post added at 07:51 PM ---------- Previous post was at 07:44 PM ----------

I gues sthe problem is that your volume knob does not control android's volume but send commands to MCU.

Could you try using "Volume+" App to control volume if that works?
Our RK3066 HU doesn't have this functional - android volume change is blocked by ROM. Tried this some time earlier.
Alsa mixer was used on this reason. Service just catches microntek MCU volume changes and sends alsa_amixer commands with the same value of volume in %.
 

R4D3N

Senior Member
Dec 23, 2008
174
38
0
I tried but It won't appear in Superuser because when I run it, it doesn't prompt for Root Privilleges, it just runs. How can I manually add it to Superuser?


PS: I am using Malaysk's latest firmware for RK3188.
 

R4D3N

Senior Member
Dec 23, 2008
174
38
0
I installed SuperSU, i granted permanent SuperUser for Headunit but I have the same problem. After a while, the volume control stops working. It works again only if I reboot or if I clear data of the Headunit program.

Ideas?
 

aluver

Senior Member
Aug 30, 2014
150
35
0
I installed SuperSU, i granted permanent SuperUser for Headunit but I have the same problem. After a while, the volume control stops working. It works again only if I reboot or if I clear data of the Headunit program.

Ideas?
When you clear data of the Headunit program, it restarts. So, you just give it 15 min of work with root-access again. Try to delete in SuperSU access rule for this service and reboot. When it will ask for root, give it permanent root. Or you can choose in SuperSU permanent root for all applications.
 

R4D3N

Senior Member
Dec 23, 2008
174
38
0
Thank you very much. I got that working too, I now I have only one problem.

Everytime I power one the unit or when it powers from sleep the volume is at 100% and after I press the volume button it changes at the value on the screen.

Is there a way the set set the default volume as MUTE or 10% ?
 

aluver

Senior Member
Aug 30, 2014
150
35
0
If this happens after cold start too, I have the one idea only. Your sevice is starting too early, before the DAC determined by system. Check your startup sequences scripts.
Insmod-commands must be at first positions of install-recovery.sh
mtcservice must be launched by install-recovery-2.sh
There is no problem for me with Malaysk fw #23.
default install-recovery-2.sh from there:
Code:
#dsa
lsd () {
	to=$1
	shift
	for i in $*; do
		if [ -d $i ]; then
			i=${i%/}
			j=${i##*/}
			if [ "${j#com.tomtom.*}" != "$j" ]; then
				k=$((k+1))
				j=$to/$j
				if [ -n "`ls $j`" ]; then continue; fi
				mkdir -p $j
				if mount | grep "$j "; then umount $j; fi
				mount -o bind $i $j
			else
				lsd $to $i/*/
			fi
		fi
	done
}

{
IFS=${IFS#??}
while ! mount | grep "/mnt/internal_sd "; do sleep 1; done
ck=0
while true; do
	k=0
	
	#########################################################################
	### lsd syntax:                                                       ###
	### First argument is the target (internal) folder.                   ###
	### Further arguments make a list of source (external) storage paths. ###
	### If any com.tomtom.* folder is found in any source path tree,      ###
	### it will be (bind) mounted under the target folder.                ###
	#########################################################################
	lsd /mnt/internal_sd/tomtom /mnt/external_sd*/*/ /mnt/usb_storage*/*/

	if [ $k -gt 0 ]; then
		ck=0
		sleep 20
		continue
	fi
	if [ $ck -ge 90 ]; then
		sleep 30
	else
		ck=$((ck+1))
		sleep 1
	fi
done
} >/dev/null 2>&1 &

getpid () {
	ps | busybox sed -n "/busybox sed -n/! s/[^ ]* *\([0-9]*\).*$1.*/\1/p"
}

while true; do
	
	pid=`getpid maxmpz`
	if [ -z "$pid" -o "$pid" != "$pap" ]; then
		om=0
		st=0
		while true; do
			st=$((st+1))
			nm=`mount | grep usb_storage | busybox wc -l`
			if [ $nm -ne $om ]; then
				om=$nm
				st=0
			else
				if [ $st -gt 3 ]; then
					if [ $nm -gt 0 ]; then
						usb=1
						break
					fi
					if [ -z "$usb" ]; then
						break
					fi
					st=0
				fi
			fi
			if [ $nm -gt 0 ]; then
				sleep 1
			else
				sleep 3
			fi
		done
		while ! am startservice -a com.maxmpz.audioplayer.API_COMMAND --ei cmd 3; do sleep 1; done
		sleep 2
		pap=`getpid maxmpz`
	fi


	pid=`getpid petrows`
	if [ -z "$pid" ]; then
		while ! am startservice com.petrows.mtcservice/.ServiceMain; do sleep 1; done
		sleep 1
	fi
	
	
	sleep 10
done &
As you can see startservice com.petrows.mtcservice exists here by default.
I have just replaced old mtcservice apk by new own edition.
PS: Answer with quotes please, because it's the only way to get an E-mail notification for me. I visit this place very rarely.
 

peti007

Senior Member
Nov 20, 2014
125
16
0
Tatabánya
Does anyone use any RCA mixer or other stuff with DAC to use the built in BT handsfree and FM radio? If I understand good need to connect the DAC and the head unit's RCA outputs to the amplifier in same time.
I found this: Rolls MX22A it is an active mixer, or a passive diy mixer good enough for us?
Or anybody tired the Behringer UCA202/UCA222? It has RCA input and monitor output.

I haven't got any DAC, so I can't try it, but thinking of buying one.
 
Last edited:

aluver

Senior Member
Aug 30, 2014
150
35
0
Does anyone use any RCA mixer or other stuff with DAC to use the built in BT handsfree and FM radio? If I understand good need to connect the DAC and the head unit's RCA outputs to the amplifier in same time
If you want to built SQ system, don't do this. This way is wrong - you'll loose the sound quality your DAC gives. Just leave one pair of speakers (coax at rear?) plugged to front speaker outs of your HU and all dirt will live there :) with BT and radio. You'll CAN hear sound from them, when you need that, but the noise from line outs of HU shouldn't be mixed to your clear music stream ;)
The real music must be at front only: 2-way, 3-way, with sub, etc.
 

peti007

Senior Member
Nov 20, 2014
125
16
0
Tatabánya
If you want to built SQ system, don't do this. This way is wrong - you'll loose the sound quality your DAC gives. Just leave one pair of speakers (coax at rear?) plugged to front speaker outs of your HU and all dirt will live there :) with BT and radio. You'll CAN hear sound from them, when you need that, but the noise from line outs of HU shouldn't be mixed to your clear music stream ;)
The real music must be at front only: 2-way, 3-way, with sub, etc.
If I listen to FM radio, the HU's RCA out sounds and the DAC is muted, if I listen to music over DAC the HU's RCA is muted.
Maybe I'm wrong, but if I connect the HU's front RCA out and the DAC's RCA out to the RCA mixer in the same time, it doesn't mean they both sound in the same time. There is noise on the HU's RCA too when no sound came out from it?