ASoC: SOF: Intel: hda: expose some codeloader functions
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Thu, 14 Apr 2022 18:48:16 +0000 (13:48 -0500)
committerMark Brown <broonie@kernel.org>
Tue, 19 Apr 2022 11:03:45 +0000 (12:03 +0100)
Expose the code loader functions for re-use in new platforms

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20220414184817.362215-15-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda-loader.c
sound/soc/sof/intel/hda.h

index f6c50ee..78ceb5a 100644 (file)
@@ -41,9 +41,9 @@ static void hda_ssp_set_cbp_cfp(struct snd_sof_dev *sdev)
        }
 }
 
-static struct hdac_ext_stream *cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format,
-                                                unsigned int size, struct snd_dma_buffer *dmab,
-                                                int direction)
+struct hdac_ext_stream *hda_cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format,
+                                             unsigned int size, struct snd_dma_buffer *dmab,
+                                             int direction)
 {
        struct hdac_ext_stream *hext_stream;
        struct hdac_stream *hstream;
@@ -234,8 +234,8 @@ static int cl_trigger(struct snd_sof_dev *sdev,
        }
 }
 
-static int cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
-                     struct hdac_ext_stream *hext_stream)
+int hda_cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
+                  struct hdac_ext_stream *hext_stream)
 {
        struct hdac_stream *hstream = &hext_stream->hstream;
        int sd_offset = SOF_STREAM_SD_OFFSET(hstream);
@@ -266,7 +266,7 @@ static int cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
        return ret;
 }
 
-static int cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream)
+int hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream)
 {
        struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
        const struct sof_intel_dsp_desc *chip = hda->desc;
@@ -328,8 +328,8 @@ int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev)
        stripped_firmware.size = plat_data->fw->size - plat_data->fw_offset;
 
        /* prepare capture stream for ICCMAX */
-       iccmax_stream = cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, stripped_firmware.size,
-                                         &dmab_bdl, SNDRV_PCM_STREAM_CAPTURE);
+       iccmax_stream = hda_cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, stripped_firmware.size,
+                                             &dmab_bdl, SNDRV_PCM_STREAM_CAPTURE);
        if (IS_ERR(iccmax_stream)) {
                dev_err(sdev->dev, "error: dma prepare for ICCMAX stream failed\n");
                return PTR_ERR(iccmax_stream);
@@ -341,7 +341,7 @@ int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev)
         * Perform iccmax stream cleanup. This should be done even if firmware loading fails.
         * If the cleanup also fails, we return the initial error
         */
-       ret1 = cl_cleanup(sdev, &dmab_bdl, iccmax_stream);
+       ret1 = hda_cl_cleanup(sdev, &dmab_bdl, iccmax_stream);
        if (ret1 < 0) {
                dev_err(sdev->dev, "error: ICCMAX stream cleanup failed\n");
 
@@ -420,8 +420,9 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev)
        init_waitqueue_head(&sdev->boot_wait);
 
        /* prepare DMA for code loader stream */
-       hext_stream = cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, stripped_firmware.size,
-                                       &dmab, SNDRV_PCM_STREAM_PLAYBACK);
+       hext_stream = hda_cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT,
+                                           stripped_firmware.size,
+                                           &dmab, SNDRV_PCM_STREAM_PLAYBACK);
        if (IS_ERR(hext_stream)) {
                dev_err(sdev->dev, "error: dma prepare for fw loading failed\n");
                return PTR_ERR(hext_stream);
@@ -475,7 +476,7 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev)
         * Continue with code loading and firmware boot
         */
        hda->boot_iteration = HDA_FW_BOOT_ATTEMPTS;
-       ret = cl_copy_fw(sdev, hext_stream);
+       ret = hda_cl_copy_fw(sdev, hext_stream);
        if (!ret)
                dev_dbg(sdev->dev, "Firmware download successful, booting...\n");
        else
@@ -488,7 +489,7 @@ cleanup:
         * This should be done even if firmware loading fails.
         * If the cleanup also fails, we return the initial error
         */
-       ret1 = cl_cleanup(sdev, &dmab, hext_stream);
+       ret1 = hda_cl_cleanup(sdev, &dmab, hext_stream);
        if (ret1 < 0) {
                dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n");
 
index f7a9301..3644548 100644 (file)
@@ -588,6 +588,12 @@ int hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir);
  */
 int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev);
 int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev);
+int hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream);
+struct hdac_ext_stream *hda_cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format,
+                                             unsigned int size, struct snd_dma_buffer *dmab,
+                                             int direction);
+int hda_cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
+                  struct hdac_ext_stream *hext_stream);
 #define HDA_CL_STREAM_FORMAT 0x40
 
 /* pre and post fw run ops */