From patchwork Fri Dec 1 13:23:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 10087073 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 434C0603B4 for ; Fri, 1 Dec 2017 13:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B6B62A525 for ; Fri, 1 Dec 2017 13:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 100B92A52C; Fri, 1 Dec 2017 13:23:56 +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 7FBCD2A525 for ; Fri, 1 Dec 2017 13:23:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 25A1F6ED39; Fri, 1 Dec 2017 13:23:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllnx209.ext.ti.com (fllnx209.ext.ti.com [198.47.19.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4EE7A6ED39 for ; Fri, 1 Dec 2017 13:23:54 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id vB1DNGhN029994; Fri, 1 Dec 2017 07:23:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1512134596; bh=anB6KtdAqEtIH4Au0igtM8CZjWQbXI7q8WMLrzks7oE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=GrFG+24/2X7Zk9CWwnlbropTrnf+TPu69GBRjZ5RVNMqhvSEa+o7aMI2NNmhgF+rd QtvpXWNd9RWEZU/1jVPmY45oluSf0gvk+vD/TzNcqE7ajmgI6eNl2d0Nb9w+LWqLRW RzVnTSfn+hP2fpNyjiLpnVn5f2Vorwn0BDktLV9w= Received: from DLEE103.ent.ti.com (dlee103.ent.ti.com [157.170.170.33]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id vB1DNBJu010043; Fri, 1 Dec 2017 07:23:11 -0600 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Fri, 1 Dec 2017 07:23:11 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Fri, 1 Dec 2017 07:23:11 -0600 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id vB1DMrHR028773; Fri, 1 Dec 2017 07:23:09 -0600 From: Peter Ujfalusi To: , Subject: [PATCH 7/7] drm/omap: Add kernel parameter to specify the desired display order Date: Fri, 1 Dec 2017 15:23:44 +0200 Message-ID: <20171201132344.13450-8-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171201132344.13450-1-peter.ujfalusi@ti.com> References: <20171201132344.13450-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: airlied@linux.ie, jsarha@ti.com, dri-devel@lists.freedesktop.org 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 omapdrm.displays (int array) can be used to reorder the displays by id if needed. It can be also used to disable display. If the board have two active displays: 0 - LCD 1 - HDMI then: omapdrm.displays=0,1 - represents the original order (LCD, HDMI) omapdrm.displays=1,0 - represents reverse order (HDMI, LCD) omapdrm.displays=0 - only the LCD is enabled omapdrm.displays=1 - only the HDMI is enabled omapdrm.displays=-1 - disable all displays Signed-off-by: Peter Ujfalusi --- drivers/gpu/drm/omapdrm/omap_drv.c | 55 +++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 4e58343d5db2..4604ad36d566 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -36,6 +36,14 @@ #define DRIVER_MINOR 0 #define DRIVER_PATCHLEVEL 0 +#define MAX_NR_DISPLAYS 8 +static int display_order[MAX_NR_DISPLAYS]; +static int display_order_nelm; +module_param_array_named(displays, display_order, int, &display_order_nelm, + 0444); +MODULE_PARM_DESC(displays, + "ID array to specify the order of the active displays"); + /* * mode config funcs */ @@ -192,12 +200,21 @@ static int omap_compare_dssdevs(const void *a, const void *b) static void omap_collect_dssdevs(struct drm_device *ddev) { struct omap_drm_private *priv = ddev->dev_private; + struct omap_dss_device *dssdevs[ARRAY_SIZE(priv->dssdevs)]; struct omap_dss_device *dssdev = NULL; + int num_dssdevs = 0; + unsigned long dssdev_mask = 0; + int i; + + /* No displays should be enabled */ + if (display_order_nelm == 1 && display_order[0] < 0) + return; for_each_dss_dev(dssdev) { omap_dss_get_device(dssdev); - priv->dssdevs[priv->num_dssdevs++] = dssdev; - if (priv->num_dssdevs == ARRAY_SIZE(priv->dssdevs)) { + set_bit(num_dssdevs, &dssdev_mask); + dssdevs[num_dssdevs++] = dssdev; + if (num_dssdevs == ARRAY_SIZE(dssdevs)) { /* To balance the 'for_each_dss_dev' loop */ omap_dss_put_device(dssdev); break; @@ -205,8 +222,38 @@ static void omap_collect_dssdevs(struct drm_device *ddev) } /* Sort the list by DT aliases */ - sort(priv->dssdevs, priv->num_dssdevs, sizeof(priv->dssdevs[0]), - omap_compare_dssdevs, NULL); + sort(dssdevs, num_dssdevs, sizeof(dssdevs[0]), omap_compare_dssdevs, + NULL); + + /* Do ordering based on the display_order parameter array */ + for (i = 0; i < display_order_nelm; i++) { + int old_index = display_order[i]; + + if ((old_index >= 0 && old_index < num_dssdevs) && + (dssdev_mask & BIT(old_index))) { + priv->dssdevs[priv->num_dssdevs++] = dssdevs[old_index]; + clear_bit(old_index, &dssdev_mask); + } else { + dev_err(ddev->dev, + "Ignoring invalid displays module parameter\n"); + priv->num_dssdevs = 0; + break; + } + } + + /* if the target list is empty, copy the collected dssdevs, if any */ + if (priv->num_dssdevs == 0) { + for (i = 0; i < num_dssdevs; i++) + priv->dssdevs[i] = dssdevs[i]; + + priv->num_dssdevs = num_dssdevs; + } else { + u32 idx; + + /* check if we have dssdev which is not carried over */ + for_each_set_bit(idx, &dssdev_mask, ARRAY_SIZE(dssdevs)) + omap_dss_put_device(dssdevs[idx]); + } } static int omap_connect_dssdevs(struct drm_device *ddev)