123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- #ifndef ZEPHYR_INCLUDE_DRIVERS_DISPLAY_DISPLAY_CONTROLLER_H_
- #define ZEPHYR_INCLUDE_DRIVERS_DISPLAY_DISPLAY_CONTROLLER_H_
- #include <kernel.h>
- #include <device.h>
- #include <zephyr/types.h>
- #include <drivers/cfg_drv/dev_config.h>
- #include "display_graphics.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define DC_INVALID_CMD (UINT32_MAX)
- #define DISPLAY_PORT_TYPE(major, minor) (((major) << 8) | (minor))
- #define DISPLAY_PORT_TYPE_MAJOR(type) (((type) >> 8) & 0xFF)
- #define DISPLAY_PORT_TYPE_MINOR(type) ((type) & 0xFF)
- #define DISPLAY_PORT_Unknown (0)
- #define DISPLAY_PORT_MCU (1)
- #define DISPLAY_PORT_TR (2)
- #define DISPLAY_PORT_SPI (4)
- #define DISPLAY_MCU_8080 (0)
- #define DISPLAY_MCU_6800 (1)
- #define DISPLAY_PORT_MCU_8080 DISPLAY_PORT_TYPE(DISPLAY_PORT_MCU, DISPLAY_MCU_8080)
- #define DISPLAY_PORT_MCU_6800 DISPLAY_PORT_TYPE(DISPLAY_PORT_MCU, DISPLAY_MCU_6800)
- #define DISPLAY_SPI_3LINE_1 (0)
- #define DISPLAY_SPI_3LINE_2 (1)
- #define DISPLAY_SPI_4LINE_1 (2)
- #define DISPLAY_SPI_4LINE_2 (3)
- #define DISPLAY_QSPI (4)
- #define DISPLAY_QSPI_SYNC (5)
- #define DISPLAY_QSPI_DDR_0 (6)
- #define DISPLAY_QSPI_DDR_1 (7)
- #define DISPLAY_QSPI_DDR_2 (8)
- #define DISPLAY_PORT_SPI_3LINE_1 DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_SPI_3LINE_1)
- #define DISPLAY_PORT_SPI_3LINE_2 DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_SPI_3LINE_2)
- #define DISPLAY_PORT_SPI_4LINE_1 DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_SPI_4LINE_1)
- #define DISPLAY_PORT_SPI_4LINE_2 DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_SPI_4LINE_2)
- #define DISPLAY_PORT_QSPI DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_QSPI)
- #define DISPLAY_PORT_QSPI_SYNC DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_QSPI_SYNC)
- #define DISPLAY_PORT_QSPI_DDR_0 DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_QSPI_DDR_0)
- #define DISPLAY_PORT_QSPI_DDR_1 DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_QSPI_DDR_1)
- #define DISPLAY_PORT_QSPI_DDR_2 DISPLAY_PORT_TYPE(DISPLAY_PORT_SPI, DISPLAY_QSPI_DDR_2)
- #define DISPLAY_PORT_TR_LCD DISPLAY_PORT_TYPE(DISPLAY_PORT_TR, 0)
- struct display_videoport {
-
- union {
- uint16_t type;
- struct {
- uint8_t minor_type;
- uint8_t major_type;
- };
- };
- union {
-
- struct {
- uint8_t cs : 1;
- uint8_t lsb_first : 1;
- uint8_t bus_width;
- uint8_t clk_low_duration;
- uint8_t clk_high_duration;
- } mcu_mode;
-
- struct {
- uint8_t cs : 1;
- uint8_t lsb_first : 1;
-
- uint8_t cpol : 1;
-
- uint8_t cpha : 1;
- uint8_t dual_lane : 1;
- uint8_t dcp_mode : 1;
- uint8_t rd_lane : 2;
- uint8_t rd_dummy_cycles;
- uint8_t rd_delay_ns;
- uint8_t wr_delay_d0_ns;
- uint8_t wr_delay_d1_ns;
- uint8_t wr_delay_d2_ns;
- uint8_t wr_delay_d3_ns;
- uint8_t delay_csx_ns;
- uint8_t delay_scl_ns;
- uint8_t ahb_clk_div;
- } spi_mode;
- struct {
- uint8_t low_bit : 3;
- uint8_t hck_tail_on : 1;
- uint8_t vck_on_xrstl : 1;
- uint8_t vck_on_idle : 1;
- uint8_t hck_on_idle : 1;
- uint8_t ptl_on : 1;
- uint8_t frp_on : 1;
- uint8_t vcom_inv : 1;
- uint8_t frp_inv : 1;
- uint8_t xfrp_inv : 1;
- uint8_t xrst_inv : 1;
- uint8_t vst_inv : 1;
- uint8_t hst_inv : 1;
- uint8_t vck_inv : 1;
- uint8_t hck_inv : 1;
- uint8_t enb_inv : 1;
- uint32_t tw_xrst : 8;
- uint32_t tw_vcom : 23;
- uint32_t td_vst : 8;
- uint32_t tw_vst : 8;
- uint32_t td_hst : 8;
- uint32_t tw_hst : 8;
- uint32_t td_vck : 8;
- uint32_t tw_vck : 11;
- uint32_t tp_hck : 2;
- uint32_t td_hck : 8;
- uint32_t ts_enb : 11;
- uint32_t th_enb : 11;
- uint32_t td_data : 8;
- uint32_t td_enb : 13;
- uint32_t tw_enb : 13;
- uint32_t tsm_enb : 11;
- uint32_t thm_enb : 11;
- uint32_t twm_vck : 10;
- } tr_mode;
- };
- };
- enum display_flags {
-
- DISPLAY_FLAGS_TE_LOW = BIT(0),
- DISPLAY_FLAGS_TE_HIGH = BIT(1),
-
- DISPLAY_FLAGS_HSYNC_LOW = BIT(2),
- DISPLAY_FLAGS_HSYNC_HIGH = BIT(3),
-
- DISPLAY_FLAGS_VSYNC_LOW = BIT(4),
- DISPLAY_FLAGS_VSYNC_HIGH = BIT(5),
-
- DISPLAY_FLAGS_DE_LOW = BIT(6),
- DISPLAY_FLAGS_DE_HIGH = BIT(7),
-
- DISPLAY_FLAGS_PIXDATA_POSEDGE = BIT(8),
-
- DISPLAY_FLAGS_PIXDATA_NEGEDGE = BIT(9),
-
- DISPLAY_FLAGS_SYNC_POSEDGE = BIT(10),
-
- DISPLAY_FLAGS_SYNC_NEGEDGE = BIT(11),
- };
- struct display_videomode {
- uint32_t pixel_format;
-
- uint32_t pixel_clk;
- uint16_t refresh_rate;
- uint16_t hactive;
- uint16_t hfront_porch;
- uint16_t hback_porch;
- uint16_t hsync_len;
- uint16_t vactive;
- uint16_t vfront_porch;
- uint16_t vback_porch;
- uint16_t vsync_len;
-
- uint16_t flags;
- };
- enum display_controller_ctrl_type {
- DISPLAY_CONTROLLER_CTRL_COMPLETE_CB = 0,
- DISPLAY_CONTROLLER_CTRL_VSYNC_CB,
- DISPLAY_CONTROLLER_CTRL_HOTPLUG_CB,
- };
- typedef void (*display_controller_complete_t)(void *arg);
- typedef void (*display_controller_vsync_t)(void *arg, uint32_t timestamp);
- typedef void (*display_controller_hotplug_t)(void *arg, int connected);
- enum display_controller_source_type {
- DISPLAY_CONTROLLER_SOURCE_MCU = 0,
- DISPLAY_CONTROLLER_SOURCE_ENGINE,
- DISPLAY_CONTROLLER_SOURCE_DMA,
- DISPLAY_CONTROLLER_NUM_SOURCES,
- };
- typedef int (*display_controller_control_api)(
- const struct device *dev, int cmd, void *arg1, void *arg2);
- typedef int (*display_controller_enable_api)(const struct device *dev,
- const struct display_videoport *port);
- typedef int (*display_controller_disable_api)(const struct device *dev);
- typedef int (*display_controller_set_mode_api)(const struct device *dev,
- const struct display_videomode *mode);
- typedef int (*display_controller_read_config_api)(const struct device *dev,
- uint32_t cmd, void *buf, uint32_t len);
- typedef int (*display_controller_write_config_api)(const struct device *dev,
- uint32_t cmd, const void *buf, uint32_t len);
- typedef int (*display_controller_read_pixels_api)(const struct device *dev,
- uint32_t cmd, const struct display_buffer_descriptor *desc, void *buf);
- typedef int (*display_controller_write_pixels_api)(
- const struct device *dev, uint32_t cmd, uint32_t hsync_cmd,
- const struct display_buffer_descriptor *desc, const void *buf);
- typedef int (*display_controller_set_source_api)(const struct device *dev,
- enum display_controller_source_type source_type,
- const struct device *source_dev);
- struct display_controller_driver_api {
- display_controller_control_api control;
- display_controller_enable_api enable;
- display_controller_disable_api disable;
- display_controller_set_mode_api set_mode;
- display_controller_set_source_api set_source;
- display_controller_read_config_api read_config;
- display_controller_write_config_api write_config;
- display_controller_read_pixels_api read_pixels;
- display_controller_write_pixels_api write_pixels;
- };
- static inline int display_controller_control(const struct device *dev,
- int cmd, void *arg1, void *arg2)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->control(dev, cmd, arg1, arg2);
- }
- static inline int display_controller_enable(const struct device *dev,
- const struct display_videoport *port)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->enable(dev, port);
- }
- static inline int display_controller_disable(const struct device *dev)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->disable(dev);
- }
- static inline int display_controller_set_mode(const struct device *dev,
- const struct display_videomode *mode)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->set_mode(dev, mode);
- }
- static inline int display_controller_set_source(const struct device *dev,
- enum display_controller_source_type source_type, const struct device *source_dev)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->set_source(dev, source_type, source_dev);
- }
- static inline int display_controller_read_config(const struct device *dev,
- uint32_t cmd, void *buf, uint32_t len)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->read_config(dev, cmd, buf, len);
- }
- static inline int display_controller_write_config(const struct device *dev,
- uint32_t cmd, const void *buf, uint32_t len)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->write_config(dev, cmd, buf, len);
- }
- static inline int display_controller_read_pixels(const struct device *dev,
- uint32_t cmd, const struct display_buffer_descriptor *desc, void *buf)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->read_pixels(dev, cmd, desc, buf);
- }
- static inline int display_controller_write_pixels(
- const struct device *dev, uint32_t cmd, uint32_t hsync_cmd,
- const struct display_buffer_descriptor *desc, const void *buf)
- {
- struct display_controller_driver_api *api =
- (struct display_controller_driver_api *)dev->api;
- return api->write_pixels(dev, cmd, hsync_cmd, desc, buf);
- }
- #ifdef __cplusplus
- }
- #endif
- #endif
|