Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Resolution Set in /dev/shm/retroarch.cfg #3338

Open
theofficialgman opened this issue May 12, 2021 · 9 comments
Open

Incorrect Resolution Set in /dev/shm/retroarch.cfg #3338

theofficialgman opened this issue May 12, 2021 · 9 comments

Comments

@theofficialgman
Copy link
Contributor

theofficialgman commented May 12, 2021

Screen is rotated with xrandr left at boot time on this system (nintendo switch)

Retropie incorrectly populates the /dev/shm/retroarch.cfg with

video_fullscreen = "true"
video_fullscreen_x = "720"
video_fullscreen_y = "1280"

the X and Y values are backwards and causes all retroarch emulators to crash with output such as

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  152 (XFree86-VidModeExtension)
  Minor opcode of failed request:  10 (XF86VidModeSwitchToMode)
  Value in failed request:  0x193
  Serial number of failed request:  31
  Current serial number in output stream:  33

reversing the X and Y values manually in this file and launching with the same command works fine
this is not an issue for display configurations where the screen is not rotated

# populate with target resolution & fullscreen flag if KMS is active


applicable code linked above

@theofficialgman
Copy link
Contributor Author

theofficialgman commented May 12, 2021

video_refresh_rate is also set incorrectly to 60 instead of the reported 59.93Hz but according to the code that is the desired function (to round to an integer)

@theofficialgman
Copy link
Contributor Author

output from xrandr --verbose to help debug the issue

Screen 0: minimum 8 x 8, current 1280 x 720, maximum 16384 x 16384
DSI-0 connected primary 1280x720+0+0 (0x18d) left (normal left inverted right x axis y axis) 0mm x 0mm
	Identifier: 0x18c
	Timestamp:  2192869
	Subpixel:   unknown
	Gamma:      1.0:1.0:1.0
	Brightness: 1.0
	Clones:    
	CRTC:       0
	CRTCs:      0
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	_MUTTER_PRESENTATION_OUTPUT: 0 
	TegraOverlayBlendmode: Opaque 
		supported: Opaque, SourceAlphaBlend, PremultSourceAlphaBlend
	TegraOverlayPriority: 255 
		range: (0, 255)
	BorderDimensions: 4 
		supported: 4
	Border: 0 0 0 0 
		range: (0, 65535)
	SignalFormat: TMDS 
		supported: TMDS
	ConnectorType: Panel 
	non-desktop: 0 
		supported: 0, 1
  720x1280 (0x18d) 77.905MHz +HSync +VSync *current +preferred
        h: width   720 start  856 end  928 total 1000 skew    0 clock  77.91KHz
        v: height 1280 start 1290 end 1291 total 1300           clock  59.93Hz
DP-0 disconnected (normal left inverted right x axis y axis)
	Identifier: 0x18e
	Timestamp:  2192869
	Subpixel:   unknown
	Clones:    
	CRTCs:      1
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	_MUTTER_PRESENTATION_OUTPUT: 0 
	TegraOverlayBlendmode: Opaque 
		supported: Opaque, SourceAlphaBlend, PremultSourceAlphaBlend
	TegraOverlayPriority: 255 
		range: (0, 255)
	BorderDimensions: 4 
		supported: 4
	Border: 0 0 0 0 
		range: (0, 65535)
	SignalFormat: DisplayPort 
		supported: DisplayPort
	ConnectorType: DisplayPort 
	non-desktop: 0 
		supported: 0, 1

@joolswills
Copy link
Member

This code was done by @psyke83 - maybe he has an idea

The code grabs the primary display and all modes supported by it then references them via the connected display ID (0x18d in this case).

Although the first reference has 1280x720 the first mode is actually 720x1280.

We might be able to workaround it by adding an option to ignore xrandr completely or swap the values based on the string "inverted" , but not sure the best fix if retroarch requires the values swapped as it would seem correct how we have them set in regards to the orientation.

@joolswills
Copy link
Member

I will need to look at the retroarch code also.

@psyke83
Copy link
Member

psyke83 commented Jun 27, 2021

I think that this part of the log signifies the orientation:

"DSI-0 connected primary 1280x720+0+0 (0x18d) left (normal left inverted right x axis y axis) 0mm x 0mm"

The possible orientation types reported by xrandr are normal, left, right and inverted. When I have time, I'll check the retroarch config to see if there's an additional setting that we need to map to handle the specific orientation type, as simply doing an x/y resolution flip may not work for everybody.

