天嵌 ARM开发社区

 找回密码
 注册
查看: 4182|回复: 11

VIDIOC_ENUM_FMT pc机打印的结果和开发板上打印出的结果不同

[复制链接]
changqiong0606 发表于 2012-11-26 21:48:35 | 显示全部楼层 |阅读模式

求助各位大神
情况是这样的,V4L2编程,我想查询摄像头所有输出格式,调用函数ioctl(dev, VIDIOC_ENUM_FMT, &fmt);
宿主机pc机上打印结果是MJPG和YUYV都支持的,但是交叉编译在开发板上运行时,却发现只能打印出YUYV。

pc机的linux内核是2.6.32
开发板内核2.6.30,我想应该不是内核的原因吧,毕竟内核版本很接近。

如果不是,那到底是什么原因呢??:'(

纠结啊,求助各位。。。先谢了。。。
 楼主| changqiong0606 发表于 2012-11-26 21:52:25 | 显示全部楼层
版主 各位大神。。。求助啊
回复

使用道具 举报

TQ-ZQL 发表于 2012-11-27 10:00:31 | 显示全部楼层
本帖最后由 TQ-ZQL 于 2012-11-27 10:03 编辑

内核不同驱动有不同这个很正常,这个具体你还得要看下你自己摄像头的驱动。 你看下fmt.type是不是一样的,如果是一样的,那驱动不同引起的机率应该比较大
回复

使用道具 举报

 楼主| changqiong0606 发表于 2012-11-28 19:09:34 | 显示全部楼层
fmt.type都是1啊,为什么说这样 “引起的机率应该比较大”呢啊 版主:dizzy:
回复

使用道具 举报

 楼主| changqiong0606 发表于 2012-12-3 10:22:52 | 显示全部楼层
TQ-ZQL 发表于 2012-11-27 10:00
内核不同驱动有不同这个很正常,这个具体你还得要看下你自己摄像头的驱动。 你看下fmt.type是不是一样的,如 ...

fmt.type有三种V4L2_BUF_TYPE_VIDEO_CAPTURE,V4L2_BUF_TYPE_VIDEO_OUTPUT,V4L2_BUF_TYPE_VIDEO_OVERLAY,我设置的fmt.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
目前已经排除内核版本的原因了,因为我在移植的linux 3.0内核也出现一样的问题,在板子中只能查到YUYV格式,但是在PC机却可以查询到MJPG和YUYV两种格式。纠结啊,还请版主明示。
回复

使用道具 举报

亚瑟王 发表于 2012-12-3 11:14:06 | 显示全部楼层
changqiong0606 发表于 2012-12-3 10:22
fmt.type有三种V4L2_BUF_TYPE_VIDEO_CAPTURE,V4L2_BUF_TYPE_VIDEO_OUTPUT,V4L2_BUF_TYPE_VIDEO_OVERLAY, ...

这个主要和摄像头驱动有关,摄像头驱动识别出来是哪种格式,对外就是哪种格式了。
回复

使用道具 举报

 楼主| changqiong0606 发表于 2012-12-3 18:14:45 | 显示全部楼层
亚瑟王 发表于 2012-12-3 11:14
这个主要和摄像头驱动有关,摄像头驱动识别出来是哪种格式,对外就是哪种格式了。

嗯,我只是不明白为什么驱动会这样处理,按道理在pc机上都能识别出来两种格式,板子没道理只识别一种啊,pc机上的内核驱动和板子内核驱动一样的啊。。。
回复

使用道具 举报

亚瑟王 发表于 2012-12-3 18:50:48 | 显示全部楼层
changqiong0606 发表于 2012-12-3 18:14
嗯,我只是不明白为什么驱动会这样处理,按道理在pc机上都能识别出来两种格式,板子没道理只识别一种啊, ...

有可能是内核配置上缺少什么东西引起的。
回复

使用道具 举报

 楼主| changqiong0606 发表于 2012-12-3 18:59:38 | 显示全部楼层
亚瑟王 发表于 2012-12-3 18:50
有可能是内核配置上缺少什么东西引起的。

嗯,谢谢,我再查查看。希望早点解决
回复

使用道具 举报

 楼主| changqiong0606 发表于 2012-12-4 13:48:07 | 显示全部楼层
本帖最后由 changqiong0606 于 2012-12-6 22:23 编辑

还是有问题。
我重新配置了内核,添加了对V4L驱动支持(multimedia device),我使用的摄像头是奥尼品牌的,sonix主控芯片,0C45:6341型号;添加了对usb摄像头驱动模块支持(usb sopport),还有uvc相关。我现在还是怀疑配置哪里出了问题,还请各位看贴的大神指点指点,是不是还有哪些地方没有配置对?也给今后要用到相似摄像头的一个方向吧。
  --- V4L USB devices                                              │ │  
  │ │    <*>   USB Video Class (UVC)                                      │ │  
  │ │        UVC input events device support                          │ │  
  │ │    <*>   GSPCA based webcams  --->                                  │
