This repository has been archived by the owner on Sep 6, 2022. It is now read-only.
forked from begonia-dev/android_device_redmi_begonia
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
begonia: rootdir: Fix in-call volumes
* Add shell daemon for correcting volumes using tinymix (don't forget add this tool to build) * Kang idea by phhusson/treble_experimentations#1908 * Refactored code * Also adapt channels and sh path for A12 Signed-off-by: 7Soldier <reg.fm4@gmail.com>
- Loading branch information
Showing
5 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/vendor/bin/sh | ||
### Begonia In-call volume fix by TTTT555 ### | ||
while [ "$(getprop sys.boot_completed | tr -d '\r')" != "1" ]; do sleep 1; done | ||
sleep 10 | ||
|
||
# Channel current volume (to find all params use "tinymix" command) | ||
chcurrent=$(/system/bin/tinymix "ADDA_DL_GAIN" --v) | ||
# Used gain = chcurrent + our offset < max value by tinymix "ADDA_DL_GAIN" | ||
chused=65535 | ||
# Start value need less than $callmin | ||
callcurrentold=0 | ||
|
||
# Logging | ||
/system/bin/log -t MTKInCallDirtyFix "Starting Service" | ||
/system/bin/log -t MTKInCallDirtyFix "Hardware Current Gain: $chcurrent" | ||
/system/bin/log -t MTKInCallDirtyFix "Hardware Used Gain: $chused" | ||
|
||
# Loop every 2 seconds | ||
while true | ||
do | ||
# Check call status | ||
callstatus=$(/system/bin/tinymix "Speech_SCP_CALL_STATE" --v) | ||
|
||
if [ "$callstatus" = 1 ] | ||
then | ||
# Check call min volume in decimal FIXME: write HEX to DEX in one line | ||
callmin=$(/system/bin/service call audio 18 i32 0 | /system/bin/awk -F ' ' '{print $3}' | sed 's/0*//') | ||
callmin=$(echo $((16#$callmin))) | ||
# Check call max volume in decimal FIXME: write HEX to DEX in one line | ||
callmax=$(/system/bin/service call audio 19 i32 0 | /system/bin/awk -F ' ' '{print $3}' | sed 's/0*//') | ||
callmax=$(echo $((16#$callmax))) | ||
# Calculate interval for using via parabolic function | ||
interval=$(/system/bin/expr $chused / $callmax / $callmax) | ||
|
||
# Enable deep buffer for fix crackling | ||
/system/bin/tinymix "deep_buffer_irq_cnt" 2048 | ||
/system/bin/tinymix "deep_buffer_scenario" 1 | ||
|
||
while [ "$callstatus" = 1 ] | ||
do | ||
# Check choosen volume level FIXME: write HEX to DEX in one line | ||
callcurrent=$(/system/bin/service call audio 17 i32 0 | /system/bin/awk -F ' ' '{print $3}' | sed 's/0*//') | ||
callcurrent=$(echo $((16#$callcurrent))) | ||
if [ "$callcurrentold" != "$callcurrent" ] | ||
then | ||
# Calculate and write the new channel volume via parabolic function & rewrite max Db for small speaker | ||
newchvol=$(/system/bin/expr $callcurrent \* $callcurrent \* $interval) | ||
/system/bin/tinymix "ADDA_DL_GAIN" $newchvol | ||
/system/bin/tinymix "Handset_PGA_GAIN" 8Db | ||
/system/bin/log -t MTKInCallDirtyFix "Hardware In-Call Volume: $newchvol" | ||
callcurrentold=$callcurrent | ||
fi | ||
callstatus=$(/system/bin/tinymix "Speech_SCP_CALL_STATE" --v) | ||
done | ||
# Restore $callcurrentold and chcurrent | ||
/system/bin/tinymix "ADDA_DL_GAIN" $chcurrent | ||
callcurrentold=0 | ||
fi | ||
sleep 2 | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
on boot | ||
start incalladj | ||
|
||
# Start in-call volume adjusting for headset | ||
service incalladj /vendor/bin/setup_MTK_In-Call_volume_adjust.sh | ||
class main | ||
user root | ||
seclabel u:r:su:s0 | ||
oneshot |