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 25, 2024
1 parent 5d995ee commit cf7ed8c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/linux/backend-v4l2.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ namespace librealsense
void set_power_state(power_state state) override;
power_state get_power_state() const override { return _state; }

void init_xu(const extension_unit&) override {}
void register_xu( platform::extension_unit && xu ) 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;
control_range get_xu_range(const extension_unit& xu, uint8_t control, int len) 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
4 changes: 3 additions & 1 deletion src/mf/mf-uvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace librealsense
static bool is_connected(const uvc_device_info& info);
static void foreach_uvc_device(enumeration_callback action);

void init_xu(const extension_unit& xu) override;
void register_xu( platform::extension_unit && xu ) override { _xus.push_back( std::move( xu ) ); }
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;
control_range get_xu_range(const extension_unit& xu, uint8_t ctrl, int len) const override;
Expand All @@ -101,6 +101,7 @@ namespace librealsense
private:
friend class source_reader_callback;

void init_xu(const extension_unit& xu);
void play_profile(stream_profile profile, frame_callback callback);
void stop_stream_cleanup(const stream_profile& profile, std::vector<profile_and_callback>::iterator& elem);
void flush(int sIndex);
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
6 changes: 3 additions & 3 deletions src/platform/uvc-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class uvc_device
virtual void set_power_state( power_state state ) = 0;
virtual power_state get_power_state() const = 0;

virtual void init_xu( const extension_unit & xu ) = 0;
virtual void register_xu( platform::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;
virtual control_range get_xu_range( const extension_unit & xu, uint8_t ctrl, int len ) const = 0;
Expand Down Expand Up @@ -183,7 +183,7 @@ class retry_controls_work_around : public uvc_device

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

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

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

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

void init_xu( const extension_unit & xu ) override { _dev.front()->init_xu( xu ); }
void register_xu( platform::extension_unit && xu ) override { _dev.front()->register_xu( std::move( 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
6 changes: 0 additions & 6 deletions src/uvc/uvc-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,6 @@ namespace librealsense
return _power_state;
}

void rs_uvc_device::init_xu(const extension_unit& xu)
{
// not supported
return;
}

bool rs_uvc_device::set_xu(const extension_unit& xu, uint8_t ctrl, const uint8_t* data, int len)
{
return uvc_set_ctrl(xu.unit, ctrl, (void *) data, len);
Expand Down
2 changes: 1 addition & 1 deletion src/uvc/uvc-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace librealsense
virtual void set_power_state(power_state state) override;
virtual power_state get_power_state() const override;

virtual void init_xu(const extension_unit& xu) override;
void register_xu( platform::extension_unit && xu ) override {} // Not supported
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;
virtual control_range get_xu_range(const extension_unit& xu, uint8_t ctrl, int len) const override;
Expand Down

0 comments on commit cf7ed8c

Please sign in to comment.