Skip to content

Commit 99b57bb

Browse files
committed
gpu: drm: adp: base the max framebuffer width and height on screen size
This is not necessary but makes a check for non-desktop devices in Xorg's modesetting driver very simple. The intended daemon(s) for the touchbar display have no need to allocate larger than the display framebuffers (ignoring alignment). Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 0bda379 commit 99b57bb

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/gpu/drm/adp/adp_drv.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#define ADP_CTRL_VBLANK_ON 0x12
3636
#define ADP_CTRL_FIFO_ON 0x601
3737
#define ADP_SCREEN_SIZE 0x0c
38+
#define ADP_SCREEN_HSIZE GENMASK(15, 0)
39+
#define ADP_SCREEN_VSIZE GENMASK(31, 16)
3840

3941
#define ADBE_FIFO 0x10c0
4042
#define ADBE_FIFO_SYNC 0xc0000000
@@ -415,8 +417,8 @@ static int adp_get_modes(struct drm_connector *connector)
415417
size = readl(adp->fe + ADP_SCREEN_SIZE);
416418
mode = drm_mode_create(connector->dev);
417419

418-
mode->vdisplay = size >> 16;
419-
mode->hdisplay = size & 0xFFFF;
420+
mode->vdisplay = FIELD_GET(ADP_SCREEN_VSIZE, size);
421+
mode->hdisplay = FIELD_GET(ADP_SCREEN_HSIZE, size);
420422
mode->hsync_start = mode->hdisplay + 8;
421423
mode->hsync_end = mode->hsync_start + 80;
422424
mode->htotal = mode->hsync_end + 40;
@@ -464,15 +466,28 @@ static int adp_setup_mode_config(struct adp_drv_private *adp)
464466
{
465467
struct drm_device *drm = &adp->drm;
466468
int ret;
469+
u32 size;
467470

468471
ret = drmm_mode_config_init(drm);
469472
if (ret)
470473
return ret;
471474

475+
/*
476+
* Query screen size restrict the frame buffer size to the screen size
477+
* aligned to the next multiple of 64. This is not necessary but can be
478+
* used as simple check for non-desktop devices.
479+
* Xorg's modesetting driver does not care about the connector
480+
* "non-desktop" property. The max frame buffer width or height can be
481+
* easily checked and a device can be reject if the max width/height is
482+
* smaller than 120 for example.
483+
* Any touchbar daemon is not limited by this small framebuffer size.
484+
*/
485+
size = readl(adp->fe + ADP_SCREEN_SIZE);
486+
472487
drm->mode_config.min_width = 32;
473488
drm->mode_config.min_height = 32;
474-
drm->mode_config.max_width = 16384;
475-
drm->mode_config.max_height = 16384;
489+
drm->mode_config.max_width = ALIGN(FIELD_GET(ADP_SCREEN_HSIZE, size), 64);
490+
drm->mode_config.max_height = ALIGN(FIELD_GET(ADP_SCREEN_VSIZE, size), 64);
476491
drm->mode_config.preferred_depth = 24;
477492
drm->mode_config.prefer_shadow = 0;
478493
drm->mode_config.funcs = &adp_mode_config_funcs;

0 commit comments

Comments
 (0)