Skip to content

Commit

Permalink
Fix: Should not set HDR when it is already enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Arun-Prasad-V committed Dec 13, 2023
1 parent 851aed5 commit dc14073
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
4 changes: 0 additions & 4 deletions src/ds/d400/d400-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ namespace librealsense

synthetic_sensor::open(requests);

// needed in order to restore the HDR sub-preset when streaming is turned off and on
if (_hdr_cfg && _hdr_cfg->is_enabled())
get_option(RS2_OPTION_HDR_ENABLED).set(1.f);

// Activate Thermal Compensation tracking
if (supports_option(RS2_OPTION_THERMAL_COMPENSATION))
_owner->_thermal_monitor->update(true);
Expand Down
4 changes: 4 additions & 0 deletions src/ds/ds-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,10 @@ namespace librealsense
else
{
if (_hdr_cfg->is_enabled())
/*throw wrong_api_call_sequence_exception(
rsutils::string::from() << "The control - " << _uvc_option->get_description()
<< " - is locked while HDR mode is active.");*/

LOG_WARNING("The control - " << _uvc_option->get_description()
<< " - is locked while HDR mode is active.\n");
else
Expand Down
41 changes: 27 additions & 14 deletions src/hdr-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace librealsense
_sensor(depth_ep),
_is_enabled(false),
_is_config_in_process(false),
_has_config_changed(false),
_current_hdr_sequence_index(DEFAULT_CURRENT_HDR_SEQUENCE_INDEX),
_auto_exposure_to_be_restored(false),
_emitter_on_off_to_be_restored(false),
Expand Down Expand Up @@ -215,12 +214,6 @@ namespace librealsense
default:
throw invalid_value_exception("option is not an HDR option");
}

// subpreset configuration change is immediately sent to firmware if HDR is already running
if (_is_enabled && _has_config_changed)
{
send_sub_preset_to_fw();
}
}

bool hdr_config::is_config_in_process() const
Expand Down Expand Up @@ -280,8 +273,14 @@ namespace librealsense
}
}

_is_enabled = send_sub_preset_to_fw();
_has_config_changed = false;
std::vector<byte> response;
send_sub_preset_to_fw();
_is_enabled = is_hdr_enabled_in_device(response);
configure_hdr_as_in_fw(response);
}
else
{
LOG_WARNING("HDR: re-enablement not supported. Disable HDR first and then try enabling again." );
}
}
else
Expand Down Expand Up @@ -504,15 +503,29 @@ namespace librealsense

void hdr_config::set_exposure(float value)
{
_hdr_sequence_params[_current_hdr_sequence_index]._exposure = value;
_has_config_changed = true;
std::vector<byte> res;
_is_enabled = is_hdr_enabled_in_device(res);
if (!_is_enabled)
_hdr_sequence_params[_current_hdr_sequence_index]._exposure = value;
else
/*throw wrong_api_call_sequence_exception(
rsutils::string::from() << "hdr_config::set_exposure(...) failed! Cannot update HDR when it is already enabled." );*/
LOG_WARNING("hdr_config::set_exposure(...) failed! Cannot update HDR when it is already enabled.\n");
}

void hdr_config::set_gain(float value)
{
_hdr_sequence_params[_current_hdr_sequence_index]._gain = value;
_has_config_changed = true;
}
std::vector<byte> res;
_is_enabled = is_hdr_enabled_in_device(res);
if (!_is_enabled)
{
_hdr_sequence_params[_current_hdr_sequence_index]._gain = value;
}
else
/*throw invalid_value_exception(
rsutils::string::from() << "hdr_config::set_gain(...) failed! Cannot update HDR when it is already enabled." );*/
LOG_WARNING("hdr_config::set_gain(...) failed! Cannot update HDR when it is already enabled.\n");
}


hdr_params::hdr_params() :
Expand Down
1 change: 0 additions & 1 deletion src/hdr-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ namespace librealsense
int _current_hdr_sequence_index;
mutable bool _is_enabled;
bool _is_config_in_process;
bool _has_config_changed;
bool _auto_exposure_to_be_restored;
bool _emitter_on_off_to_be_restored;
hw_monitor& _hwm;
Expand Down

0 comments on commit dc14073

Please sign in to comment.