ctsrc.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
  3. *
  4. * This source file is released under GPL v2 license (no other versions).
  5. * See the COPYING file included in the main directory of this source
  6. * distribution for the license terms and conditions.
  7. *
  8. * @File ctsrc.h
  9. *
  10. * @Brief
  11. * This file contains the definition of the Sample Rate Convertor
  12. * resource management object.
  13. *
  14. * @Author Liu Chun
  15. * @Date May 13 2008
  16. *
  17. */
  18. #ifndef CTSRC_H
  19. #define CTSRC_H
  20. #include "ctresource.h"
  21. #include "ctimap.h"
  22. #include <linux/spinlock.h>
  23. #include <linux/list.h>
  24. #include <sound/core.h>
  25. #define SRC_STATE_OFF 0x0
  26. #define SRC_STATE_INIT 0x4
  27. #define SRC_STATE_RUN 0x5
  28. #define SRC_SF_U8 0x0
  29. #define SRC_SF_S16 0x1
  30. #define SRC_SF_S24 0x2
  31. #define SRC_SF_S32 0x3
  32. #define SRC_SF_F32 0x4
  33. /* Define the descriptor of a src resource */
  34. enum SRCMODE {
  35. MEMRD, /* Read data from host memory */
  36. MEMWR, /* Write data to host memory */
  37. ARCRW, /* Read from and write to audio ring channel */
  38. NUM_SRCMODES
  39. };
  40. struct src_rsc_ops;
  41. struct src {
  42. struct rsc rsc; /* Basic resource info */
  43. struct src *intlv; /* Pointer to next interleaved SRC in a series */
  44. const struct src_rsc_ops *ops; /* SRC specific operations */
  45. /* Number of contiguous srcs for interleaved usage */
  46. unsigned char multi;
  47. unsigned char mode; /* Working mode of this SRC resource */
  48. };
  49. struct src_rsc_ops {
  50. int (*set_state)(struct src *src, unsigned int state);
  51. int (*set_bm)(struct src *src, unsigned int bm);
  52. int (*set_sf)(struct src *src, unsigned int sf);
  53. int (*set_pm)(struct src *src, unsigned int pm);
  54. int (*set_rom)(struct src *src, unsigned int rom);
  55. int (*set_vo)(struct src *src, unsigned int vo);
  56. int (*set_st)(struct src *src, unsigned int st);
  57. int (*set_bp)(struct src *src, unsigned int bp);
  58. int (*set_cisz)(struct src *src, unsigned int cisz);
  59. int (*set_ca)(struct src *src, unsigned int ca);
  60. int (*set_sa)(struct src *src, unsigned int sa);
  61. int (*set_la)(struct src *src, unsigned int la);
  62. int (*set_pitch)(struct src *src, unsigned int pitch);
  63. int (*set_clr_zbufs)(struct src *src);
  64. int (*commit_write)(struct src *src);
  65. int (*get_ca)(struct src *src);
  66. int (*init)(struct src *src);
  67. struct src* (*next_interleave)(struct src *src);
  68. };
  69. /* Define src resource request description info */
  70. struct src_desc {
  71. /* Number of contiguous master srcs for interleaved usage */
  72. unsigned char multi;
  73. unsigned char msr;
  74. unsigned char mode; /* Working mode of the requested srcs */
  75. };
  76. /* Define src manager object */
  77. struct src_mgr {
  78. struct rsc_mgr mgr; /* Basic resource manager info */
  79. struct snd_card *card; /* pointer to this card */
  80. spinlock_t mgr_lock;
  81. /* request src resource */
  82. int (*get_src)(struct src_mgr *mgr,
  83. const struct src_desc *desc, struct src **rsrc);
  84. /* return src resource */
  85. int (*put_src)(struct src_mgr *mgr, struct src *src);
  86. int (*src_enable_s)(struct src_mgr *mgr, struct src *src);
  87. int (*src_enable)(struct src_mgr *mgr, struct src *src);
  88. int (*src_disable)(struct src_mgr *mgr, struct src *src);
  89. int (*commit_write)(struct src_mgr *mgr);
  90. };
  91. /* Define the descriptor of a SRC Input Mapper resource */
  92. struct srcimp_mgr;
  93. struct srcimp_rsc_ops;
  94. struct srcimp {
  95. struct rsc rsc;
  96. unsigned char idx[8];
  97. struct imapper *imappers;
  98. unsigned int mapped; /* A bit-map indicating which conj rsc is mapped */
  99. struct srcimp_mgr *mgr;
  100. const struct srcimp_rsc_ops *ops;
  101. };
  102. struct srcimp_rsc_ops {
  103. int (*map)(struct srcimp *srcimp, struct src *user, struct rsc *input);
  104. int (*unmap)(struct srcimp *srcimp);
  105. };
  106. /* Define SRCIMP resource request description info */
  107. struct srcimp_desc {
  108. unsigned int msr;
  109. };
  110. struct srcimp_mgr {
  111. struct rsc_mgr mgr; /* Basic resource manager info */
  112. struct snd_card *card; /* pointer to this card */
  113. spinlock_t mgr_lock;
  114. spinlock_t imap_lock;
  115. struct list_head imappers;
  116. struct imapper *init_imap;
  117. unsigned int init_imap_added;
  118. /* request srcimp resource */
  119. int (*get_srcimp)(struct srcimp_mgr *mgr,
  120. const struct srcimp_desc *desc,
  121. struct srcimp **rsrcimp);
  122. /* return srcimp resource */
  123. int (*put_srcimp)(struct srcimp_mgr *mgr, struct srcimp *srcimp);
  124. int (*imap_add)(struct srcimp_mgr *mgr, struct imapper *entry);
  125. int (*imap_delete)(struct srcimp_mgr *mgr, struct imapper *entry);
  126. };
  127. /* Constructor and destructor of SRC resource manager */
  128. int src_mgr_create(struct hw *hw, struct src_mgr **rsrc_mgr);
  129. int src_mgr_destroy(struct src_mgr *src_mgr);
  130. /* Constructor and destructor of SRCIMP resource manager */
  131. int srcimp_mgr_create(struct hw *hw, struct srcimp_mgr **rsrc_mgr);
  132. int srcimp_mgr_destroy(struct srcimp_mgr *srcimp_mgr);
  133. #endif /* CTSRC_H */