Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Tegra host1x GEM implementation
4 *
5 * Copyright (c) 2012-2013, NVIDIA Corporation.
6 */
7
8#ifndef __HOST1X_GEM_H
9#define __HOST1X_GEM_H
10
11#include <linux/host1x.h>
12
13#include <drm/drm.h>
14#include <drm/drm_gem.h>
15
16#define TEGRA_BO_BOTTOM_UP (1 << 0)
17
18enum tegra_bo_tiling_mode {
19 TEGRA_BO_TILING_MODE_PITCH,
20 TEGRA_BO_TILING_MODE_TILED,
21 TEGRA_BO_TILING_MODE_BLOCK,
22};
23
24struct tegra_bo_tiling {
25 enum tegra_bo_tiling_mode mode;
26 unsigned long value;
27};
28
29struct 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 paddr;
35 void *vaddr;
36
37 struct drm_mm_node *mm;
38 unsigned long num_pages;
39 struct page **pages;
40 /* size of IOMMU mapping */
41 size_t size;
42
43 struct tegra_bo_tiling tiling;
44};
45
46static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
47{
48 return container_of(gem, struct tegra_bo, gem);
49}
50
51static inline struct tegra_bo *host1x_to_tegra_bo(struct host1x_bo *bo)
52{
53 return container_of(bo, struct tegra_bo, base);
54}
55
56struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size,
57 unsigned long flags);
58struct 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);
63void tegra_bo_free_object(struct drm_gem_object *gem);
64int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
65 struct drm_mode_create_dumb *args);
66
67extern const struct vm_operations_struct tegra_bo_vm_ops;
68
69int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma);
70int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
71
72struct dma_buf *tegra_gem_prime_export(struct drm_gem_object *gem,
73 int flags);
74struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
75 struct dma_buf *buf);
76
77#endif
1/*
2 * Tegra host1x GEM implementation
3 *
4 * Copyright (c) 2012-2013, NVIDIA Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __HOST1X_GEM_H
12#define __HOST1X_GEM_H
13
14#include <linux/host1x.h>
15
16#include <drm/drm.h>
17#include <drm/drmP.h>
18
19#define TEGRA_BO_TILED (1 << 0)
20#define TEGRA_BO_BOTTOM_UP (1 << 1)
21
22struct tegra_bo {
23 struct drm_gem_object gem;
24 struct host1x_bo base;
25 unsigned long flags;
26 struct sg_table *sgt;
27 dma_addr_t paddr;
28 void *vaddr;
29};
30
31static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
32{
33 return container_of(gem, struct tegra_bo, gem);
34}
35
36struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
37 unsigned long flags);
38struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
39 struct drm_device *drm,
40 unsigned int size,
41 unsigned long flags,
42 unsigned int *handle);
43void tegra_bo_free_object(struct drm_gem_object *gem);
44int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
45 struct drm_mode_create_dumb *args);
46int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm,
47 uint32_t handle, uint64_t *offset);
48
49int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
50
51extern const struct vm_operations_struct tegra_bo_vm_ops;
52
53struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
54 struct drm_gem_object *gem,
55 int flags);
56struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
57 struct dma_buf *buf);
58
59#endif