xref: /openbmc/linux/include/sound/jack.h (revision 4e3f0dc6)
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;
769058cbe1SJie Yang 	struct list_head kctl_list;
779058cbe1SJie Yang 	struct snd_card *card;
78e76d8ceaSMark Brown 	int registered;
79e76d8ceaSMark Brown 	int type;
80e76d8ceaSMark Brown 	const char *id;
81e76d8ceaSMark Brown 	char name[100];
82831853c8SMark Brown 	unsigned int key[6];   /* Keep in sync with definitions above */
839d59065cSTakashi Iwai 	void *private_data;
849d59065cSTakashi Iwai 	void (*private_free)(struct snd_jack *);
85e76d8ceaSMark Brown };
86e76d8ceaSMark Brown 
87e76d8ceaSMark Brown #ifdef CONFIG_SND_JACK
88e76d8ceaSMark Brown 
89e76d8ceaSMark Brown int snd_jack_new(struct snd_card *card, const char *id, int type,
904e3f0dc6SJie Yang 		 struct snd_jack **jack, bool initial_kctl, bool phantom_jack);
919058cbe1SJie Yang int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask);
92e76d8ceaSMark Brown void snd_jack_set_parent(struct snd_jack *jack, struct device *parent);
93ebb812cbSMark Brown int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
94ebb812cbSMark Brown 		     int keytype);
95e76d8ceaSMark Brown 
96e76d8ceaSMark Brown void snd_jack_report(struct snd_jack *jack, int status);
97e76d8ceaSMark Brown 
98e76d8ceaSMark Brown #else
99e76d8ceaSMark Brown static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
1004e3f0dc6SJie Yang 			       struct snd_jack **jack, bool initial_kctl, bool phantom_jack)
101e76d8ceaSMark Brown {
102e76d8ceaSMark Brown 	return 0;
103e76d8ceaSMark Brown }
104e76d8ceaSMark Brown 
1059058cbe1SJie Yang static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
1069058cbe1SJie Yang {
1079058cbe1SJie Yang 	return 0;
1089058cbe1SJie Yang }
1099058cbe1SJie Yang 
110e76d8ceaSMark Brown static inline void snd_jack_set_parent(struct snd_jack *jack,
111e76d8ceaSMark Brown 				       struct device *parent)
112e76d8ceaSMark Brown {
113e76d8ceaSMark Brown }
114e76d8ceaSMark Brown 
115bf35df66STakashi Iwai static inline int snd_jack_set_key(struct snd_jack *jack,
116bf35df66STakashi Iwai 				   enum snd_jack_types type,
117bf35df66STakashi Iwai 				   int keytype)
118bf35df66STakashi Iwai {
119bf35df66STakashi Iwai 	return 0;
120bf35df66STakashi Iwai }
121bf35df66STakashi Iwai 
122e76d8ceaSMark Brown static inline void snd_jack_report(struct snd_jack *jack, int status)
123e76d8ceaSMark Brown {
124e76d8ceaSMark Brown }
125e76d8ceaSMark Brown 
126e76d8ceaSMark Brown #endif
127e76d8ceaSMark Brown 
128e76d8ceaSMark Brown #endif
129