Skip to content

Commit 9509ed7

Browse files
committed
drivers: display: elcdif: Decouple PxP from the display controller
PxP is a distinct HW IP for image processing which is independent of the display controller. Decouple it from the elcdif driver. Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
1 parent ad4c3e3 commit 9509ed7

File tree

4 files changed

+1
-114
lines changed

4 files changed

+1
-114
lines changed

drivers/display/display_mcux_elcdif.c

Lines changed: 1 addition & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
#include <fsl_cache.h>
1818
#endif
1919

20-
#ifdef CONFIG_MCUX_ELCDIF_PXP
21-
#include <zephyr/drivers/dma.h>
22-
#include <zephyr/drivers/dma/dma_mcux_pxp.h>
23-
#endif
24-
2520
#include <zephyr/logging/log.h>
2621
#include <zephyr/irq.h>
2722

@@ -39,7 +34,6 @@ struct mcux_elcdif_config {
3934
elcdif_rgb_mode_config_t rgb_mode;
4035
const struct pinctrl_dev_config *pincfg;
4136
const struct gpio_dt_spec backlight_gpio;
42-
const struct device *pxp;
4337
};
4438

4539
struct mcux_elcdif_data {
@@ -54,22 +48,8 @@ struct mcux_elcdif_data {
5448
struct k_sem sem;
5549
/* Tracks index of next active driver framebuffer */
5650
uint8_t next_idx;
57-
#ifdef CONFIG_MCUX_ELCDIF_PXP
58-
/* Given to when PXP completes operation */
59-
struct k_sem pxp_done;
60-
#endif
6151
};
6252

63-
#ifdef CONFIG_MCUX_ELCDIF_PXP
64-
static void mcux_elcdif_pxp_callback(const struct device *dma_dev, void *user_data,
65-
uint32_t channel, int ret)
66-
{
67-
struct mcux_elcdif_data *data = user_data;
68-
69-
k_sem_give(&data->pxp_done);
70-
}
71-
#endif /* CONFIG_MCUX_ELCDIF_PXP */
72-
7353
static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const uint16_t y,
7454
const struct display_buffer_descriptor *desc, const void *buf)
7555
{
@@ -92,15 +72,6 @@ static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const u
9272
LOG_DBG("Setting FB from %p->%p", (void *)dev_data->active_fb, (void *)buf);
9373
dev_data->active_fb = buf;
9474
full_fb = true;
95-
} else if ((x == 0) && (y == 0) && (desc->width == config->rgb_mode.panelHeight) &&
96-
(desc->height == config->rgb_mode.panelWidth) && (desc->pitch == desc->width) &&
97-
IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP)) {
98-
/* With the PXP, we can rotate this display buffer to align
99-
* with output dimensions
100-
*/
101-
LOG_DBG("Setting FB from %p->%p", (void *)dev_data->active_fb, (void *)buf);
102-
dev_data->active_fb = buf;
103-
full_fb = true;
10475
} else {
10576
/* We must use partial framebuffer copy */
10677
if (CONFIG_MCUX_ELCDIF_FB_NUM == 0) {
@@ -137,77 +108,6 @@ static int mcux_elcdif_write(const struct device *dev, const uint16_t x, const u
137108
DCACHE_CleanByRange((uint32_t)dev_data->active_fb, dev_data->fb_bytes);
138109
#endif
139110

140-
#ifdef CONFIG_MCUX_ELCDIF_PXP
141-
if (full_fb) {
142-
/* Configure PXP using DMA API, and rotate/flip frame */
143-
struct dma_config pxp_dma = {0};
144-
struct dma_block_config pxp_block = {0};
145-
146-
/* Source buffer is input to display_write, we will
147-
* place modified output into a driver framebuffer.
148-
*/
149-
dev_data->active_fb = dev_data->fb[dev_data->next_idx];
150-
pxp_block.source_address = (uint32_t)buf;
151-
pxp_block.dest_address = (uint32_t)dev_data->active_fb;
152-
pxp_block.block_size = desc->buf_size;
153-
154-
/* DMA slot sets pixel format and rotation angle */
155-
if (dev_data->pixel_format == PIXEL_FORMAT_BGR_565) {
156-
pxp_dma.dma_slot = DMA_MCUX_PXP_FMT(DMA_MCUX_PXP_FMT_RGB565);
157-
} else if (dev_data->pixel_format == PIXEL_FORMAT_RGB_888) {
158-
pxp_dma.dma_slot = DMA_MCUX_PXP_FMT(DMA_MCUX_PXP_FMT_RGB888);
159-
} else if (dev_data->pixel_format == PIXEL_FORMAT_ARGB_8888) {
160-
pxp_dma.dma_slot = DMA_MCUX_PXP_FMT(DMA_MCUX_PXP_FMT_ARGB8888);
161-
} else {
162-
/* Cannot rotate */
163-
return -ENOTSUP;
164-
}
165-
if (IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP_ROTATE_90)) {
166-
pxp_dma.dma_slot |= DMA_MCUX_PXP_CMD(DMA_MCUX_PXP_CMD_ROTATE_90);
167-
} else if (IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP_ROTATE_180)) {
168-
pxp_dma.dma_slot |= DMA_MCUX_PXP_CMD(DMA_MCUX_PXP_CMD_ROTATE_180);
169-
} else if (IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP_ROTATE_270)) {
170-
pxp_dma.dma_slot |= DMA_MCUX_PXP_CMD(DMA_MCUX_PXP_CMD_ROTATE_270);
171-
} else {
172-
pxp_dma.dma_slot |= DMA_MCUX_PXP_CMD(DMA_MCUX_PXP_CMD_ROTATE_0);
173-
}
174-
175-
/* DMA linked_channel sets the flip direction */
176-
if (IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP_FLIP_HORIZONTAL)) {
177-
pxp_dma.linked_channel |= DMA_MCUX_PXP_FLIP(DMA_MCUX_PXP_FLIP_HORIZONTAL);
178-
} else if (IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP_FLIP_VERTICAL)) {
179-
pxp_dma.linked_channel |= DMA_MCUX_PXP_FLIP(DMA_MCUX_PXP_FLIP_VERTICAL);
180-
} else if (IS_ENABLED(CONFIG_MCUX_ELCDIF_PXP_FLIP_BOTH)) {
181-
pxp_dma.linked_channel |= DMA_MCUX_PXP_FLIP(DMA_MCUX_PXP_FLIP_BOTH);
182-
} else {
183-
pxp_dma.linked_channel |= DMA_MCUX_PXP_FLIP(DMA_MCUX_PXP_FLIP_DISABLE);
184-
}
185-
186-
pxp_dma.channel_direction = MEMORY_TO_MEMORY;
187-
pxp_dma.source_data_size = desc->width * dev_data->pixel_bytes;
188-
pxp_dma.dest_data_size = config->rgb_mode.panelWidth * dev_data->pixel_bytes;
189-
/* Burst lengths are heights of source/dest buffer in pixels */
190-
pxp_dma.source_burst_length = desc->height;
191-
pxp_dma.dest_burst_length = config->rgb_mode.panelHeight;
192-
pxp_dma.head_block = &pxp_block;
193-
pxp_dma.dma_callback = mcux_elcdif_pxp_callback;
194-
pxp_dma.user_data = dev_data;
195-
196-
ret = dma_config(config->pxp, 0, &pxp_dma);
197-
if (ret < 0) {
198-
return ret;
199-
}
200-
ret = dma_start(config->pxp, 0);
201-
if (ret < 0) {
202-
return ret;
203-
}
204-
k_sem_take(&dev_data->pxp_done, K_FOREVER);
205-
} else {
206-
LOG_WRN("PXP rotation/flip will not work correctly unless a full sized "
207-
"framebuffer is provided");
208-
}
209-
#endif /* CONFIG_MCUX_ELCDIF_PXP */
210-
211111
/* Queue next framebuffer */
212112
ELCDIF_SetNextBufferAddr(config->base, (uint32_t)dev_data->active_fb);
213113

