xref: /linux/sound/usb/mixer.h (revision 3360b84b8ed1f08bfb39743465b858a04492fcc3)
1f0b5e634SDaniel Mack #ifndef __USBMIXER_H
2f0b5e634SDaniel Mack #define __USBMIXER_H
3f0b5e634SDaniel Mack 
4*3360b84bSTakashi Iwai #include <sound/info.h>
5*3360b84bSTakashi Iwai 
6f0b5e634SDaniel Mack struct usb_mixer_interface {
7f0b5e634SDaniel Mack 	struct snd_usb_audio *chip;
81faa5d07SDaniel Mack 	struct usb_host_interface *hostif;
9f0b5e634SDaniel Mack 	struct list_head list;
10f0b5e634SDaniel Mack 	unsigned int ignore_ctl_error;
11f0b5e634SDaniel Mack 	struct urb *urb;
12f0b5e634SDaniel Mack 	/* array[MAX_ID_ELEMS], indexed by unit id */
13*3360b84bSTakashi Iwai 	struct usb_mixer_elem_list **id_elems;
14f0b5e634SDaniel Mack 
1523caaf19SDaniel Mack 	/* the usb audio specification version this interface complies to */
1623caaf19SDaniel Mack 	int protocol;
1723caaf19SDaniel Mack 
18f0b5e634SDaniel Mack 	/* Sound Blaster remote control stuff */
19f0b5e634SDaniel Mack 	const struct rc_config *rc_cfg;
20f0b5e634SDaniel Mack 	u32 rc_code;
21f0b5e634SDaniel Mack 	wait_queue_head_t rc_waitq;
22f0b5e634SDaniel Mack 	struct urb *rc_urb;
23f0b5e634SDaniel Mack 	struct usb_ctrlrequest *rc_setup_packet;
24f0b5e634SDaniel Mack 	u8 rc_buffer[6];
25f0b5e634SDaniel Mack 
26f0b5e634SDaniel Mack 	u8 audigy2nx_leds[3];
27f0b5e634SDaniel Mack 	u8 xonar_u1_status;
28f0b5e634SDaniel Mack };
29f0b5e634SDaniel Mack 
309e38658fSDaniel Mack #define MAX_CHANNELS	16	/* max logical channels */
319e38658fSDaniel Mack 
329e38658fSDaniel Mack enum {
339e38658fSDaniel Mack 	USB_MIXER_BOOLEAN,
349e38658fSDaniel Mack 	USB_MIXER_INV_BOOLEAN,
359e38658fSDaniel Mack 	USB_MIXER_S8,
369e38658fSDaniel Mack 	USB_MIXER_U8,
379e38658fSDaniel Mack 	USB_MIXER_S16,
389e38658fSDaniel Mack 	USB_MIXER_U16,
399e38658fSDaniel Mack };
40f0b5e634SDaniel Mack 
41*3360b84bSTakashi Iwai typedef void (*usb_mixer_elem_dump_func_t)(struct snd_info_buffer *buffer,
42*3360b84bSTakashi Iwai 					 struct usb_mixer_elem_list *list);
43*3360b84bSTakashi Iwai typedef int (*usb_mixer_elem_resume_func_t)(struct usb_mixer_elem_list *elem);
44*3360b84bSTakashi Iwai 
45*3360b84bSTakashi Iwai struct usb_mixer_elem_list {
46f0b5e634SDaniel Mack 	struct usb_mixer_interface *mixer;
47*3360b84bSTakashi Iwai 	struct usb_mixer_elem_list *next_id_elem; /* list of controls with same id */
48*3360b84bSTakashi Iwai 	struct snd_kcontrol *kctl;
49f0b5e634SDaniel Mack 	unsigned int id;
50*3360b84bSTakashi Iwai 	usb_mixer_elem_dump_func_t dump;
51*3360b84bSTakashi Iwai 	usb_mixer_elem_resume_func_t resume;
52*3360b84bSTakashi Iwai };
53*3360b84bSTakashi Iwai 
54*3360b84bSTakashi Iwai struct usb_mixer_elem_info {
55*3360b84bSTakashi Iwai 	struct usb_mixer_elem_list head;
56f0b5e634SDaniel Mack 	unsigned int control;	/* CS or ICN (high byte) */
57f0b5e634SDaniel Mack 	unsigned int cmask; /* channel mask bitmap: 0 = master */
589f814105SEldad Zack 	unsigned int idx_off; /* Control index offset */
59a6a33259SDaniel Mack 	unsigned int ch_readonly;
60a6a33259SDaniel Mack 	unsigned int master_readonly;
61f0b5e634SDaniel Mack 	int channels;
62f0b5e634SDaniel Mack 	int val_type;
63f0b5e634SDaniel Mack 	int min, max, res;
64f0b5e634SDaniel Mack 	int dBmin, dBmax;
65f0b5e634SDaniel Mack 	int cached;
66f0b5e634SDaniel Mack 	int cache_val[MAX_CHANNELS];
67f0b5e634SDaniel Mack 	u8 initialized;
68f41d6049SChris J Arges 	void *private_data;
69f0b5e634SDaniel Mack };
70f0b5e634SDaniel Mack 
71f0b5e634SDaniel Mack int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
72f0b5e634SDaniel Mack 			 int ignore_error);
73a6cece9dSTakashi Iwai void snd_usb_mixer_disconnect(struct usb_mixer_interface *mixer);
74f0b5e634SDaniel Mack 
75f0b5e634SDaniel Mack void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid);
76f0b5e634SDaniel Mack 
77f0b5e634SDaniel Mack int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
78f0b5e634SDaniel Mack 				int request, int validx, int value_set);
79f0b5e634SDaniel Mack 
80*3360b84bSTakashi Iwai int snd_usb_mixer_add_control(struct usb_mixer_elem_list *list,
81ef9d5970SDaniel Mack 			      struct snd_kcontrol *kctl);
82ef9d5970SDaniel Mack 
83*3360b84bSTakashi Iwai void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list,
84*3360b84bSTakashi Iwai 				 struct usb_mixer_interface *mixer,
85*3360b84bSTakashi Iwai 				 int unitid);
86*3360b84bSTakashi Iwai 
87285de9c0SFelix Homann int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
88285de9c0SFelix Homann 			  unsigned int size, unsigned int __user *_tlv);
89285de9c0SFelix Homann 
90400362f1STakashi Iwai #ifdef CONFIG_PM
91400362f1STakashi Iwai int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer);
92400362f1STakashi Iwai int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume);
93400362f1STakashi Iwai #endif
94400362f1STakashi Iwai 
95eef90451SChris J Arges int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
96eef90451SChris J Arges                              int index, int value);
97eef90451SChris J Arges 
98eef90451SChris J Arges int snd_usb_get_cur_mix_value(struct usb_mixer_elem_info *cval,
99eef90451SChris J Arges                              int channel, int index, int *value);
100eef90451SChris J Arges 
101eef90451SChris J Arges extern void snd_usb_mixer_elem_free(struct snd_kcontrol *kctl);
102eef90451SChris J Arges 
103f0b5e634SDaniel Mack #endif /* __USBMIXER_H */
104