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