Debian Codegraph @

tegra/private.h

raw
1 /*
2 * Copyright © 2012, 2013 Thierry Reding
3 * Copyright © 2013 Erik Faye-Lund
4 * Copyright © 2014 NVIDIA Corporation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 #ifndef __DRM_TEGRA_PRIVATE_H__
26 #define __DRM_TEGRA_PRIVATE_H__ 1
27
28 #include <stdbool.h>
29 #include <stddef.h>
30 #include <stdint.h>
31
32 #include <libdrm_macros.h>
33 #include <xf86atomic.h>
34
35 #include "tegra_drm.h"
36 #include "tegra.h"
37
38 #define container_of(ptr, type, member) ({ \
39 const __typeof__(((type *)0)->member) *__mptr = (ptr); \
40 (type *)((char *)__mptr - offsetof(type, member)); \
41 })
42
43 enum host1x_class {
44 HOST1X_CLASS_HOST1X = 0x01,
45 HOST1X_CLASS_GR2D = 0x51,
46 HOST1X_CLASS_GR2D_SB = 0x52,
47 HOST1X_CLASS_VIC = 0x5d,
48 HOST1X_CLASS_GR3D = 0x60,
49 };
50
51 struct drm_tegra {
52 bool close;
53 int fd;
54 };
55
56 struct drm_tegra_bo {
57 struct drm_tegra *drm;
58 uint32_t handle;
59 uint64_t offset;
60 uint32_t flags;
61 uint32_t size;
62 atomic_t ref;
63 void *map;
64 };
65
66 struct drm_tegra_channel {
67 struct drm_tegra *drm;
68 enum host1x_class class;
69 uint32_t capabilities;
70 unsigned int version;
71 uint64_t context;
72
73 unsigned int cond_shift;
74 };
75
76 struct drm_tegra_mapping {
77 struct drm_tegra_channel *channel;
78 uint32_t id;
79 };
80
81 struct drm_tegra_pushbuf {
82 struct drm_tegra_job *job;
83
84 uint32_t *start;
85 uint32_t *end;
86 uint32_t *ptr;
87 };
88
89 void drm_tegra_pushbuf_free(struct drm_tegra_pushbuf *pushbuf);
90
91 struct drm_tegra_job {
92 struct drm_tegra_channel *channel;
93 struct drm_tegra_pushbuf *pushbuf;
94 size_t page_size;
95
96 struct drm_tegra_submit_cmd *commands;
97 unsigned int num_commands;
98
99 struct drm_tegra_submit_buf *buffers;
100 unsigned int num_buffers;
101
102 struct {
103 uint32_t id;
104 uint32_t increments;
105 uint32_t fence;
106 } syncpt;
107 };
108
109 struct drm_tegra_submit_cmd *
110 drm_tegra_job_add_command(struct drm_tegra_job *job, uint32_t type,
111 uint32_t flags);
112
113 struct drm_tegra_syncpoint {
114 struct drm_tegra *drm;
115 uint32_t id;
116 };
117
118 #endif /* __DRM_TEGRA_PRIVATE_H__ */