Hello community,
I tried to configure the isp pieline within my application to get some pictures from my ov3640 camera sensor, but unfortunately some errors and ambiguity emerged. I use the gumstix overo board and a linux kernel version 3.5.
I tried to manually set the pipeline like this:
VS_printf(_T("TOM APPL 1 ##########\n"));
if ((cam->fd_v4l2_media = open("/dev/media0", O_RDWR, 0)) < 0)
{
//if ((cam->fd_v4l2 = open("/dev/video0", O_RDWR, 0)) < 0)
printf("TOM APPL OPEN MEDIA0 FAILED ##########\n");
return ERR_ERROR;
}
VS_printf(_T("TOM APPL 2 ##########\n"));
#define ENTITY_COUNT 20
#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
#define MEDIA_PAD_FL_INPUT (1 << 0)
#define MEDIA_PAD_FL_OUTPUT (1 << 1)
#define P_CCDC_SOURCE 1
#define P_VIDEO 0
//#define OV3640_FORMAT_DEF V4L2_MBUS_FMT_YUYV8_2X8
#define OV3640_FORMAT_DEF V4L2_PIX_FMT_RGB565
#define OV3640_WIDTH_DEF 640
#define OV3640_HEIGHT_DEF 480
//#define OV3640_WIDTH_DEF 2048
//#define OV3640_HEIGHT_DEF 1536
#define P_CCDC_SINK 0 /* sink pad of ccdc */
struct media_entity_desc entity[ENTITY_COUNT];
int E_VIDEO;
int E_OV3640;
int E_CCDC;
int ret;
int entities_count;
int index = 0;
do {
memset(&entity[index], 0, sizeof(struct media_entity_desc));
entity[index].id = index | MEDIA_ENT_ID_FLAG_NEXT;
ret = ioctl(cam->fd_v4l2_media, MEDIA_IOC_ENUM_ENTITIES, &entity[index]);
if (ret < 0) {
if (errno == EINVAL)
break;
}else {
VS_printf(_T("TOM APPL ENTITY NAME: %s ##########\n"),entity[index].name);
//printf("TOM APPL ENTITY NAME: %s ##########\n",entity[index].name);
if (!strcmp(entity[index].name, "OMAP3 ISP CCDC output")) {
E_VIDEO = entity[index].id;
}
else if (!strcmp(entity[index].name, "ov3640 3-003c")) {
E_OV3640 = entity[index].id;
}
else if (!strcmp(entity[index].name, "OMAP3 ISP CCDC")) {
E_CCDC = entity[index].id;
}
printf("[%x]:%s\n", entity[index].id, entity[index].name);
}
index++;
} while (ret == 0 && index < ENTITY_COUNT);
entities_count = index;
printf("total number of entities: %x\n", entities_count);
VS_printf(_T("TOM APPL 3 ##########\n"));
// 6. enable 'ov3640-->ccdc' link
struct media_link_desc link;
//link = calloc(sizeof(struct media_link),sizeof(UINT8));
//*link = (struct media_link*)calloc(sizeof(struct media_link),sizeof(UINT8));
printf("6. ENABLEing link [ov3640]----------->[ccdc]\n");
memset(&link, 0, sizeof(link));
link.flags |= MEDIA_LNK_FL_ENABLED;
link.source.entity = E_OV3640;
link.source.index = 0; //nur ein pad
link.source.flags = MEDIA_PAD_FL_OUTPUT;
link.sink.entity = E_CCDC;
link.sink.index = 0;
link.sink.flags = MEDIA_PAD_FL_INPUT;
ret = ioctl(cam->fd_v4l2_media, MEDIA_IOC_SETUP_LINK, &link);
if(ret) {
VS_printf(_T("failed to enable link between ov3640 and ccdc\n"));
return ERR_ERROR;
} else
VS_printf(_T("[ov3640]----------->[ccdc]\tENABLED\n"));
VS_printf(_T("TOM APPL 4 ##########\n"));
// 7. enable 'ccdc->memory' link
printf("7. ENABLEing link [ccdc]----------->[video_node]\n");
memset(&link, 0, sizeof(link));
link.flags |= MEDIA_LNK_FL_ENABLED;
link.source.entity = E_CCDC;
link.source.index = P_CCDC_SOURCE;
link.source.flags = MEDIA_PAD_FL_OUTPUT;
link.sink.entity = E_VIDEO;
link.sink.index = P_VIDEO;
link.sink.flags = MEDIA_PAD_FL_INPUT;
ret = ioctl(cam->fd_v4l2_media, MEDIA_IOC_SETUP_LINK, &link);
if(ret) {
VS_printf(_T("failed to enable link between ccdc and video node\n"));
return ERR_ERROR;
} else
VS_printf(_T("[ccdc]----------->[video_node]\t ENABLED\n"));
printf("**********************************************\n");
// 14.open capture device
if ((cam->fd_v4l2 = open("/dev/video2", O_RDWR | O_NONBLOCK, 0)) <= -1) {
VS_printf(_T("failed to open /dev/video2"));
return ERR_ERROR;
}
struct v4l2_input input;
/* 15.enumerate inputs supported by capture*/
printf("15.enumerating INPUTS\n");
bzero(&input, sizeof(struct v4l2_input));
input.type = V4L2_INPUT_TYPE_CAMERA;
input.index = 0;
index = 0;
while (1) {
ret = ioctl(cam->fd_v4l2, VIDIOC_ENUMINPUT, &input);
if(ret != 0)
break;
printf("[%x].%s\n", index, input.name);
bzero(&input, sizeof(struct v4l2_input));
index++;
input.index = index;
}
/* 16.setting CAMERA as input */
printf("16. setting CAMERA as input. . .\n");
bzero(&input, sizeof(struct v4l2_input));
input.type = V4L2_INPUT_TYPE_CAMERA;
input.index = 0;
if (-1 == ioctl (cam->fd_v4l2, VIDIOC_S_INPUT, &input.index)) {
VS_printf(_T("failed to set CAMERA with capture device\n"));
//goto cleanup;
return ERR_ERROR;
} else
VS_printf(_T("successfully set CAMERA input\n"));
/* 8. set format on pad of mt9p031 */
cam->fd_v4l2_ov3640 = open("/dev/v4l-subdev8", O_RDWR);
if(cam->fd_v4l2_ov3640 == -1) {
VS_printf(_T("failed to open /dev/v4l-subdev8"));
//goto cleanup;
return ERR_ERROR;
}
struct v4l2_subdev_format fmt;
VS_printf(_T("8. setting format on pad of mt9p031 entity. . .\n"));
memset(&fmt, 0, sizeof(fmt));
fmt.pad = 0;
fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
fmt.format.code = OV3640_FORMAT_DEF;
fmt.format.width = OV3640_WIDTH_DEF;
fmt.format.height = OV3640_HEIGHT_DEF;
fmt.format.field = V4L2_FIELD_NONE;
ret = ioctl(cam->fd_v4l2_ov3640, VIDIOC_SUBDEV_S_FMT, &fmt);
if(ret) {
VS_printf(_T("failed to set format on pad %x\n"), fmt.pad);
//goto cleanup;
return ERR_ERROR;
}
else
VS_printf(_T("successfully format is set on pad %x\n"), fmt.pad);
/* 9. set format on sink-pad of ccdc */
cam->fd_v4l2_isp_ccdc = open("/dev/v4l-subdev2", O_RDWR);
if(cam->fd_v4l2_isp_ccdc == -1) {
VS_printf(_T("failed to open /dev/v4l-subdev2"));
//goto cleanup;
return ERR_ERROR;
}
// set format on sink pad of ccdc
VS_printf(_T("12. setting format on sink-pad of ccdc entity. . .\n"));
memset(&fmt, 0, sizeof(fmt));
fmt.pad = P_CCDC_SINK;
fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
fmt.format.code = OV3640_FORMAT_DEF;
fmt.format.width = OV3640_WIDTH_DEF;
fmt.format.height = OV3640_HEIGHT_DEF;
fmt.format.field = V4L2_FIELD_NONE;
ret = ioctl(cam->fd_v4l2_isp_ccdc, VIDIOC_SUBDEV_S_FMT, &fmt);
if(ret) {
VS_printf(_T("failed to set format on pad %x\n"), fmt.pad);
//goto cleanup;
return ERR_ERROR;
}
else
VS_printf(_T("successfully format is set on pad %x\n"), fmt.pad);
/* 13. set format on source-pad of ccdc */
printf("13. setting format on OF-pad of ccdc entity. . . \n");
memset(&fmt, 0, sizeof(fmt));
fmt.pad = P_CCDC_SOURCE;
fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
fmt.format.code = OV3640_FORMAT_DEF;
fmt.format.width = OV3640_WIDTH_DEF;
fmt.format.height = OV3640_HEIGHT_DEF;
fmt.format.colorspace = V4L2_COLORSPACE_JPEG;
fmt.format.field = V4L2_FIELD_NONE;
ret = ioctl(cam->fd_v4l2_isp_ccdc, VIDIOC_SUBDEV_S_FMT, &fmt);
if(ret) {
VS_printf(_T("failed to set format on pad %x\n"), fmt.pad);
//goto cleanup;
return ERR_ERROR;
}
else
VS_printf(_T("successfully format is set on pad %x\n"), fmt.pad);
struct v4l2_format v4l2_fmt;
int capture_pitch;
VS_printf(_T("17. setting format V4L2_PIX_FMT_SBGGR16\n"));
//CLEAR(v4l2_fmt);
v4l2_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
v4l2_fmt.fmt.pix.width = OV3640_WIDTH_DEF;
v4l2_fmt.fmt.pix.height = OV3640_HEIGHT_DEF;
//v4l2_fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SBGGR16;
v4l2_fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB565;
v4l2_fmt.fmt.pix.field = V4L2_FIELD_NONE;
if (-1 == ioctl(cam->fd_v4l2, VIDIOC_S_FMT, &v4l2_fmt)) {
VS_printf(_T("failed to set format on captute device \n"));
return ERR_ERROR;
} else
VS_printf(_T("successfully set the format\n"));
/* 15.call G_FMT for knowing picth */
if (-1 == ioctl(cam->fd_v4l2, VIDIOC_G_FMT, &v4l2_fmt)) {
VS_printf(_T("failed to get format from captute device \n"));
return ERR_ERROR;
} else {
VS_printf(_T("capture_pitch: %x\n"), v4l2_fmt.fmt.pix.bytesperline);
capture_pitch = v4l2_fmt.fmt.pix.bytesperline;
}
/* 18.make sure 3 buffers are supported for streaming */
printf("18. Requesting for 3 buffers\n");
struct v4l2_requestbuffers req;
//CLEAR(req);
req.count = 3;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_USERPTR;
if (-1 == ioctl(cam->fd_v4l2, VIDIOC_REQBUFS, &req)) {
VS_printf(_T("call to VIDIOC_REQBUFS failed\n"));
return ERR_ERROR;
}
if (req.count != 3) {
VS_printf(_T("3 buffers not supported by capture device"));
return ERR_ERROR;
} else
VS_printf(_T("3 buffers are supported for streaming\n"));
VS_printf(_T("TOM APPL 900 ##########\n"));
/* 20.start streaming */
enum v4l2_buf_type type;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == ioctl(cam->fd_v4l2, VIDIOC_STREAMON, &type)) {
VS_printf(_T("failed to start streaming on capture device"));
return ERR_ERROR;
} else
VS_printf(_T("streaming started successfully\n"));
/* ENDE */
VS_printf(_T("TOM APPL 1000 ##########\n"));
my output loglooks like this:
TOM APPL 1 ##########
TOM APPL 2 ##########
TOM APPL ENTITY NAME: OMAP3 ISP CCP2 ##########
TOM APPL ENTITY NAME: OMAP3 ISP CCP2 input ##########
TOM APPL ENTITY NAME: OMAP3 ISP CSI2a ##########
TOM APPL ENTITY NAME: OMAP3 ISP CSI2a output ##########
TOM APPL ENTITY NAME: OMAP3 ISP CCDC ##########
TOM APPL ENTITY NAME: OMAP3 ISP CCDC output ##########
TOM APPL ENTITY NAME: OMAP3 ISP preview ##########
TOM APPL ENTITY NAME: OMAP3 ISP preview input ##########
TOM APPL ENTITY NAME: OMAP3 ISP preview output ##########
TOM APPL ENTITY NAME: OMAP3 ISP resizer ##########
TOM APPL ENTITY NAME: OMAP3 ISP resizer input ##########
TOM APPL ENTITY NAME: OMAP3 ISP resizer output ##########
TOM APPL ENTITY NAME: OMAP3 ISP AEWB ##########
TOM APPL ENTITY NAME: OMAP3 ISP AF ##########
TOM APPL ENTITY NAME: OMAP3 ISP histogram ##########
TOM APPL ENTITY NAME: ov3640 3-003c ##########
TOM APPL 3 ##########
[tvp7002]----------->[ccdc] ENABLED
TOM APPL 4 ##########
[ccdc]----------->[video_node] ENABLED
successfully set CAMERA input
8. setting format on pad of mt9p031 entity. . .
successfully format is set on pad 0
12. setting format on sink-pad of ccdc entity. . .
successfully format is set on pad 0
successfully format is set on pad 1
17. setting format V4L2_PIX_FMT_SBGGR16
successfully set the format
capture_pitch: 500
3 buffers are supported for streaming
TOM APPL 900 ##########
overo2 [ 916.723297] Internal error: Oops: 17 [#1] PREEMPT ARM
overo2 [ 916.798278] Process MBVisionCameraS (pid: 1309, stack limit = 0xcd9122f0)
overo2 [ 916.805358] Stack: (0xcd913a00 to 0xcd914000)
overo2 [ 916.809906] 3a00: ceec6440 cd913a68 cd913a10 bf01d320 00000001 00000000 00000280 000001e0
overo2 [ 916.818420] 3a20: 00002008 00000000 00000000 00000000 00000000 00000000 00000000 00000000
overo2 [ 916.826965] 3a40: 00000000 00000000 00000004 00000101 00000009 c0765b80 cd912000 c003a448
overo2 [ 916.835510] 3a60: cec06170 c025d4b4 00000001 00000000 00000280 000001e0 0000300a 00000001
overo2 [ 916.844024] 3a80: 00000008 00000000 00000000 00000000 00000000 00000000 00000000 00000000
overo2 [ 916.852569] 3aa0: cd913ac4 cdaf02ac 00000001 cd913ad4 cd92da10 cdaf9148 cdaf9148 cdaf02ac
overo2 [ 916.861114] 3ac0: 00000009 cdaf8fd8 cdaf9148 bf0013f8 c06d943c 00000000 00000001 cdaf9148
overo2 [ 916.869628] 3ae0: 00000001 cdaf8fd8 00000009 cd92da10 00000001 00000000 60000013 cd913b10
overo2 [ 916.878173] 3b00: c0033b4c c0034584 60000013 ffffffff 00000000 00000000 00000000 00000000
overo2 [ 916.886718] 3b20: c0725248 00000021 ccc4c080 00000000 cd913e68 cd913b40 c048eb6c c005db38
overo2 [ 916.895233] 3b40: 22222222 22222222 22222222 22222222 cd933000 00000001 00000001 cccb1bc0
overo2 [ 916.903778] 3b60: 00000001 cdaf9148 cccb1bc0 cdaf93f4 cd933000 cdaf9148 cd913e68 bf03d92c
overo2 [ 916.912292] 3b80: cdaf942c 00000402 00000000 00000000 4ae3160d 12b63f0f 00000000 000001c9
overo2 [ 916.920837] 3ba0: 00000008 ccc4c080 60000113 c00e0b00 ccc4c080 00000020 ccc4c080 cd8e1c80
overo2 [ 916.929382] 3bc0: 00000020 c0424340 00000020 cd8e1c80 ccc4c080 cd8e1c80 ccc4c080 cda29de4
overo2 [ 916.937896] 3be0: 00000016 32c213ac 00000002 c042bd08 ccc4c080 c0416064 00000000 00000000
overo2 [ 916.946441] 3c00: cd8e1c80 c0710b20 00000000 ccc4c080 cda29dd0 cd913c20 c042c474 c005db38
overo2 [ 916.954986] 3c20: 32c213ac 00000016 00000002 00000101 00000009 c0765b80 cd912000 c0710b20
overo2 [ 916.963500] 3c40: cec06170 00000006 c0710b20 c04edac4 00000000 cd8e1c80 c06c5b30 c0710b20
overo2 [ 916.972045] 3c60: 00000001 c040e110 cda29dd0 00000008 cd8e1c80 00000000 c06c51f8 cd913cb4
overo2 [ 916.980590] 3c80: cd913cbc c040dbe0 cee91800 00000001 00000008 c06c51d8 00000008 cee91800
overo2 [ 916.989105] 3ca0: c06c51d8 c03ea784 cee91c80 00000046 00000001 cd8e1c80 00000010 c06c51f8
overo2 [ 916.997650] 3cc0: 00000010 cd913cd0 c030a484 c005db38 00000010 cd913ce0 c030c950 c005db38
overo2 [ 917.006195] 3ce0: 00000000 c0765b80 cee91d4c cd912000 00000010 00000101 c0864860 c00afd10
overo2 [ 917.014709] 3d00: cdb68b78 cd913d10 c00b0944 c005db38 cd912000 00000003 cd913d58 ceac7e30
overo2 [ 917.023254] 3d20: 0000000a 85ac318f 00085ac3 c00dad54 00000000 c0016514 c0864860 00000000
overo2 [ 917.031799] 3d40: 00000000 c00cd138 00025000 00000001 cd933000 00000000 cccb1bc0 bf04c1dc
overo2 [ 917.040313] 3d60: ffffffe7 cdaf9148 cd913e68 bf0143ac cdad8000 cce08e40 00025000 00000000
overo2 [ 917.048858] 3d80: 00025000 cdb68b78 00000028 c00cde14 0000001d c06c8878 00000000 c0057a98
overo2 [ 917.057403] 3da0: 000000d5 40045612 cccb1bc0 cd933000 c0723b88 cce08e40 cd913dec cd913dc8
overo2 [ 917.065948] 3dc0: c005f364 c005db38 cee95570 00000000 00000019 ced69ac0 cee95540 cce08e40
overo2 [ 917.074462] 3de0: cd913e7c cd913df0 c048fe78 c005db38 a0000093 00000000 00000000 c0059f24
overo2 [ 917.083007] 3e00: c0490004 cd912000 cee95540 00000000 cd913e44 cd913e20 c005fcf0 c005db38
overo2 [ 917.091552] 3e20: cd913ee4 cd92fcd8 00000000 00000001 cd92fce4 00000000 40045612 00000000
overo2 [ 917.100067] 3e40: cccb1bc0 00000000 00000000 cd913e68 00000000 bf012774 00000004 bf012908
overo2 [ 917.108612] 3e60: be9755fc 00000001 00000001 cd913e78 c005eccc c005db38 00000004 c048f8d8
overo2 [ 917.117156] 3e80: c004ca7c 00000002 cd92fc00 cdbe3000 00000001 cd912000 cd92f400 cd913ea8
overo2 [ 917.125671] 3ea0: c029e2b8 c005ec84 0000000a 00001f00 00000002 c048e7a0 cd92f400 cd913ec8
overo2 [ 917.134216] 3ec0: c0052530 cefd7e08 00000003 00000001 00000000 60000013 00000000 00000018
overo2 [ 917.142761] 3ee0: cceff248 cd913ef0 c0057588 cccb1bc0 cdaf9148 00000000 40045612 be9755fc
overo2 [ 917.151306] 3f00: cd912000 00000000 be97564c bf010708 ccc5a0e8 cccb1bc0 00000004 00000004
overo2 [ 917.159820] 3f20: be9755fc c00f9c18 c0299a28 00000000 00000000 00000000 00000006 cceff248
overo2 [ 917.168365] 3f40: 00000018 00000002 c8906148 00000000 cd912000 00000000 be974024 c00ea8ec
overo2 [ 917.176910] 3f60: 00000000 00000000 00000000 be9755fc 40045612 00000004 cccb1bc0 cd912000
overo2 [ 917.185424] 3f80: 00000000 c00f9ccc cd913fb0 00000000 010deae0 00000000 0000ceb8 00000036
overo2 [ 917.193969] 3fa0: c000e984 c000e800 010deae0 00000000 00000004 40045612 be9755fc 00000004
overo2 [ 917.202514] 3fc0: 010deae0 00000000 0000ceb8 00000036 00000000 00000000 b6fd3000 be97564c
overo2 [ 917.211029] 3fe0: 00000000 be974040 0000f66c b671e45c 60000010 00000004 8f2fe821 8f2fec21
overo2 [ 917.321228] Code: ebffebaf e1a05000 e1a00004 ebffebac (e595200c)
Can anyone tell me what is missing or what I might have done wrong?
And I have one additional question. When I want to change the format through my application. Do I need to change the format on all three pads or would it be enought to call the ioctl just for the video device (video2)?
Regards, Tom