aboutsummaryrefslogtreecommitdiffstats
path: root/CREDITS
Commit message (Expand)AuthorAge
* MAINTAINERS: remove Adam Fritzler, remove his email address in other sourcesJoe Perches2008-02-03
* remove obsolete contact information from CREDITSAdrian Bunk2008-02-03
* [CAN]: Add maintainer entriesOliver Hartkopp2008-01-28
* Convert files to UTF-8 and some cleanupsJan Engelhardt2007-10-19
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuildLinus Torvalds2007-10-16
|\
| * kbuild: move Kai Germaschewski to CREDITSSam Ravnborg2007-10-12
* | Merge branch 'linus' of master.kernel.org:/pub/scm/linux/kernel/git/perex/alsaLinus Torvalds2007-10-16
|\ \
| * | [ALSA] Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.czJaroslav Kysela2007-10-16
| |/
* / CREDITS: correct Mikael Pettersson's URLMikael Pettersson2007-10-16
|/
* [RT2x00]: add driver for Ralink wireless hardwareIvo van Doorn2007-10-10
* Slab maintainer & Credits updateChristoph Lameter2007-07-26
* [ALSA] Update Claudio's CREDITS informationClaudio Matsuoka2007-07-20
* Fix up CREDIT entry orderingLi Yang2007-06-20
* further UTF-8 fixes and name correctionDavid Woodhouse2007-05-11
* Convert the toplevel files CREDITS and MAINTAINERS to UTF-8.John Anthony Kazos Jr2007-05-09
* Add webpages' URL and summarize 3 lines.Miguel Ojeda2007-05-08
* proc: maps protectionKees Cook2007-05-08
* [PATCH] x86-64: Change my email addressAndi Kleen2007-05-02
* USB: update MAINAINERS and CREDITS for Freescale USB driverLi Yang2007-04-27
* [WIRELESS] cfg80211: New wireless config infrastructure.Johannes Berg2007-04-26
* [CREDITS]: Update Arnaldo entryArnaldo Carvalho de Melo2007-04-26
* [PATCH] CREDITS: update my email addressMikael Pettersson2007-02-26
* [PATCH] drivers: add LCD supportMiguel Ojeda Sandonis2007-02-11
* Change Linus' email address tooLinus Torvalds2007-01-23
* [PATCH] Update CREDITS and MAINTAINERS entries for Lennert BuytenhekLennert Buytenhek2006-12-30
* [PATCH] Generic HID layer - buildJiri Kosina2006-12-08
* [TCP]: MD5 Signature Option (RFC2385) support.YOSHIFUJI Hideaki2006-12-03
* [PATCH] Update my CREDITS entryDavid Weinehall2006-11-17
* [PATCH] Tigran has movedTigran Aivazian2006-11-08
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6Linus Torvalds2006-10-04
|\
| * Merge branch 'master' into gfs2Steven Whitehouse2006-10-02
| |\
| * \ [GFS2] Fix up merge of Linus' kernel into GFS2Steven Whitehouse2006-09-25
| |\ \
| * \ \ Merge branch 'master' into gfs2Steven Whitehouse2006-08-29
| |\ \ \
| * \ \ \ Merge branch 'master'Steven Whitehouse2006-07-17
| |\ \ \ \
| * \ \ \ \ Merge rsync://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6Steven Whitehouse2006-07-03
| |\ \ \ \ \
| * \ \ \ \ \ Merge branch 'master'Steven Whitehouse2006-05-25
| |\ \ \ \ \ \
| * \ \ \ \ \ \ Merge branch 'master'Steven Whitehouse2006-05-12
| |\ \ \ \ \ \ \
| * | | | | | | | [GFS2] Update my Credits file entrySteven Whitehouse2006-04-28
* | | | | | | | | [PATCH] RCU: CREDITS and MAINTAINERSJosh Triplett2006-10-04
* | | | | | | | | Add missing maintainer countries in CREDITSSamuel Tardieu2006-10-03
* | | | | | | | | Michal Wronski: update contact infoMichal Wronski2006-10-03
* | | | | | | | | [PATCH] Add Pekka to CREDITSPekka Enberg2006-10-03
| |_|_|_|_|_|_|/ |/| | | | | | |
* | | | | | | | [PATCH] /sys/modules: allow full length section namesIan S. Nelson2006-09-29
* | | | | | | | [PATCH] Small update to CREDITSJesper Juhl2006-09-29
| |_|_|_|_|_|/ |/| | | | | |
* | | | | | | [NetLabel]: documentationPaul Moore2006-09-22
| |_|_|_|_|/ |/| | | | |
* | | | | | [DCCP]: Update contact details and copyrightIan McDonald2006-08-26
| |_|_|_|/ |/| | | |
* | | | | [PATCH] Updates CREDITS fileLuiz Fernando N. Capitulino2006-07-10
| |_|_|/ |/| | |
* | | | Merge master.kernel.org:/pub/scm/linux/kernel/git/kyle/parisc-2.6Linus Torvalds2006-06-29
|\ \ \ \
| * | | | [PARISC] Update Thibaut Varene's CREDITS entryThibaut Varene2006-06-27
* | | | | move acknowledgment for Mark Adler to CREDITSAdrian Bunk2006-06-26
|/ / / /
es' href='/cgit/cgit.cgi/litmus-rt-budgetable-locks.git/.git/commit/sound/soc/soc-jack.c?h=update_litmus_2019&id=d5021ec9fc32edc6f512c2375923d757e9825f6a'>d5021ec9fc32
ec67624d33d5

