1d5ac70f0Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 2d5ac70f0Sopenharmony_ci/* 3d5ac70f0Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 4d5ac70f0Sopenharmony_ci * it under the terms of the GNU General Public License as published by 5d5ac70f0Sopenharmony_ci * the Free Software Foundation; either version 2 of the License, or 6d5ac70f0Sopenharmony_ci * (at your option) any later version. 7d5ac70f0Sopenharmony_ci * 8d5ac70f0Sopenharmony_ci * This program is distributed in the hope that it will be useful, 9d5ac70f0Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 10d5ac70f0Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11d5ac70f0Sopenharmony_ci * GNU General Public License for more details. 12d5ac70f0Sopenharmony_ci */ 13d5ac70f0Sopenharmony_ci 14d5ac70f0Sopenharmony_ci#ifndef __UAPI_SOUND_TLV_H 15d5ac70f0Sopenharmony_ci#define __UAPI_SOUND_TLV_H 16d5ac70f0Sopenharmony_ci 17d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_CONTAINER 0 /* one level down - group of TLVs */ 18d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_DB_SCALE 1 /* dB scale */ 19d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_DB_LINEAR 2 /* linear volume */ 20d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_DB_RANGE 3 /* dB range container */ 21d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_DB_MINMAX 4 /* dB scale with min/max */ 22d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_DB_MINMAX_MUTE 5 /* dB scale with min/max with mute */ 23d5ac70f0Sopenharmony_ci 24d5ac70f0Sopenharmony_ci/* 25d5ac70f0Sopenharmony_ci * channel-mapping TLV items 26d5ac70f0Sopenharmony_ci * TLV length must match with num_channels 27d5ac70f0Sopenharmony_ci */ 28d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_CHMAP_FIXED 0x101 /* fixed channel position */ 29d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_CHMAP_VAR 0x102 /* channels freely swappable */ 30d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVT_CHMAP_PAIRED 0x103 /* pair-wise swappable */ 31d5ac70f0Sopenharmony_ci 32d5ac70f0Sopenharmony_ci/* 33d5ac70f0Sopenharmony_ci * TLV structure is right behind the struct snd_ctl_tlv: 34d5ac70f0Sopenharmony_ci * unsigned int type - see SNDRV_CTL_TLVT_* 35d5ac70f0Sopenharmony_ci * unsigned int length 36d5ac70f0Sopenharmony_ci * .... data aligned to sizeof(unsigned int), use 37d5ac70f0Sopenharmony_ci * block_length = (length + (sizeof(unsigned int) - 1)) & 38d5ac70f0Sopenharmony_ci * ~(sizeof(unsigned int) - 1)) .... 39d5ac70f0Sopenharmony_ci */ 40d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_ITEM(type, ...) \ 41d5ac70f0Sopenharmony_ci (type), SNDRV_CTL_TLVD_LENGTH(__VA_ARGS__), __VA_ARGS__ 42d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_LENGTH(...) \ 43d5ac70f0Sopenharmony_ci ((unsigned int)sizeof((const unsigned int[]) { __VA_ARGS__ })) 44d5ac70f0Sopenharmony_ci 45d5ac70f0Sopenharmony_ci/* Accessor offsets for TLV data items */ 46d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVO_TYPE 0 47d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVO_LEN 1 48d5ac70f0Sopenharmony_ci 49d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_CONTAINER_ITEM(...) \ 50d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_CONTAINER, __VA_ARGS__) 51d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DECLARE_CONTAINER(name, ...) \ 52d5ac70f0Sopenharmony_ci unsigned int name[] = { \ 53d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_CONTAINER_ITEM(__VA_ARGS__) \ 54d5ac70f0Sopenharmony_ci } 55d5ac70f0Sopenharmony_ci 56d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DB_SCALE_MASK 0xffff 57d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DB_SCALE_MUTE 0x10000 58d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \ 59d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_SCALE, \ 60d5ac70f0Sopenharmony_ci (min), \ 61d5ac70f0Sopenharmony_ci ((step) & SNDRV_CTL_TLVD_DB_SCALE_MASK) | \ 62d5ac70f0Sopenharmony_ci ((mute) ? SNDRV_CTL_TLVD_DB_SCALE_MUTE : 0)) 63d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DECLARE_DB_SCALE(name, min, step, mute) \ 64d5ac70f0Sopenharmony_ci unsigned int name[] = { \ 65d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_DB_SCALE_ITEM(min, step, mute) \ 66d5ac70f0Sopenharmony_ci } 67d5ac70f0Sopenharmony_ci 68d5ac70f0Sopenharmony_ci/* Accessor offsets for min, mute and step items in dB scale type TLV */ 69d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVO_DB_SCALE_MIN 2 70d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVO_DB_SCALE_MUTE_AND_STEP 3 71d5ac70f0Sopenharmony_ci 72d5ac70f0Sopenharmony_ci/* dB scale specified with min/max values instead of step */ 73d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \ 74d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX, (min_dB), (max_dB)) 75d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \ 76d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_MINMAX_MUTE, (min_dB), (max_dB)) 77d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX(name, min_dB, max_dB) \ 78d5ac70f0Sopenharmony_ci unsigned int name[] = { \ 79d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_DB_MINMAX_ITEM(min_dB, max_dB) \ 80d5ac70f0Sopenharmony_ci } 81d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DECLARE_DB_MINMAX_MUTE(name, min_dB, max_dB) \ 82d5ac70f0Sopenharmony_ci unsigned int name[] = { \ 83d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_DB_MINMAX_MUTE_ITEM(min_dB, max_dB) \ 84d5ac70f0Sopenharmony_ci } 85d5ac70f0Sopenharmony_ci 86d5ac70f0Sopenharmony_ci/* Accessor offsets for min, max items in db-minmax types of TLV. */ 87d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVO_DB_MINMAX_MIN 2 88d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVO_DB_MINMAX_MAX 3 89d5ac70f0Sopenharmony_ci 90d5ac70f0Sopenharmony_ci/* linear volume between min_dB and max_dB (.01dB unit) */ 91d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \ 92d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_LINEAR, (min_dB), (max_dB)) 93d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DECLARE_DB_LINEAR(name, min_dB, max_dB) \ 94d5ac70f0Sopenharmony_ci unsigned int name[] = { \ 95d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_DB_LINEAR_ITEM(min_dB, max_dB) \ 96d5ac70f0Sopenharmony_ci } 97d5ac70f0Sopenharmony_ci 98d5ac70f0Sopenharmony_ci/* Accessor offsets for min, max items in db-linear type of TLV. */ 99d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVO_DB_LINEAR_MIN 2 100d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVO_DB_LINEAR_MAX 3 101d5ac70f0Sopenharmony_ci 102d5ac70f0Sopenharmony_ci/* dB range container: 103d5ac70f0Sopenharmony_ci * Items in dB range container must be ordered by their values and by their 104d5ac70f0Sopenharmony_ci * dB values. This implies that larger values must correspond with larger 105d5ac70f0Sopenharmony_ci * dB values (which is also required for all other mixer controls). 106d5ac70f0Sopenharmony_ci */ 107d5ac70f0Sopenharmony_ci/* Each item is: <min> <max> <TLV> */ 108d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DB_RANGE_ITEM(...) \ 109d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_ITEM(SNDRV_CTL_TLVT_DB_RANGE, __VA_ARGS__) 110d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DECLARE_DB_RANGE(name, ...) \ 111d5ac70f0Sopenharmony_ci unsigned int name[] = { \ 112d5ac70f0Sopenharmony_ci SNDRV_CTL_TLVD_DB_RANGE_ITEM(__VA_ARGS__) \ 113d5ac70f0Sopenharmony_ci } 114d5ac70f0Sopenharmony_ci 115d5ac70f0Sopenharmony_ci#define SNDRV_CTL_TLVD_DB_GAIN_MUTE -9999999 116d5ac70f0Sopenharmony_ci 117d5ac70f0Sopenharmony_ci#endif 118