Skip to main content
Senior
January 23, 2026
Solved

Output gain set is omitted in WM8904_Init()

  • January 23, 2026
  • 2 replies
  • 153 views

Hi,

// WM8904.c
int32_t WM8904_Init(WM8904_Object_t *pObj, WM8904_Init_t *pInit)
 // ...
 if ((WM8904_CurrentDevices & WM8904_OUT_HEADPHONE) == WM8904_OUT_HEADPHONE)
 {
 ret += WM8904_SetVolume(pObj, VOLUME_OUTPUT, (uint8_t)pInit->Volume);
 }

 // ...
 
 /* Store current devices */
 WM8904_CurrentDevices = (pInit->OutputDevice | pInit->InputDevice);

 in line 4, WM8904_CurrentDevices is still 0, so the gain is not set.

I'd change the line this way:

 if ((pInit->OutputDevice & WM8904_OUT_HEADPHONE) == WM8904_OUT_HEADPHONE)
 {
 ret += WM8904_SetVolume(pObj, VOLUME_OUTPUT, (uint8_t)pInit->Volume);
 }

 

Best answer by Saket_Om

Hello @ERROR 

The issue has been solved and released on Github. Please check the link below:

STMicroelectronics/stm32-wm8904 at 195857c3b70fc582fc534df5c8e5d3b2a1c40bb4

2 replies

Technical Moderator
January 23, 2026

Hello @ERROR 

Thank you for bringing this issue to our attention.

I reported this internally.

Internal ticket number: 225790 (This is an internal tracking number and is not accessible or usable by customers).

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"
Saket_OmBest answer
Technical Moderator
January 23, 2026

Hello @ERROR 

The issue has been solved and released on Github. Please check the link below:

STMicroelectronics/stm32-wm8904 at 195857c3b70fc582fc534df5c8e5d3b2a1c40bb4

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"