九鼎创展论坛中文版English
登录 | 立即注册 设为首页收藏本站 切换到宽版
查看: 3805|回复: 2
打印 上一主题 下一主题

x210自带摄像头ov2655 ioctl获取或者设置摄像头信息出错

[复制链接]
跳转到指定楼层
楼主
发表于 2016-12-6 10:55:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
x210自带摄像头ov2655应用编程ioctl获取或者设置摄像头信息出错,



int main(void)
{
        int cameraFd = 0;
        int ret = 0;
        struct v4l2_fmtdesc fmt;

        cameraFd = open("/dev/video0", O_RDWR | O_NONBLOCK);
        if(cameraFd < 0)
        {
                perror("cameraFd");
                return -1;
        }
       
        memset(&fmt, 0, sizeof(fmt));
        fmt.index = 0;
        fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        while ((ret = ioctl(cameraFd, VIDIOC_ENUM_FMT, &fmt)) == 0)
        {
                fmt.index++;
                printf("{ pixelformat = ''%c%c%c%c'', description = ''%s'' }\n",

                                fmt.pixelformat & 0xFF, (fmt.pixelformat >> 8) & 0xFF,

                                (fmt.pixelformat >> 16) & 0xFF, (fmt.pixelformat >> 24) & 0xFF,

                                fmt.description);
       
        }

        return 0;
}



执行结果如下:
[   24.525856] s3c-fimc-0 : fimc_enum_fmt_vid_capture: No capture device.



用自带的安卓4.0测试过摄像头,是接上了的,



追到内核源码中:
int fimc_enum_fmt_vid_capture(struct file *file, void *fh,
                                        struct v4l2_fmtdesc *f)
{
        struct fimc_control *ctrl = ((struct fimc_prv_data *)fh)->ctrl;
        int i = f->index;
        int num_entries = 0;
        int ret = 0;

        fimc_dbg("%s\n", __func__);

        if (!ctrl->cam || !ctrl->cam->sd) {
                fimc_err("%s: No capture device.\n", __func__);                                                ///////////////////这里发现没有camera和sd
                return -ENODEV;
        }

        num_entries = sizeof(capture_fmts)/sizeof(struct v4l2_fmtdesc);

        if (i >= num_entries) {
                f->index -= num_entries;
                mutex_lock(&ctrl->v4l2_lock);
                ret = subdev_call(ctrl, video, enum_fmt, f);
                mutex_unlock(&ctrl->v4l2_lock);
                f->index += num_entries;
                return ret;
        }

        memcpy(f, &capture_fmts, sizeof(*f));

        return 0;
}


////////在这个结构体中定义:

const struct v4l2_ioctl_ops fimc_v4l2_ops = {
        .vidioc_querycap                = fimc_querycap,
        .vidioc_reqbufs                        = fimc_reqbufs,
        .vidioc_querybuf                = fimc_querybuf,
        .vidioc_g_ctrl                        = fimc_g_ctrl,
        .vidioc_s_ctrl                        = fimc_s_ctrl,
        .vidioc_s_ext_ctrls                = fimc_s_ext_ctrls,
        .vidioc_cropcap                        = fimc_cropcap,
        .vidioc_g_crop                        = fimc_g_crop,
        .vidioc_s_crop                        = fimc_s_crop,
        .vidioc_streamon                = fimc_streamon,
        .vidioc_streamoff                = fimc_streamoff,
        .vidioc_qbuf                        = fimc_qbuf,
        .vidioc_dqbuf                        = fimc_dqbuf,
        .vidioc_enum_fmt_vid_cap        = fimc_enum_fmt_vid_capture,
        。。。
}


///////////继续往往下追。。。

struct video_device fimc_video_device[FIMC_DEVICES] = {
        [0] = {
                .fops = &fimc_fops,
                .ioctl_ops = &fimc_v4l2_ops,
                .release = fimc_vdev_release,
        },
        [1] = {
                .fops = &fimc_fops,
                .ioctl_ops = &fimc_v4l2_ops,
                .release = fimc_vdev_release,
        },
        [2] = {
                .fops = &fimc_fops,
                .ioctl_ops = &fimc_v4l2_ops,
                .release = fimc_vdev_release,
        },
};




static
struct fimc_control *fimc_register_controller(struct platform_device *pdev)
{
        struct s3c_platform_fimc *pdata;
        struct fimc_control *ctrl;
        struct resource *res;
        int id, mdev_id;

        id = pdev->id;
        mdev_id = S5P_MDEV_FIMC0 + id;
        pdata = to_fimc_plat(&pdev->dev);

        ctrl = get_fimc_ctrl(id);
        ctrl->id = id;
        ctrl->dev = &pdev->dev;
        ctrl->vd = &fimc_video_device[id];                                        /////这里绑定的
        ctrl->vd->minor = id;
        。。。
}



///////再往下

static int __devinit fimc_probe(struct platform_device *pdev)
{
        struct s3c_platform_fimc *pdata;
        struct fimc_control *ctrl;
        struct clk *srclk;
        int ret;

        if (!fimc_dev) {
                fimc_dev = kzalloc(sizeof(*fimc_dev), GFP_KERNEL);
                if (!fimc_dev) {
                        dev_err(&pdev->dev, "%s: not enough memory\n",
                                __func__);
                        return -ENOMEM;
                }
        }

        ctrl = fimc_register_controller(pdev);                                                                                                                ////////这里调用
        if (!ctrl) {
                printk(KERN_ERR "%s: cannot register fimc\n", __func__);
                goto err_alloc;
        }
        。。。
        。。。
        。。。
        ret = device_create_file(&(pdev->dev), &dev_attr_log_level);
        if (ret < 0) {
                fimc_err("failed to add sysfs entries\n");
                goto err_global;
        }
        printk(KERN_INFO "FIMC%d registered successfully\n", ctrl->id);                                                ////////////////但是这个probe函数的这句打印在内核启动的时候有                       

        return 0;

}



内核启动打印信息:

[    5.555974] FIMC0 registered successfully
[    5.559790] FIMC1 registered successfully
[    5.563768] FIMC2 registered successfully






网上查过,有个描述类似的帖子http://www.360doc.com/content/13/0312/12/7775902_270985761.shtml


问题就是这样,不怎么会解决,新手求助

回复

使用道具 举报

沙发
 楼主| 发表于 2016-12-6 11:01:58 | 只看该作者
make x210ii_qt_defconfig
make menuconfig 中间添加了NFS的,其他没变

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|深圳市九鼎创展科技官方论坛 ( 粤ICP备11028681号-2  

GMT+8, 2024-5-2 05:40 , Processed in 0.017003 second(s), 16 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表