예제 #1
0
void cmd_audiohw_headphone_vol(int argc, char** argv)
{
	if(argc < 2)
	{
		bufferPrintf("%s <left> [right] (between 0:%d and 63:%d dB)\r\n", argv[0], audiohw_settings[SOUND_VOLUME].minval, audiohw_settings[SOUND_VOLUME].maxval);
		return;
	}

	int left = parseNumber(argv[1]);
	int right;

	if(argc >= 3)
		right = parseNumber(argv[2]);
	else
		right = left;

	audiohw_set_headphone_vol(left, right);

	bufferPrintf("Set headphone volumes to: %d / %d\r\n", left, right);
}
예제 #2
0
파일: sound.c 프로젝트: IlVerz/rockbox
static void set_prescaled_volume(void)
{
    int prescale = 0;
    int l, r;

/* The codecs listed use HW tone controls but don't have suitable prescaler
 * functionality, so we let the prescaler stay at 0 for these, unless
 * SW tone controls are in use. This is to avoid needing the SW DSP just for
 * the prescaling.
 */
#if defined(HAVE_SW_TONE_CONTROLS) || !(defined(HAVE_WM8975) \
    || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
    || defined(HAVE_WM8758) || defined(HAVE_WM8985) || defined(HAVE_UDA1341))

#if defined(AUDIOHW_HAVE_BASS) && defined(AUDIOHW_HAVE_TREBLE)
    prescale = MAX(current_bass, current_treble);
#endif
#if defined(AUDIOHW_HAVE_EQ)
    int i;
    for (i = 0; i < AUDIOHW_EQ_BAND_NUM; i++)
        prescale = MAX(current_eq_band_gain[i], prescale);
#endif

    if (prescale < 0)
        prescale = 0;  /* no need to prescale if we don't boost
                          bass, treble or eq band */

    /* Gain up the analog volume to compensate the prescale gain reduction,
     * but if this would push the volume over the top, reduce prescaling
     * instead (might cause clipping). */
    if (current_volume + prescale > VOLUME_MAX)
        prescale = VOLUME_MAX - current_volume;
#endif

#if defined(AUDIOHW_HAVE_PRESCALER)
    audiohw_set_prescaler(prescale);
#else
    dsp_callback(DSP_CALLBACK_SET_PRESCALE, prescale);
#endif

    if (current_volume == VOLUME_MIN)
        prescale = 0;  /* Make sure the chip gets muted at VOLUME_MIN */

    l = r = current_volume + prescale;

    /* Balance the channels scaled by the current volume and min volume. */
    /* Subtract a dB from VOLUME_MIN to get it to a mute level */
    if (current_balance > 0)
    {
        l -= ((l - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
    }
    else if (current_balance < 0)
    {
        r += ((r - (VOLUME_MIN - ONE_DB)) * current_balance) / VOLUME_RANGE;
    }

#ifdef HAVE_SW_VOLUME_CONTROL
    dsp_callback(DSP_CALLBACK_SET_SW_VOLUME, 0);
#endif

#ifndef HAVE_SDL_AUDIO
#if CONFIG_CODEC == MAS3507D
    dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
#elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
   || defined(HAVE_WM8711) || defined(HAVE_WM8721) || defined(HAVE_WM8731) \
   || defined(HAVE_WM8750) || defined(HAVE_WM8751) || defined(HAVE_AS3514) \
   || defined(HAVE_TSC2100) || defined(HAVE_AK4537) || defined(HAVE_UDA1341) \
   || defined(HAVE_CS42L55)
    audiohw_set_master_vol(tenthdb2master(l), tenthdb2master(r));
#if defined(HAVE_WM8975) || defined(HAVE_WM8758) \
    || (defined(HAVE_WM8751) && defined(TOSHIBA_GIGABEAT_F)) \
    || defined(HAVE_WM8985) || defined(HAVE_CS42L55)
    audiohw_set_lineout_vol(tenthdb2master(0), tenthdb2master(0));
#endif

#elif defined(HAVE_TLV320) || defined(HAVE_WM8978) || defined(HAVE_WM8985)
    audiohw_set_headphone_vol(tenthdb2master(l), tenthdb2master(r));
#elif defined(HAVE_JZ4740_CODEC) || defined(HAVE_SDL_AUDIO) || defined(ANDROID)
    audiohw_set_volume(current_volume);
#endif
#else /* HAVE_SDL_AUDIO */
    audiohw_set_volume(current_volume);
#endif /* !HAVE_SDL_AUDIO */
}