Skip to content

Commit

Permalink
XU list saved in uvc_device not uvc_sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Dec 24, 2024
1 parent 5d995ee commit b538882
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/linux/backend-v4l2.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ namespace librealsense
void set_power_state(power_state state) override;
power_state get_power_state() const override { return _state; }

void register_xu( platform::extension_unit && xu ) override {}
void init_xu(const extension_unit&) override {}
bool set_xu(const extension_unit& xu, uint8_t control, const uint8_t* data, int size) override;
bool get_xu(const extension_unit& xu, uint8_t control, uint8_t* data, int size) const override;
Expand Down
3 changes: 3 additions & 0 deletions src/mf/mf-uvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,9 @@ namespace librealsense
CHECK_HR(MFCreateSourceReaderFromMediaSource(_source, _reader_attrs, &_reader));
CHECK_HR(_reader->SetStreamSelection(static_cast<DWORD>(MF_SOURCE_READER_ALL_STREAMS), TRUE));
_power_state = D0;
for( auto && xu : _xus )
init_xu( xu );
}
void wmf_uvc_device::set_d3()
Expand Down
2 changes: 2 additions & 0 deletions src/mf/mf-uvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace librealsense
static bool is_connected(const uvc_device_info& info);
static void foreach_uvc_device(enumeration_callback action);

void register_xu( platform::extension_unit && xu ) override { _xus.push_back( std::move( xu ) ); }
void init_xu(const extension_unit& xu) override;
bool set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len) override;
bool get_xu(const extension_unit& xu, uint8_t ctrl, uint8_t* data, int len) const override;
Expand Down Expand Up @@ -146,6 +147,7 @@ namespace librealsense
bool _streaming = false;
std::atomic<bool> _is_started = false;
std::wstring _device_id;
std::vector< platform::extension_unit > _xus;
};

class source_reader_callback : public IMFSourceReaderCallback
Expand Down
5 changes: 5 additions & 0 deletions src/platform/uvc-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class uvc_device
virtual void set_power_state( power_state state ) = 0;
virtual power_state get_power_state() const = 0;

virtual void register_xu( platform::extension_unit && xu ) = 0;
virtual void init_xu( const extension_unit & xu ) = 0;
virtual bool set_xu( const extension_unit & xu, uint8_t ctrl, const uint8_t * data, int len ) = 0;
virtual bool get_xu( const extension_unit & xu, uint8_t ctrl, uint8_t * data, int len ) const = 0;
Expand Down Expand Up @@ -183,6 +184,8 @@ class retry_controls_work_around : public uvc_device

power_state get_power_state() const override { return _dev->get_power_state(); }

void register_xu( platform::extension_unit && xu ) override { _dev->register_xu( std::move( xu ) ); }

void init_xu( const extension_unit & xu ) override { _dev->init_xu( xu ); }

bool set_xu( const extension_unit & xu, uint8_t ctrl, const uint8_t * data, int len ) override
Expand Down Expand Up @@ -313,6 +316,8 @@ class multi_pins_uvc_device : public uvc_device

power_state get_power_state() const override { return _dev.front()->get_power_state(); }

void register_xu( platform::extension_unit && xu ) override { _dev.front()->register_xu( std::move( xu ) ); }

void init_xu( const extension_unit & xu ) override { _dev.front()->init_xu( xu ); }

bool set_xu( const extension_unit & xu, uint8_t ctrl, const uint8_t * data, int len ) override
Expand Down
4 changes: 1 addition & 3 deletions src/uvc-sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void uvc_sensor::finished_bulk_operation()

void uvc_sensor::register_xu( platform::extension_unit xu )
{
_xus.push_back( std::move( xu ) );
_device->register_xu( std::move( xu ) );
}


Expand Down Expand Up @@ -419,8 +419,6 @@ void uvc_sensor::acquire_power()
try
{
_device->set_power_state( platform::D0 );
for( auto && xu : _xus )
_device->init_xu( xu );
}
catch( std::exception const & e )
{
Expand Down
1 change: 0 additions & 1 deletion src/uvc-sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class uvc_sensor : public raw_sensor_base
std::atomic< int > _user_count;
std::mutex _power_lock;
std::mutex _configure_lock;
std::vector< platform::extension_unit > _xus;
std::unique_ptr< power > _power;
std::unique_ptr< frame_timestamp_reader > _timestamp_reader;
};
Expand Down
1 change: 1 addition & 0 deletions src/uvc/uvc-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace librealsense
virtual void set_power_state(power_state state) override;
virtual power_state get_power_state() const override;

void register_xu( platform::extension_unit && xu ) override {} // Not supported
virtual void init_xu(const extension_unit& xu) override;
virtual bool set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len) override;
virtual bool get_xu(const extension_unit& xu, uint8_t ctrl, uint8_t* data, int len) const override;
Expand Down

0 comments on commit b538882

Please sign in to comment.