1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Merge pull request #11403 from jdgleaver/dingux-integer-scaling

OpenDingux: Enable integer scaling when using the 'sdl_dingux' gfx driver
This commit is contained in:
Autechre 2020-10-02 18:10:05 +02:00 committed by GitHub
commit 8379a0b40c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 6 deletions

View File

@ -22,6 +22,7 @@
#define DINGUX_ALLOW_DOWNSCALING_FILE "/sys/devices/platform/jz-lcd.0/allow_downscaling"
#define DINGUX_KEEP_ASPECT_RATIO_FILE "/sys/devices/platform/jz-lcd.0/keep_aspect_ratio"
#define DINGUX_INTEGER_SCALING_FILE "/sys/devices/platform/jz-lcd.0/integer_scaling"
#define DINGUX_BATTERY_CAPACITY_FILE "/sys/class/power_supply/battery/capacity"
/* Enables/disables downscaling when using
@ -58,6 +59,22 @@ bool dingux_ipu_set_aspect_ratio_enable(bool enable)
path, enable_str, 1);
}
/* Enables/disables integer scaling when
* 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";
/* Check whether file exists */
if (!path_is_valid(path))
return false;
/* Write enable state to file */
return filestream_write_file(
path, enable_str, 1);
}
/* Fetches internal battery level */
int dingux_get_battery_level(void)
{

View File

@ -35,6 +35,10 @@ bool dingux_ipu_set_downscaling_enable(bool enable);
* image to the full screen dimensions) */
bool dingux_ipu_set_aspect_ratio_enable(bool enable);
/* Enables/disables integer scaling when
* when using the IPU hardware scaler */
bool dingux_ipu_set_integer_scaling_enable(bool enable);
/* Fetches internal battery level */
int dingux_get_battery_level(void);

View File

@ -61,6 +61,7 @@ typedef struct sdl_dingux_video
bool font_lut[SDL_DINGUX_NUM_FONT_GLYPHS][FONT_WIDTH * FONT_HEIGHT];
bool rgb32;
bool vsync;
bool integer_scaling;
bool menu_active;
bool was_in_menu;
bool quitting;
@ -268,9 +269,11 @@ static void sdl_dingux_gfx_free(void *data)
SDL_QuitSubSystem(SDL_INIT_VIDEO);
/* It is good manners to leave IPU aspect
* ratio scaling enabled when shutting down */
/* It is good manners to leave IPU scaling
* parameters in the default state when
* shutting down */
dingux_ipu_set_aspect_ratio_enable(true);
dingux_ipu_set_integer_scaling_enable(false);
free(vid);
}
@ -281,6 +284,7 @@ static void *sdl_dingux_gfx_init(const video_info_t *video,
sdl_dingux_video_t *vid = NULL;
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;
const char *input_joypad_driver = settings->arrays.input_joypad_driver;
uint32_t surface_flags = (video->vsync) ?
(SDL_HWSURFACE | SDL_TRIPLEBUF | SDL_FULLSCREEN) :
@ -288,6 +292,7 @@ static void *sdl_dingux_gfx_init(const video_info_t *video,
dingux_ipu_set_downscaling_enable(true);
dingux_ipu_set_aspect_ratio_enable(ipu_keep_aspect);
dingux_ipu_set_integer_scaling_enable(ipu_integer_scaling);
if (SDL_WasInit(0) == 0)
{
@ -327,10 +332,11 @@ static void *sdl_dingux_gfx_init(const video_info_t *video,
goto error;
}
vid->vsync = video->vsync;
vid->rgb32 = video->rgb32;
vid->menu_active = false;
vid->was_in_menu = false;
vid->rgb32 = video->rgb32;
vid->vsync = video->vsync;
vid->integer_scaling = ipu_integer_scaling;
vid->menu_active = false;
vid->was_in_menu = false;
SDL_ShowCursor(SDL_DISABLE);
@ -615,6 +621,19 @@ static void sdl_dingux_set_filtering(void *data, unsigned index, bool smooth, bo
static void sdl_dingux_apply_state_changes(void *data)
{
sdl_dingux_video_t *vid = (sdl_dingux_video_t*)data;
settings_t *settings = config_get_ptr();
bool ipu_integer_scaling = (settings) ? settings->bools.video_scale_integer : false;
if (!vid || !settings)
return;
/* Update integer scaling state, if required */
if (vid->integer_scaling != ipu_integer_scaling)
{
dingux_ipu_set_integer_scaling_enable(ipu_integer_scaling);
vid->integer_scaling = ipu_integer_scaling;
}
}
static uint32_t sdl_dingux_get_flags(void *data)

View File

@ -7360,6 +7360,10 @@ unsigned menu_displaylist_build_list(
#if defined(DINGUX)
if (string_is_equal(settings->arrays.video_driver, "sdl_dingux"))
{
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER,
PARSE_ONLY_BOOL, false) == 0)
count++;
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_VIDEO_DINGUX_IPU_KEEP_ASPECT,
PARSE_ONLY_BOOL, false) == 0)