Where is HAL source code of networking and audio.

371 views
Skip to first unread message

YoungJoon Lee

unread,
Jun 29, 2017, 9:37:08 PM6/29/17
to Android-x86
Hello, I have USB LTE modem and it is driven by module sierra.ko. I don't change any setting. Just build android x86 makes it working and I can use internet.

But, there is no ethernet connection icon on bar on top.

And when I activate wifi, my usb modem is unable until reboot. I guess it is because HAL of network device has problem with my Modem. I want to modify it. Somebody help me found where is rule between HAL?

Another problem is Audio device. I cannot play sound using SPDIF Digital aux. I check kernel and module. Kernel module of my Sound cards loaded on lsmod. But I can't play sound. I think it is also because of HAL. I check sound policy file on /system/etc. It looks like digital aux is written on output device.(But priority is low=Written toward behind)

Thank you for reading.

Chih-Wei Huang

unread,
Jun 29, 2017, 9:42:54 PM6/29/17
to Android-x86
2017-06-30 9:37 GMT+08:00 YoungJoon Lee <get...@gmail.com>:
> Hello, I have USB LTE modem and it is driven by module sierra.ko. I don't change any setting. Just build android x86 makes it working and I can use internet.

Good to know. Which version of android-x86 do you use?

> But, there is no ethernet connection icon on bar on top.

Ethernet icon? Why do you think that?

> And when I activate wifi, my usb modem is unable until reboot. I guess it is because HAL of network device has problem with my Modem. I want to modify it. Somebody help me found where is rule between HAL?

See hardware/ril/

> Another problem is Audio device. I cannot play sound using SPDIF Digital aux. I check kernel and module. Kernel module of my Sound cards loaded on lsmod. But I can't play sound. I think it is also because of HAL. I check sound policy file on /system/etc. It looks like digital aux is written on output device.(But priority is low=Written toward behind)

hardware/libaudio

--
Chih-Wei
Android-x86 project
http://www.android-x86.org

YoungJoon Lee

unread,
Jun 29, 2017, 10:43:09 PM6/29/17
to Android-x86
Hello. Version is nougat-x86.

I think reason of next is because of HAL. Absent if Ethernet icon connection also same reason. I will look ril. Thank uou.
> > And when I activate wifi, my usb modem is unable until reboot. I guess it is because HAL of network device has problem with my Modem. I want to modify it. Somebody help me found where is rule between HAL?
>
> See hardware/ril/

Thank you. I also look libaudio.



2017년 6월 30일 금요일 오전 10시 42분 54초 UTC+9, Chih-Wei Huang 님의 말:

YoungJoon Lee

unread,
Jun 30, 2017, 8:24:43 PM6/30/17
to Android-x86
Hello, I check my HAL sources and device.
My device has many audio devices.(Realtek alc analog, Realtek alc spdif, intel hdmi else) But What I want to use is Realtek alc hdmi.

1. module(snd-hda-intel) is not loading. 
Kernel message(dmesg) said information about my audio devices. And lspci also know which module control HW. I will attach full version of dmesg and logcat result.
[    2.723801] input: HDA Intel PCH Front Mic as /devices/pci0000:00/0000:00:1f.3/sound/card0/input5
[    2.723856] input: HDA Intel PCH Rear Mic as /devices/pci0000:00/0000:00:1f.3/sound/card0/input6
[    2.723877] input: HDA Intel PCH Line as /devices/pci0000:00/0000:00:1f.3/sound/card0/input7
[    2.723925] input: HDA Intel PCH Line Out Front as /devices/pci0000:00/0000:00:1f.3/sound/card0/input8
[    2.723968] input: HDA Intel PCH Line Out Surround as /devices/pci0000:00/0000:00:1f.3/sound/card0/input9
[    2.724002] input: HDA Intel PCH Line Out CLFE as /devices/pci0000:00/0000:00:1f.3/sound/card0/input10
[    2.724034] input: HDA Intel PCH Front Headphone as /devices/pci0000:00/0000:00:1f.3/sound/card0/input11
[    2.724067] input: HDA Intel PCH HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input12
[    2.724087] input: HDA Intel PCH HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input13
[    2.724107] input: HDA Intel PCH HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:1f.3/sound/card0/input14

