Add OpenDingux Beta support

This commit is contained in:
jdgleaver 2021-03-23 12:46:25 +00:00
parent 0674de54ee
commit 0a08437e0a
16 changed files with 543 additions and 174 deletions

View File

@ -403,6 +403,27 @@ build-retroarch-dingux-mips32:
- "cp -f libretro-common/audio/dsp_filters/*.dsp ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/audio"
- "cp -f gfx/video_filters/*.filt ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/video"
build-retroarch-dingux-odbeta-mips32:
image: $CI_SERVER_HOST:5050/libretro-infrastructure/libretro-build-dingux:odbeta
stage: build
variables:
MEDIA_PATH: .media
STRIP_BIN: 1
before_script:
- export NUMPROC=$(($(nproc)/3))
artifacts:
paths:
- retroarch_rg350_odbeta.opk
- ${MEDIA_PATH}
expire_in: 10 min
dependencies: []
script:
- "make -j$NUMPROC -f Makefile.rg350_odbeta"
- "mkdir -p ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/audio"
- "mkdir -p ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/video"
- "cp -f libretro-common/audio/dsp_filters/*.dsp ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/audio"
- "cp -f gfx/video_filters/*.filt ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/video"
build-retroarch-android-normal:
image: $CI_SERVER_HOST:5050/libretro-infrastructure/libretro-build-android:latest
stage: build

View File

@ -120,12 +120,12 @@ DEF_FLAGS += -mplt -mno-shared
DEF_FLAGS += -ffunction-sections -fdata-sections
DEF_FLAGS += -I. -Ideps -Ideps/stb -DDINGUX=1 -MMD
DEF_FLAGS += -Wall -Wno-unused-variable
DEF_FLAGS += -std=gnu99 -D_GNU_SOURCE
DEF_FLAGS += -std=gnu99 -D_GNU_SOURCE -flto
LIBS := -ldl -lz -lrt -ludev -pthread
CFLAGS :=
CXXFLAGS := -fno-exceptions -fno-rtti -std=c++11 -D__STDC_CONSTANT_MACROS
ASFLAGS :=
LDFLAGS := -flto -Wl,--gc-sections
LDFLAGS := -Wl,--gc-sections
INCLUDE_DIRS = -I$(GCW0_INC_DIR)
LIBRARY_DIRS = -L$(GCW0_LIB_DIR)
DEFINES := -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64 -UHAVE_STATIC_DUMMY
@ -155,6 +155,7 @@ endif
include Makefile.common
DEF_FLAGS += $(INCLUDE_DIRS)
LDFLAGS += $(CFLAGS) $(CXXFLAGS) $(DEF_FLAGS)
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS)

229
Makefile.rg350_odbeta Normal file
View File

