Arm-2D  
2D Image Processing Library for Cortex-M Processors
 
Loading...
Searching...
No Matches
arm_2d_types.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: arm_2d_types.h
22 * Description: Public header file to contain the Arm-2D structs
23 *
24 * $Date: 25. Nov 2022
25 * $Revision: V.1.1.0
26 *
27 * Target Processor: Cortex-M cores
28 * -------------------------------------------------------------------- */
29
30
31#ifndef __ARM_2D_TYPES_H__
32#define __ARM_2D_TYPES_H__
33
34/*============================ INCLUDES ======================================*/
35#include <string.h>
36#include <stdint.h>
37#include <stdbool.h>
38#include <assert.h>
39
40#include "arm_2d_features.h"
41#include "arm_2d_utils.h"
42#include "__arm_2d_math.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48#if defined(__clang__)
49# pragma clang diagnostic push
50# pragma clang diagnostic ignored "-Wunknown-warning-option"
51# pragma clang diagnostic ignored "-Wreserved-identifier"
52# pragma clang diagnostic ignored "-Wmissing-declarations"
53# pragma clang diagnostic ignored "-Wpadded"
54# pragma clang diagnostic ignored "-Wc11-extensions"
55#elif __IS_COMPILER_ARM_COMPILER_5__
56# pragma diag_suppress 64
57#elif __IS_COMPILER_GCC__
58# pragma GCC diagnostic push
59# pragma GCC diagnostic ignored "-Wmissing-declarations"
60# pragma GCC diagnostic ignored "-Wpadded"
61#endif
62
63/*!
64 * \addtogroup gKernel 1 Kernel
65 * @{
66 */
67
68/*============================ MACROS ========================================*/
69
70/* A patch for GCC support */
71#if defined(__IS_COMPILER_GCC__) && __IS_COMPILER_GCC__ && __ARM_2D_HAS_HELIUM__
72
73# ifndef __ARM_2D_SUPPRESS_GCC_HELIUM_PATCH_WARNING__
74# pragma GCC warning "As GCC has compilation issues for supporting Helium,\
75 the scalar version is used. You can define a macro\
76 __ARM_2D_SUPPRESS_GCC_HELIUM_PATCH_WARNING__ to suppress this warning."
77# endif
78
79# undef __ARM_2D_HAS_HELIUM__
80# undef __ARM_2D_HAS_HELIUM_INTEGER__
81# undef __ARM_2D_HAS_HELIUM_FLOAT__
82
83# define __ARM_2D_HAS_HELIUM__ 0 //!< target MCU has no Helium extension
84# define __ARM_2D_HAS_HELIUM_INTEGER__ 0 //!< target MCU has no Helium integer extension
85# define __ARM_2D_HAS_HELIUM_FLOAT__ 0 //!< target MCU has no Helium floating point extension
86#endif
87
88/*============================ MACROFIED FUNCTIONS ===========================*/
89/*============================ TYPES =========================================*/
90
91
92/*----------------------------------------------------------------------------*
93 * Infrastructure *
94 *----------------------------------------------------------------------------*/
95
96/*!
97 * \brief finite-state-machine status return (Compatible with arm_status, minimal integer: int8_t)
98 *
99 */
100typedef enum {
101 arm_fsm_rt_err = -1, //!< fsm error
102 arm_fsm_rt_cpl = 0, //!< fsm complete
103 arm_fsm_rt_on_going = 1, //!< fsm on-going
104 arm_fsm_rt_wait_for_obj = 2, //!< fsm wait for IPC object
105 arm_fsm_rt_async = 3, //!< fsm work asynchronously, please check it later.
106 arm_fsm_rt_wait_for_res = 4, //!< wait for resource
108
109/*!
110 * \brief the error code for arm-2d (minimal integer: int8_t)
111 *
112 */
113typedef enum {
114 ARM_2D_ERR_NOT_AVAILABLE = -12, //!< service is not available or not initialissed
115 ARM_2D_ERR_UNSUPPORTED_COLOUR = -11, //!< the specified colour is not supported
116 ARM_2D_ERR_BUSY = -10, //!< service is busy
117 ARM_2D_ERR_INSUFFICIENT_RESOURCE = -9, //!< insufficient resource
118 ARM_2D_ERR_IO_BUSY = -8, //!< HW accelerator is busy
119 ARM_2D_ERR_IO_ERROR = -7, //!< Generic HW error
120 ARM_2D_ERR_MISSING_PARAM = -6, //!< missing mandatory parameter
121 ARM_2D_ERR_INVALID_OP = -5, //!< unsupported / invalid operation
122 ARM_2D_ERR_NOT_SUPPORT = -4, //!< feature/service/operation is not supported
123 ARM_2D_ERR_OUT_OF_REGION = -3, //!< the operation is out of target area
124 ARM_2D_ERR_INVALID_PARAM = -2, //!< invalid parameter
125 ARM_2D_ERR_UNKNOWN = -1, //!< generic or unknown errors
126 ARM_2D_ERR_NONE = 0, //!< no error
128
129/*!
130 * \brief comparison result
131 *
132 */
133typedef enum {
134 ARM_2D_CMP_SMALLER = -1, //!< the target is smaller than the reference
135 ARM_2D_CMP_EQUALS = 0, //!< the target is equal to the reference
136 ARM_2D_CMP_LARGER = 1, //!< the target is larger than the reference
138
139/*----------------------------------------------------------------------------*
140 * Colour definitions *
141 *----------------------------------------------------------------------------*/
142
143/*!
144 * \brief the colour type for gray8 (8bit gray scale)
145 *
146 */
147typedef union arm_2d_color_gray8_t {
148 uint8_t tValue;
150
151/*!
152 * \brief the colour type for rgb565
153 *
154 */
156 uint16_t tValue;
157 struct {
158 uint16_t u5B : 5;
159 uint16_t u6G : 6;
160 uint16_t u5R : 5;
161 };
163
164/*!
165 * \brief the colour type for brga8888
166 *
167 * \details In most cases four equal-sized pieces of adjacent memory are used,
168 * one for each channel, and a 0 in a channel indicates black color or
169 * transparent alpha, while all-1 bits indicates white or fully opaque
170 * alpha. By far the most common format is to store 8 bits (one byte)
171 * for each channel, which is 32 bits for each pixel.
172 *
173 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
174 */
176 uint32_t tValue;
177 struct {
178 uint32_t u8B : 8;
179 uint32_t u8G : 8;
180 uint32_t u8R : 8;
181 uint32_t u8A : 8;
182 };
184
185/*!
186 * \brief the colour type for rgb888 (compliant with ccca888 and bgra8888)
187 *
188 * \details In most cases four equal-sized pieces of adjacent memory are used,
189 * one for each channel, and a 0 in a channel indicates black color or
190 * transparent alpha, while all-1 bits indicates white or fully opaque
191 * alpha. By far the most common format is to store 8 bits (one byte)
192 * for each channel, which is 32 bits for each pixel.
193 *
194 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
195 */
197 uint32_t tValue;
198 struct {
199 uint32_t u8B : 8;
200 uint32_t u8G : 8;
201 uint32_t u8R : 8;
202 uint32_t : 8;
203 };
205
206/*!
207 * \brief the colour type for any 32bit colour formats which has an alpha channel on its 3rd byte.
208 *
209 * \details In most cases four equal-sized pieces of adjacent memory are used,
210 * one for each channel, and a 0 in a channel indicates black color or
211 * transparent alpha, while all-1 bits indicates white or fully opaque
212 * alpha. By far the most common format is to store 8 bits (one byte)
213 * for each channel, which is 32 bits for each pixel.
214 *
215 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
216 */
218 uint32_t tValue;
219 struct {
220 uint8_t u8C[3];
221 uint8_t u8A;
222 };
224
225/*!
226 * \brief the colour type for any 32bit colour formats which has an alpha channel on its first byte.
227 *
228 * \details In most cases four equal-sized pieces of adjacent memory are used,
229 * one for each channel, and a 0 in a channel indicates black color or
230 * transparent alpha, while all-1 bits indicates white or fully opaque
231 * alpha. By far the most common format is to store 8 bits (one byte)
232 * for each channel, which is 32 bits for each pixel.
233 *
234 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
235 */
237 uint32_t tValue;
238 struct {
239 uint8_t u8A;
240 uint8_t u8C[3];
241 };
243
244/*!
245 * \brief the colour type for any 32bit colour formats which has an unused-alpha channel on its 3rd byte.
246 *
247 * \details In most cases four equal-sized pieces of adjacent memory are used,
248 * one for each channel, and a 0 in a channel indicates black color or
249 * transparent alpha, while all-1 bits indicates white or fully opaque
250 * alpha. By far the most common format is to store 8 bits (one byte)
251 * for each channel, which is 32 bits for each pixel.
252 *
253 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
254 */
256 uint32_t tValue;
257 struct {
258 uint8_t u8C[3];
259 uint8_t : 8;
260 };
262
263/*!
264 * \brief the colour type for any 32bit colour formats which has an unused-alpha channel on its first byte.
265 *
266 * \details In most cases four equal-sized pieces of adjacent memory are used,
267 * one for each channel, and a 0 in a channel indicates black color or
268 * transparent alpha, while all-1 bits indicates white or fully opaque
269 * alpha. By far the most common format is to store 8 bits (one byte)
270 * for each channel, which is 32 bits for each pixel.
271 *
272 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
273 */
275 uint32_t tValue;
276 struct {
277 uint8_t : 8;
278 uint8_t u8C[3];
279 };
281
282/*!
283 * \brief enumerations for colour attributes
284 */
285enum {
286 ARM_2D_COLOUR_SZ_1BIT = 0, //!< 1 bit:black and white
287 ARM_2D_COLOUR_SZ_2BIT = 1, //!< 4 colours or 4 gray-levels
288 ARM_2D_COLOUR_SZ_4BIT = 2, //!< 16 colours or 16 gray-levels
289 ARM_2D_COLOUR_SZ_8BIT = 3, //!< 256 colours
290 ARM_2D_COLOUR_SZ_16BIT = 4, //!< 16bits
291 ARM_2D_COLOUR_SZ_32BIT = 5, //!< true colour
292
293 ARM_2D_COLOUR_SZ_1BIT_msk = ARM_2D_COLOUR_SZ_1BIT << 1,
294 ARM_2D_COLOUR_SZ_2BIT_msk = ARM_2D_COLOUR_SZ_2BIT << 1,
295 ARM_2D_COLOUR_SZ_4BIT_msk = ARM_2D_COLOUR_SZ_4BIT << 1,
296 ARM_2D_COLOUR_SZ_8BIT_msk = ARM_2D_COLOUR_SZ_8BIT << 1,
297 ARM_2D_COLOUR_SZ_16BIT_msk = ARM_2D_COLOUR_SZ_16BIT<< 1,
298 ARM_2D_COLOUR_SZ_32BIT_msk = ARM_2D_COLOUR_SZ_32BIT<< 1,
299 ARM_2D_COLOUR_SZ_msk = (0x07 << 1),
300
301 ARM_2D_COLOUR_LITTLE_ENDIAN = 0,
302 ARM_2D_COLOUR_BIG_ENDIAN = 1,
303
304 ARM_2D_COLOUR_LITTLE_ENDIAN_msk = ARM_2D_COLOUR_LITTLE_ENDIAN << 4,
305 ARM_2D_COLOUR_BIG_ENDIAN_msk = ARM_2D_COLOUR_BIG_ENDIAN << 4,
306
307 ARM_2D_COLOUR_NO_ALPHA = 0,
308 ARM_2D_COLOUR_HAS_ALPHA = 1,
309
310 ARM_2D_COLOUR_NO_ALPHA_msk = ARM_2D_COLOUR_NO_ALPHA << 0,
311 ARM_2D_COLOUR_HAS_ALPHA_msk = ARM_2D_COLOUR_HAS_ALPHA << 0,
312
313 ARM_2D_COLOUR_VARIANT_pos = 5,
314 ARM_2D_COLOUR_VARIANT_msk = 0x07 << ARM_2D_COLOUR_VARIANT_pos,
315};
316
317/* macros for colour attributes */
318#define ARM_2D_M_COLOUR_SZ_1BIT 0 //!< 1 bit:black and white
319#define ARM_2D_M_COLOUR_SZ_2BIT 1 //!< 4 colours or 4 gray-levels
320#define ARM_2D_M_COLOUR_SZ_4BIT 2 //!< 16 colours or 16 gray-levels
321#define ARM_2D_M_COLOUR_SZ_8BIT 3 //!< 256 colours
322#define ARM_2D_M_COLOUR_SZ_16BIT 4 //!< 16bits
323#define ARM_2D_M_COLOUR_SZ_32BIT 5 //!< true colour
324
325#define ARM_2D_M_COLOUR_SZ_1BIT_msk (ARM_2D_M_COLOUR_SZ_1BIT << 1) //!< bitmask for 1bit colour formats
326#define ARM_2D_M_COLOUR_SZ_2BIT_msk (ARM_2D_M_COLOUR_SZ_2BIT << 1) //!< bitmask for 2bit colour formats
327#define ARM_2D_M_COLOUR_SZ_4BIT_msk (ARM_2D_M_COLOUR_SZ_4BIT << 1) //!< bitmask for 4bit colour formats
328#define ARM_2D_M_COLOUR_SZ_8BIT_msk (ARM_2D_M_COLOUR_SZ_8BIT << 1) //!< bitmask for 8bit colour formats
329#define ARM_2D_M_COLOUR_SZ_16BIT_msk (ARM_2D_M_COLOUR_SZ_16BIT<< 1) //!< bitmask for 16bit colour formats
330#define ARM_2D_M_COLOUR_SZ_32BIT_msk (ARM_2D_M_COLOUR_SZ_32BIT<< 1) //!< bitmask for 32bit colour formats
331#define ARM_2D_M_COLOUR_SZ_msk (0x07 << 1), //!< bitmask for the SZ bitfield
332
333#define ARM_2D_M_COLOUR_LITTLE_ENDIAN 0 //!< pixels are stored in little endian
334#define ARM_2D_M_COLOUR_BIG_ENDIAN 1 //!< pixels are stored big endian
335
336#define ARM_2D_M_COLOUR_LITTLE_ENDIAN_msk (ARM_2D_M_COLOUR_LITTLE_ENDIAN << 4)//!< bitmask for little-endian
337#define ARM_2D_M_COLOUR_BIG_ENDIAN_msk (ARM_2D_M_COLOUR_BIG_ENDIAN << 4)//!< bitmask for big-endian
338
339#define ARM_2D_M_COLOUR_NO_ALPHA 0 //!< there is no alpha channel in each pixel
340#define ARM_2D_M_COLOUR_HAS_ALPHA 1 //!< there is an alpha channel in each pixel
341
342#define ARM_2D_M_COLOUR_NO_ALPHA_msk (ARM_2D_M_COLOUR_NO_ALPHA << 0) //!< bitmask for no-alpha-channel-in-pixel
343#define ARM_2D_M_COLOUR_HAS_ALPHA_msk (ARM_2D_M_COLOUR_HAS_ALPHA << 0) //!< bitmask for has-alpha-channel-in-pixel
344
345#define ARM_2D_M_COLOUR_VARIANT_pos 5 //!< offset for the VARIANT bitfield
346#define ARM_2D_M_COLOUR_VARIANT_msk (0x07<<ARM_2D_M_COLOUR_VARIANT_pos) //!< bitmask for the VARIANT bitfield
347
348/*!
349 * \brief enumerations for colour types
350 *
351 */
352enum {
353 ARM_2D_COLOUR_MONOCHROME = ARM_2D_COLOUR_SZ_1BIT_msk,
354 ARM_2D_COLOUR_BIN = ARM_2D_COLOUR_SZ_1BIT_msk,
355 ARM_2D_COLOUR_1BIT = ARM_2D_COLOUR_SZ_1BIT_msk,
356
357 ARM_2D_COLOUR_MASK_A2 = ARM_2D_M_COLOUR_SZ_2BIT_msk,
358 ARM_2D_COLOUR_MASK_A4 = ARM_2D_M_COLOUR_SZ_4BIT_msk,
359
360 ARM_2D_COLOUR_8BIT = ARM_2D_COLOUR_SZ_8BIT_msk,
361 ARM_2D_COLOUR_GRAY8 = ARM_2D_COLOUR_SZ_8BIT_msk,
362 ARM_2D_COLOUR_MASK_A8 = ARM_2D_COLOUR_SZ_8BIT_msk,
363
364 ARM_2D_COLOUR_16BIT = ARM_2D_COLOUR_SZ_16BIT_msk,
365 ARM_2D_COLOUR_RGB16 = ARM_2D_COLOUR_SZ_16BIT_msk,
366 ARM_2D_COLOUR_RGB565 = ARM_2D_COLOUR_RGB16,
367
368/* won't support
369 ARM_2D_COLOUR_RGB565_BE = ARM_2D_COLOUR_SZ_16BIT_msk |
370 ARM_2D_COLOUR_BIG_ENDIAN_msk ,
371 */
372
373 ARM_2D_COLOUR_32BIT = ARM_2D_COLOUR_SZ_32BIT_msk ,
374 ARM_2D_COLOUR_RGB32 = ARM_2D_COLOUR_SZ_32BIT_msk ,
375
376 ARM_2D_COLOUR_CCCN888 = ARM_2D_COLOUR_RGB32 ,
377 ARM_2D_COLOUR_CCCA8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
378 ARM_2D_COLOUR_HAS_ALPHA_msk ,
379
380 ARM_2D_COLOUR_RGB888 = ARM_2D_COLOUR_CCCN888 ,
381 ARM_2D_COLOUR_BGRA8888 = ARM_2D_COLOUR_CCCA8888 ,
382
383/* not supported yet
384 ARM_2D_COLOUR_NCCC888 = ARM_2D_COLOUR_RGB32 |
385 ARM_2D_COLOUR_BIG_ENDIAN_msk ,
386 ARM_2D_COLOUR_ACCC8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
387 ARM_2D_COLOUR_HAS_ALPHA_msk |
388 ARM_2D_COLOUR_BIG_ENDIAN_msk ,
389*/
390 ARM_2D_CHANNEL_8in32 = ARM_2D_COLOUR_SZ_32BIT_msk |
391 ARM_2D_COLOUR_HAS_ALPHA_msk |
392 ARM_2D_COLOUR_VARIANT_msk ,
393};
394
395/* macros for colour formats */
396#define ARM_2D_M_COLOUR_MONOCHROME ARM_2D_M_COLOUR_SZ_1BIT_msk //!< macro for the monochrome
397#define ARM_2D_M_COLOUR_BIN ARM_2D_M_COLOUR_SZ_1BIT_msk //!< macro for the 1bit colour format (alias)
398#define ARM_2D_M_COLOUR_1BIT ARM_2D_M_COLOUR_SZ_1BIT_msk //!< macro for the 1bin colour format (alias)
399
400#define ARM_2D_M_COLOUR_MASK_A2 ARM_2D_M_COLOUR_SZ_2BIT_msk //!< macro for the 2bit alpha mask
401#define ARM_2D_M_COLOUR_MASK_A4 ARM_2D_M_COLOUR_SZ_4BIT_msk //!< macro for the 4bit alpha mask
402
403#define ARM_2D_M_COLOUR_8BIT ARM_2D_M_COLOUR_SZ_8BIT_msk //!< macro for the generic 8bit colour formats
404#define ARM_2D_M_COLOUR_GRAY8 ARM_2D_M_COLOUR_SZ_8BIT_msk //!< macro for the gray8 colour format
405#define ARM_2D_M_COLOUR_MASK_A8 ARM_2D_M_COLOUR_SZ_8BIT_msk //!< macro for the 8bit alpha mask
406
407#define ARM_2D_M_COLOUR_16BIT ARM_2D_M_COLOUR_SZ_16BIT_msk //!< macro for the generic 16bit colour formats
408#define ARM_2D_M_COLOUR_RGB16 ARM_2D_M_COLOUR_SZ_16BIT_msk //!< macro for the generic 16bit colour formats
409#define ARM_2D_M_COLOUR_RGB565 ARM_2D_M_COLOUR_RGB16 //!< macro for the rgb565
410
411/* won't support
412#define ARM_2D_M_COLOUR_RGB565_BE ( ARM_2D_M_COLOUR_SZ_16BIT_msk \
413 | ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
414 */
415
416#define ARM_2D_M_COLOUR_32BIT ARM_2D_M_COLOUR_SZ_32BIT_msk //!< macro for the generic 32bit colour formats
417#define ARM_2D_M_COLOUR_RGB32 ARM_2D_M_COLOUR_SZ_32BIT_msk //!< macro for the generic 32bit colour formats
418
419#define ARM_2D_M_COLOUR_CCCN888 ARM_2D_M_COLOUR_RGB32 //!< macro for the generic 32bit colour formats with an reserved channel at the highest byte
420
421/*! macro for the generic 32bit colour formats with an alpha channel at the highest byte */
422#define ARM_2D_M_COLOUR_CCCA8888 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
423 | ARM_2D_M_COLOUR_HAS_ALPHA_msk)
424
425#define ARM_2D_M_COLOUR_RGB888 ARM_2D_M_COLOUR_CCCN888 //!< macro for the RGB888 (BGRN8888)
426#define ARM_2D_M_COLOUR_BGRAA8888 ARM_2D_M_COLOUR_CCCA8888 //!< macro for the BGRA8888
427
428/* not supported yet
429#define ARM_2D_M_COLOUR_NCCC888 ( ARM_2D_M_COLOUR_RGB32 \
430 | ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
431#define ARM_2D_M_COLOUR_ACCC8888 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
432 | ARM_2D_M_COLOUR_HAS_ALPHA_msk \
433 | ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
434*/
435/*! macro for a special colour format which access only one channel in RGB32 */
436#define ARM_2D_M_CHANNEL_8in32 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
437 | ARM_2D_M_COLOUR_HAS_ALPHA_msk) \
438 | ARM_2D_M_COLOUR_VARIANT_msk )
439
440/*!
441 * \brief a type used as colour descriptor
442 *
443 */
444typedef union {
445 struct {
446 uint8_t bHasAlpha : 1; //!< whether the target colour has alpha channel
447 uint8_t u3ColourSZ : 3; //!< the size of the colour
448 uint8_t bBigEndian : 1; //!< whether the colour is stored in big endian
449 uint8_t u3Variant : 3;
450 };
451 uint8_t chScheme;
453
454/*----------------------------------------------------------------------------*
455 * Tile and Regions *
456 *----------------------------------------------------------------------------*/
457
458/*!
459 * \brief a type for coordinates (integer)
460 *
461 */
462typedef struct arm_2d_location_t {
463 int16_t iX; //!< x in Cartesian coordinate system
464 int16_t iY; //!< y in Cartesian coordinate system
466
467/*!
468 * \brief a type for coordinates in floating point
469 *
470 */
471typedef struct arm_2d_point_float_t {
472 float fX; //!< x in Cartesian coordinate system
473 float fY; //!< y in Cartesian coordinate system
475
476/*!
477 * \brief a type for coordinates in fixed point
478 *
479 */
480typedef struct arm_2d_point_fx_t {
481 int32_t X; //!< x in Cartesian coordinate system
482 int32_t Y; //!< y in Cartesian coordinate system
484
485/*!
486 * \brief a type for the size of an rectangular area
487 *
488 */
489typedef struct arm_2d_size_t {
490 int16_t iWidth; //!< width of an rectangular area
491 int16_t iHeight; //!< height of an rectangular area
493
494/*!
495 * \brief a type for an rectangular area
496 *
497 */
498typedef struct arm_2d_region_t {
499 implement_ex(arm_2d_location_t, tLocation); //!< the location (top-left corner)
500 implement_ex(arm_2d_size_t, tSize); //!< the size
502
503/*!
504 * \brief a type for tile
505 *
506 */
507typedef struct arm_2d_tile_t arm_2d_tile_t;
509 implement_ex(struct {
510 uint8_t bIsRoot : 1; //!< is this tile a root tile
511 uint8_t bHasEnforcedColour : 1; //!< does this tile contains enforced colour info
512 uint8_t bDerivedResource : 1; //!< indicate whether this is a derived resources (when bIsRoot == 0)
513 uint8_t bVirtualResource : 1; //!< indicate whether the resource should be loaded on-demand
514 uint8_t : 4;
515 uint8_t : 8;
516 uint8_t : 8;
517 arm_2d_color_info_t tColourInfo; //!< enforced colour
518 }, tInfo);
519
520 implement_ex(arm_2d_region_t, tRegion); //!< the region of the tile
521
522 union {
523 /* when bIsRoot is true, phwBuffer is available,
524 * otherwise ptParent is available
525 */
526 arm_2d_tile_t *ptParent; //!< a pointer points to the parent tile
527 uint8_t *pchBuffer; //!< a pointer points to a buffer in a 8bit colour type
528 uint16_t *phwBuffer; //!< a pointer points to a buffer in a 16bit colour type
529 uint32_t *pwBuffer; //!< a pointer points to a buffer in a 32bit colour type
530
531 intptr_t nAddress; //!< a pointer in integer
532 };
533};
534
535/*!
536 * \brief the enumeration type for describing memory types
537 *
538 */
539typedef enum {
540 ARM_2D_MEM_TYPE_UNSPECIFIED, //!< normal memory, we don't know its characterisics
541 ARM_2D_MEM_TYPE_SLOW, //!< for slow memories, such as SDRAM, DDRAM, external memory etc
542 ARM_2D_MEM_TYPE_FAST, //!< for fast memories, such as TCM, SRAM etc.
544
545typedef union __arm_2d_mem_info_t {
546 struct {
547 uint32_t u24SizeInByte : 24; //!< the memory size in Byte
548 uint32_t u2ItemSize : 3; //!< the size of the data item
549 uint32_t u2Align : 3; //!< the alignment
550 uint32_t u2Type : 2; //!< The memory type define in enum arm_2d_mem_type_t
551 };
552 uint32_t Value; //!< Memory Information
554
555
556/*!
557 * \brief a type for scratch memory blocks
558 *
559 */
560typedef struct __arm_2d_mem_t __arm_2d_mem_t;
562 union {
563 __arm_2d_mem_t *ptNext; //!< a list pointer
564 uint32_t wSignature; //!< a signature for validation
565 };
566 __arm_2d_mem_info_t tInfo; //!< memory info
567 uint8_t pBuffer[]; //!< a constant pointer points to the buffer following this header
568};
569
570
571/*!
572 * \brief a type for virtual resource
573 *
574 * \note the flag tTile.tInfo.bVirtualResource must be true (1)
575 */
576typedef struct arm_2d_vres_t arm_2d_vres_t;
578
579 /*! base class: tTile */
581
582 /*! a reference of an user object */
583 uintptr_t pTarget;
584
585 /*!
586 * \brief a method to load a specific part of an image
587 * \param[in] pTarget a reference of an user object
588 * \param[in] ptVRES a reference of this virtual resource
589 * \param[in] ptRegion the target region of the image
590 * \return intptr_t the address of a resource buffer which holds the content
591 */
592 intptr_t (*Load) ( uintptr_t pTarget,
593 arm_2d_vres_t *ptVRES,
594 arm_2d_region_t *ptRegion);
595
596 /*!
597 * \brief a method to despose the buffer
598 * \param[in] pTarget a reference of an user object
599 * \param[in] ptVRES a reference of this virtual resource
600 * \param[in] pBuffer the target buffer
601 */
602 void (*Depose) ( uintptr_t pTarget,
603 arm_2d_vres_t *ptVRES,
604 intptr_t pBuffer );
605};
606
607/*----------------------------------------------------------------------------*
608 * Task *
609 *----------------------------------------------------------------------------*/
610
611/*!
612 * \brief arm-2d application level task control block
613 *
614 */
615typedef struct arm_2d_task_t {
616ARM_PRIVATE(
617 arm_fsm_rt_t tResult; //!< the temporary result of the task
618 uint8_t chState; //!< the state of the FSM
619
620 void *ptTask; //!< a pointer for an internal object
623
624/*----------------------------------------------------------------------------*
625 * Operation and Events Handling *
626 *----------------------------------------------------------------------------*/
627
628
630
631/*!
632 * \brief a prototype of event handlers for 2D operations
633 *
634 * \param[in] ptThisOP the target 2D operation descriptor
635 * \param[in] tResult the operation result
636 * \param[in] pTarget A user attached object
637 * \return bool a boolean value to indicate whether the event has been handled
638 */
640 arm_fsm_rt_t tResult,
641 void *pTarget);
642
643/*!
644 * \brief a type for 2D operation event handling
645 *
646 */
647typedef struct arm_2d_op_evt_t {
649 void *pTarget; //!< user attached target
651
652/*!
653 * \brief a prototype for generic event handlers
654 *
655 * \param pTarget A user attached object
656 * \return bool a boolean value to indicate whether the event has been handled
657 */
658typedef bool arm_2d_evt_handler_t(void *pTarget);
659
660/*!
661 * \brief a type for generic event handling
662 *
663 */
664typedef struct arm_2d_evt_t {
665 arm_2d_evt_handler_t *fnHandler; //!< event handler
666 void *pTarget; //!< user attached target
668
669
670#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE _BV(0) //!< opcode has source tile info
671#define ARM_2D_OP_INFO_PARAM_HAS_TARGET _BV(1) //!< opcode has target tile info
672#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK _BV(2) //!< opcode has source mask info
673#define ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK _BV(3) //!< opcode has target mask info
674#define ARM_2D_OP_INFO_PARAM_HAS_ORIGIN _BV(4) //!< opcode has original tile info
675
676/*! a bitmask for INFO_PARAM_HAS_xxxx bitfields */
677#define ARM_2D_OP_INFO_PARAM_TILES_MASK ( \
678 ARM_2D_OP_INFO_PARAM_HAS_SOURCE | \
679 ARM_2D_OP_INFO_PARAM_HAS_TARGET | \
680 ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK | \
681 ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK | \
682 ARM_2D_OP_INFO_PARAM_HAS_ORIGIN )
683
684
685//! \brief an incomplete defintion which is only used for defining pointers
687
688/*!
689 * \brief A descriptive header for 2D operations
690 */
691typedef union __arm_2d_op_info_t {
692 struct {
693 arm_2d_color_info_t Colour; //!< the colour used in thie operation
694 union {
695 struct {
696 uint8_t bHasSource : 1; //!< whether this operation contains source tile
697 uint8_t bHasTarget : 1; //!< whether this operation contains target tile
698 uint8_t bHasSrcMask : 1; //!< whether this operation has Mask layer for source tile
699 uint8_t bHasDesMask : 1; //!< whether this operation has Mask layer for target tile
700 uint8_t bHasOrigin : 1; //!< whether the Source has an origin tile
701 uint8_t : 2;
702 uint8_t bAllowEnforcedColour : 1; //!< whether this operation allow enforced colours in tiles
703 };
704 uint8_t chValue; //!< feature value
705 }Param; //!< operation feature set
706
707 uint8_t chInClassOffset; //!< some operation uses this as the offset of the key member in the class
708 uint8_t chOpIndex; //!< __ARM_2D_OP_IDX_XXXXXX
709
710 union {
711 struct {
712 uint8_t CopyLike; //!< A copy-like interface contains the target tile, the source tile and the copy size
713 uint8_t FillLike; //!< A copy-like interface contains the target tile and the source tile
714 };
715 struct {
716 uint8_t CopyOrigLike; //!< A copy-like interface contains the target tile, the dummy tile, the reference to the original source tile and the copy size
717 uint8_t FillOrigLike; //!< A copy-like interface contains the target tile, the dummy tile and the reference to the original source tile
718 };
719 struct {
720 uint8_t TileProcessLike; //!< A simple interface contains only the target tile
721 };
722 }LowLevelInterfaceIndex; //!< Low level interface index
723
724 union {
725 const __arm_2d_low_level_io_t *IO[2]; //!< array of IOs
726
727 struct {
728 const __arm_2d_low_level_io_t *ptCopyLike; //!< the function pointer for a copy-like implementation
729 const __arm_2d_low_level_io_t *ptFillLike; //!< the function pointer for a fill-like implementation
730 };
731 struct {
732 const __arm_2d_low_level_io_t *ptCopyOrigLike; //!< the function pointer for a copy-orig-like implementation
733 const __arm_2d_low_level_io_t *ptFillOrigLike; //!< the function pointer for a fill-orig-like implementation
734 };
735 struct {
736 const __arm_2d_low_level_io_t *ptTileProcessLike; //!< the function pointer for the tile-process-like implementation
737 };
738 }LowLevelIO; //!< low level IO definition
739
740 }Info; //!< operation description
741 uint32_t wID; //!< Operation ID
743
744/*!
745 * \brief how would you want to accelerate the 2d-operation
746 */
747enum {
748 //! Use hardware acceleration if possible, even if there is a long queue to wait
750
751 //! Only use Hardware Acceleration, if it is not supported, IO error will be issued
753
754 //! Only use software algorithm
756
757 //!< don't care, let the arm-2d library decide
758 ARM_2D_PREF_ACC_DONT_CARE = 3,
759};
760
761#define __ARM_2D_OP_STATUS_BUSY_msk (1 << 4) //!< bitmask for the busy flag
762#define __ARM_2D_OP_STATUS_IO_ERROR_msk (1 << 5) //!< bitmask for the IO error flag
763#define __ARM_2D_OP_STATUS_CPL_msk (1 << 6) //!< bitmask for the complete flag
764
765/*!
766 * \brief a type for 2D operation status
767 *
768 */
769typedef union arm_2d_op_status_t {
770 struct {
771 uint16_t u4SubTaskCount : 4; //!< sub task count
772 uint16_t bIsBusy : 1; //!< busy flag
773 uint16_t bIOError : 1; //!< HW IO Error
774 uint16_t bOpCpl : 1; //!< the whole operation complete
775 uint16_t : 9; //!< reserved
776 };
777 uint16_t tValue; //!< the host integer
779
780/*!
781 * \brief the abstract class of 2D operations
782 *
783 */
785ARM_PRIVATE(
786 arm_2d_op_core_t *ptNext; //!< a pointer for a single list
787
788 const __arm_2d_op_info_t *ptOp; //!< the pointer for the corresponding 2D operation description
789
790 struct {
791 uint8_t u2ACCMethods : 2; //!< acceleration Methods
792 uint8_t : 6; //!< reserved
793 }Preference;
794
795 int8_t tResult; //!< operation result
796 volatile arm_2d_op_status_t Status; //!< operation status
797
798 arm_2d_op_evt_t evt2DOpCpl; //!< operation-complete event
799
801 uintptr_t pUserParam; //!< user attached object
802};
803
804/*!
805 * \brief the base class for operations with only a target tile
806 * \note arm_2d_op_msk_t inherits from arm_2d_op_core_t
807 */
808typedef struct arm_2d_op_t {
810 struct {
811 const arm_2d_tile_t *ptTile; //!< target tile
812 const arm_2d_region_t *ptRegion; //!< target region
813 } Target;
815
816/*!
817 * \brief the base class for operations with a target tile and a target mask
818 * \note arm_2d_op_msk_t inherits from arm_2d_op_t
819 */
820typedef struct arm_2d_op_msk_t {
822 struct {
823 const arm_2d_tile_t *ptTile; //!< target tile
824 const arm_2d_region_t *ptRegion; //!< target region
825 } Target;
826
827 /* derived part */
828 struct {
829 const arm_2d_tile_t *ptTile; //!< target tile
830 } Mask;
832
833/*!
834 * \brief the base class for operations with a target tile and a source tile
835 * \note arm_2d_op_src_t inherits from arm_2d_op_t
836 */
837typedef struct arm_2d_op_src_t {
839 struct {
840 const arm_2d_tile_t *ptTile; //!< target tile
841 const arm_2d_region_t *ptRegion; //!< target region
842 } Target;
843
844 /* derived part */
845 struct {
846 const arm_2d_tile_t *ptTile; //!< source tile
847 }Source;
848 uint32_t wMode;
850
851/*!
852 * \brief the base class for operations with a target tile, a source tile and masks
853 * \note arm_2d_op_src_msk_t inherits from arm_2d_op_src_t
854 */
855typedef struct arm_2d_op_src_msk_t {
857 struct {
858 const arm_2d_tile_t *ptTile; //!< target tile
859 const arm_2d_region_t *ptRegion; //!< target region
860 } Target;
861 struct {
862 const arm_2d_tile_t *ptTile; //!< source tile
863 }Source;
864 uint32_t wMode;
865
866 /* derived part */
867 struct {
868 const arm_2d_tile_t *ptSourceSide; //!< source side mask
869 const arm_2d_tile_t *ptTargetSide; //!< target side mask
870 } Mask;
872
873/*!
874 * \brief the base class for operations with a target tile, a dummy tile and a reference to the original source tile
875 * \note arm_2d_op_src_orig_t inherits from arm_2d_op_src_t
876 */
877typedef struct arm_2d_op_src_orig_t {
879 struct {
880 const arm_2d_tile_t *ptTile; //!< target tile
881 const arm_2d_region_t *ptRegion; //!< target region
882 } Target;
883 struct {
884 const arm_2d_tile_t *ptTile; //!< the dummy source tile
885 }Source;
886 uint32_t wMode;
887
888 /* derived part */
889 struct {
890 const arm_2d_tile_t *ptTile; //!< the origin tile
891 arm_2d_tile_t tDummySource; //!< the buffer for the source
892 }Origin;
893
895
896/*!
897 * \brief the base class for operations with a target tile, a dummy tile, a reference to the original source tile and masks
898 * \note arm_2d_op_src_orig_msk_t inherits from arm_2d_op_src_orig_t
899 */
902 struct {
903 const arm_2d_tile_t *ptTile; //!< target tile
904 const arm_2d_region_t *ptRegion; //!< target region
905 } Target;
906 struct {
907 const arm_2d_tile_t *ptTile; //!< the dummy source tile
908 }Source;
909 uint32_t wMode;
910 struct {
911 const arm_2d_tile_t *ptTile; //!< the origin tile
912 arm_2d_tile_t tDummySource; //!< the buffer for the source
913 }Origin;
914
915 /* derived part */
916 struct {
917 const arm_2d_tile_t *ptOriginSide; //!< origin side mask
918 const arm_2d_tile_t *ptTargetSide; //!< target side mask
919 } Mask;
921
922
923/*----------------------------------------------------------------------------*
924 * Fast Rotation linear regression structure
925 *----------------------------------------------------------------------------*/
926
927#if (__ARM_2D_HAS_HELIUM_FLOAT__ || __ARM_2D_HAS_FPU__) \
928 && !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
929/*!
930 * \brief a type for parameters of linear interpolation (in floating point)
931 *
932 */
933typedef struct arm_2d_rot_linear_regr_t {
934 float slopeY;
935 float interceptY;
936 float slopeX;
937 float interceptX;
939
940#else
941/*!
942 * \brief a type for parameters of linear interpolation (in fixed point)
943 *
944 */
946 int32_t slopeY;
947 int32_t interceptY;
948 int32_t slopeX;
949 int32_t interceptX;
951
952#endif
953
954/*============================ GLOBAL VARIABLES ==============================*/
955/*============================ PROTOTYPES ====================================*/
956
957/*! @} */
958
959#if defined(__clang__)
960#pragma clang diagnostic pop
961#elif __IS_COMPILER_ARM_COMPILER_5__
962#pragma diag_warning 64
963#elif __IS_COMPILER_GCC__
964#pragma GCC diagnostic pop
965#endif
966
967#ifdef __cplusplus
968}
969#endif
970
971#endif // __ARM_2D_TYPES_H__
972
973