Skip to content

Commit 5d84409

Browse files
committed
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 <[email protected]> Cc: Neil Armstrong <[email protected]> Cc: Robert Foss <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Jonas Karlman <[email protected]> Cc: Jernej Skrabec <[email protected]> Cc: Thierry Reding <[email protected]> Cc: Emma Anholt <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Reviewed-by: Laurent Pinchart <[email protected]> Acked-by: Maxime Ripard <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Acked-by: Thierry Reding <[email protected]>
1 parent ee4cce0 commit 5d84409

File tree

7 files changed

+59
-50
lines changed

7 files changed

+59
-50
lines changed

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,9 +1426,9 @@ void dw_hdmi_set_high_tmds_clock_ratio(struct dw_hdmi *hdmi,
14261426
/* Control for TMDS Bit Period/TMDS Clock-Period Ratio */
14271427
if (dw_hdmi_support_scdc(hdmi, display)) {
14281428
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);
14301430
else
1431-
drm_scdc_set_high_tmds_clock_ratio(hdmi->ddc, 0);
1431+
drm_scdc_set_high_tmds_clock_ratio(&hdmi->connector, 0);
14321432
}
14331433
}
14341434
EXPORT_SYMBOL_GPL(dw_hdmi_set_high_tmds_clock_ratio);
@@ -2116,7 +2116,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi,
21162116
min_t(u8, bytes, SCDC_MIN_SOURCE_VERSION));
21172117

21182118
/* Enabled Scrambling in the Sink */
2119-
drm_scdc_set_scrambling(hdmi->ddc, 1);
2119+
drm_scdc_set_scrambling(&hdmi->connector, 1);
21202120

