Commit 5a1219efe912855f0fc64471d31c1c392d8ad488

Authored by Marek Vasut
Committed by Remy Bohmer
1 parent 9a8c72a6c4

USB: Drop dead code from usb_kbd.c

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Cc: Remy Bohmer <linux@bohmer.net>
Cc: Wolfgang Denk <wd@denx.de>

Showing 1 changed file with 0 additions and 379 deletions Side-by-side Diff

... ... @@ -505,383 +505,4 @@
505 505 return 1;
506 506 #endif
507 507 }
508   -
509   -#if 0
510   -struct usb_hid_descriptor {
511   - unsigned char bLength;
512   - unsigned char bDescriptorType; /* 0x21 for HID */
513   - unsigned short bcdHID; /* release number */
514   - unsigned char bCountryCode;
515   - unsigned char bNumDescriptors;
516   - unsigned char bReportDescriptorType;
517   - unsigned short wDescriptorLength;
518   -} __packed;
519   -
520   -/*
521   - * We parse each description item into this structure. Short items data
522   - * values are expanded to 32-bit signed int, long items contain a pointer
523   - * into the data area.
524   - */
525   -
526   -struct hid_item {
527   - unsigned char format;
528   - unsigned char size;
529   - unsigned char type;
530   - unsigned char tag;
531   - union {
532   - unsigned char u8;
533   - char s8;
534   - unsigned short u16;
535   - short s16;
536   - unsigned long u32;
537   - long s32;
538   - unsigned char *longdata;
539   - } data;
540   -};
541   -
542   -/*
543   - * HID report item format
544   - */
545   -
546   -#define HID_ITEM_FORMAT_SHORT 0
547   -#define HID_ITEM_FORMAT_LONG 1
548   -
549   -/*
550   - * Special tag indicating long items
551   - */
552   -
553   -#define HID_ITEM_TAG_LONG 15
554   -
555   -
556   -static struct usb_hid_descriptor usb_kbd_hid_desc;
557   -
558   -void usb_kbd_display_hid(struct usb_hid_descriptor *hid)
559   -{
560   - printf("USB_HID_DESC:\n");
561   - printf(" bLenght 0x%x\n", hid->bLength);
562   - printf(" bcdHID 0x%x\n", hid->bcdHID);
563   - printf(" bCountryCode %d\n", hid->bCountryCode);
564   - printf(" bNumDescriptors 0x%x\n", hid->bNumDescriptors);
565   - printf(" bReportDescriptorType 0x%x\n", hid->bReportDescriptorType);
566   - printf(" wDescriptorLength 0x%x\n", hid->wDescriptorLength);
567   -}
568   -
569   -
570   -/*
571   - * Fetch a report description item from the data stream. We support long
572   - * items, though they are not used yet.
573   - */
574   -
575   -static int fetch_item(unsigned char *start, unsigned char *end,
576   - struct hid_item *item)
577   -{
578   - if ((end - start) > 0) {
579   - unsigned char b = *start++;
580   - item->type = (b >> 2) & 3;
581   - item->tag = (b >> 4) & 15;
582   - if (item->tag == HID_ITEM_TAG_LONG) {
583   - item->format = HID_ITEM_FORMAT_LONG;
584   - if ((end - start) >= 2) {
585   - item->size = *start++;
586   - item->tag = *start++;
587   - if ((end - start) >= item->size) {
588   - item->data.longdata = start;
589   - start += item->size;
590   - return item->size;
591   - }
592   - }
593   - } else {
594   - item->format = HID_ITEM_FORMAT_SHORT;
595   - item->size = b & 3;
596   - switch (item->size) {
597   - case 0:
598   - return item->size;
599   - case 1:
600   - if ((end - start) >= 1) {
601   - item->data.u8 = *start++;
602   - return item->size;
603   - }
604   - break;
605   - case 2:
606   - if ((end - start) >= 2) {
607   - item->data.u16 = le16_to_cpu(
608   - (unsigned short *)start);
609   - start += 2;
610   - return item->size;
611   - }
612   - case 3:
613   - item->size++;
614   - if ((end - start) >= 4) {
615   - item->data.u32 = le32_to_cpu(
616   - (unsigned long *)start);
617   - start += 4;
618   - return item->size;
619   - }
620   - }
621   - }
622   - }
623   - return -1;
624   -}
625   -
626   -/*
627   - * HID report descriptor item type (prefix bit 2, 3)
628   - */
629   -
630   -#define HID_ITEM_TYPE_MAIN 0
631   -#define HID_ITEM_TYPE_GLOBAL 1
632   -#define HID_ITEM_TYPE_LOCAL 2
633   -#define HID_ITEM_TYPE_RESERVED 3
634   -/*
635   - * HID report descriptor main item tags
636   - */
637   -
638   -#define HID_MAIN_ITEM_TAG_INPUT 8
639   -#define HID_MAIN_ITEM_TAG_OUTPUT 9
640   -#define HID_MAIN_ITEM_TAG_FEATURE 11
641   -#define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10
642   -#define HID_MAIN_ITEM_TAG_END_COLLECTION 12
643   -/*
644   - * HID report descriptor main item contents
645   - */
646   -
647   -#define HID_MAIN_ITEM_CONSTANT 0x001
648   -#define HID_MAIN_ITEM_VARIABLE 0x002
649   -#define HID_MAIN_ITEM_RELATIVE 0x004
650   -#define HID_MAIN_ITEM_WRAP 0x008
651   -#define HID_MAIN_ITEM_NONLINEAR 0x010
652   -#define HID_MAIN_ITEM_NO_PREFERRED 0x020
653   -#define HID_MAIN_ITEM_NULL_STATE 0x040
654   -#define HID_MAIN_ITEM_VOLATILE 0x080
655   -#define HID_MAIN_ITEM_BUFFERED_BYTE 0x100
656   -
657   -/*
658   - * HID report descriptor collection item types
659   - */
660   -
661   -#define HID_COLLECTION_PHYSICAL 0
662   -#define HID_COLLECTION_APPLICATION 1
663   -#define HID_COLLECTION_LOGICAL 2
664   -/*
665   - * HID report descriptor global item tags
666   - */
667   -
668   -#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0
669   -#define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1
670   -#define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2
671   -#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3
672   -#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4
673   -#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5
674   -#define HID_GLOBAL_ITEM_TAG_UNIT 6
675   -#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7
676   -#define HID_GLOBAL_ITEM_TAG_REPORT_ID 8
677   -#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9
678   -#define HID_GLOBAL_ITEM_TAG_PUSH 10
679   -#define HID_GLOBAL_ITEM_TAG_POP 11
680   -
681   -/*
682   - * HID report descriptor local item tags
683   - */
684   -
685   -#define HID_LOCAL_ITEM_TAG_USAGE 0
686   -#define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1
687   -#define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2
688   -#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3
689   -#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4
690   -#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5
691   -#define HID_LOCAL_ITEM_TAG_STRING_INDEX 7
692   -#define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8
693   -#define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9
694   -#define HID_LOCAL_ITEM_TAG_DELIMITER 10
695   -
696   -
697   -static void usb_kbd_show_item(struct hid_item *item)
698   -{
699   - switch (item->type) {
700   - case HID_ITEM_TYPE_MAIN:
701   - switch (item->tag) {
702   - case HID_MAIN_ITEM_TAG_INPUT:
703   - printf("Main Input");
704   - break;
705   - case HID_MAIN_ITEM_TAG_OUTPUT:
706   - printf("Main Output");
707   - break;
708   - case HID_MAIN_ITEM_TAG_FEATURE:
709   - printf("Main Feature");
710   - break;
711   - case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION:
712   - printf("Main Begin Collection");
713   - break;
714   - case HID_MAIN_ITEM_TAG_END_COLLECTION:
715   - printf("Main End Collection");
716   - break;
717   - default:
718   - printf("Main reserved %d", item->tag);
719   - break;
720   - }
721   - break;
722   - case HID_ITEM_TYPE_GLOBAL:
723   - switch (item->tag) {
724   - case HID_GLOBAL_ITEM_TAG_USAGE_PAGE:
725   - printf("- Global Usage Page");
726   - break;
727   - case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM:
728   - printf("- Global Logical Minimum");
729   - break;
730   - case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM:
731   - printf("- Global Logical Maximum");
732   - break;
733   - case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM:
734   - printf("- Global physical Minimum");
735   - break;
736   - case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM:
737   - printf("- Global physical Maximum");
738   - break;
739   - case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT:
740   - printf("- Global Unit Exponent");
741   - break;
742   - case HID_GLOBAL_ITEM_TAG_UNIT:
743   - printf("- Global Unit");
744   - break;
745   - case HID_GLOBAL_ITEM_TAG_REPORT_SIZE:
746   - printf("- Global Report Size");
747   - break;
748   - case HID_GLOBAL_ITEM_TAG_REPORT_ID:
749   - printf("- Global Report ID");
750   - break;
751   - case HID_GLOBAL_ITEM_TAG_REPORT_COUNT:
752   - printf("- Global Report Count");
753   - break;
754   - case HID_GLOBAL_ITEM_TAG_PUSH:
755   - printf("- Global Push");
756   - break;
757   - case HID_GLOBAL_ITEM_TAG_POP:
758   - printf("- Global Pop");
759   - break;
760   - default:
761   - printf("- Global reserved %d", item->tag);
762   - break;
763   - }
764   - break;
765   - case HID_ITEM_TYPE_LOCAL:
766   - switch (item->tag) {
767   - case HID_LOCAL_ITEM_TAG_USAGE:
768   - printf("-- Local Usage");
769   - break;
770   - case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM:
771   - printf("-- Local Usage Minimum");
772   - break;
773   - case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM:
774   - printf("-- Local Usage Maximum");
775   - break;
776   - case HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX:
777   - printf("-- Local Designator Index");
778   - break;
779   - case HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM:
780   - printf("-- Local Designator Minimum");
781   - break;
782   - case HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM:
783   - printf("-- Local Designator Maximum");
784   - break;
785   - case HID_LOCAL_ITEM_TAG_STRING_INDEX:
786   - printf("-- Local String Index");
787   - break;
788   - case HID_LOCAL_ITEM_TAG_STRING_MINIMUM:
789   - printf("-- Local String Minimum");
790   - break;
791   - case HID_LOCAL_ITEM_TAG_STRING_MAXIMUM:
792   - printf("-- Local String Maximum");
793   - break;
794   - case HID_LOCAL_ITEM_TAG_DELIMITER:
795   - printf("-- Local Delimiter");
796   - break;
797   - default:
798   - printf("-- Local reserved %d", item->tag);
799   - break;
800   - }
801   - break;
802   - default:
803   - printf("--- reserved %d", item->type);
804   - break;
805   - }
806   - switch (item->size) {
807   - case 1:
808   - printf(" %d", item->data.u8);
809   - break;
810   - case 2:
811   - printf(" %d", item->data.u16);
812   - break;
813   - case 4:
814   - printf(" %ld", item->data.u32);
815   - break;
816   - }
817   - printf("\n");
818   -}
819   -
820   -
821   -static int usb_kbd_get_hid_desc(struct usb_device *dev)
822   -{
823   - unsigned char buffer[256];
824   - struct usb_descriptor_header *head;
825   - struct usb_config_descriptor *config;
826   - int index, len, i;
827   - unsigned char *start, *end;
828   - struct hid_item item;
829   -
830   - if (usb_get_configuration_no(dev, &buffer[0], 0) == -1)
831   - return -1;
832   - head = (struct usb_descriptor_header *)&buffer[0];
833   - if (head->bDescriptorType != USB_DT_CONFIG) {
834   - printf(" ERROR: NOT USB_CONFIG_DESC %x\n",
835   - head->bDescriptorType);
836   - return -1;
837   - }
838   - index = head->bLength;
839   - config = (struct usb_config_descriptor *)&buffer[0];
840   - len = le16_to_cpu(config->wTotalLength);
841   - /*
842   - * Ok the first entry must be a configuration entry,
843   - * now process the others
844   - */
845   - head = (struct usb_descriptor_header *)&buffer[index];
846   - while (index+1 < len) {
847   - if (head->bDescriptorType == USB_DT_HID) {
848   - printf("HID desc found\n");
849   - memcpy(&usb_kbd_hid_desc, &buffer[index],
850   - buffer[index]);
851   - le16_to_cpus(&usb_kbd_hid_desc.bcdHID);
852   - le16_to_cpus(&usb_kbd_hid_desc.wDescriptorLength);
853   - usb_kbd_display_hid(&usb_kbd_hid_desc);
854   - len = 0;
855   - break;
856   - }
857   - index += head->bLength;
858   - head = (struct usb_descriptor_header *)&buffer[index];
859   - }
860   - if (len > 0)
861   - return -1;
862   - len = usb_kbd_hid_desc.wDescriptorLength;
863   - index = usb_get_class_descriptor(dev, 0, USB_DT_REPORT, 0, &buffer[0],
864   - len);
865   - if (index < 0) {
866   - printf("reading report descriptor failed\n");
867   - return -1;
868   - }
869   - printf(" report descriptor (size %u, read %d)\n", len, index);
870   - start = &buffer[0];
871   - end = &buffer[len];
872   - i = 0;
873   - do {
874   - index = fetch_item(start, end, &item);
875   - i += index;
876   - i++;
877   - if (index >= 0)
878   - usb_kbd_show_item(&item);
879   -
880   - start += index;
881   - start++;
882   - } while (index >= 0);
883   -
884   -}
885   -
886   -#endif