Merged in alinjerpelea/nuttx (pull request #1046)
boards: spresense: add audio implementation * boards: arm: cxd56xx: add audio implementation Add the board audio control implemantation Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> * boards: arm: cxd56xx: update audio defconfig Small updates to build the platforms specific audio driver Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> * boards: arm: cxd56xx: drivers: add audio implementation Add the audio implementation for CXD56XX chip Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> * boards: arm: cxd56xx: fix Load switch GPIO During the initial bringup the grong GPIO was set. Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com> Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
3a28d2e6f7
commit
33d0de4d57
946
arch/arm/include/cxd56xx/audio.h
Normal file
946
arch/arm/include/cxd56xx/audio.h
Normal file
@ -0,0 +1,946 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/include/cxd56xx/audio.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* audioutils Audio Utility
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ARCH_ARM_INCLUDE_CXD56XX_CXD56_AUDIO_H
|
||||
#define __ARCH_ARM_INCLUDE_CXD56XX_CXD56_AUDIO_H
|
||||
|
||||
/* API Documents creater with Doxgen */
|
||||
|
||||
/* cxd56_audio_api Audio Driver API
|
||||
*
|
||||
*
|
||||
* chip/cxd56_audio.h
|
||||
* CXD5602 Audio Driver API
|
||||
* CXD5602 Audio SW Team
|
||||
*/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
***************************************************************************/
|
||||
|
||||
/* Mic channel max. */
|
||||
|
||||
#define CXD56_AUDIO_MIC_CH_MAX 8
|
||||
|
||||
/* DNC binary size. */
|
||||
|
||||
#define CXD56_AUDIO_DNC_FW_SIZE 512
|
||||
#define CXD56_AUDIO_DNC_CFG_SIZE 128
|
||||
|
||||
/* DEQ band number. */
|
||||
|
||||
#define CXD56_AUDIO_DEQ_BAND_NUM 6
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* cxd56_audio common return code. */
|
||||
|
||||
#define CXD56_AUDIO_ECODE uint16_t
|
||||
|
||||
#define CXD56_AUDIO_ECODE_OK 0x0000
|
||||
#define CXD56_AUDIO_ECODE_POW 0x1000
|
||||
#define CXD56_AUDIO_ECODE_FIL 0x2000
|
||||
#define CXD56_AUDIO_ECODE_MIC 0x3000
|
||||
#define CXD56_AUDIO_ECODE_VOL 0x4000
|
||||
#define CXD56_AUDIO_ECODE_DIG 0x5000
|
||||
#define CXD56_AUDIO_ECODE_BEP 0x6000
|
||||
#define CXD56_AUDIO_ECODE_INT 0x7000
|
||||
#define CXD56_AUDIO_ECODE_DMA 0x8000
|
||||
#define CXD56_AUDIO_ECODE_ANA 0x9000
|
||||
#define CXD56_AUDIO_ECODE_REG 0xA000
|
||||
#define CXD56_AUDIO_ECODE_CFG 0xB000
|
||||
|
||||
/* Error code of power */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_POW_STATE (CXD56_AUDIO_ECODE_POW | 0x01)
|
||||
|
||||
/* Error code of filter */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_FIL_DNC_BIN (CXD56_AUDIO_ECODE_FIL | 0x01)
|
||||
|
||||
/* Error code of mic */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_MIC_NO_ANA (CXD56_AUDIO_ECODE_MIC | 0x01)
|
||||
#define CXD56_AUDIO_ECODE_MIC_ARG_NULL (CXD56_AUDIO_ECODE_MIC | 0x02)
|
||||
|
||||
/* Error code of volume */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_VOL_ID (CXD56_AUDIO_ECODE_VOL | 0x01)
|
||||
#define CXD56_AUDIO_ECODE_VOL_MAX (CXD56_AUDIO_ECODE_VOL | 0x02)
|
||||
#define CXD56_AUDIO_ECODE_VOL_MIN (CXD56_AUDIO_ECODE_VOL | 0x03)
|
||||
|
||||
/* Error code of digital */
|
||||
|
||||
/* Error code of beep */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_BEP_FREQ_MAX (CXD56_AUDIO_ECODE_BEP | 0x01)
|
||||
#define CXD56_AUDIO_ECODE_BEP_FREQ_MIN (CXD56_AUDIO_ECODE_BEP | 0x02)
|
||||
#define CXD56_AUDIO_ECODE_BEP_VOL_MAX (CXD56_AUDIO_ECODE_BEP | 0x03)
|
||||
#define CXD56_AUDIO_ECODE_BEP_VOL_MIN (CXD56_AUDIO_ECODE_BEP | 0x04)
|
||||
|
||||
/* Error code of interrupt */
|
||||
|
||||
/* Error code of dma */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_DMA_ARG_NULL (CXD56_AUDIO_ECODE_DMA | 0x01)
|
||||
#define CXD56_AUDIO_ECODE_DMA_PATH_INV (CXD56_AUDIO_ECODE_DMA | 0x02)
|
||||
#define CXD56_AUDIO_ECODE_DMA_PATH_COMB (CXD56_AUDIO_ECODE_DMA | 0x03)
|
||||
#define CXD56_AUDIO_ECODE_DMA_PATH_DUP (CXD56_AUDIO_ECODE_DMA | 0x04)
|
||||
#define CXD56_AUDIO_ECODE_DMA_PATH_MAX (CXD56_AUDIO_ECODE_DMA | 0x05)
|
||||
#define CXD56_AUDIO_ECODE_DMA_HANDLE_NULL (CXD56_AUDIO_ECODE_DMA | 0x06)
|
||||
#define CXD56_AUDIO_ECODE_DMA_HANDLE_INV (CXD56_AUDIO_ECODE_DMA | 0x07)
|
||||
#define CXD56_AUDIO_ECODE_DMA_CH_NO_ENABLE (CXD56_AUDIO_ECODE_DMA | 0x08)
|
||||
#define CXD56_AUDIO_ECODE_DMA_CH1_4_INV (CXD56_AUDIO_ECODE_DMA | 0x09)
|
||||
#define CXD56_AUDIO_ECODE_DMA_CH5_8_INV (CXD56_AUDIO_ECODE_DMA | 0x0a)
|
||||
#define CXD56_AUDIO_ECODE_DMA_SMP_TIMEOUT (CXD56_AUDIO_ECODE_DMA | 0x0b)
|
||||
#define CXD56_AUDIO_ECODE_DMA_BUSY (CXD56_AUDIO_ECODE_DMA | 0x0c)
|
||||
|
||||
#define CXD56_AUDIO_ECODE_DMA_CMPLT (CXD56_AUDIO_ECODE_DMA | 0x11)
|
||||
#define CXD56_AUDIO_ECODE_DMA_TRANS (CXD56_AUDIO_ECODE_DMA | 0x12)
|
||||
#define CXD56_AUDIO_ECODE_DMA_CMB (CXD56_AUDIO_ECODE_DMA | 0x13)
|
||||
|
||||
/* Error code of analog */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_ANA_DISABLE (CXD56_AUDIO_ECODE_ANA | 0x01)
|
||||
#define CXD56_AUDIO_ECODE_ANA_PWON (CXD56_AUDIO_ECODE_ANA | 0x02)
|
||||
#define CXD56_AUDIO_ECODE_ANA_PWOFF (CXD56_AUDIO_ECODE_ANA | 0x03)
|
||||
#define CXD56_AUDIO_ECODE_ANA_CLK_EN (CXD56_AUDIO_ECODE_ANA | 0x04)
|
||||
#define CXD56_AUDIO_ECODE_ANA_CHKID (CXD56_AUDIO_ECODE_ANA | 0x05)
|
||||
#define CXD56_AUDIO_ECODE_ANA_SERIAL (CXD56_AUDIO_ECODE_ANA | 0x06)
|
||||
#define CXD56_AUDIO_ECODE_ANA_PWON_MBIAS (CXD56_AUDIO_ECODE_ANA | 0x07)
|
||||
#define CXD56_AUDIO_ECODE_ANA_PWON_INPUT (CXD56_AUDIO_ECODE_ANA | 0x08)
|
||||
#define CXD56_AUDIO_ECODE_ANA_SET_SMASTER (CXD56_AUDIO_ECODE_ANA | 0x09)
|
||||
#define CXD56_AUDIO_ECODE_ANA_PWON_OUTPUT (CXD56_AUDIO_ECODE_ANA | 0x0A)
|
||||
#define CXD56_AUDIO_ECODE_ANA_PWOFF_INPUT (CXD56_AUDIO_ECODE_ANA | 0x0B)
|
||||
#define CXD56_AUDIO_ECODE_ANA_PWOFF_OUTPUT (CXD56_AUDIO_ECODE_ANA | 0x0C)
|
||||
#define CXD56_AUDIO_ECODE_ANA_ENABLE_OUTPUT (CXD56_AUDIO_ECODE_ANA | 0x0D)
|
||||
#define CXD56_AUDIO_ECODE_ANA_DISABLE_OUTPUT (CXD56_AUDIO_ECODE_ANA | 0x0E)
|
||||
#define CXD56_AUDIO_ECODE_ANA_SET_MICGAIN (CXD56_AUDIO_ECODE_ANA | 0x0F)
|
||||
#define CXD56_AUDIO_ECODE_ANA_NOTIFY_MICBOOT (CXD56_AUDIO_ECODE_ANA | 0x10)
|
||||
|
||||
/* Error code of register */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_REG_AC (CXD56_AUDIO_ECODE_REG | 0x100)
|
||||
#define CXD56_AUDIO_ECODE_REG_BCA (CXD56_AUDIO_ECODE_REG | 0x200)
|
||||
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_REVID (CXD56_AUDIO_ECODE_REG_AC | 0x01)
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_DEVID (CXD56_AUDIO_ECODE_REG_AC | 0x02)
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_MICMODE (CXD56_AUDIO_ECODE_REG_AC | 0x03)
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_ALCTGT (CXD56_AUDIO_ECODE_REG_AC | 0x04)
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_ALCKNEE (CXD56_AUDIO_ECODE_REG_AC | 0x05)
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_SPCLIMT (CXD56_AUDIO_ECODE_REG_AC | 0x06)
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_CLKMODE (CXD56_AUDIO_ECODE_REG_AC | 0x07)
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_SEL_INV (CXD56_AUDIO_ECODE_REG_AC | 0x08)
|
||||
#define CXD56_AUDIO_ECODE_REG_AC_CSTE_VOL (CXD56_AUDIO_ECODE_REG_AC | 0x09)
|
||||
|
||||
/* Error code of config */
|
||||
|
||||
#define CXD56_AUDIO_ECODE_CFG_CLK_MODE (CXD56_AUDIO_ECODE_CFG | 0x01)
|
||||
|
||||
enum cxd56_audio_state_e
|
||||
{
|
||||
/* Power OFF state */
|
||||
|
||||
CXD56_AUDIO_POWER_STATE_OFF = 0,
|
||||
|
||||
/* Power ON state */
|
||||
|
||||
CXD56_AUDIO_POWER_STATE_ON
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_state_e cxd56_audio_state_t;
|
||||
|
||||
enum cxd56_audio_i2s_src_byp_e
|
||||
{
|
||||
/* SRC bypass disable */
|
||||
|
||||
CXD56_AUDIO_I2S_BYP_DISABLE = 0,
|
||||
|
||||
/* SRC bpass enable */
|
||||
|
||||
CXD56_AUDIO_I2S_BYP_ENABLE,
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_i2s_src_byp_e cxd56_audio_i2s_src_byp_t;
|
||||
|
||||
enum cxd56_audio_volid_e
|
||||
{
|
||||
/* SDIN1_VOL */
|
||||
|
||||
CXD56_AUDIO_VOLID_MIXER_IN1 = 0,
|
||||
|
||||
/* SDIN2_VOL */
|
||||
|
||||
CXD56_AUDIO_VOLID_MIXER_IN2,
|
||||
|
||||
/* DAC_VOL */
|
||||
|
||||
CXD56_AUDIO_VOLID_MIXER_OUT
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_volid_e cxd56_audio_volid_t;
|
||||
|
||||
/* Select DNC type */
|
||||
|
||||
enum cxd56_audio_dnc_id_e
|
||||
{
|
||||
/* Feed Back DNC */
|
||||
|
||||
CXD56_AUDIO_DNC_ID_FB = 0,
|
||||
|
||||
/* Feed Forward DNC */
|
||||
|
||||
CXD56_AUDIO_DNC_ID_FF
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_dnc_id_e cxd56_audio_dnc_id_t;
|
||||
|
||||
/* Select dma path in */
|
||||
|
||||
enum cxd56_audio_dma_path_e
|
||||
{
|
||||
/* Mic to memory */
|
||||
|
||||
CXD56_AUDIO_DMA_PATH_MIC_TO_MEM = 0,
|
||||
|
||||
/* Memory to BUS I/F1 */
|
||||
|
||||
CXD56_AUDIO_DMA_PATH_MEM_TO_BUSIF1,
|
||||
|
||||
/* Memory to BUS I/F2 */
|
||||
|
||||
CXD56_AUDIO_DMA_PATH_MEM_TO_BUSIF2,
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_dma_path_e cxd56_audio_dma_path_t;
|
||||
|
||||
/* Internal signal type */
|
||||
|
||||
enum cxd56_audio_signal_e
|
||||
{
|
||||
/* MIC1 signal */
|
||||
|
||||
CXD56_AUDIO_SIG_MIC1,
|
||||
|
||||
/* MIC2 signal */
|
||||
|
||||
CXD56_AUDIO_SIG_MIC2,
|
||||
|
||||
/* MIC3 signal */
|
||||
|
||||
CXD56_AUDIO_SIG_MIC3,
|
||||
|
||||
/* MIC4 signal */
|
||||
|
||||
CXD56_AUDIO_SIG_MIC4,
|
||||
|
||||
/* I2S0 signal */
|
||||
|
||||
CXD56_AUDIO_SIG_I2S0,
|
||||
|
||||
/* I2S1 signal */
|
||||
|
||||
CXD56_AUDIO_SIG_I2S1,
|
||||
|
||||
/* BUS I/F1 signal */
|
||||
|
||||
CXD56_AUDIO_SIG_BUSIF1,
|
||||
|
||||
/* BUS I/F2 signal */
|
||||
|
||||
CXD56_AUDIO_SIG_BUSIF2,
|
||||
|
||||
/* MIX signal */
|
||||
|
||||
CXD56_AUDIO_SIG_MIX
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_signal_e cxd56_audio_signal_t;
|
||||
|
||||
/* DMAC ID to get in AS_SetAudioDataPath function */
|
||||
|
||||
enum cxd56_audio_dma_e
|
||||
{
|
||||
/* AudioCodec input */
|
||||
|
||||
CXD56_AUDIO_DMAC_MIC = 0,
|
||||
|
||||
/* I2S_OUT */
|
||||
|
||||
CXD56_AUDIO_DMAC_I2S0_DOWN,
|
||||
|
||||
/* I2S2_OUT */
|
||||
|
||||
CXD56_AUDIO_DMAC_I2S1_DOWN
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_dma_e cxd56_audio_dma_t;
|
||||
|
||||
/* Select output device ID */
|
||||
|
||||
enum cxd56_audio_outdev_e
|
||||
{
|
||||
CXD56_AUDIO_OUTDEV_OFF = 0,
|
||||
CXD56_AUDIO_OUTDEV_SP,
|
||||
CXD56_AUDIO_OUTDEV_I2S
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_outdev_e cxd56_audio_outdev_t;
|
||||
|
||||
enum cxd56_audio_clkmode_e
|
||||
{
|
||||
CXD56_AUDIO_CLKMODE_NORMAL = 0,
|
||||
CXD56_AUDIO_CLKMODE_HIRES,
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_clkmode_e cxd56_audio_clkmode_t;
|
||||
|
||||
enum cxd56_audio_dmafmt_e
|
||||
{
|
||||
CXD56_AUDIO_DMA_FMT_LR = 0,
|
||||
CXD56_AUDIO_DMA_FMT_RL,
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_dmafmt_e cxd56_audio_dmafmt_t;
|
||||
|
||||
enum cxd56_audio_samp_fmt_e
|
||||
{
|
||||
CXD56_AUDIO_SAMP_FMT_24 = 0,
|
||||
CXD56_AUDIO_SAMP_FMT_16
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_samp_fmt_e cxd56_audio_samp_fmt_t;
|
||||
|
||||
enum cxd56_audio_dsr_rate_e
|
||||
{
|
||||
CXD56_AUDIO_DSR_1STEP = 0x0,
|
||||
CXD56_AUDIO_DSR_2STEP,
|
||||
CXD56_AUDIO_DSR_4STEP,
|
||||
CXD56_AUDIO_DSR_6STEP,
|
||||
CXD56_AUDIO_DSR_8STEP,
|
||||
CXD56_AUDIO_DSR_11STEP,
|
||||
CXD56_AUDIO_DSR_12STEP,
|
||||
CXD56_AUDIO_DSR_16STEP,
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_dsr_rate_e cxd56_audio_dsr_rate_t;
|
||||
|
||||
enum cxd56_audio_dma_state_e
|
||||
{
|
||||
CXD56_AUDIO_DMA_STATE_REDY = 0x0,
|
||||
CXD56_AUDIO_DMA_STATE_RUN,
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_dma_state_e cxd56_audio_dma_state_t;
|
||||
|
||||
enum cxd56_audio_micdev_e
|
||||
{
|
||||
CXD56_AUDIO_MIC_DEV_NONE = 0,
|
||||
CXD56_AUDIO_MIC_DEV_ANALOG,
|
||||
CXD56_AUDIO_MIC_DEV_DIGITAL,
|
||||
CXD56_AUDIO_MIC_DEV_ANADIG
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_micdev_e cxd56_audio_micdev_t;
|
||||
|
||||
enum cxd56_audio_sp_drv_e
|
||||
{
|
||||
CXD56_AUDIO_SP_DRV_LINEOUT = 0,
|
||||
CXD56_AUDIO_SP_DRV_1DRIVER,
|
||||
CXD56_AUDIO_SP_DRV_2DRIVER,
|
||||
CXD56_AUDIO_SP_DRV_4DRIVER
|
||||
};
|
||||
|
||||
typedef enum cxd56_audio_sp_drv_e cxd56_audio_sp_drv_t;
|
||||
|
||||
struct cxd56_audio_i2s_param_s
|
||||
{
|
||||
uint32_t data_rate;
|
||||
cxd56_audio_i2s_src_byp_t bypass_mode;
|
||||
};
|
||||
|
||||
typedef struct cxd56_audio_i2s_param_s cxd56_audio_i2s_param_t;
|
||||
|
||||
struct cxd56_audio_mic_gain_s
|
||||
{
|
||||
int32_t gain[CXD56_AUDIO_MIC_CH_MAX];
|
||||
};
|
||||
|
||||
typedef struct cxd56_audio_mic_gain_s cxd56_audio_mic_gain_t;
|
||||
|
||||
struct cxd56_audio_dnc_bin_s
|
||||
{
|
||||
uint32_t firm[CXD56_AUDIO_DNC_FW_SIZE];
|
||||
uint32_t config[CXD56_AUDIO_DNC_CFG_SIZE];
|
||||
};
|
||||
|
||||
typedef struct cxd56_audio_dnc_bin_s cxd56_audio_dnc_bin_t;
|
||||
|
||||
struct cxd56_audio_sel_s
|
||||
{
|
||||
/* Whether to select with AU_DAT_SEL1 */
|
||||
|
||||
bool au_dat_sel1;
|
||||
|
||||
/* Whether to select with AU_DAT_SEL2 */
|
||||
|
||||
bool au_dat_sel2;
|
||||
|
||||
/* Whether to select with COD_INSEL2 */
|
||||
|
||||
bool cod_insel2;
|
||||
|
||||
/* Whether to select with COD_INSEL3 */
|
||||
|
||||
bool cod_insel3;
|
||||
|
||||
/* Whether to select with SRC1IN_SEL */
|
||||
|
||||
bool src1in_sel;
|
||||
|
||||
/* Whether to select with SRC2IN_SEL */
|
||||
|
||||
bool src2in_sel;
|
||||
};
|
||||
|
||||
typedef struct cxd56_audio_sel_s cxd56_audio_sel_t;
|
||||
|
||||
struct cxd56_audio_deq_coef_func_s
|
||||
{
|
||||
uint32_t b0;
|
||||
uint32_t b1;
|
||||
uint32_t b2;
|
||||
uint32_t a0;
|
||||
uint32_t a1;
|
||||
};
|
||||
|
||||
typedef struct cxd56_audio_deq_coef_func_s cxd56_audio_deq_coef_func_t;
|
||||
|
||||
struct cxd56_audio_deq_coef_s
|
||||
{
|
||||
cxd56_audio_deq_coef_func_t coef[CXD56_AUDIO_DEQ_BAND_NUM];
|
||||
};
|
||||
|
||||
typedef struct cxd56_audio_deq_coef_s cxd56_audio_deq_coef_t;
|
||||
|
||||
struct cxd56_audio_dma_mstate_s
|
||||
{
|
||||
uint8_t start;
|
||||
uint8_t err_setting;
|
||||
uint8_t buf_state;
|
||||
};
|
||||
typedef struct cxd56_audio_dma_mstate_s cxd56_audio_dma_mstate_t;
|
||||
|
||||
/* DMAC transfer callback function */
|
||||
|
||||
typedef void (* cxd56_audio_dma_cb_t)(cxd56_audio_dma_t handle,
|
||||
uint32_t code);
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/* Power on Audio driver
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_poweron(void);
|
||||
|
||||
/* Power off BaseBand driver
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_poweroff(void);
|
||||
|
||||
/* Enable clear stereo
|
||||
*
|
||||
* sign_inv: Sign inversion(false: positive, true:negative)
|
||||
* vol: volume, -825:-82.5dB, ... -195:-19.5dB, step:5
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_en_cstereo(bool sign_inv, int16_t vol);
|
||||
|
||||
/* Disable clear stereo
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dis_cstereo(void);
|
||||
|
||||
/* Power on DNC
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_poweron_dnc(void);
|
||||
|
||||
/* Power off DNC
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_poweroff_dnc(void);
|
||||
|
||||
/* Enable DNC
|
||||
*
|
||||
* id: target DNC device
|
||||
* bin: firmware and configurator
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_en_dnc(cxd56_audio_dnc_id_t id,
|
||||
FAR cxd56_audio_dnc_bin_t *bin);
|
||||
|
||||
/* Disable DNC
|
||||
*
|
||||
* id: target DNC device
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dis_dnc(cxd56_audio_dnc_id_t id);
|
||||
|
||||
/* Disable DEQ
|
||||
*
|
||||
* coef: coef data
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_en_deq(FAR cxd56_audio_deq_coef_t *coef);
|
||||
|
||||
/* Disable DEQ
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dis_deq(void);
|
||||
|
||||
/* Enable BaseBand driver input
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_en_input(void);
|
||||
|
||||
/* Enable BaseBand driver output
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_en_output(void);
|
||||
|
||||
/* Disable BaseBand driver input
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dis_input(void);
|
||||
|
||||
/* Disable BaseBand driver output
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dis_output(void);
|
||||
|
||||
/* Set speaker output status
|
||||
*
|
||||
* sp_out_en: Whether speaker output is done or not
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_spout(bool sp_out_en);
|
||||
|
||||
/* Set volume
|
||||
*
|
||||
* id: target volume device id
|
||||
* vol: volume[-1020:-102.0dB, ... 120:12.0dB]
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_vol(cxd56_audio_volid_t id, int16_t vol);
|
||||
|
||||
/* Mute volume
|
||||
*
|
||||
* id: target volume device id
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mute_vol(cxd56_audio_volid_t id);
|
||||
|
||||
/* Unmute volume
|
||||
*
|
||||
* id: target volume device id
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_unmute_vol(cxd56_audio_volid_t id);
|
||||
|
||||
/* mute volume with fade-out
|
||||
*
|
||||
* id: target volume device id
|
||||
* wait: wait fade-out end
|
||||
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mute_vol_fade(cxd56_audio_volid_t id,
|
||||
bool wait);
|
||||
|
||||
/* unmute volume with fade-in
|
||||
*
|
||||
* id: target volume device id
|
||||
* wait: wait fade-in end
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_unmute_vol_fade(cxd56_audio_volid_t id,
|
||||
bool wait);
|
||||
|
||||
/* Set beep frequency parameter
|
||||
*
|
||||
* freq: beep frequency, 94:94Hz, ... 4085:4085Hz, step:1
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_beep_freq(uint16_t freq);
|
||||
|
||||
/* Set beep volume parameter
|
||||
*
|
||||
* vol: beep volume, -90:-90dB, ... 0:0dB, step:3, default:-12,
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_beep_vol(int16_t vol);
|
||||
|
||||
/* Play beep
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_play_beep(void);
|
||||
|
||||
/* Stop beep
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_stop_beep(void);
|
||||
|
||||
/* Set MIC gain
|
||||
*
|
||||
* gain: MIC gain[Analog:0~210[dB*10], Digital:-7850~0[dB*100]]
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_micgain(FAR cxd56_audio_mic_gain_t *gain);
|
||||
|
||||
/* Set DEQ table
|
||||
*
|
||||
* en: DEQ enable or disable
|
||||
* deq: coef table
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_deq(bool en,
|
||||
FAR cxd56_audio_deq_coef_t *deq);
|
||||
|
||||
/* Get dma handle
|
||||
*
|
||||
* path: dma path type
|
||||
* handle: dma handle
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_get_dmahandle(cxd56_audio_dma_path_t path,
|
||||
FAR cxd56_audio_dma_t *handle);
|
||||
|
||||
/* Free dma handle
|
||||
*
|
||||
* handle: Dma handle
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_free_dmahandle(FAR cxd56_audio_dma_t handle);
|
||||
|
||||
/* Set internal data path
|
||||
*
|
||||
* sig: Internal singal type
|
||||
* sel: Internal selector type
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_datapath(cxd56_audio_signal_t sig,
|
||||
cxd56_audio_sel_t sel);
|
||||
|
||||
/* Initialize dma transfer function
|
||||
*
|
||||
* handle: Dma handle
|
||||
* fmt: sampling data format 24bits or 16bits
|
||||
* ch_num: Channel data numbers in DMA data
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_init_dma(cxd56_audio_dma_t handle,
|
||||
cxd56_audio_samp_fmt_t fmt,
|
||||
FAR uint8_t *ch_num);
|
||||
|
||||
/* Initialize dma transfer function
|
||||
*
|
||||
* handle: Dma handle
|
||||
* cb: Call back function for notify dma state
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_dmacb(cxd56_audio_dma_t handle,
|
||||
FAR cxd56_audio_dma_cb_t cb);
|
||||
|
||||
/* Enable dma interrupt
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_en_dmaint(void);
|
||||
|
||||
/* Disable dma interrupt
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dis_dmaint(void);
|
||||
|
||||
/* Clear dma error interrupt state
|
||||
*
|
||||
* handle: Dma handle
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_clear_dmaerrint(cxd56_audio_dma_t handle);
|
||||
|
||||
/* Mask dma error interrupt
|
||||
*
|
||||
* handle: Dma handle
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mask_dmaerrint(cxd56_audio_dma_t handle);
|
||||
|
||||
/* Unmask dma error interrupt
|
||||
*
|
||||
* handle: Dma handle
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_unmask_dmaerrint(cxd56_audio_dma_t handle);
|
||||
|
||||
/* Start dma transfer
|
||||
*
|
||||
* handle: Dma handle
|
||||
* addr: data address
|
||||
* sample: number of samples
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_start_dma(cxd56_audio_dma_t handle,
|
||||
uint32_t addr,
|
||||
uint32_t sample);
|
||||
|
||||
/* Stop dma transfer
|
||||
*
|
||||
* handle: Dma handle
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_stop_dma(cxd56_audio_dma_t handle);
|
||||
|
||||
/* Set audio clock mode
|
||||
*
|
||||
* mode: clock mode
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_clkmode(cxd56_audio_clkmode_t mode);
|
||||
|
||||
/* Get audio clock mode
|
||||
*
|
||||
* cxd56_audio_clkmode_t clock mode
|
||||
*/
|
||||
|
||||
cxd56_audio_clkmode_t cxd56_audio_get_clkmode(void);
|
||||
|
||||
/* Get data format type of dma
|
||||
*
|
||||
* cxd56_audio_dmafmt_t clock mode
|
||||
*/
|
||||
|
||||
cxd56_audio_dmafmt_t cxd56_audio_get_dmafmt(void);
|
||||
|
||||
/* Get mic device type
|
||||
*
|
||||
* cxd56_audio_micdev_t mic device type
|
||||
*/
|
||||
|
||||
cxd56_audio_micdev_t cxd56_audio_get_micdev(void);
|
||||
|
||||
/* Enable digital soft ramp rate control
|
||||
*
|
||||
* rate: Ramp rate
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_en_digsft(cxd56_audio_dsr_rate_t rate);
|
||||
|
||||
/* Disable digital soft ramp rate control
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dis_digsft(void);
|
||||
|
||||
/* Enable I2S I/O
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_en_i2s_io(void);
|
||||
|
||||
/* Disable I2S I/O
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dis_i2s_io(void);
|
||||
|
||||
/* Get audio driver status
|
||||
*
|
||||
* cxd56_audio_state_t value : current status
|
||||
*/
|
||||
|
||||
cxd56_audio_state_t cxd56_audio_get_status(void);
|
||||
|
||||
/* Set audio speaker driver mode
|
||||
*
|
||||
* sp_driver: speaker driver mode
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_spdriver(cxd56_audio_sp_drv_t sp_driver);
|
||||
|
||||
/* Get audio speaker driver mode
|
||||
*
|
||||
* cxd56_audio_sp_drv_t speaker driver mode
|
||||
*/
|
||||
|
||||
cxd56_audio_sp_drv_t cxd56_audio_get_spdriver(void);
|
||||
|
||||
/* Set Mic mapping
|
||||
*
|
||||
* map mic mapping
|
||||
*
|
||||
* CXD56_AUDIO_ECODE return code
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_set_micmap(uint32_t map);
|
||||
|
||||
/* Get Mic mapping
|
||||
*
|
||||
* mic mapping
|
||||
*/
|
||||
|
||||
uint32_t cxd56_audio_get_micmap(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ARCH_ARM_INCLUDE_CXD56XX_CXD56_AUDIO_H */
|
@ -34,6 +34,10 @@
|
||||
|
||||
CSRCS += cxd56_boot.c
|
||||
|
||||
ifeq ($(CONFIG_CXD56_AUDIO), y)
|
||||
CSRCS += cxd56_audio.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y)
|
||||
CSRCS += cxd56_uid.c
|
||||
endif
|
||||
|
390
boards/arm/cxd56xx/common/src/cxd56_audio.c
Normal file
390
boards/arm/cxd56xx/common/src/cxd56_audio.c
Normal file
@ -0,0 +1,390 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/cxd56xx/common/src/cxd56_audio.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include "cxd56_pmic.h"
|
||||
#include "cxd56_gpio.h"
|
||||
#include "cxd56_pinconfig.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Check if the following are defined in the board.h */
|
||||
|
||||
#ifndef CXD5247_XRST
|
||||
# error "CXD5247_XRST must be defined in board.h !!"
|
||||
#endif
|
||||
#ifndef CXD5247_AVDD
|
||||
# error "CXD5247_AVDD must be defined in board.h !!"
|
||||
#endif
|
||||
#ifndef CXD5247_DVDD
|
||||
# error "CXD5247_DVDD must be defined in board.h !!"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: check_pin_i2s_mode
|
||||
*
|
||||
* Description:
|
||||
* Check if the pin is I2S.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static bool check_pin_i2s_mode(uint32_t pin)
|
||||
{
|
||||
bool res = false;
|
||||
cxd56_pin_status_t pstat;
|
||||
|
||||
if (cxd56_pin_status(pin, &pstat) >= 0)
|
||||
{
|
||||
if (pstat.mode == 1)
|
||||
{
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_aca_power_control
|
||||
*
|
||||
* Description:
|
||||
* Power on/off the Aca device on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_aca_power_control(int target, bool en)
|
||||
{
|
||||
int ret = 0;
|
||||
static int first = 1;
|
||||
static bool avdd_on = false;
|
||||
static bool dvdd_on = false;
|
||||
|
||||
if (first)
|
||||
{
|
||||
/* gpio configuration (output disabled yet) */
|
||||
|
||||
cxd56_gpio_config(CXD5247_XRST, false);
|
||||
|
||||
first = 0;
|
||||
}
|
||||
|
||||
if (en)
|
||||
{
|
||||
if (!dvdd_on && (target & CXD5247_DVDD))
|
||||
{
|
||||
/* reset assert */
|
||||
|
||||
cxd56_gpio_write(CXD5247_XRST, false);
|
||||
}
|
||||
|
||||
/* power on */
|
||||
|
||||
if (!avdd_on && (target & CXD5247_AVDD))
|
||||
{
|
||||
board_power_control(POWER_AUDIO_AVDD, true);
|
||||
avdd_on = true;
|
||||
}
|
||||
if (!dvdd_on && (target & CXD5247_DVDD))
|
||||
{
|
||||
board_power_control(POWER_AUDIO_DVDD, true);
|
||||
dvdd_on = true;
|
||||
|
||||
/* reset release */
|
||||
|
||||
cxd56_gpio_write(CXD5247_XRST, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dvdd_on && (target & CXD5247_DVDD))
|
||||
{
|
||||
/* reset assert */
|
||||
|
||||
cxd56_gpio_write(CXD5247_XRST, false);
|
||||
}
|
||||
|
||||
/* power off */
|
||||
|
||||
if (avdd_on && (target & CXD5247_AVDD))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_aca_power_monitor
|
||||
*
|
||||
* Description:
|
||||
* Get status of Power on/off the Aca device on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool board_aca_power_monitor(int target)
|
||||
{
|
||||
bool avdd_stat = true;
|
||||
bool dvdd_stat = true;
|
||||
|
||||
if (target & CXD5247_AVDD)
|
||||
{
|
||||
avdd_stat = board_power_monitor(POWER_AUDIO_AVDD);
|
||||
}
|
||||
if (target & CXD5247_DVDD)
|
||||
{
|
||||
dvdd_stat = board_power_monitor(POWER_AUDIO_DVDD);
|
||||
}
|
||||
|
||||
return avdd_stat && dvdd_stat;
|
||||
}
|
||||
|
||||
#define MUTE_OFF_DELAY (1250 * 1000) /* ms */
|
||||
#define MUTE_ON_DELAY (150 * 1000) /* ms */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_external_amp_mute_control
|
||||
*
|
||||
* Description:
|
||||
* External Amp. Mute on/off.
|
||||
* true: Mute on
|
||||
* false: Mute off
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_external_amp_mute_control(bool en)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (en)
|
||||
{
|
||||
/* Mute ON */
|
||||
|
||||
ret = board_power_control(POWER_AUDIO_MUTE, false);
|
||||
usleep(MUTE_ON_DELAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mute OFF */
|
||||
|
||||
usleep(MUTE_OFF_DELAY);
|
||||
ret = board_power_control(POWER_AUDIO_MUTE, true);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_external_amp_mute_monitor
|
||||
*
|
||||
* Description:
|
||||
* Get External Amp. Mute status.
|
||||
* true: Mute on
|
||||
* false: Mute off
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool board_external_amp_mute_monitor(void)
|
||||
{
|
||||
bool mute = board_power_monitor(POWER_AUDIO_MUTE);
|
||||
return !mute;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_i2s_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable I2S on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_audio_i2s_enable(void)
|
||||
{
|
||||
#ifdef CONFIG_CXD56_I2S0
|
||||
/* Select I2S0_BCK, I2S0_LRCK, I2S0_DATA_IN, I2S0_DATA_OUT. */
|
||||
|
||||
# ifdef CONFIG_CXD56_AUDIO_I2S_DEVICE_1_MASTER
|
||||
/* I2S0 Master. */
|
||||
|
||||
# ifdef CONFIG_CXD56_AUDIO_I2S_LOWEMI_2MA
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S0_M_NORM);
|
||||
# else
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S0_M_HIGH);
|
||||
# endif
|
||||
# else
|
||||
/* I2S0 Slave. */
|
||||
|
||||
# ifdef CONFIG_CXD56_AUDIO_I2S_LOWEMI_2MA
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S0_S_NORM);
|
||||
# else
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S0_S_HIGH);
|
||||
# endif
|
||||
# endif /* CONFIG_CXD56_AUDIO_I2S_DEVICE_1_MASTER */
|
||||
#endif /* CONFIG_CXD56_I2S0 */
|
||||
|
||||
#ifdef CONFIG_CXD56_I2S1
|
||||
/* Select I2S1_BCK, I2S1_LRCK, I2S1_DATA_IN, I2S1_DATA_OUT. */
|
||||
|
||||
# ifdef CONFIG_CXD56_AUDIO_I2S_DEVICE_2_MASTER
|
||||
/* I2S1 Master. */
|
||||
|
||||
# ifdef CONFIG_CXD56_AUDIO_I2S_LOWEMI_2MA
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S1_M_NORM);
|
||||
# else
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S1_M_HIGH);
|
||||
# endif
|
||||
# else
|
||||
/* I2S1 Slave. */
|
||||
|
||||
# ifdef CONFIG_CXD56_AUDIO_I2S_LOWEMI_2MA
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S1_S_NORM);
|
||||
# else
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S1_S_HIGH);
|
||||
# endif
|
||||
# endif /* CONFIG_CXD56_AUDIO_I2S_DEVICE_2_MASTER */
|
||||
#endif /* CONFIG_CXD56_I2S1 */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_i2s_disable
|
||||
*
|
||||
* Description:
|
||||
* Dsiable I2S on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_audio_i2s_disable(void)
|
||||
{
|
||||
#ifdef CONFIG_CXD56_I2S0
|
||||
/* Select GPIO(P1v_00/01/02/03) */
|
||||
|
||||
if (check_pin_i2s_mode(PIN_I2S0_BCK))
|
||||
{
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S0_GPIO);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CXD56_I2S1
|
||||
/* Select GPIO(P1v_00/01/02/03) */
|
||||
|
||||
if (check_pin_i2s_mode(PIN_I2S1_BCK))
|
||||
{
|
||||
CXD56_PIN_CONFIGS(PINCONFS_I2S1_GPIO);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize audio I/O on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_audio_initialize(void)
|
||||
{
|
||||
/* Select MCLK. */
|
||||
|
||||
#ifndef CONFIG_CXD56_AUDIO_ANALOG_NONE
|
||||
CXD56_PIN_CONFIGS(PINCONFS_MCLK);
|
||||
#endif
|
||||
|
||||
/* Select PDM_CLK, PDM_IN, PDM_OUT. */
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_PDM_LOWEMI_2MA
|
||||
CXD56_PIN_CONFIGS(PINCONFS_PDM_NORM);
|
||||
#else
|
||||
CXD56_PIN_CONFIGS(PINCONFS_PDM_HIGH);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_finalize
|
||||
*
|
||||
* Description:
|
||||
* Finalize audio I/O on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_audio_finalize(void)
|
||||
{
|
||||
/* Select GPIO(P1x_00). */
|
||||
|
||||
#ifndef CONFIG_CXD56_AUDIO_ANALOG_NONE
|
||||
CXD56_PIN_CONFIGS(PINCONFS_MCLK_GPIO);
|
||||
#endif
|
||||
|
||||
/* Select GPIO(P1y_00/01/02). */
|
||||
|
||||
CXD56_PIN_CONFIGS(PINCONFS_PDM_GPIO);
|
||||
|
||||
/* Disable I2S. */
|
||||
|
||||
board_audio_i2s_disable();
|
||||
}
|
@ -3,4 +3,5 @@
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
source "drivers/platform/audio/Kconfig"
|
||||
source "drivers/platform/sensors/Kconfig"
|
||||
|
@ -33,4 +33,5 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include platform$(DELIM)audio$(DELIM)Make.defs
|
||||
include platform$(DELIM)sensors$(DELIM)Make.defs
|
||||
|
429
boards/arm/cxd56xx/drivers/audio/Kconfig
Normal file
429
boards/arm/cxd56xx/drivers/audio/Kconfig
Normal file
@ -0,0 +1,429 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
comment "Audio Options"
|
||||
|
||||
menuconfig CXD56_AUDIO
|
||||
bool "CXD56 Audio Driver"
|
||||
default n
|
||||
|
||||
if CXD56_AUDIO
|
||||
|
||||
config CXD56_I2S0
|
||||
bool "I2S0"
|
||||
default y
|
||||
---help---
|
||||
Enable I2S channel 0
|
||||
|
||||
config CXD56_I2S1
|
||||
bool "I2S1"
|
||||
default n
|
||||
---help---
|
||||
Enable I2S channel 1
|
||||
|
||||
menu "Audio baseband config settings"
|
||||
|
||||
choice
|
||||
prompt "Audio analog block selection"
|
||||
default CXD56_AUDIO_ANALOG_CXD5247
|
||||
|
||||
config CXD56_AUDIO_ANALOG_CXD5247
|
||||
bool "CXD5247"
|
||||
|
||||
config CXD56_AUDIO_ANALOG_NONE
|
||||
bool "System does not use audio analog block"
|
||||
endchoice
|
||||
|
||||
if CXD56_AUDIO_ANALOG_CXD5247
|
||||
menu "CXD5247 settings"
|
||||
choice
|
||||
prompt "X'tal frequency of the CXD5247"
|
||||
default CXD56_AUDIO_XTAL_SEL_49_152MHZ
|
||||
|
||||
config CXD56_AUDIO_XTAL_SEL_24_576MHZ
|
||||
bool "24.576MHz"
|
||||
|
||||
config CXD56_AUDIO_XTAL_SEL_49_152MHZ
|
||||
bool "49.152MHz"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "MICBIAS voltage of the CXD5247"
|
||||
default CXD56_AUDIO_MICBIAS_20V
|
||||
|
||||
config CXD56_AUDIO_MICBIAS_20V
|
||||
bool "2.0V"
|
||||
|
||||
config CXD56_AUDIO_MICBIAS_28V
|
||||
bool "2.8V"
|
||||
endchoice
|
||||
|
||||
config CXD56_AUDIO_MIC_CHANNEL_SEL
|
||||
hex "MIC channel select map"
|
||||
default 0xFFFF4321
|
||||
range 0 0xFFFFFFFF
|
||||
---help---
|
||||
This designates microphone input of the CXD5247 in matrix format.
|
||||
One microphone can be assigned to multiple channels (CHs.)
|
||||
(Example: When DMA transfer is performed in monaural mode,
|
||||
AMIC1 is assigned to CH1 and CH2 and the same audio data is
|
||||
transferred to the each channel)
|
||||
|
||||
choice
|
||||
prompt "Output drive strength of MCLKOUT selection"
|
||||
default CXD56_AUDIO_MCLKOUT_WEAKEST
|
||||
|
||||
config CXD56_AUDIO_MCLKOUT_WEAKEST
|
||||
bool "2mA"
|
||||
|
||||
config CXD56_AUDIO_MCLKOUT_WEAKER
|
||||
bool "4mA"
|
||||
|
||||
config CXD56_AUDIO_MCLKOUT_STRONGER
|
||||
bool "6mA"
|
||||
|
||||
config CXD56_AUDIO_MCLKOUT_STRONGEST
|
||||
bool "8mA"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Output drive strength of CLKOUT_DMIC selection"
|
||||
default CXD56_AUDIO_CLKOUT_DMIC_WEAKEST
|
||||
|
||||
config CXD56_AUDIO_CLKOUT_DMIC_WEAKEST
|
||||
bool "2mA"
|
||||
|
||||
config CXD56_AUDIO_CLKOUT_DMIC_WEAKER
|
||||
bool "4mA"
|
||||
|
||||
config CXD56_AUDIO_CLKOUT_DMIC_STRONGER
|
||||
bool "6mA"
|
||||
|
||||
config CXD56_AUDIO_CLKOUT_DMIC_STRONGEST
|
||||
bool "8mA"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Output drive strength of DA_DATA selection"
|
||||
default CXD56_AUDIO_DA_DATA_WEAKEST
|
||||
|
||||
config CXD56_AUDIO_DA_DATA_WEAKEST
|
||||
bool "2mA"
|
||||
|
||||
config CXD56_AUDIO_DA_DATA_WEAKER
|
||||
bool "4mA"
|
||||
|
||||
config CXD56_AUDIO_DA_DATA_STRONGER
|
||||
bool "6mA"
|
||||
|
||||
config CXD56_AUDIO_DA_DATA_STRONGEST
|
||||
bool "8mA"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Output drive strength of GPO_A selection"
|
||||
default CXD56_AUDIO_GPO_A_WEAKEST
|
||||
|
||||
config CXD56_AUDIO_GPO_A_WEAKEST
|
||||
bool "2mA"
|
||||
|
||||
config CXD56_AUDIO_GPO_A_WEAKER
|
||||
bool "4mA"
|
||||
|
||||
config CXD56_AUDIO_GPO_A_STRONGER
|
||||
bool "6mA"
|
||||
|
||||
config CXD56_AUDIO_GPO_A_STRONGEST
|
||||
bool "8mA"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Input source of Cascaded Integrator-Comb filter selection"
|
||||
default CXD56_AUDIO_CIC_IN_SEL_CXD
|
||||
|
||||
config CXD56_AUDIO_CIC_IN_SEL_CXD
|
||||
bool "from CXD5247"
|
||||
|
||||
config CXD56_AUDIO_CIC_IN_SEL_DMIC
|
||||
bool "from DMIC"
|
||||
|
||||
config CXD56_AUDIO_CIC_IN_SEL_NONE
|
||||
bool "No Cascaded Integrator-Comb filter input"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Drive currents of PDM signals"
|
||||
default CXD56_AUDIO_PDM_LOWEMI_2MA
|
||||
|
||||
config CXD56_AUDIO_PDM_LOWEMI_2MA
|
||||
bool "2mA"
|
||||
|
||||
config CXD56_AUDIO_PDM_LOWEMI_4MA
|
||||
bool "4mA"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "HPADC mic bias selection"
|
||||
default CXD56_AUDIO_HPADC_MIC_BIAS_OFF
|
||||
---help---
|
||||
This setting depends on a circuit board configration.
|
||||
Set "Microphone bias is enabled" when a microphone connected to
|
||||
HPADC should be applied with voltage from the CXD5247.
|
||||
Otherwise, set "Microphone bias is disabled".
|
||||
|
||||
config CXD56_AUDIO_HPADC_MIC_BIAS_ON
|
||||
bool "Microphone bias is enabled"
|
||||
|
||||
config CXD56_AUDIO_HPADC_MIC_BIAS_OFF
|
||||
bool "Microphone bias is disabled"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Version of the CXD5247"
|
||||
default CXD56_CXD5247_VER_ES4
|
||||
|
||||
config CXD56_CXD5247_VER_ES2
|
||||
bool "ES Version 2.0"
|
||||
|
||||
config CXD56_CXD5247_VER_ES3
|
||||
bool "ES Version 3.0"
|
||||
|
||||
config CXD56_CXD5247_VER_ES4
|
||||
bool "ES Version 4.0"
|
||||
endchoice
|
||||
|
||||
if CXD56_CXD5247_VER_ES4
|
||||
choice
|
||||
prompt "Speaker time split on drive selection"
|
||||
default CXD56_AUDIO_SP_SPLIT_SHORTEST
|
||||
|
||||
config CXD56_AUDIO_SP_SPLIT_SHORTEST
|
||||
bool "shortest"
|
||||
|
||||
config CXD56_AUDIO_SP_SPLIT_SHORT
|
||||
bool "short"
|
||||
|
||||
config CXD56_AUDIO_SP_SPLIT_LONG
|
||||
bool "long"
|
||||
|
||||
config CXD56_AUDIO_SP_SPLIT_LONGEST
|
||||
bool "longest"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Speaker drive mode selection"
|
||||
default CXD56_AUDIO_SP_DRV_LINEOUT
|
||||
|
||||
config CXD56_AUDIO_SP_DRV_4DRIVERT
|
||||
bool "4Driver(SPK)"
|
||||
|
||||
config CXD56_AUDIO_SP_DRV_2DRIVERT
|
||||
bool "2Driver"
|
||||
|
||||
config CXD56_AUDIO_SP_DRV_1DRIVERT
|
||||
bool "1Driver(HP)"
|
||||
|
||||
config CXD56_AUDIO_SP_DRV_LINEOUT
|
||||
bool "Lineout"
|
||||
endchoice
|
||||
endif # CXD56_CXD5247_VER_ES4
|
||||
endmenu
|
||||
endif # CXD56_AUDIO_ANALOG_CXD5247
|
||||
|
||||
menu "I2S settings"
|
||||
|
||||
if CXD56_I2S0
|
||||
choice
|
||||
prompt "I2S0 device mode selection"
|
||||
default CXD56_AUDIO_I2S_DEVICE_1_SLAVE
|
||||
---help---
|
||||
This designates ports and clock modes that are connected
|
||||
as interfaces for PCM signal input and output.
|
||||
|
||||
config CXD56_AUDIO_I2S_DEVICE_1_SLAVE
|
||||
bool "I2S0 Slave mode"
|
||||
|
||||
config CXD56_AUDIO_I2S_DEVICE_1_MASTER
|
||||
bool "I2S0 Master mode"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "I2S0 format type selection"
|
||||
default CXD56_AUDIO_I2S_FORMAT_1_I2S
|
||||
---help---
|
||||
This designates the format of PCM signals on I2S.
|
||||
|
||||
config CXD56_AUDIO_I2S_FORMAT_1_I2S
|
||||
bool "I2S format"
|
||||
|
||||
config CXD56_AUDIO_I2S_FORMAT_1_LEFT
|
||||
bool "Left Justified format"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "I2S0 bypass mode selection"
|
||||
default CXD56_AUDIO_I2S_BYPASS_MODE_1_DISABLE
|
||||
---help---
|
||||
This designates the bypass mode of the sampling rate converter.
|
||||
To improve sound quality, set it to "Enable".
|
||||
The bypass mode can be enable when audio clk_mode is Hi-Res mode,
|
||||
and I2S device mode is master mode and rate is 192kHz(192000).
|
||||
|
||||
config CXD56_AUDIO_I2S_BYPASS_MODE_1_ENABLE
|
||||
bool "Enable bypass"
|
||||
|
||||
config CXD56_AUDIO_I2S_BYPASS_MODE_1_DISABLE
|
||||
bool "Disable bypass"
|
||||
endchoice
|
||||
|
||||
config CXD56_AUDIO_I2S_RATE_1
|
||||
int "I2S0 data rate"
|
||||
default 48000
|
||||
range 48000 192000
|
||||
---help---
|
||||
This designates input and output data rate of I2S.
|
||||
The maximum rate is 192000.
|
||||
|
||||
endif # CXD56_I2S0
|
||||
|
||||
if CXD56_I2S1
|
||||
choice
|
||||
prompt "I2S1 device mode selection"
|
||||
default CXD56_AUDIO_I2S_DEVICE_2_SLAVE
|
||||
---help---
|
||||
This designates ports and clock modes that are connected
|
||||
as interfaces for PCM signal input and output.
|
||||
|
||||
config CXD56_AUDIO_I2S_DEVICE_2_SLAVE
|
||||
bool "I2S1 Slave mode"
|
||||
|
||||
config CXD56_AUDIO_I2S_DEVICE_2_MASTER
|
||||
bool "I2S1 Master mode"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "I2S1 format type selection"
|
||||
default CXD56_AUDIO_I2S_FORMAT_2_I2S
|
||||
---help---
|
||||
This designates the format of PCM signals on I2S0.
|
||||
|
||||
config CXD56_AUDIO_I2S_FORMAT_2_I2S
|
||||
bool "I2S format"
|
||||
|
||||
config CXD56_AUDIO_I2S_FORMAT_2_LEFT
|
||||
bool "Left Justified format"
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "I2S1 bypass mode selection"
|
||||
default CXD56_AUDIO_I2S_BYPASS_MODE_2_DISABLE
|
||||
---help---
|
||||
This designates the bypass mode of the sampling rate converter.
|
||||
To improve sound quality, set it to "Enable".
|
||||
The bypass mode can be enable when audio clk_mode is Hi-Res mode,
|
||||
and I2S device mode is master mode and rate is 192kHz(192000).
|
||||
|
||||
config CXD56_AUDIO_I2S_BYPASS_MODE_2_ENABLE
|
||||
bool "Enable bypass"
|
||||
|
||||
config CXD56_AUDIO_I2S_BYPASS_MODE_2_DISABLE
|
||||
bool "Disable bypass"
|
||||
endchoice
|
||||
|
||||
config CXD56_AUDIO_I2S_RATE_2
|
||||
int "I2S1 data rate"
|
||||
default 48000
|
||||
range 48000 192000
|
||||
---help---
|
||||
This designates input and output data rate of I2S1.
|
||||
The maximum rate is 192000.
|
||||
|
||||
endif # CXD56_I2S1
|
||||
|
||||
choice
|
||||
prompt "Drive currents of I2S signals"
|
||||
default CXD56_AUDIO_I2S_LOWEMI_2MA
|
||||
|
||||
config CXD56_AUDIO_I2S_LOWEMI_2MA
|
||||
bool "2mA"
|
||||
|
||||
config CXD56_AUDIO_I2S_LOWEMI_4MA
|
||||
bool "4mA"
|
||||
endchoice
|
||||
endmenu
|
||||
|
||||
choice
|
||||
prompt "ON/OFF of Automatic Level Control/Sound Pressure Counter selection"
|
||||
default CXD56_AUDIO_ALC_SPC_SEL_OFF
|
||||
|
||||
config CXD56_AUDIO_ALC_SPC_SEL_OFF
|
||||
bool "All OFF"
|
||||
|
||||
config CXD56_AUDIO_ALC_SPC_SEL_ALC
|
||||
bool "Automatic Level Control ON"
|
||||
|
||||
config CXD56_AUDIO_ALC_SPC_SEL_SPC
|
||||
bool "Sound Pressure Counter ON"
|
||||
endchoice
|
||||
|
||||
if CXD56_AUDIO_ALC_SPC_SEL_ALC
|
||||
menu "Automatic Level Control setting"
|
||||
config CXD56_AUDIO_ALC_KNEE
|
||||
int "Knee levels of Automatic Level Control.[(1/10)dB]"
|
||||
default -40
|
||||
range -635 0
|
||||
---help---
|
||||
This command sets integer values 10 times larger than knee levels of
|
||||
Automatic Level Control. (step width: 0.5 dB) When a value within the
|
||||
range in the table below with a number other than 0 or 5 in one's
|
||||
place is designated, it will be regarded as a integer value round up
|
||||
to zero or five in the one's place. For example, when "-24" is
|
||||
designated, the value will be regarded as "-20".
|
||||
|
||||
config CXD56_AUDIO_ALC_TARGET
|
||||
int "Target level of Automatic Level Control.[dB]"
|
||||
default 0
|
||||
range -63 0
|
||||
endmenu
|
||||
endif # CXD56_AUDIO_ALC_SPC_SEL_ALC
|
||||
|
||||
if CXD56_AUDIO_ALC_SPC_SEL_SPC
|
||||
menu "Sound Pressure Conter setting"
|
||||
config CXD56_AUDIO_SPC_LIMIT
|
||||
int "Limit levels of Sound Pressure Counter.[(1/10)dB]"
|
||||
default 0
|
||||
range -250 0
|
||||
---help---
|
||||
This command sets integer values 10 times larger than limit levels of
|
||||
Sound Pressure Counter. (step width: 0.5 dB) When a value within the
|
||||
range in the table below with a number other than 0 or 5 in one's
|
||||
place is designated, it will be regarded as a integer value round up
|
||||
to zero or five in the one's place. For example, when "-24" is
|
||||
designated, the value will be regarded as "-20".
|
||||
endmenu
|
||||
endif # CXD56_AUDIO_ALC_SPC_SEL_SPC
|
||||
|
||||
choice
|
||||
prompt "LR data format during DMA transfer"
|
||||
default CXD56_AUDIO_DMA_DATA_FORMAT_RL
|
||||
---help---
|
||||
This sets the data arrangement of left channel and right channel in
|
||||
the data format for 16 bit DMA transfer.
|
||||
|
||||
config CXD56_AUDIO_DMA_DATA_FORMAT_LR
|
||||
bool "allocate left channel data in most significant bit"
|
||||
|
||||
config CXD56_AUDIO_DMA_DATA_FORMAT_RL
|
||||
bool "allocate right channel data in most significant bit"
|
||||
endchoice
|
||||
|
||||
config CXD56_AUDIO_MIC_BOOT_WAIT
|
||||
int "Wait time for mic booting.[msec]"
|
||||
default 1100
|
||||
range 0 65535
|
||||
|
||||
endmenu
|
||||
|
||||
endif # CXD56_AUDIO
|
19
boards/arm/cxd56xx/drivers/audio/Make.defs
Normal file
19
boards/arm/cxd56xx/drivers/audio/Make.defs
Normal file
@ -0,0 +1,19 @@
|
||||
CSRCS += cxd56_audio.c
|
||||
CSRCS += cxd56_audio_config.c
|
||||
CSRCS += cxd56_audio_analog.c
|
||||
CSRCS += cxd56_audio_power.c
|
||||
CSRCS += cxd56_audio_filter.c
|
||||
CSRCS += cxd56_audio_mic.c
|
||||
CSRCS += cxd56_audio_volume.c
|
||||
CSRCS += cxd56_audio_digital.c
|
||||
CSRCS += cxd56_audio_beep.c
|
||||
CSRCS += cxd56_audio_irq.c
|
||||
CSRCS += cxd56_audio_dma.c
|
||||
CSRCS += cxd56_audio_ac_reg.c
|
||||
CSRCS += cxd56_audio_bca_reg.c
|
||||
CSRCS += cxd56_audio_aca.c
|
||||
CSRCS += cxd56_audio_pin.c
|
||||
|
||||
DEPPATH += --dep-path platform$(DELIM)audio
|
||||
VPATH += :platform$(DELIM)audio
|
||||
CFLAGS += $(shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)platform$(DELIM)audio)
|
1305
boards/arm/cxd56xx/drivers/audio/cxd56_audio.c
Normal file
1305
boards/arm/cxd56xx/drivers/audio/cxd56_audio.c
Normal file
File diff suppressed because it is too large
Load Diff
1617
boards/arm/cxd56xx/drivers/audio/cxd56_audio_ac_reg.c
Normal file
1617
boards/arm/cxd56xx/drivers/audio/cxd56_audio_ac_reg.c
Normal file
File diff suppressed because it is too large
Load Diff
454
boards/arm/cxd56xx/drivers/audio/cxd56_audio_ac_reg.h
Normal file
454
boards/arm/cxd56xx/drivers/audio/cxd56_audio_ac_reg.h
Normal file
@ -0,0 +1,454 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_ac_reg.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_AC_REG_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_AC_REG_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
enum audio_codec_register_id_e
|
||||
{
|
||||
RI_REVID = 0,
|
||||
RI_DEVICEID,
|
||||
RI_PDN_AMICEXT,
|
||||
RI_PDN_AMIC1,
|
||||
RI_PDN_AMIC2,
|
||||
RI_PDN_DAC,
|
||||
RI_PDN_LINEIN,
|
||||
RI_PDN_MIC,
|
||||
RI_PDN_DMIC,
|
||||
RI_PDN_DSPB,
|
||||
RI_PDN_ANC,
|
||||
RI_PDN_DNC1,
|
||||
RI_PDN_DNC2,
|
||||
RI_PDN_SMSTR,
|
||||
RI_PDN_DSPS2,
|
||||
RI_PDN_DSPS1,
|
||||
RI_PDN_DSPC,
|
||||
RI_FS_FS,
|
||||
RI_DECIM0_EN,
|
||||
RI_DECIM1_EN,
|
||||
RI_SDES_EN,
|
||||
RI_MCK_AHBMSTR_EN,
|
||||
RI_AU_DAT_SEL2,
|
||||
RI_AU_DAT_SEL1,
|
||||
RI_COD_INSEL3,
|
||||
RI_COD_INSEL2,
|
||||
RI_COD_INSEL1,
|
||||
RI_DSR_RATE,
|
||||
RI_DIGSFT,
|
||||
RI_SRC1,
|
||||
RI_SRC1IN_SEL,
|
||||
RI_SRC2,
|
||||
RI_SRC2IN_SEL,
|
||||
RI_DIF2,
|
||||
RI_DIF1,
|
||||
RI_SD2MASTER,
|
||||
RI_SD1MASTER,
|
||||
RI_SDCK_OUTENX,
|
||||
RI_HI_RES_MODE,
|
||||
RI_HPF2_MODE,
|
||||
RI_CIC2IN_SWAP,
|
||||
RI_INV_DMIC2L,
|
||||
RI_INV_DMIC2R,
|
||||
RI_CIC2_GAIN_MODE,
|
||||
RI_CIC2IN_SEL,
|
||||
RI_ADC2_BOOST,
|
||||
RI_INV_AMIC2L,
|
||||
RI_INV_AMIC2R,
|
||||
RI_HPF1_MODE,
|
||||
RI_CIC1IN_SWAP,
|
||||
RI_INV_DMIC1L,
|
||||
RI_INV_DMIC1R,
|
||||
RI_CIC1_GAIN_MODE,
|
||||
RI_CIC1IN_SEL,
|
||||
RI_ADC1_BOOST,
|
||||
RI_ADC_FS,
|
||||
RI_INV_AMIC1L,
|
||||
RI_INV_AMIC1R,
|
||||
RI_HPF4_MODE,
|
||||
RI_CIC4IN_SWAP,
|
||||
RI_INV_DMIC4L,
|
||||
RI_INV_DMIC4R,
|
||||
RI_CIC4IN_SEL,
|
||||
RI_ADC4_BOOST,
|
||||
RI_INV_AMIC4L,
|
||||
RI_INV_AMIC4R,
|
||||
RI_HPF3_MODE,
|
||||
RI_CIC3IN_SWAP,
|
||||
RI_INV_DMIC3L,
|
||||
RI_INV_DMIC3R,
|
||||
RI_CIC3IN_SEL,
|
||||
RI_ADC_3_BOOST,
|
||||
RI_INV_AMIC3L,
|
||||
RI_INV_AMIC3R,
|
||||
RI_CIC1_RGAIN,
|
||||
RI_CIC1_LGAIN,
|
||||
RI_CIC2_RGAIN,
|
||||
RI_CIC2_LGAIN,
|
||||
RI_CIC3_RGAIN,
|
||||
RI_CIC3_LGAIN,
|
||||
RI_CIC4_RGAIN,
|
||||
RI_CIC4_LGAIN,
|
||||
RI_SPC_LIMIT,
|
||||
RI_SPC_EN,
|
||||
RI_ALC_KNEE,
|
||||
RI_ALCTARGET,
|
||||
RI_ALC_REC,
|
||||
RI_ALC_EN,
|
||||
RI_INV_ASP2R,
|
||||
RI_INV_ASP2L,
|
||||
RI_INV_ASP1R,
|
||||
RI_INV_ASP1L,
|
||||
RI_ARC,
|
||||
RI_ARC_VOL,
|
||||
RI_CS_VOL,
|
||||
RI_CS_SIGN,
|
||||
RI_SDOUT_VOL,
|
||||
RI_SDIN2_VOL,
|
||||
RI_SDIN1_VOL,
|
||||
RI_SDIN1_EN,
|
||||
RI_SDIN2_EN,
|
||||
RI_SDOUT1_EN,
|
||||
RI_SDOUT2_EN,
|
||||
RI_MUTE_B,
|
||||
RI_BLF_EN,
|
||||
RI_TRANS_MODE,
|
||||
RI_DAC_VOL,
|
||||
RI_LINEIN_VOL,
|
||||
RI_BEEP_VOL,
|
||||
RI_BEEP_FREQ,
|
||||
RI_BEEP_ON,
|
||||
RI_M_SPCLKERR1,
|
||||
RI_M_SPCLKERR2,
|
||||
RI_ADC1L_VOL,
|
||||
RI_ADC1R_VOL,
|
||||
RI_ADC2L_VOL,
|
||||
RI_ADC2R_VOL,
|
||||
RI_SMS_INTIM,
|
||||
RI_DNC2_AVF,
|
||||
RI_DNC2_MONION1,
|
||||
RI_DNC2_MONIEN1,
|
||||
RI_DNC2_MONION0,
|
||||
RI_DNC2_MONIEN0,
|
||||
RI_DNC1_AVF,
|
||||
RI_DNC1_MONION1,
|
||||
RI_DNC1_MONIEN1,
|
||||
RI_DNC1_MONION0,
|
||||
RI_DNC1_MONIEN0,
|
||||
RI_DNC2_CFMD,
|
||||
RI_DNC2_ESS,
|
||||
RI_DNC2_ZWR,
|
||||
RI_DNC2_MUTE,
|
||||
RI_DNC2_START,
|
||||
RI_DNC1_CFMD,
|
||||
RI_DNC1_ESS,
|
||||
RI_DNC1_ZWR,
|
||||
RI_DNC1_MUTE,
|
||||
RI_DNC1_START,
|
||||
RI_DNC_STB,
|
||||
RI_DCMFS_34,
|
||||
RI_DNC_512,
|
||||
RI_DCMFS,
|
||||
RI_DNC1_CANVOL1,
|
||||
RI_DNC1_CANVOL0,
|
||||
RI_DNC2_CANVOL1,
|
||||
RI_DNC2_CANVOL0,
|
||||
RI_DNC1_MONVOL1,
|
||||
RI_DNC1_MONVOL0,
|
||||
RI_DNC2_MONVOL1,
|
||||
RI_DNC2_MONVOL0,
|
||||
RI_DNC1_ALGAIN1,
|
||||
RI_DNC1_ALGAIN0,
|
||||
RI_DNC2_ALGAIN1,
|
||||
RI_DNC2_ALGAIN0,
|
||||
RI_DNC_PHD,
|
||||
RI_DNC1_LIMIYT,
|
||||
RI_DNC1_LMTON0,
|
||||
RI_DNC1_LIMITR,
|
||||
RI_DNC1_LIMITA,
|
||||
RI_DNC1_INSTMD,
|
||||
RI_DNC2_LIMIYT,
|
||||
RI_DNC2_LMTON0,
|
||||
RI_DNC2_LIMITR,
|
||||
RI_DNC2_LIMITA,
|
||||
RI_DNC2_INSTMD,
|
||||
RI_ANC_FALVL,
|
||||
RI_ANC_TST,
|
||||
RI_ANC_FATST,
|
||||
RI_ENVREG_RESET,
|
||||
RI_ANC_CHSEL,
|
||||
RI_ANC_TR,
|
||||
RI_ANC_TA,
|
||||
RI_ANC_SOUT,
|
||||
RI_ANC_FASPN,
|
||||
RI_ANC_ZWR,
|
||||
RI_ANC_MUTE,
|
||||
RI_ANC_START,
|
||||
RI_ANC_FASTART,
|
||||
RI_ANC_FAWTB,
|
||||
RI_ANC_FAWTA,
|
||||
RI_ANC_ENV1,
|
||||
RI_ANC_ENV0,
|
||||
RI_ANC_CURST,
|
||||
RI_ANC_FAST,
|
||||
RI_ANC_ENV2,
|
||||
RI_NS_AMMD,
|
||||
RI_BPGAIN,
|
||||
RI_BPSEL,
|
||||
RI_NSDI,
|
||||
RI_NSII,
|
||||
RI_BPON,
|
||||
RI_NSMS,
|
||||
RI_CHSEL,
|
||||
RI_NSADJON,
|
||||
RI_NSX2,
|
||||
RI_NSPMUTE,
|
||||
RI_NSDD,
|
||||
RI_OUT2DLY,
|
||||
RI_NSAD,
|
||||
RI_PWMMD,
|
||||
RI_NSAS,
|
||||
RI_NSADJ,
|
||||
RI_VCONT,
|
||||
RI_TEST_OUT,
|
||||
RI_TEST_OUT_SEL0,
|
||||
RI_TEST_OUT_SEL1,
|
||||
RI_TEST_IN,
|
||||
RI_S_RESET,
|
||||
RI_HALT_INHIBIT,
|
||||
RI_FSRDBGMD,
|
||||
RI_BEEP_TEST,
|
||||
RI_ARWPHSET,
|
||||
RI_DSPRAM4_CLR,
|
||||
RI_DSPRAM3_CLR,
|
||||
RI_DSPRAM2_CLR,
|
||||
RI_DSPRAM1_CLR,
|
||||
RI_ALC_DELAY,
|
||||
RI_ALC_ALG,
|
||||
RI_ARC_TIMER,
|
||||
RI_ARC_DLY,
|
||||
RI_SPC_AWEIGHT,
|
||||
RI_SPC_ALC_ATTACK,
|
||||
RI_SPC_ALC_RELEASE,
|
||||
RI_ALC_LPF,
|
||||
RI_SPC_ENERGY,
|
||||
RI_W_RSRV,
|
||||
RI_R_RSRV,
|
||||
RI_SER_MODE,
|
||||
RI_PDM_OUT_EN,
|
||||
RI_FS_CLK_EN,
|
||||
RI_SEL_OUT4_R,
|
||||
RI_SEL_OUT4_L,
|
||||
RI_SEL_OUT3_R,
|
||||
RI_SEL_OUT3_L,
|
||||
RI_SEL_OUT2_R,
|
||||
RI_SEL_OUT2_L,
|
||||
RI_SEL_OUT1_R,
|
||||
RI_SEL_OUT1_L,
|
||||
RI_OUTEN_MIC1L_B,
|
||||
RI_OUTEN_MIC1R_B,
|
||||
RI_OUTEN_MIC2L_B,
|
||||
RI_OUTEN_MIC2R_B,
|
||||
RI_OUTEN_MIC1L_A,
|
||||
RI_OUTEN_MIC1R_A,
|
||||
RI_OUTEN_MIC2L_A,
|
||||
RI_OUTEN_MIC2R_A,
|
||||
RI_SEL_OUTF,
|
||||
RI_SEL_INF,
|
||||
RI_SEL_DECIM,
|
||||
RI_DEQ_COEF_1B0,
|
||||
RI_DEQ_EN,
|
||||
RI_DEQ_COEF_1B1,
|
||||
RI_DEQ_COEF_1B2,
|
||||
RI_DEQ_COEF_1A1,
|
||||
RI_DEQ_COEF_1A2,
|
||||
RI_DEQ_COEF_2B0,
|
||||
RI_DEQ_COEF_2B1,
|
||||
RI_DEQ_COEF_2B2,
|
||||
RI_DEQ_COEF_2A1,
|
||||
RI_DEQ_COEF_2A2,
|
||||
RI_DEQ_COEF_3B0,
|
||||
RI_DEQ_COEF_3B1,
|
||||
RI_DEQ_COEF_3B2,
|
||||
RI_DEQ_COEF_3A1,
|
||||
RI_DEQ_COEF_3A2,
|
||||
RI_DEQ_COEF_4B0,
|
||||
RI_DEQ_COEF_4B1,
|
||||
RI_DEQ_COEF_4B2,
|
||||
RI_DEQ_COEF_4A1,
|
||||
RI_DEQ_COEF_4A2,
|
||||
RI_DEQ_COEF_5B0,
|
||||
RI_DEQ_COEF_5B1,
|
||||
RI_DEQ_COEF_5B2,
|
||||
RI_DEQ_COEF_5A1,
|
||||
RI_DEQ_COEF_5A2,
|
||||
RI_DEQ_COEF_6B0,
|
||||
RI_DEQ_COEF_6B1,
|
||||
RI_DEQ_COEF_6B2,
|
||||
RI_DEQ_COEF_6A1,
|
||||
RI_DEQ_COEF_6A2,
|
||||
RI_LR_SWAP1,
|
||||
RI_LR_SWAP2,
|
||||
RI_DUMMY_0,
|
||||
RI_DUMMY_1,
|
||||
RI_DUMMY_2,
|
||||
RI_DUMMY_3,
|
||||
RI_DUMMY_4,
|
||||
RI_DUMMY_5,
|
||||
RI_DUMMY_6,
|
||||
RI_DUMMY_7,
|
||||
RI_DUMMY_8,
|
||||
RI_DUMMY_9,
|
||||
RI_DUMMY_10,
|
||||
RI_DUMMY_11,
|
||||
RI_DUMMY_12,
|
||||
RI_DUMMY_13,
|
||||
RI_DUMMY_14,
|
||||
RI_DUMMY_15,
|
||||
RI_DUMMY_16,
|
||||
RI_DUMMY_17,
|
||||
RI_DUMMY_18,
|
||||
RI_DUMMY_19,
|
||||
RI_DUMMY_20,
|
||||
RI_DUMMY_21,
|
||||
RI_DUMMY_22,
|
||||
RI_DUMMY_23,
|
||||
RI_DUMMY_24,
|
||||
RI_DUMMY_25,
|
||||
RI_DUMMY_26,
|
||||
RI_DUMMY_27,
|
||||
RI_DUMMY_28,
|
||||
RI_DUMMY_29,
|
||||
RI_DUMMY_30,
|
||||
RI_DUMMY_31,
|
||||
RI_RAM_RW_EN,
|
||||
RI_REG_MAX_ENTRY
|
||||
};
|
||||
|
||||
typedef enum audio_codec_register_id_e AC_REG_ID;
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct cxd56_audio_ac_reg_seloutch_s
|
||||
{
|
||||
uint8_t ch[CXD56_AUDIO_MIC_CH_MAX];
|
||||
};
|
||||
|
||||
typedef struct cxd56_audio_ac_reg_seloutch_s cxd56_audio_ac_reg_seloutch_t;
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_ac_reg_checkid(void);
|
||||
void cxd56_audio_ac_reg_resetdsp(void);
|
||||
void cxd56_audio_ac_reg_initdsp(void);
|
||||
void cxd56_audio_ac_reg_poweron_sdes(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_ac_reg_set_micmode(uint8_t mic_mode);
|
||||
void cxd56_audio_ac_reg_poweron_codec(void);
|
||||
void cxd56_audio_ac_reg_poweroff_codec(void);
|
||||
void cxd56_audio_ac_reg_enable_serialif(void);
|
||||
void cxd56_audio_ac_reg_init_selector(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_ac_reg_set_alcspc(void);
|
||||
void cxd56_audio_ac_reg_poweron_dnc(void);
|
||||
void cxd56_audio_ac_reg_poweroff_dnc(void);
|
||||
void cxd56_audio_ac_reg_disable_dnc(cxd56_audio_dnc_id_t id);
|
||||
void cxd56_audio_ac_reg_enable_dnc(cxd56_audio_dnc_id_t id);
|
||||
void cxd56_audio_ac_reg_mute_dnc(cxd56_audio_dnc_id_t id);
|
||||
void cxd56_audio_ac_reg_unmute_dnc(cxd56_audio_dnc_id_t id);
|
||||
void cxd56_audio_ac_reg_set_dncram(cxd56_audio_dnc_id_t id,
|
||||
FAR cxd56_audio_dnc_bin_t *bin);
|
||||
void cxd56_audio_ac_reg_enable_deq(void);
|
||||
void cxd56_audio_ac_reg_disable_deq(void);
|
||||
void cxd56_audio_ac_reg_set_deq_param(FAR cxd56_audio_deq_coef_t *deq);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_ac_reg_poweron_cic(uint8_t mic_in,
|
||||
uint8_t mic_mode,
|
||||
uint8_t cic_num,
|
||||
FAR cxd56_audio_mic_gain_t *gain);
|
||||
void cxd56_audio_ac_reg_poweroff_cic(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_ac_reg_poweron_decim(uint8_t mic_mode,
|
||||
uint8_t clk_mode);
|
||||
void cxd56_audio_ac_reg_poweroff_decim(void);
|
||||
void cxd56_audio_ac_reg_poweron_smaster(uint8_t clk_mode);
|
||||
void cxd56_audio_ac_reg_poweroff_smaster(void);
|
||||
void cxd56_audio_ac_reg_enable_smaster(void);
|
||||
void cxd56_audio_ac_reg_disable_smaster(void);
|
||||
void cxd56_audio_ac_reg_enable_beep(void);
|
||||
void cxd56_audio_ac_reg_disable_beep(void);
|
||||
void cxd56_audio_ac_reg_set_beep_freq(uint32_t freq);
|
||||
void cxd56_audio_ac_reg_set_beep_vol(uint32_t vol);
|
||||
void cxd56_audio_ac_reg_set_cicgain(uint8_t cic_num,
|
||||
FAR cxd56_audio_mic_gain_t *gain);
|
||||
void cxd56_audio_ac_reg_enable_digsft(void);
|
||||
void cxd56_audio_ac_reg_disable_digsft(void);
|
||||
void cxd56_audio_ac_reg_set_dsrrate(uint32_t rate);
|
||||
void cxd56_audio_ac_reg_set_seloutch(FAR cxd56_audio_ac_reg_seloutch_t *seloutch);
|
||||
void cxd56_audio_ac_reg_enable_dma(void);
|
||||
|
||||
void cxd56_audio_ac_reg_poweron_i2s(uint8_t clk_mode);
|
||||
void cxd56_audio_ac_reg_enable_i2s_src1(void);
|
||||
void cxd56_audio_ac_reg_enable_i2s_src2(void);
|
||||
void cxd56_audio_ac_reg_enable_i2s_bcklrckout(void);
|
||||
void cxd56_audio_ac_reg_disable_i2s_bcklrckout(void);
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_ac_reg_set_selector(cxd56_audio_signal_t sig,
|
||||
cxd56_audio_sel_t sel);
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_ac_reg_enable_cstereo(bool sign_inv,
|
||||
int16_t vol);
|
||||
void cxd56_audio_ac_reg_disable_cstereo(void);
|
||||
void cxd56_audio_ac_reg_set_vol_sdin1(uint32_t vol);
|
||||
void cxd56_audio_ac_reg_set_vol_sdin2(uint32_t vol);
|
||||
void cxd56_audio_ac_reg_set_vol_dac(uint32_t vol);
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_AC_REG_H */
|
801
boards/arm/cxd56xx/drivers/audio/cxd56_audio_aca.c
Normal file
801
boards/arm/cxd56xx/drivers/audio/cxd56_audio_aca.c
Normal file
@ -0,0 +1,801 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_aca.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_aca.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define MIC_CH_BITNUM 4
|
||||
#define MIC_CH_BITMAP 0xf
|
||||
|
||||
#define MIC_GAIN_MAX 150
|
||||
#define MIC_GAIN_MIN 0
|
||||
|
||||
#define PGA_GAIN_MAX 60
|
||||
#define PGA_GAIN_MIN 0
|
||||
|
||||
#define AS_VGAIN_MAX 60
|
||||
#define AS_VGAIN_MIN -95
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_OSC_UNKNOWN,
|
||||
AS_ACA_OSC_24_576MHZ, /* 24.576MHz */
|
||||
AS_ACA_OSC_24_576MHZ_HIRES, /* 24.576MHz,Hi-Res */
|
||||
AS_ACA_OSC_49_152MHZ, /* 49.152MHz */
|
||||
AS_ACA_OSC_49_152MHZ_HIRES, /* 49.152MHz,Hi-Res */
|
||||
AS_ACA_OSC_MAX_ENTRY
|
||||
} asAcaPulcoOscModeId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_MIC_UNKNOWN,
|
||||
AS_ACA_MIC_AMIC, /* Analog MIC */
|
||||
AS_ACA_MIC_DMIC, /* Digital MIC */
|
||||
AS_ACA_MIC_BOTH, /* Analog MIC and Digital MIC */
|
||||
AS_ACA_MIC_MAX_ENTRY
|
||||
} asAcaPulcoMicDeviceId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_MICBIAS_SEL_UNKNOWN,
|
||||
AS_ACA_MICBIAS_SEL_2_0V, /* 2.0V */
|
||||
AS_ACA_MICBIAS_SEL_2_8V, /* 2.8V */
|
||||
AS_ACA_MICBIAS_SEL_MAX_ENTRY
|
||||
} asAcaPulcoMicBiasSelId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_IO_DS_UNKNOWN,
|
||||
AS_ACA_IO_DS_WEAKEST, /* Weakest */
|
||||
AS_ACA_IO_DS_WEAKER, /* Weaker */
|
||||
AS_ACA_IO_DS_STRONGER, /* Stronger */
|
||||
AS_ACA_IO_DS_STRONGEST, /* Strongest */
|
||||
AS_ACA_IO_DS_MAX_ENTRY
|
||||
} asAcaPulcoIoDsId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_SMSTR_MODE_FS_UNKNOWN,
|
||||
AS_SMSTR_MODE_FS_16, /* 16fs */
|
||||
AS_SMSTR_MODE_FS_32, /* 32fs */
|
||||
AS_SMSTR_MODE_FS_MAX_ENTRY
|
||||
} asSmstrModeId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_SMSTR_MCK_FS_UNKNOWN,
|
||||
AS_SMSTR_MCK_FS_512, /* 512fs */
|
||||
AS_SMSTR_MCK_FS_1024, /* 1024fs */
|
||||
AS_SMSTR_MCK_FS_MAX_ENTRY
|
||||
} asSmstrMckId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_SMSTR_PWMMD_UNKNOWN,
|
||||
AS_SMSTR_PWMMD_SINGLE, /* Single side */
|
||||
AS_SMSTR_PWMMD_BOTH, /* Both side */
|
||||
AS_SMSTR_PWMMD_SINGLE_ALTER, /* Single side alternating */
|
||||
AS_SMSTR_PWMMD_BOTH_ALTER, /* Both side alternating */
|
||||
AS_SMSTR_PWMMD_MAX_ENTRY
|
||||
} asSmstrPwmModeId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_SMSTR_CHSEL_UNKNOWN,
|
||||
AS_SMSTR_CHSEL_NORMAL, /* Normal */
|
||||
AS_SMSTR_CHSEL_EXCHANGE, /* Exchange L and R */
|
||||
AS_SMSTR_CHSEL_MAX_ENTRY
|
||||
} asSmstrChSelId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_OUT_UNKNOWN,
|
||||
AS_ACA_OUT_HP, /* Headphone output */
|
||||
AS_ACA_OUT_EP, /* Ear Speaker output */
|
||||
AS_ACA_OUT_PWM, /* PWM output */
|
||||
AS_ACA_OUT_HP_PWM, /* Headphone and PWM output */
|
||||
AS_ACA_OUT_EP_PWM, /* Ear Speaker and PWM output */
|
||||
AS_ACA_OUT_OFF, /* Disable output */
|
||||
AS_ACA_OUT_MAX_ENTRY
|
||||
} asAcaPulcoOutDeviceId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_PWMOUT_UNKNOWN,
|
||||
AS_ACA_PWMOUT_OFF, /* Disable */
|
||||
AS_ACA_PWMOUT_LN, /* LN */
|
||||
AS_ACA_PWMOUT_LP, /* LP */
|
||||
AS_ACA_PWMOUT_RN, /* RN */
|
||||
AS_ACA_PWMOUT_RP, /* RP */
|
||||
AS_ACA_PWMOUT_MAX_ENTRY
|
||||
} asAcaPulcoPwmOutId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_SP_LOOP_MODE_UNKNOWN,
|
||||
AS_ACA_SP_LOOP_MODE_ENABLE,
|
||||
AS_ACA_SP_LOOP_MODE_DISABLE,
|
||||
AS_ACA_SP_LOOP_MODE_MAX_ENTRY
|
||||
} asAcaSpLoopModeId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_SP_DELAY_SEL_UNKNOWN,
|
||||
AS_ACA_SP_DELAY_SEL_NON,
|
||||
AS_ACA_SP_DELAY_SEL_SHORT,
|
||||
AS_ACA_SP_DELAY_SEL_MIDDLE,
|
||||
AS_ACA_SP_DELAY_SEL_LONG,
|
||||
AS_ACA_SP_DELAY_SEL_MAX_ENTRY
|
||||
} asAcaSpDelaySelId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_SP_DLY_FREE_UNKNOWN,
|
||||
AS_ACA_SP_DLY_FREE_OFF,
|
||||
AS_ACA_SP_DLY_FREE_ON,
|
||||
AS_ACA_SP_DLY_FREE_MAX_ENTRY
|
||||
} asAcaSpDlyFreeId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_SP_SPLITON_SEL_UNKNOWN,
|
||||
AS_ACA_SP_SPLITON_SEL_SHORTEST,
|
||||
AS_ACA_SP_SPLITON_SEL_SHORT,
|
||||
AS_ACA_SP_SPLITON_SEL_LONG,
|
||||
AS_ACA_SP_SPLITON_SEL_LONGEST,
|
||||
AS_ACA_SP_SPLITON_SEL_MAX_ENTRY
|
||||
} asAcaSpSplitonSelId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_SP_DRV_SEL_UNKNOWN,
|
||||
AS_ACA_SP_DRV_SEL_4DRIVER,
|
||||
AS_ACA_SP_DRV_SEL_2DRIVER,
|
||||
AS_ACA_SP_DRV_SEL_1DRIVER,
|
||||
AS_ACA_SP_DRV_SEL_LINEOUT,
|
||||
AS_ACA_SP_DRV_SEL_MAX_ENTRY
|
||||
} asAcaSpDrvSelId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_SER_MODE_UNKNOWN,
|
||||
AS_ACA_SER_MODE_8CH, /* 8ch */
|
||||
AS_ACA_SER_MODE_4CH, /* 4ch */
|
||||
AS_ACA_SER_MODE_MAX_ENTRY
|
||||
} asAcaPulcoSerModeId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_SER_FS_UNKNOWN,
|
||||
AS_ACA_SER_FS_128, /* 128fs */
|
||||
AS_ACA_SER_FS_64, /* 64fs */
|
||||
AS_ACA_SER_FS_MAX_ENTRY
|
||||
} asAcaPulcoSerFsId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_SER_SEL_FIX0 = 0,
|
||||
AS_ACA_SER_SEL_AMIC1 = 1,
|
||||
AS_ACA_SER_SEL_AMIC2 = 2,
|
||||
AS_ACA_SER_SEL_AMIC3 = 3,
|
||||
AS_ACA_SER_SEL_AMIC4 = 4,
|
||||
AS_ACA_SER_SEL_DMIC1 = 5,
|
||||
AS_ACA_SER_SEL_DMIC2 = 6,
|
||||
AS_ACA_SER_SEL_DMIC3 = 7,
|
||||
AS_ACA_SER_SEL_DMIC4 = 8,
|
||||
AS_ACA_SER_SEL_DMIC5 = 9,
|
||||
AS_ACA_SER_SEL_DMIC6 = 10,
|
||||
AS_ACA_SER_SEL_DMIC7 = 11,
|
||||
AS_ACA_SER_SEL_DMIC8 = 12,
|
||||
AS_ACA_SER_SEL_UNKNOWN = 15,
|
||||
AS_ACA_SER_SEL_MAX_ENTRY = 16
|
||||
} asAcaPulcoSerSelChId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_SDES_DES_SEL_UNKNOWN,
|
||||
AS_SDES_DES_SEL_CH1,
|
||||
AS_SDES_DES_SEL_CH2,
|
||||
AS_SDES_DES_SEL_CH3,
|
||||
AS_SDES_DES_SEL_CH4,
|
||||
AS_SDES_DES_SEL_CH5,
|
||||
AS_SDES_DES_SEL_CH6,
|
||||
AS_SDES_DES_SEL_CH7,
|
||||
AS_SDES_DES_SEL_CH8,
|
||||
AS_SDES_DES_SEL_MAX_ENTRY
|
||||
} asSdesDesSelOutId;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
AS_ACA_CHECK_ID,
|
||||
AS_ACA_POWER_ON_COMMON,
|
||||
AS_ACA_POWER_ON_INPUT,
|
||||
AS_ACA_POWER_ON_OUTPUT,
|
||||
AS_ACA_SET_SERDES,
|
||||
AS_ACA_SET_SMASTER,
|
||||
AS_ACA_POWER_OFF_COMMON,
|
||||
AS_ACA_POWER_OFF_INPUT,
|
||||
AS_ACA_POWER_OFF_OUTPUT,
|
||||
AS_ACA_POWER_ON_MICBIAS,
|
||||
AS_ACA_POWER_OFF_MICBIAS,
|
||||
AS_ACA_INIT_AMIC,
|
||||
AS_ACA_SET_AMIC_BOOT_DONE,
|
||||
AS_ACA_SET_OUTPUT_DEVICE,
|
||||
AS_ACA_GET_REGISTER,
|
||||
AS_ACA_SET_REGISTER,
|
||||
AS_ACA_CONTROL_TYPE_NUM
|
||||
} AsAcaControlType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
asAcaPulcoOscModeId oscMode;
|
||||
asAcaPulcoMicDeviceId micDev;
|
||||
asAcaPulcoIoDsId gpoDs;
|
||||
asAcaPulcoIoDsId adDataDs;
|
||||
asAcaPulcoIoDsId dmicClkDs;
|
||||
asAcaPulcoIoDsId mclkDs;
|
||||
} asAcaPulcoParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
asAcaPulcoMicDeviceId micDev;
|
||||
asAcaPulcoMicBiasSelId micBiasSel;
|
||||
uint32_t micGain[4];
|
||||
uint32_t pgaGain[4];
|
||||
int32_t vgain[4];
|
||||
} asAcaPulcoInParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
asSmstrModeId mode;
|
||||
asSmstrMckId mckFs;
|
||||
asSmstrPwmModeId pwmMode;
|
||||
asSmstrChSelId chSel;
|
||||
uint8_t out2Dly;
|
||||
} asAcaPulcoSmstrParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
asAcaPulcoOutDeviceId outDev;
|
||||
asAcaPulcoPwmOutId pwmOut[2];
|
||||
asAcaSpDelaySelId spDelay;
|
||||
asAcaSpLoopModeId loopMode;
|
||||
asSmstrModeId mode;
|
||||
asAcaSpDlyFreeId spDlyFree;
|
||||
asAcaSpSplitonSelId spSpliton;
|
||||
asAcaSpDrvSelId spDrv;
|
||||
} asAcaPulcoOutParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t bank;
|
||||
uint32_t addr;
|
||||
uint32_t value;
|
||||
} asAcaPulcoRegParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
asAcaPulcoSerModeId serMode;
|
||||
asAcaPulcoSerFsId serFs;
|
||||
union
|
||||
{
|
||||
asAcaPulcoSerSelChId in[CXD56_AUDIO_MIC_CH_MAX];
|
||||
asSdesDesSelOutId out[CXD56_AUDIO_MIC_CH_MAX];
|
||||
} selCh;
|
||||
} asSerDesParam;
|
||||
|
||||
/* Select output device ID */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* output device none */
|
||||
|
||||
AS_OUT_DEV_OFF,
|
||||
|
||||
/* output device speaker */
|
||||
|
||||
AS_OUT_DEV_SP,
|
||||
|
||||
/* output device i2s */
|
||||
|
||||
AS_OUT_DEV_I2S,
|
||||
AS_OUT_DEV_NUM
|
||||
} asOutDeviceId;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern uint32_t AS_AcaControl(uint8_t type, uint32_t param);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void get_osc_mode(uint8_t cfg_mclk, asAcaPulcoOscModeId *osc)
|
||||
{
|
||||
cxd56_audio_clkmode_t clk_mode = cxd56_audio_config_get_clkmode();
|
||||
|
||||
if (cfg_mclk == CXD56_AUDIO_CFG_XTAL_24_576MHZ)
|
||||
{
|
||||
if (clk_mode == CXD56_AUDIO_CLKMODE_HIRES)
|
||||
{
|
||||
*osc = AS_ACA_OSC_24_576MHZ_HIRES;
|
||||
}
|
||||
else
|
||||
{
|
||||
*osc = AS_ACA_OSC_24_576MHZ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (clk_mode == CXD56_AUDIO_CLKMODE_HIRES)
|
||||
{
|
||||
*osc = AS_ACA_OSC_49_152MHZ_HIRES;
|
||||
}
|
||||
else
|
||||
{
|
||||
*osc = AS_ACA_OSC_49_152MHZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void get_mic_dev(uint32_t cfg_mic, FAR asAcaPulcoMicDeviceId *dev)
|
||||
{
|
||||
bool is_amic = false;
|
||||
bool is_dmic = false;
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < CXD56_AUDIO_MIC_CH_MAX; i++)
|
||||
{
|
||||
uint8_t mic_sel;
|
||||
mic_sel = (cfg_mic >> (i * MIC_CH_BITNUM)) & MIC_CH_BITMAP;
|
||||
if ((mic_sel >= 1) && (mic_sel <= 4))
|
||||
{
|
||||
is_amic = true;
|
||||
}
|
||||
else if ((mic_sel >= 5) && (mic_sel <= 12))
|
||||
{
|
||||
is_dmic = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_amic && is_dmic)
|
||||
{
|
||||
*dev = AS_ACA_MIC_BOTH;
|
||||
}
|
||||
else if(is_amic)
|
||||
{
|
||||
*dev = AS_ACA_MIC_AMIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dev = AS_ACA_MIC_DMIC;
|
||||
}
|
||||
}
|
||||
|
||||
static void get_drv_str(uint8_t cfg_ds, FAR asAcaPulcoIoDsId *ds)
|
||||
{
|
||||
switch (cfg_ds)
|
||||
{
|
||||
case CXD56_AUDIO_CFG_DS_WEAKEST:
|
||||
*ds = AS_ACA_IO_DS_WEAKEST;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_CFG_DS_WEAKER:
|
||||
*ds = AS_ACA_IO_DS_WEAKER;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_CFG_DS_STRONGER:
|
||||
*ds = AS_ACA_IO_DS_STRONGER;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_CFG_DS_STRONGEST:
|
||||
*ds = AS_ACA_IO_DS_STRONGEST;
|
||||
break;
|
||||
|
||||
default:
|
||||
*ds = AS_ACA_IO_DS_WEAKEST;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void get_mic_bias(uint8_t cfg_bsel, FAR asAcaPulcoMicBiasSelId *bsel)
|
||||
{
|
||||
switch (cfg_bsel)
|
||||
{
|
||||
case CXD56_AUDIO_CFG_MIC_BIAS_20V:
|
||||
*bsel = AS_ACA_MICBIAS_SEL_2_0V;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_CFG_MIC_BIAS_28V:
|
||||
*bsel = AS_ACA_MICBIAS_SEL_2_8V;
|
||||
break;
|
||||
|
||||
default:
|
||||
*bsel = AS_ACA_MICBIAS_SEL_2_0V;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void get_sp_split_on(uint8_t cf_sp_spliton, FAR asAcaSpSplitonSelId *spSpliton)
|
||||
{
|
||||
switch (cf_sp_spliton)
|
||||
{
|
||||
case CXD56_AUDIO_CFG_SP_SPLITON_LONGEST:
|
||||
*spSpliton = AS_ACA_SP_SPLITON_SEL_LONGEST;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_CFG_SP_SPLITON_LONG:
|
||||
*spSpliton = AS_ACA_SP_SPLITON_SEL_LONG;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_CFG_SP_SPLITON_SHORT:
|
||||
*spSpliton = AS_ACA_SP_SPLITON_SEL_SHORT;
|
||||
break;
|
||||
|
||||
default:
|
||||
*spSpliton = AS_ACA_SP_SPLITON_SEL_SHORTEST;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void get_sp_driver(uint8_t cfg_sp_drv, FAR asAcaSpDrvSelId *spDrv)
|
||||
{
|
||||
switch (cfg_sp_drv)
|
||||
{
|
||||
case CXD56_AUDIO_SP_DRV_LINEOUT:
|
||||
*spDrv = AS_ACA_SP_DRV_SEL_LINEOUT;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_SP_DRV_1DRIVER:
|
||||
*spDrv = AS_ACA_SP_DRV_SEL_1DRIVER;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_SP_DRV_2DRIVER:
|
||||
*spDrv = AS_ACA_SP_DRV_SEL_2DRIVER;
|
||||
break;
|
||||
|
||||
default:
|
||||
*spDrv = AS_ACA_SP_DRV_SEL_4DRIVER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void get_pwon_param(asAcaPulcoParam *param)
|
||||
{
|
||||
uint32_t mic_map = cxd56_audio_config_get_micmap();
|
||||
|
||||
get_osc_mode((uint8_t)CXD56_AUDIO_CFG_MCLK, ¶m->oscMode);
|
||||
get_mic_dev(mic_map, ¶m->micDev);
|
||||
get_drv_str((uint8_t)CXD56_AUDIO_CFG_GPO_A_DS, ¶m->gpoDs);
|
||||
get_drv_str((uint8_t)CXD56_AUDIO_CFG_DA_DS, ¶m->adDataDs);
|
||||
get_drv_str((uint8_t)CXD56_AUDIO_CFG_DMIC_CLK_DS, ¶m->dmicClkDs);
|
||||
get_drv_str((uint8_t)CXD56_AUDIO_CFG_MCLKOUT_DS, ¶m->mclkDs);
|
||||
}
|
||||
|
||||
void get_serial_param(asSerDesParam *param)
|
||||
{
|
||||
uint8_t mic_mode = cxd56_audio_config_get_micmode();
|
||||
uint32_t mic_map = cxd56_audio_config_get_micmap();
|
||||
uint8_t mic_sel = 0;
|
||||
uint8_t i;
|
||||
|
||||
if (CXD56_AUDIO_CFG_MIC_MODE_128FS == mic_mode)
|
||||
{
|
||||
param->serMode = AS_ACA_SER_MODE_4CH;
|
||||
param->serFs = AS_ACA_SER_FS_128;
|
||||
}
|
||||
else
|
||||
{
|
||||
param->serMode = AS_ACA_SER_MODE_8CH;
|
||||
param->serFs = AS_ACA_SER_FS_64;
|
||||
}
|
||||
|
||||
for (i = 0; i < CXD56_AUDIO_MIC_CH_MAX; i++)
|
||||
{
|
||||
mic_sel = (mic_map >> (i * MIC_CH_BITNUM)) & MIC_CH_BITMAP;
|
||||
param->selCh.in[i] = (asAcaPulcoSerSelChId)mic_sel;
|
||||
}
|
||||
}
|
||||
|
||||
void get_input_param(asAcaPulcoInParam *param,
|
||||
FAR cxd56_audio_mic_gain_t *gain)
|
||||
{
|
||||
uint8_t mic_sel;
|
||||
uint8_t mic_id;
|
||||
uint32_t mic_map = cxd56_audio_config_get_micmap();
|
||||
uint32_t pga_gain;
|
||||
uint8_t i;
|
||||
|
||||
memset((void *)param, 0, sizeof(asAcaPulcoInParam));
|
||||
|
||||
get_mic_dev(mic_map, ¶m->micDev);
|
||||
|
||||
get_mic_bias((uint8_t)CXD56_AUDIO_CFG_MIC_BIAS, ¶m->micBiasSel);
|
||||
|
||||
for (i = 0; i < CXD56_AUDIO_MIC_CH_MAX; i++)
|
||||
{
|
||||
mic_sel = (mic_map >> (i * MIC_CH_BITNUM)) & MIC_CH_BITMAP;
|
||||
if ((mic_sel >= 1) && (mic_sel <= 4))
|
||||
{
|
||||
mic_id = mic_sel - 1;
|
||||
param->micGain[mic_id] = (gain->gain[i] >= MIC_GAIN_MAX) ?
|
||||
MIC_GAIN_MAX : (gain->gain[i] / 30) * 30;
|
||||
|
||||
pga_gain = gain->gain[i] - param->micGain[mic_id];
|
||||
param->pgaGain[mic_id] = (pga_gain >= PGA_GAIN_MAX) ?
|
||||
PGA_GAIN_MAX : pga_gain;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void get_smaster_param(asAcaPulcoSmstrParam *param)
|
||||
{
|
||||
cxd56_audio_clkmode_t clk_mode = cxd56_audio_config_get_clkmode();
|
||||
|
||||
if (clk_mode == CXD56_AUDIO_CLKMODE_HIRES)
|
||||
{
|
||||
param->mode = AS_SMSTR_MODE_FS_32;
|
||||
param->mckFs = AS_SMSTR_MCK_FS_1024;
|
||||
}
|
||||
else
|
||||
{
|
||||
param->mode = AS_SMSTR_MODE_FS_16;
|
||||
param->mckFs = AS_SMSTR_MCK_FS_512;
|
||||
}
|
||||
|
||||
param->chSel = AS_SMSTR_CHSEL_NORMAL;
|
||||
param->out2Dly = 0x00;
|
||||
|
||||
param->pwmMode = AS_SMSTR_PWMMD_BOTH;
|
||||
}
|
||||
|
||||
void get_pwon_out_param(asAcaPulcoOutParam *param)
|
||||
{
|
||||
cxd56_audio_clkmode_t clk_mode = cxd56_audio_config_get_clkmode();
|
||||
|
||||
if (clk_mode == CXD56_AUDIO_CLKMODE_HIRES)
|
||||
{
|
||||
param->mode = AS_SMSTR_MODE_FS_32;
|
||||
}
|
||||
else
|
||||
{
|
||||
param->mode = AS_SMSTR_MODE_FS_16;
|
||||
}
|
||||
|
||||
param->outDev = AS_ACA_OUT_OFF;
|
||||
param->pwmOut[0] = AS_ACA_PWMOUT_UNKNOWN;
|
||||
param->pwmOut[1] = AS_ACA_PWMOUT_UNKNOWN;
|
||||
param->spDelay = AS_ACA_SP_DELAY_SEL_UNKNOWN;
|
||||
param->loopMode = AS_ACA_SP_LOOP_MODE_UNKNOWN;
|
||||
param->spDlyFree = AS_ACA_SP_DLY_FREE_UNKNOWN;
|
||||
|
||||
get_sp_split_on((uint8_t)CXD56_AUDIO_CFG_SP_SPLIT_ON, ¶m->spSpliton);
|
||||
get_sp_driver((uint8_t)cxd56_audio_config_get_spdriver(), ¶m->spDrv);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweron(void)
|
||||
{
|
||||
if (AS_AcaControl(AS_ACA_CHECK_ID, (uint32_t)NULL) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_CHKID;
|
||||
}
|
||||
|
||||
asAcaPulcoParam pwon_param;
|
||||
get_pwon_param(&pwon_param);
|
||||
|
||||
if (AS_AcaControl(AS_ACA_POWER_ON_COMMON, (uint32_t)&pwon_param) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWON;
|
||||
}
|
||||
|
||||
asSerDesParam serial_param;
|
||||
get_serial_param(&serial_param);
|
||||
|
||||
if (AS_AcaControl(AS_ACA_SET_SERDES, (uint32_t)&serial_param) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_SERIAL;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff(void)
|
||||
{
|
||||
if (AS_AcaControl(AS_ACA_POWER_OFF_COMMON, (uint32_t)NULL) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWOFF;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_micbias(void)
|
||||
{
|
||||
if (AS_AcaControl(AS_ACA_POWER_ON_MICBIAS, (uint32_t)NULL) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWON_MBIAS;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_input(FAR cxd56_audio_mic_gain_t *gain)
|
||||
{
|
||||
asAcaPulcoInParam pwon_input_param;
|
||||
|
||||
get_input_param(&pwon_input_param, gain);
|
||||
|
||||
if (AS_AcaControl(AS_ACA_POWER_ON_INPUT, (uint32_t)&pwon_input_param) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWON_INPUT;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_set_smaster(void)
|
||||
{
|
||||
asAcaPulcoSmstrParam smaster_param;
|
||||
|
||||
get_smaster_param(&smaster_param);
|
||||
|
||||
if (AS_AcaControl(AS_ACA_SET_SMASTER, (uint32_t)&smaster_param) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_SET_SMASTER;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_output(void)
|
||||
{
|
||||
asAcaPulcoOutParam pwon_output_param;
|
||||
|
||||
get_pwon_out_param(&pwon_output_param);
|
||||
|
||||
if (AS_AcaControl(AS_ACA_POWER_ON_OUTPUT, (uint32_t)&pwon_output_param) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWON_OUTPUT;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff_input(void)
|
||||
{
|
||||
if (AS_AcaControl(AS_ACA_POWER_OFF_INPUT, (uint32_t)NULL) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWOFF_INPUT;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff_output(void)
|
||||
{
|
||||
if (AS_AcaControl(AS_ACA_POWER_OFF_OUTPUT, (uint32_t)NULL) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWOFF_OUTPUT;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_enable_output(void)
|
||||
{
|
||||
if (AS_AcaControl(AS_ACA_SET_OUTPUT_DEVICE, (uint32_t)AS_OUT_DEV_SP) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_ENABLE_OUTPUT;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_disable_output(void)
|
||||
{
|
||||
if (AS_AcaControl(AS_ACA_SET_OUTPUT_DEVICE, (uint32_t)AS_OUT_DEV_OFF) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_DISABLE_OUTPUT;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_set_micgain(FAR cxd56_audio_mic_gain_t *gain)
|
||||
{
|
||||
asAcaPulcoInParam mic_gain_param;
|
||||
|
||||
get_input_param(&mic_gain_param, gain);
|
||||
|
||||
if (AS_AcaControl(AS_ACA_INIT_AMIC, (uint32_t)&mic_gain_param) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_SET_MICGAIN;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_notify_micbootdone(void)
|
||||
{
|
||||
if (AS_AcaControl(AS_ACA_SET_AMIC_BOOT_DONE, (uint32_t)NULL) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_NOTIFY_MICBOOT;
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_read_reg(asAcaPulcoRegParam *param)
|
||||
{
|
||||
AS_AcaControl(AS_ACA_GET_REGISTER, (uint32_t)param);
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_write_reg(asAcaPulcoRegParam *param)
|
||||
{
|
||||
AS_AcaControl(AS_ACA_SET_REGISTER, (uint32_t)param);
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
83
boards/arm/cxd56xx/drivers/audio/cxd56_audio_aca.h
Normal file
83
boards/arm/cxd56xx/drivers/audio/cxd56_audio_aca.h
Normal file
@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_aca.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_ACA_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_ACA_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define DNC1_IRAM_BASE 0x3000
|
||||
#define DNC1_CRAM_BASE 0x3800
|
||||
#define DNC2_IRAM_BASE 0x3c00
|
||||
#define DNC2_CRAM_BASE 0x4400
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweron(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_micbias(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_input(FAR cxd56_audio_mic_gain_t *gain);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_set_smaster(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweron_output(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff_input(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_poweroff_output(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_enable_output(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_disable_output(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_set_micgain(FAR cxd56_audio_mic_gain_t *gain);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_aca_notify_micbootdone(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_ACA_H */
|
309
boards/arm/cxd56xx/drivers/audio/cxd56_audio_analog.c
Normal file
309
boards/arm/cxd56xx/drivers/audio/cxd56_audio_analog.c
Normal file
@ -0,0 +1,309 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_analog.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <time.h>
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_analog.h"
|
||||
#include "cxd56_audio_aca.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define AUD_MCLK_EXT (0u<<16) /* External XTAL */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
inline void cxd56_audio_clock_enable(uint32_t clk, uint32_t div);
|
||||
inline void cxd56_audio_clock_disable(void);
|
||||
inline bool cxd56_audio_clock_is_enabled(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
uint64_t g_mic_boot_start_time = 0x0ull;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void clear_mic_boot_time(void)
|
||||
{
|
||||
g_mic_boot_start_time = 0x0ull;
|
||||
}
|
||||
|
||||
static void set_mic_boot_time(void)
|
||||
{
|
||||
struct timespec start;
|
||||
if (clock_gettime(CLOCK_REALTIME, &start) < 0)
|
||||
{
|
||||
g_mic_boot_start_time = 0x0ull;
|
||||
return;
|
||||
}
|
||||
|
||||
g_mic_boot_start_time = (uint64_t)start.tv_sec * 1000 +
|
||||
(uint64_t)start.tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
static void wait_mic_boot_finish(void)
|
||||
{
|
||||
if (g_mic_boot_start_time != 0x0ull)
|
||||
{
|
||||
struct timespec end;
|
||||
if (clock_gettime(CLOCK_REALTIME, &end) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint64_t time = (uint64_t)end.tv_sec * 1000 +
|
||||
(uint64_t)end.tv_nsec / 1000000 -
|
||||
g_mic_boot_start_time;
|
||||
|
||||
if (time < CXD56_AUDIO_MIC_BOOT_WAIT)
|
||||
{
|
||||
usleep((CXD56_AUDIO_MIC_BOOT_WAIT - time) * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweron(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
if (board_aca_power_control(CXD5247_AVDD | CXD5247_DVDD, true) != 0)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWON;
|
||||
}
|
||||
|
||||
if (!board_aca_power_monitor(CXD5247_AVDD | CXD5247_DVDD))
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_PWON;
|
||||
}
|
||||
|
||||
ret = cxd56_audio_aca_poweron();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
cxd56_audio_clock_enable(AUD_MCLK_EXT, 0);
|
||||
if (!cxd56_audio_clock_is_enabled())
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_ANA_CLK_EN;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweroff(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
cxd56_audio_clock_disable();
|
||||
|
||||
ret = cxd56_audio_aca_poweroff();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
board_aca_power_control(CXD5247_AVDD | CXD5247_DVDD, false);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweron_input(FAR cxd56_audio_mic_gain_t *gain)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
uint8_t mic_dev = cxd56_audio_config_get_micdev();
|
||||
|
||||
if ((mic_dev == CXD56_AUDIO_CFG_MIC_DEV_ANALOG) ||
|
||||
(mic_dev == CXD56_AUDIO_CFG_MIC_DEV_ANADIG))
|
||||
{
|
||||
ret = cxd56_audio_aca_poweron_micbias();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
set_mic_boot_time();
|
||||
}
|
||||
|
||||
ret = cxd56_audio_aca_poweron_input(gain);
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweron_output(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
|
||||
ret = cxd56_audio_aca_set_smaster();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = cxd56_audio_aca_poweron_output();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweroff_input(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
ret = cxd56_audio_aca_poweroff_input();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
clear_mic_boot_time();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweroff_output(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
ret = cxd56_audio_aca_poweroff_output();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_enable_output(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
ret = cxd56_audio_aca_enable_output();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_disable_output(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
ret = cxd56_audio_aca_disable_output();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_set_micgain(FAR cxd56_audio_mic_gain_t *gain)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
|
||||
ret = cxd56_audio_aca_set_micgain(gain);
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_wait_input_standby()
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
#ifdef CONFIG_CXD56_AUDIO_ANALOG_CXD5247
|
||||
wait_mic_boot_finish();
|
||||
ret = cxd56_audio_aca_notify_micbootdone();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
76
boards/arm/cxd56xx/drivers/audio/cxd56_audio_analog.h
Normal file
76
boards/arm/cxd56xx/drivers/audio/cxd56_audio_analog.h
Normal file
@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_analog.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_ANALOG_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_ANALOG_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweron(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweroff(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweron_input(FAR cxd56_audio_mic_gain_t *gain);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweron_output(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweroff_input(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_poweroff_output(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_enable_output(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_disable_output(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_set_micgain(FAR cxd56_audio_mic_gain_t *gain);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_analog_wait_input_standby(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_ANALOG_H */
|
1197
boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.c
Normal file
1197
boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.c
Normal file
File diff suppressed because it is too large
Load Diff
312
boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.h
Normal file
312
boards/arm/cxd56xx/drivers/audio/cxd56_audio_bca_reg.h
Normal file
@ -0,0 +1,312 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_bca_reg.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_BCA_REG_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_BCA_REG_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BCA_Mic_In_start_adr,
|
||||
BCA_Mic_In_sample_no,
|
||||
BCA_Mic_In_rtd_trg,
|
||||
BCA_Mic_In_nointr,
|
||||
BCA_Mic_In_bitwt,
|
||||
BCA_Mic_In_ch8_sel,
|
||||
BCA_Mic_In_ch7_sel,
|
||||
BCA_Mic_In_ch6_sel,
|
||||
BCA_Mic_In_ch5_sel,
|
||||
BCA_Mic_In_ch4_sel,
|
||||
BCA_Mic_In_ch3_sel,
|
||||
BCA_Mic_In_ch2_sel,
|
||||
BCA_Mic_In_ch1_sel,
|
||||
BCA_Mic_In_start,
|
||||
BCA_Mic_In_error_setting,
|
||||
BCA_Mic_In_monbuf,
|
||||
BCA_I2s1_In_start_adr,
|
||||
BCA_I2s1_In_sample_no,
|
||||
BCA_I2s1_In_rtd_trg,
|
||||
BCA_I2s1_In_nointr,
|
||||
BCA_I2s1_In_bitwt,
|
||||
BCA_I2s1_In_ch2_sel,
|
||||
BCA_I2s1_In_ch1_sel,
|
||||
BCA_I2s1_In_Mon_start,
|
||||
BCA_I2s1_In_Mon_error_setting,
|
||||
BCA_I2s1_In_Mon_monbuf,
|
||||
BCA_I2s2_In_start_adr,
|
||||
BCA_I2s2_In_sample_no,
|
||||
BCA_I2s2_In_rtd_trg,
|
||||
BCA_I2s2_In_nointr,
|
||||
BCA_I2s2_In_bitwt,
|
||||
BCA_I2s2_In_ch2_sel,
|
||||
BCA_I2s2_In_ch1_sel,
|
||||
BCA_I2s2_In_Mon_start,
|
||||
BCA_I2s2_In_Mon_error_setting,
|
||||
BCA_I2s2_In_Mon_monbuf,
|
||||
BCA_I2s1_Out_start_adr,
|
||||
BCA_I2s1_Out_sample_no,
|
||||
BCA_I2s1_Out_rtd_trg,
|
||||
BCA_I2s1_Out_nointr,
|
||||
BCA_I2s1_Out_bitwt,
|
||||
BCA_I2s1_Out_sd1_r_sel,
|
||||
BCA_I2s1_Out_sd1_l_sel,
|
||||
BCA_I2s1_Out_Mon_start,
|
||||
BCA_I2s1_Out_Mon_error_setting,
|
||||
BCA_I2s1_Out_Mon_monbuf,
|
||||
BCA_I2s2_Out_start_adr,
|
||||
BCA_I2s2_Out_sample_no,
|
||||
BCA_I2s2_Out_rtd_trg,
|
||||
BCA_I2s2_Out_nointr,
|
||||
BCA_I2s2_Out_bitwt,
|
||||
BCA_I2s2_Out_sd1_r_sel,
|
||||
BCA_I2s2_Out_sd1_l_sel,
|
||||
BCA_I2s2_Out_Mon_start,
|
||||
BCA_I2s2_Out_Mon_error_setting,
|
||||
BCA_I2s2_Out_Mon_monbuf,
|
||||
BCA_I2s_ensel,
|
||||
BCA_Mic_In_prdat_u,
|
||||
BCA_I2s1_In_prdat_u,
|
||||
BCA_I2s2_In_prdat_u,
|
||||
BCA_I2s1_Out_prdat_d,
|
||||
BCA_I2s2_Out_prdat_d,
|
||||
BCA_Mic_Int_Ctrl_done_mic,
|
||||
BCA_Mic_Int_Ctrl_err_mic,
|
||||
BCA_Mic_Int_Ctrl_smp_mic,
|
||||
BCA_Mic_Int_Ctrl_cmb_mic,
|
||||
BCA_I2s1_Int_Ctrl_done_i2so,
|
||||
BCA_I2s1_Int_Ctrl_err_i2so,
|
||||
BCA_I2s1_Int_Ctrl_done_i2si,
|
||||
BCA_I2s1_Int_Ctrl_err_i2si,
|
||||
BCA_I2s1_Int_Ctrl_smp_i2s,
|
||||
BCA_I2s1_Int_Ctrl_cmb_i2s,
|
||||
BCA_I2s2_Int_Ctrl_done_i2so,
|
||||
BCA_I2s2_Int_Ctrl_err_i2so,
|
||||
BCA_I2s2_Int_Ctrl_done_i2si,
|
||||
BCA_I2s2_Int_Ctrl_err_i2si,
|
||||
BCA_I2s2_Int_Ctrl_smp_i2s,
|
||||
BCA_I2s2_Int_Ctrl_cmb_i2s,
|
||||
BCA_Mic_Int_Mask_done_mic,
|
||||
BCA_Mic_Int_Mask_err_mic,
|
||||
BCA_Mic_Int_Mask_smp_mic,
|
||||
BCA_Mic_Int_Mask_cmb_mic,
|
||||
BCA_Mic_Int_Mask_nostpmsk,
|
||||
BCA_Mic_Int_Mask_srst_mic,
|
||||
BCA_I2s1_Int_Mask_done_i2so,
|
||||
BCA_I2s1_Int_Mask_err_i2so,
|
||||
BCA_I2s1_Int_Mask_done_i2si,
|
||||
BCA_I2s1_Int_Mask_err_i2si,
|
||||
BCA_I2s1_Int_Mask_smp_i2s,
|
||||
BCA_I2s1_Int_Mask_cmb_i2s,
|
||||
BCA_I2s1_Int_Mask_nostpmsk,
|
||||
BCA_I2s1_Int_Mask_srst_i2s,
|
||||
BCA_I2s2_Int_Mask_done_i2so,
|
||||
BCA_I2s2_Int_Mask_err_i2so,
|
||||
BCA_I2s2_Int_Mask_done_i2si,
|
||||
BCA_I2s2_Int_Mask_err_i2si,
|
||||
BCA_I2s2_Int_Mask_smp_i2s,
|
||||
BCA_I2s2_Int_Mask_cmb_i2s,
|
||||
BCA_I2s2_Int_Mask_nostpmsk,
|
||||
BCA_I2s2_Int_Mask_srst_i2s,
|
||||
BCA_Int_m_hresp_err,
|
||||
BCA_Int_m_i2s1_bck_err1,
|
||||
BCA_Int_m_i2s1_bck_err2,
|
||||
BCA_Int_m_anc_faint,
|
||||
BCA_Int_m_ovf_smasl,
|
||||
BCA_Int_m_ovf_smasr,
|
||||
BCA_Int_m_ovf_dnc1l,
|
||||
BCA_Int_m_ovf_dnc1r,
|
||||
BCA_Int_m_ovf_dnc2l,
|
||||
BCA_Int_m_ovf_dnc2r,
|
||||
BCA_Int_clr_hresp_err,
|
||||
BCA_Int_clr_i2s1_bck_err1,
|
||||
BCA_Int_clr_i2S1_bck_err2,
|
||||
BCA_Int_clr_anc_faint,
|
||||
BCA_Int_clr_ovf_smasl,
|
||||
BCA_Int_clr_ovf_smasr,
|
||||
BCA_Int_clr_ovf_dnc1l,
|
||||
BCA_Int_clr_ovf_dnc1r,
|
||||
BCA_Int_clr_ovf_dnc2l,
|
||||
BCA_Int_clr_ovf_dnc2r,
|
||||
BCA_Int_hresp_err,
|
||||
BCA_Int_i2s_bck_err1,
|
||||
BCA_Int_i2s_bck_err2,
|
||||
BCA_Int_anc_faint,
|
||||
BCA_Int_ovf_smasl,
|
||||
BCA_Int_ovf_smasr,
|
||||
BCA_Int_ovf_dnc1l,
|
||||
BCA_Int_ovf_dnc1r,
|
||||
BCA_Int_ovf_dnc2l,
|
||||
BCA_Int_ovf_dnc2r,
|
||||
BCA_Dbg_Mic_ch1_data,
|
||||
BCA_Dbg_Mic_ch2_data,
|
||||
BCA_Dbg_Mic_ch3_data,
|
||||
BCA_Dbg_Mic_ch4_data,
|
||||
BCA_Dbg_Mic_ch5_data,
|
||||
BCA_Dbg_Mic_ch6_data,
|
||||
BCA_Dbg_Mic_ch7_data,
|
||||
BCA_Dbg_Mic_ch8_data,
|
||||
BCA_Dbg_I2s1_u_ch1_data,
|
||||
BCA_Dbg_I2s1_u_ch2_data,
|
||||
BCA_Dbg_I2s1_d_ch1_data,
|
||||
BCA_Dbg_I2s1_d_ch2_data,
|
||||
BCA_Dbg_I2s2_u_ch1_data,
|
||||
BCA_Dbg_I2s2_u_ch2_data,
|
||||
BCA_Dbg_I2s2_d_ch1_data,
|
||||
BCA_Dbg_I2s2_d_ch2_data,
|
||||
BCA_Dbg_Ctrl_mic_dbg_en,
|
||||
BCA_Dbg_Ctrl_I2s1_dbg_u_en,
|
||||
BCA_Dbg_Ctrl_I2s1_dbg_d_en,
|
||||
BCA_Dbg_Ctrl_I2s2_dbg_u_en,
|
||||
BCA_Dbg_Ctrl_I2s2_dbg_d_en,
|
||||
BCA_Clk_En_ahbmstr_mic_en,
|
||||
BCA_Clk_En_ahbmstr_I2s1_en,
|
||||
BCA_Clk_En_ahbmstr_I2s2_en,
|
||||
BCA_Mclk_Mon_thresh,
|
||||
AHB_Master_Mic_Mask,
|
||||
AHB_Master_I2s1_Mask,
|
||||
AHB_Master_I2s2_Mask,
|
||||
BCA_REG_MAX_ENTRY
|
||||
} BCA_REG_ID;
|
||||
|
||||
#define DMA_STATE_BIT_AC_DONE 1
|
||||
#define DMA_STATE_BIT_AC_ERR 2
|
||||
#define DMA_STATE_BIT_AC_CMB 8
|
||||
#define DMA_STATE_BIT_I2S_OUT_DONE 1
|
||||
#define DMA_STATE_BIT_I2S_OUT_ERR 2
|
||||
#define DMA_STATE_BIT_I2S_IN_DONE 4
|
||||
#define DMA_STATE_BIT_I2S_IN_ERR 8
|
||||
#define DMA_STATE_BIT_I2S_CMB 32
|
||||
|
||||
#define DMA_MSTATE_START 1
|
||||
#define DMA_MSTART_READY 0
|
||||
|
||||
#define DMA_MSTATE_ERR_OK
|
||||
#define DMA_MSTATE_ERR_NO_ENABLE_CH 1
|
||||
#define DMA_MSTATE_ERR_CH1_4_INVALID 2
|
||||
#define DMA_MSTATE_ERR_CH5_8_INVALID 4
|
||||
|
||||
#define DMA_MSTATE_BUF_EMPTY 3
|
||||
|
||||
#define DMA_CMD_FIFO_NOT_FULL 1
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_bca_reg_clear_bck_err_int(void);
|
||||
void cxd56_audio_bca_reg_set_smaster(void);
|
||||
void cxd56_audio_bca_reg_set_datarate(uint8_t clk_mode);
|
||||
|
||||
void cxd56_audio_bca_reg_en_fmt24(cxd56_audio_dma_t handle, uint8_t ch_num);
|
||||
void cxd56_audio_bca_reg_en_fmt16(cxd56_audio_dma_t handle, uint8_t ch_num);
|
||||
|
||||
void cxd56_audio_bca_reg_en_bus_err_int(void);
|
||||
void cxd56_audio_bca_reg_dis_bus_err_int(void);
|
||||
|
||||
void cxd56_audio_bca_reg_get_dma_mstate(cxd56_audio_dma_t handle,
|
||||
FAR cxd56_audio_dma_mstate_t *state);
|
||||
|
||||
uint32_t cxd56_audio_bca_reg_get_dma_done_state_mic(void);
|
||||
uint32_t cxd56_audio_bca_reg_get_dma_done_state_i2s1(void);
|
||||
uint32_t cxd56_audio_bca_reg_get_dma_done_state_i2s2(void);
|
||||
|
||||
void cxd56_audio_bca_reg_mask_done_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_unmask_done_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_clear_done_int(cxd56_audio_dma_t handle);
|
||||
|
||||
void cxd56_audio_bca_reg_clear_dma_done_state_mic(uint32_t value);
|
||||
void cxd56_audio_bca_reg_clear_dma_done_state_i2s1(uint32_t value);
|
||||
void cxd56_audio_bca_reg_clear_dma_done_state_i2s2(uint32_t value);
|
||||
|
||||
bool cxd56_audio_bca_reg_is_dma_fifo_empty(cxd56_audio_dma_t handle);
|
||||
|
||||
void cxd56_audio_bca_reg_mask_err_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_unmask_err_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_clear_err_int(cxd56_audio_dma_t handle);
|
||||
|
||||
void cxd56_audio_bca_reg_mask_cmb_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_unmask_cmb_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_clear_cmb_int(cxd56_audio_dma_t handle);
|
||||
|
||||
uint32_t cxd56_audio_bca_reg_get_int_status(void);
|
||||
void cxd56_audio_bca_reg_clear_int_status(uint32_t int_au);
|
||||
|
||||
void cxd56_audio_bca_reg_mask_bus_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_unmask_bus_int(cxd56_audio_dma_t handle);
|
||||
|
||||
void cxd56_audio_bca_reg_set_start_addr(cxd56_audio_dma_t handle,
|
||||
uint32_t addr);
|
||||
void cxd56_audio_bca_reg_set_sample_no(cxd56_audio_dma_t handle,
|
||||
uint32_t sample);
|
||||
void cxd56_audio_bca_reg_start_dma(cxd56_audio_dma_t handle,
|
||||
bool nointr);
|
||||
void cxd56_audio_bca_reg_stop_dma(cxd56_audio_dma_t handle);
|
||||
|
||||
bool cxd56_audio_bca_reg_is_done_int(cxd56_audio_dma_t handle);
|
||||
bool cxd56_audio_bca_reg_is_err_int(cxd56_audio_dma_t handle);
|
||||
|
||||
bool cxd56_audio_bca_reg_is_smp_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_mask_smp_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_unmask_smp_int(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_clear_smp_int(cxd56_audio_dma_t handle);
|
||||
|
||||
uint32_t cxd56_audio_bca_reg_get_mon_state_err(cxd56_audio_dma_t handle);
|
||||
uint32_t cxd56_audio_bca_reg_get_mon_state_start(cxd56_audio_dma_t handle);
|
||||
uint32_t cxd56_audio_bca_reg_get_mon_state_buf(cxd56_audio_dma_t handle);
|
||||
uint32_t cxd56_audio_bca_reg_get_dma_state(cxd56_audio_dma_t handle);
|
||||
void cxd56_audio_bca_reg_reset_chsel(cxd56_audio_dma_t handle);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_BCA_REG_H */
|
209
boards/arm/cxd56xx/drivers/audio/cxd56_audio_beep.c
Normal file
209
boards/arm/cxd56xx/drivers/audio/cxd56_audio_beep.c
Normal file
@ -0,0 +1,209 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_beep.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_ac_reg.h"
|
||||
#include "cxd56_audio_beep.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Maximum frequency. */
|
||||
|
||||
#define FREQ_MAX 4085
|
||||
|
||||
/* Minimum frequency. */
|
||||
|
||||
#define FREQ_MIN 94
|
||||
|
||||
/* Maximum volume. */
|
||||
|
||||
#define VOL_MAX 0
|
||||
|
||||
/* Minimum volume. */
|
||||
|
||||
#define VOL_MIN -90
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static bool g_beep = false;
|
||||
|
||||
static const uint16_t g_beepfreqtable[] =
|
||||
{
|
||||
120, 127, 134, 142, 151, 160, 169, 180, 190, 201, 214, 226,
|
||||
240, 254, 269, 285, 302, 320, 339, 360, 381, 403, 428, 453,
|
||||
480, 509, 539, 571, 606, 642, 681, 719, 762, 810, 857, 910,
|
||||
965, 1021, 1079, 1143, 1215, 1289, 1362, 1444, 1536, 1627, 1714, 1829,
|
||||
1939, 2043, 2182, 2313, 2400, 2560, 2704, 2866, 3048, 3200, 3429, 3623,
|
||||
3840, 4085, 94
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t convert_freq(uint32_t freq)
|
||||
{
|
||||
uint32_t prev;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < sizeof(g_beepfreqtable) / sizeof(uint16_t); i++)
|
||||
{
|
||||
prev = (i + 62) % 63;
|
||||
if (freq < g_beepfreqtable[i])
|
||||
{
|
||||
if (prev == 62)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(g_beepfreqtable[prev] <= freq)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_beep_set_freq(uint16_t freq)
|
||||
{
|
||||
uint32_t conv_freq = 0;
|
||||
|
||||
if (freq > FREQ_MAX)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_BEP_FREQ_MAX;
|
||||
}
|
||||
|
||||
if (freq < FREQ_MIN)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_BEP_FREQ_MIN;
|
||||
}
|
||||
|
||||
/* Mute beep. */
|
||||
|
||||
cxd56_audio_ac_reg_disable_beep();
|
||||
|
||||
/* Convert Frequency. */
|
||||
|
||||
conv_freq = convert_freq(freq);
|
||||
|
||||
/* Set beep parameter. */
|
||||
|
||||
cxd56_audio_ac_reg_set_beep_freq(conv_freq);
|
||||
|
||||
if (g_beep)
|
||||
{
|
||||
cxd56_audio_ac_reg_enable_beep();
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_beep_set_vol(int16_t vol)
|
||||
{
|
||||
uint32_t conv_vol = 0;
|
||||
|
||||
if (vol > VOL_MAX)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_BEP_VOL_MAX;
|
||||
}
|
||||
|
||||
if (vol < VOL_MIN)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_BEP_VOL_MIN;
|
||||
}
|
||||
|
||||
/* Mute off. */
|
||||
|
||||
cxd56_audio_ac_reg_disable_beep();
|
||||
|
||||
/* Convert Volume. */
|
||||
|
||||
if (vol != 0)
|
||||
{
|
||||
conv_vol = -vol / 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
conv_vol = 0;
|
||||
}
|
||||
|
||||
/* Set beep parameter. */
|
||||
|
||||
cxd56_audio_ac_reg_set_beep_vol(conv_vol);
|
||||
|
||||
if (g_beep)
|
||||
{
|
||||
cxd56_audio_ac_reg_enable_beep();
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
void cxd56_audio_beep_play(void)
|
||||
{
|
||||
g_beep = true;
|
||||
|
||||
cxd56_audio_ac_reg_enable_beep();
|
||||
}
|
||||
|
||||
void cxd56_audio_beep_stop(void)
|
||||
{
|
||||
g_beep = false;
|
||||
|
||||
cxd56_audio_ac_reg_disable_beep();
|
||||
}
|
70
boards/arm/cxd56xx/drivers/audio/cxd56_audio_beep.h
Normal file
70
boards/arm/cxd56xx/drivers/audio/cxd56_audio_beep.h
Normal file
@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_beep.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_BEEP_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_BEEP_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_beep_set_freq(uint16_t freq);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_beep_set_vol(int16_t vol);
|
||||
void cxd56_audio_beep_play(void);
|
||||
void cxd56_audio_beep_stop(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_BEEP_H */
|
197
boards/arm/cxd56xx/drivers/audio/cxd56_audio_config.c
Normal file
197
boards/arm/cxd56xx/drivers/audio/cxd56_audio_config.c
Normal file
@ -0,0 +1,197 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_config.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include "cxd56_audio_config.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define MIC_CH_BITNUM 4
|
||||
#define MIC_CH_BITMAP 0xf
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
struct cxd56_audio_cfg_s
|
||||
{
|
||||
uint8_t mic_num;
|
||||
uint8_t mic_dev;
|
||||
uint8_t mic_mode;
|
||||
uint32_t mic_map;
|
||||
cxd56_audio_clkmode_t clk_mode;
|
||||
cxd56_audio_sp_drv_t sp_driver;
|
||||
};
|
||||
static struct cxd56_audio_cfg_s g_audio_cfg =
|
||||
{
|
||||
1,
|
||||
CXD56_AUDIO_CFG_MIC_DEV_ANADIG,
|
||||
CXD56_AUDIO_CFG_MIC_MODE_64FS,
|
||||
CXD56_AUDIO_CFG_MIC,
|
||||
CXD56_AUDIO_CLKMODE_NORMAL,
|
||||
CXD56_AUDIO_CFG_SP_DRIVER
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static void set_miccfg(void)
|
||||
{
|
||||
bool is_amic = false;
|
||||
bool is_dmic = false;
|
||||
uint8_t mic_num = 0;
|
||||
uint8_t mic_sel = 0;
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < CXD56_AUDIO_MIC_CH_MAX; i++)
|
||||
{
|
||||
mic_sel = (g_audio_cfg.mic_map >> (i * MIC_CH_BITNUM)) &
|
||||
MIC_CH_BITMAP;
|
||||
if ((mic_sel >= 1) && (mic_sel <= 4))
|
||||
{
|
||||
is_amic = true;
|
||||
mic_num++;
|
||||
}
|
||||
else if ((mic_sel >= 5) && (mic_sel <= 12))
|
||||
{
|
||||
is_dmic = true;
|
||||
mic_num++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set mic number. */
|
||||
|
||||
g_audio_cfg.mic_num = mic_num;
|
||||
|
||||
/* Set mic device type and mode. */
|
||||
|
||||
if (is_amic)
|
||||
{
|
||||
if(is_dmic)
|
||||
{
|
||||
g_audio_cfg.mic_dev = CXD56_AUDIO_CFG_MIC_DEV_ANADIG;
|
||||
g_audio_cfg.mic_mode = CXD56_AUDIO_CFG_MIC_MODE_64FS;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_audio_cfg.mic_dev = CXD56_AUDIO_CFG_MIC_DEV_ANALOG;
|
||||
g_audio_cfg.mic_mode = CXD56_AUDIO_CFG_MIC_MODE_128FS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_dmic)
|
||||
{
|
||||
g_audio_cfg.mic_dev = CXD56_AUDIO_CFG_MIC_DEV_DIGITAL;
|
||||
g_audio_cfg.mic_mode = CXD56_AUDIO_CFG_MIC_MODE_64FS;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_audio_cfg.mic_dev = CXD56_AUDIO_CFG_MIC_DEV_NONE;
|
||||
g_audio_cfg.mic_mode = CXD56_AUDIO_CFG_MIC_MODE_64FS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_config_init(void)
|
||||
{
|
||||
/* Set mic config */
|
||||
|
||||
set_miccfg();
|
||||
}
|
||||
|
||||
uint8_t cxd56_audio_config_get_micmode(void)
|
||||
{
|
||||
return g_audio_cfg.mic_mode;
|
||||
}
|
||||
|
||||
uint8_t cxd56_audio_config_get_micdev(void)
|
||||
{
|
||||
return g_audio_cfg.mic_dev;
|
||||
}
|
||||
|
||||
uint8_t cxd56_audio_config_get_micnum(void)
|
||||
{
|
||||
return g_audio_cfg.mic_num;
|
||||
}
|
||||
|
||||
void cxd56_audio_config_set_spdriver(cxd56_audio_sp_drv_t sp_driver)
|
||||
{
|
||||
g_audio_cfg.sp_driver = sp_driver;
|
||||
}
|
||||
|
||||
cxd56_audio_sp_drv_t cxd56_audio_config_get_spdriver(void)
|
||||
{
|
||||
return g_audio_cfg.sp_driver;
|
||||
}
|
||||
|
||||
void cxd56_audio_config_set_clkmode(cxd56_audio_clkmode_t mode)
|
||||
{
|
||||
g_audio_cfg.clk_mode = mode;
|
||||
}
|
||||
|
||||
cxd56_audio_clkmode_t cxd56_audio_config_get_clkmode(void)
|
||||
{
|
||||
return g_audio_cfg.clk_mode;
|
||||
}
|
||||
|
||||
void cxd56_audio_config_set_micmap(uint32_t map)
|
||||
{
|
||||
g_audio_cfg.mic_map = map;
|
||||
}
|
||||
|
||||
uint32_t cxd56_audio_config_get_micmap(void)
|
||||
{
|
||||
return g_audio_cfg.mic_map;
|
||||
}
|
383
boards/arm/cxd56xx/drivers/audio/cxd56_audio_config.h
Normal file
383
boards/arm/cxd56xx/drivers/audio/cxd56_audio_config.h
Normal file
@ -0,0 +1,383 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_config.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_CONFIG_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_CONFIG_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
enum cxd56_audio_cfg_mic_mode_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_MIC_MODE_64FS = 0,
|
||||
CXD56_AUDIO_CFG_MIC_MODE_128FS
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_mic_dev_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_MIC_DEV_NONE = 0,
|
||||
CXD56_AUDIO_CFG_MIC_DEV_ANALOG,
|
||||
CXD56_AUDIO_CFG_MIC_DEV_DIGITAL,
|
||||
CXD56_AUDIO_CFG_MIC_DEV_ANADIG
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_mic_bias_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_MIC_BIAS_20V = 0,
|
||||
CXD56_AUDIO_CFG_MIC_BIAS_28V
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_xtal_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_XTAL_24_576MHZ = 0,
|
||||
CXD56_AUDIO_CFG_XTAL_49_152MHZ
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_ds_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_DS_WEAKEST = 0,
|
||||
CXD56_AUDIO_CFG_DS_WEAKER,
|
||||
CXD56_AUDIO_CFG_DS_STRONGER,
|
||||
CXD56_AUDIO_CFG_DS_STRONGEST
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_i2s_mode_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_I2S_MODE_MASTER = 0,
|
||||
CXD56_AUDIO_CFG_I2S_MODE_SLAVE
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_i2s_format_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_I2S_FORMAT_NORMAL = 0,
|
||||
CXD56_AUDIO_CFG_I2S_FORMAT_LEFT
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_i2s_bypass_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_I2S_BYPASS_DISABLE = 0,
|
||||
CXD56_AUDIO_CFG_I2S_BYPASS_ENABLE
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_cic_in_sel_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_CIC_IN_SEL_NONE = 0,
|
||||
CXD56_AUDIO_CFG_CIC_IN_SEL_CXD,
|
||||
CXD56_AUDIO_CFG_CIC_IN_SEL_DMICIF
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_alc_spc_sel_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_ALCSPC_NONE = 0,
|
||||
CXD56_AUDIO_CFG_ALCSPC_ALC,
|
||||
CXD56_AUDIO_CFG_ALCSPC_SPC
|
||||
};
|
||||
|
||||
#define CXD56_AUDIO_CFG_SPC_LIMIT_DEFAULT 0
|
||||
#define CXD56_AUDIO_CFG_ALC_TARGET_DEFAULT 0
|
||||
#define CXD56_AUDIO_CFG_ALC_KNEE_DEFAULT 0
|
||||
|
||||
enum cxd56_audio_cfg_dma_formatl_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_DMA_FORMAT_LR = 0,
|
||||
CXD56_AUDIO_CFG_DMA_FORMAT_RL
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_hpadc_mic_bias_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_HPADC_MIC_BIAS_OFF = 0,
|
||||
CXD56_AUDIO_CFG_HPADC_MIC_BIAS_ON
|
||||
};
|
||||
|
||||
enum cxd56_audio_cfg_sp_spliton_e
|
||||
{
|
||||
CXD56_AUDIO_CFG_SP_SPLITON_LONGEST = 0,
|
||||
CXD56_AUDIO_CFG_SP_SPLITON_LONG,
|
||||
CXD56_AUDIO_CFG_SP_SPLITON_SHORT,
|
||||
CXD56_AUDIO_CFG_SP_SPLITON_SHORTEST
|
||||
};
|
||||
|
||||
/* Mic bias voltage select */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_MICBIAS_20V)
|
||||
# define CXD56_AUDIO_CFG_MIC_BIAS CXD56_AUDIO_CFG_MIC_BIAS_20V
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_MIC_BIAS CXD56_AUDIO_CFG_MIC_BIAS_28V
|
||||
#endif
|
||||
|
||||
/* Master clock select */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_XTAL_SEL_49_152MHZ)
|
||||
# define CXD56_AUDIO_CFG_MCLK CXD56_AUDIO_CFG_XTAL_49_152MHZ
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_MCLK CXD56_AUDIO_CFG_XTAL_24_576MHZ
|
||||
#endif
|
||||
|
||||
/* Mic select */
|
||||
|
||||
#define CXD56_AUDIO_CFG_MIC CONFIG_CXD56_AUDIO_MIC_CHANNEL_SEL
|
||||
|
||||
/* Drive strength of global pin output-A */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_GPO_A_WEAKEST)
|
||||
# define CXD56_AUDIO_CFG_GPO_A_DS CXD56_AUDIO_CFG_DS_WEAKEST
|
||||
#elif defined(CONFIG_CXD56_AUDIO_GPO_A_WEAKER)
|
||||
# define CXD56_AUDIO_CFG_GPO_A_DS CXD56_AUDIO_CFG_DS_WEAKER
|
||||
#elif defined(CONFIG_CXD56_AUDIO_GPO_A_STRONGER)
|
||||
# define CXD56_AUDIO_CFG_GPO_A_DS CXD56_AUDIO_CFG_DS_STRONGER
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_GPO_A_DS CXD56_AUDIO_CFG_DS_STRONGEST
|
||||
#endif
|
||||
|
||||
/* Drive strength of D/A converted data */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_DA_DATA_WEAKEST)
|
||||
# define CXD56_AUDIO_CFG_DA_DS CXD56_AUDIO_CFG_DS_WEAKEST
|
||||
#elif defined(CONFIG_CXD56_AUDIO_DA_DATA_WEAKER)
|
||||
# define CXD56_AUDIO_CFG_DS_DS CXD56_AUDIO_CFG_DS_WEAKER
|
||||
#elif defined(CONFIG_CXD56_AUDIO_DA_DATA_STRONGER)
|
||||
# define CXD56_AUDIO_CFG_DA_DS CXD56_AUDIO_CFG_DS_STRONGER
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_DA_DS CXD56_AUDIO_CFG_DS_STRONGEST
|
||||
#endif
|
||||
|
||||
/* Drive strength of digital mic clock */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_CLKOUT_DMIC_WEAKEST)
|
||||
# define CXD56_AUDIO_CFG_DMIC_CLK_DS CXD56_AUDIO_CFG_DS_WEAKEST
|
||||
#elif defined(CONFIG_CXD56_AUDIO_CLKOUT_DMIC_WEAKER)
|
||||
# define CXD56_AUDIO_CFG_DMIC_CLK_DS CXD56_AUDIO_CFG_DS_WEAKER
|
||||
#elif defined(CONFIG_CXD56_AUDIO_CLKOUT_DMIC_STRONGER)
|
||||
# define CXD56_AUDIO_CFG_DMIC_CLK_DS CXD56_AUDIO_CFG_DS_STRONGER
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_DMIC_CLK_DS CXD56_AUDIO_CFG_DS_STRONGEST
|
||||
#endif
|
||||
|
||||
/* Drive strength of master clock */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_MCLKOUT_WEAKEST)
|
||||
# define CXD56_AUDIO_CFG_MCLKOUT_DS CXD56_AUDIO_CFG_DS_WEAKEST
|
||||
#elif defined(CONFIG_CXD56_AUDIO_MCLKOUT_WEAKER)
|
||||
# define CXD56_AUDIO_CFG_MCLKOUT_DS CXD56_AUDIO_CFG_DS_WEAKER
|
||||
#elif defined(CONFIG_CXD56_AUDIO_MCLKOUT_STRONGER)
|
||||
# define CXD56_AUDIO_CFG_MCLKOUT_DS CXD56_AUDIO_CFG_DS_STRONGER
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_MCLKOUT_DS CXD56_AUDIO_CFG_DS_STRONGEST
|
||||
#endif
|
||||
|
||||
/* I2S mode of I2S1 */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_I2S_DEVICE_1_MASTER)
|
||||
# define CXD56_AUDIO_CFG_I2S1_MODE CXD56_AUDIO_CFG_I2S_MODE_MASTER
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_I2S1_MODE CXD56_AUDIO_CFG_I2S_MODE_SLAVE
|
||||
#endif
|
||||
|
||||
/* I2S format of I2S1 */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_I2S_FORMAT_1_LEFT)
|
||||
# define CXD56_AUDIO_CFG_I2S1_FORMAT CXD56_AUDIO_CFG_I2S_FORMAT_LEFT
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_I2S1_FORMAT CXD56_AUDIO_CFG_I2S_FORMAT_NORMAL
|
||||
#endif
|
||||
|
||||
/* I2S bypass mode of I2S1 */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_I2S_BYPASS_MODE_1_ENABLE)
|
||||
# define CXD56_AUDIO_CFG_I2S1_BYPASS CXD56_AUDIO_CFG_I2S_BYPASS_ENABLE
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_I2S1_BYPASS CXD56_AUDIO_CFG_I2S_BYPASS_DISABLE
|
||||
#endif
|
||||
|
||||
/* I2S data rate of I2S1 */
|
||||
|
||||
#if defined(CONFIG_CXD56_I2S0)
|
||||
# define CXD56_AUDIO_CFG_I2S1_DATA_RATE CONFIG_CXD56_AUDIO_I2S_RATE_1
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_I2S1_DATA_RATE 0
|
||||
#endif
|
||||
|
||||
/* I2S mode of I2S2 */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_I2S_DEVICE_2_MASTER)
|
||||
# define CXD56_AUDIO_CFG_I2S2_MODE CXD56_AUDIO_CFG_I2S_MODE_MASTER
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_I2S2_MODE CXD56_AUDIO_CFG_I2S_MODE_SLAVE
|
||||
#endif
|
||||
|
||||
/* I2S format of I2S2 */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_I2S_FORMAT_2_LEFT)
|
||||
# define CXD56_AUDIO_CFG_I2S2_FORMAT CXD56_AUDIO_CFG_I2S_FORMAT_LEFT
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_I2S2_FORMAT CXD56_AUDIO_CFG_I2S_FORMAT_NORMAL
|
||||
#endif
|
||||
|
||||
/* I2S bypass mode of I2S2 */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_I2S_BYPASS_MODE_2_ENABLE)
|
||||
# define CXD56_AUDIO_CFG_I2S2_BYPASS CXD56_AUDIO_CFG_I2S_BYPASS_ENABLE
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_I2S2_BYPASS CXD56_AUDIO_CFG_I2S_BYPASS_DISABLE
|
||||
#endif
|
||||
|
||||
/* I2S data rate of I2S2 */
|
||||
|
||||
#if defined(CONFIG_CXD56_I2S1)
|
||||
# define CXD56_AUDIO_CFG_I2S2_DATA_RATE CONFIG_CXD56_AUDIO_I2S_RATE_2
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_I2S2_DATA_RATE 0
|
||||
#endif
|
||||
|
||||
/* CIC filter input path */
|
||||
|
||||
#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
|
||||
|
||||
/* Wait time of mic boot */
|
||||
|
||||
#define CXD56_AUDIO_MIC_BOOT_WAIT CONFIG_CXD56_AUDIO_MIC_BOOT_WAIT
|
||||
|
||||
/* ALC and SPC filter select */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_ALC_SPC_SEL_OFF)
|
||||
# define CXD56_AUDIO_CFG_ALCSPC CXD56_AUDIO_CFG_ALCSPC_NONE
|
||||
#elif defined (CONFIG_CXD56_AUDIO_ALC_SPC_SEL_ALC)
|
||||
# define CXD56_AUDIO_CFG_ALCSPC CXD56_AUDIO_CFG_ALCSPC_ALC
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_ALCSPC CXD56_AUDIO_CFG_ALCSPC_SPC
|
||||
#endif
|
||||
|
||||
/* SPC limit level */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_ALC_SPC_SEL_SPC)
|
||||
# define CXD56_AUDIO_CFG_SPC_LIMIT CONFIG_CXD56_AUDIO_SPC_LIMIT
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_SPC_LIMIT CXD56_AUDIO_CFG_SPC_LIMIT_DEFAULT
|
||||
#endif
|
||||
|
||||
/* ALC target level */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_ALC_SPC_SEL_ALC)
|
||||
# define CXD56_AUDIO_CFG_ALC_TARGET CONFIG_CXD56_AUDIO_ALC_TARGET
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_ALC_TARGET CXD56_AUDIO_CFG_ALC_TARGET_DEFAULT
|
||||
#endif
|
||||
|
||||
/* ALC knee point */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_ALC_SPC_SEL_ALC)
|
||||
# define CXD56_AUDIO_CFG_ALC_KNEE CONFIG_CXD56_AUDIO_ALC_KNEE
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_ALC_KNEE CXD56_AUDIO_CFG_ALC_KNEE_DEFAULT
|
||||
#endif
|
||||
|
||||
/* DMA format */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_DMA_DATA_FORMAT_LR)
|
||||
# define CXD56_AUDIO_CFG_DMA_FORMAT CXD56_AUDIO_CFG_DMA_FORMAT_LR
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_DMA_FORMAT CXD56_AUDIO_CFG_DMA_FORMAT_RL
|
||||
#endif
|
||||
|
||||
/* Mic bias for HPADC */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_HPADC_MIC_BIAS_ON)
|
||||
# define CXD56_AUDIO_CFG_HPADC_MIC_BIAS CXD56_AUDIO_CFG_HPADC_MIC_BIAS_ON
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_HPADC_MIC_BIAS CXD56_AUDIO_CFG_HPADC_MIC_BIAS_OFF
|
||||
#endif
|
||||
|
||||
/* Speaker time split on drive */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_SP_SPLIT_LONGEST)
|
||||
# define CXD56_AUDIO_CFG_SP_SPLIT_ON CXD56_AUDIO_CFG_SP_SPLITON_LONGEST
|
||||
#elif defined(CONFIG_CXD56_AUDIO_SP_SPLIT_LONG)
|
||||
# define CXD56_AUDIO_CFG_SP_SPLIT_ON CXD56_AUDIO_CFG_SP_SPLITON_LONG
|
||||
#elif defined(CONFIG_CXD56_AUDIO_SP_SPLIT_SHORT)
|
||||
# define CXD56_AUDIO_CFG_SP_SPLIT_ON CXD56_AUDIO_CFG_SP_SPLITON_SHORT
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_SP_SPLIT_ON CXD56_AUDIO_CFG_SP_SPLITON_SHORTEST
|
||||
#endif
|
||||
|
||||
/* Speaker drive mode */
|
||||
|
||||
#if defined(CONFIG_CXD56_AUDIO_SP_DRV_LINEOUT)
|
||||
# define CXD56_AUDIO_CFG_SP_DRIVER CXD56_AUDIO_SP_DRV_LINEOUT
|
||||
#elif defined(CONFIG_CXD56_AUDIO_SP_DRV_1DRIVERT)
|
||||
# define CXD56_AUDIO_CFG_SP_DRIVER CXD56_AUDIO_SP_DRV_1DRIVER
|
||||
#elif defined(CONFIG_CXD56_AUDIO_SP_DRV_2DRIVERT)
|
||||
# define CXD56_AUDIO_CFG_SP_DRIVER CXD56_AUDIO_SP_DRV_2DRIVER
|
||||
#else
|
||||
# define CXD56_AUDIO_CFG_SP_DRIVER CXD56_AUDIO_SP_DRV_4DRIVER
|
||||
#endif
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_config_init(void);
|
||||
uint8_t cxd56_audio_config_get_micmode(void);
|
||||
uint8_t cxd56_audio_config_get_micdev(void);
|
||||
uint8_t cxd56_audio_config_get_micnum(void);
|
||||
void cxd56_audio_config_set_spdriver(cxd56_audio_sp_drv_t sp_driver);
|
||||
cxd56_audio_sp_drv_t cxd56_audio_config_get_spdriver(void);
|
||||
void cxd56_audio_config_set_clkmode(cxd56_audio_clkmode_t mode);
|
||||
cxd56_audio_clkmode_t cxd56_audio_config_get_clkmode(void);
|
||||
void cxd56_audio_config_set_micmap(uint32_t map);
|
||||
uint32_t cxd56_audio_config_get_micmap(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_CONFIG_H */
|
115
boards/arm/cxd56xx/drivers/audio/cxd56_audio_digital.c
Normal file
115
boards/arm/cxd56xx/drivers/audio/cxd56_audio_digital.c
Normal file
@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_digital.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_ac_reg.h"
|
||||
#include "cxd56_audio_bca_reg.h"
|
||||
#include "cxd56_audio_digital.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_digital_poweron(void)
|
||||
{
|
||||
#if defined(CONFIG_CXD56_I2S0) || defined(CONFIG_CXD56_I2S1)
|
||||
cxd56_audio_clkmode_t clk_mode = cxd56_audio_config_get_clkmode();
|
||||
|
||||
/* Clear interrupt status of bck_err. */
|
||||
|
||||
cxd56_audio_bca_reg_clear_bck_err_int();
|
||||
|
||||
/* PowerON i2s. */
|
||||
|
||||
cxd56_audio_ac_reg_poweron_i2s(clk_mode);
|
||||
#endif /* defined(CONFIG_CXD56_I2S0) || defined(CONFIG_CXD56_I2S1) */
|
||||
}
|
||||
|
||||
void cxd56_audio_digital_enable(void)
|
||||
{
|
||||
#if defined(CONFIG_CXD56_I2S0) || defined(CONFIG_CXD56_I2S1)
|
||||
|
||||
#ifdef CONFIG_CXD56_I2S0
|
||||
/* Enable I2S data input and output of SRC1 */
|
||||
|
||||
cxd56_audio_ac_reg_enable_i2s_src1();
|
||||
#endif /* CONFIG_CXD56_I2S0 */
|
||||
|
||||
#ifdef CONFIG_CXD56_I2S1
|
||||
/* Enable I2S data input and output of SRC2 */
|
||||
|
||||
cxd56_audio_ac_reg_enable_i2s_src2();
|
||||
#endif /* CONFIG_CXD56_I2S1 */
|
||||
|
||||
if ((CXD56_AUDIO_CFG_I2S1_MODE == CXD56_AUDIO_CFG_I2S_MODE_MASTER) ||
|
||||
(CXD56_AUDIO_CFG_I2S2_MODE == CXD56_AUDIO_CFG_I2S_MODE_MASTER))
|
||||
{
|
||||
/* Enable BCK, LRCK output. */
|
||||
|
||||
cxd56_audio_ac_reg_enable_i2s_bcklrckout();
|
||||
}
|
||||
else
|
||||
{
|
||||
cxd56_audio_ac_reg_disable_i2s_bcklrckout();
|
||||
}
|
||||
#endif /* defined(CONFIG_CXD56_I2S0) || defined(CONFIG_CXD56_I2S1) */
|
||||
}
|
68
boards/arm/cxd56xx/drivers/audio/cxd56_audio_digital.h
Normal file
68
boards/arm/cxd56xx/drivers/audio/cxd56_audio_digital.h
Normal file
@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_digital.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_DIGITAL_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_DIGITAL_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_digital_poweron(void);
|
||||
void cxd56_audio_digital_enable(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_DIGITAL_H */
|
707
boards/arm/cxd56xx/drivers/audio/cxd56_audio_dma.c
Normal file
707
boards/arm/cxd56xx/drivers/audio/cxd56_audio_dma.c
Normal file
@ -0,0 +1,707 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_dma.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_dma.h"
|
||||
#include "cxd56_audio_mic.h"
|
||||
#include "cxd56_audio_ac_reg.h"
|
||||
#include "cxd56_audio_bca_reg.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Register type. */
|
||||
|
||||
enum audio_irq_reg_type_e
|
||||
{
|
||||
INT_EN1_REG = 0,
|
||||
INT_POL_REG,
|
||||
INT_IRQ1_REG
|
||||
};
|
||||
|
||||
/* INT_EN1 */
|
||||
#define CXD56_INTC_BASE 0xe0045000
|
||||
#define INT_EN1_REG_ADDR (CXD56_INTC_BASE + 0x10 + 3 * 4)
|
||||
#define INT_EN1_BIT_AU0 6
|
||||
#define INT_EN1_BIT_AU1 7
|
||||
#define INT_EN1_BIT_AU2 8
|
||||
#define INT_EN1_BIT_AU3 9
|
||||
|
||||
/* INT_POL */
|
||||
|
||||
#define INT_POL_REG (CXD56_INTC_BASE + 0x20 + 3 * 4)
|
||||
#define INT_POL_BIT_AU0 6
|
||||
#define INT_POL_BIT_AU1 7
|
||||
#define INT_POL_BIT_AU2 8
|
||||
#define INT_POL_BIT_AU3 9
|
||||
|
||||
/* INT_IRQ1 */
|
||||
|
||||
#define INT_IRQ1_REG_ADDR (CXD56_INTC_BASE + 0x30 + 3 * 4)
|
||||
#define INT_IRQ1_BIT_AU0 6
|
||||
#define INT_IRQ1_BIT_AU1 7
|
||||
#define INT_IRQ1_BIT_AU2 8
|
||||
#define INT_IRQ1_BIT_AU3 9
|
||||
|
||||
#define DMA_HANDLE_MAX_NUM (CXD56_AUDIO_DMAC_I2S1_DOWN + 1)
|
||||
|
||||
#define DMA_TIMEOUT_CNT 10000
|
||||
#define DMA_START_RETRY_CNT 10
|
||||
#define DMA_SMP_WAIT_HIRES 10 /* usec per sample. */
|
||||
#define DMA_SMP_WAIT_NORMALT 40 /* usec per sample. */
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t g_dma_act_status = 0;
|
||||
static cxd56_audio_dma_cb_t g_dma_cb[DMA_HANDLE_MAX_NUM];
|
||||
|
||||
static bool s_work_arroud_dmac[DMA_HANDLE_MAX_NUM] =
|
||||
{
|
||||
true,
|
||||
true,
|
||||
true
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
* Private Macro
|
||||
****************************************************************************/
|
||||
|
||||
#define SET_DMA_ACT(_path_) g_dma_act_status |= (1 << _path_)
|
||||
#define CLR_DMA_ACT(_path_) g_dma_act_status &= ~(1 << _path_)
|
||||
#define IS_DMA_ACT(_path_) ((g_dma_act_status & (1 << _path_)) != 0)
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t read_int_reg(uint32_t reg)
|
||||
{
|
||||
volatile uint32_t *addr;
|
||||
uint32_t data = 0;
|
||||
|
||||
if (reg == INT_EN1_REG)
|
||||
{
|
||||
addr = (volatile uint32_t *)INT_EN1_REG_ADDR;
|
||||
}
|
||||
else if (reg == INT_IRQ1_REG)
|
||||
{
|
||||
addr = (volatile uint32_t *)INT_IRQ1_REG_ADDR;
|
||||
}
|
||||
else
|
||||
{
|
||||
addr = (volatile uint32_t *)INT_POL_REG;
|
||||
}
|
||||
|
||||
data = *addr;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static uint32_t write_int_reg(uint32_t reg, uint32_t data)
|
||||
{
|
||||
volatile uint32_t *addr;
|
||||
|
||||
if (reg == INT_EN1_REG)
|
||||
{
|
||||
addr = (volatile uint32_t *)INT_EN1_REG_ADDR;
|
||||
*addr = data;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static CXD56_AUDIO_ECODE get_dma_handle(cxd56_audio_dma_path_t path,
|
||||
FAR cxd56_audio_dma_t *handle)
|
||||
{
|
||||
switch (path)
|
||||
{
|
||||
case CXD56_AUDIO_DMA_PATH_MIC_TO_MEM:
|
||||
*handle = CXD56_AUDIO_DMAC_MIC;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_DMA_PATH_MEM_TO_BUSIF1:
|
||||
*handle = CXD56_AUDIO_DMAC_I2S0_DOWN;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_DMA_PATH_MEM_TO_BUSIF2:
|
||||
*handle = CXD56_AUDIO_DMAC_I2S1_DOWN;
|
||||
break;
|
||||
|
||||
default:
|
||||
return CXD56_AUDIO_ECODE_DMA_PATH_INV;
|
||||
}
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
static CXD56_AUDIO_ECODE get_dma_path(cxd56_audio_dma_t handle,
|
||||
FAR cxd56_audio_dma_path_t *path)
|
||||
{
|
||||
switch (handle)
|
||||
{
|
||||
case CXD56_AUDIO_DMAC_MIC:
|
||||
*path = CXD56_AUDIO_DMA_PATH_MIC_TO_MEM;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_DMAC_I2S0_DOWN:
|
||||
*path = CXD56_AUDIO_DMA_PATH_MEM_TO_BUSIF1;
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_DMAC_I2S1_DOWN:
|
||||
*path = CXD56_AUDIO_DMA_PATH_MEM_TO_BUSIF2;
|
||||
break;
|
||||
|
||||
default:
|
||||
return CXD56_AUDIO_ECODE_DMA_HANDLE_INV;
|
||||
}
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
static CXD56_AUDIO_ECODE start_dma(cxd56_audio_dma_t handle)
|
||||
{
|
||||
cxd56_audio_bca_reg_start_dma(handle, false);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
static CXD56_AUDIO_ECODE exec_dma_ch_sync_workaround(
|
||||
cxd56_audio_dma_t handle)
|
||||
{
|
||||
int timeout_cnt = 0;
|
||||
int retry_cnt;
|
||||
|
||||
cxd56_audio_clkmode_t clk_mode = cxd56_audio_config_get_clkmode();
|
||||
|
||||
/* Execute out-of-sync workaround.
|
||||
* 1. Clear smp interrupt status
|
||||
* 2. Read until smp interrupt state is true
|
||||
* 3. Reset channel select setting
|
||||
* 4. Start dma transfer
|
||||
* It needs to be less than 9 us by the processing so far.
|
||||
* If it does not fit below 9 us, err_int is generated, so retry.
|
||||
*/
|
||||
|
||||
/* Mask dma done interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_mask_done_int(handle);
|
||||
|
||||
for (retry_cnt = 0; retry_cnt < DMA_START_RETRY_CNT; retry_cnt++)
|
||||
{
|
||||
/* Clear interrupt status */
|
||||
|
||||
cxd56_audio_bca_reg_clear_err_int(handle);
|
||||
cxd56_audio_bca_reg_clear_smp_int(handle);
|
||||
|
||||
/* Lock interrupt */
|
||||
|
||||
up_irq_disable();
|
||||
sched_lock();
|
||||
|
||||
/* Wait smp interrupt. */
|
||||
|
||||
for (timeout_cnt = 0; timeout_cnt < DMA_TIMEOUT_CNT; timeout_cnt++)
|
||||
{
|
||||
if (cxd56_audio_bca_reg_is_smp_int(handle))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (timeout_cnt == DMA_TIMEOUT_CNT)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_DMA_SMP_TIMEOUT;
|
||||
}
|
||||
|
||||
/* Reset Channel select. */
|
||||
|
||||
cxd56_audio_bca_reg_reset_chsel(handle);
|
||||
|
||||
/* Start dma. */
|
||||
|
||||
cxd56_audio_bca_reg_start_dma(handle, false);
|
||||
|
||||
/* Unlock interrupt */
|
||||
|
||||
sched_unlock();
|
||||
up_irq_enable();
|
||||
|
||||
/* Wait for 1sample tramsfer. */
|
||||
|
||||
if (clk_mode == CXD56_AUDIO_CLKMODE_HIRES)
|
||||
{
|
||||
up_udelay(DMA_SMP_WAIT_HIRES);
|
||||
}
|
||||
else
|
||||
{
|
||||
up_udelay(DMA_SMP_WAIT_NORMALT);
|
||||
}
|
||||
|
||||
/* Check whether an error interrupt has occurred. */
|
||||
|
||||
if (cxd56_audio_bca_reg_is_err_int(handle))
|
||||
{
|
||||
cxd56_audio_bca_reg_stop_dma(handle);
|
||||
cxd56_audio_bca_reg_clear_err_int(handle);
|
||||
|
||||
for (timeout_cnt = 0; timeout_cnt < DMA_TIMEOUT_CNT; timeout_cnt++)
|
||||
{
|
||||
if (DMA_MSTATE_BUF_EMPTY ==
|
||||
cxd56_audio_bca_reg_get_mon_state_buf(handle))
|
||||
{
|
||||
if (cxd56_audio_bca_reg_is_done_int(handle))
|
||||
{
|
||||
cxd56_audio_bca_reg_clear_done_int(handle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Unmask dma done interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_unmask_done_int(handle);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
static CXD56_AUDIO_ECODE start_dma_workaround(cxd56_audio_dma_t handle)
|
||||
{
|
||||
/* There are two workarounds.
|
||||
* One is a workaround in which the error interrupt of
|
||||
* dma is incorrectly generated.
|
||||
* The other is a workaround for the problem that the channel
|
||||
* is out of sync.
|
||||
* Because both require processing at the beginning of dma,
|
||||
* call out workaround with out-of-sync from the workaround
|
||||
* for interrupt error.
|
||||
*/
|
||||
|
||||
/* Execute error interrupt workaround.
|
||||
* 1. Mask dma error interrupt
|
||||
* 2. Wait 77 cycle after dma transfer starts
|
||||
* 3. Clear interrupt status
|
||||
* 4. Unmask dma error interrupt
|
||||
*/
|
||||
|
||||
cxd56_audio_bca_reg_mask_err_int(handle);
|
||||
|
||||
/* Transfer start and wait processing of dma is done
|
||||
* in out-of-sync workaround.
|
||||
*/
|
||||
|
||||
CXD56_AUDIO_ECODE ret = exec_dma_ch_sync_workaround(handle);
|
||||
|
||||
cxd56_audio_bca_reg_clear_err_int(handle);
|
||||
cxd56_audio_bca_reg_unmask_err_int(handle);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_get_handle(cxd56_audio_dma_path_t path,
|
||||
FAR cxd56_audio_dma_t *handle)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
/* Check error of argument */
|
||||
|
||||
if (handle == NULL)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_DMA_HANDLE_NULL;
|
||||
}
|
||||
|
||||
/* Check duplicate order */
|
||||
|
||||
if (IS_DMA_ACT(path))
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_DMA_PATH_DUP;
|
||||
}
|
||||
|
||||
ret = get_dma_handle(path, handle);
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
SET_DMA_ACT(path);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_free_handle(FAR cxd56_audio_dma_t handle)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
cxd56_audio_dma_path_t path;
|
||||
|
||||
ret = get_dma_path(handle, &path);
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
CLR_DMA_ACT(path);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_init(cxd56_audio_dma_t handle,
|
||||
cxd56_audio_samp_fmt_t fmt,
|
||||
FAR uint8_t *ch_num)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
uint32_t ch_setting;
|
||||
|
||||
cxd56_audio_ac_reg_enable_dma();
|
||||
|
||||
if (handle == CXD56_AUDIO_DMAC_MIC)
|
||||
{
|
||||
ret = cxd56_audio_mic_set_seloutch(*ch_num, fmt);
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set Stereo channel number. */
|
||||
|
||||
*ch_num = 2;
|
||||
}
|
||||
|
||||
if (fmt == CXD56_AUDIO_SAMP_FMT_24)
|
||||
{
|
||||
cxd56_audio_bca_reg_en_fmt24(handle, *ch_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxd56_audio_bca_reg_en_fmt16(handle, *ch_num);
|
||||
}
|
||||
|
||||
/* Clear interrupt state. */
|
||||
|
||||
cxd56_audio_bca_reg_clear_done_int(handle);
|
||||
cxd56_audio_bca_reg_clear_err_int(handle);
|
||||
cxd56_audio_bca_reg_clear_cmb_int(handle);
|
||||
|
||||
/* Enable interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_unmask_done_int(handle);
|
||||
|
||||
/* cxd56_audio_bca_reg_mask_done_int(handle); TODO: polling */
|
||||
|
||||
/* Enable interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_unmask_err_int(handle);
|
||||
cxd56_audio_bca_reg_unmask_cmb_int(handle);
|
||||
cxd56_audio_bca_reg_unmask_bus_int(handle);
|
||||
|
||||
/* Check channel setting. */
|
||||
|
||||
ch_setting = cxd56_audio_bca_reg_get_mon_state_err(handle);
|
||||
switch (ch_setting)
|
||||
{
|
||||
case DMA_MSTATE_ERR_NO_ENABLE_CH:
|
||||
return CXD56_AUDIO_ECODE_DMA_CH_NO_ENABLE;
|
||||
|
||||
case DMA_MSTATE_ERR_CH1_4_INVALID:
|
||||
return CXD56_AUDIO_ECODE_DMA_CH1_4_INV;
|
||||
|
||||
case DMA_MSTATE_ERR_CH5_8_INVALID:
|
||||
return CXD56_AUDIO_ECODE_DMA_CH5_8_INV;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_set_cb(cxd56_audio_dma_t handle,
|
||||
FAR cxd56_audio_dma_cb_t cb)
|
||||
{
|
||||
g_dma_cb[handle] = cb;
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_get_mstate(cxd56_audio_dma_t handle,
|
||||
FAR cxd56_audio_dma_mstate_t *state)
|
||||
{
|
||||
cxd56_audio_bca_reg_get_dma_mstate(handle, state);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_en_dmaint(void)
|
||||
{
|
||||
volatile uint32_t int_en;
|
||||
|
||||
int_en = read_int_reg(INT_EN1_REG);
|
||||
|
||||
int_en |= (1 << INT_EN1_BIT_AU0);
|
||||
int_en |= (1 << INT_EN1_BIT_AU1);
|
||||
int_en |= (1 << INT_EN1_BIT_AU2);
|
||||
int_en |= (1 << INT_EN1_BIT_AU3);
|
||||
|
||||
write_int_reg(INT_EN1_REG, int_en);
|
||||
|
||||
/* Enalbe bus error interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_en_bus_err_int();
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_dis_dmaint(void)
|
||||
{
|
||||
volatile uint32_t int_en;
|
||||
|
||||
int_en = read_int_reg(INT_EN1_REG);
|
||||
|
||||
int_en &= ~(1 << INT_EN1_BIT_AU0);
|
||||
int_en &= ~(1 << INT_EN1_BIT_AU1);
|
||||
int_en &= ~(1 << INT_EN1_BIT_AU2);
|
||||
int_en &= ~(1 << INT_EN1_BIT_AU3);
|
||||
|
||||
write_int_reg(INT_EN1_REG, int_en);
|
||||
|
||||
/* Disalbe bus error interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_dis_bus_err_int();
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_start(cxd56_audio_dma_t handle,
|
||||
uint32_t addr,
|
||||
uint32_t sample)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
if (DMA_CMD_FIFO_NOT_FULL != cxd56_audio_bca_reg_get_dma_state(handle))
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_DMA_BUSY;
|
||||
}
|
||||
|
||||
cxd56_audio_bca_reg_set_start_addr(handle, addr);
|
||||
cxd56_audio_bca_reg_set_sample_no(handle, sample);
|
||||
|
||||
if (s_work_arroud_dmac[handle])
|
||||
{
|
||||
s_work_arroud_dmac[handle] = false;
|
||||
ret = start_dma_workaround(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = start_dma(handle);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_stop(cxd56_audio_dma_t handle)
|
||||
{
|
||||
cxd56_audio_bca_reg_stop_dma(handle);
|
||||
s_work_arroud_dmac[handle] = true;
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
void CXD56_audio_dma_int_handler(void)
|
||||
{
|
||||
uint32_t int_irq = read_int_reg(INT_IRQ1_REG);
|
||||
uint32_t int_ac = cxd56_audio_bca_reg_get_dma_done_state_mic();
|
||||
uint32_t int_i2s = cxd56_audio_bca_reg_get_dma_done_state_i2s1();
|
||||
uint32_t int_i2s2 = cxd56_audio_bca_reg_get_dma_done_state_i2s2();
|
||||
|
||||
/* AUDIO_INT_AC : check interruption from mic */
|
||||
|
||||
if ((int_irq & (1 << INT_IRQ1_BIT_AU0)) && (int_ac != 0))
|
||||
{
|
||||
/* Clear interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_clear_dma_done_state_mic(int_ac);
|
||||
|
||||
/* Check done complete state. */
|
||||
|
||||
if (int_ac & DMA_STATE_BIT_AC_DONE)
|
||||
{
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_MIC])(CXD56_AUDIO_DMAC_MIC,
|
||||
CXD56_AUDIO_ECODE_DMA_CMPLT);
|
||||
}
|
||||
|
||||
/* Check transfer err state. */
|
||||
|
||||
if (int_ac & DMA_STATE_BIT_AC_ERR)
|
||||
{
|
||||
cxd56_audio_bca_reg_mask_err_int(CXD56_AUDIO_DMAC_MIC);
|
||||
|
||||
cxd56_audio_bca_reg_clear_err_int(CXD56_AUDIO_DMAC_MIC);
|
||||
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_MIC])(CXD56_AUDIO_DMAC_MIC,
|
||||
CXD56_AUDIO_ECODE_DMA_TRANS);
|
||||
}
|
||||
|
||||
/* Check bus err state. */
|
||||
|
||||
if (int_ac & DMA_STATE_BIT_AC_CMB)
|
||||
{
|
||||
cxd56_audio_bca_reg_mask_cmb_int(CXD56_AUDIO_DMAC_MIC);
|
||||
|
||||
cxd56_audio_bca_reg_clear_cmb_int(CXD56_AUDIO_DMAC_MIC);
|
||||
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_MIC])(CXD56_AUDIO_DMAC_MIC,
|
||||
CXD56_AUDIO_ECODE_DMA_CMB);
|
||||
}
|
||||
}
|
||||
|
||||
/* AUDIO_INT_I2S1 : check interruption from I2S-1 */
|
||||
|
||||
if ((int_irq & (1 << INT_IRQ1_BIT_AU1)) && (int_i2s != 0))
|
||||
{
|
||||
/* Clear interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_clear_dma_done_state_i2s1(int_i2s);
|
||||
|
||||
/* Check done complete state. */
|
||||
|
||||
if (int_i2s & DMA_STATE_BIT_I2S_OUT_DONE)
|
||||
{
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_I2S0_DOWN])(CXD56_AUDIO_DMAC_I2S0_DOWN,
|
||||
CXD56_AUDIO_ECODE_DMA_CMPLT);
|
||||
}
|
||||
|
||||
/* Check transfer err state. */
|
||||
|
||||
if (int_i2s & DMA_STATE_BIT_I2S_OUT_ERR)
|
||||
{
|
||||
cxd56_audio_bca_reg_mask_err_int(CXD56_AUDIO_DMAC_I2S0_DOWN);
|
||||
|
||||
cxd56_audio_bca_reg_clear_err_int(CXD56_AUDIO_DMAC_I2S0_DOWN);
|
||||
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_I2S0_DOWN])(CXD56_AUDIO_DMAC_I2S0_DOWN,
|
||||
CXD56_AUDIO_ECODE_DMA_TRANS);
|
||||
}
|
||||
|
||||
/* Check bus err state. */
|
||||
|
||||
if (int_i2s & DMA_STATE_BIT_I2S_CMB)
|
||||
{
|
||||
cxd56_audio_bca_reg_mask_cmb_int(CXD56_AUDIO_DMAC_I2S0_DOWN);
|
||||
|
||||
cxd56_audio_bca_reg_clear_cmb_int(CXD56_AUDIO_DMAC_I2S0_DOWN);
|
||||
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_I2S0_DOWN])(CXD56_AUDIO_DMAC_I2S0_DOWN,
|
||||
CXD56_AUDIO_ECODE_DMA_CMB);
|
||||
}
|
||||
}
|
||||
|
||||
/* AUDIO_INT_I2S2 : check interruption from I2S-2 */
|
||||
|
||||
if ((int_irq & (1 << INT_IRQ1_BIT_AU2)) && (int_i2s2 != 0))
|
||||
{
|
||||
/* Clear interrupt. */
|
||||
|
||||
cxd56_audio_bca_reg_clear_dma_done_state_i2s2(int_i2s2);
|
||||
|
||||
/* Check done complete state. */
|
||||
|
||||
if (int_i2s2 & DMA_STATE_BIT_I2S_OUT_DONE)
|
||||
{
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_I2S1_DOWN])(CXD56_AUDIO_DMAC_I2S1_DOWN,
|
||||
CXD56_AUDIO_ECODE_DMA_CMPLT);
|
||||
}
|
||||
|
||||
/* Check transfer err state. */
|
||||
|
||||
if (int_i2s2 & DMA_STATE_BIT_I2S_OUT_ERR)
|
||||
{
|
||||
cxd56_audio_bca_reg_mask_err_int(CXD56_AUDIO_DMAC_I2S1_DOWN);
|
||||
|
||||
cxd56_audio_bca_reg_clear_err_int(CXD56_AUDIO_DMAC_I2S1_DOWN);
|
||||
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_I2S1_DOWN])(CXD56_AUDIO_DMAC_I2S1_DOWN,
|
||||
CXD56_AUDIO_ECODE_DMA_TRANS);
|
||||
}
|
||||
|
||||
/* Check bus err state. */
|
||||
|
||||
if (int_i2s2 & DMA_STATE_BIT_I2S_CMB)
|
||||
{
|
||||
cxd56_audio_bca_reg_mask_cmb_int(CXD56_AUDIO_DMAC_I2S1_DOWN);
|
||||
|
||||
cxd56_audio_bca_reg_clear_cmb_int(CXD56_AUDIO_DMAC_I2S1_DOWN);
|
||||
|
||||
(*g_dma_cb[CXD56_AUDIO_DMAC_I2S1_DOWN])(CXD56_AUDIO_DMAC_I2S1_DOWN,
|
||||
CXD56_AUDIO_ECODE_DMA_CMB);
|
||||
}
|
||||
}
|
||||
|
||||
if (int_irq & (1 << INT_IRQ1_BIT_AU3))
|
||||
{
|
||||
uint32_t int_au = cxd56_audio_bca_reg_get_int_status();
|
||||
|
||||
if (int_au != 0)
|
||||
{
|
||||
cxd56_audio_bca_reg_clear_int_status(int_au);
|
||||
}
|
||||
}
|
||||
}
|
81
boards/arm/cxd56xx/drivers/audio/cxd56_audio_dma.h
Normal file
81
boards/arm/cxd56xx/drivers/audio/cxd56_audio_dma.h
Normal file
@ -0,0 +1,81 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_dma.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_DMA_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_DMA_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_get_handle(cxd56_audio_dma_path_t path,
|
||||
FAR cxd56_audio_dma_t *handle);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_free_handle(cxd56_audio_dma_t handle);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_init(cxd56_audio_dma_t handle,
|
||||
cxd56_audio_samp_fmt_t fmt,
|
||||
FAR uint8_t *ch_num);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_set_cb(cxd56_audio_dma_t handle,
|
||||
FAR cxd56_audio_dma_cb_t cb);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_get_mstate(cxd56_audio_dma_t handle,
|
||||
FAR cxd56_audio_dma_mstate_t *state);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_en_dmaint(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_dis_dmaint(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_start(cxd56_audio_dma_t handle,
|
||||
uint32_t addr,
|
||||
uint32_t sample);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_dma_stop(cxd56_audio_dma_t handle);
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_DMA_H */
|
140
boards/arm/cxd56xx/drivers/audio/cxd56_audio_filter.c
Normal file
140
boards/arm/cxd56xx/drivers/audio/cxd56_audio_filter.c
Normal file
@ -0,0 +1,140 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_filter.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_filter.h"
|
||||
#include "cxd56_audio_ac_reg.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_filter_set_cstereo(bool en,
|
||||
bool sign_inv,
|
||||
int16_t vol)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
if (en)
|
||||
{
|
||||
ret = cxd56_audio_ac_reg_enable_cstereo(sign_inv, vol);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxd56_audio_ac_reg_disable_cstereo();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void cxd56_audio_filter_poweron_dnc(void)
|
||||
{
|
||||
cxd56_audio_ac_reg_poweron_dnc();
|
||||
}
|
||||
|
||||
void cxd56_audio_filter_poweroff_dnc(void)
|
||||
{
|
||||
cxd56_audio_ac_reg_poweroff_dnc();
|
||||
}
|
||||
|
||||
void cxd56_audio_filter_set_dnc(cxd56_audio_dnc_id_t id,
|
||||
bool en,
|
||||
FAR cxd56_audio_dnc_bin_t *bin)
|
||||
{
|
||||
/* Desable DNC. */
|
||||
|
||||
cxd56_audio_ac_reg_disable_dnc(id);
|
||||
|
||||
/* Set binary data to SRAM. */
|
||||
|
||||
if (bin != NULL)
|
||||
{
|
||||
cxd56_audio_ac_reg_set_dncram(id, bin);
|
||||
}
|
||||
|
||||
/* Enable DNC. */
|
||||
|
||||
if (en)
|
||||
{
|
||||
cxd56_audio_ac_reg_enable_dnc(id);
|
||||
}
|
||||
}
|
||||
|
||||
void cxd56_audio_filter_set_deq(bool en,
|
||||
FAR cxd56_audio_deq_coef_t *deq)
|
||||
{
|
||||
/* Disable DEQ. */
|
||||
|
||||
cxd56_audio_ac_reg_disable_deq();
|
||||
|
||||
/* Set DEQ coef data to register. */
|
||||
|
||||
if (deq != NULL)
|
||||
{
|
||||
cxd56_audio_ac_reg_set_deq_param(deq);
|
||||
}
|
||||
|
||||
/* Enable DEQ. */
|
||||
|
||||
if (en)
|
||||
{
|
||||
cxd56_audio_ac_reg_enable_deq();
|
||||
}
|
||||
}
|
76
boards/arm/cxd56xx/drivers/audio/cxd56_audio_filter.h
Normal file
76
boards/arm/cxd56xx/drivers/audio/cxd56_audio_filter.h
Normal file
@ -0,0 +1,76 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_filter.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_FILTER_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_FILTER_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_filter_set_cstereo(bool en,
|
||||
bool sign_inv,
|
||||
int16_t vol);
|
||||
void cxd56_audio_filter_poweron_dnc(void);
|
||||
void cxd56_audio_filter_poweroff_dnc(void);
|
||||
void cxd56_audio_filter_set_dnc(cxd56_audio_dnc_id_t id,
|
||||
bool en,
|
||||
FAR cxd56_audio_dnc_bin_t *bin);
|
||||
void cxd56_audio_filter_set_deq(bool en,
|
||||
FAR cxd56_audio_deq_coef_t *deq);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_FILTER_H */
|
100
boards/arm/cxd56xx/drivers/audio/cxd56_audio_irq.c
Normal file
100
boards/arm/cxd56xx/drivers/audio/cxd56_audio_irq.c
Normal file
@ -0,0 +1,100 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_irq.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
|
||||
#include "cxd56_audio_irq.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
extern void CXD56_audio_dma_int_handler(void);
|
||||
|
||||
/***************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_irq_attach(void)
|
||||
{
|
||||
irq_attach(CXD56_IRQ_AUDIO_0, (xcpt_t)CXD56_audio_dma_int_handler, NULL);
|
||||
irq_attach(CXD56_IRQ_AUDIO_1, (xcpt_t)CXD56_audio_dma_int_handler, NULL);
|
||||
irq_attach(CXD56_IRQ_AUDIO_2, (xcpt_t)CXD56_audio_dma_int_handler, NULL);
|
||||
irq_attach(CXD56_IRQ_AUDIO_3, (xcpt_t)CXD56_audio_dma_int_handler, NULL);
|
||||
}
|
||||
|
||||
void cxd56_audio_irq_detach(void)
|
||||
{
|
||||
irq_detach(CXD56_IRQ_AUDIO_0);
|
||||
irq_detach(CXD56_IRQ_AUDIO_1);
|
||||
irq_detach(CXD56_IRQ_AUDIO_2);
|
||||
irq_detach(CXD56_IRQ_AUDIO_3);
|
||||
}
|
||||
|
||||
void cxd56_audio_irq_enable(void)
|
||||
{
|
||||
up_enable_irq(CXD56_IRQ_AUDIO_0);
|
||||
up_enable_irq(CXD56_IRQ_AUDIO_1);
|
||||
up_enable_irq(CXD56_IRQ_AUDIO_2);
|
||||
}
|
||||
|
||||
void cxd56_audio_irq_disable(void)
|
||||
{
|
||||
up_disable_irq(CXD56_IRQ_AUDIO_0);
|
||||
up_disable_irq(CXD56_IRQ_AUDIO_1);
|
||||
up_disable_irq(CXD56_IRQ_AUDIO_2);
|
||||
}
|
70
boards/arm/cxd56xx/drivers/audio/cxd56_audio_irq.h
Normal file
70
boards/arm/cxd56xx/drivers/audio/cxd56_audio_irq.h
Normal file
@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_irq.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_IRQ_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_IRQ_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_irq_attach(void);
|
||||
void cxd56_audio_irq_detach(void);
|
||||
void cxd56_audio_irq_enable(void);
|
||||
void cxd56_audio_irq_disable(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_IRQ_H */
|
229
boards/arm/cxd56xx/drivers/audio/cxd56_audio_mic.c
Normal file
229
boards/arm/cxd56xx/drivers/audio/cxd56_audio_mic.c
Normal file
@ -0,0 +1,229 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_mic.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_mic.h"
|
||||
#include "cxd56_audio_ac_reg.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CIC_NUM 4
|
||||
#define CIC_MIC_CH_NUM 2
|
||||
|
||||
#define MIC_CH_BITNUM 4
|
||||
#define MIC_CH_BITMAP 0xf
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mic_enable(FAR cxd56_audio_mic_gain_t *gain)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
uint8_t mic_num;
|
||||
uint8_t cic_num;
|
||||
uint8_t mic_sel;
|
||||
uint8_t mic_mode;
|
||||
uint32_t mic_map;
|
||||
cxd56_audio_mic_gain_t cic_gain;
|
||||
cxd56_audio_clkmode_t clk_mode;
|
||||
uint8_t i;
|
||||
|
||||
/* Get mic number. */
|
||||
|
||||
mic_num = cxd56_audio_config_get_micnum();
|
||||
|
||||
/* Get CIC filter number. */
|
||||
|
||||
cic_num = (mic_num + 1) / CIC_MIC_CH_NUM;
|
||||
|
||||
/* Get mic mode. */
|
||||
|
||||
mic_mode = cxd56_audio_config_get_micmode();
|
||||
|
||||
/* Set cic gain. */
|
||||
|
||||
mic_map = cxd56_audio_config_get_micmap();
|
||||
|
||||
for (i = 0; i < CXD56_AUDIO_MIC_CH_MAX; i++)
|
||||
{
|
||||
mic_sel = (mic_map >> (i * MIC_CH_BITNUM)) &
|
||||
MIC_CH_BITMAP;
|
||||
if ((mic_sel >= 1) && (mic_sel <= 4))
|
||||
{
|
||||
cic_gain.gain[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cic_gain.gain[i] = gain->gain[i];
|
||||
}
|
||||
}
|
||||
|
||||
ret = cxd56_audio_ac_reg_poweron_cic(CXD56_AUDIO_CFG_CIC_IN,
|
||||
mic_mode,
|
||||
cic_num,
|
||||
&cic_gain);
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
clk_mode = cxd56_audio_config_get_clkmode();
|
||||
ret = cxd56_audio_ac_reg_poweron_decim(mic_mode, clk_mode);
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mic_disable(void)
|
||||
{
|
||||
/* Disable DECIM. */
|
||||
|
||||
cxd56_audio_ac_reg_poweroff_decim();
|
||||
|
||||
/* Power off CIC. */
|
||||
|
||||
cxd56_audio_ac_reg_poweroff_cic();
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mic_set_gain(FAR cxd56_audio_mic_gain_t *gain)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
uint8_t mic_num;
|
||||
uint8_t cic_num;
|
||||
uint8_t mic_sel;
|
||||
uint32_t mic_map;
|
||||
cxd56_audio_mic_gain_t cic_gain;
|
||||
uint8_t i;
|
||||
|
||||
/* Get mic number. */
|
||||
|
||||
mic_num = cxd56_audio_config_get_micnum();
|
||||
|
||||
/* Get CIC filter number. */
|
||||
|
||||
cic_num = (mic_num + 1) / CIC_MIC_CH_NUM;
|
||||
|
||||
/* Set cic gain. */
|
||||
|
||||
mic_map = cxd56_audio_config_get_micmap();
|
||||
|
||||
for (i = 0; i < CXD56_AUDIO_MIC_CH_MAX; i++)
|
||||
{
|
||||
mic_sel = (mic_map >> (i * MIC_CH_BITNUM)) &
|
||||
MIC_CH_BITMAP;
|
||||
if ((mic_sel >= 1) && (mic_sel <= 4))
|
||||
{
|
||||
cic_gain.gain[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cic_gain.gain[i] = gain->gain[i];
|
||||
}
|
||||
}
|
||||
|
||||
cxd56_audio_ac_reg_set_cicgain(cic_num, &cic_gain);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mic_set_seloutch(uint8_t dma_mic_num,
|
||||
cxd56_audio_samp_fmt_t format)
|
||||
{
|
||||
uint8_t i;
|
||||
cxd56_audio_ac_reg_seloutch_t seloutch;
|
||||
|
||||
if ((format == CXD56_AUDIO_SAMP_FMT_16) &&
|
||||
(CXD56_AUDIO_CFG_DMA_FORMAT == CXD56_AUDIO_CFG_DMA_FORMAT_RL))
|
||||
{
|
||||
for (i = 0; i < CXD56_AUDIO_MIC_CH_MAX; i++)
|
||||
{
|
||||
seloutch.ch[i] = (i & 1) ? i - 1 : i + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < CXD56_AUDIO_MIC_CH_MAX; i++)
|
||||
{
|
||||
seloutch.ch[i] = i;
|
||||
}
|
||||
}
|
||||
|
||||
if ((format == CXD56_AUDIO_SAMP_FMT_16) && ((dma_mic_num & 1) == 1))
|
||||
{
|
||||
if (CXD56_AUDIO_CFG_DMA_FORMAT == CXD56_AUDIO_CFG_DMA_FORMAT_LR)
|
||||
{
|
||||
seloutch.ch[dma_mic_num] = seloutch.ch[dma_mic_num - 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
seloutch.ch[dma_mic_num - 1] = seloutch.ch[dma_mic_num];
|
||||
}
|
||||
}
|
||||
|
||||
cxd56_audio_ac_reg_set_seloutch(&seloutch);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
71
boards/arm/cxd56xx/drivers/audio/cxd56_audio_mic.h
Normal file
71
boards/arm/cxd56xx/drivers/audio/cxd56_audio_mic.h
Normal file
@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_mic.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_MIC_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_MIC_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mic_enable(FAR cxd56_audio_mic_gain_t *gain);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mic_disable(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mic_set_gain(FAR cxd56_audio_mic_gain_t *gain);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_mic_set_seloutch(uint8_t mic_num,
|
||||
cxd56_audio_samp_fmt_t format);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_MIC_H */
|
60
boards/arm/cxd56xx/drivers/audio/cxd56_audio_pin.c
Normal file
60
boards/arm/cxd56xx/drivers/audio/cxd56_audio_pin.c
Normal file
@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_pin.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "cxd56_audio_pin.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_pin_i2s_set(void)
|
||||
{
|
||||
/* Enable I2S. */
|
||||
|
||||
board_audio_i2s_enable();
|
||||
}
|
||||
|
||||
void cxd56_audio_pin_i2s_unset(void)
|
||||
{
|
||||
/* Disable I2S. */
|
||||
|
||||
board_audio_i2s_disable();
|
||||
}
|
68
boards/arm/cxd56xx/drivers/audio/cxd56_audio_pin.h
Normal file
68
boards/arm/cxd56xx/drivers/audio/cxd56_audio_pin.h
Normal file
@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_pin.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_PIN_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_PIN_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
void cxd56_audio_pin_i2s_set(void);
|
||||
void cxd56_audio_pin_i2s_unset(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_PIN_H */
|
138
boards/arm/cxd56xx/drivers/audio/cxd56_audio_power.c
Normal file
138
boards/arm/cxd56xx/drivers/audio/cxd56_audio_power.c
Normal file
@ -0,0 +1,138 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_power.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_power.h"
|
||||
#include "cxd56_audio_digital.h"
|
||||
#include "cxd56_audio_ac_reg.h"
|
||||
#include "cxd56_audio_bca_reg.h"
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static CXD56_AUDIO_ECODE power_on_codec(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
cxd56_audio_clkmode_t clk_mode = cxd56_audio_config_get_clkmode();
|
||||
|
||||
ret = cxd56_audio_ac_reg_checkid();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
cxd56_audio_ac_reg_initdsp();
|
||||
cxd56_audio_ac_reg_poweron_sdes();
|
||||
|
||||
uint8_t mic_mode = cxd56_audio_config_get_micmode();
|
||||
ret = cxd56_audio_ac_reg_set_micmode(mic_mode);
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
cxd56_audio_ac_reg_poweron_codec();
|
||||
cxd56_audio_digital_poweron();
|
||||
cxd56_audio_ac_reg_resetdsp();
|
||||
cxd56_audio_digital_enable();
|
||||
cxd56_audio_ac_reg_enable_serialif();
|
||||
cxd56_audio_ac_reg_init_selector();
|
||||
|
||||
ret = cxd56_audio_ac_reg_set_alcspc();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
cxd56_audio_bca_reg_set_datarate(clk_mode);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_power_on(void)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
|
||||
|
||||
/* Power on audio codec block. */
|
||||
|
||||
ret = power_on_codec();
|
||||
if (CXD56_AUDIO_ECODE_OK != ret)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_power_off(void)
|
||||
{
|
||||
/* Power off audio codec block. */
|
||||
|
||||
cxd56_audio_ac_reg_poweroff_codec();
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
68
boards/arm/cxd56xx/drivers/audio/cxd56_audio_power.h
Normal file
68
boards/arm/cxd56xx/drivers/audio/cxd56_audio_power.h
Normal file
@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_power.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_POWER_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_POWER_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_power_on(void);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_power_off(void);
|
||||
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_POWER_H */
|
288
boards/arm/cxd56xx/drivers/audio/cxd56_audio_volume.c
Normal file
288
boards/arm/cxd56xx/drivers/audio/cxd56_audio_volume.c
Normal file
@ -0,0 +1,288 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_volume.c
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "cxd56_audio_config.h"
|
||||
#include "cxd56_audio_ac_reg.h"
|
||||
#include "cxd56_audio_analog.h"
|
||||
#include "cxd56_audio_volume.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Number of volume device. */
|
||||
|
||||
#define VOLUME_NUM 3
|
||||
|
||||
/* Maximum value. */
|
||||
|
||||
#define VOLUME_MAX 120
|
||||
|
||||
/* Minimum value. */
|
||||
|
||||
#define VOLUME_MIN -1020
|
||||
|
||||
/* Mute volume. */
|
||||
|
||||
#define VOLUME_MUTE -1025
|
||||
|
||||
#define MUTE_BIT_API 0x01
|
||||
#define MUTE_BIT_FADE 0x02
|
||||
#define MUTE_VOL_REG 0x33
|
||||
#define VOL_WAIT_TIME 20
|
||||
#define VOL_TO_REG(vol) (((vol) / 5) & 0xff)
|
||||
#define VOL_MUTE_TIME(vol, n_cycle) \
|
||||
(((VOL_TO_REG(vol) - MUTE_VOL_REG) & 0xff) * (n_cycle + 1) * 4 / 48 * 1000)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type
|
||||
****************************************************************************/
|
||||
|
||||
struct set_vol_prm_s
|
||||
{
|
||||
int16_t hold_vol;
|
||||
uint8_t mute_bit;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct set_vol_prm_s g_volparam[VOLUME_NUM] =
|
||||
{
|
||||
{VOLUME_MUTE, MUTE_BIT_API},
|
||||
{VOLUME_MUTE, MUTE_BIT_API},
|
||||
{VOLUME_MUTE, MUTE_BIT_API}
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static CXD56_AUDIO_ECODE set_mute(cxd56_audio_volid_t id,
|
||||
bool wait,
|
||||
uint8_t type)
|
||||
{
|
||||
uint32_t waittime = 0;
|
||||
|
||||
waittime = VOL_MUTE_TIME(g_volparam[id].hold_vol, 1);
|
||||
|
||||
if (g_volparam[id].mute_bit == 0)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case CXD56_AUDIO_VOLID_MIXER_IN1:
|
||||
cxd56_audio_ac_reg_set_vol_sdin1(MUTE_VOL_REG);
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_VOLID_MIXER_IN2:
|
||||
cxd56_audio_ac_reg_set_vol_sdin2(MUTE_VOL_REG);
|
||||
break;
|
||||
|
||||
default:
|
||||
cxd56_audio_ac_reg_set_vol_dac(MUTE_VOL_REG);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (wait)
|
||||
{
|
||||
usleep(waittime);
|
||||
}
|
||||
|
||||
g_volparam[id].mute_bit |= type;
|
||||
|
||||
if (g_volparam[CXD56_AUDIO_VOLID_MIXER_OUT].mute_bit != 0)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = cxd56_audio_analog_disable_output();
|
||||
if (ret != CXD56_AUDIO_ECODE_OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
static CXD56_AUDIO_ECODE set_unmute(cxd56_audio_volid_t id,
|
||||
bool wait,
|
||||
uint8_t type)
|
||||
{
|
||||
uint32_t waittime = 0;
|
||||
|
||||
g_volparam[id].mute_bit &= ~type;
|
||||
|
||||
if (g_volparam[CXD56_AUDIO_VOLID_MIXER_OUT].mute_bit == 0)
|
||||
{
|
||||
CXD56_AUDIO_ECODE ret = cxd56_audio_analog_enable_output();
|
||||
if (ret != CXD56_AUDIO_ECODE_OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_volparam[id].mute_bit == 0)
|
||||
{
|
||||
if (type == MUTE_BIT_API)
|
||||
{
|
||||
waittime = VOL_WAIT_TIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* fade */
|
||||
|
||||
waittime = VOL_MUTE_TIME(g_volparam[id].hold_vol, 1);
|
||||
}
|
||||
|
||||
uint32_t vol = VOL_TO_REG(g_volparam[id].hold_vol);
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case CXD56_AUDIO_VOLID_MIXER_IN1:
|
||||
cxd56_audio_ac_reg_set_vol_sdin1(vol);
|
||||
break;
|
||||
|
||||
case CXD56_AUDIO_VOLID_MIXER_IN2:
|
||||
cxd56_audio_ac_reg_set_vol_sdin2(vol);
|
||||
break;
|
||||
|
||||
default:
|
||||
cxd56_audio_ac_reg_set_vol_dac(vol);
|
||||
break;
|
||||
}
|
||||
|
||||
if (wait)
|
||||
{
|
||||
usleep(waittime);
|
||||
}
|
||||
}
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_set(cxd56_audio_volid_t id,
|
||||
int16_t vol)
|
||||
{
|
||||
if (id >= VOLUME_NUM)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_VOL_ID;
|
||||
}
|
||||
|
||||
if (VOLUME_MIN > vol)
|
||||
{
|
||||
if (VOLUME_MUTE != vol)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_VOL_MIN;
|
||||
}
|
||||
}
|
||||
if (VOLUME_MAX < vol)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_VOL_MAX;
|
||||
}
|
||||
|
||||
g_volparam[id].hold_vol = vol;
|
||||
set_unmute(id, true, MUTE_BIT_API);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_mute(cxd56_audio_volid_t id)
|
||||
{
|
||||
if (id >= VOLUME_NUM)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_VOL_ID;
|
||||
}
|
||||
|
||||
set_mute(id, true, MUTE_BIT_API);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_unmute(cxd56_audio_volid_t id)
|
||||
{
|
||||
if (id >= VOLUME_NUM)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_VOL_ID;
|
||||
}
|
||||
|
||||
set_unmute(id, true, MUTE_BIT_API);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_mute_fade(cxd56_audio_volid_t id,
|
||||
bool wait)
|
||||
{
|
||||
if (id >= VOLUME_NUM)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_VOL_ID;
|
||||
}
|
||||
|
||||
set_mute(id, wait, MUTE_BIT_FADE);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_unmute_fade(cxd56_audio_volid_t id,
|
||||
bool wait)
|
||||
{
|
||||
if (id >= VOLUME_NUM)
|
||||
{
|
||||
return CXD56_AUDIO_ECODE_VOL_ID;
|
||||
}
|
||||
|
||||
set_unmute(id, wait, MUTE_BIT_FADE);
|
||||
|
||||
return CXD56_AUDIO_ECODE_OK;
|
||||
}
|
72
boards/arm/cxd56xx/drivers/audio/cxd56_audio_volume.h
Normal file
72
boards/arm/cxd56xx/drivers/audio/cxd56_audio_volume.h
Normal file
@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
* arch/arm/src/cxd56xx/cxd56_audio_volume.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_VOLUME_H
|
||||
#define __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_VOLUME_H
|
||||
|
||||
/***************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <arch/chip/audio.h>
|
||||
|
||||
/***************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_set(cxd56_audio_volid_t id, int16_t vol);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_mute(cxd56_audio_volid_t id);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_unmute(cxd56_audio_volid_t id);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_mute_fade(cxd56_audio_volid_t id,
|
||||
bool wait);
|
||||
CXD56_AUDIO_ECODE cxd56_audio_volume_unmute_fade(cxd56_audio_volid_t id,
|
||||
bool wait);
|
||||
#endif /* __ARCH_ARM_SRC_CXD56XX_CXD56_AUDIO_VOLUME_H */
|
@ -21,6 +21,7 @@ CONFIG_BOARD_LOOPSPERMSEC=5434
|
||||
CONFIG_BOOT_RUNFROMISRAM=y
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_CLOCK_MONOTONIC=y
|
||||
CONFIG_CXD56_AUDIO=y
|
||||
CONFIG_CXD56_BINARY=y
|
||||
CONFIG_CXD56_I2C0=y
|
||||
CONFIG_CXD56_I2C=y
|
||||
@ -28,7 +29,6 @@ CONFIG_CXD56_SDIO=y
|
||||
CONFIG_CXD56_SPI4=y
|
||||
CONFIG_CXD56_SPI5=y
|
||||
CONFIG_CXD56_SPI=y
|
||||
CONFIG_CXD56_AUDIO=y
|
||||
CONFIG_CXD56_USBDEV=y
|
||||
CONFIG_DEBUG_FULLOPT=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
@ -42,6 +42,7 @@ CONFIG_FS_SMARTFS=y
|
||||
CONFIG_HAVE_CXX=y
|
||||
CONFIG_HAVE_CXXINITIALIZE=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_LIBM=y
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MMCSD=y
|
||||
@ -70,6 +71,7 @@ CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_SMARTFS_ALIGNED_ACCESS=y
|
||||
CONFIG_SMARTFS_MAXNAMLEN=30
|
||||
CONFIG_SMARTFS_MULTI_ROOT_DIRS=y
|
||||
CONFIG_SPECIFIC_DRIVERS=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_START_DAY=6
|
||||
CONFIG_START_MONTH=12
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include "cxd56_wdt.h"
|
||||
#include "cxd56_gpioif.h"
|
||||
|
||||
#include "cxd56_audio.h"
|
||||
#include "cxd56_ak09912.h"
|
||||
#include "cxd56_apds9930.h"
|
||||
#include "cxd56_apds9960.h"
|
||||
@ -214,12 +215,13 @@ enum board_power_device
|
||||
|
||||
POWER_AUDIO_DVDD = PMIC_LSW(2),
|
||||
POWER_FLASH = PMIC_LSW(3),
|
||||
POWER_TCXO = PMIC_LSW(3),
|
||||
POWER_TCXO = PMIC_LSW(4),
|
||||
POWER_LNA = PMIC_LSW(4),
|
||||
|
||||
/* GPO */
|
||||
|
||||
POWER_AUDIO_AVDD = PMIC_GPO(0),
|
||||
POWER_AUDIO_AVDD = PMIC_GPO(1),
|
||||
POWER_AUDIO_MUTE = PMIC_GPO(6),
|
||||
POWER_SENSOR_18V = PMIC_GPO(1),
|
||||
POWER_SENSOR_33V = PMIC_GPO(2),
|
||||
POWER_BMI160 = POWER_SENSOR_18V,
|
||||
|
160
boards/arm/cxd56xx/spresense/include/cxd56_audio.h
Normal file
160
boards/arm/cxd56xx/spresense/include/cxd56_audio.h
Normal file
@ -0,0 +1,160 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/cxd56xx/spresense/include/cxd56_audio.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_AUDIO_H
|
||||
#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_AUDIO_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_aca_power_control
|
||||
*
|
||||
* Description:
|
||||
* Power on/off the Aca device on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_aca_power_control(int target, bool en);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_aca_power_monitor
|
||||
*
|
||||
* Description:
|
||||
* Get status of Power on/off the Aca device on the board.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool board_aca_power_monitor(int target);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_external_amp_mute_control
|
||||
*
|
||||
* Description:
|
||||
* External Amp. Mute on/off.
|
||||
* true: Mute on
|
||||
* false: Mute off
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_external_amp_mute_control(bool en);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_external_amp_mute_monitor
|
||||
*
|
||||
* Description:
|
||||
* Get External Amp. Mute status.
|
||||
* true: Mute on
|
||||
* false: Mute off
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool board_external_amp_mute_monitor(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_i2s_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable I2S on the board.
|
||||
* Used by the audio driver. Do not use by users.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_audio_i2s_enable(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_i2s_disable
|
||||
*
|
||||
* Description:
|
||||
* Disable I2S on the board.
|
||||
* Used by the audio driver. Do not use by users.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_audio_i2s_disable(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize audio I/O on the board.
|
||||
* Used by the audio driver. Do not use by users.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_audio_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_audio_finalize
|
||||
*
|
||||
* Description:
|
||||
* Finalize audio I/O on the board.
|
||||
* Used by the audio driver. Do not use by users.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void board_audio_finalize(void);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_AUDIO_H */
|
Loading…
Reference in New Issue
Block a user