Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Tegra host1x GEM implementation |
| 3 | * |
| 4 | * Copyright (c) 2012-2013, NVIDIA Corporation. |
| 5 | * |
Thierry Reding | 9a2ac2d | 2014-02-11 15:52:01 +0100 | [diff] [blame] | 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. |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef __HOST1X_GEM_H |
| 12 | #define __HOST1X_GEM_H |
| 13 | |
Thierry Reding | 35d747a | 2013-09-24 16:30:32 +0200 | [diff] [blame] | 14 | #include <linux/host1x.h> |
| 15 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 16 | #include <drm/drm.h> |
| 17 | #include <drm/drmP.h> |
Daniel Vetter | d9fc941 | 2014-09-23 15:46:53 +0200 | [diff] [blame] | 18 | #include <drm/drm_gem.h> |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 19 | |
Thierry Reding | c134f01 | 2014-06-03 14:48:12 +0200 | [diff] [blame] | 20 | #define TEGRA_BO_BOTTOM_UP (1 << 0) |
| 21 | |
| 22 | enum tegra_bo_tiling_mode { |
| 23 | TEGRA_BO_TILING_MODE_PITCH, |
| 24 | TEGRA_BO_TILING_MODE_TILED, |
| 25 | TEGRA_BO_TILING_MODE_BLOCK, |
| 26 | }; |
| 27 | |
| 28 | struct tegra_bo_tiling { |
| 29 | enum tegra_bo_tiling_mode mode; |
| 30 | unsigned long value; |
| 31 | }; |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 32 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 33 | struct tegra_bo { |
| 34 | struct drm_gem_object gem; |
| 35 | struct host1x_bo base; |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 36 | unsigned long flags; |
Thierry Reding | 3800391 | 2013-12-12 10:00:43 +0100 | [diff] [blame] | 37 | struct sg_table *sgt; |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 38 | dma_addr_t paddr; |
| 39 | void *vaddr; |
Thierry Reding | c134f01 | 2014-06-03 14:48:12 +0200 | [diff] [blame] | 40 | |
Thierry Reding | df06b75 | 2014-06-26 21:41:53 +0200 | [diff] [blame] | 41 | struct drm_mm_node *mm; |
| 42 | unsigned long num_pages; |
| 43 | struct page **pages; |
| 44 | /* size of IOMMU mapping */ |
| 45 | size_t size; |
| 46 | |
Thierry Reding | c134f01 | 2014-06-03 14:48:12 +0200 | [diff] [blame] | 47 | struct tegra_bo_tiling tiling; |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem) |
| 51 | { |
| 52 | return container_of(gem, struct tegra_bo, gem); |
| 53 | } |
| 54 | |
Thierry Reding | 71c3862 | 2014-11-03 13:23:02 +0100 | [diff] [blame] | 55 | struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size, |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 56 | unsigned long flags); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 57 | struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file, |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 58 | struct drm_device *drm, |
Thierry Reding | 71c3862 | 2014-11-03 13:23:02 +0100 | [diff] [blame] | 59 | size_t size, |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 60 | unsigned long flags, |
Thierry Reding | 71c3862 | 2014-11-03 13:23:02 +0100 | [diff] [blame] | 61 | u32 *handle); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 62 | void tegra_bo_free_object(struct drm_gem_object *gem); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 63 | int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm, |
| 64 | struct drm_mode_create_dumb *args); |
| 65 | int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm, |
Thierry Reding | 71c3862 | 2014-11-03 13:23:02 +0100 | [diff] [blame] | 66 | u32 handle, u64 *offset); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 67 | |
| 68 | int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma); |
| 69 | |
| 70 | extern const struct vm_operations_struct tegra_bo_vm_ops; |
| 71 | |
Thierry Reding | 3800391 | 2013-12-12 10:00:43 +0100 | [diff] [blame] | 72 | struct dma_buf *tegra_gem_prime_export(struct drm_device *drm, |
| 73 | struct drm_gem_object *gem, |
| 74 | int flags); |
| 75 | struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm, |
| 76 | struct dma_buf *buf); |
| 77 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 78 | #endif |