Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  *   This program is free software; you can redistribute it and/or modify
0004  *   it under the terms of the GNU General Public License as published by
0005  *   the Free Software Foundation; either version 2 of the License, or
0006  *   (at your option) any later version.
0007  *
0008  *   This program is distributed in the hope that it will be useful,
0009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0011  *   GNU General Public License for more details.
0012  */
0013 
0014 #ifndef __UAPI_SOUND_TLV_H
0015 #define __UAPI_SOUND_TLV_H
0016 
0017 #define SNDRV_CTL_TLVT_CONTAINER 0  /* one level down - group of TLVs */
0018 #define SNDRV_CTL_TLVT_DB_SCALE 1       /* dB scale */
0019 #define SNDRV_CTL_TLVT_DB_LINEAR 2  /* linear volume */
0020 #define SNDRV_CTL_TLVT_DB_RANGE 3   /* dB range container */
0021 #define SNDRV_CTL_TLVT_DB_MINMAX 4  /* dB scale with min/max */
0022 #define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */
0023 
0024 /*
0025  * channel-mapping TLV items
0026  *  TLV length must match with num_channels
0027  */
0028 #define SNDRV_CTL_TLVT_CHMAP_FIXED  0x101   /* fixed channel position */
0029 #define SNDRV_CTL_TLVT_CHMAP_VAR    0x102   /* channels freely swappable */
0030 #define SNDRV_CTL_TLVT_CHMAP_PAIRED 0x103   /* pair-wise swappable */
0031 
0032 /*
0033  * TLV structure is right behind the struct snd_ctl_tlv:
0034  *   unsigned int type      - see SNDRV_CTL_TLVT_*
0035  *   unsigned int length
0036  *   .... data aligned to sizeof(unsigned int), use
0037  *        block_length = (length + (sizeof(unsigned int) - 1)) &
0038  *                       ~(sizeof(unsigned int) - 1)) ....
0039  */
0040 #define SNDRV_CTL_TLVD_ITEM(type, ...) \
0041     (type), SNDRV_CTL_TLVD_LENGTH(__VA_ARGS__), __VA_ARGS__
0042 #define SNDRV_CTL_TLVD_LENGTH(...) \
0043     ((unsigned int)sizeof((const unsigned int[]) { __VA_ARGS__ }))
0044 
0045 /* Accessor offsets for TLV data items */
0046 #define SNDRV_CTL_TLVO_TYPE     0
0047 #define SNDRV_CTL_TLVO_LEN      1
0048 
0049 #define SNDRV_CTL_TLVD_CONTAINER_ITEM(...) \
0050     SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_CONTAINER, __VA_ARGS__)
0051 #define SNDRV_CTL_TLVD_DECLARE_CONTAINER(name, ...) \
0052     unsigned int name[] = { \
0053         SNDRV_CTL_TLVD_CONTAINER_ITEM(__VA_ARGS__) \
0054     }
0055 
0056 #define SNDRV_CTL_TLVD_DB_SCALE_MASK    0xffff
0057 #define SNDRV_CTL_TLVD_DB_SCALE_MUTE    0x10000
0058 #define SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \
0059     SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_SCALE, \
0060                 (min), \
0061                 ((step) & SNDRV_CTL_TLVD_DB_SCALE_MASK) | \
0062                  ((mute) ? SNDRV_CTL_TLVD_DB_SCALE_MUTE : 0))
0063 #define SNDRV_CTL_TLVD_DECLARE_DB_SCALE(name, min, step, mute) \
0064     unsigned int name[] = { \
0065         SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \
0066     }
0067 
0068 /* Accessor offsets for min, mute and step items in dB scale type TLV */
0069 #define SNDRV_CTL_TLVO_DB_SCALE_MIN     2
0070 #define SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP   3
0071 
0072 /* dB scale specified with min/max values instead of step */
0073 #define SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \
0074     SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX, (min_dB), (max_dB))
0075 #define SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
0076     SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX_MUTE, (min_dB), (max_dB))
0077 #define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(name, min_dB, max_dB) \
0078     unsigned int name[] = { \
0079         SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \
0080     }
0081 #define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX_MUTE(name, min_dB, max_dB) \
0082     unsigned int name[] = { \
0083         SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \
0084     }
0085 
0086 /* Accessor offsets for min, max items in db-minmax types of TLV. */
0087 #define SNDRV_CTL_TLVO_DB_MINMAX_MIN    2
0088 #define SNDRV_CTL_TLVO_DB_MINMAX_MAX    3
0089 
0090 /* linear volume between min_dB and max_dB (.01dB unit) */
0091 #define SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
0092     SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_LINEAR, (min_dB), (max_dB))
0093 #define SNDRV_CTL_TLVD_DECLARE_DB_LINEAR(name, min_dB, max_dB) \
0094     unsigned int name[] = { \
0095         SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \
0096     }
0097 
0098 /* Accessor offsets for min, max items in db-linear type of TLV. */
0099 #define SNDRV_CTL_TLVO_DB_LINEAR_MIN    2
0100 #define SNDRV_CTL_TLVO_DB_LINEAR_MAX    3
0101 
0102 /* dB range container:
0103  * Items in dB range container must be ordered by their values and by their
0104  * dB values. This implies that larger values must correspond with larger
0105  * dB values (which is also required for all other mixer controls).
0106  */
0107 /* Each item is: <min> <max> <TLV> */
0108 #define SNDRV_CTL_TLVD_DB_RANGE_ITEM(...) \
0109     SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_RANGE, __VA_ARGS__)
0110 #define SNDRV_CTL_TLVD_DECLARE_DB_RANGE(name, ...) \
0111     unsigned int name[] = { \
0112         SNDRV_CTL_TLVD_DB_RANGE_ITEM(__VA_ARGS__) \
0113     }
0114 
0115 #define SNDRV_CTL_TLVD_DB_GAIN_MUTE -9999999
0116 
0117 #endif