| OLD | NEW |
| 1 /* | 1 /* |
| 2 * linux/sound/soc.h -- ALSA SoC Layer | 2 * linux/sound/soc.h -- ALSA SoC Layer |
| 3 * | 3 * |
| 4 * Author: Liam Girdwood | 4 * Author: Liam Girdwood |
| 5 * Created: Aug 11th 2005 | 5 * Created: Aug 11th 2005 |
| 6 * Copyright: Wolfson Microelectronics. PLC. | 6 * Copyright: Wolfson Microelectronics. PLC. |
| 7 * | 7 * |
| 8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License version 2 as | 9 * it under the terms of the GNU General Public License version 2 as |
| 10 * published by the Free Software Foundation. | 10 * published by the Free Software Foundation. |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 */ | 215 */ |
| 216 enum snd_soc_bias_level { | 216 enum snd_soc_bias_level { |
| 217 SND_SOC_BIAS_OFF, | 217 SND_SOC_BIAS_OFF, |
| 218 SND_SOC_BIAS_STANDBY, | 218 SND_SOC_BIAS_STANDBY, |
| 219 SND_SOC_BIAS_PREPARE, | 219 SND_SOC_BIAS_PREPARE, |
| 220 SND_SOC_BIAS_ON, | 220 SND_SOC_BIAS_ON, |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 struct snd_jack; | 223 struct snd_jack; |
| 224 struct snd_soc_card; | 224 struct snd_soc_card; |
| 225 struct snd_soc_device; | |
| 226 struct snd_soc_pcm_stream; | 225 struct snd_soc_pcm_stream; |
| 227 struct snd_soc_ops; | 226 struct snd_soc_ops; |
| 228 struct snd_soc_dai_mode; | |
| 229 struct snd_soc_pcm_runtime; | 227 struct snd_soc_pcm_runtime; |
| 230 struct snd_soc_dai; | 228 struct snd_soc_dai; |
| 231 struct snd_soc_dai_driver; | 229 struct snd_soc_dai_driver; |
| 232 struct snd_soc_platform; | 230 struct snd_soc_platform; |
| 233 struct snd_soc_dai_link; | 231 struct snd_soc_dai_link; |
| 234 struct snd_soc_platform_driver; | 232 struct snd_soc_platform_driver; |
| 235 struct snd_soc_codec; | 233 struct snd_soc_codec; |
| 236 struct snd_soc_codec_driver; | 234 struct snd_soc_codec_driver; |
| 237 struct soc_enum; | 235 struct soc_enum; |
| 238 struct snd_soc_ac97_ops; | |
| 239 struct snd_soc_jack; | 236 struct snd_soc_jack; |
| 237 struct snd_soc_jack_zone; |
| 240 struct snd_soc_jack_pin; | 238 struct snd_soc_jack_pin; |
| 239 struct snd_soc_cache_ops; |
| 240 #include <sound/soc-dapm.h> |
| 241 | 241 |
| 242 #ifdef CONFIG_GPIOLIB | 242 #ifdef CONFIG_GPIOLIB |
| 243 struct snd_soc_jack_gpio; | 243 struct snd_soc_jack_gpio; |
| 244 #endif | 244 #endif |
| 245 | 245 |
| 246 typedef int (*hw_write_t)(void *,const char* ,int); | 246 typedef int (*hw_write_t)(void *,const char* ,int); |
| 247 | 247 |
| 248 extern struct snd_ac97_bus_ops soc_ac97_ops; | 248 extern struct snd_ac97_bus_ops soc_ac97_ops; |
| 249 | 249 |
| 250 enum snd_soc_control_type { | 250 enum snd_soc_control_type { |
| 251 SND_SOC_CUSTOM, | 251 SND_SOC_CUSTOM, |
| 252 SND_SOC_I2C, | 252 SND_SOC_I2C, |
| 253 SND_SOC_SPI, | 253 SND_SOC_SPI, |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 enum snd_soc_compress_type { |
| 257 SND_SOC_FLAT_COMPRESSION = 1, |
| 258 SND_SOC_LZO_COMPRESSION, |
| 259 SND_SOC_RBTREE_COMPRESSION |
| 260 }; |
| 261 |
| 262 int snd_soc_register_card(struct snd_soc_card *card); |
| 263 int snd_soc_unregister_card(struct snd_soc_card *card); |
| 264 int snd_soc_suspend(struct device *dev); |
| 265 int snd_soc_resume(struct device *dev); |
| 266 int snd_soc_poweroff(struct device *dev); |
| 256 int snd_soc_register_platform(struct device *dev, | 267 int snd_soc_register_platform(struct device *dev, |
| 257 struct snd_soc_platform_driver *platform_drv); | 268 struct snd_soc_platform_driver *platform_drv); |
| 258 void snd_soc_unregister_platform(struct device *dev); | 269 void snd_soc_unregister_platform(struct device *dev); |
| 259 int snd_soc_register_codec(struct device *dev, | 270 int snd_soc_register_codec(struct device *dev, |
| 260 » » struct snd_soc_codec_driver *codec_drv, | 271 » » const struct snd_soc_codec_driver *codec_drv, |
| 261 struct snd_soc_dai_driver *dai_drv, int num_dai); | 272 struct snd_soc_dai_driver *dai_drv, int num_dai); |
| 262 void snd_soc_unregister_codec(struct device *dev); | 273 void snd_soc_unregister_codec(struct device *dev); |
| 263 int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg); | 274 int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, |
| 275 » » » » unsigned int reg); |
| 264 int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | 276 int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, |
| 265 int addr_bits, int data_bits, | 277 int addr_bits, int data_bits, |
| 266 enum snd_soc_control_type control); | 278 enum snd_soc_control_type control); |
| 279 int snd_soc_cache_sync(struct snd_soc_codec *codec); |
| 280 int snd_soc_cache_init(struct snd_soc_codec *codec); |
| 281 int snd_soc_cache_exit(struct snd_soc_codec *codec); |
| 282 int snd_soc_cache_write(struct snd_soc_codec *codec, |
| 283 unsigned int reg, unsigned int value); |
| 284 int snd_soc_cache_read(struct snd_soc_codec *codec, |
| 285 unsigned int reg, unsigned int *value); |
| 286 int snd_soc_default_volatile_register(struct snd_soc_codec *codec, |
| 287 unsigned int reg); |
| 288 int snd_soc_default_readable_register(struct snd_soc_codec *codec, |
| 289 unsigned int reg); |
| 267 | 290 |
| 268 /* Utility functions to get clock rates from various things */ | 291 /* Utility functions to get clock rates from various things */ |
| 269 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); | 292 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); |
| 270 int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); | 293 int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params); |
| 271 int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots); | 294 int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots); |
| 272 int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms); | 295 int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms); |
| 273 | 296 |
| 274 /* set runtime hw params */ | 297 /* set runtime hw params */ |
| 275 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, | 298 int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, |
| 276 const struct snd_pcm_hardware *hw); | 299 const struct snd_pcm_hardware *hw); |
| 277 | 300 |
| 278 /* Jack reporting */ | 301 /* Jack reporting */ |
| 279 int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, | 302 int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, |
| 280 struct snd_soc_jack *jack); | 303 struct snd_soc_jack *jack); |
| 281 void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); | 304 void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); |
| 282 int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, | 305 int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, |
| 283 struct snd_soc_jack_pin *pins); | 306 struct snd_soc_jack_pin *pins); |
| 284 void snd_soc_jack_notifier_register(struct snd_soc_jack *jack, | 307 void snd_soc_jack_notifier_register(struct snd_soc_jack *jack, |
| 285 struct notifier_block *nb); | 308 struct notifier_block *nb); |
| 286 void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, | 309 void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack, |
| 287 struct notifier_block *nb); | 310 struct notifier_block *nb); |
| 311 int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count, |
| 312 struct snd_soc_jack_zone *zones); |
| 313 int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage); |
| 288 #ifdef CONFIG_GPIOLIB | 314 #ifdef CONFIG_GPIOLIB |
| 289 int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | 315 int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, |
| 290 struct snd_soc_jack_gpio *gpios); | 316 struct snd_soc_jack_gpio *gpios); |
| 291 void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, | 317 void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, |
| 292 struct snd_soc_jack_gpio *gpios); | 318 struct snd_soc_jack_gpio *gpios); |
| 293 #endif | 319 #endif |
| 294 | 320 |
| 295 /* codec register bit access */ | 321 /* codec register bit access */ |
| 296 int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, | 322 int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, |
| 297 unsigned int mask, unsigned int value); | 323 unsigned int mask, unsigned int value); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 int snd_soc_limit_volume(struct snd_soc_codec *codec, | 374 int snd_soc_limit_volume(struct snd_soc_codec *codec, |
| 349 const char *name, int max); | 375 const char *name, int max); |
| 350 int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol, | 376 int snd_soc_info_volsw_2r_sx(struct snd_kcontrol *kcontrol, |
| 351 struct snd_ctl_elem_info *uinfo); | 377 struct snd_ctl_elem_info *uinfo); |
| 352 int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol, | 378 int snd_soc_get_volsw_2r_sx(struct snd_kcontrol *kcontrol, |
| 353 struct snd_ctl_elem_value *ucontrol); | 379 struct snd_ctl_elem_value *ucontrol); |
| 354 int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, | 380 int snd_soc_put_volsw_2r_sx(struct snd_kcontrol *kcontrol, |
| 355 struct snd_ctl_elem_value *ucontrol); | 381 struct snd_ctl_elem_value *ucontrol); |
| 356 | 382 |
| 357 /** | 383 /** |
| 384 * struct snd_soc_reg_access - Describes whether a given register is |
| 385 * readable, writable or volatile. |
| 386 * |
| 387 * @reg: the register number |
| 388 * @read: whether this register is readable |
| 389 * @write: whether this register is writable |
| 390 * @vol: whether this register is volatile |
| 391 */ |
| 392 struct snd_soc_reg_access { |
| 393 u16 reg; |
| 394 u16 read; |
| 395 u16 write; |
| 396 u16 vol; |
| 397 }; |
| 398 |
| 399 /** |
| 358 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection | 400 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection |
| 359 * | 401 * |
| 360 * @pin: name of the pin to update | 402 * @pin: name of the pin to update |
| 361 * @mask: bits to check for in reported jack status | 403 * @mask: bits to check for in reported jack status |
| 362 * @invert: if non-zero then pin is enabled when status is not reported | 404 * @invert: if non-zero then pin is enabled when status is not reported |
| 363 */ | 405 */ |
| 364 struct snd_soc_jack_pin { | 406 struct snd_soc_jack_pin { |
| 365 struct list_head list; | 407 struct list_head list; |
| 366 const char *pin; | 408 const char *pin; |
| 367 int mask; | 409 int mask; |
| 368 bool invert; | 410 bool invert; |
| 369 }; | 411 }; |
| 370 | 412 |
| 371 /** | 413 /** |
| 414 * struct snd_soc_jack_zone - Describes voltage zones of jack detection |
| 415 * |
| 416 * @min_mv: start voltage in mv |
| 417 * @max_mv: end voltage in mv |
| 418 * @jack_type: type of jack that is expected for this voltage |
| 419 * @debounce_time: debounce_time for jack, codec driver should wait for this |
| 420 * duration before reading the adc for voltages |
| 421 * @:list: list container |
| 422 */ |
| 423 struct snd_soc_jack_zone { |
| 424 unsigned int min_mv; |
| 425 unsigned int max_mv; |
| 426 unsigned int jack_type; |
| 427 unsigned int debounce_time; |
| 428 struct list_head list; |
| 429 }; |
| 430 |
| 431 /** |
| 372 * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection | 432 * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection |
| 373 * | 433 * |
| 374 * @gpio: gpio number | 434 * @gpio: gpio number |
| 375 * @name: gpio name | 435 * @name: gpio name |
| 376 * @report: value to report when jack detected | 436 * @report: value to report when jack detected |
| 377 * @invert: report presence in low state | 437 * @invert: report presence in low state |
| 378 * @debouce_time: debouce time in ms | 438 * @debouce_time: debouce time in ms |
| 379 */ | 439 */ |
| 380 #ifdef CONFIG_GPIOLIB | 440 #ifdef CONFIG_GPIOLIB |
| 381 struct snd_soc_jack_gpio { | 441 struct snd_soc_jack_gpio { |
| 382 unsigned int gpio; | 442 unsigned int gpio; |
| 383 const char *name; | 443 const char *name; |
| 384 int report; | 444 int report; |
| 385 int invert; | 445 int invert; |
| 386 int debounce_time; | 446 int debounce_time; |
| 387 struct snd_soc_jack *jack; | 447 struct snd_soc_jack *jack; |
| 388 struct delayed_work work; | 448 struct delayed_work work; |
| 389 | 449 |
| 390 int (*jack_status_check)(void); | 450 int (*jack_status_check)(void); |
| 391 }; | 451 }; |
| 392 #endif | 452 #endif |
| 393 | 453 |
| 394 struct snd_soc_jack { | 454 struct snd_soc_jack { |
| 395 struct snd_jack *jack; | 455 struct snd_jack *jack; |
| 396 struct snd_soc_codec *codec; | 456 struct snd_soc_codec *codec; |
| 397 struct list_head pins; | 457 struct list_head pins; |
| 398 int status; | 458 int status; |
| 399 struct blocking_notifier_head notifier; | 459 struct blocking_notifier_head notifier; |
| 460 struct list_head jack_zones; |
| 400 }; | 461 }; |
| 401 | 462 |
| 402 /* SoC PCM stream information */ | 463 /* SoC PCM stream information */ |
| 403 struct snd_soc_pcm_stream { | 464 struct snd_soc_pcm_stream { |
| 404 const char *stream_name; | 465 const char *stream_name; |
| 405 u64 formats; /* SNDRV_PCM_FMTBIT_* */ | 466 u64 formats; /* SNDRV_PCM_FMTBIT_* */ |
| 406 unsigned int rates; /* SNDRV_PCM_RATE_* */ | 467 unsigned int rates; /* SNDRV_PCM_RATE_* */ |
| 407 unsigned int rate_min; /* min rate */ | 468 unsigned int rate_min; /* min rate */ |
| 408 unsigned int rate_max; /* max rate */ | 469 unsigned int rate_max; /* max rate */ |
| 409 unsigned int channels_min; /* min channels */ | 470 unsigned int channels_min; /* min channels */ |
| 410 unsigned int channels_max; /* max channels */ | 471 unsigned int channels_max; /* max channels */ |
| 411 }; | 472 }; |
| 412 | 473 |
| 413 /* SoC audio ops */ | 474 /* SoC audio ops */ |
| 414 struct snd_soc_ops { | 475 struct snd_soc_ops { |
| 415 int (*startup)(struct snd_pcm_substream *); | 476 int (*startup)(struct snd_pcm_substream *); |
| 416 void (*shutdown)(struct snd_pcm_substream *); | 477 void (*shutdown)(struct snd_pcm_substream *); |
| 417 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *)
; | 478 int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *)
; |
| 418 int (*hw_free)(struct snd_pcm_substream *); | 479 int (*hw_free)(struct snd_pcm_substream *); |
| 419 int (*prepare)(struct snd_pcm_substream *); | 480 int (*prepare)(struct snd_pcm_substream *); |
| 420 int (*trigger)(struct snd_pcm_substream *, int); | 481 int (*trigger)(struct snd_pcm_substream *, int); |
| 421 }; | 482 }; |
| 422 | 483 |
| 484 /* SoC cache ops */ |
| 485 struct snd_soc_cache_ops { |
| 486 const char *name; |
| 487 enum snd_soc_compress_type id; |
| 488 int (*init)(struct snd_soc_codec *codec); |
| 489 int (*exit)(struct snd_soc_codec *codec); |
| 490 int (*read)(struct snd_soc_codec *codec, unsigned int reg, |
| 491 unsigned int *value); |
| 492 int (*write)(struct snd_soc_codec *codec, unsigned int reg, |
| 493 unsigned int value); |
| 494 int (*sync)(struct snd_soc_codec *codec); |
| 495 }; |
| 496 |
| 423 /* SoC Audio Codec device */ | 497 /* SoC Audio Codec device */ |
| 424 struct snd_soc_codec { | 498 struct snd_soc_codec { |
| 425 const char *name; | 499 const char *name; |
| 500 const char *name_prefix; |
| 426 int id; | 501 int id; |
| 427 struct device *dev; | 502 struct device *dev; |
| 428 » struct snd_soc_codec_driver *driver; | 503 » const struct snd_soc_codec_driver *driver; |
| 429 | 504 |
| 430 struct mutex mutex; | 505 struct mutex mutex; |
| 431 struct snd_soc_card *card; | 506 struct snd_soc_card *card; |
| 432 struct list_head list; | 507 struct list_head list; |
| 433 struct list_head card_list; | 508 struct list_head card_list; |
| 434 int num_dai; | 509 int num_dai; |
| 510 enum snd_soc_compress_type compress_type; |
| 511 size_t reg_size; /* reg_cache_size * reg_word_size */ |
| 512 int (*volatile_register)(struct snd_soc_codec *, unsigned int); |
| 513 int (*readable_register)(struct snd_soc_codec *, unsigned int); |
| 435 | 514 |
| 436 /* runtime */ | 515 /* runtime */ |
| 437 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ | 516 struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ |
| 438 unsigned int active; | 517 unsigned int active; |
| 439 » unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */ | 518 » unsigned int cache_bypass:1; /* Suppress access to the cache */ |
| 440 » unsigned int cache_only:1; /* Suppress writes to hardware */ | |
| 441 » unsigned int cache_sync:1; /* Cache needs to be synced to hardware */ | |
| 442 unsigned int suspended:1; /* Codec is in suspend PM state */ | 519 unsigned int suspended:1; /* Codec is in suspend PM state */ |
| 443 unsigned int probed:1; /* Codec has been probed */ | 520 unsigned int probed:1; /* Codec has been probed */ |
| 444 unsigned int ac97_registered:1; /* Codec has been AC97 registered */ | 521 unsigned int ac97_registered:1; /* Codec has been AC97 registered */ |
| 445 unsigned int ac97_created:1; /* Codec has been created by SoC */ | 522 unsigned int ac97_created:1; /* Codec has been created by SoC */ |
| 446 unsigned int sysfs_registered:1; /* codec has been sysfs registered */ | 523 unsigned int sysfs_registered:1; /* codec has been sysfs registered */ |
| 524 unsigned int cache_init:1; /* codec cache has been initialized */ |
| 525 u32 cache_only; /* Suppress writes to hardware */ |
| 526 u32 cache_sync; /* Cache needs to be synced to hardware */ |
| 447 | 527 |
| 448 /* codec IO */ | 528 /* codec IO */ |
| 449 void *control_data; /* codec control (i2c/3wire) data */ | 529 void *control_data; /* codec control (i2c/3wire) data */ |
| 450 hw_write_t hw_write; | 530 hw_write_t hw_write; |
| 451 unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); | 531 unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); |
| 532 unsigned int (*read)(struct snd_soc_codec *, unsigned int); |
| 533 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); |
| 452 void *reg_cache; | 534 void *reg_cache; |
| 535 const void *reg_def_copy; |
| 536 const struct snd_soc_cache_ops *cache_ops; |
| 537 struct mutex cache_rw_mutex; |
| 453 | 538 |
| 454 /* dapm */ | 539 /* dapm */ |
| 455 » u32 pop_time; | 540 » struct snd_soc_dapm_context dapm; |
| 456 » struct list_head dapm_widgets; | |
| 457 » struct list_head dapm_paths; | |
| 458 » enum snd_soc_bias_level bias_level; | |
| 459 » enum snd_soc_bias_level suspend_bias_level; | |
| 460 » struct delayed_work delayed_work; | |
| 461 | 541 |
| 462 #ifdef CONFIG_DEBUG_FS | 542 #ifdef CONFIG_DEBUG_FS |
| 463 struct dentry *debugfs_codec_root; | 543 struct dentry *debugfs_codec_root; |
| 464 struct dentry *debugfs_reg; | 544 struct dentry *debugfs_reg; |
| 465 struct dentry *debugfs_pop_time; | |
| 466 struct dentry *debugfs_dapm; | 545 struct dentry *debugfs_dapm; |
| 467 #endif | 546 #endif |
| 468 }; | 547 }; |
| 469 | 548 |
| 470 /* codec driver */ | 549 /* codec driver */ |
| 471 struct snd_soc_codec_driver { | 550 struct snd_soc_codec_driver { |
| 472 | 551 |
| 473 /* driver ops */ | 552 /* driver ops */ |
| 474 int (*probe)(struct snd_soc_codec *); | 553 int (*probe)(struct snd_soc_codec *); |
| 475 int (*remove)(struct snd_soc_codec *); | 554 int (*remove)(struct snd_soc_codec *); |
| 476 int (*suspend)(struct snd_soc_codec *, | 555 int (*suspend)(struct snd_soc_codec *, |
| 477 pm_message_t state); | 556 pm_message_t state); |
| 478 int (*resume)(struct snd_soc_codec *); | 557 int (*resume)(struct snd_soc_codec *); |
| 479 | 558 |
| 480 /* codec IO */ | 559 /* codec IO */ |
| 481 unsigned int (*read)(struct snd_soc_codec *, unsigned int); | 560 unsigned int (*read)(struct snd_soc_codec *, unsigned int); |
| 482 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | 561 int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); |
| 483 int (*display_register)(struct snd_soc_codec *, char *, | 562 int (*display_register)(struct snd_soc_codec *, char *, |
| 484 size_t, unsigned int); | 563 size_t, unsigned int); |
| 485 » int (*volatile_register)(unsigned int); | 564 » int (*volatile_register)(struct snd_soc_codec *, unsigned int); |
| 486 » int (*readable_register)(unsigned int); | 565 » int (*readable_register)(struct snd_soc_codec *, unsigned int); |
| 487 short reg_cache_size; | 566 short reg_cache_size; |
| 488 short reg_cache_step; | 567 short reg_cache_step; |
| 489 short reg_word_size; | 568 short reg_word_size; |
| 490 const void *reg_cache_default; | 569 const void *reg_cache_default; |
| 570 short reg_access_size; |
| 571 const struct snd_soc_reg_access *reg_access_default; |
| 572 enum snd_soc_compress_type compress_type; |
| 491 | 573 |
| 492 /* codec bias level */ | 574 /* codec bias level */ |
| 493 int (*set_bias_level)(struct snd_soc_codec *, | 575 int (*set_bias_level)(struct snd_soc_codec *, |
| 494 enum snd_soc_bias_level level); | 576 enum snd_soc_bias_level level); |
| 577 |
| 578 void (*seq_notifier)(struct snd_soc_dapm_context *, |
| 579 enum snd_soc_dapm_type, int); |
| 495 }; | 580 }; |
| 496 | 581 |
| 497 /* SoC platform interface */ | 582 /* SoC platform interface */ |
| 498 struct snd_soc_platform_driver { | 583 struct snd_soc_platform_driver { |
| 499 | 584 |
| 500 int (*probe)(struct snd_soc_platform *); | 585 int (*probe)(struct snd_soc_platform *); |
| 501 int (*remove)(struct snd_soc_platform *); | 586 int (*remove)(struct snd_soc_platform *); |
| 502 int (*suspend)(struct snd_soc_dai *dai); | 587 int (*suspend)(struct snd_soc_dai *dai); |
| 503 int (*resume)(struct snd_soc_dai *dai); | 588 int (*resume)(struct snd_soc_dai *dai); |
| 504 | 589 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 /* Symmetry requirements */ | 632 /* Symmetry requirements */ |
| 548 unsigned int symmetric_rates:1; | 633 unsigned int symmetric_rates:1; |
| 549 | 634 |
| 550 /* codec/machine specific init - e.g. add machine controls */ | 635 /* codec/machine specific init - e.g. add machine controls */ |
| 551 int (*init)(struct snd_soc_pcm_runtime *rtd); | 636 int (*init)(struct snd_soc_pcm_runtime *rtd); |
| 552 | 637 |
| 553 /* machine stream operations */ | 638 /* machine stream operations */ |
| 554 struct snd_soc_ops *ops; | 639 struct snd_soc_ops *ops; |
| 555 }; | 640 }; |
| 556 | 641 |
| 642 struct snd_soc_codec_conf { |
| 643 const char *dev_name; |
| 644 |
| 645 /* |
| 646 * optional map of kcontrol, widget and path name prefixes that are |
| 647 * associated per device |
| 648 */ |
| 649 const char *name_prefix; |
| 650 |
| 651 /* |
| 652 * set this to the desired compression type if you want to |
| 653 * override the one supplied in codec->driver->compress_type |
| 654 */ |
| 655 enum snd_soc_compress_type compress_type; |
| 656 }; |
| 657 |
| 658 struct snd_soc_aux_dev { |
| 659 const char *name; /* Codec name */ |
| 660 const char *codec_name; /* for multi-codec */ |
| 661 |
| 662 /* codec/machine specific init - e.g. add machine controls */ |
| 663 int (*init)(struct snd_soc_dapm_context *dapm); |
| 664 }; |
| 665 |
| 557 /* SoC card */ | 666 /* SoC card */ |
| 558 struct snd_soc_card { | 667 struct snd_soc_card { |
| 559 const char *name; | 668 const char *name; |
| 560 struct device *dev; | 669 struct device *dev; |
| 561 struct snd_card *snd_card; | 670 struct snd_card *snd_card; |
| 562 struct module *owner; | 671 struct module *owner; |
| 563 | 672 |
| 564 struct list_head list; | 673 struct list_head list; |
| 565 struct mutex mutex; | 674 struct mutex mutex; |
| 566 | 675 |
| 567 bool instantiated; | 676 bool instantiated; |
| 568 | 677 |
| 569 » int (*probe)(struct platform_device *pdev); | 678 » int (*probe)(struct snd_soc_card *card); |
| 570 » int (*remove)(struct platform_device *pdev); | 679 » int (*remove)(struct snd_soc_card *card); |
| 571 | 680 |
| 572 /* the pre and post PM functions are used to do any PM work before and | 681 /* the pre and post PM functions are used to do any PM work before and |
| 573 * after the codec and DAI's do any PM work. */ | 682 * after the codec and DAI's do any PM work. */ |
| 574 » int (*suspend_pre)(struct platform_device *pdev, pm_message_t state); | 683 » int (*suspend_pre)(struct snd_soc_card *card); |
| 575 » int (*suspend_post)(struct platform_device *pdev, pm_message_t state); | 684 » int (*suspend_post)(struct snd_soc_card *card); |
| 576 » int (*resume_pre)(struct platform_device *pdev); | 685 » int (*resume_pre)(struct snd_soc_card *card); |
| 577 » int (*resume_post)(struct platform_device *pdev); | 686 » int (*resume_post)(struct snd_soc_card *card); |
| 578 | 687 |
| 579 /* callbacks */ | 688 /* callbacks */ |
| 580 int (*set_bias_level)(struct snd_soc_card *, | 689 int (*set_bias_level)(struct snd_soc_card *, |
| 581 enum snd_soc_bias_level level); | 690 enum snd_soc_bias_level level); |
| 691 int (*set_bias_level_post)(struct snd_soc_card *, |
| 692 enum snd_soc_bias_level level); |
| 582 | 693 |
| 583 long pmdown_time; | 694 long pmdown_time; |
| 584 | 695 |
| 585 /* CPU <--> Codec DAI links */ | 696 /* CPU <--> Codec DAI links */ |
| 586 struct snd_soc_dai_link *dai_link; | 697 struct snd_soc_dai_link *dai_link; |
| 587 int num_links; | 698 int num_links; |
| 588 struct snd_soc_pcm_runtime *rtd; | 699 struct snd_soc_pcm_runtime *rtd; |
| 589 int num_rtd; | 700 int num_rtd; |
| 590 | 701 |
| 702 /* optional codec specific configuration */ |
| 703 struct snd_soc_codec_conf *codec_conf; |
| 704 int num_configs; |
| 705 |
| 706 /* |
| 707 * optional auxiliary devices such as amplifiers or codecs with DAI |
| 708 * link unused |
| 709 */ |
| 710 struct snd_soc_aux_dev *aux_dev; |
| 711 int num_aux_devs; |
| 712 struct snd_soc_pcm_runtime *rtd_aux; |
| 713 int num_aux_rtd; |
| 714 |
| 591 struct work_struct deferred_resume_work; | 715 struct work_struct deferred_resume_work; |
| 592 | 716 |
| 593 /* lists of probed devices belonging to this card */ | 717 /* lists of probed devices belonging to this card */ |
| 594 struct list_head codec_dev_list; | 718 struct list_head codec_dev_list; |
| 595 struct list_head platform_dev_list; | 719 struct list_head platform_dev_list; |
| 596 struct list_head dai_dev_list; | 720 struct list_head dai_dev_list; |
| 721 |
| 722 struct list_head widgets; |
| 723 struct list_head paths; |
| 724 struct list_head dapm_list; |
| 725 |
| 726 #ifdef CONFIG_DEBUG_FS |
| 727 struct dentry *debugfs_card_root; |
| 728 struct dentry *debugfs_pop_time; |
| 729 #endif |
| 730 u32 pop_time; |
| 731 |
| 732 void *drvdata; |
| 597 }; | 733 }; |
| 598 | 734 |
| 599 /* SoC machine DAI configuration, glues a codec and cpu DAI together */ | 735 /* SoC machine DAI configuration, glues a codec and cpu DAI together */ |
| 600 struct snd_soc_pcm_runtime { | 736 struct snd_soc_pcm_runtime { |
| 601 struct device dev; | 737 struct device dev; |
| 602 struct snd_soc_card *card; | 738 struct snd_soc_card *card; |
| 603 struct snd_soc_dai_link *dai_link; | 739 struct snd_soc_dai_link *dai_link; |
| 604 | 740 |
| 605 unsigned int complete:1; | 741 unsigned int complete:1; |
| 606 unsigned int dev_registered:1; | 742 unsigned int dev_registered:1; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 632 unsigned char shift_l; | 768 unsigned char shift_l; |
| 633 unsigned char shift_r; | 769 unsigned char shift_r; |
| 634 unsigned int max; | 770 unsigned int max; |
| 635 unsigned int mask; | 771 unsigned int mask; |
| 636 const char **texts; | 772 const char **texts; |
| 637 const unsigned int *values; | 773 const unsigned int *values; |
| 638 void *dapm; | 774 void *dapm; |
| 639 }; | 775 }; |
| 640 | 776 |
| 641 /* codec IO */ | 777 /* codec IO */ |
| 642 static inline unsigned int snd_soc_read(struct snd_soc_codec *codec, | 778 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); |
| 643 » » » » » unsigned int reg) | 779 unsigned int snd_soc_write(struct snd_soc_codec *codec, |
| 780 » » » unsigned int reg, unsigned int val); |
| 781 |
| 782 /* device driver data */ |
| 783 |
| 784 static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card, |
| 785 » » void *data) |
| 644 { | 786 { |
| 645 » return codec->driver->read(codec, reg); | 787 » card->drvdata = data; |
| 646 } | 788 } |
| 647 | 789 |
| 648 static inline unsigned int snd_soc_write(struct snd_soc_codec *codec, | 790 static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card) |
| 649 » » » » » unsigned int reg, unsigned int val) | |
| 650 { | 791 { |
| 651 » return codec->driver->write(codec, reg, val); | 792 » return card->drvdata; |
| 652 } | 793 } |
| 653 | 794 |
| 654 /* device driver data */ | |
| 655 | |
| 656 static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, | 795 static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec, |
| 657 void *data) | 796 void *data) |
| 658 { | 797 { |
| 659 dev_set_drvdata(codec->dev, data); | 798 dev_set_drvdata(codec->dev, data); |
| 660 } | 799 } |
| 661 | 800 |
| 662 static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) | 801 static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec) |
| 663 { | 802 { |
| 664 return dev_get_drvdata(codec->dev); | 803 return dev_get_drvdata(codec->dev); |
| 665 } | 804 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 679 void *data) | 818 void *data) |
| 680 { | 819 { |
| 681 dev_set_drvdata(&rtd->dev, data); | 820 dev_set_drvdata(&rtd->dev, data); |
| 682 } | 821 } |
| 683 | 822 |
| 684 static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd) | 823 static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd) |
| 685 { | 824 { |
| 686 return dev_get_drvdata(&rtd->dev); | 825 return dev_get_drvdata(&rtd->dev); |
| 687 } | 826 } |
| 688 | 827 |
| 828 static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) |
| 829 { |
| 830 INIT_LIST_HEAD(&card->dai_dev_list); |
| 831 INIT_LIST_HEAD(&card->codec_dev_list); |
| 832 INIT_LIST_HEAD(&card->platform_dev_list); |
| 833 INIT_LIST_HEAD(&card->widgets); |
| 834 INIT_LIST_HEAD(&card->paths); |
| 835 INIT_LIST_HEAD(&card->dapm_list); |
| 836 } |
| 837 |
| 689 #include <sound/soc-dai.h> | 838 #include <sound/soc-dai.h> |
| 690 | 839 |
| 691 #ifdef CONFIG_DEBUG_FS | 840 #ifdef CONFIG_DEBUG_FS |
| 692 extern struct dentry *asoc_debugfs_root; | 841 extern struct dentry *snd_soc_debugfs_root; |
| 693 #endif | 842 #endif |
| 694 | 843 |
| 844 extern const struct dev_pm_ops snd_soc_pm_ops; |
| 845 |
| 695 #endif | 846 #endif |
| OLD | NEW |