summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/panel
diff options
context:
space:
mode:
authorAndrzej Hajda <a.hajda@samsung.com>2016-08-18 17:05:32 +0200
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:52:34 +0900
commit77814b73851c090f54af32645a39184cee893932 (patch)
treefb00562279124a0322ae3a70a159130cf67160ea /drivers/gpu/drm/panel
parentec04f5a13929bf224257eb519d88f8f5b29adc73 (diff)
drm/panel/s6e3ha2: switch to mipi_dsi_dcs_write_buffer helper
mipi_dsi_dcs_write_buffer is more suitable helper than mipi_dsi_dcs_write. It does not replicate buffers and is less prone to off-by-one errors. Change-Id: I9924bfd1ef18130fd36b6120cec0cd6c9dcfc276 Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Diffstat (limited to 'drivers/gpu/drm/panel')
-rw-r--r--drivers/gpu/drm/panel/panel-s6e3ha2.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/drivers/gpu/drm/panel/panel-s6e3ha2.c b/drivers/gpu/drm/panel/panel-s6e3ha2.c
index 58ad4885e9bf..0ee77ae4057d 100644
--- a/drivers/gpu/drm/panel/panel-s6e3ha2.c
+++ b/drivers/gpu/drm/panel/panel-s6e3ha2.c
@@ -312,8 +312,7 @@ static int s6e3ha2_clear_error(struct s6e3ha2 *ctx)
return ret;
}
-static void s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const u8 cmd,
- const void *data, size_t len)
+static void s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const void *data, size_t len)
{
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
ssize_t ret;
@@ -321,7 +320,7 @@ static void s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const u8 cmd,
if (ctx->error < 0)
return;
- ret = mipi_dsi_dcs_write(dsi, cmd, data, len);
+ ret = mipi_dsi_dcs_write_buffer(dsi, data, len);
if (ret < 0) {
dev_err(ctx->dev, "error %zd writing dcs seq: %*ph\n", ret,
(int)len, data);
@@ -329,11 +328,16 @@ static void s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const u8 cmd,
}
}
-#define s6e3ha2_dcs_write_seq_static(ctx, cmd, seq...) \
+#define s6e3ha2_dcs_write_seq(ctx, seq...) \
+({\
+ const u8 d[] = { seq };\
+ s6e3ha2_dcs_write(ctx, d, ARRAY_SIZE(d));\
+})
+
+#define s6e3ha2_dcs_write_seq_static(ctx, seq...) \
({\
- static const u8 c = cmd;\
static const u8 d[] = { seq };\
- s6e3ha2_dcs_write(ctx, c, d, ARRAY_SIZE(d));\
+ s6e3ha2_dcs_write(ctx, d, ARRAY_SIZE(d));\
})
#define NSEQ(seq...) sizeof((char[]){ seq }), seq
@@ -343,7 +347,7 @@ static void s6e3ha2__write_nseq(struct s6e3ha2 *ctx, const u8 *nseq)
int count;
while ((count = *nseq++)) {
- s6e3ha2_dcs_write(ctx, *nseq, nseq + 1, count - 1);
+ s6e3ha2_dcs_write(ctx, nseq, count);
nseq += count;
}
}
@@ -525,13 +529,12 @@ static int s6e3ha2_get_brightness(struct backlight_device *bl_dev)
return bl_dev->props.brightness;
}
-static void s6e3ha2_set_vint(struct s6e3ha2 *ctx) {
- struct backlight_device *bl_dev = ctx->bl_dev;
- unsigned int brightness = bl_dev->props.brightness;
- unsigned char data[] = { 0x8b,
- VINT_TABLE[brightness * (VINT_STATUS_MAX - 1) / MAX_BRIGHTNESS] };
+static void s6e3ha2_set_vint(struct s6e3ha2 *ctx)
+{
+ int vind = (VINT_STATUS_MAX - 1)
+ * ctx->bl_dev->props.brightness / MAX_BRIGHTNESS;
- s6e3ha2_dcs_write(ctx, 0xf4, data, 2);
+ s6e3ha2_dcs_write_seq(ctx, 0xf4, 0x8b, VINT_TABLE[vind]);
}
static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness)
@@ -542,8 +545,11 @@ static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness)
static void s6e3ha2_update_gamma(struct s6e3ha2 *ctx, unsigned int brightness)
{
unsigned int index = s6e3ha2_get_brightness_index(brightness);
+ char data[GAMMA_CMD_CNT + 1];
- s6e3ha2_dcs_write(ctx, 0xca, gamma_tbl[index], GAMMA_CMD_CNT);
+ data[0] = 0xca;
+ memcpy(data + 1, gamma_tbl[index], GAMMA_CMD_CNT);
+ s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data));
s6e3ha2_gamma_update(ctx);
if (!ctx->error)