diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/media/radio/miropcm20-rds.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/media/radio/miropcm20-rds.c')
-rw-r--r-- | drivers/media/radio/miropcm20-rds.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c new file mode 100644 index 000000000000..df79d5e0aaed --- /dev/null +++ b/drivers/media/radio/miropcm20-rds.c | |||
@@ -0,0 +1,133 @@ | |||
1 | /* MiroSOUND PCM20 radio rds interface driver | ||
2 | * (c) 2001 Robert Siemer <Robert.Siemer@gmx.de> | ||
3 | * Thanks to Fred Seidel. See miropcm20-rds-core.c for further information. | ||
4 | */ | ||
5 | |||
6 | /* Revision history: | ||
7 | * | ||
8 | * 2001-04-18 Robert Siemer <Robert.Siemer@gmx.de> | ||
9 | * separate file for user interface driver | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/fs.h> | ||
16 | #include <linux/miscdevice.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <asm/uaccess.h> | ||
19 | #include "miropcm20-rds-core.h" | ||
20 | |||
21 | static char * text_buffer; | ||
22 | static int rds_users = 0; | ||
23 | |||
24 | |||
25 | static int rds_f_open(struct inode *in, struct file *fi) | ||
26 | { | ||
27 | if (rds_users) | ||
28 | return -EBUSY; | ||
29 | |||
30 | rds_users++; | ||
31 | if ((text_buffer=kmalloc(66, GFP_KERNEL)) == 0) { | ||
32 | rds_users--; | ||
33 | printk(KERN_NOTICE "aci-rds: Out of memory by open()...\n"); | ||
34 | return -ENOMEM; | ||
35 | } | ||
36 | |||
37 | return 0; | ||
38 | } | ||
39 | |||
40 | static int rds_f_release(struct inode *in, struct file *fi) | ||
41 | { | ||
42 | kfree(text_buffer); | ||
43 | |||
44 | rds_users--; | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static void print_matrix(char *ch, char out[]) | ||
49 | { | ||
50 | int j; | ||
51 | |||
52 | for (j=7; j>=0; j--) { | ||
53 | out[7-j] = ((*ch >> j) & 0x1) + '0'; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | static ssize_t rds_f_read(struct file *file, char __user *buffer, size_t length, loff_t *offset) | ||
58 | { | ||
59 | // i = sprintf(text_buffer, "length: %d, offset: %d\n", length, *offset); | ||
60 | |||
61 | char c; | ||
62 | char bits[8]; | ||
63 | |||
64 | msleep(2000); | ||
65 | aci_rds_cmd(RDS_STATUS, &c, 1); | ||
66 | print_matrix(&c, bits); | ||
67 | if (copy_to_user(buffer, bits, 8)) | ||
68 | return -EFAULT; | ||
69 | |||
70 | /* if ((c >> 3) & 1) { | ||
71 | aci_rds_cmd(RDS_STATIONNAME, text_buffer+1, 8); | ||
72 | text_buffer[0] = ' ' ; | ||
73 | text_buffer[9] = '\n'; | ||
74 | return copy_to_user(buffer+8, text_buffer, 10) ? -EFAULT: 18; | ||
75 | } | ||
76 | */ | ||
77 | /* if ((c >> 6) & 1) { | ||
78 | aci_rds_cmd(RDS_PTYTATP, &c, 1); | ||
79 | if ( c & 1) | ||
80 | sprintf(text_buffer, " M"); | ||
81 | else | ||
82 | sprintf(text_buffer, " S"); | ||
83 | if ((c >> 1) & 1) | ||
84 | sprintf(text_buffer+2, " TA"); | ||
85 | else | ||
86 | sprintf(text_buffer+2, " --"); | ||
87 | if ((c >> 7) & 1) | ||
88 | sprintf(text_buffer+5, " TP"); | ||
89 | else | ||
90 | sprintf(text_buffer+5, " --"); | ||
91 | sprintf(text_buffer+8, " %2d\n", (c >> 2) & 0x1f); | ||
92 | return copy_to_user(buffer+8, text_buffer, 12) ? -EFAULT: 20; | ||
93 | } | ||
94 | */ | ||
95 | |||
96 | if ((c >> 4) & 1) { | ||
97 | aci_rds_cmd(RDS_TEXT, text_buffer, 65); | ||
98 | text_buffer[0] = ' ' ; | ||
99 | text_buffer[65] = '\n'; | ||
100 | return copy_to_user(buffer+8, text_buffer,66) ? -EFAULT : 66+8; | ||
101 | } else { | ||
102 | put_user('\n', buffer+8); | ||
103 | return 9; | ||
104 | } | ||
105 | } | ||
106 | |||
107 | static struct file_operations rds_fops = { | ||
108 | .owner = THIS_MODULE, | ||
109 | .read = rds_f_read, | ||
110 | .open = rds_f_open, | ||
111 | .release = rds_f_release | ||
112 | }; | ||
113 | |||
114 | static struct miscdevice rds_miscdev = { | ||
115 | .minor = MISC_DYNAMIC_MINOR, | ||
116 | .name = "radiotext", | ||
117 | .devfs_name = "v4l/rds/radiotext", | ||
118 | .fops = &rds_fops, | ||
119 | }; | ||
120 | |||
121 | static int __init miropcm20_rds_init(void) | ||
122 | { | ||
123 | return misc_register(&rds_miscdev); | ||
124 | } | ||
125 | |||
126 | static void __exit miropcm20_rds_cleanup(void) | ||
127 | { | ||
128 | misc_deregister(&rds_miscdev); | ||
129 | } | ||
130 | |||
131 | module_init(miropcm20_rds_init); | ||
132 | module_exit(miropcm20_rds_cleanup); | ||
133 | MODULE_LICENSE("GPL"); | ||