xref: /openbmc/linux/sound/soc/intel/boards/skl_hda_dsp_common.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1e149ca29SPierre-Louis Bossart /* SPDX-License-Identifier: GPL-2.0-only */
27c33b5f1SRakesh Ughreja /*
37c33b5f1SRakesh Ughreja  * Copyright(c) 2015-18 Intel Corporation.
47c33b5f1SRakesh Ughreja  */
57c33b5f1SRakesh Ughreja 
67c33b5f1SRakesh Ughreja /*
77c33b5f1SRakesh Ughreja  * This file defines data structures used in Machine Driver for Intel
87c33b5f1SRakesh Ughreja  * platforms with HDA Codecs.
97c33b5f1SRakesh Ughreja  */
107c33b5f1SRakesh Ughreja 
110f163110SKai Vehmanen #ifndef __SKL_HDA_DSP_COMMON_H
120f163110SKai Vehmanen #define __SKL_HDA_DSP_COMMON_H
137c33b5f1SRakesh Ughreja #include <linux/module.h>
147c33b5f1SRakesh Ughreja #include <linux/platform_device.h>
157c33b5f1SRakesh Ughreja #include <sound/core.h>
167c33b5f1SRakesh Ughreja #include <sound/jack.h>
177de9a47cSKai Vehmanen #include <sound/hda_codec.h>
187de9a47cSKai Vehmanen #include "../../codecs/hdac_hda.h"
197de9a47cSKai Vehmanen #include "hda_dsp_common.h"
207c33b5f1SRakesh Ughreja 
212b131b5aSRander Wang #define HDA_DSP_MAX_BE_DAI_LINKS 7
227c33b5f1SRakesh Ughreja 
237c33b5f1SRakesh Ughreja struct skl_hda_hdmi_pcm {
247c33b5f1SRakesh Ughreja 	struct list_head head;
257c33b5f1SRakesh Ughreja 	struct snd_soc_dai *codec_dai;
267c33b5f1SRakesh Ughreja 	struct snd_soc_jack hdmi_jack;
277c33b5f1SRakesh Ughreja 	int device;
287c33b5f1SRakesh Ughreja };
297c33b5f1SRakesh Ughreja 
307c33b5f1SRakesh Ughreja struct skl_hda_private {
317c33b5f1SRakesh Ughreja 	struct list_head hdmi_pcm_list;
327c33b5f1SRakesh Ughreja 	int pcm_count;
337c33b5f1SRakesh Ughreja 	int dai_index;
347c33b5f1SRakesh Ughreja 	const char *platform_name;
357de9a47cSKai Vehmanen 	bool common_hdmi_codec_drv;
36*ffc6d45dSKai Vehmanen 	bool idisp_codec;
377c33b5f1SRakesh Ughreja };
387c33b5f1SRakesh Ughreja 
397c33b5f1SRakesh Ughreja extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS];
407c33b5f1SRakesh Ughreja int skl_hda_hdmi_jack_init(struct snd_soc_card *card);
417c33b5f1SRakesh Ughreja int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device);
427c33b5f1SRakesh Ughreja 
437de9a47cSKai Vehmanen /*
447de9a47cSKai Vehmanen  * Search card topology and register HDMI PCM related controls
457de9a47cSKai Vehmanen  * to codec driver.
467de9a47cSKai Vehmanen  */
skl_hda_hdmi_build_controls(struct snd_soc_card * card)477de9a47cSKai Vehmanen static inline int skl_hda_hdmi_build_controls(struct snd_soc_card *card)
487de9a47cSKai Vehmanen {
497de9a47cSKai Vehmanen 	struct skl_hda_private *ctx = snd_soc_card_get_drvdata(card);
507de9a47cSKai Vehmanen 	struct snd_soc_component *component;
517de9a47cSKai Vehmanen 	struct skl_hda_hdmi_pcm *pcm;
527de9a47cSKai Vehmanen 
53d2ad9d6cSKai Vehmanen 	/* HDMI disabled, do not create controls */
54d2ad9d6cSKai Vehmanen 	if (list_empty(&ctx->hdmi_pcm_list))
55d2ad9d6cSKai Vehmanen 		return 0;
56d2ad9d6cSKai Vehmanen 
577de9a47cSKai Vehmanen 	pcm = list_first_entry(&ctx->hdmi_pcm_list, struct skl_hda_hdmi_pcm,
587de9a47cSKai Vehmanen 			       head);
597de9a47cSKai Vehmanen 	component = pcm->codec_dai->component;
607de9a47cSKai Vehmanen 	if (!component)
617de9a47cSKai Vehmanen 		return -EINVAL;
627de9a47cSKai Vehmanen 
637de9a47cSKai Vehmanen 	return hda_dsp_hdmi_build_controls(card, component);
647de9a47cSKai Vehmanen }
657de9a47cSKai Vehmanen 
667c33b5f1SRakesh Ughreja #endif /* __SOUND_SOC_HDA_DSP_COMMON_H */
67