Skip to content

Commit

Permalink
update the low level sync-up scheme of the pfb helper service
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Dec 28, 2024
1 parent 63b3a90 commit 0e38976
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion ARM.Arm-2D.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
</RTE_Components_h>
</component>

<component Cclass="Acceleration" Cgroup="Arm-2D Helper" Csub="PFB" Cversion="2.5.2" condition="Arm-2D-CORE">
<component Cclass="Acceleration" Cgroup="Arm-2D Helper" Csub="PFB" Cversion="2.5.3" condition="Arm-2D-CORE">
<description>Helper services for LCD adaptor(s), e.g. Generic Partial Framebuffer, Scene Player etc.</description>
<files>
<file category="include" name="Helper/Include/" />
Expand Down
12 changes: 9 additions & 3 deletions Helper/Include/arm_2d_helper_pfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* Title: #include "arm_2d_helper_pfb.h"
* Description: Public header file for the PFB helper service
*
* $Date: 26. Dec 2024
* $Revision: V.1.12.4
* $Date: 28. Dec 2024
* $Revision: V.1.13.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -678,7 +678,13 @@ typedef struct arm_2d_helper_pfb_dependency_t {
//! event handler for drawing GUI
arm_2d_helper_draw_evt_t evtOnDrawing;

//! low level rendering handler wants to sync-up (return arm_fsm_rt_wait_for_obj)
/*! event handler for waiting LCD finish rendering previous frame
* \note when then handler return false, the refresh task will yield and return
* arm_fsm_rt_wait_async.
* when the handler return true, it means the display device finished
* rendering the previous frame and the refresh task will continue the
* following steps.
*/
arm_2d_evt_t evtOnLowLevelSyncUp;

//! event handler for each frame complete
Expand Down
36 changes: 20 additions & 16 deletions Helper/Source/arm_2d_helper_pfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* Title: #include "arm_2d_helper_pfb.c"
* Description: the pfb helper service source code
*
* $Date: 26. Dec 2024
* $Revision: V.1.12.4
* $Date: 28. Dec 2024
* $Revision: V.1.13.0
*
* Target Processor: Cortex-M cores
* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -152,8 +152,7 @@ void __arm_2d_helper_pfb_free(arm_2d_helper_pfb_t *ptThis, arm_2d_pfb_t *ptPFB)
}

/* set event */
if ( (NULL == this.tCFG.Dependency.evtOnLowLevelSyncUp.fnHandler)
&& ((uintptr_t)NULL != this.Adapter.pFPBPoolAvailable)) {
if ((uintptr_t)NULL != this.Adapter.pFPBPoolAvailable) {
arm_2d_port_set_semaphore(this.Adapter.pFPBPoolAvailable);
}

Expand Down Expand Up @@ -275,10 +274,8 @@ arm_2d_err_t arm_2d_helper_pfb_init(arm_2d_helper_pfb_t *ptThis,
}
} while(0);

if (NULL == this.tCFG.Dependency.evtOnLowLevelSyncUp.fnHandler) {
/* use default semaphore */
this.Adapter.pFPBPoolAvailable = arm_2d_port_new_semaphore();
}
/* use semaphore */
this.Adapter.pFPBPoolAvailable = arm_2d_port_new_semaphore();

/* initialize internal dirty region pool*/
do {
Expand Down Expand Up @@ -2680,9 +2677,20 @@ ARM_PT_BEGIN(this.Adapter.chPT)
assert(NULL == this.Adapter.OptimizedDirtyRegions.ptWorkingList);
assert(NULL == this.Adapter.OptimizedDirtyRegions.ptCandidateList);
}

ARM_PT_ENTRY();
/* wait until LCD finish rendering the previous frame */
if (NULL != this.tCFG.Dependency.evtOnLowLevelSyncUp.fnHandler){
// wait until lcd is ready
if (!(*this.tCFG.Dependency.evtOnLowLevelSyncUp.fnHandler)(
this.tCFG.Dependency.evtOnLowLevelSyncUp.pTarget)) {
ARM_PT_GOTO_PREV_ENTRY(arm_fsm_rt_async);
}
}

