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(display->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()
138 val = panel->backlight.pwm_level_max - (val - panel->backlight.pwm_level_min); in intel_backlight_level_from_pwm()
140 return scale(val, panel->backlight.pwm_level_min, panel->backlight.pwm_level_max, in intel_backlight_level_from_pwm()
141 panel->backlight.min, panel->backlight.max); in intel_backlight_level_from_pwm()
168 if (panel->backlight.combination_mode) { in i9xx_get_backlight()
193 return intel_de_read(i915, BXT_BLC_PWM_DUTY(panel->backlight.controller)); in bxt_get_backlight()
201 pwm_get_state(panel->backlight.pwm, &state); in ext_pwm_get_backlight()
232 drm_WARN_ON(&i915->drm, panel->backlight.pwm_level_max == 0); in i9xx_set_backlight()
234 if (panel->backlight.combination_mode) { in i9xx_set_backlight()
237 lbpc = level * 0xfe / panel->backlight.pwm_level_max + 1; in i9xx_set_backlight()
270 intel_de_write(i915, BXT_BLC_PWM_DUTY(panel->backlight.controller), level); in bxt_set_backlight()
277 pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100); in ext_pwm_set_backlight()
278 pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); in ext_pwm_set_backlight()
288 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] set backlight level = %d\n", in intel_panel_actually_set_backlight()
291 panel->backlight.funcs->set(conn_state, level); in intel_panel_actually_set_backlight()
294 /* set backlight brightness to level in range [0..max], assuming hw min is
307 * connection_mutex isn't held across the entire backlight in intel_backlight_set_acpi()
311 if (!panel->backlight.present || !conn_state->crtc) in intel_backlight_set_acpi()
314 mutex_lock(&i915->display.backlight.lock); in intel_backlight_set_acpi()
316 drm_WARN_ON(&i915->drm, panel->backlight.max == 0); in intel_backlight_set_acpi()
319 panel->backlight.level = hw_level; in intel_backlight_set_acpi()
321 if (panel->backlight.device) in intel_backlight_set_acpi()
322 panel->backlight.device->props.brightness = in intel_backlight_set_acpi()
324 panel->backlight.level, in intel_backlight_set_acpi()
325 panel->backlight.device->props.max_brightness); in intel_backlight_set_acpi()
327 if (panel->backlight.enabled) in intel_backlight_set_acpi()
330 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_set_acpi()
351 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] CPU backlight was enabled, disabling\n", in lpt_disable_backlight()
404 intel_de_rmw(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in bxt_disable_backlight()
407 if (panel->backlight.controller == 1) in bxt_disable_backlight()
419 intel_de_rmw(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in cnp_disable_backlight()
430 panel->backlight.pwm_state.enabled = false; in ext_pwm_disable_backlight()
431 pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); in ext_pwm_disable_backlight()
440 if (!panel->backlight.present) in intel_backlight_disable()
444 * Do not disable backlight on the vga_switcheroo path. When switching in intel_backlight_disable()
446 * backlight. This will leave the backlight on unnecessarily when in intel_backlight_disable()
450 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] Skipping backlight disable on vga switch\n", in intel_backlight_disable()
455 mutex_lock(&i915->display.backlight.lock); in intel_backlight_disable()
457 if (panel->backlight.device) in intel_backlight_disable()
458 panel->backlight.device->props.power = BACKLIGHT_POWER_OFF; in intel_backlight_disable()
459 panel->backlight.enabled = false; in intel_backlight_disable()
460 panel->backlight.funcs->disable(old_conn_state, 0); in intel_backlight_disable()
462 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_disable()
475 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] PCH backlight already enabled\n", in lpt_enable_backlight()
483 panel->backlight.alternate_pwm_increment ? in lpt_enable_backlight()
487 panel->backlight.alternate_pwm_increment ? in lpt_enable_backlight()
490 pch_ctl2 = panel->backlight.pwm_level_max << 16; in lpt_enable_backlight()
494 if (panel->backlight.active_low_pwm) in lpt_enable_backlight()
520 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] CPU backlight already enabled\n", in pch_enable_backlight()
528 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] PCH backlight already enabled\n", in pch_enable_backlight()
545 pch_ctl2 = panel->backlight.pwm_level_max << 16; in pch_enable_backlight()
549 if (panel->backlight.active_low_pwm) in pch_enable_backlight()
567 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] backlight already enabled\n", in i9xx_enable_backlight()
572 freq = panel->backlight.pwm_level_max; in i9xx_enable_backlight()
573 if (panel->backlight.combination_mode) in i9xx_enable_backlight()
577 if (panel->backlight.combination_mode) in i9xx_enable_backlight()
579 if (IS_PINEVIEW(i915) && panel->backlight.active_low_pwm) in i9xx_enable_backlight()
589 * Needed to enable backlight on some 855gm models. BLC_HIST_CTL is in i9xx_enable_backlight()
591 * that has backlight. in i9xx_enable_backlight()
608 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] backlight already enabled\n", in i965_enable_backlight()
614 freq = panel->backlight.pwm_level_max; in i965_enable_backlight()
615 if (panel->backlight.combination_mode) in i965_enable_backlight()
622 if (panel->backlight.combination_mode) in i965_enable_backlight()
624 if (panel->backlight.active_low_pwm) in i965_enable_backlight()
644 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] backlight already enabled\n", in vlv_enable_backlight()
650 ctl = panel->backlight.pwm_level_max << 16; in vlv_enable_backlight()
657 if (panel->backlight.active_low_pwm) in vlv_enable_backlight()
674 if (panel->backlight.controller == 1) { in bxt_enable_backlight()
684 if (panel->backlight.util_pin_active_low) in bxt_enable_backlight()
690 pwm_ctl = intel_de_read(i915, BXT_BLC_PWM_CTL(panel->backlight.controller)); in bxt_enable_backlight()
692 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] backlight already enabled\n", in bxt_enable_backlight()
695 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in bxt_enable_backlight()
699 intel_de_write(i915, BXT_BLC_PWM_FREQ(panel->backlight.controller), in bxt_enable_backlight()
700 panel->backlight.pwm_level_max); in bxt_enable_backlight()
705 if (panel->backlight.active_low_pwm) in bxt_enable_backlight()
708 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl); in bxt_enable_backlight()
709 intel_de_posting_read(i915, BXT_BLC_PWM_CTL(panel->backlight.controller)); in bxt_enable_backlight()
710 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in bxt_enable_backlight()
722 pwm_ctl = intel_de_read(i915, BXT_BLC_PWM_CTL(panel->backlight.controller)); in cnp_enable_backlight()
724 drm_dbg_kms(&i915->drm, "backlight already enabled\n"); in cnp_enable_backlight()
726 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in cnp_enable_backlight()
730 intel_de_write(i915, BXT_BLC_PWM_FREQ(panel->backlight.controller), in cnp_enable_backlight()
731 panel->backlight.pwm_level_max); in cnp_enable_backlight()
736 if (panel->backlight.active_low_pwm) in cnp_enable_backlight()
739 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl); in cnp_enable_backlight()
740 intel_de_posting_read(i915, BXT_BLC_PWM_CTL(panel->backlight.controller)); in cnp_enable_backlight()
741 intel_de_write(i915, BXT_BLC_PWM_CTL(panel->backlight.controller), in cnp_enable_backlight()
751 pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100); in ext_pwm_enable_backlight()
752 panel->backlight.pwm_state.enabled = true; in ext_pwm_enable_backlight()
753 pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state); in ext_pwm_enable_backlight()
762 WARN_ON(panel->backlight.max == 0); in __intel_backlight_enable()
764 if (panel->backlight.level < panel->backlight.min) { in __intel_backlight_enable()
765 panel->backlight.level = panel->backlight.min; in __intel_backlight_enable()
766 if (panel->backlight.device) in __intel_backlight_enable()
767 panel->backlight.device->props.brightness = in __intel_backlight_enable()
769 panel->backlight.level, in __intel_backlight_enable()
770 panel->backlight.device->props.max_brightness); in __intel_backlight_enable()
773 panel->backlight.funcs->enable(crtc_state, conn_state, panel->backlight.level); in __intel_backlight_enable()
774 panel->backlight.enabled = true; in __intel_backlight_enable()
775 if (panel->backlight.device) in __intel_backlight_enable()
776 panel->backlight.device->props.power = BACKLIGHT_POWER_ON; in __intel_backlight_enable()
787 if (!panel->backlight.present) in intel_backlight_enable()
792 mutex_lock(&i915->display.backlight.lock); in intel_backlight_enable()
796 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_enable()
806 mutex_lock(&i915->display.backlight.lock); in intel_panel_get_backlight()
808 if (panel->backlight.enabled) in intel_panel_get_backlight()
809 val = panel->backlight.funcs->get(connector, intel_connector_get_pipe(connector)); in intel_panel_get_backlight()
811 mutex_unlock(&i915->display.backlight.lock); in intel_panel_get_backlight()
813 drm_dbg_kms(&i915->drm, "get backlight PWM = %d\n", val); in intel_panel_get_backlight()
824 panel->backlight.min, panel->backlight.max); in scale_user_to_hw()
827 /* set backlight brightness to level in range [0..max], scaling wrt hw min */
836 if (!panel->backlight.present) in intel_panel_set_backlight()
839 mutex_lock(&i915->display.backlight.lock); in intel_panel_set_backlight()
841 drm_WARN_ON(&i915->drm, panel->backlight.max == 0); in intel_panel_set_backlight()
844 panel->backlight.level = hw_level; in intel_panel_set_backlight()
846 if (panel->backlight.enabled) in intel_panel_set_backlight()
849 mutex_unlock(&i915->display.backlight.lock); in intel_panel_set_backlight()
867 * backlight class device does not make it easy to differentiate in intel_backlight_device_update_status()
871 if (panel->backlight.enabled) { in intel_backlight_device_update_status()
872 if (panel->backlight.power) { in intel_backlight_device_update_status()
875 panel->backlight.power(connector, enable); in intel_backlight_device_update_status()
922 if (WARN_ON(panel->backlight.device)) in intel_backlight_device_register()
925 if (!panel->backlight.present) in intel_backlight_device_register()
928 WARN_ON(panel->backlight.max == 0); in intel_backlight_device_register()
939 * Note: Everything should work even if the backlight device max in intel_backlight_device_register()
942 props.max_brightness = panel->backlight.max; in intel_backlight_device_register()
944 panel->backlight.level, in intel_backlight_device_register()
947 if (panel->backlight.enabled) in intel_backlight_device_register()
961 * prevents registration of multiple backlight devices in the in intel_backlight_device_register()
963 * compatibility. Use unique names for subsequent backlight devices as a in intel_backlight_device_register()
967 name = kasprintf(GFP_KERNEL, "card%d-%s-backlight", in intel_backlight_device_register()
977 "[CONNECTOR:%d:%s] backlight device %s register failed: %ld\n", in intel_backlight_device_register()
983 panel->backlight.device = bd; in intel_backlight_device_register()
986 "[CONNECTOR:%d:%s] backlight device %s registered\n", in intel_backlight_device_register()
999 if (panel->backlight.device) { in intel_backlight_device_unregister()
1000 backlight_device_unregister(panel->backlight.device); in intel_backlight_device_unregister()
1001 panel->backlight.device = NULL; in intel_backlight_device_unregister()
1036 if (panel->backlight.alternate_pwm_increment) in spt_hz_to_pwm()
1055 if (panel->backlight.alternate_pwm_increment) in lpt_hz_to_pwm()
1082 * clock frequency/32) in total for a complete cycle of modulated backlight
1146 u16 pwm_freq_hz = connector->panel.vbt.backlight.pwm_freq_hz; in get_vbt_pwm_freq()
1150 "VBT defined backlight frequency %u Hz\n", in get_vbt_pwm_freq()
1155 "default backlight frequency %u Hz\n", in get_vbt_pwm_freq()
1169 if (!panel->backlight.pwm_funcs->hz_to_pwm) { in get_backlight_max_vbt()
1171 "backlight frequency conversion not supported\n"); in get_backlight_max_vbt()
1175 pwm = panel->backlight.pwm_funcs->hz_to_pwm(connector, pwm_freq_hz); in get_backlight_max_vbt()
1178 "backlight frequency conversion failed\n"); in get_backlight_max_vbt()
1194 drm_WARN_ON(&i915->drm, panel->backlight.pwm_level_max == 0); in get_backlight_min_vbt()
1203 min = clamp_t(int, connector->panel.vbt.backlight.min_brightness, 0, 64); in get_backlight_min_vbt()
1204 if (min != connector->panel.vbt.backlight.min_brightness) { in get_backlight_min_vbt()
1206 "clamping VBT min backlight %d/255 to %d/255\n", in get_backlight_min_vbt()
1207 connector->panel.vbt.backlight.min_brightness, min); in get_backlight_min_vbt()
1211 return scale(min, 0, 255, 0, panel->backlight.pwm_level_max); in get_backlight_min_vbt()
1225 panel->backlight.alternate_pwm_increment = alt; in lpt_setup_backlight()
1228 panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY; in lpt_setup_backlight()
1231 panel->backlight.pwm_level_max = pch_ctl2 >> 16; in lpt_setup_backlight()
1235 if (!panel->backlight.pwm_level_max) in lpt_setup_backlight()
1236 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in lpt_setup_backlight()
1238 if (!panel->backlight.pwm_level_max) in lpt_setup_backlight()
1241 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in lpt_setup_backlight()
1243 panel->backlight.pwm_enabled = pch_ctl1 & BLM_PCH_PWM_ENABLE; in lpt_setup_backlight()
1245 cpu_mode = panel->backlight.pwm_enabled && HAS_PCH_LPT(i915) && in lpt_setup_backlight()
1253 "CPU backlight register was enabled, switching to PCH override\n"); in lpt_setup_backlight()
1265 "[CONNECTOR:%d:%s] Using native PCH PWM for backlight control\n", in lpt_setup_backlight()
1278 panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY; in pch_setup_backlight()
1281 panel->backlight.pwm_level_max = pch_ctl2 >> 16; in pch_setup_backlight()
1283 if (!panel->backlight.pwm_level_max) in pch_setup_backlight()
1284 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in pch_setup_backlight()
1286 if (!panel->backlight.pwm_level_max) in pch_setup_backlight()
1289 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in pch_setup_backlight()
1292 panel->backlight.pwm_enabled = (cpu_ctl2 & BLM_PWM_ENABLE) && in pch_setup_backlight()
1296 "[CONNECTOR:%d:%s] Using native PCH PWM for backlight control\n", in pch_setup_backlight()
1311 panel->backlight.combination_mode = ctl & BLM_LEGACY_MODE; in i9xx_setup_backlight()
1314 panel->backlight.active_low_pwm = ctl & BLM_POLARITY_PNV; in i9xx_setup_backlight()
1316 panel->backlight.pwm_level_max = ctl >> 17; in i9xx_setup_backlight()
1318 if (!panel->backlight.pwm_level_max) { in i9xx_setup_backlight()
1319 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in i9xx_setup_backlight()
1320 panel->backlight.pwm_level_max >>= 1; in i9xx_setup_backlight()
1323 if (!panel->backlight.pwm_level_max) in i9xx_setup_backlight()
1326 if (panel->backlight.combination_mode) in i9xx_setup_backlight()
1327 panel->backlight.pwm_level_max *= 0xff; in i9xx_setup_backlight()
1329 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in i9xx_setup_backlight()
1333 val = clamp(val, panel->backlight.pwm_level_min, panel->backlight.pwm_level_max); in i9xx_setup_backlight()
1335 panel->backlight.pwm_enabled = val != 0; in i9xx_setup_backlight()
1338 "[CONNECTOR:%d:%s] Using native PWM for backlight control\n", in i9xx_setup_backlight()
1351 panel->backlight.combination_mode = ctl2 & BLM_COMBINATION_MODE; in i965_setup_backlight()
1352 panel->backlight.active_low_pwm = ctl2 & BLM_POLARITY_I965; in i965_setup_backlight()
1355 panel->backlight.pwm_level_max = ctl >> 16; in i965_setup_backlight()
1357 if (!panel->backlight.pwm_level_max) in i965_setup_backlight()
1358 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in i965_setup_backlight()
1360 if (!panel->backlight.pwm_level_max) in i965_setup_backlight()
1363 if (panel->backlight.combination_mode) in i965_setup_backlight()
1364 panel->backlight.pwm_level_max *= 0xff; in i965_setup_backlight()
1366 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in i965_setup_backlight()
1368 panel->backlight.pwm_enabled = ctl2 & BLM_PWM_ENABLE; in i965_setup_backlight()
1371 "[CONNECTOR:%d:%s] Using native PWM for backlight control\n", in i965_setup_backlight()
1387 panel->backlight.active_low_pwm = ctl2 & BLM_POLARITY_I965; in vlv_setup_backlight()
1390 panel->backlight.pwm_level_max = ctl >> 16; in vlv_setup_backlight()
1392 if (!panel->backlight.pwm_level_max) in vlv_setup_backlight()
1393 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in vlv_setup_backlight()
1395 if (!panel->backlight.pwm_level_max) in vlv_setup_backlight()
1398 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in vlv_setup_backlight()
1400 panel->backlight.pwm_enabled = ctl2 & BLM_PWM_ENABLE; in vlv_setup_backlight()
1403 "[CONNECTOR:%d:%s] Using native PWM for backlight control (on pipe %c)\n", in vlv_setup_backlight()
1416 panel->backlight.controller = connector->panel.vbt.backlight.controller; in bxt_setup_backlight()
1419 BXT_BLC_PWM_CTL(panel->backlight.controller)); in bxt_setup_backlight()
1422 if (panel->backlight.controller == 1) { in bxt_setup_backlight()
1424 panel->backlight.util_pin_active_low = in bxt_setup_backlight()
1428 panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY; in bxt_setup_backlight()
1429 panel->backlight.pwm_level_max = in bxt_setup_backlight()
1430 intel_de_read(i915, BXT_BLC_PWM_FREQ(panel->backlight.controller)); in bxt_setup_backlight()
1432 if (!panel->backlight.pwm_level_max) in bxt_setup_backlight()
1433 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in bxt_setup_backlight()
1435 if (!panel->backlight.pwm_level_max) in bxt_setup_backlight()
1438 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in bxt_setup_backlight()
1440 panel->backlight.pwm_enabled = pwm_ctl & BXT_BLC_PWM_ENABLE; in bxt_setup_backlight()
1443 "[CONNECTOR:%d:%s] Using native PWM for backlight control (controller=%d)\n", in bxt_setup_backlight()
1445 panel->backlight.controller); in bxt_setup_backlight()
1485 * CNP has the BXT implementation of backlight, but with only one in cnp_setup_backlight()
1488 panel->backlight.controller = connector->panel.vbt.backlight.controller; in cnp_setup_backlight()
1489 if (!cnp_backlight_controller_is_valid(i915, panel->backlight.controller)) { in cnp_setup_backlight()
1490 drm_dbg_kms(&i915->drm, "[CONNECTOR:%d:%s] Invalid backlight controller %d, assuming 0\n", in cnp_setup_backlight()
1492 panel->backlight.controller); in cnp_setup_backlight()
1493 panel->backlight.controller = 0; in cnp_setup_backlight()
1497 BXT_BLC_PWM_CTL(panel->backlight.controller)); in cnp_setup_backlight()
1499 panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY; in cnp_setup_backlight()
1500 panel->backlight.pwm_level_max = in cnp_setup_backlight()
1501 intel_de_read(i915, BXT_BLC_PWM_FREQ(panel->backlight.controller)); in cnp_setup_backlight()
1503 if (!panel->backlight.pwm_level_max) in cnp_setup_backlight()
1504 panel->backlight.pwm_level_max = get_backlight_max_vbt(connector); in cnp_setup_backlight()
1506 if (!panel->backlight.pwm_level_max) in cnp_setup_backlight()
1509 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in cnp_setup_backlight()
1511 panel->backlight.pwm_enabled = pwm_ctl & BXT_BLC_PWM_ENABLE; in cnp_setup_backlight()
1514 "[CONNECTOR:%d:%s] Using native PCH PWM for backlight control (controller=%d)\n", in cnp_setup_backlight()
1516 panel->backlight.controller); in cnp_setup_backlight()
1529 /* Get the right PWM chip for DSI backlight according to VBT */ in ext_pwm_setup_backlight()
1531 panel->backlight.pwm = pwm_get(i915->drm.dev, "pwm_pmic_backlight"); in ext_pwm_setup_backlight()
1534 panel->backlight.pwm = pwm_get(i915->drm.dev, "pwm_soc_backlight"); in ext_pwm_setup_backlight()
1538 if (IS_ERR(panel->backlight.pwm)) { in ext_pwm_setup_backlight()
1541 panel->backlight.pwm = NULL; in ext_pwm_setup_backlight()
1545 panel->backlight.pwm_level_max = 100; /* 100% */ in ext_pwm_setup_backlight()
1546 panel->backlight.pwm_level_min = get_backlight_min_vbt(connector); in ext_pwm_setup_backlight()
1548 if (pwm_is_enabled(panel->backlight.pwm)) { in ext_pwm_setup_backlight()
1550 pwm_get_state(panel->backlight.pwm, &panel->backlight.pwm_state); in ext_pwm_setup_backlight()
1552 level = pwm_get_relative_duty_cycle(&panel->backlight.pwm_state, in ext_pwm_setup_backlight()
1555 panel->backlight.pwm_enabled = true; in ext_pwm_setup_backlight()
1559 NSEC_PER_SEC / (unsigned long)panel->backlight.pwm_state.period, in ext_pwm_setup_backlight()
1563 panel->backlight.pwm_state.period = in ext_pwm_setup_backlight()
1568 "[CONNECTOR:%d:%s] Using %s PWM for backlight control\n", in ext_pwm_setup_backlight()
1579 panel->backlight.pwm_funcs->set(conn_state, in intel_pwm_set_backlight()
1588 panel->backlight.pwm_funcs->get(connector, pipe)); in intel_pwm_get_backlight()
1597 panel->backlight.pwm_funcs->enable(crtc_state, conn_state, in intel_pwm_enable_backlight()
1606 panel->backlight.pwm_funcs->disable(conn_state, in intel_pwm_disable_backlight()
1615 ret = panel->backlight.pwm_funcs->setup(connector, pipe); in intel_pwm_setup_backlight()
1619 panel->backlight.min = panel->backlight.pwm_level_min; in intel_pwm_setup_backlight()
1620 panel->backlight.max = panel->backlight.pwm_level_max; in intel_pwm_setup_backlight()
1621 panel->backlight.level = intel_pwm_get_backlight(connector, pipe); in intel_pwm_setup_backlight()
1622 panel->backlight.enabled = panel->backlight.pwm_enabled; in intel_pwm_setup_backlight()
1636 if (!panel->backlight.present) in intel_backlight_update()
1639 mutex_lock(&i915->display.backlight.lock); in intel_backlight_update()
1640 if (!panel->backlight.enabled) in intel_backlight_update()
1643 mutex_unlock(&i915->display.backlight.lock); in intel_backlight_update()
1652 if (!connector->panel.vbt.backlight.present) { in intel_backlight_setup()
1655 "[CONNECTOR:%d:%s] no backlight present per VBT, but present per quirk\n", in intel_backlight_setup()
1659 "[CONNECTOR:%d:%s] no backlight present per VBT\n", in intel_backlight_setup()
1666 if (drm_WARN_ON(display->drm, !panel->backlight.funcs)) in intel_backlight_setup()
1670 mutex_lock(&display->backlight.lock); in intel_backlight_setup()
1671 ret = panel->backlight.funcs->setup(connector, pipe); in intel_backlight_setup()
1672 mutex_unlock(&display->backlight.lock); in intel_backlight_setup()
1676 "[CONNECTOR:%d:%s] failed to setup backlight\n", in intel_backlight_setup()
1681 panel->backlight.present = true; in intel_backlight_setup()
1684 "[CONNECTOR:%d:%s] backlight initialized, %s, brightness %u/%u\n", in intel_backlight_setup()
1686 str_enabled_disabled(panel->backlight.enabled), in intel_backlight_setup()
1687 panel->backlight.level, panel->backlight.max); in intel_backlight_setup()
1695 if (panel->backlight.pwm) in intel_backlight_destroy()
1696 pwm_put(panel->backlight.pwm); in intel_backlight_destroy()
1698 panel->backlight.present = false; in intel_backlight_destroy()
1789 /* Set up chip specific backlight functions */
1801 panel->backlight.pwm_funcs = &bxt_pwm_funcs; in intel_backlight_init_funcs()
1803 panel->backlight.pwm_funcs = &cnp_pwm_funcs; in intel_backlight_init_funcs()
1806 panel->backlight.pwm_funcs = &lpt_pwm_funcs; in intel_backlight_init_funcs()
1808 panel->backlight.pwm_funcs = &spt_pwm_funcs; in intel_backlight_init_funcs()
1810 panel->backlight.pwm_funcs = &pch_pwm_funcs; in intel_backlight_init_funcs()
1813 panel->backlight.pwm_funcs = &ext_pwm_funcs; in intel_backlight_init_funcs()
1815 panel->backlight.pwm_funcs = &vlv_pwm_funcs; in intel_backlight_init_funcs()
1818 panel->backlight.pwm_funcs = &i965_pwm_funcs; in intel_backlight_init_funcs()
1820 panel->backlight.pwm_funcs = &i9xx_pwm_funcs; in intel_backlight_init_funcs()
1828 connector->panel.backlight.power = intel_pps_backlight_power; in intel_backlight_init_funcs()
1831 /* We're using a standard PWM backlight interface */ in intel_backlight_init_funcs()
1832 panel->backlight.funcs = &pwm_bl_funcs; in intel_backlight_init_funcs()