From patchwork Wed Sep 9 17:21:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 7147711 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A19FABEEC1 for ; Wed, 9 Sep 2015 17:17:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C35B520A06 for ; Wed, 9 Sep 2015 17:17:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8C26520A13 for ; Wed, 9 Sep 2015 17:17:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 777776EC8C; Wed, 9 Sep 2015 10:17:37 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5BC3F6EC90 for ; Wed, 9 Sep 2015 10:17:36 -0700 (PDT) Received: by wiclk2 with SMTP id lk2so29787338wic.1 for ; Wed, 09 Sep 2015 10:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OEOVpgHadsCGiswZdhKBkqR5srbPnyzQbpVocqwVHhY=; b=JEOVVxI3N6jJRwHN+sdByAkDBk2ITYX9Jw/Pw7INGCMc+Yw7oPVILABjsfgqyZxyR1 f8TEZL9oBTI4YGxu0hv5F5Ht1OcUptBy5kmZEKdr8bH2Dm+Q2qRFfq+/IEMJllLNYIYu uvLnDg1bkm/T2jaZgo9TP/BzhXR5ErKbizFXKF2cHiZ58PDcHTQCadL1lMSbNAErGCXY weKnacTDrG+mvKh6ubhgo4Y1qrRAPN/bg9jKjSrqKikI5j8ZuRpxo/Bo2avQyKYBB7fl BSD8lUlkszdrrdVExoANKlwtu74uywA3GfX7LYytlk7rOqkjDSuz7JzFUHqLk9qTgfwD Ekxw== X-Received: by 10.194.93.3 with SMTP id cq3mr59585469wjb.20.1441819055153; Wed, 09 Sep 2015 10:17:35 -0700 (PDT) Received: from arch-x220.localdomain (cpc12-croy20-2-0-cust52.croy.cable.virginm.net. [82.44.54.53]) by smtp.gmail.com with ESMTPSA id j7sm11257042wjz.11.2015.09.09.10.17.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Sep 2015 10:17:34 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 12/12] tests/drmdevice: add drm{Get, Free}Device() example Date: Wed, 9 Sep 2015 18:21:33 +0100 Message-Id: <1441819293-25567-13-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1441819293-25567-1-git-send-email-emil.l.velikov@gmail.com> References: <1441819293-25567-1-git-send-email-emil.l.velikov@gmail.com> Cc: emil.l.velikov@gmail.com 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Emil Velikov --- tests/drmdevice.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/drmdevice.c b/tests/drmdevice.c index 4055f45..c336327 100644 --- a/tests/drmdevice.c +++ b/tests/drmdevice.c @@ -23,6 +23,9 @@ #include #include +#include +#include +#include #include @@ -62,7 +65,8 @@ int main(void) { drmDevicePtr *devices; - int ret, max_devices; + drmDevicePtr device; + int fd, ret, max_devices; max_devices = drmGetDevices(NULL, 0); @@ -84,9 +88,24 @@ main(void) return -1; } - for (int i = 0; i < ret; i++) + for (int i = 0; i < ret; i++) { print_device_info(devices[i], i); + for (int j = 0; j < DRM_NODE_MAX; j++) { + if (devices[i]->available_nodes & 1 << j) { + fd = open(devices[i]->nodes[j], O_RDONLY | O_CLOEXEC, 0); + if (fd < 0) + continue; + + if (drmGetDevice(fd, &device) == 0) { + print_device_info(device, -1); + drmFreeDevice(&device); + } + close(fd); + } + } + } + drmFreeDevices(devices, ret); free(devices); return 0;