diff --git a/src/common/common.c b/src/common/common.c index cf7289f..66b3b0c 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -821,7 +821,8 @@ int isCharging(void) { static char governor[128]; void enterSleep(void) { - SetRawVolume(-60); + //SetRawVolume(-60); + SetMute(1); // SetRawBrightness(0); putInt("/sys/class/gpio/export", 4); putFile("/sys/class/gpio/gpio4/direction", "out"); @@ -841,6 +842,7 @@ void exitSleep(void) { putInt("/sys/class/pwm/pwmchip0/pwm0/enable",0); putInt("/sys/class/pwm/pwmchip0/pwm0/enable",1); // SetBrightness(GetBrightness()); + SetMute(0); SetVolume(GetVolume()); // restore previous governor diff --git a/src/keymon/keymon.c b/src/keymon/keymon.c index 3d4bcbb..bd145d1 100644 --- a/src/keymon/keymon.c +++ b/src/keymon/keymon.c @@ -176,6 +176,7 @@ int main (int argc, char *argv[]) { } else { val = GetVolume(); if (val0) SetMute(0); } } break; @@ -194,6 +195,7 @@ int main (int argc, char *argv[]) { } else { val = GetVolume(); if (val>0) SetVolume(--val); + if (val==0) SetMute(1); } } break; diff --git a/src/libmsettings/msettings.c b/src/libmsettings/msettings.c index 4299022..f11214d 100644 --- a/src/libmsettings/msettings.c +++ b/src/libmsettings/msettings.c @@ -11,6 +11,9 @@ #include +#include +#include + #include "msettings.h" /////////////////////////////////////// @@ -30,6 +33,7 @@ static Settings DefaultSettings = { static Settings* settings; #define SHM_KEY "/SharedSettings" +#define MI_AO_SETMUTE 0x4008690d static char SettingsPath[256]; static int shm_fd = -1; static int is_host = 0; @@ -67,6 +71,8 @@ void InitSettings(void) { MI_AO_Enable(0); MI_AO_EnableChn(0,0); SetVolume(GetVolume()); + if (GetVolume()==0) SetMute(1); + else SetMute(0); SetBrightness(GetBrightness()); } void QuitSettings(void) { @@ -116,6 +122,17 @@ void SetRawVolume(int val) { MI_AO_SetVolume(0,val); } +void SetMute(int mute) { + int fd = open("/dev/mi_ao", O_RDWR); + if (fd >= 0) { + int buf2[] = {0, mute}; + uint64_t buf1[] = {sizeof(buf2), (uintptr_t)buf2}; + + ioctl(fd, MI_AO_SETMUTE, buf1); + close(fd); + } +} + int GetJack(void) { return 0; } diff --git a/src/libmsettings/msettings.h b/src/libmsettings/msettings.h index a511956..a5edd3e 100644 --- a/src/libmsettings/msettings.h +++ b/src/libmsettings/msettings.h @@ -9,6 +9,7 @@ int GetVolume(void); void SetRawBrightness(int value); // 0-100 void SetRawVolume(int value); // -60-0 +void SetMute(int mute); // 0-1 void SetBrightness(int value); // 0-10 void SetVolume(int value); // 0-20