当前位置:网站首页>[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!
边栏推荐
- Why is it not recommended to use BeanUtils in production?
- Three core issues of concurrent programming - "deep understanding of high concurrent programming"
- 【数据挖掘】任务1:距离计算
- C application interface development foundation - form control (3) - file control
- [data mining] task 6: DBSCAN clustering
- [interview question] 1369 when can't I use arrow function?
- Network security OpenVAS
- [shutter] animation animation (basic process of shutter animation | create animation controller | create animation | set value listener | set state listener | use animation values in layout | animatio
- Network security - phishing
- [data mining] task 4:20newsgroups clustering
猜你喜欢
![[fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)](/img/68/65b8c0530cfdc92ba4f583b0162544.gif)
[fluent] hero animation (hero animation use process | create hero animation core components | create source page | create destination page | page Jump)

High resolution network (Part 1): Principle Analysis

Everything file search tool
![[data mining] task 1: distance calculation](/img/72/a63cdfe32a7c438acf48a069d9bba1.png)
[data mining] task 1: distance calculation

¢ growth path and experience sharing of getting an offer

How is the mask effect achieved in the LPL ban/pick selection stage?

小程序開發的部分功能

"Jetpack - livedata parsing"

LeetCode 987. Vertical order transverse of a binary tree - Binary Tree Series Question 7

What is tone. Diao's story
随机推荐
[data mining] task 2: mimic-iii data processing of medical database
2022-02-15 reading the meta module inspiration of the influxdb cluster
NCTF 2018 part Title WP (1)
Problems encountered in small program development of dark horse shopping mall
[technology development-23]: application of DSP in future converged networks
[error record] the shutter component reports an error (no directionality widget found. | richtext widgets require a directionality)
【数据挖掘】任务4:20Newsgroups聚类
【QT】自定义控件的封装
网络安全-动态路由协议RIP
How to refresh the opening amount of Oracle ERP
A simple tool for analyzing fgui dependencies
Huakaiyun (Zhiyin) | virtual host: what is a virtual host
Network security OpenVAS
¢ growth path and experience sharing of getting an offer
Network security - virus
String splicing function of MySQL
【数据挖掘】任务3:决策树分类
Network security - the simplest virus
C application interface development foundation - form control (2) - MDI form
QTableWidget懒加载剩内存,不卡!