Hi Shuah and others,
Shuah Khan wrote:
Add media token device resource framework to allow sharing resources such as tuner, dma, audio etc. across media drivers and non-media sound drivers that control media hardware. The Media token resource is created at the main struct device that is common to all drivers that claim various pieces of the main media device, which allows them to find the resource using the main struct device. As an example, digital, analog, and snd-usb-audio drivers can use the media token resource API using the main struct device for the interface the media device is attached to.
This patch series consists of media token resource framework and changes to use it in dvb-core, v4l2-core, au0828 driver, and snd-usb-audio driver.
With these changes dvb and v4l2 can share the tuner without disrupting each other. Used tvtime, xawtv, kaffeine, and vlc, vlc audio capture option, arecord/aplay during development to identify v4l2 vb2 and vb1 ioctls and file operations that disrupt the digital stream and would require changes to check tuner ownership prior to changing the tuner configuration. vb2 changes are made in the v4l2-core and vb1 changes are made in the au0828 driver to encourage porting drivers to vb2 to advantage of the new media token resource framework with changes in the core.
I know this comes quite late after the first patch series has been sent, but I'd like to ask if you have you considered a different approach: rather than implementing something entirely new, the Media controller can almost do this already. It models the physical layout of the device, instead of creating special use case specific Media entity like constructs for tuner and audio. Also the Media token framework does not appear to be as a perfect match for the Media controller framework which is also planned to be used by DVB already:
URL:http://linuxtv.org/news.php?entry=2014-10-21.mchehab; look for "3) DVB API improvements". There have been ALSA MC patches as well but I'm not aware of the status of those at the moment.
The tokens appear much like media entities of specific kind to me.
Currently, media entities may only be entities bound to a given subsystem, but I don't think it has to (or perhaps even may) stay that way.
In case of the Media controller, mutual exclusion of different users is currently performed by adding the entities to a pipeline and incrementing the streaming count once streaming is enabled --- on different interfaces streaming may mean a different thing.
The Media controller interface does not handle serialising potential users that may wish to configure the device. If that's needed then we'll need to think how to add it.