2022-08-16 14:51:10 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the Trezor project, https://trezor.io/
|
|
|
|
*
|
|
|
|
* Copyright (c) SatoshiLabs
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BUFFERS_H
|
|
|
|
#define _BUFFERS_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "common.h"
|
2022-10-14 10:43:37 +00:00
|
|
|
#include TREZOR_BOARD
|
2022-08-16 14:51:10 +00:00
|
|
|
|
|
|
|
#define BUFFER_PIXELS DISPLAY_RESX
|
|
|
|
|
2023-03-06 17:54:23 +00:00
|
|
|
#define TEXT_BUFFER_HEIGHT 36
|
2022-08-16 14:51:10 +00:00
|
|
|
|
|
|
|
#if TEXT_BUFFER_HEIGHT < FONT_MAX_HEIGHT
|
|
|
|
#error Text buffer height is too small, please adjust to match used fonts
|
|
|
|
#endif
|
|
|
|
|
2022-11-22 15:42:54 +00:00
|
|
|
#define LINE_BUFFER_16BPP_SIZE (BUFFER_PIXELS * 2)
|
|
|
|
#define LINE_BUFFER_4BPP_SIZE (BUFFER_PIXELS / 2)
|
|
|
|
#define TEXT_BUFFER_SIZE ((BUFFER_PIXELS * TEXT_BUFFER_HEIGHT) / 2)
|
2022-10-13 11:37:02 +00:00
|
|
|
#define JPEG_BUFFER_SIZE (BUFFER_PIXELS * 16)
|
|
|
|
|
|
|
|
// 3100 is needed according to tjpgd docs,
|
|
|
|
// 256 because we need non overlapping memory in rust
|
|
|
|
// 6 << 10 is for huffman decoding table
|
2023-03-29 13:26:22 +00:00
|
|
|
// 1000 bytes reserve, as we discovered that we are running out of memory
|
|
|
|
// sometimes
|
|
|
|
#define JPEG_WORK_SIZE (3100 + 256 + (6 << 10) + 1000)
|
2022-10-13 11:37:02 +00:00
|
|
|
|
|
|
|
#if defined BOOTLOADER
|
|
|
|
#define BUFFER_SECTION __attribute__((section(".buf")))
|
|
|
|
#else
|
|
|
|
#define BUFFER_SECTION
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined BOOTLOADER || defined TREZOR_EMULATOR
|
|
|
|
#define NODMA_BUFFER_SECTION
|
|
|
|
#else
|
|
|
|
#define NODMA_BUFFER_SECTION __attribute__((section(".no_dma_buffers")))
|
|
|
|
#endif
|
2022-08-16 14:51:10 +00:00
|
|
|
|
|
|
|
typedef __attribute__((aligned(4))) struct {
|
|
|
|
uint8_t buffer[LINE_BUFFER_16BPP_SIZE];
|
|
|
|
} line_buffer_16bpp_t;
|
|
|
|
|
|
|
|
typedef __attribute__((aligned(4))) struct {
|
|
|
|
uint8_t buffer[LINE_BUFFER_4BPP_SIZE];
|
|
|
|
} line_buffer_4bpp_t;
|
|
|
|
|
|
|
|
typedef __attribute__((aligned(4))) struct {
|
|
|
|
uint8_t buffer[TEXT_BUFFER_SIZE];
|
|
|
|
} buffer_text_t;
|
|
|
|
|
2022-10-13 11:37:02 +00:00
|
|
|
typedef __attribute__((aligned(4))) struct {
|
|
|
|
uint16_t buffer[JPEG_BUFFER_SIZE];
|
|
|
|
} buffer_jpeg_t;
|
|
|
|
|
|
|
|
typedef __attribute__((aligned(4))) struct {
|
|
|
|
uint8_t buffer[JPEG_WORK_SIZE];
|
|
|
|
} buffer_jpeg_work_t;
|
|
|
|
|
|
|
|
typedef __attribute__((aligned(4))) struct {
|
|
|
|
uint16_t buffer[10][3][BUFFER_PIXELS];
|
|
|
|
} buffer_blurring_t;
|
|
|
|
|
2022-08-16 14:51:10 +00:00
|
|
|
extern const int32_t text_buffer_height;
|
|
|
|
extern const int32_t buffer_width;
|
|
|
|
|
|
|
|
line_buffer_16bpp_t* buffers_get_line_buffer_16bpp(uint16_t idx, bool clear);
|
|
|
|
line_buffer_4bpp_t* buffers_get_line_buffer_4bpp(uint16_t idx, bool clear);
|
|
|
|
buffer_text_t* buffers_get_text_buffer(uint16_t idx, bool clear);
|
2022-10-13 11:37:02 +00:00
|
|
|
buffer_jpeg_t* buffers_get_jpeg_buffer(uint16_t idx, bool clear);
|
|
|
|
buffer_jpeg_work_t* buffers_get_jpeg_work_buffer(uint16_t idx, bool clear);
|
|
|
|
buffer_blurring_t* buffers_get_blurring_buffer(uint16_t idx, bool clear);
|
2022-08-16 14:51:10 +00:00
|
|
|
|
2022-10-14 10:43:37 +00:00
|
|
|
#endif // _BUFFERS_H
|