Skip to content

Commit f3b17ec

Browse files
committed
Merge remote-tracking branch 'upstream/master'
# Conflicts: # input.cpp # scheduler.cpp
2 parents 7c6710f + 22a7759 commit f3b17ec

18 files changed

Lines changed: 1925 additions & 207 deletions

MiSTer.ini

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[MiSTer]
2-
;debug=1 ; set to 1 to enable debugging messages. Default is 0(disabled).
2+
;debug=1 ; set to 1 to enable debugging messages, 2 - write to /tmp/debug.txt. Default is 0(disabled).
33
key_menu_as_rgui=0 ; set to 1 to make the MENU key map to RGUI in Minimig (e.g. for Right Amiga)
44
forced_scandoubler=0 ; set to 1 to run scandoubler on VGA output always (depends on core).
55
;ypbpr=0 ; set to 1 for YPbPr on VGA output. (obsolete. see vga_mode)
@@ -22,6 +22,13 @@ rbf_hide_datecode=0 ; 1 - hides datecodes from rbf file names. Press F2 for q
2222
menu_pal=0 ; 1 - PAL mode for menu core
2323
hdmi_limited=0 ; 1 - use limited (16..235) color range over HDMI
2424
; 2 - use limited (16..255) color range over HDMI, for VGA converters.
25+
hdmi_cec=0 ; 1 - enable HDMI-CEC via ADV7513, 0 - disable.
26+
hdmi_cec_input_mode=1 ; 0 - ignore CEC remote input, 1 - accept mapped CEC keys.
27+
hdmi_cec_power_on=1 ; 1 - on power-on, try once to make MiSTer the active HDMI input once EDID provides its CEC address.
28+
hdmi_cec_sleep=0 ; 1 - send CEC STANDBY after video_off minutes of no input activity. Requires video_off>0.
29+
hdmi_cec_wake=0 ; 1 - on input after that idle period, send wake (ImageViewOn/TextViewOn/ActiveSource).
30+
hdmi_cec_clock=0 ; 0 - auto-detect 12MHz/50MHz, otherwise floating point value from 3.0 to 100.0 (3-100MHz).
31+
;
2532
direct_video=0 ; 1 - enable core video timing over HDMI, use only with VGA converters.
2633
; 2 - auto-mode for HDMI DACs that report 1024x768 resolution (AG6200, CS5213).
2734
; Power cycle when switching between HDMI displays and DACs. No hot-plug detection.
@@ -33,7 +40,6 @@ fb_terminal=1 ; 1 - enabled (default), 0 - disabled
3340
osd_timeout=30 ; 5-3600 timeout (in seconds) for OSD to disappear in Menu core. 0 - never timeout.
3441
; Background picture will get darker after double timeout
3542
video_off=0 ; output black frame in Menu core after timeout (is seconds). Valid only if osd_timout is non zero.
36-
video_off_hdmi=0 ; 1 - power down HDMI on video_off timeout (TV can sleep), 0 - keep HDMI active
3743
video_off_logo=0 ; 1 - show moving MiSTer logo when video_off is enabled (to distinguish from TV off mode)
3844
osd_rotate=0 ; Display OSD menu rotated, 0 - no rotation, 1 - rotate right (+90°), 2 - rotate left (-90°)
3945
vga_sog=0 ; 1 - enable sync on green (needs analog I/O board v6.0 or newer).
@@ -390,3 +396,8 @@ osd_lock_time=5
390396
; 2 - Additionally don't send new SPD upon OSD open/close
391397
; 3 - Don't send SPD at all.
392398
;spd_quirk=0
399+
400+
; 1...1440 - minutes till HDMI off if no user activity detected (no input from mouse/keyboard/joystick).
401+
; unlike video_off which works only in Menu core, this option works in all cores.
402+
; 0 (default) - don't turn HDMI off.
403+
hdmi_off=0

MiSTer.vcxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@
5858
<ClCompile Include="DiskImage.cpp" />
5959
<ClCompile Include="file_io.cpp" />
6060
<ClCompile Include="fpga_io.cpp" />
61-
<ClCompile Include="game_docs.cpp" />
61+
<ClCompile Include="game_docs.cpp" />
6262
<ClCompile Include="gamecontroller_db.cpp" />
6363
<ClCompile Include="hardware.cpp" />
64+
<ClCompile Include="hdmi_cec.cpp" />
6465
<ClCompile Include="ide.cpp" />
6566
<ClCompile Include="ide_cdrom.cpp" />
6667
<ClCompile Include="input.cpp" />
@@ -135,9 +136,10 @@
135136
<ClInclude Include="fpga_nic301.h" />
136137
<ClInclude Include="fpga_reset_manager.h" />
137138
<ClInclude Include="fpga_system_manager.h" />
138-
<ClInclude Include="game_docs.h" />
139+
<ClInclude Include="game_docs.h" />
139140
<ClInclude Include="gamecontroller_db.h" />
140141
<ClInclude Include="hardware.h" />
142+
<ClInclude Include="hdmi_cec.h" />
141143
<ClInclude Include="ide.h" />
142144
<ClInclude Include="ide_cdrom.h" />
143145
<ClInclude Include="input.h" />