1|x86_64:/ $ lspci -mk
00:1f.3 "Class 0403" "8086" "a2f0" "1043" "8723" "snd_hda_intel"
00:00.0 "Class 0600" "8086" "591f" "1043" "8694"
00:1b.3 "Class 0604" "8086" "a2ea" "1043" "8694" "pcieport"
05:00.0 "Class 0c03" "1b21" "2142" "1043" "8732" "xhci_hcd"
00:1d.0 "Class 0604" "8086" "a298" "1043" "8694" "pcieport"
00:1f.6 "Class 0200" "8086" "15b8" "1043" "8672" "e1000e"
00:1c.4 "Class 0604" "8086" "a294" "1043" "8694" "pcieport"
00:02.0 "Class 0300" "8086" "5912" "1043" "8694" "i915"
00:14.0 "Class 0c03" "8086" "a2af" "1043" "8694" "xhci_hcd"
00:1f.4 "Class 0c05" "8086" "a2a3" "1043" "8694" "i801_smbus"
00:17.0 "Class 0106" "8086" "a282" "1043" "8694" "ahci"
00:1f.2 "Class 0580" "8086" "a2a1" "1043" "8694"
03:00.0 "Class 0108" "144d" "a804" "144d" "a801" "nvme"
00:1c.0 "Class 0604" "8086" "a290" "1043" "8694" "pcieport"
00:1f.0 "Class 0601" "8086" "a2c5" "1043" "8694"
00:1b.4 "Class 0604" "8086" "a2eb" "0000" "0000" "pcieport"
02:00.0 "Class 0280" "168c" "003e" "1043" "86e0" "ath10k_pci"
00:16.0 "Class 0780" "8086" "a2ba" "1043" "8694"
00:1b.0 "Class 0604" "8086" "a2e7" "1043" "8694" "pcieport"




I think, because of missing module, alsa_aplay also doesn't know list of devices.
$ alsa_aplay -L
null
     
Discard all samples (playback) or generate zero samples (capture)


Before check my system, I think alsa_aplay -L doesn't work because of HAL's bug.

Next, I insert modules.
$ modprobe snd-hda-intel

And then,


alsa_aplay can found my deivces but sound is not working. I think priority of other device is higher and device 1 is not working.

So, I decide approach priority with next.
First, make module is loaded on boot.
Second, set proper priority or disable devices not used.

Questions.
Q1. Is my approach right?
Q2. How can I do that? I am looking for ./external/alsa-utils/alsactl/init/00main now. Is it affect to kernel loading?
Q3(Not related to this subject) There is a lot of kernel log messages start with avc: ~~~. Can I ignore these messages? Or must fix error messages? 

Other informations : I build my android on VM.(Not on physical machine.) So, I think device information generated on building time is not used.

Thank you very much for reading.


2017년 6월 30일 금요일 오전 10시 42분 54초 UTC+9, Chih-Wei Huang 님의 말:
2017-06-30 9:37 GMT+08:00 YoungJoon Lee <get...@gmail.com>:
2017년 6월 30일 금요일 오전 10시 42분 54초 UTC+9, Chih-Wei Huang 님의 말:
2017-06-30 9:37 GMT+08:00 YoungJoon Lee <get...@gmail.com>:
full_dmesg.txt
logcat.txt

YoungJoon Lee

unread,
Jul 1, 2017, 5:32:46 AM7/1/17
to Android-x86
I change kernel config. change HD-Audio from M to Yes. So, Driver will loaded automatically. Like next. 
<*> Build Realtek HD-audio codec support


and disable modules what I don't needed. Like this.
< > Build HDMI/DisplayPort HD-audio codec support



After this, Sound can play from card0 device0(Analog out)
But still not from digital(toslink).(card0 device1)

2017년 7월 1일 토요일 오전 9시 24분 43초 UTC+9, YoungJoon Lee 님의 말:

YoungJoon Lee

unread,
Jul 4, 2017, 7:42:49 AM7/4/17
to Android-x86
Hello, I still cannot play audio from spdif.

I found old approach which is change device to 0(by make analog device disable).

