Arm-2D  
2D Image Processing Library for Cortex-M Processors
 
Loading...
Searching...
No Matches
arm_2d.h
1/*
2 * Copyright (C) 2022 Arm Limited or its affiliates. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19/* ----------------------------------------------------------------------
20 * Project: Arm-2D Library
21 * Title: #include "arm_2d.h"
22 * Description: Public header file to contain the all avaialble Arm-2D
23 * interface header files
24 *
25 * $Date: 15 May 2025
26 * $Revision: V.1.2.3
27 *
28 * Target Processor: Cortex-M cores
29 * -------------------------------------------------------------------- */
30
31#ifndef __ARM_2D_H__
32#define __ARM_2D_H__
33
34/*============================ INCLUDES ======================================*/
35#include "arm_2d_types.h"
36#include "arm_2d_op.h"
37#include "arm_2d_tile.h"
38#include "arm_2d_draw.h"
39#include "arm_2d_conversion.h"
40#include "arm_2d_alpha_blending.h"
41#include "arm_2d_transform.h"
42#include "arm_2d_filter.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/* suppress some warnings for user applications when using arm-2d.
49 */
50#if defined(__clang__)
51# pragma clang diagnostic push
52# pragma clang diagnostic ignored "-Wunknown-warning-option"
53# pragma clang diagnostic ignored "-Wreserved-identifier"
54# pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end"
55# pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
56# pragma clang diagnostic ignored "-Wgnu-statement-expression"
57# pragma clang diagnostic ignored "-Wextra-semi-stmt"
58# pragma clang diagnostic ignored "-Wcompound-token-split-by-macro"
59# pragma clang diagnostic ignored "-Winitializer-overrides"
60# pragma clang diagnostic ignored "-Wgcc-compat"
61# pragma clang diagnostic ignored "-Wgnu-empty-initializer"
62# pragma clang diagnostic ignored "-Wshadow"
63# pragma clang diagnostic ignored "-Wconditional-uninitialized"
64# pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
65# pragma clang diagnostic ignored "-Wc23-extensions"
66# pragma clang diagnostic ignored "-Wunused-value"
67# pragma clang diagnostic ignored "-Wbad-function-cast"
68# pragma clang diagnostic ignored "-Wundef"
69#elif __IS_COMPILER_GCC__
70# pragma GCC diagnostic ignored "-Wpedantic"
71# pragma GCC diagnostic ignored "-Wmissing-braces"
72# pragma GCC diagnostic ignored "-Wunused-value"
73# pragma GCC diagnostic ignored "-Wnonnull-compare"
74# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
75# pragma GCC diagnostic ignored "-Wunused-const-variable"
76#elif defined(__IS_COMPILER_ARM_COMPILER_5__)
77# pragma diag_suppress 1296,174,64,177,1
78#endif
79
80/*!
81 * \addtogroup gKernel 1 Kernel
82 * @{
83 */
84
85/*============================ MACROS ========================================*/
86
87/* arm-2d version */
88#define ARM_2D_VERSION_MAJOR 1 //!< Major version
89#define ARM_2D_VERSION_MINOR 2 //!< Minor version
90#define ARM_2D_VERSION_PATCH 3 //!< Patch number
91#define ARM_2D_VERSION_STR "" //!< tag
92
93/*!
94 * \brief arm-2d version number in decimal
95 *
96 */
97#define ARM_2D_VERSION ( ARM_2D_VERSION_MAJOR * 10000ul \
98 + ARM_2D_VERSION_MINOR * 100ul \
99 + ARM_2D_VERSION_PATCH)
100
101/*============================ MACROFIED FUNCTIONS ===========================*/
102
103#define ARM_2D_OP_INIT(__OP) \
104 arm_2d_op_init((arm_2d_op_core_t *)&(__OP), sizeof(__OP))
105#define ARM_2D_OP_DEPOSE(__OP) \
106 arm_2d_op_depose((arm_2d_op_core_t *)&(__OP), sizeof(__OP))
107/*!
108 * \brief wait asynchronous operation complete
109 * \param[in] ... [OPTIONAL] the address of the target OP (NULL or ignore means using the default OP)
110 * \retval true sync up with operation
111 * \retval false operation is busy
112 */
113#define ARM_2D_OP_WAIT_ASYNC(...) \
114 arm_2d_op_wait_async((arm_2d_op_core_t *)(NULL,##__VA_ARGS__))
115
116/*============================ TYPES =========================================*/
117
118/*!
119 * \brief a type for arm-2d runtime configuration
120 *
121 */
122typedef struct {
123 /*! if the target region is out of the target tile, return arm_fsm_rt_cpl */
125
126 /*! indicate that there is a dedicated thread to run arm_2d_task() in RTOS env */
128 uint8_t : 6;
130
131/*!
132 * \brief a type for arm-2d version
133 *
134 */
135typedef struct {
136 uint8_t Major; //!< major version
137 uint8_t Minor; //!< minor version
138 uint8_t Patch; //!< patch number
139 uint8_t : 8;
141
142/*============================ GLOBAL VARIABLES ==============================*/
143
144/*!
145 * \brief arm-2d runtime feature configuration
146 *
147 */
148extern
150
151/*!
152 * \brief arm-2d version
153 *
154 */
155extern
157
158/*============================ PROTOTYPES ====================================*/
159
160/*!
161 * \brief initialise arm-2d
162 */
163extern
164void arm_2d_init(void);
165
166/*!
167 * \brief set the default frame buffer
168 * \param ptFrameBuffer the new frame buffer,
169 * \note Passing NULL means using no default framebuffer
170 * \return arm_2d_tile_t* the address of the old frame buffer
171 */
172extern
174 const arm_2d_tile_t *ptFrameBuffer);
175
176/*!
177 * \brief get the default frame buffer
178 * \return arm_2d_tile_t* the address of the default frame buffer
179 */
180extern
182
183/*!
184 * \brief attach a user param (which could be a pointer) to specified OP
185 * \param ptOP the address of the target OP (NULL means using the default OP)
186 * \param pUserParam a user parameter (it can be used as a pointer)
187 */
188extern
189void arm_2d_set_user_param(arm_2d_op_core_t *ptOP, uintptr_t pUserParam);
190
191
192/*!
193 * \brief initialize an given opcode
194 * \param ptOP the address of the target OP
195 * \param tSize the size of the opcode object
196 * \return arm_2d_op_core_t * the address of the OP
197 */
198extern
200
201
202/*!
203 * \brief depose an given opcode
204 * \param ptOP the address of the target OP
205 * \param tSize the size of the opcode object
206 * \return arm_2d_op_core_t * the address of the OP
207 */
208extern
210
211/*!
212 * \brief attach a semaphore (which could be a pointer) to specified OP
213 * \param ptOP the address of the target OP (NULL means using the default OP)
214 * \param pSemaphore a pointer points to a RTOS semaphore
215 * \note this API only available when __ARM_2D_HAS_ASYNC__ is 1
216 */
217extern
218void arm_2d_op_attach_semaphore(arm_2d_op_core_t *ptOP, uintptr_t pSemaphore);
219
220/*!
221 * \brief get the attached semaphore (which could be a pointer) from specified OP
222 * \param ptOP the address of the target OP (NULL means using the default OP)
223 * \return uintptr_t the semaphore
224 * \note this API only available when __ARM_2D_HAS_ASYNC__ is 1
225 */
226extern
228
229/*!
230 * \brief wait asynchronous operation complete
231 * \param[in] ptOP the address of the target OP (NULL means using the default OP)
232 * \retval true sync up with operation
233 * \retval false operation is busy
234 */
235extern
237
238/*!
239 \brief get the status of a specified OP,
240 \details usually, it is used after calling arm_2d_op_wait_async().
241 E.g.
242 \code
243 //! wait for previous operation complete
244 do {
245 arm_2d_op_wait_async();
246 arm_2d_op_status_t tStatus = arm_2d_get_op_status();
247 if (tStatus.bIOError) {
248 //! error detected
249 ...
250 } else if (tStatus.bOpCpl) {
251 break;
252 }
253 } while(true);
254 \endcode
255 \param ptOP the address of the target OP (NULL means using the default OP)
256 \return arm_2d_op_status_t the operation status
257 */
258extern
260
261/*!
262 * \brief arm-2d pixel pipeline task entery
263 * \note This function is *TRHEAD-SAFE*
264 * \param ptTask the address of an arm-2d task control block
265 * \retval arm_fsm_rt_cpl The sub-task FIFO is empty, the caller can wait for a
266 * semaphore set by arm_2d_notif_sub_task_fifo_task_arrive()
267 * \retval arm_fsm_rt_on_going The arm_2d_task yields
268 * \retval arm_fsm_rt_async You shouldn't see this value
269 * \retval arm_fsm_rt_wait_for_obj hardware accelerator wants to sync-up with applications.
270 * \retval (<0) Serious error is detected.
271 */
272extern
274
275/*!
276 * \brief allocate a memory block with specified memory type
277 *
278 * \param wSize the minimal size
279 * \param nAlign the alignment
280 * \param tType the type of memory
281 * \return void* the memory address
282 */
283extern
284void *__arm_2d_allocate_scratch_memory( uint32_t wSize,
285 uint_fast8_t nAlign,
286 arm_2d_mem_type_t tType);
287/*!
288 * \brief free a specified memory block
289 *
290 * \param tType the type of memory
291 * \param pBuff the address of the memory
292 */
293extern
295 void *pBuff);
296
297/*!
298 * \brief allocate a scratch memory and initialize arm_2d_scratch_mem_t object
299 *
300 * \param[out] ptMemory the address of an arm_2d_scratch_mem_t object to hold
301 * the result
302 * \param[in] hwItemSize the size of each item
303 * \param[in] hwItemCount the number of items
304 * \param[in] hwAlignment the alignment requirement
305 * \param[in] tType the type of memory
306 * \return arm_2d_scratch_mem_t* the initialized the arm_2d_scratch_mem_t object
307 * address. NULL means failed to allocate scratch memory
308 */
309extern
310ARM_NONNULL(1)
312 uint16_t hwItemSize,
313 uint16_t hwItemCount,
314 uint16_t hwAlignment,
315 arm_2d_mem_type_t tType);
316
317
318/*!
319 * \brief free a scratch memory with a given scratch memory descriptor object
320 *
321 * \param[in] the target scratch memory descriptor
322 * \return arm_2d_scratch_mem_t * the de-initialized the scratch memory descriptor
323 */
324extern
325ARM_NONNULL(1)
327
328/*! @} */
329
330/*! \note delibrately comment out */
331//#if defined(__clang__)
332//# pragma clang diagnostic pop
333//#endif
334
335#ifdef __cplusplus
336}
337#endif
338
339
340#endif