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