aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-15 03:01:42 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:53 -0400
commit0259567ad60df13a55583b84d2cddb5526705907 (patch)
tree232e066c323f82bf5063538d89e847f05317f79b /drivers
parentc7f7a569d9b4ea7c53ab6fcd1377895312d8372b (diff)
[PATCH] Input: convert konicawc to dynamic input_dev allocation
Input: convert konicawc to dynamic input_dev allocation This is required for input_dev sysfs integration Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/media/konicawc.c89
1 files changed, 61 insertions, 28 deletions
diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c
index 20ac9e1069d4..9fe2c2710d13 100644
--- a/drivers/usb/media/konicawc.c
+++ b/drivers/usb/media/konicawc.c
@@ -119,7 +119,7 @@ struct konicawc {
119 int yplanesz; /* Number of bytes in the Y plane */ 119 int yplanesz; /* Number of bytes in the Y plane */
120 unsigned int buttonsts:1; 120 unsigned int buttonsts:1;
121#ifdef CONFIG_INPUT 121#ifdef CONFIG_INPUT
122 struct input_dev input; 122 struct input_dev *input;
123 char input_physname[64]; 123 char input_physname[64];
124#endif 124#endif
125}; 125};
@@ -218,6 +218,57 @@ static void konicawc_adjust_picture(struct uvd *uvd)
218 konicawc_camera_on(uvd); 218 konicawc_camera_on(uvd);
219} 219}
220 220
221#ifdef CONFIG_INPUT
222
223static void konicawc_register_input(struct konicawc *cam, struct usb_device *dev)
224{
225 struct input_dev *input_dev;
226
227 usb_make_path(dev, cam->input_physname, sizeof(cam->input_physname));
228 strncat(cam->input_physname, "/input0", sizeof(cam->input_physname));
229
230 cam->input = input_dev = input_allocate_device();
231 if (!input_dev) {
232 warn("Not enough memory for camera's input device\n");
233 return;
234 }
235
236 input_dev->name = "Konicawc snapshot button";
237 input_dev->phys = cam->input_physname;
238 usb_to_input_id(dev, &input_dev->id);
239 input_dev->cdev.dev = &dev->dev;
240
241 input_dev->evbit[0] = BIT(EV_KEY);
242 input_dev->keybit[LONG(BTN_0)] = BIT(BTN_0);
243
244 input_dev->private = cam;
245
246 input_register_device(cam->input);
247}
248
249static void konicawc_unregister_input(struct konicawc *cam)
250{
251 if (cam->input) {
252 input_unregister_device(cam->input);
253 cam->input = NULL;
254 }
255}
256
257static void konicawc_report_buttonstat(struct konicawc *cam)
258{
259 if (cam->input) {
260 input_report_key(cam->input, BTN_0, cam->buttonsts);
261 input_sync(cam->input);
262 }
263}
264
265#else
266
267static inline void konicawc_register_input(struct konicawc *cam, struct usb_device *dev) { }
268static inline void konicawc_unregister_input(struct konicawc *cam) { }
269static inline void konicawc_report_buttonstat(struct konicawc *cam) { }
270
271#endif /* CONFIG_INPUT */
221 272
222static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb) 273static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct urb *stsurb)
223{ 274{
@@ -273,10 +324,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
273 if(button != cam->buttonsts) { 324 if(button != cam->buttonsts) {
274 DEBUG(2, "button: %sclicked", button ? "" : "un"); 325 DEBUG(2, "button: %sclicked", button ? "" : "un");
275 cam->buttonsts = button; 326 cam->buttonsts = button;
276#ifdef CONFIG_INPUT 327 konicawc_report_buttonstat(cam);
277 input_report_key(&cam->input, BTN_0, cam->buttonsts);
278 input_sync(&cam->input);
279#endif
280 } 328 }
281 329
282 if(sts == 0x01) { /* drop frame */ 330 if(sts == 0x01) { /* drop frame */
@@ -645,9 +693,9 @@ static int konicawc_set_video_mode(struct uvd *uvd, struct video_window *vw)
645 RingQueue_Flush(&uvd->dp); 693 RingQueue_Flush(&uvd->dp);
646 cam->lastframe = -2; 694 cam->lastframe = -2;
647 if(uvd->curframe != -1) { 695 if(uvd->curframe != -1) {
648 uvd->frame[uvd->curframe].curline = 0; 696 uvd->frame[uvd->curframe].curline = 0;
649 uvd->frame[uvd->curframe].seqRead_Length = 0; 697 uvd->frame[uvd->curframe].seqRead_Length = 0;
650 uvd->frame[uvd->curframe].seqRead_Index = 0; 698 uvd->frame[uvd->curframe].seqRead_Index = 0;
651 } 699 }
652 700
653 konicawc_start_data(uvd); 701 konicawc_start_data(uvd);
@@ -718,7 +766,6 @@ static void konicawc_configure_video(struct uvd *uvd)
718 DEBUG(1, "setting initial values"); 766 DEBUG(1, "setting initial values");
719} 767}
720 768
721
722static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid) 769static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id *devid)
723{ 770{
724 struct usb_device *dev = interface_to_usbdev(intf); 771 struct usb_device *dev = interface_to_usbdev(intf);
@@ -839,21 +886,8 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
839 err("usbvideo_RegisterVideoDevice() failed."); 886 err("usbvideo_RegisterVideoDevice() failed.");
840 uvd = NULL; 887 uvd = NULL;
841 } 888 }
842#ifdef CONFIG_INPUT 889
843 /* Register input device for button */ 890 konicawc_register_input(cam, dev);
844 memset(&cam->input, 0, sizeof(struct input_dev));
845 cam->input.name = "Konicawc snapshot button";
846 cam->input.private = cam;
847 cam->input.evbit[0] = BIT(EV_KEY);
848 cam->input.keybit[LONG(BTN_0)] = BIT(BTN_0);
849 usb_to_input_id(dev, &cam->input.id);
850 input_register_device(&cam->input);
851
852 usb_make_path(dev, cam->input_physname, 56);
853 strcat(cam->input_physname, "/input0");
854 cam->input.phys = cam->input_physname;
855 info("konicawc: %s on %s\n", cam->input.name, cam->input.phys);
856#endif
857 } 891 }
858 892
859 if (uvd) { 893 if (uvd) {
@@ -869,10 +903,9 @@ static void konicawc_free_uvd(struct uvd *uvd)
869 int i; 903 int i;
870 struct konicawc *cam = (struct konicawc *)uvd->user_data; 904 struct konicawc *cam = (struct konicawc *)uvd->user_data;
871 905
872#ifdef CONFIG_INPUT 906 konicawc_unregister_input(cam);
873 input_unregister_device(&cam->input); 907
874#endif 908 for (i = 0; i < USBVIDEO_NUMSBUF; i++) {
875 for (i=0; i < USBVIDEO_NUMSBUF; i++) {
876 usb_free_urb(cam->sts_urb[i]); 909 usb_free_urb(cam->sts_urb[i]);
877 cam->sts_urb[i] = NULL; 910 cam->sts_urb[i] = NULL;
878 } 911 }