From patchwork Fri Mar 24 14:47:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 9642985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B7ED960327 for ; Fri, 24 Mar 2017 14:48:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABD0320700 for ; Fri, 24 Mar 2017 14:48:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A02F4223B3; Fri, 24 Mar 2017 14:48:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4907020700 for ; Fri, 24 Mar 2017 14:48:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF5676EC15; Fri, 24 Mar 2017 14:48:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0EEE46EC1D for ; Fri, 24 Mar 2017 14:48:06 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v2OEm2DT020393; Fri, 24 Mar 2017 09:48:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1490366882; bh=7eC8GC2TbfGGVbCQTBIaWpLTZQnfj8//ugb62ZncElQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=TMUYRPfPVdkDyR9EPeLG9GdBccHFAIb2gv1VUHWyaEijiL8BuyudDh9gCeXOCuqLp 1L01XKrNgNzTIaMdVBSsEOUlqIB4ZoyUdOWqof+TYZpZIUpgLX3qUHjO+jyYQdab8k cZ03p3p8X4/adHUH0k/kMUuaX4W+1C+vCw855D5U= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v2OEm2Xs023500; Fri, 24 Mar 2017 09:48:02 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Fri, 24 Mar 2017 09:48:02 -0500 Received: from jadmar.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v2OElxnk022185; Fri, 24 Mar 2017 09:48:01 -0500 From: Jyri Sarha To: Subject: [PATCH v4 1/6] drm/omap: Get rid of DRM_OMAP_NUM_CRTCS config option Date: Fri, 24 Mar 2017 16:47:51 +0200 Message-ID: X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 Cc: tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com, Jyri Sarha X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/Kconfig | 9 ------ drivers/gpu/drm/omapdrm/omap_drv.c | 59 +++++++++++--------------------------- 2 files changed, 16 insertions(+), 52 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/Kconfig b/drivers/gpu/drm/omapdrm/Kconfig index 556f81f..b3d08c5 100644 --- a/drivers/gpu/drm/omapdrm/Kconfig +++ b/drivers/gpu/drm/omapdrm/Kconfig @@ -10,15 +10,6 @@ config DRM_OMAP if DRM_OMAP -config DRM_OMAP_NUM_CRTCS - int "Number of CRTCs" - range 1 10 - default 1 if ARCH_OMAP2 || ARCH_OMAP3 - default 2 if ARCH_OMAP4 - help - Select the number of video overlays which can be used as framebuffers. - The remaining overlays are reserved for video. - source "drivers/gpu/drm/omapdrm/dss/Kconfig" source "drivers/gpu/drm/omapdrm/displays/Kconfig" diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index ad8d16c..b040f5f 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -34,11 +34,6 @@ #define DRIVER_MINOR 0 #define DRIVER_PATCHLEVEL 0 -static int num_crtc = CONFIG_DRM_OMAP_NUM_CRTCS; - -MODULE_PARM_DESC(num_crtc, "Number of overlays to use as CRTCs"); -module_param(num_crtc, int, 0600); - /* * mode config funcs */ @@ -319,7 +314,7 @@ static int omap_modeset_init(struct drm_device *dev) struct omap_dss_device *dssdev = NULL; int num_ovls = priv->dispc_ops->get_num_ovls(); int num_mgrs = priv->dispc_ops->get_num_mgrs(); - int num_crtcs; + int num_crtcs = 0; int i, id = 0; int ret; u32 possible_crtcs; @@ -331,12 +326,15 @@ static int omap_modeset_init(struct drm_device *dev) return ret; /* - * We usually don't want to create a CRTC for each manager, at least - * not until we have a way to expose private planes to userspace. - * Otherwise there would not be enough video pipes left for drm planes. - * We use the num_crtc argument to limit the number of crtcs we create. + * Let's create one CRTC for each connected DSS device if we + * have display managers and overlays (for primary planes) for + * them. */ - num_crtcs = min3(num_crtc, num_mgrs, num_ovls); + for_each_dss_dev(dssdev) + if (omapdss_device_is_connected(dssdev)) + num_crtcs++; + + num_crtcs = min3(num_crtcs, num_mgrs, num_ovls); possible_crtcs = (1 << num_crtcs) - 1; dssdev = NULL; @@ -376,11 +374,9 @@ static int omap_modeset_init(struct drm_device *dev) drm_mode_connector_attach_encoder(connector, encoder); /* - * if we have reached the limit of the crtcs we are allowed to - * create, let's not try to look for a crtc for this - * panel/encoder and onwards, we will, of course, populate the - * the possible_crtcs field for all the encoders with the final - * set of crtcs we create + * if we have reached the limit of the crtcs we can + * create, let's not try to create a crtc for this + * panel/encoder and onwards. */ if (id == num_crtcs) continue; @@ -415,33 +411,6 @@ static int omap_modeset_init(struct drm_device *dev) } /* - * we have allocated crtcs according to the need of the panels/encoders, - * adding more crtcs here if needed - */ - for (; id < num_crtcs; id++) { - - /* find a free manager for this crtc */ - for (i = 0; i < num_mgrs; i++) { - if (!channel_used(dev, i)) - break; - } - - if (i == num_mgrs) { - /* this shouldn't really happen */ - dev_err(dev->dev, "no managers left for crtc\n"); - return -ENOMEM; - } - - ret = omap_modeset_create_crtc(dev, id, i, - possible_crtcs); - if (ret < 0) { - dev_err(dev->dev, - "could not create CRTC (channel %u)\n", i); - return ret; - } - } - - /* * Create normal planes for the remaining overlays: */ for (; id < num_ovls; id++) { @@ -456,6 +425,10 @@ static int omap_modeset_init(struct drm_device *dev) priv->planes[priv->num_planes++] = plane; } + /* + * populate the the possible_crtcs field for all the encoders + * we created. + */ for (i = 0; i < priv->num_encoders; i++) { struct drm_encoder *encoder = priv->encoders[i]; struct omap_dss_device *dssdev =