aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/omapdrm/omap_crtc.c
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2017-11-30 07:12:37 -0500
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-12-19 03:32:00 -0500
commita7631c4b9846a433c06422c6cc64a8a5025071a2 (patch)
tree087a97ad01bba924654ababf81dea02302d521da /drivers/gpu/drm/omapdrm/omap_crtc.c
parent867d7e0212170a24f0889e940a5b05ee34551e27 (diff)
drm/omap: Filter displays mode based on bandwidth limit
If we have memory bandwidth limit configured, reject the modes which would require more bandwidth than the limit if it is used with one full resolution plane (most common use case). This filtering is not providing full protection as it is possible that application would pick smaller crtc resolution with high resolution planes and down scaling, or can enable more smaller planes where the sum of their bandwidth need would be higher than the limit. This patch only allows us to filter out modes which would need more bandwidth if they were used with one full screen plane. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/gpu/drm/omapdrm/omap_crtc.c')
-rw-r--r--drivers/gpu/drm/omapdrm/omap_crtc.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c b/drivers/gpu/drm/omapdrm/omap_crtc.c
index cc85c16cbc2a..ae2e16ed3874 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -23,6 +23,7 @@
23#include <drm/drm_crtc_helper.h> 23#include <drm/drm_crtc_helper.h>
24#include <drm/drm_mode.h> 24#include <drm/drm_mode.h>
25#include <drm/drm_plane_helper.h> 25#include <drm/drm_plane_helper.h>
26#include <linux/math64.h>
26 27
27#include "omap_drv.h" 28#include "omap_drv.h"
28 29
@@ -400,6 +401,41 @@ static void omap_crtc_atomic_disable(struct drm_crtc *crtc,
400 drm_crtc_vblank_off(crtc); 401 drm_crtc_vblank_off(crtc);
401} 402}
402 403
404static enum drm_mode_status omap_crtc_mode_valid(struct drm_crtc *crtc,
405 const struct drm_display_mode *mode)
406{
407 struct omap_drm_private *priv = crtc->dev->dev_private;
408
409 /* Check for bandwidth limit */
410 if (priv->max_bandwidth) {
411 /*
412 * Estimation for the bandwidth need of a given mode with one
413 * full screen plane:
414 * bandwidth = resolution * 32bpp * (pclk / (vtotal * htotal))
415 * ^^ Refresh rate ^^
416 *
417 * The interlaced mode is taken into account by using the
418 * pixelclock in the calculation.
419 *
420 * The equation is rearranged for 64bit arithmetic.
421 */
422 uint64_t bandwidth = mode->clock * 1000;
423 unsigned int bpp = 4;
424
425 bandwidth = bandwidth * mode->hdisplay * mode->vdisplay * bpp;
426 bandwidth = div_u64(bandwidth, mode->htotal * mode->vtotal);
427
428 /*
429 * Reject modes which would need more bandwidth if used with one
430 * full resolution plane (most common use case).
431 */
432 if (priv->max_bandwidth < bandwidth)
433 return MODE_BAD;
434 }
435
436 return MODE_OK;
437}
438
403static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc) 439static void omap_crtc_mode_set_nofb(struct drm_crtc *crtc)
404{ 440{
405 struct omap_crtc *omap_crtc = to_omap_crtc(crtc); 441 struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
@@ -621,6 +657,7 @@ static const struct drm_crtc_helper_funcs omap_crtc_helper_funcs = {
621 .atomic_flush = omap_crtc_atomic_flush, 657 .atomic_flush = omap_crtc_atomic_flush,
622 .atomic_enable = omap_crtc_atomic_enable, 658 .atomic_enable = omap_crtc_atomic_enable,
623 .atomic_disable = omap_crtc_atomic_disable, 659 .atomic_disable = omap_crtc_atomic_disable,
660 .mode_valid = omap_crtc_mode_valid,
624}; 661};
625 662
626/* ----------------------------------------------------------------------------- 663/* -----------------------------------------------------------------------------