init.qcom.early_boot.sh 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #! /vendor/bin/sh
  2. # Copyright (c) 2012-2013,2016,2018-2020 The Linux Foundation. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are met:
  6. # * Redistributions of source code must retain the above copyright
  7. # notice, this list of conditions and the following disclaimer.
  8. # * Redistributions in binary form must reproduce the above copyright
  9. # notice, this list of conditions and the following disclaimer in the
  10. # documentation and/or other materials provided with the distribution.
  11. # * Neither the name of The Linux Foundation nor
  12. # the names of its contributors may be used to endorse or promote
  13. # products derived from this software without specific prior written
  14. # permission.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  20. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  23. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  25. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. #
  28. export PATH=/vendor/bin
  29. # Set platform variables
  30. if [ -f /sys/devices/soc0/hw_platform ]; then
  31. soc_hwplatform=`cat /sys/devices/soc0/hw_platform` 2> /dev/null
  32. else
  33. soc_hwplatform=`cat /sys/devices/system/soc/soc0/hw_platform` 2> /dev/null
  34. fi
  35. if [ -f /sys/devices/soc0/soc_id ]; then
  36. soc_hwid=`cat /sys/devices/soc0/soc_id` 2> /dev/null
  37. else
  38. soc_hwid=`cat /sys/devices/system/soc/soc0/id` 2> /dev/null
  39. fi
  40. if [ -f /sys/devices/soc0/platform_version ]; then
  41. soc_hwver=`cat /sys/devices/soc0/platform_version` 2> /dev/null
  42. else
  43. soc_hwver=`cat /sys/devices/system/soc/soc0/platform_version` 2> /dev/null
  44. fi
  45. if [ -f /sys/class/drm/card0-DSI-1/modes ]; then
  46. echo "detect" > /sys/class/drm/card0-DSI-1/status
  47. mode_file=/sys/class/drm/card0-DSI-1/modes
  48. while read line; do
  49. fb_width=${line%%x*};
  50. break;
  51. done < $mode_file
  52. elif [ -f /sys/class/graphics/fb0/virtual_size ]; then
  53. res=`cat /sys/class/graphics/fb0/virtual_size` 2> /dev/null
  54. fb_width=${res%,*}
  55. fi
  56. log -t BOOT -p i "MSM target '$1', SoC '$soc_hwplatform', HwID '$soc_hwid', SoC ver '$soc_hwver'"
  57. #For drm based display driver
  58. vbfile=/sys/module/drm/parameters/vblankoffdelay
  59. if [ -w $vbfile ]; then
  60. echo -1 > $vbfile
  61. else
  62. log -t DRM_BOOT -p w "file: '$vbfile' or perms doesn't exist"
  63. fi
  64. function set_density_by_fb() {
  65. #put default density based on width
  66. if [ -z $fb_width ]; then
  67. setprop vendor.display.lcd_density 320
  68. else
  69. if [ $fb_width -ge 1600 ]; then
  70. setprop vendor.display.lcd_density 640
  71. elif [ $fb_width -ge 1440 ]; then
  72. setprop vendor.display.lcd_density 560
  73. elif [ $fb_width -ge 1080 ]; then
  74. setprop vendor.display.lcd_density 480
  75. elif [ $fb_width -ge 720 ]; then
  76. setprop vendor.display.lcd_density 320 #for 720X1280 resolution
  77. elif [ $fb_width -ge 480 ]; then
  78. setprop vendor.display.lcd_density 240 #for 480X854 QRD resolution
  79. else
  80. setprop vendor.display.lcd_density 160
  81. fi
  82. fi
  83. }
  84. baseband=`getprop ro.baseband`
  85. #enable atfwd daemon all targets except sda, apq, qcs
  86. case "$baseband" in
  87. "apq" | "sda" | "qcs" )
  88. setprop persist.vendor.radio.atfwd.start false;;
  89. *)
  90. setprop persist.vendor.radio.atfwd.start true;;
  91. esac
  92. #set default lcd density
  93. #Since lcd density has read only
  94. #property, it will not overwrite previous set
  95. #property if any target is setting forcefully.
  96. set_density_by_fb
  97. # Setup display nodes & permissions
  98. # HDMI can be fb1 or fb2
  99. # Loop through the sysfs nodes and determine
  100. # the HDMI(dtv panel)
  101. function set_perms() {
  102. #Usage set_perms <filename> <ownership> <permission>
  103. chown -h $2 $1
  104. chmod $3 $1
  105. }
  106. # check for the type of driver FB or DRM
  107. fb_driver=/sys/class/graphics/fb0
  108. if [ -e "$fb_driver" ]
  109. then
  110. # check for mdp caps
  111. file=/sys/class/graphics/fb0/mdp/caps
  112. if [ -f "$file" ]
  113. then
  114. setprop vendor.gralloc.disable_ubwc 1
  115. cat $file | while read line; do
  116. case "$line" in
  117. *"ubwc"*)
  118. setprop vendor.gralloc.enable_fb_ubwc 1
  119. setprop vendor.gralloc.disable_ubwc 0
  120. esac
  121. done
  122. fi
  123. else
  124. set_perms /sys/devices/virtual/hdcp/msm_hdcp/min_level_change system.graphics 0660
  125. fi
  126. # allow system_graphics group to access pmic secure_mode node
  127. set_perms /sys/class/lcd_bias/secure_mode system.graphics 0660
  128. set_perms /sys/class/leds/wled/secure_mode system.graphics 0660
  129. boot_reason=`cat /proc/sys/kernel/boot_reason`
  130. reboot_reason=`getprop ro.boot.alarmboot`
  131. if [ "$boot_reason" = "3" ] || [ "$reboot_reason" = "true" ]; then
  132. setprop ro.vendor.alarm_boot true
  133. else
  134. setprop ro.vendor.alarm_boot false
  135. fi
  136. # copy GPU frequencies to vendor property
  137. if [ -f /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies ]; then
  138. gpu_freq=`cat /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies` 2> /dev/null
  139. setprop vendor.gpu.available_frequencies "$gpu_freq"
  140. fi