浏览代码

Add support for defining the transfer curve per mode

Martijn Braam 1 年之前
父节点
当前提交
8eb42d77e6
共有 3 个文件被更改,包括 18 次插入2 次删除
  1. 3 2
      config/purism,librem5.conf
  2. 4 0
      include/libmegapixels.h
  3. 11 0
      src/parse.c

+ 3 - 2
config/purism,librem5.conf

@@ -13,11 +13,11 @@ Rear: {
             Rate: 15;
             Format: "GRBG8";
             Rotate: 270;
+            Transfer: "srgb";
 
             # All the links on this platform are immutable
             Pipeline: (
                 {Type: "Mode", Entity: "s5k3l6xx"},
-                {Type: "Rate", Entity: "s5k3l6xx"},
                 {Type: "Mode", Entity: "imx8mq-mipi-csi2"},
                 {Type: "Mode", Entity: "csi"},
             );
@@ -28,9 +28,10 @@ Rear: {
             Rate: 30;
             Format: "GRBG8";
             Rotate: 270;
+            Transfer: "srgb";
+
             Pipeline: (
                 {Type: "Mode", Entity: "s5k3l6xx"},
-                {Type: "Rate", Entity: "s5k3l6xx"},
                 {Type: "Mode", Entity: "imx8mq-mipi-csi2"},
                 {Type: "Mode", Entity: "csi"},
             );

+ 4 - 0
include/libmegapixels.h

@@ -21,6 +21,9 @@ libmegapixels_find_config(char *configfile);
 #define LIBMEGAPIXELS_CFA_GRBG 3
 #define LIBMEGAPIXELS_CFA_RGGB 4
 
+#define LIBMEGAPIXELS_XFER_RAW 0;
+#define LIBMEGAPIXELS_XFER_SRGB 8;
+
 struct _lmp_cmd {
 		int type;
 		const char *entity_from;
@@ -48,6 +51,7 @@ struct _lmp_mode {
 		int format;
 		int rotation;
 		int mirrored;
+		int xfer;
 		double focal_length;
 		double f_number;
 

+ 11 - 0
src/parse.c

@@ -249,6 +249,17 @@ load_camera(libmegapixels_devconfig *config, config_t *cfg, const char *name)
 		mm->v4l_pixfmt = libmegapixels_format_to_v4l_pixfmt(mm->format);
 		mm->media_busfmt = libmegapixels_format_to_media_busfmt(mm->format);
 
+		const char *xfer;
+		if (config_setting_lookup_string(mode, "Transfer", &xfer)) {
+			if (strcmp(xfer, "srgb") == 0) {
+				mm->xfer = LIBMEGAPIXELS_XFER_SRGB;
+			} else {
+				mm->xfer = LIBMEGAPIXELS_XFER_RAW;
+			}
+		} else {
+			mm->xfer = LIBMEGAPIXELS_XFER_RAW;
+		}
+
 		if (!config_setting_lookup_int(mode, "Rotate", &mm->rotation)) {
 			mm->rotation = 0;
 		}