diff mbox

[v3,3/4] ALSA: hda - display audio call sync_audio_rate callback

Message ID 1439808001-132727-3-git-send-email-libin.yang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yang, Libin Aug. 17, 2015, 10:40 a.m. UTC
From: Libin Yang <libin.yang@intel.com>

For display audio, call the sync_audio_rate callback function
to do the synchronization between gfx driver and audio driver.

Signed-off-by: Libin Yang <libin.yang@intel.com>
---
 sound/pci/hda/patch_hdmi.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Takashi Iwai Aug. 17, 2015, 12:26 p.m. UTC | #1
On Mon, 17 Aug 2015 12:40:00 +0200,
libin.yang@intel.com wrote:
> 
> From: Libin Yang <libin.yang@intel.com>
> 
> For display audio, call the sync_audio_rate callback function
> to do the synchronization between gfx driver and audio driver.
> 
> Signed-off-by: Libin Yang <libin.yang@intel.com>

I guess it would be easier to take this series from drm tree.
Feel free to my ack
  Reviewed-by: Takashi Iwai <tiwai@suse.de>


thanks,

Takashi


> ---
>  sound/pci/hda/patch_hdmi.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
> index a97db5f..1668868 100644
> --- a/sound/pci/hda/patch_hdmi.c
> +++ b/sound/pci/hda/patch_hdmi.c
> @@ -1770,6 +1770,16 @@ static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
>  	return non_pcm;
>  }
>  
> +/* There is a fixed mapping between audio pin node and display port
> + * on current Intel platforms:
> + * Pin Widget 5 - PORT B (port = 1 in i915 driver)
> + * Pin Widget 6 - PORT C (port = 2 in i915 driver)
> + * Pin Widget 7 - PORT D (port = 3 in i915 driver)
> + */
> +static int intel_pin2port(hda_nid_t pin_nid)
> +{
> +	return pin_nid - 4;
> +}
>  
>  /*
>   * HDMI callbacks
> @@ -1786,6 +1796,8 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
>  	int pin_idx = hinfo_to_pin_index(codec, hinfo);
>  	struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
>  	hda_nid_t pin_nid = per_pin->pin_nid;
> +	struct snd_pcm_runtime *runtime = substream->runtime;
> +	struct i915_audio_component *acomp = codec->bus->core.audio_component;
>  	bool non_pcm;
>  	int pinctl;
>  
> @@ -1802,6 +1814,13 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
>  		intel_not_share_assigned_cvt(codec, pin_nid, per_pin->mux_idx);
>  	}
>  
> +	/* Call sync_audio_rate to set the N/CTS/M manually if necessary */
> +	/* Todo: add DP1.2 MST audio support later */
> +	if (acomp && acomp->ops && acomp->ops->sync_audio_rate)
> +		acomp->ops->sync_audio_rate(acomp->dev,
> +				intel_pin2port(pin_nid),
> +				runtime->rate);
> +
>  	non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
>  	mutex_lock(&per_pin->lock);
>  	per_pin->channels = substream->runtime->channels;
> -- 
> 1.9.1
>
Yang, Libin Aug. 17, 2015, 2:42 p.m. UTC | #2
Hi Takashi,

> -----Original Message-----
> From: Takashi Iwai [mailto:tiwai@suse.de]
> Sent: Monday, August 17, 2015 8:26 PM
> To: Yang, Libin
> Cc: alsa-devel@alsa-project.org; intel-gfx@lists.freedesktop.org;
> daniel.vetter@ffwll.ch; jani.nikula@linux.intel.com
> Subject: Re: [PATCH v3 3/4] ALSA: hda - display audio call
> sync_audio_rate callback
> 
> On Mon, 17 Aug 2015 12:40:00 +0200,
> libin.yang@intel.com wrote:
> >
> > From: Libin Yang <libin.yang@intel.com>
> >
> > For display audio, call the sync_audio_rate callback function
> > to do the synchronization between gfx driver and audio driver.
> >
> > Signed-off-by: Libin Yang <libin.yang@intel.com>
> 
> I guess it would be easier to take this series from drm tree.
> Feel free to my ack
>   Reviewed-by: Takashi Iwai <tiwai@suse.de>

