public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Cc: intel-gfx <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v3] drm/i915: rewrite hsw/bdw audio codec enable/disable sequences
Date: Thu, 30 Oct 2014 10:51:36 +0200	[thread overview]
Message-ID: <877fzij5yf.fsf@intel.com> (raw)
In-Reply-To: <CABVU7+uhLGmtMOar5qRus9zat4Lwex+kpGOgvT+gtd0Qb3CrRA@mail.gmail.com>

On Wed, 29 Oct 2014, Rodrigo Vivi <rodrigo.vivi@gmail.com> wrote:
> On Tue, Oct 28, 2014 at 5:03 AM, Jani Nikula <jani.nikula@intel.com> wrote:
>> There's some serious confusion regarding ELD valid bit that gets set and
>> cleared back and forth etc. Rewrite it all based on the documented audio
>> codec enable/disable sequences.
>>
>> v3: replace vblank wait with a comment
>
> Why did you remove the vblank wait? seemed correct by spec you
> pointed... at least looking to BDW one...

The problem is, we can't do that call in modeset path without getting a
warning, IIUC this is since we moved to the drm vblank wait
call. Daniel?

BR,
Jani.




>
>
>>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_audio.c | 110 ++++++++++++++++---------------------
>>  1 file changed, 46 insertions(+), 64 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_audio.c b/drivers/gpu/drm/i915/intel_audio.c
>> index 821514c95229..2e7d42878b9d 100644
>> --- a/drivers/gpu/drm/i915/intel_audio.c
>> +++ b/drivers/gpu/drm/i915/intel_audio.c
>> @@ -132,14 +132,26 @@ static void g4x_audio_codec_enable(struct drm_connector *connector,
>>
>>  static void hsw_audio_codec_disable(struct intel_encoder *encoder)
>>  {
>> -       struct drm_device *dev = encoder->base.dev;
>> -       struct drm_i915_private *dev_priv = dev->dev_private;
>> -       struct drm_crtc *crtc = encoder->base.crtc;
>> -       enum pipe pipe = to_intel_crtc(crtc)->pipe;
>> +       struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
>> +       struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
>> +       enum pipe pipe = intel_crtc->pipe;
>>         uint32_t tmp;
>>
>> +       DRM_DEBUG_KMS("Disable audio codec on pipe %c\n", pipe_name(pipe));
>> +
>> +       /* Disable timestamps */
>> +       tmp = I915_READ(HSW_AUD_CFG(pipe));
>> +       tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
>> +       tmp |= AUD_CONFIG_N_PROG_ENABLE;
>> +       tmp &= ~AUD_CONFIG_UPPER_N_MASK;
>> +       tmp &= ~AUD_CONFIG_LOWER_N_MASK;
>> +       if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
>> +               tmp |= AUD_CONFIG_N_VALUE_INDEX;
>> +       I915_WRITE(HSW_AUD_CFG(pipe), tmp);
>> +
>> +       /* Invalidate ELD */
>>         tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
>> -       tmp &= ~((AUDIO_OUTPUT_ENABLE_A | AUDIO_ELD_VALID_A) << (pipe * 4));
>> +       tmp &= ~(AUDIO_ELD_VALID_A << (pipe * 4));
>>         I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
>>  }
>>
>> @@ -149,77 +161,47 @@ static void hsw_audio_codec_enable(struct drm_connector *connector,
>>  {
>>         struct drm_i915_private *dev_priv = connector->dev->dev_private;
>>         struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
>> -       uint8_t *eld = connector->eld;
>> -       uint32_t eldv;
>> +       enum pipe pipe = intel_crtc->pipe;
>> +       const uint8_t *eld = connector->eld;
>>         uint32_t tmp;
>>         int len, i;
>> -       enum pipe pipe = intel_crtc->pipe;
>> -       enum port port;
>> -       int hdmiw_hdmiedid = HSW_AUD_EDID_DATA(pipe);
>> -       int aud_cntl_st = HSW_AUD_DIP_ELD_CTRL(pipe);
>> -       int aud_config = HSW_AUD_CFG(pipe);
>> -       int aud_cntrl_st2 = HSW_AUD_PIN_ELD_CP_VLD;
>>
>> -       /* Audio output enable */
>> -       DRM_DEBUG_DRIVER("HDMI audio: enable codec\n");
>> -       tmp = I915_READ(aud_cntrl_st2);
>> -       tmp |= (AUDIO_OUTPUT_ENABLE_A << (pipe * 4));
>> -       I915_WRITE(aud_cntrl_st2, tmp);
>> -       POSTING_READ(aud_cntrl_st2);
>> -
>> -       /* Set ELD valid state */
>> -       tmp = I915_READ(aud_cntrl_st2);
>> -       DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%08x\n", tmp);
>> -       tmp |= (AUDIO_ELD_VALID_A << (pipe * 4));
>> -       I915_WRITE(aud_cntrl_st2, tmp);
>> -       tmp = I915_READ(aud_cntrl_st2);
>> -       DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%08x\n", tmp);
>> -
>> -       /* Enable HDMI mode */
>> -       tmp = I915_READ(aud_config);
>> -       DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%08x\n", tmp);
>> -       /* clear N_programing_enable and N_value_index */
>> -       tmp &= ~(AUD_CONFIG_N_VALUE_INDEX | AUD_CONFIG_N_PROG_ENABLE);
>> -       I915_WRITE(aud_config, tmp);
>> +       DRM_DEBUG_KMS("Enable audio codec on pipe %c, %u bytes ELD\n",
>> +                     pipe_name(pipe), eld[2]);
>>
>> -       DRM_DEBUG_DRIVER("ELD on pipe %c\n", pipe_name(pipe));
>> -
>> -       eldv = AUDIO_ELD_VALID_A << (pipe * 4);
>> -
>> -       if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
>> -               I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */
>> -       else
>> -               I915_WRITE(aud_config, audio_config_hdmi_pixel_clock(mode));
>> -
>> -       if (intel_eld_uptodate(connector,
>> -                              aud_cntrl_st2, eldv,
>> -                              aud_cntl_st, IBX_ELD_ADDRESS_MASK,
>> -                              hdmiw_hdmiedid))
>> -               return;
>> +       /* Enable audio presence detect, invalidate ELD */
>> +       tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
>> +       tmp |= AUDIO_OUTPUT_ENABLE_A << (pipe * 4);
>> +       tmp &= ~(AUDIO_ELD_VALID_A << (pipe * 4));
>> +       I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
>>
>> -       tmp = I915_READ(aud_cntrl_st2);
>> -       tmp &= ~eldv;
>> -       I915_WRITE(aud_cntrl_st2, tmp);
>> +       /* XXX: vblank wait here */
>>
>> -       tmp = I915_READ(aud_cntl_st);
>> +       /* Reset ELD write address */
>> +       tmp = I915_READ(HSW_AUD_DIP_ELD_CTRL(pipe));
>>         tmp &= ~IBX_ELD_ADDRESS_MASK;
>> -       I915_WRITE(aud_cntl_st, tmp);
>> -       port = (tmp >> 29) & DIP_PORT_SEL_MASK;         /* DIP_Port_Select, 0x1 = PortB */
>> -       DRM_DEBUG_DRIVER("port num:%d\n", port);
>> +       I915_WRITE(HSW_AUD_DIP_ELD_CTRL(pipe), tmp);
>>
>> -       len = min_t(int, eld[2], 21);   /* 84 bytes of hw ELD buffer */
>> -       DRM_DEBUG_DRIVER("ELD size %d\n", len);
>> +       /* Up to 84 bytes of hw ELD buffer */
>> +       len = min_t(int, eld[2], 21);
>>         for (i = 0; i < len; i++)
>> -               I915_WRITE(hdmiw_hdmiedid, *((uint32_t *)eld + i));
>> -
>> -       tmp = I915_READ(aud_cntrl_st2);
>> -       tmp |= eldv;
>> -       I915_WRITE(aud_cntrl_st2, tmp);
>> +               I915_WRITE(HSW_AUD_EDID_DATA(pipe), *((uint32_t *)eld + i));
>>
>> -       /* XXX: Transitional */
>> +       /* ELD valid */
>>         tmp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
>> -       tmp |= ((AUDIO_OUTPUT_ENABLE_A | AUDIO_ELD_VALID_A) << (pipe * 4));
>> +       tmp |= AUDIO_ELD_VALID_A << (pipe * 4);
>>         I915_WRITE(HSW_AUD_PIN_ELD_CP_VLD, tmp);
>> +
>> +       /* Enable timestamps */
>> +       tmp = I915_READ(HSW_AUD_CFG(pipe));
>> +       tmp &= ~AUD_CONFIG_N_VALUE_INDEX;
>> +       tmp &= ~AUD_CONFIG_N_PROG_ENABLE;
>> +       tmp &= ~AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK;
>> +       if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DISPLAYPORT))
>> +               tmp |= AUD_CONFIG_N_VALUE_INDEX;
>> +       else
>> +               tmp |= audio_config_hdmi_pixel_clock(mode);
>> +       I915_WRITE(HSW_AUD_CFG(pipe), tmp);
>>  }
>>
>>  static void ilk_audio_codec_enable(struct drm_connector *connector,
>> --
>> 2.1.1
>>
>
>
>
> -- 
> Rodrigo Vivi
> Blog: http://blog.vivi.eng.br

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2014-10-30  8:52 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-27 14:26 [PATCH v2 00/18] drm/i915: hdmi/dp audio rework Jani Nikula
2014-10-27 14:26 ` [PATCH v2 01/18] drm/i915: add new intel audio file to group DP/HDMI audio Jani Nikula
2014-10-27 17:40   ` Vivi, Rodrigo
2014-10-27 14:26 ` [PATCH v2 02/18] drm/i915/audio: constify hdmi audio clock struct Jani Nikula
2014-10-27 17:42   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 03/18] drm/i915/audio: beat some sense into the variable types and names Jani Nikula
2014-10-27 17:46   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 04/18] drm/i915: pass intel_encoder to intel_write_eld Jani Nikula
2014-10-27 17:47   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 05/18] drm/i915/audio: pass intel_encoder on to platform specific ELD functions Jani Nikula
2014-10-27 17:52   ` Rodrigo Vivi
2014-10-28  7:30     ` Daniel Vetter
2014-10-29 21:48       ` Rodrigo Vivi
2014-10-30  8:52         ` Jani Nikula
2014-11-03 11:59           ` Daniel Vetter
2014-11-04 23:18             ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 06/18] drm/i915/audio: set ELD Conn_Type at one place Jani Nikula
2014-10-27 18:00   ` Rodrigo Vivi
2014-10-28  9:18     ` Jani Nikula
2014-10-28 11:53     ` [PATCH v3] " Jani Nikula
2014-10-28 16:23       ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 07/18] drm/i915/ddi: write ELD where it's supposed to be done Jani Nikula
2014-10-27 18:04   ` Rodrigo Vivi
2014-10-28  8:28     ` Jani Nikula
2014-10-30 17:16       ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 08/18] drm/i915: introduce intel_audio_codec_{enable, disable} Jani Nikula
2014-10-27 18:21   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 09/18] drm/i915/audio: remove misleading checks for !eld[0] Jani Nikula
2014-10-27 18:27   ` Rodrigo Vivi
2014-10-27 18:29     ` Rodrigo Vivi
2014-11-03 12:04     ` Daniel Vetter
2014-10-27 14:26 ` [PATCH v2 10/18] drm/i915: clean up and clarify audio related register defines Jani Nikula
2014-10-27 18:31   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 11/18] drm/i915: rewrite hsw/bdw audio codec enable/disable sequences Jani Nikula
2014-10-27 18:35   ` Rodrigo Vivi
2014-10-28 15:18     ` Jani Nikula
2014-10-28 12:03   ` [PATCH v3] " Jani Nikula
2014-10-29 21:49     ` Rodrigo Vivi
2014-10-30  8:51       ` Jani Nikula [this message]
2014-10-30 17:54     ` Rodrigo Vivi
2014-10-31  9:12       ` Jani Nikula
2014-11-03 12:09         ` Daniel Vetter
2014-11-04  8:30           ` [PATCH v4] " Jani Nikula
2014-11-04 23:15             ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 12/18] drm/i915/audio: rewrite vlv/chv and gen 5-7 audio codec enable sequence Jani Nikula
2014-10-28 12:04   ` [PATCH v3] " Jani Nikula
2014-10-30 18:04     ` Rodrigo Vivi
2014-10-31  9:17       ` Jani Nikula
2014-11-04  8:31         ` [PATCH v4] " Jani Nikula
2014-11-05  9:25           ` Daniel Vetter
     [not found]           ` <CABVU7+uFMsMDa5mnXmDmQzGOYq5ict_aTLROXjyz8v4qOJrEog@mail.gmail.com>
