All of lore.kernel.org
 help / color / mirror / Atom feed
From: jeeja.kp@intel.com
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, patches.audio@intel.com, broonie@kernel.org,
	liam.r.girdwood@intel.com, Jeeja KP <jeeja.kp@intel.com>
Subject: [PATCH 04/30] ASoC: hdac_hdmi: Move channel info from pin to PCM structure
Date: Mon, 16 Jan 2017 23:27:31 +0530	[thread overview]
Message-ID: <1484589477-7630-5-git-send-email-jeeja.kp@intel.com> (raw)
In-Reply-To: <1484589477-7630-1-git-send-email-jeeja.kp@intel.com>

From: Jeeja KP <jeeja.kp@intel.com>

Channel info is part of the pcm parameter and channel map control is
created for each pcm. So move channel info to pcm instead of pin
structure and the mutex lock to pcm.

Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
---
 sound/soc/codecs/hdac_hdmi.c | 76 ++++++++++++++++++++------------------------
 1 file changed, 34 insertions(+), 42 deletions(-)

diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index c0b49f4..2a370d6 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -85,10 +85,6 @@ struct hdac_hdmi_pin {
 	hda_nid_t mux_nids[HDA_MAX_CONNECTIONS];
 	struct hdac_hdmi_eld eld;
 	struct hdac_ext_device *edev;
-	struct mutex lock;
-	bool chmap_set;
-	unsigned char chmap[8]; /* ALSA API channel-map */
-	int channels; /* current number of channels */
 };
 
 struct hdac_hdmi_pcm {
@@ -100,6 +96,9 @@ struct hdac_hdmi_pcm {
 	int stream_tag;
 	int channels;
 	int format;
+	bool chmap_set;
+	unsigned char chmap[8]; /* ALSA API channel-map */
+	struct mutex lock;
 };
 
 struct hdac_hdmi_dai_pin_map {
@@ -217,13 +216,13 @@ struct dp_audio_infoframe {
 };
 
 static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *hdac,
-				hda_nid_t cvt_nid, hda_nid_t pin_nid)
+		   struct hdac_hdmi_pcm *pcm, struct hdac_hdmi_pin *pin)
 {
 	uint8_t buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE];
 	struct hdmi_audio_infoframe frame;
 	struct dp_audio_infoframe dp_ai;
 	struct hdac_hdmi_priv *hdmi = hdac->private_data;
-	struct hdac_hdmi_pin *pin;
+	struct hdac_hdmi_cvt *cvt = pcm->cvt;
 	u8 *dip;
 	int ret;
 	int i;
@@ -231,19 +230,14 @@ static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *hdac,
 	u8 conn_type;
 	int channels, ca;
 
-	list_for_each_entry(pin, &hdmi->pin_list, head) {
-		if (pin->nid == pin_nid)
-			break;
-	}
-
 	ca = snd_hdac_channel_allocation(&hdac->hdac, pin->eld.info.spk_alloc,
-			pin->channels, pin->chmap_set, true, pin->chmap);
+			pcm->channels, pcm->chmap_set, true, pcm->chmap);
 
 	channels = snd_hdac_get_active_channels(ca);
-	hdmi->chmap.ops.set_channel_count(&hdac->hdac, cvt_nid, channels);
+	hdmi->chmap.ops.set_channel_count(&hdac->hdac, cvt->nid, channels);
 
 	snd_hdac_setup_channel_mapping(&hdmi->chmap, pin->nid, false, ca,
-				pin->channels, pin->chmap, pin->chmap_set);
+				pcm->channels, pcm->chmap, pcm->chmap_set);
 
 	eld_buf = pin->eld.eld_buffer;
 	conn_type = drm_eld_get_conn_type(eld_buf);
@@ -279,26 +273,26 @@ static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *hdac,
 	}
 
 	/* stop infoframe transmission */
-	hdac_hdmi_set_dip_index(hdac, pin_nid, 0x0, 0x0);
-	snd_hdac_codec_write(&hdac->hdac, pin_nid, 0,
+	hdac_hdmi_set_dip_index(hdac, pin->nid, 0x0, 0x0);
+	snd_hdac_codec_write(&hdac->hdac, pin->nid, 0,
 			AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_DISABLE);
 
 
 	/*  Fill infoframe. Index auto-incremented */
-	hdac_hdmi_set_dip_index(hdac, pin_nid, 0x0, 0x0);
+	hdac_hdmi_set_dip_index(hdac, pin->nid, 0x0, 0x0);
 	if (conn_type == DRM_ELD_CONN_TYPE_HDMI) {
 		for (i = 0; i < sizeof(buffer); i++)
-			snd_hdac_codec_write(&hdac->hdac, pin_nid, 0,
+			snd_hdac_codec_write(&hdac->hdac, pin->nid, 0,
 				AC_VERB_SET_HDMI_DIP_DATA, buffer[i]);
 	} else {
 		for (i = 0; i < sizeof(dp_ai); i++)
-			snd_hdac_codec_write(&hdac->hdac, pin_nid, 0,
+			snd_hdac_codec_write(&hdac->hdac, pin->nid, 0,
 				AC_VERB_SET_HDMI_DIP_DATA, dip[i]);
 	}
 
 	/* Start infoframe */
-	hdac_hdmi_set_dip_index(hdac, pin_nid, 0x0, 0x0);
-	snd_hdac_codec_write(&hdac->hdac, pin_nid, 0,
+	hdac_hdmi_set_dip_index(hdac, pin->nid, 0x0, 0x0);
+	snd_hdac_codec_write(&hdac->hdac, pin->nid, 0,
 			AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_BEST);
 
 	return 0;
@@ -476,18 +470,22 @@ static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream,
 	struct hdac_ext_device *hdac = snd_soc_dai_get_drvdata(dai);
 	struct hdac_hdmi_priv *hdmi = hdac->private_data;
 	struct hdac_hdmi_dai_pin_map *dai_map;
+	struct hdac_hdmi_pcm *pcm;
 
 	dai_map = &hdmi->dai_map[dai->id];
 
-	if (dai_map->pin) {
-		mutex_lock(&dai_map->pin->lock);
-		dai_map->pin->chmap_set = false;
-		memset(dai_map->pin->chmap, 0, sizeof(dai_map->pin->chmap));
-		dai_map->pin->channels = 0;
-		mutex_unlock(&dai_map->pin->lock);
+	pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt);
 
-		dai_map->pin = NULL;
+	if (pcm) {
+		mutex_lock(&pcm->lock);
+		pcm->chmap_set = false;
+		memset(pcm->chmap, 0, sizeof(pcm->chmap));
+		pcm->channels = 0;
+		mutex_unlock(&pcm->lock);
 	}
+
+	if (dai_map->pin)
+		dai_map->pin = NULL;
 }
 
 static int
@@ -611,8 +609,7 @@ static int hdac_hdmi_pin_output_widget_event(struct snd_soc_dapm_widget *w,
 
 		hdac_hdmi_set_amp(edev, pin->nid, AMP_OUT_UNMUTE);
 
-		return hdac_hdmi_setup_audio_infoframe(edev, pcm->cvt->nid,
-								pin->nid);
+		return hdac_hdmi_setup_audio_infoframe(edev, pcm, pin);
 
 	case SND_SOC_DAPM_POST_PMD:
 		hdac_hdmi_set_amp(edev, pin->nid, AMP_OUT_MUTE);
@@ -1110,7 +1107,6 @@ static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid)
 	hdmi->num_pin++;
 
 	pin->edev = edev;
-	mutex_init(&pin->lock);
 
 	return 0;
 }
@@ -1361,6 +1357,7 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device)
 		return -ENOMEM;
 	pcm->pcm_id = device;
 	pcm->cvt = hdmi->dai_map[dai->id].cvt;
+	mutex_init(&pcm->lock);
 
 	snd_pcm = hdac_hdmi_get_pcm_from_id(dai->component->card, device);
 	if (snd_pcm) {
@@ -1506,13 +1503,8 @@ static void hdac_hdmi_get_chmap(struct hdac_device *hdac, int pcm_idx,
 	struct hdac_ext_device *edev = to_ehdac_device(hdac);
 	struct hdac_hdmi_priv *hdmi = edev->private_data;
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
-	struct hdac_hdmi_pin *pin = pcm->pin;
-
-	/* chmap is already set to 0 in caller */
-	if (!pin)
-		return;
 
-	memcpy(chmap, pin->chmap, ARRAY_SIZE(pin->chmap));
+	memcpy(chmap, pcm->chmap, ARRAY_SIZE(pcm->chmap));
 }
 
 static void hdac_hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
@@ -1523,12 +1515,12 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx,
 	struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx);
 	struct hdac_hdmi_pin *pin = pcm->pin;
 
-	mutex_lock(&pin->lock);
-	pin->chmap_set = true;
-	memcpy(pin->chmap, chmap, ARRAY_SIZE(pin->chmap));
+	mutex_lock(&pcm->lock);
+	pcm->chmap_set = true;
+	memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap));
 	if (prepared)
