diff --git a/configure b/configure index a02b8f93b97b1..36a89cf4e798c 100755 --- a/configure +++ b/configure @@ -774,6 +774,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -995,6 +996,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' @@ -1247,6 +1249,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1384,7 +1395,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1537,6 +1548,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -20926,34 +20938,8 @@ else $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. -ac_x_includes=no -ac_x_libraries=no -# Do we need to do anything special at all? -ac_save_LIBS=$LIBS -LIBS="-lX11 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -XrmInitialize () - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - # We can compile and link X programs with no special options. - ac_x_includes= - ac_x_libraries= -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS="$ac_save_LIBS" -# If that didn't work, only try xmkmf and filesystem searches -# for native compilation. -if test x"$ac_x_includes" = xno && test "$cross_compiling" = no; then : - rm -f -r conftest.dir +ac_x_includes=no ac_x_libraries=no +rm -f -r conftest.dir if mkdir conftest.dir; then cd conftest.dir cat >Imakefile <<'_ACEOF' @@ -20992,7 +20978,7 @@ _ACEOF rm -f -r conftest.dir fi - # Standard set of common directories for X headers. +# Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include @@ -21019,8 +21005,6 @@ ac_x_header_dirs=' /usr/local/include/X11R5 /usr/local/include/X11R4 -/opt/X11/include - /usr/X386/include /usr/x386/include /usr/XFree86/include/X11 @@ -21094,17 +21078,15 @@ rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no -fi -# Record the results. case $ac_x_includes,$ac_x_libraries in #( - no,* | *,no | *\'*) : + no,* | *,no | *\'*) # Didn't find X, or a directory has "'" in its name. - ac_cv_have_x="have_x=no" ;; #( - *) : + ac_cv_have_x="have_x=no";; #( + *) # Record where we found X for the cache. ac_cv_have_x="have_x=yes\ ac_x_includes='$ac_x_includes'\ - ac_x_libraries='$ac_x_libraries'" ;; + ac_x_libraries='$ac_x_libraries'" esac fi ;; #( @@ -23131,6 +23113,39 @@ $as_echo "#define SDL_AUDIO_DRIVER_QSA 1" >>confdefs.h fi } +CheckMMiyooVideo() +{ + if test x$enable_video = xyes; then + +$as_echo "#define SDL_VIDEO_DRIVER_MMIYOO 1" >>confdefs.h + + +$as_echo "#define SDL_VIDEO_RENDER_MMIYOO 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/video/mmiyoo/*.c" + have_video=yes + EXTRA_CFLAGS="$EXTRA_CFLAGS -fPIC -mcpu=cortex-a7 -mfpu=neon-vfpv4 -O3 -I/opt/mmiyoo/arm-buildroot-linux-gnueabihf/sysroot/usr/include/SDL2" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L. -lEGL -lGLESv2 -lrt -lSDL2_image -lSDL2_ttf -ljson-c" + SUMMARY_video="${SUMMARY_video} mmiyoo" + fi +} + +CheckMMiyooAudio() +{ + if test x$enable_audio = xyes; then + +$as_echo "#define SDL_AUDIO_DRIVER_MMIYOO 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/audio/mmiyoo/*.c" + have_audio=yes + if test x$HOST = xarm-linux; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMMIYOO -mcpu=cortex-a7 -mfpu=neon-vfpv4 -O3" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Lmmiyoo/libs -lmi_ao -lshmvar -lmi_common -lmi_sys -lmi_gfx" + fi + SUMMARY_audio="${SUMMARY_audio} mmiyoo" + fi +} + # Check whether --enable-video-opengl was given. if test "${enable_video_opengl+set}" = set; then : enableval=$enable_video_opengl; @@ -25766,6 +25781,13 @@ $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h CheckQNXVideo ;; esac + + case "$MOD" in + *mmiyoo*) ARCH=mmiyoo + CheckMMiyooVideo + ;; + esac + CheckVisibilityHidden CheckDeclarationAfterStatement CheckDummyVideo @@ -25882,6 +25904,9 @@ $as_echo "#define SDL_AUDIO_DRIVER_AAUDIO 1" >>confdefs.h nto) CheckQNXAudio ;; + mmiyoo) + CheckMMiyooAudio + ;; esac fi # Set up files for the joystick library @@ -25913,6 +25938,13 @@ $as_echo "#define SDL_JOYSTICK_ANDROID 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" have_joystick=yes ;; + mmiyoo) + +$as_echo "#define SDL_JOYSTICK_MMIYOO 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/joystick/mmiyoo/*.c" + have_joystick=yes + ;; esac fi # Set up files for the haptic library diff --git a/configure.ac b/configure.ac index 3c1c6c858380e..765e78d5ffb69 100644 --- a/configure.ac +++ b/configure.ac @@ -2383,6 +2383,33 @@ CheckQNXAudio() fi } +CheckMMiyooVideo() +{ + if test x$enable_video = xyes; then + AC_DEFINE(SDL_VIDEO_DRIVER_MMIYOO, 1, [ ]) + AC_DEFINE(SDL_VIDEO_RENDER_MMIYOO, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/video/mmiyoo/*.c" + have_video=yes + EXTRA_CFLAGS="$EXTRA_CFLAGS -fPIC -mcpu=cortex-a7 -mfpu=neon-vfpv4 -O3 -I/opt/mmiyoo/arm-buildroot-linux-gnueabihf/sysroot/usr/include/SDL2" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L. -lEGL -lGLESv2 -lrt -lSDL2_image -lSDL2_ttf -ljson-c" + SUMMARY_video="${SUMMARY_video} mmiyoo" + fi +} + +CheckMMiyooAudio() +{ + if test x$enable_audio = xyes; then + AC_DEFINE(SDL_AUDIO_DRIVER_MMIYOO, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/audio/mmiyoo/*.c" + have_audio=yes + if test x$HOST = xarm-linux; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMMIYOO -mcpu=cortex-a7 -mfpu=neon-vfpv4 -O3" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Lmmiyoo/libs -lmi_ao -lshmvar -lmi_common -lmi_sys -lmi_gfx" + fi + SUMMARY_audio="${SUMMARY_audio} mmiyoo" + fi +} + dnl Check to see if OpenGL support is desired AC_ARG_ENABLE(video-opengl, [AS_HELP_STRING([--enable-video-opengl], [include OpenGL support [default=yes]])], @@ -3665,6 +3692,13 @@ case "$host" in CheckQNXVideo ;; esac + + case "$MOD" in + *mmiyoo*) ARCH=mmiyoo + CheckMMiyooVideo + ;; + esac + CheckVisibilityHidden CheckDeclarationAfterStatement CheckDummyVideo @@ -3769,6 +3803,9 @@ case "$host" in nto) CheckQNXAudio ;; + mmiyoo) + CheckMMiyooAudio + ;; esac fi # Set up files for the joystick library @@ -3794,6 +3831,11 @@ case "$host" in SOURCES="$SOURCES $srcdir/src/joystick/steam/*.c" have_joystick=yes ;; + mmiyoo) + AC_DEFINE(SDL_JOYSTICK_MMIYOO, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/joystick/mmiyoo/*.c" + have_joystick=yes + ;; esac fi # Set up files for the haptic library diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 0d981b410cdbf..44cc955f9077a 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -477,4 +477,9 @@ /* Enable dynamic libsamplerate support */ #undef SDL_LIBSAMPLERATE_DYNAMIC +#undef SDL_VIDEO_DRIVER_MMIYOO +#undef SDL_VIDEO_RENDER_MMIYOO +#undef SDL_AUDIO_DRIVER_MMIYOO +#undef SDL_JOYSTICK_MMIYOO + #endif /* SDL_config_h_ */ diff --git a/run.sh b/run.sh new file mode 100755 index 0000000000000..fc3ded9953735 --- /dev/null +++ b/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash +export MOD=mmiyoo +export CROSS=/opt/mmiyoo/bin/arm-linux-gnueabihf- +export CC=${CROSS}gcc +export AR=${CROSS}ar +export AS=${CROSS}as +export LD=${CROSS}ld +export CXX=${CROSS}g++ +export HOST=arm-linux + +echo "Building SDL2 for Miyoo Mini / Miyoo Mini Plus" +if [ ! -z "$1" ] && [ "$1" == "config" ]; then + ./autogen.sh + ./configure --disable-joystick-virtual --disable-sensor --disable-power --disable-alsa --disable-diskaudio --disable-video-x11 --disable-video-wayland --disable-video-kmsdrm --disable-video-vulkan --disable-dbus --disable-ime --disable-fcitx --disable-hidapi --disable-pulseaudio --disable-sndio --disable-libudev --disable-jack --disable-video-opengl --disable-video-opengles --disable-video-opengles2 --disable-oss --disable-dummyaudio --disable-video-dummy --host=${HOST} +fi + +make -j4 V=99 diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 849416c83e284..9bf0adefdcbed 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -121,6 +121,9 @@ static const AudioBootStrap *const bootstrap[] = { #endif #if SDL_AUDIO_DRIVER_DUMMY &DUMMYAUDIO_bootstrap, +#endif +#if SDL_AUDIO_DRIVER_MMIYOO + &MMIYOOAUDIO_bootstrap, #endif NULL }; diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 6c602f07b655c..69a372d40c8a1 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -212,6 +212,7 @@ extern AudioBootStrap PSPAUDIO_bootstrap; extern AudioBootStrap VITAAUD_bootstrap; extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap; extern AudioBootStrap OS2AUDIO_bootstrap; +extern AudioBootStrap MMIYOOAUDIO_bootstrap; #endif /* SDL_sysaudio_h_ */ diff --git a/src/audio/mmiyoo/SDL_audio_mmiyoo.c b/src/audio/mmiyoo/SDL_audio_mmiyoo.c new file mode 100644 index 0000000000000..5219341c29579 --- /dev/null +++ b/src/audio/mmiyoo/SDL_audio_mmiyoo.c @@ -0,0 +1,164 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_AUDIO_DRIVER_MMIYOO + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SDL_timer.h" +#include "SDL_audio.h" +#include "SDL_audio_mmiyoo.h" +#include "../SDL_audio_c.h" +#include "../SDL_audiodev_c.h" + +#define MI_AUDIO_SAMPLE_PER_FRAME 768 + +#if defined(MMIYOO) +#include "mi_sys.h" +#include "mi_common_datatype.h" +#include "mi_ao.h" + +static MI_AUDIO_Attr_t stSetAttr; +static MI_AUDIO_Attr_t stGetAttr; +static MI_AO_CHN AoChn = 0; +static MI_AUDIO_DEV AoDevId = 0; +#endif + +static void MMIYOO_CloseDevice(_THIS) +{ + SDL_free(this->hidden->mixbuf); + SDL_free(this->hidden); +#if defined(MMIYOO) + MI_AO_DisableChn(AoDevId, AoChn); + MI_AO_Disable(AoDevId); +#endif +} + +static int MMIYOO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) +{ +#if defined(MMIYOO) + MI_S32 miret = 0; + MI_S32 s32SetVolumeDb = 0; + MI_S32 s32GetVolumeDb = 0; + MI_SYS_ChnPort_t stAoChn0OutputPort0; +#endif + + this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc((sizeof * this->hidden)); + if(this->hidden == NULL) { + return SDL_OutOfMemory(); + } + SDL_zerop(this->hidden); + + this->hidden->mixlen = this->spec.samples * 2 * this->spec.channels; + this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); + if(this->hidden->mixbuf == NULL) { + return SDL_OutOfMemory(); + } + +#if defined(MMIYOO) + stSetAttr.eBitwidth = E_MI_AUDIO_BIT_WIDTH_16; + stSetAttr.eWorkmode = E_MI_AUDIO_MODE_I2S_MASTER; + stSetAttr.u32FrmNum = 6; + stSetAttr.u32PtNumPerFrm = this->spec.samples; + stSetAttr.u32ChnCnt = this->spec.channels; + stSetAttr.eSoundmode = this->spec.channels == 2 ? E_MI_AUDIO_SOUND_MODE_STEREO : E_MI_AUDIO_SOUND_MODE_MONO; + stSetAttr.eSamplerate = (MI_AUDIO_SampleRate_e)this->spec.freq; + printf("%s, freq:%d sample:%d channels:%d\n", __func__, this->spec.freq, this->spec.samples, this->spec.channels); + miret = MI_AO_SetPubAttr(AoDevId, &stSetAttr); + if(miret != MI_SUCCESS) { + printf("%s, failed to set PubAttr\n", __func__); + return -1; + } + miret = MI_AO_GetPubAttr(AoDevId, &stGetAttr); + if(miret != MI_SUCCESS) { + printf("%s, failed to get PubAttr\n", __func__); + return -1; + } + miret = MI_AO_Enable(AoDevId); + if(miret != MI_SUCCESS) { + printf("%s, failed to enable AO\n", __func__); + return -1; + } + miret = MI_AO_EnableChn(AoDevId, AoChn); + if(miret != MI_SUCCESS) { + printf("%s, failed to enable Channel\n", __func__); + return -1; + } + miret = MI_AO_SetVolume(AoDevId, s32SetVolumeDb); + if(miret != MI_SUCCESS) { + printf("%s, failed to set Volume\n", __func__); + return -1; + } + MI_AO_GetVolume(AoDevId, &s32GetVolumeDb); + stAoChn0OutputPort0.eModId = E_MI_MODULE_ID_AO; + stAoChn0OutputPort0.u32DevId = AoDevId; + stAoChn0OutputPort0.u32ChnId = AoChn; + stAoChn0OutputPort0.u32PortId = 0; + MI_SYS_SetChnOutputPortDepth(&stAoChn0OutputPort0, 12, 13); +#endif + return 0; +} + +static void MMIYOO_PlayDevice(_THIS) +{ +#if defined(MMIYOO) + MI_AUDIO_Frame_t aoTestFrame; + + aoTestFrame.eBitwidth = stGetAttr.eBitwidth; + aoTestFrame.eSoundmode = stGetAttr.eSoundmode; + aoTestFrame.u32Len = this->hidden->mixlen; + aoTestFrame.apVirAddr[0] = this->hidden->mixbuf; + aoTestFrame.apVirAddr[1] = NULL; + MI_AO_SendFrame(AoDevId, AoChn, &aoTestFrame, 1); +#endif +} + +static Uint8 *MMIYOO_GetDeviceBuf(_THIS) +{ + return (this->hidden->mixbuf); +} + +static int MMIYOO_Init(SDL_AudioDriverImpl *impl) +{ + impl->OpenDevice = MMIYOO_OpenDevice; + impl->PlayDevice = MMIYOO_PlayDevice; + impl->GetDeviceBuf = MMIYOO_GetDeviceBuf; + impl->CloseDevice = MMIYOO_CloseDevice; + impl->OnlyHasDefaultOutputDevice = 1; + return 1; +} + +AudioBootStrap MMIYOOAUDIO_bootstrap = {"MMIYOO", "MMIYOO AUDIO DRIVER", MMIYOO_Init, 0}; + +#endif + diff --git a/src/audio/mmiyoo/SDL_audio_mmiyoo.h b/src/audio/mmiyoo/SDL_audio_mmiyoo.h new file mode 100644 index 0000000000000..480a84ad381da --- /dev/null +++ b/src/audio/mmiyoo/SDL_audio_mmiyoo.h @@ -0,0 +1,46 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef __SDL_AUDIO_MMIYOO_H__ +#define __SDL_AUDIO_MMIYOO_H__ + +#include "../SDL_sysaudio.h" + +#define _THIS SDL_AudioDevice *this + +struct SDL_PrivateAudioData +{ + /* The file descriptor for the audio device */ + int audio_fd; + + /* Raw mixing buffer */ + Uint8 *mixbuf; + int mixlen; +}; +#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ + +#endif + diff --git a/src/audio/mmiyoo/mi_aio_datatype.h b/src/audio/mmiyoo/mi_aio_datatype.h new file mode 100755 index 0000000000000..460da7679f024 --- /dev/null +++ b/src/audio/mmiyoo/mi_aio_datatype.h @@ -0,0 +1,219 @@ +/* SigmaStar trade secret */ +/* Copyright (c) [2019~2020] SigmaStar Technology. +All rights reserved. + +Unless otherwise stipulated in writing, any and all information contained +herein regardless in any format shall remain the sole proprietary of +SigmaStar and be kept in strict confidence +(SigmaStar Confidential Information) by the recipient. +Any unauthorized act including without limitation unauthorized disclosure, +copying, use, reproduction, sale, distribution, modification, disassembling, +reverse engineering and compiling of the contents of SigmaStar Confidential +Information is unlawful and strictly prohibited. SigmaStar hereby reserves the +rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_AIO_DEP_DATATYPE_H_ +#define _MI_AIO_DEP_DATATYPE_H_ + +#include "mi_sys_datatype.h" + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= +#define MI_AUDIO_MAX_CHN_NUM (16) + + + +//============================================================================= +// Data type definition +//============================================================================= +typedef enum +{ + E_MI_AUDIO_ALGORITHM_MODE_DEFAULT, + E_MI_AUDIO_ALGORITHM_MODE_USER, + E_MI_AUDIO_ALGORITHM_MODE_MUSIC, + E_MI_AUDIO_ALGORITHM_MODE_INVALID, +} MI_AUDIO_AlgorithmMode_e; + +typedef enum +{ + E_MI_AUDIO_SAMPLE_RATE_8000 = 8000, /* 8kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_11025 = 11025, /* 11.025kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_12000 = 12000, /* 12kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_16000 = 16000, /* 16kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_22050 = 22050, /* 22.05kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_24000 = 24000, /* 24kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_32000 = 32000, /* 32kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_44100 = 44100, /* 44.1kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_48000 = 48000, /* 48kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_96000 = 96000, /* 96kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_INVALID, +} MI_AUDIO_SampleRate_e; + +typedef enum +{ + E_MI_AUDIO_BIT_WIDTH_16 = 0, /* 16bit width */ + E_MI_AUDIO_BIT_WIDTH_24 = 1, /* 24bit width */ + E_MI_AUDIO_BIT_WIDTH_MAX, +} MI_AUDIO_BitWidth_e; + +typedef enum +{ + E_MI_AUDIO_MODE_I2S_MASTER, /* I2S master mode */ + E_MI_AUDIO_MODE_I2S_SLAVE, /* I2S slave mode */ + E_MI_AUDIO_MODE_TDM_MASTER, /* TDM master mode */ + E_MI_AUDIO_MODE_TDM_SLAVE, /* TDM slave mode */ + E_MI_AUDIO_MODE_MAX, +} MI_AUDIO_Mode_e; + +typedef enum +{ + E_MI_AUDIO_SOUND_MODE_MONO = 0, /* mono */ + E_MI_AUDIO_SOUND_MODE_STEREO = 1, /* stereo */ + E_MI_AUDIO_SOUND_MODE_QUEUE = 2, /* all data in One chn */ + E_MI_AUDIO_SOUND_MODE_MAX, +} MI_AUDIO_SoundMode_e; + +typedef enum +{ + E_MI_AUDIO_HPF_FREQ_80 = 80, /* 80Hz */ + E_MI_AUDIO_HPF_FREQ_120 = 120, /* 120Hz */ + E_MI_AUDIO_HPF_FREQ_150 = 150, /* 150Hz */ + E_MI_AUDIO_HPF_FREQ_INVALID, +} MI_AUDIO_HpfFreq_e; + +typedef enum +{ + E_MI_AUDIO_NR_SPEED_LOW, + E_MI_AUDIO_NR_SPEED_MID, + E_MI_AUDIO_NR_SPEED_HIGH +} MI_AUDIO_NrSpeed_e; + +typedef enum +{ + E_MI_AUDIO_I2S_FMT_I2S_MSB, + E_MI_AUDIO_I2S_FMT_LEFT_JUSTIFY_MSB, +} MI_AUDIO_I2sFmt_e; + +typedef enum +{ + E_MI_AUDIO_I2S_MCLK_0, //not enable + E_MI_AUDIO_I2S_MCLK_12_288M, //12.288M + E_MI_AUDIO_I2S_MCLK_16_384M, //16.384M + E_MI_AUDIO_I2S_MCLK_18_432M, //18.432M + E_MI_AUDIO_I2S_MCLK_24_576M, //24.576M + E_MI_AUDIO_I2S_MCLK_24M, // 24MHz + E_MI_AUDIO_I2S_MCLK_48M, // 48MHz +} MI_AUDIO_I2sMclk_e; + +typedef struct MI_AUDIO_I2sConfig_s { + MI_AUDIO_I2sFmt_e eFmt; + MI_AUDIO_I2sMclk_e eMclk; + MI_BOOL bSyncClock; //I2s Tx BCLK, Rx BCLK use the same clock source +} MI_AUDIO_I2sConfig_t; + +typedef struct MI_AUDIO_Attr_s { + MI_AUDIO_SampleRate_e eSamplerate; /* sample rate */ + MI_AUDIO_BitWidth_e eBitwidth; /* bitwidth */ + MI_AUDIO_Mode_e eWorkmode; /* I2s master or slave mode */ + MI_AUDIO_SoundMode_e eSoundmode; /* mono or stereo */ + MI_U32 u32FrmNum; /* frame num in buffer */ + MI_U32 u32PtNumPerFrm; /* number of samples */ + MI_U32 u32CodecChnCnt; /* channel number on Codec */ + MI_U32 u32ChnCnt; + union { + MI_AUDIO_I2sConfig_t stI2sConfig; + } WorkModeSetting; + +} MI_AUDIO_Attr_t; + +typedef struct MI_AUDIO_Frame_s { + MI_AUDIO_BitWidth_e eBitwidth; /* audio frame bitwidth */ + MI_AUDIO_SoundMode_e eSoundmode; /* audio frame momo or stereo mode */ + void *apVirAddr[MI_AUDIO_MAX_CHN_NUM]; + MI_U64 u64TimeStamp; /* audio frame timestamp */ + MI_U32 u32Seq; /* audio frame seq */ + MI_U32 u32Len; /* data lenth per channel in frame */ + MI_U32 au32PoolId[2]; + /* Only use for Ai */ + void *apSrcPcmVirAddr[MI_AUDIO_MAX_CHN_NUM]; /* Ai original pcm data from ai channel */ + MI_U32 u32SrcPcmLen; /* length of Ai original pcm data */ + +} MI_AUDIO_Frame_t; + +typedef struct MI_AUDIO_AecFrame_s { + MI_AUDIO_Frame_t stRefFrame; /* aec reference audio frame */ + MI_BOOL bValid; /* whether frame is valid */ +} MI_AUDIO_AecFrame_t; + +typedef struct MI_AUDIO_SaveFileInfo_s { + MI_BOOL bCfg; + MI_U8 szFilePath[256]; + MI_U32 u32FileSize; /*in KB*/ +} MI_AUDIO_SaveFileInfo_t; + +typedef struct MI_AUDIO_HpfConfig_s { + MI_AUDIO_AlgorithmMode_e eMode; + MI_AUDIO_HpfFreq_e eHpfFreq; /*freq to be processed*/ +} MI_AUDIO_HpfConfig_t; + +typedef struct MI_AUDIO_AnrConfig_s { + MI_AUDIO_AlgorithmMode_e eMode; + MI_U32 u32NrIntensity; + MI_U32 u32NrSmoothLevel; + MI_AUDIO_NrSpeed_e eNrSpeed; +} MI_AUDIO_AnrConfig_t; + +typedef struct AgcGainInfo_s { + MI_S32 s32GainMax; + MI_S32 s32GainMin; + MI_S32 s32GainInit; +} AgcGainInfo_t; + +typedef struct MI_AUDIO_AgcConfig_s { + MI_AUDIO_AlgorithmMode_e eMode; + AgcGainInfo_t stAgcGainInfo; + MI_U32 u32DropGainMax; + MI_U32 u32AttackTime; + MI_U32 u32ReleaseTime; + MI_S16 s16Compression_ratio_input[5]; + MI_S16 s16Compression_ratio_output[5]; + MI_S32 s32TargetLevelDb; + MI_S32 s32NoiseGateDb; + MI_U32 u32NoiseGateAttenuationDb; +} MI_AUDIO_AgcConfig_t; + +typedef struct MI_AUDIO_EqConfig_s { + MI_AUDIO_AlgorithmMode_e eMode; + MI_S16 s16EqGainDb[129]; +} MI_AUDIO_EqConfig_t; + +typedef enum +{ + E_MI_AUDIO_G726_MODE_16 = 0, + E_MI_AUDIO_G726_MODE_24, + E_MI_AUDIO_G726_MODE_32, + E_MI_AUDIO_G726_MODE_40, + E_MI_AUDIO_G726_MODE_INVALID, +} MI_AUDIO_G726Mode_e; + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= + + +#endif // _MI_AIO_DEP_DATATYPE_H_ diff --git a/src/audio/mmiyoo/mi_ao.h b/src/audio/mmiyoo/mi_ao.h new file mode 100755 index 0000000000000..3a354e895f72a --- /dev/null +++ b/src/audio/mmiyoo/mi_ao.h @@ -0,0 +1,94 @@ +/* SigmaStar trade secret */ +/* Copyright (c) [2019~2020] SigmaStar Technology. +All rights reserved. + +Unless otherwise stipulated in writing, any and all information contained +herein regardless in any format shall remain the sole proprietary of +SigmaStar and be kept in strict confidence +(SigmaStar Confidential Information) by the recipient. +Any unauthorized act including without limitation unauthorized disclosure, +copying, use, reproduction, sale, distribution, modification, disassembling, +reverse engineering and compiling of the contents of SigmaStar Confidential +Information is unlawful and strictly prohibited. SigmaStar hereby reserves the +rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef __MI_AO_H__ +#define __MI_AO_H__ + +#include "mi_aio_datatype.h" +#include "mi_ao_datatype.h" + +#define AO_MAJOR_VERSION 2 +#define AO_SUB_VERSION 10 +#define MACRO_TO_STR(macro) #macro +#define AO_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_ao_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_ao_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_ao_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_AO_API_VERSION AO_VERSION_STR(AO_MAJOR_VERSION,AO_SUB_VERSION) + +#ifdef __cplusplus +extern "C" { +#endif + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= + + +//============================================================================= +// Data type definition +//============================================================================= + + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= +MI_S32 MI_AO_SetPubAttr(MI_AUDIO_DEV AoDevId, MI_AUDIO_Attr_t *pstAttr); +MI_S32 MI_AO_GetPubAttr(MI_AUDIO_DEV AoDevId, MI_AUDIO_Attr_t *pstAttr); +MI_S32 MI_AO_Enable(MI_AUDIO_DEV AoDevId); +MI_S32 MI_AO_Disable(MI_AUDIO_DEV AoDevId); +MI_S32 MI_AO_EnableChn(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_DisableChn(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_SendFrame(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AUDIO_Frame_t *pstData, MI_S32 s32MilliSec); +MI_S32 MI_AO_EnableReSmp(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AUDIO_SampleRate_e eInSampleRate); +MI_S32 MI_AO_DisableReSmp(MI_AUDIO_DEV AiDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_PauseChn(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_ResumeChn(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_ClearChnBuf(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_QueryChnStat(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_ChnState_t *pstStatus); +MI_S32 MI_AO_SetVolume(MI_AUDIO_DEV AoDevId, MI_S32 s32VolumeDb); +MI_S32 MI_AO_GetVolume(MI_AUDIO_DEV AoDevId, MI_S32 *ps32VolumeDb); +MI_S32 MI_AO_SetMute(MI_AUDIO_DEV AoDevId, MI_BOOL bEnable); +MI_S32 MI_AO_GetMute(MI_AUDIO_DEV AoDevId, MI_BOOL *pbEnable); +MI_S32 MI_AO_ClrPubAttr(MI_AUDIO_DEV AoDevId); +MI_S32 MI_AO_SetVqeAttr(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_VqeConfig_t *pstVqeConfig); +MI_S32 MI_AO_GetVqeAttr(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_VqeConfig_t *pstVqeConfig); +MI_S32 MI_AO_EnableVqe(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_DisableVqe(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_SetAdecAttr(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_AdecConfig_t *pstAdecConfig); +MI_S32 MI_AO_GetAdecAttr(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_AdecConfig_t *pstAdecConfig); +MI_S32 MI_AO_EnableAdec(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_DisableAdec(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_SetChnParam(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_ChnParam_t *pstChnParam); +MI_S32 MI_AO_GetChnParam(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_ChnParam_t *pstChnParam); +MI_S32 MI_AO_SetSrcGain(MI_AUDIO_DEV AoDevId, MI_S32 s32VolumeDb); +#ifdef __cplusplus +} +#endif + +#endif///__MI_AO_H__ diff --git a/src/audio/mmiyoo/mi_ao_datatype.h b/src/audio/mmiyoo/mi_ao_datatype.h new file mode 100755 index 0000000000000..29f4cb383f116 --- /dev/null +++ b/src/audio/mmiyoo/mi_ao_datatype.h @@ -0,0 +1,137 @@ +/* SigmaStar trade secret */ +/* Copyright (c) [2019~2020] SigmaStar Technology. +All rights reserved. + +Unless otherwise stipulated in writing, any and all information contained +herein regardless in any format shall remain the sole proprietary of +SigmaStar and be kept in strict confidence +(SigmaStar Confidential Information) by the recipient. +Any unauthorized act including without limitation unauthorized disclosure, +copying, use, reproduction, sale, distribution, modification, disassembling, +reverse engineering and compiling of the contents of SigmaStar Confidential +Information is unlawful and strictly prohibited. SigmaStar hereby reserves the +rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef __MI_AO_DATATYPE_H__ +#define __MI_AO_DATATYPE_H__ + +#include "mi_common_datatype.h" + +#ifdef __cplusplus +extern "C" { +#endif + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= +#define MI_AO_DEV_NUM_MAX 4 +#define MI_AO_CHAN_NUM_MAX 1 + +#define MI_AO_ERR_INVALID_DEVID (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_DEVID)) +#define MI_AO_ERR_ILLEGAL_PARAM (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_ILLEGAL_PARAM)) +#define MI_AO_ERR_NOT_ENABLED (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_ENABLE)) +#define MI_AO_ERR_NULL_PTR (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NULL_PTR)) +#define MI_AO_ERR_INVALID_CHNID (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_CHNID)) +#define MI_AO_ERR_NOT_CONFIG (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_CONFIG)) +#define MI_AO_ERR_NOT_SUPPORT (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_SUPPORT)) +#define MI_AO_ERR_NOT_PERM (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_PERM)) +#define MI_AO_ERR_NOMEM (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOMEM)) +#define MI_AO_ERR_NOBUF (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOBUF)) +#define MI_AO_ERR_BUF_EMPTY (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUF_EMPTY)) +#define MI_AO_ERR_BUF_FULL (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUF_FULL)) +#define MI_AO_ERR_SYS_NOTREADY (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_SYS_NOTREADY)) +#define MI_AO_ERR_BUSY (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUSY)) +#define MI_AO_ERR_VQE_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_AO_VQE_ERR)) +#define MI_AO_ERR_ADEC_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_AO_ADEC_ERR)) +//============================================================================= +// Data type definition +//============================================================================= +typedef enum +{ + E_MI_AO_VQE_ERR = MI_AO_INITIAL_ERROR_CODE, /* VQE of AO error */ + E_MI_AO_ADEC_ERR, //ADEC of AO error +} MI_AO_ErrCode_e; + + +typedef struct MI_AO_ChnState_s { + MI_U32 u32ChnTotalNum; + MI_U32 u32ChnFreeNum; + MI_U32 u32ChnBusyNum; +} MI_AO_ChnState_t; + +typedef struct MI_AO_VqeConfig_s { + MI_BOOL bHpfOpen; + MI_BOOL bAnrOpen; + MI_BOOL bAgcOpen; + MI_BOOL bEqOpen; + MI_S32 s32WorkSampleRate; + MI_S32 s32FrameSample; + MI_AUDIO_HpfConfig_t stHpfCfg; + MI_AUDIO_AnrConfig_t stAnrCfg; + MI_AUDIO_AgcConfig_t stAgcCfg; + MI_AUDIO_EqConfig_t stEqCfg; +} MI_AO_VqeConfig_t; + +typedef enum +{ + E_MI_AUDIO_ADEC_TYPE_G711A = 0, + E_MI_AUDIO_ADEC_TYPE_G711U, + E_MI_AUDIO_ADEC_TYPE_G726, + E_MI_AUDIO_ADEC_TYPE_INVALID, +} MI_AUDIO_AdecType_e; + + +typedef struct MI_AUDIO_AdecG711Config_s { + MI_AUDIO_SampleRate_e eSamplerate; + MI_AUDIO_SoundMode_e eSoundmode; +} MI_AUDIO_AdecG711Config_t; + +typedef struct MI_AUDIO_AdecG726Config_s { + MI_AUDIO_SampleRate_e eSamplerate; + MI_AUDIO_SoundMode_e eSoundmode; + MI_AUDIO_G726Mode_e eG726Mode; +} MI_AUDIO_AdecG726Config_t; + +typedef struct MI_AO_AdecConfig_s { + MI_AUDIO_AdecType_e eAdecType; + union { + MI_AUDIO_AdecG711Config_t stAdecG711Cfg; + MI_AUDIO_AdecG726Config_t stAdecG726Cfg; + }; +} MI_AO_AdecConfig_t; + +typedef struct MI_AO_ChnGainConfig_s { + MI_BOOL bEnableGainSet; + MI_S16 s16Gain; +} MI_AO_ChnGainConfig_t; + +typedef struct MI_AO_ChnParam_s { + MI_AO_ChnGainConfig_t stChnGain; + MI_U32 u32Reserved; +} MI_AO_ChnParam_t; + + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= + + +#ifdef __cplusplus +} +#endif + +#endif //__MI_AO_DATATYPE_H__ diff --git a/src/audio/mmiyoo/mi_common.h b/src/audio/mmiyoo/mi_common.h new file mode 100755 index 0000000000000..e8569ea26050b --- /dev/null +++ b/src/audio/mmiyoo/mi_common.h @@ -0,0 +1,29 @@ +/* SigmaStar trade secret */ +/* Copyright (c) [2019~2020] SigmaStar Technology. +All rights reserved. + +Unless otherwise stipulated in writing, any and all information contained +herein regardless in any format shall remain the sole proprietary of +SigmaStar and be kept in strict confidence +(SigmaStar Confidential Information) by the recipient. +Any unauthorized act including without limitation unauthorized disclosure, +copying, use, reproduction, sale, distribution, modification, disassembling, +reverse engineering and compiling of the contents of SigmaStar Confidential +Information is unlawful and strictly prohibited. SigmaStar hereby reserves the +rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_COMMON_H_ +#define _MI_COMMON_H_ + +#include "mi_common_datatype.h" + +#define COMMON_MAJOR_VERSION 2 +#define COMMON_SUB_VERSION 3 +#define MACRO_TO_STR(macro) #macro +#define COMMON_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_common_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_common_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_common_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_COMMON_API_VERSION COMMON_VERSION_STR(COMMON_MAJOR_VERSION,COMMON_SUB_VERSION) + +#endif///_MI_COMMON_H_ diff --git a/src/audio/mmiyoo/mi_common_datatype.h b/src/audio/mmiyoo/mi_common_datatype.h new file mode 100755 index 0000000000000..0811f738bccba --- /dev/null +++ b/src/audio/mmiyoo/mi_common_datatype.h @@ -0,0 +1,266 @@ +/* SigmaStar trade secret */ +/* Copyright (c) [2019~2020] SigmaStar Technology. +All rights reserved. + +Unless otherwise stipulated in writing, any and all information contained +herein regardless in any format shall remain the sole proprietary of +SigmaStar and be kept in strict confidence +(SigmaStar Confidential Information) by the recipient. +Any unauthorized act including without limitation unauthorized disclosure, +copying, use, reproduction, sale, distribution, modification, disassembling, +reverse engineering and compiling of the contents of SigmaStar Confidential +Information is unlawful and strictly prohibited. SigmaStar hereby reserves the +rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_COMMON_DATATYPE_H_ +#define _MI_COMMON_DATATYPE_H_ + +//------------------------------------------------------------------------------------------------- +// System Data Type +//------------------------------------------------------------------------------------------------- +/// data type unsigned char, data length 1 byte +typedef unsigned char MI_U8; // 1 byte +/// data type unsigned short, data length 2 byte +typedef unsigned short MI_U16; // 2 bytes +/// data type unsigned int, data length 4 byte +typedef unsigned int MI_U32; // 4 bytes +/// data type unsigned int, data length 8 byte +typedef unsigned long long MI_U64; // 8 bytes +/// data type signed char, data length 1 byte +typedef signed char MI_S8; // 1 byte +/// data type signed short, data length 2 byte +typedef signed short MI_S16; // 2 bytes +/// data type signed int, data length 4 byte +typedef signed int MI_S32; // 4 bytes +/// data type signed int, data length 8 byte +typedef signed long long MI_S64; // 8 bytes +/// data type float, data length 4 byte +typedef float MI_FLOAT; // 4 bytes +/// data type 64bit physical address +typedef unsigned long long MI_PHY; // 8 bytes +/// data type pointer content +typedef unsigned long MI_VIRT; // 4 bytes when 32bit toolchain, 8 bytes when 64bit toolchain. + +typedef unsigned char MI_BOOL; + +//------------------------------------------------------------------------------------------------- +// Moudle common type +//------------------------------------------------------------------------------------------------- +typedef MI_S32 MI_AI_CHN; +typedef MI_S32 MI_AO_CHN; +typedef MI_S32 MI_AUDIO_DEV; +typedef MI_S32 MI_VIF_DEV; +typedef MI_S32 MI_DISP_DEV; +typedef MI_S32 MI_DISP_LAYER; +typedef MI_S32 MI_DISP_CHN; +typedef MI_S32 MI_VENC_CHN; +typedef MI_S32 MI_VDEC_CHN; +typedef MI_S32 MI_IVE_HANDLE; +typedef MI_S32 MI_VPE_DEV; +typedef MI_S32 MI_DIVP_CHN; +typedef MI_U32 MI_RGN_HANDLE; +typedef MI_U32 MI_SED_CHN; +typedef MI_S32 MI_HANDLE; +//------------------------------------------------------------------------------------------------- +// Macros +//------------------------------------------------------------------------------------------------- +#define INIT_ST(st) do { \ + memset(&st, 0, sizeof(st));\ + st.u16SizeofStructure = sizeof(st);\ +}while(0) + + + +//------------------------------------------------------------------------------------------------- +// Defines +//------------------------------------------------------------------------------------------------- +#define MI_HANDLE_NULL (0) +#define MI_SUCCESS (0) +#define MI_BIT(_bit_) (1 << (_bit_)) +#define MI_ERR_ID (0x80000000L + 0x20000000L) +#define MI_IVE_INITIAL_ERROR_CODE (0x80) +#define MI_VDF_INITIAL_ERROR_CODE (0xA0) +#define MI_VENC_INITIAL_ERROR_CODE (0xC0) +#define MI_RGN_INITIAL_ERROR_CODE (0xE0) +#define MI_AI_INITIAL_ERROR_CODE (0x100) +#define MI_AO_INITIAL_ERROR_CODE (0x120) +#define MI_VIF_INITIAL_ERROR_CODE (0x140) +#define MI_VPE_INITIAL_ERROR_CODE (0x160) +#define MI_VDEC_INITIAL_ERROR_CODE (0x180) +#define MI_SYS_INITIAL_ERROR_CODE (0x1A0) +#define MI_FB_INITIAL_ERROR_CODE (0x1C0) +#define MI_HDMI_INITIAL_ERROR_CODE (0x1E0) +#define MI_DIVP_INITIAL_ERROR_CODE (0x200) +#define MI_GFX_INITIAL_ERROR_CODE (0x220) +#define MI_VDISP_INITIAL_ERROR_CODE (0x240) +#define MI_DISP_INITIAL_ERROR_CODE (0x260) +#define MI_WARP_INITIAL_ERROR_CODE (0x280) +#define MI_CV_INITIAL_ERROR_CODE (0x2A0) +#define MI_CEVA_INITIAL_ERROR_CODE (0x2C0) +#define MI_UAC_INITIAL_ERROR_CODE (0x2E0) +#define MI_LDC_INITIAL_ERROR_CODE (0x300) + +#ifndef UNUSED +#define UNUSED(var) (void)((var) = (var)) +#endif + +/****************************************************************************** +|----------------------------------------------------------------| +| 1 | APP_ID | MOD_ID | ERR_LEVEL | ERR_ID | +|----------------------------------------------------------------| +|<--><--7bits----><----8bits---><--4bits---><------12bits------->| +******************************************************************************/ + +#define MI_DEF_ERR( module, level, errid) \ + ((MI_S32)( (MI_ERR_ID) | ((module) << 16 ) | ((level)<<12) | (errid) )) + + +#ifndef __KERNEL__ +/// data type null pointer +#ifdef NULL +#undef NULL +#endif +#define NULL 0 + + +#if !defined(__cplusplus) +#ifndef true +/// definition for true +#define true 1 +/// definition for false +#define false 0 +#endif +#endif + +#if !defined(TRUE) && !defined(FALSE) +/// definition for TRUE +#define TRUE 1 +/// definition for FALSE +#define FALSE 0 +#endif +#endif + +#define TO_STR_NATIVE(e) #e +#define TO_STR_PROXY(m, e) m(e) +#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) +#define COMPILE_DATE_TIME() __DATE__ __TIME__ + +///ASCII color code +#define ASCII_COLOR_RED "\033[1;31m" +#define ASCII_COLOR_WHITE "\033[1;37m" +#define ASCII_COLOR_YELLOW "\033[1;33m" +#define ASCII_COLOR_BLUE "\033[1;36m" +#define ASCII_COLOR_GREEN "\033[1;32m" +#define ASCII_COLOR_END "\033[0m" + +//------------------------------------------------------------------------------------------------- +// Structures +//------------------------------------------------------------------------------------------------- + + + +//------------------------------------------------------------------------------------------------- +// Enum +//------------------------------------------------------------------------------------------------- +typedef enum +{ + E_MI_MODULE_ID_IVE = 0, + E_MI_MODULE_ID_VDF = 1, + E_MI_MODULE_ID_VENC = 2, + E_MI_MODULE_ID_RGN = 3, + E_MI_MODULE_ID_AI = 4, + E_MI_MODULE_ID_AO = 5, + E_MI_MODULE_ID_VIF = 6, + E_MI_MODULE_ID_VPE = 7, + E_MI_MODULE_ID_VDEC = 8, + E_MI_MODULE_ID_SYS = 9, + E_MI_MODULE_ID_FB = 10, + E_MI_MODULE_ID_HDMI = 11, + E_MI_MODULE_ID_DIVP = 12, + E_MI_MODULE_ID_GFX = 13, + E_MI_MODULE_ID_VDISP = 14, + E_MI_MODULE_ID_DISP = 15, + E_MI_MODULE_ID_OS = 16, + E_MI_MODULE_ID_IAE = 17, + E_MI_MODULE_ID_MD = 18, + E_MI_MODULE_ID_OD = 19, + E_MI_MODULE_ID_SHADOW = 20, + E_MI_MODULE_ID_WARP = 21, + E_MI_MODULE_ID_UAC = 22, + E_MI_MODULE_ID_LDC = 23, + E_MI_MODULE_ID_SD = 24, + E_MI_MODULE_ID_PANEL = 25, + E_MI_MODULE_ID_CIPHER = 26, + E_MI_MODULE_ID_SNR = 27, + E_MI_MODULE_ID_WLAN = 28, + E_MI_MODULE_ID_IPU = 29, + E_MI_MODULE_ID_MIPITX = 30, + //E_MI_MODULE_ID_SED = 29, + E_MI_MODULE_ID_MAX, +} MI_ModuleId_e; + +typedef enum +{ + E_MI_ERR_LEVEL_INFO, /* informational */ + E_MI_ERR_LEVEL_WARNING, /* warning conditions */ + E_MI_ERR_LEVEL_ERROR, /* error conditions */ + E_MI_ERR_LEVEL_BUTT +} MI_ErrLevel_e; + +typedef enum +{ + E_MI_ERR_INVALID_DEVID = 1, /* invlalid device ID */ + E_MI_ERR_INVALID_CHNID = 2, /* invlalid channel ID */ + E_MI_ERR_ILLEGAL_PARAM = 3, /* at lease one parameter is illagal + ** eg, an illegal enumeration value */ + E_MI_ERR_EXIST = 4, /* resource exists */ + E_MI_ERR_UNEXIST = 5,/* resource unexists */ + E_MI_ERR_NULL_PTR = 6, /* using a NULL point */ + E_MI_ERR_NOT_CONFIG = 7, /* try to enable or initialize system, device + ** or channel, before configing attribute */ + E_MI_ERR_NOT_SUPPORT = 8, /* operation or type is not supported by NOW */ + E_MI_ERR_NOT_PERM = 9, /* operation is not permitted + ** eg, try to change static attribute */ + E_MI_ERR_NOMEM = 12,/* failure caused by malloc memory */ + E_MI_ERR_NOBUF = 13,/* failure caused by malloc buffer */ + E_MI_ERR_BUF_EMPTY = 14,/* no data in buffer */ + E_MI_ERR_BUF_FULL = 15,/* no buffer for new data */ + E_MI_ERR_SYS_NOTREADY = 16,/* System is not ready,maybe not initialed or + ** loaded. Returning the error code when opening + ** a device file failed. */ + E_MI_ERR_BADADDR = 17,/* bad address, + ** eg. used for copy_from_user & copy_to_user */ + E_MI_ERR_BUSY = 18,/* resource is busy, + ** eg. destroy a venc chn without unregister it */ + E_MI_ERR_CHN_NOT_STARTED = 19,/* channel not start*/ + E_MI_ERR_CHN_NOT_STOPED = 20,/* channel not stop*/ + E_MI_ERR_NOT_INIT = 21,/* module not init before use it*/ + E_MI_ERR_INITED = 22,/* module already init*/ + E_MI_ERR_NOT_ENABLE = 23,/* device channel or port not enable*/ + E_MI_ERR_NOT_DISABLE = 24,/* device channel or port not disable*/ + E_MI_ERR_SYS_TIMEOUT = 25,/* sys timeout*/ + E_MI_ERR_DEV_NOT_STARTED = 26,/* device not started*/ + E_MI_ERR_DEV_NOT_STOPED = 27,/* device not stoped*/ + E_MI_ERR_CHN_NO_CONTENT = 28,/* there is no content in the channel.*/ + E_MI_ERR_NOVASPACE = 29,/* failure caused by va mmap */ + E_MI_ERR_NOITEM = 30,/* no item record in ringpool */ + E_MI_ERR_FAILED, /* unexpected error */ + + E_MI_ERR_MAX = 127,/* maxium code, private error code of all modules + ** must be greater than it */ +} MI_ErrCode_e; + +typedef enum +{ + MI_DBG_NONE = 0, + MI_DBG_ERR, + MI_DBG_WRN, + MI_DBG_KMSG, + MI_DBG_API, + MI_DBG_INFO, + MI_DBG_DEBUG, + MI_DBG_TRACE, + MI_DBG_ALL +} MI_DBG_LEVEL_e; + +#endif///_MI_COMMON_DATATYPE_H_ diff --git a/src/audio/mmiyoo/mi_sys.h b/src/audio/mmiyoo/mi_sys.h new file mode 100755 index 0000000000000..66c22bba703e5 --- /dev/null +++ b/src/audio/mmiyoo/mi_sys.h @@ -0,0 +1,170 @@ +/* SigmaStar trade secret */ +/* Copyright (c) [2019~2020] SigmaStar Technology. +All rights reserved. + +Unless otherwise stipulated in writing, any and all information contained +herein regardless in any format shall remain the sole proprietary of +SigmaStar and be kept in strict confidence +(SigmaStar Confidential Information) by the recipient. +Any unauthorized act including without limitation unauthorized disclosure, +copying, use, reproduction, sale, distribution, modification, disassembling, +reverse engineering and compiling of the contents of SigmaStar Confidential +Information is unlawful and strictly prohibited. SigmaStar hereby reserves the +rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_SYS_H_ +#define _MI_SYS_H_ + +#include "mi_common.h" +#include "mi_sys_datatype.h" + +#define SYS_MAJOR_VERSION 2 +#define SYS_SUB_VERSION 15 +#define MACRO_TO_STR(macro) #macro +#define SYS_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_sys_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_sys_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_sys_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_SYS_API_VERSION SYS_VERSION_STR(SYS_MAJOR_VERSION,SYS_SUB_VERSION) + +#ifdef __cplusplus +extern "C" { +#endif + +MI_S32 MI_SYS_Init(void); + +MI_S32 MI_SYS_Exit(void); + +MI_S32 MI_SYS_BindChnPort(MI_SYS_ChnPort_t *pstSrcChnPort, MI_SYS_ChnPort_t *pstDstChnPort, MI_U32 u32SrcFrmrate, MI_U32 u32DstFrmrate); + +MI_S32 MI_SYS_BindChnPort2(MI_SYS_ChnPort_t *pstSrcChnPort, MI_SYS_ChnPort_t *pstDstChnPort, MI_U32 u32SrcFrmrate, MI_U32 u32DstFrmrate, MI_SYS_BindType_e eBindType, MI_U32 u32BindParam); + +MI_S32 MI_SYS_UnBindChnPort(MI_SYS_ChnPort_t *pstSrcChnPort, MI_SYS_ChnPort_t *pstDstChnPort); + +MI_S32 MI_SYS_GetBindbyDest(MI_SYS_ChnPort_t *pstDstChnPort, MI_SYS_ChnPort_t *pstSrcChnPort); + +MI_S32 MI_SYS_GetVersion(MI_SYS_Version_t *pstVersion); + +MI_S32 MI_SYS_GetCurPts(MI_U64 *pu64Pts); + +MI_S32 MI_SYS_InitPtsBase(MI_U64 u64PtsBase); + +MI_S32 MI_SYS_SyncPts(MI_U64 u64Pts); + +MI_S32 MI_SYS_SetReg(MI_U32 u32RegAddr, MI_U16 u16Value, MI_U16 u16Mask); + +MI_S32 MI_SYS_GetReg(MI_U32 u32RegAddr, MI_U16 *pu16Value); + +MI_S32 MI_SYS_SetChnMMAConf(MI_ModuleId_e eModId, MI_U32 u32DevId, MI_U32 u32ChnId, MI_U8 *pu8MMAHeapName); + +MI_S32 MI_SYS_GetChnMMAConf(MI_ModuleId_e eModId, MI_U32 u32DevId, MI_U32 u32ChnId, void *data, MI_U32 u32Length); + +MI_S32 MI_SYS_ChnInputPortGetBuf(MI_SYS_ChnPort_t *pstChnPort, MI_SYS_BufConf_t *pstBufConf, MI_SYS_BufInfo_t *pstBufInfo, MI_SYS_BUF_HANDLE *bufHandle, MI_S32 s32TimeOutMs); + +MI_S32 MI_SYS_ChnInputPortPutBuf(MI_SYS_BUF_HANDLE bufHandle, MI_SYS_BufInfo_t *pstBufInfo, MI_BOOL bDropBuf); + +MI_S32 MI_SYS_ChnOutputPortGetBuf(MI_SYS_ChnPort_t *pstChnPort, MI_SYS_BufInfo_t *pstBufInfo, MI_SYS_BUF_HANDLE *bufHandle); + +MI_S32 MI_SYS_ChnOutputPortPutBuf(MI_SYS_BUF_HANDLE hBufHandle); + +MI_S32 MI_SYS_SetChnOutputPortDepth(MI_SYS_ChnPort_t *pstChnPort, MI_U32 u32UserFrameDepth, MI_U32 u32BufQueueDepth); + +MI_S32 MI_SYS_ChnPortInjectBuf(MI_SYS_BUF_HANDLE handle, MI_SYS_ChnPort_t *pstChnInputPort); + +MI_S32 MI_SYS_GetFd(MI_SYS_ChnPort_t *pstChnPort, MI_S32 *s32Fd); + +MI_S32 MI_SYS_CloseFd(MI_S32 s32ChnPortFd); + +MI_S32 MI_SYS_ConfDevPubPools(MI_ModuleId_e eModule, MI_U32 u32DevId, MI_VB_PoolListConf_t stPoolListConf); + +MI_S32 MI_SYS_ReleaseDevPubPools(MI_ModuleId_e eModule, MI_U32 u32DevId); + +MI_S32 MI_SYS_ConfGloPubPools(MI_VB_PoolListConf_t stPoolListConf); + +MI_S32 MI_SYS_ReleaseGloPubPools(void); + +MI_S32 MI_SYS_Set_Vdec_UseVbPool_Flag(MI_U32 u32Value); + +MI_S32 MI_SYS_ConfigPrivateMMAPool(MI_SYS_GlobalPrivPoolConfig_t *pstGlobalPrivPoolConf); + +MI_S32 MI_SYS_MemsetPa(MI_PHY phyPa, MI_U32 u32Val, MI_U32 u32Lenth); + +MI_S32 MI_SYS_MemcpyPa(MI_PHY phyDst, MI_PHY phySrc, MI_U32 u32Lenth); + +MI_S32 MI_SYS_BufFillPa(MI_SYS_FrameData_t *pstBuf, MI_U32 u32Val, MI_SYS_WindowRect_t *pstRect); + +MI_S32 MI_SYS_BufBlitPa(MI_SYS_FrameData_t *pstDstBuf, MI_SYS_WindowRect_t *pstDstRect, MI_SYS_FrameData_t *pstSrcBuf, MI_SYS_WindowRect_t *pstSrcRect); + +MI_S32 MI_SYS_PrivateDevChnHeapAlloc(MI_ModuleId_e eModule, MI_U32 u32Devid, MI_S32 s32ChnId, MI_U8 *pu8BufName, MI_U32 u32blkSize, MI_PHY *pphyAddr, MI_BOOL bTailAlloc); + +MI_S32 MI_SYS_PrivateDevChnHeapFree(MI_ModuleId_e eModule, MI_U32 u32Devid, MI_S32 s32ChnId, MI_PHY phyAddr); +MI_S32 MI_SYS_ReadUuid(MI_U64 *u64Uuid); + +/* +N.B. +below MMAHeapName can only be NULL or real mma heap name, do not set it with random character string. +you can get mma heap name xxx from "mma_heap=xxx," of cat /proc/cmdline. +*/ +MI_S32 MI_SYS_MMA_Alloc(MI_U8 *pstMMAHeapName, MI_U32 u32BlkSize, MI_PHY *phyAddr); + +MI_S32 MI_SYS_MMA_Free(MI_PHY phyAddr); +MI_S32 MI_SYS_Mmap(MI_U64 phyAddr, MI_U32 u32Size, void **ppVirtualAddress, MI_BOOL bCache); + +MI_S32 MI_SYS_Munmap(void *pVirtualAddress, MI_U32 u32Size); +MI_S32 MI_SYS_FlushInvCache(void *pVirtualAddress, MI_U32 u32Length); + +#ifdef __USER__ +#define DEBUG_YUV_USER_API +#ifdef DEBUG_YUV_USER_API +typedef FILE *FILE_HANDLE; +//return value of the following API is not standard file operation return value. + +/* +return : +FILE_HANDLE type in fact is a pointer, +NULL:fail +not NULL:success +*/ +FILE_HANDLE open_yuv_file(const char *pathname, int open_for_write); + +/* +return value: +0:success +-1:fail +*/ +int read_yuv_file(FILE_HANDLE filehandle, MI_SYS_FrameData_t framedata); + +/* +return value: +0:success +-1:fail +*/ +int write_yuv_file(FILE_HANDLE filehandle, MI_SYS_FrameData_t framedata); + +void close_yuv_file(FILE_HANDLE filehandle); + +/* +return value: +0:success +-1:fail +*/ +int reset_yuv_file(FILE_HANDLE filehandle); + +/* +return value: +0:success +-1:fail +*/ +int is_in_yuv_file_end(FILE_HANDLE filehandle); +#endif +#else +/* +do nothing,kernel space debug API is in mi_sys_internal.h/mi_sys_internal.c +*/ +#endif + +#ifdef __cplusplus +} +#endif + +#endif ///_MI_SYS_H_ diff --git a/src/audio/mmiyoo/mi_sys_datatype.h b/src/audio/mmiyoo/mi_sys_datatype.h new file mode 100755 index 0000000000000..87fb52878ebdb --- /dev/null +++ b/src/audio/mmiyoo/mi_sys_datatype.h @@ -0,0 +1,469 @@ +/* SigmaStar trade secret */ +/* Copyright (c) [2019~2020] SigmaStar Technology. +All rights reserved. + +Unless otherwise stipulated in writing, any and all information contained +herein regardless in any format shall remain the sole proprietary of +SigmaStar and be kept in strict confidence +(SigmaStar Confidential Information) by the recipient. +Any unauthorized act including without limitation unauthorized disclosure, +copying, use, reproduction, sale, distribution, modification, disassembling, +reverse engineering and compiling of the contents of SigmaStar Confidential +Information is unlawful and strictly prohibited. SigmaStar hereby reserves the +rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_SYS_DATATYPE_H_ +#define _MI_SYS_DATATYPE_H_ + +#include "mi_common.h" +#define MI_SYS_MAX_INPUT_PORT_CNT (16) +#define MI_SYS_MAX_OUTPUT_PORT_CNT (5) +#define MI_SYS_MAX_DEV_CHN_CNT (48) +#define MI_SYS_INVLAID_SEQUENCE_NUM ((MI_U32)-1) + + +//ensure that sizeof(MI_VB_PoolListConf_t) is less that 4096 !!! +#define MI_MAX_MMA_HEAP_LENGTH (32) +#define MI_VB_POOL_LIST_MAX_CNT (8) + +#define MI_SYS_INVALID_PTS (0xffffffffffffffffULL) + +#define MI_VB_BLK_HANDLE_INVALID (-1) +#define MI_VB_POOL_HANDLE_INVALID (-1) + +#define MI_SYS_MAP_VA 0x80000000 +#define MI_SYS_MAP_CPU_READ 0X20000000 +#define MI_SYS_MAP_CPU_WRITE 0X10000000 + +#define MI_SYS_INVLAID_SEQUENCE_NUM ((MI_U32)-1) + +#define MI_SYS_SUCCESS MI_SUCCESS// do not use MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, MI_SUCCESS) !!!! + +/* SYS Module ErrorCode */ +#define MI_ERR_SYS_INVALID_DEVID MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_DEVID) +#define MI_ERR_SYS_INVALID_CHNID MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_CHNID) +#define MI_ERR_SYS_ILLEGAL_PARAM MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_ILLEGAL_PARAM) +#define MI_ERR_SYS_EXIST MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_EXIST) +#define MI_ERR_SYS_UNEXIST MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_UNEXIST) +#define MI_ERR_SYS_NULL_PTR MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NULL_PTR) +#define MI_ERR_SYS_NOT_CONFIG MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_CONFIG) +#define MI_ERR_SYS_NOT_SUPPORT MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_SUPPORT) +#define MI_ERR_SYS_NOT_PERM MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_PERM) +#define MI_ERR_SYS_NOMEM MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOMEM) +#define MI_ERR_SYS_NOBUF MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOBUF) +#define MI_ERR_SYS_BUF_EMPTY MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUF_EMPTY) +#define MI_ERR_SYS_BUF_FULL MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUF_FULL) +#define MI_ERR_SYS_SYS_NOTREADY MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_SYS_NOTREADY) +#define MI_ERR_SYS_BADADDR MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BADADDR) +#define MI_ERR_SYS_BUSY MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUSY) +#define MI_ERR_SYS_CHN_NOT_STARTED MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_CHN_NOT_STARTED) +#define MI_ERR_SYS_CHN_NOT_STOPED MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_CHN_NOT_STOPED) +#define MI_ERR_SYS_NOT_INIT MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_INIT) +#define MI_ERR_SYS_INITED MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INITED) +#define MI_ERR_SYS_NOT_ENABLE MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_ENABLE) +#define MI_ERR_SYS_NOT_DISABLE MI_DEF_ERR(E_MI_MODULE_ID_SYS,E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_DISABLE) +#define MI_ERR_SYS_TIMEOUT MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_SYS_TIMEOUT) +#define MI_ERR_SYS_DEV_NOT_STARTED MI_DEF_ERR(E_MI_MODULE_ID_SYS,E_MI_ERR_LEVEL_ERROR, E_MI_ERR_DEV_NOT_STARTED) +#define MI_ERR_SYS_DEV_NOT_STOPED MI_DEF_ERR(E_MI_MODULE_ID_SYS,E_MI_ERR_LEVEL_ERROR, E_MI_ERR_DEV_NOT_STOPED) +#define MI_ERR_SYS_CHN_NO_CONTENT MI_DEF_ERR(E_MI_MODULE_ID_SYS,E_MI_ERR_LEVEL_ERROR, E_MI_ERR_CHN_NO_CONTENT) +#define MI_ERR_SYS_NOVASAPCE MI_DEF_ERR(E_MI_MODULE_ID_SYS,E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOVASPACE) +#define MI_ERR_SYS_NOITEM MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOITEM) +#define MI_ERR_SYS_FAILED MI_DEF_ERR(E_MI_MODULE_ID_SYS, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_FAILED) + +typedef MI_S32 MI_VB_POOL_HANDLE; +typedef MI_S32 MI_VB_BLK_HANDLE; +typedef MI_S32 MI_SYS_BUF_HANDLE; + +/* +****************************************************TODO Refine***************************************** +*/ +typedef void *MI_SYS_RINGPOOL_HANDLE; + +typedef enum +{ + E_MI_RINGPOOL_GET_RINGPOOL_SPACE, + E_MI_RINGPOOL_GET_FREE_SPACE, + E_MI_RINGPOOL_GET_RECORD, + E_MI_RINGPOOL_APPEND_TAIL_RECORD, + E_MI_RINGPOOL_RELEASE_HEAD_RECORD, + E_MI_RINGPOOL_CANCEL_UNFINISHED_TAIL_Record, + E_MI_RINGPOOL_CMD_MAX, +} MI_SYS_RingPool_Cmd_e; + +typedef struct MI_SYS_RingPool_Config_s { + MI_U32 u32SizeOfPool; + MI_U32 u32MinAllocSize; + MI_U32 u32Alignment; + void (*OnContentAvailable)(MI_SYS_RINGPOOL_HANDLE hHandle, void *pDrvPrivateData); + void (*OnFreeSpaceAvailable)(MI_SYS_RINGPOOL_HANDLE hHandle, void *pDrvPrivateData); + void *pDrvPrivateData; +} MI_SYS_RingPool_Config_t; + +typedef struct MI_SYS_RingPool_Record_s { + MI_U64 u64ExtFlags; + MI_U64 u64Pts; + MI_U64 u64SeqNum; + MI_U64 bEndOfStream; + MI_U64 PA; + char *VA_In_Kernel; + MI_U32 u32Length; +} MI_SYS_RingPool_Record_t; + +typedef struct MI_RingPool_AppendTailRecord_s { + MI_SYS_RingPool_Record_t stNextContentRecord; + MI_BOOL bContentClosed; +} MI_RingPool_AppendTailRecord_t; + +/* +****************************************************TODO Refine***************************************** +*/ + +#if !defined(TRUE) && !defined(FALSE) +/// definition for TRUE +#define TRUE 1 +/// definition for FALSE +#define FALSE 0 +#endif + +typedef struct MI_VB_BufBlkInfo_s { + MI_VB_POOL_HANDLE poolHandle; + MI_U32 u32OffsetInVBPool; + MI_U32 u32BlkSize; + MI_PHY phySicalAddr; + void *pVirtualAddress; +} MI_VB_BufBlkInfo_t; + +typedef struct MI_VB_PoolConf_s { + MI_U32 u32BlkSize; + MI_U32 u32BlkCnt; + MI_U8 u8MMAHeapName[MI_MAX_MMA_HEAP_LENGTH]; +} MI_VB_PoolConf_t; + +typedef struct MI_VB_PoolListConf_s { + MI_U32 u32PoolListCnt; + MI_VB_PoolConf_t stPoolConf[MI_VB_POOL_LIST_MAX_CNT]; +} MI_VB_PoolListConf_t; + +typedef enum +{ + E_MI_SYS_DATA_PRECISION_8BPP, + E_MI_SYS_DATA_PRECISION_10BPP, + E_MI_SYS_DATA_PRECISION_12BPP, + E_MI_SYS_DATA_PRECISION_14BPP, + E_MI_SYS_DATA_PRECISION_16BPP, + E_MI_SYS_DATA_PRECISION_MAX, +} MI_SYS_DataPrecision_e; + +typedef enum +{ + E_MI_SYS_PIXEL_BAYERID_RG, + E_MI_SYS_PIXEL_BAYERID_GR, + E_MI_SYS_PIXEL_BAYERID_BG, + E_MI_SYS_PIXEL_BAYERID_GB, + E_MI_SYS_PIXEL_RGBIR_R0, + E_MI_SYS_PIXEL_RGBIR_G0, + E_MI_SYS_PIXEL_RGBIR_B0, + E_MI_SYS_PIXEL_RGBIR_G1, + E_MI_SYS_PIXEL_RGBIR_G2, + E_MI_SYS_PIXEL_RGBIR_I0, + E_MI_SYS_PIXEL_RGBIR_G3, + E_MI_SYS_PIXEL_RGBIR_I1, + E_MI_SYS_PIXEL_BAYERID_MAX, +} MI_SYS_BayerId_e; + +typedef enum +{ + E_MI_SYS_PIXEL_FRAME_YUV422_YUYV = 0, + E_MI_SYS_PIXEL_FRAME_ARGB8888, + E_MI_SYS_PIXEL_FRAME_ABGR8888, + E_MI_SYS_PIXEL_FRAME_BGRA8888, + + E_MI_SYS_PIXEL_FRAME_RGB565, + E_MI_SYS_PIXEL_FRAME_ARGB1555, + E_MI_SYS_PIXEL_FRAME_ARGB4444, + E_MI_SYS_PIXEL_FRAME_I2, + E_MI_SYS_PIXEL_FRAME_I4, + E_MI_SYS_PIXEL_FRAME_I8, + + E_MI_SYS_PIXEL_FRAME_YUV_SEMIPLANAR_422, + E_MI_SYS_PIXEL_FRAME_YUV_SEMIPLANAR_420, + E_MI_SYS_PIXEL_FRAME_YUV_MST_420, + E_MI_SYS_PIXEL_FRAME_YUV422_UYVY, + E_MI_SYS_PIXEL_FRAME_YUV422_YVYU, + E_MI_SYS_PIXEL_FRAME_YUV422_VYUY, + + //vdec sigmastar private video format + E_MI_SYS_PIXEL_FRAME_YC420_MSTTILE1_H264, + E_MI_SYS_PIXEL_FRAME_YC420_MSTTILE2_H265, + E_MI_SYS_PIXEL_FRAME_YC420_MSTTILE3_H265, + + E_MI_SYS_PIXEL_FRAME_RGB_BAYER_BASE, + E_MI_SYS_PIXEL_FRAME_RGB_BAYER_NUM = E_MI_SYS_PIXEL_FRAME_RGB_BAYER_BASE + E_MI_SYS_DATA_PRECISION_MAX * E_MI_SYS_PIXEL_BAYERID_MAX - 1, + + E_MI_SYS_PIXEL_FRAME_RGB888, + E_MI_SYS_PIXEL_FRAME_BGR888, + + E_MI_SYS_PIXEL_FRAME_FORMAT_MAX, +} MI_SYS_PixelFormat_e; + +#define RGB_BAYER_PIXEL(BitMode, PixelID) (E_MI_SYS_PIXEL_FRAME_RGB_BAYER_BASE+ BitMode*E_MI_SYS_PIXEL_BAYERID_MAX+ PixelID) + +typedef enum +{ + E_MI_SYS_COMPRESS_MODE_NONE,//no compress + E_MI_SYS_COMPRESS_MODE_SEG,//compress unit is 256 bytes as a segment + E_MI_SYS_COMPRESS_MODE_LINE,//compress unit is the whole line + E_MI_SYS_COMPRESS_MODE_FRAME,//compress unit is the whole frame + E_MI_SYS_COMPRESS_MODE_BUTT, //number +} MI_SYS_CompressMode_e; + +typedef enum +{ + E_MI_SYS_FRAME_SCAN_MODE_PROGRESSIVE = 0x0, // progessive. + E_MI_SYS_FRAME_SCAN_MODE_INTERLACE = 0x1, // interlace. + E_MI_SYS_FRAME_SCAN_MODE_MAX, +} MI_SYS_FrameScanMode_e; + +typedef enum +{ + E_MI_SYS_FRAME_TILE_MODE_NONE = 0, + E_MI_SYS_FRAME_TILE_MODE_16x16, // tile mode 16x16 + E_MI_SYS_FRAME_TILE_MODE_16x32, // tile mode 16x32 + E_MI_SYS_FRAME_TILE_MODE_32x16, // tile mode 32x16 + E_MI_SYS_FRAME_TILE_MODE_32x32, // tile mode 32x32 + E_MI_SYS_FRAME_TILE_MODE_MAX +} MI_SYS_FrameTileMode_e; + +typedef enum +{ + E_MI_SYS_FIELDTYPE_NONE, //< no field. + E_MI_SYS_FIELDTYPE_TOP, //< Top field only. + E_MI_SYS_FIELDTYPE_BOTTOM, //< Bottom field only. + E_MI_SYS_FIELDTYPE_BOTH, //< Both fields. + E_MI_SYS_FIELDTYPE_NUM +} MI_SYS_FieldType_e; + +typedef enum +{ + E_MI_SYS_BUFDATA_RAW = 0, + E_MI_SYS_BUFDATA_FRAME, + E_MI_SYS_BUFDATA_META, +} MI_SYS_BufDataType_e; + +typedef enum +{ + E_MI_SYS_ROTATE_NONE, //Rotate 0 degrees + E_MI_SYS_ROTATE_90, //Rotate 90 degrees + E_MI_SYS_ROTATE_180, //Rotate 180 degrees + E_MI_SYS_ROTATE_270, //Rotate 270 degrees + E_MI_SYS_ROTATE_NUM, +} MI_SYS_Rotate_e; + +typedef enum +{ + E_MI_SYS_BIND_TYPE_FRAME_BASE = 0x00000001, + E_MI_SYS_BIND_TYPE_SW_LOW_LATENCY = 0x00000002, + E_MI_SYS_BIND_TYPE_REALTIME = 0x00000004, + E_MI_SYS_BIND_TYPE_HW_AUTOSYNC = 0x00000008, + E_MI_SYS_BIND_TYPE_HW_RING = 0x00000010 +} MI_SYS_BindType_e; + +typedef enum +{ + E_MI_SYS_VPE_TO_VENC_PRIVATE_RING_POOL = 0, + E_MI_SYS_PER_CHN_PRIVATE_POOL = 1, + E_MI_SYS_PER_DEV_PRIVATE_POOL = 2, + E_MI_SYS_PER_CHN_PORT_OUTPUT_POOL = 3, +} MI_SYS_InsidePrivatePoolType_e; + +typedef enum +{ + E_MI_SYS_FRAME_ISP_INFO_TYPE_NONE, + E_MI_SYS_FRAME_ISP_INFO_TYPE_GLOBAL_GRADIENT +} MI_SYS_FrameIspInfoType_e; + + +typedef struct MI_SYS_ChnPort_s { + MI_ModuleId_e eModId; + MI_U32 u32DevId; + MI_U32 u32ChnId; + MI_U32 u32PortId; + +} MI_SYS_ChnPort_t; + +typedef struct MI_SYS_WindowRect_s { + MI_U16 u16X; + MI_U16 u16Y; + MI_U16 u16Width; + MI_U16 u16Height; +} MI_SYS_WindowRect_t; + +typedef struct MI_SYS_WindowSize_s { + MI_U16 u16Width; + MI_U16 u16Height; +} MI_SYS_WindowSize_t; + +typedef struct MI_SYS_RawData_s { + void *pVirAddr; + MI_PHY phyAddr;//notice that this is miu bus addr,not cpu bus addr. + MI_U32 u32BufSize; + + MI_U32 u32ContentSize; + MI_BOOL bEndOfFrame; + MI_U64 u64SeqNum; +} MI_SYS_RawData_t; + +typedef struct MI_SYS_MetaData_s { + void *pVirAddr; + MI_PHY phyAddr;//notice that this is miu bus addr,not cpu bus addr. + + MI_U32 u32Size; + MI_U32 u32ExtraData; /*driver special flag*/ + MI_ModuleId_e eDataFromModule; +} MI_SYS_MetaData_t; + +typedef enum +{ + REALTIME_FRAME_DATA, + RINGBUF_FRAME_DATA, + NORMAL_FRAME_DATA, +} MI_SYS_FrameData_PhySignalType; + +#define MI_SYS_REALTIME_MAGIC_PADDR ((MI_PHY)0x46414B45) //"FAKE" +#define MI_SYS_REALTIME_MAGIC_VADDR ((void*)0x46414B45) //"FAKE" +#define MI_SYS_REALTIME_MAGIC_PITCH ((MI_U32)0x46414B45) //"FAKE" + +typedef struct MI_SYS_FrameIspInfo_s { + MI_SYS_FrameIspInfoType_e eType; + union { + MI_U32 u32GlobalGradient; + } uIspInfo; +} MI_SYS_FrameIspInfo_t; + +//N.B. in MI_SYS_FrameData_t should never support u32Size, +//for other values are enough,and not support u32Size is general standard method. +typedef struct MI_SYS_FrameData_s { + MI_SYS_FrameTileMode_e eTileMode; + MI_SYS_PixelFormat_e ePixelFormat; + MI_SYS_CompressMode_e eCompressMode; + MI_SYS_FrameScanMode_e eFrameScanMode; + MI_SYS_FieldType_e eFieldType; + MI_SYS_FrameData_PhySignalType ePhylayoutType; + + MI_U16 u16Width; + MI_U16 u16Height; +//in case ePhylayoutType equal to REALTIME_FRAME_DATA, pVirAddr would be MI_SYS_REALTIME_MAGIC_PADDR and phyAddr would be MI_SYS_REALTIME_MAGIC_VADDR + + void *pVirAddr[3]; + MI_PHY phyAddr[3];//notice that this is miu bus addr,not cpu bus addr. + MI_U32 u32Stride[3]; + MI_U32 u32BufSize;//total size that allocated for this buffer,include consider alignment. + + MI_U16 u16RingBufStartLine;//Valid in case RINGBUF_FRAME_DATA, u16RingBufStartLine must be LGE than 0 and less than u16Height + MI_U16 u16RingBufRealTotalHeight;///Valid in case RINGBUF_FRAME_DATA, u16RingBufStartLine must be LGE than u16Height + + MI_SYS_FrameIspInfo_t stFrameIspInfo;//isp info of each frame + MI_SYS_WindowRect_t stContentCropWindow; +} MI_SYS_FrameData_t; + +typedef struct MI_SYS_BufInfo_s { + MI_U64 u64Pts; + MI_U64 u64SidebandMsg; + MI_SYS_BufDataType_e eBufType; + MI_BOOL bEndOfStream; + MI_BOOL bUsrBuf; + MI_U32 u32SequenceNumber; + union { + MI_SYS_FrameData_t stFrameData; + MI_SYS_RawData_t stRawData; + MI_SYS_MetaData_t stMetaData; + }; +} MI_SYS_BufInfo_t; + +typedef struct MI_SYS_FrameBufExtraConfig_s { + //Buf alignment requirement in horizontal + MI_U16 u16BufHAlignment; + //Buf alignment requirement in vertical + MI_U16 u16BufVAlignment; + //Buf alignment requirement in chroma + MI_U16 u16BufChromaAlignment; + //Clear padding flag + MI_BOOL bClearPadding; +} MI_SYS_FrameBufExtraConfig_t; + +typedef struct MI_SYS_BufFrameConfig_s { + MI_U16 u16Width; + MI_U16 u16Height; + MI_SYS_FrameScanMode_e eFrameScanMode;// + MI_SYS_PixelFormat_e eFormat; + MI_SYS_FrameBufExtraConfig_t stFrameBufExtraConf;//set by MI_SYS internal + //MI_U32 u32Size;//this value will be calculated through others values in this struct +} MI_SYS_BufFrameConfig_t; + +typedef struct MI_SYS_BufRawConfig_s { + MI_U32 u32Size; +} MI_SYS_BufRawConfig_t; + +typedef struct MI_SYS_MetaDataConfig_s { + MI_U32 u32Size; +} MI_SYS_MetaDataConfig_t; + +typedef struct MI_SYS_BufConf_s { + MI_SYS_BufDataType_e eBufType; + MI_U32 u32Flags; //0 or MI_SYS_MAP_VA + MI_U64 u64TargetPts; + union { + MI_SYS_BufFrameConfig_t stFrameCfg; + MI_SYS_BufRawConfig_t stRawCfg; + MI_SYS_MetaDataConfig_t stMetaCfg; + }; +} MI_SYS_BufConf_t; + +typedef struct MI_SYS_Version_s { + MI_U8 u8Version[128]; +} MI_SYS_Version_t; + + +typedef struct MI_PerChnPrivHeapConf_s { + MI_ModuleId_e eModule; + MI_U32 u32Devid; + MI_U32 u32Channel; + MI_U8 u8MMAHeapName[MI_MAX_MMA_HEAP_LENGTH]; + MI_U32 u32PrivateHeapSize; +} MI_SYS_PerChnPrivHeapConf_t; + +typedef struct MI_PerDevPrivHeapConf_s { + MI_ModuleId_e eModule; + MI_U32 u32Devid; + MI_U32 u32Reserve; + MI_U8 u8MMAHeapName[MI_MAX_MMA_HEAP_LENGTH]; + MI_U32 u32PrivateHeapSize; +} MI_SYS_PerDevPrivHeapConf_t; + +typedef struct MI_SYS_PerVpe2VencRingPoolConf_s { + MI_U32 u32VencInputRingPoolStaticSize; + MI_U8 u8MMAHeapName[MI_MAX_MMA_HEAP_LENGTH]; +} MI_SYS_PerVpe2VencRingPoolConf_t; + +typedef struct MI_SYS_PerChnPortOutputPool_s { + MI_ModuleId_e eModule; + MI_U32 u32Devid; + MI_U32 u32Channel; + MI_U32 u32Port; + MI_U8 u8MMAHeapName[MI_MAX_MMA_HEAP_LENGTH]; + MI_U32 u32PrivateHeapSize; +} MI_SYS_PerChnPortOutputPool_t; + +typedef struct MI_SYS_GlobalPrivPoolConfig_s { + MI_SYS_InsidePrivatePoolType_e eConfigType; + MI_BOOL bCreate; + union { + MI_SYS_PerChnPrivHeapConf_t stPreChnPrivPoolConfig; + MI_SYS_PerDevPrivHeapConf_t stPreDevPrivPoolConfig; + MI_SYS_PerVpe2VencRingPoolConf_t stPreVpe2VencRingPrivPoolConfig; + MI_SYS_PerChnPortOutputPool_t stPreChnPortOutputPrivPool; + } uConfig; +} MI_SYS_GlobalPrivPoolConfig_t; + + +#endif ///_MI_SYS_DATATYPE_H_ diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 696038d2e8e4b..c3ee45d259cf0 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -98,6 +98,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #ifdef SDL_JOYSTICK_VITA &SDL_VITA_JoystickDriver, #endif +#if defined(SDL_JOYSTICK_MMIYOO) + &SDL_MMIYOO_JoystickDriver, +#endif #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) &SDL_DUMMY_JoystickDriver #endif diff --git a/src/joystick/SDL_sysjoystick.h b/src/joystick/SDL_sysjoystick.h index 8b879217990bd..7c59f7f5ba442 100644 --- a/src/joystick/SDL_sysjoystick.h +++ b/src/joystick/SDL_sysjoystick.h @@ -222,6 +222,7 @@ extern SDL_JoystickDriver SDL_WINMM_JoystickDriver; extern SDL_JoystickDriver SDL_OS2_JoystickDriver; extern SDL_JoystickDriver SDL_PSP_JoystickDriver; extern SDL_JoystickDriver SDL_VITA_JoystickDriver; +extern SDL_JoystickDriver SDL_MMIYOO_JoystickDriver; #endif /* SDL_sysjoystick_h_ */ diff --git a/src/joystick/mmiyoo/SDL_joystick_mmiyoo.c b/src/joystick/mmiyoo/SDL_joystick_mmiyoo.c new file mode 100644 index 0000000000000..e95b19b458d3f --- /dev/null +++ b/src/joystick/mmiyoo/SDL_joystick_mmiyoo.c @@ -0,0 +1,153 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if defined(SDL_JOYSTICK_MMIYOO) + +#include "SDL_joystick.h" +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" + +static int MMIYOO_JoystickInit(void) +{ + return 1; +} + +static int MMIYOO_JoystickGetCount(void) +{ + return 1; +} + +static void MMIYOO_JoystickDetect(void) +{ +} + +static const char* MMIYOO_JoystickGetDeviceName(int device_index) +{ + return "MMiyoo Joystick"; +} + +static int MMIYOO_JoystickGetDevicePlayerIndex(int device_index) +{ + return -1; +} + +static void MMIYOO_JoystickSetDevicePlayerIndex(int device_index, int player_index) +{ +} + +static SDL_JoystickGUID MMIYOO_JoystickGetDeviceGUID(int device_index) +{ + SDL_JoystickGUID guid; + const char *name = MMIYOO_JoystickGetDeviceName(device_index); + SDL_zero(guid); + SDL_memcpy(&guid, name, SDL_min(sizeof(guid), SDL_strlen(name))); + return guid; +} + +static SDL_JoystickID MMIYOO_JoystickGetDeviceInstanceID(int device_index) +{ + return device_index; +} + +static int MMIYOO_JoystickOpen(SDL_Joystick *joystick, int device_index) +{ + joystick->nbuttons = 14; + joystick->naxes = 2; + joystick->nhats = 0; + return 0; +} + +static int MMIYOO_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +{ + return SDL_Unsupported(); +} + +static int MMIYOO_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +{ + return SDL_Unsupported(); +} + +static Uint32 MMIYOO_JoystickGetCapabilities(SDL_Joystick *joystick) +{ + return 0; +} + +static int MMIYOO_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +{ + return SDL_Unsupported(); +} + +static int MMIYOO_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) +{ + return SDL_Unsupported(); +} + +static int MMIYOO_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +{ + return SDL_Unsupported(); +} + +static void MMIYOO_JoystickUpdate(SDL_Joystick *joystick) +{ +} + +static void MMIYOO_JoystickClose(SDL_Joystick *joystick) +{ +} + +static void MMIYOO_JoystickQuit(void) +{ +} + +static SDL_bool MMIYOO_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +{ + return SDL_FALSE; +} + +SDL_JoystickDriver SDL_MMIYOO_JoystickDriver = { + MMIYOO_JoystickInit, + MMIYOO_JoystickGetCount, + MMIYOO_JoystickDetect, + MMIYOO_JoystickGetDeviceName, + MMIYOO_JoystickGetDevicePlayerIndex, + MMIYOO_JoystickSetDevicePlayerIndex, + MMIYOO_JoystickGetDeviceGUID, + MMIYOO_JoystickGetDeviceInstanceID, + MMIYOO_JoystickOpen, + MMIYOO_JoystickRumble, + MMIYOO_JoystickRumbleTriggers, + MMIYOO_JoystickGetCapabilities, + MMIYOO_JoystickSetLED, + MMIYOO_JoystickSendEffect, + MMIYOO_JoystickSetSensorsEnabled, + MMIYOO_JoystickUpdate, + MMIYOO_JoystickClose, + MMIYOO_JoystickQuit, + MMIYOO_JoystickGetGamepadMapping +}; + +#endif + diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 03c2691d26431..ec3d0d90c841f 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -118,7 +118,10 @@ static const SDL_RenderDriver *render_drivers[] = { &VITA_GXM_RenderDriver, #endif #if SDL_VIDEO_RENDER_SW - &SW_RenderDriver + &SW_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_MMIYOO + &MMIYOO_RenderDriver #endif }; #endif /* !SDL_RENDER_DISABLED */ diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index ff38ed0dd698e..765b07c80a6c0 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -276,6 +276,7 @@ extern SDL_RenderDriver GLES_RenderDriver; extern SDL_RenderDriver DirectFB_RenderDriver; extern SDL_RenderDriver METAL_RenderDriver; extern SDL_RenderDriver PSP_RenderDriver; +extern SDL_RenderDriver MMIYOO_RenderDriver; extern SDL_RenderDriver SW_RenderDriver; extern SDL_RenderDriver VITA_GXM_RenderDriver; diff --git a/src/render/mmiyoo/SDL_render_mmiyoo.c b/src/render/mmiyoo/SDL_render_mmiyoo.c new file mode 100644 index 0000000000000..5949c46c25a8a --- /dev/null +++ b/src/render/mmiyoo/SDL_render_mmiyoo.c @@ -0,0 +1,368 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_MMIYOO + +#include "SDL_hints.h" +#include "../SDL_sysrender.h" +#include "../../video/mmiyoo/SDL_video_mmiyoo.h" +#include "../../video/mmiyoo/SDL_event_mmiyoo.h" + +typedef struct MMIYOO_TextureData { + void *data; + unsigned int size; + unsigned int width; + unsigned int height; + unsigned int bits; + unsigned int format; + unsigned int pitch; +} MMIYOO_TextureData; + +typedef struct { + SDL_Texture *boundTarget; + SDL_bool initialized; + unsigned int bpp; + SDL_bool vsync; +} MMIYOO_RenderData; + +#define MAX_TEXTURE 10 + +struct _NDS_TEXTURE { + int pitch; + const void *pixels; + SDL_Texture *texture; +}; + +extern MMIYOO_EventInfo MMiyooEventInfo; + +static struct _NDS_TEXTURE ntex[MAX_TEXTURE] = {0}; + +static int update_texture(void *chk, void *new, const void *pixels, int pitch) +{ + int cc = 0; + + for (cc=0; ccwidth = texture->w; + mmiyoo_texture->height = texture->h; + mmiyoo_texture->format = texture->format; + + switch(mmiyoo_texture->format) { + case SDL_PIXELFORMAT_RGB565: + mmiyoo_texture->bits = 16; + break; + case SDL_PIXELFORMAT_ARGB8888: + mmiyoo_texture->bits = 32; + break; + default: + printf("%s, invalid format %d\n", __func__, mmiyoo_texture->format); + return -1; + } + + mmiyoo_texture->pitch = mmiyoo_texture->width * SDL_BYTESPERPIXEL(texture->format); + mmiyoo_texture->size = mmiyoo_texture->height * mmiyoo_texture->pitch; + mmiyoo_texture->data = SDL_calloc(1, mmiyoo_texture->size); + + if(!mmiyoo_texture->data) { + SDL_free(mmiyoo_texture); + return SDL_OutOfMemory(); + } + + mmiyoo_texture->data = SDL_calloc(1, mmiyoo_texture->size); + texture->driverdata = mmiyoo_texture; + update_texture(NULL, texture, NULL, 0); + GFX_Clear(); + return 0; +} + +static int MMIYOO_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch) +{ + MMIYOO_TextureData *mmiyoo_texture = (MMIYOO_TextureData*)texture->driverdata; + + *pixels = mmiyoo_texture->data; + *pitch = mmiyoo_texture->pitch; + return 0; +} + +static int MMIYOO_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch) +{ + update_texture(texture, texture, pixels, pitch); + return 0; +} + +static void MMIYOO_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + SDL_Rect rect = {0}; + MMIYOO_TextureData *mmiyoo_texture = (MMIYOO_TextureData*)texture->driverdata; + + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + MMIYOO_UpdateTexture(renderer, texture, &rect, mmiyoo_texture->data, mmiyoo_texture->pitch); +} + +static void MMIYOO_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode) +{ +} + +static int MMIYOO_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) +{ + return 0; +} + +static int MMIYOO_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + return 0; +} + +static int MMIYOO_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) +{ + return 0; +} + +static int MMIYOO_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, + int num_vertices, const void *indices, int num_indices, int size_indices, + float scale_x, float scale_y) +{ + return 0; +} + +static int MMIYOO_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count) +{ + return 0; +} + +static int MMIYOO_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect) +{ + int pitch = 0; + SDL_Rect dst = {0}; + const void *pixels = NULL; + + float sx = 640.0 / srcrect->w; + float sy = 480.0 / srcrect->h; + float m = sx < sy ? sx : sy; + + pitch = get_pitch(texture); + pixels = get_pixels(texture); + + if ((pitch == 0) || (pixels == NULL)) { + return 0; + } + + dst.w = m * srcrect->w; + dst.h = m * srcrect->h; + dst.x = (640 - dst.w) / 2; + dst.y = (480 - dst.h) / 2; + GFX_Copy(pixels, *srcrect, dst, pitch, 0, E_MI_GFX_ROTATE_180); + return 0; +} + +static int MMIYOO_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, + const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) +{ + return 0; +} + +static int MMIYOO_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +{ + return 0; +} + +static int MMIYOO_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 pixel_format, void *pixels, int pitch) +{ + return SDL_Unsupported(); +} + +static void MMIYOO_RenderPresent(SDL_Renderer *renderer) +{ + GFX_Flip(); +} + +static void MMIYOO_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + MMIYOO_TextureData *mmiyoo_texture = (MMIYOO_TextureData*)texture->driverdata; + + if (mmiyoo_texture) { + update_texture(texture, NULL, NULL, 0); + if (mmiyoo_texture->data) { + SDL_free(mmiyoo_texture->data); + } + SDL_free(mmiyoo_texture); + texture->driverdata = NULL; + } +} + +static void MMIYOO_DestroyRenderer(SDL_Renderer *renderer) +{ + MMIYOO_RenderData *data = (MMIYOO_RenderData *)renderer->driverdata; + + if(data) { + if(!data->initialized) { + return; + } + + data->initialized = SDL_FALSE; + SDL_free(data); + } + SDL_free(renderer); +} + +static int MMIYOO_SetVSync(SDL_Renderer *renderer, const int vsync) +{ + return 0; +} + +SDL_Renderer *MMIYOO_CreateRenderer(SDL_Window *window, Uint32 flags) +{ + int pixelformat = 0; + SDL_Renderer *renderer = NULL; + MMIYOO_RenderData *data = NULL; + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if(!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (MMIYOO_RenderData *) SDL_calloc(1, sizeof(*data)); + if(!data) { + MMIYOO_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + + renderer->WindowEvent = MMIYOO_WindowEvent; + renderer->CreateTexture = MMIYOO_CreateTexture; + renderer->UpdateTexture = MMIYOO_UpdateTexture; + renderer->LockTexture = MMIYOO_LockTexture; + renderer->UnlockTexture = MMIYOO_UnlockTexture; + renderer->SetTextureScaleMode = MMIYOO_SetTextureScaleMode; + renderer->SetRenderTarget = MMIYOO_SetRenderTarget; + renderer->QueueSetViewport = MMIYOO_QueueSetViewport; + renderer->QueueSetDrawColor = MMIYOO_QueueSetViewport; + renderer->QueueDrawPoints = MMIYOO_QueueDrawPoints; + renderer->QueueDrawLines = MMIYOO_QueueDrawPoints; + renderer->QueueGeometry = MMIYOO_QueueGeometry; + renderer->QueueFillRects = MMIYOO_QueueFillRects; + renderer->QueueCopy = MMIYOO_QueueCopy; + renderer->QueueCopyEx = MMIYOO_QueueCopyEx; + renderer->RunCommandQueue = MMIYOO_RunCommandQueue; + renderer->RenderReadPixels = MMIYOO_RenderReadPixels; + renderer->RenderPresent = MMIYOO_RenderPresent; + renderer->DestroyTexture = MMIYOO_DestroyTexture; + renderer->DestroyRenderer = MMIYOO_DestroyRenderer; + renderer->SetVSync = MMIYOO_SetVSync; + renderer->info = MMIYOO_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + renderer->driverdata = data; + renderer->window = window; + + if(data->initialized != SDL_FALSE) { + return 0; + } + data->initialized = SDL_TRUE; + + if(flags & SDL_RENDERER_PRESENTVSYNC) { + data->vsync = SDL_TRUE; + } + else { + data->vsync = SDL_FALSE; + } + + pixelformat = SDL_GetWindowPixelFormat(window); + switch(pixelformat) { + case SDL_PIXELFORMAT_RGB565: + data->bpp = 2; + break; + case SDL_PIXELFORMAT_ARGB8888: + data->bpp = 4; + break; + } + return renderer; +} + +SDL_RenderDriver MMIYOO_RenderDriver = { + .CreateRenderer = MMIYOO_CreateRenderer, + .info = { + .name = "MMIYOO", + .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, + .num_texture_formats = 2, + .texture_formats = { + [0] = SDL_PIXELFORMAT_RGB565, [2] = SDL_PIXELFORMAT_ARGB8888, + }, + .max_texture_width = 800, + .max_texture_height = 600, + } +}; + +#endif + diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 3f401a5b2efaa..c959f46a1a6dc 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -446,6 +446,7 @@ extern VideoBootStrap RPI_bootstrap; extern VideoBootStrap KMSDRM_bootstrap; extern VideoBootStrap KMSDRM_LEGACY_bootstrap; extern VideoBootStrap DUMMY_bootstrap; +extern VideoBootStrap MMIYOO_bootstrap; extern VideoBootStrap Wayland_bootstrap; extern VideoBootStrap NACL_bootstrap; extern VideoBootStrap VIVANTE_bootstrap; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index cad77f1a8035f..6e1aa66e980b2 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -124,6 +124,9 @@ static VideoBootStrap *bootstrap[] = { #endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, +#endif +#if SDL_VIDEO_DRIVER_MMIYOO + &MMIYOO_bootstrap, #endif NULL }; diff --git a/src/video/mmiyoo/SDL_event_mmiyoo.c b/src/video/mmiyoo/SDL_event_mmiyoo.c new file mode 100644 index 0000000000000..425f2eb51d00e --- /dev/null +++ b/src/video/mmiyoo/SDL_event_mmiyoo.c @@ -0,0 +1,242 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MMIYOO + +#include +#include +#include +#include +#include +#include +#include "../../events/SDL_events_c.h" +#include "../../core/linux/SDL_evdev.h" +#include "../../thread/SDL_systhread.h" + +#include "SDL_video_mmiyoo.h" +#include "SDL_event_mmiyoo.h" + +MMIYOO_EventInfo MMiyooEventInfo = {0}; + +extern MMIYOO_VideoInfo MMiyooVideoInfo; + +static int running = 0; +static int event_fd = -1; +static uint32_t pre_ticks = 0; +static SDL_sem *event_sem = NULL; +static SDL_Thread *thread = NULL; +static uint32_t pre_keypad_bitmaps = 0; + +static void check_mouse_pos(void) +{ + if (MMiyooEventInfo.mouse.y < MMiyooEventInfo.mouse.miny) { + MMiyooEventInfo.mouse.y = MMiyooEventInfo.mouse.miny; + } + if (MMiyooEventInfo.mouse.y > MMiyooEventInfo.mouse.maxy) { + MMiyooEventInfo.mouse.y = MMiyooEventInfo.mouse.maxy; + } + if (MMiyooEventInfo.mouse.x < MMiyooEventInfo.mouse.minx) { + MMiyooEventInfo.mouse.x = MMiyooEventInfo.mouse.minx; + } + if (MMiyooEventInfo.mouse.x >= MMiyooEventInfo.mouse.maxx) { + MMiyooEventInfo.mouse.x = MMiyooEventInfo.mouse.maxx; + } +} + +static int get_move_interval(int type) +{ + float move = 0.0; + + move = ((float)clock() - pre_ticks) / ((type == 0) ? 10000 : 12000); + if (move <= 0.0) { + move = 1.0; + } + return (int)(1.0 * move); +} + +int EventUpdate(void *data) +{ + uint32_t bit = 0; + struct input_event ev = {0}; + + while (running) { + SDL_SemWait(event_sem); + if (event_fd > 0) { + if (read(event_fd, &ev, sizeof(struct input_event))) { + if ((ev.type == EV_KEY) && (ev.value != 2)) { + //printf("%s, code:%d\n", __func__, ev.code); + + switch (ev.code) { + case 103: bit = (1 << MYKEY_UP); break; + case 108: bit = (1 << MYKEY_DOWN); break; + case 105: bit = (1 << MYKEY_LEFT); break; + case 106: bit = (1 << MYKEY_RIGHT); break; + case 57: bit = (1 << MYKEY_A); break; + case 29: bit = (1 << MYKEY_B); break; + case 42: bit = (1 << MYKEY_X); break; + case 56: bit = (1 << MYKEY_Y); break; + case 28: bit = (1 << MYKEY_START); break; + case 97: bit = (1 << MYKEY_SELECT); break; + case 18: bit = (1 << MYKEY_L1); break; + case 15: bit = (1 << MYKEY_L2); break; + case 20: bit = (1 << MYKEY_R1); break; + case 14: bit = (1 << MYKEY_R2); break; + case 1: bit = (1 << MYKEY_MENU); break; + case 116: bit = (1 << MYKEY_POWER); break; + case 115: bit = (1 << MYKEY_VOLUP); break; + case 114: bit = (1 << MYKEY_VOLDOWN); break; + } + + if(bit){ + if(ev.value){ + MMiyooEventInfo.keypad.bitmaps|= bit; + } + else{ + MMiyooEventInfo.keypad.bitmaps&= ~bit; + } + } + } + + if (!(MMiyooEventInfo.keypad.bitmaps & 0x0f)) { + pre_ticks = clock(); + } + } + } + SDL_SemPost(event_sem); + usleep(1000000 / 60); + } + + return 0; +} + +void MMIYOO_EventInit(void) +{ + pre_keypad_bitmaps = 0; + memset(&MMiyooEventInfo, 0, sizeof(MMiyooEventInfo)); + MMiyooEventInfo.mouse.minx = 0; + MMiyooEventInfo.mouse.miny = 0; + MMiyooEventInfo.mouse.maxx = 256; + MMiyooEventInfo.mouse.maxy = 192; + MMiyooEventInfo.mouse.x = 50; + MMiyooEventInfo.mouse.y = 190; + MMiyooEventInfo.mode = MMIYOO_KEYPAD_MODE; + +#if defined(MMIYOO) + event_fd = open("/dev/input/event0", O_RDONLY | O_NONBLOCK | O_CLOEXEC); + if(event_fd < 0){ + printf("failed to open /dev/input/event0\n"); + } +#endif + + if((event_sem = SDL_CreateSemaphore(1)) == NULL) { + SDL_SetError("Can't create input semaphore"); + return; + } + + running = 1; + if((thread = SDL_CreateThreadInternal(EventUpdate, "MMIYOOInputThread", 4096, NULL)) == NULL) { + SDL_SetError("Can't create input thread"); + return; + } +} + +void MMIYOO_EventDeinit(void) +{ + running = 0; + SDL_WaitThread(thread, NULL); + SDL_DestroySemaphore(event_sem); + if(event_fd > 0) { + close(event_fd); + event_fd = -1; + } +} + +void MMIYOO_PumpEvents(_THIS) +{ + const SDL_Scancode code[]={ + SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, + SDLK_SPACE, SDLK_LCTRL, SDLK_LSHIFT, SDLK_LALT, + SDLK_e, SDLK_t, SDLK_TAB, SDLK_BACKSPACE, + SDLK_RCTRL, SDLK_RETURN, SDLK_ESCAPE + }; + + SDL_SemWait(event_sem); + if (MMiyooEventInfo.mode == MMIYOO_KEYPAD_MODE) { + if (pre_keypad_bitmaps != MMiyooEventInfo.keypad.bitmaps) { + int cc = 0; + uint32_t v0 = pre_keypad_bitmaps; + uint32_t v1 = MMiyooEventInfo.keypad.bitmaps; + + for (cc=0; cc<=MYKEY_LAST_BITS; cc++) { + if ((v0 & 1) != (v1 & 1)) { + SDL_SendKeyboardKey((v1 & 1) ? SDL_PRESSED : SDL_RELEASED, SDL_GetScancodeFromKey(code[cc])); + } + v0>>= 1; + v1>>= 1; + } + pre_keypad_bitmaps = MMiyooEventInfo.keypad.bitmaps; + } + } + else { + int updated = 0; + + if (pre_keypad_bitmaps != MMiyooEventInfo.keypad.bitmaps) { + uint32_t v0 = pre_keypad_bitmaps; + uint32_t v1 = MMiyooEventInfo.keypad.bitmaps; + + if ((v0 & (1 << MYKEY_A)) != (v1 & (1 << MYKEY_A))) { + SDL_SendMouseButton(MMiyooVideoInfo.window, 0, (v1 & (1 << MYKEY_A)) ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_LEFT); + } + } + + if (MMiyooEventInfo.keypad.bitmaps & (1 << MYKEY_UP)) { + updated = 1; + MMiyooEventInfo.mouse.y-= get_move_interval(1); + } + if (MMiyooEventInfo.keypad.bitmaps & (1 << MYKEY_DOWN)) { + updated = 1; + MMiyooEventInfo.mouse.y+= get_move_interval(1); + } + if (MMiyooEventInfo.keypad.bitmaps & (1 << MYKEY_LEFT)) { + updated = 1; + MMiyooEventInfo.mouse.x-= get_move_interval(0); + } + if (MMiyooEventInfo.keypad.bitmaps & (1 << MYKEY_RIGHT)) { + updated = 1; + MMiyooEventInfo.mouse.x+= get_move_interval(0); + } + check_mouse_pos(); + + if(updated){ + SDL_SendMouseMotion(MMiyooVideoInfo.window, 0, 0, MMiyooEventInfo.mouse.x, MMiyooEventInfo.mouse.y); + } + + pre_keypad_bitmaps = MMiyooEventInfo.keypad.bitmaps; + } + SDL_SemPost(event_sem); +} + +#endif + diff --git a/src/video/mmiyoo/SDL_event_mmiyoo.h b/src/video/mmiyoo/SDL_event_mmiyoo.h new file mode 100644 index 0000000000000..9e0d402164384 --- /dev/null +++ b/src/video/mmiyoo/SDL_event_mmiyoo.h @@ -0,0 +1,80 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef __SDL_EVENT_MMIYOO_H__ +#define __SDL_EVENT_MMIYOO_H__ + +#include "../../SDL_internal.h" +#include "SDL_event_mmiyoo.h" + +#define MYKEY_UP 0 +#define MYKEY_DOWN 1 +#define MYKEY_LEFT 2 +#define MYKEY_RIGHT 3 +#define MYKEY_A 4 +#define MYKEY_B 5 +#define MYKEY_X 6 +#define MYKEY_Y 7 +#define MYKEY_L1 8 +#define MYKEY_R1 9 +#define MYKEY_L2 10 +#define MYKEY_R2 11 +#define MYKEY_SELECT 12 +#define MYKEY_START 13 +#define MYKEY_MENU 14 +#define MYKEY_QSAVE 15 +#define MYKEY_QLOAD 16 +#define MYKEY_FF 17 +#define MYKEY_EXIT 18 +#define MYKEY_POWER 19 +#define MYKEY_VOLUP 20 +#define MYKEY_VOLDOWN 21 + +#define MYKEY_LAST_BITS 18 // ignore POWER, VOL-, VOL+ keys + +#define MMIYOO_KEYPAD_MODE 0 +#define MMIYOO_MOUSE_MODE 1 + +typedef struct _MMIYOO_EventInfo { + struct _keypad{ + uint32_t bitmaps; + } keypad; + + struct _mouse{ + int x; + int y; + int minx; + int miny; + int maxx; + int maxy; + } mouse; + + int mode; +} MMIYOO_EventInfo; + +extern void MMIYOO_EventInit(void); +extern void MMIYOO_EventDeinit(void); +extern void MMIYOO_PumpEvents(_THIS); + +#endif + diff --git a/src/video/mmiyoo/SDL_framebuffer_mmiyoo.c b/src/video/mmiyoo/SDL_framebuffer_mmiyoo.c new file mode 100644 index 0000000000000..1706560b84f44 --- /dev/null +++ b/src/video/mmiyoo/SDL_framebuffer_mmiyoo.c @@ -0,0 +1,86 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MMIYOO + +#include "../SDL_sysvideo.h" +#include "SDL_framebuffer_mmiyoo.h" + +#define MMIYOO_SURFACE "_SDL_MMiyooSurface" + +int MMIYOO_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) +{ + SDL_Surface *surface; + const Uint32 surface_format = SDL_PIXELFORMAT_RGB888; + int w, h; + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + + surface = (SDL_Surface *) SDL_GetWindowData(window, MMIYOO_SURFACE); + SDL_FreeSurface(surface); + + SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); + SDL_GetWindowSize(window, &w, &h); + surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); + if(!surface) { + return -1; + } + + SDL_SetWindowData(window, MMIYOO_SURFACE, surface); + *format = surface_format; + *pixels = surface->pixels; + *pitch = surface->pitch; + return 0; +} + +int MMIYOO_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + static int frame_number; + SDL_Surface *surface; + + surface = (SDL_Surface *) SDL_GetWindowData(window, MMIYOO_SURFACE); + if(!surface) { + return SDL_SetError("Couldn't find mmiyoo surface for window"); + } + + if(SDL_getenv("SDL_VIDEO_MMIYOO_SAVE_FRAMES")) { + char file[128]; + SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", + SDL_GetWindowID(window), ++frame_number); + SDL_SaveBMP(surface, file); + } + return 0; +} + +void MMIYOO_DestroyWindowFramebuffer(_THIS, SDL_Window *window) +{ + SDL_Surface *surface; + + surface = (SDL_Surface *) SDL_SetWindowData(window, MMIYOO_SURFACE, NULL); + SDL_FreeSurface(surface); +} + +#endif + diff --git a/src/video/mmiyoo/SDL_framebuffer_mmiyoo.h b/src/video/mmiyoo/SDL_framebuffer_mmiyoo.h new file mode 100644 index 0000000000000..34563f66f1b62 --- /dev/null +++ b/src/video/mmiyoo/SDL_framebuffer_mmiyoo.h @@ -0,0 +1,35 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef __SDL_FRAMEBUFFER_MMIYOO_H__ +#define __SDL_FRAMEBUFFER_MMIYOO_H__ + +#include "../../SDL_internal.h" + +extern int MMIYOO_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch); +extern int MMIYOO_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void MMIYOO_DestroyWindowFramebuffer(_THIS, SDL_Window *window); + +#endif + diff --git a/src/video/mmiyoo/SDL_opengles_mmiyoo.c b/src/video/mmiyoo/SDL_opengles_mmiyoo.c new file mode 100644 index 0000000000000..b149652615be2 --- /dev/null +++ b/src/video/mmiyoo/SDL_opengles_mmiyoo.c @@ -0,0 +1,166 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MMIYOO + +#include "SDL_video_mmiyoo.h" +#include "SDL_opengles_mmiyoo.h" + +static EGLDisplay display=0; +static EGLContext context=0; +static EGLSurface surface=0; +static EGLConfig config=0; +static void *ppFunc=NULL; +static void *pfb_idx=NULL; +static void *pfb_vaddr=NULL; + +EGLBoolean eglUpdateBufferSettings(EGLDisplay display, EGLSurface surface, void *pFunc, void *fb_idx, void *fb_vaddr); + +int glLoadLibrary(_THIS, const char *name) +{ + return 0; +} + +void *glGetProcAddress(_THIS, const char *proc) +{ + return eglGetProcAddress(proc); +} + +void glUnloadLibrary(_THIS) +{ + eglTerminate(_this->gl_data->display); +} + +SDL_GLContext glCreateContext(_THIS, SDL_Window *window) +{ + EGLint i=0; + EGLint val=0; + EGLBoolean rc=0; + EGLConfig *cfgs=NULL; + EGLint numConfigs=0; + EGLint majorVersion=0; + EGLint minorVersion=0; + struct { + EGLint client_version[2]; + EGLint none; + } egl_ctx_attr = { + .client_version = { EGL_CONTEXT_CLIENT_VERSION, 2 }, + .none = EGL_NONE + }; + + struct { + EGLint render_buffer[2]; + EGLint none; + } egl_surf_attr = { + .render_buffer = { EGL_RENDER_BUFFER, EGL_BACK_BUFFER }, + .none = EGL_NONE + }; + + display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + eglInitialize(display, &majorVersion, &minorVersion); + eglGetConfigs(display, NULL, 0, &numConfigs); + printf("sdl2 eglGetConfigs %d\n", numConfigs); + + cfgs = SDL_malloc(numConfigs * sizeof(EGLConfig)); + if(cfgs == NULL) { + return NULL; + } + + rc = eglGetConfigs(display, cfgs, numConfigs, &numConfigs); + if(rc != EGL_TRUE) { + SDL_free(cfgs); + return NULL; + } + + for(i = 0; i < numConfigs; i++) { + eglGetConfigAttrib(display, cfgs[i], EGL_SURFACE_TYPE, &val); + if(!(val & EGL_WINDOW_BIT)) { + continue; + } + + eglGetConfigAttrib(display, cfgs[i], EGL_RENDERABLE_TYPE, &val); + if(!(val & EGL_OPENGL_ES2_BIT)) { + continue; + } + + eglGetConfigAttrib(display, cfgs[i], EGL_DEPTH_SIZE, &val); + if(val == 0) { + continue; + } + + config = cfgs[i]; + printf("sdl2 set config %d\n", i); + break; + } + SDL_free(cfgs); + + printf("sdl2 eglCreateContext\n"); + context = eglCreateContext(display, config, EGL_NO_CONTEXT, (EGLint *)&egl_ctx_attr); + if(context == EGL_NO_CONTEXT) { + return NULL; + } + + printf("sdl2 eglCreateWindowSurface\n"); + surface = eglCreateWindowSurface(display, config, 0, (EGLint*)&egl_surf_attr); + if(surface == EGL_NO_SURFACE) { + return NULL; + } + + printf("sdl2 eglMakeCurrent\n"); + eglMakeCurrent(display, surface, surface, context); + + printf("sdl2 %s, %p %p %p\n", __func__, ppFunc, pfb_idx, pfb_vaddr); + eglUpdateBufferSettings(display, surface, ppFunc, pfb_idx, pfb_vaddr); + return context; +} + +int glSetSwapInterval(_THIS, int interval) +{ + return 0; +} + +int glUpdateBufferSettings(void *pFunc, void *fb_idx, void *fb_vaddr) +{ + ppFunc = pFunc; + pfb_idx = fb_idx; + pfb_vaddr = fb_vaddr; + return 0; +} + +int glSwapWindow(_THIS, SDL_Window *window) +{ + return eglSwapBuffers(display, surface) == EGL_TRUE ? 0 : -1; +} + +int glMakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) +{ + return 0; +} + +void glDeleteContext(_THIS, SDL_GLContext context) +{ +} + +#endif diff --git a/src/video/mmiyoo/SDL_opengles_mmiyoo.h b/src/video/mmiyoo/SDL_opengles_mmiyoo.h new file mode 100644 index 0000000000000..6e5658e48adeb --- /dev/null +++ b/src/video/mmiyoo/SDL_opengles_mmiyoo.h @@ -0,0 +1,49 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef __SDL_OPENGLES_MMIYOO_H__ +#define __SDL_OPENGLES_MMIYOO_H__ + +#include +#include +#include "../SDL_sysvideo.h" + +typedef struct SDL_GLDriverData +{ + EGLDisplay display; + EGLContext context; + EGLSurface surface; +} SDL_GLDriverData; + +void *glGetProcAddress(_THIS, const char *proc); +extern int glGetConfig(EGLConfig *pconf, int *pformat); +extern int glLoadLibrary(_THIS, const char *name); +extern int glSetSwapInterval(_THIS, int interval); +extern int glSwapWindow(_THIS, SDL_Window *window); +extern int glMakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context); +extern int glUpdateBufferSettings(void *pFunc, void *fb_idx, void *fb_vaddr); +extern void glDeleteContext(_THIS, SDL_GLContext context); +extern void glUnloadLibrary(_THIS); +extern SDL_GLContext glCreateContext(_THIS, SDL_Window *window); + +#endif diff --git a/src/video/mmiyoo/SDL_video_mmiyoo.c b/src/video/mmiyoo/SDL_video_mmiyoo.c new file mode 100644 index 0000000000000..fd6db6f0cd902 --- /dev/null +++ b/src/video/mmiyoo/SDL_video_mmiyoo.c @@ -0,0 +1,333 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MMIYOO + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../events/SDL_events_c.h" +#include "../SDL_sysvideo.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" + +#include "SDL_image.h" +#include "SDL_version.h" +#include "SDL_syswm.h" +#include "SDL_loadso.h" +#include "SDL_events.h" +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "SDL_video_mmiyoo.h" +#include "SDL_event_mmiyoo.h" +#include "SDL_opengles_mmiyoo.h" +#include "SDL_framebuffer_mmiyoo.h" + +#include "hex_pen.h" + +MMIYOO_VideoInfo MMiyooVideoInfo={0}; +extern MMIYOO_EventInfo MMiyooEventInfo; + +static GFX gfx = {0}; +static int MMIYOO_VideoInit(_THIS); +static int MMIYOO_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +static void MMIYOO_VideoQuit(_THIS); + +void GFX_Init(void) +{ + MI_SYS_Init(); + MI_GFX_Open(); + + gfx.fd = open("/dev/fb0", O_RDWR); + ioctl(gfx.fd, FBIOGET_FSCREENINFO, &gfx.finfo); + gfx.fb.phyAddr = gfx.finfo.smem_start; + ioctl(gfx.fd, FBIOGET_VSCREENINFO, &gfx.vinfo); + gfx.vinfo.yoffset = 0; + ioctl(gfx.fd, FBIOPUT_VSCREENINFO, &gfx.vinfo); + MI_SYS_MemsetPa(gfx.fb.phyAddr, 0, FB_SIZE); + MI_SYS_Mmap(gfx.fb.phyAddr, gfx.finfo.smem_len, &gfx.fb.virAddr, TRUE); + memset(&gfx.hw.opt, 0, sizeof(gfx.hw.opt)); + + MI_SYS_MMA_Alloc(NULL, TMP_SIZE, &gfx.tmp.phyAddr); + MI_SYS_Mmap(gfx.tmp.phyAddr, TMP_SIZE, &gfx.tmp.virAddr, TRUE); + + MI_SYS_MMA_Alloc(NULL, TMP_SIZE, &gfx.overlay.phyAddr); + MI_SYS_Mmap(gfx.overlay.phyAddr, TMP_SIZE, &gfx.overlay.virAddr, TRUE); +} + +void GFX_Quit(void) +{ + gfx.vinfo.yoffset = 0; + ioctl(gfx.fd, FBIOPUT_VSCREENINFO, &gfx.vinfo); + close(gfx.fd); + gfx.fd = 0; + + MI_SYS_Munmap(gfx.fb.virAddr, TMP_SIZE); + MI_SYS_Munmap(gfx.tmp.virAddr, TMP_SIZE); + MI_SYS_MMA_Free(gfx.tmp.phyAddr); + MI_SYS_Munmap(gfx.overlay.virAddr, TMP_SIZE); + MI_SYS_MMA_Free(gfx.overlay.phyAddr); + MI_GFX_Close(); + MI_SYS_Exit(); +} + +void GFX_Clear(void) +{ + MI_SYS_MemsetPa(gfx.fb.phyAddr, 0, FB_SIZE); + MI_SYS_MemsetPa(gfx.tmp.phyAddr, 0, TMP_SIZE); +} + +int GFX_Copy(const void *pixels, SDL_Rect srcrect, SDL_Rect dstrect, int pitch, int alpha, int rotate) +{ + MI_U16 u16Fence = 0; + + if (pixels == NULL) { + return -1; + } + memcpy(gfx.tmp.virAddr, pixels, srcrect.h * pitch); + + gfx.hw.opt.u32GlobalSrcConstColor = 0; + gfx.hw.opt.eRotate = rotate; + gfx.hw.opt.eSrcDfbBldOp = E_MI_GFX_DFB_BLD_ONE; + gfx.hw.opt.eDstDfbBldOp = 0; + gfx.hw.opt.eDFBBlendFlag = 0; + + gfx.hw.src.rt.s32Xpos = srcrect.x; + gfx.hw.src.rt.s32Ypos = srcrect.y; + gfx.hw.src.rt.u32Width = srcrect.w; + gfx.hw.src.rt.u32Height = srcrect.h; + gfx.hw.src.surf.u32Width = srcrect.w; + gfx.hw.src.surf.u32Height = srcrect.h; + gfx.hw.src.surf.u32Stride = pitch; + gfx.hw.src.surf.eColorFmt = (pitch / srcrect.w) == 2 ? E_MI_GFX_FMT_RGB565 : E_MI_GFX_FMT_ARGB8888; + gfx.hw.src.surf.phyAddr = gfx.tmp.phyAddr; + + gfx.hw.dst.rt.s32Xpos = 0; + gfx.hw.dst.rt.s32Ypos = 0; + gfx.hw.dst.rt.u32Width = FB_W; + gfx.hw.dst.rt.u32Height = FB_H; + gfx.hw.dst.rt.s32Xpos = dstrect.x; + gfx.hw.dst.rt.s32Ypos = dstrect.y; + gfx.hw.dst.rt.u32Width = dstrect.w; + gfx.hw.dst.rt.u32Height = dstrect.h; + gfx.hw.dst.surf.u32Width = FB_W; + gfx.hw.dst.surf.u32Height = FB_H; + gfx.hw.dst.surf.u32Stride = FB_W * FB_BPP; + gfx.hw.dst.surf.eColorFmt = E_MI_GFX_FMT_ARGB8888; + gfx.hw.dst.surf.phyAddr = gfx.fb.phyAddr + (FB_W * gfx.vinfo.yoffset * FB_BPP); + + MI_SYS_FlushInvCache(gfx.tmp.virAddr, pitch * srcrect.h); + MI_GFX_BitBlit(&gfx.hw.src.surf, &gfx.hw.src.rt, &gfx.hw.dst.surf, &gfx.hw.dst.rt, &gfx.hw.opt, &u16Fence); + MI_GFX_WaitAllDone(FALSE, u16Fence); + return 0; +} + +void GFX_Flip(void) +{ + ioctl(gfx.fd, FBIOPAN_DISPLAY, &gfx.vinfo); + gfx.vinfo.yoffset ^= FB_H; +} + +static int MMIYOO_Available(void) +{ + const char *envr = SDL_getenv("SDL_VIDEODRIVER"); + if((envr) && (SDL_strcmp(envr, MMIYOO_DRIVER_NAME) == 0)) { + return 1; + } + return 0; +} + +static void MMIYOO_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device); +} + +int MMIYOO_CreateWindow(_THIS, SDL_Window *window) +{ + SDL_SetMouseFocus(window); + MMiyooVideoInfo.window = window; + printf("%s, w:%d, h:%d\n", __func__, window->w, window->h); + //glUpdateBufferSettings(fb_flip, &fb_idx, fb_vaddr); + return 0; +} + +int MMIYOO_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) +{ + return SDL_Unsupported(); +} + +static SDL_VideoDevice *MMIYOO_CreateDevice(int devindex) +{ + SDL_VideoDevice *device=NULL; + SDL_GLDriverData *gldata=NULL; + + if(!MMIYOO_Available()) { + return (0); + } + + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if(!device) { + SDL_OutOfMemory(); + return (0); + } + device->is_dummy = SDL_TRUE; + + device->VideoInit = MMIYOO_VideoInit; + device->VideoQuit = MMIYOO_VideoQuit; + device->SetDisplayMode = MMIYOO_SetDisplayMode; + device->PumpEvents = MMIYOO_PumpEvents; + device->CreateSDLWindow = MMIYOO_CreateWindow; + device->CreateSDLWindowFrom = MMIYOO_CreateWindowFrom; + device->CreateWindowFramebuffer = MMIYOO_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = MMIYOO_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = MMIYOO_DestroyWindowFramebuffer; + + device->GL_LoadLibrary = glLoadLibrary; + device->GL_GetProcAddress = glGetProcAddress; + device->GL_CreateContext = glCreateContext; + device->GL_SetSwapInterval = glSetSwapInterval; + device->GL_SwapWindow = glSwapWindow; + device->GL_MakeCurrent = glMakeCurrent; + device->GL_DeleteContext = glDeleteContext; + device->GL_UnloadLibrary = glUnloadLibrary; + + gldata = (SDL_GLDriverData*)SDL_calloc(1, sizeof(SDL_GLDriverData)); + if(gldata == NULL) { + SDL_OutOfMemory(); + SDL_free(device); + return NULL; + } + device->gl_data = gldata; + + device->free = MMIYOO_DeleteDevice; + return device; +} + +VideoBootStrap MMIYOO_bootstrap = {MMIYOO_DRIVER_NAME, "MMIYOO VIDEO DRIVER", MMIYOO_CreateDevice}; + +int MMIYOO_VideoInit(_THIS) +{ + SDL_DisplayMode mode={0}; + SDL_VideoDisplay display={0}; + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_RGB565; + mode.w = 640; + mode.h = 480; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_ARGB8888; + mode.w = 640; + mode.h = 480; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_RGB565; + mode.w = 800; + mode.h = 480; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_ARGB8888; + mode.w = 800; + mode.h = 480; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_RGB565; + mode.w = 800; + mode.h = 600; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_ARGB8888; + mode.w = 800; + mode.h = 600; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_RGB565; + mode.w = 320; + mode.h = 240; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_ARGB8888; + mode.w = 320; + mode.h = 240; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_RGB565; + mode.w = 480; + mode.h = 272; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_ARGB8888; + mode.w = 480; + mode.h = 272; + mode.refresh_rate = 60; + SDL_AddDisplayMode(&display, &mode); + + SDL_AddVideoDisplay(&display, SDL_FALSE); + + GFX_Init(); + MMIYOO_EventInit(); + return 0; +} + +static int MMIYOO_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + return 0; +} + +void MMIYOO_VideoQuit(_THIS) +{ + GFX_Quit(); + MMIYOO_EventDeinit(); +} + +#endif + diff --git a/src/video/mmiyoo/SDL_video_mmiyoo.h b/src/video/mmiyoo/SDL_video_mmiyoo.h new file mode 100644 index 0000000000000..482610f619cba --- /dev/null +++ b/src/video/mmiyoo/SDL_video_mmiyoo.h @@ -0,0 +1,95 @@ +/* + Customized version for Miyoo-Mini handheld. + Only tested under Miyoo-Mini stock OS (original firmware) with Parasyte compatible layer. + + Copyright (C) 1997-2022 Sam Lantinga + Copyright (C) 2022-2022 Steward Fu + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef __SDL_VIDEO_MMIYOO_H__ +#define __SDL_VIDEO_MMIYOO_H__ + +#include + +#include "../SDL_sysvideo.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_ttf.h" +#include "SDL_image.h" +#include "SDL_version.h" +#include "SDL_syswm.h" +#include "SDL_loadso.h" +#include "SDL_events.h" +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "SDL_video_mmiyoo.h" +#include "SDL_event_mmiyoo.h" +#include "SDL_framebuffer_mmiyoo.h" +#include "SDL_opengles_mmiyoo.h" + +#include "../../audio/mmiyoo/mi_sys.h" +#include "../../video/mmiyoo/mi_gfx.h" + +#ifndef MAX_PATH + #define MAX_PATH 255 +#endif + +#define FB_W 640 +#define FB_H 480 +#define FB_BPP 4 +#define FB_SIZE (FB_W * FB_H * FB_BPP * 2) +#define TMP_SIZE (FB_W * FB_H * FB_BPP) +#define MMIYOO_DRIVER_NAME "mmiyoo" +#define BASE_REG_RIU_PA 0x1f000000 +#define BASE_REG_MPLL_PA (BASE_REG_RIU_PA + 0x103000 * 2) + +typedef struct MMIYOO_VideoInfo { + SDL_Window *window; +} MMIYOO_VideoInfo; + +typedef struct _GFX { + int fd; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + + struct _DMA { + MI_PHY phyAddr; + void *virAddr; + } fb, tmp, overlay; + + struct _HW { + struct _BUF { + MI_GFX_Surface_t surf; + MI_GFX_Rect_t rt; + } src, dst, overlay; + MI_GFX_Opt_t opt; + } hw; +} GFX; + +void GFX_Clear(void); +void GFX_Flip(void); +int GFX_Copy(const void *pixels, SDL_Rect srcrect, SDL_Rect dstrect, int pitch, int alpha, int rotate); + +int draw_pen(const void *pixels, int width, int pitch); + +#endif + diff --git a/src/video/mmiyoo/hex_pen.h b/src/video/mmiyoo/hex_pen.h new file mode 100644 index 0000000000000..78d2d612c10d5 --- /dev/null +++ b/src/video/mmiyoo/hex_pen.h @@ -0,0 +1,30 @@ +uint32_t hex_pen[] = { +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6d1b19,0x922422,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e1b19,0xff3e3a,0xff3e3a,0x912421,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e1b19,0xff3e3a,0xff3e3a,0xff3e3a,0xff3e3a,0x912421,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6d1b19,0xff3e3a,0xff3e3a,0xff3e3a,0xff3e3a,0xff3e3a,0xff3e3a,0x832025,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e500e,0xff8131,0xff3e3a,0xff3e3a,0xff3e3a,0xff3e3a,0xff3e3a,0xe73840,0xcc3245,0x741d28,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e500e,0xffb820,0xffb820,0xff8131,0xff3e3a,0xff3e3a,0xff3e3a,0xe73840,0xcc3245,0xcc3245,0xcc3245,0x741d28,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6d4f0e,0xffb820,0xffb820,0xffb820,0xffb820,0xff8131,0xff3e3a,0xe73840,0xcc3245,0xcc3245,0xcc3245,0xcc3245,0xcc3245,0x751d28, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6d4f0e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xf17736,0xcc3245,0xcc3245,0xcc3245,0xcc3245,0xcc3245,0xcc3245,0x57161e, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e500e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xe26c3b,0xcc3245,0xcc3245,0xcc3245,0xcc3245,0x59161e,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e500e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xe26c3b,0xcc3245,0xcc3245,0x58161e,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e500e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xe26c3b,0x58161e,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e500e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6e4311,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6e500e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6f4311,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x6d4f0e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6d4211,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x0,0x6d4f0e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6d4211,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x0,0x6e500e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6f4311,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x0,0x6e500e,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6e4311,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0x6a5023,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6e4311,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x0,0xe9d1a1,0xffc45e,0xffb820,0xffb820,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6e4311,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x403a2e,0xffe7b5,0xffe5b0,0xffc45e,0xffb820,0xffb820,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6f4311,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0x8f8266,0xffe7b5,0xffe7b5,0xffe5b1,0xffc45e,0xffaa24,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6d4211,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x0,0xe4cea2,0xffe7b5,0xffe7b5,0xffe7b5,0xffda91,0xffa83e,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0xff9a27,0x6d4211,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x151424,0xe5d0b0,0xffe7b5,0xffe7b5,0xffdc95,0xffd06a,0xffce68,0xffa83e,0xff9a27,0xff9a27,0xff9a27,0x6f4311,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x1e2155,0x5252a0,0xe5d0b0,0xffdc95,0xffd06a,0xffd06a,0xffd06a,0xffce68,0xffa83e,0xff9a27,0x6e4311,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x0,0x30378b,0x373e9f,0x504386,0xe5b969,0xffd06a,0xffd06a,0xffd06a,0xffd06a,0xe9bb5f,0x6a4518,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0xb0c1e,0x373e9f,0x352c86,0x340d66,0x503366,0xe4b969,0xe4ba5f,0x8f753c,0x41351b,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x1c2051,0x352c86,0x340d66,0x2e0c59,0x1c0737,0x150e17,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +0x251f5d,0x1b0734,0xa0314,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, +}; \ No newline at end of file diff --git a/src/video/mmiyoo/mi_ai.h b/src/video/mmiyoo/mi_ai.h new file mode 100755 index 0000000000000..0c3331ccb3e96 --- /dev/null +++ b/src/video/mmiyoo/mi_ai.h @@ -0,0 +1,111 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef __MI_AI_H__ +#define __MI_AI_H__ + +#include "mi_aio_datatype.h" +#include "mi_ai_datatype.h" + + +#define AI_MAJOR_VERSION 2 +#define AI_SUB_VERSION 12 +#define MACRO_TO_STR(macro) #macro +#define AI_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_ai_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_ai_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_ai_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_AI_API_VERSION AI_VERSION_STR(AI_MAJOR_VERSION,AI_SUB_VERSION) + +#ifdef __cplusplus +extern "C" { +#endif + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= + + +//============================================================================= +// Data type definition +//============================================================================= + + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= +MI_S32 MI_AI_SetPubAttr(MI_AUDIO_DEV AiDevId, MI_AUDIO_Attr_t *pstAttr); +MI_S32 MI_AI_GetPubAttr(MI_AUDIO_DEV AiDevId, MI_AUDIO_Attr_t*pstAttr); +MI_S32 MI_AI_Enable(MI_AUDIO_DEV AiDevId); +MI_S32 MI_AI_Disable(MI_AUDIO_DEV AiDevId); +MI_S32 MI_AI_EnableChn(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_DisableChn(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_GetFrame(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AUDIO_Frame_t*pstFrm, MI_AUDIO_AecFrame_t *pstAecFrm , MI_S32 s32MilliSec); +MI_S32 MI_AI_ReleaseFrame(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AUDIO_Frame_t *pstFrm, MI_AUDIO_AecFrame_t *pstAecFrm); +MI_S32 MI_AI_SetChnParam(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_ChnParam_t *pstChnParam); +MI_S32 MI_AI_GetChnParam(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_ChnParam_t *pstChnParam); +MI_S32 MI_AI_EnableReSmp(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AUDIO_SampleRate_e eOutSampleRate); +MI_S32 MI_AI_DisableReSmp(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_SetVqeAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AI_VqeConfig_t *pstVqeConfig); +MI_S32 MI_AI_GetVqeAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_VqeConfig_t *pstVqeConfig); +MI_S32 MI_AI_EnableVqe(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_DisableVqe(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_ClrPubAttr(MI_AUDIO_DEV AiDevId); +MI_S32 MI_AI_SaveFile(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn,MI_AUDIO_SaveFileInfo_t *pstSaveFileInfo); +MI_S32 MI_AI_SetVqeVolume(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_S32 s32VolumeDb); +MI_S32 MI_AI_GetVqeVolume(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_S32 *ps32VolumeDb); +MI_S32 MI_AI_SetAencAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_AencConfig_t * pstAencConfig); +MI_S32 MI_AI_GetAencAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_AencConfig_t * pstAencConfig); +MI_S32 MI_AI_EnableAenc(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_DisableAenc(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_DupChn(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_SetAedAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_AedConfig_t *pstAedConfig); +MI_S32 MI_AI_GetAedAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_AedConfig_t *pstAedConfig); +MI_S32 MI_AI_EnableAed(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_DisableAed(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_GetAedResult(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_AedResult_t *pstAedResult); +MI_S32 MI_AI_SetExtAecChn(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_CHN AiAECSndChn); +MI_S32 MI_AI_SetSslInitAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_SslInitAttr_t* pstSslInitAttr); +MI_S32 MI_AI_GetSslInitAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_SslInitAttr_t* pstSslInitAttr); +MI_S32 MI_AI_SetSslConfigAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_SslConfigAttr_t* pstSslConfigAttr); +MI_S32 MI_AI_GetSslConfigAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_SslConfigAttr_t* pstSslConfigAttr); +MI_S32 MI_AI_EnableSsl(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_DisableSsl(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_GetSslDoa(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_S32 *ps32SslDoa); +MI_S32 MI_AI_SetBfInitAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_BfInitAttr_t* pstBfInitAttr); +MI_S32 MI_AI_GetBfInitAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_BfInitAttr_t* pstBfInitAttr); +MI_S32 MI_AI_SetBfConfigAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_BfConfigAttr_t* pstBfConfigAttr); +MI_S32 MI_AI_GetBfConfigAttr(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_AI_BfConfigAttr_t* pstBfConfigAttr); +MI_S32 MI_AI_EnableBf(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_DisableBf(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn); +MI_S32 MI_AI_SetBfAngle(MI_AUDIO_DEV AiDevId, MI_AI_CHN AiChn, MI_S32 s32BfAngle); + +#ifdef __cplusplus +} +#endif + +#endif ///__MI_AI_H__ diff --git a/src/video/mmiyoo/mi_ai_datatype.h b/src/video/mmiyoo/mi_ai_datatype.h new file mode 100755 index 0000000000000..11e3fbbc1528e --- /dev/null +++ b/src/video/mmiyoo/mi_ai_datatype.h @@ -0,0 +1,204 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef __MI_AI_DATATYPE_H__ +#define __MI_AI_DATATYPE_H__ + +#include "mi_common_datatype.h" + +#ifdef __cplusplus +extern "C" { +#endif + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= +#define MI_AI_DEV_NUM_MAX 4 +#define MI_AI_CHAN_NUM_MAX 4 + +#define MI_AI_ERR_INVALID_DEVID (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_DEVID)) +#define MI_AI_ERR_ILLEGAL_PARAM (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_ILLEGAL_PARAM)) +#define MI_AI_ERR_NOT_ENABLED (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_ENABLE)) +#define MI_AI_ERR_NULL_PTR (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NULL_PTR)) +#define MI_AI_ERR_INVALID_CHNID (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_CHNID)) +#define MI_AI_ERR_NOT_CONFIG (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_CONFIG)) +#define MI_AI_ERR_NOT_SUPPORT (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_SUPPORT)) +#define MI_AI_ERR_NOT_PERM (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_PERM)) +#define MI_AI_ERR_NOMEM (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOMEM)) +#define MI_AI_ERR_NOBUF (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOBUF)) +#define MI_AI_ERR_BUF_EMPTY (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUF_EMPTY)) +#define MI_AI_ERR_BUF_FULL (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUF_FULL)) +#define MI_AI_ERR_SYS_NOTREADY (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_SYS_NOTREADY)) +#define MI_AI_ERR_BUSY (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUSY)) +#define MI_AI_ERR_VQE_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_AI_VQE_ERR)) +#define MI_AI_ERR_AENC_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_AI_AENC_ERR)) +#define MI_AI_ERR_AED_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_AI_AED_ERR)) +#define MI_AI_ERR_SSL_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_AI_SSL_ERR)) +#define MI_AI_ERR_BF_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AI, E_MI_ERR_LEVEL_ERROR, E_MI_AI_BF_ERR)) + +//============================================================================= +// Data type definition +//============================================================================= +typedef enum +{ + E_MI_AI_VQE_ERR = MI_AI_INITIAL_ERROR_CODE, /* VQE of AI error */ + E_MI_AI_AENC_ERR, + E_MI_AI_AED_ERR, + E_MI_AI_SSL_ERR, + E_MI_AI_BF_ERR, +} MI_AI_ErrCode_e; + +typedef struct MI_AI_ChnGainConfig_s +{ + MI_BOOL bEnableGainSet; + MI_S16 s16FrontGain; + MI_S16 s16RearGain; +} MI_AI_ChnGainConfig_t; + +typedef struct MI_AI_ChnParam_s +{ + MI_AI_ChnGainConfig_t stChnGain; + MI_U32 u32Reserved; +} MI_AI_ChnParam_t; + +typedef struct MI_AI_AecConfig_s +{ + MI_BOOL bComfortNoiseEnable; + MI_S16 s16DelaySample; + MI_U32 u32AecSupfreq[6]; + MI_U32 u32AecSupIntensity[7]; + MI_S32 s32Reserved; +} MI_AI_AecConfig_t; + +typedef struct MI_AI_VqeConfig_s +{ + MI_BOOL bHpfOpen; + MI_BOOL bAecOpen; + MI_BOOL bAnrOpen; + MI_BOOL bAgcOpen; + MI_BOOL bEqOpen; + MI_U32 u32ChnNum; + MI_S32 s32WorkSampleRate; + MI_S32 s32FrameSample; + MI_AUDIO_HpfConfig_t stHpfCfg; + MI_AI_AecConfig_t stAecCfg; + MI_AUDIO_AnrConfig_t stAnrCfg; + MI_AUDIO_AgcConfig_t stAgcCfg; + MI_AUDIO_EqConfig_t stEqCfg; +} MI_AI_VqeConfig_t; + + +typedef enum{ + E_MI_AUDIO_AENC_TYPE_G711A = 0, + E_MI_AUDIO_AENC_TYPE_G711U, + E_MI_AUDIO_AENC_TYPE_G726, + E_MI_AUDIO_AENC_TYPE_INVALID, +} MI_AUDIO_AencType_e; + + +typedef struct MI_AUDIO_AencG711Config_s{ + MI_AUDIO_SampleRate_e eSamplerate; + MI_AUDIO_SoundMode_e eSoundmode; +} MI_AUDIO_AencG711Config_t; + +typedef struct MI_AUDIO_AencG726Config_s{ + MI_AUDIO_SampleRate_e eSamplerate; + MI_AUDIO_SoundMode_e eSoundmode; + MI_AUDIO_G726Mode_e eG726Mode; +} MI_AUDIO_AencG726Config_t; + +typedef struct MI_AI_AencConfig_s{ + MI_AUDIO_AencType_e eAencType; + union + { + MI_AUDIO_AencG711Config_t stAencG711Cfg; + MI_AUDIO_AencG726Config_t stAencG726Cfg; + }; +} MI_AI_AencConfig_t; + +typedef enum +{ + E_MI_AUDIO_AED_SEN_LOW, + E_MI_AUDIO_AED_SEN_MID, + E_MI_AUDIO_AED_SEN_HIGH, + E_MI_AUDIO_AED_SEN_INVALID, +} MI_AUDIO_AedSensitivity_e; + +typedef struct MI_AI_AedConfig_s +{ + MI_BOOL bEnableNr; + MI_AUDIO_AedSensitivity_e eSensitivity; + MI_S32 s32OperatingPoint; + MI_S32 s32VadThresholdDb; + MI_S32 s32LsdThresholdDb; +} MI_AI_AedConfig_t; + +typedef struct MI_AI_AedResult_s +{ + MI_BOOL bAcousticEventDetected; + MI_BOOL bLoudSoundDetected; +} MI_AI_AedResult_t; + +typedef struct MI_AI_SslInitAttr_s +{ + MI_U32 u32MicDistance; + MI_BOOL bBfMode; +} MI_AI_SslInitAttr_t; + +typedef struct MI_AI_SslConfigAttr_s +{ + MI_S32 s32Temperature; + MI_S32 s32NoiseGateDbfs; + MI_S32 s32DirectionFrameNum; + +} MI_AI_SslConfigAttr_t; + +typedef struct MI_AI_BfInitAttr_s +{ + MI_U32 u32MicDistance; + MI_U32 u32ChanCnt; +} MI_AI_BfInitAttr_t; + +typedef struct MI_AI_BfConfigAttr_s +{ + MI_S32 s32Temperature; + MI_S32 s32NoiseGateDbfs; + MI_S32 s32NoiseSupressionMode; + MI_S32 s32NoiseEstimation; + MI_FLOAT outputGain; +} MI_AI_BfConfigAttr_t; + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= + + +#ifdef __cplusplus +} +#endif + +#endif //__MI_AI_DATATYPE_H__ diff --git a/src/video/mmiyoo/mi_aio.h b/src/video/mmiyoo/mi_aio.h new file mode 100755 index 0000000000000..3e963bc1353c6 --- /dev/null +++ b/src/video/mmiyoo/mi_aio.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_AIO_DEP_H_ +#define _MI_AIO_DEP_H_ + + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= + + +//============================================================================= +// Data type definition +//============================================================================= + + + + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= + + +#endif // _MI_AIO_DEP_H_ diff --git a/src/video/mmiyoo/mi_aio_datatype.h b/src/video/mmiyoo/mi_aio_datatype.h new file mode 100755 index 0000000000000..47d5a8badf53d --- /dev/null +++ b/src/video/mmiyoo/mi_aio_datatype.h @@ -0,0 +1,225 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_AIO_DEP_DATATYPE_H_ +#define _MI_AIO_DEP_DATATYPE_H_ + +#include "mi_sys_datatype.h" + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= +#define MI_AUDIO_MAX_CHN_NUM (16) + + + +//============================================================================= +// Data type definition +//============================================================================= +typedef enum +{ + E_MI_AUDIO_ALGORITHM_MODE_DEFAULT, + E_MI_AUDIO_ALGORITHM_MODE_USER, + E_MI_AUDIO_ALGORITHM_MODE_MUSIC, + E_MI_AUDIO_ALGORITHM_MODE_INVALID, +}MI_AUDIO_AlgorithmMode_e; + +typedef enum +{ + E_MI_AUDIO_SAMPLE_RATE_8000 = 8000, /* 8kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_11025 = 11025, /* 11.025kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_12000 = 12000, /* 12kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_16000 = 16000, /* 16kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_22050 = 22050, /* 22.05kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_24000 = 24000, /* 24kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_32000 = 32000, /* 32kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_44100 = 44100, /* 44.1kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_48000 = 48000, /* 48kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_96000 = 96000, /* 96kHz sampling rate */ + E_MI_AUDIO_SAMPLE_RATE_INVALID, +}MI_AUDIO_SampleRate_e; + +typedef enum +{ + E_MI_AUDIO_BIT_WIDTH_16 =0, /* 16bit width */ + E_MI_AUDIO_BIT_WIDTH_24 =1, /* 24bit width */ + E_MI_AUDIO_BIT_WIDTH_MAX, +}MI_AUDIO_BitWidth_e; + +typedef enum +{ + E_MI_AUDIO_MODE_I2S_MASTER, /* I2S master mode */ + E_MI_AUDIO_MODE_I2S_SLAVE, /* I2S slave mode */ + E_MI_AUDIO_MODE_TDM_MASTER, /* TDM master mode */ + E_MI_AUDIO_MODE_TDM_SLAVE, /* TDM slave mode */ + E_MI_AUDIO_MODE_MAX, +}MI_AUDIO_Mode_e; + +typedef enum +{ + E_MI_AUDIO_SOUND_MODE_MONO = 0, /* mono */ + E_MI_AUDIO_SOUND_MODE_STEREO = 1, /* stereo */ + E_MI_AUDIO_SOUND_MODE_QUEUE = 2, /* all data in One chn */ + E_MI_AUDIO_SOUND_MODE_MAX, +}MI_AUDIO_SoundMode_e; + +typedef enum +{ + E_MI_AUDIO_HPF_FREQ_80 = 80, /* 80Hz */ + E_MI_AUDIO_HPF_FREQ_120 = 120, /* 120Hz */ + E_MI_AUDIO_HPF_FREQ_150 = 150, /* 150Hz */ + E_MI_AUDIO_HPF_FREQ_INVALID, +}MI_AUDIO_HpfFreq_e; + +typedef enum +{ + E_MI_AUDIO_NR_SPEED_LOW, + E_MI_AUDIO_NR_SPEED_MID, + E_MI_AUDIO_NR_SPEED_HIGH +}MI_AUDIO_NrSpeed_e; + +typedef enum +{ + E_MI_AUDIO_I2S_FMT_I2S_MSB, + E_MI_AUDIO_I2S_FMT_LEFT_JUSTIFY_MSB, +}MI_AUDIO_I2sFmt_e; + +typedef enum{ + E_MI_AUDIO_I2S_MCLK_0, //not enable + E_MI_AUDIO_I2S_MCLK_12_288M, //12.288M + E_MI_AUDIO_I2S_MCLK_16_384M, //16.384M + E_MI_AUDIO_I2S_MCLK_18_432M, //18.432M + E_MI_AUDIO_I2S_MCLK_24_576M, //24.576M + E_MI_AUDIO_I2S_MCLK_24M, // 24MHz + E_MI_AUDIO_I2S_MCLK_48M, // 48MHz +}MI_AUDIO_I2sMclk_e; + +typedef struct MI_AUDIO_I2sConfig_s +{ + MI_AUDIO_I2sFmt_e eFmt; + MI_AUDIO_I2sMclk_e eMclk; + MI_BOOL bSyncClock; //I2s Tx BCLK, Rx BCLK use the same clock source +}MI_AUDIO_I2sConfig_t; + +typedef struct MI_AUDIO_Attr_s +{ + MI_AUDIO_SampleRate_e eSamplerate; /* sample rate */ + MI_AUDIO_BitWidth_e eBitwidth; /* bitwidth */ + MI_AUDIO_Mode_e eWorkmode; /* I2s master or slave mode */ + MI_AUDIO_SoundMode_e eSoundmode; /* mono or stereo */ + MI_U32 u32FrmNum; /* frame num in buffer */ + MI_U32 u32PtNumPerFrm; /* number of samples */ + MI_U32 u32CodecChnCnt; /* channel number on Codec */ + MI_U32 u32ChnCnt; + union{ + MI_AUDIO_I2sConfig_t stI2sConfig; + }WorkModeSetting; + +}MI_AUDIO_Attr_t; + +typedef struct MI_AUDIO_Frame_s +{ + MI_AUDIO_BitWidth_e eBitwidth; /* audio frame bitwidth */ + MI_AUDIO_SoundMode_e eSoundmode; /* audio frame momo or stereo mode */ + void *apVirAddr[MI_AUDIO_MAX_CHN_NUM]; + MI_U64 u64TimeStamp; /* audio frame timestamp */ + MI_U32 u32Seq; /* audio frame seq */ + MI_U32 u32Len; /* data lenth per channel in frame */ + MI_U32 au32PoolId[2]; + /* Only use for Ai */ + void *apSrcPcmVirAddr[MI_AUDIO_MAX_CHN_NUM]; /* Ai original pcm data from ai channel */ + MI_U32 u32SrcPcmLen; /* length of Ai original pcm data */ + +}MI_AUDIO_Frame_t; + +typedef struct MI_AUDIO_AecFrame_s +{ + MI_AUDIO_Frame_t stRefFrame; /* aec reference audio frame */ + MI_BOOL bValid; /* whether frame is valid */ +}MI_AUDIO_AecFrame_t; + +typedef struct MI_AUDIO_SaveFileInfo_s +{ + MI_BOOL bCfg; + MI_U8 szFilePath[256]; + MI_U32 u32FileSize; /*in KB*/ +}MI_AUDIO_SaveFileInfo_t; + +typedef struct MI_AUDIO_HpfConfig_s +{ + MI_AUDIO_AlgorithmMode_e eMode; + MI_AUDIO_HpfFreq_e eHpfFreq; /*freq to be processed*/ +}MI_AUDIO_HpfConfig_t; + +typedef struct MI_AUDIO_AnrConfig_s +{ + MI_AUDIO_AlgorithmMode_e eMode; + MI_U32 u32NrIntensity; + MI_U32 u32NrSmoothLevel; + MI_AUDIO_NrSpeed_e eNrSpeed; +}MI_AUDIO_AnrConfig_t; + +typedef struct AgcGainInfo_s{ + MI_S32 s32GainMax; + MI_S32 s32GainMin; + MI_S32 s32GainInit; +}AgcGainInfo_t; + +typedef struct MI_AUDIO_AgcConfig_s +{ + MI_AUDIO_AlgorithmMode_e eMode; + AgcGainInfo_t stAgcGainInfo; + MI_U32 u32DropGainMax; + MI_U32 u32AttackTime; + MI_U32 u32ReleaseTime; + MI_S16 s16Compression_ratio_input[5]; + MI_S16 s16Compression_ratio_output[5]; + MI_S32 s32TargetLevelDb; + MI_S32 s32NoiseGateDb; + MI_U32 u32NoiseGateAttenuationDb; +}MI_AUDIO_AgcConfig_t; + +typedef struct MI_AUDIO_EqConfig_s +{ + MI_AUDIO_AlgorithmMode_e eMode; + MI_S16 s16EqGainDb[129]; +}MI_AUDIO_EqConfig_t; + +typedef enum{ + E_MI_AUDIO_G726_MODE_16 = 0, + E_MI_AUDIO_G726_MODE_24, + E_MI_AUDIO_G726_MODE_32, + E_MI_AUDIO_G726_MODE_40, + E_MI_AUDIO_G726_MODE_INVALID, +}MI_AUDIO_G726Mode_e; + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= + + +#endif // _MI_AIO_DEP_DATATYPE_H_ diff --git a/src/video/mmiyoo/mi_ao.h b/src/video/mmiyoo/mi_ao.h new file mode 100755 index 0000000000000..d0d5f54bba9df --- /dev/null +++ b/src/video/mmiyoo/mi_ao.h @@ -0,0 +1,93 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef __MI_AO_H__ +#define __MI_AO_H__ + +#include "mi_aio_datatype.h" +#include "mi_ao_datatype.h" + +#define AO_MAJOR_VERSION 2 +#define AO_SUB_VERSION 10 +#define MACRO_TO_STR(macro) #macro +#define AO_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_ao_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_ao_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_ao_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_AO_API_VERSION AO_VERSION_STR(AO_MAJOR_VERSION,AO_SUB_VERSION) + +#ifdef __cplusplus +extern "C" { +#endif + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= + + +//============================================================================= +// Data type definition +//============================================================================= + + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= +MI_S32 MI_AO_SetPubAttr(MI_AUDIO_DEV AoDevId, MI_AUDIO_Attr_t *pstAttr); +MI_S32 MI_AO_GetPubAttr(MI_AUDIO_DEV AoDevId, MI_AUDIO_Attr_t *pstAttr); +MI_S32 MI_AO_Enable(MI_AUDIO_DEV AoDevId); +MI_S32 MI_AO_Disable(MI_AUDIO_DEV AoDevId); +MI_S32 MI_AO_EnableChn(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_DisableChn(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_SendFrame(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AUDIO_Frame_t *pstData, MI_S32 s32MilliSec); +MI_S32 MI_AO_EnableReSmp(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AUDIO_SampleRate_e eInSampleRate); +MI_S32 MI_AO_DisableReSmp(MI_AUDIO_DEV AiDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_PauseChn(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_ResumeChn(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_ClearChnBuf(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_QueryChnStat(MI_AUDIO_DEV AoDevId , MI_AO_CHN AoChn, MI_AO_ChnState_t *pstStatus); +MI_S32 MI_AO_SetVolume(MI_AUDIO_DEV AoDevId, MI_S32 s32VolumeDb); +MI_S32 MI_AO_GetVolume(MI_AUDIO_DEV AoDevId, MI_S32 *ps32VolumeDb); +MI_S32 MI_AO_SetMute(MI_AUDIO_DEV AoDevId, MI_BOOL bEnable); +MI_S32 MI_AO_GetMute(MI_AUDIO_DEV AoDevId, MI_BOOL *pbEnable); +MI_S32 MI_AO_ClrPubAttr(MI_AUDIO_DEV AoDevId); +MI_S32 MI_AO_SetVqeAttr(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_VqeConfig_t *pstVqeConfig); +MI_S32 MI_AO_GetVqeAttr(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_VqeConfig_t *pstVqeConfig); +MI_S32 MI_AO_EnableVqe(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_DisableVqe(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_SetAdecAttr(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_AdecConfig_t *pstAdecConfig); +MI_S32 MI_AO_GetAdecAttr(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_AdecConfig_t *pstAdecConfig); +MI_S32 MI_AO_EnableAdec(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_DisableAdec(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn); +MI_S32 MI_AO_SetChnParam(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_ChnParam_t *pstChnParam); +MI_S32 MI_AO_GetChnParam(MI_AUDIO_DEV AoDevId, MI_AO_CHN AoChn, MI_AO_ChnParam_t *pstChnParam); +MI_S32 MI_AO_SetSrcGain(MI_AUDIO_DEV AoDevId, MI_S32 s32VolumeDb); +#ifdef __cplusplus +} +#endif + +#endif///__MI_AO_H__ diff --git a/src/video/mmiyoo/mi_ao_datatype.h b/src/video/mmiyoo/mi_ao_datatype.h new file mode 100755 index 0000000000000..54199e2d9f28b --- /dev/null +++ b/src/video/mmiyoo/mi_ao_datatype.h @@ -0,0 +1,140 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef __MI_AO_DATATYPE_H__ +#define __MI_AO_DATATYPE_H__ + +#include "mi_common_datatype.h" + +#ifdef __cplusplus +extern "C" { +#endif + +//============================================================================= +// Include files +//============================================================================= + + +//============================================================================= +// Extern definition +//============================================================================= + +//============================================================================= +// Macro definition +//============================================================================= +#define MI_AO_DEV_NUM_MAX 4 +#define MI_AO_CHAN_NUM_MAX 1 + +#define MI_AO_ERR_INVALID_DEVID (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_DEVID)) +#define MI_AO_ERR_ILLEGAL_PARAM (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_ILLEGAL_PARAM)) +#define MI_AO_ERR_NOT_ENABLED (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_ENABLE)) +#define MI_AO_ERR_NULL_PTR (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NULL_PTR)) +#define MI_AO_ERR_INVALID_CHNID (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_CHNID)) +#define MI_AO_ERR_NOT_CONFIG (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_CONFIG)) +#define MI_AO_ERR_NOT_SUPPORT (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_SUPPORT)) +#define MI_AO_ERR_NOT_PERM (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_PERM)) +#define MI_AO_ERR_NOMEM (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOMEM)) +#define MI_AO_ERR_NOBUF (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOBUF)) +#define MI_AO_ERR_BUF_EMPTY (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUF_EMPTY)) +#define MI_AO_ERR_BUF_FULL (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUF_FULL)) +#define MI_AO_ERR_SYS_NOTREADY (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_SYS_NOTREADY)) +#define MI_AO_ERR_BUSY (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUSY)) +#define MI_AO_ERR_VQE_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_AO_VQE_ERR)) +#define MI_AO_ERR_ADEC_ERR (MI_DEF_ERR( E_MI_MODULE_ID_AO, E_MI_ERR_LEVEL_ERROR, E_MI_AO_ADEC_ERR)) +//============================================================================= +// Data type definition +//============================================================================= +typedef enum +{ + E_MI_AO_VQE_ERR = MI_AO_INITIAL_ERROR_CODE, /* VQE of AO error */ + E_MI_AO_ADEC_ERR, //ADEC of AO error +}MI_AO_ErrCode_e; + + +typedef struct MI_AO_ChnState_s +{ + MI_U32 u32ChnTotalNum; + MI_U32 u32ChnFreeNum; + MI_U32 u32ChnBusyNum; +} MI_AO_ChnState_t; + +typedef struct MI_AO_VqeConfig_s +{ + MI_BOOL bHpfOpen; + MI_BOOL bAnrOpen; + MI_BOOL bAgcOpen; + MI_BOOL bEqOpen; + MI_S32 s32WorkSampleRate; + MI_S32 s32FrameSample; + MI_AUDIO_HpfConfig_t stHpfCfg; + MI_AUDIO_AnrConfig_t stAnrCfg; + MI_AUDIO_AgcConfig_t stAgcCfg; + MI_AUDIO_EqConfig_t stEqCfg; +}MI_AO_VqeConfig_t; + +typedef enum{ + E_MI_AUDIO_ADEC_TYPE_G711A = 0, + E_MI_AUDIO_ADEC_TYPE_G711U, + E_MI_AUDIO_ADEC_TYPE_G726, + E_MI_AUDIO_ADEC_TYPE_INVALID, +}MI_AUDIO_AdecType_e; + + +typedef struct MI_AUDIO_AdecG711Config_s{ + MI_AUDIO_SampleRate_e eSamplerate; + MI_AUDIO_SoundMode_e eSoundmode; +}MI_AUDIO_AdecG711Config_t; + +typedef struct MI_AUDIO_AdecG726Config_s{ + MI_AUDIO_SampleRate_e eSamplerate; + MI_AUDIO_SoundMode_e eSoundmode; + MI_AUDIO_G726Mode_e eG726Mode; +}MI_AUDIO_AdecG726Config_t; + +typedef struct MI_AO_AdecConfig_s{ + MI_AUDIO_AdecType_e eAdecType; + union + { + MI_AUDIO_AdecG711Config_t stAdecG711Cfg; + MI_AUDIO_AdecG726Config_t stAdecG726Cfg; + }; +}MI_AO_AdecConfig_t; + +typedef struct MI_AO_ChnGainConfig_s +{ + MI_BOOL bEnableGainSet; + MI_S16 s16Gain; +}MI_AO_ChnGainConfig_t; + +typedef struct MI_AO_ChnParam_s +{ + MI_AO_ChnGainConfig_t stChnGain; + MI_U32 u32Reserved; +} MI_AO_ChnParam_t; + + +//============================================================================= +// Variable definition +//============================================================================= + + +//============================================================================= +// Global function definition +//============================================================================= + + +#ifdef __cplusplus +} +#endif + +#endif //__MI_AO_DATATYPE_H__ diff --git a/src/video/mmiyoo/mi_common.h b/src/video/mmiyoo/mi_common.h new file mode 100755 index 0000000000000..05662267647b9 --- /dev/null +++ b/src/video/mmiyoo/mi_common.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_COMMON_H_ +#define _MI_COMMON_H_ + +#include "mi_common_datatype.h" + +#define COMMON_MAJOR_VERSION 2 +#define COMMON_SUB_VERSION 3 +#define MACRO_TO_STR(macro) #macro +#define COMMON_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_common_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_common_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_common_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_COMMON_API_VERSION COMMON_VERSION_STR(COMMON_MAJOR_VERSION,COMMON_SUB_VERSION) + +#endif///_MI_COMMON_H_ diff --git a/src/video/mmiyoo/mi_common_datatype.h b/src/video/mmiyoo/mi_common_datatype.h new file mode 100755 index 0000000000000..0b2330de1d17d --- /dev/null +++ b/src/video/mmiyoo/mi_common_datatype.h @@ -0,0 +1,265 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_COMMON_DATATYPE_H_ +#define _MI_COMMON_DATATYPE_H_ + +//------------------------------------------------------------------------------------------------- +// System Data Type +//------------------------------------------------------------------------------------------------- +/// data type unsigned char, data length 1 byte +typedef unsigned char MI_U8; // 1 byte +/// data type unsigned short, data length 2 byte +typedef unsigned short MI_U16; // 2 bytes +/// data type unsigned int, data length 4 byte +typedef unsigned int MI_U32; // 4 bytes +/// data type unsigned int, data length 8 byte +typedef unsigned long long MI_U64; // 8 bytes +/// data type signed char, data length 1 byte +typedef signed char MI_S8; // 1 byte +/// data type signed short, data length 2 byte +typedef signed short MI_S16; // 2 bytes +/// data type signed int, data length 4 byte +typedef signed int MI_S32; // 4 bytes +/// data type signed int, data length 8 byte +typedef signed long long MI_S64; // 8 bytes +/// data type float, data length 4 byte +typedef float MI_FLOAT; // 4 bytes +/// data type 64bit physical address +typedef unsigned long long MI_PHY; // 8 bytes +/// data type pointer content +typedef unsigned long MI_VIRT; // 4 bytes when 32bit toolchain, 8 bytes when 64bit toolchain. + +typedef unsigned char MI_BOOL; + +//------------------------------------------------------------------------------------------------- +// Moudle common type +//------------------------------------------------------------------------------------------------- +typedef MI_S32 MI_AI_CHN; +typedef MI_S32 MI_AO_CHN; +typedef MI_S32 MI_AUDIO_DEV; +typedef MI_S32 MI_VIF_DEV; +typedef MI_S32 MI_DISP_DEV; +typedef MI_S32 MI_DISP_LAYER; +typedef MI_S32 MI_DISP_CHN; +typedef MI_S32 MI_VENC_CHN; +typedef MI_S32 MI_VDEC_CHN; +typedef MI_S32 MI_IVE_HANDLE; +typedef MI_S32 MI_VPE_DEV; +typedef MI_S32 MI_DIVP_CHN; +typedef MI_U32 MI_RGN_HANDLE; +typedef MI_U32 MI_SED_CHN; +typedef MI_S32 MI_HANDLE; +//------------------------------------------------------------------------------------------------- +// Macros +//------------------------------------------------------------------------------------------------- +#define INIT_ST(st) do { \ + memset(&st, 0, sizeof(st));\ + st.u16SizeofStructure = sizeof(st);\ +}while(0) + + + +//------------------------------------------------------------------------------------------------- +// Defines +//------------------------------------------------------------------------------------------------- +#define MI_HANDLE_NULL (0) +#define MI_SUCCESS (0) +#define MI_BIT(_bit_) (1 << (_bit_)) +#define MI_ERR_ID (0x80000000L + 0x20000000L) +#define MI_IVE_INITIAL_ERROR_CODE (0x80) +#define MI_VDF_INITIAL_ERROR_CODE (0xA0) +#define MI_VENC_INITIAL_ERROR_CODE (0xC0) +#define MI_RGN_INITIAL_ERROR_CODE (0xE0) +#define MI_AI_INITIAL_ERROR_CODE (0x100) +#define MI_AO_INITIAL_ERROR_CODE (0x120) +#define MI_VIF_INITIAL_ERROR_CODE (0x140) +#define MI_VPE_INITIAL_ERROR_CODE (0x160) +#define MI_VDEC_INITIAL_ERROR_CODE (0x180) +#define MI_SYS_INITIAL_ERROR_CODE (0x1A0) +#define MI_FB_INITIAL_ERROR_CODE (0x1C0) +#define MI_HDMI_INITIAL_ERROR_CODE (0x1E0) +#define MI_DIVP_INITIAL_ERROR_CODE (0x200) +#define MI_GFX_INITIAL_ERROR_CODE (0x220) +#define MI_VDISP_INITIAL_ERROR_CODE (0x240) +#define MI_DISP_INITIAL_ERROR_CODE (0x260) +#define MI_WARP_INITIAL_ERROR_CODE (0x280) +#define MI_CV_INITIAL_ERROR_CODE (0x2A0) +#define MI_CEVA_INITIAL_ERROR_CODE (0x2C0) +#define MI_UAC_INITIAL_ERROR_CODE (0x2E0) +#define MI_LDC_INITIAL_ERROR_CODE (0x300) + +#ifndef UNUSED +#define UNUSED(var) (void)((var) = (var)) +#endif + +/****************************************************************************** +|----------------------------------------------------------------| +| 1 | APP_ID | MOD_ID | ERR_LEVEL | ERR_ID | +|----------------------------------------------------------------| +|<--><--7bits----><----8bits---><--4bits---><------12bits------->| +******************************************************************************/ + +#define MI_DEF_ERR( module, level, errid) \ + ((MI_S32)( (MI_ERR_ID) | ((module) << 16 ) | ((level)<<12) | (errid) )) + + +#ifndef __KERNEL__ +/// data type null pointer +#ifdef NULL +#undef NULL +#endif +#define NULL 0 + + +#if !defined(__cplusplus) +#ifndef true +/// definition for true +#define true 1 +/// definition for false +#define false 0 +#endif +#endif + +#if !defined(TRUE) && !defined(FALSE) +/// definition for TRUE +#define TRUE 1 +/// definition for FALSE +#define FALSE 0 +#endif +#endif + +#define TO_STR_NATIVE(e) #e +#define TO_STR_PROXY(m, e) m(e) +#define MACRO_TO_STRING(e) TO_STR_PROXY(TO_STR_NATIVE, e) +#define COMPILE_DATE_TIME() __DATE__ __TIME__ + +///ASCII color code +#define ASCII_COLOR_RED "\033[1;31m" +#define ASCII_COLOR_WHITE "\033[1;37m" +#define ASCII_COLOR_YELLOW "\033[1;33m" +#define ASCII_COLOR_BLUE "\033[1;36m" +#define ASCII_COLOR_GREEN "\033[1;32m" +#define ASCII_COLOR_END "\033[0m" + +//------------------------------------------------------------------------------------------------- +// Structures +//------------------------------------------------------------------------------------------------- + + + +//------------------------------------------------------------------------------------------------- +// Enum +//------------------------------------------------------------------------------------------------- +typedef enum +{ + E_MI_MODULE_ID_IVE = 0, + E_MI_MODULE_ID_VDF = 1, + E_MI_MODULE_ID_VENC = 2, + E_MI_MODULE_ID_RGN = 3, + E_MI_MODULE_ID_AI = 4, + E_MI_MODULE_ID_AO = 5, + E_MI_MODULE_ID_VIF = 6, + E_MI_MODULE_ID_VPE = 7, + E_MI_MODULE_ID_VDEC = 8, + E_MI_MODULE_ID_SYS = 9, + E_MI_MODULE_ID_FB = 10, + E_MI_MODULE_ID_HDMI = 11, + E_MI_MODULE_ID_DIVP = 12, + E_MI_MODULE_ID_GFX = 13, + E_MI_MODULE_ID_VDISP = 14, + E_MI_MODULE_ID_DISP = 15, + E_MI_MODULE_ID_OS = 16, + E_MI_MODULE_ID_IAE = 17, + E_MI_MODULE_ID_MD = 18, + E_MI_MODULE_ID_OD = 19, + E_MI_MODULE_ID_SHADOW = 20, + E_MI_MODULE_ID_WARP = 21, + E_MI_MODULE_ID_UAC = 22, + E_MI_MODULE_ID_LDC = 23, + E_MI_MODULE_ID_SD = 24, + E_MI_MODULE_ID_PANEL = 25, + E_MI_MODULE_ID_CIPHER = 26, + E_MI_MODULE_ID_SNR = 27, + E_MI_MODULE_ID_WLAN =28, + E_MI_MODULE_ID_IPU = 29, + E_MI_MODULE_ID_MIPITX = 30, + //E_MI_MODULE_ID_SED = 29, + E_MI_MODULE_ID_MAX, +} MI_ModuleId_e; + +typedef enum +{ + E_MI_ERR_LEVEL_INFO, /* informational */ + E_MI_ERR_LEVEL_WARNING, /* warning conditions */ + E_MI_ERR_LEVEL_ERROR, /* error conditions */ + E_MI_ERR_LEVEL_BUTT +} MI_ErrLevel_e; + +typedef enum +{ + E_MI_ERR_INVALID_DEVID = 1, /* invlalid device ID */ + E_MI_ERR_INVALID_CHNID = 2, /* invlalid channel ID */ + E_MI_ERR_ILLEGAL_PARAM = 3, /* at lease one parameter is illagal + ** eg, an illegal enumeration value */ + E_MI_ERR_EXIST = 4, /* resource exists */ + E_MI_ERR_UNEXIST = 5,/* resource unexists */ + E_MI_ERR_NULL_PTR = 6, /* using a NULL point */ + E_MI_ERR_NOT_CONFIG = 7, /* try to enable or initialize system, device + ** or channel, before configing attribute */ + E_MI_ERR_NOT_SUPPORT = 8, /* operation or type is not supported by NOW */ + E_MI_ERR_NOT_PERM = 9, /* operation is not permitted + ** eg, try to change static attribute */ + E_MI_ERR_NOMEM = 12,/* failure caused by malloc memory */ + E_MI_ERR_NOBUF = 13,/* failure caused by malloc buffer */ + E_MI_ERR_BUF_EMPTY = 14,/* no data in buffer */ + E_MI_ERR_BUF_FULL = 15,/* no buffer for new data */ + E_MI_ERR_SYS_NOTREADY = 16,/* System is not ready,maybe not initialed or + ** loaded. Returning the error code when opening + ** a device file failed. */ + E_MI_ERR_BADADDR = 17,/* bad address, + ** eg. used for copy_from_user & copy_to_user */ + E_MI_ERR_BUSY = 18,/* resource is busy, + ** eg. destroy a venc chn without unregister it */ + E_MI_ERR_CHN_NOT_STARTED = 19,/* channel not start*/ + E_MI_ERR_CHN_NOT_STOPED = 20,/* channel not stop*/ + E_MI_ERR_NOT_INIT = 21,/* module not init before use it*/ + E_MI_ERR_INITED = 22,/* module already init*/ + E_MI_ERR_NOT_ENABLE = 23,/* device channel or port not enable*/ + E_MI_ERR_NOT_DISABLE = 24,/* device channel or port not disable*/ + E_MI_ERR_SYS_TIMEOUT = 25,/* sys timeout*/ + E_MI_ERR_DEV_NOT_STARTED = 26,/* device not started*/ + E_MI_ERR_DEV_NOT_STOPED = 27,/* device not stoped*/ + E_MI_ERR_CHN_NO_CONTENT = 28,/* there is no content in the channel.*/ + E_MI_ERR_NOVASPACE = 29,/* failure caused by va mmap */ + E_MI_ERR_NOITEM = 30,/* no item record in ringpool */ + E_MI_ERR_FAILED ,/* unexpected error */ + + E_MI_ERR_MAX = 127,/* maxium code, private error code of all modules + ** must be greater than it */ +}MI_ErrCode_e; + +typedef enum +{ + MI_DBG_NONE = 0, + MI_DBG_ERR, + MI_DBG_WRN, + MI_DBG_KMSG, + MI_DBG_API, + MI_DBG_INFO, + MI_DBG_DEBUG, + MI_DBG_TRACE, + MI_DBG_ALL +}MI_DBG_LEVEL_e; + +#endif///_MI_COMMON_DATATYPE_H_ diff --git a/src/video/mmiyoo/mi_disp.h b/src/video/mmiyoo/mi_disp.h new file mode 100755 index 0000000000000..d8e56521337fc --- /dev/null +++ b/src/video/mmiyoo/mi_disp.h @@ -0,0 +1,82 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_DISP_H_ +#define _MI_DISP_H_ + +#include "mi_disp_datatype.h" + +#define DISP_MAJOR_VERSION 2 +#define DISP_SUB_VERSION 5 +#define MACRO_TO_STR(macro) #macro +#define DISP_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_disp_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_disp_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_disp_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_DISP_API_VERSION DISP_VERSION_STR(DISP_MAJOR_VERSION,DISP_SUB_VERSION) + +#ifdef __cplusplus +extern "C" { +#endif + +MI_S32 MI_DISP_Enable(MI_DISP_DEV DispDev); +MI_S32 MI_DISP_Disable(MI_DISP_DEV DispDev); +MI_S32 MI_DISP_SetPubAttr(MI_DISP_DEV DispDev, const MI_DISP_PubAttr_t *pstPubAttr); +MI_S32 MI_DISP_GetPubAttr(MI_DISP_DEV DispDev, MI_DISP_PubAttr_t *pstPubAttr); +MI_S32 MI_DISP_DeviceAttach(MI_DISP_DEV DispSrcDev, MI_DISP_DEV DispDstDev); +MI_S32 MI_DISP_DeviceDetach(MI_DISP_DEV DispSrcDev, MI_DISP_DEV DispDstDev); +MI_S32 MI_DISP_EnableVideoLayer(MI_DISP_LAYER DispLayer); +MI_S32 MI_DISP_DisableVideoLayer(MI_DISP_LAYER DispLayer); +MI_S32 MI_DISP_SetVideoLayerAttr(MI_DISP_LAYER DispLayer, const MI_DISP_VideoLayerAttr_t *pstLayerAttr); +MI_S32 MI_DISP_GetVideoLayerAttr(MI_DISP_LAYER DispLayer, MI_DISP_VideoLayerAttr_t *pstLayerAttr); +MI_S32 MI_DISP_BindVideoLayer(MI_DISP_LAYER DispLayer, MI_DISP_DEV DispDev); +MI_S32 MI_DISP_UnBindVideoLayer(MI_DISP_LAYER DispLayer, MI_DISP_DEV DispDev); +MI_S32 MI_DISP_SetPlayToleration(MI_DISP_LAYER DispLayer, MI_U32 u32Toleration); +MI_S32 MI_DISP_GetPlayToleration(MI_DISP_LAYER DispLayer, MI_U32 *pu32Toleration); +MI_S32 MI_DISP_GetScreenFrame(MI_DISP_LAYER DispLayer, MI_DISP_VideoFrame_t *pstVFrame); +MI_S32 MI_DISP_ReleaseScreenFrame(MI_DISP_LAYER DispLayer, MI_DISP_VideoFrame_t *pstVFrame); +MI_S32 MI_DISP_SetVideoLayerAttrBegin(MI_DISP_LAYER DispLayer); +MI_S32 MI_DISP_SetVideoLayerAttrEnd(MI_DISP_LAYER DispLayer); +MI_S32 MI_DISP_SetInputPortAttr(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort, const MI_DISP_InputPortAttr_t *pstInputPortAttr); +MI_S32 MI_DISP_GetInputPortAttr(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort, MI_DISP_InputPortAttr_t *pstInputPortAttr); +MI_S32 MI_DISP_EnableInputPort (MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort); +MI_S32 MI_DISP_DisableInputPort(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort); +MI_S32 MI_DISP_SetInputPortDispPos(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort, const MI_DISP_Position_t *pstDispPos); +MI_S32 MI_DISP_GetInputPortDispPos(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort, MI_DISP_Position_t *pstDispPos); +MI_S32 MI_DISP_PauseInputPort (MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort); +MI_S32 MI_DISP_ResumeInputPort (MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort); +MI_S32 MI_DISP_StepInputPort(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort); +MI_S32 MI_DISP_ShowInputPort(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort); +MI_S32 MI_DISP_HideInputPort(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort); +MI_S32 MI_DISP_SetInputPortSyncMode (MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort, MI_DISP_SyncMode_e eMode); +MI_S32 MI_DISP_QueryInputPortStat(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort, MI_DISP_QueryChannelStatus_t *pstStatus); +MI_S32 MI_DISP_SetZoomInWindow(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort, MI_DISP_VidWinRect_t* pstZoomRect); +MI_S32 MI_DISP_GetVgaParam(MI_DISP_DEV DispDev, MI_DISP_VgaParam_t *pstVgaParam); +MI_S32 MI_DISP_SetVgaParam(MI_DISP_DEV DispDev, MI_DISP_VgaParam_t *pstVgaParam); +MI_S32 MI_DISP_GetHdmiParam(MI_DISP_DEV DispDev, MI_DISP_HdmiParam_t *pstHdmiParam); +MI_S32 MI_DISP_SetHdmiParam(MI_DISP_DEV DispDev, MI_DISP_HdmiParam_t *pstHdmiParam); +MI_S32 MI_DISP_GetLcdParam(MI_DISP_DEV DispDev, MI_DISP_LcdParam_t *pstLcdParam); +MI_S32 MI_DISP_SetLcdParam(MI_DISP_DEV DispDev, MI_DISP_LcdParam_t *pstLcdParam); +MI_S32 MI_DISP_GetCvbsParam(MI_DISP_DEV DispDev, MI_DISP_CvbsParam_t *pstCvbsParam); +MI_S32 MI_DISP_SetCvbsParam(MI_DISP_DEV DispDev, MI_DISP_CvbsParam_t *pstCvbsParam); +MI_S32 MI_DISP_DeviceSetColorTempeture(MI_DISP_DEV DispDev, MI_DISP_ColorTemperature_t *pstColorTempInfo); +MI_S32 MI_DISP_DeviceGetColorTempeture(MI_DISP_DEV DispDev, MI_DISP_ColorTemperature_t *pstColorTempInfo); +MI_S32 MI_DISP_DeviceSetGammaParam(MI_DISP_DEV DispDev, MI_DISP_GammaParam_t * pstGammaParam); +MI_S32 MI_DISP_ClearInputPortBuffer(MI_DISP_LAYER DispLayer, MI_DISP_INPUTPORT LayerInputPort, MI_BOOL bClrAll); +MI_S32 MI_DISP_SetVideoLayerRotateMode(MI_DISP_LAYER DispLayer, MI_DISP_RotateConfig_t *pstRotateConfig); + +#ifdef __cplusplus +} +#endif + +#endif///_MI_DISP_H_ diff --git a/src/video/mmiyoo/mi_disp_datatype.h b/src/video/mmiyoo/mi_disp_datatype.h new file mode 100755 index 0000000000000..48c0b1c327b43 --- /dev/null +++ b/src/video/mmiyoo/mi_disp_datatype.h @@ -0,0 +1,326 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_DISP_DATATYPE_H_ +#define _MI_DISP_DATATYPE_H_ +#include "mi_sys_datatype.h" + +#define MI_DISP_SUCCESS (0) +#define MI_DISP_FAIL (1) +#define MI_ERR_DISP_INVALID_DEVID (0xA00F8001) //The device ID does not fall within the value range. +#define MI_ERR_DISP_INVALID_CHNID (0xA00F8002) //The channel ID does not fall within the value range. +#define MI_ERR_DISP_ILLEGAL_PARAM (0xA00F8003) //The parameter value does not fall within the value range. +#define MI_ERR_DISP_NULL_PTR (0xA00F8006) //The pointer is null. +#define MI_ERR_DISP_NOT_SUPPORT (0xA00F8008) //The operation is not supported. +#define MI_ERR_DISP_NOT_PERMIT (0xA00F8009) //The operation is forbidden. +#define MI_ERR_DISP_NO_MEM (0xA00F800C) //The memory is insufficient. +#define MI_ERR_DISP_SYS_NOTREADY (0xA00F8010) //The system is not initialized. +#define MI_ERR_DISP_BUSY (0xA00F8012) //The resources are unavailable. +#define MI_ERR_DISP_DEV_NOT_CONFIG (0xA00F8040) //The MI_DISP device is not configured. +#define MI_ERR_DISP_DEV_NOT_ENABLE (0xA00F8041) //The MI_DISP device is not enabled. +#define MI_ERR_DISP_DEV_HAS_ENABLED (0xA00F8042) //The MI_DISP device has been enabled. +#define MI_ERR_DISP_DEV_HAS_BINDED (0xA00F8043) //The device has been bound. +#define MI_ERR_DISP_DEV_NOT_BINDED (0xA00F8044) //The device is not bound. +#define MI_ERR_DISP_VIDEO_NOT_ENABLE (0xA00F8045) //The video layer is not enabled. +#define MI_ERR_DISP_VIDEO_NOT_DISABLE (0xA00F8046) //The video layer is not disabled. +#define MI_ERR_DISP_VIDEO_NOT_CONFIG (0xA00F8047) //The video layer is not configured. +#define MI_ERR_DISP_CHN_NOT_DISABLE (0xA00F8048) //The MI_DISP input port is not disabled. +#define MI_ERR_DISP_CHN_NOT_ENABLE (0xA00F8049) //No MI_DISP input port is enabled. +#define MI_ERR_DISP_CHN_NOT_CONFIG (0xA00F804A) //The MI_DISP input port is not configured. +#define MI_ERR_DISP_CHN_NOT_ALLOC (0xA00F804B) //No MI_DISP input port is allocated. +#define MI_ERR_DISP_INVALID_PATTERN (0xA00F804C) //The pattern is invalid. +#define MI_ERR_DISP_INVALID_POSITION (0xA00F804D) //The cascade position is invalid. +#define MI_ERR_DISP_WAIT_TIMEOUT (0xA00F804E) //Waiting times out. +#define MI_ERR_DISP_INVALID_VFRAME (0xA00F804F) //The video frame is invalid. +#define MI_ERR_DISP_INVALID_RECT_PARA (0xA00F8050) //The rectangle parameter is invalid. +#define MI_ERR_DISP_GFX_NOT_DISABLE (0xA00F8065) //The graphics layer is not disabled. +#define MI_ERR_DISP_GFX_NOT_BIND (0xA00F8066) //The graphics layer is not bound. +#define MI_ERR_DISP_GFX_NOT_UNBIND (0xA00F8067) //The graphics layer is not unbound. +#define MI_ERR_DISP_GFX_INVALID_ID (0xA00F8068) //The graphics layer ID does not fall within the value range. +#define MI_ERR_DISP_CHN_AREA_OVERLAP (0xA00F806b) //The MI_DISP input port areas overlap. +#define MI_ERR_DISP_INVALID_LAYERID (0xA00F806d) //The video layer ID does not fall within the value range. +#define MI_ERR_DISP_VIDEO_HAS_BINDED (0xA00F806e) //The video layer has been bound. +#define MI_ERR_DISP_VIDEO_NOT_BINDED (0xA00F806f) //The video layer is not bound + +#define MI_DISP_DEV_MAX 1 +#define MI_DISP_LAYER_MAX 2 +#define MI_DISP_INPUTPORT_MAX 16 + +//typedef MI_U32 MI_DISP_DEV; +//typedef MI_U32 MI_DISP_LAYER; +typedef MI_U32 MI_DISP_INPUTPORT; + +typedef enum +{ + E_MI_DISP_INTF_CVBS = 0, + E_MI_DISP_INTF_YPBPR, + E_MI_DISP_INTF_VGA, + E_MI_DISP_INTF_BT656, + E_MI_DISP_INTF_BT1120, + E_MI_DISP_INTF_HDMI, + E_MI_DISP_INTF_LCD, + E_MI_DISP_INTF_BT656_H, + E_MI_DISP_INTF_BT656_L, + E_MI_DISP_INTF_MAX, +}MI_DISP_Interface_e; + +typedef enum +{ + E_MI_DISP_OUTPUT_PAL = 0, + E_MI_DISP_OUTPUT_NTSC, + E_MI_DISP_OUTPUT_960H_PAL, /* ITU-R BT.1302 960 x 576 at 50 Hz (interlaced)*/ + E_MI_DISP_OUTPUT_960H_NTSC, /* ITU-R BT.1302 960 x 480 at 60 Hz (interlaced)*/ + + E_MI_DISP_OUTPUT_480i60, + E_MI_DISP_OUTPUT_576i50, + E_MI_DISP_OUTPUT_480P60, + E_MI_DISP_OUTPUT_576P50, + E_MI_DISP_OUTPUT_720P50, + E_MI_DISP_OUTPUT_720P60, + E_MI_DISP_OUTPUT_1080P24, + E_MI_DISP_OUTPUT_1080P25, + E_MI_DISP_OUTPUT_1080P30, + E_MI_DISP_OUTPUT_1080I50, + E_MI_DISP_OUTPUT_1080I60, + E_MI_DISP_OUTPUT_1080P50, + E_MI_DISP_OUTPUT_1080P60, + + E_MI_DISP_OUTPUT_640x480_60, /* VESA 640 x 480 at 60 Hz (non-interlaced) CVT */ + E_MI_DISP_OUTPUT_800x600_60, /* VESA 800 x 600 at 60 Hz (non-interlaced) */ + E_MI_DISP_OUTPUT_1024x768_60, /* VESA 1024 x 768 at 60 Hz (non-interlaced) */ + E_MI_DISP_OUTPUT_1280x1024_60, /* VESA 1280 x 1024 at 60 Hz (non-interlaced) */ + E_MI_DISP_OUTPUT_1366x768_60, /* VESA 1366 x 768 at 60 Hz (non-interlaced) */ + E_MI_DISP_OUTPUT_1440x900_60, /* VESA 1440 x 900 at 60 Hz (non-interlaced) CVT Compliant */ + E_MI_DISP_OUTPUT_1280x800_60, /* 1280*800@60Hz VGA@60Hz*/ + E_MI_DISP_OUTPUT_1680x1050_60, /* VESA 1680 x 1050 at 60 Hz (non-interlaced) */ + E_MI_DISP_OUTPUT_1920x2160_30, /* 1920x2160_30 */ + E_MI_DISP_OUTPUT_1600x1200_60, /* VESA 1600 x 1200 at 60 Hz (non-interlaced) */ + E_MI_DISP_OUTPUT_1920x1200_60, /* VESA 1920 x 1600 at 60 Hz (non-interlaced) CVT (Reduced Blanking)*/ + + E_MI_DISP_OUTPUT_2560x1440_30, /* 2560x1440_30 */ + E_MI_DISP_OUTPUT_2560x1600_60, /* 2560x1600_60 */ + E_MI_DISP_OUTPUT_3840x2160_30, /* 3840x2160_30 */ + E_MI_DISP_OUTPUT_3840x2160_60, /* 3840x2160_60 */ + E_MI_DISP_OUTPUT_USER, + E_MI_DISP_OUTPUT_MAX, +} MI_DISP_OutputTiming_e; + +typedef enum +{ + E_MI_DISP_ROTATE_NONE, + E_MI_DISP_ROTATE_90, + E_MI_DISP_ROTATE_180, + E_MI_DISP_ROTATE_270, + E_MI_DISP_ROTATE_NUM, +}MI_DISP_RotateMode_e; + +typedef enum +{ + E_MI_DISP_CSC_MATRIX_BYPASS = 0, /* do not change color space */ + + E_MI_DISP_CSC_MATRIX_BT601_TO_BT709, /* change color space from BT.601 to BT.709 */ + E_MI_DISP_CSC_MATRIX_BT709_TO_BT601, /* change color space from BT.709 to BT.601 */ + + E_MI_DISP_CSC_MATRIX_BT601_TO_RGB_PC, /* change color space from BT.601 to RGB */ + E_MI_DISP_CSC_MATRIX_BT709_TO_RGB_PC, /* change color space from BT.709 to RGB */ + + E_MI_DISP_CSC_MATRIX_RGB_TO_BT601_PC, /* change color space from RGB to BT.601 */ + E_MI_DISP_CSC_MATRIX_RGB_TO_BT709_PC, /* change color space from RGB to BT.709 */ + + E_MI_DISP_CSC_MATRIX_NUM +} MI_DISP_CscMattrix_e; + +typedef enum +{ + E_MI_DISP_SYNC_MODE_INVALID = 0, + E_MI_DISP_SYNC_MODE_CHECK_PTS, + E_MI_DISP_SYNC_MODE_FREE_RUN, + E_MI_DISP_SYNC_MODE_NUM, +} MI_DISP_SyncMode_e; + +typedef enum +{ + E_MI_LAYER_INPUTPORT_STATUS_INVALID = 0, + E_MI_LAYER_INPUTPORT_STATUS_PAUSE, + E_MI_LAYER_INPUTPORT_STATUS_RESUME, + E_MI_LAYER_INPUTPORT_STATUS_STEP, + E_MI_LAYER_INPUTPORT_STATUS_REFRESH, + E_MI_LAYER_INPUTPORT_STATUS_SHOW, + E_MI_LAYER_INPUTPORT_STATUS_HIDE, + E_MI_LAYER_INPUTPORT_STATUS_NUM, +} MI_DISP_InputPortStatus_e; + +typedef struct MI_DISP_SyncInfo_s +{ + MI_BOOL bSynm; /* sync mode(0:timing,as BT.656; 1:signal,as LCD) */ + MI_BOOL bIop; /* interlaced or progressive display(0:i; 1:p) */ + MI_U8 u8Intfb; /* interlace bit width while output */ + + MI_U16 u16Vact ; /* vertical active area */ + MI_U16 u16Vbb; /* vertical back blank porch */ + MI_U16 u16Vfb; /* vertical front blank porch */ + + MI_U16 u16Hact; /* herizontal active area */ + MI_U16 u16Hbb; /* herizontal back blank porch */ + MI_U16 u16Hfb; /* herizontal front blank porch */ + MI_U16 u16Hmid; /* bottom herizontal active area */ + + MI_U16 u16Bvact; /* bottom vertical active area */ + MI_U16 u16Bvbb; /* bottom vertical back blank porch */ + MI_U16 u16Bvfb; /* bottom vertical front blank porch */ + + MI_U16 u16Hpw; /* horizontal pulse width */ + MI_U16 u16Vpw; /* vertical pulse width */ + + MI_BOOL bIdv; /* inverse data valid of output */ + MI_BOOL bIhs; /* inverse horizontal synch signal */ + MI_BOOL bIvs; /* inverse vertical synch signal */ + MI_U32 u32FrameRate; +} MI_DISP_SyncInfo_t; + + +typedef struct MI_DISP_PubAttr_s +{ + MI_U32 u32BgColor; /* Background color of a device, in RGB format. */ + MI_DISP_Interface_e eIntfType; /* Type of a VO interface */ + MI_DISP_OutputTiming_e eIntfSync; /* Type of a VO interface timing */ + MI_DISP_SyncInfo_t stSyncInfo; /* Information about VO interface timings */ +} MI_DISP_PubAttr_t; + +typedef struct MI_DISP_CompressAttr_s +{ + MI_BOOL bSupportCompress; /* Whether to support compress */ +} MI_DISP_CompressAttr_t; + +typedef struct MI_DISP_VidWin_Rect_s +{ + MI_U16 u16X; + MI_U16 u16Y; + MI_U16 u16Width; + MI_U16 u16Height; +} MI_DISP_VidWinRect_t; + +typedef struct MI_DISP_VideoLayerSize_s +{ + MI_U32 u16Width; + MI_U32 u16Height; +} MI_DISP_VideoLayerSize_t; + +typedef struct MI_DISP_VideoLayerAttr_s +{ + MI_DISP_VidWinRect_t stVidLayerDispWin; /* Display resolution */ +// TODO: dev + MI_DISP_VideoLayerSize_t stVidLayerSize; /* Canvas size of the video layer */ + // TODO: Tommy delete pixel format & doc + MI_SYS_PixelFormat_e ePixFormat; /* Pixel format of the video layer */ +} MI_DISP_VideoLayerAttr_t; + +typedef struct MI_DISP_Csc_s +{ + MI_DISP_CscMattrix_e eCscMatrix; + MI_U32 u32Luma; /* luminance: 0 ~ 100 default: 50 */ + MI_U32 u32Contrast; /* contrast : 0 ~ 100 default: 50 */ + MI_U32 u32Hue; /* hue : 0 ~ 100 default: 50 */ + MI_U32 u32Saturation; /* saturation: 0 ~ 100 default: 40 */ +} MI_DISP_Csc_t; + +typedef struct MI_DISP_VideoFrame_s +{ + MI_U32 u32Width; + MI_U32 u32Height; + MI_SYS_PixelFormat_e ePixelFormat; + MI_PHY aphyAddr; + void * pavirAddr; + MI_U64 u64pts; + MI_U32 u32PrivateData; + MI_U32 u32Size; + MI_U32 u32Stride; +} MI_DISP_VideoFrame_t; +/* General Operation of InputPort */ +typedef struct MI_DISP_InputPortAttr_s +{ + MI_DISP_VidWinRect_t stDispWin; /* rect of video out chn */ + MI_U16 u16SrcWidth; + MI_U16 u16SrcHeight; +} MI_DISP_InputPortAttr_t; +typedef struct MI_DISP_Position_s +{ + MI_U16 u16X; + MI_U16 u16Y; +} MI_DISP_Position_t; + +typedef struct MI_DISP_QueryChannelStatus_s +{ + MI_BOOL bEnable; + MI_DISP_InputPortStatus_e eStatus; +} MI_DISP_QueryChannelStatus_t; + +typedef struct MI_DISP_VgaParam_s +{ + MI_DISP_Csc_t stCsc; /* color space */ + MI_U32 u32Gain; /* current gain of VGA signals. [0, 64). default:0x30 */ + MI_U32 u32Sharpness; +} MI_DISP_VgaParam_t; + +typedef struct MI_DISP_HdmiParam_s +{ + MI_DISP_Csc_t stCsc; /* color space */ + MI_U32 u32Gain; /* current gain of HDMI signals. [0, 64). default:0x30 */ + MI_U32 u32Sharpness; +} MI_DISP_HdmiParam_t; + +typedef struct MI_DISP_LcdParam_s +{ + MI_DISP_Csc_t stCsc; /* color space */ + MI_U32 u32Sharpness; +} MI_DISP_LcdParam_t; + +typedef struct MI_DISP_CvbsParam_s +{ + MI_BOOL bEnable; +} MI_DISP_CvbsParam_t; + + +typedef struct MI_DISP_RotateConfig_s +{ + MI_DISP_RotateMode_e eRotateMode; +}MI_DISP_RotateConfig_t; + +typedef struct +{ + MI_U16 u16RedOffset; + MI_U16 u16GreenOffset; + MI_U16 u16BlueOffset; + + MI_U16 u16RedColor; // 00~FF, 0x80 is no change + MI_U16 u16GreenColor;// 00~FF, 0x80 is no change + MI_U16 u16BlueColor; // 00~FF, 0x80 is no change +}MI_DISP_ColorTemperature_t; + +typedef struct +{ + MI_BOOL bEn; + MI_U16 u16EntryNum; + MI_U8 *pu8ColorR; + MI_U8 *pu8ColorG; + MI_U8 *pu8ColorB; +}MI_DISP_GammaParam_t; + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif + +#endif///_MI_DISP_DATATYPE_H_ diff --git a/src/video/mmiyoo/mi_divp.h b/src/video/mmiyoo/mi_divp.h new file mode 100755 index 0000000000000..f6c85fc6b7e01 --- /dev/null +++ b/src/video/mmiyoo/mi_divp.h @@ -0,0 +1,135 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_DIVP_H_ +#define _MI_DIVP_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "mi_divp_datatype.h" + +#define DIVP_MAJOR_VERSION 2 +#define DIVP_SUB_VERSION 4 +#define MACRO_TO_STR(macro) #macro +#define DIVP_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_divp_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_divp_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_divp_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_DIVP_API_VERSION DIVP_VERSION_STR(DIVP_MAJOR_VERSION,DIVP_SUB_VERSION) + +//------------------------------------------------------------------------------ +/// @brief create a DIVP channel. +/// @param[out] pDivpChn: DIVP channel ID. +/// @param[in] pstAttr: Attribute of DIVP channel. +/// @return MI_SUCCESS: succeed in creating a channel. +/// MI_DIVP_ERR_INVALID_PARAM: invalid input patamter. +/// MI_DIVP_ERR_NULL_PTR: NULL poiter error. +/// MI_DIVP_ERR_FAILED: Fail to create a channel. +/// MI_DIVP_ERR_NO_RESOUCE: there is no resource. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_CreateChn (MI_DIVP_CHN DivpChn, MI_DIVP_ChnAttr_t* pstAttr); + +//------------------------------------------------------------------------------ +/// @brief deatroy a DIVP channel. +/// @param[in] DivpChn: DIVP channel ID. +/// @return MI_SUCCESS: succeed in deatroying a DIVP channel. +/// MI_DIVP_ERR_INVALID_CHNID: Invalid channel ID. +/// MI_DIVP_ERR_FAILED: Fail to deatroy a DIVP channel. +/// MI_DIVP_ERR_CHN_BUSY:channel is busy. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_DestroyChn(MI_DIVP_CHN DivpChn); + +//------------------------------------------------------------------------------ +/// @brief set attribute of DIVP channel. +/// @param[in] DivpChn: DIVP channel ID. +/// @param[in] pstAttr: Attribute of DIVP channel. +/// @return MI_SUCCESS: succeed in setting attribute of DIVP channel. +/// MI_DIVP_ERR_INVALID_CHNID: Invalid channel ID. +/// MI_DIVP_ERR_INVALID_PARAM: Invalid input patamter. +/// MI_DIVP_ERR_NULL_PTR: NULL poiter error. +/// MI_DIVP_ERR_CHN_NOT_SUPPORT: not support. +/// MI_DIVP_ERR_FAILED: Fail to set attribute of DIVP channel. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_SetChnAttr(MI_DIVP_CHN DivpChn, MI_DIVP_ChnAttr_t* pstAttr); + +//------------------------------------------------------------------------------ +/// @brief get attribute of DIVP channel. +/// @param[in] DivpChn: DIVP channel ID. +/// @param[in] pstAttr: Attribute of DIVP channel. +/// @return MI_SUCCESS: succeed in getting attribute of DIVP channel. +/// MI_DIVP_ERR_INVALID_CHNID: Invalid channel ID. +/// MI_DIVP_ERR_NULL_PTR: NULL poiter error. +/// MI_DIVP_ERR_FAILED: Fail to get attribute of DIVP channel. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_GetChnAttr(MI_DIVP_CHN DivpChn, MI_DIVP_ChnAttr_t* pstAttr); + +//------------------------------------------------------------------------------ +/// @brief start a DIVP channel. +/// @param[in] DivpChn: DIVP channel ID. +/// @return MI_SUCCESS: succeed in starting a DIVP channel. +/// MI_DIVP_ERR_INVALID_CHNID: Invalid channel ID. +/// MI_DIVP_ERR_FAILED: Fail to start a DIVP channel. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_StartChn(MI_DIVP_CHN DivpChn); + +//------------------------------------------------------------------------------ +/// @brief stop a DIVP channel. +/// @param[in] DivpChn: DIVP channel ID. +/// @return MI_SUCCESS: succeed in stopping a DIVP channel. +/// MI_DIVP_ERR_INVALID_CHNID: Invalid channel ID. +/// MI_DIVP_ERR_FAILED: Fail to stop a DIVP channel. +/// MI_DIVP_ERR_CHN_BUSY:channel is busy. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_StopChn(MI_DIVP_CHN DivpChn); + +//------------------------------------------------------------------------------ +/// @brief set attribute of DIVP channel output port. +/// @param[in] DivpChn: DIVP channel ID. +/// @param[in] pstOutputPortAttr: DIVP channel output port attribute. +/// @return MI_SUCCESS: succeed in setting attribute of DIVP channel output port. +/// MI_DIVP_ERR_INVALID_CHNID: Invalid channel ID. +/// MI_DIVP_ERR_INVALID_PARAM: Invalid input patamter. +/// MI_DIVP_ERR_NULL_PTR: NULL poiter error. +/// MI_DIVP_ERR_FAILED: Fail to set attribute of DIVP channel output port. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_SetOutputPortAttr (MI_DIVP_CHN DivpChn, MI_DIVP_OutputPortAttr_t * pstOutputPortAttr); + +//------------------------------------------------------------------------------ +/// @brief get attribute of DIVP channel output port. +/// @param[in] DivpChn: DIVP channel ID. +/// @param[out] pstOutputPortAttr: DIVP channel output port attribute. +/// @return MI_SUCCESS: succeed in getting attribute of DIVP channel output port. +/// MI_DIVP_ERR_FAILED: Fail to get attribute of DIVP channel output port. +/// MI_DIVP_ERR_INVALID_CHNID: Invalid channel ID. +/// MI_DIVP_ERR_NULL_PTR: NULL poiter error. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_GetOutputPortAttr (MI_DIVP_CHN DivpChn, MI_DIVP_OutputPortAttr_t * pstOutputPortAttr); + +//------------------------------------------------------------------------------ +/// @brief refresh a DIVP channel. +/// @param[in] DivpChn: DIVP channel ID. +/// @return MI_SUCCESS: succeed in refreshing a DIVP channel. +/// MI_DIVP_ERR_INVALID_CHNID: Invalid channel ID. +/// MI_DIVP_ERR_FAILED: Fail to refresh a DIVP channel. +//------------------------------------------------------------------------------ +MI_S32 MI_DIVP_RefreshChn(MI_DIVP_CHN DivpChn); + +MI_S32 MI_DIVP_StretchBuf(MI_DIVP_DirectBuf_t *pstSrcBuf, MI_SYS_WindowRect_t *pstSrcCrop, MI_DIVP_DirectBuf_t *pstDstBuf); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/video/mmiyoo/mi_divp_datatype.h b/src/video/mmiyoo/mi_divp_datatype.h new file mode 100755 index 0000000000000..368445127db43 --- /dev/null +++ b/src/video/mmiyoo/mi_divp_datatype.h @@ -0,0 +1,80 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_DIVP_DATATYPE_H_ +#define _MI_DIVP_DATATYPE_H_ +#pragma pack(push) +#pragma pack(4) + +#define MI_DIVP_CHN_MAX_NUM (6) +#define MI_DIVP_ERR_INVALID_DEVID (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_DEVID)) +#define MI_DIVP_ERR_INVALID_CHNID (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_CHNID)) +#define MI_DIVP_ERR_INVALID_PARAM (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_ILLEGAL_PARAM)) +#define MI_DIVP_ERR_NULL_PTR (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NULL_PTR)) +#define MI_DIVP_ERR_FAILED (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_FAILED)) +#define MI_DIVP_ERR_CHN_NOT_STARTED (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_CHN_NOT_STARTED)) +#define MI_DIVP_ERR_CHN_NOT_STOPED (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_CHN_NOT_STOPED)) +#define MI_DIVP_ERR_CHN_NOT_SUPPORT (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_SUPPORT)) +#define MI_DIVP_ERR_NO_RESOUCE (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_UNEXIST)) +#define MI_DIVP_ERR_CHN_BUSY (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUSY)) +#define MI_DIVP_ERR_HAS_CREATED (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_EXIST)) +#define MI_DIVP_ERR_NO_CONTENT (MI_DEF_ERR( E_MI_MODULE_ID_DIVP, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_CHN_NO_CONTENT)) + +typedef enum +{ + E_MI_DIVP_DI_TYPE_OFF,//off + E_MI_DIVP_DI_TYPE_2D,///2.5D DI + E_MI_DIVP_DI_TYPE_3D,///3D DI + E_MI_DIVP_DI_TYPE_NUM, +} MI_DIVP_DiType_e; + +typedef enum +{ + E_MI_DIVP_TNR_LEVEL_OFF, + E_MI_DIVP_TNR_LEVEL_LOW, + E_MI_DIVP_TNR_LEVEL_MIDDLE, + E_MI_DIVP_TNR_LEVEL_HIGH, + E_MI_DIVP_TNR_LEVEL_NUM, +} MI_DIVP_TnrLevel_e; + +typedef struct MI_DIVP_OutputPortAttr_s +{ + MI_U32 u32Width;//output width + MI_U32 u32Height;//output height + MI_SYS_PixelFormat_e ePixelFormat;//output pixel format + MI_SYS_CompressMode_e eCompMode;//compress mode +}MI_DIVP_OutputPortAttr_t; + +typedef struct MI_DIVP_ChnAttr_s +{ + MI_U32 u32MaxWidth;//support max input width + MI_U32 u32MaxHeight;//support max input height + MI_DIVP_TnrLevel_e eTnrLevel;//TNR level + MI_DIVP_DiType_e eDiType;//DI type + MI_SYS_Rotate_e eRotateType;//rotate angle + MI_SYS_WindowRect_t stCropRect;//crop information + MI_BOOL bHorMirror;//horizontal mirror + MI_BOOL bVerMirror;//vertical mirror +}MI_DIVP_ChnAttr_t; + +typedef struct MI_DIVP_DirectBuf_s +{ + MI_SYS_PixelFormat_e ePixelFormat; //YUV420SP or ARGB888 only + MI_U32 u32Width; + MI_U32 u32Height; + MI_U32 u32Stride[3]; + MI_PHY phyAddr[3]; +}MI_DIVP_DirectBuf_t; + +#pragma pack(pop) +#endif diff --git a/src/video/mmiyoo/mi_gfx.h b/src/video/mmiyoo/mi_gfx.h new file mode 100755 index 0000000000000..5553cde99a4ea --- /dev/null +++ b/src/video/mmiyoo/mi_gfx.h @@ -0,0 +1,73 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_GFX_H_ +#define _MI_GFX_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include "mi_common.h" +#include "mi_gfx_datatype.h" + +#define GFX_MAJOR_VERSION 2 +#define GFX_SUB_VERSION 5 +#define MACRO_TO_STR(macro) #macro +#define GFX_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_gfx_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_gfx_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_gfx_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_GFX_API_VERSION GFX_VERSION_STR(GFX_MAJOR_VERSION,GFX_SUB_VERSION) + +/*------------------------------------------------------------------------------------------- + * Global Functions +-------------------------------------------------------------------------------------------*/ + +MI_S32 MI_GFX_Open(void); +MI_S32 MI_GFX_Close(void); +MI_S32 MI_GFX_WaitAllDone(MI_BOOL bWaitAllDone, MI_U16 u16TargetFence); + +//------------------------------------------------------------------------------------------------- +/// Fill Rect +/// @param pstDst \b IN: Target Surface info +/// @param pstDstRect \b IN: Target Rect info +/// @param u32ColorVal \b IN: Color to fill +/// For all RGB color, the color set as the ARGB8888 format.\n +/// Each color component need to shift to high bit.\n +/// Use ARGB1555 as the example, the source color key as the following:\n +/// ARGB1555 --> ARRRRRGGGGGBBBBB (every character represents one bit)\n +/// For I8 format, the index set to b component\n +/// @param pu16Fence \b OUT: wait fence +/// @return MI_SUCCESS - Success +/// @return OTHER - Failure +//------------------------------------------------------------------------------------------------ +MI_S32 MI_GFX_QuickFill(MI_GFX_Surface_t *pstDst, MI_GFX_Rect_t *pstDstRect, + MI_U32 u32ColorVal, MI_U16 *pu16Fence); +MI_S32 MI_GFX_GetAlphaThresholdValue(MI_U8 *pu8ThresholdValue); +MI_S32 MI_GFX_SetAlphaThresholdValue(MI_U8 u8ThresholdValue); +MI_S32 MI_GFX_BitBlit(MI_GFX_Surface_t *pstSrc, MI_GFX_Rect_t *pstSrcRect, + MI_GFX_Surface_t *pstDst, MI_GFX_Rect_t *pstDstRect, MI_GFX_Opt_t *pstOpt, MI_U16 *pu16Fence); +//------------------------------------------------------------------------------------------------- +/// Set Palette for Index Color format(I2/I4/I8) +/// @param eColorFmt \b IN: Index Color format(I2/I4/I8) +/// @param pstPalette \b IN: RGB color data array for corresponding Index Color +/// @return MI_SUCCESS - Success +/// @return OTHER - Failure,refer to error code +//------------------------------------------------------------------------------------------------ +MI_S32 MI_GFX_SetPalette(MI_GFX_ColorFmt_e eColorFmt, MI_GFX_Palette_t* pstPalette); + +#ifdef __cplusplus +} +#endif + +#endif //_MI_GFX_H_ diff --git a/src/video/mmiyoo/mi_gfx_datatype.h b/src/video/mmiyoo/mi_gfx_datatype.h new file mode 100755 index 0000000000000..f42d3e0be11b4 --- /dev/null +++ b/src/video/mmiyoo/mi_gfx_datatype.h @@ -0,0 +1,222 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ + +#ifndef _MI_GFX_DATATYPE_H_ +#define _MI_GFX_DATATYPE_H_ +#ifdef __cplusplus +extern "C" { +#endif +#include "mi_common.h" +#include "mi_gfx_datatype.h" + +typedef enum +{ + E_MI_GFX_FMT_I1 = 0, /* MS_ColorFormat */ + E_MI_GFX_FMT_I2, + E_MI_GFX_FMT_I4, + E_MI_GFX_FMT_I8, + E_MI_GFX_FMT_FABAFGBG2266, + E_MI_GFX_FMT_1ABFGBG12355, + E_MI_GFX_FMT_RGB565, + E_MI_GFX_FMT_ARGB1555, + E_MI_GFX_FMT_ARGB4444, + E_MI_GFX_FMT_ARGB1555_DST, + E_MI_GFX_FMT_YUV422, + E_MI_GFX_FMT_ARGB8888, + E_MI_GFX_FMT_RGBA5551, + E_MI_GFX_FMT_RGBA4444, + E_MI_GFX_FMT_ABGR8888, + E_MI_GFX_FMT_BGRA5551, + E_MI_GFX_FMT_ABGR1555, + E_MI_GFX_FMT_ABGR4444, + E_MI_GFX_FMT_BGRA4444, + E_MI_GFX_FMT_BGR565, + E_MI_GFX_FMT_RGBA8888, + E_MI_GFX_FMT_BGRA8888, + E_MI_GFX_FMT_MAX +} MI_GFX_ColorFmt_e; + +typedef enum +{ + E_MI_GFX_RGB_OP_EQUAL = 0, + E_MI_GFX_RGB_OP_NOT_EQUAL, + E_MI_GFX_ALPHA_OP_EQUAL, + E_MI_GFX_ALPHA_OP_NOT_EQUAL, + E_MI_GFX_ARGB_OP_EQUAL, + E_MI_GFX_ARGB_OP_NOT_EQUAL, + E_MI_GFX_CKEY_OP_MAX, +} MI_GFX_ColorKeyOp_e; + +typedef enum +{ + E_MI_GFX_DFB_BLD_ZERO = 0, + E_MI_GFX_DFB_BLD_ONE, + E_MI_GFX_DFB_BLD_SRCCOLOR, + E_MI_GFX_DFB_BLD_INVSRCCOLOR, + E_MI_GFX_DFB_BLD_SRCALPHA, + E_MI_GFX_DFB_BLD_INVSRCALPHA, + E_MI_GFX_DFB_BLD_DESTALPHA, + E_MI_GFX_DFB_BLD_INVDESTALPHA, + E_MI_GFX_DFB_BLD_DESTCOLOR, + E_MI_GFX_DFB_BLD_INVDESTCOLOR, + E_MI_GFX_DFB_BLD_SRCALPHASAT, + E_MI_GFX_DFB_BLD_MAX, +} MI_GFX_DfbBldOp_e; + +typedef enum +{ + E_MI_GFX_MIRROR_NONE = 0, + E_MI_GFX_MIRROR_HORIZONTAL, + E_MI_GFX_MIRROR_VERTICAL, + E_MI_GFX_MIRROR_BOTH, + E_MI_GFX_MIRROR_MAX +} MI_GFX_Mirror_e; + +typedef enum +{ + E_MI_GFX_ROTATE_0 = 0, + E_MI_GFX_ROTATE_90, + E_MI_GFX_ROTATE_180, + E_MI_GFX_ROTATE_270, + E_MI_GFX_ROTATE_MAX +} MI_GFX_Rotate_e; + +typedef enum +{ + E_MI_GFX_ERR_NOT_INIT = MI_GFX_INITIAL_ERROR_CODE, + E_MI_GFX_ERR_GFX_DRV_NOT_SUPPORT, + E_MI_GFX_ERR_GFX_DRV_FAIL_FORMAT, + E_MI_GFX_ERR_GFX_NON_ALIGN_ADDRESS, + E_MI_GFX_ERR_GFX_NON_ALIGN_PITCH, + E_MI_GFX_ERR_GFX_DRV_FAIL_OVERLAP, + E_MI_GFX_ERR_GFX_DRV_FAIL_STRETCH, + E_MI_GFX_ERR_GFX_DRV_FAIL_ITALIC, + E_MI_GFX_ERR_GFX_DRV_FAIL_LOCKED, + E_MI_GFX_ERR_GFX_DRV_FAIL_BLTADDR, + E_MI_GFX_ERR_MAX +} MI_GFX_ErrCode_e; + + +/* GFX Module ErrorCode */ +#define MI_ERR_GFX_INVALID_PARAM MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_ILLEGAL_PARAM) +#define MI_ERR_GFX_INVALID_DEVID MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_DEVID) +#define MI_ERR_GFX_DEV_BUSY MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_BUSY) + +#define MI_ERR_GFX_NOT_INIT MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_NOT_INIT) +#define MI_ERR_GFX_DRV_NOT_SUPPORT MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_DRV_NOT_SUPPORT) +#define MI_ERR_GFX_DRV_FAIL_FORMAT MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_DRV_FAIL_FORMAT) +#define MI_ERR_GFX_NON_ALIGN_ADDRESS MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_NON_ALIGN_ADDRESS) +#define MI_ERR_GFX_NON_ALIGN_PITCH MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_NON_ALIGN_PITCH) +#define MI_ERR_GFX_DRV_FAIL_OVERLAP MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_DRV_FAIL_OVERLAP) +#define MI_ERR_GFX_DRV_FAIL_STRETCH MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_DRV_FAIL_STRETCH) +#define MI_ERR_GFX_DRV_FAIL_ITALIC MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_DRV_FAIL_ITALIC) +#define MI_ERR_GFX_DRV_FAIL_LOCKED MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_DRV_FAIL_LOCKED) +#define MI_ERR_GFX_DRV_FAIL_BLTADDR MI_DEF_ERR(E_MI_MODULE_ID_GFX, E_MI_ERR_LEVEL_ERROR, E_MI_GFX_ERR_GFX_DRV_FAIL_BLTADDR) + +typedef struct MI_GFX_Rect_s +{ + MI_S32 s32Xpos; + MI_S32 s32Ypos; + MI_U32 u32Width; + MI_U32 u32Height; +} MI_GFX_Rect_t; + +//============================================================================= +// GFX palette information +//============================================================================= + +typedef union +{ + /// ARGB8888 byte order + struct + { + MI_U8 u8A; + MI_U8 u8R; + MI_U8 u8G; + MI_U8 u8B; + } RGB; + // u8Data[0] = u8A + // u8Data[1] = u8R + // u8Data[2] = u8G + // u8Data[3] = u8B + MI_U8 u8Data[4]; +} MI_GFX_PaletteEntry_t; + +typedef struct MI_GFX_Palette_s +{ + /// array subscripts are indentical to value of Index Color + MI_GFX_PaletteEntry_t aunPalette[256]; + /// Starting Index in palette to config + MI_U16 u16PalStart; + /// Ending Index in palette to config + MI_U16 u16PalEnd; +}MI_GFX_Palette_t; + +typedef struct MI_GFX_ColorKey_s +{ + MI_U32 u32ColorStart; + MI_U32 u32ColorEnd; +} MI_GFX_ColorKeyValue_t; + +typedef struct MI_GFX_ColorKeyInfo_s +{ + MI_BOOL bEnColorKey; + MI_GFX_ColorKeyOp_e eCKeyOp; + MI_GFX_ColorFmt_e eCKeyFmt; + MI_GFX_ColorKeyValue_t stCKeyVal; +} MI_GFX_ColorKeyInfo_t; + +typedef struct MI_GFX_Surface_s +{ + MI_PHY phyAddr; + MI_GFX_ColorFmt_e eColorFmt; + MI_U32 u32Width; + MI_U32 u32Height; + MI_U32 u32Stride; +} MI_GFX_Surface_t; + +typedef enum +{ + E_MI_GFX_DFB_BLEND_NOFX = 0x00000000, + E_MI_GFX_DFB_BLEND_COLORALPHA = 0x00000001, + E_MI_GFX_DFB_BLEND_ALPHACHANNEL = 0x00000002, + E_MI_GFX_DFB_BLEND_COLORIZE = 0x00000004, + E_MI_GFX_DFB_BLEND_SRC_PREMULTIPLY = 0x00000008, + E_MI_GFX_DFB_BLEND_SRC_PREMULTCOLOR = 0x00000010, + E_MI_GFX_DFB_BLEND_DST_PREMULTIPLY = 0x00000020, + E_MI_GFX_DFB_BLEND_XOR = 0x00000040, + E_MI_GFX_DFB_BLEND_DEMULTIPLY = 0x00000080, + E_MI_GFX_DFB_BLEND_SRC_COLORKEY = 0x00000100, + E_MI_GFX_DFB_BLEND_DST_COLORKEY = 0x00000200, + E_MI_GFX_DFB_BLEND_MAX = 0x3FF +} MI_Gfx_DfbBlendFlags_e; + +typedef struct MI_GFX_Opt_s +{ + MI_GFX_Rect_t stClipRect; + MI_GFX_ColorKeyInfo_t stSrcColorKeyInfo; + MI_GFX_ColorKeyInfo_t stDstColorKeyInfo; + MI_GFX_DfbBldOp_e eSrcDfbBldOp; + MI_GFX_DfbBldOp_e eDstDfbBldOp; + MI_GFX_Mirror_e eMirror; + MI_GFX_Rotate_e eRotate; + MI_Gfx_DfbBlendFlags_e eDFBBlendFlag; + MI_U32 u32GlobalSrcConstColor; + MI_U32 u32GlobalDstConstColor; +} MI_GFX_Opt_t; +#ifdef __cplusplus +} +#endif + +#endif///_MI_GFX_DATATYPE_H_ diff --git a/src/video/mmiyoo/mi_hdmi.h b/src/video/mmiyoo/mi_hdmi.h new file mode 100755 index 0000000000000..204bd88df8e19 --- /dev/null +++ b/src/video/mmiyoo/mi_hdmi.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_HDMI_H_ +#define _MI_HDMI_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include "mi_common.h" +#include "mi_hdmi_datatype.h" + +#define HDMI_MAJOR_VERSION 2 +#define HDMI_SUB_VERSION 3 +#define MACRO_TO_STR(macro) #macro +#define HDMI_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_hdmi_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_hdmi_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_hdmi_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_HDMI_API_VERSION HDMI_VERSION_STR(HDMI_MAJOR_VERSION,HDMI_SUB_VERSION) + +MI_S32 MI_HDMI_Init(MI_HDMI_InitParam_t *pstInitParam); +MI_S32 MI_HDMI_DeInit(void); +MI_S32 MI_HDMI_Open(MI_HDMI_DeviceId_e eHdmi); +MI_S32 MI_HDMI_Close(MI_HDMI_DeviceId_e eHdmi); +MI_S32 MI_HDMI_SetAttr(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_Attr_t *pstAttr); +MI_S32 MI_HDMI_GetAttr(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_Attr_t *pstAttr); +MI_S32 MI_HDMI_Start(MI_HDMI_DeviceId_e eHdmi); +MI_S32 MI_HDMI_Stop(MI_HDMI_DeviceId_e eHdmi); +MI_S32 MI_HDMI_GetSinkInfo(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_SinkInfo_t *pstSinkInfo); +MI_S32 MI_HDMI_SetAvMute(MI_HDMI_DeviceId_e eHdmi, MI_BOOL bAvMute); +MI_S32 MI_HDMI_ForceGetEdid(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_Edid_t *pstEdidData); +MI_S32 MI_HDMI_SetDeepColor(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_DeepColor_e eDeepColor); +MI_S32 MI_HDMI_GetDeepColor(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_DeepColor_e *peDeepColor); +MI_S32 MI_HDMI_SetInfoFrame(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_InfoFrame_t *pstInfoFrame); +MI_S32 MI_HDMI_GetInfoFrame(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_InfoFrameType_e eInfoFrameType, + MI_HDMI_InfoFrame_t *pstInfoFrame); +MI_S32 MI_HDMI_SetAnalogDrvCurrent(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_AnalogDrvCurrent_t *pstAnalogDrvCurrent); + +#ifdef __cplusplus +} +#endif + +#endif ///_MI_HDMI_H_ diff --git a/src/video/mmiyoo/mi_hdmi_datatype.h b/src/video/mmiyoo/mi_hdmi_datatype.h new file mode 100755 index 0000000000000..51a2ad41a2259 --- /dev/null +++ b/src/video/mmiyoo/mi_hdmi_datatype.h @@ -0,0 +1,412 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_HDMI_DATATYPE_H_ +#define _MI_HDMI_DATATYPE_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include "mi_common.h" + +/*------------------------------------------------------------------------------------------------- + * Enum + ------------------------------------------------------------------------------------------------*/ +typedef enum +{ + E_MI_HDMI_ID_0 = 0, + E_MI_HDMI_ID_MAX +} MI_HDMI_DeviceId_e; + +typedef enum +{ + E_MI_HDMI_EVENT_HOTPLUG = 0, + E_MI_HDMI_EVENT_NO_PLUG, + E_MI_HDMI_EVENT_MAX +} MI_HDMI_EventType_e; + +typedef enum +{ + E_MI_HDMI_TIMING_480_60I = 0, + E_MI_HDMI_TIMING_480_60P = 1, + E_MI_HDMI_TIMING_576_50I = 2, + E_MI_HDMI_TIMING_576_50P = 3, + E_MI_HDMI_TIMING_720_50P = 4, + E_MI_HDMI_TIMING_720_60P = 5, + E_MI_HDMI_TIMING_1080_50I = 6, + E_MI_HDMI_TIMING_1080_50P = 7, + E_MI_HDMI_TIMING_1080_60I = 8, + E_MI_HDMI_TIMING_1080_60P = 9, + E_MI_HDMI_TIMING_1080_30P = 10, + E_MI_HDMI_TIMING_1080_25P = 11, + E_MI_HDMI_TIMING_1080_24P = 12, + E_MI_HDMI_TIMING_4K2K_30P = 13, + E_MI_HDMI_TIMING_1440_50P = 14, + E_MI_HDMI_TIMING_1440_60P = 15, + E_MI_HDMI_TIMING_1440_24P = 16, + E_MI_HDMI_TIMING_1440_30P = 17, + E_MI_HDMI_TIMING_1470_50P = 18, + E_MI_HDMI_TIMING_1470_60P = 19, + E_MI_HDMI_TIMING_1470_24P = 20, + E_MI_HDMI_TIMING_1470_30P = 21, + E_MI_HDMI_TIMING_1920x2205_24P = 22, + E_MI_HDMI_TIMING_1920x2205_30P = 23, + E_MI_HDMI_TIMING_4K2K_25P = 24, + E_MI_HDMI_TIMING_4K1K_60P = 25, + E_MI_HDMI_TIMING_4K2K_60P = 26, + E_MI_HDMI_TIMING_4K2K_24P = 27, + E_MI_HDMI_TIMING_4K2K_50P = 28, + E_MI_HDMI_TIMING_2205_24P = 29, + E_MI_HDMI_TIMING_4K1K_120P = 30, + E_MI_HDMI_TIMING_4096x2160_24P = 31, + E_MI_HDMI_TIMING_4096x2160_25P = 32, + E_MI_HDMI_TIMING_4096x2160_30P = 33, + E_MI_HDMI_TIMING_4096x2160_50P = 34, + E_MI_HDMI_TIMING_4096x2160_60P = 35, + E_MI_HDMI_TIMING_1024x768_60P = 36, + E_MI_HDMI_TIMING_1280x1024_60P = 37, + E_MI_HDMI_TIMING_1440x900_60P = 38, + E_MI_HDMI_TIMING_1600x1200_60P = 39, + E_MI_HDMI_TIMING_1280x800_60P = 40, + E_MI_HDMI_TIMING_1366x768_60P = 41, + E_MI_HDMI_TIMING_1680x1050_60P = 42, + E_MI_HDMI_TIMING_MAX, +} MI_HDMI_TimingType_e; + +typedef enum +{ + E_MI_HDMI_COLOR_TYPE_RGB444 = 0, + E_MI_HDMI_COLOR_TYPE_YCBCR422, + E_MI_HDMI_COLOR_TYPE_YCBCR444, + E_MI_HDMI_COLOR_TYPE_YCBCR420, + E_MI_HDMI_COLOR_TYPE_MAX +} MI_HDMI_ColorType_e; + +typedef enum +{ + E_MI_HDMI_OUTPUT_MODE_HDMI = 0, + E_MI_HDMI_OUTPUT_MODE_HDMI_HDCP, + E_MI_HDMI_OUTPUT_MODE_DVI, + E_MI_HDMI_OUTPUT_MODE_DVI_HDCP, + E_MI_HDMI_OUTPUT_MODE_MAX, +} MI_HDMI_OutputMode_e; + +typedef enum +{ + E_MI_HDMI_DEEP_COLOR_24BIT = 0, + E_MI_HDMI_DEEP_COLOR_30BIT, + E_MI_HDMI_DEEP_COLOR_36BIT, + E_MI_HDMI_DEEP_COLOR_48BIT, + E_MI_HDMI_DEEP_COLOR_MAX, +} MI_HDMI_DeepColor_e; + +typedef enum +{ + E_MI_HDMI_AUDIO_SAMPLERATE_UNKNOWN = 0, + E_MI_HDMI_AUDIO_SAMPLERATE_32K = 1, + E_MI_HDMI_AUDIO_SAMPLERATE_44K = 2, + E_MI_HDMI_AUDIO_SAMPLERATE_48K = 3, + E_MI_HDMI_AUDIO_SAMPLERATE_88K = 4, + E_MI_HDMI_AUDIO_SAMPLERATE_96K = 5, + E_MI_HDMI_AUDIO_SAMPLERATE_176K = 6, + E_MI_HDMI_AUDIO_SAMPLERATE_192K = 7, + E_MI_HDMI_AUDIO_SAMPLERATE_MAX, +} MI_HDMI_SampleRate_e; + +typedef enum +{ + E_MI_HDMI_BIT_DEPTH_8 = 8, + E_MI_HDMI_BIT_DEPTH_16 = 16, + E_MI_HDMI_BIT_DEPTH_18 = 18, + E_MI_HDMI_BIT_DEPTH_20 = 20, + E_MI_HDMI_BIT_DEPTH_24 = 24, + E_MI_HDMI_BIT_DEPTH_32 = 32, + E_MI_HDMI_BIT_DEPTH_MAX +} MI_HDMI_BitDepth_e; + +typedef enum +{ + E_MI_HDMI_ACODE_PCM = 0, + E_MI_HDMI_ACODE_NON_PCM, + E_MI_HDMI_ACODE_MAX +} MI_HDMI_AudioCodeType_e; + +typedef enum +{ + E_MI_HDMI_INFOFRAME_TYPE_AVI = 0, + E_MI_HDMI_INFOFRAME_TYPE_SPD, + E_MI_HDMI_INFOFRAME_TYPE_AUDIO, + E_MI_HDMI_INFOFRAME_TYPE_MAX +} MI_HDMI_InfoFrameType_e; + +typedef enum +{ + E_MI_HDMI_VIDEO_AFD_SameAsPictureAR = 8, // 1000 + E_MI_HDMI_VIDEO_AFD_4_3_Center = 9, // 1001 + E_MI_HDMI_VIDEO_AFD_16_9_Center = 10, // 1010 + E_MI_HDMI_VIDEO_AFD_14_9_Center = 11, // 1011 + E_MI_HDMI_VIDEO_AFD_Others = 15, // 0000~ 0111, 1100 ~ 1111 +} MI_HDMI_VideoAfdRatio_e; + +typedef enum +{ + E_MI_HDMI_AUDIO_CODING_REFER_STREAM_HEAD = 0, + E_MI_HDMI_AUDIO_CODING_PCM, + E_MI_HDMI_AUDIO_CODING_AC3, + E_MI_HDMI_AUDIO_CODING_MPEG1, + E_MI_HDMI_AUDIO_CODING_MP3, + E_MI_HDMI_AUDIO_CODING_MPEG2, + E_MI_HDMI_AUDIO_CODING_AAC, + E_MI_HDMI_AUDIO_CODING_DTS, + E_MI_HDMI_AUDIO_CODING_DDPLUS, + E_MI_HDMI_AUDIO_CODING_MLP, + E_MI_HDMI_AUDIO_CODING_WMA, + E_MI_HDMI_AUDIO_CODING_MAX +} MI_HDMI_AudioCodingType_e; + +typedef enum +{ + E_MI_HDMI_SCAN_INFO_NO_DATA = 0, /**< No Scan information*/ + E_MI_HDMI_SCAN_INFO_OVERSCANNED, /**< Scan information, Overscanned (for television) */ + E_MI_HDMI_SCAN_INFO_UNDERSCANNED, /**< Scan information, Underscanned (for computer) */ + E_MI_HDMI_SCAN_INFO_FUTURE, + E_MI_HDMI_SCAN_INFO_MAX +} MI_HDMI_ScanInfo_e; + +typedef enum +{ + E_MI_HDMI_COLORIMETRY_NO_DATA = 0, + E_MI_HDMI_COLORIMETRY_SMPTE170M, + E_MI_HDMI_COLORIMETRY_ITUR709, + E_MI_HDMI_COLORIMETRY_EXTEND, + E_MI_HDMI_COLORIMETRY_MAX, +} MI_HDMI_Colorimetry_e; + +typedef enum +{ + E_MI_HDMI_EXT_COLORIMETRY_XVYCC601 = 0, + E_MI_HDMI_EXT_COLORIMETRY_XVYCC709, + E_MI_HDMI_EXT_COLORIMETRY_SYCC601, + E_MI_HDMI_EXT_COLORIMETRY_ADOBEYCC601, + E_MI_HDMI_EXT_COLORIMETRY_ADOBERGB, + E_MI_HDMI_EXT_COLORIMETRY_BT2020CYCC, //mapping to ext. colorimetry format BT2020Y'cC'bcC'rc + E_MI_HDMI_EXT_COLORIMETRY_BT2020YCC, //mapping to ext. colorimetry format BT2020 RGB or YCbCr + E_MI_HDMI_EXT_COLORIMETRY_BT2020RGB, //mapping to ext. colorimetry format BT2020 RGB or YCbCr + E_MI_HDMI_EXT_COLORIMETRY_MAX, +} MI_HDMI_ExtColorimetry_e; + +typedef enum +{ + E_MI_HDMI_ASPECT_RATIO_INVALID = 0, /**< unknown aspect ratio */ + E_MI_HDMI_ASPECT_RATIO_4TO3, /**< 4:3 */ + E_MI_HDMI_ASPECT_RATIO_16TO9, /**< 16:9 */ + E_MI_HDMI_ASPECT_RATIO_21TO9, /**< 21:9 */ + E_MI_HDMI_ASPECT_RATIO_MAX +} MI_HDMI_AspectRatio_e; + +typedef enum +{ + E_MI_HDMI_YCC_QUANTIZATION_LIMITED_RANGE = 0, /**< Limited quantization range of 220 levels when receiving a CE video format*/ + E_MI_HDMI_YCC_QUANTIZATION_FULL_RANGE, /**< Full quantization range of 256 levels when receiving an IT video format*/ + E_MI_HDMI_YCC_QUANTIZATION_MAX +} MI_HDMI_YccQuantRange_e; + +typedef enum +{ + E_MI_HDMI_ERR_UNSUPPORT_TIMING = MI_HDMI_INITIAL_ERROR_CODE, + E_MI_HDMI_ERR_UNSUPPORT_COLORTYPE, + E_MI_HDMI_ERR_UNSUPPORT_COLORDEPTH, + E_MI_HDMI_ERR_UNSUPPORT_OUTPUTMODE, + E_MI_HDMI_ERR_UNSUPPORT_ACODETYPE, + E_MI_HDMI_ERR_UNSUPPORT_AFREQ, + E_MI_HDMI_ERR_EDID_HEADER_ERR, + E_MI_HDMI_ERR_EDID_DATA_ERR, + E_MI_HDMI_ERR_EDID_PRASE_ERR, + E_MI_HDMI_ERR_MAX +} MI_HDMI_ErrCode_e; + +/*------------------------------------------------------------------------------------------------- + * Defines + ------------------------------------------------------------------------------------------------*/ +#define MI_HDMI_MAX_ACAP_CNT 8 +#define MI_HDMI_MAX_AUDIO_SAMPLE_RATE_CNT 10 + +/* HDMI Module ErrorCode */ +#define MI_ERR_HDMI_INVALID_PARAM MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_ILLEGAL_PARAM) +#define MI_ERR_HDMI_INVALID_DEVID MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_INVALID_DEVID) +#define MI_ERR_HDMI_DRV_FAILED MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_FAILED) +#define MI_ERR_HDMI_NOT_INIT MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_INIT) +#define MI_ERR_HDMI_NOT_SUPPORT MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_ERR_NOT_SUPPORT) +#define MI_ERR_HDMI_UNSUPPORT_TIMING MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_HDMI_ERR_UNSUPPORT_TIMING) +#define MI_ERR_HDMI_UNSUPPORT_COLORTYPE MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_HDMI_ERR_UNSUPPORT_COLORTYPE) +#define MI_ERR_HDMI_UNSUPPORT_ACODETYPE MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_HDMI_ERR_UNSUPPORT_ACODETYPE) +#define MI_ERR_HDMI_UNSUPPORT_AFREQ MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_HDMI_ERR_UNSUPPORT_AFREQ) +#define MI_ERR_HDMI_EDID_HEADER_ERR MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_HDMI_ERR_EDID_HEADER_ERR) +#define MI_ERR_HDMI_EDID_DATA_ERR MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_HDMI_ERR_EDID_DATA_ERR) +#define MI_ERR_HDMI_EDID_PRASE_ERR MI_DEF_ERR(E_MI_MODULE_ID_HDMI, E_MI_ERR_LEVEL_ERROR, E_MI_HDMI_ERR_EDID_PRASE_ERR) + +/*------------------------------------------------------------------------------------------------- + * Callback + ------------------------------------------------------------------------------------------------*/ +typedef MI_S32 (* MI_HDMI_EventCallBack)(MI_HDMI_DeviceId_e eHdmi, MI_HDMI_EventType_e event, void *pEventParam, void *pUsrParam); + +/*------------------------------------------------------------------------------------------------- + * Structures + ------------------------------------------------------------------------------------------------*/ +typedef struct MI_HDMI_InitParam_s +{ + MI_HDMI_EventCallBack pfnHdmiEventCallback; + void *pCallBackArgs; +} MI_HDMI_InitParam_t; + +typedef struct MI_HDMI_VideoAttr_s +{ + MI_BOOL bEnableVideo; + MI_HDMI_TimingType_e eTimingType; + MI_HDMI_OutputMode_e eOutputMode; + MI_HDMI_ColorType_e eColorType; + MI_HDMI_DeepColor_e eDeepColorMode; +} MI_HDMI_VideoAttr_t; + +typedef struct MI_HDMI_AudioAttr_s +{ + MI_BOOL bEnableAudio; + MI_BOOL bIsMultiChannel;// 0->2channel 1->8channel + MI_HDMI_SampleRate_e eSampleRate; + MI_HDMI_BitDepth_e eBitDepth; + MI_HDMI_AudioCodeType_e eCodeType; +} MI_HDMI_AudioAttr_t; + +typedef struct MI_HDMI_EnInfoFrame_s +{ + MI_BOOL bEnableAviInfoFrame; + MI_BOOL bEnableAudInfoFrame; + MI_BOOL bEnableSpdInfoFrame; +} MI_HDMI_EnInfoFrame_t; + +typedef struct MI_HDMI_Attr_s +{ + MI_BOOL bConnect; + MI_HDMI_VideoAttr_t stVideoAttr; + MI_HDMI_AudioAttr_t stAudioAttr; + MI_HDMI_EnInfoFrame_t stEnInfoFrame; +} MI_HDMI_Attr_t; + +typedef struct MI_HDMI_Edid_s +{ + MI_BOOL bEdidValid; + MI_U32 u32Edidlength; + MI_U8 au8Edid[512]; /* EDID buffer */ +} MI_HDMI_Edid_t; + +typedef struct MI_HDMI_Sink_Info_s +{ + MI_BOOL bConnected; + MI_BOOL bSupportHdmi; + MI_HDMI_TimingType_e eNativeTimingType; + MI_BOOL abVideoFmtSupported[E_MI_HDMI_TIMING_MAX]; + MI_BOOL bSupportYCbCr444; + MI_BOOL bSupportYCbCr422; + MI_BOOL bSupportYCbCr; + MI_BOOL bSupportxvYcc601; + MI_BOOL bSupportxvYcc709; + MI_U8 u8MdBit; + MI_BOOL abAudioFmtSupported[MI_HDMI_MAX_ACAP_CNT]; + MI_U32 au32AudioSampleRateSupported[MI_HDMI_MAX_AUDIO_SAMPLE_RATE_CNT]; + MI_U32 u32MaxPcmChannels; + MI_U8 u8Speaker; + MI_U8 au8IdManufactureName[4]; + MI_U32 u32IdProductCode; + MI_U32 u32IdSerialNumber; + MI_U32 u32WeekOfManufacture; + MI_U32 u32YearOfManufacture; + MI_U8 u8Version; + MI_U8 u8Revision; + MI_U8 u8EdidExternBlockNum; + MI_U8 au8IeeRegId[3];//IEEE registeration identifier + MI_U8 u8PhyAddr_A; + MI_U8 u8PhyAddr_B; + MI_U8 u8PhyAddr_C; + MI_U8 u8PhyAddr_D; + MI_BOOL bSupportDviDual; + MI_BOOL bSupportDeepColorYcbcr444; + MI_BOOL bSupportDeepColor30Bit; + MI_BOOL bSupportDeepColor36Bit; + MI_BOOL bSupportDeepColor48Bit; + MI_BOOL bSupportAi; + MI_U32 u8MaxTmdsClock; + MI_BOOL bILatencyFieldsPresent; + MI_BOOL bLatencyFieldsPresent; + MI_BOOL bHdmiVideoPresent; + MI_U8 u8VideoLatency; + MI_U8 u8AudioLatency; + MI_U8 u8InterlacedVideoLatency; + MI_U8 u8InterlacedAudioLatency; +} MI_HDMI_SinkInfo_t; + +typedef struct MI_HDMIAviInforFrameVer_s +{ + MI_BOOL bEnableAfdOverWrite; + MI_U8 A0Value; + MI_HDMI_ColorType_e eColorType; + MI_HDMI_Colorimetry_e eColorimetry; + MI_HDMI_ExtColorimetry_e eExtColorimetry; + MI_HDMI_YccQuantRange_e eYccQuantRange; + MI_HDMI_TimingType_e eTimingType; //trans to MS_VIDEO_TIMING in impl + MI_HDMI_VideoAfdRatio_e eAfdRatio; + MI_HDMI_ScanInfo_e eScanInfo; + MI_HDMI_AspectRatio_e eAspectRatio; +} MI_HDMI_AviInfoFrameVer_t; + +typedef struct MI_HDMI_AudInfoFrameVer_s +{ + MI_U32 u32ChannelCount; //2 4 6 8 channels + MI_HDMI_AudioCodeType_e eAudioCodeType;//PCM NON-PCM + MI_HDMI_SampleRate_e eSampleRate; +} MI_HDMI_AudInfoFrameVer_t; + +typedef struct MI_HDMI_SpdInfoFrame_s +{ + MI_U8 au8VendorName[8]; + MI_U8 au8ProductDescription[16]; +} MI_HDMI_SpdInfoFrame_t; + +typedef union +{ + MI_HDMI_AviInfoFrameVer_t stAviInfoFrame; + MI_HDMI_AudInfoFrameVer_t stAudInfoFrame; + MI_HDMI_SpdInfoFrame_t stSpdInfoFrame; +} MI_HDMI_InfoFrameUnit_u; + +typedef struct MI_HDMI_InfoFrame_s +{ + MI_HDMI_InfoFrameType_e eInfoFrameType; /* InfoFrame type */ + MI_HDMI_InfoFrameUnit_u unInforUnit; /* InfoFrame date */ +} MI_HDMI_InfoFrame_t; + +typedef struct MI_HDMI_AnalogDrvCurrent_s +{ + MI_U8 u8DrvCurTap1Ch0; + MI_U8 u8DrvCurTap1Ch1; + MI_U8 u8DrvCurTap1Ch2; + MI_U8 u8DrvCurTap1Ch3; + MI_U8 u8DrvCurTap2Ch0; + MI_U8 u8DrvCurTap2Ch1; + MI_U8 u8DrvCurTap2Ch2; + MI_U8 u8DrvCurTap2Ch3; +} MI_HDMI_AnalogDrvCurrent_t; + +#ifdef __cplusplus +} +#endif +#endif //_MI_HDMI_DATATYPE_H_ diff --git a/src/video/mmiyoo/mi_panel.h b/src/video/mmiyoo/mi_panel.h new file mode 100755 index 0000000000000..4b90213f46afb --- /dev/null +++ b/src/video/mmiyoo/mi_panel.h @@ -0,0 +1,57 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_PANEL_H_ +#define _MI_PANEL_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include "mi_common.h" +#include "mi_panel_datatype.h" + +#define PANEL_MAJOR_VERSION 2 +#define PANEL_SUB_VERSION 8 +#define MACRO_TO_STR(macro) #macro +#define PANEL_VERSION_STR(major_version,sub_version) ({char *tmp = sub_version/100 ? \ + "mi_panel_version_" MACRO_TO_STR(major_version)"." MACRO_TO_STR(sub_version) : sub_version/10 ? \ + "mi_panel_version_" MACRO_TO_STR(major_version)".0" MACRO_TO_STR(sub_version) : \ + "mi_panel_version_" MACRO_TO_STR(major_version)".00" MACRO_TO_STR(sub_version);tmp;}) +#define MI_PANEL_API_VERSION PANEL_VERSION_STR(PANEL_MAJOR_VERSION,PANEL_SUB_VERSION) + +MI_S32 MI_PANEL_Init(MI_PANEL_LinkType_e eLinkType); +MI_S32 MI_PANEL_DeInit(void); +MI_S32 MI_PANEL_SetIndex(MI_PANEL_INDEX_e eIndex); +MI_S32 MI_PANEL_GetTotalNum(MI_U32 *pu32TotalNum); +MI_S32 MI_PANEL_SetPowerOn(MI_PANEL_PowerConfig_t *pstPowerCfg); +MI_S32 MI_PANEL_GetPowerOn(MI_PANEL_PowerConfig_t *pstPowerCfg); +MI_S32 MI_PANEL_SetBackLight(MI_PANEL_BackLightConfig_t *pstBackLightCfg); +MI_S32 MI_PANEL_GetBackLight(MI_PANEL_BackLightConfig_t *pstBackLightCfg); +MI_S32 MI_PANEL_SetBackLightLevel(MI_PANEL_BackLightConfig_t *pstBackLightCfg); +MI_S32 MI_PANEL_GetBackLightLevel(MI_PANEL_BackLightConfig_t *pstBackLightCfg); +MI_S32 MI_PANEL_SetSscConfig(MI_PANEL_SscConfig_t *pstSscCfg); +MI_S32 MI_PANEL_SetMipiDsiConfig(MI_PANEL_MipiDsiConfig_t *pstMipiDsiCfg); +MI_S32 MI_PANEL_SetTimingConfig(MI_PANEL_TimingConfig_t *pstTimingCfg); +MI_S32 MI_PANEL_SetDrvCurrentConfig(MI_PANEL_DrvCurrentConfig_t *pstDrvCurrentCfg); +MI_S32 MI_PANEL_SetOutputPattern(MI_PANEL_TestPatternConfig_t * pstTestPatternCfg); +MI_S32 MI_PANEL_SetPanelParam(MI_PANEL_ParamConfig_t *pstParamCfg); +MI_S32 MI_PANEL_GPIO_Init(MI_PANEL_GpioConfig_t *pstGpioCfg); +MI_S32 MI_PANEL_SetGpioStatus(MI_U16 u16GpioNum, MI_BOOL bValue); +MI_S32 MI_PANEL_SetCmd(MI_U32 u32Value, MI_U8 u8Bits); +MI_S32 MI_PANEL_PWM_Init(MI_PANEL_PwmConfig_t *pstPwmCfg); + +#ifdef __cplusplus +} +#endif + +#endif ///_MI_PANEL_H_ diff --git a/src/video/mmiyoo/mi_panel_datatype.h b/src/video/mmiyoo/mi_panel_datatype.h new file mode 100755 index 0000000000000..63ec72e0c3748 --- /dev/null +++ b/src/video/mmiyoo/mi_panel_datatype.h @@ -0,0 +1,366 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ +#ifndef _MI_PANEL_DATATYPE_H_ +#define _MI_PANEL_DATATYPE_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include "mi_common.h" + + +/*------------------------------------------------------------------------------------------------- + * Enum + ------------------------------------------------------------------------------------------------*/ + +typedef enum +{ + E_MI_PNL_AUO_21_1920x1080_60Hz = 0, + E_MI_PNL_LG_37_1920x1080_60Hz, + E_MI_PNL_INX_10_1280x800_60Hz, + E_MI_PNL_MAX +}MI_PANEL_INDEX_e; + +typedef enum +{ + E_MI_PNL_MIPI_DSI_LANE_NONE = 0, + E_MI_PNL_MIPI_DSI_LANE_1 = 1, + E_MI_PNL_MIPI_DSI_LANE_2 = 2, + E_MI_PNL_MIPI_DSI_LANE_3 = 3, + E_MI_PNL_MIPI_DSI_LANE_4 = 4, +}MI_PANEL_MipiDsiLaneMode_e; + +typedef enum +{ + E_MI_PNL_MIPI_DSI_RGB565 = 0, + E_MI_PNL_MIPI_DSI_RGB666 = 1, + E_MI_PNL_MIPI_DSI_LOOSELY_RGB666 = 2, + E_MI_PNL_MIPI_DSI_RGB888 = 3, +}MI_PANEL_MipiDsiFormat_e; + +typedef enum +{ + E_MI_PNL_MIPI_DSI_CMD_MODE = 0, + E_MI_PNL_MIPI_DSI_SYNC_PULSE = 1, + E_MI_PNL_MIPI_DSI_SYNC_EVENT = 2, + E_MI_PNL_MIPI_DSI_BURST_MODE = 3, +}MI_PANEL_MipiDsiCtrlMode_e; + +typedef enum +{ + E_MI_PNL_LINK_TTL, ///< TTL type + E_MI_PNL_LINK_LVDS, ///< LVDS type + E_MI_PNL_LINK_RSDS, ///< RSDS type + E_MI_PNL_LINK_MINILVDS, ///< TCON + E_MI_PNL_LINK_ANALOG_MINILVDS, ///< Analog TCON + E_MI_PNL_LINK_DIGITAL_MINILVDS, ///< Digital TCON + E_MI_PNL_LINK_MFC, ///< Ursa (TTL output to Ursa) + E_MI_PNL_LINK_DAC_I, ///< DAC output + E_MI_PNL_LINK_DAC_P, ///< DAC output + E_MI_PNL_LINK_PDPLVDS, ///< For PDP(Vsync use Manually MODE) + E_MI_PNL_LINK_EXT, ///< EXT LPLL TYPE + E_MI_PNL_LINK_MIPI_DSI, ///< Mipi DSI +}MI_PANEL_LinkType_e; + +typedef enum +{ + E_MI_PNL_ASPECT_RATIO_4_3 = 0, ///< set aspect ratio to 4 : 3 + E_MI_PNL_ASPECT_RATIO_WIDE, ///< set aspect ratio to 16 : 9 + E_MI_PNL_ASPECT_RATIO_OTHER, ///< resvered for other aspect ratio other than 4:3/ 16:9 +}MI_PANEL_AspectRatio_e; + +typedef enum +{ + E_MI_PNL_TI_10BIT_MODE = 0, + E_MI_PNL_TI_8BIT_MODE = 2, + E_MI_PNL_TI_6BIT_MODE = 3, +}MI_PANEL_TiBitMode_e; + +typedef enum +{ + E_MI_PNL_OUTPUT_10BIT_MODE = 0, //default is 10bit, becasue 8bit panel can use 10bit config and 8bit config. + E_MI_PNL_OUTPUT_6BIT_MODE = 1, //but 10bit panel(like PDP panel) can only use 10bit config. + E_MI_PNL_OUTPUT_8BIT_MODE = 2, //and some PDA panel is 6bit. + E_MI_PNL_OUTPUT_565BIT_MODE = 3, +}MI_PANEL_OutputFormatBitMode_e; + +typedef enum +{ + E_MI_PNL_CHG_DCLK = 0, ///0)indicates an set up connection +/// @param[in] *pstConnectParam :. +/// infra mode:contains nessesarry information to establish a sta connection +/// @return MI_SUCCESS: connect success. +/// @return MI_WLAN_ERR_MOD_NOT_INIT: open wlan device first +//------------------------------------------------------------------------------ +MI_RESULT MI_WLAN_Connect(WLAN_HANDLE *hWLan, MI_WLAN_ConnectParam_t *pstConnectParam); + +//------------------------------------------------------------------------------ +/// @brief disconnect wlan +/// @param[in] hWLan wlan handle. +/// @return MI_SUCCESS: Process success. +/// @return MI_WLAN_ERR_NOT_CONFIG: set up a wlan connection first +//------------------------------------------------------------------------------ +MI_RESULT MI_WLAN_Disconnect(WLAN_HANDLE hWLan); + +//------------------------------------------------------------------------------ +/// @brief scan ap info +/// @param[in] *pstParam info param. //reserved +/// @param[out] *pstResult result. +/// @return MI_SUCCESS: success. +/// @return MI_WLAN_ERR_NOT_CONFIG: open wlan first +//------------------------------------------------------------------------------ +MI_RESULT MI_WLAN_Scan(MI_WLAN_ScanParam_t *pstParam, MI_WLAN_ScanResult_t *pstResult); + +//------------------------------------------------------------------------------ +/// @brief set wlan debug level +/// @param[in] eDgbLevel debug level. +/// @return MI_OK: Process success. +/// @return MI_ERR_FAILED: Process failed +//------------------------------------------------------------------------------ +//MI_RESULT MI_WLAN_SetDebugLevel(MI_DBG_LEVEL_e eDgbLevel); + +//------------------------------------------------------------------------------ +/// @brief get current wlan status +/// @param[in] the struct to store wlan status +/// @return MI_SUCCESS: Process success. +/// @return MI_WLAN_ERR_NOT_CONFIG: open wlan first +//------------------------------------------------------------------------------ +MI_RESULT MI_WLAN_GetStatus(MI_WLAN_Status_t *status); + +//------------------------------------------------------------------------------ +/// @brief get wlan chip version +/// @return MI_OK: Process success +/// @return MI_ERR_FAILED: Process failed +//------------------------------------------------------------------------------ +MI_RESULT MI_WLAN_GetWlanChipVersion(MI_U8 *ChipVersion); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/video/mmiyoo/mi_wlan_datatype.h b/src/video/mmiyoo/mi_wlan_datatype.h new file mode 100755 index 0000000000000..e19bf39a9829f --- /dev/null +++ b/src/video/mmiyoo/mi_wlan_datatype.h @@ -0,0 +1,73 @@ +/* Copyright (c) 2018-2019 Sigmastar Technology Corp. + All rights reserved. + + Unless otherwise stipulated in writing, any and all information contained + herein regardless in any format shall remain the sole proprietary of + Sigmastar Technology Corp. and be kept in strict confidence + (��Sigmastar Confidential Information��) by the recipient. + Any unauthorized act including without limitation unauthorized disclosure, + copying, use, reproduction, sale, distribution, modification, disassembling, + reverse engineering and compiling of the contents of Sigmastar Confidential + Information is unlawful and strictly prohibited. Sigmastar hereby reserves the + rights to any and all damages, losses, costs and expenses resulting therefrom. +*/ + +#ifndef __MI_WLAN_DATATYPE_H__ +#define __MI_WLAN_DATATYPE_H__ +#ifdef __cplusplus +extern "C" { +#endif + +#define DBG_LEVEL_FATAL (1) +#define DBG_LEVEL_ERROR (2) +#define DBG_LEVEL_WARN (3) +#define DBG_LEVEL_INFO (4) +#define DBG_LEVEL_DEBUG (5) +#define DBG_LEVEL_ENTRY (6) + +#define DBG_LEVEL DBG_LEVEL_WARN + +#define COLOR_NONE "\033[0m" +#define COLOR_BLACK "\033[0;30m" +#define COLOR_BLUE "\033[0;34m" +#define COLOR_GREEN "\033[0;32m" +#define COLOR_CYAN "\033[0;36m" +#define COLOR_RED "\033[0;31m" +#define COLOR_YELLOW "\033[1;33m" +#define COLOR_WHITE "\033[1;37m" + +#define DBG_ENTRY(fmt, args...) ({do{if(DBG_LEVEL>=DBG_LEVEL_ENTRY){printf(COLOR_CYAN"[WLAN_ENTRY]:%s[%d]: ", __FUNCTION__,__LINE__);printf(fmt, ##args);printf(COLOR_NONE);}}while(0);}) +#define DBG_DEBUG(fmt, args...) ({do{if(DBG_LEVEL>=DBG_LEVEL_DEBUG){printf(COLOR_WHITE"[WLAN_BDG]:%s[%d]: ", __FUNCTION__,__LINE__);printf(fmt, ##args);printf(COLOR_NONE);}}while(0);}) +#define DBG_INFO(fmt, args...) ({do{if(DBG_LEVEL>=DBG_LEVEL_INFO) {printf(COLOR_GREEN"[WLAN_INFO]:%s[%d]: ", __FUNCTION__,__LINE__);printf(fmt, ##args);printf(COLOR_NONE);}}while(0);}) +#define DBG_WRN(fmt, args...) ({do{if(DBG_LEVEL>=DBG_LEVEL_WARN) {printf(COLOR_YELLOW"[WLAN_WRN]:%s[%d]: ", __FUNCTION__,__LINE__);printf(fmt, ##args);printf(COLOR_NONE);}}while(0);}) +#define DBG_ERR(fmt, args...) ({do{if(DBG_LEVEL>=DBG_LEVEL_ERROR){printf(COLOR_RED"[WLAN_ERR]:%s[%d]: ", __FUNCTION__,__LINE__);printf(fmt, ##args);printf(COLOR_NONE);}}while(0);}) +#define DBG_FATAL(fmt, args...) ({do{if(DBG_LEVEL>=DBG_LEVEL_FATAL){printf(COLOR_RED"[WLAN_FATAL]:%s[%d]: ", __FUNCTION__,__LINE__);printf(fmt, ##args);printf(COLOR_NONE);}}while(0);}) + + + +typedef enum +{ + E_WLAN_CMD_INIT = 0, + E_WLAN_CMD_OPEN, + E_WLAN_CMD_CLOSE, + E_WLAN_CMD_DEINIT, + E_WLAN_CMD_SCAN, + E_WLAN_CMD_CONNECT, + E_WLAN_CMD_CONNECT_addNetWork, + E_WLAN_CMD_DISCONNECT, + E_WLAN_CMD_STATUS, + E_WLAN_CMD_VERSION, + E_WLAN_CMD_CHANNEL, + E_WLAN_CMD_NUM +} E_WLAN_CMD; + + + + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/test/configure b/test/configure index 60344e3ecde82..f00055dc868b8 100755 --- a/test/configure +++ b/test/configure @@ -643,6 +643,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -725,6 +726,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' @@ -977,6 +979,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1114,7 +1125,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1267,6 +1278,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -3661,34 +3673,8 @@ else $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. -ac_x_includes=no -ac_x_libraries=no -# Do we need to do anything special at all? -ac_save_LIBS=$LIBS -LIBS="-lX11 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -XrmInitialize () - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - # We can compile and link X programs with no special options. - ac_x_includes= - ac_x_libraries= -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS="$ac_save_LIBS" -# If that didn't work, only try xmkmf and filesystem searches -# for native compilation. -if test x"$ac_x_includes" = xno && test "$cross_compiling" = no; then : - rm -f -r conftest.dir +ac_x_includes=no ac_x_libraries=no +rm -f -r conftest.dir if mkdir conftest.dir; then cd conftest.dir cat >Imakefile <<'_ACEOF' @@ -3727,7 +3713,7 @@ _ACEOF rm -f -r conftest.dir fi - # Standard set of common directories for X headers. +# Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include @@ -3754,8 +3740,6 @@ ac_x_header_dirs=' /usr/local/include/X11R5 /usr/local/include/X11R4 -/opt/X11/include - /usr/X386/include /usr/x386/include /usr/XFree86/include/X11 @@ -3829,17 +3813,15 @@ rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no -fi -# Record the results. case $ac_x_includes,$ac_x_libraries in #( - no,* | *,no | *\'*) : + no,* | *,no | *\'*) # Didn't find X, or a directory has "'" in its name. - ac_cv_have_x="have_x=no" ;; #( - *) : + ac_cv_have_x="have_x=no";; #( + *) # Record where we found X for the cache. ac_cv_have_x="have_x=yes\ ac_x_includes='$ac_x_includes'\ - ac_x_libraries='$ac_x_libraries'" ;; + ac_x_libraries='$ac_x_libraries'" esac fi ;; #(