Get it. Thanks.

Regards,
Libin

> 
> 
> thanks,
> 
> Takashi
> 
> 
> > ---
> >  sound/pci/hda/patch_hdmi.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> > diff --git a/sound/pci/hda/patch_hdmi.c
> b/sound/pci/hda/patch_hdmi.c
> > index a97db5f..1668868 100644
> > --- a/sound/pci/hda/patch_hdmi.c
> > +++ b/sound/pci/hda/patch_hdmi.c
> > @@ -1770,6 +1770,16 @@ static bool
> check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
> >  	return non_pcm;
> >  }
> >
> > +/* There is a fixed mapping between audio pin node and display
> port
> > + * on current Intel platforms:
> > + * Pin Widget 5 - PORT B (port = 1 in i915 driver)
> > + * Pin Widget 6 - PORT C (port = 2 in i915 driver)
> > + * Pin Widget 7 - PORT D (port = 3 in i915 driver)
> > + */
> > +static int intel_pin2port(hda_nid_t pin_nid)
> > +{
> > +	return pin_nid - 4;
> > +}
> >
> >  /*
> >   * HDMI callbacks
> > @@ -1786,6 +1796,8 @@ static int
> generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
> >  	int pin_idx = hinfo_to_pin_index(codec, hinfo);
> >  	struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
> >  	hda_nid_t pin_nid = per_pin->pin_nid;
> > +	struct snd_pcm_runtime *runtime = substream->runtime;
> > +	struct i915_audio_component *acomp = codec->bus-
> >core.audio_component;
> >  	bool non_pcm;
> >  	int pinctl;
> >
> > @@ -1802,6 +1814,13 @@ static int
> generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
> >  		intel_not_share_assigned_cvt(codec, pin_nid, per_pin-
> >mux_idx);
> >  	}
> >
> > +	/* Call sync_audio_rate to set the N/CTS/M manually if
> necessary */
> > +	/* Todo: add DP1.2 MST audio support later */
> > +	if (acomp && acomp->ops && acomp->ops->sync_audio_rate)
> > +		acomp->ops->sync_audio_rate(acomp->dev,
> > +				intel_pin2port(pin_nid),
> > +				runtime->rate);
> > +
> >  	non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
> >  	mutex_lock(&per_pin->lock);
> >  	per_pin->channels = substream->runtime->channels;
> > --
> > 1.9.1
> >
diff mbox

Patch

diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index a97db5f..1668868 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1770,6 +1770,16 @@  static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
 	return non_pcm;
 }
 
+/* There is a fixed mapping between audio pin node and display port
+ * on current Intel platforms:
+ * Pin Widget 5 - PORT B (port = 1 in i915 driver)
+ * Pin Widget 6 - PORT C (port = 2 in i915 driver)
+ * Pin Widget 7 - PORT D (port = 3 in i915 driver)
+ */
+static int intel_pin2port(hda_nid_t pin_nid)
+{
+	return pin_nid - 4;
+}
 
 /*
  * HDMI callbacks
@@ -1786,6 +1796,8 @@  static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
 	int pin_idx = hinfo_to_pin_index(codec, hinfo);
 	struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
 	hda_nid_t pin_nid = per_pin->pin_nid;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct i915_audio_component *acomp = codec->bus->core.audio_component;
 	bool non_pcm;
 	int pinctl;
 
@@ -1802,6 +1814,13 @@  static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
 		intel_not_share_assigned_cvt(codec, pin_nid, per_pin->mux_idx);
 	}
 
+	/* Call sync_audio_rate to set the N/CTS/M manually if necessary */
+	/* Todo: add DP1.2 MST audio support later */
+	if (acomp && acomp->ops && acomp->ops->sync_audio_rate)
+		acomp->ops->sync_audio_rate(acomp->dev,
+				intel_pin2port(pin_nid),
+				runtime->rate);
+
 	non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
 	mutex_lock(&per_pin->lock);
 	per_pin->channels = substream->runtime->channels;