]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.146/drm-ast-fixed-reading-monitor-edid-not-stable-issue.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.146 / drm-ast-fixed-reading-monitor-edid-not-stable-issue.patch
1 From 924770877b5ec2917e3e3bcce1d3a8a1c20238b3 Mon Sep 17 00:00:00 2001
2 From: "Y.C. Chen" <yc_chen@aspeedtech.com>
3 Date: Thu, 22 Nov 2018 11:56:28 +0800
4 Subject: drm/ast: fixed reading monitor EDID not stable issue
5
6 [ Upstream commit 300625620314194d9e6d4f6dda71f2dc9cf62d9f ]
7
8 v1: over-sample data to increase the stability with some specific monitors
9 v2: refine to avoid infinite loop
10 v3: remove un-necessary "volatile" declaration
11
12 [airlied: fix two checkpatch warnings]
13
14 Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
15 Signed-off-by: Dave Airlie <airlied@redhat.com>
16 Link: https://patchwork.freedesktop.org/patch/msgid/1542858988-1127-1-git-send-email-yc_chen@aspeedtech.com
17 Signed-off-by: Sasha Levin <sashal@kernel.org>
18 ---
19 drivers/gpu/drm/ast/ast_mode.c | 36 ++++++++++++++++++++++++++++------
20 1 file changed, 30 insertions(+), 6 deletions(-)
21
22 diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
23 index 57205016b04a..201874b96dd6 100644
24 --- a/drivers/gpu/drm/ast/ast_mode.c
25 +++ b/drivers/gpu/drm/ast/ast_mode.c
26 @@ -954,9 +954,21 @@ static int get_clock(void *i2c_priv)
27 {
28 struct ast_i2c_chan *i2c = i2c_priv;
29 struct ast_private *ast = i2c->dev->dev_private;
30 - uint32_t val;
31 + uint32_t val, val2, count, pass;
32 +
33 + count = 0;
34 + pass = 0;
35 + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
36 + do {
37 + val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
38 + if (val == val2) {
39 + pass++;
40 + } else {
41 + pass = 0;
42 + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
43 + }
44 + } while ((pass < 5) && (count++ < 0x10000));
45
46 - val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
47 return val & 1 ? 1 : 0;
48 }
49
50 @@ -964,9 +976,21 @@ static int get_data(void *i2c_priv)
51 {
52 struct ast_i2c_chan *i2c = i2c_priv;
53 struct ast_private *ast = i2c->dev->dev_private;
54 - uint32_t val;
55 + uint32_t val, val2, count, pass;
56 +
57 + count = 0;
58 + pass = 0;
59 + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
60 + do {
61 + val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
62 + if (val == val2) {
63 + pass++;
64 + } else {
65 + pass = 0;
66 + val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
67 + }
68 + } while ((pass < 5) && (count++ < 0x10000));
69
70 - val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
71 return val & 1 ? 1 : 0;
72 }
73
74 @@ -979,7 +1003,7 @@ static void set_clock(void *i2c_priv, int clock)
75
76 for (i = 0; i < 0x10000; i++) {
77 ujcrb7 = ((clock & 0x01) ? 0 : 1);
78 - ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
79 + ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
80 jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
81 if (ujcrb7 == jtemp)
82 break;
83 @@ -995,7 +1019,7 @@ static void set_data(void *i2c_priv, int data)
84
85 for (i = 0; i < 0x10000; i++) {
86 ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
87 - ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
88 + ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
89 jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
90 if (ujcrb7 == jtemp)
91 break;
92 --
93 2.19.1
94