public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] em28xx: Fix dual transport stream use
@ 2018-06-27 19:41 Brad Love
  2018-06-27 19:41 ` [PATCH] em28xx: Fix dual transport stream operation Brad Love
  2018-06-28  9:10 ` [PATCH] [RFC] em28xx: Fix dual transport stream use Mauro Carvalho Chehab
  0 siblings, 2 replies; 8+ messages in thread
From: Brad Love @ 2018-06-27 19:41 UTC (permalink / raw)
  To: linux-media, mchehab, dheitmueller; +Cc: Brad Love

When dual transport stream support was added the call to set
alt mode on the USB interface was moved to em28xx_dvb_init.
This was reported to break streaming for a device, so the
call was re-added to em28xx_start_streaming.

Commit 509f89652f83 ("media: em28xx: fix a regression with HVR-950")

This regression fix however broke dual transport stream support.
When a tuner starts streaming it sets alt mode on the USB interface.
The problem is both tuners share the same USB interface, so when
the second tuner becomes active and sets alt mode on the interface
it kills streaming on the other port.

It was suggested add a refcount somewhere and only set alt mode if
no tuners are currently active on the interface. This requires
sharing some state amongst both tuner devices, with appropriate
locking.

What I've done here is the following:
- Add a usage_count pointer to struct em28xx
- Share usage_count between both em28xx devices
- Only set alt mode if usage_count is zero
- Increment usage_count when each tuner becomes active
- Decrement usage_count when a tuner becomes idle

With usage_count in the main em28xx struct, locking is handled as
follows:
- if a secondary tuner exists, lock dev->dev_next->lock
- if no secondary tuner exists, lock dev->lock

By using the above scheme a single tuner device, will lock itself,
the first tuner in a dual tuner device will lock the second tuner,
and the second tuner in a dual tuner device will lock itself aka
the second tuner instance.

This is a perhaps a little hacky, which is why I've added the RFC.
A quick solution was required though, so I don't fix a couple
newer Hauppauge devices, just to break a lot of older ones.


Brad Love (1):
  em28xx: Fix dual transport stream operation

 drivers/media/usb/em28xx/em28xx-cards.c |  6 ++++-
 drivers/media/usb/em28xx/em28xx-dvb.c   | 47 +++++++++++++++++++++++++++++++--
 drivers/media/usb/em28xx/em28xx.h       |  1 +
 3 files changed, 51 insertions(+), 3 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-06-29  0:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-27 19:41 [PATCH] [RFC] em28xx: Fix dual transport stream use Brad Love
2018-06-27 19:41 ` [PATCH] em28xx: Fix dual transport stream operation Brad Love
2018-06-27 19:46   ` Brad Love
2018-06-28  9:10 ` [PATCH] [RFC] em28xx: Fix dual transport stream use Mauro Carvalho Chehab
2018-06-28 14:23   ` Brad Love
2018-06-28 17:33     ` Brad Love
2018-06-28 18:43       ` Mauro Carvalho Chehab
2018-06-29  0:21         ` Brad Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox