From cf7ed8ca002c0db6629f182b3e13b1ff6e57ede2 Mon Sep 17 00:00:00 2001 From: ohadmeir Date: Tue, 24 Dec 2024 21:37:48 +0200 Subject: [PATCH] XU list saved in uvc_device not uvc_sensor --- src/linux/backend-v4l2.h | 2 +- src/mf/mf-uvc.cpp | 3 +++ src/mf/mf-uvc.h | 4 +++- src/platform/uvc-device.h | 6 +++--- src/uvc-sensor.cpp | 4 +--- src/uvc-sensor.h | 1 - src/uvc/uvc-device.cpp | 6 ------ src/uvc/uvc-device.h | 2 +- 8 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/linux/backend-v4l2.h b/src/linux/backend-v4l2.h index bc24df144e..a4bfd8749e 100644 --- a/src/linux/backend-v4l2.h +++ b/src/linux/backend-v4l2.h @@ -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; diff --git a/src/mf/mf-uvc.cpp b/src/mf/mf-uvc.cpp index 305cfab412..6e985c462e 100644 --- a/src/mf/mf-uvc.cpp +++ b/src/mf/mf-uvc.cpp @@ -885,6 +885,9 @@ namespace librealsense CHECK_HR(MFCreateSourceReaderFromMediaSource(_source, _reader_attrs, &_reader)); CHECK_HR(_reader->SetStreamSelection(static_cast(MF_SOURCE_READER_ALL_STREAMS), TRUE)); _power_state = D0; + + for( auto && xu : _xus ) + init_xu( xu ); } void wmf_uvc_device::set_d3() diff --git a/src/mf/mf-uvc.h b/src/mf/mf-uvc.h index 1ae61ab5a0..ee9a04ef5b 100644 --- a/src/mf/mf-uvc.h +++ b/src/mf/mf-uvc.h @@ -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; @@ -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::iterator& elem); void flush(int sIndex); @@ -146,6 +147,7 @@ namespace librealsense bool _streaming = false; std::atomic _is_started = false; std::wstring _device_id; + std::vector< platform::extension_unit > _xus; }; class source_reader_callback : public IMFSourceReaderCallback diff --git a/src/platform/uvc-device.h b/src/platform/uvc-device.h index b6267990f0..7c37561176 100644 --- a/src/platform/uvc-device.h +++ b/src/platform/uvc-device.h @@ -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; @@ -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 { @@ -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 { diff --git a/src/uvc-sensor.cpp b/src/uvc-sensor.cpp index fab565af0f..c617c165ca 100644 --- a/src/uvc-sensor.cpp +++ b/src/uvc-sensor.cpp @@ -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 ) ); } @@ -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 ) { diff --git a/src/uvc-sensor.h b/src/uvc-sensor.h index f2370d56b0..ffc63dc3b7 100644 --- a/src/uvc-sensor.h +++ b/src/uvc-sensor.h @@ -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; }; diff --git a/src/uvc/uvc-device.cpp b/src/uvc/uvc-device.cpp index a23615ae74..d144ed81b2 100644 --- a/src/uvc/uvc-device.cpp +++ b/src/uvc/uvc-device.cpp @@ -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); diff --git a/src/uvc/uvc-device.h b/src/uvc/uvc-device.h index aa9b6c93d1..6ca8516626 100644 --- a/src/uvc/uvc-device.h +++ b/src/uvc/uvc-device.h @@ -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;