MIPI CSI 摄像头 接到开发板上 不会用....

JangSeo 2021-04-29 03:32:44
用mplayer 播下摄像头看看,出错啦,




也不知道是不是摄像头坏了,有大神可以指点指点怎么诊断下,
...全文
811 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yoveldf 2021-05-12
  • 打赏
  • 举报
回复
驱动支持吗?
r40_tinav2.1_最终验证通过_使用CB-S来验证OV5640有横条纹fpscamera+SPI2.0成功_20171114_1443没有外层目录.7z 开发板:CB-S 1、(可选修改/调试技巧:) 除了ov5640.c之外,其它的驱动都不编译,节省编译时间! W:\ov5640_spi20_r40t\lichee\linux-3.10\drivers\media\platform\sunxi-vfe\device\Makefile obj-m += ov5640.o #obj-m += ov2640.o #obj-m += ov7736.o #obj-m += s5k4ec.o #obj-m += s5k4ec_mipi.o #obj-m += gc2035.o #obj-m += gt2005.o #obj-m += gc0307.o #obj-m += gc0308.o #obj-m += gc0328.o #obj-m += gc0328c.o #obj-m += gc2145.o #obj-m += gc0329.o #obj-m += gc0311.o #obj-m += hi253.o #obj-m += sp2518.o #obj-m += sp2519.o #obj-m += sp0718.o #obj-m += sp0838.o #obj-m += ov16825.o #obj-m += ov5650.o #obj-m += ov5647.o #obj-m += ov5647_mipi.o #obj-m += t8et5.o #obj-m += s5k4e1.o #obj-m += s5k4e1_mipi.o #obj-m += sp2518.o #obj-m += sp0718.o #obj-m += gc5004.o #obj-m += gc5004_mipi.o #obj-m += ov5648.o #obj-m += ar0330.o #obj-m += ov5648.o #obj-m += sp5408.o #obj-m += ov12830.o #obj-m += ov8825.o #obj-m += ov8850.o #obj-m += gc2155.o #obj-m += ov8858.o #obj-m += ov13850.o #obj-m += imx214.o #obj-m += ov8858_4lane.o #obj-m += sp5409.o #obj-m += s5k5e2yx.o #obj-m += ov2710_mipi.o #obj-m += ov2686.o (这里是看ov5640的驱动的probe执行是否正确?设备ID是否读取成功!) W:\ov5640_spi20_r40t\lichee\linux-3.10\drivers\media\platform\sunxi-vfe\device\ov5640.c static int sensor_detect(struct v4l2_subdev *sd) { data_type rdval; printk("****wyb %s:%d/%s()! \n", __FILE__, __LINE__, __func__); LOG_ERR_RET(sensor_read(sd, 0x300a, &rdval;)) printk("****wyb %s:%d/%s()! 0x300a rdval=0xx\n", __FILE__, __LINE__, __func__, rdval); if(rdval != 0x56) return -ENODEV; LOG_ERR_RET(sensor_read(sd, 0x300b, &rdval;)) printk("****wyb %s:%d/%s()! 0x300b rdval=0xx\n", __FILE__, __LINE__, __func__, rdval); if(rdval != 0x40) return -ENODEV; return 0; } (在全志R16平台改过这个文件,让摄像头不要休眠,但是全志R40平台的tina v2.1系统下不需要修改!) W:\ov5640_spi20_r40t\lichee\linux-3.10\drivers\media\platform\sunxi-vfe\vfe.c 2、(可
R58点亮ov2640.txt 开发板:全志公板,全志R58(CPU:Octa-Core Cortex-A7 CPU) http://www.allwinnertech.com/clq/r/R58.html 全志官网R58的简介 android4.4.4/linux3.4.39 2016/6/30 9:36 1、配置ov2640在android层配置的分辨率为vga(预览/拍照/录像) 注意:系统自带的快拍APP就在这里查找分辨率参数发送到camera的HAL层。 cubieboard2开发板使用的是全志A20的CPU,自带两路CSI摄像头接口。 一般使用CSI1,所有生成的设备节点是/dev/video1。 一般情况下,MIPI为主摄像头(后置摄像头),那设备节点就是/dev/video0。 没有接MIPI摄像头,那就空出来,像全志A20那样配置成为了/dev/video1了。结果被坑了。 后来想起来: insmod /system/vendor/modules/ov2640.ko insmod /system/vendor/modules/vfe_v4l2.ko 手工加载vfe_v4l2.ko驱动模块之后,生成了设备节点/dev/video0。 赶紧修改为/dev/video0。然后使用adb push进去。 修改属性之后,摄像头还是不显示。重启之后正常了。这里折腾了好久!!!! R:\wyb\r58_bmi160_bma250_ov2640_dev\android\device\softwinner\octopus-f1\configs\camera.cfg ;------------------------------------------------------------------------------- ; 用于camera的配置 ; ; 采用格式: ; key = key_value ; 注意: 每个key需要顶格写; ; key_value紧跟着key后面的等号后面, 位于同一行中; ; key_value限制大小为256字节以内; ; ;------------------------------------------------------------------------------- ;------------------------------------------------------------------------------- ; exif information of "make" and "model" ;------------------------------------------------------------------------------- key_camera_exif_make = MAKE_AllWinner key_camera_exif_model = MODEL_f1 ;------------------------------------------------------------------------------- ; 1 for single camera, 2 for double camera ;------------------------------------------------------------------------------- number_of_camera = 1 ;------------------------------------------------------------------------------- ; CAMERA_FACING_BACK ; ov8858 ov2640 ;------------------------------------------------------------------------------- camera_id = 0 ;------------------------------------------------------------------------------- ; 1 for CAMERA_FACING_FRONT ; 0 for CAMERA_FACING_BACK ;------------------------------------------------------------------------------- camera_facing = 0 ;------------------------------------------------------------------------------- ; 1 for camera without isp(using built-in isp of Axx) ; 0 for camera with isp ;------------------------------------------------------------------------------- use_builtin_isp = 0 ;------------------------------------------------------------------------------- ; camera orientation (0, 90, 180, 270) ;------------------------------------------------------------------------------- camera_orientation = 90 ;------------------------------------------------------------------------------- ; driver device name ;------------------------------------------------------------------------------- camera_device = /dev/video0 ;------------------------------------------------------------------------------- ; device id ; for two camera devices with one CSI ;------------------------------------------------------------------------------- device_id = 0 used_preview_size = 1 key_support_preview_size = 640x480 key_default_preview_size = 640x480 used_picture_size = 1 key_support_picture_size = 640x480 key_default_picture_size = 640x480 used_flash_mode = 0 key_support_flash_mode = on,off,auto,red-eye,torch key_default_flash_mode = off used_color_effect=0 key_support_color_effect = none,mono,negative,sepia,aqua key_default_color_effect = none used_frame_rate = 1 key_support_frame_rate = 25 key_default_frame_rate = 25 used_focus_mode = 1 key_support_focus_mode = auto,infinity,macro,fixed key_default_focus_mode = auto ;used_scene_mode = 0 ;key_support_scene_mode = auto,action,portrait,landscape,night,night-portrait,theatre,beach,snow,sunset,steadyphoto,fireworks,sports,party,candlelight,barcode,hdr ;key_default_scene_mode = auto used_scene_mode = 1 key_support_scene_mode = auto,hdr key_default_scene_mode = auto used_white_balance = 1 key_support_white_balance = auto,incandescent,fluorescent,warm-fluorescent,daylight,cloudy-daylight key_default_white_balance = auto used_exposure_compensation = 1 key_max_exposure_compensation = 3 key_min_exposure_compensation = -3 key_step_exposure_compensation = 1 key_default_exposure_compensation = 0 used_zoom = 1 key_zoom_supported = true key_smooth_zoom_supported = false key_zoom_ratios = 100,120,150,200,230,250,300 key_max_zoom = 30 key_default_zoom = 0 key_horizonal_view_angle = 64 key_vertical_view_angle = 39.4 2、R:\wyb\r58_bmi160_bma250_ov2640_dev\android\device\softwinner\octopus-f1\hawkview\sensor_list_cfg.ini #A80 sensor list configs # ##################bus config###################### # #used: 0: not used, 1: used; #csi_sel: 0: mipi, 1: parallel ; #device_sel: 0: dev0, 1: dev1; #sensor_twi_id: twi id, for example: sensor_twi_id = 0 # ##################power configs################### #power_settings_enable: 0: enable the power settings in sysconfig.fex; 1: enable the power settings in this file. # #iovdd The name of iovdd for this camera; #iovdd_vol The voltage value of iovdd in uV; # ###############detect sensor configs############## # #detect_sensor_num: The number of sensors need be detected in this bus. #sensor_name[x]: The sensor name in sensor driver. #sensor_twi_addr[x]: The i2c address of this sensor. #sensor_type[x]: The sensor type, 0: YUV, 1: RAW; #sensor_stby_mode[x]: Not used; #sensor_hflip[x] Horizontal flip; #sensor_vflip[x] Vertical flip; #act_name[x] The VCM name in vcm driver, only RAW sensor need be configured; #act_twi_addr[x] The i2c address of this VCM; # ################################################## [rear_camera_cfg] #bus configs used = 1 csi_sel = 1 device_sel = 1 sensor_twi_id = 2 #power configs power_settings_enable = 0 iovdd = "axp22_aldo2" iovdd_vol = 2800000 avdd = "axp15_aldo2" avdd_vol = 2800000 dvdd = "axp22_eldo1" dvdd_vol = 1500000 afvdd = "" afvdd_vol = 2800000 #detect sensor configs detect_sensor_num = 1 sensor_name0 = "ov2640" sensor_twi_addr0 = 0x60 sensor_type0 = 0 sensor_stby_mode0 = 0 sensor_hflip0 = 0 sensor_vflip0 = 0 act_name0 = act_twi_addr0 = 3、在init.rc(init.sun8i.rc)中加载ov2640.ko这个驱动模块。 R:\wyb\r58_bmi160_bma250_ov2640_dev\android\device\softwinner\octopus-f1\init.sun8i.rc #csi module insmod /system/vendor/modules/videobuf-core.ko insmod /system/vendor/modules/videobuf-dma-contig.ko insmod /system/vendor/modules/cam_detect.ko insmod /system/vendor/modules/cci.ko #insmod /system/vendor/modules/actuator.ko insmod /system/vendor/modules/vfe_os.ko insmod /system/vendor/modules/vfe_subdev.ko #insmod /system/vendor/modules/actuator.ko #insmod /system/vendor/modules/dw9714_act.ko #insmod /system/vendor/modules/hi253.ko #insmod /system/vendor/modules/ov8858_4lane.ko insmod /system/vendor/modules/ov2640.ko insmod /system/vendor/modules/vfe_v4l2.ko 启动之后实际加载的摄像头的驱动模块: shell@octopus-f1:/ $ shell@octopus-f1:/ $ lsmod cdc_ether 3163 0 - Live 0x00000000 rtl8150 9023 0 - Live 0x00000000 mcs7830 5644 0 - Live 0x00000000 qf9700 5904 0 - Live 0x00000000 asix 13590 0 - Live 0x00000000 usbnet 14128 4 cdc_ether,mcs7830,qf9700,asix, Live 0x00000000 bcm_btlpm 7658 0 - Live 0x00000000 ltr_501als 10649 0 - Live 0x00000000 bma250 7988 0 - Live 0x00000000 sw_device 14680 0 - Live 0x00000000 sunxi_schw 13015 0 - Live 0x00000000 (O) vfe_v4l2 786415 1 - Live 0x00000000 ov2640 14830 0 - Live 0x00000000 vfe_subdev 4695 2 vfe_v4l2,ov2640, Live 0x00000000 vfe_os 4113 2 vfe_v4l2,vfe_subdev, Live 0x00000000 cci 22800 2 vfe_v4l2,ov2640, Live 0x00000000 videobuf_dma_contig 4165 1 vfe_v4l2, Live 0x00000000 videobuf_core 16528 2 vfe_v4l2,videobuf_dma_contig, Live 0x00000000 pvrsrvkm 279691 38 - Live 0x00000000 (O) hdmi 38647 0 - Live 0x00000000 disp 1023342 6 hdmi, Live 0x00000000 sunxi_tr 9348 1 disp, Live 0x00000000 nand 299887 0 - Live 0x00000000 (O) shell@octopus-f1:/ $ 4、驱动程序:ov2640.c及其V4L2的适配层。 配置ov5640.c的编译选项,默认已经配置好,不用修改: R:\wyb\r58_bmi160_bma250_ov2640_dev\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\ov2640.c R:\wyb\r58_bmi160_bma250_ov2640_dev\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\Makefile obj-m += ov5640.o R:\wyb\r58_bmi160_bma250_ov2640_dev\lichee\linux-3.4\drivers\media\video\sunxi-vfe\Kconfig 5、 R:\wyb\r58_bmi160_bma250_ov2640_dev\lichee\tools\pack\chips\sun8iw6p1\configs\f1\sys_config.fex ;-------------------------------------------------------------------------------- ;vip (video input port) configuration ;vip_used: 0:disable 1:enable ;vip_mode: 0:sample one interface to one buffer 1:sample two interface to one buffer ;vip_dev_qty: The quantity of devices linked to capture bus ; ;vip_define_sensor_list: If you want use sensor detect function, please set vip_define_sensor_list = 1, and ; verify that file /system/etc/hawkview/sensor_list_cfg.ini is properly configured! ; ;vip_dev(x)_pos: sensor position, "rear" or "front", if vip_define_sensor_list = 1, ;vip_dev(x)_pos must be configured! ; ;vip_dev(x)_isp_used 0:not use isp 1:use isp ;vip_dev(x)_fmt: 0:yuv 1:bayer raw rgb ;vip_dev(x)_stby_mode: 0:not shut down power at standby 1:shut down power at standby ;vip_dev(x)_vflip: flip in vertical direction 0:disable 1:enable ;vip_dev(x)_hflip: flip in horizontal direction 0:disable 1:enable ;vip_dev(x)_iovdd: camera module io power handle string, pmu power supply ;vip_dev(x)_iovdd_vol: camera module io power voltage, pmu power supply ;vip_dev(x)_avdd: camera module analog power handle string, pmu power supply ;vip_dev(x)_avdd_vol: camera module analog power voltage, pmu power supply ;vip_dev(x)_dvdd: camera module core power handle string, pmu power supply ;vip_dev(x)_dvdd_vol: camera module core power voltage, pmu power supply ;vip_dev(x)_afvdd: camera module vcm power handle string, pmu power supply ;vip_dev(x)_afvdd_vol: camera module vcm power voltage, pmu power supply ;x indicates the index of the devices which are linked to the same capture bus ;fill voltage in uV, e.g. iovdd = 2.8V, vip_devx_iovdd_vol = 2800000 ;fill handle string as below: ;axp22_eldo3 ;axp22_dldo4 ;axp22_eldo2 ;fill handle string "" when not using any pmu power supply ;-------------------------------------------------------------------------------- [csi0] vip_used = 1 vip_mode = 0 vip_dev_qty = 1 vip_define_sensor_list = 0 vip_csi_pck = port:PE00 vip_csi_mck = port:PE01 vip_csi_hsync = port:PE02 vip_csi_vsync = port:PE03 vip_csi_d0 = vip_csi_d1 = vip_csi_d2 = port:PE06 vip_csi_d3 = port:PE07 vip_csi_d4 = port:PE08 vip_csi_d5 = port:PE09 vip_csi_d6 = port:PE10 vip_csi_d7 = port:PE11 vip_csi_d8 = port:PE12 vip_csi_d9 = port:PE13 vip_csi_sck = port:PE14 vip_csi_sda = port:PE15 vip_dev0_mname = "ov2640" vip_dev0_pos = "rear" vip_dev0_lane = 1 vip_dev0_twi_id = 2 vip_dev0_twi_addr = 0x60 vip_dev0_isp_used = 0 vip_dev0_fmt = 0 vip_dev0_stby_mode = 0 vip_dev0_vflip = 0 vip_dev0_hflip = 0 vip_dev0_iovdd = "" vip_dev0_iovdd_vol = 2800000 vip_dev0_avdd = "" vip_dev0_avdd_vol = 2800000 vip_dev0_dvdd = "" vip_dev0_dvdd_vol = 1500000 vip_dev0_afvdd = "" vip_dev0_afvdd_vol = 2800000 vip_dev0_power_en = vip_dev0_reset = port:PE4 vip_dev0_pwdn = port:PE5 vip_dev0_flash_en = vip_dev0_flash_mode = vip_dev0_af_pwdn = 6、开发板摄像头的I2C挂载在TWI2上面了,注意打开: ;---------------------------------------------------------------------------------- ;i2c configuration ;---------------------------------------------------------------------------------- [twi0] twi_used = 1 twi_scl = port:PH0 twi_sda = port:PH1 [twi1] twi_used = 1 twi_scl = port:PH2 twi_sda = port:PH3 [twi2] twi_used = 1 twi_scl = port:PH4 twi_sda = port:PH5 不过奇怪的是,摄像头并没有向其它平台那样生成这个设备节点: /sys/class/i2c-adapter/i2c-2/2-0030 shell@octopus-f1:/ $ shell@octopus-f1:/ $ cd /sys/class/i2c-adapter/i2c-2/ shell@octopus-f1:/sys/class/i2c-adapter/i2c-2 $ shell@octopus-f1:/sys/class/i2c-adapter/i2c-2 $ ll drwxr-xr-x root root 1970-01-02 08:06 2-003b --w------- root root 4096 1970-01-02 08:06 delete_device lrwxrwxrwx root root 1970-01-02 08:06 device -> ../../twi.2 -r--r--r-- root root 4096 1970-01-02 08:06 name --w------- root root 4096 1970-01-02 08:06 new_device drwxr-xr-x root root 1970-01-02 08:06 power lrwxrwxrwx root root 1970-01-02 08:06 subsystem -> ../../../../bus/i2c -rw-r--r-- root root 4096 1970-01-02 08:06 uevent shell@octopus-f1:/sys/class/i2c-adapter/i2c-2 $ 可能是ov2640的驱动程序不完整,没有通过i2c_detect来注册2-0030这个节点。 直接在驱动程序中读取I2C,还是对的。device ID = 0x2642。
全志R16平台的tinav2.0系统下调通HM1375 2017/8/24 14:04 开发板:SC3817R OS:tina V2.0 1、最新的驱动程序请直接联系HiMax原厂/代理商! R:\wyb\thl_r16_tinav2.0_hm1375\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\hm1375.c 2、 R:\wyb\thl_r16_tinav2.0_hm1375\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\Makefile EXTRA_LDFLAGS += --strip-debug ifneq ($(strip $(CONFIG_ARCH_SUN8IW8)),) obj-$(CONFIG_OV2710_MIPI)+= ov2710_mipi.o obj-$(CONFIG_OV4689)+= ov4689.o obj-$(CONFIG_OV4689_60FPS)+= ov4689_60fps.o obj-$(CONFIG_AR0330_MIPI)+= ar0330_mipi.o obj-$(CONFIG_OV4689_SDV)+= ov4689_sdv.o obj-$(CONFIG_GC1004_MIPI)+= gc1004_mipi.o obj-$(CONFIG_H22_MIPI)+= h22_mipi.o obj-$(CONFIG_NT99231_MIPI)+= nt99231_mipi.o else obj-m+= hm1375.o #obj-m+= ov5640.o #obj-m+= ov2640.o #obj-m+= ov7736.o #obj-m+= s5k4ec.o #obj-m+= s5k4ec_mipi.o #obj-m+= gc2035.o #obj-m+= gt2005.o #obj-m+= gc0307.o #obj-m+= gc0308.o #obj-m+= gc0328.o #obj-m+= gc0328c.o #obj-m+= gc0329.o #obj-m+= gc0311.o #obj-m+= hi253.o #obj-m+= sp2518.o #obj-m+= sp2519.o #obj-m+= sp0718.o #obj-m+= sp0838.o #obj-m+= ov16825.o #obj-m+= ov5650.o #obj-m+= ov5647.o #obj-m+= ov5647_mipi.o #obj-m+= t8et5.o #obj-m+= s5k4e1.o #obj-m+= s5k4e1_mipi.o #obj-m+= sp2518.o #obj-m+= sp0718.o #obj-m+= gc5004.o #obj-m+= gc5004_mipi.o #obj-m+= ov5648.o #obj-m+= ar0330.o #obj-m+= ov5648.o #obj-m+= sp5408.o #obj-m+= ov12830.o #obj-m+= ov8825.o #obj-m+= ov8850.o #obj-m+= gc2155.o #obj-m+= gc2145.o #obj-m+= gc2145d.o #obj-m+= ov8858.o #obj-m+= ov13850.o #obj-m+= imx214.o #obj-m+= ov8858_4lane.o #obj-m+= sp5409.o #obj-m+= s5k5e2yx.o #obj-m+= ov2710_mipi.o #obj-m+= siv121d.o #obj-m+= ov2710_mipi.o #obj-m+= bg0703.o #obj-m+= gc1014_mipi.o #obj-m+= imx219.o #obj-m+= imx224.o #obj-m+= imx322.o #obj-m+= ov8858_r2a_4lane.o #obj-m+= ov8865_4lane.o #obj-m+= ps1210.o #obj-m+= imx291.o endif 3、让tinav2.0启动之后不让摄像头camera休眠: R:\wyb\thl_r16_tinav2.0_hm1375\lichee\linux-3.4\drivers\media\video\sunxi-vfe\vfe.c static void probe_work_handle(struct work_struct *work) { struct vfe_dev *dev= container_of(work, struct vfe_dev, probe_work.work); int ret = 0; int input_num; int device_valid_count = 0; struct video_device *vfd; char vfe_name[16] = {0}; mutex_lock(&probe_hdl_lock); vfe_print("probe_work_handle start!\n"); vfe_dbg(0,"v4l2_device_register\n"); #ifdef USE_SPECIFIC_CCI vfe_clk_open(dev); #endif /* v4l2 device register */ ret = v4l2_device_register(&dev->pdev->dev, &dev->v4l2_dev); if (ret) { vfe_err("Error registering v4l2 device\n"); goto probe_hdl_free_dev; } dev_set_drvdata(&dev->pdev->dev, (dev)); vfe_dbg(0,"v4l2 subdev register\n"); /* v4l2 subdev register */ dev->is_same_module = 0; for(input_num=0; input_numdev_qty; input_num++) { vfe_print("v4l2 subdev register input_num = %d\n",input_num); if(!strcmp(dev->ccm_cfg[input_num]->ccm,"")) { vfe_err("Sensor name is NULL!\n"); goto snesor_register_end; } if(dev->is_same_module) { dev->ccm_cfg[input_num]->sd = dev->ccm_cfg[input_num-1]->sd; vfe_dbg(0,"num = %d , sd_0 = %p,sd_1 = %p\n",input_num,dev->ccm_cfg[input_num]->sd,dev->ccm_cfg[input_num-1]->sd); goto snesor_register_end; } if((dev->dev_qty > 1) && (input_num+1dev_qty)) { if((!strcmp(dev->ccm_cfg[input_num]->ccm,dev->ccm_cfg[input_num+1]->ccm))) dev->is_same_module = 1; } if(dev->vip_define_sensor_list == 1) { if(dev->ccm_cfg[input_num]->sensor_cfg_ini->power_settings_enable == 1) { cpy_ccm_power_settings(dev->ccm_cfg[input_num]); } } #ifdef _REGULATOR_CHANGE_ #else if(vfe_device_regulator_get(dev->ccm_cfg[input_num])) { vfe_err("vfe_device_regulator_get error at input_num = %d\n",input_num); goto snesor_register_end; } #endif vfe_print("vfe sensor detect start! input_num = %d\n",input_num); dev->input = input_num; if(vfe_sensor_register_check(dev,&dev->v4l2_dev,dev->ccm_cfg[input_num],&dev->dev_sensor[input_num],input_num) == NULL) { vfe_err("vfe sensor register check error at input_num = %d\n",input_num); dev->device_valid_flag[input_num] = 0; //goto snesor_register_end; } else{ dev->device_valid_flag[input_num] = 1; device_valid_count ++; } if(dev->ccm_cfg[input_num]->is_isp_used && dev->ccm_cfg[input_num]->is_bayer_raw) { if(read_ini_info(dev,input_num, "/system/etc/hawkview/")) { vfe_warn("read ini info fail\n"); } } if(dev->ccm_cfg[input_num]->act_used == 1) { dev->dev_act[input_num].addr = (unsigned short)(dev->ccm_cfg[input_num]->act_slave>>1); strcpy(dev->dev_act[input_num].type,dev->ccm_cfg[input_num]->act_name); if(vfe_actuator_subdev_register(dev,dev->ccm_cfg[input_num], &dev->dev_act[input_num]) != 0) ;//goto probe_hdl_free_dev; } snesor_register_end: vfe_dbg(0,"dev->ccm_cfg[%d] = %p\n",input_num,dev->ccm_cfg[input_num]); vfe_dbg(0,"dev->ccm_cfg[%d]->sd = %p\n",input_num,dev->ccm_cfg[input_num]->sd); vfe_dbg(0,"dev->ccm_cfg[%d]->power.iovdd = %p\n",input_num,dev->ccm_cfg[input_num]->power.iovdd); vfe_dbg(0,"dev->ccm_cfg[%d]->power.avdd = %p\n",input_num,dev->ccm_cfg[input_num]->power.avdd); vfe_dbg(0,"dev->ccm_cfg[%d]->power.dvdd = %p\n",input_num,dev->ccm_cfg[input_num]->power.dvdd); vfe_dbg(0,"dev->ccm_cfg[%d]->power.afvdd = %p\n",input_num,dev->ccm_cfg[input_num]->power.afvdd); } dev->input = -1; /*video device register */ ret = -ENOMEM; vfd = video_device_alloc(); if (!vfd) { goto probe_hdl_unreg_dev; } *vfd = vfe_template[dev->id]; vfd->v4l2_dev = &dev->v4l2_dev; sprintf(vfe_name,"vfe-%d",dev->id); dev_set_name(&vfd->dev, vfe_name); if (0 != device_valid_count) { ret = video_register_device(vfd, VFL_TYPE_GRABBER, dev->id); if (ret < 0) { goto probe_hdl_rel_vdev; } } video_set_drvdata(vfd, dev); /*add device list*/ /* Now that everything is fine, let's add it to device list */ list_add_tail(&dev->devlist, &devlist); dev->vfd = vfd; vfe_print("V4L2 device registered as %s\n",video_device_node_name(vfd)); /*initial video buffer queue*/ videobuf_queue_dma_contig_init(&dev->vb_vidq, &vfe_video_qops, NULL, &dev->slock, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE,//default format, can be changed by s_fmt sizeof(struct vfe_buffer), dev,NULL); ret = sysfs_create_group(&dev->pdev->dev.kobj, &vfe_attribute_group); #ifdef CONFIG_ES dev->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1; dev->early_suspend.suspend = vfe_early_suspend; dev->early_suspend.resume = vfe_late_resume; // [hawkview_err]xxxxcan't open /dev/video0(Resource temporarily unavailable) // 2016/10/25 14:33 wenyuanbo cloase suspend. // register_early_suspend(&dev->early_suspend); vfe_print("register_early_suspend @ probe handle!\n"); #endif #ifdef USE_SPECIFIC_CCI vfe_clk_close(dev); #endif vfe_print("probe_work_handle end!\n"); mutex_unlock(&probe_hdl_lock); return ; probe_hdl_rel_vdev: video_device_release(vfd); vfe_print("video_device_release @ probe_hdl!\n"); probe_hdl_unreg_dev: vfe_print("v4l2_device_unregister @ probe_hdl!\n"); v4l2_device_unregister(&dev->v4l2_dev); probe_hdl_free_dev: vfe_print("vfe_resource_release @ probe_hdl!\n"); #ifdef USE_SPECIFIC_CCI csi_cci_exit_helper(dev->cci_sel); vfe_clk_close(dev); #endif //vfe_resource_release(dev); vfe_err("Failed to install at probe handle\n"); mutex_unlock(&probe_hdl_lock); return ; } 4、 R:\wyb\thl_r16_tinav2.0_hm1375\package\allwinner\cameratest\src\common\hawkview.c int fetch_sub_cmd(const char* buf,int buf_len,char** cmd,int* cmd_num,int lenght) { int i = 0,j = 0,n = 0; while(buf[i] != '#'){ //the sub cmd end by '#' while(buf[i] != 'x' && buf[i] != ':' && buf[i] != '#') { if((i+1) > buf_len) return 0; 修改为: if(i++ > buf_len) return 0; *((char*)cmd + n*lenght + j++) = buf[i++]; if(j > lenght) { hv_err("sub cmd over long\n"); *cmd_num = n + 1; return -1; } } *((char*)cmd + n*lenght + j++) = '\0'; n++; j = 0; if(buf[i] != '#'){ i++; } if(n > *cmd_num){ hv_err("the max cmd num is %d\n",*cmd_num); return -1; } } *cmd_num = n; return 0; } R:\wyb\thl_r16_tinav2.0_hm1375\package\allwinner\cameratest\src\common\video.c static int capture_frame(void* capture,int (*set_disp_addr)(int,int,unsigned int*),pthread_mutex_t* mutex) { capture_handle* cap = (capture_handle*)capture; int ret; int i; struct v4l2_buffer buf; enum v4l2_buf_type type; fd_set fds; struct timeval tv; pthread_mutex_lock(mutex); //used for cammand and status debug if (old_vi_cmd != cap->cmd){ hv_dbg("capture frame command %d --> %d\n",old_vi_cmd,cap->cmd); old_vi_cmd = (int)cap->cmd; } if(old_status != cap->status){ hv_dbg("capture frame status %d --> %d\n",old_status,cap->status); old_status = cap->status; } if(cap->status == OFF && cap->cmd == START_STREAMMING){ hv_dbg("capture start streaming\n"); type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (ioctl(videofh, VIDIOC_STREAMON, &type) == -1) { hv_err("VIDIOC_STREAMON error! %s\n",strerror(errno)); goto quit; } cap->status = ON; cap->cmd = COMMAND_UNUSED; pthread_mutex_unlock(mutex); return 0; } if(cap->status == ON && cap->cmd == STOP_STREAMMING){ hv_dbg("capture stop streaming\n"); type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if(-1 == ioctl(videofh, VIDIOC_STREAMOFF, &type)){ hv_err("VIDIOC_STREAMOFF error! %s\n",strerror(errno)); goto quit; } cap->status = OFF; cap->cmd = COMMAND_UNUSED; capture_quit(capture); pthread_mutex_unlock(mutex); return 2; } if(cap->status == OFF) { pthread_mutex_unlock(mutex); return 0; } FD_ZERO(&fds); FD_SET(videofh, &fds); tv.tv_sec = 2; tv.tv_usec = 0; pthread_mutex_unlock(mutex); ret = select(videofh + 1, &fds, NULL, NULL, &tv); pthread_mutex_lock(mutex); //hv_dbg("select video ret: %d\n",ret); if (ret == -1) { if (errno == EINTR) { return 0; } hv_err("select error\n"); goto stream_off; } else if (ret == 0) { hv_err("select timeout\n"); pthread_mutex_unlock(mutex); return 0; } memset(&buf, 0, sizeof(struct v4l2_buffer)); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; ret = ioctl(videofh, VIDIOC_DQBUF, &buf); if (ret == -1) { hv_err("VIDIOC_DQBUF failed!\n"); goto stream_off; } float framerate; framerate = get_framerate((long long)(buf.timestamp.tv_sec),(long long)(buf.timestamp.tv_usec)); if(framerate > 1.0){ cap->cap_fps = framerate; //hv_dbg("framerate: %0.2ffps\n",cap->cap_fps); } //sync capture info perp x second #define M_SECOND 200 if(is_x_msec(M_SECOND,(long long)(buf.timestamp.tv_sec),(long long)(buf.timestamp.tv_usec))){ getExifInfo(&(cap->frame.exif)); set_cap_info((void*)cap); 修改为: // set_cap_info((void*)cap); } if(cap->cmd == STOP_SAVE_FRAME && cap->save_status == ON) cap->save_status = OFF; //save frame , the frame will be get by PC Tool to preview on PC screen //frame format: /dev/frame_x (x:0~21) if(cap->cmd == SAVE_FRAME || cap->save_status == ON ) { if(cap->cmd == SAVE_FRAME){ cap->save_status = ON; cap->cmd = COMMAND_UNUSED; } ret = do_save_frame(capture,buf.index); } //take yuv image,it will save the target frame exif info in the same time //image name: xxxx (set by usered through command) //exif info name: xxxx.exif if(cap->cmd == SAVE_IMAGE ) { ret = 0;//getExifInfo(&(cap->picture.exif)); //get target frame exif info successfully then save the target image //if get the exif info fail,it will try next frame if(ret == 0){ buffers[buf.index].phy_addr = buf.m.offset - 0x20000000; hv_dbg("index: %d buffers[buf.index].start = %p\n",buf.index,buffers[buf.index].start); //do_save_image(capture,buf.index); do_save_sub_image(capture,buf.index); cap->cmd = COMMAND_UNUSED; } } //get display addr int w,h; unsigned int addr; get_disp_addr(capture, buf.m.offset,&addr,&w,&h); // set disp buffer if (set_disp_addr){ set_disp_addr(w,h,&addr); } ret = ioctl(videofh, VIDIOC_QBUF, &buf); if (ret == -1) { hv_err("VIDIOC_DQBUF failed!\n"); goto stream_off; } pthread_mutex_unlock(mutex); return 0; stream_off: hv_err("err stream off\n"); ioctl(videofh, VIDIOC_STREAMOFF, &type); quit: capture_quit(capture); pthread_mutex_unlock(mutex); return -1; } R:\wyb\thl_r16_tinav2.0_hm1375\package\allwinner\cameratest\src\common\video_helper.c int set_cap_info(void* capture) { char info[500]; char exif[500]; char file_path[20]; capture_handle* cap = (capture_handle*)capture; memset(info,0,sizeof(info)); strcpy(file_path,"dev/info"); 修改为: //strcpy(file_path, "dev/info"); sprintf(file_path, "%s/%s.info", PATH, cap->picture.path_name); //sync string: sensor_type:save_status:framrate:capture_w:capture_h,sub_w,sub_h# sprintf(info, \ "sensor_type = %s\n" \ "status = %d\n" \ "framerate = %0.2f\n" \ "subchanel_width = %d\n" \ "subchanel_height = %d\n" \ "rotation = %d\n\n", \ (cap->sensor_type == 1)?"raw":"yuv", \ cap->save_status, \ cap->cap_fps, \ cap->sub_w, \ cap->sub_h, \ cap->sub_rot); make_exif_info(exif,"none",&(cap->frame.exif),cap->cap_w,cap->cap_h); strcat(info,exif); //hv_dbg("info str:\n%s\n",info); return write_file(file_path,info,sizeof(info)); } int do_save_sub_image(void* capture,int buf_index) { int ret; char image_name[30]; capture_handle* cap = (capture_handle*)capture; memset(image_name,0,sizeof(image_name)); sprintf(image_name,"%s/%s", PATH,cap->picture.path_name); hv_dbg("image_name: %s\n",image_name); (建议增加这里) set_cap_info(capture); set_exif_info(capture); hv_dbg("--------set_exif_info end\n"); void* vir_sub_start = NULL; unsigned int phy_sub_start = 0; int w,h; if(cap->sensor_type == V4L2_SENSOR_TYPE_RAW){ vir_sub_start = (unsigned int)(buffers[buf_index].start) + ALIGN_4K(ALIGN_16B(cap->cap_w) * cap->cap_h * 3 >> 1); phy_sub_start = buffers[buf_index].phy_addr + ALIGN_4K(ALIGN_16B(cap->cap_w) * cap->cap_h * 3 >> 1); w = cap->sub_w; h = cap->sub_h; } else { vir_sub_start = buffers[buf_index].start; phy_sub_start = buffers[buf_index].phy_addr; w = cap->cap_w; h = cap->cap_h; } #ifdef ANDROID_ENV ret = save_jpeg_frame(image_name,phy_sub_start,w,h); //sprintf(image_name,"/data/camera/yuv%s", cap->picture.path_name); //ret = save_jpeg_frame_by_viraddr(image_name,(void*)vir_sub_start,cap->sub_w,cap->sub_h); #else sprintf(image_name,"%s/yuv%s", PATH,cap->picture.path_name); ret = save_frame_to_file(image_name, \ (void*)(vir_sub_start), \ w,h,cap->cap_fmt, \ 1); #endif if(ret == -1) hv_err("save image failed!\n"); return 0; } 5、可选增加fpscamera: R:\wyb\thl_r16_tinav2.0_hm1375\package\allwinner\fpscamera 6、 define KernelPackage/sunxi-vfe SUBMENU:=$(VIDEO_MENU) TITLE:=sunxi-vfe support FILES:=$(LINUX_DIR)/drivers/media/video/videobuf-core.ko FILES+=$(LINUX_DIR)/drivers/media/video/videobuf-dma-contig.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/csi_cci/cci.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_os.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_subdev.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/device/gc0308.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_v4l2.ko AUTOLOAD:=$(call AutoLoad,90,videobuf-core videobuf-dma-contig cci vfe_os vfe_subdev gc0308 vfe_v4l2) endef 修改为: define KernelPackage/sunxi-vfe SUBMENU:=$(VIDEO_MENU) TITLE:=sunxi-vfe support FILES:=$(LINUX_DIR)/drivers/media/video/videobuf-core.ko FILES+=$(LINUX_DIR)/drivers/media/video/videobuf-dma-contig.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/csi_cci/cci.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_os.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_subdev.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/device/hm1375.ko FILES+=$(LINUX_DIR)/drivers/media/video/sunxi-vfe/vfe_v4l2.ko AUTOLOAD:=$(call AutoLoad,90,videobuf-core videobuf-dma-contig cci vfe_os vfe_subdev hm1375 vfe_v4l2) endef 7、 R:\wyb\thl_r16_tinav2.0_hm1375\target\allwinner\astar-parrot\configs\sys_config.fex ;---------------------------------------------------------------------------------- ;dcdc1_vol ---set dcdc1 voltage,mV,1600-3400,100mV/step ;dcdc2_vol ---set dcdc2 voltage,mV,600-1540,20mV/step ;dcdc3_vol ---set dcdc3 voltage,mV,600-1860,20mV/step ;dcdc4_vol ---set dcdc4 voltage,mV,600-1540,20mV/step ;dcdc5_vol ---set dcdc5 voltage,mV,1000-2550,50mV/step ;aldo2_vol ---set aldo2 voltage,mV,700-3300,100mV/step ;aldo3_vol ---set aldo3 voltage,mV,700-3300,100mV/step ;---------------------------------------------------------------------------------- [power_sply] dcdc1_vol = 3000 dcdc2_vol = 1100 dcdc3_vol = 1200 dcdc4_vol = 0 dcdc5_vol = 1500 aldo2_vol = 2500 aldo3_vol = 3000 dldo3_vol = 2800 ;gpio0_vol = 2800 ldoio0_vol = 2800 [twi2] twi_used = 1 twi_scl = port:PE12<3> twi_sda = port:PE13<3> ;-------------------------------------------------------------------------------- ;vip (video input port) configuration ;vip_used: 0:disable 1:enable ;vip_mode: 0:sample one interface to one buffer 1:sample two interface to one buffer ;vip_dev_qty: The quantity of devices linked to capture bus ; ;vip_define_sensor_list: If you want use sensor detect function, please set vip_define_sensor_list = 1, and ; verify that file /system/etc/hawkview/sensor_list_cfg.ini is properly configured! ; ;vip_dev(x)_pos: sensor position, "rear" or "front", if vip_define_sensor_list = 1,vip_dev(x)_pos must be configured! ; ;vip_dev(x)_isp_used 0:not use isp 1:use isp ;vip_dev(x)_fmt: 0:yuv 1:bayer raw rgb ;vip_dev(x)_stby_mode: 0:not shut down power at standby 1:shut down power at standby ;vip_dev(x)_vflip: flip in vertical direction 0:disable 1:enable ;vip_dev(x)_hflip: flip in horizontal direction 0:disable 1:enable ;vip_dev(x)_iovdd: camera module io power handle string, pmu power supply ;vip_dev(x)_iovdd_vol: camera module io power voltage, pmu power supply ;vip_dev(x)_avdd: camera module analog power handle string, pmu power supply ;vip_dev(x)_avdd_vol: camera module analog power voltage, pmu power supply ;vip_dev(x)_dvdd: camera module core power handle string, pmu power supply ;vip_dev(x)_dvdd_vol: camera module core power voltage, pmu power supply ;vip_dev(x)_afvdd: camera module vcm power handle string, pmu power supply ;vip_dev(x)_afvdd_vol: camera module vcm power voltage, pmu power supply ;x indicates the index of the devices which are linked to the same capture bus ;fill voltage in uV, e.g. iovdd = 2.8V, vip_devx_iovdd_vol = 2800000 ;fill handle string as below: ;axp22_eldo3 ;axp22_dldo4 ;axp22_eldo2 ;fill handle string "" when not using any pmu power supply ;-------------------------------------------------------------------------------- [csi0] vip_used = 1 vip_mode = 0 vip_dev_qty = 1 vip_define_sensor_list = 0 vip_csi_pck = port:PE00<2> vip_csi_mck = port:PE01<2> vip_csi_hsync = port:PE02<2> vip_csi_vsync = port:PE03<2> vip_csi_d0 = port:PE04<2> vip_csi_d1 = port:PE05<2> vip_csi_d2 = port:PE06<2> vip_csi_d3 = port:PE07<2> vip_csi_d4 = port:PE08<2> vip_csi_d5 = port:PE09<2> vip_csi_d6 = port:PE10<2> vip_csi_d7 = port:PE11<2> ;vip_csi_sck = port:PE12<2> ;vip_csi_sda = port:PE13<2> vip_dev0_mname = "hm1375" vip_dev0_pos = "rear" vip_dev0_lane = 1 vip_dev0_twi_id = 2 vip_dev0_twi_addr = 0x48 vip_dev0_isp_used = 0 vip_dev0_fmt = 0 (调试的时候推荐选0,给摄像头时钟供电,方便测量电压:) vip_dev0_stby_mode = 0 vip_dev0_vflip = 0 vip_dev0_hflip = 0 vip_dev0_iovdd = "" vip_dev0_iovdd_vol = 2800000 vip_dev0_avdd = "axp22_ldoio0" vip_dev0_avdd_vol = 2800000 vip_dev0_dvdd = "" vip_dev0_dvdd_vol = 1800000 vip_dev0_afvdd = "" vip_dev0_afvdd_vol = 2800000 vip_dev0_power_en = vip_dev0_reset = port:PE14<1><0> vip_dev0_pwdn = port:PE15<1><1> vip_dev0_flash_en = vip_dev0_flash_mode = vip_dev0_af_pwdn = 8、可选: rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ make menuconfig 内核的修改保存在这里: R:\wyb\thl_r16_tinav2.0_hm1375\target\allwinner\astar-parrot\config-3.4 rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ make menuconfig 系统的修改保存在这里: R:\wyb\thl_r16_tinav2.0_hm1375\target\allwinner\astar-parrot\defconfig 9、为了调试方便,可选修改: R:\wyb\thl_r16_tinav2.0_hm1375\target\allwinner\generic\configs\env.cfg bootdelay=3 #default bootcmd, will change at runtime according to key press bootcmd=run setargs_nand boot_normal#default nand boot #kernel command arguments console=ttyS0,115200 nor_root=/dev/mtdblock4 nand_root=/dev/nandd mmc_root=/dev/mmcblk0p7 init=/sbin/init loglevel=8 #set kernel cmdline if boot.img or recovery.img has no cmdline we will use this setargs_nor=setenv bootargs console=${console} root=${nor_root} rootwait init=${init} ion_cma_list="8m,32m,64m,128m,256m"loglevel=${loglevel} partitions=${partitions} setargs_nand=setenv bootargs console=${console} root=${nand_root} rootwait init=${init} ion_cma_list="8m,32m,64m,128m,256m" loglevel=${loglevel} partitions=${partitions} setargs_mmc=setenv bootargs console=${console} root=${mmc_root} rootwait init=${init} ion_cma_list="8m,32m,64m,128m,256m" loglevel=${loglevel} partitions=${partitions} #nand command syntax: sunxi_flash read address partition_name read_bytes #0x40007800 = 0x40008000(kernel entry) - 0x800(boot.img header 2k) boot_normal=fatload sunxi_flash boot 43800000 uImage;bootm 43800000 boot_recovery=fatload sunxi_flash extend 43800000 uImage;bootm 43800000 boot_fastboot=fastboot #recovery key recovery_key_value_max=0x13 recovery_key_value_min=0x10 #fastboot key fastboot_key_value_max=0x8 fastboot_key_value_min=0x2 10、先编译一遍tianv2.0的系统,然后增加sunxi-vfe support支持: rootroot@rootroot-E400:~$ cd wyb/thl_r16_tinav2.0_hm1375/ rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ 7za x thl_r16_tinav2.0_hm1375等待最终验证_20170824_1141.7z -r -o./ rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ source build/envsetup.sh including target/allwinner/octopus-dev/vendorsetup.sh including target/allwinner/astar-parrot/vendorsetup.sh including target/allwinner/astar-evb/vendorsetup.sh including target/allwinner/generic/vendorsetup.sh including target/allwinner/tulip-d1/vendorsetup.sh including target/allwinner/astar-spk/vendorsetup.sh rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ lunch You're building on Linux Lunch menu... pick a combo: 1. octopus_dev-tina 2. octopus_dev-dragonboard 3. astar_parrot-tina 4. astar_parrot-dragonboard 5. astar_evb-tina 6. tulip_d1-tina 7. tulip_d1-dragonboard 8. astar_spk-tina 9. astar_spk-dragonboard Which would you like?3 ============================================ PLATFORM_VERSION_CODENAME=Neptune PLATFORM_VERSION=2.0.0 TARGET_PRODUCT=astar_parrot TARGET_BUILD_VARIANT=tina TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a-neon TARGET_CPU_VARIANT=cortex-a7 TARGET_2ND_ARCH= TARGET_2ND_ARCH_VARIANT= TARGET_2ND_CPU_VARIANT= HOST_ARCH=x86_64 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=57513AA3 OUT_DIR= ============================================ rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ make -j8 rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ pack -d rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ make menuconfig Allwinner ---> < > fpscamera................................. fpscamera just test the camera 修改为: <*> fpscamera................................. fpscamera just test the camera Kernel modules ---> Video Support ---> < > kmod-sunxi-vfe......................................... sunxi-vfe support 修改为: <*> kmod-sunxi-vfe......................................... sunxi-vfe support rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ make -j12 rootroot@rootroot-E400:~/wyb/thl_r16_tinav2.0_hm1375$ pack -d 11、加载hm1375的驱动的时候查看I2C是否是通的: R:\wyb\thl_r16_tinav2.0_hm1375\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\hm1375.c static int sensor_detect(struct v4l2_subdev *sd) { int ret; unsigned char rdval; printk("****wyb %s:%d/%s()! verify HM1375\n", __FILE__, __LINE__, __func__); LOG_ERR_RET(sensor_read(sd, 0x0001, &rdval)) ret = sensor_read(sd, 0x0001,&rdval); printk("****wyb %s:%d/%s()! reg:0x0001=value:0xx right=0x03/0x13\n", __FILE__, __LINE__, __func__, rdval); if (ret < 0) { vfe_dev_err("sensor_read err at sensor_detect!\n"); return ret; } if((rdval != 0x03) && (rdval != 0x13)) { vfe_dev_err("read high val: %d\n", rdval); return -ENODEV; } LOG_ERR_RET(sensor_read(sd, 0x0002, &rdval)) printk("****wyb %s:%d/%s()! reg:0x0002=value:0xx right=0x75\n", __FILE__, __LINE__, __func__, rdval); if(rdval != 0x75) { vfe_dev_err("read low val: %d\n", rdval); return -ENODEV; } printk("HM1375 sensor_detect OK\r\n"); return 0; } (奇怪的时候HM1375的0x0001号寄存器,第一次读是0x03,以后都是0x13,好神奇!) [ 16.030894] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2891/sensor_detect()! verify HM1375 [ 16.042100] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2895/sensor_detect()! reg:0x0001=value:0x03 right=0x03/0x13 [ 16.055259] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2909/sensor_detect()! reg:0x0002=value:0x75 right=0x75 [ 16.067560] HM1375 sensor_detect OK [ 47.398156] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2891/sensor_detect()! verify HM1375 [ 47.409351] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2895/sensor_detect()! reg:0x0001=value:0x13 right=0x03/0x13 [ 47.422492] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2909/sensor_detect()! reg:0x0002=value:0x75 right=0x75 [ 47.434769] HM1375 sensor_detect OK [ 88.217828] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2891/sensor_detect()! verify HM1375 [ 88.228920] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2895/sensor_detect()! reg:0x0001=value:0x13 right=0x03/0x13 [ 88.242056] ****wyb drivers/media/video/sunxi-vfe/device/hm1375.c:2909/sensor_detect()! reg:0x0002=value:0x75 right=0x75 [ 88.254325] HM1375 sensor_detect OK

5,313

社区成员

发帖
与我相关
我的任务
社区描述
硬件使用专区,欢迎大家讨论硬件相关内容 宝藏!数字IC精品文章收录(CSDN近500篇) http://t.csdn.cn/QbivO
社区管理员
  • 硬件使用社区
  • 张江打工人
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