Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Tegra host1x GEM implementation
0004  *
0005  * Copyright (c) 2012-2013, NVIDIA Corporation.
0006  */
0007 
0008 #ifndef __HOST1X_GEM_H
0009 #define __HOST1X_GEM_H
0010 
0011 #include <linux/host1x.h>
0012 
0013 #include <drm/drm.h>
0014 #include <drm/drm_gem.h>
0015 
0016 #define TEGRA_BO_BOTTOM_UP (1 << 0)
0017 
0018 enum tegra_bo_tiling_mode {
0019     TEGRA_BO_TILING_MODE_PITCH,
0020     TEGRA_BO_TILING_MODE_TILED,
0021     TEGRA_BO_TILING_MODE_BLOCK,
0022 };
0023 
0024 enum tegra_bo_sector_layout {
0025     TEGRA_BO_SECTOR_LAYOUT_TEGRA,
0026     TEGRA_BO_SECTOR_LAYOUT_GPU,
0027 };
0028 
0029 struct tegra_bo_tiling {
0030     enum tegra_bo_tiling_mode mode;
0031     unsigned long value;
0032     enum tegra_bo_sector_layout sector_layout;
0033 };
0034 
0035 struct tegra_bo {
0036     struct drm_gem_object gem;
0037     struct host1x_bo base;
0038     unsigned long flags;
0039     struct sg_table *sgt;
0040     dma_addr_t iova;
0041     void *vaddr;
0042 
0043     struct drm_mm_node *mm;
0044     unsigned long num_pages;
0045     struct page **pages;
0046     /* size of IOMMU mapping */
0047     size_t size;
0048 
0049     struct tegra_bo_tiling tiling;
0050 };
0051 
0052 static inline struct tegra_bo *to_tegra_bo(struct drm_gem_object *gem)
0053 {
0054     return container_of(gem, struct tegra_bo, gem);
0055 }
0056 
0057 static inline struct tegra_bo *host1x_to_tegra_bo(struct host1x_bo *bo)
0058 {
0059     return container_of(bo, struct tegra_bo, base);
0060 }
0061 
0062 struct tegra_bo *tegra_bo_create(struct drm_device *drm, size_t size,
0063                  unsigned long flags);
0064 struct tegra_bo *tegra_bo_create_with_handle(struct drm_file *file,
0065                          struct drm_device *drm,
0066                          size_t size,
0067                          unsigned long flags,
0068                          u32 *handle);
0069 void tegra_bo_free_object(struct drm_gem_object *gem);
0070 int tegra_bo_dumb_create(struct drm_file *file, struct drm_device *drm,
0071              struct drm_mode_create_dumb *args);
0072 
0073 extern const struct vm_operations_struct tegra_bo_vm_ops;
0074 
0075 int __tegra_gem_mmap(struct drm_gem_object *gem, struct vm_area_struct *vma);
0076 int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma);
0077 
0078 struct dma_buf *tegra_gem_prime_export(struct drm_gem_object *gem,
0079                        int flags);
0080 struct drm_gem_object *tegra_gem_prime_import(struct drm_device *drm,
0081                           struct dma_buf *buf);
0082 
0083 struct host1x_bo *tegra_gem_lookup(struct drm_file *file, u32 handle);
0084 
0085 #endif