audio_utils.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #define FRAME_NUM (8)
  17. #define PCM_BUF_COUNT (2)
  18. #define AUD_EOS_SET 0x01
  19. #define TUNNEL_MODE 0x0000
  20. #define NON_TUNNEL_MODE 0x0001
  21. #define NO_BUF_ALLOC 0x00
  22. #define BUF_ALLOC_IN 0x01
  23. #define BUF_ALLOC_OUT 0x02
  24. #define BUF_ALLOC_INOUT 0x03
  25. #define ALIGN_BUF_SIZE(size) ((size + 4095) & (~4095))
  26. struct timestamp {
  27. u32 lowpart;
  28. u32 highpart;
  29. } __packed;
  30. struct meta_in {
  31. unsigned short offset;
  32. struct timestamp ntimestamp;
  33. unsigned int nflags;
  34. } __packed;
  35. struct meta_out_dsp {
  36. u32 offset_to_frame;
  37. u32 frame_size;
  38. u32 encoded_pcm_samples;
  39. u32 msw_ts;
  40. u32 lsw_ts;
  41. u32 nflags;
  42. } __packed;
  43. struct meta_out {
  44. unsigned char num_of_frames;
  45. struct meta_out_dsp meta_out_dsp[];
  46. } __packed;
  47. struct q6audio_in {
  48. spinlock_t dsp_lock;
  49. atomic_t in_bytes;
  50. atomic_t in_samples;
  51. struct mutex lock;
  52. struct mutex read_lock;
  53. struct mutex write_lock;
  54. wait_queue_head_t read_wait;
  55. wait_queue_head_t write_wait;
  56. struct audio_client *ac;
  57. struct msm_audio_stream_config str_cfg;
  58. void *enc_cfg;
  59. struct msm_audio_buf_cfg buf_cfg;
  60. struct msm_audio_config pcm_cfg;
  61. void *codec_cfg;
  62. /* number of buffers available to read/write */
  63. atomic_t in_count;
  64. atomic_t out_count;
  65. /* first idx: num of frames per buf, second idx: offset to frame */
  66. uint32_t out_frame_info[FRAME_NUM][2];
  67. int eos_rsp;
  68. int opened;
  69. int enabled;
  70. int stopped;
  71. int event_abort;
  72. int feedback; /* Flag indicates whether used
  73. * in Non Tunnel mode
  74. */
  75. int rflush;
  76. int wflush;
  77. int buf_alloc;
  78. uint16_t min_frame_size;
  79. uint16_t max_frames_per_buf;
  80. bool reset_event;
  81. long (*enc_ioctl)(struct file *, unsigned int, unsigned long);
  82. long (*enc_compat_ioctl)(struct file *, unsigned int, unsigned long);
  83. };
  84. int audio_in_enable(struct q6audio_in *audio);
  85. int audio_in_disable(struct q6audio_in *audio);
  86. int audio_in_buf_alloc(struct q6audio_in *audio);
  87. long audio_in_ioctl(struct file *file,
  88. unsigned int cmd, unsigned long arg);
  89. #ifdef CONFIG_COMPAT
  90. long audio_in_compat_ioctl(struct file *file,
  91. unsigned int cmd, unsigned long arg);
  92. #else
  93. #define audio_in_compat_ioctl NULL
  94. #endif
  95. ssize_t audio_in_read(struct file *file, char __user *buf,
  96. size_t count, loff_t *pos);
  97. ssize_t audio_in_write(struct file *file, const char __user *buf,
  98. size_t count, loff_t *pos);
  99. int audio_in_release(struct inode *inode, struct file *file);
  100. int audio_in_set_config(struct file *file, struct msm_audio_config *cfg);