mirror of https://gitee.com/openkylin/linux.git
V4L/DVB (11270): meye: Remove buffer type checks from XXX_fmt_vid_cap, XXXbuf
The ->vidioc_(s|g|try|enum)_fmt_vid_cap() methods are only called on VIDEO_CAPTURE buffers. Thus, there is no need to check or set the buffer's 'type' field since it must already be set to VIDEO_CAPTURE. The v4l2-ioctl core only allows buffer types for which the corresponding ->vidioc_try_fmt_xxx() methods are defined to be used with vidioc_(q|dq|query)bufs() and vidioc_reqbufs(). Since this driver only defines ->vidioc_try_fmt_vid_cap() the checks can be removed from vidioc_reqbufs(), vidioc_querybuf(), vidioc_qbuf(), and vidioc_dqbuf(). Also, the buffer index is unsigned so it's not necessary to check if it is less than zero. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
185cda9666
commit
6174523c59
|
@ -1256,18 +1256,13 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
|
||||||
if (f->index > 1)
|
if (f->index > 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (f->index == 0) {
|
if (f->index == 0) {
|
||||||
/* standard YUV 422 capture */
|
/* standard YUV 422 capture */
|
||||||
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
||||||
f->flags = 0;
|
f->flags = 0;
|
||||||
strcpy(f->description, "YUV422");
|
strcpy(f->description, "YUV422");
|
||||||
f->pixelformat = V4L2_PIX_FMT_YUYV;
|
f->pixelformat = V4L2_PIX_FMT_YUYV;
|
||||||
} else {
|
} else {
|
||||||
/* compressed MJPEG capture */
|
/* compressed MJPEG capture */
|
||||||
f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
|
||||||
f->flags = V4L2_FMT_FLAG_COMPRESSED;
|
f->flags = V4L2_FMT_FLAG_COMPRESSED;
|
||||||
strcpy(f->description, "MJPEG");
|
strcpy(f->description, "MJPEG");
|
||||||
f->pixelformat = V4L2_PIX_FMT_MJPEG;
|
f->pixelformat = V4L2_PIX_FMT_MJPEG;
|
||||||
|
@ -1279,9 +1274,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
|
||||||
static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
|
static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
|
||||||
struct v4l2_format *f)
|
struct v4l2_format *f)
|
||||||
{
|
{
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
|
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
|
||||||
f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
|
f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -1312,9 +1304,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
|
||||||
static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
|
static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
|
||||||
struct v4l2_format *f)
|
struct v4l2_format *f)
|
||||||
{
|
{
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
switch (meye.mchip_mode) {
|
switch (meye.mchip_mode) {
|
||||||
case MCHIP_HIC_MODE_CONT_OUT:
|
case MCHIP_HIC_MODE_CONT_OUT:
|
||||||
default:
|
default:
|
||||||
|
@ -1338,9 +1327,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
|
||||||
static int vidioc_s_fmt_vid_cap(struct file *file, void *fh,
|
static int vidioc_s_fmt_vid_cap(struct file *file, void *fh,
|
||||||
struct v4l2_format *f)
|
struct v4l2_format *f)
|
||||||
{
|
{
|
||||||
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
|
if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
|
||||||
f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
|
f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -1386,9 +1372,6 @@ static int vidioc_reqbufs(struct file *file, void *fh,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (req->memory != V4L2_MEMORY_MMAP)
|
if (req->memory != V4L2_MEMORY_MMAP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -1429,9 +1412,9 @@ static int vidioc_reqbufs(struct file *file, void *fh,
|
||||||
|
|
||||||
static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
||||||
{
|
{
|
||||||
int index = buf->index;
|
unsigned int index = buf->index;
|
||||||
|
|
||||||
if (index < 0 || index >= gbuffers)
|
if (index >= gbuffers)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
buf->bytesused = meye.grab_buffer[index].size;
|
buf->bytesused = meye.grab_buffer[index].size;
|
||||||
|
@ -1455,13 +1438,10 @@ static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
||||||
|
|
||||||
static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
||||||
{
|
{
|
||||||
if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (buf->memory != V4L2_MEMORY_MMAP)
|
if (buf->memory != V4L2_MEMORY_MMAP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (buf->index < 0 || buf->index >= gbuffers)
|
if (buf->index >= gbuffers)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED)
|
if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED)
|
||||||
|
@ -1481,9 +1461,6 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
|
||||||
{
|
{
|
||||||
int reqnr;
|
int reqnr;
|
||||||
|
|
||||||
if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (buf->memory != V4L2_MEMORY_MMAP)
|
if (buf->memory != V4L2_MEMORY_MMAP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue