本为你主要讲解如何让摄像头ov13850支持自动对焦功能。
摄像头的对角主要通过VCM马达驱动芯片DW9714来实现的。
一、环境
soc : rk3568 board: EVB1-DDR4-V10 软 件:Android 11 Linux:4.19.232 Camera:ov13850二、DW9714
1.DW9714简介
DW9714专为自动对焦和光学变焦照相手机、数码相机和摄像机应用而设计,
由韩国动运国际有限公司(Dongwoon )设计生产。
工作电压可达3.6V。
DAC通过I2C串行接口控制,该接口以高达400kHz的时钟速率操作DAC。
DW9714集成了上电复位电路、掉电功能和精确匹配的检测电阻。
上电复位电路大流量卡确保当电源上电时,DAC输出为0V,直到发生有效的写位值。它具有断电功能,可将器件的电流消耗降至最大1uA。
2. 特征
用于自动对焦的VCM驱动程序关机功能:XSD=低电平有效VCM的10位分辨率电流吸收为120mAI2C串行接口(可用于1.8V输入电平)集成电流检测电阻保证所有代码的单调性低至0.5uA(典型值)上电复位掉电功能2.3V至3.6V操作3. 模块图
4. 引脚
序号Pin NameI/O Description Note1IOUTOutput current sink2VSS接地3VDD供电4SDAI2C interface input (DATA)5SCLI2C interface大流量卡 input/output (CLOCK)6XSD(1)关机模式,低有效
5. 参考电路
6. i2c时序
由以下时序可以看到,vcm9714利用I2C接口通信时,每次读/写,直接传输2个字节的数据,通信之前,不需要发送内部寄存器地址。
7. 寄存器格式
引脚说明PDPower down mode1: Power down mode (active high)0: Normal operation modeFLAG写操作时必须置为低D[9:0]Data input输出电流 = (D[9:0]/1023) X 120mA最大电流 = 120mA +/- 5%S[3:2]Codes per step0: 0大流量卡 (no SRC) – direct driving1: 12 :23: 4S[1:0]步进周期0: 811: 1622: 3243: 648
三、驱动移植
vcm9714与rk3568连接图:
设备树:@arch/arm64/boot/dts/rockchip/rk3568-evb1-ddr4-v10.dtsi 560 dw9714: dw9714@c { 561 compatible = “dongwoon,dw9714”; 562 status = “okay”; 563 reg = <0x0c>; 564 rockchip,camera-module-index = <0>; 565 rockchip,vcm-st大流量卡art-current = <10>; 566 rockchip,vcm-rated-current = <85>; 567 rockchip,vcm-step-mode = <5>; 568 rockchip,camera-module-facing = “back”; 569 }; 570 571 ov13850: ov13850@10 { …… 584 lens-focus = <&dw9714>; …… 591 };其中,下面这两个属性,必须要和对应的的摄像头ov13850信息保持一致
rockchip,camera-module-index = <0>; rockchip,camera-module-facin大流量卡g =“back”;摄像头支持的马达驱动信息通过以下属性关联
lens-focus = <&dw9714>; Makefile@kernel\drivers\media\i2c\Makefile obj-$(CONFIG_VIDEO_DW9714) += dw9714.o Kconfig@kernel\drivers\media\i2c\Kconfig config VIDEO_DW9714 tristate “DW9714 lens voice coil support” depends onI2C && VIDEO_V4L2 && MEDIA_CONTROLLER dep大流量卡endson VIDEO_V4L2_SUBDEV_API —help— This is a driver for the DW9714 camera lens voice coil. DW9714 is a 10 bit DAC with 120mA output current sink capability. This is designed for linear control of voice coil motors, controlled via I2C serial interface. 支持该驱动:@ arch/arm64/configs/rockchip_defconfig大流量卡 572 CONFIG_VIDEO_DW9714=y 驱动:rk_android11.0_sdk_220718\kernel\drivers\media\i2c\dw9714.c四、调试信息
1. 启动的驱动log
[ 0.800799] vm149c 4-000c: probing… [ 0.800820] vm149c 4-000c: driver version: 00.01.00 [ 0.800834] vm149c 4-000c: could not get module rockchip,vcm-max-current from dts! [ 0.800847] vm149c 4-000c: could not get module r大流量卡ockchip,vcm-start-current from dts! [ 0.800860] vm149c 4-000c: could not get module rockchip,vcm-rated-current from dts! [ 0.800872] vm149c 4-000c: could not get module rockchip,vcm-step-mode from dts! [ 0.800907] vm149c 4-000c: probing successful2. 查看拓扑结构
media-ctl -p …………… – entity 74: m00_b_ov13850 4-0010 (1 pad, 1 link) type V4L2 subde大流量卡v subtype Sensor device node name /dev/v4l-subdev4 pad0: Source [fmt:SBGGR10/4224×3136] -> “rockchip-csi2-dphy0”:0 [] – entity 78: m00_b_gpio-flash (0 pad, 0 link) type V4L2 subdev subtype Flash device node name /dev/v4l-subdev5 – entity 79: m00_b_dw9714 4-000c (0 pad, 0 link) type V4L2 subdev subtype Lens device node name /dev/v4l-subdev6四、驱动大流量卡分析
vcm9714驱动比较简单,基于i2c总线,
核心就是要注册基于v4l2的subdev,
提供给用户层调用的核心回调函数如下:
获取并设置当前马达的posstatic const struct v4l2_ctrl_ops dw9714_vcm_ctrl_ops = { .g_volatile_ctrl = dw9714_get_ctrl, .s_ctrl = dw9714_set_ctrl, }; static int dw9714_init_controls(struct dw9714_device *dev_vcm) { struct v4l2_ctrl_handler*hdl 大流量卡= &dev_vcm->ctrls_vcm;const struct v4l2_ctrl_ops *ops = &dw9714_vcm_ctrl_ops; v4l2_ctrl_handler_init(hdl, 1); v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FOCUS_ABSOLUTE, 0, VCMDRV_MAX_LOG, 1, VCMDRV_MAX_LOG); …… } static const struct v4l2_subdev_core_opsdw9714_core_ops = { .ioctl = dw9714_ioctl大流量卡, };static const struct v4l2_subdev_ops dw9714_ops = { .core = &dw9714_core_ops, }; static int dw9714_probe(struct i2c_client *client, const struct i2c_device_id *id) { v4l2_i2c_subdev_init(&dw9714_dev->sd, client, &dw9714_ops); }所有camera原创文章已经汇总成pdf,
后台回复:rxw
即可获取
友情提醒: 请添加客服微信进行免费领取流量卡!
QQ交流群:226333560 站长微信:qgzmt2
原创文章,作者:sunyaqun,如若转载,请注明出处:https://www.dallk.cn/33490.html