2D Image Processing Library for Cortex-M Processors
All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
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: cmsis_nn_typs.h
22 * Description: Public header file to contain the Arm-2D structs
23 *
24 * $Date: 12. July 2022
25 * $Revision: V.1.0.1
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/*============================ MACROS ========================================*/
65/*============================ MACROFIED FUNCTIONS ===========================*/
66/*============================ TYPES =========================================*/
67
68
69/*----------------------------------------------------------------------------*
70 * Infrastructure *
71 *----------------------------------------------------------------------------*/
72
73/*!
74 * \brief finite-state-machine status return (Compatible with arm_status, minimal integer: int8_t)
75 *
76 */
77typedef enum {
78 arm_fsm_rt_err = -1, //!< fsm error
79 arm_fsm_rt_cpl = 0, //!< fsm complete
80 arm_fsm_rt_on_going = 1, //!< fsm on-going
81 arm_fsm_rt_wait_for_obj = 2, //!< fsm wait for IPC object
82 arm_fsm_rt_async = 3, //!< fsm work asynchronously, please check it later.
83 arm_fsm_rt_wait_for_res = 4, //!< wait for resource
84} arm_fsm_rt_t;
85
86/*!
87 * \brief the error code for arm-2d (minimal integer: int8_t)
88 *
89 */
90typedef enum {
91 ARM_2D_ERR_UNSUPPORTED_COLOUR = -11, //!< the specified colour is not supported
92 ARM_2D_ERR_BUSY = -10, //!< service is busy
93 ARM_2D_ERR_INSUFFICIENT_RESOURCE = -9, //!< insufficient resource
94 ARM_2D_ERR_IO_BUSY = -8, //!< HW accelerator is busy
95 ARM_2D_ERR_IO_ERROR = -7, //!< Generic HW error
96 ARM_2D_ERR_MISSING_PARAM = -6, //!< missing mandatory parameter
97 ARM_2D_ERR_INVALID_OP = -5, //!< unsupported / invalid operation
98 ARM_2D_ERR_NOT_SUPPORT = -4, //!< feature/service/operation is not supported
99 ARM_2D_ERR_OUT_OF_REGION = -3, //!< the operation is out of target area
100 ARM_2D_ERR_INVALID_PARAM = -2, //!< invalid parameter
101 ARM_2D_ERR_UNKNOWN = -1, //!< generic or unknown errors
102 ARM_2D_ERR_NONE = 0, //!< no error
103} arm_2d_err_t;
104
105/*!
106 * \brief comparison result
107 *
108 */
109typedef enum {
110 ARM_2D_CMP_SMALLER = -1, //!< the target is smaller than the reference
111 ARM_2D_CMP_EQUALS = 0, //!< the target is equal to the reference
112 ARM_2D_CMP_LARGER = 1, //!< the target is larger than the reference
113} arm_2d_cmp_t;
114
115/*----------------------------------------------------------------------------*
116 * Colour definitions *
117 *----------------------------------------------------------------------------*/
118
119/*!
120 * \brief the colour type for gray8 (8bit gray scale)
121 *
122 */
123typedef union arm_2d_color_gray8_t {
124 uint8_t tValue;
126
127/*!
128 * \brief the colour type for rgb565
129 *
130 */
132 uint16_t tValue;
133 struct {
134 uint16_t u5B : 5;
135 uint16_t u6G : 6;
136 uint16_t u5R : 5;
137 };
139
140/*!
141 * \brief the colour type for brga8888
142 *
143 * \details In most cases four equal-sized pieces of adjacent memory are used,
144 * one for each channel, and a 0 in a channel indicates black color or
145 * transparent alpha, while all-1 bits indicates white or fully opaque
146 * alpha. By far the most common format is to store 8 bits (one byte)
147 * for each channel, which is 32 bits for each pixel.
148 *
149 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
150 */
152 uint32_t tValue;
153 struct {
154 uint32_t u8B : 8;
155 uint32_t u8G : 8;
156 uint32_t u8R : 8;
157 uint32_t u8A : 8;
158 };
160
161/*!
162 * \brief the colour type for rgb888 (compliant with ccca888 and bgra8888)
163 *
164 * \details In most cases four equal-sized pieces of adjacent memory are used,
165 * one for each channel, and a 0 in a channel indicates black color or
166 * transparent alpha, while all-1 bits indicates white or fully opaque
167 * alpha. By far the most common format is to store 8 bits (one byte)
168 * for each channel, which is 32 bits for each pixel.
169 *
170 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
171 */
173 uint32_t tValue;
174 struct {
175 uint32_t u8B : 8;
176 uint32_t u8G : 8;
177 uint32_t u8R : 8;
178 uint32_t : 8;
179 };
181
182/*!
183 * \brief the colour type for any 32bit colour formats which has an alpha channel on its 3rd byte.
184 *
185 * \details In most cases four equal-sized pieces of adjacent memory are used,
186 * one for each channel, and a 0 in a channel indicates black color or
187 * transparent alpha, while all-1 bits indicates white or fully opaque
188 * alpha. By far the most common format is to store 8 bits (one byte)
189 * for each channel, which is 32 bits for each pixel.
190 *
191 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
192 */
194 uint32_t tValue;
195 struct {
196 uint8_t u8C[3];
197 uint8_t u8A;
198 };
200
201/*!
202 * \brief the colour type for any 32bit colour formats which has an alpha channel on its first byte.
203 *
204 * \details In most cases four equal-sized pieces of adjacent memory are used,
205 * one for each channel, and a 0 in a channel indicates black color or
206 * transparent alpha, while all-1 bits indicates white or fully opaque
207 * alpha. By far the most common format is to store 8 bits (one byte)
208 * for each channel, which is 32 bits for each pixel.
209 *
210 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
211 */
213 uint32_t tValue;
214 struct {
215 uint8_t u8A;
216 uint8_t u8C[3];
217 };
219
220/*!
221 * \brief the colour type for any 32bit colour formats which has an unused-alpha channel on its 3rd byte.
222 *
223 * \details In most cases four equal-sized pieces of adjacent memory are used,
224 * one for each channel, and a 0 in a channel indicates black color or
225 * transparent alpha, while all-1 bits indicates white or fully opaque
226 * alpha. By far the most common format is to store 8 bits (one byte)
227 * for each channel, which is 32 bits for each pixel.
228 *
229 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
230 */
232 uint32_t tValue;
233 struct {
234 uint8_t u8C[3];
235 uint8_t : 8;
236 };
238
239/*!
240 * \brief the colour type for any 32bit colour formats which has an unused-alpha channel on its first byte.
241 *
242 * \details In most cases four equal-sized pieces of adjacent memory are used,
243 * one for each channel, and a 0 in a channel indicates black color or
244 * transparent alpha, while all-1 bits indicates white or fully opaque
245 * alpha. By far the most common format is to store 8 bits (one byte)
246 * for each channel, which is 32 bits for each pixel.
247 *
248 * (source: https://en.wikipedia.org/wiki/RGBA_color_model#ARGB32)
249 */
251 uint32_t tValue;
252 struct {
253 uint8_t : 8;
254 uint8_t u8C[3];
255 };
257
258/*!
259 * \brief enumerations for colour attributes
260 */
261enum {
262 ARM_2D_COLOUR_SZ_1BIT = 0, //!< 1 bit:black and white
263 ARM_2D_COLOUR_SZ_2BIT = 1, //!< 4 colours or 4 gray-levels
264 ARM_2D_COLOUR_SZ_4BIT = 2, //!< 16 colours or 16 gray-levels
265 ARM_2D_COLOUR_SZ_8BIT = 3, //!< 256 colours
266 ARM_2D_COLOUR_SZ_16BIT = 4, //!< 16bits
267 ARM_2D_COLOUR_SZ_32BIT = 5, //!< true colour
268
269 ARM_2D_COLOUR_SZ_1BIT_msk = ARM_2D_COLOUR_SZ_1BIT << 1,
270 ARM_2D_COLOUR_SZ_2BIT_msk = ARM_2D_COLOUR_SZ_2BIT << 1,
271 ARM_2D_COLOUR_SZ_4BIT_msk = ARM_2D_COLOUR_SZ_4BIT << 1,
272 ARM_2D_COLOUR_SZ_8BIT_msk = ARM_2D_COLOUR_SZ_8BIT << 1,
273 ARM_2D_COLOUR_SZ_16BIT_msk = ARM_2D_COLOUR_SZ_16BIT<< 1,
274 ARM_2D_COLOUR_SZ_32BIT_msk = ARM_2D_COLOUR_SZ_32BIT<< 1,
275 ARM_2D_COLOUR_SZ_msk = (0x07 << 1),
276
277 ARM_2D_COLOUR_LITTLE_ENDIAN = 0,
278 ARM_2D_COLOUR_BIG_ENDIAN = 1,
279
280 ARM_2D_COLOUR_LITTLE_ENDIAN_msk = ARM_2D_COLOUR_LITTLE_ENDIAN << 4,
281 ARM_2D_COLOUR_BIG_ENDIAN_msk = ARM_2D_COLOUR_BIG_ENDIAN << 4,
282
283 ARM_2D_COLOUR_NO_ALPHA = 0,
284 ARM_2D_COLOUR_HAS_ALPHA = 1,
285
286 ARM_2D_COLOUR_NO_ALPHA_msk = ARM_2D_COLOUR_NO_ALPHA << 0,
287 ARM_2D_COLOUR_HAS_ALPHA_msk = ARM_2D_COLOUR_HAS_ALPHA << 0,
288
289 ARM_2D_COLOUR_VARIANT_pos = 5,
290 ARM_2D_COLOUR_VARIANT_msk = 0x07 << ARM_2D_COLOUR_VARIANT_pos,
291};
292
293/* macros for colour attributes */
294#define ARM_2D_M_COLOUR_SZ_1BIT 0 //!< 1 bit:black and white
295#define ARM_2D_M_COLOUR_SZ_2BIT 1 //!< 4 colours or 4 gray-levels
296#define ARM_2D_M_COLOUR_SZ_4BIT 2 //!< 16 colours or 16 gray-levels
297#define ARM_2D_M_COLOUR_SZ_8BIT 3 //!< 256 colours
298#define ARM_2D_M_COLOUR_SZ_16BIT 4 //!< 16bits
299#define ARM_2D_M_COLOUR_SZ_32BIT 5 //!< true colour
300
301#define ARM_2D_M_COLOUR_SZ_1BIT_msk (ARM_2D_M_COLOUR_SZ_1BIT << 1)
302#define ARM_2D_M_COLOUR_SZ_2BIT_msk (ARM_2D_M_COLOUR_SZ_2BIT << 1)
303#define ARM_2D_M_COLOUR_SZ_4BIT_msk (ARM_2D_M_COLOUR_SZ_4BIT << 1)
304#define ARM_2D_M_COLOUR_SZ_8BIT_msk (ARM_2D_M_COLOUR_SZ_8BIT << 1)
305#define ARM_2D_M_COLOUR_SZ_16BIT_msk (ARM_2D_M_COLOUR_SZ_16BIT<< 1)
306#define ARM_2D_M_COLOUR_SZ_32BIT_msk (ARM_2D_M_COLOUR_SZ_32BIT<< 1)
307#define ARM_2D_M_COLOUR_SZ_msk (0x07 << 1),
308
309#define ARM_2D_M_COLOUR_LITTLE_ENDIAN 0
310#define ARM_2D_M_COLOUR_BIG_ENDIAN 1
311
312#define ARM_2D_M_COLOUR_LITTLE_ENDIAN_msk (ARM_2D_M_COLOUR_LITTLE_ENDIAN << 4)
313#define ARM_2D_M_COLOUR_BIG_ENDIAN_msk (ARM_2D_M_COLOUR_BIG_ENDIAN << 4)
314
315#define ARM_2D_M_COLOUR_NO_ALPHA 0
316#define ARM_2D_M_COLOUR_HAS_ALPHA 1
317
318#define ARM_2D_M_COLOUR_NO_ALPHA_msk (ARM_2D_M_COLOUR_NO_ALPHA << 0)
319#define ARM_2D_M_COLOUR_HAS_ALPHA_msk (ARM_2D_M_COLOUR_HAS_ALPHA << 0)
320
321#define ARM_2D_M_COLOUR_VARIANT_pos 5
322#define ARM_2D_M_COLOUR_VARIANT_msk (0x07 << ARM_2D_M_COLOUR_VARIANT_pos)
323
324/*!
325 * \brief enumerations for colour types
326 *
327 */
328enum {
329 ARM_2D_COLOUR_BIN = ARM_2D_COLOUR_SZ_1BIT_msk,
330 ARM_2D_COLOUR_1BIT = ARM_2D_COLOUR_SZ_1BIT_msk,
331
332 ARM_2D_COLOUR_8BIT = ARM_2D_COLOUR_SZ_8BIT_msk,
333 ARM_2D_COLOUR_GRAY8 = ARM_2D_COLOUR_SZ_8BIT_msk,
334
335 ARM_2D_COLOUR_16BIT = ARM_2D_COLOUR_SZ_16BIT_msk,
336 ARM_2D_COLOUR_RGB16 = ARM_2D_COLOUR_SZ_16BIT_msk,
337 ARM_2D_COLOUR_RGB565 = ARM_2D_COLOUR_RGB16,
338
339/* won't support
340 ARM_2D_COLOUR_RGB565_BE = ARM_2D_COLOUR_SZ_16BIT_msk |
341 ARM_2D_COLOUR_BIG_ENDIAN_msk ,
342 */
343
344 ARM_2D_COLOUR_32BIT = ARM_2D_COLOUR_SZ_32BIT_msk ,
345 ARM_2D_COLOUR_RGB32 = ARM_2D_COLOUR_SZ_32BIT_msk ,
346
347 ARM_2D_COLOUR_CCCN888 = ARM_2D_COLOUR_RGB32 ,
348 ARM_2D_COLOUR_CCCA8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
349 ARM_2D_COLOUR_HAS_ALPHA_msk ,
350
351 ARM_2D_COLOUR_RGB888 = ARM_2D_COLOUR_CCCN888 ,
352 ARM_2D_COLOUR_BGRA8888 = ARM_2D_COLOUR_CCCA8888 ,
353
354/* not supported yet
355 ARM_2D_COLOUR_NCCC888 = ARM_2D_COLOUR_RGB32 |
356 ARM_2D_COLOUR_BIG_ENDIAN_msk ,
357 ARM_2D_COLOUR_ACCC8888 = ARM_2D_COLOUR_SZ_32BIT_msk |
358 ARM_2D_COLOUR_HAS_ALPHA_msk |
359 ARM_2D_COLOUR_BIG_ENDIAN_msk ,
360*/
361 ARM_2D_CHANNEL_8in32 = ARM_2D_COLOUR_SZ_32BIT_msk |
362 ARM_2D_COLOUR_HAS_ALPHA_msk |
363 ARM_2D_COLOUR_VARIANT_msk ,
364};
365
366/* macros for colour formats */
367#define ARM_2D_M_COLOUR_BIN ARM_2D_M_COLOUR_SZ_1BIT_msk
368#define ARM_2D_M_COLOUR_1BIT ARM_2D_M_COLOUR_SZ_1BIT_msk
369
370#define ARM_2D_M_COLOUR_8BIT ARM_2D_M_COLOUR_SZ_8BIT_msk
371#define ARM_2D_M_COLOUR_GRAY8 ARM_2D_M_COLOUR_SZ_8BIT_msk
372
373#define ARM_2D_M_COLOUR_16BIT ARM_2D_M_COLOUR_SZ_16BIT_msk
374#define ARM_2D_M_COLOUR_RGB16 ARM_2D_M_COLOUR_SZ_16BIT_msk
375#define ARM_2D_M_COLOUR_RGB565 ARM_2D_M_COLOUR_RGB16
376
377/* won't support
378#define ARM_2D_M_COLOUR_RGB565_BE ( ARM_2D_M_COLOUR_SZ_16BIT_msk \
379 | ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
380 */
381
382#define ARM_2D_M_COLOUR_32BIT ARM_2D_M_COLOUR_SZ_32BIT_msk
383#define ARM_2D_M_COLOUR_RGB32 ARM_2D_M_COLOUR_SZ_32BIT_msk
384
385#define ARM_2D_M_COLOUR_CCCN888 ARM_2D_M_COLOUR_RGB32
386#define ARM_2D_M_COLOUR_CCCA8888 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
387 | ARM_2D_M_COLOUR_HAS_ALPHA_msk)
388
389#define ARM_2D_M_COLOUR_RGB888 ARM_2D_M_COLOUR_CCCN888
390#define ARM_2D_M_COLOUR_RGBA8888 ARM_2D_M_COLOUR_CCCA8888
391
392/* not supported yet
393#define ARM_2D_M_COLOUR_NCCC888 ( ARM_2D_M_COLOUR_RGB32 \
394 | ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
395#define ARM_2D_M_COLOUR_ACCC8888 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
396 | ARM_2D_M_COLOUR_HAS_ALPHA_msk \
397 | ARM_2D_M_COLOUR_BIG_ENDIAN_msk )
398*/
399#define ARM_2D_M_CHANNEL_8in32 ( ARM_2D_M_COLOUR_SZ_32BIT_msk \
400 | ARM_2D_M_COLOUR_HAS_ALPHA_msk) \
401 | ARM_2D_M_COLOUR_VARIANT_msk )
402
403/*!
404 * \brief a type used as colour descriptor
405 *
406 */
407typedef union {
408 struct {
409 uint8_t bHasAlpha : 1; //!< whether the target colour has alpha channel
410 uint8_t u3ColourSZ : 3; //!< the size of the colour
411 uint8_t bBigEndian : 1; //!< whether the colour is stored in big endian
412 uint8_t u3Variant : 3;
413 };
414 uint8_t chScheme;
416
417/*----------------------------------------------------------------------------*
418 * Tile and Regions *
419 *----------------------------------------------------------------------------*/
420
421/*!
422 * \brief a type for coordinates (integer)
423 *
424 */
425typedef struct arm_2d_location_t {
426 int16_t iX; //!< x in Cartesian coordinate system
427 int16_t iY; //!< y in Cartesian coordinate system
429
430/*!
431 * \brief a type for coordinates in floating point
432 *
433 */
434typedef struct arm_2d_point_float_t {
435 float fX; //!< x in Cartesian coordinate system
436 float fY; //!< y in Cartesian coordinate system
438
439/*!
440 * \brief a type for coordinates in fixed point
441 *
442 */
443typedef struct arm_2d_point_fx_t {
444 int32_t X; //!< x in Cartesian coordinate system
445 int32_t Y; //!< y in Cartesian coordinate system
447
448/*!
449 * \brief a type for the size of an rectangular area
450 *
451 */
452typedef struct arm_2d_size_t {
453 int16_t iWidth; //!< width of an rectangular area
454 int16_t iHeight; //!< height of an rectangular area
456
457/*!
458 * \brief a type for an rectangular area
459 *
460 */
461typedef struct arm_2d_region_t {
462 implement_ex(arm_2d_location_t, tLocation); //!< the location (top-left corner)
463 implement_ex(arm_2d_size_t, tSize); //!< the size
465
466/*!
467 * \brief a type for tile
468 *
469 */
470typedef struct arm_2d_tile_t arm_2d_tile_t;
472 implement_ex(struct {
473 uint8_t bIsRoot : 1; //!< is this tile a root tile
474 uint8_t bHasEnforcedColour : 1; //!< does this tile contains enforced colour info
475 uint8_t bDerivedResource : 1; //!< indicate whether this is a derived resources (when bIsRoot == 0)
476 uint8_t : 5;
477 uint8_t : 8;
478 uint8_t : 8;
479 arm_2d_color_info_t tColourInfo; //!< enforced colour
480 }, tInfo);
481
482 implement_ex(arm_2d_region_t, tRegion); //!< the region of the tile
483
484 union {
485 /*! when bIsRoot is true, phwBuffer is available,
486 *! otherwise ptParent is available
487 */
488 arm_2d_tile_t *ptParent; //!< a pointer points to the parent tile
489 uint8_t *pchBuffer; //!< a pointer points to a buffer in a 8bit colour type
490 uint16_t *phwBuffer; //!< a pointer points to a buffer in a 16bit colour type
491 uint32_t *pwBuffer; //!< a pointer points to a buffer in a 32bit colour type
492
493 intptr_t nAddress; //!< a pointer in integer
494 };
495};
496
497/*----------------------------------------------------------------------------*
498 * Task *
499 *----------------------------------------------------------------------------*/
500
501/*!
502 * \brief arm-2d application level task control block
503 *
504 */
505typedef struct arm_2d_task_t {
506ARM_PRIVATE(
507 arm_fsm_rt_t tResult; //!< the temporary result of the task
508 uint8_t chState; //!< the state of the FSM
509
510 void *ptTask; //!< a pointer for an internal object
513
514/*----------------------------------------------------------------------------*
515 * Operation and Events Handling *
516 *----------------------------------------------------------------------------*/
517
518
520
521/*!
522 * \brief a prototype of event handlers for 2D operations
523 *
524 * \param[in] ptThisOP the target 2D operation descriptor
525 * \param[in] tResult the operation result
526 * \param[in] pTarget A user attached object
527 * \return bool a boolean value to indicate whether the event has been handled
528 */
529typedef bool arm_2d_op_evt_handler_t( arm_2d_op_core_t *ptThisOP,
530 arm_fsm_rt_t tResult,
531 void *pTarget);
532
533/*!
534 * \brief a type for 2D operation event handling
535 *
536 */
537typedef struct arm_2d_op_evt_t {
538 arm_2d_op_evt_handler_t *fnHandler; //!< event handler
539 void *pTarget; //!< user attached target
541
542/*!
543 * \brief a prototype for generic event handlers
544 *
545 * \param pTarget A user attached object
546 * \return bool a boolean value to indicate whether the event has been handled
547 */
548typedef bool arm_2d_evt_handler_t(void *pTarget);
549
550/*!
551 * \brief a type for generic event handling
552 *
553 */
554typedef struct arm_2d_evt_t {
555 arm_2d_evt_handler_t *fnHandler; //!< event handler
556 void *pTarget; //!< user attached target
558
559
560#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE _BV(0)
561#define ARM_2D_OP_INFO_PARAM_HAS_TARGET _BV(1)
562#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK _BV(2)
563#define ARM_2D_OP_INFO_PARAM_HAS_TARGET_MASK _BV(3)
564#define ARM_2D_OP_INFO_PARAM_HAS_ORIGIN _BV(4)
565
566//! \brief an incomplete defintion which is only used for defining pointers
567typedef struct __arm_2d_low_level_io_t __arm_2d_low_level_io_t;
568
569/*!
570 * \brief A descriptive header for 2D operations
571 */
572typedef union __arm_2d_op_info_t {
573 struct {
574 arm_2d_color_info_t Colour; //!< the colour used in thie operation
575 union {
576 struct {
577 uint8_t bHasSource : 1; //!< whether this operation contains source tile
578 uint8_t bHasTarget : 1; //!< whether this operation contains target tile
579 uint8_t bHasSrcMask : 1; //!< whether this operation has Mask layer for source tile
580 uint8_t bHasDesMask : 1; //!< whether this operation has Mask layer for target tile
581 uint8_t bHasOrigin : 1; //!< whether the Source has an origin tile
582 uint8_t : 2;
583 uint8_t bAllowEnforcedColour : 1; //!< whether this operation allow enforced colours in tiles
584 };
585 uint8_t chValue;
586 }Param;
587
588 uint8_t chInClassOffset; //!< some operation uses this as the offset of the key member in the class
589 uint8_t chOpIndex; //!< __ARM_2D_OP_IDX_XXXXXX
590
591 union {
592 struct {
593 uint8_t CopyLike; //!< A copy-like interface contains the target tile, the source tile and the copy size
594 uint8_t FillLike; //!< A copy-like interface contains the target tile and the source tile
595 };
596 struct {
597 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
598 uint8_t FillOrigLike; //!< A copy-like interface contains the target tile, the dummy tile and the reference to the original source tile
599 };
600 struct {
601 uint8_t TileProcessLike; //!< A simple interface contains only the target tile
602 };
603 }LowLevelInterfaceIndex;
604
605 union {
606 const __arm_2d_low_level_io_t *IO[2];
607
608 struct {
609 const __arm_2d_low_level_io_t *ptCopyLike; //!< the function pointer for a copy-like implementation
610 const __arm_2d_low_level_io_t *ptFillLike; //!< the function pointer for a fill-like implementation
611 };
612 struct {
613 const __arm_2d_low_level_io_t *ptCopyOrigLike; //!< the function pointer for a copy-orig-like implementation
614 const __arm_2d_low_level_io_t *ptFillOrigLike; //!< the function pointer for a fill-orig-like implementation
615 };
616 struct {
617 const __arm_2d_low_level_io_t *ptTileProcessLike; //!< the function pointer for the tile-process-like implementation
618 };
619 }LowLevelIO;
620
621 }Info;
622 uint32_t wID; //!< Operation ID
624
625/*!
626 * \brief how would you want to accelerate the 2d-operation
627 */
628enum {
629 //! Use hardware acceleration if possible, even if there is a long queue to wait
630 ARM_2D_PREF_ACC_USE_HW_IF_POSSIBLE = 0,
631
632 //! Only use Hardware Acceleration, if it is not supported, IO error will be issued
633 ARM_2D_PREF_ACC_HW_ONLY = 1,
634
635 //! Only use software algorithm
636 ARM_2D_PREF_ACC_SW_ONLY = 2,
637
638 //!< don't care, let the arm-2d library decide
639 ARM_2D_PREF_ACC_DONT_CARE = 3,
640};
641
642#define __ARM_2D_OP_STATUS_BUSY_msk (1 << 4)
643#define __ARM_2D_OP_STATUS_IO_ERROR_msk (1 << 5)
644#define __ARM_2D_OP_STATUS_CPL_msk (1 << 6)
645
646/*!
647 * \brief a type for 2D operation status
648 *
649 */
650typedef union arm_2d_op_status_t {
651 struct {
652 uint16_t u4SubTaskCount : 4; //!< sub task count
653 uint16_t bIsBusy : 1; //!< busy flag
654 uint16_t bIOError : 1; //!< HW IO Error
655 uint16_t bOpCpl : 1; //!< the whole operation complete
656 uint16_t : 9; //!< reserved
657 };
658 uint16_t tValue; //!< the host integer
660
661/*!
662 * \brief the abstract class of 2D operations
663 *
664 */
666ARM_PRIVATE(
667 arm_2d_op_core_t *ptNext; //!< a pointer for a single list
668
669 const __arm_2d_op_info_t *ptOp; //!< the pointer for the corresponding 2D operation description
670
671 struct {
672 uint8_t u2ACCMethods : 2; //!< acceleration Methods
673 uint8_t : 6; //!< reserved
674 }Preference;
675
676 int8_t tResult; //!< operation result
677 volatile arm_2d_op_status_t Status; //!< operation status
678
679 arm_2d_op_evt_t evt2DOpCpl; //!< operation-complete event
680
682 uintptr_t pUserParam; //!< user attached object
683};
684
685/*!
686 * \brief the base class for operations with only a target tile
687 * \note arm_2d_op_msk_t inherits from arm_2d_op_core_t
688 */
689typedef struct arm_2d_op_t {
690 inherit(arm_2d_op_core_t);
691 struct {
692 const arm_2d_tile_t *ptTile; //!< target tile
693 const arm_2d_region_t *ptRegion; //!< target region
694 } Target;
696
697/*!
698 * \brief the base class for operations with a target tile and a target mask
699 * \note arm_2d_op_msk_t inherits from arm_2d_op_t
700 */
701typedef struct arm_2d_op_msk_t {
702 inherit(arm_2d_op_core_t);
703 struct {
704 const arm_2d_tile_t *ptTile; //!< target tile
705 const arm_2d_region_t *ptRegion; //!< target region
706 } Target;
707
708 /* derived part */
709 struct {
710 const arm_2d_tile_t *ptTile; //!< target tile
711 } Mask;
713
714/*!
715 * \brief the base class for operations with a target tile and a source tile
716 * \note arm_2d_op_src_t inherits from arm_2d_op_t
717 */
718typedef struct arm_2d_op_src_t {
719 inherit(arm_2d_op_core_t);
720 struct {
721 const arm_2d_tile_t *ptTile; //!< target tile
722 const arm_2d_region_t *ptRegion; //!< target region
723 } Target;
724
725 /* derived part */
726 struct {
727 const arm_2d_tile_t *ptTile; //!< source tile
728 }Source;
729 uint32_t wMode;
731
732/*!
733 * \brief the base class for operations with a target tile, a source tile and masks
734 * \note arm_2d_op_src_msk_t inherits from arm_2d_op_src_t
735 */
736typedef struct arm_2d_op_src_msk_t {
737 inherit(arm_2d_op_core_t);
738 struct {
739 const arm_2d_tile_t *ptTile; //!< target tile
740 const arm_2d_region_t *ptRegion; //!< target region
741 } Target;
742 struct {
743 const arm_2d_tile_t *ptTile; //!< source tile
744 }Source;
745 uint32_t wMode;
746
747 /* derived part */
748 struct {
749 const arm_2d_tile_t *ptSourceSide; //!< source side mask
750 const arm_2d_tile_t *ptTargetSide; //!< target side mask
751 } Mask;
753
754/*!
755 * \brief the base class for operations with a target tile, a dummy tile and a reference to the original source tile
756 * \note arm_2d_op_src_orig_t inherits from arm_2d_op_src_t
757 */
758typedef struct arm_2d_op_src_orig_t {
759 inherit(arm_2d_op_core_t);
760 struct {
761 const arm_2d_tile_t *ptTile; //!< target tile
762 const arm_2d_region_t *ptRegion; //!< target region
763 } Target;
764 struct {
765 const arm_2d_tile_t *ptTile; //!< the dummy source tile
766 }Source;
767 uint32_t wMode;
768
769 /* derived part */
770 struct {
771 const arm_2d_tile_t *ptTile; //!< the origin tile
772 arm_2d_tile_t tDummySource; //!< the buffer for the source
773 }Origin;
774
776
777/*!
778 * \brief the base class for operations with a target tile, a dummy tile, a reference to the original source tile and masks
779 * \note arm_2d_op_src_orig_msk_t inherits from arm_2d_op_src_orig_t
780 */
782 inherit(arm_2d_op_core_t);
783 struct {
784 const arm_2d_tile_t *ptTile; //!< target tile
785 const arm_2d_region_t *ptRegion; //!< target region
786 } Target;
787 struct {
788 const arm_2d_tile_t *ptTile; //!< the dummy source tile
789 }Source;
790 uint32_t wMode;
791 struct {
792 const arm_2d_tile_t *ptTile; //!< the origin tile
793 arm_2d_tile_t tDummySource; //!< the buffer for the source
794 }Origin;
795
796 /* derived part */
797 struct {
798 const arm_2d_tile_t *ptOriginSide; //!< origin side mask
799 const arm_2d_tile_t *ptTargetSide; //!< target side mask
800 } Mask;
802
803
804/*----------------------------------------------------------------------------*
805 * Fast Rotation linear regression structure
806 *----------------------------------------------------------------------------*/
807
808#if (__ARM_2D_HAS_HELIUM_FLOAT__ || __ARM_2D_HAS_FPU__) \
809 && !__ARM_2D_CFG_FORCED_FIXED_POINT_TRANSFORM__
810/*!
811 * \brief a type for parameters of linear interpolation (in floating point)
812 *
813 */
814typedef struct arm_2d_rot_linear_regr_t {
815 float slopeY;
816 float interceptY;
817 float slopeX;
818 float interceptX;
820
821#else
822/*!
823 * \brief a type for parameters of linear interpolation (in fixed point)
824 *
825 */
827 int32_t slopeY;
828 int32_t interceptY;
829 int32_t slopeX;
830 int32_t interceptX;
832
833#endif
834
835/*============================ GLOBAL VARIABLES ==============================*/
836/*============================ PROTOTYPES ====================================*/
837
838
839#if defined(__clang__)
840#pragma clang diagnostic pop
841#elif __IS_COMPILER_ARM_COMPILER_5__
842#pragma diag_warning 64
843#elif __IS_COMPILER_GCC__
844#pragma GCC diagnostic pop
845#endif
846
847#ifdef __cplusplus
848}
849#endif
850
851#endif // __ARM_2D_TYPES_H__
852
853