aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJyri Sarha <jsarha@ti.com>2017-03-24 10:47:51 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-04-03 05:36:40 -0400
commitf1118b893e65ada7845c587f4682b153ea40e2ad (patch)
tree9bc45ef4c337a61c85fb99858455b92964ffe083
parentc9af3ed7311f5fbc4b0e109daddfcc8a47267331 (diff)
drm/omap: Get rid of DRM_OMAP_NUM_CRTCS config option
Allocate one CRTC for each connected output and get rid of DRM_OMAP_NUM_CRTCS config option. We still can not create more CRTCs than we have DSS display managers. We also reserve one overlay per CRTC for primary plane so we can not have more CRTCs than we have overlays either. Signed-off-by: Jyri Sarha <jsarha@ti.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/gpu/drm/omapdrm/Kconfig9
-rw-r--r--drivers/gpu/drm/omapdrm/omap_drv.c59
2 files changed, 16 insertions, 52 deletions
diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig
index 556f81f6b2c7..b3d08c5f41d4 100644
--- a/drivers/gpu/drm/omapdrm/Kconfig
+++ b/drivers/gpu/drm/omapdrm/Kconfig
@@ -10,15 +10,6 @@ config DRM_OMAP
10 10
11if DRM_OMAP 11if DRM_OMAP
12 12
13config DRM_OMAP_NUM_CRTCS
14 int "Number of CRTCs"
15 range 1 10
16 default 1 if ARCH_OMAP2 || ARCH_OMAP3
17 default 2 if ARCH_OMAP4
18 help
19 Select the number of video overlays which can be used as framebuffers.
20 The remaining overlays are reserved for video.
21
22source "drivers/gpu/drm/omapdrm/dss/Kconfig" 13source "drivers/gpu/drm/omapdrm/dss/Kconfig"
23source "drivers/gpu/drm/omapdrm/displays/Kconfig" 14source "drivers/gpu/drm/omapdrm/displays/Kconfig"
24 15
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c
index 7b917c0c1a27..a8927cfebdac 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -34,11 +34,6 @@
34#define DRIVER_MINOR 0 34#define DRIVER_MINOR 0
35#define DRIVER_PATCHLEVEL 0 35#define DRIVER_PATCHLEVEL 0
36 36
37static int num_crtc = CONFIG_DRM_OMAP_NUM_CRTCS;
38
39MODULE_PARM_DESC(num_crtc, "Number of overlays to use as CRTCs");
40module_param(num_crtc, int, 0600);
41
42/* 37/*
43 * mode config funcs 38 * mode config funcs
44 */ 39 */
@@ -319,7 +314,7 @@ static int omap_modeset_init(struct drm_device *dev)
319 struct omap_dss_device *dssdev = NULL; 314 struct omap_dss_device *dssdev = NULL;
320 int num_ovls = priv->dispc_ops->get_num_ovls(); 315 int num_ovls = priv->dispc_ops->get_num_ovls();
321 int num_mgrs = priv->dispc_ops->get_num_mgrs(); 316 int num_mgrs = priv->dispc_ops->get_num_mgrs();
322 int num_crtcs; 317 int num_crtcs = 0;
323 int i, id = 0; 318 int i, id = 0;
324 int ret; 319 int ret;
325 u32 possible_crtcs; 320 u32 possible_crtcs;
@@ -331,12 +326,15 @@ static int omap_modeset_init(struct drm_device *dev)
331 return ret; 326 return ret;
332 327
333 /* 328 /*
334 * We usually don't want to create a CRTC for each manager, at least 329 * Let's create one CRTC for each connected DSS device if we
335 * not until we have a way to expose private planes to userspace. 330 * have display managers and overlays (for primary planes) for
336 * Otherwise there would not be enough video pipes left for drm planes. 331 * them.
337 * We use the num_crtc argument to limit the number of crtcs we create.
338 */ 332 */
339 num_crtcs = min3(num_crtc, num_mgrs, num_ovls); 333 for_each_dss_dev(dssdev)
334 if (omapdss_device_is_connected(dssdev))
335 num_crtcs++;
336
337 num_crtcs = min3(num_crtcs, num_mgrs, num_ovls);
340 possible_crtcs = (1 << num_crtcs) - 1; 338 possible_crtcs = (1 << num_crtcs) - 1;
341 339
342 dssdev = NULL; 340 dssdev = NULL;
@@ -376,11 +374,9 @@ static int omap_modeset_init(struct drm_device *dev)
376 drm_mode_connector_attach_encoder(connector, encoder); 374 drm_mode_connector_attach_encoder(connector, encoder);
377 375
378 /* 376 /*
379 * if we have reached the limit of the crtcs we are allowed to 377 * if we have reached the limit of the crtcs we can
380 * create, let's not try to look for a crtc for this 378 * create, let's not try to create a crtc for this
381 * panel/encoder and onwards, we will, of course, populate the 379 * panel/encoder and onwards.
382 * the possible_crtcs field for all the encoders with the final
383 * set of crtcs we create
384 */ 380 */
385 if (id == num_crtcs) 381 if (id == num_crtcs)
386 continue; 382 continue;
@@ -415,33 +411,6 @@ static int omap_modeset_init(struct drm_device *dev)
415 } 411 }
416 412
417 /* 413 /*
418 * we have allocated crtcs according to the need of the panels/encoders,
419 * adding more crtcs here if needed
420 */
421 for (; id < num_crtcs; id++) {
422
423 /* find a free manager for this crtc */
424 for (i = 0; i < num_mgrs; i++) {
425 if (!channel_used(dev, i))
426 break;
427 }
428
429 if (i == num_mgrs) {
430 /* this shouldn't really happen */
431 dev_err(dev->dev, "no managers left for crtc\n");
432 return -ENOMEM;
433 }
434
435 ret = omap_modeset_create_crtc(dev, id, i,
436 possible_crtcs);
437 if (ret < 0) {
438 dev_err(dev->dev,
439 "could not create CRTC (channel %u)\n", i);
440 return ret;
441 }
442 }
443
444 /*
445 * Create normal planes for the remaining overlays: 414 * Create normal planes for the remaining overlays:
446 */ 415 */
447 for (; id < num_ovls; id++) { 416 for (; id < num_ovls; id++) {
@@ -456,6 +425,10 @@ static int omap_modeset_init(struct drm_device *dev)
456 priv->planes[priv->num_planes++] = plane; 425 priv->planes[priv->num_planes++] = plane;
457 } 426 }
458 427
428 /*
429 * populate the the possible_crtcs field for all the encoders
430 * we created.
431 */
459 for (i = 0; i < priv->num_encoders; i++) { 432 for (i = 0; i < priv->num_encoders; i++) {
460 struct drm_encoder *encoder = priv->encoders[i]; 433 struct drm_encoder *encoder = priv->encoders[i];
461 struct omap_dss_device *dssdev = 434 struct omap_dss_device *dssdev =