高通 6125平台 显示分辨率自适应

news/2024/11/14 19:54:13/

文档说明

需要Android系统发布后可改变显示分辨率的功能

修改方法

From c105b648c960f54c714a563829f833e6f048ad2e Mon Sep 17 00:00:00 2001
From: liuxingrong <hing.liu@fibocom.com>
Date: Tue, 27 Sep 2022 10:43:04 +0800
Subject: [PATCH] carplay-dynamic_resolution---.../QcomModulePkg/Include/Library/Recovery.h  |   2 +.../QcomModulePkg/Library/BootLib/BootLib.inf |   1 +.../QcomModulePkg/Library/BootLib/Recovery.c  |  30 ++.../Library/BootLib/UpdateCmdLine.c           |  18 +-.../edk2/QcomModulePkg/QcomModulePkg.dec      |   1 +.../boot/dts/qcom/sc138-evk/trinket.dtsi      |   4 +kernel/msm-4.14/drivers/Makefile              |   1 +.../gpu/drm/msm/dsi-staging/dsi_panel.c       |  58 ++-kernel/msm-4.14/drivers/pdata/Makefile        |   1 +kernel/msm-4.14/drivers/pdata/pdata.c         | 366 ++++++++++++++++++kernel/msm-4.14/include/linux/pdata.h         |  62 +++11 files changed, 542 insertions(+), 2 deletions(-)mode change 100644 => 100755 bootable/bootloader/edk2/QcomModulePkg/Include/Library/Recovery.hmode change 100644 => 100755 bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/BootLib.infmode change 100644 => 100755 bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/Recovery.cmode change 100644 => 100755 bootable/bootloader/edk2/QcomModulePkg/QcomModulePkg.decmode change 100644 => 100755 kernel/msm-4.14/drivers/Makefilemode change 100644 => 100755 kernel/msm-4.14/drivers/gpu/drm/msm/dsi-staging/dsi_panel.ccreate mode 100755 kernel/msm-4.14/drivers/pdata/Makefilecreate mode 100755 kernel/msm-4.14/drivers/pdata/pdata.ccreate mode 100755 kernel/msm-4.14/include/linux/pdata.hdiff --git a/bootable/bootloader/edk2/QcomModulePkg/Include/Library/Recovery.h b/bootable/bootloader/edk2/QcomModulePkg/Include/Library/Recovery.h
old mode 100644
new mode 100755
index b1305b92e3..0212fc7175
--- a/bootable/bootloader/edk2/QcomModulePkg/Include/Library/Recovery.h
+++ b/bootable/bootloader/edk2/QcomModulePkg/Include/Library/Recovery.h
@@ -48,5 +48,7 @@ RecoveryInit (BOOLEAN *BootIntoRecovery);EFI_STATUSGetFfbmCommand (CHAR8 *FfbmMode, UINT32 Sz);EFI_STATUS
+GetPrivdata (unsigned char *PrivdataArr, UINT32 PrivdataSize);
+EFI_STATUSWriteRecoveryMessage (CHAR8 *Command);#endif
diff --git a/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/BootLib.inf b/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/BootLib.inf
old mode 100644
new mode 100755
index 4bb91f5ee3..b509770499
--- a/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/BootLib.inf
+++ b/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/BootLib.inf
@@ -111,6 +111,7 @@gEfiNandUserPartitionGuidgEfiMiscPartitionGuidgEfiRNGAlgRawGuid
+	gEfiPrivdata1PartitionGuidgEfiUfsLU0GuidgEfiUfsLU1GuidgEfiUfsLU2Guid
diff --git a/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/Recovery.c b/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/Recovery.c
old mode 100644
new mode 100755
index c7f8c4dea9..ed7497775f
--- a/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/Recovery.c
+++ b/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/Recovery.c
@@ -247,3 +247,33 @@ GetFfbmCommand (CHAR8 *FfbmString, UINT32 Sz)return Status;}
+
+EFI_STATUS
+GetPrivdata (unsigned char *PrivdataArr, UINT32 PrivdataSize)
+{
+  unsigned char *PrivData = NULL;
+  EFI_STATUS Status;
+  EFI_GUID Ptype = gEfiPrivdata1PartitionGuid;
+  MemCardType CardType = UNKNOWN;
+
+  CardType = CheckRootDeviceType();
+  if (CardType == NAND) {
+    Status = GetNandMiscPartiGuid (&Ptype);
+    if (Status != EFI_SUCCESS) {
+      return Status;
+    }
+  }
+
+  Status = ReadFromPartition(&Ptype, (VOID **)&PrivData, PrivdataSize);
+  if (Status != EFI_SUCCESS) {
+    DEBUG ((EFI_D_ERROR, "Error Reading private data from privdata1: %r\n", Status));
+    return Status;
+  }
+
+  gBS->CopyMem((VOID *)PrivdataArr, (VOID *)PrivData, PrivdataSize);
+
+  FreePool (PrivData);
+  PrivData = NULL;
+
+  return Status;
+}
diff --git a/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/UpdateCmdLine.c b/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
index b165f3d4fd..596a20c09f 100755
--- a/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
+++ b/bootable/bootloader/edk2/QcomModulePkg/Library/BootLib/UpdateCmdLine.c
@@ -80,6 +80,12 @@ STATIC UINTN DisplayCmdLineLen = sizeof (DisplayCmdLine);STATIC CHAR8 *AndroidBootDtboIdx = " androidboot.dtbo_idx=";STATIC CHAR8 *AndroidBootDtbIdx = " androidboot.dtb_idx=";+#define PRIVATE_DATA_SIZE       16
+unsigned char Privdata[PRIVATE_DATA_SIZE] = {'\0'};
+
+int width,heigh;
+int len;
+EFI_STATUSTargetPauseForBatteryCharge (BOOLEAN *BatteryStatus){
@@ -723,11 +729,21 @@ UpdateCmdLine (CONST CHAR8 *CmdLine,"%a%d", AndroidBootDtboIdx, DtboIdx);CmdLineLen += AsciiStrLen (DtboIdxStr);}
+	
+	GetPrivdata(Privdata, PRIVATE_DATA_SIZE);
+	len = Privdata[0] - '0';
+	for(int i = 0; i < len;i++){
+		width = width * 10 + Privdata[1+i] - '0';
+	}
+	len = Privdata[6] - '0';
+	for(int i = 0; i < len;i++){
+		heigh = heigh * 10 + Privdata[7+i] - '0';
+	}DtbIdx = GetDtbIdx ();if (DtbIdx != INVALID_PTN) {AsciiSPrint (DtbIdxStr, sizeof (DtbIdxStr),
-                   "%a%d", AndroidBootDtbIdx, DtbIdx);
+                   "%a%d%a%dx%d", AndroidBootDtbIdx, DtbIdx," panel_size=",width,heigh);CmdLineLen += AsciiStrLen (DtbIdxStr);}}
diff --git a/bootable/bootloader/edk2/QcomModulePkg/QcomModulePkg.dec b/bootable/bootloader/edk2/QcomModulePkg/QcomModulePkg.dec
old mode 100644
new mode 100755
index eefbc80ef6..19df0dc190
--- a/bootable/bootloader/edk2/QcomModulePkg/QcomModulePkg.dec
+++ b/bootable/bootloader/edk2/QcomModulePkg/QcomModulePkg.dec
@@ -88,6 +88,7 @@gEfiMdtpPartitionGuid =               { 0x3878408A, 0xE263, 0x4B67, { 0xB8, 0x78, 0x63, 0x40, 0xB3, 0x5B, 0x11, 0xE3 } }gBlockIoRefreshGuid =                 { 0xb1eb3d10, 0x9d67, 0x40ca, { 0x95, 0x59, 0xf1, 0x48, 0x8b, 0x1b, 0x2d, 0xdb } }gEfiRNGAlgRawGuid =                   { 0xe43176d7, 0xb6e8, 0x4827, { 0xb7, 0x84, 0x7f, 0xfd, 0xc4, 0xb6, 0x85, 0x61 } }
+  gEfiPrivdata1PartitionGuid =          { 0xD4AA7D5D, 0x40A6, 0x4755, { 0x8A, 0x6A, 0x5B, 0x94, 0x2D, 0xB8, 0x1B, 0x56 } }[Protocols]# SCM
diff --git a/kernel/msm-4.14/arch/arm64/boot/dts/qcom/sc138-evk/trinket.dtsi b/kernel/msm-4.14/arch/arm64/boot/dts/qcom/sc138-evk/trinket.dtsi
index 76add9aad3..6577718569 100755
--- a/kernel/msm-4.14/arch/arm64/boot/dts/qcom/sc138-evk/trinket.dtsi
+++ b/kernel/msm-4.14/arch/arm64/boot/dts/qcom/sc138-evk/trinket.dtsi
@@ -3026,6 +3026,10 @@#include "trinket-thermal.dtsi"&soc {
+	pdata_driver: pdata_driver {
+			compatible = "fibo,pdata_driver";
+	};
+icnss: qcom,icnss@C800000 {compatible = "qcom,icnss";reg = <0xC800000 0x800000>,
diff --git a/kernel/msm-4.14/drivers/Makefile b/kernel/msm-4.14/drivers/Makefile
old mode 100644
new mode 100755
index cef0160448..ddb0478e5c
--- a/kernel/msm-4.14/drivers/Makefile
+++ b/kernel/msm-4.14/drivers/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_DMADEVICES)	+= dma/# SOC specific infrastructure drivers.obj-y				+= soc/
+obj-y				+= pdata/obj-$(CONFIG_VIRTIO)		+= virtio/obj-$(CONFIG_XEN)		+= xen/
diff --git a/kernel/msm-4.14/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c b/kernel/msm-4.14/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
old mode 100644
new mode 100755
index 9039c60c91..7a752cd96b
--- a/kernel/msm-4.14/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
+++ b/kernel/msm-4.14/drivers/gpu/drm/msm/dsi-staging/dsi_panel.c
@@ -24,6 +24,7 @@#include "dsi_ctrl_hw.h"#include "dsi_parser.h"+#include <linux/pdata.h>/*** topology is currently defined by a set of following 3 values:* 1. num of layer mixers
@@ -48,6 +49,36 @@ enum dsi_dsc_ratio_type {DSC_12BPC_8BPP,DSC_RATIO_TYPE_MAX};
+char *cmdline_panel_size;
+static int get_string_num(char* src,int* width,int* height)
+{
+	int num;
+	int count=0;
+	char *p;
+	if(src == NULL || width == NULL || height == NULL)
+	{
+		return -1;
+	}
+	p = src;
+	while(*p)
+	{
+		if(*p >= '0' && *p <= '9')
+		{
+			for(num = 0; *p >= '0' && *p <= '9';p++)
+			{
+				num = num * 10 + *p - '0';		
+			}
+			count++;
+			printk("NO%d:%d\n",count,num);
+			if(count == 1)
+			*width = num;
+			if(count == 2)
+			*height = num;
+		}else if(*p != '\0' && (*p < '0' || *p > '9'))
+			p++;
+	}
+	return 0;
+}static u32 dsi_dsc_rc_buf_thresh[] = {0x0e, 0x1c, 0x2a, 0x38, 0x46, 0x54,0x62, 0x69, 0x70, 0x77, 0x79, 0x7b, 0x7d, 0x7e};
@@ -872,8 +903,18 @@ static int dsi_panel_parse_timing(struct dsi_mode_info *mode,u32 val = 0;struct dsi_display_mode *display_mode;struct dsi_display_mode_priv_info *priv_info;
+	char temp_buff[20]={0};
+	int *fibo_width;
+	int *fibo_height;
+	fibo_width = kmalloc(sizeof(int*),GFP_KERNEL);
+	fibo_height = kmalloc(sizeof(int*),GFP_KERNEL);display_mode = container_of(mode, struct dsi_display_mode, timing);
+	cmdline_panel_size = strnstr(saved_command_line, "panel_size=",strlen(saved_command_line));
+	if(cmdline_panel_size != NULL){
+		strncpy(temp_buff,cmdline_panel_size,sizeof(temp_buff));
+		get_string_num(temp_buff,fibo_width,fibo_height);
+	}priv_info = display_mode->priv_info;@@ -910,11 +951,19 @@ static int dsi_panel_parse_timing(struct dsi_mode_info *mode,goto error;}+	if(*fibo_width > QCM6125_MAX_SIZE || *fibo_width <=0 || fibo_width == NULL || cmdline_panel_size == NULL){rc = utils->read_u32(utils->data, "qcom,mdss-dsi-panel-width",&mode->h_active);if (rc) {
-		pr_err("failed to read qcom,mdss-dsi-panel-width, rc=%d\n", rc);
+			pr_err("failed to read qcom,mdss-dsi-panel-width, rc=%d\n",
+					rc);goto error;
+		}
+		pr_err("%s:%d,use defaul panel width(%d)\n",__func__, __LINE__,mode->h_active);
+	}
+	else{
+		mode->h_active = *fibo_width;
+		pr_err("%s:%d,use dynamic panel width(%d)\n",__func__, __LINE__,mode->h_active);}rc = utils->read_u32(utils->data,
@@ -953,12 +1002,19 @@ static int dsi_panel_parse_timing(struct dsi_mode_info *mode,mode->h_active, mode->h_front_porch, mode->h_back_porch,mode->h_sync_width);+	if(*fibo_height > QCM6125_MAX_SIZE || *fibo_height <=0  || fibo_height == NULL || cmdline_panel_size == NULL){rc = utils->read_u32(utils->data, "qcom,mdss-dsi-panel-height",&mode->v_active);if (rc) {pr_err("failed to read qcom,mdss-dsi-panel-height, rc=%d\n",rc);goto error;
+		}
+		pr_err("%s:%d,use defaul panel height(%d)\n",__func__, __LINE__,mode->v_active);
+	}
+	else{
+		mode->v_active = *fibo_height;
+		pr_err("%s:%d,use dynamic panel height(%d)\n",__func__, __LINE__,mode->v_active);}rc = utils->read_u32(utils->data, "qcom,mdss-dsi-v-back-porch",
diff --git a/kernel/msm-4.14/drivers/pdata/Makefile b/kernel/msm-4.14/drivers/pdata/Makefile
new file mode 100755
index 0000000000..6f77b84c91
--- /dev/null
+++ b/kernel/msm-4.14/drivers/pdata/Makefile
@@ -0,0 +1 @@
+obj-y	+= pdata.o
diff --git a/kernel/msm-4.14/drivers/pdata/pdata.c b/kernel/msm-4.14/drivers/pdata/pdata.c
new file mode 100755
index 0000000000..b2d01da8b7
--- /dev/null
+++ b/kernel/msm-4.14/drivers/pdata/pdata.c
@@ -0,0 +1,366 @@
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/workqueue.h>
+#include <linux/errno.h>
+#include <linux/pm.h>
+#include <linux/platform_device.h>
+#include <linux/input.h>
+#include <linux/i2c.h>
+#include <linux/slab.h>
+#include <linux/wait.h>
+#include <linux/time.h>
+#include <linux/delay.h>
+#include <linux/of_gpio.h>
+#include <linux/pinctrl/consumer.h>
+
+#if defined(CONFIG_FB)
+#include <linux/notifier.h>
+#include <linux/fb.h>
+#endif
+#include <linux/timer.h>
+#include <linux/string.h>
+#include <linux/pdata.h>
+
+
+static char pdata1_path[] = "/dev/block/by-name/privdata1";
+
+int file_rw(char* path,char* buf, int size,int num,int offset,int rw_flag)
+{
+	
+    struct file *fp;  
+    mm_segment_t fs;  
+    loff_t pos;
+	int ret;
+	if((0 > num) || (0 >= size) || (0 > rw_flag) || (buf == NULL) || (path == NULL))
+	{
+		printk("%s,%d,file_rw arg error\n",__func__,__LINE__);
+		return -EBADF;
+	}
+	
+	
+    fp = filp_open(path, O_RDWR, 0664); 
+    if (IS_ERR(fp)) {  
+        printk("%s,%d,fopen error=%d,%p\n",__func__,__LINE__,IS_ERR(fp),fp);
+		return -EBADF;
+    }
+    fs = get_fs();  
+    set_fs(KERNEL_DS);
+	
+	if(0 >= offset){
+		pos = fp->f_pos; 
+	}else{
+		pos = offset;
+	}
+
+	if(rw_flag == 0)
+	{
+		ret = vfs_read(fp, buf, size*num, &pos);
+		printk(" %s,%d,vfs_read pos:%d\n",__func__,__LINE__,offset);
+		if(ret < 0){
+			printk("%s,%d,vfs_read error:%d\n",__func__,__LINE__,ret);
+			goto err;
+		}else{
+			fp->f_pos = pos;
+			set_fs(fs);
+			printk(" %s,%d,vfs_read sucess:%s,ret = %d\n",__func__,__LINE__,buf,ret);
+		}	
+	}
+	else
+	{
+		ret = vfs_write(fp, buf, size*num, &pos);  
+		printk(" %s,%d,vfs_write pos:%d\n",__func__,__LINE__,offset);
+		if(ret < 0){
+			printk(" %s,%d,vfs_write error:%d\n",__func__,__LINE__,ret);
+			goto err;
+		}else{
+			fp->f_pos = pos;
+			set_fs(fs);
+			printk("%s,%d,vfs_write sucess:%s,ret = %d\n",__func__,__LINE__,buf,ret);
+		}	
+	}
+
+	filp_close(fp, NULL);  
+	printk("%s,%d,file_rw sucess\n",__func__,__LINE__);
+	return 0;
+	err:
+	filp_close(fp, NULL);  
+	printk("%s,%d,file_rw fail\n",__func__,__LINE__);
+	return -EBADF;
+}
+#if 1
+int atoi(const char *str)
+{
+    int total = 0;         
+    int isNegative = 0;    
+    int length = 0;        
+    const char *p = str;
+    char temp = '0';
+	int i;
+    if(NULL == p)       
+    {
+        return -1;
+    }
+    
+    while(*p++!='\0')    
+    {
+        length++;
+    }
+
+    p = str;            
+
+    if(*p == '-')          
+    {
+        isNegative = 1;     
+    }
+    
+    for( i = 0;i < length;i++)
+    {
+        temp = *p++;
+        if(temp > '9'||temp < '0')     
+        {
+            continue;
+        }
+        if(total != 0||temp != '0')     
+        {
+            temp -= '0';
+            total = total*10 + temp;
+        }
+    }
+
+    if(isNegative)                
+        return (0 - total);
+    else
+        return total;               
+}
+#endif
+#if 0
+//ok
+static ssize_t pdata_width_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+
+	int ret;
+	char fibo_panel_width_clen;
+	int fibo_panel_width_ilen = 1;
+	int fibo_panel_iwidth = 720;
+	char fibo_panel_width[5]={0};
+	if(0 > (ret = file_rw(pdata1_path,&fibo_panel_width_clen,sizeof(char),WIDTH_LEN_SIZE,WIDTH_LEN_OFFSET,FILE_READ)))
+	{
+		printk("%s,%d pdata_width_show error\n",__func__,__LINE__);
+		return ret;
+	}
+	sscanf(&fibo_panel_width_clen,"%d",&fibo_panel_width_ilen);
+	
+	if(0 > (ret = file_rw(pdata1_path,fibo_panel_width,sizeof(char),fibo_panel_width_ilen,WIDTH_OFFSET,FILE_READ)))
+	{
+		printk(" %s,%d pdata_width_show error\n",__func__,__LINE__);
+		return ret;
+	}
+
+	printk(" %s,%d fibo_panel_width(%s)\n",__func__,__LINE__,fibo_panel_width);
+	fibo_panel_iwidth = atoi(fibo_panel_width);
+	printk(" %s,%d pdata_width_show sucess (%d)(%d)\n",__func__,__LINE__,fibo_panel_iwidth,fibo_panel_width_ilen);
+	return (sprintf(buf, "(%d)(%d)\n", fibo_panel_iwidth,fibo_panel_width_ilen));
+}
+#endif
+
+static ssize_t pdata_width_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+
+	int ret;
+	char fibo_panel_width_clen;
+	int fibo_panel_width_ilen = 0;
+	int fibo_panel_iwidth = 0;
+	char fibo_panel_width[5]={0};
+	if(0 > (ret = file_rw(pdata1_path,&fibo_panel_width_clen,sizeof(char),WIDTH_LEN_SIZE,WIDTH_LEN_OFFSET,FILE_READ)))
+	{
+		printk(" %s,%d pdata_width_show error\n",__func__,__LINE__);
+		return ret;
+	}
+	sscanf(&fibo_panel_width_clen,"%d",&fibo_panel_width_ilen);
+	
+	if(0 > (ret = file_rw(pdata1_path,fibo_panel_width,sizeof(char),fibo_panel_width_ilen,WIDTH_OFFSET,FILE_READ)))
+	{
+		printk(" %s,%d pdata_width_show error\n",__func__,__LINE__);
+		return ret;
+	}
+
+	printk(" %s,%d fibo_panel_width(%s)\n",__func__,__LINE__,fibo_panel_width);
+	fibo_panel_iwidth = atoi(fibo_panel_width);
+	printk(" %s,%d pdata_width_show sucess (%d)(%d)\n",__func__,__LINE__,fibo_panel_iwidth,fibo_panel_width_ilen);
+	return (sprintf(buf, "(%d)(%d)\n", fibo_panel_iwidth,fibo_panel_width_ilen));
+}
+
+static ssize_t pdata_width_store(struct device *dev,struct device_attribute *attr, const char *buf, size_t len)
+{
+	int ret = 0;
+	int num = 0;
+	int width_size = 0;
+	char width_len = '4';
+	
+	//width_size = atoi(buf);
+	sscanf(buf,"%d",&width_size);
+	if(width_size >= QCM6125_MIN_SIZE && width_size < 1000){
+		width_len = '3';
+		num = 3;
+	}
+	else if(width_size >= 1000 && width_size <= QCM6125_MAX_SIZE){
+		width_len = '4';
+		num = 4;
+	}
+	else{
+		printk(" %s,%d error unsupported width_size = %d\n",__func__,__LINE__,width_size);
+		return -1;
+	}
+
+	printk(" %s,%d  width_size = %d,width_len = %c,num = %d\n",__func__,__LINE__,width_size,width_len,num);
+	if(0 > (ret = file_rw(pdata1_path,&width_len,sizeof(char),WIDTH_LEN_SIZE,WIDTH_LEN_OFFSET,FILE_WRITE)))
+	{
+		printk(" %s,%d pdata_width_store error\n",__func__,__LINE__);
+		return ret;
+	}
+	if(0 > (ret = file_rw(pdata1_path,(char*)buf,sizeof(char),num,WIDTH_OFFSET,FILE_WRITE)))
+	{
+		printk(" %s,%d pdata_width_store error\n",__func__,__LINE__);
+		return ret;
+	}
+	printk(" %s,%d pdata_width_store sucess\n",__func__,__LINE__);
+	return len;
+}
+
+static ssize_t pdata_height_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+
+	int ret;
+	char fibo_panel_height_clen;
+	int fibo_panel_height_ilen = 0;
+	int fibo_panel_iheight = 0;
+	char fibo_panel_height[5]={0};
+	if(0 > (ret = file_rw(pdata1_path,&fibo_panel_height_clen,sizeof(char),HEIGHT_LEN_SIZE,HEIGHT_LEN_OFFSET,FILE_READ)))
+	{
+		printk(" %s,%d pdata_height_show error\n",__func__,__LINE__);
+		return ret;
+	}
+	sscanf(&fibo_panel_height_clen,"%d",&fibo_panel_height_ilen);
+	
+	if(0 > (ret = file_rw(pdata1_path,fibo_panel_height,sizeof(char),fibo_panel_height_ilen,HEIGHT_OFFSET,FILE_READ)))
+	{
+		printk(" %s,%d pdata_height_show error\n",__func__,__LINE__);
+		return ret;
+	}
+
+	printk(" %s,%d fibo_panel_height(%s)\n",__func__,__LINE__,fibo_panel_height);
+	fibo_panel_iheight = atoi(fibo_panel_height);
+	printk(" %s,%d pdata_height_show sucess (%d)(%d)\n",__func__,__LINE__,fibo_panel_iheight,fibo_panel_height_ilen);
+	return (sprintf(buf, "(%d)(%d)\n", fibo_panel_iheight,fibo_panel_height_ilen));
+}
+
+static ssize_t pdata_height_store(struct device *dev,struct device_attribute *attr, const char *buf, size_t len)
+{
+	int ret = 0;
+	int num = 0;
+	int height_size = 0;
+	char height_len = '4';
+	
+	//height_size = atoi(buf);
+	sscanf(buf,"%d",&height_size);
+	if(height_size >= QCM6125_MIN_SIZE && height_size < 1000){
+		height_len = '3';
+		num = 3;
+	}
+	else if(height_size >= 1000 && height_size <= QCM6125_MAX_SIZE){
+		height_len = '4';
+		num = 4;
+	}
+	else{
+		printk(" %s,%d error unsupported height_size = %d\n",__func__,__LINE__,height_size);
+		return -1;
+	}
+
+	printk(" %s,%d  height_size = %d,height_len = %c,num = %d\n",__func__,__LINE__,height_size,height_len,num);
+	if(0 > (ret = file_rw(pdata1_path,&height_len,sizeof(char),HEIGHT_LEN_SIZE,HEIGHT_LEN_OFFSET,FILE_WRITE)))
+	{
+		printk(" %s,%d pdata_height_store error\n",__func__,__LINE__);
+		return ret;
+	}
+	if(0 > (ret = file_rw(pdata1_path,(char*)buf,sizeof(char),num,HEIGHT_OFFSET,FILE_WRITE)))
+	{
+		printk(" %s,%d pdata_height_store error\n",__func__,__LINE__);
+		return ret;
+	}
+	printk(" %s,%d pdata_height_store sucess\n",__func__,__LINE__);
+	return len;
+}
+
+
+
+static DEVICE_ATTR(pdata_width, (S_IRUGO | S_IWUSR | S_IWGRP),
+			pdata_width_show,
+			pdata_width_store);
+
+static DEVICE_ATTR(pdata_height, (S_IRUGO | S_IWUSR | S_IWGRP),
+			pdata_height_show,
+			pdata_height_store);
+			
+static struct attribute *pdata_x_y_attrs[] = {
+	&dev_attr_pdata_width.attr,
+	&dev_attr_pdata_height.attr,
+	NULL
+};
+
+static const struct attribute_group fibo_attr_grp = {
+	.attrs = pdata_x_y_attrs,
+};
+
+static int pdata_driver_probe(struct platform_device *pdev)
+{
+
+    int ret;
+
+	pr_err("-----------pdata_probe start--------------\n");
+
+	ret = sysfs_create_group(&pdev->dev.kobj, &fibo_attr_grp);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "sys file creation failed.\n");
+		return -ENOMEM;
+	}
+
+	pr_err("-----------pdata_probe success--------------\n");
+	
+    return 0;
+}
+
+
+static int pdata_driver_remove(struct platform_device *pdev)
+{
+	
+	sysfs_remove_group(&pdev->dev.kobj, &fibo_attr_grp);
+
+	return 0;
+}
+
+
+
+static const struct of_device_id pdata_driver_match[] = {
+        { .compatible = "fibo,pdata_driver" },
+        {},  
+};
+
+
+static struct platform_driver pdata_driver_driver = {
+    .driver = {
+            .name = "pdata_driver",
+            .owner = THIS_MODULE,
+            .of_match_table = pdata_driver_match,
+    },   
+    .probe = pdata_driver_probe,
+    .remove = pdata_driver_remove,
+};
+
+module_platform_driver(pdata_driver_driver);
+
+MODULE_AUTHOR("hingwing.liu");
+MODULE_DESCRIPTION("fibo misc driver");
+MODULE_LICENSE("GPL");
+MODULE_VERSION("1.0");
\ No newline at end of file
diff --git a/kernel/msm-4.14/include/linux/pdata.h b/kernel/msm-4.14/include/linux/pdata.h
new file mode 100755
index 0000000000..0a66abb5fb
--- /dev/null
+++ b/kernel/msm-4.14/include/linux/pdata.h
@@ -0,0 +1,62 @@
+/* Copyright (c) 2013, 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+#ifndef __PDATA_H_
+#define __PDATA_H_
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+#include <linux/platform_device.h>
+#include <linux/of_gpio.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/delay.h>
+#include <linux/hrtimer.h>
+#include <linux/device.h>
+#include <linux/vmalloc.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/sched.h>
+#include <linux/dcache.h>
+#include <linux/fs.h>
+#include <linux/err.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <asm/fcntl.h>
+#include <asm/processor.h>
+#include <asm/uaccess.h>
+ 
+#include <linux/string.h>
+#include <linux/errno.h>
+
+#define FILE_READ 0
+#define FILE_WRITE 1
+
+//pdata1
+// | 0 | 1  2  3  4 | 5 | 6 | 7  8  9  10 |
+// |len|    WIDTH   | 0 |len|   HEIGHT    |
+#define WIDTH_LEN_OFFSET 0
+#define WIDTH_LEN_SIZE 1
+#define WIDTH_OFFSET 1
+#define HEIGHT_LEN_OFFSET 6
+#define HEIGHT_LEN_SIZE 1
+#define HEIGHT_OFFSET 7
+#define QCM6125_MAX_SIZE 1920
+#define QCM6125_MIN_SIZE 400
+
+
+int file_rw(char* path,char* buf, int size,int num,int offset,int rw_flag); int atoi(const char *str);
+
+#endif
-- 
2.37.3


http://www.ppmy.cn/news/228005.html

相关文章

Xilinx XDMA驱动代码分析及用法

Xilinx XDMA驱动代码分析及用法 先简单的介绍一下&#xff0c;赛灵思的XDMA的驱动是用于做什么的、他的主要功能就类似与网卡pcie接口的网卡驱动、用于控制主机与fpga设备进行pcie的通讯。通讯的主要方式是设备文件的读写&#xff0c;这里不清楚的同学可以看一下我上一篇文章。…

Texlive和TeXStudio的下载安装

1.Texlive的下载链接&#xff1a;TeX Live - TeX Users Group &#xff08;1&#xff09;按照步骤来 下面随机跳转镜像网站&#xff0c;好的镜像10分钟内就可以下载好&#xff0c;速度慢的可以返回重新跳转找个速度快的网站 &#xff08;2&#xff09;下载好后&#xff0c;然后…

xilinx项目XDMA/PCIE高速传输解决方案传输效率90%

明德扬在PCIE高速传输方案积累了丰富的技术&#xff0c;传输的带宽利用率可达到90%以上&#xff0c;延迟可达到理论的最低延迟值。 明德扬能够根据客户的需求(需求、延迟和应用等)&#xff0c;为客户提供定制的PCIE解决方案&#xff0c;欢迎您与我们联系&#xff0c;沟通洽谈。…

基于FPGA的LCD1602显示屏驱动

一、LCD1602显示原理 1、引脚功能 其内部功能框图如下图所示&#xff1a; 一般来说&#xff0c;LCD1602有16条引脚&#xff0c;各个厂家的LCD1602可能略有不同&#xff0c;但基本上一样&#xff0c;其16个引脚功能如下&#xff1a; LCD1602引脚功能 引脚号引脚名电压等级功能…

S7-200 SMART 老版本固件更新

S7-200 SMART 老版本固件更新 手里有一块S7-200 SMART PLC SR20&#xff0c;不知道什么年头的产品&#xff0c;最近翻出来想让其发挥一下余热。于是上 西门子S7 200 SMART 官网 下载 STEP 7-MicroWIN SMART&#xff0c;默认就是最新版本2.7, PC Access SMART 2.3&#xff0c;一…

xlrd

1、导入模块 import xlrd 2、打开Excel文件读取数据 data xlrd.open_workbook(excelFile.xls) 3、使用技巧 #获取一个工作表 table data.sheets()[0] #通过索引顺序获取 table data.sheet_by_index(0) #通过索引顺序获取 table data.sheet_by_name(uSheet1)#通过名…

XeLaTeX: 支持现代字体 LaTeX 编译器

XeLaTeX: 支持现代字体 LaTeX 编译器 原  文&#xff1a;XeLaTeX 译  者&#xff1a;Xovee 翻译时间&#xff1a;2023年2月21日 文章目录 XeLaTeX: 支持现代字体 LaTeX 编译器介绍基础&#xff1a;Times New Roman为不同的LaTeX模块设置不同的字体Overleaf中的字体安装在O…

(22.12.20)matlab2022+yalmip+cplex安装教程,win11 x64

前言 Hi,你好&#xff01;最近刚刚更换新的电脑设备&#xff0c;安装软件时尽量选择最新版本&#xff0c;但也遇到了大大小小的安装问题&#xff0c;这里把踩到的坑一并总结出来&#xff0c;给出一份还算合理的MATLAByalmipCPLEX安装教程&#xff08;win11&#xff09;。 MAT…