Merge pull request #11093 from alphanu1/master

On the fly CRT porch adjuments
This commit is contained in:
Autechre 2020-07-28 20:09:58 +02:00 committed by GitHub
commit 0f9f46f499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 62 additions and 12 deletions

View File

@ -133,6 +133,8 @@
#define DEFAULT_CRT_SWITCH_CENTER_ADJUST 0
#define DEFAULT_CRT_SWITCH_PORCH_ADJUST 0
#define DEFAULT_HISTORY_LIST_ENABLE true
#define DEFAULT_PLAYLIST_ENTRY_RENAME true

View File

@ -2023,6 +2023,7 @@ static struct config_int_setting *populate_settings_int(
SETTING_INT("audio_wasapi_sh_buffer_length", &settings->ints.audio_wasapi_sh_buffer_length, true, DEFAULT_WASAPI_SH_BUFFER_LENGTH, false);
#endif
SETTING_INT("crt_switch_center_adjust", &settings->ints.crt_switch_center_adjust, false, DEFAULT_CRT_SWITCH_CENTER_ADJUST, false);
SETTING_INT("crt_switch_porch_adjust", &settings->ints.crt_switch_porch_adjust, false, DEFAULT_CRT_SWITCH_PORCH_ADJUST, false);
#ifdef HAVE_VULKAN
SETTING_INT("vulkan_gpu_index", &settings->ints.vulkan_gpu_index, true, DEFAULT_VULKAN_GPU_INDEX, false);
#endif

View File

@ -473,6 +473,7 @@ typedef struct settings
int state_slot;
int audio_wasapi_sh_buffer_length;
int crt_switch_center_adjust;
int crt_switch_porch_adjust;
#ifdef HAVE_VULKAN
int vulkan_gpu_index;
#endif

View File

@ -165,7 +165,7 @@ static bool x11_display_server_set_window_decorations(void *data, bool on)
#ifdef HAVE_XRANDR
static bool x11_display_server_set_resolution(void *data,
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset)
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust)
{
int screen;
Window window;
@ -201,11 +201,11 @@ static bool x11_display_server_set_resolution(void *data,
/* following code is the mode line generator */
if (width < 700)
{
hfp = (width * 1.033);
hbp = width * 1.225;
hfp = (width * 1.033)+(padjust*2);
hbp = (width * 1.225)+(padjust*2);
}else {
hfp = (width * 1.033) + (width / 112);
hbp = (width * 1.225) + (width /58);
hfp = ((width * 1.033) + (width / 112))+(padjust*4);
hbp = ((width * 1.225) + (width /58))+(padjust*4);
xoffset = xoffset*2;
}

View File

@ -81,7 +81,8 @@ static void switch_res_crt(
p_switch->ra_core_hz,
p_switch->center_adjust,
p_switch->index,
p_switch->center_adjust);
p_switch->center_adjust,
p_switch->porch_adjust);
#if defined(HAVE_VIDEOCORE)
crt_rpi_switch(width, height,
@ -196,6 +197,7 @@ void crt_switch_res_core(
unsigned width, unsigned height,
float hz, unsigned crt_mode,
int crt_switch_center_adjust,
int crt_switch_porch_adjust,
int monitor_index, bool dynamic)
{
/* ra_core_hz float passed from within
@ -206,6 +208,7 @@ void crt_switch_res_core(
height = 240;
}
p_switch->porch_adjust = crt_switch_porch_adjust;
p_switch->ra_core_height = height;
p_switch->ra_core_hz = hz;
@ -229,7 +232,8 @@ void crt_switch_res_core(
if (
(p_switch->ra_tmp_height != p_switch->ra_core_height) ||
(p_switch->ra_core_width != p_switch->ra_tmp_width) ||
(p_switch->center_adjust != p_switch->tmp_center_adjust)
(p_switch->center_adjust != p_switch->tmp_center_adjust||
p_switch->porch_adjust != p_switch->tmp_porch_adjust )
)
crt_screen_setup_aspect(
p_switch,
@ -239,6 +243,7 @@ void crt_switch_res_core(
p_switch->ra_tmp_height = p_switch->ra_core_height;
p_switch->ra_tmp_width = p_switch->ra_core_width;
p_switch->tmp_center_adjust = p_switch->center_adjust;
p_switch->tmp_porch_adjust = p_switch->porch_adjust;
/* Check if aspect is correct, if not change */
if (video_driver_get_aspect_ratio() != p_switch->fly_aspect)

View File

@ -30,6 +30,8 @@ RETRO_BEGIN_DECLS
typedef struct videocrt_switch
{
int center_adjust;
int porch_adjust;
int tmp_porch_adjust;
int tmp_center_adjust;
unsigned ra_core_width;
unsigned ra_core_height;
@ -52,6 +54,7 @@ void crt_switch_res_core(
float hz,
unsigned crt_mode,
int crt_switch_center_adjust,
int crt_switch_porch_adjust,
int monitor_index,
bool dynamic);

View File

@ -49,7 +49,7 @@ typedef struct video_display_server
bool (*set_window_progress)(void *data, int progress, bool finished);
bool (*set_window_decorations)(void *data, bool on);
bool (*set_resolution)(void *data, unsigned width,
unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset);
unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust );
void *(*get_resolution_list)(void *data,
unsigned *size);
const char *(*get_output_options)(void *data);
@ -73,7 +73,7 @@ bool video_display_server_set_window_decorations(bool on);
bool video_display_server_set_resolution(
unsigned width, unsigned height,
int int_hz, float hz, int center, int monitor_index, int xoffset);
int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust);
void *video_display_server_get_resolution_list(unsigned *size);

View File

@ -2908,6 +2908,10 @@ MSG_HASH(
MENU_ENUM_LABEL_CRT_SWITCH_X_AXIS_CENTERING,
"crt_switch_center_adjust"
)
MSG_HASH(
MENU_ENUM_LABEL_CRT_SWITCH_PORCH_ADJUST,
"crt_switch_porch_adjust"
)
MSG_HASH(
MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO,
"video_aspect_ratio"

View File

@ -1379,6 +1379,14 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_CRT_SWITCH_X_AXIS_CENTERING,
"Cycle through these options if the image is not centered properly on the display."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_CRT_SWITCH_PORCH_ADJUST,
"Porch Adjust"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_CRT_SWITCH_PORCH_ADJUST,
"Cycle through these options to adjust the porch settings to change the image size."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE,
"Use Custom Refresh Rate"

View File

@ -5634,7 +5634,7 @@ int action_cb_push_dropdown_item_resolution(const char *path,
refreshrate = (unsigned)strtoul(pch, NULL, 0);
if (video_display_server_set_resolution(width, height,
refreshrate, (float)refreshrate, 0, 0, 0))
refreshrate, (float)refreshrate, 0, 0, 0, 0))
{
settings_t *settings = config_get_ptr();

View File

@ -124,6 +124,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_quick_menu_stop_recording,
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres, MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres_super, MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION_SUPER)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres_x_axis_centering, MENU_ENUM_SUBLABEL_CRT_SWITCH_X_AXIS_CENTERING)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres_porch_adjust, MENU_ENUM_SUBLABEL_CRT_SWITCH_PORCH_ADJUST)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres_use_custom_refresh_rate, MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_driver_settings_list, MENU_ENUM_SUBLABEL_DRIVER_SETTINGS)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_retro_achievements_settings_list, MENU_ENUM_SUBLABEL_RETRO_ACHIEVEMENTS_SETTINGS)
@ -1694,6 +1695,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_CRT_SWITCH_X_AXIS_CENTERING:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_crt_switchres_x_axis_centering);
break;
case MENU_ENUM_LABEL_CRT_SWITCH_PORCH_ADJUST:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_crt_switchres_porch_adjust);
break;
case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_crt_switchres_use_custom_refresh_rate);
break;