And I found lots of comment which said disable device from bios settings.

Is there any way to set priority of devices?

I cannot set spdif digital out's priority higher than analog because both of them is supported by realtek ALC audio cards.

If I have to make digital out to card0 device0, one way is patch kernel source. But I think it is very dirty way.

I already tried to modify HAL sources asound.conf but it is not working.

Last way is disable my realtek aound and buy spdif only ddc card.

Any ideas about this problem?

Thank you for reading. I will attach information about my devices.

-----------------------------------------------------------------------------

x86_64:/ # dmesg | grep HDA
[ 1.152481] input: HDA Intel PCH Front Mic as /devices/pci0000:00/0000:00:1f.3/sound/card0/input3
[ 1.152503] input: HDA Intel PCH Rear Mic as /devices/pci0000:00/0000:00:1f.3/sound/card0/input4
[ 1.152523] input: HDA Intel PCH Line as /devices/pci0000:00/0000:00:1f.3/sound/card0/input5
[ 1.152558] input: HDA Intel PCH Line Out Front as /devices/pci0000:00/0000:00:1f.3/sound/card0/input6
[ 1.152609] input: HDA Intel PCH Line Out Surround as /devices/pci0000:00/0000:00:1f.3/sound/card0/input7
[ 1.152649] input: HDA Intel PCH Line Out CLFE as /devices/pci0000:00/0000:00:1f.3/sound/card0/input8
[ 1.152677] input: HDA Intel PCH Front Headphone as /devices/pci0000:00/0000:00:1f.3/sound/card0/input9
[ 1.152720] input: HDA Intel PCH HDMI as /devices/pci0000:00/0000:00:1f.3/sound/card0/input10
x86_64:/ # alsa_aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: Generic Analog [Generic Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: Generic Digital [Generic Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: Generic Digital [Generic Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
x86_64:/ # alsa_amixer -c 0 sset 'Speaker Digital' on
amixer: Unable to find simple control 'Speaker Digital',0

1|x86_64:/ # alsa_amixer controls
numid=34,iface=CARD,name='Front Headphone Jack'
numid=28,iface=CARD,name='Front Mic Jack'
numid=44,iface=CARD,name='HDMI Jack'
numid=30,iface=CARD,name='Line Jack'
numid=33,iface=CARD,name='Line Out CLFE Jack'
numid=31,iface=CARD,name='Line Out Front Jack'
numid=32,iface=CARD,name='Line Out Surround Jack'
numid=29,iface=CARD,name='Rear Mic Jack'
numid=35,iface=CARD,name='SPDIF Phantom Jack'
numid=27,iface=MIXER,name='Master Playback Switch'
numid=26,iface=MIXER,name='Master Playback Volume'
numid=10,iface=MIXER,name='Headphone Playback Switch'
numid=9,iface=MIXER,name='Headphone Playback Volume'
numid=18,iface=MIXER,name='Front Mic Boost Volume'
numid=2,iface=MIXER,name='Front Playback Switch'
numid=1,iface=MIXER,name='Front Playback Volume'
numid=4,iface=MIXER,name='Surround Playback Switch'
numid=3,iface=MIXER,name='Surround Playback Volume'
numid=7,iface=MIXER,name='Center Playback Switch'
numid=5,iface=MIXER,name='Center Playback Volume'
numid=8,iface=MIXER,name='LFE Playback Switch'
numid=6,iface=MIXER,name='LFE Playback Volume'
numid=20,iface=MIXER,name='Line Boost Volume'
numid=15,iface=MIXER,name='Capture Switch'
numid=17,iface=MIXER,name='Capture Switch',index=1
numid=14,iface=MIXER,name='Capture Volume'
numid=16,iface=MIXER,name='Capture Volume',index=1
numid=25,iface=MIXER,name='IEC958 Default PCM Playback Switch'
numid=40,iface=MIXER,name='IEC958 Playback Con Mask'
numid=21,iface=MIXER,name='IEC958 Playback Con Mask',index=16
numid=41,iface=MIXER,name='IEC958 Playback Pro Mask'
numid=22,iface=MIXER,name='IEC958 Playback Pro Mask',index=16
numid=42,iface=MIXER,name='IEC958 Playback Default'
numid=23,iface=MIXER,name='IEC958 Playback Default',index=16
numid=43,iface=MIXER,name='IEC958 Playback Switch'
numid=24,iface=MIXER,name='IEC958 Playback Switch',index=16
numid=11,iface=MIXER,name='Auto-Mute Mode'
numid=12,iface=MIXER,name='Input Source'
numid=13,iface=MIXER,name='Input Source',index=1
numid=19,iface=MIXER,name='Rear Mic Boost Volume'
numid=37,iface=PCM,name='Capture Channel Map'
numid=36,iface=PCM,name='Playback Channel Map'
numid=38,iface=PCM,name='Playback Channel Map',device=1
numid=39,iface=PCM,name='Capture Channel Map',device=2
numid=45,iface=PCM,name='Playback Channel Map',device=3
x86_64:/ # alsa_amixer cset numid=35 values=on
amixer: Control default element write error: Operation not permitted

