aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/es1938.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/es1938.c')
-rw-r--r--sound/pci/es1938.c103
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
1317static 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
1323static 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
1329static 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
1335static 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
1341static 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
1347static DECLARE_TLV_DB_SCALE(db_scale_capture, 0, 150, 0);
1348
1300static struct snd_kcontrol_new snd_es1938_controls[] = { 1349static struct snd_kcontrol_new snd_es1938_controls[] = {
1301ES1938_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0), 1350ES1938_DOUBLE_TLV("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0,
1351 db_scale_master),
1302ES1938_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), 1352ES1938_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},
1317ES1938_SINGLE("Hardware Volume Split", 0, 0x64, 7, 1, 0), 1370ES1938_SINGLE("Hardware Volume Split", 0, 0x64, 7, 1, 0),
1318ES1938_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0), 1371ES1938_DOUBLE_TLV("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0,
1372 db_scale_line),
1319ES1938_DOUBLE("CD Playback Volume", 0, 0x38, 0x38, 4, 0, 15, 0), 1373ES1938_DOUBLE("CD Playback Volume", 0, 0x38, 0x38, 4, 0, 15, 0),
1320ES1938_DOUBLE("FM Playback Volume", 0, 0x36, 0x36, 4, 0, 15, 0), 1374ES1938_DOUBLE_TLV("FM Playback Volume", 0, 0x36, 0x36, 4, 0, 15, 0,
1321ES1938_DOUBLE("Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0), 1375 db_scale_mic),
1322ES1938_DOUBLE("Mic Playback Volume", 0, 0x1a, 0x1a, 4, 0, 15, 0), 1376ES1938_DOUBLE_TLV("Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0,
1323ES1938_DOUBLE("Aux Playback Volume", 0, 0x3a, 0x3a, 4, 0, 15, 0), 1377 db_scale_line),
1324ES1938_DOUBLE("Capture Volume", 0, 0xb4, 0xb4, 4, 0, 15, 0), 1378ES1938_DOUBLE_TLV("Mic Playback Volume", 0, 0x1a, 0x1a, 4, 0, 15, 0,
1379 db_scale_mic),
1380ES1938_DOUBLE_TLV("Aux Playback Volume", 0, 0x3a, 0x3a, 4, 0, 15, 0,
1381 db_scale_line),
1382ES1938_DOUBLE_TLV("Capture Volume", 0, 0xb4, 0xb4, 4, 0, 15, 0,
1383 db_scale_capture),
1325ES1938_SINGLE("PC Speaker Volume", 0, 0x3c, 0, 7, 0), 1384ES1938_SINGLE("PC Speaker Volume", 0, 0x3c, 0, 7, 0),
1326ES1938_SINGLE("Record Monitor", 0, 0xa8, 3, 1, 0), 1385ES1938_SINGLE("Record Monitor", 0, 0xa8, 3, 1, 0),
1327ES1938_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), 1386ES1938_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},
1335ES1938_DOUBLE("Mono Input Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0), 1394ES1938_DOUBLE_TLV("Mono Input Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0,
1336ES1938_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0), 1395 db_scale_line),
1337ES1938_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0), 1396ES1938_DOUBLE_TLV("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0,
1338ES1938_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0), 1397 db_scale_audio2),
1339ES1938_DOUBLE("FM Capture Volume", 0, 0x6b, 0x6b, 4, 0, 15, 0), 1398ES1938_DOUBLE_TLV("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0,
1340ES1938_DOUBLE("Mono Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0), 1399 db_scale_mic),
1341ES1938_DOUBLE("CD Capture Volume", 0, 0x6a, 0x6a, 4, 0, 15, 0), 1400ES1938_DOUBLE_TLV("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0,
1342ES1938_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0), 1401 db_scale_line),
1343ES1938_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0), 1402ES1938_DOUBLE_TLV("FM Capture Volume", 0, 0x6b, 0x6b, 4, 0, 15, 0,
1344ES1938_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0), 1403 db_scale_mic),
1404ES1938_DOUBLE_TLV("Mono Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0,
1405 db_scale_line),
1406ES1938_DOUBLE_TLV("CD Capture Volume", 0, 0x6a, 0x6a, 4, 0, 15, 0,
1407 db_scale_line),
1408ES1938_DOUBLE_TLV("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0,
1409 db_scale_line),
1410ES1938_DOUBLE_TLV("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0,
1411 db_scale_audio2),
1412ES1938_DOUBLE_TLV("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0,
1413 db_scale_audio1),
1345ES1938_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), 1414ES1938_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,