示例#1
0
void AudioFtm::SetVibSpkRampControl(uint8_t rampcontrol)
{
    ALOGD("%s()", __FUNCTION__);
    AudioVIBSPKControl::getInstance()->VibSpkRampControl(rampcontrol);
}
/**
* a basic function fo AnalogClose, ckose analog power
* @param DeviceType analog part power
* @return status_t
*/
status_t AudioPlatformDevice::AnalogClose(AudioAnalogType::DEVICE_TYPE DeviceType)
{
    ALOGD("AudioPlatformDevice AnalogClose DeviceType = %s", kAudioAnalogDeviceTypeName[DeviceType]);
    mLock.lock();
    mBlockAttribute[DeviceType].mEnable = false;
    // here to open pmic digital part
    switch (DeviceType)
    {
        case AudioAnalogType::DEVICE_OUT_EARPIECER:
        case AudioAnalogType::DEVICE_OUT_EARPIECEL:
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0, 0x0000, 0x0001);  // turn off DL
            //            TopCtlChangeTrigger();
            break;
        case AudioAnalogType::DEVICE_OUT_HEADSETR:
        case AudioAnalogType::DEVICE_OUT_HEADSETL:
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0, 0x0000, 0x0001);  // turn off DL
            TopCtlChangeTrigger();
            ALOGD("AnalogClose Reset mHpRightDcCalibration/mHpLeftDcCalibration from [0x%x] [0x%x]", mHpRightDcCalibration, mHpLeftDcCalibration);
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON3, 0, 0xffff); // LCH cancel DC
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON4, 0, 0xffff); // RCH cancel DC
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON10, 0x0000, 0x0001); // enable DC cpmpensation
            DCChangeTrigger();//Trigger DC compensation
            break;
        case AudioAnalogType::DEVICE_OUT_SPEAKERR:
        case AudioAnalogType::DEVICE_OUT_SPEAKERL:
#ifdef USING_EXTAMP_HP
            mLock.unlock();
            AnalogClose(AudioAnalogType::DEVICE_OUT_HEADSETR);
            mLock.lock();
#else
            mLock.unlock();
            AnalogClose(AudioAnalogType::DEVICE_OUT_EARPIECER);
            mLock.lock();
#endif
            break;
        case AudioAnalogType::DEVICE_OUT_SPEAKER_HEADSET_R:
        case AudioAnalogType::DEVICE_OUT_SPEAKER_HEADSET_L:
            mLock.unlock();
            AnalogClose(AudioAnalogType::DEVICE_OUT_HEADSETR);
            mLock.lock();
            break;
        case AudioAnalogType::DEVICE_IN_ADC1:
        case AudioAnalogType::DEVICE_IN_ADC2:
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0, 0x0000, 0x0002);  // turn off UL
            //           TopCtlChangeTrigger();
            break;
        case AudioAnalogType::DEVICE_IN_DIGITAL_MIC:
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON9, 0x0000, 0x0010);  // disable digital mic
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0, 0x0000, 0x0002);  // turn off UL
            //            TopCtlChangeTrigger();
            break;
        case AudioAnalogType::DEVICE_2IN1_SPK:
            if (IsAudioSupportFeature(AUDIO_SUPPORT_2IN1_SPEAKER))
            {
                mLock.unlock();
                AnalogClose(AudioAnalogType::DEVICE_OUT_EARPIECER);
                mLock.lock();
            }
            break;
    }
    if (!GetDownLinkStatus() && !GetULinkStatus())
    {
        mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_SET, 0x0100, 0x0100);      // AUD 26M clock power down
        ALOGD("AudioPlatformDevice AnalogClose Power Down TOP_CKPDN1_SET");
    }
    else
    {
        ALOGD("AudioPlatformDevice AnalogClose No Power Down TOP_CKPDN1_SET");
    }
    mLock.unlock();
    return NO_ERROR;
}
/**
* a basic function for SetAnalogGain for different Volume Type
* @param VoleumType value want to set to analog volume
* @param volume function of analog gain , value between 0 ~ 255
* @return status_t
*/
status_t AudioPlatformDevice::SetAnalogGain(AudioAnalogType::VOLUME_TYPE VoleumType, int volume)
{
    ALOGD("SetAnalogGain VOLUME_TYPE = %d volume = %d ", VoleumType, volume);
    return NO_ERROR;
}
示例#4
0
void fastiva_Dalvik_java_lang_System_arraycopy(java_lang_Object_p arg0, jint srcPos, java_lang_Object_p arg2, jint dstPos, jint length) {
    ArrayObject* srcArray = (ArrayObject*) arg0;
    ArrayObject* dstArray = (ArrayObject*) arg2;
#endif

    /* Check for null pointers. */
    if (srcArray == NULL) {
        dvmThrowNullPointerException("src == null");
        THROW_VOID();
    }
    if (dstArray == NULL) {
        dvmThrowNullPointerException("dst == null");
        THROW_VOID();
    }

    /* Make sure source and destination are arrays. */
    if (!dvmIsArray(srcArray)) {
        dvmThrowArrayStoreExceptionNotArray(((Object*)srcArray)->clazz, "source");
        THROW_VOID();
    }
    if (!dvmIsArray(dstArray)) {
        dvmThrowArrayStoreExceptionNotArray(((Object*)dstArray)->clazz, "destination");
        THROW_VOID();
    }

    /* avoid int overflow */
    if (srcPos < 0 || dstPos < 0 || length < 0 ||
        srcPos > (int) srcArray->length - length ||
        dstPos > (int) dstArray->length - length)
    {
        dvmThrowExceptionFmt(gDvm.exArrayIndexOutOfBoundsException,
            "src.length=%d srcPos=%d dst.length=%d dstPos=%d length=%d",
            srcArray->length, srcPos, dstArray->length, dstPos, length);
        THROW_VOID();
    }

    ClassObject* srcClass = srcArray->clazz;
    ClassObject* dstClass = dstArray->clazz;
    char srcType = srcClass->descriptor[1];
    char dstType = dstClass->descriptor[1];

    /*
     * If one of the arrays holds a primitive type, the other array must
     * hold the same type.
     */
    bool srcPrim = (srcType != '[' && srcType != 'L');
    bool dstPrim = (dstType != '[' && dstType != 'L');
    if (srcPrim || dstPrim) {
        if (srcPrim != dstPrim || srcType != dstType) {
            dvmThrowArrayStoreExceptionIncompatibleArrays(srcClass, dstClass);
            THROW_VOID();
        }

        if (false) ALOGD("arraycopy prim[%c] dst=%p %d src=%p %d len=%d",
            srcType, dstArray->contents, dstPos,
            srcArray->contents, srcPos, length);

        switch (srcType) {
        case 'B':
        case 'Z':
            /* 1 byte per element */
            memmove((u1*) dstArray->contents + dstPos,
                (const u1*) srcArray->contents + srcPos,
                length);
            break;
        case 'C':
        case 'S':
            /* 2 bytes per element */
            move16((u1*) dstArray->contents + dstPos * 2,
                (const u1*) srcArray->contents + srcPos * 2,
                length * 2);
            break;
        case 'F':
        case 'I':
            /* 4 bytes per element */
            move32((u1*) dstArray->contents + dstPos * 4,
                (const u1*) srcArray->contents + srcPos * 4,
                length * 4);
            break;
        case 'D':
        case 'J':
            /*
             * 8 bytes per element.  We don't need to guarantee atomicity
             * of the entire 64-bit word, so we can use the 32-bit copier.
             */
            move32((u1*) dstArray->contents + dstPos * 8,
                (const u1*) srcArray->contents + srcPos * 8,
                length * 8);
            break;
        default:        /* illegal array type */
            ALOGE("Weird array type '%s'", srcClass->descriptor);
            dvmAbort();
        }
    } else {
        /*
         * Neither class is primitive.  See if elements in "src" are instances
         * of elements in "dst" (e.g. copy String to String or String to
         * Object).
         */
        const int width = sizeof(Object*);

        if (srcClass->arrayDim == dstClass->arrayDim &&
            dvmInstanceof(srcClass, dstClass))
        {
            /*
             * "dst" can hold "src"; copy the whole thing.
             */
            if (false) ALOGD("arraycopy ref dst=%p %d src=%p %d len=%d",
                dstArray->contents, dstPos * width,
                srcArray->contents, srcPos * width,
                length * width);
            move32((u1*)dstArray->contents + dstPos * width,
                (const u1*)srcArray->contents + srcPos * width,
                length * width);
            dvmWriteBarrierArray(dstArray, dstPos, dstPos+length);
        } else {
            /*
             * The arrays are not fundamentally compatible.  However, we
             * may still be able to do this if the destination object is
             * compatible (e.g. copy Object[] to String[], but the Object
             * being copied is actually a String).  We need to copy elements
             * one by one until something goes wrong.
             *
             * Because of overlapping moves, what we really want to do
             * is compare the types and count up how many we can move,
             * then call move32() to shift the actual data.  If we just
             * start from the front we could do a smear rather than a move.
             */
            Object** srcObj;
            int copyCount;
            ClassObject*   clazz = NULL;

            srcObj = ((Object**)(void*)srcArray->contents) + srcPos;

            if (length > 0 && srcObj[0] != NULL)
            {
                clazz = srcObj[0]->clazz;
                if (!dvmCanPutArrayElement(clazz, dstClass))
                    clazz = NULL;
            }

            for (copyCount = 0; copyCount < length; copyCount++)
            {
                if (srcObj[copyCount] != NULL &&
                    srcObj[copyCount]->clazz != clazz &&
                    !dvmCanPutArrayElement(srcObj[copyCount]->clazz, dstClass))
                {
                    /* can't put this element into the array */
                    break;
                }
            }

            if (false) ALOGD("arraycopy iref dst=%p %d src=%p %d count=%d of %d",
                dstArray->contents, dstPos * width,
                srcArray->contents, srcPos * width,
                copyCount, length);
            move32((u1*)dstArray->contents + dstPos * width,
                (const u1*)srcArray->contents + srcPos * width,
                copyCount * width);
            dvmWriteBarrierArray(dstArray, 0, copyCount);
            if (copyCount != length) {
                dvmThrowArrayStoreExceptionIncompatibleArrayElement(srcPos + copyCount,
                        srcObj[copyCount]->clazz, dstClass);
                THROW_VOID();
            }
        }
    }

    RETURN_VOID();
}
/**
* a basic function fo AnalogOpen, open analog power
* @param DeviceType analog part power
* @return status_t
*/
status_t AudioPlatformDevice::AnalogOpen(AudioAnalogType::DEVICE_TYPE DeviceType)
{
    ALOGD("AudioPlatformDevice AnalogOpen DeviceType = %s ", kAudioAnalogDeviceTypeName[DeviceType]);
    uint32 ulFreq, dlFreq;
    mLock.lock();
    if (mBlockAttribute[DeviceType].mEnable == true)
    {
        ALOGW("AudioPlatformDevice AnalogOpen bypass with DeviceType = %d", DeviceType);
        mLock.unlock();
        return NO_ERROR;;
    }
    mBlockAttribute[DeviceType].mEnable = true;
    // here to open pmic digital part
    ulFreq = GetULFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]);
    dlFreq = GetDLFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_OUT_DAC]);

    switch (DeviceType)
    {
        case AudioAnalogType::DEVICE_OUT_EARPIECER:
        case AudioAnalogType::DEVICE_OUT_EARPIECEL:
#if 0
            mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_CLR, 0x0100, 0x0100);      // AUD 26M clock power down release
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON1 , GetDLFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_OUT_DAC]), 0x000f);
            mAudioAnalogReg->SetAnalogReg(AFE_PMIC_NEWIF_CFG0 , GetDLNewIFFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_OUT_DAC]) << 12, 0xf000);
            TopCtlChangeTrigger();
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON5 , 0x28, 0x003f); //Use Default SDM Gain 0x28/0x3f = 0.63
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_TOP_CON0 , 0, 0xffff); //Use Normal Path
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON2 , 0, 0xffff); //Use Normal Path
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0 , 1, 0x0001); //Enable DL path
            TopCtlChangeTrigger();
