|
36 | 36 | #define ADP_CTRL_VBLANK_ON 0x12 |
37 | 37 | #define ADP_CTRL_FIFO_ON 0x601 |
38 | 38 | #define ADP_SCREEN_SIZE 0x0c |
| 39 | +#define ADP_SCREEN_HSIZE GENMASK(15, 0) |
| 40 | +#define ADP_SCREEN_VSIZE GENMASK(31, 16) |
39 | 41 |
|
40 | 42 | #define ADBE_FIFO 0x10c0 |
41 | 43 | #define ADBE_FIFO_SYNC 0xc0000000 |
@@ -416,8 +418,8 @@ static int adp_get_modes(struct drm_connector *connector) |
416 | 418 | size = readl(adp->fe + ADP_SCREEN_SIZE); |
417 | 419 | mode = drm_mode_create(connector->dev); |
418 | 420 |
|
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); |
421 | 423 | mode->hsync_start = mode->hdisplay + 8; |
422 | 424 | mode->hsync_end = mode->hsync_start + 80; |
423 | 425 | mode->htotal = mode->hsync_end + 40; |
@@ -465,15 +467,28 @@ static int adp_setup_mode_config(struct adp_drv_private *adp) |
465 | 467 | { |
466 | 468 | struct drm_device *drm = &adp->drm; |
467 | 469 | int ret; |
| 470 | + u32 size; |
468 | 471 |
|
469 | 472 | ret = drmm_mode_config_init(drm); |
470 | 473 | if (ret) |
471 | 474 | return ret; |
472 | 475 |
|
| 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 | + |
473 | 488 | drm->mode_config.min_width = 32; |
474 | 489 | 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); |
477 | 492 | drm->mode_config.preferred_depth = 24; |
478 | 493 | drm->mode_config.prefer_shadow = 0; |
479 | 494 | drm->mode_config.funcs = &adp_mode_config_funcs; |
|
0 commit comments