2 * Copyright (C) 2015 Etnaviv Project
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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * Christian Gmeiner <christian.gmeiner@gmail.com>
27 #include "etnaviv_priv.h"
28 #include "etnaviv_drmif.h"
30 static uint64_t get_param(struct etna_device *dev, uint32_t core, uint32_t param)
32 struct drm_etnaviv_param req = {
38 ret = drmCommandWriteRead(dev->fd, DRM_ETNAVIV_GET_PARAM, &req, sizeof(req));
40 ERROR_MSG("get-param (%x) failed! %d (%s)", param, ret, strerror(errno));
47 drm_public struct etna_gpu *etna_gpu_new(struct etna_device *dev, unsigned int core)
51 gpu = calloc(1, sizeof(*gpu));
53 ERROR_MSG("allocation failed");
60 gpu->model = get_param(dev, core, ETNAVIV_PARAM_GPU_MODEL);
61 gpu->revision = get_param(dev, core, ETNAVIV_PARAM_GPU_REVISION);
66 INFO_MSG(" GPU model: 0x%x (rev %x)", gpu->model, gpu->revision);
76 drm_public void etna_gpu_del(struct etna_gpu *gpu)
81 drm_public int etna_gpu_get_param(struct etna_gpu *gpu, enum etna_param_id param,
84 struct etna_device *dev = gpu->dev;
85 unsigned int core = gpu->core;
91 case ETNA_GPU_REVISION:
92 *value = gpu->revision;
94 case ETNA_GPU_FEATURES_0:
95 *value = get_param(dev, core, ETNAVIV_PARAM_GPU_FEATURES_0);
97 case ETNA_GPU_FEATURES_1:
98 *value = get_param(dev, core, ETNAVIV_PARAM_GPU_FEATURES_1);
100 case ETNA_GPU_FEATURES_2:
101 *value = get_param(dev, core, ETNAVIV_PARAM_GPU_FEATURES_2);
103 case ETNA_GPU_FEATURES_3:
104 *value = get_param(dev, core, ETNAVIV_PARAM_GPU_FEATURES_3);
106 case ETNA_GPU_FEATURES_4:
107 *value = get_param(dev, core, ETNAVIV_PARAM_GPU_FEATURES_4);
109 case ETNA_GPU_FEATURES_5:
110 *value = get_param(dev, core, ETNAVIV_PARAM_GPU_FEATURES_5);
112 case ETNA_GPU_FEATURES_6:
113 *value = get_param(dev, core, ETNAVIV_PARAM_GPU_FEATURES_6);
115 case ETNA_GPU_STREAM_COUNT:
116 *value = get_param(dev, core, ETNA_GPU_STREAM_COUNT);
118 case ETNA_GPU_REGISTER_MAX:
119 *value = get_param(dev, core, ETNA_GPU_REGISTER_MAX);
121 case ETNA_GPU_THREAD_COUNT:
122 *value = get_param(dev, core, ETNA_GPU_THREAD_COUNT);
124 case ETNA_GPU_VERTEX_CACHE_SIZE:
125 *value = get_param(dev, core, ETNA_GPU_VERTEX_CACHE_SIZE);
127 case ETNA_GPU_SHADER_CORE_COUNT:
128 *value = get_param(dev, core, ETNA_GPU_SHADER_CORE_COUNT);
130 case ETNA_GPU_PIXEL_PIPES:
131 *value = get_param(dev, core, ETNA_GPU_PIXEL_PIPES);
133 case ETNA_GPU_VERTEX_OUTPUT_BUFFER_SIZE:
134 *value = get_param(dev, core, ETNA_GPU_VERTEX_OUTPUT_BUFFER_SIZE);
136 case ETNA_GPU_BUFFER_SIZE:
137 *value = get_param(dev, core, ETNA_GPU_BUFFER_SIZE);
139 case ETNA_GPU_INSTRUCTION_COUNT:
140 *value = get_param(dev, core, ETNA_GPU_INSTRUCTION_COUNT);
142 case ETNA_GPU_NUM_CONSTANTS:
143 *value = get_param(dev, core, ETNA_GPU_NUM_CONSTANTS);
145 case ETNA_GPU_NUM_VARYINGS:
146 *value = get_param(dev, core, ETNA_GPU_NUM_VARYINGS);
150 ERROR_MSG("invalid param id: %d", param);