blob: 4f83db5abf8e502da083f2e776730d395b004108 [file] [log] [blame]
Gurchetan Singh46faf6b2016-08-05 14:40:07 -07001/*
2 * Copyright (c) 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 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"
16
17struct 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 Singha40ca9e2016-08-29 19:51:45 -070030 size_t total_size;
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070031 void *priv;
32};
33
34struct driver {
35 int fd;
36 struct backend *backend;
37 void *priv;
Gurchetan Singh1647fbe2016-08-03 17:14:55 -070038 void *buffer_table;
Gurchetan Singh1a31e602016-10-06 10:58:00 -070039 void *map_table;
Gurchetan Singh1647fbe2016-08-03 17:14:55 -070040 pthread_mutex_t table_lock;
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070041};
42
Gurchetan Singh1a31e602016-10-06 10:58:00 -070043struct map_info {
44 void *addr;
45 size_t length;
46 uint32_t handle;
47 int32_t refcount;
48};
49
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070050struct backend
51{
52 char *name;
53 int (*init)(struct driver *drv);
54 void (*close)(struct driver *drv);
55 int (*bo_create)(struct bo *bo, uint32_t width, uint32_t height,
56 drv_format_t format, uint32_t flags);
Gurchetan Singh1a31e602016-10-06 10:58:00 -070057 void* (*bo_map)(struct bo *bo, struct map_info *data, size_t plane);
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070058 int (*bo_destroy)(struct bo *bo);
Gurchetan Singhbfba8c22016-08-16 17:57:10 -070059 drv_format_t (*resolve_format)(drv_format_t format);
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070060 struct format_supported {
61 drv_format_t format;
62 uint64_t usage;
63 }
Gurchetan Singhab7ec192016-09-22 17:00:42 -070064 format_list[19];
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070065};
66
67#endif