Lines Matching +full:report +full:- +full:error
1 /* -*- linux-c -*-
5 TO CHECK: Is pressure done right on report 5?
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 documentation, and that the name of GTCO-CalComp not be used in advertising
29 written prior permission. GTCO-CalComp makes no representations about the
33 GTCO-CALCOMP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
35 EVENT SHALL GTCO-CALCOMP BE LIABLE FOR ANY SPECIAL, INDIRECT OR
79 /* Max size of a single report */
116 /* Information pulled from Report Descriptor */
132 /* Code for parsing the HID REPORT DESCRIPTOR */
187 * This is an abbreviated parser for the HID Report Descriptor. We
191 * - We know there are no LONG tags, all short
192 * - We know that we have no MAIN Feature and MAIN Output items
193 * - We know what the IRQ reports are supposed to look like.
195 * The main purpose of this is to use the HID report desc to figure
200 static void parse_hid_report_descriptor(struct gtco *device, char * report, in parse_hid_report_descriptor() argument
203 struct device *ddev = &device->intf->dev; in parse_hid_report_descriptor()
231 /* Walk this report and pull out the info we need */ in parse_hid_report_descriptor()
233 prefix = report[i++]; in parse_hid_report_descriptor()
246 data = report[i]; in parse_hid_report_descriptor()
249 data16 = get_unaligned_le16(&report[i]); in parse_hid_report_descriptor()
252 data32 = get_unaligned_le32(&report[i]); in parse_hid_report_descriptor()
270 * information from a report. We need to in parse_hid_report_descriptor()
281 dev_dbg(ddev, "::::: Saving Report: %d input #%d Max: 0x%X(%d) Min:0x%X(%d) of %d bits\n", in parse_hid_report_descriptor()
297 if (device->max_X == 0) { in parse_hid_report_descriptor()
298 device->max_X = globalval[TAG_GLOB_LOG_MAX]; in parse_hid_report_descriptor()
299 device->min_X = globalval[TAG_GLOB_LOG_MIN]; in parse_hid_report_descriptor()
305 if (device->max_Y == 0) { in parse_hid_report_descriptor()
306 device->max_Y = globalval[TAG_GLOB_LOG_MAX]; in parse_hid_report_descriptor()
307 device->min_Y = globalval[TAG_GLOB_LOG_MIN]; in parse_hid_report_descriptor()
314 if (device->maxtilt_X == 0) { in parse_hid_report_descriptor()
315 device->maxtilt_X = globalval[TAG_GLOB_LOG_MAX]; in parse_hid_report_descriptor()
316 device->mintilt_X = globalval[TAG_GLOB_LOG_MIN]; in parse_hid_report_descriptor()
322 if (device->maxtilt_Y == 0) { in parse_hid_report_descriptor()
323 device->maxtilt_Y = globalval[TAG_GLOB_LOG_MAX]; in parse_hid_report_descriptor()
324 device->mintilt_Y = globalval[TAG_GLOB_LOG_MIN]; in parse_hid_report_descriptor()
330 if (device->maxpressure == 0) { in parse_hid_report_descriptor()
331 device->maxpressure = globalval[TAG_GLOB_LOG_MAX]; in parse_hid_report_descriptor()
332 device->minpressure = globalval[TAG_GLOB_LOG_MIN]; in parse_hid_report_descriptor()
369 indentstr[x] = '-'; in parse_hid_report_descriptor()
388 indent--; in parse_hid_report_descriptor()
390 indentstr[x] = '-'; in parse_hid_report_descriptor()
425 if (device->usage == 0) in parse_hid_report_descriptor()
426 device->usage = data; in parse_hid_report_descriptor()
461 /* New report, restart numbering */ in parse_hid_report_descriptor()
559 device->urbinfo->dev = interface_to_usbdev(device->intf); in gtco_input_open()
560 if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) in gtco_input_open()
561 return -EIO; in gtco_input_open()
573 usb_kill_urb(device->urbinfo); in gtco_input_close()
581 * This information is based on what is read from the HID report and
590 inputdev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | in gtco_setup_caps()
594 inputdev->mscbit[0] = BIT_MASK(MSC_SCAN) | BIT_MASK(MSC_SERIAL) | in gtco_setup_caps()
597 /* Absolute values based on HID report info */ in gtco_setup_caps()
598 input_set_abs_params(inputdev, ABS_X, device->min_X, device->max_X, in gtco_setup_caps()
600 input_set_abs_params(inputdev, ABS_Y, device->min_Y, device->max_Y, in gtco_setup_caps()
607 input_set_abs_params(inputdev, ABS_TILT_X, device->mintilt_X, in gtco_setup_caps()
608 device->maxtilt_X, 0, 0); in gtco_setup_caps()
609 input_set_abs_params(inputdev, ABS_TILT_Y, device->mintilt_Y, in gtco_setup_caps()
610 device->maxtilt_Y, 0, 0); in gtco_setup_caps()
611 input_set_abs_params(inputdev, ABS_PRESSURE, device->minpressure, in gtco_setup_caps()
612 device->maxpressure, 0, 0); in gtco_setup_caps()
629 struct gtco *device = urbinfo->context; in gtco_urb_callback()
635 inputdev = device->inputdevice; in gtco_urb_callback()
638 if (urbinfo->status == -ECONNRESET || in gtco_urb_callback()
639 urbinfo->status == -ENOENT || in gtco_urb_callback()
640 urbinfo->status == -ESHUTDOWN) { in gtco_urb_callback()
646 if (urbinfo->status != 0) { in gtco_urb_callback()
648 * Some unknown error. Hopefully temporary. Just go and in gtco_urb_callback()
658 /* PID dependent when we interpret the report */ in gtco_urb_callback()
659 if (inputdev->id.product == PID_1000 || in gtco_urb_callback()
660 inputdev->id.product == PID_1001 || in gtco_urb_callback()
661 inputdev->id.product == PID_1002) { in gtco_urb_callback()
664 * Switch on the report ID in gtco_urb_callback()
666 * the report number. We can just fall through the case in gtco_urb_callback()
667 * statements if we start with the highest number report in gtco_urb_callback()
669 switch (device->buffer[0]) { in gtco_urb_callback()
672 val = ((u16)(device->buffer[8]) << 1); in gtco_urb_callback()
673 val |= (u16)(device->buffer[7] >> 7); in gtco_urb_callback()
675 device->buffer[8]); in gtco_urb_callback()
678 device->buffer[7] = (u8)((device->buffer[7]) & 0x7F); in gtco_urb_callback()
684 sign_extend32(device->buffer[6], 6)); in gtco_urb_callback()
687 sign_extend32(device->buffer[7], 6)); in gtco_urb_callback()
693 val = (device->buffer[5]) & MASK_BUTTON; in gtco_urb_callback()
696 just report */ in gtco_urb_callback()
702 val = get_unaligned_le16(&device->buffer[1]); in gtco_urb_callback()
705 val = get_unaligned_le16(&device->buffer[3]); in gtco_urb_callback()
709 val = device->buffer[5] & MASK_INRANGE ? 1 : 0; in gtco_urb_callback()
712 /* Report 1 is an exception to how we handle buttons */ in gtco_urb_callback()
714 if (device->buffer[0] == 1) { in gtco_urb_callback()
718 * Report value of index set as one, in gtco_urb_callback()
721 val = device->buffer[5] & MASK_BUTTON; in gtco_urb_callback()
722 dev_dbg(&device->intf->dev, in gtco_urb_callback()
723 "======>>>>>>REPORT 1: val 0x%X(%d)\n", in gtco_urb_callback()
728 * index, just report it in gtco_urb_callback()
737 device->buffer[1]); in gtco_urb_callback()
743 if (inputdev->id.product == PID_400 || in gtco_urb_callback()
744 inputdev->id.product == PID_401) { in gtco_urb_callback()
746 /* Report 2 */ in gtco_urb_callback()
747 if (device->buffer[0] == 2) { in gtco_urb_callback()
749 input_event(inputdev, EV_MSC, MSC_SCAN, device->buffer[1]); in gtco_urb_callback()
752 /* Report 1 */ in gtco_urb_callback()
753 if (device->buffer[0] == 1) { in gtco_urb_callback()
756 /* IF X max > 64K, we still a bit from the y report */ in gtco_urb_callback()
757 if (device->max_X > 0x10000) { in gtco_urb_callback()
759 val = (u16)(((u16)(device->buffer[2] << 8)) | (u8)device->buffer[1]); in gtco_urb_callback()
760 val |= (u32)(((u8)device->buffer[3] & 0x1) << 16); in gtco_urb_callback()
764 le_buffer[0] = (u8)((u8)(device->buffer[3]) >> 1); in gtco_urb_callback()
765 le_buffer[0] |= (u8)((device->buffer[3] & 0x1) << 7); in gtco_urb_callback()
767 le_buffer[1] = (u8)(device->buffer[4] >> 1); in gtco_urb_callback()
768 le_buffer[1] |= (u8)((device->buffer[5] & 0x1) << 7); in gtco_urb_callback()
775 * make it look like the standard report in gtco_urb_callback()
777 buttonbyte = device->buffer[5] >> 1; in gtco_urb_callback()
780 val = get_unaligned_le16(&device->buffer[1]); in gtco_urb_callback()
783 val = get_unaligned_le16(&device->buffer[3]); in gtco_urb_callback()
786 buttonbyte = device->buffer[5]; in gtco_urb_callback()
799 /* We don't apply any meaning to the bitmask, just report */ in gtco_urb_callback()
804 input_report_abs(inputdev, ABS_MISC, device->buffer[6]); in gtco_urb_callback()
808 /* Everybody gets report ID's */ in gtco_urb_callback()
809 input_event(inputdev, EV_MSC, MSC_RAW, device->buffer[0]); in gtco_urb_callback()
817 dev_err(&device->intf->dev, in gtco_urb_callback()
825 * - Allocate mem for a local structure to manage the device
826 * - Request a HID Report Descriptor from the device and parse it to
828 * - Create an input device and assign it attributes
829 * - Allocate an URB so the device can talk to us when the input
839 char *report; in gtco_probe() local
841 int error; in gtco_probe() local
849 dev_err(&usbinterface->dev, "No more memory\n"); in gtco_probe()
850 error = -ENOMEM; in gtco_probe()
855 gtco->inputdevice = input_dev; in gtco_probe()
858 gtco->intf = usbinterface; in gtco_probe()
861 gtco->buffer = usb_alloc_coherent(udev, REPORT_MAX_SIZE, in gtco_probe()
862 GFP_KERNEL, >co->buf_dma); in gtco_probe()
863 if (!gtco->buffer) { in gtco_probe()
864 dev_err(&usbinterface->dev, "No more memory for us buffers\n"); in gtco_probe()
865 error = -ENOMEM; in gtco_probe()
870 gtco->urbinfo = usb_alloc_urb(0, GFP_KERNEL); in gtco_probe()
871 if (!gtco->urbinfo) { in gtco_probe()
872 dev_err(&usbinterface->dev, "Failed to allocate URB\n"); in gtco_probe()
873 error = -ENOMEM; in gtco_probe()
878 if (usbinterface->cur_altsetting->desc.bNumEndpoints < 1) { in gtco_probe()
879 dev_err(&usbinterface->dev, in gtco_probe()
881 error = -EINVAL; in gtco_probe()
885 endpoint = &usbinterface->cur_altsetting->endpoint[0].desc; in gtco_probe()
888 dev_dbg(&usbinterface->dev, "gtco # interfaces: %d\n", usbinterface->num_altsetting); in gtco_probe()
889 …dev_dbg(&usbinterface->dev, "num endpoints: %d\n", usbinterface->cur_altsetting->desc.bNumEndp… in gtco_probe()
890 …dev_dbg(&usbinterface->dev, "interface class: %d\n", usbinterface->cur_altsetting->desc.bInterfa… in gtco_probe()
891 …dev_dbg(&usbinterface->dev, "endpoint: attribute:0x%x type:0x%x\n", endpoint->bmAttributes, endpoi… in gtco_probe()
893 dev_dbg(&usbinterface->dev, "endpoint: we have interrupt endpoint\n"); in gtco_probe()
895 dev_dbg(&usbinterface->dev, "interface extra len:%d\n", in gtco_probe()
896 usbinterface->cur_altsetting->extralen); in gtco_probe()
900 * HID report descriptor in gtco_probe()
902 if (usb_get_extra_descriptor(usbinterface->cur_altsetting, in gtco_probe()
904 dev_err(&usbinterface->dev, in gtco_probe()
905 "Can't retrieve exta USB descriptor to get hid report descriptor length\n"); in gtco_probe()
906 error = -EIO; in gtco_probe()
910 dev_dbg(&usbinterface->dev, in gtco_probe()
912 hid_desc->bDescriptorType, hid_desc->wDescriptorLength); in gtco_probe()
914 report = kzalloc(le16_to_cpu(hid_desc->wDescriptorLength), GFP_KERNEL); in gtco_probe()
915 if (!report) { in gtco_probe()
916 dev_err(&usbinterface->dev, "No more memory for report\n"); in gtco_probe()
917 error = -ENOMEM; in gtco_probe()
929 report, in gtco_probe()
930 le16_to_cpu(hid_desc->wDescriptorLength), in gtco_probe()
933 dev_dbg(&usbinterface->dev, "usb_control_msg result: %d\n", result); in gtco_probe()
934 if (result == le16_to_cpu(hid_desc->wDescriptorLength)) { in gtco_probe()
935 parse_hid_report_descriptor(gtco, report, result); in gtco_probe()
940 kfree(report); in gtco_probe()
942 /* If we didn't get the report, fail */ in gtco_probe()
943 if (result != le16_to_cpu(hid_desc->wDescriptorLength)) { in gtco_probe()
944 dev_err(&usbinterface->dev, in gtco_probe()
945 "Failed to get HID Report Descriptor of size: %d\n", in gtco_probe()
946 hid_desc->wDescriptorLength); in gtco_probe()
947 error = -EIO; in gtco_probe()
952 usb_make_path(udev, gtco->usbpath, sizeof(gtco->usbpath)); in gtco_probe()
953 strlcat(gtco->usbpath, "/input0", sizeof(gtco->usbpath)); in gtco_probe()
956 input_dev->open = gtco_input_open; in gtco_probe()
957 input_dev->close = gtco_input_close; in gtco_probe()
960 input_dev->name = "GTCO_CalComp"; in gtco_probe()
961 input_dev->phys = gtco->usbpath; in gtco_probe()
969 usb_to_input_id(udev, &input_dev->id); in gtco_probe()
970 input_dev->dev.parent = &usbinterface->dev; in gtco_probe()
973 usb_fill_int_urb(gtco->urbinfo, in gtco_probe()
976 endpoint->bEndpointAddress), in gtco_probe()
977 gtco->buffer, in gtco_probe()
981 endpoint->bInterval); in gtco_probe()
983 gtco->urbinfo->transfer_dma = gtco->buf_dma; in gtco_probe()
984 gtco->urbinfo->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in gtco_probe()
990 error = input_register_device(input_dev); in gtco_probe()
991 if (error) in gtco_probe()
997 usb_free_urb(gtco->urbinfo); in gtco_probe()
1000 gtco->buffer, gtco->buf_dma); in gtco_probe()
1004 return error; in gtco_probe()
1009 * is disconnected. We will get rid of the URV, de-register the input
1020 input_unregister_device(gtco->inputdevice); in gtco_disconnect()
1021 usb_kill_urb(gtco->urbinfo); in gtco_disconnect()
1022 usb_free_urb(gtco->urbinfo); in gtco_disconnect()
1024 gtco->buffer, gtco->buf_dma); in gtco_disconnect()
1028 dev_info(&interface->dev, "gtco driver disconnected\n"); in gtco_disconnect()