Skip to contentSkip to conversation

drm/ast: fixed reading monitor EDID not stable issue

PATCH Superseded Y.C. Chen 3 participants 7 messages Oct 30, 2018 – Nov 22, 2018

Subsystems (4)
lore
Share & tools
lore

Y.C. Chen

author
#0 lore raw

PATCH 1/1 drm/ast: fixed reading monitor EDID not stable issue

From: "Y.C. Chen" <[email protected]>

over-sample data to increase the stability with some specific monitors

---
 drivers/gpu/drm/ast/ast_mode.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +26 -6
index 5e77d45..22e80c0 100644
@@ -972,9 +972,19 @@ static int get_clock(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	volatile uint32_t val, val2, count;
+
+	count = 0;
+	val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		if (val == val2) count++;
+		else {
+			count = 0;
+			val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		}
+	} while (count < 5);
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
 	return val & 1 ? 1 : 0;
 }
 
@@ -982,9 +992,19 @@ static int get_data(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	volatile uint32_t val, val2, count;
+
+	count = 0;
+	val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		if (val == val2) count++;
+		else {
+			count = 0;
+			val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		}
+	} while (count < 5);
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
 	return val & 1 ? 1 : 0;
 }
 
@@ -997,7 +1017,7 @@ static void set_clock(void *i2c_priv, int clock)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((clock & 0x01) ? 0 : 1);
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
 		if (ujcrb7 == jtemp)
 			break;
@@ -1013,7 +1033,7 @@ static void set_data(void *i2c_priv, int data)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
 		if (ujcrb7 == jtemp)
 			break;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 21 lines · Y.C. Chen

From: "Y.C. Chen" <[email protected]>

over-sample data to increase the stability with some specific monitors

---
 drivers/gpu/drm/ast/ast_mode.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +2 -1
index 5e77d45..22e80c0 100644
@@ -972,9 +972,19 @@ static int get_clock(void *i2c_priv)
 {
        struct ast_i2c_chan *i2c = i2c_priv;
        struct ast_private *ast = i2c->dev->dev_private;
-       uint32_t val;
+       volatile uint32_t val, val2, count;
+

drivers/gpu/drm/ast/ast_mode.c static int get_clock(void *i2c_priv) · line 986

Quoted 10 lines
drivers/gpu/drm/ast/ast_mode.c +10 -0
+       count = 0;
+       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+       do {
+               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+               if (val == val2) count++;
+               else {
+                       count = 0;
+                       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+               }
+       } while (count < 5);

This can lead to an infinite loop if there's no stable output, no? I think those are frowned upon in the kernel...

Cheers,

-ilia

author
#2 lore raw

PATCH v2 1/1 ] drm/ast: fixed reading monitor EDID not stable issue

In reply to Y.C. Chen

From: "Y.C. Chen" <[email protected]>

v1: over-sample data to increase the stability with some specific monitors
v2: refine to avoid infinite loop

---
 drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +28 -6
index 5e77d45..092e9a7 100644
@@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	volatile uint32_t val, val2, count, pass;
+
+	count = 0;
+	pass  = 0;
+	val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		if (val == val2) pass++;
+		else {
+			pass = 0;
+			val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		}
+	} while ((pass < 5) && (count++ < 0x10000));
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
 	return val & 1 ? 1 : 0;
 }
 
@@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	volatile uint32_t val, val2, count, pass;
+
+	count = 0;
+	pass  = 0;
+	val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		if (val == val2) pass++;
+		else {
+			pass = 0;
+			val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		}
+	} while ((pass < 5) && (count++ < 0x10000));
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
 	return val & 1 ? 1 : 0;
 }
 
@@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((clock & 0x01) ? 0 : 1);
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
 		if (ujcrb7 == jtemp)
 			break;
@@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
 		if (ujcrb7 == jtemp)
 			break;
Signature · 1 line
1.8.3.1
maintainer
#3 lore raw

Re: [[PATCH v2]] drm/ast: fixed reading monitor EDID not stable issue

Quoted 5 lines · Y.C. Chen

From: "Y.C. Chen" <[email protected]>

v1: over-sample data to increase the stability with some specific monitors
v2: refine to avoid infinite loop

This contains at least 4 whitespace breakages (val =) in a few places, also why the volatiles, I don't think they make much sense here, have you verified they are required?

Dave.

Quoted 85 lines
---
 drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +28 -7
index 5e77d45..092e9a7 100644
@@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)
 {
        struct ast_i2c_chan *i2c = i2c_priv;
        struct ast_private *ast = i2c->dev->dev_private;
-       uint32_t val;
+       volatile uint32_t val, val2, count, pass;
+
+       count = 0;
+       pass  = 0;
+       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+       do {
+               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+               if (val == val2) pass++;
+               else {
+                       pass = 0;
+                       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
 
 
 
 
+               }
+       } while ((pass < 5) && (count++ < 0x10000));
 
-       val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
        return val & 1 ? 1 : 0;
 }
@@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)
 {
        struct ast_i2c_chan *i2c = i2c_priv;
        struct ast_private *ast = i2c->dev->dev_private;
-       uint32_t val;
+       volatile uint32_t val, val2, count, pass;
+
+       count = 0;
+       pass  = 0;
+       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+       do {
+               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+               if (val == val2) pass++;
+               else {
+                       pass = 0;
+                       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+               }
+       } while ((pass < 5) && (count++ < 0x10000));
 
-       val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
        return val & 1 ? 1 : 0;
 }
 
@@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)
 
        for (i = 0; i < 0x10000; i++) {
                ujcrb7 = ((clock & 0x01) ? 0 : 1);
-               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
+               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
                jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
                if (ujcrb7 == jtemp)
                        break;
@@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)
 
        for (i = 0; i < 0x10000; i++) {
                ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
-               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
+               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
                jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
                if (ujcrb7 == jtemp)
                        break;
--

1.8.3.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author
#4 lore raw

Re: [[PATCH v2]] drm/ast: fixed reading monitor EDID not stable issue

Hi Dave,
Thanks for your feedback. No issue found actually if I remove "volatile" on my platform. In my experience, if the value is volatile, adding "volatile" will be safer and no harm, that is why I add it by default. If you think it is not necessary, it's ok for me to remove it.

Regards,

Y.C. Chen

Dave Airlie <[email protected]> 於 2018年11月22日 週四 上午9:15寫道:

Quoted 97 lines · Y.C. Chen
Quoted 4 lines

From: "Y.C. Chen" <[email protected]>

v1: over-sample data to increase the stability with some specific

monitors

Quoted 1 line

v2: refine to avoid infinite loop

This contains at least 4 whitespace breakages (val =) in a few places, also why the volatiles, I don't think they make much sense here, have you verified they are required?

Dave.

Review

Quoted 7 lines
---
 drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/ast/ast_mode.c

drivers/gpu/drm/ast/ast_mode.c static int get_clock(void *i2c_priv) · line 979

Quoted 13 lines

index 5e77d45..092e9a7 100644

drivers/gpu/drm/ast/ast_mode.c +5 -1
@@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)
 {
        struct ast_i2c_chan *i2c = i2c_priv;
        struct ast_private *ast = i2c->dev->dev_private;
-       uint32_t val;
+       volatile uint32_t val, val2, count, pass;
+
+       count = 0;
+       pass  = 0;
+       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,

0x10) >> 4) & 0x01;

drivers/gpu/drm/ast/ast_mode.c static int get_clock(void *i2c_priv) · line 981

Quoted 2 lines
drivers/gpu/drm/ast/ast_mode.c +2 -0
+       do {
+               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT,

0xb7, 0x10) >> 4) & 0x01;

drivers/gpu/drm/ast/ast_mode.c static int get_clock(void *i2c_priv)

Quoted 4 lines
drivers/gpu/drm/ast/ast_mode.c +4 -0
+               if (val == val2) pass++;
+               else {
+                       pass = 0;
+                       val   = (ast_get_index_reg_mask(ast,

AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;

Quoted 9 lines
drivers/gpu/drm/ast/ast_mode.c +2 -1
+               }
+       } while ((pass < 5) && (count++ < 0x10000));
 
-       val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10)
 > 4;
        return val & 1 ? 1 : 0;
 }

drivers/gpu/drm/ast/ast_mode.c static int get_data(void *i2c_priv) · line 1000

Quoted 9 lines
drivers/gpu/drm/ast/ast_mode.c +5 -1
@@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)
 {
        struct ast_i2c_chan *i2c = i2c_priv;
        struct ast_private *ast = i2c->dev->dev_private;
-       uint32_t val;
+       volatile uint32_t val, val2, count, pass;
+
+       count = 0;
+       pass  = 0;
+       val   = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,

0x20) >> 5) & 0x01;

drivers/gpu/drm/ast/ast_mode.c static int get_data(void *i2c_priv) · line 1002

Quoted 2 lines
drivers/gpu/drm/ast/ast_mode.c +2 -0
+       do {
+               val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT,

0xb7, 0x20) >> 5) & 0x01;

drivers/gpu/drm/ast/ast_mode.c static int get_clock(void *i2c_priv)

Quoted 4 lines
drivers/gpu/drm/ast/ast_mode.c +4 -0
+               if (val == val2) pass++;
+               else {
+                       pass = 0;
+                       val   = (ast_get_index_reg_mask(ast,

AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;

drivers/gpu/drm/ast/ast_mode.c static void set_clock(void *i2c_priv, int clock) · line 1000

Quoted 13 lines
drivers/gpu/drm/ast/ast_mode.c +2 -2
+               }
+       } while ((pass < 5) && (count++ < 0x10000));
 
-       val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20)
 > 5;
        return val & 1 ? 1 : 0;
 }
@@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)
 
        for (i = 0; i < 0x10000; i++) {
                ujcrb7 = ((clock & 0x01) ? 0 : 1);
-               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,

0xfe, ujcrb7);

drivers/gpu/drm/ast/ast_mode.c static void set_clock(void *i2c_priv, int clock) · line 1022

Quoted 1 line
drivers/gpu/drm/ast/ast_mode.c +1 -0
+               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,

0xf4, ujcrb7);

drivers/gpu/drm/ast/ast_mode.c static void set_clock(void *i2c_priv, int clock) · line 1023

Quoted 1 line
drivers/gpu/drm/ast/ast_mode.c +0 -0
                jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT,

0xb7, 0x01);

Quoted 4 lines
drivers/gpu/drm/ast/ast_mode.c +0 -0
                if (ujcrb7 == jtemp)
                        break;
@@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)
 
Quoted 18 lines

drivers/gpu/drm/ast/ast_mode.c static void set_data(void *i2c_priv, int data)

Quoted 3 lines
drivers/gpu/drm/ast/ast_mode.c +0 -1
        for (i = 0; i < 0x10000; i++) {
                ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
-               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,

0xfb, ujcrb7);

drivers/gpu/drm/ast/ast_mode.c static void set_data(void *i2c_priv, int data) · line 1038

Quoted 1 line
drivers/gpu/drm/ast/ast_mode.c +1 -0
+               ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7,

0xf1, ujcrb7);

drivers/gpu/drm/ast/ast_mode.c static void set_data(void *i2c_priv, int data) · line 1039

Quoted 1 line
drivers/gpu/drm/ast/ast_mode.c +0 -0
                jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT,

0xb7, 0x04);

Quoted 9 lines
drivers/gpu/drm/ast/ast_mode.c +0 -1
                if (ujcrb7 == jtemp)
                        break;
--

1.8.3.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer
#5 lore raw

Re: [[PATCH v2]] drm/ast: fixed reading monitor EDID not stable issue

Quoted 4 lines · 陳雅正

Hi Dave,
Thanks for your feedback. No issue found actually if I remove "volatile" on my platform. In my experience, if the value is volatile, adding "volatile" will be safer and no harm, that is why I add it by default. If you think it is not necessary, it's ok for me to remove it.

Don't add it unless you've got proof you need it, we don't want it confusing people later.

Dave.

author
#6 lore raw

PATCH v3 1/1 drm/ast: fixed reading monitor EDID not stable issue

In reply to Y.C. Chen

From: "Y.C. Chen" <[email protected]>

v1: over-sample data to increase the stability with some specific monitors
v2: refine to avoid infinite loop
v3: remove un-necessary "volatile" declaration

---
 drivers/gpu/drm/ast/ast_mode.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +28 -6
index 5e77d45..843e2f9 100644
@@ -972,9 +972,20 @@ static int get_clock(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	uint32_t val, val2, count, pass;
+
+	count = 0;
+	pass = 0;
+	val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		if (val == val2) pass++;
+		else {
+			pass = 0;
+			val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4) & 0x01;
+		}
+	} while ((pass < 5) && (count++ < 0x10000));
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x10) >> 4;
 	return val & 1 ? 1 : 0;
 }
 
@@ -982,9 +993,20 @@ static int get_data(void *i2c_priv)
 {
 	struct ast_i2c_chan *i2c = i2c_priv;
 	struct ast_private *ast = i2c->dev->dev_private;
-	uint32_t val;
+	uint32_t val, val2, count, pass;
+
+	count = 0;
+	pass = 0;
+	val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+	do {
+		val2 = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		if (val == val2) pass++;
+		else {
+			pass = 0;
+			val = (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5) & 0x01;
+		}
+	} while ((pass < 5) && (count++ < 0x10000));
 
-	val = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x20) >> 5;
 	return val & 1 ? 1 : 0;
 }
 
@@ -997,7 +1019,7 @@ static void set_clock(void *i2c_priv, int clock)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((clock & 0x01) ? 0 : 1);
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfe, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf4, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x01);
 		if (ujcrb7 == jtemp)
 			break;
@@ -1013,7 +1035,7 @@ static void set_data(void *i2c_priv, int data)
 
 	for (i = 0; i < 0x10000; i++) {
 		ujcrb7 = ((data & 0x01) ? 0 : 1) << 2;
-		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xfb, ujcrb7);
+		ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0xf1, ujcrb7);
 		jtemp = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb7, 0x04);
 		if (ujcrb7 == jtemp)
 			break;
Signature · 1 line
1.8.3.1