Implement Tulip Creative Computer 4r11 (#608)

This commit is contained in:
NellowTCS
2026-08-08 06:52:34 -06:00
committed by GitHub
parent c6373b79e9
commit 564d8af64c
20 changed files with 798 additions and 9 deletions
@@ -11,6 +11,18 @@ extern "C" {
#include <tactility/device.h>
#include <tactility/drivers/gpio.h>
/**
* Optional software pixel-format conversion applied to scan-out pixels. The panel itself always
* runs at bits_per_pixel; when the host renders in a different depth (LVGL always renders RGB565
* for this driver), the selected mapper converts each tile before it reaches esp_lcd.
*/
enum RgbDisplayPixelFormat {
/** No conversion: scan-out pixels must already match bits_per_pixel. */
RGB_DISPLAY_PIXEL_FORMAT_DEFAULT = 0,
/** Convert RGB565 to packed 8-bit RGB332 (3R, 3G, 2B), for 8 data-line panels. */
RGB_DISPLAY_PIXEL_FORMAT_RGB332 = 1,
};
struct RgbDisplayConfig {
uint16_t horizontal_resolution;
uint16_t vertical_resolution;
@@ -84,6 +96,9 @@ struct RgbDisplayConfig {
// Optional reference to this display's backlight device, NULL if none.
struct Device* backlight;
// Optional software pixel-format conversion for scan-out (see enum RgbDisplayPixelFormat).
enum RgbDisplayPixelFormat pixel_format;
};
#ifdef __cplusplus
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
* Opaque per-instance state for a software pixel mapper, allocated by SoftwarePixelMapperCreateFn
* and released by SoftwarePixelMapperDestroyFn. The instance owns its conversion destination
* buffer: the driver passes this handle as map()'s dst argument.
*/
typedef void* SoftwarePixelMapperData;
/**
* Allocates a mapper instance, including its destination buffer, sized for a width x height
* source buffer.
* @param width source buffer width in pixels
* @param height source buffer height in pixels
* @return a non-null instance handle, or NULL on allocation failure
*/
typedef SoftwarePixelMapperData (*SoftwarePixelMapperCreateFn)(uint16_t width, uint16_t height);
/**
* Converts pixel_count pixels from the mapper's source format to its destination format.
* @param data instance handle from SoftwarePixelMapperCreateFn
* @param src RGB565 source pixels
* @param dst destination buffer, typically the instance's own buffer (i.e. the data handle)
* @param pixel_count number of pixels to convert
*/
typedef void (*SoftwarePixelMapperMapFn)(SoftwarePixelMapperData data, const uint16_t* src, uint8_t* dst, uint32_t pixel_count);
/**
* Releases a mapper instance created by SoftwarePixelMapperCreateFn, including its destination
* buffer.
* @param data instance handle to release
*/
typedef void (*SoftwarePixelMapperDestroyFn)(SoftwarePixelMapperData data);
/**
* A software pixel-format conversion, used to translate a driver's native source depth into a
* panel's scan-out depth when the two differ. Each mapper owns its own destination buffer, so it
* can size the allocation for its output format.
*/
struct SoftwarePixelMapper {
SoftwarePixelMapperCreateFn create;
SoftwarePixelMapperMapFn map;
SoftwarePixelMapperDestroyFn destroy;
};
/**
* RGB565 to packed 8-bit RGB332 (3 bits red, 3 bits green, 2 bits blue) mapper for panels wired
* with only 8 data lines.
*/
extern const struct SoftwarePixelMapper software_pixel_mapper_rgb332;
#ifdef __cplusplus
}
#endif