xref: /linux/drivers/gpu/drm/tegra/gem.h (revision d9fc9413f97f5c615256a5657ec667c064c07a70)
1dee8268fSThierry Reding /*
2dee8268fSThierry Reding  * Tegra host1x GEM implementation
3dee8268fSThierry Reding  *
4dee8268fSThierry Reding  * Copyright (c) 2012-2013, NVIDIA Corporation.
5dee8268fSThierry Reding  *
69a2ac2dcSThierry Reding  * This program is free software; you can redistribute it and/or modify
79a2ac2dcSThierry Reding  * it under the terms of the GNU General Public License version 2 as
89a2ac2dcSThierry Reding  * published by the Free Software Foundation.
9dee8268fSThierry Reding  */
10dee8268fSThierry Reding 
11dee8268fSThierry Reding #ifndef __HOST1X_GEM_H
12dee8268fSThierry Reding #define __HOST1X_GEM_H
13dee8268fSThierry Reding 
14dee8268fSThierry Reding #include <linux/host1x.h>
15dee8268fSThierry Reding 
16dee8268fSThierry Reding #include <drm/drm.h>
17dee8268fSThierry Reding #include <drm/drmP.h>
18*d9fc9413SDaniel Vetter #include <drm/drm_gem.h>
19dee8268fSThierry Reding 
20c134f019SThierry Reding #define TEGRA_BO_BOTTOM_UP (1 << 0)
21c134f019SThierry Reding 
22c134f019SThierry Reding enum tegra_bo_tiling_mode {
23c134f019SThierry Reding 	TEGRA_BO_TILING_MODE_PITCH,
24c134f019SThierry Reding 	TEGRA_BO_TILING_MODE_TILED,
25c134f019SThierry Reding 	TEGRA_BO_TILING_MODE_BLOCK,
26c134f019SThierry Reding };
27c134f019SThierry Reding 
28c134f019SThierry Reding struct tegra_bo_tiling {
29c134f019SThierry Reding 	enum tegra_bo_tiling_mode mode;
30c134f019SThierry Reding 	unsigned long value;
31c134f019SThierry Reding };
32773af77fSThierry Reding 
33dee8268fSThierry Reding struct tegra_bo {
34dee8268fSThierry Reding 	struct drm_gem_object gem;
35dee8268fSThierry Reding 	struct host1x_bo base;
36773af77fSThierry Reding 	unsigned long flags;
373800391dSThierry Reding 	struct sg_table *sgt;
38dee8268fSThierry Reding 	dma_addr_t paddr;
39dee8268fSThierry Reding 	void *vaddr;
40c134f019SThierry Reding 
41c134f019SThierry Reding 	struct tegra_bo_tiling tiling;
42dee8268fSThierry Reding };
43dee8268fSThierry Reding 
44dee8268fSThierry Reding static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
45dee8268fSThierry Reding {
46dee8268fSThierry Reding 	return container_of(gem, struct tegra_bo, gem);
47dee8268fSThierry Reding }
48dee8268fSThierry Reding 
49773af77fSThierry Reding struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size,
50773af77fSThierry Reding 				 unsigned long flags);
51dee8268fSThierry Reding struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
52dee8268fSThierry Reding 					     struct drm_device *drm,
53dee8268fSThierry Reding 					     unsigned int size,
54773af77fSThierry Reding 					     unsigned long flags,
55dee8268fSThierry Reding 					     unsigned int *handle);
56dee8268fSThierry Reding void tegra_bo_free_object(struct drm_gem_object *gem);
57dee8268fSThierry Reding int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
58dee8268fSThierry Reding 			 struct drm_mode_create_dumb *args);
59dee8268fSThierry Reding int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm,
60dee8268fSThierry Reding 			     uint32_t handle, uint64_t *offset);
61dee8268fSThierry Reding 
62dee8268fSThierry Reding int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
63dee8268fSThierry Reding 
64dee8268fSThierry Reding extern const struct vm_operations_struct tegra_bo_vm_ops;
65dee8268fSThierry Reding 
663800391dSThierry Reding struct dma_buf *tegra_gem_prime_export(struct drm_device *drm,
673800391dSThierry Reding 				       struct drm_gem_object *gem,
683800391dSThierry Reding 				       int flags);
693800391dSThierry Reding struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
703800391dSThierry Reding 					      struct dma_buf *buf);
713800391dSThierry Reding 
72dee8268fSThierry Reding #endif
73