MiSTer.vcxproj.filters

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@
121121
<ClCompile Include="cheats.cpp">
122122
<Filter>Source Files</Filter>
123123
</ClCompile>
124-
<ClCompile Include="game_docs.cpp">
125-
<Filter>Source Files</Filter>
126-
</ClCompile>
124+
<ClCompile Include="game_docs.cpp">
125+
<Filter>Source Files</Filter>
126+
</ClCompile>
127127
<ClCompile Include="scaler.cpp">
128128
<Filter>Source Files</Filter>
129129
</ClCompile>
@@ -256,6 +256,9 @@
256256
<ClCompile Include="support\saturn\saturncdd.cpp">
257257
<Filter>Source Files\support</Filter>
258258
</ClCompile>
259+
<ClCompile Include="hdmi_cec.cpp">
260+
<Filter>Source Files</Filter>
261+
</ClCompile>
259262
</ItemGroup>
260263
<ItemGroup>
261264
<ClInclude Include="battery.h">
@@ -351,9 +354,9 @@
351354
<ClInclude Include="cheats.h">
352355
<Filter>Header Files</Filter>
353356
</ClInclude>
354-
<ClInclude Include="game_docs.h">
355-
<Filter>Header Files</Filter>
356-
</ClInclude>
357+
<ClInclude Include="game_docs.h">
358+
<Filter>Header Files</Filter>
359+
</ClInclude>
357360
<ClInclude Include="scaler.h">
358361
<Filter>Header Files</Filter>
359362
</ClInclude>
@@ -492,5 +495,8 @@
492495
<ClInclude Include="support\saturn\saturn.h">
493496
<Filter>Header Files\support</Filter>
494497
</ClInclude>
498+
<ClInclude Include="hdmi_cec.h">
499+
<Filter>Header Files</Filter>
500+
</ClInclude>
495501
</ItemGroup>
496-
</Project>
502+
</Project>

audio.cpp

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static uint8_t vol_att = 0;
2222
static uint8_t corevol_att = 0;
2323
unsigned long vol_set_timeout = 0;
2424
static int has_filter = 0;
25+
static int has_boost = 0;
2526

2627
static char filter_cfg_path[1024] = {};
2728
static char filter_cfg[1024] = {};
@@ -31,6 +32,8 @@ static void setFilter()
3132
fileTYPE f = {};
3233

3334
has_filter = spi_uio_cmd(UIO_SET_AFILTER);
35+
has_boost = (has_filter & 2) && !is_menu();
36+
if (!has_boost) corevol_att &= 7;
3437
if (!has_filter) return;
3538

3639
snprintf(filter_cfg_path, sizeof(filter_cfg_path), AFILTER_DIR"/%s", filter_cfg + 1);
@@ -140,8 +143,11 @@ int get_volume()
140143

141144
int get_core_volume()
142145
{
146+
int boost = corevol_att & 0x60;
147+
if (boost > 0x40) boost = 0x40;
143148
corevol_att &= 7;
144149
if (corevol_att > 6) corevol_att = 6;
150+
corevol_att |= boost;
145151
return corevol_att;
146152
}
147153

@@ -182,12 +188,42 @@ void set_core_volume(int cmd)
182188
{
183189
vol_set_timeout = GetTimer(1000);
184190

185-
corevol_att &= 7;
186-
if (cmd < 0 && corevol_att < 6) corevol_att += 1;
187-
if (cmd > 0 && corevol_att > 0) corevol_att -= 1;
191+
if (has_boost)
192+
{
193+
int boost = corevol_att & 0x60;
194+
corevol_att &= 7;
195+
if (cmd < 0)
196+
{
197+
if (boost)
198+
{
199+
corevol_att = 0;
200+
boost -= 0x20;
201+
}
202+
else if (corevol_att < 6) corevol_att += 1;
203+
}
204+
205+
if (cmd > 0)
206+
{
207+
if (boost || !corevol_att)
208+
{
209+
boost += 0x20;
210+
if (boost > 0x40) boost = 0x40;
211+
}
212+
else if (corevol_att > 0) corevol_att -= 1;
213+
}
214+
215+
corevol_att |= boost;
216+
setFilter();
217+
}
218+
else
219+
{
220+
corevol_att &= 7;
221+
if (cmd < 0 && corevol_att < 6) corevol_att += 1;
222+
if (cmd > 0 && corevol_att > 0) corevol_att -= 1;
188223

189-
if (has_filter) setFilter();
190-
else send_volume();
224+
if (has_filter) setFilter();
225+
else send_volume();
226+
}
191227
}
192228

