01 Apr, 2016

5 commits

  • Extending the lifetime of the media_device struct is not handled well
    by the core, as it will erase some data from the struct, when
    media_device_cleanup() is called after unregistering it.

    While we have a fixup patch for it already, the usage of those new
    functions are needed only when we share data with other drivers.

    So, better to revert the changes.

    This reverts commit 182dde7c5d4c ("[media] media: au0828 change
    to use Managed Media Controller API")

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • The au0828 dev_state is actually a bit mask. It should not be
    checking with "==" but, instead, with a logic and. There are some
    places where it was doing it wrong.

    Fix that by replacing the dev_state set/clear/test with the
    bitops.

    As reviewed by Shuah:
    "Looks good. Tested running bind/unbind au0828 loop for 1000 times.
    Didn't see any problems and the v4l2_querycap() problem has been
    fixed with this patch.

    After the above test, ran bind/unbind snd_usb_audio 1000 times.
    Didn't see any problems. Generated media graph and the graph
    looks good."

    Cc: stable@vger.kernel.org
    Reviewed-by: Shuah Khan
    Tested-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • au0828_v4l2_close() check for dev_state == DEV_DISCONNECTED will fail to
    detect the device disconnected state correctly, if au0828_v4l2_open() runs
    to set the DEV_INITIALIZED bit. A loop test of bind/unbind found this bug
    by increasing the likelihood of au0828_v4l2_open() occurring while unbind
    is in progress. When au0828_v4l2_close() fails to detect that the device
    is in disconnect state, it attempts to power down the device and fails with
    the following general protection fault:

    [ 260.992962] Call Trace:
    [ 260.993008] [] ? xc5000_sleep+0x8f/0xd0 [xc5000]
    [ 260.993095] [] ? fe_standby+0x3c/0x50 [tuner]
    [ 260.993186] [] au0828_v4l2_close+0x53c/0x620 [au0828]
    [ 260.993298] [] v4l2_release+0xf0/0x210 [videodev]
    [ 260.993382] [] __fput+0x1fc/0x6c0
    [ 260.993449] [] ____fput+0xe/0x10
    [ 260.993519] [] task_work_run+0x133/0x1f0
    [ 260.993602] [] exit_to_usermode_loop+0x140/0x170
    [ 260.993681] [] syscall_return_slowpath+0x16a/0x1a0
    [ 260.993754] [] entry_SYSCALL_64_fastpath+0xa6/0xa8

    Cc: stable@vger.kernel.org
    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • Fix to clear enable/disable/change source handlers in the media device
    when media device is unregistered in au0828_unregister_media_device().
    When au0828 module is removed, snd-usb-audio shouldn't call the handlers.
    Clearing will ensure snd-usb-audio won't call them once au0828 is removed.

    [mchehab@osg.samsung.com: fix a compilation breakage]
    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • For au0828_enable_source() to work, the tuner links should be
    disabled and the tuner/decoder should be cached at au0828 struct.

    While here, put dev->decoder cache together with dev->tuner, as
    it makes easier to drop both latter if/when we move the enable
    routines to the V4L2 core.

    Fixes: 9822f4173f84 ('[media] au0828: use v4l2_mc_create_media_graph()')

    Signed-off-by: Mauro Carvalho Chehab
    Reviewed-by: Shuah Khan
    Tested-by: Shuah Khan

    Mauro Carvalho Chehab
     

11 Mar, 2016

3 commits


05 Mar, 2016

2 commits

  • Some functions in the au0828 driver are only used when CONFIG_MEDIA_CONTROLLER
    is enabled, and otherwise defined as empty functions:

    media/usb/au0828/au0828-core.c:208:13: error: 'au0828_media_graph_notify' defined but not used [-Werror=unused-function]
    media/usb/au0828/au0828-core.c:262:12: error: 'au0828_enable_source' defined but not used [-Werror=unused-function]
    media/usb/au0828/au0828-core.c:412:13: error: 'au0828_disable_source' defined but not used [-Werror=unused-function]

    This moves the #ifdef so the entire definitions are hidden in this case.

    [mchehab@osg.samsung.com: As pointed by Shuah Khan, a return 0 can be removed]

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Mauro Carvalho Chehab

    Arnd Bergmann
     
  • EMP202 chip inside Terratec Grabby (hw rev 2) seems to require some time
    before accessing reliably its registers. Otherwise it returns some values
    previously put on the I2C bus.

    To account for that period, we delay card setup until we have a proof that
    accessing AC97 registers is reliable. We get this proof by polling
    AC97_RESET until the expected value is read. We also check that unrelated
    registers don't return the same value. This second check handles the case
    where the expected value is constantly returned no matter which register
    is accessed.

    Signed-off-by: Matthieu Rogez
    Signed-off-by: Mauro Carvalho Chehab

    Matthieu Rogez
     

04 Mar, 2016

6 commits

  • When snd_usb_audio gets probed first, audio mixer doesn't get linked to
    the decoder.

    Change au0828_media_graph_notify() to handle the mixer entity getting
    registered before the decoder.

    Change au0828_media_device_register() to invoke
    au0828_media_graph_notify() to connect entites that were created prior
    to registering the notify handler.

    Signed-off-by: Shuah Khan
    Reported-by: Mauro Carvalho Chehab
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • TeVii S662 is a USB 2.0 DVB-S2 tuner that's identical to TechnoTrend
    S2-4600 tuner. Add the USB ID to dw2102 driver.

    Signed-off-by: Olli Salonen
    Signed-off-by: Mauro Carvalho Chehab

    Olli Salonen
     
  • ts2020.h was already included a few lines earlier. Remove the unnecessary entry.

    Signed-off-by: Olli Salonen
    Signed-off-by: Mauro Carvalho Chehab

    Olli Salonen
     
  • Terratec Grabby (hw rev 2) Record led is connected to GPIO 3
    and its logic is inverted: (PIO3 = 0: on, PIO3 = 1: off).

    Signed-off-by: Matthieu Rogez
    Signed-off-by: Mauro Carvalho Chehab

    Matthieu Rogez
     
  • Terratec Grabby (hw rev 2) REC button uses the standard snapshot button
    configuration.

    Signed-off-by: Matthieu Rogez
    Signed-off-by: Mauro Carvalho Chehab

    Matthieu Rogez
     
  • The cleanup that changed the em28xx driver to use v4l2_mc_create_media_graph
    instead of its own implementation causes a build error when CONFIG_MEDIA_CONTROLLER
    is disabled:

    drivers/media/usb/em28xx/em28xx-video.c: In function 'em28xx_v4l2_init':
    drivers/media/usb/em28xx/em28xx-video.c:2717:38: error: 'struct em28xx' has no member named 'media_dev'

    This puts the new code inside the same #ifdef that controls the presence
    of the 'media_dev' member, and that the old code was in.

    Fixes: de39078779cb ("[media] em2xx: use v4l2_mc_create_media_graph()")

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Mauro Carvalho Chehab

    Arnd Bergmann
     

03 Mar, 2016

8 commits


01 Mar, 2016

4 commits

  • As warned by smatch:
    drivers/media/usb/dvb-usb/technisat-usb2.c:263 technisat_usb2_set_led() error: doing dma on the stack (led)
    drivers/media/usb/dvb-usb/technisat-usb2.c:280 technisat_usb2_set_led_timer() error: doing dma on the stack (&b)
    drivers/media/usb/dvb-usb/technisat-usb2.c:341 technisat_usb2_identify_state() error: doing dma on the stack (version)
    drivers/media/usb/dvb-usb/technisat-usb2.c:609 technisat_usb2_get_ir() error: doing dma on the stack (buf)
    drivers/media/usb/dvb-usb/technisat-usb2.c:619 technisat_usb2_get_ir() error: doing dma on the stack (buf)

    Create a buffer at the device state and use it for all the DMA
    transfers.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • As warned by smatch:
    drivers/media/usb/airspy/airspy.c:541 airspy_start_streaming() warn: test_bit() takes a bit number
    drivers/media/usb/airspy/airspy.c:569 airspy_start_streaming() warn: test_bit() takes a bit number
    drivers/media/usb/airspy/airspy.c:605 airspy_stop_streaming() warn: test_bit() takes a bit number

    set_bit/clear_bit argument is the bit number, and not 1 << bit.

    Thankfully, one of the bits was not used (URB_BUF), with would
    otherwise cause a driver misfunctioning.

    Clean this mess by always using set_bit/clear_bit/test_bit and
    removing the unused bit.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Remove the unused ovfx2_vga_mode/ovfx2_cif_mode arrays from the ov519
    driver.

    Signed-off-by: Hans de Goede
    Signed-off-by: Mauro Carvalho Chehab

    Hans de Goede
     
  • Fix the ov519 driver not working (unable to talk to the sensor) when
    plugged into a xhci host. The root cause here is that uhci/ohci/ehci
    hosts typically will send any pending async requests every milli-second
    and then go to sleep for the rest if the milli-second, where as xhci hosts
    send them immediately, causing things to go too fast for the ov519 bridge.

    This commit adds a few delays fixing this.

    Signed-off-by: Wesley Post
    [hdegoede@redhat.com: Also add delays to w996Xcf.c, as that needs them too]
    Signed-off-by: Hans de Goede

    Signed-off-by: Mauro Carvalho Chehab

    Wesley Post
     

27 Feb, 2016

8 commits

  • Change au0828 to check if tuner is free or not before changing tuner
    configuration.

    vidioc_g_tuner(), and au0828_v4l2_close() now call v4l-core interface
    v4l_enable_media_source() before changing tuner configuration.

    Remove au0828_enable_analog_tuner() as it is no longer needed because
    v4l2-core implements common interfaces to check for media source
    availability.

    In addition, queue_setup() no longer needs the tuner availability check
    since v4l2-core does it.

    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • Add enable_source and disable_source handlers. The enable source handler
    is called from v4l2-core, dvb-core, and ALSA drivers to check if the
    shared media source is free.

    The disable source handler is called to release the shared media
    source.

    [mchehab@osg.samsung.com: fix merge conflicts]

    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • Register entity_notify async hook to create links between existing
    bridge driver entities and a newly added non-bridge driver entities. For
    example, this handler creates link between V4L decoder entity and ALSA
    mixer entity.

    [mchehab@osg.samsung.com: fix merge conflicts and make
    au0828_media_graph_notify static to shut up a warning]

    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • Change au0828_create_media_graph() to find and disable
    tuner and demod link. This helps avoid an additional
    disable step when tuner is requested by video or audio.

    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • Create tuner to demod pad link in disabled state to avoid disable step
    when tuner resource is requested by dvb.

    [mchehab@osg.samsung.com: fix a merge conflict]

    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • Media device initialization and registration steps are split. There is a
    window between media device init and media device register during usb
    probe.

    au0828 bridge driver and snd-usb-audio could try to initialize the media
    device, if they simply checked, whether the device has been registered.
    They also need to check whether the device has been initialized.

    Change the au0828-core to check if media device is already initialized
    during initialization step and check if media device is already
    registered during the registration step.

    [mchehab@osg.samsung.com: fix a merge conflict]
    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • Change au0828 to use Managed Media Controller API to share media device
    and coordinate creating/deleting the shared media device with the
    snd-usb-audio driver. The shared media device is created as device
    resource of the parent usb device of the two drivers.

    Populate media device model with USB Device product name instead of
    au0828 device board name. This change is necessary because, if the media
    device is registered by the snd-usb-audio driver first, and it doesn't
    know the au0828 board name.

    [mchehab@osg.samsung.com: Fix merge conflicts]

    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     
  • Change au0828-core to use au8522_media_pads enum defines
    instead of hard-coding the pad values.

    [mchehab@osg.samsung.com: patch rebased, as the code was
    moved to au0828-video.c. Also added AU8522_PAD_INPUT to the list
    of pad number replacements]

    Signed-off-by: Shuah Khan
    Signed-off-by: Mauro Carvalho Chehab

    Shuah Khan
     

23 Feb, 2016

4 commits

  • That fixes the following smatch warning:
    drivers/media/usb/pvrusb2/pvrusb2-hdw.c:4909 pvr2_hdw_state_log_state() error: buffer overflow 'buf' 256

    Mauro Carvalho Chehab
     
  • The buffer_complete() routine assumes that sp is not NULL,
    otherwise it will fail completely. Btw, this is also
    assumed at pvr2_buffer_queue(), with is the routine that
    setups the URB handling.

    So, remove the bogus for the callback at buffer_complete.

    This fix this smatch warning:
    drivers/media/usb/pvrusb2/pvrusb2-io.c:476 buffer_complete() warn: variable dereferenced before check 'sp' (see line 472)

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Right now, media_device_pci_init and media_device_usb_init does
    media_device allocation internaly. That preents its usage when
    the media_device struct is embedded on some other structure.

    Move memory allocation outside it, to make it more generic.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Those ancillary functions could be called even when compiled
    without V4L2 support, as warned by ktest build robot:

    All errors (new ones prefixed by >>):

    >> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/dvb-usb/dvb-usb.ko] undefined!
    >> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/dvb-usb-v2/dvb_usb_v2.ko] undefined!
    >> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/au0828/au0828.ko] undefined!

    Also, there's nothing there that are specific to V4L2. So, move
    those ancillary functions to MC core.

    No functional changes. Just function rename.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab