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

Select closest matching display resolution if requested by user is not available #13

Open
seriyps opened this issue Oct 4, 2024 · 2 comments

Comments

@seriyps
Copy link
Collaborator

seriyps commented Oct 4, 2024

I think in case none of the resolutions supported by connected monitor matches exactly the value of --screen-mode, I think it might be better to anyway select one of the resolutions that is the closest one to the requested one and use it instead of crashing?

Eg, if user requests --screen-mode 1920x1080@60 but the supported resolutions are

9 : 1920x1080@30
12 : 1920x1080@24
13 : 1600x1200@60
14 : 1680x1050@60
15 : 1280x1024@75
16 : 1280x1024@60
17 : 1152x864@75

pixelpilot should select the closest one, eg, 1920x1080@24.

The way heuristics may work is by finding the minimum of the abs( (mode_width - hdisplay) + (mode_height - hdisplay) + (mode_vrefresh - vrefresh) ) here

PixelPilot_rk/src/drm.c

Lines 441 to 450 in 4579eda

printf( "Available modes:\n");
for (int i = 0; i < conn->count_modes; i++ ) {
printf( "%d : %dx%d@%d\n",i, conn->modes[i].hdisplay, conn->modes[i].vdisplay , conn->modes[i].vrefresh );
if (conn->modes[i].hdisplay == mode_width &&
conn->modes[i].vdisplay == mode_height &&
conn->modes[i].vrefresh == mode_vrefresh
) {
fc = i;
}
}

@seriyps
Copy link
Collaborator Author

seriyps commented Oct 4, 2024

Or it might be not the best idea actually - to give user not what they explicitly asked. Given that we already have "flexible" solution: if --screen-mode is not provided, pixelpilot selects the 1st resolution that it detects...

@zhouruixi
Copy link

I think the --screen-mode setting should be determined by the PixelPilot_rk startup script. Imagine that when I set a resolution, the program starts normally, but the resolution is not what I set. This is very strange. Generally, when passing unsupported parameters to a program, the program should give a prompt that it does not support the parameter, rather than trying to correct it.

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

2 participants