diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2016-06-23 22:47:55 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-06-27 13:53:15 -0400 |
commit | efc9194bcff84666832c6493bafa92029ac6634c (patch) | |
tree | 5606d09a3a392ec3b8c401c762259cd7f7a509ce | |
parent | 1a695a905c18548062509178b98bc91e67510864 (diff) |
ASoC: hdmi-codec: callback function will be called with private data
Current hdmi-codec driver is assuming that it will be registered
from HDMI driver. Because of this assumption, each callback function
has struct device pointer which is parent device (= HDMI).
Then, it can use dev_get_drvdata() to get private data.
OTOH, on some SoC/HDMI case, SoC has VIDEO/SOUND and HDMI IPs.
This case, it needs SoC VIDEO, SoC SOUND and HDMI video, HDMI codec
driver. In DesignWare HDMI IP case, SoC VIDEO (= DRM/KMS) driver tries
to bind DesignWare HDMI video driver, and HDMI codec driver
(= hdmi-codec). This case, above "parent device" of HDMI codec driver
is DRM/KMS driver and its "device" already has private data.
And, from DT and ASoC CPU/Codec/Card binding point of view, HDMI codec
(= hdmi-codec) needs to have "parent device" (= DRM/KMS), otherwise,
it never detect sound card.
Because of these reasons, some driver can't use dev_get_drvdata() to
get private data on hdmi-codec driver. This patch add new void pointer
on hdmi_codec_pdata for private data, and callback function will be
called with it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | include/sound/hdmi-codec.h | 13 | ||||
-rw-r--r-- | sound/soc/codecs/hdmi-codec.c | 15 |
2 files changed, 16 insertions, 12 deletions
diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index fc3a481ad91e..530c57bdefa0 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h | |||
@@ -53,18 +53,19 @@ struct hdmi_codec_params { | |||
53 | int channels; | 53 | int channels; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | struct hdmi_codec_pdata; | ||
56 | struct hdmi_codec_ops { | 57 | struct hdmi_codec_ops { |
57 | /* | 58 | /* |
58 | * Called when ASoC starts an audio stream setup. | 59 | * Called when ASoC starts an audio stream setup. |
59 | * Optional | 60 | * Optional |
60 | */ | 61 | */ |
61 | int (*audio_startup)(struct device *dev); | 62 | int (*audio_startup)(struct device *dev, void *data); |
62 | 63 | ||
63 | /* | 64 | /* |
64 | * Configures HDMI-encoder for audio stream. | 65 | * Configures HDMI-encoder for audio stream. |
65 | * Mandatory | 66 | * Mandatory |
66 | */ | 67 | */ |
67 | int (*hw_params)(struct device *dev, | 68 | int (*hw_params)(struct device *dev, void *data, |
68 | struct hdmi_codec_daifmt *fmt, | 69 | struct hdmi_codec_daifmt *fmt, |
69 | struct hdmi_codec_params *hparms); | 70 | struct hdmi_codec_params *hparms); |
70 | 71 | ||
@@ -72,19 +73,20 @@ struct hdmi_codec_ops { | |||
72 | * Shuts down the audio stream. | 73 | * Shuts down the audio stream. |
73 | * Mandatory | 74 | * Mandatory |
74 | */ | 75 | */ |
75 | void (*audio_shutdown)(struct device *dev); | 76 | void (*audio_shutdown)(struct device *dev, void *data); |
76 | 77 | ||
77 | /* | 78 | /* |
78 | * Mute/unmute HDMI audio stream. | 79 | * Mute/unmute HDMI audio stream. |
79 | * Optional | 80 | * Optional |
80 | */ | 81 | */ |
81 | int (*digital_mute)(struct device *dev, bool enable); | 82 | int (*digital_mute)(struct device *dev, void *data, bool enable); |
82 | 83 | ||
83 | /* | 84 | /* |
84 | * Provides EDID-Like-Data from connected HDMI device. | 85 | * Provides EDID-Like-Data from connected HDMI device. |
85 | * Optional | 86 | * Optional |
86 | */ | 87 | */ |
87 | int (*get_eld)(struct device *dev, uint8_t *buf, size_t len); | 88 | int (*get_eld)(struct device *dev, void *data, |
89 | uint8_t *buf, size_t len); | ||
88 | }; | 90 | }; |
89 | 91 | ||
90 | /* HDMI codec initalization data */ | 92 | /* HDMI codec initalization data */ |
@@ -93,6 +95,7 @@ struct hdmi_codec_pdata { | |||
93 | uint i2s:1; | 95 | uint i2s:1; |
94 | uint spdif:1; | 96 | uint spdif:1; |
95 | int max_i2s_channels; | 97 | int max_i2s_channels; |
98 | void *data; | ||
96 | }; | 99 | }; |
97 | 100 | ||
98 | #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec" | 101 | #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec" |
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 8e36e883e453..f27d115626db 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c | |||
@@ -112,7 +112,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, | |||
112 | return ret; | 112 | return ret; |
113 | 113 | ||
114 | if (hcp->hcd.ops->audio_startup) { | 114 | if (hcp->hcd.ops->audio_startup) { |
115 | ret = hcp->hcd.ops->audio_startup(dai->dev->parent); | 115 | ret = hcp->hcd.ops->audio_startup(dai->dev->parent, hcp->hcd.data); |
116 | if (ret) { | 116 | if (ret) { |
117 | mutex_lock(&hcp->current_stream_lock); | 117 | mutex_lock(&hcp->current_stream_lock); |
118 | hcp->current_stream = NULL; | 118 | hcp->current_stream = NULL; |
@@ -122,8 +122,8 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, | |||
122 | } | 122 | } |
123 | 123 | ||
124 | if (hcp->hcd.ops->get_eld) { | 124 | if (hcp->hcd.ops->get_eld) { |
125 | ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->eld, | 125 | ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, |
126 | sizeof(hcp->eld)); | 126 | hcp->eld, sizeof(hcp->eld)); |
127 | 127 | ||
128 | if (!ret) { | 128 | if (!ret) { |
129 | ret = snd_pcm_hw_constraint_eld(substream->runtime, | 129 | ret = snd_pcm_hw_constraint_eld(substream->runtime, |
@@ -144,7 +144,7 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, | |||
144 | 144 | ||
145 | WARN_ON(hcp->current_stream != substream); | 145 | WARN_ON(hcp->current_stream != substream); |
146 | 146 | ||
147 | hcp->hcd.ops->audio_shutdown(dai->dev->parent); | 147 | hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data); |
148 | 148 | ||
149 | mutex_lock(&hcp->current_stream_lock); | 149 | mutex_lock(&hcp->current_stream_lock); |
150 | hcp->current_stream = NULL; | 150 | hcp->current_stream = NULL; |
@@ -195,8 +195,8 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, | |||
195 | hp.sample_rate = params_rate(params); | 195 | hp.sample_rate = params_rate(params); |
196 | hp.channels = params_channels(params); | 196 | hp.channels = params_channels(params); |
197 | 197 | ||
198 | return hcp->hcd.ops->hw_params(dai->dev->parent, &hcp->daifmt[dai->id], | 198 | return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, |
199 | &hp); | 199 | &hcp->daifmt[dai->id], &hp); |
200 | } | 200 | } |
201 | 201 | ||
202 | static int hdmi_codec_set_fmt(struct snd_soc_dai *dai, | 202 | static int hdmi_codec_set_fmt(struct snd_soc_dai *dai, |
@@ -280,7 +280,8 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) | |||
280 | dev_dbg(dai->dev, "%s()\n", __func__); | 280 | dev_dbg(dai->dev, "%s()\n", __func__); |
281 | 281 | ||
282 | if (hcp->hcd.ops->digital_mute) | 282 | if (hcp->hcd.ops->digital_mute) |
283 | return hcp->hcd.ops->digital_mute(dai->dev->parent, mute); | 283 | return hcp->hcd.ops->digital_mute(dai->dev->parent, |
284 | hcp->hcd.data, mute); | ||
284 | 285 | ||
285 | return 0; | 286 | return 0; |
286 | } | 287 | } |