Release 4.11 drivers/gpu/drm/i915/intel_panel.c
/*
* Copyright © 2006-2010 Intel Corporation
* Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
*
* 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.
*
* Authors:
* Eric Anholt <eric@anholt.net>
* Dave Airlie <airlied@linux.ie>
* Jesse Barnes <jesse.barnes@intel.com>
* Chris Wilson <chris@chris-wilson.co.uk>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/moduleparam.h>
#include <linux/pwm.h>
#include "intel_drv.h"
#define CRC_PMIC_PWM_PERIOD_NS 21333
void
intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
struct drm_display_mode *adjusted_mode)
{
drm_mode_copy(adjusted_mode, fixed_mode);
drm_mode_set_crtcinfo(adjusted_mode, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Chris Wilson | 18 | 60.00% | 1 | 33.33% |
Imre Deak | 7 | 23.33% | 1 | 33.33% |
Ville Syrjälä | 5 | 16.67% | 1 | 33.33% |
Total | 30 | 100.00% | 3 | 100.00% |
/**
* intel_find_panel_downclock - find the reduced downclock for LVDS in EDID
* @dev_priv: i915 device instance
* @fixed_mode : panel native mode
* @connector: LVDS/eDP connector
*
* Return downclock_avail
* Find the reduced downclock for LVDS/eDP in EDID.
*/
struct drm_display_mode *
intel_find_panel_downclock(struct drm_i915_private *dev_priv,
struct drm_display_mode *fixed_mode,
struct drm_connector *connector)
{
struct drm_display_mode *scan, *tmp_mode;
int temp_downclock;
temp_downclock = fixed_mode->clock;
tmp_mode = NULL;
list_for_each_entry(scan, &connector->probed_modes, head) {
/*
* If one mode has the same resolution with the fixed_panel
* mode while they have the different refresh rate, it means
* that the reduced downclock is found. In such
* case we can set the different FPx0/1 to dynamically select
* between low and high frequency.
*/
if (scan->hdisplay == fixed_mode->hdisplay &&
scan->hsync_start == fixed_mode->hsync_start &&
scan->hsync_end == fixed_mode->hsync_end &&
scan->htotal == fixed_mode->htotal &&
scan->vdisplay == fixed_mode->vdisplay &&
scan->vsync_start == fixed_mode->vsync_start &&
scan->vsync_end == fixed_mode->vsync_end &&
scan->vtotal == fixed_mode->vtotal) {
if (scan->clock < temp_downclock) {
/*
* The downclock is already found. But we
* expect to find the lower downclock.
*/
temp_downclock = scan->clock;
tmp_mode = scan;
}
}
}
if (temp_downclock < fixed_mode->clock)
return drm_mode_duplicate(&dev_priv->drm, tmp_mode);
else
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 160 | 96.39% | 1 | 50.00% |
Mika Kahola | 6 | 3.61% | 1 | 50.00% |
Total | 166 | 100.00% | 2 | 100.00% |
/* adjusted_mode has been preset to be the panel's fixed mode */
void
intel_pch_panel_fitting(struct intel_crtc *intel_crtc,
struct intel_crtc_state *pipe_config,
int fitting_mode)
{
const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
int x = 0, y = 0, width = 0, height = 0;
/* Native modes don't need fitting */
if (adjusted_mode->crtc_hdisplay == pipe_config->pipe_src_w &&
adjusted_mode->crtc_vdisplay == pipe_config->pipe_src_h)
goto done;
switch (fitting_mode) {
case DRM_MODE_SCALE_CENTER:
width = pipe_config->pipe_src_w;
height = pipe_config->pipe_src_h;
x = (adjusted_mode->crtc_hdisplay - width + 1)/2;
y = (adjusted_mode->crtc_vdisplay - height + 1)/2;
break;
case DRM_MODE_SCALE_ASPECT:
/* Scale but preserve the aspect ratio */
{
u32 scaled_width = adjusted_mode->crtc_hdisplay
* pipe_config->pipe_src_h;
u32 scaled_height = pipe_config->pipe_src_w
* adjusted_mode->crtc_vdisplay;
if (scaled_width > scaled_height) { /* pillar */
width = scaled_height / pipe_config->pipe_src_h;
if (width & 1)
width++;
x = (adjusted_mode->crtc_hdisplay - width + 1) / 2;
y = 0;
height = adjusted_mode->crtc_vdisplay;
} else if (scaled_width < scaled_height) { /* letter */
height = scaled_width / pipe_config->pipe_src_w;
if (height & 1)
height++;
y = (adjusted_mode->crtc_vdisplay - height + 1) / 2;
x = 0;
width = adjusted_mode->crtc_hdisplay;
} else {
x = y = 0;
width = adjusted_mode->crtc_hdisplay;
height = adjusted_mode->crtc_vdisplay;
}
}
break;
case DRM_MODE_SCALE_FULLSCREEN:
x = y = 0;
width = adjusted_mode->crtc_hdisplay;
height = adjusted_mode->crtc_vdisplay;
break;
default:
WARN(1, "bad panel fit mode: %d\n", fitting_mode);
return;
}
done:
pipe_config->pch_pfit.pos = (x << 16) | y;
pipe_config->pch_pfit.size = (width << 16) | height;
pipe_config->pch_pfit.enabled = pipe_config->pch_pfit.size != 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Chris Wilson | 251 | 72.13% | 2 | 20.00% |
Ville Syrjälä | 45 | 12.93% | 3 | 30.00% |
Jesse Barnes | 31 | 8.91% | 2 | 20.00% |
Adam Jackson | 18 | 5.17% | 1 | 10.00% |
Ander Conselvan de Oliveira | 3 | 0.86% | 2 | 20.00% |
Total | 348 | 100.00% | 10 | 100.00% |
static void
centre_horizontally(struct drm_display_mode *adjusted_mode,
int width)
{
u32 border, sync_pos, blank_width, sync_width;
/* keep the hsync and hblank widths constant */
sync_width = adjusted_mode->crtc_hsync_end - adjusted_mode->crtc_hsync_start;
blank_width = adjusted_mode->crtc_hblank_end - adjusted_mode->crtc_hblank_start;
sync_pos = (blank_width - sync_width + 1) / 2;
border = (adjusted_mode->crtc_hdisplay - width + 1) / 2;
border += border & 1; /* make the border even */
adjusted_mode->crtc_hdisplay = width;
adjusted_mode->crtc_hblank_start = width + border;
adjusted_mode->crtc_hblank_end = adjusted_mode->crtc_hblank_start + blank_width;
adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hblank_start + sync_pos;
adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + sync_width;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jesse Barnes | 106 | 87.60% | 1 | 33.33% |
Ville Syrjälä | 15 | 12.40% | 2 | 66.67% |
Total | 121 | 100.00% | 3 | 100.00% |
static void
centre_vertically(struct drm_display_mode *adjusted_mode,
int height)
{
u32 border, sync_pos, blank_width, sync_width;
/* keep the vsync and vblank widths constant */
sync_width = adjusted_mode->crtc_vsync_end - adjusted_mode->crtc_vsync_start;
blank_width = adjusted_mode->crtc_vblank_end - adjusted_mode->crtc_vblank_start;
sync_pos = (blank_width - sync_width + 1) / 2;
border = (adjusted_mode->crtc_vdisplay - height + 1) / 2;
adjusted_mode->crtc_vdisplay = height;
adjusted_mode->crtc_vblank_start = height + border;
adjusted_mode->crtc_vblank_end = adjusted_mode->crtc_vblank_start + blank_width;
adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vblank_start + sync_pos;
adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + sync_width;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jesse Barnes | 99 | 86.84% | 1 | 33.33% |
Ville Syrjälä | 15 | 13.16% | 2 | 66.67% |
Total | 114 | 100.00% | 3 | 100.00% |
static inline u32 panel_fitter_scaling(u32 source, u32 target)
{
/*
* Floating point operation is not supported. So the FACTOR
* is defined, which can avoid the floating point computation
* when calculating the panel ratio.
*/
#define ACCURACY 12
#define FACTOR (1 << ACCURACY)
u32 ratio = source * FACTOR / target;
return (FACTOR * ratio + FACTOR/2) / FACTOR;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jesse Barnes | 44 | 100.00% | 1 | 100.00% |
Total | 44 | 100.00% | 1 | 100.00% |
static void i965_scale_aspect(struct intel_crtc_state *pipe_config,
u32 *pfit_control)
{
const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
u32 scaled_width = adjusted_mode->crtc_hdisplay *
pipe_config->pipe_src_h;
u32 scaled_height = pipe_config->pipe_src_w *
adjusted_mode->crtc_vdisplay;
/* 965+ is easy, it does everything in hw */
if (scaled_width > scaled_height)
*pfit_control |= PFIT_ENABLE |
PFIT_SCALING_PILLAR;
else if (scaled_width < scaled_height)
*pfit_control |= PFIT_ENABLE |
PFIT_SCALING_LETTER;
else if (adjusted_mode->crtc_hdisplay != pipe_config->pipe_src_w)
*pfit_control |= PFIT_ENABLE | PFIT_SCALING_AUTO;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jesse Barnes | 73 | 76.04% | 1 | 14.29% |
Daniel Vetter | 10 | 10.42% | 1 | 14.29% |
Ville Syrjälä | 10 | 10.42% | 3 | 42.86% |
Ander Conselvan de Oliveira | 3 | 3.12% | 2 | 28.57% |
Total | 96 | 100.00% | 7 | 100.00% |
static void i9xx_scale_aspect(struct intel_crtc_state *pipe_config,
u32 *pfit_control, u32 *pfit_pgm_ratios,
u32 *border)
{
struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
u32 scaled_width = adjusted_mode->crtc_hdisplay *
pipe_config->pipe_src_h;
u32 scaled_height = pipe_config->pipe_src_w *
adjusted_mode->crtc_vdisplay;
u32 bits;
/*
* For earlier chips we have to calculate the scaling
* ratio by hand and program it into the
* PFIT_PGM_RATIO register
*/
if (scaled_width > scaled_height) { /* pillar */
centre_horizontally(adjusted_mode,
scaled_height /
pipe_config->pipe_src_h);
*border = LVDS_BORDER_ENABLE;
if (pipe_config->pipe_src_h != adjusted_mode->crtc_vdisplay) {
bits = panel_fitter_scaling(pipe_config->pipe_src_h,
adjusted_mode->crtc_vdisplay);
*pfit_pgm_ratios |= (bits << PFIT_HORIZ_SCALE_SHIFT |
bits << PFIT_VERT_SCALE_SHIFT);
*pfit_control |= (PFIT_ENABLE |
VERT_INTERP_BILINEAR |
HORIZ_INTERP_BILINEAR);
}
} else if (scaled_width < scaled_height) { /* letter */
centre_vertically(adjusted_mode,
scaled_width /
pipe_config->pipe_src_w);
*border = LVDS_BORDER_ENABLE;
if (pipe_config->pipe_src_w != adjusted_mode->crtc_hdisplay) {
bits = panel_fitter_scaling(pipe_config->pipe_src_w,
adjusted_mode->crtc_hdisplay);
*pfit_pgm_ratios |= (bits << PFIT_HORIZ_SCALE_SHIFT |
bits << PFIT_VERT_SCALE_SHIFT);
*pfit_control |= (PFIT_ENABLE |
VERT_INTERP_BILINEAR |
HORIZ_INTERP_BILINEAR);
}
} else {
/* Aspects match, Let hw scale both directions */
*pfit_control |= (PFIT_ENABLE |
VERT_AUTO_SCALE | HORIZ_AUTO_SCALE |
VERT_INTERP_BILINEAR |
HORIZ_INTERP_BILINEAR);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jesse Barnes | 159 | 69.43% | 1 | 16.67% |
Daniel Vetter | 45 | 19.65% | 1 | 16.67% |
Ville Syrjälä | 22 | 9.61% | 2 | 33.33% |
Ander Conselvan de Oliveira | 3 | 1.31% | 2 | 33.33% |
Total | 229 | 100.00% | 6 | 100.00% |
void intel_gmch_panel_fitting(struct intel_crtc *intel_crtc,
struct intel_crtc_state *pipe_config,
int fitting_mode)
{
struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev);
u32 pfit_control = 0, pfit_pgm_ratios = 0, border = 0;
struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
/* Native modes don't need fitting */
if (adjusted_mode->crtc_hdisplay == pipe_config->pipe_src_w &&
adjusted_mode->crtc_vdisplay == pipe_config->pipe_src_h)
goto out;
switch (fitting_mode) {
case DRM_MODE_SCALE_CENTER:
/*
* For centered modes, we have to calculate border widths &
* heights and modify the values programmed into the CRTC.
*/
centre_horizontally(adjusted_mode, pipe_config->pipe_src_w);
centre_vertically(adjusted_mode, pipe_config->pipe_src_h);
border = LVDS_BORDER_ENABLE;
break;
case DRM_MODE_SCALE_ASPECT:
/* Scale but preserve the aspect ratio */
if (INTEL_GEN(dev_priv) >= 4)
i965_scale_aspect(pipe_config, &pfit_control);
else
i9xx_scale_aspect(pipe_config, &pfit_control,
&pfit_pgm_ratios, &border);
break;
case DRM_MODE_SCALE_FULLSCREEN:
/*
* Full scaling, even if it changes the aspect ratio.
* Fortunately this is all done for us in hw.
*/
if (pipe_config->pipe_src_h != adjusted_mode->crtc_vdisplay ||
pipe_config->pipe_src_w != adjusted_mode->crtc_hdisplay) {
pfit_control |= PFIT_ENABLE;
if (INTEL_GEN(dev_priv) >= 4)
pfit_control |= PFIT_SCALING_AUTO;
else
pfit_control |= (VERT_AUTO_SCALE |
VERT_INTERP_BILINEAR |
HORIZ_AUTO_SCALE |
HORIZ_INTERP_BILINEAR);
}
break;
default:
WARN(1, "bad panel fit mode: %d\n", fitting_mode);
return;
}
/* 965+ wants fuzzy fitting */
/* FIXME: handle multiple panels by failing gracefully */
if (INTEL_GEN(dev_priv) >= 4)
pfit_control |= ((intel_crtc->pipe << PFIT_PIPE_SHIFT) |
PFIT_FILTER_FUZZY);
out:
if ((pfit_control & PFIT_ENABLE) == 0) {
pfit_control = 0;
pfit_pgm_ratios = 0;
}
/* Make sure pre-965 set dither correctly for 18bpp panels. */
if (INTEL_GEN(dev_priv) < 4 && pipe_config->pipe_bpp == 18)
pfit_control |= PANEL_8TO6_DITHER_ENABLE;
pipe_config->gmch_pfit.control = pfit_control;
pipe_config->gmch_pfit.pgm_ratios = pfit_pgm_ratios;
pipe_config->gmch_pfit.lvds_border_bits = border;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Vetter | 175 | 57.19% | 4 | 30.77% |
Jesse Barnes | 105 | 34.31% | 3 | 23.08% |
Tvrtko A. Ursulin | 13 | 4.25% | 1 | 7.69% |
Ville Syrjälä | 10 | 3.27% | 3 | 23.08% |
Ander Conselvan de Oliveira | 3 | 0.98% | 2 | 15.38% |
Total | 306 | 100.00% | 13 | 100.00% |
enum drm_connector_status
intel_panel_detect(struct drm_i915_private *dev_priv)
{
/* Assume that the BIOS does not lie through the OpRegion... */
if (!i915.panel_ignore_lid && dev_priv->opregion.lid_state) {
return *dev_priv->opregion.lid_state & 0x1 ?
connector_status_connected :
connector_status_disconnected;
}
switch (i915.panel_ignore_lid) {
case -2:
return connector_status_connected;
case -1:
return connector_status_disconnected;
default:
return connector_status_unknown;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 64 | 95.52% | 1 | 33.33% |
Mika Kahola | 2 | 2.99% | 1 | 33.33% |
Dan J Williams | 1 | 1.49% | 1 | 33.33% |
Total | 67 | 100.00% | 3 | 100.00% |
/**
* scale - scale values from one range to another
*
* @source_val: value in range [@source_min..@source_max]
*
* Return @source_val in range [@source_min..@source_max] scaled to range
* [@target_min..@target_max].
*/
static uint32_t scale(uint32_t source_val,
uint32_t source_min, uint32_t source_max,
uint32_t target_min, uint32_t target_max)
{
uint64_t target_val;
WARN_ON(source_min > source_max);
WARN_ON(target_min > target_max);
/* defensive */
source_val = clamp(source_val, source_min, source_max);
/* avoid overflows */
target_val = DIV_ROUND_CLOSEST_ULL((uint64_t)(source_val - source_min) *
(target_max - target_min), source_max - source_min);
target_val += target_min;
return target_val;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 80 | 97.56% | 1 | 50.00% |
U. Artie Eoff | 2 | 2.44% | 1 | 50.00% |
Total | 82 | 100.00% | 2 | 100.00% |
/* Scale user_level in range [0..user_max] to [hw_min..hw_max]. */
static inline u32 scale_user_to_hw(struct intel_connector *connector,
u32 user_level, u32 user_max)
{
struct intel_panel *panel = &connector->panel;
return scale(user_level, 0, user_max,
panel->backlight.min, panel->backlight.max);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 50 | 100.00% | 1 | 100.00% |
Total | 50 | 100.00% | 1 | 100.00% |
/* Scale user_level in range [0..user_max] to [0..hw_max], clamping the result
* to [hw_min..hw_max]. */
static inline u32 clamp_user_to_hw(struct intel_connector *connector,
u32 user_level, u32 user_max)
{
struct intel_panel *panel = &connector->panel;
u32 hw_level;
hw_level = scale(user_level, 0, user_max, 0, panel->backlight.max);
hw_level = clamp(hw_level, panel->backlight.min, panel->backlight.max);
return hw_level;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 72 | 100.00% | 1 | 100.00% |
Total | 72 | 100.00% | 1 | 100.00% |
/* Scale hw_level in range [hw_min..hw_max] to [0..user_max]. */
static inline u32 scale_hw_to_user(struct intel_connector *connector,
u32 hw_level, u32 user_max)
{
struct intel_panel *panel = &connector->panel;
return scale(hw_level, panel->backlight.min, panel->backlight.max,
0, user_max);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 50 | 100.00% | 1 | 100.00% |
Total | 50 | 100.00% | 1 | 100.00% |
static u32 intel_panel_compute_brightness(struct intel_connector *connector,
u32 val)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
WARN_ON(panel->backlight.max == 0);
if (i915.invert_brightness < 0)
return val;
if (i915.invert_brightness > 0 ||
dev_priv->quirks & QUIRK_INVERT_BRIGHTNESS) {
return panel->backlight.max - val;
}
return val;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 49 | 55.68% | 5 | 62.50% |
Carsten Emde | 38 | 43.18% | 2 | 25.00% |
Jesse Barnes | 1 | 1.14% | 1 | 12.50% |
Total | 88 | 100.00% | 8 | 100.00% |
static u32 lpt_get_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
return I915_READ(BLC_PWM_PCH_CTL2) & BACKLIGHT_DUTY_CYCLE_MASK;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Vetter | 20 | 60.61% | 1 | 25.00% |
Takashi Iwai | 7 | 21.21% | 1 | 25.00% |
Jani Nikula | 6 | 18.18% | 2 | 50.00% |
Total | 33 | 100.00% | 4 | 100.00% |
static u32 pch_get_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
return I915_READ(BLC_PWM_CPU_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 19 | 57.58% | 2 | 50.00% |
Chris Wilson | 13 | 39.39% | 1 | 25.00% |
Stéphane Marchesin | 1 | 3.03% | 1 | 25.00% |
Total | 33 | 100.00% | 4 | 100.00% |
static u32 i9xx_get_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 val;
val = I915_READ(BLC_PWM_CTL) & BACKLIGHT_DUTY_CYCLE_MASK;
if (INTEL_INFO(dev_priv)->gen < 4)
val >>= 1;
if (panel->backlight.combination_mode) {
u8 lbpc;
pci_read_config_byte(dev_priv->drm.pdev, LBPC, &lbpc);
val *= lbpc;
}
return val;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 48 | 50.00% | 3 | 33.33% |
Takashi Iwai | 21 | 21.88% | 1 | 11.11% |
Chris Wilson | 20 | 20.83% | 2 | 22.22% |
Keith Packard | 5 | 5.21% | 1 | 11.11% |
Joonas Lahtinen | 1 | 1.04% | 1 | 11.11% |
Carsten Emde | 1 | 1.04% | 1 | 11.11% |
Total | 96 | 100.00% | 9 | 100.00% |
static u32 _vlv_get_backlight(struct drm_i915_private *dev_priv, enum pipe pipe)
{
if (WARN_ON(pipe != PIPE_A && pipe != PIPE_B))
return 0;
return I915_READ(VLV_BLC_PWM_CTL(pipe)) & BACKLIGHT_DUTY_CYCLE_MASK;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 26 | 61.90% | 2 | 66.67% |
Ville Syrjälä | 16 | 38.10% | 1 | 33.33% |
Total | 42 | 100.00% | 3 | 100.00% |
static u32 vlv_get_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
enum pipe pipe = intel_get_pipe_from_connector(connector);
return _vlv_get_backlight(dev_priv, pipe);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 39 | 92.86% | 2 | 50.00% |
Carsten Emde | 2 | 4.76% | 1 | 25.00% |
Jesse Barnes | 1 | 2.38% | 1 | 25.00% |
Total | 42 | 100.00% | 4 | 100.00% |
static u32 bxt_get_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
return I915_READ(BXT_BLC_PWM_DUTY(panel->backlight.controller));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vandana Kannan | 26 | 54.17% | 1 | 33.33% |
A.Sunil Kamath | 17 | 35.42% | 1 | 33.33% |
Jani Nikula | 5 | 10.42% | 1 | 33.33% |
Total | 48 | 100.00% | 3 | 100.00% |
static u32 pwm_get_backlight(struct intel_connector *connector)
{
struct intel_panel *panel = &connector->panel;
int duty_ns;
duty_ns = pwm_get_duty_cycle(panel->backlight.pwm);
return DIV_ROUND_UP(duty_ns * 100, CRC_PMIC_PWM_PERIOD_NS);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Shobhit Kumar | 45 | 100.00% | 1 | 100.00% |
Total | 45 | 100.00% | 1 | 100.00% |
static u32 intel_panel_get_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 val = 0;
mutex_lock(&dev_priv->backlight_lock);
if (panel->backlight.enabled) {
val = panel->backlight.get(connector);
val = intel_panel_compute_brightness(connector, val);
}
mutex_unlock(&dev_priv->backlight_lock);
DRM_DEBUG_DRIVER("get backlight PWM = %d\n", val);
return val;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 57 | 59.38% | 5 | 50.00% |
Ville Syrjälä | 22 | 22.92% | 1 | 10.00% |
Chris Wilson | 11 | 11.46% | 1 | 10.00% |
Carsten Emde | 3 | 3.12% | 1 | 10.00% |
Daniel Vetter | 2 | 2.08% | 1 | 10.00% |
Jesse Barnes | 1 | 1.04% | 1 | 10.00% |
Total | 96 | 100.00% | 10 | 100.00% |
static void lpt_set_backlight(struct intel_connector *connector, u32 level)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
u32 val = I915_READ(BLC_PWM_PCH_CTL2) & ~BACKLIGHT_DUTY_CYCLE_MASK;
I915_WRITE(BLC_PWM_PCH_CTL2, val | level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Vetter | 27 | 56.25% | 1 | 14.29% |
Chris Wilson | 11 | 22.92% | 1 | 14.29% |
Jani Nikula | 7 | 14.58% | 3 | 42.86% |
Takashi Iwai | 2 | 4.17% | 1 | 14.29% |
Jesse Barnes | 1 | 2.08% | 1 | 14.29% |
Total | 48 | 100.00% | 7 | 100.00% |
static void pch_set_backlight(struct intel_connector *connector, u32 level)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
u32 tmp;
tmp = I915_READ(BLC_PWM_CPU_CTL) & ~BACKLIGHT_DUTY_CYCLE_MASK;
I915_WRITE(BLC_PWM_CPU_CTL, tmp | level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Chris Wilson | 29 | 58.00% | 1 | 33.33% |
Jani Nikula | 21 | 42.00% | 2 | 66.67% |
Total | 50 | 100.00% | 3 | 100.00% |
static void i9xx_set_backlight(struct intel_connector *connector, u32 level)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 tmp, mask;
WARN_ON(panel->backlight.max == 0);
if (panel->backlight.combination_mode) {
u8 lbpc;
lbpc = level * 0xfe / panel->backlight.max + 1;
level /= lbpc;
pci_write_config_byte(dev_priv->drm.pdev, LBPC, lbpc);
}
if (IS_GEN4(dev_priv)) {
mask = BACKLIGHT_DUTY_CYCLE_MASK;
} else {
level <<= 1;
mask = BACKLIGHT_DUTY_CYCLE_MASK_PNV;
}
tmp = I915_READ(BLC_PWM_CTL) & ~mask;
I915_WRITE(BLC_PWM_CTL, tmp | level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 84 | 59.57% | 5 | 41.67% |
Takashi Iwai | 29 | 20.57% | 2 | 16.67% |
Chris Wilson | 15 | 10.64% | 2 | 16.67% |
Jesse Barnes | 12 | 8.51% | 2 | 16.67% |
Joonas Lahtinen | 1 | 0.71% | 1 | 8.33% |
Total | 141 | 100.00% | 12 | 100.00% |
static void vlv_set_backlight(struct intel_connector *connector, u32 level)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
enum pipe pipe = intel_get_pipe_from_connector(connector);
u32 tmp;
if (WARN_ON(pipe != PIPE_A && pipe != PIPE_B))
return;
tmp = I915_READ(VLV_BLC_PWM_CTL(pipe)) & ~BACKLIGHT_DUTY_CYCLE_MASK;
I915_WRITE(VLV_BLC_PWM_CTL(pipe), tmp | level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 47 | 59.49% | 2 | 50.00% |
Chris Wilson | 18 | 22.78% | 1 | 25.00% |
Ville Syrjälä | 14 | 17.72% | 1 | 25.00% |
Total | 79 | 100.00% | 4 | 100.00% |
static void bxt_set_backlight(struct intel_connector *connector, u32 level)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
I915_WRITE(BXT_BLC_PWM_DUTY(panel->backlight.controller), level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vandana Kannan | 29 | 55.77% | 1 | 33.33% |
A.Sunil Kamath | 18 | 34.62% | 1 | 33.33% |
Jani Nikula | 5 | 9.62% | 1 | 33.33% |
Total | 52 | 100.00% | 3 | 100.00% |
static void pwm_set_backlight(struct intel_connector *connector, u32 level)
{
struct intel_panel *panel = &connector->panel;
int duty_ns = DIV_ROUND_UP(level * CRC_PMIC_PWM_PERIOD_NS, 100);
pwm_config(panel->backlight.pwm, duty_ns, CRC_PMIC_PWM_PERIOD_NS);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Shobhit Kumar | 49 | 100.00% | 1 | 100.00% |
Total | 49 | 100.00% | 1 | 100.00% |
static void
intel_panel_actually_set_backlight(struct intel_connector *connector, u32 level)
{
struct intel_panel *panel = &connector->panel;
DRM_DEBUG_DRIVER("set backlight PWM = %d\n", level);
level = intel_panel_compute_brightness(connector, level);
panel->backlight.set(connector, level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 51 | 100.00% | 3 | 100.00% |
Total | 51 | 100.00% | 3 | 100.00% |
/* set backlight brightness to level in range [0..max], scaling wrt hw min */
static void intel_panel_set_backlight(struct intel_connector *connector,
u32 user_level, u32 user_max)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 hw_level;
if (!panel->backlight.present)
return;
mutex_lock(&dev_priv->backlight_lock);
WARN_ON(panel->backlight.max == 0);
hw_level = scale_user_to_hw(connector, user_level, user_max);
panel->backlight.level = hw_level;
if (panel->backlight.enabled)
intel_panel_actually_set_backlight(connector, hw_level);
mutex_unlock(&dev_priv->backlight_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 113 | 98.26% | 3 | 75.00% |
Daniel Vetter | 2 | 1.74% | 1 | 25.00% |
Total | 115 | 100.00% | 4 | 100.00% |
/* set backlight brightness to level in range [0..max], assuming hw min is
* respected.
*/
void intel_panel_set_backlight_acpi(struct intel_connector *connector,
u32 user_level, u32 user_max)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
enum pipe pipe = intel_get_pipe_from_connector(connector);
u32 hw_level;
/*
* INVALID_PIPE may occur during driver init because
* connection_mutex isn't held across the entire backlight
* setup + modeset readout, and the BIOS can issue the
* requests at any time.
*/
if (!panel->backlight.present || pipe == INVALID_PIPE)
return;
mutex_lock(&dev_priv->backlight_lock);
WARN_ON(panel->backlight.max == 0);
hw_level = clamp_user_to_hw(connector, user_level, user_max);
panel->backlight.level = hw_level;
if (panel->backlight.device)
panel->backlight.device->props.brightness =
scale_hw_to_user(connector,
panel->backlight.level,
panel->backlight.device->props.max_brightness);
if (panel->backlight.enabled)
intel_panel_actually_set_backlight(connector, hw_level);
mutex_unlock(&dev_priv->backlight_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 106 | 63.47% | 9 | 56.25% |
Jesse Barnes | 26 | 15.57% | 1 | 6.25% |
Chris Wilson | 15 | 8.98% | 1 | 6.25% |
Ville Syrjälä | 8 | 4.79% | 2 | 12.50% |
Takashi Iwai | 7 | 4.19% | 1 | 6.25% |
Aaron Lu | 3 | 1.80% | 1 | 6.25% |
Daniel Vetter | 2 | 1.20% | 1 | 6.25% |
Total | 167 | 100.00% | 16 | 100.00% |
static void lpt_disable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
u32 tmp;
intel_panel_actually_set_backlight(connector, 0);
/*
* Although we don't support or enable CPU PWM with LPT/SPT based
* systems, it may have been enabled prior to loading the
* driver. Disable to avoid warnings on LCPLL disable.
*
* This needs rework if we need to add support for CPU PWM on PCH split
* platforms.
*/
tmp = I915_READ(BLC_PWM_CPU_CTL2);
if (tmp & BLM_PWM_ENABLE) {
DRM_DEBUG_KMS("cpu backlight was enabled, disabling\n");
I915_WRITE(BLC_PWM_CPU_CTL2, tmp & ~BLM_PWM_ENABLE);
}
tmp = I915_READ(BLC_PWM_PCH_CTL1);
I915_WRITE(BLC_PWM_PCH_CTL1, tmp & ~BLM_PCH_PWM_ENABLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 83 | 100.00% | 3 | 100.00% |
Total | 83 | 100.00% | 3 | 100.00% |
static void pch_disable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
u32 tmp;
intel_panel_actually_set_backlight(connector, 0);
tmp = I915_READ(BLC_PWM_CPU_CTL2);
I915_WRITE(BLC_PWM_CPU_CTL2, tmp & ~BLM_PWM_ENABLE);
tmp = I915_READ(BLC_PWM_PCH_CTL1);
I915_WRITE(BLC_PWM_PCH_CTL1, tmp & ~BLM_PCH_PWM_ENABLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 46 | 66.67% | 5 | 62.50% |
Jesse Barnes | 10 | 14.49% | 1 | 12.50% |
Takashi Iwai | 8 | 11.59% | 1 | 12.50% |
Chris Wilson | 5 | 7.25% | 1 | 12.50% |
Total | 69 | 100.00% | 8 | 100.00% |
static void i9xx_disable_backlight(struct intel_connector *connector)
{
intel_panel_actually_set_backlight(connector, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 18 | 100.00% | 1 | 100.00% |
Total | 18 | 100.00% | 1 | 100.00% |
static void i965_disable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
u32 tmp;
intel_panel_actually_set_backlight(connector, 0);
tmp = I915_READ(BLC_PWM_CTL2);
I915_WRITE(BLC_PWM_CTL2, tmp & ~BLM_PWM_ENABLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 38 | 73.08% | 3 | 60.00% |
Daniel Vetter | 12 | 23.08% | 1 | 20.00% |
Jesse Barnes | 2 | 3.85% | 1 | 20.00% |
Total | 52 | 100.00% | 5 | 100.00% |
static void vlv_disable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
enum pipe pipe = intel_get_pipe_from_connector(connector);
u32 tmp;
if (WARN_ON(pipe != PIPE_A && pipe != PIPE_B))
return;
intel_panel_actually_set_backlight(connector, 0);
tmp = I915_READ(VLV_BLC_PWM_CTL2(pipe));
I915_WRITE(VLV_BLC_PWM_CTL2(pipe), tmp & ~BLM_PWM_ENABLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 55 | 67.90% | 4 | 57.14% |
Ville Syrjälä | 14 | 17.28% | 1 | 14.29% |
Paulo Zanoni | 11 | 13.58% | 1 | 14.29% |
Chris Wilson | 1 | 1.23% | 1 | 14.29% |
Total | 81 | 100.00% | 7 | 100.00% |
static void bxt_disable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 tmp, val;
intel_panel_actually_set_backlight(connector, 0);
tmp = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
tmp & ~BXT_BLC_PWM_ENABLE);
if (panel->backlight.controller == 1) {
val = I915_READ(UTIL_PIN_CTL);
val &= ~UTIL_PIN_ENABLE;
I915_WRITE(UTIL_PIN_CTL, val);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
A.Sunil Kamath | 59 | 54.13% | 1 | 33.33% |
Vandana Kannan | 45 | 41.28% | 1 | 33.33% |
Jani Nikula | 5 | 4.59% | 1 | 33.33% |
Total | 109 | 100.00% | 3 | 100.00% |
static void pwm_disable_backlight(struct intel_connector *connector)
{
struct intel_panel *panel = &connector->panel;
/* Disable the backlight */
pwm_config(panel->backlight.pwm, 0, CRC_PMIC_PWM_PERIOD_NS);
usleep_range(2000, 3000);
pwm_disable(panel->backlight.pwm);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Shobhit Kumar | 51 | 100.00% | 1 | 100.00% |
Total | 51 | 100.00% | 1 | 100.00% |
void intel_panel_disable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
if (!panel->backlight.present)
return;
/*
* Do not disable backlight on the vga_switcheroo path. When switching
* away from i915, the other client may depend on i915 to handle the
* backlight. This will leave the backlight on unnecessarily when
* another client is not activated.
*/
if (dev_priv->drm.switch_power_state == DRM_SWITCH_POWER_CHANGING) {
DRM_DEBUG_DRIVER("Skipping backlight disable on vga switch\n");
return;
}
mutex_lock(&dev_priv->backlight_lock);
if (panel->backlight.device)
panel->backlight.device->props.power = FB_BLANK_POWERDOWN;
panel->backlight.enabled = false;
panel->backlight.disable(connector);
mutex_unlock(&dev_priv->backlight_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 76 | 65.52% | 8 | 47.06% |
Chris Wilson | 13 | 11.21% | 3 | 17.65% |
Jesse Barnes | 13 | 11.21% | 1 | 5.88% |
Ville Syrjälä | 6 | 5.17% | 1 | 5.88% |
Daniel Vetter | 5 | 4.31% | 2 | 11.76% |
Damien Lespiau | 2 | 1.72% | 1 | 5.88% |
Lukas Wunner | 1 | 0.86% | 1 | 5.88% |
Total | 116 | 100.00% | 17 | 100.00% |
static void lpt_enable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 pch_ctl1, pch_ctl2, schicken;
pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
DRM_DEBUG_KMS("pch backlight already enabled\n");
pch_ctl1 &= ~BLM_PCH_PWM_ENABLE;
I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
}
if (HAS_PCH_LPT(dev_priv)) {
schicken = I915_READ(SOUTH_CHICKEN2);
if (panel->backlight.alternate_pwm_increment)
schicken |= LPT_PWM_GRANULARITY;
else
schicken &= ~LPT_PWM_GRANULARITY;
I915_WRITE(SOUTH_CHICKEN2, schicken);
} else {
schicken = I915_READ(SOUTH_CHICKEN1);
if (panel->backlight.alternate_pwm_increment)
schicken |= SPT_PWM_GRANULARITY;
else
schicken &= ~SPT_PWM_GRANULARITY;
I915_WRITE(SOUTH_CHICKEN1, schicken);
}
pch_ctl2 = panel->backlight.max << 16;
I915_WRITE(BLC_PWM_PCH_CTL2, pch_ctl2);
pch_ctl1 = 0;
if (panel->backlight.active_low_pwm)
pch_ctl1 |= BLM_PCH_POLARITY;
/* After LPT, override is the default. */
if (HAS_PCH_LPT(dev_priv))
pch_ctl1 |= BLM_PCH_OVERRIDE_ENABLE;
I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
POSTING_READ(BLC_PWM_PCH_CTL1);
I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1 | BLM_PCH_PWM_ENABLE);
/* This won't stick until the above enable. */
intel_panel_actually_set_backlight(connector, panel->backlight.level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Vetter | 112 | 49.12% | 2 | 20.00% |
Shawn C Lee | 78 | 34.21% | 1 | 10.00% |
Jani Nikula | 17 | 7.46% | 5 | 50.00% |
Ben Widawsky | 11 | 4.82% | 1 | 10.00% |
Paulo Zanoni | 10 | 4.39% | 1 | 10.00% |
Total | 228 | 100.00% | 10 | 100.00% |
static void pch_enable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
enum pipe pipe = intel_get_pipe_from_connector(connector);
enum transcoder cpu_transcoder =
intel_pipe_to_cpu_transcoder(dev_priv, pipe);
u32 cpu_ctl2, pch_ctl1, pch_ctl2;
cpu_ctl2 = I915_READ(BLC_PWM_CPU_CTL2);
if (cpu_ctl2 & BLM_PWM_ENABLE) {
DRM_DEBUG_KMS("cpu backlight already enabled\n");
cpu_ctl2 &= ~BLM_PWM_ENABLE;
I915_WRITE(BLC_PWM_CPU_CTL2, cpu_ctl2);
}
pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
if (pch_ctl1 & BLM_PCH_PWM_ENABLE) {
DRM_DEBUG_KMS("pch backlight already enabled\n");
pch_ctl1 &= ~BLM_PCH_PWM_ENABLE;
I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
}
if (cpu_transcoder == TRANSCODER_EDP)
cpu_ctl2 = BLM_TRANSCODER_EDP;
else
cpu_ctl2 = BLM_PIPE(cpu_transcoder);
I915_WRITE(BLC_PWM_CPU_CTL2, cpu_ctl2);
POSTING_READ(BLC_PWM_CPU_CTL2);
I915_WRITE(BLC_PWM_CPU_CTL2, cpu_ctl2 | BLM_PWM_ENABLE);
/* This won't stick until the above enable. */
intel_panel_actually_set_backlight(connector, panel->backlight.level);
pch_ctl2 = panel->backlight.max << 16;
I915_WRITE(BLC_PWM_PCH_CTL2, pch_ctl2);
pch_ctl1 = 0;
if (panel->backlight.active_low_pwm)
pch_ctl1 |= BLM_PCH_POLARITY;
I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1);
POSTING_READ(BLC_PWM_PCH_CTL1);
I915_WRITE(BLC_PWM_PCH_CTL1, pch_ctl1 | BLM_PCH_PWM_ENABLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 176 | 76.19% | 5 | 50.00% |
Daniel Vetter | 37 | 16.02% | 1 | 10.00% |
Paulo Zanoni | 10 | 4.33% | 1 | 10.00% |
Jesse Barnes | 5 | 2.16% | 1 | 10.00% |
Ben Widawsky | 2 | 0.87% | 1 | 10.00% |
Scot Doyle | 1 | 0.43% | 1 | 10.00% |
Total | 231 | 100.00% | 10 | 100.00% |
static void i9xx_enable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 ctl, freq;
ctl = I915_READ(BLC_PWM_CTL);
if (ctl & BACKLIGHT_DUTY_CYCLE_MASK_PNV) {
DRM_DEBUG_KMS("backlight already enabled\n");
I915_WRITE(BLC_PWM_CTL, 0);
}
freq = panel->backlight.max;
if (panel->backlight.combination_mode)
freq /= 0xff;
ctl = freq << 17;
if (panel->backlight.combination_mode)
ctl |= BLM_LEGACY_MODE;
if (IS_PINEVIEW(dev_priv) && panel->backlight.active_low_pwm)
ctl |= BLM_POLARITY_PNV;
I915_WRITE(BLC_PWM_CTL, ctl);
POSTING_READ(BLC_PWM_CTL);
/* XXX: combine this into above write? */
intel_panel_actually_set_backlight(connector, panel->backlight.level);
/*
* Needed to enable backlight on some 855gm models. BLC_HIST_CTL is
* 855gm only, but checking for gen2 is safe, as 855gm is the only gen2
* that has backlight.
*/
if (IS_GEN2(dev_priv))
I915_WRITE(BLC_HIST_CTL, BLM_HISTOGRAM_ENABLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 159 | 98.76% | 4 | 66.67% |
Daniel Vetter | 1 | 0.62% | 1 | 16.67% |
Scot Doyle | 1 | 0.62% | 1 | 16.67% |
Total | 161 | 100.00% | 6 | 100.00% |
static void i965_enable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
enum pipe pipe = intel_get_pipe_from_connector(connector);
u32 ctl, ctl2, freq;
ctl2 = I915_READ(BLC_PWM_CTL2);
if (ctl2 & BLM_PWM_ENABLE) {
DRM_DEBUG_KMS("backlight already enabled\n");
ctl2 &= ~BLM_PWM_ENABLE;
I915_WRITE(BLC_PWM_CTL2, ctl2);
}
freq = panel->backlight.max;
if (panel->backlight.combination_mode)
freq /= 0xff;
ctl = freq << 16;
I915_WRITE(BLC_PWM_CTL, ctl);
ctl2 = BLM_PIPE(pipe);
if (panel->backlight.combination_mode)
ctl2 |= BLM_COMBINATION_MODE;
if (panel->backlight.active_low_pwm)
ctl2 |= BLM_POLARITY_I965;
I915_WRITE(BLC_PWM_CTL2, ctl2);
POSTING_READ(BLC_PWM_CTL2);
I915_WRITE(BLC_PWM_CTL2, ctl2 | BLM_PWM_ENABLE);
intel_panel_actually_set_backlight(connector, panel->backlight.level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 149 | 83.24% | 5 | 62.50% |
Jesse Barnes | 29 | 16.20% | 2 | 25.00% |
Scot Doyle | 1 | 0.56% | 1 | 12.50% |
Total | 179 | 100.00% | 8 | 100.00% |
static void vlv_enable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
enum pipe pipe = intel_get_pipe_from_connector(connector);
u32 ctl, ctl2;
if (WARN_ON(pipe != PIPE_A && pipe != PIPE_B))
return;
ctl2 = I915_READ(VLV_BLC_PWM_CTL2(pipe));
if (ctl2 & BLM_PWM_ENABLE) {
DRM_DEBUG_KMS("backlight already enabled\n");
ctl2 &= ~BLM_PWM_ENABLE;
I915_WRITE(VLV_BLC_PWM_CTL2(pipe), ctl2);
}
ctl = panel->backlight.max << 16;
I915_WRITE(VLV_BLC_PWM_CTL(pipe), ctl);
/* XXX: combine this into above write? */
intel_panel_actually_set_backlight(connector, panel->backlight.level);
ctl2 = 0;
if (panel->backlight.active_low_pwm)
ctl2 |= BLM_POLARITY_I965;
I915_WRITE(VLV_BLC_PWM_CTL2(pipe), ctl2);
POSTING_READ(VLV_BLC_PWM_CTL2(pipe));
I915_WRITE(VLV_BLC_PWM_CTL2(pipe), ctl2 | BLM_PWM_ENABLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 161 | 89.94% | 4 | 57.14% |
Ville Syrjälä | 14 | 7.82% | 1 | 14.29% |
Chris Wilson | 3 | 1.68% | 1 | 14.29% |
Scot Doyle | 1 | 0.56% | 1 | 14.29% |
Total | 179 | 100.00% | 7 | 100.00% |
static void bxt_enable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
enum pipe pipe = intel_get_pipe_from_connector(connector);
u32 pwm_ctl, val;
/* Controller 1 uses the utility pin. */
if (panel->backlight.controller == 1) {
val = I915_READ(UTIL_PIN_CTL);
if (val & UTIL_PIN_ENABLE) {
DRM_DEBUG_KMS("util pin already enabled\n");
val &= ~UTIL_PIN_ENABLE;
I915_WRITE(UTIL_PIN_CTL, val);
}
val = 0;
if (panel->backlight.util_pin_active_low)
val |= UTIL_PIN_POLARITY;
I915_WRITE(UTIL_PIN_CTL, val | UTIL_PIN_PIPE(pipe) |
UTIL_PIN_MODE_PWM | UTIL_PIN_ENABLE);
}
pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
if (pwm_ctl & BXT_BLC_PWM_ENABLE) {
DRM_DEBUG_KMS("backlight already enabled\n");
pwm_ctl &= ~BXT_BLC_PWM_ENABLE;
I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
pwm_ctl);
}
I915_WRITE(BXT_BLC_PWM_FREQ(panel->backlight.controller),
panel->backlight.max);
intel_panel_actually_set_backlight(connector, panel->backlight.level);
pwm_ctl = 0;
if (panel->backlight.active_low_pwm)
pwm_ctl |= BXT_BLC_PWM_POLARITY;
I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller), pwm_ctl);
POSTING_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
I915_WRITE(BXT_BLC_PWM_CTL(panel->backlight.controller),
pwm_ctl | BXT_BLC_PWM_ENABLE);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
A.Sunil Kamath | 135 | 52.12% | 1 | 25.00% |
Vandana Kannan | 118 | 45.56% | 1 | 25.00% |
Jani Nikula | 5 | 1.93% | 1 | 25.00% |
Vidya Srinivas | 1 | 0.39% | 1 | 25.00% |
Total | 259 | 100.00% | 4 | 100.00% |
static void pwm_enable_backlight(struct intel_connector *connector)
{
struct intel_panel *panel = &connector->panel;
pwm_enable(panel->backlight.pwm);
intel_panel_actually_set_backlight(connector, panel->backlight.level);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Shobhit Kumar | 41 | 100.00% | 1 | 100.00% |
Total | 41 | 100.00% | 1 | 100.00% |
void intel_panel_enable_backlight(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
enum pipe pipe = intel_get_pipe_from_connector(connector);
if (!panel->backlight.present)
return;
DRM_DEBUG_KMS("pipe %c\n", pipe_name(pipe));
mutex_lock(&dev_priv->backlight_lock);
WARN_ON(panel->backlight.max == 0);
if (panel->backlight.level <= panel->backlight.min) {
panel->backlight.level = panel->backlight.max;
if (panel->backlight.device)
panel->backlight.device->props.brightness =
scale_hw_to_user(connector,
panel->backlight.level,
panel->backlight.device->props.max_brightness);
}
panel->backlight.enable(connector);
panel->backlight.enabled = true;
if (panel->backlight.device)
panel->backlight.device->props.power = FB_BLANK_UNBLANK;
mutex_unlock(&dev_priv->backlight_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 180 | 92.78% | 6 | 66.67% |
Ville Syrjälä | 6 | 3.09% | 1 | 11.11% |
Jeremiah Mahler | 6 | 3.09% | 1 | 11.11% |
Daniel Vetter | 2 | 1.03% | 1 | 11.11% |
Total | 194 | 100.00% | 9 | 100.00% |
#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
static int intel_backlight_device_update_status(struct backlight_device *bd)
{
struct intel_connector *connector = bl_get_data(bd);
struct intel_panel *panel = &connector->panel;
struct drm_device *dev = connector->base.dev;
drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
DRM_DEBUG_KMS("updating intel_backlight, brightness=%d/%d\n",
bd->props.brightness, bd->props.max_brightness);
intel_panel_set_backlight(connector, bd->props.brightness,
bd->props.max_brightness);
/*
* Allow flipping bl_power as a sub-state of enabled. Sadly the
* backlight class device does not make it easy to to differentiate
* between callbacks for brightness and bl_power, so our backlight_power
* callback needs to take this into account.
*/
if (panel->backlight.enabled) {
if (panel->backlight.power) {
bool enable = bd->props.power == FB_BLANK_UNBLANK &&
bd->props.brightness != 0;
panel->backlight.power(connector, enable);
}
} else {
bd->props.power = FB_BLANK_POWERDOWN;
}
drm_modeset_unlock(&dev->mode_config.connection_mutex);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 79 | 48.47% | 5 | 50.00% |
Matthew Garrett | 31 | 19.02% | 1 | 10.00% |
Jesse Barnes | 30 | 18.40% | 1 | 10.00% |
Chris Wilson | 17 | 10.43% | 1 | 10.00% |
Rob Clark | 4 | 2.45% | 1 | 10.00% |
Daniel Vetter | 2 | 1.23% | 1 | 10.00% |
Total | 163 | 100.00% | 10 | 100.00% |
static int intel_backlight_device_get_brightness(struct backlight_device *bd)
{
struct intel_connector *connector = bl_get_data(bd);
struct drm_device *dev = connector->base.dev;
struct drm_i915_private *dev_priv = to_i915(dev);
u32 hw_level;
int ret;
intel_runtime_pm_get(dev_priv);
drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
hw_level = intel_panel_get_backlight(connector);
ret = scale_hw_to_user(connector, hw_level, bd->props.max_brightness);
drm_modeset_unlock(&dev->mode_config.connection_mutex);
intel_runtime_pm_put(dev_priv);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 79 | 75.24% | 2 | 33.33% |
Paulo Zanoni | 17 | 16.19% | 1 | 16.67% |
Rob Clark | 4 | 3.81% | 1 | 16.67% |
Chris Wilson | 3 | 2.86% | 1 | 16.67% |
Daniel Vetter | 2 | 1.90% | 1 | 16.67% |
Total | 105 | 100.00% | 6 | 100.00% |
static const struct backlight_ops intel_backlight_device_ops = {
.update_status = intel_backlight_device_update_status,
.get_brightness = intel_backlight_device_get_brightness,
};
int intel_backlight_device_register(struct intel_connector *connector)
{
struct intel_panel *panel = &connector->panel;
struct backlight_properties props;
if (WARN_ON(panel->backlight.device))
return -ENODEV;
if (!panel->backlight.present)
return 0;
WARN_ON(panel->backlight.max == 0);
memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
/*
* Note: Everything should work even if the backlight device max
* presented to the userspace is arbitrarily chosen.
*/
props.max_brightness = panel->backlight.max;
props.brightness = scale_hw_to_user(connector,
panel->backlight.level,
props.max_brightness);
if (panel->backlight.enabled)
props.power = FB_BLANK_UNBLANK;
else
props.power = FB_BLANK_POWERDOWN;
/*
* Note: using the same name independent of the connector prevents
* registration of multiple backlight devices in the driver.
*/
panel->backlight.device =
backlight_device_register("intel_backlight",
connector->base.kdev,
connector,
&intel_backlight_device_ops, &props);
if (IS_ERR(panel->backlight.device)) {
DRM_ERROR("Failed to register backlight: %ld\n",
PTR_ERR(panel->backlight.device));
panel->backlight.device = NULL;
return -ENODEV;
}
DRM_DEBUG_KMS("Connector %s backlight sysfs interface registered\n",
connector->base.name);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 188 | 89.10% | 3 | 75.00% |
Ville Syrjälä | 23 | 10.90% | 1 | 25.00% |
Total | 211 | 100.00% | 4 | 100.00% |
void intel_backlight_device_unregister(struct intel_connector *connector)
{
struct intel_panel *panel = &connector->panel;
if (panel->backlight.device) {
backlight_device_unregister(panel->backlight.device);
panel->backlight.device = NULL;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 26 | 55.32% | 1 | 33.33% |
Jesse Barnes | 17 | 36.17% | 1 | 33.33% |
Matthew Garrett | 4 | 8.51% | 1 | 33.33% |
Total | 47 | 100.00% | 3 | 100.00% |
#endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */
/*
* BXT: PWM clock frequency = 19.2 MHz.
*/
static u32 bxt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{
return DIV_ROUND_CLOSEST(KHz(19200), pwm_freq_hz);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 21 | 84.00% | 1 | 50.00% |
Ville Syrjälä | 4 | 16.00% | 1 | 50.00% |
Total | 25 | 100.00% | 2 | 100.00% |
/*
* SPT: This value represents the period of the PWM stream in clock periods
* multiplied by 16 (default increment) or 128 (alternate increment selected in
* SCHICKEN_1 bit 0). PWM clock is 24 MHz.
*/
static u32 spt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{
struct intel_panel *panel = &connector->panel;
u32 mul;
if (panel->backlight.alternate_pwm_increment)
mul = 128;
else
mul = 16;
return DIV_ROUND_CLOSEST(MHz(24), pwm_freq_hz * mul);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 52 | 91.23% | 2 | 50.00% |
Ville Syrjälä | 5 | 8.77% | 2 | 50.00% |
Total | 57 | 100.00% | 4 | 100.00% |
/*
* LPT: This value represents the period of the PWM stream in clock periods
* multiplied by 128 (default increment) or 16 (alternate increment, selected in
* LPT SOUTH_CHICKEN2 register bit 5).
*/
static u32 lpt_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 mul, clock;
if (panel->backlight.alternate_pwm_increment)
mul = 16;
else
mul = 128;
if (HAS_PCH_LPT_H(dev_priv))
clock = MHz(135); /* LPT:H */
else
clock = MHz(24); /* LPT:LP */
return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * mul);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 87 | 92.55% | 3 | 60.00% |
Ville Syrjälä | 7 | 7.45% | 2 | 40.00% |
Total | 94 | 100.00% | 5 | 100.00% |
/*
* ILK/SNB/IVB: This value represents the period of the PWM stream in PCH
* display raw clocks multiplied by 128.
*/
static u32 pch_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
return DIV_ROUND_CLOSEST(KHz(dev_priv->rawclk_freq), pwm_freq_hz * 128);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 29 | 67.44% | 1 | 33.33% |
Ville Syrjälä | 14 | 32.56% | 2 | 66.67% |
Total | 43 | 100.00% | 3 | 100.00% |
/*
* Gen2: This field determines the number of time base events (display core
* clock frequency/32) in total for a complete cycle of modulated backlight
* control.
*
* Gen3: A time base event equals the display core clock ([DevPNV] HRAW clock)
* divided by 32.
*/
static u32 i9xx_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
int clock;
if (IS_PINEVIEW(dev_priv))
clock = KHz(dev_priv->rawclk_freq);
else
clock = KHz(dev_priv->cdclk_freq);
return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 32);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 48 | 71.64% | 1 | 20.00% |
Ville Syrjälä | 19 | 28.36% | 4 | 80.00% |
Total | 67 | 100.00% | 5 | 100.00% |
/*
* Gen4: This value represents the period of the PWM stream in display core
* clocks ([DevCTG] HRAW clocks) multiplied by 128.
*
*/
static u32 i965_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
int clock;
if (IS_G4X(dev_priv))
clock = KHz(dev_priv->rawclk_freq);
else
clock = KHz(dev_priv->cdclk_freq);
return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * 128);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 31 | 46.27% | 1 | 14.29% |
Ville Syrjälä | 29 | 43.28% | 4 | 57.14% |
Mika Kahola | 4 | 5.97% | 1 | 14.29% |
Chris Wilson | 3 | 4.48% | 1 | 14.29% |
Total | 67 | 100.00% | 7 | 100.00% |
/*
* VLV: This value represents the period of the PWM stream in display core
* clocks ([DevCTG] 200MHz HRAW clocks) multiplied by 128 or 25MHz S0IX clocks
* multiplied by 16. CHV uses a 19.2MHz S0IX clock.
*/
static u32 vlv_hz_to_pwm(struct intel_connector *connector, u32 pwm_freq_hz)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
int mul, clock;
if ((I915_READ(CBR1_VLV) & CBR_PWM_CLOCK_MUX_SELECT) == 0) {
if (IS_CHERRYVIEW(dev_priv))
clock = KHz(19200);
else
clock = MHz(25);
mul = 16;
} else {
clock = KHz(dev_priv->rawclk_freq);
mul = 128;
}
return DIV_ROUND_CLOSEST(clock, pwm_freq_hz * mul);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 69 | 69.00% | 1 | 33.33% |
Ville Syrjälä | 31 | 31.00% | 2 | 66.67% |
Total | 100 | 100.00% | 3 | 100.00% |
static u32 get_backlight_max_vbt(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u16 pwm_freq_hz = dev_priv->vbt.backlight.pwm_freq_hz;
u32 pwm;
if (!panel->backlight.hz_to_pwm) {
DRM_DEBUG_KMS("backlight frequency conversion not supported\n");
return 0;
}
if (pwm_freq_hz) {
DRM_DEBUG_KMS("VBT defined backlight frequency %u Hz\n",
pwm_freq_hz);
} else {
pwm_freq_hz = 200;
DRM_DEBUG_KMS("default backlight frequency %u Hz\n",
pwm_freq_hz);
}
pwm = panel->backlight.hz_to_pwm(connector, pwm_freq_hz);
if (!pwm) {
DRM_DEBUG_KMS("backlight frequency conversion failed\n");
return 0;
}
return pwm;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 126 | 100.00% | 4 | 100.00% |
Total | 126 | 100.00% | 4 | 100.00% |
/*
* Note: The setup hooks can't assume pipe is set!
*/
static u32 get_backlight_min_vbt(struct intel_connector *connector)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
int min;
WARN_ON(panel->backlight.max == 0);
/*
* XXX: If the vbt value is 255, it makes min equal to max, which leads
* to problems. There are such machines out there. Either our
* interpretation is wrong or the vbt has bogus data. Or both. Safeguard
* against this by letting the minimum be at most (arbitrarily chosen)
* 25% of the max.
*/
min = clamp_t(int, dev_priv->vbt.backlight.min_brightness, 0, 64);
if (min != dev_priv->vbt.backlight.min_brightness) {
DRM_DEBUG_KMS("clamping VBT min backlight %d/255 to %d/255\n",
dev_priv->vbt.backlight.min_brightness, min);
}
/* vbt value is a coefficient in range [0..255] */
return scale(min, 0, 255, 0, panel->backlight.max);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 117 | 100.00% | 3 | 100.00% |
Total | 117 | 100.00% | 3 | 100.00% |
static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unused)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 pch_ctl1, pch_ctl2, val;
bool alt;
if (HAS_PCH_LPT(dev_priv))
alt = I915_READ(SOUTH_CHICKEN2) & LPT_PWM_GRANULARITY;
else
alt = I915_READ(SOUTH_CHICKEN1) & SPT_PWM_GRANULARITY;
panel->backlight.alternate_pwm_increment = alt;
pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY;
pch_ctl2 = I915_READ(BLC_PWM_PCH_CTL2);
panel->backlight.max = pch_ctl2 >> 16;
if (!panel->backlight.max)
panel->backlight.max = get_backlight_max_vbt(connector);
if (!panel->backlight.max)
return -ENODEV;
panel->backlight.min = get_backlight_min_vbt(connector);
val = lpt_get_backlight(connector);
val = intel_panel_compute_brightness(connector, val);
panel->backlight.level = clamp(val, panel->backlight.min,
panel->backlight.max);
panel->backlight.enabled = pch_ctl1 & BLM_PCH_PWM_ENABLE;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Vetter | 112 | 52.58% | 1 | 12.50% |
Jani Nikula | 97 | 45.54% | 6 | 75.00% |
Ville Syrjälä | 4 | 1.88% | 1 | 12.50% |
Total | 213 | 100.00% | 8 | 100.00% |
static int pch_setup_backlight(struct intel_connector *connector, enum pipe unused)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 cpu_ctl2, pch_ctl1, pch_ctl2, val;
pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1);
panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY;
pch_ctl2 = I915_READ(BLC_PWM_PCH_CTL2);
panel->backlight.max = pch_ctl2 >> 16;
if (!panel->backlight.max)
panel->backlight.max = get_backlight_max_vbt(connector);
if (!panel->backlight.max)
return -ENODEV;
panel->backlight.min = get_backlight_min_vbt(connector);
val = pch_get_backlight(connector);
val = intel_panel_compute_brightness(connector, val);
panel->backlight.level = clamp(val, panel->backlight.min,
panel->backlight.max);
cpu_ctl2 = I915_READ(BLC_PWM_CPU_CTL2);
panel->backlight.enabled = (cpu_ctl2 & BLM_PWM_ENABLE) &&
(pch_ctl1 & BLM_PCH_PWM_ENABLE);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 184 | 95.34% | 12 | 80.00% |
Ville Syrjälä | 4 | 2.07% | 1 | 6.67% |
Corentin Chary | 3 | 1.55% | 1 | 6.67% |
Matthew Garrett | 2 | 1.04% | 1 | 6.67% |
Total | 193 | 100.00% | 15 | 100.00% |
static int i9xx_setup_backlight(struct intel_connector *connector, enum pipe unused)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 ctl, val;
ctl = I915_READ(BLC_PWM_CTL);
if (IS_GEN2(dev_priv) || IS_I915GM(dev_priv) || IS_I945GM(dev_priv))
panel->backlight.combination_mode = ctl & BLM_LEGACY_MODE;
if (IS_PINEVIEW(dev_priv))
panel->backlight.active_low_pwm = ctl & BLM_POLARITY_PNV;
panel->backlight.max = ctl >> 17;
if (!panel->backlight.max) {
panel->backlight.max = get_backlight_max_vbt(connector);
panel->backlight.max >>= 1;
}
if (!panel->backlight.max)
return -ENODEV;
if (panel->backlight.combination_mode)
panel->backlight.max *= 0xff;
panel->backlight.min = get_backlight_min_vbt(connector);
val = i9xx_get_backlight(connector);
val = intel_panel_compute_brightness(connector, val);
panel->backlight.level = clamp(val, panel->backlight.min,
panel->backlight.max);
panel->backlight.enabled = val != 0;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 219 | 96.48% | 10 | 83.33% |
Ville Syrjälä | 4 | 1.76% | 1 | 8.33% |
Matthew Garrett | 4 | 1.76% | 1 | 8.33% |
Total | 227 | 100.00% | 12 | 100.00% |
static int i965_setup_backlight(struct intel_connector *connector, enum pipe unused)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 ctl, ctl2, val;
ctl2 = I915_READ(BLC_PWM_CTL2);
panel->backlight.combination_mode = ctl2 & BLM_COMBINATION_MODE;
panel->backlight.active_low_pwm = ctl2 & BLM_POLARITY_I965;
ctl = I915_READ(BLC_PWM_CTL);
panel->backlight.max = ctl >> 16;
if (!panel->backlight.max)
panel->backlight.max = get_backlight_max_vbt(connector);
if (!panel->backlight.max)
return -ENODEV;
if (panel->backlight.combination_mode)
panel->backlight.max *= 0xff;
panel->backlight.min = get_backlight_min_vbt(connector);
val = i9xx_get_backlight(connector);
val = intel_panel_compute_brightness(connector, val);
panel->backlight.level = clamp(val, panel->backlight.min,
panel->backlight.max);
panel->backlight.enabled = ctl2 & BLM_PWM_ENABLE;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 178 | 88.12% | 9 | 81.82% |
Matthew Garrett | 20 | 9.90% | 1 | 9.09% |
Ville Syrjälä | 4 | 1.98% | 1 | 9.09% |
Total | 202 | 100.00% | 11 | 100.00% |
static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 ctl, ctl2, val;
if (WARN_ON(pipe != PIPE_A && pipe != PIPE_B))
return -ENODEV;
ctl2 = I915_READ(VLV_BLC_PWM_CTL2(pipe));
panel->backlight.active_low_pwm = ctl2 & BLM_POLARITY_I965;
ctl = I915_READ(VLV_BLC_PWM_CTL(pipe));
panel->backlight.max = ctl >> 16;
if (!panel->backlight.max)
panel->backlight.max = get_backlight_max_vbt(connector);
if (!panel->backlight.max)
return -ENODEV;
panel->backlight.min = get_backlight_min_vbt(connector);
val = _vlv_get_backlight(dev_priv, pipe);
val = intel_panel_compute_brightness(connector, val);
panel->backlight.level = clamp(val, panel->backlight.min,
panel->backlight.max);
panel->backlight.enabled = ctl2 & BLM_PWM_ENABLE;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 166 | 82.59% | 10 | 83.33% |
Ville Syrjälä | 24 | 11.94% | 1 | 8.33% |
Matthew Garrett | 11 | 5.47% | 1 | 8.33% |
Total | 201 | 100.00% | 12 | 100.00% |
static int
bxt_setup_backlight(struct intel_connector *connector, enum pipe unused)
{
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
struct intel_panel *panel = &connector->panel;
u32 pwm_ctl, val;
panel->backlight.controller = dev_priv->vbt.backlight.controller;
pwm_ctl = I915_READ(BXT_BLC_PWM_CTL(panel->backlight.controller));
/* Controller 1 uses the utility pin. */
if (panel->backlight.controller == 1) {
val = I915_READ(UTIL_PIN_CTL);
panel->backlight.util_pin_active_low =
val & UTIL_PIN_POLARITY;
}
panel->backlight.active_low_pwm = pwm_ctl & BXT_BLC_PWM_POLARITY;
panel->backlight.max =
I915_READ(BXT_BLC_PWM_FREQ(panel->backlight.controller));
if (!panel->backlight.max)
panel->backlight.max = get_backlight_max_vbt(connector);
if (!panel->backlight.max)
return -ENODEV;
val = bxt_get_backlight(connector);
val = intel_panel_compute_brightness(connector, val);
panel->backlight.level = clamp(val, panel->backlight.min,
panel->backlight.max);
panel->backlight.enabled = pwm_ctl & BXT_BLC_PWM_ENABLE;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vandana Kannan | 108 | 50.23% | 1 | 16.67% |
A.Sunil Kamath | 52 | 24.19% | 1 | 16.67% |
Jani Nikula | 47 | 21.86% | 3 | 50.00% |
Vidya Srinivas | 8 | 3.72% | 1 | 16.67% |
Total | 215 | 100.00% | 6 | 100.00% |
static int pwm_setup_backlight(struct intel_connector *connector,
enum pipe pipe)
{
struct drm_device *dev = connector->base.dev;
struct intel_panel *panel = &connector->panel;
int retval;
/* Get the PWM chip for backlight control */
panel->backlight.pwm = pwm_get(dev->dev, "pwm_backlight");
if (IS_ERR(panel->backlight.pwm)) {
DRM_ERROR("Failed to own the pwm chip\n");
panel->backlight.pwm = NULL;
return -ENODEV;
}
/*
* FIXME: pwm_apply_args() should be removed when switching to
* the atomic PWM API.
*/
pwm_apply_args(panel->backlight.pwm);
retval = pwm_config(panel->backlight.pwm, CRC_PMIC_PWM_PERIOD_NS,
CRC_PMIC_PWM_PERIOD_NS);
if (retval < 0) {
DRM_ERROR("Failed to configure the pwm chip\n");
pwm_put(panel->backlight.pwm);
panel->backlight.pwm = NULL;
return retval;
}
panel->backlight.min = 0; /* 0% */
panel->backlight.max = 100; /* 100% */
panel->backlight.level = DIV_ROUND_UP(
pwm_get_duty_cycle(panel->backlight.pwm) * 100,
CRC_PMIC_PWM_PERIOD_NS);
panel->backlight.enabled = panel->backlight.level != 0;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Shobhit Kumar | 190 | 95.00% | 1 | 50.00% |
Boris Brezillon | 10 | 5.00% | 1 | 50.00% |
Total | 200 | 100.00% | 2 | 100.00% |
int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe)
{
struct drm_i915_private *dev_priv = to_i915(connector->dev);
struct intel_connector *intel_connector = to_intel_connector(connector);
struct intel_panel *panel = &intel_connector->panel;
int ret;
if (!dev_priv->vbt.backlight.present) {
if (dev_priv->quirks & QUIRK_BACKLIGHT_PRESENT) {
DRM_DEBUG_KMS("no backlight present per VBT, but present per quirk\n");
} else {
DRM_DEBUG_KMS("no backlight present per VBT\n");
return 0;
}
}
/* ensure intel_panel has been initialized first */
if (WARN_ON(!panel->backlight.setup))
return -ENODEV;
/* set level and max in panel struct */
mutex_lock(&dev_priv->backlight_lock);
ret = panel->backlight.setup(intel_connector, pipe);
mutex_unlock(&dev_priv->backlight_lock);
if (ret) {
DRM_DEBUG_KMS("failed to setup backlight for connector %s\n",
connector->name);
return ret;
}
panel->backlight.present = true;
DRM_DEBUG_KMS("Connector %s backlight initialized, %s, brightness %u/%u\n",
connector->name,
enableddisabled(panel->backlight.enabled),
panel->backlight.level, panel->backlight.max);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 147 | 75.77% | 10 | 62.50% |
Scot Doyle | 19 | 9.79% | 1 | 6.25% |
Matthew Garrett | 12 | 6.19% | 1 | 6.25% |
Ville Syrjälä | 11 | 5.67% | 2 | 12.50% |
Tvrtko A. Ursulin | 3 | 1.55% | 1 | 6.25% |
Daniel Vetter | 2 | 1.03% | 1 | 6.25% |
Total | 194 | 100.00% | 16 | 100.00% |
void intel_panel_destroy_backlight(struct drm_connector *connector)
{
struct intel_connector *intel_connector = to_intel_connector(connector);
struct intel_panel *panel = &intel_connector->panel;
/* dispose of the pwm */
if (panel->backlight.pwm)
pwm_put(panel->backlight.pwm);
panel->backlight.present = false;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 30 | 53.57% | 2 | 50.00% |
Shobhit Kumar | 18 | 32.14% | 1 | 25.00% |
Matthew Garrett | 8 | 14.29% | 1 | 25.00% |
Total | 56 | 100.00% | 4 | 100.00% |
/* Set up chip specific backlight functions */
static void
intel_panel_init_backlight_funcs(struct intel_panel *panel)
{
struct intel_connector *connector =
container_of(panel, struct intel_connector, panel);
struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
if (connector->base.connector_type == DRM_MODE_CONNECTOR_eDP &&
intel_dp_aux_init_backlight_funcs(connector) == 0)
return;
if (connector->base.connector_type == DRM_MODE_CONNECTOR_DSI &&
intel_dsi_dcs_init_backlight_funcs(connector) == 0)
return;
if (IS_GEN9_LP(dev_priv)) {
panel->backlight.setup = bxt_setup_backlight;
panel->backlight.enable = bxt_enable_backlight;
panel->backlight.disable = bxt_disable_backlight;
panel->backlight.set = bxt_set_backlight;
panel->backlight.get = bxt_get_backlight;
panel->backlight.hz_to_pwm = bxt_hz_to_pwm;
} else if (HAS_PCH_LPT(dev_priv) || HAS_PCH_SPT(dev_priv) ||
HAS_PCH_KBP(dev_priv)) {
panel->backlight.setup = lpt_setup_backlight;
panel->backlight.enable = lpt_enable_backlight;
panel->backlight.disable = lpt_disable_backlight;
panel->backlight.set = lpt_set_backlight;
panel->backlight.get = lpt_get_backlight;
if (HAS_PCH_LPT(dev_priv))
panel->backlight.hz_to_pwm = lpt_hz_to_pwm;
else
panel->backlight.hz_to_pwm = spt_hz_to_pwm;
} else if (HAS_PCH_SPLIT(dev_priv)) {
panel->backlight.setup = pch_setup_backlight;
panel->backlight.enable = pch_enable_backlight;
panel->backlight.disable = pch_disable_backlight;
panel->backlight.set = pch_set_backlight;
panel->backlight.get = pch_get_backlight;
panel->backlight.hz_to_pwm = pch_hz_to_pwm;
} else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
if (connector->base.connector_type == DRM_MODE_CONNECTOR_DSI) {
panel->backlight.setup = pwm_setup_backlight;
panel->backlight.enable = pwm_enable_backlight;
panel->backlight.disable = pwm_disable_backlight;
panel->backlight.set = pwm_set_backlight;
panel->backlight.get = pwm_get_backlight;
} else {
panel->backlight.setup = vlv_setup_backlight;
panel->backlight.enable = vlv_enable_backlight;
panel->backlight.disable = vlv_disable_backlight;
panel->backlight.set = vlv_set_backlight;
panel->backlight.get = vlv_get_backlight;
panel->backlight.hz_to_pwm = vlv_hz_to_pwm;
}
} else if (IS_GEN4(dev_priv)) {
panel->backlight.setup = i965_setup_backlight;
panel->backlight.enable = i965_enable_backlight;
panel->backlight.disable = i965_disable_backlight;
panel->backlight.set = i9xx_set_backlight;
panel->backlight.get = i9xx_get_backlight;
panel->backlight.hz_to_pwm = i965_hz_to_pwm;
} else {
panel->backlight.setup = i9xx_setup_backlight;
panel->backlight.enable = i9xx_enable_backlight;
panel->backlight.disable = i9xx_disable_backlight;
panel->backlight.set = i9xx_set_backlight;
panel->backlight.get = i9xx_get_backlight;
panel->backlight.hz_to_pwm = i9xx_hz_to_pwm;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 377 | 75.10% | 10 | 52.63% |
Shobhit Kumar | 35 | 6.97% | 1 | 5.26% |
Vandana Kannan | 33 | 6.57% | 1 | 5.26% |
Daniel Vetter | 23 | 4.58% | 1 | 5.26% |
Yetunde Adebisi | 18 | 3.59% | 1 | 5.26% |
Rodrigo Vivi | 5 | 1.00% | 1 | 5.26% |
Wayne Boyer | 4 | 0.80% | 1 | 5.26% |
Satheeshakrishna M | 3 | 0.60% | 1 | 5.26% |
Matthew Garrett | 3 | 0.60% | 1 | 5.26% |
Ander Conselvan de Oliveira | 1 | 0.20% | 1 | 5.26% |
Total | 502 | 100.00% | 19 | 100.00% |
int intel_panel_init(struct intel_panel *panel,
struct drm_display_mode *fixed_mode,
struct drm_display_mode *downclock_mode)
{
intel_panel_init_backlight_funcs(panel);
panel->fixed_mode = fixed_mode;
panel->downclock_mode = downclock_mode;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 29 | 72.50% | 3 | 75.00% |
Vandana Kannan | 11 | 27.50% | 1 | 25.00% |
Total | 40 | 100.00% | 4 | 100.00% |
void intel_panel_fini(struct intel_panel *panel)
{
struct intel_connector *intel_connector =
container_of(panel, struct intel_connector, panel);
if (panel->fixed_mode)
drm_mode_destroy(intel_connector->base.dev, panel->fixed_mode);
if (panel->downclock_mode)
drm_mode_destroy(intel_connector->base.dev,
panel->downclock_mode);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 44 | 69.84% | 2 | 66.67% |
Vandana Kannan | 19 | 30.16% | 1 | 33.33% |
Total | 63 | 100.00% | 3 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jani Nikula | 4837 | 55.62% | 45 | 34.62% |
Jesse Barnes | 765 | 8.80% | 6 | 4.62% |
Daniel Vetter | 593 | 6.82% | 8 | 6.15% |
Chris Wilson | 451 | 5.19% | 8 | 6.15% |
Shobhit Kumar | 436 | 5.01% | 1 | 0.77% |
Ville Syrjälä | 406 | 4.67% | 17 | 13.08% |
Vandana Kannan | 389 | 4.47% | 3 | 2.31% |
A.Sunil Kamath | 281 | 3.23% | 1 | 0.77% |
Matthew Garrett | 96 | 1.10% | 1 | 0.77% |
Shawn C Lee | 78 | 0.90% | 1 | 0.77% |
Takashi Iwai | 74 | 0.85% | 2 | 1.54% |
Paulo Zanoni | 48 | 0.55% | 2 | 1.54% |
Carsten Emde | 47 | 0.54% | 2 | 1.54% |
Scot Doyle | 23 | 0.26% | 2 | 1.54% |
Adam Jackson | 18 | 0.21% | 1 | 0.77% |
Yetunde Adebisi | 18 | 0.21% | 1 | 0.77% |
Tvrtko A. Ursulin | 16 | 0.18% | 2 | 1.54% |
Ander Conselvan de Oliveira | 13 | 0.15% | 3 | 2.31% |
Ben Widawsky | 13 | 0.15% | 2 | 1.54% |
Mika Kahola | 13 | 0.15% | 3 | 2.31% |
Boris Brezillon | 10 | 0.11% | 1 | 0.77% |
Vidya Srinivas | 9 | 0.10% | 1 | 0.77% |
Rob Clark | 8 | 0.09% | 1 | 0.77% |
Joe Perches | 7 | 0.08% | 1 | 0.77% |
Imre Deak | 7 | 0.08% | 1 | 0.77% |
Jeremiah Mahler | 6 | 0.07% | 1 | 0.77% |
Keith Packard | 5 | 0.06% | 1 | 0.77% |
Rodrigo Vivi | 5 | 0.06% | 1 | 0.77% |
Wayne Boyer | 4 | 0.05% | 1 | 0.77% |
Corentin Chary | 3 | 0.03% | 1 | 0.77% |
Satheeshakrishna M | 3 | 0.03% | 1 | 0.77% |
Javi Merino | 3 | 0.03% | 1 | 0.77% |
Aaron Lu | 3 | 0.03% | 1 | 0.77% |
Joonas Lahtinen | 2 | 0.02% | 1 | 0.77% |
U. Artie Eoff | 2 | 0.02% | 1 | 0.77% |
Damien Lespiau | 2 | 0.02% | 1 | 0.77% |
Stéphane Marchesin | 1 | 0.01% | 1 | 0.77% |
Dan J Williams | 1 | 0.01% | 1 | 0.77% |
Lukas Wunner | 1 | 0.01% | 1 | 0.77% |
Total | 8697 | 100.00% | 130 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.