blob: 35fa690b3d9063a04da720f691ad2a4fa79cb13c [file] [log] [blame]
Laurent Pinchartb5561412017-10-13 17:59:05 +03001/*
2 * omap_gem.h -- OMAP DRM GEM Object Management
3 *
4 * Copyright (C) 2011 Texas Instruments
5 * Author: Rob Clark <rob@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef __OMAPDRM_GEM_H__
21#define __OMAPDRM_GEM_H__
22
23#include <linux/types.h>
24
25enum dma_data_direction;
26
27struct dma_buf;
28struct drm_device;
29struct drm_file;
30struct drm_gem_object;
31struct drm_mode_create_dumb;
32struct file;
33struct list_head;
34struct page;
35struct seq_file;
36struct vm_area_struct;
37struct vm_fault;
38
39union omap_gem_size;
40
41/* Initialization and Cleanup */
42void omap_gem_init(struct drm_device *dev);
43void omap_gem_deinit(struct drm_device *dev);
44
45#ifdef CONFIG_PM
46int omap_gem_resume(struct drm_device *dev);
47#endif
48
49#ifdef CONFIG_DEBUG_FS
50void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
51void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
52#endif
53
54/* GEM Object Creation and Deletion */
55struct drm_gem_object *omap_gem_new(struct drm_device *dev,
56 union omap_gem_size gsize, uint32_t flags);
57struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
58 struct sg_table *sgt);
59int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
60 union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
61void omap_gem_free_object(struct drm_gem_object *obj);
62void *omap_gem_vaddr(struct drm_gem_object *obj);
63
64/* Dumb Buffers Interface */
65int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
66 uint32_t handle, uint64_t *offset);
67int omap_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
68 struct drm_mode_create_dumb *args);
69
70/* mmap() Interface */
71int omap_gem_mmap(struct file *filp, struct vm_area_struct *vma);
72int omap_gem_mmap_obj(struct drm_gem_object *obj,
73 struct vm_area_struct *vma);
74uint64_t omap_gem_mmap_offset(struct drm_gem_object *obj);
75size_t omap_gem_mmap_size(struct drm_gem_object *obj);
76
77/* PRIME Interface */
78struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
79 struct drm_gem_object *obj, int flags);
80struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
81 struct dma_buf *buffer);
82
83int omap_gem_fault(struct vm_fault *vmf);
84int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll);
85void omap_gem_cpu_sync_page(struct drm_gem_object *obj, int pgoff);
86void omap_gem_dma_sync_buffer(struct drm_gem_object *obj,
87 enum dma_data_direction dir);
88int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr);
89void omap_gem_unpin(struct drm_gem_object *obj);
90int omap_gem_get_pages(struct drm_gem_object *obj, struct page ***pages,
91 bool remap);
92int omap_gem_put_pages(struct drm_gem_object *obj);
93
94uint32_t omap_gem_flags(struct drm_gem_object *obj);
95int omap_gem_rotated_dma_addr(struct drm_gem_object *obj, uint32_t orient,
96 int x, int y, dma_addr_t *dma_addr);
97int omap_gem_tiled_stride(struct drm_gem_object *obj, uint32_t orient);
98
99#endif /* __OMAPDRM_GEM_H__ */