From 0634f8bb2e63985ebf2103318105b7185294da94 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Date: Wed, 22 Feb 2012 23:57:55 +0100
Subject: live: Use AEWB algorithm

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 Makefile |  2 +-
 live.c   | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index cb7d846..e4de38d 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ CFLAGS	:= -O2 -W -Wall -I$(KDIR)/usr/include
 LDFLAGS	:= -Lisp
 LIBS	:= -lomap3isp -lrt
 
-OBJ_LIVE := live.o events.o videoout.o
+OBJ_LIVE := live.o events.o iq.o videoout.o
 OBJ_SNAP := snapshot.o events.o
 
 %.o : %.c
diff --git a/live.c b/live.c
index c4d5ffd..0144372 100644
--- a/live.c
+++ b/live.c
@@ -46,11 +46,13 @@
 
 #include "isp/list.h"
 #include "isp/omap3isp.h"
+#include "isp/stats.h"
 #include "isp/tools.h"
 #include "isp/v4l2.h"
 #include "isp/v4l2-pool.h"
 
 #include "events.h"
+#include "iq.h"
 #include "videoout.h"
 
 #define MEDIA_DEVICE		"/dev/media0"
@@ -65,9 +67,20 @@ static unsigned int frame_skip = 0;
 
 static struct omap3_isp_device *isp = NULL;
 static struct videoout *vo = NULL;
+static struct iq_tuning *iq = NULL;
 
 static struct events events;
 
+/* -----------------------------------------------------------------------------
+ * Image quality
+ */
+
+static void __iq_aewb_process(struct omap3_isp_device *isp __attribute__((__unused__)),
+			      const struct omap3_isp_aewb_stats *stats)
+{
+	iq_aewb_process(iq, stats);
+}
+
 /* -----------------------------------------------------------------------------
  * Events
  */
@@ -135,6 +148,7 @@ static struct omap3_isp_operations isp_ops = {
 	.viewfinder_ready = viewfinder_process,
 	.watch_fd = __events_watch_fd,
 	.unwatch_fd = __events_unwatch_fd,
+	.aewb_ready = __iq_aewb_process,
 };
 
 /* -----------------------------------------------------------------------------
@@ -387,6 +401,12 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu
 	printf("viewfinder configured for %04x %ux%u\n",
 	       view_format.code, view_format.width, view_format.height);
 
+	iq = iq_init(isp);
+	if (iq == NULL) {
+		printf("error: unable to initialize image quality tuning\n");
+		goto cleanup;
+	}
+
 	/* Initialize video output. */
 	vo_devname = video_out_find();
 	if (vo_devname == NULL) {
@@ -456,6 +476,8 @@ cleanup:
 		omap3_isp_close(isp);
 	if (vo)
 		vo_cleanup(vo);
+	if (iq)
+		iq_cleanup(iq);
 
 	return exit_code;
 }
-- 
cgit v1.2.3