Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] drm/i915/sdvo: Fix handling if zero hbuf size
@ 2019-06-19 18:03 Ville Syrjala
  2019-06-19 18:03 ` [PATCH 2/6] drm/i915/sdvo: Use named initializers for the SDVO command names Ville Syrjala
                   ` (8 more replies)
  0 siblings, 9 replies; 16+ messages in thread
From: Ville Syrjala @ 2019-06-19 18:03 UTC (permalink / raw)
  To: intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The spec says:
"A value of 0 indicates that this buffer does not exist"
So we should not convert a hbuf_size of 0 into 1.

Also pull the relevant code into a helper to avoid making the
same mistake multiple times.

And while at it fix the debug prints to not say "hbuf_len" twice.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_sdvo.c | 32 ++++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_sdvo.c b/drivers/gpu/drm/i915/display/intel_sdvo.c
index ceda03e5a3d4..681411aae754 100644
--- a/drivers/gpu/drm/i915/display/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/display/intel_sdvo.c
@@ -929,6 +929,20 @@ static bool intel_sdvo_set_audio_state(struct intel_sdvo *intel_sdvo,
 				    &audio_state, 1);
 }
 
+static bool intel_sdvo_get_hbuf_size(struct intel_sdvo *intel_sdvo,
+				     u8 *hbuf_size)
+{
+	if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HBUF_INFO,
+				  hbuf_size, 1))
+		return false;
+
+	/* Buffer size is 0 based, hooray! However zero means zero. */
+	if (*hbuf_size)
+		(*hbuf_size)++;
+
+	return true;
+}
+
 #if 0
 static void intel_sdvo_dump_hdmi_buf(struct intel_sdvo *intel_sdvo)
 {
@@ -972,14 +986,10 @@ static bool intel_sdvo_write_infoframe(struct intel_sdvo *intel_sdvo,
 				  set_buf_index, 2))
 		return false;
 
-	if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HBUF_INFO,
-				  &hbuf_size, 1))
+	if (!intel_sdvo_get_hbuf_size(intel_sdvo, &hbuf_size))
 		return false;
 
-	/* Buffer size is 0 based, hooray! */
-	hbuf_size++;
-
-	DRM_DEBUG_KMS("writing sdvo hbuf: %i, hbuf_size %i, hbuf_size: %i\n",
+	DRM_DEBUG_KMS("writing sdvo hbuf: %i, length %i, hbuf_size: %i\n",
 		      if_index, length, hbuf_size);
 
 	if (hbuf_size < length)
@@ -1030,14 +1040,10 @@ static ssize_t intel_sdvo_read_infoframe(struct intel_sdvo *intel_sdvo,
 	if (tx_rate == SDVO_HBUF_TX_DISABLED)
 		return 0;
 
-	if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HBUF_INFO,
-				  &hbuf_size, 1))
-		return -ENXIO;
-
-	/* Buffer size is 0 based, hooray! */
-	hbuf_size++;
+	if (!intel_sdvo_get_hbuf_size(intel_sdvo, &hbuf_size))
+		return false;
 
-	DRM_DEBUG_KMS("reading sdvo hbuf: %i, hbuf_size %i, hbuf_size: %i\n",
+	DRM_DEBUG_KMS("reading sdvo hbuf: %i, length %i, hbuf_size: %i\n",
 		      if_index, length, hbuf_size);
 
 	hbuf_size = min_t(unsigned int, length, hbuf_size);
-- 
2.21.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-07-10 13:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-19 18:03 [PATCH 1/6] drm/i915/sdvo: Fix handling if zero hbuf size Ville Syrjala
2019-06-19 18:03 ` [PATCH 2/6] drm/i915/sdvo: Use named initializers for the SDVO command names Ville Syrjala
2019-06-19 18:08   ` Chris Wilson
2019-06-19 18:03 ` [PATCH 3/6] drm/i915/sdvo: Remove duplicate SET_INPUT_TIMINGS_PART1 cmd name string Ville Syrjala
2019-06-19 18:11   ` Chris Wilson
2019-06-19 18:03 ` [PATCH 4/6] drm/i915/sdvo: Shrink sdvo_cmd_names[] strings Ville Syrjala
2019-06-19 18:13   ` Chris Wilson
2019-06-19 18:03 ` [PATCH 5/6] drm/i915/sdvo: Reduce the size of the on stack buffers Ville Syrjala
2019-06-19 18:21   ` Chris Wilson
2019-06-24 16:40     ` Ville Syrjälä
2019-06-19 18:03 ` [PATCH 6/6] drm/i915/sdvo: Add helpers to get the cmd/status string Ville Syrjala
2019-06-19 18:15   ` Chris Wilson
2019-06-19 18:32 ` ✗ Fi.CI.SPARSE: warning for series starting with [1/6] drm/i915/sdvo: Fix handling if zero hbuf size Patchwork
2019-06-19 18:52 ` ✓ Fi.CI.BAT: success " Patchwork
2019-06-20 13:39 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-07-10 13:37 ` [PATCH 1/6] " Imre Deak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox