Projektarbeit Line Following Robot bei Prof. Chowanetz im WS22/23
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mmalomx.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. Copyright (c) 2012, Broadcom Europe Ltd
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * Neither the name of the copyright holder nor the
  12. names of its contributors may be used to endorse or promote products
  13. derived from this software without specific prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. /** \file
  26. * OpenMAX IL adaptation layer for MMAL
  27. */
  28. #include "interface/vmcs_host/khronos/IL/OMX_Core.h"
  29. #include "interface/vmcs_host/khronos/IL/OMX_Component.h"
  30. #include "interface/vmcs_host/khronos/IL/OMX_Video.h"
  31. #include "interface/vmcs_host/khronos/IL/OMX_Audio.h"
  32. #include <mmal.h>
  33. #include <util/mmal_il.h>
  34. /* Define this to 1 if you want to log all buffer transfers */
  35. #define ENABLE_MMAL_EXTRA_LOGGING 0
  36. #ifndef MMALOMX_EXPORT
  37. # define MMALOMX_EXPORT(a) a
  38. #endif
  39. #ifndef MMALOMX_IMPORT
  40. # define MMALOMX_IMPORT(a) a
  41. #endif
  42. #define MAX_MARKS_NUM 2
  43. #define MAX_ENCODINGS_NUM 20
  44. /** Per-port context data */
  45. typedef struct MMALOMX_PORT_T
  46. {
  47. struct MMALOMX_COMPONENT_T *component;
  48. MMAL_PORT_T *mmal;
  49. OMX_DIRTYPE direction;
  50. unsigned int index;
  51. unsigned int buffers;
  52. unsigned int buffers_in_transit;
  53. MMAL_BOOL_T buffers_allocated:1;
  54. MMAL_BOOL_T enabled:1;
  55. MMAL_BOOL_T populated:1;
  56. MMAL_BOOL_T zero_copy:1;
  57. MMAL_BOOL_T no_cropping:1;
  58. MMAL_BOOL_T format_changed:1;
  59. MMAL_POOL_T *pool;
  60. uint32_t actions;
  61. OMX_MARKTYPE marks[MAX_MARKS_NUM];
  62. unsigned int marks_first:8;
  63. unsigned int marks_num:8;
  64. OMX_FORMAT_PARAM_TYPE format_param;
  65. MMAL_PARAMETER_HEADER_T encodings_header;
  66. MMAL_FOURCC_T encodings[MAX_ENCODINGS_NUM];
  67. unsigned int encodings_num;
  68. } MMALOMX_PORT_T;
  69. /** Component context data */
  70. typedef struct MMALOMX_COMPONENT_T {
  71. OMX_COMPONENTTYPE omx; /**< OMX component type structure */
  72. unsigned int registry_id;
  73. const char *name;
  74. uint32_t role;
  75. OMX_CALLBACKTYPE callbacks;
  76. OMX_PTR callbacks_data;
  77. struct MMAL_COMPONENT_T *mmal;
  78. OMX_STATETYPE state;
  79. unsigned int state_transition;
  80. MMALOMX_PORT_T *ports;
  81. unsigned int ports_num;
  82. unsigned int ports_domain_num[4];
  83. MMAL_BOOL_T actions_running;
  84. OMX_U32 group_id;
  85. OMX_U32 group_priority;
  86. /* Support for command queues */
  87. MMAL_POOL_T *cmd_pool;
  88. MMAL_QUEUE_T *cmd_queue;
  89. VCOS_THREAD_T cmd_thread;
  90. MMAL_BOOL_T cmd_thread_used;
  91. VCOS_SEMAPHORE_T cmd_sema;
  92. VCOS_MUTEX_T lock; /**< Used to protect component state */
  93. VCOS_MUTEX_T lock_port; /**< Used to protect port state */
  94. } MMALOMX_COMPONENT_T;
  95. OMX_ERRORTYPE mmalomx_callback_event_handler(
  96. MMALOMX_COMPONENT_T *component,
  97. OMX_EVENTTYPE eEvent,
  98. OMX_U32 nData1,
  99. OMX_U32 nData2,
  100. OMX_PTR pEventData);
  101. #define MMALOMX_LOCK(a) vcos_mutex_lock(&a->lock)
  102. #define MMALOMX_UNLOCK(a) vcos_mutex_unlock(&a->lock)
  103. #define MMALOMX_LOCK_PORT(a,b) vcos_mutex_lock(&a->lock_port)
  104. #define MMALOMX_UNLOCK_PORT(a,b) vcos_mutex_unlock(&a->lock_port)