Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 #ifndef __SST_MFLD_DSP_H__
0003 #define __SST_MFLD_DSP_H__
0004 /*
0005  *  sst_mfld_dsp.h - Intel SST Driver for audio engine
0006  *
0007  *  Copyright (C) 2008-14 Intel Corporation
0008  *  Authors:    Vinod Koul <vinod.koul@linux.intel.com>
0009  *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0010  *
0011  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0012  */
0013 
0014 #define SST_MAX_BIN_BYTES 1024
0015 
0016 #define MAX_DBG_RW_BYTES 80
0017 #define MAX_NUM_SCATTER_BUFFERS 8
0018 #define MAX_LOOP_BACK_DWORDS 8
0019 /* IPC base address and mailbox, timestamp offsets */
0020 #define SST_MAILBOX_SIZE 0x0400
0021 #define SST_MAILBOX_SEND 0x0000
0022 #define SST_TIME_STAMP 0x1800
0023 #define SST_TIME_STAMP_MRFLD 0x800
0024 #define SST_RESERVED_OFFSET 0x1A00
0025 #define SST_SCU_LPE_MAILBOX 0x1000
0026 #define SST_LPE_SCU_MAILBOX 0x1400
0027 #define SST_SCU_LPE_LOG_BUF (SST_SCU_LPE_MAILBOX+16)
0028 #define PROCESS_MSG 0x80
0029 
0030 /* Message ID's for IPC messages */
0031 /* Bits B7: SST or IA/SC ; B6-B4: Msg Category; B3-B0: Msg Type */
0032 
0033 /* I2L Firmware/Codec Download msgs */
0034 #define IPC_IA_PREP_LIB_DNLD 0x01
0035 #define IPC_IA_LIB_DNLD_CMPLT 0x02
0036 #define IPC_IA_GET_FW_VERSION 0x04
0037 #define IPC_IA_GET_FW_BUILD_INF 0x05
0038 #define IPC_IA_GET_FW_INFO 0x06
0039 #define IPC_IA_GET_FW_CTXT 0x07
0040 #define IPC_IA_SET_FW_CTXT 0x08
0041 #define IPC_IA_PREPARE_SHUTDOWN 0x31
0042 /* I2L Codec Config/control msgs */
0043 #define IPC_PREP_D3 0x10
0044 #define IPC_IA_SET_CODEC_PARAMS 0x10
0045 #define IPC_IA_GET_CODEC_PARAMS 0x11
0046 #define IPC_IA_SET_PPP_PARAMS 0x12
0047 #define IPC_IA_GET_PPP_PARAMS 0x13
0048 #define IPC_SST_PERIOD_ELAPSED_MRFLD 0xA
0049 #define IPC_IA_ALG_PARAMS 0x1A
0050 #define IPC_IA_TUNING_PARAMS 0x1B
0051 #define IPC_IA_SET_RUNTIME_PARAMS 0x1C
0052 #define IPC_IA_SET_PARAMS 0x1
0053 #define IPC_IA_GET_PARAMS 0x2
0054 
0055 #define IPC_EFFECTS_CREATE 0xE
0056 #define IPC_EFFECTS_DESTROY 0xF
0057 
0058 /* I2L Stream config/control msgs */
0059 #define IPC_IA_ALLOC_STREAM_MRFLD 0x2
0060 #define IPC_IA_ALLOC_STREAM 0x20 /* Allocate a stream ID */
0061 #define IPC_IA_FREE_STREAM_MRFLD 0x03
0062 #define IPC_IA_FREE_STREAM 0x21 /* Free the stream ID */
0063 #define IPC_IA_SET_STREAM_PARAMS 0x22
0064 #define IPC_IA_SET_STREAM_PARAMS_MRFLD 0x12
0065 #define IPC_IA_GET_STREAM_PARAMS 0x23
0066 #define IPC_IA_PAUSE_STREAM 0x24
0067 #define IPC_IA_PAUSE_STREAM_MRFLD 0x4
0068 #define IPC_IA_RESUME_STREAM 0x25
0069 #define IPC_IA_RESUME_STREAM_MRFLD 0x5
0070 #define IPC_IA_DROP_STREAM 0x26
0071 #define IPC_IA_DROP_STREAM_MRFLD 0x07
0072 #define IPC_IA_DRAIN_STREAM 0x27 /* Short msg with str_id */
0073 #define IPC_IA_DRAIN_STREAM_MRFLD 0x8
0074 #define IPC_IA_CONTROL_ROUTING 0x29
0075 #define IPC_IA_VTSV_UPDATE_MODULES 0x20
0076 #define IPC_IA_VTSV_DETECTED 0x21
0077 
0078 #define IPC_IA_START_STREAM_MRFLD 0X06
0079 #define IPC_IA_START_STREAM 0x30 /* Short msg with str_id */
0080 
0081 #define IPC_IA_SET_GAIN_MRFLD 0x21
0082 /* Debug msgs */
0083 #define IPC_IA_DBG_MEM_READ 0x40
0084 #define IPC_IA_DBG_MEM_WRITE 0x41
0085 #define IPC_IA_DBG_LOOP_BACK 0x42
0086 #define IPC_IA_DBG_LOG_ENABLE 0x45
0087 #define IPC_IA_DBG_SET_PROBE_PARAMS 0x47
0088 
0089 /* L2I Firmware/Codec Download msgs */
0090 #define IPC_IA_FW_INIT_CMPLT 0x81
0091 #define IPC_IA_FW_INIT_CMPLT_MRFLD 0x01
0092 #define IPC_IA_FW_ASYNC_ERR_MRFLD 0x11
0093 
0094 /* L2I Codec Config/control msgs */
0095 #define IPC_SST_FRAGMENT_ELPASED 0x90 /* Request IA more data */
0096 
0097 #define IPC_SST_BUF_UNDER_RUN 0x92 /* PB Under run and stopped */
0098 #define IPC_SST_BUF_OVER_RUN 0x93 /* CAP Under run and stopped */
0099 #define IPC_SST_DRAIN_END 0x94 /* PB Drain complete and stopped */
0100 #define IPC_SST_CHNGE_SSP_PARAMS 0x95 /* PB SSP parameters changed */
0101 #define IPC_SST_STREAM_PROCESS_FATAL_ERR 0x96/* error in processing a stream */
0102 #define IPC_SST_PERIOD_ELAPSED 0x97 /* period elapsed */
0103 
0104 #define IPC_SST_ERROR_EVENT 0x99 /* Buffer over run occurred */
0105 /* L2S messages */
0106 #define IPC_SC_DDR_LINK_UP 0xC0
0107 #define IPC_SC_DDR_LINK_DOWN 0xC1
0108 #define IPC_SC_SET_LPECLK_REQ 0xC2
0109 #define IPC_SC_SSP_BIT_BANG 0xC3
0110 
0111 /* L2I Error reporting msgs */
0112 #define IPC_IA_MEM_ALLOC_FAIL 0xE0
0113 #define IPC_IA_PROC_ERR 0xE1 /* error in processing a
0114                     stream can be used by playback and
0115                     capture modules */
0116 
0117 /* L2I Debug msgs */
0118 #define IPC_IA_PRINT_STRING 0xF0
0119 
0120 /* Buffer under-run */
0121 #define IPC_IA_BUF_UNDER_RUN_MRFLD 0x0B
0122 
0123 /* Mrfld specific defines:
0124  * For asynchronous messages(INIT_CMPLT, PERIOD_ELAPSED, ASYNC_ERROR)
0125  * received from FW, the format is:
0126  *  - IPC High: pvt_id is set to zero. Always short message.
0127  *  - msg_id is in lower 16-bits of IPC low payload.
0128  *  - pipe_id is in higher 16-bits of IPC low payload for period_elapsed.
0129  *  - error id is in higher 16-bits of IPC low payload for async errors.
0130  */
0131 #define SST_ASYNC_DRV_ID 0
0132 
0133 /* Command Response or Acknowledge message to any IPC message will have
0134  * same message ID and stream ID information which is sent.
0135  * There is no specific Ack message ID. The data field is used as response
0136  * meaning.
0137  */
0138 enum ackData {
0139     IPC_ACK_SUCCESS = 0,
0140     IPC_ACK_FAILURE,
0141 };
0142 
0143 enum ipc_ia_msg_id {
0144     IPC_CMD = 1,        /*!< Task Control message ID */
0145     IPC_SET_PARAMS = 2,/*!< Task Set param message ID */
0146     IPC_GET_PARAMS = 3, /*!< Task Get param message ID */
0147     IPC_INVALID = 0xFF, /*!<Task Get param message ID */
0148 };
0149 
0150 enum sst_codec_types {
0151     /*  AUDIO/MUSIC CODEC Type Definitions */
0152     SST_CODEC_TYPE_UNKNOWN = 0,
0153     SST_CODEC_TYPE_PCM, /* Pass through Audio codec */
0154     SST_CODEC_TYPE_MP3,
0155     SST_CODEC_TYPE_MP24,
0156     SST_CODEC_TYPE_AAC,
0157     SST_CODEC_TYPE_AACP,
0158     SST_CODEC_TYPE_eAACP,
0159 };
0160 
0161 enum stream_type {
0162     SST_STREAM_TYPE_NONE = 0,
0163     SST_STREAM_TYPE_MUSIC = 1,
0164 };
0165 
0166 enum sst_error_codes {
0167     /* Error code,response to msgId: Description */
0168     /* Common error codes */
0169     SST_SUCCESS = 0,        /* Success */
0170     SST_ERR_INVALID_STREAM_ID = 1,
0171     SST_ERR_INVALID_MSG_ID = 2,
0172     SST_ERR_INVALID_STREAM_OP = 3,
0173     SST_ERR_INVALID_PARAMS = 4,
0174     SST_ERR_INVALID_CODEC = 5,
0175     SST_ERR_INVALID_MEDIA_TYPE = 6,
0176     SST_ERR_STREAM_ERR = 7,
0177 
0178     SST_ERR_STREAM_IN_USE = 15,
0179 };
0180 
0181 struct ipc_dsp_hdr {
0182     u16 mod_index_id:8;     /*!< DSP Command ID specific to tasks */
0183     u16 pipe_id:8;  /*!< instance of the module in the pipeline */
0184     u16 mod_id;     /*!< Pipe_id */
0185     u16 cmd_id;     /*!< Module ID = lpe_algo_types_t */
0186     u16 length;     /*!< Length of the payload only */
0187 } __packed;
0188 
0189 union ipc_header_high {
0190     struct {
0191         u32  msg_id:8;      /* Message ID - Max 256 Message Types */
0192         u32  task_id:4;     /* Task ID associated with this comand */
0193         u32  drv_id:4;    /* Identifier for the driver to track*/
0194         u32  rsvd1:8;       /* Reserved */
0195         u32  result:4;      /* Reserved */
0196         u32  res_rqd:1;     /* Response rqd */
0197         u32  large:1;       /* Large Message if large = 1 */
0198         u32  done:1;        /* bit 30 - Done bit */
0199         u32  busy:1;        /* bit 31 - busy bit*/
0200     } part;
0201     u32 full;
0202 } __packed;
0203 /* IPC header */
0204 union ipc_header_mrfld {
0205     struct {
0206         u32 header_low_payload;
0207         union ipc_header_high header_high;
0208     } p;
0209     u64 full;
0210 } __packed;
0211 /* CAUTION NOTE: All IPC message body must be multiple of 32 bits.*/
0212 
0213 /* IPC Header */
0214 union ipc_header {
0215     struct {
0216         u32  msg_id:8; /* Message ID - Max 256 Message Types */
0217         u32  str_id:5;
0218         u32  large:1;   /* Large Message if large = 1 */
0219         u32  reserved:2;    /* Reserved for future use */
0220         u32  data:14;   /* Ack/Info for msg, size of msg in Mailbox */
0221         u32  done:1; /* bit 30 */
0222         u32  busy:1; /* bit 31 */
0223     } part;
0224     u32 full;
0225 } __packed;
0226 
0227 /* Firmware build info */
0228 struct sst_fw_build_info {
0229     unsigned char  date[16]; /* Firmware build date */
0230     unsigned char  time[16]; /* Firmware build time */
0231 } __packed;
0232 
0233 /* Firmware Version info */
0234 struct snd_sst_fw_version {
0235     u8 build;   /* build number*/
0236     u8 minor;   /* minor number*/
0237     u8 major;   /* major number*/
0238     u8 type;    /* build type */
0239 };
0240 
0241 struct ipc_header_fw_init {
0242     struct snd_sst_fw_version fw_version;/* Firmware version details */
0243     struct sst_fw_build_info build_info;
0244     u16 result; /* Fw init result */
0245     u8 module_id; /* Module ID in case of error */
0246     u8 debug_info; /* Debug info from Module ID in case of fail */
0247 } __packed;
0248 
0249 struct snd_sst_tstamp {
0250     u64 ring_buffer_counter;    /* PB/CP: Bytes copied from/to DDR. */
0251     u64 hardware_counter;       /* PB/CP: Bytes DMAed to/from SSP. */
0252     u64 frames_decoded;
0253     u64 bytes_decoded;
0254     u64 bytes_copied;
0255     u32 sampling_frequency;
0256     u32 channel_peak[8];
0257 } __packed;
0258 
0259 /* Stream type params structure for Alloc stream */
0260 struct snd_sst_str_type {
0261     u8 codec_type;      /* Codec type */
0262     u8 str_type;        /* 1 = voice 2 = music */
0263     u8 operation;       /* Playback or Capture */
0264     u8 protected_str;   /* 0=Non DRM, 1=DRM */
0265     u8 time_slots;
0266     u8 reserved;        /* Reserved */
0267     u16 result;     /* Result used for acknowledgment */
0268 } __packed;
0269 
0270 /* Library info structure */
0271 struct module_info {
0272     u32 lib_version;
0273     u32 lib_type;/*TBD- KLOCKWORK u8 lib_type;*/
0274     u32 media_type;
0275     u8  lib_name[12];
0276     u32 lib_caps;
0277     unsigned char  b_date[16]; /* Lib build date */
0278     unsigned char  b_time[16]; /* Lib build time */
0279 } __packed;
0280 
0281 /* Library slot info */
0282 struct lib_slot_info {
0283     u8  slot_num; /* 1 or 2 */
0284     u8  reserved1;
0285     u16 reserved2;
0286     u32 iram_size; /* slot size in IRAM */
0287     u32 dram_size; /* slot size in DRAM */
0288     u32 iram_offset; /* starting offset of slot in IRAM */
0289     u32 dram_offset; /* starting offset of slot in DRAM */
0290 } __packed;
0291 
0292 struct snd_ppp_mixer_params {
0293     __u32           type; /*Type of the parameter */
0294     __u32           size;
0295     __u32           input_stream_bitmap; /*Input stream Bit Map*/
0296 } __packed;
0297 
0298 struct snd_sst_lib_download {
0299     struct module_info lib_info; /* library info type, capabilities etc */
0300     struct lib_slot_info slot_info; /* slot info to be downloaded */
0301     u32 mod_entry_pt;
0302 };
0303 
0304 struct snd_sst_lib_download_info {
0305     struct snd_sst_lib_download dload_lib;
0306     u16 result; /* Result used for acknowledgment */
0307     u8 pvt_id; /* Private ID */
0308     u8 reserved;  /* for alignment */
0309 };
0310 struct snd_pcm_params {
0311     u8 num_chan;    /* 1=Mono, 2=Stereo */
0312     u8 pcm_wd_sz;   /* 16/24 - bit*/
0313     u8 use_offload_path;    /* 0-PCM using period elpased & ALSA interfaces
0314                    1-PCM stream via compressed interface  */
0315     u8 reserved2;
0316     u32 sfreq;    /* Sampling rate in Hz */
0317     u8 channel_map[8];
0318 } __packed;
0319 
0320 /* MP3 Music Parameters Message */
0321 struct snd_mp3_params {
0322     u8  num_chan;   /* 1=Mono, 2=Stereo */
0323     u8  pcm_wd_sz; /* 16/24 - bit*/
0324     u8  crc_check; /* crc_check - disable (0) or enable (1) */
0325     u8  reserved1; /* unused*/
0326     u16 reserved2;  /* Unused */
0327 } __packed;
0328 
0329 #define AAC_BIT_STREAM_ADTS     0
0330 #define AAC_BIT_STREAM_ADIF     1
0331 #define AAC_BIT_STREAM_RAW      2
0332 
0333 /* AAC Music Parameters Message */
0334 struct snd_aac_params {
0335     u8 num_chan; /* 1=Mono, 2=Stereo*/
0336     u8 pcm_wd_sz; /* 16/24 - bit*/
0337     u8 bdownsample; /*SBR downsampling 0 - disable 1 -enabled AAC+ only */
0338     u8 bs_format; /* input bit stream format adts=0, adif=1, raw=2 */
0339     u16  reser2;
0340     u32 externalsr; /*sampling rate of basic AAC raw bit stream*/
0341     u8 sbr_signalling;/*disable/enable/set automode the SBR tool.AAC+*/
0342     u8 reser1;
0343     u16  reser3;
0344 } __packed;
0345 
0346 /* WMA Music Parameters Message */
0347 struct snd_wma_params {
0348     u8  num_chan;   /* 1=Mono, 2=Stereo */
0349     u8  pcm_wd_sz;  /* 16/24 - bit*/
0350     u16 reserved1;
0351     u32 brate;  /* Use the hard coded value. */
0352     u32 sfreq;  /* Sampling freq eg. 8000, 441000, 48000 */
0353     u32 channel_mask;  /* Channel Mask */
0354     u16 format_tag; /* Format Tag */
0355     u16 block_align;    /* packet size */
0356     u16 wma_encode_opt;/* Encoder option */
0357     u8 op_align;    /* op align 0- 16 bit, 1- MSB, 2 LSB */
0358     u8 reserved;    /* reserved */
0359 } __packed;
0360 
0361 /* Codec params structure */
0362 union  snd_sst_codec_params {
0363     struct snd_pcm_params pcm_params;
0364     struct snd_mp3_params mp3_params;
0365     struct snd_aac_params aac_params;
0366     struct snd_wma_params wma_params;
0367 } __packed;
0368 
0369 /* Address and size info of a frame buffer */
0370 struct sst_address_info {
0371     u32 addr; /* Address at IA */
0372     u32 size; /* Size of the buffer */
0373 };
0374 
0375 struct snd_sst_alloc_params_ext {
0376     __u16 sg_count;
0377     __u16 reserved;
0378     __u32 frag_size;    /*Number of samples after which period elapsed
0379                   message is sent valid only if path  = 0*/
0380     struct sst_address_info  ring_buf_info[8];
0381 };
0382 
0383 struct snd_sst_stream_params {
0384     union snd_sst_codec_params uc;
0385 } __packed;
0386 
0387 struct snd_sst_params {
0388     u32 result;
0389     u32 stream_id;
0390     u8 codec;
0391     u8 ops;
0392     u8 stream_type;
0393     u8 device_type;
0394     u8 task;
0395     struct snd_sst_stream_params sparams;
0396     struct snd_sst_alloc_params_ext aparams;
0397 };
0398 
0399 struct snd_sst_alloc_mrfld {
0400     u16 codec_type;
0401     u8 operation;
0402     u8 sg_count;
0403     struct sst_address_info ring_buf_info[8];
0404     u32 frag_size;
0405     u32 ts;
0406     struct snd_sst_stream_params codec_params;
0407 } __packed;
0408 
0409 /* Alloc stream params structure */
0410 struct snd_sst_alloc_params {
0411     struct snd_sst_str_type str_type;
0412     struct snd_sst_stream_params stream_params;
0413     struct snd_sst_alloc_params_ext alloc_params;
0414 } __packed;
0415 
0416 /* Alloc stream response message */
0417 struct snd_sst_alloc_response {
0418     struct snd_sst_str_type str_type; /* Stream type for allocation */
0419     struct snd_sst_lib_download lib_dnld; /* Valid only for codec dnld */
0420 };
0421 
0422 /* Drop response */
0423 struct snd_sst_drop_response {
0424     u32 result;
0425     u32 bytes;
0426 };
0427 
0428 struct snd_sst_async_msg {
0429     u32 msg_id; /* Async msg id */
0430     u32 payload[];
0431 };
0432 
0433 struct snd_sst_async_err_msg {
0434     u32 fw_resp; /* Firmware Result */
0435     u32 lib_resp; /*Library result */
0436 } __packed;
0437 
0438 struct snd_sst_vol {
0439     u32 stream_id;
0440     s32 volume;
0441     u32 ramp_duration;
0442     u32 ramp_type;      /* Ramp type, default=0 */
0443 };
0444 
0445 /* Gain library parameters for mrfld
0446  * based on DSP command spec v0.82
0447  */
0448 struct snd_sst_gain_v2 {
0449     u16 gain_cell_num;  /* num of gain cells to modify*/
0450     u8 cell_nbr_idx; /* instance index*/
0451     u8 cell_path_idx; /* pipe-id */
0452     u16 module_id; /*module id */
0453     u16 left_cell_gain; /* left gain value in dB*/
0454     u16 right_cell_gain; /* right gain value in dB*/
0455     u16 gain_time_const; /* gain time constant*/
0456 } __packed;
0457 
0458 struct snd_sst_mute {
0459     u32 stream_id;
0460     u32 mute;
0461 };
0462 
0463 struct snd_sst_runtime_params {
0464     u8 type;
0465     u8 str_id;
0466     u8 size;
0467     u8 rsvd;
0468     void *addr;
0469 } __packed;
0470 
0471 enum stream_param_type {
0472     SST_SET_TIME_SLOT = 0,
0473     SST_SET_CHANNEL_INFO = 1,
0474     OTHERS = 2, /*reserved for future params*/
0475 };
0476 
0477 /* CSV Voice call routing structure */
0478 struct snd_sst_control_routing {
0479     u8 control; /* 0=start, 1=Stop */
0480     u8 reserved[3]; /* Reserved- for 32 bit alignment */
0481 };
0482 
0483 struct ipc_post {
0484     struct list_head node;
0485     union ipc_header header; /* driver specific */
0486     bool is_large;
0487     bool is_process_reply;
0488     union ipc_header_mrfld mrfld_header;
0489     char *mailbox_data;
0490 };
0491 
0492 struct snd_sst_ctxt_params {
0493     u32 address; /* Physical Address in DDR where the context is stored */
0494     u32 size; /* size of the context */
0495 };
0496 
0497 struct snd_sst_lpe_log_params {
0498     u8 dbg_type;
0499     u8 module_id;
0500     u8 log_level;
0501     u8 reserved;
0502 } __packed;
0503 
0504 enum snd_sst_bytes_type {
0505     SND_SST_BYTES_SET = 0x1,
0506     SND_SST_BYTES_GET = 0x2,
0507 };
0508 
0509 struct snd_sst_bytes_v2 {
0510     u8 type;
0511     u8 ipc_msg;
0512     u8 block;
0513     u8 task_id;
0514     u8 pipe_id;
0515     u8 rsvd;
0516     u16 len;
0517     char bytes[];
0518 };
0519 
0520 #define MAX_VTSV_FILES 2
0521 struct snd_sst_vtsv_info {
0522     struct sst_address_info vfiles[MAX_VTSV_FILES];
0523 } __packed;
0524 
0525 #endif /* __SST_MFLD_DSP_H__ */