Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame] | 1 | /* |
Daniele Castagna | 7a755de | 2016-12-16 17:32:30 -0500 | [diff] [blame] | 2 | * Copyright 2016 The Chromium OS Authors. All rights reserved. |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame] | 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_PRIV_H |
| 8 | #define DRV_PRIV_H |
| 9 | |
Gurchetan Singh | 2e786ad | 2016-08-24 18:31:23 -0700 | [diff] [blame] | 10 | #include <pthread.h> |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame] | 11 | #include <stdint.h> |
| 12 | #include <stdlib.h> |
| 13 | #include <sys/types.h> |
| 14 | |
| 15 | #include "drv.h" |
| 16 | |
| 17 | struct bo |
| 18 | { |
| 19 | struct driver *drv; |
| 20 | uint32_t width; |
| 21 | uint32_t height; |
| 22 | uint32_t format; |
| 23 | uint32_t tiling; |
| 24 | size_t num_planes; |
| 25 | union bo_handle handles[DRV_MAX_PLANES]; |
| 26 | uint32_t offsets[DRV_MAX_PLANES]; |
| 27 | uint32_t sizes[DRV_MAX_PLANES]; |
| 28 | uint32_t strides[DRV_MAX_PLANES]; |
| 29 | uint64_t format_modifiers[DRV_MAX_PLANES]; |
Gurchetan Singh | a40ca9e | 2016-08-29 19:51:45 -0700 | [diff] [blame] | 30 | size_t total_size; |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame] | 31 | void *priv; |
| 32 | }; |
| 33 | |
| 34 | struct driver { |
| 35 | int fd; |
| 36 | struct backend *backend; |
| 37 | void *priv; |
Gurchetan Singh | 1647fbe | 2016-08-03 17:14:55 -0700 | [diff] [blame] | 38 | void *buffer_table; |
Gurchetan Singh | 1a31e60 | 2016-10-06 10:58:00 -0700 | [diff] [blame] | 39 | void *map_table; |
Gurchetan Singh | 27dd470 | 2016-11-23 17:27:52 -0800 | [diff] [blame] | 40 | pthread_mutex_t driver_lock; |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
Gurchetan Singh | 1a31e60 | 2016-10-06 10:58:00 -0700 | [diff] [blame] | 43 | struct map_info { |
| 44 | void *addr; |
| 45 | size_t length; |
| 46 | uint32_t handle; |
| 47 | int32_t refcount; |
Gurchetan Singh | 44d1fe4 | 2016-12-14 08:51:28 -0800 | [diff] [blame] | 48 | void *priv; |
Gurchetan Singh | 1a31e60 | 2016-10-06 10:58:00 -0700 | [diff] [blame] | 49 | }; |
| 50 | |
Gurchetan Singh | 6b41fb5 | 2017-03-01 20:14:39 -0800 | [diff] [blame^] | 51 | struct kms_item { |
Gurchetan Singh | 179687e | 2016-10-28 10:07:35 -0700 | [diff] [blame] | 52 | uint32_t format; |
| 53 | uint64_t modifier; |
| 54 | uint64_t usage; |
| 55 | }; |
| 56 | |
Gurchetan Singh | 6b41fb5 | 2017-03-01 20:14:39 -0800 | [diff] [blame^] | 57 | struct format_metadata { |
| 58 | uint32_t priority; |
| 59 | uint32_t tiling; |
| 60 | uint64_t modifier; |
| 61 | }; |
| 62 | |
| 63 | struct combination { |
| 64 | uint32_t format; |
| 65 | struct format_metadata metadata; |
| 66 | uint64_t usage; |
| 67 | }; |
| 68 | |
| 69 | struct combinations { |
| 70 | struct combination *data; |
| 71 | uint32_t size; |
| 72 | uint32_t allocations; |
Gurchetan Singh | 179687e | 2016-10-28 10:07:35 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame] | 75 | struct backend |
| 76 | { |
| 77 | char *name; |
| 78 | int (*init)(struct driver *drv); |
| 79 | void (*close)(struct driver *drv); |
| 80 | int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height, |
Gurchetan Singh | f3b22da | 2016-11-21 10:46:38 -0800 | [diff] [blame] | 81 | uint32_t format, uint32_t flags); |
Kristian H. Kristensen | b1efbd8 | 2016-09-06 11:43:26 -0700 | [diff] [blame] | 82 | int (*bo_create_with_modifiers)(struct bo *bo, |
| 83 | uint32_t width, uint32_t height, |
| 84 | uint32_t format, |
| 85 | const uint64_t *modifiers, |
| 86 | uint32_t count); |
Gurchetan Singh | 71611d6 | 2017-01-03 16:49:56 -0800 | [diff] [blame] | 87 | int (*bo_destroy)(struct bo *bo); |
| 88 | int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data); |
Gurchetan Singh | 1a31e60 | 2016-10-06 10:58:00 -0700 | [diff] [blame] | 89 | void* (*bo_map)(struct bo *bo, struct map_info *data, size_t plane); |
Gurchetan Singh | 44d1fe4 | 2016-12-14 08:51:28 -0800 | [diff] [blame] | 90 | int (*bo_unmap)(struct bo *bo, struct map_info *data); |
Gurchetan Singh | f3b22da | 2016-11-21 10:46:38 -0800 | [diff] [blame] | 91 | uint32_t (*resolve_format)(uint32_t format); |
Gurchetan Singh | 6b41fb5 | 2017-03-01 20:14:39 -0800 | [diff] [blame^] | 92 | struct combinations combos; |
Gurchetan Singh | 46faf6b | 2016-08-05 14:40:07 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | #endif |