• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HELPERS_H
8 #define HELPERS_H
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #include <stdbool.h>
15 
16 #include "drv.h"
17 #include "helpers_array.h"
18 
19 #ifndef PAGE_SIZE
20 #define PAGE_SIZE 0x1000
21 #endif
22 
23 uint32_t drv_height_from_format(uint32_t format, uint32_t height, size_t plane);
24 uint32_t drv_vertical_subsampling_from_format(uint32_t format, size_t plane);
25 uint32_t drv_size_from_format(uint32_t format, uint32_t stride, uint32_t height, size_t plane);
26 int drv_bo_from_format(struct bo *bo, uint32_t stride, uint32_t aligned_height, uint32_t format);
27 int drv_bo_from_format_and_padding(struct bo *bo, uint32_t stride, uint32_t aligned_height,
28 				   uint32_t format, uint32_t padding[DRV_MAX_PLANES]);
29 int drv_dumb_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
30 		       uint64_t use_flags);
31 int drv_dumb_bo_create_ex(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
32 			  uint64_t use_flags, uint64_t quirks);
33 int drv_dumb_bo_destroy(struct bo *bo);
34 int drv_gem_bo_destroy(struct bo *bo);
35 int drv_prime_bo_import(struct bo *bo, struct drv_import_fd_data *data);
36 void *drv_dumb_bo_map(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags);
37 int drv_bo_munmap(struct bo *bo, struct vma *vma);
38 int drv_mapping_destroy(struct bo *bo);
39 int drv_get_prot(uint32_t map_flags);
40 uintptr_t drv_get_reference_count(struct driver *drv, struct bo *bo, size_t plane);
41 void drv_increment_reference_count(struct driver *drv, struct bo *bo, size_t plane);
42 void drv_decrement_reference_count(struct driver *drv, struct bo *bo, size_t plane);
43 void drv_add_combination(struct driver *drv, uint32_t format, struct format_metadata *metadata,
44 			 uint64_t usage);
45 void drv_add_combinations(struct driver *drv, const uint32_t *formats, uint32_t num_formats,
46 			  struct format_metadata *metadata, uint64_t usage);
47 void drv_modify_combination(struct driver *drv, uint32_t format, struct format_metadata *metadata,
48 			    uint64_t usage);
49 int drv_modify_linear_combinations(struct driver *drv);
50 uint64_t drv_pick_modifier(const uint64_t *modifiers, uint32_t count,
51 			   const uint64_t *modifier_order, uint32_t order_count);
52 bool drv_has_modifier(const uint64_t *list, uint32_t count, uint64_t modifier);
53 uint32_t drv_get_standard_fourcc(uint32_t fourcc_internal);
54 uint32_t drv_resolve_format_helper(struct driver *drv, uint32_t format, uint64_t use_flags);
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif
61