123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- #ifndef __DRM_MIPI_DSI_H__
- #define __DRM_MIPI_DSI_H__
- #include <linux/device.h>
- struct mipi_dsi_host;
- struct mipi_dsi_device;
- #define MIPI_DSI_MSG_REQ_ACK BIT(0)
- #define MIPI_DSI_MSG_USE_LPM BIT(1)
- struct mipi_dsi_msg {
- u8 channel;
- u8 type;
- u16 flags;
- size_t tx_len;
- const void *tx_buf;
- size_t rx_len;
- void *rx_buf;
- };
- bool mipi_dsi_packet_format_is_short(u8 type);
- bool mipi_dsi_packet_format_is_long(u8 type);
- struct mipi_dsi_packet {
- size_t size;
- u8 header[4];
- size_t payload_length;
- const u8 *payload;
- };
- int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
- const struct mipi_dsi_msg *msg);
- struct mipi_dsi_host_ops {
- int (*attach)(struct mipi_dsi_host *host,
- struct mipi_dsi_device *dsi);
- int (*detach)(struct mipi_dsi_host *host,
- struct mipi_dsi_device *dsi);
- ssize_t (*transfer)(struct mipi_dsi_host *host,
- const struct mipi_dsi_msg *msg);
- };
- struct mipi_dsi_host {
- struct device *dev;
- const struct mipi_dsi_host_ops *ops;
- };
- int mipi_dsi_host_register(struct mipi_dsi_host *host);
- void mipi_dsi_host_unregister(struct mipi_dsi_host *host);
- #define MIPI_DSI_MODE_VIDEO BIT(0)
- #define MIPI_DSI_MODE_VIDEO_BURST BIT(1)
- #define MIPI_DSI_MODE_VIDEO_SYNC_PULSE BIT(2)
- #define MIPI_DSI_MODE_VIDEO_AUTO_VERT BIT(3)
- #define MIPI_DSI_MODE_VIDEO_HSE BIT(4)
- #define MIPI_DSI_MODE_VIDEO_HFP BIT(5)
- #define MIPI_DSI_MODE_VIDEO_HBP BIT(6)
- #define MIPI_DSI_MODE_VIDEO_HSA BIT(7)
- #define MIPI_DSI_MODE_VSYNC_FLUSH BIT(8)
- #define MIPI_DSI_MODE_EOT_PACKET BIT(9)
- #define MIPI_DSI_CLOCK_NON_CONTINUOUS BIT(10)
- #define MIPI_DSI_MODE_LPM BIT(11)
- enum mipi_dsi_pixel_format {
- MIPI_DSI_FMT_RGB888,
- MIPI_DSI_FMT_RGB666,
- MIPI_DSI_FMT_RGB666_PACKED,
- MIPI_DSI_FMT_RGB565,
- };
- struct mipi_dsi_device {
- struct mipi_dsi_host *host;
- struct device dev;
- unsigned int channel;
- unsigned int lanes;
- enum mipi_dsi_pixel_format format;
- unsigned long mode_flags;
- };
- static inline struct mipi_dsi_device *to_mipi_dsi_device(struct device *dev)
- {
- return container_of(dev, struct mipi_dsi_device, dev);
- }
- struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np);
- int mipi_dsi_attach(struct mipi_dsi_device *dsi);
- int mipi_dsi_detach(struct mipi_dsi_device *dsi);
- int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi,
- u16 value);
- ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload,
- size_t size);
- ssize_t mipi_dsi_generic_read(struct mipi_dsi_device *dsi, const void *params,
- size_t num_params, void *data, size_t size);
- enum mipi_dsi_dcs_tear_mode {
- MIPI_DSI_DCS_TEAR_MODE_VBLANK,
- MIPI_DSI_DCS_TEAR_MODE_VHBLANK,
- };
- #define MIPI_DSI_DCS_POWER_MODE_DISPLAY (1 << 2)
- #define MIPI_DSI_DCS_POWER_MODE_NORMAL (1 << 3)
- #define MIPI_DSI_DCS_POWER_MODE_SLEEP (1 << 4)
- #define MIPI_DSI_DCS_POWER_MODE_PARTIAL (1 << 5)
- #define MIPI_DSI_DCS_POWER_MODE_IDLE (1 << 6)
- ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,
- const void *data, size_t len);
- ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
- const void *data, size_t len);
- ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
- size_t len);
- int mipi_dsi_dcs_nop(struct mipi_dsi_device *dsi);
- int mipi_dsi_dcs_soft_reset(struct mipi_dsi_device *dsi);
- int mipi_dsi_dcs_get_power_mode(struct mipi_dsi_device *dsi, u8 *mode);
- int mipi_dsi_dcs_get_pixel_format(struct mipi_dsi_device *dsi, u8 *format);
- int mipi_dsi_dcs_enter_sleep_mode(struct mipi_dsi_device *dsi);
- int mipi_dsi_dcs_exit_sleep_mode(struct mipi_dsi_device *dsi);
- int mipi_dsi_dcs_set_display_off(struct mipi_dsi_device *dsi);
- int mipi_dsi_dcs_set_display_on(struct mipi_dsi_device *dsi);
- int mipi_dsi_dcs_set_column_address(struct mipi_dsi_device *dsi, u16 start,
- u16 end);
- int mipi_dsi_dcs_set_page_address(struct mipi_dsi_device *dsi, u16 start,
- u16 end);
- int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
- int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
- enum mipi_dsi_dcs_tear_mode mode);
- int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);
- struct mipi_dsi_driver {
- struct device_driver driver;
- int(*probe)(struct mipi_dsi_device *dsi);
- int(*remove)(struct mipi_dsi_device *dsi);
- void (*shutdown)(struct mipi_dsi_device *dsi);
- };
- static inline struct mipi_dsi_driver *
- to_mipi_dsi_driver(struct device_driver *driver)
- {
- return container_of(driver, struct mipi_dsi_driver, driver);
- }
- static inline void *mipi_dsi_get_drvdata(const struct mipi_dsi_device *dsi)
- {
- return dev_get_drvdata(&dsi->dev);
- }
- static inline void mipi_dsi_set_drvdata(struct mipi_dsi_device *dsi, void *data)
- {
- dev_set_drvdata(&dsi->dev, data);
- }
- int mipi_dsi_driver_register_full(struct mipi_dsi_driver *driver,
- struct module *owner);
- void mipi_dsi_driver_unregister(struct mipi_dsi_driver *driver);
- #define mipi_dsi_driver_register(driver) \
- mipi_dsi_driver_register_full(driver, THIS_MODULE)
- #define module_mipi_dsi_driver(__mipi_dsi_driver) \
- module_driver(__mipi_dsi_driver, mipi_dsi_driver_register, \
- mipi_dsi_driver_unregister)
- #endif /* __DRM_MIPI_DSI__ */
|