mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
cxd56: Add input support to Spresense audio driver
Add recording support to the Nuttx audio driver for Spresense. - Supports 16 bit data with 48 kHz sample rate only for now. - Supports 1 (dual mono) 2 or 4 channels. - Only analog mics have been tested so digital is considered unsupported.
This commit is contained in:
committed by
patacongo
parent
610fa1aadc
commit
f2c957144a
@@ -476,7 +476,7 @@ void board_audio_finalize(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static struct cxd56_lower_s g_cxd56_lower;
|
||||
static struct cxd56_lower_s g_cxd56_lower[2];
|
||||
|
||||
int board_audio_initialize_driver(int minor)
|
||||
{
|
||||
@@ -485,9 +485,9 @@ int board_audio_initialize_driver(int minor)
|
||||
char devname[12];
|
||||
int ret;
|
||||
|
||||
/* Initialize CXD56 device driver */
|
||||
/* Initialize CXD56 output device driver */
|
||||
|
||||
cxd56 = cxd56_initialize(&g_cxd56_lower);
|
||||
cxd56 = cxd56_initialize(&g_cxd56_lower[0]);
|
||||
if (!cxd56)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize the CXD56 audio\n");
|
||||
@@ -518,5 +518,30 @@ int board_audio_initialize_driver(int minor)
|
||||
devname, ret);
|
||||
}
|
||||
|
||||
/* Initialize CXD56 input device driver */
|
||||
|
||||
cxd56 = cxd56_initialize(&g_cxd56_lower[1]);
|
||||
if (!cxd56)
|
||||
{
|
||||
auderr("ERROR: Failed to initialize the CXD56 audio\n");
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
/* No decoder support at the moment, only raw PCM data. */
|
||||
|
||||
/* Create a device name */
|
||||
|
||||
snprintf(devname, 12, "pcm_in%d", minor);
|
||||
|
||||
/* Finally, we can register the CXD56 audio input device. */
|
||||
|
||||
ret = audio_register(devname, cxd56);
|
||||
if (ret < 0)
|
||||
{
|
||||
auderr("ERROR: Failed to register /dev/%s device: %d\n",
|
||||
devname, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
+1308
-146
File diff suppressed because it is too large
Load Diff
+39
-1
@@ -169,6 +169,43 @@
|
||||
# define CXD56_SP_DRIVER 3
|
||||
#endif
|
||||
|
||||
/* Mic bias voltage select */
|
||||
|
||||
#define CXD56_MIC_BIAS_20V 1
|
||||
#define CXD56_MIC_BIAS_28V 2
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_MICBIAS_20V)
|
||||
# define CXD56_MIC_BIAS CXD56_MIC_BIAS_20V
|
||||
#else
|
||||
# define CXD56_MIC_BIAS CXD56_MIC_BIAS_28V
|
||||
#endif
|
||||
|
||||
/* Mic select */
|
||||
|
||||
#define CXD56_AUDIO_CFG_MIC CONFIG_CXD56_AUDIO_MIC_CHANNEL_SEL
|
||||
|
||||
/* Mic boot wait time */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_MIC_BOOT_WAIT)
|
||||
#define CXD56_MIC_BOOT_WAIT CONFIG_CXD56_AUDIO_MIC_BOOT_WAIT
|
||||
#else
|
||||
#define CXD56_MIC_BOOT_WAIT 1100
|
||||
#endif
|
||||
|
||||
/* CIC filter input path */
|
||||
|
||||
#define CXD56_AUDIO_CFG_CIC_IN_SEL_NONE 0
|
||||
#define CXD56_AUDIO_CFG_CIC_IN_SEL_CXD 1
|
||||
#define CXD56_AUDIO_CFG_CIC_IN_SEL_DMICIF 2
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_CIC_IN_SEL_CXD)
|
||||
# define CXD56_AUDIO_CFG_CIC_IN CXD56_AUDIO_CFG_CIC_IN_SEL_CXD
|
||||
#elif defined (CONFIG_CXD56_AUDIO_CIC_IN_SEL_DMIC)
|
||||
# define CXD56_AUDIO_CFG_CIC_IN CXD56_AUDIO_CFG_CIC_IN_SEL_DMICIF
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_CIC_IN CXD56_AUDIO_CFG_CIC_IN_SEL_NONE
|
||||
#endif
|
||||
|
||||
/* DMA format */
|
||||
|
||||
#define CXD56_DMA_FORMAT_LR 0
|
||||
@@ -243,7 +280,8 @@ struct cxd56_dev_s
|
||||
#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
|
||||
uint8_t channels; /* Number of channels (1..8) */
|
||||
|
||||
/* enum cxd56_audio_samp_fmt_e format; */ /* Output bits per sample (16 or 24) */
|
||||
uint16_t mic_gain; /* Mic gain */
|
||||
uint64_t mic_boot_start; /* Mic startup wait time */
|
||||
|
||||
uint8_t bitwidth; /* Bits per sample (16 or 24) */
|
||||
bool muted; /* True: Output is muted */
|
||||
|
||||
Reference in New Issue
Block a user