Skip to content

Commit 2646e49

Browse files
committed
drivers: uc81xx: Add workaround for chips without autocopy
The UC8176 doesn't automatically copy writes to the buffer containing the old SRAM contents. In this case, we need to manually copy data to the back buffer. Signed-off-by: Andreas Sandberg <[email protected]>
1 parent f5e2374 commit 2646e49

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/display/uc81xx.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ struct uc81xx_quirks {
6363
uint16_t max_width;
6464
uint16_t max_height;
6565

66+
bool auto_copy;
67+
6668
int (*set_cdi)(const struct device *dev, bool border);
6769
};
6870

@@ -409,6 +411,8 @@ static int uc81xx_write(const struct device *dev, const uint16_t x, const uint16
409411
.flags = UC81XX_PTL_FLAG_PT_SCAN,
410412
};
411413
size_t buf_len;
414+
const uint8_t back_buffer = data->blanking_on ?
415+
UC81XX_CMD_DTM1 : UC81XX_CMD_DTM2;
412416

413417
LOG_DBG("x %u, y %u, height %u, width %u, pitch %u",
414418
x, y, desc->height, desc->width, desc->pitch);
@@ -477,6 +481,23 @@ static int uc81xx_write(const struct device *dev, const uint16_t x, const uint16
477481
}
478482
}
479483

484+
if (!config->quirks->auto_copy) {
485+
/* Some controllers don't copy the new data to the old
486+
* data buffer on refresh. Do that manually here if
487+
* needed.
488+
*/
489+
490+
if (uc81xx_write_cmd(dev, UC81XX_CMD_PTL,
491+
(const void *)&ptl, sizeof(ptl))) {
492+
return -EIO;
493+
}
494+
495+
if (uc81xx_write_cmd(dev, back_buffer,
496+
(uint8_t *)buf, buf_len)) {
497+
return -EIO;
498+
}
499+
}
500+
480501
if (uc81xx_write_cmd(dev, UC81XX_CMD_PTOUT, NULL, 0)) {
481502
return -EIO;
482503
}
@@ -659,6 +680,8 @@ static const struct uc81xx_quirks uc8176_quirks = {
659680
.max_width = 400,
660681
.max_height = 300,
661682

683+
.auto_copy = false,
684+
662685
.set_cdi = uc8176_set_cdi,
663686
};
664687
#endif
@@ -688,6 +711,8 @@ static const struct uc81xx_quirks uc8179_quirks = {
688711
.max_width = 800,
689712
.max_height = 600,
690713

714+
.auto_copy = true,
715+
691716
.set_cdi = uc8179_set_cdi,
692717
};
693718
#endif

0 commit comments

Comments
 (0)