Sun Mar 15 20:34:30 2009 UTC ()
Pull up following revision(s) (requested by jmcneill in ticket #576):
	sys/dev/video.c: revision 1.20
PR# kern/41008: possible simple mistake of field check in video(9)
video_set_format() requires hw->set_format to be set, not get_format,
from fukumoto@imasy.or.jp


(snj)
diff -r1.17.8.2 -r1.17.8.3 src/sys/dev/video.c

cvs diff -r1.17.8.2 -r1.17.8.3 src/sys/dev/video.c (expand / switch to unified diff)

--- src/sys/dev/video.c 2009/01/22 23:21:19 1.17.8.2
+++ src/sys/dev/video.c 2009/03/15 20:34:29 1.17.8.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: video.c,v 1.17.8.2 2009/01/22 23:21:19 snj Exp $ */ 1/* $NetBSD: video.c,v 1.17.8.3 2009/03/15 20:34:29 snj Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 Patrick Mahoney <pat@polycrystal.org> 4 * Copyright (c) 2008 Patrick Mahoney <pat@polycrystal.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code was written by Patrick Mahoney (pat@polycrystal.org) as 7 * This code was written by Patrick Mahoney (pat@polycrystal.org) as
8 * part of Google Summer of Code 2008. 8 * part of Google Summer of Code 2008.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * This ia a Video4Linux 2 compatible /dev/video driver for NetBSD 33 * This ia a Video4Linux 2 compatible /dev/video driver for NetBSD
34 * 34 *
35 * See http://v4l2spec.bytesex.org/ for Video4Linux 2 specifications 35 * See http://v4l2spec.bytesex.org/ for Video4Linux 2 specifications
36 */ 36 */
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.17.8.2 2009/01/22 23:21:19 snj Exp $"); 39__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.17.8.3 2009/03/15 20:34:29 snj Exp $");
40 40
41#include "video.h" 41#include "video.h"
42#if NVIDEO > 0 42#if NVIDEO > 0
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <sys/ioctl.h> 45#include <sys/ioctl.h>
46#include <sys/fcntl.h> 46#include <sys/fcntl.h>
47#include <sys/vnode.h> 47#include <sys/vnode.h>
48#include <sys/poll.h> 48#include <sys/poll.h>
49#include <sys/select.h> 49#include <sys/select.h>
50#include <sys/kmem.h> 50#include <sys/kmem.h>
51#include <sys/pool.h> 51#include <sys/pool.h>
52#include <sys/conf.h> 52#include <sys/conf.h>
@@ -750,27 +750,27 @@ video_get_format(struct video_softc *sc, @@ -750,27 +750,27 @@ video_get_format(struct video_softc *sc,
750 video_format_to_v4l2_format(&vfmt, format); 750 video_format_to_v4l2_format(&vfmt, format);
751  751
752 return 0; 752 return 0;
753} 753}
754 754
755static int 755static int
756video_set_format(struct video_softc *sc, struct v4l2_format *fmt) 756video_set_format(struct video_softc *sc, struct v4l2_format *fmt)
757{ 757{
758 const struct video_hw_if *hw; 758 const struct video_hw_if *hw;
759 struct video_format vfmt; 759 struct video_format vfmt;
760 int err; 760 int err;
761 761
762 hw = sc->hw_if; 762 hw = sc->hw_if;
763 if (hw->get_format == NULL) 763 if (hw->set_format == NULL)
764 return ENOTTY; 764 return ENOTTY;
765 765
766 v4l2_format_to_video_format(fmt, &vfmt); 766 v4l2_format_to_video_format(fmt, &vfmt);
767 767
768 err = hw->set_format(sc->hw_softc, &vfmt); 768 err = hw->set_format(sc->hw_softc, &vfmt);
769 if (err != 0) 769 if (err != 0)
770 return err; 770 return err;
771 771
772 video_format_to_v4l2_format(&vfmt, fmt); 772 video_format_to_v4l2_format(&vfmt, fmt);
773 sc->sc_stream_in.vs_format = vfmt; 773 sc->sc_stream_in.vs_format = vfmt;
774  774
775 return 0; 775 return 0;
776} 776}