aboutsummaryrefslogtreecommitdiffstats
path: root/open_firmware.c
diff options
context:
space:
mode:
Diffstat (limited to 'open_firmware.c')
-rw-r--r--open_firmware.c55
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
+}