diff --git a/boards/arm/cxd56xx/common/src/Make.defs b/boards/arm/cxd56xx/common/src/Make.defs index ba10e2182e3..5b427b144d6 100644 --- a/boards/arm/cxd56xx/common/src/Make.defs +++ b/boards/arm/cxd56xx/common/src/Make.defs @@ -34,6 +34,10 @@ CSRCS += cxd56_boot.c +ifeq ($(CONFIG_AUDIO_CXD56), y) +CSRCS += cxd56_audio.c +endif + ifeq ($(CONFIG_CXD56_AUDIO), y) CSRCS += cxd56_audio.c endif diff --git a/boards/arm/cxd56xx/common/src/cxd56_audio.c b/boards/arm/cxd56xx/common/src/cxd56_audio.c index 58ccb66f1e8..0b909459a78 100644 --- a/boards/arm/cxd56xx/common/src/cxd56_audio.c +++ b/boards/arm/cxd56xx/common/src/cxd56_audio.c @@ -47,6 +47,9 @@ #include #include +#include +#include +#include #include #include @@ -216,6 +219,7 @@ int board_aca_power_control(int target, bool en) board_power_control(POWER_AUDIO_AVDD, true); avdd_on = true; } + if (!dvdd_on && (target & CXD5247_DVDD)) { board_power_control(POWER_AUDIO_DVDD, true); @@ -242,12 +246,14 @@ int board_aca_power_control(int target, bool en) board_power_control(POWER_AUDIO_AVDD, false); avdd_on = false; } + if (dvdd_on && (target & CXD5247_DVDD)) { board_power_control(POWER_AUDIO_DVDD, false); dvdd_on = false; } } + return ret; } @@ -268,6 +274,7 @@ bool board_aca_power_monitor(int target) { avdd_stat = board_power_monitor(POWER_AUDIO_AVDD); } + if (target & CXD5247_DVDD) { dvdd_stat = board_power_monitor(POWER_AUDIO_DVDD); @@ -277,7 +284,7 @@ bool board_aca_power_monitor(int target) } #define MUTE_OFF_DELAY (1250 * 1000) /* ms */ -#define MUTE_ON_DELAY (150 * 1000) /* ms */ +#define MUTE_ON_DELAY (150 * 1000) /* ms */ /**************************************************************************** * Name: board_external_amp_mute_control @@ -460,3 +467,56 @@ void board_audio_finalize(void) board_audio_i2s_disable(); } + +/**************************************************************************** + * Name: board_audio_initialize_driver + * + * Description: + * Initialize and register the CXD56 audio driver. + * + ****************************************************************************/ + +static struct cxd56_lower_s g_cxd56_lower; + +int board_audio_initialize_driver(int minor) +{ + FAR struct audio_lowerhalf_s *cxd56; + FAR struct audio_lowerhalf_s *pcm; + char devname[12]; + int ret; + + /* Initialize CXD56 device driver */ + + cxd56 = cxd56_initialize(&g_cxd56_lower); + if (!cxd56) + { + auderr("ERROR: Failed to initialize the CXD56 audio\n"); + + return -ENODEV; + } + + /* Initialize a PCM decoder with the CXD56 instance. */ + + pcm = pcm_decode_initialize(cxd56); + if (!pcm) + { + auderr("ERROR: Failed create the PCM decoder\n"); + + return -ENODEV; + } + + /* Create a device name */ + + snprintf(devname, 12, "pcm%d", minor); + + /* Finally, we can register the PCM/CXD56 audio device. */ + + ret = audio_register(devname, pcm); + if (ret < 0) + { + auderr("ERROR: Failed to register /dev/%s device: %d\n", + devname, ret); + } + + return ret; +} diff --git a/boards/arm/cxd56xx/spresense/include/cxd56_audio.h b/boards/arm/cxd56xx/spresense/include/cxd56_audio.h index 28ad54bb87d..f9b082c107c 100644 --- a/boards/arm/cxd56xx/spresense/include/cxd56_audio.h +++ b/boards/arm/cxd56xx/spresense/include/cxd56_audio.h @@ -161,6 +161,17 @@ void board_audio_initialize(void); void board_audio_finalize(void); +/**************************************************************************** + * Name: board_audio_initialize_driver + * + * Description: + * Initializes a CXD56 audio device driver node with the given number. + * Used by the audio driver. Should not be used by users. + * + ****************************************************************************/ + +int board_audio_initialize_driver(int minor); + #undef EXTERN #if defined(__cplusplus) } diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c b/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c index 99049d24f6e..019d2f613be 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_bringup.c @@ -176,6 +176,7 @@ static void timer_initialize(void) snprintf(devname, sizeof(devname), "/dev/timer%d", i); cxd56_timer_initialize(devname, i); } + return; } #endif @@ -343,6 +344,14 @@ int cxd56_bringup(void) } #endif +#ifdef CONFIG_AUDIO_CXD56 + ret = board_audio_initialize_driver(1); + if (ret < 0) + { + _err("ERROR: Failed to initialize audio. %d\n", ret); + } +#endif + #ifdef CONFIG_VIDEO_ISX012 ret = board_isx012_initialize(IMAGER_I2C); if (ret < 0)