aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/meye.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-03-28 21:25:36 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:45 -0400
commit6174523c5948f8a36f778f0abdfc648a5d73bf46 (patch)
treec1674837d9c4f2e3177b7d2dc87e9038681d4645 /drivers/media/video/meye.c
parent185cda966633fc18b9df09b6d84d5ec2db4a57ff (diff)
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>
Diffstat (limited to 'drivers/media/video/meye.c')
-rw-r--r--drivers/media/video/meye.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c
index d9d73d888aa0..2ad11f0999c6 100644
--- a/drivers/media/video/meye.c
+++ b/drivers/media/video/meye.c
@@ -1256,18 +1256,13 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
1256 if (f->index > 1) 1256 if (f->index > 1)
1257 return -EINVAL; 1257 return -EINVAL;
1258 1258
1259 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1260 return -EINVAL;
1261
1262 if (f->index == 0) { 1259 if (f->index == 0) {
1263 /* standard YUV 422 capture */ 1260 /* standard YUV 422 capture */
1264 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1265 f->flags = 0; 1261 f->flags = 0;
1266 strcpy(f->description, "YUV422"); 1262 strcpy(f->description, "YUV422");
1267 f->pixelformat = V4L2_PIX_FMT_YUYV; 1263 f->pixelformat = V4L2_PIX_FMT_YUYV;
1268 } else { 1264 } else {
1269 /* compressed MJPEG capture */ 1265 /* compressed MJPEG capture */
1270 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1271 f->flags = V4L2_FMT_FLAG_COMPRESSED; 1266 f->flags = V4L2_FMT_FLAG_COMPRESSED;
1272 strcpy(f->description, "MJPEG"); 1267 strcpy(f->description, "MJPEG");
1273 f->pixelformat = V4L2_PIX_FMT_MJPEG; 1268 f->pixelformat = V4L2_PIX_FMT_MJPEG;
@@ -1279,9 +1274,6 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *fh,
1279static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, 1274static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
1280 struct v4l2_format *f) 1275 struct v4l2_format *f)
1281{ 1276{
1282 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1283 return -EINVAL;
1284
1285 if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV && 1277 if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
1286 f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG) 1278 f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
1287 return -EINVAL; 1279 return -EINVAL;
@@ -1312,9 +1304,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
1312static int vidioc_g_fmt_vid_cap(struct file *file, void *fh, 1304static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
1313 struct v4l2_format *f) 1305 struct v4l2_format *f)
1314{ 1306{
1315 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1316 return -EINVAL;
1317
1318 switch (meye.mchip_mode) { 1307 switch (meye.mchip_mode) {
1319 case MCHIP_HIC_MODE_CONT_OUT: 1308 case MCHIP_HIC_MODE_CONT_OUT:
1320 default: 1309 default:
@@ -1338,9 +1327,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *fh,
1338static int vidioc_s_fmt_vid_cap(struct file *file, void *fh, 1327static int vidioc_s_fmt_vid_cap(struct file *file, void *fh,
1339 struct v4l2_format *f) 1328 struct v4l2_format *f)
1340{ 1329{
1341 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1342 return -EINVAL;
1343
1344 if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV && 1330 if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV &&
1345 f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG) 1331 f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
1346 return -EINVAL; 1332 return -EINVAL;
@@ -1386,9 +1372,6 @@ static int vidioc_reqbufs(struct file *file, void *fh,
1386{ 1372{
1387 int i; 1373 int i;
1388 1374
1389 if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1390 return -EINVAL;
1391
1392 if (req->memory != V4L2_MEMORY_MMAP) 1375 if (req->memory != V4L2_MEMORY_MMAP)
1393 return -EINVAL; 1376 return -EINVAL;
1394 1377
@@ -1429,9 +1412,9 @@ static int vidioc_reqbufs(struct file *file, void *fh,
1429 1412
1430static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) 1413static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
1431{ 1414{
1432 int index = buf->index; 1415 unsigned int index = buf->index;
1433 1416
1434 if (index < 0 || index >= gbuffers) 1417 if (index >= gbuffers)
1435 return -EINVAL; 1418 return -EINVAL;
1436 1419
1437 buf->bytesused = meye.grab_buffer[index].size; 1420 buf->bytesused = meye.grab_buffer[index].size;
@@ -1455,13 +1438,10 @@ static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf)
1455 1438
1456static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) 1439static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
1457{ 1440{
1458 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1459 return -EINVAL;
1460
1461 if (buf->memory != V4L2_MEMORY_MMAP) 1441 if (buf->memory != V4L2_MEMORY_MMAP)
1462 return -EINVAL; 1442 return -EINVAL;
1463 1443
1464 if (buf->index < 0 || buf->index >= gbuffers) 1444 if (buf->index >= gbuffers)
1465 return -EINVAL; 1445 return -EINVAL;
1466 1446
1467 if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED) 1447 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)
1481{ 1461{
1482 int reqnr; 1462 int reqnr;
1483 1463
1484 if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1485 return -EINVAL;
1486
1487 if (buf->memory != V4L2_MEMORY_MMAP) 1464 if (buf->memory != V4L2_MEMORY_MMAP)
1488 return -EINVAL; 1465 return -EINVAL;
1489 1466