Skip to content

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

@seriyps

Description

@seriyps

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;
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions