etnaviv: add perfmon query implementation
[mesa.git] / src / gallium / drivers / etnaviv / etnaviv_screen.h
1 /*
2 * Copyright (c) 2012-2015 Etnaviv Project
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, sub license,
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 (including the
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the Software.
14 *
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 NON-INFRINGEMENT. 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
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Wladimir J. van der Laan <laanwj@gmail.com>
25 * Christian Gmeiner <christian.gmeiner@gmail.com>
26 */
27
28 #ifndef H_ETNAVIV_SCREEN
29 #define H_ETNAVIV_SCREEN
30
31 #include "etnaviv_internal.h"
32 #include "etnaviv_query_pm.h"
33
34 #include "os/os_thread.h"
35 #include "pipe/p_screen.h"
36 #include "renderonly/renderonly.h"
37 #include "util/slab.h"
38 #include "util/u_dynarray.h"
39
40 struct etna_bo;
41
42 /* Enum with indices for each of the feature words */
43 enum viv_features_word {
44 viv_chipFeatures = 0,
45 viv_chipMinorFeatures0 = 1,
46 viv_chipMinorFeatures1 = 2,
47 viv_chipMinorFeatures2 = 3,
48 viv_chipMinorFeatures3 = 4,
49 viv_chipMinorFeatures4 = 5,
50 viv_chipMinorFeatures5 = 6,
51 VIV_FEATURES_WORD_COUNT /* Must be last */
52 };
53
54 /** Convenience macro to probe features from state.xml.h:
55 * VIV_FEATURE(chipFeatures, FAST_CLEAR)
56 * VIV_FEATURE(chipMinorFeatures1, AUTO_DISABLE)
57 */
58 #define VIV_FEATURE(screen, word, feature) \
59 ((screen->features[viv_ ## word] & (word ## _ ## feature)) != 0)
60
61 struct etna_screen {
62 struct pipe_screen base;
63
64 int refcnt;
65 void *winsys_priv;
66
67 struct etna_device *dev;
68 struct etna_gpu *gpu;
69 struct etna_pipe *pipe;
70 struct etna_perfmon *perfmon;
71 struct renderonly *ro;
72
73 struct util_dynarray supported_pm_queries;
74 struct slab_parent_pool transfer_pool;
75
76 uint32_t model;
77 uint32_t revision;
78 uint32_t features[VIV_FEATURES_WORD_COUNT];
79
80 struct etna_specs specs;
81
82 uint32_t drm_version;
83 };
84
85 static inline struct etna_screen *
86 etna_screen(struct pipe_screen *pscreen)
87 {
88 return (struct etna_screen *)pscreen;
89 }
90
91 struct etna_bo *
92 etna_screen_bo_from_handle(struct pipe_screen *pscreen,
93 struct winsys_handle *whandle, unsigned *out_stride);
94
95 struct pipe_screen *
96 etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
97 struct renderonly *ro);
98
99 #endif