@ -0,0 +1,229 @@
#########################
## Toolchain variables ##
#########################
# Default toolchain directory
TOOLCHAIN_DIR=/opt/gcw0-toolchain
# All toolchain-related variables may be
# overridden via the command line
ifdef GCW0_CC
CC = $(GCW0_CC)
else
CC = $(TOOLCHAIN_DIR)/usr/bin/mipsel-gcw0-linux-uclibc-gcc
endif
ifdef GCW0_CXX
CXX = $(GCW0_CXX)
else
CXX = $(TOOLCHAIN_DIR)/usr/bin/mipsel-gcw0-linux-uclibc-g++
endif
ifdef GCW0_STRIP
STRIP = $(GCW0_STRIP)
else
STRIP = $(TOOLCHAIN_DIR)/usr/bin/mipsel-gcw0-linux-uclibc-strip
endif
GCW0_SDL_CONFIG ?= $(TOOLCHAIN_DIR)/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/sdl-config
GCW0_FREETYPE_CONFIG ?= $(TOOLCHAIN_DIR)/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/freetype-config
GCW0_MK_SQUASH_FS ?= $(TOOLCHAIN_DIR)/usr/bin/mksquashfs
GCW0_INC_DIR ?= $(TOOLCHAIN_DIR)/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include
GCW0_LIB_DIR ?= $(TOOLCHAIN_DIR)/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib
#########################
#########################
PACKAGE_NAME = retroarch
DEBUG ?= 0
DINGUX = 1
DINGUX_BETA = 1
HAVE_SCREENSHOTS = 0
HAVE_REWIND = 1
HAVE_7ZIP = 1
HAVE_AL = 1
# ALSA freezes when switching back from menu
HAVE_ALSA = 0
HAVE_DSP_FILTER = 1
HAVE_VIDEO_FILTER = 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_FILTERS_BUILTIN = 1
HAVE_BUILTINMBEDTLS = 0
HAVE_BUILTINZLIB = 1
HAVE_C99 = 1
HAVE_CC = 1
HAVE_CC_RESAMPLER = 1
HAVE_CHD = 1
HAVE_COMMAND = 0
HAVE_CXX = 1
HAVE_DR_MP3 = 1
HAVE_DYNAMIC = 1
HAVE_EGL = 0
HAVE_FREETYPE = 0
HAVE_GDI = 1
HAVE_GETADDRINFO = 0
HAVE_GETOPT_LONG = 1
HAVE_GLSL = 0
HAVE_HID = 1
HAVE_IBXM = 1
HAVE_IMAGEVIEWER = 1
HAVE_LANGEXTRA = 0
HAVE_LIBRETRODB = 1
HAVE_MENU = 1
HAVE_MENU_COMMON = 1
HAVE_GFX_WIDGETS = 0
HAVE_MMAP = 1
HAVE_OPENDINGUX_FBDEV = 0
HAVE_OPENGL = 0
HAVE_OPENGL1 = 0
HAVE_OPENGLES = 0
HAVE_OPENGLES3 = 0
HAVE_OPENGL_CORE = 0
HAVE_OPENSSL = 1
HAVE_OVERLAY = 0
HAVE_RBMP = 1
HAVE_RJPEG = 1
HAVE_RPILED = 0
HAVE_RPNG = 1
HAVE_RUNAHEAD = 1
HAVE_SDL_DINGUX = 1
HAVE_SHADERPIPELINE = 0
HAVE_STB_FONT = 0
HAVE_STB_IMAGE = 1
HAVE_STB_VORBIS = 1
HAVE_STDIN_CMD = 0
HAVE_STRCASESTR = 1
HAVE_THREADS = 1
HAVE_UDEV = 1
HAVE_RGUI = 1
HAVE_MATERIALUI = 0
HAVE_XMB = 0
HAVE_OZONE = 0
HAVE_ZLIB = 1
HAVE_CONFIGFILE = 1
HAVE_PATCH = 1
HAVE_CHEATS = 1
HAVE_CHEEVOS = 0
HAVE_LIBSHAKE = 1
OS = Linux
TARGET = retroarch
OPK_NAME = retroarch_rg350_odbeta.opk
OBJ :=
LINK := $(CXX)
DEF_FLAGS := -mplt -mno-shared
DEF_FLAGS += -ffunction-sections -fdata-sections
DEF_FLAGS += -I. -Ideps -Ideps/stb -DDINGUX=1 -DDINGUX_BETA=1 -MMD
DEF_FLAGS += -Wall -Wno-unused-variable
DEF_FLAGS += -std=gnu99 -D_GNU_SOURCE -flto
LIBS := -ldl -lz -lrt -ludev -pthread
CFLAGS :=
CXXFLAGS := -fno-exceptions -fno-rtti -std=c++11 -D__STDC_CONSTANT_MACROS
ASFLAGS :=
LDFLAGS := -Wl,--gc-sections
INCLUDE_DIRS = -I$(GCW0_INC_DIR)
LIBRARY_DIRS = -L$(GCW0_LIB_DIR)
DEFINES := -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64 -UHAVE_STATIC_DUMMY
DEFINES += -DHAVE_C99=1 -DHAVE_CXX=1
DEFINES += -DHAVE_GETOPT_LONG=1 -DHAVE_STRCASESTR=1 -DHAVE_DYNAMIC=1
DEFINES += -DHAVE_AL=1
DEFINES += -DHAVE_FILTERS_BUILTIN
DEFINES += -DHAVE_UDEV=1
SDL_DINGUX_CFLAGS := $(shell $(GCW0_SDL_CONFIG) --cflags)
SDL_DINGUX_LIBS := $(shell $(GCW0_SDL_CONFIG) --libs)
FREETYPE_CFLAGS := $(shell $(GCW0_FREETYPE_CONFIG) --cflags)
FREETYPE_LIBS := $(shell $(GCW0_FREETYPE_CONFIG) --libs)
AL_LIBS := -lopenal
MMAP_LIBS = -lc
OBJDIR_BASE := obj-unix
ifeq ($(DEBUG), 1)
OBJDIR := $(OBJDIR_BASE)/debug
DEF_FLAGS += -O0 -g -DDEBUG -D_DEBUG
else
OBJDIR := $(OBJDIR_BASE)/release
DEF_FLAGS += -O2 -DNDEBUG
endif
include Makefile.common
DEF_FLAGS += $(INCLUDE_DIRS)
LDFLAGS += $(CFLAGS) $(CXXFLAGS) $(DEF_FLAGS)
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS)
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
Q := @
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
define DESKTOP_ENTRY
[Desktop Entry]
Name=RetroArch
Comment=Frontend for emulators, game engines
Exec=retroarch
Terminal=false
Type=Application
StartupNotify=true
Icon=retroarch
Categories=emulators;
X-OD-NeedsDownscaling=true
endef
export DESKTOP_ENTRY
all: $(TARGET) opk
-include $(RARCH_OBJ:.o=.d)
SYMBOL_MAP := -Wl,-Map=output.map
$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.m
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo OBJC $<),)
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.S $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo AS $<),)
$(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
clean:
rm -rf $(OBJDIR_BASE)
rm -f $(TARGET)
rm -f *.d
rm -rf $(OPK_NAME)
opk: $(TARGET)
echo "$$DESKTOP_ENTRY" > default.gcw0.desktop
rm -f $(OPK_NAME)
cp media/ico_src/icon32.png retroarch.png
if [ $$STRIP_BIN -eq 1 ]; then $(STRIP) --strip-unneeded retroarch; fi
$(GCW0_MK_SQUASH_FS) retroarch default.gcw0.desktop retroarch.png $(OPK_NAME) -all-root -no-xattrs -noappend -no-exports
rm -f default.gcw0.desktop retroarch.png
.PHONY: all clean opk
print-%:
@echo '$*=$($*)'

View File

@ -74,19 +74,24 @@ static void *sdl_audio_init(const char *device,
int frames;
size_t bufsize;
SDL_AudioSpec out;
SDL_AudioSpec spec = {0};
void *tmp = NULL;
sdl_audio_t *sdl = NULL;
SDL_AudioSpec spec = {0};
void *tmp = NULL;
sdl_audio_t *sdl = NULL;
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
(void)device;
if (SDL_WasInit(0) == 0)
/* Initialise audio subsystem, if required */
if (sdl_subsystem_flags == 0)
{
if (SDL_Init(SDL_INIT_AUDIO) < 0)
return NULL;
}
else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
return NULL;
else if ((sdl_subsystem_flags & SDL_INIT_AUDIO) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
return NULL;
}
sdl = (sdl_audio_t*)calloc(1, sizeof(*sdl));
if (!sdl)
@ -227,7 +232,6 @@ static void sdl_audio_free(void *data)
sdl_audio_t *sdl = (sdl_audio_t*)data;
SDL_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
if (sdl)
{

View File

@ -18,6 +18,10 @@
#include <file/file_path.h>
#include <streams/file_stream.h>
#if defined(DINGUX_BETA)
#include <stdlib.h>
#endif
#include "dingux_utils.h"
#define DINGUX_ALLOW_DOWNSCALING_FILE "/sys/devices/platform/jz-lcd.0/allow_downscaling"
@ -27,10 +31,16 @@
#define DINGUX_SHARPNESS_DOWNSCALING_FILE "/sys/devices/platform/jz-lcd.0/sharpness_downscaling"
#define DINGUX_BATTERY_CAPACITY_FILE "/sys/class/power_supply/battery/capacity"
#define DINGUX_SCALING_MODE_ENVAR "SDL_VIDEO_KMSDRM_SCALING_MODE"
#define DINGUX_SCALING_SHARPNESS_ENVAR "SDL_VIDEO_KMSDRM_SCALING_SHARPNESS"
/* Enables/disables downscaling when using
* the IPU hardware scaler */
bool dingux_ipu_set_downscaling_enable(bool enable)
{
#if defined(DINGUX_BETA)
return true;
#else
const char *path = DINGUX_ALLOW_DOWNSCALING_FILE;
const char *enable_str = enable ? "1" : "0";
@ -41,40 +51,60 @@ bool dingux_ipu_set_downscaling_enable(bool enable)
/* Write enable state to file */
return filestream_write_file(
path, enable_str, 1);
#endif
}
/* Enables/disables aspect ratio correction
* (1:1 PAR) when using the IPU hardware
* scaler (disabling this will stretch the
* image to the full screen dimensions) */
bool dingux_ipu_set_aspect_ratio_enable(bool enable)
/* Sets the video scaling mode when using the
* IPU hardware scaler
* - keep_aspect: When 'true', aspect ratio correction
* (1:1 PAR) is applied. When 'false', image is
* stretched to full screen dimensions
* - integer_scale: When 'true', enables integer
* scaling. This implicitly sets keep_aspect to
* 'true' (since integer scaling is by definition
* 1:1 PAR)
* Note: OpenDingux stock firmware allows keep_aspect
* and integer_scale to be set independently, hence
* separate boolean values. OpenDingux beta properly
* groups the settings into a single scaling type
* parameter. When supporting both firmwares, it would
* be cleaner to refactor this function to accept one
* enum rather than 2 booleans - but this would break
* users' existing configs, so we maintain the old
* format... */
bool dingux_ipu_set_scaling_mode(bool keep_aspect, bool integer_scale)
{
const char *path = DINGUX_KEEP_ASPECT_RATIO_FILE;
const char *enable_str = enable ? "1" : "0";
#if defined(DINGUX_BETA)
const char *scaling_str = "0";
/* Check whether file exists */
if (!path_is_valid(path))
return false;
/* integer_scale takes priority */
if (integer_scale)
scaling_str = "2";
else if (keep_aspect)
scaling_str = "1";
/* Write enable state to file */
return filestream_write_file(
path, enable_str, 1);
}
return (setenv(DINGUX_SCALING_MODE_ENVAR, scaling_str, 1) == 0);
#else
const char *keep_aspect_path = DINGUX_KEEP_ASPECT_RATIO_FILE;
const char *keep_aspect_str = keep_aspect ? "1" : "0";
bool keep_aspect_success = false;
/* Enables/disables integer scaling when
* using the IPU hardware scaler */
bool dingux_ipu_set_integer_scaling_enable(bool enable)
{
const char *path = DINGUX_INTEGER_SCALING_FILE;
const char *enable_str = enable ? "1" : "0";
const char *integer_scale_path = DINGUX_INTEGER_SCALING_FILE;
const char *integer_scale_str = integer_scale ? "1" : "0";
bool integer_scale_success = false;
/* Check whether file exists */
if (!path_is_valid(path))
return false;
/* Set keep_aspect */
if (path_is_valid(keep_aspect_path))
keep_aspect_success = filestream_write_file(
keep_aspect_path, keep_aspect_str, 1);
/* Write enable state to file */
return filestream_write_file(
path, enable_str, 1);
/* Set integer_scale */
if (path_is_valid(integer_scale_path))
integer_scale_success = filestream_write_file(
integer_scale_path, integer_scale_str, 1);
return (keep_aspect_success && integer_scale_success);
#endif
}
/* Sets the image filtering method when
@ -88,11 +118,13 @@ bool dingux_ipu_set_filter_type(enum dingux_ipu_filter_type filter_type)
* factor of -0.25..-4.0 internally)
* Default bicubic sharpness factor is
* (-0.125 * 8) = -1.0 */
#if !defined(DINGUX_BETA)
const char *upscaling_path = DINGUX_SHARPNESS_UPSCALING_FILE;
const char *downscaling_path = DINGUX_SHARPNESS_DOWNSCALING_FILE;
const char *sharpness_str = "8";
bool upscaling_success = false;
bool downscaling_success = false;
#endif
const char *sharpness_str = "8";
/* Check filter type */
switch (filter_type)
@ -109,21 +141,35 @@ bool dingux_ipu_set_filter_type(enum dingux_ipu_filter_type filter_type)
break;
}
#if defined(DINGUX_BETA)
return (setenv(DINGUX_SCALING_SHARPNESS_ENVAR, sharpness_str, 1) == 0);
#else
/* Set upscaling sharpness */
if (path_is_valid(upscaling_path))
upscaling_success = filestream_write_file(
upscaling_path, sharpness_str, 1);
else
upscaling_success = false;
/* Set downscaling sharpness */
if (path_is_valid(downscaling_path))
downscaling_success = filestream_write_file(
downscaling_path, sharpness_str, 1);
else
downscaling_success = false;
return (upscaling_success && downscaling_success);
#endif
}
/* Resets the IPU hardware scaler to the
* default configuration */
bool dingux_ipu_reset(void)
{
#if defined(DINGUX_BETA)
unsetenv(DINGUX_SCALING_MODE_ENVAR);
unsetenv(DINGUX_SCALING_SHARPNESS_ENVAR);
return true;
#else
return dingux_ipu_set_scaling_mode(true, false) &&
dingux_ipu_set_filter_type(DINGUX_IPU_FILTER_BICUBIC);
#endif
}
/* Fetches internal battery level */

View File

@ -42,20 +42,34 @@ enum dingux_ipu_filter_type
* the IPU hardware scaler */
bool dingux_ipu_set_downscaling_enable(bool enable);
/* Enables/disables aspect ratio correction
* (1:1 PAR) when using the IPU hardware
* scaler (disabling this will stretch the
* image to the full screen dimensions) */
bool dingux_ipu_set_aspect_ratio_enable(bool enable);
/* Enables/disables integer scaling when
* using the IPU hardware scaler */
bool dingux_ipu_set_integer_scaling_enable(bool enable);
/* Sets the video scaling mode when using the
* IPU hardware scaler
* - keep_aspect: When 'true', aspect ratio correction
* (1:1 PAR) is applied. When 'false', image is
* stretched to full screen dimensions
* - integer_scale: When 'true', enables integer
* scaling. This implicitly sets keep_aspect to
* 'true' (since integer scaling is by definition
* 1:1 PAR)
* Note: OpenDingux stock firmware allows keep_aspect
* and integer_scale to be set independently, hence
* separate boolean values. OpenDingux beta properly
* groups the settings into a single scaling type
* parameter. When supporting both firmwares, it would
* be cleaner to refactor this function to accept one
* enum rather than 2 booleans - but this would break
* users' existing configs, so we maintain the old
* format... */
bool dingux_ipu_set_scaling_mode(bool keep_aspect, bool integer_scale);
/* Sets the image filtering method when
* using the IPU hardware scaler */
bool dingux_ipu_set_filter_type(enum dingux_ipu_filter_type filter_type);
/* Resets the IPU hardware scaler to the
* default configuration */
bool dingux_ipu_reset(void);
/* Fetches internal battery level */
int dingux_get_battery_level(void);

View File

@ -25,7 +25,6 @@
#include "sdl2_common.h"
#include "../../retroarch.h"
#ifdef HAVE_SDL2
#include "SDL.h"
#include "SDL_syswm.h"
@ -77,5 +76,3 @@ void sdl2_set_handles(void *data, enum rarch_display_type display_type)
break;
}
}
#endif

