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