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> |
| 18 | |
Thierry Reding | db7fbdf | 2013-10-07 09:47:58 +0200 | [diff] [blame] | 19 | #define TEGRA_BO_TILED (1 << 0) |
| 20 | #define TEGRA_BO_BOTTOM_UP (1 << 1) |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 21 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 22 | struct tegra_bo { |
| 23 | struct drm_gem_object gem; |
| 24 | struct host1x_bo base; |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 25 | unsigned long flags; |
Thierry Reding | 3800391 | 2013-12-12 10:00:43 +0100 | [diff] [blame] | 26 | struct sg_table *sgt; |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 27 | dma_addr_t paddr; |
| 28 | void *vaddr; |
| 29 | }; |
| 30 | |
| 31 | static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem) |
| 32 | { |
| 33 | return container_of(gem, struct tegra_bo, gem); |
| 34 | } |
| 35 | |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 36 | struct tegra_bo *tegra_bo_create(struct drm_device *drm, unsigned int size, |
| 37 | unsigned long flags); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 38 | struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file, |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 39 | struct drm_device *drm, |
| 40 | unsigned int size, |
| 41 | unsigned long flags, |
| 42 | unsigned int *handle); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 43 | void tegra_bo_free_object(struct drm_gem_object *gem); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 44 | int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm, |
| 45 | struct drm_mode_create_dumb *args); |
| 46 | int tegra_bo_dumb_map_offset(struct drm_file *file, struct drm_device *drm, |
| 47 | uint32_t handle, uint64_t *offset); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 48 | |
| 49 | int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma); |
| 50 | |
| 51 | extern const struct vm_operations_struct tegra_bo_vm_ops; |
| 52 | |
Thierry Reding | 3800391 | 2013-12-12 10:00:43 +0100 | [diff] [blame] | 53 | struct dma_buf *tegra_gem_prime_export(struct drm_device *drm, |
| 54 | struct drm_gem_object *gem, |
| 55 | int flags); |
| 56 | struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm, |
| 57 | struct dma_buf *buf); |
| 58 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 59 | #endif |