From f49cab175e5d428efde597eb2e5594a0f44a732d Mon Sep 17 00:00:00 2001 From: Robert Yang Date: Wed, 27 Feb 2019 14:16:09 -0500 Subject: [PATCH] device-samsung-p4wifi: Make sound input work (!254) ALSA configs are created based on downstream driver code and wm8994 datasheet. --- .../90-device-samsung-p4wifi-audio.rules | 2 +- .../90-device-samsung-p4wifi-jack.rules | 4 +- device/device-samsung-p4wifi/APKBUILD | 8 +- device/device-samsung-p4wifi/HiFi | 134 ++++++++++-------- device/device-samsung-p4wifi/wm8994aif1.conf | 29 ---- 5 files changed, 85 insertions(+), 92 deletions(-) diff --git a/device/device-samsung-p4wifi/90-device-samsung-p4wifi-audio.rules b/device/device-samsung-p4wifi/90-device-samsung-p4wifi-audio.rules index 0a28d5f56..ccb81c933 100644 --- a/device/device-samsung-p4wifi/90-device-samsung-p4wifi-audio.rules +++ b/device/device-samsung-p4wifi/90-device-samsung-p4wifi-audio.rules @@ -1 +1 @@ -ATTRS{id}=="wm8994aif1", RUN+="/usr/bin/alsaucm -c wm8994aif1 set _verb HiFi set _enadev Headphones" \ No newline at end of file +ATTRS{id}=="wm8994aif1", RUN+="/usr/bin/alsaucm -c wm8994aif1 set _verb HiFi set _enadev Headset" \ No newline at end of file diff --git a/device/device-samsung-p4wifi/90-device-samsung-p4wifi-jack.rules b/device/device-samsung-p4wifi/90-device-samsung-p4wifi-jack.rules index ec2a40f3a..58f1e657b 100644 --- a/device/device-samsung-p4wifi/90-device-samsung-p4wifi-jack.rules +++ b/device/device-samsung-p4wifi/90-device-samsung-p4wifi-jack.rules @@ -1,2 +1,2 @@ -SUBSYSTEM=="extcon", ATTR{name}=="sec-jack", ATTR{state}=="HEADPHONE=1", RUN+="/usr/bin/alsaucm -c wm8994aif1 set _verb HiFi set _enadev Headphones" -SUBSYSTEM=="extcon", ATTR{name}=="sec-jack", ATTR{state}=="HEADPHONE=0", RUN+="/usr/bin/alsaucm -c wm8994aif1 set _verb HiFi set _enadev Speaker" +SUBSYSTEM=="extcon", ATTR{name}=="headset-jack", ATTR{state}=="HEADPHONE=1", RUN+="/usr/bin/alsaucm -c wm8994aif1 set _verb HiFi set _enadev Headset" +SUBSYSTEM=="extcon", ATTR{name}=="headset-jack", ATTR{state}=="HEADPHONE=0", RUN+="/usr/bin/alsaucm -c wm8994aif1 set _verb HiFi set _enadev SpeakerMic" diff --git a/device/device-samsung-p4wifi/APKBUILD b/device/device-samsung-p4wifi/APKBUILD index fb5bc3c07..70e958533 100644 --- a/device/device-samsung-p4wifi/APKBUILD +++ b/device/device-samsung-p4wifi/APKBUILD @@ -64,7 +64,7 @@ nonfree_firmware() { sha512sums="803c1dd0b8dd403fbc0cf5cf381c490e1d639bad35a2e6a56c215d264a465fca3ab732a0b7c9984e87ecb87cd00eb90bd8c9b3f08a1d35c1495ecf66eaea62d2 deviceinfo e457d1095b4c5da105d83a3951ca8d4c5074384a1280dcc95f8a8c24aff64c32a807968ad449d335fbafba528050436c283036869fc979aced6e613892e46fca modules-load.conf 56b865bab0714aed53bd6535ebefd2f3629ec78786e8f87dcae4637cfacb5912d28dc39d1fe0287d34bb36b4a8371481f54647e1b25190afbcd23ed30fe7edac modprobe.conf -559d3f49a2a99445c644f53b1148fbac6963cc27fc77ba735da7b6c742b8d4faecf938943ce598ea71d590ce2297e2ec6f98aec54b2b339c861f92d0e0430434 90-device-samsung-p4wifi-audio.rules -0ba8fc472df6a2a420c963d637bebe0cb167f593c50b1cd0dfb654375a1d16de99590dc5e48d0f42e7d44b6fe2ffa9dbfec062a32483d1b5ed32f383cd29ed22 90-device-samsung-p4wifi-jack.rules -a62bbae27b3e76e5ba4b3d06fdd3a35e14b69319b213724196b5ab8acf2086bdf6aef3feef20b262294860f03b8b202a094702af458fe1cfff74c5a17a1cd915 HiFi -16640080221d6ce6b87eb02bef401a18152008f75e52c0db2eee0a67f1ac65fc9ed053cc2388012f3f661e8f5526e8133af4ae2a5176441fde382597c02a75fa wm8994aif1.conf" +9c5c332e26b7eedb6eaa1631d133a9e430ee9322f62c80d4709b4d11b73566ae85b818e510bf1762bc8a1cc8cb617e400ddcf2583db11106b272ae65faf355cb 90-device-samsung-p4wifi-audio.rules +03022552bdfc5c66acf0fd69f3a913cd24c5bdedb1a7f6db5ddee295eef27e27dabee727798cdb0000851f42d242474421d3a56a4405f8b2046080eba93fce06 90-device-samsung-p4wifi-jack.rules +b973ed600914140006616f7205e66a2efff67002069dfd0fb731da254954d5f193d02cc687a41dd2e5ee698692b9cdd7cf1c3c4b3f3dd846372bbdced11acd39 HiFi +e801765eedfb5b88e191811bcb98915559cb11c500ababced3abed3afe3b46a3cdfe393eb0265c2756a0e9d13b5067ae2208e02d91621cbd6834cf12f3f07ba6 wm8994aif1.conf" diff --git a/device/device-samsung-p4wifi/HiFi b/device/device-samsung-p4wifi/HiFi index 528bb4001..c2270b946 100644 --- a/device/device-samsung-p4wifi/HiFi +++ b/device/device-samsung-p4wifi/HiFi @@ -2,97 +2,119 @@ SectionVerb { EnableSequence [ cdev "hw:wm8994aif1" - ] + # Must reset all input/outputs else the mixer goes into a bad + # state where things randomly don't work. + cset "name='Headphone Switch' 0" + cset "name='Speaker Switch' 0" + cset "name='IN1L Switch' 0" + cset "name='IN1R Switch' 0" - DisableSequence [ - cdev "hw:wm8994aif1" + cset "name='DAC1R Mixer AIF1.1 Switch' 1" + cset "name='DAC1L Mixer AIF1.1 Switch' 1" + cset "name='DAC1 Switch' 1" + cset "name='Left Headphone Mux' DAC" + cset "name='Right Headphone Mux' DAC" ] Value { PlaybackPCM "hw:wm8994aif1,0" CapturePCM "hw:wm8994aif1,0" } - } SectionDevice."Speaker" { - Comment "Speaker Rx device" - - ConflictingDevice [ - "Headphones" - ] + Comment "Speaker" EnableSequence [ cdev "hw:wm8994aif1" - cset "name='DAC1R Mixer AIF1.1 Switch' 1" - cset "name='DAC1L Mixer AIF1.1 Switch' 1" - cset "name='DAC1 Switch' 1" - cset "name='AIF1DAC1 EQ Switch' 1" - cset "name='AIF1DAC1 EQ1 Volume' 3" - cset "name='AIF1DAC1 EQ2 Volume' 8" - cset "name='AIF1DAC1 EQ3 Volume' 16" - cset "name='AIF1DAC1 EQ4 Volume' 10" - cset "name='AIF1DAC1 EQ5 Volume' 11" + cset "name='SPKR DAC1 Switch' 1" + cset "name='SPKL DAC1 Switch' 1" cset "name='Speaker Switch' 1" - cset "name='SPKR DAC1 Switch' 1" - cset "name='SPKL DAC1 Switch' 1" - cset "name='Speaker Mixer Volume' 3" cset "name='Speaker Boost Volume' 5" - cset "name='AIF1DAC1 DRC Switch' 1" - cset "name='Speaker Volume' 61" - cset "name='Speaker Volume' 62" - ] + cset "name='Speaker Mixer Volume' 5" - DisableSequence [ - cdev "hw:wm8994aif1" - - cset "name='DAC1R Mixer AIF1.1 Switch' 1" - cset "name='DAC1L Mixer AIF1.1 Switch' 1" - cset "name='DAC1 Switch' 1" - cset "name='Speaker Switch' 0" - cset "name='SPKR DAC1 Switch' 1" - cset "name='SPKL DAC1 Switch' 1" - cset "name='Speaker Mixer Volume' 1" + exec "echo enable Speaker" ] Value { PlaybackChannels "2" } - } -SectionDevice."Headphones" { - Comment "Headset Rx device" - - ConflictingDevice [ - "Speaker" - ] +SectionDevice."SpeakerMic" { + Comment "Speaker and Microphone" EnableSequence [ cdev "hw:wm8994aif1" - cset "name='DAC1R Mixer AIF1.1 Switch' 1" - cset "name='DAC1L Mixer AIF1.1 Switch' 1" - cset "name='DAC1 Switch' 1" - cset "name='AIF1DAC1 EQ Switch' 0" - cset "name='Headphone Switch' 1" - cset "name='Headphone Volume' 35" - ] + cset "name='SPKR DAC1 Switch' 1" + cset "name='SPKL DAC1 Switch' 1" + cset "name='Speaker Switch' 1" + cset "name='Speaker Boost Volume' 5" + cset "name='Speaker Mixer Volume' 5" - DisableSequence [ - cdev "hw:wm8994aif1" - - cset "name='DAC1R Mixer AIF1.1 Switch' 1" + cset "name='MIXINL IN1L Switch' 1" + cset "name='IN1L PGA IN1LP Switch' 1" + cset "name='IN1L PGA IN1LN Switch' 1" + cset "name='AIF1ADCL Source' 0" + cset "name='AIF1ADCR Source' 0" + cset "name='AIF1ADC1L Mixer ADC/DMIC Switch' 1" cset "name='DAC1L Mixer AIF1.1 Switch' 1" - cset "name='DAC1 Switch' 1" - cset "name='Headphone Switch' 0" + cset "name='DAC1R Mixer AIF1.1 Switch' 1" + + cset "name='AIF1ADC1 HPF Switch' 1" + + # Mute the mic by default. + cset "name='IN1L Switch' 0" + + exec "echo enable Speaker and Microphone" ] Value { PlaybackChannels "2" } - } +SectionDevice."Headphone" { + Comment "Headphone" + + EnableSequence [ + cdev "hw:wm8994aif1" + cset "name='Headphone Switch' 1" + + exec "echo enable Headphone" + ] + + Value { + PlaybackChannels "2" + } +} + +SectionDevice."Headset" { + Comment "Headset" + + EnableSequence [ + cdev "hw:wm8994aif1" + cset "name='Headphone Switch' 1" + + cset "name='MIXINR IN1R Switch' 1" + cset "name='IN1R PGA IN1RN Switch' 1" + cset "name='IN1R PGA IN1RP Switch' 1" + cset "name='AIF1ADCL Source' 1" + cset "name='AIF1ADCR Source' 1" + cset "name='AIF1ADC1R Mixer ADC/DMIC Switch' 1" + cset "name='DAC1L Mixer AIF1.1 Switch' 1" + cset "name='DAC1R Mixer AIF1.1 Switch' 1" + + # Mute the mic by default. + cset "name='IN1R Switch' 0" + + exec "echo enable Headset" + ] + + Value { + PlaybackChannels "2" + } +} diff --git a/device/device-samsung-p4wifi/wm8994aif1.conf b/device/device-samsung-p4wifi/wm8994aif1.conf index f8f3e54d3..fe058e46e 100644 --- a/device/device-samsung-p4wifi/wm8994aif1.conf +++ b/device/device-samsung-p4wifi/wm8994aif1.conf @@ -1,37 +1,8 @@ SectionUseCase."HiFi" { File "HiFi" Comment "Play HiFi quality Music" - } SectionDefaults [ cdev "hw:wm8994aif1" - - cset "name='Headphone Switch' 0" - cset "name='Speaker Switch' 0" - cset "name='MIXINL IN1L Switch' 0" - cset "name='MIXINR IN1R Switch' 0" - cset "name='DAC1 Switch' 1" - cset "name='DAC1L Mixer AIF1.1 Switch' 1" - cset "name='DAC1R Mixer AIF1.1 Switch' 1" - cset "name='Left Headphone Mux' DAC" - cset "name='Right Headphone Mux' DAC" - cset "name='SPKL DAC1 Switch' 1" - cset "name='SPKR DAC1 Switch' 1" - cset "name='SPKL Boost SPKL Switch' 1" - cset "name='SPKL Boost SPKR Switch' 1" - cset "name='Speaker Mixer Volume' 1" - cset "name='IN1L PGA IN1LP Switch' 0" - cset "name='IN1L PGA IN1LN Switch' 0" - cset "name='MIXINL IN1L Volume' 1" - cset "name='IN1L Switch' 1" - cset "name='IN1L Volume' 23" - cset "name='IN1R PGA IN1RP Switch' 0" - cset "name='IN1R PGA IN1RN Switch' 0" - cset "name='MIXINR IN1R Volume' 1" - cset "name='IN1R Switch' 1" - cset "name='IN1R Volume' 23" - cset "name='AIF1ADC1L Mixer ADC/DMIC Switch' 1" - cset "name='AIF1ADC1R Mixer ADC/DMIC Switch' 1" ] -