History

ALSA: emu10k1: enable bit-exact playback, part 1: DSP attenuation

Fractional multiplication with the maximal value 2^31-1 causes some tiny distortion. Instead, we want to multiply with the full 2^31. The catch is of course that this cannot be represented in the DSP's signed 32 bit registers. One way to deal with this is to encode 1.0 as a negative number and special-case it. As a matter of fact, the SbLive! code path already contained such code, though the controls never actually exercised it. A more efficient approach is to use negative values, which actually extend to -2^31. Accordingly, for all the volume adjustments we now use the MAC1 instruction which negates the X operand. The range of the controls in highres mode is extended downwards, so -1 is the new zero/mute. At maximal excursion, real zero is not mute any more, but I don't think anyone will notice this behavior change. ;-) That also required making the min/max/values in the control structs signed. This technically changes the user space interface, but it seems implausible that someone would notice - the numbers were actually treated as if they were signed anyway (and in the actual mixer iface they _are_). And without this change, the min value didn't even make sense in the first place (and no-one noticed, because it was always 0).

Oswald Buddenhagen committed 3 years ago

Commit 1298bc91 parent de0dc313 files · +64 −69Browse files

Unified · Split

3 files
  1. include/sound/emu10k1.h +3 −3
  2. include/uapi/sound/emu10k1.h +5 −3
  3. sound/pci/emu10k1/emufx.c +56 −63
