armada_gem.h 1.8 KB

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