[PATCH 1/2] ALSA: emu10k1: add a capability bit for no MIDI

Icenowy Zheng posted 2 patches 1 month, 2 weeks ago
[PATCH 1/2] ALSA: emu10k1: add a capability bit for no MIDI
Posted by Icenowy Zheng 1 month, 2 weeks ago
Audigy Rx is a card born in the era that USB MIDI has been the
mainstream form of PC MIDI interface, and no external MIDI I/O is made
available on Audigy Rx.

Add a capability bit for emu10k1 driver to be able to hide the MPU-401
ports.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
---
 include/sound/emu10k1.h     | 1 +
 sound/pci/emu10k1/emu10k1.c | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 38db50b280eba..9172674838627 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -1673,6 +1673,7 @@ struct snd_emu_chip_details {
 	unsigned int i2c_adc:1;		/* I2C interface for ADC; requires ca0108_chip */
 	unsigned int adc_1361t:1;	/* Use Philips 1361T ADC */
 	unsigned int invert_shared_spdif:1;  /* analog/digital switch inverted */
+	unsigned int no_midi:1;		/* Has no MIDI */
 	const char *driver;
 	const char *name;
 	const char *id;		/* for backward compatibility - can be NULL if not needed */
diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c
index dadeda7758cee..d323ebbc0368f 100644
--- a/sound/pci/emu10k1/emu10k1.c
+++ b/sound/pci/emu10k1/emu10k1.c
@@ -133,7 +133,9 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
 		if (err < 0)
 			return err;
 	}
-	if (emu->audigy) {
+	if (emu->card_capabilities->no_midi) {
+		dev_info(emu->card->dev, "Card has no ext. MIDI ports.\n");
+	} else if (emu->audigy) {
 		err = snd_emu10k1_audigy_midi(emu);
 		if (err < 0)
 			return err;
-- 
2.47.0
Re: [PATCH 1/2] ALSA: emu10k1: add a capability bit for no MIDI
Posted by Oswald Buddenhagen 1 month, 2 weeks ago
On Sun, Oct 13, 2024 at 09:47:12AM +0800, Icenowy Zheng wrote:
>+++ b/sound/pci/emu10k1/emu10k1.c
>@@ -133,7 +133,9 @@ static int snd_card_emu10k1_probe(struct pci_dev *pci,
> 		if (err < 0)
> 			return err;
> 	}
>-	if (emu->audigy) {
>+	if (emu->card_capabilities->no_midi) {
>+		dev_info(emu->card->dev, "Card has no ext. MIDI ports.\n");
>
seems like excess verbosity. there are much more important things that
are not reported.

>+	} else if (emu->audigy) {
>
i would eliminate that, and instead populate the card table properly.
that's a bit more code, but it's more uniform, and the resulting binary
is even a tiny bit smaller.

also, i would squash the patches, as i see no point in having them
separate, given their size.

regards
Re: [PATCH 1/2] ALSA: emu10k1: add a capability bit for no MIDI
Posted by Icenowy Zheng 1 month, 2 weeks ago
在 2024-10-13星期日的 11:54 +0200,Oswald Buddenhagen写道:
> On Sun, Oct 13, 2024 at 09:47:12AM +0800, Icenowy Zheng wrote:
> > +++ b/sound/pci/emu10k1/emu10k1.c
> > @@ -133,7 +133,9 @@ static int snd_card_emu10k1_probe(struct
> > pci_dev *pci,
> >                 if (err < 0)
> >                         return err;
> >         }
> > -       if (emu->audigy) {
> > +       if (emu->card_capabilities->no_midi) {
> > +               dev_info(emu->card->dev, "Card has no ext. MIDI
> > ports.\n");
> > 
> seems like excess verbosity. there are much more important things
> that
> are not reported.
> 
> > +       } else if (emu->audigy) {
> > 
> i would eliminate that, and instead populate the card table properly.
> that's a bit more code, but it's more uniform, and the resulting
> binary
> is even a tiny bit smaller.

Well in fact I just insert this here to prevent a re-indent of the
following MIDI code.

Well it could be better to be a 
```
if (!emu->card_capabilities->no_midi) {
        The original code
}
```

> 
> also, i would squash the patches, as i see no point in having them
> separate, given their size.
> 
> regards