Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 306153
b: refs/heads/master
c: 769af21
h: refs/heads/master
i:
  306151: ad939aa
v: v3
  • Loading branch information
Ezequiel García authored and Mauro Carvalho Chehab committed Apr 10, 2012
1 parent ffcd92c commit 040900e
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 109 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9d9f479b39d58d5b7d9eae1d12b0f9de3c4fc606
refs/heads/master: 769af2146a93c27c8834dbca54c02cd67468036d
184 changes: 93 additions & 91 deletions trunk/drivers/media/video/em28xx/em28xx-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct em28xx_IR {
I2C IR based get keycodes - should be used with ir-kbd-i2c
**********************************************************/

int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
static int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
{
unsigned char b;

Expand Down Expand Up @@ -108,7 +108,7 @@ int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
return 1;
}

int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
static int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
{
unsigned char buf[2];
u16 code;
Expand Down Expand Up @@ -157,7 +157,7 @@ int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
return 1;
}

int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
static int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
u32 *ir_raw)
{
unsigned char buf[3];
Expand All @@ -179,7 +179,8 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
return 1;
}

int em28xx_get_key_winfast_usbii_deluxe(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
static int em28xx_get_key_winfast_usbii_deluxe(struct IR_i2c *ir, u32 *ir_key,
u32 *ir_raw)
{
unsigned char subaddr, keydetect, key;

Expand Down Expand Up @@ -387,7 +388,7 @@ int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 rc_type)
return rc;
}

void em28xx_register_i2c_ir(struct em28xx *dev)
static void em28xx_register_i2c_ir(struct em28xx *dev)
{
/* Leadtek winfast tv USBII deluxe can find a non working IR-device */
/* at address 0x18, so if that address is needed for another board in */
Expand Down Expand Up @@ -431,6 +432,93 @@ void em28xx_register_i2c_ir(struct em28xx *dev)
i2c_new_probed_device(&dev->i2c_adap, &info, addr_list, NULL);
}

/**********************************************************
Handle Webcam snapshot button
**********************************************************/

static void em28xx_query_sbutton(struct work_struct *work)
{
/* Poll the register and see if the button is depressed */
struct em28xx *dev =
container_of(work, struct em28xx, sbutton_query_work.work);
int ret;

ret = em28xx_read_reg(dev, EM28XX_R0C_USBSUSP);

if (ret & EM28XX_R0C_USBSUSP_SNAPSHOT) {
u8 cleared;
/* Button is depressed, clear the register */
cleared = ((u8) ret) & ~EM28XX_R0C_USBSUSP_SNAPSHOT;
em28xx_write_regs(dev, EM28XX_R0C_USBSUSP, &cleared, 1);

/* Not emulate the keypress */
input_report_key(dev->sbutton_input_dev, EM28XX_SNAPSHOT_KEY,
1);
/* Now unpress the key */
input_report_key(dev->sbutton_input_dev, EM28XX_SNAPSHOT_KEY,
0);
}

/* Schedule next poll */
schedule_delayed_work(&dev->sbutton_query_work,
msecs_to_jiffies(EM28XX_SBUTTON_QUERY_INTERVAL));
}

static void em28xx_register_snapshot_button(struct em28xx *dev)
{
struct input_dev *input_dev;
int err;

em28xx_info("Registering snapshot button...\n");
input_dev = input_allocate_device();
if (!input_dev) {
em28xx_errdev("input_allocate_device failed\n");
return;
}

usb_make_path(dev->udev, dev->snapshot_button_path,
sizeof(dev->snapshot_button_path));
strlcat(dev->snapshot_button_path, "/sbutton",
sizeof(dev->snapshot_button_path));
INIT_DELAYED_WORK(&dev->sbutton_query_work, em28xx_query_sbutton);

input_dev->name = "em28xx snapshot button";
input_dev->phys = dev->snapshot_button_path;
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
set_bit(EM28XX_SNAPSHOT_KEY, input_dev->keybit);
input_dev->keycodesize = 0;
input_dev->keycodemax = 0;
input_dev->id.bustype = BUS_USB;
input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
input_dev->id.version = 1;
input_dev->dev.parent = &dev->udev->dev;

err = input_register_device(input_dev);
if (err) {
em28xx_errdev("input_register_device failed\n");
input_free_device(input_dev);
return;
}

dev->sbutton_input_dev = input_dev;
schedule_delayed_work(&dev->sbutton_query_work,
msecs_to_jiffies(EM28XX_SBUTTON_QUERY_INTERVAL));
return;

}

static void em28xx_deregister_snapshot_button(struct em28xx *dev)
{
if (dev->sbutton_input_dev != NULL) {
em28xx_info("Deregistering snapshot button\n");
cancel_delayed_work_sync(&dev->sbutton_query_work);
input_unregister_device(dev->sbutton_input_dev);
dev->sbutton_input_dev = NULL;
}
return;
}

