mixer.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __USBMIXER_H
  3. #define __USBMIXER_H
  4. #include <sound/info.h>
  5. struct media_mixer_ctl;
  6. struct usbmix_connector_map {
  7. u8 id;
  8. u8 delegated_id;
  9. u8 control;
  10. u8 channel;
  11. };
  12. struct usb_mixer_interface {
  13. struct snd_usb_audio *chip;
  14. struct usb_host_interface *hostif;
  15. struct list_head list;
  16. unsigned int ignore_ctl_error;
  17. struct urb *urb;
  18. /* array[MAX_ID_ELEMS], indexed by unit id */
  19. struct usb_mixer_elem_list **id_elems;
  20. /* the usb audio specification version this interface complies to */
  21. int protocol;
  22. /* optional connector delegation map */
  23. const struct usbmix_connector_map *connector_map;
  24. /* Sound Blaster remote control stuff */
  25. const struct rc_config *rc_cfg;
  26. u32 rc_code;
  27. wait_queue_head_t rc_waitq;
  28. struct urb *rc_urb;
  29. struct usb_ctrlrequest *rc_setup_packet;
  30. u8 rc_buffer[6];
  31. struct media_mixer_ctl *media_mixer_ctl;
  32. bool disconnected;
  33. void *private_data;
  34. void (*private_free)(struct usb_mixer_interface *mixer);
  35. void (*private_suspend)(struct usb_mixer_interface *mixer);
  36. };
  37. #define MAX_CHANNELS 16 /* max logical channels */
  38. enum {
  39. USB_MIXER_BOOLEAN,
  40. USB_MIXER_INV_BOOLEAN,
  41. USB_MIXER_S8,
  42. USB_MIXER_U8,
  43. USB_MIXER_S16,
  44. USB_MIXER_U16,
  45. USB_MIXER_S32,
  46. USB_MIXER_U32,
  47. USB_MIXER_BESPOKEN, /* non-standard type */
  48. };
  49. typedef void (*usb_mixer_elem_dump_func_t)(struct snd_info_buffer *buffer,
  50. struct usb_mixer_elem_list *list);
  51. typedef int (*usb_mixer_elem_resume_func_t)(struct usb_mixer_elem_list *elem);
  52. struct usb_mixer_elem_list {
  53. struct usb_mixer_interface *mixer;
  54. struct usb_mixer_elem_list *next_id_elem; /* list of controls with same id */
  55. struct snd_kcontrol *kctl;
  56. unsigned int id;
  57. bool is_std_info;
  58. usb_mixer_elem_dump_func_t dump;
  59. usb_mixer_elem_resume_func_t resume;
  60. };
  61. /* iterate over mixer element list of the given unit id */
  62. #define for_each_mixer_elem(list, mixer, id) \
  63. for ((list) = (mixer)->id_elems[id]; (list); (list) = (list)->next_id_elem)
  64. #define mixer_elem_list_to_info(list) \
  65. container_of(list, struct usb_mixer_elem_info, head)
  66. struct usb_mixer_elem_info {
  67. struct usb_mixer_elem_list head;
  68. unsigned int control; /* CS or ICN (high byte) */
  69. unsigned int cmask; /* channel mask bitmap: 0 = master */
  70. unsigned int idx_off; /* Control index offset */
  71. unsigned int ch_readonly;
  72. unsigned int master_readonly;
  73. int channels;
  74. int val_type;
  75. int min, max, res;
  76. int max_exposed; /* control API exposes the value in 0..max_exposed */
  77. int dBmin, dBmax;
  78. int cached;
  79. int cache_val[MAX_CHANNELS];
  80. u8 initialized;
  81. u8 min_mute;
  82. void *private_data;
  83. };
  84. int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif);
  85. void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer);
  86. void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid);
  87. int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
  88. int request, int validx, int value_set);
  89. int snd_usb_mixer_add_list(struct usb_mixer_elem_list *list,
  90. struct snd_kcontrol *kctl,
  91. bool is_std_info);
  92. #define snd_usb_mixer_add_control(list, kctl) \
  93. snd_usb_mixer_add_list(list, kctl, true)
  94. void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list,
  95. struct usb_mixer_interface *mixer,
  96. int unitid);
  97. int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
  98. unsigned int size, unsigned int __user *_tlv);
  99. int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer);
  100. int snd_usb_mixer_resume(struct usb_mixer_interface *mixer);
  101. int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
  102. int index, int value);
  103. int snd_usb_get_cur_mix_value(struct usb_mixer_elem_info *cval,
  104. int channel, int index, int *value);
  105. extern void snd_usb_mixer_elem_free(struct snd_kcontrol *kctl);
  106. extern const struct snd_kcontrol_new *snd_usb_feature_unit_ctl;
  107. #endif /* __USBMIXER_H */