sonix相关的只有这两个,我都选上了,
───────────────────────── GSPCA based webcams ──────────────────────────┐
  │  Arrow keys navigate the menu.  <Enter> selects submenus --->.          │  
  │  Highlighted letters are hotkeys.  Pressing <Y> includes, <N> excludes, │  
  │  <M> modularizes features.  Press <Esc><Esc> to exit, <?> for Help, </> │  
  │  for Search.  Legend: built-in  [ ] excluded  <M> module  < >       │  
  │ ┌────^(-)─────────────────────────────────────────────────────────────┐ │  
  │ │    < >   OV534 USB Camera Driver                                    │ │  
  │ │    < >   Pixart PAC207 USB Camera Driver                            │ │  
  │ │    < >   Pixart PAC7311 USB Camera Driver                           │ │  
  │ │    <*>   SONIX Bayer USB Camera Driver                              │ │  
  │ │    <*>   SONIX JPEG USB Camera Driver                               │

不知道是不是哪里还漏了呢??

这个是在pc机上测试的结果,可以看到是可以检测出MJPG和YUYV格式的,
root@ubuntu:/opt/App/test# ./test
video /dev/video0
/dev/video0 does not support read i/o
check_videoIn
{ pixelformat = 'MJPG', description = 'MJPEG' }
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 544, height = 288 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 432, height = 240 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 320, height = 176 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 752, height = 416 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 800, height = 448 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 800, height = 600 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 864, height = 480 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 960, height = 544 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 960, height = 720 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 1024, height = 576 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 1184, height = 656 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/10, 1/5,
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 544, height = 288 }
        Time interval between frame: 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 432, height = 240 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 320, height = 176 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/60, 1/30, 1/25, 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 752, height = 416 }
        Time interval between frame: 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 800, height = 448 }
        Time interval between frame: 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 864, height = 480 }
        Time interval between frame: 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 800, height = 600 }
        Time interval between frame: 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 960, height = 544 }
        Time interval between frame: 1/20, 1/15, 1/10, 1/5,
{ discrete: width = 1024, height = 576 }
        Time interval between frame: 1/15, 1/10, 1/5,
{ discrete: width = 960, height = 720 }
        Time interval between frame: 1/15, 1/10, 1/5,
{ discrete: width = 1184, height = 656 }
        Time interval between frame: 1/10, 1/5,
video /dev/video0

这个是在板子上(TQ2440)上的测试结果,可以看到只能检测到YUYV格式,
[root@EmbedSky /]# ./test                                                   
video /dev/video0                                                               
/dev/video0 does not support read i/o                                          
check_videoIn                                                                  
{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' ,fmt.index = 0}        
{ discrete: width = 320, height = 240 }                                         
        Time interval between frame: 1/5,                                       
{ discrete: width = 160, height = 120 }                                         
        Time interval between frame: 1/20, 1/15, 1/10, 1/5,                     
video /dev/video0                                                               
Width = 320                                                                     
Height = 240                                                                    
Image size = 153600                                                            
pixelformat = ''YUYV''                                                         
Current data format information:                                                
        width:320                                                               
        height:240                                                              
        format:YUV 4:2:2 (YUYV)                                                
not support format MJPG!                                                        
Unable to set format: 22.                                                      
Init v4L2 failed !! exit fatal                                               

pc机上能够正确查询出YUYV格式和MJPG格式,我认为内核驱动是支持的,只是在板子上的时候,可能还有某个驱动没有挂上,造成只能检测YUYV的结果。还望看到帖子的大神们指点一二,是什么问题?或是漏了哪里??谢谢诶
回复

使用道具 举报

TQ-ZQL 发表于 2012-12-6 09:43:57 | 显示全部楼层
老实说这个直接看驱动最实际了。
struct v4l2_ioctl_ops
这个结构体中的.vidioc_enum_fmt_vid_cap 成员
回复

使用道具 举报

 楼主| changqiong0606 发表于 2012-12-6 22:01:00 | 显示全部楼层
本帖最后由 changqiong0606 于 2012-12-6 22:02 编辑
TQ-ZQL 发表于 2012-12-6 09:43
老实说这个直接看驱动最实际了。
struct v4l2_ioctl_ops
这个结构体中的.vidioc_enum_fmt_vid_cap 成员

谢谢版主。今天查了一天的驱动,发现了一个有趣的问题。struct v4l2_ioctl_ops结构体中的.vidioc_enum_fmt_vid_cap 成员是一个完成查询摄像头输出格式的函数,include/media/V4L2-ioctl.h中定义该结构体,然后在不同摄像头类型的目录下实现函数,例如gspa摄像头在/drivers/media/video/gspca/gspca.c  实现函数体,au0828的摄像头在drivers\media\video\au0828\au0828-video.c中实现函数体,但是uvc摄像头却没有在/drivers/media/video/uvc 目录下找到该函数体!(这是为什么呢?)
该函数最后是在V4l2-ioctl.c (drivers\media\video\V4l2-ioctl.c中统一调用的,我试过配置内核时只选择uvc摄像头,结果也是只能查询到YUYV格式,说明是调用了该函数的,只是它调用的是哪个目录下的vidioc_enum_fmt_vid_cap函数呢?有点不好找。
回复

使用道具 举报

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

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2025-6-19 00:15 , Processed in 2.048728 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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