Import the media-ctl utility and libraries

This corresponds to commit 114c1b274edc40e07e9b99a435d26438f5b99943
("Fix uninitialized pointer dereference in media_device_add_entity") in
the git://git.ideasonboard.org/media-ctl.git repository.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media-ctl: Rename source files

Prefix the library files with lib and rename main.c to media-ctl.c.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media-ctl: Remove the obsolete device argument from the help text

The standalone device argument isn't supported anymore, remove it from
the documentation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media-ctl: Document the --links option argument

The --links option take a mandatory argument. Document it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media-ctl: Always print the full help message

The short help text isn't descriptive enough to be useful.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media-ctl: Don't install libmediactl and libv4l2subdev

The libraries APIs are not deemed to be stable yet, don't install the
libraries. We must thus compile the two libraries statically to link
media-ctl accordingly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media-ctl: Update copyright years

We're well into 2014 and there no going back.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Add missing v4l2-mediabus.h

This header should also be copied when syncing with the kernel.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Synced with latest kernel

This adds the missing v4l2-mediabus.h header.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
qv4l2: fix segmentation fault when compiled without ALSA support.

If opening the video device fails, then qv4l2 attempts to disable
two alsa widgets. If qv4l2 was compiled without alsa support, then
those widget pointers are NULL and you get a segfault.

Add the proper #ifdef so this is only done if alsa support was
compiled in.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
media-ctl: Fix off-by-one buffer overflow with readlink

readlink() returns the number of bytes written to the buffer, which can
be up to the passed buffer size, without including the terminating '\0'.
This causes an off-by-one overflow as we pass the total buffer length to
the function and then try to append a terminating '\0'.

Fix it by passing the buffer size minus one to readlink().

Reported-by: Coverity Scan
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media-ctl: Fix media device version printing

Extract the version major, minor and patch level version components by
shifting right, not left.

Reported-by: Coverity Scan
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
media-ctl: Add fall through comment to fix Coverity warning

The -f case falls through the -V case during option parsing. This is
desired but result in a missing break statement warning from Coverity.
Fix it by adding a fall through comment.

Reported-by: Coverity Scan
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>