|
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
问题就是这样,不怎么会解决,新手求助
|
|