diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-12-25 06:01:38 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-29 05:17:09 -0500 |
commit | 0a58d713062fb49952b9b082514a48a0c83b269d (patch) | |
tree | dd9f9bbd3d15782b18071f3cf7d643f9cf3acc9e /drivers/media/video/stk-webcam.c | |
parent | 439105b122dfa21fbce7201d0f30b5eeac95c918 (diff) |
[media] stk-webcam: remove V4L1 compatibility code, replace with V4L2 controls
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/stk-webcam.c')
-rw-r--r-- | drivers/media/video/stk-webcam.c | 148 |
1 files changed, 30 insertions, 118 deletions
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c index b5afe5f841ce..d1a2cefbf55b 100644 --- a/drivers/media/video/stk-webcam.c +++ b/drivers/media/video/stk-webcam.c | |||
@@ -230,120 +230,6 @@ static int stk_initialise(struct stk_camera *dev) | |||
230 | return -1; | 230 | return -1; |
231 | } | 231 | } |
232 | 232 | ||
233 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
234 | |||
235 | /* sysfs functions */ | ||
236 | /*FIXME cleanup this */ | ||
237 | |||
238 | static ssize_t show_brightness(struct device *class, | ||
239 | struct device_attribute *attr, char *buf) | ||
240 | { | ||
241 | struct video_device *vdev = to_video_device(class); | ||
242 | struct stk_camera *dev = vdev_to_camera(vdev); | ||
243 | |||
244 | return sprintf(buf, "%X\n", dev->vsettings.brightness); | ||
245 | } | ||
246 | |||
247 | static ssize_t store_brightness(struct device *class, | ||
248 | struct device_attribute *attr, const char *buf, size_t count) | ||
249 | { | ||
250 | char *endp; | ||
251 | unsigned long value; | ||
252 | int ret; | ||
253 | |||
254 | struct video_device *vdev = to_video_device(class); | ||
255 | struct stk_camera *dev = vdev_to_camera(vdev); | ||
256 | |||
257 | value = simple_strtoul(buf, &endp, 16); | ||
258 | |||
259 | dev->vsettings.brightness = (int) value; | ||
260 | |||
261 | ret = stk_sensor_set_brightness(dev, value >> 8); | ||
262 | if (ret) | ||
263 | return ret; | ||
264 | else | ||
265 | return count; | ||
266 | } | ||
267 | |||
268 | static ssize_t show_hflip(struct device *class, | ||
269 | struct device_attribute *attr, char *buf) | ||
270 | { | ||
271 | struct video_device *vdev = to_video_device(class); | ||
272 | struct stk_camera *dev = vdev_to_camera(vdev); | ||
273 | |||
274 | return sprintf(buf, "%d\n", dev->vsettings.hflip); | ||
275 | } | ||
276 | |||
277 | static ssize_t store_hflip(struct device *class, | ||
278 | struct device_attribute *attr, const char *buf, size_t count) | ||
279 | { | ||
280 | struct video_device *vdev = to_video_device(class); | ||
281 | struct stk_camera *dev = vdev_to_camera(vdev); | ||
282 | |||
283 | if (strncmp(buf, "1", 1) == 0) | ||
284 | dev->vsettings.hflip = 1; | ||
285 | else if (strncmp(buf, "0", 1) == 0) | ||
286 | dev->vsettings.hflip = 0; | ||
287 | else | ||
288 | return -EINVAL; | ||
289 | |||
290 | return strlen(buf); | ||
291 | } | ||
292 | |||
293 | static ssize_t show_vflip(struct device *class, | ||
294 | struct device_attribute *attr, char *buf) | ||
295 | { | ||
296 | struct video_device *vdev = to_video_device(class); | ||
297 | struct stk_camera *dev = vdev_to_camera(vdev); | ||
298 | |||
299 | return sprintf(buf, "%d\n", dev->vsettings.vflip); | ||
300 | } | ||
301 | |||
302 | static ssize_t store_vflip(struct device *class, | ||
303 | struct device_attribute *attr, const char *buf, size_t count) | ||
304 | { | ||
305 | struct video_device *vdev = to_video_device(class); | ||
306 | struct stk_camera *dev = vdev_to_camera(vdev); | ||
307 | |||
308 | if (strncmp(buf, "1", 1) == 0) | ||
309 | dev->vsettings.vflip = 1; | ||
310 | else if (strncmp(buf, "0", 1) == 0) | ||
311 | dev->vsettings.vflip = 0; | ||
312 | else | ||
313 | return -EINVAL; | ||
314 | |||
315 | return strlen(buf); | ||
316 | } | ||
317 | |||
318 | static DEVICE_ATTR(brightness, S_IRUGO | S_IWUGO, | ||
319 | show_brightness, store_brightness); | ||
320 | static DEVICE_ATTR(hflip, S_IRUGO | S_IWUGO, show_hflip, store_hflip); | ||
321 | static DEVICE_ATTR(vflip, S_IRUGO | S_IWUGO, show_vflip, store_vflip); | ||
322 | |||
323 | static int stk_create_sysfs_files(struct video_device *vdev) | ||
324 | { | ||
325 | int ret; | ||
326 | |||
327 | ret = device_create_file(&vdev->dev, &dev_attr_brightness); | ||
328 | ret += device_create_file(&vdev->dev, &dev_attr_hflip); | ||
329 | ret += device_create_file(&vdev->dev, &dev_attr_vflip); | ||
330 | if (ret) | ||
331 | STK_WARNING("Could not create sysfs files\n"); | ||
332 | return ret; | ||
333 | } | ||
334 | |||
335 | static void stk_remove_sysfs_files(struct video_device *vdev) | ||
336 | { | ||
337 | device_remove_file(&vdev->dev, &dev_attr_brightness); | ||
338 | device_remove_file(&vdev->dev, &dev_attr_hflip); | ||
339 | device_remove_file(&vdev->dev, &dev_attr_vflip); | ||
340 | } | ||
341 | |||
342 | #else | ||
343 | #define stk_create_sysfs_files(a) | ||
344 | #define stk_remove_sysfs_files(a) | ||
345 | #endif | ||
346 | |||
347 | /* *********************************************** */ | 233 | /* *********************************************** */ |
348 | /* | 234 | /* |
349 | * This function is called as an URB transfert is complete (Isochronous pipe). | 235 | * This function is called as an URB transfert is complete (Isochronous pipe). |
@@ -878,7 +764,24 @@ static struct v4l2_queryctrl stk_controls[] = { | |||
878 | .step = 0x0100, | 764 | .step = 0x0100, |
879 | .default_value = 0x6000, | 765 | .default_value = 0x6000, |
880 | }, | 766 | }, |
881 | /*TODO: get more controls to work */ | 767 | { |
768 | .id = V4L2_CID_HFLIP, | ||
769 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
770 | .name = "Horizontal Flip", | ||
771 | .minimum = 0, | ||
772 | .maximum = 1, | ||
773 | .step = 1, | ||
774 | .default_value = 1, | ||
775 | }, | ||
776 | { | ||
777 | .id = V4L2_CID_VFLIP, | ||
778 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
779 | .name = "Vertical Flip", | ||
780 | .minimum = 0, | ||
781 | .maximum = 1, | ||
782 | .step = 1, | ||
783 | .default_value = 1, | ||
784 | }, | ||
882 | }; | 785 | }; |
883 | 786 | ||
884 | static int stk_vidioc_queryctrl(struct file *filp, | 787 | static int stk_vidioc_queryctrl(struct file *filp, |
@@ -906,6 +809,12 @@ static int stk_vidioc_g_ctrl(struct file *filp, | |||
906 | case V4L2_CID_BRIGHTNESS: | 809 | case V4L2_CID_BRIGHTNESS: |
907 | c->value = dev->vsettings.brightness; | 810 | c->value = dev->vsettings.brightness; |
908 | break; | 811 | break; |
812 | case V4L2_CID_HFLIP: | ||
813 | c->value = dev->vsettings.hflip; | ||
814 | break; | ||
815 | case V4L2_CID_VFLIP: | ||
816 | c->value = dev->vsettings.vflip; | ||
817 | break; | ||
909 | default: | 818 | default: |
910 | return -EINVAL; | 819 | return -EINVAL; |
911 | } | 820 | } |
@@ -920,6 +829,12 @@ static int stk_vidioc_s_ctrl(struct file *filp, | |||
920 | case V4L2_CID_BRIGHTNESS: | 829 | case V4L2_CID_BRIGHTNESS: |
921 | dev->vsettings.brightness = c->value; | 830 | dev->vsettings.brightness = c->value; |
922 | return stk_sensor_set_brightness(dev, c->value >> 8); | 831 | return stk_sensor_set_brightness(dev, c->value >> 8); |
832 | case V4L2_CID_HFLIP: | ||
833 | dev->vsettings.hflip = c->value; | ||
834 | return 0; | ||
835 | case V4L2_CID_VFLIP: | ||
836 | dev->vsettings.vflip = c->value; | ||
837 | return 0; | ||
923 | default: | 838 | default: |
924 | return -EINVAL; | 839 | return -EINVAL; |
925 | } | 840 | } |
@@ -1394,8 +1309,6 @@ static int stk_camera_probe(struct usb_interface *interface, | |||
1394 | goto error; | 1309 | goto error; |
1395 | } | 1310 | } |
1396 | 1311 | ||
1397 | stk_create_sysfs_files(&dev->vdev); | ||
1398 | |||
1399 | return 0; | 1312 | return 0; |
1400 | 1313 | ||
1401 | error: | 1314 | error: |
@@ -1411,7 +1324,6 @@ static void stk_camera_disconnect(struct usb_interface *interface) | |||
1411 | unset_present(dev); | 1324 | unset_present(dev); |
1412 | 1325 | ||
1413 | wake_up_interruptible(&dev->wait_frame); | 1326 | wake_up_interruptible(&dev->wait_frame); |
1414 | stk_remove_sysfs_files(&dev->vdev); | ||
1415 | 1327 | ||
1416 | STK_INFO("Syntek USB2.0 Camera release resources device %s\n", | 1328 | STK_INFO("Syntek USB2.0 Camera release resources device %s\n", |
1417 | video_device_node_name(&dev->vdev)); | 1329 | video_device_node_name(&dev->vdev)); |