Procházet zdrojové kódy

ae: start using minimum values for controls, too

Pavel Machek před 2 měsíci
rodič
revize
b5dbc416b5
4 změnil soubory, kde provedl 16 přidání a 2 odebrání
  1. 5 0
      src/io_pipeline.c
  2. 4 0
      src/main.c
  3. 6 2
      src/process_pipeline.c
  4. 1 0
      src/state.h

+ 5 - 0
src/io_pipeline.c

@@ -101,12 +101,14 @@ update_process_pipeline()
                 .gain.auto_control = state_io.gain.auto_control,
                 .gain.value = state_io.gain.value,
                 .gain.max = state_io.gain.max,
+                .gain.min = state_io.gain.min,
                 .gain.manual = state_io.gain.manual,
 
                 .dgain.control = state_io.dgain.control,
                 .dgain.auto_control = state_io.dgain.auto_control,
                 .dgain.value = state_io.dgain.value,
                 .dgain.max = state_io.dgain.max,
+                .dgain.min = state_io.dgain.min,
                 .dgain.manual = state_io.dgain.manual,
 
                 .exposure.control = state_io.exposure.control,
@@ -488,11 +490,13 @@ init_controls()
         if (mp_camera_query_control(
                     state_io.camera->sensor_fd, V4L2_CID_GAIN, &gain_control)) {
                 state_io.gain.control = gain_control;
+                state_io.gain.min = gain_control.min;
                 state_io.gain.max = gain_control.max;
         } else if (mp_camera_query_control(state_io.camera->sensor_fd,
                                            V4L2_CID_ANALOGUE_GAIN,
                                            &gain_control)) {
                 state_io.gain.control = gain_control;
+                state_io.gain.min = gain_control.min;
                 state_io.gain.max = gain_control.max;
         } else {
                 state_io.gain.max = 0;
@@ -520,6 +524,7 @@ init_controls()
         if (mp_camera_query_control(
                     state_io.camera->sensor_fd, V4L2_CID_DIGITAL_GAIN, &dgain_control)) {
                 state_io.dgain.control = dgain_control;
+                state_io.dgain.min = dgain_control.min;
                 state_io.dgain.max = dgain_control.max;
         } else {
                 state_io.dgain.max = 0;

+ 4 - 0
src/main.c

@@ -125,6 +125,7 @@ update_io_pipeline()
                 .gain.value = state.gain.value,
                 .gain.value_req = state.gain.value_req,
                 .gain.max = state.gain.max,
+                .gain.min = state.gain.min,
                 .gain.manual = state.gain.manual,
                 .gain.manual_req = state.gain.manual_req,
 
@@ -133,6 +134,7 @@ update_io_pipeline()
                 .dgain.value = state.dgain.value,
                 .dgain.value_req = state.dgain.value_req,
                 .dgain.max = state.dgain.max,
+                .dgain.min = state.dgain.min,
                 .dgain.manual = state.dgain.manual,
                 .dgain.manual_req = state.dgain.manual_req,
 
@@ -192,12 +194,14 @@ update_state(const mp_state_main *new_state)
         state.gain.auto_control = new_state->gain.auto_control;
         state.gain.value = new_state->gain.value;
         state.gain.max = new_state->gain.max;
+        state.gain.min = new_state->gain.min;
         state.gain.manual = new_state->gain.manual;
 
         state.dgain.control = new_state->dgain.control;
         state.dgain.auto_control = new_state->dgain.auto_control;
         state.dgain.value = new_state->dgain.value;
         state.dgain.max = new_state->dgain.max;
+        state.dgain.min = new_state->dgain.min;
         state.dgain.manual = new_state->dgain.manual;
 
         state.exposure.control = new_state->exposure.control;

+ 6 - 2
src/process_pipeline.c

@@ -505,9 +505,9 @@ summarize()
 	//time = state_proc.exposure.value * state_proc.mode->height;
 
 	/* */
-	gain = state_proc.gain.value / 32.; /* FIXME: .min */
+	gain = state_proc.gain.value / ((float) state_proc.gain.min); /* FIXME: .min */
 	if (0) /* dgain */
-		gain *= state_proc.dgain.value / 256.;
+		gain *= state_proc.dgain.value / ((float) state_proc.dgain.min);
 
 	printf("1/%.0f sec, ISO %.0f, t=%f, g=%f %d %d\n",
 	       (float) (1.0/time), (float) (gain*100),
@@ -1413,12 +1413,14 @@ update_state(MPPipeline *pipeline, const mp_state_proc *new_state)
         state_proc.gain.auto_control = new_state->gain.auto_control;
         state_proc.gain.value = new_state->gain.value;
         state_proc.gain.max = new_state->gain.max;
+        state_proc.gain.min = new_state->gain.min;
         state_proc.gain.manual = new_state->gain.manual;
 
         state_proc.dgain.control = new_state->dgain.control;
         state_proc.dgain.auto_control = new_state->dgain.auto_control;
         state_proc.dgain.value = new_state->dgain.value;
         state_proc.dgain.max = new_state->dgain.max;
+        state_proc.dgain.min = new_state->dgain.min;
         state_proc.dgain.manual = new_state->dgain.manual;
 
         state_proc.exposure.control = new_state->exposure.control;
@@ -1494,6 +1496,7 @@ update_state(MPPipeline *pipeline, const mp_state_proc *new_state)
                 .gain.value = state_proc.gain.value,
                 .gain.value_req = state_proc.gain.value_req,
                 .gain.max = state_proc.gain.max,
+                .gain.min = state_proc.gain.min,
                 .gain.manual = state_proc.gain.manual,
 
                 .dgain.control = state_proc.dgain.control,
@@ -1501,6 +1504,7 @@ update_state(MPPipeline *pipeline, const mp_state_proc *new_state)
                 .dgain.value = state_proc.dgain.value,
                 .dgain.value_req = state_proc.dgain.value_req,
                 .dgain.max = state_proc.dgain.max,
+                .dgain.min = state_proc.dgain.min,
                 .dgain.manual = state_proc.dgain.manual,
 
                 .exposure.control = state_proc.exposure.control,

+ 1 - 0
src/state.h

@@ -8,6 +8,7 @@ typedef struct cstate {
         MPControl control;
         int32_t value;
         int32_t value_req;
+        int32_t min;
         int32_t max;
         bool manual;
         bool manual_req;