2016-04-05 14:10:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2015 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
/*
|
|
|
|
* Laptops with Intel GPUs which have panels that support controlling the
|
|
|
|
* backlight through DP AUX can actually use two different interfaces: Intel's
|
|
|
|
* proprietary DP AUX backlight interface, and the standard VESA backlight
|
|
|
|
* interface. Unfortunately, at the time of writing this a lot of laptops will
|
|
|
|
* advertise support for the standard VESA backlight interface when they
|
|
|
|
* don't properly support it. However, on these systems the Intel backlight
|
|
|
|
* interface generally does work properly. Additionally, these systems will
|
|
|
|
* usually just indicate that they use PWM backlight controls in their VBIOS
|
|
|
|
* for some reason.
|
|
|
|
*/
|
|
|
|
|
2019-08-06 11:39:33 +00:00
|
|
|
#include "intel_display_types.h"
|
2019-04-29 12:29:26 +00:00
|
|
|
#include "intel_dp_aux_backlight.h"
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
#include "intel_panel.h"
|
|
|
|
|
|
|
|
/* TODO:
|
|
|
|
* Implement HDR, right now we just implement the bare minimum to bring us back into SDR mode so we
|
|
|
|
* can make people's backlights work in the mean time
|
|
|
|
*/
|
2016-04-05 14:10:52 +00:00
|
|
|
|
2020-12-04 22:36:00 +00:00
|
|
|
/*
|
|
|
|
* DP AUX registers for Intel's proprietary HDR backlight interface. We define
|
|
|
|
* them here since we'll likely be the only driver to ever use these.
|
|
|
|
*/
|
|
|
|
#define INTEL_EDP_HDR_TCON_CAP0 0x340
|
|
|
|
|
|
|
|
#define INTEL_EDP_HDR_TCON_CAP1 0x341
|
|
|
|
# define INTEL_EDP_HDR_TCON_2084_DECODE_CAP BIT(0)
|
|
|
|
# define INTEL_EDP_HDR_TCON_2020_GAMUT_CAP BIT(1)
|
|
|
|
# define INTEL_EDP_HDR_TCON_TONE_MAPPING_CAP BIT(2)
|
|
|
|
# define INTEL_EDP_HDR_TCON_SEGMENTED_BACKLIGHT_CAP BIT(3)
|
|
|
|
# define INTEL_EDP_HDR_TCON_BRIGHTNESS_NITS_CAP BIT(4)
|
|
|
|
# define INTEL_EDP_HDR_TCON_OPTIMIZATION_CAP BIT(5)
|
|
|
|
# define INTEL_EDP_HDR_TCON_SDP_COLORIMETRY_CAP BIT(6)
|
|
|
|
# define INTEL_EDP_HDR_TCON_SRGB_TO_PANEL_GAMUT_CONVERSION_CAP BIT(7)
|
|
|
|
|
|
|
|
#define INTEL_EDP_HDR_TCON_CAP2 0x342
|
|
|
|
# define INTEL_EDP_SDR_TCON_BRIGHTNESS_AUX_CAP BIT(0)
|
|
|
|
|
|
|
|
#define INTEL_EDP_HDR_TCON_CAP3 0x343
|
|
|
|
|
|
|
|
#define INTEL_EDP_HDR_GETSET_CTRL_PARAMS 0x344
|
|
|
|
# define INTEL_EDP_HDR_TCON_2084_DECODE_ENABLE BIT(0)
|
|
|
|
# define INTEL_EDP_HDR_TCON_2020_GAMUT_ENABLE BIT(1)
|
|
|
|
# define INTEL_EDP_HDR_TCON_TONE_MAPPING_ENABLE BIT(2) /* Pre-TGL+ */
|
|
|
|
# define INTEL_EDP_HDR_TCON_SEGMENTED_BACKLIGHT_ENABLE BIT(3)
|
|
|
|
# define INTEL_EDP_HDR_TCON_BRIGHTNESS_AUX_ENABLE BIT(4)
|
|
|
|
# define INTEL_EDP_HDR_TCON_SRGB_TO_PANEL_GAMUT_ENABLE BIT(5)
|
|
|
|
/* Bit 6 is reserved */
|
|
|
|
# define INTEL_EDP_HDR_TCON_SDP_COLORIMETRY_ENABLE BIT(7)
|
|
|
|
|
|
|
|
#define INTEL_EDP_HDR_CONTENT_LUMINANCE 0x346 /* Pre-TGL+ */
|
|
|
|
#define INTEL_EDP_HDR_PANEL_LUMINANCE_OVERRIDE 0x34A
|
|
|
|
#define INTEL_EDP_SDR_LUMINANCE_LEVEL 0x352
|
|
|
|
#define INTEL_EDP_BRIGHTNESS_NITS_LSB 0x354
|
|
|
|
#define INTEL_EDP_BRIGHTNESS_NITS_MSB 0x355
|
|
|
|
#define INTEL_EDP_BRIGHTNESS_DELAY_FRAMES 0x356
|
|
|
|
#define INTEL_EDP_BRIGHTNESS_PER_FRAME_STEPS 0x357
|
|
|
|
|
|
|
|
#define INTEL_EDP_BRIGHTNESS_OPTIMIZATION_0 0x358
|
|
|
|
# define INTEL_EDP_TCON_USAGE_MASK GENMASK(0, 3)
|
|
|
|
# define INTEL_EDP_TCON_USAGE_UNKNOWN 0x0
|
|
|
|
# define INTEL_EDP_TCON_USAGE_DESKTOP 0x1
|
|
|
|
# define INTEL_EDP_TCON_USAGE_FULL_SCREEN_MEDIA 0x2
|
|
|
|
# define INTEL_EDP_TCON_USAGE_FULL_SCREEN_GAMING 0x3
|
|
|
|
# define INTEL_EDP_TCON_POWER_MASK BIT(4)
|
|
|
|
# define INTEL_EDP_TCON_POWER_DC (0 << 4)
|
|
|
|
# define INTEL_EDP_TCON_POWER_AC (1 << 4)
|
|
|
|
# define INTEL_EDP_TCON_OPTIMIZATION_STRENGTH_MASK GENMASK(5, 7)
|
|
|
|
|
|
|
|
#define INTEL_EDP_BRIGHTNESS_OPTIMIZATION_1 0x359
|
|
|
|
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
/* Intel EDP backlight callbacks */
|
|
|
|
static bool
|
|
|
|
intel_dp_aux_supports_hdr_backlight(struct intel_connector *connector)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *i915 = to_i915(connector->base.dev);
|
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
|
|
|
|
struct drm_dp_aux *aux = &intel_dp->aux;
|
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
int ret;
|
|
|
|
u8 tcon_cap[4];
|
|
|
|
|
|
|
|
ret = drm_dp_dpcd_read(aux, INTEL_EDP_HDR_TCON_CAP0, tcon_cap, sizeof(tcon_cap));
|
|
|
|
if (ret < 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!(tcon_cap[1] & INTEL_EDP_HDR_TCON_BRIGHTNESS_NITS_CAP))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (tcon_cap[0] >= 1) {
|
|
|
|
drm_dbg_kms(&i915->drm, "Detected Intel HDR backlight interface version %d\n",
|
|
|
|
tcon_cap[0]);
|
|
|
|
} else {
|
|
|
|
drm_dbg_kms(&i915->drm, "Detected unsupported HDR backlight interface version %d\n",
|
|
|
|
tcon_cap[0]);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
panel->backlight.edp.intel.sdr_uses_aux =
|
|
|
|
tcon_cap[2] & INTEL_EDP_SDR_TCON_BRIGHTNESS_AUX_CAP;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32
|
|
|
|
intel_dp_aux_hdr_get_backlight(struct intel_connector *connector, enum pipe pipe)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *i915 = to_i915(connector->base.dev);
|
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
|
|
|
|
u8 tmp;
|
|
|
|
u8 buf[2] = { 0 };
|
|
|
|
|
|
|
|
if (drm_dp_dpcd_readb(&intel_dp->aux, INTEL_EDP_HDR_GETSET_CTRL_PARAMS, &tmp) < 0) {
|
|
|
|
drm_err(&i915->drm, "Failed to read current backlight mode from DPCD\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(tmp & INTEL_EDP_HDR_TCON_BRIGHTNESS_AUX_ENABLE)) {
|
|
|
|
if (!panel->backlight.edp.intel.sdr_uses_aux) {
|
|
|
|
u32 pwm_level = panel->backlight.pwm_funcs->get(connector, pipe);
|
|
|
|
|
|
|
|
return intel_panel_backlight_level_from_pwm(connector, pwm_level);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Assume 100% brightness if backlight controls aren't enabled yet */
|
|
|
|
return panel->backlight.max;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (drm_dp_dpcd_read(&intel_dp->aux, INTEL_EDP_BRIGHTNESS_NITS_LSB, buf, sizeof(buf)) < 0) {
|
|
|
|
drm_err(&i915->drm, "Failed to read brightness from DPCD\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (buf[1] << 8 | buf[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
intel_dp_aux_hdr_set_aux_backlight(const struct drm_connector_state *conn_state, u32 level)
|
|
|
|
{
|
|
|
|
struct intel_connector *connector = to_intel_connector(conn_state->connector);
|
|
|
|
struct drm_device *dev = connector->base.dev;
|
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
|
|
|
|
u8 buf[4] = { 0 };
|
|
|
|
|
|
|
|
buf[0] = level & 0xFF;
|
|
|
|
buf[1] = (level & 0xFF00) >> 8;
|
|
|
|
|
|
|
|
if (drm_dp_dpcd_write(&intel_dp->aux, INTEL_EDP_BRIGHTNESS_NITS_LSB, buf, 4) < 0)
|
|
|
|
drm_err(dev, "Failed to write brightness level to DPCD\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
intel_dp_aux_hdr_set_backlight(const struct drm_connector_state *conn_state, u32 level)
|
|
|
|
{
|
|
|
|
struct intel_connector *connector = to_intel_connector(conn_state->connector);
|
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
|
|
|
|
if (panel->backlight.edp.intel.sdr_uses_aux) {
|
|
|
|
intel_dp_aux_hdr_set_aux_backlight(conn_state, level);
|
|
|
|
} else {
|
|
|
|
const u32 pwm_level = intel_panel_backlight_level_to_pwm(connector, level);
|
|
|
|
|
|
|
|
intel_panel_set_pwm_level(conn_state, pwm_level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
intel_dp_aux_hdr_enable_backlight(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct drm_connector_state *conn_state, u32 level)
|
|
|
|
{
|
|
|
|
struct intel_connector *connector = to_intel_connector(conn_state->connector);
|
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
struct drm_i915_private *i915 = to_i915(connector->base.dev);
|
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
|
|
|
|
int ret;
|
|
|
|
u8 old_ctrl, ctrl;
|
|
|
|
|
|
|
|
ret = drm_dp_dpcd_readb(&intel_dp->aux, INTEL_EDP_HDR_GETSET_CTRL_PARAMS, &old_ctrl);
|
|
|
|
if (ret < 0) {
|
|
|
|
drm_err(&i915->drm, "Failed to read current backlight control mode: %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl = old_ctrl;
|
|
|
|
if (panel->backlight.edp.intel.sdr_uses_aux) {
|
|
|
|
ctrl |= INTEL_EDP_HDR_TCON_BRIGHTNESS_AUX_ENABLE;
|
|
|
|
intel_dp_aux_hdr_set_aux_backlight(conn_state, level);
|
|
|
|
} else {
|
|
|
|
u32 pwm_level = intel_panel_backlight_level_to_pwm(connector, level);
|
|
|
|
|
|
|
|
panel->backlight.pwm_funcs->enable(crtc_state, conn_state, pwm_level);
|
|
|
|
|
|
|
|
ctrl &= ~INTEL_EDP_HDR_TCON_BRIGHTNESS_AUX_ENABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ctrl != old_ctrl)
|
|
|
|
if (drm_dp_dpcd_writeb(&intel_dp->aux, INTEL_EDP_HDR_GETSET_CTRL_PARAMS, ctrl) < 0)
|
|
|
|
drm_err(&i915->drm, "Failed to configure DPCD brightness controls\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
intel_dp_aux_hdr_disable_backlight(const struct drm_connector_state *conn_state, u32 level)
|
|
|
|
{
|
|
|
|
struct intel_connector *connector = to_intel_connector(conn_state->connector);
|
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
|
|
|
|
/* Nothing to do for AUX based backlight controls */
|
|
|
|
if (panel->backlight.edp.intel.sdr_uses_aux)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Note we want the actual pwm_level to be 0, regardless of pwm_min */
|
|
|
|
panel->backlight.pwm_funcs->disable(conn_state, intel_panel_invert_pwm_level(connector, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
intel_dp_aux_hdr_setup_backlight(struct intel_connector *connector, enum pipe pipe)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *i915 = to_i915(connector->base.dev);
|
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (panel->backlight.edp.intel.sdr_uses_aux) {
|
|
|
|
drm_dbg_kms(&i915->drm, "SDR backlight is controlled through DPCD\n");
|
|
|
|
} else {
|
|
|
|
drm_dbg_kms(&i915->drm, "SDR backlight is controlled through PWM\n");
|
|
|
|
|
|
|
|
ret = panel->backlight.pwm_funcs->setup(connector, pipe);
|
|
|
|
if (ret < 0) {
|
|
|
|
drm_err(&i915->drm,
|
|
|
|
"Failed to setup SDR backlight controls through PWM: %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
panel->backlight.max = 512;
|
|
|
|
panel->backlight.min = 0;
|
|
|
|
panel->backlight.level = intel_dp_aux_hdr_get_backlight(connector, pipe);
|
|
|
|
panel->backlight.enabled = panel->backlight.level != 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-12-04 22:36:00 +00:00
|
|
|
/* VESA backlight callbacks */
|
2020-12-04 22:35:59 +00:00
|
|
|
static void set_vesa_backlight_enable(struct intel_dp *intel_dp, bool enable)
|
2016-04-05 14:10:52 +00:00
|
|
|
{
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
|
2018-06-12 09:19:33 +00:00
|
|
|
u8 reg_val = 0;
|
2016-04-05 14:10:52 +00:00
|
|
|
|
2017-05-23 22:38:01 +00:00
|
|
|
/* Early return when display use other mechanism to enable backlight. */
|
|
|
|
if (!(intel_dp->edp_dpcd[1] & DP_EDP_BACKLIGHT_AUX_ENABLE_CAP))
|
|
|
|
return;
|
|
|
|
|
2016-04-05 14:10:52 +00:00
|
|
|
if (drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_DISPLAY_CONTROL_REGISTER,
|
|
|
|
®_val) < 0) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm, "Failed to read DPCD register 0x%x\n",
|
|
|
|
DP_EDP_DISPLAY_CONTROL_REGISTER);
|
2016-04-05 14:10:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (enable)
|
|
|
|
reg_val |= DP_EDP_BACKLIGHT_ENABLE;
|
|
|
|
else
|
|
|
|
reg_val &= ~(DP_EDP_BACKLIGHT_ENABLE);
|
|
|
|
|
|
|
|
if (drm_dp_dpcd_writeb(&intel_dp->aux, DP_EDP_DISPLAY_CONTROL_REGISTER,
|
|
|
|
reg_val) != 1) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm, "Failed to %s aux backlight\n",
|
|
|
|
enable ? "enable" : "disable");
|
2016-04-05 14:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-04 22:35:59 +00:00
|
|
|
static bool intel_dp_aux_vesa_backlight_dpcd_mode(struct intel_connector *connector)
|
2016-04-05 14:10:52 +00:00
|
|
|
{
|
2019-12-04 18:05:47 +00:00
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
|
2020-01-16 21:16:09 +00:00
|
|
|
u8 mode_reg;
|
2016-04-05 14:10:52 +00:00
|
|
|
|
2020-01-16 21:16:09 +00:00
|
|
|
if (drm_dp_dpcd_readb(&intel_dp->aux,
|
|
|
|
DP_EDP_BACKLIGHT_MODE_SET_REGISTER,
|
|
|
|
&mode_reg) != 1) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"Failed to read the DPCD register 0x%x\n",
|
|
|
|
DP_EDP_BACKLIGHT_MODE_SET_REGISTER);
|
2020-09-18 00:28:42 +00:00
|
|
|
return false;
|
2020-01-16 21:16:09 +00:00
|
|
|
}
|
|
|
|
|
2020-09-18 00:28:42 +00:00
|
|
|
return (mode_reg & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK) ==
|
|
|
|
DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the current backlight value from DPCD register(s) based
|
|
|
|
* on if 8-bit(MSB) or 16-bit(MSB and LSB) values are supported
|
|
|
|
*/
|
2021-01-14 22:17:05 +00:00
|
|
|
static u32 intel_dp_aux_vesa_get_backlight(struct intel_connector *connector, enum pipe unused)
|
2020-09-18 00:28:42 +00:00
|
|
|
{
|
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
|
|
|
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
|
|
|
|
u8 read_val[2] = { 0x0 };
|
|
|
|
u16 level = 0;
|
|
|
|
|
2020-01-16 21:16:09 +00:00
|
|
|
/*
|
|
|
|
* If we're not in DPCD control mode yet, the programmed brightness
|
|
|
|
* value is meaningless and we should assume max brightness
|
|
|
|
*/
|
2020-12-04 22:35:59 +00:00
|
|
|
if (!intel_dp_aux_vesa_backlight_dpcd_mode(connector))
|
2020-01-16 21:16:09 +00:00
|
|
|
return connector->panel.backlight.max;
|
|
|
|
|
2016-04-05 14:10:52 +00:00
|
|
|
if (drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB,
|
|
|
|
&read_val, sizeof(read_val)) < 0) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm, "Failed to read DPCD register 0x%x\n",
|
|
|
|
DP_EDP_BACKLIGHT_BRIGHTNESS_MSB);
|
2016-04-05 14:10:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
level = read_val[0];
|
|
|
|
if (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_BYTE_COUNT)
|
|
|
|
level = (read_val[0] << 8 | read_val[1]);
|
|
|
|
|
|
|
|
return level;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sends the current backlight level over the aux channel, checking if its using
|
|
|
|
* 8-bit or 16 bit value (MSB and LSB)
|
|
|
|
*/
|
|
|
|
static void
|
2020-12-04 22:35:59 +00:00
|
|
|
intel_dp_aux_vesa_set_backlight(const struct drm_connector_state *conn_state,
|
|
|
|
u32 level)
|
2016-04-05 14:10:52 +00:00
|
|
|
{
|
2017-06-12 10:21:15 +00:00
|
|
|
struct intel_connector *connector = to_intel_connector(conn_state->connector);
|
2019-12-04 18:05:47 +00:00
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
|
2018-06-12 09:19:33 +00:00
|
|
|
u8 vals[2] = { 0x0 };
|
2016-04-05 14:10:52 +00:00
|
|
|
|
|
|
|
vals[0] = level;
|
|
|
|
|
|
|
|
/* Write the MSB and/or LSB */
|
|
|
|
if (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_BYTE_COUNT) {
|
|
|
|
vals[0] = (level & 0xFF00) >> 8;
|
|
|
|
vals[1] = (level & 0xFF);
|
|
|
|
}
|
|
|
|
if (drm_dp_dpcd_write(&intel_dp->aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB,
|
|
|
|
vals, sizeof(vals)) < 0) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"Failed to write aux backlight level\n");
|
2016-04-05 14:10:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-22 19:03:37 +00:00
|
|
|
/*
|
|
|
|
* Set PWM Frequency divider to match desired frequency in vbt.
|
|
|
|
* The PWM Frequency is calculated as 27Mhz / (F x P).
|
|
|
|
* - Where F = PWM Frequency Pre-Divider value programmed by field 7:0 of the
|
|
|
|
* EDP_BACKLIGHT_FREQ_SET register (DPCD Address 00728h)
|
|
|
|
* - Where P = 2^Pn, where Pn is the value programmed by field 4:0 of the
|
|
|
|
* EDP_PWMGEN_BIT_COUNT register (DPCD Address 00724h)
|
|
|
|
*/
|
2020-12-04 22:35:59 +00:00
|
|
|
static bool intel_dp_aux_vesa_set_pwm_freq(struct intel_connector *connector)
|
2017-06-22 19:03:37 +00:00
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
|
2019-12-04 18:05:47 +00:00
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
const u8 pn = connector->panel.backlight.edp.vesa.pwmgen_bit_count;
|
2020-01-16 21:16:08 +00:00
|
|
|
int freq, fxp, f, fxp_actual, fxp_min, fxp_max;
|
2017-06-22 19:03:37 +00:00
|
|
|
|
|
|
|
freq = dev_priv->vbt.backlight.pwm_freq_hz;
|
|
|
|
if (!freq) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Use panel default backlight frequency\n");
|
2017-06-22 19:03:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
fxp = DIV_ROUND_CLOSEST(KHz(DP_EDP_BACKLIGHT_FREQ_BASE_KHZ), freq);
|
2020-01-16 21:16:08 +00:00
|
|
|
f = clamp(DIV_ROUND_CLOSEST(fxp, 1 << pn), 1, 255);
|
|
|
|
fxp_actual = f << pn;
|
2017-06-22 19:03:37 +00:00
|
|
|
|
2020-01-16 21:16:08 +00:00
|
|
|
/* Ensure frequency is within 25% of desired value */
|
2017-06-22 19:03:37 +00:00
|
|
|
fxp_min = DIV_ROUND_CLOSEST(fxp * 3, 4);
|
|
|
|
fxp_max = DIV_ROUND_CLOSEST(fxp * 5, 4);
|
|
|
|
|
2020-01-16 21:16:08 +00:00
|
|
|
if (fxp_min > fxp_actual || fxp_actual > fxp_max) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm, "Actual frequency out of range\n");
|
2017-06-22 19:03:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-01-16 21:16:08 +00:00
|
|
|
|
2017-06-22 19:03:37 +00:00
|
|
|
if (drm_dp_dpcd_writeb(&intel_dp->aux,
|
|
|
|
DP_EDP_BACKLIGHT_FREQ_SET, (u8) f) < 0) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&dev_priv->drm,
|
|
|
|
"Failed to write aux backlight freq\n");
|
2017-06-22 19:03:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-12-04 22:35:59 +00:00
|
|
|
static void
|
|
|
|
intel_dp_aux_vesa_enable_backlight(const struct intel_crtc_state *crtc_state,
|
|
|
|
const struct drm_connector_state *conn_state, u32 level)
|
2016-04-05 14:10:52 +00:00
|
|
|
{
|
2017-06-12 10:21:15 +00:00
|
|
|
struct intel_connector *connector = to_intel_connector(conn_state->connector);
|
2019-12-04 18:05:47 +00:00
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
|
2020-01-16 21:16:08 +00:00
|
|
|
struct intel_panel *panel = &connector->panel;
|
2018-06-12 09:19:33 +00:00
|
|
|
u8 dpcd_buf, new_dpcd_buf, edp_backlight_mode;
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
u8 pwmgen_bit_count = panel->backlight.edp.vesa.pwmgen_bit_count;
|
2016-04-05 14:10:52 +00:00
|
|
|
|
2017-05-11 23:02:18 +00:00
|
|
|
if (drm_dp_dpcd_readb(&intel_dp->aux,
|
|
|
|
DP_EDP_BACKLIGHT_MODE_SET_REGISTER, &dpcd_buf) != 1) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm, "Failed to read DPCD register 0x%x\n",
|
|
|
|
DP_EDP_BACKLIGHT_MODE_SET_REGISTER);
|
2017-05-11 23:02:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-22 19:03:37 +00:00
|
|
|
new_dpcd_buf = dpcd_buf;
|
2017-05-11 23:02:18 +00:00
|
|
|
edp_backlight_mode = dpcd_buf & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
|
|
|
|
|
|
|
|
switch (edp_backlight_mode) {
|
|
|
|
case DP_EDP_BACKLIGHT_CONTROL_MODE_PWM:
|
|
|
|
case DP_EDP_BACKLIGHT_CONTROL_MODE_PRESET:
|
|
|
|
case DP_EDP_BACKLIGHT_CONTROL_MODE_PRODUCT:
|
2017-06-22 19:03:37 +00:00
|
|
|
new_dpcd_buf &= ~DP_EDP_BACKLIGHT_CONTROL_MODE_MASK;
|
|
|
|
new_dpcd_buf |= DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
|
2020-01-16 21:16:08 +00:00
|
|
|
|
|
|
|
if (drm_dp_dpcd_writeb(&intel_dp->aux,
|
|
|
|
DP_EDP_PWMGEN_BIT_COUNT,
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
pwmgen_bit_count) < 0)
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"Failed to write aux pwmgen bit count\n");
|
2020-01-16 21:16:08 +00:00
|
|
|
|
2017-05-11 23:02:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Do nothing when it is already DPCD mode */
|
|
|
|
case DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-05-11 23:02:21 +00:00
|
|
|
|
2017-06-22 19:03:37 +00:00
|
|
|
if (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_FREQ_AUX_SET_CAP)
|
2020-12-04 22:35:59 +00:00
|
|
|
if (intel_dp_aux_vesa_set_pwm_freq(connector))
|
2017-06-22 19:03:37 +00:00
|
|
|
new_dpcd_buf |= DP_EDP_BACKLIGHT_FREQ_AUX_SET_ENABLE;
|
|
|
|
|
|
|
|
if (new_dpcd_buf != dpcd_buf) {
|
|
|
|
if (drm_dp_dpcd_writeb(&intel_dp->aux,
|
|
|
|
DP_EDP_BACKLIGHT_MODE_SET_REGISTER, new_dpcd_buf) < 0) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"Failed to write aux backlight mode\n");
|
2017-06-22 19:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-04 22:35:59 +00:00
|
|
|
intel_dp_aux_vesa_set_backlight(conn_state, level);
|
|
|
|
set_vesa_backlight_enable(intel_dp, true);
|
2016-04-05 14:10:52 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 22:35:59 +00:00
|
|
|
static void intel_dp_aux_vesa_disable_backlight(const struct drm_connector_state *old_conn_state,
|
|
|
|
u32 level)
|
2016-04-05 14:10:52 +00:00
|
|
|
{
|
2020-12-04 22:35:59 +00:00
|
|
|
set_vesa_backlight_enable(enc_to_intel_dp(to_intel_encoder(old_conn_state->best_encoder)),
|
|
|
|
false);
|
2016-04-05 14:10:52 +00:00
|
|
|
}
|
|
|
|
|
2020-12-04 22:35:59 +00:00
|
|
|
static u32 intel_dp_aux_vesa_calc_max_backlight(struct intel_connector *connector)
|
2020-01-16 21:16:08 +00:00
|
|
|
{
|
|
|
|
struct drm_i915_private *i915 = to_i915(connector->base.dev);
|
2019-12-04 18:05:47 +00:00
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
2020-01-16 21:16:08 +00:00
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
u32 max_backlight = 0;
|
|
|
|
int freq, fxp, fxp_min, fxp_max, fxp_actual, f = 1;
|
|
|
|
u8 pn, pn_min, pn_max;
|
|
|
|
|
|
|
|
if (drm_dp_dpcd_readb(&intel_dp->aux, DP_EDP_PWMGEN_BIT_COUNT, &pn) == 1) {
|
|
|
|
pn &= DP_EDP_PWMGEN_BIT_COUNT_MASK;
|
|
|
|
max_backlight = (1 << pn) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find desired value of (F x P)
|
|
|
|
* Note that, if F x P is out of supported range, the maximum value or
|
|
|
|
* minimum value will applied automatically. So no need to check that.
|
|
|
|
*/
|
|
|
|
freq = i915->vbt.backlight.pwm_freq_hz;
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm, "VBT defined backlight frequency %u Hz\n",
|
|
|
|
freq);
|
2020-01-16 21:16:08 +00:00
|
|
|
if (!freq) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"Use panel default backlight frequency\n");
|
2020-01-16 21:16:08 +00:00
|
|
|
return max_backlight;
|
|
|
|
}
|
|
|
|
|
|
|
|
fxp = DIV_ROUND_CLOSEST(KHz(DP_EDP_BACKLIGHT_FREQ_BASE_KHZ), freq);
|
|
|
|
|
|
|
|
/* Use highest possible value of Pn for more granularity of brightness
|
|
|
|
* adjustment while satifying the conditions below.
|
|
|
|
* - Pn is in the range of Pn_min and Pn_max
|
|
|
|
* - F is in the range of 1 and 255
|
|
|
|
* - FxP is within 25% of desired value.
|
|
|
|
* Note: 25% is arbitrary value and may need some tweak.
|
|
|
|
*/
|
|
|
|
if (drm_dp_dpcd_readb(&intel_dp->aux,
|
|
|
|
DP_EDP_PWMGEN_BIT_COUNT_CAP_MIN, &pn_min) != 1) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"Failed to read pwmgen bit count cap min\n");
|
2020-01-16 21:16:08 +00:00
|
|
|
return max_backlight;
|
|
|
|
}
|
|
|
|
if (drm_dp_dpcd_readb(&intel_dp->aux,
|
|
|
|
DP_EDP_PWMGEN_BIT_COUNT_CAP_MAX, &pn_max) != 1) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"Failed to read pwmgen bit count cap max\n");
|
2020-01-16 21:16:08 +00:00
|
|
|
return max_backlight;
|
|
|
|
}
|
|
|
|
pn_min &= DP_EDP_PWMGEN_BIT_COUNT_MASK;
|
|
|
|
pn_max &= DP_EDP_PWMGEN_BIT_COUNT_MASK;
|
|
|
|
|
|
|
|
fxp_min = DIV_ROUND_CLOSEST(fxp * 3, 4);
|
|
|
|
fxp_max = DIV_ROUND_CLOSEST(fxp * 5, 4);
|
|
|
|
if (fxp_min < (1 << pn_min) || (255 << pn_max) < fxp_max) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"VBT defined backlight frequency out of range\n");
|
2020-01-16 21:16:08 +00:00
|
|
|
return max_backlight;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pn = pn_max; pn >= pn_min; pn--) {
|
|
|
|
f = clamp(DIV_ROUND_CLOSEST(fxp, 1 << pn), 1, 255);
|
|
|
|
fxp_actual = f << pn;
|
|
|
|
if (fxp_min <= fxp_actual && fxp_actual <= fxp_max)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm, "Using eDP pwmgen bit count of %d\n", pn);
|
2020-01-16 21:16:08 +00:00
|
|
|
if (drm_dp_dpcd_writeb(&intel_dp->aux,
|
|
|
|
DP_EDP_PWMGEN_BIT_COUNT, pn) < 0) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm,
|
|
|
|
"Failed to write aux pwmgen bit count\n");
|
2020-01-16 21:16:08 +00:00
|
|
|
return max_backlight;
|
|
|
|
}
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
panel->backlight.edp.vesa.pwmgen_bit_count = pn;
|
2020-01-16 21:16:08 +00:00
|
|
|
|
|
|
|
max_backlight = (1 << pn) - 1;
|
|
|
|
|
|
|
|
return max_backlight;
|
|
|
|
}
|
|
|
|
|
2020-12-04 22:35:59 +00:00
|
|
|
static int intel_dp_aux_vesa_setup_backlight(struct intel_connector *connector,
|
|
|
|
enum pipe pipe)
|
2016-04-05 14:10:52 +00:00
|
|
|
{
|
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
|
2020-12-04 22:35:59 +00:00
|
|
|
panel->backlight.max = intel_dp_aux_vesa_calc_max_backlight(connector);
|
2020-01-16 21:16:08 +00:00
|
|
|
if (!panel->backlight.max)
|
|
|
|
return -ENODEV;
|
2016-04-05 14:10:52 +00:00
|
|
|
|
|
|
|
panel->backlight.min = 0;
|
2021-01-14 22:17:05 +00:00
|
|
|
panel->backlight.level = intel_dp_aux_vesa_get_backlight(connector, pipe);
|
2020-12-04 22:35:59 +00:00
|
|
|
panel->backlight.enabled = intel_dp_aux_vesa_backlight_dpcd_mode(connector) &&
|
2020-09-18 00:28:42 +00:00
|
|
|
panel->backlight.level != 0;
|
2016-04-05 14:10:52 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
2020-12-04 22:35:59 +00:00
|
|
|
intel_dp_aux_supports_vesa_backlight(struct intel_connector *connector)
|
2016-04-05 14:10:52 +00:00
|
|
|
{
|
2019-12-04 18:05:47 +00:00
|
|
|
struct intel_dp *intel_dp = intel_attached_dp(connector);
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
|
2016-04-05 14:10:52 +00:00
|
|
|
|
2017-06-12 10:21:15 +00:00
|
|
|
/* Check the eDP Display control capabilities registers to determine if
|
2021-01-21 18:36:43 +00:00
|
|
|
* the panel can support backlight control over the aux channel.
|
|
|
|
*
|
|
|
|
* TODO: We currently only support AUX only backlight configurations, not backlights which
|
|
|
|
* require a mix of PWM and AUX controls to work. In the mean time, these machines typically
|
|
|
|
* work just fine using normal PWM controls anyway.
|
2016-04-05 14:10:52 +00:00
|
|
|
*/
|
2017-07-20 09:25:17 +00:00
|
|
|
if (intel_dp->edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP &&
|
2021-01-21 18:36:43 +00:00
|
|
|
(intel_dp->edp_dpcd[1] & DP_EDP_BACKLIGHT_AUX_ENABLE_CAP) &&
|
2020-10-09 08:57:49 +00:00
|
|
|
(intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP)) {
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
drm_dbg_kms(&i915->drm, "AUX Backlight Control Supported!\n");
|
2016-04-05 14:10:52 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
static const struct intel_panel_bl_funcs intel_dp_hdr_bl_funcs = {
|
|
|
|
.setup = intel_dp_aux_hdr_setup_backlight,
|
|
|
|
.enable = intel_dp_aux_hdr_enable_backlight,
|
|
|
|
.disable = intel_dp_aux_hdr_disable_backlight,
|
|
|
|
.set = intel_dp_aux_hdr_set_backlight,
|
|
|
|
.get = intel_dp_aux_hdr_get_backlight,
|
|
|
|
};
|
|
|
|
|
2020-12-04 22:35:59 +00:00
|
|
|
static const struct intel_panel_bl_funcs intel_dp_vesa_bl_funcs = {
|
|
|
|
.setup = intel_dp_aux_vesa_setup_backlight,
|
|
|
|
.enable = intel_dp_aux_vesa_enable_backlight,
|
|
|
|
.disable = intel_dp_aux_vesa_disable_backlight,
|
|
|
|
.set = intel_dp_aux_vesa_set_backlight,
|
|
|
|
.get = intel_dp_aux_vesa_get_backlight,
|
2020-11-30 21:09:45 +00:00
|
|
|
};
|
|
|
|
|
2020-09-16 16:31:37 +00:00
|
|
|
enum intel_dp_aux_backlight_modparam {
|
|
|
|
INTEL_DP_AUX_BACKLIGHT_AUTO = -1,
|
|
|
|
INTEL_DP_AUX_BACKLIGHT_OFF = 0,
|
|
|
|
INTEL_DP_AUX_BACKLIGHT_ON = 1,
|
|
|
|
INTEL_DP_AUX_BACKLIGHT_FORCE_VESA = 2,
|
|
|
|
INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL = 3,
|
|
|
|
};
|
|
|
|
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
int intel_dp_aux_init_backlight_funcs(struct intel_connector *connector)
|
2016-04-05 14:10:52 +00:00
|
|
|
{
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
struct drm_device *dev = connector->base.dev;
|
|
|
|
struct intel_panel *panel = &connector->panel;
|
|
|
|
struct intel_dp *intel_dp = enc_to_intel_dp(connector->encoder);
|
drm/i915/dp_aux_backlight: use struct drm_device based logging
Convert all the DRM_* logging macros to the struct drm_device based
macros to provide device specific logging.
No functional changes.
Generated using the following semantic patch, originally written by
Wambui Karuga <wambui.karugax@gmail.com>, with manual fixups on top:
@@
identifier fn, T;
@@
fn(...,struct drm_i915_private *T,...) {
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
@@
identifier fn, T;
@@
fn(...) {
...
struct drm_i915_private *T = ...;
<+...
(
-DRM_INFO(
+drm_info(&T->drm,
...)
|
-DRM_NOTE(
+drm_notice(&T->drm,
...)
|
-DRM_ERROR(
+drm_err(&T->drm,
...)
|
-DRM_WARN(
+drm_warn(&T->drm,
...)
|
-DRM_DEBUG_DRIVER(
+drm_dbg(&T->drm,
...)
|
-DRM_DEBUG_KMS(
+drm_dbg_kms(&T->drm,
...)
|
-DRM_DEBUG_ATOMIC(
+drm_dbg_atomic(&T->drm,
...)
)
...+>
}
Cc: Wambui Karuga <wambui.karugax@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/733d3032e61cb4892a516d5be5da5ec73bdb9fa1.1584714939.git.jani.nikula@intel.com
2020-03-20 14:36:28 +00:00
|
|
|
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
|
2020-09-16 16:31:37 +00:00
|
|
|
bool try_intel_interface = false, try_vesa_interface = false;
|
2016-04-05 14:10:52 +00:00
|
|
|
|
2020-09-16 16:31:37 +00:00
|
|
|
/* Check the VBT and user's module parameters to figure out which
|
|
|
|
* interfaces to probe
|
|
|
|
*/
|
|
|
|
switch (i915->params.enable_dpcd_backlight) {
|
|
|
|
case INTEL_DP_AUX_BACKLIGHT_OFF:
|
2016-04-05 14:10:52 +00:00
|
|
|
return -ENODEV;
|
2020-09-16 16:31:37 +00:00
|
|
|
case INTEL_DP_AUX_BACKLIGHT_AUTO:
|
|
|
|
switch (i915->vbt.backlight.type) {
|
|
|
|
case INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE:
|
|
|
|
try_vesa_interface = true;
|
|
|
|
break;
|
|
|
|
case INTEL_BACKLIGHT_DISPLAY_DDI:
|
|
|
|
try_intel_interface = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INTEL_DP_AUX_BACKLIGHT_ON:
|
|
|
|
if (i915->vbt.backlight.type != INTEL_BACKLIGHT_VESA_EDP_AUX_INTERFACE)
|
|
|
|
try_intel_interface = true;
|
|
|
|
|
|
|
|
try_vesa_interface = true;
|
|
|
|
break;
|
|
|
|
case INTEL_DP_AUX_BACKLIGHT_FORCE_VESA:
|
|
|
|
try_vesa_interface = true;
|
|
|
|
break;
|
|
|
|
case INTEL_DP_AUX_BACKLIGHT_FORCE_INTEL:
|
|
|
|
try_intel_interface = true;
|
|
|
|
break;
|
|
|
|
}
|
2016-04-05 14:10:52 +00:00
|
|
|
|
2020-03-03 21:53:18 +00:00
|
|
|
/*
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
* A lot of eDP panels in the wild will report supporting both the
|
|
|
|
* Intel proprietary backlight control interface, and the VESA
|
|
|
|
* backlight control interface. Many of these panels are liars though,
|
|
|
|
* and will only work with the Intel interface. So, always probe for
|
|
|
|
* that first.
|
2020-03-03 21:53:18 +00:00
|
|
|
*/
|
2020-09-16 16:31:37 +00:00
|
|
|
if (try_intel_interface && intel_dp_aux_supports_hdr_backlight(connector)) {
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
drm_dbg_kms(dev, "Using Intel proprietary eDP backlight controls\n");
|
|
|
|
panel->backlight.funcs = &intel_dp_hdr_bl_funcs;
|
|
|
|
return 0;
|
2020-03-03 21:53:18 +00:00
|
|
|
}
|
2016-04-05 14:10:52 +00:00
|
|
|
|
2020-09-16 16:31:37 +00:00
|
|
|
if (try_vesa_interface && intel_dp_aux_supports_vesa_backlight(connector)) {
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
drm_dbg_kms(dev, "Using VESA eDP backlight controls\n");
|
|
|
|
panel->backlight.funcs = &intel_dp_vesa_bl_funcs;
|
|
|
|
return 0;
|
|
|
|
}
|
2016-04-05 14:10:52 +00:00
|
|
|
|
drm/i915/dp: Enable Intel's HDR backlight interface (only SDR for now)
So-recently a bunch of laptops on the market have started using DPCD
backlight controls instead of the traditional DDI backlight controls.
Originally we thought we had this handled by adding VESA backlight
control support to i915, but the story ended up being a lot more
complicated then that.
Simply put-there's two main backlight interfaces Intel can see in the
wild. Intel's proprietary HDR backlight interface, and the standard VESA
backlight interface. Note that many panels have been observed to report
support for both backlight interfaces, but testing has shown far more
panels work with the Intel HDR backlight interface at the moment.
Additionally, the VBT appears to be capable of reporting support for the
VESA backlight interface but not the Intel HDR interface which needs to
be probed by setting the right magic OUI.
On top of that however, there's also actually two different variants of
the Intel HDR backlight interface. The first uses the AUX channel for
controlling the brightness of the screen in both SDR and HDR mode, and
the second only uses the AUX channel for setting the brightness level in
HDR mode - relying on PWM for setting the brightness level in SDR mode.
For the time being we've been using EDIDs to maintain a list of quirks
for panels that safely do support the VESA backlight interface. Adding
support for Intel's HDR backlight interface in addition however, should
finally allow us to auto-detect eDP backlight controls properly so long
as we probe like so:
* If the panel's VBT reports VESA backlight support, assume it really
does support it
* If the panel's VBT reports DDI backlight controls:
* First probe for Intel's HDR backlight interface
* If that fails, probe for VESA's backlight interface
* If that fails, assume no DPCD backlight control
* If the panel's VBT reports any other backlight type: just assume it
doesn't have DPCD backlight controls
Changes since v4:
* Fix checkpatch issues
Changes since v3:
* Stop using drm_device and use drm_i915_private instead
* Don't forget to return from intel_dp_aux_hdr_get_backlight() if we fail
to read the current backlight mode from the DPCD
* s/uint8_t/u8/
* Remove unneeded parenthesis in intel_dp_aux_hdr_enable_backlight()
* Use drm_dbg_kms() in intel_dp_aux_init_backlight_funcs()
Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Cc: thaytan@noraisin.net
Cc: Vasily Khoruzhick <anarsoul@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210114221709.2261452-4-lyude@redhat.com
2020-06-29 19:01:49 +00:00
|
|
|
return -ENODEV;
|
2016-04-05 14:10:52 +00:00
|
|
|
}
|