0001
0002 #ifndef __Q6_ASM_H__
0003 #define __Q6_ASM_H__
0004 #include "q6dsp-common.h"
0005 #include <dt-bindings/sound/qcom,q6asm.h>
0006
0007
0008 #define CMD_PAUSE 0x0001
0009 #define ASM_CLIENT_EVENT_CMD_PAUSE_DONE 0x1001
0010 #define CMD_FLUSH 0x0002
0011 #define ASM_CLIENT_EVENT_CMD_FLUSH_DONE 0x1002
0012 #define CMD_EOS 0x0003
0013 #define ASM_CLIENT_EVENT_CMD_EOS_DONE 0x1003
0014 #define CMD_CLOSE 0x0004
0015 #define ASM_CLIENT_EVENT_CMD_CLOSE_DONE 0x1004
0016 #define CMD_OUT_FLUSH 0x0005
0017 #define ASM_CLIENT_EVENT_CMD_OUT_FLUSH_DONE 0x1005
0018 #define CMD_SUSPEND 0x0006
0019 #define ASM_CLIENT_EVENT_CMD_SUSPEND_DONE 0x1006
0020 #define ASM_CLIENT_EVENT_CMD_RUN_DONE 0x1008
0021 #define ASM_CLIENT_EVENT_DATA_WRITE_DONE 0x1009
0022 #define ASM_CLIENT_EVENT_DATA_READ_DONE 0x100a
0023 #define ASM_WRITE_TOKEN_MASK GENMASK(15, 0)
0024 #define ASM_WRITE_TOKEN_LEN_MASK GENMASK(31, 16)
0025 #define ASM_WRITE_TOKEN_LEN_SHIFT 16
0026
0027 enum {
0028 LEGACY_PCM_MODE = 0,
0029 LOW_LATENCY_PCM_MODE,
0030 ULTRA_LOW_LATENCY_PCM_MODE,
0031 ULL_POST_PROCESSING_PCM_MODE,
0032 };
0033
0034 #define MAX_SESSIONS 8
0035 #define FORMAT_LINEAR_PCM 0x0000
0036 #define ASM_LAST_BUFFER_FLAG BIT(30)
0037
0038 struct q6asm_flac_cfg {
0039 u32 sample_rate;
0040 u32 ext_sample_rate;
0041 u32 min_frame_size;
0042 u32 max_frame_size;
0043 u16 stream_info_present;
0044 u16 min_blk_size;
0045 u16 max_blk_size;
0046 u16 ch_cfg;
0047 u16 sample_size;
0048 u16 md5_sum;
0049 };
0050
0051 struct q6asm_wma_cfg {
0052 u32 fmtag;
0053 u32 num_channels;
0054 u32 sample_rate;
0055 u32 bytes_per_sec;
0056 u32 block_align;
0057 u32 bits_per_sample;
0058 u32 channel_mask;
0059 u32 enc_options;
0060 u32 adv_enc_options;
0061 u32 adv_enc_options2;
0062 };
0063
0064 struct q6asm_alac_cfg {
0065 u32 frame_length;
0066 u8 compatible_version;
0067 u8 bit_depth;
0068 u8 pb;
0069 u8 mb;
0070 u8 kb;
0071 u8 num_channels;
0072 u16 max_run;
0073 u32 max_frame_bytes;
0074 u32 avg_bit_rate;
0075 u32 sample_rate;
0076 u32 channel_layout_tag;
0077 };
0078
0079 struct q6asm_ape_cfg {
0080 u16 compatible_version;
0081 u16 compression_level;
0082 u32 format_flags;
0083 u32 blocks_per_frame;
0084 u32 final_frame_blocks;
0085 u32 total_frames;
0086 u16 bits_per_sample;
0087 u16 num_channels;
0088 u32 sample_rate;
0089 u32 seek_table_present;
0090 };
0091
0092 typedef void (*q6asm_cb) (uint32_t opcode, uint32_t token,
0093 void *payload, void *priv);
0094 struct audio_client;
0095 struct audio_client *q6asm_audio_client_alloc(struct device *dev,
0096 q6asm_cb cb, void *priv,
0097 int session_id, int perf_mode);
0098 void q6asm_audio_client_free(struct audio_client *ac);
0099 int q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len,
0100 uint32_t msw_ts, uint32_t lsw_ts, uint32_t wflags);
0101 int q6asm_open_write(struct audio_client *ac, uint32_t stream_id,
0102 uint32_t format, u32 codec_profile,
0103 uint16_t bits_per_sample, bool is_gapless);
0104
0105 int q6asm_open_read(struct audio_client *ac, uint32_t stream_id,
0106 uint32_t format, uint16_t bits_per_sample);
0107 int q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac,
0108 uint32_t stream_id, uint32_t rate,
0109 uint32_t channels,
0110 uint16_t bits_per_sample);
0111
0112 int q6asm_read(struct audio_client *ac, uint32_t stream_id);
0113
0114 int q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
0115 uint32_t stream_id,
0116 uint32_t rate, uint32_t channels,
0117 u8 channel_map[PCM_MAX_NUM_CHANNEL],
0118 uint16_t bits_per_sample);
0119 int q6asm_stream_media_format_block_flac(struct audio_client *ac,
0120 uint32_t stream_id,
0121 struct q6asm_flac_cfg *cfg);
0122 int q6asm_stream_media_format_block_wma_v9(struct audio_client *ac,
0123 uint32_t stream_id,
0124 struct q6asm_wma_cfg *cfg);
0125 int q6asm_stream_media_format_block_wma_v10(struct audio_client *ac,
0126 uint32_t stream_id,
0127 struct q6asm_wma_cfg *cfg);
0128 int q6asm_stream_media_format_block_alac(struct audio_client *ac,
0129 uint32_t stream_id,
0130 struct q6asm_alac_cfg *cfg);
0131 int q6asm_stream_media_format_block_ape(struct audio_client *ac,
0132 uint32_t stream_id,
0133 struct q6asm_ape_cfg *cfg);
0134 int q6asm_run(struct audio_client *ac, uint32_t stream_id, uint32_t flags,
0135 uint32_t msw_ts, uint32_t lsw_ts);
0136 int q6asm_run_nowait(struct audio_client *ac, uint32_t stream_id,
0137 uint32_t flags, uint32_t msw_ts, uint32_t lsw_ts);
0138 int q6asm_stream_remove_initial_silence(struct audio_client *ac,
0139 uint32_t stream_id,
0140 uint32_t initial_samples);
0141 int q6asm_stream_remove_trailing_silence(struct audio_client *ac,
0142 uint32_t stream_id,
0143 uint32_t trailing_samples);
0144 int q6asm_cmd(struct audio_client *ac, uint32_t stream_id, int cmd);
0145 int q6asm_cmd_nowait(struct audio_client *ac, uint32_t stream_id, int cmd);
0146 int q6asm_get_session_id(struct audio_client *c);
0147 int q6asm_map_memory_regions(unsigned int dir,
0148 struct audio_client *ac,
0149 phys_addr_t phys,
0150 size_t period_sz, unsigned int periods);
0151 int q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac);
0152 #endif