cairo_dri: check for 1080p mode if primary mode is 2160p

For displays where the primary mode is 2160p, check to see
if a 1080p mode exists, and if so, use it. This allows laptops
with native 4K panels to specify a 1080p video mode via kernel
command line and have fbwhiptail use that vs native resolution.

Test: boot Librem 15v4 with kernel param 'video=eDP-1:1920x1080'
Signed-off-by: Matt Devillier's avatarMatt DeVillier <matt.devillier@puri.sm>
parent e5001e92
......@@ -188,6 +188,18 @@ cairo_dri_t *cairo_dri_open(const char *dri_filename)
struct drm_mode_crtc *saved_crtc = &(device->screens[device->num_screens].saved_crtc);
device->screens[device->num_screens].conn = conn.connector_id;
device->screens[device->num_screens].mode = conn_modes[0];
/*
* HiDPI scaling for 4k laptop screens
* only enabled when 1080p video mode also set via kernel param
*/
if (conn_modes[0].vdisplay == 2160) {
/* try to find a 1080p mode */
for (i = 0; i < conn.count_modes; i++)
if (conn_modes[i].vdisplay == 1080) {
device->screens[device->num_screens].mode = conn_modes[i];
break;
}
}
device->screens[device->num_screens].crtc = crtc;
saved_crtc->crtc_id = crtc;
if (ioctl(device->dri_fd, DRM_IOCTL_MODE_GETCRTC, saved_crtc) == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment