Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Google, Inc. |
| 3 | * Copyright (C) 2008 HTC Corporation |
Ajit Pandey | 3d7b9a2 | 2019-09-05 16:26:01 +0530 | [diff] [blame] | 4 | * Copyright (c) 2012-2017, 2019 The Linux Foundation. All rights reserved. |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 5 | * |
| 6 | * This software is licensed under the terms of the GNU General Public |
| 7 | * License version 2, as published by the Free Software Foundation, and |
| 8 | * may be copied, distributed, and modified under those terms. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 | * |
| 14 | * See the GNU General Public License for more details. |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, you can find it at http://www.fsf.org. |
| 17 | */ |
| 18 | |
| 19 | #ifndef _MSM_PCM_H |
| 20 | #define _MSM_PCM_H |
Laxminath Kasam | 605b42f | 2017-08-01 22:02:15 +0530 | [diff] [blame] | 21 | #include <dsp/apr_audio-v2.h> |
| 22 | #include <dsp/q6asm-v2.h> |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 23 | |
| 24 | |
| 25 | |
| 26 | /* Support unconventional sample rates 12000, 24000 as well */ |
| 27 | #define USE_RATE \ |
| 28 | (SNDRV_PCM_RATE_8000_48000 | SNDRV_PCM_RATE_KNOT) |
| 29 | |
| 30 | extern int copy_count; |
| 31 | |
| 32 | struct buffer { |
| 33 | void *data; |
| 34 | unsigned int size; |
| 35 | unsigned int used; |
| 36 | unsigned int addr; |
| 37 | }; |
| 38 | |
| 39 | struct buffer_rec { |
| 40 | void *data; |
| 41 | unsigned int size; |
| 42 | unsigned int read; |
| 43 | unsigned int addr; |
| 44 | }; |
| 45 | |
| 46 | struct audio_locks { |
| 47 | spinlock_t event_lock; |
| 48 | wait_queue_head_t read_wait; |
| 49 | wait_queue_head_t write_wait; |
| 50 | wait_queue_head_t eos_wait; |
| 51 | wait_queue_head_t enable_wait; |
| 52 | wait_queue_head_t flush_wait; |
| 53 | }; |
| 54 | |
| 55 | struct msm_audio_in_frame_info { |
| 56 | uint32_t size; |
| 57 | uint32_t offset; |
| 58 | }; |
| 59 | |
| 60 | #define PLAYBACK_MIN_NUM_PERIODS 2 |
| 61 | #define PLAYBACK_MAX_NUM_PERIODS 8 |
| 62 | #define PLAYBACK_MAX_PERIOD_SIZE 122880 |
| 63 | #define PLAYBACK_MIN_PERIOD_SIZE 128 |
| 64 | #define CAPTURE_MIN_NUM_PERIODS 2 |
| 65 | #define CAPTURE_MAX_NUM_PERIODS 8 |
| 66 | #define CAPTURE_MAX_PERIOD_SIZE 122880 |
| 67 | #define CAPTURE_MIN_PERIOD_SIZE 320 |
| 68 | |
| 69 | struct msm_audio { |
| 70 | struct snd_pcm_substream *substream; |
| 71 | unsigned int pcm_size; |
| 72 | unsigned int pcm_count; |
| 73 | unsigned int pcm_irq_pos; /* IRQ position */ |
| 74 | uint16_t source; /* Encoding source bit mask */ |
| 75 | |
| 76 | struct audio_client *audio_client; |
| 77 | |
| 78 | uint16_t session_id; |
| 79 | |
| 80 | uint32_t samp_rate; |
| 81 | uint32_t channel_mode; |
| 82 | uint32_t dsp_cnt; |
| 83 | |
| 84 | int abort; /* set when error, like sample rate mismatch */ |
| 85 | |
| 86 | bool reset_event; |
| 87 | int enabled; |
| 88 | int close_ack; |
| 89 | int cmd_ack; |
| 90 | /* |
| 91 | * cmd_ack doesn't tell if paticular command has been sent so can't |
| 92 | * determine if it needs to wait for completion. |
| 93 | * Use cmd_pending instead when checking whether a command is been |
| 94 | * sent or not. |
| 95 | */ |
| 96 | unsigned long cmd_pending; |
| 97 | atomic_t start; |
| 98 | atomic_t stop; |
| 99 | atomic_t out_count; |
| 100 | atomic_t in_count; |
| 101 | atomic_t out_needed; |
| 102 | atomic_t eos; |
| 103 | int out_head; |
| 104 | int periods; |
| 105 | int mmap_flag; |
| 106 | atomic_t pending_buffer; |
| 107 | bool set_channel_map; |
| 108 | char channel_map[8]; |
| 109 | int cmd_interrupt; |
| 110 | bool meta_data_mode; |
| 111 | uint32_t volume; |
| 112 | bool compress_enable; |
| 113 | /* array of frame info */ |
| 114 | struct msm_audio_in_frame_info in_frame_info[CAPTURE_MAX_NUM_PERIODS]; |
| 115 | }; |
| 116 | |
| 117 | struct output_meta_data_st { |
| 118 | uint32_t meta_data_length; |
| 119 | uint32_t frame_size; |
| 120 | uint32_t timestamp_lsw; |
| 121 | uint32_t timestamp_msw; |
| 122 | uint32_t reserved[12]; |
| 123 | }; |
| 124 | |
| 125 | struct msm_plat_data { |
| 126 | int perf_mode; |
| 127 | struct snd_pcm *pcm; |
Ajit Pandey | 3d7b9a2 | 2019-09-05 16:26:01 +0530 | [diff] [blame] | 128 | struct mutex lock; |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | #endif /*_MSM_PCM_H*/ |