Support for different HDMI resolutions.

This commit is contained in:
sorgelig
2017-12-13 20:43:43 +08:00
parent 65e4e41da9
commit b1d72360c8
6 changed files with 81 additions and 19 deletions

View File

@@ -17,7 +17,7 @@
#define INI_EOT 4 // End-Of-Transmission
#define INI_BUF_SIZE 512
#define INI_LINE_SIZE 65
#define INI_LINE_SIZE 256
#define INI_SECTION_START '['
#define INI_SECTION_END ']'
@@ -228,6 +228,7 @@ void* ini_get_var(const ini_cfg_t* cfg, int cur_section, char* buf)
if (*(float*)(cfg->vars[var_id].var) < cfg->vars[var_id].min) *(float*)(cfg->vars[var_id].var) = cfg->vars[var_id].min;
break;
case STRING:
memset(cfg->vars[var_id].var, 0, cfg->vars[var_id].max);
strncpy((char*)(cfg->vars[var_id].var), &(buf[i]), cfg->vars[var_id].max);
break;
case CUSTOM_HANDLER:

1
main.c
View File

@@ -62,6 +62,7 @@ void core_init()
user_io_detect_core_type();
mist_ini_parse();
parse_video_mode();
user_io_send_buttons(1);
if (user_io_core_type() == CORE_TYPE_MINIMIG2)

View File

@@ -7,14 +7,14 @@
#include "mist_cfg.h"
#include "user_io.h"
mist_cfg_t mist_cfg;
void mist_ini_parse()
{
memset(&mist_cfg, 0, sizeof(mist_cfg));
ini_parse(&mist_ini_cfg);
}
mist_cfg_t mist_cfg = { 0 };
// mist ini sections
const ini_section_t mist_ini_sections[] =
{
@@ -30,8 +30,9 @@ const ini_var_t mist_ini_vars[] = {
{ "KEYRAH_MODE", (void*)(&(mist_cfg.keyrah_mode)), UINT32, 0, 0xFFFFFFFF, 1 },
{ "RESET_COMBO", (void*)(&(mist_cfg.reset_combo)), UINT8, 0, 3, 1 },
{ "KEY_MENU_AS_RGUI", (void*)(&(mist_cfg.key_menu_as_rgui)), UINT8, 0, 1, 1 },
{ "VIDEO_MODE", (void*)(&(mist_cfg.video_mode)), UINT8, 0, 9, 1 },
{ "VIDEO_MODE", (void*)(mist_cfg.video_conf), STRING, 0, sizeof(mist_cfg.video_conf)-1, 1 },
{ "HDMI_AUDIO_96K", (void*)(&(mist_cfg.hdmi_audio_96k)), UINT8, 0, 1, 1 },
{ "DVI_MODE", (void*)(&(mist_cfg.dvi)), UINT8, 0, 1, 1 },
};
// mist ini config

View File

@@ -20,15 +20,15 @@ typedef struct {
uint8_t ypbpr;
uint8_t csync;
uint8_t vga_scaler;
uint8_t video_mode;
uint8_t hdmi_audio_96k;
uint8_t dvi;
uint8_t video_mode;
char video_conf[1024];
} mist_cfg_t;
//// functions ////
void mist_ini_parse();
//// global variables ////
extern const ini_cfg_t mist_ini_cfg;
extern mist_cfg_t mist_cfg;

View File

@@ -868,8 +868,11 @@ char old_video_mode = -1;
void user_io_send_buttons(char force)
{
static unsigned char key_map = 0;
unsigned char map = 0;
static unsigned short key_map = 0;
unsigned short map = 0;
map = mist_cfg.video_mode;
map = (map << CONF_RES_SHIFT) & CONF_RES_MASK;
int btn = fpga_get_buttons();
@@ -881,7 +884,8 @@ void user_io_send_buttons(char force)
if (mist_cfg.csync) map |= CONF_CSYNC;
if (mist_cfg.ypbpr) map |= CONF_YPBPR;
if (mist_cfg.forced_scandoubler) map |= CONF_FORCED_SCANDOUBLER;
if (mist_cfg.hdmi_audio_96k) map |= CONF_AUDIO_48K;
if (mist_cfg.hdmi_audio_96k) map |= CONF_AUDIO_96K;
if (mist_cfg.dvi) map |= CONF_DVI;
if ((map != key_map) || force)
{
@@ -893,16 +897,10 @@ void user_io_send_buttons(char force)
}
}
key_map = map;
spi_uio_cmd8(UIO_BUT_SW, map);
spi_uio_cmd16(UIO_BUT_SW, map);
printf("sending keymap: %X\n", map);
if ((key_map & BUTTON2) && is_x86_core()) x86_init();
}
if (old_video_mode != mist_cfg.video_mode)
{
old_video_mode = mist_cfg.video_mode;
spi_uio_cmd8(UIO_SET_VIDEO, old_video_mode);
}
}
uint32_t diskled_timer = 0;
@@ -1929,3 +1927,60 @@ emu_mode_t user_io_get_kbdemu()
{
return emu_mode;
}
void parse_video_mode()
{
char *cfg = mist_cfg.video_conf;
uint32_t items[32];
mist_cfg.video_mode = 0;
int cnt = 0;
while (*cfg)
{
char *next;
uint32_t val = strtoul(cfg, &next, 0);
if (cfg == next || (*next !=',' && *next))
{
printf("Error parsing video_mode parameter: ""%s""\n", mist_cfg.video_conf);
return;
}
if (cnt < 32) items[cnt] = val;
if (*next == ',') next++;
cfg = next;
cnt++;
}
if (cnt == 1)
{
mist_cfg.video_mode = items[0];
printf("Set predefined video_mode to %d\n", mist_cfg.video_mode);
return;
}
if (cnt < 21 || cnt > 32)
{
printf("Incorrect amount of items in video_mode parameter: %d\n", cnt);
return;
}
if (items[0])
{
printf("Incorrect video_mode parameter\n");
return;
}
spi_uio_cmd_cont(UIO_SET_VIDEO);
for (int i = 1; i <= 8; i++) spi_w(items[i]);
for (int i = 9; i < cnt; i++)
{
if (i & 1) spi_w(items[i]);
else
{
spi_w(items[i]);
spi_w(items[i] >> 16);
};
}
DisableIO();
}

