Attached is an installer for up to three hardware-level audio mods that I've created over the last few years.
Important: This installer is not flashable via TWRP, but needs to be installed using an adb root shell as outlined below.
The three mods that can be installed in any combination are
There are actually two installer provided:
To install, download the attached archive to your PC and push it to /data/local/tmp on your Pixel
Then enter an adb shell and copy the following string of commands into a root shell:
to install type
and select your install option, which also includes "revert to stock".
The following hidden text shows the original OP for reference:
It has been a tradition in the Android community to enable the earpiece speaker for multimedia playback to somewhat mitigate the drawback of having only one bottom-firing loudspeaker. I have been running a "true stereo" mod on my Nexus 5 for almost two years with great success.
The Pixel is a little bit different. Like some other phones with the SD820/821 it uses a separate speaker DAC/amp, which makes this mod quite a bit more tricky. Let me get this out of the way: the bottom speaker gets *much* louder than, for instance, the one on the Nexus 5. You cannot expect the earpiece to get this loud to create any form of "surround" effect. The only way to get there is to lower the volume of the main loudspeaker. This is what I'm describing below. This work is in no way, shape or form complete. For now, I'm giving here an outline on what needs to be done to enable dual-loudspeaker playback. I encourage others to try it out and chime in. So here it goes:
First of all you need to be rooted.Then modify the following /system/etc/mixer_paths.xml {...}.
The installation process is now described here
Now you need to save the file and reboot your phone. When you play audio you will notice that the earpiece is barely audible against the main speaker. The only way around this is to lower the speaker gain. This can be done by writing to a register in the amplifier which sits on the i2c bus:
where ZZ is the gain. By default, the speaker is set to 0 dB of gain with ZZ=00, i.e.
Now each "tick" in the upper eight bits in this 16-bit number lowers the gain by 0.5 dB. The last two gain settings are FE which is -127 dB and FF which mutes the speaker.
In my short tests I have found the a gain of -16 dB for the main speaker, i.e.
and a gain of +6 dB for the earpiece (see above) gives fairly balanced left-right volume. The speaker volume could be adjusted via an app depending on the use-case or upon boot via a script in /su/su.d
Note that the mod at this stage is dual-mono only.
Going forward I'll try to enable true stereo or something like the HTC10 tweeter-woofer arrangement.
I understand that all of this appears fairly complicated, so work needs to go into making this actually useful for others with flashable zip and control app. Any volunteers...?
Updates
Known limitations
Important: This installer is not flashable via TWRP, but needs to be installed using an adb root shell as outlined below.
The three mods that can be installed in any combination are
- The dual speaker playback mod as originally presented in this thread. When installing this mod, an app will also be installed that offers the following functionality:
- when the screen is on, the main loudspeaker level is reduced significantly to bring down its volume to the one that is attainable with the earpiece speaker. The idea is that when the screen is on you may want to use it to watch a movie or play a game where the stereo effect may enhance the listening experience. This is a "personal" use-case where the lower overall volume may not be a huge problem
- when the screen is off the main loudspeaker level is again raised to its maximum capability to not miss notifications and alarms, etc
- There is an option offered to force maximum gain also in case the screen is on, for instance when sharing a YouTube video with friends or when using the speakers in the car in navigation mode
- Stereo camcorder audio recording mod. Any app that uses the CAMCORDER device is now capable of recording stereo sound. Examples are Google's stock camcorder or "Easy Voice Recorder Pro".
- Headphone biquad filtering for frequency response compensation as first made available here. This option will also install the accompanying biQuads app and relevant files. REQUIREMENTS: system-less root and @flar2 's excellent ElementalX kernel starting with version 1.02, with codec power gating option disabled in the installer.
There are actually two installer provided:
- chdloc_hardware_audio_mods_pixel__ull.tar.gz : retains ultra-low latency (ULL) audio playback, but only supports the main loudspeaker to be active in cases where ULL is being asked for
- chdloc_hardware_audio_mods_pixel__no_ull_*.tar.gz: allows both loudspeakers to be active even when ULL is being asked for by an app. However, under the hood ULL is converted to low-latency playback only.
To install, download the attached archive to your PC and push it to /data/local/tmp on your Pixel
Code:
adb shell rm -rf /data/local/tmp/chdloc* && adb push chdloc_hardware_audio_mods_pixel*.tar.gz /data/local/tmp/
Then enter an adb shell and copy the following string of commands into a root shell:
Code:
cd /data/local/tmp && gzip -d chdloc_hardware_audio_mods_pixel__*.tar.gz && tar -xf chdloc_hardware_audio_mods_pixel*.tar && gzip chdloc_hardware_audio_mods_pixel*.tar && chmod -R a+rw chdloc* && cd chdloc_hardware_audio_mods_pixel && chmod 744 install_chdloc_mods.sh
to install type
Code:
./install_chdloc_mods.sh
The following hidden text shows the original OP for reference:
It has been a tradition in the Android community to enable the earpiece speaker for multimedia playback to somewhat mitigate the drawback of having only one bottom-firing loudspeaker. I have been running a "true stereo" mod on my Nexus 5 for almost two years with great success.
The Pixel is a little bit different. Like some other phones with the SD820/821 it uses a separate speaker DAC/amp, which makes this mod quite a bit more tricky. Let me get this out of the way: the bottom speaker gets *much* louder than, for instance, the one on the Nexus 5. You cannot expect the earpiece to get this loud to create any form of "surround" effect. The only way to get there is to lower the volume of the main loudspeaker. This is what I'm describing below. This work is in no way, shape or form complete. For now, I'm giving here an outline on what needs to be done to enable dual-loudspeaker playback. I encourage others to try it out and chime in. So here it goes:
First of all you need to be rooted.
The installation process is now described here
Now you need to save the file and reboot your phone. When you play audio you will notice that the earpiece is barely audible against the main speaker. The only way around this is to lower the speaker gain. This can be done by writing to a register in the amplifier which sits on the i2c bus:
Code:
echo 0xZZ0f > /sys/kernel/debug/tfa98xx-34/regs/06-AUDIO_CTR
Code:
echo 0x000f > /sys/kernel/debug/tfa98xx-34/regs/06-AUDIO_CTR
In my short tests I have found the a gain of -16 dB for the main speaker, i.e.
Code:
echo 0x210f > /sys/kernel/debug/tfa98xx-34/regs/06-AUDIO_CTR
Going forward I'll try to enable
I understand that all of this appears fairly complicated, so work needs to go into making this actually useful for others with flashable zip and control app. Any volunteers...?
Updates
- November 9: first release of a speaker control app
- November 7: the no-sound on the earpiece speaker during an incoming call has been fixed. For details, refer to this post. Please test and report back
- November 3: stereo support, the left channel is played by the earpiece and the right channel is played by the main speaker. Note the updated "speaker" device above. The line in red (QUAT ...) tells the mixer to send two channels to the speaker dac/amplifier. By default, the dac/amp mixes the two channels into a mono stream. If you want stereo, then issue
Code:
echo 0x8093 > /sys/kernel/debug/tfa98xx-34/regs/04-I2SREG # right channel only
Code:echo 0x809b > /sys/kernel/debug/tfa98xx-34/regs/04-I2SREG # mono mix
- November 2: Initial revision
Known limitations
Speakerphone telephony resets the DAC/amp of the main speaker and the above modifications get wiped. Hence, it would be ideal to control this mod with Tasker or some other native app.There currently is an issue with RX audio on the earpiece with an incoming phone call. There will be nothing coming out of the earpiece. Switching to speakerphone works fine. Outgoing calls are fine. This has to do with the above (necessary) changes to mixer_paths.xml and the timing on how audio devices are set up and torn down in specific use cases. An explanation and possible solutions are given below.fixed (?)
So here is the problem: A call comes in and the system plays the ringtone using the "speaker" device. With the changes above, the speaker device now also activates the earpiece speaker by default. When you answer the call, the audio HAL switches the audio devices by activating the relevant capture and playback devices. The playback device is different from the "speaker" device, but it involves the earpiece unless the phone is connected to a (potentially bluetooth) headset. Unfortunately, the "speaker" device gets disabled last, which means that the earpiece gets disabled. Here is the sequence of events as caught by logcat:
Phone is RINGING
17:30:04.578 adev_set_mode: mode 1
17:30:04.904 out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
17:30:04.908 select_devices: changing use case low-latency-playback output device from(1: handset, acdb 7) to (2: speaker, acdb 15)
17:30:04.908 enable_snd_device: snd_device(2: speaker) {=> chdloc: this line enables the earpiece}
17:30:04.924 enable_audio_route: usecase(1) apply and update mixer path: low-latency-playback speaker
Phone is answered in HANDSET mode
17:30:11.020 adev_set_mode: mode 2
17:30:11.123 out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=1
17:30:11.126 enable_snd_device: snd_device(19: voice-handset-tmus) {=> chdloc: this line enables the earpiece}
17:30:11.128 enable_snd_device: snd_device(55: voice-dmic-ef-tmus)
17:30:11.153 enable_audio_route: usecase(15) apply and update mixer path: voicemmode1-call
17:30:11.220 select_devices: changing use case low-latency-playback output device from(2: speaker, acdb 15) to (19: voice-handset-tmus, acdb 88)
17:30:11.220 disable_audio_route: usecase(1) reset and update mixer path: low-latency-playback speaker
17:30:11.277 disable_snd_device: snd_device(2: speaker) {=> chdloc: this line disables the earpiece}
17:30:11.304 enable_audio_route: usecase(1) apply and update mixer path: low-latency-playback
17:30:14.058 disable_audio_route: usecase(1) reset and update mixer path: low-latency-playback
I see three options to fix the issue:
- Have the earpiece constantly enabled. I'm currently testing this method to see whether there are any side effects. I would be in favor of this method if it works.
- Use Tasker to detect an incoming phone call and have Tasker enable the earpiece. This is actually very doable, but kludgy. I'd use this approach if the first one proves problematic.
- Mess with the audio HAL to disable the speaker *before* the voice-handset-*** device is enabled. As this involves source code changes and, therefore, a modified audio HAL (/system/lib/hw/audio.primary.msm8996.so), this would be my least favorite option.
Attachments
Last edited: