Home | History | Annotate | Download | only in dev
History log of /src/sys/dev/video.c
RevisionDateAuthorComments
 1.48  05-Jul-2025  mlelstv Use per unit names (video0, video1, ...) for cv and pool.
 1.47  12-Apr-2025  mlelstv Fix VIDIOC_ENUM_FRAMESIZES to return all frame sizes for a given
pixel format.
 1.46  16-Feb-2025  mlelstv When dropping lock around scatter_io_uiomove(), use busy flag
to serialize operations.

Hold lock while accessing video_stream and video_buffer.
 1.45  03-Mar-2022  riastradh branches: 1.45.10;
video(9): Make softc argument mandatory for video_attach_mi.

No separate video_attach_mi_softc function any more.
 1.44  03-Mar-2022  riastradh 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.
 1.43  08-Dec-2021  andvar fix various typos in comments and log messages.
 1.42  09-Aug-2021  andvar s/fist/first/
 1.41  07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.40  24-Apr-2021  thorpej branches: 1.40.8;
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?).
 1.39  13-Aug-2020  riastradh branches: 1.39.4;
Nix trailing whitespace.
 1.38  10-Aug-2020  rjs 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.
 1.37  22-May-2020  jmcneill Support VIDIOC_G_PARM/VIDIOC_S_PARM
 1.36  27-Dec-2019  msaitoh s/transfered/transferred/
 1.35  03-Sep-2018  riastradh 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!)
 1.34  28-Oct-2017  riastradh branches: 1.34.2; 1.34.4;
Kill some more extern cfdriver xyz_cd in favour of #include "ioconf.h".
 1.33  01-Jun-2017  chs 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.
 1.32  25-Jul-2014  dholland branches: 1.32.4; 1.32.8; 1.32.18;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.31  16-Mar-2014  dholland branches: 1.31.2;
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.
 1.30  17-Oct-2013  christos - remove unused variables
- moved debugging variable into debugging ifdef
 1.29  07-Jan-2013  prlw1 branches: 1.29.2;
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@
 1.28  02-Feb-2012  drochner branches: 1.28.6;
fill in timestamps in outgoing data buffers
 1.27  13-Aug-2011  jakllsch branches: 1.27.2; 1.27.6;
Restore binary compatibility with NetBSD 5 binaries that utilize video(4).
 1.26  26-Dec-2010  jmcneill 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".
 1.25  24-Dec-2010  jmcneill 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
 1.24  14-Dec-2010  jmcneill 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
 1.23  06-Dec-2009  dyoung branches: 1.23.4;
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);
}
 1.22  18-Aug-2009  christos 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!
 1.21  07-Jul-2009  njoly Fix amd64 build with VIDEO_DEBUG.
 1.20  14-Mar-2009  jmcneill branches: 1.20.2;
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
 1.19  20-Jan-2009  drochner branches: 1.19.2;
-avoid eternal block if device is not streaming
-apply locking to avoid race in poll()
-fix an obviously wrong flag check
 1.18  23-Dec-2008  jmorse 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
 1.17  21-Sep-2008  jmcneill branches: 1.17.2; 1.17.4; 1.17.6; 1.17.8;
Register with pmf
 1.16  20-Sep-2008  jmcneill Add RGB555, RGB565, UYVY support
 1.15  18-Sep-2008  jmcneill branches: 1.15.2;
Use get_format instead of set_format in videoopen
 1.14  14-Sep-2008  jmcneill Add VIDEO_FORMAT_YUV420 support
 1.13  14-Sep-2008  jmcneill Allow VIDIOC_ENUM_FORMAT to return more than one result.
 1.12  14-Sep-2008  jmcneill Revert previous double-free hack, needs revisiting.
 1.11  13-Sep-2008  jmcneill Add RGB24 support, and prevent a double-free on videoclose
 1.10  09-Sep-2008  jmcneill VIDIOC_QUERYCAP: device_xname on device_t, not softc
 1.9  09-Sep-2008  jmcneill More pixelformat mapping typo fixes
 1.8  09-Sep-2008  jmcneill Map VIDEO_FORMAT_MJPEG to V4L2_PIX_FMT_MJPEG, not V4L2_PIX_FMT_JPEG
 1.7  09-Sep-2008  jmcneill Fix "select timeout" and low framerate issues with mplayer, from drochner@
 1.6  08-Sep-2008  jmcneill Limit VIDEO_MAX_BUFS to 32 instead of 255
 1.5  07-Sep-2008  jmcneill Missing aprint newline in video_attach
 1.4  07-Sep-2008  jmcneill Actually, EINVAL is correct for an unimplemented ioctl. ENOTTY is only
