android camera2 qcom,2.4、高通camera框架:初理解之二_setParameter_原创

本文档详细介绍了如何在Android HAL1.0框架中添加OIS光学防抖参数设置。首先在Camera.java中增加接口函数,然后在App中调用此接口设置ois值。接着修改HAL层,包括添加OIS定义、设置默认值及解析处理。同时,更新Vendor层,添加OIS相关定义和设置,最终通过ioctl方法将参数传递至内核,实现OIS功能。
摘要由CSDN通过智能技术生成

HAL1.0参数设置:

A、V1增加设定参数:增加OIS光学防抖参数设置(ois参数一般不作为设置参数,在本文档仅作实验测试),仅作流程分析对比。

1)

添加接口函数,参考public void setSaturation(int

saturation)设置

在code/frameworks/base/core/java/android/hardware/Camera.java文件增加接口:

public void

setOis(int saturation){

…………

set(KEY_QC_OIS, String.valueOf(OIS));

}

2)

App设置参数调用,假设设置ois值为1

参考

packages/apps/SnapdragonCamera/src/com/android/camera/PhotoModule.java

mParameters.setSaturation(saturation);函数调用;

mParameters.setOis(ois);

由于HAL

V1参数传递是通过字符串来完成的,最后传递到HAL层的字符串里面会有“ois=1”,在HAL层进行解析。

B、Hal层相关修改:

1、

添加相关定义

1.1、 文件:hardware/qcom/camera/QCamera2/HAL/QCameraParameters.h

static

const char KEY_QC_SCE_FACTOR_STEP[];

+ static const char KEY_QC_OIS[];

static const char KEY_QC_HISTOGRAM[] ;

int32_t setSharpness(const QCameraParameters& );

+ int32_t setOis(const QCameraParameters& );

int32_t setSaturation(const QCameraParameters& );

int32_t setSharpness(int sharpness);

+ int32_t setOis(int ois);

int32_t setSaturation(int saturation);

1.2、 文件:hardware/qcom/camera/QCamera2/stack/common/cam_types.h

typedef

enum {

CAM_INTF_PARM_FLASH_BRACKETING,

CAM_INTF_PARM_GET_IMG_PROP,

CAM_INTF_PARM_MAX

+ CAM_INTF_PARM_OIS

} cam_intf_parm_type_t;

1.3、 文件:hardware/qcom/camera/QCamera2/stack/common/cam_intf.h

typedef

struct{

cam_af_bracketing_t mtf_af_bracketing_parm;

cam_sensor_type_t sensor_type;

+

+ int32_t ois_default_value;

}

cam_capability_t;

2、

添加相关设置

文件:hardware/qcom/camera/QCamera2/HAL/QCameraParameters.cpp

const

char QCameraParameters::KEY_QC_SCE_FACTOR_STEP[] =

"sce-factor-step";

+const

char QCameraParameters::KEY_QC_OIS[] = "ois";

//open

camera时OIS默认值,该值在vendor中设置

int32_t

QCameraParameters::initDefaultParameters()

{

………

+ // Set Ois

+ setOis(m_pCapability->ois_default_value);

+ ALOGE("the default_ois = %d",

m_pCapability->ois_default_value);

// Set Contrast

set(KEY_QC_MIN_CONTRAST,

m_pCapability->contrast_ctrl.min_value);

set(KEY_QC_MAX_CONTRAST,

m_pCapability->contrast_ctrl.max_value);

………

}

+int32_t

QCameraParameters::setOis(const QCameraParameters&

params)

+{

+ int ois = params.getInt(KEY_QC_OIS);

+ int prev_ois = getInt(KEY_QC_OIS);

+ if(params.get(KEY_QC_OIS) == NULL) {

+ CDBG_HIGH("%s: Ois not set by App ",__func__);

+ return NO_ERROR;

+ }

+ ALOGE("haljay ois=%d prev_ois=%d",ois, prev_ois);

+ if (prev_ois != ois) {

+ if((ois >= 0) && (ois <= 2)) {

+ CDBG(" new ois value : %d ", ois);

+ return setOis(ois);

+ } else {

+ ALOGE("%s: invalid value %d",__func__, ois);

+ return BAD_VALUE;

+ }

+ } else {

+ ALOGE("haljay no value change");

+ CDBG("%s: No value change in ois", __func__);

+ return NO_ERROR;

+ }

+}

