diff options
Diffstat (limited to 'sound/i2c/l3/uda1341.c')
| -rw-r--r-- | sound/i2c/l3/uda1341.c | 69 |
1 files changed, 38 insertions, 31 deletions
diff --git a/sound/i2c/l3/uda1341.c b/sound/i2c/l3/uda1341.c index bc7eb23e615f..746500e06950 100644 --- a/sound/i2c/l3/uda1341.c +++ b/sound/i2c/l3/uda1341.c | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | * 2002-05-12 Tomas Kasparek another code cleanup | 17 | * 2002-05-12 Tomas Kasparek another code cleanup |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | /* $Id: uda1341.c,v 1.17 2005/11/17 10:25:22 tiwai Exp $ */ | 20 | /* $Id: uda1341.c,v 1.18 2005/11/17 14:17:21 tiwai Exp $ */ |
| 21 | 21 | ||
| 22 | #include <sound/driver.h> | 22 | #include <sound/driver.h> |
| 23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
| @@ -140,15 +140,13 @@ static const char ** uda1341_enum_names[] = { | |||
| 140 | 140 | ||
| 141 | typedef int uda1341_cfg[CMD_LAST]; | 141 | typedef int uda1341_cfg[CMD_LAST]; |
| 142 | 142 | ||
| 143 | typedef struct uda1341 uda1341_t; | ||
| 144 | |||
| 145 | struct uda1341 { | 143 | struct uda1341 { |
| 146 | int (*write) (struct l3_client *uda1341, unsigned short reg, unsigned short val); | 144 | int (*write) (struct l3_client *uda1341, unsigned short reg, unsigned short val); |
| 147 | int (*read) (struct l3_client *uda1341, unsigned short reg); | 145 | int (*read) (struct l3_client *uda1341, unsigned short reg); |
| 148 | unsigned char regs[uda1341_reg_last]; | 146 | unsigned char regs[uda1341_reg_last]; |
| 149 | int active; | 147 | int active; |
| 150 | spinlock_t reg_lock; | 148 | spinlock_t reg_lock; |
| 151 | snd_card_t *card; | 149 | struct snd_card *card; |
| 152 | uda1341_cfg cfg; | 150 | uda1341_cfg cfg; |
| 153 | #ifdef CONFIG_PM | 151 | #ifdef CONFIG_PM |
| 154 | unsigned char suspend_regs[uda1341_reg_last]; | 152 | unsigned char suspend_regs[uda1341_reg_last]; |
| @@ -429,8 +427,8 @@ static const char *peak_value[] = { | |||
| 429 | "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB", | 427 | "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB", |
| 430 | }; | 428 | }; |
| 431 | 429 | ||
| 432 | static void snd_uda1341_proc_read(snd_info_entry_t *entry, | 430 | static void snd_uda1341_proc_read(struct snd_info_entry *entry, |
| 433 | snd_info_buffer_t * buffer) | 431 | struct snd_info_buffer *buffer) |
| 434 | { | 432 | { |
| 435 | struct l3_client *clnt = entry->private_data; | 433 | struct l3_client *clnt = entry->private_data; |
| 436 | struct uda1341 *uda = clnt->driver_data; | 434 | struct uda1341 *uda = clnt->driver_data; |
| @@ -494,8 +492,8 @@ static void snd_uda1341_proc_read(snd_info_entry_t *entry, | |||
| 494 | snd_iprintf(buffer, "Input Amp. Gain ch 2: %s dB\n", ig_small_value[uda->cfg[CMD_IG]]); | 492 | snd_iprintf(buffer, "Input Amp. Gain ch 2: %s dB\n", ig_small_value[uda->cfg[CMD_IG]]); |
| 495 | } | 493 | } |
| 496 | 494 | ||
| 497 | static void snd_uda1341_proc_regs_read(snd_info_entry_t *entry, | 495 | static void snd_uda1341_proc_regs_read(struct snd_info_entry *entry, |
| 498 | snd_info_buffer_t * buffer) | 496 | struct snd_info_buffer *buffer) |
| 499 | { | 497 | { |
| 500 | struct l3_client *clnt = entry->private_data; | 498 | struct l3_client *clnt = entry->private_data; |
| 501 | struct uda1341 *uda = clnt->driver_data; | 499 | struct uda1341 *uda = clnt->driver_data; |
| @@ -514,9 +512,9 @@ static void snd_uda1341_proc_regs_read(snd_info_entry_t *entry, | |||
| 514 | } | 512 | } |
| 515 | #endif /* CONFIG_PROC_FS */ | 513 | #endif /* CONFIG_PROC_FS */ |
| 516 | 514 | ||
| 517 | static void __devinit snd_uda1341_proc_init(snd_card_t *card, struct l3_client *clnt) | 515 | static void __devinit snd_uda1341_proc_init(struct snd_card *card, struct l3_client *clnt) |
| 518 | { | 516 | { |
| 519 | snd_info_entry_t *entry; | 517 | struct snd_info_entry *entry; |
| 520 | 518 | ||
| 521 | if (! snd_card_proc_new(card, "uda1341", &entry)) | 519 | if (! snd_card_proc_new(card, "uda1341", &entry)) |
| 522 | snd_info_set_text_ops(entry, clnt, 1024, snd_uda1341_proc_read); | 520 | snd_info_set_text_ops(entry, clnt, 1024, snd_uda1341_proc_read); |
| @@ -536,7 +534,8 @@ static void __devinit snd_uda1341_proc_init(snd_card_t *card, struct l3_client * | |||
| 536 | .private_value = where | (reg << 5) | (shift << 9) | (mask << 12) | (invert << 18) \ | 534 | .private_value = where | (reg << 5) | (shift << 9) | (mask << 12) | (invert << 18) \ |
| 537 | } | 535 | } |
| 538 | 536 | ||
| 539 | static int snd_uda1341_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 537 | static int snd_uda1341_info_single(struct snd_kcontrol *kcontrol, |
| 538 | struct snd_ctl_elem_info *uinfo) | ||
| 540 | { | 539 | { |
| 541 | int mask = (kcontrol->private_value >> 12) & 63; | 540 | int mask = (kcontrol->private_value >> 12) & 63; |
| 542 | 541 | ||
| @@ -547,10 +546,11 @@ static int snd_uda1341_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t | |||
| 547 | return 0; | 546 | return 0; |
| 548 | } | 547 | } |
| 549 | 548 | ||
| 550 | static int snd_uda1341_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 549 | static int snd_uda1341_get_single(struct snd_kcontrol *kcontrol, |
| 550 | struct snd_ctl_elem_value *ucontrol) | ||
| 551 | { | 551 | { |
| 552 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); | 552 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); |
| 553 | uda1341_t *uda = clnt->driver_data; | 553 | struct uda1341 *uda = clnt->driver_data; |
| 554 | int where = kcontrol->private_value & 31; | 554 | int where = kcontrol->private_value & 31; |
| 555 | int mask = (kcontrol->private_value >> 12) & 63; | 555 | int mask = (kcontrol->private_value >> 12) & 63; |
| 556 | int invert = (kcontrol->private_value >> 18) & 1; | 556 | int invert = (kcontrol->private_value >> 18) & 1; |
| @@ -562,10 +562,11 @@ static int snd_uda1341_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
| 562 | return 0; | 562 | return 0; |
| 563 | } | 563 | } |
| 564 | 564 | ||
| 565 | static int snd_uda1341_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 565 | static int snd_uda1341_put_single(struct snd_kcontrol *kcontrol, |
| 566 | struct snd_ctl_elem_value *ucontrol) | ||
| 566 | { | 567 | { |
| 567 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); | 568 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); |
| 568 | uda1341_t *uda = clnt->driver_data; | 569 | struct uda1341 *uda = clnt->driver_data; |
| 569 | int where = kcontrol->private_value & 31; | 570 | int where = kcontrol->private_value & 31; |
| 570 | int reg = (kcontrol->private_value >> 5) & 15; | 571 | int reg = (kcontrol->private_value >> 5) & 15; |
| 571 | int shift = (kcontrol->private_value >> 9) & 7; | 572 | int shift = (kcontrol->private_value >> 9) & 7; |
| @@ -591,7 +592,8 @@ static int snd_uda1341_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
| 591 | .private_value = where | (reg << 5) | (shift << 9) | (mask << 12) | (invert << 18) \ | 592 | .private_value = where | (reg << 5) | (shift << 9) | (mask << 12) | (invert << 18) \ |
| 592 | } | 593 | } |
| 593 | 594 | ||
| 594 | static int snd_uda1341_info_enum(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 595 | static int snd_uda1341_info_enum(struct snd_kcontrol *kcontrol, |
| 596 | struct snd_ctl_elem_info *uinfo) | ||
| 595 | { | 597 | { |
| 596 | int where = kcontrol->private_value & 31; | 598 | int where = kcontrol->private_value & 31; |
| 597 | const char **texts; | 599 | const char **texts; |
| @@ -612,20 +614,22 @@ static int snd_uda1341_info_enum(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * | |||
| 612 | return 0; | 614 | return 0; |
| 613 | } | 615 | } |
| 614 | 616 | ||
| 615 | static int snd_uda1341_get_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 617 | static int snd_uda1341_get_enum(struct snd_kcontrol *kcontrol, |
| 618 | struct snd_ctl_elem_value *ucontrol) | ||
| 616 | { | 619 | { |
| 617 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); | 620 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); |
| 618 | uda1341_t *uda = clnt->driver_data; | 621 | struct uda1341 *uda = clnt->driver_data; |
| 619 | int where = kcontrol->private_value & 31; | 622 | int where = kcontrol->private_value & 31; |
| 620 | 623 | ||
| 621 | ucontrol->value.enumerated.item[0] = uda->cfg[where]; | 624 | ucontrol->value.enumerated.item[0] = uda->cfg[where]; |
| 622 | return 0; | 625 | return 0; |
| 623 | } | 626 | } |
| 624 | 627 | ||
| 625 | static int snd_uda1341_put_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 628 | static int snd_uda1341_put_enum(struct snd_kcontrol *kcontrol, |
| 629 | struct snd_ctl_elem_value *ucontrol) | ||
| 626 | { | 630 | { |
| 627 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); | 631 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); |
| 628 | uda1341_t *uda = clnt->driver_data; | 632 | struct uda1341 *uda = clnt->driver_data; |
| 629 | int where = kcontrol->private_value & 31; | 633 | int where = kcontrol->private_value & 31; |
| 630 | int reg = (kcontrol->private_value >> 5) & 15; | 634 | int reg = (kcontrol->private_value >> 5) & 15; |
| 631 | int shift = (kcontrol->private_value >> 9) & 7; | 635 | int shift = (kcontrol->private_value >> 9) & 7; |
| @@ -648,7 +652,8 @@ static int snd_uda1341_put_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
| 648 | } | 652 | } |
| 649 | 653 | ||
| 650 | 654 | ||
| 651 | static int snd_uda1341_info_2regs(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 655 | static int snd_uda1341_info_2regs(struct snd_kcontrol *kcontrol, |
| 656 | struct snd_ctl_elem_info *uinfo) | ||
| 652 | { | 657 | { |
| 653 | int mask_1 = (kcontrol->private_value >> 19) & 63; | 658 | int mask_1 = (kcontrol->private_value >> 19) & 63; |
| 654 | int mask_2 = (kcontrol->private_value >> 25) & 63; | 659 | int mask_2 = (kcontrol->private_value >> 25) & 63; |
| @@ -662,10 +667,11 @@ static int snd_uda1341_info_2regs(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t | |||
| 662 | return 0; | 667 | return 0; |
| 663 | } | 668 | } |
| 664 | 669 | ||
| 665 | static int snd_uda1341_get_2regs(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 670 | static int snd_uda1341_get_2regs(struct snd_kcontrol *kcontrol, |
| 671 | struct snd_ctl_elem_value *ucontrol) | ||
| 666 | { | 672 | { |
| 667 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); | 673 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); |
| 668 | uda1341_t *uda = clnt->driver_data; | 674 | struct uda1341 *uda = clnt->driver_data; |
| 669 | int where = kcontrol->private_value & 31; | 675 | int where = kcontrol->private_value & 31; |
| 670 | int mask_1 = (kcontrol->private_value >> 19) & 63; | 676 | int mask_1 = (kcontrol->private_value >> 19) & 63; |
| 671 | int mask_2 = (kcontrol->private_value >> 25) & 63; | 677 | int mask_2 = (kcontrol->private_value >> 25) & 63; |
| @@ -680,10 +686,11 @@ static int snd_uda1341_get_2regs(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
| 680 | return 0; | 686 | return 0; |
| 681 | } | 687 | } |
| 682 | 688 | ||
| 683 | static int snd_uda1341_put_2regs(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 689 | static int snd_uda1341_put_2regs(struct snd_kcontrol *kcontrol, |
| 690 | struct snd_ctl_elem_value *ucontrol) | ||
| 684 | { | 691 | { |
| 685 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); | 692 | struct l3_client *clnt = snd_kcontrol_chip(kcontrol); |
| 686 | uda1341_t *uda = clnt->driver_data; | 693 | struct uda1341 *uda = clnt->driver_data; |
| 687 | int where = kcontrol->private_value & 31; | 694 | int where = kcontrol->private_value & 31; |
| 688 | int reg_1 = (kcontrol->private_value >> 5) & 15; | 695 | int reg_1 = (kcontrol->private_value >> 5) & 15; |
| 689 | int reg_2 = (kcontrol->private_value >> 9) & 15; | 696 | int reg_2 = (kcontrol->private_value >> 9) & 15; |
| @@ -716,7 +723,7 @@ static int snd_uda1341_put_2regs(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t | |||
| 716 | 723 | ||
| 717 | /* }}} */ | 724 | /* }}} */ |
| 718 | 725 | ||
| 719 | static snd_kcontrol_new_t snd_uda1341_controls[] = { | 726 | static struct snd_kcontrol_new snd_uda1341_controls[] = { |
| 720 | UDA1341_SINGLE("Master Playback Switch", CMD_MUTE, data0_2, 2, 1, 1), | 727 | UDA1341_SINGLE("Master Playback Switch", CMD_MUTE, data0_2, 2, 1, 1), |
| 721 | UDA1341_SINGLE("Master Playback Volume", CMD_VOLUME, data0_0, 0, 63, 1), | 728 | UDA1341_SINGLE("Master Playback Volume", CMD_VOLUME, data0_0, 0, 63, 1), |
| 722 | 729 | ||
| @@ -748,20 +755,20 @@ static snd_kcontrol_new_t snd_uda1341_controls[] = { | |||
| 748 | 755 | ||
| 749 | static void uda1341_free(struct l3_client *clnt) | 756 | static void uda1341_free(struct l3_client *clnt) |
| 750 | { | 757 | { |
| 751 | l3_detach_client(clnt); // calls kfree for driver_data (uda1341_t) | 758 | l3_detach_client(clnt); // calls kfree for driver_data (struct uda1341) |
| 752 | kfree(clnt); | 759 | kfree(clnt); |
| 753 | } | 760 | } |
| 754 | 761 | ||
| 755 | static int uda1341_dev_free(snd_device_t *device) | 762 | static int uda1341_dev_free(struct snd_device *device) |
| 756 | { | 763 | { |
| 757 | struct l3_client *clnt = device->device_data; | 764 | struct l3_client *clnt = device->device_data; |
| 758 | uda1341_free(clnt); | 765 | uda1341_free(clnt); |
| 759 | return 0; | 766 | return 0; |
| 760 | } | 767 | } |
| 761 | 768 | ||
| 762 | int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clntp) | 769 | int __init snd_chip_uda1341_mixer_new(struct snd_card *card, struct l3_client **clntp) |
| 763 | { | 770 | { |
| 764 | static snd_device_ops_t ops = { | 771 | static struct snd_device_ops ops = { |
| 765 | .dev_free = uda1341_dev_free, | 772 | .dev_free = uda1341_dev_free, |
| 766 | }; | 773 | }; |
| 767 | struct l3_client *clnt; | 774 | struct l3_client *clnt; |
| @@ -792,7 +799,7 @@ int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clntp | |||
| 792 | 799 | ||
| 793 | *clntp = clnt; | 800 | *clntp = clnt; |
| 794 | strcpy(card->mixername, "UDA1341TS Mixer"); | 801 | strcpy(card->mixername, "UDA1341TS Mixer"); |
| 795 | ((uda1341_t *)uda1341->driver_data)->card = card; | 802 | ((struct uda1341 *)clnt->driver_data)->card = card; |
| 796 | 803 | ||
| 797 | snd_uda1341_proc_init(card, clnt); | 804 | snd_uda1341_proc_init(card, clnt); |
| 798 | 805 | ||
