2 * Copyright © 2016 Broadcom
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:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 #include "common/v3d_device_info.h"
29 #include "drm-uapi/v3d_drm.h"
32 v3d_get_device_info(int fd
, struct v3d_device_info
* devinfo
, v3d_ioctl_fun drm_ioctl
) {
33 struct drm_v3d_get_param ident0
= {
34 .param
= DRM_V3D_PARAM_V3D_CORE0_IDENT0
,
36 struct drm_v3d_get_param ident1
= {
37 .param
= DRM_V3D_PARAM_V3D_CORE0_IDENT1
,
41 ret
= drm_ioctl(fd
, DRM_IOCTL_V3D_GET_PARAM
, &ident0
);
43 fprintf(stderr
, "Couldn't get V3D core IDENT0: %s\n",
47 ret
= drm_ioctl(fd
, DRM_IOCTL_V3D_GET_PARAM
, &ident1
);
49 fprintf(stderr
, "Couldn't get V3D core IDENT1: %s\n",
54 uint32_t major
= (ident0
.value
>> 24) & 0xff;
55 uint32_t minor
= (ident1
.value
>> 0) & 0xf;
57 devinfo
->ver
= major
* 10 + minor
;
59 devinfo
->vpm_size
= (ident1
.value
>> 28 & 0xf) * 8192;
61 int nslc
= (ident1
.value
>> 4) & 0xf;
62 int qups
= (ident1
.value
>> 8) & 0xf;
63 devinfo
->qpu_count
= nslc
* qups
;
65 switch (devinfo
->ver
) {
72 "V3D %d.%d not supported by this version of Mesa.\n",