| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * skl-message.c - HDA DSP interface for FW registration, Pipe and Module |
|---|
| 3 | 4 | * configurations |
|---|
| .. | .. |
|---|
| 6 | 7 | * Author:Rafal Redzimski <rafal.f.redzimski@intel.com> |
|---|
| 7 | 8 | * Jeeja KP <jeeja.kp@intel.com> |
|---|
| 8 | 9 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | | - * it under the terms of the GNU General Public License as version 2, as |
|---|
| 12 | | - * published by the Free Software Foundation. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 15 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 17 | | - * General Public License for more details. |
|---|
| 18 | 10 | */ |
|---|
| 19 | 11 | |
|---|
| 20 | 12 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 33 | 25 | static int skl_alloc_dma_buf(struct device *dev, |
|---|
| 34 | 26 | struct snd_dma_buffer *dmab, size_t size) |
|---|
| 35 | 27 | { |
|---|
| 36 | | - struct hdac_bus *bus = dev_get_drvdata(dev); |
|---|
| 37 | | - |
|---|
| 38 | | - if (!bus) |
|---|
| 39 | | - return -ENODEV; |
|---|
| 40 | | - |
|---|
| 41 | | - return bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV, size, dmab); |
|---|
| 28 | + return snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size, dmab); |
|---|
| 42 | 29 | } |
|---|
| 43 | 30 | |
|---|
| 44 | 31 | static int skl_free_dma_buf(struct device *dev, struct snd_dma_buffer *dmab) |
|---|
| 45 | 32 | { |
|---|
| 46 | | - struct hdac_bus *bus = dev_get_drvdata(dev); |
|---|
| 47 | | - |
|---|
| 48 | | - if (!bus) |
|---|
| 49 | | - return -ENODEV; |
|---|
| 50 | | - |
|---|
| 51 | | - bus->io_ops->dma_free_pages(bus, dmab); |
|---|
| 52 | | - |
|---|
| 33 | + snd_dma_free_pages(dmab); |
|---|
| 53 | 34 | return 0; |
|---|
| 54 | 35 | } |
|---|
| 55 | 36 | |
|---|
| 56 | 37 | #define SKL_ASTATE_PARAM_ID 4 |
|---|
| 57 | 38 | |
|---|
| 58 | | -void skl_dsp_set_astate_cfg(struct skl_sst *ctx, u32 cnt, void *data) |
|---|
| 39 | +void skl_dsp_set_astate_cfg(struct skl_dev *skl, u32 cnt, void *data) |
|---|
| 59 | 40 | { |
|---|
| 60 | 41 | struct skl_ipc_large_config_msg msg = {0}; |
|---|
| 61 | 42 | |
|---|
| .. | .. |
|---|
| 63 | 44 | msg.param_data_size = (cnt * sizeof(struct skl_astate_param) + |
|---|
| 64 | 45 | sizeof(cnt)); |
|---|
| 65 | 46 | |
|---|
| 66 | | - skl_ipc_set_large_config(&ctx->ipc, &msg, data); |
|---|
| 67 | | -} |
|---|
| 68 | | - |
|---|
| 69 | | -#define NOTIFICATION_PARAM_ID 3 |
|---|
| 70 | | -#define NOTIFICATION_MASK 0xf |
|---|
| 71 | | - |
|---|
| 72 | | -/* disable notfication for underruns/overruns from firmware module */ |
|---|
| 73 | | -void skl_dsp_enable_notification(struct skl_sst *ctx, bool enable) |
|---|
| 74 | | -{ |
|---|
| 75 | | - struct notification_mask mask; |
|---|
| 76 | | - struct skl_ipc_large_config_msg msg = {0}; |
|---|
| 77 | | - |
|---|
| 78 | | - mask.notify = NOTIFICATION_MASK; |
|---|
| 79 | | - mask.enable = enable; |
|---|
| 80 | | - |
|---|
| 81 | | - msg.large_param_id = NOTIFICATION_PARAM_ID; |
|---|
| 82 | | - msg.param_data_size = sizeof(mask); |
|---|
| 83 | | - |
|---|
| 84 | | - skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)&mask); |
|---|
| 47 | + skl_ipc_set_large_config(&skl->ipc, &msg, data); |
|---|
| 85 | 48 | } |
|---|
| 86 | 49 | |
|---|
| 87 | 50 | static int skl_dsp_setup_spib(struct device *dev, unsigned int size, |
|---|
| .. | .. |
|---|
| 247 | 210 | .init_fw = cnl_sst_init_fw, |
|---|
| 248 | 211 | .cleanup = cnl_sst_dsp_cleanup |
|---|
| 249 | 212 | }, |
|---|
| 213 | + { |
|---|
| 214 | + .id = 0xa348, |
|---|
| 215 | + .num_cores = 4, |
|---|
| 216 | + .loader_ops = bxt_get_loader_ops, |
|---|
| 217 | + .init = cnl_sst_dsp_init, |
|---|
| 218 | + .init_fw = cnl_sst_init_fw, |
|---|
| 219 | + .cleanup = cnl_sst_dsp_cleanup |
|---|
| 220 | + }, |
|---|
| 221 | + { |
|---|
| 222 | + .id = 0x02c8, |
|---|
| 223 | + .num_cores = 4, |
|---|
| 224 | + .loader_ops = bxt_get_loader_ops, |
|---|
| 225 | + .init = cnl_sst_dsp_init, |
|---|
| 226 | + .init_fw = cnl_sst_init_fw, |
|---|
| 227 | + .cleanup = cnl_sst_dsp_cleanup |
|---|
| 228 | + }, |
|---|
| 229 | + { |
|---|
| 230 | + .id = 0x06c8, |
|---|
| 231 | + .num_cores = 4, |
|---|
| 232 | + .loader_ops = bxt_get_loader_ops, |
|---|
| 233 | + .init = cnl_sst_dsp_init, |
|---|
| 234 | + .init_fw = cnl_sst_init_fw, |
|---|
| 235 | + .cleanup = cnl_sst_dsp_cleanup |
|---|
| 236 | + }, |
|---|
| 250 | 237 | }; |
|---|
| 251 | 238 | |
|---|
| 252 | 239 | const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id) |
|---|
| .. | .. |
|---|
| 261 | 248 | return NULL; |
|---|
| 262 | 249 | } |
|---|
| 263 | 250 | |
|---|
| 264 | | -int skl_init_dsp(struct skl *skl) |
|---|
| 251 | +int skl_init_dsp(struct skl_dev *skl) |
|---|
| 265 | 252 | { |
|---|
| 266 | 253 | void __iomem *mmio_base; |
|---|
| 267 | 254 | struct hdac_bus *bus = skl_to_bus(skl); |
|---|
| .. | .. |
|---|
| 291 | 278 | loader_ops = ops->loader_ops(); |
|---|
| 292 | 279 | ret = ops->init(bus->dev, mmio_base, irq, |
|---|
| 293 | 280 | skl->fw_name, loader_ops, |
|---|
| 294 | | - &skl->skl_sst); |
|---|
| 281 | + &skl); |
|---|
| 295 | 282 | |
|---|
| 296 | 283 | if (ret < 0) |
|---|
| 297 | 284 | goto unmap_mmio; |
|---|
| 298 | 285 | |
|---|
| 299 | | - skl->skl_sst->dsp_ops = ops; |
|---|
| 300 | | - cores = &skl->skl_sst->cores; |
|---|
| 286 | + skl->dsp_ops = ops; |
|---|
| 287 | + cores = &skl->cores; |
|---|
| 301 | 288 | cores->count = ops->num_cores; |
|---|
| 302 | 289 | |
|---|
| 303 | 290 | cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 326 | 313 | return ret; |
|---|
| 327 | 314 | } |
|---|
| 328 | 315 | |
|---|
| 329 | | -int skl_free_dsp(struct skl *skl) |
|---|
| 316 | +int skl_free_dsp(struct skl_dev *skl) |
|---|
| 330 | 317 | { |
|---|
| 331 | 318 | struct hdac_bus *bus = skl_to_bus(skl); |
|---|
| 332 | | - struct skl_sst *ctx = skl->skl_sst; |
|---|
| 333 | 319 | |
|---|
| 334 | 320 | /* disable ppcap interrupt */ |
|---|
| 335 | 321 | snd_hdac_ext_bus_ppcap_int_enable(bus, false); |
|---|
| 336 | 322 | |
|---|
| 337 | | - ctx->dsp_ops->cleanup(bus->dev, ctx); |
|---|
| 323 | + skl->dsp_ops->cleanup(bus->dev, skl); |
|---|
| 338 | 324 | |
|---|
| 339 | | - kfree(ctx->cores.state); |
|---|
| 340 | | - kfree(ctx->cores.usage_count); |
|---|
| 325 | + kfree(skl->cores.state); |
|---|
| 326 | + kfree(skl->cores.usage_count); |
|---|
| 341 | 327 | |
|---|
| 342 | | - if (ctx->dsp->addr.lpe) |
|---|
| 343 | | - iounmap(ctx->dsp->addr.lpe); |
|---|
| 328 | + if (skl->dsp->addr.lpe) |
|---|
| 329 | + iounmap(skl->dsp->addr.lpe); |
|---|
| 344 | 330 | |
|---|
| 345 | 331 | return 0; |
|---|
| 346 | 332 | } |
|---|
| .. | .. |
|---|
| 352 | 338 | * mode during system suspend. In the case of normal suspend, cancel |
|---|
| 353 | 339 | * any pending D0i3 work. |
|---|
| 354 | 340 | */ |
|---|
| 355 | | -int skl_suspend_late_dsp(struct skl *skl) |
|---|
| 341 | +int skl_suspend_late_dsp(struct skl_dev *skl) |
|---|
| 356 | 342 | { |
|---|
| 357 | | - struct skl_sst *ctx = skl->skl_sst; |
|---|
| 358 | 343 | struct delayed_work *dwork; |
|---|
| 359 | 344 | |
|---|
| 360 | | - if (!ctx) |
|---|
| 345 | + if (!skl) |
|---|
| 361 | 346 | return 0; |
|---|
| 362 | 347 | |
|---|
| 363 | | - dwork = &ctx->d0i3.work; |
|---|
| 348 | + dwork = &skl->d0i3.work; |
|---|
| 364 | 349 | |
|---|
| 365 | 350 | if (dwork->work.func) { |
|---|
| 366 | 351 | if (skl->supend_active) |
|---|
| .. | .. |
|---|
| 372 | 357 | return 0; |
|---|
| 373 | 358 | } |
|---|
| 374 | 359 | |
|---|
| 375 | | -int skl_suspend_dsp(struct skl *skl) |
|---|
| 360 | +int skl_suspend_dsp(struct skl_dev *skl) |
|---|
| 376 | 361 | { |
|---|
| 377 | | - struct skl_sst *ctx = skl->skl_sst; |
|---|
| 378 | 362 | struct hdac_bus *bus = skl_to_bus(skl); |
|---|
| 379 | 363 | int ret; |
|---|
| 380 | 364 | |
|---|
| .. | .. |
|---|
| 382 | 366 | if (!bus->ppcap) |
|---|
| 383 | 367 | return 0; |
|---|
| 384 | 368 | |
|---|
| 385 | | - ret = skl_dsp_sleep(ctx->dsp); |
|---|
| 369 | + ret = skl_dsp_sleep(skl->dsp); |
|---|
| 386 | 370 | if (ret < 0) |
|---|
| 387 | 371 | return ret; |
|---|
| 388 | 372 | |
|---|
| .. | .. |
|---|
| 393 | 377 | return 0; |
|---|
| 394 | 378 | } |
|---|
| 395 | 379 | |
|---|
| 396 | | -int skl_resume_dsp(struct skl *skl) |
|---|
| 380 | +int skl_resume_dsp(struct skl_dev *skl) |
|---|
| 397 | 381 | { |
|---|
| 398 | | - struct skl_sst *ctx = skl->skl_sst; |
|---|
| 399 | 382 | struct hdac_bus *bus = skl_to_bus(skl); |
|---|
| 400 | 383 | int ret; |
|---|
| 401 | 384 | |
|---|
| .. | .. |
|---|
| 408 | 391 | snd_hdac_ext_bus_ppcap_int_enable(bus, true); |
|---|
| 409 | 392 | |
|---|
| 410 | 393 | /* check if DSP 1st boot is done */ |
|---|
| 411 | | - if (skl->skl_sst->is_first_boot == true) |
|---|
| 394 | + if (skl->is_first_boot) |
|---|
| 412 | 395 | return 0; |
|---|
| 413 | 396 | |
|---|
| 414 | 397 | /* |
|---|
| 415 | 398 | * Disable dynamic clock and power gating during firmware |
|---|
| 416 | 399 | * and library download |
|---|
| 417 | 400 | */ |
|---|
| 418 | | - ctx->enable_miscbdcge(ctx->dev, false); |
|---|
| 419 | | - ctx->clock_power_gating(ctx->dev, false); |
|---|
| 401 | + skl->enable_miscbdcge(skl->dev, false); |
|---|
| 402 | + skl->clock_power_gating(skl->dev, false); |
|---|
| 420 | 403 | |
|---|
| 421 | | - ret = skl_dsp_wake(ctx->dsp); |
|---|
| 422 | | - ctx->enable_miscbdcge(ctx->dev, true); |
|---|
| 423 | | - ctx->clock_power_gating(ctx->dev, true); |
|---|
| 404 | + ret = skl_dsp_wake(skl->dsp); |
|---|
| 405 | + skl->enable_miscbdcge(skl->dev, true); |
|---|
| 406 | + skl->clock_power_gating(skl->dev, true); |
|---|
| 424 | 407 | if (ret < 0) |
|---|
| 425 | 408 | return ret; |
|---|
| 426 | 409 | |
|---|
| 427 | | - skl_dsp_enable_notification(skl->skl_sst, false); |
|---|
| 428 | | - |
|---|
| 429 | 410 | if (skl->cfg.astate_cfg != NULL) { |
|---|
| 430 | | - skl_dsp_set_astate_cfg(skl->skl_sst, skl->cfg.astate_cfg->count, |
|---|
| 411 | + skl_dsp_set_astate_cfg(skl, skl->cfg.astate_cfg->count, |
|---|
| 431 | 412 | skl->cfg.astate_cfg); |
|---|
| 432 | 413 | } |
|---|
| 433 | 414 | return ret; |
|---|
| .. | .. |
|---|
| 460 | 441 | * which are read from widget information passed through topology binary |
|---|
| 461 | 442 | * This is send when we create a module with INIT_INSTANCE IPC msg |
|---|
| 462 | 443 | */ |
|---|
| 463 | | -static void skl_set_base_module_format(struct skl_sst *ctx, |
|---|
| 444 | +static void skl_set_base_module_format(struct skl_dev *skl, |
|---|
| 464 | 445 | struct skl_module_cfg *mconfig, |
|---|
| 465 | 446 | struct skl_base_cfg *base_cfg) |
|---|
| 466 | 447 | { |
|---|
| .. | .. |
|---|
| 475 | 456 | base_cfg->audio_fmt.bit_depth = format->bit_depth; |
|---|
| 476 | 457 | base_cfg->audio_fmt.valid_bit_depth = format->valid_bit_depth; |
|---|
| 477 | 458 | base_cfg->audio_fmt.ch_cfg = format->ch_cfg; |
|---|
| 459 | + base_cfg->audio_fmt.sample_type = format->sample_type; |
|---|
| 478 | 460 | |
|---|
| 479 | | - dev_dbg(ctx->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n", |
|---|
| 461 | + dev_dbg(skl->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n", |
|---|
| 480 | 462 | format->bit_depth, format->valid_bit_depth, |
|---|
| 481 | 463 | format->ch_cfg); |
|---|
| 482 | 464 | |
|---|
| .. | .. |
|---|
| 484 | 466 | |
|---|
| 485 | 467 | base_cfg->audio_fmt.interleaving = format->interleaving_style; |
|---|
| 486 | 468 | |
|---|
| 487 | | - base_cfg->cps = res->cps; |
|---|
| 469 | + base_cfg->cpc = res->cpc; |
|---|
| 488 | 470 | base_cfg->ibs = res->ibs; |
|---|
| 489 | 471 | base_cfg->obs = res->obs; |
|---|
| 490 | 472 | base_cfg->is_pages = res->is_pages; |
|---|
| .. | .. |
|---|
| 513 | 495 | * Calculate the gatewat settings required for copier module, type of |
|---|
| 514 | 496 | * gateway and index of gateway to use |
|---|
| 515 | 497 | */ |
|---|
| 516 | | -static u32 skl_get_node_id(struct skl_sst *ctx, |
|---|
| 498 | +static u32 skl_get_node_id(struct skl_dev *skl, |
|---|
| 517 | 499 | struct skl_module_cfg *mconfig) |
|---|
| 518 | 500 | { |
|---|
| 519 | 501 | union skl_connector_node_id node_id = {0}; |
|---|
| .. | .. |
|---|
| 570 | 552 | return node_id.val; |
|---|
| 571 | 553 | } |
|---|
| 572 | 554 | |
|---|
| 573 | | -static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx, |
|---|
| 555 | +static void skl_setup_cpr_gateway_cfg(struct skl_dev *skl, |
|---|
| 574 | 556 | struct skl_module_cfg *mconfig, |
|---|
| 575 | 557 | struct skl_cpr_cfg *cpr_mconfig) |
|---|
| 576 | 558 | { |
|---|
| 577 | 559 | u32 dma_io_buf; |
|---|
| 578 | 560 | struct skl_module_res *res; |
|---|
| 579 | 561 | int res_idx = mconfig->res_idx; |
|---|
| 580 | | - struct skl *skl = get_skl_ctx(ctx->dev); |
|---|
| 581 | 562 | |
|---|
| 582 | | - cpr_mconfig->gtw_cfg.node_id = skl_get_node_id(ctx, mconfig); |
|---|
| 563 | + cpr_mconfig->gtw_cfg.node_id = skl_get_node_id(skl, mconfig); |
|---|
| 583 | 564 | |
|---|
| 584 | 565 | if (cpr_mconfig->gtw_cfg.node_id == SKL_NON_GATEWAY_CPR_NODE_ID) { |
|---|
| 585 | 566 | cpr_mconfig->cpr_feature_mask = 0; |
|---|
| .. | .. |
|---|
| 610 | 591 | break; |
|---|
| 611 | 592 | |
|---|
| 612 | 593 | default: |
|---|
| 613 | | - dev_warn(ctx->dev, "wrong connection type: %d\n", |
|---|
| 594 | + dev_warn(skl->dev, "wrong connection type: %d\n", |
|---|
| 614 | 595 | mconfig->hw_conn_type); |
|---|
| 615 | 596 | return; |
|---|
| 616 | 597 | } |
|---|
| .. | .. |
|---|
| 636 | 617 | #define DMA_CONTROL_ID 5 |
|---|
| 637 | 618 | #define DMA_I2S_BLOB_SIZE 21 |
|---|
| 638 | 619 | |
|---|
| 639 | | -int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps, |
|---|
| 620 | +int skl_dsp_set_dma_control(struct skl_dev *skl, u32 *caps, |
|---|
| 640 | 621 | u32 caps_size, u32 node_id) |
|---|
| 641 | 622 | { |
|---|
| 642 | 623 | struct skl_dma_control *dma_ctrl; |
|---|
| .. | .. |
|---|
| 669 | 650 | |
|---|
| 670 | 651 | memcpy(dma_ctrl->config_data, caps, caps_size); |
|---|
| 671 | 652 | |
|---|
| 672 | | - err = skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)dma_ctrl); |
|---|
| 653 | + err = skl_ipc_set_large_config(&skl->ipc, &msg, (u32 *)dma_ctrl); |
|---|
| 673 | 654 | |
|---|
| 674 | 655 | kfree(dma_ctrl); |
|---|
| 675 | 656 | return err; |
|---|
| 676 | 657 | } |
|---|
| 677 | 658 | EXPORT_SYMBOL_GPL(skl_dsp_set_dma_control); |
|---|
| 678 | 659 | |
|---|
| 679 | | -static void skl_setup_out_format(struct skl_sst *ctx, |
|---|
| 660 | +static void skl_setup_out_format(struct skl_dev *skl, |
|---|
| 680 | 661 | struct skl_module_cfg *mconfig, |
|---|
| 681 | 662 | struct skl_audio_data_format *out_fmt) |
|---|
| 682 | 663 | { |
|---|
| .. | .. |
|---|
| 694 | 675 | out_fmt->interleaving = format->interleaving_style; |
|---|
| 695 | 676 | out_fmt->sample_type = format->sample_type; |
|---|
| 696 | 677 | |
|---|
| 697 | | - dev_dbg(ctx->dev, "copier out format chan=%d fre=%d bitdepth=%d\n", |
|---|
| 678 | + dev_dbg(skl->dev, "copier out format chan=%d fre=%d bitdepth=%d\n", |
|---|
| 698 | 679 | out_fmt->number_of_channels, format->s_freq, format->bit_depth); |
|---|
| 699 | 680 | } |
|---|
| 700 | 681 | |
|---|
| .. | .. |
|---|
| 703 | 684 | * configuration and the target frequency as extra parameter passed as src |
|---|
| 704 | 685 | * config |
|---|
| 705 | 686 | */ |
|---|
| 706 | | -static void skl_set_src_format(struct skl_sst *ctx, |
|---|
| 687 | +static void skl_set_src_format(struct skl_dev *skl, |
|---|
| 707 | 688 | struct skl_module_cfg *mconfig, |
|---|
| 708 | 689 | struct skl_src_module_cfg *src_mconfig) |
|---|
| 709 | 690 | { |
|---|
| .. | .. |
|---|
| 711 | 692 | struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx]; |
|---|
| 712 | 693 | struct skl_module_fmt *fmt = &iface->outputs[0].fmt; |
|---|
| 713 | 694 | |
|---|
| 714 | | - skl_set_base_module_format(ctx, mconfig, |
|---|
| 695 | + skl_set_base_module_format(skl, mconfig, |
|---|
| 715 | 696 | (struct skl_base_cfg *)src_mconfig); |
|---|
| 716 | 697 | |
|---|
| 717 | 698 | src_mconfig->src_cfg = fmt->s_freq; |
|---|
| .. | .. |
|---|
| 722 | 703 | * module configuration and channel configuration |
|---|
| 723 | 704 | * It also take coefficients and now we have defaults applied here |
|---|
| 724 | 705 | */ |
|---|
| 725 | | -static void skl_set_updown_mixer_format(struct skl_sst *ctx, |
|---|
| 706 | +static void skl_set_updown_mixer_format(struct skl_dev *skl, |
|---|
| 726 | 707 | struct skl_module_cfg *mconfig, |
|---|
| 727 | 708 | struct skl_up_down_mixer_cfg *mixer_mconfig) |
|---|
| 728 | 709 | { |
|---|
| .. | .. |
|---|
| 730 | 711 | struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx]; |
|---|
| 731 | 712 | struct skl_module_fmt *fmt = &iface->outputs[0].fmt; |
|---|
| 732 | 713 | |
|---|
| 733 | | - skl_set_base_module_format(ctx, mconfig, |
|---|
| 714 | + skl_set_base_module_format(skl, mconfig, |
|---|
| 734 | 715 | (struct skl_base_cfg *)mixer_mconfig); |
|---|
| 735 | 716 | mixer_mconfig->out_ch_cfg = fmt->ch_cfg; |
|---|
| 736 | 717 | mixer_mconfig->ch_map = fmt->ch_map; |
|---|
| .. | .. |
|---|
| 743 | 724 | * format, gateway settings |
|---|
| 744 | 725 | * copier_module_config is sent as input buffer with INIT_INSTANCE IPC msg |
|---|
| 745 | 726 | */ |
|---|
| 746 | | -static void skl_set_copier_format(struct skl_sst *ctx, |
|---|
| 727 | +static void skl_set_copier_format(struct skl_dev *skl, |
|---|
| 747 | 728 | struct skl_module_cfg *mconfig, |
|---|
| 748 | 729 | struct skl_cpr_cfg *cpr_mconfig) |
|---|
| 749 | 730 | { |
|---|
| 750 | 731 | struct skl_audio_data_format *out_fmt = &cpr_mconfig->out_fmt; |
|---|
| 751 | 732 | struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)cpr_mconfig; |
|---|
| 752 | 733 | |
|---|
| 753 | | - skl_set_base_module_format(ctx, mconfig, base_cfg); |
|---|
| 734 | + skl_set_base_module_format(skl, mconfig, base_cfg); |
|---|
| 754 | 735 | |
|---|
| 755 | | - skl_setup_out_format(ctx, mconfig, out_fmt); |
|---|
| 756 | | - skl_setup_cpr_gateway_cfg(ctx, mconfig, cpr_mconfig); |
|---|
| 736 | + skl_setup_out_format(skl, mconfig, out_fmt); |
|---|
| 737 | + skl_setup_cpr_gateway_cfg(skl, mconfig, cpr_mconfig); |
|---|
| 757 | 738 | } |
|---|
| 758 | 739 | |
|---|
| 759 | 740 | /* |
|---|
| .. | .. |
|---|
| 761 | 742 | * configuration and params |
|---|
| 762 | 743 | */ |
|---|
| 763 | 744 | |
|---|
| 764 | | -static void skl_set_algo_format(struct skl_sst *ctx, |
|---|
| 745 | +static void skl_set_algo_format(struct skl_dev *skl, |
|---|
| 765 | 746 | struct skl_module_cfg *mconfig, |
|---|
| 766 | 747 | struct skl_algo_cfg *algo_mcfg) |
|---|
| 767 | 748 | { |
|---|
| 768 | 749 | struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)algo_mcfg; |
|---|
| 769 | 750 | |
|---|
| 770 | | - skl_set_base_module_format(ctx, mconfig, base_cfg); |
|---|
| 751 | + skl_set_base_module_format(skl, mconfig, base_cfg); |
|---|
| 771 | 752 | |
|---|
| 772 | 753 | if (mconfig->formats_config.caps_size == 0) |
|---|
| 773 | 754 | return; |
|---|
| .. | .. |
|---|
| 785 | 766 | * Mic select module take base module configuration and out-format |
|---|
| 786 | 767 | * configuration |
|---|
| 787 | 768 | */ |
|---|
| 788 | | -static void skl_set_base_outfmt_format(struct skl_sst *ctx, |
|---|
| 769 | +static void skl_set_base_outfmt_format(struct skl_dev *skl, |
|---|
| 789 | 770 | struct skl_module_cfg *mconfig, |
|---|
| 790 | 771 | struct skl_base_outfmt_cfg *base_outfmt_mcfg) |
|---|
| 791 | 772 | { |
|---|
| .. | .. |
|---|
| 793 | 774 | struct skl_base_cfg *base_cfg = |
|---|
| 794 | 775 | (struct skl_base_cfg *)base_outfmt_mcfg; |
|---|
| 795 | 776 | |
|---|
| 796 | | - skl_set_base_module_format(ctx, mconfig, base_cfg); |
|---|
| 797 | | - skl_setup_out_format(ctx, mconfig, out_fmt); |
|---|
| 777 | + skl_set_base_module_format(skl, mconfig, base_cfg); |
|---|
| 778 | + skl_setup_out_format(skl, mconfig, out_fmt); |
|---|
| 798 | 779 | } |
|---|
| 799 | 780 | |
|---|
| 800 | | -static u16 skl_get_module_param_size(struct skl_sst *ctx, |
|---|
| 781 | +static u16 skl_get_module_param_size(struct skl_dev *skl, |
|---|
| 801 | 782 | struct skl_module_cfg *mconfig) |
|---|
| 802 | 783 | { |
|---|
| 803 | 784 | u16 param_size; |
|---|
| .. | .. |
|---|
| 821 | 802 | |
|---|
| 822 | 803 | case SKL_MODULE_TYPE_BASE_OUTFMT: |
|---|
| 823 | 804 | case SKL_MODULE_TYPE_MIC_SELECT: |
|---|
| 824 | | - case SKL_MODULE_TYPE_KPB: |
|---|
| 825 | 805 | return sizeof(struct skl_base_outfmt_cfg); |
|---|
| 806 | + |
|---|
| 807 | + case SKL_MODULE_TYPE_MIXER: |
|---|
| 808 | + case SKL_MODULE_TYPE_KPB: |
|---|
| 809 | + return sizeof(struct skl_base_cfg); |
|---|
| 826 | 810 | |
|---|
| 827 | 811 | default: |
|---|
| 828 | 812 | /* |
|---|
| .. | .. |
|---|
| 842 | 826 | * base module format configuration |
|---|
| 843 | 827 | */ |
|---|
| 844 | 828 | |
|---|
| 845 | | -static int skl_set_module_format(struct skl_sst *ctx, |
|---|
| 829 | +static int skl_set_module_format(struct skl_dev *skl, |
|---|
| 846 | 830 | struct skl_module_cfg *module_config, |
|---|
| 847 | 831 | u16 *module_config_size, |
|---|
| 848 | 832 | void **param_data) |
|---|
| 849 | 833 | { |
|---|
| 850 | 834 | u16 param_size; |
|---|
| 851 | 835 | |
|---|
| 852 | | - param_size = skl_get_module_param_size(ctx, module_config); |
|---|
| 836 | + param_size = skl_get_module_param_size(skl, module_config); |
|---|
| 853 | 837 | |
|---|
| 854 | 838 | *param_data = kzalloc(param_size, GFP_KERNEL); |
|---|
| 855 | 839 | if (NULL == *param_data) |
|---|
| .. | .. |
|---|
| 859 | 843 | |
|---|
| 860 | 844 | switch (module_config->m_type) { |
|---|
| 861 | 845 | case SKL_MODULE_TYPE_COPIER: |
|---|
| 862 | | - skl_set_copier_format(ctx, module_config, *param_data); |
|---|
| 846 | + skl_set_copier_format(skl, module_config, *param_data); |
|---|
| 863 | 847 | break; |
|---|
| 864 | 848 | |
|---|
| 865 | 849 | case SKL_MODULE_TYPE_SRCINT: |
|---|
| 866 | | - skl_set_src_format(ctx, module_config, *param_data); |
|---|
| 850 | + skl_set_src_format(skl, module_config, *param_data); |
|---|
| 867 | 851 | break; |
|---|
| 868 | 852 | |
|---|
| 869 | 853 | case SKL_MODULE_TYPE_UPDWMIX: |
|---|
| 870 | | - skl_set_updown_mixer_format(ctx, module_config, *param_data); |
|---|
| 854 | + skl_set_updown_mixer_format(skl, module_config, *param_data); |
|---|
| 871 | 855 | break; |
|---|
| 872 | 856 | |
|---|
| 873 | 857 | case SKL_MODULE_TYPE_ALGO: |
|---|
| 874 | | - skl_set_algo_format(ctx, module_config, *param_data); |
|---|
| 858 | + skl_set_algo_format(skl, module_config, *param_data); |
|---|
| 875 | 859 | break; |
|---|
| 876 | 860 | |
|---|
| 877 | 861 | case SKL_MODULE_TYPE_BASE_OUTFMT: |
|---|
| 878 | 862 | case SKL_MODULE_TYPE_MIC_SELECT: |
|---|
| 863 | + skl_set_base_outfmt_format(skl, module_config, *param_data); |
|---|
| 864 | + break; |
|---|
| 865 | + |
|---|
| 866 | + case SKL_MODULE_TYPE_MIXER: |
|---|
| 879 | 867 | case SKL_MODULE_TYPE_KPB: |
|---|
| 880 | | - skl_set_base_outfmt_format(ctx, module_config, *param_data); |
|---|
| 868 | + skl_set_base_module_format(skl, module_config, *param_data); |
|---|
| 881 | 869 | break; |
|---|
| 882 | 870 | |
|---|
| 883 | 871 | default: |
|---|
| 884 | | - skl_set_base_module_format(ctx, module_config, *param_data); |
|---|
| 872 | + skl_set_base_module_format(skl, module_config, *param_data); |
|---|
| 885 | 873 | break; |
|---|
| 886 | 874 | |
|---|
| 887 | 875 | } |
|---|
| 888 | 876 | |
|---|
| 889 | | - dev_dbg(ctx->dev, "Module type=%d config size: %d bytes\n", |
|---|
| 890 | | - module_config->id.module_id, param_size); |
|---|
| 877 | + dev_dbg(skl->dev, "Module type=%d id=%d config size: %d bytes\n", |
|---|
| 878 | + module_config->m_type, module_config->id.module_id, |
|---|
| 879 | + param_size); |
|---|
| 891 | 880 | print_hex_dump_debug("Module params:", DUMP_PREFIX_OFFSET, 8, 4, |
|---|
| 892 | 881 | *param_data, param_size, false); |
|---|
| 893 | 882 | return 0; |
|---|
| .. | .. |
|---|
| 987 | 976 | * We first calculate the module format, based on module type and then |
|---|
| 988 | 977 | * invoke the DSP by sending IPC INIT_INSTANCE using ipc helper |
|---|
| 989 | 978 | */ |
|---|
| 990 | | -int skl_init_module(struct skl_sst *ctx, |
|---|
| 979 | +int skl_init_module(struct skl_dev *skl, |
|---|
| 991 | 980 | struct skl_module_cfg *mconfig) |
|---|
| 992 | 981 | { |
|---|
| 993 | 982 | u16 module_config_size = 0; |
|---|
| .. | .. |
|---|
| 995 | 984 | int ret; |
|---|
| 996 | 985 | struct skl_ipc_init_instance_msg msg; |
|---|
| 997 | 986 | |
|---|
| 998 | | - dev_dbg(ctx->dev, "%s: module_id = %d instance=%d\n", __func__, |
|---|
| 987 | + dev_dbg(skl->dev, "%s: module_id = %d instance=%d\n", __func__, |
|---|
| 999 | 988 | mconfig->id.module_id, mconfig->id.pvt_id); |
|---|
| 1000 | 989 | |
|---|
| 1001 | 990 | if (mconfig->pipe->state != SKL_PIPE_CREATED) { |
|---|
| 1002 | | - dev_err(ctx->dev, "Pipe not created state= %d pipe_id= %d\n", |
|---|
| 991 | + dev_err(skl->dev, "Pipe not created state= %d pipe_id= %d\n", |
|---|
| 1003 | 992 | mconfig->pipe->state, mconfig->pipe->ppl_id); |
|---|
| 1004 | 993 | return -EIO; |
|---|
| 1005 | 994 | } |
|---|
| 1006 | 995 | |
|---|
| 1007 | | - ret = skl_set_module_format(ctx, mconfig, |
|---|
| 996 | + ret = skl_set_module_format(skl, mconfig, |
|---|
| 1008 | 997 | &module_config_size, ¶m_data); |
|---|
| 1009 | 998 | if (ret < 0) { |
|---|
| 1010 | | - dev_err(ctx->dev, "Failed to set module format ret=%d\n", ret); |
|---|
| 999 | + dev_err(skl->dev, "Failed to set module format ret=%d\n", ret); |
|---|
| 1011 | 1000 | return ret; |
|---|
| 1012 | 1001 | } |
|---|
| 1013 | 1002 | |
|---|
| .. | .. |
|---|
| 1018 | 1007 | msg.core_id = mconfig->core_id; |
|---|
| 1019 | 1008 | msg.domain = mconfig->domain; |
|---|
| 1020 | 1009 | |
|---|
| 1021 | | - ret = skl_ipc_init_instance(&ctx->ipc, &msg, param_data); |
|---|
| 1010 | + ret = skl_ipc_init_instance(&skl->ipc, &msg, param_data); |
|---|
| 1022 | 1011 | if (ret < 0) { |
|---|
| 1023 | | - dev_err(ctx->dev, "Failed to init instance ret=%d\n", ret); |
|---|
| 1012 | + dev_err(skl->dev, "Failed to init instance ret=%d\n", ret); |
|---|
| 1024 | 1013 | kfree(param_data); |
|---|
| 1025 | 1014 | return ret; |
|---|
| 1026 | 1015 | } |
|---|
| .. | .. |
|---|
| 1029 | 1018 | return ret; |
|---|
| 1030 | 1019 | } |
|---|
| 1031 | 1020 | |
|---|
| 1032 | | -static void skl_dump_bind_info(struct skl_sst *ctx, struct skl_module_cfg |
|---|
| 1021 | +static void skl_dump_bind_info(struct skl_dev *skl, struct skl_module_cfg |
|---|
| 1033 | 1022 | *src_module, struct skl_module_cfg *dst_module) |
|---|
| 1034 | 1023 | { |
|---|
| 1035 | | - dev_dbg(ctx->dev, "%s: src module_id = %d src_instance=%d\n", |
|---|
| 1024 | + dev_dbg(skl->dev, "%s: src module_id = %d src_instance=%d\n", |
|---|
| 1036 | 1025 | __func__, src_module->id.module_id, src_module->id.pvt_id); |
|---|
| 1037 | | - dev_dbg(ctx->dev, "%s: dst_module=%d dst_instance=%d\n", __func__, |
|---|
| 1026 | + dev_dbg(skl->dev, "%s: dst_module=%d dst_instance=%d\n", __func__, |
|---|
| 1038 | 1027 | dst_module->id.module_id, dst_module->id.pvt_id); |
|---|
| 1039 | 1028 | |
|---|
| 1040 | | - dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n", |
|---|
| 1029 | + dev_dbg(skl->dev, "src_module state = %d dst module state = %d\n", |
|---|
| 1041 | 1030 | src_module->m_state, dst_module->m_state); |
|---|
| 1042 | 1031 | } |
|---|
| 1043 | 1032 | |
|---|
| .. | .. |
|---|
| 1046 | 1035 | * it is already bind. |
|---|
| 1047 | 1036 | * Find the pin allocated and unbind then using bind_unbind IPC |
|---|
| 1048 | 1037 | */ |
|---|
| 1049 | | -int skl_unbind_modules(struct skl_sst *ctx, |
|---|
| 1038 | +int skl_unbind_modules(struct skl_dev *skl, |
|---|
| 1050 | 1039 | struct skl_module_cfg *src_mcfg, |
|---|
| 1051 | 1040 | struct skl_module_cfg *dst_mcfg) |
|---|
| 1052 | 1041 | { |
|---|
| .. | .. |
|---|
| 1058 | 1047 | int out_max = src_mcfg->module->max_output_pins; |
|---|
| 1059 | 1048 | int src_index, dst_index, src_pin_state, dst_pin_state; |
|---|
| 1060 | 1049 | |
|---|
| 1061 | | - skl_dump_bind_info(ctx, src_mcfg, dst_mcfg); |
|---|
| 1050 | + skl_dump_bind_info(skl, src_mcfg, dst_mcfg); |
|---|
| 1062 | 1051 | |
|---|
| 1063 | 1052 | /* get src queue index */ |
|---|
| 1064 | 1053 | src_index = skl_get_queue_index(src_mcfg->m_out_pin, dst_id, out_max); |
|---|
| .. | .. |
|---|
| 1087 | 1076 | msg.dst_instance_id = dst_mcfg->id.pvt_id; |
|---|
| 1088 | 1077 | msg.bind = false; |
|---|
| 1089 | 1078 | |
|---|
| 1090 | | - ret = skl_ipc_bind_unbind(&ctx->ipc, &msg); |
|---|
| 1079 | + ret = skl_ipc_bind_unbind(&skl->ipc, &msg); |
|---|
| 1091 | 1080 | if (!ret) { |
|---|
| 1092 | 1081 | /* free queue only if unbind is success */ |
|---|
| 1093 | 1082 | skl_free_queue(src_mcfg->m_out_pin, src_index); |
|---|
| .. | .. |
|---|
| 1125 | 1114 | * This function finds the pins and then sends bund_unbind IPC message to |
|---|
| 1126 | 1115 | * DSP using IPC helper |
|---|
| 1127 | 1116 | */ |
|---|
| 1128 | | -int skl_bind_modules(struct skl_sst *ctx, |
|---|
| 1117 | +int skl_bind_modules(struct skl_dev *skl, |
|---|
| 1129 | 1118 | struct skl_module_cfg *src_mcfg, |
|---|
| 1130 | 1119 | struct skl_module_cfg *dst_mcfg) |
|---|
| 1131 | 1120 | { |
|---|
| .. | .. |
|---|
| 1139 | 1128 | struct skl_module *module; |
|---|
| 1140 | 1129 | struct skl_module_iface *fmt; |
|---|
| 1141 | 1130 | |
|---|
| 1142 | | - skl_dump_bind_info(ctx, src_mcfg, dst_mcfg); |
|---|
| 1131 | + skl_dump_bind_info(skl, src_mcfg, dst_mcfg); |
|---|
| 1143 | 1132 | |
|---|
| 1144 | 1133 | if (src_mcfg->m_state < SKL_MODULE_INIT_DONE || |
|---|
| 1145 | 1134 | dst_mcfg->m_state < SKL_MODULE_INIT_DONE) |
|---|
| .. | .. |
|---|
| 1171 | 1160 | |
|---|
| 1172 | 1161 | format = &fmt->outputs[src_index].fmt; |
|---|
| 1173 | 1162 | fill_pin_params(&(pin_fmt.dst_fmt), format); |
|---|
| 1174 | | - ret = skl_set_module_params(ctx, (void *)&pin_fmt, |
|---|
| 1163 | + ret = skl_set_module_params(skl, (void *)&pin_fmt, |
|---|
| 1175 | 1164 | sizeof(struct skl_cpr_pin_fmt), |
|---|
| 1176 | 1165 | CPR_SINK_FMT_PARAM_ID, src_mcfg); |
|---|
| 1177 | 1166 | |
|---|
| .. | .. |
|---|
| 1181 | 1170 | |
|---|
| 1182 | 1171 | msg.dst_queue = dst_index; |
|---|
| 1183 | 1172 | |
|---|
| 1184 | | - dev_dbg(ctx->dev, "src queue = %d dst queue =%d\n", |
|---|
| 1173 | + dev_dbg(skl->dev, "src queue = %d dst queue =%d\n", |
|---|
| 1185 | 1174 | msg.src_queue, msg.dst_queue); |
|---|
| 1186 | 1175 | |
|---|
| 1187 | 1176 | msg.module_id = src_mcfg->id.module_id; |
|---|
| .. | .. |
|---|
| 1190 | 1179 | msg.dst_instance_id = dst_mcfg->id.pvt_id; |
|---|
| 1191 | 1180 | msg.bind = true; |
|---|
| 1192 | 1181 | |
|---|
| 1193 | | - ret = skl_ipc_bind_unbind(&ctx->ipc, &msg); |
|---|
| 1182 | + ret = skl_ipc_bind_unbind(&skl->ipc, &msg); |
|---|
| 1194 | 1183 | |
|---|
| 1195 | 1184 | if (!ret) { |
|---|
| 1196 | 1185 | src_mcfg->m_state = SKL_MODULE_BIND_DONE; |
|---|
| .. | .. |
|---|
| 1206 | 1195 | return ret; |
|---|
| 1207 | 1196 | } |
|---|
| 1208 | 1197 | |
|---|
| 1209 | | -static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe, |
|---|
| 1198 | +static int skl_set_pipe_state(struct skl_dev *skl, struct skl_pipe *pipe, |
|---|
| 1210 | 1199 | enum skl_ipc_pipeline_state state) |
|---|
| 1211 | 1200 | { |
|---|
| 1212 | | - dev_dbg(ctx->dev, "%s: pipe_state = %d\n", __func__, state); |
|---|
| 1201 | + dev_dbg(skl->dev, "%s: pipe_state = %d\n", __func__, state); |
|---|
| 1213 | 1202 | |
|---|
| 1214 | | - return skl_ipc_set_pipeline_state(&ctx->ipc, pipe->ppl_id, state); |
|---|
| 1203 | + return skl_ipc_set_pipeline_state(&skl->ipc, pipe->ppl_id, state); |
|---|
| 1215 | 1204 | } |
|---|
| 1216 | 1205 | |
|---|
| 1217 | 1206 | /* |
|---|
| .. | .. |
|---|
| 1220 | 1209 | * This function creates pipeline, by sending create pipeline IPC messages |
|---|
| 1221 | 1210 | * to FW |
|---|
| 1222 | 1211 | */ |
|---|
| 1223 | | -int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe) |
|---|
| 1212 | +int skl_create_pipeline(struct skl_dev *skl, struct skl_pipe *pipe) |
|---|
| 1224 | 1213 | { |
|---|
| 1225 | 1214 | int ret; |
|---|
| 1226 | 1215 | |
|---|
| 1227 | | - dev_dbg(ctx->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id); |
|---|
| 1216 | + dev_dbg(skl->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id); |
|---|
| 1228 | 1217 | |
|---|
| 1229 | | - ret = skl_ipc_create_pipeline(&ctx->ipc, pipe->memory_pages, |
|---|
| 1218 | + ret = skl_ipc_create_pipeline(&skl->ipc, pipe->memory_pages, |
|---|
| 1230 | 1219 | pipe->pipe_priority, pipe->ppl_id, |
|---|
| 1231 | 1220 | pipe->lp_mode); |
|---|
| 1232 | 1221 | if (ret < 0) { |
|---|
| 1233 | | - dev_err(ctx->dev, "Failed to create pipeline\n"); |
|---|
| 1222 | + dev_err(skl->dev, "Failed to create pipeline\n"); |
|---|
| 1234 | 1223 | return ret; |
|---|
| 1235 | 1224 | } |
|---|
| 1236 | 1225 | |
|---|
| .. | .. |
|---|
| 1240 | 1229 | } |
|---|
| 1241 | 1230 | |
|---|
| 1242 | 1231 | /* |
|---|
| 1243 | | - * A pipeline needs to be deleted on cleanup. If a pipeline is running, then |
|---|
| 1244 | | - * pause the pipeline first and then delete it |
|---|
| 1245 | | - * The pipe delete is done by sending delete pipeline IPC. DSP will stop the |
|---|
| 1246 | | - * DMA engines and releases resources |
|---|
| 1232 | + * A pipeline needs to be deleted on cleanup. If a pipeline is running, |
|---|
| 1233 | + * then pause it first. Before actual deletion, pipeline should enter |
|---|
| 1234 | + * reset state. Finish the procedure by sending delete pipeline IPC. |
|---|
| 1235 | + * DSP will stop the DMA engines and release resources |
|---|
| 1247 | 1236 | */ |
|---|
| 1248 | | -int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe) |
|---|
| 1237 | +int skl_delete_pipe(struct skl_dev *skl, struct skl_pipe *pipe) |
|---|
| 1249 | 1238 | { |
|---|
| 1250 | 1239 | int ret; |
|---|
| 1251 | 1240 | |
|---|
| 1252 | | - dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id); |
|---|
| 1241 | + dev_dbg(skl->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id); |
|---|
| 1242 | + |
|---|
| 1243 | + /* If pipe was not created in FW, do not try to delete it */ |
|---|
| 1244 | + if (pipe->state < SKL_PIPE_CREATED) |
|---|
| 1245 | + return 0; |
|---|
| 1253 | 1246 | |
|---|
| 1254 | 1247 | /* If pipe is started, do stop the pipe in FW. */ |
|---|
| 1255 | 1248 | if (pipe->state >= SKL_PIPE_STARTED) { |
|---|
| 1256 | | - ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED); |
|---|
| 1249 | + ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED); |
|---|
| 1257 | 1250 | if (ret < 0) { |
|---|
| 1258 | | - dev_err(ctx->dev, "Failed to stop pipeline\n"); |
|---|
| 1251 | + dev_err(skl->dev, "Failed to stop pipeline\n"); |
|---|
| 1259 | 1252 | return ret; |
|---|
| 1260 | 1253 | } |
|---|
| 1261 | 1254 | |
|---|
| 1262 | 1255 | pipe->state = SKL_PIPE_PAUSED; |
|---|
| 1263 | 1256 | } |
|---|
| 1264 | 1257 | |
|---|
| 1265 | | - /* If pipe was not created in FW, do not try to delete it */ |
|---|
| 1266 | | - if (pipe->state < SKL_PIPE_CREATED) |
|---|
| 1267 | | - return 0; |
|---|
| 1268 | | - |
|---|
| 1269 | | - ret = skl_ipc_delete_pipeline(&ctx->ipc, pipe->ppl_id); |
|---|
| 1258 | + /* reset pipe state before deletion */ |
|---|
| 1259 | + ret = skl_set_pipe_state(skl, pipe, PPL_RESET); |
|---|
| 1270 | 1260 | if (ret < 0) { |
|---|
| 1271 | | - dev_err(ctx->dev, "Failed to delete pipeline\n"); |
|---|
| 1261 | + dev_err(skl->dev, "Failed to reset pipe ret=%d\n", ret); |
|---|
| 1262 | + return ret; |
|---|
| 1263 | + } |
|---|
| 1264 | + |
|---|
| 1265 | + pipe->state = SKL_PIPE_RESET; |
|---|
| 1266 | + |
|---|
| 1267 | + ret = skl_ipc_delete_pipeline(&skl->ipc, pipe->ppl_id); |
|---|
| 1268 | + if (ret < 0) { |
|---|
| 1269 | + dev_err(skl->dev, "Failed to delete pipeline\n"); |
|---|
| 1272 | 1270 | return ret; |
|---|
| 1273 | 1271 | } |
|---|
| 1274 | 1272 | |
|---|
| .. | .. |
|---|
| 1282 | 1280 | * For processing data the pipe need to be run by sending IPC set pipe state |
|---|
| 1283 | 1281 | * to DSP |
|---|
| 1284 | 1282 | */ |
|---|
| 1285 | | -int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe) |
|---|
| 1283 | +int skl_run_pipe(struct skl_dev *skl, struct skl_pipe *pipe) |
|---|
| 1286 | 1284 | { |
|---|
| 1287 | 1285 | int ret; |
|---|
| 1288 | 1286 | |
|---|
| 1289 | | - dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id); |
|---|
| 1287 | + dev_dbg(skl->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id); |
|---|
| 1290 | 1288 | |
|---|
| 1291 | 1289 | /* If pipe was not created in FW, do not try to pause or delete */ |
|---|
| 1292 | 1290 | if (pipe->state < SKL_PIPE_CREATED) |
|---|
| 1293 | 1291 | return 0; |
|---|
| 1294 | 1292 | |
|---|
| 1295 | 1293 | /* Pipe has to be paused before it is started */ |
|---|
| 1296 | | - ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED); |
|---|
| 1294 | + ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED); |
|---|
| 1297 | 1295 | if (ret < 0) { |
|---|
| 1298 | | - dev_err(ctx->dev, "Failed to pause pipe\n"); |
|---|
| 1296 | + dev_err(skl->dev, "Failed to pause pipe\n"); |
|---|
| 1299 | 1297 | return ret; |
|---|
| 1300 | 1298 | } |
|---|
| 1301 | 1299 | |
|---|
| 1302 | 1300 | pipe->state = SKL_PIPE_PAUSED; |
|---|
| 1303 | 1301 | |
|---|
| 1304 | | - ret = skl_set_pipe_state(ctx, pipe, PPL_RUNNING); |
|---|
| 1302 | + ret = skl_set_pipe_state(skl, pipe, PPL_RUNNING); |
|---|
| 1305 | 1303 | if (ret < 0) { |
|---|
| 1306 | | - dev_err(ctx->dev, "Failed to start pipe\n"); |
|---|
| 1304 | + dev_err(skl->dev, "Failed to start pipe\n"); |
|---|
| 1307 | 1305 | return ret; |
|---|
| 1308 | 1306 | } |
|---|
| 1309 | 1307 | |
|---|
| .. | .. |
|---|
| 1316 | 1314 | * Stop the pipeline by sending set pipe state IPC |
|---|
| 1317 | 1315 | * DSP doesnt implement stop so we always send pause message |
|---|
| 1318 | 1316 | */ |
|---|
| 1319 | | -int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe) |
|---|
| 1317 | +int skl_stop_pipe(struct skl_dev *skl, struct skl_pipe *pipe) |
|---|
| 1320 | 1318 | { |
|---|
| 1321 | 1319 | int ret; |
|---|
| 1322 | 1320 | |
|---|
| 1323 | | - dev_dbg(ctx->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id); |
|---|
| 1321 | + dev_dbg(skl->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id); |
|---|
| 1324 | 1322 | |
|---|
| 1325 | 1323 | /* If pipe was not created in FW, do not try to pause or delete */ |
|---|
| 1326 | 1324 | if (pipe->state < SKL_PIPE_PAUSED) |
|---|
| 1327 | 1325 | return 0; |
|---|
| 1328 | 1326 | |
|---|
| 1329 | | - ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED); |
|---|
| 1327 | + ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED); |
|---|
| 1330 | 1328 | if (ret < 0) { |
|---|
| 1331 | | - dev_dbg(ctx->dev, "Failed to stop pipe\n"); |
|---|
| 1329 | + dev_dbg(skl->dev, "Failed to stop pipe\n"); |
|---|
| 1332 | 1330 | return ret; |
|---|
| 1333 | 1331 | } |
|---|
| 1334 | 1332 | |
|---|
| .. | .. |
|---|
| 1341 | 1339 | * Reset the pipeline by sending set pipe state IPC this will reset the DMA |
|---|
| 1342 | 1340 | * from the DSP side |
|---|
| 1343 | 1341 | */ |
|---|
| 1344 | | -int skl_reset_pipe(struct skl_sst *ctx, struct skl_pipe *pipe) |
|---|
| 1342 | +int skl_reset_pipe(struct skl_dev *skl, struct skl_pipe *pipe) |
|---|
| 1345 | 1343 | { |
|---|
| 1346 | 1344 | int ret; |
|---|
| 1347 | 1345 | |
|---|
| .. | .. |
|---|
| 1349 | 1347 | if (pipe->state < SKL_PIPE_PAUSED) |
|---|
| 1350 | 1348 | return 0; |
|---|
| 1351 | 1349 | |
|---|
| 1352 | | - ret = skl_set_pipe_state(ctx, pipe, PPL_RESET); |
|---|
| 1350 | + ret = skl_set_pipe_state(skl, pipe, PPL_RESET); |
|---|
| 1353 | 1351 | if (ret < 0) { |
|---|
| 1354 | | - dev_dbg(ctx->dev, "Failed to reset pipe ret=%d\n", ret); |
|---|
| 1352 | + dev_dbg(skl->dev, "Failed to reset pipe ret=%d\n", ret); |
|---|
| 1355 | 1353 | return ret; |
|---|
| 1356 | 1354 | } |
|---|
| 1357 | 1355 | |
|---|
| .. | .. |
|---|
| 1361 | 1359 | } |
|---|
| 1362 | 1360 | |
|---|
| 1363 | 1361 | /* Algo parameter set helper function */ |
|---|
| 1364 | | -int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size, |
|---|
| 1362 | +int skl_set_module_params(struct skl_dev *skl, u32 *params, int size, |
|---|
| 1365 | 1363 | u32 param_id, struct skl_module_cfg *mcfg) |
|---|
| 1366 | 1364 | { |
|---|
| 1367 | 1365 | struct skl_ipc_large_config_msg msg; |
|---|
| .. | .. |
|---|
| 1371 | 1369 | msg.param_data_size = size; |
|---|
| 1372 | 1370 | msg.large_param_id = param_id; |
|---|
| 1373 | 1371 | |
|---|
| 1374 | | - return skl_ipc_set_large_config(&ctx->ipc, &msg, params); |
|---|
| 1372 | + return skl_ipc_set_large_config(&skl->ipc, &msg, params); |
|---|
| 1375 | 1373 | } |
|---|
| 1376 | 1374 | |
|---|
| 1377 | | -int skl_get_module_params(struct skl_sst *ctx, u32 *params, int size, |
|---|
| 1375 | +int skl_get_module_params(struct skl_dev *skl, u32 *params, int size, |
|---|
| 1378 | 1376 | u32 param_id, struct skl_module_cfg *mcfg) |
|---|
| 1379 | 1377 | { |
|---|
| 1380 | 1378 | struct skl_ipc_large_config_msg msg; |
|---|
| 1379 | + size_t bytes = size; |
|---|
| 1381 | 1380 | |
|---|
| 1382 | 1381 | msg.module_id = mcfg->id.module_id; |
|---|
| 1383 | 1382 | msg.instance_id = mcfg->id.pvt_id; |
|---|
| 1384 | 1383 | msg.param_data_size = size; |
|---|
| 1385 | 1384 | msg.large_param_id = param_id; |
|---|
| 1386 | 1385 | |
|---|
| 1387 | | - return skl_ipc_get_large_config(&ctx->ipc, &msg, params); |
|---|
| 1386 | + return skl_ipc_get_large_config(&skl->ipc, &msg, ¶ms, &bytes); |
|---|
| 1388 | 1387 | } |
|---|