Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/upstream-linus
[linux-btrfs-devel.git] / drivers / staging / hv / hv_mouse.c
blobd957fc2280196efbe11e5da197b81c70d3bdb7fe
1 /*
2 * Copyright (c) 2009, Citrix Systems, Inc.
3 * Copyright (c) 2010, Microsoft Corporation.
4 * Copyright (c) 2011, Novell Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/delay.h>
18 #include <linux/device.h>
19 #include <linux/workqueue.h>
20 #include <linux/sched.h>
21 #include <linux/wait.h>
22 #include <linux/input.h>
23 #include <linux/hid.h>
24 #include <linux/hiddev.h>
25 #include <linux/pci.h>
26 #include <linux/dmi.h>
28 #include "hyperv.h"
32 * Data types
34 struct hv_input_dev_info {
35 unsigned short vendor;
36 unsigned short product;
37 unsigned short version;
38 char name[128];
41 /* The maximum size of a synthetic input message. */
42 #define SYNTHHID_MAX_INPUT_REPORT_SIZE 16
45 * Current version
47 * History:
48 * Beta, RC < 2008/1/22 1,0
49 * RC > 2008/1/22 2,0
51 #define SYNTHHID_INPUT_VERSION_MAJOR 2
52 #define SYNTHHID_INPUT_VERSION_MINOR 0
53 #define SYNTHHID_INPUT_VERSION (SYNTHHID_INPUT_VERSION_MINOR | \
54 (SYNTHHID_INPUT_VERSION_MAJOR << 16))
57 #pragma pack(push,1)
59 * Message types in the synthetic input protocol
61 enum synthhid_msg_type {
62 SynthHidProtocolRequest,
63 SynthHidProtocolResponse,
64 SynthHidInitialDeviceInfo,
65 SynthHidInitialDeviceInfoAck,
66 SynthHidInputReport,
67 SynthHidMax
71 * Basic message structures.
73 struct synthhid_msg_hdr {
74 enum synthhid_msg_type type;
75 u32 size;
78 struct synthhid_msg {
79 struct synthhid_msg_hdr header;
80 char data[1]; /* Enclosed message */
83 union synthhid_version {
84 struct {
85 u16 minor_version;
86 u16 major_version;
88 u32 version;
92 * Protocol messages
94 struct synthhid_protocol_request {
95 struct synthhid_msg_hdr header;
96 union synthhid_version version_requested;
99 struct synthhid_protocol_response {
100 struct synthhid_msg_hdr header;
101 union synthhid_version version_requested;
102 unsigned char approved;
105 struct synthhid_device_info {
106 struct synthhid_msg_hdr header;
107 struct hv_input_dev_info hid_dev_info;
108 struct hid_descriptor hid_descriptor;
111 struct synthhid_device_info_ack {
112 struct synthhid_msg_hdr header;
113 unsigned char reserved;
116 struct synthhid_input_report {
117 struct synthhid_msg_hdr header;
118 char buffer[1];
121 #pragma pack(pop)
123 #define INPUTVSC_SEND_RING_BUFFER_SIZE 10*PAGE_SIZE
124 #define INPUTVSC_RECV_RING_BUFFER_SIZE 10*PAGE_SIZE
126 #define NBITS(x) (((x)/BITS_PER_LONG)+1)
128 enum pipe_prot_msg_type {
129 PipeMessageInvalid = 0,
130 PipeMessageData,
131 PipeMessageMaximum
135 struct pipe_prt_msg {
136 enum pipe_prot_msg_type type;
137 u32 size;
138 char data[1];
142 * Data types
144 struct mousevsc_prt_msg {
145 enum pipe_prot_msg_type type;
146 u32 size;
147 union {
148 struct synthhid_protocol_request request;
149 struct synthhid_protocol_response response;
150 struct synthhid_device_info_ack ack;
155 * Represents an mousevsc device
157 struct mousevsc_dev {
158 struct hv_device *device;
159 /* 0 indicates the device is being destroyed */
160 atomic_t ref_count;
161 int num_outstanding_req;
162 unsigned char init_complete;
163 struct mousevsc_prt_msg protocol_req;
164 struct mousevsc_prt_msg protocol_resp;
165 /* Synchronize the request/response if needed */
166 wait_queue_head_t protocol_wait_event;
167 wait_queue_head_t dev_info_wait_event;
168 int protocol_wait_condition;
169 int device_wait_condition;
170 int dev_info_status;
172 struct hid_descriptor *hid_desc;
173 unsigned char *report_desc;
174 u32 report_desc_size;
175 struct hv_input_dev_info hid_dev_info;
179 static const char *driver_name = "mousevsc";
181 /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
182 static const struct hv_guid mouse_guid = {
183 .data = {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c,
184 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}
187 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info);
188 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len);
189 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len);
191 static struct mousevsc_dev *alloc_input_device(struct hv_device *device)
193 struct mousevsc_dev *input_dev;
195 input_dev = kzalloc(sizeof(struct mousevsc_dev), GFP_KERNEL);
197 if (!input_dev)
198 return NULL;
201 * Set to 2 to allow both inbound and outbound traffics
202 * (ie get_input_device() and must_get_input_device()) to proceed.
204 atomic_cmpxchg(&input_dev->ref_count, 0, 2);
206 input_dev->device = device;
207 device->ext = input_dev;
209 return input_dev;
212 static void free_input_device(struct mousevsc_dev *device)
214 WARN_ON(atomic_read(&device->ref_count) == 0);
215 kfree(device);
219 * Get the inputdevice object if exists and its refcount > 1
221 static struct mousevsc_dev *get_input_device(struct hv_device *device)
223 struct mousevsc_dev *input_dev;
225 input_dev = (struct mousevsc_dev *)device->ext;
228 * FIXME
229 * This sure isn't a valid thing to print for debugging, no matter
230 * what the intention is...
232 * printk(KERN_ERR "-------------------------> REFCOUNT = %d",
233 * input_dev->ref_count);
236 if (input_dev && atomic_read(&input_dev->ref_count) > 1)
237 atomic_inc(&input_dev->ref_count);
238 else
239 input_dev = NULL;
241 return input_dev;
245 * Get the inputdevice object iff exists and its refcount > 0
247 static struct mousevsc_dev *must_get_input_device(struct hv_device *device)
249 struct mousevsc_dev *input_dev;
251 input_dev = (struct mousevsc_dev *)device->ext;
253 if (input_dev && atomic_read(&input_dev->ref_count))
254 atomic_inc(&input_dev->ref_count);
255 else
256 input_dev = NULL;
258 return input_dev;
261 static void put_input_device(struct hv_device *device)
263 struct mousevsc_dev *input_dev;
265 input_dev = (struct mousevsc_dev *)device->ext;
267 atomic_dec(&input_dev->ref_count);
271 * Drop ref count to 1 to effectively disable get_input_device()
273 static struct mousevsc_dev *release_input_device(struct hv_device *device)
275 struct mousevsc_dev *input_dev;
277 input_dev = (struct mousevsc_dev *)device->ext;
279 /* Busy wait until the ref drop to 2, then set it to 1 */
280 while (atomic_cmpxchg(&input_dev->ref_count, 2, 1) != 2)
281 udelay(100);
283 return input_dev;
287 * Drop ref count to 0. No one can use input_device object.
289 static struct mousevsc_dev *final_release_input_device(struct hv_device *device)
291 struct mousevsc_dev *input_dev;
293 input_dev = (struct mousevsc_dev *)device->ext;
295 /* Busy wait until the ref drop to 1, then set it to 0 */
296 while (atomic_cmpxchg(&input_dev->ref_count, 1, 0) != 1)
297 udelay(100);
299 device->ext = NULL;
300 return input_dev;
303 static void mousevsc_on_send_completion(struct hv_device *device,
304 struct vmpacket_descriptor *packet)
306 struct mousevsc_dev *input_dev;
307 void *request;
309 input_dev = must_get_input_device(device);
310 if (!input_dev) {
311 pr_err("unable to get input device...device being destroyed?");
312 return;
315 request = (void *)(unsigned long)packet->trans_id;
317 if (request == &input_dev->protocol_req) {
318 /* FIXME */
319 /* Shouldn't we be doing something here? */
322 put_input_device(device);
325 static void mousevsc_on_receive_device_info(struct mousevsc_dev *input_device,
326 struct synthhid_device_info *device_info)
328 int ret = 0;
329 struct hid_descriptor *desc;
330 struct mousevsc_prt_msg ack;
332 /* Assume success for now */
333 input_device->dev_info_status = 0;
335 /* Save the device attr */
336 memcpy(&input_device->hid_dev_info, &device_info->hid_dev_info,
337 sizeof(struct hv_input_dev_info));
339 /* Save the hid desc */
340 desc = &device_info->hid_descriptor;
341 WARN_ON(desc->bLength > 0);
343 input_device->hid_desc = kzalloc(desc->bLength, GFP_KERNEL);
345 if (!input_device->hid_desc) {
346 pr_err("unable to allocate hid descriptor - size %d", desc->bLength);
347 goto Cleanup;
350 memcpy(input_device->hid_desc, desc, desc->bLength);
352 /* Save the report desc */
353 input_device->report_desc_size = desc->desc[0].wDescriptorLength;
354 input_device->report_desc = kzalloc(input_device->report_desc_size,
355 GFP_KERNEL);
357 if (!input_device->report_desc) {
358 pr_err("unable to allocate report descriptor - size %d",
359 input_device->report_desc_size);
360 goto Cleanup;
363 memcpy(input_device->report_desc,
364 ((unsigned char *)desc) + desc->bLength,
365 desc->desc[0].wDescriptorLength);
367 /* Send the ack */
368 memset(&ack, 0, sizeof(struct mousevsc_prt_msg));
370 ack.type = PipeMessageData;
371 ack.size = sizeof(struct synthhid_device_info_ack);
373 ack.ack.header.type = SynthHidInitialDeviceInfoAck;
374 ack.ack.header.size = 1;
375 ack.ack.reserved = 0;
377 ret = vmbus_sendpacket(input_device->device->channel,
378 &ack,
379 sizeof(struct pipe_prt_msg) - sizeof(unsigned char) +
380 sizeof(struct synthhid_device_info_ack),
381 (unsigned long)&ack,
382 VM_PKT_DATA_INBAND,
383 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
384 if (ret != 0) {
385 pr_err("unable to send synthhid device info ack - ret %d",
386 ret);
387 goto Cleanup;
390 input_device->device_wait_condition = 1;
391 wake_up(&input_device->dev_info_wait_event);
393 return;
395 Cleanup:
396 kfree(input_device->hid_desc);
397 input_device->hid_desc = NULL;
399 kfree(input_device->report_desc);
400 input_device->report_desc = NULL;
402 input_device->dev_info_status = -1;
403 input_device->device_wait_condition = 1;
404 wake_up(&input_device->dev_info_wait_event);
407 static void mousevsc_on_receive_input_report(struct mousevsc_dev *input_device,
408 struct synthhid_input_report *input_report)
410 struct hv_driver *input_drv;
412 if (!input_device->init_complete) {
413 pr_info("Initialization incomplete...ignoring input_report msg");
414 return;
417 input_drv = drv_to_hv_drv(input_device->device->device.driver);
419 inputreport_callback(input_device->device,
420 input_report->buffer,
421 input_report->header.size);
424 static void mousevsc_on_receive(struct hv_device *device,
425 struct vmpacket_descriptor *packet)
427 struct pipe_prt_msg *pipe_msg;
428 struct synthhid_msg *hid_msg;
429 struct mousevsc_dev *input_dev;
431 input_dev = must_get_input_device(device);
432 if (!input_dev) {
433 pr_err("unable to get input device...device being destroyed?");
434 return;
437 pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet +
438 (packet->offset8 << 3));
440 if (pipe_msg->type != PipeMessageData) {
441 pr_err("unknown pipe msg type - type %d len %d",
442 pipe_msg->type, pipe_msg->size);
443 put_input_device(device);
444 return ;
447 hid_msg = (struct synthhid_msg *)&pipe_msg->data[0];
449 switch (hid_msg->header.type) {
450 case SynthHidProtocolResponse:
451 memcpy(&input_dev->protocol_resp, pipe_msg,
452 pipe_msg->size + sizeof(struct pipe_prt_msg) -
453 sizeof(unsigned char));
454 input_dev->protocol_wait_condition = 1;
455 wake_up(&input_dev->protocol_wait_event);
456 break;
458 case SynthHidInitialDeviceInfo:
459 WARN_ON(pipe_msg->size >= sizeof(struct hv_input_dev_info));
462 * Parse out the device info into device attr,
463 * hid desc and report desc
465 mousevsc_on_receive_device_info(input_dev,
466 (struct synthhid_device_info *)&pipe_msg->data[0]);
467 break;
468 case SynthHidInputReport:
469 mousevsc_on_receive_input_report(input_dev,
470 (struct synthhid_input_report *)&pipe_msg->data[0]);
472 break;
473 default:
474 pr_err("unsupported hid msg type - type %d len %d",
475 hid_msg->header.type, hid_msg->header.size);
476 break;
479 put_input_device(device);
482 static void mousevsc_on_channel_callback(void *context)
484 const int packetSize = 0x100;
485 int ret = 0;
486 struct hv_device *device = (struct hv_device *)context;
487 struct mousevsc_dev *input_dev;
489 u32 bytes_recvd;
490 u64 req_id;
491 unsigned char packet[0x100];
492 struct vmpacket_descriptor *desc;
493 unsigned char *buffer = packet;
494 int bufferlen = packetSize;
496 input_dev = must_get_input_device(device);
498 if (!input_dev) {
499 pr_err("unable to get input device...device being destroyed?");
500 return;
503 do {
504 ret = vmbus_recvpacket_raw(device->channel, buffer,
505 bufferlen, &bytes_recvd, &req_id);
507 if (ret == 0) {
508 if (bytes_recvd > 0) {
509 desc = (struct vmpacket_descriptor *)buffer;
511 switch (desc->type) {
512 case VM_PKT_COMP:
513 mousevsc_on_send_completion(
514 device, desc);
515 break;
517 case VM_PKT_DATA_INBAND:
518 mousevsc_on_receive(
519 device, desc);
520 break;
522 default:
523 pr_err("unhandled packet type %d, tid %llx len %d\n",
524 desc->type,
525 req_id,
526 bytes_recvd);
527 break;
530 /* reset */
531 if (bufferlen > packetSize) {
532 kfree(buffer);
534 buffer = packet;
535 bufferlen = packetSize;
537 } else {
539 * pr_debug("nothing else to read...");
540 * reset
542 if (bufferlen > packetSize) {
543 kfree(buffer);
545 buffer = packet;
546 bufferlen = packetSize;
548 break;
550 } else if (ret == -2) {
551 /* Handle large packet */
552 bufferlen = bytes_recvd;
553 buffer = kzalloc(bytes_recvd, GFP_KERNEL);
555 if (buffer == NULL) {
556 buffer = packet;
557 bufferlen = packetSize;
559 /* Try again next time around */
560 pr_err("unable to allocate buffer of size %d!",
561 bytes_recvd);
562 break;
565 } while (1);
567 put_input_device(device);
569 return;
572 static int mousevsc_connect_to_vsp(struct hv_device *device)
574 int ret = 0;
575 struct mousevsc_dev *input_dev;
576 struct mousevsc_prt_msg *request;
577 struct mousevsc_prt_msg *response;
579 input_dev = get_input_device(device);
581 if (!input_dev) {
582 pr_err("unable to get input device...device being destroyed?");
583 return -1;
586 init_waitqueue_head(&input_dev->protocol_wait_event);
587 init_waitqueue_head(&input_dev->dev_info_wait_event);
589 request = &input_dev->protocol_req;
592 * Now, initiate the vsc/vsp initialization protocol on the open channel
594 memset(request, 0, sizeof(struct mousevsc_prt_msg));
596 request->type = PipeMessageData;
597 request->size = sizeof(struct synthhid_protocol_request);
599 request->request.header.type = SynthHidProtocolRequest;
600 request->request.header.size = sizeof(unsigned long);
601 request->request.version_requested.version = SYNTHHID_INPUT_VERSION;
603 pr_info("synthhid protocol request...");
605 ret = vmbus_sendpacket(device->channel, request,
606 sizeof(struct pipe_prt_msg) -
607 sizeof(unsigned char) +
608 sizeof(struct synthhid_protocol_request),
609 (unsigned long)request,
610 VM_PKT_DATA_INBAND,
611 VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
612 if (ret != 0) {
613 pr_err("unable to send synthhid protocol request.");
614 goto Cleanup;
617 input_dev->protocol_wait_condition = 0;
618 wait_event_timeout(input_dev->protocol_wait_event,
619 input_dev->protocol_wait_condition, msecs_to_jiffies(1000));
620 if (input_dev->protocol_wait_condition == 0) {
621 ret = -ETIMEDOUT;
622 goto Cleanup;
625 response = &input_dev->protocol_resp;
627 if (!response->response.approved) {
628 pr_err("synthhid protocol request failed (version %d)",
629 SYNTHHID_INPUT_VERSION);
630 ret = -1;
631 goto Cleanup;
634 input_dev->device_wait_condition = 0;
635 wait_event_timeout(input_dev->dev_info_wait_event,
636 input_dev->device_wait_condition, msecs_to_jiffies(1000));
637 if (input_dev->device_wait_condition == 0) {
638 ret = -ETIMEDOUT;
639 goto Cleanup;
643 * We should have gotten the device attr, hid desc and report
644 * desc at this point
646 if (!input_dev->dev_info_status)
647 pr_info("**** input channel up and running!! ****");
648 else
649 ret = -1;
651 Cleanup:
652 put_input_device(device);
654 return ret;
657 static int mousevsc_on_device_add(struct hv_device *device,
658 void *additional_info)
660 int ret = 0;
661 struct mousevsc_dev *input_dev;
662 struct hv_driver *input_drv;
663 struct hv_input_dev_info dev_info;
665 input_dev = alloc_input_device(device);
667 if (!input_dev) {
668 ret = -1;
669 goto Cleanup;
672 input_dev->init_complete = false;
674 /* Open the channel */
675 ret = vmbus_open(device->channel,
676 INPUTVSC_SEND_RING_BUFFER_SIZE,
677 INPUTVSC_RECV_RING_BUFFER_SIZE,
678 NULL,
680 mousevsc_on_channel_callback,
681 device
684 if (ret != 0) {
685 pr_err("unable to open channel: %d", ret);
686 free_input_device(input_dev);
687 return -1;
690 pr_info("InputVsc channel open: %d", ret);
692 ret = mousevsc_connect_to_vsp(device);
694 if (ret != 0) {
695 pr_err("unable to connect channel: %d", ret);
697 vmbus_close(device->channel);
698 free_input_device(input_dev);
699 return ret;
702 input_drv = drv_to_hv_drv(input_dev->device->device.driver);
704 dev_info.vendor = input_dev->hid_dev_info.vendor;
705 dev_info.product = input_dev->hid_dev_info.product;
706 dev_info.version = input_dev->hid_dev_info.version;
707 strcpy(dev_info.name, "Microsoft Vmbus HID-compliant Mouse");
709 /* Send the device info back up */
710 deviceinfo_callback(device, &dev_info);
712 /* Send the report desc back up */
713 /* workaround SA-167 */
714 if (input_dev->report_desc[14] == 0x25)
715 input_dev->report_desc[14] = 0x29;
717 reportdesc_callback(device, input_dev->report_desc,
718 input_dev->report_desc_size);
720 input_dev->init_complete = true;
722 Cleanup:
723 return ret;
726 static int mousevsc_on_device_remove(struct hv_device *device)
728 struct mousevsc_dev *input_dev;
729 int ret = 0;
731 pr_info("disabling input device (%p)...",
732 device->ext);
734 input_dev = release_input_device(device);
738 * At this point, all outbound traffic should be disable. We only
739 * allow inbound traffic (responses) to proceed
741 * so that outstanding requests can be completed.
743 while (input_dev->num_outstanding_req) {
744 pr_info("waiting for %d requests to complete...",
745 input_dev->num_outstanding_req);
747 udelay(100);
750 pr_info("removing input device (%p)...", device->ext);
752 input_dev = final_release_input_device(device);
754 pr_info("input device (%p) safe to remove", input_dev);
756 /* Close the channel */
757 vmbus_close(device->channel);
759 free_input_device(input_dev);
761 return ret;
766 * Data types
768 struct input_device_context {
769 struct hv_device *device_ctx;
770 struct hid_device *hid_device;
771 struct hv_input_dev_info device_info;
772 int connected;
776 static void deviceinfo_callback(struct hv_device *dev, struct hv_input_dev_info *info)
778 struct input_device_context *input_device_ctx =
779 dev_get_drvdata(&dev->device);
781 memcpy(&input_device_ctx->device_info, info,
782 sizeof(struct hv_input_dev_info));
784 DPRINT_INFO(INPUTVSC_DRV, "%s", __func__);
787 static void inputreport_callback(struct hv_device *dev, void *packet, u32 len)
789 int ret = 0;
791 struct input_device_context *input_dev_ctx =
792 dev_get_drvdata(&dev->device);
794 ret = hid_input_report(input_dev_ctx->hid_device,
795 HID_INPUT_REPORT, packet, len, 1);
797 DPRINT_DBG(INPUTVSC_DRV, "hid_input_report (ret %d)", ret);
800 static int mousevsc_hid_open(struct hid_device *hid)
802 return 0;
805 static void mousevsc_hid_close(struct hid_device *hid)
809 static int mousevsc_probe(struct hv_device *dev)
811 int ret = 0;
813 struct input_device_context *input_dev_ctx;
815 input_dev_ctx = kmalloc(sizeof(struct input_device_context),
816 GFP_KERNEL);
818 dev_set_drvdata(&dev->device, input_dev_ctx);
820 /* Call to the vsc driver to add the device */
821 ret = mousevsc_on_device_add(dev, NULL);
823 if (ret != 0) {
824 DPRINT_ERR(INPUTVSC_DRV, "unable to add input vsc device");
826 return -1;
829 return 0;
832 static int mousevsc_remove(struct hv_device *dev)
834 int ret = 0;
836 struct input_device_context *input_dev_ctx;
838 input_dev_ctx = kmalloc(sizeof(struct input_device_context),
839 GFP_KERNEL);
841 dev_set_drvdata(&dev->device, input_dev_ctx);
843 if (input_dev_ctx->connected) {
844 hidinput_disconnect(input_dev_ctx->hid_device);
845 input_dev_ctx->connected = 0;
849 * Call to the vsc driver to let it know that the device
850 * is being removed
852 ret = mousevsc_on_device_remove(dev);
854 if (ret != 0) {
855 DPRINT_ERR(INPUTVSC_DRV,
856 "unable to remove vsc device (ret %d)", ret);
859 kfree(input_dev_ctx);
861 return ret;
864 static void reportdesc_callback(struct hv_device *dev, void *packet, u32 len)
866 struct input_device_context *input_device_ctx =
867 dev_get_drvdata(&dev->device);
868 struct hid_device *hid_dev;
870 /* hid_debug = -1; */
871 hid_dev = kmalloc(sizeof(struct hid_device), GFP_KERNEL);
873 if (hid_parse_report(hid_dev, packet, len)) {
874 DPRINT_INFO(INPUTVSC_DRV, "Unable to call hd_parse_report");
875 return;
878 if (hid_dev) {
879 DPRINT_INFO(INPUTVSC_DRV, "hid_device created");
881 hid_dev->ll_driver->open = mousevsc_hid_open;
882 hid_dev->ll_driver->close = mousevsc_hid_close;
884 hid_dev->bus = BUS_VIRTUAL;
885 hid_dev->vendor = input_device_ctx->device_info.vendor;
886 hid_dev->product = input_device_ctx->device_info.product;
887 hid_dev->version = input_device_ctx->device_info.version;
888 hid_dev->dev = dev->device;
890 sprintf(hid_dev->name, "%s",
891 input_device_ctx->device_info.name);
894 * HJ Do we want to call it with a 0
896 if (!hidinput_connect(hid_dev, 0)) {
897 hid_dev->claimed |= HID_CLAIMED_INPUT;
899 input_device_ctx->connected = 1;
901 DPRINT_INFO(INPUTVSC_DRV,
902 "HID device claimed by input\n");
905 if (!hid_dev->claimed) {
906 DPRINT_ERR(INPUTVSC_DRV,
907 "HID device not claimed by "
908 "input or hiddev\n");
911 input_device_ctx->hid_device = hid_dev;
914 kfree(hid_dev);
918 static struct hv_driver mousevsc_drv = {
919 .probe = mousevsc_probe,
920 .remove = mousevsc_remove,
923 static void mousevsc_drv_exit(void)
925 vmbus_child_driver_unregister(&mousevsc_drv.driver);
928 static int __init mousevsc_init(void)
930 struct hv_driver *drv = &mousevsc_drv;
932 DPRINT_INFO(INPUTVSC_DRV, "Hyper-V Mouse driver initializing.");
934 memcpy(&drv->dev_type, &mouse_guid,
935 sizeof(struct hv_guid));
937 drv->driver.name = driver_name;
939 /* The driver belongs to vmbus */
940 vmbus_child_driver_register(&drv->driver);
942 return 0;
945 static void __exit mousevsc_exit(void)
947 mousevsc_drv_exit();
951 * We don't want to automatically load this driver just yet, it's quite
952 * broken. It's safe if you want to load it yourself manually, but
953 * don't inflict it on unsuspecting users, that's just mean.
955 #if 0
958 * We use a PCI table to determine if we should autoload this driver This is
959 * needed by distro tools to determine if the hyperv drivers should be
960 * installed and/or configured. We don't do anything else with the table, but
961 * it needs to be present.
963 const static struct pci_device_id microsoft_hv_pci_table[] = {
964 { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */
965 { 0 }
967 MODULE_DEVICE_TABLE(pci, microsoft_hv_pci_table);
968 #endif
970 MODULE_LICENSE("GPL");
971 MODULE_VERSION(HV_DRV_VERSION);
972 module_init(mousevsc_init);
973 module_exit(mousevsc_exit);