Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 261447
b: refs/heads/master
c: 3b4d0ec
h: refs/heads/master
i:
  261445: f43e8bd
  261443: 810226e
  261439: 70cec65
v: v3
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Jul 27, 2011
1 parent 87bf33d commit 60163e7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 38 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: 52a92547508e7bb62b6325cd2954412a7ab01249
refs/heads/master: 3b4d0ec79113e77b3fe90749ae00bfa015c73048
26 changes: 17 additions & 9 deletions trunk/drivers/media/video/pwc/pwc-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,29 +782,32 @@ int pwc_get_shutter_speed(struct pwc_device *pdev, int *value)
return 0;
}


/* POWER */

int pwc_camera_power(struct pwc_device *pdev, int power)
void pwc_camera_power(struct pwc_device *pdev, int power)
{
char buf;
int r;

if (!pdev->power_save)
return;

if (pdev->type < 675 || (pdev->type < 730 && pdev->release < 6))
return 0; /* Not supported by Nala or Timon < release 6 */
return; /* Not supported by Nala or Timon < release 6 */

if (power)
buf = 0x00; /* active */
else
buf = 0xFF; /* power save */
return send_control_msg(pdev,
r = send_control_msg(pdev,
SET_STATUS_CTL, SET_POWER_SAVE_MODE_FORMATTER,
&buf, sizeof(buf));
}


if (r < 0)
PWC_ERROR("Failed to power %s camera (%d)\n",
power ? "on" : "off", r);
}

/* private calls */

int pwc_restore_user(struct pwc_device *pdev)
{
return send_control_msg(pdev,
Expand Down Expand Up @@ -1011,6 +1014,7 @@ static int pwc_get_wb_delay(struct pwc_device *pdev, int *value)
int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value)
{
unsigned char buf[2];
int r;

if (pdev->type < 730)
return 0;
Expand All @@ -1028,8 +1032,12 @@ int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value)
buf[0] = on_value;
buf[1] = off_value;

return send_control_msg(pdev,
r = send_control_msg(pdev,
SET_STATUS_CTL, LED_FORMATTER, &buf, sizeof(buf));
if (r < 0)
PWC_ERROR("Failed to set LED on/off time (%d)\n", r);

return r;
}

static int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value)
Expand Down
43 changes: 16 additions & 27 deletions trunk/drivers/media/video/pwc/pwc-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static int default_fps = 10;
#ifdef CONFIG_USB_PWC_DEBUG
int pwc_trace = PWC_DEBUG_LEVEL;
#endif
static int power_save;
static int power_save = -1;
static int led_on = 100, led_off; /* defaults to LED that is on while in use */
static int pwc_preferred_compression = 1; /* 0..3 = uncompressed..high */
static struct {
Expand Down Expand Up @@ -720,7 +720,6 @@ static int pwc_video_open(struct file *file)
return -EBUSY;
}

pwc_construct(pdev); /* set min/max sizes correct */
if (!pdev->usb_init) {
PWC_DEBUG_OPEN("Doing first time initialization.\n");
pdev->usb_init = 1;
Expand All @@ -735,16 +734,9 @@ static int pwc_video_open(struct file *file)
}
}

/* Turn on camera */
if (power_save) {
i = pwc_camera_power(pdev, 1);
if (i < 0)
PWC_DEBUG_OPEN("Failed to restore power to the camera! (%d)\n", i);
}
/* Set LED on/off time */
if (pwc_set_leds(pdev, led_on, led_off) < 0)
PWC_DEBUG_OPEN("Failed to set LED on/off time.\n");

/* Turn on camera and set LEDS on */
pwc_camera_power(pdev, 1);
pwc_set_leds(pdev, led_on, led_off);

/* So far, so good. Allocate memory. */
i = pwc_allocate_buffers(pdev);
Expand All @@ -756,7 +748,6 @@ static int pwc_video_open(struct file *file)

/* Reset buffers & parameters */
pdev->visoc_errors = 0;
pwc_construct(pdev); /* set min/max sizes correct */

/* Set some defaults */
pdev->vsnapshot = 0;
Expand Down Expand Up @@ -815,7 +806,6 @@ static int pwc_video_close(struct file *file)
{
struct video_device *vdev = file->private_data;
struct pwc_device *pdev;
int i;

PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev);

Expand All @@ -833,14 +823,8 @@ static int pwc_video_close(struct file *file)

