Skip to contentSkip to conversation

gspca pac7302: add support for camera button

RFC PATCH In review Németh Márton 1 participant 3 messages Jan 17, 2010 – Jan 28, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 2/2 gspca pac7302: add support for camera button

From: Márton Németh <[email protected]>

Add support for snapshot button found on Labtec Webcam 2200.

---

linux/drivers/media/video/gspca/pac7302.c +37 -0
diff -r 875c200a19dc linux/drivers/media/video/gspca/pac7302.c
@@ -5,6 +5,8 @@
  * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
  *
  * Separated from Pixart PAC7311 library by M�rton N�meth <[email protected]>
+ * Camera button input handling by Márton Németh <[email protected]>
+ * Copyright (C) 2009-2010 Márton Németh <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -68,6 +70,7 @@
 
 #define MODULE_NAME "pac7302"
 
+#include <linux/input.h>
 #include <media/v4l2-chip-ident.h>
 #include "gspca.h"
 
@@ -1164,6 +1167,37 @@
 }
 #endif
 
+#ifdef CONFIG_INPUT
+static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
+			u8 *data,		/* interrupt packet data */
+			int len)		/* interrput packet length */
+{
+	int ret = -EINVAL;
+	u8 data0, data1;
+
+	if (len == 2) {
+		data0 = data[0];
+		data1 = data[1];
+		if ((data0 == 0x00 && data1 == 0x11) ||
+		    (data0 == 0x22 && data1 == 0x33) ||
+		    (data0 == 0x44 && data1 == 0x55) ||
+		    (data0 == 0x66 && data1 == 0x77) ||
+		    (data0 == 0x88 && data1 == 0x99) ||
+		    (data0 == 0xaa && data1 == 0xbb) ||
+		    (data0 == 0xcc && data1 == 0xdd) ||
+		    (data0 == 0xee && data1 == 0xff)) {
+			input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
+			input_sync(gspca_dev->input_dev);
+			input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
+			input_sync(gspca_dev->input_dev);
+			ret = 0;
+		}
+	}
+
+	return ret;
+}
+#endif
+
 /* sub-driver description for pac7302 */
 static const struct sd_desc sd_desc = {
 	.name = MODULE_NAME,
@@ -1180,6 +1214,9 @@
 	.set_register = sd_dbg_s_register,
 	.get_chip_ident = sd_chip_ident,
 #endif
+#ifdef CONFIG_INPUT
+	.int_pkt_scan = sd_int_pkt_scan,
+#endif
 };
 
 /* -- module initialisation -- */
#1 lore raw

PATCH 1/1 gspca pac7302: add support for camera button

From: Márton Németh <[email protected]>

Add support for snapshot button found on Labtec Webcam 2200.

---

linux/drivers/media/video/gspca/pac7302.c +37 -0
diff -r 875c200a19dc linux/drivers/media/video/gspca/pac7302.c
@@ -5,6 +5,8 @@
  * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
  *
  * Separated from Pixart PAC7311 library by M�rton N�meth <[email protected]>
+ * Camera button input handling by Márton Németh <[email protected]>
+ * Copyright (C) 2009-2010 Márton Németh <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -68,6 +70,7 @@
 
 #define MODULE_NAME "pac7302"
 
+#include <linux/input.h>
 #include <media/v4l2-chip-ident.h>
 #include "gspca.h"
 
@@ -1164,6 +1167,37 @@
 }
 #endif
 
+#ifdef CONFIG_INPUT
+static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
+			u8 *data,		/* interrupt packet data */
+			int len)		/* interrput packet length */
+{
+	int ret = -EINVAL;
+	u8 data0, data1;
+
+	if (len == 2) {
+		data0 = data[0];
+		data1 = data[1];
+		if ((data0 == 0x00 && data1 == 0x11) ||
+		    (data0 == 0x22 && data1 == 0x33) ||
+		    (data0 == 0x44 && data1 == 0x55) ||
+		    (data0 == 0x66 && data1 == 0x77) ||
+		    (data0 == 0x88 && data1 == 0x99) ||
+		    (data0 == 0xaa && data1 == 0xbb) ||
+		    (data0 == 0xcc && data1 == 0xdd) ||
+		    (data0 == 0xee && data1 == 0xff)) {
+			input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
+			input_sync(gspca_dev->input_dev);
+			input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
+			input_sync(gspca_dev->input_dev);
+			ret = 0;
+		}
+	}
+
+	return ret;
+}
+#endif
+
 /* sub-driver description for pac7302 */
 static const struct sd_desc sd_desc = {
 	.name = MODULE_NAME,
@@ -1180,6 +1214,9 @@
 	.set_register = sd_dbg_s_register,
 	.get_chip_ident = sd_chip_ident,
 #endif
+#ifdef CONFIG_INPUT
+	.int_pkt_scan = sd_int_pkt_scan,
+#endif
 };
 
 /* -- module initialisation -- */
#2 lore raw

Hello Jean-Francois,

thank you for accepting this patch and for the previous suggestions which made it possible to reach the current state of this patchset. Also thanks for correcting the character encoding in my name.

Regards,

Márton Németh

Németh Márton írta:

Quoted 82 lines

From: Márton Németh <[email protected]>

Add support for snapshot button found on Labtec Webcam 2200.

---
diff -r 875c200a19dc linux/drivers/media/video/gspca/pac7302.c

linux/drivers/media/video/gspca/pac7302.c +37 -1
@@ -5,6 +5,8 @@
  * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
  *
  * Separated from Pixart PAC7311 library by M�rton N�meth <[email protected]>
+ * Camera button input handling by Márton Németh <[email protected]>
+ * Copyright (C) 2009-2010 Márton Németh <[email protected]>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -68,6 +70,7 @@
 
 #define MODULE_NAME "pac7302"
 
+#include <linux/input.h>
 #include <media/v4l2-chip-ident.h>
 #include "gspca.h"
 
@@ -1164,6 +1167,37 @@
 }
 #endif
 
+#ifdef CONFIG_INPUT
+static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
+			u8 *data,		/* interrupt packet data */
+			int len)		/* interrput packet length */
+{
+	int ret = -EINVAL;
+	u8 data0, data1;
+
+	if (len == 2) {
+		data0 = data[0];
+		data1 = data[1];
+		if ((data0 == 0x00 && data1 == 0x11) ||
+		    (data0 == 0x22 && data1 == 0x33) ||
+		    (data0 == 0x44 && data1 == 0x55) ||
+		    (data0 == 0x66 && data1 == 0x77) ||
+		    (data0 == 0x88 && data1 == 0x99) ||
+		    (data0 == 0xaa && data1 == 0xbb) ||
+		    (data0 == 0xcc && data1 == 0xdd) ||
+		    (data0 == 0xee && data1 == 0xff)) {
+			input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
+			input_sync(gspca_dev->input_dev);
+			input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
+			input_sync(gspca_dev->input_dev);
+			ret = 0;
+		}
+	}
+
+	return ret;
+}
+#endif
+
 /* sub-driver description for pac7302 */
 static const struct sd_desc sd_desc = {
 	.name = MODULE_NAME,
@@ -1180,6 +1214,9 @@
 	.set_register = sd_dbg_s_register,
 	.get_chip_ident = sd_chip_ident,
 #endif
+#ifdef CONFIG_INPUT
+	.int_pkt_scan = sd_int_pkt_scan,
+#endif
 };
 
 /* -- module initialisation -- */
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html