高通camera马达驱动工作流程

本文介绍了高通平台上摄像头自动对焦功能的工作原理,特别是马达驱动的实现细节。主要内容包括通过platform_driver_register注册驱动,使用msm_actuator_platform_probe函数进行设备探测,并详细解析了msm_actuator_init_module函数中的关键步骤,如互斥锁、设备资源信息的获取以及v4l2_subdev的相关操作。

        手机自动对焦功能是通过将摄像头锁入音圈马达来实现的,音圈马达 简称(VCM),它主要有线圈,磁铁组和弹片构成,线圈通过上下两个弹片固定在磁铁组成,当给线圈通电时,线圈会产生磁场,线圈磁场和磁石组相互作用,线圈会向上移动,而锁在线圈里的摄像头便一起移动,当断电时,线圈在弹片弹力下返回,这样就实现了自动对焦功能

        这里重点是讲解一下关于高通平台camera的马达驱动,和驱动驱动一样,高通平台端的马达的入口函数也是 module_init();
     module_init(msm_actuator_init_module);
    
        msm_actuator_init_module()函数主要是实现了两个功能:一个是通过 platform_driver_register函数注册驱动 msm_actuator_platform_driver ),还有一个是将 msm_actuator_i2c_driver 挂载i2c总线上;
static struct platform_driver msm_actuator_platform_driver = {
    .probe =  msm_actuator_platform_probe,      //注册成功后就会调用这个探测函数(重要)
    .driver = {
.name = " qcom, actuator",   
 .owner = THIS_MODULE,
.of_match_table =  msm_actuator_dt_match   //通过设备树的compatible匹配资源,具体见下图
}
}
<span style="font-size:18px;color:#33cc00;">static int32_t msm_actuator_platform_probe(struct platform_device *pdev)
{
      ··············
    rc = of_property_read_u32((&pdev->dev)->of_node, "cell-index",
        &pdev->id);                </span><span style="font-size:18px;color:#003333;">//获取设备资源信息</span><span style="font-size:18px;color:#33cc00;">
    CDBG("cell-index %d, rc %d\n", pdev->id, rc);
    if (rc < 0) {
        kfree(msm_actuator_t);
        pr_err("failed rc %d\n", rc);
        return rc;
    }</span>
<span style="color: rgb(51, 204, 0);font-size:18px; line-height: 1.5; font-family: 微软雅黑;">     /*初始化msm_actuator_t*/</span>
<span style="color: rgb(51, 204, 0);font-size:18px; line-height: 1.5; font-family: 微软雅黑;">   msm_actuator_t->act_v4l2_subdev_ops = &</span><span style="font-size:18px; line-height: 1.5; font-family: 微软雅黑;"><span style="color:#ff0000;">msm_actuator_subdev_ops</span></span><span style="color: rgb(51, 204, 0);font-size:18px; line-height: 1.5; font-family: 微软雅黑;">;</span>
<span style="color: rgb(51, 204, 0);font-size:18px; line-height: 1.5; font-family: 微软雅黑;">    msm_actuator_t->actuator_mutex = &msm_actuator_mutex;        //互斥锁</span>

  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值