26bd7b496cab
ec67624d33d5




535787b6ae08
ec67624d33d5







c871a05315d1


ec67624d33d5






f9a67059d43a

3028eb8c51d9

f9a67059d43a

ec67624d33d5
4c14d78e8ad3

ec67624d33d5








4c14d78e8ad3
ec67624d33d5



















008d55e258d8
ec67624d33d5




008d55e258d8
ec67624d33d5












4c14d78e8ad3
b8e22c1fe375

3f58fd84b0c0



363618f013f2
3f58fd84b0c0
d2b4c7bd7eab
ec67624d33d5

7887ab3a274d
458f7f8f819b
7887ab3a274d
008d55e258d8
7887ab3a274d



178b699c25c3

178b699c25c3
178b699c25c3

ec67624d33d5



























178b699c25c3
ec67624d33d5
4c14d78e8ad3
ec67624d33d5





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379














                                                                            



                            
                         
                              


                                       
                     









                                                                         
                                                                           

                                               
                                 
                            
                                    
                                          
                                                     
 
                                                                          


















                                                                               
                                    
                                          

                                     
 

                                                      
                  
                       
 
                            
                             
 
                                 
 
                              
                                      
 

                                                
                                                     
                                                  




                                         
                                                                
                    
                                                                 

         
                                                                               
                                                                          
 
                                
 
                                                  
 
                                   



                                       























                                                                             
                                                            
  
                    


                                                                             
                                                        














                                                                         
















                                                                     

                                                                               


                                       

                                                                            






                                                       

                                                           








                                                                   
 

































                                                                           

                     
                                                                    




                                               
                                                     







                                      


                                                   






                                                        

                                                          

                                           

                                                               
 

                                                                     








                                               
                                                                       



















                                                                      
                                                                            




                                               
                                                                                












                                                                 
                                                             

                                     



                                                                         
                                                            
                                                         
                            

                                 
                                    
                                                                              
                                     
                                                                  



                                                                                

                                                                          
 

                                                    



























                                                                             
                                             
                                                                
                                                         





                                           
/*
 * soc-jack.c  --  ALSA SoC jack handling
 *
 * Copyright 2008 Wolfson Microelectronics PLC.
 *
 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
 *
 *  This program is free software; you can redistribute  it and/or modify it
 *  under  the terms of  the GNU General  Public License as published by the
 *  Free Software Foundation;  either version 2 of the  License, or (at your
 *  option) any later version.
 */

#include <sound/jack.h>
#include <sound/soc.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/workqueue.h>
#include <linux/delay.h>
#include <linux/export.h>
#include <trace/events/asoc.h>

/**
 * snd_soc_jack_new - Create a new jack
 * @codec: ASoC codec
 * @id:    an identifying string for this jack
 * @type:  a bitmask of enum snd_jack_type values that can be detected by
 *         this jack
 * @jack:  structure to use for the jack
 *
 * Creates a new jack object.
 *
 * Returns zero if successful, or a negative error code on failure.
 * On success jack will be initialised.
 */
int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
		     struct snd_soc_jack *jack)
{
	mutex_init(&jack->mutex);
	jack->codec = codec;
	INIT_LIST_HEAD(&jack->pins);
	INIT_LIST_HEAD(&jack->jack_zones);
	BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);

	return snd_jack_new(codec->card->snd_card, id, type, &jack->jack);
}
EXPORT_SYMBOL_GPL(snd_soc_jack_new);

/**
 * snd_soc_jack_report - Report the current status for a jack
 *
 * @jack:   the jack
 * @status: a bitmask of enum snd_jack_type values that are currently detected.
 * @mask:   a bitmask of enum snd_jack_type values that being reported.
 *
 * If configured using snd_soc_jack_add_pins() then the associated
 * DAPM pins will be enabled or disabled as appropriate and DAPM
 * synchronised.
 *
 * Note: This function uses mutexes and should be called from a
 * context which can sleep (such as a workqueue).
 */
