hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/include/sound/soc-dai.h
....@@ -39,7 +39,7 @@
3939 /*
4040 * DAI Clock gating.
4141 *
42
- * DAI bit clocks can be be gated (disabled) when the DAI is not
42
+ * DAI bit clocks can be gated (disabled) when the DAI is not
4343 * sending or receiving PCM data in a frame. This can be used to save power.
4444 */
4545 #define SND_SOC_DAIFMT_CONT (1 << 4) /* continuous clock */
....@@ -76,12 +76,12 @@
7676 *
7777 * This is wrt the codec, the inverse is true for the interface
7878 * i.e. if the codec is clk and FRM master then the interface is
79
- * clk and frame slave.
79
+ * clk and frame secondary.
8080 */
8181 #define SND_SOC_DAIFMT_CBM_CFM (1 << 12) /* codec clk & FRM master */
82
-#define SND_SOC_DAIFMT_CBS_CFM (2 << 12) /* codec clk slave & FRM master */
83
-#define SND_SOC_DAIFMT_CBM_CFS (3 << 12) /* codec clk master & frame slave */
84
-#define SND_SOC_DAIFMT_CBS_CFS (4 << 12) /* codec clk & FRM slave */
82
+#define SND_SOC_DAIFMT_CBS_CFM (2 << 12) /* codec clk secondary & FRM master */
83
+#define SND_SOC_DAIFMT_CBM_CFS (3 << 12) /* codec clk master & frame secondary */
84
+#define SND_SOC_DAIFMT_CBS_CFS (4 << 12) /* codec clk & FRM secondary */
8585
8686 #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
8787 #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
....@@ -145,6 +145,70 @@
145145
146146 int snd_soc_dai_is_dummy(struct snd_soc_dai *dai);
147147
148
+int snd_soc_dai_hw_params(struct snd_soc_dai *dai,
149
+ struct snd_pcm_substream *substream,
150
+ struct snd_pcm_hw_params *params);
151
+void snd_soc_dai_hw_free(struct snd_soc_dai *dai,
152
+ struct snd_pcm_substream *substream);
153
+int snd_soc_dai_startup(struct snd_soc_dai *dai,
154
+ struct snd_pcm_substream *substream);
155
+void snd_soc_dai_shutdown(struct snd_soc_dai *dai,
156
+ struct snd_pcm_substream *substream, int rollback);
157
+snd_pcm_sframes_t snd_soc_dai_delay(struct snd_soc_dai *dai,
158
+ struct snd_pcm_substream *substream);
159
+void snd_soc_dai_suspend(struct snd_soc_dai *dai);
160
+void snd_soc_dai_resume(struct snd_soc_dai *dai);
161
+int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
162
+ struct snd_soc_pcm_runtime *rtd, int num);
163
+bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream);
164
+void snd_soc_dai_link_set_capabilities(struct snd_soc_dai_link *dai_link);
165
+void snd_soc_dai_action(struct snd_soc_dai *dai,
166
+ int stream, int action);
167
+static inline void snd_soc_dai_activate(struct snd_soc_dai *dai,
168
+ int stream)
169
+{
170
+ snd_soc_dai_action(dai, stream, 1);
171
+}
172
+static inline void snd_soc_dai_deactivate(struct snd_soc_dai *dai,
173
+ int stream)
174
+{
175
+ snd_soc_dai_action(dai, stream, -1);
176
+}
177
+int snd_soc_dai_active(struct snd_soc_dai *dai);
178
+
179
+int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order);
180
+int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order);
181
+int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd);
182
+int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream);
183
+int snd_soc_pcm_dai_trigger(struct snd_pcm_substream *substream, int cmd);
184
+int snd_soc_pcm_dai_bespoke_trigger(struct snd_pcm_substream *substream,
185
+ int cmd);
186
+
187
+int snd_soc_dai_compr_startup(struct snd_soc_dai *dai,
188
+ struct snd_compr_stream *cstream);
189
+void snd_soc_dai_compr_shutdown(struct snd_soc_dai *dai,
190
+ struct snd_compr_stream *cstream);
191
+int snd_soc_dai_compr_trigger(struct snd_soc_dai *dai,
192
+ struct snd_compr_stream *cstream, int cmd);
193
+int snd_soc_dai_compr_set_params(struct snd_soc_dai *dai,
194
+ struct snd_compr_stream *cstream,
195
+ struct snd_compr_params *params);
196
+int snd_soc_dai_compr_get_params(struct snd_soc_dai *dai,
197
+ struct snd_compr_stream *cstream,
198
+ struct snd_codec *params);
199
+int snd_soc_dai_compr_ack(struct snd_soc_dai *dai,
200
+ struct snd_compr_stream *cstream,
201
+ size_t bytes);
202
+int snd_soc_dai_compr_pointer(struct snd_soc_dai *dai,
203
+ struct snd_compr_stream *cstream,
204
+ struct snd_compr_tstamp *tstamp);
205
+int snd_soc_dai_compr_set_metadata(struct snd_soc_dai *dai,
206
+ struct snd_compr_stream *cstream,
207
+ struct snd_compr_metadata *metadata);
208
+int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
209
+ struct snd_compr_stream *cstream,
210
+ struct snd_compr_metadata *metadata);
211
+
148212 struct snd_soc_dai_ops {
149213 /*
150214 * DAI clocking configuration, all optional.
....@@ -177,11 +241,12 @@
177241
178242 int (*set_sdw_stream)(struct snd_soc_dai *dai,
179243 void *stream, int direction);
244
+ void *(*get_sdw_stream)(struct snd_soc_dai *dai, int direction);
245
+
180246 /*
181247 * DAI digital mute - optional.
182248 * Called by soc-core to minimise any pops.
183249 */
184
- int (*digital_mute)(struct snd_soc_dai *dai, int mute);
185250 int (*mute_stream)(struct snd_soc_dai *dai, int mute, int stream);
186251
187252 /*
....@@ -215,6 +280,9 @@
215280 */
216281 snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
217282 struct snd_soc_dai *);
283
+
284
+ /* bit field */
285
+ unsigned int no_capture_mute:1;
218286 };
219287
220288 struct snd_soc_cdai_ops {
....@@ -261,15 +329,11 @@
261329 /* DAI driver callbacks */
262330 int (*probe)(struct snd_soc_dai *dai);
263331 int (*remove)(struct snd_soc_dai *dai);
264
- int (*suspend)(struct snd_soc_dai *dai);
265
- int (*resume)(struct snd_soc_dai *dai);
266332 /* compress dai */
267333 int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num);
268334 /* Optional Callback used at pcm creation*/
269335 int (*pcm_new)(struct snd_soc_pcm_runtime *rtd,
270336 struct snd_soc_dai *dai);
271
- /* DAI is also used for the control bus */
272
- bool bus_control;
273337
274338 /* ops */
275339 const struct snd_soc_dai_ops *ops;
....@@ -301,11 +365,7 @@
301365 struct snd_soc_dai_driver *driver;
302366
303367 /* DAI runtime info */
304
- unsigned int capture_active; /* stream usage count */
305
- unsigned int playback_active; /* stream usage count */
306
- unsigned int probed:1;
307
-
308
- unsigned int active;
368
+ unsigned int stream_active[SNDRV_PCM_STREAM_LAST + 1]; /* usage count */
309369
310370 struct snd_soc_dapm_widget *playback_widget;
311371 struct snd_soc_dapm_widget *capture_widget;
....@@ -327,7 +387,28 @@
327387 unsigned int rx_mask;
328388
329389 struct list_head list;
390
+
391
+ /* function mark */
392
+ struct snd_pcm_substream *mark_startup;
393
+
394
+ /* bit field */
395
+ unsigned int probed:1;
330396 };
397
+
398
+static inline struct snd_soc_pcm_stream *
399
+snd_soc_dai_get_pcm_stream(const struct snd_soc_dai *dai, int stream)
400
+{
401
+ return (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
402
+ &dai->driver->playback : &dai->driver->capture;
403
+}
404
+
405
+static inline
406
+struct snd_soc_dapm_widget *snd_soc_dai_get_widget(
407
+ struct snd_soc_dai *dai, int stream)
408
+{
409
+ return (stream == SNDRV_PCM_STREAM_PLAYBACK) ?
410
+ dai->playback_widget : dai->capture_widget;
411
+}
331412
332413 static inline void *snd_soc_dai_get_dma_data(const struct snd_soc_dai *dai,
333414 const struct snd_pcm_substream *ss)
....@@ -385,4 +466,30 @@
385466 return -ENOTSUPP;
386467 }
387468
469
+/**
470
+ * snd_soc_dai_get_sdw_stream() - Retrieves SDW stream from DAI
471
+ * @dai: DAI
472
+ * @direction: Stream direction(Playback/Capture)
473
+ *
474
+ * This routine only retrieves that was previously configured
475
+ * with snd_soc_dai_get_sdw_stream()
476
+ *
477
+ * Returns pointer to stream or an ERR_PTR value, e.g.
478
+ * ERR_PTR(-ENOTSUPP) if callback is not supported;
479
+ */
480
+static inline void *snd_soc_dai_get_sdw_stream(struct snd_soc_dai *dai,
481
+ int direction)
482
+{
483
+ if (dai->driver->ops->get_sdw_stream)
484
+ return dai->driver->ops->get_sdw_stream(dai, direction);
485
+ else
486
+ return ERR_PTR(-ENOTSUPP);
487
+}
488
+
489
+static inline unsigned int
490
+snd_soc_dai_stream_active(struct snd_soc_dai *dai, int stream)
491
+{
492
+ return dai->stream_active[stream];
493
+}
494
+
388495 #endif