Skip to content

Commit d571b31

Browse files
andysancarlescufi
authored andcommitted
drivers: uc81xx: Add support for overriding LUTs
Add support for overriding display LUTs in the UC81xx driver. This makes it possible to use different LUTs for the full and partial refresh profiles. Signed-off-by: Andreas Sandberg <[email protected]>
1 parent 21208aa commit d571b31

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

drivers/display/uc81xx.c

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ struct uc81xx_profile {
4646
bool override_cdi;
4747
uint8_t tcon;
4848
bool override_tcon;
49+
50+
const struct uc81xx_dt_array lutc;
51+
const struct uc81xx_dt_array lutww;
52+
const struct uc81xx_dt_array lutkw;
53+
const struct uc81xx_dt_array lutwk;
54+
const struct uc81xx_dt_array lutkk;
55+
const struct uc81xx_dt_array lutbd;
4956
};
5057

5158
struct uc81xx_quirks {
@@ -205,7 +212,7 @@ static int uc81xx_set_profile(const struct device *dev,
205212
const struct uc81xx_config *config = dev->config;
206213
const struct uc81xx_profile *p;
207214
struct uc81xx_data *data = dev->data;
208-
const uint8_t psr =
215+
uint8_t psr =
209216
UC81XX_PSR_KW_R |
210217
UC81XX_PSR_UD |
211218
UC81XX_PSR_SHL |
@@ -240,6 +247,16 @@ static int uc81xx_set_profile(const struct device *dev,
240247
&config->softstart)) {
241248
return -EIO;
242249
}
250+
251+
/*
252+
* Enable LUT overrides if a LUT has been provided by
253+
* the user.
254+
*/
255+
if (p->lutc.len || p->lutww.len || p->lutkw.len ||
256+
p->lutwk.len || p->lutbd.len) {
257+
LOG_DBG("Using LUT from registers");
258+
psr |= UC81XX_PSR_REG;
259+
}
243260
}
244261

245262
/* Panel settings, KW mode and soft reset */
@@ -268,6 +285,30 @@ static int uc81xx_set_profile(const struct device *dev,
268285
return 0;
269286
}
270287

288+
if (uc81xx_write_array_opt(dev, UC81XX_CMD_LUTC, &p->lutc)) {
289+
return -EIO;
290+
}
291+
292+
if (uc81xx_write_array_opt(dev, UC81XX_CMD_LUTWW, &p->lutww)) {
293+
return -EIO;
294+
}
295+
296+
if (uc81xx_write_array_opt(dev, UC81XX_CMD_LUTKW, &p->lutkw)) {
297+
return -EIO;
298+
}
299+
300+
if (uc81xx_write_array_opt(dev, UC81XX_CMD_LUTWK, &p->lutwk)) {
301+
return -EIO;
302+
}
303+
304+
if (uc81xx_write_array_opt(dev, UC81XX_CMD_LUTKK, &p->lutkk)) {
305+
return -EIO;
306+
}
307+
308+
if (uc81xx_write_array_opt(dev, UC81XX_CMD_LUTBD, &p->lutbd)) {
309+
return -EIO;
310+
}
311+
271312
if (p->override_tcon) {
272313
if (uc81xx_write_cmd_uint8(dev, UC81XX_CMD_TCON, p->tcon)) {
273314
return -EIO;
@@ -660,13 +701,26 @@ static struct display_driver_api uc81xx_driver_api = {
660701

661702
#define UC81XX_PROFILE(n) \
662703
UC81XX_MAKE_ARRAY_OPT(n, pwr); \
704+
UC81XX_MAKE_ARRAY_OPT(n, lutc); \
705+
UC81XX_MAKE_ARRAY_OPT(n, lutww); \
706+
UC81XX_MAKE_ARRAY_OPT(n, lutkw); \
707+
UC81XX_MAKE_ARRAY_OPT(n, lutwk); \
708+
UC81XX_MAKE_ARRAY_OPT(n, lutkk); \
709+
UC81XX_MAKE_ARRAY_OPT(n, lutbd); \
663710
\
664711
static const struct uc81xx_profile uc81xx_profile_ ## n = { \
665712
.pwr = UC81XX_ASSIGN_ARRAY(n, pwr), \
666713
.cdi = DT_PROP_OR(n, cdi, 0), \
667714
.override_cdi = DT_NODE_HAS_PROP(n, cdi), \
668715
.tcon = DT_PROP_OR(n, tcon, 0), \
669716
.override_tcon = DT_NODE_HAS_PROP(n, tcon), \
717+
\
718+
.lutc = UC81XX_ASSIGN_ARRAY(n, lutc), \
719+
.lutww = UC81XX_ASSIGN_ARRAY(n, lutww), \
720+
.lutkw = UC81XX_ASSIGN_ARRAY(n, lutkw), \
721+
.lutwk = UC81XX_ASSIGN_ARRAY(n, lutwk), \
722+
.lutkk = UC81XX_ASSIGN_ARRAY(n, lutkk), \
723+
.lutbd = UC81XX_ASSIGN_ARRAY(n, lutbd), \
670724
};
671725

672726
#define _UC81XX_PROFILE_PTR(n) &uc81xx_profile_ ## n

drivers/display/uc81xx_regs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
#define UC81XX_CMD_LUTOPT 0x2A
2828
#define UC81XX_CMD_KWOPT 0x2B
2929

30+
#define UC81XX_CMD_LUTC 0x20
31+
#define UC81XX_CMD_LUTWW 0x21
32+
#define UC81XX_CMD_LUTKW 0x22
33+
#define UC81XX_CMD_LUTWK 0x23
34+
#define UC81XX_CMD_LUTKK 0x24
35+
#define UC81XX_CMD_LUTBD 0x25
36+
3037
/* UC8176/UC8179 */
3138
#define UC81XX_CMD_PLL 0x30
3239
#define UC81XX_CMD_TSC 0x40

dts/bindings/display/ultrachip,uc81xx-common.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,33 @@ child-binding:
7777
type: int
7878
required: false
7979
description: TCON setting value
80+
81+
lutc:
82+
type: uint8-array
83+
required: false
84+
description: VCOM LUT
85+
86+
lutww:
87+
type: uint8-array
88+
required: false
89+
description: White-to-white LUT
90+
91+
lutkw:
92+
type: uint8-array
93+
required: false
94+
description: Black-to-white LUT
95+
96+
lutwk:
97+
type: uint8-array
98+
required: false
99+
description: White-to-black LUT
100+
101+
lutkk:
102+
type: uint8-array
103+
required: false
104+
description: White-to-black LUT
105+
106+
lutbd:
107+
type: uint8-array
108+
required: false
109+
description: Border LUT

0 commit comments

Comments
 (0)