View File

@@ -52,7 +52,7 @@
#define UIO_SET_SDINFO 0x1d // send info about mounted image
#define UIO_SET_STATUS2 0x1e // 32bit status
#define UIO_GET_KBD_LED 0x1f // keyboard LEDs control
#define UIO_SET_VIDEO 0x20 // set HDMI video mode 0: 1280x720p60(TV), 1: 1280x1024p60(PC), 2-255: reserved
#define UIO_SET_VIDEO 0x20
#define UIO_PS2_CTL 0x21 // get PS2 control from supported cores
#define UIO_RTC 0x22 // transmit RTC data to core
#define UIO_GET_VRES 0x23 // get video resolution
@@ -117,7 +117,10 @@
#define CONF_CSYNC 0x08
#define CONF_FORCED_SCANDOUBLER 0x10
#define CONF_YPBPR 0x20
#define CONF_AUDIO_48K 0x40
#define CONF_AUDIO_96K 0x40
#define CONF_DVI 0x80
#define CONF_RES_MASK 0x700
#define CONF_RES_SHIFT 8
// core type value should be unlikely to be returned by broken cores
#define CORE_TYPE_UNKNOWN 0x55
@@ -197,6 +200,7 @@ void user_io_digital_joystick(unsigned char, uint16_t);
void user_io_analog_joystick(unsigned char, char, char);
char user_io_osd_is_visible();
void user_io_send_buttons(char);
void parse_video_mode();
void add_modifiers(uint8_t mod, uint16_t* keys_ps2);