edid-decode: Avoid division by zero
PATCH 1/1 edid-decode: Avoid division by zero
There are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
This causes edid-decode to crash with a divsion by error exception. This simple patch avoids so, checking for the divisor before proceeding.
--- edid-decode.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
edid-decode.c +0 -0
@@ -1022,6 +1022,17 @@ static int detailed_block(const unsigned char *x,
int in_extension)
break;
}
+ if ((ha + hbl) == 0 ||
+ (va + vbl) == 0) {
+ printf("Invalid data. Refusing to continue.\n"
+ "Horizontal Active %4d\n" + "Horizontal Blanking %4d\n" + "Vertical Active %4d\n" + "Vertical Blanking %4d\n", + ha, hbl, va, vbl);
+ return 0;
+ }
+
pixclk_khz = (x[0] + (x[1] << 8)) * 10;
refresh = (pixclk_khz * 1000) / ((ha + hbl) * (va + vbl)); printf("Detailed mode: Clock %.3f MHz, %d mm x %d mm\n"
Signature · 1 line
2.17.1
Quoted 16 lines · Breno Leitao
There are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
This causes edid-decode to crash with a divsion by error exception. This simple patch avoids so, checking for the divisor before proceeding.
Signed-off-by Breno Leitao <[email protected]>--- edid-decode.c | 11 +++++++++++ 1 file changed, 11 insertions(+)edid-decode.c +0
-0
edid-decode.c static int detailed_block(const unsigned char *x, · line 1022
Quoted 1 line
edid-decode.c +0
-0@@ -1022,6 +1022,17 @@ static int detailed_block(const unsigned char *x, int in_extension)
This should have been on one line, it looks like your mailer is wrapping lines.
edid-decode.c static int detailed_block(const unsigned char *x, · line 1027
Quoted 5 lines
edid-decode.c +2
-0break ; } +if ((ha + hbl) ==0 || + (va + vbl) ==0 ) {
I'd use '!ha || !hbl || !va || !vbl' here.
edid-decode.c static int detailed_block(const unsigned char *x, · line 1028
Quoted 1 line
edid-decode.c +1
-0+ printf("Invalid data. Refusing to continue.\n"
I'd say: "Invalid Detailing Timings:" here.
Quoted 10 lines
edid-decode.c +8
-0+"Horizontal Active %4d\n" +"Horizontal Blanking %4d\n" +"Vertical Active %4d\n" +"Vertical Blanking %4d\n" , + ha, hbl, va, vbl); +return 0 ; + } + pixclk_khz = (x[0 ] + (x[1 ] <<8 )) *10 ; refresh = (pixclk_khz *1000 ) / ((ha + hbl) * (va + vbl));
Quoted 2 lines
printf("Detailed mode: Clock %.3f MHz, %d mm x %d mm\n"
I'm happy to take this if you post a v2 with these changes!
Regards,
Hans
PATCH v2 1/1 edid-decode: Avoid division by zero
There are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
This causes edid-decode to crash with a division by zero exception. This simple patch avoids so, checking for the divisor before proceeding.
--- edid-decode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
edid-decode.c +10 -0
@@ -1022,6 +1022,16 @@ static int detailed_block(const unsigned char *x, int in_extension)break ; } +if (!ha || !hbl || !va || !vbl) { +printf ("Invalid Detailing Timings:\n" +"Horizontal Active %4d\n" +"Horizontal Blanking %4d\n" +"Vertical Active %4d\n" +"Vertical Blanking %4d\n" , + ha, hbl, va, vbl); +return 0 ; + } + pixclk_khz = (x[0 ] + (x[1 ] <<8 )) *10 ; refresh = (pixclk_khz *1000 ) / ((ha + hbl) * (va + vbl)); printf("Detailed mode: Clock %.3f MHz, %d mm x %d mm\n"
Signature · 1 line
2.17.1
Quoted 2 lines · Breno Leitao
There are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
Do you have an EDID that does this? I'd like to add it to the collection of EDIDs in edid-decode.
Some more nitpicks below:
Quoted 14 lines
This causes edid-decode to crash with a division by zero exception. This simple patch avoids so, checking for the divisor before proceeding.
Signed-off-by Breno Leitao <[email protected]>--- edid-decode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)edid-decode.c +0
-0
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1026
Quoted 5 lines
edid-decode.c +2
-0@@ -1022,6 +1022,16 @@ static int detailed_block(const unsigned char *x, int in_extension)break ; } +if (!ha || !hbl || !va || !vbl) { + printf("Invalid Detailing Timings:\n"
Detailing -> Detailed
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1028
Quoted 2 lines
edid-decode.c +2
-0+"Horizontal Active %4d\n" +"Horizontal Blanking %4d\n"
This can be a bit more concise:
"Horizontal Active/Blanking: %d/%d\n"
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1030
Quoted 2 lines
edid-decode.c +2
-0+"Vertical Active %4d\n" + "Vertical Blanking %4d\n",
Ditto.
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1037
Quoted 8 lines
edid-decode.c +4
-0+ ha, hbl, va, vbl); +return 0 ; + } + pixclk_khz = (x[0 ] + (x[1 ] <<8 )) *10 ; refresh = (pixclk_khz *1000 ) / ((ha + hbl) * (va + vbl)); printf("Detailed mode: Clock %.3f MHz, %d mm x %d mm\n"
Regards,
Hans
Hi Hans,
Quoted 6 lines · Hans Verkuil
Quoted 2 lines · Breno Leitao
There are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
Do you have an EDID that does this? I'd like to add it to the collection of EDIDs in edid-decode.
Yes, This is an example. Is this what you want?
# cat /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1/edid | hexdump 0000000 ff00 ffff ffff 00ff 8f15 4600 72f0 0000 0000010 171e 0301 6680 7839 602a a19d 4954 269b 0000020 470f 234a 0008 c081 4081 8081 0095 00b3 0000030 c0d1 c08b 0101 3a02 1880 3871 402d 2c58 0000040 0045 3dfa 0032 1e00 2166 aa56 0051 301e 0000050 8f46 0033 3dfa 0032 1e00 0000 fd00 3000 0000060 1f3e 0f50 0a00 2020 2020 2020 0000 fe00 0000070 3100 3242 3343 3050 3430 3035 200a a101 0000080 0302 401b 1647 0431 0119 1803 0923 0707 0000090 0183 0000 0366 000c 0020 0180 001d 2e7c 00000a0 a090 1a60 401e 2030 0036 0ba2 0032 1a00 00000b0 0000 f700 0a00 ca00 60e0 0000 0000 0000 00000c0 0000 0000 fc00 4500 4f4c 4520 3454 3036 00000d0 4c30 2020 0000 0000 0000 0000 0000 0000 00000e0 0000 0000 0000 0000 0000 0000 0000 0000 00000f0 0000 0000 0000 0000 0000 0000 0000 c100 0000100
Quoted 30 lines
Some more nitpicks below:
Quoted 14 lines
This causes edid-decode to crash with a division by zero exception. This simple patch avoids so, checking for the divisor before proceeding.
Signed-off-by Breno Leitao <[email protected]>--- edid-decode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)edid-decode.c +0
-0edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1026
Quoted 5 lines
edid-decode.c +2
-0@@ -1022,6 +1022,16 @@ static int detailed_block(const unsigned char *x, int in_extension)break ; } +if (!ha || !hbl || !va || !vbl) { + printf("Invalid Detailing Timings:\n"Detailing -> Detailed
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1028
Quoted 2 lines
edid-decode.c +2
-0+"Horizontal Active %4d\n" +"Horizontal Blanking %4d\n" This can be a bit more concise:
Quoted 6 lines
"Horizontal Active/Blanking: %d/%d\n"
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1030
Quoted 2 lines
edid-decode.c +2
-0+"Vertical Active %4d\n" + "Vertical Blanking %4d\n",Ditto.
Ok, let me change it and send a v3.
Quoted 22 lines · Breno Leitao
Hi Hans,
Quoted 6 lines · Hans Verkuil
Quoted 2 lines · Breno Leitao
There are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
Do you have an EDID that does this? I'd like to add it to the collection of EDIDs in edid-decode.
Yes, This is an example. Is this what you want?
# cat /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1/edid | hexdump 0000000 ff00 ffff ffff 00ff 8f15 4600 72f0 0000 0000010 171e 0301 6680 7839 602a a19d 4954 269b 0000020 470f 234a 0008 c081 4081 8081 0095 00b3 0000030 c0d1 c08b 0101 3a02 1880 3871 402d 2c58 0000040 0045 3dfa 0032 1e00 2166 aa56 0051 301e 0000050 8f46 0033 3dfa 0032 1e00 0000 fd00 3000 0000060 1f3e 0f50 0a00 2020 2020 2020 0000 fe00 0000070 3100 3242 3343 3050 3430 3035 200a a101 0000080 0302 401b 1647 0431 0119 1803 0923 0707
Quoted 8 lines
0000090 0183 0000 0366 000c 0020 0180 001d 2e7c 00000a0 a090 1a60 401e 2030 0036 0ba2 0032 1a00 00000b0 0000 f700 0a00 ca00 60e0 0000 0000 0000 00000c0 0000 0000 fc00 4500 4f4c 4520 3454 3036 00000d0 4c30 2020 0000 0000 0000 0000 0000 0000 00000e0 0000 0000 0000 0000 0000 0000 0000 0000 00000f0 0000 0000 0000 0000 0000 0000 0000 c100 0000100
Yes, that's fine. What is the brand/model of the display?
Regards,
Hans
Quoted 40 lines
Quoted 31 lines
Some more nitpicks below:
Quoted 14 lines
This causes edid-decode to crash with a division by zero exception. This simple patch avoids so, checking for the divisor before proceeding.
Signed-off-by Breno Leitao <[email protected]>--- edid-decode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)edid-decode.c +0
-0edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1026
Quoted 5 lines
edid-decode.c +2
-0@@ -1022,6 +1022,16 @@ static int detailed_block(const unsigned char *x, int in_extension)break ; } +if (!ha || !hbl || !va || !vbl) { + printf("Invalid Detailing Timings:\n"Detailing -> Detailed
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1028
Quoted 2 lines
edid-decode.c +2
-0+"Horizontal Active %4d\n" +"Horizontal Blanking %4d\n" This can be a bit more concise:
Quoted 6 lines
"Horizontal Active/Blanking: %d/%d\n"
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1030
Quoted 2 lines
edid-decode.c +2
-0+"Vertical Active %4d\n" + "Vertical Blanking %4d\n",Ditto.
Ok, let me change it and send a v3.
Quoted 32 lines · Hans Verkuil
Quoted 22 lines · Breno Leitao
Hi Hans,
Quoted 6 lines · Hans Verkuil
Quoted 2 lines · Breno Leitao
There are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
Do you have an EDID that does this? I'd like to add it to the collection of EDIDs in edid-decode.
Yes, This is an example. Is this what you want?
# cat /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1/edid | hexdump 0000000 ff00 ffff ffff 00ff 8f15 4600 72f0 0000 0000010 171e 0301 6680 7839 602a a19d 4954 269b 0000020 470f 234a 0008 c081 4081 8081 0095 00b3 0000030 c0d1 c08b 0101 3a02 1880 3871 402d 2c58 0000040 0045 3dfa 0032 1e00 2166 aa56 0051 301e 0000050 8f46 0033 3dfa 0032 1e00 0000 fd00 3000 0000060 1f3e 0f50 0a00 2020 2020 2020 0000 fe00 0000070 3100 3242 3343 3050 3430 3035 200a a101 0000080 0302 401b 1647 0431 0119 1803 0923 0707Quoted 8 lines
0000090 0183 0000 0366 000c 0020 0180 001d 2e7c 00000a0 a090 1a60 401e 2030 0036 0ba2 0032 1a00 00000b0 0000 f700 0a00 ca00 60e0 0000 0000 0000 00000c0 0000 0000 fc00 4500 4f4c 4520 3454 3036 00000d0 4c30 2020 0000 0000 0000 0000 0000 0000 00000e0 0000 0000 0000 0000 0000 0000 0000 0000 00000f0 0000 0000 0000 0000 0000 0000 0000 c100 0000100
Quoted 1 line
Yes, that's fine. What is the brand/model of the display?
This is a touch panel manufactured by Elo, model 4600.
Quoted 21 lines · Breno Leitao
Hi Hans,
Quoted 6 lines · Hans Verkuil
Quoted 2 lines · Breno Leitao
There are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
Do you have an EDID that does this? I'd like to add it to the collection of EDIDs in edid-decode.
Yes, This is an example. Is this what you want?
# cat /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1/edid | hexdump 0000000 ff00 ffff ffff 00ff 8f15 4600 72f0 0000 0000010 171e 0301 6680 7839 602a a19d 4954 269b 0000020 470f 234a 0008 c081 4081 8081 0095 00b3 0000030 c0d1 c08b 0101 3a02 1880 3871 402d 2c58 0000040 0045 3dfa 0032 1e00 2166 aa56 0051 301e 0000050 8f46 0033 3dfa 0032 1e00 0000 fd00 3000 0000060 1f3e 0f50 0a00 2020 2020 2020 0000 fe00 0000070 3100 3242 3343 3050 3430 3035 200a a101
Quoted 8 lines
0000080 0302 401b 1647 0431 0119 1803 0923 0707 0000090 0183 0000 0366 000c 0020 0180 001d 2e7c 00000a0 a090 1a60 401e 2030 0036 0ba2 0032 1a00 00000b0 0000 f700 0a00 ca00 60e0 0000 0000 0000 00000c0 0000 0000 fc00 4500 4f4c 4520 3454 3036 00000d0 4c30 2020 0000 0000 0000 0000 0000 0000 00000e0 0000 0000 0000 0000 0000 0000 0000 0000 00000f0 0000 0000 0000 0000 0000 0000 0000 c100
Can you just mail me the raw output?
cat /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1/edid >edid.bin
hexdump messes things up, swapping lsb and msb :-)
Regards,
Hans
Quoted 41 lines
0000100
Quoted 30 lines
Some more nitpicks below:
Quoted 14 lines
This causes edid-decode to crash with a division by zero exception. This simple patch avoids so, checking for the divisor before proceeding.
Signed-off-by Breno Leitao <[email protected]>--- edid-decode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)edid-decode.c +0
-0edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1026
Quoted 5 lines
edid-decode.c +2
-0@@ -1022,6 +1022,16 @@ static int detailed_block(const unsigned char *x, int in_extension)break ; } +if (!ha || !hbl || !va || !vbl) { + printf("Invalid Detailing Timings:\n"Detailing -> Detailed
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1028
Quoted 2 lines
edid-decode.c +2
-0+"Horizontal Active %4d\n" +"Horizontal Blanking %4d\n" This can be a bit more concise:
Quoted 6 lines
"Horizontal Active/Blanking: %d/%d\n"
edid-decode.c static int detailed_block(const unsigned char *x, int in_extension) · line 1030
Quoted 2 lines
edid-decode.c +2
-0+"Vertical Active %4d\n" + "Vertical Blanking %4d\n",Ditto.
Ok, let me change it and send a v3.
Quoted 3 lines · Hans Verkuil
Can you just mail me the raw output?
cat /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-1/edid >edid.bin
Sure, here it is.
PATCH v3 1/1 edid-decode: Avoid division by zero
In reply to Hans VerkuilThere are some weird monitors that returns invalid data, as zeroed Horizontal/Vertical Active/Blanking.
This causes edid-decode to crash with a divsion by error exception. This simple patch avoids so, checking for the divisor before proceeding. On invalid data, it prints something as:
...
Invalid Detailed Timings:
Horizontal Active/Blanking 32/0
Vertical Active/Blanking 0/0
...
--- edid-decode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
edid-decode.c +8 -0
@@ -1022,6 +1022,14 @@ static int detailed_block(const unsigned char *x, int in_extension)break ; } +if (!ha || !hbl || !va || !vbl) { +printf ("Invalid Detailed Timings:\n" +"Horizontal Active/Blanking %d/%d\n" +"Vertical Active/Blanking %d/%d\n" , + ha, hbl, va, vbl); +return 0 ; + } + pixclk_khz = (x[0 ] + (x[1 ] <<8 )) *10 ; refresh = (pixclk_khz *1000 ) / ((ha + hbl) * (va + vbl)); printf("Detailed mode: Clock %.3f MHz, %d mm x %d mm\n"
Signature · 1 line
2.17.1