当前位置:网站首页>[camera topic] how to save OTP data in user-defined nodes
[camera topic] how to save OTP data in user-defined nodes
2022-07-03 01:50:00 【C maple_ The day of shopping】
One 、 Preface
Before because lsc Cause the green screen problem , The module factory said lsc The data is abnormal ,
sensor factory fae There is no follow-up cooperation , Just a joke , Let's save otp data ,
It is convenient to compare when something goes wrong , And then there's no then . Support suck , Poor attitude .
If yes OTP Not very familiar with , First read the previous article !
OTP Programming complete guide points 、 Next 2 piece .
On : The main speak OTP Knowledge and debugging process .
Next : The main speak OTP Source code .
Qcom- qualcomm OTP Programming and debugging guide - On
Qcom- qualcomm OTP Programming and debugging guide - Next
Two 、 Knowledge point
Actually , These data are in kernel Layers are printed , Pictured :
But the people in the system team say this log That's too much , influence kernel Start of , Want us to save in the node , adopt cat Command to get .
2.1 General idea
- 1. Create nodes
- 2. Realization read function ( Use cat When you order, you will actively adjust read function )
2.2 Concrete realization
kernel/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
#include <linux/debugfs.h> // The required header file
#define OTP_SZIE_S5K4H7 400 //otp data size
static uint8_t otp_lsc_temp[OTP_SZIE_S5K4H7];// Array , Used to save data
char otp_lsc_buffer[1024];// Array , Used to save data
#define OTP_LSC_DATA "data"
#define OTP_LSC_PATH "/sys/kernel/debug/otp/lsc_data" // Node path
// Read function
ssize_t read_otp_lsc(struct file *filp, char __user *userbuf,
size_t count, loff_t *ppos)
{
int i;
int j = 1;
char temp[OTP_SZIE_S5K4H7] = {
0};
CDBG("zcf read_otp_lsc enter\n");
memset(otp_lsc_buffer, 0, sizeof(otp_lsc_buffer));
strlcat(otp_lsc_buffer, "AWB:\n", sizeof(otp_lsc_buffer));//AWB data
for (i = 0; i < OTP_SZIE_S5K4H7; i++) {
snprintf(temp, sizeof(temp), "%02x", otp_lsc_temp[i]);
strlcat(otp_lsc_buffer, temp, sizeof(otp_lsc_buffer));
strlcat(otp_lsc_buffer, " ", sizeof(otp_lsc_buffer));
if(i == 59)// front 60 Yes AWB data
strlcat(otp_lsc_buffer, "\nLSC:\n", sizeof(otp_lsc_buffer));
if(i == 10*j-1)// Per print 10 A number changes the line
{
j++;
strlcat(otp_lsc_buffer, "\r\n", sizeof(otp_lsc_buffer));
}
}
strlcat(otp_lsc_buffer, "\r\n", sizeof(otp_lsc_buffer));// Line break
return simple_read_from_buffer(userbuf, count,
ppos, otp_lsc_buffer, strlen(otp_lsc_buffer));
}
static const struct file_operations otp_lsc_fops = {
.read = read_otp_lsc,// Assignment read function
};
// Create nodes /sys/kernel/debug/otp/lsc_data
static int otp_init_debugfs(void)
{
int ret = 0;
struct dentry *root;
root = debugfs_create_dir("otp", NULL);
if(!root)
{
CDBG("zcf %s debugfs_create_dir(otp) failed\n", __func__);
ret = -ENOMEM;
return ret;
}
if (!debugfs_create_file(OTP_LSC_DATA,
0666,
root,
NULL,
&otp_lsc_fops));
{
CDBG("zcf %s failed to create lsc_data debugfs file\n", __func__);
ret = -ENOMEM;
return ret;
}
return ret;
}
Where to call
static int msm_eeprom_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
··· Omitted code
// stay probe Create nodes in
++ otp_init_debugfs();
··· Omitted code
rc = read_eeprom_memory(e_ctrl, &e_ctrl->cal_data);// Data will be read here
++ if(0 == strcmp(eb_info->eeprom_name,"sunwin_s5k4h7")){
++ pr_err("zcf [sensor: s5k4h7]save the otp data\n");
++ for (j = 0; j < e_ctrl->cal_data.num_data; j++)
// Save the read data in a temporary array otp_lsc_temp in
++ otp_lsc_temp[j] = e_ctrl->cal_data.mapdata[j];
++ }
··· Omitted code
}
result
3、 ... and 、 Create a camera node , preservation sensor name
kernel/msm-4.9/drivers/media/platform/msm/camera_v2/sensor/msm_sensor_driver.c
/* * Create nodes * 1. /sys/kernel/debug/bbk_camera/back_cam_name * 2. /sys/kernel/debug/bbk_camera/front_cam_name */
char front_name_buffer[32]="NULL";// Proactive name
char back_name_buffer[32]="NULL";// Post shot name
ssize_t read_front_name(struct file *filp, char __user *userbuf,
size_t count, loff_t *ppos)
{
char kbuf[32]="NULL";
sprintf(kbuf, "%s\n", front_name_buffer);
return simple_read_from_buffer(userbuf, count,ppos, kbuf, strlen(kbuf));
}
ssize_t read_back_name(struct file *filp, char __user *userbuf,
size_t count, loff_t *ppos)
{
char kbuf[32]="NULL";
sprintf(kbuf, "%s\n", back_name_buffer);
return simple_read_from_buffer(userbuf, count,ppos, kbuf, strlen(kbuf));
}
static const struct file_operations front_camera_fops = {
.read = read_front_name,// Assignment read function
};
static const struct file_operations back_camera_fops = {
.read = read_back_name,// Assignment read function
};
static int camera_node_create(void)
{
int ret = 0;
struct dentry *root;
root = debugfs_create_dir("bbk_camera", NULL);
if(!root)
{
CDBG("zcf %s debugfs_create_dir(bbk_camera) failed\n", __func__);
ret = -ENOMEM;
return ret;
}
if(root){
debugfs_create_file("front_cam_name",
0666,
root,
NULL,
&front_camera_fops);
debugfs_create_file("back_cam_name",
0666,
root,
NULL,
&back_camera_fops);
}
return ret;
}
int32_t msm_sensor_driver_probe(void *setting,
struct msm_sensor_info_t *probed_info, char *entity_name)
{
···
camera_node_create();
pr_err("%s probe succeeded", slave_info->sensor_name);
···
if(slave_info->sensor_init_params.position == 1) {
strlcpy(front_name_buffer, slave_info->sensor_name,
sizeof(front_name_buffer));
CDBG("front_name_buffer= %s\n",front_name_buffer);
}else {
strlcpy(back_name_buffer, slave_info->sensor_name,
sizeof(back_name_buffer));
CDBG("back_name_buffer= %s\n",back_name_buffer);
}
···
}
result
Stay Hungry,Stay Foolish!
边栏推荐
- Network security - firewall
- C application interface development foundation - form control (1) - form form
- 并发编程的三大核心问题 -《深入理解高并发编程》
- ¢ growth path and experience sharing of getting an offer
- Everything file search tool
- 云原生题目整理(待更新)
- Take you ten days to easily complete the go micro service series (I)
- Leetcode skimming questions_ Sum of two numbers II - enter an ordered array
- Problems encountered in small program development of dark horse shopping mall
- 【數據挖掘】任務6:DBSCAN聚類
猜你喜欢
【Camera专题】OTP数据如何保存在自定义节点中
In the face of difficult SQL requirements, HQL is not afraid
小程序开发的部分功能
并发编程的三大核心问题 -《深入理解高并发编程》
STM32 - Application of external interrupt induction lamp
LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7
传输层 TCP主要特点和TCP连接
网络安全-漏洞与木马
【Camera专题】Camera dtsi 完全解析
Niuniu's ball guessing game (dynamic planning + prefix influence)
随机推荐
疫情当头,作为Leader如何进行团队的管理?| 社区征文
Take you ten days to easily complete the go micro service series (I)
Network security OpenVAS
自定义组件、使用npm包、全局数据共享、分包
STM32 - switch of relay control lamp
Pytest learning notes (12) -allure feature · @allure Step () and allure attach
Network security - password cracking
Vant 实现简单的登录注册模块以及个人用户中心
[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
[data mining] task 6: DBSCAN clustering
Some functions of applet development
Niuniu's ball guessing game (dynamic planning + prefix influence)
NCTF 2018 part Title WP (1)
Cloud native topic sorting (to be updated)
网络安全-防火墙
STM32 - introduction of external interrupts exti and NVIC
【数据挖掘】任务2:医学数据库MIMIC-III数据处理
QTableWidget懒加载剩内存,不卡!
How is the mask effect achieved in the LPL ban/pick selection stage?
[shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)