当前位置:网站首页>[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!
边栏推荐
- STM32 - introduction of external interrupts exti and NVIC
- 网络安全-DNS欺骗与钓鱼网站
- [shutter] animation animation (animatedwidget animation use process | create animation controller | create animation | create animatedwidget animation component | animation operation)
- One of the C language practical projects is greedy snake
- 小程序开发的部分功能
- Smart management of Green Cities: Digital twin underground integrated pipe gallery platform
- 网络安全-密码破解
- Everything文件搜索工具
- CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
- 英语常用词汇
猜你喜欢
![[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array](/img/2a/98400b0d0b5eda1e52abae30746f2b.jpg)
[North Asia data recovery] data recovery case of raid crash caused by hard disk disconnection during data synchronization of hot spare disk of RAID5 disk array
![[leetcode] 797 and 1189 (basis of graph theory)](/img/2a/9c0a904151a17c2d23dea9ad04dbfe.jpg)
[leetcode] 797 and 1189 (basis of graph theory)

Niuniu's ball guessing game (dynamic planning + prefix influence)
![[data mining] task 6: DBSCAN clustering](/img/af/ad7aa523b09884eee967c6773a613f.png)
[data mining] task 6: DBSCAN clustering

网络安全-漏洞与木马

Take you ten days to easily complete the go micro service series (II)

Steps to obtain SSL certificate private key private key file
![[QT] encapsulation of custom controls](/img/33/aa2ef625d1e51e945571c116a1f1a9.png)
[QT] encapsulation of custom controls

His experience in choosing a startup company or a big Internet company may give you some inspiration

自定义组件、使用npm包、全局数据共享、分包
随机推荐
Leetcode skimming questions_ Sum of two numbers II - enter an ordered array
C application interface development foundation - form control (3) - file control
One of the C language practical projects is greedy snake
Uniapp component -uni notice bar notice bar
Everything文件搜索工具
传输层 TCP主要特点和TCP连接
[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)
[data mining] task 6: DBSCAN clustering
【数据挖掘】任务5:K-means/DBSCAN聚类:双层正方形
Introduction to kotlin collaboration
树形结构数据的处理
How is the mask effect achieved in the LPL ban/pick selection stage?
网络安全-钓鱼
數學知識:臺階-Nim遊戲—博弈論
QTableWidget懒加载剩内存,不卡!
Network security - firewall
A simple tool for analyzing fgui dependencies
Types of map key and object key
网络安全-DNS欺骗与钓鱼网站
Caused by: com. fasterxml. jackson. databind. exc.MismatchedInputException: Cannot construct instance o