On 2016年09月03日 00:58, Takashi Iwai wrote:
On Fri, 02 Sep 2016 16:11:30 +0200, Takashi Sakamoto wrote:
On Aug 30 2016 16:24, Clemens Ladisch wrote:
In the kernel, you could use the macros from include/sound/tlv.h.
Either copy them into your test program, and use them directly:
/* 4 words: */ DECLARE_TLV_DB_MINMAX(orig, -60, +60); /* container with only one subitem; 8 words: */ DECLARE_TLV_CONTAINER(orig_container, TLV_ITEM(SNDRV_CTL_TLVT_CHMAP_FIXED, SNDRV_CHMAP_FL, SNDRV_CHMAP_FR, SNDRV_CHMAP_FC, SNDRV_CHMAP_LFE) );
or create the values by hand:
orig[0] = SNDRV_CTL_TLVT_DB_MINMAX; orig[1] = 2 * sizeof(*orig); orig[2] = -60; orig[3] = +60;
orig_container[0] = SNDRV_CTL_TLVT_CONTAINER; orig_container[1] = 6 * sizeof(*orig_container); orig_container[2] = SNDRV_CTL_TLVT_CHMAP_FIXED; orig_container[3] = 4 * sizeof(*orig_container); orig_container[4] = SNDRV_CHMAP_FL orig_container[5] = SNDRV_CHMAP_FR; orig_container[6] = SNDRV_CHMAP_FC; orig_container[7] = SNDRV_CHMAP_LFE;
Mmm. For user-defined control element sets, these macros should be in UAPI.
(Also these macros were recently already put in uapi/include/sound.)
Ah, sorry, I addressed to macros such as DECLARE_TLV_DB_MINMAX, because the array is preprocessed the macro.
The macros are for static data, and for user-space, it's better to have functions filling the TLV, IMO.
In a point of maintenance, it's preferable that a single file gives the feature. No need to have several files for exactly the same feature.
Of course, we can move the macros to UAPI and give inline function APIs for applications to expand with the macros. But, this is a bit dull approach to me.
Regards
Takashi Sakamoto