AnsweredAssumed Answered

OV5640 MIPI camera on a iMX6 set exposure and gain

Question asked by Sreekanth M on Aug 20, 2015

Hi,

 

I am trying to implement the Camera Exposure parameter on OV5640 over MIPI but change in Camera Exposure via user interface has no effect on the display.

 

I followed below article as a base to my changes:

https://community.freescale.com/message/503821#503821

 

Below are the changes I made:

  1. In ov5640_mipi.c routine, in ioctl_s_ctrl function:

static int ioctl_s_ctrl(struct v4l2_int_device *s, struct v4l2_control *vc)

{

 

     switch (vc->id) {

     case V4L2_CID_EXPOSURE:

     /* turn off AE/AG */

      OV5640_turn_on_AE_AG(0);

      OV5640_set_shutter((__s32)vc->value);

      break;

     case V4L2_CID_GAIN:

      OV5640_set_gain16((__s32)vc->value);

      break;

}

}

2. In ov5640Mipi.cpp, below changes are introduced in setparameter() function

status_t Ov5640Mipi::setCameraExposureParams(int32_t expparams)

{

    FLOGI("Start of Ov5640Mipi.cpp - Exposure Value: %d", expparams);

    struct v4l2_control int_control_exp;

    int_control_exp.id = V4L2_CID_EXPOSURE;

    int_control_exp.value = expparams;

    int ret_exp = ioctl(mCameraHandle, VIDIOC_S_CTRL, &int_control_exp);

    FLOGI("The Returned exposure setting status: %d", ret_exp);

 

    return NO_ERROR;

}

 

3. DeviceAdapter.cpp

status_t DeviceAdapter::startDeviceLocked()

{

....

....

....

setCameraExposureCompensation();

}

 

void DeviceAdapter::setCameraExposureCompensation()

{

    FLOGE("DeviceAdapter: Inside setCameraExposureCompensation");

    int32_t expComp;

    status_t ret1 = NO_ERROR;

 

    ret1 = mMetadaManager->getExposureCompensation(expComp);

    if (ret1 != NO_ERROR) {

        FLOGE("DeviceAdapter: getExposureCompensation failed");

        expComp = 0;

        return;

    }

    FLOGE("DeviceAdapter: Exposure Compensation: %d", expComp);

    ret1 = setCameraExposureParams(expComp);

    if (ret1 != NO_ERROR) {

        FLOGE("DeviceAdapter: setCameraExposureParams failed");

        return;

    }

    FLOGE("DeviceAdapter: End of setCameraExposureCompensation");

}

 

status_t DeviceAdapter::setCameraExposureParams(int32_t expparams)

{

    FLOGE("DeviceAdapter: setCameraExposureParams: %d",expparams);   

    return NO_ERROR;

}

 

4. MetadaManager.cpp

 

status_t MetadaManager::getExposureCompensation(int32_t &expComp)

{

    ALOGE("MetadaManager: Executing getExposureCompensation");   

    camera_metadata_entry_t streams;

    int res = find_camera_metadata_entry(mCurrentRequest,

                ANDROID_CONTROL_AE_EXP_COMPENSATION, &streams);

    if (res != NO_ERROR) {

        ALOGE("%s: error reading jpeg Rotation tag", __FUNCTION__);

        return BAD_VALUE;

    }

    expComp = streams.data.i32[0];

    ALOGE("MetadaManager: Exposure Compensation value: %d",expComp);

    return NO_ERROR;

}

MetadaManager always returns 0 as exposure value, camera does not display continuously and no impact on change in Exposure.

Attached is logcat and routines changed.

Please share your thoughts on what's is missing in my implementation. Let me know if you need further details about the issue / implementation.

Original Attachment has been moved to: OvDevice.h.zip

Original Attachment has been moved to: DeviceAdapter.h.zip

Original Attachment has been moved to: MetadaManager.cpp.zip

Original Attachment has been moved to: log0908a.txt.zip

Original Attachment has been moved to: OvDevice.cpp.zip

Original Attachment has been moved to: DeviceAdapter.cpp.zip

Original Attachment has been moved to: Ov5640Mipi.cpp.zip

Original Attachment has been moved to: MetadaManager.h.zip

Outcomes