]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - sound/soc/soc-link.c
Merge tag 'io_uring-5.9-2020-08-21' of git://git.kernel.dk/linux-block
[mirror_ubuntu-jammy-kernel.git] / sound / soc / soc-link.c
CommitLineData
02e75636
KM
1// SPDX-License-Identifier: GPL-2.0
2//
3// soc-link.c
4//
5// Copyright (C) 2019 Renesas Electronics Corp.
6// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7//
8#include <sound/soc.h>
9#include <sound/soc-link.h>
10
11#define soc_link_ret(rtd, ret) _soc_link_ret(rtd, __func__, ret)
12static inline int _soc_link_ret(struct snd_soc_pcm_runtime *rtd,
13 const char *func, int ret)
14{
28ff437a
PLB
15 /* Positive, Zero values are not errors */
16 if (ret >= 0)
17 return ret;
18
19 /* Negative values might be errors */
02e75636
KM
20 switch (ret) {
21 case -EPROBE_DEFER:
22 case -ENOTSUPP:
02e75636
KM
23 break;
24 default:
25 dev_err(rtd->dev,
26 "ASoC: error at %s on %s: %d\n",
27 func, rtd->dai_link->name, ret);
28 }
29
30 return ret;
31}
32
33int snd_soc_link_init(struct snd_soc_pcm_runtime *rtd)
34{
35 int ret = 0;
36
37 if (rtd->dai_link->init)
38 ret = rtd->dai_link->init(rtd);
39
40 return soc_link_ret(rtd, ret);
41}
a5e6c109 42
21a00fb3
PLB
43void snd_soc_link_exit(struct snd_soc_pcm_runtime *rtd)
44{
45 if (rtd->dai_link->exit)
46 rtd->dai_link->exit(rtd);
47}
48
0cbbf8a0
KM
49int snd_soc_link_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
50 struct snd_pcm_hw_params *params)
51{
52 int ret = 0;
53
54 if (rtd->dai_link->be_hw_params_fixup)
55 ret = rtd->dai_link->be_hw_params_fixup(rtd, params);
56
57 return soc_link_ret(rtd, ret);
58}
59
7cf3c5b4 60int snd_soc_link_startup(struct snd_pcm_substream *substream)
a5e6c109 61{
0ceef681 62 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
a5e6c109
KM
63 int ret = 0;
64
65 if (rtd->dai_link->ops &&
66 rtd->dai_link->ops->startup)
67 ret = rtd->dai_link->ops->startup(substream);
68
69 return soc_link_ret(rtd, ret);
70}
71
7cf3c5b4 72void snd_soc_link_shutdown(struct snd_pcm_substream *substream)
a5e6c109 73{
0ceef681 74 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
7cf3c5b4 75
a5e6c109
KM
76 if (rtd->dai_link->ops &&
77 rtd->dai_link->ops->shutdown)
78 rtd->dai_link->ops->shutdown(substream);
79}
80
7cf3c5b4 81int snd_soc_link_prepare(struct snd_pcm_substream *substream)
a5e6c109 82{
0ceef681 83 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
a5e6c109
KM
84 int ret = 0;
85
86 if (rtd->dai_link->ops &&
87 rtd->dai_link->ops->prepare)
88 ret = rtd->dai_link->ops->prepare(substream);
89
90 return soc_link_ret(rtd, ret);
91}
92
7cf3c5b4 93int snd_soc_link_hw_params(struct snd_pcm_substream *substream,
a5e6c109
KM
94 struct snd_pcm_hw_params *params)
95{
0ceef681 96 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
a5e6c109
KM
97 int ret = 0;
98
99 if (rtd->dai_link->ops &&
100 rtd->dai_link->ops->hw_params)
101 ret = rtd->dai_link->ops->hw_params(substream, params);
102
103 return soc_link_ret(rtd, ret);
104}
105
7cf3c5b4 106void snd_soc_link_hw_free(struct snd_pcm_substream *substream)
a5e6c109 107{
0ceef681 108 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
7cf3c5b4 109
a5e6c109
KM
110 if (rtd->dai_link->ops &&
111 rtd->dai_link->ops->hw_free)
112 rtd->dai_link->ops->hw_free(substream);
113}
114
7cf3c5b4 115int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd)
a5e6c109 116{
0ceef681 117 struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
a5e6c109
KM
118 int ret = 0;
119
120 if (rtd->dai_link->ops &&
121 rtd->dai_link->ops->trigger)
122 ret = rtd->dai_link->ops->trigger(substream, cmd);
123
124 return soc_link_ret(rtd, ret);
125}
9ab711cb
KM
126
127int snd_soc_link_compr_startup(struct snd_compr_stream *cstream)
128{
129 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
130 int ret = 0;
131
132 if (rtd->dai_link->compr_ops &&
133 rtd->dai_link->compr_ops->startup)
134 ret = rtd->dai_link->compr_ops->startup(cstream);
135
136 return soc_link_ret(rtd, ret);
137}
138EXPORT_SYMBOL_GPL(snd_soc_link_compr_startup);
0e532c99
KM
139
140void snd_soc_link_compr_shutdown(struct snd_compr_stream *cstream)
141{
142 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
143
144 if (rtd->dai_link->compr_ops &&
145 rtd->dai_link->compr_ops->shutdown)
146 rtd->dai_link->compr_ops->shutdown(cstream);
147}
148EXPORT_SYMBOL_GPL(snd_soc_link_compr_shutdown);
eab810f3
KM
149
150int snd_soc_link_compr_set_params(struct snd_compr_stream *cstream)
151{
152 struct snd_soc_pcm_runtime *rtd = cstream->private_data;
153 int ret = 0;
154
155 if (rtd->dai_link->compr_ops &&
156 rtd->dai_link->compr_ops->set_params)
157 ret = rtd->dai_link->compr_ops->set_params(cstream);
158
159 return soc_link_ret(rtd, ret);
160}
161EXPORT_SYMBOL_GPL(snd_soc_link_compr_set_params);