Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/main.c | 124 ++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 62 deletions(-)
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index c6d7859dcfa..72e1f7ded5d 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -442,6 +442,68 @@ static DWORD check_bus_option(const UNICODE_STRING *option, DWORD default_value) return default_value; }
+static NTSTATUS deliver_last_report(struct device_extension *ext, DWORD buffer_length, BYTE* buffer, ULONG_PTR *out_length) +{ + if (buffer_length < ext->last_report_size) + { + *out_length = 0; + return STATUS_BUFFER_TOO_SMALL; + } + else + { + if (ext->last_report) + memcpy(buffer, ext->last_report, ext->last_report_size); + *out_length = ext->last_report_size; + return STATUS_SUCCESS; + } +} + +void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) +{ + struct device_extension *ext = (struct device_extension*)device->DeviceExtension; + IRP *irp; + LIST_ENTRY *entry; + + if (!length || !report) + return; + + EnterCriticalSection(&ext->cs); + if (length > ext->buffer_size) + { + HeapFree(GetProcessHeap(), 0, ext->last_report); + ext->last_report = HeapAlloc(GetProcessHeap(), 0, length); + if (!ext->last_report) + { + ERR_(hid_report)("Failed to alloc last report\n"); + ext->buffer_size = 0; + ext->last_report_size = 0; + ext->last_report_read = TRUE; + LeaveCriticalSection(&ext->cs); + return; + } + else + ext->buffer_size = length; + } + + memcpy(ext->last_report, report, length); + ext->last_report_size = length; + ext->last_report_read = FALSE; + + while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue) + { + IO_STACK_LOCATION *irpsp; + TRACE_(hid_report)("Processing Request\n"); + irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry); + irpsp = IoGetCurrentIrpStackLocation(irp); + irp->IoStatus.Status = deliver_last_report(ext, + irpsp->Parameters.DeviceIoControl.OutputBufferLength, + irp->UserBuffer, &irp->IoStatus.Information); + ext->last_report_read = TRUE; + IoCompleteRequest(irp, IO_NO_INCREMENT); + } + LeaveCriticalSection(&ext->cs); +} + static NTSTATUS handle_IRP_MN_QUERY_DEVICE_RELATIONS(IRP *irp) { NTSTATUS status = irp->IoStatus.Status; @@ -794,22 +856,6 @@ static NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp) return pdo_pnp_dispatch(device, irp); }
-static NTSTATUS deliver_last_report(struct device_extension *ext, DWORD buffer_length, BYTE* buffer, ULONG_PTR *out_length) -{ - if (buffer_length < ext->last_report_size) - { - *out_length = 0; - return STATUS_BUFFER_TOO_SMALL; - } - else - { - if (ext->last_report) - memcpy(buffer, ext->last_report, ext->last_report_size); - *out_length = ext->last_report_size; - return STATUS_SUCCESS; - } -} - static NTSTATUS hid_get_device_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DWORD buffer_len) { struct device_extension *ext = (struct device_extension *)device->DeviceExtension; @@ -996,52 +1042,6 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) return status; }
-void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) -{ - struct device_extension *ext = (struct device_extension*)device->DeviceExtension; - IRP *irp; - LIST_ENTRY *entry; - - if (!length || !report) - return; - - EnterCriticalSection(&ext->cs); - if (length > ext->buffer_size) - { - HeapFree(GetProcessHeap(), 0, ext->last_report); - ext->last_report = HeapAlloc(GetProcessHeap(), 0, length); - if (!ext->last_report) - { - ERR_(hid_report)("Failed to alloc last report\n"); - ext->buffer_size = 0; - ext->last_report_size = 0; - ext->last_report_read = TRUE; - LeaveCriticalSection(&ext->cs); - return; - } - else - ext->buffer_size = length; - } - - memcpy(ext->last_report, report, length); - ext->last_report_size = length; - ext->last_report_read = FALSE; - - while ((entry = RemoveHeadList(&ext->irp_queue)) != &ext->irp_queue) - { - IO_STACK_LOCATION *irpsp; - TRACE_(hid_report)("Processing Request\n"); - irp = CONTAINING_RECORD(entry, IRP, Tail.Overlay.ListEntry); - irpsp = IoGetCurrentIrpStackLocation(irp); - irp->IoStatus.Status = deliver_last_report(ext, - irpsp->Parameters.DeviceIoControl.OutputBufferLength, - irp->UserBuffer, &irp->IoStatus.Information); - ext->last_report_read = TRUE; - IoCompleteRequest(irp, IO_NO_INCREMENT); - } - LeaveCriticalSection(&ext->cs); -} - BOOL is_xbox_gamepad(WORD vid, WORD pid) { int i;
Instead of calling process_hid_report.
This adds a reference count on unix devices to make sure they are kept alive until all their input report events have been processed.
This also uses a bus-specific device list, to be able to find devices from joystick ids without having to call back to the win32 side.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_sdl.c | 78 ++++++++++++++++++++++----------- dlls/winebus.sys/main.c | 31 ++++++++++++- dlls/winebus.sys/unix_private.h | 4 ++ dlls/winebus.sys/unixlib.c | 50 +++++++++++++++++++-- dlls/winebus.sys/unixlib.h | 8 ++++ 5 files changed, 140 insertions(+), 31 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index a0b44283182..6eafcb75285 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -59,12 +59,22 @@ WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
WINE_DECLARE_DEBUG_CHANNEL(hid_report);
+static CRITICAL_SECTION sdl_cs; +static CRITICAL_SECTION_DEBUG sdl_cs_debug = +{ + 0, 0, &sdl_cs, + { &sdl_cs_debug.ProcessLocksList, &sdl_cs_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": sdl_cs") } +}; +static CRITICAL_SECTION sdl_cs = { &sdl_cs_debug, -1, 0, 0, 0, 0 }; + static const WCHAR sdl_busidW[] = {'S','D','L','J','O','Y',0}; static struct sdl_bus_options options;
static void *sdl_handle = NULL; static UINT quit_event = -1; static struct list event_queue = LIST_INIT(event_queue); +static struct list device_list = LIST_INIT(device_list);
#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL MAKE_FUNCPTR(SDL_GetError); @@ -136,9 +146,14 @@ static inline struct platform_private *impl_from_unix_device(struct unix_device return CONTAINING_RECORD(iface, struct platform_private, unix_device); }
-static inline struct platform_private *impl_from_DEVICE_OBJECT(DEVICE_OBJECT *device) +static struct platform_private *find_device_from_id(SDL_JoystickID id) { - return impl_from_unix_device(get_unix_device(device)); + struct platform_private *device; + + LIST_FOR_EACH_ENTRY(device, &device_list, struct platform_private, unix_device.entry) + if (device->id == id) return device; + + return NULL; }
#define CONTROLLER_NUM_BUTTONS 11 @@ -501,6 +516,10 @@ static void sdl_device_stop(struct unix_device *iface) pSDL_JoystickClose(private->sdl_joystick); if (private->sdl_controller) pSDL_GameControllerClose(private->sdl_controller); if (private->sdl_haptic) pSDL_HapticClose(private->sdl_haptic); + + EnterCriticalSection(&sdl_cs); + list_remove(&private->unix_device.entry); + LeaveCriticalSection(&sdl_cs); }
static NTSTATUS sdl_device_get_reportdescriptor(struct unix_device *iface, BYTE *buffer, @@ -586,11 +605,11 @@ static const struct unix_device_vtbl sdl_device_vtbl = sdl_device_set_feature_report, };
-static BOOL set_report_from_event(DEVICE_OBJECT *device, SDL_Event *event) +static BOOL set_report_from_event(struct platform_private *device, SDL_Event *event) { - struct platform_private *private; - private = impl_from_DEVICE_OBJECT(device); - if (private->sdl_controller) + struct unix_device *iface = &device->unix_device; + + if (device->sdl_controller) { /* We want mapped events */ return TRUE; @@ -603,9 +622,9 @@ static BOOL set_report_from_event(DEVICE_OBJECT *device, SDL_Event *event) { SDL_JoyButtonEvent *ie = &event->jbutton;
- set_button_value(private, ie->button, ie->state); + set_button_value(device, ie->button, ie->state);
- process_hid_report(device, private->report_buffer, private->buffer_length); + bus_event_queue_input_report(&event_queue, iface, device->report_buffer, device->buffer_length); break; } case SDL_JOYAXISMOTION: @@ -614,8 +633,8 @@ static BOOL set_report_from_event(DEVICE_OBJECT *device, SDL_Event *event)
if (ie->axis < 6) { - set_axis_value(private, ie->axis, ie->value, FALSE); - process_hid_report(device, private->report_buffer, private->buffer_length); + set_axis_value(device, ie->axis, ie->value, FALSE); + bus_event_queue_input_report(&event_queue, iface, device->report_buffer, device->buffer_length); } break; } @@ -623,16 +642,16 @@ static BOOL set_report_from_event(DEVICE_OBJECT *device, SDL_Event *event) { SDL_JoyBallEvent *ie = &event->jball;
- set_ball_value(private, ie->ball, ie->xrel, ie->yrel); - process_hid_report(device, private->report_buffer, private->buffer_length); + set_ball_value(device, ie->ball, ie->xrel, ie->yrel); + bus_event_queue_input_report(&event_queue, iface, device->report_buffer, device->buffer_length); break; } case SDL_JOYHATMOTION: { SDL_JoyHatEvent *ie = &event->jhat;
- set_hat_value(private, ie->hat, ie->value); - process_hid_report(device, private->report_buffer, private->buffer_length); + set_hat_value(device, ie->hat, ie->value); + bus_event_queue_input_report(&event_queue, iface, device->report_buffer, device->buffer_length); break; } default: @@ -641,10 +660,9 @@ static BOOL set_report_from_event(DEVICE_OBJECT *device, SDL_Event *event) return FALSE; }
-static BOOL set_mapped_report_from_event(DEVICE_OBJECT *device, SDL_Event *event) +static BOOL set_mapped_report_from_event(struct platform_private *device, SDL_Event *event) { - struct platform_private *private; - private = impl_from_DEVICE_OBJECT(device); + struct unix_device *iface = &device->unix_device;
switch(event->type) { @@ -672,8 +690,8 @@ static BOOL set_mapped_report_from_event(DEVICE_OBJECT *device, SDL_Event *event case SDL_CONTROLLER_BUTTON_DPAD_DOWN: case SDL_CONTROLLER_BUTTON_DPAD_LEFT: case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: - set_hat_value(private, 0, compose_dpad_value(private->sdl_controller)); - process_hid_report(device, private->report_buffer, private->buffer_length); + set_hat_value(device, 0, compose_dpad_value(device->sdl_controller)); + bus_event_queue_input_report(&event_queue, iface, device->report_buffer, device->buffer_length); break;
default: @@ -682,8 +700,8 @@ static BOOL set_mapped_report_from_event(DEVICE_OBJECT *device, SDL_Event *event
if (usage >= 0) { - set_button_value(private, usage, ie->state); - process_hid_report(device, private->report_buffer, private->buffer_length); + set_button_value(device, usage, ie->state); + bus_event_queue_input_report(&event_queue, iface, device->report_buffer, device->buffer_length); } break; } @@ -691,8 +709,8 @@ static BOOL set_mapped_report_from_event(DEVICE_OBJECT *device, SDL_Event *event { SDL_ControllerAxisEvent *ie = &event->caxis;
- set_axis_value(private, ie->axis, ie->value, TRUE); - process_hid_report(device, private->report_buffer, private->buffer_length); + set_axis_value(device, ie->axis, ie->value, TRUE); + bus_event_queue_input_report(&event_queue, iface, device->report_buffer, device->buffer_length); break; } default: @@ -759,6 +777,7 @@ static void sdl_add_device(unsigned int index) TRACE("%s id %d, desc %s.\n", controller ? "controller" : "joystick", id, debugstr_device_desc(&desc));
if (!(private = unix_device_create(&sdl_device_vtbl, sizeof(struct platform_private)))) return; + list_add_tail(&device_list, &private->unix_device.entry); private->sdl_joystick = joystick; private->sdl_controller = controller; private->id = id; @@ -768,11 +787,13 @@ static void sdl_add_device(unsigned int index)
static void process_device_event(SDL_Event *event) { - DEVICE_OBJECT *device; + struct platform_private *device; SDL_JoystickID id;
TRACE_(hid_report)("Received action %x\n", event->type);
+ EnterCriticalSection(&sdl_cs); + if (event->type == SDL_JOYDEVICEADDED) sdl_add_device(((SDL_JoyDeviceEvent *)event)->which); else if (event->type == SDL_JOYDEVICEREMOVED) @@ -783,17 +804,19 @@ static void process_device_event(SDL_Event *event) else if (event->type >= SDL_JOYAXISMOTION && event->type <= SDL_JOYBUTTONUP) { id = ((SDL_JoyButtonEvent *)event)->which; - device = bus_find_hid_device(sdl_busidW, ULongToPtr(id)); + device = find_device_from_id(id); if (device) set_report_from_event(device, event); else WARN("failed to find device with id %d\n", id); } else if (event->type >= SDL_CONTROLLERAXISMOTION && event->type <= SDL_CONTROLLERBUTTONUP) { id = ((SDL_ControllerButtonEvent *)event)->which; - device = bus_find_hid_device(sdl_busidW, ULongToPtr(id)); + device = find_device_from_id(id); if (device) set_mapped_report_from_event(device, event); else WARN("failed to find device with id %d\n", id); } + + LeaveCriticalSection(&sdl_cs); }
static void sdl_load_mappings(void) @@ -938,6 +961,9 @@ NTSTATUS sdl_bus_wait(void *args) struct bus_event *result = args; SDL_Event event;
+ /* cleanup previously returned event */ + bus_event_cleanup(result); + do { if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 72e1f7ded5d..87526fc2129 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -393,6 +393,25 @@ DEVICE_OBJECT *bus_find_hid_device(const WCHAR *bus_id, void *platform_dev) return ret; }
+static DEVICE_OBJECT *bus_find_unix_device(struct unix_device *unix_device) +{ + struct device_extension *ext; + DEVICE_OBJECT *ret = NULL; + + EnterCriticalSection(&device_list_cs); + LIST_FOR_EACH_ENTRY(ext, &device_list, struct device_extension, entry) + { + if (ext->unix_device == unix_device) + { + ret = ext->device; + break; + } + } + LeaveCriticalSection(&device_list_cs); + + return ret; +} + static void bus_unlink_hid_device(DEVICE_OBJECT *device) { struct device_extension *ext = (struct device_extension *)device->DeviceExtension; @@ -635,6 +654,13 @@ static DWORD CALLBACK bus_main_thread(void *args) winebus_call(device_remove, event->device_created.device); } break; + case BUS_EVENT_TYPE_INPUT_REPORT: + EnterCriticalSection(&device_list_cs); + device = bus_find_unix_device(event->input_report.device); + if (!device) WARN("could not find device for %s bus device %p\n", debugstr_w(bus.name), event->input_report.device); + else process_hid_report(device, event->input_report.buffer, event->input_report.length); + LeaveCriticalSection(&device_list_cs); + break; } }
@@ -646,7 +672,7 @@ static DWORD CALLBACK bus_main_thread(void *args)
static NTSTATUS bus_main_thread_start(struct bus_main_params *bus) { - DWORD i = bus_count++; + DWORD i = bus_count++, max_size;
if (!(bus->init_done = CreateEventW(NULL, FALSE, FALSE, NULL))) { @@ -655,7 +681,8 @@ static NTSTATUS bus_main_thread_start(struct bus_main_params *bus) return STATUS_UNSUCCESSFUL; }
- if (!(bus->bus_event = HeapAlloc(GetProcessHeap(), 0, sizeof(struct bus_event)))) + max_size = offsetof(struct bus_event, input_report.buffer[0x10000]); + if (!(bus->bus_event = HeapAlloc(GetProcessHeap(), 0, max_size))) { ERR("failed to allocate %s bus event.\n", debugstr_w(bus->name)); CloseHandle(bus->init_done); diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index 6234c2c7bbc..611873db17f 100644 --- a/dlls/winebus.sys/unix_private.h +++ b/dlls/winebus.sys/unix_private.h @@ -45,6 +45,7 @@ struct unix_device { const struct unix_device_vtbl *vtbl; struct list entry; + LONG ref; };
extern void *unix_device_create(const struct unix_device_vtbl *vtbl, SIZE_T size) DECLSPEC_HIDDEN; @@ -61,9 +62,12 @@ extern NTSTATUS iohid_bus_init(void *) DECLSPEC_HIDDEN; extern NTSTATUS iohid_bus_wait(void *) DECLSPEC_HIDDEN; extern NTSTATUS iohid_bus_stop(void *) DECLSPEC_HIDDEN;
+extern void bus_event_cleanup(struct bus_event *event) DECLSPEC_HIDDEN; extern void bus_event_queue_destroy(struct list *queue) DECLSPEC_HIDDEN; extern BOOL bus_event_queue_device_removed(struct list *queue, const WCHAR *bus_id, void *context) DECLSPEC_HIDDEN; extern BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *device, struct device_desc *desc) DECLSPEC_HIDDEN; +extern BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device, + BYTE *report, USHORT length) DECLSPEC_HIDDEN; extern BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) DECLSPEC_HIDDEN;
struct hid_descriptor diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index ade38c19854..b91de06e73c 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -248,16 +248,30 @@ void *unix_device_create(const struct unix_device_vtbl *vtbl, SIZE_T size)
if (!(iface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size))) return NULL; iface->vtbl = vtbl; + iface->ref = 1;
return iface; }
+static void unix_device_decref(struct unix_device *iface) +{ + if (!InterlockedDecrement(&iface->ref)) + { + iface->vtbl->destroy(iface); + HeapFree(GetProcessHeap(), 0, iface); + } +} + +static ULONG unix_device_incref(struct unix_device *iface) +{ + return InterlockedIncrement(&iface->ref); +} + static NTSTATUS unix_device_remove(void *args) { struct unix_device *iface = args; iface->vtbl->stop(iface); - iface->vtbl->destroy(iface); - HeapFree(GetProcessHeap(), 0, iface); + unix_device_decref(iface); return STATUS_SUCCESS; }
@@ -328,12 +342,21 @@ const unixlib_entry_t __wine_unix_call_funcs[] = unix_device_set_feature_report, };
+void bus_event_cleanup(struct bus_event *event) +{ + if (event->type == BUS_EVENT_TYPE_INPUT_REPORT) + unix_device_decref(event->input_report.device); +} + void bus_event_queue_destroy(struct list *queue) { struct bus_event *event, *next;
LIST_FOR_EACH_ENTRY_SAFE(event, next, queue, struct bus_event, entry) + { + bus_event_cleanup(event); HeapFree(GetProcessHeap(), 0, event); + } }
BOOL bus_event_queue_device_removed(struct list *queue, const WCHAR *bus_id, void *context) @@ -364,17 +387,38 @@ BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *devi return TRUE; }
+BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device, BYTE *report, USHORT length) +{ + ULONG size = offsetof(struct bus_event, input_report.buffer[length]); + struct bus_event *event = HeapAlloc(GetProcessHeap(), 0, size); + if (!event) return FALSE; + + if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */ + + event->type = BUS_EVENT_TYPE_INPUT_REPORT; + event->input_report.device = device; + event->input_report.length = length; + memcpy(event->input_report.buffer, report, length); + list_add_tail(queue, &event->entry); + + return TRUE; +} + BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) { struct list *entry = list_head(queue); struct bus_event *tmp; + ULONG size;
if (!entry) return FALSE;
tmp = LIST_ENTRY(entry, struct bus_event, entry); list_remove(entry);
- memcpy(event, tmp, sizeof(*event)); + if (event->type != BUS_EVENT_TYPE_INPUT_REPORT) size = sizeof(*event); + else size = offsetof(struct bus_event, input_report.buffer[event->input_report.length]); + + memcpy(event, tmp, size); HeapFree(GetProcessHeap(), 0, tmp);
return TRUE; diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h index 12df5d8bd5b..47256e80740 100644 --- a/dlls/winebus.sys/unixlib.h +++ b/dlls/winebus.sys/unixlib.h @@ -69,6 +69,7 @@ enum bus_event_type BUS_EVENT_TYPE_NONE, BUS_EVENT_TYPE_DEVICE_REMOVED, BUS_EVENT_TYPE_DEVICE_CREATED, + BUS_EVENT_TYPE_INPUT_REPORT, };
struct bus_event @@ -89,6 +90,13 @@ struct bus_event struct unix_device *device; struct device_desc desc; } device_created; + + struct + { + struct unix_device *device; + USHORT length; + BYTE buffer[1]; + } input_report; }; };
Instead of calling process_hid_report.
We need to guard the event queue as the input reports are read from dedicated threads.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_udev.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index e26e11c720d..45c5b2e151a 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -648,6 +648,7 @@ static DWORD CALLBACK device_report_thread(void *args) { DEVICE_OBJECT *device = (DEVICE_OBJECT*)args; struct platform_private *private = impl_from_DEVICE_OBJECT(device); + struct unix_device *iface = &private->unix_device; struct pollfd plfds[2];
plfds[0].fd = private->device_fd; @@ -671,7 +672,11 @@ static DWORD CALLBACK device_report_thread(void *args) else if (size == 0) TRACE_(hid_report)("Failed to read report\n"); else - process_hid_report(device, report_buffer, size); + { + EnterCriticalSection(&udev_cs); + bus_event_queue_input_report(&event_queue, iface, report_buffer, size); + LeaveCriticalSection(&udev_cs); + } } return 0; } @@ -876,6 +881,7 @@ static DWORD CALLBACK lnxev_device_report_thread(void *args) { DEVICE_OBJECT *device = (DEVICE_OBJECT*)args; struct wine_input_private *private = input_impl_from_DEVICE_OBJECT(device); + struct unix_device *iface = &private->base.unix_device; struct pollfd plfds[2];
plfds[0].fd = private->base.device_fd; @@ -899,7 +905,11 @@ static DWORD CALLBACK lnxev_device_report_thread(void *args) else if (size == 0) TRACE_(hid_report)("Failed to read report\n"); else if (set_report_from_event(private, &ie)) - process_hid_report(device, private->current_report_buffer, private->buffer_length); + { + EnterCriticalSection(&udev_cs); + bus_event_queue_input_report(&event_queue, iface, private->current_report_buffer, private->buffer_length); + LeaveCriticalSection(&udev_cs); + } } return 0; } @@ -1276,16 +1286,27 @@ NTSTATUS udev_bus_wait(void *args) pfd[1].events = POLLIN; pfd[1].revents = 0;
+ /* cleanup previously returned event */ + bus_event_cleanup(result); + while (1) { - if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; + EnterCriticalSection(&udev_cs); + if (bus_event_queue_pop(&event_queue, result)) + { + LeaveCriticalSection(&udev_cs); + return STATUS_PENDING; + } + LeaveCriticalSection(&udev_cs); if (poll(pfd, 2, -1) <= 0) continue; if (pfd[1].revents) break; process_monitor_event(udev_monitor); }
TRACE("UDEV main loop exiting\n"); + EnterCriticalSection(&udev_cs); bus_event_queue_destroy(&event_queue); + LeaveCriticalSection(&udev_cs); udev_monitor_unref(udev_monitor); udev_unref(udev_context); udev_context = NULL;
Instead of calling process_hid_report.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 4 ---- dlls/winebus.sys/bus_iohid.c | 9 ++++++--- dlls/winebus.sys/main.c | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 75ff218c26d..67215019dfc 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -29,10 +29,6 @@
struct unix_device *get_unix_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
-/* HID Plug and Play Bus */ -DEVICE_OBJECT *bus_find_hid_device(const WCHAR *bus_id, void *platform_dev) DECLSPEC_HIDDEN; -void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) DECLSPEC_HIDDEN; - /* General Bus Functions */ BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index d9de7059be3..c16c780bc76 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -133,8 +133,8 @@ static void handle_IOHIDDeviceIOHIDReportCallback(void *context, IOReturn result, void *sender, IOHIDReportType type, uint32_t reportID, uint8_t *report, CFIndex report_length) { - DEVICE_OBJECT *device = (DEVICE_OBJECT*)context; - process_hid_report(device, report, report_length); + struct unix_device *iface = (struct unix_device *)context; + bus_event_queue_input_report(&event_queue, iface, report, report_length); }
static void iohid_device_destroy(struct unix_device *iface) @@ -161,7 +161,7 @@ static NTSTATUS iohid_device_start(struct unix_device *iface, DEVICE_OBJECT *dev length = CFNumberToDWORD(num); private->buffer = HeapAlloc(GetProcessHeap(), 0, length);
- IOHIDDeviceRegisterInputReportCallback(private->device, private->buffer, length, handle_IOHIDDeviceIOHIDReportCallback, device); + IOHIDDeviceRegisterInputReportCallback(private->device, private->buffer, length, handle_IOHIDDeviceIOHIDReportCallback, iface); return STATUS_SUCCESS; }
@@ -378,6 +378,9 @@ NTSTATUS iohid_bus_wait(void *args) { struct bus_event *result = args;
+ /* cleanup previously returned event */ + bus_event_cleanup(result); + do { if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 87526fc2129..ce548980640 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -370,7 +370,7 @@ static DEVICE_OBJECT *bus_create_hid_device(struct device_desc *desc, struct uni return device; }
-DEVICE_OBJECT *bus_find_hid_device(const WCHAR *bus_id, void *platform_dev) +static DEVICE_OBJECT *bus_find_hid_device(const WCHAR *bus_id, void *platform_dev) { struct device_extension *ext; DEVICE_OBJECT *ret = NULL; @@ -477,7 +477,7 @@ static NTSTATUS deliver_last_report(struct device_extension *ext, DWORD buffer_l } }
-void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) +static void process_hid_report(DEVICE_OBJECT *device, BYTE *report, DWORD length) { struct device_extension *ext = (struct device_extension*)device->DeviceExtension; IRP *irp;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_udev.c | 285 ++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 161 deletions(-)
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 45c5b2e151a..b94af8db71c 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -100,7 +100,6 @@ static CRITICAL_SECTION udev_cs = { &udev_cs_debug, -1, 0, 0, 0, 0 }; static struct udev *udev_context = NULL; static struct udev_monitor *udev_monitor; static int deviceloop_control[2]; -static int udev_monitor_fd; static struct list event_queue = LIST_INIT(event_queue); static struct list device_list = LIST_INIT(device_list);
@@ -111,12 +110,10 @@ static struct udev_bus_options options; struct platform_private { struct unix_device unix_device; + void (*read_report)(struct unix_device *iface);
struct udev_device *udev_device; int device_fd; - - HANDLE report_thread; - int control_pipe[2]; };
static inline struct platform_private *impl_from_unix_device(struct unix_device *iface) @@ -124,9 +121,60 @@ static inline struct platform_private *impl_from_unix_device(struct unix_device return CONTAINING_RECORD(iface, struct platform_private, unix_device); }
-static inline struct platform_private *impl_from_DEVICE_OBJECT(DEVICE_OBJECT *device) +#define MAX_DEVICES 128 +static int close_fds[MAX_DEVICES]; +static struct pollfd poll_fds[MAX_DEVICES]; +static struct platform_private *poll_devs[MAX_DEVICES]; +static int close_count, poll_count; + +static void stop_polling_device(struct unix_device *iface) { - return impl_from_unix_device(get_unix_device(device)); + struct platform_private *private = impl_from_unix_device(iface); + int i; + + if (private->device_fd == -1) return; /* already removed */ + + for (i = 2; i < poll_count; ++i) + if (poll_fds[i].fd == private->device_fd) break; + + if (i == poll_count) + ERR("could not find poll entry matching device %p fd\n", iface); + else + { + poll_count--; + poll_fds[i] = poll_fds[poll_count]; + poll_devs[i] = poll_devs[poll_count]; + close_fds[close_count++] = private->device_fd; + private->device_fd = -1; + } +} + +static void start_polling_device(struct unix_device *iface) +{ + struct platform_private *private = impl_from_unix_device(iface); + + if (poll_count >= ARRAY_SIZE(poll_fds)) + ERR("could not start polling device %p, too many fds\n", iface); + else + { + poll_devs[poll_count] = private; + poll_fds[poll_count].fd = private->device_fd; + poll_fds[poll_count].events = POLLIN; + poll_fds[poll_count].revents = 0; + poll_count++; + + write(deviceloop_control[1], "u", 1); + } +} + +static struct platform_private *find_device_from_fd(int fd) +{ + int i; + + for (i = 2; i < poll_count; ++i) if (poll_fds[i].fd == fd) break; + if (i < poll_count) return poll_devs[i]; + + return NULL; }
static const char *get_device_syspath(struct udev_device *dev) @@ -558,7 +606,6 @@ static void hidraw_device_destroy(struct unix_device *iface) { struct platform_private *private = impl_from_unix_device(iface);
- close(private->device_fd); udev_device_unref(private->udev_device); }
@@ -569,27 +616,11 @@ static int udev_device_compare(struct unix_device *iface, void *platform_dev) return strcmp(udev_device_get_syspath(dev1), udev_device_get_syspath(dev2)); }
-static DWORD CALLBACK device_report_thread(void *args); - static NTSTATUS hidraw_device_start(struct unix_device *iface, DEVICE_OBJECT *device) { - struct platform_private *private = impl_from_unix_device(iface); - - if (pipe(private->control_pipe) != 0) - { - ERR("Control pipe creation failed\n"); - return STATUS_UNSUCCESSFUL; - } - - private->report_thread = CreateThread(NULL, 0, device_report_thread, device, 0, NULL); - if (!private->report_thread) - { - ERR("Unable to create device report thread\n"); - close(private->control_pipe[0]); - close(private->control_pipe[1]); - return STATUS_UNSUCCESSFUL; - } - + EnterCriticalSection(&udev_cs); + start_polling_device(iface); + LeaveCriticalSection(&udev_cs); return STATUS_SUCCESS; }
@@ -598,17 +629,9 @@ static void hidraw_device_stop(struct unix_device *iface) struct platform_private *private = impl_from_unix_device(iface);
EnterCriticalSection(&udev_cs); + stop_polling_device(iface); list_remove(&private->unix_device.entry); LeaveCriticalSection(&udev_cs); - - if (private->report_thread) - { - write(private->control_pipe[1], "q", 1); - WaitForSingleObject(private->report_thread, INFINITE); - close(private->control_pipe[0]); - close(private->control_pipe[1]); - CloseHandle(private->report_thread); - } }
static NTSTATUS hidraw_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, @@ -644,41 +667,18 @@ static NTSTATUS hidraw_device_get_report_descriptor(struct unix_device *iface, B #endif }
-static DWORD CALLBACK device_report_thread(void *args) +static void hidraw_device_read_report(struct unix_device *iface) { - DEVICE_OBJECT *device = (DEVICE_OBJECT*)args; - struct platform_private *private = impl_from_DEVICE_OBJECT(device); - struct unix_device *iface = &private->unix_device; - struct pollfd plfds[2]; - - plfds[0].fd = private->device_fd; - plfds[0].events = POLLIN; - plfds[0].revents = 0; - plfds[1].fd = private->control_pipe[0]; - plfds[1].events = POLLIN; - plfds[1].revents = 0; - - while (1) - { - int size; - BYTE report_buffer[1024]; - - if (poll(plfds, 2, -1) <= 0) continue; - if (plfds[1].revents) - break; - size = read(plfds[0].fd, report_buffer, sizeof(report_buffer)); - if (size == -1) - TRACE_(hid_report)("Read failed. Likely an unplugged device %d %s\n", errno, strerror(errno)); - else if (size == 0) - TRACE_(hid_report)("Failed to read report\n"); - else - { - EnterCriticalSection(&udev_cs); - bus_event_queue_input_report(&event_queue, iface, report_buffer, size); - LeaveCriticalSection(&udev_cs); - } - } - return 0; + struct platform_private* private = impl_from_unix_device(iface); + BYTE report_buffer[1024]; + + int size = read(private->device_fd, report_buffer, sizeof(report_buffer)); + if (size == -1) + TRACE_(hid_report)("Read failed. Likely an unplugged device %d %s\n", errno, strerror(errno)); + else if (size == 0) + TRACE_(hid_report)("Failed to read report\n"); + else + bus_event_queue_input_report(&event_queue, iface, report_buffer, size); }
static void hidraw_device_set_output_report(struct unix_device *iface, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) @@ -802,11 +802,6 @@ static inline struct wine_input_private *input_impl_from_unix_device(struct unix return CONTAINING_RECORD(impl_from_unix_device(iface), struct wine_input_private, base); }
-static inline struct wine_input_private *input_impl_from_DEVICE_OBJECT(DEVICE_OBJECT *device) -{ - return CONTAINING_RECORD(impl_from_DEVICE_OBJECT(device), struct wine_input_private, base); -} - static void lnxev_device_destroy(struct unix_device *iface) { struct wine_input_private *ext = input_impl_from_unix_device(iface); @@ -815,12 +810,9 @@ static void lnxev_device_destroy(struct unix_device *iface) HeapFree(GetProcessHeap(), 0, ext->last_report_buffer); hid_descriptor_free(&ext->desc);
- close(ext->base.device_fd); udev_device_unref(ext->base.udev_device); }
-static DWORD CALLBACK lnxev_device_report_thread(void *args); - static NTSTATUS lnxev_device_start(struct unix_device *iface, DEVICE_OBJECT *device) { struct wine_input_private *ext = input_impl_from_unix_device(iface); @@ -829,21 +821,9 @@ static NTSTATUS lnxev_device_start(struct unix_device *iface, DEVICE_OBJECT *dev if ((status = build_report_descriptor(ext, ext->base.udev_device))) return status;
- if (pipe(ext->base.control_pipe) != 0) - { - ERR("Control pipe creation failed\n"); - return STATUS_UNSUCCESSFUL; - } - - ext->base.report_thread = CreateThread(NULL, 0, lnxev_device_report_thread, device, 0, NULL); - if (!ext->base.report_thread) - { - ERR("Unable to create device report thread\n"); - close(ext->base.control_pipe[0]); - close(ext->base.control_pipe[1]); - return STATUS_UNSUCCESSFUL; - } - + EnterCriticalSection(&udev_cs); + start_polling_device(iface); + LeaveCriticalSection(&udev_cs); return STATUS_SUCCESS; }
@@ -852,17 +832,9 @@ static void lnxev_device_stop(struct unix_device *iface) struct wine_input_private *ext = input_impl_from_unix_device(iface);
EnterCriticalSection(&udev_cs); + stop_polling_device(iface); list_remove(&ext->base.unix_device.entry); LeaveCriticalSection(&udev_cs); - - if (ext->base.report_thread) - { - write(ext->base.control_pipe[1], "q", 1); - WaitForSingleObject(ext->base.report_thread, INFINITE); - close(ext->base.control_pipe[0]); - close(ext->base.control_pipe[1]); - CloseHandle(ext->base.report_thread); - } }
static NTSTATUS lnxev_device_get_report_descriptor(struct unix_device *iface, BYTE *buffer, @@ -877,41 +849,22 @@ static NTSTATUS lnxev_device_get_report_descriptor(struct unix_device *iface, BY return STATUS_SUCCESS; }
-static DWORD CALLBACK lnxev_device_report_thread(void *args) +static void lnxev_device_read_report(struct unix_device *iface) { - DEVICE_OBJECT *device = (DEVICE_OBJECT*)args; - struct wine_input_private *private = input_impl_from_DEVICE_OBJECT(device); - struct unix_device *iface = &private->base.unix_device; - struct pollfd plfds[2]; - - plfds[0].fd = private->base.device_fd; - plfds[0].events = POLLIN; - plfds[0].revents = 0; - plfds[1].fd = private->base.control_pipe[0]; - plfds[1].events = POLLIN; - plfds[1].revents = 0; - - while (1) - { - int size; - struct input_event ie; - - if (poll(plfds, 2, -1) <= 0) continue; - if (plfds[1].revents || !private->current_report_buffer || private->buffer_length == 0) - break; - size = read(plfds[0].fd, &ie, sizeof(ie)); - if (size == -1) - TRACE_(hid_report)("Read failed. Likely an unplugged device\n"); - else if (size == 0) - TRACE_(hid_report)("Failed to read report\n"); - else if (set_report_from_event(private, &ie)) - { - EnterCriticalSection(&udev_cs); - bus_event_queue_input_report(&event_queue, iface, private->current_report_buffer, private->buffer_length); - LeaveCriticalSection(&udev_cs); - } - } - return 0; + struct wine_input_private *private = input_impl_from_unix_device(iface); + struct input_event ie; + int size; + + if (!private->current_report_buffer || private->buffer_length == 0) + return; + + size = read(private->base.device_fd, &ie, sizeof(ie)); + if (size == -1) + TRACE_(hid_report)("Read failed. Likely an unplugged device\n"); + else if (size == 0) + TRACE_(hid_report)("Failed to read report\n"); + else if (set_report_from_event(private, &ie)) + bus_event_queue_input_report(&event_queue, iface, private->current_report_buffer, private->buffer_length); }
static void lnxev_device_set_output_report(struct unix_device *iface, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) @@ -1020,10 +973,7 @@ static void udev_add_device(struct udev_device *dev) TRACE("udev %s syspath %s\n", debugstr_a(devnode), udev_device_get_syspath(dev));
#ifdef HAS_PROPER_INPUT_HEADER - EnterCriticalSection(&udev_cs); - private = find_device_from_syspath(get_device_syspath(dev)); - LeaveCriticalSection(&udev_cs); - if (private) + if ((private = find_device_from_syspath(get_device_syspath(dev)))) { TRACE("duplicate device found, not adding the new one\n"); close(fd); @@ -1091,9 +1041,8 @@ static void udev_add_device(struct udev_device *dev) if (strcmp(subsystem, "hidraw") == 0) { if (!(private = unix_device_create(&hidraw_device_vtbl, sizeof(struct platform_private)))) return; - EnterCriticalSection(&udev_cs); list_add_tail(&device_list, &private->unix_device.entry); - LeaveCriticalSection(&udev_cs); + private->read_report = hidraw_device_read_report; private->udev_device = udev_device_ref(dev); private->device_fd = fd;
@@ -1103,9 +1052,8 @@ static void udev_add_device(struct udev_device *dev) else if (strcmp(subsystem, "input") == 0) { if (!(private = unix_device_create(&lnxev_device_vtbl, sizeof(struct wine_input_private)))) return; - EnterCriticalSection(&udev_cs); list_add_tail(&device_list, &private->unix_device.entry); - LeaveCriticalSection(&udev_cs); + private->read_report = lnxev_device_read_report; private->udev_device = udev_device_ref(dev); private->device_fd = fd;
@@ -1241,6 +1189,8 @@ static void process_monitor_event(struct udev_monitor *monitor)
NTSTATUS udev_bus_init(void *args) { + int monitor_fd; + TRACE("args %p\n", args);
options = *(struct udev_bus_options *)args; @@ -1257,12 +1207,20 @@ NTSTATUS udev_bus_init(void *args) goto error; }
- if (!(udev_monitor = create_monitor(&udev_monitor_fd))) + if (!(udev_monitor = create_monitor(&monitor_fd))) { ERR("UDEV monitor creation failed\n"); goto error; }
+ poll_fds[0].fd = monitor_fd; + poll_fds[0].events = POLLIN; + poll_fds[0].revents = 0; + poll_fds[1].fd = deviceloop_control[0]; + poll_fds[1].events = POLLIN; + poll_fds[1].revents = 0; + poll_count = 2; + build_initial_deviceset(); return STATUS_SUCCESS;
@@ -1276,37 +1234,42 @@ error:
NTSTATUS udev_bus_wait(void *args) { + struct platform_private *device; struct bus_event *result = args; - struct pollfd pfd[2]; - - pfd[0].fd = udev_monitor_fd; - pfd[0].events = POLLIN; - pfd[0].revents = 0; - pfd[1].fd = deviceloop_control[0]; - pfd[1].events = POLLIN; - pfd[1].revents = 0; + struct pollfd pfd[MAX_DEVICES]; + char ctrl = 0; + int i, count;
/* cleanup previously returned event */ bus_event_cleanup(result);
- while (1) + while (ctrl != 'q') { + if (bus_event_queue_pop(&event_queue, result)) return STATUS_PENDING; + EnterCriticalSection(&udev_cs); - if (bus_event_queue_pop(&event_queue, result)) + while (close_count--) close(close_fds[close_count]); + memcpy(pfd, poll_fds, poll_count * sizeof(*pfd)); + count = poll_count; + close_count = 0; + LeaveCriticalSection(&udev_cs); + + while (poll(pfd, count, -1) <= 0) {} + + EnterCriticalSection(&udev_cs); + if (pfd[0].revents) process_monitor_event(udev_monitor); + if (pfd[1].revents) read(deviceloop_control[0], &ctrl, 1); + for (i = 2; i < count; ++i) { - LeaveCriticalSection(&udev_cs); - return STATUS_PENDING; + if (!pfd[i].revents) continue; + device = find_device_from_fd(pfd[i].fd); + if (device) device->read_report(&device->unix_device); } LeaveCriticalSection(&udev_cs); - if (poll(pfd, 2, -1) <= 0) continue; - if (pfd[1].revents) break; - process_monitor_event(udev_monitor); }
TRACE("UDEV main loop exiting\n"); - EnterCriticalSection(&udev_cs); bus_event_queue_destroy(&event_queue); - LeaveCriticalSection(&udev_cs); udev_monitor_unref(udev_monitor); udev_unref(udev_context); udev_context = NULL;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 2 -- dlls/winebus.sys/main.c | 6 ------ 2 files changed, 8 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 67215019dfc..df53508d2c0 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -27,8 +27,6 @@
#include "unixlib.h"
-struct unix_device *get_unix_device(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; - /* General Bus Functions */ BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index ce548980640..3e63a84adcc 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -217,12 +217,6 @@ static void unix_device_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKE winebus_call(device_set_feature_report, ¶ms); }
-struct unix_device *get_unix_device(DEVICE_OBJECT *device) -{ - struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - return ext->unix_device; -} - static DWORD get_device_index(struct device_desc *desc) { struct device_extension *ext;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus_iohid.c | 2 +- dlls/winebus.sys/bus_sdl.c | 2 +- dlls/winebus.sys/bus_udev.c | 4 ++-- dlls/winebus.sys/main.c | 7 +------ dlls/winebus.sys/unix_private.h | 2 +- dlls/winebus.sys/unixlib.c | 9 ++++----- dlls/winebus.sys/unixlib.h | 7 ------- 7 files changed, 10 insertions(+), 23 deletions(-)
diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index c16c780bc76..8bdd7857ae6 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -151,7 +151,7 @@ static int iohid_device_compare(struct unix_device *iface, void *context) return 0; }
-static NTSTATUS iohid_device_start(struct unix_device *iface, DEVICE_OBJECT *device) +static NTSTATUS iohid_device_start(struct unix_device *iface) { DWORD length; struct platform_private *private = impl_from_unix_device(iface); diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 6eafcb75285..6a6f364edf6 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -502,7 +502,7 @@ static int sdl_device_compare(struct unix_device *iface, void *context) return impl_from_unix_device(iface)->id - PtrToUlong(context); }
-static NTSTATUS sdl_device_start(struct unix_device *iface, DEVICE_OBJECT *device) +static NTSTATUS sdl_device_start(struct unix_device *iface) { struct platform_private *ext = impl_from_unix_device(iface); if (ext->sdl_controller) return build_mapped_report_descriptor(ext); diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index b94af8db71c..23b649ff511 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -616,7 +616,7 @@ static int udev_device_compare(struct unix_device *iface, void *platform_dev) return strcmp(udev_device_get_syspath(dev1), udev_device_get_syspath(dev2)); }
-static NTSTATUS hidraw_device_start(struct unix_device *iface, DEVICE_OBJECT *device) +static NTSTATUS hidraw_device_start(struct unix_device *iface) { EnterCriticalSection(&udev_cs); start_polling_device(iface); @@ -813,7 +813,7 @@ static void lnxev_device_destroy(struct unix_device *iface) udev_device_unref(ext->base.udev_device); }
-static NTSTATUS lnxev_device_start(struct unix_device *iface, DEVICE_OBJECT *device) +static NTSTATUS lnxev_device_start(struct unix_device *iface) { struct wine_input_private *ext = input_impl_from_unix_device(iface); NTSTATUS status; diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 3e63a84adcc..162787c4e4a 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -160,12 +160,7 @@ static int unix_device_compare(DEVICE_OBJECT *device, void *context) static NTSTATUS unix_device_start(DEVICE_OBJECT *device) { struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - struct device_start_params params = - { - .iface = ext->unix_device, - .device = device - }; - return winebus_call(device_start, ¶ms); + return winebus_call(device_start, ext->unix_device); }
static NTSTATUS unix_device_get_report_descriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length) diff --git a/dlls/winebus.sys/unix_private.h b/dlls/winebus.sys/unix_private.h index 611873db17f..3f8d73d033a 100644 --- a/dlls/winebus.sys/unix_private.h +++ b/dlls/winebus.sys/unix_private.h @@ -33,7 +33,7 @@ struct unix_device_vtbl { void (*destroy)(struct unix_device *iface); int (*compare)(struct unix_device *iface, void *platform_dev); - NTSTATUS (*start)(struct unix_device *iface, DEVICE_OBJECT *device); + NTSTATUS (*start)(struct unix_device *iface); void (*stop)(struct unix_device *iface); NTSTATUS (*get_report_descriptor)(struct unix_device *iface, BYTE *buffer, DWORD length, DWORD *out_length); void (*set_output_report)(struct unix_device *iface, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io); diff --git a/dlls/winebus.sys/unixlib.c b/dlls/winebus.sys/unixlib.c index b91de06e73c..87cc7de3474 100644 --- a/dlls/winebus.sys/unixlib.c +++ b/dlls/winebus.sys/unixlib.c @@ -56,7 +56,7 @@ static int mouse_compare(struct unix_device *iface, void *context) return 0; }
-static NTSTATUS mouse_start(struct unix_device *iface, DEVICE_OBJECT *device) +static NTSTATUS mouse_start(struct unix_device *iface) { struct mouse_device *impl = mouse_from_unix_device(iface);
@@ -160,7 +160,7 @@ static int keyboard_compare(struct unix_device *iface, void *context) return 0; }
-static NTSTATUS keyboard_start(struct unix_device *iface, DEVICE_OBJECT *device) +static NTSTATUS keyboard_start(struct unix_device *iface) { struct keyboard_device *impl = keyboard_from_unix_device(iface);
@@ -284,9 +284,8 @@ static NTSTATUS unix_device_compare(void *args)
static NTSTATUS unix_device_start(void *args) { - struct device_start_params *params = args; - struct unix_device *iface = params->iface; - return iface->vtbl->start(iface, params->device); + struct unix_device *iface = args; + return iface->vtbl->start(iface); }
static NTSTATUS unix_device_get_report_descriptor(void *args) diff --git a/dlls/winebus.sys/unixlib.h b/dlls/winebus.sys/unixlib.h index 47256e80740..61684d0c0af 100644 --- a/dlls/winebus.sys/unixlib.h +++ b/dlls/winebus.sys/unixlib.h @@ -24,7 +24,6 @@ #include <windef.h> #include <winbase.h> #include <winternl.h> -#include <ddk/wdm.h> #include <ddk/hidclass.h> #include <hidusage.h>
@@ -112,12 +111,6 @@ struct device_compare_params void *context; };
-struct device_start_params -{ - struct unix_device *iface; - DEVICE_OBJECT *device; -}; - struct device_descriptor_params { struct unix_device *iface;