From patchwork Wed Apr 11 15:22:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru-Cosmin Gheorghe X-Patchwork-Id: 10335689 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 6B13C6053B for ; Wed, 11 Apr 2018 15:23:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D1EC2897C for ; Wed, 11 Apr 2018 15:23:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51FE128980; Wed, 11 Apr 2018 15:23:23 +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=-5.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, 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 B0E6D2897C for ; Wed, 11 Apr 2018 15:23:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 95A606E69E; Wed, 11 Apr 2018 15:23:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10056.outbound.protection.outlook.com [40.107.1.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id A1FA16E69E for ; Wed, 11 Apr 2018 15:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tD/fnvVQxbl/PA3nejU5ZYnkoEBJZGO2rIqfTs4mI7Q=; b=elRJj9BU8khcyC9lbp9MZiNejJZjWehuJeoZN4blJYsyS6rCcA8Nm7wvCWf8IplYt/WaBfB5bjiCkhcW5mRPEwwOy78GgmYeRAY5O60c4YRltuKPuR/21klqTh5a5dYZR217LgyZuEvo4KIS/U1OEUdZYluP5lzXw9wCXPkLy8s= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Alexandru-Cosmin.Gheorghe@arm.com; Received: from e114479-lin.cambridge.arm.com (217.140.96.140) by AM5PR0801MB1249.eurprd08.prod.outlook.com (2603:10a6:203:1e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.675.10; Wed, 11 Apr 2018 15:23:16 +0000 From: Alexandru Gheorghe To: dri-devel@lists.freedesktop.org, liviu.dudau@arm.com, brian.starkey@arm.com, ayan.halder@arm.com, seanpaul@chromium.org Subject: [PATCH hwc v2 04/18] drm_hwcomposer: Add resource manager class Date: Wed, 11 Apr 2018 16:22:15 +0100 Message-Id: <1523460149-1740-5-git-send-email-alexandru-cosmin.gheorghe@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523460149-1740-1-git-send-email-alexandru-cosmin.gheorghe@arm.com> References: <1523460149-1740-1-git-send-email-alexandru-cosmin.gheorghe@arm.com> MIME-Version: 1.0 X-Originating-IP: [217.140.96.140] X-ClientProxiedBy: VI1PR0701CA0066.eurprd07.prod.outlook.com (2603:10a6:800:5f::28) To AM5PR0801MB1249.eurprd08.prod.outlook.com (2603:10a6:203:1e::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM5PR0801MB1249; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 3:j16XkVXBz1+Bmpbce9xZmMy2DwYd6zjW0yTWMMl9Y78DyF/Bv5Uqp+AJVd2NVEv7gaSvxGHPUyOOGoNO/+q5CZRNLyeyPUzrxIRBrv0y9jWt8KYKc0ea3bSjaQycYBCI/CyPQOI/6F+iiV4YJiRMo2ANP9xnvLM4AalsNcRSlxSLGjDBk1qLmQvDDvindYOwxBBTl3Aka2G67eif0/Xx/3Mkjp+XCIm5AcPLTOLMISZThmmPVyEeEivuYVbuXrDX; 25:9jFJqVlGrxkqsrYVCKEMyMzTNTo7ywMDHZtBpMXyuUWTmwc3sqjgLlflOsh0Swjhyc1NzHw4hxCJZizaSiC6N/iCd8FYFPy6lMNFlaJQKayRzFD+6+Gdcs/Kh5uG2kGlIc6l7SR8mh5Aegr8u02HJefMpweiKlzl42R6uSFEm4Fd97oUFjHfgJCSPkpl4lH10M1o4l8dzokSPzff3x4izjuogDBGW1cnptQFb9vInirCNimFbqRoUhIfCIQJ09McRw7x3hYXxNxsuMcN2yVOOGN3e3ExmH525M62+2iiU2W9fwqauraXf9+KAaWBSykVlvTNAsgI4RTyqVIydN+r6A==; 31:N1WoV300eKptLibVKcKKFlVf3Kd65xwMGS0aCzJ3/iJvmlNAuk30vw9sJhN56NWoUl3fsx4Qx8AlbKE/lQg3dJBC10e6jVFw1joLzqLBYTmhIExkOFqk3NFZPZNhTH1GsjWjtghA6Uz3Rf5tZo3iIWUiodRMQqP4HUhC8Z2WsLZ+23ynk39Vc3gpOZX+ilaPOWZ+G0jtah5Ax9dbm8lpWU5jKq2sZaqVjp4e/QnMEUw= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1249: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 20:6RTDWCsp8/WpfrvsLz2IX2Rc9e89CkJiEivm20jJ+5WL4DGW02Quiz12MeSnIAHR0FdfU8pUo/h7d5NEem1IYKCu0D+Uzkr9OjlpvHGpdiJvhZJ3mR5HC10wwcqLJB3WOWaQDk1VeAjj18tFtGbewdZJqae4QAXbFkYPVjxl2Rc=; 4:5oSDGyxeWVIYOocTqrBuz9NiSSILhpsHCmSv0XsJZis6tvK+9/nJsDDVgCyzqdefBc2dMsIfqcQtKd0VAuAm1hHMCC7UXg8xz0c1WRxROBq9owHA39vUQt+bXLL1YsrPGDz07+LCm17UemH079ZAYR2YyyZx9o2SzldZuAF+i9rsp/VB3CkAH6WYKjht6LtlBw37ZuuQFIa+9F7qQ+pPknp8NbvfxMmPg58ddhgybPymCqrtg/G+l2Lnw9k6RMJPeW0LdvKYD44Eu82gEVNg4TMA8+F9ORjW2Gu1P5jLd/vYp94Lx8IGNVd6Kqw1PJ70 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231221)(944501327)(52105095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:AM5PR0801MB1249; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1249; X-Forefront-PRVS: 0639027A9E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(346002)(396003)(376002)(366004)(39860400002)(189003)(199004)(16526019)(478600001)(305945005)(50226002)(16586007)(68736007)(7736002)(86362001)(81156014)(8676002)(316002)(81166006)(4326008)(25786009)(2906002)(50466002)(8936002)(6486002)(105586002)(48376002)(186003)(956004)(5660300001)(72206003)(106356001)(476003)(53936002)(3846002)(76176011)(51416003)(52116002)(47776003)(7696005)(36756003)(66066001)(11346002)(446003)(386003)(97736004)(59450400001)(6116002)(2616005)(26005)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0801MB1249; H:e114479-lin.cambridge.arm.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0801MB1249; 23:K9USUAGdHsXtwoXpVtyF66LN1TrgIcaXmJm87Xt?= =?us-ascii?Q?Gh0iAVtSa658NQM3Fm2IOFXKs5+NF5Io2tjCJUSFYfrJH3Q1bp+tqZ5juTZq?= =?us-ascii?Q?L0n5SMSvH1QsFwevXZLRyhMg3JL8jljggVamZe6ULBVq9oXAjWGd7rF9JFCw?= =?us-ascii?Q?XZHKMeAAxYitCFJKrR/OQQLWUaOkZZ3IR1rJcsCpvMxAwiLngwHORGtQtYj0?= =?us-ascii?Q?EUHTKSYzpI7vlJVMN+5Er4kvdW0FOR6jcDvU9DmMf02/Qaoq4mvp0kSsZQPl?= =?us-ascii?Q?F8cH6bL/UlAWOZ3XIiB9hS92Xp07RclNeinGZUFBkDpvDowVS1SFjylayi4q?= =?us-ascii?Q?D89qC1tYhiZjKhcbvVK7XcUuUSGr0C0bcK5vgwMFUtCVOG1s8fbsax9AhA0i?= =?us-ascii?Q?rrBK77URE6SqaYDYfW12oJD9LHrQVXd6y5JrY4bL5vfeNRpSTGLp8aZ3J8Ti?= =?us-ascii?Q?YR4JMWUqH0sNhJPtHRhkpb7vqgPrFl3tivzHwLpzTrYEk2SesQVYUqYcSR+f?= =?us-ascii?Q?p3Nqq+uvexgb33GxyRuxeJY+S1z1cP/UGRGJM0XXGpzs2AdCFTSOa7/L6zbh?= =?us-ascii?Q?KkbfTl/yV7iLE71RVLJxeOcnb29qA+1e1MHNSm7OoQ3vf2fIpRlwamTKb6N7?= =?us-ascii?Q?x7BsH3L1vuA3zRfyMcaFqJ7fGq7Isda6jUHTnpPJ27QKIMJKIiVQaQi//WTJ?= =?us-ascii?Q?vco+L9HzAvzgWd4WR/U8f2kJyDBgjWq2WdmNez0bLI9sOylNF640LtGQy+wr?= =?us-ascii?Q?DsLARRfeZbprIkS7HyEdDbvx+oZ66hCQjM9kx2/E9DwY47qx4RDA0Roag/CN?= =?us-ascii?Q?yce9DlI4FU+xucRC1qqFCXcSsfxKoIHuwukP1qTbulyTIt9kYCJZ2MFLI984?= =?us-ascii?Q?ozXBzjhgnBBpfFGcHUbtPbBkeaooR1S7A5ABpU3pe8+dy/C09yKkoNmY/3W8?= =?us-ascii?Q?WuMjBscUfdcnYD01prrv+nb2FH1qFQCcNDSloVqP4Ll5QCwGYRsOtzkakTgA?= =?us-ascii?Q?jRBF8VyC8DqdheNobEC1dg61rOpvcREmqfnKx5hb5sTnPkEViPhkYvAIVvqf?= =?us-ascii?Q?VMBBCBJgHhODGewDzusKTYiaWsxo01OOqE/pVFeAZdUi9gxtC+aMFq4Y5AyI?= =?us-ascii?Q?2+L8CUsPtjnqrERhoNMDl4BHkZtZsf6/Sf255zGvursqZORNBNkYeIA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: mcQIXJSRNXqzOcVYCkKerMZH/9aumdQ3VVM65EJzoch+RIuaPbgeum2/oREUWo2AxRIpLUVFvrvXA7aYBuQD+UjDqjjp2slwyYhobaggRRDiOZlVQlv1XvbwKvPNxEQM6L1ZdwW690RGolT/T/dQ+30JE7vbnDJueSPgr2YD3lzrUgtnLSF0zVm3JgbqO9a6 X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 6:A0XNQBrS1FgNx+bXVk2PnmO6GWDlgRMkXCGfu1Kqy8UHZ37xhBygEBXZbndpa4iMeLdJdAFpnAaJD7kI5oXx4iFLmZmLw93rLzhG0TsNEb4GfFlNVppm36S6UZ/cP22w7675r1GeB+Wv4B7WRyuzeHgqhtZEWUul0ZDl1QHIfzEp70NUNbgEh6kwGDhUNxUtyq9J/131eqsG/0GO495X+RLf/rvjhYEN3rkhhIWWYLl/qMUVu7bg4/i0ZaJH578eq4Xr5jeedoez9Oc0UNcx57B8POZrQCWeRD3XUKw4KX6u0i7X/VqekswyBtGezQfvO/6NxAYkuANjVJH3GrVUqTEIHcRK5PKMVpuDpO7Llvm/V9LsdeO/EOfeVvVZQ34EnpITp9MGXjOtYcOZqzzoWtm7nzqN0fszbl0P51zdkLEHHunzNcqTpkK3r+yDQTUFhb0Cb4wQeyed5B9xx+wM9g==; 5:kBeXhy7ZFX7Dmvp9reeEZqosISgurWzWTERoRipfzpndt/6YtfWd8iudvRpHbUMHl2cdKwko5Dz+/xaMnjZkSxlK3lPne/5qM2OzJCweLLikrH5cjNp5UXpGd6lCbDIXvWtkjNp0OvZPOeE8AWcD2FKcjepsynzCB6whFUHoBS0=; 24:KzX98UWq3QD3JNTNhAgke+aMuyOYx7GggbXeqdZ69luEDlPKz/QBQ/9PIFDU8Q6mr9NqZaHKLEfIAK/62IKfiURwOfuimD2kIXPQFyOVf/g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1249; 7:J2j6RwxctXuIpI3tAYACTakmv4r8FHicAAU1RjGhmxv0U5S56432YUoVWWTe5zo4h4/emXzz46j1m6tx9TiaP0w/IciWdqq2f0IedPgm134XCDrZ4/IuD+Pe640DaZI+brIQG/YBVxJXlbhDn+fl5BwzraybcjdaYuLZV6I4HEofJFi7rnGldboqfquurIem38enOjtnADof29UGFbcZS0zsQHvi8/v4LT3BHAF9rG5HYmnnngBeV+cCTPf6SV8H X-MS-Office365-Filtering-Correlation-Id: 013e7af2-a79d-418e-54c0-08d59fc02655 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2018 15:23:16.3522 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 013e7af2-a79d-418e-54c0-08d59fc02655 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1249 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: nd@arm.com, Alexandru Gheorghe Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a resource manager object that is responsible for detecting all kms devices and allocates unique display numbers for every detected display. This is controlled by the value of hwc.drm.device property, if it ends with a %, it will try to open minor devices until and error is detected. E.g: /dev/dri/card% Additionally, this will be used for finding an available writeback connector that will be used for the flattening of the currently displayed scene. Signed-off-by: Alexandru Gheorghe --- Android.mk | 1 + resourcemanager.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ resourcemanager.h | 29 ++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 resourcemanager.cpp create mode 100644 resourcemanager.h diff --git a/Android.mk b/Android.mk index 1add286..736fe24 100644 --- a/Android.mk +++ b/Android.mk @@ -52,6 +52,7 @@ LOCAL_C_INCLUDES := \ LOCAL_SRC_FILES := \ autolock.cpp \ + resourcemanager.cpp \ drmresources.cpp \ drmconnector.cpp \ drmcrtc.cpp \ diff --git a/resourcemanager.cpp b/resourcemanager.cpp new file mode 100644 index 0000000..e7b654e --- /dev/null +++ b/resourcemanager.cpp @@ -0,0 +1,71 @@ +#include "resourcemanager.h" +#include +#include + +namespace android { + +ResourceManager::ResourceManager() : gralloc_(NULL) { +} + +int ResourceManager::Init() { + char path_pattern[PROPERTY_VALUE_MAX]; + property_get("hwc.drm.device", path_pattern, "/dev/dri/card%"); + + uint8_t minor = 0; + int last_display_index = 0; + int last_char = strlen(path_pattern) - 1; + do { + char path[PROPERTY_VALUE_MAX]; + if (path_pattern[last_char] == '%') { + path_pattern[last_char] = '\0'; + snprintf(path, PROPERTY_VALUE_MAX, "%s%d", path_pattern, minor); + path_pattern[last_char] = '%'; + } else { + snprintf(path, PROPERTY_VALUE_MAX, "%s", path_pattern); + } + std::unique_ptr drm = std::make_unique(); + last_display_index = drm->Init(this, path, last_display_index); + if (last_display_index < 0) { + break; + } + std::shared_ptr importer; + importer.reset(Importer::CreateInstance(drm.get())); + if (!importer) { + ALOGE("Failed to create importer instance"); + break; + } + importers_.push_back(importer); + drms_.push_back(std::move(drm)); + minor++; + last_display_index++; + } while (path_pattern[last_char] == '%'); + + if (!drms_.size()) { + ALOGE("Failed to find any working drm device"); + return -EINVAL; + } + + return hw_get_module(GRALLOC_HARDWARE_MODULE_ID, + (const hw_module_t **)&gralloc_); +} + +DrmResources *ResourceManager::GetDrmResources(int display) { + for (uint32_t i = 0; i < drms_.size(); i++) { + if (drms_[i]->HandlesDisplay(display)) + return drms_[i].get(); + } + return NULL; +} + +std::shared_ptr ResourceManager::GetImporter(int display) { + for (uint32_t i = 0; i < drms_.size(); i++) { + if (drms_[i]->HandlesDisplay(display)) + return importers_[i]; + } + return NULL; +} + +const gralloc_module_t *ResourceManager::GetGralloc() { + return gralloc_; +} +} diff --git a/resourcemanager.h b/resourcemanager.h new file mode 100644 index 0000000..b8caa9a --- /dev/null +++ b/resourcemanager.h @@ -0,0 +1,29 @@ +#ifndef RESOURCEMANAGER_H +#define RESOURCEMANAGER_H + +#include "drmresources.h" +#include "platform.h" + +namespace android { + +class DrmResources; +class Importer; + +class ResourceManager { + public: + ResourceManager(); + ResourceManager(const ResourceManager &) = delete; + ResourceManager &operator=(const ResourceManager &) = delete; + int Init(); + DrmResources *GetDrmResources(int display); + std::shared_ptr GetImporter(int display); + const gralloc_module_t *GetGralloc(); + + private: + std::vector> drms_; + std::vector> importers_; + const gralloc_module_t *gralloc_; +}; +} + +#endif // RESOURCEMANAGER_H