Camera error: Can't cnnect to the camera

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Camera error: Can't cnnect to the camera

1,344 Views
jiejia
Contributor III

Dear all,

  board: refer to mx6q-sabresd

  BSP:android_M6.0.1_2.0.0

  I have a camera(1920*1080 30fps yuv422) conneted to my board of csi0.  I had finish the camera driver, and I had wrote my hal according to Ov5640Csi.cpp in libcamera3. When I used the camera app released by system, it can be preview and taken picture. When I used the camera app to record, a dialog box was pop up:

Camera error

      Can't cnnect to the camera

   I think the problem my be the hal file.  Here is my hal file. Any advises are appreciated.

Gv7601Csi.cpp:

#include "Gv7601Csi.h"

Gv7601Csi::Gv7601Csi(int32_t id, int32_t facing, int32_t orientation, char* path) : Camera(id, facing, orientation, path)
{
  mVideoStream = new OvStream(this);
}

Gv7601Csi::~Gv7601Csi()
{
}

status_t Gv7601Csi::initSensorStaticData()
{
  int32_t fd = open(mDevPath, O_RDWR);
  

  // first read sensor format.
  int ret = 0, index = 0;
  int sensorFormats[MAX_SENSOR_FORMAT];
  int availFormats[MAX_SENSOR_FORMAT];
  memset(sensorFormats, 0, sizeof(sensorFormats));
  memset(availFormats, 0, sizeof(availFormats));

  // v4l2 does not support enum format, now hard code here.
  sensorFormats[index] = v4l2_fourcc('N', 'V', '1', '2');
  availFormats[index++] = v4l2_fourcc('N', 'V', '1', '2');
  sensorFormats[index] = v4l2_fourcc('Y', 'V', '1', '2');
  availFormats[index++] = v4l2_fourcc('Y', 'V', '1', '2');
  mSensorFormatCount = changeSensorFormats(sensorFormats, mSensorFormats, index);
  if (mSensorFormatCount == 0) {
    ALOGE("%s no sensor format enum", __func__);
    close(fd);
    return BAD_VALUE;
  }

  availFormats[index++] = v4l2_fourcc('B', 'L', 'O', 'B');
  availFormats[index++] = v4l2_fourcc('R', 'A', 'W', 'S');
  //availFormats[2] = v4l2_fourcc('Y', 'U', 'Y', 'V');
  mAvailableFormatCount = changeSensorFormats(availFormats, mAvailableFormats, index);

  index = 0;
  char TmpStr[20];
  int previewCnt = 0, pictureCnt = 0;
  struct v4l2_frmsizeenum vid_frmsize;
  struct v4l2_frmivalenum vid_frmval;
  while (ret == 0) {
    memset(TmpStr, 0, 20);
    memset(&vid_frmsize, 0, sizeof(struct v4l2_frmsizeenum));
    vid_frmsize.index = index++;
    vid_frmsize.pixel_format = convertPixelFormatToV4L2Format(mSensorFormats[0]);
    ret = ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &vid_frmsize);
    if (ret != 0) {
      continue;
    }
    vid_frmval.discrete.denominator = 30;
    vid_frmval.discrete.numerator = 1;
    mPictureResolutions[pictureCnt++] = vid_frmsize.discrete.width;
    mPictureResolutions[pictureCnt++] = vid_frmsize.discrete.height;
    mPreviewResolutions[previewCnt++] = vid_frmsize.discrete.width;
    mPreviewResolutions[previewCnt++] = vid_frmsize.discrete.height;

  } // end while

  mPreviewResolutionCount = previewCnt;
  mPictureResolutionCount = pictureCnt;

  mMinFrameDuration = 33331760L;
  mMaxFrameDuration = 30000000000L;
  int i;
  for (i=0; i<MAX_RESOLUTION_SIZE && i<pictureCnt; i+=2) {
    ALOGI("SupportedPictureSizes: %d x %d", mPictureResolutions[i], mPictureResolutions[i+1]);
  }

  adjustPreviewResolutions();

  i = 0;
  mTargetFpsRange[i++] = 30;
  mTargetFpsRange[i++] = 30;
  mTargetFpsRange[i++] = 30;
  mTargetFpsRange[i++] = 30;

  setMaxPictureResolutions();
  ALOGI("mMaxWidth:%d, mMaxHeight:%d", mMaxWidth, mMaxHeight);

  mFocalLength = 3.37f;
  mPhysicalWidth = 3.6288f; //2592 x 1.4u
  mPhysicalHeight = 2.7216f; //1944 x 1.4u

  close(fd);
  return NO_ERROR;
}

// configure device.

int32_t Gv7601Csi::OvStream::onDeviceConfigureLocked()
{
  ALOGI("%s", __func__);
  int32_t ret = 0;
  if (mDev <= 0) {
    ALOGE("%s invalid fd handle", __func__);
    return BAD_VALUE;
  }

  int32_t input = 1;
  ret = ioctl(mDev, VIDIOC_S_INPUT, &input);
  if (ret < 0) {
    ALOGE("%s VIDIOC_S_INPUT Failed: %s", __func__, strerror(errno));
    return ret;
  }

  return USPStream::onDeviceConfigureLocked();
}

Labels (3)
0 Kudos
3 Replies

768 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello Jie,

    You should modify parameters to be your camera's in media_profiles.xml.

