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)


相关推荐

  • Java面向对象编程三大特征 – 封装

    Java面向对象编程三大特征 – 封装本文关键字:Java、面向对象、三大特征、封装。封装是面向对象编程中的三大特征之一,在对封装性进行解释时我们有必要先了解一些面向对象的思想,以及相关的概念。

  • Python全国二级等级考试(2019)

    Python全国二级等级考试(2019)

  • Qt 5.14.1 安装详解「建议收藏」

    Qt 5.14.1 安装详解「建议收藏」1、打开安装包qt-opensource-windows-x86-5.14.1.exe,next2、这里需要登录(点击这里注册:https://www.qt.io/)3、选择同意,下一步,下一步4、选择安装目录(需要大约3.2G的空间大小)5、选择组件(非常重要)6、同意许可协议,点击下一步,安装…

  • Python和Pycharm安装与卸载教程「建议收藏」

    Python和Pycharm安装与卸载教程「建议收藏」简介Python解释器通常我们说的Python是指一种跨平台的程序设计语言,而我们这里说的安装Python是指安装Python解释器,只有安装Python解释器你的计算机才能读懂Python语言。PycharmPycharm是一种PythonIDE(集成开发环境),带有一整套帮助Python开发的高效率工具。Pycharm分为专业版(Professional,收费)和社区版(community,免费)。只需要python基础功能可以下载社区版,想要解锁更多功能下载专业版。ps:学生可以申请免

  • extremedb是开源的吗_最简单的数据库开发软件

    extremedb是开源的吗_最简单的数据库开发软件最近我接触了嵌入式数据库eXtremeDB,由于这方面资料很少,网上的参考资料都大同小异,只靠着软件本身提供的参考文档进行开发,所以刚开始开发有些困难。故将基本的用法整理一下。关于eXtremeDB的特性,这里就不阐述了,直接从开发开始。下面以简单的模板为例进行阐述。1.构建.mco文件打开记事本,然后另存为XX.mco后缀文件。.mco文件里面需要定义数据库所需的字段类型,名称等,…

    2022年10月14日
  • html js 数组添加,js数组添加数据

    html js 数组添加,js数组添加数据我们在学习python的过程中,会对列表、字符串添加数据。在Javascript中,我们也会对数组添加数据。在不同的位置添加数据有着不同的方法。本文介绍js数组添加数据的三种方法:1、结尾添加push()方法;2、头部添加unshift()方法;3、向/从数组指定位置添加/删除项目,然后返回被删除的项目splice()方法。方式一:结尾添加push()方法1、语法arrayObject.pus…

发表回复

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

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