aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-03-13 11:26:14 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-22 03:54:39 -0400
commitc2f644aeeba3a5178767e757e93151959f037db1 (patch)
tree998f0edc74e8da70baa103155fa7410e2640c938 /drivers
parentc05df8b32ab4b8103f8c20cbd3ab7191be613b68 (diff)
[media] gspca_cpia1: Add support for button
Not only the qx3 microscope has a button, but some cameras too. Tested with the Trust sp@cecam 100 (and with a creative and ezcam without button). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/cpia1.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/drivers/media/video/gspca/cpia1.c b/drivers/media/video/gspca/cpia1.c
index 2a4a428f2018..9ddbac680663 100644
--- a/drivers/media/video/gspca/cpia1.c
+++ b/drivers/media/video/gspca/cpia1.c
@@ -28,6 +28,7 @@
28 28
29#define MODULE_NAME "cpia1" 29#define MODULE_NAME "cpia1"
30 30
31#include <linux/input.h>
31#include "gspca.h" 32#include "gspca.h"
32 33
33MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); 34MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
@@ -653,10 +654,15 @@ static int do_command(struct gspca_dev *gspca_dev, u16 command,
653 break; 654 break;
654 655
655 case CPIA_COMMAND_ReadMCPorts: 656 case CPIA_COMMAND_ReadMCPorts:
656 if (!sd->params.qx3.qx3_detected)
657 break;
658 /* test button press */ 657 /* test button press */
659 sd->params.qx3.button = ((gspca_dev->usb_buf[1] & 0x02) == 0); 658 a = ((gspca_dev->usb_buf[1] & 0x02) == 0);
659 if (a != sd->params.qx3.button) {
660#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
661 input_report_key(gspca_dev->input_dev, KEY_CAMERA, a);
662 input_sync(gspca_dev->input_dev);
663#endif
664 sd->params.qx3.button = a;
665 }
660 if (sd->params.qx3.button) { 666 if (sd->params.qx3.button) {
661 /* button pressed - unlock the latch */ 667 /* button pressed - unlock the latch */
662 do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, 668 do_command(gspca_dev, CPIA_COMMAND_WriteMCPort,
@@ -1738,6 +1744,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
1738 1744
1739static void sd_stopN(struct gspca_dev *gspca_dev) 1745static void sd_stopN(struct gspca_dev *gspca_dev)
1740{ 1746{
1747 struct sd *sd = (struct sd *) gspca_dev;
1748
1741 command_pause(gspca_dev); 1749 command_pause(gspca_dev);
1742 1750
1743 /* save camera state for later open (developers guide ch 3.5.3) */ 1751 /* save camera state for later open (developers guide ch 3.5.3) */
@@ -1748,6 +1756,17 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1748 1756
1749 /* Update the camera status */ 1757 /* Update the camera status */
1750 do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0); 1758 do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0);
1759
1760#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
1761 /* If the last button state is pressed, release it now! */
1762 if (sd->params.qx3.button) {
1763 /* The camera latch will hold the pressed state until we reset
1764 the latch, so we do not reset sd->params.qx3.button now, to
1765 avoid a false keypress being reported the next sd_start */
1766 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
1767 input_sync(gspca_dev->input_dev);
1768 }
1769#endif
1751} 1770}
1752 1771
1753/* this function is called at probe and resume time */ 1772/* this function is called at probe and resume time */
@@ -1852,8 +1871,7 @@ static void sd_dq_callback(struct gspca_dev *gspca_dev)
1852 1871
1853 /* Update our knowledge of the camera state */ 1872 /* Update our knowledge of the camera state */
1854 do_command(gspca_dev, CPIA_COMMAND_GetExposure, 0, 0, 0, 0); 1873 do_command(gspca_dev, CPIA_COMMAND_GetExposure, 0, 0, 0, 0);
1855 if (sd->params.qx3.qx3_detected) 1874 do_command(gspca_dev, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0);
1856 do_command(gspca_dev, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0);
1857} 1875}
1858 1876
1859static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 1877static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
@@ -2085,6 +2103,9 @@ static const struct sd_desc sd_desc = {
2085 .dq_callback = sd_dq_callback, 2103 .dq_callback = sd_dq_callback,
2086 .pkt_scan = sd_pkt_scan, 2104 .pkt_scan = sd_pkt_scan,
2087 .querymenu = sd_querymenu, 2105 .querymenu = sd_querymenu,
2106#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
2107 .other_input = 1,
2108#endif
2088}; 2109};
2089 2110
2090/* -- module initialisation -- */ 2111/* -- module initialisation -- */