aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/usbvideo/vicam.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-18 14:25:58 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-18 14:25:58 -0400
commita267c0a887064720dfab5775a4f09b20b4f8ec37 (patch)
tree25de1f109ff6ef7f0967c22755604cc667944afd /drivers/media/video/usbvideo/vicam.c
parentd756d10e246a01515d07f8161181b8a14afba7cc (diff)
parent97989ada7628da262eafb4bebce0a319c7cb0f5f (diff)
Merge branch 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb
* 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb: (126 commits) V4L/DVB (5847): Clean up schedule_timeout calls in cpia2 and ivtv code V4L/DVB (5846): Clean up setting state and scheduling timeouts V4L/DVB (5844): ivtv: add high volume debugging flag V4L/DVB (5843): ivtv: fix missing signal_pending check. V4L/DVB (5842): ivtv: Add locking to ensure stream setup is atomic. V4L/DVB (5841): tveeprom: add support for Philips FQ1216LME MK3 tuner. V4L/DVB (5840): fix dst and cx24123: tune() callback changed signess for delay V4L/DVB (5838): dvb-core: Fix signedness warnings (gcc 4.1.1, kernel 2.6.22) V4L/DVB (5837): stv0299: Fix signedness warning (gcc 4.1.1, kernel 2.6.22) V4L/DVB (5836): dvb-ttpci: re-initialize aspect ratio and pan scan after arm crash V4L/DVB (5835): saa7146/dvb-ttpci: Fix signedness warnings (gcc 4.1.1, kernel 2.6.22) V4L/DVB (5834): dvb-core: fix signedness warnings and const stripping V4L/DVB (5832): ir-common: optimize bit extract function V4L/DVB (5831): stradis: use ARRAY_SIZE V4L/DVB (5829): Firmware extract and loading for opera dvb-usb update V4L/DVB (5828): Kconfig: Added GemTek USB radio and removed experimental dependency. V4L/DVB (5826): Usbvision: video mux cleanup V4L/DVB (5825): Alter the tuner type for the WinTV USB UK PAL model. V4L/DVB (5824): Usbvision: Hauppauge WinTV USB SECAM_L fix V4L/DVB (5821): Saa7134: add remote control support for LifeView FlyDVB-S LR300 ...
Diffstat (limited to 'drivers/media/video/usbvideo/vicam.c')
-rw-r--r--drivers/media/video/usbvideo/vicam.c181
1 files changed, 0 insertions, 181 deletions
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 982b115193f8..2d9c0dd3b733 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -42,7 +42,6 @@
42#include <linux/usb.h> 42#include <linux/usb.h>
43#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
44#include <linux/slab.h> 44#include <linux/slab.h>
45#include <linux/proc_fs.h>
46#include <linux/mutex.h> 45#include <linux/mutex.h>
47#include "usbvideo.h" 46#include "usbvideo.h"
48 47
@@ -417,11 +416,6 @@ struct vicam_camera {
417 u8 open_count; 416 u8 open_count;
418 u8 bulkEndpoint; 417 u8 bulkEndpoint;
419 int needsDummyRead; 418 int needsDummyRead;
420
421#if defined(CONFIG_VIDEO_PROC_FS)
422 struct proc_dir_entry *proc_dir;
423#endif
424
425}; 419};
426 420
427static int vicam_probe( struct usb_interface *intf, const struct usb_device_id *id); 421static int vicam_probe( struct usb_interface *intf, const struct usb_device_id *id);
@@ -1065,175 +1059,6 @@ vicam_mmap(struct file *file, struct vm_area_struct *vma)
1065 return 0; 1059 return 0;
1066} 1060}
1067 1061
1068#if defined(CONFIG_VIDEO_PROC_FS)
1069
1070static struct proc_dir_entry *vicam_proc_root = NULL;
1071
1072static int vicam_read_helper(char *page, char **start, off_t off,
1073 int count, int *eof, int value)
1074{
1075 char *out = page;
1076 int len;
1077
1078 out += sprintf(out, "%d",value);
1079
1080 len = out - page;
1081 len -= off;
1082 if (len < count) {
1083 *eof = 1;
1084 if (len <= 0)
1085 return 0;
1086 } else
1087 len = count;
1088
1089 *start = page + off;
1090 return len;
1091}
1092
1093static int vicam_read_proc_shutter(char *page, char **start, off_t off,
1094 int count, int *eof, void *data)
1095{
1096 return vicam_read_helper(page,start,off,count,eof,
1097 ((struct vicam_camera *)data)->shutter_speed);
1098}
1099
1100static int vicam_read_proc_gain(char *page, char **start, off_t off,
1101 int count, int *eof, void *data)
1102{
1103 return vicam_read_helper(page,start,off,count,eof,
1104 ((struct vicam_camera *)data)->gain);
1105}
1106
1107static int
1108vicam_write_proc_shutter(struct file *file, const char *buffer,
1109 unsigned long count, void *data)
1110{
1111 u16 stmp;
1112 char kbuf[8];
1113 struct vicam_camera *cam = (struct vicam_camera *) data;
1114
1115 if (count > 6)
1116 return -EINVAL;
1117
1118 if (copy_from_user(kbuf, buffer, count))
1119 return -EFAULT;
1120
1121 stmp = (u16) simple_strtoul(kbuf, NULL, 10);
1122 if (stmp < 4 || stmp > 32000)
1123 return -EINVAL;
1124
1125 cam->shutter_speed = stmp;
1126
1127 return count;
1128}
1129
1130static int
1131vicam_write_proc_gain(struct file *file, const char *buffer,
1132 unsigned long count, void *data)
1133{
1134 u16 gtmp;
1135 char kbuf[8];
1136
1137 struct vicam_camera *cam = (struct vicam_camera *) data;
1138
1139 if (count > 4)
1140 return -EINVAL;
1141
1142 if (copy_from_user(kbuf, buffer, count))
1143 return -EFAULT;
1144
1145 gtmp = (u16) simple_strtoul(kbuf, NULL, 10);
1146 if (gtmp > 255)
1147 return -EINVAL;
1148 cam->gain = gtmp;
1149
1150 return count;
1151}
1152
1153static void
1154vicam_create_proc_root(void)
1155{
1156 vicam_proc_root = proc_mkdir("video/vicam", NULL);
1157
1158 if (vicam_proc_root)
1159 vicam_proc_root->owner = THIS_MODULE;
1160 else
1161 printk(KERN_ERR
1162 "could not create /proc entry for vicam!");
1163}
1164
1165static void
1166vicam_destroy_proc_root(void)
1167{
1168 if (vicam_proc_root)
1169 remove_proc_entry("video/vicam", 0);
1170}
1171
1172static void
1173vicam_create_proc_entry(struct vicam_camera *cam)
1174{
1175 char name[64];
1176 struct proc_dir_entry *ent;
1177
1178 DBG(KERN_INFO "vicam: creating proc entry\n");
1179
1180 if (!vicam_proc_root || !cam) {
1181 printk(KERN_INFO
1182 "vicam: could not create proc entry, %s pointer is null.\n",
1183 (!cam ? "camera" : "root"));
1184 return;
1185 }
1186
1187 sprintf(name, "video%d", cam->vdev.minor);
1188
1189 cam->proc_dir = proc_mkdir(name, vicam_proc_root);
1190
1191 if ( !cam->proc_dir )
1192 return; // FIXME: We should probably return an error here
1193
1194 ent = create_proc_entry("shutter", S_IFREG | S_IRUGO | S_IWUSR,
1195 cam->proc_dir);
1196 if (ent) {
1197 ent->data = cam;
1198 ent->read_proc = vicam_read_proc_shutter;
1199 ent->write_proc = vicam_write_proc_shutter;
1200 ent->size = 64;
1201 }
1202
1203 ent = create_proc_entry("gain", S_IFREG | S_IRUGO | S_IWUSR,
1204 cam->proc_dir);
1205 if (ent) {
1206 ent->data = cam;
1207 ent->read_proc = vicam_read_proc_gain;
1208 ent->write_proc = vicam_write_proc_gain;
1209 ent->size = 64;
1210 }
1211}
1212
1213static void
1214vicam_destroy_proc_entry(void *ptr)
1215{
1216 struct vicam_camera *cam = (struct vicam_camera *) ptr;
1217 char name[16];
1218
1219 if ( !cam->proc_dir )
1220 return;
1221
1222 sprintf(name, "video%d", cam->vdev.minor);
1223 remove_proc_entry("shutter", cam->proc_dir);
1224 remove_proc_entry("gain", cam->proc_dir);
1225 remove_proc_entry(name,vicam_proc_root);
1226 cam->proc_dir = NULL;
1227
1228}
1229
1230#else
1231static inline void vicam_create_proc_root(void) { }
1232static inline void vicam_destroy_proc_root(void) { }
1233static inline void vicam_create_proc_entry(struct vicam_camera *cam) { }
1234static inline void vicam_destroy_proc_entry(void *ptr) { }
1235#endif
1236
1237static const struct file_operations vicam_fops = { 1062static const struct file_operations vicam_fops = {
1238 .owner = THIS_MODULE, 1063 .owner = THIS_MODULE,
1239 .open = vicam_open, 1064 .open = vicam_open,
@@ -1330,8 +1155,6 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
1330 return -EIO; 1155 return -EIO;
1331 } 1156 }
1332 1157
1333 vicam_create_proc_entry(cam);
1334
1335 printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",cam->vdev.minor); 1158 printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",cam->vdev.minor);
1336 1159
1337 usb_set_intfdata (intf, cam); 1160 usb_set_intfdata (intf, cam);
@@ -1363,8 +1186,6 @@ vicam_disconnect(struct usb_interface *intf)
1363 1186
1364 cam->udev = NULL; 1187 cam->udev = NULL;
1365 1188
1366 vicam_destroy_proc_entry(cam);
1367
1368 /* the only thing left to do is synchronize with 1189 /* the only thing left to do is synchronize with
1369 * our close/release function on who should release 1190 * our close/release function on who should release
1370 * the camera memory. if there are any users using the 1191 * the camera memory. if there are any users using the
@@ -1390,7 +1211,6 @@ usb_vicam_init(void)
1390{ 1211{
1391 int retval; 1212 int retval;
1392 DBG(KERN_INFO "ViCam-based WebCam driver startup\n"); 1213 DBG(KERN_INFO "ViCam-based WebCam driver startup\n");
1393 vicam_create_proc_root();
1394 retval = usb_register(&vicam_driver); 1214 retval = usb_register(&vicam_driver);
1395 if (retval) 1215 if (retval)
1396 printk(KERN_WARNING "usb_register failed!\n"); 1216 printk(KERN_WARNING "usb_register failed!\n");
@@ -1404,7 +1224,6 @@ usb_vicam_exit(void)
1404 "ViCam-based WebCam driver shutdown\n"); 1224 "ViCam-based WebCam driver shutdown\n");
1405 1225
1406 usb_deregister(&vicam_driver); 1226 usb_deregister(&vicam_driver);
1407 vicam_destroy_proc_root();
1408} 1227}
1409 1228
1410module_init(usb_vicam_init); 1229module_init(usb_vicam_init);