From patchwork Wed Mar 21 10:08:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 10299037 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 C6207602B3 for ; Wed, 21 Mar 2018 10:08:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5F0228CF1 for ; Wed, 21 Mar 2018 10:08:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA9AE297A0; Wed, 21 Mar 2018 10:08:43 +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 AEDDD28CF1 for ; Wed, 21 Mar 2018 10:08:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 65B1D6E8D5; Wed, 21 Mar 2018 10:08:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllnx210.ext.ti.com (fllnx210.ext.ti.com [198.47.19.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id C71406E8D5 for ; Wed, 21 Mar 2018 10:08:37 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w2LA8Ztm011790; Wed, 21 Mar 2018 05:08:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1521626915; bh=174Ftr1DIqx6sk2ygky2BZvJaZNSOslGYfG4B8EoXnw=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YlksFwKo2JVfuqZ/7qf8QB/6cVVqMTi9EvaXKu+HRDefyXMImtM4Xcf1JO6mFNjDy KGfvSV9lmentG2frsx7mrDtLPhkioK6z2FI/Zx2/zzM7Vhjk4d3sBVLZ9UxCui1CAB VjFnGKZykMWiRrLAz6pIJ74uRxk3+lqmUliv669w= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2LA8Z0Z010356; Wed, 21 Mar 2018 05:08:35 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 21 Mar 2018 05:08:34 -0500 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.1261.35 via Frontend Transport; Wed, 21 Mar 2018 05:08:34 -0500 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 w2LA8O1f013726; Wed, 21 Mar 2018 05:08:33 -0500 From: Peter Ujfalusi To: , Subject: [PATCH v2 4/6] drm/omap: Do dss_device (display) ordering in omap_drv.c Date: Wed, 21 Mar 2018 12:08:29 +0200 Message-ID: <20180321100831.12716-5-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180321100831.12716-1-peter.ujfalusi@ti.com> References: <20180321100831.12716-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: airlied@linux.ie, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Sort the dssdev array based on DT aliases. With this change we can remove the panel ordering from dss/display.c and have all sorting related to dssdevs in one place. Signed-off-by: Peter Ujfalusi --- drivers/gpu/drm/omapdrm/dss/display.c | 2 ++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 + drivers/gpu/drm/omapdrm/omap_drv.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c index 424143128cd4..3ef99f344bd3 100644 --- a/drivers/gpu/drm/omapdrm/dss/display.c +++ b/drivers/gpu/drm/omapdrm/dss/display.c @@ -52,6 +52,8 @@ int omapdss_register_display(struct omap_dss_device *dssdev) if (id < 0) id = disp_num_counter++; + dssdev->alias_id = id; + snprintf(dssdev->alias, sizeof(dssdev->alias), "display%d", id); /* Use 'label' property for name, if it exists */ diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 14d74adb13fb..d1056d0d32c2 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -467,6 +467,7 @@ struct omap_dss_device { /* alias in the form of "display%d" */ char alias[16]; + int alias_id; enum omap_display_type type; enum omap_display_type output_type; diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 2cd2349622a9..65666e946799 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -15,6 +15,8 @@ * this program. If not, see . */ +#include +#include #include #include @@ -165,6 +167,18 @@ static void omap_disconnect_dssdevs(struct drm_device *ddev) priv->num_dssdevs = 0; } +static int omap_compare_dssdevs(const void *a, const void *b) +{ + const struct omap_dss_device *dssdev1 = *(struct omap_dss_device **)a; + const struct omap_dss_device *dssdev2 = *(struct omap_dss_device **)b; + + if (dssdev1->alias_id > dssdev2->alias_id) + return 1; + else if (dssdev1->alias_id < dssdev2->alias_id) + return -1; + return 0; +} + static void omap_collect_dssdevs(struct drm_device *ddev) { struct omap_drm_private *priv = ddev->dev_private; @@ -179,6 +193,10 @@ static void omap_collect_dssdevs(struct drm_device *ddev) break; } } + + /* Sort the list by DT aliases */ + sort(priv->dssdevs, priv->num_dssdevs, sizeof(priv->dssdevs[0]), + omap_compare_dssdevs, NULL); } static int omap_connect_dssdevs(struct drm_device *ddev)