|
如何在linux下,实现ov5640之类的cmos摄像头的驱动?
发表于 2016-7-18 11:31:39
浏览:7969
|
回复:3
打印
只看该作者
[复制链接]
楼主
本帖最后由 点缀0001 于 2016-7-28 11:16 编辑
使用5.1系统的kernel,rk3288-reload开发板,在linux下开发
使用内核自带的摄像头驱动,写了一个测试程序,但是把申请的缓冲区放入队列时失败了,查找了原因,是在:
- for (i = 0; i < NB_BUFFER; i++) {
- memset(&tV4l2Buf, 0, sizeof(struct v4l2_buffer));
- tV4l2Buf.index = i;
- tV4l2Buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- tV4l2Buf.memory = V4L2_MEMORY_MMAP;
- tV4l2Buf.flags = 0;
- iRet = ioctl(v4l2_fd, VIDIOC_QUERYBUF, &tV4l2Buf);
- if (iRet < 0) {
- DWrite("Unable to query buffer.\n");
- goto end;
- }
-
- printf("length: 0x%x offset: 0x%x\n", tV4l2Buf.length, tV4l2Buf.m.offset);
- pucVideoBuf[i] = (unsigned char *)mmap(0, /* start anywhere */
- tV4l2Buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, v4l2_fd,
- tV4l2Buf.m.offset);
- if (pucVideoBuf[i] == MAP_FAILED) {
- DWrite("Unable to map buffer\n");
- goto end;
- }
- printf("length: 0x%x offset: 0x%x\n", tV4l2Buf.length, tV4l2Buf.m.offset);
- 打印出来的结果是:
- length: 0xeb000 offset: 0x0
- length: 0xeb000 offset: 0xeb000
- length: 0xeb000 offset: 0x1d6000
- length: 0xeb000 offset: 0x2c1000
- 但是在 rk30_camera_oneframe.c 驱动的 rk_videobuf_prepare 函数里面不允许 videobuf 的偏移值为 0 ,
- if ((bytes_per_line < 0) || (vb->boff == 0))
- return -EINVAL; // 如果为0,就返回一个无效值
复制代码 导致后面无法把申请的缓冲区放入队列
rk30_camera_oneframe.c 不支持linux下的摄像头驱动吗?
|
|