1|x86_64:/ # alsa
alsa_amixer alsa_aplay alsa_ctl alsa_ucm
1|x86_64:/ # alsa_
alsa_amixer alsa_aplay alsa_ctl alsa_ucm
1|x86_64:/ # alsa
alsa_amixer alsa_aplay alsa_ctl alsa_ucm
1|x86_64:/ # alsa_ucm
acct/ init.android_x86_64.rc sbin/
bugreports init.environ.rc sdcard/
cache/ init.rc seapp_contexts
charger init.superuser.rc selinux_version
config/ init.usb.configfs.rc sepolicy
d/ init.usb.rc service_contexts
data/ init.zygote32.rc storage/
default.prop init.zygote64_32.rc sys/
dev/ lib/ system/
etc/ mnt/ ueventd.android_x86_64.rc
file_contexts.bin oem/ ueventd.rc
fstab.android_x86_64 proc/ vendor/
init property_contexts
1|x86_64:/ # alsa_ucm
acct/ init.android_x86_64.rc sbin/
bugreports init.environ.rc sdcard/
cache/ init.rc seapp_contexts
charger init.superuser.rc selinux_version
config/ init.usb.configfs.rc sepolicy
d/ init.usb.rc service_contexts
data/ init.zygote32.rc storage/
default.prop init.zygote64_32.rc sys/
dev/ lib/ system/
etc/ mnt/ ueventd.android_x86_64.rc
file_contexts.bin oem/ ueventd.rc
fstab.android_x86_64 proc/ vendor/
init property_contexts
1|x86_64:/ # alsa_ucm -?
alsa_ucm: invalid option -- ?
Try 'alsa_ucm --help' for more information.
1|x86_64:/ # alsa_ucm --help
Usage: alsa_ucm <options> [command]

Available options:
-h,--help this help
-c,--card NAME open card NAME
-i,--interactive interactive mode
-b,--batch FILE batch mode (use '-' for the stdin input)
-n,--no-open do not open first card found

Available commands:
open NAME open card NAME
reset reset sound card to default state
reload reload configuration
listcards list available cards
list IDENTIFIER list command
get IDENTIFIER get string value
geti IDENTIFIER get integer value
set IDENTIFIER VALUE set string value
h,help help
q,quit quit
ALSA lib external/alsa-lib/src/ucm/parser.c:1142:(uc_mgr_scan_master_configs) error: could not scan directory /system/usr/share/alsa/ucm: No such file or directory
alsa_ucm: unable to obtain card list: No such file or directory
1|x86_64:/ # alsa_ucm -c 0
ALSA lib external/alsa-lib/src/ucm/utils.c:67:(uc_mgr_config_load) could not open configuration file /system/usr/share/alsa/ucm/0/0.conf
ALSA lib external/alsa-lib/src/ucm/parser.c:1082:(load_master_config) error: could not parse configuration for card 0
ALSA lib external/alsa-lib/src/ucm/main.c:665:(snd_use_case_mgr_open) error: failed to import 0 use case configuration -2
alsa_ucm: error failed to open sound card 0: No such file or directory
1|x86_64:/ # alsa_ucm listcards
ALSA lib external/alsa-lib/src/ucm/parser.c:1142:(uc_mgr_scan_master_configs) error: could not scan directory /system/usr/share/alsa/ucm: No such file or directory
alsa_ucm: unable to obtain card list: No such file or directory
1|x86_64:/ # alsa
alsa_amixer alsa_aplay alsa_ctl alsa_ucm
1|x86_64:/ # alsa_
alsa_amixer alsa_aplay alsa_ctl alsa_ucm
1|x86_64:/ # alsa_ctl
alsactl: Specify command...
x86_64:/ # alsa_ctl -?
alsa_ctl: invalid option -- ?
Usage: alsactl <options> command

Available global options:
-h,--help this help
-d,--debug debug mode
-v,--version print version of this program

Available state options:
-f,--file # configuration file (default /var/lib/alsa/asound.state)
-F,--force try to restore the matching controls as much as possible
(default mode)
-g,--ignore ignore 'No soundcards found' error
-P,--pedantic do not restore mismatching controls (old default)
-I,--no-init-fallback
don't initialize even if restore fails
-r,--runstate # save restore and init state to this file (only errors)
default settings is 'no file set'
-R,--remove remove runstate file at first, otherwise append errors

Available init options:
-E,--env #=# set environment variable for init phase (NAME=VALUE)
-i,--initfile # main configuation file for init phase (default /system/usr/share/alsa/init/00main)


Available commands:
store <card #> save current driver setup for one or each soundcards
to configuration file
restore <card #> load current driver setup for one or each soundcards
from configuration file
init <card #> initialize driver to a default state
names <card #> dump information about all the known present (sub-)devices
into configuration file (DEPRECATED)
1|x86_64:/ # alsa_ctl init 0
Found hardware: "HDA-Intel" "Realtek Generic" "HDA:10ec1168,10438723,00100003 HDA:8086280b,80860101,00100000" "0x1043" "0x8723"
Hardware is initialized using a generic method
99|x86_64:/ # alsa_ctl
alsactl: Specify command...
x86_64:/ # alsa_ctl -?
alsa_ctl: invalid option -- ?
Usage: alsactl <options> command

Available global options:
-h,--help this help
-d,--debug debug mode
-v,--version print version of this program

Available state options:
-f,--file # configuration file (default /var/lib/alsa/asound.state)
-F,--force try to restore the matching controls as much as possible
(default mode)
-g,--ignore ignore 'No soundcards found' error
-P,--pedantic do not restore mismatching controls (old default)
-I,--no-init-fallback
don't initialize even if restore fails
-r,--runstate # save restore and init state to this file (only errors)
default settings is 'no file set'
-R,--remove remove runstate file at first, otherwise append errors

Available init options:
-E,--env #=# set environment variable for init phase (NAME=VALUE)
-i,--initfile # main configuation file for init phase (default /system/usr/share/alsa/init/00main)


