From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 970EEC433EF for ; Mon, 25 Apr 2022 19:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244886AbiDYTTl (ORCPT ); Mon, 25 Apr 2022 15:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244900AbiDYTTk (ORCPT ); Mon, 25 Apr 2022 15:19:40 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 445C070933 for ; Mon, 25 Apr 2022 12:16:32 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id y11so10009521ilp.4 for ; Mon, 25 Apr 2022 12:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=79En++Vr1sBSFe95ZCwf7O++Q0VkaYApBB88Isyd460=; b=bzG3eZUlAl0ggoOzuuLI5O1WhDZS9GQJIaFV+7UtNOc1o1feP84SPW4ERFgXkv4Ro5 6csM937vKr0j+oqPsbd2/0mWPwHuO12L5x4s/HUAVf9J0RdWR/zuqfwaJnt0SIfMQbup 54RpeG6bXZFjOMuMbCt5BvYJOnW72UpNFiwOW2jSMCXHMTAsMsCQ/fjitGFPqq1TNSDN ez2ePnzRAvQl6wpERPaN8A/0irDpz5aCrlGfqLtdXeXsf8FJeG9HLdnyvsuD2bZUcBJj +Ci1otaIuU9AwvgUvjO8+x0YkHXeCTugK15hVml1zqHppha012lY8mirasG4D892yQXk EQkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=79En++Vr1sBSFe95ZCwf7O++Q0VkaYApBB88Isyd460=; b=junRxUceUtpOtXKbcn20FEcJO9MdaeuK2CW9dEFPEEYzjXNpVDrOyYMzb8gummJi8P ZYnAHFKHDNERmC4QkKzLMQeWtrG0KZHEBuZ9wIuEFqpO3OWvZo8tkKs1n/vt+vdKKVNW cI7JHykF3bj1MLbtXjCnURZ6SrIgM8Ed9BMSilGGU8Koo5uaKGvyGSUccWKeck/2AjvE ApRmeDSCXd9TG9kPyewaBWWF0CFuV4KZXbR6CuB+6faic6Jx+ad/XQIxvAHAd7BxER98 kXhDFN8We9WMmfZix1OGaa2G2sJSZy8UYwpvWFMY9aWoH5ohfZy50tRwV2OXgIYm0KHO PhgA== X-Gm-Message-State: AOAM53147aq1T47XtiwoPidxIct1nnmL6k1fzijDaCnP6QRG6Nhh4Tsb zRDLTnU9tzMY+MKyADZOvPI= X-Google-Smtp-Source: ABdhPJwAjDo4Y58LSzhwSJX4OrL4YeclpJC1tFCkJC7k94r0WLOgi/9zgr5Et8wZVl0oSYsymhx36g== X-Received: by 2002:a92:cccb:0:b0:2c2:7641:ed49 with SMTP id u11-20020a92cccb000000b002c27641ed49mr7662663ilq.271.1650914191606; Mon, 25 Apr 2022 12:16:31 -0700 (PDT) Received: from localhost.localdomain (cpe-65-29-252-111.wi.res.rr.com. [65.29.252.111]) by smtp.gmail.com with ESMTPSA id m14-20020a92c52e000000b002cd804f045dsm5322842ili.1.2022.04.25.12.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 12:16:31 -0700 (PDT) From: Daniel Kaehn To: tiwai@suse.com Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, Daniel Kaehn Subject: [PATCH v4 0/2] Add generic serial MIDI driver using serial bus API Date: Mon, 25 Apr 2022 14:16:01 -0500 Message-Id: <20220425191602.770932-1-kaehndan@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Generic serial MIDI driver adding support for using serial devices compatible with the serial bus as raw MIDI devices, allowing using additional serial devices not compatible with the existing serial-u16550 driver. Supports only setting standard serial baudrates on the underlying serial device; however, the underlying serial device can be configured so that a requested 38.4 kBaud is actually the standard MIDI 31.25 kBaud. Supports DeviceTree configuration. Changes in v4: - Fix regressed typo - Correct 3.84 kBaud -> 38.4 kBaud in DT & Kconfig (sorry about spam - noticed after sending v3 and didn't want to let the error sit around for too long) Changes in v3: - Replace use of snd_printk() with dev_* alternatives - Removed unnecessary initialization of err variables - Replaced instances of `== SERIAL_MODE_NOT_OPENED` with zero check - Loop on output_write to completely fill output buffer if data available - Depend on CONFIG_OF in Kconfig - Replace use of devm_kzalloc() with extra_size allocation in snd_devm_card_new() - Use module_serdev_device_driver() instead of module_init() and module_exit(0) Changes in v2: - Fix 'snd_serial_generic_write_wakeup' missing static keyword - Correct 3.125 kBaud > 31.25 kBaud in documentation for MIDI The need for this driver arose from a project using a Raspberry Pi4 which needed to receive and send raw MIDI with low latency. The pl011 UART used is not compatible with the existing serial MIDI driver made for u16550-style devices. Using a userspace program such as ttymidi to feed input from the TTY device to a virtual ALSA MIDI device was functional, but not ideal. I am not sure if a MIDI driver needing the mentioned 'hack' to clock 38.4 kBaud down to the standard MIDI baud is permissible in the mainline kernel, but am submitting nevertheless in case it is useful. To my knowledge, it doesn't seem that there would be any way for this driver to manually configure a serial port to 31.25 kBaud using the serial bus API (please correct me f I'm wrong). In my use case, I am actually configuring one port to run at 115.2 kBaud for faster communication with a custom onboard MIDI controller. Daniel Kaehn (2): dt-bindings: sound: Add generic serial MIDI device Add generic serial MIDI driver using serial bus API .../devicetree/bindings/sound/serialmidi.yaml | 41 +++ sound/drivers/Kconfig | 18 + sound/drivers/Makefile | 2 + sound/drivers/serial-generic.c | 319 ++++++++++++++++++ 4 files changed, 380 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/serialmidi.yaml create mode 100644 sound/drivers/serial-generic.c base-commit: d615b5416f8a1afeb82d13b238f8152c572d59c0 -- 2.33.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C2EBC433EF for ; Mon, 25 Apr 2022 19:17:30 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 49AE5181A; Mon, 25 Apr 2022 21:16:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 49AE5181A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1650914248; bh=ZrxApqOb0Tv/rc6pCzD6ZmCES1t4dQpoPJa0p2npixs=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=OBMzEt3uiFJSueX6TVLh4KLCqzUINfkr4PksRxMoQ8wdKDJaCeSsPP9WfeY8KrlA6 QCijNufd/ZqO/fZjiW22qcZ6OSuZq4SMYA4vbczCrlvkhDTAjtIA787ffnRCP2Zo6C MwfvUCeuN7Og6rRklGwl6MLANi8hg6rd9WJ+7OcQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D1447F80152; Mon, 25 Apr 2022 21:16:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7C879F8016A; Mon, 25 Apr 2022 21:16:36 +0200 (CEST) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D5447F800FA for ; Mon, 25 Apr 2022 21:16:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D5447F800FA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bzG3eZUl" Received: by mail-il1-x130.google.com with SMTP id d3so9988615ilr.10 for ; Mon, 25 Apr 2022 12:16:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=79En++Vr1sBSFe95ZCwf7O++Q0VkaYApBB88Isyd460=; b=bzG3eZUlAl0ggoOzuuLI5O1WhDZS9GQJIaFV+7UtNOc1o1feP84SPW4ERFgXkv4Ro5 6csM937vKr0j+oqPsbd2/0mWPwHuO12L5x4s/HUAVf9J0RdWR/zuqfwaJnt0SIfMQbup 54RpeG6bXZFjOMuMbCt5BvYJOnW72UpNFiwOW2jSMCXHMTAsMsCQ/fjitGFPqq1TNSDN ez2ePnzRAvQl6wpERPaN8A/0irDpz5aCrlGfqLtdXeXsf8FJeG9HLdnyvsuD2bZUcBJj +Ci1otaIuU9AwvgUvjO8+x0YkHXeCTugK15hVml1zqHppha012lY8mirasG4D892yQXk EQkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=79En++Vr1sBSFe95ZCwf7O++Q0VkaYApBB88Isyd460=; b=ig26v9IJgMupyXbhS7qqKxh2vBPAXeizVxjSUFVyOse4GcDc+PB5xlrDQPPIUhvMs2 XUx1pIU40iuuMsMJtP8ZJwDT9yjwY25BAcQO4uHnqSaVb5YA9jKNoP5IyGKx4/OAS+zh nXIfNj4dukEDWTeZiFs9PNlUkFS+vC78HtSUdyVzqkWlQyKLOG9v+v4J9180UhqBmBQi AZO4Emo2xGVk3NOYCJzgkzftBimM5f256AjwryYB9Pe4jGCg0EaplOwOO9JbhzoXKPSm CGG1Nep/Vs21NFQsF3mFoZc2u0NY6Gt/00H5f8xke65jTzBoo3XN8gChVW1lllEPwECS 18ng== X-Gm-Message-State: AOAM532XVyzndulpjTO3hGfLxJII5l6FHwQTYMnx+oV+SIsxoQBMnZTe LFXDhJ4TrneSRRuNMI0sIPE= X-Google-Smtp-Source: ABdhPJwAjDo4Y58LSzhwSJX4OrL4YeclpJC1tFCkJC7k94r0WLOgi/9zgr5Et8wZVl0oSYsymhx36g== X-Received: by 2002:a92:cccb:0:b0:2c2:7641:ed49 with SMTP id u11-20020a92cccb000000b002c27641ed49mr7662663ilq.271.1650914191606; Mon, 25 Apr 2022 12:16:31 -0700 (PDT) Received: from localhost.localdomain (cpe-65-29-252-111.wi.res.rr.com. [65.29.252.111]) by smtp.gmail.com with ESMTPSA id m14-20020a92c52e000000b002cd804f045dsm5322842ili.1.2022.04.25.12.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 12:16:31 -0700 (PDT) From: Daniel Kaehn To: tiwai@suse.com Subject: [PATCH v4 0/2] Add generic serial MIDI driver using serial bus API Date: Mon, 25 Apr 2022 14:16:01 -0500 Message-Id: <20220425191602.770932-1-kaehndan@gmail.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Daniel Kaehn X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Generic serial MIDI driver adding support for using serial devices compatible with the serial bus as raw MIDI devices, allowing using additional serial devices not compatible with the existing serial-u16550 driver. Supports only setting standard serial baudrates on the underlying serial device; however, the underlying serial device can be configured so that a requested 38.4 kBaud is actually the standard MIDI 31.25 kBaud. Supports DeviceTree configuration. Changes in v4: - Fix regressed typo - Correct 3.84 kBaud -> 38.4 kBaud in DT & Kconfig (sorry about spam - noticed after sending v3 and didn't want to let the error sit around for too long) Changes in v3: - Replace use of snd_printk() with dev_* alternatives - Removed unnecessary initialization of err variables - Replaced instances of `== SERIAL_MODE_NOT_OPENED` with zero check - Loop on output_write to completely fill output buffer if data available - Depend on CONFIG_OF in Kconfig - Replace use of devm_kzalloc() with extra_size allocation in snd_devm_card_new() - Use module_serdev_device_driver() instead of module_init() and module_exit(0) Changes in v2: - Fix 'snd_serial_generic_write_wakeup' missing static keyword - Correct 3.125 kBaud > 31.25 kBaud in documentation for MIDI The need for this driver arose from a project using a Raspberry Pi4 which needed to receive and send raw MIDI with low latency. The pl011 UART used is not compatible with the existing serial MIDI driver made for u16550-style devices. Using a userspace program such as ttymidi to feed input from the TTY device to a virtual ALSA MIDI device was functional, but not ideal. I am not sure if a MIDI driver needing the mentioned 'hack' to clock 38.4 kBaud down to the standard MIDI baud is permissible in the mainline kernel, but am submitting nevertheless in case it is useful. To my knowledge, it doesn't seem that there would be any way for this driver to manually configure a serial port to 31.25 kBaud using the serial bus API (please correct me f I'm wrong). In my use case, I am actually configuring one port to run at 115.2 kBaud for faster communication with a custom onboard MIDI controller. Daniel Kaehn (2): dt-bindings: sound: Add generic serial MIDI device Add generic serial MIDI driver using serial bus API .../devicetree/bindings/sound/serialmidi.yaml | 41 +++ sound/drivers/Kconfig | 18 + sound/drivers/Makefile | 2 + sound/drivers/serial-generic.c | 319 ++++++++++++++++++ 4 files changed, 380 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/serialmidi.yaml create mode 100644 sound/drivers/serial-generic.c base-commit: d615b5416f8a1afeb82d13b238f8152c572d59c0 -- 2.33.0