exynos_drm_gem.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* exynos_drm_gem.h
  2. *
  3. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  4. * Authoer: Inki Dae <inki.dae@samsung.com>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the "Software"),
  8. * to deal in the Software without restriction, including without limitation
  9. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. * and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the next
  14. * paragraph) shall be included in all copies or substantial portions of the
  15. * Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23. * OTHER DEALINGS IN THE SOFTWARE.
  24. */
  25. #ifndef _EXYNOS_DRM_GEM_H_
  26. #define _EXYNOS_DRM_GEM_H_
  27. #define to_exynos_gem_obj(x) container_of(x,\
  28. struct exynos_drm_gem_obj, base)
  29. /*
  30. * exynos drm gem buffer structure.
  31. *
  32. * @kvaddr: kernel virtual address to allocated memory region.
  33. * @dma_addr: bus address(accessed by dma) to allocated memory region.
  34. * - this address could be physical address without IOMMU and
  35. * device address with IOMMU.
  36. * @size: size of allocated memory region.
  37. */
  38. struct exynos_drm_gem_buf {
  39. void __iomem *kvaddr;
  40. dma_addr_t dma_addr;
  41. unsigned long size;
  42. };
  43. /*
  44. * exynos drm buffer structure.
  45. *
  46. * @base: a gem object.
  47. * - a new handle to this gem object would be created
  48. * by drm_gem_handle_create().
  49. * @buffer: a pointer to exynos_drm_gem_buffer object.
  50. * - contain the information to memory region allocated
  51. * by user request or at framebuffer creation.
  52. * continuous memory region allocated by user request
  53. * or at framebuffer creation.
  54. *
  55. * P.S. this object would be transfered to user as kms_bo.handle so
  56. * user can access the buffer through kms_bo.handle.
  57. */
  58. struct exynos_drm_gem_obj {
  59. struct drm_gem_object base;
  60. struct exynos_drm_gem_buf *buffer;
  61. };
  62. /* destroy a buffer with gem object */
  63. void exynos_drm_gem_destroy(struct exynos_drm_gem_obj *exynos_gem_obj);
  64. /* create a new buffer with gem object */
  65. struct exynos_drm_gem_obj *exynos_drm_gem_create(struct drm_device *dev,
  66. unsigned long size);
  67. /*
  68. * request gem object creation and buffer allocation as the size
  69. * that it is calculated with framebuffer information such as width,
  70. * height and bpp.
  71. */
  72. int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
  73. struct drm_file *file_priv);
  74. /* get buffer offset to map to user space. */
  75. int exynos_drm_gem_map_offset_ioctl(struct drm_device *dev, void *data,
  76. struct drm_file *file_priv);
  77. /*
  78. * mmap the physically continuous memory that a gem object contains
  79. * to user space.
  80. */
  81. int exynos_drm_gem_mmap_ioctl(struct drm_device *dev, void *data,
  82. struct drm_file *file_priv);
  83. /* initialize gem object. */
  84. int exynos_drm_gem_init_object(struct drm_gem_object *obj);
  85. /* free gem object. */
  86. void exynos_drm_gem_free_object(struct drm_gem_object *gem_obj);
  87. /* create memory region for drm framebuffer. */
  88. int exynos_drm_gem_dumb_create(struct drm_file *file_priv,
  89. struct drm_device *dev,
  90. struct drm_mode_create_dumb *args);
  91. /* map memory region for drm framebuffer to user space. */
  92. int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv,
  93. struct drm_device *dev, uint32_t handle,
  94. uint64_t *offset);
  95. /*
  96. * destroy memory region allocated.
  97. * - a gem handle and physical memory region pointed by a gem object
  98. * would be released by drm_gem_handle_delete().
  99. */
  100. int exynos_drm_gem_dumb_destroy(struct drm_file *file_priv,
  101. struct drm_device *dev,
  102. unsigned int handle);
  103. /* page fault handler and mmap fault address(virtual) to physical memory. */
  104. int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
  105. /* set vm_flags and we can change the vm attribute to other one at here. */
  106. int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
  107. #endif