Skip to content

Commit e621c23

Browse files
committed
drivers: display: Change display buffer pitch from pixel to byte
The `pitch` in `struct display_buffer_descriptor` is defined as "Number of pixels between consecutive rows in the data buffer". Limitation: Some display controller needs the pitch of byte be dividable by an even value (e.g., 4, 64, ...), if the parameter pitch here is the number of pixels, then the RGB888 (3 bytes per pixel) can't work Change the unit of `pitch` from pixel to byte Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
1 parent 923ece1 commit e621c23

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

include/zephyr/drivers/display.h

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,46 @@ struct display_capabilities {
143143
enum display_orientation current_orientation;
144144
};
145145

146-
/** @brief Structure to describe display data buffer layout */
146+
/**
147+
* @brief Structure to describe display data buffer layout
148+
*
149+
* @verbatim
150+
* Frame Buffer Memory Layout:
151+
*
152+
* <----------------- pitch (bytes per row) ------------------>
153+
* <------ width * bytes_per_pixel ------>
154+
* +---------------------------------------+--------------------+
155+
* | Pixel | Pixel | Pixel | ... | Pixel | Padding/Unused | ^
156+
* | (0,0) | (1,0) | (2,0) | |(w-1,0) | | |
157+
* +---------------------------------------+--------------------+ |
158+
* | Pixel | Pixel | Pixel | ... | Pixel | Padding/Unused | |
159+
* | (0,1) | (1,1) | (2,1) | |(w-1,1) | | height
160+
* +---------------------------------------+--------------------+ (rows)
161+
* | Pixel | Pixel | Pixel | ... | Pixel | Padding/Unused | |
162+
* | (0,2) | (1,2) | (2,2) | |(w-1,2) | | |
163+
* +---------------------------------------+--------------------+ |
164+
* | ... | ... | ... | ... | ... | ... | |
165+
* +---------------------------------------+--------------------+ |
166+
* | Pixel | Pixel | Pixel | ... | Pixel | Padding/Unused | |
167+
* |(0,h-1)|(1,h-1)|(2,h-1)| |(w-1,h-1)| | v
168+
* +---------------------------------------+---------------------+
169+
*
170+
* width = Number of pixels per row (visible width)
171+
* height = Number of rows (visible height)
172+
* pitch = Number of bytes per row (including padding for alignment)
173+
*
174+
* Note: pitch >= width * bytes_per_pixel
175+
* The difference is padding added for memory alignment requirements.
176+
* @endverbatim
177+
*/
147178
struct display_buffer_descriptor {
148179
/** Data buffer size in bytes */
149180
uint32_t buf_size;
150181
/** Data buffer row width in pixels */
151182
uint16_t width;
152183
/** Data buffer column height in pixels */
153184
uint16_t height;
154-
/** Number of pixels between consecutive rows in the data buffer */
185+
/** Number of bytes between consecutive rows in the data buffer */
155186
uint16_t pitch;
156187
/** Indicates that this is not the last write buffer of the frame */
157188
bool frame_incomplete;

include/zephyr/drivers/mipi_dbi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ static inline int mipi_dbi_command_read(const struct device *dev,
258258
* @param config MIPI DBI configuration
259259
* @param framebuf: framebuffer to write to display
260260
* @param desc: descriptor of framebuffer to write. Note that the pitch must
261-
* be equal to width. "buf_size" field determines how many bytes will be
261+
* be equal to width * bytes_per_pixel (pitch is now in bytes per row).
262+
* "buf_size" field determines how many bytes will be
262263
* written.
263264
* @param pixfmt: pixel format of framebuffer data
264265
* @retval 0 buffer write succeeded.

0 commit comments

Comments
 (0)