MTK camera info文件节点添加
2017-12-27 10:15
579 查看
MTK camera info文件节点添加
MTK camera info文件节点添加proc file创建function
废话少说直接上fucking code
1.proc file创建function:
struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, struct proc_dir_entry *parent, const struct file_operations *proc_fops, void *data);
2.废话少说,直接上fucking code:
#include <linux/string.h> #include <asm/uaccess.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/proc_fs.h> #include <linux/device.h> #include <linux/miscdevice.h> static int front_camera_otp_flag; static int rear_camera_otp_flag; static char front_camera_module_name[15]; static char rear_camera_module_name[15]; static char front_camera_ic_name[15]; static char rear_camera_ic_name[15]; void lct_camera_set_proc_otpinfo_flag(int index, int flag) { if (index == 0) { rear_camera_otp_flag = flag; } else if (index == 1) { front_camera_otp_flag = flag; } } void lct_camera_set_proc_camera_name(int index, char *module_name, char *ic_name) { if (index == 0) { strcpy(rear_camera_module_name, module_name); strcpy(rear_camera_ic_name, ic_name); } else if (index == 1) { strcpy(front_camera_module_name, module_name); strcpy(front_camera_ic_name, ic_name); } } static ssize_t camera_proc_camera_info_read(struct file *file, char __user *buff, size_t size, loff_t *ppos) { int cnt = 0; char *page = NULL; page = kzalloc(128, GFP_KERNEL); cnt = sprintf(page, "[FRONT_CAM_Module]:%s,[FRONT_CAM_IC]:%s,[REAR_CAM_Module]:%s,[REAR_CAM_IC]:%s\n", (strlen(front_camera_module_name) ? front_camera_module_name : "NULL"), (strlen(front_camera_ic_name) ? front_camera_ic_name : "NULL"), (strlen(rear_camera_module_name) ? rear_camera_module_name : "NULL"), (strlen(rear_camera_ic_name) ? rear_camera_ic_name : "NULL")); cnt = simple_read_from_buffer(buff, size, ppos, page, cnt); kfree(page); return cnt; } static ssize_t camera_proc_camera_otp_info_read(struct file *file, char __user *buff, size_t size, loff_t *ppos) { int cnt = 0; char *page = NULL; page = kzalloc(128, GFP_KERNEL); cnt = sprintf(page, "sub :%d,main :%d\n", front_camera_otp_flag, rear_camera_otp_flag); cnt = simple_read_from_buffer(buff, size, ppos, page, cnt); kfree(page); return cnt; } static const struct file_operations camera_proc_camera_info_fops = { .read = camera_proc_camera_info_read, }; static const struct file_operations camera_proc_camera_otp_info_fops = { .read = camera_proc_camera_otp_info_read, }; static int camera_create_proc_entry(void) { struct proc_dir_entry *proc_entry_camera; struct proc_dir_entry *proc_entry_camera_otp; //creat camera info proc proc_entry_camera = proc_create_data("camera_info", 0444, NULL, &camera_proc_camera_info_fops, NULL); if (IS_ERR_OR_NULL(proc_entry_camera)) { pr_err("%s:%d: add /proc/camera_info error!\n", __func__, __LINE__); } //creat camera otp info proc proc_entry_camera_otp = proc_create_data("otpinfo", 0444, NULL, &camera_proc_camera_otp_info_fops, NULL); if (IS_ERR_OR_NULL(proc_entry_camera_otp)) { pr_err("%s:%d: add /proc/camera_otp_info error!\n", __func__, __LINE__); } return 0; } static int __init lct_camera_info_init(void) { camera_create_proc_entry(); return 0; } static void __exit lct_camera_info_exit(void) { } module_init(lct_camera_info_init); module_exit(lct_camera_info_exit); MODULE_DESCRIPTION("Lct camera info driver"); MODULE_AUTHOR("Koson Liao <liaokesen@longcheer.com>"); MODULE_LICENSE("GPL");
相关文章推荐
- info.plist文件里面添加描述 -> 配置定位,相册等
- MTK 平台上如何给 camera 添加一种 preview size
- Android系统之路(初识MTK) ------ (详细精华)添加客供系统壁纸去除系统动态壁纸/Camera默认fine/remove android beam
- iOS 10中info.plist 文件 Privacy - Camera Usage Description等
- 在ASP.NET中实现多文件上传(以及添加节点的问题)(setAttribute())
- 读取文件内容并将内容添加到节点
- mapx 使用layerinfo 添加shape 文件层.(VB)
- 在shuiguo.xml文件中第三个水果中的苹果节点中添加节点<小苹果>small apple</小苹果>,添加小苹果后将其文本内容修改为“小苹果”,修改该节点后将其父节点苹果(即第三个苹果元素)删除
- MTK平台添加Camera设备信息
- 在Linux DeviceTree添加dtsi文件并在驱动中读取节点信息写入sys文件系统
- Spark添加/更改集群节点需要修改的配置文件
- iOS 10中info.plist 文件 Privacy - Camera Usage Description等
- dom4j解析xml文件,添加新节点,添加节点内容,读取文件中节点内容作为新增节点内容
- MTK 平台上如何给 camera 添加一种 preview size
- js动态创建style节点(js文件中添加css)
- Greenplum学习10--添加节点gpexpand ①(在每台segment加入一个节点)(生成节点配置文件)
- React-Native 在iOS9之后,网络请求默认为Https请求,如需支持Http,修改info.plist文件添加键值对设置允许http访问。
- MTK 平台上如何给 camera 添加一种 preview size
- MTK 平台上如何给 camera 添加一种 preview size
- mtk平台下,在makefile文件添加的宏不在了。