soundwire: intel: update stream callbacks for hwparams/free stream operations
authorRander Wang <rander.wang@linux.intel.com>
Thu, 12 Dec 2019 01:45:02 +0000 (19:45 -0600)
committerVinod Koul <vkoul@kernel.org>
Thu, 12 Dec 2019 03:47:06 +0000 (09:17 +0530)
The SoundWire DAIs for Intel platform are created in
drivers/soundwire/intel.c, while the communication with the Intel DSP
is all controlled in soc/sof/intel

When the DAI status changes, a callback is used to bridge the gap
between the two subsystems.

The naming of the existing 'config_stream' callback does not map well
with any of ALSA/ASoC concepts. This patch renames it as
'params_stream' to be more self-explanatory.

A new 'free_stream' callback is added in case any resources allocated
in the 'params_stream' stage need to be released. In the SOF
implementation, this is used in the hw_free case to release the DMA
channels over IPC.

These two callbacks now rely on structures which expose the link_id
and alh_stream_id (required by the firmware IPC), instead of a list of
parameters. The 'void *' definitions are changed to use explicit
types, as suggested on alsa-devel during earlier reviews.

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20191212014507.28050-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/intel.c
drivers/soundwire/intel.h
drivers/soundwire/intel_init.c
include/linux/soundwire/sdw_intel.h

index 99dc610..0371d3d 100644 (file)
@@ -529,17 +529,24 @@ intel_pdi_alh_configure(struct sdw_intel *sdw, struct sdw_cdns_pdi *pdi)
        intel_writel(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id), conf);
 }
 
-static int intel_config_stream(struct sdw_intel *sdw,
+static int intel_params_stream(struct sdw_intel *sdw,
                               struct snd_pcm_substream *substream,
                               struct snd_soc_dai *dai,
-                              struct snd_pcm_hw_params *hw_params, int link_id)
+                              struct snd_pcm_hw_params *hw_params,
+                              int link_id, int alh_stream_id)
 {
        struct sdw_intel_link_res *res = sdw->res;
+       struct sdw_intel_stream_params_data params_data;
 
-       if (res->ops && res->ops->config_stream && res->arg)
-               return res->ops->config_stream(res->arg,
-                               substream, dai, hw_params, link_id);
+       params_data.substream = substream;
+       params_data.dai = dai;
+       params_data.hw_params = hw_params;
+       params_data.link_id = link_id;
+       params_data.alh_stream_id = alh_stream_id;
 
+       if (res->ops && res->ops->params_stream && res->dev)
+               return res->ops->params_stream(res->dev,
+                                              &params_data);
        return -EIO;
 }
 
@@ -654,7 +661,8 @@ static int intel_hw_params(struct snd_pcm_substream *substream,
 
 
        /* Inform DSP about PDI stream number */
-       ret = intel_config_stream(sdw, substream, dai, params,
+       ret = intel_params_stream(sdw, substream, dai, params,
+                                 sdw->instance,
                                  pdi->intel_alh_id);
        if (ret)
                goto error;
index e4cc1d3..38b7c12 100644 (file)
@@ -14,7 +14,7 @@
  * @alh: ALH (Audio Link Hub) pointer
  * @irq: Interrupt line
  * @ops: Shim callback ops
- * @arg: Shim callback ops argument
+ * @dev: device implementing hw_params and free callbacks
  */
 struct sdw_intel_link_res {
        struct platform_device *pdev;
@@ -24,7 +24,7 @@ struct sdw_intel_link_res {
        void __iomem *alh;
        int irq;
        const struct sdw_intel_ops *ops;
-       void *arg;
+       struct device *dev;
 };
 
 #endif /* __SDW_INTEL_LOCAL_H */
index bc739a3..4b76940 100644 (file)
@@ -119,6 +119,7 @@ static struct sdw_intel_ctx
                link->alh = res->mmio_base + SDW_ALH_BASE;
 
                link->ops = res->ops;
+               link->dev = res->dev;
 
                memset(&pdevinfo, 0, sizeof(pdevinfo));
 
index 034eca8..3ccb38d 100644 (file)
@@ -5,14 +5,38 @@
 #define __SDW_INTEL_H
 
 /**
+ * struct sdw_intel_stream_params_data: configuration passed during
+ * the @params_stream callback, e.g. for interaction with DSP
+ * firmware.
+ */
+struct sdw_intel_stream_params_data {
+       struct snd_pcm_substream *substream;
+       struct snd_soc_dai *dai;
+       struct snd_pcm_hw_params *hw_params;
+       int link_id;
+       int alh_stream_id;
+};
+
+/**
+ * struct sdw_intel_stream_free_data: configuration passed during
+ * the @free_stream callback, e.g. for interaction with DSP
+ * firmware.
+ */
+struct sdw_intel_stream_free_data {
+       struct snd_pcm_substream *substream;
+       struct snd_soc_dai *dai;
+       int link_id;
+};
+
+/**
  * struct sdw_intel_ops: Intel audio driver callback ops
  *
- * @config_stream: configure the stream with the hw_params
- * the first argument containing the context is mandatory
  */
 struct sdw_intel_ops {
-       int (*config_stream)(void *arg, void *substream,
-                            void *dai, void *hw_params, int stream_num);
+       int (*params_stream)(struct device *dev,
+                            struct sdw_intel_stream_params_data *params_data);
+       int (*free_stream)(struct device *dev,
+                          struct sdw_intel_stream_free_data *free_data);
 };
 
 /**