21212121
/*
21222122
* To activate the scrambler feature, you must ensure
@@ -2132,7 +2132,7 @@ static void hdmi_av_composer(struct dw_hdmi *hdmi,
21322132
hdmi_writeb(hdmi, 0, HDMI_FC_SCRAMBLER_CTRL);
21332133
hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ,
21342134
HDMI_MC_SWRSTZ);
2135-
drm_scdc_set_scrambling(hdmi->ddc, 0);
2135+
drm_scdc_set_scrambling(&hdmi->connector, 0);
21362136
}
21372137
}
21382138

drivers/gpu/drm/display/drm_scdc_helper.c

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <linux/delay.h>
2727

2828
#include <drm/display/drm_scdc_helper.h>
29+
#include <drm/drm_connector.h>
30+
#include <drm/drm_device.h>
2931
#include <drm/drm_print.h>
3032

3133
/**
@@ -140,22 +142,24 @@ EXPORT_SYMBOL(drm_scdc_write);
140142

141143
/**
142144
* drm_scdc_get_scrambling_status - what is status of scrambling?
143-
* @adapter: I2C adapter for DDC channel
145+
* @connector: connector
144146
*
145147
* Reads the scrambler status over SCDC, and checks the
146148
* scrambling status.
147149
*
148150
* Returns:
149151
* True if the scrambling is enabled, false otherwise.
150152
*/
151-
bool drm_scdc_get_scrambling_status(struct i2c_adapter *adapter)
153+
bool drm_scdc_get_scrambling_status(struct drm_connector *connector)
152154
{
153155
u8 status;
154156
int ret;
155157

156-
ret = drm_scdc_readb(adapter, SCDC_SCRAMBLER_STATUS, &status);
158+
ret = drm_scdc_readb(connector->ddc, SCDC_SCRAMBLER_STATUS, &status);
157159
if (ret < 0) {
158-
DRM_DEBUG_KMS("Failed to read scrambling status: %d\n", ret);
160+
drm_dbg_kms(connector->dev,
161+
"[CONNECTOR:%d:%s] Failed to read scrambling status: %d\n",
162+
connector->base.id, connector->name, ret);
159163
return false;
160164
}
161165

@@ -165,7 +169,7 @@ EXPORT_SYMBOL(drm_scdc_get_scrambling_status);
165169

166170
/**
167171
* drm_scdc_set_scrambling - enable scrambling
168-
* @adapter: I2C adapter for DDC channel
172+
* @connector: connector
169173
* @enable: bool to indicate if scrambling is to be enabled/disabled
170174
*
171175
* Writes the TMDS config register over SCDC channel, and:
@@ -175,14 +179,17 @@ EXPORT_SYMBOL(drm_scdc_get_scrambling_status);
175179
* Returns:
176180
* True if scrambling is set/reset successfully, false otherwise.
177181
*/
178-
bool drm_scdc_set_scrambling(struct i2c_adapter *adapter, bool enable)
182+
bool drm_scdc_set_scrambling(struct drm_connector *connector,
183+
bool enable)
179184
{
180185
u8 config;
181186
int ret;
182187

183-
ret = drm_scdc_readb(adapter, SCDC_TMDS_CONFIG, &config);
188+
ret = drm_scdc_readb(connector->ddc, SCDC_TMDS_CONFIG, &config);
184189
if (ret < 0) {
185-
DRM_DEBUG_KMS("Failed to read TMDS config: %d\n", ret);
190+
drm_dbg_kms(connector->dev,
191+
"[CONNECTOR:%d:%s] Failed to read TMDS config: %d\n",
192+
connector->base.id, connector->name, ret);
186193
return false;
187194
}
188195

@@ -191,9 +198,11 @@ bool drm_scdc_set_scrambling(struct i2c_adapter *adapter, bool enable)
191198
else
192199
config &= ~SCDC_SCRAMBLING_ENABLE;
193200

194-
ret = drm_scdc_writeb(adapter, SCDC_TMDS_CONFIG, config);
201+
ret = drm_scdc_writeb(connector->ddc, SCDC_TMDS_CONFIG, config);
195202
if (ret < 0) {
196-
DRM_DEBUG_KMS("Failed to enable scrambling: %d\n", ret);
203+
drm_dbg_kms(connector->dev,
204+
"[CONNECTOR:%d:%s] Failed to enable scrambling: %d\n",
205+
connector->base.id, connector->name, ret);
197206
return false;
198207
}
199208

@@ -203,7 +212,7 @@ EXPORT_SYMBOL(drm_scdc_set_scrambling);
203212

204213
/**
205214
* drm_scdc_set_high_tmds_clock_ratio - set TMDS clock ratio
206-
* @adapter: I2C adapter for DDC channel
215+
* @connector: connector
207216
* @set: ret or reset the high clock ratio
208217
*
209218
*
@@ -230,14 +239,17 @@ EXPORT_SYMBOL(drm_scdc_set_scrambling);
230239
* Returns:
231240
* True if write is successful, false otherwise.
232241
*/
233-
bool drm_scdc_set_high_tmds_clock_ratio(struct i2c_adapter *adapter, bool set)
242+
bool drm_scdc_set_high_tmds_clock_ratio(struct drm_connector *connector,
243+
bool set)
234244
{
235245
u8 config;
236246
int ret;
237247

238-
ret = drm_scdc_readb(adapter, SCDC_TMDS_CONFIG, &config);
248+
ret = drm_scdc_readb(connector->ddc, SCDC_TMDS_CONFIG, &config);
239249
if (ret < 0) {
240-
DRM_DEBUG_KMS("Failed to read TMDS config: %d\n", ret);
250+
drm_dbg_kms(connector->dev,
251+
"[CONNECTOR:%d:%s] Failed to read TMDS config: %d\n",
252+
connector->base.id, connector->name, ret);
241253
return false;
242254
}
243255

@@ -246,9 +258,11 @@ bool drm_scdc_set_high_tmds_clock_ratio(struct i2c_adapter *adapter, bool set)
246258
else
247259
config &= ~SCDC_TMDS_BIT_CLOCK_RATIO_BY_40;
248260

249-
ret = drm_scdc_writeb(adapter, SCDC_TMDS_CONFIG, config);
261+
ret = drm_scdc_writeb(connector->ddc, SCDC_TMDS_CONFIG, config);
250262
if (ret < 0) {
251-
DRM_DEBUG_KMS("Failed to set TMDS clock ratio: %d\n", ret);
263+
drm_dbg_kms(connector->dev,
264+
"[CONNECTOR:%d:%s] Failed to set TMDS clock ratio: %d\n",
265+
connector->base.id, connector->name, ret);
252266
return false;
253267
}
254268

drivers/gpu/drm/i915/display/intel_ddi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3988,8 +3988,8 @@ static int intel_hdmi_reset_link(struct intel_encoder *encoder,
39883988

39893989
ret = drm_scdc_readb(adapter, SCDC_TMDS_CONFIG, &config);
39903990
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);
39933993
return 0;
39943994
}
39953995

drivers/gpu/drm/i915/display/intel_hdmi.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,11 +2646,8 @@ bool intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder,
26462646
bool scrambling)
26472647
{
26482648
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
2649-
struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(encoder);
26502649
struct drm_scrambling *sink_scrambling =
26512650
&connector->display_info.hdmi.scdc.scrambling;
2652-
struct i2c_adapter *adapter =
2653-
intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
26542651

26552652
if (!sink_scrambling->supported)
26562653
return true;
@@ -2661,9 +2658,8 @@ bool intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder,
26612658
str_yes_no(scrambling), high_tmds_clock_ratio ? 40 : 10);
26622659

26632660
/* Set TMDS bit clock ratio to 1/40 or 1/10, and enable/disable scrambling */
2664-
return drm_scdc_set_high_tmds_clock_ratio(adapter,
2665-
high_tmds_clock_ratio) &&
2666-
drm_scdc_set_scrambling(adapter, scrambling);
2661+
return drm_scdc_set_high_tmds_clock_ratio(connector, high_tmds_clock_ratio) &&
2662+
drm_scdc_set_scrambling(connector, scrambling);
26672663
}
26682664

