xref: /linux/include/sound/jack.h (revision bf35df66f1c613b46e054ca35ceb5caddacc6fa8)
1e76d8ceaSMark Brown #ifndef __SOUND_JACK_H
2e76d8ceaSMark Brown #define __SOUND_JACK_H
3e76d8ceaSMark Brown 
4e76d8ceaSMark Brown /*
5e76d8ceaSMark Brown  *  Jack abstraction layer
6e76d8ceaSMark Brown  *
7e76d8ceaSMark Brown  *  Copyright 2008 Wolfson Microelectronics plc
8e76d8ceaSMark Brown  *
9e76d8ceaSMark Brown  *
10e76d8ceaSMark Brown  *   This program is free software; you can redistribute it and/or modify
11e76d8ceaSMark Brown  *   it under the terms of the GNU General Public License as published by
12e76d8ceaSMark Brown  *   the Free Software Foundation; either version 2 of the License, or
13e76d8ceaSMark Brown  *   (at your option) any later version.
14e76d8ceaSMark Brown  *
15e76d8ceaSMark Brown  *   This program is distributed in the hope that it will be useful,
16e76d8ceaSMark Brown  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
17e76d8ceaSMark Brown  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18e76d8ceaSMark Brown  *   GNU General Public License for more details.
19e76d8ceaSMark Brown  *
20e76d8ceaSMark Brown  *   You should have received a copy of the GNU General Public License
21e76d8ceaSMark Brown  *   along with this program; if not, write to the Free Software
22e76d8ceaSMark Brown  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23e76d8ceaSMark Brown  *
24e76d8ceaSMark Brown  */
25e76d8ceaSMark Brown 
26e76d8ceaSMark Brown #include <sound/core.h>
27e76d8ceaSMark Brown 
28e76d8ceaSMark Brown struct input_dev;
29e76d8ceaSMark Brown 
30e76d8ceaSMark Brown /**
31e83280f9STakashi Iwai  * enum snd_jack_types - Jack types which can be reported
32e83280f9STakashi Iwai  * @SND_JACK_HEADPHONE: Headphone
33e83280f9STakashi Iwai  * @SND_JACK_MICROPHONE: Microphone
34e83280f9STakashi Iwai  * @SND_JACK_HEADSET: Headset
35e83280f9STakashi Iwai  * @SND_JACK_LINEOUT: Line out
36e83280f9STakashi Iwai  * @SND_JACK_MECHANICAL: Mechanical switch
37e83280f9STakashi Iwai  * @SND_JACK_VIDEOOUT: Video out
38e83280f9STakashi Iwai  * @SND_JACK_AVOUT: AV (Audio Video) out
39e83280f9STakashi Iwai  * @SND_JACK_LINEIN:  Line in
40e83280f9STakashi Iwai  * @SND_JACK_BTN_0: Button 0
41e83280f9STakashi Iwai  * @SND_JACK_BTN_1: Button 1
42e83280f9STakashi Iwai  * @SND_JACK_BTN_2: Button 2
43e83280f9STakashi Iwai  * @SND_JACK_BTN_3: Button 3
44e83280f9STakashi Iwai  * @SND_JACK_BTN_4: Button 4
45e83280f9STakashi Iwai  * @SND_JACK_BTN_5: Button 5
467b366d5fSTakashi Iwai  *
477b366d5fSTakashi Iwai  * These values are used as a bitmask.
48bd8a71a7SMark Brown  *
49bd8a71a7SMark Brown  * Note that this must be kept in sync with the lookup table in
50bd8a71a7SMark Brown  * sound/core/jack.c.
51e76d8ceaSMark Brown  */
52e76d8ceaSMark Brown enum snd_jack_types {
53e76d8ceaSMark Brown 	SND_JACK_HEADPHONE	= 0x0001,
54e76d8ceaSMark Brown 	SND_JACK_MICROPHONE	= 0x0002,
55e76d8ceaSMark Brown 	SND_JACK_HEADSET	= SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
56a53ccab3SMatthew Ranostay 	SND_JACK_LINEOUT	= 0x0004,
57cdc69364SMark Brown 	SND_JACK_MECHANICAL	= 0x0008, /* If detected separately */
58d506fc32SJani Nikula 	SND_JACK_VIDEOOUT	= 0x0010,
59d506fc32SJani Nikula 	SND_JACK_AVOUT		= SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
607c2f8e40SDavid Henningsson 	SND_JACK_LINEIN		= 0x0020,
61ebb812cbSMark Brown 
62ebb812cbSMark Brown 	/* Kept separate from switches to facilitate implementation */
63ebb812cbSMark Brown 	SND_JACK_BTN_0		= 0x4000,
64ebb812cbSMark Brown 	SND_JACK_BTN_1		= 0x2000,
65ebb812cbSMark Brown 	SND_JACK_BTN_2		= 0x1000,
66831853c8SMark Brown 	SND_JACK_BTN_3		= 0x0800,
67831853c8SMark Brown 	SND_JACK_BTN_4		= 0x0400,
68831853c8SMark Brown 	SND_JACK_BTN_5		= 0x0200,
69e76d8ceaSMark Brown };
70e76d8ceaSMark Brown 
7153803aeaSMark Brown /* Keep in sync with definitions above */
7253803aeaSMark Brown #define SND_JACK_SWITCH_TYPES 6
7353803aeaSMark Brown 
74e76d8ceaSMark Brown struct snd_jack {
75e76d8ceaSMark Brown 	struct input_dev *input_dev;
76e76d8ceaSMark Brown 	int registered;
77e76d8ceaSMark Brown 	int type;
78e76d8ceaSMark Brown 	const char *id;
79e76d8ceaSMark Brown 	char name[100];
80831853c8SMark Brown 	unsigned int key[6];   /* Keep in sync with definitions above */
819d59065cSTakashi Iwai 	void *private_data;
829d59065cSTakashi Iwai 	void (*private_free)(struct snd_jack *);
83e76d8ceaSMark Brown };
84e76d8ceaSMark Brown 
85e76d8ceaSMark Brown #ifdef CONFIG_SND_JACK
86e76d8ceaSMark Brown 
87e76d8ceaSMark Brown int snd_jack_new(struct snd_card *card, const char *id, int type,
88e76d8ceaSMark Brown 		 struct snd_jack **jack);
89e76d8ceaSMark Brown void snd_jack_set_parent(struct snd_jack *jack, struct device *parent);
90ebb812cbSMark Brown int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
91ebb812cbSMark Brown 		     int keytype);
92e76d8ceaSMark Brown 
93e76d8ceaSMark Brown void snd_jack_report(struct snd_jack *jack, int status);
94e76d8ceaSMark Brown 
95e76d8ceaSMark Brown #else
96e76d8ceaSMark Brown 
97e76d8ceaSMark Brown static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
98e76d8ceaSMark Brown 			       struct snd_jack **jack)
99e76d8ceaSMark Brown {
100e76d8ceaSMark Brown 	return 0;
101e76d8ceaSMark Brown }
102e76d8ceaSMark Brown 
103e76d8ceaSMark Brown static inline void snd_jack_set_parent(struct snd_jack *jack,
104e76d8ceaSMark Brown 				       struct device *parent)
105e76d8ceaSMark Brown {
106e76d8ceaSMark Brown }
107e76d8ceaSMark Brown 
108*bf35df66STakashi Iwai static inline int snd_jack_set_key(struct snd_jack *jack,
109*bf35df66STakashi Iwai 				   enum snd_jack_types type,
110*bf35df66STakashi Iwai 				   int keytype)
111*bf35df66STakashi Iwai {
112*bf35df66STakashi Iwai 	return 0;
113*bf35df66STakashi Iwai }
114*bf35df66STakashi Iwai 
115e76d8ceaSMark Brown static inline void snd_jack_report(struct snd_jack *jack, int status)
116e76d8ceaSMark Brown {
117e76d8ceaSMark Brown }
118e76d8ceaSMark Brown 
119e76d8ceaSMark Brown #endif
120e76d8ceaSMark Brown 
121e76d8ceaSMark Brown #endif
122