Skip to content
Snippets Groups Projects
Select Git revision
  • 0ac4b0f4bab0cc9946d1bff28b44bb3bc007cb2c
  • main default protected
  • phhw
  • captouch-threshold
  • t
  • dos
  • test2
  • test
  • slewtest
  • simtest
  • view-think
  • vm-pending
  • media-buf
  • scope
  • passthrough
  • wave
  • vsync
  • dos-main-patch-50543
  • json-error
  • rahix/big-flow3r
  • pippin/media_framework
  • v1.3.0
  • v1.2.0
  • v1.2.0+rc1
  • v1.1.1
  • v1.1.0
  • v1.1.0+rc1
  • v1.0.0
  • v1.0.0+rc6
  • v1.0.0+rc5
  • v1.0.0+rc4
  • v1.0.0+rc3
  • v1.0.0+rc2
  • v1.0.0+rc1
34 results

st3m_gfx.c

Blame
  • Forked from flow3r / flow3r firmware
    Source project has a limited visibility.
    st3m_gfx.c 25.80 KiB
    #include "st3m_gfx.h"
    // Submit a filled ctx descriptor to the rasterization pipeline.
    
    #include <string.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"
    
    // Each buffer  takes ~116kB SPIRAM. While one framebuffer is being blitted, the
    // other one is being written to by the rasterizer.
    #define ST3M_GFX_NBUFFERS 2
    // More ctx drawlists than buffers so that micropython doesn't get starved when
    // pipeline runs in lockstep.
    #define ST3M_GFX_NCTX 3
    
    // A framebuffer descriptor, pointing at a framebuffer.
    typedef struct {
        // The numeric ID of this descriptor.
        int num;
        // SPIRAM buffer.
        uint16_t buffer[240 * 240];
        Ctx *ctx;
    } st3m_framebuffer_desc_t;
    
    // 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 st3m_ctx_desc_t *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(st3m_ctx_desc_t *desc);
    
    static const char *TAG = "st3m-gfx";
    
    // Framebuffer descriptors, containing framebuffer and ctx for each of the
    // framebuffers.
    //
    // These live in SPIRAM, as we don't have enough space in SRAM/IRAM.
    EXT_RAM_BSS_ATTR static st3m_framebuffer_desc_t
        framebuffer_descs[ST3M_GFX_NBUFFERS];
    
    #define OVERLAY_WIDTH 120
    #define OVERLAY_HEIGHT 160
    #define OVERLAY_X 60
    #define OVERLAY_Y 0
    
    static int _st3m_overlay_height = 0;
    EXT_RAM_BSS_ATTR static uint8_t
        st3m_overlay_fb[OVERLAY_WIDTH * OVERLAY_HEIGHT * 4];
    EXT_RAM_BSS_ATTR uint16_t st3m_overlay_backup[OVERLAY_WIDTH * OVERLAY_HEIGHT];
    static Ctx *_st3m_overlay_ctx = NULL;
    
    static st3m_ctx_desc_t dctx_descs[ST3M_GFX_NCTX];
    
    // Queue of free framebuffer descriptors, written into by crtc once rendered,