int em28xx_ir_init(struct em28xx *dev)
{
struct em28xx_IR *ir;
Expand Down Expand Up @@ -530,89 +618,3 @@ int em28xx_ir_fini(struct em28xx *dev)
return 0;
}

/**********************************************************
Handle Webcam snapshot button
**********************************************************/

static void em28xx_query_sbutton(struct work_struct *work)
{
/* Poll the register and see if the button is depressed */
struct em28xx *dev =
container_of(work, struct em28xx, sbutton_query_work.work);
int ret;

ret = em28xx_read_reg(dev, EM28XX_R0C_USBSUSP);

if (ret & EM28XX_R0C_USBSUSP_SNAPSHOT) {
u8 cleared;
/* Button is depressed, clear the register */
cleared = ((u8) ret) & ~EM28XX_R0C_USBSUSP_SNAPSHOT;
em28xx_write_regs(dev, EM28XX_R0C_USBSUSP, &cleared, 1);

/* Not emulate the keypress */
input_report_key(dev->sbutton_input_dev, EM28XX_SNAPSHOT_KEY,
1);
/* Now unpress the key */
input_report_key(dev->sbutton_input_dev, EM28XX_SNAPSHOT_KEY,
0);
}

/* Schedule next poll */
schedule_delayed_work(&dev->sbutton_query_work,
msecs_to_jiffies(EM28XX_SBUTTON_QUERY_INTERVAL));
}

void em28xx_register_snapshot_button(struct em28xx *dev)
{
struct input_dev *input_dev;
int err;

em28xx_info("Registering snapshot button...\n");
input_dev = input_allocate_device();
if (!input_dev) {
em28xx_errdev("input_allocate_device failed\n");
return;
}

usb_make_path(dev->udev, dev->snapshot_button_path,
sizeof(dev->snapshot_button_path));
strlcat(dev->snapshot_button_path, "/sbutton",
sizeof(dev->snapshot_button_path));
INIT_DELAYED_WORK(&dev->sbutton_query_work, em28xx_query_sbutton);

input_dev->name = "em28xx snapshot button";
input_dev->phys = dev->snapshot_button_path;
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
set_bit(EM28XX_SNAPSHOT_KEY, input_dev->keybit);
input_dev->keycodesize = 0;
input_dev->keycodemax = 0;
input_dev->id.bustype = BUS_USB;
input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
input_dev->id.version = 1;
input_dev->dev.parent = &dev->udev->dev;

err = input_register_device(input_dev);
if (err) {
em28xx_errdev("input_register_device failed\n");
input_free_device(input_dev);
return;
}

dev->sbutton_input_dev = input_dev;
schedule_delayed_work(&dev->sbutton_query_work,
msecs_to_jiffies(EM28XX_SBUTTON_QUERY_INTERVAL));
return;

}

void em28xx_deregister_snapshot_button(struct em28xx *dev)
{
if (dev->sbutton_input_dev != NULL) {
em28xx_info("Deregistering snapshot button\n");
cancel_delayed_work_sync(&dev->sbutton_query_work);
input_unregister_device(dev->sbutton_input_dev);
dev->sbutton_input_dev = NULL;
}
return;
}
17 changes: 0 additions & 17 deletions trunk/drivers/media/video/em28xx/em28xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -702,35 +702,18 @@ extern void em28xx_card_setup(struct em28xx *dev);
extern struct em28xx_board em28xx_boards[];
extern struct usb_device_id em28xx_id_table[];
extern const unsigned int em28xx_bcount;
void em28xx_register_i2c_ir(struct em28xx *dev);
int em28xx_tuner_callback(void *ptr, int component, int command, int arg);
void em28xx_release_resources(struct em28xx *dev);

/* Provided by em28xx-input.c */

#ifdef CONFIG_VIDEO_EM28XX_RC

int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
u32 *ir_raw);
int em28xx_get_key_winfast_usbii_deluxe(struct IR_i2c *ir, u32 *ir_key,
u32 *ir_raw);
void em28xx_register_snapshot_button(struct em28xx *dev);
void em28xx_deregister_snapshot_button(struct em28xx *dev);

int em28xx_ir_init(struct em28xx *dev);
int em28xx_ir_fini(struct em28xx *dev);

#else

#define em28xx_get_key_terratec NULL
#define em28xx_get_key_em_haup NULL
#define em28xx_get_key_pinnacle_usb_grey NULL
#define em28xx_get_key_winfast_usbii_deluxe NULL

static inline void em28xx_register_snapshot_button(struct em28xx *dev) {}
static inline void em28xx_deregister_snapshot_button(struct em28xx *dev) {}
static inline int em28xx_ir_init(struct em28xx *dev) { return 0; }
static inline int em28xx_ir_fini(struct em28xx *dev) { return 0; }

Expand Down

0 comments on commit 040900e

Please sign in to comment.