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

Commit dab7e310 authored by Andreas Bombe's avatar Andreas Bombe Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB: V4L2: Replace loops for finding max buffers in VIDIOC_REQBUFS callbacks



Due to obvious copy and paste coding a number of video capture drivers
which implement a limit on the buffer memory decremented the user
supplied buffer count in a while loop until it reaches an acceptable
value.

This is a silly thing to do when the maximum value can be directly
computed.

Signed-off-by: default avatarAndreas Bombe <aeb@debian.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 0a062033
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1806,8 +1806,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
	*size = fh->fmt->depth*fh->width*fh->height >> 3;
	if (0 == *count)
		*count = gbuffers;
	while (*size * *count > gbuffers * gbufsize)
		(*count)--;
	if (*size * *count > gbuffers * gbufsize)
		*count = (gbuffers * gbufsize) / *size;
	return 0;
}

+2 −2
Original line number Diff line number Diff line
@@ -514,8 +514,8 @@ static int buffer_setup(struct videobuf_queue *q, unsigned int *count,
	*size = fh->fmt->depth*fh->width*fh->height >> 3;
	if (0 == *count)
		*count = 32;
	while (*size * *count > vid_limit * 1024 * 1024)
		(*count)--;
	if (*size * *count > vid_limit * 1024 * 1024)
		*count = (vid_limit * 1024 * 1024) / *size;
	return 0;
}

+2 −2
Original line number Diff line number Diff line
@@ -561,8 +561,8 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
	*size = fh->fmt->depth*fh->width*fh->height >> 3;
	if (0 == *count)
		*count = 32;
	while (*size * *count > vid_limit * 1024 * 1024)
		(*count)--;
	if (*size * *count > vid_limit * 1024 * 1024)
		*count = (vid_limit * 1024 * 1024) / *size;
	return 0;
}

+2 −2
Original line number Diff line number Diff line
@@ -139,8 +139,8 @@ static int mx1_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
	if (!*count)
		*count = 32;

	while (*size * *count > MAX_VIDEO_MEM * 1024 * 1024)
		(*count)--;
	if (*size * *count > MAX_VIDEO_MEM * 1024 * 1024)
		*count = (MAX_VIDEO_MEM * 1024 * 1024) / *size;

	dev_dbg(icd->dev.parent, "count=%d, size=%d\n", *count, *size);

+2 −2
Original line number Diff line number Diff line
@@ -452,8 +452,8 @@ static int omap24xxcam_vbq_setup(struct videobuf_queue *vbq, unsigned int *cnt,
	*size = fh->pix.sizeimage;

	/* accessing fh->cam->capture_mem is ok, it's constant */
	while (*size * *cnt > fh->cam->capture_mem)
		(*cnt)--;
	if (*size * *cnt > fh->cam->capture_mem)
		*cnt = fh->cam->capture_mem / *size;

	return 0;
}
Loading