aboutsummaryrefslogtreecommitdiffstats
path: root/vbe.c
diff options
context:
space:
mode:
authorAnssi Hannula <anssi@mandriva.org>2010-01-02 05:10:29 +0000
committerAnssi Hannula <anssi@mandriva.org>2010-01-02 05:10:29 +0000
commit412da37667cc06fd16b1e28b1b5f20e9a467de8f (patch)
treee3711b6a7883edf6988c7a33d1932d05c9147cc7 /vbe.c
parent423de7f72b60fe852c7b07ad80b80b8fcb47880a (diff)
downloadmonitor-edid-412da37667cc06fd16b1e28b1b5f20e9a467de8f.tar
monitor-edid-412da37667cc06fd16b1e28b1b5f20e9a467de8f.tar.gz
monitor-edid-412da37667cc06fd16b1e28b1b5f20e9a467de8f.tar.bz2
monitor-edid-412da37667cc06fd16b1e28b1b5f20e9a467de8f.tar.xz
monitor-edid-412da37667cc06fd16b1e28b1b5f20e9a467de8f.zip
Add handling of EDID extension blocks.
Diffstat (limited to 'vbe.c')
-rw-r--r--vbe.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/vbe.c b/vbe.c
index 8eb74fc..56882d3 100644
--- a/vbe.c
+++ b/vbe.c
@@ -209,11 +209,10 @@ static int vbe_check_ddc_capabilities(int port)
return 1;
}
-static int vbe_get_edid_info(char *edid, int port)
+static int vbe_get_edid_info(char *edid, int port, int block)
{
int i;
unsigned char *mem;
- const int EDID_BLOCK_SIZE = 128;
struct LRMI_regs regs;
/* initialize LRMI */
@@ -235,6 +234,7 @@ static int vbe_get_edid_info(char *edid, int port)
regs.eax = 0x4f15;
regs.ebx = 0x0001;
regs.ecx = port;
+ regs.edx = block;
regs.es = (uintptr_t)(mem - LRMI_base_addr()) >> 4;
regs.edi = (uintptr_t)(mem - LRMI_base_addr()) & 0x0f;
@@ -262,6 +262,7 @@ static int vbe_get_edid_info(char *edid, int port)
int get_edid(char *edid, int port)
{
+ int i, extensions;
int ok = 0;
if (getuid() != 0) {
@@ -272,9 +273,26 @@ int get_edid(char *edid, int port)
ok =
(box_is_xbox() || (vbe_check_vbe_info() &&
vbe_check_ddc_capabilities(port))) &&
- vbe_get_edid_info(edid, port);
+ vbe_get_edid_info(edid, port, 0);
- return ok ? 128 : 0;
+ if (!ok)
+ return 0;
+
+ extensions = ((unsigned char*)edid)[126];
+ if (extensions > MAX_EXTENSION_COUNT) {
+ log_err("EDID: Reported %d extensions, only reading %d\n",
+ extensions, MAX_EXTENSION_COUNT);
+ extensions = MAX_EXTENSION_COUNT;
+ }
+
+ for (i = 1; i <= extensions; i++) {
+ if (!vbe_get_edid_info(edid + i * EDID_BLOCK_SIZE, port, i)) {
+ log_err("EDID: Failure reading extension block %d\n", i);
+ break;
+ }
+ }
+
+ return i * EDID_BLOCK_SIZE;
}
int box_is_xbox() {