try it, please!

0 Kudos

768 Views
jiejia
Contributor III

Hi, Sun

   Thanks for reply. I have tried changed media_profiles.xml to support only 1080P, the error is the same.

<?xml version="1.0" encoding="utf-8"?>
<MediaSettings>
<!-- Each camcorder profile defines a set of predefined configuration parameters -->
<CamcorderProfiles cameraId="0">
<EncoderProfile quality="1080p" fileFormat="mp4" duration="30">
<Video codec="h264"
bitRate="8000000"
width="1920"
height="1080"
frameRate="30" />

<Audio codec="aac"
bitRate="96000"
sampleRate="44100"
channels="1" />

<Camera previewFrameRate="30" />
<EncoderOutputFileFormat name="mp4" />
</EncoderProfile>


<ImageEncoding quality="70" />
<ImageEncoding quality="80" />
<ImageEncoding quality="90" />
<ImageDecoding memCap="20000000" />
</CamcorderProfiles>


<!--
If a codec is not enabled, it is invisible to the applications
In other words, the applications won't be able to use the codec
or query the capabilities of the codec at all if it is disabled
-->
<VideoEncoderCap name="h263" enabled="true"
minBitRate="48000" maxBitRate="8000000"
minFrameWidth="176" maxFrameWidth="1920"
minFrameHeight="144" maxFrameHeight="1080"
minFrameRate="1" maxFrameRate="30" />

<VideoEncoderCap name="m4v" enabled="true"
minBitRate="64000" maxBitRate="8000000"
minFrameWidth="176" maxFrameWidth="1920"
minFrameHeight="144" maxFrameHeight="1080"
minFrameRate="1" maxFrameRate="30" />

<VideoEncoderCap name="h264" enabled="true"
minBitRate="64000" maxBitRate="8000000"
minFrameWidth="176" maxFrameWidth="1920"
minFrameHeight="144" maxFrameHeight="1080"
minFrameRate="1" maxFrameRate="30" />

.....................

0 Kudos

768 Views
jiejia
Contributor III

There is on sound card in my board. We only nedd to record the image.   Would my problem be caused by the audio record?    

Here is the log:

01-01 00:11:46.698 214 3291 E ACodec : [OMX.Freescale.std.video_encoder.avc.hw-based] storeMetaDataInBuffers (output) failed w/ err -1010
01-01 00:11:46.698 214 3291 E OMXNodeInstance: setConfig(36:Freescale.std._encoder.avc.hw-based, ConfigPriority(0x6f800002)) ERROR: UnsupportedIndex(0x8000101a)
01-01 00:11:46.747 214 682 E AudioSystem: AudioSystem::getInputBufferSize failed sampleRate 44100 format 0x1 channelMask 10
01-01 00:11:46.747 214 682 E AudioRecord: AudioSystem could not query the input buffer size for sampleRate 44100, format 0x1, channelMask 0x10; status -22
01-01 00:11:46.747 214 682 E StagefrightRecorder: audio source is not initialized
01-01 00:11:46.747 214 682 E MPEG4Writer: Stop() called but track is not started
01-01 00:11:46.777 3147 3147 E MediaRecorder: start failed: -2147483648
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: Could not start media recorder.
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: java.lang.RuntimeException: start failed.
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at android.media.MediaRecorder.start(Native Method)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at com.android.camera.VideoModule$11.onStorageUpdateDone(VideoModule.java:1399)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at com.android.camera.CameraActivity$20.onPostExecute(CameraActivity.java:2351)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at com.android.camera.CameraActivity$20.onPostExecute(CameraActivity.java:2346)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at android.os.AsyncTask.finish(AsyncTask.java:651)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at android.os.AsyncTask.-wrap1(AsyncTask.java)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at android.os.Handler.dispatchMessage(Handler.java:102)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at android.os.Looper.loop(Looper.java:148)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at android.app.ActivityThread.main(ActivityThread.java:5422)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at java.lang.reflect.Method.invoke(Native Method)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-01 00:11:46.781 3147 3147 E CAM_VideoModule: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: Handling Camera Access Failure:
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: java.lang.Exception
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at com.android.camera.FatalErrorHandlerImpl.onGenericCameraAccessFailure(FatalErrorHandlerImpl.java:84)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at com.android.camera.VideoModule$11.onStorageUpdateDone(VideoModule.java:1402)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at com.android.camera.CameraActivity$20.onPostExecute(CameraActivity.java:2351)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at com.android.camera.CameraActivity$20.onPostExecute(CameraActivity.java:2346)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at android.os.AsyncTask.finish(AsyncTask.java:651)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at android.os.AsyncTask.-wrap1(AsyncTask.java)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at android.os.Handler.dispatchMessage(Handler.java:102)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at android.os.Looper.loop(Looper.java:148)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at android.app.ActivityThread.main(ActivityThread.java:5422)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at java.lang.reflect.Method.invoke(Native Method)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-01 00:11:46.783 3147 3147 E CAM_FatalErrorHandler: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-01 00:11:46.785 3147 3147 E CAM_CameraUtil: Show fatal error dialog
01-01 00:11:47.305 207 231 E BufferQueueProducer: [com.android.camera2/com.android.camera.CameraLauncher] dequeueBuffer: can't dequeue multiple buffers without setting the buffer count

0 Kudos