Select Git revision
group__SDHC__ADMA__ADDR__0.html
st3m_gfx.c 28.79 KiB
#include "st3m_gfx.h"
// Submit a filled ctx descriptor to the rasterization pipeline.
#include <string.h>
#include <pthread.h>
#include "esp_log.h"
#include "esp_system.h"
#include "esp_task.h"
#include "esp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
// clang-format off
#include "ctx_config.h"
#include "ctx.h"
// clang-format on
#include "flow3r_bsp.h"
#include "st3m_counter.h"
#include "st3m_version.h"
#define ST3M_GFX_DEFAULT_MODE st3m_gfx_16bpp_osd
static EXT_RAM_BSS_ATTR uint16_t fb[240 * 240];
// Get a free drawlist ctx to draw into.
//
// ticks_to_wait can be used to limit the time to wait for a free ctx
// descriptor, or portDELAY_MAX can be specified to wait forever. If the timeout
// expires, NULL will be returned.
static Ctx *st3m_gfx_drawctx_free_get(TickType_t ticks_to_wait);
// Submit a filled ctx descriptor to the rasterization pipeline.
static void st3m_gfx_drawctx_pipe_put(void);
static const char *TAG = "st3m-gfx";
#define N_DRAWLISTS 3
// we keep the OSD buffer the same size as the main framebuffer,
// allowing us to do different combos of which buffer is osd and not
#define ST3M_OSD_WIDTH 240
#define ST3M_OSD_HEIGHT 240
#define ST3M_OSD_X 0
#define ST3M_OSD_Y 0
static st3m_gfx_mode _st3m_gfx_mode = st3m_gfx_default + 1;
EXT_RAM_BSS_ATTR static uint8_t
st3m_osd_fb[ST3M_OSD_WIDTH * ST3M_OSD_HEIGHT * 4];
EXT_RAM_BSS_ATTR uint16_t st3m_osd_backup[ST3M_OSD_WIDTH * ST3M_OSD_HEIGHT];
// drawlist ctx
static Ctx *user_ctx[N_DRAWLISTS];
// each frame buffer has an associated rasterizer context
static Ctx *fb_GRAY8_ctx = NULL;
static Ctx *fb_GRAYA8_ctx = NULL;
static Ctx *fb_RGB565_BS_ctx = NULL;
static Ctx *fb_RGBA8_ctx = NULL;
// corner pixel coordinates for osd clip
static pthread_mutex_t osd_mutex = PTHREAD_MUTEX_INITIALIZER;
static int _st3m_osd_y1[N_DRAWLISTS + 1];
static int _st3m_osd_x1[N_DRAWLISTS + 1];
static int _st3m_osd_y0[N_DRAWLISTS + 1];
static int _st3m_osd_x0[N_DRAWLISTS + 1];