Available commands:
store <card #> save current driver setup for one or each soundcards
to configuration file
restore <card #> load current driver setup for one or each soundcards
from configuration file
init <card #> initialize driver to a default state
names <card #> dump information about all the known present (sub-)devices
into configuration file (DEPRECATED)
1|x86_64:/ # alsa
alsa_amixer alsa_aplay alsa_ctl alsa_ucm
1|x86_64:/ # alsa_
alsa_amixer alsa_aplay alsa_ctl alsa_ucm
1|x86_64:/ # alsa_aplay
acct/ init.android_x86_64.rc sbin/
bugreports init.environ.rc sdcard/
cache/ init.rc seapp_contexts
charger init.superuser.rc selinux_version
config/ init.usb.configfs.rc sepolicy
d/ init.usb.rc service_contexts
data/ init.zygote32.rc storage/
default.prop init.zygote64_32.rc sys/
dev/ lib/ system/
etc/ mnt/ ueventd.android_x86_64.rc
file_contexts.bin oem/ ueventd.rc
fstab.android_x86_64 proc/ vendor/
init property_contexts
1|x86_64:/ # alsa_aplay -?
alsa_aplay: invalid option -- ?
Try `aplay --help' for more information.
1|x86_64:/ # alsa_aplay --help
Usage: aplay [OPTION]... [FILE]...

-h, --help help
--version print current version
-l, --list-devices list all soundcards and digital audio devices
-L, --list-pcms list device names
-D, --device=NAME select PCM by name
-q, --quiet quiet mode
-t, --file-type TYPE file type (voc, wav, raw or au)
-c, --channels=# channels
-f, --format=FORMAT sample format (case insensitive)
-r, --rate=# sample rate
-d, --duration=# interrupt after # seconds
-M, --mmap mmap stream
-N, --nonblock nonblocking mode
-F, --period-time=# distance between interrupts is # microseconds
-B, --buffer-time=# buffer duration is # microseconds
--period-size=# distance between interrupts is # frames
--buffer-size=# buffer duration is # frames
-A, --avail-min=# min available space for wakeup is # microseconds
-R, --start-delay=# delay for automatic PCM start is # microseconds
(relative to buffer size if <= 0)
-T, --stop-delay=# delay for automatic PCM stop is # microseconds from xrun
-v, --verbose show PCM structure and setup (accumulative)
-V, --vumeter=TYPE enable VU meter (TYPE: mono or stereo)
-I, --separate-channels one file for each channel
--disable-resample disable automatic rate resample
--disable-channels disable automatic channel conversions
--disable-format disable automatic format conversions
--disable-softvol disable software volume control (softvol)
--test-position test ring buffer position
--test-coef=# test coeficient for ring buffer position (default 8)
expression for validation is: coef * (buffer_size / 2)
--test-nowait do not wait for ring buffer - eats whole CPU
--max-file-time=# start another output file when the old file has recorded
for this many seconds
--process-id-file write the process ID here
--use-strftime apply the strftime facility to the output file name
Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE
Some of these may not be available on selected hardware
The availabled format shortcuts are:
-f cd (16 bit little endian, 44100, stereo)
-f cdr (16 bit big endian, 44100, stereo)
-f dat (16 bit little endian, 48000, stereo)
x86_64:/ # alsa_aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=PCH
HDA Intel PCH, Generic Analog
Default Audio Device
x86_64:/ # alsa_aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: Generic Analog [Generic Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: Generic Digital [Generic Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: Generic Digital [Generic Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
x86_64:/ # alsa_aplay -D 3
ALSA lib external/alsa-lib/src/pcm/pcm.c:2208:(snd_pcm_open_noupdate) Unknown PCM 3
aplay: main:662: audio open error: No such file or directory
1|x86_64:/ # alsa_aplay -D 3




2017년 7월 1일 토요일 오후 6시 32분 46초 UTC+9, YoungJoon Lee 님의 말:

YoungJoon Lee

unread,
Jul 4, 2017, 9:12:00 AM7/4/17
to Android-x86
Hello, 

I found that modifying /sound/pci/hda/hda_codec.c can adjust priority of devices. I will try it.

2017년 7월 4일 화요일 오후 8시 42분 49초 UTC+9, YoungJoon Lee 님의 말:

Chih-Wei Huang

unread,
Jul 5, 2017, 5:57:48 AM7/5/17
to Android-x86
2017-07-04 21:12 GMT+08:00 YoungJoon Lee <get...@gmail.com>:
> Hello,
>
> I found that modifying /sound/pci/hda/hda_codec.c can adjust priority of
> devices. I will try it.

You should read the select_card function in
hardware/libaudio/audio_hw.c
to see how a card (device node) is selected.
As a test, you can also try to hardcode
the device node in it.

You can also test without changing the code.
Just remove the device node under /dev/snd
that you don't want to use, then restart audioserver
like:

x86_64:/ # ps | grep audioserver
audioserver 2357 1 26964 9684 0 0000000000 S
/system/bin/audioserver
x86_64:/ # kill 2357

The audioserver will restart automatically
and select the next available device node.

YoungJoon Lee

unread,
Jul 12, 2017, 11:29:07 AM7/12/17
to Android-x86
Thank you very much for your help.

I have a question.

I found this post.

In this post, it looks like changing pcmCnDmp can control output device. 
mv /dev/snd/pcmC0D0p /dev/snd/pcmC0D0p_tmp 
mv /dev/snd/pcmC0D3p /dev/snd/pcmC0D0p 
mv /dev/snd/pcmC0D0p_tmp /dev/snd/pcmC0D3p 

Q1. In my system, there is /dev/snd/pcmC0D0p and /dev/snd/pcmC0D0c. What represnt p and c? 

Q2. It looks like HAL determine number of n and m(pcmCnDmp). I have to make correct Card# and Device# to C0D0p. And these codes can be determined by select_card and select_device. 

Q3. In function select_card, it looks like get info of HDMI device is different from other devices(Line:226). How about SPDIF output?(My card is realtek HD Audio=series alc) I have to change source code to treat SPDIF same as HDMI? 

Q4. Every major Linux dist wiki has alsa document. But almost all of them is focused on usage of alsa. And I don't know design of android alsa design. I always install pulseaudio on Linux without any knowledge about alsa and alsa mixer. Package pulse audio makes my sound work. So, I have never check between them. Is there any document show interaction between android sound server-HAl and kerner driver?

Thank you very much. 

2017년 7월 5일 수요일 오후 6시 57분 48초 UTC+9, Chih-Wei Huang 님의 말:

Chih-Wei Huang

unread,
Jul 12, 2017, 12:40:10 PM7/12/17
to Android-x86
2017-07-12 23:29 GMT+08:00 YoungJoon Lee <get...@gmail.com>:
> Thank you very much for your help.
>
> I have a question.
>
> I found this post.
> https://groups.google.com/forum/#!searchin/android-x86/alsa$20state$20hdmi%7Csort:date/android-x86/ZmG-biOnNDI/kVfYK11-yHIJ
>
> In this post, it looks like changing pcmCnDmp can control output device.
>>
>> mv /dev/snd/pcmC0D0p /dev/snd/pcmC0D0p_tmp
>> mv /dev/snd/pcmC0D3p /dev/snd/pcmC0D0p
>> mv /dev/snd/pcmC0D0p_tmp /dev/snd/pcmC0D3p
>
>
> Q1. In my system, there is /dev/snd/pcmC0D0p and /dev/snd/pcmC0D0c. What
> represnt p and c?

p - playback
c - capture

> Q2. It looks like HAL determine number of n and m(pcmCnDmp). I have to make
> correct Card# and Device# to C0D0p. And these codes can be determined by
> select_card and select_device.

Currently the card selection is very naive.
It just selects the first available card.

> Q3. In function select_card, it looks like get info of HDMI device is
> different from other devices(Line:226). How about SPDIF output?(My card is
> realtek HD Audio=series alc) I have to change source code to treat SPDIF
> same as HDMI?

I don't know.
I know nothing about SPDIF.

> Q4. Every major Linux dist wiki has alsa document. But almost all of them is
> focused on usage of alsa. And I don't know design of android alsa design. I
> always install pulseaudio on Linux without any knowledge about alsa and alsa
> mixer. Package pulse audio makes my sound work. So, I have never check
> between them. Is there any document show interaction between android sound
> server-HAl and kerner driver?

No.

As said the current card selection is naive.
If you can you are welcome to introduce
the logic used in major Linux dist
to our HAL.

YoungJoon Lee

unread,
Jul 13, 2017, 12:53:04 PM7/13/17
to Android-x86
Hello, Chih wei Huang.

I test several approaches today. 

In my /dev/snd/ 
There is 1 cards 2 devices.
hwC0D0 and hwC0D2.
And there is 3 pcm files.
pcmC0D0p pcmC0D1p pcmC0D3p

When I boot, I can play music with analog 3.5mm headphone jack.

But I want to play music with optical out. 

I try to change pcm devices.
I rename pcmC0D0p to pcmC0D9p.bak and rename pcmC0D1p to pcmC0D0p. And kill audioserver But I can't play music with optical out. Next, I try pcmC0D3p to pcmC0D0p But still no sound.
All combination of hwC0D0 hwC0D1 and pcm devices is not work. 

I check analog out can only play music on initial hwC0D0 and pcmC0D0p. changing pcm and hw file makes audio not working.

I think hwC0D1 + pcmC0D1p or pcmC0D3p combination is correct. And no audio's reason is not only combination.

Is there any approaches related to digital audio out? I search google group but still cannot solve my problem now.
I found some post said output sample rate is wrong.(But not tested yet)

Thank you for reading.



2017년 7월 13일 목요일 오전 1시 40분 10초 UTC+9, Chih-Wei Huang 님의 말:

Chih-Wei Huang

unread,
Jul 13, 2017, 1:40:14 PM7/13/17
to Android-x86
2017-07-14 0:53 GMT+08:00 YoungJoon Lee <get...@gmail.com>:
> Hello, Chih wei Huang.
>
> I test several approaches today.
>
> In my /dev/snd/
> There is 1 cards 2 devices.
> hwC0D0 and hwC0D2.
> And there is 3 pcm files.
> pcmC0D0p pcmC0D1p pcmC0D3p
>
> When I boot, I can play music with analog 3.5mm headphone jack.
>
> But I want to play music with optical out.
>
> I try to change pcm devices.
> I rename pcmC0D0p to pcmC0D9p.bak and rename pcmC0D1p to pcmC0D0p. And kill
> audioserver But I can't play music with optical out. Next, I try pcmC0D3p to
> pcmC0D0p But still no sound.
> All combination of hwC0D0 hwC0D1 and pcm devices is not work.
>
> I check analog out can only play music on initial hwC0D0 and pcmC0D0p.
> changing pcm and hw file makes audio not working.
>
> I think hwC0D1 + pcmC0D1p or pcmC0D3p combination is correct. And no audio's
> reason is not only combination.
>
> Is there any approaches related to digital audio out? I search google group
> but still cannot solve my problem now.
> I found some post said output sample rate is wrong.(But not tested yet)

Yes. That could be a possible reason.

Another possibility is it requires special initialization.
In this case, you can use a Linux distro which
can set it up correctly.
Save its state by alsactl, copy the audio state file
to android-x86 and then restore it.

YoungJoon Lee

unread,
Jul 14, 2017, 2:29:49 PM7/14/17
to Android-x86
Hello, Chih wei Huang. 

Thank you very much for your help.

I can solve my problem today. Because I don't change HAL source, select card must work correctly and other alsa setting is not correct.(I guess my device is mute)

I will write how I can solve my problem. It will help other people who have same problems.

Environment : My MOBO(ASUS STRIX Z270I) has ALC1220(CARD0) Codec. It is not supported on android kernel yet.
My MOBO has SPDIF(Optical=toslink) out and HDMI(CARD1) out and DP(CARD1) out and 3.5mm stereo out. 
SPDIF is supported by CARD0. 

First approach : I patch my kernel. patch just add device code 1220 to kernel file. You can found patch on google search. And then I build my kernel with default defconfig of android x86. 

Problem : 3.5mm stereo out works but all other card is not work.

Next approach : I tried many approaches posted in google group but all of them is not working on my system.

Last : 
I boot with Ubuntu live USB and go to sound setup.  And I set 3.5mm stereo to mute and set spdif digital out remove mute option. And I store setting of state. (sudo -s needed) alsactl --file ~/name_of_file store. And copy name_of_file to your android system. 

Check your /etc/init.sh. You can found init script of alsa device.
Memo `cat /proc/asound/card0/id` and change file name to id.state. (In my case, mv name_of_file PCH.state) 
Copy id.state to /etc/alsa/

Test : alsactl --file /etc/alsa/id.state restore

Now you can play sound. id.state is automatically loaded by /etc/init.sh

Notice that, You must make card what you want to use to card0.  You can disable all other devices on bios. Or you can remove options on kernel menuconfig.

This guide will help who successfully makes card to order # 0 but cannot play audio.
If Ubuntu also can't play audio, you can't try this approach.

PS. Chih wei Huang, Do you have NVMe patch for installer script? I have tried several hard coding approach but it is not working yet.
Root checking __________________ continue and cannot boot. I think my scripte init is buggy.

Best regards.


2017년 7월 14일 금요일 오전 2시 40분 14초 UTC+9, Chih-Wei Huang 님의 말:
Reply all
Reply to author
Forward
0 new messages