<span class="il">Reviewed</span>-<span class="il">by</span>: <span class="il">Rodrigo</span> <span class="il">Vivi</span> <<a href="mailto:rodrigo.vivi@gmail.com"><span class="il">rodrigo</span>.<span class="il">vivi</span>@gmail.com</a>><br>
<br><div class="gmail_quote">On Sun, Oct 21, 2012 at 8:52 AM, Daniel Vetter <span dir="ltr"><<a href="mailto:daniel.vetter@ffwll.ch" target="_blank">daniel.vetter@ffwll.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">Like in the case of native hdmi, which is fixed already in<br>
<br>
commit adf00b26d18e1b3570451296e03bcb20e4798cdd<br>
Author: Paulo Zanoni <<a href="mailto:paulo.r.zanoni@intel.com">paulo.r.zanoni@intel.com</a>><br>
Date: Tue Sep 25 13:23:34 2012 -0300<br>
<br>
drm/i915: make sure we write all the DIP data bytes<br>
<br>
we need to clear the entire sdvo buffer to avoid upsetting the<br>
display.<br>
<br>
Since infoframe buffer writing is now a bit more elaborate, extract it<br>
into it's own function. This will be useful if we ever get around to<br>
properly update the ELD for sdvo. Also #define proper names for the<br>
two buffer indexes with fixed usage.<br>
<br>
v2: Cite the right commit above, spotted by Paulo Zanoni.<br>
<br>
v3: I'm too stupid to paste the right commit.<br>
<br>
</div>v4: Ben Hutchings noticed that I've failed to handle an underflow in<br>
my loop logic, breaking it for i >= length + 8. Since I've just lost C<br>
programmer license, use his solution. Also, make the frustrated 0-base<br>
buffer size a notch more clear.<br>
<div class="im"><br>
Reported-and-tested-by: Jürg Billeter <<a href="mailto:j@bitron.ch">j@bitron.ch</a>><br>
Bugzilla: <a href="https://bugzilla.kernel.org/show_bug.cgi?id=25732" target="_blank">https://bugzilla.kernel.org/show_bug.cgi?id=25732</a><br>
Cc: <a href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a><br>
</div>Cc: Paulo Zanoni <<a href="mailto:przanoni@gmail.com">przanoni@gmail.com</a>><br>
Cc: Ben Hutchings <<a href="mailto:ben@decadent.org.uk">ben@decadent.org.uk</a>><br>
<div class="im">Signed-off-by: Daniel Vetter <<a href="mailto:daniel.vetter@ffwll.ch">daniel.vetter@ffwll.ch</a>><br>
---<br>
</div> drivers/gpu/drm/i915/intel_sdvo.c | 62 +++++++++++++++++++++-----------<br>
drivers/gpu/drm/i915/intel_sdvo_regs.h | 2 ++<br>
2 files changed, 44 insertions(+), 20 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c<br>
index d2e8c9f..ac9489c 100644<br>
--- a/drivers/gpu/drm/i915/intel_sdvo.c<br>
+++ b/drivers/gpu/drm/i915/intel_sdvo.c<br>
@@ -895,6 +895,45 @@ static void intel_sdvo_dump_hdmi_buf(struct intel_sdvo *intel_sdvo)<br>
<div class="im"> }<br>
#endif<br>
<br>
+static bool intel_sdvo_write_infoframe(struct intel_sdvo *intel_sdvo,<br>
+ unsigned if_index, uint8_t tx_rate,<br>
+ uint8_t *data, unsigned length)<br>
+{<br>
+ uint8_t set_buf_index[2] = { if_index, 0 };<br>
+ uint8_t hbuf_size, tmp[8];<br>
+ int i;<br>
+<br>
+ if (!intel_sdvo_set_value(intel_sdvo,<br>
+ SDVO_CMD_SET_HBUF_INDEX,<br>
+ set_buf_index, 2))<br>
+ return false;<br>
+<br>
+ if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HBUF_INFO,<br>
+ &hbuf_size, 1))<br>
+ return false;<br>
+<br>
</div>+ /* Buffer size is 0 based, hooray! */<br>
+ hbuf_size++;<br>
+<br>
<div class="im">+ DRM_DEBUG_KMS("writing sdvo hbuf: %i, hbuf_size %i, hbuf_size: %i\n",<br>
+ if_index, length, hbuf_size);<br>
+<br>
+ for (i = 0; i < hbuf_size; i += 8) {<br>
+ memset(tmp, 0, 8);<br>
</div>+ if (i < length)<br>
+ memcpy(tmp, data + i, min_t(unsigned, 8, length - i));<br>
<div class="im">+<br>
+ if (!intel_sdvo_set_value(intel_sdvo,<br>
+ SDVO_CMD_SET_HBUF_DATA,<br>
+ tmp, 8))<br>
+ return false;<br>
+ }<br>
+<br>
</div><div class="im">+ return intel_sdvo_set_value(intel_sdvo,<br>
+ SDVO_CMD_SET_HBUF_TXRATE,<br>
+ &tx_rate, 1);<br>
+}<br>
+<br>
static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo)<br>
{<br>
struct dip_infoframe avi_if = {<br>
</div>@@ -902,11 +941,7 @@ static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo)<br>
<div class="im"> .ver = DIP_VERSION_AVI,<br>
.len = DIP_LEN_AVI,<br>
};<br>
- uint8_t tx_rate = SDVO_HBUF_TX_VSYNC;<br>
- uint8_t set_buf_index[2] = { 1, 0 };<br>
uint8_t sdvo_data[4 + sizeof(avi_if.body.avi)];<br>
- uint64_t *data = (uint64_t *)sdvo_data;<br>
- unsigned i;<br>
<br>
intel_dip_infoframe_csum(&avi_if);<br>
<br>
</div>@@ -916,22 +951,9 @@ static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo)<br>
<div class="HOEnZb"><div class="h5"> sdvo_data[3] = avi_if.checksum;<br>
memcpy(&sdvo_data[4], &avi_if.body, sizeof(avi_if.body.avi));<br>
<br>
- if (!intel_sdvo_set_value(intel_sdvo,<br>
- SDVO_CMD_SET_HBUF_INDEX,<br>
- set_buf_index, 2))<br>
- return false;<br>
-<br>
- for (i = 0; i < sizeof(sdvo_data); i += 8) {<br>
- if (!intel_sdvo_set_value(intel_sdvo,<br>
- SDVO_CMD_SET_HBUF_DATA,<br>
- data, 8))<br>
- return false;<br>
- data++;<br>
- }<br>
-<br>
- return intel_sdvo_set_value(intel_sdvo,<br>
- SDVO_CMD_SET_HBUF_TXRATE,<br>
- &tx_rate, 1);<br>
+ return intel_sdvo_write_infoframe(intel_sdvo, SDVO_HBUF_INDEX_AVI_IF,<br>
+ SDVO_HBUF_TX_VSYNC,<br>
+ sdvo_data, sizeof(sdvo_data));<br>
}<br>
<br>
static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo)<br>
diff --git a/drivers/gpu/drm/i915/intel_sdvo_regs.h b/drivers/gpu/drm/i915/intel_sdvo_regs.h<br>
index 9d03014..770bdd6 100644<br>
--- a/drivers/gpu/drm/i915/intel_sdvo_regs.h<br>
+++ b/drivers/gpu/drm/i915/intel_sdvo_regs.h<br>
@@ -708,6 +708,8 @@ struct intel_sdvo_enhancements_arg {<br>
#define SDVO_CMD_SET_AUDIO_STAT 0x91<br>
#define SDVO_CMD_GET_AUDIO_STAT 0x92<br>
#define SDVO_CMD_SET_HBUF_INDEX 0x93<br>
+ #define SDVO_HBUF_INDEX_ELD 0<br>
+ #define SDVO_HBUF_INDEX_AVI_IF 1<br>
#define SDVO_CMD_GET_HBUF_INDEX 0x94<br>
#define SDVO_CMD_GET_HBUF_INFO 0x95<br>
#define SDVO_CMD_SET_HBUF_AV_SPLIT 0x96<br>
--<br>
1.7.10.4<br>
<br>
_______________________________________________<br>
Intel-gfx mailing list<br>
<a href="mailto:Intel-gfx@lists.freedesktop.org">Intel-gfx@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/intel-gfx" target="_blank">http://lists.freedesktop.org/mailman/listinfo/intel-gfx</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div>Rodrigo Vivi</div><div>Blog: <a href="http://blog.vivi.eng.br" target="_blank">http://blog.vivi.eng.br</a></div><div> </div><br>