2 * Copyright (c) 2015 MediaTek Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef _MTK_DRM_GEM_H_
15 #define _MTK_DRM_GEM_H_
17 #include <drm/drm_gem.h>
20 * mtk drm buffer structure.
22 * @base: a gem object.
23 * - a new handle to this gem object would be created
24 * by drm_gem_handle_create().
25 * @cookie: the return value of dma_alloc_attrs(), keep it for dma_free_attrs()
26 * @kvaddr: kernel virtual address of gem buffer.
27 * @dma_addr: dma address of gem buffer.
28 * @dma_attrs: dma attributes of gem buffer.
30 * P.S. this object would be transferred to user as kms_bo.handle so
31 * user can access the buffer through kms_bo.handle.
33 struct mtk_drm_gem_obj
{
34 struct drm_gem_object base
;
38 unsigned long dma_attrs
;
42 #define to_mtk_gem_obj(x) container_of(x, struct mtk_drm_gem_obj, base)
44 void mtk_drm_gem_free_object(struct drm_gem_object
*gem
);
45 struct mtk_drm_gem_obj
*mtk_drm_gem_create(struct drm_device
*dev
, size_t size
,
47 int mtk_drm_gem_dumb_create(struct drm_file
*file_priv
, struct drm_device
*dev
,
48 struct drm_mode_create_dumb
*args
);
49 int mtk_drm_gem_dumb_map_offset(struct drm_file
*file_priv
,
50 struct drm_device
*dev
, uint32_t handle
,
52 int mtk_drm_gem_mmap(struct file
*filp
, struct vm_area_struct
*vma
);
53 int mtk_drm_gem_mmap_buf(struct drm_gem_object
*obj
,
54 struct vm_area_struct
*vma
);
55 struct sg_table
*mtk_gem_prime_get_sg_table(struct drm_gem_object
*obj
);
56 struct drm_gem_object
*mtk_gem_prime_import_sg_table(struct drm_device
*dev
,
57 struct dma_buf_attachment
*attach
, struct sg_table
*sg
);