vxkernel - v0.6.0-31 : fix vxdev + fix FPS synchronization API + disable DMA

*fix*
> [vxdev]
  | proper send script arguments
  | proper boards scanning
> [src/driver/screen/r61524]
  | disable double buffering per default
> [FPS]
  | fix FPS sync
This commit is contained in:
Yann MAGNIN 2023-01-17 22:13:43 +01:00
parent 3fb1bb296e
commit d59a8c986f
10 changed files with 43 additions and 24 deletions

View File

@ -147,10 +147,10 @@ extern int sh7305_tmu_prof_quit(timer_prof_t *prof);
#include <vhex/timer/fps.h>
/* sh7305_tmu_fps_init() : initialize fps object */
extern void sh7305_tmu_fps_init(fps_t *fps);
extern void sh7305_tmu_fps_init(fps_t *fps, int fps_target);
/* sh7305_tmu_fps_sync() : compute frame statistic and wait whanted FPS */
extern void sh7305_tmu_fps_sync(fps_t *fps, int fps_target);
extern void sh7305_tmu_fps_sync(fps_t *fps);
/* sh7305_fps_quit() : uninit the fps object */
extern void sh7305_tmu_fps_quit(fps_t *fps);

View File

@ -7,6 +7,7 @@
struct timer_fps {
int fps;
int fps_real;
int fps_target;
uint32_t render;
int32_t margin;
uint32_t objectif;
@ -15,10 +16,10 @@ struct timer_fps {
typedef struct timer_fps fps_t;
/* timer_fps_init() : initialize fps object */
extern void timer_fps_init(fps_t *fps);
extern void timer_fps_init(fps_t *fps, int fps_target);
/* timer_fps_sync() : try to syncronize to X frame per seconds */
extern void timer_fps_sync(fps_t *fps, int fps_target);
extern void timer_fps_sync(fps_t *fps);
/* timer_fps_quit() : uninit fps object */
extern void timer_fps_quit(fps_t *fps);

View File

@ -26,8 +26,8 @@ struct timer_drv_interface
uint32_t (*timer_prof_time)(timer_prof_t *prof);
int (*timer_prof_quit)(timer_prof_t *prof);
/* FPS */
void (*timer_fps_init)(fps_t *fps);
void (*timer_fps_sync)(fps_t *fps, int fps_target);
void (*timer_fps_init)(fps_t *fps, int fps_target);
void (*timer_fps_sync)(fps_t *fps);
void (*timer_fps_quit)(fps_t *fps);
};

View File

@ -182,30 +182,36 @@ int sdl_tmu_prof_quit(timer_prof_t *prof)
//---
/* sh7305_tmu_fps_init() : initialize fps object */
void sdl_tmu_fps_init(fps_t *fps)
void sdl_tmu_fps_init(fps_t *fps, int fps_target)
{
memset(fps, 0x00, sizeof(fps_t));
fps->anchor = SDL_GetTicks();
fps->objectif = 1000 / fps_target;
fps->fps_target = fps_target;
}
/* sdl_tmu_fps_sync() : compute frame statistic and wait whanted FPS */
void sdl_tmu_fps_sync(fps_t *fps, int fps_target)
void sdl_tmu_fps_sync(fps_t *fps)
{
uint32_t snapshot;
uint32_t target_ticks;
snapshot = SDL_GetTicks();
fps->objectif = 1000 / fps_target;
fps->render = snapshot - fps->anchor;
fps->margin = fps->objectif - fps->render;
fps->fps_real = 1000 / fps->render;
fps->fps_real = 1000;
if (fps->render > 0)
fps->fps_real /= fps->render;
fps->fps = fps->fps_real;
if (fps->margin > 0)
fps->fps = fps_target;
fps->fps = fps->fps_target;
target_ticks = snapshot + fps->objectif;
while (1) {
if (SDL_GetTicks() - fps->anchor >= fps->objectif)
if (SDL_GetTicks() >= target_ticks)
break;
}

View File

@ -9,36 +9,42 @@
// Public FPS API
//---
// TODO : proper handle
extern uint32_t *tmu_prof_tcnt;
/* sh7305_tmu_fps_init() : initialize fps object */
void sh7305_tmu_fps_init(fps_t *fps)
void sh7305_tmu_fps_init(fps_t *fps, int fps_target)
{
sh7305_tmu_prof_init(NULL);
memset(fps, 0x00, sizeof(fps_t));
fps->objectif = 1000000 / fps_target;
fps->fps_target = fps_target;
}
/* sh7305_tmu_fps_sync() : compute frame statistic and wait whanted FPS */
void sh7305_tmu_fps_sync(fps_t *fps, int fps_target)
void sh7305_tmu_fps_sync(fps_t *fps)
{
struct cpg_clock_frequency cpg_freq;
uint32_t target_ticks;
uint32_t snap;
//TODO: proper freq calculation
cpg_clock_freq(&cpg_freq);
snap = (uint32_t)(((uint64_t)*tmu_prof_tcnt * 4 * 1000000) / cpg_freq.Pphi_f);
fps->objectif = 1000000 / fps_target;
fps->render = fps->anchor - snap;
fps->margin = fps->objectif - fps->render;
/* we don't secure the division because it negligent */
fps->fps_real = 1000000 / fps->render;
fps->fps = fps->fps_real;
if (fps->margin > 0)
fps->fps = fps_target;
fps->fps = fps->fps_target;
target_ticks = snap + fps->objectif;
while (1) {
if (*tmu_prof_tcnt - fps->anchor >= fps->objectif)
if (*tmu_prof_tcnt >= target_ticks)
break;
}

View File

@ -62,6 +62,7 @@ VALIGNED(4) VWEAK int r61524_frame_frag_send(dsurface_t *surface)
if (dma >= 0)
sh7305_dma_wait(dma);
#if 0
/* Set the windows size */
r61524_select(horizontal_ram_start);
r61524_write(0);
@ -71,6 +72,7 @@ VALIGNED(4) VWEAK int r61524_frame_frag_send(dsurface_t *surface)
r61524_write(0);
r61524_select(vertical_ram_end);
r61524_write(223);
#endif
/* Set the RAM position */
r61524_select(ram_address_horizontal);
@ -128,6 +130,10 @@ struct r61524_ctx {
static void __r61524_configure(struct r61524_ctx *s)
{
/* disable double-buffering display */
r61524_atomic_transfert = true;
/* screen information */
s->HSA = 0;
s->HEA = 395;
s->VSA = 0;

View File

@ -12,17 +12,17 @@ extern struct {
/* timer_fps_init() : initialize fps object */
void timer_fps_init(fps_t *fps)
void timer_fps_init(fps_t *fps, int target_ticks)
{
if (timer_info.driver.timer_fps_init != NULL)
timer_info.driver.timer_fps_init(fps);
timer_info.driver.timer_fps_init(fps, target_ticks);
}
/* timer_fps_sync() : try to syncronize to X frame per seconds */
void timer_fps_sync(fps_t *fps, int fps_target)
void timer_fps_sync(fps_t *fps)
{
if (timer_info.driver.timer_fps_sync != NULL)
timer_info.driver.timer_fps_sync(fps, fps_target);
timer_info.driver.timer_fps_sync(fps);
}
/* timer_fps_quit() : uninit fps object */

View File

@ -14,7 +14,7 @@ __all__ = [
# Internal functions
#---
__PROJ_PREFIX__ = f"{os.path.dirname(__file__)}/../.."
__PROJ_PREFIX__ = f"{os.path.dirname(__file__)}/../../.."
def _warning(text):
print(text, file=sys.stderr)

2
vxdev
View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash
python3 scripts/vxdev
python3 scripts/vxdev $@

View File

@ -43,7 +43,7 @@ assets_prefix = [
]
VXSDK_PUBLIC_BUILD_LDFLAGS = [
'-T {VXSDK_CURRENT_SOURCE_DIR}/boards/fxcg50/fxcg50.ld',
'-static-pie',
'-static',
'-Wl,-q'
]