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>
31 #include "dsp_mbcmd.h"
34 static DECLARE_WAIT_QUEUE_HEAD(read_wait_q);
35 static unsigned int change_cnt;
37 void dsp_twch_touch(void)
40 wake_up_interruptible(&read_wait_q);
44 * @count: represents the device counts of the user's interst
46 static ssize_t dsp_twch_read(struct file *file, char __user *buf, size_t count,
49 long taskstat[TASKDEV_MAX];
50 int devcount = count / sizeof(long);
54 if (dsp_cfgstat_get_stat() != CFGSTAT_READY) {
55 printk(KERN_ERR "omapdsp: dsp has not been configured.\n");
59 prepare_to_wait(&read_wait_q, &wait, TASK_INTERRUPTIBLE);
60 if (change_cnt == 0) /* last check */
62 finish_wait(&read_wait_q, &wait);
64 /* unconfigured while waiting ;-( */
65 if ((change_cnt == 0) && (dsp_cfgstat_get_stat() != CFGSTAT_READY))
68 if (devcount > TASKDEV_MAX)
69 devcount = TASKDEV_MAX;
71 count = devcount * sizeof(long);
73 for (i = 0; i < devcount; i++) {
75 * once the device state is read, the 'STALE' bit will be set
76 * so that the Dynamic Loader can distinguish the new request
79 taskstat[i] = taskdev_state_stale(i);
82 if (copy_to_user(buf, taskstat, count))
88 static unsigned int dsp_twch_poll(struct file *file, poll_table *wait)
90 unsigned int mask = 0;
92 poll_wait(file, &read_wait_q, wait);
94 mask |= POLLIN | POLLRDNORM;
99 static int dsp_twch_ioctl(struct inode *inode, struct file *file,
100 unsigned int cmd, unsigned long arg)
105 case TWCH_IOCTL_MKDEV:
108 if (copy_from_user(name, (void __user *)arg, TNM_LEN))
110 name[TNM_LEN-1] = '\0';
111 ret = dsp_mkdev(name);
115 case TWCH_IOCTL_RMDEV:
118 if (copy_from_user(name, (void __user *)arg, TNM_LEN))
120 name[TNM_LEN-1] = '\0';
121 ret = dsp_rmdev(name);
125 case TWCH_IOCTL_TADD:
127 struct omap_dsp_taddinfo ti;
128 if (copy_from_user(&ti, (void __user *)arg, sizeof(ti)))
130 ret = dsp_tadd_minor(ti.minor, ti.taskadr);
134 case TWCH_IOCTL_TDEL:
135 ret = dsp_tdel_minor(arg);
138 case TWCH_IOCTL_TKILL:
139 ret = dsp_tkill_minor(arg);
149 struct file_operations dsp_twch_fops = {
150 .owner = THIS_MODULE,
151 .read = dsp_twch_read,
152 .poll = dsp_twch_poll,
153 .ioctl = dsp_twch_ioctl,
156 void dsp_twch_start(void)
158 change_cnt = 1; /* first read will not wait */
161 void dsp_twch_stop(void)
163 wake_up_interruptible(&read_wait_q);