xref: /linux/drivers/gpu/drm/tegra/gem.h (revision db7fbdfd25ee009165b6c3b80a9d1c6d8534ad94)
1dee8268fSThierry Reding /*
2dee8268fSThierry Reding  * Tegra host1x GEM implementation
3dee8268fSThierry Reding  *
4dee8268fSThierry Reding  * Copyright (c) 2012-2013, NVIDIA Corporation.
5dee8268fSThierry Reding  *
6dee8268fSThierry Reding  * This program is free software; you can redistribute it and/or modify it
7dee8268fSThierry Reding  * under the terms and conditions of the GNU General Public License,
8dee8268fSThierry Reding  * version 2, as published by the Free Software Foundation.
9dee8268fSThierry Reding  *
10dee8268fSThierry Reding  * This program is distributed in the hope it will be useful, but WITHOUT
11dee8268fSThierry Reding  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12dee8268fSThierry Reding  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13dee8268fSThierry Reding  * more details.
14dee8268fSThierry Reding  *
15dee8268fSThierry Reding  * You should have received a copy of the GNU General Public License
16dee8268fSThierry Reding  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17dee8268fSThierry Reding  */
18dee8268fSThierry Reding 
19dee8268fSThierry Reding #ifndef __HOST1X_GEM_H
20dee8268fSThierry Reding #define __HOST1X_GEM_H
21dee8268fSThierry Reding 
22dee8268fSThierry Reding #include <linux/host1x.h>
23dee8268fSThierry Reding 
24dee8268fSThierry Reding #include <drm/drm.h>
25dee8268fSThierry Reding #include <drm/drmP.h>
26dee8268fSThierry Reding 
27773af77fSThierry Reding #define TEGRA_BO_TILED     (1 << 0)
28*db7fbdfdSThierry Reding #define TEGRA_BO_BOTTOM_UP (1 << 1)
29773af77fSThierry Reding 
30dee8268fSThierry Reding struct tegra_bo {
31dee8268fSThierry Reding 	struct drm_gem_object gem;
32dee8268fSThierry Reding 	struct host1x_bo base;
33773af77fSThierry Reding 	unsigned long flags;
34dee8268fSThierry Reding 	dma_addr_t paddr;
35dee8268fSThierry Reding 	void *vaddr;
36dee8268fSThierry Reding };
37dee8268fSThierry Reding 
38dee8268fSThierry Reding static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
39dee8268fSThierry Reding {
40dee8268fSThierry Reding 	return container_of(gem, struct tegra_bo, gem);
41dee8268fSThierry Reding }
42dee8268fSThierry Reding 
43dee8268fSThierry Reding extern const struct host1x_bo_ops tegra_bo_ops;
44dee8268fSThierry Reding 
45773af77fSThierry Reding struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
46773af77fSThierry Reding 				 unsigned long flags);
47dee8268fSThierry Reding struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
48dee8268fSThierry Reding 					     struct drm_device *drm,
49dee8268fSThierry Reding 					     unsigned int size,
50773af77fSThierry Reding 					     unsigned long flags,
51dee8268fSThierry Reding 					     unsigned int *handle);
52dee8268fSThierry Reding void tegra_bo_free_object(struct drm_gem_object *gem);
53dee8268fSThierry Reding int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
54dee8268fSThierry Reding 			 struct drm_mode_create_dumb *args);
55dee8268fSThierry Reding int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm,
56dee8268fSThierry Reding 			     uint32_t handle, uint64_t *offset);
57dee8268fSThierry Reding 
58dee8268fSThierry Reding int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
59dee8268fSThierry Reding 
60dee8268fSThierry Reding extern const struct vm_operations_struct tegra_bo_vm_ops;
61dee8268fSThierry Reding 
62dee8268fSThierry Reding #endif
63