summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKamil Tomaszewski <kamil.tomaszewski@sony.com>2019-10-04 11:00:00 +0200
committerKamil Tomaszewski <kamil.tomaszewski@sony.com>2019-10-07 12:31:42 +0200
commit1205d3e3052bf057e4bae0d1da046bfcfbb2c21b (patch)
treeb92fd6662e1fb1af5dcc3321ab993611ebda4f73 /tools
parent7aefcc449a8a0f05bfd7c76ae745b8013f36dc57 (diff)
Add validation
Diffstat (limited to 'tools')
-rw-r--r--tools/gen_usb_descriptor.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py
index eccfbea67..ab6beca42 100644
--- a/tools/gen_usb_descriptor.py
+++ b/tools/gen_usb_descriptor.py
@@ -32,7 +32,7 @@ parser.add_argument('--devices', type=lambda l: tuple(l.split(',')), default=DEF
help='devices to include in descriptor (AUDIO includes MIDI support)')
parser.add_argument('--hid_devices', type=lambda l: tuple(l.split(',')), default=DEFAULT_HID_DEVICES,
help='HID devices to include in HID report descriptor')
-parser.add_argument('--relative_ep_num', type=int, default=1,
+parser.add_argument('--renumber_endpoints', type=int, default=1,
help='use relative(1) or absolute(0) endpoint number')
parser.add_argument('--cdc_ep_num_notification', type=int, default=0,
help='endpoint number of CDC NOTIFICATION')
@@ -63,6 +63,24 @@ unknown_hid_devices = list(frozenset(args.hid_devices) - ALL_HID_DEVICES_SET)
if unknown_hid_devices:
raise ValueError("Unknown HID devices(s)", unknown_hid_devices)
+if not args.renumber_endpoints:
+ if 'CDC' in args.devices:
+ if (args.cdc_ep_num_notification == 0 or args.cdc_ep_num_data_out == 0 or
+ args.cdc_ep_num_data_in == 0):
+ raise ValueError("Endpoint address must not be 0")
+
+ if 'MSC' in args.devices:
+ if args.msc_ep_num_out == 0 or args.msc_ep_num_in == 0:
+ raise ValueError("Endpoint address must not be 0")
+
+ if 'HID' in args.devices:
+ if args.hid_ep_num_in == 0:
+ raise ValueError("Endpoint address must not be 0")
+
+ if 'AUDIO' in args.devices:
+ if args.midi_ep_num_out == 0 or args.midi_ep_num_in == 0:
+ raise ValueError("Endpoint address must not be 0")
+
class StringIndex:
"""Assign a monotonically increasing index to each unique string. Start with 0."""
string_to_index = {}
@@ -323,15 +341,10 @@ if 'HID' in args.devices:
if 'AUDIO' in args.devices:
interfaces_to_join.append(audio_interfaces)
-if args.relative_ep_num:
- # util.join_interfaces() will renumber the endpoints to make them unique across descriptors,
- # and renumber the interfaces in order. But we still need to fix up certain
- # interface cross-references.
- interfaces = util.join_interfaces(*interfaces_to_join)
-else:
- # util.renumbers_interfaces() will renumber the interfaces in order. But we still need to
- # fix up certain interface cross-references.
- interfaces = util.renumbers_interfaces(*interfaces_to_join)
+# util.join_interfaces() will renumber the endpoints to make them unique across descriptors,
+# and renumber the interfaces in order. But we still need to fix up certain
+# interface cross-references.
+interfaces = util.join_interfaces(interfaces_to_join, renumber_endpoints=args.renumber_endpoints)
# Now adjust the CDC interface cross-references.