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 437ac2a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 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: 0 additions & 4 deletions src/ds/d500/d500-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@ namespace librealsense
set_frame_metadata_modifier([&](frame_additional_data& data) {data.depth_units = _depth_units.load(); });

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);
}); //group_multiple_fw_calls
}

Expand Down
5 changes: 3 additions & 2 deletions src/ds/ds-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,9 @@ namespace librealsense
else
{
if (_hdr_cfg->is_enabled())
LOG_WARNING("The control - " << _uvc_option->get_description()
<< " - is locked while HDR mode is active.\n");
throw wrong_api_call_sequence_exception(
rsutils::string::from() << "The control - " << _uvc_option->get_description()
<< " - is locked while HDR mode is active.");
else
_uvc_option->set(value);
}
Expand Down
36 changes: 22 additions & 14 deletions src/hdr-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "ds/d400/d400-private.h"

#include <rsutils/string/from.h>

#include "types.h"

namespace librealsense
{
Expand All @@ -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 @@ -264,7 +257,7 @@ namespace librealsense
if (!_is_enabled)
{
// saving status of options that are not compatible with hdr,
// so that they could be reenabled after hdr disable
// so that they could be reenabled after hdr disable
set_options_to_be_restored_after_disable();

if (_use_workaround)
Expand All @@ -281,7 +274,14 @@ namespace librealsense
}

_is_enabled = send_sub_preset_to_fw();
_has_config_changed = false;
if (!_is_enabled)
{
LOG_WARNING("Couldn't enable HDR." );
}
}
else
{
LOG_WARNING("HDR is already enabled. Skipping the request." );
}
}
else
Expand Down Expand Up @@ -504,14 +504,22 @@ namespace librealsense

void hdr_config::set_exposure(float value)
{
_hdr_sequence_params[_current_hdr_sequence_index]._exposure = value;
_has_config_changed = true;
if (!_is_enabled)
_hdr_sequence_params[_current_hdr_sequence_index]._exposure = value;
else
throw wrong_api_call_sequence_exception(rsutils::string::from()
<< "Cannot update HDR config (exposure) while HDR mode is active." );
}

void hdr_config::set_gain(float value)
{
_hdr_sequence_params[_current_hdr_sequence_index]._gain = value;
_has_config_changed = true;
if (!_is_enabled)
{
_hdr_sequence_params[_current_hdr_sequence_index]._gain = value;
}
else
throw wrong_api_call_sequence_exception(rsutils::string::from()
<< "Cannot update HDR config (gain) while HDR mode is active." );
}


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 437ac2a

Please sign in to comment.