blob: 3ad6903b336513c194bdbe7cf7d136919f94702b [file] [log] [blame]
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05301/* 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
31struct timestamp {
32 u32 lowpart;
33 u32 highpart;
34} __packed;
35
36struct meta_in {
37 unsigned short offset;
38 struct timestamp ntimestamp;
39 unsigned int nflags;
40} __packed;
41
42struct 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
51struct meta_out {
52 unsigned char num_of_frames;
53 struct meta_out_dsp meta_out_dsp[];
54} __packed;
55
56struct 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
98int audio_in_enable(struct q6audio_in *audio);
99int audio_in_disable(struct q6audio_in *audio);
100int audio_in_buf_alloc(struct q6audio_in *audio);
101long audio_in_ioctl(struct file *file,
102 unsigned int cmd, unsigned long arg);
103#ifdef CONFIG_COMPAT
104long 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
109ssize_t audio_in_read(struct file *file, char __user *buf,
110 size_t count, loff_t *pos);
111ssize_t audio_in_write(struct file *file, const char __user *buf,
112 size_t count, loff_t *pos);
113int audio_in_release(struct inode *inode, struct file *file);
114int audio_in_set_config(struct file *file, struct msm_audio_config *cfg);
Laxminath Kasam8b1366a2017-10-05 01:44:16 +0530115int aac_in_init(void);
116int amrnb_in_init(void);
117int amrwb_in_init(void);
118int audio_aac_init(void);
119int audio_alac_init(void);
120int audio_amrnb_init(void);
121int audio_amrwb_init(void);
122int audio_amrwbplus_init(void);
123int audio_ape_init(void);
124int audio_evrc_init(void);
125int audio_g711alaw_init(void);
126int audio_g711mlaw_init(void);
127int audio_effects_init(void);
128int audio_mp3_init(void);
129int audio_multiaac_init(void);
130int audio_qcelp_init(void);
131int audio_wma_init(void);
132int audio_wmapro_init(void);
133int evrc_in_init(void);
134int g711alaw_in_init(void);
135int g711mlaw_in_init(void);
136int qcelp_in_init(void);
137void aac_in_exit(void);
138void amrnb_in_exit(void);
139void amrwb_in_exit(void);
140void audio_aac_exit(void);
141void audio_alac_exit(void);
142void audio_amrnb_exit(void);
143void audio_amrwb_exit(void);
144void audio_amrwbplus_exit(void);
145void audio_ape_exit(void);
146void audio_evrc_exit(void);
147void audio_g711alaw_exit(void);
148void audio_g711mlaw_exit(void);
149void audio_effects_exit(void);
150void audio_mp3_exit(void);
151void audio_multiaac_exit(void);
152void audio_qcelp_exit(void);
153void audio_wma_exit(void);
154void audio_wmapro_exit(void);
155void evrc_in_exit(void);
156void g711alaw_in_exit(void);
157void g711mlaw_in_exit(void);
158void qcelp_in_exit(void);