From patchwork Tue Aug 29 07:32:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 9926815 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 3F5C360380 for ; Tue, 29 Aug 2017 07:51:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F7F228877 for ; Tue, 29 Aug 2017 07:51:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 245272888C; Tue, 29 Aug 2017 07:51: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 A4B4528877 for ; Tue, 29 Aug 2017 07:51:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F0E66E372; Tue, 29 Aug 2017 07:51:09 +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 07B4F6E372 for ; Tue, 29 Aug 2017 07:51:07 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v7T7W6tZ030233; Tue, 29 Aug 2017 02:32:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1503991926; bh=R7tIalCqwtpPlYB6EG7NDSdh2nN4yH2FtrgEV4/a3g8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BcHhvDs/KgmS37KLolXsN3gW5QU4otWIoUsyH/v3QZKDUVNupcCZuzSbnSFLAJTq6 lc1e5Bizq1wmRgm8AlL7sp3NAgRgN6hjJ6Fj8vaJ914AeryuXv/UdX7+veUb940Sak rZ9QYt+x5TOR9GAJaCW8e2odDvoXGgECiYR+rZoc= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v7T7W68t016517; Tue, 29 Aug 2017 02:32:06 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Tue, 29 Aug 2017 02:32:05 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Tue, 29 Aug 2017 02:32:05 -0500 Received: from feketebors.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 v7T7VsJc020217; Tue, 29 Aug 2017 02:32:04 -0500 From: Peter Ujfalusi To: , , Subject: [RFC 5/7] drm/omap: Do dss_device (display) ordering in omap_drv.c Date: Tue, 29 Aug 2017 10:32:16 +0300 Message-ID: <20170829073218.11097-6-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170829073218.11097-1-peter.ujfalusi@ti.com> References: <20170829073218.11097-1-peter.ujfalusi@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: 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 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/omap_drv.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 32dc0e88220f..0e100a359d26 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -18,6 +18,8 @@ */ #include +#include +#include #include #include @@ -162,6 +164,22 @@ 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; + int id1, id2; + + id1 = of_alias_get_id(dssdev1->dev->of_node, "display"); + id2 = of_alias_get_id(dssdev2->dev->of_node, "display"); + + if (id1 > id2) + return 1; + else if (id1 < id2) + return -1; + return 0; +} + static void omap_collect_dssdevs(struct drm_device *ddev) { struct omap_drm_private *priv = ddev->dev_private; @@ -176,6 +194,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)