aoa.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Apple Onboard Audio definitions
  3. *
  4. * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
  5. *
  6. * GPL v2, can be found in COPYING.
  7. */
  8. #ifndef __AOA_H
  9. #define __AOA_H
  10. #include <asm/prom.h>
  11. #include <linux/module.h>
  12. #include <sound/core.h>
  13. #include <sound/asound.h>
  14. #include <sound/control.h>
  15. #include "aoa-gpio.h"
  16. #include "soundbus/soundbus.h"
  17. #define MAX_CODEC_NAME_LEN 32
  18. struct aoa_codec {
  19. char name[MAX_CODEC_NAME_LEN];
  20. struct module *owner;
  21. /* called when the fabric wants to init this codec.
  22. * Do alsa card manipulations from here. */
  23. int (*init)(struct aoa_codec *codec);
  24. /* called when the fabric is done with the codec.
  25. * The alsa card will be cleaned up so don't bother. */
  26. void (*exit)(struct aoa_codec *codec);
  27. /* May be NULL, but can be used by the fabric.
  28. * Refcounting is the codec driver's responsibility */
  29. struct device_node *node;
  30. /* assigned by fabric before init() is called, points
  31. * to the soundbus device. Cannot be NULL. */
  32. struct soundbus_dev *soundbus_dev;
  33. /* assigned by the fabric before init() is called, points
  34. * to the fabric's gpio runtime record for the relevant
  35. * device. */
  36. struct gpio_runtime *gpio;
  37. /* assigned by the fabric before init() is called, contains
  38. * a codec specific bitmask of what outputs and inputs are
  39. * actually connected */
  40. u32 connected;
  41. /* data the fabric can associate with this structure */
  42. void *fabric_data;
  43. /* private! */
  44. struct list_head list;
  45. struct aoa_fabric *fabric;
  46. };
  47. /* return 0 on success */
  48. extern int
  49. aoa_codec_register(struct aoa_codec *codec);
  50. extern void
  51. aoa_codec_unregister(struct aoa_codec *codec);
  52. #define MAX_LAYOUT_NAME_LEN 32
  53. struct aoa_fabric {
  54. char name[MAX_LAYOUT_NAME_LEN];
  55. struct module *owner;
  56. /* once codecs register, they are passed here after.
  57. * They are of course not initialised, since the
  58. * fabric is responsible for initialising some fields
  59. * in the codec structure! */
  60. int (*found_codec)(struct aoa_codec *codec);
  61. /* called for each codec when it is removed,
  62. * also in the case that aoa_fabric_unregister
  63. * is called and all codecs are removed
  64. * from this fabric.
  65. * Also called if found_codec returned 0 but
  66. * the codec couldn't initialise. */
  67. void (*remove_codec)(struct aoa_codec *codec);
  68. /* If found_codec returned 0, and the codec
  69. * could be initialised, this is called. */
  70. void (*attached_codec)(struct aoa_codec *codec);
  71. };
  72. /* return 0 on success, -EEXIST if another fabric is
  73. * registered, -EALREADY if the same fabric is registered.
  74. * Passing NULL can be used to test for the presence
  75. * of another fabric, if -EALREADY is returned there is
  76. * no other fabric present.
  77. * In the case that the function returns -EALREADY
  78. * and the fabric passed is not NULL, all codecs
  79. * that are not assigned yet are passed to the fabric
  80. * again for reconsideration. */
  81. extern int
  82. aoa_fabric_register(struct aoa_fabric *fabric, struct device *dev);
  83. /* it is vital to call this when the fabric exits!
  84. * When calling, the remove_codec will be called
  85. * for all codecs, unless it is NULL. */
  86. extern void
  87. aoa_fabric_unregister(struct aoa_fabric *fabric);
  88. /* if for some reason you want to get rid of a codec
  89. * before the fabric is removed, use this.
  90. * Note that remove_codec is called for it! */
  91. extern void
  92. aoa_fabric_unlink_codec(struct aoa_codec *codec);
  93. /* alsa help methods */
  94. struct aoa_card {
  95. struct snd_card *alsa_card;
  96. };
  97. extern int aoa_snd_device_new(snd_device_type_t type,
  98. void * device_data, struct snd_device_ops * ops);
  99. extern struct snd_card *aoa_get_card(void);
  100. extern int aoa_snd_ctl_add(struct snd_kcontrol* control);
  101. /* GPIO stuff */
  102. extern struct gpio_methods *pmf_gpio_methods;
  103. extern struct gpio_methods *ftr_gpio_methods;
  104. /* extern struct gpio_methods *map_gpio_methods; */
  105. #endif /* __AOA_H */