Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/arch/arm/src/amebasmart: Add macro for I2S DMA size and page number #6621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/configs/rtl8730e/audio/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ CONFIG_AMEBASMART_I2S2=y
# CONFIG_AMEBASMART_I2S_RX is not set
CONFIG_AMEBASMART_I2S_TX=y
CONFIG_AMEBASMART_I2S_TXCL=16
CONFIG_AMEBASMART_I2S_TX_DMA_SIZE=4096
CONFIG_AMEBASMART_I2S_TX_DMA_PAGE=4

#
# Realtek RTL8730E WIFI Support
Expand Down
3 changes: 2 additions & 1 deletion build/configs/rtl8730e/flat_dev_ddr/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ CONFIG_AMEBASMART_I2S2=y
# CONFIG_AMEBASMART_I2S_RX is not set
CONFIG_AMEBASMART_I2S_TX=y
CONFIG_AMEBASMART_I2S_TXCL=32

CONFIG_AMEBASMART_I2S_TX_DMA_SIZE=4096
CONFIG_AMEBASMART_I2S_TX_DMA_PAGE=4
#
# Realtek RTL8730E WIFI Support
#
Expand Down
3 changes: 2 additions & 1 deletion build/configs/rtl8730e/flat_dev_psram/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ CONFIG_AMEBASMART_I2S2=y
# CONFIG_AMEBASMART_I2S_RX is not set
CONFIG_AMEBASMART_I2S_TX=y
CONFIG_AMEBASMART_I2S_TXCL=32

CONFIG_AMEBASMART_I2S_TX_DMA_SIZE=4096
CONFIG_AMEBASMART_I2S_TX_DMA_PAGE=4
#
# Realtek RTL8730E WIFI Support
#
Expand Down
3 changes: 2 additions & 1 deletion build/configs/rtl8730e/loadable_audio/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ CONFIG_AMEBASMART_I2S2=y
# CONFIG_AMEBASMART_I2S_RX is not set
CONFIG_AMEBASMART_I2S_TX=y
CONFIG_AMEBASMART_I2S_TXCL=16

CONFIG_AMEBASMART_I2S_TX_DMA_SIZE=4096
CONFIG_AMEBASMART_I2S_TX_DMA_PAGE=4
#
# Realtek RTL8730E WIFI Support
#
Expand Down
3 changes: 2 additions & 1 deletion build/configs/rtl8730e/loadable_ext_ddr/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ CONFIG_AMEBASMART_I2S2=y
# CONFIG_AMEBASMART_I2S_RX is not set
CONFIG_AMEBASMART_I2S_TX=y
CONFIG_AMEBASMART_I2S_TXCL=16

CONFIG_AMEBASMART_I2S_TX_DMA_SIZE=4096
CONFIG_AMEBASMART_I2S_TX_DMA_PAGE=4
#
# Realtek RTL8730E WIFI Support
#
Expand Down
3 changes: 2 additions & 1 deletion build/configs/rtl8730e/loadable_ext_psram/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ CONFIG_AMEBASMART_I2S2=y
# CONFIG_AMEBASMART_I2S3 is not set
# CONFIG_AMEBASMART_I2S_RX is not set
CONFIG_AMEBASMART_I2S_TX=y

CONFIG_AMEBASMART_I2S_TX_DMA_SIZE=4096
CONFIG_AMEBASMART_I2S_TX_DMA_PAGE=4
#
# Realtek RTL8730E WIFI Support
#
Expand Down
14 changes: 14 additions & 0 deletions os/arch/arm/src/amebasmart/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ config AMEBASMART_I2S_TXCL
int "I2S TX Channel Length"
default 32
range 8 32

config AMEBASMART_I2S_TX_DMA_SIZE
int "I2S TX DMA SIZE"
default 4096
range 4 16384
zhongnuo-tang marked this conversation as resolved.
Show resolved Hide resolved
---help---
4 ~ 16384, set to a factor of APB size

config AMEBASMART_I2S_TX_DMA_PAGE
int "I2S TX DMA PAGE"
default 4
---help---
DMA page should be more than 2
zhongnuo-tang marked this conversation as resolved.
Show resolved Hide resolved

endif
endif

Expand Down
13 changes: 11 additions & 2 deletions os/arch/arm/src/amebasmart/amebasmart_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@

#define OVER_SAMPLE_RATE (384U)

#define I2S_DMA_PAGE_SIZE 4096 /* 4 ~ 16384, set to a factor of APB size */
#define I2S_DMA_PAGE_NUM 4 /* Vaild number is 2~4 */
#ifdef CONFIG_AMEBASMART_I2S_TX_DMA_SIZE
#define I2S_DMA_PAGE_SIZE CONFIG_AMEBASMART_I2S_TX_DMA_SIZE /* 4 ~ 16384, set to a factor of APB size */
#else
#define I2S_DMA_PAGE_SIZE 4096 /* 4 ~ 16384, set to a factor of APB size */
#endif

#ifdef CONFIG_AMEBASMART_I2S_TX_DMA_PAGE
#define I2S_DMA_PAGE_NUM CONFIG_AMEBASMART_I2S_TX_DMA_PAGE /* Minimum number is 2 */
#else
#define I2S_DMA_PAGE_NUM 4
#endif

#ifdef CONFIG_PM
static volatile bool i2s_lock_state = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
#include "ameba_audio_clock.h"
#include "amebasmart_i2s.h"

#ifdef CONFIG_AMEBASMART_I2S_TX_DMA_PAGE
#define SP_MAX_DMA_PAGE_NUM (CONFIG_AMEBASMART_I2S_TX_DMA_PAGE + 1)
#else
#define SP_MAX_DMA_PAGE_NUM 8
zhongnuo-tang marked this conversation as resolved.
Show resolved Hide resolved

#endif
/** @addtogroup Ameba_Mbed_API
* @{
*/
Expand Down Expand Up @@ -220,8 +223,8 @@ void i2s_set_dma_buffer(i2s_t *obj, char *tx_buf, char *rx_buf,
uint32_t i, j;
#endif

if ((page_num < 2) || (page_num > 8) || (page_size < 8)) {
DBG_PRINTF(MODULE_I2S, LEVEL_INFO, "%s: PageNum(%d) valid value is 2~8; PageSize(%d must > 8)\r\n", \
if ((page_num < 2) || (page_num > (SP_MAX_DMA_PAGE_NUM - 1)) || (page_size < 4)) {
DBG_PRINTF(MODULE_I2S, LEVEL_INFO, "%s: PageNum(%d) valid value is > 2 and less than SP_MAX_DMA_PAGE_NUM; PageSize(%d must > 4)\r\n", \
__FUNCTION__, page_num, page_size);
return;
}
Expand Down