This patch addresses a regression introduced in the following patch:
commit 5264a522a5
Author: Shuah Khan <shuahkh@osg.samsung.com>
[media] media: tuner xc5000 - release firmwware from xc5000_release()
The "priv" struct is actually reference counted, so the xc5000_release()
function gets called multiple times for hybrid devices. Because
release_firmware() was always being called, it would work fine as expected
on the first call but then the second call would corrupt aribtrary memory.
Set the pointer to NULL after releasing so that we don't call
release_firmware() twice.
This problem was detected in the HVR-950q where plugging/unplugging the
device multiple times would intermittently show panics in completely
unrelated areas of the kernel.
Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
The release_firmware() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Adds control of the IF output level to the xc5000 tuner
configuration structure. Increases the IF level to the
demodulator to fix failure to lock and picture breakup
issues (with the au8522 demodulator, in the case of the
Hauppauge HVR950Q).
This patch works with all XC5000 firmware versions.
Signed-off-by: Richard Vollkommer <linux@hauppauge.com>
Signed-off-by: Michael Ira Krufky <mkrufky@linuxtv.org>
Reviewed-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
I moved the call to hybrid_tuner_release_state(priv) after
"priv->firmware" dereference.
Fixes: 5264a522a5 ('[media] media: tuner xc5000 - release firmwware from xc5000_release()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
xc5000 doesn't load firmware at attach time instead loads it
when it needs to set and change configuration from its init,
frequency, digital and analog mode set interffaces. As a result,
when system is suspended before firmware is loaded, firmware
load can be avoided during resume. Loading formware in this
scenario results in slowpath warnings during resume as it won't
be in the suspend firmware cache.
Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
xc5000 releases firmware right after loading it. Change it to
save the firmware and release it from xc5000_release(). This
helps avoid fecthing firmware when forced firmware load requests
come in to change analog tv frequence and when firmware needs to
be reloaded after suspend and resume.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Now that xc5000_set_params() is also called during resume,
move the code that checks for the firmware to happen there.
This way, the firmware will be loaded either for analog or
digital TV when .resume callback is called.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
xc5000_set_params() is a bad name for a function that
handles only digital TV. Rename it to xc5000_set_digital_params(),
and proper name the generic function that works for both
digital and analog.
No functional changes.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
As we need a function that reapply the last tuned radio,
in order to do resume, split the code that validates and
updates the internal priv struct from the ones that
actually set radio and TV.
A latter patch will add support for resume.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
As we'll be adding a code to resume tuner operation, we
need to move the code that actually sets DTV on a separate
function, to be called by the resume code.
No functional changes, just code got moved.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
After xc5000 stops working, it waits for 5 seconds, waiting
for a new usage. Only after that it goes to low power mode.
If a suspend event happens before that, a work queue will
remain active, with causes suspend to crash.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
On a normal condition, no errors should happen at xc5000
firmware upload is done. So, print at the dmesg if something
bad happens.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Currently, firmware retry logic keeps reading from FS every
time during the retry logic. This is not needed. Instead,
only release the firmware read after success.
While here, make the non-debug messages less verbose, as it
only matters to the user if the firmware was successfully
loaded, or if some error happened.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
With the current code, if something bad happens during the
firmware init process, the device will keep trying forever,
and removing it would cause an OOPS.
Instead, try only a limited amount of time. If not, fails.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
The programmed frequency on xc5000 is not the middle
frequency, but the initial frequency on the bandwidth range.
However, the DVB API works with the middle frequency.
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Some drivers, like au0828 are very sensitive to tuner sleep and may
break if the sleep happens too fast. Also, by keeping the tuner alive
for a while could speedup tuning process during channel scan. So,
change the logic to delay the actual sleep to 5 seconds after its
command.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
WARNING: please, no space before tabs
+#define XC_PRODUCT_ID_FW_LOADED ^I0x1388$
WARNING: please, no space before tabs
+#define DK_SECAM_A2LDK3 ^I13$
WARNING: please, no space before tabs
+#define DK_SECAM_A2MONO ^I14$
WARNING: please, no space before tabs
+#define FM_RADIO_INPUT2 ^I21$
WARNING: please, no space before tabs
+#define FM_RADIO_INPUT1 ^I22$
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
There's absolutely no reason to wrap msleep() call here.
Just rename all occurences of xc_wait() with msleep() and
remove the wrapper function.
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
I found very small bug in xc5000 source. When set option debug=1 and
listen a radio we see in dmesg xc5000: xc_SetTVStandard()
Standard = M/N-NTSC/PAL-BTSC at all times. However, it should be, instead
"FM Radio-INPUT1_MONO".
That happens because xc5000_set_radio_freq() gets the correct value for
VideoMode and AudioMode for radio and calls xc_SetTVStandard() where name
of standard comes from the incorrect place priv->video_standard.
This incorrect debug message makes debugging a little difficult.
Signed-off-by: Dmitry Belimov <d.belimov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
There is a missing break so we use XC_RF_MODE_CABLE instead of
XC_RF_MODE_AIR.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Move the tuners one level up, as the "common" directory will be used
by drivers that are shared between more than one driver.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>