mtk camera架构_c语言源代码网站

mtk camera架构_c语言源代码网站Kd_camera_hw.c(custom\viroyal73\kernel\camera\camera)#include<linux/videodev2.h>#include<linux/i2c.h>#include<linux/platform_device.h>#include<linux/delay.h>#i…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

Kd_camera_hw.c (custom\viroyal73\kernel\camera\camera)

#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/fs.h>
#include <asm/atomic.h>

#include “kd_camera_hw.h”

//#include “kd_cust_image_sensor.h”
#include “kd_imgsensor.h”
#include “kd_imgsensor_define.h”
#include “kd_camera_feature.h”

/******************************************************************************
* Debug configuration
******************************************************************************/
#define PFX “[kd_camera_hw]”
#define PK_DBG_NONE(fmt, arg…) do {} while (0)
#define PK_DBG_FUNC(fmt, arg…) printk(KERN_INFO PFX “%s: ” fmt, __FUNCTION__ ,##arg)

#define DEBUG_CAMERA_HW_K
#ifdef DEBUG_CAMERA_HW_K
#define PK_DBG PK_DBG_FUNC
#define PK_ERR(fmt, arg…) printk(KERN_ERR PFX “%s: ” fmt, __FUNCTION__ ,##arg)
#else
#define PK_DBG(a,…)
#define PK_ERR(a,…)
#endif

