Commit c2f644ae authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

[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: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c05df8b3
......@@ -28,6 +28,7 @@
#define MODULE_NAME "cpia1"
#include <linux/input.h>
#include "gspca.h"
MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
......@@ -653,10 +654,15 @@ static int do_command(struct gspca_dev *gspca_dev, u16 command,
break;
case CPIA_COMMAND_ReadMCPorts:
if (!sd->params.qx3.qx3_detected)
break;
/* test button press */
sd->params.qx3.button = ((gspca_dev->usb_buf[1] & 0x02) == 0);
a = ((gspca_dev->usb_buf[1] & 0x02) == 0);
if (a != sd->params.qx3.button) {
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
input_report_key(gspca_dev->input_dev, KEY_CAMERA, a);
input_sync(gspca_dev->input_dev);
#endif
sd->params.qx3.button = a;
}
if (sd->params.qx3.button) {
/* button pressed - unlock the latch */
do_command(gspca_dev, CPIA_COMMAND_WriteMCPort,
......@@ -1738,6 +1744,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
static void sd_stopN(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
command_pause(gspca_dev);
/* 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)
/* Update the camera status */
do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0);
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
/* If the last button state is pressed, release it now! */
if (sd->params.qx3.button) {
/* The camera latch will hold the pressed state until we reset
the latch, so we do not reset sd->params.qx3.button now, to
avoid a false keypress being reported the next sd_start */
input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
input_sync(gspca_dev->input_dev);
}
#endif
}
/* this function is called at probe and resume time */
......@@ -1852,7 +1871,6 @@ static void sd_dq_callback(struct gspca_dev *gspca_dev)
/* Update our knowledge of the camera state */
do_command(gspca_dev, CPIA_COMMAND_GetExposure, 0, 0, 0, 0);
if (sd->params.qx3.qx3_detected)
do_command(gspca_dev, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0);
}
......@@ -2085,6 +2103,9 @@ static const struct sd_desc sd_desc = {
.dq_callback = sd_dq_callback,
.pkt_scan = sd_pkt_scan,
.querymenu = sd_querymenu,
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
.other_input = 1,
#endif
};
/* -- module initialisation -- */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment