diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2021-03-21 06:28:30 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-03-22 14:22:27 +0300 |
commit | 5c6ea94f2b7c5ce4c012ac8c23fd35588f69c4c7 (patch) | |
tree | abf95057eec9bb6efdf26943efd6f658e4a52f19 /sound/firewire/bebob/bebob_command.c | |
parent | caa271510687f3ce3eed3a120cd2a6f71bc49223 (diff) | |
download | linux-5c6ea94f2b7c5ce4c012ac8c23fd35588f69c4c7.tar.xz |
ALSA: bebob: detect the number of available MIDI ports
Current implementation counts the number of input/output plugs for MIDI
type and uses the count as the number of physical MIDI ports. However,
the number of channels of the port represents the count.
This commit fixes the bug by additional vendor-specific AVC command
extension.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210321032831.340278-3-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/bebob/bebob_command.c')
-rw-r--r-- | sound/firewire/bebob/bebob_command.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sound/firewire/bebob/bebob_command.c b/sound/firewire/bebob/bebob_command.c index e276ab8f9006..022df09c68ff 100644 --- a/sound/firewire/bebob/bebob_command.c +++ b/sound/firewire/bebob/bebob_command.c @@ -143,6 +143,42 @@ end: return err; } +int avc_bridgeco_get_plug_ch_count(struct fw_unit *unit, u8 addr[AVC_BRIDGECO_ADDR_BYTES], + unsigned int *ch_count) +{ + u8 *buf; + int err; + + buf = kzalloc(12, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + + // Info type is 'plug type'. + avc_bridgeco_fill_plug_info_extension_command(buf, addr, 0x02); + + err = fcp_avc_transaction(unit, buf, 12, buf, 12, + BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | + BIT(6) | BIT(7) | BIT(9)); + if (err < 0) + ; + else if (err < 11) + err = -EIO; + else if (buf[0] == 0x08) // NOT IMPLEMENTED + err = -ENOSYS; + else if (buf[0] == 0x0a) // REJECTED + err = -EINVAL; + else if (buf[0] == 0x0b) // IN TRANSITION + err = -EAGAIN; + if (err < 0) + goto end; + + *ch_count = buf[10]; + err = 0; +end: + kfree(buf); + return err; +} + int avc_bridgeco_get_plug_ch_pos(struct fw_unit *unit, u8 addr[AVC_BRIDGECO_ADDR_BYTES], u8 *buf, unsigned int len) |