# B9A — backlight mechanism. READ-ONLY.

## Answer: PM8916 MPP4 used as a constant CURRENT SINK (40 mA) for the LED backlight. On/off only in LK; no PWM, no WLED, no DCS, no GPIO,
## no separate LED-driver IC seen in any stock source.

== Stock LK (bootchain/aboot-analysis/lk.bin, target_backlight_ctrl @0x8f600b54; details in b9a-stock-lk.txt)
  pm8x41 MPP struct base = 0xa300 (MPP4), mode byte = 1
  write SID0 0xa340 MODE_CTL = 0x61   (mode 6 = current sink <<4, source sel 0, bit0 = 1 'on')
  write SID0 0xa34c SINK_CTL = 0x07   (7 -> 40 mA; PM8916 MPP sink steps 5 mA * (n+1))
  write SID0 0xa346 EN_CTL   = 0x80   (master enable)
  mdelay(20)
  backlight descriptor: bl_interface_type 1 ("BL_WLED" label), min 1, max 0xfff, pmic 'PMIC_8941' (CAF template values)
  Order in LK: panel power/reset -> SPI init -> 19 init cmds (DISPON, RAMWR) -> logo frame -> backlight ON (msm_display_init order:
  panel power_func, panel on, then bl_func) -> continuous splash (left on for the kernel).

== Stock Android kernel (dt/dtb_01.dts)
  qcom,leds@a300 (compatible qcom,leds-qpnp, label "mpp"):
    qcom,led_mpp_4: linux,name "lcd-bl", default-trigger "bkl-trigger", default-state off,
    qcom,max-current 40, qcom,current-setting 40 (mA), qcom,id 6 (QPNP_ID_LED_MPP), qcom,mode "manual",
    qcom,source-sel 1, qcom,mode-ctrl 0x60 (current sink)
  panel: qcom,mdss-spi-bl-pmic-control-type "bl_ctrl_wled", bl-min 1, bl-max 255 -> mdss_fb "lcd-backlight" led triggers "bkl-trigger"
    -> lcd-bl (MPP4). No pwm node referenced.
  Android sysfs (android/leds.txt): /sys/class/leds/lcd-backlight (mdss_fb_primary) and /sys/class/leds/lcd-bl (leds-qpnp-de736200)
  Android userspace: com.qualcomm.display running; ro.sf.lcd_density 114; persist.sys.juzhen.soft.version JZ_MIFI_LCD_COM_20260709.

== Who powers / who sets brightness
  - Supply of the LED string: not visible in any stock source (MPP4 only sinks current; anode presumably from VPH_PWR/VBAT — unproven, board-level).
  - Enable + "brightness": MPP4 SINK_CTL (5..40 mA, 8 steps) and EN. Stock uses 40 mA fixed. Fine brightness would need MPP4 DTEST/LPG PWM
    (not used by stock).
  - Order: backlight AFTER panel init + first frame (avoids showing GRAM garbage).

== Current Linux (live, b9a-linux-display.txt)
  MPP4: MODE_CTL 00, EN_CTL 00, SINK_CTL 00 -> OFF; /sys/class/backlight empty; /sys/class/leds has no lcd-bl.
  DT: pm8916_mpps@a000 present (qcom,pm8916-mpp, gpio-controller, 4 MPPs), no pinctrl state for mpp4, pm8916_pwm disabled.
  Kernel: PINCTRL_QCOM_SPMI_PMIC=y, BACKLIGHT_CLASS_DEVICE=y, BACKLIGHT_GPIO=y, LEDS_CLASS=y.

== Upstream mapping (read-only check of /home/q/aurora-kbuild/src)
  drivers/pinctrl/qcom/pinctrl-spmi-mpp.c: function "sink" => MODE_CTL mode 6; "drive-strength" written RAW to SINK_CTL (0x4c) -> use 7
  for 40 mA; "output-high"/gpio value => MODE_CTL bit0. EN_CTL = master enable. => DT:
    &pm8916_mpps { lcd_bl_default: mpp4-state { pins = "mpp4"; function = "sink"; drive-strength = <7>; output-low; }; };
    backlight: backlight { compatible = "gpio-backlight"; gpios = <&pm8916_mpps 4 GPIO_ACTIVE_HIGH>; pinctrl... };
  This reproduces LK's 0x61/0x07/0x80 exactly when on (to be verified in B9B by reading back the 3 registers).