#else
            mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_CLR, 0x0100, 0x0100);      // AUD 26M clock power down release
            mAudioAnalogReg->SetAnalogReg(AFE_PMIC_NEWIF_CFG0, GetDLNewIFFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_OUT_DAC]) << 12 | 0x330, 0xffff); // config up8x_rxif
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON1, dlFreq, 0x000f); // DL sampling rate
            TopCtlChangeTrigger();
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0, 0x0001, 0x0001);                       // turn on DL
#endif

            break;

        case AudioAnalogType::DEVICE_OUT_HEADSETR:
        case AudioAnalogType::DEVICE_OUT_HEADSETL:
#if 0
            mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_CLR, 0x0100, 0x0100);      // AUD 26M clock power down release
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON1 , GetDLFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_OUT_DAC]), 0x000f);
            mAudioAnalogReg->SetAnalogReg(AFE_PMIC_NEWIF_CFG0 , GetDLNewIFFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_OUT_DAC]) << 12, 0xf000);
            TopCtlChangeTrigger();
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON5 , 0x28, 0x003f); //Use Default SDM Gain 0x28/0x3f = 0.63
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_TOP_CON0 , 0, 0xffff); //Use Normal Path
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON2 , 0, 0xffff); //Use Normal Path
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0 , 1, 0x0001); //Enable DL path
            TopCtlChangeTrigger();
#else
            mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_CLR, 0x0100, 0x0100);      // AUD 26M clock power down release
            mAudioAnalogReg->SetAnalogReg(AFE_PMIC_NEWIF_CFG0, GetDLNewIFFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_OUT_DAC]) << 12 | 0x330, 0xffff); // config up8x_rxif
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON1, dlFreq, 0x000f); // DL sampling rate
            //DC compensation setting
            ALOGD("AnalogOpen mHpRightDcCalibration [0x%x] mHpLeftDcCalibration [0x%x]", mHpRightDcCalibration, mHpLeftDcCalibration);
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON3, mHpLeftDcCalibration, 0xffff); // LCH cpmpensation value
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON4, mHpRightDcCalibration, 0xffff); // RCH cpmpensation value
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON10, 0x0001, 0x0001); // enable DC cpmpensation
            DCChangeTrigger();//Trigger DC compensation
            TopCtlChangeTrigger();
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0, 0x0001, 0x0001);  // turn on DL
#endif
            break;
        case AudioAnalogType::DEVICE_OUT_SPEAKERR:
        case AudioAnalogType::DEVICE_OUT_SPEAKERL:
#ifdef USING_EXTAMP_HP
            mLock.unlock();
            AnalogOpen(AudioAnalogType::DEVICE_OUT_HEADSETR);
            mLock.lock();
#else
            mLock.unlock();
            AnalogOpen(AudioAnalogType::DEVICE_OUT_EARPIECER);
            mLock.lock();
#endif

            break;
        case AudioAnalogType::DEVICE_OUT_SPEAKER_HEADSET_R:
        case AudioAnalogType::DEVICE_OUT_SPEAKER_HEADSET_L:
            mLock.unlock();
            AnalogOpen(AudioAnalogType::DEVICE_OUT_HEADSETR);
            mLock.lock();
            break;
        case AudioAnalogType::DEVICE_IN_ADC1:
        case AudioAnalogType::DEVICE_IN_ADC2:
            ALOGD("AudioPlatformDevice::DEVICE_IN_ADC2:");
#if 0
            mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_CLR, 0x0100, 0x0100);      // AUD 26M clock power down release
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON1 , GetULFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]) << 4, 0x0010);
            mAudioAnalogReg->SetAnalogReg(AFE_PMIC_NEWIF_CFG2, 0x302F | (GetULNewIFFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]) << 10), 0xffff); // config UL up8x_rxif adc voice mode
            TopCtlChangeTrigger();
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0 , 0x02, 0x0002); //Enable UL path
            TopCtlChangeTrigger();
#else
            mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_CLR, 0x0100, 0x0100);      // AUD 26M clock power down release
            mAudioAnalogReg->SetAnalogReg(AFE_PMIC_NEWIF_CFG2, 0x302F | (GetULNewIFFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]) << 10), 0xffff); // config UL up8x_rxif adc voice mode
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON1, GetULFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]) << 4, 0x0010); // UL sampling rate
            TopCtlChangeTrigger();
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0, 0x0002, 0x0002);  // turn on UL
#endif

            break;
        case AudioAnalogType::DEVICE_IN_DIGITAL_MIC:
#if 0
            mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_CLR, 0x0100, 0x0100);      // AUD 26M clock power down release
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON1 , GetULFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]), 0x0010);
            mAudioAnalogReg->SetAnalogReg(AFE_PMIC_NEWIF_CFG2, 0x302F | (GetULNewIFFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]) << 10), 0xffff); // config UL up8x_rxif adc voice mode
            TopCtlChangeTrigger();
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON9 , 0x0011, 0x0011); // enable digital mic, 3.25M clock rate
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0 , 0x02, 0x0002); //Enable UL path
            TopCtlChangeTrigger();
#else
            mAudioAnalogReg->SetAnalogReg(TOP_CKPDN1_CLR, 0x0100, 0x0100);      // AUD 26M clock power down release
            mAudioAnalogReg->SetAnalogReg(AFE_PMIC_NEWIF_CFG2, 0x302F | (GetULNewIFFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]) << 10), 0xffff); // config UL up8x_rxif adc voice mode
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON1, GetULFrequency(mBlockSampleRate[AudioAnalogType::DEVICE_IN_ADC]) << 4, 0x0010); // UL sampling rate
            TopCtlChangeTrigger();
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON9, 0x0011, 0x0011);  // enable digital mic, 3.25M clock rate
            mAudioAnalogReg->SetAnalogReg(ABB_AFE_CON0, 0x0002, 0x0002);  // turn on UL
#endif

            break;
        case AudioAnalogType::DEVICE_2IN1_SPK:
            if (IsAudioSupportFeature(AUDIO_SUPPORT_2IN1_SPEAKER))
            {
                mLock.unlock();
                AnalogOpen(AudioAnalogType::DEVICE_OUT_EARPIECER);
                mLock.lock();
            }
            break;
    }
    mLock.unlock();
    return NO_ERROR;
}
status_t AudioAnalogControl::SetAnalogMute(AudioAnalogType::VOLUME_TYPE VoleumType, bool mute)
{
    ALOGD("SetAnalogMute VoleumType = %d mute = %d \n", VoleumType, mute);
    mAudioMachineDevice->SetAnalogMute(VoleumType, mute);
    return NO_ERROR;
}
bool AudioAnalogControl::GetAnalogState(AudioAnalogType::DEVICE_TYPE DeviceType)
{
    ALOGD("+GetAnalogState DeviceType [%s]=%d\n", kAudioAnalogDeviceTypeName[DeviceType], mBlockAttribute[DeviceType].mEnable);
    return mBlockAttribute[DeviceType].mEnable;
}
示例#8
0
/*
 * ´´½¨Ò»¸öÐ嵀 java/lang/reflect/Method¶ÔÏó,ʹÓÃ'meth'ÄÚÈÝÈ¥¹¹ÔìËü.
 *  
 */
