diff options
Diffstat (limited to 'sound/soc/soc-utils.c')
-rw-r--r-- | sound/soc/soc-utils.c | 76 |
1 files changed, 56 insertions, 20 deletions
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 1d07b931f3d8..ec921ec99c26 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c | |||
@@ -13,6 +13,7 @@ | |||
13 | * option) any later version. | 13 | * option) any later version. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/platform_device.h> | ||
16 | #include <sound/core.h> | 17 | #include <sound/core.h> |
17 | #include <sound/pcm.h> | 18 | #include <sound/pcm.h> |
18 | #include <sound/pcm_params.h> | 19 | #include <sound/pcm_params.h> |
@@ -28,26 +29,9 @@ int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params) | |||
28 | { | 29 | { |
29 | int sample_size; | 30 | int sample_size; |
30 | 31 | ||
31 | switch (params_format(params)) { | 32 | sample_size = snd_pcm_format_width(params_format(params)); |
32 | case SNDRV_PCM_FORMAT_S16_LE: | 33 | if (sample_size < 0) |
33 | case SNDRV_PCM_FORMAT_S16_BE: | 34 | return sample_size; |
34 | sample_size = 16; | ||
35 | break; | ||
36 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
37 | case SNDRV_PCM_FORMAT_S20_3BE: | ||
38 | sample_size = 20; | ||
39 | break; | ||
40 | case SNDRV_PCM_FORMAT_S24_LE: | ||
41 | case SNDRV_PCM_FORMAT_S24_BE: | ||
42 | sample_size = 24; | ||
43 | break; | ||
44 | case SNDRV_PCM_FORMAT_S32_LE: | ||
45 | case SNDRV_PCM_FORMAT_S32_BE: | ||
46 | sample_size = 32; | ||
47 | break; | ||
48 | default: | ||
49 | return -ENOTSUPP; | ||
50 | } | ||
51 | 35 | ||
52 | return snd_soc_calc_frame_size(sample_size, params_channels(params), | 36 | return snd_soc_calc_frame_size(sample_size, params_channels(params), |
53 | 1); | 37 | 1); |
@@ -72,3 +56,55 @@ int snd_soc_params_to_bclk(struct snd_pcm_hw_params *params) | |||
72 | return ret; | 56 | return ret; |
73 | } | 57 | } |
74 | EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk); | 58 | EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk); |
59 | |||
60 | static struct snd_soc_platform_driver dummy_platform; | ||
61 | |||
62 | static __devinit int snd_soc_dummy_probe(struct platform_device *pdev) | ||
63 | { | ||
64 | return snd_soc_register_platform(&pdev->dev, &dummy_platform); | ||
65 | } | ||
66 | |||
67 | static __devexit int snd_soc_dummy_remove(struct platform_device *pdev) | ||
68 | { | ||
69 | snd_soc_unregister_platform(&pdev->dev); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static struct platform_driver soc_dummy_driver = { | ||
75 | .driver = { | ||
76 | .name = "snd-soc-dummy", | ||
77 | .owner = THIS_MODULE, | ||
78 | }, | ||
79 | .probe = snd_soc_dummy_probe, | ||
80 | .remove = __devexit_p(snd_soc_dummy_remove), | ||
81 | }; | ||
82 | |||
83 | static struct platform_device *soc_dummy_dev; | ||
84 | |||
85 | int __init snd_soc_util_init(void) | ||
86 | { | ||
87 | int ret; | ||
88 | |||
89 | soc_dummy_dev = platform_device_alloc("snd-soc-dummy", -1); | ||
90 | if (!soc_dummy_dev) | ||
91 | return -ENOMEM; | ||
92 | |||
93 | ret = platform_device_add(soc_dummy_dev); | ||
94 | if (ret != 0) { | ||
95 | platform_device_put(soc_dummy_dev); | ||
96 | return ret; | ||
97 | } | ||
98 | |||
99 | ret = platform_driver_register(&soc_dummy_driver); | ||
100 | if (ret != 0) | ||
101 | platform_device_unregister(soc_dummy_dev); | ||
102 | |||
103 | return ret; | ||
104 | } | ||
105 | |||
106 | void __exit snd_soc_util_exit(void) | ||
107 | { | ||
108 | platform_device_unregister(soc_dummy_dev); | ||
109 | platform_driver_unregister(&soc_dummy_driver); | ||
110 | } | ||