1920x1200 & 1920x1440 Aspect Ratio Detection

Discussion about displays and related hardware including MiSTer filters and video settings.
User avatar
skooter
Posts: 65
Joined: Mon May 25, 2020 1:37 pm
Location: Brazil
Has thanked: 2 times
Been thanked: 19 times
Contact:

1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by skooter »

When I set my mister to 1920x1200 or 1920x1440, my Magewell USB Capture HDMI incorrectly detects its aspect ratio as 16:9.

I think it was an issue with the capture device, but when my OSSC is set to 1920x1200 it is correctly detected as 8:5 by the same device with the same default configuration.

Am I doing something wrong?

I could override the aspect ratio through their utility, but it is annoying because I have some cores set to 1920x1080 (like SMS, which is larger than 4:3 after crop) and others set to 1920x1440 and I would have to change the aspect ratio whenever I change the resolution.
FoxbatStargazer
Top Contributor
Posts: 1019
Joined: Thu Dec 10, 2020 5:44 pm
Has thanked: 315 times
Been thanked: 238 times

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by FoxbatStargazer »

I wouldn't know how but this may be connected with the video modes and blanking intervals or such. I have several Sony LCDs that will only show 50hz correctly when fed video_mode=9, you can't just force 50hz on video_mode=8 or your own similar modeline and have it interpreted correctly. Odds are the capture card may be looking for something similar. There are many ways to generate the same resolution and if you can somehow copy what your OSSC is doing with a custom modeline you may have better results.
User avatar
skooter
Posts: 65
Joined: Mon May 25, 2020 1:37 pm
Location: Brazil
Has thanked: 2 times
Been thanked: 19 times
Contact:

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by skooter »

I tried to copy all the parameters (vertical and horizontal front porch, sync width, back porch) from the OSSC output, but nothing works for MiSTer. It is always detected as 16:9. It must be something else.
User avatar
skooter
Posts: 65
Joined: Mon May 25, 2020 1:37 pm
Location: Brazil
Has thanked: 2 times
Been thanked: 19 times
Contact:

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by skooter »

According to the wikipedia entry on EDID - https://en.wikipedia.org/wiki/Extended_ ... ation_Data - there are some fields related to the aspect ratio. Could it be that MiSTer is not setting them?
User avatar
skooter
Posts: 65
Joined: Mon May 25, 2020 1:37 pm
Location: Brazil
Has thanked: 2 times
Been thanked: 19 times
Contact:

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by skooter »

I finally found out the root of this problem: MiSTer is sending a wrong VIC configuration in the AVI InfoFrame. Apparently, the automatic VIC detection of the HDMI chip (ADV7513) fails when we set resolutions or frequencies above its specifications. According to its specs, the limit is 165 MHz and 1920x1080.

When MiSTer is set to 1920x1440, the VIC is set to 16, which corresponds to 1920x1080 @ 60 Hz with a 16:9 aspect ratio. When the sink (in this case Magewell USB Capture HDMI) realizes this mismatch between the resolution and refresh rate in the actual image and in the VIC field, it uses what is in the image. However, there is no aspect ratio in the image, so it keeps using the wrong information set in VIC.

I confirmed this issue by building the SNES core with the VIC detection disabled. This is accomplished by disabling pixel repetition and setting VIC manually, according to the ADV7513 Programming Guide.

So what I did in hdmi_config.sv was:
- set register 0x3B[6:5] to '10'
- set register 0x3C to '00000000'

This fixed the issue and the aspect ratio is correctly identified in any resolution.

My suggestion is to update the framework so the automatic VIC detection is not used when the resolution is above 1920x1080 or the frequency is above 165 MHz. In these cases, VIC should be set to zero. There will be no loss since there are no valid VIC numbers for 1920x1440 resolutions (or any resolution above 1080p and below 2160p).

While I was messing in hdmi_config.sv, I also realized that the A0 field in the AVI InfoFrame (0x55[4]) is set to 1, which indicates that the Active Format Data is present in Data Byte 2 bits R3 through R0. However, R3 to R0 (0x56[3:0]) is currently set to '0000', which is not valid. It should be set to '1000', which means "Same as Picture Aspect Ratio". Moreover, when the aspect ratio is 16:9 or 4:3, it can be set to 0x56[5:4]. It is not mandatory, but I think it would increase the compatibility with some devices. When the aspect ratio is different than that, it should be set to '00'.

Finally, I also did some tests by setting the IT content to Game (0x57[7] to '1' and 0x59[5:4] to '11') and it makes my TV automatically change to game mode, like modern systems like PlayStation 4, PlayStation 5 and Nintendo Switch do. I believe this should be a mister.ini option, so people could choose the IT mode (Game, Graphics, etc.) or IT disabled according to what is best for their TVs/monitors.

I would implement this stuff myself but I have no experience with FPGA programming and I have no idea how to bring the variables I need into hdmi_config.sv

I'd like to thank wickerwaka and Zakk for all the knowledge shared on the official Discord server, which helped me a lot in figuring out these issues.
flynnsbit
Top Contributor
Posts: 552
Joined: Sun May 24, 2020 8:07 pm
Has thanked: 185 times
Been thanked: 310 times
Contact:

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by flynnsbit »

skooter wrote: Mon Apr 18, 2022 1:29 pm I finally found out the root of this problem: MiSTer is sending a wrong VIC configuration in the AVI InfoFrame. Apparently, the automatic VIC detection of the HDMI chip (ADV7513) fails when we set resolutions or frequencies above its specifications. According to its specs, the limit is 165 MHz and 1920x1080.

When MiSTer is set to 1920x1440, the VIC is set to 16, which corresponds to 1920x1080 @ 60 Hz with a 16:9 aspect ratio. When the sink (in this case Magewell USB Capture HDMI) realizes this mismatch between the resolution and refresh rate in the actual image and in the VIC field, it uses what is in the image. However, there is no aspect ratio in the image, so it keeps using the wrong information set in VIC.

I confirmed this issue by building the SNES core with the VIC detection disabled. This is accomplished by disabling pixel repetition and setting VIC manually, according to the ADV7513 Programming Guide.

So what I did in hdmi_config.sv was:
- set register 0x3B[6:5] to '10'
- set register 0x3C to '00000000'

This fixed the issue and the aspect ratio is correctly identified in any resolution.

My suggestion is to update the framework so the automatic VIC detection is not used when the resolution is above 1920x1080 or the frequency is above 165 MHz. In these cases, VIC should be set to zero. There will be no loss since there are no valid VIC numbers for 1920x1440 resolutions (or any resolution above 1080p and below 2160p).

While I was messing in hdmi_config.sv, I also realized that the A0 field in the AVI InfoFrame (0x55[4]) is set to 1, which indicates that the Active Format Data is present in Data Byte 2 bits R3 through R0. However, R3 to R0 (0x56[3:0]) is currently set to '0000', which is not valid. It should be set to '1000', which means "Same as Picture Aspect Ratio". Moreover, when the aspect ratio is 16:9 or 4:3, it can be set to 0x56[5:4]. It is not mandatory, but I think it would increase the compatibility with some devices. When the aspect ratio is different than that, it should be set to '00'.

Finally, I also did some tests by setting the IT content to Game (0x57[7] to '1' and 0x59[5:4] to '11') and it makes my TV automatically change to game mode, like modern systems like PlayStation 4, PlayStation 5 and Nintendo Switch do. I believe this should be a mister.ini option, so people could choose the IT mode (Game, Graphics, etc.) or IT disabled according to what is best for their TVs/monitors.

I would implement this stuff myself but I have no experience with FPGA programming and I have no idea how to bring the variables I need into hdmi_config.sv

I'd like to thank wickerwaka and Zakk for all the knowledge shared on the official Discord server, which helped me a lot in figuring out these issues.
I would suggest a github item somewhere to track all of this instead of the forum post. Good research.
User avatar
skooter
Posts: 65
Joined: Mon May 25, 2020 1:37 pm
Location: Brazil
Has thanked: 2 times
Been thanked: 19 times
Contact:

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by skooter »

Thanks. I'll create an issue in the framework GitHub.
orange428
Posts: 23
Joined: Thu Aug 27, 2020 4:36 pm
Been thanked: 5 times

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by orange428 »

Hi, great find. In the mean time would you mind posting your SNES core so we can test it? I have a monitor I'm trying to run at 2048x1536 and it works but the monitor always has a screen overlay error message complaining about the signal. I wonder if your changes might improve compatibility with these high resolutions. Thanks so much.
User avatar
skooter
Posts: 65
Joined: Mon May 25, 2020 1:37 pm
Location: Brazil
Has thanked: 2 times
Been thanked: 19 times
Contact:

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by skooter »

Sure. It is attached.
Besides setting VIC to zero, it also sets IT to Game mode.
Attachments
SNES.rbf
(4.11 MiB) Downloaded 152 times
orange428
Posts: 23
Joined: Thu Aug 27, 2020 4:36 pm
Been thanked: 5 times

Re: 1920x1200 & 1920x1440 Aspect Ratio Detection

Unread post by orange428 »

Hi, thanks for posting the core! Will post back here with my results.
Post Reply