2016-12-12 19:29:48 +07:00
|
|
|
/*
|
|
|
|
* Copyright © 2013 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.
|
|
|
|
*
|
|
|
|
* Author: Damien Lespiau <damien.lespiau@intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/circ_buf.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include "intel_drv.h"
|
|
|
|
|
|
|
|
static const char * const pipe_crc_sources[] = {
|
|
|
|
"none",
|
|
|
|
"plane1",
|
|
|
|
"plane2",
|
|
|
|
"pipe",
|
|
|
|
"TV",
|
|
|
|
"DP-B",
|
|
|
|
"DP-C",
|
|
|
|
"DP-D",
|
|
|
|
"auto",
|
|
|
|
};
|
|
|
|
|
|
|
|
static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 *val)
|
2016-12-12 19:29:48 +07:00
|
|
|
{
|
|
|
|
if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
|
|
|
|
*source = INTEL_PIPE_CRC_SOURCE_PIPE;
|
|
|
|
|
|
|
|
switch (*source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
*val = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int i9xx_pipe_crc_auto_source(struct drm_i915_private *dev_priv,
|
|
|
|
enum pipe pipe,
|
|
|
|
enum intel_pipe_crc_source *source)
|
|
|
|
{
|
|
|
|
struct drm_device *dev = &dev_priv->drm;
|
|
|
|
struct intel_encoder *encoder;
|
|
|
|
struct intel_crtc *crtc;
|
|
|
|
struct intel_digital_port *dig_port;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
*source = INTEL_PIPE_CRC_SOURCE_PIPE;
|
|
|
|
|
|
|
|
drm_modeset_lock_all(dev);
|
|
|
|
for_each_intel_encoder(dev, encoder) {
|
|
|
|
if (!encoder->base.crtc)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
crtc = to_intel_crtc(encoder->base.crtc);
|
|
|
|
|
|
|
|
if (crtc->pipe != pipe)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (encoder->type) {
|
|
|
|
case INTEL_OUTPUT_TVOUT:
|
|
|
|
*source = INTEL_PIPE_CRC_SOURCE_TV;
|
|
|
|
break;
|
|
|
|
case INTEL_OUTPUT_DP:
|
|
|
|
case INTEL_OUTPUT_EDP:
|
|
|
|
dig_port = enc_to_dig_port(&encoder->base);
|
2017-11-09 22:24:34 +07:00
|
|
|
switch (dig_port->base.port) {
|
2016-12-12 19:29:48 +07:00
|
|
|
case PORT_B:
|
|
|
|
*source = INTEL_PIPE_CRC_SOURCE_DP_B;
|
|
|
|
break;
|
|
|
|
case PORT_C:
|
|
|
|
*source = INTEL_PIPE_CRC_SOURCE_DP_C;
|
|
|
|
break;
|
|
|
|
case PORT_D:
|
|
|
|
*source = INTEL_PIPE_CRC_SOURCE_DP_D;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN(1, "nonexisting DP port %c\n",
|
2017-11-09 22:24:34 +07:00
|
|
|
port_name(dig_port->base.port));
|
2016-12-12 19:29:48 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drm_modeset_unlock_all(dev);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vlv_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
|
|
|
|
enum pipe pipe,
|
|
|
|
enum intel_pipe_crc_source *source,
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 *val)
|
2016-12-12 19:29:48 +07:00
|
|
|
{
|
|
|
|
bool need_stable_symbols = false;
|
|
|
|
|
|
|
|
if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
|
|
|
|
int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (*source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_B:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_VLV;
|
|
|
|
need_stable_symbols = true;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_C:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_VLV;
|
|
|
|
need_stable_symbols = true;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_D:
|
|
|
|
if (!IS_CHERRYVIEW(dev_priv))
|
|
|
|
return -EINVAL;
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_VLV;
|
|
|
|
need_stable_symbols = true;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
*val = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When the pipe CRC tap point is after the transcoders we need
|
|
|
|
* to tweak symbol-level features to produce a deterministic series of
|
|
|
|
* symbols for a given frame. We need to reset those features only once
|
|
|
|
* a frame (instead of every nth symbol):
|
|
|
|
* - DC-balance: used to ensure a better clock recovery from the data
|
|
|
|
* link (SDVO)
|
|
|
|
* - DisplayPort scrambling: used for EMI reduction
|
|
|
|
*/
|
|
|
|
if (need_stable_symbols) {
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 tmp = I915_READ(PORT_DFT2_G4X);
|
2016-12-12 19:29:48 +07:00
|
|
|
|
|
|
|
tmp |= DC_BALANCE_RESET_VLV;
|
|
|
|
switch (pipe) {
|
|
|
|
case PIPE_A:
|
|
|
|
tmp |= PIPE_A_SCRAMBLE_RESET;
|
|
|
|
break;
|
|
|
|
case PIPE_B:
|
|
|
|
tmp |= PIPE_B_SCRAMBLE_RESET;
|
|
|
|
break;
|
|
|
|
case PIPE_C:
|
|
|
|
tmp |= PIPE_C_SCRAMBLE_RESET;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
I915_WRITE(PORT_DFT2_G4X, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int i9xx_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
|
|
|
|
enum pipe pipe,
|
|
|
|
enum intel_pipe_crc_source *source,
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 *val)
|
2016-12-12 19:29:48 +07:00
|
|
|
{
|
|
|
|
bool need_stable_symbols = false;
|
|
|
|
|
|
|
|
if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
|
|
|
|
int ret = i9xx_pipe_crc_auto_source(dev_priv, pipe, source);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (*source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_TV:
|
|
|
|
if (!SUPPORTS_TV(dev_priv))
|
|
|
|
return -EINVAL;
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_TV_PRE;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_B:
|
|
|
|
if (!IS_G4X(dev_priv))
|
|
|
|
return -EINVAL;
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_B_G4X;
|
|
|
|
need_stable_symbols = true;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_C:
|
|
|
|
if (!IS_G4X(dev_priv))
|
|
|
|
return -EINVAL;
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_C_G4X;
|
|
|
|
need_stable_symbols = true;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_D:
|
|
|
|
if (!IS_G4X(dev_priv))
|
|
|
|
return -EINVAL;
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_DP_D_G4X;
|
|
|
|
need_stable_symbols = true;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
*val = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When the pipe CRC tap point is after the transcoders we need
|
|
|
|
* to tweak symbol-level features to produce a deterministic series of
|
|
|
|
* symbols for a given frame. We need to reset those features only once
|
|
|
|
* a frame (instead of every nth symbol):
|
|
|
|
* - DC-balance: used to ensure a better clock recovery from the data
|
|
|
|
* link (SDVO)
|
|
|
|
* - DisplayPort scrambling: used for EMI reduction
|
|
|
|
*/
|
|
|
|
if (need_stable_symbols) {
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 tmp = I915_READ(PORT_DFT2_G4X);
|
2016-12-12 19:29:48 +07:00
|
|
|
|
|
|
|
WARN_ON(!IS_G4X(dev_priv));
|
|
|
|
|
|
|
|
I915_WRITE(PORT_DFT_I9XX,
|
|
|
|
I915_READ(PORT_DFT_I9XX) | DC_BALANCE_RESET);
|
|
|
|
|
|
|
|
if (pipe == PIPE_A)
|
|
|
|
tmp |= PIPE_A_SCRAMBLE_RESET;
|
|
|
|
else
|
|
|
|
tmp |= PIPE_B_SCRAMBLE_RESET;
|
|
|
|
|
|
|
|
I915_WRITE(PORT_DFT2_G4X, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vlv_undo_pipe_scramble_reset(struct drm_i915_private *dev_priv,
|
|
|
|
enum pipe pipe)
|
|
|
|
{
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 tmp = I915_READ(PORT_DFT2_G4X);
|
2016-12-12 19:29:48 +07:00
|
|
|
|
|
|
|
switch (pipe) {
|
|
|
|
case PIPE_A:
|
|
|
|
tmp &= ~PIPE_A_SCRAMBLE_RESET;
|
|
|
|
break;
|
|
|
|
case PIPE_B:
|
|
|
|
tmp &= ~PIPE_B_SCRAMBLE_RESET;
|
|
|
|
break;
|
|
|
|
case PIPE_C:
|
|
|
|
tmp &= ~PIPE_C_SCRAMBLE_RESET;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(tmp & PIPE_SCRAMBLE_RESET_MASK))
|
|
|
|
tmp &= ~DC_BALANCE_RESET_VLV;
|
|
|
|
I915_WRITE(PORT_DFT2_G4X, tmp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void g4x_undo_pipe_scramble_reset(struct drm_i915_private *dev_priv,
|
|
|
|
enum pipe pipe)
|
|
|
|
{
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 tmp = I915_READ(PORT_DFT2_G4X);
|
2016-12-12 19:29:48 +07:00
|
|
|
|
|
|
|
if (pipe == PIPE_A)
|
|
|
|
tmp &= ~PIPE_A_SCRAMBLE_RESET;
|
|
|
|
else
|
|
|
|
tmp &= ~PIPE_B_SCRAMBLE_RESET;
|
|
|
|
I915_WRITE(PORT_DFT2_G4X, tmp);
|
|
|
|
|
|
|
|
if (!(tmp & PIPE_SCRAMBLE_RESET_MASK)) {
|
|
|
|
I915_WRITE(PORT_DFT_I9XX,
|
|
|
|
I915_READ(PORT_DFT_I9XX) & ~DC_BALANCE_RESET);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 *val)
|
2016-12-12 19:29:48 +07:00
|
|
|
{
|
|
|
|
if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
|
|
|
|
*source = INTEL_PIPE_CRC_SOURCE_PIPE;
|
|
|
|
|
|
|
|
switch (*source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PLANE1:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PLANE2:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_ILK;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_ILK;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
*val = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-17 21:55:09 +07:00
|
|
|
static void hsw_pipe_A_crc_wa(struct drm_i915_private *dev_priv,
|
|
|
|
bool enable)
|
2016-12-12 19:29:48 +07:00
|
|
|
{
|
|
|
|
struct drm_device *dev = &dev_priv->drm;
|
|
|
|
struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, PIPE_A);
|
|
|
|
struct intel_crtc_state *pipe_config;
|
|
|
|
struct drm_atomic_state *state;
|
2017-04-04 20:24:57 +07:00
|
|
|
struct drm_modeset_acquire_ctx ctx;
|
2016-12-12 19:29:48 +07:00
|
|
|
int ret = 0;
|
|
|
|
|
2017-04-04 20:24:57 +07:00
|
|
|
drm_modeset_acquire_init(&ctx, 0);
|
|
|
|
|
2016-12-12 19:29:48 +07:00
|
|
|
state = drm_atomic_state_alloc(dev);
|
|
|
|
if (!state) {
|
|
|
|
ret = -ENOMEM;
|
2017-01-18 19:34:28 +07:00
|
|
|
goto unlock;
|
2016-12-12 19:29:48 +07:00
|
|
|
}
|
|
|
|
|
2017-04-04 20:24:57 +07:00
|
|
|
state->acquire_ctx = &ctx;
|
|
|
|
|
|
|
|
retry:
|
2016-12-12 19:29:48 +07:00
|
|
|
pipe_config = intel_atomic_get_crtc_state(state, crtc);
|
|
|
|
if (IS_ERR(pipe_config)) {
|
|
|
|
ret = PTR_ERR(pipe_config);
|
2017-01-18 19:34:28 +07:00
|
|
|
goto put_state;
|
2016-12-12 19:29:48 +07:00
|
|
|
}
|
|
|
|
|
2017-08-17 21:55:09 +07:00
|
|
|
if (HAS_IPS(dev_priv)) {
|
|
|
|
/*
|
|
|
|
* When IPS gets enabled, the pipe CRC changes. Since IPS gets
|
|
|
|
* enabled and disabled dynamically based on package C states,
|
|
|
|
* user space can't make reliable use of the CRCs, so let's just
|
|
|
|
* completely disable it.
|
|
|
|
*/
|
|
|
|
pipe_config->ips_force_disable = enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IS_HASWELL(dev_priv)) {
|
|
|
|
pipe_config->pch_pfit.force_thru = enable;
|
|
|
|
if (pipe_config->cpu_transcoder == TRANSCODER_EDP &&
|
|
|
|
pipe_config->pch_pfit.enabled != enable)
|
|
|
|
pipe_config->base.connectors_changed = true;
|
|
|
|
}
|
2016-12-12 19:29:48 +07:00
|
|
|
|
|
|
|
ret = drm_atomic_commit(state);
|
2017-01-18 19:34:28 +07:00
|
|
|
|
|
|
|
put_state:
|
2017-04-04 20:24:57 +07:00
|
|
|
if (ret == -EDEADLK) {
|
|
|
|
drm_atomic_state_clear(state);
|
|
|
|
drm_modeset_backoff(&ctx);
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2017-01-18 19:34:28 +07:00
|
|
|
drm_atomic_state_put(state);
|
|
|
|
unlock:
|
2016-12-12 19:29:48 +07:00
|
|
|
WARN(ret, "Toggling workaround to %i returns %i\n", enable, ret);
|
2017-04-04 20:24:57 +07:00
|
|
|
drm_modeset_drop_locks(&ctx);
|
|
|
|
drm_modeset_acquire_fini(&ctx);
|
2016-12-12 19:29:48 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ivb_pipe_crc_ctl_reg(struct drm_i915_private *dev_priv,
|
|
|
|
enum pipe pipe,
|
|
|
|
enum intel_pipe_crc_source *source,
|
2019-01-16 16:15:19 +07:00
|
|
|
u32 *val,
|
2018-03-08 19:02:02 +07:00
|
|
|
bool set_wa)
|
2016-12-12 19:29:48 +07:00
|
|
|
{
|
|
|
|
if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
|
2019-02-15 02:22:16 +07:00
|
|
|
*source = INTEL_PIPE_CRC_SOURCE_PIPE;
|
2016-12-12 19:29:48 +07:00
|
|
|
|
|
|
|
switch (*source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PLANE1:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PLANE2:
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_SPRITE_IVB;
|
|
|
|
break;
|
2019-02-15 02:22:16 +07:00
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
2018-03-08 19:02:02 +07:00
|
|
|
if (set_wa && (IS_HASWELL(dev_priv) ||
|
2017-08-17 21:55:09 +07:00
|
|
|
IS_BROADWELL(dev_priv)) && pipe == PIPE_A)
|
|
|
|
hsw_pipe_A_crc_wa(dev_priv, true);
|
2016-12-12 19:29:48 +07:00
|
|
|
|
|
|
|
*val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PF_IVB;
|
|
|
|
break;
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
*val = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-01-10 20:43:04 +07:00
|
|
|
static int get_new_crc_ctl_reg(struct drm_i915_private *dev_priv,
|
|
|
|
enum pipe pipe,
|
2018-03-08 19:02:02 +07:00
|
|
|
enum intel_pipe_crc_source *source, u32 *val,
|
|
|
|
bool set_wa)
|
2017-01-10 20:43:04 +07:00
|
|
|
{
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-13 01:10:43 +07:00
|
|
|
if (IS_GEN(dev_priv, 2))
|
2017-01-10 20:43:04 +07:00
|
|
|
return i8xx_pipe_crc_ctl_reg(source, val);
|
|
|
|
else if (INTEL_GEN(dev_priv) < 5)
|
|
|
|
return i9xx_pipe_crc_ctl_reg(dev_priv, pipe, source, val);
|
|
|
|
else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
|
|
|
|
return vlv_pipe_crc_ctl_reg(dev_priv, pipe, source, val);
|
drm/i915: merge gen checks to use range
Instead of using IS_GEN() for consecutive gen checks, let's pass the
range to IS_GEN_RANGE(). By code inspection these were the ranges deemed
necessary for spatch:
@@
expression e;
@@
(
- IS_GEN(e, 3) || IS_GEN(e, 2)
+ IS_GEN_RANGE(e, 2, 3)
|
- IS_GEN(e, 3) || IS_GEN(e, 4)
+ IS_GEN_RANGE(e, 3, 4)
|
- IS_GEN(e, 5) || IS_GEN(e, 6)
+ IS_GEN_RANGE(e, 5, 6)
|
- IS_GEN(e, 6) || IS_GEN(e, 7)
+ IS_GEN_RANGE(e, 6, 7)
|
- IS_GEN(e, 7) || IS_GEN(e, 8)
+ IS_GEN_RANGE(e, 7, 8)
|
- IS_GEN(e, 8) || IS_GEN(e, 9)
+ IS_GEN_RANGE(e, 8, 9)
|
- IS_GEN(e, 10) || IS_GEN(e, 9)
+ IS_GEN_RANGE(e, 9, 10)
|
- IS_GEN(e, 9) || IS_GEN(e, 10)
+ IS_GEN_RANGE(e, 9, 10)
)
After conversion, checking we don't have any missing IS_GEN_RANGE() ||
IS_GEN() was also done.
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-3-lucas.demarchi@intel.com
2018-12-13 01:10:44 +07:00
|
|
|
else if (IS_GEN_RANGE(dev_priv, 5, 6))
|
2017-01-10 20:43:04 +07:00
|
|
|
return ilk_pipe_crc_ctl_reg(source, val);
|
|
|
|
else
|
2018-03-08 19:02:02 +07:00
|
|
|
return ivb_pipe_crc_ctl_reg(dev_priv, pipe, source, val, set_wa);
|
2017-01-10 20:43:04 +07:00
|
|
|
}
|
|
|
|
|
2016-12-12 19:29:48 +07:00
|
|
|
static int
|
|
|
|
display_crc_ctl_parse_source(const char *buf, enum intel_pipe_crc_source *s)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2017-01-10 20:43:04 +07:00
|
|
|
if (!buf) {
|
|
|
|
*s = INTEL_PIPE_CRC_SOURCE_NONE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-05-04 01:17:06 +07:00
|
|
|
i = match_string(pipe_crc_sources, ARRAY_SIZE(pipe_crc_sources), buf);
|
|
|
|
if (i < 0)
|
|
|
|
return i;
|
2016-12-12 19:29:48 +07:00
|
|
|
|
2018-05-04 01:17:06 +07:00
|
|
|
*s = i;
|
|
|
|
return 0;
|
2016-12-12 19:29:48 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void intel_display_crc_init(struct drm_i915_private *dev_priv)
|
|
|
|
{
|
|
|
|
enum pipe pipe;
|
|
|
|
|
|
|
|
for_each_pipe(dev_priv, pipe) {
|
|
|
|
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
|
|
|
|
|
|
|
|
spin_lock_init(&pipe_crc->lock);
|
|
|
|
}
|
|
|
|
}
|
2017-01-10 20:43:04 +07:00
|
|
|
|
2018-07-13 20:59:38 +07:00
|
|
|
static int i8xx_crc_source_valid(struct drm_i915_private *dev_priv,
|
|
|
|
const enum intel_pipe_crc_source source)
|
|
|
|
{
|
|
|
|
switch (source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int i9xx_crc_source_valid(struct drm_i915_private *dev_priv,
|
|
|
|
const enum intel_pipe_crc_source source)
|
|
|
|
{
|
|
|
|
switch (source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_TV:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_B:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_C:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_D:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vlv_crc_source_valid(struct drm_i915_private *dev_priv,
|
|
|
|
const enum intel_pipe_crc_source source)
|
|
|
|
{
|
|
|
|
switch (source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_B:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_C:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_DP_D:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ilk_crc_source_valid(struct drm_i915_private *dev_priv,
|
|
|
|
const enum intel_pipe_crc_source source)
|
|
|
|
{
|
|
|
|
switch (source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PLANE1:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PLANE2:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ivb_crc_source_valid(struct drm_i915_private *dev_priv,
|
|
|
|
const enum intel_pipe_crc_source source)
|
|
|
|
{
|
|
|
|
switch (source) {
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PIPE:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PLANE1:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_PLANE2:
|
|
|
|
case INTEL_PIPE_CRC_SOURCE_NONE:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
intel_is_valid_crc_source(struct drm_i915_private *dev_priv,
|
|
|
|
const enum intel_pipe_crc_source source)
|
|
|
|
{
|
drm/i915: replace IS_GEN<N> with IS_GEN(..., N)
Define IS_GEN() similarly to our IS_GEN_RANGE(). but use gen instead of
gen_mask to do the comparison. Now callers can pass then gen as a parameter,
so we don't require one macro for each gen.
The following spatch was used to convert the users of these macros:
@@
expression e;
@@
(
- IS_GEN2(e)
+ IS_GEN(e, 2)
|
- IS_GEN3(e)
+ IS_GEN(e, 3)
|
- IS_GEN4(e)
+ IS_GEN(e, 4)
|
- IS_GEN5(e)
+ IS_GEN(e, 5)
|
- IS_GEN6(e)
+ IS_GEN(e, 6)
|
- IS_GEN7(e)
+ IS_GEN(e, 7)
|
- IS_GEN8(e)
+ IS_GEN(e, 8)
|
- IS_GEN9(e)
+ IS_GEN(e, 9)
|
- IS_GEN10(e)
+ IS_GEN(e, 10)
|
- IS_GEN11(e)
+ IS_GEN(e, 11)
)
v2: use IS_GEN rather than GT_GEN and compare to info.gen rather than
using the bitmask
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-2-lucas.demarchi@intel.com
2018-12-13 01:10:43 +07:00
|
|
|
if (IS_GEN(dev_priv, 2))
|
2018-07-13 20:59:38 +07:00
|
|
|
return i8xx_crc_source_valid(dev_priv, source);
|
|
|
|
else if (INTEL_GEN(dev_priv) < 5)
|
|
|
|
return i9xx_crc_source_valid(dev_priv, source);
|
|
|
|
else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
|
|
|
|
return vlv_crc_source_valid(dev_priv, source);
|
drm/i915: merge gen checks to use range
Instead of using IS_GEN() for consecutive gen checks, let's pass the
range to IS_GEN_RANGE(). By code inspection these were the ranges deemed
necessary for spatch:
@@
expression e;
@@
(
- IS_GEN(e, 3) || IS_GEN(e, 2)
+ IS_GEN_RANGE(e, 2, 3)
|
- IS_GEN(e, 3) || IS_GEN(e, 4)
+ IS_GEN_RANGE(e, 3, 4)
|
- IS_GEN(e, 5) || IS_GEN(e, 6)
+ IS_GEN_RANGE(e, 5, 6)
|
- IS_GEN(e, 6) || IS_GEN(e, 7)
+ IS_GEN_RANGE(e, 6, 7)
|
- IS_GEN(e, 7) || IS_GEN(e, 8)
+ IS_GEN_RANGE(e, 7, 8)
|
- IS_GEN(e, 8) || IS_GEN(e, 9)
+ IS_GEN_RANGE(e, 8, 9)
|
- IS_GEN(e, 10) || IS_GEN(e, 9)
+ IS_GEN_RANGE(e, 9, 10)
|
- IS_GEN(e, 9) || IS_GEN(e, 10)
+ IS_GEN_RANGE(e, 9, 10)
)
After conversion, checking we don't have any missing IS_GEN_RANGE() ||
IS_GEN() was also done.
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181212181044.15886-3-lucas.demarchi@intel.com
2018-12-13 01:10:44 +07:00
|
|
|
else if (IS_GEN_RANGE(dev_priv, 5, 6))
|
2018-07-13 20:59:38 +07:00
|
|
|
return ilk_crc_source_valid(dev_priv, source);
|
|
|
|
else
|
|
|
|
return ivb_crc_source_valid(dev_priv, source);
|
|
|
|
}
|
|
|
|
|
2018-07-13 20:59:39 +07:00
|
|
|
const char *const *intel_crtc_get_crc_sources(struct drm_crtc *crtc,
|
|
|
|
size_t *count)
|
|
|
|
{
|
|
|
|
*count = ARRAY_SIZE(pipe_crc_sources);
|
|
|
|
return pipe_crc_sources;
|
|
|
|
}
|
|
|
|
|
2018-07-13 20:59:38 +07:00
|
|
|
int intel_crtc_verify_crc_source(struct drm_crtc *crtc, const char *source_name,
|
|
|
|
size_t *values_cnt)
|
|
|
|
{
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->dev);
|
|
|
|
enum intel_pipe_crc_source source;
|
|
|
|
|
|
|
|
if (display_crc_ctl_parse_source(source_name, &source) < 0) {
|
|
|
|
DRM_DEBUG_DRIVER("unknown source %s\n", source_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (source == INTEL_PIPE_CRC_SOURCE_AUTO ||
|
|
|
|
intel_is_valid_crc_source(dev_priv, source) == 0) {
|
|
|
|
*values_cnt = 5;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2018-08-21 15:38:56 +07:00
|
|
|
int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name)
|
2017-01-10 20:43:04 +07:00
|
|
|
{
|
2018-03-08 19:02:02 +07:00
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->dev);
|
2017-01-10 20:43:04 +07:00
|
|
|
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index];
|
|
|
|
enum intel_display_power_domain power_domain;
|
|
|
|
enum intel_pipe_crc_source source;
|
2019-01-14 21:21:24 +07:00
|
|
|
intel_wakeref_t wakeref;
|
2017-01-10 20:43:04 +07:00
|
|
|
u32 val = 0; /* shut up gcc */
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (display_crc_ctl_parse_source(source_name, &source) < 0) {
|
|
|
|
DRM_DEBUG_DRIVER("unknown source %s\n", source_name);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
power_domain = POWER_DOMAIN_PIPE(crtc->index);
|
2019-01-14 21:21:24 +07:00
|
|
|
wakeref = intel_display_power_get_if_enabled(dev_priv, power_domain);
|
|
|
|
if (!wakeref) {
|
2017-01-10 20:43:04 +07:00
|
|
|
DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2018-03-08 19:02:02 +07:00
|
|
|
ret = get_new_crc_ctl_reg(dev_priv, crtc->index, &source, &val, true);
|
2017-01-10 20:43:04 +07:00
|
|
|
if (ret != 0)
|
|
|
|
goto out;
|
|
|
|
|
2018-03-08 19:02:02 +07:00
|
|
|
pipe_crc->source = source;
|
2017-01-10 20:43:04 +07:00
|
|
|
I915_WRITE(PIPE_CRC_CTL(crtc->index), val);
|
|
|
|
POSTING_READ(PIPE_CRC_CTL(crtc->index));
|
|
|
|
|
|
|
|
if (!source) {
|
|
|
|
if (IS_G4X(dev_priv))
|
|
|
|
g4x_undo_pipe_scramble_reset(dev_priv, crtc->index);
|
|
|
|
else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
|
|
|
|
vlv_undo_pipe_scramble_reset(dev_priv, crtc->index);
|
2017-08-17 21:55:09 +07:00
|
|
|
else if ((IS_HASWELL(dev_priv) ||
|
|
|
|
IS_BROADWELL(dev_priv)) && crtc->index == PIPE_A)
|
|
|
|
hsw_pipe_A_crc_wa(dev_priv, false);
|
2017-01-10 20:43:04 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
pipe_crc->skipped = 0;
|
|
|
|
|
|
|
|
out:
|
2019-01-14 21:21:24 +07:00
|
|
|
intel_display_power_put(dev_priv, power_domain, wakeref);
|
2017-01-10 20:43:04 +07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2018-03-08 19:02:02 +07:00
|
|
|
|
|
|
|
void intel_crtc_enable_pipe_crc(struct intel_crtc *intel_crtc)
|
|
|
|
{
|
|
|
|
struct drm_crtc *crtc = &intel_crtc->base;
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->dev);
|
|
|
|
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index];
|
|
|
|
u32 val = 0;
|
|
|
|
|
|
|
|
if (!crtc->crc.opened)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (get_new_crc_ctl_reg(dev_priv, crtc->index, &pipe_crc->source, &val, false) < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Don't need pipe_crc->lock here, IRQs are not generated. */
|
|
|
|
pipe_crc->skipped = 0;
|
|
|
|
|
|
|
|
I915_WRITE(PIPE_CRC_CTL(crtc->index), val);
|
|
|
|
POSTING_READ(PIPE_CRC_CTL(crtc->index));
|
|
|
|
}
|
|
|
|
|
|
|
|
void intel_crtc_disable_pipe_crc(struct intel_crtc *intel_crtc)
|
|
|
|
{
|
|
|
|
struct drm_crtc *crtc = &intel_crtc->base;
|
|
|
|
struct drm_i915_private *dev_priv = to_i915(crtc->dev);
|
|
|
|
struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[crtc->index];
|
|
|
|
|
|
|
|
/* Swallow crc's until we stop generating them. */
|
|
|
|
spin_lock_irq(&pipe_crc->lock);
|
|
|
|
pipe_crc->skipped = INT_MIN;
|
|
|
|
spin_unlock_irq(&pipe_crc->lock);
|
|
|
|
|
|
|
|
I915_WRITE(PIPE_CRC_CTL(crtc->index), 0);
|
|
|
|
POSTING_READ(PIPE_CRC_CTL(crtc->index));
|
|
|
|
synchronize_irq(dev_priv->drm.irq);
|
|
|
|
}
|