Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: SOF: Intel: hda-loader: change signature of code loader helpers

We need to reuse cl_prepare, cl_trigger and cl_cleanup helpers from a
SoundWire context where only the device information is
available. Rather than pass the 'sdev' argument, use get_drvdata() to
retrieve the required structure.

For consistency, rename hda_cl_stream_prepare() as hda_cl_prepare().

These three helpers are also exported so that they can be referenced
from another module.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://msgid.link/r/20240404185448.136157-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Pierre-Louis Bossart and committed by
Mark Brown
6cbf0861 e9ae5adc

+34 -27
+27 -23
sound/soc/sof/intel/hda-loader.c
··· 44 44 } 45 45 } 46 46 47 - struct hdac_ext_stream *hda_cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format, 48 - unsigned int size, struct snd_dma_buffer *dmab, 49 - int direction, bool is_iccmax) 47 + struct hdac_ext_stream *hda_cl_prepare(struct device *dev, unsigned int format, 48 + unsigned int size, struct snd_dma_buffer *dmab, 49 + int direction, bool is_iccmax) 50 50 { 51 + struct snd_sof_dev *sdev = dev_get_drvdata(dev); 51 52 struct hdac_ext_stream *hext_stream; 52 53 struct hdac_stream *hstream; 53 - struct pci_dev *pci = to_pci_dev(sdev->dev); 54 54 int ret; 55 55 56 56 hext_stream = hda_dsp_stream_get(sdev, direction, 0); ··· 63 63 hstream->substream = NULL; 64 64 65 65 /* allocate DMA buffer */ 66 - ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, &pci->dev, size, dmab); 66 + ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG, dev, size, dmab); 67 67 if (ret < 0) { 68 68 dev_err(sdev->dev, "error: memory alloc failed: %d\n", ret); 69 69 goto out_put; ··· 96 96 hda_dsp_stream_put(sdev, direction, hstream->stream_tag); 97 97 return ERR_PTR(ret); 98 98 } 99 + EXPORT_SYMBOL_NS(hda_cl_prepare, SND_SOC_SOF_INTEL_HDA_COMMON); 99 100 100 101 /* 101 102 * first boot sequence has some extra steps. ··· 221 220 return ret; 222 221 } 223 222 224 - static int cl_trigger(struct snd_sof_dev *sdev, 225 - struct hdac_ext_stream *hext_stream, int cmd) 223 + int hda_cl_trigger(struct device *dev, struct hdac_ext_stream *hext_stream, int cmd) 226 224 { 225 + struct snd_sof_dev *sdev = dev_get_drvdata(dev); 227 226 struct hdac_stream *hstream = &hext_stream->hstream; 228 227 int sd_offset = SOF_STREAM_SD_OFFSET(hstream); 229 228 ··· 247 246 return hda_dsp_stream_trigger(sdev, hext_stream, cmd); 248 247 } 249 248 } 249 + EXPORT_SYMBOL_NS(hda_cl_trigger, SND_SOC_SOF_INTEL_HDA_COMMON); 250 250 251 - int hda_cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab, 251 + int hda_cl_cleanup(struct device *dev, struct snd_dma_buffer *dmab, 252 252 struct hdac_ext_stream *hext_stream) 253 253 { 254 + struct snd_sof_dev *sdev = dev_get_drvdata(dev); 254 255 struct hdac_stream *hstream = &hext_stream->hstream; 255 256 int sd_offset = SOF_STREAM_SD_OFFSET(hstream); 256 257 int ret = 0; ··· 281 278 282 279 return ret; 283 280 } 281 + EXPORT_SYMBOL_NS(hda_cl_cleanup, SND_SOC_SOF_INTEL_HDA_COMMON); 284 282 285 283 int hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream) 286 284 { ··· 290 286 unsigned int reg; 291 287 int ret, status; 292 288 293 - ret = cl_trigger(sdev, hext_stream, SNDRV_PCM_TRIGGER_START); 289 + ret = hda_cl_trigger(sdev->dev, hext_stream, SNDRV_PCM_TRIGGER_START); 294 290 if (ret < 0) { 295 291 dev_err(sdev->dev, "error: DMA trigger start failed\n"); 296 292 return ret; ··· 313 309 __func__, chip->rom_status_reg); 314 310 } 315 311 316 - ret = cl_trigger(sdev, hext_stream, SNDRV_PCM_TRIGGER_STOP); 312 + ret = hda_cl_trigger(sdev->dev, hext_stream, SNDRV_PCM_TRIGGER_STOP); 317 313 if (ret < 0) { 318 314 dev_err(sdev->dev, "error: DMA trigger stop failed\n"); 319 315 if (!status) ··· 338 334 * Prepare capture stream for ICCMAX. We do not need to store 339 335 * the data, so use a buffer of PAGE_SIZE for receiving. 340 336 */ 341 - iccmax_stream = hda_cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, PAGE_SIZE, 342 - &dmab_bdl, SNDRV_PCM_STREAM_CAPTURE, true); 337 + iccmax_stream = hda_cl_prepare(sdev->dev, HDA_CL_STREAM_FORMAT, PAGE_SIZE, 338 + &dmab_bdl, SNDRV_PCM_STREAM_CAPTURE, true); 343 339 if (IS_ERR(iccmax_stream)) { 344 340 dev_err(sdev->dev, "error: dma prepare for ICCMAX stream failed\n"); 345 341 return PTR_ERR(iccmax_stream); ··· 351 347 * Perform iccmax stream cleanup. This should be done even if firmware loading fails. 352 348 * If the cleanup also fails, we return the initial error 353 349 */ 354 - ret1 = hda_cl_cleanup(sdev, &dmab_bdl, iccmax_stream); 350 + ret1 = hda_cl_cleanup(sdev->dev, &dmab_bdl, iccmax_stream); 355 351 if (ret1 < 0) { 356 352 dev_err(sdev->dev, "error: ICCMAX stream cleanup failed\n"); 357 353 ··· 423 419 init_waitqueue_head(&sdev->boot_wait); 424 420 425 421 /* prepare DMA for code loader stream */ 426 - hext_stream = hda_cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, 427 - stripped_firmware.size, 428 - &dmab, SNDRV_PCM_STREAM_PLAYBACK, false); 422 + hext_stream = hda_cl_prepare(sdev->dev, HDA_CL_STREAM_FORMAT, 423 + stripped_firmware.size, 424 + &dmab, SNDRV_PCM_STREAM_PLAYBACK, false); 429 425 if (IS_ERR(hext_stream)) { 430 426 dev_err(sdev->dev, "error: dma prepare for fw loading failed\n"); 431 427 return PTR_ERR(hext_stream); ··· 498 494 * This should be done even if firmware loading fails. 499 495 * If the cleanup also fails, we return the initial error 500 496 */ 501 - ret1 = hda_cl_cleanup(sdev, &dmab, hext_stream); 497 + ret1 = hda_cl_cleanup(sdev->dev, &dmab, hext_stream); 502 498 if (ret1 < 0) { 503 499 dev_err(sdev->dev, "error: Code loader DSP cleanup failed\n"); 504 500 ··· 540 536 stripped_firmware.size = fw_lib->sof_fw.fw->size - fw_lib->sof_fw.payload_offset; 541 537 542 538 /* prepare DMA for code loader stream */ 543 - hext_stream = hda_cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, 544 - stripped_firmware.size, 545 - &dmab, SNDRV_PCM_STREAM_PLAYBACK, false); 539 + hext_stream = hda_cl_prepare(sdev->dev, HDA_CL_STREAM_FORMAT, 540 + stripped_firmware.size, 541 + &dmab, SNDRV_PCM_STREAM_PLAYBACK, false); 546 542 if (IS_ERR(hext_stream)) { 547 543 dev_err(sdev->dev, "%s: DMA prepare failed\n", __func__); 548 544 return PTR_ERR(hext_stream); ··· 585 581 goto cleanup; 586 582 } 587 583 588 - ret = cl_trigger(sdev, hext_stream, SNDRV_PCM_TRIGGER_START); 584 + ret = hda_cl_trigger(sdev->dev, hext_stream, SNDRV_PCM_TRIGGER_START); 589 585 if (ret < 0) { 590 586 dev_err(sdev->dev, "%s: DMA trigger start failed\n", __func__); 591 587 goto cleanup; ··· 602 598 ret = sof_ipc_tx_message_no_reply(sdev->ipc, &msg, 0); 603 599 604 600 /* Stop the DMA channel */ 605 - ret1 = cl_trigger(sdev, hext_stream, SNDRV_PCM_TRIGGER_STOP); 601 + ret1 = hda_cl_trigger(sdev->dev, hext_stream, SNDRV_PCM_TRIGGER_STOP); 606 602 if (ret1 < 0) { 607 603 dev_err(sdev->dev, "%s: DMA trigger stop failed\n", __func__); 608 604 if (!ret) ··· 611 607 612 608 cleanup: 613 609 /* clean up even in case of error and return the first error */ 614 - ret1 = hda_cl_cleanup(sdev, &dmab, hext_stream); 610 + ret1 = hda_cl_cleanup(sdev->dev, &dmab, hext_stream); 615 611 if (ret1 < 0) { 616 612 dev_err(sdev->dev, "%s: Code loader DSP cleanup failed\n", __func__); 617 613
+7 -4
sound/soc/sof/intel/hda.h
··· 703 703 int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev); 704 704 int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev); 705 705 int hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream); 706 - struct hdac_ext_stream *hda_cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format, 707 - unsigned int size, struct snd_dma_buffer *dmab, 708 - int direction, bool is_iccmax); 709 - int hda_cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab, 706 + 707 + struct hdac_ext_stream *hda_cl_prepare(struct device *dev, unsigned int format, 708 + unsigned int size, struct snd_dma_buffer *dmab, 709 + int direction, bool is_iccmax); 710 + int hda_cl_trigger(struct device *dev, struct hdac_ext_stream *hext_stream, int cmd); 711 + 712 + int hda_cl_cleanup(struct device *dev, struct snd_dma_buffer *dmab, 710 713 struct hdac_ext_stream *hext_stream); 711 714 int cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot); 712 715 #define HDA_CL_STREAM_FORMAT 0x40