Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
0002 /*
0003  * This file is provided under a dual BSD/GPLv2 license.  When using or
0004  * redistributing this file, you may do so under either license.
0005  *
0006  * Copyright(c) 2018 Intel Corporation. All rights reserved.
0007  *
0008  * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
0009  */
0010 
0011 #ifndef __INCLUDE_SOUND_SOF_H
0012 #define __INCLUDE_SOUND_SOF_H
0013 
0014 #include <linux/pci.h>
0015 #include <sound/soc.h>
0016 #include <sound/soc-acpi.h>
0017 
0018 struct snd_sof_dsp_ops;
0019 struct snd_sof_dev;
0020 
0021 /**
0022  * enum sof_fw_state - DSP firmware state definitions
0023  * @SOF_FW_BOOT_NOT_STARTED:    firmware boot is not yet started
0024  * @SOF_FW_BOOT_PREPARE:    preparing for boot (firmware loading for exaqmple)
0025  * @SOF_FW_BOOT_IN_PROGRESS:    firmware boot is in progress
0026  * @SOF_FW_BOOT_FAILED:     firmware boot failed
0027  * @SOF_FW_BOOT_READY_FAILED:   firmware booted but fw_ready op failed
0028  * @SOF_FW_BOOT_READY_OK:   firmware booted and fw_ready op passed
0029  * @SOF_FW_BOOT_COMPLETE:   firmware is booted up and functional
0030  * @SOF_FW_CRASHED:     firmware crashed after successful boot
0031  */
0032 enum sof_fw_state {
0033     SOF_FW_BOOT_NOT_STARTED = 0,
0034     SOF_FW_BOOT_PREPARE,
0035     SOF_FW_BOOT_IN_PROGRESS,
0036     SOF_FW_BOOT_FAILED,
0037     SOF_FW_BOOT_READY_FAILED,
0038     SOF_FW_BOOT_READY_OK,
0039     SOF_FW_BOOT_COMPLETE,
0040     SOF_FW_CRASHED,
0041 };
0042 
0043 /* DSP power states */
0044 enum sof_dsp_power_states {
0045     SOF_DSP_PM_D0,
0046     SOF_DSP_PM_D1,
0047     SOF_DSP_PM_D2,
0048     SOF_DSP_PM_D3,
0049 };
0050 
0051 /* Definitions for multiple IPCs */
0052 enum sof_ipc_type {
0053     SOF_IPC,
0054     SOF_INTEL_IPC4,
0055     SOF_IPC_TYPE_COUNT
0056 };
0057 
0058 /*
0059  * SOF Platform data.
0060  */
0061 struct snd_sof_pdata {
0062     const struct firmware *fw;
0063     const char *name;
0064     const char *platform;
0065 
0066     struct device *dev;
0067 
0068     /* indicate how many first bytes shouldn't be loaded into DSP memory. */
0069     size_t fw_offset;
0070 
0071     /*
0072      * notification callback used if the hardware initialization
0073      * can take time or is handled in a workqueue. This callback
0074      * can be used by the caller to e.g. enable runtime_pm
0075      * or limit functionality until all low-level inits are
0076      * complete.
0077      */
0078     void (*sof_probe_complete)(struct device *dev);
0079 
0080     /* descriptor */
0081     const struct sof_dev_desc *desc;
0082 
0083     /* firmware and topology filenames */
0084     const char *fw_filename_prefix;
0085     const char *fw_filename;
0086     const char *tplg_filename_prefix;
0087     const char *tplg_filename;
0088 
0089     /* machine */
0090     struct platform_device *pdev_mach;
0091     const struct snd_soc_acpi_mach *machine;
0092 
0093     void *hw_pdata;
0094 
0095     enum sof_ipc_type ipc_type;
0096 };
0097 
0098 /*
0099  * Descriptor used for setting up SOF platform data. This is used when
0100  * ACPI/PCI data is missing or mapped differently.
0101  */
0102 struct sof_dev_desc {
0103     /* list of machines using this configuration */
0104     struct snd_soc_acpi_mach *machines;
0105 
0106     /* alternate list of machines using this configuration */
0107     struct snd_soc_acpi_mach *alt_machines;
0108 
0109     bool use_acpi_target_states;
0110 
0111     /* Platform resource indexes in BAR / ACPI resources. */
0112     /* Must set to -1 if not used - add new items to end */
0113     int resindex_lpe_base;
0114     int resindex_pcicfg_base;
0115     int resindex_imr_base;
0116     int irqindex_host_ipc;
0117 
0118     /* IPC timeouts in ms */
0119     int ipc_timeout;
0120     int boot_timeout;
0121 
0122     /* chip information for dsp */
0123     const void *chip_info;
0124 
0125     /* defaults for no codec mode */
0126     const char *nocodec_tplg_filename;
0127 
0128     /* information on supported IPCs */
0129     unsigned int ipc_supported_mask;
0130     enum sof_ipc_type ipc_default;
0131 
0132     /* defaults paths for firmware and topology files */
0133     const char *default_fw_path[SOF_IPC_TYPE_COUNT];
0134     const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
0135 
0136     /* default firmware name */
0137     const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
0138 
0139     struct snd_sof_dsp_ops *ops;
0140     int (*ops_init)(struct snd_sof_dev *sdev);
0141     void (*ops_free)(struct snd_sof_dev *sdev);
0142 };
0143 
0144 int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
0145 int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
0146 
0147 #endif