1 /* 2 * Copyright 2016 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 #ifndef CROS_GRALLOC_HELPERS_H 8 #define CROS_GRALLOC_HELPERS_H 9 10 #include "../drv.h" 11 #include "cros_gralloc_handle.h" 12 13 #include <system/graphics.h> 14 #include <system/window.h> 15 16 #include <string> 17 18 // Reserve the GRALLOC_USAGE_PRIVATE_0 bit from hardware/gralloc.h for buffers 19 // used for front rendering. minigbm backend later decides to use 20 // BO_USE_FRONT_RENDERING or BO_USE_LINEAR upon buffer allocaton. 21 #define BUFFER_USAGE_FRONT_RENDERING (1U << 28) 22 23 struct cros_gralloc_buffer_descriptor { 24 uint32_t width; 25 uint32_t height; 26 int32_t droid_format; 27 int32_t droid_usage; 28 uint32_t drm_format; 29 uint64_t use_flags; 30 uint64_t reserved_region_size; 31 std::string name; 32 }; 33 34 constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA; 35 constexpr uint32_t handle_data_size = 36 ((sizeof(struct cros_gralloc_handle) - offsetof(cros_gralloc_handle, fds[0])) / sizeof(int)); 37 38 uint32_t cros_gralloc_convert_format(int32_t format); 39 40 uint64_t cros_gralloc_convert_usage(uint64_t usage); 41 42 uint32_t cros_gralloc_convert_map_usage(uint64_t usage); 43 44 cros_gralloc_handle_t cros_gralloc_convert_handle(buffer_handle_t handle); 45 46 int32_t cros_gralloc_sync_wait(int32_t fence, bool close_fence); 47 48 std::string get_drm_format_string(uint32_t drm_format); 49 50 #endif 51