PageRenderTime 72ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/staging/intel_sst/intel_sst_ioctl.h

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