blob: 62492c284cb5b99c9a36316827ec3a7e6603b462 [file] [log] [blame]
Gurchetan Singh46faf6b2016-08-05 14:40:07 -07001/*
Daniele Castagna7a755de2016-12-16 17:32:30 -05002 * Copyright 2016 The Chromium OS Authors. All rights reserved.
Gurchetan Singh46faf6b2016-08-05 14:40:07 -07003 * 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 Singh2e786ad2016-08-24 18:31:23 -070010#include <pthread.h>
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070011#include <stdint.h>
12#include <stdlib.h>
13#include <sys/types.h>
14
15#include "drv.h"
Gurchetan Singh179687e2016-10-28 10:07:35 -070016#include "list.h"
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070017
18struct bo
19{
20 struct driver *drv;
21 uint32_t width;
22 uint32_t height;
23 uint32_t format;
24 uint32_t tiling;
25 size_t num_planes;
26 union bo_handle handles[DRV_MAX_PLANES];
27 uint32_t offsets[DRV_MAX_PLANES];
28 uint32_t sizes[DRV_MAX_PLANES];
29 uint32_t strides[DRV_MAX_PLANES];
30 uint64_t format_modifiers[DRV_MAX_PLANES];
Gurchetan Singha40ca9e2016-08-29 19:51:45 -070031 size_t total_size;
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070032 void *priv;
33};
34
35struct driver {
36 int fd;
37 struct backend *backend;
38 void *priv;
Gurchetan Singh1647fbe2016-08-03 17:14:55 -070039 void *buffer_table;
Gurchetan Singh1a31e602016-10-06 10:58:00 -070040 void *map_table;
Gurchetan Singh27dd4702016-11-23 17:27:52 -080041 pthread_mutex_t driver_lock;
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070042};
43
Gurchetan Singh1a31e602016-10-06 10:58:00 -070044struct map_info {
45 void *addr;
46 size_t length;
47 uint32_t handle;
48 int32_t refcount;
Gurchetan Singh44d1fe42016-12-14 08:51:28 -080049 void *priv;
Gurchetan Singh1a31e602016-10-06 10:58:00 -070050};
51
Gurchetan Singh179687e2016-10-28 10:07:35 -070052struct supported_combination {
53 uint32_t format;
54 uint64_t modifier;
55 uint64_t usage;
56};
57
58struct combination_list_element {
59 struct supported_combination combination;
60 struct list_head link;
61};
62
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070063struct backend
64{
65 char *name;
66 int (*init)(struct driver *drv);
67 void (*close)(struct driver *drv);
68 int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height,
Gurchetan Singhf3b22da2016-11-21 10:46:38 -080069 uint32_t format, uint32_t flags);
Kristian H. Kristensenb1efbd82016-09-06 11:43:26 -070070 int (*bo_create_with_modifiers)(struct bo *bo,
71 uint32_t width, uint32_t height,
72 uint32_t format,
73 const uint64_t *modifiers,
74 uint32_t count);
Gurchetan Singh71611d62017-01-03 16:49:56 -080075 int (*bo_destroy)(struct bo *bo);
76 int (*bo_import)(struct bo *bo, struct drv_import_fd_data *data);
Gurchetan Singh1a31e602016-10-06 10:58:00 -070077 void* (*bo_map)(struct bo *bo, struct map_info *data, size_t plane);
Gurchetan Singh44d1fe42016-12-14 08:51:28 -080078 int (*bo_unmap)(struct bo *bo, struct map_info *data);
Gurchetan Singhf3b22da2016-11-21 10:46:38 -080079 uint32_t (*resolve_format)(uint32_t format);
Gurchetan Singh179687e2016-10-28 10:07:35 -070080 struct list_head combinations;
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070081};
82
83#endif