Hans Verkuil [Mon, 9 Mar 2015 20:04:12 +0000 (17:04 -0300)]
[media] ov7670: use colorspace SRGB instead of JPEG
Even though the format is Y'CbCr, the colorspace used by the sensor
is almost certainly SRGB. The sensor is also not generating JPEG data,
so it makes no sense to use V4L2_COLORSPACE_JPEG here.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Thu, 5 Mar 2015 20:33:17 +0000 (17:33 -0300)]
[media] marvell-ccic: use vb2 helpers and core locking
Use the V4L2 core locking system instead of rolling your own. Switch to
the vb2 fop and ioctl helpers to get rid of a lot of code. This also made
it easy to add VB2_READ to the DMA modes, since you get read() for free
with vb2 and these helpers.
Finally remove the users field: this information is also available from
the core framework, no need to keep track of it in the driver.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Thu, 5 Mar 2015 15:00:11 +0000 (12:00 -0300)]
[media] marvell-ccic: control handler fixes
No controls were reported, even though the ov7670 does have controls.
Two reasons for this: the v4l2_ctrl_handler_init() call must come
before the ov7670 is loaded (otherwise the ov7670 won't know that
its controls should be added to the bridge driver), and the
v4l2_ctrl_handler_free() call at the end should only be called if
the ret value is non-zero (otherwise you would just free all the
controls that were just added).
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Added the necessary capabilities to stop this warning.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reported-by: Laura Abbott <labbott@redhat.com> Cc: <stable@vger.kernel.org> # for v3.19 and up Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Hans Verkuil [Fri, 27 Mar 2015 18:17:56 +0000 (15:17 -0300)]
[media] saa7164: fix querycap warning
Fix the VIDIOC_QUERYCAP warning due to the missing device_caps. Don't fill
in the version field, the V4L2 core will do that for you.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: <stable@vger.kernel.org> # for v3.19 and up Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Steven Toth [Sat, 28 Mar 2015 12:07:47 +0000 (09:07 -0300)]
[media] saa7164: fix HVR2255 ATSC inversion issue
QAM mode in the LGDT3306 auto detects inversion. VSB does not.
Forgot to include tis fact in the original patch set.
Tested with QAM and VSB after this patch, working fine.
Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Steven Toth [Mon, 23 Mar 2015 18:45:48 +0000 (15:45 -0300)]
[media] saa7164: Add Digital TV support for the HVR2255 and HVR2205
Adding support for the Hauppauge HVR2255 and Hauppauge HVR2205
PCIe cards. Digital TV for DVB-T and ATSC/US-Cable is known to
work. Support for analog RF tuners does not work due to
a lack of analog support in the upstream SI2157 driver.
Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Jan Kara [Tue, 17 Mar 2015 11:56:31 +0000 (08:56 -0300)]
[media] vb2: Push mmap_sem down to memops
Currently vb2 core acquires mmap_sem just around call to
__qbuf_userptr(). However since commit f035eb4e976ef5 (videobuf2: fix
lockdep warning) it isn't necessary to acquire it so early as we no
longer have to drop queue mutex before acquiring mmap_sem. So push
acquisition of mmap_sem down into .get_userptr and .put_userptr memops
so that the semaphore is acquired for a shorter time and it is clearer
what it is needed for.
Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] v4l2-dv-timings: fix rounding in hblank and hsync calculation
Changed the rounding calculation for hblank and hsync to match it
to equations in cvt and gtf standards.
In cvt calculation, hsync needs to be rounded down.
In gtf calculations, hblank needs to be rounded to nearest multiple
of twice the cell granularity and hsync needs to be rounded to the
nearest multiple of cell granularity.
Cc: Martin Bugge <marbugge@cisco.com> Signed-off-by: Prashant Laddha <prladdha@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
[media] v4l2-dv-timings: fix rounding error in vsync_bp calculation
Changed the rounding offsets used in vsync_bp calculation in cvt and
gtf timings. The results for vsync_bp should now match with results
from timing generator spreadsheets for cvt and gtf standards.
In the vsync_bp calculation for cvt, always round down the value of
(CVT_MIN_VSYNC_BP / h_period_est) and then add 1. It thus, reflects
the equation used in timing generator spreadsheet. Using 1999999 as
rounding offset, could pontentially lead to bumping up the vsync_bp
value by extra 1.
In the vsync_bp calculations for gtf, instead of round up or round
down, round the (CVT_MIN_VSYNC_BP / h_period_est) to the nearest
integer.
Thanks to Martin Bugge <marbugge@cisco.com> for validating with
standards and suggestions on equations.
Cc: Martin Bugge <marbugge@cisco.com> Signed-off-by: Prashant Laddha <prladdha@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
VIDEOBUF2_DMA_SG cannot be enabled manually by the user, it's always
selected automatically by drivers that need it. Several of those drivers
already have an explicit dependency on HAS_DMA.
Make VIDEOBUF2_DMA_SG depend on HAS_DMA. This makes it easier to find
drivers that select VIDEOBUF2_DMA_SG without depending on HAS_DMA, as
Kconfig will give a warning.
[media] v4l: xilinx: VIDEO_XILINX should depend on HAS_DMA
If NO_DMA=y:
warning: (VIDEO_XILINX && VIDEO_DM365_VPFE && VIDEO_DT3155 && VIDEO_OMAP4) selects VIDEOBUF2_DMA_CONTIG which has unmet direct dependencies (MEDIA_SUPPORT && HAS_DMA)
media/v4l2-core/videobuf2-dma-contig.c: In function ‘vb2_dc_mmap’:
media/v4l2-core/videobuf2-dma-contig.c:207: error: implicit declaration of function ‘dma_mmap_coherent’
media/v4l2-core/videobuf2-dma-contig.c: In function ‘vb2_dc_get_base_sgt’:
media/v4l2-core/videobuf2-dma-contig.c:390: error: implicit declaration of function ‘dma_get_sgtable’
VIDEO_XILINX selects VIDEOBUF2_DMA_CONTIG, which bypasses its dependency
on HAS_DMA. Make VIDEO_XILINX depend on HAS_DMA to fix this.
When using VIDIOC_G_EDID there is a special case where start_blocks and
blocks are both set to 0. In that case the driver just has to set blocks to
the total number of available blocks and return 0.
Even though the drivers do this right and v4l2-compliance tests for it, it
turned out not to be documented in the spec. Fix this.
[media] media: adv7604: Fix masks used for querying timings in ADV7611
All masks for timings are different between ADV7604 and ADV7611.
Most of the values have 1 precision bit more in the latter.
Fix this by adding new fields to the chip_info structure.
Hans Verkuil [Fri, 3 Apr 2015 10:22:40 +0000 (07:22 -0300)]
[media] cx88: v4l2-compliance fixes
Fix three v4l2-compliance failures:
- the colorspace wasn't set in vidioc_try_fmt_vid_cap().
- the field wasn't set in v4l2_buffer when vb2_buffer_done() was called.
- the sequence wasn't set in v4l2_buffer when vb2_buffer_done() was called.
This fix also removes the unused buf->count field and starts the count
at 0 instead of 1.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
v4l2-ioctl: add a missing break at v4l_fill_fmtdesc()
The changeset ba3002045f8022 added a logic at the core to fill
the format description, however, a break is missing on one of
the formats, as reported by smatch:
drivers/media/v4l2-core/v4l2-ioctl.c:1211 v4l_fill_fmtdesc() warn: missing break? reassigning 'descr'
as reported by smatch:
drivers/media/pci/bt8xx/bttv-audio-hook.c:201 lt9415_audio() warn: bitwise AND condition is false here
drivers/media/pci/bt8xx/bttv-audio-hook.c:241 winfast2000_audio() warn: bitwise AND condition is false here
drivers/media/pci/bt8xx/bttv-audio-hook.c:276 pvbt878p9b_audio() warn: bitwise AND condition is false here
drivers/media/pci/bt8xx/bttv-audio-hook.c:307 fv2000s_audio() warn: bitwise AND condition is false here
drivers/media/pci/bt8xx/bttv-audio-hook.c:334 windvr_audio() warn: bitwise AND condition is false here
drivers/media/pci/bt8xx/bttv-audio-hook.c:371 adtvk503_audio() warn: bitwise AND condition is false here
there are some serious issues at the audio hook implementation.
They're not following what's specified at the DocBook:
http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-tuner.html#tuner-audmode
Basically, it was assuming that the audmode (V4L2_TUNER_MODE_foo)
is a variable with a bit maskk. However, it isn't.
The bitmask only applies to rxsubchans field (V4L2_TUNER_SUB_foo).
As the code is also too complex, and not all hooks were returning
both audmode and rxsubchans to a VIDIOC_G_TUNER, rewrite the
functions, in order to fix both for get and set tuner ioctls.
[media] redrat3: change return argument on redrat3_send_cmd() to int
redrat3_send_cmd() can return an error or the read data. However,
it currently returns an u8, as reported by smatch:
drivers/media/rc/redrat3.c:416 redrat3_send_cmd() warn: signedness bug returning '(-12)'
The indentation on this driver were deadly broken. On lots
of places, it was using 4 spaces instead of tab to indent.
On other parts, it were using tabs.
Also, on several places, it were not even being properly aligned,
as reported by smatch:
drivers/media/dvb-frontends/dib0070.c:179 dib0070_set_bandwidth() warn: inconsistent indenting
drivers/media/dvb-frontends/dib0070.c:198 dib0070_captrim() warn: inconsistent indenting
drivers/media/dvb-frontends/dib0070.c:246 dib0070_set_ctrl_lo5() warn: inconsistent indenting
drivers/media/dvb-frontends/dib0070.c:260 dib0070_ctrl_agc_filter() warn: inconsistent indenting
drivers/media/dvb-frontends/dib0070.c:494 dib0070_tune_digital() warn: inconsistent indenting
drivers/media/dvb-frontends/dib0070.c:498 dib0070_tune_digital() warn: inconsistent indenting
drivers/media/dvb-frontends/dib0070.c:655 dib0070_reset() warn: inconsistent indenting
drivers/media/dvb-frontends/dib0070.c:711 dib0070_reset() warn: curly braces intended?
drivers/media/dvb-frontends/dib0070.c:713 dib0070_reset() warn: inconsistent indenting
My first idea were to leave it as-is or to just touch the above.
However, this won't be fixing anything. So, as painful as it
is, let's fix indentation globally on the driver, and then
address the inconsistencies.
Hopefully, this driver doesn't have much patches, so it likely
won't conflict to any other patch during this merge window.
Besides the big size of this patch, no functional changes
were done.
[media] ov7670: check read error also for REG_AECHH on ov7670_s_exp()
ov7670_s_exp() checks read error for 2 registers: REG_COM1
and REG_COM8. But, although it uses the value latter, it
doesn't check errors on REG_AECHH read. Yet, as it is doing
a bitmask operation there, the read operation should succeed.
So, fix the code to also check if this succeeded.
This fixes this smatch report:
drivers/media/i2c/ov7670.c:1366 ov7670_s_exp() warn: inconsistent indenting
[media] stv0297: change typecast to u64 to avoid smatch warnings
drivers/media/dvb-frontends/stv0297.c:140 stv0297_get_symbolrate() warn: should 'stv0297_readreg(state, 86) << 8' be a 64 bit type?
drivers/media/dvb-frontends/stv0297.c:141 stv0297_get_symbolrate() warn: should 'stv0297_readreg(state, 87) << 16' be a 64 bit type?
drivers/media/dvb-frontends/stv0297.c:142 stv0297_get_symbolrate() warn: should 'stv0297_readreg(state, 88) << 24' be a 64 bit type?
As reported by smatch:
drivers/media/tuners/qt1010.c:357 qt1010_init() error: buffer overflow 'i2c_data' 34 <= 34
This should not happen with the current code, as the i2c_data array
doesn't end with a QT1010_M1, but it doesn't hurt add a BUG_ON
to notify if one modifies it and breaks.
As reported by smatch:
drivers/media/usb/gspca/zc3xx.c:5994 transfer_update() info: ignoring unreachable code.
That happens because there's a return that it is never called,
as the work queue runs an infinite loop, except when the device is
put to sleep or an error happens.
When an error happens, a break statement is enough to go out of
the loop. So, let's remove the goto, as break is the typical
instruction used to end a loop.
[media] cx24117: fix a buffer overflow when checking userspace params
The maximum size for a DiSEqC command is 6, according to the
userspace API. However, the code allows to write up much more values:
drivers/media/dvb-frontends/cx24116.c:983 cx24116_send_diseqc_msg() error: buffer overflow 'd->msg' 6 <= 23
[media] cx24116: fix a buffer overflow when checking userspace params
The maximum size for a DiSEqC command is 6, according to the
userspace API. However, the code allows to write up much more values:
drivers/media/dvb-frontends/cx24116.c:983 cx24116_send_diseqc_msg() error: buffer overflow 'd->msg' 6 <= 23
[media] s5h1420: fix a buffer overflow when checking userspace params
The maximum size for a DiSEqC command is 6, according to the
userspace API. However, the code allows to write up to 7 values:
drivers/media/dvb-frontends/s5h1420.c:193 s5h1420_send_master_cmd() error: buffer overflow 'cmd->msg' 6 <= 7
The last one is actually due to a commented code. Let's rework
it, in order to remove the sparse warning without removing the
dead code, as it may be useful in the future.