Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: sound/soc/codecs/cx20442.c

Issue 6577007: CHROMIUM: ASoC: Import entire upstream ASoC tree (Closed)
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sound/soc/codecs/cs42l51.c ('k') | sound/soc/codecs/da7210.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * cx20442.c -- CX20442 ALSA Soc Audio driver 2 * cx20442.c -- CX20442 ALSA Soc Audio driver
3 * 3 *
4 * Copyright 2009 Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> 4 * Copyright 2009 Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>
5 * 5 *
6 * Initially based on sound/soc/codecs/wm8400.c 6 * Initially based on sound/soc/codecs/wm8400.c
7 * Copyright 2008, 2009 Wolfson Microelectronics PLC. 7 * Copyright 2008, 2009 Wolfson Microelectronics PLC.
8 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 8 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your 12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version. 13 * option) any later version.
14 */ 14 */
15 15
16 #include <linux/tty.h> 16 #include <linux/tty.h>
17 #include <linux/slab.h> 17 #include <linux/slab.h>
18 18
19 #include <sound/core.h> 19 #include <sound/core.h>
20 #include <sound/initval.h> 20 #include <sound/initval.h>
21 #include <sound/soc-dapm.h> 21 #include <sound/soc.h>
22 22
23 #include "cx20442.h" 23 #include "cx20442.h"
24 24
25 25
26 struct cx20442_priv { 26 struct cx20442_priv {
27 enum snd_soc_control_type control_type; 27 enum snd_soc_control_type control_type;
28 void *control_data; 28 void *control_data;
29 u8 reg_cache[1];
30 }; 29 };
31 30
32 #define CX20442_PM 0x0 31 #define CX20442_PM 0x0
33 32
34 #define CX20442_TELIN 0 33 #define CX20442_TELIN 0
35 #define CX20442_TELOUT 1 34 #define CX20442_TELOUT 1
36 #define CX20442_MIC 2 35 #define CX20442_MIC 2
37 #define CX20442_SPKOUT 3 36 #define CX20442_SPKOUT 3
38 #define CX20442_AGC 4 37 #define CX20442_AGC 4
39 38
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 {"Input Mixer", NULL, "MIC Bias"}, 81 {"Input Mixer", NULL, "MIC Bias"},
83 82
84 {"TELIN Bias", NULL, "TELIN"}, 83 {"TELIN Bias", NULL, "TELIN"},
85 {"Input Mixer", NULL, "TELIN Bias"}, 84 {"Input Mixer", NULL, "TELIN Bias"},
86 85
87 {"ADC", NULL, "Input Mixer"}, 86 {"ADC", NULL, "Input Mixer"},
88 }; 87 };
89 88
90 static int cx20442_add_widgets(struct snd_soc_codec *codec) 89 static int cx20442_add_widgets(struct snd_soc_codec *codec)
91 { 90 {
92 » snd_soc_dapm_new_controls(codec, cx20442_dapm_widgets, 91 » struct snd_soc_dapm_context *dapm = &codec->dapm;
92
93 » snd_soc_dapm_new_controls(dapm, cx20442_dapm_widgets,
93 ARRAY_SIZE(cx20442_dapm_widgets)); 94 ARRAY_SIZE(cx20442_dapm_widgets));
94 95 » snd_soc_dapm_add_routes(dapm, cx20442_audio_map,
95 » snd_soc_dapm_add_routes(codec, cx20442_audio_map,
96 ARRAY_SIZE(cx20442_audio_map)); 96 ARRAY_SIZE(cx20442_audio_map));
97 97
98 return 0; 98 return 0;
99 } 99 }
100 100
101 static unsigned int cx20442_read_reg_cache(struct snd_soc_codec *codec, 101 static unsigned int cx20442_read_reg_cache(struct snd_soc_codec *codec,
102 unsigned int reg) 102 unsigned int reg)
103 { 103 {
104 u8 *reg_cache = codec->reg_cache; 104 u8 *reg_cache = codec->reg_cache;
105 105
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 tty->disc_data = NULL; 256 tty->disc_data = NULL;
257 257
258 if (!codec) 258 if (!codec)
259 return; 259 return;
260 260
261 cx20442 = snd_soc_codec_get_drvdata(codec); 261 cx20442 = snd_soc_codec_get_drvdata(codec);
262 262
263 /* Prevent the codec driver from further accessing the modem */ 263 /* Prevent the codec driver from further accessing the modem */
264 codec->hw_write = NULL; 264 codec->hw_write = NULL;
265 cx20442->control_data = NULL; 265 cx20442->control_data = NULL;
266 » codec->pop_time = 0; 266 » codec->card->pop_time = 0;
267 } 267 }
268 268
269 /* Line discipline .hangup() */ 269 /* Line discipline .hangup() */
270 static int v253_hangup(struct tty_struct *tty) 270 static int v253_hangup(struct tty_struct *tty)
271 { 271 {
272 v253_close(tty); 272 v253_close(tty);
273 return 0; 273 return 0;
274 } 274 }
275 275
276 /* Line discipline .receive_buf() */ 276 /* Line discipline .receive_buf() */
277 static void v253_receive(struct tty_struct *tty, 277 static void v253_receive(struct tty_struct *tty,
278 const unsigned char *cp, char *fp, int count) 278 const unsigned char *cp, char *fp, int count)
279 { 279 {
280 struct snd_soc_codec *codec = tty->disc_data; 280 struct snd_soc_codec *codec = tty->disc_data;
281 struct cx20442_priv *cx20442; 281 struct cx20442_priv *cx20442;
282 282
283 if (!codec) 283 if (!codec)
284 return; 284 return;
285 285
286 cx20442 = snd_soc_codec_get_drvdata(codec); 286 cx20442 = snd_soc_codec_get_drvdata(codec);
287 287
288 if (!cx20442->control_data) { 288 if (!cx20442->control_data) {
289 /* First modem response, complete setup procedure */ 289 /* First modem response, complete setup procedure */
290 290
291 /* Set up codec driver access to modem controls */ 291 /* Set up codec driver access to modem controls */
292 cx20442->control_data = tty; 292 cx20442->control_data = tty;
293 codec->hw_write = (hw_write_t)tty->ops->write; 293 codec->hw_write = (hw_write_t)tty->ops->write;
294 » » codec->pop_time = 1; 294 » » codec->card->pop_time = 1;
295 } 295 }
296 } 296 }
297 297
298 /* Line discipline .write_wakeup() */ 298 /* Line discipline .write_wakeup() */
299 static void v253_wakeup(struct tty_struct *tty) 299 static void v253_wakeup(struct tty_struct *tty)
300 { 300 {
301 } 301 }
302 302
303 struct tty_ldisc_ops v253_ops = { 303 struct tty_ldisc_ops v253_ops = {
304 .magic = TTY_LDISC_MAGIC, 304 .magic = TTY_LDISC_MAGIC,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 341
342 cx20442 = kzalloc(sizeof(struct cx20442_priv), GFP_KERNEL); 342 cx20442 = kzalloc(sizeof(struct cx20442_priv), GFP_KERNEL);
343 if (cx20442 == NULL) 343 if (cx20442 == NULL)
344 return -ENOMEM; 344 return -ENOMEM;
345 snd_soc_codec_set_drvdata(codec, cx20442); 345 snd_soc_codec_set_drvdata(codec, cx20442);
346 346
347 cx20442_add_widgets(codec); 347 cx20442_add_widgets(codec);
348 348
349 cx20442->control_data = NULL; 349 cx20442->control_data = NULL;
350 codec->hw_write = NULL; 350 codec->hw_write = NULL;
351 » codec->pop_time = 0; 351 » codec->card->pop_time = 0;
352 352
353 return 0; 353 return 0;
354 } 354 }
355 355
356 /* power down chip */ 356 /* power down chip */
357 static int cx20442_codec_remove(struct snd_soc_codec *codec) 357 static int cx20442_codec_remove(struct snd_soc_codec *codec)
358 { 358 {
359 struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); 359 struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec);
360 360
361 if (cx20442->control_data) { 361 if (cx20442->control_data) {
362 struct tty_struct *tty = cx20442->control_data; 362 struct tty_struct *tty = cx20442->control_data;
363 tty_hangup(tty); 363 tty_hangup(tty);
364 } 364 }
365 365
366 kfree(cx20442); 366 kfree(cx20442);
367 return 0; 367 return 0;
368 } 368 }
369 369
370 static const u8 cx20442_reg;
371
370 static struct snd_soc_codec_driver cx20442_codec_dev = { 372 static struct snd_soc_codec_driver cx20442_codec_dev = {
371 .probe = cx20442_codec_probe, 373 .probe = cx20442_codec_probe,
372 .remove = cx20442_codec_remove, 374 .remove = cx20442_codec_remove,
375 .reg_cache_default = &cx20442_reg,
373 .reg_cache_size = 1, 376 .reg_cache_size = 1,
374 .reg_word_size = sizeof(u8), 377 .reg_word_size = sizeof(u8),
375 .read = cx20442_read_reg_cache, 378 .read = cx20442_read_reg_cache,
376 .write = cx20442_write, 379 .write = cx20442_write,
377 }; 380 };
378 381
379 static int cx20442_platform_probe(struct platform_device *pdev) 382 static int cx20442_platform_probe(struct platform_device *pdev)
380 { 383 {
381 return snd_soc_register_codec(&pdev->dev, 384 return snd_soc_register_codec(&pdev->dev,
382 &cx20442_codec_dev, &cx20442_dai, 1); 385 &cx20442_codec_dev, &cx20442_dai, 1);
(...skipping 23 matching lines...) Expand all
406 static void __exit cx20442_exit(void) 409 static void __exit cx20442_exit(void)
407 { 410 {
408 platform_driver_unregister(&cx20442_platform_driver); 411 platform_driver_unregister(&cx20442_platform_driver);
409 } 412 }
410 module_exit(cx20442_exit); 413 module_exit(cx20442_exit);
411 414
412 MODULE_DESCRIPTION("ASoC CX20442-11 voice modem codec driver"); 415 MODULE_DESCRIPTION("ASoC CX20442-11 voice modem codec driver");
413 MODULE_AUTHOR("Janusz Krzysztofik"); 416 MODULE_AUTHOR("Janusz Krzysztofik");
414 MODULE_LICENSE("GPL"); 417 MODULE_LICENSE("GPL");
415 MODULE_ALIAS("platform:cx20442-codec"); 418 MODULE_ALIAS("platform:cx20442-codec");
OLDNEW
« no previous file with comments | « sound/soc/codecs/cs42l51.c ('k') | sound/soc/codecs/da7210.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698