-		hdac_hdmi_setup_audio_infoframe(edev, pcm->cvt->nid, pin->nid);
-	mutex_unlock(&pin->lock);
+		hdac_hdmi_setup_audio_infoframe(edev, pcm, pin);
+	mutex_unlock(&pcm->lock);
 }
 
 static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)
-- 
2.5.0

  parent reply	other threads:[~2017-01-16 17:47 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 17:57 [PATCH 00/30] ASoC: hdac_hdmi: Add support to enable MST audio jeeja.kp
2017-01-16 17:57 ` [PATCH 01/30] ASoC: hdac_hdmi: use audio component framework to read ELD jeeja.kp
2017-01-20 13:37   ` Applied "ASoC: hdac_hdmi: use audio component framework to read ELD" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 02/30] ASoC: hdac_hdmi: Register widget event handlers jeeja.kp
2017-01-16 17:57 ` [PATCH 03/30] ASoC: Intel: Skylake: Use set_tdm_slot to set the dma channel jeeja.kp
2017-01-24 18:40   ` Applied "ASoC: Intel: Skylake: Use set_tdm_slot to set the dma channel" to the asoc tree Mark Brown
2017-01-16 17:57 ` jeeja.kp [this message]
2017-02-04 12:12   ` Applied "ASoC: hdac_hdmi: Move channel info from pin to PCM structure" " Mark Brown
2017-01-16 17:57 ` [PATCH 05/30] ASoC: Intel: bxt: add channel map support in rt298 machine jeeja.kp
2017-02-04 12:12   ` Applied "ASoC: Intel: bxt: add channel map support in rt298 machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 06/30] ASoC: Intel: bxt: add channel map support in bxt_da7219_max98357a machine jeeja.kp
2017-02-04 12:12   ` Applied "ASoC: Intel: bxt: add channel map support in bxt_da7219_max98357a machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 07/30] ASoC: hdac_hdmi: Begin to add support for DP Multi-stream audio jeeja.kp
2017-01-16 17:57 ` [PATCH 08/30] ASoC: Intel: Skylake: Add route change to rt286 machine jeeja.kp
2017-01-16 17:57 ` [PATCH 09/30] ASoC: Intel: Skylake: Add route change to nau88l25_max98357a machine jeeja.kp
2017-01-16 17:57 ` [PATCH 10/30] ASoC: Intel: Skylake: Add route change to nau88l25_ssm4567 machine jeeja.kp
2017-01-16 17:57 ` [PATCH 11/30] ASoC: Intel: bxt: Add route change to rt298 machine jeeja.kp
2017-01-16 17:57 ` [PATCH 12/30] ASoC: Intel: bxt: Add route change to da7219_max98357a machine jeeja.kp
2017-01-16 17:57 ` [PATCH 13/30] ASoC: hdac_hdmi: Add support to handle MST capable pin jeeja.kp
2017-01-16 17:57 ` [PATCH 14/30] ASoC: hdac_hdmi: Add MST verb support jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: hdac_hdmi: Add MST verb support" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 15/30] ASoC: hdac_hdmi: Handle MST pin jack detection at boot/resume jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: hdac_hdmi: Handle MST pin jack detection at boot/resume" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 16/30] ASoc: hdac_hdmi: Configure pin verbs for MST jeeja.kp
2017-02-16 19:04   ` Applied "ASoc: hdac_hdmi: Configure pin verbs for MST" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 17/30] ASoC: hdac_hdmi: Add support for multiple ports to a PCM jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: hdac_hdmi: Add support for multiple ports to a PCM" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 18/30] ASoC: hdac_hdmi: Use ASoC jack instead of snd_jack jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: hdac_hdmi: Use ASoC jack instead of snd_jack" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 19/30] ASoC: Intel: Skylake: Create ASoC jack for hdmi in rt286 machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: Skylake: Create ASoC jack for hdmi in rt286 machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 20/30] ASoC: Intel: Skylake: Create ASoC jack for hdmi in skl_nau88l25_max98357a machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: Skylake: Create ASoC jack for hdmi in skl_nau88l25_max98357a machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 21/30] ASoC: Intel: Skylake: Create ASoC jack for hdmi in skl_nau88l25_ssm4567 machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: Skylake: Create ASoC jack for hdmi in nau88l25_ssm4567 machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 22/30] ASoC: Intel: bxt: Create ASoC jack for hdmi in bxt_rt298 machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: bxt: Create ASoC jack for hdmi in bxt_rt298 machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 23/30] ASoC: Intel: bxt: Create ASoC jack for hdmi in bxt_da7219_max98357 machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: bxt: Create ASoC jack for hdmi in bxt_da7219_max98357 machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 24/30] ASoC: hdac_hdmi: Add machine pin widget for each port jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: hdac_hdmi: Add machine pin widget for each port" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 25/30] ASoC: Intel: Skylake: Add jack port initialize in rt286 machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: Skylake: Add jack port initialize in rt286 machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 26/30] ASoC: Intel: Skylake: Add jack port initialize in skl_nau88l25_max98357a machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: Skylake: Add jack port initialize in nau88l25_max98357a machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 27/30] ASoC: Intel: Skylake: Add jack port initialize in skl_nau88l25_ssm4567 machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: Skylake: Add jack port initialize in nau88l25_ssm4567 machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 28/30] ASoC: Intel: Skylake: Add jack port initialize in bxt_rt298 machine jeeja.kp
2017-02-17 13:22   ` Applied "ASoC: Intel: bxt: Add jack port initialize in bxt_rt298 machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 29/30] ASoC: Intel: Skylake: Add jack port initialize in bxt_da7219_max98357a machine jeeja.kp
2017-02-16 19:04   ` Applied "ASoC: Intel: bxt: Add jack port initialize in da7219_max98357a machine" to the asoc tree Mark Brown
2017-01-16 17:57 ` [PATCH 30/30] ASoC: Intel: Skylake: Fix to delete DSP pipe after stopping pipe jeeja.kp
2017-03-15 18:13   ` Applied "ASoC: Intel: Skylake: Fix to delete DSP pipe after stopping pipe" to the asoc tree Mark Brown
2017-01-17 17:54 ` [PATCH 00/30] ASoC: hdac_hdmi: Add support to enable MST audio Mark Brown
2017-01-18 12:44   ` Jeeja KP

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=1484589477-7630-5-git-send-email-jeeja.kp@intel.com \
    --to=jeeja.kp@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=liam.r.girdwood@intel.com \
    --cc=patches.audio@intel.com \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.