马达对应的actuator结构体分析

2024-06-07 09:04

本文主要是介绍马达对应的actuator结构体分析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

​1.文件: mm-camera2/media-controller/modules/sensors/actuator/actuator.h中对actuator_data_t进行了如下定义:

这个结构体是actuator马达控制的最外层的数据结构。

typedef struct {
    int32_t fd;
    actuator_ctrl_t *ctrl;
    int16_t curr_step_pos;
    int16_t cur_restore_pos;
    uint16_t total_steps;
    uint8_t is_af_supported;
    uint8_t cam_name;
    uinit8_t load_params;
} actuator_data_t;

    1.1. fd ---> 与内核进行交互的文件描述述(节点名称??? 节点名称为/dev/v4l-subdev4)。

    1.2 ctrl ---> 重点结构体,其中我们定义的不同sensor的参数即是actuator_ctrl_t结构体,这是3A算法对外进行的参数配置接口。

    1.3 curr_step_pos ---> 这个是一直变化的,它的作用是保存马达当前所处的位置。

    1.4 cur_restore_pos ---> 进行马达复位是的位置设定。

    1.5 total_steps ---> 表示马达可移动的总步数。它由下面代码计算所得:

  1. total_steps = af_tune_ptr->af_algo.position_far_end -
  2.     af_tune_ptr->af_algo.position_near_end + 1;
  3. total_steps += af_tune_ptr->af_algo.undershoot_adjust;

    1.6 is_af_supported ---> 代表sensor是否支持自动对焦,是在actuator模块的初始化函数中通过ioctl与底层交互获取

    1.7 cam_name ---> camera name,获取同上一起获取,这个名字的作用主要是与我们定义的若干文件进行加载时匹配,根据头文件中af_tune.af_header_info.cam_name字段进行匹配加载,(对于200与201camera的不同处理即是在底层赋给不同的值在实现加载不同的头文件)。

    1.8 load_params ---> 代表头文件是否加载,初始值设为1,加载完成后将其置0,后面则不会重复加载。

2.下面主要看actuator_ctrl_t结构体,我们定义的头文件也即此结构体。

  1. typedef struct {
  2.     af_tunne_parms_t af_tune;
  3. } actuator_ctrl_t;

​af_tunne_parms_t结构体各个版本的定义不同,0208/0301,故其定义在各自的文件目录下,我们使用的是0301版本,其定义文件为mm-camera2/media-controller/modules/sensors/actuators/0301/af_tunning.h

2.1 结构体af_header_info (变量af_header_info) 定义如下:

/** _af_header_info:
 **/
typedef struct _af_header_info {
  uint16_t header_version; // 头文件版本
  enum af_camera_name cam_name; // camera 名字
  char module_name[MAX_ACT_MOD_NAME_SIZE]; //模块名称
  char actuator_name[MAX_ACT_NAME_SIZE]; //马达名称
}af_header_info_t;

成员1. uint16_t header_version = 0x301;

  1. /* header_version */

成员2. enum af_camera_name af_camera_name cam_name = ACTUATOR_MAIN_CAM_1;

  1. /* module_name */

​其取值范围如下:

enum af_camera_name {ACTUATOR_MAIN_CAM_0,ACTUATOR_MAIN_CAM_1,ACTUATOR_MAIN_CAM_2,ACTUATOR_MAIN_CAM_3,ACTUATOR_MAIN_CAM_4,ACTUATOR_MAIN_CAM_5,ACTUATOR_WEB_CAM_0,ACTUATOR_WEB_CAM_1,ACTUATOR_WEB_CAM_2,
};

成员3. char module_name[MAX_ACT_MOD_NAME_SIZE] = "abico";

  1. /* module_name */

​成员4. char actuator_name[MAX_ACT_NAME_SIZE] = "dw9714";

  1. /* actuator_name */

主要成员cam_name,此处定义的名字将会与上面通过ioctl获取的名字进行匹配,如果匹配成功,则加载此头文件。实现代码如下:

if (af_actuator_ptr->is_af_supported) {
  for (cnt = 0; cnt < (sizeof(actuators) / sizeof(actuators[0][0])/
    ACTUATOR_CAM_MODE_MAX); cnt++) {
    if (af_actuator_ptr->cam_name == actuators[cam_mode][cnt].af_tune.
      af_header_info.cam_name) {
      af_actuator_ptr->ctrl = &actuators[cam_mode][cnt]; //将头文件的定义进行赋值
      break;
    }
  }
}

2.2 结构体af_tuning_alog_t(变量af_algo)定义如下:

/** _af_tuning_algo: AF tuning parameters specific to AF
 *  algorithm.
 *
 *  @af_process_type: af algorithm type used // AF的处理算法选择
 *
 *  @position_near_end: nearest position lens can move to
 *
 *  @position_default_in_macro: default lens rest position when
 *                            focus mode is Macro.
 *
 *  @position_boundary: determines near end of search range for
 *                    Normal focus mode.
 *
 *  @position_default_in_normal: default lens reset position
 *                             when focus mode is other than
 *                             macro.
 *
 *  @position_far_end: farthest point of the search range
 *
 *  @position_normal_hyperfocal: normal position of the lens when
 *                               focus fails
 *
 *  @undershoot_protect: when enabled, lens will be moved more
 *                     in either forward or backward direction.
 *  @undershoot_adjust: when undershoot_protect is enabled, lens
 *                    movement is adjusted by this amount.
 *
 *  @fv_drop_allowance: amount by which fv is allowed to drop
 *                    below max
 *
 *  @lef_af_assist_enable: enable/disable led assisted AF
 *
 *  @led_af_assist_trigger_idx: Lux Index燼t which LED assist
 *                            for autofocus is enabled.
 *
 *  @af_tuning_continuous_t: af parameters for continuous focus
 *
 *  @af_exh: af parameters for exhaustive af
 *
 *  @af_sad: sad related tuning parameters
 *
 *  @af_shake_resistant: tuning parameters for af shake
 *                     resistant.
 *
 *  @af_motion_sensor: trigger parameters for af motion sensor.
 **/
typedef struct _af_tuning_algo {
  unsigned short af_process_type;
  unsigned short position_near_end;
  unsigned short position_default_in_macro;
  unsigned short position_boundary;
  unsigned short position_default_in_normal;
  unsigned short position_far_end;
  unsigned short position_normal_hyperfocal;
  unsigned short position_macro_rgn;
  unsigned short undershoot_protect;
  unsigned short undershoot_adjust;
  float fv_drop_allowance;
  int lef_af_assist_enable;
  long led_af_assist_trigger_idx;
  int lens_reset_frame_skip_cnt;
  float low_light_gain_th;
  af_tuning_continuous_t af_cont;
  af_tuning_exhaustive_t af_exh;
  af_tuning_fullsweep_t af_full;
  af_tuning_sp_t af_sp;
  af_shake_resistant_t af_shake_resistant;
  af_motion_sensor_t af_motion_sensor;
}af_tuning_algo_t;

成员1. unsigned short af_process_type = AF_EXHAUSTIVE_SEARCH;

    变量的赋值由下列枚举类型决定: 

/* Variable name: af_process_type.
 * Defines which AF algorithm to use -
 *   Exhaustive/Slope-predictive/Continuous.
 * 3A version:
 * Default value: AF_EXHAUSTIVE_SEARCH.
 * Data range: based on af_algo_type
 */
        AF_EXHAUSTIVE_SEARCH, (其值为下列枚举类型中列出)/******************************************************************************
AF Algorithm tuning parameters AF算法调试选择
******************************************************************************/
/** af_algo_type: Type of algorithm currently supported
**/
typedef enum {
  AF_PROCESS_DEFAULT   = -2, // 默认算法
  AF_PROCESS_UNCHANGED = -1, // UNCHANGED
  AF_EXHAUSTIVE_SEARCH = 0, // 穷举算法
  AF_EXHAUSTIVE_FAST, // 快速穷举法
  AF_HILL_CLIMBING_CONSERVATIVE, // 保守爬山算法
  AF_HILL_CLIMBING_DEFAULT, // 默认爬上算法
  AF_HILL_CLIMBING_AGGRESSIVE, // 激进爬山算法
  AF_FULL_SWEEP, // 扫描线算法
  AF_SLOPE_PREDICTIVE_SEARCH, // 坡度预测算法
  AF_CONTINUOUS_SEARCH, // 连续搜索算法
  AF_PROCESS_MAX
} af_algo_type;

成员2.  unsigned short position_near_end   = 0;

/* Variable name: position_near_end.
 * Used to control how far lens can move away from mechanical stop.  It
 * is defined in term of indices, where position_far_end >
 * position_near_end.
 * 3A version:
 * Default value: 0.
 * Data range: 0 to (position_far_end - 1).
 * Constraints: Less than position_far_end. Total steps for AF lens to
 *              travel = position_far_end - position_near_end.  For
 *              sanity check, it should be more than 20 steps.
 * Effect: Non-zero means we are limiting AF travel range even more than
 *         the values obtained from AF tuning.  For example, if AF lens
 *         on the final production modules move 8 steps beyond the
 *         necessary MACRO focused distance, we can reduce travel range
 *         by setting position_near_end to 8 (or less to account for
 *         module-to-module variation).
 */

    用于控制镜头在多远处机械停止的位置,这个被定义为position_far_end > position_near_end.

成员3.  unsigned short position_default_in_macro = 0;

/* Variable name: position_default_in_macro.
 * Gives default rest position of lens when focus mode is Macro.
 * 3A version:
 * Default value: 0.
 * Data range: 0 to position_far_end.
 */

    在对焦方式为无限远时,给出镜头静止时的默认位置,范围为: 0 - position_far_end

成员4.  unsigned short position_boundary = 35;

/* Variable name: position_boundary.
 * Used to control how far lens can move away from mechanical stop in
 * NORMAL search mode.
 * 3A version:
 * Default value: 0.
 * Data range: 0 to (position_far_end - 1).
 * Constraints: Less than position_far_end.
 * Effect: The closer it is to position_far_end, the less steps AF lens is allowed
 * to travel in NORMAL search mode.
 */

    位置边界

成员5.  unsigned short position_default_in_normal = 40;

​/* Variable name: position_default_in_normal.
 * Gives default rest position of lens when focus mode is Normal/Auto.
 * mode.
 * 3A version:
 * Default value: position_far_end.
 * Data range: 0 to position_far_end.
 */

成员6.  unsigned short position_far_end = 45;

/* Variable name: position_far_end.
 * Used to control how far lens can move away from mechanical stop.  It is
 * defined in term of indices, where position_far_end > position_near_end.
 * 3A version:
 * Default value: actuator infinity position
 * Data range: 1 to infinty
 * Constraints:
 * Effect: Non-zero means we are limiting AF travel range even more than the
 *         values obtained from AF tuning.
 */

成员7.  unsigned short position_normal_hyperfocal = 38;

/* Variable name: position_normal_hyperfocal.
 * Gives default position of lens when focus mode is Normal/Auto and
 * focus fails.
 * 3A version:
 * Default value: position_far_end.
 * Data range: 0 to position_far_end.
 */

成员8.  unsigned short position_macro_rgn = 18;

/* Variable name: position_macro_rgn.
 * Starting lens position of macro region.
 * 3A version:
 * Default value: tunable..
 * Data range: 0 to position_far_end.
 */

成员9.  unsigned short undershoot_protect = 0;

/* Variable name: undershoot_protect.
 * Boolean flag to enable/disable the feature
 * 3A version:
 * Default value: 0 (disable)
 * Data range: 0 (enable) or 1 (disable)
 * Constraints: the degree of protection from undershoot will be depends
 *              on undershoot_adjust variable
 * Effect: If this feature is enabled, lens will move more in one
 *         direction over the other direction. This is needed when
 *         it is determined that AF actuator has severe hysteresis on
 *         its movement during characterization process. The feature
 *         compensate hysteresis by moving the lens more
 *         in either forward or backward direction.
 */

成员10.  unsigned short undershoot_adjust = 0;

/* Variable name: undershoot_adjust.
 * Used when undershoot protection is enabled.
 * 3A version:
 * Default value: 0
 * Data range: 0 to (coarse step size - 1)
 * Constraints: As noted above, number greater than or equal to coarse
 *              step size is not recommended.
 * Effect: When feature is turned on, the feature will compensate the
 *         undershoot movement of lens (mainly due to severe hysteresis)
 *         by moving extra step specified in this variable.
 */

成员11.float fv_drop_allowance = 0.55;

/* Variable name: fv_drop_allowance.
 * If focus value drops below this much of maximum fv, search forward
 * is stopped.
 * 3A version:
 * Default value: 0.5
 * Data range: 0 to less than 1
 * Constraints: Value less than 0.75 is recommended.
 * Effect: Increasing this value makes it easier to stop the search
 * forward.
 */

成员12.int lef_af_assist_enable = 1;

/* Variable name: lef_af_assist_enable.
 * Enable or disable the LED assist for auto focus feature.
 * 3A version:
 * Default value: 0.5
 * Data range: 1 or 0.
 * Constraints: None
 * Effect: LED auto focus assist is enabled.
 */

成员13.long led_af_assist_trigger_idx = 372;

/* Variable name: led_af_assist_trigger_idx.
 * Lux Index燼t which LED assist for autofocus is enabled.
 * 3A version:
 * Default value: wLED Trigger Index (calculated)
 * Data range: 0 to 1000
 * Constraints: None
 * Effect: Selects scene brightness level at which LED auto focus assist
 * can be enabled.
 */

成员14.int lens_reset_frame_skip_cnt = 6;

/* Variable name: lens_reset_frame_skip_cnt
 * How many frames to skip after resetting the lens
 * 3A version:
 * Default value: 2
 * Data range: 2 - 6
 * Constraints: Integers
 * Effect: Bigger in value represents longer waiting time.
 */

成员15.float low_light_gain_th = 10;

/* Variable name: low_light_gain_th
 * When the aec gain is above this threshold, we assume it's low light condition.
 * 3A version:
 * Default value: 10
 * Data range:
 * Constraints:
 * Effect:
 */

成员16.af_tuning_continuous_t af_cont;

    af_tunning_continuous_t定义如下:

/** _af_tuning_continuous: AF tuning parameters specific to
 *  Continuous AF
 *
 *  @enable: CAF is enabled/disabled (currently only used by
 *         ez-tune)
 *
 *  @scene_change_detection_ratio: fv change to trigger a
 *                                  target change
 *
 *  @panning_stable_fv_change_trigger: fv change vs past
 *                                      frame fv to trigger to
 *               

这篇关于马达对应的actuator结构体分析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1038735

相关文章

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

Python中顺序结构和循环结构示例代码

《Python中顺序结构和循环结构示例代码》:本文主要介绍Python中的条件语句和循环语句,条件语句用于根据条件执行不同的代码块,循环语句用于重复执行一段代码,文章还详细说明了range函数的使... 目录一、条件语句(1)条件语句的定义(2)条件语句的语法(a)单分支 if(b)双分支 if-else(

最长公共子序列问题的深度分析与Java实现方式

《最长公共子序列问题的深度分析与Java实现方式》本文详细介绍了最长公共子序列(LCS)问题,包括其概念、暴力解法、动态规划解法,并提供了Java代码实现,暴力解法虽然简单,但在大数据处理中效率较低,... 目录最长公共子序列问题概述问题理解与示例分析暴力解法思路与示例代码动态规划解法DP 表的构建与意义动

使用Navicat工具比对两个数据库所有表结构的差异案例详解

《使用Navicat工具比对两个数据库所有表结构的差异案例详解》:本文主要介绍如何使用Navicat工具对比两个数据库test_old和test_new,并生成相应的DDLSQL语句,以便将te... 目录概要案例一、如图两个数据库test_old和test_new进行比较:二、开始比较总结概要公司存在多

Spring Boot Actuator使用说明

《SpringBootActuator使用说明》SpringBootActuator是一个用于监控和管理SpringBoot应用程序的强大工具,通过引入依赖并配置,可以启用默认的监控接口,... 目录项目里引入下面这个依赖使用场景总结说明:本文介绍Spring Boot Actuator的使用,关于Spri

C#使用DeepSeek API实现自然语言处理,文本分类和情感分析

《C#使用DeepSeekAPI实现自然语言处理,文本分类和情感分析》在C#中使用DeepSeekAPI可以实现多种功能,例如自然语言处理、文本分类、情感分析等,本文主要为大家介绍了具体实现步骤,... 目录准备工作文本生成文本分类问答系统代码生成翻译功能文本摘要文本校对图像描述生成总结在C#中使用Deep

MybatisGenerator文件生成不出对应文件的问题

《MybatisGenerator文件生成不出对应文件的问题》本文介绍了使用MybatisGenerator生成文件时遇到的问题及解决方法,主要步骤包括检查目标表是否存在、是否能连接到数据库、配置生成... 目录MyBATisGenerator 文件生成不出对应文件先在项目结构里引入“targetProje

Redis主从/哨兵机制原理分析

《Redis主从/哨兵机制原理分析》本文介绍了Redis的主从复制和哨兵机制,主从复制实现了数据的热备份和负载均衡,而哨兵机制可以监控Redis集群,实现自动故障转移,哨兵机制通过监控、下线、选举和故... 目录一、主从复制1.1 什么是主从复制1.2 主从复制的作用1.3 主从复制原理1.3.1 全量复制

Redis主从复制的原理分析

《Redis主从复制的原理分析》Redis主从复制通过将数据镜像到多个从节点,实现高可用性和扩展性,主从复制包括初次全量同步和增量同步两个阶段,为优化复制性能,可以采用AOF持久化、调整复制超时时间、... 目录Redis主从复制的原理主从复制概述配置主从复制数据同步过程复制一致性与延迟故障转移机制监控与维

Redis连接失败:客户端IP不在白名单中的问题分析与解决方案

《Redis连接失败:客户端IP不在白名单中的问题分析与解决方案》在现代分布式系统中,Redis作为一种高性能的内存数据库,被广泛应用于缓存、消息队列、会话存储等场景,然而,在实际使用过程中,我们可能... 目录一、问题背景二、错误分析1. 错误信息解读2. 根本原因三、解决方案1. 将客户端IP添加到Re