blob: 76a94151dad82b0f0d11ab42015170c041361552 [file] [log] [blame]
merothh32be6882022-01-03 01:54:57 +05301#! /vendor/bin/sh
2
Rohit R Sekharadf49712022-11-17 21:05:16 +05303# Copyright (c) 2012-2013,2016,2018-2021 The Linux Foundation. All rights reserved.
merothh32be6882022-01-03 01:54:57 +05304#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above copyright
10# notice, this list of conditions and the following disclaimer in the
11# documentation and/or other materials provided with the distribution.
12# * Neither the name of The Linux Foundation nor
13# the names of its contributors may be used to endorse or promote
14# products derived from this software without specific prior written
15# permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
Michael Bestasc3ad1cd2023-10-03 15:27:40 +030029#Changes from Qualcomm Innovation Center are provided under the following license:
30#Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
31#SPDX-License-Identifier: BSD-3-Clause-Clear
32#
merothh32be6882022-01-03 01:54:57 +053033
34export PATH=/vendor/bin
35
36# Set platform variables
37if [ -f /sys/devices/soc0/hw_platform ]; then
38 soc_hwplatform=`cat /sys/devices/soc0/hw_platform` 2> /dev/null
39else
40 soc_hwplatform=`cat /sys/devices/system/soc/soc0/hw_platform` 2> /dev/null
41fi
42if [ -f /sys/devices/soc0/soc_id ]; then
43 soc_hwid=`cat /sys/devices/soc0/soc_id` 2> /dev/null
44else
45 soc_hwid=`cat /sys/devices/system/soc/soc0/id` 2> /dev/null
46fi
47if [ -f /sys/devices/soc0/platform_version ]; then
48 soc_hwver=`cat /sys/devices/soc0/platform_version` 2> /dev/null
49else
50 soc_hwver=`cat /sys/devices/system/soc/soc0/platform_version` 2> /dev/null
51fi
52
53if [ -f /sys/class/drm/card0-DSI-1/modes ]; then
54 echo "detect" > /sys/class/drm/card0-DSI-1/status
55 mode_file=/sys/class/drm/card0-DSI-1/modes
56 while read line; do
57 fb_width=${line%%x*};
58 break;
59 done < $mode_file
60elif [ -f /sys/class/graphics/fb0/virtual_size ]; then
61 res=`cat /sys/class/graphics/fb0/virtual_size` 2> /dev/null
62 fb_width=${res%,*}
63fi
64
65log -t BOOT -p i "MSM target '$1', SoC '$soc_hwplatform', HwID '$soc_hwid', SoC ver '$soc_hwver'"
66
67#For drm based display driver
68vbfile=/sys/module/drm/parameters/vblankoffdelay
69if [ -w $vbfile ]; then
70 echo -1 > $vbfile
71else
72 log -t DRM_BOOT -p w "file: '$vbfile' or perms doesn't exist"
73fi
74
75function set_density_by_fb() {
76 #put default density based on width
77 if [ -z $fb_width ]; then
78 setprop vendor.display.lcd_density 320
79 else
80 if [ $fb_width -ge 1600 ]; then
81 setprop vendor.display.lcd_density 640
82 elif [ $fb_width -ge 1440 ]; then
83 setprop vendor.display.lcd_density 560
84 elif [ $fb_width -ge 1080 ]; then
Michael Bestas0134c1e2023-08-30 13:51:03 +030085 setprop vendor.display.lcd_density 480
merothh32be6882022-01-03 01:54:57 +053086 elif [ $fb_width -ge 720 ]; then
87 setprop vendor.display.lcd_density 320 #for 720X1280 resolution
88 elif [ $fb_width -ge 480 ]; then
89 setprop vendor.display.lcd_density 240 #for 480X854 QRD resolution
90 else
91 setprop vendor.display.lcd_density 160
92 fi
93 fi
94}
95
96target=`getprop ro.board.platform`
97case "$target" in
98 "msm7630_surf" | "msm7630_1x" | "msm7630_fusion")
99 case "$soc_hwplatform" in
100 "FFA" | "SVLTE_FFA")
101 # linking to surf_keypad_qwerty.kcm.bin instead of surf_keypad_numeric.kcm.bin so that
102 # the UI keyboard works fine.
103 ln -s /system/usr/keychars/surf_keypad_qwerty.kcm.bin /system/usr/keychars/surf_keypad.kcm.bin
104 ;;
105 "Fluid")
106 setprop vendor.display.lcd_density 240
107 setprop qcom.bt.dev_power_class 2
108 ;;
109 *)
110 ln -s /system/usr/keychars/surf_keypad_qwerty.kcm.bin /system/usr/keychars/surf_keypad.kcm.bin
111 ;;
112 esac
113 ;;
114 "sm6150")
115 case "$soc_hwplatform" in
116 "ADP")
117 setprop vendor.display.lcd_density 160
118 ;;
119 esac
120 case "$soc_hwid" in
121 365|366)
122 sku_ver=`cat /sys/devices/platform/soc/aa00000.qcom,vidc1/sku_version` 2> /dev/null
123 setprop vendor.media.target.version 1
124 if [ $sku_ver -eq 1 ]; then
125 setprop vendor.media.target.version 2
126 fi
127 ;;
128 355|369|377|384)
129 setprop vendor.chre.enabled 0
130 ;;
131 *)
132 esac
133 ;;
134 "msm8660")
135 case "$soc_hwplatform" in
136 "Fluid")
137 setprop vendor.display.lcd_density 240
138 ;;
139 "Dragon")
140 setprop ro.sound.alsa "WM8903"
141 ;;
142 esac
143 ;;
144
145 "msm8960")
146 # lcd density is write-once. Hence the separate switch case
147 case "$soc_hwplatform" in
148 "Liquid")
149 if [ "$soc_hwver" == "196608" ]; then # version 0x30000 is 3D sku
150 setprop ro.sf.hwrotation 90
151 fi
152
153 setprop vendor.display.lcd_density 160
154 ;;
155 "MTP")
156 setprop vendor.display.lcd_density 240
157 ;;
158 *)
159 case "$soc_hwid" in
160 "109")
161 setprop vendor.display.lcd_density 160
162 ;;
163 *)
164 setprop vendor.display.lcd_density 240
165 ;;
166 esac
167 ;;
168 esac
169
170 #Set up composition type based on the target
171 case "$soc_hwid" in
172 87)
173 #8960
174 setprop debug.composition.type dyn
175 ;;
176 153|154|155|156|157|138)
177 #8064 V2 PRIME | 8930AB | 8630AB | 8230AB | 8030AB | 8960AB
178 setprop debug.composition.type c2d
179 ;;
180 *)
181 esac
182 ;;
183
184 "msm8974")
185 case "$soc_hwplatform" in
186 "Liquid")
187 setprop vendor.display.lcd_density 160
188 # Liquid do not have hardware navigation keys, so enable
189 # Android sw navigation bar
190 setprop ro.hw.nav_keys 0
191 ;;
192 "Dragon")
193 setprop vendor.display.lcd_density 240
194 ;;
195 *)
196 setprop vendor.display.lcd_density 320
197 ;;
198 esac
199 ;;
200
201 "msm8226")
202 case "$soc_hwplatform" in
203 *)
204 setprop vendor.display.lcd_density 320
205 ;;
206 esac
207 ;;
208
209 "msm8610" | "apq8084" | "mpq8092")
210 case "$soc_hwplatform" in
211 *)
212 setprop vendor.display.lcd_density 240
213 ;;
214 esac
215 ;;
216 "apq8084")
217 case "$soc_hwplatform" in
218 "Liquid")
219 setprop vendor.display.lcd_density 320
220 # Liquid do not have hardware navigation keys, so enable
221 # Android sw navigation bar
222 setprop ro.hw.nav_keys 0
223 ;;
224 "SBC")
225 setprop vendor.display.lcd_density 200
226 # SBC do not have hardware navigation keys, so enable
227 # Android sw navigation bar
228 setprop qemu.hw.mainkeys 0
229 ;;
230 *)
231 setprop vendor.display.lcd_density 480
232 ;;
233 esac
234 ;;
235 "msm8996")
236 case "$soc_hwplatform" in
237 "Dragon")
238 setprop vendor.display.lcd_density 240
239 setprop qemu.hw.mainkeys 0
240 ;;
241 "ADP")
242 setprop vendor.display.lcd_density 160
243 setprop qemu.hw.mainkeys 0
244 ;;
245 "SBC")
246 setprop vendor.display.lcd_density 240
247 setprop qemu.hw.mainkeys 0
248 ;;
249 *)
250 setprop vendor.display.lcd_density 560
251 ;;
252 esac
253 ;;
254 "msm8937" | "msm8940")
255 # Set vendor.opengles.version based on chip id.
256 # MSM8937 and MSM8940 variants supports OpenGLES 3.1
257 # 196608 is decimal for 0x30000 to report version 3.0
258 # 196609 is decimal for 0x30001 to report version 3.1
259 # 196610 is decimal for 0x30002 to report version 3.2
260 case "$soc_hwid" in
261 294|295|296|297|298|313|353|354|363|364)
Rohit R Sekharadf49712022-11-17 21:05:16 +0530262 # Disable adsprpcd_sensorspd daemon
263 setprop vendor.fastrpc.disable.adsprpcd_sensorspd.daemon 1
264
merothh32be6882022-01-03 01:54:57 +0530265 setprop vendor.opengles.version 196610
266 if [ $soc_hwid = 354 ]
267 then
268 setprop vendor.media.target.version 1
269 log -t BOOT -p i "SDM429 early_boot prop set for: HwID '$soc_hwid'"
270 fi
271 ;;
272 303|307|308|309|320|386|436)
273 # Vulkan is not supported for 8917 variants
274 setprop vendor.opengles.version 196608
275 setprop persist.graphics.vulkan.disable true
276 setprop vendor.gralloc.disable_ahardware_buffer 1
277 # Disable adsprpcd_sensorspd daemon
278 setprop vendor.fastrpc.disable.adsprpcd_sensorspd.daemon 1
279 ;;
280 *)
281 setprop vendor.opengles.version 196608
282 ;;
283 esac
284 ;;
285 "msm8909")
286 case "$soc_hwplatform" in
287 *)
288 setprop persist.graphics.vulkan.disable true
289 ;;
290 esac
291 ;;
292 "msm8998" | "apq8098_latv")
293 case "$soc_hwplatform" in
294 *)
295 setprop vendor.display.lcd_density 560
296 ;;
297 esac
298 ;;
299 "sdm845")
300 case "$soc_hwplatform" in
301 *)
302 if [ $fb_width -le 1600 ]; then
303 setprop vendor.display.lcd_density 560
304 else
305 setprop vendor.display.lcd_density 640
306 fi
307 ;;
308 esac
309 ;;
310 "msmnile")
311 case "$soc_hwplatform" in
312 *)
313 if [ $fb_width -le 1600 ]; then
314 setprop vendor.display.lcd_density 560
315 else
316 setprop vendor.display.lcd_density 640
317 fi
318 ;;
319 esac
320 ;;
321 "kona")
322 case "$soc_hwplatform" in
323 *)
324 setprop vendor.media.target_variant "_kona"
325 if [ $fb_width -le 1600 ]; then
326 setprop vendor.display.lcd_density 560
327 else
328 setprop vendor.display.lcd_density 640
329 fi
330 ;;
331 esac
332 ;;
333 "lito")
334 case "$soc_hwid" in
335 400|440)
336 sku_ver=`cat /sys/devices/platform/soc/aa00000.qcom,vidc1/sku_version` 2> /dev/null
337 if [ $sku_ver -eq 1 ]; then
338 setprop vendor.media.target.version 1
339 fi
340 ;;
341 434|459)
342 sku_ver=`cat /sys/devices/platform/soc/aa00000.qcom,vidc1/sku_version` 2> /dev/null
343 setprop vendor.media.target.version 2
344 if [ $sku_ver -eq 1 ]; then
345 setprop vendor.media.target.version 3
346 fi
347 ;;
348 476)
349 # Fraser soc_id 476
350 setprop vendor.display.enable_qsync_idle 1
351 ;;
352 esac
353 ;;
354 "bengal")
355 case "$soc_hwid" in
356 441|473)
357 # 441 is for scuba and 473 for scuba iot qcm
358 setprop vendor.fastrpc.disable.cdsprpcd.daemon 1
359 setprop vendor.media.target.version 2
360 setprop vendor.gralloc.disable_ubwc 1
361 setprop vendor.display.enhance_idle_time 1
362 setprop vendor.netflix.bsp_rev ""
363 # 196609 is decimal for 0x30001 to report version 3.1
364 setprop vendor.opengles.version 196609
365 sku_ver=`cat /sys/devices/platform/soc/5a00000.qcom,vidc1/sku_version` 2> /dev/null
366 if [ $sku_ver -eq 1 ]; then
367 setprop vendor.media.target.version 3
368 fi
369 ;;
370 471|474)
371 # 471 is for scuba APQ and 474 for scuba iot qcs
372 setprop vendor.fastrpc.disable.cdsprpcd.daemon 1
373 setprop vendor.gralloc.disable_ubwc 1
374 setprop vendor.display.enhance_idle_time 1
375 setprop vendor.netflix.bsp_rev ""
376 ;;
Michael Bestasc3ad1cd2023-10-03 15:27:40 +0300377 518|561|586)
378 setprop vendor.media.target.version 3
Rohit R Sekharadf49712022-11-17 21:05:16 +0530379 ;;
Michael Bestasc3ad1cd2023-10-03 15:27:40 +0300380 585)
381 setprop vendor.media.target.version 4
merothh32be6882022-01-03 01:54:57 +0530382 ;;
383 esac
384 ;;
385 "sdm710" | "msmpeafowl")
386 case "$soc_hwplatform" in
387 *)
388 if [ $fb_width -le 1600 ]; then
389 setprop vendor.display.lcd_density 560
390 else
391 setprop vendor.display.lcd_density 640
392 fi
393
394 sku_ver=`cat /sys/devices/platform/soc/aa00000.qcom,vidc1/sku_version` 2> /dev/null
395 if [ $sku_ver -eq 1 ]; then
396 setprop vendor.media.target.version 1
397 fi
398 ;;
399 esac
400 ;;
401 "msm8953")
402 cap_ver = 1
403 if [ -e "/sys/devices/platform/soc/1d00000.qcom,vidc/capability_version" ]; then
404 cap_ver=`cat /sys/devices/platform/soc/1d00000.qcom,vidc/capability_version` 2> /dev/null
405 else
406 cap_ver=`cat /sys/devices/soc/1d00000.qcom,vidc/capability_version` 2> /dev/null
407 fi
408
409 if [ $cap_ver -eq 1 ]; then
410 setprop vendor.media.target.version 1
411 fi
412 ;;
413 #Set property to differentiate SDM660 & SDM455
414 #SOC ID for SDM455 is 385
415 "sdm660")
416 case "$soc_hwplatform" in
417 *)
418 if [ $fb_width -le 1600 ]; then
419 setprop vendor.display.lcd_density 560
420 else
421 setprop vendor.display.lcd_density 640
422 fi
423
424 if [ $soc_hwid -eq 385 ]; then
425 setprop vendor.media.target.version 1
426 fi
427 ;;
428 esac
429 ;;
430 "holi")
431 setprop vendor.media.target_variant "_holi"
432 ;;
433esac
434case "$target" in
435 "msm8937")
436 case "$soc_hwid" in
437 386|354|353|303)
438 # enable qrtr-ns service for kernel 4.14 or above
439 KernelVersionStr=`cat /proc/sys/kernel/osrelease`
440 KernelVersionS=${KernelVersionStr:2:2}
441 KernelVersionA=${KernelVersionStr:0:1}
442 KernelVersionB=${KernelVersionS%.*}
443
444 if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 14 ]; then
445 setprop init.svc.vendor.qrtrns.enable 1
446 fi
447 ;;
448 esac
449 ;;
450 esac
451
merothh32be6882022-01-03 01:54:57 +0530452#set default lcd density
453#Since lcd density has read only
454#property, it will not overwrite previous set
455#property if any target is setting forcefully.
456set_density_by_fb
457
458
459# set Lilliput LCD density for ADP
460product=`getprop ro.build.product`
461
462case "$product" in
463 "msmnile_au")
464 setprop vendor.display.lcd_density 160
465 echo 902400000 > /sys/class/devfreq/soc:qcom,cpu0-cpu-l3-lat/min_freq
466 echo 1612800000 > /sys/class/devfreq/soc:qcom,cpu0-cpu-l3-lat/max_freq
467 echo 902400000 > /sys/class/devfreq/soc:qcom,cpu4-cpu-l3-lat/min_freq
468 echo 1612800000 > /sys/class/devfreq/soc:qcom,cpu4-cpu-l3-lat/max_freq
469 ;;
470 *)
471 ;;
472esac
473case "$product" in
474 "sm6150_au")
475 setprop vendor.display.lcd_density 160
476 ;;
477 *)
478 ;;
479esac
480case "$product" in
481 "sdmshrike_au")
482 setprop vendor.display.lcd_density 160
483 ;;
484 *)
485 ;;
486esac
487
488case "$product" in
489 "msmnile_gvmq")
490 setprop vendor.display.lcd_density 160
491 ;;
492 *)
493 ;;
494esac
Rohit R Sekharadf49712022-11-17 21:05:16 +0530495
496case "$product" in
497 "msmnile_gvmgh")
498 setprop vendor.display.lcd_density 160
499 ;;
500 *)
501 ;;
502esac
merothh32be6882022-01-03 01:54:57 +0530503# Setup display nodes & permissions
504# HDMI can be fb1 or fb2
505# Loop through the sysfs nodes and determine
506# the HDMI(dtv panel)
507
508function set_perms() {
509 #Usage set_perms <filename> <ownership> <permission>
510 chown -h $2 $1
511 chmod $3 $1
512}
513
514# check for the type of driver FB or DRM
515fb_driver=/sys/class/graphics/fb0
516if [ -e "$fb_driver" ]
517then
518 # check for mdp caps
519 file=/sys/class/graphics/fb0/mdp/caps
520 if [ -f "$file" ]
521 then
522 setprop vendor.gralloc.disable_ubwc 1
523 cat $file | while read line; do
524 case "$line" in
525 *"ubwc"*)
526 setprop vendor.gralloc.enable_fb_ubwc 1
527 setprop vendor.gralloc.disable_ubwc 0
528 esac
529 done
530 fi
531else
532 set_perms /sys/devices/virtual/hdcp/msm_hdcp/min_level_change system.graphics 0660
533fi
534
535# allow system_graphics group to access pmic secure_mode node
536set_perms /sys/class/lcd_bias/secure_mode system.graphics 0660
537set_perms /sys/class/leds/wled/secure_mode system.graphics 0660
538
539boot_reason=`cat /proc/sys/kernel/boot_reason`
540reboot_reason=`getprop ro.boot.alarmboot`
541if [ "$boot_reason" = "3" ] || [ "$reboot_reason" = "true" ]; then
542 setprop ro.vendor.alarm_boot true
543else
544 setprop ro.vendor.alarm_boot false
545fi
546
547# copy GPU frequencies to vendor property
548if [ -f /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies ]; then
549 gpu_freq=`cat /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies` 2> /dev/null
550 setprop vendor.gpu.available_frequencies "$gpu_freq"
551fi