ctresource.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 ctresource.h
  9. *
  10. * @Brief
  11. * This file contains the definition of generic hardware resources for
  12. * resource management.
  13. *
  14. * @Author Liu Chun
  15. * @Date May 13 2008
  16. *
  17. */
  18. #ifndef CTRESOURCE_H
  19. #define CTRESOURCE_H
  20. #include <linux/types.h>
  21. enum RSCTYP {
  22. SRC,
  23. SRCIMP,
  24. AMIXER,
  25. SUM,
  26. DAIO,
  27. NUM_RSCTYP /* This must be the last one and less than 16 */
  28. };
  29. struct rsc_ops;
  30. struct rsc {
  31. u32 idx:12; /* The index of a resource */
  32. u32 type:4; /* The type (RSCTYP) of a resource */
  33. u32 conj:12; /* Current conjugate index */
  34. u32 msr:4; /* The Master Sample Rate a resource working on */
  35. void *ctrl_blk; /* Chip specific control info block for a resource */
  36. struct hw *hw; /* Chip specific object for hardware access means */
  37. const struct rsc_ops *ops; /* Generic resource operations */
  38. };
  39. struct rsc_ops {
  40. int (*master)(struct rsc *rsc); /* Move to master resource */
  41. int (*next_conj)(struct rsc *rsc); /* Move to next conjugate resource */
  42. int (*index)(const struct rsc *rsc); /* Return the index of resource */
  43. /* Return the output slot number */
  44. int (*output_slot)(const struct rsc *rsc);
  45. };
  46. int
  47. rsc_init(struct rsc *rsc, u32 idx, enum RSCTYP type, u32 msr, struct hw *hw);
  48. int rsc_uninit(struct rsc *rsc);
  49. struct rsc_mgr {
  50. enum RSCTYP type; /* The type (RSCTYP) of resource to manage */
  51. unsigned int amount; /* The total amount of a kind of resource */
  52. unsigned int avail; /* The amount of currently available resources */
  53. unsigned char *rscs; /* The bit-map for resource allocation */
  54. void *ctrl_blk; /* Chip specific control info block */
  55. struct hw *hw; /* Chip specific object for hardware access */
  56. };
  57. /* Resource management is based on bit-map mechanism */
  58. int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type,
  59. unsigned int amount, struct hw *hw);
  60. int rsc_mgr_uninit(struct rsc_mgr *mgr);
  61. int mgr_get_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int *ridx);
  62. int mgr_put_resource(struct rsc_mgr *mgr, unsigned int n, unsigned int idx);
  63. #endif /* CTRESOURCE_H */