diff --git a/drivers/display/display_co5300.c b/drivers/display/display_co5300.c index 934c14f3a19a3..503c318f26789 100644 --- a/drivers/display/display_co5300.c +++ b/drivers/display/display_co5300.c @@ -37,6 +37,7 @@ struct co5300_config { uint16_t panel_height; uint16_t channel; uint16_t num_of_lanes; + uint16_t frame_pitch_align; /* Pitch alignment requirement, in bytes. */ }; struct co5300_data { @@ -46,7 +47,7 @@ struct co5300_data { struct k_sem tear_effect_sem; /* Pointer to framebuffer */ uint8_t *frame_ptr; - uint32_t frame_pitch; + uint32_t frame_pitch; /* Pitch in bytes. */ }; /* Organized as MIPI_CMD | SIZE OF MIPI PARAM | MIPI PARAM */ @@ -108,12 +109,12 @@ static void co5300_copy_and_adjust_coordinates(const struct device *dev, /* Copy the update area to the framebuffer */ src = buf; - dst = data->frame_ptr + (y * data->frame_pitch * data->bytes_per_pixel) + dst = data->frame_ptr + (y * data->frame_pitch) + (x * data->bytes_per_pixel); for (uint16_t row = 0; row < desc->height; row++) { memcpy(dst, src, desc->width * data->bytes_per_pixel); - src += desc->pitch * data->bytes_per_pixel; - dst += data->frame_pitch * data->bytes_per_pixel; + src += desc->pitch; + dst += data->frame_pitch; } /* @@ -139,7 +140,7 @@ static void co5300_copy_and_adjust_coordinates(const struct device *dev, local_desc->height = ROUND_UP(local_desc->height, 2U); local_desc->pitch = data->frame_pitch; local_desc->frame_incomplete = desc->frame_incomplete; - local_desc->buf_size = local_desc->width * local_desc->height * data->bytes_per_pixel; + local_desc->buf_size = local_desc->pitch * local_desc->height; } static int co5300_write(const struct device *dev, @@ -222,7 +223,7 @@ static int co5300_write(const struct device *dev, /* Start memory write. */ /* The address and the total pixel size of the updated area. */ - src = data->frame_ptr + (local_y * data->frame_pitch * data->bytes_per_pixel) + src = data->frame_ptr + (local_y * data->frame_pitch) + (local_x * data->bytes_per_pixel); tx_size = local_desc.buf_size; @@ -246,11 +247,11 @@ static int co5300_write(const struct device *dev, } /* Advance source pointer and decrement remaining */ - if (local_desc.pitch > local_desc.width) { + if (local_desc.pitch > local_desc.width * data->bytes_per_pixel) { total_bytes_sent += bytes_written; src += bytes_written + total_bytes_sent / (local_desc.width * data->bytes_per_pixel) * - ((local_desc.pitch - local_desc.width) * data->bytes_per_pixel); + (local_desc.pitch - local_desc.width * data->bytes_per_pixel); } else { src += bytes_written; } @@ -342,6 +343,7 @@ static int co5300_set_pixel_format(const struct device *dev, /* Update the format in the device data after DCS command succeeds. */ data->bytes_per_pixel = bytes_per_pixel; data->pixel_format = mipi_pixel_format; + data->frame_pitch = ROUND_UP(config->panel_width * bytes_per_pixel, config->frame_pitch_align); return 0; } @@ -552,13 +554,12 @@ static DEVICE_API(display, co5300_api) = { .tear_effect_gpios = GPIO_DT_SPEC_INST_GET_OR(node_id, tear_effect_gpios, {0}), \ .panel_width = DT_INST_PROP(node_id, width), \ .panel_height = DT_INST_PROP(node_id, height), \ + .frame_pitch_align = DT_INST_PROP_OR(node_id, pitch_align, 1), \ }; \ CO5300_FRAMEBUFFER_DECL(node_id); \ static struct co5300_data co5300_data_##node_id = { \ .pixel_format = DT_INST_PROP(node_id, pixel_format), \ .frame_ptr = CO5300_FRAMEBUFFER(node_id), \ - .frame_pitch = ROUND_UP(DT_INST_PROP(node_id, width), \ - DT_INST_PROP(node_id, pitch_align)), \ }; \ DEVICE_DT_INST_DEFINE(node_id, \ &co5300_init, \ diff --git a/drivers/display/display_dummy.c b/drivers/display/display_dummy.c index de9394b0ea759..62b9021a98a08 100644 --- a/drivers/display/display_dummy.c +++ b/drivers/display/display_dummy.c @@ -37,19 +37,21 @@ static int dummy_display_write(const struct device *dev, const uint16_t x, const void *buf) { const struct dummy_display_config *config = dev->config; + struct dummy_display_data *disp_data = dev->data; + uint8_t bytes_per_pixel; + + bytes_per_pixel = DISPLAY_BITS_PER_PIXEL(disp_data->current_pixel_format) / 8; - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); - __ASSERT(desc->pitch <= config->width, - "Pitch in descriptor is larger than screen size"); + __ASSERT(desc->width * bytes_per_pixel <= desc->pitch, "Pitch is smaller than width"); __ASSERT(desc->height <= config->height, "Height in descriptor is larger than screen size"); - __ASSERT(x + desc->pitch <= config->width, + __ASSERT(x + desc->width <= config->width, "Writing outside screen boundaries in horizontal direction"); __ASSERT(y + desc->height <= config->height, "Writing outside screen boundaries in vertical direction"); - if (desc->width > desc->pitch || - x + desc->pitch > config->width || + if (desc->width * bytes_per_pixel > desc->pitch || + x + desc->width > config->width || y + desc->height > config->height) { return -EINVAL; } diff --git a/drivers/display/display_gc9x01x.c b/drivers/display/display_gc9x01x.c index 43ae97d00013f..9cd27e875d25c 100644 --- a/drivers/display/display_gc9x01x.c +++ b/drivers/display/display_gc9x01x.c @@ -516,8 +516,8 @@ static int gc9x01x_write(const struct device *dev, const uint16_t x, const uint1 uint16_t nbr_of_writes; uint16_t write_h; - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); - __ASSERT((desc->pitch * data->bytes_per_pixel * desc->height) <= desc->buf_size, + __ASSERT(desc->width * data->bytes_per_pixel <= desc->pitch, "Pitch is smaller than width"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); LOG_DBG("Writing %dx%d (w,h) @ %dx%d (x,y)", desc->width, desc->height, x, y); @@ -526,7 +526,7 @@ static int gc9x01x_write(const struct device *dev, const uint16_t x, const uint1 return ret; } - if (desc->pitch > desc->width) { + if (desc->pitch > desc->width * data->bytes_per_pixel) { write_h = 1U; nbr_of_writes = desc->height; mipi_desc.height = 1; @@ -540,7 +540,7 @@ static int gc9x01x_write(const struct device *dev, const uint16_t x, const uint1 mipi_desc.width = desc->width; /* Per MIPI API, pitch must always match width */ - mipi_desc.pitch = desc->width; + mipi_desc.pitch = desc->width * data->bytes_per_pixel; mipi_desc.frame_incomplete = desc->frame_incomplete; ret = gc9x01x_transmit(dev, GC9X01X_CMD_MEMWR, NULL, 0); @@ -558,7 +558,7 @@ static int gc9x01x_write(const struct device *dev, const uint16_t x, const uint1 return ret; } - write_data_start += desc->pitch * data->bytes_per_pixel; + write_data_start += desc->pitch; } return 0; diff --git a/drivers/display/display_hub12.c b/drivers/display/display_hub12.c index 29fcaf625057e..77b83592ba057 100644 --- a/drivers/display/display_hub12.c +++ b/drivers/display/display_hub12.c @@ -157,7 +157,7 @@ static int hub12_write(const struct device *dev, const uint16_t x, const uint16_ return -EINVAL; } - if (desc->pitch != desc->width) { + if (desc->pitch != (desc->width / HUB12_PIXELS_PER_BYTE)) { LOG_ERR("Unsupported pitch"); return -ENOTSUP; } @@ -173,7 +173,7 @@ static int hub12_write(const struct device *dev, const uint16_t x, const uint16_ memcpy(data->framebuffer, src, fb_size); } else { /* Partial update */ - size_t src_pitch_bytes = desc->pitch / HUB12_PIXELS_PER_BYTE; + size_t src_pitch_bytes = desc->pitch; size_t dest_pitch_bytes = config->width / HUB12_PIXELS_PER_BYTE; for (uint16_t j = 0; j < desc->height; j++) { diff --git a/drivers/display/display_ili9xxx.c b/drivers/display/display_ili9xxx.c index ef258cfed8922..228678a815053 100644 --- a/drivers/display/display_ili9xxx.c +++ b/drivers/display/display_ili9xxx.c @@ -136,9 +136,8 @@ static int ili9xxx_write(const struct device *dev, const uint16_t x, uint16_t nbr_of_writes; uint16_t write_h; - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); - __ASSERT((desc->pitch * data->bytes_per_pixel * desc->height) <= - desc->buf_size, + __ASSERT(desc->width * data->bytes_per_pixel <= desc->pitch, "Pitch is smaller than width"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); LOG_DBG("Writing %dx%d (w,h) @ %dx%d (x,y)", desc->width, desc->height, @@ -148,11 +147,11 @@ static int ili9xxx_write(const struct device *dev, const uint16_t x, return r; } - if (desc->pitch > desc->width) { + if (desc->pitch > desc->width * data->bytes_per_pixel) { write_h = 1U; nbr_of_writes = desc->height; mipi_desc.height = 1; - mipi_desc.buf_size = desc->pitch * data->bytes_per_pixel; + mipi_desc.buf_size = desc->pitch; } else { write_h = desc->height; mipi_desc.height = desc->height; @@ -162,7 +161,7 @@ static int ili9xxx_write(const struct device *dev, const uint16_t x, mipi_desc.width = desc->width; /* Per MIPI API, pitch must always match width */ - mipi_desc.pitch = desc->width; + mipi_desc.pitch = desc->width * data->bytes_per_pixel; mipi_desc.frame_incomplete = desc->frame_incomplete; r = ili9xxx_transmit(dev, ILI9XXX_RAMWR, NULL, 0); @@ -180,7 +179,7 @@ static int ili9xxx_write(const struct device *dev, const uint16_t x, return r; } - write_data_start += desc->pitch * data->bytes_per_pixel; + write_data_start += desc->pitch; } return 0; @@ -204,9 +203,8 @@ static int ili9xxx_read(const struct device *dev, const uint16_t x, return -ENOTSUP; } - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); - __ASSERT((desc->pitch * data->bytes_per_pixel * desc->height) <= - desc->buf_size, + __ASSERT(desc->width * data->bytes_per_pixel <= desc->pitch, "Pitch is smaller than width"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Output buffer too small"); LOG_DBG("Reading %dx%d (w,h) @ %dx%d (x,y)", desc->width, desc->height, @@ -235,7 +233,7 @@ static int ili9xxx_read(const struct device *dev, const uint16_t x, mipi_desc.width = 1; mipi_desc.height = 1; /* Per MIPI API, pitch must always match width */ - mipi_desc.pitch = 1; + mipi_desc.pitch = 1 * data->bytes_per_pixel; nbr_of_reads = desc->width * desc->height; diff --git a/drivers/display/display_intel_multibootfb.c b/drivers/display/display_intel_multibootfb.c index f9182e1f0f462..93e52332f0274 100644 --- a/drivers/display/display_intel_multibootfb.c +++ b/drivers/display/display_intel_multibootfb.c @@ -23,7 +23,7 @@ struct framebuf_dev_config { struct framebuf_dev_data { void *buffer; - uint32_t pitch; + uint32_t pitch; /* In Bytes. */ }; static int framebuf_set_pixel_format(const struct device *dev, @@ -135,12 +135,12 @@ static int multiboot_framebuf_init(const struct device *dev) adj_x = info->fb_width - config->width; adj_y = info->fb_height - config->height; - data->pitch = (info->fb_pitch / 4) + adj_x; + data->pitch = info->fb_pitch + adj_x * sizeof(uint32_t); adj_x /= 2U; adj_y /= 2U; buffer = (uint32_t *) (uintptr_t) info->fb_addr_lo; buffer += adj_x; - buffer += adj_y * data->pitch; + buffer += adj_y * (data->pitch / sizeof(uint32_t)); data->buffer = buffer; return 0; } else { diff --git a/drivers/display/display_led_strip_matrix.c b/drivers/display/display_led_strip_matrix.c index f47521864d108..c54309d49463c 100644 --- a/drivers/display/display_led_strip_matrix.c +++ b/drivers/display/display_led_strip_matrix.c @@ -88,10 +88,13 @@ static struct led_rgb *pixel_address(const struct led_strip_matrix_config *confi static inline int check_descriptor(const struct led_strip_matrix_config *config, const uint16_t x, const uint16_t y, const struct display_buffer_descriptor *desc) { - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); - __ASSERT(desc->pitch <= config->width, "Pitch in descriptor is larger than screen size"); + const uint16_t bytes_per_pixel = (config->pixel_format == PIXEL_FORMAT_ARGB_8888 ? 4 : 3); + const uint16_t width_bytes = desc->width * bytes_per_pixel; + + __ASSERT(width_bytes <= desc->pitch, "Pitch is smaller than width"); + __ASSERT(desc->pitch <= config->width * bytes_per_pixel, "Pitch in descriptor is larger than screen size"); __ASSERT(desc->height <= config->height, "Height in descriptor is larger than screen size"); - __ASSERT(x + desc->pitch <= config->width, + __ASSERT(x + desc->width <= config->width, "Writing outside screen boundaries in horizontal direction"); __ASSERT(y + desc->height <= config->height, "Writing outside screen boundaries in vertical direction"); @@ -109,6 +112,7 @@ static int led_strip_matrix_write(const struct device *dev, const uint16_t x, co { const struct led_strip_matrix_config *config = dev->config; const uint8_t *buf_ptr = buf; + const uint16_t bytes_per_pixel = (config->pixel_format == PIXEL_FORMAT_ARGB_8888 ? 4 : 3); int rc; rc = check_descriptor(config, x, y, desc); @@ -138,8 +142,7 @@ static int led_strip_matrix_write(const struct device *dev, const uint16_t x, co buf_ptr++; } } - buf_ptr += (desc->pitch - desc->width) * - (config->pixel_format == PIXEL_FORMAT_ARGB_8888 ? 4 : 3); + buf_ptr += desc->pitch - (desc->width * bytes_per_pixel); } for (size_t i = 0; i < config->num_of_strips; i++) { @@ -158,6 +161,7 @@ static int led_strip_matrix_read(const struct device *dev, const uint16_t x, con { const struct led_strip_matrix_config *config = dev->config; uint8_t *buf_ptr = buf; + const uint16_t bytes_per_pixel = (config->pixel_format == PIXEL_FORMAT_ARGB_8888 ? 4 : 3); int rc; rc = check_descriptor(config, x, y, desc); @@ -183,8 +187,7 @@ static int led_strip_matrix_read(const struct device *dev, const uint16_t x, con buf_ptr++; } } - buf_ptr += (desc->pitch - desc->width) * - (config->pixel_format == PIXEL_FORMAT_ARGB_8888 ? 4 : 3); + buf_ptr += desc->pitch - (desc->width * bytes_per_pixel); } return 0; diff --git a/drivers/display/display_max7219.c b/drivers/display/display_max7219.c index a04b92394f899..1023a82a55e77 100644 --- a/drivers/display/display_max7219.c +++ b/drivers/display/display_max7219.c @@ -151,11 +151,11 @@ static int max7219_write(const struct device *dev, const uint16_t x, const uint1 /* * MAX7219 only supports PIXEL_FORMAT_MONO01. 1 bit stands for 1 pixel. */ - __ASSERT((desc->pitch * desc->height) <= (desc->buf_size * 8U), "Input buffer too small"); - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); - __ASSERT(desc->pitch <= max_width, "Pitch in descriptor is larger than screen size"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); + __ASSERT((desc->width + 7U) / 8U <= desc->pitch, "Pitch is smaller than width"); + __ASSERT(desc->pitch * 8U <= max_width, "Pitch in descriptor is larger than screen size"); __ASSERT(desc->height <= max_height, "Height in descriptor is larger than screen size"); - __ASSERT(x + desc->pitch <= max_width, + __ASSERT(x + desc->pitch * 8U <= max_width, "Writing outside screen boundaries in horizontal direction"); __ASSERT(y + desc->height <= max_height, "Writing outside screen boundaries in vertical direction"); @@ -164,7 +164,7 @@ static int max7219_write(const struct device *dev, const uint16_t x, const uint1 return -EINVAL; } - if ((x + desc->pitch) > max_width || (y + desc->height) > max_height) { + if ((x + desc->pitch * 8U) > max_width || (y + desc->height) > max_height) { return -EINVAL; } @@ -311,7 +311,7 @@ static int max7219_init(const struct device *dev) .buf_size = dev_config->num_cascading * MAX7219_DIGITS_PER_DEVICE, .height = dev_config->num_cascading * MAX7219_DIGITS_PER_DEVICE, .width = MAX7219_DIGITS_PER_DEVICE, - .pitch = MAX7219_DIGITS_PER_DEVICE, + .pitch = (MAX7219_DIGITS_PER_DEVICE + 7U) / 8U, }; ret = max7219_write(dev, 0, 0, &desc, dev_data->digit_buf); diff --git a/drivers/display/display_mcux_dcnano_lcdif.c b/drivers/display/display_mcux_dcnano_lcdif.c index f94f09b18538e..7c7787c0af710 100644 --- a/drivers/display/display_mcux_dcnano_lcdif.c +++ b/drivers/display/display_mcux_dcnano_lcdif.c @@ -53,7 +53,7 @@ static int mcux_dcnano_lcdif_write(const struct device *dev, const uint16_t x, const uint8_t *src; uint8_t *dst; - __ASSERT((data->pixel_bytes * desc->pitch * desc->height) <= + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); LOG_DBG("W=%d, H=%d @%d,%d", desc->width, desc->height, x, y); @@ -61,7 +61,7 @@ static int mcux_dcnano_lcdif_write(const struct device *dev, const uint16_t x, if ((x == 0) && (y == 0) && (desc->width == config->dpi_config.panelWidth) && (desc->height == config->dpi_config.panelHeight) && - (desc->pitch == desc->width)) { + (desc->pitch == (desc->width * data->pixel_bytes))) { /* We can use the display buffer directly, without copying */ LOG_DBG("Setting FB from %p->%p", (void *)data->active_fb, (void *)buf); @@ -87,7 +87,7 @@ static int mcux_dcnano_lcdif_write(const struct device *dev, const uint16_t x, for (h_idx = 0; h_idx < desc->height; h_idx++) { memcpy(dst, src, data->pixel_bytes * desc->width); - src += data->pixel_bytes * desc->pitch; + src += desc->pitch; dst += data->pixel_bytes * config->dpi_config.panelWidth; } LOG_DBG("Setting FB from %p->%p", (void *) data->active_fb, diff --git a/drivers/display/display_mcux_elcdif.c b/drivers/display/display_mcux_elcdif.c index f5fce6d43cd11..a0dda3a4b5d1b 100644 --- a/drivers/display/display_mcux_elcdif.c +++ b/drivers/display/display_mcux_elcdif.c @@ -89,7 +89,8 @@ static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const u LOG_DBG("W=%d, H=%d, @%d,%d", desc->width, desc->height, x, y); - if ((x == 0) && (y == 0) && (desc->width == config->rgb_mode.panelWidth) && + if ((x == 0) && (y == 0) && + (desc->pitch == config->rgb_mode.panelWidth * dev_data->pixel_bytes) && (desc->height == config->rgb_mode.panelHeight) && (desc->pitch == desc->width)) { /* We can use the display buffer directly, no need to copy it */ LOG_DBG("Setting FB from %p->%p", (void *)dev_data->active_fb, (void *)buf); @@ -97,6 +98,7 @@ static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const u full_fb = true; } else if ((x == 0) && (y == 0) && (desc->width == config->rgb_mode.panelHeight) && (desc->height == config->rgb_mode.panelWidth) && (desc->pitch == desc->width) && + (desc->pitch == config->rgb_mode.panelHeight * dev_data->pixel_bytes) && IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP)) { /* With the PXP, we can rotate this display buffer to align * with output dimensions @@ -126,7 +128,7 @@ static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const u for (h_idx = 0; h_idx < desc->height; h_idx++) { memcpy(dst, src, dev_data->pixel_bytes * desc->width); - src += dev_data->pixel_bytes * desc->pitch; + src += desc->pitch; dst += dev_data->pixel_bytes * config->rgb_mode.panelWidth; } @@ -187,7 +189,7 @@ static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const u } pxp_dma.channel_direction = MEMORY_TO_MEMORY; - pxp_dma.source_data_size = desc->width * dev_data->pixel_bytes; + pxp_dma.source_data_size = desc->pitch; pxp_dma.dest_data_size = config->rgb_mode.panelWidth * dev_data->pixel_bytes; /* Burst lengths are heights of source/dest buffer in pixels */ pxp_dma.source_burst_length = desc->height; diff --git a/drivers/display/display_mcux_lcdifv3.c b/drivers/display/display_mcux_lcdifv3.c index e759f7c2b118c..9cf2536b5e184 100644 --- a/drivers/display/display_mcux_lcdifv3.c +++ b/drivers/display/display_mcux_lcdifv3.c @@ -80,13 +80,13 @@ static int mcux_lcdifv3_write(const struct device *dev, const uint16_t x, const const uint8_t *src; uint8_t *dst; - __ASSERT((data->pixel_bytes * desc->pitch * desc->height) <= desc->buf_size, + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); LOG_DBG("W=%d, H=%d @%d,%d", desc->width, desc->height, x, y); if ((x == 0) && (y == 0) && (desc->width == config->display_config.panelWidth) && - (desc->height == config->display_config.panelHeight) && (desc->pitch == desc->width)) { + (desc->height == config->display_config.panelHeight) && (desc->pitch == desc->width * data->pixel_bytes)) { /* We can use the display buffer directly, without copying */ LOG_DBG("Setting FB from %p->%p", (void *)data->active_fb, (void *)buf); data->active_fb = buf; @@ -111,7 +111,7 @@ static int mcux_lcdifv3_write(const struct device *dev, const uint16_t x, const for (h_idx = 0; h_idx < desc->height; h_idx++) { memcpy(dst, src, data->pixel_bytes * desc->width); - src += data->pixel_bytes * desc->pitch; + src += desc->pitch; dst += data->pixel_bytes * config->display_config.panelWidth; } LOG_DBG("Setting FB from %p->%p", (void *)data->active_fb, diff --git a/drivers/display/display_nrf_led_matrix.c b/drivers/display/display_nrf_led_matrix.c index babd10eb0464a..8d20f50a0615d 100644 --- a/drivers/display/display_nrf_led_matrix.c +++ b/drivers/display/display_nrf_led_matrix.c @@ -247,11 +247,11 @@ static int api_write(const struct device *dev, return -EINVAL; } - if (desc->pitch < desc->width) { + if (desc->pitch < (desc->width + 7) / 8) { return -EINVAL; } - uint16_t to_skip = desc->pitch - desc->width; + uint16_t to_skip = (desc->pitch * 8) - desc->width; uint8_t mask = 0; uint8_t data = 0; diff --git a/drivers/display/display_renesas_lcdc.c b/drivers/display/display_renesas_lcdc.c index f2d3b7ca2c979..fe7630281afd0 100644 --- a/drivers/display/display_renesas_lcdc.c +++ b/drivers/display/display_renesas_lcdc.c @@ -508,7 +508,7 @@ static int display_smartbond_read(const struct device *dev, k_sem_take(&data->dma_sync_sem, K_FOREVER); src += data->layer.stride; - dst += (desc->pitch * config->pixel_size); + dst += desc->pitch; } if (dma_stop(data->dma, data->dma_channel)) { @@ -577,7 +577,7 @@ static int display_smartbond_write(const struct device *dev, k_sem_take(&data->dma_sync_sem, K_FOREVER); dst += data->layer.stride; - src += (desc->pitch * config->pixel_size); + src += desc->pitch; } if (dma_stop(data->dma, data->dma_channel)) { diff --git a/drivers/display/display_renesas_ra.c b/drivers/display/display_renesas_ra.c index b7e5cb8497f21..f7f2804faca9d 100644 --- a/drivers/display/display_renesas_ra.c +++ b/drivers/display/display_renesas_ra.c @@ -70,12 +70,12 @@ static int ra_display_write(const struct device *dev, const uint16_t x, const ui bool vsync_wait = false; fsp_err_t err; - if (desc->pitch < desc->width) { + if (desc->pitch < (desc->width * data->pixel_size)) { LOG_ERR("Pitch is smaller than width"); return -EINVAL; } - if ((desc->pitch * data->pixel_size * desc->height) > desc->buf_size) { + if ((desc->pitch * desc->height) > desc->buf_size) { LOG_ERR("Input buffer too small"); return -EINVAL; } @@ -112,7 +112,7 @@ static int ra_display_write(const struct device *dev, const uint16_t x, const ui for (row = 0; row < desc->height; row++) { (void)memcpy(dst, src, desc->width * data->pixel_size); dst += (config->width * data->pixel_size); - src += (desc->pitch * data->pixel_size); + src += desc->pitch; } #endif /* CONFIG_RENESAS_RA_GLCDC_FB_NUM == 0 */ } @@ -165,7 +165,7 @@ static int ra_display_read(const struct device *dev, const uint16_t x, const uin for (row = 0; row < desc->height; row++) { (void)memcpy(dst, src, desc->width * data->pixel_size); src += (config->width * data->pixel_size); - dst += (desc->pitch * data->pixel_size); + dst += desc->pitch; } return 0; diff --git a/drivers/display/display_rm67162.c b/drivers/display/display_rm67162.c index fc6c6f4dd9bdb..3ac2bbc6536f6 100644 --- a/drivers/display/display_rm67162.c +++ b/drivers/display/display_rm67162.c @@ -381,10 +381,10 @@ static int rm67162_write_fb(const struct device *dev, bool first_write, return (int)wlen; } /* Advance source pointer and decrement remaining */ - if (desc->pitch > desc->width) { + if (desc->pitch > desc->width * data->bytes_per_pixel) { len_sent += wlen; local_src += wlen + len_sent / (desc->width * data->bytes_per_pixel) * - ((desc->pitch - desc->width) * data->bytes_per_pixel); + (desc->pitch - desc->width * data->bytes_per_pixel); } else { local_src += wlen; } diff --git a/drivers/display/display_sdl.c b/drivers/display/display_sdl.c index 0b5af2e774621..3de34aba7c3fe 100644 --- a/drivers/display/display_sdl.c +++ b/drivers/display/display_sdl.c @@ -218,7 +218,7 @@ static void sdl_display_write_argb8888(void *disp_buf, __ASSERT((desc->pitch * 4U * desc->height) <= desc->buf_size, "Input buffer too small"); - memcpy(disp_buf, buf, desc->pitch * 4U * desc->height); + memcpy(disp_buf, buf, desc->pitch * desc->height); } static void sdl_display_write_rgb888(uint8_t *disp_buf, @@ -229,13 +229,12 @@ static void sdl_display_write_rgb888(uint8_t *disp_buf, uint32_t pixel; const uint8_t *byte_ptr; - __ASSERT((desc->pitch * 3U * desc->height) <= desc->buf_size, + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); for (h_idx = 0U; h_idx < desc->height; ++h_idx) { for (w_idx = 0U; w_idx < desc->width; ++w_idx) { - byte_ptr = (const uint8_t *)buf + - ((h_idx * desc->pitch) + w_idx) * 3U; + byte_ptr = (const uint8_t *)buf + (h_idx * desc->pitch) + (w_idx * 3U); pixel = *byte_ptr << 16; pixel |= *(byte_ptr + 1) << 8; pixel |= *(byte_ptr + 2); @@ -253,13 +252,12 @@ static void sdl_display_write_al88(uint8_t *disp_buf, uint32_t pixel; const uint8_t *byte_ptr; - __ASSERT((desc->pitch * 2U * desc->height) <= desc->buf_size, + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); for (h_idx = 0U; h_idx < desc->height; ++h_idx) { for (w_idx = 0U; w_idx < desc->width; ++w_idx) { - byte_ptr = (const uint8_t *)buf + - ((h_idx * desc->pitch) + w_idx) * 2U; + byte_ptr = (const uint8_t *)buf + (h_idx * desc->pitch) + (w_idx * 2U); pixel = *(byte_ptr + 1) << 24; pixel |= *(byte_ptr) << 16; pixel |= *(byte_ptr) << 8; @@ -279,13 +277,13 @@ static void sdl_display_write_rgb565(uint8_t *disp_buf, const uint16_t *pix_ptr; uint16_t rgb565; - __ASSERT((desc->pitch * 2U * desc->height) <= desc->buf_size, + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); for (h_idx = 0U; h_idx < desc->height; ++h_idx) { for (w_idx = 0U; w_idx < desc->width; ++w_idx) { - pix_ptr = (const uint16_t *)buf + - ((h_idx * desc->pitch) + w_idx); + pix_ptr = (const uint16_t *)((const uint8_t *)buf + + (h_idx * desc->pitch)) + w_idx; rgb565 = sys_be16_to_cpu(*pix_ptr); pixel = (((rgb565 >> 11) & 0x1F) * 255 / 31) << 16; pixel |= (((rgb565 >> 5) & 0x3F) * 255 / 63) << 8; @@ -304,13 +302,13 @@ static void sdl_display_write_bgr565(uint8_t *disp_buf, uint32_t pixel; const uint16_t *pix_ptr; - __ASSERT((desc->pitch * 2U * desc->height) <= desc->buf_size, + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); for (h_idx = 0U; h_idx < desc->height; ++h_idx) { for (w_idx = 0U; w_idx < desc->width; ++w_idx) { - pix_ptr = (const uint16_t *)buf + - ((h_idx * desc->pitch) + w_idx); + pix_ptr = (const uint16_t *)((const uint8_t *)buf + + (h_idx * desc->pitch)) + w_idx; pixel = (((*pix_ptr >> 11) & 0x1F) * 255 / 31) << 16; pixel |= (((*pix_ptr >> 5) & 0x3F) * 255 / 63) << 8; pixel |= (*pix_ptr & 0x1F) * 255 / 31; @@ -332,8 +330,7 @@ static void sdl_display_write_mono(uint8_t *disp_buf, uint32_t one_color; uint8_t *disp_buf_start; - __ASSERT((desc->pitch * desc->height) <= (desc->buf_size * 8U), - "Input buffer too small"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); __ASSERT((desc->height % 8) == 0U, "Input buffer height not aligned per 8 pixels"); @@ -473,7 +470,7 @@ static void sdl_display_read_argb8888(const uint8_t *read_buf, { __ASSERT((desc->pitch * 4U * desc->height) <= desc->buf_size, "Read buffer is too small"); - memcpy(buf, read_buf, desc->pitch * 4U * desc->height); + memcpy(buf, read_buf, desc->pitch * desc->height); } static void sdl_display_read_rgb888(const uint8_t *read_buf, @@ -484,10 +481,10 @@ static void sdl_display_read_rgb888(const uint8_t *read_buf, uint8_t *buf8; const uint32_t *pix_ptr; - __ASSERT((desc->pitch * 3U * desc->height) <= desc->buf_size, "Read buffer is too small"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Read buffer is too small"); for (h_idx = 0U; h_idx < desc->height; ++h_idx) { - buf8 = ((uint8_t *)buf) + desc->pitch * 3U * h_idx; + buf8 = ((uint8_t *)buf) + desc->pitch * h_idx; for (w_idx = 0U; w_idx < desc->width; ++w_idx) { pix_ptr = (const uint32_t *)read_buf + ((h_idx * desc->pitch) + w_idx); @@ -510,10 +507,10 @@ static void sdl_display_read_rgb565(const uint8_t *read_buf, uint16_t *buf16; const uint32_t *pix_ptr; - __ASSERT((desc->pitch * 2U * desc->height) <= desc->buf_size, "Read buffer is too small"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Read buffer is too small"); for (h_idx = 0U; h_idx < desc->height; ++h_idx) { - buf16 = (void *)(((uint8_t *)buf) + desc->pitch * 2U * h_idx); + buf16 = (void *)(((uint8_t *)buf) + desc->pitch * h_idx); for (w_idx = 0U; w_idx < desc->width; ++w_idx) { pix_ptr = (const uint32_t *)read_buf + ((h_idx * desc->pitch) + w_idx); @@ -535,10 +532,10 @@ static void sdl_display_read_bgr565(const uint8_t *read_buf, uint16_t *buf16; const uint32_t *pix_ptr; - __ASSERT((desc->pitch * 2U * desc->height) <= desc->buf_size, "Read buffer is too small"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Read buffer is too small"); for (h_idx = 0U; h_idx < desc->height; ++h_idx) { - buf16 = (void *)(((uint8_t *)buf) + desc->pitch * 2U * h_idx); + buf16 = (void *)(((uint8_t *)buf) + desc->pitch * h_idx); for (w_idx = 0U; w_idx < desc->width; ++w_idx) { pix_ptr = (const uint32_t *)read_buf + ((h_idx * desc->pitch) + w_idx); @@ -562,7 +559,7 @@ static void sdl_display_read_mono(const uint8_t *read_buf, const uint32_t *pix_ptr; uint8_t *buf8; - __ASSERT((desc->pitch * desc->height) <= (desc->buf_size * 8U), "Read buffer is too small"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Read buffer is too small"); __ASSERT((desc->height % 8U) == 0U, "Read buffer height not aligned per 8 pixels"); for (tile_idx = 0U; tile_idx < (desc->height / 8U); ++tile_idx) { @@ -613,10 +610,10 @@ static void sdl_display_read_al88(const uint8_t *read_buf, uint8_t *buf8; const uint32_t *pix_ptr; - __ASSERT((desc->pitch * 2U * desc->height) <= desc->buf_size, "Read buffer is too small"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Read buffer is too small"); for (h_idx = 0U; h_idx < desc->height; ++h_idx) { - buf8 = ((uint8_t *)buf) + desc->pitch * 2U * h_idx; + buf8 = ((uint8_t *)buf) + desc->pitch * h_idx; for (w_idx = 0U; w_idx < desc->width; ++w_idx) { pix_ptr = (const uint32_t *)read_buf + ((h_idx * desc->pitch) + w_idx); diff --git a/drivers/display/display_sh1122.c b/drivers/display/display_sh1122.c index c4ddf5feaef62..c4a0b78bf179b 100644 --- a/drivers/display/display_sh1122.c +++ b/drivers/display/display_sh1122.c @@ -217,7 +217,7 @@ static int sh1122_write_pixels_mipi(const struct device *dev, const uint8_t *buf struct display_buffer_descriptor mipi_desc; mipi_desc.buf_size = desc->width / 2; - mipi_desc.pitch = desc->pitch; + mipi_desc.pitch = desc->width / 2; /* One byte contains 2 pixels */ mipi_desc.width = desc->width; mipi_desc.height = 1; @@ -260,6 +260,7 @@ static int sh1122_write(const struct device *dev, const uint16_t x, const uint16 int total = 0; uint8_t ybuf = y; + /* Supported pixel format is PIXEL_FORMAT_L_8, pitch equals width */ if (desc->pitch != desc->width) { LOG_ERR("Pitch is not width"); return -EINVAL; diff --git a/drivers/display/display_ssd1320.c b/drivers/display/display_ssd1320.c index abc25b22cca22..5a9f9dc77db83 100644 --- a/drivers/display/display_ssd1320.c +++ b/drivers/display/display_ssd1320.c @@ -267,7 +267,7 @@ static int ssd1320_write_pixels_mipi(const struct device *dev, const uint8_t *bu int ret, i; int total = 0; - mipi_desc.pitch = desc->pitch; + mipi_desc.pitch = desc->pitch / 2; while (pixel_count > total) { i = ssd1320_convert_L_8(dev, buf, total, pixel_count); diff --git a/drivers/display/display_ssd1331.c b/drivers/display/display_ssd1331.c index d1e9957e0f3e0..0930c0ac397d7 100644 --- a/drivers/display/display_ssd1331.c +++ b/drivers/display/display_ssd1331.c @@ -194,7 +194,7 @@ static int ssd1331_write(const struct device *dev, const uint16_t x, const uint1 uint8_t x_position[] = {x, x + desc->width - 1}; uint8_t y_position[] = {y, y + desc->height - 1}; - if (desc->pitch != desc->width) { + if (desc->pitch != desc->width * 2) { LOG_ERR("Pitch is not width"); return -EINVAL; } diff --git a/drivers/display/display_ssd135x.c b/drivers/display/display_ssd135x.c index c662e5d66ffba..9e5c363a8367b 100644 --- a/drivers/display/display_ssd135x.c +++ b/drivers/display/display_ssd135x.c @@ -181,7 +181,7 @@ static int ssd135x_write(const struct device *dev, const uint16_t x, const uint1 (x + desc->width - 1 + config->column_offset) & 0x7F}; uint8_t y_position[] = {y & 0x7F, (y + desc->height - 1) & 0x7F}; - if (desc->pitch != desc->width) { + if (desc->pitch != desc->width * 2) { LOG_ERR("Pitch is not width"); return -EINVAL; } diff --git a/drivers/display/display_ssd1363.c b/drivers/display/display_ssd1363.c index 6618970b9a3bb..5f251964b1ca7 100644 --- a/drivers/display/display_ssd1363.c +++ b/drivers/display/display_ssd1363.c @@ -253,7 +253,7 @@ static int ssd1363_write_pixels_mipi(const struct device *dev, const uint8_t *bu int ret, i; int total = 0; - mipi_desc.pitch = desc->pitch; + mipi_desc.pitch = desc->pitch / 2; while (pixel_count > total) { i = ssd1363_convert_L_8(dev, buf, total, pixel_count); @@ -306,7 +306,7 @@ static int ssd1363_write(const struct device *dev, const uint16_t x, const uint1 size_t buf_len; int32_t pixel_count = desc->width * desc->height; - if (desc->pitch != desc->width) { + if (desc->pitch != desc->width * DISPLAY_BITS_PER_PIXEL(PIXEL_FORMAT_L_8) / 8) { LOG_ERR("Pitch is not width"); return -EINVAL; } diff --git a/drivers/display/display_st730x.c b/drivers/display/display_st730x.c index a8c6644b0cc04..00e67a7ba274d 100644 --- a/drivers/display/display_st730x.c +++ b/drivers/display/display_st730x.c @@ -365,8 +365,8 @@ static int st730x_write(const struct device *dev, const uint16_t x, const uint16 uint8_t x_position[] = {x_start, x_end}; uint8_t y_position[] = {y / ST730X_PPYA, (y + desc->height) / ST730X_PPYA - 1}; - if (desc->pitch != desc->width) { - LOG_ERR("Pitch is not width"); + if (desc->pitch * ST730X_PPB != desc->width) { + LOG_ERR("Pitch x ST730X_PPB is not width"); return -EINVAL; } @@ -416,6 +416,7 @@ static int st730x_write(const struct device *dev, const uint16_t x, const uint16 mipi_desc.buf_size = i * desc->width / ST730X_PPB; mipi_desc.width = desc->width; mipi_desc.height = i; + mipi_desc.pitch = desc->width / ST730X_PPB; err = mipi_dbi_write_display(config->mipi_dev, &config->dbi_config, config->conversion_buf, &mipi_desc, diff --git a/drivers/display/display_st75256.c b/drivers/display/display_st75256.c index 7be532ec78b69..948fa3f57d797 100644 --- a/drivers/display/display_st75256.c +++ b/drivers/display/display_st75256.c @@ -183,6 +183,7 @@ static int st75256_write_pixels_MONO01(const struct device *dev, const uint16_t struct display_buffer_descriptor mipi_desc; int ret; + mipi_desc.pitch = desc->width; for (int i = 0; i < desc->height / 8; i++) { st75256_set_window(dev, x, y + i * 8, desc->width, desc->height); st75256_start_write(dev); @@ -260,14 +261,6 @@ static int st75256_write(const struct device *dev, const uint16_t x, const uint1 struct st75256_data *data = dev->data; size_t buf_len; - /* pitch is always width because of vtiled monochrome at 8 pixels per byte - * or greyscale at one pixel per byte converted to vtiled 4 pixels per byte - */ - if (desc->pitch != desc->width) { - LOG_ERR("Pitch is not width"); - return -EINVAL; - } - if (data->current_pixel_format == PIXEL_FORMAT_MONO01) { buf_len = MIN(desc->buf_size, desc->height * desc->width / 8); if ((y % 8) != 0 || (desc->height % 8) != 0) { diff --git a/drivers/display/display_st7567.c b/drivers/display/display_st7567.c index 0ecf0ba6f5d60..9bdc190e94c8d 100644 --- a/drivers/display/display_st7567.c +++ b/drivers/display/display_st7567.c @@ -328,8 +328,8 @@ static int st7567_write(const struct device *dev, const uint16_t x, const uint16 { size_t buf_len; - if (desc->pitch < desc->width) { - LOG_ERR("Pitch is smaller than width"); + if (desc->pitch < desc->width / 8) { + LOG_ERR("Pitch is smaller than width in bytes"); return -EINVAL; } @@ -339,7 +339,7 @@ static int st7567_write(const struct device *dev, const uint16_t x, const uint16 return -EINVAL; } - if (desc->pitch > desc->width) { + if (desc->pitch > desc->width / 8) { LOG_ERR("Unsupported mode"); return -EINVAL; } diff --git a/drivers/display/display_st7735r.c b/drivers/display/display_st7735r.c index 6d785f9056d15..d711ae69ef5d7 100644 --- a/drivers/display/display_st7735r.c +++ b/drivers/display/display_st7735r.c @@ -183,8 +183,7 @@ static int st7735r_write(const struct device *dev, enum display_pixel_format fmt; struct display_buffer_descriptor mipi_desc; - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); - __ASSERT((desc->pitch * ST7735R_PIXEL_SIZE * desc->height) + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); LOG_DBG("Writing %dx%d (w,h) @ %dx%d (x,y)", @@ -194,11 +193,11 @@ static int st7735r_write(const struct device *dev, goto out; } - if (desc->pitch > desc->width) { + if (desc->pitch > (desc->width * ST7735R_PIXEL_SIZE)) { write_h = 1U; nbr_of_writes = desc->height; mipi_desc.height = 1; - mipi_desc.buf_size = desc->pitch * ST7735R_PIXEL_SIZE; + mipi_desc.buf_size = desc->pitch; } else { write_h = desc->height; nbr_of_writes = 1U; @@ -208,7 +207,7 @@ static int st7735r_write(const struct device *dev, mipi_desc.width = desc->width; /* Per MIPI API, pitch must always match width */ - mipi_desc.pitch = desc->width; + mipi_desc.pitch = desc->width * ST7735R_PIXEL_SIZE; if (!(config->madctl & ST7735R_MADCTL_BGR) != !config->rgb_is_inverted) { @@ -224,7 +223,7 @@ static int st7735r_write(const struct device *dev, goto out; } - write_data_start += (desc->pitch * ST7735R_PIXEL_SIZE); + write_data_start += desc->pitch; for (write_cnt = 1U; write_cnt < nbr_of_writes; ++write_cnt) { ret = mipi_dbi_write_display(config->mipi_dev, &config->dbi_config, @@ -235,7 +234,7 @@ static int st7735r_write(const struct device *dev, goto out; } - write_data_start += (desc->pitch * ST7735R_PIXEL_SIZE); + write_data_start += desc->pitch; } ret = 0; diff --git a/drivers/display/display_st7789v.c b/drivers/display/display_st7789v.c index 084d48a3e549c..8c80bf1ddc8c6 100644 --- a/drivers/display/display_st7789v.c +++ b/drivers/display/display_st7789v.c @@ -160,8 +160,8 @@ static int st7789v_write(const struct device *dev, enum display_pixel_format pixfmt; int ret; - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); - __ASSERT((desc->pitch * ST7789V_PIXEL_SIZE * desc->height) <= desc->buf_size, + __ASSERT(desc->width * ST7789V_PIXEL_SIZE <= desc->pitch, "Pitch is smaller than width"); + __ASSERT((desc->pitch * desc->height) <= desc->buf_size, "Input buffer too small"); LOG_DBG("Writing %dx%d (w,h) @ %dx%d (x,y)", @@ -171,11 +171,11 @@ static int st7789v_write(const struct device *dev, return ret; } - if (desc->pitch > desc->width) { + if ((desc->pitch / ST7789V_PIXEL_SIZE) > desc->width) { write_h = 1U; nbr_of_writes = desc->height; mipi_desc.height = 1; - mipi_desc.buf_size = desc->pitch * ST7789V_PIXEL_SIZE; + mipi_desc.buf_size = desc->pitch; } else { write_h = desc->height; nbr_of_writes = 1U; @@ -192,7 +192,7 @@ static int st7789v_write(const struct device *dev, mipi_desc.width = desc->width; /* Per MIPI API, pitch must always match width */ - mipi_desc.pitch = desc->width; + mipi_desc.pitch = desc->width * ST7789V_PIXEL_SIZE; /* Send RAMWR command */ ret = st7789v_transmit(dev, ST7789V_CMD_RAMWR, NULL, 0); @@ -207,7 +207,7 @@ static int st7789v_write(const struct device *dev, return ret; } - write_data_start += (desc->pitch * ST7789V_PIXEL_SIZE); + write_data_start += desc->pitch; } return ret; diff --git a/drivers/display/display_stm32_ltdc.c b/drivers/display/display_stm32_ltdc.c index 5d1ac60d81825..43fcc96816262 100644 --- a/drivers/display/display_stm32_ltdc.c +++ b/drivers/display/display_stm32_ltdc.c @@ -190,7 +190,7 @@ static int stm32_ltdc_write(const struct device *dev, const uint16_t x, if ((x == 0) && (y == 0) && (desc->width == config->width) && (desc->height == config->height) && - (desc->pitch == desc->width)) { + (desc->pitch == desc->width * data->current_pixel_size)) { /* Use buf as ltdc frame buffer directly if it length same as ltdc frame buffer. */ pend_buf = buf; } else { @@ -221,7 +221,7 @@ static int stm32_ltdc_write(const struct device *dev, const uint16_t x, (void) memcpy(dst, src, desc->width * data->current_pixel_size); sys_cache_data_flush_range(dst, desc->width * data->current_pixel_size); dst += (config->width * data->current_pixel_size); - src += (desc->pitch * data->current_pixel_size); + src += desc->pitch; } } @@ -269,7 +269,7 @@ static int stm32_ltdc_read(const struct device *dev, const uint16_t x, (void) memcpy(dst, src, desc->width * data->current_pixel_size); sys_cache_data_flush_range(dst, desc->width * data->current_pixel_size); src += (config->width * data->current_pixel_size); - dst += (desc->pitch * data->current_pixel_size); + dst += desc->pitch; } return 0; diff --git a/drivers/display/ls0xx.c b/drivers/display/ls0xx.c index f85ae1c6a4029..6819fa662933c 100644 --- a/drivers/display/ls0xx.c +++ b/drivers/display/ls0xx.c @@ -253,7 +253,7 @@ static int ls0xx_write(const struct device *dev, const uint16_t x, return -EINVAL; } - if (desc->pitch != desc->width) { + if (desc->pitch != (desc->width / LS0XX_PIXELS_PER_BYTE)) { LOG_ERR("Unsupported mode"); return -ENOTSUP; } diff --git a/drivers/display/mb_display.c b/drivers/display/mb_display.c index 0985c6d2bbfd0..ee85d42daafda 100644 --- a/drivers/display/mb_display.c +++ b/drivers/display/mb_display.c @@ -83,7 +83,7 @@ static int update_content(struct mb_display *disp, const struct mb_image *img) .buf_size = sizeof(struct mb_image), .width = MB_DISP_XRES, .height = MB_DISP_YRES, - .pitch = 8, + .pitch = 1, }; struct mb_image tmp_img; int ret; diff --git a/drivers/display/ssd1306.c b/drivers/display/ssd1306.c index f1ed5d73a33e4..566cc6958c5ee 100644 --- a/drivers/display/ssd1306.c +++ b/drivers/display/ssd1306.c @@ -306,7 +306,7 @@ static int ssd1306_write_sh1106(const struct device *dev, const uint16_t x, cons return -1; } - if (ssd1306_write_bus(dev, buf_ptr, desc->width, false)) { + if (ssd1306_write_bus(dev, buf_ptr, desc->pitch, false)) { return -1; } @@ -326,7 +326,7 @@ static int ssd1306_write(const struct device *dev, const uint16_t x, const uint1 const struct ssd1306_config *config = dev->config; size_t buf_len; - if (desc->pitch < desc->width) { + if (desc->pitch < desc->width / 8) { LOG_ERR("Pitch is smaller than width"); return -1; } @@ -337,7 +337,7 @@ static int ssd1306_write(const struct device *dev, const uint16_t x, const uint1 return -1; } - if (desc->pitch > desc->width) { + if (desc->pitch > desc->width / 8) { LOG_ERR("Unsupported mode"); return -1; } diff --git a/drivers/display/ssd1322.c b/drivers/display/ssd1322.c index db7ac6559ff75..00503241284bc 100644 --- a/drivers/display/ssd1322.c +++ b/drivers/display/ssd1322.c @@ -242,10 +242,6 @@ static int ssd1322_write(const struct device *dev, const uint16_t x, const uint1 int ret; uint8_t cmd_data[2]; - if (desc->pitch != desc->width) { - LOG_ERR("Pitch is different from width"); - return -EINVAL; - } switch (data->current_pixel_format) { case PIXEL_FORMAT_MONO01: diff --git a/drivers/display/ssd1327.c b/drivers/display/ssd1327.c index 4dec70fbf9e44..5d5c4214db6e7 100644 --- a/drivers/display/ssd1327.c +++ b/drivers/display/ssd1327.c @@ -284,7 +284,7 @@ static int ssd1327_write(const struct device *dev, const uint16_t x, const uint1 uint8_t x_position[] = {x / 2, (x + desc->width - 1) / 2}; uint8_t y_position[] = {y, y + desc->height - 1}; - if (desc->pitch != desc->width) { + if (desc->pitch != desc->width * sizeof(uint8_t)) { LOG_ERR("Pitch is not width"); return -EINVAL; } diff --git a/drivers/display/ssd16xx.c b/drivers/display/ssd16xx.c index 0b9a3559dd546..384b0e3b3dafd 100644 --- a/drivers/display/ssd16xx.c +++ b/drivers/display/ssd16xx.c @@ -316,12 +316,12 @@ static int ssd16xx_set_window(const struct device *dev, uint16_t panel_h = config->height - config->height % EPD_PANEL_NUMOF_ROWS_PER_PAGE; - if (desc->pitch < desc->width) { + if (desc->pitch < desc->width / SSD16XX_PIXELS_PER_BYTE) { LOG_ERR("Pitch is smaller than width"); return -EINVAL; } - if (desc->pitch > desc->width) { + if (desc->pitch > desc->width / SSD16XX_PIXELS_PER_BYTE) { LOG_ERR("Unsupported mode"); return -ENOTSUP; } @@ -422,7 +422,7 @@ static int ssd16xx_write(const struct device *dev, const uint16_t x, config->profiles[SSD16XX_PROFILE_PARTIAL] != NULL; const bool partial_refresh = !data->blanking_on && have_partial_refresh; const size_t buf_len = MIN(desc->buf_size, - desc->height * desc->width / 8); + desc->height * desc->pitch); int err; if (buf == NULL || buf_len == 0U) { @@ -498,7 +498,7 @@ int ssd16xx_read_ram(const struct device *dev, enum ssd16xx_ram ram_type, { const struct ssd16xx_data *data = dev->data; const size_t buf_len = MIN(desc->buf_size, - desc->height * desc->width / 8); + desc->height * desc->pitch); int err; uint8_t ram_ctrl; diff --git a/drivers/display/uc81xx.c b/drivers/display/uc81xx.c index edbf4d0cea47f..0c6b15bc4974d 100644 --- a/drivers/display/uc81xx.c +++ b/drivers/display/uc81xx.c @@ -399,9 +399,9 @@ static int uc81xx_write(const struct device *dev, const uint16_t x, const uint16 LOG_DBG("x %u, y %u, height %u, width %u, pitch %u", x, y, desc->height, desc->width, desc->pitch); - buf_len = MIN(desc->buf_size, - desc->height * desc->width / UC81XX_PIXELS_PER_BYTE); - __ASSERT(desc->width <= desc->pitch, "Pitch is smaller than width"); + buf_len = MIN(desc->buf_size, desc->height * desc->pitch); + __ASSERT(desc->width / UC81XX_PIXELS_PER_BYTE <= desc->pitch, + "Pitch is smaller than width"); __ASSERT(buf != NULL, "Buffer is not available"); __ASSERT(buf_len != 0U, "Buffer of length zero"); __ASSERT(!(desc->width % UC81XX_PIXELS_PER_BYTE), diff --git a/drivers/mipi_dbi/mipi_dbi_nxp_dcnano_lcdif.c b/drivers/mipi_dbi/mipi_dbi_nxp_dcnano_lcdif.c index 8870f1ef3e39d..9777ea1dbb30e 100644 --- a/drivers/mipi_dbi/mipi_dbi_nxp_dcnano_lcdif.c +++ b/drivers/mipi_dbi/mipi_dbi_nxp_dcnano_lcdif.c @@ -244,14 +244,8 @@ static int mipi_dbi_dcnano_lcdif_write_display(const struct device *dev, LCDIF_SetFrameBufferConfig(config->base, 0, &fbConfig); - if (bytes_per_pixel == 3U) { - /* For RGB888 the stride shall be calculated as - * 4 bytes per pixel instead of 3. - */ - LCDIF_SetFrameBufferStride(config->base, 0, 4U * desc->pitch); - } else { - LCDIF_SetFrameBufferStride(config->base, 0, bytes_per_pixel * desc->pitch); - } + /* pitch is now in bytes per row */ + LCDIF_SetFrameBufferStride(config->base, 0, desc->pitch); /* Set the updated area's size according to desc. */ LCDIF_SetFrameBufferPosition(config->base, 0U, 0U, 0U, desc->width, diff --git a/drivers/mipi_dsi/dsi_mcux_2l.c b/drivers/mipi_dsi/dsi_mcux_2l.c index c4615f32ec803..2436ec5a6d11d 100644 --- a/drivers/mipi_dsi/dsi_mcux_2l.c +++ b/drivers/mipi_dsi/dsi_mcux_2l.c @@ -244,7 +244,7 @@ static status_t dsi_mcux_dcnano_transfer(const struct device *dev, uint8_t chann struct display_buffer_descriptor local_desc = { .width = desc->width, .height = data->height, - .pitch = desc->pitch, + .pitch = desc->pitch / data->src_bytes_per_pixel, }; /* Every time buffer 64 pixels first before the transfer. */ @@ -647,7 +647,7 @@ static ssize_t dsi_mcux_transfer(const struct device *dev, uint8_t channel, */ if (desc != NULL) { #endif - if ((desc->pitch * data->src_bytes_per_pixel) > + if (desc->pitch > (msg->tx_len / desc->height)) { data->data_left_each_line = desc->width * data->src_bytes_per_pixel; msg->tx_len = data->data_left_each_line; diff --git a/include/zephyr/drivers/display.h b/include/zephyr/drivers/display.h index 39911d08baadf..69558ed439ad9 100644 --- a/include/zephyr/drivers/display.h +++ b/include/zephyr/drivers/display.h @@ -143,7 +143,38 @@ struct display_capabilities { enum display_orientation current_orientation; }; -/** @brief Structure to describe display data buffer layout */ +/** + * @brief Structure to describe display data buffer layout + * + * @verbatim + * Frame Buffer Memory Layout: + * + * <----------------- pitch (bytes per row) ------------------> + * <------ width * bytes_per_pixel ------> + * +---------------------------------------+--------------------+ + * | Pixel | Pixel | Pixel | ... | Pixel | Padding/Unused | ^ + * | (0,0) | (1,0) | (2,0) | |(w-1,0) | | | + * +---------------------------------------+--------------------+ | + * | Pixel | Pixel | Pixel | ... | Pixel | Padding/Unused | | + * | (0,1) | (1,1) | (2,1) | |(w-1,1) | | height + * +---------------------------------------+--------------------+ (rows) + * | Pixel | Pixel | Pixel | ... | Pixel | Padding/Unused | | + * | (0,2) | (1,2) | (2,2) | |(w-1,2) | | | + * +---------------------------------------+--------------------+ | + * | ... | ... | ... | ... | ... | ... | | + * +---------------------------------------+--------------------+ | + * | Pixel | Pixel | Pixel | ... | Pixel | Padding/Unused | | + * |(0,h-1)|(1,h-1)|(2,h-1)| |(w-1,h-1)| | v + * +---------------------------------------+---------------------+ + * + * width = Number of pixels per row (visible width) + * height = Number of rows (visible height) + * pitch = Number of bytes per row (including padding for alignment) + * + * Note: pitch >= width * bytes_per_pixel + * The difference is padding added for memory alignment requirements. + * @endverbatim + */ struct display_buffer_descriptor { /** Data buffer size in bytes */ uint32_t buf_size; @@ -151,7 +182,7 @@ struct display_buffer_descriptor { uint16_t width; /** Data buffer column height in pixels */ uint16_t height; - /** Number of pixels between consecutive rows in the data buffer */ + /** Number of bytes between consecutive rows in the data buffer */ uint16_t pitch; /** Indicates that this is not the last write buffer of the frame */ bool frame_incomplete; diff --git a/include/zephyr/drivers/mipi_dbi.h b/include/zephyr/drivers/mipi_dbi.h index b47c9b1749ae7..438b29bbc1510 100644 --- a/include/zephyr/drivers/mipi_dbi.h +++ b/include/zephyr/drivers/mipi_dbi.h @@ -258,7 +258,8 @@ static inline int mipi_dbi_command_read(const struct device *dev, * @param config MIPI DBI configuration * @param framebuf: framebuffer to write to display * @param desc: descriptor of framebuffer to write. Note that the pitch must - * be equal to width. "buf_size" field determines how many bytes will be + * be equal to width * bytes_per_pixel (pitch is now in bytes per row). + * "buf_size" field determines how many bytes will be * written. * @param pixfmt: pixel format of framebuffer data * @retval 0 buffer write succeeded. diff --git a/modules/lvgl/lvgl_display_mono.c b/modules/lvgl/lvgl_display_mono.c index 960a18f993677..bb1bef2ff9ab3 100644 --- a/modules/lvgl/lvgl_display_mono.c +++ b/modules/lvgl/lvgl_display_mono.c @@ -106,7 +106,7 @@ void lvgl_flush_cb_mono(lv_display_t *display, const lv_area_t *area, uint8_t *p struct display_buffer_descriptor desc = { .buf_size = (w * h) / 8U, .width = w, - .pitch = w, + .pitch = DIV_ROUND_UP(w, 8), .height = h, .frame_incomplete = !is_last, }; diff --git a/samples/boards/nordic/nrf_led_matrix/src/main.c b/samples/boards/nordic/nrf_led_matrix/src/main.c index c98937c8fd347..411a415928fdf 100644 --- a/samples/boards/nordic/nrf_led_matrix/src/main.c +++ b/samples/boards/nordic/nrf_led_matrix/src/main.c @@ -18,7 +18,7 @@ static const struct display_buffer_descriptor buf_desc = { .buf_size = sizeof(buf), .width = 5, .height = 5, - .pitch = 8, + .pitch = 1, }; static void update_block_3x3(const struct device *dev) diff --git a/samples/drivers/display/src/main.c b/samples/drivers/display/src/main.c index 273349e5897d4..9041e01534ae5 100644 --- a/samples/drivers/display/src/main.c +++ b/samples/drivers/display/src/main.c @@ -344,7 +344,29 @@ int main(void) (void)memset(buf, bg_color, buf_size); buf_desc.buf_size = buf_size; - buf_desc.pitch = ROUND_UP(capabilities.x_resolution, CONFIG_SAMPLE_PITCH_ALIGN); + switch (capabilities.current_pixel_format) { + case PIXEL_FORMAT_ARGB_8888: + buf_desc.pitch = capabilities.x_resolution * 4; + break; + case PIXEL_FORMAT_RGB_888: + buf_desc.pitch = capabilities.x_resolution * 3; + break; + case PIXEL_FORMAT_RGB_565: + case PIXEL_FORMAT_BGR_565: + case PIXEL_FORMAT_AL_88: + buf_desc.pitch = capabilities.x_resolution * 2; + break; + case PIXEL_FORMAT_L_8: + buf_desc.pitch = capabilities.x_resolution; + break; + case PIXEL_FORMAT_MONO01: + case PIXEL_FORMAT_MONO10: + buf_desc.pitch = DIV_ROUND_UP(capabilities.x_resolution, NUM_BITS(uint8_t)); + break; + default: + break; + } + buf_desc.pitch = ROUND_UP(buf_desc.pitch, CONFIG_SAMPLE_PITCH_ALIGN); buf_desc.width = capabilities.x_resolution; buf_desc.height = h_step; @@ -376,7 +398,29 @@ int main(void) } } - buf_desc.pitch = ROUND_UP(rect_w, CONFIG_SAMPLE_PITCH_ALIGN); + switch (capabilities.current_pixel_format) { + case PIXEL_FORMAT_ARGB_8888: + buf_desc.pitch = rect_w * 4; + break; + case PIXEL_FORMAT_RGB_888: + buf_desc.pitch = rect_w * 3; + break; + case PIXEL_FORMAT_RGB_565: + case PIXEL_FORMAT_BGR_565: + case PIXEL_FORMAT_AL_88: + buf_desc.pitch = rect_w * 2; + break; + case PIXEL_FORMAT_L_8: + buf_desc.pitch = rect_w; + break; + case PIXEL_FORMAT_MONO01: + case PIXEL_FORMAT_MONO10: + buf_desc.pitch = DIV_ROUND_UP(rect_w, NUM_BITS(uint8_t)); + break; + default: + break; + } + buf_desc.pitch = ROUND_UP(buf_desc.pitch, CONFIG_SAMPLE_PITCH_ALIGN); buf_desc.width = rect_w; buf_desc.height = rect_h; diff --git a/samples/drivers/video/capture/src/main.c b/samples/drivers/video/capture/src/main.c index f1b54aae1105d..2095c86c6d93b 100644 --- a/samples/drivers/video/capture/src/main.c +++ b/samples/drivers/video/capture/src/main.c @@ -78,7 +78,7 @@ static int app_display_frame(const struct device *const display_dev, struct display_buffer_descriptor buf_desc = { .buf_size = vbuf->bytesused, .width = fmt->width, - .pitch = buf_desc.width, + .pitch = fmt->pitch, .height = vbuf->bytesused / fmt->pitch, }; diff --git a/samples/subsys/input/draw_touch_events/src/main.c b/samples/subsys/input/draw_touch_events/src/main.c index a39b7a3ab588a..7607f26e65f6c 100644 --- a/samples/subsys/input/draw_touch_events/src/main.c +++ b/samples/subsys/input/draw_touch_events/src/main.c @@ -77,6 +77,7 @@ static int clear_screen(void) ddesc.width = MIN(buf_desc.width, rem_w); ddesc.height = MIN(buf_desc.height, rem_h); + ddesc.pitch = ddesc.width * BPP; ddesc.buf_size = ddesc.width * ddesc.height * BPP; ret = display_write(display_dev, x, y, &ddesc, buffer_cross_empty); @@ -143,6 +144,7 @@ int main(void) return 0; } fill_cross_buffer(); + buf_desc.pitch = CROSS_DIM * BPP; ret = display_blanking_off(display_dev); if (ret < 0 && ret != -ENOSYS) { LOG_ERR("Failed to turn blanking off (error %d)", ret); diff --git a/subsys/fb/cfb.c b/subsys/fb/cfb.c index 8aec3ab763afd..59d4ab57d4fc7 100644 --- a/subsys/fb/cfb.c +++ b/subsys/fb/cfb.c @@ -576,7 +576,7 @@ int cfb_framebuffer_finalize(const struct device *dev) .buf_size = fb->size, .width = fb->x_res, .height = fb->y_res, - .pitch = fb->x_res, + .pitch = fb->x_res / 8, }; if ((fb->pixel_format == PIXEL_FORMAT_MONO10) == fb->inverted) { diff --git a/tests/drivers/display/display_check/src/main.c b/tests/drivers/display/display_check/src/main.c index 33a3ec9dd156a..307137837d4e2 100644 --- a/tests/drivers/display/display_check/src/main.c +++ b/tests/drivers/display/display_check/src/main.c @@ -336,7 +336,7 @@ int test_display(void) (void)memset(buf, bg_color, buf_size); buf_desc.buf_size = buf_size; - buf_desc.pitch = capabilities.x_resolution; + buf_desc.pitch = DIV_ROUND_UP(capabilities.x_resolution * DISPLAY_BITS_PER_PIXEL(capabilities.current_pixel_format), NUM_BITS(uint8_t)); buf_desc.width = capabilities.x_resolution; buf_desc.height = h_step; @@ -360,7 +360,7 @@ int test_display(void) display_write(display_dev, 0, idx, &buf_desc, buf); } - buf_desc.pitch = rect_w; + buf_desc.pitch = DIV_ROUND_UP(rect_w * DISPLAY_BITS_PER_PIXEL(capabilities.current_pixel_format), NUM_BITS(uint8_t)); buf_desc.width = rect_w; buf_desc.height = rect_h; diff --git a/tests/drivers/display/display_read_write/src/main.c b/tests/drivers/display/display_read_write/src/main.c index 16e1ba1688ac4..3df481bb33534 100644 --- a/tests/drivers/display/display_read_write/src/main.c +++ b/tests/drivers/display/display_read_write/src/main.c @@ -50,7 +50,7 @@ static void verify_bytes_of_area(uint8_t *data, int cmp_x, int cmp_y, size_t wid { struct display_buffer_descriptor desc = { .height = height, - .pitch = width, + .pitch = width * bpp, .width = width, .buf_size = height * width * bpp, }; @@ -71,7 +71,7 @@ static void verify_background_color(int x, int y, size_t width, size_t height, u size_t buf_size = height * width * bpp / ((is_vtiled || is_htiled) ? 8 : 1); struct display_buffer_descriptor desc = { .height = height, - .pitch = width, + .pitch = width * bpp, .width = width, .buf_size = buf_size, }; @@ -125,7 +125,7 @@ static void display_before(void *text_fixture) struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width * bpp, .width = display_width, .buf_size = display_height * display_width * bpp, }; @@ -155,7 +155,7 @@ ZTEST(display_read_write, test_write_to_buffer_head) uint16_t buf_size = width * bpp; struct display_buffer_descriptor desc = { .height = height, - .pitch = width, + .pitch = width * bpp, .width = width, .buf_size = buf_size, }; @@ -183,13 +183,13 @@ ZTEST(display_read_write, test_write_to_buffer_tail) uint16_t buf_size = width * bpp; struct display_buffer_descriptor desc = { .height = height, - .pitch = width, + .pitch = width * bpp, .width = width, .buf_size = buf_size, }; struct display_buffer_descriptor desc_whole = { .height = display_height, - .pitch = display_width, + .pitch = display_width * bpp, .width = display_width, .buf_size = display_height * display_width * bpp / height, }; @@ -229,13 +229,13 @@ ZTEST(display_read_write, test_read_does_not_clear_existing_buffer) uint16_t buf_size = width * bpp; struct display_buffer_descriptor desc = { .height = height, - .pitch = width, + .pitch = width * bpp, .width = width, .buf_size = buf_size, }; struct display_buffer_descriptor desc_whole = { .height = display_height, - .pitch = display_width, + .pitch = display_width * bpp, .width = display_width, .buf_size = display_height * display_width * bpp / height, }; diff --git a/tests/subsys/display/cfb/basic/src/clear.c b/tests/subsys/display/cfb/basic/src/clear.c index b0359564de800..2a996c59a0b02 100644 --- a/tests/subsys/display/cfb/basic/src/clear.c +++ b/tests/subsys/display/cfb/basic/src/clear.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/draw_circle.c b/tests/subsys/display/cfb/basic/src/draw_circle.c index e42199eb0618e..02569138bcb97 100644 --- a/tests/subsys/display/cfb/basic/src/draw_circle.c +++ b/tests/subsys/display/cfb/basic/src/draw_circle.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/draw_line.c b/tests/subsys/display/cfb/basic/src/draw_line.c index 1b2c3d5118abf..f0b78d7a60b6b 100644 --- a/tests/subsys/display/cfb/basic/src/draw_line.c +++ b/tests/subsys/display/cfb/basic/src/draw_line.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/draw_point.c b/tests/subsys/display/cfb/basic/src/draw_point.c index ef78f212dc6d5..5907e17b5fa69 100644 --- a/tests/subsys/display/cfb/basic/src/draw_point.c +++ b/tests/subsys/display/cfb/basic/src/draw_point.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/draw_rect.c b/tests/subsys/display/cfb/basic/src/draw_rect.c index 2c6b81d5d8b4f..578fa0e2cd1c9 100644 --- a/tests/subsys/display/cfb/basic/src/draw_rect.c +++ b/tests/subsys/display/cfb/basic/src/draw_rect.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/draw_text_rectspace1016.c b/tests/subsys/display/cfb/basic/src/draw_text_rectspace1016.c index faee4885601ac..79a8a74ab96a5 100644 --- a/tests/subsys/display/cfb/basic/src/draw_text_rectspace1016.c +++ b/tests/subsys/display/cfb/basic/src/draw_text_rectspace1016.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/invert.c b/tests/subsys/display/cfb/basic/src/invert.c index fb13c6bc9e621..1242b82724dc6 100644 --- a/tests/subsys/display/cfb/basic/src/invert.c +++ b/tests/subsys/display/cfb/basic/src/invert.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/invert_area.c b/tests/subsys/display/cfb/basic/src/invert_area.c index 98b86559ff161..7f54524da210f 100644 --- a/tests/subsys/display/cfb/basic/src/invert_area.c +++ b/tests/subsys/display/cfb/basic/src/invert_area.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/print_rectspace1016.c b/tests/subsys/display/cfb/basic/src/print_rectspace1016.c index f1cf9dddfe4ab..4414e31c256c0 100644 --- a/tests/subsys/display/cfb/basic/src/print_rectspace1016.c +++ b/tests/subsys/display/cfb/basic/src/print_rectspace1016.c @@ -26,7 +26,7 @@ static void cfb_test_before(void *text_fixture) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; diff --git a/tests/subsys/display/cfb/basic/src/utils.c b/tests/subsys/display/cfb/basic/src/utils.c index 454e605aa4cb8..5b7b5bf91f143 100644 --- a/tests/subsys/display/cfb/basic/src/utils.c +++ b/tests/subsys/display/cfb/basic/src/utils.c @@ -53,7 +53,7 @@ bool verify_pixel(int x, int y, uint32_t color) { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; @@ -67,7 +67,7 @@ bool verify_image(int cmp_x, int cmp_y, const uint32_t *img, size_t width, size_ { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, }; @@ -98,7 +98,7 @@ bool verify_color_inside_rect(int x, int y, size_t width, size_t height, uint32_ { struct display_buffer_descriptor desc = { .height = display_height, - .pitch = display_width, + .pitch = display_width / 8, .width = display_width, .buf_size = display_height * display_width / 8, };