Running custom code when sound driver starts/stops playing sound

Our devices generates electro-magnetic interference which makes the speaker to tick annoyingly. To avoid that, we would like to keep our speaker de-energized all the time, and to power it only during the period when sounds are played. So we need a custom code (that sets/clears a GPIO pin) to be executed when the sound driver starts and stops playing a sound.

Before we switched to Toradex SOMs, we had been using a different manufacturer’s SOMs with BSP provided as sources, so we could add our code to ASPM_START_TX and ASPM_STOP_TX event handlers in the sound driver.

Toradex WEC7 BSP is distributed in the binary form so that’s not the way.

Could you please suggest any solution to make a custom code executed when a sound starts and stops
playing? Is there a possibility to register some driver’s callback function, or something like that? Any idea would be appreciated!

Thank you in advance!

Hi @mirsky ,

Unfortunately on iMX6 we don’t have a way to configure a GPIO for this purpose (on PXA and Tegra platform we have this already).
The functionality could be added be added by us (then you could configure the GPIO it in the registry)
Giving out the source could be a little problematic due to licensing issues.

Until when do you need this feature? so i can schedule it internally.

Dear @germano.tx ,

Thank you for your reply! It would be wonderful to have such a possibility.

To be sure that we are on the same page, could you please confirm that I understood the suggested solution correctly:

  • There will be a registry value that defines the number of the GPIO pin for powering sound on/off.
  • Just before a sound playing starts, the GPIO pin with that number will be set to ioHigh.
  • Just after the sound playing ends, the pin will be reset to ioLow.

Until when do you need this feature? so i can schedule it internally.

We will be grateful if we can have it until May.