概述
(1)源码参考
本篇文章实作环境是:调试效果或debug sensor register时需要动态读写sensor寄存器应该怎样修改代码?
目前参考的代码是Kernel-4.19,具体每个kernel版本可能都差不多,这里我们只看Main Sensor。
//kernel-4.19/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_proc.c
enum IMGSENSOR_RETURN imgsensor_proc_init(void)
{
memset(mtk_ccm_name, 0, camera_info_size);
//proc/driver/下创建相关的节点
proc_create("driver/camsensor", 0664, NULL, &fcamera_proc_fops);
proc_create("driver/camsensor2", 0664, NULL, &fcamera_proc_fops2);
proc_create("driver/camsensor3", 0664, NULL, &fcamera_proc_fops3);
proc_create("driver/camsensor4", 0664, NULL, &fcamera_proc_fops4);
proc_create(
"driver/pdaf_type", 0664, NULL, &fcamera_proc_fops_set_pdaf_type);
proc_create(PROC_SENSOR_STAT, 0664, NULL, &fcamera_proc_fops_status);
/* Camera information */
proc_create(PROC_CAMERA_INFO, 0664, NULL, &fcamera_proc_fops1);
return IMGSENSOR_RETURN_SUCCESS;
}
//proc/driver/camsensor节点
static const struct file_operations fcamera_proc_fops = {
.owner = THIS_MODULE,
.read = seq_read,
.open = proc_camsensor_open,
.write = CAMERA_HW_Reg_Debug
};
/************************************************************************
* CAMERA_HW_Reg_Debug()
* Used for sensor register read/write by proc file
************************************************************************/
static ssize_t CAMERA_HW_Reg_Debug(
struct file *file,
const char *buffer,
size_t count,
loff_t *data)
{
char regBuf[64] = { '