Store the best_firmware_version in struct alsa_card

This commit is contained in:
Geoffrey D. Bennett
2024-03-12 02:11:21 +10:30
parent 6e40b8d9ed
commit 984133f61d
4 changed files with 6 additions and 9 deletions

View File

@@ -4,6 +4,7 @@
#include <sys/inotify.h>
#include "alsa.h"
#include "scarlett2-firmware.h"
#include "stringhelper.h"
#include "window-iface.h"
@@ -778,6 +779,7 @@ static void alsa_scan_cards(void) {
alsa_subscribe(card);
alsa_get_usbid(card);
alsa_get_serial_number(card);
card->best_firmware_version = scarlett2_get_best_firmware_version(card->pid);
if (card->serial) {

View File

@@ -155,6 +155,7 @@ struct alsa_card {
uint32_t pid;
char *serial;
char *name;
int best_firmware_version;
snd_ctl_t *handle;
struct pollfd pfd;
GArray *elems;

View File

@@ -25,10 +25,7 @@ GtkWidget *create_iface_update_main(struct alsa_card *card) {
gtk_widget_add_css_class(w, "window-title");
gtk_box_append(GTK_BOX(content), w);
uint32_t best_firmware_version =
scarlett2_get_best_firmware_version(card->pid);
if (!best_firmware_version) {
if (!card->best_firmware_version) {
w = gtk_label_new(NULL);
gtk_label_set_markup(
GTK_LABEL(w),

View File

@@ -5,7 +5,6 @@
#include "device-update-firmware.h"
#include "gtkhelper.h"
#include "scarlett2.h"
#include "scarlett2-firmware.h"
#include "scarlett2-ioctls.h"
#include "widget-boolean.h"
#include "window-startup.h"
@@ -273,10 +272,8 @@ static void add_reset_actions(
return;
int firmware_version = alsa_get_elem_value(firmware_elem);
uint32_t best_firmware_version =
scarlett2_get_best_firmware_version(card->pid);
if (firmware_version >= best_firmware_version)
if (firmware_version >= card->best_firmware_version)
return;
char *s = g_strdup_printf(
@@ -284,7 +281,7 @@ static void add_reset_actions(
"factory default settings and update the firmware from version "
"%d to %d.",
firmware_version,
best_firmware_version
card->best_firmware_version
);
add_reset_action(
card,