cs4344.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /****************************************************************************
  2. * include/nuttx/audio/cs4344.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_NUTTX_AUDIO_CS4344_H
  21. #define __INCLUDE_NUTTX_AUDIO_CS4344_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <stdint.h>
  26. #include <stdbool.h>
  27. #include <nuttx/irq.h>
  28. #ifdef CONFIG_AUDIO_CS4344
  29. /****************************************************************************
  30. * Pre-processor Definitions
  31. ****************************************************************************/
  32. /* Configuration ************************************************************
  33. *
  34. * CONFIG_AUDIO_CS4344 - Enables CS4344 support
  35. * CONFIG_CS4344_INFLIGHT - Maximum number of buffers that the CS4344
  36. * driver will send to the I2S driver before any have completed.
  37. * CONFIG_CS4344_MSG_PRIO - Priority of messages sent to the CS4344
  38. * worker thread.
  39. * CONFIG_CS4344_BUFFER_SIZE - Preferred buffer size
  40. * CONFIG_CS4344_NUM_BUFFERS - Preferred number of buffers
  41. * CONFIG_CS4344_WORKER_STACKSIZE - Stack size to use when creating the the
  42. * CS4344 worker thread.
  43. * CONFIG_CS4344_REGDUMP - Enable logic to dump all CS4344 registers to
  44. * the SYSLOG device.
  45. */
  46. /* Pre-requisites */
  47. #ifndef CONFIG_AUDIO
  48. # error CONFIG_AUDIO is required for audio subsystem support
  49. #endif
  50. #ifndef CONFIG_I2S
  51. # error CONFIG_I2S is required by the CS4344 driver
  52. #endif
  53. #ifndef CONFIG_SCHED_WORKQUEUE
  54. # error CONFIG_SCHED_WORKQUEUE is required by the CS4344 driver
  55. #endif
  56. /* Default configuration values */
  57. #ifndef CONFIG_CS4344_INFLIGHT
  58. # define CONFIG_CS4344_INFLIGHT 2
  59. #endif
  60. #if CONFIG_CS4344_INFLIGHT > 255
  61. # error CONFIG_CS4344_INFLIGHT must fit in a uint8_t
  62. #endif
  63. #ifndef CONFIG_CS4344_MSG_PRIO
  64. # define CONFIG_CS4344_MSG_PRIO 1
  65. #endif
  66. #ifndef CONFIG_CS4344_BUFFER_SIZE
  67. # define CONFIG_CS4344_BUFFER_SIZE 8192
  68. #endif
  69. #ifndef CONFIG_CS4344_NUM_BUFFERS
  70. # define CONFIG_CS4344_NUM_BUFFERS 4
  71. #endif
  72. #ifndef CONFIG_CS4344_WORKER_STACKSIZE
  73. # define CONFIG_CS4344_WORKER_STACKSIZE 768
  74. #endif
  75. /****************************************************************************
  76. * Public Types
  77. ****************************************************************************/
  78. /****************************************************************************
  79. * Public Data
  80. ****************************************************************************/
  81. #ifdef __cplusplus
  82. #define EXTERN extern "C"
  83. extern "C"
  84. {
  85. #else
  86. #define EXTERN extern
  87. #endif
  88. /****************************************************************************
  89. * Public Function Prototypes
  90. ****************************************************************************/
  91. /****************************************************************************
  92. * Name: cs4344_initialize
  93. *
  94. * Description:
  95. * Initialize the CS4344 device.
  96. *
  97. * Input Parameters:
  98. * i2s - An I2S driver instance
  99. * lower - Persistent board configuration data
  100. *
  101. * Returned Value:
  102. * A new lower half audio interface for the CS4344 device is returned on
  103. * success; NULL is returned on failure.
  104. *
  105. ****************************************************************************/
  106. struct i2s_dev_s; /* Forward reference. Defined in include/nuttx/audio/i2s.h */
  107. struct audio_lowerhalf_s; /* Forward reference. Defined in nuttx/audio/audio.h */
  108. FAR struct audio_lowerhalf_s * cs4344_initialize(FAR struct i2s_dev_s *i2s);
  109. #undef EXTERN
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif /* CONFIG_AUDIO_CS4344 */
  114. #endif /* __INCLUDE_NUTTX_AUDIO_CS4344_H */