diff --git a/apps/examples/hello/hello_main.c b/apps/examples/hello/hello_main.c index ada58ad5d5..07750fcffd 100644 --- a/apps/examples/hello/hello_main.c +++ b/apps/examples/hello/hello_main.c @@ -56,10 +56,26 @@ #include #include +#include + + +#include +#include /**************************************************************************** * hello_main ****************************************************************************/ +#define byteWrite_DEBUG +#define UART_Printf printf + + +#define DEVICE_ADDRESS 0x1A // Device address when ADO = 1 + +#define I2C_FREQ 100000 + +int counter = 0; + +extern int amebad_PA0_set(unsigned int value); #ifdef CONFIG_BUILD_KERNEL int main(int argc, FAR char *argv[]) @@ -67,6 +83,230 @@ int main(int argc, FAR char *argv[]) int hello_main(int argc, char *argv[]) #endif { +#if 1 + amebad_PA0_set(0); + lldbg("set gpio0 to low"); + lldbg("registering i2s driver\n"); + struct i2s_dev_s *i2s = amebad_i2s_initialize(0); + sleep(2); + amebad_PA0_set(1); + lldbg("set gpio0 to high"); + sleep(2); + FAR struct i2c_dev_s *dev; + + dev = up_i2cinitialize(0); + + int ret = 0; + FAR struct i2c_config_s config; + uint8_t buf[2]; + uint8_t addr[2]; + + config.frequency = 100000; + config.addrlen = 7; + config.address = 0x1A; + +// while(true) { + + addr[0] = 0x04; + addr[1] = 0x00; + + ret = i2c_write(dev, &config, addr, 2); + + if (ret != 2) { + lldbg("write fail\n"); + return; + } + else lldbg("written 0x%02x to regaddr 0x%02x\n", addr[1], addr[0]); + + sleep(2); + + ret = i2c_write(dev, &config, addr, 1); // send address 0x01 followed by read command. + + if (ret != 1) { + lldbg("write fail\n"); + return; + } + + ret = i2c_read(dev, &config, buf, 1); + + if (ret != 1) { + lldbg("read fail\n"); + return; + } + + lldbg("read 0x%02x from regaddr 0x%02x\n", buf[0], addr[0]); + + sleep(2); + + addr[0] = 0x05; + addr[1] = 0x3F; + + ret = i2c_write(dev, &config, addr, 2); + + if (ret != 2) { + lldbg("write fail\n"); + return; + } + else lldbg("written 0x%02x to regaddr 0x%02x\n", addr[1], addr[0]); + + sleep(2); + + ret = i2c_write(dev, &config, addr, 1); // send address 0x01 followed by read command. + + if (ret != 1) { + lldbg("write fail\n"); + return; + } + + ret = i2c_read(dev, &config, buf, 1); + + if (ret != 1) { + lldbg("read fail\n"); + return; + } + + lldbg("read 0x%02x from regaddr 0x%02x\n", buf[0], addr[0]); + + sleep(2); + + addr[0] = 0x03; // write to regaddr 0x01 value 0x00 + addr[1] = 0x01; + + ret = i2c_write(dev, &config, addr, 2); + + if (ret != 2) { + lldbg("write fail\n"); + return; + } + else lldbg("written 0x%02x to regaddr 0x%02x\n", addr[1], addr[0]); + + sleep(2); + + ret = i2c_write(dev, &config, addr, 1); // send address 0x01 followed by read command. + + if (ret != 1) { + lldbg("write fail\n"); + return; + } + + ret = i2c_read(dev, &config, buf, 1); + + if (ret != 1) { + lldbg("read fail\n"); + return; + } + + + lldbg("read 0x%02x from regaddr 0x%02x\n", buf[0], addr[0]); + + sleep(2); + + addr[0] = 0x01; + addr[1] = 0x00; + + ret = i2c_write(dev, &config, addr, 2); + + if (ret != 2) { + lldbg("write fail\n"); + return; + } else lldbg("written 0x%02x to regaddr 0x%02x\n", addr[1], addr[0]); + + sleep(2); + + while(true) { + + ret = i2c_write(dev, &config, addr, 1); // send address 0x01 followed by read command. + + if (ret != 1) { + lldbg("write fail\n"); + return; + } + + ret = i2c_read(dev, &config, buf, 1); + + if (ret != 1) { + lldbg("read fail\n"); + return; + } + + lldbg("read 0x%02x from regaddr 0x%02x\n", buf[0], addr[0]); + + if (buf[0] == 0x02) break; // wait until we read 0x02 from the register. + + sleep(2); + + } + + addr[0] = 0x2A; // write to regaddr 0x01 value 0x00 + addr[1] = 0xCC; + + ret = i2c_write(dev, &config, addr, 2); + + if (ret != 2) { + lldbg("write fail\n"); + return; + } + else lldbg("written 0x%02x to regaddr 0x%02x\n", addr[1], addr[0]); + + sleep(2); + + ret = i2c_write(dev, &config, addr, 1); // send address 0x01 followed by read command. + + if (ret != 1) { + lldbg("write fail\n"); + return; + } + + ret = i2c_read(dev, &config, buf, 1); + + if (ret != 1) { + lldbg("read fail\n"); + return; + } + + + lldbg("read 0x%02x from regaddr 0x%02x\n", buf[0], addr[0]); + + sleep(2); + + addr[0] = 0x2B; // master volume fine + addr[1] = 0x03; + + ret = i2c_write(dev, &config, addr, 2); + + if (ret != 2) { + lldbg("write fail\n"); + return; + } + else lldbg("written 0x%02x to regaddr 0x%02x\n", addr[1], addr[0]); + + sleep(2); + + ret = i2c_write(dev, &config, addr, 1); // send address 0x01 followed by read command. + + if (ret != 1) { + lldbg("write fail\n"); + return; + } + + ret = i2c_read(dev, &config, buf, 1); + + if (ret != 1) { + lldbg("read fail\n"); + return; + } + + + lldbg("read 0x%02x from regaddr 0x%02x\n", buf[0], addr[0]); + +#else + sleep(2); + counter++; printf("Hello, World!!\n"); + if (counter == 3) { + printf("registering i2s driver\n"); + struct i2s_dev_s *i2s = amebad_i2s_initialize(0); + } +#endif return 0; } diff --git a/apps/examples/mediaplayer/BufferInputDataSource.cpp b/apps/examples/mediaplayer/BufferInputDataSource.cpp index ac94b5723e..fcefba244e 100644 --- a/apps/examples/mediaplayer/BufferInputDataSource.cpp +++ b/apps/examples/mediaplayer/BufferInputDataSource.cpp @@ -37,7 +37,7 @@ bool BufferInputDataSource::isPrepared() bool BufferInputDataSource::open() { if (!isPrepared()) { - mFp = fopen("/rom/over_16000.mp3", "rb"); + mFp = fopen("/mnt/sample.mp3", "rb"); mSrcSize = 2048; mSrcBuf = new unsigned char[mSrcSize]; // Application can specify all audio informations (audioType/sampleRate/channels/pcmFormat), diff --git a/apps/examples/mediaplayer/CmdView.cpp b/apps/examples/mediaplayer/CmdView.cpp index 876388ed6c..d6ad2031da 100644 --- a/apps/examples/mediaplayer/CmdView.cpp +++ b/apps/examples/mediaplayer/CmdView.cpp @@ -59,7 +59,7 @@ int CmdView::selectSource(vector sourceList) } cout << "====================" << endl; - return getUserInput(0, sourceList.size()); + return 4;//getUserInput(0, sourceList.size()); } int CmdView::selectPlayer(void) @@ -70,7 +70,7 @@ int CmdView::selectPlayer(void) cout << " 2. Select PLAYER B " << endl; cout << "====================" << endl; - int player = getUserInput(0, 2) - 1; + int player = 1 -1 ; //getUserInput(0, 2) - 1; if (player != -1) { cout << "PLAYER " << (char)('A' + player) << " is selected" << endl; } @@ -82,13 +82,13 @@ int CmdView::selectCommand(void) cout << "====================" << endl; cout << " 0. Do Nothing " << endl; cout << " 1. PLAYER_START " << endl; - cout << " 2. PLAYER_PAUSE " << endl; - cout << " 3. PLAYER_RESUME " << endl; - cout << " 4. PLAYER_STOP " << endl; - cout << " 5. GET_MAX_VOLUME " << endl; - cout << " 6. VOLUME_UP " << endl; - cout << " 7. VOLUME_DOWN " << endl; +// cout << " 2. PLAYER_PAUSE " << endl; +// cout << " 3. PLAYER_RESUME " << endl; + cout << " 2. PLAYER_STOP " << endl; +// cout << " 5. GET_MAX_VOLUME " << endl; +// cout << " 6. VOLUME_UP " << endl; +// cout << " 7. VOLUME_DOWN " << endl; cout << "====================" << endl; - return getUserInput(0, 7); + return getUserInput(0, 2); } } diff --git a/apps/examples/mediaplayer/mediaplayer_main.cpp b/apps/examples/mediaplayer/mediaplayer_main.cpp index 5b47387da7..f624196dc8 100644 --- a/apps/examples/mediaplayer/mediaplayer_main.cpp +++ b/apps/examples/mediaplayer/mediaplayer_main.cpp @@ -50,7 +50,7 @@ static const int TEST_PCM = 1; static const int TEST_BUFFER = 2; static const int TEST_HTTP = 3; -static char TEST_FILE_PATH[128] = "/rom/44100.pcm"; +static char TEST_FILE_PATH[128] = "/mnt/44100.pcm"; // We don't provide any song's URL, to avoid license issue. // Please fill a valid URL to `TEST_HTTP_URL` for testing! static const std::string TEST_HTTP_URL = ""; @@ -58,12 +58,12 @@ static const std::string TEST_HTTP_URL = ""; enum test_command_e { APP_OFF = 0, PLAYER_START = 1, - PLAYER_PAUSE, - PLAYER_RESUME, +// PLAYER_PAUSE, +// PLAYER_RESUME, PLAYER_STOP, - GET_MAX_VOLUME, - VOLUME_UP, - VOLUME_DOWN +// GET_MAX_VOLUME, +// VOLUME_UP, +// VOLUME_DOWN }; class MyMediaPlayer : public MediaPlayerObserverInterface, @@ -104,10 +104,10 @@ bool MyMediaPlayer::init(int test) switch (test) { case TEST_PCM: makeSource = []() { - auto source = std::move(unique_ptr(new FileInputDataSource("/rom/44100.pcm"))); - source->setSampleRate(44100); + auto source = std::move(unique_ptr(new FileInputDataSource("/mnt/file.raw"))); + source->setSampleRate(48000); source->setChannels(2); - source->setPcmFormat(AUDIO_FORMAT_TYPE_S16_LE); + source->setPcmFormat(AUDIO_FORMAT_TYPE_S32_LE); return std::move(source); }; break; @@ -156,7 +156,7 @@ void MyMediaPlayer::doCommand(int command) } focusManager.requestFocus(mFocusRequest); break; - case PLAYER_PAUSE: +/* case PLAYER_PAUSE: cout << "PLAYER_PAUSE is selected" << endl; if (mp.pause() != PLAYER_OK) { cout << "Mediaplayer::pause failed" << endl; @@ -168,7 +168,7 @@ void MyMediaPlayer::doCommand(int command) cout << "Mediaplayer::start failed" << endl; } break; - case PLAYER_STOP: +*/ case PLAYER_STOP: cout << "PLAYER_STOP is selected" << endl; if (mp.stop() != PLAYER_OK) { cout << "Mediaplayer::stop failed" << endl; @@ -180,7 +180,7 @@ void MyMediaPlayer::doCommand(int command) isSourceSet = false; focusManager.abandonFocus(mFocusRequest); break; - case GET_MAX_VOLUME: +/* case GET_MAX_VOLUME: cout << "GET_MAX_VOLUME is selected" << endl; if (mp.getMaxVolume(&volume) != PLAYER_OK) { cout << "MediaPlayer::getMaxVolume failed" << endl; @@ -230,7 +230,7 @@ void MyMediaPlayer::doCommand(int command) cout << "Now, Volume is " << (int)volume << endl; } break; - default: +*/ default: break; } } @@ -314,9 +314,10 @@ class MediaPlayerController public: void start() { + int player = -5; while (true) { vector sourceList = {"Exit APP", "Test PCM", "Test BUFFER", "Test HTTP"}; - listDirEntries("/rom", sourceList); + listDirEntries("/mnt", sourceList); auto test = view.selectSource(sourceList); if (test == 0) { break; @@ -329,7 +330,7 @@ class MediaPlayerController } while (true) { - auto player = view.selectPlayer(); + if (player == -5) player = view.selectPlayer(); if (player < 0) { break; } diff --git a/apps/system/i2c/i2c_dev.c b/apps/system/i2c/i2c_dev.c index d8aa1332b2..8da5fe6772 100644 --- a/apps/system/i2c/i2c_dev.c +++ b/apps/system/i2c/i2c_dev.c @@ -214,7 +214,7 @@ int i2ccmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv) ret = I2C_TRANSFER(dev, msg, 2); } - if (ret == OK) { + if (ret > 0) { i2ctool_printf(i2ctool, "%02x ", addr); } else { i2ctool_printf(i2ctool, "-- "); diff --git a/apps/system/i2c/i2c_get.c b/apps/system/i2c/i2c_get.c index a1fe0a126a..fdd7285c6e 100644 --- a/apps/system/i2c/i2c_get.c +++ b/apps/system/i2c/i2c_get.c @@ -237,12 +237,13 @@ int i2ctool_get(FAR struct i2ctool_s *i2ctool, FAR struct i2c_dev_s *dev, uint8_ /* Return the result of the read operation */ - if (ret == OK) { + if (ret > 0) { if (i2ctool->width == 8) { *result = (uint16_t)u.data8; } else { *result = u.data16; } + ret = 0; } return ret; diff --git a/apps/system/i2c/i2c_set.c b/apps/system/i2c/i2c_set.c index 2ab4574eb9..1661adf37b 100644 --- a/apps/system/i2c/i2c_set.c +++ b/apps/system/i2c/i2c_set.c @@ -254,6 +254,7 @@ int i2ctool_set(FAR struct i2ctool_s *i2ctool, FAR struct i2c_dev_s *dev, uint8_ } } else { ret = I2C_TRANSFER(dev, msg, 2); + if (ret > 0) ret = 0; } return ret; diff --git a/build/configs/rtl8721csm/audio/Make.defs b/build/configs/rtl8721csm/audio/Make.defs new file mode 100644 index 0000000000..e910bb31ac --- /dev/null +++ b/build/configs/rtl8721csm/audio/Make.defs @@ -0,0 +1,239 @@ +########################################################################### +# +# Copyright 2021 Samsung Electronics All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +# +########################################################################### +############################################################################ +# +# Copyright (C) 2020 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# 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 NuttX 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. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +ARCH_FAMILY = $(patsubst "%",%,$(CONFIG_ARCH_FAMILY)) +include ${TOPDIR}/arch/$(CONFIG_ARCH)/src/$(ARCH_FAMILY)/Toolchain.defs + +ifeq ($(CONFIG_AMEBAD_TRUSTZONE),y) +LDSCRIPT = rlx8721d_img2_ns.ld +else +LDSCRIPT = rlx8721d_img2_is.ld +endif + +ifeq ($(CONFIG_LIBCXX_HAVE_LIBSUPCXX),y) +LIBSUPXX = "/root/tizenrt/os/../build/configs/rtl8721csm/audio/libsupc++.a" +EXTRA_LIBPATHS += -L "${shell dirname "$(LIBSUPXX)"}" +EXTRA_LIBS += -lsupc++ +endif + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/../framework/include}" -isystem "${shell cygpath -w $(TOPDIR)/../external/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/../external/include}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/../build/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/../framework/include -isystem $(TOPDIR)/../external/include + ARCHINCLUDES += -isystem $(TOPDIR)/net/lwip/src/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/../external/include + ARCHXXINCLUDES += -isystem $(TOPDIR)/net/lwip/src/include + ARCHXXINCLUDES += -isystem $(TOPDIR)/../external/include/libcxx + ARCHXXINCLUDES += -isystem $(TOPDIR)/../framework/include + ARCHSCRIPT = -T$(TOPDIR)/../build/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AS = $(CROSSDEV)as +AR = $(CROSSDEV)ar rcs +NM = $(CROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump +LD_ROM = $(CROSSDEV)ld +CC_SIZE = $(CROSSDEV)size +FROMELF = $(CROSSDEV)objcopy +STRIP = $(CROSSDEV)strip +NM = $(ARCROSSDEV)nm + +GDB = arm-none-eabi-gdb +GDBR = arm-none-eabi-gdb +READELF = arm-none-eabi-readelf + +REMOVE = -rm -f +REMOVEDIR = rm -rf +MKDIR = mkdir +MAKE = make +CD = cd +COPY = cp +MOVE = mv + +PREPENDTOOL = $(COMPILATION_FILE_FOLDER)/prepend_header.sh +CODE_ANALYZE_PYTHON=$(COMPILATION_FILE_FOLDER)/code_analyze.py + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} +ARCHCCMINOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f2} + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + ARCHOPTIMIZATION = -g +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ifeq ($(CONFIG_FRAME_POINTER),y) + ARCHOPTIMIZATION += -fomit-frame-pointer -mapcs -mno-sched-prolog +endif + +ARCHCFLAGS = -fno-builtin -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 +ARCHCXXFLAGS = -fno-builtin -fexceptions -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 +ifeq ($(QUICKBUILD),y) +ARCHWARNINGS = -Wall -Werror -Wstrict-prototypes -Wshadow -Wundef -Wno-implicit-function-declaration -Wno-unused-function -Wno-unused-but-set-variable +ARCHWARNINGSXX = -Wall -Werror -Wshadow -Wundef +else +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -Wno-implicit-function-declaration -Wno-unused-function -Wno-unused-but-set-variable +ARCHWARNINGSXX = -Wall -Wshadow -Wundef +# only version 4.9 supports color diagnostics +ifeq "$(ARCHMAJOR)" "4" +ifeq "$(ARCHMINOR)" "9" + ARCHWARNINGS += -fdiagnostics-color=auto + ARCHWARNINGSCC += -fdiagnostics-color=auto +endif +endif + +endif +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe -ffunction-sections -fdata-sections +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXFLAGS += -std=c++11 -DCLOCK_MONOTONIC -D__TINYARA__ +CXXFLAGS += -fexceptions -fcheck-new -frtti +CXXFLAGS += -pedantic -D_DEBUG -D_LIBCPP_BUILD_STATIC -ffunction-sections -fdata-sections -D__GLIBCXX__ +ifeq ($(CONFIG_LIBCXX),y) +CXXFLAGS += -DCONFIG_WCHAR_BUILTIN +endif +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +########################################################################################################################################## +CFLAGS += -march=armv8-m.main+dsp +CFLAGS += -mthumb +CFLAGS += -mcmse +#CFLAGS += -mfloat-abi=hard +#CFLAGS += -mfpu=fpv5-sp-d16 + + +#CFLAGS += -g +#CFLAGS += -gdwarf-3 +#CFLAGS += -nodefaultlibs +#CFLAGS += -O2 +#CFLAGS += -D__FPU_PRESENT + +#CFLAGS += -fstack-usage +#CFLAGS += -fdata-sections +#CFLAGS += -nostartfiles +#CFLAGS += -nostdlib +#CFLAGS += -Wpointer-arith +#CFLAGS += -Wno-write-strings +#CFLAGS += -Wno-maybe-uninitialized +#CFLAGS += --save-temps +#CFLAGS += -c +#CFLAGS += -MMD + +#CFLAGS += -Wextra + +#CFLAGS += $(IFLAGS) +CFLAGS += -DCONFIG_PLATFORM_8721D +CFLAGS += -DCONFIG_USE_MBEDTLS_ROM_ALG +CFLAGS += -DDM_ODM_SUPPORT_TYPE=32 +CFLAGS += -DSTD_PRINTF +CFLAGS += -DCONFIG_PLATFORM_TIZENRT_OS=1 +CFLAGS += -DARM_CORE_CM4 + +#LDFLAGS += --wrap=printf + +########################################################################################################################################## + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = .axf + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + +LDFLAGS += --gc-sections + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + +define MAKE_BOARD_SPECIFIC_BIN + $(TOPDIR)/../build/configs/rtl8721csm/rtl8721csm_make_bin.sh +endef + +SECURE_HEADER_SIZE=32 + +define MAKE_SAMSUNG_HEADER + $(TOPDIR)/../os/tools/mksamsungheader.py kernel ${SECURE_HEADER_SIZE} +endef + +define MAKE_BOOTPARAM + $(TOPDIR)/../os/tools/mkbootparam.py +endef + +define DOWNLOAD + $(TOPDIR)/../build/configs/common_download.sh $(1) $(2) $(3) $(4) $(5) $(6) +endef diff --git a/build/configs/rtl8721csm/audio/defconfig b/build/configs/rtl8721csm/audio/defconfig new file mode 100644 index 0000000000..fba6d3d8a1 --- /dev/null +++ b/build/configs/rtl8721csm/audio/defconfig @@ -0,0 +1,1510 @@ +# +# Automatically generated file; DO NOT EDIT. +# TinyAra Configuration +# + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_DEFAULT_SMALL is not set +CONFIG_HOST_LINUX=y +# CONFIG_HOST_OSX is not set +# CONFIG_HOST_WINDOWS is not set +# CONFIG_HOST_OTHER is not set +# CONFIG_WINDOWS_NATIVE is not set + +# +# Build Configuration +# +CONFIG_APPS_DIR="../apps" +CONFIG_FRAMEWORK_DIR="../framework" +CONFIG_TOOLS_DIR="../tools" +CONFIG_BUILD_FLAT=y +# CONFIG_APP_BINARY_SEPARATION is not set +# CONFIG_BUILD_2PASS is not set +CONFIG_BOARD_BUILD_DATE="200204" +# CONFIG_BINARY_SIGNING is not set + +# +# Binary Output Formats +# +CONFIG_INTELHEX_BINARY=y +# CONFIG_MOTOROLA_SREC is not set +CONFIG_RAW_BINARY=y +# CONFIG_UBOOT_UIMAGE is not set +# CONFIG_DOWNLOAD_IMAGE is not set + +# +# Customize Header Files +# +# CONFIG_ARCH_STDINT_H is not set +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_FLOAT_H is not set +# CONFIG_ARCH_STDARG_H is not set +CONFIG_ARCH_HAVE_CUSTOMOPT=y +# CONFIG_DEBUG_NOOPT is not set +# CONFIG_DEBUG_CUSTOMOPT is not set +CONFIG_DEBUG_FULLOPT=y + +# +# Chip Selection +# +CONFIG_ARCH_ARM=y +# CONFIG_ARCH_XTENSA is not set +CONFIG_ARCH="arm" +# CONFIG_ARCH_CHIP_LM is not set +# CONFIG_ARCH_CHIP_S5J is not set +# CONFIG_ARCH_CHIP_BCM4390X is not set +# CONFIG_ARCH_CHIP_STM32 is not set +# CONFIG_ARCH_CHIP_IMXRT is not set +# CONFIG_ARCH_CHIP_STM32L4 is not set +CONFIG_ARCH_CHIP_AMEBAD=y +CONFIG_ARCH_CHIP="amebad" + +# +# ARM Options +# +# CONFIG_ARCH_CORTEXM3 is not set +# CONFIG_ARCH_CORTEXM4 is not set +# CONFIG_ARCH_CORTEXM7 is not set +CONFIG_ARCH_CORTEXM33=y +# CONFIG_ARCH_CORTEXR4 is not set +# CONFIG_ARCH_ARMV7M_FAMILY is not set +CONFIG_ARCH_ARMV8M_FAMILY=y +# CONFIG_ARCH_ARMV7R_FAMILY is not set +CONFIG_ARCH_FAMILY="armv8-m" +CONFIG_ARCH_HAVE_CMNVECTOR=y +CONFIG_ARM_CMNVECTOR=y +CONFIG_ARCH_HAVE_FPU=y +# CONFIG_ARCH_HAVE_DPFPU is not set +CONFIG_ARCH_HAVE_LAZYFPU=y +# CONFIG_ARCH_FPU is not set +# CONFIG_ARM_HAVE_MPU_UNIFIED is not set +CONFIG_ARM_MPU=y +CONFIG_ARMV8M_MPU=y +CONFIG_ARMV8M_MPU_NREGIONS=8 +# CONFIG_DEBUG_HARDFAULT is not set + +# +# Exception stack options +# +# CONFIG_ARCH_HAVE_DABORTSTACK is not set +# CONFIG_REG_STACK_OVERFLOW_PROTECTION is not set +CONFIG_STACK_OVERFLOW_PROTECTION_DISABLE=y +# CONFIG_SYSTEM_REBOOT_REASON is not set + +# +# ARMV8M Configuration Options +# +CONFIG_ARMV8M_HAVE_ICACHE=y +CONFIG_ARMV8M_HAVE_DCACHE=y +# CONFIG_ARMV8M_LAZYFPU is not set +CONFIG_ARMV8M_USEBASEPRI=y +CONFIG_ARMV8M_TRUSTZONE=y +CONFIG_ARMV8M_ICACHE=y +CONFIG_ARMV8M_DCACHE=y +# CONFIG_ARMV8M_DCACHE_WRITETHROUGH is not set +# CONFIG_ARMV8M_HAVE_ITCM is not set +# CONFIG_ARMV8M_HAVE_DTCM is not set +# CONFIG_ARMV8M_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARMV8M_TOOLCHAIN_CODEREDL is not set +# CONFIG_ARMV8M_TOOLCHAIN_CODESOURCERYL is not set +CONFIG_ARMV8M_TOOLCHAIN_GNU_EABIL=y +# CONFIG_ARMV8M_TOOLCHAIN_CLANGL is not set +# CONFIG_ARMV8M_HAVE_STACKCHECK is not set +# CONFIG_ARMV8M_ITMSYSLOG is not set + +# +# AMEBAD Configuration Options +# +CONFIG_ARCH_CHIP_RTL8721CSM=y + +# +# Realtek RTL8721D Peripheral Support +# +CONFIG_RTL8721D_UART=y +CONFIG_RTL8721D_UART0=y +CONFIG_RTL8721D_UART1=y +CONFIG_RTL8721D_UART2=y +CONFIG_RTL8721D_SERIAL_FIFO=y +CONFIG_AMEBAD_I2S=y +# CONFIG_AMEBAD_I2S_RX is not set +CONFIG_AMEBAD_I2S_TX=y +# CONFIG_AMEBAD_I2C_DYNTIMEO is not set +CONFIG_AMEBAD_I2CTIMEOSEC=0 +CONFIG_AMEBAD_I2CTIMEOMS=500 +CONFIG_AMEBAD_I2CTIMEOTICKS=500 + +# +# Realtek RTL8721D WIFI Support +# +CONFIG_AMEBAD_WIFI=y + +# +# Realtek RTL8721D BLE Support +# +CONFIG_AMEBAD_BLE=y +CONFIG_FTL_ENABLED=y +# CONFIG_AMEBAD_BLE_DEBUG is not set +CONFIG_AMEBAD_BLE_PERIPHERAL=y +CONFIG_AMEBAD_BLE_CENTRAL=y +CONFIG_AMEBAD_BLE_SCATTERNET=y + +# +# Realtek RTL8721D TrustZone Support +# +CONFIG_AMEBAD_TRUSTZONE=y +# CONFIG_AMEBAD_RDP is not set + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +# CONFIG_ARCH_DMA is not set +CONFIG_ARCH_HAVE_IRQPRIO=y +# CONFIG_ARCH_L2CACHE is not set +# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set +# CONFIG_ARCH_HAVE_ADDRENV is not set +# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set +CONFIG_ARCH_HAVE_VFORK=y +# CONFIG_ARCH_HAVE_MMU is not set +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARCH_NAND_HWECC is not set +# CONFIG_ARCH_HAVE_EXTCLK is not set +# CONFIG_ARCH_HAVE_POWEROFF is not set +CONFIG_ARCH_HAVE_RESET=y +CONFIG_ARCH_USE_MPU=y +CONFIG_ARCH_IRQPRIO=y +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_IDLE_CUSTOM is not set +# CONFIG_ARCH_HAVE_RAMFUNCS is not set +CONFIG_ARCH_HAVE_RAMVECTORS=y +# CONFIG_ARCH_RAMVECTORS is not set +# CONFIG_SUPPRESS_INTERRUPTS is not set +# CONFIG_SUPPRESS_TIMER_INTS is not set + +# +# Board Settings +# +CONFIG_BOARD_LOOPSPERMSEC=22222 +# CONFIG_ARCH_CALIBRATION is not set + +# +# Interrupt options +# +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=0 +CONFIG_ARCH_NESTED_IRQ_STACK_SIZE=512 +CONFIG_ARCH_HAVE_NESTED_INTERRUPT=y +CONFIG_ARCH_HAVE_HIPRI_INTERRUPT=y +# CONFIG_ARCH_HIPRI_INTERRUPT is not set + +# +# Boot options +# +# CONFIG_BOOT_RUNFROMEXTSRAM is not set +CONFIG_BOOT_RUNFROMFLASH=y +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Boot Memory Configuration +# +CONFIG_RAM_KREGIONx_START="0x10005000,0x02000000," +CONFIG_RAM_KREGIONx_SIZE="466944,3145728," +# CONFIG_DDR is not set +# CONFIG_ARCH_HAVE_SDRAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_RTL8721CSM=y +# CONFIG_ARCH_BOARD_ARTIK05X_FAMILY is not set +# CONFIG_ARCH_BOARD_ESP32_FAMILY is not set +CONFIG_ARCH_BOARD="rtl8721csm" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_BUTTONS=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_HAVE_IRQBUTTONS=y +# CONFIG_ARCH_IRQBUTTONS is not set +CONFIG_ARCH_HAVE_RAM_KERNEL_TEXT=y +# CONFIG_BOARD_CRASHDUMP is not set +# CONFIG_BOARD_ASSERT_AUTORESET is not set +CONFIG_BOARD_ASSERT_SYSTEM_HALT=y +CONFIG_LIB_BOARDCTL=y +CONFIG_BOARDCTL_RESET=y +# CONFIG_BOARDCTL_UNIQUEID is not set +# CONFIG_BOARD_FOTA_SUPPORT is not set + +# +# Board-Specific Options +# +CONFIG_FLASH_START_ADDR=0x8000000 +CONFIG_FLASH_SIZE=16777216 + +# +# SPI Flash driver +# +CONFIG_AMEBAD_FLASH_BASE=0x0 +CONFIG_AMEBAD_FLASH_CAPACITY=0x1000000 +CONFIG_AMEBAD_FLASH_PAGE_SIZE=256 +CONFIG_AMEBAD_FLASH_BLOCK_SIZE=4096 +CONFIG_ARCH_BOARD_HAVE_FLASH=y + +# +# Board-Partition Options +# +CONFIG_FLASH_PARTITION=y +CONFIG_FLASH_MINOR=0 +CONFIG_FLASH_PART_SIZE="16,8,16,472,8,5888,5888,4080,8," +CONFIG_FLASH_PART_TYPE="none,none,none,none,none,kernel,kernel,smartfs,bootparam," +CONFIG_FLASH_PART_NAME="bl1,bl2,reserved,ss,system_data,kernel,kernel,userfs,bootparam," +# CONFIG_ARCH_BOARD_HAVE_SECOND_FLASH is not set +CONFIG_AUTOMOUNT=y +CONFIG_AUTOMOUNT_USERFS=y + +# +# SE Selection +# +CONFIG_SE=y +CONFIG_DEBUG_SECURE_ELEMENT_ERROR=y +# CONFIG_DEBUG_SECURE_ELEMENT_INFO is not set +# CONFIG_SE_SSS is not set +# CONFIG_SE_KONAI is not set +# CONFIG_SE_VIRTUAL is not set +CONFIG_SE_AMEBA=y +CONFIG_HW_RNG=y +CONFIG_HW_DH_PARAM=y +CONFIG_HW_ECDH_PARAM=y +CONFIG_HW_RSA_VERIFICATION=y +CONFIG_HW_ECDSA_VERIFICATION=y +CONFIG_HW_RSA_ENC=y +CONFIG_HW_SE_STORAGE=y +# CONFIG_HW_AES_ENC is not set +CONFIG_SE_SECURE_CONTEXT_SIZE=4096 + +# +# Crypto Module +# +# CONFIG_CRYPTO is not set + +# +# Kernel Features +# +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_ENVIRON is not set + +# +# Clocks and Timers +# +CONFIG_USEC_PER_TICK=1000 +CONFIG_SYSTEM_TIME64=y +# CONFIG_CLOCK_MONOTONIC is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2011 +CONFIG_START_MONTH=12 +CONFIG_START_DAY=6 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=8 +CONFIG_WDOG_INTRESERVE=0 +CONFIG_PREALLOC_TIMERS=2 + +# +# Tasks and Scheduling +# +CONFIG_INIT_ENTRYPOINT=y +CONFIG_RR_INTERVAL=10 +CONFIG_TASK_NAME_SIZE=31 +CONFIG_MAX_TASKS=32 +CONFIG_SCHED_HAVE_PARENT=y +# CONFIG_SCHED_CHILD_STATUS is not set +CONFIG_SCHED_WAITPID=y +CONFIG_SIGKILL_HANDLER=y + +# +# Pthread Options +# +CONFIG_PTHREAD_MUTEX_TYPES=y +# CONFIG_PTHREAD_MUTEX_ROBUST is not set +CONFIG_PTHREAD_MUTEX_UNSAFE=y +# CONFIG_PTHREAD_MUTEX_BOTH is not set +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NPTHREAD_DESTRUCTOR_ITERATIONS=4 +# CONFIG_PTHREAD_CLEANUP is not set +# CONFIG_CANCELLATION_POINTS is not set + +# +# Performance Monitoring +# +CONFIG_SCHED_CPULOAD=y +# CONFIG_SCHED_CPULOAD_EXTCLK is not set +CONFIG_SCHED_CPULOAD_TIMECONSTANT=2 +# CONFIG_SCHED_MULTI_CPULOAD is not set + +# +# Latency optimization +# +# CONFIG_SCHED_YIELD_OPTIMIZATION is not set + +# +# Files and I/O +# +CONFIG_DEV_CONSOLE=y +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +# CONFIG_PRIORITY_INHERITANCE is not set + +# +# RTOS hooks +# +CONFIG_BOARD_INITIALIZE=y +# CONFIG_BOARD_INITTHREAD is not set +# CONFIG_SCHED_STARTHOOK is not set +CONFIG_SCHED_ATEXIT=y +CONFIG_SCHED_ONEXIT=y + +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCHLD=4 +CONFIG_SIG_SIGCONDTIMEDOUT=16 +CONFIG_SIG_SIGWORK=17 + +# +# POSIX Message Queue Options +# +CONFIG_PREALLOC_MQ_MSGS=32 +CONFIG_MQ_MAXMSGSIZE=32 + +# +# Stack size information +# +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +# CONFIG_MPU_STACKGAURD is not set +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 + +# +# Device Drivers +# +# CONFIG_DISABLE_POLL is not set +CONFIG_DEV_NULL=y +CONFIG_DEV_URANDOM=y +CONFIG_DEV_URANDOM_XORSHIFT128=y +# CONFIG_DEV_URANDOM_CONGRUENTIAL is not set +CONFIG_DEV_ZERO=y +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set +# CONFIG_CAN is not set +# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set +# CONFIG_ARCH_HAVE_PWM_MULTICHAN is not set +# CONFIG_PWM is not set +CONFIG_ARCH_HAVE_I2CRESET=y +CONFIG_I2C=y +# CONFIG_I2C_SLAVE is not set +CONFIG_I2C_USERIO=y +CONFIG_I2C_TRANSFER=y +CONFIG_I2C_POLLED=y +# CONFIG_I2C_TRACE is not set +# CONFIG_I2C_RESET is not set +# CONFIG_I2C_WRITEREAD is not set +CONFIG_SPI=y +CONFIG_SPI_USERIO=y +# CONFIG_SPI_OWNBUS is not set +CONFIG_SPI_EXCHANGE=y +CONFIG_SPI_CMDDATA=y +# CONFIG_SPI_BITBANG is not set +CONFIG_GPIO=y +CONFIG_I2S=y +CONFIG_AUDIO_DEVICES=y +CONFIG_AUDIO_MAX_INPUT_CARD_NUM=2 +CONFIG_AUDIO_MAX_OUTPUT_CARD_NUM=2 +CONFIG_AUDIO_MAX_DEVICE_NUM=3 +# CONFIG_AUDIO_PROCESSING_FEATURES is not set +# CONFIG_AUDIO_I2SCHAR is not set +# CONFIG_AUDIO_ALC5658 is not set +# CONFIG_AUDIO_NULL is not set +# CONFIG_AUDIO_CX20921 is not set +CONFIG_AUDIO_UB6470=y +# CONFIG_AUDIO_TAS5749 is not set +# CONFIG_DRIVERS_VIDEO is not set + +# +# LCD Driver Support +# +# CONFIG_LCD is not set +# CONFIG_BCH is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +CONFIG_TIMER=y +# CONFIG_MMINFO is not set +# CONFIG_PRODCONFIG is not set +# CONFIG_ANALOG is not set +# CONFIG_DRIVERS_OS_API_TEST is not set +# CONFIG_NETDEVICES is not set +CONFIG_PIPES=y +CONFIG_DEV_PIPE_SIZE=1024 +# CONFIG_POWER is not set +CONFIG_SERIAL=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y +# CONFIG_16550_UART is not set +# CONFIG_ARCH_HAVE_UART is not set +CONFIG_ARCH_HAVE_UART0=y +CONFIG_ARCH_HAVE_UART1=y +CONFIG_ARCH_HAVE_UART2=y +# CONFIG_ARCH_HAVE_UART3 is not set +# CONFIG_ARCH_HAVE_UART4 is not set +# CONFIG_ARCH_HAVE_UART5 is not set +# CONFIG_ARCH_HAVE_UART6 is not set +# CONFIG_ARCH_HAVE_UART7 is not set +# CONFIG_ARCH_HAVE_UART8 is not set +# CONFIG_ARCH_HAVE_SCI0 is not set +# CONFIG_ARCH_HAVE_SCI1 is not set +# CONFIG_ARCH_HAVE_USART0 is not set +# CONFIG_ARCH_HAVE_USART1 is not set +# CONFIG_ARCH_HAVE_USART2 is not set +# CONFIG_ARCH_HAVE_USART3 is not set +# CONFIG_ARCH_HAVE_USART4 is not set +# CONFIG_ARCH_HAVE_USART5 is not set +# CONFIG_ARCH_HAVE_USART6 is not set +# CONFIG_ARCH_HAVE_USART7 is not set +# CONFIG_ARCH_HAVE_USART8 is not set +# CONFIG_ARCH_HAVE_OTHER_UART is not set + +# +# USART Configuration +# +# CONFIG_OTHER_UART_SERIALDRIVER is not set +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +CONFIG_SERIAL_NPOLLWAITERS=2 +# CONFIG_SERIAL_IFLOWCONTROL is not set +# CONFIG_SERIAL_OFLOWCONTROL is not set +# CONFIG_SERIAL_TIOCSERGSTRUCT is not set +CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y +CONFIG_SERIAL_TERMIOS=y +# CONFIG_UART0_SERIAL_CONSOLE is not set +# CONFIG_UART1_SERIAL_CONSOLE is not set +CONFIG_UART2_SERIAL_CONSOLE=y +# CONFIG_OTHER_SERIAL_CONSOLE is not set +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# UART0 Configuration +# +CONFIG_UART0_RXBUFSIZE=1024 +CONFIG_UART0_TXBUFSIZE=1024 +CONFIG_UART0_BAUD=115200 +CONFIG_UART0_BITS=8 +CONFIG_UART0_PARITY=0 +CONFIG_UART0_2STOP=0 +# CONFIG_UART0_IFLOWCONTROL is not set +# CONFIG_UART0_OFLOWCONTROL is not set +# CONFIG_UART_SERIALDRIVER is not set +# CONFIG_UART0_SERIALDRIVER is not set +# CONFIG_UART1_SERIALDRIVER is not set +# CONFIG_UART2_SERIALDRIVER is not set +# CONFIG_UART3_SERIALDRIVER is not set +# CONFIG_UART4_SERIALDRIVER is not set +# CONFIG_UART5_SERIALDRIVER is not set +# CONFIG_UART6_SERIALDRIVER is not set +# CONFIG_UART7_SERIALDRIVER is not set +# CONFIG_UART8_SERIALDRIVER is not set +CONFIG_UART1_RXBUFSIZE=1024 +CONFIG_UART1_TXBUFSIZE=1024 +CONFIG_UART1_BAUD=115200 +CONFIG_UART1_BITS=8 +CONFIG_UART1_PARITY=0 +CONFIG_UART1_2STOP=0 +# CONFIG_UART1_IFLOWCONTROL is not set +# CONFIG_UART1_OFLOWCONTROL is not set +CONFIG_UART2_RXBUFSIZE=1024 +CONFIG_UART2_TXBUFSIZE=1024 +CONFIG_UART2_BAUD=115200 +CONFIG_UART2_BITS=8 +CONFIG_UART2_PARITY=0 +CONFIG_UART2_2STOP=0 +# CONFIG_UART2_IFLOWCONTROL is not set +# CONFIG_UART2_OFLOWCONTROL is not set +# CONFIG_LPUART_SERIALDRIVER is not set +# CONFIG_LPUART0_SERIALDRIVER is not set +# CONFIG_LPUART1_SERIALDRIVER is not set +# CONFIG_LPUART2_SERIALDRIVER is not set +# CONFIG_LPUART3_SERIALDRIVER is not set +# CONFIG_LPUART4_SERIALDRIVER is not set +# CONFIG_LPUART5_SERIALDRIVER is not set +# CONFIG_LPUART6_SERIALDRIVER is not set +# CONFIG_LPUART7_SERIALDRIVER is not set +# CONFIG_LPUART8_SERIALDRIVER is not set + +# +# UART1 Configuration +# + +# +# UART2 Configuration +# +# CONFIG_SENSOR is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_FOTA_DRIVER is not set + +# +# System Logging +# +# CONFIG_RAMLOG is not set +# CONFIG_SYSLOG_CONSOLE is not set + +# +# T-trace +# +# CONFIG_TTRACE is not set +# CONFIG_IOTDEV is not set + +# +# Wireless Device Options +# +CONFIG_DRIVERS_WIRELESS=y +CONFIG_DRIVERS_BLUETOOTH=y +# CONFIG_DRIVERS_BR_EDR is not set +CONFIG_DRIVERS_BLE=y +# CONFIG_VIRTUAL_BLE is not set +CONFIG_RTK_BLE=y +# CONFIG_OTP is not set +CONFIG_SECURITY_LINK_DRV=y +CONFIG_SECURITY_LINK=y +# CONFIG_SECURITY_LINK_DRV_PROFILE is not set + +# +# Networking Support +# +CONFIG_ARCH_HAVE_NET=y +# CONFIG_ARCH_HAVE_PHY is not set +CONFIG_NET=y +CONFIG_NET_LWIP=y + +# +# LwIP options +# +CONFIG_NET_IPv4=y +CONFIG_NET_IP_DEFAULT_TTL=255 +# CONFIG_NET_IP_FORWARD is not set +CONFIG_NET_IP_OPTIONS_ALLOWED=y +CONFIG_NET_IP_FRAG=y +CONFIG_NET_IP_REASSEMBLY=y +CONFIG_NET_IPV4_REASS_MAX_PBUFS=60 +CONFIG_NET_IPV4_REASS_MAXAGE=5 +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_TTL=255 +# CONFIG_NET_BROADCAST_PING is not set +# CONFIG_NET_MULTICAST_PING4 is not set +CONFIG_NET_LWIP_IGMP=y +CONFIG_NET_LWIP_MEMP_NUM_IGMP_GROUP=8 +CONFIG_NET_ARP=y +CONFIG_NET_ARP_TABLESIZE=10 +CONFIG_NET_ARP_QUEUEING=y +CONFIG_NET_ETHARP_TRUST_IP_MAC=y +CONFIG_NET_ETH_PAD_SIZE=0 +# CONFIG_NET_ARP_STATIC_ENTRIES is not set +CONFIG_NET_UDP=y +# CONFIG_NET_NETBUF_RECVINFO is not set +CONFIG_NET_UDP_TTL=255 +# CONFIG_NET_UDPLITE is not set +CONFIG_NET_TCP=y +CONFIG_NET_TCP_TTL=255 +CONFIG_NET_TCP_WND=58400 +# CONFIG_NET_WND_SCALE is not set +CONFIG_NET_TCP_MAXRTX=12 +CONFIG_NET_TCP_SYNMAXRTX=6 +CONFIG_NET_TCP_QUEUE_OOSEQ=y +CONFIG_NET_TCP_MSS=1460 +CONFIG_NET_TCP_CALCULATE_EFF_SEND_MSS=y +CONFIG_NET_TCP_SND_BUF=29200 +CONFIG_NET_TCP_SND_QUEUELEN=80 +CONFIG_NET_TCP_OOSEQ_MAX_BYTES=0 +CONFIG_NET_TCP_OOSEQ_MAX_PBUFS=0 +# CONFIG_NET_TCP_LISTEN_BACKLOG is not set +CONFIG_NET_TCP_OVERSIZE=1460 +# CONFIG_NET_TCP_TIMESTAMPS is not set +CONFIG_NET_TCP_WND_UPDATE_THRESHOLD=29200 +CONFIG_NET_IPv6=y +CONFIG_NET_IPv6_NUM_ADDRESSES=3 +# CONFIG_NET_IPv6_FORWARD is not set +# CONFIG_NET_IPv6_FRAG is not set +CONFIG_NET_IPv6_REASS=y +CONFIG_NET_IPV6_REASS_MAXAGE=60 +CONFIG_NET_IPv6_SEND_ROUTER_SOLICIT=y +CONFIG_NET_IPv6_AUTOCONFIG=y +CONFIG_NET_IPv6_DUP_DETECT_ATTEMPTS=1 +# CONFIG_NET_IPv6_PMTU_FOR_MULTICAST is not set + +# +# Neighbor Discovery (RFC 4861) +# +CONFIG_NET_IPv6_ND=y +CONFIG_NET_IPv6_ND_QUEUEING=y +CONFIG_NET_IPv6_ND_QUEUE=20 +CONFIG_NET_IPv6_ND_NUM_NEIGHBORS=10 +CONFIG_NET_IPv6_ND_NUM_DESTINATIONS=10 +CONFIG_NET_IPv6_ND_NUM_PREFIXES=5 +CONFIG_NET_IPv6_ND_NUM_ROUTERS=3 +CONFIG_NET_IPv6_ND_MAX_MULTICAST_SOLICIT=3 +CONFIG_NET_IPv6_ND_MAX_UNICAST_SOLICIT=3 +CONFIG_NET_IPv6_ND_MAX_SOLICIT_INTERVAL=4000 +CONFIG_NET_IPv6_ND_REACHABLE_TIME=30000 +CONFIG_NET_IPv6_ND_RETRANS_TIMER=1005 +CONFIG_NET_IPv6_ND_DELAY_FIRST_PROBE_TIME=5000 +CONFIG_NET_IPv6_ND_ALLOW_RA_UPDATES=y +CONFIG_NET_IPv6_ND_TCP_REACHABILITY_HINTS=y +CONFIG_NET_IPv6_ND_RDNSS_MAX_DNS_SERVERS=0 + +# +# ICMPv6 (RFC 4443) +# +CONFIG_NET_IPv6_ICMP=y +CONFIG_NET_IPv6_ICMP_DATASIZE=8 +CONFIG_NET_IPv6_ICMP_HL=255 +# CONFIG_NET_MULTICAST_PING6 is not set +CONFIG_NET_IPv6_MLD=y +CONFIG_NET_IPv6_MLD_GROUP=4 +# CONFIG_NET_IPv6_DHCP is not set + +# +# Socket support +# +CONFIG_NET_SOCKET=y +CONFIG_NBSDSOCKET_DESCRIPTORS=20 +CONFIG_NET_TCP_KEEPALIVE=y +CONFIG_NET_RAW=y +# CONFIG_NET_SOCKET_OPTION_BROADCAST is not set +# CONFIG_NET_RANDOMIZE_INITIAL_LOCAL_PORTS is not set +CONFIG_NET_SO_SNDTIMEO=y +CONFIG_NET_SO_RCVTIMEO=y +CONFIG_NET_SO_RCVBUF=y +CONFIG_NET_SO_REUSE=y +# CONFIG_NET_SO_REUSE_RXTOALL is not set + +# +# LWIP Mailbox Configurations +# +CONFIG_NET_TCPIP_MBOX_SIZE=64 +CONFIG_NET_DEFAULT_ACCEPTMBOX_SIZE=64 +CONFIG_NET_DEFAULT_RAW_RECVMBOX_SIZE=64 +CONFIG_NET_DEFAULT_TCP_RECVMBOX_SIZE=54 +CONFIG_NET_DEFAULT_UDP_RECVMBOX_SIZE=64 + +# +# Memory Configurations +# +CONFIG_NET_MEM_ALIGNMENT=4 +# CONFIG_NET_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT is not set +# CONFIG_NET_MEM_LIBC_MALLOC is not set +CONFIG_NET_MEMP_MEM_MALLOC=y +# CONFIG_NET_MEM_USE_POOLS is not set +CONFIG_NET_MEM_SIZE=81920 + +# +# LWIP Task Configurations +# +# CONFIG_NET_TCPIP_CORE_LOCKING is not set +# CONFIG_NET_TCPIP_CORE_LOCKING_INPUT is not set +CONFIG_NET_TCPIP_THREAD_NAME="LWIP_TCP/IP" +CONFIG_NET_TCPIP_THREAD_PRIO=105 +CONFIG_NET_TCPIP_THREAD_STACKSIZE=4096 +CONFIG_NET_COMPAT_MUTEX=y +CONFIG_NET_SYS_LIGHTWEIGHT_PROT=y +CONFIG_NET_DEFAULT_THREAD_NAME="lwIP" +CONFIG_NET_DEFAULT_THREAD_PRIO=1 +CONFIG_NET_DEFAULT_THREAD_STACKSIZE=0 + +# +# Debug Options for Network +# +# CONFIG_NET_LWIP_ASSERT is not set +# CONFIG_NET_LWIP_ERROR is not set +# CONFIG_NET_LWIP_DEBUG is not set + +# +# Enable Statistics +# +CONFIG_NET_STATS=y +# CONFIG_NET_STATS_DISPLAY is not set +# CONFIG_NET_LINK_STATS is not set +# CONFIG_NET_ETHARP_STATS is not set +# CONFIG_NET_IP_STATS is not set +# CONFIG_NET_IPFRAG_STATS is not set +# CONFIG_NET_ICMP_STATS is not set +# CONFIG_NET_UDP_STATS is not set +# CONFIG_NET_TCP_STATS is not set +# CONFIG_NET_MEM_STATS is not set +# CONFIG_NET_SYS_STATS is not set +# CONFIG_NET_IPv6_STATS is not set +# CONFIG_NET_IPv6_ICMP_STATS is not set +# CONFIG_NET_IPv6_MLD_STATS is not set +# CONFIG_NET_IPv6_ND_STATS is not set +# CONFIG_NET_LWIP_VLAN is not set +# CONFIG_NET_LWIP_SLIP_INTERFACE is not set +# CONFIG_NET_LWIP_PPP_SUPPORT is not set +# CONFIG_NET_LWIP_SNMP is not set +CONFIG_NET_LWIP_NETDB=y +CONFIG_NET_DNS_TABLE_SIZE=4 +CONFIG_NET_DNS_MAX_NAME_LENGTH=256 +CONFIG_NET_DNS_MAX_SERVERS=3 +# CONFIG_NET_DNS_DOES_NAME_CHECK is not set +CONFIG_NET_DNS_SECURE=0 +CONFIG_NET_DNS_MAX_TTL=604800 +CONFIG_NET_DNS_MAX_RETRIES=4 +# CONFIG_NET_DNS_LOCAL_HOSTLIST is not set +# CONFIG_NET_LWIP_SINGLE_PBUF is not set + +# +# Driver buffer configuration +# +CONFIG_NET_ETH_MTU=1500 +CONFIG_NET_GUARDSIZE=2 + +# +# Data link support +# +# CONFIG_NET_MULTILINK is not set +CONFIG_NET_ETHERNET=y + +# +# Protocols +# + +# +# Dynamic Host Configuration Protocol (DHCP) +# +# CONFIG_NET_DHCP is not set +CONFIG_NET_LWIP_DHCP=y +# CONFIG_LWIP_DHCP_HOSTNAME is not set +CONFIG_NETUTILS_DHCPC=y +CONFIG_LWIP_DHCPC=y +CONFIG_LWIP_DHCPC_TIMEOUT=10000 +CONFIG_NETUTILS_DHCPD=y +CONFIG_LWIP_DHCPS=y +CONFIG_LWIP_DHCPS_LEASE_DEF=120 +CONFIG_LWIP_DHCPS_SERVER_IP="192.168.47.1" +CONFIG_LWIP_DHCPS_SERVER_NETMASK="255.255.255.0" +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# CONFIG_LWIP_DHCPS_UNICAST is not set +# CONFIG_LWIP_DHCPS_ADDITIONAL_DNS is not set +# CONFIG_NETUTILS_XMLRPC is not set +# CONFIG_NETUTILS_NTPCLIENT is not set +# CONFIG_NETUTILS_WEBSERVER is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_MDNS is not set +# CONFIG_NETUTILS_FTPD is not set +# CONFIG_NETUTILS_WEBSOCKET is not set +# CONFIG_NETUTILS_LIBCOAP is not set +# CONFIG_NETUTILS_TFTPC is not set +# CONFIG_NETUTILS_TELNETD is not set +# CONFIG_NETUTILS_SMTP is not set +# CONFIG_GRPC is not set +# CONFIG_NETUTILS_MQTT is not set +CONFIG_NET_SECURITY_TLS=y +CONFIG_TLS_WITH_HW_ACCEL=y +CONFIG_TLS_MPI_MAX_SIZE=512 +# CONFIG_TLS_HAVE_NO_TIME_DATE is not set + +# +# HW Options +# +CONFIG_TLS_HW_RNG=y +CONFIG_TLS_HW_DH_PARAM=y +CONFIG_TLS_HW_ECDH_PARAM=y +CONFIG_TLS_HW_RSA_VERIFICATION=y +CONFIG_TLS_HW_ECDSA_VERIFICATION=y +CONFIG_TLS_HW_RSA_ENC=y + +# +# Wireless +# +CONFIG_WIFI_MANAGER=y +# CONFIG_SELECT_WLAN_VIRTUAL is not set +# CONFIG_SELECT_SCSC_WLAN is not set +# CONFIG_SELECT_RTK_WLAN is not set +CONFIG_SELECT_PROPRIETARY_WLAN=y +CONFIG_SELECT_PROPRIETARY_SUPPLICANT=y +# CONFIG_WIFI_MANAGER_SAVE_CONFIG is not set +CONFIG_WIFIMGR_SOFTAP_IFNAME="wlan0" +CONFIG_WIFIMGR_STA_IFNAME="wlan0" +# CONFIG_WIFIMGR_DISABLE_DHCPC is not set +# CONFIG_WIFIMGR_DISABLE_DHCPS is not set +CONFIG_DISABLE_EXTERNAL_AUTOCONNECT=y + +# +# Bluetooth +# +CONFIG_BLE_MANAGER=y + +# +# Network utilities +# +CONFIG_NETUTILS_NETLIB=y +CONFIG_NET_NETMON=y +CONFIG_NETUTILS_STATS_DISPLAY_TOOL=y + +# +# Network Manager +# +CONFIG_NET_NETMGR=y +# CONFIG_NET_NETMGR_ZEROCOPY is not set +# CONFIG_NET_TASK_BIND is not set +# CONFIG_NET_DEBUG_PORT is not set + +# +# Network Device Operations +# +# CONFIG_NETDEV_PHY_IOCTL is not set +CONFIG_LWNL80211=y +# CONFIG_DEBUG_LWNL80211_ERROR is not set +# CONFIG_DEBUG_LWNL80211_INFO is not set +# CONFIG_DEBUG_LWNL80211_VENDOR_DRV_ERROR is not set +# CONFIG_DEBUG_LWNL80211_VENDOR_DRV_INFO is not set +CONFIG_NET_LOOPBACK_INTERFACE=y + +# +# Audio Support +# +CONFIG_AUDIO=y +# CONFIG_AUDIO_MULTI_SESSION is not set + +# +# Audio Buffer Configuration +# +# CONFIG_AUDIO_LARGE_BUFFERS is not set +CONFIG_AUDIO_NUM_BUFFERS=2 +CONFIG_AUDIO_BUFSIZE=2048 +# CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS is not set + +# +# Exclude Specific Audio Features +# +# CONFIG_AUDIO_EXCLUDE_GAIN is not set +# CONFIG_AUDIO_EXCLUDE_VOLUME is not set +# CONFIG_AUDIO_EXCLUDE_BALANCE is not set +CONFIG_AUDIO_EXCLUDE_EQUALIZER=y +# CONFIG_AUDIO_EXCLUDE_TONE is not set +# CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME is not set +# CONFIG_AUDIO_EXCLUDE_STOP is not set +# CONFIG_AUDIO_EXCLUDE_FFORWARD is not set +CONFIG_AUDIO_EXCLUDE_REWIND=y +# CONFIG_AUDIO_CUSTOM_DEV_PATH is not set + +# +# Media Support +# +CONFIG_MEDIA=y +CONFIG_MEDIA_PLAYER=y +CONFIG_MEDIA_PLAYER_STACKSIZE=4096 +CONFIG_MEDIA_PLAYER_OBSERVER_STACKSIZE=2048 +CONFIG_INPUT_DATASOURCE_STACKSIZE=4096 +CONFIG_HTTPSOURCE_DOWNLOAD_BUFFER_SIZE=4096 +CONFIG_HTTPSOURCE_DOWNLOAD_BUFFER_THRESHOLD=2048 +CONFIG_HTTPSOURCE_DOWNLOAD_STACKSIZE=8192 +CONFIG_DATASOURCE_PREPARSE_BUFFER_SIZE=4096 +CONFIG_CONTAINER_FORMAT=y + +# +# Containers for multi-media +# +CONFIG_CONTAINER_MPEG2TS=y +# CONFIG_CONTAINER_MP4 is not set +# CONFIG_CONTAINER_OGG is not set + +# +# Containers exclusive to audio +# +# CONFIG_CONTAINER_WAV is not set +CONFIG_DEMUX_BUFFER_SIZE=4096 +# CONFIG_MEDIA_RECORDER is not set +# CONFIG_MEDIA_VOICE_SPEECH_DETECTOR is not set +CONFIG_AUDIO_RESAMPLER_BUFSIZE=4096 +CONFIG_FILE_DATASOURCE_STREAM_BUFFER_SIZE=4096 +CONFIG_FILE_DATASOURCE_STREAM_BUFFER_THRESHOLD=2048 +CONFIG_BUFFER_DATASOURCE_STREAM_BUFFER_SIZE=4096 +CONFIG_BUFFER_DATASOURCE_STREAM_BUFFER_THRESHOLD=1 +CONFIG_HANDLER_STREAM_BUFFER_SIZE=4096 +CONFIG_HANDLER_STREAM_BUFFER_THRESHOLD=2048 +CONFIG_AUDIO_CODEC=y +CONFIG_AUDIO_CODEC_RINGBUFFER_SIZE=16384 + +# +# File Systems +# +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +CONFIG_FS_READABLE=y +CONFIG_FS_WRITABLE=y +# CONFIG_FS_AIO is not set +# CONFIG_FS_NAMED_SEMAPHORES is not set +CONFIG_FS_MQUEUE_MPATH="/var/mqueue" +CONFIG_FS_SMARTFS=y + +# +# SMARTFS options +# +CONFIG_SMARTFS_ERASEDSTATE=0xff +CONFIG_SMARTFS_MAXNAMLEN=32 +# CONFIG_SMARTFS_MULTI_ROOT_DIRS is not set +CONFIG_SMARTFS_ALIGNED_ACCESS=y +# CONFIG_SMARTFS_DYNAMIC_HEADER is not set +# CONFIG_SMARTFS_ENTRY_TIMESTAMP is not set +CONFIG_FS_PROCFS=y +# CONFIG_FS_AUTOMOUNT_PROCFS is not set + +# +# Exclude individual procfs entries +# +# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set +# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set +# CONFIG_FS_PROCFS_EXCLUDE_VERSION is not set +# CONFIG_FS_PROCFS_EXCLUDE_CPULOAD is not set +# CONFIG_FS_PROCFS_EXCLUDE_IRQS is not set +# CONFIG_FS_PROCFS_EXCLUDE_MTD is not set +# CONFIG_FS_PROCFS_EXCLUDE_PARTITIONS is not set +# CONFIG_FS_PROCFS_EXCLUDE_SMARTFS is not set +# CONFIG_FS_ROMFS is not set +# CONFIG_FS_TMPFS is not set + +# +# Block Driver Configurations +# +# CONFIG_RAMDISK is not set + +# +# MTD Configuration +# +CONFIG_MTD=y +CONFIG_MTD_PARTITION=y +CONFIG_MTD_PARTITION_NAMES=y +# CONFIG_MTD_PROGMEM is not set +CONFIG_MTD_FTL=y + +# +# MTD_FTL Configurations +# +# CONFIG_MTD_CONFIG is not set +# CONFIG_MTD_BYTE_WRITE is not set + +# +# MTD Device Drivers +# +# CONFIG_MTD_M25P is not set +# CONFIG_RAMMTD is not set +CONFIG_MTD_SMART=y + +# +# SMART Device options +# +CONFIG_MTD_SMART_SECTOR_SIZE=1024 +CONFIG_MTD_SMART_WEAR_LEVEL=y +# CONFIG_MTD_SMART_ENABLE_CRC is not set +# CONFIG_MTD_SMART_JOURNALING is not set +# CONFIG_MTD_SMART_SECTOR_ERASE_DEBUG is not set +# CONFIG_MTD_SMART_ALLOC_DEBUG is not set +# CONFIG_MTD_W25 is not set +# CONFIG_MTD_JEDEC is not set + +# +# System Logging +# +# CONFIG_SYSLOG is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +# CONFIG_GENERATE_FS_IMAGE is not set + +# +# Database +# +# CONFIG_ARASTORAGE is not set + +# +# AraUI Framework +# +# CONFIG_UI is not set + +# +# Memory Management +# +CONFIG_MM_KERNEL_HEAP=y +# CONFIG_REALLOC_DISABLE_NEIGHBOR_EXTENSION is not set +# CONFIG_MM_SMALL is not set +CONFIG_KMM_REGIONS=2 +CONFIG_KMM_NHEAPS=1 +# CONFIG_GRAN is not set +# CONFIG_MM_ASSERT_ON_FAIL is not set + +# +# Work Queue Support +# +CONFIG_SCHED_WORKQUEUE=y + +# +# Kernel Work Queue +# +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=224 +CONFIG_SCHED_HPWORKSTACKSIZE=2048 +CONFIG_SCHED_LPWORK=y +CONFIG_SCHED_LPNTHREADS=1 +CONFIG_SCHED_LPWORKPRIORITY=50 +CONFIG_SCHED_LPWORKSTACKSIZE=2048 +# CONFIG_DEBUG_WORKQUEUE is not set + +# +# Power Management +# +# CONFIG_PM is not set + +# +# Debug Options +# +CONFIG_DEBUG=y +CONFIG_DEBUG_ERROR=y +CONFIG_DEBUG_WARN=y +CONFIG_DEBUG_VERBOSE=y + +# +# Subsystem Debug Options +# +# CONFIG_DEBUG_AUDIO is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_DEBUG_LIB is not set +# CONFIG_DEBUG_MM is not set +CONFIG_DEBUG_NET=y +CONFIG_DEBUG_NET_ERROR=y +CONFIG_DEBUG_NET_WARN=y +# CONFIG_DEBUG_NET_INFO is not set +# CONFIG_DEBUG_BLE is not set +# CONFIG_DEBUG_PM is not set +# CONFIG_DEBUG_SCHED is not set +# CONFIG_DEBUG_TASH is not set + +# +# Framework Debug Options +# +# CONFIG_DEBUG_IOTBUS is not set +# CONFIG_DEBUG_MEDIA is not set + +# +# OS Function Debug Options +# +CONFIG_ARCH_HAVE_HEAPCHECK=y +# CONFIG_DEBUG_HEAP is not set +# CONFIG_DEBUG_MM_HEAPINFO is not set +# CONFIG_DEBUG_IRQ is not set + +# +# Driver Debug Options +# +# CONFIG_DEBUG_ANALOG is not set +# CONFIG_DEBUG_I2S is not set +# CONFIG_DEBUG_SPI is not set +# CONFIG_DEBUG_TIMER is not set + +# +# System Debug Options +# +# CONFIG_DEBUG_SYSTEM is not set + +# +# Stack Debug Options +# +CONFIG_ARCH_HAVE_STACKCHECK=y +# CONFIG_STACK_COLORATION is not set + +# +# Build Debug Options +# +CONFIG_DEBUG_SYMBOLS=y +# CONFIG_FRAME_POINTER is not set + +# +# Logger Module +# +# CONFIG_LOGM is not set + +# +# Built-in Libraries +# + +# +# Standard C Library Options +# +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +CONFIG_LIB_HOMEDIR="/" +CONFIG_LIBM=y +# CONFIG_NOPRINTF_FIELDWIDTH is not set +CONFIG_LIBC_FLOATINGPOINT=y +CONFIG_LIBC_LONG_LONG=y +CONFIG_LIBC_FLOATPRECISION=6 +CONFIG_LIBC_SCANSET=y +# CONFIG_NOPRINTF_LONGLONG_TO_ASCII is not set +# CONFIG_LIBC_IOCTL_VARIADIC is not set +CONFIG_LIBC_WCHAR=y +# CONFIG_LIBC_LOCALE is not set +CONFIG_LIB_RAND_ORDER=1 +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +CONFIG_LIBC_STRERROR=y +# CONFIG_LIBC_STRERROR_SHORT is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_LIBC_TMPDIR="/tmp" +CONFIG_LIBC_MAX_TMPFILE=32 +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIBC_LOCALTIME=y +CONFIG_LIBC_TZ_MAX_TIMES=320 +CONFIG_LIBC_TZ_MAX_TYPES=20 +CONFIG_LIBC_TZDIR="/etc/zoneinfo" +# CONFIG_LIBC_DOWNLOAD_ZONEINFO is not set +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_LIBC_ARCH_ELF is not set +CONFIG_ARCH_OPTIMIZED_FUNCTIONS=y +# CONFIG_ARCH_MEMCPY is not set +CONFIG_MEMCPY_VIK=y +CONFIG_MEMCPY_PRE_INC_PTRS=y +# CONFIG_MEMCPY_INDEXED_COPY is not set +# CONFIG_MEMCPY_64BIT is not set +# CONFIG_ARCH_MEMCMP is not set +# CONFIG_ARCH_MEMMOVE is not set +# CONFIG_ARCH_MEMSET is not set +CONFIG_MEMSET_OPTSPEED=y +# CONFIG_MEMSET_64BIT is not set +# CONFIG_ARCH_STPNCPY is not set +# CONFIG_ARCH_STRCHR is not set +# CONFIG_ARCH_STRCMP is not set +# CONFIG_ARCH_STRCPY is not set +# CONFIG_ARCH_STRNCPY is not set +# CONFIG_ARCH_STRLEN is not set +# CONFIG_ARCH_STRNLEN is not set +# CONFIG_ARCH_BZERO is not set +# CONFIG_LIB_ENVPATH is not set +# CONFIG_LIB_HASHMAP is not set + +# +# Program Execution Options +# +# CONFIG_LIBC_SYMTAB is not set + +# +# Basic CXX Support +# +CONFIG_C99_BOOL8=y +CONFIG_HAVE_CXX=y +CONFIG_CXX_NEWLONG=y + +# +# LLVM C++ Library (libcxx) +# +CONFIG_LIBCXX=y +CONFIG_LIBCXX_EXCEPTION=y +CONFIG_LIBCXX_IOSTREAM_BUFSIZE=32 +CONFIG_LIBCXX_HAVE_LIBSUPCXX=y + +# +# External Libraries +# +# CONFIG_AVS_DEVICE_SDK is not set +# CONFIG_AWS_SDK is not set +# CONFIG_NETUTILS_CODECS is not set + +# +# CURL Options +# +CONFIG_ENABLE_CURL=y +# CONFIG_DISABLE_HTTP is not set +# CONFIG_USE_ZLIB is not set +# CONFIG_DISABLE_COOKIES is not set +CONFIG_DISABLE_DICT=y +CONFIG_DISABLE_FILE=y +CONFIG_DISABLE_FTP=y +CONFIG_DISABLE_TFTP=y +CONFIG_DISABLE_GOPHER=y +CONFIG_DISABLE_SCP=y +CONFIG_DISABLE_TELNET=y +CONFIG_DISABLE_LDAP=y +CONFIG_DISABLE_SMB=y +CONFIG_DISABLE_SMTP=y +CONFIG_DISABLE_POP3=y +CONFIG_DISABLE_PROXY=y +CONFIG_DISABLE_IMAP=y +CONFIG_DISABLE_RTSP=y +CONFIG_DISABLE_NTLM=y +# CONFIG_DISABLE_CRYPTO_AUTH is not set +CONFIG_CA_PATH="/rom" +CONFIG_CA_BUNDLE="/rom/curl-certificates.crt" +# CONFIG_CA_FALLBACK is not set +# CONFIG_CURL_DEBUG is not set +# CONFIG_ERROR_REPORT is not set +# CONFIG_GMOCK is not set +# CONFIG_ENABLE_IOTIVITY is not set +CONFIG_NETUTILS_JSON=y +# CONFIG_LIBTUV is not set +# CONFIG_PROTOBUF is not set +# CONFIG_LWM2M_WAKAAMA is not set +# CONFIG_WIFI_MBOX is not set +# CONFIG_CODEC_LIBOPUS is not set +CONFIG_STRESS_TOOL=y +# CONFIG_VOICE_SOFTWARE_EPD is not set +# CONFIG_EXTERNAL_VEC is not set +# CONFIG_LIBLZMA is not set +# CONFIG_NANOPB is not set +# CONFIG_LIBSODIUM is not set +# CONFIG_OPENSSL_WRAPPER is not set +# CONFIG_STDK_IOT_CORE is not set + +# +# Binary Loader +# +# CONFIG_BINFMT_ENABLE is not set + +# +# Binary Compression +# + +# +# Application Configuration +# + +# +# Application entry point list +# +# CONFIG_ENTRY_MANUAL is not set +CONFIG_ENTRY_MEDIAPLAYER=y +# CONFIG_ENTRY_WIFIMANAGER_TEST is not set +CONFIG_USER_ENTRYPOINT="mediaplayer_main" +CONFIG_BUILTIN_APPS=y + +# +# Examples +# +# CONFIG_EXAMPLES_AVS_TEST is not set +# CONFIG_EXAMPLES_AWS is not set +# CONFIG_EXAMPLES_BLE_RMC is not set +# CONFIG_EXAMPLES_CURLTEST is not set +# CONFIG_EXAMPLES_CXXTEST is not set +# CONFIG_EXAMPLES_DNSCLIENT_TEST is not set +# CONFIG_EXAMPLES_DTLS_CLIENT is not set +# CONFIG_EXAMPLES_DTLS_SERVER is not set +# CONFIG_EXAMPLES_EEPROM_TEST is not set +# CONFIG_EXAMPLES_EVENTLOOP is not set +# CONFIG_EXAMPLES_FOTA_SAMPLE is not set +# CONFIG_FILESYSTEM_TEST is not set +# CONFIG_EXAMPLES_HEAVY_SIGNAL_MESSAGE_TEST is not set +# CONFIG_EXAMPLES_HELLO is not set +# CONFIG_EXAMPLES_HELLOXX is not set +# CONFIG_EXAMPLES_IOTBUS_TEST is not set +# CONFIG_EXAMPLES_IOTJS_STARTUP is not set +# CONFIG_EXAMPLES_KERNEL_SAMPLE is not set +# CONFIG_EXAMPLES_LIBTUV is not set +# CONFIG_EXAMPLES_LWNL_SAMPLE is not set +CONFIG_EXAMPLES_MEDIAPLAYER=y +# CONFIG_EXAMPLES_MEDIARECORDER is not set +# CONFIG_EXAMPLES_MEMORY_FRAGMENTATION_TEST is not set +# CONFIG_EXAMPLES_NETTEST is not set + +# +# Performance +# +# CONFIG_EXAMPLES_HEAP_PERFORMANCE_TEST is not set +# CONFIG_EXAMPLES_SYSCALL_PERFORMANCE is not set +# CONFIG_EXAMPLES_TLS_BENCHMARK is not set +# CONFIG_EXAMPLES_TLS_HANDSHAKE is not set +# CONFIG_EXAMPLES_TLS_SECLINK is not set +# CONFIG_EXAMPLES_RDP is not set +# CONFIG_EXAMPLES_RSSI_REPORT is not set +# CONFIG_EXAMPLES_SECURITY_HAL_TEST is not set +# CONFIG_EXAMPLES_MBEDTLS_SELF_TEST is not set +# CONFIG_EXAMPLES_SECLINK_TEST is not set +# CONFIG_EXAMPLES_SECURITY_API_TEST is not set +# CONFIG_EXAMPLES_SECURITY_SEE_TEST is not set +# CONFIG_EXAMPLES_SECLINK_TOOL is not set +# CONFIG_EXAMPLES_SELECT_TEST is not set +# CONFIG_EXAMPLES_SENSORBOARD is not set +# CONFIG_EXAMPLES_SETJMP_TEST is not set +# CONFIG_EXAMPLES_SIMPLE_FILE_TRANSFER is not set +# CONFIG_EXAMPLES_SMARTFS_BUF_OPTIMIZATION is not set +# CONFIG_EXAMPLES_FS_PERFORMANCE is not set +# CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMART_TEST is not set +# CONFIG_EXAMPLES_SMARTFS_POWERCUT is not set +# CONFIG_EXAMPLES_SPEECH_DETECTOR_TEST is not set +# CONFIG_EXAMPLES_ST_THINGS is not set +# CONFIG_EXAMPLES_TESTCASE is not set +# CONFIG_EXAMPLES_TIMER is not set +# CONFIG_EXAMPLES_TLS_CLIENT is not set +# CONFIG_EXAMPLES_TLS_SELFTEST is not set +# CONFIG_EXAMPLES_TLS_SERVER is not set +# CONFIG_EXAMPLES_WAVE_GEN is not set +# CONFIG_EXAMPLES_TAHI is not set +CONFIG_EXAMPLES_WIFIMANAGER_TEST=y +CONFIG_WIFIMANAGER_TEST_TRIAL=5 +CONFIG_EXAMPLES_WIFIMANAGER_AP_LIST_ITEMS_COUNT=10 + +# +# Platform-specific Support +# +# CONFIG_PLATFORM_CONFIGDATA is not set +CONFIG_HAVE_CXXINITIALIZE=y + +# +# Shell +# +CONFIG_TASH=y +CONFIG_TASH_MAX_STORE_COMMANDS=10 +# CONFIG_TASH_USLEEP is not set +CONFIG_TASH_REBOOT=y +# CONFIG_TASH_COMMAND_INTERFACE is not set +CONFIG_TASH_CMDTASK_STACKSIZE=4096 +CONFIG_TASH_CMDTASK_PRIORITY=100 +# CONFIG_TASH_SCRIPT is not set +# CONFIG_SECURED_TASH is not set + +# +# System Libraries and Add-Ons +# +# CONFIG_SYSTEM_CLE is not set +# CONFIG_SYSTEM_CUTERM is not set +# CONFIG_SYSTEM_FLASH_READ is not set +# CONFIG_SYSTEM_FOTA_HAL is not set +# CONFIG_SYSTEM_I2CTOOL is not set +# CONFIG_SYSTEM_INIFILE is not set +CONFIG_SYSTEM_PREAPP_INIT=y +CONFIG_SYSTEM_PREAPP_STACKSIZE=2048 +CONFIG_SYSTEM_IPERF=y +CONFIG_IPERF_PRIORITY=106 +CONFIG_IPERF_STACKSIZE=4096 +CONFIG_SYSTEM_NETDB=y +CONFIG_SYSTEM_NETDB_STACKSIZE=2048 +CONFIG_SYSTEM_NETDB_PRIORITY=100 +# CONFIG_SYSTEM_RAMTEST is not set +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y +CONFIG_SYSTEM_INFORMATION=y +CONFIG_SYSTEM_CMDS=y +CONFIG_FS_CMDS=y +CONFIG_FSCMD_BUFFER_LEN=256 +CONFIG_NET_CMDS=y +CONFIG_NET_PING_CMD=y +CONFIG_NET_PING_CMD_ICOUNT=5 +CONFIG_ENABLE_CPULOAD=y +CONFIG_CPULOADMONITOR_PRIORITY=100 +CONFIG_CPULOADMONITOR_INTERVAL=5 +CONFIG_ENABLE_DATE=y +CONFIG_ENABLE_ENV_GET=y +CONFIG_ENABLE_ENV_SET=y +CONFIG_ENABLE_ENV_UNSET=y +CONFIG_ENABLE_FREE=y +# CONFIG_ENABLE_TZSELECT is not set +CONFIG_ENABLE_KILL=y +CONFIG_ENABLE_KILLALL=y +# CONFIG_ENABLE_PS is not set +# CONFIG_ENABLE_STACKMONITOR is not set +CONFIG_ENABLE_UPTIME=y +# CONFIG_SYSTEM_VI is not set + +# +# Loadable apps Configuration +# +CONFIG_APP1_INFO=y +CONFIG_APP1_BIN_NAME="app1" +CONFIG_APP1_BIN_TYPE="ELF" +CONFIG_APP1_BIN_VER=190412 +CONFIG_APP1_BIN_DYN_RAMSIZE=512000 +CONFIG_APP1_BIN_LOADING_PRIORITY="HIGH" +CONFIG_APP1_MAIN_STACKSIZE=4096 +CONFIG_APP1_MAIN_PRIORITY=220 +CONFIG_APP2_INFO=y +CONFIG_APP2_BIN_NAME="app2" +CONFIG_APP2_BIN_TYPE="ELF" +CONFIG_APP2_BIN_VER=190412 +CONFIG_APP2_BIN_DYN_RAMSIZE=512000 +CONFIG_APP2_BIN_LOADING_PRIORITY="HIGH" +CONFIG_APP2_MAIN_STACKSIZE=8192 +CONFIG_APP2_MAIN_PRIORITY=180 + +# +# Runtime Environment +# +# CONFIG_ENABLE_IOTJS is not set + +# +# Device Management +# +# CONFIG_DM is not set + +# +# Binary manager +# +# CONFIG_BINARY_MANAGER is not set + +# +# Task Monitor +# +# CONFIG_TASK_MONITOR is not set + +# +# Task manager +# +# CONFIG_TASK_MANAGER is not set + +# +# Event Loop Framework +# +# CONFIG_EVENTLOOP is not set + +# +# Messaging Framework +# +# CONFIG_MESSAGING_IPC is not set + +# +# Preference Support +# +# CONFIG_PREFERENCE is not set + +# +# Things Management +# + +# +# IoTBus Framework +# +CONFIG_IOTBUS=y +CONFIG_IOTBUS_GPIO=y +CONFIG_IOTBUS_I2C=y +# CONFIG_IOTBUS_SPI is not set +CONFIG_IOTBUS_UART=y + +# +# Security Framework +# +# CONFIG_SECURITY_API is not set diff --git a/build/configs/rtl8721csm/audio/libsupc++.a b/build/configs/rtl8721csm/audio/libsupc++.a new file mode 100755 index 0000000000..31f13b7844 Binary files /dev/null and b/build/configs/rtl8721csm/audio/libsupc++.a differ diff --git a/build/configs/rtl8721csm/hello/defconfig b/build/configs/rtl8721csm/hello/defconfig index a150774def..b9852578e9 100644 --- a/build/configs/rtl8721csm/hello/defconfig +++ b/build/configs/rtl8721csm/hello/defconfig @@ -24,6 +24,7 @@ CONFIG_BUILD_FLAT=y # CONFIG_APP_BINARY_SEPARATION is not set # CONFIG_BUILD_2PASS is not set CONFIG_BOARD_BUILD_DATE="200204" +# CONFIG_BINARY_SIGNING is not set # # Binary Output Formats @@ -128,6 +129,13 @@ CONFIG_RTL8721D_UART0=y CONFIG_RTL8721D_UART1=y CONFIG_RTL8721D_UART2=y CONFIG_RTL8721D_SERIAL_FIFO=y +CONFIG_AMEBAD_I2S=y +# CONFIG_AMEBAD_I2S_RX is not set +CONFIG_AMEBAD_I2S_TX=y +# CONFIG_AMEBAD_I2C_DYNTIMEO is not set +CONFIG_AMEBAD_I2CTIMEOSEC=0 +CONFIG_AMEBAD_I2CTIMEOMS=500 +CONFIG_AMEBAD_I2CTIMEOTICKS=500 # # Realtek RTL8721D WIFI Support @@ -279,6 +287,7 @@ CONFIG_HW_RSA_VERIFICATION=y CONFIG_HW_ECDSA_VERIFICATION=y CONFIG_HW_RSA_ENC=y CONFIG_HW_SE_STORAGE=y +# CONFIG_HW_AES_ENC is not set CONFIG_SE_SECURE_CONTEXT_SIZE=4096 # @@ -410,7 +419,14 @@ CONFIG_DEV_ZERO=y # CONFIG_ARCH_HAVE_PWM_MULTICHAN is not set # CONFIG_PWM is not set CONFIG_ARCH_HAVE_I2CRESET=y -# CONFIG_I2C is not set +CONFIG_I2C=y +# CONFIG_I2C_SLAVE is not set +CONFIG_I2C_USERIO=y +CONFIG_I2C_TRANSFER=y +CONFIG_I2C_POLLED=y +# CONFIG_I2C_TRACE is not set +# CONFIG_I2C_RESET is not set +# CONFIG_I2C_WRITEREAD is not set CONFIG_SPI=y CONFIG_SPI_USERIO=y # CONFIG_SPI_OWNBUS is not set @@ -418,8 +434,18 @@ CONFIG_SPI_EXCHANGE=y CONFIG_SPI_CMDDATA=y # CONFIG_SPI_BITBANG is not set CONFIG_GPIO=y -# CONFIG_I2S is not set -# CONFIG_AUDIO_DEVICES is not set +CONFIG_I2S=y +CONFIG_AUDIO_DEVICES=y +CONFIG_AUDIO_MAX_INPUT_CARD_NUM=2 +CONFIG_AUDIO_MAX_OUTPUT_CARD_NUM=2 +CONFIG_AUDIO_MAX_DEVICE_NUM=3 +# CONFIG_AUDIO_PROCESSING_FEATURES is not set +# CONFIG_AUDIO_I2SCHAR is not set +# CONFIG_AUDIO_ALC5658 is not set +# CONFIG_AUDIO_NULL is not set +# CONFIG_AUDIO_CX20921 is not set +# CONFIG_AUDIO_UB6470 is not set +# CONFIG_AUDIO_TAS5749 is not set # CONFIG_DRIVERS_VIDEO is not set # @@ -431,6 +457,7 @@ CONFIG_GPIO=y # CONFIG_WATCHDOG is not set CONFIG_TIMER=y # CONFIG_MMINFO is not set +# CONFIG_PRODCONFIG is not set # CONFIG_ANALOG is not set # CONFIG_DRIVERS_OS_API_TEST is not set # CONFIG_NETDEVICES is not set @@ -567,6 +594,7 @@ CONFIG_RTK_BLE=y # CONFIG_OTP is not set CONFIG_SECURITY_LINK_DRV=y CONFIG_SECURITY_LINK=y +# CONFIG_SECURITY_LINK_DRV_PROFILE is not set # # Networking Support @@ -606,6 +634,7 @@ CONFIG_NET_UDP_TTL=255 CONFIG_NET_TCP=y CONFIG_NET_TCP_TTL=255 CONFIG_NET_TCP_WND=58400 +# CONFIG_NET_WND_SCALE is not set CONFIG_NET_TCP_MAXRTX=12 CONFIG_NET_TCP_SYNMAXRTX=6 CONFIG_NET_TCP_QUEUE_OOSEQ=y @@ -738,14 +767,6 @@ CONFIG_NET_STATS=y # CONFIG_NET_LWIP_SLIP_INTERFACE is not set # CONFIG_NET_LWIP_PPP_SUPPORT is not set # CONFIG_NET_LWIP_SNMP is not set - -# -# Interface Name -# -CONFIG_NET_ETH_IFNAME="en" -CONFIG_NET_LOOP_IFNAME="lo" -CONFIG_NET_STA_IFNAME="wl" -CONFIG_NET_SOFTAP_IFNAME="sa" CONFIG_NET_LWIP_NETDB=y CONFIG_NET_DNS_TABLE_SIZE=4 CONFIG_NET_DNS_MAX_NAME_LENGTH=256 @@ -789,6 +810,7 @@ CONFIG_LWIP_DHCPS_SERVER_IP="192.168.47.1" CONFIG_LWIP_DHCPS_SERVER_NETMASK="255.255.255.0" CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 # CONFIG_LWIP_DHCPS_UNICAST is not set +# CONFIG_LWIP_DHCPS_ADDITIONAL_DNS is not set # CONFIG_NETUTILS_XMLRPC is not set # CONFIG_NETUTILS_NTPCLIENT is not set # CONFIG_NETUTILS_WEBSERVER is not set @@ -804,6 +826,7 @@ CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 CONFIG_NET_SECURITY_TLS=y CONFIG_TLS_WITH_HW_ACCEL=y CONFIG_TLS_MPI_MAX_SIZE=512 +# CONFIG_TLS_HAVE_NO_TIME_DATE is not set # # HW Options @@ -849,6 +872,7 @@ CONFIG_NETUTILS_STATS_DISPLAY_TOOL=y CONFIG_NET_NETMGR=y # CONFIG_NET_NETMGR_ZEROCOPY is not set # CONFIG_NET_TASK_BIND is not set +# CONFIG_NET_DEBUG_PORT is not set # # Network Device Operations @@ -862,11 +886,36 @@ CONFIG_NET_LOOPBACK_INTERFACE=y # # Audio Support # -# CONFIG_AUDIO is not set +CONFIG_AUDIO=y +# CONFIG_AUDIO_MULTI_SESSION is not set + +# +# Audio Buffer Configuration +# +# CONFIG_AUDIO_LARGE_BUFFERS is not set +CONFIG_AUDIO_NUM_BUFFERS=2 +CONFIG_AUDIO_BUFSIZE=2048 +# CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS is not set + +# +# Exclude Specific Audio Features +# +# CONFIG_AUDIO_EXCLUDE_GAIN is not set +# CONFIG_AUDIO_EXCLUDE_VOLUME is not set +# CONFIG_AUDIO_EXCLUDE_BALANCE is not set +CONFIG_AUDIO_EXCLUDE_EQUALIZER=y +# CONFIG_AUDIO_EXCLUDE_TONE is not set +# CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME is not set +# CONFIG_AUDIO_EXCLUDE_STOP is not set +# CONFIG_AUDIO_EXCLUDE_FFORWARD is not set +CONFIG_AUDIO_EXCLUDE_REWIND=y +# CONFIG_AUDIO_CUSTOM_DEV_PATH is not set # # Media Support # +# CONFIG_MEDIA is not set +# CONFIG_AUDIO_CODEC is not set # # File Systems @@ -950,6 +999,7 @@ CONFIG_MTD_SMART_WEAR_LEVEL=y # # CONFIG_SYSLOG is not set # CONFIG_SYSLOG_TIMESTAMP is not set +# CONFIG_GENERATE_FS_IMAGE is not set # # Database @@ -987,6 +1037,7 @@ CONFIG_SCHED_LPWORK=y CONFIG_SCHED_LPNTHREADS=1 CONFIG_SCHED_LPWORKPRIORITY=50 CONFIG_SCHED_LPWORKSTACKSIZE=2048 +# CONFIG_DEBUG_WORKQUEUE is not set # # Power Management @@ -1004,12 +1055,14 @@ CONFIG_DEBUG_WARN=y # # Subsystem Debug Options # +# CONFIG_DEBUG_AUDIO is not set # CONFIG_DEBUG_FS is not set # CONFIG_DEBUG_LIB is not set # CONFIG_DEBUG_MM is not set CONFIG_DEBUG_NET=y CONFIG_DEBUG_NET_ERROR=y CONFIG_DEBUG_NET_WARN=y +# CONFIG_DEBUG_BLE is not set # CONFIG_DEBUG_PM is not set # CONFIG_DEBUG_SCHED is not set # CONFIG_DEBUG_TASH is not set @@ -1033,6 +1086,7 @@ CONFIG_ARCH_HAVE_HEAPCHECK=y # CONFIG_DEBUG_ANALOG is not set # CONFIG_DEBUG_I2S is not set # CONFIG_DEBUG_SPI is not set +# CONFIG_DEBUG_TIMER is not set # # System Debug Options @@ -1140,6 +1194,7 @@ CONFIG_MEMSET_OPTSPEED=y CONFIG_NETUTILS_JSON=y # CONFIG_LIBTUV is not set # CONFIG_LWM2M_WAKAAMA is not set +# CONFIG_WIFI_MBOX is not set CONFIG_STRESS_TOOL=y # CONFIG_VOICE_SOFTWARE_EPD is not set # CONFIG_EXTERNAL_VEC is not set @@ -1170,7 +1225,6 @@ CONFIG_ENTRY_HELLO=y # CONFIG_ENTRY_WIFIMANAGER_TEST is not set CONFIG_USER_ENTRYPOINT="hello_main" CONFIG_BUILTIN_APPS=y -CONFIG_EXAMPLES_WIFIMANAGER_AP_LIST_ITEMS_COUNT=10 # # Examples @@ -1184,7 +1238,7 @@ CONFIG_EXAMPLES_BLE_RMC=y # CONFIG_EXAMPLES_EEPROM_TEST is not set # CONFIG_EXAMPLES_EVENTLOOP is not set # CONFIG_EXAMPLES_FOTA_SAMPLE is not set -# CONFIG_FILESYSTEM_HELPER_ENABLE is not set +# CONFIG_FILESYSTEM_TEST is not set # CONFIG_EXAMPLES_HEAVY_SIGNAL_MESSAGE_TEST is not set CONFIG_EXAMPLES_HELLO=y # CONFIG_EXAMPLES_IOTBUS_TEST is not set @@ -1201,27 +1255,36 @@ CONFIG_EXAMPLES_HELLO=y # CONFIG_EXAMPLES_HEAP_PERFORMANCE_TEST is not set # CONFIG_EXAMPLES_SYSCALL_PERFORMANCE is not set # CONFIG_EXAMPLES_TLS_BENCHMARK is not set +# CONFIG_EXAMPLES_TLS_HANDSHAKE is not set # CONFIG_EXAMPLES_TLS_SECLINK is not set -# CONFIG_EXAMPLES_PROC_TEST is not set # CONFIG_EXAMPLES_RDP is not set # CONFIG_EXAMPLES_RSSI_REPORT is not set -# CONFIG_EXAMPLES_SECURITY_API_TEST is not set +# CONFIG_EXAMPLES_SECURITY_HAL_TEST is not set # CONFIG_EXAMPLES_MBEDTLS_SELF_TEST is not set +# CONFIG_EXAMPLES_SECLINK_TEST is not set +# CONFIG_EXAMPLES_SECURITY_API_TEST is not set +# CONFIG_EXAMPLES_SECURITY_SEE_TEST is not set +# CONFIG_EXAMPLES_SECLINK_TOOL is not set # CONFIG_EXAMPLES_SELECT_TEST is not set # CONFIG_EXAMPLES_SENSORBOARD is not set # CONFIG_EXAMPLES_SETJMP_TEST is not set # CONFIG_EXAMPLES_SIMPLE_FILE_TRANSFER is not set +# CONFIG_EXAMPLES_SMARTFS_BUF_OPTIMIZATION is not set +# CONFIG_EXAMPLES_FS_PERFORMANCE is not set # CONFIG_EXAMPLES_SMART is not set # CONFIG_EXAMPLES_SMART_TEST is not set # CONFIG_EXAMPLES_SMARTFS_POWERCUT is not set # CONFIG_EXAMPLES_ST_THINGS is not set -# CONFIG_EXAMPLES_TAHI is not set # CONFIG_EXAMPLES_TESTCASE is not set +# CONFIG_EXAMPLES_TIMER is not set # CONFIG_EXAMPLES_TLS_CLIENT is not set # CONFIG_EXAMPLES_TLS_SELFTEST is not set # CONFIG_EXAMPLES_TLS_SERVER is not set +# CONFIG_EXAMPLES_WAVE_GEN is not set +# CONFIG_EXAMPLES_TAHI is not set CONFIG_EXAMPLES_WIFIMANAGER_TEST=y CONFIG_WIFIMANAGER_TEST_TRIAL=5 +CONFIG_EXAMPLES_WIFIMANAGER_AP_LIST_ITEMS_COUNT=10 # # Platform-specific Support @@ -1248,6 +1311,13 @@ CONFIG_TASH_CMDTASK_PRIORITY=100 # CONFIG_SYSTEM_CUTERM is not set # CONFIG_SYSTEM_FLASH_READ is not set # CONFIG_SYSTEM_FOTA_HAL is not set +CONFIG_SYSTEM_I2CTOOL=y +CONFIG_I2CTOOL_MINBUS=0 +CONFIG_I2CTOOL_MAXBUS=3 +CONFIG_I2CTOOL_MINADDR=0x03 +CONFIG_I2CTOOL_MAXADDR=0x77 +CONFIG_I2CTOOL_MAXREGADDR=0xff +CONFIG_I2CTOOL_DEFFREQ=400000 # CONFIG_SYSTEM_INIFILE is not set CONFIG_SYSTEM_PREAPP_INIT=y CONFIG_SYSTEM_PREAPP_STACKSIZE=2048 @@ -1285,6 +1355,22 @@ CONFIG_ENABLE_UPTIME=y # # Loadable apps Configuration # +CONFIG_APP1_INFO=y +CONFIG_APP1_BIN_NAME="app1" +CONFIG_APP1_BIN_TYPE="ELF" +CONFIG_APP1_BIN_VER=190412 +CONFIG_APP1_BIN_DYN_RAMSIZE=512000 +CONFIG_APP1_BIN_LOADING_PRIORITY="HIGH" +CONFIG_APP1_MAIN_STACKSIZE=4096 +CONFIG_APP1_MAIN_PRIORITY=220 +CONFIG_APP2_INFO=y +CONFIG_APP2_BIN_NAME="app2" +CONFIG_APP2_BIN_TYPE="ELF" +CONFIG_APP2_BIN_VER=190412 +CONFIG_APP2_BIN_DYN_RAMSIZE=512000 +CONFIG_APP2_BIN_LOADING_PRIORITY="HIGH" +CONFIG_APP2_MAIN_STACKSIZE=8192 +CONFIG_APP2_MAIN_PRIORITY=180 # # Runtime Environment @@ -1335,6 +1421,7 @@ CONFIG_ENABLE_UPTIME=y # CONFIG_IOTBUS=y CONFIG_IOTBUS_GPIO=y +CONFIG_IOTBUS_I2C=y # CONFIG_IOTBUS_SPI is not set CONFIG_IOTBUS_UART=y diff --git a/framework/src/media/MediaWorker.cpp b/framework/src/media/MediaWorker.cpp index a73e0a3613..c4040397c6 100644 --- a/framework/src/media/MediaWorker.cpp +++ b/framework/src/media/MediaWorker.cpp @@ -94,13 +94,13 @@ bool MediaWorker::processLoop() void *MediaWorker::mediaLooper(void *arg) { auto worker = static_cast(arg); - medvdbg("MediaWorker : mediaLooper\n"); +// medvdbg("MediaWorker : mediaLooper\n"); while (worker->mIsRunning) { while (worker->processLoop() && worker->mWorkerQueue.isEmpty()); std::function run = worker->deQueue(); - medvdbg("MediaWorker : deQueue\n"); +// medvdbg("MediaWorker : deQueue\n"); if (run != nullptr) { run(); } diff --git a/framework/src/media/audio/audio_manager.c b/framework/src/media/audio/audio_manager.c index 4ef8e2f21a..09877b2bf9 100644 --- a/framework/src/media/audio/audio_manager.c +++ b/framework/src/media/audio/audio_manager.c @@ -622,6 +622,7 @@ audio_manager_result_t audio_manager_init(void) am_initialized = 1; + /* for (card_id = 0; card_id < CONFIG_AUDIO_MAX_INPUT_CARD_NUM; card_id++) { pthread_mutex_init(&(g_audio_in_cards[card_id].card_mutex), NULL); } @@ -630,6 +631,7 @@ audio_manager_result_t audio_manager_init(void) meddbg("find card failed result : %d\n", ret); return ret; } + */ for (card_id = 0; card_id < CONFIG_AUDIO_MAX_OUTPUT_CARD_NUM; card_id++) { pthread_mutex_init(&(g_audio_out_cards[card_id].card_mutex), NULL); diff --git a/os/arch/arm/src/amebad/Kconfig b/os/arch/arm/src/amebad/Kconfig index 619cb9ad14..0ee447abc4 100644 --- a/os/arch/arm/src/amebad/Kconfig +++ b/os/arch/arm/src/amebad/Kconfig @@ -51,6 +51,49 @@ config RTL8721D_SERIAL_FIFO bool "UART SERIAL FIFO" default n +config AMEBAD_I2S + bool "Enable Amebad I2S" + default n + +if AMEBAD_I2S +config AMEBAD_I2S_RX + bool "Enable I2S RX" + default n + +config AMEBAD_I2S_TX + bool "Enable I2S TX" + default n +endif + +config AMEBAD_I2C_DYNTIMEO + bool "[Amebad I2C]Use dynamic timeouts" + default n + +config AMEBAD_I2C_DYNTIMEO_USECPERBYTE + int "[Amebad I2C]Timeout Microseconds per Byte" + default 500 + depends on AMEBAD_I2C_DYNTIMEO + +config AMEBAD_I2C_DYNTIMEO_STARTSTOP + int "[Amebad I2C]Timeout for Start/Stop (Milliseconds)" + default 1000 + depends on AMEBAD_I2C_DYNTIMEO + +config AMEBAD_I2CTIMEOSEC + int "[Amebad I2C]Timeout seconds" + default 0 + depends on !AMEBAD_I2C_DYNTIMEO + +config AMEBAD_I2CTIMEOMS + int "[Amebad I2C]Timeout Milliseconds" + default 500 + depends on !AMEBAD_I2C_DYNTIMEO + +config AMEBAD_I2CTIMEOTICKS + int "[Amebad I2C]Timeout for Done and Stop (ticks)" + default 500 + depends on !AMEBAD_I2C_DYNTIMEO + endmenu menu "Realtek RTL8721D WIFI Support" diff --git a/os/arch/arm/src/amebad/amebad_i2c.c b/os/arch/arm/src/amebad/amebad_i2c.c index 5affe1ebdf..7432b4c152 100644 --- a/os/arch/arm/src/amebad/amebad_i2c.c +++ b/os/arch/arm/src/amebad/amebad_i2c.c @@ -303,8 +303,8 @@ static const struct amebad_i2c_config_s amebad_i2c1_config = { //.busy_idle = CONFIG_I2C1_BUSYIDLE, //.filtscl = CONFIG_I2C1_FILTSCL, //.filtsda = CONFIG_I2C1_FILTSDA, - .scl_pin = PA_25, - .sda_pin = PA_26, + .scl_pin = PB_5, + .sda_pin = PB_6, #ifndef CONFIG_I2C_SLAVE .mode = AMEBAD_I2C_MASTER, #else @@ -765,7 +765,7 @@ static int amebad_i2c_isr_process(struct amebad_i2c_priv_s *priv) if ((w_msgv->flags & I2C_M_READ) == 0) { - i2cinfo("i2c writing"); + lldbg("i2c writing"); #ifdef CONFIG_I2C_SLAVE i2c_slave_read(priv->i2c_object, &read_restart, 1); @@ -778,7 +778,7 @@ static int amebad_i2c_isr_process(struct amebad_i2c_priv_s *priv) } if ((r_msgv->flags & I2C_M_READ) != 0) { - i2cinfo("i2c reading"); + lldbg("i2c reading"); #ifdef CONFIG_I2C_SLAVE ret = i2c_slave_read(priv->i2c_object, r_msgv->buffer, r_msgv->length); @@ -792,7 +792,6 @@ static int amebad_i2c_isr_process(struct amebad_i2c_priv_s *priv) if ((w_msgv->flags & I2C_M_READ) == 0) { - i2cinfo("i2c writing"); #ifdef CONFIG_I2C_SLAVE i2c_slave_set_for_rd_req(priv->i2c_object, 1); @@ -800,16 +799,26 @@ static int amebad_i2c_isr_process(struct amebad_i2c_priv_s *priv) #else ret = rtk_i2c_write(priv->i2c_object, priv->msgv->addr, w_msgv->buffer, w_msgv->length, 1); #endif + //lldbg("i2c writing - priv->msgv->addr = 0x%x, w_msgv->buffer = 0x%x 0x%x, w_msgv->length = 0x%x\n", priv->msgv->addr, w_msgv->buffer[0], w_msgv->buffer[1], w_msgv->length); + if(ret != w_msgv->length) { + lldbg("write length is not successful - ret = %d, w_msgv->length = %d\n", ret, w_msgv->length); + ret = -1; + } } else if ((w_msgv->flags & I2C_M_READ) != 0) { - i2cinfo("i2c reading"); + #ifdef CONFIG_I2C_SLAVE ret = i2c_slave_read(priv->i2c_object, w_msgv->buffer, w_msgv->length); #else ret = rtk_i2c_read(priv->i2c_object, priv->msgv->addr, w_msgv->buffer, w_msgv->length, 1); #endif + //lldbg("i2c reading - priv->msgv->addr = 0x%x, w_msgv->buffer = 0x%x\n", priv->msgv->addr, w_msgv->buffer[0]); + if(ret != w_msgv->length) { + lldbg("read length is not successful - ret = %d, w_msgv->length = %d\n", ret, w_msgv->length); + ret = -1; + } } #endif /* #ifdef CONFIG_I2C_WRITEREAD */ diff --git a/os/arch/arm/src/amebad/amebad_i2s.c b/os/arch/arm/src/amebad/amebad_i2s.c index 264f09d817..51a4e89b9a 100644 --- a/os/arch/arm/src/amebad/amebad_i2s.c +++ b/os/arch/arm/src/amebad/amebad_i2s.c @@ -56,6 +56,7 @@ //#ifndef CONFIG_SCHED_WORKQUEUE //#error Work queue support is required (CONFIG_SCHED_WORKQUEUE) //#endif +#define __16_BIT_PADDING__ #ifdef CONFIG_AUDIO //#ifndef CONFIG_AUDIO @@ -116,10 +117,13 @@ #define OVER_SAMPLE_RATE (384U) -#define I2S_DMA_PAGE_SIZE 768 // 2 ~ 4096 -#define I2S_DMA_PAGE_NUM 4 // Vaild number is 2~4 +#define I2S_DMA_PAGE_SIZE 1024 /* 4 ~ 16384, set to a factor of APB size */ +#define I2S_DMA_PAGE_NUM 4 /* Vaild number is 2~4 */ /* I2S buffer container */ +#ifdef __16_BIT_PADDING__ +uint8_t audio_buf[I2S_DMA_PAGE_SIZE]; +#endif struct amebad_buffer_s { struct amebad_buffer_s *flink; /* Supports a singly linked list */ @@ -164,7 +168,7 @@ struct amebad_i2s_s { uint32_t i2s_sd_rx_pin; uint32_t i2s_mck_pin; - uint8_t* i2s_tx_buf; + uint8_t i2s_tx_buf[I2S_DMA_PAGE_NUM * I2S_DMA_PAGE_SIZE]; /* Allocate buffer for use in TX */ uint8_t* i2s_rx_buf; i2s_irq_handler rx_isr_handler; @@ -183,6 +187,7 @@ struct amebad_i2s_s { int sample_rate; /*!< I2S sample rate */ int channel_num; /*!< Number of channels */ int bits_per_sample; /*!< Bits per sample */ + struct ap_buffer_s *apb_tx; /* Pointer to application TX audio buffer to track current TX byte count */ #if defined(I2S_HAVE_RX) && (0 < I2S_HAVE_RX) struct amebad_transport_s rx; /* RX transport state */ @@ -281,10 +286,10 @@ static int i2s_err_cb_register(struct i2s_dev_s *dev, i2s_err_cb_t cb, void *arg static const i2s_config_t i2s_default_config = { - .sample_rate = CONFIG_AMEBAD_I2S_SAMPLERATE, - .bits_per_sample = CONFIG_AMEBAD_I2S_DATALEN, + .sample_rate = I2S_SR_48KHZ, + .bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, - .channel_num = CH_MONO, + .channel_num = CH_STEREO, #if defined(I2S_HAVE_TX) && (0 < I2S_HAVE_TX) .direction = I2S_DIR_TX, #endif @@ -354,7 +359,7 @@ static void i2s_txdma_timeout(int argc, uint32_t arg) { struct amebad_i2s_s *priv = (struct amebad_i2s_s *)arg; DEBUGASSERT(priv != NULL); - + lldbg("************** timeout has hapenned **************\n"); /* Then schedule completion of the transfer to occur on the worker thread. * Set the result with -ETIMEDOUT. */ @@ -363,26 +368,75 @@ static void i2s_txdma_timeout(int argc, uint32_t arg) static int i2s_txdma_prep(struct amebad_i2s_s *priv, struct amebad_buffer_s *bfcontainer) { - struct ap_buffer_s *apb; + // struct ap_buffer_s *apb; - apb = bfcontainer->apb; + // apb = bfcontainer->apb; - priv->i2s_tx_buf = (void *)&(apb->samp[apb->curbyte]); - i2s_set_dma_buffer(&priv->i2s_object, (char*)priv->i2s_tx_buf, NULL, I2S_DMA_PAGE_NUM, I2S_DMA_PAGE_SIZE); + // priv->i2s_tx_buf = (void *)&(apb->samp[apb->curbyte]); + // i2s_set_dma_buffer(&priv->i2s_object, (char*)priv->i2s_tx_buf, NULL, I2S_DMA_PAGE_NUM, I2S_DMA_PAGE_SIZE); return 0; } +static int amebad_i2s_tx(struct amebad_i2s_s *priv, struct amebad_buffer_s *bfcontainer) +{ + int ret; + int* ptx_buf; + int tx_size; + + tx_size = I2S_DMA_PAGE_SIZE; /* Track current byte size to increment by */ + struct ap_buffer_s *apb; + if (NULL != bfcontainer && NULL != bfcontainer->apb) { + + apb = bfcontainer->apb; + /* Add the container to the list of active DMAs */ + sq_addlast((sq_entry_t *)bfcontainer, &priv->tx.act); + + i2s_set_direction(&priv->i2s_object, I2S_DIR_TX); + priv->apb_tx = apb; /* Reference current TX apb in our I2S struct */ + /* Start sending first page, after that the txdma callback will be called in the tx irq handler */ + ptx_buf = i2s_get_tx_page(&priv->i2s_object); +#ifdef __16_BIT_PADDING__ + memset(audio_buf, 0, sizeof(audio_buf)); + if ((apb->nbytes - apb->curbyte) <= (tx_size/2)) { /* Check if remaining bytes to TX is less than the maximum length we can pad */ + tx_size = apb->nbytes - apb->curbyte; /* Update tx_size to the remaining bytes left to TX */ + for (int j=0; jsamp[apb->curbyte+(j*2)], 2); + } + memset(ptx_buf, 0, I2S_DMA_PAGE_SIZE); /* Clear ptx_buf to prevent sending old data since we are sending less than I2S_DMA_PAGE_SIZE */ + memcpy((void*)ptx_buf, (void*)audio_buf, tx_size*2); + apb->curbyte += tx_size; /* Remaining bytes to TX can fit into buffer, increment current byte by the remaining tx_size */ + } + else { + for (int j=0; j<(I2S_DMA_PAGE_SIZE/4); j++) { + memcpy(audio_buf+(2+(j*4)), &apb->samp[apb->curbyte+(j*2)], 2); + } + memcpy((void*)ptx_buf, (void*)audio_buf, I2S_DMA_PAGE_SIZE); + apb->curbyte += tx_size/2; /* We padded half of I2S_DMA_PAGE_SIZE worth of data */ + } +#else + if ((apb->nbytes - apb->curbyte) <= tx_size) { + tx_size = apb->nbytes - apb->curbyte; + memset(ptx_buf, 0, I2S_DMA_PAGE_SIZE); /* Clear ptx_buf to prevent sending old data since we are sending less than I2S_DMA_PAGE_SIZE */ + memcpy((void*)ptx_buf, (void*)&apb->samp[apb->curbyte], tx_size); + } + else { + memcpy((void*)ptx_buf, (void*)&apb->samp[apb->curbyte], I2S_DMA_PAGE_SIZE); + } + apb->curbyte += tx_size; /* No padding, ptx_buf is big enough to fill the whole tx_size */ +#endif + i2s_send_page(&priv->i2s_object, (uint32_t*)ptx_buf); + } + return; +} + static int i2s_tx_start(struct amebad_i2s_s *priv) { struct amebad_buffer_s *bfcontainer = NULL; int ret; irqstate_t flags; - int* ptx_buf; - int pg_idx; struct ap_buffer_s *apb; - apb = bfcontainer->apb; /* Check if the DMA is IDLE */ if (!sq_empty(&priv->tx.act)) { @@ -400,24 +454,9 @@ static int i2s_tx_start(struct amebad_i2s_s *priv) /* Remove the pending TX transfer at the head of the TX pending queue. */ bfcontainer = (struct amebad_buffer_s *)sq_remfirst(&priv->tx.pend); - if (NULL != bfcontainer && NULL != bfcontainer->apb) { - - /* Add the container to the list of active DMAs */ - sq_addlast((sq_entry_t *)bfcontainer, &priv->tx.act); - - i2s_set_direction(&priv->i2s_object, I2S_DIR_TX); - - /* send I2S_DMA_PAGE_NUM page, after that the txdma callback will be called in the tx irq handler */ - for (pg_idx = 0; pg_idx < I2S_DMA_PAGE_NUM; ++pg_idx) { - - ptx_buf = i2s_get_tx_page(&priv->i2s_object); - i2s_send_page(&priv->i2s_object, (uint32_t*)ptx_buf); - apb->curbyte += (I2S_DMA_PAGE_SIZE/sizeof(short)); - if(apb->curbyte >= apb->nmaxbytes*(priv->i2s_object.channel_num == CH_MONO?1:2)) - apb->curbyte = 0; - } - } + /* Start first transfer */ + amebad_i2s_tx(priv, bfcontainer); irqrestore(flags); /* Start a watchdog to catch DMA timeouts */ @@ -468,7 +507,6 @@ static void i2s_tx_worker(void *arg) flags = irqsave(); bfcontainer = (struct amebad_buffer_s *)sq_remfirst(&priv->tx.done); irqrestore(flags); - /* Perform the TX transfer done callback */ DEBUGASSERT(bfcontainer && bfcontainer->callback); @@ -521,9 +559,8 @@ static void i2s_tx_schedule(struct amebad_i2s_s *priv, int result) /* Remove the next buffer container from the tx.pend list */ bfcontainer = (struct amebad_buffer_s *)sq_remfirst(&priv->tx.pend); - /* Add the completed buffer container to the tail of the tx.act queue */ - sq_addlast((sq_entry_t *) bfcontainer, &priv->tx.act); - + /* Start next transfer */ + amebad_i2s_tx(priv, bfcontainer); } /* If the worker has completed running, then reschedule the working thread. @@ -564,8 +601,8 @@ static uint32_t i2s_txdatawidth(struct i2s_dev_s *dev, int bits) struct amebad_i2s_s *priv = (struct amebad_i2s_s *)dev; /* Support 16, 24, 32 bits */ - DEBUGASSERT(priv && (bits == I2S_BITS_PER_SAMPLE_16BIT / - || bits == I2S_BITS_PER_SAMPLE_32BIT / + DEBUGASSERT(priv && (bits == I2S_BITS_PER_SAMPLE_16BIT \ + || bits == I2S_BITS_PER_SAMPLE_32BIT \ || bits == I2S_BITS_PER_SAMPLE_24BIT)); priv->bits_per_sample = bits; @@ -617,10 +654,8 @@ static int i2s_send(struct i2s_dev_s *dev, struct ap_buffer_s *apb, i2s_callback DEBUGASSERT(priv && apb); - i2sinfo("[I2S TX] apb=%p nbytes=%d arg=%p samp=%p timeout=%d\n", apb, apb->nbytes - apb->curbyte, apb->samp, arg, timeout); - + // i2sinfo("[I2S TX] apb=%p nbytes=%d samp=%p arg=%p timeout=%d\n", apb, apb->nbytes - apb->curbyte, apb->samp, arg, timeout); i2s_dump_buffer("Sending", &apb->samp[apb->curbyte], apb->nbytes - apb->curbyte); - #if defined(I2S_HAVE_TX) && (0 < I2S_HAVE_TX) struct amebad_buffer_s *bfcontainer; irqstate_t flags; @@ -649,9 +684,6 @@ static int i2s_send(struct i2s_dev_s *dev, struct ap_buffer_s *apb, i2s_callback bfcontainer->apb = apb; bfcontainer->result = -EBUSY; - /* Prepare DMA microcode */ - i2s_txdma_prep(priv, bfcontainer); - flags = irqsave(); sq_addlast((sq_entry_t *) bfcontainer, &priv->tx.pend); irqrestore(flags); @@ -679,10 +711,49 @@ static int i2s_send(struct i2s_dev_s *dev, struct ap_buffer_s *apb, i2s_callback void i2s_transfer_tx_handleirq(void *data, char *pbuf) { + /* This handler is called after every completion of i2s_send_page() */ struct amebad_i2s_s *priv = (struct amebad_i2s_s *)data; + int tx_size; - int result = OK; - i2s_txdma_callback(priv, result); + tx_size = I2S_DMA_PAGE_SIZE; /* Track current byte size to increment by */ + if ((priv->apb_tx->nbytes - priv->apb_tx->curbyte) <= 0) { /* Condition to stop sending if all data in the buffer has been sent */ + int result = OK; + i2s_txdma_callback(priv, result); + } + else { + int *ptx_buf; + ptx_buf = i2s_get_tx_page(&priv->i2s_object); +#ifdef __16_BIT_PADDING__ + memset(audio_buf, 0, sizeof(audio_buf)); + if ((priv->apb_tx->nbytes - priv->apb_tx->curbyte) <= (tx_size/2)) { /* Check if remaining bytes to TX is less than the maximum length we can pad */ + tx_size = priv->apb_tx->nbytes - priv->apb_tx->curbyte; /* Update tx_size to the remaining bytes left to TX */ + for (int j=0; japb_tx->samp[priv->apb_tx->curbyte+(j*2)], 2); + } + memset(ptx_buf, 0, I2S_DMA_PAGE_SIZE); /* Clear ptx_buf to prevent sending old data since we are sending less than I2S_DMA_PAGE_SIZE */ + memcpy((void*)ptx_buf, (void*)audio_buf, tx_size*2); + priv->apb_tx->curbyte += tx_size; /* Remaining bytes to TX can fit into buffer, increment current byte by the remaining tx_size */ + } + else { + for (int j=0; j<(I2S_DMA_PAGE_SIZE/4); j++) { + memcpy(audio_buf+(2+(j*4)), &priv->apb_tx->samp[priv->apb_tx->curbyte+(j*2)], 2); + } + memcpy((void*)ptx_buf, (void*)audio_buf, I2S_DMA_PAGE_SIZE); + priv->apb_tx->curbyte += tx_size/2; /* We padded half of I2S_DMA_PAGE_SIZE worth of data */ + } +#else + if ((priv->apb_tx->nbytes - priv->apb_tx->curbyte) <= tx_size) { + tx_size = priv->apb_tx->nbytes - priv->apb_tx->curbyte; + memset(ptx_buf, 0, I2S_DMA_PAGE_SIZE); /* Clear ptx_buf to prevent sending old data since we are sending less than I2S_DMA_PAGE_SIZE */ + memcpy((void*)ptx_buf, (void*)&priv->apb_tx->samp[priv->apb_tx->curbyte], tx_size); + } + else { + memcpy((void*)ptx_buf, (void*)&priv->apb_tx->samp[priv->apb_tx->curbyte], I2S_DMA_PAGE_SIZE); + } + priv->apb_tx->curbyte += tx_size; /* No padding, ptx_buf is big enough to fill the whole tx_size */ +#endif + i2s_send_page(&priv->i2s_object, (uint32_t*)ptx_buf); + } } @@ -744,7 +815,7 @@ static int i2s_rxdma_prep(struct amebad_i2s_s *priv, struct amebad_buffer_s *bfc static int i2s_rx_start(struct amebad_i2s_s *priv) { - struct amebad_buffer_s *bfcontainer; + struct amebad_buffer_s *bfcontainer = NULL; int ret; irqstate_t flags; @@ -931,8 +1002,8 @@ static uint32_t i2s_rxdatawidth(struct i2s_dev_s *dev, int bits) struct amebad_i2s_s *priv = (struct amebad_i2s_s *)dev; /* Support 16, 24, 32 bits */ - DEBUGASSERT(priv && (bits == I2S_BITS_PER_SAMPLE_16BIT / - || bits == I2S_BITS_PER_SAMPLE_32BIT / + DEBUGASSERT(priv && (bits == I2S_BITS_PER_SAMPLE_16BIT \ + || bits == I2S_BITS_PER_SAMPLE_32BIT \ || bits == I2S_BITS_PER_SAMPLE_24BIT)); priv->bits_per_sample = bits; @@ -1056,7 +1127,7 @@ void i2s_transfer_rx_handleirq(void *data, char *pbuf) int result = OK; - i2s_rxdma_callback(priv, result); + //i2s_rxdma_callback(priv, result); } #if defined(I2S_HAVE_RX) && (0 < I2S_HAVE_RX) @@ -1630,11 +1701,11 @@ static uint32_t i2s_samplerate(struct i2s_dev_s *dev, uint32_t rate) static void amebad_i2s_initpins(struct amebad_i2s_s *priv) { - priv->i2s_sclk_pin = PA_2; - priv->i2s_ws_pin = PA_4; + priv->i2s_sclk_pin = PB_29; + priv->i2s_ws_pin = PB_31; priv->i2s_sd_tx_pin = PB_26; - priv->i2s_sd_rx_pin = PA_0; - priv->i2s_mck_pin = PA_12; + priv->i2s_sd_rx_pin = PB_22; + priv->i2s_mck_pin = PB_23; } /**************************************************************************** @@ -1775,7 +1846,7 @@ struct i2s_dev_s *amebad_i2s_initialize(uint16_t port) i2s_init(&priv->i2s_object, priv->i2s_sclk_pin, priv->i2s_ws_pin, priv->i2s_sd_tx_pin, priv->i2s_sd_rx_pin, priv->i2s_mck_pin); /* Initialize buffering */ - //i2s_set_dma_buffer(&priv->i2s_object, priv->i2s_tx_buf, priv->i2s_rx_buf, I2S_DMA_PAGE_NUM, I2S_DMA_PAGE_SIZE); + i2s_set_dma_buffer(&priv->i2s_object, (char*)priv->i2s_tx_buf, NULL, I2S_DMA_PAGE_NUM, I2S_DMA_PAGE_SIZE); /* Allocate DMA Buffer for TX */ /* configures IRQ */ priv->rx_isr_handler = (i2s_irq_handler)&i2s_transfer_rx_handleirq; diff --git a/os/arch/arm/src/amebad/amebad_lowerhalf.c b/os/arch/arm/src/amebad/amebad_lowerhalf.c index bbab249228..765603701e 100644 --- a/os/arch/arm/src/amebad/amebad_lowerhalf.c +++ b/os/arch/arm/src/amebad/amebad_lowerhalf.c @@ -123,6 +123,16 @@ static void amebad_gpio_set(FAR struct gpio_lowerhalf_s *lower, gpio_write(&priv->obj, value); } +int amebad_gpio_write(PinName pin, FAR unsigned int value) { + gpio_t p; + p.pin = pin; + gpio_write(&p, value); +} + +int amebad_PA0_set(FAR unsigned int value) { + return amebad_gpio_write(_PA_0, value); +} + /**************************************************************************** * Name: amebad_gpio_get * @@ -142,7 +152,6 @@ static int amebad_gpio_get(FAR struct gpio_lowerhalf_s *lower) return gpio_read(&priv->obj); } - static int amebad_gpio_setdir(FAR struct gpio_lowerhalf_s *lower, unsigned long arg) { @@ -258,6 +267,7 @@ FAR struct gpio_lowerhalf_s *amebad_gpio_lowerhalf(u32 pinname, u32 pinmode, u32 gpio_init(&lower->obj, pinname); gpio_dir(&lower->obj, pinmode); gpio_mode(&lower->obj, pinpull); + gpio_write(&lower->obj, 0); lower->pinmode =pinmode; lower->pinpull = pinpull; lower->ops = &amebad_gpio_ops; diff --git a/os/arch/arm/src/amebad/amebad_serial.c b/os/arch/arm/src/amebad/amebad_serial.c index c30ee942bb..bce7a83126 100644 --- a/os/arch/arm/src/amebad/amebad_serial.c +++ b/os/arch/arm/src/amebad/amebad_serial.c @@ -307,8 +307,8 @@ static struct rtl8721d_up_dev_s g_uart1priv = { #endif .baud = CONFIG_UART1_BAUD, .irq = RTL8721D_UARTLP_IRQ, - .tx = PA_12, - .rx = PA_13, + .tx = PB_1, + .rx = PB_2, .FlowControl = FlowControlNone, .txint_enable = false, .rxint_enable = false, diff --git a/os/arch/arm/src/amebad/amebad_spi.c b/os/arch/arm/src/amebad/amebad_spi.c index 3850d6465c..e07b4e3dbc 100644 --- a/os/arch/arm/src/amebad/amebad_spi.c +++ b/os/arch/arm/src/amebad/amebad_spi.c @@ -266,10 +266,10 @@ static struct amebad_spidev_s g_spi1dev = { .spi_object = {0}, .spi_idx = MBED_SPI1, - .spi_mosi = PB_4, - .spi_miso = PB_5, - .spi_sclk = PB_6, - .spi_cs = PB_7, + .spi_mosi = PA_12, + .spi_miso = PA_13, + .spi_sclk = PA_14, + .spi_cs = PA_15, .nbits = 8, .mode = SPIDEV_MODE0, .role = AMEBAD_SPI_MASTER diff --git a/os/arch/arm/src/common/up_initialize.c b/os/arch/arm/src/common/up_initialize.c index 092ec14893..227ceb0d6a 100644 --- a/os/arch/arm/src/common/up_initialize.c +++ b/os/arch/arm/src/common/up_initialize.c @@ -83,6 +83,8 @@ #include #endif +extern int rtl_ub6470_initialize(int minor); + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -324,5 +326,6 @@ void up_initialize(void) /* Initialize the L2 cache if present and selected */ up_l2ccinitialize(); + board_led_on(LED_IRQSENABLED); } diff --git a/os/board/rtl8721csm/Kconfig b/os/board/rtl8721csm/Kconfig index 88272a7f1e..c1a75558a7 100644 --- a/os/board/rtl8721csm/Kconfig +++ b/os/board/rtl8721csm/Kconfig @@ -14,7 +14,7 @@ config FLASH_START_ADDR config FLASH_SIZE int - default 8388608 + default 16777216 help A size of flash (in bytes). This is fixed value, so user doesn't need to change it. @@ -30,7 +30,7 @@ config AMEBAD_FLASH_BASE config AMEBAD_FLASH_CAPACITY hex "Size for user filesystem" - default 0x80000 + default 0x1000000 help Setting this vaule to configure flash size for user filesystem, such as smartfs, romfs. @@ -46,7 +46,6 @@ config AMEBAD_FLASH_BLOCK_SIZE default 4096 help Setting this vaule to configure erase unit size of esp32 SPI flash. - + endmenu endif - diff --git a/os/board/rtl8721csm/src/Make.defs b/os/board/rtl8721csm/src/Make.defs index f8328e635d..d9ef88231a 100644 --- a/os/board/rtl8721csm/src/Make.defs +++ b/os/board/rtl8721csm/src/Make.defs @@ -51,3 +51,4 @@ CSRCS += rtl8721csm_boot.c CSRCS += rtl8721csm_i2schar.c +CSRCS += rtl_ub6470.c diff --git a/os/board/rtl8721csm/src/component/common/mbed/targets/hal/rtl8721d/i2s_api.c b/os/board/rtl8721csm/src/component/common/mbed/targets/hal/rtl8721d/i2s_api.c index 1457f6892a..b089e4e994 100644 --- a/os/board/rtl8721csm/src/component/common/mbed/targets/hal/rtl8721d/i2s_api.c +++ b/os/board/rtl8721csm/src/component/common/mbed/targets/hal/rtl8721d/i2s_api.c @@ -134,7 +134,7 @@ void i2s_init(i2s_t *obj, PinName sck, PinName ws, PinName sd_tx, PinName sd_rx, Pinmux_Config(sck, PINMUX_FUNCTION_I2S); Pinmux_Config(ws, PINMUX_FUNCTION_I2S); Pinmux_Config(sd_tx, PINMUX_FUNCTION_I2S); - Pinmux_Config(sd_rx, PINMUX_FUNCTION_I2S); + //Pinmux_Config(sd_rx, PINMUX_FUNCTION_I2S); Pinmux_Config(mck, PINMUX_FUNCTION_I2S); next_tx_complete = 0; diff --git a/os/board/rtl8721csm/src/component/common/mbed/targets/hal/rtl8721d/spi_api.c b/os/board/rtl8721csm/src/component/common/mbed/targets/hal/rtl8721d/spi_api.c index add8858d98..8fb72e1b1d 100644 --- a/os/board/rtl8721csm/src/component/common/mbed/targets/hal/rtl8721d/spi_api.c +++ b/os/board/rtl8721csm/src/component/common/mbed/targets/hal/rtl8721d/spi_api.c @@ -440,7 +440,7 @@ void spi_init (spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName sse Pinmux_Config(mosi, PINMUX_FUNCTION_SPIM); Pinmux_Config(miso, PINMUX_FUNCTION_SPIM); Pinmux_Config(sclk, PINMUX_FUNCTION_SPIM); - Pinmux_Config(ssel, PINMUX_FUNCTION_SPIM); + //Pinmux_Config(ssel, PINMUX_FUNCTION_SPIM); SSI_InitStruct.SPI_Role=SSI_MASTER; ssi_adapter->Role = SSI_MASTER; diff --git a/os/board/rtl8721csm/src/rtl8721csm_boot.c b/os/board/rtl8721csm/src/rtl8721csm_boot.c index 69ca55afef..3639b467b3 100644 --- a/os/board/rtl8721csm/src/rtl8721csm_boot.c +++ b/os/board/rtl8721csm/src/rtl8721csm_boot.c @@ -171,17 +171,7 @@ void board_gpio_initialize(void) u32 pinpull; } pins[] = { { - PA_0, PIN_OUTPUT, PullNone - }, { PA_1, PIN_OUTPUT, PullNone - }, { - PA_2, PIN_OUTPUT, PullNone - }, { - PA_3, PIN_OUTPUT, PullNone - }, { - PB_5, PIN_OUTPUT, PullNone - }, { - PA_12, PIN_INPUT, PullDown }, /* {PA_6, PIN_OUTPUT, PullNone}, {PA_7, PIN_OUTPUT, PullNone}, @@ -340,6 +330,10 @@ void board_initialize(void) } } #endif +#ifdef CONFIG_AUDIO_UB6470 + rtl_ub6470_initialize(0); +#endif + #ifdef CONFIG_FTL_ENABLED app_ftl_init(); #endif diff --git a/os/board/rtl8721csm/src/rtl_ub6470.c b/os/board/rtl8721csm/src/rtl_ub6470.c new file mode 100644 index 0000000000..19b1233203 --- /dev/null +++ b/os/board/rtl8721csm/src/rtl_ub6470.c @@ -0,0 +1,266 @@ +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "amebad_i2s.h" + +#include "objects.h" +#include "PinNames.h" +#include "component/common/mbed/hal/gpio_api.h" + +extern FAR struct i2s_dev_s *amebad_i2s_initialize(uint16_t port); +extern int amebad_gpio_write(PinName pin, FAR unsigned int value); + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* i2c config */ +#define UB6470_I2C_PORT 0 +#define UB6470_I2C_FREQ 100000 +#define UB6470_I2C_ADDRLEN 7 + +#define UB6470_GPIO_A0_FAULT 9 //I2C_STRAP_PIN +#define UB6470_GPIO_A0_FAULT_VAL 1 //HIGH +#define UB6470_I2C_ADDR_H 0x1A +#define UB6470_I2C_ADDR_L 0x1A + +/* i2s config */ +#define UB6470_I2S_PORT 0 +#define UB6470_I2S_IS_MASTER 1 +#define UB6470_I2S_IS_OUTPUT 1 + +/*other pin config */ +#ifdef CONFIG_UB6470_RESET_GPIO +#define UB6470_GPIO_RESET_PIN CONFIG_UB6470_RESET_GPIO //active low +#else +#define UB6470_GPIO_RESET_PIN 12 /* active low */ +#endif +#define UB6470_GPIO_PDN 0 /* active low */ + +#define UB6470_AVAILABLE_MINOR_MIN 0 +#define UB6470_AVAILABLE_MINOR_MAX 25 + +#ifdef CONFIG_AUDIO_UB6470 + +extern struct i2s_dev_s *amebad_i2s_initialize(uint16_t port); + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct cy4390x_ub6470_audioinfo_s { + /* Standard MW8904 interface */ + struct ub6470_lower_s lower; + /* Extensions for the cy4390x board */ + ub6470_handler_t handler; + FAR void *arg; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ +static void ub6470_control_reset_pin(bool active); +static void ub6470_control_powerdown(bool powerdown); + +/**************************************************************************** + * Private Data + ****************************************************************************/ +static struct cy4390x_ub6470_audioinfo_s g_ub6470info = { + .lower = { + .i2c_config = { + .frequency = UB6470_I2C_FREQ, +#if (UB6470_GPIO_A0_FAULT_VAL) + .address = UB6470_I2C_ADDR_H, +#else + .address = UB6470_I2C_ADDR_L, +#endif + .addrlen = UB6470_I2C_ADDRLEN, + }, + }, +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +gpio_t gpio_pa0; + +static void ub6470_control_reset_pin(bool active) +{ + //The reset pins are shared with cx20921 and ub6470. the reset pin is controlled here //CONFIG_AUDIO_UB6470_CX20921_SHARED_RESET_PIN + if(active) + { + lldbg("reset low\n"); + //amebad_gpio_write(_PA_0, 0); + gpio_write(&gpio_pa0, 0); + for (int i = 0; i < 100000000; i++) { + int ans; + for (int j = 0; j <1000; j++) ans = j; + //if (i %10000000 == 0) lldbg("waiting after power off %d\n", ans); + } + //amebad_gpio_write(_PA_0, 1); + gpio_write(&gpio_pa0, 1); + //lldbg("power on\n"); + for (int i = 0; i < 100000000; i++) { + int ans; + for (int j = 0; j <1000; j++) ans = j; + //if (i %10000000 == 0) lldbg("waiting after power up %d\n", ans); + } + lldbg("reset high\n"); + } + else + { + audvdbg("exit hw reset\n"); + } +} + +static void ub6470_control_powerdown(bool enter_powerdown) +{ +#ifdef CONFIG_UB6470_EXCLUDE_PDN_CONTROL +#else + if(enter_powerdown) + { + //amebad_gpio_write(_PA_0, 0); + audvdbg("enter powerdown\n"); + } + else + { + //amebad_gpio_write(_PA_0, 1); + audvdbg("exit powerdown\n"); + } +#endif +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: cy4390x_ub6470_initialize + * + * Description: + * This function is called by platform-specific, setup logic to configure + * and register the UB6470 device. This function will register the driver + * as /dev/ub6470[x] where x is determined by the minor device number. + * + * Input Parameters: + * minor - The input device minor number + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ +int rtl_ub6470_initialize(int minor) +{ + FAR struct audio_lowerhalf_s *ub6470; + FAR struct i2c_dev_s *i2c; + FAR struct i2s_dev_s *i2s = NULL; + static bool initialized = false; // for compilation sake + char devname[12]; + int ret; + + audvdbg("minor %d\n", minor); + DEBUGASSERT(minor >= UB6470_AVAILABLE_MINOR_MIN && minor <= UB6470_AVAILABLE_MINOR_MAX); + +#define UB6470_AVAIALBLE_MINOR_MIN 0 +#define UB6470_AVAIALBLE_MINOR_MAX 25 + + /* Have we already initialized? Since we never uninitialize we must prevent + * multiple initializations. This is necessary, for example, when the + * touchscreen example is used as a built-in application in NSH and can be + * called numerous time. It will attempt to initialize each time. + */ + + if (!initialized) { + /* Get an instance of the I2C interface for the UB6470 chip select */ + lldbg("calling init\n"); + lldbg("i2c init called\n"); + i2c = up_i2cinitialize(UB6470_I2C_PORT); + if (!i2c) { + auddbg("ERROR: Failed to initialize CODEC I2C%d\n"); + ret = -ENODEV; + goto errout_with_i2c; + } + lldbg("i2c init done\n"); + lldbg("calling init i2s\n"); + /* Get an instance of the I2S interface for the UB6470 data channel */ + i2s = amebad_i2s_initialize(UB6470_I2S_PORT); + if (!i2s) { + auddbg("ERROR: Failed to initialize I2S\n"); + ret = -ENODEV; + goto errout_with_i2s; + } + + lldbg("calling init i2s done\n"); + + gpio_init(&gpio_pa0, PA_0); + gpio_write(&gpio_pa0, 0); + gpio_dir(&gpio_pa0, PIN_OUTPUT); + gpio_mode(&gpio_pa0, PullNone); +#ifdef CONFIG_UB6470_EXCLUDE_PDN_CONTROL + g_ub6470info.lower.control_powerdown = ub6470_control_powerdown; +#else + g_ub6470info.lower.control_powerdown = ub6470_control_powerdown; + g_ub6470info.lower.control_powerdown(false); +#endif + + g_ub6470info.lower.control_hw_reset = ub6470_control_reset_pin; + g_ub6470info.lower.control_hw_reset(true); /*power on*/ + g_ub6470info.lower.control_hw_reset(false); /*does nothing*/ + + /* Now we can use these I2C and I2S interfaces to initialize the + * UB6470 which will return an audio interface. + */ + /* Create a device name */ + snprintf(devname, sizeof(devname), "pcmC%uD%u%c", minor, 0, 'p'); + lldbg("calling init lower\n"); + ub6470 = ub6470_initialize(i2c, i2s, &g_ub6470info.lower); + if (!ub6470) { + auddbg("ERROR: Failed to initialize the UB6470\n"); + ret = -ENODEV; + goto errout_with_ub6470; + } + lldbg("calling init lower done\n"); + /* Finally, we can register the PCM/UB6470/I2C/I2S audio device. + * + * Is anyone young enough to remember Rube Goldberg? + */ + lldbg("registering audio device here\n"); + ret = audio_register(devname, ub6470); + lldbg("registrred the device\n"); + if (ret < 0) { + auddbg("ERROR: Failed to register /dev/%s device: %d\n", devname, ret); + goto errout_with_pcm; + } + + /* Now we are initialized */ + + initialized = true; + } + + return OK; + + /* Error exits. Unfortunately there is no mechanism in place now to + * recover resources from most errors on initialization failures. + */ + +errout_with_pcm: +errout_with_i2c: +errout_with_ub6470: +errout_with_i2s: + return ret; +} +#endif diff --git a/os/drivers/audio/Kconfig b/os/drivers/audio/Kconfig index 68c75577da..a1e9c1b06d 100644 --- a/os/drivers/audio/Kconfig +++ b/os/drivers/audio/Kconfig @@ -171,6 +171,15 @@ config CX20921_I2S_TIMEOUT ---help--- Set timeout of CX20921 I2S response in millisecond +config AUDIO_UB6470 + bool "UB6470 DAC audio chip" + default n + depends on AUDIO + ---help--- + Select to enable support for the TAS5749 DAC Audio codec by TI + NOTE: This driver also depends on both I2C and I2S support although + that dependency is not explicit here. + config AUDIO_TAS5749 bool "TAS5749 DAC audio chip" default n diff --git a/os/drivers/audio/Make.defs b/os/drivers/audio/Make.defs index 216d3086f8..1b78c21f6e 100644 --- a/os/drivers/audio/Make.defs +++ b/os/drivers/audio/Make.defs @@ -76,6 +76,10 @@ ifeq ($(CONFIG_AUDIO_TAS5749),y) CSRCS += tas5749.c endif +ifeq ($(CONFIG_AUDIO_UB6470),y) +CSRCS += ub6470.c +endif + # Include Audio driver support DEPPATH += --dep-path audio diff --git a/os/drivers/audio/ub6470.c b/os/drivers/audio/ub6470.c new file mode 100644 index 0000000000..ef9cb7f2fd --- /dev/null +++ b/os/drivers/audio/ub6470.c @@ -0,0 +1,1254 @@ +/**************************************************************************** + * + * Copyright 2022 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ub6470.h" +#include "ub6470scripts.h" + +#define UB6470_I2S_TIMEOUT_MS 200 + +/* Default configuration values */ +#ifndef CONFIG_UB6470_BUFFER_SIZE +#define CONFIG_UB6470_BUFFER_SIZE 4096 +#endif + +#ifndef CONFIG_UB6470_NUM_BUFFERS +#define CONFIG_UB6470_NUM_BUFFERS 4 +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ +static UB6470_REG_DATA_TYPE g_ub6470_i2c_mode = UB6470_REG_D_1BYTE; + +static const struct audio_ops_s g_audioops = { + .getcaps = ub6470_getcaps, /* getcaps */ + .configure = ub6470_configure, /* configure */ + .shutdown = ub6470_shutdown, /* shutdown */ + .start = ub6470_start, /* start */ +#ifndef CONFIG_AUDIO_EXCLUDE_STOP + .stop = ub6470_stop, /* stop */ +#endif +#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME + .pause = ub6470_pause, /* pause */ + .resume = ub6470_resume, /* resume */ +#endif + .allocbuffer = NULL, /* allocbuffer */ + .freebuffer = NULL, /* freebuffer */ + .enqueuebuffer = ub6470_enqueuebuffer, /* enqueue_buffer */ + .cancelbuffer = ub6470_cancelbuffer, /* cancel_buffer */ + .ioctl = ub6470_ioctl, /* ioctl */ + .read = NULL, /* read */ + .read = NULL, /* write */ + .reserve = ub6470_reserve, /* reserve */ + .release = ub6470_release, /* release */ +}; + +/**************************************************************************** + * Name: delay + * + * Description + * Delay in ms. + ****************************************************************************/ +static void delay(unsigned int mS) +{ + //usleep(mS * 1000); + int ans; + for (int i = 0; i < 100000000; i++) { + ans = (ans + i)%5; + if (i %50000000 == 0) printf("waiting === delay\n", ans); + } + ans += 1; +} + +/**************************************************************************** + * Name: ub6470_readreg + * + * Description + * Read the specified 8-bit register from the UB6470 device. + * + * enable i2c readwrite in config for this. + * + ****************************************************************************/ +uint8_t ub6470_readreg_1byte(FAR struct ub6470_dev_s *priv, uint8_t regaddr) +{ + uint8_t reg[4]; + FAR struct i2c_dev_s *dev = priv->i2c; + FAR struct i2c_config_s *ub6470_i2c_config = &(priv->lower->i2c_config); + uint8_t reg_w[4]; + reg_w[0] = regaddr; + //int ret = i2c_writeread(dev, ub6470_i2c_config, reg_w, 1, reg, 1); + int ret = i2c_write(dev, ub6470_i2c_config, reg_w, 1); + ret = i2c_read(dev, ub6470_i2c_config, reg, 1); + if (ret < 0) { + printf("Error, cannot read reg %x\n", regaddr); + PANIC(); + return FAIL_8; + } + //else printf("read to 0x%x ret = %d\n", regaddr, ret); + return reg[0]; +} + +/**************************************************************************** + * Name: ub6470_readreg + * + * Description + * Read the specified 32-bit register from the UB6470 device. (big endian) + * + ****************************************************************************/ +uint32_t ub6470_readreg_4byte(FAR struct ub6470_dev_s *priv, uint8_t regaddr) +{ + int32_t ret; + uint8_t reg[4]; + uint32_t regval; + FAR struct i2c_dev_s *dev = priv->i2c; + FAR struct i2c_config_s *ub6470_i2c_config = &(priv->lower->i2c_config); + + reg[0] = regaddr; + + ret = i2c_write(dev, ub6470_i2c_config, reg, 1); + if (ret < 0) { + auddbg("Error, cannot read reg %x\n", regaddr); + return FAIL_32; + } + ret = i2c_read(dev, ub6470_i2c_config, reg, 3); + if (ret < 0) { + auddbg("Error, cannot read reg %x\n", regaddr); + return FAIL_32; + } + regval = ((reg[0] << 24) | (reg[1] << 16) | (reg[2] << 8) | (reg[3])); + printf("%02x\t%02x\t%02x\t%02x\n", regaddr, reg[0], reg[1], reg[2]); + return ret; +} + +/************************************************************************************ + * Name: ub6470_writereg_1byte + * + * Description: + * Write the specified 8-bit register to the UB6470 device. + * + ************************************************************************************/ +static int ub6470_writereg_1byte(FAR struct ub6470_dev_s *priv, uint8_t regaddr, uint8_t regval) +{ + int ret; + uint8_t reg[2]; + FAR struct i2c_dev_s *dev = priv->i2c; + FAR struct i2c_config_s *ub6470_i2c_config = &(priv->lower->i2c_config); + + reg[0] = regaddr; + reg[1] = regval; + + ret = i2c_write(dev, ub6470_i2c_config, (uint8_t *)reg, 2); + if (ret != 2) { + auddbg("Error, cannot write reg %x\n", regaddr); + } + //else printf("written to 0x%x val 0x%x ret = %d\n", regaddr, regval, ret); + uint8_t regval2 = ub6470_readreg_1byte(priv, regaddr); + printf("0x%02x\t0x%02x\n", regaddr, regval2); + return ret; +} + +/************************************************************************************ + * Name: ub6470_writereg_4byte + * + * Description: + * Write the specified 32-bit register to the UB6470 device. + * + ************************************************************************************/ +static int ub6470_writereg_4byte(FAR struct ub6470_dev_s *priv, uint8_t regaddr, uint8_t regval[4]) +{ + int ret; + uint8_t reg[5]; + FAR struct i2c_dev_s *dev = priv->i2c; + FAR struct i2c_config_s *ub6470_i2c_config = &(priv->lower->i2c_config); + + reg[0] = regaddr; + reg[1] = regval[1]; + reg[2] = regval[2]; + reg[3] = regval[3]; + //reg[4] = regval[3]; + + ret = i2c_write(dev, ub6470_i2c_config, (uint8_t *)reg, 4); + if (ret != 4) { + auddbg("Error, cannot write reg %x\n", regaddr); + } + ret = ub6470_readreg_4byte(priv, regaddr); + return ret; +} + +/************************************************************************************ + * Name: ub6470_exec_i2c_script + * + * Description: + * Executes given script through i2c to configuure UB6470 device. + * + ************************************************************************************/ +static int ub6470_exec_i2c_script(FAR struct ub6470_dev_s *priv, t_codec_init_script_entry *script, uint32_t size) +{ + uint32_t i; + uint16_t ret = 0; + UB6470_REG_DATA_TYPE reg_acc; + + for (i = 0; i < size; i++) { + reg_acc = (UB6470_REG_DATA_TYPE)script[i].type; + if (reg_acc == UB6470_REG_D_1BYTE) { + ret = ub6470_writereg_1byte(priv, (uint8_t)script[i].addr, script[i].val[0]); + } else if (reg_acc == UB6470_REG_D_4BYTE) { + ret = ub6470_writereg_4byte(priv, (uint8_t)script[i].addr, script[i].val); + } + + /* + if ((uint8_t)script[i].addr == 0x01) { + delay(script[i].delay); // wait as we are setting pll registers + uint8_t regval2 = ub6470_readreg_1byte(priv, 0x01); + printf("val of 0x01 : 0x%02x\n", regval2); + } + */ + + } + return ret; +} + +/************************************************************************************ + * Name: ub6470_takesem + * + * Description: + * Take a semaphore count, handling the nasty EINTR return if we are interrupted + * by a signal. + * + ************************************************************************************/ +static void ub6470_takesem(sem_t *sem) +{ + int ret; + + do { + ret = sem_wait(sem); + DEBUGASSERT(ret == 0 || errno == EINTR); + } while (ret < 0); +} + +/************************************************************************************ + * Name: ub6470_setvolume + * + * Description: + * Set the right and left volume values in the UB6470 device based on the current + * volume and balance settings. + * + ************************************************************************************/ +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME +static void ub6470_setvolume(FAR struct ub6470_dev_s *priv) +{ + printf("set volume is called\n"); + /* if no audio device object return */ + if (!priv) { + auddbg("Error, Device's private data Not available\n"); + return; + } + + if (priv->running) { + audvdbg("volume=%u mute=%u\n", priv->volume, priv->mute); + if (priv->mute) { + ub6470_exec_i2c_script(priv, codec_init_mute_on_script, sizeof(codec_init_mute_on_script) / sizeof(t_codec_init_script_entry)); + } else { + codec_set_master_volume_script[1].val[0] = (uint8_t)priv->volume; + int ret = ub6470_exec_i2c_script(priv, codec_set_master_volume_script, sizeof(codec_set_master_volume_script) / sizeof(t_codec_init_script_entry)); + printf("set volume output : %d\n", ret); + } + } else { + audvdbg("not running[volume=%u mute=%u]\n", priv->volume, priv->mute); + } +} +#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */ + +/************************************************************************************ + * Name: ub6470_setbass + * + * Description: + * Set the bass level. + * + * The level and range are in whole percentage levels (0-100). + * + ************************************************************************************/ +#ifndef CONFIG_AUDIO_EXCLUDE_TONE +static void ub6470_setbass(FAR struct ub6470_dev_s *priv, uint8_t bass) +{ + audvdbg("bass=%u\n", bass); +} +#endif /* CONFIG_AUDIO_EXCLUDE_TONE */ + +/************************************************************************************ + * Name: ub6470_settreble + * + * Description: + * Set the treble level . + * + * The level and range are in whole percentage levels (0-100). + * + ************************************************************************************/ +#ifndef CONFIG_AUDIO_EXCLUDE_TONE +static void ub6470_settreble(FAR struct ub6470_dev_s *priv, uint8_t treble) +{ + audvdbg("treble=%u\n", treble); +} +#endif + +/**************************************************************************** + * Name: ub6470_set_i2s_datawidth + * + * Description: + * Set the 8- 16- 24- bit data modes + * + ****************************************************************************/ +static void ub6470_set_i2s_datawidth(FAR struct ub6470_dev_s *priv) +{ + /* if no audio device object return */ + if (!priv) { + auddbg("Error, Device's private data Not available\n"); + return; + } + + if (priv->inout) { + I2S_RXDATAWIDTH(priv->i2s, priv->bpsamp); + } else { + I2S_TXDATAWIDTH(priv->i2s, priv->bpsamp); + } +} + +/**************************************************************************** + * Name: ub6470_set_i2s_samplerate + * + * Description: + * + ****************************************************************************/ +static void ub6470_set_i2s_samplerate(FAR struct ub6470_dev_s *priv) +{ + /* if no audio device object return */ + if (!priv) { + auddbg("Error, Device's private data Not available\n"); + return; + } + + if (priv->inout) { + I2S_RXSAMPLERATE(priv->i2s, priv->samprate); + } else { + I2S_TXSAMPLERATE(priv->i2s, priv->samprate); + } +} + +/**************************************************************************** + * Name: ub6470_getcaps + * + * Description: + * Get the audio device capabilities + * + ****************************************************************************/ +static int ub6470_getcaps(FAR struct audio_lowerhalf_s *dev, int type, FAR struct audio_caps_s *caps) +{ +#if !defined(CONFIG_AUDIO_EXCLUDE_VOLUME) || !defined(CONFIG_AUDIO_EXCLUDE_TONE) + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; +#endif + /* Validate the structure */ + + DEBUGASSERT(caps && caps->ac_len >= sizeof(struct audio_caps_s)); + audvdbg("type=%d ac_type=%d\n", type, caps->ac_type); + + /* Fill in the caller's structure based on requested info */ + + caps->ac_controls.w = 0; + + switch (caps->ac_type) { + /* Caller is querying for the types of units we support */ + + case AUDIO_TYPE_QUERY: + + /* Provide our overall capabilities. The interfacing software + * must then call us back for specific info for each capability. + */ + + caps->ac_channels = UB6470_CHANNELS; /* Stereo output */ + + switch (caps->ac_subtype) { + case AUDIO_TYPE_QUERY: + /* We don't decode any formats! Only something above us in + * the audio stream can perform decoding on our behalf. + */ + + /* The types of audio units we implement */ + caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE; + + break; + + default: + caps->ac_controls.b[0] = AUDIO_SUBFMT_END; + break; + } + + break; + + /* Provide capabilities of our INPUT & OUTPUT unit */ + case AUDIO_TYPE_OUTPUT: + caps->ac_channels = UB6470_CHANNELS; + switch (caps->ac_subtype) { + case AUDIO_TYPE_QUERY: + /* Report the Sample rates we support */ + caps->ac_controls.b[0] = AUDIO_SAMP_RATE_TYPE_48K; + break; + + case AUDIO_FMT_MP3: + case AUDIO_FMT_WMA: + case AUDIO_FMT_PCM: + break; + + default: + break; + } + + break; + + /* Provide capabilities of our FEATURE units */ + + case AUDIO_TYPE_FEATURE: + + /* If the sub-type is UNDEF, then report the Feature Units we support */ + + if (caps->ac_subtype == AUDIO_FU_UNDEF) { + /* Fill in the ac_controls section with the Feature Units we have */ + + caps->ac_controls.b[0] = AUDIO_FU_VOLUME | AUDIO_FU_BASS | AUDIO_FU_TREBLE; + caps->ac_controls.b[1] = AUDIO_FU_BALANCE >> 8; + } else { + /* TODO: Do we need to provide specific info for the Feature Units, + * such as volume setting ranges, etc.? + */ + } + + switch (caps->ac_format.hw) { + case AUDIO_FU_VOLUME: + caps->ac_controls.hw[0] = UB6470_SPK_VOL_MAX; + caps->ac_controls.hw[1] = priv->volume; + break; + default: + break; + } + + break; + + /* All others we don't support */ + + default: + + /* Zero out the fields to indicate no support */ + + caps->ac_subtype = 0; + caps->ac_channels = 0; + + break; + } + + /* Return the length of the audio_caps_s struct for validation of + * proper Audio device type. + */ + + return caps->ac_len; +} + +/**************************************************************************** + * Name: ub6470_configure + * + * Description: + * Configure the audio device for the specified mode of operation. + * + ****************************************************************************/ +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_configure(FAR struct audio_lowerhalf_s *dev, FAR void *session, FAR const struct audio_caps_s *caps) +#else +static int ub6470_configure(FAR struct audio_lowerhalf_s *dev, FAR const struct audio_caps_s *caps) +#endif +{ +#if !defined(CONFIG_AUDIO_EXCLUDE_VOLUME) || !defined(CONFIG_AUDIO_EXCLUDE_TONE) + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; +#endif + int ret = OK; + + DEBUGASSERT(priv && caps); + audvdbg("ac_type: %d\n", caps->ac_type); + + + /* UB6470 supports on the fly changes for almost all changes + so no need to do anything. But if any issue, worth looking here */ + + switch (caps->ac_type) { + case AUDIO_TYPE_FEATURE: + audvdbg(" AUDIO_TYPE_FEATURE\n"); + + /* Inner swich case: Process based on Feature Unit */ + switch (caps->ac_format.hw) { +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME + case AUDIO_FU_VOLUME: { + /* Set the volume */ + uint16_t volume = caps->ac_controls.hw[0]; + audvdbg(" Volume: %d\n", volume); + if (volume < UB6470_SPK_VOL_MIN) { + priv->volume = UB6470_SPK_VOL_MIN; + } else if (volume >= UB6470_SPK_VOL_MAX) { + priv->volume = UB6470_SPK_VOL_MAX; + } else { + priv->volume = volume; + } + printf("set volume is called\n"); + ub6470_setvolume(priv); + } + break; + case AUDIO_FU_MUTE: { + /* Mute or unmute: true(1) or false(0) */ + bool mute = caps->ac_controls.b[0]; + audvdbg("mute: 0x%x\n", mute); + priv->mute = mute; + ub6470_setvolume(priv); + } + break; +#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */ + +#ifndef CONFIG_AUDIO_EXCLUDE_TONE + case AUDIO_FU_BASS: { + /* Set the bass. The percentage level (0-100) is in the + * ac_controls.b[0] parameter. */ + + uint8_t bass = caps->ac_controls.b[0]; + audvdbg(" Bass: %d\n", bass); + if (bass <= UB6470_BASS_MAX) { + ub6470_setbass(priv, bass); + } + } + break; + case AUDIO_FU_TREBLE: { + /* Set the treble. The percentage level (0-100) is in the + * ac_controls.b[0] parameter. */ + + uint8_t treble = caps->ac_controls.b[0]; + audvdbg(" Treble: %d\n", treble); + if (treble <= UB6470_TREBLE_MAX) { + ub6470_settreble(priv, treble); + } + } + break; +#endif /* CONFIG_AUDIO_EXCLUDE_TONE */ + default: + auddbg(" ERROR: Unrecognized feature unit\n"); + break; + } + break; /* Break for inner switch case */ + case AUDIO_TYPE_OUTPUT: + audvdbg(" AUDIO_TYPE :%s\n", caps->ac_type == AUDIO_TYPE_INPUT ? "INPUT" : "OUTPUT"); + /* Verify that all of the requested values are supported */ + + ret = -EDOM; + if (caps->ac_channels != UB6470_CHANNELS) { + auddbg("ERROR: Unsupported number of channels: %d\n", caps->ac_channels); + break; + } + + if (caps->ac_controls.b[2] != UB6470_BPSAMP) { + auddbg("ERROR: Unsupported bits per sample: %d\n", caps->ac_controls.b[2]); + break; + } + + /* Save the current stream configuration */ + + priv->samprate = caps->ac_controls.hw[0]; + priv->nchannels = caps->ac_channels; + priv->bpsamp = caps->ac_controls.b[2]; + + audvdbg(" Number of channels: 0x%x\n", priv->nchannels); + audvdbg(" Sample rate: 0x%x\n", priv->samprate); + audvdbg(" Sample width: 0x%x\n", priv->bpsamp); + + /* Reconfigure the FLL to support the resulting number or channels, + * bits per sample, and bitrate. + */ + ret = OK; + priv->inout = false; + break; + + case AUDIO_TYPE_PROCESSING: + break; + + default: + break; + } + return ret; +} + +/**************************************************************************** + * Name: ub6470_shutdown + * + * Description: + * Shutdown the UB6470 chip and put it in the lowest power state possible. + * + ****************************************************************************/ +static int ub6470_shutdown(FAR struct audio_lowerhalf_s *dev) +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + struct ub6470_lower_s *lower = priv->lower; + + DEBUGASSERT(priv); + + if (!priv) { + return -EINVAL; + } + + /* First disable interrupts */ + ub6470_takesem(&priv->devsem); + sq_entry_t *tmp = NULL; + for (tmp = (sq_entry_t *)sq_peek(&priv->pendq); tmp; tmp = sq_next(tmp)) { + sq_rem(tmp, &priv->pendq); + audvdbg("(tasshutdown)removing tmp with addr 0x%x\n", tmp); + } + sq_init(&priv->pendq); + + if (priv->running) { + I2S_STOP(priv->i2s, I2S_TX); + ub6470_exec_i2c_script(priv, codec_stop_script, sizeof(codec_stop_script) / sizeof(t_codec_init_script_entry)); + priv->running = false; + } + priv->paused = false; + + ub6470_givesem(&priv->devsem); + + /* Now issue a software reset. This puts all UB6470 registers back in + * their default state. + */ + + if (lower->control_powerdown) { + lower->control_powerdown(1); //need hardware support here, func in board dir + } + return OK; +} + +/**************************************************************************** + * Name: ub6470_io_err_cb + * + * Description: + * Callback function for io error + * + ****************************************************************************/ +static void ub6470_io_err_cb(FAR struct i2s_dev_s *dev, FAR void *arg, int flags) +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)arg; + + /* Call upper callback, let it post msg to user q + * apb is set NULL, okay? Rethink + */ + if (priv && priv->dev.upper) { + priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_IOERR, NULL, flags); + } + +} + +/**************************************************************************** + * Name: ub6470_start + * + * Description: + * Start the configured operation (audio streaming, volume enabled, etc.). + * + ****************************************************************************/ + +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_start(FAR struct audio_lowerhalf_s *dev, FAR void *session) +#else +static int ub6470_start(FAR struct audio_lowerhalf_s *dev) +#endif +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + + if (!priv) { + return -EINVAL; + } + + audvdbg(" ub6470_start Entry\n"); + ub6470_takesem(&priv->devsem); + if (priv->running) { + goto ub_start_withsem; + } + + /* Register cb for io error */ + I2S_ERR_CB_REG(priv->i2s, ub6470_io_err_cb, priv); + + /* Finally set ub6470 to be running */ + priv->running = true; + priv->mute = false; +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME + ub6470_setvolume(priv); +#endif + + sq_entry_t *tmp = NULL; + sq_queue_t *q = &priv->pendq; + for (tmp = sq_peek(q); tmp; tmp = sq_next(tmp)) { + ub6470_enqueuebuffer(dev, (struct ap_buffer_s *)tmp); + } + + /* Exit reduced power modes of operation */ + /* REVISIT */ + +ub_start_withsem: + + ub6470_givesem(&priv->devsem); + return OK; +} + +/**************************************************************************** + * Name: ub6470_stop + * + * Description: Stop the configured operation (audio streaming, volume + * disabled, etc.). + * + ****************************************************************************/ + +#ifndef CONFIG_AUDIO_EXCLUDE_STOP +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_stop(FAR struct audio_lowerhalf_s *dev, FAR void *session) +#else +static int ub6470_stop(FAR struct audio_lowerhalf_s *dev) +#endif +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + + if (!priv) { + return -EINVAL; + } + audvdbg(" ub6470_stop Entry\n"); + ub6470_takesem(&priv->devsem); + I2S_STOP(priv->i2s, I2S_TX); + /* Need to run the stop script here */ + ub6470_exec_i2c_script(priv, codec_stop_script, sizeof(codec_stop_script) / sizeof(t_codec_init_script_entry)); + + priv->running = false; + priv->mute = true; + ub6470_givesem(&priv->devsem); + + /* Enter into a reduced power usage mode */ + /* REVISIT: */ + + return OK; +} +#endif + +/**************************************************************************** + * Name: ub6470_pause + * + * Description: Pauses the playback. + * + ****************************************************************************/ +#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_pause(FAR struct audio_lowerhalf_s *dev, FAR void *session) +#else +static int ub6470_pause(FAR struct audio_lowerhalf_s *dev) +#endif +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + + if (!priv) { + return -EINVAL; + } + audvdbg(" ub6470_pause Entry\n"); + ub6470_takesem(&priv->devsem); + + if (priv->running && !priv->paused) { + /* Disable interrupts to prevent us from suppling any more data */ + + priv->paused = true; + priv->mute = true; +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME + ub6470_setvolume(priv); +#endif + I2S_PAUSE(priv->i2s, I2S_TX); + } + + ub6470_givesem(&priv->devsem); + + return OK; +} +#endif /* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME */ + +/**************************************************************************** + * Name: ub6470_resume + * + * Description: Resumes the playback. + * + ****************************************************************************/ +#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_resume(FAR struct audio_lowerhalf_s *dev, FAR void *session) +#else +static int ub6470_resume(FAR struct audio_lowerhalf_s *dev) +#endif +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + + if (!priv) { + return -EINVAL; + } + + audvdbg(" ub6470_resume Entry\n"); + ub6470_takesem(&priv->devsem); + + if (priv->running && priv->paused) { + priv->paused = false; + priv->mute = false; +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME + ub6470_setvolume(priv); +#endif + + I2S_RESUME(priv->i2s, I2S_TX); + + } + + ub6470_givesem(&priv->devsem); + return OK; +} +#endif /* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME */ + +/**************************************************************************** + * Name: ub6470_rxcallback + * + * Description: Called when I2S filled a buffer. No recycling mechanism now. + * + ****************************************************************************/ + +static void ub6470_txcallback(FAR struct i2s_dev_s *dev, FAR struct ap_buffer_s *apb, FAR void *arg, int result) +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)arg; + + DEBUGASSERT(priv && apb); + + ub6470_takesem(&priv->devsem); + sq_entry_t *tmp; + for (tmp = (sq_entry_t *)sq_peek(&priv->pendq); tmp; tmp = sq_next(tmp)) { + if (tmp == (sq_entry_t *)apb) { + sq_rem(tmp, &priv->pendq); + audvdbg("found the apb to remove 0x%x\n", tmp); + break; + } + } + + /* Call upper callback, let it post msg to user q */ + priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_DEQUEUE, apb, OK); + + ub6470_givesem(&priv->devsem); +} + +/**************************************************************************** + * Name: ub6470_enqueuebuffer + * + * Description: Enqueue an Audio Pipeline Buffer for playback/ processing. + * + ****************************************************************************/ +static int ub6470_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_buffer_s *apb) +{ + //printf("In enqueue buffer\n"); + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + int ret; + + if (!priv || !apb) { + return -EINVAL; + } + + if (!priv->running) { + printf("device not runnning\n"); + /* Add the new buffer to the tail of pending audio buffers */ + ub6470_takesem(&priv->devsem); + sq_addlast((sq_entry_t *)&apb->dq_entry, &priv->pendq); + printf("enqueue added buf 0x%x\n", apb); + ub6470_givesem(&priv->devsem); + return OK; + } + //printf("I2S send is called\n"); + priv->volume = UB6470_SPK_VOL_MAX; + /* debugging prupose to check if volume is not on mute*/ + //printf("set volume to max\n"); + //ub6470_setvolume(priv); + /* + uint8_t regval2 = ub6470_readreg_1byte(priv, 0x3C); + printf("val of 0x3C : 0x%02x\n", regval2); + regval2 = ub6470_readreg_1byte(priv, 0x3D); + printf("val of 0x3D : 0x%02x\n", regval2); + regval2 = ub6470_readreg_1byte(priv, 0x0F); + printf("val of 0x0F : 0x%02x\n", regval2); + regval2 = ub6470_readreg_1byte(priv, 0x2A); + printf("val of 0x2A : 0x%02x\n", regval2); + */ + ret = I2S_SEND(priv->i2s, apb, ub6470_txcallback, priv, UB6470_I2S_TIMEOUT_MS); + + return ret; +} + +/**************************************************************************** + * Name: ub6470_cancelbuffer + * + * Description: Called when an enqueued buffer is being cancelled. + * + ****************************************************************************/ +static int ub6470_cancelbuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_buffer_s *apb) +{ + audvdbg("apb=%p\n", apb); + /* Need to add logic here */ + return OK; +} + +/**************************************************************************** + * Name: ub6470_ioctl + * + * Description: Perform a device ioctl + * + ****************************************************************************/ +static int ub6470_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd, unsigned long arg) +{ + FAR struct ap_buffer_info_s *bufinfo; + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + + if (!priv) { + return -EINVAL; + } + + /* Deal with ioctls passed from the upper-half driver */ + + switch (cmd) { + + case AUDIOIOC_PREPARE: { + audvdbg("AUDIOIOC_PREPARE: ub6470 prepare\n"); + uint8_t regval; + struct ub6470_lower_s *lower = priv->lower; + + /* Take semaphore */ + ub6470_takesem(&priv->devsem); + + /* Pause i2s channel */ + I2S_PAUSE(priv->i2s, I2S_TX); + + if (lower->control_powerdown) { + lower->control_powerdown(0); + //delay(10); //spec is 100us + } + //ub6470_exec_i2c_script(priv, codec_initial_script, sizeof(codec_initial_script) / sizeof(t_codec_init_script_entry)); + + /* Amp Error Check */ // add error reg here + ub6470_writereg_1byte(priv, (uint8_t)0x0E, 0x00); + regval = ub6470_readreg_1byte(priv, 0x0E); + if (regval != 0x00) { + auddbg("ERROR: Amp has some error! register : 0x%02x value : 0x%02x \n", 0x0E, regval); + } + + /* Resume I2S */ + I2S_RESUME(priv->i2s, I2S_TX); + + /* Give semaphore */ + ub6470_givesem(&priv->devsem); + } + break; + case AUDIOIOC_HWRESET: { + /* REVISIT: Should we completely re-initialize the chip? We + * can't just issue a software reset; that would puts all UB6470 + * registers back in their default state. + */ + + audvdbg("AUDIOIOC_HWRESET:\n"); + ub6470_hw_reset(priv); + } + break; + + /* Report our preferred buffer size and quantity */ + + case AUDIOIOC_GETBUFFERINFO: { + /* Report our preferred buffer size and quantity */ + audvdbg("AUDIOIOC_GETBUFFERINFO:\n"); + /* Take semaphore */ + ub6470_takesem(&priv->devsem); + + bufinfo = (FAR struct ap_buffer_info_s *)arg; +#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS + bufinfo->buffer_size = CONFIG_UB6470_BUFFER_SIZE; + bufinfo->nbuffers = CONFIG_UB6470_NUM_BUFFERS; +#else + bufinfo->buffer_size = CONFIG_UB6470_BUFFER_SIZE; + bufinfo->nbuffers = CONFIG_UB6470_NUM_BUFFERS; +#endif + audvdbg("buffer_size : %d nbuffers : %d\n", bufinfo->buffer_size, bufinfo->nbuffers); + + /* Give semaphore */ + ub6470_givesem(&priv->devsem); + } + break; + + + default: + audvdbg("ub6470_ioctl received unkown cmd 0x%x\n", cmd); + break; + } + + return OK; +} + +/**************************************************************************** + * Name: ub6470_reserve + * + * Description: Reserves a session (the only one we have). + * + ****************************************************************************/ +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_reserve(FAR struct audio_lowerhalf_s *dev, FAR void **session) +#else +static int ub6470_reserve(FAR struct audio_lowerhalf_s *dev) +#endif +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + int ret = OK; + + if (!priv) { + return -EINVAL; + } + + /* Borrow the APBQ semaphore for thread sync */ + + ub6470_takesem(&priv->devsem); + if (priv->reserved) { + ret = -EBUSY; + } else { + /* Initialize the session context */ + +#ifdef CONFIG_AUDIO_MULTI_SESSION + *session = NULL; +#endif + priv->inflight = 0; + priv->running = false; + priv->paused = false; +#ifndef CONFIG_AUDIO_EXCLUDE_STOP + priv->terminating = false; +#endif + priv->reserved = true; + } + + ub6470_givesem(&priv->devsem); + + return ret; +} + +/**************************************************************************** + * Name: ub6470_release + * + * Description: Releases the session (the only one we have). + * + ****************************************************************************/ +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_release(FAR struct audio_lowerhalf_s *dev, FAR void *session) +#else +static int ub6470_release(FAR struct audio_lowerhalf_s *dev) +#endif +{ + FAR struct ub6470_dev_s *priv = (FAR struct ub6470_dev_s *)dev; + + if (!priv) { + return -EINVAL; + } + ub6470_takesem(&priv->devsem); + if (priv->running) { + I2S_STOP(priv->i2s, I2S_TX); + ub6470_exec_i2c_script(priv, codec_stop_script, sizeof(codec_stop_script) / sizeof(t_codec_init_script_entry)); + priv->running = false; + } + priv->reserved = false; + ub6470_givesem(&priv->devsem); + + return OK; +} + +/* Reset and reconfigure the UB6470 hardwaqre */ +/**************************************************************************** + * Name: ub6470_reconfigure + * + * Description: + * re-initialize the UB6470 + * + * Input Parameters: + * priv - A reference to the driver state structure + * + * Returned Value: + * None + * + ****************************************************************************/ +static void ub6470_reconfigure(FAR struct ub6470_dev_s *priv) +{ + priv->inout = false; + /* Put audio output back to its initial configuration */ + priv->samprate = UB6470_DEFAULT_SAMPRATE; + priv->nchannels = UB6470_DEFAULT_NCHANNELS; + priv->bpsamp = UB6470_DEFAULT_BPSAMP; +#if !defined(CONFIG_AUDIO_EXCLUDE_VOLUME) && !defined(CONFIG_AUDIO_EXCLUDE_BALANCE) + priv->balance = b16HALF; /* Center balance */ +#endif + + /* Software reset. This puts all UB6470 registers back in their + * default state. + */ + int res = ub6470_exec_i2c_script(priv, codec_initial_script, sizeof(codec_initial_script) / sizeof(t_codec_init_script_entry)); + uint8_t regval2; + while (true) { + regval2 = ub6470_readreg_1byte(priv, 0x01); + if (regval2 == 0x02) { + printf("value of 0x01 is set to 0x02\n"); + for (int i = 0; i < 1000000; i++) { + regval2++; + } + break; + } + printf("value of 0x01 is set to :%d\n", regval2); + for (int i = 0; i < 1000000; i++) { + regval2++; + } + } + res = ub6470_exec_i2c_script(priv, codec_initial_script2, sizeof(codec_initial_script2) / sizeof(t_codec_init_script_entry)); + printf("reconfigure output : %d\n", res); +// ub6470_set_i2s_samplerate(priv); +// ub6470_set_i2s_datawidth(priv); +} + +/**************************************************************************** + * Name: ub6470_hw_reset + * + * Description: + * Reset and re-initialize the UB6470 + * + * Input Parameters: + * priv - A reference to the driver state structure + * + * Returned Value: + * None + * + ****************************************************************************/ +static void ub6470_hw_reset(FAR struct ub6470_dev_s *priv) +{ + if (!priv) { + return; + } + + struct ub6470_lower_s *lower = priv->lower; + + if (lower->control_hw_reset) { + lower->control_hw_reset(true); + delay(100); + lower->control_hw_reset(false); + delay(100); + } + ub6470_reconfigure(priv); + //ub6470_exec_i2c_script(priv, codec_init_mute_on_script, sizeof(codec_init_mute_on_script) / sizeof(t_codec_init_script_entry)); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ub6470_initialize + * + * Description: + * Initialize the UB6470 device. + * + * Input Parameters: + * i2c - An I2C driver instance + * i2s - An I2S driver instance + * lower - Persistent board configuration data + * + * Returned Value: + * A new lower half audio interface for the UB6470 device is returned on + * success; NULL is returned on failure. + * + ****************************************************************************/ +FAR struct audio_lowerhalf_s *ub6470_initialize(FAR struct i2c_dev_s *i2c, FAR struct i2s_dev_s *i2s, FAR struct ub6470_lower_s *lower) +{ + + FAR struct ub6470_dev_s *priv; + uint8_t regval; + /* Sanity check */ + DEBUGASSERT(i2c && lower && i2s); + + auddbg("I2s dev addr is 0x%x\n", i2s); + + /* Allocate a UB6470 device structure */ + priv = (FAR struct ub6470_dev_s *)kmm_zalloc(sizeof(struct ub6470_dev_s)); + + if (!priv) { + return NULL; + } + + /* Initialize the UB6470 device structure. Since we used kmm_zalloc, + * only the non-zero elements of the structure need to be initialized. + */ + + priv->dev.ops = &g_audioops; + priv->lower = lower; + priv->i2c = i2c; + priv->i2s = i2s; + + sem_init(&priv->devsem, 0, 1); + sq_init(&priv->pendq); + + /* Software reset. This puts all UB6470 registers back in their + * default state. + */ + + /*reconfigure the UB6470 hardwaqre */ + ub6470_reconfigure(priv); + //ub6470_exec_i2c_script(priv, codec_init_mute_on_script, sizeof(codec_init_mute_on_script) / sizeof(t_codec_init_script_entry)); + +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME + priv->volume = UB6470_SPK_VOL_DEF; + ub6470_setvolume(priv); +#endif + + return &priv->dev; + +errout_with_dev: + sem_destroy(&priv->devsem); + kmm_free(priv); + return NULL; +} + diff --git a/os/drivers/audio/ub6470.h b/os/drivers/audio/ub6470.h new file mode 100644 index 0000000000..34e5773208 --- /dev/null +++ b/os/drivers/audio/ub6470.h @@ -0,0 +1,184 @@ +/**************************************************************************** + * + * Copyright 2022 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +#ifndef __DRIVERS_AUDIO_UB6470_H +#define __DRIVERS_AUDIO_UB6470_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ +#include + +#ifdef CONFIG_AUDIO_UB6470 +#include +#include +#include +#include +#include +#include +#include +#ifdef UB6470_USE_FFLOCK_INT +#include +#endif + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +#define UB6470_SAMPLE_FREQUENCY_IN_HZ (48000) /* refer to Input data sample rate */ +#define UB6470_CHANNELS 2 +#define UB6470_BPSAMP 16 /* refer to Digital Audio Interface Control registers */ + +#define UB6470_DEFAULT_SAMPRATE 48000 +#define UB6470_DEFAULT_NCHANNELS 2 +#define UB6470_DEFAULT_BPSAMP 16 +#define FAIL_8 0xFF +#define FAIL_32 0xFFFFFFFF +#define ub6470_givesem(s) sem_post(s) + +#define UB6470_SPK_VOL_MIN 3 +#define UB6470_SPK_VOL_MAX 255 +#define UB6470_SPK_VOL_DEF 180 +#define UB6470_BASS_MAX 100 +#define UB6470_TREBLE_MAX 100 + +/* Commonly defined and redefined macros */ + +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + +#ifndef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct ub6470_dev_s { + /* We are an audio lower half driver (We are also the upper "half" of + * the UB6470 driver with respect to the board lower half driver). + * + * Terminology: Our "lower" half audio instances will be called dev for the + * publicly visible version and "priv" for the version that only this driver + * knows. From the point of view of this driver, it is the board lower + * "half" that is referred to as "lower". + */ + + struct audio_lowerhalf_s dev; /* UB6470 audio lower half (this device) */ + + /* Our specific driver data goes here */ + + FAR struct ub6470_lower_s *lower; /* Pointer to the board lower functions */ + FAR struct i2c_dev_s *i2c; /* I2C driver to use */ + FAR struct i2s_dev_s *i2s; /* I2S driver to use */ + struct sq_queue_s pendq; /* Queue of pending buffers to be sent */ + sem_t devsem; /* Protection for both pendq & dev */ + +#ifdef UB6470_USE_FFLOCK_INT + struct work_s work; /* Interrupt work */ +#endif + uint16_t samprate; /* Configured samprate (samples/sec) */ +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME +#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE + uint16_t balance; /* Current balance level (b16) */ +#endif /* CONFIG_AUDIO_EXCLUDE_BALANCE */ + uint8_t volume; /* Current volume level {0..63} */ +#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */ + uint8_t nchannels; /* Number of channels (1 or 2) */ + uint8_t bpsamp; /* Bits per sample (8 or 16) */ + volatile uint8_t inflight; /* Number of audio buffers in-flight */ +#ifdef UB6470_USE_FFLOCK_INT + volatile bool locked; /* FLL is locked */ +#endif + bool running; /* True: Worker thread is running */ + bool paused; /* True: Playing is paused */ + bool mute; /* True: Output is muted */ +#ifndef CONFIG_AUDIO_EXCLUDE_STOP + bool terminating; /* True: Stop requested */ +#endif + bool reserved; /* True: Device is reserved */ + volatile int result; /* The result of the last transfer */ + bool inout; /* True: IN device */ +}; + +/**************************************************************************** + * Private Declarations + ****************************************************************************/ +static void ub6470_takesem(sem_t *sem); + +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME +static void ub6470_setvolume(FAR struct ub6470_dev_s *priv); +#endif + +#ifndef CONFIG_AUDIO_EXCLUDE_TONE +static void ub6470_setbass(FAR struct ub6470_dev_s *priv, uint8_t bass); +static void ub6470_settreble(FAR struct ub6470_dev_s *priv, uint8_t treble); +#endif +static void ub6470_set_i2s_datawidth(FAR struct ub6470_dev_s *priv); +static void ub6470_set_i2s_samplerate(FAR struct ub6470_dev_s *priv); + +/* Audio lower half methods (and close friends) */ + +static int ub6470_getcaps(FAR struct audio_lowerhalf_s *dev, int type, FAR struct audio_caps_s *caps); +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_configure(FAR struct audio_lowerhalf_s *dev, FAR void *session, FAR const struct audio_caps_s *caps); +#else +static int ub6470_configure(FAR struct audio_lowerhalf_s *dev, FAR const struct audio_caps_s *caps); +#endif +static int ub6470_shutdown(FAR struct audio_lowerhalf_s *dev); + +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_start(FAR struct audio_lowerhalf_s *dev, FAR void *session); +#else +static int ub6470_start(FAR struct audio_lowerhalf_s *dev); +#endif +#ifndef CONFIG_AUDIO_EXCLUDE_STOP +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_stop(FAR struct audio_lowerhalf_s *dev, FAR void *session); +#else +static int ub6470_stop(FAR struct audio_lowerhalf_s *dev); +#endif +#endif +#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_pause(FAR struct audio_lowerhalf_s *dev, FAR void *session); +static int ub6470_resume(FAR struct audio_lowerhalf_s *dev, FAR void *session); +#else +static int ub6470_pause(FAR struct audio_lowerhalf_s *dev); +static int ub6470_resume(FAR struct audio_lowerhalf_s *dev); +#endif +#endif +static int ub6470_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_buffer_s *apb); +static int ub6470_cancelbuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_buffer_s *apb); +static int ub6470_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd, unsigned long arg); +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_reserve(FAR struct audio_lowerhalf_s *dev, FAR void **session); +#else +static int ub6470_reserve(FAR struct audio_lowerhalf_s *dev); +#endif +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int ub6470_release(FAR struct audio_lowerhalf_s *dev, FAR void *session); +#else +static int ub6470_release(FAR struct audio_lowerhalf_s *dev); +#endif + +static void ub6470_reconfigure(FAR struct ub6470_dev_s *priv); +static void ub6470_hw_reset(FAR struct ub6470_dev_s *priv); +#endif /* CONFIG_AUDIO_UB6470 */ +#endif /* __DRIVERS_AUDIO_UB6470_H */ diff --git a/os/drivers/audio/ub6470scripts.h b/os/drivers/audio/ub6470scripts.h new file mode 100644 index 0000000000..455198b140 --- /dev/null +++ b/os/drivers/audio/ub6470scripts.h @@ -0,0 +1,459 @@ +/**************************************************************************** + * + * Copyright 2022 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ +#ifndef __DRIVERS_AUDIO_UB6470SCRIPTS_H +#define __DRIVERS_AUDIO_UB6470SCRIPTS_H + +#include + +#ifdef CONFIG_AUDIO_UB6470 + +/**************************************************************************** + * Included Files + ****************************************************************************/ + + +typedef enum { + UB6470_REG_D_1BYTE, + UB6470_REG_D_4BYTE, + UB6470_REG_DATA_TYPE_MAX +} UB6470_REG_DATA_TYPE; + +/* TYPEDEFS */ +typedef struct { + char /* UB6470_REG_DATA_TYPE */ type; + uint8_t addr; /* UB6470_REG_1BYTE_MODE addr or UB6470_REG_4BYTE_MODE addr */ + uint8_t val[4]; + unsigned int delay; +} t_codec_init_script_entry; + +t_codec_init_script_entry codec_stop_script[] = { + {UB6470_REG_D_1BYTE, 0x2A, {0x00,}, 0} +}; + +t_codec_init_script_entry codec_initial_script[] = { /* refer to regs_default.h file for ub647x */ + {UB6470_REG_D_1BYTE, 0x04, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x05, {0x3F,}, 0}, + {UB6470_REG_D_1BYTE, 0x03, {0x01,}, 0}, + + {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, +}; + +t_codec_init_script_entry codec_initial_script2[] = { + // {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + // {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + // {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + // {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + // {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + //{UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + + {UB6470_REG_D_1BYTE, 0x11, {0x50,}, 0}, + + {UB6470_REG_D_1BYTE, 0x6B, {0x40,}, 0}, + + {UB6470_REG_D_1BYTE, 0x25, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x26, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x27, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x28, {0x00,}, 0}, + + //SDIO Format1 Setting +// {UB6470_REG_D_1BYTE, 0x10, {0x50,}, 0}, + + //SDIO Format2 Setting + // {UB6470_REG_D_1BYTE, 0x11, {0x60,}, 0}, + + {UB6470_REG_D_1BYTE, 0x20, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x21, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x22, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x23, {0x00,}, 0}, + + {UB6470_REG_D_4BYTE, 0xF8, {0x00, 0x00, 0x04, 0x18}, 0}, + {UB6470_REG_D_4BYTE, 0xF9, {0x00, 0x3F, 0xFB, 0xE7}, 0}, + {UB6470_REG_D_4BYTE, 0xFA, {0x00, 0x3F, 0xF4, 0x2C}, 0}, + {UB6470_REG_D_4BYTE, 0xFB, {0x00, 0x40, 0x00, 0x40}, 0}, + + {UB6470_REG_D_1BYTE, 0x31, {0xD4,}, 0}, + + {UB6470_REG_D_1BYTE, 0x30, {0x01,}, 0}, + + {UB6470_REG_D_1BYTE, 0x33, {0x00,}, 0}, + + {UB6470_REG_D_1BYTE, 0x34, {0xC9,}, 0}, + + {UB6470_REG_D_1BYTE, 0x36, {0x40,}, 0}, + + {UB6470_REG_D_1BYTE, 0x38, {0xCF,}, 0}, + + {UB6470_REG_D_1BYTE, 0x3A, {0xCF,}, 0}, + + {UB6470_REG_D_1BYTE, 0x20, {0xCF,}, 0}, + {UB6470_REG_D_1BYTE, 0x21, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x23, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x23, {0xCF,}, 0}, + + {UB6470_REG_D_1BYTE, 0x24, {0x00,}, 0}, + + {UB6470_REG_D_1BYTE, 0x42, {0x01,}, 0}, + {UB6470_REG_D_1BYTE, 0x43, {0x7C,}, 0}, + {UB6470_REG_D_1BYTE, 0x44, {0x20,}, 0}, + {UB6470_REG_D_1BYTE, 0x45, {0x03,}, 0}, + {UB6470_REG_D_1BYTE, 0x46, {0x1F,}, 0}, + {UB6470_REG_D_1BYTE, 0x47, {0x03,}, 0}, + {UB6470_REG_D_1BYTE, 0x48, {0x1A,}, 0}, + {UB6470_REG_D_1BYTE, 0x49, {0x03,}, 0}, + {UB6470_REG_D_1BYTE, 0x4A, {0x11,}, 0}, + {UB6470_REG_D_1BYTE, 0x53, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x56, {0x32,}, 0}, + {UB6470_REG_D_1BYTE, 0x58, {0x0E,}, 0}, + {UB6470_REG_D_1BYTE, 0x7F, {0x68,}, 0}, + + {UB6470_REG_D_1BYTE, 0x0E, {0x01,}, 0}, + + {UB6470_REG_D_1BYTE, 0x52, {0x10,}, 0}, + + {UB6470_REG_D_1BYTE, 0x41, {0xE4,}, 0}, + + {UB6470_REG_D_1BYTE, 0x40, {0x03,}, 0}, + + {UB6470_REG_D_1BYTE, 0x29, {0x0C,}, 0}, + + {UB6470_REG_D_1BYTE, 0x2A, {0xCC,}, 0}, + {UB6470_REG_D_1BYTE, 0x2B, {0x00,}, 0}, + + /* + //REG_IvDisEn = 0x0000 + + + //PLL Setting + {UB6470_REG_D_1BYTE, 0x04, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x05, {0x3F,}, 0}, + {UB6470_REG_D_1BYTE, 0x03, {0x01,}, 0}, + + //Power Down On/Off + {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x01, {0x00,}, 0}, + +//DRC Filter Disable Setting + {UB6470_REG_D_1BYTE, 0x2F, {0x00,}, 0}, + +//EQ Disable Setting + {UB6470_REG_D_1BYTE, 0x25, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x26, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x27, {0x00,}, 0}, + {UB6470_REG_D_1BYTE, 0x28, {0x00,}, 0}, + +//Dynamic Boost Disable + {UB6470_REG_D_1BYTE, 0x6B, {0x00,}, 0}, + +//Audio IF Page Setting + +//SDIO Format1 Setting + {UB6470_REG_D_1BYTE, 0x10, {0xDC,}, 0}, + +//SDIO Format2 Setting + {UB6470_REG_D_1BYTE, 0x11, {0x50,}, 0}, + +//SDO Enable Setting + {UB6470_REG_D_1BYTE, 0x13, {0x00,}, 0}, + +//Mixer Page Setting + +//Tuning need by h/w lab +//Input L to OutPut L Mixer +{UB6470_REG_D_1BYTE, 0x20, {0xCF,}, 0}, + +//Input R to OutPut L Mixer = Mute +{UB6470_REG_D_1BYTE, 0x21, {0x00,}, 0}, + +//Input L to OutPut R Mixer = Mute +{UB6470_REG_D_1BYTE, 0x22, {0x00,}, 0}, + +//Input R to OutPut R Mixer +{UB6470_REG_D_1BYTE, 0x23, {0xCF,}, 0}, + +//Mixer Polarity Setting +{UB6470_REG_D_1BYTE, 0x24, {0x00,}, 0}, + +//Speaker Left Volume = 0.000 +{UB6470_REG_D_1BYTE, 0x2C, {0xCF,}, 0}, + +//Speaker Right Volume = 0.000 +{UB6470_REG_D_1BYTE, 0x2D, {0xCF,}, 0}, + +//Headphone Left Volume = -6.000 +{UB6470_REG_D_1BYTE, 0x6E, {0xC3,}, 0}, + +//Headphone Right Volume = -6.000 +{UB6470_REG_D_1BYTE, 0x6F, {0xC3,}, 0}, + + +//Master/Fine Volume = 5.0000 +{UB6470_REG_D_1BYTE, 0x2E, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x2A, {0xCC,}, 0}, +{UB6470_REG_D_1BYTE, 0x2B, {0x00,}, 0}, + + +// Errro Monitoring Auto Clear +{UB6470_REG_D_1BYTE, 0x0E, {0x00,}, 0}, + +//Output Control Page Setting + +//PWM Output Mapping +{UB6470_REG_D_1BYTE, 0x41, {0xE4,}, 0}, + + +//PWM SP Setting +{UB6470_REG_D_1BYTE, 0x44, {0x20,}, 0}, + + +//PWM SP Min Pulse +{UB6470_REG_D_1BYTE, 0x45, {0x03,}, 0}, + + +//PWM Left Initial Pulse +{UB6470_REG_D_1BYTE, 0x46, {0x13,}, 0}, + +//PWM Left BD Mode Offset +{UB6470_REG_D_1BYTE, 0x47, {0x0A,}, 0}, + +//PWM Right Initial Pulse +{UB6470_REG_D_1BYTE, 0x48, {0x1F,}, 0}, + +//PWM Right BD Mode Offset +{UB6470_REG_D_1BYTE, 0x49, {0x03,}, 0}, + +//PWM BD Mode Offset End +{UB6470_REG_D_1BYTE, 0x4A, {0x06,}, 0}, + + +//Power Stage Recovery Time +{UB6470_REG_D_1BYTE, 0x51, {0xC0,}, 0}, + + +//Power Stage Error Count Mode +{UB6470_REG_D_1BYTE, 0x52, {0x10,}, 0}, + + +//Headphone Mute Control +{UB6470_REG_D_1BYTE, 0x4E, {0x11,}, 0}, + +//Headphone Phase Control +{UB6470_REG_D_1BYTE, 0x5D, {0x88,}, 0}, + + +//External Error Effectr +{UB6470_REG_D_1BYTE, 0x53, {0x01,}, 0}, + + +//Mute When Power Stage Error +{UB6470_REG_D_1BYTE, 0x50, {0x00,}, 0}, + +//Power Stage Monitor1 +{UB6470_REG_D_1BYTE, 0x5E, {0x00,}, 0}, + +//Power Stage Monitor2 +{UB6470_REG_D_1BYTE, 0x5F, {0x00,}, 0}, + +//Left Clipping Level = 24.0dB +{UB6470_REG_D_1BYTE, 0x70, {0xFF,}, 0}, + +//Right Clipping Level = 24.0dB +{UB6470_REG_D_1BYTE, 0x71, {0xFF,}, 0}, + +//PWM DC Cut Filter Setting +{UB6470_REG_D_1BYTE, 0x42, {0x01,}, 0}, + +//PWM SNR/THD Setting +{UB6470_REG_D_1BYTE, 0x43, {0x9C,}, 0}, +{UB6470_REG_D_1BYTE, 0x56, {0x50,}, 0}, +{UB6470_REG_D_1BYTE, 0x58, {0x10,}, 0}, +{UB6470_REG_D_1BYTE, 0x50, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x7F, {0x97,}, 0}, + +//MOCS Page Setting + +//MOCS Setting(Offset, Min, Gain) +{UB6470_REG_D_1BYTE, 0x00, {0x01,}, 0}, +{UB6470_REG_D_4BYTE, 0xCC, {0x00, 0x10, 0x00, 0x00}, 0}, +{UB6470_REG_D_4BYTE, 0xCD, {0x00, 0x28, 0x00, 0x00}, 0}, +{UB6470_REG_D_4BYTE, 0xCE, {0x00, 0x00, 0x00, 0x80}, 0}, +{UB6470_REG_D_4BYTE, 0xCF, {0x00, 0x04, 0x00, 0x00}, 0}, +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, + + +//MOCS Hold Delay +{UB6470_REG_D_1BYTE, 0x75, {0x20,}, 0}, + + +//MOCS Output Control +{UB6470_REG_D_1BYTE, 0x74, {0x00,}, 0}, + + +//DRC Page Setting + +//DRC Enable Setting +{UB6470_REG_D_1BYTE, 0x30, {0x00,}, 0}, + +//DRC1 Threshold = 2.5dB +{UB6470_REG_D_1BYTE, 0x31, {0xD4,}, 0}, + +//DRC2 Threshold = 0.0dB +{UB6470_REG_D_1BYTE, 0x32, {0xCF,}, 0}, + + + +//Compress Enable Setting +{UB6470_REG_D_1BYTE, 0x33, {0x00,}, 0}, + +//Cmp1 Threshold = -3.0dB +{UB6470_REG_D_1BYTE, 0x34, {0xC9,}, 0}, + +//Cmp2 Threshold = -3.0dB +{UB6470_REG_D_1BYTE, 0x35, {0xC9,}, 0}, + +//Cmp1 Slop = 0.500 +{UB6470_REG_D_1BYTE, 0x36, {0x40,}, 0}, + +//Cmp2 Slop = 1.000 +{UB6470_REG_D_1BYTE, 0x37, {0x80,}, 0}, + + + +//Left DRC1 Mixer Level = 0.0dB +{UB6470_REG_D_1BYTE, 0x38, {0xCF,}, 0}, + +//Left DRC2 Mixer Level = Mute +{UB6470_REG_D_1BYTE, 0x39, {0x00,}, 0}, + +//Right DRC1 Mixer Level = 0.0dB +{UB6470_REG_D_1BYTE, 0x3A, {0xCF,}, 0}, + +//Right DRC2 Mixer Level = Mute +{UB6470_REG_D_1BYTE, 0x3B, {0x00,}, 0}, + +//DRC1 Attack/Release Setting +{UB6470_REG_D_4BYTE, 0xF8, {0x00, 0x00, 0x04, 0x18}, 0}, +{UB6470_REG_D_4BYTE, 0xF9, {0x00, 0x3F, 0xFB, 0xE7}, 0}, +{UB6470_REG_D_4BYTE, 0xFA, {0x00, 0x3F, 0xF4, 0x2C}, 0}, +{UB6470_REG_D_4BYTE, 0xFB, {0x00, 0x40, 0x00, 0x40}, 0}, + + +//DRC2 Attack/Release Setting +{UB6470_REG_D_4BYTE, 0xFC, {0x00, 0x00, 0x04, 0x18}, 0}, +{UB6470_REG_D_4BYTE, 0xFD, {0x00, 0x3F, 0xFB, 0xE7}, 0}, +{UB6470_REG_D_4BYTE, 0xFE, {0x00, 0x3F, 0x5C, 0x28}, 0}, +{UB6470_REG_D_4BYTE, 0xFF, {0x00, 0x40, 0x00, 0x40}, 0}, + + +//Page 1 Setting +{UB6470_REG_D_1BYTE, 0x00, {0x01,}, 0}, +//EQ Filter Checksum Setting +{UB6470_REG_D_4BYTE, 0xD0, {0x00, 0x0F, 0x85, 0x9E}, 0}, +//Page 0 Setting +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, + + + + +//Page 1 Setting +{UB6470_REG_D_1BYTE, 0x00, {0x01,}, 0}, +//DRC Filter Checksum Setting +{UB6470_REG_D_4BYTE, 0xD1, {0x00, 0x00, 0x00, 0x00}, 0}, +//Page 0 Setting +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, + + + + +//EQ Mode +{UB6470_REG_D_1BYTE, 0x67, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x68, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x69, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x6A, {0x00,}, 0}, + +//Dynamic Boost Page + +//Boost Threshold = -3.0 +{UB6470_REG_D_1BYTE, 0x6C, {0xC9,}, 0}, + +//Boost Slope = 0.500 +{UB6470_REG_D_1BYTE, 0x6D, {0x40,}, 0}, + + +//Dynamic Boost Attack/Release Setting +{UB6470_REG_D_4BYTE, 0xF6, {0x00, 0x3F, 0x5C, 0x28}, 0}, +{UB6470_REG_D_4BYTE, 0xF7, {0x00, 0x40, 0x00, 0x40}, 0}, + +//Boost Gain = 18.0 +{UB6470_REG_D_4BYTE, 0xF3, {0x00, 0x7F, 0xFF, 0xFF}, 0}, + +//Response Gain = -40 + +//Delay +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x00, {0x00,}, 0}, + +//Boost Enable = OFF, EQ Adding = ON, EQ No = 1 +{UB6470_REG_D_1BYTE, 0x6B, {0x40,}, 0}, + +//DRC Filter Enable Setting +{UB6470_REG_D_1BYTE, 0x2F, {0x00,}, 0}, +//EQ Enable Setting +{UB6470_REG_D_1BYTE, 0x25, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x26, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x27, {0x00,}, 0}, +{UB6470_REG_D_1BYTE, 0x28, {0x00,}, 0}, + +//PWM Speaker/Headphone Select +{UB6470_REG_D_1BYTE, 0x57, {0x00,}, 0}, + + +//PWM Output Enable On/Off - default stereo +{UB6470_REG_D_1BYTE, 0x40, {0x03,}, 0}, + + +//DSP Mute On/Off +{UB6470_REG_D_1BYTE, 0x29, {0x00,}, 0}, + +//Monitoring Register Enable +{UB6470_REG_D_1BYTE, 0x0E, {0x01,}, 0} +//End identifier +//{END_IDENTIFIER, 0x00} +*/ +}; + +t_codec_init_script_entry codec_init_mute_on_script[] = { + {UB6470_REG_D_1BYTE, 0x2A, {0x00,}, 0} +}; + +t_codec_init_script_entry codec_set_master_volume_script[] = { + {UB6470_REG_D_1BYTE, 0x2A, {0x03,}, 0}, + {UB6470_REG_D_1BYTE, 0x2A, {0xFF,}, 0} +}; + + +#endif /* CONFIG_AUDIO_UB6470 */ +#endif /* __DRIVERS_AUDIO_UB6470SCRIPTS_H */ diff --git a/os/include/tinyara/audio/ub6470.h b/os/include/tinyara/audio/ub6470.h new file mode 100644 index 0000000000..35a29f4a99 --- /dev/null +++ b/os/include/tinyara/audio/ub6470.h @@ -0,0 +1,227 @@ +/**************************************************************************** + * + * Copyright 2022 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +#ifndef __INCLUDE_TINYARA_AUDIO_UB6470_H +#define __INCLUDE_TINYARA_AUDIO_UB6470_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include +#include + +#ifdef CONFIG_AUDIO_UB6470 + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************ + * + * CONFIG_AUDIO_UB6470 - Enables UB6470 support + * CONFIG_UB6470_INITVOLUME - The initial volume level in the range {0..1000} + * CONFIG_UB6470_INFLIGHT - Maximum number of buffers that the UB6470 driver + * will send to the I2S driver before any have completed. + * CONFIG_UB6470_MSG_PRIO - Priority of messages sent to the UB6470 worker + * thread. + * CONFIG_UB6470_BUFFER_SIZE - Preferred buffer size + * CONFIG_UB6470_NUM_BUFFERS - Preferred number of buffers + * CONFIG_UB6470_WORKER_STACKSIZE - Stack size to use when creating the + * UB6470 worker thread. + */ + +/* Pre-requisites */ + +#ifndef CONFIG_AUDIO +#error CONFIG_AUDIO is required for audio subsystem support +#endif + +#ifndef CONFIG_I2S +#error CONFIG_I2S is required by the UB6470 driver +#endif + +#ifndef CONFIG_I2C +#error CONFIG_I2C is required by the UB6470 driver +#endif + +#ifndef CONFIG_SCHED_WORKQUEUE +#error CONFIG_SCHED_WORKQUEUE is required by the UB6470 driver +#endif + +/* Default configuration values */ + +#ifndef CONFIG_UB6470_INITVOLUME +#define CONFIG_UB6470_INITVOLUME 250 +#endif + +#ifndef CONFIG_UB6470_INFLIGHT +#define CONFIG_UB6470_INFLIGHT 2 +#endif + +#if CONFIG_UB6470_INFLIGHT > 255 +#error CONFIG_UB6470_INFLIGHT must fit in a uint8_t +#endif + +#ifndef CONFIG_UB6470_MSG_PRIO +#define CONFIG_UB6470_MSG_PRIO 1 +#endif + +#ifndef CONFIG_UB6470_BUFFER_SIZE +#define CONFIG_UB6470_BUFFER_SIZE 8192 +#endif + +#ifndef CONFIG_UB6470_NUM_BUFFERS +#define CONFIG_UB6470_NUM_BUFFERS 4 +#endif + +#ifndef CONFIG_UB6470_WORKER_STACKSIZE +#define CONFIG_UB6470_WORKER_STACKSIZE 768 +#endif + +/* Helper macros ************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ +/* This is the type of the UB6470 interrupt handler. The lower level code + * will intercept the interrupt and provide the upper level with the private + * data that was provided when the interrupt was attached. + */ + +struct ub6470_lower_s; /* Forward reference. Defined below */ + +typedef CODE int (*ub6470_handler_t)(FAR const struct ub6470_lower_s *lower, FAR void *arg); + +/* A reference to a structure of this type must be passed to the UB6470 + * driver. This structure provides information about the configuration + * of the UB6470 and provides some board-specific hooks. + * + * Memory for this structure is provided by the caller. It is not copied + * by the driver and is presumed to persist while the driver is active. + */ + +struct ub6470_lower_s { + /* I2C characterization */ + struct i2c_config_s i2c_config; /* I2C config should be bere */ + + /* Clocking is provided via MCLK. The UB6470 driver will need to know + * the frequency of MCLK in order to generate the correct bitrates. + */ + uint32_t mclk; /* Master clock frequency. In slave mode never used */ + + CODE void (*control_hw_reset)(bool active); + CODE void (*control_powerdown)(bool enter_powerdown); +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: ub6470_initialize + * + * Description: + * Initialize the UB6470 device. + * + * Input Parameters: + * i2c - An I2C driver instance + * i2s - An I2S driver instance + * lower - Persistent board configuration data + * + * Returned Value: + * A new lower half audio interface for the UB6470 device is returned on + * success; NULL is returned on failure. + * + ****************************************************************************/ + +struct i2c_dev_s; /* Forward reference. Defined in include/tinyara ... */ +struct i2s_dev_s; /* Forward reference. Defined in include/tinyara ... */ +struct audio_lowerhalf_s; /* Forward reference. Defined in tinyara/audio/audio.h */ + +FAR struct audio_lowerhalf_s *ub6470_initialize(struct i2c_dev_s *i2c, FAR struct i2s_dev_s *i2s, FAR struct ub6470_lower_s *lower); + +/**************************************************************************** + * Name: ub6470_dump_registers + * + * Description: + * Dump the contents of all UB6470 registers to the syslog device + * + * Input Parameters: + * dev - The device instance returned by ub6470_initialize + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#ifdef CONFIG_UB6470_REGDUMP +void ub6470_dump_registers(FAR struct audio_lowerhalf_s *dev, FAR const char *msg); // not implemented for tas +#else +/* This eliminates the need for any conditional compilation in the + * including file. + */ + +#define ub6470_dump_registers(d, m) +#endif + +/**************************************************************************** + * Name: ub6470_clock_analysis + * + * Description: + * Analyze the settings in the clock chain and dump to syslog. + * + * Input Parameters: + * dev - The device instance returned by ub6470_initialize + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#ifdef CONFIG_UB6470_CLKDEBUG +void ub6470_clock_analysis(FAR struct audio_lowerhalf_s *dev, FAR const char *msg); // not implemented for tas +#else +/* This eliminates the need for any conditional compilation in the + * including file. + */ + +#define ub6470_clock_analysis(d, m) +#endif + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_AUDIO_UB6470 */ +#endif /* __INCLUDE_TINYARA_AUDIO_UB6470_H */