void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
{
	struct snd_soc_codec *codec;
	struct snd_soc_dapm_context *dapm;
	struct snd_soc_jack_pin *pin;
	int enable;

	trace_snd_soc_jack_report(jack, mask, status);

	if (!jack)
		return;

	codec = jack->codec;
	dapm =  &codec->dapm;

	mutex_lock(&jack->mutex);

	jack->status &= ~mask;
	jack->status |= status & mask;

	trace_snd_soc_jack_notify(jack, status);

	list_for_each_entry(pin, &jack->pins, list) {
		enable = pin->mask & jack->status;

		if (pin->invert)
			enable = !enable;

		if (enable)
			snd_soc_dapm_enable_pin(dapm, pin->pin);
		else
			snd_soc_dapm_disable_pin(dapm, pin->pin);
	}

	/* Report before the DAPM sync to help users updating micbias status */
	blocking_notifier_call_chain(&jack->notifier, jack->status, jack);

	snd_soc_dapm_sync(dapm);

	snd_jack_report(jack->jack, jack->status);

	mutex_unlock(&jack->mutex);
}
EXPORT_SYMBOL_GPL(snd_soc_jack_report);

/**
 * snd_soc_jack_add_zones - Associate voltage zones with jack
 *
 * @jack:  ASoC jack
 * @count: Number of zones
 * @zone:  Array of zones
 *
 * After this function has been called the zones specified in the
 * array will be associated with the jack.
 */
int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
			  struct snd_soc_jack_zone *zones)
{
	int i;

	for (i = 0; i < count; i++) {
		INIT_LIST_HEAD(&zones[i].list);
		list_add(&(zones[i].list), &jack->jack_zones);
	}
	return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_jack_add_zones);

/**
 * snd_soc_jack_get_type - Based on the mic bias value, this function returns
 * the type of jack from the zones declared in the jack type
 *
 * @jack:  ASoC jack
 * @micbias_voltage:  mic bias voltage at adc channel when jack is plugged in
 *
 * Based on the mic bias value passed, this function helps identify
 * the type of jack from the already declared jack zones
 */
int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage)
{
	struct snd_soc_jack_zone *zone;

	list_for_each_entry(zone, &jack->jack_zones, list) {
		if (micbias_voltage >= zone->min_mv &&
			micbias_voltage < zone->max_mv)
				return zone->jack_type;
	}
	return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_jack_get_type);

/**
 * snd_soc_jack_add_pins - Associate DAPM pins with an ASoC jack
 *
 * @jack:  ASoC jack
 * @count: Number of pins
 * @pins:  Array of pins
 *
 * After this function has been called the DAPM pins specified in the
 * pins array will have their status updated to reflect the current
 * state of the jack whenever the jack status is updated.
 */
int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
			  struct snd_soc_jack_pin *pins)
{
	int i;

	for (i = 0; i < count; i++) {
		if (!pins[i].pin) {
			dev_err(jack->codec->dev, "ASoC: No name for pin %d\n",
				i);
			return -EINVAL;
		}
		if (!pins[i].mask) {
			dev_err(jack->codec->dev, "ASoC: No mask for pin %d"
				" (%s)\n", i, pins[i].pin);
			return -EINVAL;
		}

		INIT_LIST_HEAD(&pins[i].list);
		list_add(&(pins[i].list), &jack->pins);
	}

	snd_soc_dapm_new_widgets(&jack->codec->card->dapm);

	/* Update to reflect the last reported status; canned jack
	 * implementations are likely to set their state before the
	 * card has an opportunity to associate pins.
	 */
	snd_soc_jack_report(jack, 0, 0);

	return 0;
}
EXPORT_SYMBOL_GPL(snd_soc_jack_add_pins);

/**
 * snd_soc_jack_notifier_register - Register a notifier for jack status
 *
 * @jack:  ASoC jack
 * @nb:    Notifier block to register
 *
 * Register for notification of the current status of the jack.  Note
 * that it is not possible to report additional jack events in the
 * callback from the notifier, this is intended to support
 * applications such as enabling electrical detection only when a
 * mechanical detection event has occurred.
 */
void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
				    struct notifier_block *nb)
{
	blocking_notifier_chain_register(&jack->notifier, nb);
}
EXPORT_SYMBOL_GPL(snd_soc_jack_notifier_register);

/**
 * snd_soc_jack_notifier_unregister - Unregister a notifier for jack status
 *
 * @jack:  ASoC jack
 * @nb:    Notifier block to unregister
 *
 * Stop notifying for status changes.
 */
