aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/ac97_codec.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/sound/ac97_codec.h')
-rw-r--r--include/sound/ac97_codec.h169
1 files changed, 83 insertions, 86 deletions
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 7f0ca79d6c98..b0b3ea7b365e 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -391,65 +391,35 @@
391 * 391 *
392 */ 392 */
393 393
394typedef struct _snd_ac97_bus ac97_bus_t; 394struct snd_ac97;
395typedef struct _snd_ac97_bus_ops ac97_bus_ops_t;
396typedef struct _snd_ac97_template ac97_template_t;
397typedef struct _snd_ac97 ac97_t;
398
399enum ac97_pcm_cfg {
400 AC97_PCM_CFG_FRONT = 2,
401 AC97_PCM_CFG_REAR = 10, /* alias surround */
402 AC97_PCM_CFG_LFE = 11, /* center + lfe */
403 AC97_PCM_CFG_40 = 4, /* front + rear */
404 AC97_PCM_CFG_51 = 6, /* front + rear + center/lfe */
405 AC97_PCM_CFG_SPDIF = 20
406};
407
408/* PCM allocation */
409struct ac97_pcm {
410 ac97_bus_t *bus;
411 unsigned int stream: 1, /* stream type: 1 = capture */
412 exclusive: 1, /* exclusive mode, don't override with other pcms */
413 copy_flag: 1, /* lowlevel driver must fill all entries */
414 spdif: 1; /* spdif pcm */
415 unsigned short aslots; /* active slots */
416 unsigned int rates; /* available rates */
417 struct {
418 unsigned short slots; /* driver input: requested AC97 slot numbers */
419 unsigned short rslots[4]; /* allocated slots per codecs */
420 unsigned char rate_table[4];
421 ac97_t *codec[4]; /* allocated codecs */
422 } r[2]; /* 0 = standard rates, 1 = double rates */
423 unsigned long private_value; /* used by the hardware driver */
424};
425 395
426struct snd_ac97_build_ops { 396struct snd_ac97_build_ops {
427 int (*build_3d) (ac97_t *ac97); 397 int (*build_3d) (struct snd_ac97 *ac97);
428 int (*build_specific) (ac97_t *ac97); 398 int (*build_specific) (struct snd_ac97 *ac97);
429 int (*build_spdif) (ac97_t *ac97); 399 int (*build_spdif) (struct snd_ac97 *ac97);
430 int (*build_post_spdif) (ac97_t *ac97); 400 int (*build_post_spdif) (struct snd_ac97 *ac97);
431#ifdef CONFIG_PM 401#ifdef CONFIG_PM
432 void (*suspend) (ac97_t *ac97); 402 void (*suspend) (struct snd_ac97 *ac97);
433 void (*resume) (ac97_t *ac97); 403 void (*resume) (struct snd_ac97 *ac97);
434#endif 404#endif
435 void (*update_jacks) (ac97_t *ac97); /* for jack-sharing */ 405 void (*update_jacks) (struct snd_ac97 *ac97); /* for jack-sharing */
436}; 406};
437 407
438struct _snd_ac97_bus_ops { 408struct snd_ac97_bus_ops {
439 void (*reset) (ac97_t *ac97); 409 void (*reset) (struct snd_ac97 *ac97);
440 void (*write) (ac97_t *ac97, unsigned short reg, unsigned short val); 410 void (*write) (struct snd_ac97 *ac97, unsigned short reg, unsigned short val);
441 unsigned short (*read) (ac97_t *ac97, unsigned short reg); 411 unsigned short (*read) (struct snd_ac97 *ac97, unsigned short reg);
442 void (*wait) (ac97_t *ac97); 412 void (*wait) (struct snd_ac97 *ac97);
443 void (*init) (ac97_t *ac97); 413 void (*init) (struct snd_ac97 *ac97);
444}; 414};
445 415
446struct _snd_ac97_bus { 416struct snd_ac97_bus {
447 /* -- lowlevel (hardware) driver specific -- */ 417 /* -- lowlevel (hardware) driver specific -- */
448 ac97_bus_ops_t *ops; 418 struct snd_ac97_bus_ops *ops;
449 void *private_data; 419 void *private_data;
450 void (*private_free) (ac97_bus_t *bus); 420 void (*private_free) (struct snd_ac97_bus *bus);
451 /* --- */ 421 /* --- */
452 snd_card_t *card; 422 struct snd_card *card;
453 unsigned short num; /* bus number */ 423 unsigned short num; /* bus number */
454 unsigned short no_vra: 1, /* bridge doesn't support VRA */ 424 unsigned short no_vra: 1, /* bridge doesn't support VRA */
455 dra: 1, /* bridge supports double rate */ 425 dra: 1, /* bridge supports double rate */
@@ -459,13 +429,13 @@ struct _snd_ac97_bus {
459 unsigned short used_slots[2][4]; /* actually used PCM slots */ 429 unsigned short used_slots[2][4]; /* actually used PCM slots */
460 unsigned short pcms_count; /* count of PCMs */ 430 unsigned short pcms_count; /* count of PCMs */
461 struct ac97_pcm *pcms; 431 struct ac97_pcm *pcms;
462 ac97_t *codec[4]; 432 struct snd_ac97 *codec[4];
463 snd_info_entry_t *proc; 433 struct snd_info_entry *proc;
464}; 434};
465 435
466struct _snd_ac97_template { 436struct snd_ac97_template {
467 void *private_data; 437 void *private_data;
468 void (*private_free) (ac97_t *ac97); 438 void (*private_free) (struct snd_ac97 *ac97);
469 struct pci_dev *pci; /* assigned PCI device - used for quirks */ 439 struct pci_dev *pci; /* assigned PCI device - used for quirks */
470 unsigned short num; /* number of codec: 0 = primary, 1 = secondary */ 440 unsigned short num; /* number of codec: 0 = primary, 1 = secondary */
471 unsigned short addr; /* physical address of codec [0-3] */ 441 unsigned short addr; /* physical address of codec [0-3] */
@@ -474,16 +444,16 @@ struct _snd_ac97_template {
474 DECLARE_BITMAP(reg_accessed, 0x80); /* bit flags */ 444 DECLARE_BITMAP(reg_accessed, 0x80); /* bit flags */
475}; 445};
476 446
477struct _snd_ac97 { 447struct snd_ac97 {
478 /* -- lowlevel (hardware) driver specific -- */ 448 /* -- lowlevel (hardware) driver specific -- */
479 struct snd_ac97_build_ops * build_ops; 449 struct snd_ac97_build_ops * build_ops;
480 void *private_data; 450 void *private_data;
481 void (*private_free) (ac97_t *ac97); 451 void (*private_free) (struct snd_ac97 *ac97);
482 /* --- */ 452 /* --- */
483 ac97_bus_t *bus; 453 struct snd_ac97_bus *bus;
484 struct pci_dev *pci; /* assigned PCI device - used for quirks */ 454 struct pci_dev *pci; /* assigned PCI device - used for quirks */
485 snd_info_entry_t *proc; 455 struct snd_info_entry *proc;
486 snd_info_entry_t *proc_regs; 456 struct snd_info_entry *proc_regs;
487 unsigned short subsystem_vendor; 457 unsigned short subsystem_vendor;
488 unsigned short subsystem_device; 458 unsigned short subsystem_device;
489 struct semaphore reg_mutex; 459 struct semaphore reg_mutex;
@@ -517,43 +487,47 @@ struct _snd_ac97 {
517 struct device dev; 487 struct device dev;
518}; 488};
519 489
520#define to_ac97_t(d) container_of(d, struct _snd_ac97, dev) 490#define to_ac97_t(d) container_of(d, struct snd_ac97, dev)
521 491
522/* conditions */ 492/* conditions */
523static inline int ac97_is_audio(ac97_t * ac97) 493static inline int ac97_is_audio(struct snd_ac97 * ac97)
524{ 494{
525 return (ac97->scaps & AC97_SCAP_AUDIO); 495 return (ac97->scaps & AC97_SCAP_AUDIO);
526} 496}
527static inline int ac97_is_modem(ac97_t * ac97) 497static inline int ac97_is_modem(struct snd_ac97 * ac97)
528{ 498{
529 return (ac97->scaps & AC97_SCAP_MODEM); 499 return (ac97->scaps & AC97_SCAP_MODEM);
530} 500}
531static inline int ac97_is_rev22(ac97_t * ac97) 501static inline int ac97_is_rev22(struct snd_ac97 * ac97)
532{ 502{
533 return (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_22; 503 return (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_22;
534} 504}
535static inline int ac97_can_amap(ac97_t * ac97) 505static inline int ac97_can_amap(struct snd_ac97 * ac97)
536{ 506{
537 return (ac97->ext_id & AC97_EI_AMAP) != 0; 507 return (ac97->ext_id & AC97_EI_AMAP) != 0;
538} 508}
539static inline int ac97_can_spdif(ac97_t * ac97) 509static inline int ac97_can_spdif(struct snd_ac97 * ac97)
540{ 510{
541 return (ac97->ext_id & AC97_EI_SPDIF) != 0; 511 return (ac97->ext_id & AC97_EI_SPDIF) != 0;
542} 512}
543 513
544/* functions */ 514/* functions */
545int snd_ac97_bus(snd_card_t *card, int num, ac97_bus_ops_t *ops, void *private_data, ac97_bus_t **rbus); /* create new AC97 bus */ 515/* create new AC97 bus */
546int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97); /* create mixer controls */ 516int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops,
547const char *snd_ac97_get_short_name(ac97_t *ac97); 517 void *private_data, struct snd_ac97_bus **rbus);
548 518/* create mixer controls */
549void snd_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short value); 519int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
550unsigned short snd_ac97_read(ac97_t *ac97, unsigned short reg); 520 struct snd_ac97 **rac97);
551void snd_ac97_write_cache(ac97_t *ac97, unsigned short reg, unsigned short value); 521const char *snd_ac97_get_short_name(struct snd_ac97 *ac97);
552int snd_ac97_update(ac97_t *ac97, unsigned short reg, unsigned short value); 522
553int snd_ac97_update_bits(ac97_t *ac97, unsigned short reg, unsigned short mask, unsigned short value); 523void snd_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short value);
524unsigned short snd_ac97_read(struct snd_ac97 *ac97, unsigned short reg);
525void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned short value);
526int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value);
527int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value);
554#ifdef CONFIG_PM 528#ifdef CONFIG_PM
555void snd_ac97_suspend(ac97_t *ac97); 529void snd_ac97_suspend(struct snd_ac97 *ac97);
556void snd_ac97_resume(ac97_t *ac97); 530void snd_ac97_resume(struct snd_ac97 *ac97);
557#endif 531#endif
558 532
559/* quirk types */ 533/* quirk types */
@@ -567,6 +541,7 @@ enum {
567 AC97_TUNE_ALC_JACK, /* for Realtek, enable JACK detection */ 541 AC97_TUNE_ALC_JACK, /* for Realtek, enable JACK detection */
568 AC97_TUNE_INV_EAPD, /* inverted EAPD implementation */ 542 AC97_TUNE_INV_EAPD, /* inverted EAPD implementation */
569 AC97_TUNE_MUTE_LED, /* EAPD bit works as mute LED */ 543 AC97_TUNE_MUTE_LED, /* EAPD bit works as mute LED */
544 AC97_TUNE_HP_MUTE_LED, /* EAPD bit works as mute LED, use headphone control as master */
570}; 545};
571 546
572struct ac97_quirk { 547struct ac97_quirk {
@@ -578,24 +553,46 @@ struct ac97_quirk {
578 int type; /* quirk type above */ 553 int type; /* quirk type above */
579}; 554};
580 555
581int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, const char *override); 556int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, const char *override);
582int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned int rate); 557int snd_ac97_set_rate(struct snd_ac97 *ac97, int reg, unsigned int rate);
558
559/*
560 * PCM allocation
561 */
562
563enum ac97_pcm_cfg {
564 AC97_PCM_CFG_FRONT = 2,
565 AC97_PCM_CFG_REAR = 10, /* alias surround */
566 AC97_PCM_CFG_LFE = 11, /* center + lfe */
567 AC97_PCM_CFG_40 = 4, /* front + rear */
568 AC97_PCM_CFG_51 = 6, /* front + rear + center/lfe */
569 AC97_PCM_CFG_SPDIF = 20
570};
571
572struct ac97_pcm {
573 struct snd_ac97_bus *bus;
574 unsigned int stream: 1, /* stream type: 1 = capture */
575 exclusive: 1, /* exclusive mode, don't override with other pcms */
576 copy_flag: 1, /* lowlevel driver must fill all entries */
577 spdif: 1; /* spdif pcm */
578 unsigned short aslots; /* active slots */
579 unsigned int rates; /* available rates */
580 struct {
581 unsigned short slots; /* driver input: requested AC97 slot numbers */
582 unsigned short rslots[4]; /* allocated slots per codecs */
583 unsigned char rate_table[4];
584 struct snd_ac97 *codec[4]; /* allocated codecs */
585 } r[2]; /* 0 = standard rates, 1 = double rates */
586 unsigned long private_value; /* used by the hardware driver */
587};
583 588
584int snd_ac97_pcm_assign(ac97_bus_t *ac97, 589int snd_ac97_pcm_assign(struct snd_ac97_bus *ac97,
585 unsigned short pcms_count, 590 unsigned short pcms_count,
586 const struct ac97_pcm *pcms); 591 const struct ac97_pcm *pcms);
587int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate, 592int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate,
588 enum ac97_pcm_cfg cfg, unsigned short slots); 593 enum ac97_pcm_cfg cfg, unsigned short slots);
589int snd_ac97_pcm_close(struct ac97_pcm *pcm); 594int snd_ac97_pcm_close(struct ac97_pcm *pcm);
590int snd_ac97_pcm_double_rate_rules(snd_pcm_runtime_t *runtime); 595int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
591
592struct ac97_enum {
593 unsigned char reg;
594 unsigned char shift_l;
595 unsigned char shift_r;
596 unsigned short mask;
597 const char **texts;
598};
599 596
600/* ad hoc AC97 device driver access */ 597/* ad hoc AC97 device driver access */
601extern struct bus_type ac97_bus_type; 598extern struct bus_type ac97_bus_type;