int kdCISModulePowerOn(CAMERA_DUAL_CAMERA_SENSOR_ENUM SensorIdx, char *currSensorName, BOOL On, char* mode_name)
{

u32 pinSetIdx = 0;//default main sensor

#define IDX_PS_CMRST 0
#define IDX_PS_CMPDN 4

#define IDX_PS_MODE 1
#define IDX_PS_ON 2
#define IDX_PS_OFF 3
u32 pinSet[2][8] = {

//for main sensor
{GPIO_CAMERA_CMRST_PIN,
GPIO_CAMERA_CMRST_PIN_M_GPIO, /* mode */
GPIO_OUT_ONE, /* ON state */
GPIO_OUT_ZERO, /* OFF state */
GPIO_CAMERA_CMPDN_PIN,
GPIO_CAMERA_CMPDN_PIN_M_GPIO,
/*modified for OV5642, by tyd-lg, 2011-08-05*/
#if !defined(SID130B_YUV)
GPIO_OUT_ZERO,
GPIO_OUT_ONE,
#else
GPIO_OUT_ONE,
GPIO_OUT_ZERO,
#endif
},
//for sub sensor
{GPIO_CAMERA_CMRST1_PIN,
GPIO_CAMERA_CMRST1_PIN_M_GPIO,
GPIO_OUT_ONE,
GPIO_OUT_ZERO,
GPIO_CAMERA_CMPDN1_PIN,
GPIO_CAMERA_CMPDN1_PIN_M_GPIO,
GPIO_OUT_ZERO,
GPIO_OUT_ONE,
}
};

if (DUAL_CAMERA_MAIN_SENSOR == SensorIdx){

pinSetIdx = 0;
}
else if (DUAL_CAMERA_SUB_SENSOR == SensorIdx) {

pinSetIdx = 1;
}

//power ON
if (On) {

//in case
printk(“Set CAMERA_POWER_PULL_PIN for power \n”);
if (mt_set_gpio_pull_enable(GPIO_CAMERA_LDO_EN_PIN, GPIO_PULL_DISABLE)) {PK_DBG(“[[CAMERA SENSOR] Set CAMERA_POWER_PULL_PIN DISABLE ! \n”); }
if(mt_set_gpio_mode(GPIO_CAMERA_LDO_EN_PIN, GPIO_CAMERA_LDO_EN_PIN_M_GPIO)){PK_DBG(“[[CAMERA SENSOR] set CAMERA_POWER_PULL_PIN mode failed!! \n”);}
if(mt_set_gpio_dir(GPIO_CAMERA_LDO_EN_PIN,GPIO_DIR_OUT)){PK_DBG(“[[CAMERA SENSOR] set CAMERA_POWER_PULL_PIN dir failed!! \n”);}
if(mt_set_gpio_out(GPIO_CAMERA_LDO_EN_PIN,GPIO_OUT_ONE)){PK_DBG(“[[CAMERA SENSOR] set CAMERA_POWER_PULL_PIN failed!! \n”);}

if (currSensorName && (0 == strcmp(SENSOR_DRVNAME_OV3640_YUV,currSensorName)))
{

PK_DBG(“[ON_OV3640YUV case 1.5V]sensorIdx:%d \n”,SensorIdx);
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D, VOL_1500,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}
else if (currSensorName && (0 == strcmp(SENSOR_DRVNAME_OV5642_RAW, currSensorName))) {

PK_DBG(“[OV5642Raw Workaround,!!!!!!!!!!!!!!!!\n”);
PK_DBG(“[ON_OV5642Raw case 2.8V IO_Temperal Workaround]sensorIdx:%d \n”,SensorIdx);
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D2, VOL_2800,mode_name)) {

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}
else //general case on
{

PK_DBG(“[ON_general 1.8V]sensorIdx:%d \n”,SensorIdx);
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D2, VOL_1800,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}

if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_A, VOL_2800,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable analog power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}

if (currSensorName && (0 == strcmp(SENSOR_DRVNAME_IMX073_MIPI_RAW,currSensorName))){

PK_DBG(“[ON_general 1.3V]sensorIdx:%d \n”,SensorIdx);
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D, VOL_1300,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}
else if (currSensorName && (0 == strcmp(SENSOR_DRVNAME_SIV121D_YUV,currSensorName))){

PK_DBG(“[ON_general 1.8V]sensorIdx:%d \n”,SensorIdx);
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D, VOL_1800,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}
else if (currSensorName && (0 == strcmp(SENSOR_DRVNAME_SID130B_YUV,currSensorName))){

PK_DBG(“[ON_general 1.8V]sensorIdx:%d \n”,SensorIdx);
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D, VOL_1800,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}
else if (currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC0329_YUV,currSensorName))){

PK_DBG(“[ON_general 1.8V]sensorIdx:%d \n”,SensorIdx);
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D, VOL_1800,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}
else
{ // general case on
PK_DBG(“[ON_general 1.5V]sensorIdx:%d \n”,SensorIdx);
if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_D, VOL_1500,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}

if(TRUE != hwPowerOn(CAMERA_POWER_VCAM_A2, VOL_2800,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable analog power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}

// wait power to be stable
mdelay(5);
//disable inactive sensor
if (GPIO_CAMERA_INVALID != pinSet[1-pinSetIdx][IDX_PS_CMRST]) {

printk(“A6-camera: disable inactive sensor, pinSetIdx = %d\n”, pinSetIdx);
printk(“A6-camera: operate CMRST = GPIO_%d, PS_OFF = %d\n”, pinSet[1-pinSetIdx][IDX_PS_CMRST], pinSet[1-pinSetIdx][IDX_PS_CMRST+IDX_PS_OFF]);
printk(“A6-camera: operate CMPDN = GPIO_%d, PS_OFF = %d\n”, pinSet[1-pinSetIdx][IDX_PS_CMPDN], pinSet[1-pinSetIdx][IDX_PS_CMPDN+IDX_PS_OFF]);

if(mt_set_gpio_mode(pinSet[1-pinSetIdx][IDX_PS_CMRST],pinSet[1-pinSetIdx][IDX_PS_CMRST+IDX_PS_MODE])){PK_DBG(“[CAMERA SENSOR] set gpio mode failed!! \n”);}
if(mt_set_gpio_mode(pinSet[1-pinSetIdx][IDX_PS_CMPDN],pinSet[1-pinSetIdx][IDX_PS_CMPDN+IDX_PS_MODE])){PK_DBG(“[CAMERA LENS] set gpio mode failed!! \n”);}
if(mt_set_gpio_dir(pinSet[1-pinSetIdx][IDX_PS_CMRST],GPIO_DIR_OUT)){PK_DBG(“[CAMERA SENSOR] set gpio dir failed!! \n”);}
if(mt_set_gpio_dir(pinSet[1-pinSetIdx][IDX_PS_CMPDN],GPIO_DIR_OUT)){PK_DBG(“[CAMERA LENS] set gpio dir failed!! \n”);}
if(mt_set_gpio_out(pinSet[1-pinSetIdx][IDX_PS_CMRST],pinSet[1-pinSetIdx][IDX_PS_CMRST+IDX_PS_OFF])){PK_DBG(“[CAMERA SENSOR] set gpio failed!! \n”);} //low == reset sensor
if(mt_set_gpio_out(pinSet[1-pinSetIdx][IDX_PS_CMPDN],pinSet[1-pinSetIdx][IDX_PS_CMPDN+IDX_PS_OFF])){PK_DBG(“[CAMERA LENS] set gpio failed!! \n”);} //high == power down lens module
}

//enable active sensor
//RST pin
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST]) {

//PDN pin
printk(“A6-camera: enable inactive sensor, pinSetIdx = %d\n”, pinSetIdx);
printk(“A6-camera: operate CMRST = GPIO_%d, PS_OFF = %d\n”, pinSet[pinSetIdx][IDX_PS_CMRST], pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_OFF]);
printk(“A6-camera: operate CMPDN = GPIO_%d, PS_OFF = %d\n”, pinSet[pinSetIdx][IDX_PS_CMPDN], pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_OFF]);
if(mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_MODE])){PK_DBG(“[CAMERA LENS] set gpio mode failed!! \n”);}
if(mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMPDN],GPIO_DIR_OUT)){PK_DBG(“[CAMERA LENS] set gpio dir failed!! \n”);}
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_ON])){PK_DBG(“[CAMERA LENS] set gpio failed!! \n”);}

