浏览代码

Front camera metadata and auto exposure switch

Martijn Braam 4 年之前
父节点
当前提交
9cbebee116
共有 5 个文件被更改,包括 26 次插入5 次删除
  1. 3 0
      config/pine64,pinephone-1.0.ini
  2. 3 0
      config/pine64,pinephone-1.1.ini
  3. 3 0
      config/pine64,pinephone-1.2.ini
  4. 3 0
      config/pine64,pinetab.ini
  5. 14 5
      main.c

+ 3 - 0
config/pine64,pinephone-1.0.ini

@@ -25,3 +25,6 @@ height=600
 rate=30
 fmt=BGGR8
 rotate=90
+focallength=2.6
+cropfactor=12.7
+fnumber=2.8

+ 3 - 0
config/pine64,pinephone-1.1.ini

@@ -25,3 +25,6 @@ height=600
 rate=30
 fmt=BGGR8
 rotate=90
+focallength=2.6
+cropfactor=12.7
+fnumber=2.8

+ 3 - 0
config/pine64,pinephone-1.2.ini

@@ -25,3 +25,6 @@ height=600
 rate=30
 fmt=BGGR8
 rotate=90
+focallength=2.6
+cropfactor=12.7
+fnumber=2.8

+ 3 - 0
config/pine64,pinetab.ini

@@ -25,3 +25,6 @@ height=600
 rate=30
 fmt=BGGR8
 rotate=90
+focallength=2.6
+cropfactor=12.7
+fnumber=2.8

+ 14 - 5
main.c

@@ -84,6 +84,8 @@ static cairo_surface_t *surface = NULL;
 static int preview_width = -1;
 static int preview_height = -1;
 static char *last_path = NULL;
+static int auto_exposure = 1;
+static int auto_gain = 1;
 
 // Widgets
 GtkWidget *preview;
@@ -265,11 +267,18 @@ init_sensor(char *fn, int width, int height, int mbus, int rate)
 		fmt.format.width, fmt.format.height,
 		fmt.format.code);
 
-	// Placeholder, default is also 1
-	//v4l2_ctrl_set(fd, V4L2_CID_AUTOGAIN, 0);
-	//v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
-	//v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE, height/24);
-	//v4l2_ctrl_set(fd, V4L2_CID_GAIN, 0);
+	if (auto_exposure) {
+		v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_AUTO);
+	} else {
+		v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE_AUTO, V4L2_EXPOSURE_MANUAL);
+		v4l2_ctrl_set(fd, V4L2_CID_EXPOSURE, height/2);
+	}
+	if (auto_gain) {
+		v4l2_ctrl_set(fd, V4L2_CID_AUTOGAIN, 1);
+	} else {
+		v4l2_ctrl_set(fd, V4L2_CID_AUTOGAIN, 0);
+		v4l2_ctrl_set(fd, V4L2_CID_GAIN, 0);
+	}
 	close(current.fd);
 	current.fd = fd;
 }