diff options
author | Takashi Iwai <tiwai@suse.de> | 2006-09-06 07:35:27 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-09-23 04:46:18 -0400 |
commit | 0b59397268ed418e139db3806f7956ffcb18b33d (patch) | |
tree | 4f5a0a91be5e0bfbfe244b755be6820d66dca3a0 /sound/pci/es1938.c | |
parent | 55a29af5ed5d914f017e6a7c613a4d7cc34f82d9 (diff) |
[ALSA] Add dB information to es1938 driver
Added the dB information to ESS Solo (es1938) driver.
The new compound dB range TLVs are used for non-linear native
volume controls.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/es1938.c')
-rw-r--r-- | sound/pci/es1938.c | 103 |
1 files changed, 86 insertions, 17 deletions
diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index cc0f34f68185..3784088bea84 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #include <sound/opl3.h> | 62 | #include <sound/opl3.h> |
63 | #include <sound/mpu401.h> | 63 | #include <sound/mpu401.h> |
64 | #include <sound/initval.h> | 64 | #include <sound/initval.h> |
65 | #include <sound/tlv.h> | ||
65 | 66 | ||
66 | #include <asm/io.h> | 67 | #include <asm/io.h> |
67 | 68 | ||
@@ -1164,6 +1165,14 @@ static int snd_es1938_reg_read(struct es1938 *chip, unsigned char reg) | |||
1164 | return snd_es1938_read(chip, reg); | 1165 | return snd_es1938_read(chip, reg); |
1165 | } | 1166 | } |
1166 | 1167 | ||
1168 | #define ES1938_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \ | ||
1169 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1170 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,\ | ||
1171 | .name = xname, .index = xindex, \ | ||
1172 | .info = snd_es1938_info_single, \ | ||
1173 | .get = snd_es1938_get_single, .put = snd_es1938_put_single, \ | ||
1174 | .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24), \ | ||
1175 | .tlv = { .p = xtlv } } | ||
1167 | #define ES1938_SINGLE(xname, xindex, reg, shift, mask, invert) \ | 1176 | #define ES1938_SINGLE(xname, xindex, reg, shift, mask, invert) \ |
1168 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 1177 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
1169 | .info = snd_es1938_info_single, \ | 1178 | .info = snd_es1938_info_single, \ |
@@ -1217,6 +1226,14 @@ static int snd_es1938_put_single(struct snd_kcontrol *kcontrol, | |||
1217 | return snd_es1938_reg_bits(chip, reg, mask, val) != val; | 1226 | return snd_es1938_reg_bits(chip, reg, mask, val) != val; |
1218 | } | 1227 | } |
1219 | 1228 | ||
1229 | #define ES1938_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \ | ||
1230 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
1231 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,\ | ||
1232 | .name = xname, .index = xindex, \ | ||
1233 | .info = snd_es1938_info_double, \ | ||
1234 | .get = snd_es1938_get_double, .put = snd_es1938_put_double, \ | ||
1235 | .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22), \ | ||
1236 | .tlv = { .p = xtlv } } | ||
1220 | #define ES1938_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ | 1237 | #define ES1938_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ |
1221 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ | 1238 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ |
1222 | .info = snd_es1938_info_double, \ | 1239 | .info = snd_es1938_info_double, \ |
@@ -1297,8 +1314,41 @@ static int snd_es1938_put_double(struct snd_kcontrol *kcontrol, | |||
1297 | return change; | 1314 | return change; |
1298 | } | 1315 | } |
1299 | 1316 | ||
1317 | static unsigned int db_scale_master[] = { | ||
1318 | TLV_DB_RANGE_HEAD(2), | ||
1319 | 0, 54, TLV_DB_SCALE_ITEM(-3600, 50, 1), | ||
1320 | 54, 63, TLV_DB_SCALE_ITEM(-900, 100, 0), | ||
1321 | }; | ||
1322 | |||
1323 | static unsigned int db_scale_audio1[] = { | ||
1324 | TLV_DB_RANGE_HEAD(2), | ||
1325 | 0, 8, TLV_DB_SCALE_ITEM(-3300, 300, 1), | ||
1326 | 8, 15, TLV_DB_SCALE_ITEM(-900, 150, 0), | ||
1327 | }; | ||
1328 | |||
1329 | static unsigned int db_scale_audio2[] = { | ||
1330 | TLV_DB_RANGE_HEAD(2), | ||
1331 | 0, 8, TLV_DB_SCALE_ITEM(-3450, 300, 1), | ||
1332 | 8, 15, TLV_DB_SCALE_ITEM(-1050, 150, 0), | ||
1333 | }; | ||
1334 | |||
1335 | static unsigned int db_scale_mic[] = { | ||
1336 | TLV_DB_RANGE_HEAD(2), | ||
1337 | 0, 8, TLV_DB_SCALE_ITEM(-2400, 300, 1), | ||
1338 | 8, 15, TLV_DB_SCALE_ITEM(0, 150, 0), | ||
1339 | }; | ||
1340 | |||
1341 | static unsigned int db_scale_line[] = { | ||
1342 | TLV_DB_RANGE_HEAD(2), | ||
1343 | 0, 8, TLV_DB_SCALE_ITEM(-3150, 300, 1), | ||
1344 | 8, 15, TLV_DB_SCALE_ITEM(-750, 150, 0), | ||
1345 | }; | ||
1346 | |||
1347 | static DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0); | ||
1348 | |||
1300 | static struct snd_kcontrol_new snd_es1938_controls[] = { | 1349 | static struct snd_kcontrol_new snd_es1938_controls[] = { |
1301 | ES1938_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0), | 1350 | ES1938_DOUBLE_TLV("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0, |
1351 | db_scale_master), | ||
1302 | ES1938_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), | 1352 | ES1938_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), |
1303 | { | 1353 | { |
1304 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1354 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
@@ -1309,19 +1359,28 @@ ES1938_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), | |||
1309 | }, | 1359 | }, |
1310 | { | 1360 | { |
1311 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1361 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
1362 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
1363 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), | ||
1312 | .name = "Hardware Master Playback Switch", | 1364 | .name = "Hardware Master Playback Switch", |
1313 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | 1365 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
1314 | .info = snd_es1938_info_hw_switch, | 1366 | .info = snd_es1938_info_hw_switch, |
1315 | .get = snd_es1938_get_hw_switch, | 1367 | .get = snd_es1938_get_hw_switch, |
1368 | .tlv = { .p = db_scale_master }, | ||
1316 | }, | 1369 | }, |
1317 | ES1938_SINGLE("Hardware Volume Split", 0, 0x64, 7, 1, 0), | 1370 | ES1938_SINGLE("Hardware Volume Split", 0, 0x64, 7, 1, 0), |
1318 | ES1938_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0), | 1371 | ES1938_DOUBLE_TLV("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0, |
1372 | db_scale_line), | ||
1319 | ES1938_DOUBLE("CD Playback Volume", 0, 0x38, 0x38, 4, 0, 15, 0), | 1373 | ES1938_DOUBLE("CD Playback Volume", 0, 0x38, 0x38, 4, 0, 15, 0), |
1320 | ES1938_DOUBLE("FM Playback Volume", 0, 0x36, 0x36, 4, 0, 15, 0), | 1374 | ES1938_DOUBLE_TLV("FM Playback Volume", 0, 0x36, 0x36, 4, 0, 15, 0, |
1321 | ES1938_DOUBLE("Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0), | 1375 | db_scale_mic), |
1322 | ES1938_DOUBLE("Mic Playback Volume", 0, 0x1a, 0x1a, 4, 0, 15, 0), | 1376 | ES1938_DOUBLE_TLV("Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0, |
1323 | ES1938_DOUBLE("Aux Playback Volume", 0, 0x3a, 0x3a, 4, 0, 15, 0), | 1377 | db_scale_line), |
1324 | ES1938_DOUBLE("Capture Volume", 0, 0xb4, 0xb4, 4, 0, 15, 0), | 1378 | ES1938_DOUBLE_TLV("Mic Playback Volume", 0, 0x1a, 0x1a, 4, 0, 15, 0, |
1379 | db_scale_mic), | ||
1380 | ES1938_DOUBLE_TLV("Aux Playback Volume", 0, 0x3a, 0x3a, 4, 0, 15, 0, | ||
1381 | db_scale_line), | ||
1382 | ES1938_DOUBLE_TLV("Capture Volume", 0, 0xb4, 0xb4, 4, 0, 15, 0, | ||
1383 | db_scale_capture), | ||
1325 | ES1938_SINGLE("PC Speaker Volume", 0, 0x3c, 0, 7, 0), | 1384 | ES1938_SINGLE("PC Speaker Volume", 0, 0x3c, 0, 7, 0), |
1326 | ES1938_SINGLE("Record Monitor", 0, 0xa8, 3, 1, 0), | 1385 | ES1938_SINGLE("Record Monitor", 0, 0xa8, 3, 1, 0), |
1327 | ES1938_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), | 1386 | ES1938_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), |
@@ -1332,16 +1391,26 @@ ES1938_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), | |||
1332 | .get = snd_es1938_get_mux, | 1391 | .get = snd_es1938_get_mux, |
1333 | .put = snd_es1938_put_mux, | 1392 | .put = snd_es1938_put_mux, |
1334 | }, | 1393 | }, |
1335 | ES1938_DOUBLE("Mono Input Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0), | 1394 | ES1938_DOUBLE_TLV("Mono Input Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0, |
1336 | ES1938_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0), | 1395 | db_scale_line), |
1337 | ES1938_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0), | 1396 | ES1938_DOUBLE_TLV("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0, |
1338 | ES1938_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0), | 1397 | db_scale_audio2), |
1339 | ES1938_DOUBLE("FM Capture Volume", 0, 0x6b, 0x6b, 4, 0, 15, 0), | 1398 | ES1938_DOUBLE_TLV("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0, |
1340 | ES1938_DOUBLE("Mono Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0), | 1399 | db_scale_mic), |
1341 | ES1938_DOUBLE("CD Capture Volume", 0, 0x6a, 0x6a, 4, 0, 15, 0), | 1400 | ES1938_DOUBLE_TLV("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0, |
1342 | ES1938_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0), | 1401 | db_scale_line), |
1343 | ES1938_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0), | 1402 | ES1938_DOUBLE_TLV("FM Capture Volume", 0, 0x6b, 0x6b, 4, 0, 15, 0, |
1344 | ES1938_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0), | 1403 | db_scale_mic), |
1404 | ES1938_DOUBLE_TLV("Mono Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0, | ||
1405 | db_scale_line), | ||
1406 | ES1938_DOUBLE_TLV("CD Capture Volume", 0, 0x6a, 0x6a, 4, 0, 15, 0, | ||
1407 | db_scale_line), | ||
1408 | ES1938_DOUBLE_TLV("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0, | ||
1409 | db_scale_line), | ||
1410 | ES1938_DOUBLE_TLV("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0, | ||
1411 | db_scale_audio2), | ||
1412 | ES1938_DOUBLE_TLV("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0, | ||
1413 | db_scale_audio1), | ||
1345 | ES1938_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), | 1414 | ES1938_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), |
1346 | { | 1415 | { |
1347 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 1416 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |