108d7334dSsnj/* 208d7334dSsnj * Copyright © 2014 NVIDIA Corporation 308d7334dSsnj * 408d7334dSsnj * Permission is hereby granted, free of charge, to any person obtaining a 508d7334dSsnj * copy of this software and associated documentation files (the "Software"), 608d7334dSsnj * to deal in the Software without restriction, including without limitation 708d7334dSsnj * the rights to use, copy, modify, merge, publish, distribute, sublicense, 808d7334dSsnj * and/or sell copies of the Software, and to permit persons to whom the 908d7334dSsnj * Software is furnished to do so, subject to the following conditions: 1008d7334dSsnj * 1108d7334dSsnj * The above copyright notice and this permission notice shall be included in 1208d7334dSsnj * all copies or substantial portions of the Software. 1308d7334dSsnj * 1408d7334dSsnj * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1508d7334dSsnj * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1608d7334dSsnj * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1708d7334dSsnj * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1808d7334dSsnj * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1908d7334dSsnj * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2008d7334dSsnj * OTHER DEALINGS IN THE SOFTWARE. 2108d7334dSsnj */ 2208d7334dSsnj 2308d7334dSsnj#include <fcntl.h> 2408d7334dSsnj#include <stdio.h> 2508d7334dSsnj#include <unistd.h> 2608d7334dSsnj 2708d7334dSsnj#include "xf86drm.h" 2808d7334dSsnj#include "tegra.h" 2908d7334dSsnj 3008d7334dSsnjstatic const char default_device[] = "/dev/dri/card0"; 3108d7334dSsnj 3208d7334dSsnjint main(int argc, char *argv[]) 3308d7334dSsnj{ 340ed5401bSmrg struct drm_tegra *tegra; 350ed5401bSmrg drmVersionPtr version; 360ed5401bSmrg const char *device; 370ed5401bSmrg int err, fd; 3808d7334dSsnj 390ed5401bSmrg if (argc < 2) 400ed5401bSmrg device = default_device; 410ed5401bSmrg else 420ed5401bSmrg device = argv[1]; 4308d7334dSsnj 440ed5401bSmrg fd = open(device, O_RDWR); 450ed5401bSmrg if (fd < 0) 460ed5401bSmrg return 1; 4708d7334dSsnj 480ed5401bSmrg version = drmGetVersion(fd); 490ed5401bSmrg if (version) { 500ed5401bSmrg printf("Version: %d.%d.%d\n", version->version_major, 510ed5401bSmrg version->version_minor, version->version_patchlevel); 520ed5401bSmrg printf(" Name: %s\n", version->name); 530ed5401bSmrg printf(" Date: %s\n", version->date); 540ed5401bSmrg printf(" Description: %s\n", version->desc); 5508d7334dSsnj 560ed5401bSmrg drmFreeVersion(version); 570ed5401bSmrg } 5808d7334dSsnj 590ed5401bSmrg err = drm_tegra_new(fd, &tegra); 600ed5401bSmrg if (err < 0) 610ed5401bSmrg return 1; 6208d7334dSsnj 630ed5401bSmrg drm_tegra_close(tegra); 640ed5401bSmrg close(fd); 6508d7334dSsnj 660ed5401bSmrg return 0; 6708d7334dSsnj} 68