101e04c3fSmrg/*
201e04c3fSmrg * Copyright © 2014-2017 Broadcom
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, sublicense,
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 next
1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the
1301e04c3fSmrg * 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 NONINFRINGEMENT.  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 DEALINGS
2101e04c3fSmrg * IN THE SOFTWARE.
2201e04c3fSmrg */
2301e04c3fSmrg
247ec681f3Smrg#ifndef V3D_SCREEN_H
257ec681f3Smrg#define V3D_SCREEN_H
2601e04c3fSmrg
2701e04c3fSmrg#include "pipe/p_screen.h"
289f464c52Smaya#include "renderonly/renderonly.h"
2901e04c3fSmrg#include "os/os_thread.h"
307ec681f3Smrg#include "frontend/drm_driver.h"
3101e04c3fSmrg#include "util/list.h"
3201e04c3fSmrg#include "util/slab.h"
3301e04c3fSmrg#include "broadcom/common/v3d_debug.h"
3401e04c3fSmrg#include "broadcom/common/v3d_device_info.h"
3501e04c3fSmrg
3601e04c3fSmrgstruct v3d_bo;
3701e04c3fSmrg
3801e04c3fSmrg/* These are tunable parameters in the HW design, but all the V3D
3901e04c3fSmrg * implementations agree.
4001e04c3fSmrg */
417ec681f3Smrg#define V3D_UIFCFG_BANKS 8
427ec681f3Smrg#define V3D_UIFCFG_PAGE_SIZE 4096
437ec681f3Smrg#define V3D_UIFCFG_XOR_VALUE (1 << 4)
447ec681f3Smrg#define V3D_PAGE_CACHE_SIZE (V3D_UIFCFG_PAGE_SIZE * V3D_UIFCFG_BANKS)
457ec681f3Smrg#define V3D_UBLOCK_SIZE 64
467ec681f3Smrg#define V3D_UIFBLOCK_SIZE (4 * V3D_UBLOCK_SIZE)
477ec681f3Smrg#define V3D_UIFBLOCK_ROW_SIZE (4 * V3D_UIFBLOCK_SIZE)
4801e04c3fSmrg
4901e04c3fSmrgstruct v3d_simulator_file;
5001e04c3fSmrg
5101e04c3fSmrgstruct v3d_screen {
5201e04c3fSmrg        struct pipe_screen base;
539f464c52Smaya        struct renderonly *ro;
5401e04c3fSmrg        int fd;
5501e04c3fSmrg
5601e04c3fSmrg        struct v3d_device_info devinfo;
5701e04c3fSmrg
5801e04c3fSmrg        const char *name;
5901e04c3fSmrg
6001e04c3fSmrg        struct slab_parent_pool transfer_pool;
6101e04c3fSmrg
6201e04c3fSmrg        struct v3d_bo_cache {
6301e04c3fSmrg                /** List of struct v3d_bo freed, by age. */
6401e04c3fSmrg                struct list_head time_list;
6501e04c3fSmrg                /** List of struct v3d_bo freed, per size, by age. */
6601e04c3fSmrg                struct list_head *size_list;
6701e04c3fSmrg                uint32_t size_list_size;
6801e04c3fSmrg
6901e04c3fSmrg                mtx_t lock;
7001e04c3fSmrg        } bo_cache;
7101e04c3fSmrg
7201e04c3fSmrg        const struct v3d_compiler *compiler;
7301e04c3fSmrg
747ec681f3Smrg        struct hash_table *bo_handles;
7501e04c3fSmrg        mtx_t bo_handles_mutex;
7601e04c3fSmrg
7701e04c3fSmrg        uint32_t bo_size;
7801e04c3fSmrg        uint32_t bo_count;
797ec681f3Smrg        uint32_t prim_types;
8001e04c3fSmrg
819f464c52Smaya        bool has_csd;
827ec681f3Smrg        bool has_cache_flush;
837ec681f3Smrg        bool has_perfmon;
847ec681f3Smrg        bool nonmsaa_texture_size_limit;
859f464c52Smaya
8601e04c3fSmrg        struct v3d_simulator_file *sim_file;
8701e04c3fSmrg};
8801e04c3fSmrg
8901e04c3fSmrgstatic inline struct v3d_screen *
9001e04c3fSmrgv3d_screen(struct pipe_screen *screen)
9101e04c3fSmrg{
9201e04c3fSmrg        return (struct v3d_screen *)screen;
9301e04c3fSmrg}
9401e04c3fSmrg
957ec681f3Smrgstruct pipe_screen *v3d_screen_create(int fd,
967ec681f3Smrg                                      const struct pipe_screen_config *config,
977ec681f3Smrg                                      struct renderonly *ro);
9801e04c3fSmrg
9901e04c3fSmrgvoid
10001e04c3fSmrgv3d_fence_init(struct v3d_screen *screen);
10101e04c3fSmrg
1027ec681f3Smrg#endif /* V3D_SCREEN_H */
103