+int32_t

QCameraParameters::setOis(int ois)

+{

+ char val[16];

+ sprintf(val, "%d", ois);

+ updateParamEntry(KEY_QC_OIS, val);

+ CDBG("%s: Setting ois %s", __func__, val);

+ ALOGE("haljay %s set ois=%s OIS=%d", __func__, val,

CAM_INTF_PARM_OIS);

+ int32_t value = ois;

+ return AddSetParmEntryToBatch(m_pParamBuf,

+ CAM_INTF_PARM_OIS,

+ sizeof(value),

+ &value);

+}

函数int32_t

QCameraParameters::updateParameters添加setOis:

if ((rc =

setBrightness(params))) final_rc = rc;

if ((rc =

setZoom(params))) final_rc = rc;

if ((rc =

setSharpness(params))) final_rc = rc;

+ if ((rc =

setOis(params))) final_rc = rc;

if ((rc = setSaturation(params))) final_rc

= rc;

C、Vendor层相关修改:

1、

添加相关定义

1.1、 文件:kernel/include/media/msm_cam_sensor.h

enum

msm_actuator_cfg_type_t {

CFG_SET_POSITION,

CFG_ACTUATOR_POWERDOWN,

CFG_ACTUATOR_POWERUP,

+

CFG_ACTUATOR_OIS,

};

struct

msm_actuator_cfg_data {

struct msm_actuator_get_info_t get_info;

struct msm_actuator_set_position_t setpos;

enum af_camera_name cam_name;

+ void *setting;

} cfg;

1.2、 文件:vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/mct/pipeline/mct_pipeline.c

在函数boolean

mct_pipeline_populate_query_cap_buffer(mct_pipeline_t

*pipeline)中添加:

hal_data->sharpness_ctrl.min_value = 0;

hal_data->sharpness_ctrl.step = 6;

+ hal_data->ois_default_value = 1;

hal_data->contrast_ctrl.def_value = 5;

hal_data->contrast_ctrl.max_value = 10;

1.3、 文件:vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/module/sensor_common.h

typedef

enum {

SENSOR_SET_AWB_UPDATE,

+ ACTUATOR_SET_OIS

}

sensor_submodule_event_type_t;

2、

添加相关设置

文件:vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/module/module_sensor.c

2.1、获取hal层参数

在函数static boolean

module_sensor_event_control_set_parm中增加:

+ case CAM_INTF_PARM_OIS:{

+ if (!event_control->parm_data) {

+ SERR("failed parm_data NULL");

+ ret = FALSE;

+ break;

+ }

+ module_sensor_params_t *ois_module_params = NULL;

+ ois_module_params =

s_bundle->module_sensor_params[SUB_MODULE_ACTUATOR];

+ if (ois_module_params->func_tbl.process != NULL)

{

+ rc = ois_module_params->func_tbl.process(

+ ois_module_params->sub_module_private,

+ ACTUATOR_SET_OIS,

event_control->parm_data);

+ }

+ if (rc < 0) {

+ SERR("failed");

+ ret = FALSE;

+ }

+ break;

+ }

文件:vendor/qcom/proprietary/mm-camera/mm-camera2/media-controller/modules/sensors/actuators/actuator.c

2.2、在函数int32_t

actuator_process中增加:

case ACTUATOR_SET_POSITION:

rc =

actuator_set_position(actuator_ctrl, data);

break;

+

+ case ACTUATOR_SET_OIS:

+ rc = actuator_set_ois(actuator_ctrl, data);

+ break;

2.3、将参数通过ioctl方法下至内核

+static int actuator_set_ois(void *ptr,

void *data) {

+ int rc = 0;

+ int32_t *ois_level = (int32_t*)data;

+ actuator_data_t *ois_actuator_ptr = (actuator_data_t

*)ptr;

+ struct msm_actuator_cfg_data cfg;

+ if (ois_actuator_ptr->fd <= 0)

+ return -EINVAL;

+ cfg.cfgtype = CFG_ACTUATOR_OIS;

+ cfg.cfg.setting = ois_level;

+

+ rc = ioctl(ois_actuator_ptr->fd, VIDIOC_MSM_ACTUATOR_CFG,

&cfg);

+ if (rc < 0) {

+ SERR("failed-errno: %s!!!",strerror(errno));

+ }

+ return rc;

+}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值