xref: /openbmc/linux/drivers/gpu/drm/tegra/uapi.h (revision 83c51056)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2020 NVIDIA Corporation */
3 
4 #ifndef _TEGRA_DRM_UAPI_H
5 #define _TEGRA_DRM_UAPI_H
6 
7 #include <linux/dma-mapping.h>
8 #include <linux/idr.h>
9 #include <linux/kref.h>
10 #include <linux/xarray.h>
11 
12 #include <drm/drm.h>
13 
14 struct drm_file;
15 struct drm_device;
16 
17 struct tegra_drm_file {
18 	/* Legacy UAPI state */
19 	struct idr legacy_contexts;
20 	struct mutex lock;
21 
22 	/* New UAPI state */
23 	struct xarray contexts;
24 	struct xarray syncpoints;
25 };
26 
27 struct tegra_drm_mapping {
28 	struct kref ref;
29 
30 	struct device *dev;
31 	struct host1x_bo *bo;
32 	struct sg_table *sgt;
33 	enum dma_data_direction direction;
34 	dma_addr_t iova;
35 	dma_addr_t iova_end;
36 };
37 
38 int tegra_drm_ioctl_channel_open(struct drm_device *drm, void *data,
39 				 struct drm_file *file);
40 int tegra_drm_ioctl_channel_close(struct drm_device *drm, void *data,
41 				  struct drm_file *file);
42 int tegra_drm_ioctl_channel_map(struct drm_device *drm, void *data,
43 				struct drm_file *file);
44 int tegra_drm_ioctl_channel_unmap(struct drm_device *drm, void *data,
45 				  struct drm_file *file);
46 int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,
47 				   struct drm_file *file);
48 int tegra_drm_ioctl_syncpoint_allocate(struct drm_device *drm, void *data,
49 				       struct drm_file *file);
50 int tegra_drm_ioctl_syncpoint_free(struct drm_device *drm, void *data,
51 				   struct drm_file *file);
52 int tegra_drm_ioctl_syncpoint_wait(struct drm_device *drm, void *data,
53 				   struct drm_file *file);
54 
55 void tegra_drm_uapi_close_file(struct tegra_drm_file *file);
56 void tegra_drm_mapping_put(struct tegra_drm_mapping *mapping);
57 
58 #endif
59