2014-11-05 10:41             ` Jani Nikula
2014-11-05 12:31               ` Daniel Vetter
2014-10-27 14:26 ` [PATCH v2 13/18] drm/i915/audio: add vlv/chv/gen5-7 audio codec disable sequence Jani Nikula
2014-10-30 18:59   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 14/18] drm/i915: enable audio codec after port Jani Nikula
2014-10-30 19:03   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 15/18] drm/i915/audio: add audio codec disable on g4x Jani Nikula
2014-10-30 19:10   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 16/18] drm/i915/audio: add audio codec enable debug log for g4x Jani Nikula
2014-10-27 18:37   ` Rodrigo Vivi
2014-10-27 14:26 ` [PATCH v2 17/18] drm/i915: make pipe/port based audio valid accessors easier to use Jani Nikula
2014-10-27 18:39   ` Rodrigo Vivi
2014-10-27 14:27 ` [PATCH v2 18/18] drm/i915/audio: add DOC comment describing HDA over HDMI/DP Jani Nikula
2014-10-27 18:40   ` Rodrigo Vivi
2014-10-28 14:20 ` [PATCH 1/2] drm/edid: add #defines and helpers for ELD Jani Nikula
2014-10-28 14:20   ` [PATCH 2/2] drm/edid: fix Baseline_ELD_Len field in drm_edid_to_eld() Jani Nikula
2014-11-05 15:37     ` Rodrigo Vivi
2014-11-10 13:39     ` Daniel Vetter
     [not found]       ` <CAKMK7uF0EFz5DDTJJS9KJ405vgH=FQS5d3FT3spTYp9XxCr-UQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-10 22:38         ` Ben Skeggs
2014-11-10 23:13     ` Daniel Vetter
2014-11-04 23:53   ` [PATCH 1/2] drm/edid: add #defines and helpers for ELD Rodrigo Vivi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877fzij5yf.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox