1 /* 2 * Copyright 2014 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 DRV_HELPERS_H 8 #define DRV_HELPERS_H 9 10 #include <stdbool.h> 11 12 #include "drv.h" 13 #include "drv_array_helpers.h" 14 15 #ifndef PAGE_SIZE 16 #define PAGE_SIZE 0x1000 17 #endif 18 19 struct format_metadata; 20 21 uint32_t drv_height_from_format(uint32_t format, uint32_t height, size_t plane); 22 uint32_t drv_vertical_subsampling_from_format(uint32_t format, size_t plane); 23 uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane); 24 int drv_bo_from_format(struct bo *bo, uint32_t stride, uint32_t aligned_height, uint32_t format); 25 int drv_bo_from_format_and_padding(struct bo *bo, uint32_t stride, uint32_t aligned_height, 26 uint32_t format, uint32_t padding[DRV_MAX_PLANES]); 27 int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, 28 uint64_t use_flags); 29 int drv_dumb_bo_create_ex(struct bo *bo, uint32_t width, uint32_t height, uint32_t format, 30 uint64_t use_flags, uint64_t quirks); 31 int drv_dumb_bo_destroy(struct bo *bo); 32 int drv_gem_bo_destroy(struct bo *bo); 33 int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data); 34 void *drv_dumb_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags); 35 int drv_bo_munmap(struct bo *bo, struct vma *vma); 36 int drv_get_prot(uint32_t map_flags); 37 void drv_add_combination(struct driver *drv, uint32_t format, struct format_metadata *metadata, 38 uint64_t usage); 39 void drv_add_combinations(struct driver *drv, const uint32_t *formats, uint32_t num_formats, 40 struct format_metadata *metadata, uint64_t usage); 41 void drv_modify_combination(struct driver *drv, uint32_t format, struct format_metadata *metadata, 42 uint64_t usage); 43 int drv_modify_linear_combinations(struct driver *drv); 44 uint64_t drv_pick_modifier(const uint64_t *modifiers, uint32_t count, 45 const uint64_t *modifier_order, uint32_t order_count); 46 bool drv_has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier); 47 void drv_resolve_format_and_use_flags_helper(struct driver *drv, uint32_t format, 48 uint64_t use_flags, uint32_t *out_format, 49 uint64_t *out_use_flags); 50 51 #endif 52