if(mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_MODE])){PK_DBG(“[CAMERA SENSOR] set gpio mode failed!! \n”);}
if(mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMRST],GPIO_DIR_OUT)){PK_DBG(“[CAMERA SENSOR] set gpio dir failed!! \n”);}
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_OFF])){PK_DBG(“[CAMERA SENSOR] set gpio failed!! \n”);}
mdelay(5);
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_ON])){PK_DBG(“[CAMERA SENSOR] set gpio failed!! \n”);}
mdelay(5);

}
#ifdef GPIO_CAMERA_AF_EN_PIN
//@ for main to enable AF
if (pinSetIdx == 0) {

if(mt_set_gpio_mode(GPIO_CAMERA_AF_EN_PIN, GPIO_MODE_00)){PK_DBG(“[CAMERA SENSOR AF ] set gpio mode failed!! \n”);}
if(mt_set_gpio_dir(GPIO_CAMERA_AF_EN_PIN,GPIO_DIR_OUT)){PK_DBG(“[CAMERA SENSOR] set gpio dir failed!! \n”);}
if(mt_set_gpio_out(GPIO_CAMERA_AF_EN_PIN,GPIO_OUT_ONE)){PK_DBG(“[CAMERA SENSOR] set gpio failed!! \n”);} //low == reset sensor
}
#endif
}
else {//power OFF
printk(“Set GPIO 94 for power OFF\n”);
if (mt_set_gpio_pull_enable(GPIO_CAMERA_LDO_EN_PIN, GPIO_PULL_DISABLE)) {PK_DBG(“[CAMERA SENSOR] Set GPIO94 PULL DISABLE ! \n”); }
if(mt_set_gpio_mode(GPIO_CAMERA_LDO_EN_PIN, GPIO_CAMERA_LDO_EN_PIN_M_GPIO)){PK_DBG(“[CAMERA SENSOR] set gpio mode failed!! \n”);}
if(mt_set_gpio_dir(GPIO_CAMERA_LDO_EN_PIN,GPIO_DIR_OUT)){PK_DBG(“[CAMERA SENSOR] set gpio dir failed!! \n”);}
if(mt_set_gpio_out(GPIO_CAMERA_LDO_EN_PIN,GPIO_OUT_ZERO)){PK_DBG(“[CAMERA SENSOR] set gpio failed!! \n”);}

//PK_DBG(“[OFF]sensorIdx:%d \n”,SensorIdx);
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST]) {

printk(“A6-camera: off sensor, pinSetIdx = %d\n”, pinSetIdx);
printk(“A6-camera: operate CMRST = GPIO_%d, PS_OFF = %d\n”, pinSet[pinSetIdx][IDX_PS_CMRST], pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_OFF]);
printk(“A6-camera: operate CMPDN = GPIO_%d, PS_OFF = %d\n”, pinSet[pinSetIdx][IDX_PS_CMPDN], pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_OFF]);
if(mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_MODE])){PK_DBG(“[CAMERA SENSOR] set gpio mode failed!! \n”);}
if(mt_set_gpio_mode(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_MODE])){PK_DBG(“[CAMERA LENS] set gpio mode failed!! \n”);}
if(mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMRST],GPIO_DIR_OUT)){PK_DBG(“[CAMERA SENSOR] set gpio dir failed!! \n”);}
if(mt_set_gpio_dir(pinSet[pinSetIdx][IDX_PS_CMPDN],GPIO_DIR_OUT)){PK_DBG(“[CAMERA LENS] set gpio dir failed!! \n”);}
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMRST],pinSet[pinSetIdx][IDX_PS_CMRST+IDX_PS_OFF])){PK_DBG(“[CAMERA SENSOR] set gpio failed!! \n”);} //low == reset sensor
if(mt_set_gpio_out(pinSet[pinSetIdx][IDX_PS_CMPDN],pinSet[pinSetIdx][IDX_PS_CMPDN+IDX_PS_OFF])){PK_DBG(“[CAMERA LENS] set gpio failed!! \n”);} //high == power down lens module
}

