예제 #1
0
int tfa98xxDiagLoadPreset(int slave)
{
        Tfa98xx_handle_t handle;
        int result = 1;         // 1 is failure
        Tfa98xx_Config_t cfg;
        unsigned char tstbuf[0x87 + sizeof(cfg)];

        TRACEIN;
        lastApiError = Tfa98xx_Open(slave << 1, &handle);
        if (lastApiError != Tfa98xx_Error_Ok)
                return 2;

        coldStartup(handle);
        lastApiError =
            Tfa98xx_DspWritePreset(handle, TFA98XX_PRESET_LENGTH,
            			settings_HQ_KS_13X18_DUMBO_preset);
        assert(lastApiError == Tfa98xx_Error_Ok);

        lastApiError =
            Tfa98xx_DspGetParam(handle, 1 /*MODULE_SPEAKERBOOST */ , 0x80,
                                sizeof(tstbuf), tstbuf);
        assert(lastApiError == Tfa98xx_Error_Ok);

        result =
            0 != memcmp(settings_HQ_KS_13X18_DUMBO_preset, &tstbuf[sizeof(cfg)],
                        sizeof(Tfa98xx_Preset_t));
        if (result)
                sprintf(lastErrorString, "DSP parameters mismatch");

 stop:
        Tfa98xx_Close(handle);
        lastError = result;
        TRACEOUT;
        return result;
}
예제 #2
0
int tfa98xxDiagLoadConfig(int slave)
{
        Tfa98xx_handle_t handle;
        int result = 1;         // 1 is failure
        Tfa98xx_Config_t cfg;

        TRACEIN;
        lastApiError = Tfa98xx_Open(slave << 1, &handle);
        if (lastApiError != Tfa98xx_Error_Ok)
                return 2;

        coldStartup(handle);
        lastApiError = Tfa98xx_DspWriteConfig(handle, TFA98XX_CONFIG_LENGTH,
        		settings_Setup87_config);
        assert(lastApiError == Tfa98xx_Error_Ok);

        lastApiError =
            Tfa98xx_DspGetParam(handle, 1 /*MODULE_SPEAKERBOOST */ , 0x80,
                                sizeof(cfg), cfg);
        assert(lastApiError == Tfa98xx_Error_Ok);

        result =
            0 != memcmp(settings_Setup87_config, cfg, sizeof(Tfa98xx_Config_t));
        if (result)
                sprintf(lastErrorString, "DSP parameters mismatch");

 stop:
        Tfa98xx_Close(handle);
        lastError = result;
        TRACEOUT;
        return result;
}
예제 #3
0
/*
 * load speaker parameters and verify readback
 *
 *   note: this function can be called from other tests it uses the global handle
 */
int tfa98xxDiagLoadSpeaker(int slave)
{
        int result = 1;         // 1 is failure
        int gbl=0;
        Tfa98xx_SpeakerParameters_t spkr;

        TRACEIN;

        if ( gHandle<0 ) {
            lastApiError = Tfa98xx_Open(slave << 1, &gHandle);
            if (lastApiError != Tfa98xx_Error_Ok)
                return 2;
        } else
            gbl = 1;

        coldStartup(gHandle);
        lastApiError =
            Tfa98xx_DspWriteSpeakerParameters(gHandle, TFA98XX_SPEAKERPARAMETER_LENGTH,
                                              settings_KS_13X18_DUMBO_speaker);
        assert(lastApiError == Tfa98xx_Error_Ok);

        lastApiError =
            Tfa98xx_DspGetParam(gHandle, 1 /*MODULE_SPEAKERBOOST */ , 0x86,
                                sizeof(spkr), spkr);
        assert(lastApiError == Tfa98xx_Error_Ok);

        result =
            0 != memcmp(settings_KS_13X18_DUMBO_speaker, spkr,
                        sizeof(Tfa98xx_SpeakerParameters_t));
        if (result)
                sprintf(lastErrorString, "DSP parameters mismatch");

 stop:
         if ( !gbl ) {
             Tfa98xx_Close(gHandle);
             lastError = result;
             gHandle=-1;
         }
        TRACEOUT;
        return result;

}
예제 #4
0
int tfa98xxDiagDsp(int slave)
{
        Tfa98xx_handle_t handle;
        int i, result = 0;      // !0 is failure
        char tag[TFA98XX_MAXTAG], string[TFA98XX_MAXTAG + 1], *ptr;
        const char *exp = DSP_revstring;

        TRACEIN;
        lastApiError = Tfa98xx_Open(slave << 1, &handle);
        if (lastApiError != Tfa98xx_Error_Ok)
                return 3;

        coldStartup(handle);

        lastApiError =
            Tfa98xx_DspGetParam(handle, 1 /*MODULE_SPEAKERBOOST */ , 0xFF,
                                TFA98XX_MAXTAG, tag);
        if (lastApiError != Tfa98xx_Error_Ok) {
                sprintf(lastErrorString, "DSP failure");
                return 1;
        }

        ptr = string;
        // the characters are in every 3rd byte
        for (i = 2; i < TFA98XX_MAXTAG; i += 3) {
                if (isprint(tag[i])) {
                        *ptr++ = tag[i];        // only printable chars
                }
        }
        *ptr = '\0';

        if (strcmp(exp, string)) {
                sprintf(lastErrorString, "wrong DSP revtag: exp %s rcv:%s\n",
                        exp, string);
                return 2;
        }
 stop:
        Tfa98xx_Close(handle);
        lastError = result;
        TRACEOUT;
        return result;
}
예제 #5
0
static int mono_speaker_on(
	int channel,
	struct tfa98xx_param_data *speaker,
	struct tfa98xx_param_data *config,
	struct tfa98xx_param_data *preset,
	struct tfa98xx_param_data *eq)
{
	enum Tfa98xx_Error err;
	FIXEDPT re25;
	int calibrateDone = 0;

