diff -Naup motion-3.1.17/conf.c motion-3.1.17-picture_controls/conf.c
--- motion-3.1.17/conf.c	2004-10-10 23:45:57.000000000 +0200
+++ motion-3.1.17-picture_controls/conf.c	2004-10-16 06:48:43.000000000 +0200
@@ -69,6 +69,10 @@ struct config conf_template = {
 	low_cpu:               0,
 	nochild:               0,
 	autobright:            0,
+	brightness:	       0,
+	contrast:	       0,
+	saturation:	       0,
+	hue:		       0,
 	roundrobin_frames:     1,
 	roundrobin_skip:       1,
 	pre_capture:           0,
@@ -268,7 +272,34 @@ config_param config_params[] = {
 	copy_bool,
 	print_bool
 	},
-
+	{
+	"brightness",
+	"#Set the initial brightness of a video device.",
+	CONF_OFFSET(brightness),
+	copy_int,
+	print_int
+	},
+	{
+	"contrast",
+	"#Set the contrast of a video device.",
+	CONF_OFFSET(contrast),
+	copy_int,
+	print_int
+	},
+	{
+	"saturation",
+	"#Set  the saturation of a video device.",
+	CONF_OFFSET(saturation),
+	copy_int,
+	print_int
+	},
+	{
+	"hue",
+	"#Set the hue of a video device.",
+	CONF_OFFSET(hue),
+	copy_int,
+	print_int
+	},
 	{
 	"roundrobin_frames",
 	"\n############################################################\n"
diff -Naup motion-3.1.17/conf.h motion-3.1.17-picture_controls/conf.h
--- motion-3.1.17/conf.h	2004-08-01 11:49:07.000000000 +0200
+++ motion-3.1.17-picture_controls/conf.h	2004-10-16 06:49:11.000000000 +0200
@@ -50,6 +50,10 @@ struct config {
 	int low_cpu;
 	int nochild;
 	int autobright;
+	int brightness;
+	int contrast;
+	int saturation;
+	int hue;
 	int roundrobin_frames;
 	int roundrobin_skip;
 	int pre_capture;
diff -Naup motion-3.1.17/motion.c motion-3.1.17-picture_controls/motion.c
--- motion-3.1.17/motion.c	2004-10-11 00:22:33.000000000 +0200
+++ motion-3.1.17-picture_controls/motion.c	2004-10-16 06:45:10.000000000 +0200
@@ -722,11 +722,7 @@ static void *motion_loop(void *arg)
 			}
 		} else
 			diffs=0;
-#ifndef WITHOUT_V4L			
-		/* Auto-brightness feature */
-		if (cnt->conf.autobright)
-			vid_autobright(&cnt->conf, cnt->video_dev, newimg, cnt->conf.width, cnt->conf.height);
-#endif
+
 		if (cnt->moved) {
 			cnt->moved--;
 			diffs=0;
diff -Naup motion-3.1.17/video.c motion-3.1.17-picture_controls/video.c
--- motion-3.1.17/video.c	2004-10-10 23:14:37.000000000 +0200
+++ motion-3.1.17-picture_controls/video.c	2004-10-16 07:03:33.000000000 +0200
@@ -18,12 +18,96 @@
 /* for the v4l stuff: */
 #include "sys/mman.h"
 #include "sys/ioctl.h"
+#include "math.h"
 #endif /* WITHOUT_V4L */
 
 /* for rotation */
 #include "rotate.h"
 
 #ifndef WITHOUT_V4L
+
+static void v4l_picture_controls(struct context *cnt, int dev)
+{
+	unsigned char *image = cnt->imgs.new;
+	struct video_picture vid_pic;
+	int make_change = 0;
+	int i, j = 0, avg = 0, offset = 0;
+	int bri = cnt->conf.brightness;
+	int cont = cnt->conf.contrast;
+	int sat = cnt->conf.saturation;
+	int hue = cnt->conf.hue;
+
+	if (ioctl(dev, VIDIOCGPICT, &vid_pic)==-1) {
+		perror("ioctl VIDIOCGPICT");
+	}
+	
+	if (cnt->conf.autobright) {
+		for (i = 0; i < cnt->conf.width * cnt->conf.height * 3; i += 100) {
+			avg += *image++;
+			j++;
+		}
+		avg = avg / j;
+
+		if (avg > 140 || avg < 64) {
+			if (ioctl(dev, VIDIOCGPICT, &vid_pic)==-1) {
+				perror("ioctl VIDIOCGPICT");
+			}
+			if (avg > 140) {
+				offset=avg-140;
+				if (vid_pic.brightness > 100*offset) {
+					vid_pic.brightness-=100*offset;
+					make_change = 1;
+				}
+			}
+			if (avg < 64) {
+				offset=64-avg;
+				if (vid_pic.brightness < 65535-100*offset) {
+					vid_pic.brightness+=100*offset;
+					make_change = 1;
+				}
+			}
+			if (make_change)
+				printf("auto_brightness: %d\n", vid_pic.brightness);
+		}
+	} else {
+		if (bri && (fabsf((vid_pic.brightness/255) - bri) > 1.0)) {
+			vid_pic.brightness = bri * 255;
+			make_change = 1;
+		}
+	}
+	if (cont && (fabsf((vid_pic.contrast/255.0) - cont) > 1.0)) {
+		printf("contrast: %d(%d)\n", vid_pic.contrast, cont);
+		vid_pic.contrast = cont * 255;
+		make_change = 1;
+	}
+
+	if (sat && (fabsf((vid_pic.colour/255) - sat) > 1.0)) {
+		printf("colour: %d(%d)\n", vid_pic.colour, sat);
+		vid_pic.colour = sat * 255;
+		make_change = 1;
+	}
+
+	if (hue && (fabsf((vid_pic.hue/255) - hue) > 1.0)) {
+		printf("hue: %d(%d)\n", vid_pic.hue, hue);
+		vid_pic.hue = hue * 255;
+		make_change = 1;
+	}
+
+	if (make_change) {
+		//vid_pic.palette = cnt->imgs.type;
+		if (ioctl(dev, VIDIOCSPICT, &vid_pic)==-1) {
+			perror("ioctl VIDIOCSPICT");
+		}
+	}
+}
+
+void vid_picture_controls (struct context *cnt, int dev)
+{
+	if (!cnt->conf.netcam_url)
+		v4l_picture_controls(cnt, dev);
+}
+		
+
 void yuv422to420p(unsigned char *map, unsigned char *cap_map, int width, int height)
 {
 	unsigned char *src, *dest, *src2, *dest2;
@@ -286,7 +370,7 @@ static char *v4l_next (struct video_dev 
 	return map;
 }
 
-void v4l_set_input (struct video_dev *viddev, char *map, int width, int height, int input, int norm, int skip, unsigned long freq)
+void v4l_set_input (struct video_dev *viddev, char *map, int width, int height, int input, int norm, int skip, unsigned long freq, struct context *cnt)
 {
 	int dev=viddev->fd;
 	int i;
@@ -323,6 +407,7 @@ void v4l_set_input (struct video_dev *vi
 				return;
 			}
 		}
+		vid_picture_controls(cnt, dev);		
 		viddev->input=input;
 		viddev->width=width;
 		viddev->height=height;
@@ -330,6 +415,8 @@ void v4l_set_input (struct video_dev *vi
 		/* skip a few frames if needed */
 		for (i=0; i<skip; i++)
 			v4l_next (viddev, map, width, height);
+	} else {
+		vid_picture_controls(cnt, dev);
 	}
 }
 
@@ -418,38 +505,6 @@ static int v4l_putpipe (int dev, char *i
 	return write(dev, image, size);
 }
 
-static void v4l_autobright (int dev, unsigned char *image, int width, int height)
-{
-	struct video_picture vid_pic;
-	int i, j=0, avg=0, offset=0;
-	
-	for (i=0; i<width*height; i+=100) {
-		avg+=*image++;
-		j++;
-	}
-	avg=avg/j;
-
-	if (avg > 140 || avg < 64) {
-		if (ioctl(dev, VIDIOCGPICT, &vid_pic)==-1) {
-			syslog(LOG_ERR, "ioctl VIDIOCGPICT: %m");
-		}
-		if (avg > 140) {
-			offset=avg-140;
-			if (vid_pic.brightness > 100*offset)
-				vid_pic.brightness-=100*offset;
-		}
-		if (avg < 64) {
-			offset=64-avg;
-			if (vid_pic.brightness < 65535-100*offset)
-				vid_pic.brightness+=100*offset;
-		}
-		printf("auto_brightness: %d\n", vid_pic.brightness);
-		if (ioctl(dev, VIDIOCSPICT, &vid_pic)==-1) {
-			syslog(LOG_ERR, "ioctl VIDIOCSPICT: %m");
-		}
-	}
-}
-
 /*****************************************************************************
 	Wrappers calling the actual capture routines
  *****************************************************************************/
@@ -627,7 +682,7 @@ char *vid_next (struct context *cnt, int
 			cnt->switched=1;
 		}
 
-		v4l_set_input (viddevs[i], map, width, height, conf->input, conf->norm, conf->roundrobin_skip, conf->frequency);
+		v4l_set_input (viddevs[i], map, width, height, conf->input, conf->norm, conf->roundrobin_skip, conf->frequency,cnt);
 		ret=v4l_next (viddevs[i], map, width, height);
 
 		if (--viddevs[i]->frames <= 0) {
@@ -654,10 +709,4 @@ int vid_putpipe (int dev, char *image, i
 {
 	return v4l_putpipe (dev, image, size);
 }
-
-void vid_autobright (struct config *conf, int dev, char *image, int width, int height)
-{
-	if (!conf->netcam_url) 
-		v4l_autobright(dev, image, width, height);
-}
 #endif /*WITHOUT_V4L*/
diff -Naup motion-3.1.17/video.h motion-3.1.17-picture_controls/video.h
--- motion-3.1.17/video.h	2004-10-11 18:53:16.000000000 +0200
+++ motion-3.1.17-picture_controls/video.h	2004-10-16 07:03:54.000000000 +0200
@@ -61,7 +61,6 @@ char *vid_next (struct context *, int de
 void vid_init(void);
 int vid_startpipe (char *devname, int width, int height, int);
 int vid_putpipe (int dev, char *image, int);
-void vid_autobright (struct config *, int dev, char *image, int width, int height);
 void vid_close(void);
 void vid_cleanup(void);
 #endif