26692665
static u8 chv_port_to_ddc_pin(struct drm_i915_private *dev_priv, enum port port)

drivers/gpu/drm/tegra/sor.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,10 +2140,8 @@ static void tegra_sor_hdmi_disable_scrambling(struct tegra_sor *sor)
21402140

21412141
static void tegra_sor_hdmi_scdc_disable(struct tegra_sor *sor)
21422142
{
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);
21472145

21482146
tegra_sor_hdmi_disable_scrambling(sor);
21492147
}
@@ -2168,20 +2166,17 @@ static void tegra_sor_hdmi_enable_scrambling(struct tegra_sor *sor)
21682166

21692167
static void tegra_sor_hdmi_scdc_enable(struct tegra_sor *sor)
21702168
{
2171-
struct i2c_adapter *ddc = sor->output.ddc;
2172-
2173-
drm_scdc_set_high_tmds_clock_ratio(ddc, true);
2174-
drm_scdc_set_scrambling(ddc, true);
2169+
drm_scdc_set_high_tmds_clock_ratio(&sor->output.connector, true);
2170+
drm_scdc_set_scrambling(&sor->output.connector, true);
21752171

21762172
tegra_sor_hdmi_enable_scrambling(sor);
21772173
}
21782174

21792175
static void tegra_sor_hdmi_scdc_work(struct work_struct *work)
21802176
{
21812177
struct tegra_sor *sor = container_of(work, struct tegra_sor, scdc.work);
2182-
struct i2c_adapter *ddc = sor->output.ddc;
21832178

2184-
if (!drm_scdc_get_scrambling_status(ddc)) {
2179+
if (!drm_scdc_get_scrambling_status(&sor->output.connector)) {
21852180
DRM_DEBUG_KMS("SCDC not scrambled\n");
21862181
tegra_sor_hdmi_scdc_enable(sor);
21872182
}

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ static void vc4_hdmi_set_infoframes(struct drm_encoder *encoder)
885885
static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
886886
{
887887
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;
889890
const struct drm_display_mode *mode = &vc4_hdmi->saved_adjusted_mode;
890891
unsigned long flags;
891892
int idx;
@@ -903,8 +904,8 @@ static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
903904
if (!drm_dev_enter(drm, &idx))
904905
return;
905906

906-
drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, true);
907-
drm_scdc_set_scrambling(vc4_hdmi->ddc, true);
907+
drm_scdc_set_high_tmds_clock_ratio(connector, true);
908+
drm_scdc_set_scrambling(connector, true);
908909

909910
spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
910911
HDMI_WRITE(HDMI_SCRAMBLER_CTL, HDMI_READ(HDMI_SCRAMBLER_CTL) |
@@ -922,7 +923,8 @@ static void vc4_hdmi_enable_scrambling(struct drm_encoder *encoder)
922923
static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder)
923924
{
924925
struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
925-
struct drm_device *drm = vc4_hdmi->connector.dev;
926+
struct drm_connector *connector = &vc4_hdmi->connector;
927+
struct drm_device *drm = connector->dev;
926928
unsigned long flags;
927929
int idx;
928930

@@ -944,8 +946,8 @@ static void vc4_hdmi_disable_scrambling(struct drm_encoder *encoder)
944946
~VC5_HDMI_SCRAMBLER_CTL_ENABLE);
945947
spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
946948

947-
drm_scdc_set_scrambling(vc4_hdmi->ddc, false);
948-
drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, false);
949+
drm_scdc_set_scrambling(connector, false);
950+
drm_scdc_set_high_tmds_clock_ratio(connector, false);
949951

950952
drm_dev_exit(idx);
951953
}
@@ -955,12 +957,13 @@ static void vc4_hdmi_scrambling_wq(struct work_struct *work)
955957
struct vc4_hdmi *vc4_hdmi = container_of(to_delayed_work(work),
956958
struct vc4_hdmi,
957959
scrambling_work);
960+
struct drm_connector *connector = &vc4_hdmi->connector;
958961

