18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Driver for Digigram miXart soundcards
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * mixer callbacks
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (c) 2003 by Digigram <alsa@digigram.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/time.h>
118c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
128c2ecf20Sopenharmony_ci#include <linux/init.h>
138c2ecf20Sopenharmony_ci#include <linux/mutex.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <sound/core.h>
168c2ecf20Sopenharmony_ci#include "mixart.h"
178c2ecf20Sopenharmony_ci#include "mixart_core.h"
188c2ecf20Sopenharmony_ci#include "mixart_hwdep.h"
198c2ecf20Sopenharmony_ci#include <sound/control.h>
208c2ecf20Sopenharmony_ci#include <sound/tlv.h>
218c2ecf20Sopenharmony_ci#include "mixart_mixer.h"
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic const u32 mixart_analog_level[256] = {
248c2ecf20Sopenharmony_ci	0xc2c00000,		/* [000] -96.0 dB */
258c2ecf20Sopenharmony_ci	0xc2bf0000,		/* [001] -95.5 dB */
268c2ecf20Sopenharmony_ci	0xc2be0000,		/* [002] -95.0 dB */
278c2ecf20Sopenharmony_ci	0xc2bd0000,		/* [003] -94.5 dB */
288c2ecf20Sopenharmony_ci	0xc2bc0000,		/* [004] -94.0 dB */
298c2ecf20Sopenharmony_ci	0xc2bb0000,		/* [005] -93.5 dB */
308c2ecf20Sopenharmony_ci	0xc2ba0000,		/* [006] -93.0 dB */
318c2ecf20Sopenharmony_ci	0xc2b90000,		/* [007] -92.5 dB */
328c2ecf20Sopenharmony_ci	0xc2b80000,		/* [008] -92.0 dB */
338c2ecf20Sopenharmony_ci	0xc2b70000,		/* [009] -91.5 dB */
348c2ecf20Sopenharmony_ci	0xc2b60000,		/* [010] -91.0 dB */
358c2ecf20Sopenharmony_ci	0xc2b50000,		/* [011] -90.5 dB */
368c2ecf20Sopenharmony_ci	0xc2b40000,		/* [012] -90.0 dB */
378c2ecf20Sopenharmony_ci	0xc2b30000,		/* [013] -89.5 dB */
388c2ecf20Sopenharmony_ci	0xc2b20000,		/* [014] -89.0 dB */
398c2ecf20Sopenharmony_ci	0xc2b10000,		/* [015] -88.5 dB */
408c2ecf20Sopenharmony_ci	0xc2b00000,		/* [016] -88.0 dB */
418c2ecf20Sopenharmony_ci	0xc2af0000,		/* [017] -87.5 dB */
428c2ecf20Sopenharmony_ci	0xc2ae0000,		/* [018] -87.0 dB */
438c2ecf20Sopenharmony_ci	0xc2ad0000,		/* [019] -86.5 dB */
448c2ecf20Sopenharmony_ci	0xc2ac0000,		/* [020] -86.0 dB */
458c2ecf20Sopenharmony_ci	0xc2ab0000,		/* [021] -85.5 dB */
468c2ecf20Sopenharmony_ci	0xc2aa0000,		/* [022] -85.0 dB */
478c2ecf20Sopenharmony_ci	0xc2a90000,		/* [023] -84.5 dB */
488c2ecf20Sopenharmony_ci	0xc2a80000,		/* [024] -84.0 dB */
498c2ecf20Sopenharmony_ci	0xc2a70000,		/* [025] -83.5 dB */
508c2ecf20Sopenharmony_ci	0xc2a60000,		/* [026] -83.0 dB */
518c2ecf20Sopenharmony_ci	0xc2a50000,		/* [027] -82.5 dB */
528c2ecf20Sopenharmony_ci	0xc2a40000,		/* [028] -82.0 dB */
538c2ecf20Sopenharmony_ci	0xc2a30000,		/* [029] -81.5 dB */
548c2ecf20Sopenharmony_ci	0xc2a20000,		/* [030] -81.0 dB */
558c2ecf20Sopenharmony_ci	0xc2a10000,		/* [031] -80.5 dB */
568c2ecf20Sopenharmony_ci	0xc2a00000,		/* [032] -80.0 dB */
578c2ecf20Sopenharmony_ci	0xc29f0000,		/* [033] -79.5 dB */
588c2ecf20Sopenharmony_ci	0xc29e0000,		/* [034] -79.0 dB */
598c2ecf20Sopenharmony_ci	0xc29d0000,		/* [035] -78.5 dB */
608c2ecf20Sopenharmony_ci	0xc29c0000,		/* [036] -78.0 dB */
618c2ecf20Sopenharmony_ci	0xc29b0000,		/* [037] -77.5 dB */
628c2ecf20Sopenharmony_ci	0xc29a0000,		/* [038] -77.0 dB */
638c2ecf20Sopenharmony_ci	0xc2990000,		/* [039] -76.5 dB */
648c2ecf20Sopenharmony_ci	0xc2980000,		/* [040] -76.0 dB */
658c2ecf20Sopenharmony_ci	0xc2970000,		/* [041] -75.5 dB */
668c2ecf20Sopenharmony_ci	0xc2960000,		/* [042] -75.0 dB */
678c2ecf20Sopenharmony_ci	0xc2950000,		/* [043] -74.5 dB */
688c2ecf20Sopenharmony_ci	0xc2940000,		/* [044] -74.0 dB */
698c2ecf20Sopenharmony_ci	0xc2930000,		/* [045] -73.5 dB */
708c2ecf20Sopenharmony_ci	0xc2920000,		/* [046] -73.0 dB */
718c2ecf20Sopenharmony_ci	0xc2910000,		/* [047] -72.5 dB */
728c2ecf20Sopenharmony_ci	0xc2900000,		/* [048] -72.0 dB */
738c2ecf20Sopenharmony_ci	0xc28f0000,		/* [049] -71.5 dB */
748c2ecf20Sopenharmony_ci	0xc28e0000,		/* [050] -71.0 dB */
758c2ecf20Sopenharmony_ci	0xc28d0000,		/* [051] -70.5 dB */
768c2ecf20Sopenharmony_ci	0xc28c0000,		/* [052] -70.0 dB */
778c2ecf20Sopenharmony_ci	0xc28b0000,		/* [053] -69.5 dB */
788c2ecf20Sopenharmony_ci	0xc28a0000,		/* [054] -69.0 dB */
798c2ecf20Sopenharmony_ci	0xc2890000,		/* [055] -68.5 dB */
808c2ecf20Sopenharmony_ci	0xc2880000,		/* [056] -68.0 dB */
818c2ecf20Sopenharmony_ci	0xc2870000,		/* [057] -67.5 dB */
828c2ecf20Sopenharmony_ci	0xc2860000,		/* [058] -67.0 dB */
838c2ecf20Sopenharmony_ci	0xc2850000,		/* [059] -66.5 dB */
848c2ecf20Sopenharmony_ci	0xc2840000,		/* [060] -66.0 dB */
858c2ecf20Sopenharmony_ci	0xc2830000,		/* [061] -65.5 dB */
868c2ecf20Sopenharmony_ci	0xc2820000,		/* [062] -65.0 dB */
878c2ecf20Sopenharmony_ci	0xc2810000,		/* [063] -64.5 dB */
888c2ecf20Sopenharmony_ci	0xc2800000,		/* [064] -64.0 dB */
898c2ecf20Sopenharmony_ci	0xc27e0000,		/* [065] -63.5 dB */
908c2ecf20Sopenharmony_ci	0xc27c0000,		/* [066] -63.0 dB */
918c2ecf20Sopenharmony_ci	0xc27a0000,		/* [067] -62.5 dB */
928c2ecf20Sopenharmony_ci	0xc2780000,		/* [068] -62.0 dB */
938c2ecf20Sopenharmony_ci	0xc2760000,		/* [069] -61.5 dB */
948c2ecf20Sopenharmony_ci	0xc2740000,		/* [070] -61.0 dB */
958c2ecf20Sopenharmony_ci	0xc2720000,		/* [071] -60.5 dB */
968c2ecf20Sopenharmony_ci	0xc2700000,		/* [072] -60.0 dB */
978c2ecf20Sopenharmony_ci	0xc26e0000,		/* [073] -59.5 dB */
988c2ecf20Sopenharmony_ci	0xc26c0000,		/* [074] -59.0 dB */
998c2ecf20Sopenharmony_ci	0xc26a0000,		/* [075] -58.5 dB */
1008c2ecf20Sopenharmony_ci	0xc2680000,		/* [076] -58.0 dB */
1018c2ecf20Sopenharmony_ci	0xc2660000,		/* [077] -57.5 dB */
1028c2ecf20Sopenharmony_ci	0xc2640000,		/* [078] -57.0 dB */
1038c2ecf20Sopenharmony_ci	0xc2620000,		/* [079] -56.5 dB */
1048c2ecf20Sopenharmony_ci	0xc2600000,		/* [080] -56.0 dB */
1058c2ecf20Sopenharmony_ci	0xc25e0000,		/* [081] -55.5 dB */
1068c2ecf20Sopenharmony_ci	0xc25c0000,		/* [082] -55.0 dB */
1078c2ecf20Sopenharmony_ci	0xc25a0000,		/* [083] -54.5 dB */
1088c2ecf20Sopenharmony_ci	0xc2580000,		/* [084] -54.0 dB */
1098c2ecf20Sopenharmony_ci	0xc2560000,		/* [085] -53.5 dB */
1108c2ecf20Sopenharmony_ci	0xc2540000,		/* [086] -53.0 dB */
1118c2ecf20Sopenharmony_ci	0xc2520000,		/* [087] -52.5 dB */
1128c2ecf20Sopenharmony_ci	0xc2500000,		/* [088] -52.0 dB */
1138c2ecf20Sopenharmony_ci	0xc24e0000,		/* [089] -51.5 dB */
1148c2ecf20Sopenharmony_ci	0xc24c0000,		/* [090] -51.0 dB */
1158c2ecf20Sopenharmony_ci	0xc24a0000,		/* [091] -50.5 dB */
1168c2ecf20Sopenharmony_ci	0xc2480000,		/* [092] -50.0 dB */
1178c2ecf20Sopenharmony_ci	0xc2460000,		/* [093] -49.5 dB */
1188c2ecf20Sopenharmony_ci	0xc2440000,		/* [094] -49.0 dB */
1198c2ecf20Sopenharmony_ci	0xc2420000,		/* [095] -48.5 dB */
1208c2ecf20Sopenharmony_ci	0xc2400000,		/* [096] -48.0 dB */
1218c2ecf20Sopenharmony_ci	0xc23e0000,		/* [097] -47.5 dB */
1228c2ecf20Sopenharmony_ci	0xc23c0000,		/* [098] -47.0 dB */
1238c2ecf20Sopenharmony_ci	0xc23a0000,		/* [099] -46.5 dB */
1248c2ecf20Sopenharmony_ci	0xc2380000,		/* [100] -46.0 dB */
1258c2ecf20Sopenharmony_ci	0xc2360000,		/* [101] -45.5 dB */
1268c2ecf20Sopenharmony_ci	0xc2340000,		/* [102] -45.0 dB */
1278c2ecf20Sopenharmony_ci	0xc2320000,		/* [103] -44.5 dB */
1288c2ecf20Sopenharmony_ci	0xc2300000,		/* [104] -44.0 dB */
1298c2ecf20Sopenharmony_ci	0xc22e0000,		/* [105] -43.5 dB */
1308c2ecf20Sopenharmony_ci	0xc22c0000,		/* [106] -43.0 dB */
1318c2ecf20Sopenharmony_ci	0xc22a0000,		/* [107] -42.5 dB */
1328c2ecf20Sopenharmony_ci	0xc2280000,		/* [108] -42.0 dB */
1338c2ecf20Sopenharmony_ci	0xc2260000,		/* [109] -41.5 dB */
1348c2ecf20Sopenharmony_ci	0xc2240000,		/* [110] -41.0 dB */
1358c2ecf20Sopenharmony_ci	0xc2220000,		/* [111] -40.5 dB */
1368c2ecf20Sopenharmony_ci	0xc2200000,		/* [112] -40.0 dB */
1378c2ecf20Sopenharmony_ci	0xc21e0000,		/* [113] -39.5 dB */
1388c2ecf20Sopenharmony_ci	0xc21c0000,		/* [114] -39.0 dB */
1398c2ecf20Sopenharmony_ci	0xc21a0000,		/* [115] -38.5 dB */
1408c2ecf20Sopenharmony_ci	0xc2180000,		/* [116] -38.0 dB */
1418c2ecf20Sopenharmony_ci	0xc2160000,		/* [117] -37.5 dB */
1428c2ecf20Sopenharmony_ci	0xc2140000,		/* [118] -37.0 dB */
1438c2ecf20Sopenharmony_ci	0xc2120000,		/* [119] -36.5 dB */
1448c2ecf20Sopenharmony_ci	0xc2100000,		/* [120] -36.0 dB */
1458c2ecf20Sopenharmony_ci	0xc20e0000,		/* [121] -35.5 dB */
1468c2ecf20Sopenharmony_ci	0xc20c0000,		/* [122] -35.0 dB */
1478c2ecf20Sopenharmony_ci	0xc20a0000,		/* [123] -34.5 dB */
1488c2ecf20Sopenharmony_ci	0xc2080000,		/* [124] -34.0 dB */
1498c2ecf20Sopenharmony_ci	0xc2060000,		/* [125] -33.5 dB */
1508c2ecf20Sopenharmony_ci	0xc2040000,		/* [126] -33.0 dB */
1518c2ecf20Sopenharmony_ci	0xc2020000,		/* [127] -32.5 dB */
1528c2ecf20Sopenharmony_ci	0xc2000000,		/* [128] -32.0 dB */
1538c2ecf20Sopenharmony_ci	0xc1fc0000,		/* [129] -31.5 dB */
1548c2ecf20Sopenharmony_ci	0xc1f80000,		/* [130] -31.0 dB */
1558c2ecf20Sopenharmony_ci	0xc1f40000,		/* [131] -30.5 dB */
1568c2ecf20Sopenharmony_ci	0xc1f00000,		/* [132] -30.0 dB */
1578c2ecf20Sopenharmony_ci	0xc1ec0000,		/* [133] -29.5 dB */
1588c2ecf20Sopenharmony_ci	0xc1e80000,		/* [134] -29.0 dB */
1598c2ecf20Sopenharmony_ci	0xc1e40000,		/* [135] -28.5 dB */
1608c2ecf20Sopenharmony_ci	0xc1e00000,		/* [136] -28.0 dB */
1618c2ecf20Sopenharmony_ci	0xc1dc0000,		/* [137] -27.5 dB */
1628c2ecf20Sopenharmony_ci	0xc1d80000,		/* [138] -27.0 dB */
1638c2ecf20Sopenharmony_ci	0xc1d40000,		/* [139] -26.5 dB */
1648c2ecf20Sopenharmony_ci	0xc1d00000,		/* [140] -26.0 dB */
1658c2ecf20Sopenharmony_ci	0xc1cc0000,		/* [141] -25.5 dB */
1668c2ecf20Sopenharmony_ci	0xc1c80000,		/* [142] -25.0 dB */
1678c2ecf20Sopenharmony_ci	0xc1c40000,		/* [143] -24.5 dB */
1688c2ecf20Sopenharmony_ci	0xc1c00000,		/* [144] -24.0 dB */
1698c2ecf20Sopenharmony_ci	0xc1bc0000,		/* [145] -23.5 dB */
1708c2ecf20Sopenharmony_ci	0xc1b80000,		/* [146] -23.0 dB */
1718c2ecf20Sopenharmony_ci	0xc1b40000,		/* [147] -22.5 dB */
1728c2ecf20Sopenharmony_ci	0xc1b00000,		/* [148] -22.0 dB */
1738c2ecf20Sopenharmony_ci	0xc1ac0000,		/* [149] -21.5 dB */
1748c2ecf20Sopenharmony_ci	0xc1a80000,		/* [150] -21.0 dB */
1758c2ecf20Sopenharmony_ci	0xc1a40000,		/* [151] -20.5 dB */
1768c2ecf20Sopenharmony_ci	0xc1a00000,		/* [152] -20.0 dB */
1778c2ecf20Sopenharmony_ci	0xc19c0000,		/* [153] -19.5 dB */
1788c2ecf20Sopenharmony_ci	0xc1980000,		/* [154] -19.0 dB */
1798c2ecf20Sopenharmony_ci	0xc1940000,		/* [155] -18.5 dB */
1808c2ecf20Sopenharmony_ci	0xc1900000,		/* [156] -18.0 dB */
1818c2ecf20Sopenharmony_ci	0xc18c0000,		/* [157] -17.5 dB */
1828c2ecf20Sopenharmony_ci	0xc1880000,		/* [158] -17.0 dB */
1838c2ecf20Sopenharmony_ci	0xc1840000,		/* [159] -16.5 dB */
1848c2ecf20Sopenharmony_ci	0xc1800000,		/* [160] -16.0 dB */
1858c2ecf20Sopenharmony_ci	0xc1780000,		/* [161] -15.5 dB */
1868c2ecf20Sopenharmony_ci	0xc1700000,		/* [162] -15.0 dB */
1878c2ecf20Sopenharmony_ci	0xc1680000,		/* [163] -14.5 dB */
1888c2ecf20Sopenharmony_ci	0xc1600000,		/* [164] -14.0 dB */
1898c2ecf20Sopenharmony_ci	0xc1580000,		/* [165] -13.5 dB */
1908c2ecf20Sopenharmony_ci	0xc1500000,		/* [166] -13.0 dB */
1918c2ecf20Sopenharmony_ci	0xc1480000,		/* [167] -12.5 dB */
1928c2ecf20Sopenharmony_ci	0xc1400000,		/* [168] -12.0 dB */
1938c2ecf20Sopenharmony_ci	0xc1380000,		/* [169] -11.5 dB */
1948c2ecf20Sopenharmony_ci	0xc1300000,		/* [170] -11.0 dB */
1958c2ecf20Sopenharmony_ci	0xc1280000,		/* [171] -10.5 dB */
1968c2ecf20Sopenharmony_ci	0xc1200000,		/* [172] -10.0 dB */
1978c2ecf20Sopenharmony_ci	0xc1180000,		/* [173] -9.5 dB */
1988c2ecf20Sopenharmony_ci	0xc1100000,		/* [174] -9.0 dB */
1998c2ecf20Sopenharmony_ci	0xc1080000,		/* [175] -8.5 dB */
2008c2ecf20Sopenharmony_ci	0xc1000000,		/* [176] -8.0 dB */
2018c2ecf20Sopenharmony_ci	0xc0f00000,		/* [177] -7.5 dB */
2028c2ecf20Sopenharmony_ci	0xc0e00000,		/* [178] -7.0 dB */
2038c2ecf20Sopenharmony_ci	0xc0d00000,		/* [179] -6.5 dB */
2048c2ecf20Sopenharmony_ci	0xc0c00000,		/* [180] -6.0 dB */
2058c2ecf20Sopenharmony_ci	0xc0b00000,		/* [181] -5.5 dB */
2068c2ecf20Sopenharmony_ci	0xc0a00000,		/* [182] -5.0 dB */
2078c2ecf20Sopenharmony_ci	0xc0900000,		/* [183] -4.5 dB */
2088c2ecf20Sopenharmony_ci	0xc0800000,		/* [184] -4.0 dB */
2098c2ecf20Sopenharmony_ci	0xc0600000,		/* [185] -3.5 dB */
2108c2ecf20Sopenharmony_ci	0xc0400000,		/* [186] -3.0 dB */
2118c2ecf20Sopenharmony_ci	0xc0200000,		/* [187] -2.5 dB */
2128c2ecf20Sopenharmony_ci	0xc0000000,		/* [188] -2.0 dB */
2138c2ecf20Sopenharmony_ci	0xbfc00000,		/* [189] -1.5 dB */
2148c2ecf20Sopenharmony_ci	0xbf800000,		/* [190] -1.0 dB */
2158c2ecf20Sopenharmony_ci	0xbf000000,		/* [191] -0.5 dB */
2168c2ecf20Sopenharmony_ci	0x00000000,		/* [192] 0.0 dB */
2178c2ecf20Sopenharmony_ci	0x3f000000,		/* [193] 0.5 dB */
2188c2ecf20Sopenharmony_ci	0x3f800000,		/* [194] 1.0 dB */
2198c2ecf20Sopenharmony_ci	0x3fc00000,		/* [195] 1.5 dB */
2208c2ecf20Sopenharmony_ci	0x40000000,		/* [196] 2.0 dB */
2218c2ecf20Sopenharmony_ci	0x40200000,		/* [197] 2.5 dB */
2228c2ecf20Sopenharmony_ci	0x40400000,		/* [198] 3.0 dB */
2238c2ecf20Sopenharmony_ci	0x40600000,		/* [199] 3.5 dB */
2248c2ecf20Sopenharmony_ci	0x40800000,		/* [200] 4.0 dB */
2258c2ecf20Sopenharmony_ci	0x40900000,		/* [201] 4.5 dB */
2268c2ecf20Sopenharmony_ci	0x40a00000,		/* [202] 5.0 dB */
2278c2ecf20Sopenharmony_ci	0x40b00000,		/* [203] 5.5 dB */
2288c2ecf20Sopenharmony_ci	0x40c00000,		/* [204] 6.0 dB */
2298c2ecf20Sopenharmony_ci	0x40d00000,		/* [205] 6.5 dB */
2308c2ecf20Sopenharmony_ci	0x40e00000,		/* [206] 7.0 dB */
2318c2ecf20Sopenharmony_ci	0x40f00000,		/* [207] 7.5 dB */
2328c2ecf20Sopenharmony_ci	0x41000000,		/* [208] 8.0 dB */
2338c2ecf20Sopenharmony_ci	0x41080000,		/* [209] 8.5 dB */
2348c2ecf20Sopenharmony_ci	0x41100000,		/* [210] 9.0 dB */
2358c2ecf20Sopenharmony_ci	0x41180000,		/* [211] 9.5 dB */
2368c2ecf20Sopenharmony_ci	0x41200000,		/* [212] 10.0 dB */
2378c2ecf20Sopenharmony_ci	0x41280000,		/* [213] 10.5 dB */
2388c2ecf20Sopenharmony_ci	0x41300000,		/* [214] 11.0 dB */
2398c2ecf20Sopenharmony_ci	0x41380000,		/* [215] 11.5 dB */
2408c2ecf20Sopenharmony_ci	0x41400000,		/* [216] 12.0 dB */
2418c2ecf20Sopenharmony_ci	0x41480000,		/* [217] 12.5 dB */
2428c2ecf20Sopenharmony_ci	0x41500000,		/* [218] 13.0 dB */
2438c2ecf20Sopenharmony_ci	0x41580000,		/* [219] 13.5 dB */
2448c2ecf20Sopenharmony_ci	0x41600000,		/* [220] 14.0 dB */
2458c2ecf20Sopenharmony_ci	0x41680000,		/* [221] 14.5 dB */
2468c2ecf20Sopenharmony_ci	0x41700000,		/* [222] 15.0 dB */
2478c2ecf20Sopenharmony_ci	0x41780000,		/* [223] 15.5 dB */
2488c2ecf20Sopenharmony_ci	0x41800000,		/* [224] 16.0 dB */
2498c2ecf20Sopenharmony_ci	0x41840000,		/* [225] 16.5 dB */
2508c2ecf20Sopenharmony_ci	0x41880000,		/* [226] 17.0 dB */
2518c2ecf20Sopenharmony_ci	0x418c0000,		/* [227] 17.5 dB */
2528c2ecf20Sopenharmony_ci	0x41900000,		/* [228] 18.0 dB */
2538c2ecf20Sopenharmony_ci	0x41940000,		/* [229] 18.5 dB */
2548c2ecf20Sopenharmony_ci	0x41980000,		/* [230] 19.0 dB */
2558c2ecf20Sopenharmony_ci	0x419c0000,		/* [231] 19.5 dB */
2568c2ecf20Sopenharmony_ci	0x41a00000,		/* [232] 20.0 dB */
2578c2ecf20Sopenharmony_ci	0x41a40000,		/* [233] 20.5 dB */
2588c2ecf20Sopenharmony_ci	0x41a80000,		/* [234] 21.0 dB */
2598c2ecf20Sopenharmony_ci	0x41ac0000,		/* [235] 21.5 dB */
2608c2ecf20Sopenharmony_ci	0x41b00000,		/* [236] 22.0 dB */
2618c2ecf20Sopenharmony_ci	0x41b40000,		/* [237] 22.5 dB */
2628c2ecf20Sopenharmony_ci	0x41b80000,		/* [238] 23.0 dB */
2638c2ecf20Sopenharmony_ci	0x41bc0000,		/* [239] 23.5 dB */
2648c2ecf20Sopenharmony_ci	0x41c00000,		/* [240] 24.0 dB */
2658c2ecf20Sopenharmony_ci	0x41c40000,		/* [241] 24.5 dB */
2668c2ecf20Sopenharmony_ci	0x41c80000,		/* [242] 25.0 dB */
2678c2ecf20Sopenharmony_ci	0x41cc0000,		/* [243] 25.5 dB */
2688c2ecf20Sopenharmony_ci	0x41d00000,		/* [244] 26.0 dB */
2698c2ecf20Sopenharmony_ci	0x41d40000,		/* [245] 26.5 dB */
2708c2ecf20Sopenharmony_ci	0x41d80000,		/* [246] 27.0 dB */
2718c2ecf20Sopenharmony_ci	0x41dc0000,		/* [247] 27.5 dB */
2728c2ecf20Sopenharmony_ci	0x41e00000,		/* [248] 28.0 dB */
2738c2ecf20Sopenharmony_ci	0x41e40000,		/* [249] 28.5 dB */
2748c2ecf20Sopenharmony_ci	0x41e80000,		/* [250] 29.0 dB */
2758c2ecf20Sopenharmony_ci	0x41ec0000,		/* [251] 29.5 dB */
2768c2ecf20Sopenharmony_ci	0x41f00000,		/* [252] 30.0 dB */
2778c2ecf20Sopenharmony_ci	0x41f40000,		/* [253] 30.5 dB */
2788c2ecf20Sopenharmony_ci	0x41f80000,		/* [254] 31.0 dB */
2798c2ecf20Sopenharmony_ci	0x41fc0000,		/* [255] 31.5 dB */
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci#define MIXART_ANALOG_CAPTURE_LEVEL_MIN   0      /* -96.0 dB + 8.0 dB = -88.0 dB */
2838c2ecf20Sopenharmony_ci#define MIXART_ANALOG_CAPTURE_LEVEL_MAX   255    /*  31.5 dB + 8.0 dB =  39.5 dB */
2848c2ecf20Sopenharmony_ci#define MIXART_ANALOG_CAPTURE_ZERO_LEVEL  176    /*  -8.0 dB + 8.0 dB =  0.0 dB */
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci#define MIXART_ANALOG_PLAYBACK_LEVEL_MIN  0      /* -96.0 dB + 1.5 dB = -94.5 dB (possible is down to (-114.0+1.5)dB) */
2878c2ecf20Sopenharmony_ci#define MIXART_ANALOG_PLAYBACK_LEVEL_MAX  192    /*   0.0 dB + 1.5 dB =  1.5 dB */
2888c2ecf20Sopenharmony_ci#define MIXART_ANALOG_PLAYBACK_ZERO_LEVEL 189    /*  -1.5 dB + 1.5 dB =  0.0 dB */
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_cistatic int mixart_update_analog_audio_level(struct snd_mixart* chip, int is_capture)
2918c2ecf20Sopenharmony_ci{
2928c2ecf20Sopenharmony_ci	int i, err;
2938c2ecf20Sopenharmony_ci	struct mixart_msg request;
2948c2ecf20Sopenharmony_ci	struct mixart_io_level io_level;
2958c2ecf20Sopenharmony_ci	struct mixart_return_uid resp;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	memset(&io_level, 0, sizeof(io_level));
2988c2ecf20Sopenharmony_ci	io_level.channel = -1; /* left and right */
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	for(i=0; i<2; i++) {
3018c2ecf20Sopenharmony_ci		if(is_capture) {
3028c2ecf20Sopenharmony_ci			io_level.level[i].analog_level = mixart_analog_level[chip->analog_capture_volume[i]];
3038c2ecf20Sopenharmony_ci		} else {
3048c2ecf20Sopenharmony_ci			if(chip->analog_playback_active[i])
3058c2ecf20Sopenharmony_ci				io_level.level[i].analog_level = mixart_analog_level[chip->analog_playback_volume[i]];
3068c2ecf20Sopenharmony_ci			else
3078c2ecf20Sopenharmony_ci				io_level.level[i].analog_level = mixart_analog_level[MIXART_ANALOG_PLAYBACK_LEVEL_MIN];
3088c2ecf20Sopenharmony_ci		}
3098c2ecf20Sopenharmony_ci	}
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci	if(is_capture)	request.uid = chip->uid_in_analog_physio;
3128c2ecf20Sopenharmony_ci	else		request.uid = chip->uid_out_analog_physio;
3138c2ecf20Sopenharmony_ci	request.message_id = MSG_PHYSICALIO_SET_LEVEL;
3148c2ecf20Sopenharmony_ci	request.data = &io_level;
3158c2ecf20Sopenharmony_ci	request.size = sizeof(io_level);
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
3188c2ecf20Sopenharmony_ci	if((err<0) || (resp.error_code)) {
3198c2ecf20Sopenharmony_ci		dev_dbg(chip->card->dev,
3208c2ecf20Sopenharmony_ci			"error MSG_PHYSICALIO_SET_LEVEL card(%d) is_capture(%d) error_code(%x)\n",
3218c2ecf20Sopenharmony_ci			chip->chip_idx, is_capture, resp.error_code);
3228c2ecf20Sopenharmony_ci		return -EINVAL;
3238c2ecf20Sopenharmony_ci	}
3248c2ecf20Sopenharmony_ci	return 0;
3258c2ecf20Sopenharmony_ci}
3268c2ecf20Sopenharmony_ci
3278c2ecf20Sopenharmony_ci/*
3288c2ecf20Sopenharmony_ci * analog level control
3298c2ecf20Sopenharmony_ci */
3308c2ecf20Sopenharmony_cistatic int mixart_analog_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
3318c2ecf20Sopenharmony_ci{
3328c2ecf20Sopenharmony_ci	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
3338c2ecf20Sopenharmony_ci	uinfo->count = 2;
3348c2ecf20Sopenharmony_ci	if(kcontrol->private_value == 0) {	/* playback */
3358c2ecf20Sopenharmony_ci		uinfo->value.integer.min = MIXART_ANALOG_PLAYBACK_LEVEL_MIN;  /* -96 dB */
3368c2ecf20Sopenharmony_ci		uinfo->value.integer.max = MIXART_ANALOG_PLAYBACK_LEVEL_MAX;  /* 0 dB */
3378c2ecf20Sopenharmony_ci	} else {				/* capture */
3388c2ecf20Sopenharmony_ci		uinfo->value.integer.min = MIXART_ANALOG_CAPTURE_LEVEL_MIN;   /* -96 dB */
3398c2ecf20Sopenharmony_ci		uinfo->value.integer.max = MIXART_ANALOG_CAPTURE_LEVEL_MAX;   /* 31.5 dB */
3408c2ecf20Sopenharmony_ci	}
3418c2ecf20Sopenharmony_ci	return 0;
3428c2ecf20Sopenharmony_ci}
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_cistatic int mixart_analog_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3458c2ecf20Sopenharmony_ci{
3468c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
3478c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
3488c2ecf20Sopenharmony_ci	if(kcontrol->private_value == 0) {	/* playback */
3498c2ecf20Sopenharmony_ci		ucontrol->value.integer.value[0] = chip->analog_playback_volume[0];
3508c2ecf20Sopenharmony_ci		ucontrol->value.integer.value[1] = chip->analog_playback_volume[1];
3518c2ecf20Sopenharmony_ci	} else {				/* capture */
3528c2ecf20Sopenharmony_ci		ucontrol->value.integer.value[0] = chip->analog_capture_volume[0];
3538c2ecf20Sopenharmony_ci		ucontrol->value.integer.value[1] = chip->analog_capture_volume[1];
3548c2ecf20Sopenharmony_ci	}
3558c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
3568c2ecf20Sopenharmony_ci	return 0;
3578c2ecf20Sopenharmony_ci}
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_cistatic int mixart_analog_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
3608c2ecf20Sopenharmony_ci{
3618c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
3628c2ecf20Sopenharmony_ci	int changed = 0;
3638c2ecf20Sopenharmony_ci	int is_capture, i;
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
3668c2ecf20Sopenharmony_ci	is_capture = (kcontrol->private_value != 0);
3678c2ecf20Sopenharmony_ci	for (i = 0; i < 2; i++) {
3688c2ecf20Sopenharmony_ci		int new_volume = ucontrol->value.integer.value[i];
3698c2ecf20Sopenharmony_ci		int *stored_volume = is_capture ?
3708c2ecf20Sopenharmony_ci			&chip->analog_capture_volume[i] :
3718c2ecf20Sopenharmony_ci			&chip->analog_playback_volume[i];
3728c2ecf20Sopenharmony_ci		if (is_capture) {
3738c2ecf20Sopenharmony_ci			if (new_volume < MIXART_ANALOG_CAPTURE_LEVEL_MIN ||
3748c2ecf20Sopenharmony_ci			    new_volume > MIXART_ANALOG_CAPTURE_LEVEL_MAX)
3758c2ecf20Sopenharmony_ci				continue;
3768c2ecf20Sopenharmony_ci		} else {
3778c2ecf20Sopenharmony_ci			if (new_volume < MIXART_ANALOG_PLAYBACK_LEVEL_MIN ||
3788c2ecf20Sopenharmony_ci			    new_volume > MIXART_ANALOG_PLAYBACK_LEVEL_MAX)
3798c2ecf20Sopenharmony_ci				continue;
3808c2ecf20Sopenharmony_ci		}
3818c2ecf20Sopenharmony_ci		if (*stored_volume != new_volume) {
3828c2ecf20Sopenharmony_ci			*stored_volume = new_volume;
3838c2ecf20Sopenharmony_ci			changed = 1;
3848c2ecf20Sopenharmony_ci		}
3858c2ecf20Sopenharmony_ci	}
3868c2ecf20Sopenharmony_ci	if (changed)
3878c2ecf20Sopenharmony_ci		mixart_update_analog_audio_level(chip, is_capture);
3888c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
3898c2ecf20Sopenharmony_ci	return changed;
3908c2ecf20Sopenharmony_ci}
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(db_scale_analog, -9600, 50, 0);
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mixart_control_analog_level = {
3958c2ecf20Sopenharmony_ci	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
3968c2ecf20Sopenharmony_ci	.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
3978c2ecf20Sopenharmony_ci		   SNDRV_CTL_ELEM_ACCESS_TLV_READ),
3988c2ecf20Sopenharmony_ci	/* name will be filled later */
3998c2ecf20Sopenharmony_ci	.info =		mixart_analog_vol_info,
4008c2ecf20Sopenharmony_ci	.get =		mixart_analog_vol_get,
4018c2ecf20Sopenharmony_ci	.put =		mixart_analog_vol_put,
4028c2ecf20Sopenharmony_ci	.tlv = { .p = db_scale_analog },
4038c2ecf20Sopenharmony_ci};
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ci/* shared */
4068c2ecf20Sopenharmony_ci#define mixart_sw_info		snd_ctl_boolean_stereo_info
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_cistatic int mixart_audio_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4098c2ecf20Sopenharmony_ci{
4108c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
4138c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[0] = chip->analog_playback_active[0];
4148c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[1] = chip->analog_playback_active[1];
4158c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
4168c2ecf20Sopenharmony_ci	return 0;
4178c2ecf20Sopenharmony_ci}
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_cistatic int mixart_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
4208c2ecf20Sopenharmony_ci{
4218c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
4228c2ecf20Sopenharmony_ci	int i, changed = 0;
4238c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
4248c2ecf20Sopenharmony_ci	for (i = 0; i < 2; i++) {
4258c2ecf20Sopenharmony_ci		if (chip->analog_playback_active[i] !=
4268c2ecf20Sopenharmony_ci		    ucontrol->value.integer.value[i]) {
4278c2ecf20Sopenharmony_ci			chip->analog_playback_active[i] =
4288c2ecf20Sopenharmony_ci				!!ucontrol->value.integer.value[i];
4298c2ecf20Sopenharmony_ci			changed = 1;
4308c2ecf20Sopenharmony_ci		}
4318c2ecf20Sopenharmony_ci	}
4328c2ecf20Sopenharmony_ci	if (changed) /* update playback levels */
4338c2ecf20Sopenharmony_ci		mixart_update_analog_audio_level(chip, 0);
4348c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
4358c2ecf20Sopenharmony_ci	return changed;
4368c2ecf20Sopenharmony_ci}
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mixart_control_output_switch = {
4398c2ecf20Sopenharmony_ci	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
4408c2ecf20Sopenharmony_ci	.name =         "Master Playback Switch",
4418c2ecf20Sopenharmony_ci	.info =         mixart_sw_info,		/* shared */
4428c2ecf20Sopenharmony_ci	.get =          mixart_audio_sw_get,
4438c2ecf20Sopenharmony_ci	.put =          mixart_audio_sw_put
4448c2ecf20Sopenharmony_ci};
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_cistatic const u32 mixart_digital_level[256] = {
4478c2ecf20Sopenharmony_ci	0x00000000,		/* [000] = 0.00e+000 = mute if <= -109.5dB */
4488c2ecf20Sopenharmony_ci	0x366e1c7a,		/* [001] = 3.55e-006 = pow(10.0, 0.05 * -109.0dB) */
4498c2ecf20Sopenharmony_ci	0x367c3860,		/* [002] = 3.76e-006 = pow(10.0, 0.05 * -108.5dB) */
4508c2ecf20Sopenharmony_ci	0x36859525,		/* [003] = 3.98e-006 = pow(10.0, 0.05 * -108.0dB) */
4518c2ecf20Sopenharmony_ci	0x368d7f74,		/* [004] = 4.22e-006 = pow(10.0, 0.05 * -107.5dB) */
4528c2ecf20Sopenharmony_ci	0x3695e1d4,		/* [005] = 4.47e-006 = pow(10.0, 0.05 * -107.0dB) */
4538c2ecf20Sopenharmony_ci	0x369ec362,		/* [006] = 4.73e-006 = pow(10.0, 0.05 * -106.5dB) */
4548c2ecf20Sopenharmony_ci	0x36a82ba8,		/* [007] = 5.01e-006 = pow(10.0, 0.05 * -106.0dB) */
4558c2ecf20Sopenharmony_ci	0x36b222a0,		/* [008] = 5.31e-006 = pow(10.0, 0.05 * -105.5dB) */
4568c2ecf20Sopenharmony_ci	0x36bcb0c1,		/* [009] = 5.62e-006 = pow(10.0, 0.05 * -105.0dB) */
4578c2ecf20Sopenharmony_ci	0x36c7defd,		/* [010] = 5.96e-006 = pow(10.0, 0.05 * -104.5dB) */
4588c2ecf20Sopenharmony_ci	0x36d3b6d3,		/* [011] = 6.31e-006 = pow(10.0, 0.05 * -104.0dB) */
4598c2ecf20Sopenharmony_ci	0x36e0424e,		/* [012] = 6.68e-006 = pow(10.0, 0.05 * -103.5dB) */
4608c2ecf20Sopenharmony_ci	0x36ed8c14,		/* [013] = 7.08e-006 = pow(10.0, 0.05 * -103.0dB) */
4618c2ecf20Sopenharmony_ci	0x36fb9f6c,		/* [014] = 7.50e-006 = pow(10.0, 0.05 * -102.5dB) */
4628c2ecf20Sopenharmony_ci	0x37054423,		/* [015] = 7.94e-006 = pow(10.0, 0.05 * -102.0dB) */
4638c2ecf20Sopenharmony_ci	0x370d29a5,		/* [016] = 8.41e-006 = pow(10.0, 0.05 * -101.5dB) */
4648c2ecf20Sopenharmony_ci	0x371586f0,		/* [017] = 8.91e-006 = pow(10.0, 0.05 * -101.0dB) */
4658c2ecf20Sopenharmony_ci	0x371e631b,		/* [018] = 9.44e-006 = pow(10.0, 0.05 * -100.5dB) */
4668c2ecf20Sopenharmony_ci	0x3727c5ac,		/* [019] = 1.00e-005 = pow(10.0, 0.05 * -100.0dB) */
4678c2ecf20Sopenharmony_ci	0x3731b69a,		/* [020] = 1.06e-005 = pow(10.0, 0.05 * -99.5dB) */
4688c2ecf20Sopenharmony_ci	0x373c3e53,		/* [021] = 1.12e-005 = pow(10.0, 0.05 * -99.0dB) */
4698c2ecf20Sopenharmony_ci	0x374765c8,		/* [022] = 1.19e-005 = pow(10.0, 0.05 * -98.5dB) */
4708c2ecf20Sopenharmony_ci	0x3753366f,		/* [023] = 1.26e-005 = pow(10.0, 0.05 * -98.0dB) */
4718c2ecf20Sopenharmony_ci	0x375fba4f,		/* [024] = 1.33e-005 = pow(10.0, 0.05 * -97.5dB) */
4728c2ecf20Sopenharmony_ci	0x376cfc07,		/* [025] = 1.41e-005 = pow(10.0, 0.05 * -97.0dB) */
4738c2ecf20Sopenharmony_ci	0x377b06d5,		/* [026] = 1.50e-005 = pow(10.0, 0.05 * -96.5dB) */
4748c2ecf20Sopenharmony_ci	0x3784f352,		/* [027] = 1.58e-005 = pow(10.0, 0.05 * -96.0dB) */
4758c2ecf20Sopenharmony_ci	0x378cd40b,		/* [028] = 1.68e-005 = pow(10.0, 0.05 * -95.5dB) */
4768c2ecf20Sopenharmony_ci	0x37952c42,		/* [029] = 1.78e-005 = pow(10.0, 0.05 * -95.0dB) */
4778c2ecf20Sopenharmony_ci	0x379e030e,		/* [030] = 1.88e-005 = pow(10.0, 0.05 * -94.5dB) */
4788c2ecf20Sopenharmony_ci	0x37a75fef,		/* [031] = 2.00e-005 = pow(10.0, 0.05 * -94.0dB) */
4798c2ecf20Sopenharmony_ci	0x37b14ad5,		/* [032] = 2.11e-005 = pow(10.0, 0.05 * -93.5dB) */
4808c2ecf20Sopenharmony_ci	0x37bbcc2c,		/* [033] = 2.24e-005 = pow(10.0, 0.05 * -93.0dB) */
4818c2ecf20Sopenharmony_ci	0x37c6ecdd,		/* [034] = 2.37e-005 = pow(10.0, 0.05 * -92.5dB) */
4828c2ecf20Sopenharmony_ci	0x37d2b65a,		/* [035] = 2.51e-005 = pow(10.0, 0.05 * -92.0dB) */
4838c2ecf20Sopenharmony_ci	0x37df32a3,		/* [036] = 2.66e-005 = pow(10.0, 0.05 * -91.5dB) */
4848c2ecf20Sopenharmony_ci	0x37ec6c50,		/* [037] = 2.82e-005 = pow(10.0, 0.05 * -91.0dB) */
4858c2ecf20Sopenharmony_ci	0x37fa6e9b,		/* [038] = 2.99e-005 = pow(10.0, 0.05 * -90.5dB) */
4868c2ecf20Sopenharmony_ci	0x3804a2b3,		/* [039] = 3.16e-005 = pow(10.0, 0.05 * -90.0dB) */
4878c2ecf20Sopenharmony_ci	0x380c7ea4,		/* [040] = 3.35e-005 = pow(10.0, 0.05 * -89.5dB) */
4888c2ecf20Sopenharmony_ci	0x3814d1cc,		/* [041] = 3.55e-005 = pow(10.0, 0.05 * -89.0dB) */
4898c2ecf20Sopenharmony_ci	0x381da33c,		/* [042] = 3.76e-005 = pow(10.0, 0.05 * -88.5dB) */
4908c2ecf20Sopenharmony_ci	0x3826fa6f,		/* [043] = 3.98e-005 = pow(10.0, 0.05 * -88.0dB) */
4918c2ecf20Sopenharmony_ci	0x3830df51,		/* [044] = 4.22e-005 = pow(10.0, 0.05 * -87.5dB) */
4928c2ecf20Sopenharmony_ci	0x383b5a49,		/* [045] = 4.47e-005 = pow(10.0, 0.05 * -87.0dB) */
4938c2ecf20Sopenharmony_ci	0x3846743b,		/* [046] = 4.73e-005 = pow(10.0, 0.05 * -86.5dB) */
4948c2ecf20Sopenharmony_ci	0x38523692,		/* [047] = 5.01e-005 = pow(10.0, 0.05 * -86.0dB) */
4958c2ecf20Sopenharmony_ci	0x385eab48,		/* [048] = 5.31e-005 = pow(10.0, 0.05 * -85.5dB) */
4968c2ecf20Sopenharmony_ci	0x386bdcf1,		/* [049] = 5.62e-005 = pow(10.0, 0.05 * -85.0dB) */
4978c2ecf20Sopenharmony_ci	0x3879d6bc,		/* [050] = 5.96e-005 = pow(10.0, 0.05 * -84.5dB) */
4988c2ecf20Sopenharmony_ci	0x38845244,		/* [051] = 6.31e-005 = pow(10.0, 0.05 * -84.0dB) */
4998c2ecf20Sopenharmony_ci	0x388c2971,		/* [052] = 6.68e-005 = pow(10.0, 0.05 * -83.5dB) */
5008c2ecf20Sopenharmony_ci	0x3894778d,		/* [053] = 7.08e-005 = pow(10.0, 0.05 * -83.0dB) */
5018c2ecf20Sopenharmony_ci	0x389d43a4,		/* [054] = 7.50e-005 = pow(10.0, 0.05 * -82.5dB) */
5028c2ecf20Sopenharmony_ci	0x38a6952c,		/* [055] = 7.94e-005 = pow(10.0, 0.05 * -82.0dB) */
5038c2ecf20Sopenharmony_ci	0x38b0740f,		/* [056] = 8.41e-005 = pow(10.0, 0.05 * -81.5dB) */
5048c2ecf20Sopenharmony_ci	0x38bae8ac,		/* [057] = 8.91e-005 = pow(10.0, 0.05 * -81.0dB) */
5058c2ecf20Sopenharmony_ci	0x38c5fbe2,		/* [058] = 9.44e-005 = pow(10.0, 0.05 * -80.5dB) */
5068c2ecf20Sopenharmony_ci	0x38d1b717,		/* [059] = 1.00e-004 = pow(10.0, 0.05 * -80.0dB) */
5078c2ecf20Sopenharmony_ci	0x38de2440,		/* [060] = 1.06e-004 = pow(10.0, 0.05 * -79.5dB) */
5088c2ecf20Sopenharmony_ci	0x38eb4de8,		/* [061] = 1.12e-004 = pow(10.0, 0.05 * -79.0dB) */
5098c2ecf20Sopenharmony_ci	0x38f93f3a,		/* [062] = 1.19e-004 = pow(10.0, 0.05 * -78.5dB) */
5108c2ecf20Sopenharmony_ci	0x39040206,		/* [063] = 1.26e-004 = pow(10.0, 0.05 * -78.0dB) */
5118c2ecf20Sopenharmony_ci	0x390bd472,		/* [064] = 1.33e-004 = pow(10.0, 0.05 * -77.5dB) */
5128c2ecf20Sopenharmony_ci	0x39141d84,		/* [065] = 1.41e-004 = pow(10.0, 0.05 * -77.0dB) */
5138c2ecf20Sopenharmony_ci	0x391ce445,		/* [066] = 1.50e-004 = pow(10.0, 0.05 * -76.5dB) */
5148c2ecf20Sopenharmony_ci	0x39263027,		/* [067] = 1.58e-004 = pow(10.0, 0.05 * -76.0dB) */
5158c2ecf20Sopenharmony_ci	0x3930090d,		/* [068] = 1.68e-004 = pow(10.0, 0.05 * -75.5dB) */
5168c2ecf20Sopenharmony_ci	0x393a7753,		/* [069] = 1.78e-004 = pow(10.0, 0.05 * -75.0dB) */
5178c2ecf20Sopenharmony_ci	0x394583d2,		/* [070] = 1.88e-004 = pow(10.0, 0.05 * -74.5dB) */
5188c2ecf20Sopenharmony_ci	0x395137ea,		/* [071] = 2.00e-004 = pow(10.0, 0.05 * -74.0dB) */
5198c2ecf20Sopenharmony_ci	0x395d9d8a,		/* [072] = 2.11e-004 = pow(10.0, 0.05 * -73.5dB) */
5208c2ecf20Sopenharmony_ci	0x396abf37,		/* [073] = 2.24e-004 = pow(10.0, 0.05 * -73.0dB) */
5218c2ecf20Sopenharmony_ci	0x3978a814,		/* [074] = 2.37e-004 = pow(10.0, 0.05 * -72.5dB) */
5228c2ecf20Sopenharmony_ci	0x3983b1f8,		/* [075] = 2.51e-004 = pow(10.0, 0.05 * -72.0dB) */
5238c2ecf20Sopenharmony_ci	0x398b7fa6,		/* [076] = 2.66e-004 = pow(10.0, 0.05 * -71.5dB) */
5248c2ecf20Sopenharmony_ci	0x3993c3b2,		/* [077] = 2.82e-004 = pow(10.0, 0.05 * -71.0dB) */
5258c2ecf20Sopenharmony_ci	0x399c8521,		/* [078] = 2.99e-004 = pow(10.0, 0.05 * -70.5dB) */
5268c2ecf20Sopenharmony_ci	0x39a5cb5f,		/* [079] = 3.16e-004 = pow(10.0, 0.05 * -70.0dB) */
5278c2ecf20Sopenharmony_ci	0x39af9e4d,		/* [080] = 3.35e-004 = pow(10.0, 0.05 * -69.5dB) */
5288c2ecf20Sopenharmony_ci	0x39ba063f,		/* [081] = 3.55e-004 = pow(10.0, 0.05 * -69.0dB) */
5298c2ecf20Sopenharmony_ci	0x39c50c0b,		/* [082] = 3.76e-004 = pow(10.0, 0.05 * -68.5dB) */
5308c2ecf20Sopenharmony_ci	0x39d0b90a,		/* [083] = 3.98e-004 = pow(10.0, 0.05 * -68.0dB) */
5318c2ecf20Sopenharmony_ci	0x39dd1726,		/* [084] = 4.22e-004 = pow(10.0, 0.05 * -67.5dB) */
5328c2ecf20Sopenharmony_ci	0x39ea30db,		/* [085] = 4.47e-004 = pow(10.0, 0.05 * -67.0dB) */
5338c2ecf20Sopenharmony_ci	0x39f81149,		/* [086] = 4.73e-004 = pow(10.0, 0.05 * -66.5dB) */
5348c2ecf20Sopenharmony_ci	0x3a03621b,		/* [087] = 5.01e-004 = pow(10.0, 0.05 * -66.0dB) */
5358c2ecf20Sopenharmony_ci	0x3a0b2b0d,		/* [088] = 5.31e-004 = pow(10.0, 0.05 * -65.5dB) */
5368c2ecf20Sopenharmony_ci	0x3a136a16,		/* [089] = 5.62e-004 = pow(10.0, 0.05 * -65.0dB) */
5378c2ecf20Sopenharmony_ci	0x3a1c2636,		/* [090] = 5.96e-004 = pow(10.0, 0.05 * -64.5dB) */
5388c2ecf20Sopenharmony_ci	0x3a2566d5,		/* [091] = 6.31e-004 = pow(10.0, 0.05 * -64.0dB) */
5398c2ecf20Sopenharmony_ci	0x3a2f33cd,		/* [092] = 6.68e-004 = pow(10.0, 0.05 * -63.5dB) */
5408c2ecf20Sopenharmony_ci	0x3a399570,		/* [093] = 7.08e-004 = pow(10.0, 0.05 * -63.0dB) */
5418c2ecf20Sopenharmony_ci	0x3a44948c,		/* [094] = 7.50e-004 = pow(10.0, 0.05 * -62.5dB) */
5428c2ecf20Sopenharmony_ci	0x3a503a77,		/* [095] = 7.94e-004 = pow(10.0, 0.05 * -62.0dB) */
5438c2ecf20Sopenharmony_ci	0x3a5c9112,		/* [096] = 8.41e-004 = pow(10.0, 0.05 * -61.5dB) */
5448c2ecf20Sopenharmony_ci	0x3a69a2d7,		/* [097] = 8.91e-004 = pow(10.0, 0.05 * -61.0dB) */
5458c2ecf20Sopenharmony_ci	0x3a777ada,		/* [098] = 9.44e-004 = pow(10.0, 0.05 * -60.5dB) */
5468c2ecf20Sopenharmony_ci	0x3a83126f,		/* [099] = 1.00e-003 = pow(10.0, 0.05 * -60.0dB) */
5478c2ecf20Sopenharmony_ci	0x3a8ad6a8,		/* [100] = 1.06e-003 = pow(10.0, 0.05 * -59.5dB) */
5488c2ecf20Sopenharmony_ci	0x3a9310b1,		/* [101] = 1.12e-003 = pow(10.0, 0.05 * -59.0dB) */
5498c2ecf20Sopenharmony_ci	0x3a9bc784,		/* [102] = 1.19e-003 = pow(10.0, 0.05 * -58.5dB) */
5508c2ecf20Sopenharmony_ci	0x3aa50287,		/* [103] = 1.26e-003 = pow(10.0, 0.05 * -58.0dB) */
5518c2ecf20Sopenharmony_ci	0x3aaec98e,		/* [104] = 1.33e-003 = pow(10.0, 0.05 * -57.5dB) */
5528c2ecf20Sopenharmony_ci	0x3ab924e5,		/* [105] = 1.41e-003 = pow(10.0, 0.05 * -57.0dB) */
5538c2ecf20Sopenharmony_ci	0x3ac41d56,		/* [106] = 1.50e-003 = pow(10.0, 0.05 * -56.5dB) */
5548c2ecf20Sopenharmony_ci	0x3acfbc31,		/* [107] = 1.58e-003 = pow(10.0, 0.05 * -56.0dB) */
5558c2ecf20Sopenharmony_ci	0x3adc0b51,		/* [108] = 1.68e-003 = pow(10.0, 0.05 * -55.5dB) */
5568c2ecf20Sopenharmony_ci	0x3ae91528,		/* [109] = 1.78e-003 = pow(10.0, 0.05 * -55.0dB) */
5578c2ecf20Sopenharmony_ci	0x3af6e4c6,		/* [110] = 1.88e-003 = pow(10.0, 0.05 * -54.5dB) */
5588c2ecf20Sopenharmony_ci	0x3b02c2f2,		/* [111] = 2.00e-003 = pow(10.0, 0.05 * -54.0dB) */
5598c2ecf20Sopenharmony_ci	0x3b0a8276,		/* [112] = 2.11e-003 = pow(10.0, 0.05 * -53.5dB) */
5608c2ecf20Sopenharmony_ci	0x3b12b782,		/* [113] = 2.24e-003 = pow(10.0, 0.05 * -53.0dB) */
5618c2ecf20Sopenharmony_ci	0x3b1b690d,		/* [114] = 2.37e-003 = pow(10.0, 0.05 * -52.5dB) */
5628c2ecf20Sopenharmony_ci	0x3b249e76,		/* [115] = 2.51e-003 = pow(10.0, 0.05 * -52.0dB) */
5638c2ecf20Sopenharmony_ci	0x3b2e5f8f,		/* [116] = 2.66e-003 = pow(10.0, 0.05 * -51.5dB) */
5648c2ecf20Sopenharmony_ci	0x3b38b49f,		/* [117] = 2.82e-003 = pow(10.0, 0.05 * -51.0dB) */
5658c2ecf20Sopenharmony_ci	0x3b43a669,		/* [118] = 2.99e-003 = pow(10.0, 0.05 * -50.5dB) */
5668c2ecf20Sopenharmony_ci	0x3b4f3e37,		/* [119] = 3.16e-003 = pow(10.0, 0.05 * -50.0dB) */
5678c2ecf20Sopenharmony_ci	0x3b5b85e0,		/* [120] = 3.35e-003 = pow(10.0, 0.05 * -49.5dB) */
5688c2ecf20Sopenharmony_ci	0x3b6887cf,		/* [121] = 3.55e-003 = pow(10.0, 0.05 * -49.0dB) */
5698c2ecf20Sopenharmony_ci	0x3b764f0e,		/* [122] = 3.76e-003 = pow(10.0, 0.05 * -48.5dB) */
5708c2ecf20Sopenharmony_ci	0x3b8273a6,		/* [123] = 3.98e-003 = pow(10.0, 0.05 * -48.0dB) */
5718c2ecf20Sopenharmony_ci	0x3b8a2e77,		/* [124] = 4.22e-003 = pow(10.0, 0.05 * -47.5dB) */
5728c2ecf20Sopenharmony_ci	0x3b925e89,		/* [125] = 4.47e-003 = pow(10.0, 0.05 * -47.0dB) */
5738c2ecf20Sopenharmony_ci	0x3b9b0ace,		/* [126] = 4.73e-003 = pow(10.0, 0.05 * -46.5dB) */
5748c2ecf20Sopenharmony_ci	0x3ba43aa2,		/* [127] = 5.01e-003 = pow(10.0, 0.05 * -46.0dB) */
5758c2ecf20Sopenharmony_ci	0x3badf5d1,		/* [128] = 5.31e-003 = pow(10.0, 0.05 * -45.5dB) */
5768c2ecf20Sopenharmony_ci	0x3bb8449c,		/* [129] = 5.62e-003 = pow(10.0, 0.05 * -45.0dB) */
5778c2ecf20Sopenharmony_ci	0x3bc32fc3,		/* [130] = 5.96e-003 = pow(10.0, 0.05 * -44.5dB) */
5788c2ecf20Sopenharmony_ci	0x3bcec08a,		/* [131] = 6.31e-003 = pow(10.0, 0.05 * -44.0dB) */
5798c2ecf20Sopenharmony_ci	0x3bdb00c0,		/* [132] = 6.68e-003 = pow(10.0, 0.05 * -43.5dB) */
5808c2ecf20Sopenharmony_ci	0x3be7facc,		/* [133] = 7.08e-003 = pow(10.0, 0.05 * -43.0dB) */
5818c2ecf20Sopenharmony_ci	0x3bf5b9b0,		/* [134] = 7.50e-003 = pow(10.0, 0.05 * -42.5dB) */
5828c2ecf20Sopenharmony_ci	0x3c02248a,		/* [135] = 7.94e-003 = pow(10.0, 0.05 * -42.0dB) */
5838c2ecf20Sopenharmony_ci	0x3c09daac,		/* [136] = 8.41e-003 = pow(10.0, 0.05 * -41.5dB) */
5848c2ecf20Sopenharmony_ci	0x3c1205c6,		/* [137] = 8.91e-003 = pow(10.0, 0.05 * -41.0dB) */
5858c2ecf20Sopenharmony_ci	0x3c1aacc8,		/* [138] = 9.44e-003 = pow(10.0, 0.05 * -40.5dB) */
5868c2ecf20Sopenharmony_ci	0x3c23d70a,		/* [139] = 1.00e-002 = pow(10.0, 0.05 * -40.0dB) */
5878c2ecf20Sopenharmony_ci	0x3c2d8c52,		/* [140] = 1.06e-002 = pow(10.0, 0.05 * -39.5dB) */
5888c2ecf20Sopenharmony_ci	0x3c37d4dd,		/* [141] = 1.12e-002 = pow(10.0, 0.05 * -39.0dB) */
5898c2ecf20Sopenharmony_ci	0x3c42b965,		/* [142] = 1.19e-002 = pow(10.0, 0.05 * -38.5dB) */
5908c2ecf20Sopenharmony_ci	0x3c4e4329,		/* [143] = 1.26e-002 = pow(10.0, 0.05 * -38.0dB) */
5918c2ecf20Sopenharmony_ci	0x3c5a7bf1,		/* [144] = 1.33e-002 = pow(10.0, 0.05 * -37.5dB) */
5928c2ecf20Sopenharmony_ci	0x3c676e1e,		/* [145] = 1.41e-002 = pow(10.0, 0.05 * -37.0dB) */
5938c2ecf20Sopenharmony_ci	0x3c7524ac,		/* [146] = 1.50e-002 = pow(10.0, 0.05 * -36.5dB) */
5948c2ecf20Sopenharmony_ci	0x3c81d59f,		/* [147] = 1.58e-002 = pow(10.0, 0.05 * -36.0dB) */
5958c2ecf20Sopenharmony_ci	0x3c898712,		/* [148] = 1.68e-002 = pow(10.0, 0.05 * -35.5dB) */
5968c2ecf20Sopenharmony_ci	0x3c91ad39,		/* [149] = 1.78e-002 = pow(10.0, 0.05 * -35.0dB) */
5978c2ecf20Sopenharmony_ci	0x3c9a4efc,		/* [150] = 1.88e-002 = pow(10.0, 0.05 * -34.5dB) */
5988c2ecf20Sopenharmony_ci	0x3ca373af,		/* [151] = 2.00e-002 = pow(10.0, 0.05 * -34.0dB) */
5998c2ecf20Sopenharmony_ci	0x3cad2314,		/* [152] = 2.11e-002 = pow(10.0, 0.05 * -33.5dB) */
6008c2ecf20Sopenharmony_ci	0x3cb76563,		/* [153] = 2.24e-002 = pow(10.0, 0.05 * -33.0dB) */
6018c2ecf20Sopenharmony_ci	0x3cc24350,		/* [154] = 2.37e-002 = pow(10.0, 0.05 * -32.5dB) */
6028c2ecf20Sopenharmony_ci	0x3ccdc614,		/* [155] = 2.51e-002 = pow(10.0, 0.05 * -32.0dB) */
6038c2ecf20Sopenharmony_ci	0x3cd9f773,		/* [156] = 2.66e-002 = pow(10.0, 0.05 * -31.5dB) */
6048c2ecf20Sopenharmony_ci	0x3ce6e1c6,		/* [157] = 2.82e-002 = pow(10.0, 0.05 * -31.0dB) */
6058c2ecf20Sopenharmony_ci	0x3cf49003,		/* [158] = 2.99e-002 = pow(10.0, 0.05 * -30.5dB) */
6068c2ecf20Sopenharmony_ci	0x3d0186e2,		/* [159] = 3.16e-002 = pow(10.0, 0.05 * -30.0dB) */
6078c2ecf20Sopenharmony_ci	0x3d0933ac,		/* [160] = 3.35e-002 = pow(10.0, 0.05 * -29.5dB) */
6088c2ecf20Sopenharmony_ci	0x3d1154e1,		/* [161] = 3.55e-002 = pow(10.0, 0.05 * -29.0dB) */
6098c2ecf20Sopenharmony_ci	0x3d19f169,		/* [162] = 3.76e-002 = pow(10.0, 0.05 * -28.5dB) */
6108c2ecf20Sopenharmony_ci	0x3d231090,		/* [163] = 3.98e-002 = pow(10.0, 0.05 * -28.0dB) */
6118c2ecf20Sopenharmony_ci	0x3d2cba15,		/* [164] = 4.22e-002 = pow(10.0, 0.05 * -27.5dB) */
6128c2ecf20Sopenharmony_ci	0x3d36f62b,		/* [165] = 4.47e-002 = pow(10.0, 0.05 * -27.0dB) */
6138c2ecf20Sopenharmony_ci	0x3d41cd81,		/* [166] = 4.73e-002 = pow(10.0, 0.05 * -26.5dB) */
6148c2ecf20Sopenharmony_ci	0x3d4d494a,		/* [167] = 5.01e-002 = pow(10.0, 0.05 * -26.0dB) */
6158c2ecf20Sopenharmony_ci	0x3d597345,		/* [168] = 5.31e-002 = pow(10.0, 0.05 * -25.5dB) */
6168c2ecf20Sopenharmony_ci	0x3d6655c3,		/* [169] = 5.62e-002 = pow(10.0, 0.05 * -25.0dB) */
6178c2ecf20Sopenharmony_ci	0x3d73fbb4,		/* [170] = 5.96e-002 = pow(10.0, 0.05 * -24.5dB) */
6188c2ecf20Sopenharmony_ci	0x3d813856,		/* [171] = 6.31e-002 = pow(10.0, 0.05 * -24.0dB) */
6198c2ecf20Sopenharmony_ci	0x3d88e078,		/* [172] = 6.68e-002 = pow(10.0, 0.05 * -23.5dB) */
6208c2ecf20Sopenharmony_ci	0x3d90fcbf,		/* [173] = 7.08e-002 = pow(10.0, 0.05 * -23.0dB) */
6218c2ecf20Sopenharmony_ci	0x3d99940e,		/* [174] = 7.50e-002 = pow(10.0, 0.05 * -22.5dB) */
6228c2ecf20Sopenharmony_ci	0x3da2adad,		/* [175] = 7.94e-002 = pow(10.0, 0.05 * -22.0dB) */
6238c2ecf20Sopenharmony_ci	0x3dac5156,		/* [176] = 8.41e-002 = pow(10.0, 0.05 * -21.5dB) */
6248c2ecf20Sopenharmony_ci	0x3db68738,		/* [177] = 8.91e-002 = pow(10.0, 0.05 * -21.0dB) */
6258c2ecf20Sopenharmony_ci	0x3dc157fb,		/* [178] = 9.44e-002 = pow(10.0, 0.05 * -20.5dB) */
6268c2ecf20Sopenharmony_ci	0x3dcccccd,		/* [179] = 1.00e-001 = pow(10.0, 0.05 * -20.0dB) */
6278c2ecf20Sopenharmony_ci	0x3dd8ef67,		/* [180] = 1.06e-001 = pow(10.0, 0.05 * -19.5dB) */
6288c2ecf20Sopenharmony_ci	0x3de5ca15,		/* [181] = 1.12e-001 = pow(10.0, 0.05 * -19.0dB) */
6298c2ecf20Sopenharmony_ci	0x3df367bf,		/* [182] = 1.19e-001 = pow(10.0, 0.05 * -18.5dB) */
6308c2ecf20Sopenharmony_ci	0x3e00e9f9,		/* [183] = 1.26e-001 = pow(10.0, 0.05 * -18.0dB) */
6318c2ecf20Sopenharmony_ci	0x3e088d77,		/* [184] = 1.33e-001 = pow(10.0, 0.05 * -17.5dB) */
6328c2ecf20Sopenharmony_ci	0x3e10a4d3,		/* [185] = 1.41e-001 = pow(10.0, 0.05 * -17.0dB) */
6338c2ecf20Sopenharmony_ci	0x3e1936ec,		/* [186] = 1.50e-001 = pow(10.0, 0.05 * -16.5dB) */
6348c2ecf20Sopenharmony_ci	0x3e224b06,		/* [187] = 1.58e-001 = pow(10.0, 0.05 * -16.0dB) */
6358c2ecf20Sopenharmony_ci	0x3e2be8d7,		/* [188] = 1.68e-001 = pow(10.0, 0.05 * -15.5dB) */
6368c2ecf20Sopenharmony_ci	0x3e361887,		/* [189] = 1.78e-001 = pow(10.0, 0.05 * -15.0dB) */
6378c2ecf20Sopenharmony_ci	0x3e40e2bb,		/* [190] = 1.88e-001 = pow(10.0, 0.05 * -14.5dB) */
6388c2ecf20Sopenharmony_ci	0x3e4c509b,		/* [191] = 2.00e-001 = pow(10.0, 0.05 * -14.0dB) */
6398c2ecf20Sopenharmony_ci	0x3e586bd9,		/* [192] = 2.11e-001 = pow(10.0, 0.05 * -13.5dB) */
6408c2ecf20Sopenharmony_ci	0x3e653ebb,		/* [193] = 2.24e-001 = pow(10.0, 0.05 * -13.0dB) */
6418c2ecf20Sopenharmony_ci	0x3e72d424,		/* [194] = 2.37e-001 = pow(10.0, 0.05 * -12.5dB) */
6428c2ecf20Sopenharmony_ci	0x3e809bcc,		/* [195] = 2.51e-001 = pow(10.0, 0.05 * -12.0dB) */
6438c2ecf20Sopenharmony_ci	0x3e883aa8,		/* [196] = 2.66e-001 = pow(10.0, 0.05 * -11.5dB) */
6448c2ecf20Sopenharmony_ci	0x3e904d1c,		/* [197] = 2.82e-001 = pow(10.0, 0.05 * -11.0dB) */
6458c2ecf20Sopenharmony_ci	0x3e98da02,		/* [198] = 2.99e-001 = pow(10.0, 0.05 * -10.5dB) */
6468c2ecf20Sopenharmony_ci	0x3ea1e89b,		/* [199] = 3.16e-001 = pow(10.0, 0.05 * -10.0dB) */
6478c2ecf20Sopenharmony_ci	0x3eab8097,		/* [200] = 3.35e-001 = pow(10.0, 0.05 * -9.5dB) */
6488c2ecf20Sopenharmony_ci	0x3eb5aa1a,		/* [201] = 3.55e-001 = pow(10.0, 0.05 * -9.0dB) */
6498c2ecf20Sopenharmony_ci	0x3ec06dc3,		/* [202] = 3.76e-001 = pow(10.0, 0.05 * -8.5dB) */
6508c2ecf20Sopenharmony_ci	0x3ecbd4b4,		/* [203] = 3.98e-001 = pow(10.0, 0.05 * -8.0dB) */
6518c2ecf20Sopenharmony_ci	0x3ed7e89b,		/* [204] = 4.22e-001 = pow(10.0, 0.05 * -7.5dB) */
6528c2ecf20Sopenharmony_ci	0x3ee4b3b6,		/* [205] = 4.47e-001 = pow(10.0, 0.05 * -7.0dB) */
6538c2ecf20Sopenharmony_ci	0x3ef240e2,		/* [206] = 4.73e-001 = pow(10.0, 0.05 * -6.5dB) */
6548c2ecf20Sopenharmony_ci	0x3f004dce,		/* [207] = 5.01e-001 = pow(10.0, 0.05 * -6.0dB) */
6558c2ecf20Sopenharmony_ci	0x3f07e80b,		/* [208] = 5.31e-001 = pow(10.0, 0.05 * -5.5dB) */
6568c2ecf20Sopenharmony_ci	0x3f0ff59a,		/* [209] = 5.62e-001 = pow(10.0, 0.05 * -5.0dB) */
6578c2ecf20Sopenharmony_ci	0x3f187d50,		/* [210] = 5.96e-001 = pow(10.0, 0.05 * -4.5dB) */
6588c2ecf20Sopenharmony_ci	0x3f21866c,		/* [211] = 6.31e-001 = pow(10.0, 0.05 * -4.0dB) */
6598c2ecf20Sopenharmony_ci	0x3f2b1896,		/* [212] = 6.68e-001 = pow(10.0, 0.05 * -3.5dB) */
6608c2ecf20Sopenharmony_ci	0x3f353bef,		/* [213] = 7.08e-001 = pow(10.0, 0.05 * -3.0dB) */
6618c2ecf20Sopenharmony_ci	0x3f3ff911,		/* [214] = 7.50e-001 = pow(10.0, 0.05 * -2.5dB) */
6628c2ecf20Sopenharmony_ci	0x3f4b5918,		/* [215] = 7.94e-001 = pow(10.0, 0.05 * -2.0dB) */
6638c2ecf20Sopenharmony_ci	0x3f5765ac,		/* [216] = 8.41e-001 = pow(10.0, 0.05 * -1.5dB) */
6648c2ecf20Sopenharmony_ci	0x3f642905,		/* [217] = 8.91e-001 = pow(10.0, 0.05 * -1.0dB) */
6658c2ecf20Sopenharmony_ci	0x3f71adf9,		/* [218] = 9.44e-001 = pow(10.0, 0.05 * -0.5dB) */
6668c2ecf20Sopenharmony_ci	0x3f800000,		/* [219] = 1.00e+000 = pow(10.0, 0.05 * 0.0dB) */
6678c2ecf20Sopenharmony_ci	0x3f8795a0,		/* [220] = 1.06e+000 = pow(10.0, 0.05 * 0.5dB) */
6688c2ecf20Sopenharmony_ci	0x3f8f9e4d,		/* [221] = 1.12e+000 = pow(10.0, 0.05 * 1.0dB) */
6698c2ecf20Sopenharmony_ci	0x3f9820d7,		/* [222] = 1.19e+000 = pow(10.0, 0.05 * 1.5dB) */
6708c2ecf20Sopenharmony_ci	0x3fa12478,		/* [223] = 1.26e+000 = pow(10.0, 0.05 * 2.0dB) */
6718c2ecf20Sopenharmony_ci	0x3faab0d5,		/* [224] = 1.33e+000 = pow(10.0, 0.05 * 2.5dB) */
6728c2ecf20Sopenharmony_ci	0x3fb4ce08,		/* [225] = 1.41e+000 = pow(10.0, 0.05 * 3.0dB) */
6738c2ecf20Sopenharmony_ci	0x3fbf84a6,		/* [226] = 1.50e+000 = pow(10.0, 0.05 * 3.5dB) */
6748c2ecf20Sopenharmony_ci	0x3fcaddc8,		/* [227] = 1.58e+000 = pow(10.0, 0.05 * 4.0dB) */
6758c2ecf20Sopenharmony_ci	0x3fd6e30d,		/* [228] = 1.68e+000 = pow(10.0, 0.05 * 4.5dB) */
6768c2ecf20Sopenharmony_ci	0x3fe39ea9,		/* [229] = 1.78e+000 = pow(10.0, 0.05 * 5.0dB) */
6778c2ecf20Sopenharmony_ci	0x3ff11b6a,		/* [230] = 1.88e+000 = pow(10.0, 0.05 * 5.5dB) */
6788c2ecf20Sopenharmony_ci	0x3fff64c1,		/* [231] = 2.00e+000 = pow(10.0, 0.05 * 6.0dB) */
6798c2ecf20Sopenharmony_ci	0x40074368,		/* [232] = 2.11e+000 = pow(10.0, 0.05 * 6.5dB) */
6808c2ecf20Sopenharmony_ci	0x400f4735,		/* [233] = 2.24e+000 = pow(10.0, 0.05 * 7.0dB) */
6818c2ecf20Sopenharmony_ci	0x4017c496,		/* [234] = 2.37e+000 = pow(10.0, 0.05 * 7.5dB) */
6828c2ecf20Sopenharmony_ci	0x4020c2bf,		/* [235] = 2.51e+000 = pow(10.0, 0.05 * 8.0dB) */
6838c2ecf20Sopenharmony_ci	0x402a4952,		/* [236] = 2.66e+000 = pow(10.0, 0.05 * 8.5dB) */
6848c2ecf20Sopenharmony_ci	0x40346063,		/* [237] = 2.82e+000 = pow(10.0, 0.05 * 9.0dB) */
6858c2ecf20Sopenharmony_ci	0x403f1082,		/* [238] = 2.99e+000 = pow(10.0, 0.05 * 9.5dB) */
6868c2ecf20Sopenharmony_ci	0x404a62c2,		/* [239] = 3.16e+000 = pow(10.0, 0.05 * 10.0dB) */
6878c2ecf20Sopenharmony_ci	0x405660bd,		/* [240] = 3.35e+000 = pow(10.0, 0.05 * 10.5dB) */
6888c2ecf20Sopenharmony_ci	0x406314a0,		/* [241] = 3.55e+000 = pow(10.0, 0.05 * 11.0dB) */
6898c2ecf20Sopenharmony_ci	0x40708933,		/* [242] = 3.76e+000 = pow(10.0, 0.05 * 11.5dB) */
6908c2ecf20Sopenharmony_ci	0x407ec9e1,		/* [243] = 3.98e+000 = pow(10.0, 0.05 * 12.0dB) */
6918c2ecf20Sopenharmony_ci	0x4086f161,		/* [244] = 4.22e+000 = pow(10.0, 0.05 * 12.5dB) */
6928c2ecf20Sopenharmony_ci	0x408ef052,		/* [245] = 4.47e+000 = pow(10.0, 0.05 * 13.0dB) */
6938c2ecf20Sopenharmony_ci	0x4097688d,		/* [246] = 4.73e+000 = pow(10.0, 0.05 * 13.5dB) */
6948c2ecf20Sopenharmony_ci	0x40a06142,		/* [247] = 5.01e+000 = pow(10.0, 0.05 * 14.0dB) */
6958c2ecf20Sopenharmony_ci	0x40a9e20e,		/* [248] = 5.31e+000 = pow(10.0, 0.05 * 14.5dB) */
6968c2ecf20Sopenharmony_ci	0x40b3f300,		/* [249] = 5.62e+000 = pow(10.0, 0.05 * 15.0dB) */
6978c2ecf20Sopenharmony_ci	0x40be9ca5,		/* [250] = 5.96e+000 = pow(10.0, 0.05 * 15.5dB) */
6988c2ecf20Sopenharmony_ci	0x40c9e807,		/* [251] = 6.31e+000 = pow(10.0, 0.05 * 16.0dB) */
6998c2ecf20Sopenharmony_ci	0x40d5debc,		/* [252] = 6.68e+000 = pow(10.0, 0.05 * 16.5dB) */
7008c2ecf20Sopenharmony_ci	0x40e28aeb,		/* [253] = 7.08e+000 = pow(10.0, 0.05 * 17.0dB) */
7018c2ecf20Sopenharmony_ci	0x40eff755,		/* [254] = 7.50e+000 = pow(10.0, 0.05 * 17.5dB) */
7028c2ecf20Sopenharmony_ci	0x40fe2f5e,		/* [255] = 7.94e+000 = pow(10.0, 0.05 * 18.0dB) */
7038c2ecf20Sopenharmony_ci};
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_ci#define MIXART_DIGITAL_LEVEL_MIN   0      /* -109.5 dB */
7068c2ecf20Sopenharmony_ci#define MIXART_DIGITAL_LEVEL_MAX   255    /*  18.0 dB */
7078c2ecf20Sopenharmony_ci#define MIXART_DIGITAL_ZERO_LEVEL  219    /*  0.0 dB */
7088c2ecf20Sopenharmony_ci
7098c2ecf20Sopenharmony_ci
7108c2ecf20Sopenharmony_ciint mixart_update_playback_stream_level(struct snd_mixart* chip, int is_aes, int idx)
7118c2ecf20Sopenharmony_ci{
7128c2ecf20Sopenharmony_ci	int err, i;
7138c2ecf20Sopenharmony_ci	int volume[2];
7148c2ecf20Sopenharmony_ci	struct mixart_msg request;
7158c2ecf20Sopenharmony_ci	struct mixart_set_out_stream_level_req set_level;
7168c2ecf20Sopenharmony_ci	u32 status = 0;
7178c2ecf20Sopenharmony_ci	struct mixart_pipe *pipe;
7188c2ecf20Sopenharmony_ci
7198c2ecf20Sopenharmony_ci	memset(&set_level, 0, sizeof(set_level));
7208c2ecf20Sopenharmony_ci	set_level.nb_of_stream = 1;
7218c2ecf20Sopenharmony_ci	set_level.stream_level.desc.stream_idx = idx;
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_ci	if(is_aes) {
7248c2ecf20Sopenharmony_ci		pipe = &chip->pipe_out_dig;	/* AES playback */
7258c2ecf20Sopenharmony_ci		idx += MIXART_PLAYBACK_STREAMS;
7268c2ecf20Sopenharmony_ci	} else {
7278c2ecf20Sopenharmony_ci		pipe = &chip->pipe_out_ana;	/* analog playback */
7288c2ecf20Sopenharmony_ci	}
7298c2ecf20Sopenharmony_ci
7308c2ecf20Sopenharmony_ci	/* only when pipe exists ! */
7318c2ecf20Sopenharmony_ci	if(pipe->status == PIPE_UNDEFINED)
7328c2ecf20Sopenharmony_ci		return 0;
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_ci	set_level.stream_level.desc.uid_pipe = pipe->group_uid;
7358c2ecf20Sopenharmony_ci
7368c2ecf20Sopenharmony_ci	for(i=0; i<2; i++) {
7378c2ecf20Sopenharmony_ci		if(chip->digital_playback_active[idx][i])
7388c2ecf20Sopenharmony_ci			volume[i] = chip->digital_playback_volume[idx][i];
7398c2ecf20Sopenharmony_ci		else
7408c2ecf20Sopenharmony_ci			volume[i] = MIXART_DIGITAL_LEVEL_MIN;
7418c2ecf20Sopenharmony_ci	}
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_ci	set_level.stream_level.out_level.valid_mask1 = MIXART_OUT_STREAM_SET_LEVEL_LEFT_AUDIO1 | MIXART_OUT_STREAM_SET_LEVEL_RIGHT_AUDIO2;
7448c2ecf20Sopenharmony_ci	set_level.stream_level.out_level.left_to_out1_level = mixart_digital_level[volume[0]];
7458c2ecf20Sopenharmony_ci	set_level.stream_level.out_level.right_to_out2_level = mixart_digital_level[volume[1]];
7468c2ecf20Sopenharmony_ci
7478c2ecf20Sopenharmony_ci	request.message_id = MSG_STREAM_SET_OUT_STREAM_LEVEL;
7488c2ecf20Sopenharmony_ci	request.uid = (struct mixart_uid){0,0};
7498c2ecf20Sopenharmony_ci	request.data = &set_level;
7508c2ecf20Sopenharmony_ci	request.size = sizeof(set_level);
7518c2ecf20Sopenharmony_ci
7528c2ecf20Sopenharmony_ci	err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status);
7538c2ecf20Sopenharmony_ci	if((err<0) || status) {
7548c2ecf20Sopenharmony_ci		dev_dbg(chip->card->dev,
7558c2ecf20Sopenharmony_ci			"error MSG_STREAM_SET_OUT_STREAM_LEVEL card(%d) status(%x)\n",
7568c2ecf20Sopenharmony_ci			chip->chip_idx, status);
7578c2ecf20Sopenharmony_ci		return -EINVAL;
7588c2ecf20Sopenharmony_ci	}
7598c2ecf20Sopenharmony_ci	return 0;
7608c2ecf20Sopenharmony_ci}
7618c2ecf20Sopenharmony_ci
7628c2ecf20Sopenharmony_ciint mixart_update_capture_stream_level(struct snd_mixart* chip, int is_aes)
7638c2ecf20Sopenharmony_ci{
7648c2ecf20Sopenharmony_ci	int err, i, idx;
7658c2ecf20Sopenharmony_ci	struct mixart_pipe *pipe;
7668c2ecf20Sopenharmony_ci	struct mixart_msg request;
7678c2ecf20Sopenharmony_ci	struct mixart_set_in_audio_level_req set_level;
7688c2ecf20Sopenharmony_ci	u32 status = 0;
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_ci	if(is_aes) {
7718c2ecf20Sopenharmony_ci		idx = 1;
7728c2ecf20Sopenharmony_ci		pipe = &chip->pipe_in_dig;
7738c2ecf20Sopenharmony_ci	} else {
7748c2ecf20Sopenharmony_ci		idx = 0;
7758c2ecf20Sopenharmony_ci		pipe = &chip->pipe_in_ana;
7768c2ecf20Sopenharmony_ci	}
7778c2ecf20Sopenharmony_ci
7788c2ecf20Sopenharmony_ci	/* only when pipe exists ! */
7798c2ecf20Sopenharmony_ci	if(pipe->status == PIPE_UNDEFINED)
7808c2ecf20Sopenharmony_ci		return 0;
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_ci	memset(&set_level, 0, sizeof(set_level));
7838c2ecf20Sopenharmony_ci	set_level.audio_count = 2;
7848c2ecf20Sopenharmony_ci	set_level.level[0].connector = pipe->uid_left_connector;
7858c2ecf20Sopenharmony_ci	set_level.level[1].connector = pipe->uid_right_connector;
7868c2ecf20Sopenharmony_ci
7878c2ecf20Sopenharmony_ci	for(i=0; i<2; i++) {
7888c2ecf20Sopenharmony_ci		set_level.level[i].valid_mask1 = MIXART_AUDIO_LEVEL_DIGITAL_MASK;
7898c2ecf20Sopenharmony_ci		set_level.level[i].digital_level = mixart_digital_level[chip->digital_capture_volume[idx][i]];
7908c2ecf20Sopenharmony_ci	}
7918c2ecf20Sopenharmony_ci
7928c2ecf20Sopenharmony_ci	request.message_id = MSG_STREAM_SET_IN_AUDIO_LEVEL;
7938c2ecf20Sopenharmony_ci	request.uid = (struct mixart_uid){0,0};
7948c2ecf20Sopenharmony_ci	request.data = &set_level;
7958c2ecf20Sopenharmony_ci	request.size = sizeof(set_level);
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_ci	err = snd_mixart_send_msg(chip->mgr, &request, sizeof(status), &status);
7988c2ecf20Sopenharmony_ci	if((err<0) || status) {
7998c2ecf20Sopenharmony_ci		dev_dbg(chip->card->dev,
8008c2ecf20Sopenharmony_ci			"error MSG_STREAM_SET_IN_AUDIO_LEVEL card(%d) status(%x)\n",
8018c2ecf20Sopenharmony_ci			chip->chip_idx, status);
8028c2ecf20Sopenharmony_ci		return -EINVAL;
8038c2ecf20Sopenharmony_ci	}
8048c2ecf20Sopenharmony_ci	return 0;
8058c2ecf20Sopenharmony_ci}
8068c2ecf20Sopenharmony_ci
8078c2ecf20Sopenharmony_ci
8088c2ecf20Sopenharmony_ci/* shared */
8098c2ecf20Sopenharmony_cistatic int mixart_digital_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
8108c2ecf20Sopenharmony_ci{
8118c2ecf20Sopenharmony_ci	uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
8128c2ecf20Sopenharmony_ci	uinfo->count = 2;
8138c2ecf20Sopenharmony_ci	uinfo->value.integer.min = MIXART_DIGITAL_LEVEL_MIN;   /* -109.5 dB */
8148c2ecf20Sopenharmony_ci	uinfo->value.integer.max = MIXART_DIGITAL_LEVEL_MAX;   /*   18.0 dB */
8158c2ecf20Sopenharmony_ci	return 0;
8168c2ecf20Sopenharmony_ci}
8178c2ecf20Sopenharmony_ci
8188c2ecf20Sopenharmony_ci#define MIXART_VOL_REC_MASK	1
8198c2ecf20Sopenharmony_ci#define MIXART_VOL_AES_MASK	2
8208c2ecf20Sopenharmony_ci
8218c2ecf20Sopenharmony_cistatic int mixart_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
8228c2ecf20Sopenharmony_ci{
8238c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
8248c2ecf20Sopenharmony_ci	int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
8258c2ecf20Sopenharmony_ci	int *stored_volume;
8268c2ecf20Sopenharmony_ci	int is_capture = kcontrol->private_value & MIXART_VOL_REC_MASK;
8278c2ecf20Sopenharmony_ci	int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
8288c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
8298c2ecf20Sopenharmony_ci	if(is_capture) {
8308c2ecf20Sopenharmony_ci		if(is_aes)	stored_volume = chip->digital_capture_volume[1];	/* AES capture */
8318c2ecf20Sopenharmony_ci		else		stored_volume = chip->digital_capture_volume[0];	/* analog capture */
8328c2ecf20Sopenharmony_ci	} else {
8338c2ecf20Sopenharmony_ci		snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
8348c2ecf20Sopenharmony_ci		if(is_aes)	stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx]; /* AES playback */
8358c2ecf20Sopenharmony_ci		else		stored_volume = chip->digital_playback_volume[idx];	/* analog playback */
8368c2ecf20Sopenharmony_ci	}
8378c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[0] = stored_volume[0];
8388c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[1] = stored_volume[1];
8398c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
8408c2ecf20Sopenharmony_ci	return 0;
8418c2ecf20Sopenharmony_ci}
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_cistatic int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
8448c2ecf20Sopenharmony_ci{
8458c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
8468c2ecf20Sopenharmony_ci	int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
8478c2ecf20Sopenharmony_ci	int changed = 0;
8488c2ecf20Sopenharmony_ci	int is_capture = kcontrol->private_value & MIXART_VOL_REC_MASK;
8498c2ecf20Sopenharmony_ci	int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
8508c2ecf20Sopenharmony_ci	int* stored_volume;
8518c2ecf20Sopenharmony_ci	int i;
8528c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
8538c2ecf20Sopenharmony_ci	if (is_capture) {
8548c2ecf20Sopenharmony_ci		if (is_aes)	/* AES capture */
8558c2ecf20Sopenharmony_ci			stored_volume = chip->digital_capture_volume[1];
8568c2ecf20Sopenharmony_ci		else		/* analog capture */
8578c2ecf20Sopenharmony_ci			stored_volume = chip->digital_capture_volume[0];
8588c2ecf20Sopenharmony_ci	} else {
8598c2ecf20Sopenharmony_ci		snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
8608c2ecf20Sopenharmony_ci		if (is_aes)	/* AES playback */
8618c2ecf20Sopenharmony_ci			stored_volume = chip->digital_playback_volume[MIXART_PLAYBACK_STREAMS + idx];
8628c2ecf20Sopenharmony_ci		else		/* analog playback */
8638c2ecf20Sopenharmony_ci			stored_volume = chip->digital_playback_volume[idx];
8648c2ecf20Sopenharmony_ci	}
8658c2ecf20Sopenharmony_ci	for (i = 0; i < 2; i++) {
8668c2ecf20Sopenharmony_ci		int vol = ucontrol->value.integer.value[i];
8678c2ecf20Sopenharmony_ci		if (vol < MIXART_DIGITAL_LEVEL_MIN ||
8688c2ecf20Sopenharmony_ci		    vol > MIXART_DIGITAL_LEVEL_MAX)
8698c2ecf20Sopenharmony_ci			continue;
8708c2ecf20Sopenharmony_ci		if (stored_volume[i] != vol) {
8718c2ecf20Sopenharmony_ci			stored_volume[i] = vol;
8728c2ecf20Sopenharmony_ci			changed = 1;
8738c2ecf20Sopenharmony_ci		}
8748c2ecf20Sopenharmony_ci	}
8758c2ecf20Sopenharmony_ci	if (changed) {
8768c2ecf20Sopenharmony_ci		if (is_capture)
8778c2ecf20Sopenharmony_ci			mixart_update_capture_stream_level(chip, is_aes);
8788c2ecf20Sopenharmony_ci		else
8798c2ecf20Sopenharmony_ci			mixart_update_playback_stream_level(chip, is_aes, idx);
8808c2ecf20Sopenharmony_ci	}
8818c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
8828c2ecf20Sopenharmony_ci	return changed;
8838c2ecf20Sopenharmony_ci}
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_cistatic const DECLARE_TLV_DB_SCALE(db_scale_digital, -10950, 50, 0);
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new snd_mixart_pcm_vol =
8888c2ecf20Sopenharmony_ci{
8898c2ecf20Sopenharmony_ci	.iface =        SNDRV_CTL_ELEM_IFACE_MIXER,
8908c2ecf20Sopenharmony_ci	.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
8918c2ecf20Sopenharmony_ci		   SNDRV_CTL_ELEM_ACCESS_TLV_READ),
8928c2ecf20Sopenharmony_ci	/* name will be filled later */
8938c2ecf20Sopenharmony_ci	/* count will be filled later */
8948c2ecf20Sopenharmony_ci	.info =         mixart_digital_vol_info,		/* shared */
8958c2ecf20Sopenharmony_ci	.get =          mixart_pcm_vol_get,
8968c2ecf20Sopenharmony_ci	.put =          mixart_pcm_vol_put,
8978c2ecf20Sopenharmony_ci	.tlv = { .p = db_scale_digital },
8988c2ecf20Sopenharmony_ci};
8998c2ecf20Sopenharmony_ci
9008c2ecf20Sopenharmony_ci
9018c2ecf20Sopenharmony_cistatic int mixart_pcm_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
9028c2ecf20Sopenharmony_ci{
9038c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
9048c2ecf20Sopenharmony_ci	int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
9058c2ecf20Sopenharmony_ci	snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
9068c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
9078c2ecf20Sopenharmony_ci	if(kcontrol->private_value & MIXART_VOL_AES_MASK)	/* AES playback */
9088c2ecf20Sopenharmony_ci		idx += MIXART_PLAYBACK_STREAMS;
9098c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0];
9108c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1];
9118c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
9128c2ecf20Sopenharmony_ci	return 0;
9138c2ecf20Sopenharmony_ci}
9148c2ecf20Sopenharmony_ci
9158c2ecf20Sopenharmony_cistatic int mixart_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
9168c2ecf20Sopenharmony_ci{
9178c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
9188c2ecf20Sopenharmony_ci	int changed = 0;
9198c2ecf20Sopenharmony_ci	int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK;
9208c2ecf20Sopenharmony_ci	int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */
9218c2ecf20Sopenharmony_ci	int i, j;
9228c2ecf20Sopenharmony_ci	snd_BUG_ON(idx >= MIXART_PLAYBACK_STREAMS);
9238c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
9248c2ecf20Sopenharmony_ci	j = idx;
9258c2ecf20Sopenharmony_ci	if (is_aes)
9268c2ecf20Sopenharmony_ci		j += MIXART_PLAYBACK_STREAMS;
9278c2ecf20Sopenharmony_ci	for (i = 0; i < 2; i++) {
9288c2ecf20Sopenharmony_ci		if (chip->digital_playback_active[j][i] !=
9298c2ecf20Sopenharmony_ci		    ucontrol->value.integer.value[i]) {
9308c2ecf20Sopenharmony_ci			chip->digital_playback_active[j][i] =
9318c2ecf20Sopenharmony_ci				!!ucontrol->value.integer.value[i];
9328c2ecf20Sopenharmony_ci			changed = 1;
9338c2ecf20Sopenharmony_ci		}
9348c2ecf20Sopenharmony_ci	}
9358c2ecf20Sopenharmony_ci	if (changed)
9368c2ecf20Sopenharmony_ci		mixart_update_playback_stream_level(chip, is_aes, idx);
9378c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
9388c2ecf20Sopenharmony_ci	return changed;
9398c2ecf20Sopenharmony_ci}
9408c2ecf20Sopenharmony_ci
9418c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mixart_control_pcm_switch = {
9428c2ecf20Sopenharmony_ci	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
9438c2ecf20Sopenharmony_ci	/* name will be filled later */
9448c2ecf20Sopenharmony_ci	.count =        MIXART_PLAYBACK_STREAMS,
9458c2ecf20Sopenharmony_ci	.info =         mixart_sw_info,		/* shared */
9468c2ecf20Sopenharmony_ci	.get =          mixart_pcm_sw_get,
9478c2ecf20Sopenharmony_ci	.put =          mixart_pcm_sw_put
9488c2ecf20Sopenharmony_ci};
9498c2ecf20Sopenharmony_ci
9508c2ecf20Sopenharmony_cistatic int mixart_update_monitoring(struct snd_mixart* chip, int channel)
9518c2ecf20Sopenharmony_ci{
9528c2ecf20Sopenharmony_ci	int err;
9538c2ecf20Sopenharmony_ci	struct mixart_msg request;
9548c2ecf20Sopenharmony_ci	struct mixart_set_out_audio_level audio_level;
9558c2ecf20Sopenharmony_ci	u32 resp = 0;
9568c2ecf20Sopenharmony_ci
9578c2ecf20Sopenharmony_ci	if(chip->pipe_out_ana.status == PIPE_UNDEFINED)
9588c2ecf20Sopenharmony_ci		return -EINVAL; /* no pipe defined */
9598c2ecf20Sopenharmony_ci
9608c2ecf20Sopenharmony_ci	if(!channel)	request.uid = chip->pipe_out_ana.uid_left_connector;
9618c2ecf20Sopenharmony_ci	else		request.uid = chip->pipe_out_ana.uid_right_connector;
9628c2ecf20Sopenharmony_ci	request.message_id = MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL;
9638c2ecf20Sopenharmony_ci	request.data = &audio_level;
9648c2ecf20Sopenharmony_ci	request.size = sizeof(audio_level);
9658c2ecf20Sopenharmony_ci
9668c2ecf20Sopenharmony_ci	memset(&audio_level, 0, sizeof(audio_level));
9678c2ecf20Sopenharmony_ci	audio_level.valid_mask1 = MIXART_AUDIO_LEVEL_MONITOR_MASK | MIXART_AUDIO_LEVEL_MUTE_M1_MASK;
9688c2ecf20Sopenharmony_ci	audio_level.monitor_level = mixart_digital_level[chip->monitoring_volume[channel!=0]];
9698c2ecf20Sopenharmony_ci	audio_level.monitor_mute1 = !chip->monitoring_active[channel!=0];
9708c2ecf20Sopenharmony_ci
9718c2ecf20Sopenharmony_ci	err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
9728c2ecf20Sopenharmony_ci	if((err<0) || resp) {
9738c2ecf20Sopenharmony_ci		dev_dbg(chip->card->dev,
9748c2ecf20Sopenharmony_ci			"error MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL card(%d) resp(%x)\n",
9758c2ecf20Sopenharmony_ci			chip->chip_idx, resp);
9768c2ecf20Sopenharmony_ci		return -EINVAL;
9778c2ecf20Sopenharmony_ci	}
9788c2ecf20Sopenharmony_ci	return 0;
9798c2ecf20Sopenharmony_ci}
9808c2ecf20Sopenharmony_ci
9818c2ecf20Sopenharmony_ci/*
9828c2ecf20Sopenharmony_ci * monitoring level control
9838c2ecf20Sopenharmony_ci */
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_cistatic int mixart_monitor_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
9868c2ecf20Sopenharmony_ci{
9878c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
9888c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
9898c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[0] = chip->monitoring_volume[0];
9908c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[1] = chip->monitoring_volume[1];
9918c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
9928c2ecf20Sopenharmony_ci	return 0;
9938c2ecf20Sopenharmony_ci}
9948c2ecf20Sopenharmony_ci
9958c2ecf20Sopenharmony_cistatic int mixart_monitor_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
9968c2ecf20Sopenharmony_ci{
9978c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
9988c2ecf20Sopenharmony_ci	int changed = 0;
9998c2ecf20Sopenharmony_ci	int i;
10008c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
10018c2ecf20Sopenharmony_ci	for (i = 0; i < 2; i++) {
10028c2ecf20Sopenharmony_ci		if (chip->monitoring_volume[i] !=
10038c2ecf20Sopenharmony_ci		    ucontrol->value.integer.value[i]) {
10048c2ecf20Sopenharmony_ci			chip->monitoring_volume[i] =
10058c2ecf20Sopenharmony_ci				!!ucontrol->value.integer.value[i];
10068c2ecf20Sopenharmony_ci			mixart_update_monitoring(chip, i);
10078c2ecf20Sopenharmony_ci			changed = 1;
10088c2ecf20Sopenharmony_ci		}
10098c2ecf20Sopenharmony_ci	}
10108c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
10118c2ecf20Sopenharmony_ci	return changed;
10128c2ecf20Sopenharmony_ci}
10138c2ecf20Sopenharmony_ci
10148c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mixart_control_monitor_vol = {
10158c2ecf20Sopenharmony_ci	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
10168c2ecf20Sopenharmony_ci	.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
10178c2ecf20Sopenharmony_ci		   SNDRV_CTL_ELEM_ACCESS_TLV_READ),
10188c2ecf20Sopenharmony_ci	.name =         "Monitoring Volume",
10198c2ecf20Sopenharmony_ci	.info =		mixart_digital_vol_info,		/* shared */
10208c2ecf20Sopenharmony_ci	.get =		mixart_monitor_vol_get,
10218c2ecf20Sopenharmony_ci	.put =		mixart_monitor_vol_put,
10228c2ecf20Sopenharmony_ci	.tlv = { .p = db_scale_digital },
10238c2ecf20Sopenharmony_ci};
10248c2ecf20Sopenharmony_ci
10258c2ecf20Sopenharmony_ci/*
10268c2ecf20Sopenharmony_ci * monitoring switch control
10278c2ecf20Sopenharmony_ci */
10288c2ecf20Sopenharmony_ci
10298c2ecf20Sopenharmony_cistatic int mixart_monitor_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
10308c2ecf20Sopenharmony_ci{
10318c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
10328c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
10338c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[0] = chip->monitoring_active[0];
10348c2ecf20Sopenharmony_ci	ucontrol->value.integer.value[1] = chip->monitoring_active[1];
10358c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
10368c2ecf20Sopenharmony_ci	return 0;
10378c2ecf20Sopenharmony_ci}
10388c2ecf20Sopenharmony_ci
10398c2ecf20Sopenharmony_cistatic int mixart_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
10408c2ecf20Sopenharmony_ci{
10418c2ecf20Sopenharmony_ci	struct snd_mixart *chip = snd_kcontrol_chip(kcontrol);
10428c2ecf20Sopenharmony_ci	int changed = 0;
10438c2ecf20Sopenharmony_ci	int i;
10448c2ecf20Sopenharmony_ci	mutex_lock(&chip->mgr->mixer_mutex);
10458c2ecf20Sopenharmony_ci	for (i = 0; i < 2; i++) {
10468c2ecf20Sopenharmony_ci		if (chip->monitoring_active[i] !=
10478c2ecf20Sopenharmony_ci		    ucontrol->value.integer.value[i]) {
10488c2ecf20Sopenharmony_ci			chip->monitoring_active[i] =
10498c2ecf20Sopenharmony_ci				!!ucontrol->value.integer.value[i];
10508c2ecf20Sopenharmony_ci			changed |= (1<<i); /* mask 0x01 ans 0x02 */
10518c2ecf20Sopenharmony_ci		}
10528c2ecf20Sopenharmony_ci	}
10538c2ecf20Sopenharmony_ci	if (changed) {
10548c2ecf20Sopenharmony_ci		/* allocate or release resources for monitoring */
10558c2ecf20Sopenharmony_ci		int allocate = chip->monitoring_active[0] ||
10568c2ecf20Sopenharmony_ci			chip->monitoring_active[1];
10578c2ecf20Sopenharmony_ci		if (allocate) {
10588c2ecf20Sopenharmony_ci			/* allocate the playback pipe for monitoring */
10598c2ecf20Sopenharmony_ci			snd_mixart_add_ref_pipe(chip, MIXART_PCM_ANALOG, 0, 1);
10608c2ecf20Sopenharmony_ci			/* allocate the capture pipe for monitoring */
10618c2ecf20Sopenharmony_ci			snd_mixart_add_ref_pipe(chip, MIXART_PCM_ANALOG, 1, 1);
10628c2ecf20Sopenharmony_ci		}
10638c2ecf20Sopenharmony_ci		if (changed & 0x01)
10648c2ecf20Sopenharmony_ci			mixart_update_monitoring(chip, 0);
10658c2ecf20Sopenharmony_ci		if (changed & 0x02)
10668c2ecf20Sopenharmony_ci			mixart_update_monitoring(chip, 1);
10678c2ecf20Sopenharmony_ci		if (!allocate) {
10688c2ecf20Sopenharmony_ci			/* release the capture pipe for monitoring */
10698c2ecf20Sopenharmony_ci			snd_mixart_kill_ref_pipe(chip->mgr,
10708c2ecf20Sopenharmony_ci						 &chip->pipe_in_ana, 1);
10718c2ecf20Sopenharmony_ci			/* release the playback pipe for monitoring */
10728c2ecf20Sopenharmony_ci			snd_mixart_kill_ref_pipe(chip->mgr,
10738c2ecf20Sopenharmony_ci						 &chip->pipe_out_ana, 1);
10748c2ecf20Sopenharmony_ci		}
10758c2ecf20Sopenharmony_ci	}
10768c2ecf20Sopenharmony_ci
10778c2ecf20Sopenharmony_ci	mutex_unlock(&chip->mgr->mixer_mutex);
10788c2ecf20Sopenharmony_ci	return (changed != 0);
10798c2ecf20Sopenharmony_ci}
10808c2ecf20Sopenharmony_ci
10818c2ecf20Sopenharmony_cistatic const struct snd_kcontrol_new mixart_control_monitor_sw = {
10828c2ecf20Sopenharmony_ci	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
10838c2ecf20Sopenharmony_ci	.name =         "Monitoring Switch",
10848c2ecf20Sopenharmony_ci	.info =         mixart_sw_info,		/* shared */
10858c2ecf20Sopenharmony_ci	.get =          mixart_monitor_sw_get,
10868c2ecf20Sopenharmony_ci	.put =          mixart_monitor_sw_put
10878c2ecf20Sopenharmony_ci};
10888c2ecf20Sopenharmony_ci
10898c2ecf20Sopenharmony_ci
10908c2ecf20Sopenharmony_cistatic void mixart_reset_audio_levels(struct snd_mixart *chip)
10918c2ecf20Sopenharmony_ci{
10928c2ecf20Sopenharmony_ci	/* analog volumes can be set even if there is no pipe */
10938c2ecf20Sopenharmony_ci	mixart_update_analog_audio_level(chip, 0);
10948c2ecf20Sopenharmony_ci	/* analog levels for capture only on the first two chips */
10958c2ecf20Sopenharmony_ci	if(chip->chip_idx < 2) {
10968c2ecf20Sopenharmony_ci		mixart_update_analog_audio_level(chip, 1);
10978c2ecf20Sopenharmony_ci	}
10988c2ecf20Sopenharmony_ci	return;
10998c2ecf20Sopenharmony_ci}
11008c2ecf20Sopenharmony_ci
11018c2ecf20Sopenharmony_ci
11028c2ecf20Sopenharmony_ciint snd_mixart_create_mixer(struct mixart_mgr *mgr)
11038c2ecf20Sopenharmony_ci{
11048c2ecf20Sopenharmony_ci	struct snd_mixart *chip;
11058c2ecf20Sopenharmony_ci	int err, i;
11068c2ecf20Sopenharmony_ci
11078c2ecf20Sopenharmony_ci	mutex_init(&mgr->mixer_mutex); /* can be in another place */
11088c2ecf20Sopenharmony_ci
11098c2ecf20Sopenharmony_ci	for(i=0; i<mgr->num_cards; i++) {
11108c2ecf20Sopenharmony_ci		struct snd_kcontrol_new temp;
11118c2ecf20Sopenharmony_ci		chip = mgr->chip[i];
11128c2ecf20Sopenharmony_ci
11138c2ecf20Sopenharmony_ci		/* analog output level control */
11148c2ecf20Sopenharmony_ci		temp = mixart_control_analog_level;
11158c2ecf20Sopenharmony_ci		temp.name = "Master Playback Volume";
11168c2ecf20Sopenharmony_ci		temp.private_value = 0; /* playback */
11178c2ecf20Sopenharmony_ci		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
11188c2ecf20Sopenharmony_ci			return err;
11198c2ecf20Sopenharmony_ci		/* output mute controls */
11208c2ecf20Sopenharmony_ci		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_output_switch, chip))) < 0)
11218c2ecf20Sopenharmony_ci			return err;
11228c2ecf20Sopenharmony_ci
11238c2ecf20Sopenharmony_ci		/* analog input level control only on first two chips !*/
11248c2ecf20Sopenharmony_ci		if(i<2) {
11258c2ecf20Sopenharmony_ci			temp = mixart_control_analog_level;
11268c2ecf20Sopenharmony_ci			temp.name = "Master Capture Volume";
11278c2ecf20Sopenharmony_ci			temp.private_value = 1; /* capture */
11288c2ecf20Sopenharmony_ci			if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
11298c2ecf20Sopenharmony_ci				return err;
11308c2ecf20Sopenharmony_ci		}
11318c2ecf20Sopenharmony_ci
11328c2ecf20Sopenharmony_ci		temp = snd_mixart_pcm_vol;
11338c2ecf20Sopenharmony_ci		temp.name = "PCM Playback Volume";
11348c2ecf20Sopenharmony_ci		temp.count = MIXART_PLAYBACK_STREAMS;
11358c2ecf20Sopenharmony_ci		temp.private_value = 0; /* playback analog */
11368c2ecf20Sopenharmony_ci		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
11378c2ecf20Sopenharmony_ci			return err;
11388c2ecf20Sopenharmony_ci
11398c2ecf20Sopenharmony_ci		temp.name = "PCM Capture Volume";
11408c2ecf20Sopenharmony_ci		temp.count = 1;
11418c2ecf20Sopenharmony_ci		temp.private_value = MIXART_VOL_REC_MASK; /* capture analog */
11428c2ecf20Sopenharmony_ci		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
11438c2ecf20Sopenharmony_ci			return err;
11448c2ecf20Sopenharmony_ci
11458c2ecf20Sopenharmony_ci		if(mgr->board_type == MIXART_DAUGHTER_TYPE_AES) {
11468c2ecf20Sopenharmony_ci			temp.name = "AES Playback Volume";
11478c2ecf20Sopenharmony_ci			temp.count = MIXART_PLAYBACK_STREAMS;
11488c2ecf20Sopenharmony_ci			temp.private_value = MIXART_VOL_AES_MASK; /* playback AES/EBU */
11498c2ecf20Sopenharmony_ci			if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
11508c2ecf20Sopenharmony_ci				return err;
11518c2ecf20Sopenharmony_ci
11528c2ecf20Sopenharmony_ci			temp.name = "AES Capture Volume";
11538c2ecf20Sopenharmony_ci			temp.count = 0;
11548c2ecf20Sopenharmony_ci			temp.private_value = MIXART_VOL_REC_MASK | MIXART_VOL_AES_MASK; /* capture AES/EBU */
11558c2ecf20Sopenharmony_ci			if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
11568c2ecf20Sopenharmony_ci				return err;
11578c2ecf20Sopenharmony_ci		}
11588c2ecf20Sopenharmony_ci		temp = mixart_control_pcm_switch;
11598c2ecf20Sopenharmony_ci		temp.name = "PCM Playback Switch";
11608c2ecf20Sopenharmony_ci		temp.private_value = 0; /* playback analog */
11618c2ecf20Sopenharmony_ci		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
11628c2ecf20Sopenharmony_ci			return err;
11638c2ecf20Sopenharmony_ci
11648c2ecf20Sopenharmony_ci		if(mgr->board_type == MIXART_DAUGHTER_TYPE_AES) {
11658c2ecf20Sopenharmony_ci			temp.name = "AES Playback Switch";
11668c2ecf20Sopenharmony_ci			temp.private_value = MIXART_VOL_AES_MASK; /* playback AES/EBU */
11678c2ecf20Sopenharmony_ci			if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
11688c2ecf20Sopenharmony_ci				return err;
11698c2ecf20Sopenharmony_ci		}
11708c2ecf20Sopenharmony_ci
11718c2ecf20Sopenharmony_ci		/* monitoring */
11728c2ecf20Sopenharmony_ci		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_monitor_vol, chip))) < 0)
11738c2ecf20Sopenharmony_ci			return err;
11748c2ecf20Sopenharmony_ci		if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&mixart_control_monitor_sw, chip))) < 0)
11758c2ecf20Sopenharmony_ci			return err;
11768c2ecf20Sopenharmony_ci
11778c2ecf20Sopenharmony_ci		/* init all mixer data and program the master volumes/switches */
11788c2ecf20Sopenharmony_ci		mixart_reset_audio_levels(chip);
11798c2ecf20Sopenharmony_ci	}
11808c2ecf20Sopenharmony_ci	return 0;
11818c2ecf20Sopenharmony_ci}
1182