#ifdef GPIO_CAMERA_AF_EN_PIN
//@ for main to disable AF
if (pinSetIdx == 0) {

if(mt_set_gpio_mode(GPIO_CAMERA_AF_EN_PIN, GPIO_MODE_00)){PK_DBG(“[CAMERA SENSOR AF ] set gpio mode failed!! \n”);}
if(mt_set_gpio_dir(GPIO_CAMERA_AF_EN_PIN,GPIO_DIR_OUT)){PK_DBG(“[CAMERA SENSOR] set gpio dir failed!! \n”);}
if(mt_set_gpio_out(GPIO_CAMERA_AF_EN_PIN,GPIO_OUT_ZERO)){PK_DBG(“[CAMERA SENSOR] set gpio failed!! \n”);} //low == reset sensor
}
#endif

if(TRUE != hwPowerDown(CAMERA_POWER_VCAM_A,mode_name)) {

PK_DBG(“[CAMERA SENSOR] Fail to OFF analog power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
if(TRUE != hwPowerDown(CAMERA_POWER_VCAM_A2,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable analog power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
if(TRUE != hwPowerDown(CAMERA_POWER_VCAM_D, mode_name)) {

PK_DBG(“[CAMERA SENSOR] Fail to OFF digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
if(TRUE != hwPowerDown(CAMERA_POWER_VCAM_D2,mode_name))
{

PK_DBG(“[CAMERA SENSOR] Fail to enable digital power\n”);
//return -EIO;
goto _kdCISModulePowerOn_exit_;
}
}//

return 0;

_kdCISModulePowerOn_exit_:
return -EIO;
}

EXPORT_SYMBOL(kdCISModulePowerOn);

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/226763.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号