include/sound/emu10k1.h+3−3
@@ -1508,9 +1508,9 @@ struct snd_emu10k1_fx8010_ctl { · 1507 unmodified lines
1508 unsigned int vcount;1508 unsigned int vcount;
1509 unsigned int count; /* count of GPR (1..16) */1509 unsigned int count; /* count of GPR (1..16) */
1510 unsigned short gpr[32]; /* GPR number(s) */1510 unsigned short gpr[32]; /* GPR number(s) */
1511 unsigned int value[32];1511 int value[32];
1512 unsigned int min; /* minimum range */1512 int min; /* minimum range */
1513 unsigned int max; /* maximum range */1513 int max; /* maximum range */
1514 unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */1514 unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */
1515 struct snd_kcontrol *kcontrol;1515 struct snd_kcontrol *kcontrol;
1516};1516};
include/uapi/sound/emu10k1.h+5−3
@@ -308,6 +308,8 @@ struct snd_emu10k1_fx8010_info { · 307 unmodified lines
308#define EMU10K1_GPR_TRANSLATION_BASS 2308#define EMU10K1_GPR_TRANSLATION_BASS 2
309#define EMU10K1_GPR_TRANSLATION_TREBLE 3309#define EMU10K1_GPR_TRANSLATION_TREBLE 3
310#define EMU10K1_GPR_TRANSLATION_ONOFF 4310#define EMU10K1_GPR_TRANSLATION_ONOFF 4
311#define EMU10K1_GPR_TRANSLATION_NEGATE 5
312#define EMU10K1_GPR_TRANSLATION_NEG_TABLE100 6
311 313
312enum emu10k1_ctl_elem_iface {314enum emu10k1_ctl_elem_iface {
313 EMU10K1_CTL_ELEM_IFACE_MIXER = 2, /* virtual mixer device */315 EMU10K1_CTL_ELEM_IFACE_MIXER = 2, /* virtual mixer device */
@@ -328,9 +330,9 @@ struct snd_emu10k1_fx8010_control_gpr { · 14 unmodified lines
328 unsigned int vcount; /* visible count */330 unsigned int vcount; /* visible count */
329 unsigned int count; /* count of GPR (1..16) */331 unsigned int count; /* count of GPR (1..16) */
330 unsigned short gpr[32]; /* GPR number(s) */332 unsigned short gpr[32]; /* GPR number(s) */
331 unsigned int value[32]; /* initial values */333 int value[32]; /* initial values */
332 unsigned int min; /* minimum range */334 int min; /* minimum range */
333 unsigned int max; /* maximum range */335 int max; /* maximum range */
334 unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */336 unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */
335 const unsigned int *tlv;337 const unsigned int *tlv;
336};338};
sound/pci/emu10k1/emufx.c+56−63
@@ -332,7 +332,7 @@ static int snd_emu10k1_gpr_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl · 331 unmodified lines
332 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);332 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
333 struct snd_emu10k1_fx8010_ctl *ctl =333 struct snd_emu10k1_fx8010_ctl *ctl =
334 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value;334 (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value;
335 unsigned int nval, val;335 int nval, val;
336 unsigned int i, j;336 unsigned int i, j;
337 int change = 0;337 int change = 0;
338 338
@@ -349,9 +349,16 @@ static int snd_emu10k1_gpr_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl · 10 unmodified lines
349 case EMU10K1_GPR_TRANSLATION_NONE:349 case EMU10K1_GPR_TRANSLATION_NONE:
350 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, val);350 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, val);
351 break;351 break;
352 case EMU10K1_GPR_TRANSLATION_NEGATE:
353 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, ~val);
354 break;
352 case EMU10K1_GPR_TRANSLATION_TABLE100:355 case EMU10K1_GPR_TRANSLATION_TABLE100:
353 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]);356 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]);
354 break;357 break;
358 case EMU10K1_GPR_TRANSLATION_NEG_TABLE100:
359 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0,
360 val == 100 ? 0x80000000 : -(int)db_table[val]);
361 break;
355 case EMU10K1_GPR_TRANSLATION_BASS:362 case EMU10K1_GPR_TRANSLATION_BASS:
356 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {363 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
357 change = -EIO;364 change = -EIO;
@@ -771,8 +778,10 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, · 413 unmodified lines
771 }778 }
772 switch (gctl->translation) {779 switch (gctl->translation) {
773 case EMU10K1_GPR_TRANSLATION_NONE:780 case EMU10K1_GPR_TRANSLATION_NONE:
781 case EMU10K1_GPR_TRANSLATION_NEGATE:
774 break;782 break;
775 case EMU10K1_GPR_TRANSLATION_TABLE100:783 case EMU10K1_GPR_TRANSLATION_TABLE100:
784 case EMU10K1_GPR_TRANSLATION_NEG_TABLE100:
776 if (gctl->min != 0 || gctl->max != 100) {785 if (gctl->min != 0 || gctl->max != 100) {
777 err = -EINVAL;786 err = -EINVAL;
778 goto __error;787 goto __error;
@@ -1137,44 +1146,44 @@ static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu, · 358 unmodified lines
1137 1146
1138static void1147static void
1139snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,1148snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
1140 const char *name, int gpr, int defval)1149 const char *name, int gpr, int defval)
1141{1150{
1142 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;1151 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
1143 strcpy(ctl->id.name, name);1152 strcpy(ctl->id.name, name);
1144 ctl->vcount = ctl->count = 1;1153 ctl->vcount = ctl->count = 1;
1145 if (high_res_gpr_volume) {1154 if (high_res_gpr_volume) {
1146 ctl->min = 0;1155 ctl->min = -1;
1147 ctl->max = 0x7fffffff;1156 ctl->max = 0x7fffffff;
1148 ctl->tlv = snd_emu10k1_db_linear;1157 ctl->tlv = snd_emu10k1_db_linear;
1149 ctl->translation = EMU10K1_GPR_TRANSLATION_NONE;1158 ctl->translation = EMU10K1_GPR_TRANSLATION_NEGATE;
1150 defval = defval * 0x7fffffffLL / 100;1159 defval = defval * 0x80000000LL / 100 - 1;
1151 } else {1160 } else {
1152 ctl->min = 0;1161 ctl->min = 0;
1153 ctl->max = 100;1162 ctl->max = 100;
1154 ctl->tlv = snd_emu10k1_db_scale1;1163 ctl->tlv = snd_emu10k1_db_scale1;
1155 ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;1164 ctl->translation = EMU10K1_GPR_TRANSLATION_NEG_TABLE100;
1156 }1165 }
1157 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;1166 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
1158}1167}
1159 1168
1160static void1169static void
1161snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,1170snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
1162 const char *name, int gpr, int defval)1171 const char *name, int gpr, int defval)
1163{1172{
1164 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;1173 ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
1165 strcpy(ctl->id.name, name);1174 strcpy(ctl->id.name, name);
1166 ctl->vcount = ctl->count = 2;1175 ctl->vcount = ctl->count = 2;
1167 if (high_res_gpr_volume) {1176 if (high_res_gpr_volume) {
1168 ctl->min = 0;1177 ctl->min = -1;
1169 ctl->max = 0x7fffffff;1178 ctl->max = 0x7fffffff;
1170 ctl->tlv = snd_emu10k1_db_linear;1179 ctl->tlv = snd_emu10k1_db_linear;
1171 ctl->translation = EMU10K1_GPR_TRANSLATION_NONE;1180 ctl->translation = EMU10K1_GPR_TRANSLATION_NEGATE;
1172 defval = defval * 0x7fffffffLL / 100;1181 defval = defval * 0x80000000LL / 100 - 1;
1173 } else {1182 } else {
1174 ctl->min = 0;1183 ctl->min = 0;
1175 ctl->max = 100;1184 ctl->max = 100;
1176 ctl->tlv = snd_emu10k1_db_scale1;1185 ctl->tlv = snd_emu10k1_db_scale1;
1177 ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100;1186 ctl->translation = EMU10K1_GPR_TRANSLATION_NEG_TABLE100;
1178 }1187 }
1179 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;1188 ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
1180 ctl->gpr[1] = gpr + 1; ctl->value[1] = defval;1189 ctl->gpr[1] = gpr + 1; ctl->value[1] = defval;
@@ -1293,36 +1302,36 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) · 112 unmodified lines
1293 1302
1294#if 11303#if 1
1295 /* PCM front Playback Volume (independent from stereo mix)1304 /* PCM front Playback Volume (independent from stereo mix)
1296 * playback = 0 + ( gpr * FXBUS_PCM_LEFT_FRONT >> 31)1305 * playback = -gpr * FXBUS_PCM_LEFT_FRONT >> 31
1297 * where gpr contains attenuation from corresponding mixer control1306 * where gpr contains negated attenuation from corresponding mixer control
1298 * (snd_emu10k1_init_stereo_control)1307 * (snd_emu10k1_init_stereo_control)
1299 */1308 */
1300 A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT));1309 A_OP(icode, &ptr, iMAC1, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT));
1301 A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT));1310 A_OP(icode, &ptr, iMAC1, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT));
1302 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Front Playback Volume", gpr, 100);1311 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Front Playback Volume", gpr, 100);
1303 gpr += 2;1312 gpr += 2;
1304 1313
1305 /* PCM Surround Playback (independent from stereo mix) */1314 /* PCM Surround Playback (independent from stereo mix) */
1306 A_OP(icode, &ptr, iMAC0, A_GPR(playback+2), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_REAR));1315 A_OP(icode, &ptr, iMAC1, A_GPR(playback+2), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_REAR));
1307 A_OP(icode, &ptr, iMAC0, A_GPR(playback+3), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_REAR));1316 A_OP(icode, &ptr, iMAC1, A_GPR(playback+3), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_REAR));
1308 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Surround Playback Volume", gpr, 100);1317 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Surround Playback Volume", gpr, 100);
1309 gpr += 2;1318 gpr += 2;
1310 1319
1311 /* PCM Side Playback (independent from stereo mix) */1320 /* PCM Side Playback (independent from stereo mix) */
1312 if (emu->card_capabilities->spk71) {1321 if (emu->card_capabilities->spk71) {
1313 A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_SIDE));1322 A_OP(icode, &ptr, iMAC1, A_GPR(playback+6), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_SIDE));
1314 A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_SIDE));1323 A_OP(icode, &ptr, iMAC1, A_GPR(playback+7), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_SIDE));
1315 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Side Playback Volume", gpr, 100);1324 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Side Playback Volume", gpr, 100);
1316 gpr += 2;1325 gpr += 2;
1317 }1326 }
1318 1327
1319 /* PCM Center Playback (independent from stereo mix) */1328 /* PCM Center Playback (independent from stereo mix) */
1320 A_OP(icode, &ptr, iMAC0, A_GPR(playback+4), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_CENTER));1329 A_OP(icode, &ptr, iMAC1, A_GPR(playback+4), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_CENTER));
1321 snd_emu10k1_init_mono_control(&controls[nctl++], "PCM Center Playback Volume", gpr, 100);1330 snd_emu10k1_init_mono_control(&controls[nctl++], "PCM Center Playback Volume", gpr, 100);
1322 gpr++;1331 gpr++;
1323 1332
1324 /* PCM LFE Playback (independent from stereo mix) */1333 /* PCM LFE Playback (independent from stereo mix) */
1325 A_OP(icode, &ptr, iMAC0, A_GPR(playback+5), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LFE));1334 A_OP(icode, &ptr, iMAC1, A_GPR(playback+5), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LFE));
1326 snd_emu10k1_init_mono_control(&controls[nctl++], "PCM LFE Playback Volume", gpr, 100);1335 snd_emu10k1_init_mono_control(&controls[nctl++], "PCM LFE Playback Volume", gpr, 100);
1327 gpr++;1336 gpr++;
1328 1337
@@ -1330,26 +1339,26 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) · 1 unmodified line
1330 * Stereo Mix1339 * Stereo Mix
1331 */1340 */
1332 /* Wave (PCM) Playback Volume (will be renamed later) */1341 /* Wave (PCM) Playback Volume (will be renamed later) */
1333 A_OP(icode, &ptr, iMAC0, A_GPR(stereo_mix), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT));1342 A_OP(icode, &ptr, iMAC1, A_GPR(stereo_mix), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT));
1334 A_OP(icode, &ptr, iMAC0, A_GPR(stereo_mix+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT));1343 A_OP(icode, &ptr, iMAC1, A_GPR(stereo_mix+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT));
1335 snd_emu10k1_init_stereo_control(&controls[nctl++], "Wave Playback Volume", gpr, 100);1344 snd_emu10k1_init_stereo_control(&controls[nctl++], "Wave Playback Volume", gpr, 100);
1336 gpr += 2;1345 gpr += 2;
1337 1346
1338 /* Synth Playback */1347 /* Synth Playback */
1339 A_OP(icode, &ptr, iMAC0, A_GPR(stereo_mix+0), A_GPR(stereo_mix+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT));1348 A_OP(icode, &ptr, iMAC1, A_GPR(stereo_mix+0), A_GPR(stereo_mix+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT));
1340 A_OP(icode, &ptr, iMAC0, A_GPR(stereo_mix+1), A_GPR(stereo_mix+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT));1349 A_OP(icode, &ptr, iMAC1, A_GPR(stereo_mix+1), A_GPR(stereo_mix+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT));
1341 snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Playback Volume", gpr, 100);1350 snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Playback Volume", gpr, 100);
1342 gpr += 2;1351 gpr += 2;
1343 1352
1344 /* Wave (PCM) Capture */1353 /* Wave (PCM) Capture */
1345 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT));1354 A_OP(icode, &ptr, iMAC1, A_GPR(capture+0), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT));
1346 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT));1355 A_OP(icode, &ptr, iMAC1, A_GPR(capture+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT));
1347 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Capture Volume", gpr, 0);1356 snd_emu10k1_init_stereo_control(&controls[nctl++], "PCM Capture Volume", gpr, 0);
1348 gpr += 2;1357 gpr += 2;
1349 1358
1350 /* Synth Capture */1359 /* Synth Capture */
1351 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT));1360 A_OP(icode, &ptr, iMAC1, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_FXBUS(FXBUS_MIDI_LEFT));
1352 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT));1361 A_OP(icode, &ptr, iMAC1, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_FXBUS(FXBUS_MIDI_RIGHT));
1353 snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Capture Volume", gpr, 0);1362 snd_emu10k1_init_stereo_control(&controls[nctl++], "Synth Capture Volume", gpr, 0);
1354 gpr += 2;1363 gpr += 2;
1355 1364
@@ -1357,23 +1366,23 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) · 1 unmodified line
1357 * inputs1366 * inputs
1358 */1367 */
1359#define A_ADD_VOLUME_IN(var,vol,input) \1368#define A_ADD_VOLUME_IN(var,vol,input) \
1360A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))1369 A_OP(icode, &ptr, iMAC1, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1361 1370
1362 if (emu->card_capabilities->emu_model) {1371 if (emu->card_capabilities->emu_model) {
1363 /* EMU1010 DSP 0 and DSP 1 Capture */1372 /* EMU1010 DSP 0 and DSP 1 Capture */
1364 // The 24 MSB hold the actual value. We implicitly discard the 16 LSB.1373 // The 24 MSB hold the actual value. We implicitly discard the 16 LSB.
1365 if (emu->card_capabilities->ca0108_chip) {1374 if (emu->card_capabilities->ca0108_chip) {
1366 // For unclear reasons, the EMU32IN cannot be the Y operand!1375 // For unclear reasons, the EMU32IN cannot be the Y operand!
1367 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A3_EMU32IN(0x0), A_GPR(gpr));1376 A_OP(icode, &ptr, iMAC1, A_GPR(capture+0), A_GPR(capture+0), A3_EMU32IN(0x0), A_GPR(gpr));
1368 // A3_EMU32IN(0) is delayed by one sample, so all other A3_EMU32IN channels1377 // A3_EMU32IN(0) is delayed by one sample, so all other A3_EMU32IN channels
1369 // need to be delayed as well; we use an auxiliary register for that.1378 // need to be delayed as well; we use an auxiliary register for that.
1370 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+2), A_GPR(gpr+1));1379 A_OP(icode, &ptr, iMAC1, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+2), A_GPR(gpr+1));
1371 A_OP(icode, &ptr, iACC3, A_GPR(gpr+2), A3_EMU32IN(0x1), A_C_00000000, A_C_00000000);1380 A_OP(icode, &ptr, iACC3, A_GPR(gpr+2), A3_EMU32IN(0x1), A_C_00000000, A_C_00000000);
1372 } else {1381 } else {
1373 A_OP(icode, &ptr, iMAC0, A_GPR(capture+0), A_GPR(capture+0), A_GPR(gpr), A_P16VIN(0x0));1382 A_OP(icode, &ptr, iMAC1, A_GPR(capture+0), A_GPR(capture+0), A_P16VIN(0x0), A_GPR(gpr));
1374 // A_P16VIN(0) is delayed by one sample, so all other A_P16VIN channels1383 // A_P16VIN(0) is delayed by one sample, so all other A_P16VIN channels
1375 // need to be delayed as well; we use an auxiliary register for that.1384 // need to be delayed as well; we use an auxiliary register for that.
1376 A_OP(icode, &ptr, iMAC0, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+1), A_GPR(gpr+2));1385 A_OP(icode, &ptr, iMAC1, A_GPR(capture+1), A_GPR(capture+1), A_GPR(gpr+2), A_GPR(gpr+1));
1377 A_OP(icode, &ptr, iACC3, A_GPR(gpr+2), A_P16VIN(0x1), A_C_00000000, A_C_00000000);1386 A_OP(icode, &ptr, iACC3, A_GPR(gpr+2), A_P16VIN(0x1), A_C_00000000, A_C_00000000);
1378 }1387 }
1379 snd_emu10k1_init_stereo_control(&controls[nctl++], "EMU Capture Volume", gpr, 0);1388 snd_emu10k1_init_stereo_control(&controls[nctl++], "EMU Capture Volume", gpr, 0);
@@ -1465,33 +1474,33 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) · 85 unmodified lines
1465 }1474 }
1466 1475
1467 /* Stereo Mix Front Playback Volume */1476 /* Stereo Mix Front Playback Volume */
1468 A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_GPR(playback), A_GPR(gpr), A_GPR(stereo_mix));1477 A_OP(icode, &ptr, iMAC1, A_GPR(playback), A_GPR(playback), A_GPR(gpr), A_GPR(stereo_mix));
1469 A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_GPR(playback+1), A_GPR(gpr+1), A_GPR(stereo_mix+1));1478 A_OP(icode, &ptr, iMAC1, A_GPR(playback+1), A_GPR(playback+1), A_GPR(gpr+1), A_GPR(stereo_mix+1));
1470 snd_emu10k1_init_stereo_control(&controls[nctl++], "Front Playback Volume", gpr, 100);1479 snd_emu10k1_init_stereo_control(&controls[nctl++], "Front Playback Volume", gpr, 100);
1471 gpr += 2;1480 gpr += 2;
1472 1481
1473 /* Stereo Mix Surround Playback */1482 /* Stereo Mix Surround Playback */
1474 A_OP(icode, &ptr, iMAC0, A_GPR(playback+2), A_GPR(playback+2), A_GPR(gpr), A_GPR(stereo_mix));1483 A_OP(icode, &ptr, iMAC1, A_GPR(playback+2), A_GPR(playback+2), A_GPR(gpr), A_GPR(stereo_mix));
1475 A_OP(icode, &ptr, iMAC0, A_GPR(playback+3), A_GPR(playback+3), A_GPR(gpr+1), A_GPR(stereo_mix+1));1484 A_OP(icode, &ptr, iMAC1, A_GPR(playback+3), A_GPR(playback+3), A_GPR(gpr+1), A_GPR(stereo_mix+1));
1476 snd_emu10k1_init_stereo_control(&controls[nctl++], "Surround Playback Volume", gpr, 0);1485 snd_emu10k1_init_stereo_control(&controls[nctl++], "Surround Playback Volume", gpr, 0);
1477 gpr += 2;1486 gpr += 2;
1478 1487
1479 /* Stereo Mix Center Playback */1488 /* Stereo Mix Center Playback */
1480 /* Center = sub = Left/2 + Right/2 */1489 /* Center = sub = Left/2 + Right/2 */
1481 A_OP(icode, &ptr, iINTERP, A_GPR(tmp), A_GPR(stereo_mix), A_C_40000000, A_GPR(stereo_mix+1));1490 A_OP(icode, &ptr, iINTERP, A_GPR(tmp), A_GPR(stereo_mix), A_C_40000000, A_GPR(stereo_mix+1));
1482 A_OP(icode, &ptr, iMAC0, A_GPR(playback+4), A_GPR(playback+4), A_GPR(gpr), A_GPR(tmp));1491 A_OP(icode, &ptr, iMAC1, A_GPR(playback+4), A_GPR(playback+4), A_GPR(gpr), A_GPR(tmp));
1483 snd_emu10k1_init_mono_control(&controls[nctl++], "Center Playback Volume", gpr, 0);1492 snd_emu10k1_init_mono_control(&controls[nctl++], "Center Playback Volume", gpr, 0);
1484 gpr++;1493 gpr++;
1485 1494
1486 /* Stereo Mix LFE Playback */1495 /* Stereo Mix LFE Playback */
1487 A_OP(icode, &ptr, iMAC0, A_GPR(playback+5), A_GPR(playback+5), A_GPR(gpr), A_GPR(tmp));1496 A_OP(icode, &ptr, iMAC1, A_GPR(playback+5), A_GPR(playback+5), A_GPR(gpr), A_GPR(tmp));
1488 snd_emu10k1_init_mono_control(&controls[nctl++], "LFE Playback Volume", gpr, 0);1497 snd_emu10k1_init_mono_control(&controls[nctl++], "LFE Playback Volume", gpr, 0);
1489 gpr++;1498 gpr++;
1490 1499
1491 if (emu->card_capabilities->spk71) {1500 if (emu->card_capabilities->spk71) {
1492 /* Stereo Mix Side Playback */1501 /* Stereo Mix Side Playback */
1493 A_OP(icode, &ptr, iMAC0, A_GPR(playback+6), A_GPR(playback+6), A_GPR(gpr), A_GPR(stereo_mix));1502 A_OP(icode, &ptr, iMAC1, A_GPR(playback+6), A_GPR(playback+6), A_GPR(gpr), A_GPR(stereo_mix));
1494 A_OP(icode, &ptr, iMAC0, A_GPR(playback+7), A_GPR(playback+7), A_GPR(gpr+1), A_GPR(stereo_mix+1));1503 A_OP(icode, &ptr, iMAC1, A_GPR(playback+7), A_GPR(playback+7), A_GPR(gpr+1), A_GPR(stereo_mix+1));
1495 snd_emu10k1_init_stereo_control(&controls[nctl++], "Side Playback Volume", gpr, 0);1504 snd_emu10k1_init_stereo_control(&controls[nctl++], "Side Playback Volume", gpr, 0);
1496 gpr += 2;1505 gpr += 2;
1497 }1506 }
@@ -1579,7 +1588,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) · 81 unmodified lines
1579 1588
1580 /* Master volume (will be renamed later) */1589 /* Master volume (will be renamed later) */
1581 for (z = 0; z < 8; z++)1590 for (z = 0; z < 8; z++)
1582 A_OP(icode, &ptr, iMAC0, A_GPR(playback+z), A_C_00000000, A_GPR(gpr), A_GPR(playback+z));1591 A_OP(icode, &ptr, iMAC1, A_GPR(playback+z), A_C_00000000, A_GPR(gpr), A_GPR(playback+z));
1583 snd_emu10k1_init_mono_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0);1592 snd_emu10k1_init_mono_control(&controls[nctl++], "Wave Master Playback Volume", gpr, 0);
1584 gpr++;1593 gpr++;
1585 1594
@@ -1731,30 +1740,14 @@ __err_gpr: · 145 unmodified lines
1731 * initial DSP configuration for Emu10k11740 * initial DSP configuration for Emu10k1
1732 */1741 */
1733 1742
1734/* when volume = max, then copy only to avoid volume modification */1743/* Volumes are in the [-2^31, 0] range, zero being mute. */
1735/* with iMAC0 (negative values) */
1736static void _volume(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)1744static void _volume(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
1737{1745{
1738 OP(icode, ptr, iMAC0, dst, C_00000000, src, vol);1746 OP(icode, ptr, iMAC1, dst, C_00000000, src, vol);
1739 OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff);
1740 OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000001);
1741 OP(icode, ptr, iACC3, dst, src, C_00000000, C_00000000);
1742}1747}
1743static void _volume_add(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)1748static void _volume_add(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
1744{1749{
1745 OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff);1750 OP(icode, ptr, iMAC1, dst, dst, src, vol);
1746 OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000002);
1747 OP(icode, ptr, iMACINT0, dst, dst, src, C_00000001);
1748 OP(icode, ptr, iSKIP, C_00000000, C_7fffffff, C_7fffffff, C_00000001);
1749 OP(icode, ptr, iMAC0, dst, dst, src, vol);
1750}
1751static void _volume_out(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol)
1752{
1753 OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff);
1754 OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000002);
1755 OP(icode, ptr, iACC3, dst, src, C_00000000, C_00000000);
1756 OP(icode, ptr, iSKIP, C_00000000, C_7fffffff, C_7fffffff, C_00000001);
1757 OP(icode, ptr, iMAC0, dst, C_00000000, src, vol);
1758}1751}
1759 1752
1760#define VOLUME(icode, ptr, dst, src, vol) \1753#define VOLUME(icode, ptr, dst, src, vol) \
@@ -1766,7 +1759,7 @@ static void _volume_out(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst · 5 unmodified lines
1766#define VOLUME_ADDIN(icode, ptr, dst, src, vol) \1759#define VOLUME_ADDIN(icode, ptr, dst, src, vol) \
1767 _volume_add(icode, ptr, GPR(dst), EXTIN(src), GPR(vol))1760 _volume_add(icode, ptr, GPR(dst), EXTIN(src), GPR(vol))
1768#define VOLUME_OUT(icode, ptr, dst, src, vol) \1761#define VOLUME_OUT(icode, ptr, dst, src, vol) \
1769 _volume_out(icode, ptr, EXTOUT(dst), GPR(src), GPR(vol))1762 _volume(icode, ptr, EXTOUT(dst), GPR(src), GPR(vol))
1770#define _SWITCH(icode, ptr, dst, src, sw) \1763#define _SWITCH(icode, ptr, dst, src, sw) \
1771 OP((icode), ptr, iMACINT0, dst, C_00000000, src, sw);1764 OP((icode), ptr, iMACINT0, dst, C_00000000, src, sw);
1772#define SWITCH(icode, ptr, dst, src, sw) \1765#define SWITCH(icode, ptr, dst, src, sw) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t