aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usbmidi.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-05-02 02:51:26 -0400
committerJaroslav Kysela <perex@suse.cz>2005-05-29 04:05:47 -0400
commit27d10f5664c7650af3b2ffadfefaf19b36dc7bd8 (patch)
treeb89c8d639041f460557bf6e9078c7cee7426cd2b /sound/usb/usbmidi.c
parentb259b10c420a59a2fdbcf5a3498253ebcbdffa1e (diff)
[ALSA] usb-audio - cache vendor/product IDs
USB generic driver Cache the decoded values of idVendor/idProduct to get rid of most of those ugly le16_to_cpu() calls. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound/usb/usbmidi.c')
-rw-r--r--sound/usb/usbmidi.c123
1 files changed, 59 insertions, 64 deletions
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 304a13451ec9..bee70068dce0 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -955,88 +955,87 @@ static snd_rawmidi_substream_t* snd_usbmidi_find_substream(snd_usb_midi_t* umidi
955 * such as internal control or synthesizer ports. 955 * such as internal control or synthesizer ports.
956 */ 956 */
957static struct { 957static struct {
958 __u16 vendor; 958 u32 id;
959 __u16 product;
960 int port; 959 int port;
961 const char *name_format; 960 const char *name_format;
962} snd_usbmidi_port_names[] = { 961} snd_usbmidi_port_names[] = {
963 /* Roland UA-100 */ 962 /* Roland UA-100 */
964 {0x0582, 0x0000, 2, "%s Control"}, 963 { USB_ID(0x0582, 0x0000), 2, "%s Control" },
965 /* Roland SC-8850 */ 964 /* Roland SC-8850 */
966 {0x0582, 0x0003, 0, "%s Part A"}, 965 { USB_ID(0x0582, 0x0003), 0, "%s Part A" },
967 {0x0582, 0x0003, 1, "%s Part B"}, 966 { USB_ID(0x0582, 0x0003), 1, "%s Part B" },
968 {0x0582, 0x0003, 2, "%s Part C"}, 967 { USB_ID(0x0582, 0x0003), 2, "%s Part C" },
969 {0x0582, 0x0003, 3, "%s Part D"}, 968 { USB_ID(0x0582, 0x0003), 3, "%s Part D" },
970 {0x0582, 0x0003, 4, "%s MIDI 1"}, 969 { USB_ID(0x0582, 0x0003), 4, "%s MIDI 1" },
971 {0x0582, 0x0003, 5, "%s MIDI 2"}, 970 { USB_ID(0x0582, 0x0003), 5, "%s MIDI 2" },
972 /* Roland U-8 */ 971 /* Roland U-8 */
973 {0x0582, 0x0004, 0, "%s MIDI"}, 972 { USB_ID(0x0582, 0x0004), 0, "%s MIDI" },
974 {0x0582, 0x0004, 1, "%s Control"}, 973 { USB_ID(0x0582, 0x0004), 1, "%s Control" },
975 /* Roland SC-8820 */ 974 /* Roland SC-8820 */
976 {0x0582, 0x0007, 0, "%s Part A"}, 975 { USB_ID(0x0582, 0x0007), 0, "%s Part A" },
977 {0x0582, 0x0007, 1, "%s Part B"}, 976 { USB_ID(0x0582, 0x0007), 1, "%s Part B" },
978 {0x0582, 0x0007, 2, "%s MIDI"}, 977 { USB_ID(0x0582, 0x0007), 2, "%s MIDI" },
979 /* Roland SK-500 */ 978 /* Roland SK-500 */
980 {0x0582, 0x000b, 0, "%s Part A"}, 979 { USB_ID(0x0582, 0x000b), 0, "%s Part A" },
981 {0x0582, 0x000b, 1, "%s Part B"}, 980 { USB_ID(0x0582, 0x000b), 1, "%s Part B" },
982 {0x0582, 0x000b, 2, "%s MIDI"}, 981 { USB_ID(0x0582, 0x000b), 2, "%s MIDI" },
983 /* Roland SC-D70 */ 982 /* Roland SC-D70 */
984 {0x0582, 0x000c, 0, "%s Part A"}, 983 { USB_ID(0x0582, 0x000c), 0, "%s Part A" },
985 {0x0582, 0x000c, 1, "%s Part B"}, 984 { USB_ID(0x0582, 0x000c), 1, "%s Part B" },
986 {0x0582, 0x000c, 2, "%s MIDI"}, 985 { USB_ID(0x0582, 0x000c), 2, "%s MIDI" },
987 /* Edirol UM-880 */ 986 /* Edirol UM-880 */
988 {0x0582, 0x0014, 8, "%s Control"}, 987 { USB_ID(0x0582, 0x0014), 8, "%s Control" },
989 /* Edirol SD-90 */ 988 /* Edirol SD-90 */
990 {0x0582, 0x0016, 0, "%s Part A"}, 989 { USB_ID(0x0582, 0x0016), 0, "%s Part A" },
991 {0x0582, 0x0016, 1, "%s Part B"}, 990 { USB_ID(0x0582, 0x0016), 1, "%s Part B" },
992 {0x0582, 0x0016, 2, "%s MIDI 1"}, 991 { USB_ID(0x0582, 0x0016), 2, "%s MIDI 1" },
993 {0x0582, 0x0016, 3, "%s MIDI 2"}, 992 { USB_ID(0x0582, 0x0016), 3, "%s MIDI 2" },
994 /* Edirol UM-550 */ 993 /* Edirol UM-550 */
995 {0x0582, 0x0023, 5, "%s Control"}, 994 { USB_ID(0x0582, 0x0023), 5, "%s Control" },
996 /* Edirol SD-20 */ 995 /* Edirol SD-20 */
997 {0x0582, 0x0027, 0, "%s Part A"}, 996 { USB_ID(0x0582, 0x0027), 0, "%s Part A" },
998 {0x0582, 0x0027, 1, "%s Part B"}, 997 { USB_ID(0x0582, 0x0027), 1, "%s Part B" },
999 {0x0582, 0x0027, 2, "%s MIDI"}, 998 { USB_ID(0x0582, 0x0027), 2, "%s MIDI" },
1000 /* Edirol SD-80 */ 999 /* Edirol SD-80 */
1001 {0x0582, 0x0029, 0, "%s Part A"}, 1000 { USB_ID(0x0582, 0x0029), 0, "%s Part A" },
1002 {0x0582, 0x0029, 1, "%s Part B"}, 1001 { USB_ID(0x0582, 0x0029), 1, "%s Part B" },
1003 {0x0582, 0x0029, 2, "%s MIDI 1"}, 1002 { USB_ID(0x0582, 0x0029), 2, "%s MIDI 1" },
1004 {0x0582, 0x0029, 3, "%s MIDI 2"}, 1003 { USB_ID(0x0582, 0x0029), 3, "%s MIDI 2" },
1005 /* Edirol UA-700 */ 1004 /* Edirol UA-700 */
1006 {0x0582, 0x002b, 0, "%s MIDI"}, 1005 { USB_ID(0x0582, 0x002b), 0, "%s MIDI" },
1007 {0x0582, 0x002b, 1, "%s Control"}, 1006 { USB_ID(0x0582, 0x002b), 1, "%s Control" },
1008 /* Roland VariOS */ 1007 /* Roland VariOS */
1009 {0x0582, 0x002f, 0, "%s MIDI"}, 1008 { USB_ID(0x0582, 0x002f), 0, "%s MIDI" },
1010 {0x0582, 0x002f, 1, "%s External MIDI"}, 1009 { USB_ID(0x0582, 0x002f), 1, "%s External MIDI" },
1011 {0x0582, 0x002f, 2, "%s Sync"}, 1010 { USB_ID(0x0582, 0x002f), 2, "%s Sync" },
1012 /* Edirol PCR */ 1011 /* Edirol PCR */
1013 {0x0582, 0x0033, 0, "%s MIDI"}, 1012 { USB_ID(0x0582, 0x0033), 0, "%s MIDI" },
1014 {0x0582, 0x0033, 1, "%s 1"}, 1013 { USB_ID(0x0582, 0x0033), 1, "%s 1" },
1015 {0x0582, 0x0033, 2, "%s 2"}, 1014 { USB_ID(0x0582, 0x0033), 2, "%s 2" },
1016 /* BOSS GS-10 */ 1015 /* BOSS GS-10 */
1017 {0x0582, 0x003b, 0, "%s MIDI"}, 1016 { USB_ID(0x0582, 0x003b), 0, "%s MIDI" },
1018 {0x0582, 0x003b, 1, "%s Control"}, 1017 { USB_ID(0x0582, 0x003b), 1, "%s Control" },
1019 /* Edirol UA-1000 */ 1018 /* Edirol UA-1000 */
1020 {0x0582, 0x0044, 0, "%s MIDI"}, 1019 { USB_ID(0x0582, 0x0044), 0, "%s MIDI" },
1021 {0x0582, 0x0044, 1, "%s Control"}, 1020 { USB_ID(0x0582, 0x0044), 1, "%s Control" },
1022 /* Edirol UR-80 */ 1021 /* Edirol UR-80 */
1023 {0x0582, 0x0048, 0, "%s MIDI"}, 1022 { USB_ID(0x0582, 0x0048), 0, "%s MIDI" },
1024 {0x0582, 0x0048, 1, "%s 1"}, 1023 { USB_ID(0x0582, 0x0048), 1, "%s 1" },
1025 {0x0582, 0x0048, 2, "%s 2"}, 1024 { USB_ID(0x0582, 0x0048), 2, "%s 2" },
1026 /* Edirol PCR-A */ 1025 /* Edirol PCR-A */
1027 {0x0582, 0x004d, 0, "%s MIDI"}, 1026 { USB_ID(0x0582, 0x004d), 0, "%s MIDI" },
1028 {0x0582, 0x004d, 1, "%s 1"}, 1027 { USB_ID(0x0582, 0x004d), 1, "%s 1" },
1029 {0x0582, 0x004d, 2, "%s 2"}, 1028 { USB_ID(0x0582, 0x004d), 2, "%s 2" },
1030 /* M-Audio MidiSport 8x8 */ 1029 /* M-Audio MidiSport 8x8 */
1031 {0x0763, 0x1031, 8, "%s Control"}, 1030 { USB_ID(0x0763, 0x1031), 8, "%s Control" },
1032 {0x0763, 0x1033, 8, "%s Control"}, 1031 { USB_ID(0x0763, 0x1033), 8, "%s Control" },
1033 /* MOTU Fastlane */ 1032 /* MOTU Fastlane */
1034 {0x07fd, 0x0001, 0, "%s MIDI A"}, 1033 { USB_ID(0x07fd, 0x0001), 0, "%s MIDI A" },
1035 {0x07fd, 0x0001, 1, "%s MIDI B"}, 1034 { USB_ID(0x07fd, 0x0001), 1, "%s MIDI B" },
1036 /* Emagic Unitor8/AMT8/MT4 */ 1035 /* Emagic Unitor8/AMT8/MT4 */
1037 {0x086a, 0x0001, 8, "%s Broadcast"}, 1036 { USB_ID(0x086a, 0x0001), 8, "%s Broadcast" },
1038 {0x086a, 0x0002, 8, "%s Broadcast"}, 1037 { USB_ID(0x086a, 0x0002), 8, "%s Broadcast" },
1039 {0x086a, 0x0003, 4, "%s Broadcast"}, 1038 { USB_ID(0x086a, 0x0003), 4, "%s Broadcast" },
1040}; 1039};
1041 1040
1042static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, 1041static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi,
@@ -1044,7 +1043,6 @@ static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi,
1044 snd_rawmidi_substream_t** rsubstream) 1043 snd_rawmidi_substream_t** rsubstream)
1045{ 1044{
1046 int i; 1045 int i;
1047 __u16 vendor, product;
1048 const char *name_format; 1046 const char *name_format;
1049 1047
1050 snd_rawmidi_substream_t* substream = snd_usbmidi_find_substream(umidi, stream, number); 1048 snd_rawmidi_substream_t* substream = snd_usbmidi_find_substream(umidi, stream, number);
@@ -1055,11 +1053,8 @@ static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi,
1055 1053
1056 /* TODO: read port name from jack descriptor */ 1054 /* TODO: read port name from jack descriptor */
1057 name_format = "%s MIDI %d"; 1055 name_format = "%s MIDI %d";
1058 vendor = le16_to_cpu(umidi->chip->dev->descriptor.idVendor);
1059 product = le16_to_cpu(umidi->chip->dev->descriptor.idProduct);
1060 for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_names); ++i) { 1056 for (i = 0; i < ARRAY_SIZE(snd_usbmidi_port_names); ++i) {
1061 if (snd_usbmidi_port_names[i].vendor == vendor && 1057 if (snd_usbmidi_port_names[i].id == umidi->chip->usb_id &&
1062 snd_usbmidi_port_names[i].product == product &&
1063 snd_usbmidi_port_names[i].port == number) { 1058 snd_usbmidi_port_names[i].port == number) {
1064 name_format = snd_usbmidi_port_names[i].name_format; 1059 name_format = snd_usbmidi_port_names[i].name_format;
1065 break; 1060 break;
@@ -1226,7 +1221,7 @@ static int snd_usbmidi_detect_endpoints(snd_usb_midi_t* umidi,
1226 struct usb_endpoint_descriptor* epd; 1221 struct usb_endpoint_descriptor* epd;
1227 int i, out_eps = 0, in_eps = 0; 1222 int i, out_eps = 0, in_eps = 0;
1228 1223
1229 if (le16_to_cpu(umidi->chip->dev->descriptor.idVendor) == 0x0582) 1224 if (USB_ID_VENDOR(umidi->chip->usb_id) == 0x0582)
1230 snd_usbmidi_switch_roland_altsetting(umidi); 1225 snd_usbmidi_switch_roland_altsetting(umidi);
1231 1226
1232 if (endpoint[0].out_ep || endpoint[0].in_ep) 1227 if (endpoint[0].out_ep || endpoint[0].in_ep)