needed for the VIDIOC_*_FMT ioctls.
 1.3  07-Sep-2008  jmcneill Return ENOTTY instead of EINVAL if a driver doesn't implement one of the
set, try, get, or enum format ioctls.
 1.2  06-Sep-2008  rmind Unbreak build when VIDEO_DEBUG is not defined.
 1.1  06-Sep-2008  jmcneill Add MI video4linux2 layer, part of Patrick Mahoney's Google Summer
of Code 2008 project.
 1.15.2.3  10-Oct-2008  skrll Sync with HEAD.
 1.15.2.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.15.2.1  18-Sep-2008  wrstuden file video.c was added on branch wrstuden-revivesa on 2008-09-18 04:35:01 +0000
 1.17.8.3  15-Mar-2009  snj 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
 1.17.8.2  22-Jan-2009  snj Pull up following revision(s) (requested by drochner in ticket #305):
sys/dev/video.c: revision 1.19
-avoid eternal block if device is not streaming
-apply locking to avoid race in poll()
-fix an obviously wrong flag check
 1.17.8.1  27-Dec-2008  snj Pull up following revision(s) (requested by jmorse in ticket #204):
sys/dev/video.c: revision 1.18
sys/dev/usb/uvideo.c: revision 1.24
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
 1.17.6.3  28-Apr-2009  skrll Sync with HEAD.
 1.17.6.2  03-Mar-2009  skrll Sync with HEAD.
 1.17.6.1  19-Jan-2009  skrll Sync with HEAD.
 1.17.4.2  19-Oct-2008  haad Sync with HEAD.
 1.17.4.1  21-Sep-2008  haad file video.c was added on branch haad-dm on 2008-10-19 22:16:18 +0000
 1.17.2.3  17-Jan-2009  mjf Sync with HEAD.
 1.17.2.2  28-Sep-2008  mjf Sync with HEAD.
 1.17.2.1  21-Sep-2008  mjf file video.c was added on branch mjf-devfs2 on 2008-09-28 10:40:18 +0000
 1.19.2.2  23-Jul-2009  jym Sync with HEAD.
 1.19.2.1  13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.20.2.5  11-Mar-2010  yamt sync with head
 1.20.2.4  19-Aug-2009  yamt sync with head.
 1.20.2.3  18-Jul-2009  yamt sync with head.
 1.20.2.2  04-May-2009  yamt sync with head.
 1.20.2.1  14-Mar-2009  yamt file video.c was added on branch yamt-nfs-mp on 2009-05-04 08:12:33 +0000
 1.23.4.1  05-Mar-2011  rmind sync with head
 1.27.6.1  18-Feb-2012  mrg merge to -current.
 1.27.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.27.2.2  23-Jan-2013  yamt sync with head
 1.27.2.1  17-Apr-2012  yamt sync with head
 1.28.6.3  03-Dec-2017  jdolecek update from HEAD
 1.28.6.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.28.6.1  25-Feb-2013  tls resync with head
 1.29.2.1  18-May-2014  rmind sync with head
 1.31.2.1  10-Aug-2014  tls Rebase.
 1.32.18.1  27-Apr-2017  pgoyette Restore all work from the former pgoyette-localcount branch (which is
now abandoned doe to cvs merge botch).

The branch now builds, and installs via anita. There are still some
problems (cgd is non-functional and all atf tests time-out) but they
will get resolved soon.
 1.32.8.2  26-Jul-2016  pgoyette Typo
 1.32.8.1  26-Jul-2016  pgoyette Sync with HEAD
 1.32.4.1  28-Aug-2017  skrll Sync with HEAD
 1.34.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.34.4.1  10-Jun-2019  christos Sync with HEAD
 1.34.2.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.39.4.1  02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.40.8.1  04-Aug-2021  thorpej Adapt to CFARGS().
 1.45.10.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed