On 13 July 2018 at 06:11, Yannick Fertré <yannick.fer...@st.com> wrote: > Mipi_display.c contains a set of dsi helpers. > This file is a copy of file drm_mipi_dsi.c (linux kernel). > > Signed-off-by: Yannick Fertré <yannick.fer...@st.com> > --- > drivers/video/Kconfig | 9 + > drivers/video/Makefile | 1 + > drivers/video/mipi_display.c | 817 > +++++++++++++++++++++++++++++++++++++++++++ > include/mipi_display.h | 257 +++++++++++++- > 4 files changed, 1083 insertions(+), 1 deletion(-) > create mode 100644 drivers/video/mipi_display.c >
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig > index 5ee9032..560da1a 100644 > --- a/drivers/video/Kconfig > +++ b/drivers/video/Kconfig > @@ -73,6 +73,15 @@ config VIDEO_ANSI > Enable ANSI escape sequence decoding for a more fully functional > console. > > +config VIDEO_MIPI_DSI > + bool "Support MIPI DSI interface" > + depends on DM_VIDEO > + default y if DM_VIDEO Why default y? Many boards won't use MIPI. > + help > + Support MIPI DSI interface for driving a MIPI compatible device. > + The MIPI Display Serial Interface (MIPI DSI) defines a high-speed > + serial interface between a host processor and a display module. > + > config CONSOLE_NORMAL [..] > diff --git a/include/mipi_display.h b/include/mipi_display.h > index ddcc8ca..5c3dbbe 100644 > --- a/include/mipi_display.h > +++ b/include/mipi_display.h > @@ -4,12 +4,16 @@ > * > * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovet...@gmx.de> > * Copyright (C) 2006 Nokia Corporation > - * Author: Imre Deak <imre.d...@nokia.com> > + * Copyright (C) 2018 STMicroelectronics - All Rights Reserved > + * Author(s): Imre Deak <imre.d...@nokia.com> > + * Yannick Fertre <yannick.fer...@st.com> > + * Philippe Cornu <philippe.co...@st.com> > * > * This program is free software; you can redistribute it and/or modify > * it under the terms of the GNU General Public License version 2 as > * published by the Free Software Foundation. > */ > + > #ifndef MIPI_DISPLAY_H > #define MIPI_DISPLAY_H > > @@ -115,6 +119,14 @@ enum { > MIPI_DCS_READ_MEMORY_CONTINUE = 0x3E, > MIPI_DCS_SET_TEAR_SCANLINE = 0x44, > MIPI_DCS_GET_SCANLINE = 0x45, > + MIPI_DCS_SET_DISPLAY_BRIGHTNESS = 0x51, /* MIPI DCS 1.3 */ > + MIPI_DCS_GET_DISPLAY_BRIGHTNESS = 0x52, /* MIPI DCS 1.3 */ > + MIPI_DCS_WRITE_CONTROL_DISPLAY = 0x53, /* MIPI DCS 1.3 */ > + MIPI_DCS_GET_CONTROL_DISPLAY = 0x54, /* MIPI DCS 1.3 */ > + MIPI_DCS_WRITE_POWER_SAVE = 0x55, /* MIPI DCS 1.3 */ > + MIPI_DCS_GET_POWER_SAVE = 0x56, /* MIPI DCS 1.3 */ > + MIPI_DCS_SET_CABC_MIN_BRIGHTNESS = 0x5E, /* MIPI DCS 1.3 */ > + MIPI_DCS_GET_CABC_MIN_BRIGHTNESS = 0x5F, /* MIPI DCS 1.3 */ > MIPI_DCS_READ_DDB_START = 0xA1, > MIPI_DCS_READ_DDB_CONTINUE = 0xA8, > }; > @@ -127,4 +139,247 @@ enum { > #define MIPI_DCS_PIXEL_FMT_8BIT 2 > #define MIPI_DCS_PIXEL_FMT_3BIT 1 > > +struct mipi_dsi_host; > +struct mipi_dsi_device; > + > +/* request ACK from peripheral */ > +#define MIPI_DSI_MSG_REQ_ACK BIT(0) > +/* use Low Power Mode to transmit message */ > +#define MIPI_DSI_MSG_USE_LPM BIT(1) > + > +/** > + * struct mipi_dsi_msg - read/write DSI buffer > + * @channel: virtual channel id > + * @type: payload data type > + * @flags: flags controlling this message transmission > + * @tx_len: length of @tx_buf > + * @tx_buf: data to be written > + * @rx_len: length of @rx_buf > + * @rx_buf: data to be read, or NULL > + */ > +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 - represents a MIPI DSI packet in protocol format > + * @size: size (in bytes) of the packet > + * @header: the four bytes that make up the header (Data ID, Word Count or > + * Packet Data, and ECC) > + * @payload_length: number of bytes in the payload > + * @payload: a pointer to a buffer containing the payload, if any > + */ > +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 - DSI bus operations > + * @attach: attach DSI device to DSI host > + * @detach: detach DSI device from DSI host > + * @transfer: transmit a DSI packet > + * > + * DSI packets transmitted by .transfer() are passed in as mipi_dsi_msg > + * structures. This structure contains information about the type of packet > + * being transmitted as well as the transmit and receive buffers. When an > + * error is encountered during transmission, this function will return a > + * negative error code. On success it shall return the number of bytes > + * transmitted for write packets or the number of bytes received for read > + * packets. > + * > + * Note that typically DSI packet transmission is atomic, so the .transfer() > + * function will seldomly return anything other than the number of bytes > + * contained in the transmit buffer on success. > + */ > +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); This looks like an interface that should use driver model? > + > +int mipi_dsi_attach(struct mipi_dsi_device *dsi); > +int mipi_dsi_detach(struct mipi_dsi_device *dsi); > +int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt); Should there be a MIPI uclass? [..] > +ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi, > + const void *data, size_t len); These functions all need full function comments. > +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); > +int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 > scanline); > +int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, > + u16 brightness); > +int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, > + u16 *brightness); > + > #endif > -- > 1.9.1 > Regards, Simon _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot