diff options
author | Rakesh Ughreja <rakesh.a.ughreja@intel.com> | 2018-06-01 23:53:49 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-06-28 01:33:29 -0400 |
commit | 3787a39852b0d6a9e67336f8fb5815c13ab78bb6 (patch) | |
tree | b8ec55865d7cfc994d2cc963b9c58490c550079a | |
parent | ce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff) |
ALSA: hdac: Remove usage of struct hdac_ext_device and use hdac_device instead
This patch removes the hdac_ext_device structure. The legacy and
enhanced HDaudio capabilities can be handled in a backward-compatible
way without separate definitions.
Follow-up patches in this series handle the bus and driver definitions.
Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | include/sound/hdaudio_ext.h | 36 | ||||
-rw-r--r-- | sound/hda/ext/hdac_ext_bus.c | 25 | ||||
-rw-r--r-- | sound/soc/codecs/hdac_hdmi.c | 396 |
3 files changed, 204 insertions, 253 deletions
diff --git a/include/sound/hdaudio_ext.h b/include/sound/hdaudio_ext.h index 9c14e21dda85..c1a5ad0e6e39 100644 --- a/include/sound/hdaudio_ext.h +++ b/include/sound/hdaudio_ext.h | |||
@@ -181,48 +181,20 @@ struct hda_dai_map { | |||
181 | u32 maxbps; | 181 | u32 maxbps; |
182 | }; | 182 | }; |
183 | 183 | ||
184 | #define HDA_MAX_NIDS 16 | ||
185 | |||
186 | /** | ||
187 | * struct hdac_ext_device - HDAC Ext device | ||
188 | * | ||
189 | * @hdac: hdac core device | ||
190 | * @nid_list - the dai map which matches the dai-name with the nid | ||
191 | * @map_cur_idx - the idx in use in dai_map | ||
192 | * @ops - the hda codec ops common to all codec drivers | ||
193 | * @pvt_data - private data, for asoc contains asoc codec object | ||
194 | */ | ||
195 | struct hdac_ext_device { | ||
196 | struct hdac_device hdev; | ||
197 | struct hdac_ext_bus *ebus; | ||
198 | |||
199 | /* soc-dai to nid map */ | ||
200 | struct hda_dai_map nid_list[HDA_MAX_NIDS]; | ||
201 | unsigned int map_cur_idx; | ||
202 | |||
203 | /* codec ops */ | ||
204 | struct hdac_ext_codec_ops ops; | ||
205 | |||
206 | struct snd_card *card; | ||
207 | void *scodec; | ||
208 | void *private_data; | ||
209 | }; | ||
210 | |||
211 | struct hdac_ext_dma_params { | 184 | struct hdac_ext_dma_params { |
212 | u32 format; | 185 | u32 format; |
213 | u8 stream_tag; | 186 | u8 stream_tag; |
214 | }; | 187 | }; |
215 | #define to_ehdac_device(dev) (container_of((dev), \ | 188 | |
216 | struct hdac_ext_device, hdev)) | ||
217 | /* | 189 | /* |
218 | * HD-audio codec base driver | 190 | * HD-audio codec base driver |
219 | */ | 191 | */ |
220 | struct hdac_ext_driver { | 192 | struct hdac_ext_driver { |
221 | struct hdac_driver hdac; | 193 | struct hdac_driver hdac; |
222 | 194 | ||
223 | int (*probe)(struct hdac_ext_device *dev); | 195 | int (*probe)(struct hdac_device *dev); |
224 | int (*remove)(struct hdac_ext_device *dev); | 196 | int (*remove)(struct hdac_device *dev); |
225 | void (*shutdown)(struct hdac_ext_device *dev); | 197 | void (*shutdown)(struct hdac_device *dev); |
226 | }; | 198 | }; |
227 | 199 | ||
228 | int snd_hda_ext_driver_register(struct hdac_ext_driver *drv); | 200 | int snd_hda_ext_driver_register(struct hdac_ext_driver *drv); |
diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c index 0daf31383084..0e4823fdd411 100644 --- a/sound/hda/ext/hdac_ext_bus.c +++ b/sound/hda/ext/hdac_ext_bus.c | |||
@@ -137,17 +137,16 @@ static void default_release(struct device *dev) | |||
137 | */ | 137 | */ |
138 | int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr) | 138 | int snd_hdac_ext_bus_device_init(struct hdac_ext_bus *ebus, int addr) |
139 | { | 139 | { |
140 | struct hdac_ext_device *edev; | ||
141 | struct hdac_device *hdev = NULL; | 140 | struct hdac_device *hdev = NULL; |
142 | struct hdac_bus *bus = ebus_to_hbus(ebus); | 141 | struct hdac_bus *bus = ebus_to_hbus(ebus); |
143 | char name[15]; | 142 | char name[15]; |
144 | int ret; | 143 | int ret; |
145 | 144 | ||
146 | edev = kzalloc(sizeof(*edev), GFP_KERNEL); | 145 | hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); |
147 | if (!edev) | 146 | if (!hdev) |
148 | return -ENOMEM; | 147 | return -ENOMEM; |
149 | hdev = &edev->hdev; | 148 | |
150 | edev->ebus = ebus; | 149 | hdev->bus = bus; |
151 | 150 | ||
152 | snprintf(name, sizeof(name), "ehdaudio%dD%d", ebus->idx, addr); | 151 | snprintf(name, sizeof(name), "ehdaudio%dD%d", ebus->idx, addr); |
153 | 152 | ||
@@ -176,10 +175,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_init); | |||
176 | */ | 175 | */ |
177 | void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev) | 176 | void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev) |
178 | { | 177 | { |
179 | struct hdac_ext_device *edev = to_ehdac_device(hdev); | ||
180 | |||
181 | snd_hdac_device_exit(hdev); | 178 | snd_hdac_device_exit(hdev); |
182 | kfree(edev); | 179 | kfree(hdev); |
183 | } | 180 | } |
184 | EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit); | 181 | EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit); |
185 | 182 | ||
@@ -212,27 +209,25 @@ static inline struct hdac_ext_driver *get_edrv(struct device *dev) | |||
212 | return edrv; | 209 | return edrv; |
213 | } | 210 | } |
214 | 211 | ||
215 | static inline struct hdac_ext_device *get_edev(struct device *dev) | 212 | static inline struct hdac_device *get_hdev(struct device *dev) |
216 | { | 213 | { |
217 | struct hdac_device *hdev = dev_to_hdac_dev(dev); | 214 | struct hdac_device *hdev = dev_to_hdac_dev(dev); |
218 | struct hdac_ext_device *edev = to_ehdac_device(hdev); | 215 | return hdev; |
219 | |||
220 | return edev; | ||
221 | } | 216 | } |
222 | 217 | ||
223 | static int hda_ext_drv_probe(struct device *dev) | 218 | static int hda_ext_drv_probe(struct device *dev) |
224 | { | 219 | { |
225 | return (get_edrv(dev))->probe(get_edev(dev)); | 220 | return (get_edrv(dev))->probe(get_hdev(dev)); |
226 | } | 221 | } |
227 | 222 | ||
228 | static int hdac_ext_drv_remove(struct device *dev) | 223 | static int hdac_ext_drv_remove(struct device *dev) |
229 | { | 224 | { |
230 | return (get_edrv(dev))->remove(get_edev(dev)); | 225 | return (get_edrv(dev))->remove(get_hdev(dev)); |
231 | } | 226 | } |
232 | 227 | ||
233 | static void hdac_ext_drv_shutdown(struct device *dev) | 228 | static void hdac_ext_drv_shutdown(struct device *dev) |
234 | { | 229 | { |
235 | return (get_edrv(dev))->shutdown(get_edev(dev)); | 230 | return (get_edrv(dev))->shutdown(get_hdev(dev)); |
236 | } | 231 | } |
237 | 232 | ||
238 | /** | 233 | /** |
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 84f7a7a36e4b..f1e235817a65 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c | |||
@@ -85,7 +85,7 @@ struct hdac_hdmi_pin { | |||
85 | bool mst_capable; | 85 | bool mst_capable; |
86 | struct hdac_hdmi_port *ports; | 86 | struct hdac_hdmi_port *ports; |
87 | int num_ports; | 87 | int num_ports; |
88 | struct hdac_ext_device *edev; | 88 | struct hdac_device *hdev; |
89 | }; | 89 | }; |
90 | 90 | ||
91 | struct hdac_hdmi_port { | 91 | struct hdac_hdmi_port { |
@@ -126,6 +126,9 @@ struct hdac_hdmi_drv_data { | |||
126 | }; | 126 | }; |
127 | 127 | ||
128 | struct hdac_hdmi_priv { | 128 | struct hdac_hdmi_priv { |
129 | struct hdac_device *hdev; | ||
130 | struct snd_soc_component *component; | ||
131 | struct snd_card *card; | ||
129 | struct hdac_hdmi_dai_port_map dai_map[HDA_MAX_CVTS]; | 132 | struct hdac_hdmi_dai_port_map dai_map[HDA_MAX_CVTS]; |
130 | struct list_head pin_list; | 133 | struct list_head pin_list; |
131 | struct list_head cvt_list; | 134 | struct list_head cvt_list; |
@@ -139,7 +142,7 @@ struct hdac_hdmi_priv { | |||
139 | struct snd_soc_dai_driver *dai_drv; | 142 | struct snd_soc_dai_driver *dai_drv; |
140 | }; | 143 | }; |
141 | 144 | ||
142 | #define hdev_to_hdmi_priv(_hdev) ((to_ehdac_device(_hdev))->private_data) | 145 | #define hdev_to_hdmi_priv(_hdev) dev_get_drvdata(&(_hdev)->dev) |
143 | 146 | ||
144 | static struct hdac_hdmi_pcm * | 147 | static struct hdac_hdmi_pcm * |
145 | hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi, | 148 | hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi, |
@@ -158,7 +161,7 @@ hdac_hdmi_get_pcm_from_cvt(struct hdac_hdmi_priv *hdmi, | |||
158 | static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm, | 161 | static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm, |
159 | struct hdac_hdmi_port *port, bool is_connect) | 162 | struct hdac_hdmi_port *port, bool is_connect) |
160 | { | 163 | { |
161 | struct hdac_ext_device *edev = port->pin->edev; | 164 | struct hdac_device *hdev = port->pin->hdev; |
162 | 165 | ||
163 | if (is_connect) | 166 | if (is_connect) |
164 | snd_soc_dapm_enable_pin(port->dapm, port->jack_pin); | 167 | snd_soc_dapm_enable_pin(port->dapm, port->jack_pin); |
@@ -172,7 +175,7 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm, | |||
172 | * ports. | 175 | * ports. |
173 | */ | 176 | */ |
174 | if (pcm->jack_event == 0) { | 177 | if (pcm->jack_event == 0) { |
175 | dev_dbg(&edev->hdev.dev, | 178 | dev_dbg(&hdev->dev, |
176 | "jack report for pcm=%d\n", | 179 | "jack report for pcm=%d\n", |
177 | pcm->pcm_id); | 180 | pcm->pcm_id); |
178 | snd_soc_jack_report(pcm->jack, SND_JACK_AVOUT, | 181 | snd_soc_jack_report(pcm->jack, SND_JACK_AVOUT, |
@@ -198,19 +201,18 @@ static void hdac_hdmi_jack_report(struct hdac_hdmi_pcm *pcm, | |||
198 | /* | 201 | /* |
199 | * Get the no devices that can be connected to a port on the Pin widget. | 202 | * Get the no devices that can be connected to a port on the Pin widget. |
200 | */ | 203 | */ |
201 | static int hdac_hdmi_get_port_len(struct hdac_ext_device *edev, hda_nid_t nid) | 204 | static int hdac_hdmi_get_port_len(struct hdac_device *hdev, hda_nid_t nid) |
202 | { | 205 | { |
203 | unsigned int caps; | 206 | unsigned int caps; |
204 | unsigned int type, param; | 207 | unsigned int type, param; |
205 | 208 | ||
206 | caps = get_wcaps(&edev->hdev, nid); | 209 | caps = get_wcaps(hdev, nid); |
207 | type = get_wcaps_type(caps); | 210 | type = get_wcaps_type(caps); |
208 | 211 | ||
209 | if (!(caps & AC_WCAP_DIGITAL) || (type != AC_WID_PIN)) | 212 | if (!(caps & AC_WCAP_DIGITAL) || (type != AC_WID_PIN)) |
210 | return 0; | 213 | return 0; |
211 | 214 | ||
212 | param = snd_hdac_read_parm_uncached(&edev->hdev, nid, | 215 | param = snd_hdac_read_parm_uncached(hdev, nid, AC_PAR_DEVLIST_LEN); |
213 | AC_PAR_DEVLIST_LEN); | ||
214 | if (param == -1) | 216 | if (param == -1) |
215 | return param; | 217 | return param; |
216 | 218 | ||
@@ -222,10 +224,10 @@ static int hdac_hdmi_get_port_len(struct hdac_ext_device *edev, hda_nid_t nid) | |||
222 | * id selected on the pin. Return 0 means the first port entry | 224 | * id selected on the pin. Return 0 means the first port entry |
223 | * is selected or MST is not supported. | 225 | * is selected or MST is not supported. |
224 | */ | 226 | */ |
225 | static int hdac_hdmi_port_select_get(struct hdac_ext_device *edev, | 227 | static int hdac_hdmi_port_select_get(struct hdac_device *hdev, |
226 | struct hdac_hdmi_port *port) | 228 | struct hdac_hdmi_port *port) |
227 | { | 229 | { |
228 | return snd_hdac_codec_read(&edev->hdev, port->pin->nid, | 230 | return snd_hdac_codec_read(hdev, port->pin->nid, |
229 | 0, AC_VERB_GET_DEVICE_SEL, 0); | 231 | 0, AC_VERB_GET_DEVICE_SEL, 0); |
230 | } | 232 | } |
231 | 233 | ||
@@ -233,7 +235,7 @@ static int hdac_hdmi_port_select_get(struct hdac_ext_device *edev, | |||
233 | * Sets the selected port entry for the configuring Pin widget verb. | 235 | * Sets the selected port entry for the configuring Pin widget verb. |
234 | * returns error if port set is not equal to port get otherwise success | 236 | * returns error if port set is not equal to port get otherwise success |
235 | */ | 237 | */ |
236 | static int hdac_hdmi_port_select_set(struct hdac_ext_device *edev, | 238 | static int hdac_hdmi_port_select_set(struct hdac_device *hdev, |
237 | struct hdac_hdmi_port *port) | 239 | struct hdac_hdmi_port *port) |
238 | { | 240 | { |
239 | int num_ports; | 241 | int num_ports; |
@@ -242,8 +244,7 @@ static int hdac_hdmi_port_select_set(struct hdac_ext_device *edev, | |||
242 | return 0; | 244 | return 0; |
243 | 245 | ||
244 | /* AC_PAR_DEVLIST_LEN is 0 based. */ | 246 | /* AC_PAR_DEVLIST_LEN is 0 based. */ |
245 | num_ports = hdac_hdmi_get_port_len(edev, port->pin->nid); | 247 | num_ports = hdac_hdmi_get_port_len(hdev, port->pin->nid); |
246 | |||
247 | if (num_ports < 0) | 248 | if (num_ports < 0) |
248 | return -EIO; | 249 | return -EIO; |
249 | /* | 250 | /* |
@@ -253,13 +254,13 @@ static int hdac_hdmi_port_select_set(struct hdac_ext_device *edev, | |||
253 | if (num_ports + 1 < port->id) | 254 | if (num_ports + 1 < port->id) |
254 | return 0; | 255 | return 0; |
255 | 256 | ||
256 | snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0, | 257 | snd_hdac_codec_write(hdev, port->pin->nid, 0, |
257 | AC_VERB_SET_DEVICE_SEL, port->id); | 258 | AC_VERB_SET_DEVICE_SEL, port->id); |
258 | 259 | ||
259 | if (port->id != hdac_hdmi_port_select_get(edev, port)) | 260 | if (port->id != hdac_hdmi_port_select_get(hdev, port)) |
260 | return -EIO; | 261 | return -EIO; |
261 | 262 | ||
262 | dev_dbg(&edev->hdev.dev, "Selected the port=%d\n", port->id); | 263 | dev_dbg(&hdev->dev, "Selected the port=%d\n", port->id); |
263 | 264 | ||
264 | return 0; | 265 | return 0; |
265 | } | 266 | } |
@@ -277,13 +278,6 @@ static struct hdac_hdmi_pcm *get_hdmi_pcm_from_id(struct hdac_hdmi_priv *hdmi, | |||
277 | return NULL; | 278 | return NULL; |
278 | } | 279 | } |
279 | 280 | ||
280 | static inline struct hdac_ext_device *to_hda_ext_device(struct device *dev) | ||
281 | { | ||
282 | struct hdac_device *hdev = dev_to_hdac_dev(dev); | ||
283 | |||
284 | return to_ehdac_device(hdev); | ||
285 | } | ||
286 | |||
287 | static unsigned int sad_format(const u8 *sad) | 281 | static unsigned int sad_format(const u8 *sad) |
288 | { | 282 | { |
289 | return ((sad[0] >> 0x3) & 0x1f); | 283 | return ((sad[0] >> 0x3) & 0x1f); |
@@ -324,15 +318,13 @@ format_constraint: | |||
324 | } | 318 | } |
325 | 319 | ||
326 | static void | 320 | static void |
327 | hdac_hdmi_set_dip_index(struct hdac_ext_device *edev, hda_nid_t pin_nid, | 321 | hdac_hdmi_set_dip_index(struct hdac_device *hdev, hda_nid_t pin_nid, |
328 | int packet_index, int byte_index) | 322 | int packet_index, int byte_index) |
329 | { | 323 | { |
330 | int val; | 324 | int val; |
331 | 325 | ||
332 | val = (packet_index << 5) | (byte_index & 0x1f); | 326 | val = (packet_index << 5) | (byte_index & 0x1f); |
333 | 327 | snd_hdac_codec_write(hdev, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); | |
334 | snd_hdac_codec_write(&edev->hdev, pin_nid, 0, | ||
335 | AC_VERB_SET_HDMI_DIP_INDEX, val); | ||
336 | } | 328 | } |
337 | 329 | ||
338 | struct dp_audio_infoframe { | 330 | struct dp_audio_infoframe { |
@@ -347,14 +339,14 @@ struct dp_audio_infoframe { | |||
347 | u8 LFEPBL01_LSV36_DM_INH7; | 339 | u8 LFEPBL01_LSV36_DM_INH7; |
348 | }; | 340 | }; |
349 | 341 | ||
350 | static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *edev, | 342 | static int hdac_hdmi_setup_audio_infoframe(struct hdac_device *hdev, |
351 | struct hdac_hdmi_pcm *pcm, struct hdac_hdmi_port *port) | 343 | struct hdac_hdmi_pcm *pcm, struct hdac_hdmi_port *port) |
352 | { | 344 | { |
353 | uint8_t buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE]; | 345 | uint8_t buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE]; |
354 | struct hdmi_audio_infoframe frame; | 346 | struct hdmi_audio_infoframe frame; |
355 | struct hdac_hdmi_pin *pin = port->pin; | 347 | struct hdac_hdmi_pin *pin = port->pin; |
356 | struct dp_audio_infoframe dp_ai; | 348 | struct dp_audio_infoframe dp_ai; |
357 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 349 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
358 | struct hdac_hdmi_cvt *cvt = pcm->cvt; | 350 | struct hdac_hdmi_cvt *cvt = pcm->cvt; |
359 | u8 *dip; | 351 | u8 *dip; |
360 | int ret; | 352 | int ret; |
@@ -363,11 +355,11 @@ static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *edev, | |||
363 | u8 conn_type; | 355 | u8 conn_type; |
364 | int channels, ca; | 356 | int channels, ca; |
365 | 357 | ||
366 | ca = snd_hdac_channel_allocation(&edev->hdev, port->eld.info.spk_alloc, | 358 | ca = snd_hdac_channel_allocation(hdev, port->eld.info.spk_alloc, |
367 | pcm->channels, pcm->chmap_set, true, pcm->chmap); | 359 | pcm->channels, pcm->chmap_set, true, pcm->chmap); |
368 | 360 | ||
369 | channels = snd_hdac_get_active_channels(ca); | 361 | channels = snd_hdac_get_active_channels(ca); |
370 | hdmi->chmap.ops.set_channel_count(&edev->hdev, cvt->nid, channels); | 362 | hdmi->chmap.ops.set_channel_count(hdev, cvt->nid, channels); |
371 | 363 | ||
372 | snd_hdac_setup_channel_mapping(&hdmi->chmap, pin->nid, false, ca, | 364 | snd_hdac_setup_channel_mapping(&hdmi->chmap, pin->nid, false, ca, |
373 | pcm->channels, pcm->chmap, pcm->chmap_set); | 365 | pcm->channels, pcm->chmap, pcm->chmap_set); |
@@ -400,32 +392,31 @@ static int hdac_hdmi_setup_audio_infoframe(struct hdac_ext_device *edev, | |||
400 | break; | 392 | break; |
401 | 393 | ||
402 | default: | 394 | default: |
403 | dev_err(&edev->hdev.dev, "Invalid connection type: %d\n", | 395 | dev_err(&hdev->dev, "Invalid connection type: %d\n", conn_type); |
404 | conn_type); | ||
405 | return -EIO; | 396 | return -EIO; |
406 | } | 397 | } |
407 | 398 | ||
408 | /* stop infoframe transmission */ | 399 | /* stop infoframe transmission */ |
409 | hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0); | 400 | hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); |
410 | snd_hdac_codec_write(&edev->hdev, pin->nid, 0, | 401 | snd_hdac_codec_write(hdev, pin->nid, 0, |
411 | AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_DISABLE); | 402 | AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_DISABLE); |
412 | 403 | ||
413 | 404 | ||
414 | /* Fill infoframe. Index auto-incremented */ | 405 | /* Fill infoframe. Index auto-incremented */ |
415 | hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0); | 406 | hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); |
416 | if (conn_type == DRM_ELD_CONN_TYPE_HDMI) { | 407 | if (conn_type == DRM_ELD_CONN_TYPE_HDMI) { |
417 | for (i = 0; i < sizeof(buffer); i++) | 408 | for (i = 0; i < sizeof(buffer); i++) |
418 | snd_hdac_codec_write(&edev->hdev, pin->nid, 0, | 409 | snd_hdac_codec_write(hdev, pin->nid, 0, |
419 | AC_VERB_SET_HDMI_DIP_DATA, buffer[i]); | 410 | AC_VERB_SET_HDMI_DIP_DATA, buffer[i]); |
420 | } else { | 411 | } else { |
421 | for (i = 0; i < sizeof(dp_ai); i++) | 412 | for (i = 0; i < sizeof(dp_ai); i++) |
422 | snd_hdac_codec_write(&edev->hdev, pin->nid, 0, | 413 | snd_hdac_codec_write(hdev, pin->nid, 0, |
423 | AC_VERB_SET_HDMI_DIP_DATA, dip[i]); | 414 | AC_VERB_SET_HDMI_DIP_DATA, dip[i]); |
424 | } | 415 | } |
425 | 416 | ||
426 | /* Start infoframe */ | 417 | /* Start infoframe */ |
427 | hdac_hdmi_set_dip_index(edev, pin->nid, 0x0, 0x0); | 418 | hdac_hdmi_set_dip_index(hdev, pin->nid, 0x0, 0x0); |
428 | snd_hdac_codec_write(&edev->hdev, pin->nid, 0, | 419 | snd_hdac_codec_write(hdev, pin->nid, 0, |
429 | AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_BEST); | 420 | AC_VERB_SET_HDMI_DIP_XMIT, AC_DIPXMIT_BEST); |
430 | 421 | ||
431 | return 0; | 422 | return 0; |
@@ -435,12 +426,12 @@ static int hdac_hdmi_set_tdm_slot(struct snd_soc_dai *dai, | |||
435 | unsigned int tx_mask, unsigned int rx_mask, | 426 | unsigned int tx_mask, unsigned int rx_mask, |
436 | int slots, int slot_width) | 427 | int slots, int slot_width) |
437 | { | 428 | { |
438 | struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); | 429 | struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); |
439 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 430 | struct hdac_device *hdev = hdmi->hdev; |
440 | struct hdac_hdmi_dai_port_map *dai_map; | 431 | struct hdac_hdmi_dai_port_map *dai_map; |
441 | struct hdac_hdmi_pcm *pcm; | 432 | struct hdac_hdmi_pcm *pcm; |
442 | 433 | ||
443 | dev_dbg(&edev->hdev.dev, "%s: strm_tag: %d\n", __func__, tx_mask); | 434 | dev_dbg(&hdev->dev, "%s: strm_tag: %d\n", __func__, tx_mask); |
444 | 435 | ||
445 | dai_map = &hdmi->dai_map[dai->id]; | 436 | dai_map = &hdmi->dai_map[dai->id]; |
446 | 437 | ||
@@ -455,8 +446,8 @@ static int hdac_hdmi_set_tdm_slot(struct snd_soc_dai *dai, | |||
455 | static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, | 446 | static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, |
456 | struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai) | 447 | struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai) |
457 | { | 448 | { |
458 | struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); | 449 | struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); |
459 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 450 | struct hdac_device *hdev = hdmi->hdev; |
460 | struct hdac_hdmi_dai_port_map *dai_map; | 451 | struct hdac_hdmi_dai_port_map *dai_map; |
461 | struct hdac_hdmi_port *port; | 452 | struct hdac_hdmi_port *port; |
462 | struct hdac_hdmi_pcm *pcm; | 453 | struct hdac_hdmi_pcm *pcm; |
@@ -469,7 +460,7 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, | |||
469 | return -ENODEV; | 460 | return -ENODEV; |
470 | 461 | ||
471 | if ((!port->eld.monitor_present) || (!port->eld.eld_valid)) { | 462 | if ((!port->eld.monitor_present) || (!port->eld.eld_valid)) { |
472 | dev_err(&edev->hdev.dev, | 463 | dev_err(&hdev->dev, |
473 | "device is not configured for this pin:port%d:%d\n", | 464 | "device is not configured for this pin:port%d:%d\n", |
474 | port->pin->nid, port->id); | 465 | port->pin->nid, port->id); |
475 | return -ENODEV; | 466 | return -ENODEV; |
@@ -489,28 +480,28 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, | |||
489 | return 0; | 480 | return 0; |
490 | } | 481 | } |
491 | 482 | ||
492 | static int hdac_hdmi_query_port_connlist(struct hdac_ext_device *edev, | 483 | static int hdac_hdmi_query_port_connlist(struct hdac_device *hdev, |
493 | struct hdac_hdmi_pin *pin, | 484 | struct hdac_hdmi_pin *pin, |
494 | struct hdac_hdmi_port *port) | 485 | struct hdac_hdmi_port *port) |
495 | { | 486 | { |
496 | if (!(get_wcaps(&edev->hdev, pin->nid) & AC_WCAP_CONN_LIST)) { | 487 | if (!(get_wcaps(hdev, pin->nid) & AC_WCAP_CONN_LIST)) { |
497 | dev_warn(&edev->hdev.dev, | 488 | dev_warn(&hdev->dev, |
498 | "HDMI: pin %d wcaps %#x does not support connection list\n", | 489 | "HDMI: pin %d wcaps %#x does not support connection list\n", |
499 | pin->nid, get_wcaps(&edev->hdev, pin->nid)); | 490 | pin->nid, get_wcaps(hdev, pin->nid)); |
500 | return -EINVAL; | 491 | return -EINVAL; |
501 | } | 492 | } |
502 | 493 | ||
503 | if (hdac_hdmi_port_select_set(edev, port) < 0) | 494 | if (hdac_hdmi_port_select_set(hdev, port) < 0) |
504 | return -EIO; | 495 | return -EIO; |
505 | 496 | ||
506 | port->num_mux_nids = snd_hdac_get_connections(&edev->hdev, pin->nid, | 497 | port->num_mux_nids = snd_hdac_get_connections(hdev, pin->nid, |
507 | port->mux_nids, HDA_MAX_CONNECTIONS); | 498 | port->mux_nids, HDA_MAX_CONNECTIONS); |
508 | if (port->num_mux_nids == 0) | 499 | if (port->num_mux_nids == 0) |
509 | dev_warn(&edev->hdev.dev, | 500 | dev_warn(&hdev->dev, |
510 | "No connections found for pin:port %d:%d\n", | 501 | "No connections found for pin:port %d:%d\n", |
511 | pin->nid, port->id); | 502 | pin->nid, port->id); |
512 | 503 | ||
513 | dev_dbg(&edev->hdev.dev, "num_mux_nids %d for pin:port %d:%d\n", | 504 | dev_dbg(&hdev->dev, "num_mux_nids %d for pin:port %d:%d\n", |
514 | port->num_mux_nids, pin->nid, port->id); | 505 | port->num_mux_nids, pin->nid, port->id); |
515 | 506 | ||
516 | return port->num_mux_nids; | 507 | return port->num_mux_nids; |
@@ -526,7 +517,7 @@ static int hdac_hdmi_query_port_connlist(struct hdac_ext_device *edev, | |||
526 | * connected. | 517 | * connected. |
527 | */ | 518 | */ |
528 | static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt( | 519 | static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt( |
529 | struct hdac_ext_device *edev, | 520 | struct hdac_device *hdev, |
530 | struct hdac_hdmi_priv *hdmi, | 521 | struct hdac_hdmi_priv *hdmi, |
531 | struct hdac_hdmi_cvt *cvt) | 522 | struct hdac_hdmi_cvt *cvt) |
532 | { | 523 | { |
@@ -541,7 +532,7 @@ static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt( | |||
541 | 532 | ||
542 | list_for_each_entry(port, &pcm->port_list, head) { | 533 | list_for_each_entry(port, &pcm->port_list, head) { |
543 | mutex_lock(&pcm->lock); | 534 | mutex_lock(&pcm->lock); |
544 | ret = hdac_hdmi_query_port_connlist(edev, | 535 | ret = hdac_hdmi_query_port_connlist(hdev, |
545 | port->pin, port); | 536 | port->pin, port); |
546 | mutex_unlock(&pcm->lock); | 537 | mutex_unlock(&pcm->lock); |
547 | if (ret < 0) | 538 | if (ret < 0) |
@@ -568,8 +559,8 @@ static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt( | |||
568 | static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, | 559 | static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, |
569 | struct snd_soc_dai *dai) | 560 | struct snd_soc_dai *dai) |
570 | { | 561 | { |
571 | struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); | 562 | struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); |
572 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 563 | struct hdac_device *hdev = hdmi->hdev; |
573 | struct hdac_hdmi_dai_port_map *dai_map; | 564 | struct hdac_hdmi_dai_port_map *dai_map; |
574 | struct hdac_hdmi_cvt *cvt; | 565 | struct hdac_hdmi_cvt *cvt; |
575 | struct hdac_hdmi_port *port; | 566 | struct hdac_hdmi_port *port; |
@@ -578,7 +569,7 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, | |||
578 | dai_map = &hdmi->dai_map[dai->id]; | 569 | dai_map = &hdmi->dai_map[dai->id]; |
579 | 570 | ||
580 | cvt = dai_map->cvt; | 571 | cvt = dai_map->cvt; |
581 | port = hdac_hdmi_get_port_from_cvt(edev, hdmi, cvt); | 572 | port = hdac_hdmi_get_port_from_cvt(hdev, hdmi, cvt); |
582 | 573 | ||
583 | /* | 574 | /* |
584 | * To make PA and other userland happy. | 575 | * To make PA and other userland happy. |
@@ -589,7 +580,7 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, | |||
589 | if ((!port->eld.monitor_present) || | 580 | if ((!port->eld.monitor_present) || |
590 | (!port->eld.eld_valid)) { | 581 | (!port->eld.eld_valid)) { |
591 | 582 | ||
592 | dev_warn(&edev->hdev.dev, | 583 | dev_warn(&hdev->dev, |
593 | "Failed: present?:%d ELD valid?:%d pin:port: %d:%d\n", | 584 | "Failed: present?:%d ELD valid?:%d pin:port: %d:%d\n", |
594 | port->eld.monitor_present, port->eld.eld_valid, | 585 | port->eld.monitor_present, port->eld.eld_valid, |
595 | port->pin->nid, port->id); | 586 | port->pin->nid, port->id); |
@@ -611,8 +602,7 @@ static int hdac_hdmi_pcm_open(struct snd_pcm_substream *substream, | |||
611 | static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream, | 602 | static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream, |
612 | struct snd_soc_dai *dai) | 603 | struct snd_soc_dai *dai) |
613 | { | 604 | { |
614 | struct hdac_ext_device *edev = snd_soc_dai_get_drvdata(dai); | 605 | struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); |
615 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | ||
616 | struct hdac_hdmi_dai_port_map *dai_map; | 606 | struct hdac_hdmi_dai_port_map *dai_map; |
617 | struct hdac_hdmi_pcm *pcm; | 607 | struct hdac_hdmi_pcm *pcm; |
618 | 608 | ||
@@ -695,10 +685,10 @@ static void hdac_hdmi_fill_route(struct snd_soc_dapm_route *route, | |||
695 | route->connected = handler; | 685 | route->connected = handler; |
696 | } | 686 | } |
697 | 687 | ||
698 | static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev, | 688 | static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_device *hdev, |
699 | struct hdac_hdmi_port *port) | 689 | struct hdac_hdmi_port *port) |
700 | { | 690 | { |
701 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 691 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
702 | struct hdac_hdmi_pcm *pcm = NULL; | 692 | struct hdac_hdmi_pcm *pcm = NULL; |
703 | struct hdac_hdmi_port *p; | 693 | struct hdac_hdmi_port *p; |
704 | 694 | ||
@@ -715,33 +705,32 @@ static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev, | |||
715 | return NULL; | 705 | return NULL; |
716 | } | 706 | } |
717 | 707 | ||
718 | static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, | 708 | static void hdac_hdmi_set_power_state(struct hdac_device *hdev, |
719 | hda_nid_t nid, unsigned int pwr_state) | 709 | hda_nid_t nid, unsigned int pwr_state) |
720 | { | 710 | { |
721 | int count; | 711 | int count; |
722 | unsigned int state; | 712 | unsigned int state; |
723 | 713 | ||
724 | if (get_wcaps(&edev->hdev, nid) & AC_WCAP_POWER) { | 714 | if (get_wcaps(hdev, nid) & AC_WCAP_POWER) { |
725 | if (!snd_hdac_check_power_state(&edev->hdev, nid, pwr_state)) { | 715 | if (!snd_hdac_check_power_state(hdev, nid, pwr_state)) { |
726 | for (count = 0; count < 10; count++) { | 716 | for (count = 0; count < 10; count++) { |
727 | snd_hdac_codec_read(&edev->hdev, nid, 0, | 717 | snd_hdac_codec_read(hdev, nid, 0, |
728 | AC_VERB_SET_POWER_STATE, | 718 | AC_VERB_SET_POWER_STATE, |
729 | pwr_state); | 719 | pwr_state); |
730 | state = snd_hdac_sync_power_state(&edev->hdev, | 720 | state = snd_hdac_sync_power_state(hdev, |
731 | nid, pwr_state); | 721 | nid, pwr_state); |
732 | if (!(state & AC_PWRST_ERROR)) | 722 | if (!(state & AC_PWRST_ERROR)) |
733 | break; | 723 | break; |
734 | } | 724 | } |
735 | } | 725 | } |
736 | |||
737 | } | 726 | } |
738 | } | 727 | } |
739 | 728 | ||
740 | static void hdac_hdmi_set_amp(struct hdac_ext_device *edev, | 729 | static void hdac_hdmi_set_amp(struct hdac_device *hdev, |
741 | hda_nid_t nid, int val) | 730 | hda_nid_t nid, int val) |
742 | { | 731 | { |
743 | if (get_wcaps(&edev->hdev, nid) & AC_WCAP_OUT_AMP) | 732 | if (get_wcaps(hdev, nid) & AC_WCAP_OUT_AMP) |
744 | snd_hdac_codec_write(&edev->hdev, nid, 0, | 733 | snd_hdac_codec_write(hdev, nid, 0, |
745 | AC_VERB_SET_AMP_GAIN_MUTE, val); | 734 | AC_VERB_SET_AMP_GAIN_MUTE, val); |
746 | } | 735 | } |
747 | 736 | ||
@@ -750,40 +739,40 @@ static int hdac_hdmi_pin_output_widget_event(struct snd_soc_dapm_widget *w, | |||
750 | struct snd_kcontrol *kc, int event) | 739 | struct snd_kcontrol *kc, int event) |
751 | { | 740 | { |
752 | struct hdac_hdmi_port *port = w->priv; | 741 | struct hdac_hdmi_port *port = w->priv; |
753 | struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); | 742 | struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); |
754 | struct hdac_hdmi_pcm *pcm; | 743 | struct hdac_hdmi_pcm *pcm; |
755 | 744 | ||
756 | dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n", | 745 | dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", |
757 | __func__, w->name, event); | 746 | __func__, w->name, event); |
758 | 747 | ||
759 | pcm = hdac_hdmi_get_pcm(edev, port); | 748 | pcm = hdac_hdmi_get_pcm(hdev, port); |
760 | if (!pcm) | 749 | if (!pcm) |
761 | return -EIO; | 750 | return -EIO; |
762 | 751 | ||
763 | /* set the device if pin is mst_capable */ | 752 | /* set the device if pin is mst_capable */ |
764 | if (hdac_hdmi_port_select_set(edev, port) < 0) | 753 | if (hdac_hdmi_port_select_set(hdev, port) < 0) |
765 | return -EIO; | 754 | return -EIO; |
766 | 755 | ||
767 | switch (event) { | 756 | switch (event) { |
768 | case SND_SOC_DAPM_PRE_PMU: | 757 | case SND_SOC_DAPM_PRE_PMU: |
769 | hdac_hdmi_set_power_state(edev, port->pin->nid, AC_PWRST_D0); | 758 | hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D0); |
770 | 759 | ||
771 | /* Enable out path for this pin widget */ | 760 | /* Enable out path for this pin widget */ |
772 | snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0, | 761 | snd_hdac_codec_write(hdev, port->pin->nid, 0, |
773 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); | 762 | AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); |
774 | 763 | ||
775 | hdac_hdmi_set_amp(edev, port->pin->nid, AMP_OUT_UNMUTE); | 764 | hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_UNMUTE); |
776 | 765 | ||
777 | return hdac_hdmi_setup_audio_infoframe(edev, pcm, port); | 766 | return hdac_hdmi_setup_audio_infoframe(hdev, pcm, port); |
778 | 767 | ||
779 | case SND_SOC_DAPM_POST_PMD: | 768 | case SND_SOC_DAPM_POST_PMD: |
780 | hdac_hdmi_set_amp(edev, port->pin->nid, AMP_OUT_MUTE); | 769 | hdac_hdmi_set_amp(hdev, port->pin->nid, AMP_OUT_MUTE); |
781 | 770 | ||
782 | /* Disable out path for this pin widget */ | 771 | /* Disable out path for this pin widget */ |
783 | snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0, | 772 | snd_hdac_codec_write(hdev, port->pin->nid, 0, |
784 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); | 773 | AC_VERB_SET_PIN_WIDGET_CONTROL, 0); |
785 | 774 | ||
786 | hdac_hdmi_set_power_state(edev, port->pin->nid, AC_PWRST_D3); | 775 | hdac_hdmi_set_power_state(hdev, port->pin->nid, AC_PWRST_D3); |
787 | break; | 776 | break; |
788 | 777 | ||
789 | } | 778 | } |
@@ -795,11 +784,11 @@ static int hdac_hdmi_cvt_output_widget_event(struct snd_soc_dapm_widget *w, | |||
795 | struct snd_kcontrol *kc, int event) | 784 | struct snd_kcontrol *kc, int event) |
796 | { | 785 | { |
797 | struct hdac_hdmi_cvt *cvt = w->priv; | 786 | struct hdac_hdmi_cvt *cvt = w->priv; |
798 | struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); | 787 | struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); |
799 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 788 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
800 | struct hdac_hdmi_pcm *pcm; | 789 | struct hdac_hdmi_pcm *pcm; |
801 | 790 | ||
802 | dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n", | 791 | dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", |
803 | __func__, w->name, event); | 792 | __func__, w->name, event); |
804 | 793 | ||
805 | pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, cvt); | 794 | pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, cvt); |
@@ -808,29 +797,29 @@ static int hdac_hdmi_cvt_output_widget_event(struct snd_soc_dapm_widget *w, | |||
808 | 797 | ||
809 | switch (event) { | 798 | switch (event) { |
810 | case SND_SOC_DAPM_PRE_PMU: | 799 | case SND_SOC_DAPM_PRE_PMU: |
811 | hdac_hdmi_set_power_state(edev, cvt->nid, AC_PWRST_D0); | 800 | hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D0); |
812 | 801 | ||
813 | /* Enable transmission */ | 802 | /* Enable transmission */ |
814 | snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, | 803 | snd_hdac_codec_write(hdev, cvt->nid, 0, |
815 | AC_VERB_SET_DIGI_CONVERT_1, 1); | 804 | AC_VERB_SET_DIGI_CONVERT_1, 1); |
816 | 805 | ||
817 | /* Category Code (CC) to zero */ | 806 | /* Category Code (CC) to zero */ |
818 | snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, | 807 | snd_hdac_codec_write(hdev, cvt->nid, 0, |
819 | AC_VERB_SET_DIGI_CONVERT_2, 0); | 808 | AC_VERB_SET_DIGI_CONVERT_2, 0); |
820 | 809 | ||
821 | snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, | 810 | snd_hdac_codec_write(hdev, cvt->nid, 0, |
822 | AC_VERB_SET_CHANNEL_STREAMID, pcm->stream_tag); | 811 | AC_VERB_SET_CHANNEL_STREAMID, pcm->stream_tag); |
823 | snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, | 812 | snd_hdac_codec_write(hdev, cvt->nid, 0, |
824 | AC_VERB_SET_STREAM_FORMAT, pcm->format); | 813 | AC_VERB_SET_STREAM_FORMAT, pcm->format); |
825 | break; | 814 | break; |
826 | 815 | ||
827 | case SND_SOC_DAPM_POST_PMD: | 816 | case SND_SOC_DAPM_POST_PMD: |
828 | snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, | 817 | snd_hdac_codec_write(hdev, cvt->nid, 0, |
829 | AC_VERB_SET_CHANNEL_STREAMID, 0); | 818 | AC_VERB_SET_CHANNEL_STREAMID, 0); |
830 | snd_hdac_codec_write(&edev->hdev, cvt->nid, 0, | 819 | snd_hdac_codec_write(hdev, cvt->nid, 0, |
831 | AC_VERB_SET_STREAM_FORMAT, 0); | 820 | AC_VERB_SET_STREAM_FORMAT, 0); |
832 | 821 | ||
833 | hdac_hdmi_set_power_state(edev, cvt->nid, AC_PWRST_D3); | 822 | hdac_hdmi_set_power_state(hdev, cvt->nid, AC_PWRST_D3); |
834 | break; | 823 | break; |
835 | 824 | ||
836 | } | 825 | } |
@@ -842,10 +831,10 @@ static int hdac_hdmi_pin_mux_widget_event(struct snd_soc_dapm_widget *w, | |||
842 | struct snd_kcontrol *kc, int event) | 831 | struct snd_kcontrol *kc, int event) |
843 | { | 832 | { |
844 | struct hdac_hdmi_port *port = w->priv; | 833 | struct hdac_hdmi_port *port = w->priv; |
845 | struct hdac_ext_device *edev = to_hda_ext_device(w->dapm->dev); | 834 | struct hdac_device *hdev = dev_to_hdac_dev(w->dapm->dev); |
846 | int mux_idx; | 835 | int mux_idx; |
847 | 836 | ||
848 | dev_dbg(&edev->hdev.dev, "%s: widget: %s event: %x\n", | 837 | dev_dbg(&hdev->dev, "%s: widget: %s event: %x\n", |
849 | __func__, w->name, event); | 838 | __func__, w->name, event); |
850 | 839 | ||
851 | if (!kc) | 840 | if (!kc) |
@@ -854,11 +843,11 @@ static int hdac_hdmi_pin_mux_widget_event(struct snd_soc_dapm_widget *w, | |||
854 | mux_idx = dapm_kcontrol_get_value(kc); | 843 | mux_idx = dapm_kcontrol_get_value(kc); |
855 | 844 | ||
856 | /* set the device if pin is mst_capable */ | 845 | /* set the device if pin is mst_capable */ |
857 | if (hdac_hdmi_port_select_set(edev, port) < 0) | 846 | if (hdac_hdmi_port_select_set(hdev, port) < 0) |
858 | return -EIO; | 847 | return -EIO; |
859 | 848 | ||
860 | if (mux_idx > 0) { | 849 | if (mux_idx > 0) { |
861 | snd_hdac_codec_write(&edev->hdev, port->pin->nid, 0, | 850 | snd_hdac_codec_write(hdev, port->pin->nid, 0, |
862 | AC_VERB_SET_CONNECT_SEL, (mux_idx - 1)); | 851 | AC_VERB_SET_CONNECT_SEL, (mux_idx - 1)); |
863 | } | 852 | } |
864 | 853 | ||
@@ -877,8 +866,8 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol, | |||
877 | struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol); | 866 | struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol); |
878 | struct snd_soc_dapm_context *dapm = w->dapm; | 867 | struct snd_soc_dapm_context *dapm = w->dapm; |
879 | struct hdac_hdmi_port *port = w->priv; | 868 | struct hdac_hdmi_port *port = w->priv; |
880 | struct hdac_ext_device *edev = to_hda_ext_device(dapm->dev); | 869 | struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); |
881 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 870 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
882 | struct hdac_hdmi_pcm *pcm = NULL; | 871 | struct hdac_hdmi_pcm *pcm = NULL; |
883 | const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]]; | 872 | const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0]]; |
884 | 873 | ||
@@ -931,12 +920,12 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol, | |||
931 | * care of selecting the right one and leaving all other inputs selected to | 920 | * care of selecting the right one and leaving all other inputs selected to |
932 | * "NONE" | 921 | * "NONE" |
933 | */ | 922 | */ |
934 | static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev, | 923 | static int hdac_hdmi_create_pin_port_muxs(struct hdac_device *hdev, |
935 | struct hdac_hdmi_port *port, | 924 | struct hdac_hdmi_port *port, |
936 | struct snd_soc_dapm_widget *widget, | 925 | struct snd_soc_dapm_widget *widget, |
937 | const char *widget_name) | 926 | const char *widget_name) |
938 | { | 927 | { |
939 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 928 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
940 | struct hdac_hdmi_pin *pin = port->pin; | 929 | struct hdac_hdmi_pin *pin = port->pin; |
941 | struct snd_kcontrol_new *kc; | 930 | struct snd_kcontrol_new *kc; |
942 | struct hdac_hdmi_cvt *cvt; | 931 | struct hdac_hdmi_cvt *cvt; |
@@ -948,17 +937,17 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev, | |||
948 | int i = 0; | 937 | int i = 0; |
949 | int num_items = hdmi->num_cvt + 1; | 938 | int num_items = hdmi->num_cvt + 1; |
950 | 939 | ||
951 | kc = devm_kzalloc(&edev->hdev.dev, sizeof(*kc), GFP_KERNEL); | 940 | kc = devm_kzalloc(&hdev->dev, sizeof(*kc), GFP_KERNEL); |
952 | if (!kc) | 941 | if (!kc) |
953 | return -ENOMEM; | 942 | return -ENOMEM; |
954 | 943 | ||
955 | se = devm_kzalloc(&edev->hdev.dev, sizeof(*se), GFP_KERNEL); | 944 | se = devm_kzalloc(&hdev->dev, sizeof(*se), GFP_KERNEL); |
956 | if (!se) | 945 | if (!se) |
957 | return -ENOMEM; | 946 | return -ENOMEM; |
958 | 947 | ||
959 | snprintf(kc_name, NAME_SIZE, "Pin %d port %d Input", | 948 | snprintf(kc_name, NAME_SIZE, "Pin %d port %d Input", |
960 | pin->nid, port->id); | 949 | pin->nid, port->id); |
961 | kc->name = devm_kstrdup(&edev->hdev.dev, kc_name, GFP_KERNEL); | 950 | kc->name = devm_kstrdup(&hdev->dev, kc_name, GFP_KERNEL); |
962 | if (!kc->name) | 951 | if (!kc->name) |
963 | return -ENOMEM; | 952 | return -ENOMEM; |
964 | 953 | ||
@@ -976,35 +965,35 @@ static int hdac_hdmi_create_pin_port_muxs(struct hdac_ext_device *edev, | |||
976 | se->mask = roundup_pow_of_two(se->items) - 1; | 965 | se->mask = roundup_pow_of_two(se->items) - 1; |
977 | 966 | ||
978 | sprintf(mux_items, "NONE"); | 967 | sprintf(mux_items, "NONE"); |
979 | items[i] = devm_kstrdup(&edev->hdev.dev, mux_items, GFP_KERNEL); | 968 | items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); |
980 | if (!items[i]) | 969 | if (!items[i]) |
981 | return -ENOMEM; | 970 | return -ENOMEM; |
982 | 971 | ||
983 | list_for_each_entry(cvt, &hdmi->cvt_list, head) { | 972 | list_for_each_entry(cvt, &hdmi->cvt_list, head) { |
984 | i++; | 973 | i++; |
985 | sprintf(mux_items, "cvt %d", cvt->nid); | 974 | sprintf(mux_items, "cvt %d", cvt->nid); |
986 | items[i] = devm_kstrdup(&edev->hdev.dev, mux_items, GFP_KERNEL); | 975 | items[i] = devm_kstrdup(&hdev->dev, mux_items, GFP_KERNEL); |
987 | if (!items[i]) | 976 | if (!items[i]) |
988 | return -ENOMEM; | 977 | return -ENOMEM; |
989 | } | 978 | } |
990 | 979 | ||
991 | se->texts = devm_kmemdup(&edev->hdev.dev, items, | 980 | se->texts = devm_kmemdup(&hdev->dev, items, |
992 | (num_items * sizeof(char *)), GFP_KERNEL); | 981 | (num_items * sizeof(char *)), GFP_KERNEL); |
993 | if (!se->texts) | 982 | if (!se->texts) |
994 | return -ENOMEM; | 983 | return -ENOMEM; |
995 | 984 | ||
996 | return hdac_hdmi_fill_widget_info(&edev->hdev.dev, widget, | 985 | return hdac_hdmi_fill_widget_info(&hdev->dev, widget, |
997 | snd_soc_dapm_mux, port, widget_name, NULL, kc, 1, | 986 | snd_soc_dapm_mux, port, widget_name, NULL, kc, 1, |
998 | hdac_hdmi_pin_mux_widget_event, | 987 | hdac_hdmi_pin_mux_widget_event, |
999 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_REG); | 988 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_REG); |
1000 | } | 989 | } |
1001 | 990 | ||
1002 | /* Add cvt <- input <- mux route map */ | 991 | /* Add cvt <- input <- mux route map */ |
1003 | static void hdac_hdmi_add_pinmux_cvt_route(struct hdac_ext_device *edev, | 992 | static void hdac_hdmi_add_pinmux_cvt_route(struct hdac_device *hdev, |
1004 | struct snd_soc_dapm_widget *widgets, | 993 | struct snd_soc_dapm_widget *widgets, |
1005 | struct snd_soc_dapm_route *route, int rindex) | 994 | struct snd_soc_dapm_route *route, int rindex) |
1006 | { | 995 | { |
1007 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 996 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1008 | const struct snd_kcontrol_new *kc; | 997 | const struct snd_kcontrol_new *kc; |
1009 | struct soc_enum *se; | 998 | struct soc_enum *se; |
1010 | int mux_index = hdmi->num_cvt + hdmi->num_ports; | 999 | int mux_index = hdmi->num_cvt + hdmi->num_ports; |
@@ -1046,8 +1035,8 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) | |||
1046 | { | 1035 | { |
1047 | struct snd_soc_dapm_widget *widgets; | 1036 | struct snd_soc_dapm_widget *widgets; |
1048 | struct snd_soc_dapm_route *route; | 1037 | struct snd_soc_dapm_route *route; |
1049 | struct hdac_ext_device *edev = to_hda_ext_device(dapm->dev); | 1038 | struct hdac_device *hdev = dev_to_hdac_dev(dapm->dev); |
1050 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1039 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1051 | struct snd_soc_dai_driver *dai_drv = hdmi->dai_drv; | 1040 | struct snd_soc_dai_driver *dai_drv = hdmi->dai_drv; |
1052 | char widget_name[NAME_SIZE]; | 1041 | char widget_name[NAME_SIZE]; |
1053 | struct hdac_hdmi_cvt *cvt; | 1042 | struct hdac_hdmi_cvt *cvt; |
@@ -1099,7 +1088,7 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) | |||
1099 | for (j = 0; j < pin->num_ports; j++) { | 1088 | for (j = 0; j < pin->num_ports; j++) { |
1100 | sprintf(widget_name, "Pin%d-Port%d Mux", | 1089 | sprintf(widget_name, "Pin%d-Port%d Mux", |
1101 | pin->nid, pin->ports[j].id); | 1090 | pin->nid, pin->ports[j].id); |
1102 | ret = hdac_hdmi_create_pin_port_muxs(edev, | 1091 | ret = hdac_hdmi_create_pin_port_muxs(hdev, |
1103 | &pin->ports[j], &widgets[i], | 1092 | &pin->ports[j], &widgets[i], |
1104 | widget_name); | 1093 | widget_name); |
1105 | if (ret < 0) | 1094 | if (ret < 0) |
@@ -1134,7 +1123,7 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) | |||
1134 | } | 1123 | } |
1135 | } | 1124 | } |
1136 | 1125 | ||
1137 | hdac_hdmi_add_pinmux_cvt_route(edev, widgets, route, i); | 1126 | hdac_hdmi_add_pinmux_cvt_route(hdev, widgets, route, i); |
1138 | 1127 | ||
1139 | snd_soc_dapm_new_controls(dapm, widgets, | 1128 | snd_soc_dapm_new_controls(dapm, widgets, |
1140 | ((2 * hdmi->num_ports) + hdmi->num_cvt)); | 1129 | ((2 * hdmi->num_ports) + hdmi->num_cvt)); |
@@ -1146,9 +1135,9 @@ static int create_fill_widget_route_map(struct snd_soc_dapm_context *dapm) | |||
1146 | 1135 | ||
1147 | } | 1136 | } |
1148 | 1137 | ||
1149 | static int hdac_hdmi_init_dai_map(struct hdac_ext_device *edev) | 1138 | static int hdac_hdmi_init_dai_map(struct hdac_device *hdev) |
1150 | { | 1139 | { |
1151 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1140 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1152 | struct hdac_hdmi_dai_port_map *dai_map; | 1141 | struct hdac_hdmi_dai_port_map *dai_map; |
1153 | struct hdac_hdmi_cvt *cvt; | 1142 | struct hdac_hdmi_cvt *cvt; |
1154 | int dai_id = 0; | 1143 | int dai_id = 0; |
@@ -1164,7 +1153,7 @@ static int hdac_hdmi_init_dai_map(struct hdac_ext_device *edev) | |||
1164 | dai_id++; | 1153 | dai_id++; |
1165 | 1154 | ||
1166 | if (dai_id == HDA_MAX_CVTS) { | 1155 | if (dai_id == HDA_MAX_CVTS) { |
1167 | dev_warn(&edev->hdev.dev, | 1156 | dev_warn(&hdev->dev, |
1168 | "Max dais supported: %d\n", dai_id); | 1157 | "Max dais supported: %d\n", dai_id); |
1169 | break; | 1158 | break; |
1170 | } | 1159 | } |
@@ -1173,9 +1162,9 @@ static int hdac_hdmi_init_dai_map(struct hdac_ext_device *edev) | |||
1173 | return 0; | 1162 | return 0; |
1174 | } | 1163 | } |
1175 | 1164 | ||
1176 | static int hdac_hdmi_add_cvt(struct hdac_ext_device *edev, hda_nid_t nid) | 1165 | static int hdac_hdmi_add_cvt(struct hdac_device *hdev, hda_nid_t nid) |
1177 | { | 1166 | { |
1178 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1167 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1179 | struct hdac_hdmi_cvt *cvt; | 1168 | struct hdac_hdmi_cvt *cvt; |
1180 | char name[NAME_SIZE]; | 1169 | char name[NAME_SIZE]; |
1181 | 1170 | ||
@@ -1190,10 +1179,10 @@ static int hdac_hdmi_add_cvt(struct hdac_ext_device *edev, hda_nid_t nid) | |||
1190 | list_add_tail(&cvt->head, &hdmi->cvt_list); | 1179 | list_add_tail(&cvt->head, &hdmi->cvt_list); |
1191 | hdmi->num_cvt++; | 1180 | hdmi->num_cvt++; |
1192 | 1181 | ||
1193 | return hdac_hdmi_query_cvt_params(&edev->hdev, cvt); | 1182 | return hdac_hdmi_query_cvt_params(hdev, cvt); |
1194 | } | 1183 | } |
1195 | 1184 | ||
1196 | static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev, | 1185 | static int hdac_hdmi_parse_eld(struct hdac_device *hdev, |
1197 | struct hdac_hdmi_port *port) | 1186 | struct hdac_hdmi_port *port) |
1198 | { | 1187 | { |
1199 | unsigned int ver, mnl; | 1188 | unsigned int ver, mnl; |
@@ -1202,7 +1191,7 @@ static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev, | |||
1202 | >> DRM_ELD_VER_SHIFT; | 1191 | >> DRM_ELD_VER_SHIFT; |
1203 | 1192 | ||
1204 | if (ver != ELD_VER_CEA_861D && ver != ELD_VER_PARTIAL) { | 1193 | if (ver != ELD_VER_CEA_861D && ver != ELD_VER_PARTIAL) { |
1205 | dev_err(&edev->hdev.dev, "HDMI: Unknown ELD version %d\n", ver); | 1194 | dev_err(&hdev->dev, "HDMI: Unknown ELD version %d\n", ver); |
1206 | return -EINVAL; | 1195 | return -EINVAL; |
1207 | } | 1196 | } |
1208 | 1197 | ||
@@ -1210,7 +1199,7 @@ static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev, | |||
1210 | DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; | 1199 | DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; |
1211 | 1200 | ||
1212 | if (mnl > ELD_MAX_MNL) { | 1201 | if (mnl > ELD_MAX_MNL) { |
1213 | dev_err(&edev->hdev.dev, "HDMI: MNL Invalid %d\n", mnl); | 1202 | dev_err(&hdev->dev, "HDMI: MNL Invalid %d\n", mnl); |
1214 | return -EINVAL; | 1203 | return -EINVAL; |
1215 | } | 1204 | } |
1216 | 1205 | ||
@@ -1222,8 +1211,8 @@ static int hdac_hdmi_parse_eld(struct hdac_ext_device *edev, | |||
1222 | static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin, | 1211 | static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin, |
1223 | struct hdac_hdmi_port *port) | 1212 | struct hdac_hdmi_port *port) |
1224 | { | 1213 | { |
1225 | struct hdac_ext_device *edev = pin->edev; | 1214 | struct hdac_device *hdev = pin->hdev; |
1226 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1215 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1227 | struct hdac_hdmi_pcm *pcm; | 1216 | struct hdac_hdmi_pcm *pcm; |
1228 | int size = 0; | 1217 | int size = 0; |
1229 | int port_id = -1; | 1218 | int port_id = -1; |
@@ -1241,14 +1230,14 @@ static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin, | |||
1241 | if (pin->mst_capable) | 1230 | if (pin->mst_capable) |
1242 | port_id = port->id; | 1231 | port_id = port->id; |
1243 | 1232 | ||
1244 | size = snd_hdac_acomp_get_eld(&edev->hdev, pin->nid, port_id, | 1233 | size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id, |
1245 | &port->eld.monitor_present, | 1234 | &port->eld.monitor_present, |
1246 | port->eld.eld_buffer, | 1235 | port->eld.eld_buffer, |
1247 | ELD_MAX_SIZE); | 1236 | ELD_MAX_SIZE); |
1248 | 1237 | ||
1249 | if (size > 0) { | 1238 | if (size > 0) { |
1250 | size = min(size, ELD_MAX_SIZE); | 1239 | size = min(size, ELD_MAX_SIZE); |
1251 | if (hdac_hdmi_parse_eld(edev, port) < 0) | 1240 | if (hdac_hdmi_parse_eld(hdev, port) < 0) |
1252 | size = -EINVAL; | 1241 | size = -EINVAL; |
1253 | } | 1242 | } |
1254 | 1243 | ||
@@ -1260,11 +1249,11 @@ static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin, | |||
1260 | port->eld.eld_size = 0; | 1249 | port->eld.eld_size = 0; |
1261 | } | 1250 | } |
1262 | 1251 | ||
1263 | pcm = hdac_hdmi_get_pcm(edev, port); | 1252 | pcm = hdac_hdmi_get_pcm(hdev, port); |
1264 | 1253 | ||
1265 | if (!port->eld.monitor_present || !port->eld.eld_valid) { | 1254 | if (!port->eld.monitor_present || !port->eld.eld_valid) { |
1266 | 1255 | ||
1267 | dev_err(&edev->hdev.dev, "%s: disconnect for pin:port %d:%d\n", | 1256 | dev_err(&hdev->dev, "%s: disconnect for pin:port %d:%d\n", |
1268 | __func__, pin->nid, port->id); | 1257 | __func__, pin->nid, port->id); |
1269 | 1258 | ||
1270 | /* | 1259 | /* |
@@ -1316,9 +1305,9 @@ static int hdac_hdmi_add_ports(struct hdac_hdmi_priv *hdmi, | |||
1316 | return 0; | 1305 | return 0; |
1317 | } | 1306 | } |
1318 | 1307 | ||
1319 | static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid) | 1308 | static int hdac_hdmi_add_pin(struct hdac_device *hdev, hda_nid_t nid) |
1320 | { | 1309 | { |
1321 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1310 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1322 | struct hdac_hdmi_pin *pin; | 1311 | struct hdac_hdmi_pin *pin; |
1323 | int ret; | 1312 | int ret; |
1324 | 1313 | ||
@@ -1328,7 +1317,7 @@ static int hdac_hdmi_add_pin(struct hdac_ext_device *edev, hda_nid_t nid) | |||
1328 | 1317 | ||
1329 | pin->nid = nid; | 1318 | pin->nid = nid; |
1330 | pin->mst_capable = false; | 1319 | pin->mst_capable = false; |
1331 | pin->edev = edev; | 1320 | pin->hdev = hdev; |
1332 | ret = hdac_hdmi_add_ports(hdmi, pin); | 1321 | ret = hdac_hdmi_add_ports(hdmi, pin); |
1333 | if (ret < 0) | 1322 | if (ret < 0) |
1334 | return ret; | 1323 | return ret; |
@@ -1459,15 +1448,14 @@ static int hdac_hdmi_create_dais(struct hdac_device *hdev, | |||
1459 | * Parse all nodes and store the cvt/pin nids in array | 1448 | * Parse all nodes and store the cvt/pin nids in array |
1460 | * Add one time initialization for pin and cvt widgets | 1449 | * Add one time initialization for pin and cvt widgets |
1461 | */ | 1450 | */ |
1462 | static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev, | 1451 | static int hdac_hdmi_parse_and_map_nid(struct hdac_device *hdev, |
1463 | struct snd_soc_dai_driver **dais, int *num_dais) | 1452 | struct snd_soc_dai_driver **dais, int *num_dais) |
1464 | { | 1453 | { |
1465 | hda_nid_t nid; | 1454 | hda_nid_t nid; |
1466 | int i, num_nodes; | 1455 | int i, num_nodes; |
1467 | struct hdac_hdmi_cvt *temp_cvt, *cvt_next; | 1456 | struct hdac_hdmi_cvt *temp_cvt, *cvt_next; |
1468 | struct hdac_hdmi_pin *temp_pin, *pin_next; | 1457 | struct hdac_hdmi_pin *temp_pin, *pin_next; |
1469 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1458 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1470 | struct hdac_device *hdev = &edev->hdev; | ||
1471 | int ret; | 1459 | int ret; |
1472 | 1460 | ||
1473 | hdac_hdmi_skl_enable_all_pins(hdev); | 1461 | hdac_hdmi_skl_enable_all_pins(hdev); |
@@ -1492,13 +1480,13 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev, | |||
1492 | switch (type) { | 1480 | switch (type) { |
1493 | 1481 | ||
1494 | case AC_WID_AUD_OUT: | 1482 | case AC_WID_AUD_OUT: |
1495 | ret = hdac_hdmi_add_cvt(edev, nid); | 1483 | ret = hdac_hdmi_add_cvt(hdev, nid); |
1496 | if (ret < 0) | 1484 | if (ret < 0) |
1497 | goto free_widgets; | 1485 | goto free_widgets; |
1498 | break; | 1486 | break; |
1499 | 1487 | ||
1500 | case AC_WID_PIN: | 1488 | case AC_WID_PIN: |
1501 | ret = hdac_hdmi_add_pin(edev, nid); | 1489 | ret = hdac_hdmi_add_pin(hdev, nid); |
1502 | if (ret < 0) | 1490 | if (ret < 0) |
1503 | goto free_widgets; | 1491 | goto free_widgets; |
1504 | break; | 1492 | break; |
@@ -1518,7 +1506,7 @@ static int hdac_hdmi_parse_and_map_nid(struct hdac_ext_device *edev, | |||
1518 | } | 1506 | } |
1519 | 1507 | ||
1520 | *num_dais = hdmi->num_cvt; | 1508 | *num_dais = hdmi->num_cvt; |
1521 | ret = hdac_hdmi_init_dai_map(edev); | 1509 | ret = hdac_hdmi_init_dai_map(hdev); |
1522 | if (ret < 0) | 1510 | if (ret < 0) |
1523 | goto free_widgets; | 1511 | goto free_widgets; |
1524 | 1512 | ||
@@ -1544,17 +1532,17 @@ free_widgets: | |||
1544 | 1532 | ||
1545 | static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) | 1533 | static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) |
1546 | { | 1534 | { |
1547 | struct hdac_ext_device *edev = aptr; | 1535 | struct hdac_device *hdev = aptr; |
1548 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1536 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1549 | struct hdac_hdmi_pin *pin = NULL; | 1537 | struct hdac_hdmi_pin *pin = NULL; |
1550 | struct hdac_hdmi_port *hport = NULL; | 1538 | struct hdac_hdmi_port *hport = NULL; |
1551 | struct snd_soc_component *component = edev->scodec; | 1539 | struct snd_soc_component *component = hdmi->component; |
1552 | int i; | 1540 | int i; |
1553 | 1541 | ||
1554 | /* Don't know how this mapping is derived */ | 1542 | /* Don't know how this mapping is derived */ |
1555 | hda_nid_t pin_nid = port + 0x04; | 1543 | hda_nid_t pin_nid = port + 0x04; |
1556 | 1544 | ||
1557 | dev_dbg(&edev->hdev.dev, "%s: for pin:%d port=%d\n", __func__, | 1545 | dev_dbg(&hdev->dev, "%s: for pin:%d port=%d\n", __func__, |
1558 | pin_nid, pipe); | 1546 | pin_nid, pipe); |
1559 | 1547 | ||
1560 | /* | 1548 | /* |
@@ -1567,7 +1555,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) | |||
1567 | SNDRV_CTL_POWER_D0) | 1555 | SNDRV_CTL_POWER_D0) |
1568 | return; | 1556 | return; |
1569 | 1557 | ||
1570 | if (atomic_read(&edev->hdev.in_pm)) | 1558 | if (atomic_read(&hdev->in_pm)) |
1571 | return; | 1559 | return; |
1572 | 1560 | ||
1573 | list_for_each_entry(pin, &hdmi->pin_list, head) { | 1561 | list_for_each_entry(pin, &hdmi->pin_list, head) { |
@@ -1614,15 +1602,15 @@ static struct snd_pcm *hdac_hdmi_get_pcm_from_id(struct snd_soc_card *card, | |||
1614 | 1602 | ||
1615 | /* create jack pin kcontrols */ | 1603 | /* create jack pin kcontrols */ |
1616 | static int create_fill_jack_kcontrols(struct snd_soc_card *card, | 1604 | static int create_fill_jack_kcontrols(struct snd_soc_card *card, |
1617 | struct hdac_ext_device *edev) | 1605 | struct hdac_device *hdev) |
1618 | { | 1606 | { |
1619 | struct hdac_hdmi_pin *pin; | 1607 | struct hdac_hdmi_pin *pin; |
1620 | struct snd_kcontrol_new *kc; | 1608 | struct snd_kcontrol_new *kc; |
1621 | char kc_name[NAME_SIZE], xname[NAME_SIZE]; | 1609 | char kc_name[NAME_SIZE], xname[NAME_SIZE]; |
1622 | char *name; | 1610 | char *name; |
1623 | int i = 0, j; | 1611 | int i = 0, j; |
1624 | struct snd_soc_component *component = edev->scodec; | 1612 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1625 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1613 | struct snd_soc_component *component = hdmi->component; |
1626 | 1614 | ||
1627 | kc = devm_kcalloc(component->dev, hdmi->num_ports, | 1615 | kc = devm_kcalloc(component->dev, hdmi->num_ports, |
1628 | sizeof(*kc), GFP_KERNEL); | 1616 | sizeof(*kc), GFP_KERNEL); |
@@ -1659,8 +1647,8 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, | |||
1659 | int hdac_hdmi_jack_port_init(struct snd_soc_component *component, | 1647 | int hdac_hdmi_jack_port_init(struct snd_soc_component *component, |
1660 | struct snd_soc_dapm_context *dapm) | 1648 | struct snd_soc_dapm_context *dapm) |
1661 | { | 1649 | { |
1662 | struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); | 1650 | struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); |
1663 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1651 | struct hdac_device *hdev = hdmi->hdev; |
1664 | struct hdac_hdmi_pin *pin; | 1652 | struct hdac_hdmi_pin *pin; |
1665 | struct snd_soc_dapm_widget *widgets; | 1653 | struct snd_soc_dapm_widget *widgets; |
1666 | struct snd_soc_dapm_route *route; | 1654 | struct snd_soc_dapm_route *route; |
@@ -1715,7 +1703,7 @@ int hdac_hdmi_jack_port_init(struct snd_soc_component *component, | |||
1715 | return ret; | 1703 | return ret; |
1716 | 1704 | ||
1717 | /* Add Jack Pin switch Kcontrol */ | 1705 | /* Add Jack Pin switch Kcontrol */ |
1718 | ret = create_fill_jack_kcontrols(dapm->card, edev); | 1706 | ret = create_fill_jack_kcontrols(dapm->card, hdev); |
1719 | 1707 | ||
1720 | if (ret < 0) | 1708 | if (ret < 0) |
1721 | return ret; | 1709 | return ret; |
@@ -1735,8 +1723,8 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, | |||
1735 | struct snd_soc_jack *jack) | 1723 | struct snd_soc_jack *jack) |
1736 | { | 1724 | { |
1737 | struct snd_soc_component *component = dai->component; | 1725 | struct snd_soc_component *component = dai->component; |
1738 | struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); | 1726 | struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); |
1739 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1727 | struct hdac_device *hdev = hdmi->hdev; |
1740 | struct hdac_hdmi_pcm *pcm; | 1728 | struct hdac_hdmi_pcm *pcm; |
1741 | struct snd_pcm *snd_pcm; | 1729 | struct snd_pcm *snd_pcm; |
1742 | int err; | 1730 | int err; |
@@ -1758,7 +1746,7 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, | |||
1758 | if (snd_pcm) { | 1746 | if (snd_pcm) { |
1759 | err = snd_hdac_add_chmap_ctls(snd_pcm, device, &hdmi->chmap); | 1747 | err = snd_hdac_add_chmap_ctls(snd_pcm, device, &hdmi->chmap); |
1760 | if (err < 0) { | 1748 | if (err < 0) { |
1761 | dev_err(&edev->hdev.dev, | 1749 | dev_err(&hdev->dev, |
1762 | "chmap control add failed with err: %d for pcm: %d\n", | 1750 | "chmap control add failed with err: %d for pcm: %d\n", |
1763 | err, device); | 1751 | err, device); |
1764 | kfree(pcm); | 1752 | kfree(pcm); |
@@ -1772,7 +1760,7 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, | |||
1772 | } | 1760 | } |
1773 | EXPORT_SYMBOL_GPL(hdac_hdmi_jack_init); | 1761 | EXPORT_SYMBOL_GPL(hdac_hdmi_jack_init); |
1774 | 1762 | ||
1775 | static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev, | 1763 | static void hdac_hdmi_present_sense_all_pins(struct hdac_device *hdev, |
1776 | struct hdac_hdmi_priv *hdmi, bool detect_pin_caps) | 1764 | struct hdac_hdmi_priv *hdmi, bool detect_pin_caps) |
1777 | { | 1765 | { |
1778 | int i; | 1766 | int i; |
@@ -1781,7 +1769,7 @@ static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev, | |||
1781 | list_for_each_entry(pin, &hdmi->pin_list, head) { | 1769 | list_for_each_entry(pin, &hdmi->pin_list, head) { |
1782 | if (detect_pin_caps) { | 1770 | if (detect_pin_caps) { |
1783 | 1771 | ||
1784 | if (hdac_hdmi_get_port_len(edev, pin->nid) == 0) | 1772 | if (hdac_hdmi_get_port_len(hdev, pin->nid) == 0) |
1785 | pin->mst_capable = false; | 1773 | pin->mst_capable = false; |
1786 | else | 1774 | else |
1787 | pin->mst_capable = true; | 1775 | pin->mst_capable = true; |
@@ -1798,68 +1786,68 @@ static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev, | |||
1798 | 1786 | ||
1799 | static int hdmi_codec_probe(struct snd_soc_component *component) | 1787 | static int hdmi_codec_probe(struct snd_soc_component *component) |
1800 | { | 1788 | { |
1801 | struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); | 1789 | struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); |
1802 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1790 | struct hdac_device *hdev = hdmi->hdev; |
1803 | struct snd_soc_dapm_context *dapm = | 1791 | struct snd_soc_dapm_context *dapm = |
1804 | snd_soc_component_get_dapm(component); | 1792 | snd_soc_component_get_dapm(component); |
1805 | struct hdac_ext_link *hlink = NULL; | 1793 | struct hdac_ext_link *hlink = NULL; |
1806 | int ret; | 1794 | int ret; |
1807 | 1795 | ||
1808 | edev->scodec = component; | 1796 | hdmi->component = component; |
1809 | 1797 | ||
1810 | /* | 1798 | /* |
1811 | * hold the ref while we probe, also no need to drop the ref on | 1799 | * hold the ref while we probe, also no need to drop the ref on |
1812 | * exit, we call pm_runtime_suspend() so that will do for us | 1800 | * exit, we call pm_runtime_suspend() so that will do for us |
1813 | */ | 1801 | */ |
1814 | hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdev.dev)); | 1802 | hlink = snd_hdac_ext_bus_get_link(hbus_to_ebus(hdev->bus), |
1803 | dev_name(&hdev->dev)); | ||
1815 | if (!hlink) { | 1804 | if (!hlink) { |
1816 | dev_err(&edev->hdev.dev, "hdac link not found\n"); | 1805 | dev_err(&hdev->dev, "hdac link not found\n"); |
1817 | return -EIO; | 1806 | return -EIO; |
1818 | } | 1807 | } |
1819 | 1808 | ||
1820 | snd_hdac_ext_bus_link_get(edev->ebus, hlink); | 1809 | snd_hdac_ext_bus_link_get(hbus_to_ebus(hdev->bus), hlink); |
1821 | 1810 | ||
1822 | ret = create_fill_widget_route_map(dapm); | 1811 | ret = create_fill_widget_route_map(dapm); |
1823 | if (ret < 0) | 1812 | if (ret < 0) |
1824 | return ret; | 1813 | return ret; |
1825 | 1814 | ||
1826 | aops.audio_ptr = edev; | 1815 | aops.audio_ptr = hdev; |
1827 | ret = snd_hdac_i915_register_notifier(&aops); | 1816 | ret = snd_hdac_i915_register_notifier(&aops); |
1828 | if (ret < 0) { | 1817 | if (ret < 0) { |
1829 | dev_err(&edev->hdev.dev, "notifier register failed: err: %d\n", | 1818 | dev_err(&hdev->dev, "notifier register failed: err: %d\n", ret); |
1830 | ret); | ||
1831 | return ret; | 1819 | return ret; |
1832 | } | 1820 | } |
1833 | 1821 | ||
1834 | hdac_hdmi_present_sense_all_pins(edev, hdmi, true); | 1822 | hdac_hdmi_present_sense_all_pins(hdev, hdmi, true); |
1835 | /* Imp: Store the card pointer in hda_codec */ | 1823 | /* Imp: Store the card pointer in hda_codec */ |
1836 | edev->card = dapm->card->snd_card; | 1824 | hdmi->card = dapm->card->snd_card; |
1837 | 1825 | ||
1838 | /* | 1826 | /* |
1839 | * hdac_device core already sets the state to active and calls | 1827 | * hdac_device core already sets the state to active and calls |
1840 | * get_noresume. So enable runtime and set the device to suspend. | 1828 | * get_noresume. So enable runtime and set the device to suspend. |
1841 | */ | 1829 | */ |
1842 | pm_runtime_enable(&edev->hdev.dev); | 1830 | pm_runtime_enable(&hdev->dev); |
1843 | pm_runtime_put(&edev->hdev.dev); | 1831 | pm_runtime_put(&hdev->dev); |
1844 | pm_runtime_suspend(&edev->hdev.dev); | 1832 | pm_runtime_suspend(&hdev->dev); |
1845 | 1833 | ||
1846 | return 0; | 1834 | return 0; |
1847 | } | 1835 | } |
1848 | 1836 | ||
1849 | static void hdmi_codec_remove(struct snd_soc_component *component) | 1837 | static void hdmi_codec_remove(struct snd_soc_component *component) |
1850 | { | 1838 | { |
1851 | struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); | 1839 | struct hdac_hdmi_priv *hdmi = snd_soc_component_get_drvdata(component); |
1840 | struct hdac_device *hdev = hdmi->hdev; | ||
1852 | 1841 | ||
1853 | pm_runtime_disable(&edev->hdev.dev); | 1842 | pm_runtime_disable(&hdev->dev); |
1854 | } | 1843 | } |
1855 | 1844 | ||
1856 | #ifdef CONFIG_PM | 1845 | #ifdef CONFIG_PM |
1857 | static int hdmi_codec_prepare(struct device *dev) | 1846 | static int hdmi_codec_prepare(struct device *dev) |
1858 | { | 1847 | { |
1859 | struct hdac_ext_device *edev = to_hda_ext_device(dev); | 1848 | struct hdac_device *hdev = dev_to_hdac_dev(dev); |
1860 | struct hdac_device *hdev = &edev->hdev; | ||
1861 | 1849 | ||
1862 | pm_runtime_get_sync(&edev->hdev.dev); | 1850 | pm_runtime_get_sync(&hdev->dev); |
1863 | 1851 | ||
1864 | /* | 1852 | /* |
1865 | * Power down afg. | 1853 | * Power down afg. |
@@ -1876,16 +1864,15 @@ static int hdmi_codec_prepare(struct device *dev) | |||
1876 | 1864 | ||
1877 | static void hdmi_codec_complete(struct device *dev) | 1865 | static void hdmi_codec_complete(struct device *dev) |
1878 | { | 1866 | { |
1879 | struct hdac_ext_device *edev = to_hda_ext_device(dev); | 1867 | struct hdac_device *hdev = dev_to_hdac_dev(dev); |
1880 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 1868 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1881 | struct hdac_device *hdev = &edev->hdev; | ||
1882 | 1869 | ||
1883 | /* Power up afg */ | 1870 | /* Power up afg */ |
1884 | snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, | 1871 | snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, |
1885 | AC_PWRST_D0); | 1872 | AC_PWRST_D0); |
1886 | 1873 | ||
1887 | hdac_hdmi_skl_enable_all_pins(&edev->hdev); | 1874 | hdac_hdmi_skl_enable_all_pins(hdev); |
1888 | hdac_hdmi_skl_enable_dp12(&edev->hdev); | 1875 | hdac_hdmi_skl_enable_dp12(hdev); |
1889 | 1876 | ||
1890 | /* | 1877 | /* |
1891 | * As the ELD notify callback request is not entertained while the | 1878 | * As the ELD notify callback request is not entertained while the |
@@ -1893,9 +1880,9 @@ static void hdmi_codec_complete(struct device *dev) | |||
1893 | * all pins here. pin capablity change is not support, so use the | 1880 | * all pins here. pin capablity change is not support, so use the |
1894 | * already set pin caps. | 1881 | * already set pin caps. |
1895 | */ | 1882 | */ |
1896 | hdac_hdmi_present_sense_all_pins(edev, hdmi, false); | 1883 | hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); |
1897 | 1884 | ||
1898 | pm_runtime_put_sync(&edev->hdev.dev); | 1885 | pm_runtime_put_sync(&hdev->dev); |
1899 | } | 1886 | } |
1900 | #else | 1887 | #else |
1901 | #define hdmi_codec_prepare NULL | 1888 | #define hdmi_codec_prepare NULL |
@@ -1922,7 +1909,6 @@ static void hdac_hdmi_get_chmap(struct hdac_device *hdev, int pcm_idx, | |||
1922 | static void hdac_hdmi_set_chmap(struct hdac_device *hdev, int pcm_idx, | 1909 | static void hdac_hdmi_set_chmap(struct hdac_device *hdev, int pcm_idx, |
1923 | unsigned char *chmap, int prepared) | 1910 | unsigned char *chmap, int prepared) |
1924 | { | 1911 | { |
1925 | struct hdac_ext_device *edev = to_ehdac_device(hdev); | ||
1926 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); | 1912 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
1927 | struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); | 1913 | struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); |
1928 | struct hdac_hdmi_port *port; | 1914 | struct hdac_hdmi_port *port; |
@@ -1938,7 +1924,7 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdev, int pcm_idx, | |||
1938 | memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap)); | 1924 | memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap)); |
1939 | list_for_each_entry(port, &pcm->port_list, head) | 1925 | list_for_each_entry(port, &pcm->port_list, head) |
1940 | if (prepared) | 1926 | if (prepared) |
1941 | hdac_hdmi_setup_audio_infoframe(edev, pcm, port); | 1927 | hdac_hdmi_setup_audio_infoframe(hdev, pcm, port); |
1942 | mutex_unlock(&pcm->lock); | 1928 | mutex_unlock(&pcm->lock); |
1943 | } | 1929 | } |
1944 | 1930 | ||
@@ -1987,10 +1973,9 @@ static struct hdac_hdmi_drv_data intel_drv_data = { | |||
1987 | .vendor_nid = INTEL_VENDOR_NID, | 1973 | .vendor_nid = INTEL_VENDOR_NID, |
1988 | }; | 1974 | }; |
1989 | 1975 | ||
1990 | static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) | 1976 | static int hdac_hdmi_dev_probe(struct hdac_device *hdev) |
1991 | { | 1977 | { |
1992 | struct hdac_device *hdev = &edev->hdev; | 1978 | struct hdac_hdmi_priv *hdmi_priv = NULL; |
1993 | struct hdac_hdmi_priv *hdmi_priv; | ||
1994 | struct snd_soc_dai_driver *hdmi_dais = NULL; | 1979 | struct snd_soc_dai_driver *hdmi_dais = NULL; |
1995 | struct hdac_ext_link *hlink = NULL; | 1980 | struct hdac_ext_link *hlink = NULL; |
1996 | int num_dais = 0; | 1981 | int num_dais = 0; |
@@ -1999,24 +1984,25 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) | |||
1999 | const struct hda_device_id *hdac_id = hdac_get_device_id(hdev, hdrv); | 1984 | const struct hda_device_id *hdac_id = hdac_get_device_id(hdev, hdrv); |
2000 | 1985 | ||
2001 | /* hold the ref while we probe */ | 1986 | /* hold the ref while we probe */ |
2002 | hlink = snd_hdac_ext_bus_get_link(edev->ebus, dev_name(&edev->hdev.dev)); | 1987 | hlink = snd_hdac_ext_bus_get_link(hbus_to_ebus(hdev->bus), |
1988 | dev_name(&hdev->dev)); | ||
2003 | if (!hlink) { | 1989 | if (!hlink) { |
2004 | dev_err(&edev->hdev.dev, "hdac link not found\n"); | 1990 | dev_err(&hdev->dev, "hdac link not found\n"); |
2005 | return -EIO; | 1991 | return -EIO; |
2006 | } | 1992 | } |
2007 | 1993 | ||
2008 | snd_hdac_ext_bus_link_get(edev->ebus, hlink); | 1994 | snd_hdac_ext_bus_link_get(hbus_to_ebus(hdev->bus), hlink); |
2009 | 1995 | ||
2010 | hdmi_priv = devm_kzalloc(&hdev->dev, sizeof(*hdmi_priv), GFP_KERNEL); | 1996 | hdmi_priv = devm_kzalloc(&hdev->dev, sizeof(*hdmi_priv), GFP_KERNEL); |
2011 | if (hdmi_priv == NULL) | 1997 | if (hdmi_priv == NULL) |
2012 | return -ENOMEM; | 1998 | return -ENOMEM; |
2013 | 1999 | ||
2014 | edev->private_data = hdmi_priv; | ||
2015 | snd_hdac_register_chmap_ops(hdev, &hdmi_priv->chmap); | 2000 | snd_hdac_register_chmap_ops(hdev, &hdmi_priv->chmap); |
2016 | hdmi_priv->chmap.ops.get_chmap = hdac_hdmi_get_chmap; | 2001 | hdmi_priv->chmap.ops.get_chmap = hdac_hdmi_get_chmap; |
2017 | hdmi_priv->chmap.ops.set_chmap = hdac_hdmi_set_chmap; | 2002 | hdmi_priv->chmap.ops.set_chmap = hdac_hdmi_set_chmap; |
2018 | hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; | 2003 | hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; |
2019 | hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; | 2004 | hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; |
2005 | hdmi_priv->hdev = hdev; | ||
2020 | 2006 | ||
2021 | if (!hdac_id) | 2007 | if (!hdac_id) |
2022 | return -ENODEV; | 2008 | return -ENODEV; |
@@ -2027,7 +2013,7 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) | |||
2027 | else | 2013 | else |
2028 | hdmi_priv->drv_data = &intel_drv_data; | 2014 | hdmi_priv->drv_data = &intel_drv_data; |
2029 | 2015 | ||
2030 | dev_set_drvdata(&hdev->dev, edev); | 2016 | dev_set_drvdata(&hdev->dev, hdmi_priv); |
2031 | 2017 | ||
2032 | INIT_LIST_HEAD(&hdmi_priv->pin_list); | 2018 | INIT_LIST_HEAD(&hdmi_priv->pin_list); |
2033 | INIT_LIST_HEAD(&hdmi_priv->cvt_list); | 2019 | INIT_LIST_HEAD(&hdmi_priv->cvt_list); |
@@ -2038,15 +2024,15 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) | |||
2038 | * Turned off in the runtime_suspend during the first explicit | 2024 | * Turned off in the runtime_suspend during the first explicit |
2039 | * pm_runtime_suspend call. | 2025 | * pm_runtime_suspend call. |
2040 | */ | 2026 | */ |
2041 | ret = snd_hdac_display_power(edev->hdev.bus, true); | 2027 | ret = snd_hdac_display_power(hdev->bus, true); |
2042 | if (ret < 0) { | 2028 | if (ret < 0) { |
2043 | dev_err(&edev->hdev.dev, | 2029 | dev_err(&hdev->dev, |
2044 | "Cannot turn on display power on i915 err: %d\n", | 2030 | "Cannot turn on display power on i915 err: %d\n", |
2045 | ret); | 2031 | ret); |
2046 | return ret; | 2032 | return ret; |
2047 | } | 2033 | } |
2048 | 2034 | ||
2049 | ret = hdac_hdmi_parse_and_map_nid(edev, &hdmi_dais, &num_dais); | 2035 | ret = hdac_hdmi_parse_and_map_nid(hdev, &hdmi_dais, &num_dais); |
2050 | if (ret < 0) { | 2036 | if (ret < 0) { |
2051 | dev_err(&hdev->dev, | 2037 | dev_err(&hdev->dev, |
2052 | "Failed in parse and map nid with err: %d\n", ret); | 2038 | "Failed in parse and map nid with err: %d\n", ret); |
@@ -2058,14 +2044,14 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) | |||
2058 | ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, | 2044 | ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, |
2059 | hdmi_dais, num_dais); | 2045 | hdmi_dais, num_dais); |
2060 | 2046 | ||
2061 | snd_hdac_ext_bus_link_put(edev->ebus, hlink); | 2047 | snd_hdac_ext_bus_link_put(hbus_to_ebus(hdev->bus), hlink); |
2062 | 2048 | ||
2063 | return ret; | 2049 | return ret; |
2064 | } | 2050 | } |
2065 | 2051 | ||
2066 | static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) | 2052 | static int hdac_hdmi_dev_remove(struct hdac_device *hdev) |
2067 | { | 2053 | { |
2068 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); | 2054 | struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); |
2069 | struct hdac_hdmi_pin *pin, *pin_next; | 2055 | struct hdac_hdmi_pin *pin, *pin_next; |
2070 | struct hdac_hdmi_cvt *cvt, *cvt_next; | 2056 | struct hdac_hdmi_cvt *cvt, *cvt_next; |
2071 | struct hdac_hdmi_pcm *pcm, *pcm_next; | 2057 | struct hdac_hdmi_pcm *pcm, *pcm_next; |
@@ -2105,8 +2091,7 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) | |||
2105 | #ifdef CONFIG_PM | 2091 | #ifdef CONFIG_PM |
2106 | static int hdac_hdmi_runtime_suspend(struct device *dev) | 2092 | static int hdac_hdmi_runtime_suspend(struct device *dev) |
2107 | { | 2093 | { |
2108 | struct hdac_ext_device *edev = to_hda_ext_device(dev); | 2094 | struct hdac_device *hdev = dev_to_hdac_dev(dev); |
2109 | struct hdac_device *hdev = &edev->hdev; | ||
2110 | struct hdac_bus *bus = hdev->bus; | 2095 | struct hdac_bus *bus = hdev->bus; |
2111 | struct hdac_ext_bus *ebus = hbus_to_ebus(bus); | 2096 | struct hdac_ext_bus *ebus = hbus_to_ebus(bus); |
2112 | struct hdac_ext_link *hlink = NULL; | 2097 | struct hdac_ext_link *hlink = NULL; |
@@ -2129,7 +2114,7 @@ static int hdac_hdmi_runtime_suspend(struct device *dev) | |||
2129 | AC_PWRST_D3); | 2114 | AC_PWRST_D3); |
2130 | err = snd_hdac_display_power(bus, false); | 2115 | err = snd_hdac_display_power(bus, false); |
2131 | if (err < 0) { | 2116 | if (err < 0) { |
2132 | dev_err(bus->dev, "Cannot turn on display power on i915\n"); | 2117 | dev_err(dev, "Cannot turn on display power on i915\n"); |
2133 | return err; | 2118 | return err; |
2134 | } | 2119 | } |
2135 | 2120 | ||
@@ -2146,8 +2131,7 @@ static int hdac_hdmi_runtime_suspend(struct device *dev) | |||
2146 | 2131 | ||
2147 | static int hdac_hdmi_runtime_resume(struct device *dev) | 2132 | static int hdac_hdmi_runtime_resume(struct device *dev) |
2148 | { | 2133 | { |
2149 | struct hdac_ext_device *edev = to_hda_ext_device(dev); | 2134 | struct hdac_device *hdev = dev_to_hdac_dev(dev); |
2150 | struct hdac_device *hdev = &edev->hdev; | ||
2151 | struct hdac_bus *bus = hdev->bus; | 2135 | struct hdac_bus *bus = hdev->bus; |
2152 | struct hdac_ext_bus *ebus = hbus_to_ebus(bus); | 2136 | struct hdac_ext_bus *ebus = hbus_to_ebus(bus); |
2153 | struct hdac_ext_link *hlink = NULL; | 2137 | struct hdac_ext_link *hlink = NULL; |
@@ -2169,12 +2153,12 @@ static int hdac_hdmi_runtime_resume(struct device *dev) | |||
2169 | 2153 | ||
2170 | err = snd_hdac_display_power(bus, true); | 2154 | err = snd_hdac_display_power(bus, true); |
2171 | if (err < 0) { | 2155 | if (err < 0) { |
2172 | dev_err(bus->dev, "Cannot turn on display power on i915\n"); | 2156 | dev_err(dev, "Cannot turn on display power on i915\n"); |
2173 | return err; | 2157 | return err; |
2174 | } | 2158 | } |
2175 | 2159 | ||
2176 | hdac_hdmi_skl_enable_all_pins(&edev->hdev); | 2160 | hdac_hdmi_skl_enable_all_pins(hdev); |
2177 | hdac_hdmi_skl_enable_dp12(&edev->hdev); | 2161 | hdac_hdmi_skl_enable_dp12(hdev); |
2178 | 2162 | ||
2179 | /* Power up afg */ | 2163 | /* Power up afg */ |
2180 | snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, | 2164 | snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, |