gbmint.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright © 2011 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  19. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  20. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. * DEALINGS IN THE SOFTWARE.
  23. *
  24. * Authors:
  25. * Benjamin Franzke <benjaminfranzke@googlemail.com>
  26. */
  27. #ifndef INTERNAL_H_
  28. #define INTERNAL_H_
  29. #include "gbm.h"
  30. #include <sys/stat.h>
  31. /* GCC visibility */
  32. #if defined(__GNUC__)
  33. #define GBM_EXPORT __attribute__ ((visibility("default")))
  34. #else
  35. #define GBM_EXPORT
  36. #endif
  37. /**
  38. * \file gbmint.h
  39. * \brief Internal implementation details of gbm
  40. */
  41. /**
  42. * The device used for the memory allocation.
  43. *
  44. * The members of this structure should be not accessed directly
  45. */
  46. struct gbm_device {
  47. /* Hack to make a gbm_device detectable by its first element. */
  48. struct gbm_device *(*dummy)(int);
  49. int fd;
  50. const char *name;
  51. unsigned int refcount;
  52. struct stat stat;
  53. void (*destroy)(struct gbm_device *gbm);
  54. int (*is_format_supported)(struct gbm_device *gbm,
  55. uint32_t format,
  56. uint32_t usage);
  57. struct gbm_bo *(*bo_create)(struct gbm_device *gbm,
  58. uint32_t width, uint32_t height,
  59. uint32_t format,
  60. uint32_t usage);
  61. struct gbm_bo *(*bo_import)(struct gbm_device *gbm, uint32_t type,
  62. void *buffer, uint32_t usage);
  63. int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);
  64. int (*bo_get_fd)(struct gbm_bo *bo);
  65. void (*bo_destroy)(struct gbm_bo *bo);
  66. struct gbm_surface *(*surface_create)(struct gbm_device *gbm,
  67. uint32_t width, uint32_t height,
  68. uint32_t format, uint32_t flags);
  69. struct gbm_bo *(*surface_lock_front_buffer)(struct gbm_surface *surface);
  70. void (*surface_release_buffer)(struct gbm_surface *surface,
  71. struct gbm_bo *bo);
  72. int (*surface_has_free_buffers)(struct gbm_surface *surface);
  73. void (*surface_destroy)(struct gbm_surface *surface);
  74. };
  75. /**
  76. * The allocated buffer object.
  77. *
  78. * The members in this structure should not be accessed directly.
  79. */
  80. struct gbm_bo {
  81. struct gbm_device *gbm;
  82. uint32_t width;
  83. uint32_t height;
  84. uint32_t stride;
  85. uint32_t format;
  86. union gbm_bo_handle handle;
  87. void *user_data;
  88. void (*destroy_user_data)(struct gbm_bo *, void *);
  89. };
  90. struct gbm_surface {
  91. struct gbm_device *gbm;
  92. uint32_t width;
  93. uint32_t height;
  94. uint32_t format;
  95. uint32_t flags;
  96. };
  97. struct gbm_backend {
  98. const char *backend_name;
  99. struct gbm_device *(*create_device)(int fd);
  100. };
  101. struct gbm_device *
  102. _gbm_mesa_get_device(int fd);
  103. #endif