1 /* 2 * Copyright (C) 2012 Russell King 3 * 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. 7 */ 8 #ifndef ARMADA_GEM_H 9 #define ARMADA_GEM_H 10 11 #include <drm/drm_gem.h> 12 13 /* GEM */ 14 struct armada_gem_object { 15 struct drm_gem_object obj; 16 void *addr; 17 phys_addr_t phys_addr; 18 resource_size_t dev_addr; 19 bool mapped; 20 struct drm_mm_node *linear; /* for linear backed */ 21 struct page *page; /* for page backed */ 22 struct sg_table *sgt; /* for imported */ 23 void (*update)(void *); 24 void *update_data; 25 }; 26 27 extern const struct vm_operations_struct armada_gem_vm_ops; 28 29 #define drm_to_armada_gem(o) container_of(o, struct armada_gem_object, obj) 30 31 void armada_gem_free_object(struct drm_gem_object *); 32 int armada_gem_linear_back(struct drm_device *, struct armada_gem_object *); 33 void *armada_gem_map_object(struct drm_device *, struct armada_gem_object *); 34 struct armada_gem_object *armada_gem_alloc_private_object(struct drm_device *, 35 size_t); 36 int armada_gem_dumb_create(struct drm_file *, struct drm_device *, 37 struct drm_mode_create_dumb *); 38 int armada_gem_dumb_map_offset(struct drm_file *, struct drm_device *, 39 uint32_t, uint64_t *); 40 int armada_gem_dumb_destroy(struct drm_file *, struct drm_device *, 41 uint32_t); 42 struct dma_buf *armada_gem_prime_export(struct drm_device *dev, 43 struct drm_gem_object *obj, int flags); 44 struct drm_gem_object *armada_gem_prime_import(struct drm_device *, 45 struct dma_buf *); 46 int armada_gem_map_import(struct armada_gem_object *); 47 48 static inline struct armada_gem_object *armada_gem_object_lookup( 49 struct drm_file *dfile, unsigned handle) 50 { 51 struct drm_gem_object *obj = drm_gem_object_lookup(dfile, handle); 52 53 return obj ? drm_to_armada_gem(obj) : NULL; 54 } 55 #endif 56