1*96f60e37SRussell King /* 2*96f60e37SRussell King * Copyright (C) 2012 Russell King 3*96f60e37SRussell King * 4*96f60e37SRussell King * This program is free software; you can redistribute it and/or modify 5*96f60e37SRussell King * it under the terms of the GNU General Public License version 2 as 6*96f60e37SRussell King * published by the Free Software Foundation. 7*96f60e37SRussell King */ 8*96f60e37SRussell King #ifndef ARMADA_GEM_H 9*96f60e37SRussell King #define ARMADA_GEM_H 10*96f60e37SRussell King 11*96f60e37SRussell King /* GEM */ 12*96f60e37SRussell King struct armada_gem_object { 13*96f60e37SRussell King struct drm_gem_object obj; 14*96f60e37SRussell King void *addr; 15*96f60e37SRussell King phys_addr_t phys_addr; 16*96f60e37SRussell King resource_size_t dev_addr; 17*96f60e37SRussell King struct drm_mm_node *linear; /* for linear backed */ 18*96f60e37SRussell King struct page *page; /* for page backed */ 19*96f60e37SRussell King struct sg_table *sgt; /* for imported */ 20*96f60e37SRussell King void (*update)(void *); 21*96f60e37SRussell King void *update_data; 22*96f60e37SRussell King }; 23*96f60e37SRussell King 24*96f60e37SRussell King extern const struct vm_operations_struct armada_gem_vm_ops; 25*96f60e37SRussell King 26*96f60e37SRussell King #define drm_to_armada_gem(o) container_of(o, struct armada_gem_object, obj) 27*96f60e37SRussell King 28*96f60e37SRussell King void armada_gem_free_object(struct drm_gem_object *); 29*96f60e37SRussell King int armada_gem_linear_back(struct drm_device *, struct armada_gem_object *); 30*96f60e37SRussell King void *armada_gem_map_object(struct drm_device *, struct armada_gem_object *); 31*96f60e37SRussell King struct armada_gem_object *armada_gem_alloc_private_object(struct drm_device *, 32*96f60e37SRussell King size_t); 33*96f60e37SRussell King int armada_gem_dumb_create(struct drm_file *, struct drm_device *, 34*96f60e37SRussell King struct drm_mode_create_dumb *); 35*96f60e37SRussell King int armada_gem_dumb_map_offset(struct drm_file *, struct drm_device *, 36*96f60e37SRussell King uint32_t, uint64_t *); 37*96f60e37SRussell King int armada_gem_dumb_destroy(struct drm_file *, struct drm_device *, 38*96f60e37SRussell King uint32_t); 39*96f60e37SRussell King struct dma_buf *armada_gem_prime_export(struct drm_device *dev, 40*96f60e37SRussell King struct drm_gem_object *obj, int flags); 41*96f60e37SRussell King struct drm_gem_object *armada_gem_prime_import(struct drm_device *, 42*96f60e37SRussell King struct dma_buf *); 43*96f60e37SRussell King int armada_gem_map_import(struct armada_gem_object *); 44*96f60e37SRussell King 45*96f60e37SRussell King static inline struct armada_gem_object *armada_gem_object_lookup( 46*96f60e37SRussell King struct drm_device *dev, struct drm_file *dfile, unsigned handle) 47*96f60e37SRussell King { 48*96f60e37SRussell King struct drm_gem_object *obj = drm_gem_object_lookup(dev, dfile, handle); 49*96f60e37SRussell King 50*96f60e37SRussell King return obj ? drm_to_armada_gem(obj) : NULL; 51*96f60e37SRussell King } 52*96f60e37SRussell King #endif 53