Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 181762
b: refs/heads/master
c: 417a4d2
h: refs/heads/master
v: v3
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Feb 26, 2010
1 parent 7befcde commit cc41b30
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e7637521ac92ce99045b8f8a9c1419bb7814ff9a
refs/heads/master: 417a4d26591e3f2b7784791246048ed315f3fdce
62 changes: 62 additions & 0 deletions trunk/drivers/media/video/gspca/ov519.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/
#define MODULE_NAME "ov519"

#include <linux/input.h>
#include "gspca.h"

MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
Expand Down Expand Up @@ -70,6 +71,9 @@ struct sd {
char invert_led;
#define BRIDGE_INVERT_LED 8

char snapshot_pressed;
char snapshot_needs_reset;

/* Determined by sensor type */
__u8 sif;

Expand Down Expand Up @@ -2685,6 +2689,26 @@ static void ov51x_led_control(struct sd *sd, int on)
}
}

static void sd_reset_snapshot(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;

if (!sd->snapshot_needs_reset)
return;

/* Note it is important that we clear sd->snapshot_needs_reset,
before actually clearing the snapshot state in the bridge
otherwise we might race with the pkt_scan interrupt handler */
sd->snapshot_needs_reset = 0;

switch (sd->bridge) {
case BRIDGE_OV519:
reg_w(sd, R51x_SYS_RESET, 0x40);
reg_w(sd, R51x_SYS_RESET, 0x00);
break;
}
}

static int ov51x_upload_quan_tables(struct sd *sd)
{
const unsigned char yQuanTable511[] = {
Expand Down Expand Up @@ -3921,6 +3945,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
setautobrightness(sd);
setfreq(sd);

/* Force clear snapshot state in case the snapshot button was
pressed while we weren't streaming */
sd->snapshot_needs_reset = 1;
sd_reset_snapshot(gspca_dev);
sd->snapshot_pressed = 0;

ret = ov51x_restart(sd);
if (ret < 0)
goto out;
Expand Down Expand Up @@ -4033,6 +4063,30 @@ static void ov518_pkt_scan(struct gspca_dev *gspca_dev,
gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
}

static void ov519_handle_button(struct gspca_dev *gspca_dev, u8 state)
{
struct sd *sd = (struct sd *) gspca_dev;

/* This should never happen, but better to check */
if (state != 0 && state != 1)
return;

/* We may need to reset the button state multiple times, as resetting
does not work as long as the button stays pressed, so always set
snapshot_needs_reset (instead of only on a state change to 1). */
if (state)
sd->snapshot_needs_reset = 1;

if (sd->snapshot_pressed != state) {
#ifdef CONFIG_INPUT
input_report_key(gspca_dev->input_dev, KEY_CAMERA, state);
input_sync(gspca_dev->input_dev);
#endif

sd->snapshot_pressed = state;
}
}

static void ov519_pkt_scan(struct gspca_dev *gspca_dev,
u8 *data, /* isoc packet */
int len) /* iso packet length */
Expand All @@ -4052,6 +4106,9 @@ static void ov519_pkt_scan(struct gspca_dev *gspca_dev,
if (data[0] == 0xff && data[1] == 0xff && data[2] == 0xff) {
switch (data[3]) {
case 0x50: /* start of frame */
/* Don't check the button state here, as the state
usually (always ?) changes at EOF and checking it
here leads to unnecessary snapshot state resets. */
#define HDRSZ 16
data += HDRSZ;
len -= HDRSZ;
Expand All @@ -4063,6 +4120,7 @@ static void ov519_pkt_scan(struct gspca_dev *gspca_dev,
gspca_dev->last_packet_type = DISCARD_PACKET;
return;
case 0x51: /* end of frame */
ov519_handle_button(gspca_dev, data[11]);
if (data[9] != 0)
gspca_dev->last_packet_type = DISCARD_PACKET;
gspca_frame_add(gspca_dev, LAST_PACKET,
Expand Down Expand Up @@ -4505,9 +4563,13 @@ static const struct sd_desc sd_desc = {
.stopN = sd_stopN,
.stop0 = sd_stop0,
.pkt_scan = sd_pkt_scan,
.dq_callback = sd_reset_snapshot,
.querymenu = sd_querymenu,
.get_jcomp = sd_get_jcomp,
.set_jcomp = sd_set_jcomp,
#ifdef CONFIG_INPUT
.other_input = 1,
#endif
};

/* -- module initialisation -- */
Expand Down

0 comments on commit cc41b30

Please sign in to comment.