Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@zonque.org>
To: Damien Zammit <damien.zammit@gmail.com>, Mark Hills <mark@xwax.org>
Cc: alsa-devel@alsa-project.org, Clemens Ladisch <clemens@ladisch.de>
Subject: Re: [PATCH] ALSA: usb-audio - Capture and duplex support for Digidesign Mbox 1 sound card.
Date: Mon, 31 Mar 2014 19:47:53 +0200	[thread overview]
Message-ID: <5339AA49.6060906@zonque.org> (raw)
In-Reply-To: <53378DC2.3090603@gmail.com>

Hi Damien,

On 03/30/2014 05:21 AM, Damien Zammit wrote:
> On 30/03/14 09:57, Mark Hills wrote:
>> Thanks. I took a look and I think I have a similar concern to Daniel for 
>> readability. The code should really be shared with the quirk on a single 
>> endpoint.
> I guess a significant rewrite will be required.

Yeah, now that you changed the code to handle an arbitrary amount of
endpoints, you could as well change all user of
QUIRK_AUDIO_FIXED_ENDPOINT over to the new one, and initialize .epmulti
to 1. That should already work, right? (Though, I have to mention that
I'm unhappy with the name of that variable :)).

>> The duplicate code in the patch already has different handling of 
>> maxpacksize and datainterval -- is that intentional? It's apparent because 
>> the new code ignores the values given in the quirk.

That souldn't be the case then, of course.

> Not intentional, maxpacksize and datainterval happened to be identical
> for both endpoints on the Mbox.

So it's easy to change.

> Looking at the current struct for a snd_usb_audio_quirk:
> 
> struct snd_usb_audio_quirk {
>         const char *vendor_name;
>         const char *product_name;
>         int16_t ifnum;
>         uint16_t type;
>         const void *data;
> }
> 
> It is quite versatile, we shouldn't need to alter the quirk struct, just
> the data it holds.

A const void* can hold any kind of struct, and you need to cast it back
to your struct eventually anyway. Thinking about it again, I don't like
the idea of an extra member in struct snd_usb_audio_quirk either. What
would be nicer is to introduce something like this:

struct audioformats {
	unsigned int n_formats;
	const struct audioformat *format;
};

... and then define the quirk like this:

	.type = QUIRK_AUDIO_FIXED_MULTI_ENDPOINTS,
	.data = (const struct audioformats) {
		.n_formats = 2,
		.format = (const struct audioformat[]) {
			[0] = {
				.formats = SNDRV_PCM_FMTBIT_S24_3BE,
				...
			},
			[1] = {
				.formats = SNDRV_PCM_FMTBIT_S24_3BE,
				...
			},
		},
	}

IOW, encapsulate struct audioformat once more, so that the counter
variable is specific to this kind of quirk.

Also, you can write the actual quirk handler so that it loops over the
array entries, so you can re-use the code for both
QUIRK_AUDIO_FIXED_MULTI_ENDPOINTS and QUIRK_AUDIO_FIXED_ENDPOINT.

Do you follow? :)

>  Is an array of audioformats for this kind of
> interface the ideal choice?

Not sure whether I understand what you mean. Would be best to share a
patch that implements your idea.

> Also, maybe we can read bNumEndpoints to determine if it is a
> multi-endpoint interface and act accordingly, then we don't need an
> extra element in snd_usb_audio_quirk.

I think adding an array type is the best way to handle it.


Thanks,
Daniel

  reply	other threads:[~2014-03-31 17:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-26 15:10 [PATCH] ALSA: usb-audio - Capture and duplex support for Digidesign Mbox 1 sound card Damien Zammit
2014-01-26 15:30 ` Damien Zammit
2014-01-26 16:52 ` Clemens Ladisch
2014-01-27  3:02   ` Damien Zammit
2014-03-01  7:40     ` Damien Zammit
2014-03-03 21:01     ` Daniel Mack
2014-03-29  5:01       ` Mark Hills
2014-03-29 12:27         ` [alsa-devel] " Damien Zammit
2014-03-29 22:57           ` Mark Hills
2014-03-30  3:21             ` Damien Zammit
2014-03-31 17:47               ` Daniel Mack [this message]
2014-04-01  2:41                 ` Damien Zammit
2014-03-29  5:35       ` Damien Zammit
2014-03-31 17:58         ` Daniel Mack

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=5339AA49.6060906@zonque.org \
    --to=daniel@zonque.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=damien.zammit@gmail.com \
    --cc=mark@xwax.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox