From patchwork Fri Mar 2 13:48:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Parrot X-Patchwork-Id: 10254757 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 9EA0D60211 for ; Fri, 2 Mar 2018 14:14:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E376289A5 for ; Fri, 2 Mar 2018 14:14:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 815D3289AA; Fri, 2 Mar 2018 14:14:52 +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 167A5289A5 for ; Fri, 2 Mar 2018 14:14:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64AD06E01A; Fri, 2 Mar 2018 14:14:48 +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 767406E015 for ; Fri, 2 Mar 2018 14:14:47 +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 w22DmKOk004936; Fri, 2 Mar 2018 07:48:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519998500; bh=i3c6nIJ+J9eLhTX4wUiLG/i1Kh2F+piZijpq2mLWzu0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=EZe7AliqokJPI/m2iREKFsUNu0dmtwHOY2WnNPvPmcwJX3V9Oj6QOgAXncMWz2cl2 H1yjBRixTslqpH0+JzsYXuUI8+/zR0+XPaVqv+AWeSHdInzIrC9s/PSWkbOZoY4w1V mw1BQz9HG0RBCfWlQk9VLn4S8YsKC6q/xWzBQjUk= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w22DmKbV029114; Fri, 2 Mar 2018 07:48:20 -0600 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Fri, 2 Mar 2018 07:48:20 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Fri, 2 Mar 2018 07:48:20 -0600 Received: from uda0869644a.dhcp.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 w22DmE5g032677; Fri, 2 Mar 2018 07:48:20 -0600 From: Benoit Parrot To: , Laurent Pinchart , , Rob Herring Subject: [Patch 3/4] drm/omap: Add virtual plane DT parsing support Date: Fri, 2 Mar 2018 07:48:03 -0600 Message-ID: <20180302134804.3690-4-bparrot@ti.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180302134804.3690-1-bparrot@ti.com> References: <20180302134804.3690-1-bparrot@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: Peter Ujfalusi , Tomi Valkeinen , Jyri Sarha Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Virtual planes are used to extend display size capability for display larger than 2048 pixels by splitting the frame buffer equally between two physical planes. Here we are adding DT support to parse 'plane' child nodes which describe how logical planes are mapped to physical plane(s) and which crtc they are available on. Signed-off-by: Benoit Parrot --- drivers/gpu/drm/omapdrm/dss/dispc.c | 110 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/omapdrm/dss/omapdss.h | 11 ++++ 2 files changed, 121 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 624dee22f46b..559b70d9762d 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -4334,6 +4334,115 @@ static u32 dispc_get_memory_bandwidth_limit(void) return limit; } +static struct device_node *dispc_of_get_plane_by_id(struct device_node *node, + u32 id) +{ + struct device_node *plane; + + for_each_child_of_node(node, plane) { + u32 plane_id = 0; + + if (of_node_cmp(plane->name, "plane") != 0) + continue; + of_property_read_u32(plane, "reg", &plane_id); + if (id == plane_id) + break; + } + + return plane; +} + +static int dispc_parse_dt_plane_data(struct dispc_plane_mappings *plane) +{ + struct platform_device *pdev = dispc.pdev; + struct device_node *np = pdev->dev.of_node; + struct device_node *ep; + struct property *prop; + const __be32 *cur; + u32 v; + u32 num_ovls = dispc_get_num_ovls(); + unsigned long int hw_plane_mask = (1 << num_ovls) - 1; + u32 num_planes; + int i, index; + + if (!np) + return 0; + + for (i = 0; i < num_ovls; i++) { + ep = dispc_of_get_plane_by_id(np, i); + if (!ep) + break; + if (!of_property_read_bool(ep, "hw-planes")) { + dev_err(&pdev->dev, + "malformed plane node: hw-planes missing.\n"); + return -EINVAL; + } + + index = 0; + of_property_for_each_u32(ep, "hw-planes", prop, cur, v) { + if (v >= num_ovls) { + dev_err(&pdev->dev, + "hw-planes property: '%d' out-of-range.\n", + v); + return -EINVAL; + } + if (!(hw_plane_mask & BIT_MASK(v))) { + dev_err(&pdev->dev, + "hw-planes property: '%d' used more than once.\n", + v); + return -EINVAL; + } + clear_bit(v, &hw_plane_mask); + + if (index == 0) { + plane->plane[i].main_id = v; + } else if (index == 1) { + plane->plane[i].aux_id = v; + plane->plane[i].is_virtual = true; + } else if (index > 1) { + dev_err(&pdev->dev, + "hw-planes property: more than 2 values specified.\n"); + return -EINVAL; + } + index++; + } + + of_property_for_each_u32(ep, "hw-crtcs", prop, cur, v) { + if (v >= num_ovls) { + dev_err(&pdev->dev, + "hw-crtcs property: '%d' out-of-range.\n", + v); + return -EINVAL; + } + plane->plane[i].crtc_mask |= 1 << v; + } + } + + num_planes = i; + + if (num_planes) { + dev_dbg(&pdev->dev, "Plane definitions found from DT:"); + for (i = 0; i < num_planes; i++) { + if (plane->plane[i].is_virtual) { + dev_dbg(&pdev->dev, + "plane%d: virtual hw-planes: %d, %d crtc_mask: 0x%04x", + i, plane->plane[i].main_id, + plane->plane[i].aux_id, + plane->plane[i].crtc_mask); + } else { + dev_dbg(&pdev->dev, + "plane%d: hw-planes: %d crtc_mask: 0x%04x", + i, plane->plane[i].main_id, + plane->plane[i].crtc_mask); + } + } + } + + plane->num_planes = num_planes; + + return 0; +} + /* * Workaround for errata i734 in DSS dispc * - LCD1 Gamma Correction Is Not Working When GFX Pipe Is Disabled @@ -4525,6 +4634,7 @@ static const struct dispc_ops dispc_ops = { .ovl_enable = dispc_ovl_enable, .ovl_setup = dispc_ovl_setup, .ovl_get_color_modes = dispc_ovl_get_color_modes, + .get_plane_mapping = dispc_parse_dt_plane_data, }; /* DISPC HW IP initialisation */ diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index f8f83e826a56..b8c9b30bf5ed 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -637,6 +637,16 @@ void omapdss_set_is_initialized(bool set); struct device_node *dss_of_port_get_parent_device(struct device_node *port); u32 dss_of_port_get_port_number(struct device_node *port); +struct dispc_plane_mappings { + struct { + u32 main_id; + u32 aux_id; + u32 crtc_mask; + bool is_virtual; + } plane[4]; + u32 num_planes; +}; + struct dss_mgr_ops { int (*connect)(enum omap_channel channel, struct omap_dss_device *dst); @@ -719,6 +729,7 @@ struct dispc_ops { enum omap_channel channel); const u32 *(*ovl_get_color_modes)(enum omap_plane_id plane); + int (*get_plane_mapping)(struct dispc_plane_mappings *plane); }; void dispc_set_ops(const struct dispc_ops *o);