Meng Wang | 43bbb87 | 2018-12-10 12:32:05 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Meng Wang | ee084a0 | 2018-09-04 16:11:58 +0800 | [diff] [blame] | 2 | /* Copyright (c) 2011-2014, 2017-2018, The Linux Foundation. All rights reserved. |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | #include <linux/init.h> |
| 6 | #include <linux/module.h> |
| 7 | #include <linux/platform_device.h> |
| 8 | #include <linux/of_device.h> |
| 9 | #include <sound/core.h> |
| 10 | #include <sound/soc.h> |
| 11 | #include <sound/pcm.h> |
| 12 | |
Meng Wang | ee084a0 | 2018-09-04 16:11:58 +0800 | [diff] [blame] | 13 | #define DRV_NAME "msm-pcm-hostless" |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 14 | |
| 15 | static int msm_pcm_hostless_prepare(struct snd_pcm_substream *substream) |
| 16 | { |
| 17 | if (!substream) { |
| 18 | pr_err("%s: invalid params\n", __func__); |
| 19 | return -EINVAL; |
| 20 | } |
| 21 | pm_qos_remove_request(&substream->latency_pm_qos_req); |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | static const struct snd_pcm_ops msm_pcm_hostless_ops = { |
| 26 | .prepare = msm_pcm_hostless_prepare |
| 27 | }; |
| 28 | |
Meng Wang | ee084a0 | 2018-09-04 16:11:58 +0800 | [diff] [blame] | 29 | static struct snd_soc_component_driver msm_soc_hostless_component = { |
| 30 | .name = DRV_NAME, |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 31 | .ops = &msm_pcm_hostless_ops, |
| 32 | }; |
| 33 | |
| 34 | static int msm_pcm_hostless_probe(struct platform_device *pdev) |
| 35 | { |
| 36 | |
| 37 | pr_debug("%s: dev name %s\n", __func__, dev_name(&pdev->dev)); |
Meng Wang | ee084a0 | 2018-09-04 16:11:58 +0800 | [diff] [blame] | 38 | return snd_soc_register_component(&pdev->dev, |
| 39 | &msm_soc_hostless_component, |
| 40 | NULL, 0); |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | static int msm_pcm_hostless_remove(struct platform_device *pdev) |
| 44 | { |
Meng Wang | ee084a0 | 2018-09-04 16:11:58 +0800 | [diff] [blame] | 45 | snd_soc_unregister_component(&pdev->dev); |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | static const struct of_device_id msm_pcm_hostless_dt_match[] = { |
| 50 | {.compatible = "qcom,msm-pcm-hostless"}, |
| 51 | {} |
| 52 | }; |
| 53 | |
| 54 | static struct platform_driver msm_pcm_hostless_driver = { |
| 55 | .driver = { |
| 56 | .name = "msm-pcm-hostless", |
| 57 | .owner = THIS_MODULE, |
| 58 | .of_match_table = msm_pcm_hostless_dt_match, |
| 59 | }, |
| 60 | .probe = msm_pcm_hostless_probe, |
| 61 | .remove = msm_pcm_hostless_remove, |
| 62 | }; |
| 63 | |
Laxminath Kasam | 8b1366a | 2017-10-05 01:44:16 +0530 | [diff] [blame] | 64 | int __init msm_pcm_hostless_init(void) |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 65 | { |
| 66 | return platform_driver_register(&msm_pcm_hostless_driver); |
| 67 | } |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 68 | |
Asish Bhattacharya | 5faacb3 | 2017-12-04 17:23:15 +0530 | [diff] [blame] | 69 | void msm_pcm_hostless_exit(void) |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 70 | { |
| 71 | platform_driver_unregister(&msm_pcm_hostless_driver); |
| 72 | } |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 73 | |
| 74 | MODULE_DESCRIPTION("Hostless platform driver"); |
| 75 | MODULE_LICENSE("GPL v2"); |