All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Jerome Anand <jerome.anand@intel.com>
Subject: [PATCH 03/53] ALSA: x86: Drop indirect calls of had_ops
Date: Thu,  2 Feb 2017 18:02:17 +0100	[thread overview]
Message-ID: <20170202170307.24484-5-tiwai@suse.de> (raw)
In-Reply-To: <20170202170307.24484-1-tiwai@suse.de>

We have only a single implementation of had_ops, hence there is no
merit to use the indirect calls at all.  Let's replace it with the
direct calls -- which allows the compiler more optimizations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/x86/intel_hdmi_audio.c    | 85 ++++++++++++++++++-----------------------
 sound/x86/intel_hdmi_audio.h    | 21 ++--------
 sound/x86/intel_hdmi_audio_if.c |  4 +-
 3 files changed, 42 insertions(+), 68 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 1e0bc72a8f63..84ce4e09ada5 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -280,13 +280,12 @@ static int had_read_modify_aud_config_v2(struct snd_pcm_substream *substream,
 	return had_read_modify(AUD_CONFIG, data, mask);
 }
 
-static void snd_intelhad_enable_audio_v2(struct snd_pcm_substream *substream,
-					u8 enable)
+void snd_intelhad_enable_audio(struct snd_pcm_substream *substream, u8 enable)
 {
 	had_read_modify_aud_config_v2(substream, enable, BIT(0));
 }
 
-static void snd_intelhad_reset_audio_v2(u8 reset)
+static void snd_intelhad_reset_audio(u8 reset)
 {
 	had_write_register(AUD_HDMI_STATUS_v2, reset);
 }
@@ -359,13 +358,13 @@ static int had_prog_status_reg(struct snd_pcm_substream *substream,
 	return 0;
 }
 
-/**
+/*
  * function to initialize audio
  * registers and buffer confgiuration registers
  * This function is called in the prepare callback
  */
