sof-priv.h (3e62579436c6a7fc35de7318e6c5f495b8d0046c) | sof-priv.h (ee1e79b72e3cf5eac42ba9de827536f91d4c04e2) |
---|---|
1/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ 2/* 3 * This file is provided under a dual BSD/GPLv2 license. When using or 4 * redistributing this file, you may do so under either license. 5 * 6 * Copyright(c) 2018 Intel Corporation. All rights reserved. 7 * 8 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> 9 */ 10 11#ifndef __SOUND_SOC_SOF_PRIV_H 12#define __SOUND_SOC_SOF_PRIV_H 13 14#include <linux/device.h> | 1/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ 2/* 3 * This file is provided under a dual BSD/GPLv2 license. When using or 4 * redistributing this file, you may do so under either license. 5 * 6 * Copyright(c) 2018 Intel Corporation. All rights reserved. 7 * 8 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> 9 */ 10 11#ifndef __SOUND_SOC_SOF_PRIV_H 12#define __SOUND_SOC_SOF_PRIV_H 13 14#include <linux/device.h> |
15 | |
16#include <sound/hdaudio.h> | 15#include <sound/hdaudio.h> |
17#include <sound/soc.h> 18#include <sound/control.h> 19 | |
20#include <sound/sof.h> | 16#include <sound/sof.h> |
21#include <sound/sof/stream.h> /* needs to be included before control.h */ 22#include <sound/sof/control.h> 23#include <sound/sof/dai.h> | |
24#include <sound/sof/info.h> 25#include <sound/sof/pm.h> | 17#include <sound/sof/info.h> 18#include <sound/sof/pm.h> |
26#include <sound/sof/topology.h> | |
27#include <sound/sof/trace.h> | 19#include <sound/sof/trace.h> |
28 | |
29#include <uapi/sound/sof/fw.h> 30 31/* debug flags */ 32#define SOF_DBG_ENABLE_TRACE BIT(0) 33#define SOF_DBG_REGS BIT(1) 34#define SOF_DBG_MBOX BIT(2) 35#define SOF_DBG_TEXT BIT(3) 36#define SOF_DBG_PCI BIT(4) --- 6 unchanged lines hidden (view full) --- 43#define SND_SOF_BARS 8 44 45/* time in ms for runtime suspend delay */ 46#define SND_SOF_SUSPEND_DELAY_MS 2000 47 48/* DMA buffer size for trace */ 49#define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16) 50 | 20#include <uapi/sound/sof/fw.h> 21 22/* debug flags */ 23#define SOF_DBG_ENABLE_TRACE BIT(0) 24#define SOF_DBG_REGS BIT(1) 25#define SOF_DBG_MBOX BIT(2) 26#define SOF_DBG_TEXT BIT(3) 27#define SOF_DBG_PCI BIT(4) --- 6 unchanged lines hidden (view full) --- 34#define SND_SOF_BARS 8 35 36/* time in ms for runtime suspend delay */ 37#define SND_SOF_SUSPEND_DELAY_MS 2000 38 39/* DMA buffer size for trace */ 40#define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16) 41 |
51/* max number of FE PCMs before BEs */ 52#define SOF_BE_PCM_BASE 16 53 | |
54#define SOF_IPC_DSP_REPLY 0 55#define SOF_IPC_HOST_REPLY 1 56 57/* convenience constructor for DAI driver streams */ 58#define SOF_DAI_STREAM(sname, scmin, scmax, srates, sfmt) \ 59 {.stream_name = sname, .channels_min = scmin, .channels_max = scmax, \ 60 .rates = srates, .formats = sfmt} 61 62#define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ 63 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT) 64 65#define ENABLE_DEBUGFS_CACHEBUF \ 66 (IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) || \ 67 IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST)) 68 | 42#define SOF_IPC_DSP_REPLY 0 43#define SOF_IPC_HOST_REPLY 1 44 45/* convenience constructor for DAI driver streams */ 46#define SOF_DAI_STREAM(sname, scmin, scmax, srates, sfmt) \ 47 {.stream_name = sname, .channels_min = scmin, .channels_max = scmax, \ 48 .rates = srates, .formats = sfmt} 49 50#define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ 51 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT) 52 53#define ENABLE_DEBUGFS_CACHEBUF \ 54 (IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) || \ 55 IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST)) 56 |
69#define DMA_CHAN_INVALID 0xFFFFFFFF 70 | |
71/* DSP D0ix sub-state */ 72enum sof_d0_substate { 73 SOF_DSP_D0I0 = 0, /* DSP default D0 substate */ 74 SOF_DSP_D0I3, /* DSP D0i3(low power) substate*/ 75}; 76 77struct snd_sof_dev; 78struct snd_sof_ipc_msg; --- 219 unchanged lines hidden (view full) --- 298 size_t msg_size; 299 size_t reply_size; 300 int reply_error; 301 302 wait_queue_head_t waitq; 303 bool ipc_complete; 304}; 305 | 57/* DSP D0ix sub-state */ 58enum sof_d0_substate { 59 SOF_DSP_D0I0 = 0, /* DSP default D0 substate */ 60 SOF_DSP_D0I3, /* DSP D0i3(low power) substate*/ 61}; 62 63struct snd_sof_dev; 64struct snd_sof_ipc_msg; --- 219 unchanged lines hidden (view full) --- 284 size_t msg_size; 285 size_t reply_size; 286 int reply_error; 287 288 wait_queue_head_t waitq; 289 bool ipc_complete; 290}; 291 |
306/* PCM stream, mapped to FW component */ 307struct snd_sof_pcm_stream { 308 u32 comp_id; 309 struct snd_dma_buffer page_table; 310 struct sof_ipc_stream_posn posn; 311 struct snd_pcm_substream *substream; 312 struct work_struct period_elapsed_work; 313 bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */ 314 /* 315 * flag to indicate that the DSP pipelines should be kept 316 * active or not while suspending the stream 317 */ 318 bool suspend_ignored; 319}; 320 321/* ALSA SOF PCM device */ 322struct snd_sof_pcm { 323 struct snd_sof_dev *sdev; 324 struct snd_soc_tplg_pcm pcm; 325 struct snd_sof_pcm_stream stream[2]; 326 struct list_head list; /* list in sdev pcm list */ 327 struct snd_pcm_hw_params params[2]; 328 bool prepared[2]; /* PCM_PARAMS set successfully */ 329}; 330 331struct snd_sof_led_control { 332 unsigned int use_led; 333 unsigned int direction; 334 unsigned int led_value; 335}; 336 337/* ALSA SOF Kcontrol device */ 338struct snd_sof_control { 339 struct snd_sof_dev *sdev; 340 int comp_id; 341 int min_volume_step; /* min volume step for volume_table */ 342 int max_volume_step; /* max volume step for volume_table */ 343 int num_channels; 344 u32 readback_offset; /* offset to mmaped data if used */ 345 struct sof_ipc_ctrl_data *control_data; 346 u32 size; /* cdata size */ 347 enum sof_ipc_ctrl_cmd cmd; 348 u32 *volume_table; /* volume table computed from tlv data*/ 349 350 struct list_head list; /* list in sdev control list */ 351 352 struct snd_sof_led_control led_ctl; 353}; 354 355/* ASoC SOF DAPM widget */ 356struct snd_sof_widget { 357 struct snd_sof_dev *sdev; 358 int comp_id; 359 int pipeline_id; 360 int complete; 361 int id; 362 363 struct snd_soc_dapm_widget *widget; 364 struct list_head list; /* list in sdev widget list */ 365 366 void *private; /* core does not touch this */ 367}; 368 369/* ASoC SOF DAPM route */ 370struct snd_sof_route { 371 struct snd_sof_dev *sdev; 372 373 struct snd_soc_dapm_route *route; 374 struct list_head list; /* list in sdev route list */ 375 376 void *private; 377}; 378 379/* ASoC DAI device */ 380struct snd_sof_dai { 381 struct snd_sof_dev *sdev; 382 const char *name; 383 const char *cpu_dai_name; 384 385 struct sof_ipc_comp_dai comp_dai; 386 struct sof_ipc_dai_config *dai_config; 387 struct list_head list; /* list in sdev dai list */ 388}; 389 | |
390/* 391 * SOF Device Level. 392 */ 393struct snd_sof_dev { 394 struct device *dev; 395 spinlock_t ipc_lock; /* lock for IPC users */ 396 spinlock_t hw_lock; /* lock for HW IO access */ 397 --- 128 unchanged lines hidden (view full) --- 526 struct sof_ipc_pcm_params *params); 527int snd_sof_dsp_mailbox_init(struct snd_sof_dev *sdev, u32 dspbox, 528 size_t dspbox_size, u32 hostbox, 529 size_t hostbox_size); 530int snd_sof_ipc_valid(struct snd_sof_dev *sdev); 531int sof_ipc_tx_message(struct snd_sof_ipc *ipc, u32 header, 532 void *msg_data, size_t msg_bytes, void *reply_data, 533 size_t reply_bytes); | 292/* 293 * SOF Device Level. 294 */ 295struct snd_sof_dev { 296 struct device *dev; 297 spinlock_t ipc_lock; /* lock for IPC users */ 298 spinlock_t hw_lock; /* lock for HW IO access */ 299 --- 128 unchanged lines hidden (view full) --- 428 struct sof_ipc_pcm_params *params); 429int snd_sof_dsp_mailbox_init(struct snd_sof_dev *sdev, u32 dspbox, 430 size_t dspbox_size, u32 hostbox, 431 size_t hostbox_size); 432int snd_sof_ipc_valid(struct snd_sof_dev *sdev); 433int sof_ipc_tx_message(struct snd_sof_ipc *ipc, u32 header, 434 void *msg_data, size_t msg_bytes, void *reply_data, 435 size_t reply_bytes); |
534struct snd_sof_widget *snd_sof_find_swidget(struct snd_sof_dev *sdev, 535 const char *name); 536struct snd_sof_widget *snd_sof_find_swidget_sname(struct snd_sof_dev *sdev, 537 const char *pcm_name, 538 int dir); 539struct snd_sof_dai *snd_sof_find_dai(struct snd_sof_dev *sdev, 540 const char *name); | |
541 | 436 |
542static inline 543struct snd_sof_pcm *snd_sof_find_spcm_dai(struct snd_sof_dev *sdev, 544 struct snd_soc_pcm_runtime *rtd) 545{ 546 struct snd_sof_pcm *spcm = NULL; 547 548 list_for_each_entry(spcm, &sdev->pcm_list, list) { 549 if (le32_to_cpu(spcm->pcm.dai_id) == rtd->dai_link->id) 550 return spcm; 551 } 552 553 return NULL; 554} 555 556bool snd_sof_dsp_d0i3_on_suspend(struct snd_sof_dev *sdev); 557 558struct snd_sof_pcm *snd_sof_find_spcm_name(struct snd_sof_dev *sdev, 559 const char *name); 560struct snd_sof_pcm *snd_sof_find_spcm_comp(struct snd_sof_dev *sdev, 561 unsigned int comp_id, 562 int *direction); 563struct snd_sof_pcm *snd_sof_find_spcm_pcm_id(struct snd_sof_dev *sdev, 564 unsigned int pcm_id); 565void snd_sof_pcm_period_elapsed(struct snd_pcm_substream *substream); 566 | |
567/* | 437/* |
568 * Stream IPC 569 */ 570int snd_sof_ipc_stream_posn(struct snd_sof_dev *sdev, 571 struct snd_sof_pcm *spcm, int direction, 572 struct sof_ipc_stream_posn *posn); 573 574/* 575 * Mixer IPC 576 */ 577int snd_sof_ipc_set_get_comp_data(struct snd_sof_ipc *ipc, 578 struct snd_sof_control *scontrol, u32 ipc_cmd, 579 enum sof_ipc_ctrl_type ctrl_type, 580 enum sof_ipc_ctrl_cmd ctrl_cmd, 581 bool send); 582 583/* 584 * Topology. 585 * There is no snd_sof_free_topology since topology components will 586 * be freed by snd_soc_unregister_component, 587 */ 588int snd_sof_load_topology(struct snd_sof_dev *sdev, const char *file); 589int snd_sof_complete_pipeline(struct snd_sof_dev *sdev, 590 struct snd_sof_widget *swidget); 591 592int sof_load_pipeline_ipc(struct snd_sof_dev *sdev, 593 struct sof_ipc_pipe_new *pipeline, 594 struct sof_ipc_comp_reply *r); 595 596/* | |
597 * Trace/debug 598 */ 599int snd_sof_init_trace(struct snd_sof_dev *sdev); 600void snd_sof_release_trace(struct snd_sof_dev *sdev); 601void snd_sof_free_trace(struct snd_sof_dev *sdev); 602int snd_sof_dbg_init(struct snd_sof_dev *sdev); 603void snd_sof_free_debug(struct snd_sof_dev *sdev); 604int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev, --- 14 unchanged lines hidden (view full) --- 619void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev); 620 621/* 622 * Platform specific ops. 623 */ 624extern struct snd_compr_ops sof_compressed_ops; 625 626/* | 438 * Trace/debug 439 */ 440int snd_sof_init_trace(struct snd_sof_dev *sdev); 441void snd_sof_release_trace(struct snd_sof_dev *sdev); 442void snd_sof_free_trace(struct snd_sof_dev *sdev); 443int snd_sof_dbg_init(struct snd_sof_dev *sdev); 444void snd_sof_free_debug(struct snd_sof_dev *sdev); 445int snd_sof_debugfs_io_item(struct snd_sof_dev *sdev, --- 14 unchanged lines hidden (view full) --- 460void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev); 461 462/* 463 * Platform specific ops. 464 */ 465extern struct snd_compr_ops sof_compressed_ops; 466 467/* |
627 * Kcontrols. 628 */ 629 630int snd_sof_volume_get(struct snd_kcontrol *kcontrol, 631 struct snd_ctl_elem_value *ucontrol); 632int snd_sof_volume_put(struct snd_kcontrol *kcontrol, 633 struct snd_ctl_elem_value *ucontrol); 634int snd_sof_switch_get(struct snd_kcontrol *kcontrol, 635 struct snd_ctl_elem_value *ucontrol); 636int snd_sof_switch_put(struct snd_kcontrol *kcontrol, 637 struct snd_ctl_elem_value *ucontrol); 638int snd_sof_enum_get(struct snd_kcontrol *kcontrol, 639 struct snd_ctl_elem_value *ucontrol); 640int snd_sof_enum_put(struct snd_kcontrol *kcontrol, 641 struct snd_ctl_elem_value *ucontrol); 642int snd_sof_bytes_get(struct snd_kcontrol *kcontrol, 643 struct snd_ctl_elem_value *ucontrol); 644int snd_sof_bytes_put(struct snd_kcontrol *kcontrol, 645 struct snd_ctl_elem_value *ucontrol); 646int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, 647 const unsigned int __user *binary_data, 648 unsigned int size); 649int snd_sof_bytes_ext_get(struct snd_kcontrol *kcontrol, 650 unsigned int __user *binary_data, 651 unsigned int size); 652 653/* | |
654 * DSP Architectures. 655 */ 656static inline void sof_stack(struct snd_sof_dev *sdev, void *oops, u32 *stack, 657 u32 stack_words) 658{ | 468 * DSP Architectures. 469 */ 470static inline void sof_stack(struct snd_sof_dev *sdev, void *oops, u32 *stack, 471 u32 stack_words) 472{ |
659 if (sof_arch_ops(sdev)->dsp_stack) | |
660 sof_arch_ops(sdev)->dsp_stack(sdev, oops, stack, stack_words); 661} 662 663static inline void sof_oops(struct snd_sof_dev *sdev, void *oops) 664{ 665 if (sof_arch_ops(sdev)->dsp_oops) 666 sof_arch_ops(sdev)->dsp_oops(sdev, oops); 667} --- 34 unchanged lines hidden --- | 473 sof_arch_ops(sdev)->dsp_stack(sdev, oops, stack, stack_words); 474} 475 476static inline void sof_oops(struct snd_sof_dev *sdev, void *oops) 477{ 478 if (sof_arch_ops(sdev)->dsp_oops) 479 sof_arch_ops(sdev)->dsp_oops(sdev, oops); 480} --- 34 unchanged lines hidden --- |