From c491f8e99349e4022fac0dec6536ab4b43396507 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 23 Feb 2005 17:33:43 +0000 Subject: *** empty log message *** --- open_firmware.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 open_firmware.c (limited to 'open_firmware.c') 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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 +} -- cgit v1.2.1