Compare commits

...

16 Commits

Author SHA1 Message Date
Alan Coopersmith
a0eaca36a7 Improve man page formatting
More closely follow common style as described on
https://man7.org/linux/man-pages/man7/man-pages.7.html
and fix warnings raised by `mandoc -T lint` and `groff -rCHECKSTYLE=10`

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-video-v4l/-/merge_requests/7>
2025-07-12 15:16:15 -07:00
Enrico Weigelt, metux IT consult
eb1e55874c Use asprintf() instead of Xasprintf()
This driver is Linux-only, so it's safe to assume asprintf() here.

It's one of the last few drivers ever using that function, so
blocking its removal from Xorg ABI.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-video-v4l/-/merge_requests/5>
2025-03-07 09:51:42 +01:00
Alan Coopersmith
36ffdb5239 Fix -Wdiscarded-qualifiers warning in AddV4LEnc()
v4l.c: In function 'AddV4LEnc':
v4l.c:920:16: warning: passing argument 1 of 'sprintf' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  920 |     sprintf(enc->name,"%s-%s",norm,fixname(input));
      |             ~~~^~~~~~
In file included from v4l.c:20:
/usr/include/stdio.h:363:38: note: expected 'char * restrict' but argument is of type 'const char *'
  363 | extern int sprintf (char *__restrict __s,
      |                     ~~~~~~~~~~~~~~~~~^~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-01-16 13:38:49 -08:00
Alan Coopersmith
7899231c65 Quiet -Wredundant-decls warnings for strlcat and strlcpy
In file included from /usr/include/xorg/misc.h:119,
                 from /usr/include/xorg/xf86str.h:37,
                 from /usr/include/xorg/xf86.h:44,
                 from v4l.c:25:
/usr/include/xorg/os.h:595:1: warning: redundant redeclaration of 'strlcpy'
 [-Wredundant-decls]
  595 | strlcpy(char *dst, const char *src, size_t siz);
      | ^~~~~~~
In file included from v4l.c:19:
/usr/include/string.h:506:15: note: previous declaration of 'strlcpy' with
 type 'size_t(char * restrict, const char * restrict, size_t)' {aka
 'long unsigned int(char * restrict, const char * restrict, long unsigned int)'}
  506 | extern size_t strlcpy (char *__restrict __dest,
      |               ^~~~~~~
/usr/include/xorg/os.h:597:1: warning: redundant redeclaration of 'strlcat'
 [-Wredundant-decls]
  597 | strlcat(char *dst, const char *src, size_t siz);
      | ^~~~~~~
/usr/include/string.h:512:15: note: previous declaration of 'strlcat' with
 type 'size_t(char * restrict, const char * restrict, size_t)' {aka
 'long unsigned int(char * restrict, const char * restrict, long unsigned int)'}
  512 | extern size_t strlcat (char *__restrict __dest,
      |               ^~~~~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-01-16 13:30:10 -08:00
Alan Coopersmith
10e0e12fcf Add X.Org's standard C warning flags to AM_CFLAGS
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-01-16 13:08:07 -08:00
Alan Coopersmith
07871d6be3 configure: Use LT_INIT from libtool 2 instead of deprecated AC_PROG_LIBTOOL
AC_PROG_LIBTOOL was replaced by LT_INIT in libtool 2 in 2008,
so it's time to rely on it.

Clears autoconf warnings:

configure.ac:45: warning: The macro 'AC_PROG_LIBTOOL' is obsolete.
configure.ac:45: You should run autoupdate.
aclocal.m4:3551: AC_PROG_LIBTOOL is expanded from...
configure.ac:45: the top level

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-01-16 13:07:35 -08:00
Alan Coopersmith
6367e7e46d gitlab CI: ensure libtool is installed in build container
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-10-07 09:06:39 -07:00
Alan Coopersmith
1f9068a1c8 gitlab CI: stop requiring Signed-off-by in commits
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-02-09 12:07:00 -08:00
Alan Coopersmith
c5235058aa gitlab CI: add a basic build test
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-01-29 15:49:27 -08:00
Alan Coopersmith
cb3970480f Fix spelling/wording issues
Found by using:
    codespell --builtin clear,rare,usage,informal,code,names

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-01-29 15:48:26 -08:00
Alan Coopersmith
a375e88f89 Build xz tarballs instead of bzip2
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-01-29 15:45:50 -08:00
Alan Coopersmith
3df0a355f9 Update configure.ac bug URL for gitlab migration
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2018-12-07 19:18:13 -08:00
Peter Hutterer
b3244827d9 Fix ioctl return value handling
Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2018-10-08 13:16:35 +10:00
Peter Hutterer
3370b6b6a4 Fix handling of realloc failure
Coverity complaint and whatnot

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2018-10-08 13:16:28 +10:00
Peter Hutterer
a020fda02f Ensure the device name is null-terminated
And expand the size to 18, because the stack array we copied this into is 18
bytes long. This covers us for up to 999 (kernel) v4l devices and that is
definitely not a reason to use the "640k ought to be enough" meme.

Found by - you guessed it - coverity!

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2018-10-08 13:10:14 +10:00
Peter Hutterer
3f9022bdfe Remove unused variable osname
Coverity is unhappy and there's enough unhappiness in this world already, so
let's go for the low-hanging fruit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2018-10-08 13:07:25 +10:00
6 changed files with 158 additions and 35 deletions

98
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,98 @@
# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
#
# This CI uses the freedesktop.org ci-templates.
# Please see the ci-templates documentation for details:
# https://freedesktop.pages.freedesktop.org/ci-templates/
.templates_sha: &template_sha 25e8e9f020880aa35fffe3d6b259b933f0f9449f # see https://docs.gitlab.com/ee/ci/yaml/#includefile
include:
# Arch container builder template
- project: 'freedesktop/ci-templates'
ref: *template_sha
file: '/templates/arch.yml'
- project: 'freedesktop/ci-templates'
ref: *template_sha
file: '/templates/ci-fairy.yml'
- template: Security/SAST.gitlab-ci.yml
stages:
- prep # prep work like rebuilding the container images if there is a change
- build # for actually building and testing things in a container
- test
- deploy
variables:
FDO_UPSTREAM_REPO: 'xorg/driver/xf86-video-v4l'
# The tag should be updated each time the list of packages is updated.
# Changing a tag forces the associated image to be rebuilt.
# Note: the tag has no meaning, we use a date format purely for readability
FDO_DISTRIBUTION_TAG: '2023-10-01.0'
FDO_DISTRIBUTION_PACKAGES: 'git gcc pkgconf autoconf automake libtool make xorg-util-macros xorgproto xorg-server-devel pixman'
#
# Verify that commit messages are as expected
#
check-commits:
extends:
- .fdo.ci-fairy
stage: prep
script:
- ci-fairy check-commits --junit-xml=results.xml
except:
- master@xorg/driver/xf86-video-v4l
variables:
GIT_DEPTH: 100
artifacts:
reports:
junit: results.xml
#
# Verify that the merge request has the allow-collaboration checkbox ticked
#
check-merge-request:
extends:
- .fdo.ci-fairy
stage: deploy
script:
- ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
artifacts:
when: on_failure
reports:
junit: results.xml
allow_failure: true
#
# Build a container with the given tag and the packages pre-installed.
# This only happens if the tag changes, otherwise the existing image is
# re-used.
#
container-prep:
extends:
- .fdo.container-build@arch
stage: prep
variables:
GIT_STRATEGY: none
#
# The default build, runs on the image built above.
#
build:
stage: build
extends:
- .fdo.distribution-image@arch
script:
- autoreconf -ivf
- mkdir _builddir
- pushd _builddir > /dev/null
- ../configure --disable-silent-rules
- make
- make check
- make distcheck
- popd > /dev/null

View File

@@ -24,14 +24,14 @@
AC_PREREQ([2.60])
AC_INIT([xf86-video-v4l],
[0.3.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[https://gitlab.freedesktop.org/xorg/driver/xf86-video-v4l/issues],
[xf86-video-v4l])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR(.)
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_INIT_AUTOMAKE([foreign dist-xz])
AM_MAINTAINER_MODE
# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
@@ -41,8 +41,7 @@ XORG_MACROS_VERSION(1.8)
XORG_DEFAULT_OPTIONS
# Initialize libtool
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
LT_INIT([disable-static])
AH_TOP([#include "xorg-server.h"])
@@ -60,7 +59,10 @@ XORG_DRIVER_CHECK_EXT(XV, videoproto)
# Obtain compiler/linker options for the driver dependencies
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto $REQUIRED_MODULES])
# Checks for libraries.
# Checks for library functions
# We don't use strlcat or strlcpy, but check to quiet a -Wredundant-decls warning
# from xorg/os.h which will otherwise redefine it.
AC_CHECK_FUNCS([strlcat strlcpy])
AC_SUBST([moduledir])

View File

@@ -1,7 +1,6 @@
.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.man,v 1.2 2001/01/27 18:20:55 dawes Exp $
.\" shorthand for double quote that works everywhere.
.ds q \N'34'
.TH V4L __drivermansuffix__ __vendorversion__
.TH V4L 4 2009-01-09 __vendorversion__
.SH NAME
v4l \- video4linux driver
.SH SYNOPSIS
@@ -12,11 +11,15 @@ v4l \- video4linux driver
.B EndSection
.fi
.SH DESCRIPTION
.B v4l
is an __xservername__ driver for video4linux cards. It provides a Xvideo
extension port for video overlay. Just add the driver to the module
list within the module section of your __xconfigfile__ file if you want
to use it. There are no config options.
.B v4l
is an
.B Xorg
driver for video4linux cards.
It provides a Xvideo extension port for video overlay.
Just add the driver to the module list within the module section of your
.B xorg.conf
file if you want to use it.
There are no config options.
.P
Note that the extmod module is also required for the Xvideo
support (and lots of other extensions too).
@@ -30,10 +33,14 @@ overlay.
bt848/bt878-based TV cards are the most popular hardware these
days.
.SH CONFIGURATION DETAILS
Please refer to __xconfigfile__(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
Please refer to
.BR xorg.conf (5)
for general configuration details.
This section only covers configuration details specific to this driver.
.SH "SEE ALSO"
__xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
.BR Xorg (1),
.BR Xserver (1),
.BR xorg.conf (5),
.BR X (7)
.SH AUTHORS
Authors include: Gerd Knorr <kraxel@bytesex.org>

View File

@@ -23,7 +23,7 @@
# -avoid-version prevents gratuitous .0.0.0 version numbers on the end
# _ladir passes a dummy rpath to libtool so the thing will actually link
# TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
AM_CFLAGS = @XORG_CFLAGS@
AM_CFLAGS = $(BASE_CFLAGS) $(XORG_CFLAGS)
v4l_drv_la_LTLIBRARIES = v4l_drv.la
v4l_drv_la_LDFLAGS = -module -avoid-version
v4l_drv_ladir = @moduledir@/drivers

View File

@@ -10,6 +10,10 @@
#include "config.h"
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
@@ -86,7 +90,6 @@ _X_EXPORT XF86ModuleData v4lModuleData = { &v4lVersRec, v4lSetup, NULL };
static pointer
v4lSetup(pointer module, pointer opts, int *errmaj, int *errmin)
{
const char *osname;
static Bool setupDone = FALSE;
if (setupDone) {
@@ -110,7 +113,7 @@ v4lSetup(pointer module, pointer opts, int *errmaj, int *errmin)
#define VIDEO_OFF 0 /* really off */
#define VIDEO_RGB 1 /* rgb overlay (directly to fb) */
#define VIDEO_YUV 2 /* yuv overlay (to offscreen memory + hw scaling) */
#define VIDEO_RECLIP 3 /* temporarly off, window clipping changes */
#define VIDEO_RECLIP 3 /* temporarily off, window clipping changes */
typedef struct _XvV4LCtrlRec {
struct v4l2_queryctrl qctrl;
@@ -189,7 +192,7 @@ static const XF86AttributeRec FreqAttr =
static struct V4L_DEVICE {
int fd;
int useCount;
char devName[16];
char devName[18];
} v4l_devices[MAX_V4L_DEVICES] = {
{ -1 },
{ -1 },
@@ -770,12 +773,15 @@ V4lSetPortAttribute(ScrnInfoPtr pScrn,
} else if (attribute == xvFreq) {
struct v4l2_frequency freq;
memset(&freq, 0, sizeof(freq));
ioctl(V4L_FD, VIDIOC_G_FREQUENCY, &freq);
freq.frequency = value;
if (ioctl(V4L_FD, VIDIOC_S_FREQUENCY, &freq) == -1)
xf86Msg(X_ERROR, "v4l: Error %d while setting frequency\n", errno);
else
ret = Success;
if (ioctl(V4L_FD, VIDIOC_G_FREQUENCY, &freq) == -1) {
xf86Msg(X_ERROR, "v4l: Error %d while getting frequency\n", errno);
} else {
freq.frequency = value;
if (ioctl(V4L_FD, VIDIOC_S_FREQUENCY, &freq) == -1)
xf86Msg(X_ERROR, "v4l: Error %d while setting frequency\n", errno);
else
ret = Success;
}
} else {
for (i = 0; i < pPPriv->n_qctrl; i++)
if (pPPriv->XvV4LCtrl[i].xv == attribute)
@@ -906,16 +912,20 @@ static int
AddV4LEnc(XF86VideoEncodingPtr enc, int entry,
char *norm, char *input, int width, int height, int n, int d)
{
enc->id = entry;
enc->name = malloc(strlen(norm) + strlen(input) + 2);
if (!enc->name)
char *name;
if (asprintf(&name, "%s-%s", norm, fixname(input)) < 0)
name = NULL;
if (name == NULL)
return -1;
enc->id = entry;
enc->name = name;
enc->width = width;
enc->height = height;
enc->rate.numerator = n;
enc->rate.denominator = d * 2; /* Refresh rate is twice, due to interlace */
sprintf(enc->name,"%s-%s",norm,fixname(input));
xf86Msg(X_INFO, "v4l: adding input %s, %dx%d %d fps\n",
enc->name, enc->width, enc->height, (d + n - 1)/n);
@@ -1121,6 +1131,7 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
XF86VideoAdaptorPtr *VAR = NULL;
char dev[18];
int fd,i,j,d;
void *tmp;
for (i = 0, d = 0; d < MAX_V4L_DEVICES; d++) {
sprintf(dev, "/dev/video%d", d);
@@ -1158,13 +1169,18 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
}
xf86Msg(X_INFO, "v4l: enabling overlay mode for %s.\n", dev);
strncpy(V4L_NAME, dev, 16);
strncpy(V4L_NAME, dev, 18);
V4L_NAME[17] = '\0';
V4LBuildEncodings(pPPriv, fd);
if (NULL == pPPriv->enc)
return FALSE;
/* alloc VideoAdaptorRec */
VAR = realloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
tmp = realloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
if (!tmp)
return FALSE;
VAR = tmp;
VAR[i] = malloc(sizeof(XF86VideoAdaptorRec));
if (!VAR[i])
return FALSE;
@@ -1186,7 +1202,7 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
/* Initialize yuv_format */
if (0 != pPPriv->yuv_format) {
/* pass throuth scaler attributes */
/* pass through scaler attributes */
for (j = 0; j < pPPriv->myfmt->num_attributes; j++) {
v4l_add_attr(&VAR[i]->pAttributes, &VAR[i]->nAttributes,
pPPriv->myfmt->attributes+j);

View File

@@ -511,7 +511,7 @@ struct v4l2_jpegcompression {
__u32 jpeg_markers; /* Which markers should go into the JPEG
* output. Unless you exactly know what
* you do, leave them untouched.
* Inluding less markers will make the
* Including less markers will make the
* resulting code smaller, but there will
* be fewer applications which can read it.
* The presence of the APP and COM marker
@@ -523,7 +523,7 @@ struct v4l2_jpegcompression {
#define V4L2_JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */
#define V4L2_JPEG_MARKER_COM (1<<6) /* Comment segment */
#define V4L2_JPEG_MARKER_APP (1<<7) /* App segment, driver will
* allways use APP0 */
* always use APP0 */
};
/*