Lines Matching full:backlight
6 #include <linux/backlight.h>
68 hw_level = scale(user_level, 0, user_max, 0, panel->backlight.max); in clamp_user_to_hw()
69 hw_level = clamp(hw_level, panel->backlight.min, panel->backlight.max); in clamp_user_to_hw()
80 return scale(hw_level, panel->backlight.min, panel->backlight.max, in scale_hw_to_user()
89 drm_WARN_ON(&i915->drm, panel->backlight.pwm_level_max == 0); in intel_backlight_invert_pwm_level()
96 return panel->backlight.pwm_level_max - val + panel->backlight.pwm_level_min; in intel_backlight_invert_pwm_level()
108 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] set backlight PWM = %d\n", in intel_backlight_set_pwm_level()
110 panel->backlight.pwm_funcs->set(conn_state, val); in intel_backlight_set_pwm_level()
119 panel->backlight.max == 0 || panel->backlight.pwm_level_max == 0); in intel_backlight_level_to_pwm()
121 val = scale(val, panel->backlight.min, panel->backlight.max, in intel_backlight_level_to_pwm()
122 panel->backlight.pwm_level_min, panel->backlight.pwm_level_max); in intel_backlight_level_to_pwm()
133 panel->backlight.max == 0 || panel->backlight.pwm_level_max == 0); in intel_backlight_level_from_pwm()
137 val = panel->backlight.pwm_level_max - (val - panel->backlight.pwm_level_min); in intel_backlight_level_from_pwm()
139 return scale(val, panel->backlight.pwm_level_min, panel->backlight.pwm_level_max, in intel_backlight_level_from_pwm()
140 panel->backlight.min, panel->backlight.max); in intel_backlight_level_from_pwm()
167 if (panel->backlight.combination_mode) { in i9xx_get_backlight()
192 return intel_de_read(i915, BXT_BLC_PWM_DUTY(panel->backlight.controller)); in bxt_get_backlight()
200 pwm_get_state(panel->backlight.pwm, &state); in ext_pwm_get_backlight()
231 drm_WARN_ON(&i915->drm, panel->backlight.pwm_level_max == 0); in i9xx_set_backlight()
233 if (panel->backlight.combination_mode) { in i9xx_set_backlight()
236 lbpc = level * 0xfe / panel->backlight.pwm_level_max + 1; in i9xx_set_backlight()
269 intel_de_write(i915, BXT_BLC_PWM_DUTY(panel->backlight.controller), level); in bxt_set_backlight()
276 pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100); in ext_pwm_set_backlight()
277 pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); in ext_pwm_set_backlight()
287 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] set backlight level = %d\n", in intel_panel_actually_set_backlight()
290 panel->backlight.funcs->set(conn_state, level); in intel_panel_actually_set_backlight()
293 /* set backlight brightness to level in range [0..max], assuming hw min is
306 * connection_mutex isn't held across the entire backlight in intel_backlight_set_acpi()
310 if (!panel->backlight.present || !conn_state->crtc) in intel_backlight_set_acpi()
313 mutex_lock(&i915->display.backlight.lock); in intel_backlight_set_acpi()
315 drm_WARN_ON(&i915->drm, panel->backlight.max == 0); in intel_backlight_set_acpi()
318 panel->backlight.level = hw_level; in intel_backlight_set_acpi()
320 if (panel->backlight.device) in intel_backlight_set_acpi()
321 panel->backlight.device->props.brightness = in intel_backlight_set_acpi()
323 panel->backlight.level, in intel_backlight_set_acpi()
324 panel->backlight.device->props.max_brightness); in intel_backlight_set_acpi()
326 if (panel->backlight.enabled) in intel_backlight_set_acpi()
329 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_set_acpi()
350 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] CPU backlight was enabled, disabling\n", in lpt_disable_backlight()
403 intel_de_rmw(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in bxt_disable_backlight()
406 if (panel->backlight.controller == 1) in bxt_disable_backlight()
418 intel_de_rmw(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in cnp_disable_backlight()
429 panel->backlight.pwm_state.enabled = false; in ext_pwm_disable_backlight()
430 pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); in ext_pwm_disable_backlight()
439 if (!panel->backlight.present) in intel_backlight_disable()
443 * Do not disable backlight on the vga_switcheroo path. When switching in intel_backlight_disable()
445 * backlight. This will leave the backlight on unnecessarily when in intel_backlight_disable()
449 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] Skipping backlight disable on vga switch\n", in intel_backlight_disable()
454 mutex_lock(&i915->display.backlight.lock); in intel_backlight_disable()
456 if (panel->backlight.device) in intel_backlight_disable()
457 panel->backlight.device->props.power = FB_BLANK_POWERDOWN; in intel_backlight_disable()
458 panel->backlight.enabled = false; in intel_backlight_disable()
459 panel->backlight.funcs->disable(old_conn_state, 0); in intel_backlight_disable()
461 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_disable()
474 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] PCH backlight already enabled\n", in lpt_enable_backlight()
482 panel->backlight.alternate_pwm_increment ? in lpt_enable_backlight()
486 panel->backlight.alternate_pwm_increment ? in lpt_enable_backlight()
489 pch_ctl2 = panel->backlight.pwm_level_max << 16; in lpt_enable_backlight()
493 if (panel->backlight.active_low_pwm) in lpt_enable_backlight()
519 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] CPU backlight already enabled\n", in pch_enable_backlight()
527 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] PCH backlight already enabled\n", in pch_enable_backlight()
544 pch_ctl2 = panel->backlight.pwm_level_max << 16; in pch_enable_backlight()
548 if (panel->backlight.active_low_pwm) in pch_enable_backlight()
566 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] backlight already enabled\n", in i9xx_enable_backlight()
571 freq = panel->backlight.pwm_level_max; in i9xx_enable_backlight()
572 if (panel->backlight.combination_mode) in i9xx_enable_backlight()
576 if (panel->backlight.combination_mode) in i9xx_enable_backlight()
578 if (IS_PINEVIEW(i915) && panel->backlight.active_low_pwm) in i9xx_enable_backlight()
588 * Needed to enable backlight on some 855gm models. BLC_HIST_CTL is in i9xx_enable_backlight()
590 * that has backlight. in i9xx_enable_backlight()
607 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] backlight already enabled\n", in i965_enable_backlight()
613 freq = panel->backlight.pwm_level_max; in i965_enable_backlight()
614 if (panel->backlight.combination_mode) in i965_enable_backlight()
621 if (panel->backlight.combination_mode) in i965_enable_backlight()
623 if (panel->backlight.active_low_pwm) in i965_enable_backlight()
643 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] backlight already enabled\n", in vlv_enable_backlight()
649 ctl = panel->backlight.pwm_level_max << 16; in vlv_enable_backlight()
656 if (panel->backlight.active_low_pwm) in vlv_enable_backlight()
673 if (panel->backlight.controller == 1) { in bxt_enable_backlight()
683 if (panel->backlight.util_pin_active_low) in bxt_enable_backlight()
689 pwm_ctl = intel_de_read(i915, BXT_BLC_PWM_CTL(panel->backlight.controller)); in bxt_enable_backlight()
691 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] backlight already enabled\n", in bxt_enable_backlight()
694 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in bxt_enable_backlight()
698 intel_de_write(i915, BXT_BLC_PWM_FREQ(panel->backlight.controller), in bxt_enable_backlight()
699 panel->backlight.pwm_level_max); in bxt_enable_backlight()
704 if (panel->backlight.active_low_pwm) in bxt_enable_backlight()
707 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl); in bxt_enable_backlight()
708 intel_de_posting_read(i915, BXT_BLC_PWM_CTL(panel->backlight.controller)); in bxt_enable_backlight()
709 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in bxt_enable_backlight()
721 pwm_ctl = intel_de_read(i915, BXT_BLC_PWM_CTL(panel->backlight.controller)); in cnp_enable_backlight()
723 drm_dbg_kms(&i915->drm, "backlight already enabled\n"); in cnp_enable_backlight()
725 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in cnp_enable_backlight()
729 intel_de_write(i915, BXT_BLC_PWM_FREQ(panel->backlight.controller), in cnp_enable_backlight()
730 panel->backlight.pwm_level_max); in cnp_enable_backlight()
735 if (panel->backlight.active_low_pwm) in cnp_enable_backlight()
738 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl); in cnp_enable_backlight()
739 intel_de_posting_read(i915, BXT_BLC_PWM_CTL(panel->backlight.controller)); in cnp_enable_backlight()
740 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in cnp_enable_backlight()
750 pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100); in ext_pwm_enable_backlight()
751 panel->backlight.pwm_state.enabled = true; in ext_pwm_enable_backlight()
752 pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); in ext_pwm_enable_backlight()
761 WARN_ON(panel->backlight.max == 0); in __intel_backlight_enable()
763 if (panel->backlight.level <= panel->backlight.min) { in __intel_backlight_enable()
764 panel->backlight.level = panel->backlight.max; in __intel_backlight_enable()
765 if (panel->backlight.device) in __intel_backlight_enable()
766 panel->backlight.device->props.brightness = in __intel_backlight_enable()
768 panel->backlight.level, in __intel_backlight_enable()
769 panel->backlight.device->props.max_brightness); in __intel_backlight_enable()
772 panel->backlight.funcs->enable(crtc_state, conn_state, panel->backlight.level); in __intel_backlight_enable()
773 panel->backlight.enabled = true; in __intel_backlight_enable()
774 if (panel->backlight.device) in __intel_backlight_enable()
775 panel->backlight.device->props.power = FB_BLANK_UNBLANK; in __intel_backlight_enable()
786 if (!panel->backlight.present) in intel_backlight_enable()
791 mutex_lock(&i915->display.backlight.lock); in intel_backlight_enable()
795 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_enable()
805 mutex_lock(&i915->display.backlight.lock); in intel_panel_get_backlight()
807 if (panel->backlight.enabled) in intel_panel_get_backlight()
808 val = panel->backlight.funcs->get(connector, intel_connector_get_pipe(connector)); in intel_panel_get_backlight()
810 mutex_unlock(&i915->display.backlight.lock); in intel_panel_get_backlight()
812 drm_dbg_kms(&i915->drm, "get backlight PWM = %d\n", val); in intel_panel_get_backlight()
823 panel->backlight.min, panel->backlight.max); in scale_user_to_hw()
826 /* set backlight brightness to level in range [0..max], scaling wrt hw min */
835 if (!panel->backlight.present) in intel_panel_set_backlight()
838 mutex_lock(&i915->display.backlight.lock); in intel_panel_set_backlight()
840 drm_WARN_ON(&i915->drm, panel->backlight.max == 0); in intel_panel_set_backlight()
843 panel->backlight.level = hw_level; in intel_panel_set_backlight()
845 if (panel->backlight.enabled) in intel_panel_set_backlight()
848 mutex_unlock(&i915->display.backlight.lock); in intel_panel_set_backlight()
866 * backlight class device does not make it easy to differentiate in intel_backlight_device_update_status()
870 if (panel->backlight.enabled) { in intel_backlight_device_update_status()
871 if (panel->backlight.power) { in intel_backlight_device_update_status()
874 panel->backlight.power(connector, enable); in intel_backlight_device_update_status()
921 if (WARN_ON(panel->backlight.device)) in intel_backlight_device_register()
924 if (!panel->backlight.present) in intel_backlight_device_register()
927 WARN_ON(panel->backlight.max == 0); in intel_backlight_device_register()
938 * Note: Everything should work even if the backlight device max in intel_backlight_device_register()
941 props.max_brightness = panel->backlight.max; in intel_backlight_device_register()
943 panel->backlight.level, in intel_backlight_device_register()
946 if (panel->backlight.enabled) in intel_backlight_device_register()
960 * prevents registration of multiple backlight devices in the in intel_backlight_device_register()
962 * compatibility. Use unique names for subsequent backlight devices as a in intel_backlight_device_register()
966 name = kasprintf(GFP_KERNEL, "card%d-%s-backlight", in intel_backlight_device_register()
976 "[CONNECTOR:%d:%s] backlight device %s register failed: %ld\n", in intel_backlight_device_register()
982 panel->backlight.device = bd; in intel_backlight_device_register()
985 "[CONNECTOR:%d:%s] backlight device %s registered\n", in intel_backlight_device_register()
998 if (panel->backlight.device) { in intel_backlight_device_unregister()
999 backlight_device_unregister(panel->backlight.device); in intel_backlight_device_unregister()
1000 panel->backlight.device = NULL; in intel_backlight_device_unregister()
1035 if (panel->backlight.alternate_pwm_increment) in spt_hz_to_pwm()
1054 if (panel->backlight.alternate_pwm_increment) in lpt_hz_to_pwm()
1081 * clock frequency/32) in total for a complete cycle of modulated backlight
1145 u16 pwm_freq_hz = connector->panel.vbt.backlight.pwm_freq_hz; in get_vbt_pwm_freq()
1149 "VBT defined backlight frequency %u Hz\n", in get_vbt_pwm_freq()
1154 "default backlight frequency %u Hz\n", in get_vbt_pwm_freq()
1168 if (!panel->backlight.pwm_funcs->hz_to_pwm) { in get_backlight_max_vbt()
1170 "backlight frequency conversion not supported\n"); in get_backlight_max_vbt()
1174 pwm = panel->backlight.pwm_funcs->hz_to_pwm(connector, pwm_freq_hz); in get_backlight_max_vbt()
1177 "backlight frequency conversion failed\n"); in get_backlight_max_vbt()
1193 drm_WARN_ON(&i915->drm, panel->backlight.pwm_level_max == 0); in get_backlight_min_vbt()
1202 min = clamp_t(int, connector->panel.vbt.backlight.min_brightness, 0, 64); in get_backlight_min_vbt()
1203 if (min != connector->panel.vbt.backlight.min_brightness) { in get_backlight_min_vbt()
1205 "clamping VBT min backlight %d/255 to %d/255\n", in get_backlight_min_vbt()
1206 connector->panel.vbt.backlight.min_brightness, min); in get_backlight_min_vbt()
1210 return scale(min, 0, 255, 0, panel->backlight.pwm_level_max); in get_backlight_min_vbt()
1224 panel->backlight.alternate_pwm_increment = alt; in lpt_setup_backlight()
1227 panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY; in lpt_setup_backlight()
1230 panel->backlight.pwm_level_max = pch_ctl2 >> 16; in lpt_setup_backlight()
1234 if (!panel->backlight.pwm_level_max) in lpt_setup_backlight()
1235 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in lpt_setup_backlight()
1237 if (!panel->backlight.pwm_level_max) in lpt_setup_backlight()
1240 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in lpt_setup_backlight()
1242 panel->backlight.pwm_enabled = pch_ctl1 & BLM_PCH_PWM_ENABLE; in lpt_setup_backlight()
1244 cpu_mode = panel->backlight.pwm_enabled && HAS_PCH_LPT(i915) && in lpt_setup_backlight()
1252 "CPU backlight register was enabled, switching to PCH override\n"); in lpt_setup_backlight()
1264 "[CONNECTOR:%d:%s] Using native PCH PWM for backlight control\n", in lpt_setup_backlight()
1277 panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY; in pch_setup_backlight()
1280 panel->backlight.pwm_level_max = pch_ctl2 >> 16; in pch_setup_backlight()
1282 if (!panel->backlight.pwm_level_max) in pch_setup_backlight()
1283 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in pch_setup_backlight()
1285 if (!panel->backlight.pwm_level_max) in pch_setup_backlight()
1288 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in pch_setup_backlight()
1291 panel->backlight.pwm_enabled = (cpu_ctl2 & BLM_PWM_ENABLE) && in pch_setup_backlight()
1295 "[CONNECTOR:%d:%s] Using native PCH PWM for backlight control\n", in pch_setup_backlight()
1310 panel->backlight.combination_mode = ctl & BLM_LEGACY_MODE; in i9xx_setup_backlight()
1313 panel->backlight.active_low_pwm = ctl & BLM_POLARITY_PNV; in i9xx_setup_backlight()
1315 panel->backlight.pwm_level_max = ctl >> 17; in i9xx_setup_backlight()
1317 if (!panel->backlight.pwm_level_max) { in i9xx_setup_backlight()
1318 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in i9xx_setup_backlight()
1319 panel->backlight.pwm_level_max >>= 1; in i9xx_setup_backlight()
1322 if (!panel->backlight.pwm_level_max) in i9xx_setup_backlight()
1325 if (panel->backlight.combination_mode) in i9xx_setup_backlight()
1326 panel->backlight.pwm_level_max *= 0xff; in i9xx_setup_backlight()
1328 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in i9xx_setup_backlight()
1332 val = clamp(val, panel->backlight.pwm_level_min, panel->backlight.pwm_level_max); in i9xx_setup_backlight()
1334 panel->backlight.pwm_enabled = val != 0; in i9xx_setup_backlight()
1337 "[CONNECTOR:%d:%s] Using native PWM for backlight control\n", in i9xx_setup_backlight()
1350 panel->backlight.combination_mode = ctl2 & BLM_COMBINATION_MODE; in i965_setup_backlight()
1351 panel->backlight.active_low_pwm = ctl2 & BLM_POLARITY_I965; in i965_setup_backlight()
1354 panel->backlight.pwm_level_max = ctl >> 16; in i965_setup_backlight()
1356 if (!panel->backlight.pwm_level_max) in i965_setup_backlight()
1357 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in i965_setup_backlight()
1359 if (!panel->backlight.pwm_level_max) in i965_setup_backlight()
1362 if (panel->backlight.combination_mode) in i965_setup_backlight()
1363 panel->backlight.pwm_level_max *= 0xff; in i965_setup_backlight()
1365 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in i965_setup_backlight()
1367 panel->backlight.pwm_enabled = ctl2 & BLM_PWM_ENABLE; in i965_setup_backlight()
1370 "[CONNECTOR:%d:%s] Using native PWM for backlight control\n", in i965_setup_backlight()
1386 panel->backlight.active_low_pwm = ctl2 & BLM_POLARITY_I965; in vlv_setup_backlight()
1389 panel->backlight.pwm_level_max = ctl >> 16; in vlv_setup_backlight()
1391 if (!panel->backlight.pwm_level_max) in vlv_setup_backlight()
1392 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in vlv_setup_backlight()
1394 if (!panel->backlight.pwm_level_max) in vlv_setup_backlight()
1397 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in vlv_setup_backlight()
1399 panel->backlight.pwm_enabled = ctl2 & BLM_PWM_ENABLE; in vlv_setup_backlight()
1402 "[CONNECTOR:%d:%s] Using native PWM for backlight control (on pipe %c)\n", in vlv_setup_backlight()
1415 panel->backlight.controller = connector->panel.vbt.backlight.controller; in bxt_setup_backlight()
1418 BXT_BLC_PWM_CTL(panel->backlight.controller)); in bxt_setup_backlight()
1421 if (panel->backlight.controller == 1) { in bxt_setup_backlight()
1423 panel->backlight.util_pin_active_low = in bxt_setup_backlight()
1427 panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY; in bxt_setup_backlight()
1428 panel->backlight.pwm_level_max = in bxt_setup_backlight()
1429 intel_de_read(i915, BXT_BLC_PWM_FREQ(panel->backlight.controller)); in bxt_setup_backlight()
1431 if (!panel->backlight.pwm_level_max) in bxt_setup_backlight()
1432 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in bxt_setup_backlight()
1434 if (!panel->backlight.pwm_level_max) in bxt_setup_backlight()
1437 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in bxt_setup_backlight()
1439 panel->backlight.pwm_enabled = pwm_ctl & BXT_BLC_PWM_ENABLE; in bxt_setup_backlight()
1442 "[CONNECTOR:%d:%s] Using native PWM for backlight control (controller=%d)\n", in bxt_setup_backlight()
1444 panel->backlight.controller); in bxt_setup_backlight()
1481 * CNP has the BXT implementation of backlight, but with only one in cnp_setup_backlight()
1484 panel->backlight.controller = connector->panel.vbt.backlight.controller; in cnp_setup_backlight()
1485 if (!cnp_backlight_controller_is_valid(i915, panel->backlight.controller)) { in cnp_setup_backlight()
1486 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] Invalid backlight controller %d, assuming 0\n", in cnp_setup_backlight()
1488 panel->backlight.controller); in cnp_setup_backlight()
1489 panel->backlight.controller = 0; in cnp_setup_backlight()
1493 BXT_BLC_PWM_CTL(panel->backlight.controller)); in cnp_setup_backlight()
1495 panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY; in cnp_setup_backlight()
1496 panel->backlight.pwm_level_max = in cnp_setup_backlight()
1497 intel_de_read(i915, BXT_BLC_PWM_FREQ(panel->backlight.controller)); in cnp_setup_backlight()
1499 if (!panel->backlight.pwm_level_max) in cnp_setup_backlight()
1500 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in cnp_setup_backlight()
1502 if (!panel->backlight.pwm_level_max) in cnp_setup_backlight()
1505 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in cnp_setup_backlight()
1507 panel->backlight.pwm_enabled = pwm_ctl & BXT_BLC_PWM_ENABLE; in cnp_setup_backlight()
1510 "[CONNECTOR:%d:%s] Using native PCH PWM for backlight control (controller=%d)\n", in cnp_setup_backlight()
1512 panel->backlight.controller); in cnp_setup_backlight()
1525 /* Get the right PWM chip for DSI backlight according to VBT */ in ext_pwm_setup_backlight()
1527 panel->backlight.pwm = pwm_get(i915->drm.dev, "pwm_pmic_backlight"); in ext_pwm_setup_backlight()
1530 panel->backlight.pwm = pwm_get(i915->drm.dev, "pwm_soc_backlight"); in ext_pwm_setup_backlight()
1534 if (IS_ERR(panel->backlight.pwm)) { in ext_pwm_setup_backlight()
1537 panel->backlight.pwm = NULL; in ext_pwm_setup_backlight()
1541 panel->backlight.pwm_level_max = 100; /* 100% */ in ext_pwm_setup_backlight()
1542 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in ext_pwm_setup_backlight()
1544 if (pwm_is_enabled(panel->backlight.pwm)) { in ext_pwm_setup_backlight()
1546 pwm_get_state(panel->backlight.pwm, &panel->backlight.pwm_state); in ext_pwm_setup_backlight()
1548 level = pwm_get_relative_duty_cycle(&panel->backlight.pwm_state, in ext_pwm_setup_backlight()
1551 panel->backlight.pwm_enabled = true; in ext_pwm_setup_backlight()
1555 NSEC_PER_SEC / (unsigned long)panel->backlight.pwm_state.period, in ext_pwm_setup_backlight()
1559 panel->backlight.pwm_state.period = in ext_pwm_setup_backlight()
1564 "[CONNECTOR:%d:%s] Using %s PWM for backlight control\n", in ext_pwm_setup_backlight()
1575 panel->backlight.pwm_funcs->set(conn_state, in intel_pwm_set_backlight()
1584 panel->backlight.pwm_funcs->get(connector, pipe)); in intel_pwm_get_backlight()
1593 panel->backlight.pwm_funcs->enable(crtc_state, conn_state, in intel_pwm_enable_backlight()
1602 panel->backlight.pwm_funcs->disable(conn_state, in intel_pwm_disable_backlight()
1611 ret = panel->backlight.pwm_funcs->setup(connector, pipe); in intel_pwm_setup_backlight()
1615 panel->backlight.min = panel->backlight.pwm_level_min; in intel_pwm_setup_backlight()
1616 panel->backlight.max = panel->backlight.pwm_level_max; in intel_pwm_setup_backlight()
1617 panel->backlight.level = intel_pwm_get_backlight(connector, pipe); in intel_pwm_setup_backlight()
1618 panel->backlight.enabled = panel->backlight.pwm_enabled; in intel_pwm_setup_backlight()
1632 if (!panel->backlight.present) in intel_backlight_update()
1635 mutex_lock(&i915->display.backlight.lock); in intel_backlight_update()
1636 if (!panel->backlight.enabled) in intel_backlight_update()
1639 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_update()
1648 if (!connector->panel.vbt.backlight.present) { in intel_backlight_setup()
1651 "[CONNECTOR:%d:%s] no backlight present per VBT, but present per quirk\n", in intel_backlight_setup()
1655 "[CONNECTOR:%d:%s] no backlight present per VBT\n", in intel_backlight_setup()
1662 if (drm_WARN_ON(&i915->drm, !panel->backlight.funcs)) in intel_backlight_setup()
1666 mutex_lock(&i915->display.backlight.lock); in intel_backlight_setup()
1667 ret = panel->backlight.funcs->setup(connector, pipe); in intel_backlight_setup()
1668 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_setup()
1672 "[CONNECTOR:%d:%s] failed to setup backlight\n", in intel_backlight_setup()
1677 panel->backlight.present = true; in intel_backlight_setup()
1680 "[CONNECTOR:%d:%s] backlight initialized, %s, brightness %u/%u\n", in intel_backlight_setup()
1682 str_enabled_disabled(panel->backlight.enabled), in intel_backlight_setup()
1683 panel->backlight.level, panel->backlight.max); in intel_backlight_setup()
1691 if (panel->backlight.pwm) in intel_backlight_destroy()
1692 pwm_put(panel->backlight.pwm); in intel_backlight_destroy()
1694 panel->backlight.present = false; in intel_backlight_destroy()
1785 /* Set up chip specific backlight functions */
1797 panel->backlight.pwm_funcs = &bxt_pwm_funcs; in intel_backlight_init_funcs()
1799 panel->backlight.pwm_funcs = &cnp_pwm_funcs; in intel_backlight_init_funcs()
1802 panel->backlight.pwm_funcs = &lpt_pwm_funcs; in intel_backlight_init_funcs()
1804 panel->backlight.pwm_funcs = &spt_pwm_funcs; in intel_backlight_init_funcs()
1806 panel->backlight.pwm_funcs = &pch_pwm_funcs; in intel_backlight_init_funcs()
1809 panel->backlight.pwm_funcs = &ext_pwm_funcs; in intel_backlight_init_funcs()
1811 panel->backlight.pwm_funcs = &vlv_pwm_funcs; in intel_backlight_init_funcs()
1814 panel->backlight.pwm_funcs = &i965_pwm_funcs; in intel_backlight_init_funcs()
1816 panel->backlight.pwm_funcs = &i9xx_pwm_funcs; in intel_backlight_init_funcs()
1824 connector->panel.backlight.power = intel_pps_backlight_power; in intel_backlight_init_funcs()
1827 /* We're using a standard PWM backlight interface */ in intel_backlight_init_funcs()
1828 panel->backlight.funcs = &pwm_bl_funcs; in intel_backlight_init_funcs()