diff options
author | Enrico Jorns <ejo@pengutronix.de> | 2016-01-08 15:07:13 +0100 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2016-01-08 17:33:01 +0100 |
commit | 13831afd261b7d91b2241634d59004d62999c2ce (patch) | |
tree | 745ac561153c0a61aeee21c1ba216cbb4ee529ae | |
parent | 909c7a26bb934f1c6a0265bbddfec72efe53879a (diff) | |
download | kmsfbwrap-13831afd261b7d91b2241634d59004d62999c2ce.tar.gz kmsfbwrap-13831afd261b7d91b2241634d59004d62999c2ce.tar.xz |
fix calculation in drm_find_max_res()
xres and yres were tested and assigned separately. Thus the largest x
and y resolution was found, but this does not assure that a mode exists
with this x and y resolution.
The new calculation is based on multiplying x and y resolution and
comparing the number of pixels to find the maximum available resolution.
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
-rw-r--r-- | src/kmsfb-manage.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/kmsfb-manage.c b/src/kmsfb-manage.c index 7ad6823..4f7f917 100644 --- a/src/kmsfb-manage.c +++ b/src/kmsfb-manage.c @@ -265,14 +265,21 @@ static struct drm_connector *drm_find_connector(struct drm_resource *res, int co static void drm_find_max_res(struct drm_resource *res, uint32_t *xres, uint32_t *yres) { int i, j; + uint32_t maxpix = 0; for (i = 0; i < res->num_connectors; i++) { struct drm_connector *con = &res->connectors[i]; for (j = 0; j < con->num_modes; j++) { struct drm_mode_modeinfo *mode = &con->modes[j]; - if (xres && *xres < mode->hdisplay) + uint32_t pixnum = mode->hdisplay * mode->vdisplay; + + if (pixnum <= maxpix) + continue; + + maxpix = pixnum; + if (xres) *xres = mode->hdisplay; - if (yres && *yres < mode->vdisplay) + if (yres) *yres = mode->vdisplay; } } |