From 318d0dde61bbb469adaae05b63df28512d9ba745 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Fri, 2 Oct 2009 13:25:28 -0400 Subject: Start monitor API --- Makefile | 7 ++++++- cvt.c | 2 +- gtf.c | 2 +- minitru.h | 6 ++---- monitor.c | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 monitor.c 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 -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); +} -- cgit v1.2.3