xref: /linux/drivers/gpu/drm/armada/armada_gem.h (revision d9fc9413f97f5c615256a5657ec667c064c07a70)
196f60e37SRussell King /*
296f60e37SRussell King  * Copyright (C) 2012 Russell King
396f60e37SRussell King  *
496f60e37SRussell King  * This program is free software; you can redistribute it and/or modify
596f60e37SRussell King  * it under the terms of the GNU General Public License version 2 as
696f60e37SRussell King  * published by the Free Software Foundation.
796f60e37SRussell King  */
896f60e37SRussell King #ifndef ARMADA_GEM_H
996f60e37SRussell King #define ARMADA_GEM_H
1096f60e37SRussell King 
11*d9fc9413SDaniel Vetter #include <drm/drm_gem.h>
12*d9fc9413SDaniel Vetter 
1396f60e37SRussell King /* GEM */
1496f60e37SRussell King struct armada_gem_object {
1596f60e37SRussell King 	struct drm_gem_object	obj;
1696f60e37SRussell King 	void			*addr;
1796f60e37SRussell King 	phys_addr_t		phys_addr;
1896f60e37SRussell King 	resource_size_t		dev_addr;
1996f60e37SRussell King 	struct drm_mm_node	*linear;	/* for linear backed */
2096f60e37SRussell King 	struct page		*page;		/* for page backed */
2196f60e37SRussell King 	struct sg_table		*sgt;		/* for imported */
2296f60e37SRussell King 	void			(*update)(void *);
2396f60e37SRussell King 	void			*update_data;
2496f60e37SRussell King };
2596f60e37SRussell King 
2696f60e37SRussell King extern const struct vm_operations_struct armada_gem_vm_ops;
2796f60e37SRussell King 
2896f60e37SRussell King #define drm_to_armada_gem(o) container_of(o, struct armada_gem_object, obj)
2996f60e37SRussell King 
3096f60e37SRussell King void armada_gem_free_object(struct drm_gem_object *);
3196f60e37SRussell King int armada_gem_linear_back(struct drm_device *, struct armada_gem_object *);
3296f60e37SRussell King void *armada_gem_map_object(struct drm_device *, struct armada_gem_object *);
3396f60e37SRussell King struct armada_gem_object *armada_gem_alloc_private_object(struct drm_device *,
3496f60e37SRussell King 	size_t);
3596f60e37SRussell King int armada_gem_dumb_create(struct drm_file *, struct drm_device *,
3696f60e37SRussell King 	struct drm_mode_create_dumb *);
3796f60e37SRussell King int armada_gem_dumb_map_offset(struct drm_file *, struct drm_device *,
3896f60e37SRussell King 	uint32_t, uint64_t *);
3996f60e37SRussell King int armada_gem_dumb_destroy(struct drm_file *, struct drm_device *,
4096f60e37SRussell King 	uint32_t);
4196f60e37SRussell King struct dma_buf *armada_gem_prime_export(struct drm_device *dev,
4296f60e37SRussell King 	struct drm_gem_object *obj, int flags);
4396f60e37SRussell King struct drm_gem_object *armada_gem_prime_import(struct drm_device *,
4496f60e37SRussell King 	struct dma_buf *);
4596f60e37SRussell King int armada_gem_map_import(struct armada_gem_object *);
4696f60e37SRussell King 
4796f60e37SRussell King static inline struct armada_gem_object *armada_gem_object_lookup(
4896f60e37SRussell King 	struct drm_device *dev, struct drm_file *dfile, unsigned handle)
4996f60e37SRussell King {
5096f60e37SRussell King 	struct drm_gem_object *obj = drm_gem_object_lookup(dev, dfile, handle);
5196f60e37SRussell King 
5296f60e37SRussell King 	return obj ? drm_to_armada_gem(obj) : NULL;
5396f60e37SRussell King }
5496f60e37SRussell King #endif
55