Merge pull request #5 from polachok/new
[pscnv.git] / test / get_param.c
blobf639a3e0b7bfd0d4494a9a715931486317c25b3a
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2010 PathScale Inc. All rights reserved.
24 * Use is subject to license terms.
27 #include <fcntl.h>
28 #include <assert.h>
29 #include <errno.h>
30 #include <xf86drm.h>
31 #include <stdio.h>
32 #include "libpscnv.h"
34 int DoTest(int fd)
36 int ret;
37 int i, j;
38 uint64_t tmp[7];
39 uint64_t value;
40 char param_name[7][15] = {"chipset_id", "vendor", "device", "bus type",
41 "graph units", "ptimer time",
42 "vram size"};
44 tmp[0] = PSCNV_GETPARAM_CHIPSET_ID;
45 tmp[1] = PSCNV_GETPARAM_PCI_VENDOR;
46 tmp[2] = PSCNV_GETPARAM_PCI_DEVICE;
47 tmp[3] = PSCNV_GETPARAM_BUS_TYPE;
48 tmp[4] = PSCNV_GETPARAM_GRAPH_UNITS;
49 tmp[5] = PSCNV_GETPARAM_PTIMER_TIME;
50 tmp[6] = PSCNV_GETPARAM_FB_SIZE;
53 for (i = 0; i < 7; i++) {
54 ret = pscnv_getparam(fd, tmp[i], &value);
55 if (ret==0) {
56 printf("%s : 0x%llx\n", param_name[i], value);
57 } else {
58 printf("%s : failed ret = %d\n", param_name[i], ret);
61 return ret;
65 int
66 main()
68 int fd;
69 int result;
71 fd = drmOpen("pscnv", 0);
73 if (fd == -1)
74 return fd;
75 result = DoTest(fd);
77 close (fd);
79 return result;