MTK---将背光pwm模式改为一线脉冲模式

将背光pwm模式改为一线脉冲模式,提高背光最大亮度

1.dws配置

--- a/device/hebs/q9v52_k39tv1_bsp_1g-customer/q9v52_k39tv1_bsp_1g-m18_ms5314g/dws/kernel/q9v52_k39tv1_bsp_1g.dws
+++ b/device/hebs/q9v52_k39tv1_bsp_1g-customer/q9v52_k39tv1_bsp_1g-m18_ms5314g/dws/kernel/q9v52_k39tv1_bsp_1g.dws
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--dct_version="2.5" buid_sn="161102" dws_modification_time="05.14.2024.09:56:52"-->
+<!--dct_version="2.5" buid_sn="161102" dws_modification_time="06.07.2024.10:20:09"-->
 <dct_cfg>
     <general chip="MT6739">
         <proj>MT6739</proj>
@@ -1274,9 +1274,9 @@
             </gpio84>
             <gpio85>
                 <eint_mode>false</eint_mode>
-                <def_mode>1</def_mode>
-                <mode_arr>11000000</mode_arr>
-                <inpull_en>true</inpull_en>
+                <def_mode>0</def_mode>
+                <mode_arr>10000000</mode_arr>
+                <inpull_en>false</inpull_en>
                 <inpull_selhigh>false</inpull_selhigh>
                 <def_dir>OUT</def_dir>
                 <in>false</in>

2.dts

diff --git a/kernel-4.14/arch/arm/boot/dts/q9v52_k39tv1_bsp_1g.dts b/kernel-4.14/arch/arm/boot/dts/q9v52_k39tv1_bsp_1g.dts
index 36ca631..754ce28 100755 (executable)
--- a/kernel-4.14/arch/arm/boot/dts/q9v52_k39tv1_bsp_1g.dts
+++ b/kernel-4.14/arch/arm/boot/dts/q9v52_k39tv1_bsp_1g.dts
@@ -72,7 +72,7 @@
        };
        led6:led@6 {
                compatible = "mediatek,lcd-backlight";
-               led_mode = <5>;
+               led_mode = <2>;
                data = <1>;
                pwm_config = <0 2 0 0 0>;
        };
@@ -414,7 +414,8 @@
        pinctrl-names = "default", "state_eint_as_int",
                "state_eint_output0", "state_eint_output1",
                "state_rst_output0", "state_rst_output1",
-               "state_en_output0", "state_en_output1";
+               "state_en_output0", "state_en_output1",
+               "ctp_pins_backlight_low","ctp_pins_backlight_high";
        pinctrl-0 = <&ctp_pins_default>;
        pinctrl-1 = <&ctp_pins_eint_as_int>;
        pinctrl-2 = <&ctp_pins_eint_output0>;
@@ -423,6 +424,8 @@
        pinctrl-5 = <&ctp_pins_rst_output1>;
        pinctrl-6 = <&ctp_pins_en_output0>;
        pinctrl-7 = <&ctp_pins_en_output1>;     
+       pinctrl-8 = <&ctp_pins_backlight_low>;
+       pinctrl-9 = <&ctp_pins_backlight_high>;
        status = "okay";
 };
 &pio {
@@ -477,6 +480,20 @@
                        output-high;
                };
        };
+       ctp_pins_backlight_low: backlightlow {
+               pins_cmd_dat {
+                       pinmux = <PINMUX_GPIO85__FUNC_GPIO85>;
+                       slew-rate = <1>;
+                       output-low;
+               };
+       };
+       ctp_pins_backlight_high: backlighthigh {
+               pins_cmd_dat {
+                       pinmux = <PINMUX_GPIO85__FUNC_GPIO85>;
+                       slew-rate = <1>;
+                       output-high;
+               };
+       };
 };

3.lk

--- a/vendor/mediatek/proprietary/bootable/bootloader/lk/target/q9v52_k39tv1_bsp_1g/cust_leds.c
+++ b/vendor/mediatek/proprietary/bootable/bootloader/lk/target/q9v52_k39tv1_bsp_1g/cust_leds.c
@@ -5,7 +5,8 @@
 
 //extern int DISP_SetBacklight(int level);
 
-extern int disp_bls_set_backlight(unsigned int level);
+extern int brightness_set_gpio(int gpio_num, int level);
+//extern int disp_bls_set_backlight(unsigned int level);
 enum led_brightness backlight_default_level = LED_FULL;
 
 
