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:
Alin Jerpelea
2019-10-09 23:55:20 +00:00
committed by Gregory Nutt
parent 3a28d2e6f7
commit 33d0de4d57
39 changed files with 11321 additions and 3 deletions
File diff suppressed because it is too large Load Diff
+4
View File
@@ -34,6 +34,10 @@
CSRCS += cxd56_boot.c CSRCS += cxd56_boot.c
ifeq ($(CONFIG_CXD56_AUDIO), y)
CSRCS += cxd56_audio.c
endif
ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y) ifeq ($(CONFIG_BOARDCTL_UNIQUEID),y)
CSRCS += cxd56_uid.c CSRCS += cxd56_uid.c
endif endif
+390
View 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();
}
+1
View File
@@ -3,4 +3,5 @@
# see the file kconfig-language.txt in the NuttX tools repository. # see the file kconfig-language.txt in the NuttX tools repository.
# #
source "drivers/platform/audio/Kconfig"
source "drivers/platform/sensors/Kconfig" source "drivers/platform/sensors/Kconfig"
+1
View File
@@ -33,4 +33,5 @@
# #
############################################################################ ############################################################################
include platform$(DELIM)audio$(DELIM)Make.defs
include platform$(DELIM)sensors$(DELIM)Make.defs include platform$(DELIM)sensors$(DELIM)Make.defs
+429
View 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
@@ -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)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -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 */
File diff suppressed because it is too large Load Diff
@@ -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 */
@@ -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;
}
@@ -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 */
File diff suppressed because it is too large Load Diff
@@ -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 */
@@ -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();
}
@@ -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 */
@@ -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;
}
@@ -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 */
@@ -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) */
}
@@ -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 */
File diff suppressed because it is too large Load Diff
@@ -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 */
@@ -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();
}
}
@@ -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 */
@@ -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);
}
@@ -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 */
@@ -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;
}
@@ -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 */
@@ -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();
}
@@ -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 */
@@ -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;
}
@@ -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 */
@@ -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;
}
@@ -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_BOOT_RUNFROMISRAM=y
CONFIG_BUILTIN=y CONFIG_BUILTIN=y
CONFIG_CLOCK_MONOTONIC=y CONFIG_CLOCK_MONOTONIC=y
CONFIG_CXD56_AUDIO=y
CONFIG_CXD56_BINARY=y CONFIG_CXD56_BINARY=y
CONFIG_CXD56_I2C0=y CONFIG_CXD56_I2C0=y
CONFIG_CXD56_I2C=y CONFIG_CXD56_I2C=y
@@ -28,7 +29,6 @@ CONFIG_CXD56_SDIO=y
CONFIG_CXD56_SPI4=y CONFIG_CXD56_SPI4=y
CONFIG_CXD56_SPI5=y CONFIG_CXD56_SPI5=y
CONFIG_CXD56_SPI=y CONFIG_CXD56_SPI=y
CONFIG_CXD56_AUDIO=y
CONFIG_CXD56_USBDEV=y CONFIG_CXD56_USBDEV=y
CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y CONFIG_DEBUG_SYMBOLS=y
@@ -42,6 +42,7 @@ CONFIG_FS_SMARTFS=y
CONFIG_HAVE_CXX=y CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_I2C=y CONFIG_I2C=y
CONFIG_LIBM=y
CONFIG_MAX_TASKS=16 CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2 CONFIG_MAX_WDOGPARMS=2
CONFIG_MMCSD=y CONFIG_MMCSD=y
@@ -70,6 +71,7 @@ CONFIG_SDCLONE_DISABLE=y
CONFIG_SMARTFS_ALIGNED_ACCESS=y CONFIG_SMARTFS_ALIGNED_ACCESS=y
CONFIG_SMARTFS_MAXNAMLEN=30 CONFIG_SMARTFS_MAXNAMLEN=30
CONFIG_SMARTFS_MULTI_ROOT_DIRS=y CONFIG_SMARTFS_MULTI_ROOT_DIRS=y
CONFIG_SPECIFIC_DRIVERS=y
CONFIG_SPI=y CONFIG_SPI=y
CONFIG_START_DAY=6 CONFIG_START_DAY=6
CONFIG_START_MONTH=12 CONFIG_START_MONTH=12
+4 -2
View File
@@ -56,6 +56,7 @@
#include "cxd56_wdt.h" #include "cxd56_wdt.h"
#include "cxd56_gpioif.h" #include "cxd56_gpioif.h"
#include "cxd56_audio.h"
#include "cxd56_ak09912.h" #include "cxd56_ak09912.h"
#include "cxd56_apds9930.h" #include "cxd56_apds9930.h"
#include "cxd56_apds9960.h" #include "cxd56_apds9960.h"
@@ -214,12 +215,13 @@ enum board_power_device
POWER_AUDIO_DVDD = PMIC_LSW(2), POWER_AUDIO_DVDD = PMIC_LSW(2),
POWER_FLASH = PMIC_LSW(3), POWER_FLASH = PMIC_LSW(3),
POWER_TCXO = PMIC_LSW(3), POWER_TCXO = PMIC_LSW(4),
POWER_LNA = PMIC_LSW(4), POWER_LNA = PMIC_LSW(4),
/* GPO */ /* 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_18V = PMIC_GPO(1),
POWER_SENSOR_33V = PMIC_GPO(2), POWER_SENSOR_33V = PMIC_GPO(2),
POWER_BMI160 = POWER_SENSOR_18V, POWER_BMI160 = POWER_SENSOR_18V,
@@ -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 */