1d722e3fbSopenharmony_ci/* 2d722e3fbSopenharmony_ci * Copyright © 2014 NVIDIA Corporation 3d722e3fbSopenharmony_ci * 4d722e3fbSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5d722e3fbSopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6d722e3fbSopenharmony_ci * to deal in the Software without restriction, including without limitation 7d722e3fbSopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8d722e3fbSopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9d722e3fbSopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10d722e3fbSopenharmony_ci * 11d722e3fbSopenharmony_ci * The above copyright notice and this permission notice shall be included in 12d722e3fbSopenharmony_ci * all copies or substantial portions of the Software. 13d722e3fbSopenharmony_ci * 14d722e3fbSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15d722e3fbSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16d722e3fbSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17d722e3fbSopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18d722e3fbSopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19d722e3fbSopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20d722e3fbSopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 21d722e3fbSopenharmony_ci */ 22d722e3fbSopenharmony_ci 23d722e3fbSopenharmony_ci#include <fcntl.h> 24d722e3fbSopenharmony_ci#include <stdio.h> 25d722e3fbSopenharmony_ci#include <unistd.h> 26d722e3fbSopenharmony_ci 27d722e3fbSopenharmony_ci#include "xf86drm.h" 28d722e3fbSopenharmony_ci#include "tegra.h" 29d722e3fbSopenharmony_ci 30d722e3fbSopenharmony_cistatic const char default_device[] = "/dev/dri/card0"; 31d722e3fbSopenharmony_ci 32d722e3fbSopenharmony_ciint main(int argc, char *argv[]) 33d722e3fbSopenharmony_ci{ 34d722e3fbSopenharmony_ci struct drm_tegra *tegra; 35d722e3fbSopenharmony_ci drmVersionPtr version; 36d722e3fbSopenharmony_ci const char *device; 37d722e3fbSopenharmony_ci int err, fd; 38d722e3fbSopenharmony_ci 39d722e3fbSopenharmony_ci if (argc < 2) 40d722e3fbSopenharmony_ci device = default_device; 41d722e3fbSopenharmony_ci else 42d722e3fbSopenharmony_ci device = argv[1]; 43d722e3fbSopenharmony_ci 44d722e3fbSopenharmony_ci fd = open(device, O_RDWR); 45d722e3fbSopenharmony_ci if (fd < 0) 46d722e3fbSopenharmony_ci return 1; 47d722e3fbSopenharmony_ci 48d722e3fbSopenharmony_ci version = drmGetVersion(fd); 49d722e3fbSopenharmony_ci if (version) { 50d722e3fbSopenharmony_ci printf("Version: %d.%d.%d\n", version->version_major, 51d722e3fbSopenharmony_ci version->version_minor, version->version_patchlevel); 52d722e3fbSopenharmony_ci printf(" Name: %s\n", version->name); 53d722e3fbSopenharmony_ci printf(" Date: %s\n", version->date); 54d722e3fbSopenharmony_ci printf(" Description: %s\n", version->desc); 55d722e3fbSopenharmony_ci 56d722e3fbSopenharmony_ci drmFreeVersion(version); 57d722e3fbSopenharmony_ci } 58d722e3fbSopenharmony_ci 59d722e3fbSopenharmony_ci err = drm_tegra_new(fd, &tegra); 60d722e3fbSopenharmony_ci if (err < 0) 61d722e3fbSopenharmony_ci return 1; 62d722e3fbSopenharmony_ci 63d722e3fbSopenharmony_ci drm_tegra_close(tegra); 64d722e3fbSopenharmony_ci close(fd); 65d722e3fbSopenharmony_ci 66d722e3fbSopenharmony_ci return 0; 67d722e3fbSopenharmony_ci} 68