Smatch reports a warning:
drivers/media/usb/tm6000/tm6000-video.c:646 tm6000_prepare_isoc() error: we previously assumed 'dev->urb_buffer' could be null (see line 624)
This is not really a problem, but it actually shows that the check
if urb_buffer is NULL is being done twice: at the if and at
tm6000_alloc_urb_buffers().
We don't need to do it twice. So, remove the extra check. The code
become cleaner, and, as a collateral effect, smatch becomes happy.
Smatch currently produces two warnings:
drivers/media/pci/ivtv/ivtv-fileops.c:901 ivtv_v4l2_close() warn: suspicious bitop condition
drivers/media/pci/ivtv/ivtv-fileops.c:1026 ivtv_open() warn: suspicious bitop condition
Those are false positives, but it is not hard to get rid of them by
using a different way to evaluate the macro, splitting the logical
boolean evaluation from the bitmap one.
As reported by smatch:
drivers/media/pci/bt8xx/dst_ca.c:323 ca_get_message() warn: this array is probably non-NULL. 'p_ca_message->msg'
drivers/media/pci/bt8xx/dst_ca.c:498 ca_send_message() warn: this array is probably non-NULL. 'p_ca_message->msg'
Those two checks are needless/useless, as the ca_msg struct is
declared as:
typedef struct ca_msg {
unsigned int index;
unsigned int type;
unsigned int length;
unsigned char msg[256];
} ca_msg_t;
So, if the p_ca_message pointer is not null, msg will also be
not null.
It seems that there's actually a bug here: the same var (idx) is used
as an index for vertical and horizontal scaling arrays. However,
there are 4 elements on the h arrays, and only 3 at the v ones.
On the first loop, it may select index 4 for the horizontal array.
In this case, if the second loop fails to select an index, the
code would keep using 4 for the vertical array, with is past of
the array sizes.
The intent here seems to use index 0, if the scale is not found.
[media] vivid: don't use more than 1024 bytes of stack
Remove the following compilation warnings:
drivers/media/platform/vivid/vivid-tpg.c: In function 'tpg_gen_text':
drivers/media/platform/vivid/vivid-tpg.c:1562:1: warning: the frame size of 1308 bytes is larger than 1024 bytes [-Wframe-larger-than=]
}
^
This seems to be due to some bad optimization done by gcc.
Moving the for() loop to happen inside the macro solves the
issue.
While here, fix CodingStyle at the switch().
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Marek Szyprowski [Thu, 28 May 2015 11:11:47 +0000 (08:11 -0300)]
[media] media: s5p-mfc: fix sparse warnings
Commits a0f10c131cc49d7d84394beb7903e1f246331224 and 6c9fe765360efa97c63b89af685b620baf5e0012 ("media: s5p-mfc: fix broken
pointer cast on 64bit arch") fixed issue with lossy cast on 64-bit
architectures. However it also removed __iomem attribute from that cast.
This leads to sparse warnings. This patch fixes those warnings by adding
__iomem cast in case of v6+ code version and replacing readl/writel by
simple u32 load/store operations in case of v5 code (which is called on
system memory allocated by dma_alloc_coherent() instead of io registers).
Reported-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Lad, Prabhakar [Mon, 25 May 2015 15:34:27 +0000 (12:34 -0300)]
[media] media: davinci_vpfe: clear the output_specs
clear of the output_specs before passing it to the
configure_resizer_out_params(), so that no garbage values
are set.
This fixes following build warning:
drivers/staging/media/davinci_vpfe/dm365_resizer.c: In function 'resizer_set_stream':
drivers/staging/media/davinci_vpfe/dm365_resizer.c:190:46: warning: 'output_specs.vst_c'
may be used uninitialized in this function [-Wmaybe-uninitialized]
param->ext_mem_param[index].rsz_sdr_ptr_s_c = output->vst_c;
^
drivers/staging/media/davinci_vpfe/dm365_resizer.c:316:30: note: 'output_specs.vst_c' was declared here
struct vpfe_rsz_output_spec output_specs;
^
Antti Palosaari [Fri, 29 May 2015 19:42:33 +0000 (16:42 -0300)]
[media] si2168: Implement own I2C adapter locking
We need own I2C locking because of tuner I2C adapter/repeater.
Firmware command is executed using I2C send + reply message. Default
I2C adapter locking protects only single I2C operation, not whole
send + reply sequence as needed. Due to that, it was possible tuner
I2C message interrupts firmware command sequence.
Reported-by: Adam Baker <linux@baker-net.org.uk> Signed-off-by: Antti Palosaari <crope@iki.fi> Reviewed-by: Adam Baker <linux@baker-net.org.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
The changeset dc9ef7d11207 change the open() ioctl documentation to
match the V4L2 open(). However, some cut-and-pasted stuff doesn't
match what actually happens at the DVB core.
So, fix the documentation entry to be more accurate with the DVB
frontend open() specifics.
Laurent Pinchart [Sun, 24 May 2015 22:45:38 +0000 (19:45 -0300)]
[media] uvcvideo: Remove unneeded device disconnected flag
The UVC_DEV_DISCONNECTED flag is set when the USB device is
disconnected, and checked in the open() handler to refuse opening a
device that has been disconnected.
This is inherently racy, but the race condition is taken care of in the
V4L2 core, which also fails open() calls when the V4L2 device node has
been unregistered. As the uvcvideo USB disconnect handler unregisters
all its video device nodes, the UVC_DEV_DISCONNECTED flag doesn't serve
any purpose anymore and can be removed.
Laurent Pinchart [Tue, 12 May 2015 21:57:53 +0000 (18:57 -0300)]
[media] uvcvideo: Fix incorrect bandwidth with Chicony device 04f2:b50b
The "TOSHIBA Web Camera - 5M" Chicony device (04f2:b50b) seems to
compute the bandwidth on 16 bits and erroneously sign-extend it to
32 bits, resulting in a huge bandwidth value. Detect and fix that
condition by setting the 16 MSBs to 0 when they're all equal to 1.
Reported-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Thu, 16 Apr 2015 23:04:55 +0000 (20:04 -0300)]
[media] m88ds3103: add I2C client binding
Implement I2C client device binding.
Wrap media attach to driver I2C probe.
Add wrapper from m88ds3103_attach() to m88ds3103_probe() via driver
core in order to provide proper I2C client for legacy media attach
binding.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Tue, 14 Apr 2015 00:00:09 +0000 (21:00 -0300)]
[media] m88ds3103: do not return error from get_frontend() when not ready
Do not return error from get_frontend() when status is queried, but
the frontend didn't lock yet. The proper behavior is to only update the
cache after having a lock.
[mchehab@osg.samsung.com: fix the patch description] Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] gspca: sn9c2028: Add gain and autogain controls Genius Videocam Live v2
Autogain algorithm is very simple, if average luminance is low - increase gain,
if it's high - decrease gain. Gain granularity is low enough for this algo to
stabilize quickly.
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] gspca: sn9c2028: Add support for Genius Videocam Live v2
This cam seems to return different values on long commands, so make status check
in sn9c2028_long_command() more tolerant. Anyway, read value isn't used anywhere
later.
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] wl128x: Allow compile test of GPIO consumers if !GPIOLIB
The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is
not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer
functionality only, can still be compiled if GPIOLIB is not enabled.
Relax the dependency on GPIOLIB if COMPILE_TEST is enabled, where
appropriate.
Florian Echtler [Mon, 25 May 2015 12:04:16 +0000 (09:04 -0300)]
[media] return BUF_STATE_ERROR if streaming stopped during acquisition
When stop_streaming is called while a frame is currently being retrieved, the
buffer being filled will still be returned with BUF_STATE_DONE. By resetting
the sequence number and checking before returning the buffer, it can now
correctly be returned with BUF_STATE_ERROR.
Signed-off-by: Martin Kaltenbrunner <modin@yuri.at> Signed-off-by: Florian Echtler <floe@butterbrot.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Florian Echtler [Mon, 25 May 2015 12:04:15 +0000 (09:04 -0300)]
[media] add extra debug output, remove noisy warning
Add dev_dbg statements for easier future debugging; also change the warning
about packet ID mismatches to debug output to avoid flooding the logs. This
warning is only important in a very specific/rare use case when trying to
correlate input events with video data.
Signed-off-by: Martin Kaltenbrunner <modin@yuri.at> Signed-off-by: Florian Echtler <floe@butterbrot.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Florian Echtler [Mon, 25 May 2015 12:04:14 +0000 (09:04 -0300)]
[media] add frame size/frame rate query functions
Add missing functions to query the single fixed frame size (960x540) and
supported frame rates. Technically, the SUR40 supports any arbitrary frame
rate up to 60 FPS, as it is polled and not interrupt-driven. For now, we
just report 30 and 60 FPS, which is sufficient to make most V4L2 tools work.
Signed-off-by: Martin Kaltenbrunner <modin@yuri.at> Signed-off-by: Florian Echtler <floe@butterbrot.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Florian Echtler [Mon, 25 May 2015 12:04:13 +0000 (09:04 -0300)]
[media] reduce poll interval to allow full 60 FPS framerate
The SUR40 hardware can deliver images at up to 60 FPS; at full USB2 bandwidth,
one raw frame will take about 11 ms to transmit. If the poll interval is above
5 ms, fully handling one frame will take longer than 16 ms and the overall
frame rate will drop below 60 FPS. To get the full frame rate without blocking
all the time and still allowing for a bit of timing jitter, we reduce the poll
interval to 4 ms.
Signed-off-by: Martin Kaltenbrunner <modin@yuri.at> Signed-off-by: Florian Echtler <floe@butterbrot.org> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Antti Palosaari [Sun, 17 May 2015 11:38:04 +0000 (08:38 -0300)]
[media] v4l2: correct two SDR format names
U8 and U16LE format human readable names were translated with string
containing emulated word. These strings were taken from msi2500 driver,
where those formats were emulated (after module parameter is set). But
on API correct names should be used, without any special case notes.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Fri, 15 May 2015 12:29:09 +0000 (09:29 -0300)]
[media] videodev2.h: add macros to map colorspace defaults
The mapping of COLORSPACE_DEFAULT, YCBCR_ENC_DEFAULT or QUANTIZATION_DEFAULT
to proper non-default values is fairly complex, and it is something that
needs to be done both in the kernel and in userspace.
So add macros that can do this conversion, making this available to both
kernel and userspace.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Fri, 15 May 2015 12:29:05 +0000 (09:29 -0300)]
[media] videodev2.h: add COLORSPACE_DEFAULT
V4L2_COLORSPACE_DEFAULT is added so we have a specific define for
the default case where applications do not set it but leave it to 0.
In that case the driver will set the colorspace based on what it
captures.
This is already used, but we never had a define for the value 0.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Mon, 18 May 2015 13:29:17 +0000 (10:29 -0300)]
[media] ivtv: fix incorrect audio mode report in log_status
The log_status ioctl should report if the audio input has mode Bilingual. However, the
check against the itv->dualwatch_stereo_mode is completely wrong and is a left-over from
the distant past. Not only is the bitmask obviously wrong, the test itself is broken too
since itv->dualwatch_stereo_mode is no longer a bitmask at all.
Fix this code properly.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] media/videobuf2-dma-vmalloc: Save output from dma_map_sg
dma_map_sg returns the number of areas mapped by the hardware,
which could be different than the areas given as an input.
The output must be saved to nent.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] media/videobuf2-dma-contig: Save output from dma_map_sg
dma_map_sg returns the number of areas mapped by the hardware,
which could be different than the areas given as an input.
The output must be saved to nent.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] media/videobuf2-dma-sg: Fix handling of sg_table structure
When sg_alloc_table_from_pages() does not fail it returns a sg_table
structure with nents and nents_orig initialized to the same value.
dma_map_sg returns the number of areas mapped by the hardware,
which could be different than the areas given as an input.
The output must be saved to nent.
The output of dma_map, should be used to transverse the scatter list.
dma_unmap_sg needs the value passed to dma_map_sg (nents_orig).
sg_free_tables uses also orig_nent.
This patch fix the file to follow this paradigm.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Fri, 22 May 2015 08:30:02 +0000 (05:30 -0300)]
[media] cobalt: fix sparse warnings
drivers/media/pci/cobalt/cobalt-flash.c:101:5: warning: symbol 'cobalt_flash_probe' was not declared. Should it be static?
drivers/media/pci/cobalt/cobalt-flash.c:126:6: warning: symbol 'cobalt_flash_remove' was not declared. Should it be static?
drivers/media/pci/cobalt/cobalt-cpld.c:101:6: warning: symbol 'cobalt_cpld_status' was not declared. Should it be static?
drivers/media/pci/cobalt/cobalt-cpld.c:240:6: warning: symbol 'cobalt_cpld_set_freq' was not declared. Should it be static?
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Fri, 22 May 2015 08:31:46 +0000 (05:31 -0300)]
[media] cobalt: fix sparse warnings
drivers/media/pci/cobalt/cobalt-flash.c:39:36: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/cobalt/cobalt-flash.c:54:36: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/cobalt/cobalt-flash.c:63:36: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/cobalt/cobalt-flash.c:82:36: warning: incorrect type in initializer (different address spaces)
drivers/media/pci/cobalt/cobalt-flash.c:107:19: warning: incorrect type in assignment (different address spaces)
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Fri, 22 May 2015 07:37:27 +0000 (04:37 -0300)]
[media] cobalt: fix compiler warnings on 32 bit OSes
Fixes these warnings:
drivers/media/pci/cobalt/cobalt-omnitek.c: In function 'omni_sg_dma_start':
drivers/media/pci/cobalt/cobalt-omnitek.c:112:28: warning: right shift count >= width of type [-Wshift-count-overflow]
iowrite32((u32)(desc->bus >> 32), DESCRIPTOR(s->dma_channel) + 4);
^
drivers/media/pci/cobalt/cobalt-omnitek.c: In function 'descriptor_list_create':
drivers/media/pci/cobalt/cobalt-omnitek.c:222:28: warning: right shift count >= width of type [-Wshift-count-overflow]
d->next_h = (u32)(next >> 32);
^
drivers/media/pci/cobalt/cobalt-omnitek.c:268:32: warning: right shift count >= width of type [-Wshift-count-overflow]
d->next_h = (u32)(desc->bus >> 32);
^
drivers/media/pci/cobalt/cobalt-omnitek.c:275:27: warning: right shift count >= width of type [-Wshift-count-overflow]
d->next_h = (u32)(next >> 32);
^
drivers/media/pci/cobalt/cobalt-omnitek.c: In function 'descriptor_list_chain':
drivers/media/pci/cobalt/cobalt-omnitek.c:293:31: warning: right shift count >= width of type [-Wshift-count-overflow]
d->next_h = (u32)(next->bus >> 32);
^
drivers/media/pci/cobalt/cobalt-omnitek.c: In function 'descriptor_list_loopback':
drivers/media/pci/cobalt/cobalt-omnitek.c:332:30: warning: right shift count >= width of type [-Wshift-count-overflow]
d->next_h = (u32)(desc->bus >> 32);
^
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Thu, 21 May 2015 09:19:28 +0000 (06:19 -0300)]
[media] cobalt: fix irqs used for the adv7511 transmitter
The interrupt bit assignments use for the adv7511 were off by one.
This means that the current scheme (bit << (4 * stream_index)) can
no longer be used.
Fix this by precalculating and storing the correct masks in the
cobalt_stream struct.
This wasn't noticed before because the adv7511 interrupts are very
rare. But for CEC support these interrupts are essential, so this made
me realize that it wasn't working correctly.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] DocBook: Update DocBook version and fix a few legacy things
The DVB part of the media API documentation has several
legacy things on it:
- Examples that don't work;
- APIs unused and deprecated;
- places mentioning the wrong API version.
Fix them and bump the documentation version, in order to
reflect the cleanup efforts to make it more consistent with
the current status of the API.
[media] DocBook: cleaup the notes about DTV properties
The notes there are somewhat confusing and assumes that the
reader would have read the DVBv3 way. This is not true anymore,
as the DVBv3 is now on a separate section that is marked as
deprecated.
So, cleanup the notes.
While here, add a note about using libdvbv5, instead of using
the DVBv5 API directly.
[media] DocBook: Add an example for using FE_SET_PROPERTY
In order to make it clearer about how to use the DVBv5 calls,
add an example of its usage. That should make it clearer about
what's actually required for the DVBv5 calls to work.
[media] DocBook: cross-reference enum fe_modulation where needed
At frontend legacy API description, there are three places
where fe_modulation_t is defined. Cross-reference it to point
to the right place at the documentation.
[media] DocBook: add a proper description for dvb_frontend_info.fe_type
The fe_type is deprecated at the DVB API. However, it may still
be used by legacy DVBv3 applications. While this works with old
devices, modern devices may support more than one delivery
system.
Add an explanation about that and a point to what should be
used, instead, in order for legacy apps to support newer hardware.
What's written there about the arguments for this ioctl
is bogus: it doesn't return an enum (or a typedef)
for enum fe_status. Instead, it returns a bitmask with the
values defined by enum fe_status.
Also, the size of the integer returned is not 16 bits, but,
instead, sizeof(fe_status_t), e. g. sizeof(enum), with is
arch-dependent.
This should of course be fixed, but this should be done on
a separate patch.
[media] DocBook: better organize the function descriptions for frontend
Move the function ioctl definitions to the end of the chapter,
at their importance. That makes the document better organized,
as the DVB frontend system call index will look like:
open()
close()
ioctl FE_GET_INFO — Query DVB frontend capabilities and returns information about the front-end. This call only requires read-only access to the device
ioctl FE_READ_STATUS — Returns status information about the front-end. This call only requires read-only access to the device
ioctl FE_SET_PROPERTY, FE_GET_PROPERTY — FE_SET_PROPERTY sets one or more frontend properties. FE_GET_PROPERTY returns one or more frontend properties.
ioctl FE_DISEQC_RESET_OVERLOAD — Restores the power to the antenna subsystem, if it was powered off due to power overload.
ioctl FE_DISEQC_SEND_MASTER_CMD — Sends a DiSEqC command
ioctl FE_DISEQC_RECV_SLAVE_REPLY — Receives reply from a DiSEqC 2.0 command
ioctl FE_DISEQC_SEND_BURST — Sends a 22KHz tone burst for 2x1 mini DiSEqC satellite selection.
ioctl FE_SET_TONE — Sets/resets the generation of the continuous 22kHz tone.
ioctl FE_SET_VOLTAGE — Allow setting the DC level sent to the antenna subsystem.
ioctl FE_ENABLE_HIGH_LNB_VOLTAGE — Select output DC level between normal LNBf voltages or higher LNBf voltages.
ioctl FE_SET_FRONTEND_TUNE_MODE — Allow setting tuner mode flags to the frontend.
Use the proper format for FE_SET_VOLTAGE documentation and fix
the documentation. The description for the enum is not 100%,
and it is missing the voltage off value.
Also, it is better to keep the enum description together with
the ioctl, as both are used together.
[media] DocBook: move FE_GET_PROPERTY to its own xml file
That helps the xref logic at the Makefile to point to the
right place. Also, it becomes more organized and easier to
maintain if each ioctl have its own xml file.
[media] DocBook: Improve xref check for undocumented ioctls
There are several badly documented undocumented ioctls.
Currently, it just generates an empty link. Instead of doing that,
only add references to the ones that exists, and add a warning
for all references that weren't found.