/* Turn off LEDS and power down camera, but only when not unplugged */
if (pdev->udev) {
/* Turn LEDs off */
if (pwc_set_leds(pdev, 0, 0) < 0)
PWC_DEBUG_MODULE("Failed to set LED on/off time.\n");
if (power_save) {
i = pwc_camera_power(pdev, 0);
if (i < 0)
PWC_ERROR("Failed to power down camera (%d)\n", i);
}
pwc_set_leds(pdev, 0, 0);
pwc_camera_power(pdev, 0);
pdev->vopen--;
PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", pdev->vopen);
}
Expand Down Expand Up @@ -1016,6 +1000,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
int hint, rc;
int features = 0;
int video_nr = -1; /* default: use next available device */
int my_power_save = power_save;
char serial_number[30], *name;

vendor_id = le16_to_cpu(udev->descriptor.idVendor);
Expand Down Expand Up @@ -1133,7 +1118,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
PWC_INFO("Logitech QuickCam Zoom (new model) USB webcam detected.\n");
name = "Logitech QuickCam Zoom";
type_id = 740; /* CCD sensor */
power_save = 1;
if (my_power_save == -1)
my_power_save = 1;
break;
case 0x08b5:
PWC_INFO("Logitech QuickCam Orbit/Sphere USB webcam detected.\n");
Expand Down Expand Up @@ -1250,6 +1236,9 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
else
return -ENODEV; /* Not any of the know types; but the list keeps growing. */

if (my_power_save == -1)
my_power_save = 0;

memset(serial_number, 0, 30);
usb_string(udev, udev->descriptor.iSerialNumber, serial_number, 29);
PWC_DEBUG_PROBE("Device serial number is %s\n", serial_number);
Expand Down Expand Up @@ -1278,13 +1267,15 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
pdev->angle_range.tilt_min = -3000;
pdev->angle_range.tilt_max = 2500;
}
pwc_construct(pdev); /* set min/max sizes correct */

mutex_init(&pdev->modlock);
spin_lock_init(&pdev->queued_bufs_lock);
INIT_LIST_HEAD(&pdev->queued_bufs);

pdev->udev = udev;
pdev->vcompression = pwc_preferred_compression;
pdev->power_save = my_power_save;

/* Init videobuf2 queue structure */
memset(&pdev->vb_queue, 0, sizeof(pdev->vb_queue));
Expand Down Expand Up @@ -1424,7 +1415,7 @@ module_param(fps, int, 0444);
#ifdef CONFIG_USB_PWC_DEBUG
module_param_named(trace, pwc_trace, int, 0644);
#endif
module_param(power_save, int, 0444);
module_param(power_save, int, 0644);
module_param(compression, int, 0444);
module_param_array(leds, int, &leds_nargs, 0444);
module_param_array(dev_hint, charp, &dev_hint_nargs, 0444);
Expand All @@ -1434,7 +1425,7 @@ MODULE_PARM_DESC(fps, "Initial frames per second. Varies with model, useful rang
#ifdef CONFIG_USB_PWC_DEBUG
MODULE_PARM_DESC(trace, "For debugging purposes");
#endif
MODULE_PARM_DESC(power_save, "Turn power save feature in camera on or off");
MODULE_PARM_DESC(power_save, "Turn power saving for new cameras on or off");
MODULE_PARM_DESC(compression, "Preferred compression quality. Range 0 (uncompressed) to 3 (high compression)");
MODULE_PARM_DESC(leds, "LED on,off time in milliseconds");
MODULE_PARM_DESC(dev_hint, "Device node hints");
Expand Down Expand Up @@ -1491,8 +1482,6 @@ static int __init usb_pwc_init(void)
pwc_preferred_compression = compression;
PWC_DEBUG_MODULE("Preferred compression set to %d.\n", pwc_preferred_compression);
}
if (power_save)
PWC_DEBUG_MODULE("Enabling power save on open/close.\n");
if (leds[0] >= 0)
led_on = leds[0];
if (leds[1] >= 0)
Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/media/video/pwc/pwc.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ struct pwc_device
char vsnapshot; /* snapshot mode */
char vsync; /* used by isoc handler */
char vmirror; /* for ToUCaM series */
char power_save; /* Do powersaving for this cam */

int cmd_len;
unsigned char cmd_buf[13];
Expand Down Expand Up @@ -290,7 +291,7 @@ extern int pwc_set_dynamic_noise(struct pwc_device *pdev, int noise);
extern int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise);

/* Power down or up the camera; not supported by all models */
extern int pwc_camera_power(struct pwc_device *pdev, int power);
extern void pwc_camera_power(struct pwc_device *pdev, int power);

/* Private ioctl()s; see pwc-ioctl.h */
extern long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg);
Expand Down

0 comments on commit 60163e7

Please sign in to comment.