Arm-2D  
2D Image Processing Library for Cortex-M Processors
arm_2d_features.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_features.h"
22 * Description: Public header file to indicate features avaialble for this
23 * arm-2d library variant.
24 *
25 * $Date: 14. Aug 2023
26 * $Revision: V.1.1.0
27 *
28 * Target Processor: Cortex-M cores
29 * -------------------------------------------------------------------- */
30
31#ifndef __ARM_2D_FEATURES_H__
32#define __ARM_2D_FEATURES_H__
33
34/*============================ INCLUDES ======================================*/
35
36/*!
37 * \addtogroup gKernel 1 Kernel
38 * @{
39 */
40
41#ifndef ___ARM_2D_CFG_SKIP_HEADER___
42# ifndef ___ARM_2D_CFG_HEADER___
43# include "arm_2d_cfg.h"
44# else
45# include ___ARM_2D_CFG_HEADER___
46# endif
47#endif
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53#if defined(__clang__)
54# pragma clang diagnostic push
55# pragma clang diagnostic ignored "-Wunknown-warning-option"
56# pragma clang diagnostic ignored "-Wreserved-identifier"
57# pragma clang diagnostic ignored "-Wmicrosoft-anon-tag"
58# pragma clang diagnostic ignored "-Wdeclaration-after-statement"
59#endif
60
61/*============================ MACROS ========================================*/
62
63#undef __ARM_2D_HAS_HELIUM__
64#undef __ARM_2D_HAS_HELIUM_INTEGER__
65#undef __ARM_2D_HAS_HELIUM_FLOAT__
66
67#if defined(__ARM_FEATURE_MVE) && __ARM_FEATURE_MVE
68# define __ARM_2D_HAS_HELIUM__ 1 //!< target MCU has the Helium extension
69# define __ARM_2D_HAS_HELIUM_INTEGER__ 1 //!< target MCU has the Helium integer extension
70# if (__ARM_FEATURE_MVE & 2)
71# define __ARM_2D_HAS_HELIUM_FLOAT__ 1 //!< target MCU has the Helium floating point extension
72# else
73# define __ARM_2D_HAS_HELIUM_FLOAT__ 0 //!< target MCU has no Helium floating point extension
74# endif
75#else
76# define __ARM_2D_HAS_HELIUM__ 0 //!< target MCU has no Helium extension
77# define __ARM_2D_HAS_HELIUM_INTEGER__ 0 //!< target MCU has no Helium integer extension
78# define __ARM_2D_HAS_HELIUM_FLOAT__ 0 //!< target MCU has no Helium floating point extension
79#endif
80
81
82#ifndef __ARM_2D_HAS_ACI__
83# define __ARM_2D_HAS_ACI__ 0 //!< target MCU has no ACI implementation
84#endif
85
86#ifndef __ARM_2D_HAS_TIGHTLY_COUPLED_ACC__
87# define __ARM_2D_HAS_TIGHTLY_COUPLED_ACC__ 0 //!< target MCU has no tightly coupled acceleration (other than ACI)
88#endif
89
90#ifndef __ARM_2D_HAS_HW_ACC__
91# define __ARM_2D_HAS_HW_ACC__ 0 //!< target MCU has no dedicated hardware (async) acceleration
92#endif
93
94#if defined(__ARM_2D_HAS_HW_ACC__) && __ARM_2D_HAS_HW_ACC__
95# if defined(__ARM_2D_HAS_ASYNC__) && !__ARM_2D_HAS_ASYNC__
96# warning As long as __ARM_2D_HAS_HW_ACC__ is set to 1,\
97 __ARM_2D_HAS_ASYNC__ is forced to 1. Since you set __ARM_2D_HAS_ASYNC__ to\
98 0, please remove your macro definition for __ARM_2D_HAS_ASYNC__ to avoid this\
99 warning.
100# endif
101# undef __ARM_2D_HAS_ASYNC__
102# define __ARM_2D_HAS_ASYNC__ 1 //!< enable asynchronous mode (enable pipeline)
103#endif
104
105#ifndef __ARM_2D_HAS_ASYNC__
106# define __ARM_2D_HAS_ASYNC__ 1 //!< enable asynchronous mode (enable pipeline)
107#endif
108#if defined(__ARM_2D_HAS_ASYNC__) && __ARM_2D_HAS_ASYNC__
109# if !defined(__ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__) || \
110 __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ < 4
111# define __ARM_2D_CFG_DEFAULT_SUB_TASK_POOL_SIZE__ 4 //!< default pool size for sub-tasks
112# endif
113#endif
114
115#undef __ARM_2D_HAS_FPU__
116#if defined(__ARM_FP)
117#define __ARM_2D_HAS_FPU__ 1 //!< target MCU has FPU
118#else
119#define __ARM_2D_HAS_FPU__ 0 //!< target MCU has no FPU
120#endif
121
122#undef __ARM_2D_HAS_DSP__
123#if defined(__ARM_FEATURE_DSP) && __ARM_FEATURE_DSP
124#define __ARM_2D_HAS_DSP__ 1 //!< target MCU has a (simple) DSP extension
125#else
126#define __ARM_2D_HAS_DSP__ 0 //!< target MCU has no DSP extension
127#endif
128
129#ifndef __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__
130# ifdef __ARM_2D_HAS_INTERPOLATION_ROTATION__
131# warning __ARM_2D_HAS_INTERPOLATION_ROTATION__ is deprecated, please use __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ instead.
132/*! \brief __ARM_2D_HAS_INTERPOLATION_ROTATION__ is deprecated
133 *! add this for backward compatible
134 */
135
136/*! enable the anti-alias support in transform operations */
137# define __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ \
138 __ARM_2D_HAS_INTERPOLATION_ROTATION__
139# else
140# define __ARM_2D_HAS_ANTI_ALIAS_TRANSFORM__ 0 //!< disable the anti-alias support in transform operations
141# endif
142#endif
143
144
145/*! \note DO NOT define macro __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ unless
146 *! you sure about what you are doing.
147 */
148#if !__ARM_2D_HAS_FPU__
149# undef __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
150# define __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ 1 //!< use fixed point numbers in transform operations
151#elif !__ARM_2D_HAS_HELIUM__ \
152 && !defined(__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__)
153 /*! \note For Armv7-m processors and Armv8-m processors that have no Helium
154 *! extension but only FPU, fixed point rotation is faster than the
155 *! float point rotation even if FPU can accelerate float point
156 *! operations.
157 */
158# define __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ 1 //!< use fixed point numbers in transform operations
159#endif
160
161#if __ARM_2D_HAS_HELIUM_INTEGER__ && !__ARM_2D_HAS_HELIUM_FLOAT__
162# undef __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
163# define __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ 1 //!< use fixed point numbers in transform operations
164#endif
165
166#ifndef __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
167# define __ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__ 1 //!< use fixed point numbers in transform operations
168#endif
169
170#ifndef __ARM_2D_CFG_OPTIMIZE_FOR_POINTER_LIKE_SHAPES_IN_TRANSFORM__
171# define __ARM_2D_CFG_OPTIMIZE_FOR_POINTER_LIKE_SHAPES_IN_TRANSFORM__ 1
172#endif
173
174/*! \note In your application, if you do need to use RGBA8888 for some resources
175 *! and you want to use colour channels (e.g. the alpha channel) in mask
176 *! related APIs, please set this macro to 1 in your project.
177 */
178#ifndef __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__
179# define __ARM_2D_CFG_SUPPORT_COLOUR_CHANNEL_ACCESS__ 1 //!< enable the support for CCCA8888
180#endif
181
182/*----------------------------------------------------------------------------*
183 * Unsafe configurations *
184 *----------------------------------------------------------------------------*
185 * Following macro switches are used to improve performance with aggressive *
186 * methods which might cause errors or distortions in some cases. *
187 * Those macros are undefined by defaults. Please use with cautions. *
188 *----------------------------------------------------------------------------*
189 * *
190 * 1. __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__ *
191 * This option is used to remove calibration in angle computations to gain *
192 * a better performance, small error might be noticible for angles like *
193 * 90, 180, 270 etc. *
194 * *
195 * 2. __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__ *
196 * This option is used to speed up M-cores without DSP support *
197 * It skips saturation in the QADD/QDADD/QDSUB involved in the rotation. *
198 * The chances of overflow remain low as elements involved are using *
199 * non-accumulating Q15.16 format and integer parts are in the range of *
200 * the screen size providing enough margin. *
201 * *
202 * 3. __ARM_2D_CFG_UNSAFE_IGNORE_ALPHA_255_COMPENSATION__ *
203 * When define this macro, alpha value 0xFF will not be treated as opaque *
204 * in mask related operations you can barely see the background. Defining *
205 * this macro can get a big performance uplift. *
206 *----------------------------------------------------------------------------*/
207
208
209/*! \note __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__ is
210 * deprecated.
211 * Please use __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__ instead.
212 */
213#ifndef __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__
214# ifdef __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__
215
216# warning __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__\
217 is deprecated, please use __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__\
218 instead.
219
220/*! disable the small angle calibration in transform operations */
221# define __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_TRANSFORM__ \
222 __ARM_2D_CFG_UNSAFE_IGNORE_CALIB_IN_ROTATION_FOR_PERFORMANCE__
223# endif
224#endif
225
226/*! \note __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__ is
227 * deprecated.
228 * Please use __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__ instead.
229 */
230#ifndef __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__
231# ifdef __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__
232# warning __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__\
233 is deprecated, please use __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__\
234 instead.
235
236/*! disable the saturation protection in fixed point operations */
237# define __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT__ \
238 __ARM_2D_CFG_UNSAFE_NO_SATURATION_IN_FIXED_POINT_FOR_PERFROMANCE__
239#endif
240#endif
241
242/*============================ MACROFIED FUNCTIONS ===========================*/
243/*============================ TYPES =========================================*/
244/*============================ GLOBAL VARIABLES ==============================*/
245/*============================ PROTOTYPES ====================================*/
246
247/*! @} */
248
249#ifdef __cplusplus
250}
251#endif
252
253
254/*============================ POST INCLUDES =================================*/
255
256/* include user acceleration header file(s) */
257#if defined(__ARM_2D_HAS_TIGHTLY_COUPLED_ACC__) && __ARM_2D_HAS_TIGHTLY_COUPLED_ACC__
258# include "arm_2d_user_sync_acc.h"
259#endif
260#if defined(__ARM_2D_HAS_ACI__) && __ARM_2D_HAS_ACI__
261# include "arm_2d_user_aci.h"
262#endif
263#if defined(__ARM_2D_HAS_HW_ACC__) && __ARM_2D_HAS_HW_ACC__
264# include "arm_2d_user_async_acc.h"
265#endif
266
267#endif