sp<CameraHardwareInterface> JordanCameraWrapper::createInstance(int cameraId)
{
    LOGV("%s :", __func__);
    if (singleton != NULL) {
        sp<CameraHardwareInterface> hardware = singleton.promote();
        if (hardware != NULL) {
            return hardware;
        }
    }

    CameraType type = CAM_SOC;
    sp<CameraHardwareInterface> motoInterface;
    sp<CameraHardwareInterface> hardware;

    if (deviceCardMatches("/dev/video3", "camise")) {
        LOGI("Detected SOC device\n");
        /* entry point of SOC driver is android::CameraHalSocImpl::createInstance() */
        motoInterface = openMotoInterface("libsoccamera.so", "_ZN7android16CameraHalSocImpl14createInstanceEv");
        type = CAM_SOC;
    } else if (deviceCardMatches("/dev/video0", "mt9p012")) {
        LOGI("Detected BAYER device\n");
        /* entry point of Bayer driver is android::CameraHal::createInstance() */
        motoInterface = openMotoInterface("libbayercamera.so", "_ZN7android9CameraHal14createInstanceEv");
        type = CAM_BAYER;
    } else {
        LOGE("Camera type detection failed");
     }
    return hardware;
}
sp<MotoCameraWrapper> MotoCameraWrapper::createInstance(int cameraId)
{
    if (singleton != NULL) {
        sp<MotoCameraWrapper> hardware = singleton.promote();
        if (hardware != NULL) {
            return hardware;
        }
    }

    CameraType type = UNKNOWN;
    sp<CameraHardwareInterface> motoInterface;
    sp<MotoCameraWrapper> hardware;
    char motodevice[PROPERTY_VALUE_MAX];

    /* Device detection */
    property_get("ro.product.device", motodevice, "");
    if (strcmp(motodevice, "shadow") == 0) {
        type = DROIDX;
    } else if (strcmp(motodevice, "droid2") == 0) {
        type = DROID2;
    } else if (strcmp(motodevice, "droid2we") == 0) {
        type = DROID2WE;
    } else if (strcmp(motodevice, "jordan") == 0) {
        if (deviceCardMatches("/dev/video3", "camise")) {
            type = DEFY_GREEN;
        } else if (deviceCardMatches("/dev/video0", "mt9p012")) {
            type = DEFY_RED;
        }
    }

    /* Load our Gingerbread library entry point */
    switch (type) {
        case DROIDX:
        case DROID2:
        case DROID2WE:
            motoInterface = openMotoInterface("libcamera.so", "_ZN7android9CameraHal14createInstanceEv");
            break;
        case DEFY_RED:
            motoInterface = openMotoInterface("libbayercamera.so", "_ZN7android9CameraHal14createInstanceEv");
            break;
        case DEFY_GREEN:
            motoInterface = openMotoInterface("libsoccamera.so", "_ZN7android16CameraHalSocImpl14createInstanceEv");
            break;
        case UNKNOWN:
        default:
            break;
    }

    if (motoInterface != NULL) {
        hardware = new MotoCameraWrapper(motoInterface, type);
        singleton = hardware;
    } else {
        LOGE("Could not open hardware interface");
    }

    return hardware;
}
sp<MotoCameraWrapper> MotoCameraWrapper::createInstance(int cameraId)
{
    LOGV("%s :", __func__);
    if (singleton != NULL) {
        sp<MotoCameraWrapper> hardware = singleton.promote();
        if (hardware != NULL) {
            return hardware;
        }
    }

    CameraType type = UNKNOWN;
    sp<CameraHardwareInterface> motoInterface;
    sp<MotoCameraWrapper> hardware;
    char motodevice[PROPERTY_VALUE_MAX];

    /* Device detection */
    property_get("ro.product.device", motodevice, "");
    if (strcmp(motodevice, "shadow") == 0) {
        type = DROIDX;
    } else if (strcmp(motodevice, "droid2") == 0) {
        type = DROID2;
    } else if (strcmp(motodevice, "droid2we") == 0) {
        type = DROID2WE;
    } else if (strcmp(motodevice, "venus2") == 0) {
        type = DROIDPRO;
    } else if (strcmp(motodevice, "jordan") == 0) {
        if (deviceCardMatches("/dev/video3", "camise")) {
	        type = CAM_SOC;
        } else if (deviceCardMatches("/dev/video0", "mt9p012")) {
	        type = CAM_BAYER;
        }
    }

    /* Load our Gingerbread library entry point */
    switch (type) {
        case DROIDX:
        case DROID2:
        case DROID2WE:
        case DROIDPRO:
			LOGI("Detected DROID device\n");
			/* entry point of DROID driver is android::CameraHal::createInstance() */
            motoInterface = openMotoInterface("libcamera.so", "_ZN7android9CameraHal14createInstanceEv");
            break;
        case CAM_SOC:
            LOGI("Detected SOC device\n");
	        /* entry point of SOC driver is android::CameraHalSocImpl::createInstance() */
	        motoInterface = openMotoInterface("libsoccamera.so", "_ZN7android16CameraHalSocImpl14createInstanceEv");
            break;
		case CAM_BAYER:
            LOGI("Detected BAYER device\n");
	        /* entry point of Bayer driver is android::CameraHal::createInstance() */
	        motoInterface = openMotoInterface("libbayercamera.so", "_ZN7android9CameraHal14createInstanceEv");
            break;
        case UNKNOWN:
        default:
			LOGE("Camera type detection failed");
            break;
    }

    if (motoInterface != NULL) {
        hardware = new MotoCameraWrapper(motoInterface, type);
        singleton = hardware;
    } else {
        LOGE("Could not open hardware interface");
    }

    return hardware;
}