Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1966bc2a authored by Ondrej Zary's avatar Ondrej Zary Committed by Mauro Carvalho Chehab
Browse files

[media] gspca: store current mode instead of individual parameters



Store complete current mode (struct v4l2_pix_format) in struct gspca_dev
instead of separate pixfmt, width and height parameters.
This is a preparation for variable resolution support.

Signed-off-by: default avatarOndrej Zary <linux@rainbow-software.org>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 08149ecf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -783,7 +783,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
	struct sd *sd = (struct sd *) gspca_dev;

	/* create the JPEG header */
	jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
	jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height,
			gspca_dev->pixfmt.width,
			0x22);		/* JPEG 411 */
	jpeg_set_qual(sd->jpeg_hdr, QUALITY);

+2 −2
Original line number Diff line number Diff line
@@ -1553,9 +1553,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
		sd->params.format.videoSize = VIDEOSIZE_CIF;

	sd->params.roi.colEnd = sd->params.roi.colStart +
				(gspca_dev->width >> 3);
				(gspca_dev->pixfmt.width >> 3);
	sd->params.roi.rowEnd = sd->params.roi.rowStart +
				(gspca_dev->height >> 2);
				(gspca_dev->pixfmt.height >> 2);

	/* And now set the camera to a known state */
	ret = do_command(gspca_dev, CPIA_COMMAND_SetGrabMode,
+11 −19
Original line number Diff line number Diff line
@@ -504,8 +504,7 @@ static int frame_alloc(struct gspca_dev *gspca_dev, struct file *file,
	unsigned int frsz;
	int i;

	i = gspca_dev->curr_mode;
	frsz = gspca_dev->cam.cam_mode[i].sizeimage;
	frsz = gspca_dev->pixfmt.sizeimage;
	PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz);
	frsz = PAGE_ALIGN(frsz);
	if (count >= GSPCA_MAX_FRAMES)
@@ -627,16 +626,14 @@ static struct usb_host_endpoint *alt_xfer(struct usb_host_interface *alt,
static u32 which_bandwidth(struct gspca_dev *gspca_dev)
{
	u32 bandwidth;
	int i;

	/* get the (max) image size */
	i = gspca_dev->curr_mode;
	bandwidth = gspca_dev->cam.cam_mode[i].sizeimage;
	bandwidth = gspca_dev->pixfmt.sizeimage;

	/* if the image is compressed, estimate its mean size */
	if (!gspca_dev->cam.needs_full_bandwidth &&
	    bandwidth < gspca_dev->cam.cam_mode[i].width *
				gspca_dev->cam.cam_mode[i].height)
	    bandwidth < gspca_dev->pixfmt.width *
				gspca_dev->pixfmt.height)
		bandwidth = bandwidth * 3 / 8;	/* 0.375 */

	/* estimate the frame rate */
@@ -650,7 +647,7 @@ static u32 which_bandwidth(struct gspca_dev *gspca_dev)

		/* don't hope more than 15 fps with USB 1.1 and
		 * image resolution >= 640x480 */
		if (gspca_dev->width >= 640
		if (gspca_dev->pixfmt.width >= 640
		 && gspca_dev->dev->speed == USB_SPEED_FULL)
			bandwidth *= 15;		/* 15 fps */
		else
@@ -982,9 +979,7 @@ static void gspca_set_default_mode(struct gspca_dev *gspca_dev)

	i = gspca_dev->cam.nmodes - 1;	/* take the highest mode */
	gspca_dev->curr_mode = i;
	gspca_dev->width = gspca_dev->cam.cam_mode[i].width;
	gspca_dev->height = gspca_dev->cam.cam_mode[i].height;
	gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i].pixelformat;
	gspca_dev->pixfmt = gspca_dev->cam.cam_mode[i];

	/* does nothing if ctrl_handler == NULL */
	v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler);
@@ -1105,10 +1100,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
			    struct v4l2_format *fmt)
{
	struct gspca_dev *gspca_dev = video_drvdata(file);
	int mode;

	mode = gspca_dev->curr_mode;
	fmt->fmt.pix = gspca_dev->cam.cam_mode[mode];
	fmt->fmt.pix = gspca_dev->pixfmt;
	/* some drivers use priv internally, zero it before giving it to
	   userspace */
	fmt->fmt.pix.priv = 0;
@@ -1187,10 +1180,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
		ret = -EBUSY;
		goto out;
	}
	gspca_dev->width = fmt->fmt.pix.width;
	gspca_dev->height = fmt->fmt.pix.height;
	gspca_dev->pixfmt = fmt->fmt.pix.pixelformat;
	gspca_dev->curr_mode = ret;
	gspca_dev->pixfmt = gspca_dev->cam.cam_mode[ret];

	ret = 0;
out:
@@ -1471,8 +1462,9 @@ static int vidioc_streamon(struct file *file, void *priv,
		if (ret < 0)
			goto out;
	}
	PDEBUG_MODE(gspca_dev, D_STREAM, "stream on OK", gspca_dev->pixfmt,
		    gspca_dev->width, gspca_dev->height);
	PDEBUG_MODE(gspca_dev, D_STREAM, "stream on OK",
		    gspca_dev->pixfmt.pixelformat,
		    gspca_dev->pixfmt.width, gspca_dev->pixfmt.height);
	ret = 0;
out:
	mutex_unlock(&gspca_dev->queue_lock);
+1 −3
Original line number Diff line number Diff line
@@ -183,9 +183,7 @@ struct gspca_dev {
	__u8 streaming;			/* protected by both mutexes (*) */

	__u8 curr_mode;			/* current camera mode */
	__u32 pixfmt;			/* current mode parameters */
	__u16 width;
	__u16 height;
	struct v4l2_pix_format pixfmt;	/* current mode parameters */
	__u32 sequence;			/* frame sequence number */

	wait_queue_head_t wq;		/* wait queue */
+3 −2
Original line number Diff line number Diff line
@@ -378,11 +378,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
	struct sd *dev = (struct sd *) gspca_dev;

	/* create the JPEG header */
	jpeg_define(dev->jpeg_hdr, gspca_dev->height, gspca_dev->width,
	jpeg_define(dev->jpeg_hdr, gspca_dev->pixfmt.height,
			gspca_dev->pixfmt.width,
			0x21);          /* JPEG 422 */
	jpeg_set_qual(dev->jpeg_hdr, dev->quality);
	PDEBUG(D_STREAM, "Start streaming at %dx%d",
		gspca_dev->height, gspca_dev->width);
		gspca_dev->pixfmt.height, gspca_dev->pixfmt.width);
	jlj_start(gspca_dev);
	return gspca_dev->usb_err;
}
Loading