@joolswills
Copy link
Member

Thanks.

@theofficialgman
Copy link
Contributor Author

theofficialgman commented Jun 29, 2021

If I might ask, what is the reason for this functionality at all?
setting the resolution values to empty eg: video_fullscreen_x="" seems to work fine at least for my config

I will note xrandr is a mess.. you have to be careful how you get that resolution and rotation info, you can get different output depending if your xrandr backend uses v1.2 and newer commands or v1.1 older (one might say 720x1280 normal while the other will say 1280x720 left)

@theofficialgman
Copy link
Contributor Author

@psyke83 can you look at this again? still an issue

@theofficialgman
Copy link
Contributor Author

theofficialgman commented Jul 21, 2022

basically the issue is this function

function get_all_x11_modes()
{
declare -Ag MODE
local id
local line
while read -r id; do
# populate CONNECTOR:0xID into an array
MODE_ID+=($id) # output:id as in (hdmi:0x44)
read -r line
# array is x/y resolution @ vertical refresh rate ( details )
MODE[$id]="$line"
done < <( $XRANDR --verbose | awk '
# defines the type of line
# true is the "header" (output and id)
# false is the "description" (Mode: and everything that begins with a space)
{ type = /^[^ \t]+/ }
# Exit after the first output
type && output {exit} # New header and output set means new output
# many outputs can be connected, but only the ones with the id are in use.
# output must be connected and have an (id)
type && / connected/ && /\(0x[0-9a-f]+\)/ {
output=$1; next
}
# parse mode and lines
# If we are in a "description", and output is set (output being what we want)
# And if $2 is an id, we are in a video mode description line
!type && output && $2 ~ /^\(0x[0-9a-f]+\)$/ {
# Print CRTC identifier (CONNECTOR:0xID)
print output ":" substr($2,2,length($2)-2) # id
# get rid of what we printed
$1="";$2=""
sub(/^[ \t]+/,"") # trim spaces
# save rest of the line
info=$0
# Save width from the 2nd line of the video mode
getline; width=$3
# Save height & vrefresh from the 3rd line of video mode
getline; height=$3; vrefresh=$NF
# Print video mode details
print width "x" height " @ " vrefresh " (" info ")"
}
')
}

doesn't take into account rotation values left/right/inverted etc, AT ALL
all it does is report back the actual screen resolution (which doesn't factor in rotation)

here is verbose output to help with your fixing. you will need to switch to reading the resolution from the first line since this is the only correct spot to query it

Screen 0: minimum 8 x 8, current 1280 x 720, maximum 16384 x 16384
DSI-0 connected primary 1280x720+0+0 (0x18d) left (normal left inverted right x axis y axis) 0mm x 0mm
	Identifier: 0x18c
	Timestamp:  1746173
	Subpixel:   unknown
	Gamma:      1.0:1.0:1.0
	Brightness: 1.0
	Clones:    
	CRTC:       0
	CRTCs:      0
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	_MUTTER_PRESENTATION_OUTPUT: 0 
	TegraOverlayBlendmode: Opaque 
		supported: Opaque, SourceAlphaBlend, PremultSourceAlphaBlend
	TegraOverlayPriority: 255 
		range: (0, 255)
	BorderDimensions: 4 
		supported: 4
	Border: 0 0 0 0 
		range: (0, 65535)
	SignalFormat: TMDS 
		supported: TMDS
	ConnectorType: Panel 
  720x1280 (0x18d) 78.003MHz +HSync +VSync *current +preferred
        h: width   720 start  856 end  928 total 1000 skew    0 clock  78.00KHz
        v: height 1280 start 1290 end 1291 total 1300           clock  60.00Hz
DP-0 disconnected (normal left inverted right x axis y axis)
	Identifier: 0x18e
	Timestamp:  1746173
	Subpixel:   unknown
	Clones:    
	CRTCs:      1
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	_MUTTER_PRESENTATION_OUTPUT: 0 
	TegraOverlayBlendmode: Opaque 
		supported: Opaque, SourceAlphaBlend, PremultSourceAlphaBlend
	TegraOverlayPriority: 255 
		range: (0, 255)
	BorderDimensions: 4 
		supported: 4
	Border: 0 0 0 0 
		range: (0, 65535)
	SignalFormat: DisplayPort 
		supported: DisplayPort
	ConnectorType: DisplayPort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants