diff options
author | Mark Brown <broonie@kernel.org> | 2017-11-10 16:30:50 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-11-10 16:30:50 -0500 |
commit | aa38bff80896e3918f357816a79a9b4a1d375c56 (patch) | |
tree | 125e0c5833611d5d791d9019181404df78d1b630 | |
parent | 73e13d0f6c1b3d69f0379500ba6d17d8a43a50c6 (diff) | |
parent | e07bd30bb87f6a6ca1f75fa41df71ff5e7bc6a3f (diff) |
Merge remote-tracking branch 'asoc/topic/core' into asoc-next
-rw-r--r-- | include/sound/soc.h | 94 | ||||
-rw-r--r-- | sound/soc/soc-compress.c | 461 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 192 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 8 | ||||
-rw-r--r-- | sound/soc/soc-io.c | 14 | ||||
-rw-r--r-- | sound/soc/soc-pcm.c | 459 |
6 files changed, 1090 insertions, 138 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 580da1e4f141..0668cbd9f0b5 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -480,6 +480,8 @@ int devm_snd_soc_register_component(struct device *dev, | |||
480 | const struct snd_soc_component_driver *component_driver, | 480 | const struct snd_soc_component_driver *component_driver, |
481 | struct snd_soc_dai_driver *dai_drv, int num_dai); | 481 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
482 | void snd_soc_unregister_component(struct device *dev); | 482 | void snd_soc_unregister_component(struct device *dev); |
483 | struct snd_soc_component *snd_soc_lookup_component(struct device *dev, | ||
484 | const char *driver_name); | ||
483 | int snd_soc_cache_init(struct snd_soc_codec *codec); | 485 | int snd_soc_cache_init(struct snd_soc_codec *codec); |
484 | int snd_soc_cache_exit(struct snd_soc_codec *codec); | 486 | int snd_soc_cache_exit(struct snd_soc_codec *codec); |
485 | 487 | ||
@@ -800,6 +802,10 @@ struct snd_soc_component_driver { | |||
800 | int (*suspend)(struct snd_soc_component *); | 802 | int (*suspend)(struct snd_soc_component *); |
801 | int (*resume)(struct snd_soc_component *); | 803 | int (*resume)(struct snd_soc_component *); |
802 | 804 | ||
805 | /* pcm creation and destruction */ | ||
806 | int (*pcm_new)(struct snd_soc_pcm_runtime *); | ||
807 | void (*pcm_free)(struct snd_pcm *); | ||
808 | |||
803 | /* component wide operations */ | 809 | /* component wide operations */ |
804 | int (*set_sysclk)(struct snd_soc_component *component, | 810 | int (*set_sysclk)(struct snd_soc_component *component, |
805 | int clk_id, int source, unsigned int freq, int dir); | 811 | int clk_id, int source, unsigned int freq, int dir); |
@@ -817,10 +823,22 @@ struct snd_soc_component_driver { | |||
817 | void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type, | 823 | void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type, |
818 | int subseq); | 824 | int subseq); |
819 | int (*stream_event)(struct snd_soc_component *, int event); | 825 | int (*stream_event)(struct snd_soc_component *, int event); |
826 | int (*set_bias_level)(struct snd_soc_component *component, | ||
827 | enum snd_soc_bias_level level); | ||
828 | |||
829 | const struct snd_pcm_ops *ops; | ||
830 | const struct snd_compr_ops *compr_ops; | ||
820 | 831 | ||
821 | /* probe ordering - for components with runtime dependencies */ | 832 | /* probe ordering - for components with runtime dependencies */ |
822 | int probe_order; | 833 | int probe_order; |
823 | int remove_order; | 834 | int remove_order; |
835 | |||
836 | /* bits */ | ||
837 | unsigned int idle_bias_on:1; | ||
838 | unsigned int suspend_bias_off:1; | ||
839 | unsigned int pmdown_time:1; /* care pmdown_time at stop */ | ||
840 | unsigned int endianness:1; | ||
841 | unsigned int non_legacy_dai_naming:1; | ||
824 | }; | 842 | }; |
825 | 843 | ||
826 | struct snd_soc_component { | 844 | struct snd_soc_component { |
@@ -877,6 +895,8 @@ struct snd_soc_component { | |||
877 | void (*remove)(struct snd_soc_component *); | 895 | void (*remove)(struct snd_soc_component *); |
878 | int (*suspend)(struct snd_soc_component *); | 896 | int (*suspend)(struct snd_soc_component *); |
879 | int (*resume)(struct snd_soc_component *); | 897 | int (*resume)(struct snd_soc_component *); |
898 | int (*pcm_new)(struct snd_soc_component *, struct snd_soc_pcm_runtime *); | ||
899 | void (*pcm_free)(struct snd_soc_component *, struct snd_pcm *); | ||
880 | 900 | ||
881 | int (*set_sysclk)(struct snd_soc_component *component, | 901 | int (*set_sysclk)(struct snd_soc_component *component, |
882 | int clk_id, int source, unsigned int freq, int dir); | 902 | int clk_id, int source, unsigned int freq, int dir); |
@@ -884,6 +904,8 @@ struct snd_soc_component { | |||
884 | int source, unsigned int freq_in, unsigned int freq_out); | 904 | int source, unsigned int freq_in, unsigned int freq_out); |
885 | int (*set_jack)(struct snd_soc_component *component, | 905 | int (*set_jack)(struct snd_soc_component *component, |
886 | struct snd_soc_jack *jack, void *data); | 906 | struct snd_soc_jack *jack, void *data); |
907 | int (*set_bias_level)(struct snd_soc_component *component, | ||
908 | enum snd_soc_bias_level level); | ||
887 | 909 | ||
888 | /* machine specific init */ | 910 | /* machine specific init */ |
889 | int (*init)(struct snd_soc_component *component); | 911 | int (*init)(struct snd_soc_component *component); |
@@ -1418,6 +1440,21 @@ static inline void snd_soc_codec_init_bias_level(struct snd_soc_codec *codec, | |||
1418 | } | 1440 | } |
1419 | 1441 | ||
1420 | /** | 1442 | /** |
1443 | * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level | ||
1444 | * @component: The COMPONENT for which to initialize the DAPM bias level | ||
1445 | * @level: The DAPM level to initialize to | ||
1446 | * | ||
1447 | * Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level(). | ||
1448 | */ | ||
1449 | static inline void | ||
1450 | snd_soc_component_init_bias_level(struct snd_soc_component *component, | ||
1451 | enum snd_soc_bias_level level) | ||
1452 | { | ||
1453 | snd_soc_dapm_init_bias_level( | ||
1454 | snd_soc_component_get_dapm(component), level); | ||
1455 | } | ||
1456 | |||
1457 | /** | ||
1421 | * snd_soc_dapm_get_bias_level() - Get current CODEC DAPM bias level | 1458 | * snd_soc_dapm_get_bias_level() - Get current CODEC DAPM bias level |
1422 | * @codec: The CODEC for which to get the DAPM bias level | 1459 | * @codec: The CODEC for which to get the DAPM bias level |
1423 | * | 1460 | * |
@@ -1430,6 +1467,19 @@ static inline enum snd_soc_bias_level snd_soc_codec_get_bias_level( | |||
1430 | } | 1467 | } |
1431 | 1468 | ||
1432 | /** | 1469 | /** |
1470 | * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level | ||
1471 | * @component: The COMPONENT for which to get the DAPM bias level | ||
1472 | * | ||
1473 | * Returns: The current DAPM bias level of the COMPONENT. | ||
1474 | */ | ||
1475 | static inline enum snd_soc_bias_level | ||
1476 | snd_soc_component_get_bias_level(struct snd_soc_component *component) | ||
1477 | { | ||
1478 | return snd_soc_dapm_get_bias_level( | ||
1479 | snd_soc_component_get_dapm(component)); | ||
1480 | } | ||
1481 | |||
1482 | /** | ||
1433 | * snd_soc_codec_force_bias_level() - Set the CODEC DAPM bias level | 1483 | * snd_soc_codec_force_bias_level() - Set the CODEC DAPM bias level |
1434 | * @codec: The CODEC for which to set the level | 1484 | * @codec: The CODEC for which to set the level |
1435 | * @level: The level to set to | 1485 | * @level: The level to set to |
@@ -1445,6 +1495,23 @@ static inline int snd_soc_codec_force_bias_level(struct snd_soc_codec *codec, | |||
1445 | } | 1495 | } |
1446 | 1496 | ||
1447 | /** | 1497 | /** |
1498 | * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level | ||
1499 | * @component: The COMPONENT for which to set the level | ||
1500 | * @level: The level to set to | ||
1501 | * | ||
1502 | * Forces the COMPONENT bias level to a specific state. See | ||
1503 | * snd_soc_dapm_force_bias_level(). | ||
1504 | */ | ||
1505 | static inline int | ||
1506 | snd_soc_component_force_bias_level(struct snd_soc_component *component, | ||
1507 | enum snd_soc_bias_level level) | ||
1508 | { | ||
1509 | return snd_soc_dapm_force_bias_level( | ||
1510 | snd_soc_component_get_dapm(component), | ||
1511 | level); | ||
1512 | } | ||
1513 | |||
1514 | /** | ||
1448 | * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol | 1515 | * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol |
1449 | * @kcontrol: The kcontrol | 1516 | * @kcontrol: The kcontrol |
1450 | * | 1517 | * |
@@ -1457,6 +1524,19 @@ static inline struct snd_soc_codec *snd_soc_dapm_kcontrol_codec( | |||
1457 | return snd_soc_dapm_to_codec(snd_soc_dapm_kcontrol_dapm(kcontrol)); | 1524 | return snd_soc_dapm_to_codec(snd_soc_dapm_kcontrol_dapm(kcontrol)); |
1458 | } | 1525 | } |
1459 | 1526 | ||
1527 | /** | ||
1528 | * snd_soc_dapm_kcontrol_component() - Returns the component associated to a kcontrol | ||
1529 | * @kcontrol: The kcontrol | ||
1530 | * | ||
1531 | * This function must only be used on DAPM contexts that are known to be part of | ||
1532 | * a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined. | ||
1533 | */ | ||
1534 | static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component( | ||
1535 | struct snd_kcontrol *kcontrol) | ||
1536 | { | ||
1537 | return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol)); | ||
1538 | } | ||
1539 | |||
1460 | /* codec IO */ | 1540 | /* codec IO */ |
1461 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); | 1541 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); |
1462 | int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, | 1542 | int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg, |
@@ -1473,9 +1553,23 @@ static inline int snd_soc_cache_sync(struct snd_soc_codec *codec) | |||
1473 | return regcache_sync(codec->component.regmap); | 1553 | return regcache_sync(codec->component.regmap); |
1474 | } | 1554 | } |
1475 | 1555 | ||
1556 | /** | ||
1557 | * snd_soc_component_cache_sync() - Sync the register cache with the hardware | ||
1558 | * @component: COMPONENT to sync | ||
1559 | * | ||
1560 | * Note: This function will call regcache_sync() | ||
1561 | */ | ||
1562 | static inline int snd_soc_component_cache_sync( | ||
1563 | struct snd_soc_component *component) | ||
1564 | { | ||
1565 | return regcache_sync(component->regmap); | ||
1566 | } | ||
1567 | |||
1476 | /* component IO */ | 1568 | /* component IO */ |
1477 | int snd_soc_component_read(struct snd_soc_component *component, | 1569 | int snd_soc_component_read(struct snd_soc_component *component, |
1478 | unsigned int reg, unsigned int *val); | 1570 | unsigned int reg, unsigned int *val); |
1571 | unsigned int snd_soc_component_read32(struct snd_soc_component *component, | ||
1572 | unsigned int reg); | ||
1479 | int snd_soc_component_write(struct snd_soc_component *component, | 1573 | int snd_soc_component_write(struct snd_soc_component *component, |
1480 | unsigned int reg, unsigned int val); | 1574 | unsigned int reg, unsigned int val); |
1481 | int snd_soc_component_update_bits(struct snd_soc_component *component, | 1575 | int snd_soc_component_update_bits(struct snd_soc_component *component, |
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 2cb8d3b55fbc..d9b1e6417fb9 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c | |||
@@ -30,8 +30,10 @@ static int soc_compr_open(struct snd_compr_stream *cstream) | |||
30 | { | 30 | { |
31 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 31 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
32 | struct snd_soc_platform *platform = rtd->platform; | 32 | struct snd_soc_platform *platform = rtd->platform; |
33 | struct snd_soc_component *component; | ||
34 | struct snd_soc_rtdcom_list *rtdcom; | ||
33 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 35 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
34 | int ret = 0; | 36 | int ret = 0, __ret; |
35 | 37 | ||
36 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 38 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
37 | 39 | ||
@@ -44,7 +46,7 @@ static int soc_compr_open(struct snd_compr_stream *cstream) | |||
44 | } | 46 | } |
45 | } | 47 | } |
46 | 48 | ||
47 | if (platform->driver->compr_ops && platform->driver->compr_ops->open) { | 49 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->open) { |
48 | ret = platform->driver->compr_ops->open(cstream); | 50 | ret = platform->driver->compr_ops->open(cstream); |
49 | if (ret < 0) { | 51 | if (ret < 0) { |
50 | pr_err("compress asoc: can't open platform %s\n", | 52 | pr_err("compress asoc: can't open platform %s\n", |
@@ -53,6 +55,27 @@ static int soc_compr_open(struct snd_compr_stream *cstream) | |||
53 | } | 55 | } |
54 | } | 56 | } |
55 | 57 | ||
58 | for_each_rtdcom(rtd, rtdcom) { | ||
59 | component = rtdcom->component; | ||
60 | |||
61 | /* ignore duplication for now */ | ||
62 | if (platform && (component == &platform->component)) | ||
63 | continue; | ||
64 | |||
65 | if (!component->driver->compr_ops || | ||
66 | !component->driver->compr_ops->open) | ||
67 | continue; | ||
68 | |||
69 | __ret = component->driver->compr_ops->open(cstream); | ||
70 | if (__ret < 0) { | ||
71 | pr_err("compress asoc: can't open platform %s\n", | ||
72 | component->name); | ||
73 | ret = __ret; | ||
74 | } | ||
75 | } | ||
76 | if (ret < 0) | ||
77 | goto machine_err; | ||
78 | |||
56 | if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->startup) { | 79 | if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->startup) { |
57 | ret = rtd->dai_link->compr_ops->startup(cstream); | 80 | ret = rtd->dai_link->compr_ops->startup(cstream); |
58 | if (ret < 0) { | 81 | if (ret < 0) { |
@@ -68,7 +91,21 @@ static int soc_compr_open(struct snd_compr_stream *cstream) | |||
68 | return 0; | 91 | return 0; |
69 | 92 | ||
70 | machine_err: | 93 | machine_err: |
71 | if (platform->driver->compr_ops && platform->driver->compr_ops->free) | 94 | for_each_rtdcom(rtd, rtdcom) { |
95 | component = rtdcom->component; | ||
96 | |||
97 | /* ignore duplication for now */ | ||
98 | if (platform && (component == &platform->component)) | ||
99 | continue; | ||
100 | |||
101 | if (!component->driver->compr_ops || | ||
102 | !component->driver->compr_ops->free) | ||
103 | continue; | ||
104 | |||
105 | component->driver->compr_ops->free(cstream); | ||
106 | } | ||
107 | |||
108 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) | ||
72 | platform->driver->compr_ops->free(cstream); | 109 | platform->driver->compr_ops->free(cstream); |
73 | plat_err: | 110 | plat_err: |
74 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) | 111 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) |
@@ -84,11 +121,13 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) | |||
84 | struct snd_pcm_substream *fe_substream = | 121 | struct snd_pcm_substream *fe_substream = |
85 | fe->pcm->streams[cstream->direction].substream; | 122 | fe->pcm->streams[cstream->direction].substream; |
86 | struct snd_soc_platform *platform = fe->platform; | 123 | struct snd_soc_platform *platform = fe->platform; |
124 | struct snd_soc_component *component; | ||
125 | struct snd_soc_rtdcom_list *rtdcom; | ||
87 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; | 126 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; |
88 | struct snd_soc_dpcm *dpcm; | 127 | struct snd_soc_dpcm *dpcm; |
89 | struct snd_soc_dapm_widget_list *list; | 128 | struct snd_soc_dapm_widget_list *list; |
90 | int stream; | 129 | int stream; |
91 | int ret = 0; | 130 | int ret = 0, __ret; |
92 | 131 | ||
93 | if (cstream->direction == SND_COMPRESS_PLAYBACK) | 132 | if (cstream->direction == SND_COMPRESS_PLAYBACK) |
94 | stream = SNDRV_PCM_STREAM_PLAYBACK; | 133 | stream = SNDRV_PCM_STREAM_PLAYBACK; |
@@ -107,7 +146,7 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) | |||
107 | } | 146 | } |
108 | 147 | ||
109 | 148 | ||
110 | if (platform->driver->compr_ops && platform->driver->compr_ops->open) { | 149 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->open) { |
111 | ret = platform->driver->compr_ops->open(cstream); | 150 | ret = platform->driver->compr_ops->open(cstream); |
112 | if (ret < 0) { | 151 | if (ret < 0) { |
113 | pr_err("compress asoc: can't open platform %s\n", | 152 | pr_err("compress asoc: can't open platform %s\n", |
@@ -116,6 +155,27 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) | |||
116 | } | 155 | } |
117 | } | 156 | } |
118 | 157 | ||
158 | for_each_rtdcom(fe, rtdcom) { | ||
159 | component = rtdcom->component; | ||
160 | |||
161 | /* ignore duplication for now */ | ||
162 | if (platform && (component == &platform->component)) | ||
163 | continue; | ||
164 | |||
165 | if (!component->driver->compr_ops || | ||
166 | !component->driver->compr_ops->open) | ||
167 | continue; | ||
168 | |||
169 | __ret = component->driver->compr_ops->open(cstream); | ||
170 | if (__ret < 0) { | ||
171 | pr_err("compress asoc: can't open platform %s\n", | ||
172 | component->name); | ||
173 | ret = __ret; | ||
174 | } | ||
175 | } | ||
176 | if (ret < 0) | ||
177 | goto machine_err; | ||
178 | |||
119 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->startup) { | 179 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->startup) { |
120 | ret = fe->dai_link->compr_ops->startup(cstream); | 180 | ret = fe->dai_link->compr_ops->startup(cstream); |
121 | if (ret < 0) { | 181 | if (ret < 0) { |
@@ -167,7 +227,21 @@ fe_err: | |||
167 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) | 227 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) |
168 | fe->dai_link->compr_ops->shutdown(cstream); | 228 | fe->dai_link->compr_ops->shutdown(cstream); |
169 | machine_err: | 229 | machine_err: |
170 | if (platform->driver->compr_ops && platform->driver->compr_ops->free) | 230 | for_each_rtdcom(fe, rtdcom) { |
231 | component = rtdcom->component; | ||
232 | |||
233 | /* ignore duplication for now */ | ||
234 | if (platform && (component == &platform->component)) | ||
235 | continue; | ||
236 | |||
237 | if (!component->driver->compr_ops || | ||
238 | !component->driver->compr_ops->free) | ||
239 | continue; | ||
240 | |||
241 | component->driver->compr_ops->free(cstream); | ||
242 | } | ||
243 | |||
244 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) | ||
171 | platform->driver->compr_ops->free(cstream); | 245 | platform->driver->compr_ops->free(cstream); |
172 | plat_err: | 246 | plat_err: |
173 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) | 247 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) |
@@ -210,6 +284,8 @@ static int soc_compr_free(struct snd_compr_stream *cstream) | |||
210 | { | 284 | { |
211 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 285 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
212 | struct snd_soc_platform *platform = rtd->platform; | 286 | struct snd_soc_platform *platform = rtd->platform; |
287 | struct snd_soc_component *component; | ||
288 | struct snd_soc_rtdcom_list *rtdcom; | ||
213 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 289 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
214 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 290 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
215 | int stream; | 291 | int stream; |
@@ -235,7 +311,21 @@ static int soc_compr_free(struct snd_compr_stream *cstream) | |||
235 | if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->shutdown) | 311 | if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->shutdown) |
236 | rtd->dai_link->compr_ops->shutdown(cstream); | 312 | rtd->dai_link->compr_ops->shutdown(cstream); |
237 | 313 | ||
238 | if (platform->driver->compr_ops && platform->driver->compr_ops->free) | 314 | for_each_rtdcom(rtd, rtdcom) { |
315 | component = rtdcom->component; | ||
316 | |||
317 | /* ignore duplication for now */ | ||
318 | if (platform && (component == &platform->component)) | ||
319 | continue; | ||
320 | |||
321 | if (!component->driver->compr_ops || | ||
322 | !component->driver->compr_ops->free) | ||
323 | continue; | ||
324 | |||
325 | component->driver->compr_ops->free(cstream); | ||
326 | } | ||
327 | |||
328 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) | ||
239 | platform->driver->compr_ops->free(cstream); | 329 | platform->driver->compr_ops->free(cstream); |
240 | 330 | ||
241 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) | 331 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) |
@@ -267,6 +357,8 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) | |||
267 | { | 357 | { |
268 | struct snd_soc_pcm_runtime *fe = cstream->private_data; | 358 | struct snd_soc_pcm_runtime *fe = cstream->private_data; |
269 | struct snd_soc_platform *platform = fe->platform; | 359 | struct snd_soc_platform *platform = fe->platform; |
360 | struct snd_soc_component *component; | ||
361 | struct snd_soc_rtdcom_list *rtdcom; | ||
270 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; | 362 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; |
271 | struct snd_soc_dpcm *dpcm; | 363 | struct snd_soc_dpcm *dpcm; |
272 | int stream, ret; | 364 | int stream, ret; |
@@ -304,9 +396,23 @@ static int soc_compr_free_fe(struct snd_compr_stream *cstream) | |||
304 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) | 396 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->shutdown) |
305 | fe->dai_link->compr_ops->shutdown(cstream); | 397 | fe->dai_link->compr_ops->shutdown(cstream); |
306 | 398 | ||
307 | if (platform->driver->compr_ops && platform->driver->compr_ops->free) | 399 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->free) |
308 | platform->driver->compr_ops->free(cstream); | 400 | platform->driver->compr_ops->free(cstream); |
309 | 401 | ||
402 | for_each_rtdcom(fe, rtdcom) { | ||
403 | component = rtdcom->component; | ||
404 | |||
405 | /* ignore duplication for now */ | ||
406 | if (platform && (component == &platform->component)) | ||
407 | continue; | ||
408 | |||
409 | if (!component->driver->compr_ops || | ||
410 | !component->driver->compr_ops->free) | ||
411 | continue; | ||
412 | |||
413 | component->driver->compr_ops->free(cstream); | ||
414 | } | ||
415 | |||
310 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) | 416 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->shutdown) |
311 | cpu_dai->driver->cops->shutdown(cstream, cpu_dai); | 417 | cpu_dai->driver->cops->shutdown(cstream, cpu_dai); |
312 | 418 | ||
@@ -319,18 +425,38 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd) | |||
319 | 425 | ||
320 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 426 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
321 | struct snd_soc_platform *platform = rtd->platform; | 427 | struct snd_soc_platform *platform = rtd->platform; |
428 | struct snd_soc_component *component; | ||
429 | struct snd_soc_rtdcom_list *rtdcom; | ||
322 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 430 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
323 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 431 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
324 | int ret = 0; | 432 | int ret = 0, __ret; |
325 | 433 | ||
326 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 434 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
327 | 435 | ||
328 | if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) { | 436 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->trigger) { |
329 | ret = platform->driver->compr_ops->trigger(cstream, cmd); | 437 | ret = platform->driver->compr_ops->trigger(cstream, cmd); |
330 | if (ret < 0) | 438 | if (ret < 0) |
331 | goto out; | 439 | goto out; |
332 | } | 440 | } |
333 | 441 | ||
442 | for_each_rtdcom(rtd, rtdcom) { | ||
443 | component = rtdcom->component; | ||
444 | |||
445 | /* ignore duplication for now */ | ||
446 | if (platform && (component == &platform->component)) | ||
447 | continue; | ||
448 | |||
449 | if (!component->driver->compr_ops || | ||
450 | !component->driver->compr_ops->trigger) | ||
451 | continue; | ||
452 | |||
453 | __ret = component->driver->compr_ops->trigger(cstream, cmd); | ||
454 | if (__ret < 0) | ||
455 | ret = __ret; | ||
456 | } | ||
457 | if (ret < 0) | ||
458 | goto out; | ||
459 | |||
334 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->trigger) | 460 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->trigger) |
335 | cpu_dai->driver->cops->trigger(cstream, cmd, cpu_dai); | 461 | cpu_dai->driver->cops->trigger(cstream, cmd, cpu_dai); |
336 | 462 | ||
@@ -353,16 +479,36 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) | |||
353 | { | 479 | { |
354 | struct snd_soc_pcm_runtime *fe = cstream->private_data; | 480 | struct snd_soc_pcm_runtime *fe = cstream->private_data; |
355 | struct snd_soc_platform *platform = fe->platform; | 481 | struct snd_soc_platform *platform = fe->platform; |
482 | struct snd_soc_component *component; | ||
483 | struct snd_soc_rtdcom_list *rtdcom; | ||
356 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; | 484 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; |
357 | int ret = 0, stream; | 485 | int ret = 0, __ret, stream; |
358 | 486 | ||
359 | if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN || | 487 | if (cmd == SND_COMPR_TRIGGER_PARTIAL_DRAIN || |
360 | cmd == SND_COMPR_TRIGGER_DRAIN) { | 488 | cmd == SND_COMPR_TRIGGER_DRAIN) { |
361 | 489 | ||
362 | if (platform->driver->compr_ops && | 490 | if (platform && |
491 | platform->driver->compr_ops && | ||
363 | platform->driver->compr_ops->trigger) | 492 | platform->driver->compr_ops->trigger) |
364 | return platform->driver->compr_ops->trigger(cstream, | 493 | return platform->driver->compr_ops->trigger(cstream, |
365 | cmd); | 494 | cmd); |
495 | |||
496 | for_each_rtdcom(fe, rtdcom) { | ||
497 | component = rtdcom->component; | ||
498 | |||
499 | /* ignore duplication for now */ | ||
500 | if (platform && (component == &platform->component)) | ||
501 | continue; | ||
502 | |||
503 | if (!component->driver->compr_ops || | ||
504 | !component->driver->compr_ops->trigger) | ||
505 | continue; | ||
506 | |||
507 | __ret = component->driver->compr_ops->trigger(cstream, cmd); | ||
508 | if (__ret < 0) | ||
509 | ret = __ret; | ||
510 | } | ||
511 | return ret; | ||
366 | } | 512 | } |
367 | 513 | ||
368 | if (cstream->direction == SND_COMPRESS_PLAYBACK) | 514 | if (cstream->direction == SND_COMPRESS_PLAYBACK) |
@@ -379,12 +525,30 @@ static int soc_compr_trigger_fe(struct snd_compr_stream *cstream, int cmd) | |||
379 | goto out; | 525 | goto out; |
380 | } | 526 | } |
381 | 527 | ||
382 | if (platform->driver->compr_ops && platform->driver->compr_ops->trigger) { | 528 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->trigger) { |
383 | ret = platform->driver->compr_ops->trigger(cstream, cmd); | 529 | ret = platform->driver->compr_ops->trigger(cstream, cmd); |
384 | if (ret < 0) | 530 | if (ret < 0) |
385 | goto out; | 531 | goto out; |
386 | } | 532 | } |
387 | 533 | ||
534 | for_each_rtdcom(fe, rtdcom) { | ||
535 | component = rtdcom->component; | ||
536 | |||
537 | /* ignore duplication for now */ | ||
538 | if (platform && (component == &platform->component)) | ||
539 | continue; | ||
540 | |||
541 | if (!component->driver->compr_ops || | ||
542 | !component->driver->compr_ops->trigger) | ||
543 | continue; | ||
544 | |||
545 | __ret = component->driver->compr_ops->trigger(cstream, cmd); | ||
546 | if (__ret < 0) | ||
547 | ret = __ret; | ||
548 | } | ||
549 | if (ret < 0) | ||
550 | goto out; | ||
551 | |||
388 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; | 552 | fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; |
389 | 553 | ||
390 | ret = dpcm_be_dai_trigger(fe, stream, cmd); | 554 | ret = dpcm_be_dai_trigger(fe, stream, cmd); |
@@ -415,8 +579,10 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, | |||
415 | { | 579 | { |
416 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 580 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
417 | struct snd_soc_platform *platform = rtd->platform; | 581 | struct snd_soc_platform *platform = rtd->platform; |
582 | struct snd_soc_component *component; | ||
583 | struct snd_soc_rtdcom_list *rtdcom; | ||
418 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 584 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
419 | int ret = 0; | 585 | int ret = 0, __ret; |
420 | 586 | ||
421 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 587 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
422 | 588 | ||
@@ -432,12 +598,30 @@ static int soc_compr_set_params(struct snd_compr_stream *cstream, | |||
432 | goto err; | 598 | goto err; |
433 | } | 599 | } |
434 | 600 | ||
435 | if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) { | 601 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_params) { |
436 | ret = platform->driver->compr_ops->set_params(cstream, params); | 602 | ret = platform->driver->compr_ops->set_params(cstream, params); |
437 | if (ret < 0) | 603 | if (ret < 0) |
438 | goto err; | 604 | goto err; |
439 | } | 605 | } |
440 | 606 | ||
607 | for_each_rtdcom(rtd, rtdcom) { | ||
608 | component = rtdcom->component; | ||
609 | |||
610 | /* ignore duplication for now */ | ||
611 | if (platform && (component == &platform->component)) | ||
612 | continue; | ||
613 | |||
614 | if (!component->driver->compr_ops || | ||
615 | !component->driver->compr_ops->set_params) | ||
616 | continue; | ||
617 | |||
618 | __ret = component->driver->compr_ops->set_params(cstream, params); | ||
619 | if (__ret < 0) | ||
620 | ret = __ret; | ||
621 | } | ||
622 | if (ret < 0) | ||
623 | goto err; | ||
624 | |||
441 | if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) { | 625 | if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->set_params) { |
442 | ret = rtd->dai_link->compr_ops->set_params(cstream); | 626 | ret = rtd->dai_link->compr_ops->set_params(cstream); |
443 | if (ret < 0) | 627 | if (ret < 0) |
@@ -471,8 +655,10 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, | |||
471 | struct snd_pcm_substream *fe_substream = | 655 | struct snd_pcm_substream *fe_substream = |
472 | fe->pcm->streams[cstream->direction].substream; | 656 | fe->pcm->streams[cstream->direction].substream; |
473 | struct snd_soc_platform *platform = fe->platform; | 657 | struct snd_soc_platform *platform = fe->platform; |
658 | struct snd_soc_component *component; | ||
659 | struct snd_soc_rtdcom_list *rtdcom; | ||
474 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; | 660 | struct snd_soc_dai *cpu_dai = fe->cpu_dai; |
475 | int ret = 0, stream; | 661 | int ret = 0, __ret, stream; |
476 | 662 | ||
477 | if (cstream->direction == SND_COMPRESS_PLAYBACK) | 663 | if (cstream->direction == SND_COMPRESS_PLAYBACK) |
478 | stream = SNDRV_PCM_STREAM_PLAYBACK; | 664 | stream = SNDRV_PCM_STREAM_PLAYBACK; |
@@ -487,12 +673,30 @@ static int soc_compr_set_params_fe(struct snd_compr_stream *cstream, | |||
487 | goto out; | 673 | goto out; |
488 | } | 674 | } |
489 | 675 | ||
490 | if (platform->driver->compr_ops && platform->driver->compr_ops->set_params) { | 676 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_params) { |
491 | ret = platform->driver->compr_ops->set_params(cstream, params); | 677 | ret = platform->driver->compr_ops->set_params(cstream, params); |
492 | if (ret < 0) | 678 | if (ret < 0) |
493 | goto out; | 679 | goto out; |
494 | } | 680 | } |
495 | 681 | ||
682 | for_each_rtdcom(fe, rtdcom) { | ||
683 | component = rtdcom->component; | ||
684 | |||
685 | /* ignore duplication for now */ | ||
686 | if (platform && (component == &platform->component)) | ||
687 | continue; | ||
688 | |||
689 | if (!component->driver->compr_ops || | ||
690 | !component->driver->compr_ops->set_params) | ||
691 | continue; | ||
692 | |||
693 | __ret = component->driver->compr_ops->set_params(cstream, params); | ||
694 | if (__ret < 0) | ||
695 | ret = __ret; | ||
696 | } | ||
697 | if (ret < 0) | ||
698 | goto out; | ||
699 | |||
496 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->set_params) { | 700 | if (fe->dai_link->compr_ops && fe->dai_link->compr_ops->set_params) { |
497 | ret = fe->dai_link->compr_ops->set_params(cstream); | 701 | ret = fe->dai_link->compr_ops->set_params(cstream); |
498 | if (ret < 0) | 702 | if (ret < 0) |
@@ -531,8 +735,10 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, | |||
531 | { | 735 | { |
532 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 736 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
533 | struct snd_soc_platform *platform = rtd->platform; | 737 | struct snd_soc_platform *platform = rtd->platform; |
738 | struct snd_soc_component *component; | ||
739 | struct snd_soc_rtdcom_list *rtdcom; | ||
534 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 740 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
535 | int ret = 0; | 741 | int ret = 0, __ret; |
536 | 742 | ||
537 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 743 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
538 | 744 | ||
@@ -542,8 +748,27 @@ static int soc_compr_get_params(struct snd_compr_stream *cstream, | |||
542 | goto err; | 748 | goto err; |
543 | } | 749 | } |
544 | 750 | ||
545 | if (platform->driver->compr_ops && platform->driver->compr_ops->get_params) | 751 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_params) { |
546 | ret = platform->driver->compr_ops->get_params(cstream, params); | 752 | ret = platform->driver->compr_ops->get_params(cstream, params); |
753 | if (ret < 0) | ||
754 | goto err; | ||
755 | } | ||
756 | |||
757 | for_each_rtdcom(rtd, rtdcom) { | ||
758 | component = rtdcom->component; | ||
759 | |||
760 | /* ignore duplication for now */ | ||
761 | if (platform && (component == &platform->component)) | ||
762 | continue; | ||
763 | |||
764 | if (!component->driver->compr_ops || | ||
765 | !component->driver->compr_ops->get_params) | ||
766 | continue; | ||
767 | |||
768 | __ret = component->driver->compr_ops->get_params(cstream, params); | ||
769 | if (__ret < 0) | ||
770 | ret = __ret; | ||
771 | } | ||
547 | 772 | ||
548 | err: | 773 | err: |
549 | mutex_unlock(&rtd->pcm_mutex); | 774 | mutex_unlock(&rtd->pcm_mutex); |
@@ -555,13 +780,35 @@ static int soc_compr_get_caps(struct snd_compr_stream *cstream, | |||
555 | { | 780 | { |
556 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 781 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
557 | struct snd_soc_platform *platform = rtd->platform; | 782 | struct snd_soc_platform *platform = rtd->platform; |
558 | int ret = 0; | 783 | struct snd_soc_component *component; |
784 | struct snd_soc_rtdcom_list *rtdcom; | ||
785 | int ret = 0, __ret; | ||
559 | 786 | ||
560 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 787 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
561 | 788 | ||
562 | if (platform->driver->compr_ops && platform->driver->compr_ops->get_caps) | 789 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_caps) { |
563 | ret = platform->driver->compr_ops->get_caps(cstream, caps); | 790 | ret = platform->driver->compr_ops->get_caps(cstream, caps); |
791 | if (ret < 0) | ||
792 | goto err; | ||
793 | } | ||
794 | |||
795 | for_each_rtdcom(rtd, rtdcom) { | ||
796 | component = rtdcom->component; | ||
797 | |||
798 | /* ignore duplication for now */ | ||
799 | if (platform && (component == &platform->component)) | ||
800 | continue; | ||
564 | 801 | ||
802 | if (!component->driver->compr_ops || | ||
803 | !component->driver->compr_ops->get_caps) | ||
804 | continue; | ||
805 | |||
806 | __ret = component->driver->compr_ops->get_caps(cstream, caps); | ||
807 | if (__ret < 0) | ||
808 | ret = __ret; | ||
809 | } | ||
810 | |||
811 | err: | ||
565 | mutex_unlock(&rtd->pcm_mutex); | 812 | mutex_unlock(&rtd->pcm_mutex); |
566 | return ret; | 813 | return ret; |
567 | } | 814 | } |
@@ -571,13 +818,35 @@ static int soc_compr_get_codec_caps(struct snd_compr_stream *cstream, | |||
571 | { | 818 | { |
572 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 819 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
573 | struct snd_soc_platform *platform = rtd->platform; | 820 | struct snd_soc_platform *platform = rtd->platform; |
574 | int ret = 0; | 821 | struct snd_soc_component *component; |
822 | struct snd_soc_rtdcom_list *rtdcom; | ||
823 | int ret = 0, __ret; | ||
575 | 824 | ||
576 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 825 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
577 | 826 | ||
578 | if (platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps) | 827 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_codec_caps) { |
579 | ret = platform->driver->compr_ops->get_codec_caps(cstream, codec); | 828 | ret = platform->driver->compr_ops->get_codec_caps(cstream, codec); |
829 | if (ret < 0) | ||
830 | goto err; | ||
831 | } | ||
832 | |||
833 | for_each_rtdcom(rtd, rtdcom) { | ||
834 | component = rtdcom->component; | ||
835 | |||
836 | /* ignore duplication for now */ | ||
837 | if (platform && (component == &platform->component)) | ||
838 | continue; | ||
580 | 839 | ||
840 | if (!component->driver->compr_ops || | ||
841 | !component->driver->compr_ops->get_codec_caps) | ||
842 | continue; | ||
843 | |||
844 | __ret = component->driver->compr_ops->get_codec_caps(cstream, codec); | ||
845 | if (__ret < 0) | ||
846 | ret = __ret; | ||
847 | } | ||
848 | |||
849 | err: | ||
581 | mutex_unlock(&rtd->pcm_mutex); | 850 | mutex_unlock(&rtd->pcm_mutex); |
582 | return ret; | 851 | return ret; |
583 | } | 852 | } |
@@ -586,8 +855,10 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) | |||
586 | { | 855 | { |
587 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 856 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
588 | struct snd_soc_platform *platform = rtd->platform; | 857 | struct snd_soc_platform *platform = rtd->platform; |
858 | struct snd_soc_component *component; | ||
859 | struct snd_soc_rtdcom_list *rtdcom; | ||
589 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 860 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
590 | int ret = 0; | 861 | int ret = 0, __ret; |
591 | 862 | ||
592 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 863 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
593 | 864 | ||
@@ -597,8 +868,27 @@ static int soc_compr_ack(struct snd_compr_stream *cstream, size_t bytes) | |||
597 | goto err; | 868 | goto err; |
598 | } | 869 | } |
599 | 870 | ||
600 | if (platform->driver->compr_ops && platform->driver->compr_ops->ack) | 871 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->ack) { |
601 | ret = platform->driver->compr_ops->ack(cstream, bytes); | 872 | ret = platform->driver->compr_ops->ack(cstream, bytes); |
873 | if (ret < 0) | ||
874 | goto err; | ||
875 | } | ||
876 | |||
877 | for_each_rtdcom(rtd, rtdcom) { | ||
878 | component = rtdcom->component; | ||
879 | |||
880 | /* ignore duplication for now */ | ||
881 | if (platform && (component == &platform->component)) | ||
882 | continue; | ||
883 | |||
884 | if (!component->driver->compr_ops || | ||
885 | !component->driver->compr_ops->ack) | ||
886 | continue; | ||
887 | |||
888 | __ret = component->driver->compr_ops->ack(cstream, bytes); | ||
889 | if (__ret < 0) | ||
890 | ret = __ret; | ||
891 | } | ||
602 | 892 | ||
603 | err: | 893 | err: |
604 | mutex_unlock(&rtd->pcm_mutex); | 894 | mutex_unlock(&rtd->pcm_mutex); |
@@ -610,7 +900,9 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, | |||
610 | { | 900 | { |
611 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 901 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
612 | struct snd_soc_platform *platform = rtd->platform; | 902 | struct snd_soc_platform *platform = rtd->platform; |
613 | int ret = 0; | 903 | struct snd_soc_component *component; |
904 | struct snd_soc_rtdcom_list *rtdcom; | ||
905 | int ret = 0, __ret; | ||
614 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 906 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
615 | 907 | ||
616 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 908 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
@@ -618,9 +910,29 @@ static int soc_compr_pointer(struct snd_compr_stream *cstream, | |||
618 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer) | 910 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->pointer) |
619 | cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai); | 911 | cpu_dai->driver->cops->pointer(cstream, tstamp, cpu_dai); |
620 | 912 | ||
621 | if (platform->driver->compr_ops && platform->driver->compr_ops->pointer) | 913 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->pointer) { |
622 | ret = platform->driver->compr_ops->pointer(cstream, tstamp); | 914 | ret = platform->driver->compr_ops->pointer(cstream, tstamp); |
915 | if (ret < 0) | ||
916 | goto err; | ||
917 | } | ||
918 | |||
919 | for_each_rtdcom(rtd, rtdcom) { | ||
920 | component = rtdcom->component; | ||
921 | |||
922 | /* ignore duplication for now */ | ||
923 | if (platform && (component == &platform->component)) | ||
924 | continue; | ||
925 | |||
926 | if (!component->driver->compr_ops || | ||
927 | !component->driver->compr_ops->pointer) | ||
928 | continue; | ||
623 | 929 | ||
930 | __ret = component->driver->compr_ops->pointer(cstream, tstamp); | ||
931 | if (__ret < 0) | ||
932 | ret = __ret; | ||
933 | } | ||
934 | |||
935 | err: | ||
624 | mutex_unlock(&rtd->pcm_mutex); | 936 | mutex_unlock(&rtd->pcm_mutex); |
625 | return ret; | 937 | return ret; |
626 | } | 938 | } |
@@ -630,13 +942,34 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, | |||
630 | { | 942 | { |
631 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 943 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
632 | struct snd_soc_platform *platform = rtd->platform; | 944 | struct snd_soc_platform *platform = rtd->platform; |
633 | int ret = 0; | 945 | struct snd_soc_component *component; |
946 | struct snd_soc_rtdcom_list *rtdcom; | ||
947 | int ret = 0, __ret; | ||
634 | 948 | ||
635 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 949 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
636 | 950 | ||
637 | if (platform->driver->compr_ops && platform->driver->compr_ops->copy) | 951 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->copy) { |
638 | ret = platform->driver->compr_ops->copy(cstream, buf, count); | 952 | ret = platform->driver->compr_ops->copy(cstream, buf, count); |
953 | if (ret < 0) | ||
954 | goto err; | ||
955 | } | ||
956 | |||
957 | for_each_rtdcom(rtd, rtdcom) { | ||
958 | component = rtdcom->component; | ||
959 | |||
960 | /* ignore duplication for now */ | ||
961 | if (platform && (component == &platform->component)) | ||
962 | continue; | ||
963 | |||
964 | if (!component->driver->compr_ops || | ||
965 | !component->driver->compr_ops->copy) | ||
966 | continue; | ||
639 | 967 | ||
968 | __ret = component->driver->compr_ops->copy(cstream, buf, count); | ||
969 | if (__ret < 0) | ||
970 | ret = __ret; | ||
971 | } | ||
972 | err: | ||
640 | mutex_unlock(&rtd->pcm_mutex); | 973 | mutex_unlock(&rtd->pcm_mutex); |
641 | return ret; | 974 | return ret; |
642 | } | 975 | } |
@@ -646,8 +979,10 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream, | |||
646 | { | 979 | { |
647 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 980 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
648 | struct snd_soc_platform *platform = rtd->platform; | 981 | struct snd_soc_platform *platform = rtd->platform; |
982 | struct snd_soc_component *component; | ||
983 | struct snd_soc_rtdcom_list *rtdcom; | ||
649 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 984 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
650 | int ret = 0; | 985 | int ret = 0, __ret; |
651 | 986 | ||
652 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_metadata) { | 987 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->set_metadata) { |
653 | ret = cpu_dai->driver->cops->set_metadata(cstream, metadata, cpu_dai); | 988 | ret = cpu_dai->driver->cops->set_metadata(cstream, metadata, cpu_dai); |
@@ -655,8 +990,27 @@ static int soc_compr_set_metadata(struct snd_compr_stream *cstream, | |||
655 | return ret; | 990 | return ret; |
656 | } | 991 | } |
657 | 992 | ||
658 | if (platform->driver->compr_ops && platform->driver->compr_ops->set_metadata) | 993 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->set_metadata) { |
659 | ret = platform->driver->compr_ops->set_metadata(cstream, metadata); | 994 | ret = platform->driver->compr_ops->set_metadata(cstream, metadata); |
995 | if (ret < 0) | ||
996 | return ret; | ||
997 | } | ||
998 | |||
999 | for_each_rtdcom(rtd, rtdcom) { | ||
1000 | component = rtdcom->component; | ||
1001 | |||
1002 | /* ignore duplication for now */ | ||
1003 | if (platform && (component == &platform->component)) | ||
1004 | continue; | ||
1005 | |||
1006 | if (!component->driver->compr_ops || | ||
1007 | !component->driver->compr_ops->set_metadata) | ||
1008 | continue; | ||
1009 | |||
1010 | __ret = component->driver->compr_ops->set_metadata(cstream, metadata); | ||
1011 | if (__ret < 0) | ||
1012 | ret = __ret; | ||
1013 | } | ||
660 | 1014 | ||
661 | return ret; | 1015 | return ret; |
662 | } | 1016 | } |
@@ -666,8 +1020,10 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, | |||
666 | { | 1020 | { |
667 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | 1021 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; |
668 | struct snd_soc_platform *platform = rtd->platform; | 1022 | struct snd_soc_platform *platform = rtd->platform; |
1023 | struct snd_soc_component *component; | ||
1024 | struct snd_soc_rtdcom_list *rtdcom; | ||
669 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1025 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
670 | int ret = 0; | 1026 | int ret = 0, __ret; |
671 | 1027 | ||
672 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_metadata) { | 1028 | if (cpu_dai->driver->cops && cpu_dai->driver->cops->get_metadata) { |
673 | ret = cpu_dai->driver->cops->get_metadata(cstream, metadata, cpu_dai); | 1029 | ret = cpu_dai->driver->cops->get_metadata(cstream, metadata, cpu_dai); |
@@ -675,8 +1031,27 @@ static int soc_compr_get_metadata(struct snd_compr_stream *cstream, | |||
675 | return ret; | 1031 | return ret; |
676 | } | 1032 | } |
677 | 1033 | ||
678 | if (platform->driver->compr_ops && platform->driver->compr_ops->get_metadata) | 1034 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->get_metadata) { |
679 | ret = platform->driver->compr_ops->get_metadata(cstream, metadata); | 1035 | ret = platform->driver->compr_ops->get_metadata(cstream, metadata); |
1036 | if (ret < 0) | ||
1037 | return ret; | ||
1038 | } | ||
1039 | |||
1040 | for_each_rtdcom(rtd, rtdcom) { | ||
1041 | component = rtdcom->component; | ||
1042 | |||
1043 | /* ignore duplication for now */ | ||
1044 | if (platform && (component == &platform->component)) | ||
1045 | continue; | ||
1046 | |||
1047 | if (!component->driver->compr_ops || | ||
1048 | !component->driver->compr_ops->get_metadata) | ||
1049 | continue; | ||
1050 | |||
1051 | __ret = component->driver->compr_ops->get_metadata(cstream, metadata); | ||
1052 | if (__ret < 0) | ||
1053 | ret = __ret; | ||
1054 | } | ||
680 | 1055 | ||
681 | return ret; | 1056 | return ret; |
682 | } | 1057 | } |
@@ -723,6 +1098,8 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | |||
723 | { | 1098 | { |
724 | struct snd_soc_codec *codec = rtd->codec; | 1099 | struct snd_soc_codec *codec = rtd->codec; |
725 | struct snd_soc_platform *platform = rtd->platform; | 1100 | struct snd_soc_platform *platform = rtd->platform; |
1101 | struct snd_soc_component *component; | ||
1102 | struct snd_soc_rtdcom_list *rtdcom; | ||
726 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 1103 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
727 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1104 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
728 | struct snd_compr *compr; | 1105 | struct snd_compr *compr; |
@@ -798,9 +1175,25 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | |||
798 | memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); | 1175 | memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops)); |
799 | } | 1176 | } |
800 | 1177 | ||
1178 | |||
801 | /* Add copy callback for not memory mapped DSPs */ | 1179 | /* Add copy callback for not memory mapped DSPs */ |
802 | if (platform->driver->compr_ops && platform->driver->compr_ops->copy) | 1180 | if (platform && platform->driver->compr_ops && platform->driver->compr_ops->copy) |
1181 | compr->ops->copy = soc_compr_copy; | ||
1182 | |||
1183 | for_each_rtdcom(rtd, rtdcom) { | ||
1184 | component = rtdcom->component; | ||
1185 | |||
1186 | /* ignore duplication for now */ | ||
1187 | if (platform && (component == &platform->component)) | ||
1188 | continue; | ||
1189 | |||
1190 | if (!component->driver->compr_ops || | ||
1191 | !component->driver->compr_ops->copy) | ||
1192 | continue; | ||
1193 | |||
803 | compr->ops->copy = soc_compr_copy; | 1194 | compr->ops->copy = soc_compr_copy; |
1195 | } | ||
1196 | |||
804 | 1197 | ||
805 | mutex_init(&compr->lock); | 1198 | mutex_init(&compr->lock); |
806 | ret = snd_compress_new(rtd->card->snd_card, num, direction, | 1199 | ret = snd_compress_new(rtd->card->snd_card, num, direction, |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3a1c3b44de5e..533c822ca6e6 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -614,6 +614,8 @@ struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, | |||
614 | } | 614 | } |
615 | EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream); | 615 | EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream); |
616 | 616 | ||
617 | static const struct snd_soc_ops null_snd_soc_ops; | ||
618 | |||
617 | static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( | 619 | static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( |
618 | struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) | 620 | struct snd_soc_card *card, struct snd_soc_dai_link *dai_link) |
619 | { | 621 | { |
@@ -626,6 +628,9 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( | |||
626 | INIT_LIST_HEAD(&rtd->component_list); | 628 | INIT_LIST_HEAD(&rtd->component_list); |
627 | rtd->card = card; | 629 | rtd->card = card; |
628 | rtd->dai_link = dai_link; | 630 | rtd->dai_link = dai_link; |
631 | if (!rtd->dai_link->ops) | ||
632 | rtd->dai_link->ops = &null_snd_soc_ops; | ||
633 | |||
629 | rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) * | 634 | rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) * |
630 | dai_link->num_codecs, | 635 | dai_link->num_codecs, |
631 | GFP_KERNEL); | 636 | GFP_KERNEL); |
@@ -639,8 +644,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( | |||
639 | 644 | ||
640 | static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd) | 645 | static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd) |
641 | { | 646 | { |
642 | if (rtd && rtd->codec_dais) | 647 | kfree(rtd->codec_dais); |
643 | kfree(rtd->codec_dais); | ||
644 | snd_soc_rtdcom_del_all(rtd); | 648 | snd_soc_rtdcom_del_all(rtd); |
645 | kfree(rtd); | 649 | kfree(rtd); |
646 | } | 650 | } |
@@ -2632,7 +2636,7 @@ EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls); | |||
2632 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, | 2636 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, |
2633 | unsigned int freq, int dir) | 2637 | unsigned int freq, int dir) |
2634 | { | 2638 | { |
2635 | if (dai->driver && dai->driver->ops->set_sysclk) | 2639 | if (dai->driver->ops->set_sysclk) |
2636 | return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir); | 2640 | return dai->driver->ops->set_sysclk(dai, clk_id, freq, dir); |
2637 | 2641 | ||
2638 | return snd_soc_component_set_sysclk(dai->component, clk_id, 0, | 2642 | return snd_soc_component_set_sysclk(dai->component, clk_id, 0, |
@@ -2700,7 +2704,7 @@ EXPORT_SYMBOL_GPL(snd_soc_component_set_sysclk); | |||
2700 | int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, | 2704 | int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, |
2701 | int div_id, int div) | 2705 | int div_id, int div) |
2702 | { | 2706 | { |
2703 | if (dai->driver && dai->driver->ops->set_clkdiv) | 2707 | if (dai->driver->ops->set_clkdiv) |
2704 | return dai->driver->ops->set_clkdiv(dai, div_id, div); | 2708 | return dai->driver->ops->set_clkdiv(dai, div_id, div); |
2705 | else | 2709 | else |
2706 | return -EINVAL; | 2710 | return -EINVAL; |
@@ -2720,7 +2724,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_clkdiv); | |||
2720 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, | 2724 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source, |
2721 | unsigned int freq_in, unsigned int freq_out) | 2725 | unsigned int freq_in, unsigned int freq_out) |
2722 | { | 2726 | { |
2723 | if (dai->driver && dai->driver->ops->set_pll) | 2727 | if (dai->driver->ops->set_pll) |
2724 | return dai->driver->ops->set_pll(dai, pll_id, source, | 2728 | return dai->driver->ops->set_pll(dai, pll_id, source, |
2725 | freq_in, freq_out); | 2729 | freq_in, freq_out); |
2726 | 2730 | ||
@@ -2786,7 +2790,7 @@ EXPORT_SYMBOL_GPL(snd_soc_component_set_pll); | |||
2786 | */ | 2790 | */ |
2787 | int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) | 2791 | int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) |
2788 | { | 2792 | { |
2789 | if (dai->driver && dai->driver->ops->set_bclk_ratio) | 2793 | if (dai->driver->ops->set_bclk_ratio) |
2790 | return dai->driver->ops->set_bclk_ratio(dai, ratio); | 2794 | return dai->driver->ops->set_bclk_ratio(dai, ratio); |
2791 | else | 2795 | else |
2792 | return -EINVAL; | 2796 | return -EINVAL; |
@@ -2860,7 +2864,7 @@ static int snd_soc_xlate_tdm_slot_mask(unsigned int slots, | |||
2860 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, | 2864 | int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, |
2861 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) | 2865 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) |
2862 | { | 2866 | { |
2863 | if (dai->driver && dai->driver->ops->xlate_tdm_slot_mask) | 2867 | if (dai->driver->ops->xlate_tdm_slot_mask) |
2864 | dai->driver->ops->xlate_tdm_slot_mask(slots, | 2868 | dai->driver->ops->xlate_tdm_slot_mask(slots, |
2865 | &tx_mask, &rx_mask); | 2869 | &tx_mask, &rx_mask); |
2866 | else | 2870 | else |
@@ -2869,7 +2873,7 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, | |||
2869 | dai->tx_mask = tx_mask; | 2873 | dai->tx_mask = tx_mask; |
2870 | dai->rx_mask = rx_mask; | 2874 | dai->rx_mask = rx_mask; |
2871 | 2875 | ||
2872 | if (dai->driver && dai->driver->ops->set_tdm_slot) | 2876 | if (dai->driver->ops->set_tdm_slot) |
2873 | return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask, | 2877 | return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask, |
2874 | slots, slot_width); | 2878 | slots, slot_width); |
2875 | else | 2879 | else |
@@ -2893,7 +2897,7 @@ int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, | |||
2893 | unsigned int tx_num, unsigned int *tx_slot, | 2897 | unsigned int tx_num, unsigned int *tx_slot, |
2894 | unsigned int rx_num, unsigned int *rx_slot) | 2898 | unsigned int rx_num, unsigned int *rx_slot) |
2895 | { | 2899 | { |
2896 | if (dai->driver && dai->driver->ops->set_channel_map) | 2900 | if (dai->driver->ops->set_channel_map) |
2897 | return dai->driver->ops->set_channel_map(dai, tx_num, tx_slot, | 2901 | return dai->driver->ops->set_channel_map(dai, tx_num, tx_slot, |
2898 | rx_num, rx_slot); | 2902 | rx_num, rx_slot); |
2899 | else | 2903 | else |
@@ -2910,7 +2914,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_channel_map); | |||
2910 | */ | 2914 | */ |
2911 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) | 2915 | int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) |
2912 | { | 2916 | { |
2913 | if (dai->driver && dai->driver->ops->set_tristate) | 2917 | if (dai->driver->ops->set_tristate) |
2914 | return dai->driver->ops->set_tristate(dai, tristate); | 2918 | return dai->driver->ops->set_tristate(dai, tristate); |
2915 | else | 2919 | else |
2916 | return -EINVAL; | 2920 | return -EINVAL; |
@@ -3250,6 +3254,30 @@ static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm, | |||
3250 | return component->driver->stream_event(component, event); | 3254 | return component->driver->stream_event(component, event); |
3251 | } | 3255 | } |
3252 | 3256 | ||
3257 | static int snd_soc_component_drv_pcm_new(struct snd_soc_component *component, | ||
3258 | struct snd_soc_pcm_runtime *rtd) | ||
3259 | { | ||
3260 | if (component->driver->pcm_new) | ||
3261 | return component->driver->pcm_new(rtd); | ||
3262 | |||
3263 | return 0; | ||
3264 | } | ||
3265 | |||
3266 | static void snd_soc_component_drv_pcm_free(struct snd_soc_component *component, | ||
3267 | struct snd_pcm *pcm) | ||
3268 | { | ||
3269 | if (component->driver->pcm_free) | ||
3270 | component->driver->pcm_free(pcm); | ||
3271 | } | ||
3272 | |||
3273 | static int snd_soc_component_set_bias_level(struct snd_soc_dapm_context *dapm, | ||
3274 | enum snd_soc_bias_level level) | ||
3275 | { | ||
3276 | struct snd_soc_component *component = dapm->component; | ||
3277 | |||
3278 | return component->driver->set_bias_level(component, level); | ||
3279 | } | ||
3280 | |||
3253 | static int snd_soc_component_initialize(struct snd_soc_component *component, | 3281 | static int snd_soc_component_initialize(struct snd_soc_component *component, |
3254 | const struct snd_soc_component_driver *driver, struct device *dev) | 3282 | const struct snd_soc_component_driver *driver, struct device *dev) |
3255 | { | 3283 | { |
@@ -3270,16 +3298,21 @@ static int snd_soc_component_initialize(struct snd_soc_component *component, | |||
3270 | component->set_sysclk = component->driver->set_sysclk; | 3298 | component->set_sysclk = component->driver->set_sysclk; |
3271 | component->set_pll = component->driver->set_pll; | 3299 | component->set_pll = component->driver->set_pll; |
3272 | component->set_jack = component->driver->set_jack; | 3300 | component->set_jack = component->driver->set_jack; |
3301 | component->pcm_new = snd_soc_component_drv_pcm_new; | ||
3302 | component->pcm_free = snd_soc_component_drv_pcm_free; | ||
3273 | 3303 | ||
3274 | dapm = snd_soc_component_get_dapm(component); | 3304 | dapm = snd_soc_component_get_dapm(component); |
3275 | dapm->dev = dev; | 3305 | dapm->dev = dev; |
3276 | dapm->component = component; | 3306 | dapm->component = component; |
3277 | dapm->bias_level = SND_SOC_BIAS_OFF; | 3307 | dapm->bias_level = SND_SOC_BIAS_OFF; |
3278 | dapm->idle_bias_off = true; | 3308 | dapm->idle_bias_off = !driver->idle_bias_on; |
3309 | dapm->suspend_bias_off = driver->suspend_bias_off; | ||
3279 | if (driver->seq_notifier) | 3310 | if (driver->seq_notifier) |
3280 | dapm->seq_notifier = snd_soc_component_seq_notifier; | 3311 | dapm->seq_notifier = snd_soc_component_seq_notifier; |
3281 | if (driver->stream_event) | 3312 | if (driver->stream_event) |
3282 | dapm->stream_event = snd_soc_component_stream_event; | 3313 | dapm->stream_event = snd_soc_component_stream_event; |
3314 | if (driver->set_bias_level) | ||
3315 | dapm->set_bias_level = snd_soc_component_set_bias_level; | ||
3283 | 3316 | ||
3284 | INIT_LIST_HEAD(&component->dai_list); | 3317 | INIT_LIST_HEAD(&component->dai_list); |
3285 | mutex_init(&component->io_mutex); | 3318 | mutex_init(&component->io_mutex); |
@@ -3371,6 +3404,41 @@ static void snd_soc_component_del_unlocked(struct snd_soc_component *component) | |||
3371 | list_del(&component->list); | 3404 | list_del(&component->list); |
3372 | } | 3405 | } |
3373 | 3406 | ||
3407 | #define ENDIANNESS_MAP(name) \ | ||
3408 | (SNDRV_PCM_FMTBIT_##name##LE | SNDRV_PCM_FMTBIT_##name##BE) | ||
3409 | static u64 endianness_format_map[] = { | ||
3410 | ENDIANNESS_MAP(S16_), | ||
3411 | ENDIANNESS_MAP(U16_), | ||
3412 | ENDIANNESS_MAP(S24_), | ||
3413 | ENDIANNESS_MAP(U24_), | ||
3414 | ENDIANNESS_MAP(S32_), | ||
3415 | ENDIANNESS_MAP(U32_), | ||
3416 | ENDIANNESS_MAP(S24_3), | ||
3417 | ENDIANNESS_MAP(U24_3), | ||
3418 | ENDIANNESS_MAP(S20_3), | ||
3419 | ENDIANNESS_MAP(U20_3), | ||
3420 | ENDIANNESS_MAP(S18_3), | ||
3421 | ENDIANNESS_MAP(U18_3), | ||
3422 | ENDIANNESS_MAP(FLOAT_), | ||
3423 | ENDIANNESS_MAP(FLOAT64_), | ||
3424 | ENDIANNESS_MAP(IEC958_SUBFRAME_), | ||
3425 | }; | ||
3426 | |||
3427 | /* | ||
3428 | * Fix up the DAI formats for endianness: codecs don't actually see | ||
3429 | * the endianness of the data but we're using the CPU format | ||
3430 | * definitions which do need to include endianness so we ensure that | ||
3431 | * codec DAIs always have both big and little endian variants set. | ||
3432 | */ | ||
3433 | static void convert_endianness_formats(struct snd_soc_pcm_stream *stream) | ||
3434 | { | ||
3435 | int i; | ||
3436 | |||
3437 | for (i = 0; i < ARRAY_SIZE(endianness_format_map); i++) | ||
3438 | if (stream->formats & endianness_format_map[i]) | ||
3439 | stream->formats |= endianness_format_map[i]; | ||
3440 | } | ||
3441 | |||
3374 | int snd_soc_add_component(struct device *dev, | 3442 | int snd_soc_add_component(struct device *dev, |
3375 | struct snd_soc_component *component, | 3443 | struct snd_soc_component *component, |
3376 | const struct snd_soc_component_driver *component_driver, | 3444 | const struct snd_soc_component_driver *component_driver, |
@@ -3378,6 +3446,7 @@ int snd_soc_add_component(struct device *dev, | |||
3378 | int num_dai) | 3446 | int num_dai) |
3379 | { | 3447 | { |
3380 | int ret; | 3448 | int ret; |
3449 | int i; | ||
3381 | 3450 | ||
3382 | ret = snd_soc_component_initialize(component, component_driver, dev); | 3451 | ret = snd_soc_component_initialize(component, component_driver, dev); |
3383 | if (ret) | 3452 | if (ret) |
@@ -3386,7 +3455,15 @@ int snd_soc_add_component(struct device *dev, | |||
3386 | component->ignore_pmdown_time = true; | 3455 | component->ignore_pmdown_time = true; |
3387 | component->registered_as_component = true; | 3456 | component->registered_as_component = true; |
3388 | 3457 | ||
3389 | ret = snd_soc_register_dais(component, dai_drv, num_dai, true); | 3458 | if (component_driver->endianness) { |
3459 | for (i = 0; i < num_dai; i++) { | ||
3460 | convert_endianness_formats(&dai_drv[i].playback); | ||
3461 | convert_endianness_formats(&dai_drv[i].capture); | ||
3462 | } | ||
3463 | } | ||
3464 | |||
3465 | ret = snd_soc_register_dais(component, dai_drv, num_dai, | ||
3466 | !component_driver->non_legacy_dai_naming); | ||
3390 | if (ret < 0) { | 3467 | if (ret < 0) { |
3391 | dev_err(dev, "ASoC: Failed to register DAIs: %d\n", ret); | 3468 | dev_err(dev, "ASoC: Failed to register DAIs: %d\n", ret); |
3392 | goto err_cleanup; | 3469 | goto err_cleanup; |
@@ -3412,10 +3489,8 @@ int snd_soc_register_component(struct device *dev, | |||
3412 | struct snd_soc_component *component; | 3489 | struct snd_soc_component *component; |
3413 | 3490 | ||
3414 | component = kzalloc(sizeof(*component), GFP_KERNEL); | 3491 | component = kzalloc(sizeof(*component), GFP_KERNEL); |
3415 | if (!component) { | 3492 | if (!component) |
3416 | dev_err(dev, "ASoC: Failed to allocate memory\n"); | ||
3417 | return -ENOMEM; | 3493 | return -ENOMEM; |
3418 | } | ||
3419 | 3494 | ||
3420 | return snd_soc_add_component(dev, component, component_driver, | 3495 | return snd_soc_add_component(dev, component, component_driver, |
3421 | dai_drv, num_dai); | 3496 | dai_drv, num_dai); |
@@ -3460,6 +3535,32 @@ void snd_soc_unregister_component(struct device *dev) | |||
3460 | } | 3535 | } |
3461 | EXPORT_SYMBOL_GPL(snd_soc_unregister_component); | 3536 | EXPORT_SYMBOL_GPL(snd_soc_unregister_component); |
3462 | 3537 | ||
3538 | struct snd_soc_component *snd_soc_lookup_component(struct device *dev, | ||
3539 | const char *driver_name) | ||
3540 | { | ||
3541 | struct snd_soc_component *component; | ||
3542 | struct snd_soc_component *ret; | ||
3543 | |||
3544 | ret = NULL; | ||
3545 | mutex_lock(&client_mutex); | ||
3546 | list_for_each_entry(component, &component_list, list) { | ||
3547 | if (dev != component->dev) | ||
3548 | continue; | ||
3549 | |||
3550 | if (driver_name && | ||
3551 | (driver_name != component->driver->name) && | ||
3552 | (strcmp(component->driver->name, driver_name) != 0)) | ||
3553 | continue; | ||
3554 | |||
3555 | ret = component; | ||
3556 | break; | ||
3557 | } | ||
3558 | mutex_unlock(&client_mutex); | ||
3559 | |||
3560 | return ret; | ||
3561 | } | ||
3562 | EXPORT_SYMBOL_GPL(snd_soc_lookup_component); | ||
3563 | |||
3463 | static int snd_soc_platform_drv_probe(struct snd_soc_component *component) | 3564 | static int snd_soc_platform_drv_probe(struct snd_soc_component *component) |
3464 | { | 3565 | { |
3465 | struct snd_soc_platform *platform = snd_soc_component_to_platform(component); | 3566 | struct snd_soc_platform *platform = snd_soc_component_to_platform(component); |
@@ -3474,6 +3575,26 @@ static void snd_soc_platform_drv_remove(struct snd_soc_component *component) | |||
3474 | platform->driver->remove(platform); | 3575 | platform->driver->remove(platform); |
3475 | } | 3576 | } |
3476 | 3577 | ||
3578 | static int snd_soc_platform_drv_pcm_new(struct snd_soc_component *component, | ||
3579 | struct snd_soc_pcm_runtime *rtd) | ||
3580 | { | ||
3581 | struct snd_soc_platform *platform = snd_soc_component_to_platform(component); | ||
3582 | |||
3583 | if (platform->driver->pcm_new) | ||
3584 | return platform->driver->pcm_new(rtd); | ||
3585 | |||
3586 | return 0; | ||
3587 | } | ||
3588 | |||
3589 | static void snd_soc_platform_drv_pcm_free(struct snd_soc_component *component, | ||
3590 | struct snd_pcm *pcm) | ||
3591 | { | ||
3592 | struct snd_soc_platform *platform = snd_soc_component_to_platform(component); | ||
3593 | |||
3594 | if (platform->driver->pcm_free) | ||
3595 | platform->driver->pcm_free(pcm); | ||
3596 | } | ||
3597 | |||
3477 | /** | 3598 | /** |
3478 | * snd_soc_add_platform - Add a platform to the ASoC core | 3599 | * snd_soc_add_platform - Add a platform to the ASoC core |
3479 | * @dev: The parent device for the platform | 3600 | * @dev: The parent device for the platform |
@@ -3497,6 +3618,10 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, | |||
3497 | platform->component.probe = snd_soc_platform_drv_probe; | 3618 | platform->component.probe = snd_soc_platform_drv_probe; |
3498 | if (platform_drv->remove) | 3619 | if (platform_drv->remove) |
3499 | platform->component.remove = snd_soc_platform_drv_remove; | 3620 | platform->component.remove = snd_soc_platform_drv_remove; |
3621 | if (platform_drv->pcm_new) | ||
3622 | platform->component.pcm_new = snd_soc_platform_drv_pcm_new; | ||
3623 | if (platform_drv->pcm_free) | ||
3624 | platform->component.pcm_free = snd_soc_platform_drv_pcm_free; | ||
3500 | 3625 | ||
3501 | #ifdef CONFIG_DEBUG_FS | 3626 | #ifdef CONFIG_DEBUG_FS |
3502 | platform->component.debugfs_prefix = "platform"; | 3627 | platform->component.debugfs_prefix = "platform"; |
@@ -3594,39 +3719,6 @@ void snd_soc_unregister_platform(struct device *dev) | |||
3594 | } | 3719 | } |
3595 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); | 3720 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); |
3596 | 3721 | ||
3597 | static u64 codec_format_map[] = { | ||
3598 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE, | ||
3599 | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE, | ||
3600 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE, | ||
3601 | SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE, | ||
3602 | SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE, | ||
3603 | SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE, | ||
3604 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3BE, | ||
3605 | SNDRV_PCM_FMTBIT_U24_3LE | SNDRV_PCM_FMTBIT_U24_3BE, | ||
3606 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE, | ||
3607 | SNDRV_PCM_FMTBIT_U20_3LE | SNDRV_PCM_FMTBIT_U20_3BE, | ||
3608 | SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE, | ||
3609 | SNDRV_PCM_FMTBIT_U18_3LE | SNDRV_PCM_FMTBIT_U18_3BE, | ||
3610 | SNDRV_PCM_FMTBIT_FLOAT_LE | SNDRV_PCM_FMTBIT_FLOAT_BE, | ||
3611 | SNDRV_PCM_FMTBIT_FLOAT64_LE | SNDRV_PCM_FMTBIT_FLOAT64_BE, | ||
3612 | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | ||
3613 | | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE, | ||
3614 | }; | ||
3615 | |||
3616 | /* Fix up the DAI formats for endianness: codecs don't actually see | ||
3617 | * the endianness of the data but we're using the CPU format | ||
3618 | * definitions which do need to include endianness so we ensure that | ||
3619 | * codec DAIs always have both big and little endian variants set. | ||
3620 | */ | ||
3621 | static void fixup_codec_formats(struct snd_soc_pcm_stream *stream) | ||
3622 | { | ||
3623 | int i; | ||
3624 | |||
3625 | for (i = 0; i < ARRAY_SIZE(codec_format_map); i++) | ||
3626 | if (stream->formats & codec_format_map[i]) | ||
3627 | stream->formats |= codec_format_map[i]; | ||
3628 | } | ||
3629 | |||
3630 | static int snd_soc_codec_drv_probe(struct snd_soc_component *component) | 3722 | static int snd_soc_codec_drv_probe(struct snd_soc_component *component) |
3631 | { | 3723 | { |
3632 | struct snd_soc_codec *codec = snd_soc_component_to_codec(component); | 3724 | struct snd_soc_codec *codec = snd_soc_component_to_codec(component); |
@@ -3777,8 +3869,8 @@ int snd_soc_register_codec(struct device *dev, | |||
3777 | codec->component.regmap = codec_drv->get_regmap(dev); | 3869 | codec->component.regmap = codec_drv->get_regmap(dev); |
3778 | 3870 | ||
3779 | for (i = 0; i < num_dai; i++) { | 3871 | for (i = 0; i < num_dai; i++) { |
3780 | fixup_codec_formats(&dai_drv[i].playback); | 3872 | convert_endianness_formats(&dai_drv[i].playback); |
3781 | fixup_codec_formats(&dai_drv[i].capture); | 3873 | convert_endianness_formats(&dai_drv[i].capture); |
3782 | } | 3874 | } |
3783 | 3875 | ||
3784 | ret = snd_soc_register_dais(&codec->component, dai_drv, num_dai, false); | 3876 | ret = snd_soc_register_dais(&codec->component, dai_drv, num_dai, false); |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index dcef67a9bd48..9d4748e2b67a 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -3681,7 +3681,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
3681 | switch (event) { | 3681 | switch (event) { |
3682 | case SND_SOC_DAPM_PRE_PMU: | 3682 | case SND_SOC_DAPM_PRE_PMU: |
3683 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; | 3683 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; |
3684 | if (source->driver->ops && source->driver->ops->startup) { | 3684 | if (source->driver->ops->startup) { |
3685 | ret = source->driver->ops->startup(&substream, source); | 3685 | ret = source->driver->ops->startup(&substream, source); |
3686 | if (ret < 0) { | 3686 | if (ret < 0) { |
3687 | dev_err(source->dev, | 3687 | dev_err(source->dev, |
@@ -3695,7 +3695,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
3695 | goto out; | 3695 | goto out; |
3696 | 3696 | ||
3697 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; | 3697 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; |
3698 | if (sink->driver->ops && sink->driver->ops->startup) { | 3698 | if (sink->driver->ops->startup) { |
3699 | ret = sink->driver->ops->startup(&substream, sink); | 3699 | ret = sink->driver->ops->startup(&substream, sink); |
3700 | if (ret < 0) { | 3700 | if (ret < 0) { |
3701 | dev_err(sink->dev, | 3701 | dev_err(sink->dev, |
@@ -3725,13 +3725,13 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
3725 | ret = 0; | 3725 | ret = 0; |
3726 | 3726 | ||
3727 | source->active--; | 3727 | source->active--; |
3728 | if (source->driver->ops && source->driver->ops->shutdown) { | 3728 | if (source->driver->ops->shutdown) { |
3729 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; | 3729 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; |
3730 | source->driver->ops->shutdown(&substream, source); | 3730 | source->driver->ops->shutdown(&substream, source); |
3731 | } | 3731 | } |
3732 | 3732 | ||
3733 | sink->active--; | 3733 | sink->active--; |
3734 | if (sink->driver->ops && sink->driver->ops->shutdown) { | 3734 | if (sink->driver->ops->shutdown) { |
3735 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; | 3735 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; |
3736 | sink->driver->ops->shutdown(&substream, sink); | 3736 | sink->driver->ops->shutdown(&substream, sink); |
3737 | } | 3737 | } |
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 9b3939049cef..20340ade20a7 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c | |||
@@ -41,6 +41,20 @@ int snd_soc_component_read(struct snd_soc_component *component, | |||
41 | } | 41 | } |
42 | EXPORT_SYMBOL_GPL(snd_soc_component_read); | 42 | EXPORT_SYMBOL_GPL(snd_soc_component_read); |
43 | 43 | ||
44 | unsigned int snd_soc_component_read32(struct snd_soc_component *component, | ||
45 | unsigned int reg) | ||
46 | { | ||
47 | unsigned int val; | ||
48 | int ret; | ||
49 | |||
50 | ret = snd_soc_component_read(component, reg, &val); | ||
51 | if (ret < 0) | ||
52 | return -1; | ||
53 | |||
54 | return val; | ||
55 | } | ||
56 | EXPORT_SYMBOL_GPL(snd_soc_component_read32); | ||
57 | |||
44 | /** | 58 | /** |
45 | * snd_soc_component_write() - Write register value | 59 | * snd_soc_component_write() - Write register value |
46 | * @component: Component to write to | 60 | * @component: Component to write to |
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index c0f0b09cb433..8075856668c2 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
@@ -133,16 +133,25 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream) | |||
133 | */ | 133 | */ |
134 | bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) | 134 | bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) |
135 | { | 135 | { |
136 | struct snd_soc_rtdcom_list *rtdcom; | ||
137 | struct snd_soc_component *component; | ||
136 | int i; | 138 | int i; |
137 | bool ignore = true; | 139 | bool ignore = true; |
138 | 140 | ||
139 | if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) | 141 | if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) |
140 | return true; | 142 | return true; |
141 | 143 | ||
144 | for_each_rtdcom(rtd, rtdcom) { | ||
145 | component = rtdcom->component; | ||
146 | |||
147 | ignore &= !component->driver->pmdown_time; | ||
148 | } | ||
149 | |||
150 | /* this will be removed */ | ||
142 | for (i = 0; i < rtd->num_codecs; i++) | 151 | for (i = 0; i < rtd->num_codecs; i++) |
143 | ignore &= rtd->codec_dais[i]->component->ignore_pmdown_time; | 152 | ignore &= rtd->codec_dais[i]->component->ignore_pmdown_time; |
144 | 153 | ||
145 | return rtd->cpu_dai->component->ignore_pmdown_time && ignore; | 154 | return ignore; |
146 | } | 155 | } |
147 | 156 | ||
148 | /** | 157 | /** |
@@ -459,7 +468,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
459 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 468 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
460 | struct snd_soc_dai *codec_dai; | 469 | struct snd_soc_dai *codec_dai; |
461 | const char *codec_dai_name = "multicodec"; | 470 | const char *codec_dai_name = "multicodec"; |
462 | int i, ret = 0; | 471 | int i, ret = 0, __ret; |
463 | 472 | ||
464 | pinctrl_pm_select_default_state(cpu_dai->dev); | 473 | pinctrl_pm_select_default_state(cpu_dai->dev); |
465 | for (i = 0; i < rtd->num_codecs; i++) | 474 | for (i = 0; i < rtd->num_codecs; i++) |
@@ -474,7 +483,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
474 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 483 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
475 | 484 | ||
476 | /* startup the audio subsystem */ | 485 | /* startup the audio subsystem */ |
477 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->startup) { | 486 | if (cpu_dai->driver->ops->startup) { |
478 | ret = cpu_dai->driver->ops->startup(substream, cpu_dai); | 487 | ret = cpu_dai->driver->ops->startup(substream, cpu_dai); |
479 | if (ret < 0) { | 488 | if (ret < 0) { |
480 | dev_err(cpu_dai->dev, "ASoC: can't open interface" | 489 | dev_err(cpu_dai->dev, "ASoC: can't open interface" |
@@ -483,7 +492,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
483 | } | 492 | } |
484 | } | 493 | } |
485 | 494 | ||
486 | if (platform->driver->ops && platform->driver->ops->open) { | 495 | if (platform && platform->driver->ops && platform->driver->ops->open) { |
487 | ret = platform->driver->ops->open(substream); | 496 | ret = platform->driver->ops->open(substream); |
488 | if (ret < 0) { | 497 | if (ret < 0) { |
489 | dev_err(platform->dev, "ASoC: can't open platform" | 498 | dev_err(platform->dev, "ASoC: can't open platform" |
@@ -492,9 +501,32 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
492 | } | 501 | } |
493 | } | 502 | } |
494 | 503 | ||
504 | ret = 0; | ||
505 | for_each_rtdcom(rtd, rtdcom) { | ||
506 | component = rtdcom->component; | ||
507 | |||
508 | /* ignore duplication for now */ | ||
509 | if (platform && (component == &platform->component)) | ||
510 | continue; | ||
511 | |||
512 | if (!component->driver->ops || | ||
513 | !component->driver->ops->open) | ||
514 | continue; | ||
515 | |||
516 | __ret = component->driver->ops->open(substream); | ||
517 | if (__ret < 0) { | ||
518 | dev_err(component->dev, | ||
519 | "ASoC: can't open component %s: %d\n", | ||
520 | component->name, ret); | ||
521 | ret = __ret; | ||
522 | } | ||
523 | } | ||
524 | if (ret < 0) | ||
525 | goto component_err; | ||
526 | |||
495 | for (i = 0; i < rtd->num_codecs; i++) { | 527 | for (i = 0; i < rtd->num_codecs; i++) { |
496 | codec_dai = rtd->codec_dais[i]; | 528 | codec_dai = rtd->codec_dais[i]; |
497 | if (codec_dai->driver->ops && codec_dai->driver->ops->startup) { | 529 | if (codec_dai->driver->ops->startup) { |
498 | ret = codec_dai->driver->ops->startup(substream, | 530 | ret = codec_dai->driver->ops->startup(substream, |
499 | codec_dai); | 531 | codec_dai); |
500 | if (ret < 0) { | 532 | if (ret < 0) { |
@@ -511,7 +543,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
511 | codec_dai->rx_mask = 0; | 543 | codec_dai->rx_mask = 0; |
512 | } | 544 | } |
513 | 545 | ||
514 | if (rtd->dai_link->ops && rtd->dai_link->ops->startup) { | 546 | if (rtd->dai_link->ops->startup) { |
515 | ret = rtd->dai_link->ops->startup(substream); | 547 | ret = rtd->dai_link->ops->startup(substream); |
516 | if (ret < 0) { | 548 | if (ret < 0) { |
517 | pr_err("ASoC: %s startup failed: %d\n", | 549 | pr_err("ASoC: %s startup failed: %d\n", |
@@ -585,7 +617,7 @@ dynamic: | |||
585 | return 0; | 617 | return 0; |
586 | 618 | ||
587 | config_err: | 619 | config_err: |
588 | if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown) | 620 | if (rtd->dai_link->ops->shutdown) |
589 | rtd->dai_link->ops->shutdown(substream); | 621 | rtd->dai_link->ops->shutdown(substream); |
590 | 622 | ||
591 | machine_err: | 623 | machine_err: |
@@ -598,7 +630,22 @@ codec_dai_err: | |||
598 | codec_dai->driver->ops->shutdown(substream, codec_dai); | 630 | codec_dai->driver->ops->shutdown(substream, codec_dai); |
599 | } | 631 | } |
600 | 632 | ||
601 | if (platform->driver->ops && platform->driver->ops->close) | 633 | component_err: |
634 | for_each_rtdcom(rtd, rtdcom) { | ||
635 | component = rtdcom->component; | ||
636 | |||
637 | /* ignore duplication for now */ | ||
638 | if (platform && (component == &platform->component)) | ||
639 | continue; | ||
640 | |||
641 | if (!component->driver->ops || | ||
642 | !component->driver->ops->close) | ||
643 | continue; | ||
644 | |||
645 | component->driver->ops->close(substream); | ||
646 | } | ||
647 | |||
648 | if (platform && platform->driver->ops && platform->driver->ops->close) | ||
602 | platform->driver->ops->close(substream); | 649 | platform->driver->ops->close(substream); |
603 | 650 | ||
604 | platform_err: | 651 | platform_err: |
@@ -692,12 +739,26 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) | |||
692 | codec_dai->driver->ops->shutdown(substream, codec_dai); | 739 | codec_dai->driver->ops->shutdown(substream, codec_dai); |
693 | } | 740 | } |
694 | 741 | ||
695 | if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown) | 742 | if (rtd->dai_link->ops->shutdown) |
696 | rtd->dai_link->ops->shutdown(substream); | 743 | rtd->dai_link->ops->shutdown(substream); |
697 | 744 | ||
698 | if (platform->driver->ops && platform->driver->ops->close) | 745 | if (platform && platform->driver->ops && platform->driver->ops->close) |
699 | platform->driver->ops->close(substream); | 746 | platform->driver->ops->close(substream); |
700 | 747 | ||
748 | for_each_rtdcom(rtd, rtdcom) { | ||
749 | component = rtdcom->component; | ||
750 | |||
751 | /* ignore duplication for now */ | ||
752 | if (platform && (component == &platform->component)) | ||
753 | continue; | ||
754 | |||
755 | if (!component->driver->ops || | ||
756 | !component->driver->ops->close) | ||
757 | continue; | ||
758 | |||
759 | component->driver->ops->close(substream); | ||
760 | } | ||
761 | |||
701 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 762 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
702 | if (snd_soc_runtime_ignore_pmdown_time(rtd)) { | 763 | if (snd_soc_runtime_ignore_pmdown_time(rtd)) { |
703 | /* powered down playback stream now */ | 764 | /* powered down playback stream now */ |
@@ -745,13 +806,15 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
745 | { | 806 | { |
746 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 807 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
747 | struct snd_soc_platform *platform = rtd->platform; | 808 | struct snd_soc_platform *platform = rtd->platform; |
809 | struct snd_soc_component *component; | ||
810 | struct snd_soc_rtdcom_list *rtdcom; | ||
748 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 811 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
749 | struct snd_soc_dai *codec_dai; | 812 | struct snd_soc_dai *codec_dai; |
750 | int i, ret = 0; | 813 | int i, ret = 0; |
751 | 814 | ||
752 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 815 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
753 | 816 | ||
754 | if (rtd->dai_link->ops && rtd->dai_link->ops->prepare) { | 817 | if (rtd->dai_link->ops->prepare) { |
755 | ret = rtd->dai_link->ops->prepare(substream); | 818 | ret = rtd->dai_link->ops->prepare(substream); |
756 | if (ret < 0) { | 819 | if (ret < 0) { |
757 | dev_err(rtd->card->dev, "ASoC: machine prepare error:" | 820 | dev_err(rtd->card->dev, "ASoC: machine prepare error:" |
@@ -760,7 +823,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
760 | } | 823 | } |
761 | } | 824 | } |
762 | 825 | ||
763 | if (platform->driver->ops && platform->driver->ops->prepare) { | 826 | if (platform && platform->driver->ops && platform->driver->ops->prepare) { |
764 | ret = platform->driver->ops->prepare(substream); | 827 | ret = platform->driver->ops->prepare(substream); |
765 | if (ret < 0) { | 828 | if (ret < 0) { |
766 | dev_err(platform->dev, "ASoC: platform prepare error:" | 829 | dev_err(platform->dev, "ASoC: platform prepare error:" |
@@ -769,9 +832,28 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
769 | } | 832 | } |
770 | } | 833 | } |
771 | 834 | ||
835 | for_each_rtdcom(rtd, rtdcom) { | ||
836 | component = rtdcom->component; | ||
837 | |||
838 | /* ignore duplication for now */ | ||
839 | if (platform && (component == &platform->component)) | ||
840 | continue; | ||
841 | |||
842 | if (!component->driver->ops || | ||
843 | !component->driver->ops->prepare) | ||
844 | continue; | ||
845 | |||
846 | ret = component->driver->ops->prepare(substream); | ||
847 | if (ret < 0) { | ||
848 | dev_err(component->dev, | ||
849 | "ASoC: platform prepare error: %d\n", ret); | ||
850 | goto out; | ||
851 | } | ||
852 | } | ||
853 | |||
772 | for (i = 0; i < rtd->num_codecs; i++) { | 854 | for (i = 0; i < rtd->num_codecs; i++) { |
773 | codec_dai = rtd->codec_dais[i]; | 855 | codec_dai = rtd->codec_dais[i]; |
774 | if (codec_dai->driver->ops && codec_dai->driver->ops->prepare) { | 856 | if (codec_dai->driver->ops->prepare) { |
775 | ret = codec_dai->driver->ops->prepare(substream, | 857 | ret = codec_dai->driver->ops->prepare(substream, |
776 | codec_dai); | 858 | codec_dai); |
777 | if (ret < 0) { | 859 | if (ret < 0) { |
@@ -783,7 +865,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
783 | } | 865 | } |
784 | } | 866 | } |
785 | 867 | ||
786 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->prepare) { | 868 | if (cpu_dai->driver->ops->prepare) { |
787 | ret = cpu_dai->driver->ops->prepare(substream, cpu_dai); | 869 | ret = cpu_dai->driver->ops->prepare(substream, cpu_dai); |
788 | if (ret < 0) { | 870 | if (ret < 0) { |
789 | dev_err(cpu_dai->dev, | 871 | dev_err(cpu_dai->dev, |
@@ -829,7 +911,7 @@ int soc_dai_hw_params(struct snd_pcm_substream *substream, | |||
829 | { | 911 | { |
830 | int ret; | 912 | int ret; |
831 | 913 | ||
832 | if (dai->driver->ops && dai->driver->ops->hw_params) { | 914 | if (dai->driver->ops->hw_params) { |
833 | ret = dai->driver->ops->hw_params(substream, params, dai); | 915 | ret = dai->driver->ops->hw_params(substream, params, dai); |
834 | if (ret < 0) { | 916 | if (ret < 0) { |
835 | dev_err(dai->dev, "ASoC: can't set %s hw params: %d\n", | 917 | dev_err(dai->dev, "ASoC: can't set %s hw params: %d\n", |
@@ -851,16 +933,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
851 | { | 933 | { |
852 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 934 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
853 | struct snd_soc_platform *platform = rtd->platform; | 935 | struct snd_soc_platform *platform = rtd->platform; |
936 | struct snd_soc_component *component; | ||
937 | struct snd_soc_rtdcom_list *rtdcom; | ||
854 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 938 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
855 | int i, ret = 0; | 939 | int i, ret = 0, __ret; |
856 | 940 | ||
857 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 941 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
858 | 942 | if (rtd->dai_link->ops->hw_params) { | |
859 | ret = soc_pcm_params_symmetry(substream, params); | ||
860 | if (ret) | ||
861 | goto out; | ||
862 | |||
863 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) { | ||
864 | ret = rtd->dai_link->ops->hw_params(substream, params); | 943 | ret = rtd->dai_link->ops->hw_params(substream, params); |
865 | if (ret < 0) { | 944 | if (ret < 0) { |
866 | dev_err(rtd->card->dev, "ASoC: machine hw_params" | 945 | dev_err(rtd->card->dev, "ASoC: machine hw_params" |
@@ -915,7 +994,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
915 | if (ret < 0) | 994 | if (ret < 0) |
916 | goto interface_err; | 995 | goto interface_err; |
917 | 996 | ||
918 | if (platform->driver->ops && platform->driver->ops->hw_params) { | 997 | if (platform && platform->driver->ops && platform->driver->ops->hw_params) { |
919 | ret = platform->driver->ops->hw_params(substream, params); | 998 | ret = platform->driver->ops->hw_params(substream, params); |
920 | if (ret < 0) { | 999 | if (ret < 0) { |
921 | dev_err(platform->dev, "ASoC: %s hw params failed: %d\n", | 1000 | dev_err(platform->dev, "ASoC: %s hw params failed: %d\n", |
@@ -924,18 +1003,62 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
924 | } | 1003 | } |
925 | } | 1004 | } |
926 | 1005 | ||
1006 | ret = 0; | ||
1007 | for_each_rtdcom(rtd, rtdcom) { | ||
1008 | component = rtdcom->component; | ||
1009 | |||
1010 | /* ignore duplication for now */ | ||
1011 | if (platform && (component == &platform->component)) | ||
1012 | continue; | ||
1013 | |||
1014 | if (!component->driver->ops || | ||
1015 | !component->driver->ops->hw_params) | ||
1016 | continue; | ||
1017 | |||
1018 | __ret = component->driver->ops->hw_params(substream, params); | ||
1019 | if (__ret < 0) { | ||
1020 | dev_err(component->dev, | ||
1021 | "ASoC: %s hw params failed: %d\n", | ||
1022 | component->name, ret); | ||
1023 | ret = __ret; | ||
1024 | } | ||
1025 | } | ||
1026 | if (ret < 0) | ||
1027 | goto component_err; | ||
1028 | |||
927 | /* store the parameters for each DAIs */ | 1029 | /* store the parameters for each DAIs */ |
928 | cpu_dai->rate = params_rate(params); | 1030 | cpu_dai->rate = params_rate(params); |
929 | cpu_dai->channels = params_channels(params); | 1031 | cpu_dai->channels = params_channels(params); |
930 | cpu_dai->sample_bits = | 1032 | cpu_dai->sample_bits = |
931 | snd_pcm_format_physical_width(params_format(params)); | 1033 | snd_pcm_format_physical_width(params_format(params)); |
932 | 1034 | ||
1035 | ret = soc_pcm_params_symmetry(substream, params); | ||
1036 | if (ret) | ||
1037 | goto component_err; | ||
933 | out: | 1038 | out: |
934 | mutex_unlock(&rtd->pcm_mutex); | 1039 | mutex_unlock(&rtd->pcm_mutex); |
935 | return ret; | 1040 | return ret; |
936 | 1041 | ||
1042 | component_err: | ||
1043 | for_each_rtdcom(rtd, rtdcom) { | ||
1044 | component = rtdcom->component; | ||
1045 | |||
1046 | /* ignore duplication */ | ||
1047 | if (platform && (component == &platform->component)) | ||
1048 | continue; | ||
1049 | |||
1050 | if (!component->driver->ops || | ||
1051 | !component->driver->ops->hw_free) | ||
1052 | continue; | ||
1053 | |||
1054 | component->driver->ops->hw_free(substream); | ||
1055 | } | ||
1056 | |||
1057 | if (platform && platform->driver->ops && platform->driver->ops->hw_free) | ||
1058 | platform->driver->ops->hw_free(substream); | ||
1059 | |||
937 | platform_err: | 1060 | platform_err: |
938 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free) | 1061 | if (cpu_dai->driver->ops->hw_free) |
939 | cpu_dai->driver->ops->hw_free(substream, cpu_dai); | 1062 | cpu_dai->driver->ops->hw_free(substream, cpu_dai); |
940 | 1063 | ||
941 | interface_err: | 1064 | interface_err: |
@@ -944,12 +1067,12 @@ interface_err: | |||
944 | codec_err: | 1067 | codec_err: |
945 | while (--i >= 0) { | 1068 | while (--i >= 0) { |
946 | struct snd_soc_dai *codec_dai = rtd->codec_dais[i]; | 1069 | struct snd_soc_dai *codec_dai = rtd->codec_dais[i]; |
947 | if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free) | 1070 | if (codec_dai->driver->ops->hw_free) |
948 | codec_dai->driver->ops->hw_free(substream, codec_dai); | 1071 | codec_dai->driver->ops->hw_free(substream, codec_dai); |
949 | codec_dai->rate = 0; | 1072 | codec_dai->rate = 0; |
950 | } | 1073 | } |
951 | 1074 | ||
952 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free) | 1075 | if (rtd->dai_link->ops->hw_free) |
953 | rtd->dai_link->ops->hw_free(substream); | 1076 | rtd->dai_link->ops->hw_free(substream); |
954 | 1077 | ||
955 | mutex_unlock(&rtd->pcm_mutex); | 1078 | mutex_unlock(&rtd->pcm_mutex); |
@@ -963,6 +1086,8 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |||
963 | { | 1086 | { |
964 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1087 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
965 | struct snd_soc_platform *platform = rtd->platform; | 1088 | struct snd_soc_platform *platform = rtd->platform; |
1089 | struct snd_soc_component *component; | ||
1090 | struct snd_soc_rtdcom_list *rtdcom; | ||
966 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1091 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
967 | struct snd_soc_dai *codec_dai; | 1092 | struct snd_soc_dai *codec_dai; |
968 | bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | 1093 | bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
@@ -995,21 +1120,36 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |||
995 | } | 1120 | } |
996 | 1121 | ||
997 | /* free any machine hw params */ | 1122 | /* free any machine hw params */ |
998 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free) | 1123 | if (rtd->dai_link->ops->hw_free) |
999 | rtd->dai_link->ops->hw_free(substream); | 1124 | rtd->dai_link->ops->hw_free(substream); |
1000 | 1125 | ||
1001 | /* free any DMA resources */ | 1126 | /* free any DMA resources */ |
1002 | if (platform->driver->ops && platform->driver->ops->hw_free) | 1127 | if (platform && platform->driver->ops && platform->driver->ops->hw_free) |
1003 | platform->driver->ops->hw_free(substream); | 1128 | platform->driver->ops->hw_free(substream); |
1004 | 1129 | ||
1130 | /* free any component resources */ | ||
1131 | for_each_rtdcom(rtd, rtdcom) { | ||
1132 | component = rtdcom->component; | ||
1133 | |||
1134 | /* ignore duplication for now */ | ||
1135 | if (platform && (component == &platform->component)) | ||
1136 | continue; | ||
1137 | |||
1138 | if (!component->driver->ops || | ||
1139 | !component->driver->ops->hw_free) | ||
1140 | continue; | ||
1141 | |||
1142 | component->driver->ops->hw_free(substream); | ||
1143 | } | ||
1144 | |||
1005 | /* now free hw params for the DAIs */ | 1145 | /* now free hw params for the DAIs */ |
1006 | for (i = 0; i < rtd->num_codecs; i++) { | 1146 | for (i = 0; i < rtd->num_codecs; i++) { |
1007 | codec_dai = rtd->codec_dais[i]; | 1147 | codec_dai = rtd->codec_dais[i]; |
1008 | if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free) | 1148 | if (codec_dai->driver->ops->hw_free) |
1009 | codec_dai->driver->ops->hw_free(substream, codec_dai); | 1149 | codec_dai->driver->ops->hw_free(substream, codec_dai); |
1010 | } | 1150 | } |
1011 | 1151 | ||
1012 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free) | 1152 | if (cpu_dai->driver->ops->hw_free) |
1013 | cpu_dai->driver->ops->hw_free(substream, cpu_dai); | 1153 | cpu_dai->driver->ops->hw_free(substream, cpu_dai); |
1014 | 1154 | ||
1015 | mutex_unlock(&rtd->pcm_mutex); | 1155 | mutex_unlock(&rtd->pcm_mutex); |
@@ -1020,13 +1160,15 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1020 | { | 1160 | { |
1021 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1161 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
1022 | struct snd_soc_platform *platform = rtd->platform; | 1162 | struct snd_soc_platform *platform = rtd->platform; |
1163 | struct snd_soc_component *component; | ||
1164 | struct snd_soc_rtdcom_list *rtdcom; | ||
1023 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1165 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
1024 | struct snd_soc_dai *codec_dai; | 1166 | struct snd_soc_dai *codec_dai; |
1025 | int i, ret; | 1167 | int i, ret; |
1026 | 1168 | ||
1027 | for (i = 0; i < rtd->num_codecs; i++) { | 1169 | for (i = 0; i < rtd->num_codecs; i++) { |
1028 | codec_dai = rtd->codec_dais[i]; | 1170 | codec_dai = rtd->codec_dais[i]; |
1029 | if (codec_dai->driver->ops && codec_dai->driver->ops->trigger) { | 1171 | if (codec_dai->driver->ops->trigger) { |
1030 | ret = codec_dai->driver->ops->trigger(substream, | 1172 | ret = codec_dai->driver->ops->trigger(substream, |
1031 | cmd, codec_dai); | 1173 | cmd, codec_dai); |
1032 | if (ret < 0) | 1174 | if (ret < 0) |
@@ -1034,19 +1176,35 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
1034 | } | 1176 | } |
1035 | } | 1177 | } |
1036 | 1178 | ||
1037 | if (platform->driver->ops && platform->driver->ops->trigger) { | 1179 | if (platform && platform->driver->ops && platform->driver->ops->trigger) { |
1038 | ret = platform->driver->ops->trigger(substream, cmd); | 1180 | ret = platform->driver->ops->trigger(substream, cmd); |
1039 | if (ret < 0) | 1181 | if (ret < 0) |
1040 | return ret; | 1182 | return ret; |
1041 | } | 1183 | } |
1042 | 1184 | ||
1043 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->trigger) { | 1185 | for_each_rtdcom(rtd, rtdcom) { |
1186 | component = rtdcom->component; | ||
1187 | |||
1188 | /* ignore duplication for now */ | ||
1189 | if (platform && (component == &platform->component)) | ||
1190 | continue; | ||
1191 | |||
1192 | if (!component->driver->ops || | ||
1193 | !component->driver->ops->trigger) | ||
1194 | continue; | ||
1195 | |||
1196 | ret = component->driver->ops->trigger(substream, cmd); | ||
1197 | if (ret < 0) | ||
1198 | return ret; | ||
1199 | } | ||
1200 | |||
1201 | if (cpu_dai->driver->ops->trigger) { | ||
1044 | ret = cpu_dai->driver->ops->trigger(substream, cmd, cpu_dai); | 1202 | ret = cpu_dai->driver->ops->trigger(substream, cmd, cpu_dai); |
1045 | if (ret < 0) | 1203 | if (ret < 0) |
1046 | return ret; | 1204 | return ret; |
1047 | } | 1205 | } |
1048 | 1206 | ||
1049 | if (rtd->dai_link->ops && rtd->dai_link->ops->trigger) { | 1207 | if (rtd->dai_link->ops->trigger) { |
1050 | ret = rtd->dai_link->ops->trigger(substream, cmd); | 1208 | ret = rtd->dai_link->ops->trigger(substream, cmd); |
1051 | if (ret < 0) | 1209 | if (ret < 0) |
1052 | return ret; | 1210 | return ret; |
@@ -1065,8 +1223,7 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream, | |||
1065 | 1223 | ||
1066 | for (i = 0; i < rtd->num_codecs; i++) { | 1224 | for (i = 0; i < rtd->num_codecs; i++) { |
1067 | codec_dai = rtd->codec_dais[i]; | 1225 | codec_dai = rtd->codec_dais[i]; |
1068 | if (codec_dai->driver->ops && | 1226 | if (codec_dai->driver->ops->bespoke_trigger) { |
1069 | codec_dai->driver->ops->bespoke_trigger) { | ||
1070 | ret = codec_dai->driver->ops->bespoke_trigger(substream, | 1227 | ret = codec_dai->driver->ops->bespoke_trigger(substream, |
1071 | cmd, codec_dai); | 1228 | cmd, codec_dai); |
1072 | if (ret < 0) | 1229 | if (ret < 0) |
@@ -1074,7 +1231,7 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream, | |||
1074 | } | 1231 | } |
1075 | } | 1232 | } |
1076 | 1233 | ||
1077 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->bespoke_trigger) { | 1234 | if (cpu_dai->driver->ops->bespoke_trigger) { |
1078 | ret = cpu_dai->driver->ops->bespoke_trigger(substream, cmd, cpu_dai); | 1235 | ret = cpu_dai->driver->ops->bespoke_trigger(substream, cmd, cpu_dai); |
1079 | if (ret < 0) | 1236 | if (ret < 0) |
1080 | return ret; | 1237 | return ret; |
@@ -1090,6 +1247,8 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) | |||
1090 | { | 1247 | { |
1091 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1248 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
1092 | struct snd_soc_platform *platform = rtd->platform; | 1249 | struct snd_soc_platform *platform = rtd->platform; |
1250 | struct snd_soc_component *component; | ||
1251 | struct snd_soc_rtdcom_list *rtdcom; | ||
1093 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1252 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
1094 | struct snd_soc_dai *codec_dai; | 1253 | struct snd_soc_dai *codec_dai; |
1095 | struct snd_pcm_runtime *runtime = substream->runtime; | 1254 | struct snd_pcm_runtime *runtime = substream->runtime; |
@@ -1098,15 +1257,31 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) | |||
1098 | snd_pcm_sframes_t codec_delay = 0; | 1257 | snd_pcm_sframes_t codec_delay = 0; |
1099 | int i; | 1258 | int i; |
1100 | 1259 | ||
1101 | if (platform->driver->ops && platform->driver->ops->pointer) | 1260 | if (platform && platform->driver->ops && platform->driver->ops->pointer) |
1102 | offset = platform->driver->ops->pointer(substream); | 1261 | offset = platform->driver->ops->pointer(substream); |
1103 | 1262 | ||
1104 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->delay) | 1263 | for_each_rtdcom(rtd, rtdcom) { |
1264 | component = rtdcom->component; | ||
1265 | |||
1266 | /* ignore duplication for now */ | ||
1267 | if (platform && (component == &platform->component)) | ||
1268 | continue; | ||
1269 | |||
1270 | if (!component->driver->ops || | ||
1271 | !component->driver->ops->pointer) | ||
1272 | continue; | ||
1273 | |||
1274 | /* FIXME: use 1st pointer */ | ||
1275 | offset = component->driver->ops->pointer(substream); | ||
1276 | break; | ||
1277 | } | ||
1278 | |||
1279 | if (cpu_dai->driver->ops->delay) | ||
1105 | delay += cpu_dai->driver->ops->delay(substream, cpu_dai); | 1280 | delay += cpu_dai->driver->ops->delay(substream, cpu_dai); |
1106 | 1281 | ||
1107 | for (i = 0; i < rtd->num_codecs; i++) { | 1282 | for (i = 0; i < rtd->num_codecs; i++) { |
1108 | codec_dai = rtd->codec_dais[i]; | 1283 | codec_dai = rtd->codec_dais[i]; |
1109 | if (codec_dai->driver->ops && codec_dai->driver->ops->delay) | 1284 | if (codec_dai->driver->ops->delay) |
1110 | codec_delay = max(codec_delay, | 1285 | codec_delay = max(codec_delay, |
1111 | codec_dai->driver->ops->delay(substream, | 1286 | codec_dai->driver->ops->delay(substream, |
1112 | codec_dai)); | 1287 | codec_dai)); |
@@ -2285,9 +2460,27 @@ static int soc_pcm_ioctl(struct snd_pcm_substream *substream, | |||
2285 | { | 2460 | { |
2286 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 2461 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
2287 | struct snd_soc_platform *platform = rtd->platform; | 2462 | struct snd_soc_platform *platform = rtd->platform; |
2463 | struct snd_soc_component *component; | ||
2464 | struct snd_soc_rtdcom_list *rtdcom; | ||
2288 | 2465 | ||
2289 | if (platform->driver->ops && platform->driver->ops->ioctl) | 2466 | if (platform && platform->driver->ops && platform->driver->ops->ioctl) |
2290 | return platform->driver->ops->ioctl(substream, cmd, arg); | 2467 | return platform->driver->ops->ioctl(substream, cmd, arg); |
2468 | |||
2469 | for_each_rtdcom(rtd, rtdcom) { | ||
2470 | component = rtdcom->component; | ||
2471 | |||
2472 | /* ignore duplication for now */ | ||
2473 | if (platform && (component == &platform->component)) | ||
2474 | continue; | ||
2475 | |||
2476 | if (!component->driver->ops || | ||
2477 | !component->driver->ops->ioctl) | ||
2478 | continue; | ||
2479 | |||
2480 | /* FIXME: use 1st ioctl */ | ||
2481 | return component->driver->ops->ioctl(substream, cmd, arg); | ||
2482 | } | ||
2483 | |||
2291 | return snd_pcm_lib_ioctl(substream, cmd, arg); | 2484 | return snd_pcm_lib_ioctl(substream, cmd, arg); |
2292 | } | 2485 | } |
2293 | 2486 | ||
@@ -2635,12 +2828,150 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream) | |||
2635 | static void soc_pcm_private_free(struct snd_pcm *pcm) | 2828 | static void soc_pcm_private_free(struct snd_pcm *pcm) |
2636 | { | 2829 | { |
2637 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; | 2830 | struct snd_soc_pcm_runtime *rtd = pcm->private_data; |
2638 | struct snd_soc_platform *platform = rtd->platform; | 2831 | struct snd_soc_rtdcom_list *rtdcom; |
2832 | struct snd_soc_component *component; | ||
2833 | |||
2834 | for_each_rtdcom(rtd, rtdcom) { | ||
2835 | /* need to sync the delayed work before releasing resources */ | ||
2836 | |||
2837 | flush_delayed_work(&rtd->delayed_work); | ||
2838 | component = rtdcom->component; | ||
2839 | |||
2840 | if (component->pcm_free) | ||
2841 | component->pcm_free(component, pcm); | ||
2842 | } | ||
2843 | } | ||
2844 | |||
2845 | static int soc_rtdcom_ack(struct snd_pcm_substream *substream) | ||
2846 | { | ||
2847 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
2848 | struct snd_soc_rtdcom_list *rtdcom; | ||
2849 | struct snd_soc_component *component; | ||
2850 | |||
2851 | for_each_rtdcom(rtd, rtdcom) { | ||
2852 | component = rtdcom->component; | ||
2853 | |||
2854 | if (!component->driver->ops || | ||
2855 | !component->driver->ops->ack) | ||
2856 | continue; | ||
2857 | |||
2858 | /* FIXME. it returns 1st ask now */ | ||
2859 | return component->driver->ops->ack(substream); | ||
2860 | } | ||
2861 | |||
2862 | return -EINVAL; | ||
2863 | } | ||
2864 | |||
2865 | static int soc_rtdcom_copy_user(struct snd_pcm_substream *substream, int channel, | ||
2866 | unsigned long pos, void __user *buf, | ||
2867 | unsigned long bytes) | ||
2868 | { | ||
2869 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
2870 | struct snd_soc_rtdcom_list *rtdcom; | ||
2871 | struct snd_soc_component *component; | ||
2872 | |||
2873 | for_each_rtdcom(rtd, rtdcom) { | ||
2874 | component = rtdcom->component; | ||
2875 | |||
2876 | if (!component->driver->ops || | ||
2877 | !component->driver->ops->copy_user) | ||
2878 | continue; | ||
2879 | |||
2880 | /* FIXME. it returns 1st copy now */ | ||
2881 | return component->driver->ops->copy_user(substream, channel, | ||
2882 | pos, buf, bytes); | ||
2883 | } | ||
2884 | |||
2885 | return -EINVAL; | ||
2886 | } | ||
2887 | |||
2888 | static int soc_rtdcom_copy_kernel(struct snd_pcm_substream *substream, int channel, | ||
2889 | unsigned long pos, void *buf, unsigned long bytes) | ||
2890 | { | ||
2891 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
2892 | struct snd_soc_rtdcom_list *rtdcom; | ||
2893 | struct snd_soc_component *component; | ||
2894 | |||
2895 | for_each_rtdcom(rtd, rtdcom) { | ||
2896 | component = rtdcom->component; | ||
2639 | 2897 | ||
2640 | /* need to sync the delayed work before releasing resources */ | 2898 | if (!component->driver->ops || |
2641 | flush_delayed_work(&rtd->delayed_work); | 2899 | !component->driver->ops->copy_kernel) |
2642 | if (platform->driver->pcm_free) | 2900 | continue; |
2643 | platform->driver->pcm_free(pcm); | 2901 | |
2902 | /* FIXME. it returns 1st copy now */ | ||
2903 | return component->driver->ops->copy_kernel(substream, channel, | ||
2904 | pos, buf, bytes); | ||
2905 | } | ||
2906 | |||
2907 | return -EINVAL; | ||
2908 | } | ||
2909 | |||
2910 | static int soc_rtdcom_fill_silence(struct snd_pcm_substream *substream, int channel, | ||
2911 | unsigned long pos, unsigned long bytes) | ||
2912 | { | ||
2913 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
2914 | struct snd_soc_rtdcom_list *rtdcom; | ||
2915 | struct snd_soc_component *component; | ||
2916 | |||
2917 | for_each_rtdcom(rtd, rtdcom) { | ||
2918 | component = rtdcom->component; | ||
2919 | |||
2920 | if (!component->driver->ops || | ||
2921 | !component->driver->ops->fill_silence) | ||
2922 | continue; | ||
2923 | |||
2924 | /* FIXME. it returns 1st silence now */ | ||
2925 | return component->driver->ops->fill_silence(substream, channel, | ||
2926 | pos, bytes); | ||
2927 | } | ||
2928 | |||
2929 | return -EINVAL; | ||
2930 | } | ||
2931 | |||
2932 | static struct page *soc_rtdcom_page(struct snd_pcm_substream *substream, | ||
2933 | unsigned long offset) | ||
2934 | { | ||
2935 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
2936 | struct snd_soc_rtdcom_list *rtdcom; | ||
2937 | struct snd_soc_component *component; | ||
2938 | struct page *page; | ||
2939 | |||
2940 | for_each_rtdcom(rtd, rtdcom) { | ||
2941 | component = rtdcom->component; | ||
2942 | |||
2943 | if (!component->driver->ops || | ||
2944 | !component->driver->ops->page) | ||
2945 | continue; | ||
2946 | |||
2947 | /* FIXME. it returns 1st page now */ | ||
2948 | page = component->driver->ops->page(substream, offset); | ||
2949 | if (page) | ||
2950 | return page; | ||
2951 | } | ||
2952 | |||
2953 | return NULL; | ||
2954 | } | ||
2955 | |||
2956 | static int soc_rtdcom_mmap(struct snd_pcm_substream *substream, | ||
2957 | struct vm_area_struct *vma) | ||
2958 | { | ||
2959 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
2960 | struct snd_soc_rtdcom_list *rtdcom; | ||
2961 | struct snd_soc_component *component; | ||
2962 | |||
2963 | for_each_rtdcom(rtd, rtdcom) { | ||
2964 | component = rtdcom->component; | ||
2965 | |||
2966 | if (!component->driver->ops || | ||
2967 | !component->driver->ops->mmap) | ||
2968 | continue; | ||
2969 | |||
2970 | /* FIXME. it returns 1st mmap now */ | ||
2971 | return component->driver->ops->mmap(substream, vma); | ||
2972 | } | ||
2973 | |||
2974 | return -EINVAL; | ||
2644 | } | 2975 | } |
2645 | 2976 | ||
2646 | /* create a new pcm */ | 2977 | /* create a new pcm */ |
@@ -2649,6 +2980,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
2649 | struct snd_soc_platform *platform = rtd->platform; | 2980 | struct snd_soc_platform *platform = rtd->platform; |
2650 | struct snd_soc_dai *codec_dai; | 2981 | struct snd_soc_dai *codec_dai; |
2651 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 2982 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
2983 | struct snd_soc_component *component; | ||
2984 | struct snd_soc_rtdcom_list *rtdcom; | ||
2652 | struct snd_pcm *pcm; | 2985 | struct snd_pcm *pcm; |
2653 | char new_name[64]; | 2986 | char new_name[64]; |
2654 | int ret = 0, playback = 0, capture = 0; | 2987 | int ret = 0, playback = 0, capture = 0; |
@@ -2743,7 +3076,28 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
2743 | rtd->ops.ioctl = soc_pcm_ioctl; | 3076 | rtd->ops.ioctl = soc_pcm_ioctl; |
2744 | } | 3077 | } |
2745 | 3078 | ||
2746 | if (platform->driver->ops) { | 3079 | for_each_rtdcom(rtd, rtdcom) { |
3080 | const struct snd_pcm_ops *ops = rtdcom->component->driver->ops; | ||
3081 | |||
3082 | if (!ops) | ||
3083 | continue; | ||
3084 | |||
3085 | if (ops->ack) | ||
3086 | rtd->ops.ack = soc_rtdcom_ack; | ||
3087 | if (ops->copy_user) | ||
3088 | rtd->ops.copy_user = soc_rtdcom_copy_user; | ||
3089 | if (ops->copy_kernel) | ||
3090 | rtd->ops.copy_kernel = soc_rtdcom_copy_kernel; | ||
3091 | if (ops->fill_silence) | ||
3092 | rtd->ops.fill_silence = soc_rtdcom_fill_silence; | ||
3093 | if (ops->page) | ||
3094 | rtd->ops.page = soc_rtdcom_page; | ||
3095 | if (ops->mmap) | ||
3096 | rtd->ops.mmap = soc_rtdcom_mmap; | ||
3097 | } | ||
3098 | |||
3099 | /* overwrite */ | ||
3100 | if (platform && platform->driver->ops) { | ||
2747 | rtd->ops.ack = platform->driver->ops->ack; | 3101 | rtd->ops.ack = platform->driver->ops->ack; |
2748 | rtd->ops.copy_user = platform->driver->ops->copy_user; | 3102 | rtd->ops.copy_user = platform->driver->ops->copy_user; |
2749 | rtd->ops.copy_kernel = platform->driver->ops->copy_kernel; | 3103 | rtd->ops.copy_kernel = platform->driver->ops->copy_kernel; |
@@ -2758,10 +3112,15 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
2758 | if (capture) | 3112 | if (capture) |
2759 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); | 3113 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &rtd->ops); |
2760 | 3114 | ||
2761 | if (platform->driver->pcm_new) { | 3115 | for_each_rtdcom(rtd, rtdcom) { |
2762 | ret = platform->driver->pcm_new(rtd); | 3116 | component = rtdcom->component; |
3117 | |||
3118 | if (!component->pcm_new) | ||
3119 | continue; | ||
3120 | |||
3121 | ret = component->pcm_new(component, rtd); | ||
2763 | if (ret < 0) { | 3122 | if (ret < 0) { |
2764 | dev_err(platform->dev, | 3123 | dev_err(component->dev, |
2765 | "ASoC: pcm constructor failed: %d\n", | 3124 | "ASoC: pcm constructor failed: %d\n", |
2766 | ret); | 3125 | ret); |
2767 | return ret; | 3126 | return ret; |