@@ -29,7 +30,8 @@ static struct cust_mt65xx_led cust_led_list[MT65XX_LED_TYPE_TOTAL] = {
        {"jogball-backlight", MT65XX_LED_MODE_NONE, -1,{0,0,0,0,0}},
        {"keyboard-backlight",MT65XX_LED_MODE_NONE, -1,{0,0,0,0,0}},
        {"button-backlight",  MT65XX_LED_MODE_NONE, -1,{0,0,0,0,0}},
-       {"lcd-backlight",         MT65XX_LED_MODE_CUST_BLS_PWM, (int)disp_bls_set_backlight,{0}},
+       //{"lcd-backlight",       MT65XX_LED_MODE_CUST_BLS_PWM, (int)disp_bls_set_backlight,{0}},
+       {"lcd-backlight",     MT65XX_LED_MODE_GPIO, (int)brightness_set_gpio,{0}},
 };
 




--- a/vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6739/mt_leds.c
+++ b/vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6739/mt_leds.c
@@ -312,6 +312,11 @@ static int mt65xx_led_set_cust(struct cust_mt65xx_led *cust, int level)
                        }
 
                case MT65XX_LED_MODE_GPIO:
+                       //[begin] mbling 2023.09.12
+                       if (strcmp(cust->name,"lcd-backlight") == 0){
+                                       return brightness_set_gpio(GPIO85, level);
+                       }else
+                       // [end]
                        return ((cust_brightness_set)(cust->data))(level);
                case MT65XX_LED_MODE_PMIC:




--- a/vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6739/ddp_pwm.c
+++ b/vendor/mediatek/proprietary/bootable/bootloader/lk/platform/mt6739/ddp_pwm.c
@@ -229,4 +229,70 @@ int disp_pwm_set_backlight(disp_pwm_id_t id, int level_1024)
        return 0;
 }
 
+// [begin] mbling 2023.09.12
+#if 1
+int g_pre_count = -1;
+void brightness_set_gpio(int gpio_num, int level) {
+    mt_set_gpio_mode(gpio_num, GPIO_MODE_GPIO); 
+    mt_set_gpio_dir(gpio_num, GPIO_DIR_OUT);
+
+    if (level == 0) {
+       mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+        g_pre_count = -1;
+        mdelay(3);
+    }else {
+        int i;
+        int count = 16 - (level +  16) / 16 + 1;
+        if (count <= 1) count = 1;
+        else if (count >= 16) count = 16;
+    
+        if (count == g_pre_count) return;
+
+       mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+        mdelay(1);
+        PWM_MSG("[LED] %s backlight count=%d,level=%d\n",__func__, count, level);
+
+        for(i=0; i<count; i++) {
+            mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+            udelay(2); 
+            mt_set_gpio_out(gpio_num, GPIO_OUT_ONE); 
+            udelay(2);                             
+        }
+        g_pre_count = count;
+    }
+}
+#else
+static int s_bBacklightOn = 1;
+static int g_ledCurrPulseCount=1;
+int brightness_set_gpio(int gpio_num, int level)
+{ 
+        int i; 
+        int min_level = 30;        //the min value for UI brightness setup 
+        int max_level = 255;        //the max value for UI brightness setup 
+        int min_bri = 1;        //the min value for adjust the brightness 
+        int max_bri = 16;        //the max value for adjust the brightness 
+        int count=0, to_count=0; 
+          
+        mt_set_gpio_mode(gpio_num, GPIO_MODE_GPIO); 
+        mt_set_gpio_dir(gpio_num, GPIO_DIR_OUT);
+
+        if (level) { 
+                if (level < min_level) {  to_count = max_bri;  }
+                else if (level >= 255) { to_count = min_bri;    }
+                else { 
+                        to_count = max_bri-((level-min_level)*(max_bri-min_bri)/(max_level-min_level)); 
+                        PWM_MSG("[LED] infact count=%d\n", to_count); 
+                } 
+                if (s_bBacklightOn) { 
+                        if (g_ledCurrPulseCount > to_count) {   count = to_count+16-g_ledCurrPulseCount;   }//change brighter  
+                        else if (g_ledCurrPulseCount < to_count){   count = to_count-g_ledCurrPulseCount;   }   //change darker 
+                        else {  goto end;      } 
+                }else{ count = to_count;    } 
+                
+                PWM_MSG("[LED] need more count=%d\n", count); 
+                if (s_bBacklightOn) { 
+                        for (i=0; i<count; i++) { 
+                                mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+                                udelay(2);
+                                mt_set_gpio_out(gpio_num, GPIO_OUT_ONE); 
+                                udelay(2);
+                        } 
+                } else {
+                        //first pulse must set high more than 20 us 
+                        mt_set_gpio_out(gpio_num, GPIO_OUT_ONE); 
+                        udelay(20); 
+                        //mt6575_irq_mask_all(&mask);//ÆÁ±ÎËùÓÐÖжÏ
+                        for (i=1; i<(count-1); i++) { 
+                                mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+                                udelay(2); 
+                                mt_set_gpio_out(gpio_num, GPIO_OUT_ONE); 
+                                udelay(2);                             
+                        } 
+                        //mt6575_irq_mask_restore(&mask); // restore all interrupts     
+                } 
+                
+                g_ledCurrPulseCount = to_count; 
+                PWM_MSG("[LED]GPIO111#%d:%d:curr count=%d, more count=%d, s_bBacklightOn=%d\n", gpio_num, level, g_ledCurrPulseCount, count, s_bBacklightOn); 
+                mdelay(3); 
+                s_bBacklightOn = 1; 
+        }else { 
+                mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+                s_bBacklightOn = 0; 
+                mdelay(3);
+        } 
+end: 
+        PWM_MSG("[LED]GPIO222#%d:%d:curr count=%d, to count=%d, s_bBacklightOn=%d\n", gpio_num, level, g_ledCurrPulseCount, count, s_bBacklightOn); 
+
+        return 0; 
+} 
+#endif
+// [end]