__arm_2d_helper_perf_counter_start(&this.Statistics.lTimestamp,
ARM_2D_PERFC_DRIVER);
ARM_2D_PERFC_DRIVER);

do {
/* begin of the drawing iteration,
* try to request the tile of frame buffer
Expand Down Expand Up @@ -2731,12 +2739,8 @@ ARM_PT_BEGIN(this.Adapter.chPT)
"PFB TASK",
"No PFB is available, waiting..."
);
if (NULL != this.tCFG.Dependency.evtOnLowLevelSyncUp.fnHandler){
// wait until lcd is ready
(*this.tCFG.Dependency.evtOnLowLevelSyncUp.fnHandler)(
this.tCFG.Dependency.evtOnLowLevelSyncUp.pTarget
);
} else if ((uintptr_t)NULL != this.Adapter.pFPBPoolAvailable) {

if ((uintptr_t)NULL != this.Adapter.pFPBPoolAvailable) {
arm_2d_port_wait_for_semaphore(
this.Adapter.pFPBPoolAvailable);
}
Expand Down Expand Up @@ -2801,7 +2805,7 @@ ARM_PT_BEGIN(this.Adapter.chPT)
this.Adapter.bIsNewFrame);

// just in case some one forgot to do this...
arm_2d_op_wait_async(NULL);
ARM_2D_OP_WAIT_ASYNC();

this.Statistics.nTotalCycle +=
__arm_2d_helper_perf_counter_stop( &this.Statistics.lTimestamp,
Expand Down
1 change: 0 additions & 1 deletion Library/Include/arm_2d_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,6 @@ typedef struct arm_2d_evt_t {
void *pTarget; //!< user attached target
} arm_2d_evt_t;


#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE _BV(0) //!< opcode has source tile info
#define ARM_2D_OP_INFO_PARAM_HAS_TARGET _BV(1) //!< opcode has target tile info
#define ARM_2D_OP_INFO_PARAM_HAS_SOURCE_MASK _BV(2) //!< opcode has source mask info
Expand Down
17 changes: 9 additions & 8 deletions examples/[template][pc][vscode]/platform/Virtual_TFT_Port.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,18 +314,19 @@ int32_t Disp0_DrawBitmap(int16_t x,int16_t y,int16_t width,int16_t height,const
return 0;
}

void VT_sdl_flush(int32_t nMS)
bool VT_sdl_flush(int32_t nMS)
{
nMS = MAX(1, nMS);
#if __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__
SDL_Delay(nMS);
#else
while(!sdl_refr_cpl) {

if (sdl_refr_cpl) {
sdl_refr_cpl = false;
sdl_refr_qry = true;
return true;
} else {
SDL_Delay(nMS);
}
#endif
sdl_refr_cpl = false;
sdl_refr_qry = true;

return false;
}

#if defined(_POSIX_VERSION) || defined(CLOCK_MONOTONIC) || defined(__APPLE__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef uint32_t color_typedef;
extern void VT_init(void);
extern bool VT_is_request_quit(void);
extern void VT_deinit(void);
extern void VT_sdl_flush(int32_t nMS);
extern bool VT_sdl_flush(int32_t nMS);
extern void VT_sdl_refresh_task(void);
extern void VT_enter_global_mutex(void);
extern void VT_leave_global_mutex(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ extern "C" {
// <q>Enable the helper service for 3FB (LCD Direct Mode)
// <i> You can select this option when your LCD controller supports direct mode
#ifndef __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__
# define __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__ 0
# define __DISP0_CFG_ENABLE_3FB_HELPER_SERVICE__ 1
#endif

// <q>Disable the default scene
// <i> Remove the default scene for this display adapter. We highly recommend you to disable the default scene when creating real applications.
#ifndef __DISP0_CFG_DISABLE_DEFAULT_SCENE__
# define __DISP0_CFG_DISABLE_DEFAULT_SCENE__ 0
# define __DISP0_CFG_DISABLE_DEFAULT_SCENE__ 1
#endif

// <o>Maximum number of Virtual Resources used per API
Expand Down

0 comments on commit 0e38976

Please sign in to comment.