Skip to content

Commit efc9194

Browse files
morimotobroonie
authored andcommitted
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 <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 1a695a9 commit efc9194

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

include/sound/hdmi-codec.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,38 +53,40 @@ struct hdmi_codec_params {
5353
int channels;
5454
};
5555

56+
struct hdmi_codec_pdata;
5657
struct hdmi_codec_ops {
5758
/*
5859
* Called when ASoC starts an audio stream setup.
5960
* Optional
6061
*/
61-
int (*audio_startup)(struct device *dev);
62+
int (*audio_startup)(struct device *dev, void *data);
6263

6364
/*
6465
* Configures HDMI-encoder for audio stream.
6566
* Mandatory
6667
*/
67-
int (*hw_params)(struct device *dev,
68+
int (*hw_params)(struct device *dev, void *data,
6869
struct hdmi_codec_daifmt *fmt,
6970
struct hdmi_codec_params *hparms);
7071

7172
/*
7273
* Shuts down the audio stream.
7374
* Mandatory
7475
*/
75-
void (*audio_shutdown)(struct device *dev);
76+
void (*audio_shutdown)(struct device *dev, void *data);
7677

7778
/*
7879
* Mute/unmute HDMI audio stream.
7980
* Optional
8081
*/
81-
int (*digital_mute)(struct device *dev, bool enable);
82+
int (*digital_mute)(struct device *dev, void *data, bool enable);
8283

8384
/*
8485
* Provides EDID-Like-Data from connected HDMI device.
8586
* Optional
8687
*/
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);
8890
};
8991

9092
/* HDMI codec initalization data */
@@ -93,6 +95,7 @@ struct hdmi_codec_pdata {
9395
uint i2s:1;
9496
uint spdif:1;
9597
int max_i2s_channels;
98+
void *data;
9699
};
97100

98101
#define HDMI_CODEC_DRV_NAME "hdmi-audio-codec"

sound/soc/codecs/hdmi-codec.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
112112
return ret;
113113

114114
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);
116116
if (ret) {
117117
mutex_lock(&hcp->current_stream_lock);
118118
hcp->current_stream = NULL;
@@ -122,8 +122,8 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
122122
}
123123

124124
if (hcp->hcd.ops->get_eld) {
125-
ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->eld,
126-
sizeof(hcp->eld));
125+
ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data,
126+
hcp->eld, sizeof(hcp->eld));
127127

128128
if (!ret) {
129129
ret = snd_pcm_hw_constraint_eld(substream->runtime,
@@ -144,7 +144,7 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream,
144144

145145
WARN_ON(hcp->current_stream != substream);
146146

147-
hcp->hcd.ops->audio_shutdown(dai->dev->parent);
147+
hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data);
148148

149149
mutex_lock(&hcp->current_stream_lock);
150150
hcp->current_stream = NULL;
@@ -195,8 +195,8 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream,
195195
hp.sample_rate = params_rate(params);
196196
hp.channels = params_channels(params);
197197

198-
return hcp->hcd.ops->hw_params(dai->dev->parent, &hcp->daifmt[dai->id],
199-
&hp);
198+
return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data,
199+
&hcp->daifmt[dai->id], &hp);
200200
}
201201

202202
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)
280280
dev_dbg(dai->dev, "%s()\n", __func__);
281281

282282
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);
284285

285286
return 0;
286287
}

0 commit comments

Comments
 (0)