From 107a89de384ef51eeb291b43583d6d9c9c2a35b4 Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Wed, 8 Oct 2025 03:06:30 +0000 Subject: [PATCH] hal: ra: Initial update for drw driver This is the commit to support for drw driver on Renesas RA Signed-off-by: Duy Nguyen --- drivers/CMakeLists.txt | 1 + drivers/ra/CMakeLists.txt | 8 + drivers/ra/fsp/src/r_drw/r_drw_base.c | 233 ++++ drivers/ra/fsp/src/r_drw/r_drw_base.h | 48 + drivers/ra/fsp/src/r_drw/r_drw_memory.c | 333 ++++++ drivers/tes/dave2d/inc/dave_base.h | 1307 ++++++++++++++++++++++ drivers/tes/dave2d/inc/dave_driver.h | 681 +++++++++++ drivers/tes/dave2d/inc/dave_errorcodes.h | 72 ++ drivers/tes/dave2d/inc/dave_math.h | 111 ++ drivers/tes/dave2d/inc/dave_types.h | 33 + zephyr/blobs/renesas_open_license.txt | 44 + zephyr/module.yml | 9 + zephyr/ra/ra_cfg/fsp_cfg/r_drw_cfg.h | 14 + zephyr/ra/ra_gen/hal_data.h | 31 + 14 files changed, 2925 insertions(+) create mode 100644 drivers/ra/fsp/src/r_drw/r_drw_base.c create mode 100644 drivers/ra/fsp/src/r_drw/r_drw_base.h create mode 100644 drivers/ra/fsp/src/r_drw/r_drw_memory.c create mode 100644 drivers/tes/dave2d/inc/dave_base.h create mode 100644 drivers/tes/dave2d/inc/dave_driver.h create mode 100644 drivers/tes/dave2d/inc/dave_errorcodes.h create mode 100644 drivers/tes/dave2d/inc/dave_math.h create mode 100644 drivers/tes/dave2d/inc/dave_types.h create mode 100644 zephyr/blobs/renesas_open_license.txt create mode 100644 zephyr/ra/ra_cfg/fsp_cfg/r_drw_cfg.h diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index 45337470..28be7bb8 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -3,3 +3,4 @@ add_subdirectory_ifdef(CONFIG_HAS_RENESAS_RA_FSP ra) add_subdirectory_ifdef(CONFIG_HAS_RENESAS_RX_RDP rx) add_subdirectory_ifdef(CONFIG_HAS_RENESAS_RZ_FSP rz) +zephyr_include_directories_ifdef(CONFIG_LV_USE_DRAW_DAVE2D tes/dave2d/inc) diff --git a/drivers/ra/CMakeLists.txt b/drivers/ra/CMakeLists.txt index a50e45ba..9f292cf4 100644 --- a/drivers/ra/CMakeLists.txt +++ b/drivers/ra/CMakeLists.txt @@ -7,6 +7,7 @@ set(include_dirs ra_cfg/fsp_cfg fsp/src/bsp/mcu/all fsp/src/bsp/cmsis/Device/RENESAS/Include + fsp/src/r_drw ) set(srcs @@ -98,6 +99,13 @@ zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_IPC zephyr_library_sources_ifdef(CONFIG_USE_RA_FSP_MRAM fsp/src/r_mram/r_mram.c) +if (CONFIG_USE_RA_FSP_DRW) +zephyr_link_libraries(${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/dave2d/libdave2d.a) +zephyr_library_sources( + fsp/src/r_drw/r_drw_base.c + fsp/src/r_drw/r_drw_memory.c) +endif() + if(CONFIG_USE_RA_FSP_SCE) zephyr_include_directories( fsp/src/r_sce diff --git a/drivers/ra/fsp/src/r_drw/r_drw_base.c b/drivers/ra/fsp/src/r_drw/r_drw_base.c new file mode 100644 index 00000000..7c2b90f6 --- /dev/null +++ b/drivers/ra/fsp/src/r_drw/r_drw_base.c @@ -0,0 +1,233 @@ +/* +* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates +* +* SPDX-License-Identifier: BSD-3-Clause +*/ + +/********************************************************************************************************************** + * File Name : r_drw_base.c + * Description : This file defines the D/AVE D1 low-level driver basic functions. + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include + +#include "bsp_api.h" + +#include "r_drw_base.h" +#include "r_drw_cfg.h" + +/********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ +#define DRW_PRV_D2_DLISTSTART 50 /* display list start register index */ + +/*********************************************************************************************************************** + * Extern global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/* D1 device handle to be passed up to D2 layer */ +static d1_device_flex device_d2d = {0}; + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @internal + * @addtogroup DRW_PRV Internal DRW Documentation + * @ingroup RENESAS_INTERNAL + * @{ + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * This function initializes the D1 device handle, supplies module clock to D/AVE 2D hardware and enables the D/AVE 2D + * interrupt. It is called by the D/AVE 2D driver function d2_inithw() to initialize the D/AVE 2D hardware. + * + * @param[in] flags Reserved. Not used in this function. + * @retval Non-NULL The function returns the pointer to a d1_device object if the D1 device handle was successfully + * initialized. + * @retval NULL The function returns NULL if the interrupt could not be successfully initialized. + **********************************************************************************************************************/ +d1_device * d1_opendevice (d1_long_t flags) +{ + d1_device_flex * handle; + + FSP_PARAMETER_NOT_USED(flags); + + /* Get new device handle. */ + handle = &device_d2d; + + /* Initialize device data. */ + handle->dlist_indirect_enable = DRW_CFG_USE_DLIST_INDIRECT; + + /* Supply clock to the D/AVE 2D hardware. */ + R_BSP_MODULE_START(FSP_IP_DRW, 0); + + /* Enable the D/AVE 2D interrupt. */ + if (d1_initirq_intern(handle) == 0) + { + /* If the IRQ number is invalid return NULL. */ + handle = NULL; + + /* Stop clock supply to the D/AVE 2D hardware. */ + R_BSP_MODULE_STOP(FSP_IP_DRW, 0); + } + + /* Returns the pointer to the d1_device object. */ + return (d1_device *) handle; +} + +/*******************************************************************************************************************//** + * This function is called by the D/AVE 2D driver function d2_deinithw to de-initialize the D/AVE 2D hardware. Disables + * the D/AVE 2D interrupt and stop the module clock supply. + * + * @param[in] handle Pointer to the d1_device object. + * @retval 1 The function returns 1. + **********************************************************************************************************************/ +d1_int_t d1_closedevice (d1_device * handle) +{ + d1_device_flex * dev = (d1_device_flex *) handle; + + /* Disable the D/AVE 2D interrupt. */ + d1_shutdownirq_intern(dev); + + /* Stop clock supply to the D/AVE 2D hardware. */ + R_BSP_MODULE_STOP(FSP_IP_DRW, 0); + + return 1; +} + +/*******************************************************************************************************************//** + * This function is used to write data to a D/AVE 2D hardware register. + * + * @param[in] handle Pointer to a device handle. + * @param[in] deviceid D1_DAVE2D (Rendering core) or D1_DLISTINDIRECT (Lists of dlist support). Others are ignored. + * @param[in] index Register index (word offset from the D/AVE 2D base address). + * @param[in] value 32-bit value to write. + **********************************************************************************************************************/ +void d1_setregister (d1_device * handle, d1_int_t deviceid, d1_int_t index, d1_long_t value) +{ + d1_device_flex * handle_flex = (d1_device_flex *) handle; + + switch (deviceid) + { + case D1_DAVE2D: + { +#if DRW_CFG_USE_DLIST_INDIRECT + + /* If indirect mode is configured start processing the display list list in indirect mode */ + if ((DRW_PRV_D2_DLISTSTART == index) && (handle_flex->dlist_indirect_enable)) + { + /* Set DLISTSTART to the address of the first display list and set pp_dlist_indirect_start to the next dlist ptr */ + uint32_t * p_dlist = (uint32_t *) value; + R_DRW->DLISTSTART = *p_dlist; + handle_flex->pp_dlist_indirect_start = p_dlist + 1U; + } + else +#endif + { + /* Write data to specified D/AVE 2D register. */ + ((uint32_t *) R_DRW)[index] = (uint32_t) value; + } + + break; + } + + case D1_DLISTINDIRECT: + { +#if DRW_CFG_USE_DLIST_INDIRECT + handle_flex->dlist_indirect_enable = value; +#else + handle_flex->dlist_indirect_enable = 0; +#endif + break; + } + + default: + { + /* Not supported or Unknown device, do nothing. */ + break; + } + } +} + +/*******************************************************************************************************************//** + * This function is used to read data from a hardware register. + * Reading a register from an invalid or unsupported device ID will always return 0. + * + * @param[in] handle Pointer to a device handle. + * @param[in] deviceid D1_DAVE2D (Rendering core) or D1_DLISTINDIRECT (Lists of dlist support). Others are ignored. + * @param[in] index Register index (starts with 0). + * @retval Value The function returns the 32-bit value of the register. + **********************************************************************************************************************/ +d1_long_t d1_getregister (d1_device * handle, d1_int_t deviceid, d1_int_t index) +{ +#if DRW_CFG_USE_DLIST_INDIRECT + d1_device_flex * handle_flex = (d1_device_flex *) handle; +#else + FSP_PARAMETER_NOT_USED(handle); +#endif + + int32_t ret = 0; + + if (D1_DAVE2D == deviceid) + { + ret = (int32_t) (((uint32_t *) R_DRW)[index]); + } + +#if DRW_CFG_USE_DLIST_INDIRECT + else if (D1_DLISTINDIRECT == deviceid) + { + ret = handle_flex->dlist_indirect_enable; + } + else + { + } +#endif + + return (d1_long_t) ret; +} + +/*******************************************************************************************************************//** + * Check if the specified device ID is valid for the D/AVE 2D implementation for Flex. + * Use this function to verify that a specific hardware interface is available on the current host system. + * + * @param[in] handle Pointer to a device handle. + * @param[in] deviceid D1_DAVE2D (Rendering core) or D1_DLISTINDIRECT (Lists of dlist support). Others are ignored. + * @retval 0 The function returns 0 if specified device ID not supported. + * @retval 1 The function returns 1 if specified device ID supported. + **********************************************************************************************************************/ +d1_int_t d1_devicesupported (d1_device * handle, d1_int_t deviceid) +{ + d1_int_t ret = 0; + + FSP_PARAMETER_NOT_USED(handle); + + if (deviceid == D1_DAVE2D) + { + ret = 1; + } + +#if DRW_CFG_USE_DLIST_INDIRECT + else if (D1_DLISTINDIRECT == deviceid) + { + ret = 1; + } + else + { + } +#endif + + return ret; +} + +/*******************************************************************************************************************//** + * @} + **********************************************************************************************************************/ diff --git a/drivers/ra/fsp/src/r_drw/r_drw_base.h b/drivers/ra/fsp/src/r_drw/r_drw_base.h new file mode 100644 index 00000000..147fed21 --- /dev/null +++ b/drivers/ra/fsp/src/r_drw/r_drw_base.h @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates +* +* SPDX-License-Identifier: BSD-3-Clause +*/ + +/********************************************************************************************************************** + * File Name : r_drw_base.h + * Description : D/AVE D1 low-level driver function header file. + **********************************************************************************************************************/ + +#ifndef DRW_BASE_H +#define DRW_BASE_H + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include "bsp_api.h" +#include "dave_base.h" + +/** Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ +FSP_HEADER + +/********************************************************************************************************************** + * Macro definitions + **********************************************************************************************************************/ + +/********************************************************************************************************************** + * Typedef definitions + **********************************************************************************************************************/ +typedef long d1_long_t; +typedef int d1_int_t; +typedef unsigned int d1_uint_t; + +/** Device handle type definition for FSP implementation. */ +typedef struct _d1_device_flex +{ + volatile uint32_t * pp_dlist_indirect_start; /* Display list start address */ + int32_t dlist_indirect_enable; /* Set to 1 when supporting lists of dlist addresses */ +} d1_device_flex; + +d1_int_t d1_initirq_intern(d1_device_flex * handle); +d1_int_t d1_shutdownirq_intern(d1_device_flex * handle); + +/** Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ +FSP_FOOTER + +#endif diff --git a/drivers/ra/fsp/src/r_drw/r_drw_memory.c b/drivers/ra/fsp/src/r_drw/r_drw_memory.c new file mode 100644 index 00000000..7ac1272f --- /dev/null +++ b/drivers/ra/fsp/src/r_drw/r_drw_memory.c @@ -0,0 +1,333 @@ +/* +* Copyright (c) 2020 - 2025 Renesas Electronics Corporation and/or its affiliates +* +* SPDX-License-Identifier: BSD-3-Clause +*/ + +/********************************************************************************************************************** + * File Name : r_drw_memory.c + * Description : This file defines the D/AVE D1 low-level driver memory management functions. + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Includes + **********************************************************************************************************************/ +#include +#include +#include "r_drw_base.h" +#include "r_drw_cfg.h" + +#if (BSP_CFG_RTOS == 2) // FreeRTOS + #include "FreeRTOS.h" +#endif + +/*********************************************************************************************************************** + * Private global variables + **********************************************************************************************************************/ + +/*********************************************************************************************************************** + * Extern functions + **********************************************************************************************************************/ + +/* Optional user-defined memory allocation functions */ +#if DRW_CFG_CUSTOM_MALLOC +extern void * d1_malloc(size_t size); +extern void d1_free(void * ptr); + +#endif + +/*********************************************************************************************************************** + * Functions + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * @internal + * @addtogroup DRW_PRV Internal DRW Documentation + * @ingroup RENESAS_INTERNAL + * @{ + **********************************************************************************************************************/ + +/*******************************************************************************************************************//** + * Allocates memory in the driver heap. + * + * @param[in] size Size of the memory to be allocated. + * @retval Non-NULL The function returns a pointer to the allocation if successful. + * @retval NULL The function returns NULL if memory allocation failed. + **********************************************************************************************************************/ +void * d1_allocmem (d1_uint_t size) +{ +#if DRW_CFG_CUSTOM_MALLOC + + /* Use user-defined malloc */ + return d1_malloc((size_t) size); +#elif (BSP_CFG_RTOS == 2) // FreeRTOS + #if configSUPPORT_DYNAMIC_ALLOCATION + + /* Use FreeRTOS heap */ + return pvPortMalloc((size_t) size); + #else + + /* If RTOS dynamic allocation is disabled then allocate d1 heap data in the main heap. */ + return malloc((size_t) size); + #endif +#else + + /* If no RTOS is present then allocate d1 heap data in the main heap. */ + return malloc((size_t) size); +#endif +} + +/*******************************************************************************************************************//** + * Frees the specified memory area in the driver heap. + * + * @param[in] ptr Pointer to the memory area to be freed. + **********************************************************************************************************************/ +void d1_freemem (void * ptr) +{ +#if DRW_CFG_CUSTOM_MALLOC + + /* Use user-defined free */ + d1_free(ptr); +#elif (BSP_CFG_RTOS == 2) // FreeRTOS + #if configSUPPORT_DYNAMIC_ALLOCATION + + /* Use FreeRTOS heap */ + vPortFree(ptr); + #else + + /* If RTOS dynamic allocation is disabled then use free(). */ + free(ptr); + #endif +#else + + /* If no RTOS is present then use free(). */ + free(ptr); +#endif +} + +/*******************************************************************************************************************//** + * This function intends to return the size of the given memory block but we don't return a valid value. + * This function always returns 1. + * + * @param[in] ptr Pointer to a memory block in the heap. + * @retval 1 The function always returns 1. + **********************************************************************************************************************/ +d1_uint_t d1_memsize (void * ptr) +{ + FSP_PARAMETER_NOT_USED(ptr); + + /* Always return 1. */ + return 1U; +} + +/*******************************************************************************************************************//** + * Allocate video memory. + * FSP does not use virtual memory so this function simply calls d1_allocmem. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] memtype Type of memory (not used). + * @param[in] size Number of bytes to allocate. + * @retval Non-NULL The function returns a pointer to the allocation if successful. + * @retval NULL The function returns Null if memory allocation failed. + **********************************************************************************************************************/ +void * d1_allocvidmem (d1_device * handle, d1_int_t memtype, d1_uint_t size) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(memtype); + + return d1_allocmem(size); +} + +/*******************************************************************************************************************//** + * Free video memory. + * FSP does not use virtual memory so this function simply calls d1_freemem. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] memtype Type of memory (not used). + * @param[in] ptr Address returned by d1_allocvidmem. + **********************************************************************************************************************/ +void d1_freevidmem (d1_device * handle, d1_int_t memtype, void * ptr) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(memtype); + + d1_freemem(ptr); +} + +/*******************************************************************************************************************//** + * Get current memory status. This function is not used and always returns 0. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] memtype Type of memory (not used). + * @param[in] query Type of requested information (not used). + * @retval 0 The function always return 0. + **********************************************************************************************************************/ +d1_int_t d1_queryvidmem (d1_device * handle, d1_int_t memtype, d1_int_t query) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(memtype); + FSP_PARAMETER_NOT_USED(query); + + return 0; +} + +/*******************************************************************************************************************//** + * Return information about system memory architecture. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @retval d1_ma_unified The function always return d1_ma_unified (Unified memory architecture). + **********************************************************************************************************************/ +d1_int_t d1_queryarchitecture (d1_device * handle) +{ + FSP_PARAMETER_NOT_USED(handle); + + return d1_ma_unified; +} + +/*******************************************************************************************************************//** + * Map video memory for direct CPU access. + * FSP does not use virtual memory so this function simply returns the passed pointer. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] ptr Video memory address returned by d1_allocvidmem. + * @param[in] flags Memory mapping flags (not used). + * @retval ptr The function just returns ptr back as there is no mapping required for FSP. + **********************************************************************************************************************/ +void * d1_mapvidmem (d1_device * handle, void * ptr, d1_int_t flags) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(flags); + + /* Nothing special necessary for FSP. */ + return ptr; +} + +/*******************************************************************************************************************//** + * Release memory mapping. + * FSP does not use virtual memory so this function always returns 1. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] ptr Mapped video memory address returned by d1_mapvidmem (not used). + * @retval 1 The function always return 1. + **********************************************************************************************************************/ +d1_int_t d1_unmapvidmem (d1_device * handle, void * ptr) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(ptr); + + /* No unmapping necessary for FSP. */ + return 1; +} + +/*******************************************************************************************************************//** + * Map CPU accessible address of a video memory block back to video memory address. + * FSP does not use virtual memory so this function simply returns the passed pointer. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] ptr CPU accessible address pointing to a video memory block originally allocated using d1_allocvidmem. + * @retval ptr The function just returns ptr back as there is no mapping required for FSP. + **********************************************************************************************************************/ +void * d1_maptovidmem (d1_device * handle, void * ptr) +{ + FSP_PARAMETER_NOT_USED(handle); + + /* Nothing special necessary for FSP. */ + return ptr; +} + +/*******************************************************************************************************************//** + * Map already allocated video memory address to a CPU-accessible address. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] ptr Video memory address returned by d1_allocvidmem. + * @retval ptr The function just returns ptr back as there is no mapping required for FSP. + **********************************************************************************************************************/ +void * d1_mapfromvidmem (d1_device * handle, void * ptr) +{ + FSP_PARAMETER_NOT_USED(handle); + + /* Nothing special necessary for FSP. */ + return ptr; +} + +/*******************************************************************************************************************//** + * Copy data to video memory. Destination (video) memory area has to be allocated by d1_allocvidmem. + * As RA devices do not have separate video memory this simply calls memcpy. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] dst pointer into video memory (destination). + * @param[in] src Pointer into system memory (source). + * @param[in] size Number of bytes to copy. + * @param[in] flags Bitfield containing additional information on data to be copied (not used). + * @retval 1 The function always return 1. + **********************************************************************************************************************/ +d1_int_t d1_copytovidmem (d1_device * handle, void * dst, const void * src, d1_uint_t size, d1_int_t flags) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(flags); + + /* Simply use C standard memcpy. */ + memcpy(dst, src, size); + + return 1; +} + +/*******************************************************************************************************************//** + * Copy data from video memory. Source (video) memory area has to be allocated by d1_allocvidmem. + * As RA devices do not have separate video memory this simply calls memcpy. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] dst pointer into system memory (destination). + * @param[in] src Pointer into video memory (source). + * @param[in] size Number of bytes to copy. + * @param[in] flags Reserved for future use. + * @retval 1 The function always return 1. + **********************************************************************************************************************/ +d1_int_t d1_copyfromvidmem (d1_device * handle, void * dst, const void * src, d1_uint_t size, d1_int_t flags) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(flags); + + /* Simply use C standard memcpy. */ + memcpy(dst, src, size); + + return 1; +} + +/*******************************************************************************************************************//** + * Flush CPU data caches. RA devices do not have cache memory so this function immediately returns 1. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] memtype Memory pools to flush (can be ORed together; not used). + * @retval 1 The function always return 1. + **********************************************************************************************************************/ +d1_int_t d1_cacheflush (d1_device * handle, d1_int_t memtype) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(memtype); + + return 1; +} + +/*******************************************************************************************************************//** + * Flush part of CPU data caches. RA devices do not have cache memory so this function immediately returns 1. + * + * @param[in] handle Pointer to the d1_device object (not used). + * @param[in] memtype Memory pools to flush (can be ORed together; not used). + * @param[in] ptr Start address of memory to be flushed (not used). + * @param[in] size Size of memory to be flushed (not used). + * @retval 1 The function always return 1. + **********************************************************************************************************************/ +d1_int_t d1_cacheblockflush (d1_device * handle, d1_int_t memtype, const void * ptr, d1_uint_t size) +{ + FSP_PARAMETER_NOT_USED(handle); + FSP_PARAMETER_NOT_USED(memtype); + FSP_PARAMETER_NOT_USED(ptr); + FSP_PARAMETER_NOT_USED(size); + + return 1; +} + +/*******************************************************************************************************************//** + * @} + **********************************************************************************************************************/ diff --git a/drivers/tes/dave2d/inc/dave_base.h b/drivers/tes/dave2d/inc/dave_base.h new file mode 100644 index 00000000..66640648 --- /dev/null +++ b/drivers/tes/dave2d/inc/dave_base.h @@ -0,0 +1,1307 @@ +//-------------------------------------------------------------------------- +// Project: D/AVE +// File: dave_base.h (%version: 33 %) +// created Fri Aug 19 11:00:59 2005 by hh04027 +// +// Description: +// %date_modified: Thu Oct 18 12:36:18 2007 % (%derived_by: hh74040 %) +// +// Changes: +// 2005-12-22 CSe - added enums for timeouts and copyflags +// - changed declaration of d1_waitforirq to d1_queryirq +// 2006-01-04 CSe - added new memarchitecture flags +// - added 2 memory management functions +// - changed display controller interface +// - added timer interface +// 2006-01-13 NSc - moved videomode descriptor to videomodes.h +// 2006-02-16 CSe - added d1_deviceclkfreq function +// 2006-02-28 CSe - added d1_cacheblockflush function +// 2006-03-02 CSe - extensions for video-input (vip) +// 2006-03-08 CSe - added d1_displaytriggerupdate function +// 2006-03-15 CSe - added d1_callirqhandler function +// 2006-03-22 CSe - added d1_displayswitchlayersource function +// 2006-04-12 CSe - changed d1_irqtypes to single bit values +// 2006-06-01 CSe - added d1_getthreadid function +// 2006-06-15 CSe - extension for system ID +// 2006-07-06 MGe - added DAVE_TRACE deviceid ( dave_tace level1 driver ) +// 2007-02-21 MGe - added d1_irq_enum to d1_irqtypes +// 2007-10-05 CSe - added function d1_displaygetactivelayersource +// 2007-10-18 ASc - added display related structs to allow compilation of +// dave driver without the display driver +// 2009-03-17 MMa - support for TES DISPLAY CONTROLLER: +// - added device ID for TES Display Controller +// - added enums d1_alphamodes and d1_blendmodes +// - added new layermodes to d1_layermodes +// - added fields to d1_displaycaps +// - added fields to d1_layercaps +// - added display controller functions +// 2009-10-30 ASt - extended enumeration type d1_layermodes (contains now the 6 supported formats) +// 2012-08-27 MRe - added d1 devices D1_USERDATA and D1_DLISTINDIRECT (new version 1.3) + +/*-------------------------------------------------------------------------- +* Title: D1 API +* +* Hardware dependent D/AVE 2D low level driver +* +*--------------------------------------------------------------------- +*/ + + +#ifndef __1_dave_base_h_H +#define __1_dave_base_h_H +#ifdef __cplusplus +extern "C" { +#endif + +#define D1_VERSION_MAJOR 1 +#define D1_VERSION_MINOR 4 + +//--------------------------------------------------------------------------- +// types + +#ifndef D1_STDCALL +#ifdef WIN32 +#define D1_STDCALL __stdcall +#else +#define D1_STDCALL +#endif +#endif + + + +//--------------------------------------------------------------------------- +// device id's + +#define D1_DAVE2D 1 +#define D1_BUTTONS 2 +#define D1_LCDALTERA 3 +#define D1_DAVEDBG 4 +#define D1_VIP 5 +#define D1_SYSID 6 +#define D1_DAVE_TRACE 7 +#define D1_LCDTES 8 +#define D1_USERDATA 9 +#define D1_DLISTINDIRECT 10 + + +/*--------------------------------------------------------------------------- +* Section: Types and enumerations +*/ + +#ifndef __1_dave_driver_h_H +/*--------------------------------------------------------------------------- +* Type: d1_device +* +* Abstract type void +* +* The application uses pointers of this type to hold address of +* low level device structure without knowing the internal layout. The low level +* device structure layout being devie dependent. +* See +*/ +typedef void d1_device; +#endif + +typedef void ( D1_STDCALL *d1_interrupt)( int irqtype, void *irqdata, void *usrdata ); + +/*---------------------------------------------------------------------------*/ + +enum d1_timeouts +{ + d1_to_wait_forever = -1, + d1_to_no_wait = 0 +}; + +/*---------------------------------------------------------------------------*/ + +enum d1_memtypes +{ + d1_mem_display = 1, + d1_mem_texture = 2, + d1_mem_dlist = 4, + + d1_mem_any = 7 +}; + +/*---------------------------------------------------------------------------*/ + +enum d1_memqueries +{ + d1_mq_installed = 0, + d1_mq_available, + d1_mq_free, + d1_mq_allocated +}; + +/*---------------------------------------------------------------------------*/ + +enum d1_mapflags +{ + d1_mf_read = 1, + d1_mf_write = 2, + d1_mf_readwrite = 3, + d1_mf_direct = 4 +}; + +/*---------------------------------------------------------------------------*/ + +enum d1_copyflags +{ + d1_cf_shorts = 1, + d1_cf_ints = 2, + d1_cf_async = 16 +}; + +/*---------------------------------------------------------------------------*/ + +enum d1_irqtypes +{ + d1_irq_break = 1, + d1_irq_vbi = 2, + d1_irq_dlist = 4, + d1_irq_vip = 8, + d1_irq_enum = 16 +}; + +/*--------------------------------------------------------------------------- +* Enum: d1_memarchitectures +* +* Memory architecture types +* +* Values: +* d1_ma_unified - CPU can directly access pointers returned by allocvidmem +* d1_ma_separated - Video memory is separated from system memory and can be accessed by transfer or mapping functions only. +* d1_ma_uncached - CPU access to mapped video memory is not cached +* d1_ma_fulluma - Static arrays and malloced memory can be accessed by the hardware +* d1_ma_mapped - alloced video mem is static mapped into system mem -> use +* d1_ma_fullmapped - hardware can access malloced memory and static arrays -> use and +* d1_ma_bigendian - data in system mem is big endian -> swap before letting hardware access it +* +*/ + +enum d1_memarchitectures +{ + d1_ma_unified = 0x1, + d1_ma_separated = 0x2, + d1_ma_uncached = 0x4, + d1_ma_fulluma = 0x8, + d1_ma_mapped = 0x10, + d1_ma_fullmapped = 0x20, + d1_ma_bigendian = 0x40 +}; + + + +/*-------------------------------------------------------------------------- +* Enum: enum d1_layermodes +* +* Video input formats for layers. +* +* Values: +* d1_mode_alpha8 - 8 bit per pixel, alpha only +* d1_mode_rgb565 - 16 bit per pixel: 5 red, 6 green, 5 blue +* d1_mode_rgb888 - 32 bit per pixel: 8 red, 8 green, 8 blue, 8 unused +* d1_mode_rgb444 - 16 bit per pixel: 4 red, 4 green, 4 blue, 4 unused +* d1_mode_argb8888 - 32 bit per pixel: 8 alpha, 8 red, 8 green, 8 blue +* d1_mode_argb4444 - 16 bit per pixel: 4 alpha, 4 red, 4 green, 4 blue +* d1_mode_argb1555 - 16 bit per pixel: 1 alpha, 5 red, 5 green, 5 blue +* d1_mode_rgba8888 - 32 bit per pixel: 8 red, 8 green, 8 blue, 8 alpha +* d1_mode_rgba4444 - 16 bit per pixel: 4 red, 4 green, 4 blue, 4 alpha +* d1_mode_grey8 - 8 bit per pixel: greyscale +*/ +enum d1_layermodes +{ + d1_mode_alpha8 = 0, + d1_mode_rgb565 = 1, + d1_mode_rgb888 = 2, + d1_mode_rgb444 = 3, + d1_mode_argb8888 = 4, + d1_mode_argb4444 = 5, + d1_mode_argb1555 = 6, + d1_mode_rgba8888 = 7, + d1_mode_rgba4444 = 8, + d1_mode_rgba5551 = 9, + d1_mode_grey8 = 10, + d1_mode_count +}; + + +/*-------------------------------------------------------------------------- +* type: enum d1_alphamodes +* Constant alpha modes +* +* values: +* d1_alpha_none - constant alpha is ignored +* d1_alpha_replace - constant alpha is used for layer +* d1_alpha_mul - original alpha is multiplied by constant alpha +*/ +enum d1_alphamodes { + d1_alpha_none = 0, + d1_alpha_replace = 1, + d1_alpha_mul = 2 +}; + +/*-------------------------------------------------------------------------- +* type: enum d1_blendmodes +* Alpha Blending Modes +* +* values: +* d1_blend_zero - set alpha to 0.0 +* d1_blend_one - set alpha to 1.0 +* d1_blend_app - leave alpha unchanged +* d1_blend_inv_app - use inverted alpha +* d1_blend_sub_app - use alpha of subjacent layer +* d1_blend_inv_sub_app - use inverted alpha of subjacent layer +*/ +enum d1_blendmodes { + d1_blend_zero = 0, + d1_blend_one = 1, + d1_blend_app = 2, + d1_blend_inv_app = 3, + d1_blend_sub_app = 4, + d1_blend_inv_sub_app = 5 +}; + + +/*-------------------------------------------------------------------------- +* Type: struct d1_videomode +* +* Display controller video output parameters. +* +* Members: +* modeid - global ID for mode +* width - width of output picture in pixels +* height - height of output picture in pixels +* vfreq - refresh rate in Hz +* +*/ +typedef struct _d1_videomode +{ + unsigned int modeid; + unsigned int width; + unsigned int height; + unsigned int vfreq; + +} d1_videomode; + + +/*-------------------------------------------------------------------------- +* Type: struct d1_layercaps +* +* Display controller layer capabilities. +* +* Members: +* modecount - number of modes supported by layer +* layermodes - array of modes (pixel formats) supported by layer of type () +* constant - true when layer allows constant color only (e.g. background) (use: ) +* alpha - true when layer supports alpha (use: ) +* window - true when layer supports windowing (use: ) +* swappable - true when top-down position of layer can be changed (use: ) +* moveable - true when the position of layer can be changed (use ) +* resizeable - true when layer can be resized if windowing is enabled (use ) +* framecolour - true when a framecolour can be set for layer (use ) +* alphalayer - true when a alphalayer is available for layer (use ) +* pitch - true when the width can be smaller than the pitch (use and ) +* duplicate - true when the layer can be duplicated in horizontal and/or vertical direction (use ) +* colourkey - true when a colourkey can be set for the layer (use ) +* a1_modecount - number blendmodes for upper alpha supported by layer +* a1_modes - array of blendmodes for upper alpha supported by layer of type () (use ) +* a0_modecount - number blendmodes for lower alpha supported by layer +* a0_modes - array of blendmodes for lower alpha supported by layer of type () (use ) +*/ +typedef struct _d1_layercaps +{ + unsigned int modecount; + const int *layermodes; + int constant; + int alpha; + int window; + int swappable; + int moveable; + int resizeable; + int framecolour; + int alphalayer; + int pitch; + int duplicate; + int colourkey; + int a1_modecount; + int *a1_modes; + int a0_modecount; + int *a0_modes; +} d1_layercaps; + + +/*-------------------------------------------------------------------------- +* Type: struct d1_displaycaps +* +* Display controller capabilities. +* +* Members: +* modecount - number of output modes supported by display controller +* videomodes - array of output modes supported by display controller of type +* layercount - number of layers supported by display controller +* layercaps - array of layers capabilities of type +* major_rev - major hardware revision of display controller +* minor_rev - minor hardware revision of display controller +* blind_mode - true when controller runs in blind mode +* shadowing - true when controller has shadow registers +* gammaramp - true when controller has a gammaramp +* windowing - true when controller supports windowing for layers +* precise_blend - true when a precise alphablending method is used +* red_bits - number of red output bits +* green_bits - number of green output bits +* blue_bits - number of blue output bits +* +*/ +typedef struct _d1_displaycaps +{ + unsigned int modecount; + const d1_videomode *videomodes; + unsigned int layercount; + const d1_layercaps *layercaps; + int major_rev; + int minor_rev; + int blind_mode; + int shadowing; + int gammaramp; + int windowing; + int precise_blend; + int red_bits; + int green_bits; + int blue_bits; +} d1_displaycaps; + + + +/*--------------------------------------------------------------------------- +* Section: Basic Functions +*/ + +/*--------------------------------------------------------------------------- +* Function: d1_getversion +* +* Query version ID (device dependent). +* +* Parameters: +* None +* +* Returns: +* The driver revision as a single 32-bit integer (major version in the upper 16 bits) +* +* See also: +* +*/ +extern int d1_getversion(); + +/*--------------------------------------------------------------------------- +* Function: d1_getversionstring +* +* Query version ID string (device dependent). +* +* Parameters: +* None +* +* Returns: +* the driver version as a atring +* +* See also: +* +* +*/ +extern const char * d1_getversionstring(); + +/*--------------------------------------------------------------------------- +* Function: d1_opendevice +* +* Creates a device handle to access hardware +* +* This function sets the D/AVE ISR, enables the interrupt handling and allocates +* memory for a d1 handle. +* It is called by the D/AVE 2D driver when initialising the hardware . +* +* Parameters: +* flags - reserved. pass 0 +* +* Returns: +* pointer to a object or 0 if hardware access failed +* +*/ +extern d1_device * d1_opendevice( long flags ); + +/*--------------------------------------------------------------------------- +* Function: d1_closedevice +* +* Close a device handle +* +* It is called by the D/AVE 2D driver when de-initialising the hardware . +* Disables all interrupts. +* +* Parameters: +* handle - pointer to the object +* +* Returns: +* int - 0 if error else 1. +* +*/ +extern int d1_closedevice( d1_device *handle ); + +/*--------------------------------------------------------------------------- +* Function: d1_getthreadid +* +* Return current thread ID +* +* Parameters: +* handle - device handle , see +* +* Returns: +* Id of the current thread based on query to OS. +*/ +extern int d1_getthreadid( d1_device *handle ); + +/*--------------------------------------------------------------------------- +* Section: Memory management +*/ + +/*--------------------------------------------------------------------------- +* Function: d1_memsize +* +* Returns the size of the given memory block +* +* Parameters: +* ptr - pointer to a memory block in Heap +* +* Returns: +* int - size of the memory block. +* +*/ +extern unsigned int d1_memsize(void * ptr); + +/*--------------------------------------------------------------------------- +* Function: d1_allocmem +* +* Allocates memory on the CPU heap +* +* Parameters: +* size - Size of the memory to be allocated +* +* Returns: +* void * - Pointer to the start address of the allocated memory block +* 0 if not successful +* +*/ +extern void * d1_allocmem(unsigned int size ); + +/*--------------------------------------------------------------------------- +* Function: d1_freemem +* +* Free the specified memory area on the CPU heap +* +* Parameters: +* ptr - Pointer to the memory area to be freed +* +* Returns: +* None +* +*/ +extern void d1_freemem(void *ptr ); + +/*-------------------------------------------------------------------------- +* Function: d1_allocvidmem +* +* Allocate video memory +* +* For systems without a unified memory architecture all memory that will +* be accessed directly by hardware has to be video memory. +* On a UMA platform d1_allocvidmem will most likely behave just like a simple malloc. +* +* Note that not every platform will make use of the 'memtype' it is +* used as a hint in order to get the memory best suited for the specified +* purpose. +* +* All memory allocated using this function must be released by +* +* Parameters: +* handle - device handle (see: ) +* memtype - type of memory (see list below) +* size - number of bytes +* +* Memtypes: +* d1_mem_display - used if the memory is going to be displayed (framebuffer) +* d1_mem_texture - used for textures (accessed by dave but not by the displaycontroller) +* d1_mem_dlist - used for display lists (read only for hardware) +* +* Returns: +* pointer to memorychunk or NULL. +* +* the pointer returned by allocvidmem points directly to video memory and can +* not be accessed by the CPU (unless the memory architecture is unified - see +* ). Transfer functions like +* and can access video memory directly. +*/ +extern void * d1_allocvidmem( d1_device *handle, int memtype, unsigned int size ); + +/*-------------------------------------------------------------------------- +* Function: d1_freevidmem +* +* Release video memory +* +* The memtype should be identical to what has been specified when allocating +* the block. +* +* Parameters: +* handle - device handle (see: ) +* memtype - memory pool id (see: ) +* ptr - address returned by +* +* Returns: +* None +*/ +extern void d1_freevidmem( d1_device *handle, int memtype, void *ptr ); + +/*-------------------------------------------------------------------------- +* Function: d1_queryvidmem +* +* Get current memory status +* +* Not every platform will treat all memory pools as distinct heaps, so +* the return values might be the same for different memtype's. +* +* Parameters: +* handle - device handle (see: ) +* memtype - memory pool id (see: ) +* query - type of requested information (see below) +* +* Query types: +* d1_mq_installed - size of installed memory +* d1_mq_available - largest available free chunk +* d1_mq_free - total amount of free memory +* d1_mq_allocated - total amount of allocated memory +* +* returns: +* number of bytes +*/ +extern int d1_queryvidmem( d1_device *handle, int memtype, int query ); + +/*-------------------------------------------------------------------------- +* Function: d1_mapvidmem +* +* Map video memory for direct CPU access +* +* In order to access video memory directly with the CPU it has to be +* mapped into system memory (unless the host has a unified memory architecture). +* This function always maps an entire block (as allocated by ) +* and therfore does not need a 'size' argument. +* +* Mappings must be released before the memory is freed by . +* +* Parameters: +* handle - device handle (see: ) +* ptr - video memory address returned by +* flags - memory mapping flags (see below) +* +* Memory mapping flags: +* d1_mf_read - mapped memory will be read only +* d1_mf_write - mapped memory will be written only +* d1_mf_readwrite - full access to mapped memory +* d1_mf_direct - try mapping to the same address (make videomemory visible to +* current process using its original address) +* +* Returns: +* CPU accessible pointer to the same memory region +* +* See also: +* +*/ + +extern void * d1_mapvidmem( d1_device *handle, void *ptr, int flags ); + +/*-------------------------------------------------------------------------- +* Function: d1_unmapvidmem +* +* Release memory mapping +* +* Memory mapped using should be unmapped before it is released. +* +* Parameters: +* handle - device handle (see: ) +* ptr - mapped video memory address returned by +* +* Returns: +* boolean success. +*/ +extern int d1_unmapvidmem( d1_device *handle, void *ptr ); + +/*-------------------------------------------------------------------------- +* Function: d1_maptovidmem +* +* Map CPU accessible address of a video memory block back to video memory +* address +* +* In systems, which have CPU and hardware address spaces statically mapped to each other +* (see: ), this function can be used to convert an address inside +* the CPU address space and pointing to a block of video memory back to a video memory address. +* +* Parameters: +* handle - device handle (see: ) +* ptr - CPU accessible address pointing to a video memory block originally allocated using +* +* Returns: +* hardware accessible pointer to the same memory region or NULL if mapping not possible +* +* See also: +* +*/ +extern void * d1_maptovidmem( d1_device *handle, void *ptr ); + +/*-------------------------------------------------------------------------- +* Function: d1_mapfromvidmem +* +* Map already allocated video memory address to an address for direct CPU access +* +* In systems, which have CPU and hardware address spaces statically mapped to each other +* (see: ), this function can be used to convert a video memory +* address to an address in the CPU address space. +* +* Parameters: +* handle - device handle (see: ) +* ptr - video memory address returned by +* +* Returns: +* CPU accessible pointer to the same memory region or NULL if mapping not possible +* +* See also: +* +*/ +extern void * d1_mapfromvidmem( d1_device *handle, void *ptr ); + +/*-------------------------------------------------------------------------- +* Function: d1_copytovidmem +* +* Copy data to video memory +* +* Destination (video) memory area has to be allocated by . +* +* Parameters: +* handle - device handle (see: ) +* dst - pointer into video memory (destination) +* src - pointer into system memory (source) +* size - number of bytes to copy +* flags - bitfield containing additional information on data to be copied +* +* Flags: +* d1_cf_shorts - data consists of 16 bit values: swaps both bytes within each 16 bit value on big endian systems +* d1_cf_ints - data consists of 32 bit values: swaps all four bytes within each 32 bit value on big endian systems +* d1_cf_async - allow asynchronous copy and return before the transfer is finished +* +* Returns: +* boolean success. +* +* Note: +* A cache flush is implicitly done if the flag 'd1_cf_async' is not passed. +* To be sure, an asynchronous copy was finished, either start another copy or use see . +*/ +extern int d1_copytovidmem( d1_device *handle, void *dst, const void *src, unsigned int size, int flags ); + +/*-------------------------------------------------------------------------- +* Function: d1_copyfromvidmem +* +* Copy data from video memory +* +* Source (video) memory area has to be allocated by . +* +* Parameters: +* handle - device handle (see: ) +* dst - pointer into system memory (destination) +* src - pointer into video memory (source) +* size - number of bytes to copy +* flags - reserved for future use. pass 0 for now. +* +* Returns: +* boolean success. +* +* Note: +* a cache flush is implicitly done to be sure to use correct data. +*/ +extern int d1_copyfromvidmem( d1_device *handle, void *dst, const void *src, unsigned int size, int flags ); + +/*-------------------------------------------------------------------------- +* Function: d1_cacheflush +* +* Flush CPU data caches +* +* When accessing video memory using the CPU it might be necessary to flush +* CPU data caches in order for the DAVE hardware to see the changes. +* +* Parameters: +* handle - device handle (see: ) +* memtype - memory pools to flush (can be or'ed together) +* +* Memtypes: +* d1_mem_any - flush datacache entirely +* d1_mem_display - flush addresses from d1_mem_display only +* d1_mem_texture - flush addresses from d1_mem_texture only +* d1_mem_dlist - flush addresses from d1_mem_dlist only +* +* Returns: +* boolean success. +* +* See also: +* +*/ +extern int d1_cacheflush( d1_device *handle, int memtype ); + +/*-------------------------------------------------------------------------- +* Function: d1_cacheblockflush +* +* Flush part of CPU data caches +* +* When accessing video memory using the CPU it might be necessary to flush +* CPU data caches in order for the DAVE hardware to see the changes. +* +* Parameters: +* handle - device handle (see: ) +* memtype - memory type to be flushed +* ptr - start address of memory to be flushed +* size - size of memory to be flushed +* +* Memtypes: +* d1_mem_display - flush addresses from d1_mem_display only +* d1_mem_texture - flush addresses from d1_mem_texture only +* d1_mem_dlist - flush addresses from d1_mem_dlist only +* +* Returns: +* boolean success. +* +* See also: +* +*/ +extern int d1_cacheblockflush( d1_device *handle, int memtype, const void *ptr, unsigned int size ); + +/*-------------------------------------------------------------------------- +* Function: d1_queryarchitecture +* +* Return hints about systems memory architecture +* +* The application can often avoid memory transfers if a unified memory +* architecture is available on the host system. This function can be used +* to query the host memory architecture. +* +* Parameters: +* handle - device handle (see: ) +* +* Returns: +* +* a bitfield with the following bits set if applicable : +* +* d1_ma_unified - CPU can directly access pointers returned by . +* Transfer and mapping functions will work but are unnecessary. +* d1_ma_separated - Video memory is separated from CPU memory and can be +* accessed by copy or mapping functions only. +* d1_ma_uncached - CPU access to mapped video memory is not cached. +* d1_ma_fulluma - Static arrays and malloced memory can be accessed by the hardware. +* d1_ma_mapped - Allocated video memory is statically mapped into CPU memory. +* Use and to convert addresses. +* d1_ma_fullmapped - The whole CPU memory (malloced memory as well as static arrays) +* is statically mapped to the address space of the hardware. +* Use and to convert addresses +* between CPU address space and hardware address space. +* d1_ma_bigendian - Data in CPU memory is big endian. A swap might be needed before letting +* hardware access it (see: ). +*/ +extern int d1_queryarchitecture( d1_device *handle ); + +/*--------------------------------------------------------------------------- +* Section: Hardware port interface +*/ + +/*--------------------------------------------------------------------------- +* Function: d1_devicesupported +* +* Check if the specified device is supported +* +* Different hardware components and revisions offer different hardware registers (see: ). +* Use this function to verify that a specific hardware interface is available on the current host system. +* +* Parameters: +* handle - pointer to a low level device , see +* deviceId - used to specify target hardware component, see +* +* Returns: +* int - 0 if not supported else 1 +* +*/ +extern int d1_devicesupported( d1_device *handle, int deviceid ); + +/*--------------------------------------------------------------------------- +* Function: d1_deviceclkfreq +* +* Returns the clock frequency of the D/AVE 2D hardware +* +* Parameters: +* handle - pointer to a low level device , see +* deviceid - device type +* +* Returns: +* unsigned long - clock frequency of the drawing engine +* +*/ +extern unsigned long d1_deviceclkfreq( d1_device *handle, int deviceid ); + +/*--------------------------------------------------------------------------- +* Function: d1_setregister +* +* Writes to hardware register +* +* Access to an invalid or unsupported deviceid will be ignored +* +* Parameters: +* handle - pointer to a device , see +* deviceid - used to specify target hardware component, see +* index - register index (starts with 0) +* value - 32-bit value to write +* +* Returns: +* None +* +*/ +extern void d1_setregister( d1_device *handle, int deviceid, int index, long value ); + +/*--------------------------------------------------------------------------- +* Function: d1_getregister +* +* Read from hardware register +* +* Reading a register from an invalid or unsupported deviceId will always return 0 +* +* Parameters: +* handle - pointer to a low level device , see +* deviceid - used to specify target hardware component, see +* index - register index (starts with 0) +* +* Returns: +* long - 32-bit value of the register +* +*/ +extern long d1_getregister( d1_device *handle, int deviceid, int index ); + + +/*--------------------------------------------------------------------------- +* Section: Interrupt control +*/ + +/*--------------------------------------------------------------------------- +* Function: d1_setirqhandler +* +* Register an IRQ handler +* +* Registered callback will be called when the specified IRQ triggers. +* The IRQ will be reset automatically after the callback has been executed. +* Note that the callback code might run at a different privilege level than the main application. +* +* You can pass NULL instead of a function pointer in order to remove a registered callback. +* +* Not every interrupt is available on every platform. Unsupported IRQs will never trigger but +* setting or removing a callback for them does no harm. +* +* Parameters: +* handle - device handle (see: ) +* irqtype - interrupt ID (see below) +* code - callback address (NULL to remove handler) +* data - userdefined data (passed on to callback directly) +* +* Interrupt IDs: +* d1_irq_break - userbreak +* d1_irq_vbi - vertical blank +* d1_irq_dlist - display list finished +* +* Callback signature: +* +* | void D1_STDCALL d1_interrupt( int irqtype, void *irqdata, void *usrdata ); +* +* Note: +* +* Consider that existing ISR registrations might be disabled when setting new irq handlers. +* An ISR should always call the original ISR that was registered before d1_setirqhandler was +* called (use ). Otherwise, e.g. in case of the vertical blank irq (d1_irq_vbi), +* this will disable the display controller driver. +* +* See also: +* , +*/ +extern void d1_setirqhandler( d1_device *handle, int irqtype, d1_interrupt code, void *data ); + +/*--------------------------------------------------------------------------- +* Function: d1_getirqhandler +* +* Retrieve an IRD handler +* +* IRQ handler callbacks installed by can be retrieved using this function +* +* Parameters: +* handle - device handle (see: ) +* irqtype - interrupt ID (see: ) +* +* Returns: +* callback address or 0 if no callback is registered for given IRQ +* +* See also: +* , +*/ +extern d1_interrupt d1_getirqhandler( d1_device *handle, int irqtype ); + +/*--------------------------------------------------------------------------- +* d1_callirqhandler +* +*/ +extern int d1_callirqhandler( d1_device *handle, int irqtype, void *irqdata ); + +/*-------------------------------------------------------------------------- +* Function: d1_getirqdata +* +* Retrieve user defined data of specified IRQ +* +* User defined data assigned by can be retrieved +* using this function. +* +* Parameters: +* handle - device handle (see: ) +* irqtype - interrupt ID (see: ) +* +* Returns: +* userdefined data or NULL if no callback is registered for given IRQ +* +* See also: +* , +*/ +extern void * d1_getirqdata( d1_device *handle, int irqtype ); + +/*-------------------------------------------------------------------------- +* Function: d1_queryirq +* +* Wait for next execution of specified IRQ +* +* Instead of using IRQ callbacks you can manually block execution until a +* certain IRQ triggers. This is equivalent to setting up a callback that +* signals an Event and a 'WaitForEvent' inside the main thread. +* +* This function is often used to synchronize rendering with the vertical +* blank for flicker free animation. +* +* Parameters: +* handle - device handle (see: ) +* irqmask - interrupt ID (see: ) +* timeout - flag to specify how long to wait for the interrupt (see below) +* +* Returns: +* irqID that triggered +* +* Timeout flags: +* d1_to_wait_forever - wait forever +* d1_to_no_wait - do not wait at all +*/ +extern int d1_queryirq( d1_device *handle, int irqmask, int timeout ); + +/*--------------------------------------------------------------------------- +* Section: Timer interface +* Not required by the d2 driver at all: Only for better platform portability of applications. +*/ + +/*-------------------------------------------------------------------------- +* Function: d1_timerres +* +* Get the resolution of the timer +* +* Parameters: +* handle - device handle (see: ) +* +* Returns: +* resolution of the timer (in microseconds) +* +* See also: +* , , +*/ +extern unsigned long d1_timerres ( d1_device *handle ); + +/*-------------------------------------------------------------------------- +* Function: d1_timerlimit +* +* Get the maximum value of the timer +* +* Parameters: +* handle - device handle (see: ) +* +* Returns: +* the maximum timer value +* +* See also: +* , , +*/ +extern unsigned long d1_timerlimit( d1_device *handle ); + +/*-------------------------------------------------------------------------- +* Function: d1_timerreset +* +* Reset the timer to zero +* +* Parameters: +* handle - device handle (see: ) +* +* See also: +* , , +*/ +extern void d1_timerreset( d1_device *handle ); + +/*-------------------------------------------------------------------------- +* Function: d1_timervalue +* +* Retrieves the number of microseconds that have elapsed since the +* last reset +* +* It is limited to the resolution of the used timer (see ). +* +* Parameters: +* handle - device handle (see: ) +* +* Returns: +* the return value is the number of microseconds that have elapsed since +* the last reset +* +* See also: +* , , +*/ +extern unsigned long d1_timervalue( d1_device *handle ); + +#ifndef Dx4 +/*--------------------------------------------------------------------------- +* Section: Display controller interface +* Not required by the d2 driver at all: Only for better platform portability of applications. +*/ + +//-------------------------------------------------------------------------- +// function: d1_displaysetmode +// +// Set display controller output mode. +// +// parameters: +// handle - device handle (see ) +// mode - ID of output mode (see ) +// +// Pre-defined mode IDs: +// D1_VIDEO_OFF - turn off display controller (if possible) +// D1_VIDEO_DEFAULT - use default mode (first mode in list of +// possible modes from ) +// D1_VIDEO_640_400_60 - 640x400 pixels at 60 Hz +// D1_VIDEO_640_480_60 - 640x480 pixels at 60 Hz +// D1_VIDEO_800_600_60 - 800x600 pixels at 60 Hz +// +// Mode IDs of modes that are supported can be found out using +// . +// +// returns: +// boolean success (false if display is not capable) +// +extern int d1_displaysetmode( d1_device *handle, unsigned int mode ); + +extern int d1_displaysetlayerblendmode( d1_device *handle, int layer, int a1_mode, int a0_mode ); + +extern int d1_displaysetlayeralphamode( d1_device *handle, int layer, int mode ); + +extern int d1_displaysetlayercolourkey( d1_device *handle, int layer, unsigned int colourkey, int enable ); + +extern int d1_displaysetlayerduplication( d1_device *handle, int layer, int hor_duplication, int ver_duplication ); + +extern int d1_displaysetlayerframecolour( d1_device *handle, int layer, unsigned int framecolour ); + +//-------------------------------------------------------------------------- +// function: d1_displaysetlayersource +// +// Set pointer to frame buffer for non-constant layer. +// +// parameters: +// handle - device handle (see ) +// layer - layer number starting at 0 (see for number of layers/capabilities) +// data - start address of frame buffer +// +// returns: +// boolean success (false if layer is not capable) +// +extern int d1_displaysetlayersource( d1_device *handle, int layer, void *data ); + +//-------------------------------------------------------------------------- +// function: d1_displaysetlayerformat +// +// Set input pixel format for layer. +// +// parameters: +// handle - device handle (see ) +// layer - layer number starting at 0 (see for number of layers/capabilities) +// mode - pixel format (see for possible values) +// pitch - length of lines in pixels (normally width of layer) +// +// returns: +// boolean success (false if layer is not capable) +// +extern int d1_displaysetlayerformat( d1_device *handle, int layer, int mode, int pitch ); + +//-------------------------------------------------------------------------- +// function: d1_displaysetlayerwindow +// +// Set window for layer if layer is capable. +// +// parameters: +// handle - device handle (see ) +// layer - layer number starting at 0 (see for number of layers/capabilities) +// x - x position of top left corner in display pixel coordinates +// y - y position of top left corner in display pixel coordinates +// width - width of window in pixels +// height - height of window in pixels +// +// returns: +// boolean success (false if layer is not capable) +// +extern int d1_displaysetlayerwindow( d1_device *handle, int layer, int x, int y, int width, int height ); + +//-------------------------------------------------------------------------- +// function: d1_displaysetlayeralpha +// +// Set constant alpha value for layer if layer is capable. +// +// parameters: +// handle - device handle (see ) +// layer - layer number starting at 0 (see for number of layers/capabilities) +// alpha - alpha value in layer alpha format (see ) +// +// returns: +// boolean success (false if layer is not capable) +// +extern int d1_displaysetlayeralpha( d1_device *handle, int layer, int alpha ); + +//-------------------------------------------------------------------------- +// function: d1_displaysetlayercolor +// +// Set constant color value for layer if layer is capable. +// +// parameters: +// handle - device handle (see ) +// layer - layer number starting at 0 (see for number of layers/capabilities) +// color - color value in layer pixel format (see ) +// +// returns: +// boolean success (false if layer is not capable) +// +extern int d1_displaysetlayercolor( d1_device *handle, int layer, int color ); + +//-------------------------------------------------------------------------- +// function: d1_displaysetlayerorder +// +// Change top-down order of layers if possible. +// +// parameters: +// handle - device handle (see ) +// layer - layer number starting at 0 (see for number of layers/capabilities) +// position - new position of layer (0 is bottom) +// +// If a layer is moved to a new position the positions of the other layers are affected +// in the following way: +// Default layer position is the same as layer number (layer 0 is at bottom). +// When a new position is assigned the layer is removed where it was before and inserted at the +// new position thus shifting all other layers in between by 1 towards the position where the layer +// was located before. +// +// returns: +// boolean success (false if display/controller is not capable) +// +extern int d1_displaysetlayerorder( d1_device *handle, int layer, int position ); + +//-------------------------------------------------------------------------- +// function: d1_displaysetlayerenable +// +// Switch separate layers on/off. +// +// parameters: +// handle - device handle (see ) +// layer - layer number starting at 0 +// enable - boolean enable +// +// returns: +// boolean success (false if display/controller is not capable) +// +extern int d1_displaysetlayerenable( d1_device *handle, int layer, int enable ); + +//-------------------------------------------------------------------------- +// function: d1_displayswitchlayersource +// +// Change pointer to frame buffer for non-constant layer immediately or synchronized to vertical blanking. +// +// parameters: +// handle - device handle (see ) +// layer - layer number starting at 0 (see for number of layers/capabilities) +// data - start address of frame buffer +// sync - boolean: synchronize change to vertical blanking or not +// +// Not every display controller might be capable of changing the frame buffer source out of sync. +// In this case, the 'sync' parameter is not considered. +// +// returns: +// boolean success (false if layer is not capable) +// +extern int d1_displayswitchlayersource( d1_device *handle, int layer, void *data, int sync ); + +//-------------------------------------------------------------------------- +// function: d1_displaytriggerupdate +// +// Trigger an update of new display controller settings during next vertical +// blanking. +// +// parameters: +// handle - device handle (see ) +// +// Activates all new settings made by d1_displayset... functions since +// last update during next vertical blanking. +// +// Returns immediately: Settings made after this call before next vertical +// blanking are also activated!! +// +// returns: +// boolean success +// +extern int d1_displaytriggerupdate( d1_device *handle ); + +//-------------------------------------------------------------------------- +// function: d1_displayupdate +// +// Apply new display controller settings and update screen. +// +// parameters: +// handle - device handle (see ) +// +// Activates all new settings made by d1_displayset... functions since +// last update during next vertical blanking. +// Returns after next vertical blanking. +// +// returns: +// boolean success +// +extern int d1_displayupdate( d1_device *handle ); + +extern void * d1_displaygetactivelayersource( d1_device *handle, int layer ); + +//-------------------------------------------------------------------------- +// function: d1_displaygetcaps +// +// Query display controller/layer capabilities. +// +// parameters: +// handle - device handle (see ) +// +// returns: +// pointer to () +// +extern const d1_displaycaps * d1_displaygetcaps( d1_device *handle ); +#endif /* Dx4 */ + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/drivers/tes/dave2d/inc/dave_driver.h b/drivers/tes/dave2d/inc/dave_driver.h new file mode 100644 index 00000000..cfb52755 --- /dev/null +++ b/drivers/tes/dave2d/inc/dave_driver.h @@ -0,0 +1,681 @@ +/*-------------------------------------------------------------------------- + * Project: D/AVE + * File: dave_driver.h (%version: 69 %) + * created Mon Jan 10 13:38:57 2005 by hh04027 + * + * Description: + * %date_modified: Thu Apr 26 16:21:32 2007 % (%derived_by: hh74036 %) + * + * This is the only include file that should be read by driver applications + * See html documentation + * + * Changes: + * 2007-08-29 ASc Include headers of level0/1 driver and math pkg, + * removed tabs, changed C++ to C comments + * 2007-09-20 ASc Added blit flags for wrapping + * 2008-04-30 MRe added RLE and subbyte formats + * 2008-06-12 MRe added CLUT256 and color keying + * 2008-07-14 ASt added additional performance counter values + * 2009-01-16 MRe added defines for feature bits from dave_registermap.h + * 2009-03-06 LBe added enum constant for render buffer execute flags + * 2009-03-11 MRe incremented version to 3.2 + * 2010-02-18 MRe incremented version to 3.3 for Alpha blending feature + * 2010-03-18 MRe new enum d2_blendflags + * 2010-07-08 MRe new device flag d2_df_no_registercaching + * 2010-09-13 MRe incremented version to 3.4 beta (due to merge from branch) + * 2010-09-15 MRe removed d0 memory functions, replaced by d1 memory functions + * 2010-09-22 MRe fixed typo of dc_cc_rgb, dc_cc_all + * 2011-03-11 MRe improved/removed context backup for blit + * 2011-03-14 MRe version 3.4 + * 2011-05-30 MRe version 3.5 beta + * 2011-06-16 MRe added Alpha4, Alpha2, Alpha1 texture formats + * 2012-09-05 MRe version 3.7 + * 2012-09-25 BSp MISRA cleanup + * 2012-10-19 MRe version 3.8 +*-------------------------------------------------------------------------- */ + +#ifndef __1_dave_driver_h_H +#define __1_dave_driver_h_H +#ifdef __cplusplus +extern "C" { +#endif +/*--------------------------------------------------------------------------- */ + +#define D2_VERSION_MAJOR 3 +#define D2_VERSION_MINOR 17 +#define D2_VERSION_STATE "" /*"beta"*/ +#define D2_VERSION_BRANCH 0 + +#if (D2_VERSION_BRANCH == 0) + #define D2_VERSION_BRANCH_STRING +#elif (D2_VERSION_BRANCH == 1) + #define D2_VERSION_BRANCH_STRING Branch_1 +#endif + +/*--------------------------------------------------------------------------- + Title: Basic Types + + Note that several types represent fixedpoint numbers. + The C compiler cannot directly create these from constants. + Therefore if you want to pass an integer value of 42 to a + function that expects an argument of e.g. type you would have to write : + > function( 42 << 4 ); // conversion from integer to fixedpoint + see also +*/ + +#ifndef __1_dave_base_h_H +typedef void d1_device; +#endif + +#include + + +/*---------------------------------------------------------------------------*/ +#define D2_EXTERN extern + + +/*--------------------------------------------------------------------------- + Type: d2_device + void + + Abstract type. The application uses pointers of this type to hold the address of a device structure + without knowing its internal layout. + + see for example : +*/ +typedef void d2_device; + +/*--------------------------------------------------------------------------- + Type: d2_context + void + + Abstract type. The application uses pointers of this type to hold the address of a context structure + without knowing its internal layout. + + see for example : +*/ +typedef void d2_context; + +/*--------------------------------------------------------------------------- + Type: d2_renderbuffer + void + + Abstract type. The application uses pointers of this type to hold the address of a renderbuffer structure + without knowing its internal layout. + + see for example : +*/ +typedef void d2_renderbuffer; + +/*--------------------------------------------------------------------------- + Type: d2_color + unsigned long + + 32bit RGB value. Upper 8bits are ignored but should be set to zero. + All colors are passed to the driver in this format regardless of the framebuffer format. + + see for example : +*/ +typedef d2_u32 d2_color; + +/*--------------------------------------------------------------------------- + Type: d2_alpha + unsigned char + + Alpha information is passed as 8bit values. 255 representing fully opaque and 0 totally + transparent colors. + + see for example : +*/ +typedef d2_u8 d2_alpha; + +/*--------------------------------------------------------------------------- + Type: d2_width + short (*fixedpoint*) + + Width is defined as an unsigned 10:4 fixedpoint number (4 bits fraction). + So the maximum width is 1023 and the smallest nonzero width is 1/16. +*/ +typedef d2_s16 d2_width; + +/*--------------------------------------------------------------------------- + Type: d2_point + short (*fixedpoint*) + + Point defines a vertex component (e.g. the x coordinate of an endpoint) pixel position + and is specified as a signed 1:11:4 fixedpoint number (1bit sign, 11 bits integer, 4 bits fraction). + So the integer range is 2047 to -2048 and the smallest positive value is 1/16. + + Points are stored as 16bit quantities because they represent direct screen coordinates + and therefor do not become larger than 2047 even for HDTV resolutions. + + see for example : +*/ +typedef d2_s16 d2_point; + +/*--------------------------------------------------------------------------- +Type: d2_border + short + + The border type is used only when setting clip borders. In contrast to points, borders do + not contain any fractional information (no subpixel clipping) and are simple 11bit signed + integers. + + see for example : +*/ +typedef d2_s16 d2_border; + +/*--------------------------------------------------------------------------- + Type: d2_pattern + unsigned long + + Patterns are Nbit bitmasks (N is 32 at most so they are passed as longs) + + see for example : +*/ +typedef d2_u32 d2_pattern; + +/*--------------------------------------------------------------------------- + Type: d2_blitpos + unsigned short + + Blitpos defines an integer position in the source bitmap of a blit rendering operation. + The allowed range is 0 to 1023. +*/ +typedef d2_u16 d2_blitpos; + + +/*--------------------------------------------------------------------------- + * enums */ + +typedef d2_u32 d2_rendermodes; + +#define d2_rm_solid 1u +#define d2_rm_outline 2u +#define d2_rm_solid_outlined ((d2_u32)(1 + 2)) +#define d2_rm_shadow 4u +#define d2_rm_solid_shadow ((d2_u32)(1 + 4)) +#define d2_rm_postprocess 8u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_blendmodes; + +#define d2_bm_zero 0u +#define d2_bm_one 1u +#define d2_bm_alpha 2u +#define d2_bm_one_minus_alpha 3u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_alphamodes; + +#define d2_am_opaque 0u +#define d2_am_constant 1u +#define d2_am_gradient1 2u +#define d2_am_gradient2 4u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_fillmodes; + +#define d2_fm_color 0u +#define d2_fm_twocolor 1u +#define d2_fm_pattern 2u +#define d2_fm_texture 3u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_edgeflags; + +#define d2_edge0_shared 1u +#define d2_edge1_shared 2u +#define d2_edge2_shared 4u +#define d2_edge3_shared 8u +#define d2_edge4_shared 16u +#define d2_edge5_shared 32u + +#define d2_all_shared 63u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_wedgeflags; + +#define d2_wf_concave (d2_all_shared + 1) + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_linecapflags; + +#define d2_lc_butt 0u +#define d2_lc_square 1u +#define d2_lc_round 2u + +#define d2_lc_max 3u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_linejoinflags; + +#define d2_lj_none 0u +#define d2_lj_miter 1u +#define d2_lj_round 2u +#define d2_lj_bevel 4u + +#define d2_lj_max 7u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_lineendflags; + +#define d2_le_exclude_none 0u +#define d2_le_exclude_start 1u +#define d2_le_exclude_end 2u +#define d2_le_exclude_both 3u +#define d2_le_closed 4u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_segmentflags; + +#define d2_sf_none 0u +#define d2_sf_skip 1u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_modeflags; + +#define d2_mode_alpha8 0u +#define d2_mode_rgb565 1u + +#define d2_mode_argb8888 2u +#define d2_mode_argb4444 3u +#define d2_mode_argb1555 4u + +#define d2_mode_ai44 5u + +#define d2_mode_rgba8888 6u +#define d2_mode_rgba4444 7u +#define d2_mode_rgba5551 8u + +#define d2_mode_i8 9u +#define d2_mode_i4 10u +#define d2_mode_i2 11u +#define d2_mode_i1 12u + +#define d2_mode_alpha4 13u +#define d2_mode_alpha2 14u +#define d2_mode_alpha1 15u + +#define d2_mode_rgb888 64u /* used driver internally */ +#define d2_mode_rgb444 65u /* used driver internally */ +#define d2_mode_rgb555 66u /* used driver internally */ + + /* following additional flags can be ored together with previous modes: */ +#define d2_mode_rle 16u /* RLE decoder is used */ +#define d2_mode_clut 32u /* CLUT 256 is used */ + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_getcontextmodes; + +#define d2_context_default 0u +#define d2_context_selected 1u +#define d2_context_solid 2u +#define d2_context_outline 3u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_textureoperations; + +#define d2_to_zero 0u +#define d2_to_one 1u +#define d2_to_replace 2u +#define d2_to_copy 3u +#define d2_to_invert 4u +#define d2_to_multiply 5u +#define d2_to_invmultiply 6u +#define d2_to_blend 7u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_colorchannels; + +#define d2_cc_alpha 1u +#define d2_cc_red 2u +#define d2_cc_green 4u +#define d2_cc_blue 8u +#define d2_cc_rgb 14u +#define d2_cc_all 15u +#define dc_cc_rgb d2_cc_rgb /* backward compatibility */ +#define dc_cc_all d2_cc_all /* backward compatibility */ + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_texturemodes; + +#define d2_tm_wrapu 1u +#define d2_tm_wrapv 2u +#define d2_tm_filteru 4u +#define d2_tm_filterv 8u +#define d2_tm_filter 12u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_patternmodes; + +#define d2_pm_filter 1u +#define d2_pm_autoalign 2u +#define d2_pm_advance 4u +#define d2_pm_orthogonal 8u /* TES unsupported parameter */ + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_blitflags; + +#define d2_bf_filteru d2_tm_filteru +#define d2_bf_filterv d2_tm_filterv +#define d2_bf_filter d2_tm_filter +#define d2_bf_wrapu d2_tm_wrapu +#define d2_bf_wrapv d2_tm_wrapv +#define d2_bf_wrap (d2_tm_wrapu | d2_tm_wrapv) +#define d2_bf_colorize (d2_bf_filterv * 2) +#define d2_bf_usealpha (d2_bf_colorize * 2) +#define d2_bf_colorize2 (d2_bf_usealpha * 2) +#define d2_bf_invertalpha (d2_bf_colorize2 * 2) +#define d2_bf_no_blitctxbackup (d2_bf_invertalpha * 2) +#define d2_bf_mirroru (d2_bf_no_blitctxbackup * 2) +#define d2_bf_mirrorv (d2_bf_mirroru * 2) + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_deviceflags; + +#define d2_df_no_dlist 1u +#define d2_df_no_irq 2u +#define d2_df_no_fbcache 4u +#define d2_df_no_texcache 8u +#define d2_df_no_dwclear 16u +#define d2_df_no_registercaching 32u +#define d2_df_no_blitctxbackup 64u + +/*--------------------------------------------------------------------------- */ + +enum d2_perfcountevents +{ + d2_pc_disable = 0, + d2_pc_davecycles = 1, + d2_pc_fbreads = 2, + d2_pc_fbwrites = 3, + d2_pc_texreads = 4, + d2_pc_invpixels = 5, + d2_pc_invpixels_miss = 6, + d2_pc_dlrcycles = 7, + d2_pc_fbreadhits = 8, + d2_pc_fbreadmisses = 9, + d2_pc_fbwritehits = 10, + d2_pc_fbwritemisses = 11, + d2_pc_texreadhits = 12, + d2_pc_texreadmisses = 13, + d2_pc_cpudatareads = 14, + d2_pc_cpudatawrites = 15, + d2_pc_cpuinstrreads = 16, + + d2_pc_dlrburstreads = 17, + d2_pc_dlrwordsread = 18, + + d2_pc_rlerewinds = 20, + d2_pc_texburstreads = 21, + d2_pc_texwordsread = 22, + d2_pc_fbburstreads = 23, + d2_pc_fbwordsread = 24, + d2_pc_fbburstwrites = 25, + d2_pc_fbwordswritten = 26, + + d2_pc_fbrwconflicts = 28, + d2_pc_fbrwconflictcycles = 29, + d2_pc_noevent = 30, + d2_pc_clkcycles = 31 +}; + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_executeflags; + +#define d2_ef_default 0u +#define d2_ef_execute_once 0u +#define d2_ef_execute_multiple 1u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_blendflags; + +#define d2_blendf_default 0u +#define d2_blendf_blenddst 0u +#define d2_blendf_blendcolor2 1u + +/*--------------------------------------------------------------------------- */ + +typedef d2_u32 d2_adddlistflags; + +#define d2_al_default 0u /* default behavior */ +#define d2_al_copy 0u /* content will be copied */ +#define d2_al_no_copy 1u /* jump to the dlist will be added */ + +/*--------------------------------------------------------------------------- + * basic functions */ + +D2_EXTERN d2_s32 d2_getversion( void ); +D2_EXTERN const d2_char *d2_getversionstring( void ); +D2_EXTERN d2_device * d2_opendevice( d2_u32 flags ); +D2_EXTERN d2_s32 d2_closedevice( d2_device *handle ); +D2_EXTERN d2_s32 d2_geterror( const d2_device *handle ); +D2_EXTERN const d2_char *d2_geterrorstring( const d2_device *handle ); +D2_EXTERN const d2_char *d2_translateerror( d2_s32 errorcode ); +D2_EXTERN d2_s32 d2_inithw( d2_device *handle, d2_u32 flags ); +D2_EXTERN d2_s32 d2_deinithw( d2_device *handle ); +D2_EXTERN d1_device * d2_level1interface( const d2_device *handle ); +D2_EXTERN d2_u32 d2_getrevisionhw( const d2_device *handle ); +D2_EXTERN const d2_char* d2_getrevisionstringhw( const d2_device *handle); +D2_EXTERN d2_s32 d2_setdlistblocksize(d2_device *handle, d2_u32 size); +D2_EXTERN d2_u32 d2_getdlistblocksize(const d2_device *handle); +D2_EXTERN d2_u32 d2_getdlistblockcount(d2_device *handle); +D2_EXTERN d2_s32 d2_commandspending(d2_device *handle); +D2_EXTERN d2_s32 d2_lowlocalmemmode(d2_device *handle, d2_u32 dlistblockfactor, d2_u32 dlistblocks); + +/*--------------------------------------------------------------------------- + * context management */ + +D2_EXTERN d2_context * d2_newcontext( d2_device *handle ); +D2_EXTERN d2_s32 d2_freecontext( d2_device *handle, d2_context *ctx ); +D2_EXTERN d2_s32 d2_selectcontext( d2_device *handle, d2_context *ctx ); +D2_EXTERN d2_s32 d2_solidcontext( d2_device *handle, d2_context *ctx ); +D2_EXTERN d2_s32 d2_outlinecontext( d2_device *handle, d2_context *ctx ); +D2_EXTERN d2_context * d2_getcontext( d2_device *handle, d2_s32 mode ); + +/*--------------------------------------------------------------------------- + * device */ + +D2_EXTERN d2_s32 d2_framebuffer( d2_device *handle, void *ptr, d2_s32 pitch, d2_u32 width, d2_u32 height, d2_s32 format ); +D2_EXTERN d2_s32 d2_cliprect( d2_device *handle, d2_border xmin, d2_border ymin, d2_border xmax, d2_border ymax ); +D2_EXTERN d2_s32 d2_flushframe( d2_device *handle ); +D2_EXTERN d2_s32 d2_startframe( d2_device *handle ); +D2_EXTERN d2_s32 d2_endframe( d2_device *handle ); +D2_EXTERN d2_s32 d2_relocateframe( d2_device *handle, const void *ptr ); +D2_EXTERN d2_s32 d2_clear( d2_device *handle, d2_color color ); +D2_EXTERN d2_s32 d2_getcliprect( d2_device *handle, d2_border *xmin, d2_border *ymin, d2_border *xmax, d2_border *ymax ); +D2_EXTERN d2_s32 d2_getframebuffer( d2_device *handle, void** ptr, d2_s32* pitch, d2_u32* width, d2_u32* height, d2_s32* format); + +/*--------------------------------------------------------------------------- + * device global attributes */ + +D2_EXTERN d2_s32 d2_selectrendermode( d2_device *handle, d2_u32 mode ); +D2_EXTERN d2_s32 d2_outlinewidth( d2_device *handle, d2_width width ); +D2_EXTERN d2_s32 d2_shadowoffset( d2_device *handle, d2_point x, d2_point y ); +D2_EXTERN d2_u32 d2_getrendermode( const d2_device *handle ); +D2_EXTERN d2_s32 d2_layermerge( d2_device *handle ); + +/*--------------------------------------------------------------------------- + * renderbuffer management */ + +D2_EXTERN d2_renderbuffer * d2_newrenderbuffer( d2_device *handle, d2_u32 initialsize, d2_u32 stepsize ); +D2_EXTERN d2_s32 d2_freerenderbuffer( d2_device *handle, d2_renderbuffer *buffer ); +D2_EXTERN d2_s32 d2_selectrenderbuffer( d2_device *handle, d2_renderbuffer *buffer ); +D2_EXTERN d2_s32 d2_executerenderbuffer( d2_device *handle, d2_renderbuffer *buffer, d2_u32 flags ); +D2_EXTERN d2_renderbuffer * d2_getrenderbuffer( d2_device *handle, d2_s32 index ); +D2_EXTERN d2_s32 d2_dumprenderbuffer( d2_device *handle, d2_renderbuffer *buffer, void **rdata, d2_s32 *rsize ); +D2_EXTERN d2_u32 d2_getrenderbuffersize(d2_device *handle, d2_renderbuffer *rb); +D2_EXTERN d2_s32 d2_freedumpedbuffer( d2_device *handle, void *data ); + +/*--------------------------------------------------------------------------- + * context attribute writes */ + +D2_EXTERN d2_s32 d2_setcolor( d2_device *handle, d2_s32 index, d2_color color ); +D2_EXTERN d2_s32 d2_setalpha( d2_device *handle, d2_alpha alpha ); +D2_EXTERN d2_s32 d2_setalphaex( d2_device *handle, d2_s32 index, d2_alpha alpha ); +D2_EXTERN d2_s32 d2_setblur( d2_device *handle, d2_width blur ); +D2_EXTERN d2_s32 d2_setblendmode( d2_device *handle, d2_u32 srcfactor, d2_u32 dstfactor ); +D2_EXTERN d2_s32 d2_setalphablendmode( d2_device *handle, d2_u32 srcfactor, d2_u32 dstfactor ); +D2_EXTERN d2_s32 d2_setalphablendmodeex( d2_device *handle, d2_u32 srcfactor, d2_u32 dstfactor, d2_u32 blendflags ); +D2_EXTERN d2_s32 d2_setalphagradient( d2_device *handle, d2_s32 index, d2_point x, d2_point y, d2_point dx, d2_point dy ); +D2_EXTERN d2_s32 d2_setclipgradient( d2_device *handle, d2_s32 index, d2_point x, d2_point y, d2_s32 nx, d2_s32 ny, d2_u32 flags ); +D2_EXTERN d2_s32 d2_setalphamode( d2_device *handle, d2_u32 mode ); +D2_EXTERN d2_s32 d2_setantialiasing( d2_device *handle, d2_s32 enable ); +D2_EXTERN d2_s32 d2_setpatternalpha( d2_device *handle, d2_s32 index, d2_alpha alpha ); +D2_EXTERN d2_s32 d2_setfillmode( d2_device *handle, d2_u32 mode ); +D2_EXTERN d2_s32 d2_setpattern( d2_device *handle, d2_pattern pattern ); +D2_EXTERN d2_s32 d2_setpatternparam( d2_device *handle, d2_point x, d2_point y, d2_width dx, d2_width dy ); +D2_EXTERN d2_s32 d2_setpatternmode( d2_device *handle, d2_u32 mode ); +D2_EXTERN d2_s32 d2_setpatternsize( d2_device *handle, d2_s32 size ); +D2_EXTERN d2_s32 d2_setlinecap( d2_device *handle, d2_u32 mode ); +D2_EXTERN d2_s32 d2_setlinejoin( d2_device *handle, d2_u32 mode ); +D2_EXTERN d2_s32 d2_setlinepattern( d2_device *handle, d2_width scale, d2_s32 offset ); +D2_EXTERN d2_s32 d2_setmiterlimit( d2_device *handle, d2_width miter ); +D2_EXTERN d2_s32 d2_settexture( d2_device *handle, void *ptr, d2_s32 pitch, d2_s32 width, d2_s32 height, d2_u32 format ); +D2_EXTERN d2_s32 d2_settexturemode( d2_device *handle, d2_u32 mode ); +D2_EXTERN d2_s32 d2_settextureoperation( d2_device *handle, d2_u8 amode, d2_u8 rmode, d2_u8 gmode, d2_u8 bmode ); +D2_EXTERN d2_s32 d2_settexopparam( d2_device *handle, d2_u32 index, d2_u32 p1, d2_u32 p2 ); +D2_EXTERN d2_s32 d2_settexturemapping( d2_device *handle, d2_point x, d2_point y, d2_s32 u0, d2_s32 v0, d2_s32 dxu, d2_s32 dyu, d2_s32 dxv, d2_s32 dyv ); +D2_EXTERN d2_s32 d2_settexelcenter( d2_device *handle, d2_point x, d2_point y ); +D2_EXTERN d2_s32 d2_settexclut( d2_device *handle, d2_color* clut ); +D2_EXTERN d2_s32 d2_settexclut_part( d2_device *handle, const d2_color* clut_part, d2_u32 start_index, d2_u32 length ); +D2_EXTERN d2_s32 d2_writetexclut_direct( d2_device *handle, const d2_color* clut_part, d2_u32 start_index, d2_u32 length ); +D2_EXTERN d2_s32 d2_settexclut_offset( d2_device *handle, d2_u32 offset ); +D2_EXTERN d2_s32 d2_settexclut_format( d2_device *handle, d2_u32 format ); +D2_EXTERN d2_s32 d2_setcolorkey( d2_device *handle, d2_s32 enable, d2_color color_key ); +D2_EXTERN d2_s32 d2_setcircleextend( d2_device *handle, d2_width offset ); + +/*--------------------------------------------------------------------------- + * context attritbute reads */ + +D2_EXTERN d2_color d2_getcolor( d2_device *handle, d2_s32 index ); +D2_EXTERN d2_alpha d2_getalpha( d2_device *handle ); +D2_EXTERN d2_alpha d2_getalphaex( d2_device *handle, d2_s32 index ); +D2_EXTERN d2_width d2_getblur( d2_device *handle ); +D2_EXTERN d2_u32 d2_getblendmodesrc( d2_device *handle ); +D2_EXTERN d2_u32 d2_getblendmodedst( d2_device *handle ); +D2_EXTERN d2_u32 d2_getalphablendmodesrc( d2_device *handle ); +D2_EXTERN d2_u32 d2_getalphablendmodedst( d2_device *handle ); +D2_EXTERN d2_u8 d2_getalphablendmodeflags( d2_device *handle ); +D2_EXTERN d2_u8 d2_getalphamode( d2_device *handle ); +D2_EXTERN d2_s32 d2_getantialiasing( d2_device *handle ); +D2_EXTERN d2_alpha d2_getpatternalpha( d2_device *handle, d2_s32 index ); +D2_EXTERN d2_u8 d2_getfillmode( d2_device *handle ); +D2_EXTERN d2_pattern d2_getpattern( d2_device *handle ); +D2_EXTERN d2_u32 d2_getpatternmode( d2_device *handle ); +D2_EXTERN d2_s32 d2_getpatternsize( d2_device *handle ); +D2_EXTERN d2_u8 d2_getlinecap( d2_device *handle ); +D2_EXTERN d2_u8 d2_getlinejoin( d2_device *handle ); +D2_EXTERN d2_u8 d2_gettextureoperationa( d2_device *handle ); +D2_EXTERN d2_u8 d2_gettextureoperationr( d2_device *handle ); +D2_EXTERN d2_u8 d2_gettextureoperationg( d2_device *handle ); +D2_EXTERN d2_u8 d2_gettextureoperationb( d2_device *handle ); +D2_EXTERN d2_alpha d2_gettexopparam1( d2_device *handle, d2_u32 index ); +D2_EXTERN d2_alpha d2_gettexopparam2( d2_device *handle, d2_u32 index ); + +/*--------------------------------------------------------------------------- + * rendering commands */ + +D2_EXTERN d2_s32 d2_renderbox( d2_device *handle, d2_point x1, d2_point y1, d2_width w, d2_width h ); +D2_EXTERN d2_s32 d2_renderline( d2_device *handle, d2_point x1, d2_point y1, d2_point x2, d2_point y2, d2_width w, d2_u32 flags ); +D2_EXTERN d2_s32 d2_rendertri( d2_device *handle, d2_point x1, d2_point y1, d2_point x2, d2_point y2, d2_point x3, d2_point y3, d2_u32 flags ); +D2_EXTERN d2_s32 d2_renderquad( d2_device *handle, d2_point x1, d2_point y1, d2_point x2, d2_point y2, d2_point x3, d2_point y3, d2_point x4, d2_point y4, d2_u32 flags ); +D2_EXTERN d2_s32 d2_rendercircle( d2_device *handle, d2_point x, d2_point y, d2_width r, d2_width w ); +D2_EXTERN d2_s32 d2_renderwedge( d2_device *handle, d2_point x, d2_point y, d2_width r, d2_width w, d2_s32 nx1, d2_s32 ny1, d2_s32 nx2, d2_s32 ny2, d2_u32 flags ); +D2_EXTERN d2_s32 d2_renderline2( d2_device *handle, d2_point x1, d2_point y1, d2_point x2, d2_point y2, d2_width w1, d2_width w2, d2_u32 flags ); + +D2_EXTERN d2_s32 d2_renderpolyline( d2_device *handle, const d2_point *data, d2_u32 count, d2_width w, d2_u32 flags); +D2_EXTERN d2_s32 d2_renderpolyline2( d2_device *handle, const d2_point *data, d2_u32 count, const d2_width *w, d2_u32 flags); +D2_EXTERN d2_s32 d2_rendertrilist( d2_device *handle, const d2_point *data, const d2_u32 *flags, d2_u32 count); +D2_EXTERN d2_s32 d2_rendertrifan( d2_device *handle, const d2_point *data, const d2_u32 *flags, d2_u32 count); +D2_EXTERN d2_s32 d2_rendertristrip( d2_device *handle, const d2_point *data, const d2_u32 *flags, d2_u32 count); +D2_EXTERN d2_s32 d2_renderpolygon( d2_device *handle, const d2_point *data, d2_u32 count, d2_u32 flags); + +/*--------------------------------------------------------------------------- + * blit attributes write */ + +D2_EXTERN d2_s32 d2_setblitsrc( d2_device *handle, void *ptr, d2_s32 pitch, d2_s32 width, d2_s32 height, d2_u32 format ); + +/*--------------------------------------------------------------------------- + * blit rendering functions */ + +D2_EXTERN d2_s32 d2_blitcopy( d2_device *handle, d2_s32 srcwidth, d2_s32 srcheight, d2_blitpos srcx, d2_blitpos srcy, d2_width dstwidth, d2_width dstheight, d2_point dstx, d2_point dsty, d2_u32 flags ); + +/*--------------------------------------------------------------------------- + * performance measurement */ +D2_EXTERN d2_s32 d2_setperfcountevent( d2_device *handle, d2_u32 counter, d2_u32 event ); +D2_EXTERN d2_s32 d2_setperfcountvalue( d2_device *handle, d2_u32 counter, d2_slong value ); +D2_EXTERN d2_slong d2_getperfcountvalue( d2_device *handle, d2_u32 counter ); + +/*--------------------------------------------------------------------------- + * Utility Functions */ + +d2_s32 d2_utility_maptriangle ( d2_device *handle, const d2_f32 *points, const d2_f32 *uvs ); +d2_s32 d2_utility_perspectivewarp( d2_device *handle, d2_u16 srcwidth, d2_u16 srcheight, d2_s16 srcx, d2_s16 srcy, d2_s16 dstwidth, d2_s16 dstheight, d2_s16 dstx, d2_s16 dsty, d2_u16 wt ); +d2_s32 d2_utility_fbblitcopy ( d2_device *handle, d2_u16 width, d2_u16 height, d2_blitpos srcx, d2_blitpos srcy, d2_blitpos dstx, d2_blitpos dsty, d2_u32 flags); +void d2_rendercircle_no_hilimiterprecision( d2_device *handle, d2_u32 flag ); + + + +/*--------------------------------------------------------------------------- + * Dlist Functions */ + +d2_s32 d2_executedlist( d2_device *handle, const void *address, d2_u32 flags ); +d2_s32 d2_adddlist( d2_device *handle, void *address, d2_s32 size, d2_u32 flags ); + +/*--------------------------------------------------------------------------- + * assign errorcode IDs */ + +#define ERR(x,y) x, +enum d2_errorcodes { +#include "dave_errorcodes.h" +D2_ERROR_QUANTITY }; +#undef ERR + +/*--------------------------------------------------------------------------- + * include header files of level0 and level1 driver */ + +#include "dave_base.h" +#include "dave_math.h" + +/*--------------------------------------------------------------------------- +* define feature bits of hardware revision */ +// #define BIT(x) (1u << (x)) +#define D2FB_SWDAVE BIT(16) +#define D2FB_DLR BIT(17) +#define D2FB_FBCACHE BIT(18) +#define D2FB_TXCACHE BIT(19) +#define D2FB_PERFCOUNT BIT(20) +#define D2FB_TEXCLUT BIT(21) +#define D2FB_FBPREFETCH BIT(22) +#define D2FB_RLEUNIT BIT(23) +#define D2FB_TEXCLUT256 BIT(24) +#define D2FB_COLORKEY BIT(25) +#define D2FB_HILIMITERPRECISION BIT(26) +#define D2FB_ALPHACHANNELBLENDING BIT(27) + +/*--------------------------------------------------------------------------- */ +#ifdef __cplusplus +} +#endif +#endif diff --git a/drivers/tes/dave2d/inc/dave_errorcodes.h b/drivers/tes/dave2d/inc/dave_errorcodes.h new file mode 100644 index 00000000..1825fe55 --- /dev/null +++ b/drivers/tes/dave2d/inc/dave_errorcodes.h @@ -0,0 +1,72 @@ +/*-------------------------------------------------------------------------- + * Project: D/AVE + * File: dave_errorcodes.h (%version: 9 %) + * created Tue Jan 11 13:41:35 2005 by hh04027 + * + * Description: + * %date_modified: Mon Feb 19 15:59:15 2007 % (%derived_by: hh74036 %) + * + * Changes: + * 2007-08-31 ASc - removed tabs, changed C++ to C comments, + *-------------------------------------------------------------------------- */ + +/* Title: Errorcodes + * List of all dave driver errorcodes. + * + * Every device stores the errorcode returned by the last function executed + * for this device. Successfull operations reset this code to D2_OK. + * + * Latest errorcode can be queried by / functions + * + * Errorcodes: + * + * D2_OK - success + * D2_NOMEMORY - memory allocation failed + * D2_INVALIDDEVICE - invalid device + * D2_INVALIDCONTEXT - invalid rendering context + * D2_INVALIDBUFFER - invalid renderbuffer context + * D2_HWINUSE - hardware device already in use + * D2_DEVASSIGNED - device already assigned + * D2_DEFCONTEXT - cannot operate on default context + * D2_INVALIDINDEX - index is out of bounds + * D2_ILLEGALMODE - rendermode not supported + * D2_INVALIDWIDTH - width out of legal range + * D2_INVALIDHEIGHT - height out of legal range + * D2_NOVIDEOMEM - illegal framebuffer address + * D2_VALUETOOSMALL - parameter too close to zero + * D2_VALUENEGATIVE - parameter is negative + * D2_VALUETOOBIG - parameter value is too large + * D2_INVALIDENUM - unsupported mode + * D2_NULLPOINTER - source pointer may not be null + * D2_DEVICEBUSY - operation cannot execute while hardware is busy + * D2_DEFBUFFER - cannot operate on default buffer + * D2_NO_DISPLAYLIST - usage of displaylists a mandatory in d2_low_localmemmode + * D2_NOT_ENOUGH_DLISTBLOCKS - amount of displaylist blocks as specified in is not sufficient + * */ + +/*--------------------------------------------------------------------------- */ + + ERR( D2_OK , "success" ) + ERR( D2_NOMEMORY , "memory allocation failed" ) + ERR( D2_INVALIDDEVICE , "invalid device" ) + ERR( D2_INVALIDCONTEXT , "invalid rendering context" ) + ERR( D2_INVALIDBUFFER , "invalid renderbuffer context" ) + ERR( D2_HWINUSE , "hardware device already in use" ) + ERR( D2_DEVASSIGNED , "device already assigned" ) + ERR( D2_DEFCONTEXT , "cannot operate on default context" ) + ERR( D2_INVALIDINDEX , "index is out of bounds" ) + ERR( D2_ILLEGALMODE , "rendermode not supported" ) + ERR( D2_INVALIDWIDTH , "width out of legal range" ) + ERR( D2_INVALIDHEIGHT , "height out of legal range" ) + ERR( D2_NOVIDEOMEM , "illegal framebuffer address" ) + ERR( D2_VALUETOOSMALL , "parameter too close to zero" ) + ERR( D2_VALUENEGATIVE , "parameter is negative" ) + ERR( D2_VALUETOOBIG , "parameter value is too large" ) + ERR( D2_INVALIDENUM , "unsupported mode" ) + ERR( D2_NULLPOINTER , "source pointer may not be null" ) + ERR( D2_DEVICEBUSY , "operation cannot execute while hardware is busy" ) + ERR( D2_DEFBUFFER , "cannot operate on default buffer" ) + ERR( D2_NO_DISPLAYLIST , "d2_df_no_dlist is not supported in low_localmemmode") + ERR( D2_NOT_ENOUGH_DLISTBLOCKS , "not enough dlistblocks. please adjust in d2_lowlocalmemmode(...)") + +/*--------------------------------------------------------------------------- */ diff --git a/drivers/tes/dave2d/inc/dave_math.h b/drivers/tes/dave2d/inc/dave_math.h new file mode 100644 index 00000000..afed0a7e --- /dev/null +++ b/drivers/tes/dave2d/inc/dave_math.h @@ -0,0 +1,111 @@ +/*-------------------------------------------------------------------------- + * Project: D/AVE + * File: dave_math.h (%version: 4 %) + * created Thu Jan 13 09:41:58 2005 by hh04027 + * + * Description: + * %date_modified: Thu Jul 14 14:56:48 2005 % (%derived_by: hh04027 %) + * + * Changes: + * 2007-08-29 ASc - remove tabs, add ndoc comments, change C++ to C comments + * 2007-12-06 ASc - fixed macro name in description of D2_FIX4 + *-------------------------------------------------------------------------- */ + +/*-------------------------------------------------------------------------- + * Title: Math Functions + * Package of useful macros and functions e.g. for fixedpoint operations. + * + *-------------------------------------------------------------------------- */ + + +#ifndef __1_dave_math_h_H +#define __1_dave_math_h_H +/*--------------------------------------------------------------------------- */ + + + +/* Group: Fixedpoint Macros */ + + +/* Function: D2_FIX4(x) + * Integer to n:4 fixedpoint conversion */ +#define D2_FIX4(x) ((x) << 4) /* PRQA S 4131 */ /* $Misra: #PERF_ARITHMETIC_SHIFT_LEFT $*/ + +/* Macro: D2_INT4(x) + * n:4 to integer conversion */ +#define D2_INT4(x) ((x) >> 4) /* PRQA S 0502 */ /* $Misra: #PERF_ARITHMETIC_SHIFT_RIGHT $*/ + +/* Macro: D2_FLOOR4(x) + * n:4 fixedpoint unsigned floor (round towards -inf) */ +#define D2_FLOOR4(x) (((d2_u32)(x)) & ~15u) + +/* Macro: D2_CEIL4(x) + * n:4 fixedpoint unsigned ceil (round towards +inf) */ +#define D2_CEIL4(x) ((((d2_u32)(x)) + 15u) & ~15u) + +/* Macro: D2_FRAC4(x) + * n:4 fixedpoint fractional part only */ +#define D2_FRAC4(x) (((d2_u32)(x)) & 15u) + +/* Macro: D2_FIX16(x) + * integer to n:16 fixedpoint conversion */ +#define D2_FIX16(x) ((x) << 16) /* PRQA S 4131 */ /* $Misra: #PERF_ARITHMETIC_SHIFT_LEFT $*/ + +/* Macro: D2_INT16(x) +n:16 to integer conversion */ +#define D2_INT16(x) ((x) >> 16) /* PRQA S 0502 */ /* $Misra: #PERF_ARITHMETIC_SHIFT_RIGHT $*/ + +/* Macro: D2_FLOOR16(x) + * n:16 fixedpoint unsigned floor (round towards -inf) */ +#define D2_FLOOR16(x) (((d2_u32)(x)) & ~65535u) + +/* Macro: D2_CEIL16(x) + * n:16 fixedpoint unsigned ceil (round towards +inf) */ +#define D2_CEIL16(x) ((((d2_u32)(x)) + 65535u) & ~65535u) + +/* Macro: D2_FRAC16(x) + * n:16 fixedpoint fractional part only */ +#define D2_FRAC16(x) (((d2_u32)(x)) & 65535u) + +/* Macro: D2_EPSILON + * Smallest representable positive number (all fixedpoint formats) */ +#define D2_EPSILON 1 + +/*--------------------------------------------------------------------------- */ + + +/* Group: Math Functions */ + +/*-------------------------------------------------------------------------- + * Function: d2_sqrt + * Minimalistic 32->16 bit integer square root (no hw divide/multiply needed) + * unrolled for speed. + * + * parameters: + * x - fixedpoint number + * + * returns: + * the square root of x + * + * */ +D2_EXTERN d2_s32 d2_sqrt(d2_u32 x); + + +/*-------------------------------------------------------------------------- + * Function: d2_pow2mask + * Find next larger power of two minus 1 + * + * E.g. given number x=73 -> next larger power of two is 128, + * the result is 128 minus 1 = 127 (number with all bits set) + * + * parameters: + * x - positive number + * + * returns: + * the next larger number of two minus 1 of x + * + * */ +D2_EXTERN d2_u32 d2_pow2mask(d2_u32 x); + +/*--------------------------------------------------------------------------- */ +#endif diff --git a/drivers/tes/dave2d/inc/dave_types.h b/drivers/tes/dave2d/inc/dave_types.h new file mode 100644 index 00000000..cf5c8acb --- /dev/null +++ b/drivers/tes/dave2d/inc/dave_types.h @@ -0,0 +1,33 @@ +/*-------------------------------------------------------------------------- + * Project: D/AVE + * File: dave_types.h (%version: 69 %) + * created Tue Sep 25 17:31:44 2012 by hh04044 + * + * Description: + * %date_modified: Thu Apr 26 16:21:32 2007 % (%derived_by: hh74036 %) + * + * Definition of common basic types. + * + * Changes: + * 2012-09-25 BSp MISRA cleanup + * +*-------------------------------------------------------------------------- */ + +#ifndef __DAVE_TYPES_H__ +#define __DAVE_TYPES_H__ + + +typedef char d2_char; /* character */ +typedef signed char d2_s8; /* signed byte */ +typedef unsigned char d2_u8; /* unsigned byte */ +typedef unsigned short d2_u16; +typedef signed short d2_s16; +typedef signed int d2_s32; +typedef unsigned int d2_u32; +typedef unsigned long d2_ulong; /* platform-dependent: usually 32bit, sometimes 48bit. */ +typedef signed long d2_slong; +typedef float d2_f32; /* IEE754 single precision float */ +typedef double d2_f64; /* IEE754 double precision float */ + + +#endif /* __DAVE_TYPES_H__ */ diff --git a/zephyr/blobs/renesas_open_license.txt b/zephyr/blobs/renesas_open_license.txt new file mode 100644 index 00000000..4409162a --- /dev/null +++ b/zephyr/blobs/renesas_open_license.txt @@ -0,0 +1,44 @@ +## Renesas Open License v1.0 + +Copyright (c) 2020 - 2025, Renesas Electronics Corporation and/or its affiliates + + +By installing, copying, downloading, accessing, or otherwise using this software +or any part thereof and the related documentation from Renesas Electronics Corporation +and/or its affiliates ("Renesas"), You, either individually or on behalf of an entity +employing or engaging You, agree to be bound by this Software License Agreement. If you +do not agree or no longer agree, you are not permitted to use this software or related +documentation. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form, except as embedded into a Renesas + integrated circuit in a product or a software update for + such product, must reproduce the above copyright notice, this list of + conditions and the following disclaimer in the documentation and/or other + materials provided with the distribution. + +3. Neither the name of Renesas nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +4. This software, with or without modification, must only be used with a + Renesas integrated circuit, or other such integrated circuit permitted by Renesas in writing. + +5. Any software provided in binary form under this license must not be reverse + engineered, decompiled, modified and/or disassembled. + +THIS SOFTWARE IS PROVIDED BY RENESAS "AS IS" AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL RENESAS OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/zephyr/module.yml b/zephyr/module.yml index 774b5e85..6127e927 100644 --- a/zephyr/module.yml +++ b/zephyr/module.yml @@ -11,3 +11,12 @@ blobs: url: https://github.com/dialog-semiconductor/CMAC-library/raw/main/libcmac.a description: "Binary libraries with firmware for CMAC controller" doc-url: https://github.com/dialog-semiconductor/CMAC-library + # libdave2d + - path: dave2d/libdave2d.a + sha256: 1bd8bd9aac98d4fa9a3048c1b5f3228dac0ca4aa58b545122c4119c6507e2e02 + type: lib + version: '1.0' + license-path: zephyr/blobs/renesas_open_license.txt + url: https://github.com/renesas/libdave2d/raw/main/libdave2d.a + description: "Binary libraries with firmware for D/AVE 2D graphics accelerator" + doc-url: https://github.com/renesas/libdave2d diff --git a/zephyr/ra/ra_cfg/fsp_cfg/r_drw_cfg.h b/zephyr/ra/ra_cfg/fsp_cfg/r_drw_cfg.h new file mode 100644 index 00000000..31071023 --- /dev/null +++ b/zephyr/ra/ra_cfg/fsp_cfg/r_drw_cfg.h @@ -0,0 +1,14 @@ +/* generated configuration header file - do not edit */ +#ifndef R_DRW_CFG_H_ +#define R_DRW_CFG_H_ +#ifdef __cplusplus + extern "C" { + #endif + +#define DRW_CFG_USE_DLIST_INDIRECT ((1)) +#define DRW_CFG_CUSTOM_MALLOC ((1)) + +#ifdef __cplusplus + } + #endif +#endif /* R_DRW_CFG_H_ */ diff --git a/zephyr/ra/ra_gen/hal_data.h b/zephyr/ra/ra_gen/hal_data.h index 57ce0d42..b21c59c1 100644 --- a/zephyr/ra/ra_gen/hal_data.h +++ b/zephyr/ra/ra_gen/hal_data.h @@ -7,14 +7,45 @@ #ifndef HAL_DATA_H_ #define HAL_DATA_H_ #include "bsp_api.h" + +#if CONFIG_INPUT_RENESAS_RA_QE_TOUCH_CFG #include "rm_touch.h" +#endif + +#if CONFIG_LV_USE_DRAW_DAVE2D +#include "dave_base.h" +#include "dave_driver.h" +#include "dave_math.h" +#include "dave_types.h" +#include "r_glcdc.h" +#include +#include +#endif + FSP_HEADER +#if CONFIG_INPUT_RENESAS_RA_QE_TOUCH_CFG #define CTSU_WRITE_IRQn \ (DT_IRQ_BY_NAME(DT_INST(0, renesas_ra_ctsu), ctsuwr, irq)) #define CTSU_READ_IRQn \ (DT_IRQ_BY_NAME(DT_INST(0, renesas_ra_ctsu), ctsurd, irq)) #define CTSU_END_IRQn (DT_IRQ_BY_NAME(DT_INST(0, renesas_ra_ctsu), ctsufn, irq)) +#endif + +#if CONFIG_LV_USE_DRAW_DAVE2D +#define LV_ZEPHYR_INPUT_PIXEL_FORMAT \ + DT_PROP(DT_CHOSEN(zephyr_display), input_pixel_format) + +#if (LV_ZEPHYR_INPUT_PIXEL_FORMAT == PANEL_PIXEL_FORMAT_RGB_565) + #define LV_DISPLAY_INPUT_FORMAT DISPLAY_IN_FORMAT_16BITS_RGB565 +#elif (LV_ZEPHYR_INPUT_PIXEL_FORMAT == PANEL_PIXEL_FORMAT_RGB_888) + #define LV_DISPLAY_INPUT_FORMAT DISPLAY_IN_FORMAT_32BITS_RGB888 +#elif (LV_ZEPHYR_INPUT_PIXEL_FORMAT == PANEL_PIXEL_FORMAT_ARGB_8888) + #define LV_DISPLAY_INPUT_FORMAT DISPLAY_IN_FORMAT_32BITS_ARGB8888 +#else /* Unsupported format */ + #define LV_DISPLAY_INPUT_FORMAT (-1) +#endif +#endif FSP_FOOTER #endif /* HAL_DATA_H_ */