platform/upstream/v4l-utils.git
10 years agoqv4l2: force bytesperline recalculation when changing the width.
Hans Verkuil [Sun, 20 Jul 2014 13:19:15 +0000 (15:19 +0200)]
qv4l2: force bytesperline recalculation when changing the width.

Most drivers will always recalculate bytesperline, but some allow for
applications to set it in order to support line padding.

In that case you need to set the bytesperline to 0 when setting a new
format in order to force the recalculation.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: integrate with the cv4l-helpers.h header
Hans Verkuil [Sun, 20 Jul 2014 12:38:42 +0000 (14:38 +0200)]
qv4l2: integrate with the cv4l-helpers.h header

Replace the old v4l2-api.cpp/.h files by the cv4l-helpers.h.
It's a major change, but without any functional changes involved,
just refactoring.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: reworked the (c)v4l-helpers.h headers
Hans Verkuil [Sun, 20 Jul 2014 12:20:09 +0000 (14:20 +0200)]
v4l2-compliance: reworked the (c)v4l-helpers.h headers

These headers were designed to easy coding for the V4L2 API, in particular
hiding the complexity relating to single and multiplanar formats.

These reworked headers resolve a number of design issues and they are now ready
to be used elsewhere.

As an example, the C++ code below works for single and multiplanar video capture and
output, vbi capture and output and sdr capture. By replacing V4L2_MEMORY_MMAP with
_USERPTR it will work with userptr streaming as well. But note that the code is
missing error handling, so a real application will need to do a bit more.

int main(int argc, char **argv)
{
cv4l_fd fd;
unsigned cnt = 0;

fd.open(argc >= 2 ? argv[1] : "/dev/video0");

cv4l_queue q(fd.g_type(), V4L2_MEMORY_MMAP);

q.reqbufs(&fd, 4);
q.obtain_bufs(&fd);
q.queue_all(&fd);
fd.streamon();

cv4l_buffer buf(q);

while (fd.dqbuf(buf) == 0) {
printf("seqnr: %u bytesused[0]: %u bytesused[1]: %u\n", buf.g_sequence(),
buf.g_bytesused(0), buf.g_bytesused(1));
fd.qbuf(buf);
if (cnt++ >= 60)
break;
}
q.free(&fd);
fd.close();
}

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: QImage could be the wrong size
Hans Verkuil [Sat, 19 Jul 2014 22:23:46 +0000 (00:23 +0200)]
qv4l2: QImage could be the wrong size

The QImage should be re-created every time the resolution changes, but
sometimes that didn't happen due to bad condition. Updated the condition
ensuring a correct QImage.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: add Q shortcut to close the video window
Hans Verkuil [Sat, 19 Jul 2014 22:08:51 +0000 (00:08 +0200)]
qv4l2: add Q shortcut to close the video window

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: center frame and drop margins in full screen mode
Hans Verkuil [Sat, 19 Jul 2014 21:45:58 +0000 (23:45 +0200)]
qv4l2: center frame and drop margins in full screen mode

The video was never properly centered in the window, this has now
been fixed.

In addition there were still non-zero margins when in full screen mode,
so the image was scaled even if it should be the native screen resolution.
This is now also working properly.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: improve full-screen handling
Hans Verkuil [Sat, 19 Jul 2014 20:29:24 +0000 (22:29 +0200)]
qv4l2: improve full-screen handling

Improved the full screen handling. In particular selecting the fullscreen
mode will no longer automatically start streaming, that was not meant to
happen. Also route all fullscreen handling through the correct QAction
rather than duplicating it in the capture window. This ensures a consistent
internal state.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: fix broken priv test
Hans Verkuil [Sat, 19 Jul 2014 07:31:07 +0000 (09:31 +0200)]
v4l2-compliance: fix broken priv test

After the recent addition of V4L2_PIX_FMT_PRIV_MAGIC the priv test
in v4l2-compliance was no longer correct. Fix it by making
V4L2_PIX_FMT_PRIV_MAGIC a valid value.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: add the two new png's to the EXTRA_DIST list
Hans Verkuil [Fri, 18 Jul 2014 23:20:39 +0000 (01:20 +0200)]
qv4l2: add the two new png's to the EXTRA_DIST list

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix a coverity defect
Hans Verkuil [Fri, 18 Jul 2014 22:21:01 +0000 (00:21 +0200)]
qv4l2: fix a coverity defect

