Skip to content

Commit a79f40c

Browse files
achrisanmlankhorst
authored andcommitted
drm/kmb: Limit supported mode to 1080p
KMB only supports single resolution(1080p), this commit checks for 1920x1080x60 or 1920x1080x59 in crtc_mode_valid. Also, modes with vfp < 4 are not supported in KMB display. This change prunes display modes with vfp < 4. v2: added vfp check Fixes: 7f7b96a ("drm/kmb: Add support for KeemBay Display") Co-developed-by: Edmund Dea <[email protected]> Signed-off-by: Edmund Dea <[email protected]> Signed-off-by: Anitha Chrisanthus <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Link:https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Maarten Lankhorst <[email protected]>
1 parent 3e4c31e commit a79f40c

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

drivers/gpu/drm/kmb/kmb_crtc.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,45 @@ static void kmb_crtc_atomic_flush(struct drm_crtc *crtc,
185185
spin_unlock_irq(&crtc->dev->event_lock);
186186
}
187187

188+
static enum drm_mode_status
189+
kmb_crtc_mode_valid(struct drm_crtc *crtc,
190+
const struct drm_display_mode *mode)
191+
{
192+
int refresh;
193+
struct drm_device *dev = crtc->dev;
194+
int vfp = mode->vsync_start - mode->vdisplay;
195+
196+
if (mode->vdisplay < KMB_CRTC_MAX_HEIGHT) {
197+
drm_dbg(dev, "height = %d less than %d",
198+
mode->vdisplay, KMB_CRTC_MAX_HEIGHT);
199+
return MODE_BAD_VVALUE;
200+
}
201+
if (mode->hdisplay < KMB_CRTC_MAX_WIDTH) {
202+
drm_dbg(dev, "width = %d less than %d",
203+
mode->hdisplay, KMB_CRTC_MAX_WIDTH);
204+
return MODE_BAD_HVALUE;
205+
}
206+
refresh = drm_mode_vrefresh(mode);
207+
if (refresh < KMB_MIN_VREFRESH || refresh > KMB_MAX_VREFRESH) {
208+
drm_dbg(dev, "refresh = %d less than %d or greater than %d",
209+
refresh, KMB_MIN_VREFRESH, KMB_MAX_VREFRESH);
210+
return MODE_BAD;
211+
}
212+
213+
if (vfp < KMB_CRTC_MIN_VFP) {
214+
drm_dbg(dev, "vfp = %d less than %d", vfp, KMB_CRTC_MIN_VFP);
215+
return MODE_BAD;
216+
}
217+
218+
return MODE_OK;
219+
}
220+
188221
static const struct drm_crtc_helper_funcs kmb_crtc_helper_funcs = {
189222
.atomic_begin = kmb_crtc_atomic_begin,
190223
.atomic_enable = kmb_crtc_atomic_enable,
191224
.atomic_disable = kmb_crtc_atomic_disable,
192225
.atomic_flush = kmb_crtc_atomic_flush,
226+
.mode_valid = kmb_crtc_mode_valid,
193227
};
194228

195229
int kmb_setup_crtc(struct drm_device *drm)

drivers/gpu/drm/kmb/kmb_drv.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@
2020
#define DRIVER_MAJOR 1
2121
#define DRIVER_MINOR 1
2222

23+
/* Platform definitions */
24+
#define KMB_CRTC_MIN_VFP 4
25+
#define KMB_CRTC_MAX_WIDTH 1920 /* max width in pixels */
26+
#define KMB_CRTC_MAX_HEIGHT 1080 /* max height in pixels */
27+
#define KMB_CRTC_MIN_WIDTH 1920
28+
#define KMB_CRTC_MIN_HEIGHT 1080
2329
#define KMB_FB_MAX_WIDTH 1920
2430
#define KMB_FB_MAX_HEIGHT 1080
2531
#define KMB_FB_MIN_WIDTH 1
2632
#define KMB_FB_MIN_HEIGHT 1
27-
33+
#define KMB_MIN_VREFRESH 59 /*vertical refresh in Hz */
34+
#define KMB_MAX_VREFRESH 60 /*vertical refresh in Hz */
2835
#define KMB_LCD_DEFAULT_CLK 200000000
2936
#define KMB_SYS_CLK_MHZ 500
3037

0 commit comments

Comments
 (0)