blob: 4bb889da1e721c790ca8d0fd6c9da8c36edf003e [file] [log] [blame]
Rajesh Yadav7f79cb52018-01-22 18:29:06 +05301/*
2 * Copyright 2018 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7#ifdef DRV_MSM
8
Tanmay Shah067594b2018-11-26 10:05:18 -08009#include <assert.h>
Rob Clarke48e4d72020-08-07 08:08:30 -070010#include <dlfcn.h>
Tanmay Shah067594b2018-11-26 10:05:18 -080011#include <drm_fourcc.h>
Tanmay Shah617ee712018-07-11 16:41:05 -070012#include <errno.h>
Stephen Boyd5ff0cfd2019-04-09 11:03:00 -070013#include <inttypes.h>
Tanmay Shah617ee712018-07-11 16:41:05 -070014#include <msm_drm.h>
Tanmay Shah067594b2018-11-26 10:05:18 -080015#include <stdbool.h>
Tanmay Shah617ee712018-07-11 16:41:05 -070016#include <stdio.h>
17#include <string.h>
18#include <sys/mman.h>
19#include <xf86drm.h>
20
Yiwei Zhangb7a64442021-09-30 05:13:10 +000021#include "drv_helpers.h"
Rajesh Yadav7f79cb52018-01-22 18:29:06 +053022#include "drv_priv.h"
Rajesh Yadav7f79cb52018-01-22 18:29:06 +053023#include "util.h"
24
Tanmay Shah067594b2018-11-26 10:05:18 -080025/* Alignment values are based on SDM845 Gfx IP */
Tanmay Shah617ee712018-07-11 16:41:05 -070026#define DEFAULT_ALIGNMENT 64
Tanmay Shahc65bd8c2018-11-21 09:14:14 -080027#define BUFFER_SIZE_ALIGN 4096
28
29#define VENUS_STRIDE_ALIGN 128
30#define VENUS_SCANLINE_ALIGN 16
31#define NV12_LINEAR_PADDING (12 * 1024)
Tanmay Shah067594b2018-11-26 10:05:18 -080032#define NV12_UBWC_PADDING(y_stride) (MAX(16 * 1024, y_stride * 48))
33#define MACROTILE_WIDTH_ALIGN 64
34#define MACROTILE_HEIGHT_ALIGN 16
35#define PLANE_SIZE_ALIGN 4096
36
37#define MSM_UBWC_TILING 1
Stéphane Marchesin23e006a2018-02-28 16:37:46 -080038
Gurchetan Singhb131c9d2018-08-28 14:17:05 -070039static const uint32_t render_target_formats[] = { DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888,
Gurchetan Singh71bc6652018-09-17 17:42:05 -070040 DRM_FORMAT_RGB565, DRM_FORMAT_XBGR8888,
41 DRM_FORMAT_XRGB8888 };
Rajesh Yadav7f79cb52018-01-22 18:29:06 +053042
Tanmay Shah617ee712018-07-11 16:41:05 -070043static const uint32_t texture_source_formats[] = { DRM_FORMAT_NV12, DRM_FORMAT_R8,
Fritz Koenig2471aa22021-08-17 10:32:12 -070044 DRM_FORMAT_YVU420, DRM_FORMAT_YVU420_ANDROID,
45 DRM_FORMAT_P010 };
Alexandre Courbot1805a9b2018-05-21 19:05:10 +090046
Tanmay Shah067594b2018-11-26 10:05:18 -080047/*
48 * Each macrotile consists of m x n (mostly 4 x 4) tiles.
49 * Pixel data pitch/stride is aligned with macrotile width.
50 * Pixel data height is aligned with macrotile height.
51 * Entire pixel data buffer is aligned with 4k(bytes).
52 */
53static uint32_t get_ubwc_meta_size(uint32_t width, uint32_t height, uint32_t tile_width,
54 uint32_t tile_height)
55{
56 uint32_t macrotile_width, macrotile_height;
57
58 macrotile_width = DIV_ROUND_UP(width, tile_width);
59 macrotile_height = DIV_ROUND_UP(height, tile_height);
60
61 // Align meta buffer width to 64 blocks
62 macrotile_width = ALIGN(macrotile_width, MACROTILE_WIDTH_ALIGN);
63
64 // Align meta buffer height to 16 blocks
65 macrotile_height = ALIGN(macrotile_height, MACROTILE_HEIGHT_ALIGN);
66
67 return ALIGN(macrotile_width * macrotile_height, PLANE_SIZE_ALIGN);
68}
69
Rob Clark72787582020-12-01 12:13:13 -080070static unsigned get_pitch_alignment(struct bo *bo)
71{
72 switch (bo->meta.format) {
73 case DRM_FORMAT_NV12:
74 return VENUS_STRIDE_ALIGN;
75 case DRM_FORMAT_YVU420:
76 case DRM_FORMAT_YVU420_ANDROID:
77 /* TODO other YUV formats? */
78 /* Something (in the video stack?) assumes the U/V planes can use
79 * half the pitch as the Y plane.. to componsate, double the
80 * alignment:
81 */
82 return 2 * DEFAULT_ALIGNMENT;
83 default:
84 return DEFAULT_ALIGNMENT;
85 }
86}
87
Tanmay Shah067594b2018-11-26 10:05:18 -080088static void msm_calculate_layout(struct bo *bo)
Tanmay Shahc65bd8c2018-11-21 09:14:14 -080089{
90 uint32_t width, height;
91
Gurchetan Singh298b7572019-09-19 09:55:18 -070092 width = bo->meta.width;
93 height = bo->meta.height;
Tanmay Shahc65bd8c2018-11-21 09:14:14 -080094
95 /* NV12 format requires extra padding with platform
96 * specific alignments for venus driver
97 */
Fritz Koenig2471aa22021-08-17 10:32:12 -070098 if (bo->meta.format == DRM_FORMAT_NV12 || bo->meta.format == DRM_FORMAT_P010) {
Tanmay Shah067594b2018-11-26 10:05:18 -080099 uint32_t y_stride, uv_stride, y_scanline, uv_scanline, y_plane, uv_plane, size,
100 extra_padding;
101
Fritz Koenig2471aa22021-08-17 10:32:12 -0700102 // P010 has the same layout as NV12. The difference is that each
103 // pixel in P010 takes 2 bytes, while in NV12 each pixel takes 1 byte.
104 if (bo->meta.format == DRM_FORMAT_P010)
105 width *= 2;
106
Tanmay Shahc65bd8c2018-11-21 09:14:14 -0800107 y_stride = ALIGN(width, VENUS_STRIDE_ALIGN);
108 uv_stride = ALIGN(width, VENUS_STRIDE_ALIGN);
109 y_scanline = ALIGN(height, VENUS_SCANLINE_ALIGN * 2);
Fritz Koenigb03e9c82020-09-09 15:22:46 -0700110 uv_scanline = ALIGN(DIV_ROUND_UP(height, 2),
Gurchetan Singh99644382020-10-07 15:28:11 -0700111 VENUS_SCANLINE_ALIGN * (bo->meta.tiling ? 2 : 1));
Tanmay Shahc65bd8c2018-11-21 09:14:14 -0800112 y_plane = y_stride * y_scanline;
113 uv_plane = uv_stride * uv_scanline;
114
Gurchetan Singh298b7572019-09-19 09:55:18 -0700115 if (bo->meta.tiling == MSM_UBWC_TILING) {
Fritz Koenigb03e9c82020-09-09 15:22:46 -0700116 y_plane = ALIGN(y_plane, PLANE_SIZE_ALIGN);
117 uv_plane = ALIGN(uv_plane, PLANE_SIZE_ALIGN);
Tanmay Shah067594b2018-11-26 10:05:18 -0800118 y_plane += get_ubwc_meta_size(width, height, 32, 8);
119 uv_plane += get_ubwc_meta_size(width >> 1, height >> 1, 16, 8);
120 extra_padding = NV12_UBWC_PADDING(y_stride);
121 } else {
122 extra_padding = NV12_LINEAR_PADDING;
123 }
124
Gurchetan Singh298b7572019-09-19 09:55:18 -0700125 bo->meta.strides[0] = y_stride;
126 bo->meta.sizes[0] = y_plane;
127 bo->meta.offsets[1] = y_plane;
128 bo->meta.strides[1] = uv_stride;
Tanmay Shah067594b2018-11-26 10:05:18 -0800129 size = y_plane + uv_plane + extra_padding;
Gurchetan Singh298b7572019-09-19 09:55:18 -0700130 bo->meta.total_size = ALIGN(size, BUFFER_SIZE_ALIGN);
131 bo->meta.sizes[1] = bo->meta.total_size - bo->meta.sizes[0];
Tanmay Shahc65bd8c2018-11-21 09:14:14 -0800132 } else {
133 uint32_t stride, alignw, alignh;
134
Rob Clark72787582020-12-01 12:13:13 -0800135 alignw = ALIGN(width, get_pitch_alignment(bo));
Jeffrey Kardatzkea6a9efc2020-02-21 15:35:01 -0800136 /* HAL_PIXEL_FORMAT_YV12 requires that the buffer's height not be aligned.
137 DRM_FORMAT_R8 of height one is used for JPEG camera output, so don't
138 height align that. */
139 if (bo->meta.format == DRM_FORMAT_YVU420_ANDROID ||
Gurchetan Singh8d884742020-03-24 13:48:54 -0700140 (bo->meta.format == DRM_FORMAT_R8 && height == 1)) {
Tanmay Shahc65bd8c2018-11-21 09:14:14 -0800141 alignh = height;
142 } else {
143 alignh = ALIGN(height, DEFAULT_ALIGNMENT);
144 }
145
Gurchetan Singh298b7572019-09-19 09:55:18 -0700146 stride = drv_stride_from_format(bo->meta.format, alignw, 0);
Tanmay Shahc65bd8c2018-11-21 09:14:14 -0800147
148 /* Calculate size and assign stride, size, offset to each plane based on format */
Gurchetan Singh298b7572019-09-19 09:55:18 -0700149 drv_bo_from_format(bo, stride, alignh, bo->meta.format);
Tanmay Shah067594b2018-11-26 10:05:18 -0800150
151 /* For all RGB UBWC formats */
Gurchetan Singh298b7572019-09-19 09:55:18 -0700152 if (bo->meta.tiling == MSM_UBWC_TILING) {
153 bo->meta.sizes[0] += get_ubwc_meta_size(width, height, 16, 4);
154 bo->meta.total_size = bo->meta.sizes[0];
155 assert(IS_ALIGNED(bo->meta.total_size, BUFFER_SIZE_ALIGN));
Tanmay Shah067594b2018-11-26 10:05:18 -0800156 }
157 }
158}
159
160static bool is_ubwc_fmt(uint32_t format)
161{
162 switch (format) {
163 case DRM_FORMAT_XBGR8888:
164 case DRM_FORMAT_ABGR8888:
Fritz Koenige5c3fdf2019-12-10 16:30:34 -0800165 case DRM_FORMAT_XRGB8888:
166 case DRM_FORMAT_ARGB8888:
Tanmay Shah067594b2018-11-26 10:05:18 -0800167 case DRM_FORMAT_NV12:
168 return 1;
169 default:
170 return 0;
171 }
172}
173
174static void msm_add_ubwc_combinations(struct driver *drv, const uint32_t *formats,
175 uint32_t num_formats, struct format_metadata *metadata,
176 uint64_t use_flags)
177{
178 for (uint32_t i = 0; i < num_formats; i++) {
179 if (is_ubwc_fmt(formats[i])) {
180 struct combination combo = { .format = formats[i],
181 .metadata = *metadata,
182 .use_flags = use_flags };
183 drv_array_append(drv->combos, &combo);
184 }
Tanmay Shahc65bd8c2018-11-21 09:14:14 -0800185 }
186}
187
Rob Clarke48e4d72020-08-07 08:08:30 -0700188/**
189 * Check for buggy apps that are known to not support modifiers, to avoid surprising them
190 * with a UBWC buffer.
191 */
192static bool should_avoid_ubwc(void)
193{
194#ifndef __ANDROID__
195 /* waffle is buggy and, requests a renderable buffer (which on qcom platforms, we
196 * want to use UBWC), and then passes it to the kernel discarding the modifier.
197 * So mesa ends up correctly rendering to as tiled+compressed, but kernel tries
198 * to display as linear. Other platforms do not see this issue, simply because
199 * they only use compressed (ex, AFBC) with the BO_USE_SCANOUT flag.
200 *
201 * See b/163137550
202 */
203 if (dlsym(RTLD_DEFAULT, "waffle_display_connect")) {
204 drv_log("WARNING: waffle detected, disabling UBWC\n");
205 return true;
206 }
Fritz Koenig1d3637f2020-11-06 09:39:34 -0800207
208 /* The video_decode_accelerator_tests needs to read back the frames
209 * to verify they are correct. The frame verification relies on
210 * computing the MD5 of the video frame. UBWC results in a different
211 * MD5. This turns off UBWC for gtest until a proper frame
212 * comparison can be made
213 * Rely on the same mechanism that waffle is using, but this time check
214 * for a dynamic library function that is present in chrome, but missing
215 * in gtest. Cups is not loaded for video tests.
216 *
217 * See b/171260705
218 */
219 if (!dlsym(RTLD_DEFAULT, "cupsFilePrintf")) {
220 drv_log("WARNING: gtest detected, disabling UBWC\n");
221 return true;
222 }
Rob Clarke48e4d72020-08-07 08:08:30 -0700223#endif
224 return false;
225}
226
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530227static int msm_init(struct driver *drv)
228{
Tanmay Shah067594b2018-11-26 10:05:18 -0800229 struct format_metadata metadata;
Jeffrey Kardatzkeafb2c562020-03-02 12:25:55 -0800230 uint64_t render_use_flags = BO_USE_RENDER_MASK | BO_USE_SCANOUT;
Tanmay Shah067594b2018-11-26 10:05:18 -0800231 uint64_t texture_use_flags = BO_USE_TEXTURE_MASK | BO_USE_HW_VIDEO_DECODER;
Rob Clark6f83a442020-10-05 12:10:51 -0700232 /*
233 * NOTE: we actually could use tiled in the BO_USE_FRONT_RENDERING case,
234 * if we had a modifier for tiled-but-not-compressed. But we *cannot* use
235 * compressed in this case because the UBWC flags/meta data can be out of
236 * sync with pixel data while the GPU is writing a frame out to memory.
237 */
Gurchetan Singh146ee022021-04-02 16:34:05 -0700238 uint64_t sw_flags =
239 (BO_USE_RENDERSCRIPT | BO_USE_SW_MASK | BO_USE_LINEAR | BO_USE_FRONT_RENDERING);
Tanmay Shah067594b2018-11-26 10:05:18 -0800240
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530241 drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
Tanmay Shah067594b2018-11-26 10:05:18 -0800242 &LINEAR_METADATA, render_use_flags);
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530243
Tanmay Shah617ee712018-07-11 16:41:05 -0700244 drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
Tanmay Shah067594b2018-11-26 10:05:18 -0800245 &LINEAR_METADATA, texture_use_flags);
Alexandre Courbot1805a9b2018-05-21 19:05:10 +0900246
Ricky Liangf11f1df2020-02-13 10:42:46 +0800247 /* The camera stack standardizes on NV12 for YUV buffers. */
Hirokazu Honda3bd681c2020-06-23 17:52:20 +0900248 /* YVU420 and NV12 formats for camera, display and encoding. */
Ricky Liangf11f1df2020-02-13 10:42:46 +0800249 drv_modify_combination(drv, DRM_FORMAT_NV12, &LINEAR_METADATA,
Hirokazu Honda3bd681c2020-06-23 17:52:20 +0900250 BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_SCANOUT |
251 BO_USE_HW_VIDEO_ENCODER);
252
Ricky Liangf11f1df2020-02-13 10:42:46 +0800253 /*
254 * R8 format is used for Android's HAL_PIXEL_FORMAT_BLOB and is used for JPEG snapshots
David Stevens49518142020-06-15 13:48:48 +0900255 * from camera and input/output from hardware decoder/encoder.
Ricky Liangf11f1df2020-02-13 10:42:46 +0800256 */
Douglas Anderson0c03c9b2020-07-21 08:06:46 -0700257 drv_modify_combination(drv, DRM_FORMAT_R8, &LINEAR_METADATA,
David Stevens49518142020-06-15 13:48:48 +0900258 BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_HW_VIDEO_DECODER |
259 BO_USE_HW_VIDEO_ENCODER);
Ricky Liangf11f1df2020-02-13 10:42:46 +0800260
John Stultzd9381b62021-07-28 06:23:03 +0000261 /*
262 * Android also frequently requests YV12 formats for some camera implementations
263 * (including the external provider implmenetation). So mark it as well as valid
264 * for camera display and encoding.
265 */
266 drv_modify_combination(drv, DRM_FORMAT_YVU420_ANDROID, &LINEAR_METADATA,
267 BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_SCANOUT |
268 BO_USE_HW_VIDEO_ENCODER);
269
Gurchetan Singh71bc6652018-09-17 17:42:05 -0700270 /* Android CTS tests require this. */
271 drv_add_combination(drv, DRM_FORMAT_BGR888, &LINEAR_METADATA, BO_USE_SW_MASK);
272
Fritz Koenig2471aa22021-08-17 10:32:12 -0700273#ifdef SC_7280
274 drv_modify_combination(drv, DRM_FORMAT_P010, &LINEAR_METADATA,
275 BO_USE_SCANOUT | BO_USE_HW_VIDEO_ENCODER);
276#endif
277
Tanmay Shah067594b2018-11-26 10:05:18 -0800278 drv_modify_linear_combinations(drv);
279
Pilar Molina Lopez28cf2f12020-11-12 18:19:42 -0500280 if (should_avoid_ubwc() || !drv->compression)
Rob Clarke48e4d72020-08-07 08:08:30 -0700281 return 0;
282
Tanmay Shah067594b2018-11-26 10:05:18 -0800283 metadata.tiling = MSM_UBWC_TILING;
284 metadata.priority = 2;
285 metadata.modifier = DRM_FORMAT_MOD_QCOM_COMPRESSED;
286
287 render_use_flags &= ~sw_flags;
288 texture_use_flags &= ~sw_flags;
289
Kristian H. Kristensen8f782d82020-08-26 00:26:24 +0000290 msm_add_ubwc_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
291 &metadata, render_use_flags);
Tanmay Shah067594b2018-11-26 10:05:18 -0800292
Kristian H. Kristensen8f782d82020-08-26 00:26:24 +0000293 msm_add_ubwc_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
294 &metadata, texture_use_flags);
Tanmay Shah067594b2018-11-26 10:05:18 -0800295
Fritz Koenigb8226cb2020-08-07 14:56:18 -0700296 drv_modify_combination(drv, DRM_FORMAT_NV12, &metadata,
Gurchetan Singh45ca4492021-04-28 17:12:52 -0700297 BO_USE_SCANOUT | BO_USE_HW_VIDEO_ENCODER);
Fritz Koenigb8226cb2020-08-07 14:56:18 -0700298
Tanmay Shah067594b2018-11-26 10:05:18 -0800299 return 0;
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530300}
301
Tanmay Shah067594b2018-11-26 10:05:18 -0800302static int msm_bo_create_for_modifier(struct bo *bo, uint32_t width, uint32_t height,
303 uint32_t format, const uint64_t modifier)
Stéphane Marchesin23e006a2018-02-28 16:37:46 -0800304{
Gurchetan Singh99644382020-10-07 15:28:11 -0700305 struct drm_msm_gem_new req = { 0 };
Tanmay Shah617ee712018-07-11 16:41:05 -0700306 int ret;
307 size_t i;
308
Gurchetan Singh298b7572019-09-19 09:55:18 -0700309 bo->meta.tiling = (modifier == DRM_FORMAT_MOD_QCOM_COMPRESSED) ? MSM_UBWC_TILING : 0;
Tanmay Shah067594b2018-11-26 10:05:18 -0800310 msm_calculate_layout(bo);
Tanmay Shah617ee712018-07-11 16:41:05 -0700311
Tanmay Shah617ee712018-07-11 16:41:05 -0700312 req.flags = MSM_BO_WC | MSM_BO_SCANOUT;
Gurchetan Singh298b7572019-09-19 09:55:18 -0700313 req.size = bo->meta.total_size;
Tanmay Shah617ee712018-07-11 16:41:05 -0700314
315 ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MSM_GEM_NEW, &req);
316 if (ret) {
317 drv_log("DRM_IOCTL_MSM_GEM_NEW failed with %s\n", strerror(errno));
Stéphane Marchesin6ac299f2019-03-21 12:23:29 -0700318 return -errno;
Tanmay Shah617ee712018-07-11 16:41:05 -0700319 }
320
321 /*
322 * Though we use only one plane, we need to set handle for
323 * all planes to pass kernel checks
324 */
Gurchetan Singh52155b42021-01-27 17:55:17 -0800325 for (i = 0; i < bo->meta.num_planes; i++)
Tanmay Shah617ee712018-07-11 16:41:05 -0700326 bo->handles[i].u32 = req.handle;
Tanmay Shah617ee712018-07-11 16:41:05 -0700327
Gurchetan Singh52155b42021-01-27 17:55:17 -0800328 bo->meta.format_modifier = modifier;
Tanmay Shah617ee712018-07-11 16:41:05 -0700329 return 0;
330}
331
Tanmay Shah067594b2018-11-26 10:05:18 -0800332static int msm_bo_create_with_modifiers(struct bo *bo, uint32_t width, uint32_t height,
333 uint32_t format, const uint64_t *modifiers, uint32_t count)
334{
335 static const uint64_t modifier_order[] = {
336 DRM_FORMAT_MOD_QCOM_COMPRESSED,
337 DRM_FORMAT_MOD_LINEAR,
338 };
339
340 uint64_t modifier =
341 drv_pick_modifier(modifiers, count, modifier_order, ARRAY_SIZE(modifier_order));
342
Pilar Molina Lopez28cf2f12020-11-12 18:19:42 -0500343 if (!bo->drv->compression && modifier == DRM_FORMAT_MOD_QCOM_COMPRESSED)
344 modifier = DRM_FORMAT_MOD_LINEAR;
345
Tanmay Shah067594b2018-11-26 10:05:18 -0800346 return msm_bo_create_for_modifier(bo, width, height, format, modifier);
347}
348
349/* msm_bo_create will create linear buffers for now */
350static int msm_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
351 uint64_t flags)
352{
353 struct combination *combo = drv_get_combination(bo->drv, format, flags);
354
355 if (!combo) {
Stephen Boyd5ff0cfd2019-04-09 11:03:00 -0700356 drv_log("invalid format = %d, flags = %" PRIx64 " combination\n", format, flags);
Tanmay Shah067594b2018-11-26 10:05:18 -0800357 return -EINVAL;
358 }
359
360 return msm_bo_create_for_modifier(bo, width, height, format, combo->metadata.modifier);
361}
362
Tanmay Shah617ee712018-07-11 16:41:05 -0700363static void *msm_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags)
364{
365 int ret;
Gurchetan Singh99644382020-10-07 15:28:11 -0700366 struct drm_msm_gem_info req = { 0 };
Tanmay Shah617ee712018-07-11 16:41:05 -0700367
Tanmay Shah617ee712018-07-11 16:41:05 -0700368 req.handle = bo->handles[0].u32;
Tanmay Shah617ee712018-07-11 16:41:05 -0700369 ret = drmIoctl(bo->drv->fd, DRM_IOCTL_MSM_GEM_INFO, &req);
370 if (ret) {
371 drv_log("DRM_IOCLT_MSM_GEM_INFO failed with %s\n", strerror(errno));
372 return MAP_FAILED;
373 }
Gurchetan Singh298b7572019-09-19 09:55:18 -0700374 vma->length = bo->meta.total_size;
Tanmay Shah617ee712018-07-11 16:41:05 -0700375
Gurchetan Singh298b7572019-09-19 09:55:18 -0700376 return mmap(0, bo->meta.total_size, drv_get_prot(map_flags), MAP_SHARED, bo->drv->fd,
Tanmay Shah617ee712018-07-11 16:41:05 -0700377 req.offset);
Stéphane Marchesin23e006a2018-02-28 16:37:46 -0800378}
379
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530380const struct backend backend_msm = {
381 .name = "msm",
382 .init = msm_init,
Stéphane Marchesin23e006a2018-02-28 16:37:46 -0800383 .bo_create = msm_bo_create,
Tanmay Shah067594b2018-11-26 10:05:18 -0800384 .bo_create_with_modifiers = msm_bo_create_with_modifiers,
Tanmay Shah617ee712018-07-11 16:41:05 -0700385 .bo_destroy = drv_gem_bo_destroy,
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530386 .bo_import = drv_prime_bo_import,
Tanmay Shah617ee712018-07-11 16:41:05 -0700387 .bo_map = msm_bo_map,
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530388 .bo_unmap = drv_bo_munmap,
Gurchetan Singh695125c2021-02-03 08:44:09 -0800389 .resolve_format = drv_resolve_format_helper,
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530390};
Rajesh Yadav7f79cb52018-01-22 18:29:06 +0530391#endif /* DRV_MSM */