959-
if (drm_scdc_get_scrambling_status(vc4_hdmi->ddc))
962+
if (drm_scdc_get_scrambling_status(connector))
960963
return;
961964

962-
drm_scdc_set_high_tmds_clock_ratio(vc4_hdmi->ddc, true);
963-
drm_scdc_set_scrambling(vc4_hdmi->ddc, true);
965+
drm_scdc_set_high_tmds_clock_ratio(connector, true);
966+
drm_scdc_set_scrambling(connector, true);
964967

965968
queue_delayed_work(system_wq, &vc4_hdmi->scrambling_work,
966969
msecs_to_jiffies(SCRAMBLING_POLLING_DELAY_MS));

include/drm/display/drm_scdc_helper.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <drm/display/drm_scdc.h>
3030

31+
struct drm_connector;
3132
struct i2c_adapter;
3233

3334
ssize_t drm_scdc_read(struct i2c_adapter *adapter, u8 offset, void *buffer,
@@ -71,9 +72,9 @@ static inline int drm_scdc_writeb(struct i2c_adapter *adapter, u8 offset,
7172
return drm_scdc_write(adapter, offset, &value, sizeof(value));
7273
}
7374

74-
bool drm_scdc_get_scrambling_status(struct i2c_adapter *adapter);
75+
bool drm_scdc_get_scrambling_status(struct drm_connector *connector);
7576

76-
bool drm_scdc_set_scrambling(struct i2c_adapter *adapter, bool enable);
77-
bool drm_scdc_set_high_tmds_clock_ratio(struct i2c_adapter *adapter, bool set);
77+
bool drm_scdc_set_scrambling(struct drm_connector *connector, bool enable);
78+
bool drm_scdc_set_high_tmds_clock_ratio(struct drm_connector *connector, bool set);
7879

7980
#endif

0 commit comments

Comments
 (0)