aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/em28xx/em28xx-core.c
AgeCommit message (Collapse)Author
2022-01-27media: em28xx: fix control-message timeoutsJohan Hovold
commit d9b7e8df3aa9b8c10708aab60e72e79ac08237e4 upstream. USB control-message timeouts are specified in milliseconds and should specifically not vary with CONFIG_HZ. Fixes: a6c2ba283565 ("[PATCH] v4l: 716: support for em28xx board family") Cc: stable@vger.kernel.org # 2.6.16 Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-11-26media: em28xx: Don't use ops->suspend if it is NULLColin Ian King
[ Upstream commit 51fa3b70d27342baf1ea8aaab3e96e5f4f26d5b2 ] The call to ops->suspend for the dev->dev_next case can currently trigger a call on a null function pointer if ops->suspend is null. Skip over the use of function ops->suspend if it is null. Addresses-Coverity: ("Dereference after null check") Fixes: be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner functionality") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-03-04media: em28xx: Fix use-after-free in em28xx_alloc_urbsDinghao Liu
[ Upstream commit a26efd1961a18b91ae4cd2e433adbcf865b40fa3 ] When kzalloc() fails, em28xx_uninit_usb_xfer() will free usb_bufs->buf and set it to NULL. Thus the later access to usb_bufs->buf[i] will lead to null pointer dereference. Also the kfree(usb_bufs->buf) after that is redundant. Fixes: d571b592c6206 ("media: em28xx: don't use coherent buffer for DMA transfers") Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-27media: em28xx: Fix exception handling in em28xx_alloc_urbs()Markus Elfring
[ Upstream commit ecbce48f1ff2442371ebcd12ec0ecddb431fbd72 ] A null pointer would be passed to a call of the function "kfree" directly after a call of the function "kcalloc" failed at one place. Pass the data structure member "urb" instead for which memory was allocated before (so that this resource will be properly cleaned up). This issue was detected by using the Coccinelle software. Fixes: d571b592c6206d33731f41aa710fa0f69ac8611b ("media: em28xx: don't use coherent buffer for DMA transfers") Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-08-02media: usb: em28xx: Replace GFP_ATOMIC with GFP_KERNEL in em28xx_init_usb_xfer()Jia-Ju Bai
em28xx_init_usb_xfer() is never called in atomic context. It calls usb_submit_urb() with GFP_ATOMIC, which is not necessary. GFP_ATOMIC can be replaced with GFP_KERNEL. This is found by a static analysis tool named DCNS written by myself. Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-07-30media: em28xx: explicitly disable TS packet filterRobert Schlabbach
The em28xx driver never touched the EM2874 register bits that control the transport stream packet filters, leaving them at whatever default the firmware has set. E.g. the Pinnacle 290e disables them by default, while the Hauppauge WinTV dualHD enables discarding NULL packets by default. However, some applications require NULL packets, e.g. to determine the load in DOCSIS segments, so discarding NULL packets is undesired for such applications. This patch simply extends the bit mask when starting or stopping the transport stream packet capture, so that the filter bits are cleared. It has been verified that this makes the Hauppauge WinTV dualHD pass an unfiltered DVB-C stream including NULL packets, which it didn't before. Signed-off-by: Robert Schlabbach <Robert.Schlabbach@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-10Merge tag 'v4.17-rc4' into patchworkMauro Carvalho Chehab
Linux 4.17-rc4 * tag 'v4.17-rc4': (920 commits) Linux 4.17-rc4 KVM: x86: remove APIC Timer periodic/oneshot spikes genksyms: fix typo in parse.tab.{c,h} generation rules kbuild: replace hardcoded bison in cmd_bison_h with $(YACC) gcc-plugins: fix build condition of SANCOV plugin MAINTAINERS: Update Kbuild entry with a few paths Revert "usb: host: ehci: Use dma_pool_zalloc()" platform/x86: Kconfig: Fix dell-laptop dependency chain. platform/x86: asus-wireless: Fix NULL pointer dereference arm64: vgic-v2: Fix proxying of cpuif access KVM: arm/arm64: vgic_init: Cleanup reference to process_maintenance KVM: arm64: Fix order of vcpu_write_sys_reg() arguments MAINTAINERS & files: Canonize the e-mails I use at files media: imx-media-csi: Fix inconsistent IS_ERR and PTR_ERR tools: power/acpi, revert to LD = gcc bdi: Fix oops in wb_workfn() RDMA/cma: Do not query GID during QP state transition to RTR IB/mlx4: Fix integer overflow when calculating optimal MTT size IB/hfi1: Fix memory leak in exception path in get_irq_affinity() IB/{hfi1, rdmavt}: Fix memory leak in hfi1_alloc_devdata() upon failure ...
2018-05-04media: em28xx: Don't use ops->resume if NULLMauro Carvalho Chehab
Changeset be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner functionality") introduced a potential NULL pointer dereference, as pointed by Coverity: CID 1434731 (#1 of 1): Dereference after null check (FORWARD_NULL)16. var_deref_op: Dereferencing null pointer ops->resume. var_compare_op: Comparing ops->resume to null implies that ops->resume might be null. 1174 if (ops->resume) 1175 ops->resume(dev); 1176 if (dev->dev_next) 1177 ops->resume(dev->dev_next); Fixes: be7fd3c3a8c5 ("media: em28xx: Hauppauge DualHD second tuner functionality") Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-05-04MAINTAINERS & files: Canonize the e-mails I use at filesMauro Carvalho Chehab
From now on, I'll start using my @kernel.org as my development e-mail. As such, let's remove the entries that point to the old mchehab@s-opensource.com at MAINTAINERS file. For the files written with a copyright with mchehab@s-opensource, let's keep Samsung on their names, using mchehab+samsung@kernel.org, in order to keep pointing to my employer, with sponsors the work. For the files written before I join Samsung (on July, 4 2013), let's just use mchehab@kernel.org. For bug reports, we can simply point to just kernel.org, as this will reach my mchehab+samsung inbox anyway. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Brian Warner <brian.warner@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
2018-03-07media: em28xx: Change hex to lower caseBrad Love
Coding style fix. Signed-off-by: Brad Love <brad@nextdimension.cc> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06media: em28xx-core: fix most coding style issuesMauro Carvalho Chehab
There are a number of coding style issues at em28xx-core. Fix most of them, by using checkpatch in strict mode to point for it. Automatic fixes were made with --fix-inplace, but those were complemented by manual work. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06media: em28xx: Add SPDX license tags where neededMauro Carvalho Chehab
Most of the files there are missing a SPDX license tag. Add. While here fix some DRIVER_LICENSE macro in order to reflect the source file license, as some of the headers are GPL v2 only. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06media: em28xx: constify most static structsMauro Carvalho Chehab
There are several em28xx static structs that can now be constified. That caused a significant reduction at data segment: Before: text data bss dec hex filename 85017 59588 576 145181 2371d drivers/media/usb/em28xx/em28xx.o After: text data bss dec hex filename 112345 32292 576 145213 2373d drivers/media/usb/em28xx/em28xx.o Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06media: em28xx: stop rewriting device's structMauro Carvalho Chehab
Writing at the device's struct is evil, as two em28xx devices may be using it. So, stop abusing it, storing the values inside struct em28xx_dev. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06media: em28xx: don't use coherent buffer for DMA transfersMauro Carvalho Chehab
While coherent memory is cheap on x86, it may cause performance impacts on other archs. As we don't have any good reason to use it, let's change the logic by allocating memory via kmalloc() and letting the USB core to do the DMA mapping and memory free for us. While here, also fixes an issue that it was not de-allocating memories if something gets wrong during memory block allocation. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06media: em28xx: Bulk transfer implementation fixBrad Love
Set appropriate bulk/ISOC transfer multiplier on capture start. This sets ISOC transfer to USB endpoint configuration This sets bulk transfer to 48128 bytes (188 * 256) The bulk multiplier is maximum allowed according to Empia. Signed-off-by: Brad Love <brad@nextdimension.cc> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06media: em28xx: Hauppauge DualHD second tuner functionalityBrad Love
Implement use of secondary TS port on em28xx. Adds has_dual_ts field, allows secondary demod/tuner to be added to a single em28xx device. Hauppauge DualHD models are configured to use this feature. [mchehab@s-opensource.com: em28xx_duplicate_dev() should be static] Signed-off-by: Brad Love <brad@nextdimension.cc> Reviewed-by: Michael Ira Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-06-06[media] em28xx: fix+improve the register (usb control message) debuggingFrank Schaefer
- avoid duplicate debugging messages in em28xx_read_reg_req_len() - do not describe successful usb transfers in em28xx_read_reg_len() as "failed" - report errors in em28xx_write_regs_req(), too - print the usb error numbers, too Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-12[media] em28xx: don't store usb_device at struct em28xxMauro Carvalho Chehab
Now that we're storing usb_interface at em28xx struct, there's no good reason to keep storing usb_device, as we can get it from usb_interface. So, get rid of it. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-12-12[media] em28xx: use usb_interface for dev_foo() callsMauro Carvalho Chehab
The usb_device->dev is not the right device for dev_foo() calls. Instead, it should use usb_interface->dev. Tested-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-11-18[media] em28xx: convert it from pr_foo() to dev_foo()Mauro Carvalho Chehab
Instead of using pr_foo(), use dev_foo(), with provides a better output. As this device is a multi-interface one, we'll set the device name to show the chipset and the driver used. While here, get rid of printk continuation messages. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21[media] em28xx: convert the remaining printks to pr_fooMauro Carvalho Chehab
There are still several places with printk's called directly. Convert them to pr_foo() macros, except for the debug printk's, as those are enabled via modprobe vars. While here, realign the pr_foo() arguments to match the recommended CodingStyle. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21[media] em28xx: use pr_foo instead of em28xx-specific printk macrosMauro Carvalho Chehab
There's no reason to keep using em28xx-specific printk macros here. Just use pr_foo(). Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21[media] em28xx: mark printk continuation lines as suchMauro Carvalho Chehab
This driver has a lot of printk continuation lines for debugging purposes. Since commit 563873318d32 ("Merge branch 'printk-cleanups"), this won't work as expected anymore. So, let's add KERN_CONT to those lines. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-21[media] em28xx: don't break long linesMauro Carvalho Chehab
Due to the 80-cols checkpatch warnings, several strings were broken into multiple lines. This is not considered a good practice anymore, as it makes harder to grep for strings at the source code. So, join those continuation lines. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-24[media] media: usb: em28xx: em28xx-core: don't print error when allocating ↵Wolfram Sang
urb fails kmalloc will print enough information in case of failure. Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2014-12-23[media] em28xx-core: fix missing newlinesRussell King
Inspection shows that newlines are missing from several kernel messages in em28xx-core. Fix these. Fixes: 9c669b731470 ("[media] em28xx: add suspend/resume to em28xx_ops") Cc: <stable@vger.kernel.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-12-04[media] em28xx: checkpatch cleanup: whitespaces/new lines cleanupsMauro Carvalho Chehab
This patch is basically produced while testing a tool that Joe Perches sent upstream sometime ago: https://lkml.org/lkml/2014/7/11/794 I used it with those arguments: $ reformat_with_checkpatch.sh drivers/media/usb/em28xx/em28xx*.[ch] It actually produced 24 patches, with is too much, and showed interesting things: gcc produced different codes on most of the patches, even with just linespace changes. The total code data remained the same on all cases I checked though. Anyway, provided that we fold the resulting patches, this tool seems useful. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-10-21[media] em28xx: fix uninitialized variable warningHans Verkuil
Fix this daily build warning: In file included from build/media_build/v4l/em28xx-core.c:35:0: build/media_build/v4l/em28xx-core.c: In function 'em28xx_audio_setup': build/media_build/v4l/em28xx.h:798:2: warning: 'vid' may be used uninitialized in this function [-Wmaybe-uninitialized] printk(KERN_INFO "%s: "fmt,\ ^ build/media_build/v4l/em28xx-core.c:507:6: note: 'vid' was declared here u32 vid; ^ As far as I can tell 'vid' can not really be used uninitialized here, but the code is sufficiently complex that apparently gcc can't figure that out. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-23[media] em28xx: remove dead code line from em28xx_audio_setup()Frank Schaefer
Setting the value of the chip config register to EM28XX_CHIPCFG_AC97 in case of a read error is a leftover from the past which is no longer needed. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-23[media] em28xx: get rid of field has_audio in struct em28xx_audio_modeFrank Schaefer
Field has_audio in struct em28xx_audio_mode is used together with value EM28XX_NO_AC97 of field ac97 to determine the internal type of audio (none/i2s/ac97). This makes the code difficult to understand: !audio_mode.has_audio && audio_mode.ac97 == EM28XX_NO_AC97 => no audio !audio_mode.has_audio && audio_mode.ac97 != EM28XX_NO_AC97 => BUG audio_mode.has_audio && audio_mode.ac97 == EM28XX_NO_AC97 => AC97 audio audio_mode.has_audio && audio_mode.ac97 != EM28XX_NO_AC97 => I2S audio Simplify the whole thing by introducing an enum em28xx_int_audio_type which describes the internal audio type (none, ac97, i2s) and is hooked directly to the device struct. Then get rid of field has_audio in struct em28xx_audio_mode. A follow-up patch will then remove struct em28xx_ac97_mode and finally the whole struct em28xx_audio_mode. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-23[media] em28xx: simplify usb audio class handlingFrank Schaefer
As far as we know devices can either have audio class or vendor class usb interfaces but not both at the same time. Even if both interface types could be provided by devices at the same time, the current code is totally broken for that case. So clean up and simplify the usb audio class handling by replacing fields "has_audio_class" (device has usb audio class compliant interface) and "has_alsa_audio" (device has vendor audio interface) in struct em28xx with a single enum em28xx_usb_audio_type. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-23[media] em28xx: remove some unnecessary fields from struct em28xx_audio_modeFrank Schaefer
Fields "ac97_feat", "ac97_vendor_id" and "i2s_samplerates" of struct em28xx_audio_mode are used nowhere, except in function em28xx_audio_setup(). So get rid of them and use local variables instead. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-23[media] em28xx: check if a device has audio earlier"Frank Schaefer
GIT_AUTHOR_DATE=1409603039 This reverts commit b99f0aadd33fad269c8e62b5bec8b5c012a44a56 Author: Mauro Carvalho Chehab <m.chehab@samsung.com> [media] em28xx: check if a device has audio earlier Better to split chipset detection from the audio setup. So, move the detection code to em28xx_init_dev(). It broke analog audio of the Hauppauge winTV HVR 900 and very likely many other em28xx devices. Background: The local variable has_audio in em28xx_usb_probe() describes if the currently probed _usb_interface_ has an audio endpoint, while dev->audio_mode.has_audio means that the _device_ as a whole provides analog audio. Hence it is wrong to set dev->audio_mode.has_audio = has_audio in em28xx_usb_probe(). As result, audio support is no longer detected and configured on devices which have the audio endpoint on a separate interface, because em28xx_audio_setup() bails out immediately at the beginning. Revert the faulty commit to restore the old audio detection procedure, which checks the chip configuration register to determine if the device has analog audio. Cc: <stable@vger.kernel.org> # 3.14 to 3.16 Reported-by: Oravecz Csaba <oravecz@nytud.mta.hu> Tested-by: Oravecz Csaba <oravecz@nytud.mta.hu> Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
2014-09-03[media] em28xx: fix sparse warningsHans Verkuil
drivers/media/usb/em28xx/em28xx-core.c:297:16: warning: cast to restricted __le16 drivers/media/usb/em28xx/em28xx-cards.c:2249:20: warning: symbol 'em28xx_bcount' was not declared. Should it be static? Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-04[media] em28xx: add support for DVB monitor ledMauro Carvalho Chehab
Some devices have a LED to indicate when DVB capture started. Add support for it. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-03-03[media] em28xx: add suspend/resume to em28xx_opsShuah Khan
em28xx usb driver will have to suspend and resume its extensions. Adding suspend and resume to em28xx_ops gives extensions the ability to install suspend and resume that can be invoked from em28xx_usb driver suspend() and resume() interfaces. Approach: Add power management support to em28xx usb driver. This driver works in conjunction with extensions for each of the functions on the USB device for video/audio/dvb/remote functionality that is present on media USB devices it supports. During suspend and resume each of these extensions will have to do their part in suspending the components they control. Adding suspend and resume hooks to the existing struct em28xx_ops will enable the extensions the ability to implement suspend and resume hooks to be called from em28xx driver. The overall approach is as follows: -- add suspend and resume hooks to em28xx_ops -- add suspend and resume routines to em28xx-core to invoke suspend and resume hooks for all registered extensions. -- change em28xx dvb, audio, input, and video extensions to implement em28xx_ops: suspend and resume hooks. These hooks do what is necessary to suspend and resume the devices they control. Signed-off-by: Shuah Khan <shuah.kh@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-14[media] em28xx: push mutex down to extensions on .fini callbackMauro Carvalho Chehab
Avoid circular mutex lock by pushing the dev->lock to the .fini callback on each extension. As em28xx-dvb, em28xx-alsa and em28xx-rc have their own data structures, and don't touch at the common structure during .fini, only em28xx-v4l needs to be locked. [ 90.994317] ====================================================== [ 90.994356] [ INFO: possible circular locking dependency detected ] [ 90.994395] 3.13.0-rc1+ #24 Not tainted [ 90.994427] ------------------------------------------------------- [ 90.994458] khubd/54 is trying to acquire lock: [ 90.994490] (&card->controls_rwsem){++++.+}, at: [<ffffffffa0177b08>] snd_ctl_dev_free+0x28/0x60 [snd] [ 90.994656] [ 90.994656] but task is already holding lock: [ 90.994688] (&dev->lock){+.+.+.}, at: [<ffffffffa040db81>] em28xx_close_extension+0x31/0x90 [em28xx] [ 90.994843] [ 90.994843] which lock already depends on the new lock. [ 90.994843] [ 90.994874] [ 90.994874] the existing dependency chain (in reverse order) is: [ 90.994905] -> #1 (&dev->lock){+.+.+.}: [ 90.995057] [<ffffffff810b8fa3>] __lock_acquire+0xb43/0x1330 [ 90.995121] [<ffffffff810b9f82>] lock_acquire+0xa2/0x120 [ 90.995182] [<ffffffff816a5b6c>] mutex_lock_nested+0x5c/0x3c0 [ 90.995245] [<ffffffffa0422cca>] em28xx_vol_put_mute+0x1ba/0x1d0 [em28xx_alsa] [ 90.995309] [<ffffffffa017813d>] snd_ctl_elem_write+0xfd/0x140 [snd] [ 90.995376] [<ffffffffa01791c2>] snd_ctl_ioctl+0xe2/0x810 [snd] [ 90.995442] [<ffffffff811db8b0>] do_vfs_ioctl+0x300/0x520 [ 90.995504] [<ffffffff811dbb51>] SyS_ioctl+0x81/0xa0 [ 90.995568] [<ffffffff816b1929>] system_call_fastpath+0x16/0x1b [ 90.995630] -> #0 (&card->controls_rwsem){++++.+}: [ 90.995780] [<ffffffff810b7a47>] check_prevs_add+0x947/0x950 [ 90.995841] [<ffffffff810b8fa3>] __lock_acquire+0xb43/0x1330 [ 90.995901] [<ffffffff810b9f82>] lock_acquire+0xa2/0x120 [ 90.995962] [<ffffffff816a762b>] down_write+0x3b/0xa0 [ 90.996022] [<ffffffffa0177b08>] snd_ctl_dev_free+0x28/0x60 [snd] [ 90.996088] [<ffffffffa017a255>] snd_device_free+0x65/0x140 [snd] [ 90.996154] [<ffffffffa017a751>] snd_device_free_all+0x61/0xa0 [snd] [ 90.996219] [<ffffffffa0173af4>] snd_card_do_free+0x14/0x130 [snd] [ 90.996283] [<ffffffffa0173f14>] snd_card_free+0x84/0x90 [snd] [ 90.996349] [<ffffffffa0423397>] em28xx_audio_fini+0x97/0xb0 [em28xx_alsa] [ 90.996411] [<ffffffffa040dba6>] em28xx_close_extension+0x56/0x90 [em28xx] [ 90.996475] [<ffffffffa040f639>] em28xx_usb_disconnect+0x79/0x90 [em28xx] [ 90.996539] [<ffffffff814a06e7>] usb_unbind_interface+0x67/0x1d0 [ 90.996620] [<ffffffff8142920f>] __device_release_driver+0x7f/0xf0 [ 90.996682] [<ffffffff814292a5>] device_release_driver+0x25/0x40 [ 90.996742] [<ffffffff81428b0c>] bus_remove_device+0x11c/0x1a0 [ 90.996801] [<ffffffff81425536>] device_del+0x136/0x1d0 [ 90.996863] [<ffffffff8149e0c0>] usb_disable_device+0xb0/0x290 [ 90.996923] [<ffffffff814930c5>] usb_disconnect+0xb5/0x1d0 [ 90.996984] [<ffffffff81495ab6>] hub_port_connect_change+0xd6/0xad0 [ 90.997044] [<ffffffff814967c3>] hub_events+0x313/0x9b0 [ 90.997105] [<ffffffff81496e95>] hub_thread+0x35/0x170 [ 90.997165] [<ffffffff8108ea2f>] kthread+0xff/0x120 [ 90.997226] [<ffffffff816b187c>] ret_from_fork+0x7c/0xb0 [ 90.997287] [ 90.997287] other info that might help us debug this: [ 90.997287] [ 90.997318] Possible unsafe locking scenario: [ 90.997318] [ 90.997348] CPU0 CPU1 [ 90.997378] ---- ---- [ 90.997408] lock(&dev->lock); [ 90.997497] lock(&card->controls_rwsem); [ 90.997607] lock(&dev->lock); [ 90.997697] lock(&card->controls_rwsem); [ 90.997786] [ 90.997786] *** DEADLOCK *** [ 90.997786] [ 90.997817] 5 locks held by khubd/54: [ 90.997847] #0: (&__lockdep_no_validate__){......}, at: [<ffffffff81496564>] hub_events+0xb4/0x9b0 [ 90.998025] #1: (&__lockdep_no_validate__){......}, at: [<ffffffff81493076>] usb_disconnect+0x66/0x1d0 [ 90.998204] #2: (&__lockdep_no_validate__){......}, at: [<ffffffff8142929d>] device_release_driver+0x1d/0x40 [ 90.998383] #3: (em28xx_devlist_mutex){+.+.+.}, at: [<ffffffffa040db77>] em28xx_close_extension+0x27/0x90 [em28xx] [ 90.998567] #4: (&dev->lock){+.+.+.}, at: [<ffffffffa040db81>] em28xx_close_extension+0x31/0x90 [em28xx] Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Tested-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-10[media] em28xx: properly implement AC97 wait codeMauro Carvalho Chehab
Instead of assuming that msleep() is precise, use a jiffies based code to wait for AC97 to be available. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-07[media] em28xx: fix I2S audio sample rate definitions and info outputFrank Schaefer
The audio configuration in chip config register 0x00 and eeprom are always consistent. But currently the audio configuration #defines for the chip config register say 0x20 means 3 sample rates and 0x30 5 sample rates, while the eeprom info output says 0x20 means 1 sample rate and 0x30 3 sample rates. I've checked the datasheet excerpts I have and it seems that the meaning of these bits is different for em2820/40 (1 and 3 sample rates) and em2860+ (3 and 5 smaple rates). I have also checked my Hauppauge WinTV USB 2 (em2840) and the chip/eeprom audio config 0x20 matches the sample rates reproted by the USB device descriptor (32k only). Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-07[media] em28xx: unify module versionMauro Carvalho Chehab
Use the same module version on all em28xx sub-modules, and use the same naming convention to describe the driver. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-07[media] em28xx: check if a device has audio earlierMauro Carvalho Chehab
Better to split chipset detection from the audio setup. So, move the detection code to em28xx_init_dev(). Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-07[media] em28xx: improve extension information messagesMauro Carvalho Chehab
Add a message with consistent prints before and after each extension initialization, and provide a better text for module load. While here, add a missing sanity check for extension finish code at em28xx-v4l extension. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-07[media] em28xx: make em28xx-video to be a separate moduleMauro Carvalho Chehab
Now that all analog-specific code are at em28xx-video, convert it into an em28xx extension and load it as a separate module. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Tested-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-05[media] em28xx: Fix em28xx deplockMauro Carvalho Chehab
When em28xx extensions are loaded/removed, there are two locks: a single static em28xx_devlist_mutex that registers each extension and the struct em28xx dev->lock. When extensions are registered, em28xx_devlist_mutex is taken first, and then dev->lock. Be sure that, when extensions are being removed, the same order will be used. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-05[media] em28xx: move some video-specific functions to em28xx-videoMauro Carvalho Chehab
Now that we want to split the video handling to a separate module, move all video-specific functions to em28xx-video. No functional changes. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-12-18[media] em28xx: add support for Empia EM28178Antti Palosaari
New chip version, which is very similar than EM28174. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-12-10[media] em28xx: add support for illumination button and LEDFrank Schaefer
The SpeedLink VAD Laplace webcam is equipped with an illumination button and an illumination LED. When the button is pressed, the driver must toggle the LED state via the corresponding GPO port. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-12-10[media] em28xx: prepare for supporting multiple LEDsFrank Schaefer
Introduce a LED role and store all LEDs in an array. Also provide a helper function to retrieve a specific LED. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2013-12-10[media] em28xx: add support for GPO controlled analog capturing LEDsFrank Schaefer
Some devices are equipped with a capturing status LED that needs to be switched on/off explicitly via a GPO port. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>