Frank Schaefer [Sat, 5 Jan 2013 11:44:09 +0000 (08:44 -0300)]
[media] em28xx: fix audio input for TV mode of device Terratec Cinergy 250
Remy Blank reported that audio over USB can be made working for the television
input if .amux is changed from EM28XX_AMUX_LINE_IN to EM28XX_AMUX_VIDEO.
An examination of his devices shows, that it is indeed supplied with an EM202
AC97 audio IC. We also use this setting for the Cinergy 200.
Remy Blank also provided the original version of this patch (many thanks !).
Fixes bug 14126 (see bug report for further device details).
Jiri Slaby [Thu, 3 Jan 2013 15:53:53 +0000 (12:53 -0300)]
[media] dib0700: do not lock interruptible on tear-down paths
When mutex_lock_interruptible is used on paths where a signal can be
pending, the device is not closed properly and cannot be reused.
This usually happens when you start tzap for example and send it a
TERM signal. The signal is pending while tear-down routines are
called. Hence streaming is not properly stopped in that case. And
the device stops working from that moment on.
It has been over 3 years since the V4L2_CID_[HV]CENTER were deprecated.
Clean up the DocBook and remove the V4L2_CID_VCENTER_DEPRECATED,
V4L2_CID_VCENTER_DEPRECATED control related paragraphs.
Remove the V4L2_CID_[HV]CENTER controls definitions from v4l2-controls.h,
these controls are not used by any driver in the mainline now.
Kamil Debski [Thu, 3 Jan 2013 10:06:04 +0000 (07:06 -0300)]
[media] s5p-mfc: Change internal buffer allocation from vb2 ops to dma_alloc_coherent
Change internal buffer allocation from vb2 memory ops call to direct
calls of dma_alloc_coherent. This change shortens the code and makes it
much more readable.
Kamil Debski [Thu, 3 Jan 2013 14:02:07 +0000 (11:02 -0300)]
[media] s5p-mfc: Move firmware allocation point to avoid allocation problems
Move firmware allocation from open to probe to avoid problems
when using CMA for allocation. In certain circumstances CMA may allocate
buffer that is not in the beginning of the MFC memory area.
Sachin Kamat [Wed, 2 Jan 2013 09:45:49 +0000 (06:45 -0300)]
[media] s5p-mfc: Fix an error check
Checking unsigned variable for negative value always returns false.
Hence make this value signed as we expect it to be negative too.
Fixes the following smatch warning:
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c:572
s5p_mfc_set_enc_ref_buffer_v6() warn: unsigned 'buf_size1' is never
less than zero.
Sachin Kamat [Fri, 28 Dec 2012 09:18:27 +0000 (06:18 -0300)]
[media] s5p-mfc: Remove redundant 'break'
The code returns before this statement. Hence not required.
Silences the following smatch message:
drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c:525
s5p_mfc_set_dec_frame_buffer_v5() info: ignoring unreachable code.
Sachin Kamat [Mon, 26 Nov 2012 04:49:05 +0000 (01:49 -0300)]
[media] s5p-tv: Add missing braces around sizeof in hdmi_drv.c
Fixes the following checkpatch warnings:
WARNING: sizeof *fmt should be sizeof(*fmt)
WARNING: sizeof *res should be sizeof(*res)
WARNING: sizeof *res should be sizeof(*res)
WARNING: sizeof sd->name should be sizeof(sd->name)
Sachin Kamat [Mon, 26 Nov 2012 04:49:04 +0000 (01:49 -0300)]
[media] s5p-tv: Add missing braces around sizeof in hdmiphy_drv.c
Fixes the following checkpatch warning:
WARNING: sizeof *ctx should be sizeof(*ctx)
FILE: media/platform/s5p-tv/hdmiphy_drv.c:287:
ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
Sachin Kamat [Mon, 26 Nov 2012 04:49:02 +0000 (01:49 -0300)]
[media] s5p-tv: Add missing braces around sizeof in mixer_reg.c
Silences checkpatch warnings of the type:
WARNING: sizeof filter_y_horiz_tap8 should be sizeof(filter_y_horiz_tap8)
FILE: media/platform/s5p-tv/mixer_reg.c:473:
filter_y_horiz_tap8, sizeof filter_y_horiz_tap8);
Sachin Kamat [Mon, 26 Nov 2012 04:49:01 +0000 (01:49 -0300)]
[media] s5p-tv: Add missing braces around sizeof in mixer_video.c
Silences several checkpatch warnings of the type:
WARNING: sizeof *out should be sizeof(*out)
FILE: media/platform/s5p-tv/mixer_video.c:98:
out = kzalloc(sizeof *out, GFP_KERNEL);
[media] s5p-tv: Fix return value in sdo_probe() on error paths
Use proper return value test for clk_get() and devm_regulator_get()
functions and propagate any errors from the clock and the regulator
subsystem to the driver core. In two cases a proper error code is
now returned rather than 0.
Reported-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
[media] s5p-fimc: Prevent AB-BA deadlock during links reconfiguration
This patch patch eliminates potential AB-BA deadlock when one process calls
open(), or VIDIOC_S/TRY_FMT ioctl on the FIMC capture video node, while
other thread is reconfiguring media links via media device node:
/dev/video? open() /dev/media? MEDIA_IOC_SETUP_LINK ioctl
mutex_lock(video_lock) mutex_lock(graph_lock)
fimc_pipeline_open() fimc_md_link_notify()
mutex_lock(graph_lock) mutex_lock(video_lock)
... ...
The deadlock is avoided by always taking the graph mutex first in video
node open() or an ioctl, before the video lock is acquired. Reversed
order seems impossible, since media device driver's link_notify callback
is called with media graph mutex already held.
To ensure proper locking order VIDIOC_S_FMT and VIDIOC_TRY_FMT ioctls are
not serialized in the v4l2-core and the driver takes care of it itself.
[media] s5p-fimc: Avoid possible NULL pointer dereference in set_fmt op
This fixes following issue found with a static analysis tool:
Pointer 'ffmt' returned from call to function 'fimc_capture_try_format'
at line 1522 may be NULL and may be dereferenced at line 1535.
Although it shouldn't happen in practice, add the NULL pointer check
to be on the safe side.
Antti Palosaari [Sun, 9 Dec 2012 16:45:42 +0000 (13:45 -0300)]
[media] fc0012: remove unused callback and correct one comment
There is no need to keep dummy sleep() callback implementation as
DVB-core checks existence of it before calls callback. Due to that
we can remove it.
FC0012 is based of direct-conversion receiver architecture
(aka Zero-IF) where is no IF used. Due to that IF is always 0 Hz.
Fix comment to point that.
Antti Palosaari [Sun, 9 Dec 2012 14:46:40 +0000 (11:46 -0300)]
[media] fc0012: enable clock output on attach()
We need feed clock to slave demodulator at the very beginning
in case of dual tuner configuration.
I am not sure if that configuration changes clock output divider
or enable clock output itself...
Antti Palosaari [Sun, 9 Dec 2012 02:27:49 +0000 (23:27 -0300)]
[media] fc0012: use struct for driver config
I need even more configuration options and overloading dvb_attach()
for all those sounds quite stupid. Due to that switch struct and make
room for new options.
Javier Martin [Tue, 30 Oct 2012 14:29:01 +0000 (11:29 -0300)]
[media] mx2_camera: Remove 'buf_cleanup' callback
All necessary tasks to end the streaming properly are
already implemented in mx2_stop_streaming() and nothing
remains to be done in this callback.
Furthermore, it only included debug messages so it can
be removed.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Javier Martin [Tue, 30 Oct 2012 14:28:59 +0000 (11:28 -0300)]
[media] mx2_camera: Remove i.mx25 support
i.MX25 support has been broken for several releases
now and nobody seems to care about it.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
[g.liakhovetski@gmx.de: rebased on top of cpu_is_mx27() removal] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
[media] soc-camera: split struct soc_camera_link into host and subdevice parts
struct soc_camera_link currently contains fields, used both by sensor and
bridge drivers. To make subdevice driver re-use simpler, split it into a
host and a subdevice parts.
Currently soc-camera has a per-device node lock, used for video operations
and a per-host lock for code paths, modifying host's pipeline. Manipulating
the two locks increases complexity and doesn't bring any advantages. This
patch removes the per-device lock and uses the per-host lock for all
operations.
Currently devm_regulator_bulk_get() is called by soc-camera during host
driver probing, but regulators are attached to the camera platform
device, that is staying, independent whether the host probed successfully
or not. This can lead to repeated regulator requesting, if the host
driver is re-probed. Move the call to platform device probing to avoid
this.
[media] soc-camera: properly fix camera probing races
The recently introduced host_lock causes lockdep warnings, besides, list
enumeration in scan_add_host() must be protected by holdint the list_lock.
OTOH, holding .video_lock in soc_camera_open() isn't enough to protect
the host during its building of the pipeline, because .video_lock is per
soc-camera device. If, e.g. more than one sensor can be attached to a host
and the user tries to open both device nodes simultaneously, host's .add()
method can be called simultaneously for both sensors. Fix these problems
by holding list_lock instead of .host_lock in scan_add_host() and taking
it shortly at the beginning of soc_camera_open(), and using .host_lock to
protect host's .add() and .remove() operations only.
[media] em28xx: declare em28xx_stop_streaming as static
That fixes the following warning:
drivers/media/usb/em28xx/em28xx-video.c:611:5: warning: no previous prototype for 'em28xx_stop_streaming' [-Wmissing-prototypes]
Laurent Pinchart [Sun, 25 Nov 2012 00:35:48 +0000 (21:35 -0300)]
[media] v4l: Reset subdev v4l2_dev field to NULL if registration fails
When subdev registration fails the subdev v4l2_dev field is left to a
non-NULL value. Later calls to v4l2_device_unregister_subdev() will
consider the subdev as registered and will module_put() the subdev
module without any matching module_get().
Fix this by setting the subdev v4l2_dev field to NULL in
v4l2_device_register_subdev() when the function fails.
Frank Schaefer [Thu, 3 Jan 2013 17:27:06 +0000 (14:27 -0300)]
[media] em28xx: consider the message length limitation of the i2c adapter when reading the eeprom
EEPROMs are currently read in blocks of 16 bytes, but the em2800 is limited
to 4 bytes per read. All other chip variants support reading of max. 64 bytes
at once (according to the em258x datasheet; also verified with em2710, em2882,
and em28174).
Since em2800_i2c_recv_bytes() has been fixed to return with -EOPNOTSUPP when
more than 4 bytes are requested, EEPROM reading with this chip is broken.
It was actually broken before that change, too, it just didn't throw an error
because the i2c adapter silently returned trash data (for all reads >1 byte !).
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
- do not pass USB specific error codes to userspace/i2c-subsystem
- unify the returned error codes and make them compliant with
the i2c subsystem spec
- check number of actually transferred bytes (via USB) everywehere
- fix/improve debug messages
- improve code comments
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Frank Schaefer [Thu, 3 Jan 2013 17:27:04 +0000 (14:27 -0300)]
[media] em28xx: fix the i2c adapter functionality flags
I2C_FUNC_SMBUS_EMUL includes flag I2C_FUNC_SMBUS_WRITE_BLOCK_DATA which signals
that up to 31 data bytes can be written to the ic2 client.
But the EM2800 supports only i2c messages with max. 4 data bytes.
I2C_FUNC_IC2 should be set if a master_xfer function pointer is provided in
struct i2c_algorithm.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Frank Schaefer [Thu, 3 Jan 2013 17:27:03 +0000 (14:27 -0300)]
[media] em28xx: fix two severe bugs in function em2800_i2c_recv_bytes()
Function em2800_i2c_recv_bytes() has 2 severe bugs:
1) It does not wait for the i2c read to complete before reading the received message content from the bridge registers.
2) Reading more than 1 byte doesn't work
The former can result in data corruption, the latter always does.
The rewritten code also superseds the content of function
em2800_i2c_check_for_device().
Tested with device "Terratec Cinergy 200 USB".
Frank Schaefer [Thu, 3 Jan 2013 17:27:02 +0000 (14:27 -0300)]
[media] em28xx: respect the message size constraints for i2c transfers
The em2800 can transfer up to 4 bytes per i2c message.
All other em25xx/em27xx/28xx chips can transfer at least 64 bytes per message.
I2C adapters should never split messages transferred via the I2C subsystem
into multiple message transfers, because the result will almost always NOT be
the same as when the whole data is transferred to the I2C client in a single
message.
If the message size exceeds the capabilities of the I2C adapter, -EOPNOTSUPP
should be returned.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Frank Schaefer [Thu, 27 Dec 2012 22:02:44 +0000 (19:02 -0300)]
[media] em28xx: refactor the code in em28xx_usb_disconnect()
The main purpose of this patch is to move the call of em28xx_release_resources()
after the call of em28xx_close_extension().
This is necessary, because some resources might be needed/used by the extensions
fini() functions when they get closed.
Also mark the device as disconnected earlier in this function and unify the
em28xx_uninit_usb_xfer() calls for analog and digital mode.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Frank Schaefer [Thu, 27 Dec 2012 22:02:43 +0000 (19:02 -0300)]
[media] em28xx: simplify device state tracking
DEV_INITIALIZED of enum em28xx_dev_state state is used nowhere and there is no
need for DEV_MISCONFIGURED, so remove this enum and use a boolean field
'disconnected' in the device struct instead.
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Hans Verkuil [Fri, 7 Sep 2012 11:45:10 +0000 (08:45 -0300)]
[media] em28xx: remove sliced VBI support
The sliced VBI support in the tvp5150 is completely broken. And there is no
support for the saa7115 sliced VBI implementation in the em28xx driver. So
we remove the sliced VBI support completely.
It should be possible to get it to work with the tvp5150, but that will
require someone to really dig into that driver.
Hans Verkuil [Fri, 7 Sep 2012 10:31:54 +0000 (07:31 -0300)]
[media] em28xx: std fixes: don't implement in webcam mode, and fix std changes
When in webcam mode the STD API shouldn't be implemented.
When changing the standard the resolution wasn't updated, and there was no
check against streaming-in-progress.
Hans Verkuil [Fri, 7 Sep 2012 07:46:39 +0000 (04:46 -0300)]
[media] v4l2-ctrls: add a notify callback
Sometimes platform/bridge drivers need to be notified when a control from
a sub-device changes value. In order to support this a notify callback was
added.
[dheitmueller@kernellabs.com: fix merge conflict in v4l2-ctrls.c]
Hans Verkuil [Thu, 6 Sep 2012 13:07:25 +0000 (10:07 -0300)]
[media] em28xx: fix tuner/frequency handling
v4l2-compliance found problems with frequency clamping that wasn't
reported correctly and missing tuner index checks.
Also removed unnecessary tuner type checks (these are now done by the
v4l2 core).