mixer.h 3.3 KB

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