Merge pull request #8268 from alphanu1/master

Update to dynamic width
This commit is contained in:
Twinaphex 2019-02-14 07:05:49 +01:00 committed by GitHub
commit f6afc84885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 31 deletions

View File

@ -116,7 +116,7 @@ static void win32_display_server_destroy(void *data)
if (win32_orig_width > 0 && win32_orig_height > 0)
video_display_server_set_resolution(win32_orig_width, win32_orig_height,
win32_orig_refresh, (float)win32_orig_refresh, crt_center, 0);
win32_orig_refresh, (float)win32_orig_refresh, crt_center, 0, 0);
#ifdef HAS_TASKBAR_EXT
if (g_taskbarList)
@ -210,7 +210,7 @@ static bool win32_display_server_set_window_decorations(void *data, bool on)
}
static bool win32_display_server_set_resolution(void *data,
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index)
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset)
{
DEVMODE curDevmode;
int iModeNum;

View File

@ -44,7 +44,9 @@ static char new_mode[250] = {0};
static char xrandr[250] = {0};
static char fbset[150] = {0};
static char output[500] = {0};
static char output4[500] = {0};
static char output4[500] = {0};
static char crt_name[10] = {0};
static int crt_name_id = 0;
static bool crt_en = false;
static unsigned crtid = 20;
static XRRModeInfo crt_rrmode;
@ -127,7 +129,7 @@ static bool x11_display_server_set_window_decorations(void *data, bool on)
}
static bool x11_display_server_set_resolution(void *data,
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index)
unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset)
{
int screen;
Window window;
@ -150,6 +152,9 @@ static bool x11_display_server_set_resolution(void *data,
float pixel_clock = 0;
crt_en = true;
crt_name_id += 1;
snprintf(crt_name, sizeof(crt_name), "CRT%d", crt_name_id);
snprintf(old_mode, sizeof(old_mode), "%s", new_mode);
@ -161,8 +166,6 @@ static bool x11_display_server_set_resolution(void *data,
video_monitor_set_refresh_rate(hz);
/* following code is the mode line generator */
hsp = (width * 1.140) + x_offset;
hfp = width * 1.055;
pwidth = width;
if (height < 400 && width > 400)
@ -179,7 +182,18 @@ static bool x11_display_server_set_resolution(void *data,
if (roundw < 1.20)
roundw = 1.34;
hbp = width * roundw - 8;
if (width < 700)
{
hfp = width * 1.055;
hbp = width * roundw - 8;
}else {
hfp = (width * 1.055) + (width / 40);
hbp = (width * roundw) + (width /24);
xoffset = xoffset*2;
}
hsp = (width * 1.140) - (xoffset*4);
hmax = hbp;
if (height < 241)
@ -228,20 +242,20 @@ static bool x11_display_server_set_resolution(void *data,
/* create interlaced newmode from modline variables */
if (height < 300)
{
snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"CRT_%dx%d_%0.2f\" %f %d %d %d %d %d %d %d %d -hsync -vsync", width, height, hz, pixel_clock,
snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"%s_%dx%d_%0.2f\" %f %d %d %d %d %d %d %d %d -hsync -vsync",crt_name, width, height, hz, pixel_clock,
width, hfp, hsp, hbp, height, vfp, vsp, vbp);
system(xrandr);
}
/* create interlaced newmode from modline variables */
if (height > 300)
{
snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"CRT_%dx%d_%0.2f\" %f %d %d %d %d %d %d %d %d interlace -hsync -vsync", width, height, hz, pixel_clock,
snprintf(xrandr, sizeof(xrandr), "xrandr --newmode \"%s_%dx%d_%0.2f\" %f %d %d %d %d %d %d %d %d interlace -hsync -vsync",crt_name, width, height, hz, pixel_clock,
width, hfp, hsp, hbp, height, vfp, vsp, vbp);
system(xrandr);
}
/* variable for new mode */
snprintf(new_mode, sizeof(new_mode), "CRT_%dx%d_%0.2f", width, height, hz);
snprintf(new_mode, sizeof(new_mode), "%s_%dx%d_%0.2f",crt_name, width, height, hz);
/* need to run loops for DVI0 - DVI-2 and VGA0 - VGA-2 outputs to
* add and delete modes */

View File

@ -41,6 +41,8 @@ static unsigned ra_set_core_hz = 0;
static unsigned orig_width = 0;
static unsigned orig_height = 0;
static int crt_center_adjust = 0;
static int crt_tmp_center_adjust = 0;
static double p_clock = 0;
static bool first_run = true;
@ -97,7 +99,7 @@ void crt_aspect_ratio_switch(unsigned width, unsigned height)
static void switch_res_crt(unsigned width, unsigned height)
{
video_display_server_set_resolution(width, height,
ra_set_core_hz, ra_core_hz, crt_center_adjust, crt_index);
ra_set_core_hz, ra_core_hz, crt_center_adjust, crt_index, crt_center_adjust);
#if defined(HAVE_VIDEOCORE)
crt_rpi_switch(width, height, ra_core_hz);
video_monitor_set_refresh_rate(ra_core_hz);
@ -181,13 +183,19 @@ void crt_switch_res_core(unsigned width, unsigned height,
{
/* ra_core_hz float passed from within
* void video_driver_monitor_adjust_system_rates(void) */
if (width == 4 )
{
width = 320;
height = 240;
}
ra_core_width = width;
ra_core_height = height;
ra_core_hz = hz;
if (dynamic == true)
ra_core_width = crt_compute_dynamic_width(width);
else
ra_core_width = width;
crt_center_adjust = crt_switch_center_adjust;
crt_index = monitor_index;
@ -206,12 +214,13 @@ void crt_switch_res_core(unsigned width, unsigned height,
/* Detect resolution change and switch */
if (
(ra_tmp_height != ra_core_height) ||
(ra_core_width != ra_tmp_width)
(ra_core_width != ra_tmp_width) || (crt_center_adjust != crt_tmp_center_adjust)
)
crt_screen_setup_aspect(width, height);
crt_screen_setup_aspect(ra_core_width, ra_core_height);
ra_tmp_height = ra_core_height;
ra_tmp_width = ra_core_width;
crt_tmp_center_adjust = crt_center_adjust;
/* Check if aspect is correct, if not change */
if (video_driver_get_aspect_ratio() != fly_aspect)
@ -231,19 +240,24 @@ void crt_video_restore(void)
int crt_compute_dynamic_width(int width)
{
unsigned i;
double p_clock = 18000000;
p_clock = 15000000;
int min_height = 261;
int dynamic_width = 0;
#if defined(HAVE_VIDEOCORE)
double p_clock = 32000000;
p_clock = 32000000;
#endif
for (i =1; i < 10; i++)
for (int i =0; i < 10; i++)
{
dynamic_width = (width*0.5)*i;
dynamic_width = (width*1.5)*i;
if ((dynamic_width * min_height * ra_core_hz) > p_clock)
break;
}
return dynamic_width;
}
@ -297,7 +311,7 @@ static void crt_rpi_switch(int width, int height, float hz)
roundw = 1.34;
hfp = width * 0.065;
hsp = width * 0.1433-hfp;
hsp = width * 0.1433-hfp+(crt_center_adjust*4);
hbp = width * 0.3-hsp-hfp;

View File

@ -90,10 +90,10 @@ 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 int_hz, float hz, int center, int monitor_index, int xoffset)
{
if (current_display_server && current_display_server->set_resolution)
return current_display_server->set_resolution(current_display_server_data, width, height, int_hz, hz, center, monitor_index);
return current_display_server->set_resolution(current_display_server_data, width, height, int_hz, hz, center, monitor_index, xoffset);
return false;
}

View File

@ -41,7 +41,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);
unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset);
void *(*get_resolution_list)(void *data,
unsigned *size);
const char *(*get_output_options)(void *data);
@ -60,7 +60,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 int_hz, float hz, int center, int monitor_index, int xoffset);
void *video_display_server_get_resolution_list(unsigned *size);

View File

@ -2648,11 +2648,12 @@ void video_driver_frame(const void *data, unsigned width,
width = 3840;
if (video_info.crt_switch_resolution_super == 1920)
width = 1920;
if (video_info.crt_switch_resolution_super == 1)
video_driver_crt_dynamic_super_width = true;
else
video_driver_crt_dynamic_super_width = false;
crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust, video_info.monitor_index, video_driver_crt_dynamic_super_width);
}
else if (!video_info.crt_switch_resolution)

View File

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

View File

@ -1268,11 +1268,7 @@ static void setting_get_string_representation_crt_switch_resolution_super(
if (*setting->value.target.unsigned_integer == 0)
strlcpy(s, "NATIVE", len);
else
snprintf(s, len, "%d", *setting->value.target.unsigned_integer);
/* TO DO make 1 read as DYNAMIC */
if (*setting->value.target.unsigned_integer == 1)
else if (*setting->value.target.unsigned_integer == 1)
strlcpy(s, "DYNAMIC", len);
else
snprintf(s, len, "%d", *setting->value.target.unsigned_integer);