Commit Graph

45 Commits

Author SHA1 Message Date
riastradh 322f361339 video(9): Make softc argument mandatory for video_attach_mi.
No separate video_attach_mi_softc function any more.
2022-03-03 06:23:25 +00:00
riastradh 1268adeb28 video(4): Allow drivers to pass the softc explicitly.
This way one device driver can have multiple video0, video1, &c.,
interfaces attached, using independent state and a common parent.
2022-03-03 06:22:23 +00:00
andvar 6012d766dc fix various typos in comments and log messages. 2021-12-08 20:50:01 +00:00
andvar 20fff34fc5 s/fist/first/ 2021-08-09 21:38:04 +00:00
thorpej c7fb772b85 Merge thorpej-cfargs2. 2021-08-07 16:18:40 +00:00
thorpej 2685996b0e Merge thorpej-cfargs branch:
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
  actually needed.
- Don't be explicit about what interface attribute is attaching if
  the device only has one.  (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
  situations, making is visibly easier to see when indirect config is
  in play, and allowing for future change in semantics.  (As of now,
  this is just a wrapper around config_match(), but that is an
  implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance.  This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
2021-04-24 23:36:23 +00:00
riastradh 56c44c5ee7 Nix trailing whitespace. 2020-08-13 16:45:58 +00:00
rjs 5d3121f64a Add some extra V4L ioctl() requests to latest V4L userland to work.
Import sys/videoio.h from OpenBSD, this is just the Linux headers
concatenated together.
2020-08-10 19:27:27 +00:00
jmcneill c506a297b5 Support VIDIOC_G_PARM/VIDIOC_S_PARM 2020-05-22 11:23:51 +00:00
msaitoh a0403cde04 s/transfered/transferred/ 2019-12-27 09:41:48 +00:00
riastradh d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
riastradh 1f73c3c78a Kill some more extern cfdriver xyz_cd in favour of #include "ioconf.h". 2017-10-28 03:47:24 +00:00
chs fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
dholland f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
dholland a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
christos 3abacce2d8 - remove unused variables
- moved debugging variable into debugging ifdef
2013-10-17 21:20:10 +00:00
prlw1 584e4370b5 Allow USB memory allocation by multiple segments in scatter/gather lists
rather than in a single contiguous block which causes problems with
large USB video frames.
Based on a patch by Jeremy Morse in the thread
http://mail-index.netbsd.org/current-users/2011/01/26/msg015532.html
Tested by developing http://code.opencv.org/issues/2360
OK jmcneill@
2013-01-07 15:07:40 +00:00
drochner 1336116b2f fill in timestamps in outgoing data buffers 2012-02-02 17:21:18 +00:00
jakllsch 93a4349576 Restore binary compatibility with NetBSD 5 binaries that utilize video(4). 2011-08-13 02:49:06 +00:00
jmcneill 97dc26a286 don't try to set frequencies lower or higher than the tuner's allowed
range -- the v4l2 spec says "when the requested frequency is not possible
the driver assumes the closest possible value".
2010-12-26 23:41:45 +00:00
jmcneill df0c38f693 VIDIOC_QUERYCAP changes:
- use driver name instead of device instance name in 'driver' field
 - add 'get_businfo' callback to fill in 'bus_info' field instead of
   hard-coding "USB"
 - use the kernel version for the 'version' field instead of 1
 - adapt pseye and uvideo drivers to changes in struct video_hw_if
2010-12-24 20:54:28 +00:00
jmcneill c618ceecc4 video(4) changes to support analog tv capture devices:
- support interlacing with VIDIOC_G_FMT
 - set V4L2_CAP_TUNER if driver implements the set_tuner/get_tuner
   callbacks
 - set V4L2_CAP_AUDIO if driver implements the set_audio/get_audio/enum_audio
   callbacks
 - add support for the following ioctls: VIDIOC_ENUMSTD, VIDIOC_G_STD,
   VIDIOC_S_STD, VIDIOC_ENUMINPUT, VIDIOC_G_INPUT, VIDIOC_S_INPUT,
   VIDIOC_ENUMAUDIO, VIDIOC_G_AUDIO, VIDIOC_S_AUDIO, VIDIOC_G_TUNER,
   VIDIOC_S_TUNER, VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY
 - in video_submit_payload(), fix support for signaling sample complete
   using frame numbers
 - new optional callbacks for drivers: enum_standard, get_standard,
   set_standard, enum_input, get_input, set_input, enum_audio, get_audio,
   set_audio, get_tuner, set_tuner, get_frequency, set_frequency

for drivers that don't provide enum_standard, get_standard, set_standard,
enum_input, get_input and set_input, the original stub implementations are
provided
2010-12-14 03:25:16 +00:00
dyoung 4075f812e7 Simplify these device-activation hooks using the following semantic
patch.

XXX sc_dying must die.

@@
type device_t;

identifier act, midi_softc, midiactivate, sc, self;
@@

int
midiactivate(device_t self, enum devact act)
{
(
	struct midi_softc *sc = device_private(self);
|
-	struct midi_softc *sc;
+	struct midi_softc *sc = device_private(self);
...
-	sc = device_private(self);
)
...
	switch (act) {
-	case DVACT_ACTIVATE:
-		return (EOPNOTSUPP);
-
	case DVACT_DEACTIVATE:
(
	sc->dying
|
	sc->sc_dying
)
		=
(
	1
|
	true
)
		;
-		break;
+		return 0;
+	default:
+		return EOPNOTSUPP;
	}
-	return (0);
}
2009-12-06 22:42:48 +00:00
christos d78b2ab1fc 1. some of the video24linux structs are not as machine independent as their
authors want them to be. For the buffer ioctls, define new ioctls with
   the 32 bit buffer sizes. For the format struct, define it as packed
   so it is the same on 32 and 64 bit. (I might need to version this)
2. the mmapped buffers need to be page aligned, otherwise mmap(2) does
   not work. Make it so.
All this makes my ricoh camera work with emul-linux and skype running on
amd64. Next is sound!
2009-08-18 02:17:09 +00:00
njoly b3f068f354 Fix amd64 build with VIDEO_DEBUG. 2009-07-07 21:55:17 +00:00
jmcneill b33d444d81 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
2009-03-14 00:33:25 +00:00
drochner 26a88cd4d5 -avoid eternal block if device is not streaming
-apply locking to avoid race in poll()
-fix an obviously wrong flag check
2009-01-20 20:18:28 +00:00
jmorse b400d28c38 Fix UVC webcam output by:
- Storing updated video format after user changes format
- Round up number of xfers queued to multiple of 8, due to ehci inefficiencies
- Remove random debugging line I slipped in earlier
2008-12-23 03:22:29 +00:00
jmcneill c3641af740 Register with pmf 2008-09-21 19:26:36 +00:00
jmcneill dd257cd7a7 Add RGB555, RGB565, UYVY support 2008-09-20 18:13:40 +00:00
jmcneill b04b4cc4f6 Use get_format instead of set_format in videoopen 2008-09-18 02:47:57 +00:00
jmcneill ef1dc4a8df Add VIDEO_FORMAT_YUV420 support 2008-09-14 16:03:27 +00:00
jmcneill e3661f12b1 Allow VIDIOC_ENUM_FORMAT to return more than one result. 2008-09-14 14:31:33 +00:00
jmcneill e1dadf87f1 Revert previous double-free hack, needs revisiting. 2008-09-14 03:33:44 +00:00
jmcneill 5f7d249f98 Add RGB24 support, and prevent a double-free on videoclose 2008-09-13 23:50:54 +00:00
jmcneill 7360cd3bde VIDIOC_QUERYCAP: device_xname on device_t, not softc 2008-09-09 04:28:54 +00:00
jmcneill f97cf58f74 More pixelformat mapping typo fixes 2008-09-09 04:23:53 +00:00
jmcneill 1bb2686bdf Map VIDEO_FORMAT_MJPEG to V4L2_PIX_FMT_MJPEG, not V4L2_PIX_FMT_JPEG 2008-09-09 04:23:02 +00:00
jmcneill ff15aabd32 Fix "select timeout" and low framerate issues with mplayer, from drochner@ 2008-09-09 01:36:48 +00:00
jmcneill 6779aaaeb8 Limit VIDEO_MAX_BUFS to 32 instead of 255 2008-09-08 00:39:27 +00:00
jmcneill ba13cfccc0 Missing aprint newline in video_attach 2008-09-07 20:05:13 +00:00
jmcneill f3728d27ce Actually, EINVAL is correct for an unimplemented ioctl. ENOTTY is only
needed for the VIDIOC_*_FMT ioctls.
2008-09-07 19:06:14 +00:00
jmcneill d490ea275a Return ENOTTY instead of EINVAL if a driver doesn't implement one of the
set, try, get, or enum format ioctls.
2008-09-07 17:13:21 +00:00
rmind a4a0c53b57 Unbreak build when VIDEO_DEBUG is not defined. 2008-09-06 21:21:49 +00:00
jmcneill 8e6b89263a Add MI video4linux2 layer, part of Patrick Mahoney's Google Summer
of Code 2008 project.
2008-09-06 19:00:54 +00:00