void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
				      struct notifier_block *nb)
{
	blocking_notifier_chain_unregister(&jack->notifier, nb);
}
EXPORT_SYMBOL_GPL(snd_soc_jack_notifier_unregister);

#ifdef CONFIG_GPIOLIB
/* gpio detect */
static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
{
	struct snd_soc_jack *jack = gpio->jack;
	int enable;
	int report;

	enable = gpio_get_value_cansleep(gpio->gpio);
	if (gpio->invert)
		enable = !enable;

	if (enable)
		report = gpio->report;
	else
		report = 0;

	if (gpio->jack_status_check)
		report = gpio->jack_status_check();

	snd_soc_jack_report(jack, report, gpio->report);
}

/* irq handler for gpio pin */
static irqreturn_t gpio_handler(int irq, void *data)
{
	struct snd_soc_jack_gpio *gpio = data;
	struct device *dev = gpio->jack->codec->card->dev;

	trace_snd_soc_jack_irq(gpio->name);

	if (device_may_wakeup(dev))
		pm_wakeup_event(dev, gpio->debounce_time + 50);

	schedule_delayed_work(&gpio->work,
			      msecs_to_jiffies(gpio->debounce_time));

	return IRQ_HANDLED;
}

/* gpio work */
static void gpio_work(struct work_struct *work)
{
	struct snd_soc_jack_gpio *gpio;

	gpio = container_of(work, struct snd_soc_jack_gpio, work.work);
	snd_soc_jack_gpio_detect(gpio);
}

/**
 * snd_soc_jack_add_gpios - Associate GPIO pins with an ASoC jack
 *
 * @jack:  ASoC jack
 * @count: number of pins
 * @gpios: array of gpio pins
 *
 * This function will request gpio, set data direction and request irq
 * for each gpio in the array.
 */
int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
			struct snd_soc_jack_gpio *gpios)
{
	int i, ret;

	for (i = 0; i < count; i++) {
		if (!gpio_is_valid(gpios[i].gpio)) {
			dev_err(jack->codec->dev, "ASoC: Invalid gpio %d\n",
				gpios[i].gpio);
			ret = -EINVAL;
			goto undo;
		}
		if (!gpios[i].name) {
			dev_err(jack->codec->dev, "ASoC: No name for gpio %d\n",
				gpios[i].gpio);
			ret = -EINVAL;
			goto undo;
		}

		ret = gpio_request(gpios[i].gpio, gpios[i].name);
		if (ret)
			goto undo;

		ret = gpio_direction_input(gpios[i].gpio);
		if (ret)
			goto err;

		INIT_DELAYED_WORK(&gpios[i].work, gpio_work);
		gpios[i].jack = jack;

		ret = request_any_context_irq(gpio_to_irq(gpios[i].gpio),
					      gpio_handler,
					      IRQF_TRIGGER_RISING |
					      IRQF_TRIGGER_FALLING,
					      gpios[i].name,
					      &gpios[i]);
		if (ret < 0)
			goto err;

		if (gpios[i].wake) {
			ret = irq_set_irq_wake(gpio_to_irq(gpios[i].gpio), 1);
			if (ret != 0)
				dev_err(jack->codec->dev, "ASoC: "
				  "Failed to mark GPIO %d as wake source: %d\n",
					gpios[i].gpio, ret);
		}

		/* Expose GPIO value over sysfs for diagnostic purposes */
		gpio_export(gpios[i].gpio, false);

		/* Update initial jack status */
		snd_soc_jack_gpio_detect(&gpios[i]);
	}

	return 0;

err:
	gpio_free(gpios[i].gpio);
undo:
	snd_soc_jack_free_gpios(jack, i, gpios);

	return ret;
}
EXPORT_SYMBOL_GPL(snd_soc_jack_add_gpios);

/**
 * snd_soc_jack_free_gpios - Release GPIO pins' resources of an ASoC jack
 *
 * @jack:  ASoC jack
 * @count: number of pins
 * @gpios: array of gpio pins
 *
 * Release gpio and irq resources for gpio pins associated with an ASoC jack.
 */
void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
			struct snd_soc_jack_gpio *gpios)
{
	int i;

	for (i = 0; i < count; i++) {
		gpio_unexport(gpios[i].gpio);
		free_irq(gpio_to_irq(gpios[i].gpio), &gpios[i]);
		cancel_delayed_work_sync(&gpios[i].work);
		gpio_free(gpios[i].gpio);
		gpios[i].jack = NULL;
	}
}
EXPORT_SYMBOL_GPL(snd_soc_jack_free_gpios);
#endif	/* CONFIG_GPIOLIB */