soc-card.h 3.56 KB
Newer Older
Kuninori Morimoto's avatar
Kuninori Morimoto committed
1 2 3 4 5 6 7 8 9 10
/* SPDX-License-Identifier: GPL-2.0
 *
 * soc-card.h
 *
 * Copyright (C) 2019 Renesas Electronics Corp.
 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
 */
#ifndef __SOC_CARD_H
#define __SOC_CARD_H

11
enum snd_soc_card_subclass {
12
	SND_SOC_CARD_CLASS_ROOT		= 0,
13 14 15
	SND_SOC_CARD_CLASS_RUNTIME	= 1,
};

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
static inline void snd_soc_card_mutex_lock_root(struct snd_soc_card *card)
{
	mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_ROOT);
}

static inline void snd_soc_card_mutex_lock(struct snd_soc_card *card)
{
	mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
}

static inline void snd_soc_card_mutex_unlock(struct snd_soc_card *card)
{
	mutex_unlock(&card->mutex);
}

31 32
struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
					       const char *name);
33 34
struct snd_kcontrol *snd_soc_card_get_kcontrol_locked(struct snd_soc_card *soc_card,
						      const char *name);
35
int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
36 37 38 39 40
			  struct snd_soc_jack *jack);
int snd_soc_card_jack_new_pins(struct snd_soc_card *card, const char *id,
			       int type, struct snd_soc_jack *jack,
			       struct snd_soc_jack_pin *pins,
			       unsigned int num_pins);
41

42
int snd_soc_card_suspend_pre(struct snd_soc_card *card);
43
int snd_soc_card_suspend_post(struct snd_soc_card *card);
44
int snd_soc_card_resume_pre(struct snd_soc_card *card);
45
int snd_soc_card_resume_post(struct snd_soc_card *card);
46

47
int snd_soc_card_probe(struct snd_soc_card *card);
48
int snd_soc_card_late_probe(struct snd_soc_card *card);
49
void snd_soc_card_fixup_controls(struct snd_soc_card *card);
50
int snd_soc_card_remove(struct snd_soc_card *card);
51

52 53 54
int snd_soc_card_set_bias_level(struct snd_soc_card *card,
				struct snd_soc_dapm_context *dapm,
				enum snd_soc_bias_level level);
55 56 57
int snd_soc_card_set_bias_level_post(struct snd_soc_card *card,
				     struct snd_soc_dapm_context *dapm,
				     enum snd_soc_bias_level level);
58

59 60
int snd_soc_card_add_dai_link(struct snd_soc_card *card,
			      struct snd_soc_dai_link *dai_link);
61 62
void snd_soc_card_remove_dai_link(struct snd_soc_card *card,
				  struct snd_soc_dai_link *dai_link);
63

64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
#ifdef CONFIG_PCI
static inline void snd_soc_card_set_pci_ssid(struct snd_soc_card *card,
					     unsigned short vendor,
					     unsigned short device)
{
	card->pci_subsystem_vendor = vendor;
	card->pci_subsystem_device = device;
	card->pci_subsystem_set = true;
}

static inline int snd_soc_card_get_pci_ssid(struct snd_soc_card *card,
					    unsigned short *vendor,
					    unsigned short *device)
{
	if (!card->pci_subsystem_set)
		return -ENOENT;

	*vendor = card->pci_subsystem_vendor;
	*device = card->pci_subsystem_device;

	return 0;
}
#else /* !CONFIG_PCI */
static inline void snd_soc_card_set_pci_ssid(struct snd_soc_card *card,
					     unsigned short vendor,
					     unsigned short device)
{
}

static inline int snd_soc_card_get_pci_ssid(struct snd_soc_card *card,
					    unsigned short *vendor,
					    unsigned short *device)
{
	return -ENOENT;
}
#endif /* CONFIG_PCI */

101 102 103 104 105 106 107 108 109 110 111 112
/* device driver data */
static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
					    void *data)
{
	card->drvdata = data;
}

static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
{
	return card->drvdata;
}

113 114 115 116 117 118 119
static inline
struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
					       const char *dai_name)
{
	struct snd_soc_pcm_runtime *rtd;

	for_each_card_rtds(card, rtd) {
120 121
		if (!strcmp(snd_soc_rtd_to_codec(rtd, 0)->name, dai_name))
			return snd_soc_rtd_to_codec(rtd, 0);
122 123 124 125 126
	}

	return NULL;
}

Kuninori Morimoto's avatar
Kuninori Morimoto committed
127
#endif /* __SOC_CARD_H */