[PATCH spice-gtk v2 07/33] fixup! usb-redir: extend USB backend to support emulated devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/usb-backend.c | 79 +++++++++++++++++++++--------------------------
 1 file changed, 36 insertions(+), 43 deletions(-)

diff --git a/src/usb-backend.c b/src/usb-backend.c
index bed431c3..9aee6c7d 100644
--- a/src/usb-backend.c
+++ b/src/usb-backend.c
@@ -579,8 +579,7 @@ static int check_edev_device_filter(SpiceUsbBackendDevice *dev,
     if (!edev) {
         return 1;
     }
-    if (!device_ops(edev)->get_descriptor(
-            edev, LIBUSB_DT_CONFIG, 0, (void **)&cfg, &size)) {
+    if (!device_ops(edev)->get_descriptor(edev, LIBUSB_DT_CONFIG, 0, (void **)&cfg, &size)) {
         return 1;
     }
     while ((offset + 1) < size) {
@@ -598,25 +597,21 @@ static int check_edev_device_filter(SpiceUsbBackendDevice *dev,
         offset += len;
     }
 
-    return usbredirfilter_check(
-        rules, count,
-        dev->device_info.class,
-        dev->device_info.subclass,
-        dev->device_info.protocol,
-        cls, subcls, proto, ifnum,
-        dev->device_info.vid,
-        dev->device_info.pid,
-        dev->device_info.bcdUSB, 0);
+    return usbredirfilter_check(rules, count,
+                                dev->device_info.class,
+                                dev->device_info.subclass,
+                                dev->device_info.protocol,
+                                cls, subcls, proto, ifnum,
+                                dev->device_info.vid,
+                                dev->device_info.pid,
+                                dev->device_info.bcdUSB, 0);
 }
 
-int spice_usb_backend_device_check_filter(
-    SpiceUsbBackendDevice *dev,
-    const struct usbredirfilter_rule *rules,
-    int count)
+int spice_usb_backend_device_check_filter(SpiceUsbBackendDevice *dev,
+                                          const struct usbredirfilter_rule *rules, int count)
 {
     if (dev->libusb_device) {
-        return usbredirhost_check_device_filter(
-            rules, count, dev->libusb_device, 0);
+        return usbredirhost_check_device_filter(rules, count, dev->libusb_device, 0);
     } else {
         return check_edev_device_filter(dev, rules, count);
     }
@@ -824,9 +819,8 @@ static void usbredir_control_packet(void *priv,
     } else if (reqtype == (LIBUSB_REQUEST_TYPE_STANDARD | LIBUSB_RECIPIENT_DEVICE) &&
                h->request == LIBUSB_REQUEST_GET_DESCRIPTOR) {
         uint16_t size;
-        done = device_ops(edev)->get_descriptor(
-            edev, h->value >> 8, h->value & 0xff,
-            &out_buffer, &size);
+        done = device_ops(edev)->get_descriptor(edev, h->value >> 8, h->value & 0xff,
+                                                &out_buffer, &size);
         response.length = size;
         if (done) {
             response.status = 0;
@@ -835,8 +829,7 @@ static void usbredir_control_packet(void *priv,
     }
 
     if (!done) {
-        device_ops(edev)->control_request(
-            edev, data, data_len, &response, &out_buffer);
+        device_ops(edev)->control_request(edev, data, data_len, &response, &out_buffer);
         done = TRUE;
     }
 
@@ -848,10 +841,9 @@ static void usbredir_control_packet(void *priv,
 
     SPICE_DEBUG("%s responding with payload of %02X, status %X",
                 __FUNCTION__, response.length, response.status);
-    usbredirparser_send_control_packet(
-        ch->parser, id, &response,
-        response.length ? out_buffer : NULL,
-        response.length);
+    usbredirparser_send_control_packet(ch->parser, id, &response,
+                                       response.length ? out_buffer : NULL,
+                                       response.length);
 
     usbredir_write_flush_callback(ch);
     usbredirparser_free_packet_data(ch->parser, data);
@@ -1040,8 +1032,7 @@ static void usbredir_hello(void *priv,
     if (!edev) {
         return;
     }
-    if (!device_ops(edev)->get_descriptor(
-            edev, LIBUSB_DT_CONFIG, 0, (void **)&cfg, &size)) {
+    if (!device_ops(edev)->get_descriptor(edev, LIBUSB_DT_CONFIG, 0, (void **)&cfg, &size)) {
         return;
     }
     while ((offset + 1) < size) {
@@ -1303,27 +1294,29 @@ SpiceUsbBackendChannel *spice_usb_backend_channel_new(SpiceUsbBackend *be,
     ch->user_data = SPICE_USBREDIR_CHANNEL(user_data);
     if (be->libusb_context) {
         ch->backend = be;
-        ch->usbredirhost = usbredirhost_open_full(
-            be->libusb_context,
-            NULL,
-            usbredir_log,
-            usbredir_read_callback,
-            usbredir_write_callback,
-            usbredir_write_flush_callback,
-            usbredir_alloc_lock,
-            usbredir_lock_lock,
-            usbredir_unlock_lock,
-            usbredir_free_lock,
-            ch, PACKAGE_STRING,
-            spice_util_get_debug() ? usbredirparser_debug : usbredirparser_warning,
-            usbredirhost_fl_write_cb_owns_buffer);
+        ch->usbredirhost =
+            usbredirhost_open_full(be->libusb_context,
+                                   NULL,
+                                   usbredir_log,
+                                   usbredir_read_callback,
+                                   usbredir_write_callback,
+                                   usbredir_write_flush_callback,
+                                   usbredir_alloc_lock,
+                                   usbredir_lock_lock,
+                                   usbredir_unlock_lock,
+                                   usbredir_free_lock,
+                                   ch, PACKAGE_STRING,
+                                   spice_util_get_debug() ? usbredirparser_debug :
+                                        usbredirparser_warning,
+                                   usbredirhost_fl_write_cb_owns_buffer);
         g_warn_if_fail(ch->usbredirhost != NULL);
     }
 
     if (ch->usbredirhost) {
         ch->hidden_parser = create_parser(ch);
         ch->hidden_host = ch->usbredirhost;
-        usbredirhost_set_buffered_output_size_cb(ch->usbredirhost, usbredir_buffered_output_size_callback);
+        usbredirhost_set_buffered_output_size_cb(ch->usbredirhost,
+                                                 usbredir_buffered_output_size_callback);
     }
 
     if (!ch->hidden_parser) {
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]