Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / tegra / gem.h
blobfafb5724499be51fdb2099801a06807fda0816d1
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Tegra host1x GEM implementation
5 * Copyright (c) 2012-2013, NVIDIA Corporation.
6 */
8 #ifndef __HOST1X_GEM_H
9 #define __HOST1X_GEM_H
11 #include <linux/host1x.h>
13 #include <drm/drm.h>
14 #include <drm/drm_gem.h>
16 #define TEGRA_BO_BOTTOM_UP (1 << 0)
18 enum tegra_bo_tiling_mode {
19 TEGRA_BO_TILING_MODE_PITCH,
20 TEGRA_BO_TILING_MODE_TILED,
21 TEGRA_BO_TILING_MODE_BLOCK,
24 struct tegra_bo_tiling {
25 enum tegra_bo_tiling_mode mode;
26 unsigned long value;
29 struct tegra_bo {
30 struct drm_gem_object gem;
31 struct host1x_bo base;
32 unsigned long flags;
33 struct sg_table *sgt;
34 dma_addr_t iova;
35 void *vaddr;
37 struct drm_mm_node *mm;
38 unsigned long num_pages;
39 struct page **pages;
40 /* size of IOMMU mapping */
41 size_t size;
43 struct tegra_bo_tiling tiling;
46 static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
48 return container_of(gem, struct tegra_bo, gem);
51 static inline struct tegra_bo *host1x_to_tegra_bo(struct host1x_bo *bo)
53 return container_of(bo, struct tegra_bo, base);
56 struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size,
57 unsigned long flags);
58 struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
59 struct drm_device *drm,
60 size_t size,
61 unsigned long flags,
62 u32 *handle);
63 void tegra_bo_free_object(struct drm_gem_object *gem);
64 int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
65 struct drm_mode_create_dumb *args);
67 extern const struct vm_operations_struct tegra_bo_vm_ops;
69 int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma);
70 int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
72 struct dma_buf *tegra_gem_prime_export(struct drm_gem_object *gem,
73 int flags);
74 struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
75 struct dma_buf *buf);
77 #endif