点击左上方蓝色“一口Linux”,选择“设为星标”
本为你主要讲解如何让摄像头ov13850支持自动对焦功能。
摄像头的对角主要通过VCM马达驱动芯片DW9714来实现的。
soc : rk3568
board: EVB1-DDR4-V10
软 件:Android 11
Linux:4.19.232
Camera:ov13850
DW9714专为自动对焦和光学变焦照相手机、数码相机和摄像机应用而设计,
由韩国动运国际有限公司(Dongwoon )设计生产。
工作电压可达3.6V。
DAC通过I2C串行接口控制,该接口以高达400kHz的时钟速率操作DAC。
DW9714集成了上电复位电路、掉电功能和精确匹配的检测电阻。
上电复位电路确保当电源上电时,DAC输出为0V,直到发生有效的写位值。它具有断电功能,可将器件的电流消耗降至最大1uA。
序号 | Pin Name | I/O Description Note |
---|---|---|
1 | IOUT | Output current sink |
2 | VSS | 接地 |
3 | VDD | 供电 |
4 | SDA | I2C interface input (DATA) |
5 | SCL | I2C interface input/output (CLOCK) |
6 | XSD(1) | 关机模式,低有效 |
由以下时序可以看到,vcm9714利用I2C接口通信时,每次读/写,直接传输2个字节的数据,通信之前,不需要发送内部寄存器地址。
引脚 | 说明 |
---|---|
PD | Power down mode |
1: Power down mode (active high) | |
0: Normal operation mode | |
FLAG | 写操作时必须置为低 |
D[9:0] | Data input |
输出电流 = (D[9:0]/1023) X 120mA | |
最大电流 = 120mA +/- 5% | |
S[3:2] | Codes per step |
0: 0 (no SRC) – direct driving | |
1: 1 | |
2 :2 | |
3: 4 | |
S[1:0] | 步进周期 |
0: 81 | |
1: 162 | |
2: 324 | |
3: 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-start-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-facing = "back";
摄像头支持的马达驱动信息通过以下属性关联
lens-focus = <&dw9714>;
@kernel\drivers\media\i2c\Makefile
obj-$(CONFIG_VIDEO_DW9714) += dw9714.o
@kernel\drivers\media\i2c\Kconfig
config VIDEO_DW9714
tristate "DW9714 lens voice coil support"
depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER
depends on 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
[ 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 rockchip,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 successful
media-ctl -p
……………
- entity 74: m00_b_ov13850 4-0010 (1 pad, 1 link)
type V4L2 subdev subtype Sensor
device node name /dev/v4l-subdev4
pad0: Source
[fmt:SBGGR10/4224x3136]
-> "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,
提供给用户层调用的核心回调函数如下:
static 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_ops dw9714_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,
关注公众号:一口Linux,
后台回复:rxw
即可获取
这是一口君的新书,感谢大家支持!
end
一口Linux
关注,回复【1024】海量Linux资料赠送
精彩文章合集
文章推荐