@@ -348,13 +248,6 @@ static int mcux_elcdif_init(const struct device *dev)
348248
#endif /* DT_ANY_INST_HAS_PROP_STATUS_OKAY(backlight_gpios) */
349249

350250
k_sem_init(&dev_data->sem, 0, 1);
351-
#ifdef CONFIG_MCUX_ELCDIF_PXP
352-
k_sem_init(&dev_data->pxp_done, 0, 1);
353-
if (!device_is_ready(config->pxp)) {
354-
LOG_ERR("PXP device is not ready");
355-
return -ENODEV;
356-
}
357-
#endif
358251

359252
config->irq_config_func(dev);
360253

@@ -413,8 +306,7 @@ static DEVICE_API(display, mcux_elcdif_api) = {
413306
}, \
414307
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(id), \
415308
.backlight_gpio = GPIO_DT_SPEC_INST_GET_OR(id, backlight_gpios, {0}), \
416-
IF_ENABLED(CONFIG_MCUX_ELCDIF_PXP, \
417-
(.pxp = DEVICE_DT_GET(DT_INST_PHANDLE(id, nxp_pxp)),))}; \
309+
}; \
418310
static struct mcux_elcdif_data mcux_elcdif_data_##id = { \
419311
.next_idx = 0, \
420312
.pixel_format = DT_INST_PROP(id, pixel_format), \

dts/arm/nxp/nxp_rt10xx.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@
452452
reg = <0x402b8000 0x4000>;
453453
interrupts = <42 0>;
454454
status = "disabled";
455-
nxp,pxp = <&pxp>;
456455
};
457456

458457
lpspi1: spi@40394000 {

dts/arm/nxp/nxp_rt11xx.dtsi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@
371371
reg = <0x40804000 0x4000>;
372372
interrupts = <54 0>;
373373
status = "disabled";
374-
nxp,pxp = <&pxp>;
375374
};
376375

377376
mipi_dsi: mipi-dsi@4080c000 {
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=3686800
2-
CONFIG_DMA=y
3-
CONFIG_MCUX_ELCDIF_PXP=y
4-
CONFIG_MCUX_ELCDIF_PXP_ROTATE_90=y

0 commit comments

Comments
 (0)