*** CID 1226677:  Unused pointer value  (UNUSED_VALUE)
/utils/qv4l2/ctrl-tab.cpp: 64 in ApplicationWindow::addWidget(QGridLayout *, QWidget *, QFlags<Qt::AlignmentFlag>)()
58      }
59     }
60
61     void ApplicationWindow::addWidget(QGridLayout *grid, QWidget *w, Qt::Alignment align)
62     {
63      QToolButton *tb;
>>>     CID 1226677:  Unused pointer value  (UNUSED_VALUE)
>>>     Pointer "tb" returned by "qobject_cast(w)" is never used.
64      if (m_col % 2 && !(tb = qobject_cast<QToolButton*>(w)))
65      w->setMinimumWidth(m_minWidth);
66      if (w->sizeHint().width() > m_maxw[m_col])
67      m_maxw[m_col] = w->sizeHint().width();
68      if (w->sizeHint().height() > m_maxh)
69      m_maxh = w->sizeHint().height();

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: adding fullscreen option to toolbar main window
Anton Arbring [Fri, 18 Jul 2014 13:26:41 +0000 (15:26 +0200)]
qv4l2: adding fullscreen option to toolbar main window

To get the possibility to start capturing in fullscreen
mode from capture menu and main toolbar

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: added right click menu to capturewin
Anton Arbring [Fri, 18 Jul 2014 12:45:30 +0000 (14:45 +0200)]
qv4l2: added right click menu to capturewin

Making it possible to do certain actions in
and out of fullscreen mode

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: added fullscreen functionality for capture window
Anton Arbring [Fri, 18 Jul 2014 10:54:34 +0000 (12:54 +0200)]
qv4l2: added fullscreen functionality for capture window

One can enter fullscreen mode by a push button, the F key
or by a double click. To go back to window mode; all
the same options plus the escape key.

An eventfilter is added to show a status bar when moving
the mouse to the bottom of the screen while in fullscreen mode.

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: bypass libv4l2 when obtaining the colorspace
Hans Verkuil [Fri, 18 Jul 2014 11:57:29 +0000 (13:57 +0200)]
qv4l2: bypass libv4l2 when obtaining the colorspace

libv4l2 does not update the colorspace information when it should.
So just for the purpose of reading the colorspace information we
bypass libv4l2 and do a direct VIDIOC_G_FMT to the driver.

I kept forgetting why I wasn't getting the right colorspace results
and everytime it took me a while before I realized that the colorspace
was wrong.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
10 years agov4l2-ctl: fix returned pixelformats that map to fbdev
Hans Verkuil [Fri, 18 Jul 2014 11:47:28 +0000 (13:47 +0200)]
v4l2-ctl: fix returned pixelformats that map to fbdev

fbdev cannot report if the hardware can actually make use of the
alpha channel, so just assume that it does when v4l2-ctl translates
the fbdev pixel format information to V4L2 pixformat defines.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
10 years agolibv4lconvert: add support for new pixelformats
Hans Verkuil [Thu, 17 Jul 2014 22:27:42 +0000 (00:27 +0200)]
libv4lconvert: add support for new pixelformats

Support for alpha-channel aware pixelformats was added. Recognize those formats
in libv4lconvert.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
10 years agov4l2-ctl: add support for the new alpha-aware pixelformats.
Hans Verkuil [Thu, 17 Jul 2014 22:25:00 +0000 (00:25 +0200)]
v4l2-ctl: add support for the new alpha-aware pixelformats.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: add support for new alpha-aware pixelformats.
Hans Verkuil [Thu, 17 Jul 2014 22:15:43 +0000 (00:15 +0200)]
qv4l2: add support for new alpha-aware pixelformats.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: also check for V4L2_CAP_EXT_PIX_FORMAT in device_caps
Hans Verkuil [Thu, 17 Jul 2014 21:37:53 +0000 (23:37 +0200)]
v4l2-compliance: also check for V4L2_CAP_EXT_PIX_FORMAT in device_caps

It must be present in both capability sets.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-ctl: add support for new extended format flags field.
Hans Verkuil [Thu, 17 Jul 2014 21:36:15 +0000 (23:36 +0200)]
v4l2-ctl: add support for new extended format flags field.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: check for the presence of V4L2_CAP_EXT_PIX_FORMAT
Hans Verkuil [Thu, 17 Jul 2014 20:50:15 +0000 (22:50 +0200)]
v4l2-compliance: check for the presence of V4L2_CAP_EXT_PIX_FORMAT

This cap is set by the core, so any driver that doesn't have it is
bypassing the v4l2 core.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l-utils: add new V4L2_CAP_EXT_PIX_FORMAT capability
Hans Verkuil [Thu, 17 Jul 2014 20:47:14 +0000 (22:47 +0200)]
v4l-utils: add new V4L2_CAP_EXT_PIX_FORMAT capability

And sync up all the various capability-print functions so they
all have the same set of caps that they print. Except for rds-ctl
that just cares about radio related caps.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-ctl: allow setting/getting subsets
Hans Verkuil [Wed, 11 Jun 2014 09:42:55 +0000 (11:42 +0200)]
v4l2-ctl: allow setting/getting subsets

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-ctl: add support for array controls
Hans Verkuil [Tue, 10 Jun 2014 14:10:17 +0000 (16:10 +0200)]
v4l2-ctl: add support for array controls

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-ctl: add support for the motion detection event
Hans Verkuil [Tue, 10 Jun 2014 11:50:52 +0000 (13:50 +0200)]
v4l2-ctl: add support for the motion detection event

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l-utils: update the headers to the latest kernel version.
Hans Verkuil [Thu, 17 Jul 2014 17:26:17 +0000 (19:26 +0200)]
v4l-utils: update the headers to the latest kernel version.

Ran 'make sync-with-kernel' to get everything synced up again.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agocontrib/freebsd/Makefile.am: fix syntax error.
Hans Verkuil [Thu, 17 Jul 2014 17:19:35 +0000 (19:19 +0200)]
contrib/freebsd/Makefile.am: fix syntax error.

Add missing semi-colons.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: use the new toolbutton for three buttons in the general tab
Hans Verkuil [Thu, 17 Jul 2014 10:52:20 +0000 (12:52 +0200)]
qv4l2: use the new toolbutton for three buttons in the general tab

Replace the old pushbutton for Refresh Tuner Status and Query Standard
and Timings with the new, much better looking tool button.

This allows us to put the label on the left and the tuner status on
the right of the tool button, which looks much better.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: add new png to the list of distributed files
Hans Verkuil [Thu, 17 Jul 2014 10:12:15 +0000 (12:12 +0200)]
qv4l2: add new png to the list of distributed files

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: added icon and moved label
Anton Arbring [Thu, 17 Jul 2014 09:06:51 +0000 (11:06 +0200)]
qv4l2: added icon and moved label

For auto generated buttons, the text of the button
is now used as labels and the buttons are now
QToolButtons with enter key icons

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: m_useGLAct is only available if HAVE_QTGL is set.
Hans Verkuil [Wed, 16 Jul 2014 22:00:17 +0000 (00:00 +0200)]
qv4l2: m_useGLAct is only available if HAVE_QTGL is set.

Put #ifdef HAVE_QTGL around it to prevent a crash if it wasn't compiled
with opengl.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: always do updateVidCapFormat when changing crop/compose
Hans Verkuil [Wed, 16 Jul 2014 11:47:10 +0000 (13:47 +0200)]
qv4l2: always do updateVidCapFormat when changing crop/compose

Changing the crop size can change the format size at the same
time, so we need to update all the formatting parameters.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
10 years agov4l2-compliance: fix problems with vbi streaming.
Hans Verkuil [Wed, 16 Jul 2014 09:55:59 +0000 (11:55 +0200)]
v4l2-compliance: fix problems with vbi streaming.

VBI is only valid for SDTV inputs/outputs. In addition, when you
start streaming make sure to call s_fmt with the right VBI type
(raw vs sliced) otherwise streaming might not work if it is in the
wrong mode.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: add v4l2_format support to cv4l-helpers.h
Hans Verkuil [Wed, 16 Jul 2014 07:07:18 +0000 (09:07 +0200)]
v4l2-compliance: add v4l2_format support to cv4l-helpers.h

And use it in v4l2-compliance. This should simplify format handling
in the code.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: improved v4l helpers header, add tracing
Hans Verkuil [Wed, 16 Jul 2014 06:03:57 +0000 (08:03 +0200)]
v4l2-compliance: improved v4l helpers header, add tracing

The v4l-helpers.h header was missing ioctl tracing capabilities, this was
fairly annoying. This has now been added.

Also added additional inlines for capability checks.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: removed colon and correct rowcount
Anton Arbring [Tue, 15 Jul 2014 11:10:49 +0000 (13:10 +0200)]
qv4l2: removed colon and correct rowcount

removed colon from info labels in general info section
and changed getheight to count rows in the gui, like it
is already done in ctrl-tab.cpp

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix a confusing error message when capturing VBI.
Hans Verkuil [Tue, 15 Jul 2014 09:41:42 +0000 (11:41 +0200)]
qv4l2: fix a confusing error message when capturing VBI.

The message says "non-grey pixelformat not supported for VBI", but what
it really should say is: "this input does not support VBI".

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: bugfix and dynamic adjustments
Anton Arbring [Mon, 14 Jul 2014 14:23:57 +0000 (16:23 +0200)]
qv4l2: bugfix and dynamic adjustments

* defined a few hard coded values as consts
* calculate height of window in a more dynamic manner
* recalculate width of columns when subchannels label is changed
* changed horizontal stretch

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: refactoring general-tab.cpp
Anton Arbring [Mon, 14 Jul 2014 10:02:49 +0000 (12:02 +0200)]
qv4l2: refactoring general-tab.cpp

To get a better overview of what's going on, a lot of the
code in the constructor is moved to functions where a section
of the GUI is created.

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: allow frequency bands of just one frequency
Hans Verkuil [Tue, 15 Jul 2014 03:48:49 +0000 (05:48 +0200)]
v4l2-compliance: allow frequency bands of just one frequency

Also improve some of the ENUM_FREQ_BANDS checks.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibv4lcontrol: sync control strings/flags with the kernel
Hans Verkuil [Tue, 8 Jul 2014 11:07:27 +0000 (13:07 +0200)]
libv4lcontrol: sync control strings/flags with the kernel

The emulated control names and control flags were different from
what the kernel uses.  Sync them up.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed by: Hans de Goede <hdegoede@redhat.com>

10 years agolibv4lconvert: add support for extended controls
Hans Verkuil [Tue, 8 Jul 2014 11:04:21 +0000 (13:04 +0200)]
libv4lconvert: add support for extended controls

libv4lconvert did not support the extended control API so qv4l2, which
uses it, didn't work properly with libv4l2 since passing software
emulated controls using the extended control API will fail as those
controls are obviously not known to the driver.

This patch adds support for this API.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed by: Hans de Goede <hdegoede@redhat.com>

10 years agov4l2-compliance: only discrete framesizes are not allowed for output
Hans Verkuil [Sun, 13 Jul 2014 00:15:45 +0000 (02:15 +0200)]
v4l2-compliance: only discrete framesizes are not allowed for output

Stepwise/continuous framesizes can be valid for output as well, so
relax this test.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: fix control test
Hans Verkuil [Sat, 12 Jul 2014 10:35:54 +0000 (12:35 +0200)]
v4l2-compliance: fix control test

The test 'step > max - min' doesn't make sense if min == max.
So check for that corner case.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agords-ctl: print RBDS call sign.
Hans Verkuil [Sat, 12 Jul 2014 07:54:42 +0000 (09:54 +0200)]
rds-ctl: print RBDS call sign.

The PI code encodes a station's call sign for RBDS. Decode it and
print the call sign name.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibv4l2rds: Area Coverage is only partially available for RBDS
Hans Verkuil [Sat, 12 Jul 2014 07:32:19 +0000 (09:32 +0200)]
libv4l2rds: Area Coverage is only partially available for RBDS

RBDS supports area coverage codes only for B, D and E PI code blocks.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibv4l2rds: handle V4L2_RDS_BLOCK_INVALID.
Hans Verkuil [Sat, 12 Jul 2014 07:28:50 +0000 (09:28 +0200)]
libv4l2rds: handle V4L2_RDS_BLOCK_INVALID.

This possible block value was not understood by libv4l2rds.

This can happen if obsolete so-called 'E' blocks were received.
This should never happen in practice, but it is still good to
handle it, just in case.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: better handling of string controls with a step > 1
Hans Verkuil [Sat, 12 Jul 2014 00:28:56 +0000 (02:28 +0200)]
qv4l2: better handling of string controls with a step > 1

The strings will be filled-out to the end of the step size. That way the user
doesn't have to count spaces just to make sure the right string length is
returned.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: make tab labels more compact.
Hans Verkuil [Sat, 12 Jul 2014 00:14:58 +0000 (02:14 +0200)]
qv4l2: make tab labels more compact.

If you have lots of control classes, then the size of the tab bar gets
too big. The " Controls" suffix of the class name can easily be removed,
which actually improves the look and feel.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix coverity defect
Hans Verkuil [Fri, 11 Jul 2014 22:20:19 +0000 (00:20 +0200)]
qv4l2: fix coverity defect

** CID 1225222:  Array compared against 0  (NO_EFFECT)
/utils/qv4l2/ctrl-tab.cpp: 150 in ApplicationWindow::addTabs(int *)()

*** CID 1225222:  Array compared against 0  (NO_EFFECT)
/utils/qv4l2/ctrl-tab.cpp: 150 in ApplicationWindow::addTabs(int *)()
144      QVBoxLayout *vbox = new QVBoxLayout(t);
145      QWidget *w = new QWidget(t);
146
147      vbox->addWidget(w);
148
149      QGridLayout *grid = new QGridLayout(w);
>>>     CID 1225222:  Array compared against 0  (NO_EFFECT)
>>>     Comparing an array to null is not useful: "(char *)qctrl.name".
150      if((char *)qctrl.name) {
151      QLabel *title_tab = new QLabel((char *)qctrl.name, parentWidget());
152      QFont f = title_tab->font();
153      f.setBold(true);
154      title_tab->setFont(f);
155      grid->addWidget(title_tab, m_row, m_col, 1, m_cols, Qt::AlignLeft);

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibv4l2rds: fix date-time handling
Hans Verkuil [Fri, 11 Jul 2014 18:55:35 +0000 (20:55 +0200)]
libv4l2rds: fix date-time handling

The way the offset was handled was wrong: the fact that RDS specifies
the timezone offset in units of 30 minutes clearly was confusing.

Fixed the calculations.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: drop setSizeAdjustPolicy(QComboBox::AdjustToContents)
Hans Verkuil [Fri, 11 Jul 2014 13:41:36 +0000 (15:41 +0200)]
qv4l2: drop setSizeAdjustPolicy(QComboBox::AdjustToContents)

This made the combobox width just look weird. Only a few comboboxes had this
policy, all others used the default, so use that for all of them.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: reset size after changing aspect ratios or scaling mode
Hans Verkuil [Fri, 11 Jul 2014 13:36:50 +0000 (15:36 +0200)]
qv4l2: reset size after changing aspect ratios or scaling mode

When the video or pixel aspect ratio is changed by the user, or if
scaling is enabled/disabled, reset the window size to the optimal
size. This behavior is much more natural.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: refactor window size setting at capture start
Hans Verkuil [Fri, 11 Jul 2014 13:36:08 +0000 (15:36 +0200)]
qv4l2: refactor window size setting at capture start

- Renamed resize(), may conflict with inherited QWidget functions
- Clear separation between window size and frame size in setWindowSize()
- Use QSize and its methods where applicable
- Reset (window) size also refactored accordingly

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: refactor crop size calculation
Ove Brynestad [Thu, 10 Jul 2014 14:24:39 +0000 (16:24 +0200)]
qv4l2: refactor crop size calculation

Improve readability by using QSize members and operators for size calculations

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: refactor aspect size calculation
Ove Brynestad [Thu, 10 Jul 2014 12:40:53 +0000 (14:40 +0200)]
qv4l2: refactor aspect size calculation

Improve readability by using QSize members and operators for size calculations

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: refactored capwin variables
Ove Brynestad [Thu, 10 Jul 2014 07:21:10 +0000 (09:21 +0200)]
qv4l2: refactored capwin variables

Use QSize instead of int w,h; to store sizes
Name improvements
Move non-common variables back to renderer specific class

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: moved scaling calculations from setRenderFrame
Ove Brynestad [Tue, 8 Jul 2014 13:39:24 +0000 (15:39 +0200)]
qv4l2: moved scaling calculations from setRenderFrame

Ongoing work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: update common size variables at GL resize
Ove Brynestad [Tue, 8 Jul 2014 07:22:08 +0000 (09:22 +0200)]
qv4l2: update common size variables at GL resize

Ongoing work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: moved crop calculation out of GL renderer
Ove Brynestad [Mon, 7 Jul 2014 14:32:41 +0000 (16:32 +0200)]
qv4l2: moved crop calculation out of GL renderer

Ongoing work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: moved frame/rate count assignment to common class
Ove Brynestad [Mon, 7 Jul 2014 13:55:29 +0000 (15:55 +0200)]
qv4l2: moved frame/rate count assignment to common class

Ongoing work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: Made cropsize available to glengine
Ove Brynestad [Fri, 4 Jul 2014 14:35:09 +0000 (16:35 +0200)]
qv4l2: Made cropsize available to glengine

Ongoing work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: removed separate crop offset function
Ove Brynestad [Tue, 1 Jul 2014 10:11:29 +0000 (12:11 +0200)]
qv4l2: removed separate crop offset function

Ongoing work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: moved Qt scale/crop to common class
Ove Brynestad [Tue, 1 Jul 2014 10:11:29 +0000 (12:11 +0200)]
qv4l2: moved Qt scale/crop to common class

Ongoing work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: move setFrame out of renderer specific classes
Ove Brynestad [Tue, 1 Jul 2014 10:11:29 +0000 (12:11 +0200)]
qv4l2: move setFrame out of renderer specific classes

Ongoing work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: add and use storage for renderer independent frame info
Ove Brynestad [Mon, 30 Jun 2014 11:32:59 +0000 (13:32 +0200)]
qv4l2: add and use storage for renderer independent frame info

This starts work to move aspect/crop/scale calculations from individual render
classes to the common capture-win class. Currently different renderers use
slightly different code to calculate the various cropping/scaling/etc. data.
This makes it hard to maintain.

Signed-off-by: Ove Brynestad <ovebryne@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix square aspect ratio handling and improve Video Aspect Ratio
Hans Verkuil [Fri, 11 Jul 2014 12:52:40 +0000 (14:52 +0200)]
qv4l2: fix square aspect ratio handling and improve Video Aspect Ratio

Overriding the pixel aspect ratio to a square ratio never worked since
it was somehow missing in the switch statement.

The "4x3" video aspect ratio was moved from last to third position in
the Video Aspect Ratio list, before the widescreen formats. That is a
more logical place for it to be.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-compliance: fix various VBI tests.
Hans Verkuil [Fri, 11 Jul 2014 11:29:50 +0000 (13:29 +0200)]
v4l2-compliance: fix various VBI tests.

The VBI ioctls only make sense if the current input is a SDTV input (CAP_STD).
So skip any VBI related tests if the current input is not an SDTV input.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix height calculation when overriding pixel aspect ratio
Hans Verkuil [Fri, 11 Jul 2014 10:58:27 +0000 (12:58 +0200)]
qv4l2: fix height calculation when overriding pixel aspect ratio

When you override the pixel aspect ratio you still need to call
g_pixel_aspect to get the correct w and h values. Otherwise the
correction for top/bottom/alternate fields will go wrong.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: added titles and moved settings
Anton Arbring [Fri, 11 Jul 2014 07:51:16 +0000 (09:51 +0200)]
qv4l2: added titles and moved settings

Sorting related settings by type and adding titles for
explanation and structure.

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: alignment and size mods
Anton Arbring [Wed, 9 Jul 2014 08:31:03 +0000 (10:31 +0200)]
qv4l2: alignment and size mods

To get a more structured and professional look, everything is
left aligned. All buttons, line edits etc. gets a fixed minimum
width and expand stepwise. The window minimum size is set
accordingly.

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: hiding disabled GUI items
Anton Arbring [Thu, 10 Jul 2014 14:51:53 +0000 (16:51 +0200)]
qv4l2: hiding disabled GUI items

To make the GUI less cluttered, the input settings are shown only
if they match the current input field. A new function called updateGUI()
is called every time the input changes and shows the settings accordingly.

Signed-off-by: Anton Arbring <aarbring@cisco.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix sliced vbi support
Hans Verkuil [Thu, 10 Jul 2014 08:01:43 +0000 (10:01 +0200)]
qv4l2: fix sliced vbi support

A spurious updatePixelAspectRatio() call broke the sliced VBI capture support.
There were also a few missing checks that caused sliced VBI capture to
attempt to access the capture window, but for sliced VBI there is no capture
window.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix broken handling of V4L2_VBI_INTERLACED.
Hans Verkuil [Wed, 9 Jul 2014 21:05:13 +0000 (23:05 +0200)]
qv4l2: fix broken handling of V4L2_VBI_INTERLACED.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoRevert "qv4l2: hiding disabled GUI items"
Hans Verkuil [Tue, 8 Jul 2014 21:34:15 +0000 (23:34 +0200)]
Revert "qv4l2: hiding disabled GUI items"

This reverts commit e61dfa54b1b7212e7911ae140bb370d13f361991.

10 years agoRevert "qv4l2: alignment and size mods"
Hans Verkuil [Tue, 8 Jul 2014 21:34:13 +0000 (23:34 +0200)]
Revert "qv4l2: alignment and size mods"

This reverts commit 59fae23b008f4f12a655f35cecdb1248412524a7.

10 years agoRevert "qv4l2: added titles and moved settings"
Hans Verkuil [Tue, 8 Jul 2014 21:33:55 +0000 (23:33 +0200)]
Revert "qv4l2: added titles and moved settings"

This reverts commit 5d216dd34a194bb19481818c5496f4517822f150.

10 years agov4l2-ctl: missing support for continuous frameintervals.
Hans Verkuil [Tue, 8 Jul 2014 21:28:57 +0000 (23:28 +0200)]
v4l2-ctl: missing support for continuous frameintervals.

If VIDIOC_ENUM_FRAMEINTERVALS returns a continuous interval, then v4l2-ctl
wouldn't print the results at all.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: added titles and moved settings
Anton Arbring [Tue, 8 Jul 2014 12:20:08 +0000 (14:20 +0200)]
qv4l2: added titles and moved settings

Sorting related settings by type and adding titles for
explanation and structure.

Signed-off-by: Anton Arbring <aarbring@cisco.com>
10 years agoqv4l2: alignment and size mods
Anton Arbring [Tue, 8 Jul 2014 13:00:29 +0000 (15:00 +0200)]
qv4l2: alignment and size mods

To get a more structured and professional look, everything is
left aligned. All buttons, line edits etc. gets a fixed minimum
width and expand stepwise. The window minimum size is set
accordingly.

Signed-off-by: Anton Arbring <aarbring@cisco.com>
10 years agoqv4l2: hiding disabled GUI items
Anton Arbring [Mon, 7 Jul 2014 14:22:52 +0000 (16:22 +0200)]
qv4l2: hiding disabled GUI items

To make the GUI less cluttered, the input settings are shown only
if they match the current input field. A new function called updateGUI()
is called every time the input changes and shows the settings accordingly.

Signed-off-by: Anton Arbring <aarbring@cisco.com>
10 years agoqv4l2: fix a bug in vidFieldChanged
Hans Verkuil [Tue, 8 Jul 2014 09:19:10 +0000 (11:19 +0200)]
qv4l2: fix a bug in vidFieldChanged

updateVidFormat should be called, not updateVidCapFormat. This method
can be called for both capture and output devices.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-ctl: add support for generating limited range RGB
Hans Verkuil [Tue, 8 Jul 2014 07:39:11 +0000 (09:39 +0200)]
v4l2-ctl: add support for generating limited range RGB

The test pattern generator also supports limited range RGB. Add
an option to select this.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-ctl: the alpha flags are mutually exclusive.
Hans Verkuil [Tue, 8 Jul 2014 07:41:23 +0000 (09:41 +0200)]
v4l2-ctl: the alpha flags are mutually exclusive.

The alpha flags for a framebuffer are mutually exclusive. Implement
this in v4l2-ctl-overlay.cpp.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-ctl: add missing source chromakey support.
Hans Verkuil [Tue, 8 Jul 2014 06:56:30 +0000 (08:56 +0200)]
v4l2-ctl: add missing source chromakey support.

Standard chromakey handling was implemented, but the source-chromakey
implementation was missing.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agov4l2-ctl: vastly improve the test pattern generator.
Hans Verkuil [Mon, 7 Jul 2014 19:04:27 +0000 (21:04 +0200)]
v4l2-ctl: vastly improve the test pattern generator.

Replace the simplistic test pattern generator by a much improved
version that supports many more test patterns, support colorspace
conversions and a host of other features.

This code is based on the test pattern generator of the upcoming
vivi rewrite and excepts for some small changes in vivi-tpg.h the
code is identical to that driver. In the future the sync-with-kernel
make target of v4l-utils will just copy the code from the kernel,
making the kernel vivi driver the master copy.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: improve pixel aspect detection
Hans Verkuil [Mon, 7 Jul 2014 18:59:27 +0000 (20:59 +0200)]
qv4l2: improve pixel aspect detection

If CROPCAP is not supported, then try g_std. If that's not supported,
then try g_dv_timings. If all else failed, then just return a square
pixel aspect ratio.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: improve video output support, esp. multiplanar.
Hans Verkuil [Mon, 7 Jul 2014 18:30:46 +0000 (20:30 +0200)]
qv4l2: improve video output support, esp. multiplanar.

There was rudimentary video output support in qv4l2, at least sufficient
to use it to change things like the format.

But this didn't work if the video output driver used the multiplanar API.
Improved qv4l2 to support this.

Note that qv4l2 assumes that you either have video capture or video output.
Memory-to-memory devices are not currently supported.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: get rid of unused v4l2 class methods.
Hans Verkuil [Mon, 7 Jul 2014 18:25:21 +0000 (20:25 +0200)]
qv4l2: get rid of unused v4l2 class methods.

Clean up in preparation of improving video output support in qv4l2.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix enabling/disable frame width/height/size
Hans Verkuil [Mon, 7 Jul 2014 12:22:10 +0000 (14:22 +0200)]
qv4l2: fix enabling/disable frame width/height/size

The logic that dealt with when the frame width, height and size
fields had to be enabled and disabled was flawed. Starting and
stopping streaming would just enable all those field unconditionally,
and updating the format state could enable them while streaming.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: zero initial buffers
Hans Verkuil [Mon, 7 Jul 2014 11:51:53 +0000 (13:51 +0200)]
qv4l2: zero initial buffers

If the initial compose rectangle doesn't cover the full buffer,
then there will be a lot of garbage in the buffer if it isn't
zeroed.

Changing the compose rectangle while streaming will correctly
clear buffers as well, it was just this initial setup that caused
problems.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix incorrect disabling of the blending mode
Hans Verkuil [Mon, 7 Jul 2014 09:51:14 +0000 (11:51 +0200)]
qv4l2: fix incorrect disabling of the blending mode

When the blending mode was disabled, the blending function
wasn't turned off. Reworked the code to fix this and to make
the glBlendFunc call sequence easier to follow.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibv4l-mplane: fix compile warning
Hans Verkuil [Mon, 7 Jul 2014 08:17:04 +0000 (10:17 +0200)]
libv4l-mplane: fix compile warning

libv4l-mplane.c:356:24: warning: unused variable 'plugin' [-Wunused-variable]

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibv4l-mplane: v4l2-compliance fixes
Hans Verkuil [Sun, 6 Jul 2014 21:59:52 +0000 (23:59 +0200)]
libv4l-mplane: v4l2-compliance fixes

Fixed a variety of issues with this plugin. Found by running
v4l2-compliance -w with my multiplanar-enabled vivi driver.

- v4l2_pix_format's priv field wasn't zeroed.
- attempts to use the multiplanar buf types should return an error
  since they are disabled in the querycap capabilities.
- implement read() and write(): let the driver decide what to do with
  them.
- don't convert the buf type for the cropping ioctls. Just like the
  selection ioctls these shouldn't be converted.
- the memory field of v4l2_buffer should be copied back.
- errno was set to a negative value in at least one place.
- the create_bufs_ioctl() implementation was completely wrong.
- the querycap code didn't convert the device_caps field.

There are still a few issues left, but those come from the libv4l2
library, not from this plugin.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agolibv4l-mplane: copy back v4l2_buffer.m, fix type problems
Hans Verkuil [Sun, 6 Jul 2014 21:01:06 +0000 (23:01 +0200)]
libv4l-mplane: copy back v4l2_buffer.m, fix type problems

The ioctls operating on v4l2_buffer structs should copy back the
v4l2_plane.m to v4l2_buffer.m. Applications (like qv4l2) rely on
VIDIOC_QUERYBUF to return the correct m.offset, etc.

The format ioctls and create_bufs would call the ioctl directly
if the buffer type wasn't one of VIDEO_CAPTURE or VIDEO_OUTPUT.
However, it used the local zeroed format/v4l2_create_buffers
struct instead of the real struct. This is now fixed.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: make the destination sizeimage large enough
Hans Verkuil [Sun, 6 Jul 2014 20:57:04 +0000 (22:57 +0200)]
qv4l2: make the destination sizeimage large enough

Normally v4lconvert_try_format() will make sure that sizeimage is
large enough by calling try_fmt(). But if the multiplanar plugin is
in use, then v4lconvert_try_format() bypasses that plugin and try_fmt()
will fail since the driver expects the _MPLANE buffer types.

Normal programs won't use this function, so it won't be a problem there.
But in our case the solution is fairly simple: just calculate sizeimage
ourselves.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: remove two forgotten debug printfs
Hans Verkuil [Sun, 6 Jul 2014 20:09:33 +0000 (22:09 +0200)]
qv4l2: remove two forgotten debug printfs

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: implement SEQ_TB/BT support for the openGL renderer
Hans Verkuil [Sun, 6 Jul 2014 19:48:56 +0000 (21:48 +0200)]
qv4l2: implement SEQ_TB/BT support for the openGL renderer

Add openGL support for frames captured using the V4L2_FIELD_SEQ_TB/BT
field setting. This was the only field type that wasn't yet supported.

The software renderer still doesn't support it, only openGL does.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: add support for crop and compose
Hans Verkuil [Sun, 6 Jul 2014 13:36:05 +0000 (15:36 +0200)]
qv4l2: add support for crop and compose

Implement GUI support to set the crop and compose rectangles if that
is supported by the driver.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
10 years agoqv4l2: fix pixel aspect handling and set compose rectangle
Hans Verkuil [Sat, 5 Jul 2014 21:21:07 +0000 (23:21 +0200)]
qv4l2: fix pixel aspect handling and set compose rectangle

The pixel aspect ratio handling did not take scaling into account.

When changing the format the compose rectangle should be set to the
same size as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>