• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_H__
26 #define __DRM_TEGRA_H__ 1
27 
28 #include <stdint.h>
29 #include <stdlib.h>
30 
31 #include <tegra_drm.h>
32 
33 enum drm_tegra_class {
34     DRM_TEGRA_HOST1X,
35     DRM_TEGRA_GR2D,
36     DRM_TEGRA_GR3D,
37     DRM_TEGRA_VIC,
38 };
39 
40 struct drm_tegra_bo;
41 struct drm_tegra;
42 
43 int drm_tegra_new(int fd, struct drm_tegra **drmp);
44 void drm_tegra_close(struct drm_tegra *drm);
45 
46 int drm_tegra_bo_new(struct drm_tegra *drm, uint32_t flags, uint32_t size,
47                      struct drm_tegra_bo **bop);
48 int drm_tegra_bo_wrap(struct drm_tegra *drm, uint32_t handle, uint32_t flags,
49                       uint32_t size, struct drm_tegra_bo **bop);
50 struct drm_tegra_bo *drm_tegra_bo_ref(struct drm_tegra_bo *bo);
51 void drm_tegra_bo_unref(struct drm_tegra_bo *bo);
52 int drm_tegra_bo_get_handle(struct drm_tegra_bo *bo, uint32_t *handle);
53 int drm_tegra_bo_map(struct drm_tegra_bo *bo, void **ptr);
54 int drm_tegra_bo_unmap(struct drm_tegra_bo *bo);
55 
56 int drm_tegra_bo_get_name(struct drm_tegra_bo *bo, uint32_t *name);
57 int drm_tegra_bo_open(struct drm_tegra *drm, uint32_t name, uint32_t flags,
58                       struct drm_tegra_bo **bop);
59 
60 int drm_tegra_bo_export(struct drm_tegra_bo *bo, uint32_t flags);
61 int drm_tegra_bo_import(struct drm_tegra *drm, int fd,
62                         struct drm_tegra_bo **bop);
63 
64 struct drm_tegra_channel;
65 struct drm_tegra_mapping;
66 struct drm_tegra_pushbuf;
67 struct drm_tegra_job;
68 struct drm_tegra_syncpoint;
69 
70 enum drm_tegra_sync_cond {
71     DRM_TEGRA_SYNC_COND_IMMEDIATE,
72     DRM_TEGRA_SYNC_COND_OP_DONE,
73     DRM_TEGRA_SYNC_COND_RD_DONE,
74     DRM_TEGRA_SYNC_COND_WR_SAFE,
75     DRM_TEGRA_SYNC_COND_MAX,
76   };
77 
78 struct drm_tegra_fence {
79     struct drm_tegra *drm;
80     uint32_t syncpt;
81     uint32_t value;
82 };
83 
84 int drm_tegra_channel_open(struct drm_tegra *drm,
85                            enum drm_tegra_class client,
86                            struct drm_tegra_channel **channelp);
87 int drm_tegra_channel_close(struct drm_tegra_channel *channel);
88 unsigned int drm_tegra_channel_get_version(struct drm_tegra_channel *channel);
89 int drm_tegra_channel_map(struct drm_tegra_channel *channel,
90                           struct drm_tegra_bo *bo, uint32_t flags,
91                           struct drm_tegra_mapping **mapp);
92 int drm_tegra_channel_unmap(struct drm_tegra_mapping *map);
93 
94 int drm_tegra_job_new(struct drm_tegra_channel *channel,
95                       struct drm_tegra_job **jobp);
96 int drm_tegra_job_free(struct drm_tegra_job *job);
97 int drm_tegra_job_get_pushbuf(struct drm_tegra_job *job,
98                               struct drm_tegra_pushbuf **pushbufp);
99 int drm_tegra_job_submit(struct drm_tegra_job *job,
100                          struct drm_tegra_fence *fence);
101 int drm_tegra_job_wait(struct drm_tegra_job *job, unsigned long timeout);
102 
103 int drm_tegra_pushbuf_begin(struct drm_tegra_pushbuf *pushbuf,
104                             unsigned int words, uint32_t **ptrp);
105 int drm_tegra_pushbuf_end(struct drm_tegra_pushbuf *pushbuf, uint32_t *ptr);
106 int drm_tegra_pushbuf_wait(struct drm_tegra_pushbuf *pushbuf,
107                            struct drm_tegra_syncpoint *syncpt,
108                            uint32_t value);
109 int drm_tegra_pushbuf_relocate(struct drm_tegra_pushbuf *pushbuf,
110                                uint32_t **ptrp,
111                                struct drm_tegra_mapping *target,
112                                unsigned long offset, unsigned int shift,
113                                uint32_t flags);
114 int drm_tegra_pushbuf_sync(struct drm_tegra_pushbuf *pushbuf,
115                            struct drm_tegra_syncpoint *syncpt,
116                            unsigned int count);
117 int drm_tegra_pushbuf_sync_cond(struct drm_tegra_pushbuf *pushbuf,
118                                 uint32_t **ptrp,
119                                 struct drm_tegra_syncpoint *syncpt,
120                                 enum drm_tegra_sync_cond cond);
121 
122 int drm_tegra_syncpoint_new(struct drm_tegra *drm,
123                             struct drm_tegra_syncpoint **syncptp);
124 int drm_tegra_syncpoint_free(struct drm_tegra_syncpoint *syncpt);
125 int drm_tegra_fence_wait(struct drm_tegra_fence *fence, unsigned long timeout);
126 
127 #endif /* __DRM_TEGRA_H__ */
128