Object* dvmCreateReflectMethodObject(const Method* meth)
{
    Object* result = NULL;
    ArrayObject* params = NULL;
    ArrayObject* exceptions = NULL;
    StringObject* nameObj = NULL;
    Object* methObj;
    ClassObject* returnType;
    DexStringCache mangle;
    char* cp;
    int slot;

    if (dvmCheckException(dvmThreadSelf())) {
        ALOGW("WARNING: dvmCreateReflectMethodObject called with "
             "exception pending");
        return NULL;
    }

    dexStringCacheInit(&mangle);

    /* parent should guarantee init so we don't have to check on every call */
    assert(dvmIsClassInitialized(gDvm.classJavaLangReflectMethod));

    methObj = dvmAllocObject(gDvm.classJavaLangReflectMethod, ALLOC_DEFAULT);
    if (methObj == NULL)
        goto bail;

    /*
     * Convert the signature string into an array of classes representing
     * the arguments, and a class for the return type.
     */
    cp = dvmCopyDescriptorStringFromMethod(meth, &mangle);
    params = convertSignatureToClassArray(&cp, meth->clazz);
    if (params == NULL)
        goto bail;
    assert(*cp == ')');
    cp++;
    returnType = convertSignaturePartToClass(&cp, meth->clazz);
    if (returnType == NULL)
        goto bail;

    /*
     * Create an array with one entry for every exception that the class
     * is declared to throw.
     */
    exceptions = dvmGetMethodThrows(meth);
    if (dvmCheckException(dvmThreadSelf()))
        goto bail;

    /* method name */
    nameObj = dvmCreateStringFromCstr(meth->name);
    if (nameObj == NULL)
        goto bail;

    slot = methodToSlot(meth);

    JValue unused;
    dvmCallMethod(dvmThreadSelf(), gDvm.methJavaLangReflectMethod_init,
        methObj, &unused, meth->clazz, params, exceptions, returnType,
        nameObj, slot);
    if (dvmCheckException(dvmThreadSelf())) {
        ALOGD("Method class init threw exception");
        goto bail;
    }

    result = methObj;

bail:
    dexStringCacheRelease(&mangle);
    if (result == NULL) {
        assert(dvmCheckException(dvmThreadSelf()));
    }
    dvmReleaseTrackedAlloc((Object*) nameObj, NULL);
    dvmReleaseTrackedAlloc((Object*) params, NULL);
    dvmReleaseTrackedAlloc((Object*) exceptions, NULL);
    if (result == NULL)
        dvmReleaseTrackedAlloc(methObj, NULL);
    return result;
}
static jobject com_android_nfc_NativeLlcpConnectionlessSocket_doReceiveFrom(JNIEnv *e, jobject o, jint linkMiu)
{
   NFCSTATUS ret;
   struct timespec ts;
   uint8_t ssap;
   jobject llcpPacket = NULL;
   phLibNfc_Handle hRemoteDevice;
   phLibNfc_Handle hLlcpSocket;
   phNfc_sData_t sReceiveBuffer;
   jclass clsLlcpPacket;
   jfieldID f;
   jbyteArray receivedData = NULL;
   struct nfc_jni_callback_data cb_data;

   /* Create the local semaphore */
   if (!nfc_cb_data_init(&cb_data, NULL))
   {
      goto clean_and_return;
   }

   /* Create new LlcpPacket object */
   if(nfc_jni_cache_object(e,"com/android/nfc/LlcpPacket",&(llcpPacket)) == -1)
   {
      ALOGE("Find LlcpPacket class error");
      goto clean_and_return;
   }

   /* Get NativeConnectionless class object */
   clsLlcpPacket = e->GetObjectClass(llcpPacket);
   if(e->ExceptionCheck())
   {
      ALOGE("Get Object class error");
      goto clean_and_return;
   } 

   /* Retrieve handles */
   hRemoteDevice = nfc_jni_get_p2p_device_handle(e,o);
   hLlcpSocket = nfc_jni_get_nfc_socket_handle(e,o);
   TRACE("phLibNfc_Llcp_RecvFrom(), Socket Handle = 0x%02x, Link LIU = %d", hLlcpSocket, linkMiu);

   sReceiveBuffer.buffer = (uint8_t*)malloc(linkMiu);
   sReceiveBuffer.length = linkMiu;

   REENTRANCE_LOCK();
   ret = phLibNfc_Llcp_RecvFrom(hRemoteDevice,
                                hLlcpSocket,
                                &sReceiveBuffer,
                                nfc_jni_receive_callback,
                                &cb_data);
   REENTRANCE_UNLOCK();
   if(ret != NFCSTATUS_PENDING && ret != NFCSTATUS_SUCCESS)
   {
      ALOGE("phLibNfc_Llcp_RecvFrom() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
      goto clean_and_return;
   } 
   TRACE("phLibNfc_Llcp_RecvFrom() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));

   /* Wait for callback response */
   if(sem_wait(&cb_data.sem))
   {
      ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
      goto clean_and_return;
   }

   if(cb_data.status != NFCSTATUS_SUCCESS)
   {
       goto clean_and_return;
   }

   ssap = (uint32_t)cb_data.pContext;
   TRACE("Data Received From SSAP = %d\n, length = %d", ssap, sReceiveBuffer.length);

   /* Set Llcp Packet remote SAP */
   f = e->GetFieldID(clsLlcpPacket, "mRemoteSap", "I");
   e->SetIntField(llcpPacket, f,(jbyte)ssap);

   /* Set Llcp Packet Buffer */
   ALOGD("Set LlcpPacket Data Buffer\n");
   f = e->GetFieldID(clsLlcpPacket, "mDataBuffer", "[B");
   receivedData = e->NewByteArray(sReceiveBuffer.length);
   e->SetByteArrayRegion(receivedData, 0, sReceiveBuffer.length,(jbyte *)sReceiveBuffer.buffer);
   e->SetObjectField(llcpPacket, f, receivedData);

clean_and_return:
   nfc_cb_data_deinit(&cb_data);
   return llcpPacket;
}
/*******************************************************************************
**
** Function:        IsWiredMode_Enable
**
** Description:     Provides the connection status of EE
**
** Returns:         True if ok.
**
*******************************************************************************/
bool IsWiredMode_Enable()
{
    static const char fn [] = "DwpChannel::IsWiredMode_Enable";
    ALOGD ("%s: enter", fn);
    SecureElement &se = SecureElement::getInstance();
    tNFA_STATUS stat = NFA_STATUS_FAILED;

    static const int MAX_NUM_EE = 5;
    UINT16 meSE =0x4C0;
    UINT8 mActualNumEe;
    tNFA_EE_INFO EeInfo[MAX_NUM_EE];
    mActualNumEe = MAX_NUM_EE;

#if 0
    if(mIsInit == false)
    {
        ALOGD ("%s: JcopOs Dwnld is not initialized", fn);
        goto TheEnd;
    }
#endif
    stat = NFA_EeGetInfo(&mActualNumEe, EeInfo);
    if(stat == NFA_STATUS_OK)
    {
        for(int xx = 0; xx <  mActualNumEe; xx++)
        {
            ALOGE("xx=%d, ee_handle=0x0%x, status=0x0%x", xx, EeInfo[xx].ee_handle,EeInfo[xx].ee_status);
            if (EeInfo[xx].ee_handle == meSE)
            {
                if(EeInfo[xx].ee_status == 0x00)
                {
                    stat = NFA_STATUS_OK;
                    ALOGD ("%s: status = 0x%x", fn, stat);
                    break;
                }
                else if(EeInfo[xx].ee_status == 0x01)
                {
                    ALOGE("%s: Enable eSE-mode set ON", fn);
                    se.SecEle_Modeset(0x01);
                    usleep(2000 * 1000);
                    stat = NFA_STATUS_OK;
                    break;
                }
                else
                {
                    stat = NFA_STATUS_FAILED;
                    break;
                }
            }
            else
            {
                stat = NFA_STATUS_FAILED;
            }

        }
    }
//TheEnd: /*commented to eliminate the label defined but not used warning*/
    ALOGD("%s: exit; status = 0x%X", fn, stat);
    if(stat == NFA_STATUS_OK)
        return true;
    else
        return false;
}
示例#11
0
/*
 * ʹÓÃ'meth'ÄÚÈÝÈ¥´´½¨Ò»¸öÐ嵀 java/lang/reflect/Constructor¶ÔÏó£¬
 */
static Object* createConstructorObject(Method* meth)
{
    Object* result = NULL;
    ArrayObject* params = NULL;
    ArrayObject* exceptions = NULL;
    Object* consObj;
    DexStringCache mangle;
    char* cp;
    int slot;

    dexStringCacheInit(&mangle);

    /* parent should guarantee init so we don't have to check on every call */
    assert(dvmIsClassInitialized(gDvm.classJavaLangReflectConstructor));

    consObj = dvmAllocObject(gDvm.classJavaLangReflectConstructor,
                ALLOC_DEFAULT);
    if (consObj == NULL)
        goto bail;

    /*
     * Convert the signature string into an array of classes representing
     * the arguments.
     */
    cp = dvmCopyDescriptorStringFromMethod(meth, &mangle);
    params = convertSignatureToClassArray(&cp, meth->clazz);
    if (params == NULL)
        goto bail;
    assert(*cp == ')');
    assert(*(cp+1) == 'V');

    /*
     * Create an array with one entry for every exception that the class
     * is declared to throw.
     */
    exceptions = dvmGetMethodThrows(meth);
    if (dvmCheckException(dvmThreadSelf()))
        goto bail;

    slot = methodToSlot(meth);

    JValue unused;
    dvmCallMethod(dvmThreadSelf(), gDvm.methJavaLangReflectConstructor_init,
        consObj, &unused, meth->clazz, params, exceptions, slot);
    if (dvmCheckException(dvmThreadSelf())) {
        ALOGD("Constructor class init threw exception");
        goto bail;
    }

    result = consObj;

bail:
    dexStringCacheRelease(&mangle);
    dvmReleaseTrackedAlloc((Object*) params, NULL);
    dvmReleaseTrackedAlloc((Object*) exceptions, NULL);
    if (result == NULL) {
        assert(dvmCheckException(dvmThreadSelf()));
        dvmReleaseTrackedAlloc(consObj, NULL);
    }
    /* caller must dvmReleaseTrackedAlloc(result) */
    return result;
}
示例#12
0
/*===========================================================================
 * FUNCTION   : allocate
 *
 * DESCRIPTION: allocate requested number of buffers of certain size
 *
 * PARAMETERS :
 *   @count   : number of buffers to be allocated
 *   @size    : lenght of the buffer to be allocated
 *
 * RETURN     : int32_t type of status
 *              NO_ERROR  -- success
 *              none-zero failure code
 *==========================================================================*/
int QCameraGrallocMemory::allocate(int count, int /*size*/)
{
    int err = 0;
    status_t ret = NO_ERROR;
    int gralloc_usage = 0;
    struct ion_fd_data ion_info_fd;
    memset(&ion_info_fd, 0, sizeof(ion_info_fd));

    ALOGI(" %s : E ", __FUNCTION__);

    if (!mWindow) {
        ALOGE("Invalid native window");
        return INVALID_OPERATION;
    }

    // Increment buffer count by min undequeued buffer.
    err = mWindow->get_min_undequeued_buffer_count(mWindow,&mMinUndequeuedBuffers);
    if (err != 0) {
        ALOGE("get_min_undequeued_buffer_count  failed: %s (%d)",
                strerror(-err), -err);
        ret = UNKNOWN_ERROR;
        goto end;
    }
    count += mMinUndequeuedBuffers;

    err = mWindow->set_buffer_count(mWindow, count);
    if (err != 0) {
         ALOGE("set_buffer_count failed: %s (%d)",
                    strerror(-err), -err);
         ret = UNKNOWN_ERROR;
         goto end;
    }

    err = mWindow->set_buffers_geometry(mWindow, mWidth, mHeight, mFormat);
    if (err != 0) {
         ALOGE("%s: set_buffers_geometry failed: %s (%d)",
               __func__, strerror(-err), -err);
         ret = UNKNOWN_ERROR;
         goto end;
    }

    gralloc_usage = GRALLOC_USAGE_PRIVATE_IOMMU_HEAP;
    err = mWindow->set_usage(mWindow, gralloc_usage);
    if(err != 0) {
        /* set_usage error out */
        ALOGE("%s: set_usage rc = %d", __func__, err);
        ret = UNKNOWN_ERROR;
        goto end;
    }
    ALOGD("%s: usage = %d, geometry: %p, %d, %d, %d",
          __func__, gralloc_usage, mWindow, mWidth, mHeight, mFormat);

    //Allocate cnt number of buffers from native window
    for (int cnt = 0; cnt < count; cnt++) {
        int stride;
        err = mWindow->dequeue_buffer(mWindow, &mBufferHandle[cnt], &stride);
        if(!err) {
            ALOGV("dequeue buf hdl =%p", mBufferHandle[cnt]);
            mLocalFlag[cnt] = BUFFER_OWNED;
        } else {
            mLocalFlag[cnt] = BUFFER_NOT_OWNED;
            ALOGE("%s: dequeue_buffer idx = %d err = %d", __func__, cnt, err);
        }

        ALOGV("%s: dequeue buf: %p\n", __func__, mBufferHandle[cnt]);

        if(err != 0) {
            ALOGE("%s: dequeue_buffer failed: %s (%d)",
                  __func__, strerror(-err), -err);
            ret = UNKNOWN_ERROR;
            for(int i = 0; i < cnt; i++) {
                if(mLocalFlag[i] != BUFFER_NOT_OWNED) {
                    err = mWindow->cancel_buffer(mWindow, mBufferHandle[i]);
                    ALOGD("%s: cancel_buffer: hdl =%p", __func__, (*mBufferHandle[i]));
                }
                mLocalFlag[i] = BUFFER_NOT_OWNED;
                mBufferHandle[i] = NULL;
            }
            memset(&mMemInfo, 0, sizeof(mMemInfo));
            goto end;
        }

        mPrivateHandle[cnt] =
            (struct private_handle_t *)(*mBufferHandle[cnt]);
        mMemInfo[cnt].main_ion_fd = open("/dev/ion", O_RDONLY);
        if (mMemInfo[cnt].main_ion_fd < 0) {
            ALOGE("%s: failed: could not open ion device", __func__);
            for(int i = 0; i < cnt; i++) {
                struct ion_handle_data ion_handle;
                memset(&ion_handle, 0, sizeof(ion_handle));
                ion_handle.handle = mMemInfo[i].handle;
                if (ioctl(mMemInfo[i].main_ion_fd, ION_IOC_FREE, &ion_handle) < 0) {
                    ALOGE("%s: ion free failed", __func__);
                }
                close(mMemInfo[i].main_ion_fd);
                if(mLocalFlag[i] != BUFFER_NOT_OWNED) {
                    err = mWindow->cancel_buffer(mWindow, mBufferHandle[i]);
                    ALOGD("%s: cancel_buffer: hdl =%p", __func__, (*mBufferHandle[i]));
                }
                mLocalFlag[i] = BUFFER_NOT_OWNED;
                mBufferHandle[i] = NULL;
            }
            memset(&mMemInfo, 0, sizeof(mMemInfo));
            ret = UNKNOWN_ERROR;
            goto end;
        } else {
            ion_info_fd.fd = mPrivateHandle[cnt]->fd;
            if (ioctl(mMemInfo[cnt].main_ion_fd,
                      ION_IOC_IMPORT, &ion_info_fd) < 0) {
                ALOGE("%s: ION import failed\n", __func__);
                for(int i = 0; i < cnt; i++) {
                    struct ion_handle_data ion_handle;
                    memset(&ion_handle, 0, sizeof(ion_handle));
                    ion_handle.handle = mMemInfo[i].handle;
                    if (ioctl(mMemInfo[i].main_ion_fd, ION_IOC_FREE, &ion_handle) < 0) {
                        ALOGE("ion free failed");
                    }
                    close(mMemInfo[i].main_ion_fd);

                    if(mLocalFlag[i] != BUFFER_NOT_OWNED) {
                        err = mWindow->cancel_buffer(mWindow, mBufferHandle[i]);
                        ALOGD("%s: cancel_buffer: hdl =%p", __func__, (*mBufferHandle[i]));
                    }
                    mLocalFlag[i] = BUFFER_NOT_OWNED;
                    mBufferHandle[i] = NULL;
                }
                close(mMemInfo[cnt].main_ion_fd);
                memset(&mMemInfo, 0, sizeof(mMemInfo));
                ret = UNKNOWN_ERROR;
                goto end;
            }
        }
        mCameraMemory[cnt] =
            mGetMemory(mPrivateHandle[cnt]->fd,
                    mPrivateHandle[cnt]->size,
                    1,
                    (void *)this);
        ALOGD("%s: idx = %d, fd = %d, size = %d, offset = %d",
              __func__, cnt, mPrivateHandle[cnt]->fd,
              mPrivateHandle[cnt]->size,
              mPrivateHandle[cnt]->offset);
        mMemInfo[cnt].fd =
            mPrivateHandle[cnt]->fd;
        mMemInfo[cnt].size =
            mPrivateHandle[cnt]->size;
        mMemInfo[cnt].handle = ion_info_fd.handle;
    }
    mBufferCount = count;

    //Cancel min_undequeued_buffer buffers back to the window
    for (int i = 0; i < mMinUndequeuedBuffers; i ++) {
        err = mWindow->cancel_buffer(mWindow, mBufferHandle[i]);
        mLocalFlag[i] = BUFFER_NOT_OWNED;
    }

end:
    ALOGI(" %s : X ",__func__);
    return ret;
}
示例#13
0
void AudioFtm::SetStreamOutPostProcessBypass(bool flag)
{
    ALOGD("%s() %d", __FUNCTION__, flag);
    mStreamManager->setBypassDLProcess(flag);
    return ;
}
示例#14
0
status_t AudioFtm::setMicEnable(const audio_mic_mask_t audio_mic_mask, const bool enable)
{
    ALOGD("%s(), audio_mic_mask = 0x%x, enable = %d", __FUNCTION__, audio_mic_mask, enable);

    if (enable == true)
    {
        switch (audio_mic_mask)
        {
            case AUDIO_MIC_MASK_MIC1:
            {
                mHardwareResourceManager->setMIC1Mode(false);
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_MicSource1_Setting"), "ADC1"); //K2 add
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_ADC_1_Switch"), "On");
                //mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_MicSource1_Setting"), "ADC1");
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_Preamp1_Switch"), "IN_ADC1"); //preamp1, "IN_ADC1": AIN0, "IN_ADC2": AIN1
                break;
            }
            case AUDIO_MIC_MASK_MIC2:
            {
                mHardwareResourceManager->setMIC2Mode(false);
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_MicSource1_Setting"), "ADC1"); //ADC1: main/ref mic, ADC2: headset mic
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_ADC_1_Switch"), "On");
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_Preamp1_Switch"), "IN_ADC3"); //preamp1, "IN_ADC1": AIN0, "IN_ADC2": AIN1, "IN_ADC3": AIN2
                break;
            }
            case AUDIO_MIC_MASK_MIC3:
            {
                break;
            }
            case AUDIO_MIC_MASK_HEADSET_MIC:
            {
                mHardwareResourceManager->setMIC1Mode(true);
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_MicSource1_Setting"), "ADC2"); //K2 add
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_ADC_1_Switch"), "On");
                //mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_MicSource1_Setting"), "ADC1");
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_Preamp1_Switch"), "IN_ADC2");
                break;
            }
            default:
            {
                ALOGW("%s(), not support audio_mic_mask = 0x%x", __FUNCTION__, audio_mic_mask);
                break;
            }
        }
    }
    else
    {
        switch (audio_mic_mask)
        {
            case AUDIO_MIC_MASK_MIC1:
            {
                mHardwareResourceManager->setMIC1Mode(false);
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_Preamp1_Switch"), "OPEN");
                //mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_MicSource1_Setting"), "ADC1");
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_ADC_1_Switch"), "Off");
                break;
            }
            case AUDIO_MIC_MASK_MIC2:
            {
                mHardwareResourceManager->setMIC2Mode(false);
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_Preamp1_Switch"), "OPEN");
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_ADC_1_Switch"), "Off");
                break;
            }
            case AUDIO_MIC_MASK_MIC3:
            {
                break;
            }
            case AUDIO_MIC_MASK_HEADSET_MIC:
            {
                mHardwareResourceManager->setMIC1Mode(true);
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_Preamp1_Switch"), "OPEN");
                //mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_MicSource1_Setting"), "ADC1");
                mixer_ctl_set_enum_by_string(mixer_get_ctl_by_name(mMixer, "Audio_ADC_1_Switch"), "Off");
                break;
            }
            default:
            {
                ALOGW("%s(), not support audio_mic_mask = 0x%x", __FUNCTION__, audio_mic_mask);
                break;
            }
        }
    }

    return NO_ERROR;
}
int load_config(const char *path, hash_map < string, module_info * >*modules, list < module_info * >*clients) {
    char module[1024] = { 0, };
    char line[1024] = { 0, };
    char indicator = '=';
    module_info *cur_mod = NULL;

    FILE *file = fopen(path, "r");

    if(file == NULL) {
        ALOGE("%s open failed\n", path);
        return CONFIG_NOT_FOUND_ERR;
    }

    modules->clear();
    clients->clear();

    ALOGD("Loading config: %s\n", path);

    while(fgets(line, sizeof(line), file) != NULL) {
        char name[1024] = { 0, }, value[1024] = {
        0,};

        if(line[0] == '#')
            continue;

        if(line[0] == '[') {
            parse_module(line, module, sizeof(module));
            cur_mod = new module_info(module);
            // add module into global list
            (*modules)[(string) module] = cur_mod;
            clients->push_back(cur_mod);
            ALOGD("[%s]\n", module);
            continue;
        }

        if(module[0] != '\0') {
            parse_value(line, indicator, name, sizeof(name), value, sizeof(value));
            char *pname = trim(name);
            char *pvalue = trim(value);

            if(*pname != '\0' && *pvalue != '\0') {

                /*Initial language */
                if(!strcmp(pname, KEY_STR_LANGUAGE)) {
                    load_lang(pvalue);
                }

                /*initial font size */
                if(!strcmp(pname, KEY_FONTSIZE)) {
                    set_font_size(pvalue);
                }

                cur_mod->config_list[(string) pname] = (string) pvalue;
                ALOGI("[%s] %s:%s \n", module, pname, pvalue);
            }
        }
    }

    fclose(file);
    return CONFIG_SUCCESS;
}
示例#16
0
    status_t
    BackupDataReader::ReadNextHeader(bool *done, int *type) {
        *done = m_done;
        if (m_status != NO_ERROR) {
            return m_status;
        }

        int amt;

        amt = skip_padding();
        if (amt == EIO) {
            *done = m_done = true;
            return NO_ERROR;
        } else if (amt != NO_ERROR) {
            return amt;
        }
        amt = read(m_fd, &m_header, sizeof(m_header));
        *done = m_done = (amt == 0);
        if (*done) {
            return NO_ERROR;
        }
        CHECK_SIZE(amt, sizeof(m_header));
        m_pos += sizeof(m_header);
        if (type) {
            *type = m_header.type;
        }

        // validate and fix up the fields.
        m_header.type = fromlel(m_header.type);
        switch (m_header.type) {
            case BACKUP_HEADER_ENTITY_V1: {
                m_header.entity.keyLen = fromlel(m_header.entity.keyLen);
                if (m_header.entity.keyLen <= 0) {
                    ALOGD("Entity header at %d has keyLen<=0: 0x%08x\n", (int) m_pos,
                          (int) m_header.entity.keyLen);
                    m_status = EINVAL;
                }
                m_header.entity.dataSize = fromlel(m_header.entity.dataSize);
                m_entityCount++;

                // read the rest of the header (filename)
                size_t size = m_header.entity.keyLen;
                char *buf = m_key.lockBuffer(size);
                if (buf == NULL) {
                    m_status = ENOMEM;
                    return m_status;
                }
                int amt = read(m_fd, buf, size + 1);
                CHECK_SIZE(amt, (int) size + 1);
                m_key.unlockBuffer(size);
                m_pos += size + 1;
                SKIP_PADDING();
                m_dataEndPos = m_pos + m_header.entity.dataSize;

                break;
            }
            default:
                ALOGD("Chunk header at %d has invalid type: 0x%08x",
                      (int) (m_pos - sizeof(m_header)), (int) m_header.type);
                m_status = EINVAL;
        }

        return m_status;
    }
int AudioAnalogControl::GetAnalogGain(AudioAnalogType::VOLUME_TYPE VoleumType)
{
    ALOGD("GetAnalogGain VoleumType = %d", VoleumType);
    return mAudioMachineDevice->GetAnalogGain(VoleumType);
}
示例#18
0
static void * Audio_Record_thread(void *mPtr)
{
    struct mVibrator *hds  = (struct mVibrator *)mPtr;
    ALOGD(TAG "%s: Start", __FUNCTION__);
    usleep(100000);
    bool dumpFlag = 0; // read_preferred_recorddump() = 0
//    dumpFlag=true;//for test
    int magLower = 0,magUpper = 0;
    //read_preferred_magnitude(hds->i4OutputType,&magUpper,&magLower);
    //int freqOfRingtone = read_preferred_ringtone_freq();
    magLower = 1000;
    magUpper = 1000000000;
	int freqOfRingtone = 200;
	
    int lowFreq = freqOfRingtone * (1-0.1);
    int highFreq = freqOfRingtone * (1+0.1);
    short pbuffer[8192]={0};	
    short pbufferL[4096]={0};	
	  short pbufferR[4096]={0};	
    unsigned int freqDataL[3]={0},magDataL[3]={0};
	  unsigned int freqDataR[3]={0},magDataR[3]={0};
    int checkCnt = 0;

    return_data.vibrator.freq = 0;
    return_data.vibrator.ampl = 0;
	
    recordInit(hds->recordDevice);
    while (1) {
       memset(pbuffer,0,sizeof(pbuffer));
       memset(pbufferL,0,sizeof(pbufferL));
       memset(pbufferR,0,sizeof(pbufferR));
       
       int readSize  = readRecordData(pbuffer,8192*2);
       int i;
	   for(i = 0 ; i < 4096 ; i++)
       {
           pbufferL[i] = pbuffer[2 * i];
           pbufferR[i] = pbuffer[2 * i + 1];
       }

	    if(dumpFlag)
        {
            char filenameL[]="/data/record_dataL.pcm";
            char filenameR[]="/data/record_dataR.pcm";
		    FILE * fpL= fopen(filenameL, "wb+");
            FILE * fpR= fopen(filenameR, "wb+");
 		    
            if(fpL!=NULL)
	        {
	           fwrite(pbufferL,readSize/2,1,fpL);
		       fclose(fpL);
            }
	   
            if(fpR!=NULL)
	        {
	           fwrite(pbufferR,readSize/2,1,fpR);
		       fclose(fpR);
            }
        } 
        memset(freqDataL,0,sizeof(freqDataL));
        memset(freqDataR,0,sizeof(freqDataR));
        memset(magDataL,0,sizeof(magDataL));
        memset(magDataR,0,sizeof(magDataR));
        ApplyFFT256(48000,pbufferL,0,freqDataL,magDataL);
        ApplyFFT256(48000,pbufferR,0,freqDataR,magDataR);

        /*int j;
		for(j = 0;j < 3 ;j ++)
        {
            ALOGD("freqDataL[%d]:%d,magDataL[%d]:%d",j,freqDataL[j],j,magDataL[j]);
            ALOGD("freqDataR[%d]:%d,magDataR[%d]:%d",j,freqDataR[j],j,magDataR[j]);
        }*/
	       
	    if (((freqDataL[0] <= highFreq && freqDataL[0] >= lowFreq) && (magDataL[0] <= magUpper && magDataL[0] >= magLower))&&((freqDataR[0] <= highFreq && freqDataR[0] >= lowFreq) && (magDataR[0] <= magUpper && magDataR[0] >= magLower)))
		{
		    checkCnt ++;	
            if(checkCnt >= 5)
		    {
		        sprintf(hds->info + strlen(hds->info),"Check freq pass.\n");
	            ALOGD(" @ info : %s",hds->info);	
		        break;
		    }
	     }
	     else
		    checkCnt = 0;
	    
       if (hds->exit_thd){
	       break;
	     }
      }

      return_data.vibrator.freq = freqDataL[0];
      return_data.vibrator.ampl = magDataL[0];
	  
      ALOGD(TAG "VIBRATOR FFT: FreqL = %d, FreqR = %d, AmpL = %d, AmpR = %d", freqDataL[0], freqDataR[0], magDataL[0], magDataR[0]);

      ALOGD(TAG "%s: Stop", __FUNCTION__);
      pthread_exit(NULL); // thread exit
      return NULL;
}
status_t AudioAnalogControl::SetAnalogPinmuxInverse(bool bEnable)
{
    ALOGD("SetAnalogPinmuxInverse bEnable = %d",bEnable);
    mPinmuxInverse =bEnable;
    return NO_ERROR;
}
示例#20
0
int vibrator_autotest_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct mVibrator *mc = (struct mVibrator *)priv;
    struct textview *tv;
    struct itemview *iv;

    ALOGD(TAG "--------mAudio_receiver_entry-----------------------\n" );
    ALOGD(TAG "%s\n", __FUNCTION__);
    init_text(&mc->title, param->name, COLOR_YELLOW);
    init_text(&mc->text, "", COLOR_YELLOW);
    init_text(&mc->left_btn, uistr_key_fail, COLOR_YELLOW);
    init_text(&mc->center_btn, uistr_key_pass, COLOR_YELLOW);
    init_text(&mc->right_btn, uistr_key_back, COLOR_YELLOW);
    
    // init Audio
    Common_Audio_init();
    mc->exit_thd = false;
    vibrator_test_exit = false;

    // ui start
    if (!mc->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            ALOGD(TAG "No memory");
            return -1;
        }
        mc->iv = iv;
    }
    
    iv = mc->iv;
    iv->set_title(iv, &mc->title);
    iv->set_items(iv, items_auto, 0);
    iv->set_text(iv, &mc->text);
	iv->start_menu(iv,0);
    iv->redraw(iv);

    memset(mc->info, 0, sizeof(mc->info) / sizeof(*(mc->info)));
    mc->i4Playtime = 5*1000;//ms         //read_preferred_ringtone_time() = 5
    mc->recordDevice = WIRED_HEADSET;
    pthread_create(&mc->hHeadsetThread, NULL, update_vibrator_thread, priv);
    pthread_create(&mc->hRecordThread, NULL, Audio_Record_thread, priv);
    
    int    play_time = mc->i4Playtime;
    mc->mod->test_result = FTM_TEST_FAIL;

    int i;
    for(i = 0; i < 100 ; i ++)
    {
      //ALOGD("check mc info:%d",i);
      if (strstr(mc->info, "Check freq pass")) 
      {      
          mc->mod->test_result = FTM_TEST_PASS;
          ALOGD("Check freq pass");
          break;
      }
      usleep(play_time * 10);
    }

    if(mc->mod->test_result == FTM_TEST_FAIL)
       ALOGD("Check freq fail");

    if(mc->mod->test_result == FTM_TEST_PASS)
        usleep(2000000);

    mc->exit_thd = true;
    vibrator_test_exit = true;
	
    pthread_join(mc->hRecordThread, NULL);
    pthread_join(mc->hHeadsetThread, NULL);
    Common_Audio_deinit();
    
    LOGD(TAG "%s: End\n", __FUNCTION__);
    return 0;
}
status_t AudioAnalogControl::InitCheck()
{
    ALOGD("InitCheck \n");
    return NO_ERROR;
}
示例#22
0
status_t QCameraStream_Rdi::processRdiFrame(
  mm_camera_ch_data_buf_t *frame)
{
  ALOGV("%s",__func__);
  int err = 0;
  int msgType = 0;
  int i;
  camera_memory_t *data = NULL;

  Mutex::Autolock lock(mStopCallbackLock);
  if(!mActive) {
    ALOGE("RDI Streaming Stopped. Returning callback");
    return NO_ERROR;
  }
  if(mHalCamCtrl==NULL) {
    ALOGE("%s: X: HAL control object not set",__func__);
    /*Call buf done*/
    return BAD_VALUE;
  }

  mHalCamCtrl->mRdiMemoryLock.lock();
  mNotifyBuffer[frame->def.idx] = *frame;
  mHalCamCtrl->mRdiMemoryLock.unlock();

  mHalCamCtrl->mCallbackLock.lock();
  camera_data_callback pcb = mHalCamCtrl->mDataCb;
  mHalCamCtrl->mCallbackLock.unlock();
  ALOGD("Message enabled = 0x%x", mHalCamCtrl->mMsgEnabled);

  mHalCamCtrl->dumpFrameToFile(frame->def.frame, HAL_DUMP_FRM_RDI);

#ifdef USE_ION
  struct ion_flush_data cache_inv_data;
  int ion_fd;

  cache_inv_data.vaddr = (void *)frame->def.frame->buffer;
  cache_inv_data.fd = frame->def.frame->fd;
  cache_inv_data.handle = frame->def.frame->fd_data.handle;
  cache_inv_data.length = frame->def.frame->ion_alloc.len;
  ion_fd = frame->def.frame->ion_dev_fd;

  if (mHalCamCtrl->cache_ops(ion_fd, &cache_inv_data, ION_IOC_CLEAN_CACHES) < 0)
    ALOGE("%s: Cache clean for RDI buffer %p fd = %d failed", __func__,
      cache_inv_data.vaddr, cache_inv_data.fd);
#endif

  if (pcb != NULL) {
      //Sending rdi callback if corresponding Msgs are enabled
      if(mHalCamCtrl->mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) {
          msgType |=  CAMERA_MSG_PREVIEW_FRAME;
        data = mHalCamCtrl->mRdiMemory.camera_memory[frame->def.idx];
      } else {
          data = NULL;
      }

      if(msgType) {
          mStopCallbackLock.unlock();
          if(mActive)
            pcb(msgType, data, 0, NULL, mHalCamCtrl->mCallbackCookie);
      }
      ALOGD("end of cb");
  }
  if(MM_CAMERA_OK != cam_evt_buf_done(mCameraId, &mNotifyBuffer[frame->def.idx])) {
          ALOGE("BUF DONE FAILED");
  }
  return NO_ERROR;
}
static inline void debug_sys(const char* debuginfo)
{
	ALOGD("%s(%s)\n", debuginfo, strerror(errno));    
}
static void* iep_process_thread(void *param) 
{
    int i, cnt = 0;

    mem_region_t *mr = (mem_region_t*)param;

    uint32_t phy_src, phy_reg, phy_dst;
    int len_src, len_reg, len_dst;
    uint8_t *vir_reg, *vir_src, *vir_dst;
    iep_img src;
    iep_img dst;

    int datalen = 0;

    len_reg = mr->len_reg;
    len_src = mr->len_src;
    len_dst = mr->len_dst;

    phy_reg = mr->phy_reg;
    phy_src = mr->phy_src;
    phy_dst = mr->phy_dst;

    vir_reg = mr->vir_reg;
    vir_src = mr->vir_src;
    vir_dst = mr->vir_dst;

    iep_interface *api = iep_interface::create_new();

    FILE *srcfile = fopen(mr->src_url, "rb");
    FILE *dstfile = fopen(mr->dst_url, "wb");

    switch (mr->src_fmt) {
    case IEP_FORMAT_ABGR_8888:
    case IEP_FORMAT_ARGB_8888:
    case IEP_FORMAT_BGRA_8888:
    case IEP_FORMAT_RGBA_8888:
        datalen = mr->src_w * mr->src_h * 4;
        break;
    case IEP_FORMAT_BGR_565:
    case IEP_FORMAT_RGB_565:
    case IEP_FORMAT_YCbCr_422_P:
    case IEP_FORMAT_YCbCr_422_SP:
    case IEP_FORMAT_YCrCb_422_P:
    case IEP_FORMAT_YCrCb_422_SP:
        datalen = mr->src_w * mr->src_h * 2;
        src.v_addr = phy_src + mr->src_w * mr->src_h + mr->src_w * mr->src_h / 2;
        break;
    case IEP_FORMAT_YCbCr_420_P:
    case IEP_FORMAT_YCbCr_420_SP:
    case IEP_FORMAT_YCrCb_420_P:
    case IEP_FORMAT_YCrCb_420_SP:
        datalen = mr->src_w * mr->src_h * 3 / 2;
        src.v_addr = phy_src + mr->src_w * mr->src_h + mr->src_w * mr->src_h / 4;
        break;
    default:
        ;
    }

    ALOGD("%s %d\n", __func__, __LINE__);

    fread(vir_src, 1, datalen, srcfile);

    int64_t intime = GetTime();
    
    src.act_w = mr->src_w;
    src.act_h = mr->src_h;
    src.x_off = 0;
    src.y_off = 0;
    src.vir_w = mr->src_w;
    src.vir_h = mr->src_h;
    src.format = mr->src_fmt;
    src.mem_addr = phy_src;
    src.uv_addr  = phy_src + mr->src_w * mr->src_h;

    switch (mr->dst_fmt) {
    case IEP_FORMAT_ABGR_8888:
    case IEP_FORMAT_ARGB_8888:
    case IEP_FORMAT_BGRA_8888:
    case IEP_FORMAT_RGBA_8888:
        datalen = mr->dst_w * mr->dst_h * 4;
        break;
    case IEP_FORMAT_BGR_565:
    case IEP_FORMAT_RGB_565:
    case IEP_FORMAT_YCbCr_422_P:
    case IEP_FORMAT_YCbCr_422_SP:
    case IEP_FORMAT_YCrCb_422_P:
    case IEP_FORMAT_YCrCb_422_SP:
        datalen = mr->dst_w * mr->dst_h * 2;
        dst.v_addr = phy_dst + mr->dst_w * mr->dst_h + mr->dst_w * mr->dst_h / 2;
        break;
    case IEP_FORMAT_YCbCr_420_P:
    case IEP_FORMAT_YCbCr_420_SP:
    case IEP_FORMAT_YCrCb_420_P:
    case IEP_FORMAT_YCrCb_420_SP:
        datalen = mr->dst_w * mr->dst_h * 3 / 2;
        dst.v_addr = phy_dst + mr->dst_w * mr->dst_h + mr->dst_w * mr->dst_h / 4;
        break;
    default:
        ;
    }

    dst.act_w = mr->dst_w;
    dst.act_h = mr->dst_h;
    dst.x_off = 0;
    dst.y_off = 0;
    dst.vir_w = mr->dst_w;
    dst.vir_h = mr->dst_h;
    dst.format = mr->dst_fmt;
    dst.mem_addr = phy_dst;
    dst.uv_addr = phy_dst + mr->dst_w * mr->dst_h;

    api->init(&src, &dst);

    switch (mr->testcase) {
    case TEST_CASE_DENOISE:
        {
            FILE *cfgfile = fopen(mr->cfg_url, "r");

            if (cfgfile == NULL) {
                api->config_yuv_denoise();
            } else {
                ;
            }
        }
        break;
    case TEST_CASE_YUVENHANCE:
        {
            FILE *cfgfile = fopen(mr->cfg_url, "r");

            if (cfgfile == NULL) {
                api->config_yuv_enh();
            } else {
                iep_param_YUV_color_enhance_t yuvparam;
                parse_cfg_file(cfgfile, &yuvparam);
                api->config_yuv_enh(&yuvparam);
                fclose(cfgfile);
            }
        }
        break;
    case TEST_CASE_RGBENHANCE:
        {
            FILE *cfgfile = fopen(mr->cfg_url, "r");

            if (cfgfile == NULL) {
                api->config_color_enh();
            } else {
                iep_param_RGB_color_enhance_t rgbparam;
                parse_cfg_file(cfgfile, &rgbparam);
                api->config_color_enh(&rgbparam);
                fclose(cfgfile);
            }
        }
        break;
    case TEST_CASE_DEINTERLACE:
        {
            iep_img src1;
            iep_img dst1;
            iep_param_yuv_deinterlace_t yuv_dil;
            
            fread(vir_src + datalen, 1, datalen, srcfile);
    
            src1.act_w = mr->src_w;
            src1.act_h = mr->src_h;
            src1.x_off = 0;
            src1.y_off = 0;
            src1.vir_w = mr->src_w;
            src1.vir_h = mr->src_h;
            src1.format = mr->src_fmt;
            src1.mem_addr = phy_src + datalen;
            src1.uv_addr  = phy_src + datalen + mr->src_w * mr->src_h;

            dst1.act_w = mr->dst_w;
            dst1.act_h = mr->dst_h;
            dst1.x_off = 0;
            dst1.y_off = 0;
            dst1.vir_w = mr->dst_w;
            dst1.vir_h = mr->dst_h;
            dst1.format = mr->dst_fmt;
            dst1.mem_addr = phy_dst + datalen;
            dst1.uv_addr = phy_dst + datalen + mr->dst_w * mr->dst_h;

            FILE *cfgfile = fopen(mr->cfg_url, "r");

            if (cfgfile == NULL) {
                yuv_dil.high_freq_en = 1;
                yuv_dil.dil_mode = IEP_DEINTERLACE_MODE_I4O1;
                yuv_dil.field_order = FIELD_ORDER_BOTTOM_FIRST;
                yuv_dil.dil_ei_mode = 0;
                yuv_dil.dil_ei_smooth = 0;
                yuv_dil.dil_ei_sel = 0;
                yuv_dil.dil_ei_radius = 0;
            } else {
                parse_cfg_file(cfgfile, &yuv_dil);
                fclose(cfgfile);
            }
            
            api->config_yuv_deinterlace(&yuv_dil, &src1, &dst1);
        }
        break;
    default:
        ;
    }

#if 0
    iep_param_direct_path_interface_t dpi;

    dpi.enable = 1;
    dpi.off_x = 0;
    dpi.off_y = 0;
    dpi.width = mr->dst_w;
    dpi.height = mr->dst_h;
    dpi.layer = 1;
    
    if (0 > api->config_direct_lcdc_path(&dpi)) {
        ALOGE("Failure to Configure DIRECT LCDC PATH\n");
    }
#endif

    if (0 == api->run_sync()) {
        ALOGD("%d success\n", getpid());
    } else {
        ALOGE("%d failure\n", getpid());
    }

    ALOGD("%s consume %lld\n", __func__, GetTime() - intime);

    fwrite(vir_dst, 1, datalen, dstfile);

    fclose(srcfile);
    fclose(dstfile);

    iep_interface::reclaim(api);

    return NULL;
}
status_t AudioPlatformDevice::InitCheck()
{
    ALOGD("InitCheck");
    return NO_ERROR;
}
int main(int argc, char **argv)
{
    int i;
    pthread_t td;
    int ch;

    int pmem_phy_head;
    uint8_t *pmem_vir_head;

    VPUMemLinear_t vpumem; 
    mem_region_t mr;

    mr.src_fmt = IEP_FORMAT_YCbCr_420_SP;
    mr.src_w = 640;
    mr.src_h = 480;

    mr.dst_fmt = IEP_FORMAT_YCbCr_420_SP;
    mr.dst_w = 640;
    mr.dst_h = 480;

    /// get options
    opterr = 0;
    while ((ch = getopt(argc, argv, "f:w:h:c:F:W:H:C:t:x:")) != -1) {
        switch (ch) {
        case 'w':
            mr.src_w = atoi(optarg);
            break;
        case 'h':
            mr.src_h = atoi(optarg);
            break;
        case 'c':
            if (strcmp(optarg, "argb8888") == 0) {
                mr.src_fmt = IEP_FORMAT_ARGB_8888;
            } else if (strcmp(optarg, "abgr8888") == 0) {
                mr.src_fmt = IEP_FORMAT_ABGR_8888;
            } else if (strcmp(optarg, "rgba8888") == 0) {
                mr.src_fmt = IEP_FORMAT_BGRA_8888;
            } else if (strcmp(optarg, "bgra8888") == 0) {
                mr.src_fmt = IEP_FORMAT_BGRA_8888;
            } else if (strcmp(optarg, "rgb565") == 0) {
                mr.src_fmt = IEP_FORMAT_RGB_565;
            } else if (strcmp(optarg, "bgr565") == 0) {
                mr.src_fmt = IEP_FORMAT_BGR_565;
            } else if (strcmp(optarg, "yuv422sp") == 0) {
                mr.src_fmt = IEP_FORMAT_YCbCr_422_SP;
            } else if (strcmp(optarg, "yuv422p") == 0) {
                mr.src_fmt = IEP_FORMAT_YCbCr_422_P;
            } else if (strcmp(optarg, "yuv420sp") == 0) {
                mr.src_fmt = IEP_FORMAT_YCbCr_420_SP;
            } else if (strcmp(optarg, "yuv420p") == 0) {
                mr.src_fmt = IEP_FORMAT_YCbCr_420_P;
            } else if (strcmp(optarg, "yvu422sp") == 0) {
                mr.src_fmt = IEP_FORMAT_YCrCb_422_SP;
            } else if (strcmp(optarg, "yvu422p") == 0) {
                mr.src_fmt = IEP_FORMAT_YCrCb_422_P;
            } else if (strcmp(optarg, "yvu420sp") == 0) {
                mr.src_fmt = IEP_FORMAT_YCrCb_420_SP;
            } else if (strcmp(optarg, "yvu420p") == 0) {
                mr.src_fmt = IEP_FORMAT_YCrCb_420_P;
            }
            break;
        case 'W':
            mr.dst_w = atoi(optarg);
            break;
        case 'H':
            mr.dst_h = atoi(optarg);
            break;
        case 'C':
            if (strcmp(optarg, "argb8888") == 0) {
                mr.dst_fmt = IEP_FORMAT_ARGB_8888;
            } else if (strcmp(optarg, "abgr8888") == 0) {
                mr.dst_fmt = IEP_FORMAT_ABGR_8888;
            } else if (strcmp(optarg, "rgba8888") == 0) {
                mr.dst_fmt = IEP_FORMAT_BGRA_8888;
            } else if (strcmp(optarg, "bgra8888") == 0) {
                mr.dst_fmt = IEP_FORMAT_BGRA_8888;
            } else if (strcmp(optarg, "rgb565") == 0) {
                mr.dst_fmt = IEP_FORMAT_RGB_565;
            } else if (strcmp(optarg, "bgr565") == 0) {
                mr.dst_fmt = IEP_FORMAT_BGR_565;
            } else if (strcmp(optarg, "yuv422sp") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCbCr_422_SP;
            } else if (strcmp(optarg, "yuv422p") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCbCr_422_P;
            } else if (strcmp(optarg, "yuv420sp") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCbCr_420_SP;
            } else if (strcmp(optarg, "yuv420p") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCbCr_420_P;
            } else if (strcmp(optarg, "yvu422sp") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCrCb_422_SP;
            } else if (strcmp(optarg, "yvu422p") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCrCb_422_P;
            } else if (strcmp(optarg, "yvu420sp") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCrCb_420_SP;
            } else if (strcmp(optarg, "yvu420p") == 0) {
                mr.dst_fmt = IEP_FORMAT_YCrCb_420_P;
            }
            break;
        case 'f':
            ALOGD("input filename: %s\n", optarg);
            strcpy(mr.src_url, optarg);
            break;
        case 'F':
            ALOGD("output filename: %s\n", optarg);
            strcpy(mr.dst_url, optarg);
            break;
        case 't':
            if (strcmp(optarg, "denoise") == 0) {
                mr.testcase = TEST_CASE_DENOISE;
            } else if (strcmp(optarg, "yuvenhance") == 0) {
                mr.testcase = TEST_CASE_YUVENHANCE;
            } else if (strcmp(optarg, "rgbenhance") == 0) {
                mr.testcase = TEST_CASE_RGBENHANCE;
            } else if (strcmp(optarg, "deinterlace") == 0) {
                mr.testcase = TEST_CASE_DEINTERLACE;
            } else {
                mr.testcase = TEST_CASE_NONE;
            }
            break;
        case 'x':
            ALOGD("configure filename: %s\n", optarg);
            strcpy(mr.cfg_url, optarg);
            break;
        default:
            ;
        }
    }


    /// allocate in/out memory and initialize memory address
    VPUMallocLinear(&vpumem, 12<<20);

    pmem_phy_head = vpumem.phy_addr;//region.offset;
    pmem_vir_head = (uint8_t*)vpumem.vir_addr;

    mr.len_reg = 0x100;
    mr.len_src = 5<<20;
    mr.len_dst = 5<<20;

    mr.phy_reg = vpumem.phy_addr;
    pmem_phy_head += mr.len_reg;
    mr.phy_src = pmem_phy_head;
    pmem_phy_head += mr.len_src;
    mr.phy_dst = pmem_phy_head;
    pmem_phy_head += mr.len_dst;

    mr.vir_reg = (uint8_t*)vpumem.vir_addr;
    pmem_vir_head += mr.len_reg;
    mr.vir_src = pmem_vir_head;
    pmem_vir_head += mr.len_src;
    mr.vir_dst = pmem_vir_head;
    pmem_vir_head += mr.len_dst;

    pthread_create(&td, NULL, iep_process_thread, &mr);

    pthread_join(td, NULL);

    VPUFreeLinear(&vpumem);

    return 0;
}
/**
* a basic function fo select mux of device type, not all device may have mux
* if select a device with no mux support , report error.
* @param DeviceType analog part
* @param MuxType analog mux selection
* @return status_t
*/
status_t AudioPlatformDevice::AnalogSetMux(AudioAnalogType::DEVICE_TYPE DeviceType, AudioAnalogType::MUX_TYPE MuxType)
{
    ALOGD("AAudioPlatformDevice nalogSetMux DeviceType = %s MuxType = %s", kAudioAnalogDeviceTypeName[DeviceType], kAudioAnalogMuxTypeName[MuxType]);
    return NO_ERROR;
}
static int parse_cfg_file(FILE *file, void *param) {
    char str[100];

    fseek(file, 0, SEEK_SET);
    memset(str, 0, sizeof(str));
    read_line(file, str);

    ALOGD("cfg title %s\n", str);

    if (strncmp(str, "deinterlace", strlen("deinterlace")) == 0) {
        iep_param_yuv_deinterlace_t *arg = (iep_param_yuv_deinterlace_t*)param;
        int ret;

        do {
            memset(str, 0, sizeof(str));
            ret = read_line(file, str);
            if (strncmp(str, "high_freq_en", strlen("high_freq_en")) == 0) {
                sscanf(str, "high_freq_en %d", (int*)&arg->high_freq_en);
            } else if (strncmp(str, "dil_mode", strlen("dil_mode")) == 0) {
                sscanf(str, "dil_mode %d", (int*)&arg->dil_mode);
            } else if (strncmp(str, "dil_high_freq_fct", strlen("dil_high_freq_fct")) == 0) {
                sscanf(str, "dil_high_freq_fct %d", (int*)&arg->dil_high_freq_fct);
            } else if (strncmp(str, "dil_ei_mode", strlen("dil_ei_mode")) == 0) {
                sscanf(str, "dil_ei_mode %d", (int*)&arg->dil_ei_mode);
            } else if (strncmp(str, "dil_ei_smooth", strlen("dil_ei_smooth")) == 0) {
                sscanf(str, "dil_ei_smooth %d", (int*)&arg->dil_ei_smooth);
            } else if (strncmp(str, "dil_ei_sel", strlen("dil_ei_sel")) == 0) {
                sscanf(str, "dil_ei_sel %d", (int*)&arg->dil_ei_sel);
            } else if (strncmp(str, "dil_ei_radius", strlen("dil_ei_radius")) == 0) {
                sscanf(str, "dil_ei_radius %d", (int*)&arg->dil_ei_radius);
            }
        }
        while (ret == 0);
    } else if (strncmp(str, "yuv enhance", strlen("yuv enhance")) == 0) {
        iep_param_YUV_color_enhance_t *arg = (iep_param_YUV_color_enhance_t*)param;
        int ret;

        do {
            memset(str, 0, sizeof(str));
            ret = read_line(file, str);
            ALOGD("parameter %s\t", str);
            if (strncmp(str, "yuv_enh_saturation", strlen("yuv_enh_saturation")) == 0) {
                sscanf(str, "yuv_enh_saturation %f", &arg->yuv_enh_saturation);
                ALOGD("value %f\n", arg->yuv_enh_saturation);
            } else if (strncmp(str, "yuv_enh_contrast", strlen("yuv_enh_contrast")) == 0) {
                sscanf(str, "yuv_enh_contrast %f", &arg->yuv_enh_contrast);
                ALOGD("value %f\n", arg->yuv_enh_contrast);
            } else if (strncmp(str, "yuv_enh_brightness", strlen("yuv_enh_brightness")) == 0) {
                sscanf(str, "yuv_enh_brightness %d", (int*)&arg->yuv_enh_brightness);
                ALOGD("value %d\n", arg->yuv_enh_brightness);
            } else if (strncmp(str, "yuv_enh_hue_angle", strlen("yuv_enh_hue_angle")) == 0) {
                sscanf(str, "yuv_enh_hue_angle %d", (int*)&arg->yuv_enh_hue_angle);
                ALOGD("value %d\n", arg->yuv_enh_hue_angle);
            } else if (strncmp(str, "video_mode", strlen("video_mode")) == 0) {
                sscanf(str, "video_mode %d", (int*)&arg->video_mode);
                ALOGD("value %d\n", arg->video_mode);
            } else if (strncmp(str, "color_bar_y", strlen("color_bar_y")) == 0) {
                sscanf(str, "color_bar_y %d", (int*)&arg->color_bar_y);
                ALOGD("value %d\n", arg->color_bar_y);
            } else if (strncmp(str, "color_bar_u", strlen("color_bar_u")) == 0) {
                sscanf(str, "color_bar_u %d", (int*)&arg->color_bar_u);
                ALOGD("value %d\n", arg->color_bar_u);
            } else if (strncmp(str, "color_bar_v", strlen("color_bar_v")) == 0) {
                sscanf(str, "color_bar_v %d", (int*)&arg->color_bar_v);
                ALOGD("value %d\n", arg->color_bar_v);
            }
        }
        while (ret == 0);
    } else if (strncmp(str, "rgb enhance", strlen("rgb enhance")) == 0) {
        iep_param_RGB_color_enhance_t *arg = (iep_param_RGB_color_enhance_t*)param;
        int ret;

        do {
            memset(str, 0, sizeof(str));
            ret = read_line(file, str);
            ALOGD("parameter %s\t", str);
            if (strncmp(str, "rgb_enh_coe", strlen("rgb_enh_coe")) == 0) {
                sscanf(str, "rgb_enh_coe %f", &arg->rgb_enh_coe);
                ALOGD("value %f\n", arg->rgb_enh_coe);
            } else if (strncmp(str, "rgb_enhance_mode", strlen("rgb_enhance_mode")) == 0) {
                sscanf(str, "rgb_enhance_mode %d", (int*)&arg->rgb_enhance_mode);
                ALOGD("value %d\n", arg->rgb_enhance_mode);
            } else if (strncmp(str, "rgb_cg_en", strlen("rgb_cg_en")) == 0) {
                sscanf(str, "rgb_cg_en %d", (int*)&arg->rgb_cg_en);
                ALOGD("value %d\n", arg->rgb_cg_en);
            } else if (strncmp(str, "cg_rr", strlen("cg_rr")) == 0) {
                sscanf(str, "cg_rr %lf", &arg->cg_rr);
                ALOGD("value %f\n", arg->cg_rr);
            } else if (strncmp(str, "cg_rg", strlen("cg_rg")) == 0) {
                sscanf(str, "cg_rg %lf", &arg->cg_rg);
                ALOGD("value %f\n", arg->cg_rg);
            } else if (strncmp(str, "cg_rb", strlen("cg_rb")) == 0) {
                sscanf(str, "cg_rb %lf", &arg->cg_rb);
                ALOGD("value %f\n", arg->cg_rb);
            } else if (strncmp(str, "rgb_contrast_enhance_mode", strlen("rgb_contrast_enhance_mode")) == 0) {
                sscanf(str, "rgb_contrast_enhance_mode %d", (int*)&arg->rgb_contrast_enhance_mode);
                ALOGD("value %d\n", (int*)arg->rgb_contrast_enhance_mode);
            } else if (strncmp(str, "enh_threshold", strlen("enh_threshold")) == 0) {
                sscanf(str, "enh_threshold %d", (int*)&arg->enh_threshold);
                ALOGD("value %d\n", arg->enh_threshold);
            } else if (strncmp(str, "enh_alpha_num", strlen("enh_alpha_num")) == 0) {
                sscanf(str, "enh_alpha_num %d", (int*)&arg->enh_alpha_num);
                ALOGD("value %d\n", arg->enh_alpha_num);
            } else if (strncmp(str, "enh_alpha_base", strlen("enh_alpha_base")) == 0) {
                sscanf(str, "enh_alpha_base %d", (int*)&arg->enh_alpha_base);
                ALOGD("value %d\n", arg->enh_alpha_base);
            } else if (strncmp(str, "enh_radius", strlen("enh_radius")) == 0) {
                sscanf(str, "enh_radius %d", (int*)&arg->enh_radius);
                ALOGD("value %d\n", arg->enh_radius);
            }
        }
        while (ret == 0);
    } else if (strncmp(str, "scale", strlen("scale")) == 0) {
        iep_param_scale_t *arg = (iep_param_scale_t*)param;
        int ret;

        do {
            memset(str, 0, sizeof(str));
            ret = read_line(file, str);
            if (strncmp(str, "scale_up_mode", strlen("scale_up_mode")) == 0) {
                sscanf(str, "scale_up_mode %d", (int*)&arg->scale_up_mode);
            }
        }
        while (ret == 0);
    } else if (strncmp(str, "color space convertion", strlen("color space convertion")) == 0) {
        iep_param_color_space_convertion_t *arg = (iep_param_color_space_convertion_t*)param;
        int ret;

        do {
            memset(str, 0, sizeof(str));
            ret = read_line(file, str);
            if (strncmp(str, "rgb2yuv_mode", strlen("rgb2yuv_mode")) == 0) {
                sscanf(str, "rgb2yuv_mode %d", (int*)&arg->rgb2yuv_mode);
            } else if (strncmp(str, "yuv2rgb_mode", strlen("yuv2rgb_mode")) == 0) {
                sscanf(str, "yuv2rgb_mode %d", (int*)&arg->yuv2rgb_mode);
            } else if (strncmp(str, "rgb2yuv_input_clip", strlen("rgb2yuv_input_clip")) == 0) {
                sscanf(str, "rgb2yuv_input_clip %d", (int*)&arg->rgb2yuv_input_clip);
            } else if (strncmp(str, "yuv2rgb_input_clip", strlen("yuv2rgb_input_clip")) == 0) {
                sscanf(str, "yuv2rgb_input_clip %d", (int*)&arg->yuv2rgb_input_clip);
            } else if (strncmp(str, "global_alpha_value", strlen("global_alpha_value")) == 0) {
                sscanf(str, "global_alpha_value %d", (int*)&arg->global_alpha_value);
            } else if (strncmp(str, "dither_up_en", strlen("dither_up_en")) == 0) {
                sscanf(str, "dither_up_en %d", (int*)&arg->dither_up_en);
            } else if (strncmp(str, "dither_down_en", strlen("dither_down_en")) == 0) {
                sscanf(str, "dither_down_en %d", (int*)&arg->dither_down_en);
            }
        }
        while (ret == 0);
    } else if (strncmp(str, "direct lcdc path", strlen("direct lcdc path")) == 0) {
        iep_param_direct_path_interface_t *arg = (iep_param_direct_path_interface_t*)param;
        int ret;

        do {
            memset(str, 0, sizeof(str));
            ret = read_line(file, str);
            if (strncmp(str, "enable", strlen("enable")) == 0) {
                sscanf(str, "enable %d", (int*)&arg->enable);
            } else if (strncmp(str, "off_x", strlen("off_x")) == 0) {
                sscanf(str, "off_x %d", &arg->off_x);
            } else if (strncmp(str, "off_y", strlen("off_y")) == 0) {
                sscanf(str, "off_y %d", &arg->off_y);
            } else if (strncmp(str, "width", strlen("width")) == 0) {
                sscanf(str, "width %d", &arg->width);
            } else if (strncmp(str, "height", strlen("height")) == 0) {
                sscanf(str, "height %d", &arg->height);
            } else if (strncmp(str, "layer", strlen("layer")) == 0) {
                sscanf(str, "layer %d", (int*)&arg->layer);
            }
        }
        while (ret == 0);
    }

    return 0;
}
/**
* a basic function fo SetAnalogMute, if provide mute function of hardware.
* @param VoleumType value want to set to analog volume
* @param mute of volume type
* @return status_t
*/
status_t AudioPlatformDevice::SetAnalogMute(AudioAnalogType::VOLUME_TYPE VoleumType, bool mute)
{
    ALOGD("AudioPlatformDevice SetAnalogMute VOLUME_TYPE = %d mute = %d ", VoleumType, mute);
    return NO_ERROR;
}
示例#30
0
/// Vibration Speaker
int AudioFtm::SetVibSpkCalibrationParam(void *cali_param)
{
    ALOGD("%s()", __FUNCTION__);
    return SetAudioCompFltCustParamToNV(AUDIO_COMP_FLT_VIBSPK, (AUDIO_ACF_CUSTOM_PARAM_STRUCT *)cali_param);
}