mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
Merged in alinjerpelea/nuttx (pull request #1048)
boards: arm: cxd56xx: audio: add power_control and audio_tone_generator
* boards: arm: cxd56xx: audio: add power_control
Add a simeple way to control the audio power for userspace apps
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* boards: arm: cxd56xx: audio: add audio_tone_generator
Add a simple way to control the audio buzzer with defined frequency
for userspace apps
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
committed by
Gregory Nutt
parent
fae7e63479
commit
716c7c9bee
@@ -939,6 +939,12 @@ CXD56_AUDIO_ECODE cxd56_audio_set_micmap(uint32_t map);
|
|||||||
|
|
||||||
uint32_t cxd56_audio_get_micmap(void);
|
uint32_t cxd56_audio_get_micmap(void);
|
||||||
|
|
||||||
|
/* Tone generator
|
||||||
|
*
|
||||||
|
* Setup tone generator
|
||||||
|
*/
|
||||||
|
bool board_audio_tone_generator(bool en, int16_t vol, uint16_t freq);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* end of extern "C" */
|
} /* end of extern "C" */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <arch/chip/audio.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
@@ -104,6 +105,75 @@ static bool check_pin_i2s_mode(uint32_t pin)
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_audio_power_control
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Power on/off the audio device on the board.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
bool board_audio_power_control(bool en)
|
||||||
|
{
|
||||||
|
if (en)
|
||||||
|
{
|
||||||
|
/* Enable I2S pin. */
|
||||||
|
|
||||||
|
cxd56_audio_en_i2s_io();
|
||||||
|
|
||||||
|
/* Enable speaker output. */
|
||||||
|
|
||||||
|
cxd56_audio_set_spout(true);
|
||||||
|
|
||||||
|
/* Power on Audio driver */
|
||||||
|
|
||||||
|
if (cxd56_audio_poweron() != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Enable BaseBand driver output */
|
||||||
|
|
||||||
|
if (cxd56_audio_en_output() != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cancel output mute. */
|
||||||
|
|
||||||
|
board_external_amp_mute_control(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Set output mute. */
|
||||||
|
|
||||||
|
board_external_amp_mute_control(true);
|
||||||
|
|
||||||
|
/* Disable speaker output. */
|
||||||
|
|
||||||
|
cxd56_audio_set_spout(false);
|
||||||
|
|
||||||
|
/* Disable I2S pin. */
|
||||||
|
|
||||||
|
cxd56_audio_dis_i2s_io();
|
||||||
|
|
||||||
|
/* Power off Audio driver */
|
||||||
|
|
||||||
|
if (cxd56_audio_dis_output() != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Disable BaseBand driver output */
|
||||||
|
|
||||||
|
if (cxd56_audio_poweroff() != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: board_aca_power_control
|
* Name: board_aca_power_control
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1303,3 +1303,48 @@ uint32_t cxd56_audio_get_micmap(void)
|
|||||||
{
|
{
|
||||||
return cxd56_audio_config_get_micmap();
|
return cxd56_audio_config_get_micmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool board_audio_tone_generator(bool en, int16_t vol, uint16_t freq)
|
||||||
|
{
|
||||||
|
if (!en)
|
||||||
|
{
|
||||||
|
/* Stop beep */
|
||||||
|
|
||||||
|
if (cxd56_audio_stop_beep() != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 != freq)
|
||||||
|
{
|
||||||
|
/* Set beep frequency parameter */
|
||||||
|
|
||||||
|
if (cxd56_audio_set_beep_freq(freq) != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (255 != vol)
|
||||||
|
{
|
||||||
|
/* Set beep volume parameter */
|
||||||
|
|
||||||
|
if (cxd56_audio_set_beep_vol(vol) != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (en)
|
||||||
|
{
|
||||||
|
/* Play beep */
|
||||||
|
|
||||||
|
if (cxd56_audio_play_beep() != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -63,6 +63,17 @@ extern "C"
|
|||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_audio_power_control
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Power on/off the audio on the board.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
bool board_audio_power_control(bool en);
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: board_aca_power_control
|
* Name: board_aca_power_control
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user