101e04c3fSmrg/*
201e04c3fSmrg * Copyright (c) 2012-2015 Etnaviv Project
301e04c3fSmrg *
401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a
501e04c3fSmrg * copy of this software and associated documentation files (the "Software"),
601e04c3fSmrg * to deal in the Software without restriction, including without limitation
701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sub license,
801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the
901e04c3fSmrg * Software is furnished to do so, subject to the following conditions:
1001e04c3fSmrg *
1101e04c3fSmrg * The above copyright notice and this permission notice (including the
1201e04c3fSmrg * next paragraph) shall be included in all copies or substantial portions
1301e04c3fSmrg * of the Software.
1401e04c3fSmrg *
1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2101e04c3fSmrg * DEALINGS IN THE SOFTWARE.
2201e04c3fSmrg *
2301e04c3fSmrg * Authors:
2401e04c3fSmrg *    Wladimir J. van der Laan <laanwj@gmail.com>
2501e04c3fSmrg *    Christian Gmeiner <christian.gmeiner@gmail.com>
2601e04c3fSmrg */
2701e04c3fSmrg
2801e04c3fSmrg#ifndef H_ETNAVIV_SCREEN
2901e04c3fSmrg#define H_ETNAVIV_SCREEN
3001e04c3fSmrg
3101e04c3fSmrg#include "etnaviv_internal.h"
327ec681f3Smrg#include "etnaviv_perfmon.h"
3301e04c3fSmrg
3401e04c3fSmrg#include "os/os_thread.h"
3501e04c3fSmrg#include "pipe/p_screen.h"
3601e04c3fSmrg#include "renderonly/renderonly.h"
379f464c52Smaya#include "util/set.h"
3801e04c3fSmrg#include "util/slab.h"
3901e04c3fSmrg#include "util/u_dynarray.h"
409f464c52Smaya#include "util/u_helpers.h"
417ec681f3Smrg#include "compiler/nir/nir.h"
4201e04c3fSmrg
4301e04c3fSmrgstruct etna_bo;
4401e04c3fSmrg
4501e04c3fSmrg/* Enum with indices for each of the feature words */
4601e04c3fSmrgenum viv_features_word {
4701e04c3fSmrg   viv_chipFeatures = 0,
4801e04c3fSmrg   viv_chipMinorFeatures0 = 1,
4901e04c3fSmrg   viv_chipMinorFeatures1 = 2,
5001e04c3fSmrg   viv_chipMinorFeatures2 = 3,
5101e04c3fSmrg   viv_chipMinorFeatures3 = 4,
5201e04c3fSmrg   viv_chipMinorFeatures4 = 5,
5301e04c3fSmrg   viv_chipMinorFeatures5 = 6,
547ec681f3Smrg   viv_chipMinorFeatures6 = 7,
557ec681f3Smrg   viv_chipMinorFeatures7 = 8,
5601e04c3fSmrg   VIV_FEATURES_WORD_COUNT /* Must be last */
5701e04c3fSmrg};
5801e04c3fSmrg
5901e04c3fSmrg/** Convenience macro to probe features from state.xml.h:
6001e04c3fSmrg * VIV_FEATURE(chipFeatures, FAST_CLEAR)
6101e04c3fSmrg * VIV_FEATURE(chipMinorFeatures1, AUTO_DISABLE)
6201e04c3fSmrg */
6301e04c3fSmrg#define VIV_FEATURE(screen, word, feature) \
6401e04c3fSmrg   ((screen->features[viv_ ## word] & (word ## _ ## feature)) != 0)
6501e04c3fSmrg
6601e04c3fSmrgstruct etna_screen {
6701e04c3fSmrg   struct pipe_screen base;
6801e04c3fSmrg
6901e04c3fSmrg   int refcnt;
7001e04c3fSmrg   void *winsys_priv;
7101e04c3fSmrg
7201e04c3fSmrg   struct etna_device *dev;
7301e04c3fSmrg   struct etna_gpu *gpu;
7401e04c3fSmrg   struct etna_pipe *pipe;
7501e04c3fSmrg   struct etna_perfmon *perfmon;
7601e04c3fSmrg   struct renderonly *ro;
7701e04c3fSmrg
7801e04c3fSmrg   struct util_dynarray supported_pm_queries;
7901e04c3fSmrg   struct slab_parent_pool transfer_pool;
8001e04c3fSmrg
8101e04c3fSmrg   uint32_t model;
8201e04c3fSmrg   uint32_t revision;
8301e04c3fSmrg   uint32_t features[VIV_FEATURES_WORD_COUNT];
8401e04c3fSmrg
8501e04c3fSmrg   struct etna_specs specs;
8601e04c3fSmrg
8701e04c3fSmrg   uint32_t drm_version;
889f464c52Smaya
897ec681f3Smrg   struct etna_compiler *compiler;
907ec681f3Smrg   nir_shader_compiler_options options;
9101e04c3fSmrg};
9201e04c3fSmrg
9301e04c3fSmrgstatic inline struct etna_screen *
9401e04c3fSmrgetna_screen(struct pipe_screen *pscreen)
9501e04c3fSmrg{
9601e04c3fSmrg   return (struct etna_screen *)pscreen;
9701e04c3fSmrg}
9801e04c3fSmrg
9901e04c3fSmrgstruct etna_bo *
10001e04c3fSmrgetna_screen_bo_from_handle(struct pipe_screen *pscreen,
1017ec681f3Smrg                           struct winsys_handle *whandle);
10201e04c3fSmrg
10301e04c3fSmrgstruct pipe_screen *
10401e04c3fSmrgetna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
10501e04c3fSmrg                   struct renderonly *ro);
10601e04c3fSmrg
10701e04c3fSmrg#endif
108