aoa.h 3.7 KB

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