aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-mpeg.c
Commit message (Collapse)AuthorAgeFilesLines
* more driver stuff from 3.2.72Wolfgang Wiedmeyer2015-10-231-15/+20
|
* [media] cx88: protect cx8802_devlist with a mutexJonathan Nieder2011-05-201-3/+17
| | | | | | | | | | | | Add and use a mutex to protect the cx88-mpeg device list. Previously the BKL prevented races. Based on work by Ben Hutchings <ben@decadent.org.uk>. Tested-by: Andi Huber <hobrom@gmx.at> Tested-by: Marlon de Boer <marlon@hyves.nl> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* [media] cx88: hold device lock during sub-driver initializationJonathan Nieder2011-05-201-3/+2
| | | | | | | | | | | | | | | | | | | cx8802_blackbird_probe makes a device node for the mpeg sub-device before it has been added to dev->drvlist. If the device is opened during that time, the open succeeds but request_acquire cannot be called, so the reference count remains zero. Later, when the device is closed, the reference count becomes negative --- uh oh. Close the race by holding core->lock during probe and not releasing until the device is in drvlist and initialization finished. Previously the BKL prevented this race. Reported-by: Andreas Huber <hobrom@gmx.at> Tested-by: Andi Huber <hobrom@gmx.at> Tested-by: Marlon de Boer <marlon@hyves.nl> Cc: stable@kernel.org Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* [media] cx88: fix locking of sub-driver operationsJonathan Nieder2011-05-201-4/+0
| | | | | | | | | | | | | | | | | | | | | | The BKL conversion of this driver seems to have gone wrong. Loading the cx88-blackbird driver deadlocks. The cause: mpeg_ops::open in the cx2388x blackbird driver acquires the device lock and calls the sub-driver's request_acquire, which tries to acquire the lock again. Fix it by clarifying the semantics of request_acquire, request_release, advise_acquire, and advise_release: now all will rely on the caller to acquire the device lock. Based on work by Ben Hutchings <ben@decadent.org.uk>. Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=31962 Reported-by: Andi Huber <hobrom@gmx.at> Tested-by: Andi Huber <hobrom@gmx.at> Tested-by: Marlon de Boer <marlon@hyves.nl> Cc: stable@kernel.org Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* [media] cx88: protect per-device driver list with device lockJonathan Nieder2011-05-201-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The BKL conversion of this driver seems to have gone wrong. Various uses of the sub-device and driver lists appear to be subject to race conditions. In particular, some functions access drvlist without a relevant lock held, which will race against removal of drivers. Let's start with that --- clean up by consistently protecting dev->drvlist with dev->core->lock, noting driver functions that require the device lock to be held or not to be held. After this patch, there are still some races --- e.g., cx8802_blackbird_remove can run between the time the blackbird driver is acquired and the time it is used in mpeg_release, and there's a similar race in cx88_dvb_bus_ctrl. Later patches will address the remaining known races and the deadlock noticed by Andi. This patch just makes the semantics clearer in preparation for those later changes. Based on work by Ben Hutchings <ben@decadent.org.uk>. Tested-by: Andi Huber <hobrom@gmx.at> Tested-by: Marlon de Boer <marlon@hyves.nl> Cc: stable@kernel.org Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* [media] use pci_dev->revisionBjørn Mork2011-05-201-1/+1
| | | | | | | | | pci_setup_device() has saved the PCI revision in the pci_dev struct since Linux 2.6.23. Use it. Cc: Auke Kok <auke-jan.h.kok@intel.com> Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* media/video: explicitly flush request_module workTejun Heo2010-12-241-0/+8
| | | | | | | | | | | | | | | | | Video drivers request submodules using a work during probe and calls flush_scheduled_work() on exit to make sure the work is complete before being unloaded. This patch makes these drivers flush the work directly instead of using flush_scheduled_work(). While at it, relocate request_submodules() call in saa7134_initdev() right right before successful return as in other drivers to avoid failing after the work is scheduled and returning failure without the work still active. This is in preparation for the deprecation of flush_scheduled_work(). Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB: drivers/media: Make static data tables and strings constlawrence rust2010-10-211-3/+3
| | | | | | | | | Making static data const avoids allocation of additional r/w memory and reduces initialisation time. It also provides some additional opportunities for compiler optimisations. Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB: cx88: fix setting input when using DVBIstvan Varga2010-05-191-1/+10
| | | | | | | | | | | | | | | In cx88-mpeg.c, there is code that sets core->input to CX88_VMUX_DVB. However, this may be incorrect, since core->input is actually an index to core->board.input[], which has not enough elements to be indexed by the value of CX88_VMUX_DVB. So, the modified code searches core->board.input[] for an input with a type of CX88_VMUX_DVB, and if it does not find one, the index is simply set to zero. The change may not have much effect, though, since it appears the only case when core->input is actually used is when the current input is being queried. Signed-off-by: Istvan Varga <istvanv@users.sourceforge.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* include cleanup: Update gfp.h and slab.h includes to prepare for breaking ↵Tejun Heo2010-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implicit slab.h inclusion from percpu.h percpu.h is included by sched.h and module.h and thus ends up being included when building most .c files. percpu.h includes slab.h which in turn includes gfp.h making everything defined by the two files universally available and complicating inclusion dependencies. percpu.h -> slab.h dependency is about to be removed. Prepare for this change by updating users of gfp and slab facilities include those headers directly instead of assuming availability. As this conversion needs to touch large number of source files, the following script is used as the basis of conversion. http://userweb.kernel.org/~tj/misc/slabh-sweep.py The script does the followings. * Scan files for gfp and slab usages and update includes such that only the necessary includes are there. ie. if only gfp is used, gfp.h, if slab is used, slab.h. * When the script inserts a new include, it looks at the include blocks and try to put the new include such that its order conforms to its surrounding. It's put in the include block which contains core kernel includes, in the same order that the rest are ordered - alphabetical, Christmas tree, rev-Xmas-tree or at the end if there doesn't seem to be any matching order. * If the script can't find a place to put a new include (mostly because the file doesn't have fitting include block), it prints out an error message indicating which .h file needs to be added to the file. The conversion was done in the following steps. 1. The initial automatic conversion of all .c files updated slightly over 4000 files, deleting around 700 includes and adding ~480 gfp.h and ~3000 slab.h inclusions. The script emitted errors for ~400 files. 2. Each error was manually checked. Some didn't need the inclusion, some needed manual addition while adding it to implementation .h or embedding .c file was more appropriate for others. This step added inclusions to around 150 files. 3. The script was run again and the output was compared to the edits from #2 to make sure no file was left behind. 4. Several build tests were done and a couple of problems were fixed. e.g. lib/decompress_*.c used malloc/free() wrappers around slab APIs requiring slab.h to be added manually. 5. The script was run on all .h files but without automatically editing them as sprinkling gfp.h and slab.h inclusions around .h files could easily lead to inclusion dependency hell. Most gfp.h inclusion directives were ignored as stuff from gfp.h was usually wildly available and often used in preprocessor macros. Each slab.h inclusion directive was examined and added manually as necessary. 6. percpu.h was updated not to include slab.h. 7. Build test were done on the following configurations and failures were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my distributed build env didn't work with gcov compiles) and a few more options had to be turned off depending on archs to make things build (like ipr on powerpc/64 which failed due to missing writeq). * x86 and x86_64 UP and SMP allmodconfig and a custom test config. * powerpc and powerpc64 SMP allmodconfig * sparc and sparc64 SMP allmodconfig * ia64 SMP allmodconfig * s390 SMP allmodconfig * alpha SMP allmodconfig * um on x86_64 SMP allmodconfig 8. percpu.h modifications were reverted so that it could be applied as a separate patch and serve as bisection point. Given the fact that I had only a couple of failures from tests on step 6, I'm fairly confident about the coverage of this conversion patch. If there is a breakage, it's likely to be something in one of the arch headers which should be easily discoverable easily on most builds of the specific arch. Signed-off-by: Tejun Heo <tj@kernel.org> Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
* V4L/DVB: Add support for SMT7020 to cx88Dirk Herrendoerfer2010-02-261-0/+3
| | | | | | | | | This patch adds support for the built-in dvb device of a Samsung SMT7020s (x86 based STB) to the cx88 family. Signed-off-by: Dirk Herrendoerfer <d.herrendoerfer@herrendoerfer.name> Signed-off-by: Helmut Auer <helmut@helmutauer.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (13554a): v4l: Use the video_drvdata function in driversLaurent Pinchart2009-12-161-15/+0
| | | | | | | | | | | | | | | Fix all device drivers to use the video_drvdata function instead of maintaining a local list of minor to private data mappings. Call video_set_drvdata to register the driver private pointer when not already done. Where applicable, the local list of mappings is completely removed when it becomes unused. [mchehab.redhat.com: removed tm6000 changes as tm6000 is not ready yet for submission even on staging] Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* trivial: media/video/cx88: add __init/__exit macros to cx88 driversPeter Huewe2009-09-211-2/+2
| | | | | | | | | Trivial patch which adds the __init and __exit macros to the module_init / module_exit functions to several files in drivers/media/video/cx88/ Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
* V4L/DVB (12349): cx88: HVR1300 ensure switching from Encoder to DVB-T and ↵Sohail Syyed2009-08-131-0/+4
| | | | | | | | | | back is reliable Current tip is broken and does not switch back to DVB-T correctly Signed-off-by: Sohail Syyed <linuxtv@hubstar.net> Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* dma-mapping: replace all DMA_32BIT_MASK macro with DMA_BIT_MASK(32)Yang Hongyang2009-04-071-1/+1
| | | | | | | | Replace all DMA_32BIT_MASK macro with DMA_BIT_MASK(32) Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* V4L/DVB (10190): cx88: Fix some Kbuild troublesMauro Carvalho Chehab2009-01-071-26/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As Randy Dunlap <randy.dunlap@oracle.com> reported, cx88 has some compilation issues: drivers/built-in.o: In function `cx88_call_i2c_clients': (.text+0x20af17): undefined reference to `videobuf_dvb_get_frontend' drivers/built-in.o: In function `cx8802_probe': cx88-mpeg.c:(.devinit.text+0x268c4): undefined reference to `videobuf_dvb_alloc_frontend' cx88-mpeg.c:(.devinit.text+0x268ea): undefined reference to `videobuf_dvb_dealloc_frontends' With those configs: CONFIG_VIDEO_CX88=y CONFIG_VIDEO_CX88_BLACKBIRD=y CONFIG_VIDEO_CX88_DVB=m CONFIG_DVB_CORE=m After carefully examining the code, with the current code, several cx88 drivers (cx8800, cx8802, cx88_dvb and cx88_blackbird) should be compiled as a module, if one of them is marked as such. Just fixing Kconfig could create a very complex set of rules. Also, this hides a problem with the current approach where the dvb functionality weren't confined inside dvb module. What happens is that: - cx88-i2c (part of cx8800) has some special rules if DVB; - cx88-mpeg (cx8802 module) has also part of DVB init code; - cx88-dvb has the rest of the dvb code; - cx88-blackbird can be used with cx88-mpeg, having cx88-dvb or not. So, instead of doing some tricks at Kconfig and wait for a next breakage, this patch moves the dvb code inside cx88-i2c and cx88-mpeg into cx88-dvb. Another problem is that cx8802 were being compiled, even without cx88-dvb and cx88-blackbird modules. While on this code, let's fix also a reported problem: http://www.linuxtv.org/pipermail/linux-dvb/2009-January/031225.html A solution for the issue were proposed here: http://www.mail-archive.com/linux-media@vger.kernel.org/msg00021.html Thanks to Randy, Andy, Gregoire and Thomas for helping us to detect and solve the issues. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (10135): v4l2: introduce v4l2_file_operations.Hans Verkuil2009-01-021-2/+1
| | | | | | | | | | | | | | | | Introduce a struct v4l2_file_operations for v4l2 drivers. Remove the unnecessary inode argument. Move compat32 handling (and llseek) into the v4l2-dev core: this is now handled in the v4l2 core and no longer in the drivers themselves. Note that this changeset reverts an earlier patch that changed the return type of__video_ioctl2 from int to long. This change will be reinstated later in a much improved version. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (9654): new email addressJelle Foks2008-12-291-2/+2
| | | | | | | Please accept this patch to refer to my new email address Signed-off-by: Jelle Foks <jelle@foks.us> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (9499): cx88-mpeg: final fix for analogue only compilation + ↵Darron Broad2008-11-111-13/+15
| | | | | | | | | | | | | | de-alloc fix Final fix for when analogue only is selected for compilation (ie, !CX88_DVB) This tidies up previous fix and adds missing de-alloc memory leak on fault (eg, if fe1 fails to alloc where fe0 was allocated). Signed-off-by: Darron Broad <darron@kewl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (9333): cx88: Not all boards that requires cx88-mpeg has frontendsMauro Carvalho Chehab2008-10-211-6/+2
| | | | | | | | | | | The multifrontend changes on cx88 assumed that all boards that use cx88-mpeg supports DVB. This is not true. There also a few analog-only boards based on Blackboard design that also uses cx88-mpeg. For those boards, there's no need to allocate dvb frontends. This patch fixes videobuf allocation for those devices. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (9332): cx88: initial fix for analogue only compilationDarron Broad2008-10-211-1/+6
| | | | | | | | Initial fix for when analogue only is selected for compilation (ie, !CX88_DVB) Signed-off-by: Darron Broad <darron@kewl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (9271): videobuf: data storage optimisation (2)Darron Broad2008-10-171-1/+1
| | | | | | | | | | | To optimise data storage even further one other redundant var has been removed. This also removes a redundant assignment. Signed-off-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Darron Broad <darron@kewl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (9265): videobuf: data storage optimisationDarron Broad2008-10-171-1/+1
| | | | | | | | To optimise data storage redundant vars are removed. Signed-off-by: Darron Broad <darron@kewl.org> Signed-off-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (9250): cx88: Convert __FUNCTION__ to __func__Steven Toth2008-10-171-3/+3
| | | | | | | cx88: Convert __FUNCTION__ to __func__ Signed-off-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (9222): S2API: Add Multiple-frontend on a single adapter support.Steven Toth2008-10-171-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A detailed description from the original patches 2 years ago: "The WinTV-HVR3000 has a single transport bus which is shared between a DVB-T and DVB-S modulator. These patches build on the bus acquisition cx88 work from a few weeks ago to add support for this. So to applications the HVR3000 looks like this: /dev/dvb/adapter0/fe0 (cx24123 DVB-S demod) /dev/dvb/adapter0/fe1 (cx22702 DVB-T demod) Additional boards continue as before, eg: /dev/dvb/adapter1/fe0 (lgdt3302 ATSC demod) The basic change is removing the single instance of the videobuf_dvb in cx8802_dev and saa7134_dev(?) and replacing it with a list and some supporting functions. *NOTE* This branch was taken before v4l-dvb was closed for 2.6.19 so two or three current cx88 patches appear to be reversed by this tree, this will be cleaned up in the near future. The patches missing change the mutex handing to core->lock, fix an enumeration problem." It should be recognised that a number of people have been maintaining this patchset. Significant levels of Kudos to everyone one involved, including but not limited to: Darron Broad Fabio M. Di Nitto Carlo Scarfoglio Hans Werner Without the work of these people, and countless others, my two year old patches would of died on the Mercurial linuxtv.org vine a long time ago. TODO: Revise these patches a little further so that the need for demux1 and dvr0 is optional, not mandatory on the HVR3000. HISTORY (darron): This is the last update to MFE prepared by Hans which is based upon the `scratchpad' diff created by Carlo. All MFE work prior to that point must be attributed to Fabio who ported and maintained Steve's original patch up to that time. Signed-off-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Darron Broad <darron@kewl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
* V4L/DVB (7521): media/video/cx88 replace remaining __FUNCTION__ occurrencesHarvey Harrison2008-04-241-8/+8
| | | | | | | | __FUNCTION__ is gcc-specific, use __func__ Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7256): cx88: Add support for tuner-xc3028Mauro Carvalho Chehab2008-04-241-0/+2
| | | | | | | Callback gpio's based on Markus Rechberger, Christopher Pascoe and Steven Toth patches. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7094): static memoryDouglas Schilling Landgraf2008-04-241-1/+1
| | | | | | | | - Static memory is always initialized with 0. - Replaced in some cases C99 comments for /* */ Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7201): cx88-mpeg: Fix race condition in variable accessRicardo Cerqueira2008-02-181-3/+3
| | | | | | | | | There was a possible race condition in the increment/decrement of the active device references counter. Thanks to Trent Piepho (xyzzy@speakeasy.org) for bringing it up. Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7194): cx88-mpeg: Allow concurrent access to cx88-mpeg devicesRoland Stoll2008-02-181-4/+12
| | | | | | | | | | | | It currently isn't possible to open the frontend device of cx88-mpeg devices (DVB or Blackbird) multiple times concurrently. (for instance, to attach a signal monitoring tool while reading a stream, or to send a frequency change ioctl) This patch fixes that condition. Signed-off-by: Roland Stoll <roland@xindex.de> Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org> Reviewed-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7046): Finalise support for the Pinnacle HD 8000iSteven Toth2008-01-251-2/+6
| | | | | | | | Correctly set the atatch structures, enable IR, configure the xc5000 tuner includes. Signed-off-by: Steven Toth <stoth@hauppauge.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (7043): New card supported(partially): Pinnacle 800iSteven Toth2008-01-251-1/+6
| | | | | | | | | | From Zhang: This patch continues the support for the Pinnacle HD 800i. Patch committed as-is, cleanups to follow ... Steve Signed-off-by: Chaogui Zhang <czhang1974@gmail.com> Signed-off-by: Steven Toth <stoth@hauppauge.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6600): V4L: videobuf: don't chew up namespace STATE_.*, convert to ↵Brandon Philips2008-01-251-7/+7
| | | | | | | | | | | | | | | VIDEOBUF_ s/STATE_NEEDS_INIT/VIDEOBUF_NEEDS_INIT/g s/STATE_PREPARED/VIDEOBUF_PREPARED/g s/STATE_QUEUED/VIDEOBUF_QUEUED/g s/STATE_ACTIVE/VIDEOBUF_ACTIVE/g s/STATE_DONE/VIDEOBUF_DONE/g s/STATE_ERROR/VIDEOBUF_ERROR/g s/STATE_IDLE/VIDEOBUF_IDLE/g Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6576): cx88-mpeg.c: make 4 functions staticAdrian Bunk2008-01-251-10/+4
| | | | | | | | | | | This patch makes the following needlessly global functions static: - cx8802_init_common() - cx8802_fini_common() - cx8802_suspend_common() - cx8802_resume_common() Signed-off-by: Adrian Bunk <bunk@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6336): cx8802: Plug memory leak when unregistering a driverTrent Piepho2007-10-221-0/+2
| | | | | | | | | | When a cx8802 sub-driver was unregistered, the struct cx8802_driver, which was kmalloc()ed by cx8802_register_driver(), was deleted from the list of drivers, but never freed. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Reviewed-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6335): cx8802: Replace list_for_each+list_entry with ↵Trent Piepho2007-10-221-56/+29
| | | | | | | | | | | | | | list_for_each_entry Less code and more efficient. Got ride of a variable that counted the number of devices in cx8802_unregister_driver() but was never used. Looked leftover from a cut&paste. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Reviewed-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6334): cx88: Change (struct cx8802_dev)->drvlist to a list_head and ↵Trent Piepho2007-10-221-31/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix bugs It was a struct cx8802_driver for no apparent reason. Nothing uses a cx8802_driver in the cx8802_dev struct. The only field that was used was devlist, a list_head. The code in cx8802_remove() that removed any loaded sub-drivers was broken. It would delete the current list entry, but didn't use list_for_each_safe. It also called list_del() on the list _head_ inside the list_for_each loop? It would crash if it was run, which I don't think can ever happen. Since the cx8802 sub-drivers use the cx8802 driver, they have to be unloaded first. So there isn't any way for a sub-driver to still be loaded when cx8802_remove() is called... Except maybe with PCI hot-plug, if one removes the PCI card while the drivers are loaded? So I left some code in to handle that if it's actually possible. It will remove the sub-drivers from the device cx8802_remove() was called on, and only that device. If one has two DVB cards and unplugs one, there is no reason to unload the DVB drivers for both cards. I have no way to test this, but it can't be worse than what was there before. cx8802_get_driver() is passed a cx8802_dev pointer and looks for the requested driver on that device. It first loops over the cx8802 device list looking for the device it was passed, which is pointless. It doesn't need to find the device pointer in the list, as it already has the pointer. The list_head in the cx8802_driver struct, which joins all the _drivers_ attached to a device, was named devlist. Changed that to drvlist, since the devlist is used for a list of _devices_ in other cx8802 structs. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Reviewed-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6332): cx88: Only include the blackbird fields if blackbird is selectedTrent Piepho2007-10-221-2/+6
| | | | | | | | | Add some ifdefs around fields only used for blackbird support, similar to the way the dvb fields are only included with dvb support. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Reviewed-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6252): Adapt drivers to use the newer videobuf modulesMauro Carvalho Chehab2007-10-091-1/+2
| | | | | | | | | | | | | | PCI-dependent videobuf_foo methods were renamed as videobuf_pci_foo. Also, videobuf_dmabuf is now part of videobuf-dma-sg private struct. So, to access it, a subroutine call is needed. This patch renames all occurences of those function calls to be consistent with the video-buf split. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org> http://thread.gmane.org/gmane.comp.video.video4linux/34978/focus=34981 Reviewed-by: Ricardo Cerqueira <v4l@cerqueira.org>
* V4L/DVB (6125): whitespace cleanup: replace leading spaces with tabsMichael Krufky2007-10-091-35/+35
| | | | | | | | | | | There were many instances of 7-space indents spread throughout the v4l-dvb tree. This patch replaces the 7-space indents with tabs. The whitespace cleaner script doesn't catch these, because it assumes that all indents are 8-space. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6083): cx88-alsa: Rework buffer handlingTrent Piepho2007-10-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework the way the DMA buffer is handled and IRQs are generated. ALSA uses a ring-buffer of multiple periods. Each period is supposed to corrispond to one IRQ. The existing driver was generating one interrupt per ring-buffer, as opposed to per period. This meant that as soon as the IRQ was generated, the hardware was already starting to re-write the beginning of the buffer. Since the DMA happens on a per-line basis, there was only a narrow window to copy the data out before the buffer was overwritten. The cx88 core RISC program generator is modified so that it can set the IRQ and counter flags to count every X lines of DMA transfer. This way we can generate an interrupt every period instead of every full ring-buffer. Right now only period of one line are supported, but it should be possible to support longer periods. Note that a WRITE instruction generates an IRQ when it starts, not when the transfer is finished. Thus to generate an IRQ when line X is done, one must set the IRQ flag on the instruction that starts line X+1, not the one that ends line X. Change the line size so that there are four lines in the SRAM FIFO. If there are not four lines, the analog output from the cx88's internal DACs is full of clicks and pops. Try to handle FIFO sync errors. Sometimes the chip generates many of these errors before audio data starts. Up to 50 sync errors will be ignored and the counter reset. Have the IRQ handler save the RISC counter to the chip struct, and then have the pointer callback use this to calculate the pointer position. We could read the counter from the pointer callback, but sometimes the sync errors on start up cause the counter to go crazy. ALSA sees this and thinks there has been an overrun. The IRQ hander can avoid saving the counter position on sync errors. The chip "opened" flag wasn't necessary. ALSA won't try to open the same substream multiple times. Probably this code was cut&pasted from the bt87x driver, which has multiple sub-streams for one chip. Do error checking for the videobuf mapping functions. snd_card_cx88_runtime_free() is useless and can be deleted. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6079): Cleanup: remove linux/moduleparam.h from drivers/media filesMauro Carvalho Chehab2007-10-091-1/+0
| | | | | | | Since at least kernel 2.6.12-rc2, module.h includes moduleparm.h. This patch removes all occurences of moduleparm.h from drivers/media files. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6064): cx88: Add symbolic names for the PCI interrupt bitsTrent Piepho2007-10-091-4/+5
| | | | | | | Used for the PCI_INTMSK and PCI_INT_STAT registers. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6023): cx88: Clean up some ugly and inconsistent printk()sTrent Piepho2007-10-091-17/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | Get rid of the "CORE" prefix from cx88 printks. It was only used a few times, and it makes it look like they're coming from the kernel core or something. Fix the message, "TV tuner 60 at 0x1fe, Radio tuner -1 at 0x1fe", by adding a "cx88[0]" prefix to be consistent, and to keep people who grep their dmesg output for cx88 from missing it. Get rid of the addresses, which are always wrong. The addresses are always set to -1, but because it's an unsigned 8-bit value, the left shift converts it to the nonsense address 0x1fe. In the cx8802 driver, some cut and pasted code prefixed lines with "CORE cx88[0]:", which has been changed to "cx88[0]/2:" like the other printks from the cx8802 driver. Also fix some ugly printks in the cx8802 driver that used __FUNCTION__ for KERN_INFO and KERN_ERR messages. The changed printks in cx88-mpeg.c also needed lots of whitespace and 80-column fixes. A bunch of misc changes in cx88-dvb.c and cx88-video.c to add message levels or a consistent "cx88[?]/2" or "cx88[?]/0" prefix. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6021): cx88: Copy board information into card stateTrent Piepho2007-10-091-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The cx88 driver state stored the ID of the board type in core->board. Every time the driver need to get some information about the board configuration, it uses the board number as an index into board configuration array. This patch changes it so that the board number is in core->boardnr, and core->board is a copy of the board configuration information. This allows access to board information without the extra indirection. e.g. cx88_boards[core->board].mpeg becomes core->board.mpeg. This has a number of advantages: - The code is simpler to write. - It compiles to be smaller and faster, without needing the extra array lookup to get at the board information. - The cx88_boards array no longer needs to be exported to all cx88 modules. - The boards array can be made const - It should be possible to avoid keeping the (large) cx88_boards array around after the module is loaded. - If module parameters or eeprom info override some board configuration setting, it's not necessary to modify the boards array, which would affect all boards of the same type. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (5912): Clean up duplicate includes in drivers/media/Jesper Juhl2007-10-091-1/+0
| | | | | | | | This patch cleans up duplicate includes in drivers/media/ Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (6188): Avoid a NULL pointer dereference during mpeg_open()Steven Toth2007-09-141-1/+1
| | | | | | | | | Bug: With a hardware encoder board installed as cx88[1] and a non-encoder boards installed as cx88[0], an OOPS is generated during cx8802_get_device() called from mpeg_open(). Signed-off-by: Steven Toth <stoth@hauppauge.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (5783): Fix excess of debug messages on cx88-mpegMauro Carvalho Chehab2007-07-181-1/+1
| | | | | | | | | Closes the issue opened on Kernel bugzilla: http://bugzilla.kernel.org/show_bug.cgi?id=8383 There's no need to print timeout without debug turned on: Apr 27 23:02:14 video kernel: cx88[1]/2-mpeg: cx8802_timeout Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (5567): Cx88-mpeg.c: make 2 functions staticAdrian Bunk2007-05-091-2/+2
| | | | | | | This patch makes two needlessly global functions static. Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
* V4L/DVB (5565): Cx88: fix compilation on alphaAlexey Dobriyan2007-05-091-0/+1
| | | | | | | error: 'DMA_32BIT_MASK' undeclared Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>