-static int snd_intelhad_prog_audio_ctrl_v2(struct snd_pcm_substream *substream,
-					struct snd_intelhad *intelhaddata)
+static int snd_intelhad_audio_ctrl(struct snd_pcm_substream *substream,
+				   struct snd_intelhad *intelhaddata)
 {
 	union aud_cfg cfg_val = {.cfg_regval = 0};
 	union aud_buf_config buf_cfg = {.buf_cfgval = 0};
@@ -596,16 +595,16 @@ static int had_register_chmap_ctls(struct snd_intelhad *intelhaddata,
 	return 0;
 }
 
-/**
- * snd_intelhad_prog_dip_v2 - to initialize Data Island Packets registers
+/*
+ * snd_intelhad_prog_dip - to initialize Data Island Packets registers
  *
  * @substream:substream for which the prepare function is called
  * @intelhaddata:substream private data
  *
  * This function is called in the prepare callback
  */
-static void snd_intelhad_prog_dip_v2(struct snd_pcm_substream *substream,
-				struct snd_intelhad *intelhaddata)
+static void snd_intelhad_prog_dip(struct snd_pcm_substream *substream,
+				  struct snd_intelhad *intelhaddata)
 {
 	int i;
 	union aud_ctrl_st ctrl_state = {.ctrl_val = 0};
@@ -815,8 +814,8 @@ static int had_calculate_maud_value(u32 aud_samp_freq, u32 link_rate)
 	return maud_val;
 }
 
-/**
- * snd_intelhad_prog_cts_v2 - Program HDMI audio CTS value
+/*
+ * snd_intelhad_prog_cts - Program HDMI audio CTS value
  *
  * @aud_samp_freq: sampling frequency of audio data
  * @tmds: sampling frequency of the display data
@@ -825,9 +824,9 @@ static int had_calculate_maud_value(u32 aud_samp_freq, u32 link_rate)
  *
  * Program CTS register based on the audio and display sampling frequency
  */
-static void snd_intelhad_prog_cts_v2(u32 aud_samp_freq, u32 tmds,
-				     u32 link_rate, u32 n_param,
-				     struct snd_intelhad *intelhaddata)
+static void snd_intelhad_prog_cts(u32 aud_samp_freq, u32 tmds,
+				  u32 link_rate, u32 n_param,
+				  struct snd_intelhad *intelhaddata)
 {
 	u32 cts_val;
 	u64 dividend, divisor;
@@ -887,8 +886,8 @@ static int had_calculate_n_value(u32 aud_samp_freq)
 	return n_val;
 }
 
-/**
- * snd_intelhad_prog_n_v2 - Program HDMI audio N value
+/*
+ * snd_intelhad_prog_n - Program HDMI audio N value
  *
  * @aud_samp_freq: sampling frequency of audio data
  * @n_param: N value, depends on aud_samp_freq
@@ -897,8 +896,8 @@ static int had_calculate_n_value(u32 aud_samp_freq)
  * This function is called in the prepare callback.
  * It programs based on the audio and display sampling frequency
  */
-static int snd_intelhad_prog_n_v2(u32 aud_samp_freq, u32 *n_param,
-				struct snd_intelhad *intelhaddata)
+static int snd_intelhad_prog_n(u32 aud_samp_freq, u32 *n_param,
+			       struct snd_intelhad *intelhaddata)
 {
 	s32 n_val;
 
@@ -923,7 +922,7 @@ static int snd_intelhad_prog_n_v2(u32 aud_samp_freq, u32 *n_param,
 	return 0;
 }
 
-static void had_clear_underrun_intr_v2(struct snd_intelhad *intelhaddata)
+void snd_intelhad_handle_underrun(struct snd_intelhad *intelhaddata)
 {
 	u32 hdmi_status, i = 0;
 
@@ -1209,7 +1208,7 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
 		caps = HDMI_AUDIO_BUFFER_DONE;
 		retval = had_set_caps(HAD_SET_ENABLE_AUDIO_INT, &caps);
 		retval = had_set_caps(HAD_SET_ENABLE_AUDIO, NULL);
-		intelhaddata->ops->enable_audio(substream, 1);
+		snd_intelhad_enable_audio(substream, 1);
 
 		pr_debug("Processed _Start\n");
 
@@ -1232,10 +1231,10 @@ static int snd_intelhad_pcm_trigger(struct snd_pcm_substream *substream,
 		 */
 		caps = HDMI_AUDIO_BUFFER_DONE;
 		had_set_caps(HAD_SET_DISABLE_AUDIO_INT, &caps);
-		intelhaddata->ops->enable_audio(substream, 0);
+		snd_intelhad_enable_audio(substream, 0);
 		/* Reset buffer pointers */
-		intelhaddata->ops->reset_audio(1);
-		intelhaddata->ops->reset_audio(0);
+		snd_intelhad_reset_audio(1);
+		snd_intelhad_reset_audio(0);
 		stream->stream_status = STREAM_DROPPED;
 		had_set_caps(HAD_SET_DISABLE_AUDIO, NULL);
 		break;
@@ -1304,8 +1303,8 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream)
 	had_get_caps(HAD_GET_ELD, &intelhaddata->eeld);
 	had_get_caps(HAD_GET_DP_OUTPUT, &intelhaddata->dp_output);
 
-	retval = intelhaddata->ops->prog_n(substream->runtime->rate, &n_param,
-								intelhaddata);
+	retval = snd_intelhad_prog_n(substream->runtime->rate, &n_param,
+				     intelhaddata);
 	if (retval) {
 		pr_err("programming N value failed %#x\n", retval);
 		goto prep_end;
@@ -1315,13 +1314,13 @@ static int snd_intelhad_pcm_prepare(struct snd_pcm_substream *substream)
 		had_get_caps(HAD_GET_LINK_RATE, &link_rate);
 
 
-	intelhaddata->ops->prog_cts(substream->runtime->rate,
-				    disp_samp_freq, link_rate,
-				    n_param, intelhaddata);
+	snd_intelhad_prog_cts(substream->runtime->rate,
+			      disp_samp_freq, link_rate,
+			      n_param, intelhaddata);
 
-	intelhaddata->ops->prog_dip(substream, intelhaddata);
+	snd_intelhad_prog_dip(substream, intelhaddata);
 
-	retval = intelhaddata->ops->audio_ctrl(substream, intelhaddata);
+	retval = snd_intelhad_audio_ctrl(substream, intelhaddata);
 
 	/* Prog buffer address */
 	retval = snd_intelhad_prog_buffer(intelhaddata,
@@ -1431,7 +1430,7 @@ int hdmi_audio_mode_change(struct snd_pcm_substream *substream)
 	intelhaddata = snd_pcm_substream_chip(substream);
 
 	/* Disable Audio */
-	intelhaddata->ops->enable_audio(substream, 0);
+	snd_intelhad_enable_audio(substream, 0);
 
 	/* Update CTS value */
 	retval = had_get_caps(HAD_GET_DISPLAY_RATE, &disp_samp_freq);
@@ -1440,8 +1439,8 @@ int hdmi_audio_mode_change(struct snd_pcm_substream *substream)
 		goto out;
 	}
 
-	retval = intelhaddata->ops->prog_n(substream->runtime->rate, &n_param,
-								intelhaddata);
+	retval = snd_intelhad_prog_n(substream->runtime->rate, &n_param,
+				     intelhaddata);
 	if (retval) {
 		pr_err("programming N value failed %#x\n", retval);
 		goto out;
@@ -1450,12 +1449,12 @@ int hdmi_audio_mode_change(struct snd_pcm_substream *substream)
 	if (intelhaddata->dp_output)
 		had_get_caps(HAD_GET_LINK_RATE, &link_rate);
 
-	intelhaddata->ops->prog_cts(substream->runtime->rate,
-				    disp_samp_freq, link_rate,
-				    n_param, intelhaddata);
+	snd_intelhad_prog_cts(substream->runtime->rate,
+			      disp_samp_freq, link_rate,
+			      n_param, intelhaddata);
 
 	/* Enable Audio */
-	intelhaddata->ops->enable_audio(substream, 1);
+	snd_intelhad_enable_audio(substream, 1);
 
 out:
 	return retval;
@@ -1582,15 +1581,6 @@ static struct snd_intel_had_interface had_interface = {
 	.resume =       hdmi_audio_resume,
 };
 
-static struct had_ops had_ops_v2 = {
-	.enable_audio = snd_intelhad_enable_audio_v2,
-	.reset_audio = snd_intelhad_reset_audio_v2,
-	.prog_n =	snd_intelhad_prog_n_v2,
-	.prog_cts =	snd_intelhad_prog_cts_v2,
-	.audio_ctrl =	snd_intelhad_prog_audio_ctrl_v2,
-	.prog_dip =	snd_intelhad_prog_dip_v2,
-	.handle_underrun = had_clear_underrun_intr_v2,
-};
 /**
  * hdmi_audio_probe - to create sound card instance for HDMI audio playabck
  *
@@ -1731,7 +1721,6 @@ int hdmi_audio_probe(void *deviceptr)
 	}
 
 	intelhaddata->hw_silence = 1;
-	intelhaddata->ops = &had_ops_v2;
 
 	return retval;
 err:
diff --git a/sound/x86/intel_hdmi_audio.h b/sound/x86/intel_hdmi_audio.h
index 034b3873ffa1..394959f0bd2e 100644
--- a/sound/x86/intel_hdmi_audio.h
+++ b/sound/x86/intel_hdmi_audio.h
@@ -123,7 +123,6 @@ struct had_callback_ops {
  * @chmap: holds channel map info
  * @audio_reg_base: hdmi audio register base offset
  * @hw_silence: flag indicates SoC support for HW silence/Keep alive
- * @ops: holds ops functions based on platform
  */
 struct snd_intelhad {
 	struct snd_card	*card;
@@ -149,25 +148,8 @@ struct snd_intelhad {
 	unsigned int	*audio_reg_base;
 	unsigned int	audio_cfg_offset;
 	bool		hw_silence;
-	struct had_ops	*ops;
 };
 
-struct had_ops {
-	void (*enable_audio)(struct snd_pcm_substream *substream,
-			u8 enable);
-	void (*reset_audio)(u8 reset);
-	int (*prog_n)(u32 aud_samp_freq, u32 *n_param,
-			struct snd_intelhad *intelhaddata);
-	void (*prog_cts)(u32 aud_samp_freq, u32 tmds, u32 link_rate,
-			 u32 n_param, struct snd_intelhad *intelhaddata);
-	int (*audio_ctrl)(struct snd_pcm_substream *substream,
-				struct snd_intelhad *intelhaddata);
-	void (*prog_dip)(struct snd_pcm_substream *substream,
-				struct snd_intelhad *intelhaddata);
-	void (*handle_underrun)(struct snd_intelhad *intelhaddata);
-};
-
-
 int had_event_handler(enum had_event_type event_type, void *data);
 
 int hdmi_audio_query(void *drv_data, struct hdmi_audio_event event);
@@ -185,6 +167,9 @@ int snd_intelhad_invd_buffer(int start, int end);
 int snd_intelhad_read_len(struct snd_intelhad *intelhaddata);
 void had_build_channel_allocation_map(struct snd_intelhad *intelhaddata);
 
+void snd_intelhad_enable_audio(struct snd_pcm_substream *substream, u8 enable);
+void snd_intelhad_handle_underrun(struct snd_intelhad *intelhaddata);
+
 /* Register access functions */
 int had_get_hwstate(struct snd_intelhad *intelhaddata);
 int had_get_caps(enum had_caps_list query_element, void *capabilties);
diff --git a/sound/x86/intel_hdmi_audio_if.c b/sound/x86/intel_hdmi_audio_if.c
index 30b4b25acb24..d92fe48d916b 100644
--- a/sound/x86/intel_hdmi_audio_if.c
+++ b/sound/x86/intel_hdmi_audio_if.c
@@ -349,7 +349,7 @@ int had_process_buffer_underrun(struct snd_intelhad *intelhaddata)
 	pr_debug("Enter:%s buf_id=%d, stream_type=%d\n",
 			__func__, buf_id, stream_type);
 
-	intelhaddata->ops->handle_underrun(intelhaddata);
+	snd_intelhad_handle_underrun(intelhaddata);
 
 	if (drv_status == HAD_DRV_DISCONNECTED) {
 		pr_err("%s:Device already disconnected\n", __func__);
@@ -451,7 +451,7 @@ int had_process_hot_unplug(struct snd_intelhad *intelhaddata)
 		caps = HDMI_AUDIO_BUFFER_DONE;
 		retval = had_set_caps(HAD_SET_DISABLE_AUDIO_INT, &caps);
 		retval = had_set_caps(HAD_SET_DISABLE_AUDIO, NULL);
-		intelhaddata->ops->enable_audio(
+		snd_intelhad_enable_audio(
 			intelhaddata->stream_info.had_substream, 0);
 	}
 
-- 
2.11.0

  parent reply	other threads:[~2017-02-02 17:03 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 17:02 [PATCH 00/53] Intel LPE audio driver cleanups Takashi Iwai
2017-02-02 17:02 ` [PATCH 01/53] ALSA: x86: Don't set PCM state to DISCONNECTED Takashi Iwai
2017-02-02 17:02 ` [PATCH] drm/i915: Enable VLV audio chicken bit for LPE audio Takashi Iwai
2017-02-02 17:07   ` Takashi Iwai
2017-02-02 17:02 ` [PATCH 02/53] ALSA: x86: Remove v1 ops and structs Takashi Iwai
2017-02-02 17:02 ` Takashi Iwai [this message]
2017-02-02 17:02 ` [PATCH 04/53] ALSA: x86: Replace indirect register ops with direct calls Takashi Iwai
2017-02-02 17:02 ` [PATCH 05/53] ALSA: x86: Replace indirect query_ops " Takashi Iwai
2017-02-02 17:02 ` [PATCH 06/53] ALSA: x86: Drop snd_intel_had_interface indirect calls Takashi Iwai
2017-02-02 17:02 ` [PATCH 07/53] ALSA: x86: Pass snd_intelhad object to helpers Takashi Iwai
2017-02-02 17:02 ` [PATCH 08/53] ALSA: x86: Handle the error from hdmi_audio_probe() properly Takashi Iwai
2017-02-02 17:02 ` [PATCH 09/53] ALSA: x86: Drop useless mutex at probe Takashi Iwai
2017-02-02 17:02 ` [PATCH 10/53] ALSA: x86: Call event callback directly Takashi Iwai
2017-02-02 17:02 ` [PATCH 11/53] ALSA: x86: Fix possible stale interrupt calls Takashi Iwai
2017-02-02 17:02 ` [PATCH 12/53] ALSA: x86: Drop unused mid_hdmi_audio_is_busy() Takashi Iwai
2017-02-02 17:02 ` [PATCH 13/53] ALSA: x86: Drop the global platform device reference Takashi Iwai
2017-02-02 17:02 ` [PATCH 14/53] ALSA: x86: Drop global hlpe_state Takashi Iwai
2017-02-02 17:02 ` [PATCH 15/53] ALSA: x86: Drop global ELD copy Takashi Iwai
2017-02-02 17:02 ` [PATCH 16/53] ALSA: x86: Move the global underrun_count to struct snd_intelhad Takashi Iwai
2017-02-02 17:02 ` [PATCH 17/53] ALSA: x86: Drop unused hw_silence field Takashi Iwai
2017-02-02 19:11   ` Pierre-Louis Bossart
2017-02-02 20:04     ` Takashi Iwai
2017-02-02 20:26       ` Pierre-Louis Bossart
2017-02-03  4:25         ` Ughreja, Rakesh A
2017-02-02 17:02 ` [PATCH 18/53] ALSA: x86: Move dma_mask debug print into intel_hdmi_lpe_audio.c Takashi Iwai
2017-02-02 17:02 ` [PATCH 19/53] ALSA: x86: Embed snd_intelhad into snd_card Takashi Iwai
2017-02-02 17:02 ` [PATCH 20/53] ALSA: x86: Drop superfluous CHT PCI ID check Takashi Iwai
2017-02-02 17:02 ` [PATCH 21/53] ALSA: x86: Check platform_data earlier Takashi Iwai
2017-02-02 17:02 ` [PATCH 22/53] ALSA: x86: Call snd_card_register() at the end Takashi Iwai
2017-02-02 17:02 ` [PATCH 23/53] ALSA: x86: Drop unused hdmi_audio_query() Takashi Iwai
2017-02-02 17:02 ` [PATCH 24/53] ALSA: x86: Flatten two abstraction layers Takashi Iwai
2017-02-02 17:02 ` [PATCH 25/53] ALSA: x86: Fold intel_hdmi_audio_if.c into main file Takashi Iwai
2017-02-02 17:02 ` [PATCH 26/53] ALSA: x86: Replace pr_xxx() with dev_xxx() Takashi Iwai
2017-02-02 17:02 ` [PATCH 27/53] ALSA: x86: Fix for CONFIG_PM=n Takashi Iwai
2017-02-02 17:02 ` [PATCH 28/53] ALSA: x86: Remove indirect call of snd_pcm_period_elapsed() Takashi Iwai
2017-02-02 17:02 ` [PATCH 29/53] ALSA: x86: Drop unused fields from snd_intelhad struct Takashi Iwai
2017-02-02 17:02 ` [PATCH 30/53] ALSA: x86: Drop superfluous PCM private_free Takashi Iwai
2017-02-02 17:02 ` [PATCH 31/53] ALSA: x86: Fix sleep-in-atomic via i915 notification Takashi Iwai
2017-02-02 17:02 ` [PATCH 32/53] ALSA: x86: Remove superfluous check at resume Takashi Iwai
2017-02-02 17:02 ` [PATCH 33/53] ALSA: x86: Drop had_get_hwstate() Takashi Iwai
2017-02-02 17:02 ` [PATCH 34/53] ALSA: x86: Tidy up codes Takashi Iwai
2017-02-02 17:02 ` [PATCH 35/53] ALSA: x86: Remove _v[12] suffices Takashi Iwai
2017-02-02 17:02 ` [PATCH 36/53] ALSA: x86: Constfy tables Takashi Iwai
2017-02-02 17:02 ` [PATCH 37/53] ALSA: x86: Remove superfluous irqsave flags Takashi Iwai
2017-02-02 17:02 ` [PATCH 38/53] ALSA: x86: Fix racy access to chmap Takashi Iwai
2017-02-02 17:02 ` [PATCH 39/53] ALSA: x86: Drop flag_underrun field Takashi Iwai
2017-02-02 17:02 ` [PATCH 40/53] ALSA: x86: Drop superfluous state field Takashi Iwai
2017-02-02 17:02 ` [PATCH 41/53] ALSA: x86: Drop redundant had_stream_pvt Takashi Iwai
2017-02-02 17:02 ` [PATCH 42/53] ALSA: x86: Drop unused fields from pcm_stream_info Takashi Iwai
2017-02-02 17:02 ` [PATCH 43/53] ALSA: x86: Properly manage PCM substream lifetype Takashi Iwai
2017-02-02 17:02 ` [PATCH 44/53] ALSA: x86: Implement runtime PM Takashi Iwai
2017-02-02 17:02 ` [PATCH 45/53] ALSA: x86: Move stream status into pcm_stream_info Takashi Iwai
2017-02-02 17:03 ` [PATCH 46/53] ALSA: x86: Use the standard ELD bytes definitions Takashi Iwai
2017-02-02 17:03 ` [PATCH 47/53] ALSA: x86: Reduce redundant register field names Takashi Iwai
2017-02-02 17:03 ` [PATCH 48/53] ALSA: x86: Clean up unused defines and inclusions Takashi Iwai
2017-02-02 17:03 ` [PATCH 49/53] ALSA: x86: Create ELD control element Takashi Iwai
2017-02-02 17:03 ` [PATCH 50/53] ALSA: x86: Set CA bits for DisplayPort too Takashi Iwai
2017-02-02 17:03 ` [PATCH 51/53] ALSA: x86: Simplify comments Takashi Iwai
2017-02-02 17:03 ` [PATCH 52/53] ALSA: x86: Yet more tidy-up and clean-ups Takashi Iwai
2017-02-02 17:03 ` [PATCH 53/53] ALSA: x86: Rename drv_status to connected Takashi Iwai

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=20170202170307.24484-5-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=jerome.anand@intel.com \
    --cc=pierre-louis.bossart@linux.intel.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 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.