summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2009-10-02 13:25:28 -0400
committerAdam Jackson <ajax@redhat.com>2009-10-02 13:25:28 -0400
commit318d0dde61bbb469adaae05b63df28512d9ba745 (patch)
tree7536a96edc26e7d8548729ab1c33c31f739e1616
parentff78c8530a1466afa60528c21263bc4bf16416ef (diff)
Start monitor API
-rw-r--r--Makefile7
-rw-r--r--cvt.c2
-rw-r--r--gtf.c2
-rw-r--r--minitru.h6
-rw-r--r--monitor.c32
5 files changed, 42 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 01632d1..4c1ea94 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,9 @@
-sources = gtf.c cvt.c
+sources = \
+ cvt.c \
+ gtf.c \
+ mode.c \
+ monitor.c
+
objects = $(sources:.c=.o)
all: libminitru.so.0
diff --git a/cvt.c b/cvt.c
index f9472bc..edff0a4 100644
--- a/cvt.c
+++ b/cvt.c
@@ -49,7 +49,7 @@
struct mt_mode *
mt_ct_mode(int hdisplay, int vdisplay, float vrefresh, uint32_t flags)
{
- struct mt_mode *mode = calloc(1, sizeof(struct mt_mode));
+ struct mt_mode *mode = mt_mode_alloc();
int interlaced = !!(flags & MT_FLAG_INTERLACED);
int reduced = !!(flags & MT_FLAG_REDUCED);
diff --git a/gtf.c b/gtf.c
index 649eff4..b2ecede 100644
--- a/gtf.c
+++ b/gtf.c
@@ -95,7 +95,7 @@
struct mt_mode *
mt_gtf_mode(uint32_t h_pixels, uint32_t v_lines, float freq, uint32_t flags)
{
- struct mt_mode *mode = calloc(1, sizeof(struct mt_mode));
+ struct mt_mode *mode = mt_mode_alloc();
int interlaced = !!(flags & MT_FLAG_INTERLACED);
int margins = 0; /* XXX just rip me out */
diff --git a/minitru.h b/minitru.h
index 890bc72..d4c7f36 100644
--- a/minitru.h
+++ b/minitru.h
@@ -25,10 +25,8 @@
#include <stdint.h>
-struct mt_monitor;
-
-extern struct mt_monitor *mt_create_monitor(void *block);
-extern void mt_destroy_monitor(struct mt_monitor *monitor);
+extern void *mt_create_monitor(void *block, uint32_t len);
+extern void mt_destroy_monitor(void *monitor);
/*
* These happen to be the same as the xfree86 values, except for REDUCED
diff --git a/monitor.c b/monitor.c
new file mode 100644
index 0000000..8d9cdd8
--- /dev/null
+++ b/monitor.c
@@ -0,0 +1,32 @@
+#include "minitru-int.h"
+
+const struct mt_backend *backends[] = {
+ NULL
+};
+const int num_backends = sizeof(backends) / sizeof(struct mt_backend);
+
+void *
+mt_create_monitor(void *block, uint32_t len)
+{
+ struct mt_monitor *mon = calloc(1, sizeof(*mon));
+ int i;
+
+ mon->block = block;
+ mon->len = len;
+
+ for (i = 0; i < num_backends; i++) {
+ if (backends[i]->probe(mon)) {
+ mon->backend = backends[i];
+ return mon;
+ }
+ }
+
+ free(mon);
+ return NULL;
+}
+
+void
+mt_destroy_monitor(void *monitor)
+{
+ free(monitor);
+}