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

[media] pwc: Avoid sending mode info to the camera when it is not needed

Since we always do a set_video_mode on stream start, there is no need
to actually send the mode info to the device on a s_fmt / s_parm ioctl.
Not doing this saves us doing (slow) usb io.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d167a85c
...@@ -169,10 +169,10 @@ int send_control_msg(struct pwc_device *pdev, ...@@ -169,10 +169,10 @@ int send_control_msg(struct pwc_device *pdev,
} }
static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt, static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt,
int frames, int *compression) int frames, int *compression, int send_to_cam)
{ {
unsigned char buf[3]; unsigned char buf[3];
int ret, fps; int fps, ret = 0;
struct Nala_table_entry *pEntry; struct Nala_table_entry *pEntry;
int frames2frames[31] = int frames2frames[31] =
{ /* closest match of framerate */ { /* closest match of framerate */
...@@ -207,7 +207,8 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt, ...@@ -207,7 +207,8 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt,
return -EINVAL; return -EINVAL;
memcpy(buf, pEntry->mode, 3); memcpy(buf, pEntry->mode, 3);
ret = send_video_command(pdev, pdev->vendpoint, buf, 3); if (send_to_cam)
ret = send_video_command(pdev, pdev->vendpoint, buf, 3);
if (ret < 0) { if (ret < 0) {
PWC_DEBUG_MODULE("Failed to send video command... %d\n", ret); PWC_DEBUG_MODULE("Failed to send video command... %d\n", ret);
return ret; return ret;
...@@ -246,11 +247,11 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt, ...@@ -246,11 +247,11 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int pixfmt,
static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt,
int frames, int *compression) int frames, int *compression, int send_to_cam)
{ {
unsigned char buf[13]; unsigned char buf[13];
const struct Timon_table_entry *pChoose; const struct Timon_table_entry *pChoose;
int ret, fps; int fps, ret = 0;
if (size >= PSZ_MAX || *compression < 0 || *compression > 3) if (size >= PSZ_MAX || *compression < 0 || *compression > 3)
return -EINVAL; return -EINVAL;
...@@ -274,7 +275,8 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, ...@@ -274,7 +275,8 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt,
return -ENOENT; /* Not supported. */ return -ENOENT; /* Not supported. */
memcpy(buf, pChoose->mode, 13); memcpy(buf, pChoose->mode, 13);
ret = send_video_command(pdev, pdev->vendpoint, buf, 13); if (send_to_cam)
ret = send_video_command(pdev, pdev->vendpoint, buf, 13);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -300,10 +302,10 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt, ...@@ -300,10 +302,10 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int pixfmt,
static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt,
int frames, int *compression) int frames, int *compression, int send_to_cam)
{ {
const struct Kiara_table_entry *pChoose = NULL; const struct Kiara_table_entry *pChoose = NULL;
int fps, ret; int fps, ret = 0;
unsigned char buf[12]; unsigned char buf[12];
if (size >= PSZ_MAX || *compression < 0 || *compression > 3) if (size >= PSZ_MAX || *compression < 0 || *compression > 3)
...@@ -332,7 +334,8 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, ...@@ -332,7 +334,8 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt,
memcpy(buf, pChoose->mode, 12); memcpy(buf, pChoose->mode, 12);
/* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */ /* Firmware bug: video endpoint is 5, but commands are sent to endpoint 4 */
ret = send_video_command(pdev, 4 /* pdev->vendpoint */, buf, 12); if (send_to_cam)
ret = send_video_command(pdev, 4, buf, 12);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -358,7 +361,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt, ...@@ -358,7 +361,7 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int pixfmt,
} }
int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
int pixfmt, int frames, int *compression) int pixfmt, int frames, int *compression, int send_to_cam)
{ {
int ret, size; int ret, size;
...@@ -369,13 +372,13 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, ...@@ -369,13 +372,13 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
if (DEVICE_USE_CODEC1(pdev->type)) { if (DEVICE_USE_CODEC1(pdev->type)) {
ret = set_video_mode_Nala(pdev, size, pixfmt, frames, ret = set_video_mode_Nala(pdev, size, pixfmt, frames,
compression); compression, send_to_cam);
} else if (DEVICE_USE_CODEC3(pdev->type)) { } else if (DEVICE_USE_CODEC3(pdev->type)) {
ret = set_video_mode_Kiara(pdev, size, pixfmt, frames, ret = set_video_mode_Kiara(pdev, size, pixfmt, frames,
compression); compression, send_to_cam);
} else { } else {
ret = set_video_mode_Timon(pdev, size, pixfmt, frames, ret = set_video_mode_Timon(pdev, size, pixfmt, frames,
compression); compression, send_to_cam);
} }
if (ret < 0) { if (ret < 0) {
PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret); PWC_ERROR("Failed to set video mode %s@%d fps; return code = %d\n", size2name[size], frames, ret);
......
...@@ -385,8 +385,8 @@ static int pwc_isoc_init(struct pwc_device *pdev) ...@@ -385,8 +385,8 @@ static int pwc_isoc_init(struct pwc_device *pdev)
retry: retry:
/* We first try with low compression and then retry with a higher /* We first try with low compression and then retry with a higher
compression setting if there is not enough bandwidth. */ compression setting if there is not enough bandwidth. */
ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt,
pdev->pixfmt, pdev->vframes, &compression); pdev->vframes, &compression, 1);
/* Get the current alternate interface, adjust packet size */ /* Get the current alternate interface, adjust packet size */
intf = usb_ifnum_to_if(udev, 0); intf = usb_ifnum_to_if(udev, 0);
...@@ -1129,7 +1129,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id ...@@ -1129,7 +1129,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
/* Setup intial videomode */ /* Setup intial videomode */
rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT,
V4L2_PIX_FMT_YUV420, 30, &compression); V4L2_PIX_FMT_YUV420, 30, &compression, 1);
if (rc) if (rc)
goto err_free_mem; goto err_free_mem;
......
...@@ -493,7 +493,7 @@ static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f) ...@@ -493,7 +493,7 @@ static int pwc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f)
(pixelformat>>24)&255); (pixelformat>>24)&255);
ret = pwc_set_video_mode(pdev, f->fmt.pix.width, f->fmt.pix.height, ret = pwc_set_video_mode(pdev, f->fmt.pix.width, f->fmt.pix.height,
pixelformat, 30, &compression); pixelformat, 30, &compression, 0);
PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret); PWC_DEBUG_IOCTL("pwc_set_video_mode(), return=%d\n", ret);
...@@ -1137,7 +1137,7 @@ static int pwc_s_parm(struct file *file, void *fh, ...@@ -1137,7 +1137,7 @@ static int pwc_s_parm(struct file *file, void *fh,
} }
ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt, ret = pwc_set_video_mode(pdev, pdev->width, pdev->height, pdev->pixfmt,
fps, &compression); fps, &compression, 0);
pwc_g_parm(file, fh, parm); pwc_g_parm(file, fh, parm);
......
...@@ -369,7 +369,7 @@ void pwc_construct(struct pwc_device *pdev); ...@@ -369,7 +369,7 @@ void pwc_construct(struct pwc_device *pdev);
/** Functions in pwc-ctrl.c */ /** Functions in pwc-ctrl.c */
/* Request a certain video mode. Returns < 0 if not possible */ /* Request a certain video mode. Returns < 0 if not possible */
extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height,
int pixfmt, int frames, int *compression); int pixfmt, int frames, int *compression, int send_to_cam);
extern unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size); extern unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size);
extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value); extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor); extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
......
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