18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __Q6_ASM_H__ 38c2ecf20Sopenharmony_ci#define __Q6_ASM_H__ 48c2ecf20Sopenharmony_ci#include "q6dsp-common.h" 58c2ecf20Sopenharmony_ci#include <dt-bindings/sound/qcom,q6asm.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* ASM client callback events */ 88c2ecf20Sopenharmony_ci#define CMD_PAUSE 0x0001 98c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_CMD_PAUSE_DONE 0x1001 108c2ecf20Sopenharmony_ci#define CMD_FLUSH 0x0002 118c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_CMD_FLUSH_DONE 0x1002 128c2ecf20Sopenharmony_ci#define CMD_EOS 0x0003 138c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_CMD_EOS_DONE 0x1003 148c2ecf20Sopenharmony_ci#define CMD_CLOSE 0x0004 158c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_CMD_CLOSE_DONE 0x1004 168c2ecf20Sopenharmony_ci#define CMD_OUT_FLUSH 0x0005 178c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_CMD_OUT_FLUSH_DONE 0x1005 188c2ecf20Sopenharmony_ci#define CMD_SUSPEND 0x0006 198c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_CMD_SUSPEND_DONE 0x1006 208c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_CMD_RUN_DONE 0x1008 218c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_DATA_WRITE_DONE 0x1009 228c2ecf20Sopenharmony_ci#define ASM_CLIENT_EVENT_DATA_READ_DONE 0x100a 238c2ecf20Sopenharmony_ci#define ASM_WRITE_TOKEN_MASK GENMASK(15, 0) 248c2ecf20Sopenharmony_ci#define ASM_WRITE_TOKEN_LEN_MASK GENMASK(31, 16) 258c2ecf20Sopenharmony_ci#define ASM_WRITE_TOKEN_LEN_SHIFT 16 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cienum { 288c2ecf20Sopenharmony_ci LEGACY_PCM_MODE = 0, 298c2ecf20Sopenharmony_ci LOW_LATENCY_PCM_MODE, 308c2ecf20Sopenharmony_ci ULTRA_LOW_LATENCY_PCM_MODE, 318c2ecf20Sopenharmony_ci ULL_POST_PROCESSING_PCM_MODE, 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define MAX_SESSIONS 8 358c2ecf20Sopenharmony_ci#define FORMAT_LINEAR_PCM 0x0000 368c2ecf20Sopenharmony_ci#define ASM_LAST_BUFFER_FLAG BIT(30) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistruct q6asm_flac_cfg { 398c2ecf20Sopenharmony_ci u32 sample_rate; 408c2ecf20Sopenharmony_ci u32 ext_sample_rate; 418c2ecf20Sopenharmony_ci u32 min_frame_size; 428c2ecf20Sopenharmony_ci u32 max_frame_size; 438c2ecf20Sopenharmony_ci u16 stream_info_present; 448c2ecf20Sopenharmony_ci u16 min_blk_size; 458c2ecf20Sopenharmony_ci u16 max_blk_size; 468c2ecf20Sopenharmony_ci u16 ch_cfg; 478c2ecf20Sopenharmony_ci u16 sample_size; 488c2ecf20Sopenharmony_ci u16 md5_sum; 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistruct q6asm_wma_cfg { 528c2ecf20Sopenharmony_ci u32 fmtag; 538c2ecf20Sopenharmony_ci u32 num_channels; 548c2ecf20Sopenharmony_ci u32 sample_rate; 558c2ecf20Sopenharmony_ci u32 bytes_per_sec; 568c2ecf20Sopenharmony_ci u32 block_align; 578c2ecf20Sopenharmony_ci u32 bits_per_sample; 588c2ecf20Sopenharmony_ci u32 channel_mask; 598c2ecf20Sopenharmony_ci u32 enc_options; 608c2ecf20Sopenharmony_ci u32 adv_enc_options; 618c2ecf20Sopenharmony_ci u32 adv_enc_options2; 628c2ecf20Sopenharmony_ci}; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistruct q6asm_alac_cfg { 658c2ecf20Sopenharmony_ci u32 frame_length; 668c2ecf20Sopenharmony_ci u8 compatible_version; 678c2ecf20Sopenharmony_ci u8 bit_depth; 688c2ecf20Sopenharmony_ci u8 pb; 698c2ecf20Sopenharmony_ci u8 mb; 708c2ecf20Sopenharmony_ci u8 kb; 718c2ecf20Sopenharmony_ci u8 num_channels; 728c2ecf20Sopenharmony_ci u16 max_run; 738c2ecf20Sopenharmony_ci u32 max_frame_bytes; 748c2ecf20Sopenharmony_ci u32 avg_bit_rate; 758c2ecf20Sopenharmony_ci u32 sample_rate; 768c2ecf20Sopenharmony_ci u32 channel_layout_tag; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistruct q6asm_ape_cfg { 808c2ecf20Sopenharmony_ci u16 compatible_version; 818c2ecf20Sopenharmony_ci u16 compression_level; 828c2ecf20Sopenharmony_ci u32 format_flags; 838c2ecf20Sopenharmony_ci u32 blocks_per_frame; 848c2ecf20Sopenharmony_ci u32 final_frame_blocks; 858c2ecf20Sopenharmony_ci u32 total_frames; 868c2ecf20Sopenharmony_ci u16 bits_per_sample; 878c2ecf20Sopenharmony_ci u16 num_channels; 888c2ecf20Sopenharmony_ci u32 sample_rate; 898c2ecf20Sopenharmony_ci u32 seek_table_present; 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_citypedef void (*q6asm_cb) (uint32_t opcode, uint32_t token, 938c2ecf20Sopenharmony_ci void *payload, void *priv); 948c2ecf20Sopenharmony_cistruct audio_client; 958c2ecf20Sopenharmony_cistruct audio_client *q6asm_audio_client_alloc(struct device *dev, 968c2ecf20Sopenharmony_ci q6asm_cb cb, void *priv, 978c2ecf20Sopenharmony_ci int session_id, int perf_mode); 988c2ecf20Sopenharmony_civoid q6asm_audio_client_free(struct audio_client *ac); 998c2ecf20Sopenharmony_ciint q6asm_write_async(struct audio_client *ac, uint32_t stream_id, uint32_t len, 1008c2ecf20Sopenharmony_ci uint32_t msw_ts, uint32_t lsw_ts, uint32_t flags); 1018c2ecf20Sopenharmony_ciint q6asm_open_write(struct audio_client *ac, uint32_t stream_id, 1028c2ecf20Sopenharmony_ci uint32_t format, u32 codec_profile, 1038c2ecf20Sopenharmony_ci uint16_t bits_per_sample, bool is_gapless); 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciint q6asm_open_read(struct audio_client *ac, uint32_t stream_id, 1068c2ecf20Sopenharmony_ci uint32_t format, uint16_t bits_per_sample); 1078c2ecf20Sopenharmony_ciint q6asm_enc_cfg_blk_pcm_format_support(struct audio_client *ac, 1088c2ecf20Sopenharmony_ci uint32_t stream_id, uint32_t rate, 1098c2ecf20Sopenharmony_ci uint32_t channels, 1108c2ecf20Sopenharmony_ci uint16_t bits_per_sample); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ciint q6asm_read(struct audio_client *ac, uint32_t stream_id); 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ciint q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac, 1158c2ecf20Sopenharmony_ci uint32_t stream_id, 1168c2ecf20Sopenharmony_ci uint32_t rate, uint32_t channels, 1178c2ecf20Sopenharmony_ci u8 channel_map[PCM_MAX_NUM_CHANNEL], 1188c2ecf20Sopenharmony_ci uint16_t bits_per_sample); 1198c2ecf20Sopenharmony_ciint q6asm_stream_media_format_block_flac(struct audio_client *ac, 1208c2ecf20Sopenharmony_ci uint32_t stream_id, 1218c2ecf20Sopenharmony_ci struct q6asm_flac_cfg *cfg); 1228c2ecf20Sopenharmony_ciint q6asm_stream_media_format_block_wma_v9(struct audio_client *ac, 1238c2ecf20Sopenharmony_ci uint32_t stream_id, 1248c2ecf20Sopenharmony_ci struct q6asm_wma_cfg *cfg); 1258c2ecf20Sopenharmony_ciint q6asm_stream_media_format_block_wma_v10(struct audio_client *ac, 1268c2ecf20Sopenharmony_ci uint32_t stream_id, 1278c2ecf20Sopenharmony_ci struct q6asm_wma_cfg *cfg); 1288c2ecf20Sopenharmony_ciint q6asm_stream_media_format_block_alac(struct audio_client *ac, 1298c2ecf20Sopenharmony_ci uint32_t stream_id, 1308c2ecf20Sopenharmony_ci struct q6asm_alac_cfg *cfg); 1318c2ecf20Sopenharmony_ciint q6asm_stream_media_format_block_ape(struct audio_client *ac, 1328c2ecf20Sopenharmony_ci uint32_t stream_id, 1338c2ecf20Sopenharmony_ci struct q6asm_ape_cfg *cfg); 1348c2ecf20Sopenharmony_ciint q6asm_run(struct audio_client *ac, uint32_t stream_id, uint32_t flags, 1358c2ecf20Sopenharmony_ci uint32_t msw_ts, uint32_t lsw_ts); 1368c2ecf20Sopenharmony_ciint q6asm_run_nowait(struct audio_client *ac, uint32_t stream_id, 1378c2ecf20Sopenharmony_ci uint32_t flags, uint32_t msw_ts, uint32_t lsw_ts); 1388c2ecf20Sopenharmony_ciint q6asm_stream_remove_initial_silence(struct audio_client *ac, 1398c2ecf20Sopenharmony_ci uint32_t stream_id, 1408c2ecf20Sopenharmony_ci uint32_t initial_samples); 1418c2ecf20Sopenharmony_ciint q6asm_stream_remove_trailing_silence(struct audio_client *ac, 1428c2ecf20Sopenharmony_ci uint32_t stream_id, 1438c2ecf20Sopenharmony_ci uint32_t trailing_samples); 1448c2ecf20Sopenharmony_ciint q6asm_cmd(struct audio_client *ac, uint32_t stream_id, int cmd); 1458c2ecf20Sopenharmony_ciint q6asm_cmd_nowait(struct audio_client *ac, uint32_t stream_id, int cmd); 1468c2ecf20Sopenharmony_ciint q6asm_get_session_id(struct audio_client *ac); 1478c2ecf20Sopenharmony_ciint q6asm_map_memory_regions(unsigned int dir, 1488c2ecf20Sopenharmony_ci struct audio_client *ac, 1498c2ecf20Sopenharmony_ci phys_addr_t phys, 1508c2ecf20Sopenharmony_ci size_t bufsz, unsigned int bufcnt); 1518c2ecf20Sopenharmony_ciint q6asm_unmap_memory_regions(unsigned int dir, struct audio_client *ac); 1528c2ecf20Sopenharmony_ci#endif /* __Q6_ASM_H__ */ 153