From mboxrd@z Thu Jan 1 00:00:00 1970 From: Clemens Ladisch Subject: Re: How to add a new MIDI device to the usbaudio driver Date: Wed, 24 Aug 2011 21:51:34 +0200 Message-ID: <4E555646.2030209@ladisch.de> References: <4E5234F0.8000502@amlie.name> <4E52401C.8030605@amlie.name> <4E537524.9010303@ladisch.de> <4E537BE9.4050004@amlie.name> <4E53959A.7090702@amlie.name> <4E53A748.4070404@amlie.name> <4E53AAE4.2070303@amlie.name> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com [66.111.4.27]) by alsa0.perex.cz (Postfix) with ESMTP id 6B358244B8 for ; Wed, 24 Aug 2011 21:51:57 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Kristian Amlie Cc: alsa-devel@alsa-project.org, Daniel Mack List-Id: alsa-devel@alsa-project.org Daniel Mack wrote: > Ok, then let's try the attached patch. > + /* reset the port */ > + err = snd_usbmidi_ftdi_command(umidi, 0, 0); > + if (err < 0) > + break; > + > + /* set mctrl */ > + err = snd_usbmidi_ftdi_command(umidi, 1, 0x303); > + if (err < 0) > + break; The chip reads its initial configuration from the EEPROM, so these commands might not be necessary. > + /* set baud rate */ > + err = snd_usbmidi_ftdi_command(umidi, 3, 0xc04e); Replace 0xc04e with 0x60 to get exactly 31250 baud. Furthermore, the FT232RL chip sends two modem status bytes in its packets, so we need something like this to prevent them from being interpreted as MIDI: --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -791,7 +791,8 @@ static struct usb_protocol_ops snd_usbmidi_novation_ops = { static void snd_usbmidi_raw_input(struct snd_usb_midi_in_endpoint* ep, uint8_t* buffer, int buffer_length) { - snd_usbmidi_input_data(ep, 0, buffer, buffer_length); + if (buffer_length > 2) + snd_usbmidi_input_data(ep, 0, buffer + 2, buffer_length - 2); } static void snd_usbmidi_raw_output(struct snd_usb_midi_out_endpoint* ep, Regards, Clemens