Camera | 1.Camera基础知识
Camera | 2.MIPI、CSI基础
Camera | 3.瑞芯微平台MIPI摄像头常用调试命令
【资料图】
Camera | 4.瑞芯微平台MIPI摄像头应用程序编写
Camera | 5.Linux v4l2架构(基于rk3568)
Camera | 6.v4l2拓扑架构(基于rk3568)
Camera | 7.瑞芯微rk3568平台摄像头控制器MIPI-CSI驱动架构梳理
本文主要目标是,支持前置摄像头0v5648、后置摄像头ov13850,以及移植过程遇到的一些小问题的解决。
参考上图,摄像头详细信息如下:
2个摄像头均连接在I2C通道42个摄像头共用同一个MIPI数据通道2个摄像头各自有独立的rst、pwdn引脚rkw提供的sdk中已经提供camera时钟的设备树信息,此处选择对应时钟即可ov13850用到4个lane,0v5648用到2个lane摄像头的片选通过select-gpios来选择,拉低选择0v13850,拉高选择ov5684根据上述摄像头硬件信息,设备树信息如下:
reg:该模块输入端点序号remot-endpoint :输出端点的名字,在下面设备树信息中列举出来data-lanes :数据通道信息在这里插入图片描述
rxw sdk中已经有这两个摄像头的驱动,但是需要增加片选的逻辑,
根据前面文章,
《Camera | 4.瑞芯微平台MIPI摄像头应用程序编写》
可知开启和关闭摄像头视频流通过以下命令:
VIDIOC_STREAMON,VIDIOC_STREAMOFF
对应的回调函数
staticintov5648_s_stream(structv4l2_subdev*sd,inton)
除此之外,power控制的回调函数
staticintov5648_s_power(structv4l2_subdev*sd,inton)
我们只需要在这对应的回调函数中增加select-gpio的操作即可。
所有修改代码如下:
+#include+#include+staticintselect_gpios;//前置摄像头使能staticintov5648_s_stream(structv4l2_subdev*sd,inton){……if(on){+gpio_direction_output(select_gpios,1);+usleep_range(1000,2000);……}else{……+gpio_direction_output(select_gpios,0);+usleep_range(1000,2000);}……}staticintov5648_s_power(structv4l2_subdev*sd,inton){……if(on){+gpio_direction_output(select_gpios,1);+usleep_range(1000,2000);……}else{+gpio_direction_output(select_gpios,0);……}……}staticvoid__ov5648_power_off(structov5648*ov5648){intret;structdevice*dev=&ov5648->client->dev;+gpio_direction_output(select_gpios,0);……}staticintov5648_probe(structi2c_client*client,……+structdevice_node*np;++np=dev->of_node;……+select_gpios=of_get_named_gpio(np,"select-gpios",0);++ret=gpio_request(select_gpios,"select-gpios");+if(ret<0){+dev_err(dev,"FailedtorequestGPIO:%d,ERRNO:%d",(s32)select_gpios,ret);+//returnret;+}+printk("ov5648select_gpios=%d",select_gpios);……
加载成功后查看拓扑结构,会有以下entity 信息:
-entity70:m01_f_ov56484-0036(1pad,1link)typeV4L2subdevsubtypeSensordevicenodename/dev/v4l-subdev3pad0:Source[fmt:SBGGR10/2592x1944]->"rockchip-csi2-dphy0":0[]-entity74:m00_b_ov138504-0010(1pad,1link)typeV4L2subdevsubtypeSensordevicenodename/dev/v4l-subdev4pad0:Source[fmt:SBGGR10/4224x3136]->"rockchip-csi2-dphy0":0[ENABLED]
说明pipe通路ok。
要让安卓识别前后置摄像头,还需要在以下文件增加后置摄像头ov13850、前置摄像头ov5684信息
@hardware/rockchip/camera/etc/camera/camera3_profiles.xml@hardware/rockchip/camera/etc/camera/camera3_profiles_rk356x.xml
在这两个xml文件中增加这两个摄像头信息即可,
一口君是按照其他摄像头内容修改的,
ov5684因为分辨率问题,需要注意不要超过最大值。
成功后,摄像头app界面会有切换的按钮出现
开机后用命令抓帧,用的是前置摄像头
打开app后,界面显示的是后置摄像头信息
但是点解界面的切换按钮,获取不到前置摄像头图像,
在不重启的情况下要操作后置摄像头,执行下面操作即可。
Settings->apps¬ificationsSEEALL16APPS选择最近应用CameraStorage&cache点击clearstorage然后退出重新打开摄像头APP即可
staticintov5648_s_stream(structv4l2_subdev*sd,inton){……on=!!on;printk("6902%s(%d)enter!%dn",__func__,__LINE__,on);if(on==ov5648->streaming)gotounlock_and_return;if(on){……}else{……}ov5648->streaming=on;}
发现切换的时候没有执行该函数,所以定位是APP测出了问题
03-0102:40:30.06216991749ICAM_Profiler:[67.906ms]GUARD:CaptureModule.openCameraAndStartPreview()-[67.565ms]mOneCameraOpener.open()03-0102:40:30.06216991749ICAM_Profiler:[67.906ms]GUARD:CaptureModule.openCameraAndStartPreview()-STOP03-0102:40:30.06316991741ECAM_OneCamFtrCnfgCrtr:Unknownsupportlevel:003-0102:40:30.06316991741ICAM_OneCamCreator:Camerasupportlevel:LIMITED_JPEG03-0102:40:30.06316991741WCAM_Log:TagSimpleOneCameraFactoryis3charslongerthanlimit.03-0102:40:30.06316991741ICAM_OneCamCreator:PictureSizeConfiguration:PictureSizeCalculator.Configuration{nativesize=3264x2448,crop=Rect(0,0-3264,2448)}03-0102:40:30.06516991741DCAM_CaptureModule:onCameraOpened:com.android.camera.one.v2.initialization.GenericOneCameraImpl@200eae903-0102:40:30.06516991741DCAM_CaptureModule:picturesize:3264x2448,previewBuffer:1280x96003-0102:40:30.06516991741DCAM_CaptureModule:startingpreview...03-0102:40:30.06816991699WCAM_IndicatorIconCtrlr:Tryingtosyncapanoindicatorthatisnotinitialized.03-0102:40:30.068349349WCameraDeviceClient:createSurfaceFromGbp:Camera1withconsumerusageflag:256:Forcingasynchronousmodeforstream03-0102:40:30.068349349WCameraDeviceClient:createSurfaceFromGbp:Camera1:Overridingformat0x1toIMPLEMENTATION_DEFINED03-0102:40:30.069265265DCamera3HAL:configure_streams:streamslistptr:0xf6242dd0,num203-0102:40:30.0702651812ERkCamera:RKISP2GraphConfig:@selectSensorOutputFormat:Appstreamsize(3264x2448)largerthanSensorfullsize(2592x1944),Checkcamera3_profiles.xml03-0102:40:30.0702651812ERkCamera:RKISP2GraphConfigManager:Couldn"tgetmediaCtlconfig03-0102:40:30.0702651812ERkCamera:V4L2Subdev:queryDvTimings,ret:-1,I:0,wxh:0x003-0102:40:30.0702651812ERkCamera:V4L2Subdev:VIDIOC_SUBDEV_QUERY_DV_TIMINGSfailed:Inappropriateioctlfordevice03-0102:40:30.0702651812ERkCamera:PlatformData:ErrorqueryDvTimingsret:-2147483648(/dev/v4l-subdev3)03-0102:40:30.0702651812ERkCamera:PlatformData:Errorclosingdevice(/dev/v4l-subdev3)03-0102:40:30.0702651812ERkCamera:RKISP2GraphConfig:getMediaDevInfoinfo.model:rkisp003-0102:40:30.0702651812ERkCamera:RKISP2GraphConfigManager:Couldn"tgetImgumediaCtlconfig03-0102:40:30.0702651812ERkCamera:RKISP2ImguUnit:Processingtaskscreationfailed(ret=-2147483648)03-0102:40:30.0702651812ERkCamera:RKISP2CameraHw:Unabletoconfigurestreamforimgunit03-0102:40:30.0702651812ERkCamera:RequestThread:Errorconfiguringthestreams@handleConfigureStreams:21303-0102:40:30.0702651812ERkCamera:RequestThread:error-2147483648inhandlingmessage:303-0102:40:30.071349349ECamera3-Device:Camera1:configureStreamsLocked:Setofrequestedinputs/outputsnotsupportedbyHAL03-0102:40:30.071349349ECameraDeviceClient:endConfigure:Camera1:Unsupportedsetofinputs/outputsprovided03-0102:40:30.07116991741WCameraDevice-JV-1:Streamconfigurationfaileddueto:endConfigure:505:Camera1:Unsupportedsetofinputs/outputsprovided03-0102:40:30.07216991741ECameraCaptureSession:Session0:Failedtocreatecapturesession;configurationfailed03-0102:40:30.07216991817ECAM_CaptureModule:Couldnotsetuppreview.03-0102:40:30.07916991699DCAM_LoggingImageReader:Closing:ImageReader{width=3264,height=2448,format=JPEG}03-0102:40:30.081349349ICamera3-Device:disconnectImpl:E03-0102:40:30.088349349ICamera3-Device:disconnectImpl:X03-0102:40:30.094349349ICameraService:disconnect:Disconnectedclientforcamera1forPID1699
其中:
03-0102:40:30.0702651812ERkCamera:RKISP2GraphConfig:@selectSensorOutputFormat:Appstreamsize(3264x2448)largerthanSensorfullsize(2592x1944),Checkcamera3_profiles.xml
提示分辨率不支持,
于是打开camera3_profiles.xml,将所有3264x2448修改为2592x1944
将下面几个属性所有关3264x2448的全部删除
2592*1944*1.5=5038848
修改xml文件
关键词:
Copyright 2000-2021 by www.jiaoyu.sdqnw.net all rights reserved
邮箱 : 39 60 291 42@qq.com