1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (C) 2018-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, sublicense,
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 shall be included in
12bf215546Sopenharmony_ci * all copies or substantial portions of the Software.
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17bf215546Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
21bf215546Sopenharmony_ci *
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci#ifndef H_LIMA_UTIL
25bf215546Sopenharmony_ci#define H_LIMA_UTIL
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci#include <stdint.h>
28bf215546Sopenharmony_ci#include <stdbool.h>
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#define LIMA_PAGE_SIZE 4096
31bf215546Sopenharmony_ci
32bf215546Sopenharmony_cistruct lima_dump;
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_cibool lima_get_absolute_timeout(uint64_t *timeout);
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_cistruct lima_dump *lima_dump_create(void);
37bf215546Sopenharmony_cistruct lima_dump *lima_dump_next(struct lima_dump *dump);
38bf215546Sopenharmony_civoid lima_dump_free(struct lima_dump *dump);
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_civoid lima_dump_shader(struct lima_dump *dump, void *data, int size, bool is_frag);
41bf215546Sopenharmony_civoid lima_dump_vs_command_stream_print(struct lima_dump *dump, void *data,
42bf215546Sopenharmony_ci                                       int size, uint32_t start);
43bf215546Sopenharmony_civoid lima_dump_plbu_command_stream_print(struct lima_dump *dump, void *data,
44bf215546Sopenharmony_ci                                         int size, uint32_t start);
45bf215546Sopenharmony_civoid lima_dump_rsw_command_stream_print(struct lima_dump *dump, void *data,
46bf215546Sopenharmony_ci                                        int size, uint32_t start);
47bf215546Sopenharmony_civoid lima_dump_texture_descriptor(struct lima_dump *dump, void *data,
48bf215546Sopenharmony_ci                                  int size, uint32_t start, uint32_t offset);
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_civoid _lima_dump_command_stream_print(struct lima_dump *dump, void *data,
51bf215546Sopenharmony_ci                                     int size, bool is_float, const char *fmt, ...);
52bf215546Sopenharmony_ci#define lima_dump_command_stream_print(dump, ...) \
53bf215546Sopenharmony_ci   do { \
54bf215546Sopenharmony_ci      if (dump) \
55bf215546Sopenharmony_ci         _lima_dump_command_stream_print(dump, __VA_ARGS__); \
56bf215546Sopenharmony_ci   } while (0)
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_cistruct pipe_scissor_state;
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_civoid lima_damage_rect_union(struct pipe_scissor_state *rect,
61bf215546Sopenharmony_ci                            unsigned minx, unsigned maxx,
62bf215546Sopenharmony_ci                            unsigned miny, unsigned maxy);
63bf215546Sopenharmony_ci#endif
64