Linux Audio

Check our new training course

Loading...
v6.13.7
  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
 24enum tegra_bo_sector_layout {
 25	TEGRA_BO_SECTOR_LAYOUT_TEGRA,
 26	TEGRA_BO_SECTOR_LAYOUT_GPU,
 27};
 28
 29struct tegra_bo_tiling {
 30	enum tegra_bo_tiling_mode mode;
 31	unsigned long value;
 32	enum tegra_bo_sector_layout sector_layout;
 33};
 34
 35/*
 36 * How memory is referenced within a tegra_bo:
 37 *
 38 * Buffer source  | Mapping API(*)  | Fields
 39 * ---------------+-----------------+---------------
 40 * Allocated here | DMA API         | iova (IOVA mapped to drm->dev), vaddr (CPU VA)
 41 *
 42 * Allocated here | IOMMU API       | pages/num_pages (Phys. memory), sgt (Mapped to drm->dev),
 43 *                                  | iova/size (Mapped to domain)
 44 *
 45 * Imported       | DMA API         | dma_buf (Imported dma_buf)
 46 *
 47 * Imported       | IOMMU API       | dma_buf (Imported dma_buf),
 48 *                                  | gem->import_attach (Attachment on drm->dev),
 49 *                                  | sgt (Mapped to drm->dev)
 50 *                                  | iova/size (Mapped to domain)
 51 *
 52 * (*) If tegra->domain is set, i.e. TegraDRM IOMMU domain is directly managed through IOMMU API,
 53 *     this is IOMMU API. Otherwise DMA API.
 54 */
 55struct tegra_bo {
 56	struct drm_gem_object gem;
 57	struct host1x_bo base;
 58	unsigned long flags;
 59	struct sg_table *sgt;
 60	dma_addr_t iova;
 61	void *vaddr;
 62	struct dma_buf *dma_buf;
 63
 64	struct drm_mm_node *mm;
 65	unsigned long num_pages;
 66	struct page **pages;
 67	/* size of IOMMU mapping */
 68	size_t size;
 69
 70	struct tegra_bo_tiling tiling;
 71};
 72
 73static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
 74{
 75	return container_of(gem, struct tegra_bo, gem);
 76}
 77
 78static inline struct tegra_bo *host1x_to_tegra_bo(struct host1x_bo *bo)
 79{
 80	return container_of(bo, struct tegra_bo, base);
 81}
 82
 83struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size,
 84				 unsigned long flags);
 85struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
 86					     struct drm_device *drm,
 87					     size_t size,
 88					     unsigned long flags,
 89					     u32 *handle);
 90void tegra_bo_free_object(struct drm_gem_object *gem);
 91int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
 92			 struct drm_mode_create_dumb *args);
 93
 94extern const struct vm_operations_struct tegra_bo_vm_ops;
 95
 96int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma);
 97int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
 98
 99struct dma_buf *tegra_gem_prime_export(struct drm_gem_object *gem,
100				       int flags);
101struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
102					      struct dma_buf *buf);
103
104struct host1x_bo *tegra_gem_lookup(struct drm_file *file, u32 handle);
105
106#endif
v6.8
 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
24enum tegra_bo_sector_layout {
25	TEGRA_BO_SECTOR_LAYOUT_TEGRA,
26	TEGRA_BO_SECTOR_LAYOUT_GPU,
27};
28
29struct tegra_bo_tiling {
30	enum tegra_bo_tiling_mode mode;
31	unsigned long value;
32	enum tegra_bo_sector_layout sector_layout;
33};
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35struct tegra_bo {
36	struct drm_gem_object gem;
37	struct host1x_bo base;
38	unsigned long flags;
39	struct sg_table *sgt;
40	dma_addr_t iova;
41	void *vaddr;
 
42
43	struct drm_mm_node *mm;
44	unsigned long num_pages;
45	struct page **pages;
46	/* size of IOMMU mapping */
47	size_t size;
48
49	struct tegra_bo_tiling tiling;
50};
51
52static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
53{
54	return container_of(gem, struct tegra_bo, gem);
55}
56
57static inline struct tegra_bo *host1x_to_tegra_bo(struct host1x_bo *bo)
58{
59	return container_of(bo, struct tegra_bo, base);
60}
61
62struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size,
63				 unsigned long flags);
64struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
65					     struct drm_device *drm,
66					     size_t size,
67					     unsigned long flags,
68					     u32 *handle);
69void tegra_bo_free_object(struct drm_gem_object *gem);
70int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
71			 struct drm_mode_create_dumb *args);
72
73extern const struct vm_operations_struct tegra_bo_vm_ops;
74
75int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma);
76int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
77
78struct dma_buf *tegra_gem_prime_export(struct drm_gem_object *gem,
79				       int flags);
80struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
81					      struct dma_buf *buf);
82
83struct host1x_bo *tegra_gem_lookup(struct drm_file *file, u32 handle);
84
85#endif