全志R16的android4.4.2平台點亮gc2145(evb30)
1、配置ov2640在android層配置的分辨率為vga(預覽/拍照/錄像)
注意:系統自帶的快拍APP就在這里查找分辨率參數發送到camera的HAL層。
這里得分辨率設置為:拍照1600x1200,預覽640x480
驅動里面搜索可以設置為:1600x1200, 1280x720(花屏), 800x600(分辨率不能切換到這里), 640x480
提取分辨率的小知識:
R:\wyb\gc2145_parrotv1.1_r16m\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\gc2145.c
搜索:_regs[]
static struct regval_list sensor_default_regs[] = {
(默認分辨率是VGA分辨率:640x480)
/* 1600X1200 UXGA capture */
static struct regval_list sensor_uxga_regs[] ={
/* 800X600 SVGA,30fps*/
static struct regval_list sensor_svga_regs[] =
//1280*720---init---///
static struct regval_list gc2145_hd720_regs[] = {
R:\wyb\gc2145_parrotv1.1_r16m\android\device\softwinner\astar-evb30\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_A31S
key_camera_exif_model = MODEL_A31ST
;-------------------------------------------------------------------------------
; 1 for single camera, 2 for double camera
;-------------------------------------------------------------------------------
number_of_camera = 1
;-------------------------------------------------------------------------------
; CAMERA_FACING_BACK
; gc0307 gc2145
;-------------------------------------------------------------------------------
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 = 1600x1200, 1280x720, 800x600, 640x480
key_support_picture_size = 1600x1200, 640x480
key_default_picture_size = 640x480
used_flash_mode = 0
key_support_flash_mode = on,off,auto
key_default_flash_mode = on
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 = 10
key_default_frame_rate = 10
used_focus_mode = 0
key_support_focus_mode = auto,infinity,macro,fixed,continuous-video,continuous-picture
key_default_focus_mode = auto
used_scene_mode = 0
key_support_scene_mode = auto,portrait,landscape,night,night-portrait,theatre,beach,snow,sunset,steadyphoto,fireworks,sports,party,candlelight,barcode
key_default_scene_mode = auto
used_white_balance = 0
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
2、在init.rc(init.sun8i.rc)中加載gc2145.ko這個驅動模塊。
R:\wyb\gc2145_parrotv1.1_r16m\android\device\softwinner\astar-evb30\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/actuator.ko
#insmod /system/vendor/modules/ad5820_act.ko
insmod /system/vendor/modules/cci.ko
insmod /system/vendor/modules/vfe_os.ko
insmod /system/vendor/modules/vfe_subdev.ko
#insmod /system/vendor/modules/gc0307.ko
#insmod /system/vendor/modules/gc0308.ko
#insmod /system/vendor/modules/ov2035.ko
#insmod /system/vendor/modules/ov2640.ko
#insmod /system/vendor/modules/ov5640.ko
insmod /system/vendor/modules/gc2145.ko
insmod /system/vendor/modules/vfe_v4l2.ko
啟動之后實際加載的攝像頭的驅動模塊:
shell@astar-evb30:/ $
shell@astar-evb30:/ $ lsmod
gt82x 9849 0 - Live 0x00000000
sunxi_schw 12559 0 - Live 0x00000000 (O)
rtl8150 9023 0 - Live 0x00000000
sunxi_keyboard 3021 0 - Live 0x00000000
sw_device 13916 0 - Live 0x00000000
uvcvideo 61212 0 - Live 0x00000000
videobuf2_vmalloc 2600 1 uvcvideo, Live 0x00000000
videobuf2_memops 2366 1 videobuf2_vmalloc, Live 0x00000000
videobuf2_core 18902 1 uvcvideo, Live 0x00000000
vfe_v4l2 445492 1 - Live 0x00000000
gc2145 12782 0 - Live 0x00000000
vfe_subdev 4523 2 vfe_v4l2,gc2145, Live 0x00000000
vfe_os 3951 2 vfe_v4l2,vfe_subdev, Live 0x00000000
cci 21775 2 vfe_v4l2,gc2145, Live 0x00000000
videobuf_dma_contig 5567 1 vfe_v4l2, Live 0x00000000
videobuf_core 16520 2 vfe_v4l2,videobuf_dma_contig, Live 0x00000000
bcm_btlpm 7442 0 - Live 0x00000000
bcmdhd 629907 0 - Live 0x00000000
mali 210546 20 - Live 0x00000000 (O)
lcd 41263 0 - Live 0x00000000
disp 992816 8 mali,lcd, Live 0x00000000
nand 282782 0 - Live 0x00000000 (O)
shell@astar-evb30:/ $
3、(可選操作)沒有/dev/video1,只有/dev/video0
R:\wyb\gc2145_parrotv1.1_r16m\android\device\softwinner\astar-evb30\ueventd.sun8i.rc
/dev/video0 0666 media media
#/dev/video1 0666 media media
4、驅動程序:gc2145.c及其V4L2的適配層。
配置gc2145.c的編譯選項,只需要修改device目錄中的Makefile打開gc2145即可:
R:\wyb\gc2145_parrotv1.1_r16m\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\gc2145.c
(請嚴重注意,全志R16的parrotv1.1/android4.4.2的SDK里面是沒有,只有android6.0下有)
R:\wyb\gc2145_parrotv1.1_r16m\lichee\linux-3.4\drivers\media\video\sunxi-vfe\device\Makefile
obj-m+= gc2145.o
obj-m+= gc2155.o
(這兩個不用修改:)
R:\wyb\test_ov2640_r16\lichee\linux-3.4\drivers\media\video\sunxi-vfe\Kconfig
R:\wyb\test_ov2640_r16\lichee\linux-3.4\drivers\media\video\sunxi-vfe\Makefile
R:\wyb\gc2145_parrotv1.1_r16m\lichee\linux-3.4\drivers\media\video\sunxi-vfe\sensor_info.c
struct sensor_item sensor_list_t[] =
{
// name i2c_addr sensor type sensor size sensor max pclk
(請參照OV2640/GC2155配置)
{"gc2145",0x78,SENSOR_YUV,PIXEL_NUM_2M, CORE_CLK_RATE_FOR_2M},
{ "ov2640" , 0x60, SENSOR_YUV , PIXEL_NUM_2M , CORE_CLK_RATE_FOR_2M},
……
};
5、
R:\wyb\gc2145_parrotv1.1_r16m\lichee\tools\pack\chips\sun8iw5p1\configs\evb-30\sys_config.fex
[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 = 3300
eldo1_vol = 2800
eldo2_vol = 1800
eldo3_vol = 1800
;gldo1_vol = 3300
ldoio0_vol = 2800
ldoio1_vol = 3300
;--------------------------------------------------------------------------------
;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 = "gc2145"
vip_dev0_pos = "rear"
vip_dev0_lane = 1
vip_dev0_twi_id = 2
vip_dev0_twi_addr = 0x78
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 = "axp22_ldoio0"
vip_dev0_avdd_vol = 2800000
vip_dev0_dvdd = "axp22_ldoio1"
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 =
(可選配置:)
;----------------------------------------------------------------------------------
;usb configuration
;usb_used: usb controller enable, 0-disable, 1-enable
;usb_port_type: usb mode: 0-device, 1-host, 2-otg
;usb_detect_type: usb hotplug detect mode, 0-none, 1-vbus/id detect, 2-id/dpdm detect
;usb_id_gpio: usb id detect IO
;usb_det_vbus_gpio: usb vbus detect IO, "axp_ctrl" for axp
;usb_drv_vbus_gpio: usb dirve vbus IO
;usb_restrict_gpio: usb current restrict IO
;usb_restric_flag: usb current restrict flag
;----------------------------------------------------------------------------------
[usbc0]
usb_used = 1
usb_port_type = 0
power_start = 3
6、開發板上攝像頭的I2C掛載在TWI2上面了,邏輯是需要打開的(但是不打開也能夠用,很奇怪!):
;----------------------------------------------------------------------------------
;i2c configuration
; twi_used = twix enable
;----------------------------------------------------------------------------------
[twi0]
twi_used = 1
twi_scl = port:PH02<2>
twi_sda = port:PH03<2>
[twi1]
twi_used = 1
twi_scl = port:PH04<2>
twi_sda = port:PH05<2>
[twi2]
twi_used = 0
twi_scl = port:PE12<3>
twi_sda = port:PE13<3>
直接配置攝像頭的I2C了:
vip_csi_sck = port:PE12<2>
vip_csi_sda = port:PE13<2>
不過奇怪的是,攝像頭並沒有向其它平台那樣生成設備節點:
shell@astar-evb30:/ $
shell@astar-evb30:/ $ cd /sys/class/i2c-adapter
shell@astar-evb30:/sys/class/i2c-adapter $
shell@astar-evb30:/sys/class/i2c-adapter $
shell@astar-evb30:/sys/class/i2c-adapter $ ll
lrwxrwxrwx root root 1970-01-01 08:00 i2c-0 -> ../../devices/platform/twi.0/i2c-0
lrwxrwxrwx root root 1970-01-01 08:00 i2c-1 -> ../../devices/platform/twi.1/i2c-1
shell@astar-evb30:/sys/class/i2c-adapter $
可能是全志R16的驅動程序不太規范吧!沒有通過i2c_detect來注冊2-003C這個節點。
直接在驅動程序中讀取I2C,還是對的。0xF0/0xF1 device ID = 0x2145。
#define V4L2_IDENT_SENSOR 0x2145
/*
* The gc2145 sits on i2c with ID 0x78
*/
#define I2C_ADDR 0x78
#define SENSOR_NAME "gc2145"
android4.4.2下已經驗證的分辨率有640x480,1600x1200,1280x720(花屏),800x600沒有驗證。
640x480正常
1280x720花屏
1600x1200正常