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\p720_ov2640_r58_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\p720_ov2640_r58_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 = 0
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\p720_ov2640_r58_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\p720_ov2640_r58_dev\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\ov2640.c
R:\wyb\p720_ov2640_r58_dev\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\Makefile
obj-m += ov2640.o
R:\wyb\p720_ov2640_r58_dev\lichee\linux-3.4\drivers\media\video\sunxi-vfe\Kconfig
5、
R:\wyb\p720_ov2640_r58_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<2><default><default><default>
vip_csi_mck = port:PE01<2><default><default><default>
vip_csi_hsync = port:PE02<2><default><default><default>
vip_csi_vsync = port:PE03<2><default><default><default>
vip_csi_d0 =
vip_csi_d1 =
vip_csi_d2 = port:PE06<2><default><default><default>
vip_csi_d3 = port:PE07<2><default><default><default>
vip_csi_d4 = port:PE08<2><default><default><default>
vip_csi_d5 = port:PE09<2><default><default><default>
vip_csi_d6 = port:PE10<2><default><default><default>
vip_csi_d7 = port:PE11<2><default><default><default>
vip_csi_d8 = port:PE12<2><default><default><default>
vip_csi_d9 = port:PE13<2><default><default><default>
vip_csi_sck = port:PE14<2><default><default><default>
vip_csi_sda = port:PE15<2><default><default><default>
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<1><default><default><default>
vip_dev0_pwdn = port:PE5<1><default><default><default>
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<2><default><default><default>
twi_sda = port:PH1<2><default><default><default>
[twi1]
twi_used = 1
twi_scl = port:PH2<2><default><default><default>
twi_sda = port:PH3<2><default><default><default>
[twi2]
twi_used = 1
twi_scl = port:PH4<2><default><default><default>
twi_sda = port:PH5<2><default><default><default>
不过奇怪的是,摄像头并没有向其它平台那样生成这个设备节点:
/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。