1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2018, Linaro Limited
4 #include <linux/module.h>
5 #include <linux/platform_device.h>
6 #include <linux/of_device.h>
8 #include <sound/soc-dapm.h>
12 static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime
*rtd
,
13 struct snd_pcm_hw_params
*params
)
15 struct snd_interval
*rate
= hw_param_interval(params
,
16 SNDRV_PCM_HW_PARAM_RATE
);
17 struct snd_interval
*channels
= hw_param_interval(params
,
18 SNDRV_PCM_HW_PARAM_CHANNELS
);
20 rate
->min
= rate
->max
= 48000;
21 channels
->min
= channels
->max
= 2;
26 static void apq8096_add_be_ops(struct snd_soc_card
*card
)
28 struct snd_soc_dai_link
*link
= card
->dai_link
;
29 int i
, num_links
= card
->num_links
;
31 for (i
= 0; i
< num_links
; i
++) {
32 if (link
->no_pcm
== 1)
33 link
->be_hw_params_fixup
= apq8096_be_hw_params_fixup
;
38 static int apq8096_platform_probe(struct platform_device
*pdev
)
40 struct snd_soc_card
*card
;
41 struct device
*dev
= &pdev
->dev
;
44 card
= kzalloc(sizeof(*card
), GFP_KERNEL
);
49 dev_set_drvdata(dev
, card
);
50 ret
= qcom_snd_parse_of(card
);
52 dev_err(dev
, "Error parsing OF data\n");
56 apq8096_add_be_ops(card
);
57 ret
= snd_soc_register_card(card
);
59 goto err_card_register
;
64 kfree(card
->dai_link
);
70 static int apq8096_platform_remove(struct platform_device
*pdev
)
72 struct snd_soc_card
*card
= dev_get_drvdata(&pdev
->dev
);
74 snd_soc_unregister_card(card
);
75 kfree(card
->dai_link
);
81 static const struct of_device_id msm_snd_apq8096_dt_match
[] = {
82 {.compatible
= "qcom,apq8096-sndcard"},
86 MODULE_DEVICE_TABLE(of
, msm_snd_apq8096_dt_match
);
88 static struct platform_driver msm_snd_apq8096_driver
= {
89 .probe
= apq8096_platform_probe
,
90 .remove
= apq8096_platform_remove
,
92 .name
= "msm-snd-apq8096",
93 .of_match_table
= msm_snd_apq8096_dt_match
,
96 module_platform_driver(msm_snd_apq8096_driver
);
97 MODULE_AUTHOR("Srinivas Kandagatla <srinivas.kandagatla@linaro.org");
98 MODULE_DESCRIPTION("APQ8096 ASoC Machine Driver");
99 MODULE_LICENSE("GPL v2");