diff options
author | Jiri Kosina <jkosina@suse.cz> | 2012-04-08 15:48:52 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2012-04-08 15:48:52 -0400 |
commit | e75d660672ddd11704b7f0fdb8ff21968587b266 (patch) | |
tree | ccb9c107744c10b553c0373e450bee3971d16c00 /sound/core/pcm.c | |
parent | 61282f37927143e45b03153f3e7b48d6b702147a (diff) | |
parent | 0034102808e0dbbf3a2394b82b1bb40b5778de9e (diff) |
Merge branch 'master' into for-next
Merge with latest Linus' tree, as I have incoming patches
that fix code that is newer than current HEAD of for-next.
Conflicts:
drivers/net/ethernet/realtek/r8169.c
Diffstat (limited to 'sound/core/pcm.c')
-rw-r--r-- | sound/core/pcm.c | 100 |
1 files changed, 70 insertions, 30 deletions
diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 8928ca871c22..1a3070b4e5b5 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/time.h> | 25 | #include <linux/time.h> |
26 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
27 | #include <linux/device.h> | ||
27 | #include <sound/core.h> | 28 | #include <sound/core.h> |
28 | #include <sound/minors.h> | 29 | #include <sound/minors.h> |
29 | #include <sound/pcm.h> | 30 | #include <sound/pcm.h> |
@@ -650,7 +651,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) | |||
650 | pstr->stream = stream; | 651 | pstr->stream = stream; |
651 | pstr->pcm = pcm; | 652 | pstr->pcm = pcm; |
652 | pstr->substream_count = substream_count; | 653 | pstr->substream_count = substream_count; |
653 | if (substream_count > 0) { | 654 | if (substream_count > 0 && !pcm->internal) { |
654 | err = snd_pcm_stream_proc_init(pstr); | 655 | err = snd_pcm_stream_proc_init(pstr); |
655 | if (err < 0) { | 656 | if (err < 0) { |
656 | snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n"); | 657 | snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n"); |
@@ -674,15 +675,18 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) | |||
674 | pstr->substream = substream; | 675 | pstr->substream = substream; |
675 | else | 676 | else |
676 | prev->next = substream; | 677 | prev->next = substream; |
677 | err = snd_pcm_substream_proc_init(substream); | 678 | |
678 | if (err < 0) { | 679 | if (!pcm->internal) { |
679 | snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n"); | 680 | err = snd_pcm_substream_proc_init(substream); |
680 | if (prev == NULL) | 681 | if (err < 0) { |
681 | pstr->substream = NULL; | 682 | snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n"); |
682 | else | 683 | if (prev == NULL) |
683 | prev->next = NULL; | 684 | pstr->substream = NULL; |
684 | kfree(substream); | 685 | else |
685 | return err; | 686 | prev->next = NULL; |
687 | kfree(substream); | ||
688 | return err; | ||
689 | } | ||
686 | } | 690 | } |
687 | substream->group = &substream->self_group; | 691 | substream->group = &substream->self_group; |
688 | spin_lock_init(&substream->self_group.lock); | 692 | spin_lock_init(&substream->self_group.lock); |
@@ -696,25 +700,9 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) | |||
696 | 700 | ||
697 | EXPORT_SYMBOL(snd_pcm_new_stream); | 701 | EXPORT_SYMBOL(snd_pcm_new_stream); |
698 | 702 | ||
699 | /** | 703 | static int _snd_pcm_new(struct snd_card *card, const char *id, int device, |
700 | * snd_pcm_new - create a new PCM instance | 704 | int playback_count, int capture_count, bool internal, |
701 | * @card: the card instance | 705 | struct snd_pcm **rpcm) |
702 | * @id: the id string | ||
703 | * @device: the device index (zero based) | ||
704 | * @playback_count: the number of substreams for playback | ||
705 | * @capture_count: the number of substreams for capture | ||
706 | * @rpcm: the pointer to store the new pcm instance | ||
707 | * | ||
708 | * Creates a new PCM instance. | ||
709 | * | ||
710 | * The pcm operators have to be set afterwards to the new instance | ||
711 | * via snd_pcm_set_ops(). | ||
712 | * | ||
713 | * Returns zero if successful, or a negative error code on failure. | ||
714 | */ | ||
715 | int snd_pcm_new(struct snd_card *card, const char *id, int device, | ||
716 | int playback_count, int capture_count, | ||
717 | struct snd_pcm ** rpcm) | ||
718 | { | 706 | { |
719 | struct snd_pcm *pcm; | 707 | struct snd_pcm *pcm; |
720 | int err; | 708 | int err; |
@@ -735,6 +723,7 @@ int snd_pcm_new(struct snd_card *card, const char *id, int device, | |||
735 | } | 723 | } |
736 | pcm->card = card; | 724 | pcm->card = card; |
737 | pcm->device = device; | 725 | pcm->device = device; |
726 | pcm->internal = internal; | ||
738 | if (id) | 727 | if (id) |
739 | strlcpy(pcm->id, id, sizeof(pcm->id)); | 728 | strlcpy(pcm->id, id, sizeof(pcm->id)); |
740 | if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) { | 729 | if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) { |
@@ -756,8 +745,59 @@ int snd_pcm_new(struct snd_card *card, const char *id, int device, | |||
756 | return 0; | 745 | return 0; |
757 | } | 746 | } |
758 | 747 | ||
748 | /** | ||
749 | * snd_pcm_new - create a new PCM instance | ||
750 | * @card: the card instance | ||
751 | * @id: the id string | ||
752 | * @device: the device index (zero based) | ||
753 | * @playback_count: the number of substreams for playback | ||
754 | * @capture_count: the number of substreams for capture | ||
755 | * @rpcm: the pointer to store the new pcm instance | ||
756 | * | ||
757 | * Creates a new PCM instance. | ||
758 | * | ||
759 | * The pcm operators have to be set afterwards to the new instance | ||
760 | * via snd_pcm_set_ops(). | ||
761 | * | ||
762 | * Returns zero if successful, or a negative error code on failure. | ||
763 | */ | ||
764 | int snd_pcm_new(struct snd_card *card, const char *id, int device, | ||
765 | int playback_count, int capture_count, struct snd_pcm **rpcm) | ||
766 | { | ||
767 | return _snd_pcm_new(card, id, device, playback_count, capture_count, | ||
768 | false, rpcm); | ||
769 | } | ||
759 | EXPORT_SYMBOL(snd_pcm_new); | 770 | EXPORT_SYMBOL(snd_pcm_new); |
760 | 771 | ||
772 | /** | ||
773 | * snd_pcm_new_internal - create a new internal PCM instance | ||
774 | * @card: the card instance | ||
775 | * @id: the id string | ||
776 | * @device: the device index (zero based - shared with normal PCMs) | ||
777 | * @playback_count: the number of substreams for playback | ||
778 | * @capture_count: the number of substreams for capture | ||
779 | * @rpcm: the pointer to store the new pcm instance | ||
780 | * | ||
781 | * Creates a new internal PCM instance with no userspace device or procfs | ||
782 | * entries. This is used by ASoC Back End PCMs in order to create a PCM that | ||
783 | * will only be used internally by kernel drivers. i.e. it cannot be opened | ||
784 | * by userspace. It provides existing ASoC components drivers with a substream | ||
785 | * and access to any private data. | ||
786 | * | ||
787 | * The pcm operators have to be set afterwards to the new instance | ||
788 | * via snd_pcm_set_ops(). | ||
789 | * | ||
790 | * Returns zero if successful, or a negative error code on failure. | ||
791 | */ | ||
792 | int snd_pcm_new_internal(struct snd_card *card, const char *id, int device, | ||
793 | int playback_count, int capture_count, | ||
794 | struct snd_pcm **rpcm) | ||
795 | { | ||
796 | return _snd_pcm_new(card, id, device, playback_count, capture_count, | ||
797 | true, rpcm); | ||
798 | } | ||
799 | EXPORT_SYMBOL(snd_pcm_new_internal); | ||
800 | |||
761 | static void snd_pcm_free_stream(struct snd_pcm_str * pstr) | 801 | static void snd_pcm_free_stream(struct snd_pcm_str * pstr) |
762 | { | 802 | { |
763 | struct snd_pcm_substream *substream, *substream_next; | 803 | struct snd_pcm_substream *substream, *substream_next; |
@@ -994,7 +1034,7 @@ static int snd_pcm_dev_register(struct snd_device *device) | |||
994 | } | 1034 | } |
995 | for (cidx = 0; cidx < 2; cidx++) { | 1035 | for (cidx = 0; cidx < 2; cidx++) { |
996 | int devtype = -1; | 1036 | int devtype = -1; |
997 | if (pcm->streams[cidx].substream == NULL) | 1037 | if (pcm->streams[cidx].substream == NULL || pcm->internal) |
998 | continue; | 1038 | continue; |
999 | switch (cidx) { | 1039 | switch (cidx) { |
1000 | case SNDRV_PCM_STREAM_PLAYBACK: | 1040 | case SNDRV_PCM_STREAM_PLAYBACK: |