blob: f6533a40c2bf838be5900cb76727c9b223ddecf1 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* arch/arm/mach-msm/qdsp6/routing.c
2 *
3 * Copyright (C) 2009 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <linux/fs.h>
18#include <linux/module.h>
19#include <linux/miscdevice.h>
20#include <linux/uaccess.h>
21#include <mach/debug_mm.h>
22
23extern int q6audio_set_route(const char *name);
24
25static int q6_open(struct inode *inode, struct file *file)
26{
27 pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
28 return 0;
29}
30
31static ssize_t q6_write(struct file *file, const char __user *buf,
32 size_t count, loff_t *pos)
33{
34 char cmd[32];
35
36 pr_debug("[%s:%s] count = %d", __MM_FILE__, __func__, count);
37 if (count >= sizeof(cmd)) {
38 pr_err("[%s:%s] invalid count %d\n", __MM_FILE__,
39 __func__, count);
40 return -EINVAL;
41 }
42 if (copy_from_user(cmd, buf, count))
43 return -EFAULT;
44 cmd[count] = 0;
45
46 if ((count > 1) && (cmd[count-1] == '\n'))
47 cmd[count-1] = 0;
48
49 q6audio_set_route(cmd);
50
51 return count;
52}
53
54static int q6_release(struct inode *inode, struct file *file)
55{
56 pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
57 return 0;
58}
59
60static struct file_operations q6_fops = {
61 .owner = THIS_MODULE,
62 .open = q6_open,
63 .write = q6_write,
64 .release = q6_release,
65};
66
67static struct miscdevice q6_misc = {
68 .minor = MISC_DYNAMIC_MINOR,
69 .name = "msm_audio_route",
70 .fops = &q6_fops,
71};
72
73
74static int __init q6_init(void) {
75 return misc_register(&q6_misc);
76}
77
78device_initcall(q6_init);