blob: 8db622b2ac614e2a86fcfbc0de85402c1eb05484 [file] [log] [blame]
Stéphane Marchesin25a26062014-09-12 16:18:59 -07001/*
Daniele Castagna7a755de2016-12-16 17:32:30 -05002 * Copyright 2014 The Chromium OS Authors. All rights reserved.
Stéphane Marchesin25a26062014-09-12 16:18:59 -07003 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
Yuly Novikov96c7a3b2015-12-08 22:48:29 -05007#include <assert.h>
Dominik Behrf7b33d72014-11-11 07:17:11 -08008#include <fcntl.h>
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -08009#include <stdint.h>
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
Gurchetan Singh1ef809e2017-11-06 11:07:52 -080013#include <sys/mman.h>
Stéphane Marchesin25a26062014-09-12 16:18:59 -070014#include <xf86drm.h>
15
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070016#include "drv.h"
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070017#include "gbm_helpers.h"
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080018#include "gbm_priv.h"
Stéphane Marchesin25a26062014-09-12 16:18:59 -070019#include "util.h"
20
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080021PUBLIC int gbm_device_get_fd(struct gbm_device *gbm)
Stéphane Marchesin25a26062014-09-12 16:18:59 -070022{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070023
24 return drv_get_fd(gbm->drv);
Stéphane Marchesin25a26062014-09-12 16:18:59 -070025}
26
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080027PUBLIC const char *gbm_device_get_backend_name(struct gbm_device *gbm)
Stéphane Marchesin25a26062014-09-12 16:18:59 -070028{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070029 return drv_get_name(gbm->drv);
Stéphane Marchesin25a26062014-09-12 16:18:59 -070030}
31
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080032PUBLIC int gbm_device_is_format_supported(struct gbm_device *gbm, uint32_t format, uint32_t usage)
Stéphane Marchesin25a26062014-09-12 16:18:59 -070033{
Gurchetan Singha1892b22017-09-28 16:40:52 -070034 uint64_t use_flags;
Stéphane Marchesin25a26062014-09-12 16:18:59 -070035
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080036 if (usage & GBM_BO_USE_CURSOR && usage & GBM_BO_USE_RENDERING)
Stéphane Marchesin25a26062014-09-12 16:18:59 -070037 return 0;
38
Gurchetan Singha1892b22017-09-28 16:40:52 -070039 use_flags = gbm_convert_usage(usage);
Stéphane Marchesin25a26062014-09-12 16:18:59 -070040
Gurchetan Singha1892b22017-09-28 16:40:52 -070041 return (drv_get_combination(gbm->drv, format, use_flags) != NULL);
Stéphane Marchesin25a26062014-09-12 16:18:59 -070042}
43
44PUBLIC struct gbm_device *gbm_create_device(int fd)
45{
46 struct gbm_device *gbm;
Stéphane Marchesin25a26062014-09-12 16:18:59 -070047
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080048 gbm = (struct gbm_device *)malloc(sizeof(*gbm));
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070049
Stéphane Marchesin25a26062014-09-12 16:18:59 -070050 if (!gbm)
51 return NULL;
52
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070053 gbm->drv = drv_create(fd);
54 if (!gbm->drv) {
Stéphane Marchesin25a26062014-09-12 16:18:59 -070055 free(gbm);
56 return NULL;
57 }
58
Stéphane Marchesin25a26062014-09-12 16:18:59 -070059 return gbm;
60}
61
62PUBLIC void gbm_device_destroy(struct gbm_device *gbm)
63{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070064 drv_destroy(gbm->drv);
Stéphane Marchesin25a26062014-09-12 16:18:59 -070065 free(gbm);
66}
67
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080068PUBLIC struct gbm_surface *gbm_surface_create(struct gbm_device *gbm, uint32_t width,
Gurchetan Singha1892b22017-09-28 16:40:52 -070069 uint32_t height, uint32_t format, uint32_t usage)
Stéphane Marchesin25a26062014-09-12 16:18:59 -070070{
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080071 struct gbm_surface *surface = (struct gbm_surface *)malloc(sizeof(*surface));
Stéphane Marchesinec88e892015-11-03 16:14:59 -080072
Stéphane Marchesin25a26062014-09-12 16:18:59 -070073 if (!surface)
74 return NULL;
75
76 return surface;
77}
78
79PUBLIC void gbm_surface_destroy(struct gbm_surface *surface)
80{
81 free(surface);
82}
83
84PUBLIC struct gbm_bo *gbm_surface_lock_front_buffer(struct gbm_surface *surface)
85{
86 return NULL;
87}
88
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080089PUBLIC void gbm_surface_release_buffer(struct gbm_surface *surface, struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -070090{
91}
92
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070093static struct gbm_bo *gbm_bo_new(struct gbm_device *gbm, uint32_t format)
Stéphane Marchesin25a26062014-09-12 16:18:59 -070094{
95 struct gbm_bo *bo;
Stéphane Marchesin25a26062014-09-12 16:18:59 -070096
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080097 bo = (struct gbm_bo *)calloc(1, sizeof(*bo));
Stéphane Marchesin25a26062014-09-12 16:18:59 -070098 if (!bo)
99 return NULL;
100
101 bo->gbm = gbm;
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700102 bo->gbm_format = format;
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700103
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800104 return bo;
105}
106
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800107PUBLIC struct gbm_bo *gbm_bo_create(struct gbm_device *gbm, uint32_t width, uint32_t height,
Gurchetan Singha1892b22017-09-28 16:40:52 -0700108 uint32_t format, uint32_t usage)
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800109{
110 struct gbm_bo *bo;
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800111
Gurchetan Singha1892b22017-09-28 16:40:52 -0700112 if (!gbm_device_is_format_supported(gbm, format, usage))
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500113 return NULL;
114
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700115 bo = gbm_bo_new(gbm, format);
116
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800117 if (!bo)
118 return NULL;
119
Gurchetan Singhc062c3b2019-06-20 20:48:01 -0700120 /*
121 * HACK: This is for HAL_PIXEL_FORMAT_YV12 buffers allocated by arcvm.
122 * None of our platforms can display YV12, so we can treat as a SW buffer.
123 * Remove once this can be intelligently resolved in the guest.
124 */
125 if (format == GBM_FORMAT_YVU420 && (usage & GBM_BO_USE_LINEAR))
126 format = DRM_FORMAT_YVU420_ANDROID;
127
Gurchetan Singha1892b22017-09-28 16:40:52 -0700128 bo->bo = drv_bo_create(gbm->drv, width, height, format, gbm_convert_usage(usage));
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700129
130 if (!bo->bo) {
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700131 free(bo);
132 return NULL;
133 }
134
135 return bo;
136}
137
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800138PUBLIC struct gbm_bo *gbm_bo_create_with_modifiers(struct gbm_device *gbm, uint32_t width,
139 uint32_t height, uint32_t format,
140 const uint64_t *modifiers, uint32_t count)
Kristian H. Kristensenb1efbd82016-09-06 11:43:26 -0700141{
142 struct gbm_bo *bo;
143
144 bo = gbm_bo_new(gbm, format);
145
146 if (!bo)
147 return NULL;
148
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800149 bo->bo = drv_bo_create_with_modifiers(gbm->drv, width, height, format, modifiers, count);
Kristian H. Kristensenb1efbd82016-09-06 11:43:26 -0700150
151 if (!bo->bo) {
152 free(bo);
153 return NULL;
154 }
155
156 return bo;
157}
158
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700159PUBLIC void gbm_bo_destroy(struct gbm_bo *bo)
160{
161 if (bo->destroy_user_data) {
162 bo->destroy_user_data(bo, bo->user_data);
163 bo->destroy_user_data = NULL;
164 bo->user_data = NULL;
165 }
166
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700167 drv_bo_destroy(bo->bo);
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700168 free(bo);
169}
170
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800171PUBLIC struct gbm_bo *gbm_bo_import(struct gbm_device *gbm, uint32_t type, void *buffer,
172 uint32_t usage)
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800173{
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800174 struct gbm_bo *bo;
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700175 struct drv_import_fd_data drv_data;
176 struct gbm_import_fd_data *fd_data = buffer;
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700177 struct gbm_import_fd_planar_data *fd_planar_data = buffer;
Maksim Sisov4fe30382019-01-07 15:11:47 +0200178 struct gbm_import_fd_modifier_data *fd_modifier_data = buffer;
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700179 uint32_t gbm_format;
Maksim Sisov4fe30382019-01-07 15:11:47 +0200180 size_t num_planes, i, num_fds;
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800181
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700182 memset(&drv_data, 0, sizeof(drv_data));
Gurchetan Singha1892b22017-09-28 16:40:52 -0700183 drv_data.use_flags = gbm_convert_usage(usage);
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700184 switch (type) {
185 case GBM_BO_IMPORT_FD:
186 gbm_format = fd_data->format;
187 drv_data.width = fd_data->width;
188 drv_data.height = fd_data->height;
Gurchetan Singhf3b22da2016-11-21 10:46:38 -0800189 drv_data.format = fd_data->format;
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700190 drv_data.fds[0] = fd_data->fd;
191 drv_data.strides[0] = fd_data->stride;
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700192 break;
Maksim Sisov4fe30382019-01-07 15:11:47 +0200193 case GBM_BO_IMPORT_FD_MODIFIER:
194 gbm_format = fd_modifier_data->format;
195 drv_data.width = fd_modifier_data->width;
196 drv_data.height = fd_modifier_data->height;
197 drv_data.format = fd_modifier_data->format;
198 num_planes = drv_num_planes_from_format(drv_data.format);
Mark Yacoub769de642019-07-09 13:59:50 -0400199 assert(num_planes);
Maksim Sisov4fe30382019-01-07 15:11:47 +0200200
Mark Yacoub769de642019-07-09 13:59:50 -0400201 num_fds = fd_modifier_data->num_fds;
202 if (!num_fds || num_fds > num_planes)
203 return NULL;
204
Maksim Sisov4fe30382019-01-07 15:11:47 +0200205 for (i = 0; i < num_planes; i++) {
206 if (num_fds != num_planes)
207 drv_data.fds[i] = fd_modifier_data->fds[0];
208 else
209 drv_data.fds[i] = fd_modifier_data->fds[i];
210 drv_data.offsets[i] = fd_modifier_data->offsets[i];
211 drv_data.strides[i] = fd_modifier_data->strides[i];
212 drv_data.format_modifiers[i] = fd_modifier_data->modifier;
213 }
214
215 for (i = num_planes; i < GBM_MAX_PLANES; i++)
216 drv_data.fds[i] = -1;
217
218 break;
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700219 case GBM_BO_IMPORT_FD_PLANAR:
220 gbm_format = fd_planar_data->format;
221 drv_data.width = fd_planar_data->width;
222 drv_data.height = fd_planar_data->height;
Gurchetan Singhf3b22da2016-11-21 10:46:38 -0800223 drv_data.format = fd_planar_data->format;
Gurchetan Singh2a119342016-11-02 10:40:51 -0700224 num_planes = drv_num_planes_from_format(drv_data.format);
225
226 assert(num_planes);
227
228 for (i = 0; i < num_planes; i++) {
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700229 drv_data.fds[i] = fd_planar_data->fds[i];
230 drv_data.offsets[i] = fd_planar_data->offsets[i];
231 drv_data.strides[i] = fd_planar_data->strides[i];
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800232 drv_data.format_modifiers[i] = fd_planar_data->format_modifiers[i];
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700233 }
Gurchetan Singh2a119342016-11-02 10:40:51 -0700234
235 for (i = num_planes; i < GBM_MAX_PLANES; i++)
236 drv_data.fds[i] = -1;
237
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700238 break;
239 default:
240 return NULL;
241 }
242
243 if (!gbm_device_is_format_supported(gbm, gbm_format, usage))
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800244 return NULL;
245
Kristian H. Kristensen33459772016-09-16 11:14:16 -0700246 bo = gbm_bo_new(gbm, gbm_format);
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500247
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800248 if (!bo)
249 return NULL;
250
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700251 bo->bo = drv_bo_import(gbm->drv, &drv_data);
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800252
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700253 if (!bo->bo) {
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800254 free(bo);
255 return NULL;
256 }
257
Stéphane Marchesinf4bfdba2015-11-05 11:43:59 -0800258 return bo;
259}
260
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800261PUBLIC void *gbm_bo_map(struct gbm_bo *bo, uint32_t x, uint32_t y, uint32_t width, uint32_t height,
Gurchetan Singhf7f633a2017-09-28 17:02:12 -0700262 uint32_t transfer_flags, uint32_t *stride, void **map_data, size_t plane)
Gurchetan Singh5753c312016-10-05 15:16:22 -0700263{
Gurchetan Singh1ef809e2017-11-06 11:07:52 -0800264 void *addr;
265 off_t offset;
Gurchetan Singhf7f633a2017-09-28 17:02:12 -0700266 uint32_t map_flags;
Gurchetan Singh2b1d6892018-09-17 16:58:16 -0700267 struct rectangle rect = { .x = x, .y = y, .width = width, .height = height };
Gurchetan Singh5753c312016-10-05 15:16:22 -0700268 if (!bo || width == 0 || height == 0 || !stride || !map_data)
269 return NULL;
270
Gurchetan Singhf7f633a2017-09-28 17:02:12 -0700271 map_flags = (transfer_flags & GBM_BO_TRANSFER_READ) ? BO_MAP_READ : BO_MAP_NONE;
272 map_flags |= (transfer_flags & GBM_BO_TRANSFER_WRITE) ? BO_MAP_WRITE : BO_MAP_NONE;
Gurchetan Singh1ef809e2017-11-06 11:07:52 -0800273
274 addr = drv_bo_map(bo->bo, &rect, map_flags, (struct mapping **)map_data, plane);
275 if (addr == MAP_FAILED)
276 return MAP_FAILED;
277
Satyajit Sahu77b70552018-05-03 16:35:24 +0530278 *stride = ((struct mapping *)*map_data)->vma->map_strides[plane];
279
280 offset = *stride * rect.y;
Gurchetan Singh59598332019-06-27 17:53:24 -0700281 offset += rect.x * drv_bytes_per_pixel_from_format(bo->gbm_format, plane);
Gurchetan Singh1ef809e2017-11-06 11:07:52 -0800282 return (void *)((uint8_t *)addr + offset);
Gurchetan Singh5753c312016-10-05 15:16:22 -0700283}
284
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800285PUBLIC void gbm_bo_unmap(struct gbm_bo *bo, void *map_data)
Gurchetan Singh5753c312016-10-05 15:16:22 -0700286{
287 assert(bo);
Gurchetan Singhbd1b1b52018-03-29 16:34:53 -0700288 drv_bo_flush_or_unmap(bo->bo, map_data);
Gurchetan Singh5753c312016-10-05 15:16:22 -0700289}
290
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800291PUBLIC uint32_t gbm_bo_get_width(struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700292{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700293 return drv_bo_get_width(bo->bo);
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700294}
295
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800296PUBLIC uint32_t gbm_bo_get_height(struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700297{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700298 return drv_bo_get_height(bo->bo);
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700299}
300
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800301PUBLIC uint32_t gbm_bo_get_stride(struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700302{
Keiichi Watanabe79155d72018-08-13 16:44:54 +0900303 return gbm_bo_get_stride_for_plane(bo, 0);
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700304}
305
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800306PUBLIC uint32_t gbm_bo_get_stride_or_tiling(struct gbm_bo *bo)
Lauri Peltonen7842d8f2014-12-17 23:01:37 -0800307{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700308 return drv_bo_get_stride_or_tiling(bo->bo);
Lauri Peltonen7842d8f2014-12-17 23:01:37 -0800309}
310
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800311PUBLIC uint32_t gbm_bo_get_format(struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700312{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700313 return bo->gbm_format;
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700314}
315
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800316PUBLIC uint64_t gbm_bo_get_format_modifier(struct gbm_bo *bo)
Vince Hsua6878fe2016-05-23 10:32:25 +0800317{
Maksim Sisov79205a52018-08-03 16:31:20 +0300318 return gbm_bo_get_modifier(bo);
319}
320
321PUBLIC uint64_t gbm_bo_get_modifier(struct gbm_bo *bo)
322{
Keiichi Watanabe79155d72018-08-13 16:44:54 +0900323 return gbm_bo_get_plane_format_modifier(bo, 0);
Vince Hsua6878fe2016-05-23 10:32:25 +0800324}
325
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800326PUBLIC struct gbm_device *gbm_bo_get_device(struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700327{
328 return bo->gbm;
329}
330
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800331PUBLIC union gbm_bo_handle gbm_bo_get_handle(struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700332{
Maksim Sisovff1ecaf2018-08-10 14:53:34 +0300333 return gbm_bo_get_handle_for_plane(bo, 0);
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700334}
335
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800336PUBLIC int gbm_bo_get_fd(struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700337{
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500338 return gbm_bo_get_plane_fd(bo, 0);
339}
Stéphane Marchesin5bb6adc2014-11-05 20:21:25 -0800340
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800341PUBLIC size_t gbm_bo_get_num_planes(struct gbm_bo *bo)
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500342{
Maksim Sisov79205a52018-08-03 16:31:20 +0300343 return gbm_bo_get_plane_count(bo);
344}
345
346PUBLIC size_t gbm_bo_get_plane_count(struct gbm_bo *bo)
347{
Keiichi Watanabe79155d72018-08-13 16:44:54 +0900348 return drv_bo_get_num_planes(bo->bo);
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500349}
350
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800351PUBLIC union gbm_bo_handle gbm_bo_get_plane_handle(struct gbm_bo *bo, size_t plane)
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500352{
Maksim Sisovff1ecaf2018-08-10 14:53:34 +0300353 return gbm_bo_get_handle_for_plane(bo, plane);
354}
355
Gurchetan Singh2b1d6892018-09-17 16:58:16 -0700356PUBLIC union gbm_bo_handle gbm_bo_get_handle_for_plane(struct gbm_bo *bo, size_t plane)
Maksim Sisovff1ecaf2018-08-10 14:53:34 +0300357{
Gurchetan Singh2b1d6892018-09-17 16:58:16 -0700358 return (union gbm_bo_handle)drv_bo_get_plane_handle(bo->bo, plane).u64;
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500359}
360
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800361PUBLIC int gbm_bo_get_plane_fd(struct gbm_bo *bo, size_t plane)
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500362{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700363 return drv_bo_get_plane_fd(bo->bo, plane);
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700364}
365
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800366PUBLIC uint32_t gbm_bo_get_plane_offset(struct gbm_bo *bo, size_t plane)
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500367{
Maksim Sisov79205a52018-08-03 16:31:20 +0300368 return gbm_bo_get_offset(bo, plane);
369}
370
371PUBLIC uint32_t gbm_bo_get_offset(struct gbm_bo *bo, size_t plane)
372{
Keiichi Watanabe79155d72018-08-13 16:44:54 +0900373 return drv_bo_get_plane_offset(bo->bo, plane);
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500374}
375
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800376PUBLIC uint32_t gbm_bo_get_plane_size(struct gbm_bo *bo, size_t plane)
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500377{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700378 return drv_bo_get_plane_size(bo->bo, plane);
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500379}
380
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800381PUBLIC uint32_t gbm_bo_get_plane_stride(struct gbm_bo *bo, size_t plane)
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500382{
Maksim Sisov79205a52018-08-03 16:31:20 +0300383 return gbm_bo_get_stride_for_plane(bo, plane);
384}
385
386PUBLIC uint32_t gbm_bo_get_stride_for_plane(struct gbm_bo *bo, size_t plane)
387{
Keiichi Watanabe79155d72018-08-13 16:44:54 +0900388 return drv_bo_get_plane_stride(bo->bo, plane);
Yuly Novikov96c7a3b2015-12-08 22:48:29 -0500389}
390
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800391PUBLIC uint64_t gbm_bo_get_plane_format_modifier(struct gbm_bo *bo, size_t plane)
Vince Hsua6878fe2016-05-23 10:32:25 +0800392{
Gurchetan Singh46faf6b2016-08-05 14:40:07 -0700393 return drv_bo_get_plane_format_modifier(bo->bo, plane);
Vince Hsua6878fe2016-05-23 10:32:25 +0800394}
395
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800396PUBLIC void gbm_bo_set_user_data(struct gbm_bo *bo, void *data,
397 void (*destroy_user_data)(struct gbm_bo *, void *))
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700398{
399 bo->user_data = data;
400 bo->destroy_user_data = destroy_user_data;
401}
402
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800403PUBLIC void *gbm_bo_get_user_data(struct gbm_bo *bo)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700404{
405 return bo->user_data;
406}