diff mbox series

[2/4] ALSA: hda: Introduce HOST stream setup mechanism

Message ID 20230925115844.18795-3-cezary.rojewski@intel.com (mailing list archive)
State Superseded
Headers show
Series ALSA: hda: Abstract and update HOST-stream setup procedure | expand

Commit Message

Cezary Rojewski Sept. 25, 2023, 11:58 a.m. UTC
HDAudio stream setup procedure differs between revisions of the
controller device. Currently the differences are handled directly within
AudioDSP platform drivers with if-statements. Implement a more generic
approach and expose a function that a platform driver may use to ensure
the correct procedure is followed each time.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 include/sound/hdaudio_ext.h     |  3 +++
 sound/hda/ext/hdac_ext_stream.c | 41 +++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

Comments

Cezary Rojewski Sept. 25, 2023, 12:36 p.m. UTC | #1
On 2023-09-25 1:58 PM, Cezary Rojewski wrote:
> HDAudio stream setup procedure differs between revisions of the
> controller device. Currently the differences are handled directly within
> AudioDSP platform drivers with if-statements. Implement a more generic
> approach and expose a function that a platform driver may use to ensure
> the correct procedure is followed each time.

...

> @@ -55,9 +88,16 @@ static void snd_hdac_ext_stream_init(struct hdac_bus *bus,
>   int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
>   				 int num_stream, int dir)
>   {
> +	struct pci_dev *pci = to_pci_dev(bus->dev);
> +	int (*setup_op)(struct hdac_stream *);
>   	int stream_tag = 0;
>   	int i, tag, idx = start_idx;
>   
> +	if (pci->device == PCI_DEVICE_ID_INTEL_HDA_APL)
> +		setup_op = snd_hdac_stream_setup;
> +	else
> +		setup_op = snd_hdac_apl_host_stream_setup;

Sorry for this, due to renaming I did send incorrect revision of 
patchset. The if-statement was "negative" previously. Will send v2.

>   	for (i = 0; i < num_stream; i++) {
>   		struct hdac_ext_stream *hext_stream =
>   				kzalloc(sizeof(*hext_stream), GFP_KERNEL);
> @@ -66,6 +106,7 @@ int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
>   		tag = ++stream_tag;
>   		snd_hdac_ext_stream_init(bus, hext_stream, idx, dir, tag);
>   		idx++;
> +		hext_stream->host_setup = setup_op;
>   	}
>   
>   	return 0;
kernel test robot Sept. 25, 2023, 2:22 p.m. UTC | #2
Hi Cezary,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus broonie-sound/for-next linus/master v6.6-rc3 next-20230925]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Cezary-Rojewski/ALSA-hda-Poll-SDxFIFOS-after-programming-SDxFMT/20230925-200351
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20230925115844.18795-3-cezary.rojewski%40intel.com
patch subject: [PATCH 2/4] ALSA: hda: Introduce HOST stream setup mechanism
config: x86_64-buildonly-randconfig-002-20230925 (https://download.01.org/0day-ci/archive/20230925/202309252200.gnjksNmD-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230925/202309252200.gnjksNmD-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309252200.gnjksNmD-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> sound/hda/ext/hdac_ext_stream.c:28: warning: Function parameter or member 'hext_stream' not described in 'snd_hdac_ext_host_stream_setup'
>> sound/hda/ext/hdac_ext_stream.c:41: warning: Function parameter or member 'hstream' not described in 'snd_hdac_apl_host_stream_setup'


vim +28 sound/hda/ext/hdac_ext_stream.c

    20	
    21	/**
    22	 * snd_hdac_ext_host_stream_setup - Setup a HOST stream.
    23	 * @hext_stream - HDAudio stream to set up.
    24	 *
    25	 * Return: Zero on success or negative error code.
    26	 */
    27	int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream)
  > 28	{
    29		return hext_stream->host_setup(hdac_stream(hext_stream));
    30	}
    31	EXPORT_SYMBOL_GPL(snd_hdac_ext_host_stream_setup);
    32	
    33	/**
    34	 * snd_hdac_apl_host_stream_setup - Setup a HOST stream following procedure
    35	 *                                  recommended for ApolloLake devices.
    36	 * @hstream - HDAudio stream to set up.
    37	 *
    38	 * Return: Zero on success or negative error code.
    39	 */
    40	static int snd_hdac_apl_host_stream_setup(struct hdac_stream *hstream)
  > 41	{
    42		struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream);
    43		int ret;
    44	
    45		snd_hdac_ext_stream_decouple(hstream->bus, hext_stream, false);
    46		ret = snd_hdac_stream_setup(hstream);
    47		snd_hdac_ext_stream_decouple(hstream->bus, hext_stream, true);
    48	
    49		return ret;
    50	}
    51
