d1925651452c429f71f7bb83fa9d450d2539e03b
[openwrt/staging/ldir.git] /
1 From 602ec343e69479dbec368f67d09c9f3e3e5ac248 Mon Sep 17 00:00:00 2001
2 From: Dom Cobley <popcornmix@gmail.com>
3 Date: Thu, 7 May 2020 18:16:07 +0100
4 Subject: [PATCH] vc4_hdmi: Fix register offset when sending longer CEC
5 messages
6
7 Signed-off-by: Dom Cobley <popcornmix@gmail.com>
8 ---
9 drivers/gpu/drm/vc4/vc4_hdmi.c | 13 +++++++++++--
10 1 file changed, 11 insertions(+), 2 deletions(-)
11
12 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
13 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
14 @@ -1265,8 +1265,13 @@ static void vc4_cec_read_msg(struct vc4_
15
16 msg->len = 1 + ((cntrl1 & VC4_HDMI_CEC_REC_WRD_CNT_MASK) >>
17 VC4_HDMI_CEC_REC_WRD_CNT_SHIFT);
18 +
19 + if (msg->len > 16) {
20 + DRM_ERROR("Attempting to read too much data (%d)\n", msg->len);
21 + return;
22 + }
23 for (i = 0; i < msg->len; i += 4) {
24 - u32 val = HDMI_READ(HDMI_CEC_RX_DATA_1 + i);
25 + u32 val = HDMI_READ(HDMI_CEC_RX_DATA_1 + (i>>2));
26
27 msg->msg[i] = val & 0xff;
28 msg->msg[i + 1] = (val >> 8) & 0xff;
29 @@ -1362,8 +1367,12 @@ static int vc4_hdmi_cec_adap_transmit(st
30 u32 val;
31 unsigned int i;
32
33 + if (msg->len > 16) {
34 + DRM_ERROR("Attempting to transmit too much data (%d)\n", msg->len);
35 + return -ENOMEM;
36 + }
37 for (i = 0; i < msg->len; i += 4)
38 - HDMI_WRITE(HDMI_CEC_TX_DATA_1 + i,
39 + HDMI_WRITE(HDMI_CEC_TX_DATA_1 + (i>>2),
40 (msg->msg[i]) |
41 (msg->msg[i + 1] << 8) |
42 (msg->msg[i + 2] << 16) |