标签:自己 准备 amp eve %x linux c mode bsp 也会
本文转载自:http://www.voidcn.com/blog/Winva/article/p-6044730.html
4.3. Camera
参考文档:
1) 80-NA157-22_PRESENTATION- MSM8974-APQ8074-MSM8X26-APQ8084 LINUX CAMERA OVERVIEW.pdf
2) 80-NE717-1_MSM8974-APQ8074-MSM8X26 LINUX CAMERA SOFTWARE DESIGN DOCUMENT.pdf
3) 80-NU323-2_Multimedia Driver Development and Bringup Guide - Camera.pdf
4) 80-NL239-33_LINUX CAMERA DEBUGGING GUIDE.pdf
4.3.1. Camera软件架构
4.3.2. Kernel驱动
1) 增加dts配置
qcom,camera@5a {//back camera
compatible = “samsung,s5k3m2”;
reg = <0x5a>;
qcom,slave-id = <0x5a 0x0000 0x30d2>;
qcom,csiphy-sd-index = <0>;
qcom,csid-sd-index = <0>;
qcom,mount-angle = <90>;
qcom,sensor-name = “s5k3m2_f13s01k”;
qcom,actuator-src = <&actuator0>;
qcom,led-flash-src = <&led_flash0>;
cam_vdig-supply = <&pm8941_l3>;
cam_vana-supply = <&pm8941_l17>;
cam_vio-supply = <&pm8941_lvs2>;
cam_vaf-supply = <&pm8941_l23>;
qcom,cam-vreg-name = “cam_vdig”, “cam_vio”, “cam_vana”,
“cam_vaf”;
qcom,cam-vreg-type = <0 1 0 0>;
qcom,cam-vreg-min-voltage = <1225000 0 2850000 3000000>;
qcom,cam-vreg-max-voltage = <1225000 0 2850000 3000000>;
qcom,cam-vreg-op-mode = <105000 0 80000 100000>;
qcom,gpio-no-mux = <0>;
gpios = <&msmgpio 15 0>,
<&msmgpio 90 0>;
qcom,gpio-reset = <1>;
qcom,gpio-req-tbl-num = <0 1>;
qcom,gpio-req-tbl-flags = <1 0>;
qcom,gpio-req-tbl-label = “CAMIF_MCLK”,
“CAM_RESET1”;
qcom,gpio-set-tbl-num = <1 1>;
qcom,gpio-set-tbl-flags = <0 2>;
qcom,gpio-set-tbl-delay = <1 1000>;
qcom,csi-lane-assign = <0x4320>;
qcom,csi-lane-mask = <0x1F>;
qcom,sensor-position = <0>;
qcom,sensor-mode = <0>;
qcom,cci-master = <0>;
};
2) 增加驱动文件
kernel/drivers/media/platform/msm/camera_v2/sensor
复制一个原有camera的驱动文件并改名,比如ov8865.c改为s5k3l2.c。打开s5k3l2.c,把里面的ov8865改成s5k3l2, OV8865改为S5K3L2。
在Makefile里加上obj-$(CONFIG_S5K3L2) += s5k3l2.o
s5k3l2.c里需要改动的是上电序列,需要根据原理图来配置
static struct msm_sensor_power_setting s5k3l2_power_setting[] = {
{
.seq_type = SENSOR_VREG,
.seq_val = CAM_VIO,
.config_val = 0,
.delay = 1,
},
{
.seq_type = SENSOR_VREG,
.seq_val = CAM_VANA,
.config_val = 0,
.delay = 1,
},
{
.seq_type = SENSOR_VREG,
.seq_val = CAM_VDIG,
.config_val = 0,
.delay = 1,
},
{
.seq_type = SENSOR_VREG,
.seq_val = CAM_VAF,
.config_val = 0,
.delay = 5,
},
{
.seq_type = SENSOR_GPIO,
.seq_val = SENSOR_GPIO_STANDBY,
.config_val = GPIO_OUT_LOW,
.delay = 1,
},
{
.seq_type = SENSOR_GPIO,
.seq_val = SENSOR_GPIO_RESET,
.config_val = GPIO_OUT_LOW,
.delay = 5,
},
{
.seq_type = SENSOR_GPIO,
.seq_val = SENSOR_GPIO_AF_PWDM,
.config_val = GPIO_OUT_LOW,
.delay = 5,
},
{
.seq_type = SENSOR_GPIO,
.seq_val = SENSOR_GPIO_STANDBY,
.config_val = GPIO_OUT_HIGH,
.delay = 5,
},
{
.seq_type = SENSOR_GPIO,
.seq_val = SENSOR_GPIO_RESET,
.config_val = GPIO_OUT_HIGH,
.delay = 10,
},
{
.seq_type = SENSOR_GPIO,
.seq_val = SENSOR_GPIO_AF_PWDM,
.config_val = GPIO_OUT_HIGH,
.delay = 5,
},
{
.seq_type = SENSOR_CLK,
.seq_val = SENSOR_CAM_MCLK,
.config_val = 24000000,
.delay = 10,
},
{
.seq_type = SENSOR_I2C_MUX,
.seq_val = 0,
.config_val = 0,
.delay = 0,
},
};
3) 调试
在文件:kernel/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c
打开这个宏:#define CONFIG_MSMB_CAMERA_DEBUG
检查开机时kernel log
CDBG(“%s: read id: %x expected id %x:\n”, func, chipid,
slave_info->sensor_id);
看与camera的i2c通信是否成功。
4.3.3. user space驱动
1) 增加代码
vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/sensor_libs/ 里增加一个驱动文件夹s5k3l2,里面有两个文件:Android.mk和s5k3l2_lib.c
一般来说高通会提供驱动,模组厂也会提供相应的驱动。
把驱动加入进去,编译成so,然后push到手机里。或者整个编译成system.img,刷入手机。
有的时候,我们发现系统里找不到camera应用的图标。这是由于系统第一次启动时,后摄的kernel驱动没有准备好。
如何解决:
? Kernel驱动调试好后,重新刷userdata.img。让系统重新初始化。
? adb shell am start -n com.android.camera/com.android.camera.Camera package和activity的名字需要和手机里的应用匹配,不一定是上面这个名字。
? 安装其它的camera应用。
2) 调试
打开camera应用,看看图像预览是否成功。如果不成功,需要调试。
? 在代码里打开调试开关
vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/sensors/sensor.c
#define SLOW SERR
SLOW(“lib_name %s”, lib_name); 可以看到是否正确库被调用。
? Lane配置
qcom,csi-lane-assign = <0x4320>; 这是8974平台的值,其它平台不一样
qcom,csi-lane-mask = <0x1F>; 0x1F for 4lane, 0x7 for 2 lane, 0x3 for 1 lane
这个配置每个平台不一样。
大部分情况下,到这里基本就调通了,可以预览了。如果一直调不调,有可能是模块硬件有问题,需要和模组厂一起跳。
3) 从头创建lib.c文件 在某些情况下,如果不能得到驱动文件,需要根据芯片厂商的数据手册和高通的文档来自己写lib.c 4.3.4. 闪光灯 这是系统图自带闪光灯的配置 qcom,leds@d300 { status = “okay”; pm8941_flash0: qcom,flash_0 { qcom,max-current = <1000>; qcom,default-state = “off”; qcom,headroom = <3>; qcom,duration = <1280>; qcom,clamp-curr = <200>; qcom,startup-dly = <3>; qcom,safety-timer; label = “flash”; linux,default-trigger = “flash0_trigger”; qcom,id = <1>; linux,name = “led:flash_0”; qcom,current = <625>; }; 使用时做camera的配置文件里加上就行。 qcom,led-flash-src = <&led_flash0>; 4.3.5. 对焦马达 Kernel里面的驱动都是一样的,主要的改动在user space vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/actuator_libs vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/actuators 4.3.6. Tuning 马达,闪光灯,拍照效果都是要Tuning的。但是需要实验室环境来做。 注意:在马达的内核驱动里加上过多log,可能导致马达不能正常对焦。
标签:自己 准备 amp eve %x linux c mode bsp 也会
原文地址:http://www.cnblogs.com/zzb-Dream-90Time/p/6513930.html