4.kernel

--- a/kernel-4.14/drivers/input/touchscreen/mediatek/mtk_tpd.c
+++ b/kernel-4.14/drivers/input/touchscreen/mediatek/mtk_tpd.c
@@ -51,7 +51,7 @@ struct pinctrl_state *eint_as_int, *eint_output0,
                *eint_output1, *rst_output0, *rst_output1;
 
 // add
-struct pinctrl_state  *en_output0, *en_output1;
+struct pinctrl_state  *en_output0, *en_output1,*lcm_backlight_low, *lcm_backlight_high;
 
 const struct of_device_id touch_of_match[] = {
        { .compatible = "mediatek,touch", },
@@ -210,6 +210,7 @@ int tpd_get_gpio_info(struct platform_device *pdev)
        int ret;
 
        TPD_DEBUG("[tpd %d] mt_tpd_pinctrl+++++++++++++++++\n", pdev->id);
+       printk("mbling %s\n",__func__);
        pinctrl1 = devm_pinctrl_get(&pdev->dev);
        if (IS_ERR(pinctrl1)) {
                ret = PTR_ERR(pinctrl1);
@@ -257,7 +258,23 @@ int tpd_get_gpio_info(struct platform_device *pdev)
                        return ret;
                }
        }
-
+       lcm_backlight_low = pinctrl_lookup_state(pinctrl1, "ctp_pins_backlight_low");
+       if (IS_ERR(lcm_backlight_low)) {
+                       ret = PTR_ERR(lcm_backlight_low);
+                       dev_err(&pdev->dev, "fwq Cannot find touch pinctrl lcm_backlight_low!\n");
+                       printk("mbling333 %s\n",__func__);
+                       return ret;
+       }
+       printk("mbling111 %s\n",__func__);
+       lcm_backlight_high = pinctrl_lookup_state(pinctrl1, "ctp_pins_backlight_high");
+       if (IS_ERR(lcm_backlight_high)) {
+                       ret = PTR_ERR(lcm_backlight_high);
+                       dev_err(&pdev->dev, "fwq Cannot find touch pinctrl lcm_backlight_high!\n");
+                       printk("mbling444 %s\n",__func__);
+                       return ret;
+       }
+       
+       printk("mbling222 %s\n",__func__);
 
        //add
        {
@@ -276,13 +293,69 @@ int tpd_get_gpio_info(struct platform_device *pdev)
                        return ret;
                }
        }
-
+       
        
        TPD_DEBUG("[tpd%d] mt_tpd_pinctrl----------\n", pdev->id);
        return 0;
 }
 
 // add
