Lines 490-512
Link Here
|
490 |
static void set_volume (AC97LinkState *s, int index, |
490 |
static void set_volume (AC97LinkState *s, int index, |
491 |
audmixerctl_t mt, uint32_t val) |
491 |
audmixerctl_t mt, uint32_t val) |
492 |
{ |
492 |
{ |
493 |
int mute = (val >> MUTE_SHIFT) & 1; |
493 |
int mute; |
494 |
uint8_t rvol = VOL_MASK - (val & VOL_MASK); |
494 |
uint8_t rvol, lvol; |
495 |
uint8_t lvol = VOL_MASK - ((val >> 8) & VOL_MASK); |
|
|
496 |
rvol = 255 * rvol / VOL_MASK; |
497 |
lvol = 255 * lvol / VOL_MASK; |
498 |
|
499 |
# ifdef SOFT_VOLUME |
500 |
if (index == AC97_Master_Volume_Mute) |
501 |
AUD_set_volume_out (s->voice_po, mute, lvol, rvol); |
502 |
else |
503 |
AUD_set_volume (mt, &mute, &lvol, &rvol); |
504 |
# else |
505 |
AUD_set_volume (mt, &mute, &lvol, &rvol); |
506 |
# endif |
507 |
|
508 |
rvol = VOL_MASK - ((VOL_MASK * rvol) / 255); |
509 |
lvol = VOL_MASK - ((VOL_MASK * lvol) / 255); |
510 |
|
495 |
|
511 |
/* |
496 |
/* |
512 |
* From AC'97 SoundMax Codec AD1981A: "Because AC '97 defines 6-bit volume registers, to |
497 |
* From AC'97 SoundMax Codec AD1981A: "Because AC '97 defines 6-bit volume registers, to |
Lines 521-526
Link Here
|
521 |
if (val & RT_BIT(13)) |
506 |
if (val & RT_BIT(13)) |
522 |
val |= RT_BIT(12) | RT_BIT(11) | RT_BIT(10) | RT_BIT(9) | RT_BIT(8); |
507 |
val |= RT_BIT(12) | RT_BIT(11) | RT_BIT(10) | RT_BIT(9) | RT_BIT(8); |
523 |
|
508 |
|
|
|
509 |
/* |
510 |
* 5-bit volume, behave like one. |
511 |
*/ |
512 |
val &= ~(RT_BIT(5) | RT_BIT(13)); |
513 |
|
514 |
mute = (val >> MUTE_SHIFT) & 1; |
515 |
rvol = (255 * (VOL_MASK - (val & VOL_MASK))) / VOL_MASK; |
516 |
lvol = (255 * (VOL_MASK - ((val >> 8) & VOL_MASK))) / VOL_MASK; |
517 |
|
518 |
# ifdef SOFT_VOLUME |
519 |
if (index == AC97_Master_Volume_Mute) |
520 |
AUD_set_volume_out (s->voice_po, mute, lvol, rvol); |
521 |
else |
522 |
AUD_set_volume (mt, &mute, &lvol, &rvol); |
523 |
# else |
524 |
AUD_set_volume (mt, &mute, &lvol, &rvol); |
525 |
# endif |
526 |
|
524 |
mixer_store (s, index, val); |
527 |
mixer_store (s, index, val); |
525 |
} |
528 |
} |
526 |
|
529 |
|