2 * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
4 * Copyright (C) 2002-2006 Nokia Corporation. All rights reserved.
6 * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <linux/module.h>
26 #include <linux/poll.h>
27 #include <linux/sched.h>
28 #include <asm/uaccess.h>
29 #include <asm/arch/dsp.h>
30 #include "dsp_mbcmd.h"
33 static DECLARE_WAIT_QUEUE_HEAD(read_wait_q);
34 static unsigned int change_cnt;
36 void dsp_twch_touch(void)
39 wake_up_interruptible(&read_wait_q);
43 * @count: represents the device counts of the user's interst
45 static ssize_t dsp_twch_read(struct file *file, char __user *buf, size_t count,
48 long taskstat[TASKDEV_MAX];
49 int devcount = count / sizeof(long);
53 if (dsp_cfgstat_get_stat() != CFGSTAT_READY) {
54 printk(KERN_ERR "omapdsp: dsp has not been configured.\n");
58 prepare_to_wait(&read_wait_q, &wait, TASK_INTERRUPTIBLE);
59 if (change_cnt == 0) /* last check */
61 finish_wait(&read_wait_q, &wait);
63 /* unconfigured while waiting ;-( */
64 if ((change_cnt == 0) && (dsp_cfgstat_get_stat() != CFGSTAT_READY))
67 if (devcount > TASKDEV_MAX)
68 devcount = TASKDEV_MAX;
70 count = devcount * sizeof(long);
72 for (i = 0; i < devcount; i++) {
74 * once the device state is read, the 'STALE' bit will be set
75 * so that the Dynamic Loader can distinguish the new request
78 taskstat[i] = taskdev_state_stale(i);
81 if (copy_to_user(buf, taskstat, count))
87 static unsigned int dsp_twch_poll(struct file *file, poll_table *wait)
89 unsigned int mask = 0;
91 poll_wait(file, &read_wait_q, wait);
93 mask |= POLLIN | POLLRDNORM;
98 static int dsp_twch_ioctl(struct inode *inode, struct file *file,
99 unsigned int cmd, unsigned long arg)
104 case TWCH_IOCTL_MKDEV:
107 if (copy_from_user(name, (void __user *)arg, TNM_LEN))
109 name[TNM_LEN-1] = '\0';
110 ret = dsp_mkdev(name);
114 case TWCH_IOCTL_RMDEV:
117 if (copy_from_user(name, (void __user *)arg, TNM_LEN))
119 name[TNM_LEN-1] = '\0';
120 ret = dsp_rmdev(name);
124 case TWCH_IOCTL_TADD:
126 struct omap_dsp_taddinfo ti;
127 if (copy_from_user(&ti, (void __user *)arg, sizeof(ti)))
129 ret = dsp_tadd_minor(ti.minor, ti.taskadr);
133 case TWCH_IOCTL_TDEL:
134 ret = dsp_tdel_minor(arg);
137 case TWCH_IOCTL_TKILL:
138 ret = dsp_tkill_minor(arg);
148 struct file_operations dsp_twch_fops = {
149 .owner = THIS_MODULE,
150 .read = dsp_twch_read,
151 .poll = dsp_twch_poll,
152 .ioctl = dsp_twch_ioctl,
155 void dsp_twch_start(void)
157 change_cnt = 1; /* first read will not wait */
160 void dsp_twch_stop(void)
162 wake_up_interruptible(&read_wait_q);