From nobody Mon Feb 9 23:39:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1621384286; cv=none; d=zohomail.com; s=zohoarc; b=Yqk8JUlDkEr7bgZfJgJIdz8YXnSqPJng/8kq1aC5SYI4PqtzYN2fj/LD7wfW6lhQxeyPePdf5FvTf4gkx6mzU7YN/r94wjdrd4ncWHOMYbwvxFSeuiNXy7yMJseXXtjrMzn/7e3pLwflFvkkGLOV0DSYWEvt7T6ESnYy8uPv8Ao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621384286; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R3RA+4kJ2h4JTjeFpL0gSf8whgbWPuACywxSkQzwxB0=; b=G42iav2HsZF4N06tVOdBgbdahsi3xX9KHHLT3eXbDu1PeGX/EMHg+7ZFHIVJNF2HEqzvxPwZq++ND3vKKwR2God7r0nLfIMJZCnlHMGvhfYCSjn6MI9O7FJ4sYW2hTGTKyDPqie2UDOYHLuZ3eCLQKs4DwoDfyYkqKQmQgHNw/M= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621384286304838.4076891057963; Tue, 18 May 2021 17:31:26 -0700 (PDT) Received: from localhost ([::1]:35146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljA7R-00022U-6Y for importer@patchew.org; Tue, 18 May 2021 20:31:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58756) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljA32-00036c-SC for qemu-devel@nongnu.org; Tue, 18 May 2021 20:26:53 -0400 Received: from mga09.intel.com ([134.134.136.24]:43003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljA30-0006Qv-61 for qemu-devel@nongnu.org; Tue, 18 May 2021 20:26:52 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:26:40 -0700 Received: from vkasired-desk2.fm.intel.com ([10.105.128.127]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:26:40 -0700 IronPort-SDR: X0cWCs1bmQq1y4QKcbmKU+9vOz+N6Fns4KUImcwGGlpgTF7BQ3n75BFrI3HSb8N0krBDHIULGL GVJA4LpdwUqA== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="200902429" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="200902429" IronPort-SDR: u3FExC8N31VLUDfuW5m50pej/TN5a92UIgXvGsqG7F/6YMy8zRKZWLPa86SWobYtOJZQ1X7epr qxndB3pW0Scg== X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="394177342" From: Vivek Kasireddy To: qemu-devel@nongnu.org Subject: [PATCH v5 01/13] ui: Get the fd associated with udmabuf driver Date: Tue, 18 May 2021 17:14:02 -0700 Message-Id: <20210519001414.786439-2-vivek.kasireddy@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210519001414.786439-1-vivek.kasireddy@intel.com> References: <20210519001414.786439-1-vivek.kasireddy@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.24; envelope-from=vivek.kasireddy@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vivek Kasireddy , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Try to open the udmabuf dev node for the first time or return the fd if the device was previously opened. Based-on-patch-by: Gerd Hoffmann Cc: Gerd Hoffmann Signed-off-by: Vivek Kasireddy --- include/ui/console.h | 3 +++ ui/meson.build | 1 + ui/udmabuf.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 ui/udmabuf.c diff --git a/include/ui/console.h b/include/ui/console.h index ca3c7af6a6..b30b63976a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -471,4 +471,7 @@ bool vnc_display_reload_certs(const char *id, Error **= errp); /* input.c */ int index_from_key(const char *key, size_t key_length); =20 +/* udmabuf.c */ +int udmabuf_fd(void); + #endif diff --git a/ui/meson.build b/ui/meson.build index e8d3ff41b9..7a709ff548 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -11,6 +11,7 @@ softmmu_ss.add(files( 'kbd-state.c', 'keymaps.c', 'qemu-pixman.c', + 'udmabuf.c', )) softmmu_ss.add([spice_headers, files('spice-module.c')]) =20 diff --git a/ui/udmabuf.c b/ui/udmabuf.c new file mode 100644 index 0000000000..e6234fd86f --- /dev/null +++ b/ui/udmabuf.c @@ -0,0 +1,40 @@ +/* + * udmabuf helper functions. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "ui/console.h" + +#ifdef CONFIG_LINUX + +#include +#include + +int udmabuf_fd(void) +{ + static bool first =3D true; + static int udmabuf; + + if (!first) { + return udmabuf; + } + first =3D false; + + udmabuf =3D open("/dev/udmabuf", O_RDWR); + if (udmabuf < 0) { + warn_report("open /dev/udmabuf: %s", strerror(errno)); + } + return udmabuf; +} + +#else + +int udmabuf_fd(void) +{ + return -1; +} + +#endif --=20 2.30.2