diff mbox series

Patch

diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h
index 511211f4a2b6..d32959cb71d2 100644
--- a/include/sound/hdaudio_ext.h
+++ b/include/sound/hdaudio_ext.h
@@ -60,6 +60,8 @@  struct hdac_ext_stream {
 	bool link_locked:1;
 	bool link_prepared;
 
+	int (*host_setup)(struct hdac_stream *);
+
 	struct snd_pcm_substream *link_substream;
 };
 
@@ -86,6 +88,7 @@  void snd_hdac_ext_stream_start(struct hdac_ext_stream *hext_stream);
 void snd_hdac_ext_stream_clear(struct hdac_ext_stream *hext_stream);
 void snd_hdac_ext_stream_reset(struct hdac_ext_stream *hext_stream);
 int snd_hdac_ext_stream_setup(struct hdac_ext_stream *hext_stream, int fmt);
+int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream);
 
 struct hdac_ext_link {
 	struct hdac_bus *bus;
diff --git a/sound/hda/ext/hdac_ext_stream.c b/sound/hda/ext/hdac_ext_stream.c
index 11b7119cc47e..292bbf91acd0 100644
--- a/sound/hda/ext/hdac_ext_stream.c
+++ b/sound/hda/ext/hdac_ext_stream.c
@@ -10,12 +10,45 @@ 
  */
 
 #include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/pci_ids.h>
 #include <linux/slab.h>
 #include <sound/pcm.h>
 #include <sound/hda_register.h>
 #include <sound/hdaudio_ext.h>
 #include <sound/compress_driver.h>
 
+/**
+ * snd_hdac_ext_host_stream_setup - Setup a HOST stream.
+ * @hext_stream - HDAudio stream to set up.
+ *
+ * Return: Zero on success or negative error code.
+ */
+int snd_hdac_ext_host_stream_setup(struct hdac_ext_stream *hext_stream)
+{
+	return hext_stream->host_setup(hdac_stream(hext_stream));
+}
+EXPORT_SYMBOL_GPL(snd_hdac_ext_host_stream_setup);
+
+/**
+ * snd_hdac_apl_host_stream_setup - Setup a HOST stream following procedure
+ *                                  recommended for ApolloLake devices.
+ * @hstream - HDAudio stream to set up.
+ *
+ * Return: Zero on success or negative error code.
+ */
+static int snd_hdac_apl_host_stream_setup(struct hdac_stream *hstream)
+{
+	struct hdac_ext_stream *hext_stream = stream_to_hdac_ext_stream(hstream);
+	int ret;
+
+	snd_hdac_ext_stream_decouple(hstream->bus, hext_stream, false);
+	ret = snd_hdac_stream_setup(hstream);
+	snd_hdac_ext_stream_decouple(hstream->bus, hext_stream, true);
+
+	return ret;
+}
+
 /**
  * snd_hdac_ext_stream_init - initialize each stream (aka device)
  * @bus: HD-audio core bus
@@ -55,9 +88,16 @@  static void snd_hdac_ext_stream_init(struct hdac_bus *bus,
 int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
 				 int num_stream, int dir)
 {
+	struct pci_dev *pci = to_pci_dev(bus->dev);
+	int (*setup_op)(struct hdac_stream *);
 	int stream_tag = 0;
 	int i, tag, idx = start_idx;
 
+	if (pci->device == PCI_DEVICE_ID_INTEL_HDA_APL)
+		setup_op = snd_hdac_stream_setup;
+	else
+		setup_op = snd_hdac_apl_host_stream_setup;
+
 	for (i = 0; i < num_stream; i++) {
 		struct hdac_ext_stream *hext_stream =
 				kzalloc(sizeof(*hext_stream), GFP_KERNEL);
@@ -66,6 +106,7 @@  int snd_hdac_ext_stream_init_all(struct hdac_bus *bus, int start_idx,
 		tag = ++stream_tag;
 		snd_hdac_ext_stream_init(bus, hext_stream, idx, dir, tag);
 		idx++;
+		hext_stream->host_setup = setup_op;
 	}
 
 	return 0;