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

[media] gscpa_t613: Add support for the camera button

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 0218d53a
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define MODULE_NAME "t613" #define MODULE_NAME "t613"
#include <linux/input.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "gspca.h" #include "gspca.h"
...@@ -57,6 +58,7 @@ struct sd { ...@@ -57,6 +58,7 @@ struct sd {
u8 effect; u8 effect;
u8 sensor; u8 sensor;
u8 button_pressed;
}; };
enum sensors { enum sensors {
SENSOR_OM6802, SENSOR_OM6802,
...@@ -1095,15 +1097,35 @@ static void sd_stopN(struct gspca_dev *gspca_dev) ...@@ -1095,15 +1097,35 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
msleep(20); msleep(20);
reg_w(gspca_dev, 0x0309); reg_w(gspca_dev, 0x0309);
} }
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
/* If the last button state is pressed, release it now! */
if (sd->button_pressed) {
input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
input_sync(gspca_dev->input_dev);
sd->button_pressed = 0;
}
#endif
} }
static void sd_pkt_scan(struct gspca_dev *gspca_dev, static void sd_pkt_scan(struct gspca_dev *gspca_dev,
u8 *data, /* isoc packet */ u8 *data, /* isoc packet */
int len) /* iso packet length */ int len) /* iso packet length */
{ {
struct sd *sd = (struct sd *) gspca_dev;
int pkt_type; int pkt_type;
if (data[0] == 0x5a) { if (data[0] == 0x5a) {
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
if (len > 20) {
u8 state = (data[20] & 0x80) ? 1 : 0;
if (sd->button_pressed != state) {
input_report_key(gspca_dev->input_dev,
KEY_CAMERA, state);
input_sync(gspca_dev->input_dev);
sd->button_pressed = state;
}
}
#endif
/* Control Packet, after this came the header again, /* Control Packet, after this came the header again,
* but extra bytes came in the packet before this, * but extra bytes came in the packet before this,
* sometimes an EOF arrives, sometimes not... */ * sometimes an EOF arrives, sometimes not... */
...@@ -1410,6 +1432,9 @@ static const struct sd_desc sd_desc = { ...@@ -1410,6 +1432,9 @@ static const struct sd_desc sd_desc = {
.stopN = sd_stopN, .stopN = sd_stopN,
.pkt_scan = sd_pkt_scan, .pkt_scan = sd_pkt_scan,
.querymenu = sd_querymenu, .querymenu = sd_querymenu,
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
.other_input = 1,
#endif
}; };
/* -- module initialisation -- */ /* -- 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