193229
void save_volume()

cfg.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
cfg_t cfg;
2020
static FILE *orig_stdout = NULL;
2121
static FILE *dev_null = NULL;
22+
static FILE *debug_file = NULL;
2223

2324
typedef enum
2425
{
@@ -52,6 +53,12 @@ static const ini_var_t ini_vars[] =
5253
{ "HDMI_AUDIO_96K", (void*)(&(cfg.hdmi_audio_96k)), UINT8, 0, 1 },
5354
{ "DVI_MODE", (void*)(&(cfg.dvi_mode)), UINT8, 0, 1 },
5455
{ "HDMI_LIMITED", (void*)(&(cfg.hdmi_limited)), UINT8, 0, 2 },
56+
{ "HDMI_CEC", (void*)(&(cfg.hdmi_cec)), UINT8, 0, 1 },
57+
{ "HDMI_CEC_SLEEP", (void*)(&(cfg.hdmi_cec_sleep)), UINT8, 0, 1 },
58+
{ "HDMI_CEC_WAKE", (void*)(&(cfg.hdmi_cec_wake)), UINT8, 0, 1 },
59+
{ "HDMI_CEC_INPUT_MODE", (void*)(&(cfg.hdmi_cec_input_mode)), UINT8, 0, 1 },
60+
{ "HDMI_CEC_POWER_ON", (void*)(&(cfg.hdmi_cec_power_on)), UINT8, 0, 1 },
61+
{ "HDMI_CEC_CLOCK", (void*)(&(cfg.hdmi_cec_clock)), FLOAT, 0, 100 },
5562
{ "KBD_NOMOUSE", (void*)(&(cfg.kbd_nomouse)), UINT8, 0, 1 },
5663
{ "MOUSE_THROTTLE", (void*)(&(cfg.mouse_throttle)), UINT8, 1, 100 },
5764
{ "BOOTSCREEN", (void*)(&(cfg.bootscreen)), UINT8, 0, 1 },
@@ -108,7 +115,6 @@ static const ini_var_t ini_vars[] =
108115
{ "VRR_MODE", (void *)(&(cfg.vrr_mode)), UINT8, 0, 4 },
109116
{ "VRR_VESA_FRAMERATE", (void *)(&(cfg.vrr_vesa_framerate)), UINT8, 0, 255 },
110117
{ "VIDEO_OFF", (void*)(&(cfg.video_off)), INT16, 0, 3600 },
111-
{ "VIDEO_OFF_HDMI", (void*)(&(cfg.video_off_hdmi)), UINT8, 0, 1 },
112118
{ "VIDEO_OFF_LOGO", (void*)(&(cfg.video_off_logo)), UINT8, 0, 1 },
113119
{ "PLAYER_1_CONTROLLER", (void*)(&(cfg.player_controller[0])), STRINGARR, sizeof(cfg.player_controller[0]) / sizeof(cfg.player_controller[0][0]), sizeof(cfg.player_controller[0][0]) },
114120
{ "PLAYER_2_CONTROLLER", (void*)(&(cfg.player_controller[1])), STRINGARR, sizeof(cfg.player_controller[0]) / sizeof(cfg.player_controller[0][0]), sizeof(cfg.player_controller[0][0]) },
@@ -130,7 +136,7 @@ static const ini_var_t ini_vars[] =
130136
{ "CONTROLLER_UNIQUE_MAPPING", (void *)(cfg.controller_unique_mapping), UINT32ARR, 0, 0xFFFFFFFF },
131137
{ "OSD_LOCK", (void*)(&(cfg.osd_lock)), STRING, 0, sizeof(cfg.osd_lock) - 1 },
132138
{ "OSD_LOCK_TIME", (void*)(&(cfg.osd_lock_time)), UINT16, 0, 60 },
133-
{ "DEBUG", (void *)(&(cfg.debug)), UINT8, 0, 1 },
139+
{ "DEBUG", (void *)(&(cfg.debug)), UINT8, 0, 2 },
134140
{ "LOOKAHEAD", (void *)(&(cfg.lookahead)), UINT8, 0, 1 },
135141
{ "MAIN", (void*)(&(cfg.main)), STRING, 0, sizeof(cfg.main) - 1 },
136142
{ "VFILTER_INTERLACE_DEFAULT", (void*)(&(cfg.vfilter_interlace_default)), STRING, 0, sizeof(cfg.vfilter_interlace_default) - 1 },
@@ -139,6 +145,7 @@ static const ini_var_t ini_vars[] =
139145
{ "SCREENSHOT_IMAGE_FORMAT", (void *)(&(cfg.screenshot_image_format)), STRING, 0, sizeof(cfg.screenshot_image_format) - 1 },
140146
{ "XBE2_SHIFT", (void*)(&(cfg.xbe2_shift)), UINT16, 0, 0x22F },
141147
{ "SPD_QUIRK", (void*)(&(cfg.spd_quirk)), UINT8, 0, 3 },
148+
{ "HDMI_OFF", (void*)(&(cfg.hdmi_off)), UINT16, 0, 1440 },
142149
};
143150

144151
static const int nvars = (int)(sizeof(ini_vars) / sizeof(ini_var_t));
@@ -427,7 +434,12 @@ static void ini_parse_var(char* buf)
427434
ini_parse_numeric(var, &buf[i], var->var);
428435
if (!strcasecmp(var->name, "DEBUG"))
429436
{
430-
stdout = cfg.debug ? orig_stdout : dev_null;
437+
if (cfg.debug == 2 && !debug_file)
438+
{
439+
debug_file = fopen("/tmp/debug.txt", "w");
440+
setvbuf(debug_file, NULL, _IONBF, 0);
441+
}
442+
stdout = (cfg.debug == 2) ? debug_file : cfg.debug ? orig_stdout : dev_null;
431443
}
432444
break;
433445
}
@@ -589,13 +601,13 @@ void cfg_parse()
589601
cfg.wheel_force = 50;
590602
cfg.dvi_mode = 2;
591603
cfg.lookahead = 1;
592-
cfg.hdr = 0;
604+
cfg.hdmi_cec_input_mode = 1;
605+
cfg.hdmi_cec_power_on = 1;
593606
cfg.hdr_max_nits = 1000;
594607
cfg.hdr_avg_nits = 250;
595608
cfg.video_brightness = 50;
596609
cfg.video_contrast = 50;
597610
cfg.video_saturation = 100;
598-
cfg.video_hue = 0;
599611
strcpy(cfg.video_gain_offset, "1, 0, 1, 0, 1, 0");
600612
strcpy(cfg.main, "MiSTer");
601613
has_video_sections = false;

cfg.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ typedef struct {
1919
uint8_t hdmi_audio_96k;
2020
uint8_t dvi_mode;
2121
uint8_t hdmi_limited;
22+
uint8_t hdmi_cec;
23+
uint8_t hdmi_cec_sleep;
24+
uint8_t hdmi_cec_wake;
25+
uint8_t hdmi_cec_input_mode;
26+
uint8_t hdmi_cec_power_on;
27+
float hdmi_cec_clock;
2228
uint8_t direct_video;
2329
uint8_t video_info;
2430
float refresh_min;
@@ -80,7 +86,6 @@ typedef struct {
8086
uint8_t vrr_mode;
8187
uint8_t vrr_vesa_framerate;
8288
uint16_t video_off;
83-
uint8_t video_off_hdmi;
8489
uint8_t video_off_logo;
8590
uint8_t disable_autofire;
8691
uint8_t video_brightness;
@@ -106,6 +111,7 @@ typedef struct {
106111
char screenshot_image_format[16];
107112
uint16_t xbe2_shift;
108113
uint8_t spd_quirk;
114+
uint16_t hdmi_off;
109115
} cfg_t;
110116

111117
extern cfg_t cfg;

fpga_io.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ int fpga_get_io_type()
582582
return (fpga_gpi_read() >> 28) & 1;
583583
}
584584

585+
int fpga_get_hdmi_int()
586+
{
587+
return (fpga_gpi_read() >> 20) & 1;
588+
}
589+
585590
void reboot(int cold)
586591
{
587592
sync();
@@ -627,10 +632,21 @@ void app_restart(const char *path, const char *xml, const char *exe)
627632

628633
const char *appname = exe ? exe : getappname();
629634
printf("restarting to %s\n", appname);
630-
execl(appname, appname, path, xml, NULL);
635+
636+
//a cleaner way to re-start
637+
pid_t child = fork();
638+
if (child > 0) _exit(0);
639+
else if (child == 0)
640+
{
641+
setsid();
642+
pid_t grandchild = fork();
643+
if (grandchild > 0) _exit(0);
644+
if (grandchild == 0) execl(appname, appname, path, xml, NULL);
645+
}
631646

632647
printf("Something went wrong. Rebooting...\n");
633648
reboot(1);
649+
_exit(1);
634650
}
635651

636652
void fpga_core_reset(int reset)

fpga_io.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ void fpga_spi_fast_block_read_be(uint16_t *buf, uint32_t length);
2222

2323
void fpga_set_led(uint32_t on);
2424
int fpga_get_buttons();
25-
int fpga_get_io_type();
25+
int fpga_get_io_type();
26+
int fpga_get_hdmi_int();
2627

2728
void fpga_core_reset(int reset);
2829
void fpga_core_write(uint32_t offset, uint32_t value);

0 commit comments

Comments
 (0)