1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
296f60e37SRussell King /*
396f60e37SRussell King * Copyright (C) 2012 Russell King
496f60e37SRussell King */
596f60e37SRussell King #ifndef ARMADA_GEM_H
696f60e37SRussell King #define ARMADA_GEM_H
796f60e37SRussell King
8d9fc9413SDaniel Vetter #include <drm/drm_gem.h>
9d9fc9413SDaniel Vetter
1096f60e37SRussell King /* GEM */
1196f60e37SRussell King struct armada_gem_object {
1296f60e37SRussell King struct drm_gem_object obj;
1396f60e37SRussell King void *addr;
1496f60e37SRussell King phys_addr_t phys_addr;
1596f60e37SRussell King resource_size_t dev_addr;
16b4005857SChristoph Hellwig bool mapped;
1796f60e37SRussell King struct drm_mm_node *linear; /* for linear backed */
1896f60e37SRussell King struct page *page; /* for page backed */
1996f60e37SRussell King struct sg_table *sgt; /* for imported */
2096f60e37SRussell King void (*update)(void *);
2196f60e37SRussell King void *update_data;
2296f60e37SRussell King };
2396f60e37SRussell King
2496f60e37SRussell King #define drm_to_armada_gem(o) container_of(o, struct armada_gem_object, obj)
2596f60e37SRussell King
2696f60e37SRussell King void armada_gem_free_object(struct drm_gem_object *);
2796f60e37SRussell King int armada_gem_linear_back(struct drm_device *, struct armada_gem_object *);
2896f60e37SRussell King void *armada_gem_map_object(struct drm_device *, struct armada_gem_object *);
2996f60e37SRussell King struct armada_gem_object *armada_gem_alloc_private_object(struct drm_device *,
3096f60e37SRussell King size_t);
3196f60e37SRussell King int armada_gem_dumb_create(struct drm_file *, struct drm_device *,
3296f60e37SRussell King struct drm_mode_create_dumb *);
33*e4fa8457SDaniel Vetter struct dma_buf *armada_gem_prime_export(struct drm_gem_object *obj, int flags);
3496f60e37SRussell King struct drm_gem_object *armada_gem_prime_import(struct drm_device *,
3596f60e37SRussell King struct dma_buf *);
3696f60e37SRussell King int armada_gem_map_import(struct armada_gem_object *);
3796f60e37SRussell King
armada_gem_object_lookup(struct drm_file * dfile,unsigned handle)3896f60e37SRussell King static inline struct armada_gem_object *armada_gem_object_lookup(
39a8ad0bd8SChris Wilson struct drm_file *dfile, unsigned handle)
4096f60e37SRussell King {
41a8ad0bd8SChris Wilson struct drm_gem_object *obj = drm_gem_object_lookup(dfile, handle);
4296f60e37SRussell King
4396f60e37SRussell King return obj ? drm_to_armada_gem(obj) : NULL;
4496f60e37SRussell King }
4596f60e37SRussell King #endif
46