Skip to content

Commit

Permalink
move group_multiple_fw_calls from l500-private.h to the more general …
Browse files Browse the repository at this point in the history
…device.h

apply group_multiple_fw_calls to ds5-device
  • Loading branch information
doronhi committed Oct 14, 2021
1 parent 8367b8c commit a679ec9
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 299 deletions.
10 changes: 10 additions & 0 deletions src/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,15 @@ class device : public virtual device_interface, public info_container
lazy<std::vector<tagged_profile>> _profiles_tags;
};

// Helper function that should be used when multiple FW calls needs to be made.
// This function change the USB power to D0 (Operational) using the invoke_power function
// activate the received function and power down the state to D3 (Idle)
template<class T>
auto group_multiple_fw_calls(synthetic_sensor& s, T action)
-> decltype(action())
{
auto& us = dynamic_cast<uvc_sensor&>(*s.get_raw_sensor());

return us.invoke_powered([&](platform::uvc_device& dev) { return action(); });
}
}
557 changes: 282 additions & 275 deletions src/ds5/ds5-device.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/l500/l500-color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ namespace librealsense

try {
// Keep the USB power on while triggering multiple calls on it.
ivcam2::group_multiple_fw_calls(*this, [&]() {
group_multiple_fw_calls(*this, [&]() {
// endpoint 5 - 32KB
command cmdTprocGranEp5(ivcam2::TPROC_USB_GRAN_SET, 5, usb_trb);
_owner->_hw_monitor->send(cmdTprocGranEp5);
Expand Down
2 changes: 1 addition & 1 deletion src/l500/l500-depth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ namespace librealsense

try {
// Keep the USB power on while triggering multiple calls on it.
ivcam2::group_multiple_fw_calls(*this, [&]() {
group_multiple_fw_calls(*this, [&]() {
// endpoint 2 (depth)
command cmdTprocGranEp2(ivcam2::TPROC_USB_GRAN_SET, 2, ep2_usb_trb);
_owner->_hw_monitor->send(cmdTprocGranEp2);
Expand Down
12 changes: 6 additions & 6 deletions src/l500/l500-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace librealsense
, _was_set_manually( false )
{
// Keep the USB power on while triggering multiple calls on it.
ivcam2::group_multiple_fw_calls( _l500_dev->get_depth_sensor(), [&]() {
group_multiple_fw_calls( _l500_dev->get_depth_sensor(), [&]() {
auto min = _hw_monitor->send( command{ AMCGET, _type, get_min } );
auto max = _hw_monitor->send( command{ AMCGET, _type, get_max } );
auto step = _hw_monitor->send( command{ AMCGET, _type, get_step } );
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace librealsense
auto& depth_sensor = get_depth_sensor();

// Keep the USB power on while triggering multiple HW monitor commands on it.
ivcam2::group_multiple_fw_calls( depth_sensor, [&]() {
group_multiple_fw_calls( depth_sensor, [&]() {
if (_fw_version >= firmware_version("1.5.0.0"))
{
bool usb3mode = (_usb_mode >= platform::usb3_type || _usb_mode == platform::usb_undefined);
Expand Down Expand Up @@ -613,7 +613,7 @@ namespace librealsense
void l500_options::change_preset( rs2_l500_visual_preset preset )
{
// Keep the USB power on while triggering multiple calls on it.
ivcam2::group_multiple_fw_calls( get_depth_sensor(), [&]() {
group_multiple_fw_calls( get_depth_sensor(), [&]() {
// we need to reset the controls before change gain because after moving to auto gain
// APD is read only. This will tell the FW that the control values are defaults and
// therefore can be overridden automatically according to gain
Expand Down Expand Up @@ -671,7 +671,7 @@ namespace librealsense
void l500_options::reset_hw_controls()
{
// Keep the USB power on while triggering multiple calls on it.
ivcam2::group_multiple_fw_calls( get_depth_sensor(), [&]() {
group_multiple_fw_calls( get_depth_sensor(), [&]() {
for (auto& o : _hw_options)
if (!o.second->is_read_only())
{
Expand All @@ -691,7 +691,7 @@ namespace librealsense
void l500_options::update_defaults()
{
// Keep the USB power on while triggering multiple calls on it.
ivcam2::group_multiple_fw_calls( get_depth_sensor(), [&]() {
group_multiple_fw_calls( get_depth_sensor(), [&]() {

auto& resolution = get_depth_sensor().get_option(RS2_OPTION_SENSOR_MODE);

Expand Down Expand Up @@ -822,7 +822,7 @@ namespace librealsense
float_option_with_description::set(value);

// Keep the USB power on while triggering multiple calls on it.
ivcam2::group_multiple_fw_calls( ds, [&]() { notify( value ); } );
group_multiple_fw_calls( ds, [&]() { notify( value ); } );
}

const char * max_usable_range_option::get_description() const
Expand Down
12 changes: 0 additions & 12 deletions src/l500/l500-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,18 +618,6 @@ namespace librealsense

rs2_sensor_mode get_resolution_from_width_height(int width, int height);

// Helper function that should be used when multiple FW calls needs to be made.
// This function change the USB power to D0 (Operational) using the invoke_power function
// activate the received function and power down the state to D3 (Idle)
template<class T>
auto group_multiple_fw_calls(synthetic_sensor &s, T action)
-> decltype(action())
{
auto &us = dynamic_cast<uvc_sensor&>(*s.get_raw_sensor());

return us.invoke_powered([&](platform::uvc_device& dev) { return action(); });
}

class ac_trigger;
} // librealsense::ivcam2
} // namespace librealsense
4 changes: 2 additions & 2 deletions src/l500/l500-serializable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace librealsense
serialized_utilities::json_preset_writer writer;
writer.set_device_info(_depth_sensor.get_device());

return ivcam2::group_multiple_fw_calls( _depth_sensor, [&]() {
return group_multiple_fw_calls( _depth_sensor, [&]() {

auto options = _depth_sensor.get_supported_options();

Expand All @@ -45,7 +45,7 @@ namespace librealsense
// Verify if device information in preset file is compatible with the connected device.
reader.check_device_info(_depth_sensor.get_device());

return ivcam2::group_multiple_fw_calls(_depth_sensor, [&]() {
return group_multiple_fw_calls(_depth_sensor, [&]() {

// Set of options that should not be set in the loop
std::set< rs2_option > options_to_ignore{ RS2_OPTION_SENSOR_MODE,
Expand Down
2 changes: 1 addition & 1 deletion src/l500/l535-amc-option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ amc_option::amc_option( librealsense::l500_device * l500_dev,
, _description( description )
{
// Keep the USB power on while triggering multiple calls on it.
ivcam2::group_multiple_fw_calls( _device->get_depth_sensor(), [&]() {
group_multiple_fw_calls( _device->get_depth_sensor(), [&]() {
auto min = _hw_monitor->send( command{ AMCGET, _control, get_min } );
auto max = _hw_monitor->send( command{ AMCGET, _control, get_max } );
auto step = _hw_monitor->send( command{ AMCGET, _control, get_step } );
Expand Down
2 changes: 1 addition & 1 deletion src/l500/l535-device-options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ device_options::device_options( std::shared_ptr< librealsense::context > ctx,
auto & depth_sensor = get_depth_sensor();

// Keep the USB power on while triggering multiple HW monitor commands on it.
ivcam2::group_multiple_fw_calls( depth_sensor, [&]() {
group_multiple_fw_calls( depth_sensor, [&]() {
auto default_sensor_mode = RS2_SENSOR_MODE_VGA;

std::map< rs2_option, std::pair< amc_control, std::string > > options = {
Expand Down

0 comments on commit a679ec9

Please sign in to comment.