Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/scdc-helper: Pimp SCDC debugs

Include the device and connector information in the SCDC
debugs. Makes it easier to figure out who did what.

v2: Rely on connector->ddc (Maxime)

Cc: Andrzej Hajda <andrzej.hajda@intel.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Robert Foss <rfoss@kernel.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Jonas Karlman <jonas@kwiboo.se>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Emma Anholt <emma@anholt.net>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: intel-gfx@lists.freedesktop.org
Cc: linux-tegra@vger.kernel.org
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230403223652.18848-1-ville.syrjala@linux.intel.com
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Acked-by: Thierry Reding <treding@nvidia.com>

+59 -50
+4 -4
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
··· 1426 1426 /* Control for TMDS Bit Period/TMDS Clock-Period Ratio */ 1427 1427 if (dw_hdmi_support_scdc(hdmi, display)) { 1428 1428 if (mtmdsclock > HDMI14_MAX_TMDSCLK) 1429 - drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 1); 1429 + drm_scdc_set_high_tmds_clock_ratio(&hdmi->connector, 1); 1430 1430 else 1431 - drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 0); 1431 + drm_scdc_set_high_tmds_clock_ratio(&hdmi->connector, 0); 1432 1432 } 1433 1433 } 1434 1434 EXPORT_SYMBOL_GPL(dw_hdmi_set_high_tmds_clock_ratio); ··· 2116 2116 min_t(u8, bytes, SCDC_MIN_SOURCE_VERSION)); 2117 2117 2118 2118 /* Enabled Scrambling in the Sink */ 2119 - drm_scdc_set_scrambling(hdmi->ddc, 1); 2119 + drm_scdc_set_scrambling(&hdmi->connector, 1); 2120 2120 2121 2121 /* 2122 2122 * To activate the scrambler feature, you must ensure ··· 2132 2132 hdmi_writeb(hdmi, 0, HDMI_FC_SCRAMBLER_CTRL); 2133 2133 hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, 2134 2134 HDMI_MC_SWRSTZ); 2135 - drm_scdc_set_scrambling(hdmi->ddc, 0); 2135 + drm_scdc_set_scrambling(&hdmi->connector, 0); 2136 2136 } 2137 2137 } 2138 2138
+30 -16
drivers/gpu/drm/display/drm_scdc_helper.c
··· 26 26 #include <linux/delay.h> 27 27 28 28 #include <drm/display/drm_scdc_helper.h> 29 + #include <drm/drm_connector.h> 30 + #include <drm/drm_device.h> 29 31 #include <drm/drm_print.h> 30 32 31 33 /** ··· 142 140 143 141 /** 144 142 * drm_scdc_get_scrambling_status - what is status of scrambling? 145 - * @adapter: I2C adapter for DDC channel 143 + * @connector: connector 146 144 * 147 145 * Reads the scrambler status over SCDC, and checks the 148 146 * scrambling status. ··· 150 148 * Returns: 151 149 * True if the scrambling is enabled, false otherwise. 152 150 */ 153 - bool drm_scdc_get_scrambling_status(struct i2c_adapter *adapter) 151 + bool drm_scdc_get_scrambling_status(struct drm_connector *connector) 154 152 { 155 153 u8 status; 156 154 int ret; 157 155 158 - ret = drm_scdc_readb(adapter, SCDC_SCRAMBLER_STATUS, &status); 156 + ret = drm_scdc_readb(connector->ddc, SCDC_SCRAMBLER_STATUS, &status); 159 157 if (ret < 0) { 160 - DRM_DEBUG_KMS("Failed to read scrambling status: %d\n", ret); 158 + drm_dbg_kms(connector->dev, 159 + "[CONNECTOR:%d:%s] Failed to read scrambling status: %d\n", 160 + connector->base.id, connector->name, ret); 161 161 return false; 162 162 } 163 163 ··· 169 165 170 166 /** 171 167 * drm_scdc_set_scrambling - enable scrambling 172 - * @adapter: I2C adapter for DDC channel 168 + * @connector: connector 173 169 * @enable: bool to indicate if scrambling is to be enabled/disabled 174 170 * 175 171 * Writes the TMDS config register over SCDC channel, and: ··· 179 175 * Returns: 180 176 * True if scrambling is set/reset successfully, false otherwise. 181 177 */ 182 - bool drm_scdc_set_scrambling(struct i2c_adapter *adapter, bool enable) 178 + bool drm_scdc_set_scrambling(struct drm_connector *connector, 179 + bool enable) 183 180 { 184 181 u8 config; 185 182 int ret; 186 183 187 - ret = drm_scdc_readb(adapter, SCDC_TMDS_CONFIG, &config); 184 + ret = drm_scdc_readb(connector->ddc, SCDC_TMDS_CONFIG, &config); 188 185 if (ret < 0) { 189 - DRM_DEBUG_KMS("Failed to read TMDS config: %d\n", ret); 186 + drm_dbg_kms(connector->dev, 187 + "[CONNECTOR:%d:%s] Failed to read TMDS config: %d\n", 188 + connector->base.id, connector->name, ret); 190 189 return false; 191 190 } 192 191 ··· 198 191 else 199 192 config &= ~SCDC_SCRAMBLING_ENABLE; 200 193 201 - ret = drm_scdc_writeb(adapter, SCDC_TMDS_CONFIG, config); 194 + ret = drm_scdc_writeb(connector->ddc, SCDC_TMDS_CONFIG, config); 202 195 if (ret < 0) { 203 - DRM_DEBUG_KMS("Failed to enable scrambling: %d\n", ret); 196 + drm_dbg_kms(connector->dev, 197 + "[CONNECTOR:%d:%s] Failed to enable scrambling: %d\n", 198 + connector->base.id, connector->name, ret); 204 199 return false; 205 200 } 206 201 ··· 212 203 213 204 /** 214 205 * drm_scdc_set_high_tmds_clock_ratio - set TMDS clock ratio 215 - * @adapter: I2C adapter for DDC channel 206 + * @connector: connector 216 207 * @set: ret or reset the high clock ratio 217 208 * 218 209 * ··· 239 230 * Returns: 240 231 * True if write is successful, false otherwise. 241 232 */ 242 - bool drm_scdc_set_high_tmds_clock_ratio(struct i2c_adapter *adapter, bool set) 233 + bool drm_scdc_set_high_tmds_clock_ratio(struct drm_connector *connector, 234 + bool set) 243 235 { 244 236 u8 config; 245 237 int ret; 246 238 247 - ret = drm_scdc_readb(adapter, SCDC_TMDS_CONFIG, &config); 239 + ret = drm_scdc_readb(connector->ddc, SCDC_TMDS_CONFIG, &config); 248 240 if (ret < 0) { 249 - DRM_DEBUG_KMS("Failed to read TMDS config: %d\n", ret); 241 + drm_dbg_kms(connector->dev, 242 + "[CONNECTOR:%d:%s] Failed to read TMDS config: %d\n", 243 + connector->base.id, connector->name, ret); 250 244 return false; 251 245 } 252 246 ··· 258 246 else 259 247 config &= ~SCDC_TMDS_BIT_CLOCK_RATIO_BY_40; 260 248 261 - ret = drm_scdc_writeb(adapter, SCDC_TMDS_CONFIG, config); 249 + ret = drm_scdc_writeb(connector->ddc, SCDC_TMDS_CONFIG, config); 262 250 if (ret < 0) { 263 - DRM_DEBUG_KMS("Failed to set TMDS clock ratio: %d\n", ret); 251 + drm_dbg_kms(connector->dev, 252 + "[CONNECTOR:%d:%s] Failed to set TMDS clock ratio: %d\n", 253 + connector->base.id, connector->name, ret); 264 254 return false; 265 255 } 266 256
+2 -2
drivers/gpu/drm/i915/display/intel_ddi.c
··· 3988 3988 3989 3989 ret = drm_scdc_readb(adapter, SCDC_TMDS_CONFIG, &config); 3990 3990 if (ret < 0) { 3991 - drm_err(&dev_priv->drm, "Failed to read TMDS config: %d\n", 3992 - ret); 3991 + drm_err(&dev_priv->drm, "[CONNECTOR:%d:%s] Failed to read TMDS config: %d\n", 3992 + connector->base.base.id, connector->base.name, ret); 3993 3993 return 0; 3994 3994 } 3995 3995
+2 -6
drivers/gpu/drm/i915/display/intel_hdmi.c
··· 2646 2646 bool scrambling) 2647 2647 { 2648 2648 struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); 2649 - struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder); 2650 2649 struct drm_scrambling *sink_scrambling = 2651 2650 &connector->display_info.hdmi.scdc.scrambling; 2652 - struct i2c_adapter *adapter = 2653 - intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus); 2654 2651 2655 2652 if (!sink_scrambling->supported) 2656 2653 return true; ··· 2658 2661 str_yes_no(scrambling), high_tmds_clock_ratio ? 40 : 10); 2659 2662 2660 2663 /* Set TMDS bit clock ratio to 1/40 or 1/10, and enable/disable scrambling */ 2661 - return drm_scdc_set_high_tmds_clock_ratio(adapter, 2662 - high_tmds_clock_ratio) && 2663 - drm_scdc_set_scrambling(adapter, scrambling); 2664 + return drm_scdc_set_high_tmds_clock_ratio(connector, high_tmds_clock_ratio) && 2665 + drm_scdc_set_scrambling(connector, scrambling); 2664 2666 } 2665 2667 2666 2668 static u8 chv_port_to_ddc_pin(struct drm_i915_private *dev_priv, enum port port)
+5 -10
drivers/gpu/drm/tegra/sor.c
··· 2140 2140 2141 2141 static void tegra_sor_hdmi_scdc_disable(struct tegra_sor *sor) 2142 2142 { 2143 - struct i2c_adapter *ddc = sor->output.ddc; 2144 - 2145 - drm_scdc_set_high_tmds_clock_ratio(ddc, false); 2146 - drm_scdc_set_scrambling(ddc, false); 2143 + drm_scdc_set_high_tmds_clock_ratio(&sor->output.connector, false); 2144 + drm_scdc_set_scrambling(&sor->output.connector, false); 2147 2145 2148 2146 tegra_sor_hdmi_disable_scrambling(sor); 2149 2147 } ··· 2166 2168 2167 2169 static void tegra_sor_hdmi_scdc_enable(struct tegra_sor *sor) 2168 2170 { 2169 - struct i2c_adapter *ddc = sor->output.ddc; 2170 - 2171 - drm_scdc_set_high_tmds_clock_ratio(ddc, true); 2172 - drm_scdc_set_scrambling(ddc, true); 2171 + drm_scdc_set_high_tmds_clock_ratio(&sor->output.connector, true); 2172 + drm_scdc_set_scrambling(&sor->output.connector, true); 2173 2173 2174 2174 tegra_sor_hdmi_enable_scrambling(sor); 2175 2175 } ··· 2175 2179 static void tegra_sor_hdmi_scdc_work(struct work_struct *work) 2176 2180 { 2177 2181 struct tegra_sor *sor = container_of(work, struct tegra_sor, scdc.work); 2178 - struct i2c_adapter *ddc = sor->output.ddc; 2179 2182 2180 - if (!drm_scdc_get_scrambling_status(ddc)) { 2183 + if (!drm_scdc_get_scrambling_status(&sor->output.connector)) { 2181 2184 DRM_DEBUG_KMS("SCDC not scrambled\n"); 2182 2185 tegra_sor_hdmi_scdc_enable(sor); 2183 2186 }
+12 -9
drivers/gpu/drm/vc4/vc4_hdmi.c
··· 885 885 static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder) 886 886 { 887 887 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); 888 - struct drm_device *drm = vc4_hdmi->connector.dev; 888 + struct drm_connector *connector = &vc4_hdmi->connector; 889 + struct drm_device *drm = connector->dev; 889 890 const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode; 890 891 unsigned long flags; 891 892 int idx; ··· 904 903 if (!drm_dev_enter(drm, &idx)) 905 904 return; 906 905 907 - drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, true); 908 - drm_scdc_set_scrambling(vc4_hdmi->ddc, true); 906 + drm_scdc_set_high_tmds_clock_ratio(connector, true); 907 + drm_scdc_set_scrambling(connector, true); 909 908 910 909 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); 911 910 HDMI_WRITE(HDMI_SCRAMBLER_CTL, HDMI_READ(HDMI_SCRAMBLER_CTL) | ··· 923 922 static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder) 924 923 { 925 924 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder); 926 - struct drm_device *drm = vc4_hdmi->connector.dev; 925 + struct drm_connector *connector = &vc4_hdmi->connector; 926 + struct drm_device *drm = connector->dev; 927 927 unsigned long flags; 928 928 int idx; 929 929 ··· 946 944 ~VC5_HDMI_SCRAMBLER_CTL_ENABLE); 947 945 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); 948 946 949 - drm_scdc_set_scrambling(vc4_hdmi->ddc, false); 950 - drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, false); 947 + drm_scdc_set_scrambling(connector, false); 948 + drm_scdc_set_high_tmds_clock_ratio(connector, false); 951 949 952 950 drm_dev_exit(idx); 953 951 } ··· 957 955 struct vc4_hdmi *vc4_hdmi = container_of(to_delayed_work(work), 958 956 struct vc4_hdmi, 959 957 scrambling_work); 958 + struct drm_connector *connector = &vc4_hdmi->connector; 960 959 961 - if (drm_scdc_get_scrambling_status(vc4_hdmi->ddc)) 960 + if (drm_scdc_get_scrambling_status(connector)) 962 961 return; 963 962 964 - drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, true); 965 - drm_scdc_set_scrambling(vc4_hdmi->ddc, true); 963 + drm_scdc_set_high_tmds_clock_ratio(connector, true); 964 + drm_scdc_set_scrambling(connector, true); 966 965 967 966 queue_delayed_work(system_wq, &vc4_hdmi->scrambling_work, 968 967 msecs_to_jiffies(SCRAMBLING_POLLING_DELAY_MS));
+4 -3
include/drm/display/drm_scdc_helper.h
··· 28 28 29 29 #include <drm/display/drm_scdc.h> 30 30 31 + struct drm_connector; 31 32 struct i2c_adapter; 32 33 33 34 ssize_t drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer, ··· 72 71 return drm_scdc_write(adapter, offset, &value, sizeof(value)); 73 72 } 74 73 75 - bool drm_scdc_get_scrambling_status(struct i2c_adapter *adapter); 74 + bool drm_scdc_get_scrambling_status(struct drm_connector *connector); 76 75 77 - bool drm_scdc_set_scrambling(struct i2c_adapter *adapter, bool enable); 78 - bool drm_scdc_set_high_tmds_clock_ratio(struct i2c_adapter *adapter, bool set); 76 + bool drm_scdc_set_scrambling(struct drm_connector *connector, bool enable); 77 + bool drm_scdc_set_high_tmds_clock_ratio(struct drm_connector *connector, bool set); 79 78 80 79 #endif