1b8e80941Smrg/*
2b8e80941Smrg * Copyright (c) 2012-2015 Etnaviv Project
3b8e80941Smrg *
4b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
6b8e80941Smrg * to deal in the Software without restriction, including without limitation
7b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sub license,
8b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
9b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
10b8e80941Smrg *
11b8e80941Smrg * The above copyright notice and this permission notice (including the
12b8e80941Smrg * next paragraph) shall be included in all copies or substantial portions
13b8e80941Smrg * of the Software.
14b8e80941Smrg *
15b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21b8e80941Smrg * DEALINGS IN THE SOFTWARE.
22b8e80941Smrg *
23b8e80941Smrg * Authors:
24b8e80941Smrg *    Wladimir J. van der Laan <laanwj@gmail.com>
25b8e80941Smrg *    Christian Gmeiner <christian.gmeiner@gmail.com>
26b8e80941Smrg */
27b8e80941Smrg
28b8e80941Smrg#ifndef H_ETNAVIV_SCREEN
29b8e80941Smrg#define H_ETNAVIV_SCREEN
30b8e80941Smrg
31b8e80941Smrg#include "etnaviv_internal.h"
32b8e80941Smrg#include "etnaviv_query_pm.h"
33b8e80941Smrg
34b8e80941Smrg#include "os/os_thread.h"
35b8e80941Smrg#include "pipe/p_screen.h"
36b8e80941Smrg#include "renderonly/renderonly.h"
37b8e80941Smrg#include "util/set.h"
38b8e80941Smrg#include "util/slab.h"
39b8e80941Smrg#include "util/u_dynarray.h"
40b8e80941Smrg#include "util/u_helpers.h"
41b8e80941Smrg
42b8e80941Smrgstruct etna_bo;
43b8e80941Smrg
44b8e80941Smrg/* Enum with indices for each of the feature words */
45b8e80941Smrgenum viv_features_word {
46b8e80941Smrg   viv_chipFeatures = 0,
47b8e80941Smrg   viv_chipMinorFeatures0 = 1,
48b8e80941Smrg   viv_chipMinorFeatures1 = 2,
49b8e80941Smrg   viv_chipMinorFeatures2 = 3,
50b8e80941Smrg   viv_chipMinorFeatures3 = 4,
51b8e80941Smrg   viv_chipMinorFeatures4 = 5,
52b8e80941Smrg   viv_chipMinorFeatures5 = 6,
53b8e80941Smrg   VIV_FEATURES_WORD_COUNT /* Must be last */
54b8e80941Smrg};
55b8e80941Smrg
56b8e80941Smrg/** Convenience macro to probe features from state.xml.h:
57b8e80941Smrg * VIV_FEATURE(chipFeatures, FAST_CLEAR)
58b8e80941Smrg * VIV_FEATURE(chipMinorFeatures1, AUTO_DISABLE)
59b8e80941Smrg */
60b8e80941Smrg#define VIV_FEATURE(screen, word, feature) \
61b8e80941Smrg   ((screen->features[viv_ ## word] & (word ## _ ## feature)) != 0)
62b8e80941Smrg
63b8e80941Smrgstruct etna_screen {
64b8e80941Smrg   struct pipe_screen base;
65b8e80941Smrg
66b8e80941Smrg   int refcnt;
67b8e80941Smrg   void *winsys_priv;
68b8e80941Smrg
69b8e80941Smrg   struct etna_device *dev;
70b8e80941Smrg   struct etna_gpu *gpu;
71b8e80941Smrg   struct etna_pipe *pipe;
72b8e80941Smrg   struct etna_perfmon *perfmon;
73b8e80941Smrg   struct renderonly *ro;
74b8e80941Smrg
75b8e80941Smrg   struct util_dynarray supported_pm_queries;
76b8e80941Smrg   struct slab_parent_pool transfer_pool;
77b8e80941Smrg
78b8e80941Smrg   uint32_t model;
79b8e80941Smrg   uint32_t revision;
80b8e80941Smrg   uint32_t features[VIV_FEATURES_WORD_COUNT];
81b8e80941Smrg
82b8e80941Smrg   struct etna_specs specs;
83b8e80941Smrg
84b8e80941Smrg   uint32_t drm_version;
85b8e80941Smrg
86b8e80941Smrg   /* set of resources used by currently-unsubmitted renders */
87b8e80941Smrg   mtx_t lock;
88b8e80941Smrg   struct set *used_resources;
89b8e80941Smrg};
90b8e80941Smrg
91b8e80941Smrgstatic inline struct etna_screen *
92b8e80941Smrgetna_screen(struct pipe_screen *pscreen)
93b8e80941Smrg{
94b8e80941Smrg   return (struct etna_screen *)pscreen;
95b8e80941Smrg}
96b8e80941Smrg
97b8e80941Smrgstruct etna_bo *
98b8e80941Smrgetna_screen_bo_from_handle(struct pipe_screen *pscreen,
99b8e80941Smrg                           struct winsys_handle *whandle, unsigned *out_stride);
100b8e80941Smrg
101b8e80941Smrgstruct pipe_screen *
102b8e80941Smrgetna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
103b8e80941Smrg                   struct renderonly *ro);
104b8e80941Smrg
105b8e80941Smrg#endif
106