From: "Geoffrey D. Bennett" <g@b4.vu>
To: Takashi Iwai <tiwai@suse.de>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
alsa-devel@alsa-project.org, linux-sound@vger.kernel.org
Subject: [PATCH 00/11] ALSA: scarlett2: Firmware Upgrade and Error Handling Improvements
Date: Wed, 20 Dec 2023 04:06:04 +1030 [thread overview]
Message-ID: <cover.1703001053.git.g@b4.vu> (raw)
Hi Takashi,
11 patches to improve error handling and add firmware upgrade support
to the scarlett2 driver. The notes below incorporate your feedback &
include answers to your questions in response to my previous RFC v2
email.
Patch 1 adds GitHub links for the repo where I share this code before
submission here, and for issue reporting.
Patches 2-5 add missing error/bounds checks.
Patch 6 adds a missing lock.
Patches 7-11 add support for firmware upgrades.
The usage of the hwdep interface is as per my previous proposal:
- ioctl pversion to check the protocol version
- ioctl select_flash_segment SCARLETT2_SEGMENT_ID_SETTINGS
- ioctl erase_flash_segment
- ioctl get_erase_progress (optional)
- ioctl select_flash_segment SCARLETT2_SEGMENT_ID_FIRMWARE
- ioctl erase_flash_segment
- ioctl get_erase_progress (optional)
- write() the firmware
- ioctl reboot
Notes on the hwdep interface:
- Conflicting mixer operations are denied with EBUSY.
- The hwdep interface is marked as exclusive so there can't be
conflicting hwdep operations.
- Invalid sequences of operations (e.g. erase before select, write
before erase) return an error.
- The erase operation is asynchronous, and the progress can optionally
be monitored by calling get_erase_progress.
- If the erase progress is not monitored then subsequent hwdep
operations will wait until the erase is complete.
- The write operation is synchronous, but <1KB can be written per
call, and it returns very quickly. On the user-side it looks like
this with error checking omitted:
while (offset < len)
offset += snd_hwdep_write(hwdep, buf + offset, len - offset);
- By using a subset of the firmware-upgrade steps, other useful
high-level operations can be performed: reset-to-factory-defaults,
reset-to-factory-firmware, or just reboot.
- I considered combining the select and erase operations, but that
would prevent a future read-flash operation if that ever become
possible.
- I considered separate one-shot ioctls for reset-to-factory, etc.,
but that prevents providing progress feedback.
- In case the purpose of the other firmware segments is discovered in
the future, this implementation would be able to support
erase/write/read of them with minimal changes.
Here is a user-space implementation of all of the above:
https://github.com/geoffreybennett/scarlett2
This has been tested by me on every supported Scarlett 2nd, 3rd, 4th
Gen and Clarett+ device, and tested by a handful of others on their
Scarlett 4th Gen devices.
Thanks,
Geoffrey.
Geoffrey D. Bennett (11):
ALSA: scarlett2: Update maintainer info
ALSA: scarlett2: Add missing error check to scarlett2_config_save()
ALSA: scarlett2: Add missing error check to scarlett2_usb_set_config()
ALSA: scarlett2: Add missing error checks to *_ctl_get()
ALSA: scarlett2: Add clamp() in scarlett2_mixer_ctl_put()
ALSA: scarlett2: Add missing mutex lock around get meter levels
ALSA: scarlett2: Add #defines for firmware upgrade
ALSA: scarlett2: Retrieve useful flash segment numbers
ALSA: scarlett2: Add skeleton hwdep/ioctl interface
ALSA: scarlett2: Add ioctl commands to erase flash segments
ALSA: scarlett2: Add support for uploading new firmware
MAINTAINERS | 7 +-
include/uapi/sound/scarlett2.h | 54 ++
sound/usb/mixer_scarlett2.c | 914 ++++++++++++++++++++++++++++++---
3 files changed, 901 insertions(+), 74 deletions(-)
create mode 100644 include/uapi/sound/scarlett2.h
--
2.43.0
next reply other threads:[~2023-12-19 17:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 17:36 Geoffrey D. Bennett [this message]
2023-12-19 17:36 ` [PATCH 01/11] ALSA: scarlett2: Update maintainer info Geoffrey D. Bennett
2023-12-19 17:37 ` [PATCH 02/11] ALSA: scarlett2: Add missing error check to scarlett2_config_save() Geoffrey D. Bennett
2023-12-19 17:37 ` [PATCH 03/11] ALSA: scarlett2: Add missing error check to scarlett2_usb_set_config() Geoffrey D. Bennett
2023-12-19 17:37 ` [PATCH 04/11] ALSA: scarlett2: Add missing error checks to *_ctl_get() Geoffrey D. Bennett
2023-12-19 17:37 ` [PATCH 05/11] ALSA: scarlett2: Add clamp() in scarlett2_mixer_ctl_put() Geoffrey D. Bennett
2023-12-19 17:38 ` [PATCH 06/11] ALSA: scarlett2: Add missing mutex lock around get meter levels Geoffrey D. Bennett
2023-12-19 17:38 ` [PATCH 07/11] ALSA: scarlett2: Add #defines for firmware upgrade Geoffrey D. Bennett
2023-12-19 17:38 ` [PATCH 08/11] ALSA: scarlett2: Retrieve useful flash segment numbers Geoffrey D. Bennett
2023-12-19 17:39 ` [PATCH 09/11] ALSA: scarlett2: Add skeleton hwdep/ioctl interface Geoffrey D. Bennett
2023-12-19 17:50 ` [PATCH 10/11] ALSA: scarlett2: Add ioctl commands to erase flash segments Geoffrey D. Bennett
2023-12-19 17:50 ` [PATCH 11/11] ALSA: scarlett2: Add support for uploading new firmware Geoffrey D. Bennett
2023-12-29 12:19 ` [PATCH v2 " Geoffrey D. Bennett
2023-12-29 15:08 ` [PATCH 00/11] ALSA: scarlett2: Firmware Upgrade and Error Handling Improvements Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1703001053.git.g@b4.vu \
--to=g@b4.vu \
--cc=alsa-devel@alsa-project.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.