Skip to content

Commit 98e8dbc

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 7bd4ae4 commit 98e8dbc

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

drivers/gpu/drm/adp/adp_drv.c

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

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

419-
mode->vdisplay = size >> 16;
420-
mode->hdisplay = size & 0xFFFF;
421+
mode->vdisplay = FIELD_GET(ADP_SCREEN_VSIZE, size);
422+
mode->hdisplay = FIELD_GET(ADP_SCREEN_HSIZE, size);
421423
mode->hsync_start = mode->hdisplay + 8;
422424
mode->hsync_end = mode->hsync_start + 80;
423425
mode->htotal = mode->hsync_end + 40;
@@ -465,15 +467,28 @@ static int adp_setup_mode_config(struct adp_drv_private *adp)
465467
{
466468
struct drm_device *drm = &adp->drm;
467469
int ret;
470+
u32 size;
468471

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

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

0 commit comments

Comments
 (0)