Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid enabling hdr if is it already enabled #7673

Merged
merged 2 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions src/hdr-config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,10 @@ namespace librealsense
_hdr_sequence_params.resize(DEFAULT_HDR_SEQUENCE_SIZE);

// restoring current HDR configuration if such subpreset is active
command cmd(ds::GETSUBPRESET);
bool existing_subpreset_restored = false;
try {
auto res = _hwm.send(cmd);
if (res.size() && is_current_subpreset_hdr(res))
{
existing_subpreset_restored = configure_hdr_as_in_fw(res);
}
}
catch (std::exception ex) {
LOG_WARNING("In hdr_config::hdr_config() - hw command failed: " << ex.what());
}
std::vector<byte> res;
if (is_hdr_enabled_in_device(res))
existing_subpreset_restored = configure_hdr_as_in_fw(res);

if (!existing_subpreset_restored)
{
Expand All @@ -55,6 +47,20 @@ namespace librealsense
}
}

bool hdr_config::is_hdr_enabled_in_device(std::vector<byte>& result) const
{
command cmd(ds::GETSUBPRESET);
bool hdr_enabled_in_device = false;
try {
result = _hwm.send(cmd);
hdr_enabled_in_device = (result.size() && is_current_subpreset_hdr(result));
}
catch (std::exception ex) {
LOG_WARNING("In hdr_config::hdr_config() - hw command failed: " << ex.what());
}
return hdr_enabled_in_device;
}

bool hdr_config::is_current_subpreset_hdr(const std::vector<byte>& current_subpreset) const
{
bool result = false;
Expand Down Expand Up @@ -242,25 +248,30 @@ namespace librealsense
{
if (validate_config())
{
// saving status of options that are not compatible with hdr,
// so that they could be reenabled after hdr disable
set_options_to_be_restored_after_disable();

if (_use_workaround)
std::vector<byte> res;
_is_enabled = is_hdr_enabled_in_device(res);
if (!_is_enabled)
ev-mp marked this conversation as resolved.
Show resolved Hide resolved
{
try {
// the following statement is needed in order to get/set the UVC exposure
// instead of one of the hdr's configuration exposure
set_sequence_index(0.f);
_pre_hdr_exposure = _sensor->get_option(RS2_OPTION_EXPOSURE).query();
_sensor->get_option(RS2_OPTION_EXPOSURE).set(PRE_ENABLE_HDR_EXPOSURE);
} catch (...) {
LOG_WARNING("HDR: enforced exposure failed");
// saving status of options that are not compatible with hdr,
// so that they could be reenabled after hdr disable
set_options_to_be_restored_after_disable();

if (_use_workaround)
{
try {
// the following statement is needed in order to get/set the UVC exposure
// instead of one of the hdr's configuration exposure
set_sequence_index(0.f);
_pre_hdr_exposure = _sensor->get_option(RS2_OPTION_EXPOSURE).query();
_sensor->get_option(RS2_OPTION_EXPOSURE).set(PRE_ENABLE_HDR_EXPOSURE);
} catch (...) {
LOG_WARNING("HDR: enforced exposure failed");
}
}
}

_is_enabled = send_sub_preset_to_fw();
_has_config_changed = false;
_is_enabled = send_sub_preset_to_fw();
_has_config_changed = false;
}
}
else
// msg to user to be improved later on
Expand All @@ -275,6 +286,7 @@ namespace librealsense
{
// this sleep is needed to let the fw restore the manual exposure
std::this_thread::sleep_for(std::chrono::milliseconds(70));

if (_pre_hdr_exposure >= _exposure_range.min && _pre_hdr_exposure <= _exposure_range.max)
{
try {
Expand Down
1 change: 1 addition & 0 deletions src/hdr-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace librealsense

private:
bool is_hdr_id(int id) const;
bool is_hdr_enabled_in_device(std::vector<byte>& result) const;
bool is_current_subpreset_hdr(const std::vector<byte>& current_subpreset) const;
bool configure_hdr_as_in_fw(const std::vector<byte>& current_subpreset);
command prepare_hdr_sub_preset_command() const;
Expand Down