Re: f_uac2: why do you save two u8 in one u16?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 14, 2012 at 4:44 PM, Sebastian Andrzej Siewior
<sebastian@xxxxxxxxxxxxx> wrote:
> On Fri, Sep 14, 2012 at 12:53:56PM +0200, Sebastian Andrzej Siewior wrote:
>> looking at f_uac2.c I found this interresting piece of code:
>>
>> |struct audio_dev {
>> |         /* Currently active {Interface[15:8] | AltSettings[7:0]} */
>> |         __u16 ac_alt, as_out_alt, as_in_alt;
>> | 
>> |};
>> |
>> | 
>> |#define ALT_SET(x, a)   do {(x) &= ~0xff; (x) |= (a); } while (0)
>> |#define ALT_GET(x)      ((x) & 0xff)
>> |#define INTF_SET(x, i)  do {(x) &= 0xff; (x) |= ((i) << 8); } while (0)
>> |#define INTF_GET(x)     ((x >> 8) & 0xff)
>> | 
>> |    ALT_SET(agdev->as_out_alt, 0);
>> |    INTF_SET(agdev->as_out_alt, ret);
>> | 
>>
>> Could one of you two explain to me why smashing two different things (an
>> interface number and an alternative setting number) into one variable
>> and using a Macro to seperate them again was a good idea?
>
I don't see Interface and its AltSetting as different as you do.

> Another thing. alsa_uac2_init() calling platform_device_register() and
> platform_driver_register()? Why is that helpful can't you just call
> snd_uac2_probe() right away?
>
That is a common practice for virtual drivers (see
sound/drivers/dummy.c) and it helps assign the snd_card's "struct
device *".

> You have poor (read as non-existing) error recovery in case something
> goes wrong during the allocation endpoint/interface/request.
>
Please be more specific.

> What do I need to test this gadget?
>
insmod g_audio.ko   on gadget
connect usb cable
A new sound card will appear on each the Host and the Gadget. Use is
just like any other sound card. Playback on side could be captured on
the other or routed to speakers if your h/w has them.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux