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

[media] pwc: Move various initialization to driver load and / or stream start

Doing a bunch of initialization every time /dev/video is opened, and thus
for example when the udev rules probe for capabilities makes no sense,
do it at driver load, resp. stream start instead.

This is a preparation patch for allowing multiple opens of the /dev/video
node.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 3b4d0ec7
...@@ -261,8 +261,11 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames) ...@@ -261,8 +261,11 @@ static int set_video_mode_Nala(struct pwc_device *pdev, int size, int frames)
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;
} }
if (pEntry->compressed && pdev->pixfmt == V4L2_PIX_FMT_YUV420) if (pEntry->compressed && pdev->pixfmt == V4L2_PIX_FMT_YUV420) {
pwc_dec1_init(pdev->type, pdev->release, buf, pdev->decompress_data); ret = pwc_dec1_init(pdev, pdev->type, pdev->release, buf);
if (ret < 0)
return ret;
}
pdev->cmd_len = 3; pdev->cmd_len = 3;
memcpy(pdev->cmd_buf, buf, 3); memcpy(pdev->cmd_buf, buf, 3);
...@@ -321,8 +324,11 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, i ...@@ -321,8 +324,11 @@ static int set_video_mode_Timon(struct pwc_device *pdev, int size, int frames, i
if (ret < 0) if (ret < 0)
return ret; return ret;
if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) {
pwc_dec23_init(pdev, pdev->type, buf); ret = pwc_dec23_init(pdev, pdev->type, buf);
if (ret < 0)
return ret;
}
pdev->cmd_len = 13; pdev->cmd_len = 13;
memcpy(pdev->cmd_buf, buf, 13); memcpy(pdev->cmd_buf, buf, 13);
...@@ -394,8 +400,11 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i ...@@ -394,8 +400,11 @@ static int set_video_mode_Kiara(struct pwc_device *pdev, int size, int frames, i
if (ret < 0) if (ret < 0)
return ret; return ret;
if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) if (pChoose->bandlength > 0 && pdev->pixfmt == V4L2_PIX_FMT_YUV420) {
pwc_dec23_init(pdev, pdev->type, buf); ret = pwc_dec23_init(pdev, pdev->type, buf);
if (ret < 0)
return ret;
}
pdev->cmd_len = 12; pdev->cmd_len = 12;
memcpy(pdev->cmd_buf, buf, 12); memcpy(pdev->cmd_buf, buf, 12);
...@@ -452,6 +461,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame ...@@ -452,6 +461,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
} }
pdev->view.x = width; pdev->view.x = width;
pdev->view.y = height; pdev->view.y = height;
pdev->vcompression = compression;
pdev->frame_total_size = pdev->frame_size + pdev->frame_header_size + pdev->frame_trailer_size; pdev->frame_total_size = pdev->frame_size + pdev->frame_header_size + pdev->frame_trailer_size;
pwc_set_image_buffer_size(pdev); pwc_set_image_buffer_size(pdev);
PWC_DEBUG_SIZE("Set viewport to %dx%d, image size is %dx%d.\n", width, height, pwc_image_sizes[size].x, pwc_image_sizes[size].y); PWC_DEBUG_SIZE("Set viewport to %dx%d, image size is %dx%d.\n", width, height, pwc_image_sizes[size].x, pwc_image_sizes[size].y);
...@@ -1300,7 +1310,7 @@ static int pwc_mpt_get_status(struct pwc_device *pdev, struct pwc_mpt_status *st ...@@ -1300,7 +1310,7 @@ static int pwc_mpt_get_status(struct pwc_device *pdev, struct pwc_mpt_status *st
return 0; return 0;
} }
#ifdef CONFIG_USB_PWC_DEBUG
int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor) int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
{ {
unsigned char buf; unsigned char buf;
...@@ -1323,7 +1333,7 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor) ...@@ -1323,7 +1333,7 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
*sensor = buf; *sensor = buf;
return 0; return 0;
} }
#endif
/* End of Add-Ons */ /* End of Add-Ons */
/* ************************************************* */ /* ************************************************* */
...@@ -1387,8 +1397,6 @@ long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg) ...@@ -1387,8 +1397,6 @@ long pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
ret = -EINVAL; ret = -EINVAL;
else else
ret = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, ARGR(qual), pdev->vsnapshot); ret = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, ARGR(qual), pdev->vsnapshot);
if (ret >= 0)
pdev->vcompression = ARGR(qual);
break; break;
} }
......
...@@ -22,29 +22,19 @@ ...@@ -22,29 +22,19 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "pwc-dec1.h" #include "pwc-dec1.h"
int pwc_dec1_init(struct pwc_device *pwc, int type, int release, void *buffer)
void pwc_dec1_init(int type, int release, void *buffer, void *table)
{ {
struct pwc_dec1_private *pdec;
} if (pwc->decompress_data == NULL) {
pdec = kmalloc(sizeof(struct pwc_dec1_private), GFP_KERNEL);
void pwc_dec1_exit(void) if (pdec == NULL)
{ return -ENOMEM;
pwc->decompress_data = pdec;
}
pdec = pwc->decompress_data;
}
int pwc_dec1_alloc(struct pwc_device *pwc)
{
pwc->decompress_data = kmalloc(sizeof(struct pwc_dec1_private), GFP_KERNEL);
if (pwc->decompress_data == NULL)
return -ENOMEM;
return 0; return 0;
} }
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef PWC_DEC1_H #ifndef PWC_DEC1_H
#define PWC_DEC1_H #define PWC_DEC1_H
...@@ -32,12 +30,8 @@ ...@@ -32,12 +30,8 @@
struct pwc_dec1_private struct pwc_dec1_private
{ {
int version; int version;
}; };
int pwc_dec1_alloc(struct pwc_device *pwc); int pwc_dec1_init(struct pwc_device *pwc, int type, int release, void *buffer);
void pwc_dec1_init(int type, int release, void *buffer, void *private_data);
void pwc_dec1_exit(void);
#endif #endif
...@@ -916,27 +916,5 @@ void pwc_dec23_decompress(const struct pwc_device *pwc, ...@@ -916,27 +916,5 @@ void pwc_dec23_decompress(const struct pwc_device *pwc,
pout_planar_v += pwc->view.x; pout_planar_v += pwc->view.x;
} }
} }
} }
void pwc_dec23_exit(void)
{
/* Do nothing */
}
/**
* Allocate a private structure used by lookup table.
* You must call kfree() to free the memory allocated.
*/
int pwc_dec23_alloc(struct pwc_device *pwc)
{
pwc->decompress_data = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL);
if (pwc->decompress_data == NULL)
return -ENOMEM;
return 0;
}
/* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */
...@@ -49,19 +49,9 @@ struct pwc_dec23_private ...@@ -49,19 +49,9 @@ struct pwc_dec23_private
}; };
int pwc_dec23_alloc(struct pwc_device *pwc);
int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd); int pwc_dec23_init(struct pwc_device *pwc, int type, unsigned char *cmd);
void pwc_dec23_exit(void);
void pwc_dec23_decompress(const struct pwc_device *pwc, void pwc_dec23_decompress(const struct pwc_device *pwc,
const void *src, const void *src,
void *dst, void *dst,
int flags); int flags);
#endif #endif
/* vim: set cino= formatoptions=croql cindent shiftwidth=8 tabstop=8: */
This diff is collapsed.
...@@ -158,7 +158,6 @@ struct pwc_device ...@@ -158,7 +158,6 @@ struct pwc_device
int release; /* release number */ int release; /* release number */
int features; /* feature bits */ int features; /* feature bits */
char serial[30]; /* serial number (string) */ char serial[30]; /* serial number (string) */
int usb_init; /* set when the cam has been initialized */
/*** Video data ***/ /*** Video data ***/
int vopen; /* flag */ int vopen; /* flag */
......
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