From 36b7b2b38de82c8b018e7d1992045dbb0115336f Mon Sep 17 00:00:00 2001 From: Benjamin Schaaf Date: Mon, 26 Apr 2021 22:21:15 +1000 Subject: [PATCH] Fix gain and exposure being switched in io pipeline --- src/io_pipeline.c | 10 +++--- src/main.c | 80 ----------------------------------------------- 2 files changed, 5 insertions(+), 85 deletions(-) diff --git a/src/io_pipeline.c b/src/io_pipeline.c index 1ebb93d..22c882d 100644 --- a/src/io_pipeline.c +++ b/src/io_pipeline.c @@ -497,15 +497,15 @@ update_state(MPPipeline *pipeline, const struct mp_io_pipeline_state *state) pipeline, info->camera, on_frame, NULL); current_controls.gain_is_manual = - mp_camera_control_get_int32( - info->camera, V4L2_CID_EXPOSURE_AUTO) == - V4L2_EXPOSURE_MANUAL; + mp_camera_control_get_bool(info->camera, + V4L2_CID_AUTOGAIN) == 0; current_controls.gain = mp_camera_control_get_int32( info->camera, info->gain_ctrl); current_controls.exposure_is_manual = - mp_camera_control_get_bool(info->camera, - V4L2_CID_AUTOGAIN) == 0; + mp_camera_control_get_int32( + info->camera, V4L2_CID_EXPOSURE_AUTO) == + V4L2_EXPOSURE_MANUAL; current_controls.exposure = mp_camera_control_get_int32( info->camera, V4L2_CID_EXPOSURE); } diff --git a/src/main.c b/src/main.c index 804e718..1211f17 100644 --- a/src/main.c +++ b/src/main.c @@ -712,86 +712,6 @@ open_shutter_controls(GtkWidget *button, gpointer user_data) open_controls(button, "Shutter", 1.0, 360.0, exposure, !exposure_is_manual, set_shutter, set_shutter_auto); } -/* -static void -on_control_auto_toggled(GtkToggleButton *widget, gpointer user_data) -{ - bool is_manual = gtk_toggle_button_get_active(widget) ? false : true; - bool has_changed; - - switch (current_control) { - case USER_CONTROL_ISO: - if (gain_is_manual != is_manual) { - gain_is_manual = is_manual; - has_changed = true; - } - break; - case USER_CONTROL_SHUTTER: - if (exposure_is_manual != is_manual) { - exposure_is_manual = is_manual; - has_changed = true; - } - break; - } - - if (has_changed) { - // The slider might have been moved while Auto mode is active. When entering - // Manual mode, first read the slider value to sync with those changes. - double value = gtk_adjustment_get_value(control_slider); - switch (current_control) { - case USER_CONTROL_ISO: - if (value != gain) { - gain = (int)value; - } - break; - case USER_CONTROL_SHUTTER: { - // So far all sensors use exposure time in number of sensor rows - int new_exposure = - (int)(value / 360.0 * camera->capture_mode.height); - if (new_exposure != exposure) { - exposure = new_exposure; - } - break; - } - } - - update_io_pipeline(); - draw_controls(); - } -} - -static void -on_control_slider_changed(GtkAdjustment *widget, gpointer user_data) -{ - double value = gtk_adjustment_get_value(widget); - - bool has_changed = false; - switch (current_control) { - case USER_CONTROL_ISO: - if (value != gain) { - gain = (int)value; - has_changed = true; - } - break; - case USER_CONTROL_SHUTTER: { - // So far all sensors use exposure time in number of sensor rows - int new_exposure = - (int)(value / 360.0 * camera->capture_mode.height); - if (new_exposure != exposure) { - exposure = new_exposure; - has_changed = true; - } - break; - } - } - - if (has_changed) { - update_io_pipeline(); - draw_controls(); - } -} -*/ - static void on_realize(GtkWidget *window, gpointer *data) {