Commit graph

45 commits

Author SHA1 Message Date
Russell King 522adc7c1f [media] em28xx-core: fix missing newlines
Inspection shows that newlines are missing from several kernel messages
in em28xx-core.  Fix these.

Fixes: 9c669b7314 ("[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-23 14:46:05 -02:00
Mauro Carvalho Chehab fdf1bc9fa2 [media] em28xx: checkpatch cleanup: whitespaces/new lines cleanups
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-12-04 14:13:14 -02:00
Hans Verkuil 430e35724b [media] em28xx: fix uninitialized variable warning
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-10-21 08:51:07 -02:00
Frank Schaefer 43c3ea312c [media] em28xx: remove dead code line from em28xx_audio_setup()
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 16:13:42 -03:00
Frank Schaefer 920f1e4a52 [media] em28xx: get rid of field has_audio in struct em28xx_audio_mode
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 16:13:42 -03:00
Frank Schaefer c5874208ff [media] em28xx: simplify usb audio class handling
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 16:13:41 -03:00
Frank Schaefer 60a24ba03c [media] em28xx: remove some unnecessary fields from struct em28xx_audio_mode
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 16:13:41 -03:00
Frank Schaefer fb91bde9d3 [media] em28xx: check if a device has audio earlier"
GIT_AUTHOR_DATE=1409603039
This reverts

commit b99f0aadd3
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-23 16:13:35 -03:00
Hans Verkuil 4a9e512afa [media] em28xx: fix sparse warnings
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-09-03 10:34:58 -03:00
Mauro Carvalho Chehab 54e925498c [media] em28xx: add support for DVB monitor led
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-04 14:44:09 -03:00
Shuah Khan 9c669b7314 [media] em28xx: add suspend/resume to em28xx_ops
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-03-03 06:45:57 -03:00
Mauro Carvalho Chehab ebbfbc2006 [media] em28xx: push mutex down to extensions on .fini callback
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-14 14:39:32 -02:00
Mauro Carvalho Chehab 5022a20886 [media] em28xx: properly implement AC97 wait code
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-10 06:06:20 -02:00
Frank Schaefer 687ff8b0c4 [media] em28xx: fix I2S audio sample rate definitions and info output
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 08:33:29 -02:00
Mauro Carvalho Chehab d8992b0931 [media] em28xx: unify module version
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 05:12:10 -02:00
Mauro Carvalho Chehab b99f0aadd3 [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().

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
2014-01-07 05:11:59 -02:00
Mauro Carvalho Chehab 9634614f35 [media] em28xx: improve extension information messages
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 05:11:48 -02:00
Mauro Carvalho Chehab 01c2819330 [media] em28xx: make em28xx-video to be a separate module
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-07 05:09:26 -02:00
Mauro Carvalho Chehab 54a2a84ea9 [media] em28xx: Fix em28xx deplock
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 08:58:49 -02:00
Mauro Carvalho Chehab 0560f337f3 [media] em28xx: move some video-specific functions to em28xx-video
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>
2014-01-05 08:58:16 -02:00
Antti Palosaari 9f1d0bdab2 [media] em28xx: add support for Empia EM28178
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-18 07:18:14 -02:00
Frank Schaefer 6063d07785 [media] em28xx: add support for illumination button and LED
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 16:20:26 -02:00
Frank Schaefer 6b8a3170c9 [media] em28xx: prepare for supporting multiple LEDs
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 16:18:40 -02:00
Frank Schaefer 07e4de3004 [media] em28xx: add support for GPO controlled analog capturing LEDs
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>
2013-12-10 16:08:40 -02:00
Frank Schaefer 6914d70ecf [media] em28xx: remove GPIO register caching
The GPIO register caching is the result of wrong assumptions and incomplete
knowledge about the GPIO registers and their functionality.
Today, we know that it is not needed.
It is also limited to a single register and therefore incomplete (newer chips
are using multiple registers).
Instead of extending the caching, get rid of it, because it has no real
benefits and just bloats/complicates the code.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-06-19 11:43:20 -03:00
Frank Schaefer 1e2e9086c7 [media] em28xx: write output frame resolution to regs 0x34+0x35 for em25xx family bridges
The Windows driver writes the output resolution to registers 0x34 (width / 16)
and 0x35 (height / 16) always.
We don't know yet what these registers are used for.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-28 17:54:44 -03:00
Frank Schaefer c8c39796c4 [media] em28xx: make em28xx_set_outfmt() working with EM25xx family bridges
Streaming doesn't work with the EM2765 if bit 5 of the output format register
0x27 is set.
It's actually not clear if really has to be set for the other chips, but for
now let's keep it to avoid regressions and add a comment to the code.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-28 17:49:49 -03:00
Frank Schaefer 43a5e08d00 [media] em28xx: introduce #defines for the image quality default settings
The image quality default values will be used in at least two different places
and by using #defines we make sure that they are always consistent.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-04 14:50:31 -03:00
Frank Schaefer 84e902aa05 [media] em28xx: do not claim VBI support if the device is a camera
Avoids registering a VBI device and streaming in VBI-mode if the device is a
camera.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-03-04 14:26:06 -03:00
Frank Schaefer 33f6984ece [media] em28xx: fix analog streaming with USB bulk transfers
With the conversion to videobuf2, some unnecessary calls of
em28xx_set_alternate() have been removed. It is now called at analog streaming
start only.
This has unveiled a bug that causes USB bulk transfers to fail with all urbs
having status -EVOERFLOW.
The reason is, that for bulk transfers usb_set_interface() needs to be called
even if the previous alt setting was the same (side note: bulk transfers seem
to work only with alt=0).
While it seems to be NOT necessary for isoc transfers, it's reasonable to just
call usb_set_interface() unconditionally in em28xx_set_alternate().
Also add a comment that explains the issue to prevent regressions in the future.

Cc: stable@vger.kernel.org # for 3.8
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-02-11 18:17:44 -02:00
Frank Schaefer ddf289f98b [media] em28xx: overhaul em28xx_capture_area_set()
- move the bit shifting of width+height values inside the function
- fix the debug message format and output values
- add comment about the size limit (e.g. EM277x supports >2MPix)
- make void, because error checking is incomplete and we never check the
  returned value (we would continue anyway)

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2013-02-06 14:20:12 -02:00
Frank Schaefer 45f04e82d0 [media] em28xx: fix+improve+unify i2c error handling, debug messages and code comments
- 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>
2013-01-05 01:18:25 -02:00
Frank Schaefer 2665c2995d [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>
2013-01-05 01:09:39 -02:00
Frank Schaefer c647a91a25 [media] em28xx: improve USB endpoint logic, also use bulk transfers
The current enpoint logic ignores all bulk endpoints and uses
a fixed mapping between endpint addresses and the supported
data stream types (analog/audio/DVB):
  Ep 0x82, isoc	=> analog
  Ep 0x83, isoc	=> audio
  Ep 0x84, isoc	=> DVB
Now that the code can also do bulk transfers, the endpoint
logic has to be extended to also consider bulk endpoints.
The new logic preserves backwards compatibility and reflects
the endpoint configurations we have seen so far:
  Ep 0x82, isoc		=> analog
  Ep 0x82, bulk		=> analog
  Ep 0x83, isoc*	=> audio
  Ep 0x84, isoc		=> digital
  Ep 0x84, bulk		=> analog or digital**
 (*: audio should always be isoc)
 (**: analog, if ep 0x82 is isoc, otherwise digital)

[mchehab@redhat.com: Fix a CodingStyle issue: don't break strings
 into separate lines]

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 18:17:52 -02:00
Frank Schaefer c8e9d95b41 [media] em28xx: set USB alternate settings for analog video bulk transfers properly
Extend function em28xx_set_alternate:
- use alternate setting 0 for bulk transfers as default
- respect module parameter 'alt'=0 for bulk transfers
- set max_packet_size to 512 bytes for bulk transfers
[mchehab@redhat.com: Fix a CodingStyle issue: don't break strings
 into separate lines]
Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 18:13:11 -02:00
Frank Schaefer 0cf544a6cc [media] em28xx: rename some USB parameter fields in struct em28xx to clarify their role
Also improve the comments.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 18:11:26 -02:00
Frank Schaefer 337fe8dad5 [media] em28xx: clear USB halt/stall condition in em28xx_init_usb_xfer when using bulk transfers
[mchehab@redhat.com: Fix a CodingStyle issue: don't break strings
 into separate lines]

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 18:00:30 -02:00
Frank Schaefer 057ca0da06 [media] em28xx: create a common function for isoc and bulk USB transfer initialization
- rename em28xx_init_isoc to em28xx_init_usb_xfer
- add parameter for isoc/bulk transfer selection which is passed to em28xx_alloc_urbs
- rename local variable isoc_buf to usb_bufs

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 17:58:14 -02:00
Frank Schaefer 6ddd89d0c9 [media] em28xx: create a common function for isoc and bulk URB allocation and setup
Rename the existing function for isoc transfers em28xx_init_isoc
to em28xx_init_usb_xfer and extend it.
URB allocation and setup is now done depending on the USB
transfer type, which is selected with a new function parameter.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 17:58:00 -02:00
Frank Schaefer afb177e065 [media] em28xx: rename function em28xx_uninit_isoc to em28xx_uninit_usb_xfer
This function will be used to uninitialize USB bulk transfers, too.
Also rename the local variable isoc_bufs to usb_bufs.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 17:57:41 -02:00
Frank Schaefer 836e93bf6a [media] em28xx: update description of em28xx_irq_callback
em28xx_irq_callback can be used for isoc and bulk transfers.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 17:57:27 -02:00
Frank Schaefer 74209dc06a [media] em28xx: rename struct em28xx_usb_isoc_ctl to em28xx_usb_ctl
Also rename the corresponding field isoc_ctl in struct em28xx
to usb_ctl.
We will use this struct for USB bulk transfers, too.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 17:56:49 -02:00
Frank Schaefer f0fa9936f5 [media] em28xx: rename struct em28xx_usb_isoc_bufs to em28xx_usb_bufs
It will be used for USB bulk transfers, too.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 17:56:34 -02:00
Frank Schaefer 515688a898 [media] em28xx: rename isoc packet number constants and parameters
Rename EM28XX_NUM_PACKETS to EM28XX_NUM_ISOC_PACKETS and
EM28XX_DVB_MAX_PACKETS to EM28XX_DVB_NUM_ISOC_PACKETS to
clarify that these values are used only for isoc usb transfers.
Also use the term num_packets instead of max_packets, as this
is how these values are used and called in struct urb.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-12-22 17:56:10 -02:00
Mauro Carvalho Chehab 0c0d06cac6 [media] rename most media/video usb drivers to media/usb
Rename all USB drivers with their own directory under
drivers/media/video into drivers/media/usb and update the
building system.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-08-15 16:25:07 -03:00
Renamed from drivers/media/video/em28xx/em28xx-core.c (Browse further)