1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #include "mmalomx.h" |
29 | #include "mmalomx_util_params_common.h" |
30 | #include "mmalomx_logging.h" |
31 | |
32 | static MMAL_STATUS_T mmalomx_param_mapping_event_request(MMALOMX_PARAM_MAPPING_DIRECTION dir, |
33 | MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param) |
34 | { |
35 | OMX_CONFIG_REQUESTCALLBACKTYPE *omx = (OMX_CONFIG_REQUESTCALLBACKTYPE *)omx_param; |
36 | MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T *mmal = (MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T *)mmal_param; |
37 | const MMALOMX_PARAM_TRANSLATION_T *change_xlat; |
38 | |
39 | if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL) |
40 | { |
41 | change_xlat = mmalomx_find_parameter_from_omx_id(omx->nIndex); |
42 | if (!change_xlat) |
43 | { |
44 | VCOS_ALERT("ommalomx_param_mapping_event_request: omx parameter " |
45 | "0x%08x not recognised" , omx->nIndex); |
46 | return MMAL_EINVAL; |
47 | } |
48 | |
49 | mmal->change_id = change_xlat->mmal_id; |
50 | mmal->enable = omx->bEnable; |
51 | } |
52 | else |
53 | { |
54 | change_xlat = mmalomx_find_parameter_from_mmal_id(mmal->change_id); |
55 | if (!change_xlat) |
56 | { |
57 | VCOS_ALERT("mmalomx_param_mapping_event_request: mmal parameter " |
58 | "0x%08x not recognised" , mmal->change_id); |
59 | return MMAL_EINVAL; |
60 | } |
61 | |
62 | omx->nIndex = change_xlat->omx_id; |
63 | omx->bEnable = mmal->enable; |
64 | } |
65 | |
66 | return MMAL_SUCCESS; |
67 | } |
68 | |
69 | static MMAL_STATUS_T mmalomx_param_mapping_statistics(MMALOMX_PARAM_MAPPING_DIRECTION dir, |
70 | MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param) |
71 | { |
72 | OMX_CONFIG_BRCMPORTSTATSTYPE *omx = (OMX_CONFIG_BRCMPORTSTATSTYPE *)omx_param; |
73 | MMAL_PARAMETER_STATISTICS_T *mmal = (MMAL_PARAMETER_STATISTICS_T *)mmal_param; |
74 | |
75 | if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL) |
76 | { |
77 | mmal->buffer_count = omx->nBufferCount; |
78 | mmal->frame_count = omx->nImageCount + omx->nFrameCount; |
79 | mmal->frames_skipped = omx->nFrameSkips; |
80 | mmal->frames_discarded = omx->nDiscards; |
81 | mmal->eos_seen = omx->nEOS; |
82 | mmal->maximum_frame_bytes = omx->nMaxFrameSize; |
83 | mmal->total_bytes = omx_ticks_to_s64(omx->nByteCount); |
84 | mmal->corrupt_macroblocks = omx->nCorruptMBs; |
85 | } |
86 | else |
87 | { |
88 | omx->nBufferCount = mmal->buffer_count; |
89 | omx->nFrameCount = mmal->frame_count; |
90 | omx->nImageCount = 0; |
91 | omx->nFrameSkips = mmal->frames_skipped; |
92 | omx->nDiscards = mmal->frames_discarded; |
93 | omx->nEOS = mmal->eos_seen; |
94 | omx->nMaxFrameSize = mmal->maximum_frame_bytes; |
95 | omx->nByteCount = omx_ticks_from_s64(mmal->total_bytes); |
96 | omx->nCorruptMBs = mmal->corrupt_macroblocks; |
97 | } |
98 | |
99 | return MMAL_SUCCESS; |
100 | } |
101 | |
102 | static MMAL_STATUS_T mmalomx_param_mapping_buffer_flags(MMALOMX_PARAM_MAPPING_DIRECTION dir, |
103 | MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param) |
104 | { |
105 | OMX_PARAM_U32TYPE *omx = (OMX_PARAM_U32TYPE *)omx_param; |
106 | MMAL_PARAMETER_UINT32_T *mmal = (MMAL_PARAMETER_UINT32_T *)mmal_param; |
107 | |
108 | if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL) |
109 | mmal->value = mmalil_buffer_flags_to_mmal(omx->nU32); |
110 | else |
111 | omx->nU32 = mmalil_buffer_flags_to_omx(mmal->value); |
112 | |
113 | return MMAL_SUCCESS; |
114 | } |
115 | |
116 | static MMAL_STATUS_T mmalomx_param_mapping_time(MMALOMX_PARAM_MAPPING_DIRECTION dir, |
117 | MMAL_PARAMETER_HEADER_T *mmal_param, OMX_PTR omx_param) |
118 | { |
119 | OMX_TIME_CONFIG_TIMESTAMPTYPE *omx = (OMX_TIME_CONFIG_TIMESTAMPTYPE *)omx_param; |
120 | MMAL_PARAMETER_INT64_T *mmal = (MMAL_PARAMETER_INT64_T *)mmal_param; |
121 | |
122 | if (dir == MMALOMX_PARAM_MAPPING_TO_MMAL) |
123 | mmal->value = omx_ticks_to_s64(omx->nTimestamp); |
124 | else |
125 | omx->nTimestamp = omx_ticks_from_s64(mmal->value); |
126 | |
127 | return MMAL_SUCCESS; |
128 | } |
129 | |
130 | const MMALOMX_PARAM_TRANSLATION_T mmalomx_param_xlator_misc[] = { |
131 | MMALOMX_PARAM_STRAIGHT_MAPPING_DOUBLE_TRANSLATION(MMAL_PARAMETER_CHANGE_EVENT_REQUEST, MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T, |
132 | OMX_IndexConfigRequestCallback, OMX_CONFIG_REQUESTCALLBACKTYPE, |
133 | mmalomx_param_mapping_event_request), |
134 | MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_STATISTICS, MMAL_PARAMETER_STATISTICS_T, |
135 | OMX_IndexConfigBrcmPortStats, OMX_CONFIG_BRCMPORTSTATSTYPE, |
136 | mmalomx_param_mapping_statistics), |
137 | MMALOMX_PARAM_PASSTHROUGH(MMAL_PARAMETER_MEM_USAGE, MMAL_PARAMETER_MEM_USAGE_T, |
138 | OMX_IndexConfigBrcmPoolMemAllocSize, OMX_PARAM_U32TYPE), |
139 | MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_BUFFER_FLAG_FILTER, MMAL_PARAMETER_UINT32_T, |
140 | OMX_IndexConfigBrcmBufferFlagFilter, OMX_PARAM_U32TYPE, |
141 | mmalomx_param_mapping_buffer_flags), |
142 | MMALOMX_PARAM_BOOLEAN(MMAL_PARAMETER_ZERO_COPY, |
143 | OMX_IndexParamBrcmZeroCopy), |
144 | MMALOMX_PARAM_BOOLEAN(MMAL_PARAMETER_LOCKSTEP_ENABLE, |
145 | OMX_IndexParamBrcmLockStepEnable), |
146 | MMALOMX_PARAM_BOOLEAN_PORTLESS(MMAL_PARAMETER_POWERMON_ENABLE, |
147 | OMX_IndexConfigBrcmPowerMonitor), |
148 | MMALOMX_PARAM_STRAIGHT_MAPPING(MMAL_PARAMETER_CLOCK_TIME, MMAL_PARAMETER_INT64_T, |
149 | OMX_IndexConfigTimeCurrentMediaTime, OMX_TIME_CONFIG_TIMESTAMPTYPE, |
150 | mmalomx_param_mapping_time), |
151 | MMALOMX_PARAM_TERMINATE() |
152 | }; |
153 | |
154 | #if 0 |
155 | /* Conversions which are not done here. Should part of the core. */ |
156 | MMAL_PARAMETER_SUPPORTED_ENCODINGS |
157 | #endif |
158 | |