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();
}