mtk_drm_gem.h (1588B)
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (c) 2015 MediaTek Inc. 4 */ 5 6#ifndef _MTK_DRM_GEM_H_ 7#define _MTK_DRM_GEM_H_ 8 9#include <drm/drm_gem.h> 10 11/* 12 * mtk drm buffer structure. 13 * 14 * @base: a gem object. 15 * - a new handle to this gem object would be created 16 * by drm_gem_handle_create(). 17 * @cookie: the return value of dma_alloc_attrs(), keep it for dma_free_attrs() 18 * @kvaddr: kernel virtual address of gem buffer. 19 * @dma_addr: dma address of gem buffer. 20 * @dma_attrs: dma attributes of gem buffer. 21 * 22 * P.S. this object would be transferred to user as kms_bo.handle so 23 * user can access the buffer through kms_bo.handle. 24 */ 25struct mtk_drm_gem_obj { 26 struct drm_gem_object base; 27 void *cookie; 28 void *kvaddr; 29 dma_addr_t dma_addr; 30 unsigned long dma_attrs; 31 struct sg_table *sg; 32 struct page **pages; 33}; 34 35#define to_mtk_gem_obj(x) container_of(x, struct mtk_drm_gem_obj, base) 36 37void mtk_drm_gem_free_object(struct drm_gem_object *gem); 38struct mtk_drm_gem_obj *mtk_drm_gem_create(struct drm_device *dev, size_t size, 39 bool alloc_kmap); 40int mtk_drm_gem_dumb_create(struct drm_file *file_priv, struct drm_device *dev, 41 struct drm_mode_create_dumb *args); 42struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj); 43struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, 44 struct dma_buf_attachment *attach, struct sg_table *sg); 45int mtk_drm_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map); 46void mtk_drm_gem_prime_vunmap(struct drm_gem_object *obj, 47 struct iosys_map *map); 48 49#endif