ctresource.h 2.1 KB

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