	/* use the generic slave address for optimizations */

	coldStartup(handles[channel]);
	/*Set to calibration once*/
	/* Only needed for really first time calibration */
	setOtc(handles[channel], 1);

	/* Check if MTPEX bit is set for calibration once mode */
	if (checkMTPEX(handles[channel]) == 0) {
		pr_info("%s: DSP not yet calibrated. Calibration will start\n",
			__func__);

		/* ensure no audio during special calibration */
		err = Tfa98xx_SetMute(handles[channel], Tfa98xx_Mute_Digital);
		if (err != Tfa98xx_Error_Ok) {
			pr_err("%s: Tfa98xx_ReadRegister16 failed\n",
				__func__);
			return -EINVAL;
		}
	} else
		pr_info("%s: DSP already calibrated\n", __func__);

	/* load predefined, or fullmodel from file */
	setSpeaker(1, &handles[channel], speaker);
	/* load the settings */
	setConfig(1, &handles[channel], config);
	/* load a preset */
	setPreset(1, &handles[channel], preset);
	/* set the equalizer */
	setEQ(1, &handles[channel], eq);

	err = Tfa98xx_SelectChannel(handles[channel], Tfa98xx_Channel_L_R);
	if (err != Tfa98xx_Error_Ok) {
		pr_err("%s: Tfa98xx_SelectChannel failed\n", __func__);
		return -EINVAL;
	}

	/* all settings loaded, signal the DSP to start calibration */
	err = Tfa98xx_SetConfigured(handles[channel]);
	if (err != Tfa98xx_Error_Ok) {
		pr_err("%s: Tfa98xx_SetConfigured failed\n", __func__);
		return -EINVAL;
	}

	waitCalibration(handles[channel], &calibrateDone);
	if (calibrateDone)
		Tfa98xx_DspGetCalibrationImpedance(handles[channel], &re25);
	else {
		re25 = 0;
		err = Tfa98xx_Powerdown(handles[channel], 1);
		pr_err("%s: Tfa98xx_Powerdown failed, channel=%d\n",
			__func__, channel);
		return -EINVAL;
	}

	err = Tfa98xx_SetMute(handles[channel], Tfa98xx_Mute_Off);
	if (err != Tfa98xx_Error_Ok) {
		pr_err("%s: Tfa98xx_SetMute failed, channel=%d\n",
			__func__, channel);
		return -EINVAL;
	}

	return 0;
}
예제 #6
0
static int stereo_speaker_on(
	struct tfa98xx_param_data *speaker[2],
	struct tfa98xx_param_data *config[2],
	struct tfa98xx_param_data *preset[2],
	struct tfa98xx_param_data *eq[2])
{
	enum Tfa98xx_Error err = Tfa98xx_Error_Ok;
	unsigned char h;
	FIXEDPT re25;
	int calibrateDone = 0;

	/* use the generic slave address for optimizations */

	for (h = 0; h < 2; h++) {
		coldStartup(handles[h]);
		/*Set to calibration once*/
		/* Only needed for really first time calibration */
		setOtc(handles[h], 1);

		/* Check if MTPEX bit is set for calibration once mode */
		if (checkMTPEX(handles[h]) == 0) {
			pr_info("%s: DSP not yet calibrated. Calibration will"\
				" start\n", __func__);

			/* ensure no audio during special calibration */
			err = Tfa98xx_SetMute(
				handles[h], Tfa98xx_Mute_Digital);
			if (err != Tfa98xx_Error_Ok) {
				pr_err("%s: Tfa98xx_SetMute failed, h=%d\n",
					__func__, h);
				return -EINVAL;
			}
		} else
			pr_info("%s: DSP already calibrated\n", __func__);
	}

	/* load predefined, or fullmodel from data */
	for (h = 0; h < 2; h++)
		setSpeaker(1, &handles[h], speaker[h]);

	/* load the settings */
	for (h = 0; h < 2; h++)
		setConfig(1, &handles[h], config[h]);

	/* load a preset */
	for (h = 0; h < 2; h++)
		setPreset(1, &handles[h], preset[h]);

	/* set the equalizer */
	for (h = 0; h < 2; h++)
		setEQ(1, &handles[h], eq[h]);

	err = set_speaker_lr(handles, speaker_lr);
	if (err != Tfa98xx_Error_Ok) {
		pr_err("%s: set_speaker_lr failed\n", __func__);
		return err;
	}

	/* all settings loaded, signal the DSP to start calibration */
	for (h = 0; h < 2; h++) {
		err = Tfa98xx_SetConfigured(handles[h]);
		if (err != Tfa98xx_Error_Ok) {
			pr_err("%s: Tfa98xx_SetConfigured failed h=%d\n",
				__func__, h);
			return -EINVAL;
		}
	}

	for (h = 0; h < 2; h++) {
		calibrateDone = 0;
		waitCalibration(handles[h], &calibrateDone);
		if (calibrateDone)
			Tfa98xx_DspGetCalibrationImpedance(handles[h], &re25);
		else {
			re25 = 0;
			err = Tfa98xx_Powerdown(handles[h], 1);
			pr_err("%s: Calibration failed, power down" \
				" and return h=%d\n", __func__, h);
			return -EINVAL;
		}
		pr_info("%s re25:%016llx\n", __func__, re25);

		err = Tfa98xx_SetMute(handles[h], Tfa98xx_Mute_Off);
		if (err != Tfa98xx_Error_Ok) {
			pr_err("%s: Tfa98xx_SetMute failed, h=%d\n",
				__func__, h);
			return -EINVAL;
		}

	}

	return 0;
}