当前位置:网站首页>[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!
边栏推荐
- 网络安全-破解系统密码
- 【数据挖掘】任务4:20Newsgroups聚类
- 并发编程的三大核心问题 -《深入理解高并发编程》
- One of the C language practical projects is greedy snake
- [AUTOSAR cantp] -2.11-uds diagnostic response frame data segment data padding data filling and data optimization data optimization (Theory + configuration)
- [data mining] task 6: DBSCAN clustering
- 【Camera专题】Camera dtsi 完全解析
- 【数据挖掘】任务5:K-means/DBSCAN聚类:双层正方形
- [机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
- C语言课程信息管理系统
猜你喜欢
[机缘参悟-36]:鬼谷子-飞箝篇 - 面对捧杀与诱饵的防范之道
自定义组件、使用npm包、全局数据共享、分包
[technology development-23]: application of DSP in future converged networks
网络安全-漏洞与木马
Why is it not recommended to use BeanUtils in production?
Three core issues of concurrent programming - "deep understanding of high concurrent programming"
"Jetpack - livedata parsing"
Introduction to flask tutorial
C application interface development foundation - form control (3) - file control
传输层 TCP主要特点和TCP连接
随机推荐
High resolution network (Part 1): Principle Analysis
Uniapp component -uni notice bar notice bar
Analysis, use and extension of open source API gateway apisex
SSL flood attack of DDoS attack
Why is it not recommended to use BeanUtils in production?
[understanding of opportunity -36]: Guiguzi - flying clamp chapter - prevention against killing and bait
Network security - Trojan horse
Why can't the start method be called repeatedly? But the run method can?
Force buckle 204 Count prime
[error record] navigator operation requested with a context that does not include a naviga
小程序开发的部分功能
网络安全-木马
CF1617B Madoka and the Elegant Gift、CF1654C Alice and the Cake、 CF1696C Fishingprince Plays With Arr
[shutter] animation animation (animatedbuilder animation use process | create animation controller | create animation | create components for animation | associate animation with components | animatio
Network security - DNS spoofing and phishing websites
Everything file search tool
7-25 read numbers (loop switch)
【QT】自定义控件的封装
技术大佬准备就绪,话题C位由你决定
Huakaiyun | virtual host: IP, subnet mask, gateway, default gateway