View File

@ -19,7 +19,47 @@
#include <stdint.h>
#include <boolean.h>
#include "SDL.h"
#include "../video_defines.h"
#include "../font_driver.h"
#include "../../retroarch.h"
typedef struct sdl2_tex
{
SDL_Texture *tex;
unsigned w;
unsigned h;
size_t pitch;
bool active;
bool rgb32;
} sdl2_tex_t;
typedef struct _sdl2_video
{
bool gl;
bool quitting;
bool should_resize;
uint8_t font_r;
uint8_t font_g;
uint8_t font_b;
double rotation;
struct video_viewport vp;
video_info_t video;
sdl2_tex_t frame;
sdl2_tex_t menu;
sdl2_tex_t font;
SDL_Window *window;
SDL_Renderer *renderer;
void *font_data;
const font_renderer_driver_t *font_driver;
} sdl2_video_t;
void sdl2_set_handles(void *data, enum rarch_display_type
display_type);

View File

@ -35,10 +35,7 @@
#include "SDL.h"
#include "SDL_syswm.h"
#ifdef HAVE_SDL2
#include "../common/sdl2_common.h"
#endif
#include "../font_driver.h"
@ -46,42 +43,6 @@
#include "../../retroarch.h"
#include "../../verbosity.h"
typedef struct sdl2_tex
{
SDL_Texture *tex;
unsigned w;
unsigned h;
size_t pitch;
bool active;
bool rgb32;
} sdl2_tex_t;
typedef struct _sdl2_video
{
bool gl;
bool quitting;
bool should_resize;
uint8_t font_r;
uint8_t font_g;
uint8_t font_b;
double rotation;
struct video_viewport vp;
video_info_t video;
sdl2_tex_t frame;
sdl2_tex_t menu;
sdl2_tex_t font;
SDL_Window *window;
SDL_Renderer *renderer;
void *font_data;
const font_renderer_driver_t *font_driver;
} sdl2_video_t;
static void sdl2_gfx_free(void *data);
static INLINE void sdl_tex_zero(sdl2_tex_t *t)
@ -358,7 +319,12 @@ static void sdl_refresh_input_size(sdl2_video_t *vid, bool menu, bool rgb32,
target->h = height;
target->pitch = pitch;
target->rgb32 = rgb32;
target->active = true;
/* If target is menu, do not override 'active'
* state (this should only be set by
* sdl2_poke_texture_enable()) */
if (!menu)
target->active = true;
}
}
@ -367,23 +333,28 @@ static void *sdl2_gfx_init(const video_info_t *video,
{
int i;
unsigned flags;
sdl2_video_t *vid = NULL;
settings_t *settings = config_get_ptr();
sdl2_video_t *vid = NULL;
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
settings_t *settings = config_get_ptr();
#if defined(HAVE_X11) || defined(HAVE_WAYLAND)
const char *video_driver = NULL;
const char *video_driver = NULL;
#endif
#ifdef HAVE_X11
XInitThreads();
#endif
if (SDL_WasInit(0) == 0)
/* Initialise graphics subsystem, if required */
if (sdl_subsystem_flags == 0)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return NULL;
}
else if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
return NULL;
else if ((sdl_subsystem_flags & SDL_INIT_VIDEO) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
return NULL;
}
vid = (sdl2_video_t*)calloc(1, sizeof(*vid));
if (!vid)
@ -603,8 +574,6 @@ static void sdl2_gfx_free(void *data)
if (vid->window)
SDL_DestroyWindow(vid->window);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
if (vid->font_data)
vid->font_driver->free(vid->font_data);

View File

@ -307,19 +307,18 @@ static void sdl_dingux_gfx_free(void *data)
if (!vid)
return;
SDL_QuitSubSystem(SDL_INIT_VIDEO);
/* It is good manners to leave IPU scaling
* parameters in the default state when
* shutting down */
if (!vid->keep_aspect)
dingux_ipu_set_aspect_ratio_enable(true);
if (vid->integer_scaling)
dingux_ipu_set_integer_scaling_enable(false);
#if defined(DINGUX_BETA)
dingux_ipu_reset();
#else
if (!vid->keep_aspect || vid->integer_scaling)
dingux_ipu_set_scaling_mode(true, false);
if (vid->filter_type != DINGUX_IPU_FILTER_BICUBIC)
dingux_ipu_set_filter_type(DINGUX_IPU_FILTER_BICUBIC);
#endif
if (vid->osd_font)
bitmapfont_free_lut(vid->osd_font);
@ -343,7 +342,6 @@ static void sdl_dingux_input_driver_init(
if (string_is_empty(input_driver_name))
return;
#if defined(HAVE_SDL_DINGUX)
if (string_is_equal(input_driver_name, "sdl_dingux"))
{
*input_data = input_driver_init_wrap(&input_sdl_dingux,
@ -354,7 +352,6 @@ static void sdl_dingux_input_driver_init(
return;
}
#endif
#if defined(HAVE_SDL) || defined(HAVE_SDL2)
if (string_is_equal(input_driver_name, "sdl"))
@ -400,6 +397,7 @@ static void *sdl_dingux_gfx_init(const video_info_t *video,
input_driver_t **input, void **input_data)
{
sdl_dingux_video_t *vid = NULL;
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
settings_t *settings = config_get_ptr();
bool ipu_keep_aspect = settings->bools.video_dingux_ipu_keep_aspect;
bool ipu_integer_scaling = settings->bools.video_scale_integer;
@ -411,23 +409,26 @@ static void *sdl_dingux_gfx_init(const video_info_t *video,
(SDL_HWSURFACE | SDL_TRIPLEBUF | SDL_FULLSCREEN) :
(SDL_HWSURFACE | SDL_FULLSCREEN);
dingux_ipu_set_downscaling_enable(true);
dingux_ipu_set_aspect_ratio_enable(ipu_keep_aspect);
dingux_ipu_set_integer_scaling_enable(ipu_integer_scaling);
dingux_ipu_set_filter_type(ipu_filter_type);
if (SDL_WasInit(0) == 0)
/* Initialise graphics subsystem, if required */
if (sdl_subsystem_flags == 0)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return NULL;
}
else if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
return NULL;
else if ((sdl_subsystem_flags & SDL_INIT_VIDEO) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
return NULL;
}
vid = (sdl_dingux_video_t*)calloc(1, sizeof(*vid));
if (!vid)
return NULL;
dingux_ipu_set_downscaling_enable(true);
dingux_ipu_set_scaling_mode(ipu_keep_aspect, ipu_integer_scaling);
dingux_ipu_set_filter_type(ipu_filter_type);
vid->screen = SDL_SetVideoMode(
SDL_DINGUX_MENU_WIDTH, SDL_DINGUX_MENU_HEIGHT,
video->rgb32 ? 32 : 16,
@ -506,14 +507,18 @@ static void sdl_dingux_set_output(
/* We must have a valid SDL surface
* > Use known good fallback display mode
* (i.e. menu resolution)
* > We do not check for success here, because
* this cannot fail - and if it did, there is
* nothing we can do about it anyway... */
* > Other than logging a message, we do not
* handle errors here, because this cannot
* fail - and if it did, there is nothing
* we can do about it anyway... */
vid->screen = SDL_SetVideoMode(
SDL_DINGUX_MENU_WIDTH, SDL_DINGUX_MENU_HEIGHT,
rgb32 ? 32 : 16,
surface_flags);
if (unlikely(!vid->screen))
RARCH_ERR("[SDL1]: Critical - Failed to init fallback SDL surface: %s\n", SDL_GetError());
vid->frame_padding = 0;
vid->mode_valid = false;
}
@ -618,7 +623,7 @@ static bool sdl_dingux_gfx_frame(void *data, const void *frame,
{
sdl_dingux_video_t* vid = (sdl_dingux_video_t*)data;
if (unlikely(!frame))
if (unlikely(!vid || !frame))
return true;
/* If fast forward is currently active, we may
@ -723,10 +728,11 @@ static bool sdl_dingux_gfx_frame(void *data, const void *frame,
static void sdl_dingux_set_texture_enable(void *data, bool state, bool full_screen)
{
sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data;
(void)full_screen;
if (vid->menu_active != state)
vid->menu_active = state;
if (unlikely(!vid))
return;
vid->menu_active = state;
}
static void sdl_dingux_set_texture_frame(void *data, const void *frame, bool rgb32,
@ -735,6 +741,7 @@ static void sdl_dingux_set_texture_frame(void *data, const void *frame, bool rgb
sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data;
if (unlikely(
!vid ||
rgb32 ||
(width > SDL_DINGUX_MENU_WIDTH) ||
(height > SDL_DINGUX_MENU_HEIGHT)))
@ -808,6 +815,9 @@ static bool sdl_dingux_gfx_alive(void *data)
{
sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data;
if (unlikely(!vid))
return false;
sdl_dingux_gfx_check_window(vid);
return !vid->quitting;
}
@ -831,6 +841,9 @@ static void sdl_dingux_gfx_viewport_info(void *data, struct video_viewport *vp)
{
sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data;
if (unlikely(!vid))
return;
vp->x = 0;
vp->y = 0;
vp->width = vp->full_width = vid->frame_width;
@ -866,17 +879,12 @@ static void sdl_dingux_apply_state_changes(void *data)
if (!vid || !settings)
return;
/* Update 'keep aspect ratio' state, if required */
if (vid->keep_aspect != ipu_keep_aspect)
/* Update IPU scaling mode, if required */
if ((vid->keep_aspect != ipu_keep_aspect) ||
(vid->integer_scaling != ipu_integer_scaling))
{
dingux_ipu_set_aspect_ratio_enable(ipu_keep_aspect);
vid->keep_aspect = ipu_keep_aspect;
}
/* Update integer scaling state, if required */
if (vid->integer_scaling != ipu_integer_scaling)
{
dingux_ipu_set_integer_scaling_enable(ipu_integer_scaling);
dingux_ipu_set_scaling_mode(ipu_keep_aspect, ipu_integer_scaling);
vid->keep_aspect = ipu_keep_aspect;
vid->integer_scaling = ipu_integer_scaling;
}
}

View File

@ -75,8 +75,6 @@ static void sdl_gfx_free(void *data)
if (vid->menu.frame)
SDL_FreeSurface(vid->menu.frame);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
if (vid->font)
vid->font_driver->free(vid->font);
@ -248,6 +246,7 @@ static void *sdl_gfx_init(const video_info_t *video,
const SDL_VideoInfo *video_info = NULL;
sdl_video_t *vid = NULL;
settings_t *settings = config_get_ptr();
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
const char *path_font = settings->paths.path_font;
float video_font_size = settings->floats.video_font_size;
bool video_font_enable = settings->bools.video_font_enable;
@ -259,13 +258,17 @@ static void *sdl_gfx_init(const video_info_t *video,
XInitThreads();
#endif
if (SDL_WasInit(0) == 0)
/* Initialise graphics subsystem, if required */
if (sdl_subsystem_flags == 0)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return NULL;
}
else if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
return NULL;
else if ((sdl_subsystem_flags & SDL_INIT_VIDEO) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
return NULL;
}
vid = (sdl_video_t*)calloc(1, sizeof(*vid));
if (!vid)

View File

@ -71,14 +71,13 @@ static void sdl_ctx_destroy_resources(gfx_ctx_sdl_data_t *sdl)
SDL_FreeSurface(sdl->win);
#endif
sdl->win = NULL;
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
static void *sdl_ctx_init(void *video_driver)
{
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)
gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)
calloc(1, sizeof(gfx_ctx_sdl_data_t));
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
if (!sdl)
return NULL;
@ -87,13 +86,17 @@ static void *sdl_ctx_init(void *video_driver)
XInitThreads();
#endif
if (SDL_WasInit(0) == 0)
/* Initialise graphics subsystem, if required */
if (sdl_subsystem_flags == 0)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
goto error;
}
else if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
goto error;
else if ((sdl_subsystem_flags & SDL_INIT_VIDEO) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
goto error;
}
RARCH_LOG("[SDL_GL] SDL %i.%i.%i gfx context driver initialized.\n",
SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);

View File

@ -31,6 +31,10 @@
#include "../../verbosity.h"
#include "../../tasks/tasks_internal.h"
#ifdef HAVE_SDL2
#include "../../gfx/common/sdl2_common.h"
#endif
/* TODO/FIXME -
* fix game focus toggle */
@ -278,17 +282,17 @@ static void sdl_input_free(void *data)
#ifdef HAVE_SDL2
static void sdl2_grab_mouse(void *data, bool state)
{
struct temp
{
SDL_Window *w;
};
sdl2_video_t *video_ptr = NULL;
if (string_is_not_equal(video_driver_get_ident(), "sdl2"))
return;
/* First member of sdl2_video_t is the window */
SDL_SetWindowGrab(((struct temp*)video_driver_get_ptr())->w,
state ? SDL_TRUE : SDL_FALSE);
video_ptr = (sdl2_video_t*)video_driver_get_ptr();
if (!video_ptr)
return;
SDL_SetWindowGrab(video_ptr->window, state ? SDL_TRUE : SDL_FALSE);
}
#endif

View File

@ -321,9 +321,6 @@ static void sdl_dingux_joypad_destroy(void)
/* Disconnect joypad */
sdl_dingux_joypad_disconnect();
/* De-initialise joystick subsystem */
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
/* Flush out all pending events */
while (SDL_PollEvent(&event));
@ -337,19 +334,23 @@ static void sdl_dingux_joypad_destroy(void)
static void *sdl_dingux_joypad_init(void *data)
{
dingux_joypad_t *joypad = (dingux_joypad_t*)&dingux_joypad;
dingux_joypad_t *joypad = (dingux_joypad_t*)&dingux_joypad;
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
memset(joypad, 0, sizeof(dingux_joypad_t));
BIT64_CLEAR(lifecycle_state, RARCH_MENU_TOGGLE);
/* Initialise joystick subsystem */
if (SDL_WasInit(0) == 0)
/* Initialise joystick subsystem, if required */
if (sdl_subsystem_flags == 0)
{
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
return NULL;
}
else if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
return NULL;
else if ((sdl_subsystem_flags & SDL_INIT_JOYSTICK) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
return NULL;
}
#if defined(HAVE_LIBSHAKE)
/* Initialise rumble interface */

View File

@ -236,15 +236,9 @@ static void sdl_pad_disconnect(unsigned id)
static void sdl_joypad_destroy(void)
{
unsigned i;
#ifdef HAVE_SDL2
int subsystem = SDL_INIT_GAMECONTROLLER;
#else
int subsystem = SDL_INIT_JOYSTICK;
#endif
for (i = 0; i < MAX_USERS; i++)
sdl_pad_disconnect(i);
SDL_QuitSubSystem(subsystem);
memset(sdl_pads, 0, sizeof(sdl_pads));
}
@ -252,24 +246,36 @@ static void *sdl_joypad_init(void *data)
{
unsigned i, num_sticks;
#ifdef HAVE_SDL2
int subsystem = SDL_INIT_GAMECONTROLLER;
uint32_t subsystem = SDL_INIT_GAMECONTROLLER;
#else
int subsystem = SDL_INIT_JOYSTICK;
uint32_t subsystem = SDL_INIT_JOYSTICK;
#endif
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
if (SDL_WasInit(0) == 0)
/* Initialise joystick/controller subsystem, if required */
if (sdl_subsystem_flags == 0)
{
if (SDL_Init(subsystem) < 0)
return NULL;
}
else if (SDL_InitSubSystem(subsystem) < 0)
return NULL;
else if ((sdl_subsystem_flags & subsystem) == 0)
{
if (SDL_InitSubSystem(subsystem) < 0)
return NULL;
}
#if HAVE_SDL2
g_has_haptic = false;
if (SDL_InitSubSystem(SDL_INIT_HAPTIC) < 0)
RARCH_WARN("[SDL]: Failed to initialize haptic device support: %s\n",
SDL_GetError());
/* Initialise haptic subsystem, if required */
if ((sdl_subsystem_flags & SDL_INIT_HAPTIC) == 0)
{
if (SDL_InitSubSystem(SDL_INIT_HAPTIC) < 0)
RARCH_WARN("[SDL]: Failed to initialize haptic device support: %s\n",
SDL_GetError());
else
g_has_haptic = true;
}
else
g_has_haptic = true;
#endif

View File

@ -269,6 +269,10 @@
#include "input/input_osk_utf8_pages.h"
#endif
#if defined(HAVE_SDL) || defined(HAVE_SDL2) || defined(HAVE_SDL_DINGUX)
#include "SDL.h"
#endif
/* RetroArch global state / macros */
#include "retroarch_data.h"
/* Forward declarations */
@ -15337,6 +15341,21 @@ static void global_free(struct rarch_state *p_rarch)
retroarch_override_setting_free_state();
}
#if defined(HAVE_SDL) || defined(HAVE_SDL2) || defined(HAVE_SDL_DINGUX)
static void sdl_exit(void)
{
/* Quit any SDL subsystems, then quit
* SDL itself */
uint32_t sdl_subsystem_flags = SDL_WasInit(0);
if (sdl_subsystem_flags != 0)
{
SDL_QuitSubSystem(sdl_subsystem_flags);
SDL_Quit();
}
}
#endif
/**
* main_exit:
*
@ -15422,6 +15441,10 @@ void main_exit(void *args)
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
CoUninitialize();
#endif
#if defined(HAVE_SDL) || defined(HAVE_SDL2) || defined(HAVE_SDL_DINGUX)
sdl_exit();
#endif
}
/**