1 #ifndef __INTEL_SST_IOCTL_H__
2 #define __INTEL_SST_IOCTL_H__
3 /*
4  *  intel_sst_ioctl.h - Intel SST Driver for audio engine
5  *
6  *  Copyright (C) 2008-10 Intel Corporation
7  *  Authors:	Vinod Koul <vinod.koul@intel.com>
8  *		Harsha Priya <priya.harsha@intel.com>
9  *		Dharageswari R <dharageswari.r@intel.com>
10  *		KP Jeeja <jeeja.kp@intel.com>
11  *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12  *
13  *  This program is free software; you can redistribute it and/or modify
14  *  it under the terms of the GNU General Public License as published by
15  *  the Free Software Foundation; version 2 of the License.
16  *
17  *  This program is distributed in the hope that it will be useful, but
18  *  WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  *  General Public License for more details.
21  *
22  *  You should have received a copy of the GNU General Public License along
23  *  with this program; if not, write to the Free Software Foundation, Inc.,
24  *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25  *
26  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27  *
28  *  This file defines all sst ioctls
29  */
30 
31 /* codec and post/pre processing related info */
32 
33 #include <linux/types.h>
34 
35 enum sst_codec_types {
36 /*  AUDIO/MUSIC	CODEC Type Definitions */
37 	SST_CODEC_TYPE_UNKNOWN = 0,
38 	SST_CODEC_TYPE_PCM,	/* Pass through Audio codec */
39 	SST_CODEC_TYPE_MP3,
40 	SST_CODEC_TYPE_MP24,
41 	SST_CODEC_TYPE_AAC,
42 	SST_CODEC_TYPE_AACP,
43 	SST_CODEC_TYPE_eAACP,
44 	SST_CODEC_TYPE_WMA9,
45 	SST_CODEC_TYPE_WMA10,
46 	SST_CODEC_TYPE_WMA10P,
47 	SST_CODEC_TYPE_RA,
48 	SST_CODEC_TYPE_DDAC3,
49 	SST_CODEC_TYPE_STEREO_TRUE_HD,
50 	SST_CODEC_TYPE_STEREO_HD_PLUS,
51 
52 	/*  VOICE CODEC Type Definitions */
53 	SST_CODEC_TYPE_VOICE_PCM = 0x21, /* Pass through voice codec */
54 };
55 
56 enum sst_algo_types {
57 	SST_CODEC_SRC = 0x64,
58 	SST_CODEC_MIXER = 0x65,
59 	SST_CODEC_DOWN_MIXER = 0x66,
60 	SST_CODEC_VOLUME_CONTROL = 0x67,
61 	SST_CODEC_OEM1 = 0xC8,
62 	SST_CODEC_OEM2 = 0xC9,
63 };
64 
65 enum snd_sst_stream_ops {
66 	STREAM_OPS_PLAYBACK = 0,	/* Decode */
67 	STREAM_OPS_CAPTURE,		/* Encode */
68 	STREAM_OPS_PLAYBACK_DRM,	/* Play Audio/Voice */
69 	STREAM_OPS_PLAYBACK_ALERT,	/* Play Audio/Voice */
70 	STREAM_OPS_CAPTURE_VOICE_CALL,	/* CSV Voice recording */
71 };
72 
73 enum stream_mode {
74 	SST_STREAM_MODE_NONE = 0,
75 	SST_STREAM_MODE_DNR = 1,
76 	SST_STREAM_MODE_FNF = 2,
77 	SST_STREAM_MODE_CAPTURE = 3
78 };
79 
80 enum stream_type {
81 	SST_STREAM_TYPE_NONE = 0,
82 	SST_STREAM_TYPE_MUSIC = 1,
83 	SST_STREAM_TYPE_NORMAL = 2,
84 	SST_STREAM_TYPE_LONG_PB = 3,
85 	SST_STREAM_TYPE_LOW_LATENCY = 4,
86 };
87 
88 enum snd_sst_audio_device_type {
89 	SND_SST_DEVICE_HEADSET = 1,
90 	SND_SST_DEVICE_IHF,
91 	SND_SST_DEVICE_VIBRA,
92 	SND_SST_DEVICE_HAPTIC,
93 	SND_SST_DEVICE_CAPTURE,
94 };
95 
96 /* Firmware Version info */
97 struct snd_sst_fw_version {
98 	__u8 build;	/* build number*/
99 	__u8 minor;	/* minor number*/
100 	__u8 major;	/* major number*/
101 	__u8 type; /* build type */
102 };
103 
104 /* Port info structure */
105 struct snd_sst_port_info {
106 	__u16 port_type;
107 	__u16 reserved;
108 };
109 
110 /* Mixer info structure */
111 struct snd_sst_mix_info {
112 	__u16 max_streams;
113 	__u16 reserved;
114 };
115 
116 /* PCM Parameters */
117 struct snd_pcm_params {
118 	__u16 codec;	/* codec type */
119 	__u8 num_chan;	/* 1=Mono, 2=Stereo */
120 	__u8 pcm_wd_sz;	/* 16/24 - bit*/
121 	__u32 reserved;	/* Bitrate in bits per second */
122 	__u32 sfreq;	/* Sampling rate in Hz */
123 	__u32 ring_buffer_size;
124 	__u32 period_count;	/* period elapsed in samples*/
125 	__u32 ring_buffer_addr;
126 };
127 
128 /* MP3 Music Parameters Message */
129 struct snd_mp3_params {
130 	__u16 codec;
131 	__u8  num_chan;	/* 1=Mono, 2=Stereo	*/
132 	__u8  pcm_wd_sz; /* 16/24 - bit*/
133 	__u32 brate; /* Use the hard coded value. */
134 	__u32 sfreq; /* Sampling freq eg. 8000, 441000, 48000 */
135 	__u8  crc_check; /* crc_check - disable (0) or enable (1) */
136 	__u8  op_align; /* op align 0- 16 bit, 1- MSB, 2 LSB*/
137 	__u16 reserved;	/* Unused */
138 };
139 
140 #define AAC_BIT_STREAM_ADTS		0
141 #define AAC_BIT_STREAM_ADIF		1
142 #define AAC_BIT_STREAM_RAW		2
143 
144 /* AAC Music Parameters Message */
145 struct snd_aac_params {
146 	__u16 codec;
147 	__u8 num_chan; /* 1=Mono, 2=Stereo*/
148 	__u8 pcm_wd_sz; /* 16/24 - bit*/
149 	__u32 brate;
150 	__u32 sfreq; /* Sampling freq eg. 8000, 441000, 48000 */
151 	__u32 aac_srate;	/* Plain AAC decoder operating sample rate */
152 	__u8 mpg_id; /* 0=MPEG-2, 1=MPEG-4 */
153 	__u8 bs_format; /* input bit stream format adts=0, adif=1, raw=2 */
154 	__u8 aac_profile; /* 0=Main Profile, 1=LC profile, 3=SSR profile */
155 	__u8 ext_chl; /* No.of external channels */
156 	__u8 aot; /* Audio object type. 1=Main , 2=LC , 3=SSR, 4=SBR*/
157 	__u8 op_align; /* output alignment 0=16 bit , 1=MSB, 2= LSB align */
158 	__u8 brate_type; /* 0=CBR, 1=VBR */
159 	__u8 crc_check; /* crc check 0= disable, 1=enable */
160 	__s8 bit_stream_format[8]; /* input bit stream format adts/adif/raw */
161 	__u8 jstereo; /* Joint stereo Flag */
162 	__u8 sbr_present; /* 1 = SBR Present, 0 = SBR absent, for RAW */
163 	__u8 downsample;       /* 1 = Downsampling ON, 0 = Downsampling OFF */
164 	__u8 num_syntc_elems; /* 1- Mono/stereo, 0 - Dual Mono, 0 - for raw */
165 	__s8 syntc_id[2]; /* 0 for ID_SCE(Dula Mono), -1 for raw */
166 	__s8 syntc_tag[2]; /* raw - -1 and 0 -16 for rest of the streams */
167 	__u8 pce_present; /* Flag. 1- present 0 - not present, for RAW */
168 	__u8 sbr_type;		/* sbr_type: 0-plain aac, 1-aac-v1, 2-aac-v2 */
169 	__u8 outchmode;  /*0- mono, 1-stereo, 2-dual mono 3-Parametric stereo */
170 	__u8 ps_present;
171 };
172 
173 /* WMA Music Parameters Message */
174 struct snd_wma_params {
175 	__u16 codec;
176 	__u8  num_chan;	/* 1=Mono, 2=Stereo */
177 	__u8  pcm_wd_sz;	/* 16/24 - bit*/
178 	__u32 brate;	/* Use the hard coded value. */
179 	__u32 sfreq;	/* Sampling freq eg. 8000, 441000, 48000 */
180 	__u32 channel_mask;  /* Channel Mask */
181 	__u16 format_tag;	/* Format Tag */
182 	__u16 block_align;	/* packet size */
183 	__u16 wma_encode_opt;/* Encoder option */
184 	__u8 op_align;	/* op align 0- 16 bit, 1- MSB, 2 LSB */
185 	__u8 pcm_src;	/* input pcm bit width */
186 };
187 
188 /* Pre processing param structure */
189 struct snd_prp_params {
190 	__u32 reserved;	/* No pre-processing defined yet */
191 };
192 
193 /* Pre and post processing params structure */
194 struct snd_ppp_params {
195 	__u8			algo_id;/* Post/Pre processing algorithm ID  */
196 	__u8			str_id;	/*Only 5 bits used 0 - 31 are valid*/
197 	__u8			enable;	/* 0= disable, 1= enable*/
198 	__u8			reserved;
199 	__u32			size;	/*Size of parameters for all blocks*/
200 	void			*params;
201 } __attribute__ ((packed));
202 
203 struct snd_sst_postproc_info {
204 	__u32 src_min;		/* Supported SRC Min sampling freq */
205 	__u32 src_max;		/* Supported SRC Max sampling freq */
206 	__u8  src;		/* 0=Not supported, 1=Supported */
207 	__u8  bass_boost;		/* 0=Not Supported, 1=Supported */
208 	__u8  stereo_widening;	/* 0=Not Supported, 1=Supported */
209 	__u8  volume_control;	/* 0=Not Supported, 1=Supported */
210 	__s16 min_vol;		/* Minimum value of Volume in dB */
211 	__s16 max_vol;		/* Maximum value of Volume in dB */
212 	__u8 mute_control;	/* 0=No Mute, 1=Mute */
213 	__u8 reserved1;
214 	__u16 reserved2;
215 };
216 
217 /* pre processing Capability info structure */
218 struct snd_sst_prp_info {
219 	__s16 min_vol;			/* Minimum value of Volume in dB */
220 	__s16 max_vol;			/* Maximum value of Volume in dB */
221 	__u8 volume_control;		/* 0=Not Supported, 1=Supported */
222 	__u8 reserved1;			/* for 32 bit alignment */
223 	__u16 reserved2;		/* for 32 bit alignment */
224 } __attribute__ ((packed));
225 
226 /*Pre / Post processing algorithms support*/
227 struct snd_sst_ppp_info {
228 	__u32 src:1;		/* 0=Not supported, 1=Supported */
229 	__u32 mixer:1;		/* 0=Not supported, 1=Supported */
230 	__u32 volume_control:1;	/* 0=Not Supported, 1=Supported */
231 	__u32 mute_control:1;	/* 0=Not Supported, 1=Supported */
232 	__u32 anc:1;		/* 0=Not Supported, 1=Supported */
233 	__u32 side_tone:1;	/* 0=Not Supported, 1=Supported */
234 	__u32 dc_removal:1;	/* 0=Not Supported, 1=Supported */
235 	__u32 equalizer:1;	/* 0=Not Supported, 1=Supported */
236 	__u32 spkr_prot:1;	/* 0=Not Supported, 1=Supported */
237 	__u32 bass_boost:1;	/* 0=Not Supported, 1=Supported */
238 	__u32 stereo_widening:1;/* 0=Not Supported, 1=Supported */
239 	__u32 rsvd1:21;
240 	__u32 rsvd2;
241 };
242 
243 /* Firmware capabilities info */
244 struct snd_sst_fw_info {
245 	struct snd_sst_fw_version fw_version; /* Firmware version */
246 	__u8 audio_codecs_supported[8];	/* Codecs supported by FW */
247 	__u32 recommend_min_duration; /* Min duration for Lowpower Playback */
248 	__u8 max_pcm_streams_supported; /* Max num of PCM streams supported */
249 	__u8 max_enc_streams_supported;	/* Max number of Encoded streams  */
250 	__u16 reserved;		/* 32 bit alignment*/
251 	struct snd_sst_ppp_info ppp_info; /* pre_processing mod cap info */
252 	struct snd_sst_postproc_info pop_info; /* Post processing cap info*/
253 	struct snd_sst_port_info port_info[3]; /* Port info */
254 	struct snd_sst_mix_info mix_info;/* Mixer info */
255 	__u32 min_input_buf; /* minmum i/p buffer for decode */
256 };
257 
258 /* Codec params struture */
259 union  snd_sst_codec_params {
260 	struct snd_pcm_params pcm_params;
261 	struct snd_mp3_params mp3_params;
262 	struct snd_aac_params aac_params;
263 	struct snd_wma_params wma_params;
264 };
265 
266 
267 struct snd_sst_stream_params {
268 	union snd_sst_codec_params uc;
269 } __attribute__ ((packed));
270 
271 struct snd_sst_params {
272 	__u32 result;
273 	__u32 stream_id;
274 	__u8 codec;
275 	__u8 ops;
276 	__u8 stream_type;
277 	__u8 device_type;
278 	struct snd_sst_stream_params sparams;
279 };
280 
281 struct snd_sst_vol {
282 	__u32	stream_id;
283 	__s32	volume;
284 	__u32	ramp_duration;
285 	__u32	ramp_type;		/* Ramp type, default=0 */
286 };
287 
288 struct snd_sst_mute {
289 	__u32	stream_id;
290 	__u32	mute;
291 };
292 
293 /* ioctl related stuff here */
294 struct snd_sst_pmic_config {
295 	__u32  sfreq;                /* Sampling rate in Hz */
296 	__u16  num_chan;             /* Mono =1 or Stereo =2 */
297 	__u16  pcm_wd_sz;            /* Number of bits per sample */
298 } __attribute__ ((packed));
299 
300 struct snd_sst_get_stream_params {
301 	struct snd_sst_params codec_params;
302 	struct snd_sst_pmic_config pcm_params;
303 };
304 
305 enum snd_sst_target_type {
306 	SND_SST_TARGET_PMIC = 1,
307 	SND_SST_TARGET_LPE,
308 	SND_SST_TARGET_MODEM,
309 	SND_SST_TARGET_BT,
310 	SND_SST_TARGET_FM,
311 	SND_SST_TARGET_NONE,
312 };
313 
314 enum snd_sst_device_type {
315 	SND_SST_DEVICE_SSP = 1,
316 	SND_SST_DEVICE_PCM,
317 	SND_SST_DEVICE_OTHER,
318 };
319 
320 enum snd_sst_device_mode {
321 
322 	SND_SST_DEV_MODE_PCM_MODE1 = 1, /*(16-bit word, bit-length frame sync)*/
323 	SND_SST_DEV_MODE_PCM_MODE2,
324 	SND_SST_DEV_MODE_PCM_MODE3,
325 	SND_SST_DEV_MODE_PCM_MODE4_RIGHT_JUSTIFIED,
326 	SND_SST_DEV_MODE_PCM_MODE4_LEFT_JUSTIFIED,
327 	SND_SST_DEV_MODE_PCM_MODE4_I2S, /*(I2S mode, 16-bit words)*/
328 	SND_SST_DEV_MODE_PCM_MODE5,
329 	SND_SST_DEV_MODE_PCM_MODE6,
330 };
331 
332 enum snd_sst_port_action {
333 	SND_SST_PORT_PREPARE = 1,
334 	SND_SST_PORT_ACTIVATE,
335 };
336 
337 /* Target selection per device structure */
338 struct snd_sst_slot_info {
339 	__u8 mix_enable;	/* Mixer enable or disable */
340 	__u8 device_type;
341 	__u8 device_instance;	/* 0, 1, 2 */
342 	__u8 target_device;
343 	__u16 target_sink;
344 	__u8 slot[2];
345 	__u8 master;
346 	__u8 action;
347 	__u8 device_mode;
348 	__u8 reserved;
349 	struct snd_sst_pmic_config pcm_params;
350 } __attribute__ ((packed));
351 
352 #define SST_MAX_TARGET_DEVICES 3
353 /* Target device list structure */
354 struct snd_sst_target_device  {
355 	__u32 device_route;
356 	struct snd_sst_slot_info devices[SST_MAX_TARGET_DEVICES];
357 } __attribute__ ((packed));
358 
359 struct snd_sst_driver_info {
360 	__u32 version;	/* Version of the driver */
361 	__u32 active_pcm_streams;
362 	__u32 active_enc_streams;
363 	__u32 max_pcm_streams;
364 	__u32 max_enc_streams;
365 	__u32 buf_per_stream;
366 };
367 
368 enum snd_sst_buff_type {
369 	SST_BUF_USER = 1,
370 	SST_BUF_MMAP,
371 	SST_BUF_RAR,
372 };
373 
374 struct snd_sst_mmap_buff_entry {
375 	unsigned int offset;
376 	unsigned int size;
377 };
378 
379 struct snd_sst_mmap_buffs {
380 	unsigned int entries;
381 	enum snd_sst_buff_type type;
382 	struct snd_sst_mmap_buff_entry *buff;
383 };
384 
385 struct snd_sst_buff_entry {
386 	void *buffer;
387 	unsigned int size;
388 };
389 
390 struct snd_sst_buffs {
391 	unsigned int entries;
392 	__u8 type;
393 	struct snd_sst_buff_entry *buff_entry;
394 };
395 
396 struct snd_sst_dbufs  {
397 	unsigned long long input_bytes_consumed;
398 	unsigned long long output_bytes_produced;
399 	struct snd_sst_buffs *ibufs;
400 	struct snd_sst_buffs *obufs;
401 };
402 
403 /*IOCTL defined here */
404 /*SST MMF IOCTLS only */
405 #define SNDRV_SST_STREAM_SET_PARAMS _IOR('L', 0x00, \
406 					struct snd_sst_stream_params *)
407 #define SNDRV_SST_STREAM_GET_PARAMS _IOWR('L', 0x01, \
408 					struct snd_sst_get_stream_params *)
409 #define SNDRV_SST_STREAM_GET_TSTAMP _IOWR('L', 0x02, __u64 *)
410 #define	SNDRV_SST_STREAM_DECODE	_IOWR('L', 0x03, struct snd_sst_dbufs *)
411 #define SNDRV_SST_STREAM_BYTES_DECODED _IOWR('L', 0x04, __u64 *)
412 #define SNDRV_SST_STREAM_START	_IO('A', 0x42)
413 #define SNDRV_SST_STREAM_DROP	_IO('A', 0x43)
414 #define SNDRV_SST_STREAM_DRAIN	_IO('A', 0x44)
415 #define SNDRV_SST_STREAM_PAUSE	_IOW('A', 0x45, int)
416 #define SNDRV_SST_STREAM_RESUME _IO('A', 0x47)
417 #define SNDRV_SST_MMAP_PLAY	_IOW('L', 0x05, struct snd_sst_mmap_buffs *)
418 #define SNDRV_SST_MMAP_CAPTURE _IOW('L', 0x06, struct snd_sst_mmap_buffs *)
419 /*SST common ioctls */
420 #define SNDRV_SST_DRIVER_INFO	_IOR('L', 0x10, struct snd_sst_driver_info *)
421 #define SNDRV_SST_SET_VOL	_IOW('L', 0x11, struct snd_sst_vol *)
422 #define SNDRV_SST_GET_VOL	_IOW('L', 0x12, struct snd_sst_vol *)
423 #define SNDRV_SST_MUTE		_IOW('L', 0x13, struct snd_sst_mute *)
424 /*AM Ioctly only */
425 #define SNDRV_SST_FW_INFO	_IOR('L', 0x20,  struct snd_sst_fw_info *)
426 #define SNDRV_SST_SET_TARGET_DEVICE _IOW('L', 0x21, \
427 					struct snd_sst_target_device *)
428 /*DSP Ioctls on /dev/intel_sst_ctrl only*/
429 #define SNDRV_SST_SET_ALGO	_IOW('L', 0x30,  struct snd_ppp_params *)
430 #define SNDRV_SST_GET_ALGO	_IOWR('L', 0x31,  struct snd_ppp_params *)
431 
432 #endif /* __INTEL_SST_IOCTL_H__ */
433