Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2010-2015, 2017 The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | #include <linux/msm_audio.h> |
| 14 | #include <linux/compat.h> |
| 15 | #include "q6audio_common.h" |
| 16 | |
| 17 | #define FRAME_NUM (8) |
| 18 | |
| 19 | #define PCM_BUF_COUNT (2) |
| 20 | |
| 21 | #define AUD_EOS_SET 0x01 |
| 22 | #define TUNNEL_MODE 0x0000 |
| 23 | #define NON_TUNNEL_MODE 0x0001 |
| 24 | |
| 25 | #define NO_BUF_ALLOC 0x00 |
| 26 | #define BUF_ALLOC_IN 0x01 |
| 27 | #define BUF_ALLOC_OUT 0x02 |
| 28 | #define BUF_ALLOC_INOUT 0x03 |
| 29 | #define ALIGN_BUF_SIZE(size) ((size + 4095) & (~4095)) |
| 30 | |
| 31 | struct timestamp { |
| 32 | u32 lowpart; |
| 33 | u32 highpart; |
| 34 | } __packed; |
| 35 | |
| 36 | struct meta_in { |
| 37 | unsigned short offset; |
| 38 | struct timestamp ntimestamp; |
| 39 | unsigned int nflags; |
| 40 | } __packed; |
| 41 | |
| 42 | struct meta_out_dsp { |
| 43 | u32 offset_to_frame; |
| 44 | u32 frame_size; |
| 45 | u32 encoded_pcm_samples; |
| 46 | u32 msw_ts; |
| 47 | u32 lsw_ts; |
| 48 | u32 nflags; |
| 49 | } __packed; |
| 50 | |
| 51 | struct meta_out { |
| 52 | unsigned char num_of_frames; |
| 53 | struct meta_out_dsp meta_out_dsp[]; |
| 54 | } __packed; |
| 55 | |
| 56 | struct q6audio_in { |
| 57 | spinlock_t dsp_lock; |
| 58 | atomic_t in_bytes; |
| 59 | atomic_t in_samples; |
| 60 | |
| 61 | struct mutex lock; |
| 62 | struct mutex read_lock; |
| 63 | struct mutex write_lock; |
| 64 | wait_queue_head_t read_wait; |
| 65 | wait_queue_head_t write_wait; |
| 66 | |
| 67 | struct audio_client *ac; |
| 68 | struct msm_audio_stream_config str_cfg; |
| 69 | void *enc_cfg; |
| 70 | struct msm_audio_buf_cfg buf_cfg; |
| 71 | struct msm_audio_config pcm_cfg; |
| 72 | void *codec_cfg; |
| 73 | |
| 74 | /* number of buffers available to read/write */ |
| 75 | atomic_t in_count; |
| 76 | atomic_t out_count; |
| 77 | |
| 78 | /* first idx: num of frames per buf, second idx: offset to frame */ |
| 79 | uint32_t out_frame_info[FRAME_NUM][2]; |
| 80 | int eos_rsp; |
| 81 | int opened; |
| 82 | int enabled; |
| 83 | int stopped; |
| 84 | int event_abort; |
| 85 | int feedback; /* Flag indicates whether used |
| 86 | * in Non Tunnel mode |
| 87 | */ |
| 88 | int rflush; |
| 89 | int wflush; |
| 90 | int buf_alloc; |
| 91 | uint16_t min_frame_size; |
| 92 | uint16_t max_frames_per_buf; |
| 93 | bool reset_event; |
| 94 | long (*enc_ioctl)(struct file *, unsigned int, unsigned long); |
| 95 | long (*enc_compat_ioctl)(struct file *, unsigned int, unsigned long); |
| 96 | }; |
| 97 | |
| 98 | int audio_in_enable(struct q6audio_in *audio); |
| 99 | int audio_in_disable(struct q6audio_in *audio); |
| 100 | int audio_in_buf_alloc(struct q6audio_in *audio); |
| 101 | long audio_in_ioctl(struct file *file, |
| 102 | unsigned int cmd, unsigned long arg); |
| 103 | #ifdef CONFIG_COMPAT |
| 104 | long audio_in_compat_ioctl(struct file *file, |
| 105 | unsigned int cmd, unsigned long arg); |
| 106 | #else |
| 107 | #define audio_in_compat_ioctl NULL |
| 108 | #endif |
| 109 | ssize_t audio_in_read(struct file *file, char __user *buf, |
| 110 | size_t count, loff_t *pos); |
| 111 | ssize_t audio_in_write(struct file *file, const char __user *buf, |
| 112 | size_t count, loff_t *pos); |
| 113 | int audio_in_release(struct inode *inode, struct file *file); |
| 114 | int audio_in_set_config(struct file *file, struct msm_audio_config *cfg); |
Laxminath Kasam | 8b1366a | 2017-10-05 01:44:16 +0530 | [diff] [blame] | 115 | int aac_in_init(void); |
| 116 | int amrnb_in_init(void); |
| 117 | int amrwb_in_init(void); |
| 118 | int audio_aac_init(void); |
| 119 | int audio_alac_init(void); |
| 120 | int audio_amrnb_init(void); |
| 121 | int audio_amrwb_init(void); |
| 122 | int audio_amrwbplus_init(void); |
| 123 | int audio_ape_init(void); |
| 124 | int audio_evrc_init(void); |
| 125 | int audio_g711alaw_init(void); |
| 126 | int audio_g711mlaw_init(void); |
| 127 | int audio_effects_init(void); |
| 128 | int audio_mp3_init(void); |
| 129 | int audio_multiaac_init(void); |
| 130 | int audio_qcelp_init(void); |
| 131 | int audio_wma_init(void); |
| 132 | int audio_wmapro_init(void); |
| 133 | int evrc_in_init(void); |
| 134 | int g711alaw_in_init(void); |
| 135 | int g711mlaw_in_init(void); |
| 136 | int qcelp_in_init(void); |
| 137 | void aac_in_exit(void); |
| 138 | void amrnb_in_exit(void); |
| 139 | void amrwb_in_exit(void); |
| 140 | void audio_aac_exit(void); |
| 141 | void audio_alac_exit(void); |
| 142 | void audio_amrnb_exit(void); |
| 143 | void audio_amrwb_exit(void); |
| 144 | void audio_amrwbplus_exit(void); |
| 145 | void audio_ape_exit(void); |
| 146 | void audio_evrc_exit(void); |
| 147 | void audio_g711alaw_exit(void); |
| 148 | void audio_g711mlaw_exit(void); |
| 149 | void audio_effects_exit(void); |
| 150 | void audio_mp3_exit(void); |
| 151 | void audio_multiaac_exit(void); |
| 152 | void audio_qcelp_exit(void); |
| 153 | void audio_wma_exit(void); |
| 154 | void audio_wmapro_exit(void); |
| 155 | void evrc_in_exit(void); |
| 156 | void g711alaw_in_exit(void); |
| 157 | void g711mlaw_in_exit(void); |
| 158 | void qcelp_in_exit(void); |