Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/err.h> |
| 17 | #include <asm/uaccess.h> |
| 18 | #include <mach/qdsp5v2/audio_dev_ctl.h> |
| 19 | #include <mach/qdsp5v2/snddev_virtual.h> |
| 20 | #include <mach/debug_mm.h> |
| 21 | #include <linux/slab.h> |
| 22 | |
| 23 | static int snddev_virtual_open(struct msm_snddev_info *dev_info) |
| 24 | { |
| 25 | int rc = 0; |
| 26 | |
| 27 | if (!dev_info) |
| 28 | rc = -EINVAL; |
| 29 | return rc; |
| 30 | } |
| 31 | |
| 32 | static int snddev_virtual_close(struct msm_snddev_info *dev_info) |
| 33 | { |
| 34 | int rc = 0; |
| 35 | |
| 36 | if (!dev_info) |
| 37 | rc = -EINVAL; |
| 38 | return rc; |
| 39 | } |
| 40 | |
| 41 | static int snddev_virtual_set_freq(struct msm_snddev_info *dev_info, u32 rate) |
| 42 | { |
| 43 | int rc = 0; |
| 44 | |
| 45 | if (!dev_info) |
| 46 | rc = -EINVAL; |
| 47 | return rate; |
| 48 | } |
| 49 | |
| 50 | static int snddev_virtual_probe(struct platform_device *pdev) |
| 51 | { |
| 52 | int rc = 0; |
| 53 | struct snddev_virtual_data *pdata; |
| 54 | struct msm_snddev_info *dev_info; |
| 55 | |
| 56 | if (!pdev || !pdev->dev.platform_data) { |
| 57 | MM_ERR("Invalid caller\n"); |
| 58 | rc = -EPERM; |
| 59 | goto error; |
| 60 | } |
| 61 | pdata = pdev->dev.platform_data; |
| 62 | |
| 63 | dev_info = kmalloc(sizeof(struct msm_snddev_info), GFP_KERNEL); |
| 64 | if (!dev_info) { |
| 65 | rc = -ENOMEM; |
| 66 | goto error; |
| 67 | } |
| 68 | |
| 69 | dev_info->name = pdata->name; |
| 70 | dev_info->copp_id = pdata->copp_id; |
| 71 | dev_info->acdb_id = pdata->acdb_id; |
| 72 | dev_info->private_data = (void *) NULL; |
| 73 | dev_info->dev_ops.open = snddev_virtual_open; |
| 74 | dev_info->dev_ops.close = snddev_virtual_close; |
| 75 | dev_info->dev_ops.set_freq = snddev_virtual_set_freq; |
| 76 | dev_info->capability = pdata->capability; |
| 77 | dev_info->sample_rate = 8000; |
| 78 | dev_info->opened = 0; |
| 79 | dev_info->sessions = 0; |
| 80 | |
| 81 | msm_snddev_register(dev_info); |
| 82 | |
| 83 | error: |
| 84 | return rc; |
| 85 | } |
| 86 | |
| 87 | static int snddev_virtual_remove(struct platform_device *pdev) |
| 88 | { |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | static struct platform_driver snddev_virtual_driver = { |
| 93 | .probe = snddev_virtual_probe, |
| 94 | .remove = snddev_virtual_remove, |
| 95 | .driver = { .name = "snddev_virtual" } |
| 96 | }; |
| 97 | |
| 98 | static int __init snddev_virtual_init(void) |
| 99 | { |
| 100 | int rc = 0; |
| 101 | |
| 102 | MM_DBG(" snddev_virtual_init \n"); |
| 103 | rc = platform_driver_register(&snddev_virtual_driver); |
| 104 | if (IS_ERR_VALUE(rc)) { |
| 105 | MM_ERR("platform driver register failure\n"); |
| 106 | return -ENODEV; |
| 107 | } |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | static void __exit snddev_virtual_exit(void) |
| 112 | { |
| 113 | platform_driver_unregister(&snddev_virtual_driver); |
| 114 | |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | module_init(snddev_virtual_init); |
| 119 | module_exit(snddev_virtual_exit); |
| 120 | |
| 121 | MODULE_DESCRIPTION("Virtual Sound Device driver"); |
| 122 | MODULE_LICENSE("GPL v2"); |