View File

@ -7388,6 +7388,7 @@ unsigned menu_displaylist_build_list(
{MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, PARSE_ONLY_UINT},
{MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, PARSE_ONLY_UINT},
{MENU_ENUM_LABEL_CRT_SWITCH_X_AXIS_CENTERING, PARSE_ONLY_INT },
{MENU_ENUM_LABEL_CRT_SWITCH_PORCH_ADJUST, PARSE_ONLY_INT },
{MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE, PARSE_ONLY_BOOL},
};

View File

@ -10840,6 +10840,23 @@ static bool setting_append_list(
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);
menu_settings_list_current_add_range(list, list_info, -3, 4, 1.0, true, true);
CONFIG_INT(
list, list_info,
&settings->ints.crt_switch_porch_adjust,
MENU_ENUM_LABEL_CRT_SWITCH_PORCH_ADJUST,
MENU_ENUM_LABEL_VALUE_CRT_SWITCH_PORCH_ADJUST,
DEFAULT_CRT_SWITCH_PORCH_ADJUST,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_SPINBOX;
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
(*list)[list_info->index - 1].offset_by = 0;
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);
menu_settings_list_current_add_range(list, list_info, -20, 20, 1.0, true, true);
CONFIG_BOOL(
list, list_info,
&settings->bools.crt_switch_custom_refresh_enable,

View File

@ -940,6 +940,7 @@ enum msg_hash_enums
MENU_LABEL(CRT_SWITCH_RESOLUTION_OUTPUT_DISPLAY_ID),
MENU_LABEL(CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE),
MENU_LABEL(CRT_SWITCH_X_AXIS_CENTERING),
MENU_LABEL(CRT_SWITCH_PORCH_ADJUST),
MENU_LABEL(VIDEO_FONT_ENABLE),
MENU_LABEL(VIDEO_FONT_PATH),
MENU_LABEL(VIDEO_FONT_SIZE),

View File

@ -30518,13 +30518,13 @@ bool video_display_server_set_window_decorations(bool on)
}
bool video_display_server_set_resolution(unsigned width, unsigned height,
int int_hz, float hz, int center, int monitor_index, int xoffset)
int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust)
{
struct rarch_state *p_rarch = &rarch_st;
if (current_display_server && current_display_server->set_resolution)
return current_display_server->set_resolution(
p_rarch->current_display_server_data, width, height, int_hz,
hz, center, monitor_index, xoffset);
hz, center, monitor_index, xoffset, padjust);
return false;
}
@ -32833,6 +32833,7 @@ static void video_driver_frame(const void *data, unsigned width,
p_rarch->video_driver_core_hz,
video_info.crt_switch_resolution,
video_info.crt_switch_center_adjust,
video_info.crt_switch_porch_adjust,
video_info.monitor_index,
p_rarch->video_driver_crt_dynamic_super_width);
}
@ -32944,6 +32945,7 @@ void video_driver_build_info(video_frame_info_t *video_info)
video_info->crt_switch_resolution = settings->uints.crt_switch_resolution;
video_info->crt_switch_resolution_super = settings->uints.crt_switch_resolution_super;
video_info->crt_switch_center_adjust = settings->ints.crt_switch_center_adjust;
video_info->crt_switch_porch_adjust = settings->ints.crt_switch_porch_adjust;
video_info->black_frame_insertion = settings->bools.video_black_frame_insertion;
video_info->hard_sync = settings->bools.video_hard_sync;
video_info->hard_sync_frames = settings->uints.video_hard_sync_frames;

View File

@ -1141,6 +1141,7 @@ typedef struct video_frame_info
int custom_vp_x;
int custom_vp_y;
int crt_switch_center_adjust;
int crt_switch_porch_adjust;
unsigned hard_sync_frames;
unsigned aspect_ratio_idx;