1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (c) 2017-2019 Lima Project
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sub license,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the
12bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions
13bf215546Sopenharmony_ci * of the Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21bf215546Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
22bf215546Sopenharmony_ci *
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci#ifndef H_LIMA_SCREEN
26bf215546Sopenharmony_ci#define H_LIMA_SCREEN
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#include <stdio.h>
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#include "util/slab.h"
31bf215546Sopenharmony_ci#include "util/list.h"
32bf215546Sopenharmony_ci#include "util/disk_cache.h"
33bf215546Sopenharmony_ci#include "os/os_thread.h"
34bf215546Sopenharmony_ci
35bf215546Sopenharmony_ci#include "pipe/p_screen.h"
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_ci#define LIMA_DEBUG_GP             (1 << 0)
38bf215546Sopenharmony_ci#define LIMA_DEBUG_PP             (1 << 1)
39bf215546Sopenharmony_ci#define LIMA_DEBUG_DUMP           (1 << 2)
40bf215546Sopenharmony_ci#define LIMA_DEBUG_SHADERDB       (1 << 3)
41bf215546Sopenharmony_ci#define LIMA_DEBUG_NO_BO_CACHE    (1 << 4)
42bf215546Sopenharmony_ci#define LIMA_DEBUG_BO_CACHE       (1 << 5)
43bf215546Sopenharmony_ci#define LIMA_DEBUG_NO_TILING      (1 << 6)
44bf215546Sopenharmony_ci#define LIMA_DEBUG_NO_GROW_HEAP   (1 << 7)
45bf215546Sopenharmony_ci#define LIMA_DEBUG_SINGLE_JOB     (1 << 8)
46bf215546Sopenharmony_ci#define LIMA_DEBUG_PRECOMPILE     (1 << 9)
47bf215546Sopenharmony_ci#define LIMA_DEBUG_DISK_CACHE     (1 << 10)
48bf215546Sopenharmony_ci#define LIMA_DEBUG_NO_BLIT        (1 << 11)
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ciextern uint32_t lima_debug;
51bf215546Sopenharmony_ciextern int lima_ctx_num_plb;
52bf215546Sopenharmony_ciextern int lima_plb_max_blk;
53bf215546Sopenharmony_ciextern int lima_ppir_force_spilling;
54bf215546Sopenharmony_ciextern int lima_plb_pp_stream_cache_size;
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_cistruct ra_regs;
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci#define MIN_BO_CACHE_BUCKET (12) /* 2^12 = 4KB */
59bf215546Sopenharmony_ci#define MAX_BO_CACHE_BUCKET (22) /* 2^22 = 4MB */
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_ci#define NR_BO_CACHE_BUCKETS (MAX_BO_CACHE_BUCKET - MIN_BO_CACHE_BUCKET + 1)
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_cistruct lima_screen {
64bf215546Sopenharmony_ci   struct pipe_screen base;
65bf215546Sopenharmony_ci   struct renderonly *ro;
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ci   int refcnt;
68bf215546Sopenharmony_ci   void *winsys_priv;
69bf215546Sopenharmony_ci
70bf215546Sopenharmony_ci   int fd;
71bf215546Sopenharmony_ci   int gpu_type;
72bf215546Sopenharmony_ci   int num_pp;
73bf215546Sopenharmony_ci   uint32_t plb_max_blk;
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci   /* bo table */
76bf215546Sopenharmony_ci   mtx_t bo_table_lock;
77bf215546Sopenharmony_ci   mtx_t bo_cache_lock;
78bf215546Sopenharmony_ci   struct hash_table *bo_handles;
79bf215546Sopenharmony_ci   struct hash_table *bo_flink_names;
80bf215546Sopenharmony_ci   struct list_head bo_cache_buckets[NR_BO_CACHE_BUCKETS];
81bf215546Sopenharmony_ci   struct list_head bo_cache_time;
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_ci   struct slab_parent_pool transfer_pool;
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_ci   struct ra_regs *pp_ra;
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ci   struct lima_bo *pp_buffer;
88bf215546Sopenharmony_ci   #define pp_frame_rsw_offset       0x0000
89bf215546Sopenharmony_ci   #define pp_clear_program_offset   0x0040
90bf215546Sopenharmony_ci   #define pp_reload_program_offset  0x0080
91bf215546Sopenharmony_ci   #define pp_shared_index_offset    0x00c0
92bf215546Sopenharmony_ci   #define pp_clear_gl_pos_offset    0x0100
93bf215546Sopenharmony_ci   #define pp_buffer_size            0x1000
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci   bool has_growable_heap_buffer;
96bf215546Sopenharmony_ci
97bf215546Sopenharmony_ci   struct disk_cache *disk_cache;
98bf215546Sopenharmony_ci};
99bf215546Sopenharmony_ci
100bf215546Sopenharmony_cistatic inline struct lima_screen *
101bf215546Sopenharmony_cilima_screen(struct pipe_screen *pscreen)
102bf215546Sopenharmony_ci{
103bf215546Sopenharmony_ci   return (struct lima_screen *)pscreen;
104bf215546Sopenharmony_ci}
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_cistruct pipe_screen *
107bf215546Sopenharmony_cilima_screen_create(int fd, struct renderonly *ro);
108bf215546Sopenharmony_ci
109bf215546Sopenharmony_ci#endif
110