+#include <linux/delay.h>
+#if 1
+int g_pre_count = -1;
+void brightness_set_gpio(int gpio_num, int level) {
+    mt_set_gpio_mode(gpio_num, GPIO_MODE_GPIO); 
+    mt_set_gpio_dir(gpio_num, GPIO_DIR_OUT);
+
+    if (level == 0) {
+       mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+        g_pre_count = -1;
+        mdelay(3);
+    }else {
+        int i;
+        int count = 16 - (level +  16) / 16 + 1;
+        if (count <= 1) count = 1;
+        else if (count >= 16) count = 16;
+    
+        if (count == g_pre_count) return;
+
+       mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+        mdelay(1);
+        PWM_MSG("[LED] %s backlight count=%d,level=%d\n",__func__, count, level);
+
+        for(i=0; i<count; i++) {
+            mt_set_gpio_out(gpio_num, GPIO_OUT_ZERO); 
+            udelay(2); 
+            mt_set_gpio_out(gpio_num, GPIO_OUT_ONE); 
+            udelay(2);                             
+        }
+        g_pre_count = count;
+    }
+}
+#else
+int g_ledCurrPulseCount=1;
+void hebs_lcm_backlight_set(int level) {
+    int i; 
+    int min_level = 30;        //the min value for UI brightness setup 
+    int max_level = 255;        //the max value for UI brightness setup 
+    int min_bri = 1;        //the min value for adjust the brightness 
+    int max_bri = 16;        //the max value for adjust the brightness 
+    int count=0, to_count=0;
+       print("[LED] mbling %d\n ",level);
+    static int s_bBacklightOn = 1;
+    if (level) { 
+        if (level < min_level) {  to_count = max_bri;  }
+        else if (level > 255) { to_count = min_bri;    }
+        else { 
+            to_count = max_bri-((level-min_level)*(max_bri-min_bri)/(max_level-min_level)); 
+            pr_info("[LED] infact count=%d\n", to_count); 
+        } 
+       if (s_bBacklightOn) { 
+            if (g_ledCurrPulseCount > to_count) {   count = to_count+16-g_ledCurrPulseCount;   }//change brighter  
+            else if (g_ledCurrPulseCount < to_count){   count = to_count-g_ledCurrPulseCount;   }   //change darker 
+            else {  goto end;      }
+        }
+        else{ count = to_count;    }
+        if (s_bBacklightOn) {
+            for (i=0; i<count; i++) {
+                pinctrl_select_state(pinctrl1, lcm_backlight_low); 
+                udelay(2);
+                pinctrl_select_state(pinctrl1, lcm_backlight_high); 
+                udelay(2);         
+            }
+        }else {
+            pinctrl_select_state(pinctrl1, lcm_backlight_high); 
+            udelay(20); 
+            for (i=1; i<(count-1); i++) { 
+                pinctrl_select_state(pinctrl1, lcm_backlight_low); 
+                udelay(2); 
+                pinctrl_select_state(pinctrl1, lcm_backlight_high); 
+                udelay(2);                             
+            }
+        }
+        g_ledCurrPulseCount = to_count; 
+        pr_info("[LED]%d:curr count=%d, more count=%d, s_bBacklightOn=%d\n", level, g_ledCurrPulseCount, count, s_bBacklightOn); 
+        mdelay(3); 
+        s_bBacklightOn = 1; 
+    }else {
+        pinctrl_select_state(pinctrl1, lcm_backlight_low); 
+               printk("[LED] mbling\n");
+        s_bBacklightOn = 0; 
+        mdelay(3); 
+    }
+end: 
+    pr_info("[LED]%d:curr count=%d, to count=%d, s_bBacklightOn=%d\n", level, g_ledCurrPulseCount, count, s_bBacklightOn);
+
+}




--- a/kernel-4.14/drivers/misc/mediatek/leds/mt6739/mtk_leds.c
+++ b/kernel-4.14/drivers/misc/mediatek/leds/mt6739/mtk_leds.c
@@ -845,7 +845,13 @@ int mt_mt65xx_led_set_cust(struct cust_mt65xx_led *cust, int level)
 
        case MT65XX_LED_MODE_GPIO:
                LEDS_DEBUG("brightness_set_cust:go GPIO mode!!!!!\n");
-               return ((cust_set_brightness) (cust->data)) (level);
+               if (strcmp(cust->name, "lcd-backlight") == 0) {
+                       extern void hebs_lcm_backlight_set(int level);
+                       printk("mling MT65XX_LED_MODE_GPIO\n");
+                       hebs_lcm_backlight_set(level);
+               }
+               return 1;
+               //return ((cust_set_brightness) (cust->data)) (level);

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值