aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-11-01 05:50:20 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-11-01 13:16:27 -0400
commit46a19188171179ba2d84e6de803ce7b1c54da474 (patch)
tree9d616d87c762c586ea7eabde04c827c331f9b196
parent9f08ef59a6f71249de8b4e8a26c27075b9e99f9c (diff)
drm/i916: add "auto" pipe CRC source
On gmch platforms the normal pipe source CRC registers don't work for DP and TV encoders. And on newer platforms the single pipe CRC has been replaced by a set of CRC at different stages in the platform. Now most of our userspace tests don't care one bit about the exact CRC, they simply want something that reflects any changes on the screen. Hence add a new auto target for platform agnostic tests to use. v2: Pass back the adjusted source so that it can be shown in debugfs. v3: I seem to be unable to get a stable CRC for DP ports. So let's just disable them for now when using the auto mode. Note that testcases need to be restructured so that they can dynamically skip connectors. They also first need to set up the desired mode configuration, since otherwise the auto mode won't do the right thing. v4: Don't leak the modeset mutex on error paths. v5: Spelling fix for the i9xx auto_source function. Cc: Damien Lespiau <damien.lespiau@intel.com> Reviewed-by: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c91
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h1
2 files changed, 77 insertions, 15 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 5c45e9e598de..7c29a8827177 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -1936,6 +1936,7 @@ static const char * const pipe_crc_sources[] = {
1936 "DP-B", 1936 "DP-B",
1937 "DP-C", 1937 "DP-C",
1938 "DP-D", 1938 "DP-D",
1939 "auto",
1939}; 1940};
1940 1941
1941static const char *pipe_crc_source_name(enum intel_pipe_crc_source source) 1942static const char *pipe_crc_source_name(enum intel_pipe_crc_source source)
@@ -1964,10 +1965,13 @@ static int display_crc_ctl_open(struct inode *inode, struct file *file)
1964 return single_open(file, display_crc_ctl_show, dev); 1965 return single_open(file, display_crc_ctl_show, dev);
1965} 1966}
1966 1967
1967static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source source, 1968static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
1968 uint32_t *val) 1969 uint32_t *val)
1969{ 1970{
1970 switch (source) { 1971 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
1972 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
1973
1974 switch (*source) {
1971 case INTEL_PIPE_CRC_SOURCE_PIPE: 1975 case INTEL_PIPE_CRC_SOURCE_PIPE:
1972 *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX; 1976 *val = PIPE_CRC_ENABLE | PIPE_CRC_INCLUDE_BORDER_I8XX;
1973 break; 1977 break;
@@ -1981,10 +1985,54 @@ static int i8xx_pipe_crc_ctl_reg(enum intel_pipe_crc_source source,
1981 return 0; 1985 return 0;
1982} 1986}
1983 1987
1984static int vlv_pipe_crc_ctl_reg(enum intel_pipe_crc_source source, 1988static int i9xx_pipe_crc_auto_source(struct drm_device *dev, enum pipe pipe,
1989 enum intel_pipe_crc_source *source)
1990{
1991 struct intel_encoder *encoder;
1992 struct intel_crtc *crtc;
1993 int ret = 0;
1994
1995 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
1996
1997 mutex_lock(&dev->mode_config.mutex);
1998 list_for_each_entry(encoder, &dev->mode_config.encoder_list,
1999 base.head) {
2000 if (!encoder->base.crtc)
2001 continue;
2002
2003 crtc = to_intel_crtc(encoder->base.crtc);
2004
2005 if (crtc->pipe != pipe)
2006 continue;
2007
2008 switch (encoder->type) {
2009 case INTEL_OUTPUT_TVOUT:
2010 *source = INTEL_PIPE_CRC_SOURCE_TV;
2011 break;
2012 case INTEL_OUTPUT_DISPLAYPORT:
2013 case INTEL_OUTPUT_EDP:
2014 /* We can't get stable CRCs for DP ports somehow. */
2015 ret = -ENODEV;
2016 break;
2017 }
2018 }
2019 mutex_unlock(&dev->mode_config.mutex);
2020
2021 return ret;
2022}
2023
2024static int vlv_pipe_crc_ctl_reg(struct drm_device *dev,
2025 enum pipe pipe,
2026 enum intel_pipe_crc_source *source,
1985 uint32_t *val) 2027 uint32_t *val)
1986{ 2028{
1987 switch (source) { 2029 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
2030 int ret = i9xx_pipe_crc_auto_source(dev, pipe, source);
2031 if (ret)
2032 return ret;
2033 }
2034
2035 switch (*source) {
1988 case INTEL_PIPE_CRC_SOURCE_PIPE: 2036 case INTEL_PIPE_CRC_SOURCE_PIPE:
1989 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV; 2037 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_VLV;
1990 break; 2038 break;
@@ -2005,10 +2053,17 @@ static int vlv_pipe_crc_ctl_reg(enum intel_pipe_crc_source source,
2005} 2053}
2006 2054
2007static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev, 2055static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev,
2008 enum intel_pipe_crc_source source, 2056 enum pipe pipe,
2057 enum intel_pipe_crc_source *source,
2009 uint32_t *val) 2058 uint32_t *val)
2010{ 2059{
2011 switch (source) { 2060 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO) {
2061 int ret = i9xx_pipe_crc_auto_source(dev, pipe, source);
2062 if (ret)
2063 return ret;
2064 }
2065
2066 switch (*source) {
2012 case INTEL_PIPE_CRC_SOURCE_PIPE: 2067 case INTEL_PIPE_CRC_SOURCE_PIPE:
2013 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX; 2068 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PIPE_I9XX;
2014 break; 2069 break;
@@ -2042,10 +2097,13 @@ static int i9xx_pipe_crc_ctl_reg(struct drm_device *dev,
2042 return 0; 2097 return 0;
2043} 2098}
2044 2099
2045static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source source, 2100static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
2046 uint32_t *val) 2101 uint32_t *val)
2047{ 2102{
2048 switch (source) { 2103 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
2104 *source = INTEL_PIPE_CRC_SOURCE_PIPE;
2105
2106 switch (*source) {
2049 case INTEL_PIPE_CRC_SOURCE_PLANE1: 2107 case INTEL_PIPE_CRC_SOURCE_PLANE1:
2050 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK; 2108 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_ILK;
2051 break; 2109 break;
@@ -2065,10 +2123,13 @@ static int ilk_pipe_crc_ctl_reg(enum intel_pipe_crc_source source,
2065 return 0; 2123 return 0;
2066} 2124}
2067 2125
2068static int ivb_pipe_crc_ctl_reg(enum intel_pipe_crc_source source, 2126static int ivb_pipe_crc_ctl_reg(enum intel_pipe_crc_source *source,
2069 uint32_t *val) 2127 uint32_t *val)
2070{ 2128{
2071 switch (source) { 2129 if (*source == INTEL_PIPE_CRC_SOURCE_AUTO)
2130 *source = INTEL_PIPE_CRC_SOURCE_PF;
2131
2132 switch (*source) {
2072 case INTEL_PIPE_CRC_SOURCE_PLANE1: 2133 case INTEL_PIPE_CRC_SOURCE_PLANE1:
2073 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB; 2134 *val = PIPE_CRC_ENABLE | PIPE_CRC_SOURCE_PRIMARY_IVB;
2074 break; 2135 break;
@@ -2104,15 +2165,15 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
2104 return -EINVAL; 2165 return -EINVAL;
2105 2166
2106 if (IS_GEN2(dev)) 2167 if (IS_GEN2(dev))
2107 ret = i8xx_pipe_crc_ctl_reg(source, &val); 2168 ret = i8xx_pipe_crc_ctl_reg(&source, &val);
2108 else if (INTEL_INFO(dev)->gen < 5) 2169 else if (INTEL_INFO(dev)->gen < 5)
2109 ret = i9xx_pipe_crc_ctl_reg(dev, source, &val); 2170 ret = i9xx_pipe_crc_ctl_reg(dev, pipe, &source, &val);
2110 else if (IS_VALLEYVIEW(dev)) 2171 else if (IS_VALLEYVIEW(dev))
2111 ret = vlv_pipe_crc_ctl_reg(source, &val); 2172 ret = vlv_pipe_crc_ctl_reg(dev,pipe, &source, &val);
2112 else if (IS_GEN5(dev) || IS_GEN6(dev)) 2173 else if (IS_GEN5(dev) || IS_GEN6(dev))
2113 ret = ilk_pipe_crc_ctl_reg(source, &val); 2174 ret = ilk_pipe_crc_ctl_reg(&source, &val);
2114 else 2175 else
2115 ret = ivb_pipe_crc_ctl_reg(source, &val); 2176 ret = ivb_pipe_crc_ctl_reg(&source, &val);
2116 2177
2117 if (ret != 0) 2178 if (ret != 0)
2118 return ret; 2179 return ret;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 0a886fd24936..f2324bc46800 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1251,6 +1251,7 @@ enum intel_pipe_crc_source {
1251 INTEL_PIPE_CRC_SOURCE_DP_B, 1251 INTEL_PIPE_CRC_SOURCE_DP_B,
1252 INTEL_PIPE_CRC_SOURCE_DP_C, 1252 INTEL_PIPE_CRC_SOURCE_DP_C,
1253 INTEL_PIPE_CRC_SOURCE_DP_D, 1253 INTEL_PIPE_CRC_SOURCE_DP_D,
1254 INTEL_PIPE_CRC_SOURCE_AUTO,
1254 INTEL_PIPE_CRC_SOURCE_MAX, 1255 INTEL_PIPE_CRC_SOURCE_MAX,
1255}; 1256};
1256 1257