summaryrefslogtreecommitdiff
path: root/utils/hwstub/lib/hwstub_usb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hwstub/lib/hwstub_usb.cpp')
-rw-r--r--utils/hwstub/lib/hwstub_usb.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/utils/hwstub/lib/hwstub_usb.cpp b/utils/hwstub/lib/hwstub_usb.cpp
index 28c64d9df3..6bb1cfa049 100644
--- a/utils/hwstub/lib/hwstub_usb.cpp
+++ b/utils/hwstub/lib/hwstub_usb.cpp
@@ -153,7 +153,10 @@ error device::open_dev(std::shared_ptr<hwstub::handle>& handle)
153 libusb_device_handle *h; 153 libusb_device_handle *h;
154 int err = libusb_open(m_dev, &h); 154 int err = libusb_open(m_dev, &h);
155 if(err != LIBUSB_SUCCESS) 155 if(err != LIBUSB_SUCCESS)
156 {
157 get_context()->debug() << "Cannot open device: " << err << "\n";
156 return error::ERROR; 158 return error::ERROR;
159 }
157 /* fetch some descriptors */ 160 /* fetch some descriptors */
158 struct libusb_device_descriptor dev_desc; 161 struct libusb_device_descriptor dev_desc;
159 struct libusb_config_descriptor *config = nullptr; 162 struct libusb_config_descriptor *config = nullptr;
@@ -234,7 +237,7 @@ uint16_t device::get_pid()
234handle::handle(std::shared_ptr<hwstub::device> dev, libusb_device_handle *handle) 237handle::handle(std::shared_ptr<hwstub::device> dev, libusb_device_handle *handle)
235 :hwstub::handle(dev), m_handle(handle) 238 :hwstub::handle(dev), m_handle(handle)
236{ 239{
237 set_timeout(std::chrono::milliseconds(100)); 240 set_timeout(std::chrono::milliseconds(1000));
238} 241}
239 242
240handle::~handle() 243handle::~handle()
@@ -284,8 +287,13 @@ rb_handle::rb_handle(std::shared_ptr<hwstub::device> dev,
284{ 287{
285 m_probe_status = error::SUCCESS; 288 m_probe_status = error::SUCCESS;
286 /* claim interface */ 289 /* claim interface */
287 if(libusb_claim_interface(m_handle, m_intf) != 0) 290 int err = libusb_claim_interface(m_handle, m_intf);
291 if(err != 0)
292 {
293 get_device()->get_context()->debug() <<
294 "Cannot claim interface: " << err <<"\n";
288 m_probe_status = error::PROBE_FAILURE; 295 m_probe_status = error::PROBE_FAILURE;
296 }
289 /* check version */ 297 /* check version */
290 if(m_probe_status == error::SUCCESS) 298 if(m_probe_status == error::SUCCESS)
291 { 299 {
@@ -295,7 +303,13 @@ rb_handle::rb_handle(std::shared_ptr<hwstub::device> dev,
295 { 303 {
296 if(ver_desc.bMajor != HWSTUB_VERSION_MAJOR || 304 if(ver_desc.bMajor != HWSTUB_VERSION_MAJOR ||
297 ver_desc.bMinor < HWSTUB_VERSION_MINOR) 305 ver_desc.bMinor < HWSTUB_VERSION_MINOR)
306 {
307 get_device()->get_context()->debug() <<
308 "Version mismatch: host is " << HWSTUB_VERSION_MAJOR <<
309 "." << HWSTUB_VERSION_MINOR << ", device is " <<
310 ver_desc.bMajor << "." << ver_desc.bMinor << "\n";
298 m_probe_status = error::PROBE_FAILURE; 311 m_probe_status = error::PROBE_FAILURE;
312 }
299 } 313 }
300 } 314 }
301 /* get buffer size */ 315 /* get buffer size */
@@ -305,6 +319,10 @@ rb_handle::rb_handle(std::shared_ptr<hwstub::device> dev,
305 m_probe_status = get_layout_desc(layout_desc); 319 m_probe_status = get_layout_desc(layout_desc);
306 if(m_probe_status == error::SUCCESS) 320 if(m_probe_status == error::SUCCESS)
307 m_buf_size = layout_desc.dBufferSize; 321 m_buf_size = layout_desc.dBufferSize;
322 /* libusb limits control transfers to 4096 bytes, to which we need to subtract
323 * the size of the possible header. To play safe, limit to 4000 bytes */
324 if(m_buf_size > 4000)
325 m_buf_size = 4000;
308 } 326 }
309} 327}
310 328