RPi Additions new switching method

Partil new switching method
This commit is contained in:
alphanu1 2019-01-30 20:17:32 +00:00 committed by GitHub
parent e533dda94a
commit 76bf63f905
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5671 additions and 5519 deletions

View File

@ -24,6 +24,10 @@
#include "video_crt_switch.h" #include "video_crt_switch.h"
#include "video_display_server.h" #include "video_display_server.h"
#if defined(__arm__)
#include "include/userland/interface/vmcs_host/vc_vchi_gencmd.h"
#endif
static unsigned ra_core_width = 0; static unsigned ra_core_width = 0;
static unsigned ra_core_height = 0; static unsigned ra_core_height = 0;
static unsigned ra_tmp_width = 0; static unsigned ra_tmp_width = 0;
@ -38,6 +42,7 @@ static bool first_run = true;
static float ra_tmp_core_hz = 0.0f; static float ra_tmp_core_hz = 0.0f;
static float fly_aspect = 0.0f; static float fly_aspect = 0.0f;
static float ra_core_hz = 0.0f; static float ra_core_hz = 0.0f;
static unsigned crt_index = 0;
static void crt_check_first_run(void) static void crt_check_first_run(void)
{ {
@ -86,17 +91,23 @@ void crt_aspect_ratio_switch(unsigned width, unsigned height)
static void switch_res_crt(unsigned width, unsigned height) static void switch_res_crt(unsigned width, unsigned height)
{ {
if (height > 100)
{
video_display_server_set_resolution(width, height, video_display_server_set_resolution(width, height,
ra_set_core_hz, ra_core_hz, crt_center_adjust); ra_set_core_hz, ra_core_hz, crt_center_adjust, crt_index);
#if defined(__arm__)
crt_rpi_switch(width, height, ra_core_hz);
video_monitor_set_refresh_rate(ra_core_hz);
crt_switch_driver_reinit();
#endif
video_driver_apply_state_changes(); video_driver_apply_state_changes();
}
} }
/* Create correct aspect to fit video if resolution does not exist */ /* Create correct aspect to fit video if resolution does not exist */
static void crt_screen_setup_aspect(unsigned width, unsigned height) static void crt_screen_setup_aspect(unsigned width, unsigned height)
{ {
#if defined(__arm__)
if (height > 300)
height = height/2;
#endif
switch_crt_hz(); switch_crt_hz();
/* get original resolution of core */ /* get original resolution of core */
@ -167,6 +178,7 @@ void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt
ra_core_height = height; ra_core_height = height;
ra_core_hz = hz; ra_core_hz = hz;
crt_center_adjust = crt_switch_center_adjust; crt_center_adjust = crt_switch_center_adjust;
crt_index = monitor_index;
if (crt_mode == 2) if (crt_mode == 2)
{ {
@ -204,3 +216,136 @@ void crt_video_restore(void)
first_run = true; first_run = true;
} }
#if defined(__arm__)
static void crt_rpi_switch(int width, int height, float hz)
{
static char output[250] = {0};
static char output1[250] = {0};
static char output2[250] = {0};
static char set_hdmi[250] ={0};
static char set_hdmi_timing[250] = {0};
int i = 0;
int hfp = 0;
int hsp = 0;
int hbp = 0;
int vfp = 0;
int vsp = 0;
int vbp = 0;
int hmax = 0;
int vmax = 0;
int pdefault = 8;
int pwidth = 0;
float roundw = 0.0f;
float roundh = 0.0f;
float pixel_clock = 0;
int ip_flag = 0;
/* set core refresh from hz */
video_monitor_set_refresh_rate(hz);
/* following code is the mode line generator */
pwidth = width;
if (height < 400 && width > 400)
pwidth = width / 2;
roundw = roundf((float)pwidth / (float)height * 100) / 100;
if (height > width)
roundw = roundf((float)height / (float)width * 100) / 100;
if (roundw > 1.35)
roundw = 1.25;
if (roundw < 1.20)
roundw = 1.34;
hfp = width * 0.065;
hsp = width * 0.1433-hfp;
hbp = width * 0.3-hsp-hfp;
if (height < 241)
vmax = 261;
if (height < 241 && hz > 56 && hz < 58)
vmax = 280;
if (height < 241 && hz < 55)
vmax = 313;
if (height > 250 && height < 260 && hz > 54)
vmax = 296;
if (height > 250 && height < 260 && hz > 52 && hz < 54)
vmax = 285;
if (height > 250 && height < 260 && hz < 52)
vmax = 313;
if (height > 260 && height < 300)
vmax = 318;
if (height > 400 && hz > 56)
vmax = 533;
if (height > 520 && hz < 57)
vmax = 580;
if (height > 300 && hz < 56)
vmax = 615;
if (height > 500 && hz < 56)
vmax = 624;
if (height > 300)
pdefault = pdefault * 2;
vfp = (height + ((vmax - height) / 2) - pdefault) - height;
if (height < 300)
vsp = vfp + 3; /* needs to be 3 for progressive */
if (height > 300)
vsp = vfp + 6; /* needs to be 6 for interlaced */
vsp = 3;
vbp = (vmax-height)-vsp-vfp;
hmax = width+hfp+hsp+hbp;
if (height < 300)
{
pixel_clock = (hmax * vmax * hz) ;
ip_flag = 0;
}
if (height > 300)
{
pixel_clock = (hmax * vmax * (hz/2)) /2 ;
ip_flag = 1;
}
/* above code is the modeline generator */
snprintf(set_hdmi_timing, sizeof(set_hdmi_timings), "hdmi_timings %d 1 %d %d %d %d 1 %d %d %d 0 0 0 %f %d %f 1 ", width, hfp, hsp, hbp, height, vfp,vsp, vbp, hz, ip_flag, pixel_clock);
VCHI_INSTANCE_T vchi_instance;
VCHI_CONNECTION_T *vchi_connection = NULL;
char buffer[1024];
vcos_init ();
vchi_initialise (&vchi_instance);
vchi_connect (NULL, 0, vchi_instance);
vc_vchi_gencmd_init (vchi_instance, &vchi_connection, 1);
vc_gencmd (buffer, sizeof (buffer), set_hdmi_timing);
vc_gencmd_stop ();
vchi_disconnect (vchi_instance);
snprintf(output1, sizeof(output1),"tvservice -e \"DMT 87\" > /dev/null");
system(output1);
snprintf(output2, sizeof(output1),"fbset -g %d %d %d %d 24 > /dev/null",width, height, width, height);
system(output2);
}
#endif

View File

@ -27,7 +27,7 @@
RETRO_BEGIN_DECLS RETRO_BEGIN_DECLS
void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust); void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust, int monitor_index);
void crt_aspect_ratio_switch(unsigned width, unsigned height); void crt_aspect_ratio_switch(unsigned width, unsigned height);

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, bool video_display_server_set_resolution(unsigned width, unsigned height,
int int_hz, float hz, int center) int int_hz, float hz, int center, int monitor_index)
{ {
if (current_display_server && current_display_server->set_resolution) 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); return current_display_server->set_resolution(current_display_server_data, width, height, int_hz, hz, center, monitor_index);
return false; 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_progress)(void *data, int progress, bool finished);
bool (*set_window_decorations)(void *data, bool on); bool (*set_window_decorations)(void *data, bool on);
bool (*set_resolution)(void *data, unsigned width, bool (*set_resolution)(void *data, unsigned width,
unsigned height, int int_hz, float hz, int center); unsigned height, int int_hz, float hz, int center, int monitor_index);
void *(*get_resolution_list)(void *data, void *(*get_resolution_list)(void *data,
unsigned *size); unsigned *size);
const char *(*get_output_options)(void *data); 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( bool video_display_server_set_resolution(
unsigned width, unsigned height, unsigned width, unsigned height,
int int_hz, float hz, int center); int int_hz, float hz, int center, int monitor_index);
void *video_display_server_get_resolution_list(unsigned *size); void *video_display_server_get_resolution_list(unsigned *size);

View File

@ -2672,7 +2672,7 @@ void video_driver_frame(const void *data, unsigned width,
width = 3840; width = 3840;
if (video_info.crt_switch_resolution_super == 1920) if (video_info.crt_switch_resolution_super == 1920)
width = 1920; width = 1920;
crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust); 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);
} }
else if (!video_info.crt_switch_resolution) else if (!video_info.crt_switch_resolution)
video_driver_crt_switching_active = false; video_driver_crt_switching_active = false;
@ -2680,6 +2680,11 @@ void video_driver_frame(const void *data, unsigned width,
/* trigger set resolution*/ /* trigger set resolution*/
} }
void crt_switch_driver_reinit(void)
{
video_driver_reinit();
}
void video_driver_display_type_set(enum rarch_display_type type) void video_driver_display_type_set(enum rarch_display_type type)
{ {
video_driver_display_type = type; video_driver_display_type = type;

View File

@ -1066,6 +1066,8 @@ const video_poke_interface_t *video_driver_get_poke(void);
void video_driver_frame(const void *data, unsigned width, void video_driver_frame(const void *data, unsigned width,
unsigned height, size_t pitch); unsigned height, size_t pitch);
void crt_switch_driver_reinit(void);
#define video_driver_translate_coord_viewport_wrap(vp, mouse_x, mouse_y, res_x, res_y, res_screen_x, res_screen_y) \ #define video_driver_translate_coord_viewport_wrap(vp, mouse_x, mouse_y, res_x, res_y, res_screen_x, res_screen_y) \
(video_driver_get_viewport_info(vp) ? video_driver_translate_coord_viewport(vp, mouse_x, mouse_y, res_x, res_y, res_screen_x, res_screen_y) : false) (video_driver_get_viewport_info(vp) ? video_driver_translate_coord_viewport(vp, mouse_x, mouse_y, res_x, res_y, res_screen_x, res_screen_y) : false)