diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-02-23 17:33:43 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-02-23 17:33:43 +0000 |
commit | c491f8e99349e4022fac0dec6536ab4b43396507 (patch) | |
tree | dfc2f6bba4d40995ef4e0c152a533ad12ff47d1e /open_firmware.c | |
parent | 3b6ec4ddecee5811e38d757f15a56edfbce79b4a (diff) | |
download | monitor-edid-c491f8e99349e4022fac0dec6536ab4b43396507.tar monitor-edid-c491f8e99349e4022fac0dec6536ab4b43396507.tar.gz monitor-edid-c491f8e99349e4022fac0dec6536ab4b43396507.tar.bz2 monitor-edid-c491f8e99349e4022fac0dec6536ab4b43396507.tar.xz monitor-edid-c491f8e99349e4022fac0dec6536ab4b43396507.zip |
*** empty log message ***
Diffstat (limited to 'open_firmware.c')
-rw-r--r-- | open_firmware.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/open_firmware.c b/open_firmware.c new file mode 100644 index 0000000..2170e70 --- /dev/null +++ b/open_firmware.c @@ -0,0 +1,55 @@ +#include <sys/types.h> +#include <sys/mman.h> +#include <netinet/in.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <assert.h> +#include <limits.h> +#include <ctype.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <linux/fb.h> +#include "get-edid.h" +#include "minifind.h" + +int get_edid(char *edid) +{ + struct pathNode *n; + struct findNode *list; + FILE* edid_file = NULL; + char *path = NULL; + + list = (struct findNode *) malloc(sizeof(struct findNode)); + list->result = (struct pathNode *) malloc(sizeof(struct pathNode)); + list->result->path = NULL; + list->result->next = list->result; + + minifind("/proc/device-tree", "EDID", list); + + for (n = list->result->next; n != list->result; n = n->next) + { + path = n->path; + break; + } + + if (path) + edid_file = fopen(path, "rb"); + + if (edid_file) + { + int size = fread(edid, sizeof(unsigned char), 0x80, edid_file); + fclose(edid_file); + return size == 0x80 ? 0x80 : 0; + } else + return 0; + +#if 0 + memcpy(&man, &ret->manufacturer_name, 2); + man = ntohs(man); + memcpy(&ret->manufacturer_name, &man, 2); + + /* byteswap to match the contents of MonitorsDB */ + ret->product_code = ((ret->product_code >> 8) & 0xff) | ((ret->product_code & 0xff) << 8); +#endif +} |