[media] xc5000: add support for firmware load check and init status
The xc5000c and newer versions of the xc5000a firmware need minor revisions
to their initialization process. Add support for validating the firmware
was properly loaded, as well as checking the init status after initialization.
Based on advice from CrestaTech support as well as xc5000 datasheet v2.3.
[media] xc5000: reset device if encountering PLL lock failure
It's possible for the xc5000 to enter an unknown state such that all
subsequent tuning requests fail. The only way to recover is to reset the
tuner and reload the firmware. This problem was detected after several days
straight of issuing tuning requests every five seconds.
Reset the firmware in the event that the PLL is in an unlocked state. This
solution was provided by the engineer at CrestaTech (the company that acquired
Xceive).
[media] au0828: tune retry interval for i2c interaction
Adjust the retry timeout and number of retries to speed up xc5000
firmware download. With this change it goes from 4.2 seconds to 2.9.
The net time waited is pretty much the same, but we just poll more
often.
[media] au0828: remove control buffer from send_control_msg
There are no cases where a control message is ever sent to the au0828
with an actual buffer defined. Remove the reference to dev->ctrlmsg,
which currently requires us to hold a mutex since it is shared with the
read function.
[media] au0828: speed up i2c clock when doing xc5000 firmware load
Put a hack in place to speed up the firmware load in the case that the
xc5000 has just been reset. The chip can safely do 400 KHz in this mode,
while in normal operation it can only do 100 KHz.
This reduces the firmware load time from 6.9 seconds to 4.2.
[media] au0828: fix case where STREAMOFF being called on stopped stream causes BUG()
We weren't checking whether the resource was in use before calling
res_free(), so applications which called STREAMOFF on a v4l2 device that
wasn't already streaming would cause a BUG() to be hit (MythTV).
Reported-by: Larry Finger <larry.finger@lwfinger.net> Reported-by: Jay Harbeston <jharbestonus@gmail.com> Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
[media] au0828: prevent i2c gate from being kept open while in analog mode
The original implementation of the analog support would use an
i2c_gate_ctrl function when using the digital side of the au8522, but on
the analog side we would always just force the gate open and leave it
open all the time.
This can have adverse effects on the xc5000 given the tuner is receiving
all the spurious i2c traffic (a problem which can be exaggerated due to
bugs in the au0828 i2c hardware implementation).
Rework the existing hack to only open/close the gate when actually
talking to the tuner.
This logic might need to be reworked a bit if anybody ever tries to add
support for a board that has the au0828/au8522 but doesn't have digital
support implemented (because the i2c_gate_ctrl callback is being set in
the DVB attach). However given how few different models are in
circulation, this can be deferred until such a situation arises (if
ever).
[media] xc5000: don't invoke auto calibration unless we really did reset tuner
The current code invokes the auto calibration of the tuner whenever the
init routine is called (whenever the DVB frontend opens the device).
However we should really only be invoking the calibration if we actually
did reset the device and reload the firmware.
Rework the routine to only do calibration if reset and firmware load was
performed. Also because the called function is now a no-op if the
firmware is already loaded, the caller no longer needs to invoke
is_firmware_loaded().
[media] au8522: fix regression in logging introduced by separation of modules
The au8522 driver was broken into three modules (dig, decoder, common),
and as a result the debug modprobe option doesn't work for any of the
common functions.
Copy the module macros over to the common module so that the debug
option works again.
[media] au0828: make sure video standard is setup in tuner-core
If the user performs a tuning attempt without explicitly calling the
s_std ioctl(), a value of zero is sent from tuner-core to xc5000. This
causes the xc5000 driver to leave the standard unchanged. The problem
was masked by the fact that the xc5000 driver defaulted to NTSC, but if
you happened to perform an ATSC/ClearQAM tuning attempt and then do an
analog tune, the net effect is an analog tune with the standard still
set to DTV6.
Keep track of whether the standard has ever been sent to tuner-core. We
don't make an s_std subdev call explicitly during probe because that
will cause a firmware load (which is very time consuming on the 950q).
With the logic in this patch, the s_std call will occur automatically on
the s_freq call if it hasn't already been set.
[media] au0828: fix race condition that causes xc5000 to not bind for digital
In some cases users would see the xc5000_attach() call failing for the
digital side of the tuner on initialization. This is because of udev
running v4l-id while the digital side of the board is still coming up.
This is the exact same race condition which was present in em28xx (not
surprising since I copied all the locking logic from that driver when I
added analog support). Reproduce Mauro's fix from the em28xx driver in
au0828.
The logic as written would *never* actually return an error condition,
since the loop would run until the counter hit zero but the check was
for a value less than zero.
[media] xc5000: properly show quality register values
The quality register only has relevant data in bits 2-0, so discard the
other bits (which results in a value being printed that is consistent
with the expected 0-7 range).
[media] au0828: Make the s_reg and g_reg advanced debug calls work against the bridge
The g_reg and s_reg calls worked properly if acting on subdev registers
(such as the au8522), but didn't work against the au0828 itself. Copy
the logic over from em28xx.
[media] au8522: properly recover from the au8522 delivering misaligned TS streams
There is an apparent bug in the au8522 TS clocking which can result in
it delivering a TS payload to the au0828 that is shifted by some number
of bits. For example, the device will announce a packet containing "FA
38 FF F8" which if you shift left one bit is "1F 47 1F FF F0..."
This presents itself as no TS stream being delivered from the kernel to
userland, since the kernel demux will drop every packet.
In the event that this condition occurs, restart the DVB stream.
Also, this patch includes a couple of lines of cleanup to not change the
FIFO configuration while the FIFO is running (which can screw up the
state machine), and dequeue the buffers before turning off the FIFO.
This puts the logic in sync with the Windows driver.
[media] au8522: Fix off-by-one in SNR table for QAM256
The table of valid SNR values for QAM 256 is off by one, and as a result
if the SNR is oscillating between 40.0 and 39.9 dB, tools like azap show
it going back and forth between 40.0 and 0 (misleading some people,
including myself, to think signal lock is being lost or there is a
problem with register reads).
Fix the table so that 40.0 dB is properly represented.
[media] au8522: fix intermittent lockup of analog video decoder
It turns up the autodetection for the video standard in the au8522 is
prone to hanging the chip until a reset is performed. This condition is
trivial to reproduce simply by tuning to a station and then rapidly
unplugging/ replugging the coax feed.
Because we've never claimed to support anything other than NTSC-M, just
disable the video-standard autodetection logic and force it to always be
NTSC-M.
Hans Verkuil [Sat, 23 Jun 2012 10:47:14 +0000 (07:47 -0300)]
[media] saa7146: remove V4L2_FL_LOCK_ALL_FOPS
Add proper locking to the file operations, allowing for the removal
of the V4L2_FL_LOCK_ALL_FOPS flag.
I also removed some dead code in the form of the saa7146_devices list and
saa7146_devices_lock mutex: these were used once but that was a long time
ago.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
The dvb-usb-v2 core doesn't know anything about CI. So, the
driver needs to handle it by hand. This patch stops CI just
before stopping URB's/RC, and restarts it before URB/RC start.
It should be noticed that suspend/resume is not yet working properly,
as the PM model requires the implementation of reset_resume:
dvb_usb_az6007 1-6:1.0: no reset_resume for driver dvb_usb_az6007?
But this is not implemented there at dvb-usb-v2 yet.
Cc: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
[media] dvb-usb-v2: Don't ask user to select Cypress firmware module
The dvb-usb-v2 cypress firmware module is not optional, as drivers
won't work without it. So, instead of opening a menu for the user to
manually select, let the drivers that need it to select, hiding this
option from the Kconfig menu.
Acked-by: Antti Palosaari <crope@iki.fi> Reviewed-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/m2m-deinterlace.c: In function ‘deinterlace_issue_dma’:
drivers/media/video/m2m-deinterlace.c:363:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘dma_addr_t’ [-Wformat]
drivers/media/video/m2m-deinterlace.c:363:3: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘dma_addr_t’ [-Wformat]
Cc: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Javier Martin [Thu, 26 Jul 2012 08:55:18 +0000 (05:55 -0300)]
[media] media: Add mem2mem deinterlacing driver
Some video decoders such as tvp5150 provide separate
video fields (V4L2_FIELD_SEQ_TB/BT). This driver uses
dmaengine to convert this format to V4L2_FIELD_INTERLACED_TB/BT
(weaving) or V4L2_FIELD_NONE (line doubling) so that the
image can be displayed or processed.
Of course there will be combing effect in the image but this
can be accepted for some low quality applications.
Currently only YUV420 and YUYV formats are supported but
it can be extended later.
Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Javier Martin [Thu, 26 Jul 2012 08:53:35 +0000 (05:53 -0300)]
[media] media: coda: Add driver for Coda video codec
Coda is a range of video codecs from Chips&Media that
support H.264, H.263, MPEG4 and other video standards.
Currently only support for the codadx6 included in the
i.MX27 SoC is added. H.264 and MPEG4 video encoding
are the only supported capabilities by now.
[mchehab@redhat.com: Add missing include linux/of.h] Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Reviewed-by: Philipp Zabel<p.zabel@pengutronix.de> Reviewed-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Antti Palosaari [Wed, 25 Jul 2012 00:21:04 +0000 (21:21 -0300)]
[media] af9015: remote controller fixes
1)
AF9015 remote controller query will fail rarely due to register
access failures and dvb_usb_v2 will stop rc polling when error
returned. Add logic to allow errors until two consecutive errors
occurs.
2)
Remote controller key map was not loaded in case of key map was set as
a device property. Fix it.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Antti Palosaari [Thu, 5 Jul 2012 22:57:07 +0000 (19:57 -0300)]
[media] dvb_usb_v2: register device even no remote keymap defined
It failed to register device when remote keymap was not set.
Fix it to register device even keymap is NULL. In that case
just skip remote registration.
Driver should set RC_MAP_EMPTY to enable remote in case of
there is remote receiver but default keymap is unknown.
It is nice to have this debug, but as it generates very huge amount
of traffic, better to make it conditional. Use define macro to disable
it as I did not find out how to use dynamic debugs to dump variable
length buffers like that.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Antti Palosaari [Tue, 19 Jun 2012 02:42:53 +0000 (23:42 -0300)]
[media] dvb_usb_v2: use identify_state() to resolve firmware name
Merge get_firmware_name() to identify_state().
It is wise to resolve firmware name in that routine as it does
decision wether or not to load firmware at all. It is one very
rarely needed callback less.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Antti Palosaari [Tue, 19 Jun 2012 01:54:16 +0000 (22:54 -0300)]
[media] dvb_usb_v2: merge get_ts_config() to get_usb_stream_config()
Piggypag TS type callback to USB stream callback and change
callback name slightly to fit better.
Both of those are rather rare callback and has a relation. Transport
Stream, TS, is input stream and USB stream is output stream of
DVB USB bridge.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Antti Palosaari [Sun, 17 Jun 2012 03:27:00 +0000 (00:27 -0300)]
[media] dvb_usb_v2: use lock to sync feed and frontend control
There was synchronization problem when streaming was stopped.
Frontend was ran down before stream which causes problems.
Use mutex to synchronization. Now it looks like that:
LOCK
start frontend
UNLOCK
LOCK
start streaming
[...]
stop streaming
UNLOCK
LOCK
stop frontend
UNLOCK
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Antti Palosaari [Sat, 16 Jun 2012 19:02:57 +0000 (16:02 -0300)]
[media] dvb_usb_v2: change USB stream config logic
Initial / default USB stream configuration is now set always as a
dvb_usb_device_properties. Dynamic configuration is done top of
that if callback .get_usb_stream_config() exists. Default values
are set when callback is called so callback needs only change
values that are different than default.
In addition of that define two macros DVB_USB_STREAM_BULK() and
DVB_USB_STREAM_ISOC() for filling struct usb_data_stream_properties
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Give DVB adapter as a parameter for callback. MAC address is
adapter property and it could be (at least in theory) there
is devices having multiple adapters and all has own MAC.
Also add error handling. If callback fails error is returned
which leads device unregister.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Antti Palosaari [Fri, 15 Jun 2012 03:29:36 +0000 (00:29 -0300)]
[media] dvb_usb_v2: try to remove all adapters on exit
It did not removed adapter on error case as .num_adapters_initialized
was set after success adapter initialization. It should be safe to
try remove all possible adapters in any-case.
Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>