Sharing media resources across ALSA and au0828 drivers
Subsystems (4)
v3 cover Sharing media resources across ALSA and au0828 drivers
This patch series updates ALSA driver, and au0828 core driver to use Managed Media controller API and Media Controller API to share media resource (tuner).
This Patch v3 series is based on linux_media master. This work addresses Mauro and Takashi's comments on Patch v2 series.
Changes since Patch v2 series:
- Added documentation for uapi and new MC interfaces
1. Ran make for documentation and Mauro's doc script. Thanks for sharing the script.
- Updated commit logs as needed for clarity.
- media: v4l-core add enable/disable source common interfaces Addressed comments - added static inlines in header file
- media: dvb-frontend invoke enable/disable_source handlers Moved the patch after enable/disable handlers and left pipe in dvb_frontend_private
- media: au0828 video remove au0828_enable_analog_tuner() and
media: au0828 video change to use v4l_enable_media_source()
1. Collapsed these two patches - it doesn't make sense to keep them separate. Also added FIXME as per Mauro's suggestion.
- media: au0828 change to use Managed Media Controller API
1. Added comment explaining the need for using udev->product
instead of dev->board.name
- media: au0828 add enable, disable source handlers
1. Changed to handle S-Video and Composite inputs.
2. Fixed a bug that lets Video in when ALSA holds the source.
3. Added comments to one FIXME for s_input changes. Fix is in progress and will send it in a day or two combined with other issues found in au0828 video in the way it handles input. Doesn't impact this routine, changes are all in au0828-video.
- sound/usb: Use Media Controller API to share media resources
1. Addressed comments from Mauro and Takashi about void pointer use.
2. Fixed kbuildbot error when MEDIA_SUPPORT=m
- Dropped media: Ensure media device unregister is done only once Device removal worked without any changes to media unregister path. This work isn't necessary.
Shuah Khan (22):
[media] Docbook: media-types.xml: Add ALSA Media Controller Intf types uapi/media.h: Declare interface types for ALSA
[media] Docbook: media-types.xml: Add Audio Function Entities
media: Add ALSA Media Controller function entities
media: Media Controller register/unregister entity_notify API
media: Media Controller enable/disable source handler API
media: Media Controller export non locking __media_entity_setup_link()
edia: Media Controller non-locking
__media_entity_pipeline_start/stop()
media: v4l-core add enable/disable source common interfaces
media: Move au8522_media_pads enum to au8522.h from au8522_priv.h
media: au8522 change to create MC pad for ALSA Audio Out
media: au0828 Use au8522_media_pads enum for pad defines
media: Change v4l-core to check if source is free
media: au0828 change to use Managed Media Controller API
media: au0828 handle media_init and media_register window
media: au0828 create tuner to decoder link in disabled state
media: au0828 disable tuner to demod link
media: au0828-core register entity_notify hook
media: au0828 add enable, disable source handlers
media: dvb-frontend invoke enable/disable_source handlers
media: au0828 video change to use v4l_enable_media_source() sound/usb: Use Media Controller API to share media resources
Documentation/DocBook/media/v4l/media-types.xml | 52 ++++ drivers/media/dvb-core/dvb_frontend.c | 135 ++-------- drivers/media/dvb-frontends/au8522.h | 8 + drivers/media/dvb-frontends/au8522_decoder.c | 1 + drivers/media/dvb-frontends/au8522_priv.h | 8 - drivers/media/media-device.c | 42 +++ drivers/media/media-entity.c | 51 +++- drivers/media/usb/au0828/au0828-core.c | 325 ++++++++++++++++++++++-- drivers/media/usb/au0828/au0828-video.c | 102 +++----- drivers/media/usb/au0828/au0828.h | 6 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-fh.c | 2 + drivers/media/v4l2-core/v4l2-ioctl.c | 30 +++ drivers/media/v4l2-core/v4l2-mc.c | 52 ++++ drivers/media/v4l2-core/videobuf2-core.c | 4 + include/media/media-device.h | 86 +++++++ include/media/media-entity.h | 19 ++ include/media/v4l2-dev.h | 1 + include/media/v4l2-mc.h | 65 +++++ include/uapi/linux/media.h | 17 ++ sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 + sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++ sound/usb/media.h | 72 ++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 +- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 31 files changed, 1240 insertions(+), 220 deletions(-) create mode 100644 drivers/media/v4l2-core/v4l2-mc.c create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.h
Signature · 1 line
2.5.0
PATCH v3 1/22 Docbook: media-types.xml: Add ALSA Media Controller Intf types
Add ALSA Media Controller Intf types
--- Documentation/DocBook/media/v4l/media-types.xml | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
Documentation/DocBook/media/v4l/media-types.xml +40 -0
@@ -193,6 +193,46 @@ <entry>Device node interface for Software Defined Radio (V4L)</entry> <entry>typically, /dev/swradio?</entry> </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_PCM_CAPTURE</constant></entry> + <entry>Device node interface for ASLA PCM Capture</entry> + <entry>typically, /dev/snd/pcmC?D?c</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_PCM_PLAYBACK</constant></entry> + <entry>Device node interface for ASLA PCM Playback</entry> + <entry>typically, /dev/snd/pcmC?D?p</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_CONTROL</constant></entry> + <entry>Device node interface for ASLA Control</entry> + <entry>typically, /dev/snd/controlC?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_COMPRESS</constant></entry> + <entry>Device node interface for ASLA Compress</entry> + <entry>typically, /dev/snd/compr?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_RAWMIDI</constant></entry> + <entry>Device node interface for ASLA Raw MIDI</entry> + <entry>typically, /dev/snd/midi?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_HWDEP</constant></entry> + <entry>Device node interface for ASLA Hardware Dependent</entry> + <entry>typically, /dev/snd/hwC?D?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_SEQUENCER</constant></entry> + <entry>Device node interface for ASLA Sequencer</entry> + <entry>typically, /dev/snd/seq</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_TIMER</constant></entry> + <entry>Device node interface for ASLA Timer</entry> + <entry>typically, /dev/snd/timer</entry> + </row> </tbody> </tgroup> </table>
Signature · 1 line
2.5.0
Re: [PATCH v3 01/22] [media] Docbook: media-types.xml: Add ALSA Media Controller Intf types
Em Thu, 11 Feb 2016 16:41:17 -0700
Shuah Khan <[email protected]> escreveu:
Quoted 44 lines
Add ALSA Media Controller Intf types
Signed-off-by Shuah Khan <[email protected]>--- Documentation/DocBook/media/v4l/media-types.xml | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+)Documentation/DocBook/media/v4l/media-types.xml +29
-0@@ -193,6 +193,46 @@ <entry>Device node interface for Software Defined Radio (V4L)</entry> <entry>typically, /dev/swradio?</entry> </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_PCM_CAPTURE</constant></entry> + <entry>Device node interface for ASLA PCM Capture</entry> + <entry>typically, /dev/snd/pcmC?D?c</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_PCM_PLAYBACK</constant></entry> + <entry>Device node interface for ASLA PCM Playback</entry> + <entry>typically, /dev/snd/pcmC?D?p</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_CONTROL</constant></entry> + <entry>Device node interface for ASLA Control</entry> + <entry>typically, /dev/snd/controlC?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_COMPRESS</constant></entry> + <entry>Device node interface for ASLA Compress</entry> + <entry>typically, /dev/snd/compr?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_RAWMIDI</constant></entry> + <entry>Device node interface for ASLA Raw MIDI</entry> + <entry>typically, /dev/snd/midi?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_HWDEP</constant></entry> + <entry>Device node interface for ASLA Hardware Dependent</entry> + <entry>typically, /dev/snd/hwC?D?</entry>
Documentation/DocBook/media/v4l/media-types.xml line 234
Quoted 10 lines
Documentation/DocBook/media/v4l/media-types.xml +10
-0+ </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_SEQUENCER</constant></entry> + <entry>Device node interface for ASLA Sequencer</entry> + <entry>typically, /dev/snd/seq</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_TIMER</constant></entry> + <entry>Device node interface for ASLA Timer</entry> + <entry>typically, /dev/snd/timer</entry>
On all the above:
s,ASLA,ALSA,
Except for that, patch looks OK for me.
Takashi,
If this is OK for you too, could you please ack?
Thanks,
Mauro
Re: [PATCH v3 01/22] [media] Docbook: media-types.xml: Add ALSA Media Controller Intf types
Quoted 52 lines · Mauro Carvalho Chehab
Em Thu, 11 Feb 2016 16:41:17 -0700
Shuah Khan <[email protected]> escreveu:Quoted 49 lines
Add ALSA Media Controller Intf types
Signed-off-by Shuah Khan <[email protected]>--- Documentation/DocBook/media/v4l/media-types.xml | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+)Documentation/DocBook/media/v4l/media-types.xml +34
-0@@ -193,6 +193,46 @@ <entry>Device node interface for Software Defined Radio (V4L)</entry> <entry>typically, /dev/swradio?</entry> </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_PCM_CAPTURE</constant></entry> + <entry>Device node interface for ASLA PCM Capture</entry> + <entry>typically, /dev/snd/pcmC?D?c</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_PCM_PLAYBACK</constant></entry> + <entry>Device node interface for ASLA PCM Playback</entry> + <entry>typically, /dev/snd/pcmC?D?p</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_CONTROL</constant></entry> + <entry>Device node interface for ASLA Control</entry> + <entry>typically, /dev/snd/controlC?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_COMPRESS</constant></entry> + <entry>Device node interface for ASLA Compress</entry> + <entry>typically, /dev/snd/compr?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_RAWMIDI</constant></entry> + <entry>Device node interface for ASLA Raw MIDI</entry> + <entry>typically, /dev/snd/midi?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_HWDEP</constant></entry> + <entry>Device node interface for ASLA Hardware Dependent</entry> + <entry>typically, /dev/snd/hwC?D?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_SEQUENCER</constant></entry> + <entry>Device node interface for ASLA Sequencer</entry> + <entry>typically, /dev/snd/seq</entry>
Quoted 8 lines
Documentation/DocBook/media/v4l/media-types.xml line 234
Quoted 5 lines
Documentation/DocBook/media/v4l/media-types.xml +5
-0+ </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_TIMER</constant></entry> + <entry>Device node interface for ASLA Timer</entry> + <entry>typically, /dev/snd/timer</entry>On all the above:
s,ASLA,ALSA,
Sorry for the typo. Sent v4 with the fix.
Quoted 10 lines
Except for that, patch looks OK for me.
Takashi,
If this is OK for you too, could you please ack?
Thanks,
Mauro
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Re: [PATCH v3 01/22] [media] Docbook: media-types.xml: Add ALSA Media Controller Intf types
In reply to Mauro Carvalho ChehabQuoted 61 lines · Mauro Carvalho Chehab
Em Thu, 11 Feb 2016 16:41:17 -0700
Shuah Khan <[email protected]> escreveu:Quoted 44 lines
Add ALSA Media Controller Intf types
Signed-off-by Shuah Khan <[email protected]>--- Documentation/DocBook/media/v4l/media-types.xml | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+)Documentation/DocBook/media/v4l/media-types.xml +29
-0@@ -193,6 +193,46 @@ <entry>Device node interface for Software Defined Radio (V4L)</entry> <entry>typically, /dev/swradio?</entry> </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_PCM_CAPTURE</constant></entry> + <entry>Device node interface for ASLA PCM Capture</entry> + <entry>typically, /dev/snd/pcmC?D?c</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_PCM_PLAYBACK</constant></entry> + <entry>Device node interface for ASLA PCM Playback</entry> + <entry>typically, /dev/snd/pcmC?D?p</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_CONTROL</constant></entry> + <entry>Device node interface for ASLA Control</entry> + <entry>typically, /dev/snd/controlC?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_COMPRESS</constant></entry> + <entry>Device node interface for ASLA Compress</entry> + <entry>typically, /dev/snd/compr?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_RAWMIDI</constant></entry> + <entry>Device node interface for ASLA Raw MIDI</entry> + <entry>typically, /dev/snd/midi?</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_HWDEP</constant></entry> + <entry>Device node interface for ASLA Hardware Dependent</entry> + <entry>typically, /dev/snd/hwC?D?</entry>Documentation/DocBook/media/v4l/media-types.xml line 234
Quoted 10 lines
Documentation/DocBook/media/v4l/media-types.xml +10
-0+ </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_SEQUENCER</constant></entry> + <entry>Device node interface for ASLA Sequencer</entry> + <entry>typically, /dev/snd/seq</entry> + </row> + <row> + <entry><constant>MEDIA_INTF_T_ALSA_TIMER</constant></entry> + <entry>Device node interface for ASLA Timer</entry> + <entry>typically, /dev/snd/timer</entry>On all the above:
s,ASLA,ALSA,
Quoted 6 lines
Except for that, patch looks OK for me.
Takashi,
If this is OK for you too, could you please ack?
Hi Takashi/Mauro,
I send Patch v4 for just this patch to fix the above.
Takashi,
Could you please Ack if you are okay with this.
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
PATCH v3 2/22 uapi/media.h: Declare interface types for ALSA
In reply to Shuah KhanDeclare the interface types to be used on alsa for the new G_TOPOLOGY ioctl.
--- drivers/media/media-entity.c | 16 ++++++++++++++++ include/uapi/linux/media.h | 10 ++++++++++ 2 files changed, 26 insertions(+)
drivers/media/media-entity.c +16 -0
@@ -65,6 +65,22 @@ static inline const char *intf_type(struct media_interface *intf)return "v4l2-subdev" ;case MEDIA_INTF_T_V4L_SWRADIO :return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm-capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm-playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa-control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +case MEDIA_INTF_T_ALSA_SEQUENCER : +return "sequencer" ; +case MEDIA_INTF_T_ALSA_TIMER : +return "timer" ;default :return "unknown-intf" ; }
include/uapi/linux/media.h +10 -0
@@ -265,6 +265,7 @@ struct media_links_enum {#define MEDIA_INTF_T_DVB_BASE 0x00000100#define MEDIA_INTF_T_V4L_BASE 0x00000200 +#define MEDIA_INTF_T_ALSA_BASE 0x00000300/* Interface types */
@@ -280,6 +281,15 @@ struct media_links_enum {#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1) +#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) +#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6) +#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7) +/* * MC next gen API definitions *
Signature · 1 line
2.5.0
Re: [PATCH v3 02/22] uapi/media.h: Declare interface types for ALSA
Em Thu, 11 Feb 2016 16:41:18 -0700
Shuah Khan <[email protected]> escreveu:
Quoted 54 lines
Declare the interface types to be used on alsa for the new
G_TOPOLOGYioctl.Signed-off-by Shuah Khan <[email protected]>--- drivers/media/media-entity.c | 16 ++++++++++++++++ include/uapi/linux/media.h | 10 ++++++++++ 2 files changed, 26 insertions(+)drivers/media/media-entity.c +16
-0@@ -65,6 +65,22 @@ static inline const char *intf_type(struct media_interface *intf)return "v4l2-subdev" ;case MEDIA_INTF_T_V4L_SWRADIO :return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm-capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm-playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa-control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +case MEDIA_INTF_T_ALSA_SEQUENCER : +return "sequencer" ; +case MEDIA_INTF_T_ALSA_TIMER : +return "timer" ;default :return "unknown-intf" ; }include/uapi/linux/media.h +3
-0@@ -265,6 +265,7 @@ struct media_links_enum {#define MEDIA_INTF_T_DVB_BASE 0x00000100#define MEDIA_INTF_T_V4L_BASE 0x00000200 +#define MEDIA_INTF_T_ALSA_BASE 0x00000300/* Interface types */ @@ -280,6 +281,15 @@ struct media_links_enum {#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
include/uapi/linux/media.h struct media_links_enum { · line 295
Quoted 10 lines
include/uapi/linux/media.h +7
-0+#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) +#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6) +#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7) +/* * MC next gen API definitions *
Looks OK to me.
Takashi,
If this is OK for you too, would you mind acking it?
Thanks,
Mauro
Re: [PATCH v3 02/22] uapi/media.h: Declare interface types for ALSA
Quoted 70 lines · Mauro Carvalho Chehab
Em Thu, 11 Feb 2016 16:41:18 -0700
Shuah Khan <[email protected]> escreveu:Quoted 54 lines
Declare the interface types to be used on alsa for the new
G_TOPOLOGYioctl.Signed-off-by Shuah Khan <[email protected]>--- drivers/media/media-entity.c | 16 ++++++++++++++++ include/uapi/linux/media.h | 10 ++++++++++ 2 files changed, 26 insertions(+)drivers/media/media-entity.c +16
-0@@ -65,6 +65,22 @@ static inline const char *intf_type(struct media_interface *intf)return "v4l2-subdev" ;case MEDIA_INTF_T_V4L_SWRADIO :return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm-capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm-playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa-control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +case MEDIA_INTF_T_ALSA_SEQUENCER : +return "sequencer" ; +case MEDIA_INTF_T_ALSA_TIMER : +return "timer" ;default :return "unknown-intf" ; }include/uapi/linux/media.h +3
-0@@ -265,6 +265,7 @@ struct media_links_enum {#define MEDIA_INTF_T_DVB_BASE 0x00000100#define MEDIA_INTF_T_V4L_BASE 0x00000200 +#define MEDIA_INTF_T_ALSA_BASE 0x00000300/* Interface types */ @@ -280,6 +281,15 @@ struct media_links_enum {#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)include/uapi/linux/media.h struct media_links_enum { · line 295
Quoted 10 lines
include/uapi/linux/media.h +7
-0+#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) +#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6) +#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7) +/* * MC next gen API definitions * Looks OK to me.
Quoted 4 lines
Takashi,
If this is OK for you too, would you mind acking it?
Hi Takashi,
Are you okay with this patch? Could you please
Ack it.
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Takashi Iwai
Acked-byRe: [PATCH v3 02/22] uapi/media.h: Declare interface types for ALSA
Quoted 74 lines · Shuah Khan
Quoted 72 lines · Mauro Carvalho Chehab
Em Thu, 11 Feb 2016 16:41:18 -0700
Shuah Khan <[email protected]> escreveu:Quoted 54 lines
Declare the interface types to be used on alsa for the new
G_TOPOLOGYioctl.Signed-off-by Shuah Khan <[email protected]>--- drivers/media/media-entity.c | 16 ++++++++++++++++ include/uapi/linux/media.h | 10 ++++++++++ 2 files changed, 26 insertions(+)drivers/media/media-entity.c +16
-0@@ -65,6 +65,22 @@ static inline const char *intf_type(struct media_interface *intf)return "v4l2-subdev" ;case MEDIA_INTF_T_V4L_SWRADIO :return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm-capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm-playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa-control" ; +case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +case MEDIA_INTF_T_ALSA_SEQUENCER : +return "sequencer" ; +case MEDIA_INTF_T_ALSA_TIMER : +return "timer" ;default :return "unknown-intf" ; }include/uapi/linux/media.h +3
-0@@ -265,6 +265,7 @@ struct media_links_enum {#define MEDIA_INTF_T_DVB_BASE 0x00000100#define MEDIA_INTF_T_V4L_BASE 0x00000200 +#define MEDIA_INTF_T_ALSA_BASE 0x00000300/* Interface types */ @@ -280,6 +281,15 @@ struct media_links_enum {#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)include/uapi/linux/media.h struct media_links_enum { · line 295
Quoted 10 lines
include/uapi/linux/media.h +7
-0+#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) +#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6) +#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7) +/* * MC next gen API definitions * Looks OK to me.
Takashi,
Quoted 7 lines
Quoted 2 lines
If this is OK for you too, would you mind acking it?
Hi Takashi,
Are you okay with this patch? Could you please
Ack it.
Sorry for the late response.
Yes, this definition looks OK to me.
thanks,
Takashi
Re: [PATCH v3 02/22] uapi/media.h: Declare interface types for ALSA
In reply to Shuah KhanQuoted 23 lines · Shuah Khan
Declare the interface types to be used on alsa for the new
G_TOPOLOGYioctl.Signed-off-by Shuah Khan <[email protected]>--- drivers/media/media-entity.c | 16 ++++++++++++++++ include/uapi/linux/media.h | 10 ++++++++++ 2 files changed, 26 insertions(+)drivers/media/media-entity.c +6
-0@@ -65,6 +65,22 @@ static inline const char *intf_type(struct media_interface *intf)return "v4l2-subdev" ;case MEDIA_INTF_T_V4L_SWRADIO :return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm-capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm-playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa-control" ;
drivers/media/media-entity.c static inline const char *intf_type(struct media_interface *intf) · line 83
Quoted 10 lines
drivers/media/media-entity.c +10
-0+case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +case MEDIA_INTF_T_ALSA_SEQUENCER : +return "sequencer" ; +case MEDIA_INTF_T_ALSA_TIMER : +return "timer" ;
Wouldn't it be better to add an 'alsa' prefix for all of these?
And 'dvb-' or 'v4l2-' (or v4l-) for the others as well.
Names like 'timer' are very generic. I think it would be a good idea to make the naming more regular and have it include the subsystem name just as the define does.
Regards,
Hans
Quoted 32 lines
drivers/media/media-entity.c +0
-0default :return "unknown-intf" ; }include/uapi/linux/media.h +10
-0@@ -265,6 +265,7 @@ struct media_links_enum {#define MEDIA_INTF_T_DVB_BASE 0x00000100#define MEDIA_INTF_T_V4L_BASE 0x00000200 +#define MEDIA_INTF_T_ALSA_BASE 0x00000300/* Interface types */ @@ -280,6 +281,15 @@ struct media_links_enum {#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) +#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) +#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1) +#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) +#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) +#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) +#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) +#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6) +#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7) +/* * MC next gen API definitions *
Re: [PATCH v3 02/22] uapi/media.h: Declare interface types for ALSA
Quoted 39 lines · Hans Verkuil
Quoted 23 lines · Shuah Khan
Declare the interface types to be used on alsa for the new
G_TOPOLOGYioctl.Signed-off-by Shuah Khan <[email protected]>--- drivers/media/media-entity.c | 16 ++++++++++++++++ include/uapi/linux/media.h | 10 ++++++++++ 2 files changed, 26 insertions(+)drivers/media/media-entity.c +6
-0@@ -65,6 +65,22 @@ static inline const char *intf_type(struct media_interface *intf)return "v4l2-subdev" ;case MEDIA_INTF_T_V4L_SWRADIO :return "swradio" ; +case MEDIA_INTF_T_ALSA_PCM_CAPTURE : +return "pcm-capture" ; +case MEDIA_INTF_T_ALSA_PCM_PLAYBACK : +return "pcm-playback" ; +case MEDIA_INTF_T_ALSA_CONTROL : +return "alsa-control" ;drivers/media/media-entity.c static inline const char *intf_type(struct media_interface *intf) · line 83
Quoted 10 lines
drivers/media/media-entity.c +10
-0+case MEDIA_INTF_T_ALSA_COMPRESS : +return "compress" ; +case MEDIA_INTF_T_ALSA_RAWMIDI : +return "rawmidi" ; +case MEDIA_INTF_T_ALSA_HWDEP : +return "hwdep" ; +case MEDIA_INTF_T_ALSA_SEQUENCER : +return "sequencer" ; +case MEDIA_INTF_T_ALSA_TIMER : +return "timer" ;Wouldn't it be better to add an 'alsa' prefix for all of these?
And 'dvb-' or 'v4l2-' (or v4l-) for the others as well.
Quoted 8 lines
Names like 'timer' are very generic. I think it would be a good idea to make the naming more regular and have it include the subsystem name just as the define does.
Regards,
Hans
Yes adding more information 'dvb-' or 'v4l2-' (or v4l-), alsa to strings would help. I can fix all of them in a separate patch if that is okay with you.
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
PATCH v3 3/22 Docbook: media-types.xml: Add Audio Function Entities
In reply to Shuah KhanAdd Audio Function Entities
--- Documentation/DocBook/media/v4l/media-types.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+)
Documentation/DocBook/media/v4l/media-types.xml +12 -0
@@ -113,6 +113,18 @@ decoder. </entry> </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_CAPTURE</constant></entry> + <entry>Audio Capture Function Entity.</entry> + </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_PLAYBACK</constant></entry> + <entry>Audio Playback Function Entity.</entry> + </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_MIXER</constant></entry> + <entry>Audio Mixer Function Entity.</entry> + </row> </tbody> </tgroup> </table>
Signature · 1 line
2.5.0
Re: [PATCH v3 03/22] [media] Docbook: media-types.xml: Add Audio Function Entities
Em Thu, 11 Feb 2016 16:41:19 -0700
Shuah Khan <[email protected]> escreveu:
Quoted 20 lines
Add Audio Function Entities
Signed-off-by Shuah Khan <[email protected]>--- Documentation/DocBook/media/v4l/media-types.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+)Documentation/DocBook/media/v4l/media-types.xml +5
-0@@ -113,6 +113,18 @@ decoder. </entry> </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_CAPTURE</constant></entry> + <entry>Audio Capture Function Entity.</entry> + </row> + <row>
Documentation/DocBook/media/v4l/media-types.xml line 130
Quoted 10 lines
Documentation/DocBook/media/v4l/media-types.xml +7
-0+ <entry><constant>MEDIA_ENT_F_AUDIO_PLAYBACK</constant></entry> + <entry>Audio Playback Function Entity.</entry> + </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_MIXER</constant></entry> + <entry>Audio Mixer Function Entity.</entry> + </row> </tbody> </tgroup> </table>
Looks OK to me.
Takashi,
Could you ack if ok for you?
Signature · 2 lines
Thanks, Mauro
Takashi Iwai
Acked-byRe: [PATCH v3 03/22] [media] Docbook: media-types.xml: Add Audio Function Entities
Quoted 37 lines · Mauro Carvalho Chehab
Em Thu, 11 Feb 2016 16:41:19 -0700
Shuah Khan <[email protected]> escreveu:Quoted 20 lines
Add Audio Function Entities
Signed-off-by Shuah Khan <[email protected]>--- Documentation/DocBook/media/v4l/media-types.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+)Documentation/DocBook/media/v4l/media-types.xml +5
-0@@ -113,6 +113,18 @@ decoder. </entry> </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_CAPTURE</constant></entry> + <entry>Audio Capture Function Entity.</entry> + </row> + <row>Documentation/DocBook/media/v4l/media-types.xml line 130
Quoted 10 lines
Documentation/DocBook/media/v4l/media-types.xml +7
-0+ <entry><constant>MEDIA_ENT_F_AUDIO_PLAYBACK</constant></entry> + <entry>Audio Playback Function Entity.</entry> + </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_MIXER</constant></entry> + <entry>Audio Mixer Function Entity.</entry> + </row> </tbody> </tgroup> </table>Looks OK to me.
Quoted 3 lines
Takashi,
Could you ack if ok for you?
Yeah, nothing looks wrong, as it's pretty straightforward :)
thanks,
Takashi
Laurent Pinchart
maintainerRe: [PATCH v3 03/22] [media] Docbook: media-types.xml: Add Audio Function Entities
In reply to Shuah KhanHi Shuah,
Thank you for the patch.
Quoted 14 lines · On Thursday 11 February 2016 16:41:19 Shuah Khan wrote:
Add Audio Function Entities
Signed-off-by Shuah Khan <[email protected]>--- Documentation/DocBook/media/v4l/media-types.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+)(quoted diff) +0
-0
b/Documentation/DocBook/media/v4l/media-types.xmlindex 3730967..924a604 100644Documentation/DocBook/media/v4l/media-types.xml +0
-0@@ -113,6 +113,18 @@ decoder.
Documentation/DocBook/media/v4l/media-types.xml line 123
Quoted 10 lines
Documentation/DocBook/media/v4l/media-types.xml +8
-0</entry> </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_CAPTURE</constant></entry> + <entry>Audio Capture Function Entity.</entry> + </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_PLAYBACK</constant></entry> + <entry>Audio Playback Function Entity.</entry> + </row>
I think this deserves a longer description. From the name and short description I'm not sure what the capture and playback functions are.
Documentation/DocBook/media/v4l/media-types.xml line 127
Quoted 4 lines
Documentation/DocBook/media/v4l/media-types.xml +4
-0+ <row> + <entry><constant>MEDIA_ENT_F_AUDIO_MIXER</constant></entry> + <entry>Audio Mixer Function Entity.</entry> + </row>
Entities can implement multiple functions, so function descriptions shouldn't refer to entity this way. MEDIA_ENT_F_AUDIO_MIXER doesn't mean that the entity is an audio mixer, it means that the entity implements the audio mixer function. If you want to keep the description short you could just write "Audio mixer". A longer description could be "The entity can mix multiple input audio streams to produce an output audio stream.".
Quoted 3 lines
Documentation/DocBook/media/v4l/media-types.xml +0
-0</tbody> </tgroup> </table>
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v3 03/22] [media] Docbook: media-types.xml: Add Audio Function Entities
Quoted 33 lines · Laurent Pinchart
Hi Shuah,
Thank you for the patch.
Quoted 14 lines · On Thursday 11 February 2016 16:41:19 Shuah Khan wrote:
Add Audio Function Entities
Signed-off-by Shuah Khan <[email protected]>--- Documentation/DocBook/media/v4l/media-types.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+)(quoted diff) +0
-0
b/Documentation/DocBook/media/v4l/media-types.xmlindex 3730967..924a604 100644Documentation/DocBook/media/v4l/media-types.xml +0
-0@@ -113,6 +113,18 @@ decoder.Documentation/DocBook/media/v4l/media-types.xml line 123
Quoted 10 lines
Documentation/DocBook/media/v4l/media-types.xml +8
-0</entry> </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_CAPTURE</constant></entry> + <entry>Audio Capture Function Entity.</entry> + </row> + <row> + <entry><constant>MEDIA_ENT_F_AUDIO_PLAYBACK</constant></entry> + <entry>Audio Playback Function Entity.</entry> + </row>I think this deserves a longer description. From the name and short description I'm not sure what the capture and playback functions are.
Quoted 16 lines
Documentation/DocBook/media/v4l/media-types.xml line 127
Quoted 4 lines
Documentation/DocBook/media/v4l/media-types.xml +4
-0+ <row> + <entry><constant>MEDIA_ENT_F_AUDIO_MIXER</constant></entry> + <entry>Audio Mixer Function Entity.</entry> + </row>Entities can implement multiple functions, so function descriptions shouldn't refer to entity this way.
MEDIA_ENT_F_AUDIO_MIXERdoesn't mean that the entity is an audio mixer, it means that the entity implements the audio mixer function. If you want to keep the description short you could just write "Audio mixer". A longer description could be "The entity can mix multiple input audio streams to produce an output audio stream.".Quoted 3 lines
Documentation/DocBook/media/v4l/media-types.xml +0
-0</tbody> </tgroup> </table>
Thanks for the review. I will send a followup patch for this.
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
PATCH v3 4/22 media: Add ALSA Media Controller function entities
In reply to Shuah KhanAdd ALSA Media Controller capture, playback, and mixer function entity defines.
--- include/uapi/linux/media.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/uapi/linux/media.h +7 -0
@@ -98,6 +98,13 @@ struct media_device_info {#define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 42)/* +* Audio Entity Functions +*/ +#define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 200) +#define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 201) +#define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 202) + +/* * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility * with the legacy v1 API.The number range is out of range by purpose:
Signature · 1 line
2.5.0
Re: [PATCH v3 04/22] media: Add ALSA Media Controller function entities
Em Thu, 11 Feb 2016 16:41:20 -0700
Shuah Khan <[email protected]> escreveu:
Quoted 16 lines
Add ALSA Media Controller capture, playback, and mixer function entity defines.
Signed-off-by Shuah Khan <[email protected]>--- include/uapi/linux/media.h | 7 +++++++ 1 file changed, 7 insertions(+)include/uapi/linux/media.h +0
-0@@ -98,6 +98,13 @@ struct media_device_info {#define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 42)/*
include/uapi/linux/media.h struct media_device_info { · line 110
Quoted 10 lines
include/uapi/linux/media.h +7
-0+* Audio Entity Functions +*/ +#define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 200) +#define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 201) +#define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 202) + +/* * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility * with the legacy v1 API.The number range is out of range by purpose:
Looks OK to me.
This won't apply anymore on master, because we changed the numberspace, but it is a trivial conflict. No need to rebase.
Takashi,
If OK for you, please ack.
Signature · 2 lines
Thanks, Mauro
Takashi Iwai
Acked-byRe: [PATCH v3 04/22] media: Add ALSA Media Controller function entities
Quoted 33 lines · Mauro Carvalho Chehab
Em Thu, 11 Feb 2016 16:41:20 -0700
Shuah Khan <[email protected]> escreveu:Quoted 16 lines
Add ALSA Media Controller capture, playback, and mixer function entity defines.
Signed-off-by Shuah Khan <[email protected]>--- include/uapi/linux/media.h | 7 +++++++ 1 file changed, 7 insertions(+)include/uapi/linux/media.h +0
-0@@ -98,6 +98,13 @@ struct media_device_info {#define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 42)/* include/uapi/linux/media.h struct media_device_info { · line 110
Quoted 10 lines
include/uapi/linux/media.h +7
-0+* Audio Entity Functions +*/ +#define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 200) +#define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 201) +#define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 202) + +/* * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility * with the legacy v1 API.The number range is out of range by purpose: Looks OK to me.
Quoted 6 lines
This won't apply anymore on master, because we changed the numberspace, but it is a trivial conflict. No need to rebase.
Takashi,
If OK for you, please ack.
Takashi
PATCH v3 5/22 media: Media Controller register/unregister entity_notify API
In reply to Shuah KhanAdd new interfaces to register and unregister entity_notify hook to media device. These interfaces allow drivers to add hooks to take appropriate actions when new entities get added to a shared media device. For example, au0828 bridge driver registers an entity_notify hook to create links as needed between media graph nodes.
--- drivers/media/media-device.c | 42 +++++++++++++++++++++++++++++++++ include/media/media-device.h | 56 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+)
drivers/media/media-device.c +42 -0
@@ -536,6 +536,7 @@ static void media_device_release(struct media_devnode *mdev)int __must_check media_device_register_entity (struct media_device *mdev,struct media_entity *entity) { +struct media_entity_notify *notify, *next;unsigned int i;int ret;
@@ -575,6 +576,11 @@ int __must_check media_device_register_entity(struct media_device *mdev,media_gobj_create (mdev,MEDIA_GRAPH_PAD , &entity->pads[i].graph_obj); +/* invoke entity_notify callbacks */ +list_for_each_entry_safe (notify, next, &mdev->entity_notify, list) { + (notify)->notify (entity, notify->notify_data); + } +spin_unlock (&mdev->lock);return 0 ;
@@ -608,6 +614,8 @@ static void __media_device_unregister_entity(struct media_entity *entity)/* Remove the entity */ media_gobj_destroy (&entity->graph_obj); +/* invoke entity_notify callbacks to handle entity removal?? */ + entity->graph_obj.mdev =NULL ; }
@@ -640,6 +648,7 @@ void media_device_init(struct media_device *mdev)INIT_LIST_HEAD (&mdev->interfaces);INIT_LIST_HEAD (&mdev->pads);INIT_LIST_HEAD (&mdev->links); +INIT_LIST_HEAD (&mdev->entity_notify);spin_lock_init (&mdev->lock);mutex_init (&mdev->graph_mutex);ida_init (&mdev->entity_internal_idx);
@@ -685,11 +694,40 @@ int __must_check __media_device_register(struct media_device *mdev, }EXPORT_SYMBOL_GPL (__media_device_register); +int __must_check media_device_register_entity_notify (struct media_device *mdev, +struct media_entity_notify *nptr) +{ +spin_lock (&mdev->lock); +list_add_tail (&nptr->list, &mdev->entity_notify); +spin_unlock (&mdev->lock); +return 0 ; +} +EXPORT_SYMBOL_GPL (media_device_register_entity_notify); + +/** +* Note: Should be called with mdev->lock held. +*/ +static void __media_device_unregister_entity_notify (struct media_device *mdev, +struct media_entity_notify *nptr) +{ +list_del (&nptr->list); +} + +void media_device_unregister_entity_notify (struct media_device *mdev, +struct media_entity_notify *nptr) +{ +spin_lock (&mdev->lock); +__media_device_unregister_entity_notify (mdev, nptr); +spin_unlock (&mdev->lock); +} +EXPORT_SYMBOL_GPL (media_device_unregister_entity_notify); +void media_device_unregister (struct media_device *mdev) {struct media_entity *entity;struct media_entity *next;struct media_interface *intf, *tmp_intf; +struct media_entity_notify *notify, *nextp;if (mdev ==NULL )return ;
@@ -706,6 +744,10 @@ void media_device_unregister(struct media_device *mdev)list_for_each_entry_safe (entity, next, &mdev->entities, graph_obj.list)__media_device_unregister_entity (entity); +/* Remove all entity_notify callbacks from the media device */ +list_for_each_entry_safe (notify, nextp, &mdev->entity_notify, list) +__media_device_unregister_entity_notify (mdev, notify); +/* Remove all interfaces from the media device */ list_for_each_entry_safe (intf, tmp_intf, &mdev->interfaces, graph_obj.list) {
include/media/media-device.h +56 -0
86 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v3 6/22 media: Media Controller enable/disable source handler API
In reply to Shuah KhanAdd new fields to struct media_device to add enable_source, and disable_source handlers, and source_priv to stash driver private data that is used to run these handlers. The enable_source handler finds source entity for the passed in entity and checks if it is available. When link is found, it activates it. Disable source handler deactivates the link.
Bridge driver is expected to implement and set these handlers.
--- include/media/media-device.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
include/media/media-device.h +30 -0
@@ -302,6 +302,11 @@ struct media_entity_notify {* @entity_notify: List of registered entity_notify callbacks * @lock: Entities list lock * @graph_mutex: Entities graph operation lock +* +* @source_priv: Driver Private data for enable/disable source handlers +* @enable_source: Enable Source Handler function pointer +* @disable_source: Disable Source Handler function pointer +* * @link_notify: Link state change notification callback * * This structure represents an abstract high-level media device. It allows easy
@@ -313,6 +318,26 @@ struct media_entity_notify {* * @model is a descriptive model name exported through sysfs. It doesn't have to * be unique. +* +* @enable_source is a handler to find source entity for the +* sink entity and activate the link between them if source +* entity is free. Drivers should call this handler before +* accessing the source. +* +* @disable_source is a handler to find source entity for the +* sink entity and deactivate the link between them. Drivers +* should call this handler to release the source. +* +* Note: Bridge driver is expected to implement and set the +* handler when media_device is registered or when +* bridge driver finds the media_device during probe. +* Bridge driver sets source_priv with information +* necessary to run enable/disable source handlers. +* +* Use-case: find tuner entity connected to the decoder +* entity and check if it is available, and activate the +* the link between them from enable_source and deactivate +* from disable_source. */ struct media_device {/* dev->driver_data points to this struct. */
@@ -344,6 +369,11 @@ struct media_device {/* Serializes graph operations. */ struct mutex graph_mutex; +void *source_priv; +int (*enable_source)(struct media_entity *entity, +struct media_pipeline *pipe); +void (*disable_source)(struct media_entity *entity); +int (*link_notify)(struct media_link *link,u32 flags,unsigned int notification); };
Signature · 1 line
2.5.0
Re: [PATCH v3 06/22] media: Media Controller enable/disable source handler API
Hi Shuah,
Quoted 34 lines · Shuah Khan
Add new fields to struct
media_deviceto addenable_source, anddisable_sourcehandlers, andsource_privto stash driver private data that is used to run these handlers. Theenable_sourcehandler finds source entity for the passed in entity and checks if it is available. When link is found, it activates it. Disable source handler deactivates the link.Bridge driver is expected to implement and set these handlers.
Signed-off-by Shuah Khan <[email protected]>--- include/media/media-device.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)include/media/media-device.h +5
-0@@ -302,6 +302,11 @@ struct media_entity_notify {* @entity_notify: List of registered entity_notify callbacks * @lock: Entities list lock * @graph_mutex: Entities graph operation lock +* +* @source_priv: Driver Private data for enable/disable source handlers +* @enable_source: Enable Source Handler function pointer +* @disable_source: Disable Source Handler function pointer +* * @link_notify: Link state change notification callback * * This structure represents an abstract high-level media device. It allows easy @@ -313,6 +318,26 @@ struct media_entity_notify {* * @model is a descriptive model name exported through sysfs. It doesn't have to * be unique.
include/media/media-device.h struct media_entity_notify { · line 330
Quoted 10 lines
include/media/media-device.h +10
-0+* +* @enable_source is a handler to find source entity for the +* sink entity and activate the link between them if source +* entity is free. Drivers should call this handler before +* accessing the source. +* +* @disable_source is a handler to find source entity for the +* sink entity and deactivate the link between them. Drivers +* should call this handler to release the source. +*
Is there a particular reason you're not simply (de)activating the link, but instead add a new callback?
Quoted 25 lines
include/media/media-device.h +15
-0+* Note: Bridge driver is expected to implement and set the +* handler when media_device is registered or when +* bridge driver finds the media_device during probe. +* Bridge driver sets source_priv with information +* necessary to run enable/disable source handlers. +* +* Use-case: find tuner entity connected to the decoder +* entity and check if it is available, and activate the +* the link between them from enable_source and deactivate +* from disable_source. */ struct media_device {/* dev->driver_data points to this struct. */ @@ -344,6 +369,11 @@ struct media_device {/* Serializes graph operations. */ struct mutex graph_mutex; +void *source_priv; +int (*enable_source)(struct media_entity *entity, +struct media_pipeline *pipe); +void (*disable_source)(struct media_entity *entity); +int (*link_notify)(struct media_link *link,u32 flags,unsigned int notification); };
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v3 06/22] media: Media Controller enable/disable source handler API
Quoted 42 lines · Sakari Ailus
Hi Shuah,
Quoted 39 lines · Shuah Khan
Add new fields to struct
media_deviceto addenable_source, anddisable_sourcehandlers, andsource_privto stash driver private data that is used to run these handlers. Theenable_sourcehandler finds source entity for the passed in entity and checks if it is available. When link is found, it activates it. Disable source handler deactivates the link.Bridge driver is expected to implement and set these handlers.
Signed-off-by Shuah Khan <[email protected]>--- include/media/media-device.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)include/media/media-device.h +10
-0@@ -302,6 +302,11 @@ struct media_entity_notify {* @entity_notify: List of registered entity_notify callbacks * @lock: Entities list lock * @graph_mutex: Entities graph operation lock +* +* @source_priv: Driver Private data for enable/disable source handlers +* @enable_source: Enable Source Handler function pointer +* @disable_source: Disable Source Handler function pointer +* * @link_notify: Link state change notification callback * * This structure represents an abstract high-level media device. It allows easy @@ -313,6 +318,26 @@ struct media_entity_notify {* * @model is a descriptive model name exported through sysfs. It doesn't have to * be unique. +* +* @enable_source is a handler to find source entity for the +* sink entity and activate the link between them if source +* entity is free. Drivers should call this handler before +* accessing the source.
Quoted 8 lines
include/media/media-device.h struct media_entity_notify { · line 330
Quoted 5 lines
include/media/media-device.h +5
-0+* +* @disable_source is a handler to find source entity for the +* sink entity and deactivate the link between them. Drivers +* should call this handler to release the source. +* Is there a particular reason you're not simply (de)activating the link, but instead add a new callback?
These two handlers are separate for a couple of reasons:
1. Explicit and symmetric API is easier to use and maintain. Similar what we do in other cases, register/unregister get/put etc.
2. This is more important. Disable handler makes sure the owner is releasing the resource. Otherwise, when some other application does enable, the owner could loose the resource, if enable and disable are the same.
e.g: Video app is holding the resource, DVB app does enable. Disable handler makes sure Video/owner is the one that is asking to do the release.
thanks,
-- Shuah
Quoted 27 lines
Quoted 26 lines
include/media/media-device.h +15
-0+* Note: Bridge driver is expected to implement and set the +* handler when media_device is registered or when +* bridge driver finds the media_device during probe. +* Bridge driver sets source_priv with information +* necessary to run enable/disable source handlers. +* +* Use-case: find tuner entity connected to the decoder +* entity and check if it is available, and activate the +* the link between them from enable_source and deactivate +* from disable_source. */ struct media_device {/* dev->driver_data points to this struct. */ @@ -344,6 +369,11 @@ struct media_device {/* Serializes graph operations. */ struct mutex graph_mutex; +void *source_priv; +int (*enable_source)(struct media_entity *entity, +struct media_pipeline *pipe); +void (*disable_source)(struct media_entity *entity); +int (*link_notify)(struct media_link *link,u32 flags,unsigned int notification); };
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Re: [PATCH v3 06/22] media: Media Controller enable/disable source handler API
Hi Shuah,
Quoted 52 lines · Shuah Khan
Quoted 42 lines · Sakari Ailus
Hi Shuah,
Quoted 39 lines · Shuah Khan
Add new fields to struct
media_deviceto addenable_source, anddisable_sourcehandlers, andsource_privto stash driver private data that is used to run these handlers. Theenable_sourcehandler finds source entity for the passed in entity and checks if it is available. When link is found, it activates it. Disable source handler deactivates the link.Bridge driver is expected to implement and set these handlers.
Signed-off-by Shuah Khan <[email protected]>--- include/media/media-device.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)include/media/media-device.h +10
-0@@ -302,6 +302,11 @@ struct media_entity_notify {* @entity_notify: List of registered entity_notify callbacks * @lock: Entities list lock * @graph_mutex: Entities graph operation lock +* +* @source_priv: Driver Private data for enable/disable source handlers +* @enable_source: Enable Source Handler function pointer +* @disable_source: Disable Source Handler function pointer +* * @link_notify: Link state change notification callback * * This structure represents an abstract high-level media device. It allows easy @@ -313,6 +318,26 @@ struct media_entity_notify {* * @model is a descriptive model name exported through sysfs. It doesn't have to * be unique. +* +* @enable_source is a handler to find source entity for the +* sink entity and activate the link between them if source +* entity is free. Drivers should call this handler before +* accessing the source. Quoted 8 lines
include/media/media-device.h struct media_entity_notify { · line 330
Quoted 5 lines
include/media/media-device.h +5
-0+* +* @disable_source is a handler to find source entity for the +* sink entity and deactivate the link between them. Drivers +* should call this handler to release the source. +* Is there a particular reason you're not simply (de)activating the link, but instead add a new callback?
Quoted 5 lines
These two handlers are separate for a couple of reasons:
1. Explicit and symmetric API is easier to use and maintain. Similar what we do in other cases, register/unregister get/put etc.
Link state is set explicitly (enabled or disabled). This is certainly not a reason to create a redundant API for link setup.
Quoted 8 lines
2. This is more important. Disable handler makes sure the owner is releasing the resource. Otherwise, when some other application does enable, the owner could loose the resource, if enable and disable are the same.
e.g: Video app is holding the resource, DVB app does enable. Disable handler makes sure Video/owner is the one that is asking to do the release.
Based on the later patches in this set, the enable_source() callback of the au0828 driver performs three things:
- Find the source entity,
- Enable the link from some au0828 entity to the source and
- Start the pipeline that begins from the I/O device node. The pipe object is embedded in struct video_device.
disable_source() undoes this in reverse order.
That's in the au0828 driver and rightly so.
Then it gets murkier. enable_source() and disable_source() callbacks (through a few turns) will get called from v4l2-ioctl.c functions v4l_querycap, v4l_s_fmt, v4l_s_frequency, v4l_s_std and v4l_querystd. This is also performed in VB2 core vb2_core_streamon() function.
I certainly have no objections when it comes to blocking other processes from setting the format when a process holding a file handle to a device has e.g. set the format. The implementation is another matter.
What particularly does concern me in this patchset is:
- struct media_pipe is intended to be allocated by drivers embedded in another struct holding information the driver needs related to the pipeline. Moving this struct to struct video_device prevents this, which translates to v4l_enable_media_source() and v4l_disable_media_source() functions the patchset adds being specific to the au0828 driver. They should be part of that driver, and may not be part of the V4L2 core. struct media_pipe may not be added to struct video_device for the same reason.
- The IOCTL handlers in v4l2-ioctl.c already call driver-settable callbacks before this set. It looks like redundant callbacks are added there as ell. The same appears to be true for the VB2 callback. Could you use the existing callbacks instead of creating new ones?
As a short term solution, I propose moving the code to the au0828 driver. Once it is there, we can see whether it could be made more generic if there is a need for it elsewhere. I believe so. Support atomic pipeline configuration and startup is a generic problem that requires a generic
solution: we should have a way to construct a pipeline and prevent other users from messing with it before it's started. But as currently implemented by this patchset, it is very specific to the au0828 driver and as such may not be added to the V4L2 or the MC frameworks.
Signature · 4 lines
Best regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v3 06/22] media: Media Controller enable/disable source handler API
Quoted 96 lines · Sakari Ailus
Hi Shuah,
Quoted 52 lines · Shuah Khan
Quoted 42 lines · Sakari Ailus
Hi Shuah,
Quoted 39 lines · Shuah Khan
Add new fields to struct
media_deviceto addenable_source, anddisable_sourcehandlers, andsource_privto stash driver private data that is used to run these handlers. Theenable_sourcehandler finds source entity for the passed in entity and checks if it is available. When link is found, it activates it. Disable source handler deactivates the link.Bridge driver is expected to implement and set these handlers.
Signed-off-by Shuah Khan <[email protected]>--- include/media/media-device.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)include/media/media-device.h +10
-0@@ -302,6 +302,11 @@ struct media_entity_notify {* @entity_notify: List of registered entity_notify callbacks * @lock: Entities list lock * @graph_mutex: Entities graph operation lock +* +* @source_priv: Driver Private data for enable/disable source handlers +* @enable_source: Enable Source Handler function pointer +* @disable_source: Disable Source Handler function pointer +* * @link_notify: Link state change notification callback * * This structure represents an abstract high-level media device. It allows easy @@ -313,6 +318,26 @@ struct media_entity_notify {* * @model is a descriptive model name exported through sysfs. It doesn't have to * be unique. +* +* @enable_source is a handler to find source entity for the +* sink entity and activate the link between them if source +* entity is free. Drivers should call this handler before +* accessing the source. Quoted 8 lines
include/media/media-device.h struct media_entity_notify { · line 330
Quoted 5 lines
include/media/media-device.h +5
-0+* +* @disable_source is a handler to find source entity for the +* sink entity and deactivate the link between them. Drivers +* should call this handler to release the source. +* Is there a particular reason you're not simply (de)activating the link, but instead add a new callback?
Quoted 5 lines
These two handlers are separate for a couple of reasons:
1. Explicit and symmetric API is easier to use and maintain. Similar what we do in other cases, register/unregister get/put etc.
Link state is set explicitly (enabled or disabled). This is certainly not a reason to create a redundant API for link setup.
Quoted 8 lines
2. This is more important. Disable handler makes sure the owner is releasing the resource. Otherwise, when some other application does enable, the owner could loose the resource, if enable and disable are the same.
e.g: Video app is holding the resource, DVB app does enable. Disable handler makes sure Video/owner is the one that is asking to do the release.
Based on the later patches in this set, the
enable_source()callback of the au0828 driver performs three things:- Find the source entity,
- Enable the link from some au0828 entity to the source and
- Start the pipeline that begins from the I/O device node. The pipe object is embedded in structvideo_device.
disable_source()undoes this in reverse order.That's in the au0828 driver and rightly so.
Then it gets murkier.
enable_source()anddisable_source()callbacks (through a few turns) will get called fromv4l2-ioctl.cfunctionsv4l_querycap,v4l_s_fmt,v4l_s_frequency,v4l_s_stdandv4l_querystd. This is also performed in VB2 corevb2_core_streamon()function.I certainly have no objections when it comes to blocking other processes from setting the format when a process holding a file handle to a device has e.g. set the format. The implementation is another matter.
What particularly does concern me in this patchset is:
Quoted 8 lines
- struct
media_pipeis intended to be allocated by drivers embedded in another struct holding information the driver needs related to the pipeline. Moving this struct to structvideo_deviceprevents this, which translates tov4l_enable_media_source()andv4l_disable_media_source()functions the patchset adds being specific to the au0828 driver. They should be part of that driver, and may not be part of the V4L2 core. structmedia_pipemay not be added to structvideo_devicefor the same reason.
This media_pipe is associated with struct video_device though. I don't understand your concern. I am viewing this media_pipe as part of the registered video_device. video_device struct is in the au0828 device and gets registered as a whole including the media_pipe
Quoted 5 lines
- The IOCTL handlers in
v4l2-ioctl.calready call driver-settable callbacks before this set. It looks like redundant callbacks are added there as ell. The same appears to be true for the VB2 callback. Could you use the existing callbacks instead of creating new ones?
If I understand correctly, you are suggesting that the calls to enable and disable source should be made from the au0828 hooks. e.g vidioc_s_std()
Calling them from v4l2-core makes it generic and works on all drivers without driver changes. That is the rationale for making adding v4l2 common interfaces v4l_enable_media_source() and v4l_disable_media_source()
Quoted 10 lines
As a short term solution, I propose moving the code to the au0828 driver. Once it is there, we can see whether it could be made more generic if there is a need for it elsewhere. I believe so. Support atomic pipeline configuration and startup is a generic problem that requires a generic
solution: we should have a way to construct a pipeline and prevent other users from messing with it before it's started. But as currently implemented by this patchset, it is very specific to the au0828 driver and as such may not be added to the V4L2 or the MC frameworks.
The enable and disable handlers themselves are for a good reason. These are handlers that get called from dvb-core, v4l2-core via the common interfaces. These also get called from sound driver from the media_device. All of this is generic. Could you please elaborate on which part is au0828 driver specific other than the media_pipe in struct video_device?
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Re: [PATCH v3 06/22] media: Media Controller enable/disable source handler API
Hi Shuah,
I see that the patches have been merged to media-tree.git master and subsequently a pull request has been sent to Linus including them, but the remaining issues still need to be fixed. Some matters should be discussed further on the list.
Quoted 106 lines · Shuah Khan
Quoted 96 lines · Sakari Ailus
Hi Shuah,
Quoted 52 lines · Shuah Khan
Quoted 42 lines · Sakari Ailus
Hi Shuah,
Quoted 39 lines · Shuah Khan
Add new fields to struct
media_deviceto addenable_source, anddisable_sourcehandlers, andsource_privto stash driver private data that is used to run these handlers. Theenable_sourcehandler finds source entity for the passed in entity and checks if it is available. When link is found, it activates it. Disable source handler deactivates the link.Bridge driver is expected to implement and set these handlers.
Signed-off-by Shuah Khan <[email protected]>--- include/media/media-device.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)include/media/media-device.h +10
-0@@ -302,6 +302,11 @@ struct media_entity_notify {* @entity_notify: List of registered entity_notify callbacks * @lock: Entities list lock * @graph_mutex: Entities graph operation lock +* +* @source_priv: Driver Private data for enable/disable source handlers +* @enable_source: Enable Source Handler function pointer +* @disable_source: Disable Source Handler function pointer +* * @link_notify: Link state change notification callback * * This structure represents an abstract high-level media device. It allows easy @@ -313,6 +318,26 @@ struct media_entity_notify {* * @model is a descriptive model name exported through sysfs. It doesn't have to * be unique. +* +* @enable_source is a handler to find source entity for the +* sink entity and activate the link between them if source +* entity is free. Drivers should call this handler before +* accessing the source. Quoted 8 lines
include/media/media-device.h struct media_entity_notify { · line 330
Quoted 5 lines
include/media/media-device.h +5
-0+* +* @disable_source is a handler to find source entity for the +* sink entity and deactivate the link between them. Drivers +* should call this handler to release the source. +* Is there a particular reason you're not simply (de)activating the link, but instead add a new callback?
Quoted 5 lines
These two handlers are separate for a couple of reasons:
1. Explicit and symmetric API is easier to use and maintain. Similar what we do in other cases, register/unregister get/put etc.
Link state is set explicitly (enabled or disabled). This is certainly not a reason to create a redundant API for link setup.
Quoted 8 lines
2. This is more important. Disable handler makes sure the owner is releasing the resource. Otherwise, when some other application does enable, the owner could loose the resource, if enable and disable are the same.
e.g: Video app is holding the resource, DVB app does enable. Disable handler makes sure Video/owner is the one that is asking to do the release.
Based on the later patches in this set, the
enable_source()callback of the au0828 driver performs three things:- Find the source entity,
- Enable the link from some au0828 entity to the source and
- Start the pipeline that begins from the I/O device node. The pipe object is embedded in structvideo_device.
disable_source()undoes this in reverse order.That's in the au0828 driver and rightly so.
Then it gets murkier.
enable_source()anddisable_source()callbacks (through a few turns) will get called fromv4l2-ioctl.cfunctionsv4l_querycap,v4l_s_fmt,v4l_s_frequency,v4l_s_stdandv4l_querystd. This is also performed in VB2 corevb2_core_streamon()function.I certainly have no objections when it comes to blocking other processes from setting the format when a process holding a file handle to a device has e.g. set the format. The implementation is another matter.
What particularly does concern me in this patchset is:
Quoted 8 lines
- struct
media_pipeis intended to be allocated by drivers embedded in another struct holding information the driver needs related to the pipeline. Moving this struct to structvideo_deviceprevents this, which translates tov4l_enable_media_source()andv4l_disable_media_source()functions the patchset adds being specific to the au0828 driver. They should be part of that driver, and may not be part of the V4L2 core. structmedia_pipemay not be added to structvideo_devicefor the same reason.
Quoted 3 lines
This
media_pipeis associated with structvideo_devicethough. I don't understand your concern. I am viewing thismedia_pipeas part of the registeredvideo_device.video_devicestruct is in the au0828 device
That is another problem --- this approach excludes pipelines with multiple video nodes in them. It's not uncommon to have more than one video device in a pipeline nowadays, e.g. omap3isp driver has that in memory-to-memory processing.
Other ISPs also have more than one memory output in a single pipeline, that omap3isp driver could technically support as well.
If you look at the struct media_pipeline, it was an empty struct until a month or so ago. Drivers embed this struct in their own data structures.
Quoted 26 lines
and gets registered as a whole including the
media_pipeQuoted 5 lines
- The IOCTL handlers in
v4l2-ioctl.calready call driver-settable callbacks before this set. It looks like redundant callbacks are added there as ell. The same appears to be true for the VB2 callback. Could you use the existing callbacks instead of creating new ones?If I understand correctly, you are suggesting that the calls to enable and disable source should be made from the au0828 hooks. e.g
vidioc_s_std()Calling them from v4l2-core makes it generic and works on all drivers without driver changes. That is the rationale for making adding v4l2 common interfaces
v4l_enable_media_source()andv4l_disable_media_source()Quoted 10 lines
As a short term solution, I propose moving the code to the au0828 driver. Once it is there, we can see whether it could be made more generic if there is a need for it elsewhere. I believe so. Support atomic pipeline configuration and startup is a generic problem that requires a generic
solution: we should have a way to construct a pipeline and prevent other users from messing with it before it's started. But as currently implemented by this patchset, it is very specific to the au0828 driver and as such may not be added to the V4L2 or the MC frameworks.
Quoted 5 lines
The enable and disable handlers themselves are for a good reason. These are handlers that get called from dvb-core, v4l2-core via the common interfaces. These also get called from sound driver from the
media_device. All of this is generic. Could you please elaborate on which part is au0828 driver specific other than themedia_pipein structvideo_device?
As far as I understand, you intend to prevent changing e.g. format or input after a user holding e.g. a file handle to a video node open by other processes. The au0828 driver does this by configuring the links and starting the pipeline from the driver itself.
That solution does solve the problem in some special cases (I presume au0828 driver at least), but how about drivers that support the V4L2 sub-device API? If you start the pipeline based on VIDIOC_S_FMT, for instance, that also prevents changing the V4L2 sub-device formats along that pipeline. There is no requirement that the V4L2 sub-device formats in a pipeline must be set before the V4L2 formats.
Should VIDIOC_S_FMT, for example, have that kind of behaviour? The question is closely related to the more generic question of how do you prevent other processes from changing a pipeline (links, V4L2 sub-device formats, selections or V4L2 formats etc.) while it's being configured. So far that hasn't been done elsewhere than on video nodes, and not all drivers implemeted that. I'd like to have at least Hans's and Laurent's opinion on that. I think the idea is good in principle.
This should be considered together with existing mechanisms. The V4L2 spec says that:
Application Priority
When multiple applications share a device it may be desirable to assign them different priorities. Contrary to the traditional "rm -rf /" school of thought a video recording application could for example block other applications from changing video controls or switching the current TV channel. Another objective is to permit low priority applications working in background, which can be preempted by user controlled applications and automatically regain control of the device at a later time.
Since these features cannot be implemented entirely in user space V4L2 defines the VIDIOC_G_PRIORITY and VIDIOC_S_PRIORITY ioctls to request and query the access priority associate with a file descriptor. Opening a device assigns a medium priority, compatible with earlier versions of V4L2 and drivers not supporting these ioctls. Applications requiring a different priority will usually call VIDIOC_S_PRIORITY after verifying the device with the VIDIOC_QUERYCAP ioctl.
Ioctls changing driver properties, such as VIDIOC_S_INPUT, return an EBUSY error code after another application obtained higher priority.
<URL:http://hverkuil.home.xs4all.nl/spec/media.html#app-pri>
Setting the input should thus be possible unless another application (file handle) has a higher priority.
It would be good to write an RFC on the topic so that it's easier for everyone to understand the underlying technical problems and the intended way to resolve those issues (once there is one).
In order to make your solution generic, it should also
1. Support pipelines with multiple video nodes in them.
2. Assuming people find extending (and implementing them where implementation is missing) the current priority mechanisms, provide a way to prevent other processes from changing configuration of V4L2/MC/V4L2 sub-device nodes (links, V4L2 sub-device formats, selections or V4L2 formats etc.). The au0828 implementation should be in line with this.
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
PATCH v3 7/22 media: Media Controller export non locking __media_entity_setup_link()
In reply to Shuah KhanExport __media_entity_setup_link() to be used from code paths that hold the graph_mutex.
--- drivers/media/media-entity.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/media-entity.c +1 -0
@@ -805,6 +805,7 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)return ret; } +EXPORT_SYMBOL_GPL (__media_entity_setup_link);int media_entity_setup_link (struct media_link *link,u32 flags) {
Signature · 1 line
2.5.0
PATCH v3 8/22 media: Media Controller non-locking __media_entity_pipeline_start/stop()
In reply to Shuah KhanAdd non-locking __media_entity_pipeline_start/stop() interfaces to be called from code paths that hold the graph_mutex.
--- drivers/media/media-entity.c | 34 ++++++++++++++++++++++++---------- include/media/media-entity.h | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+), 10 deletions(-)
drivers/media/media-entity.c +24 -10
@@ -365,8 +365,8 @@ EXPORT_SYMBOL_GPL(media_entity_graph_walk_next);* Pipeline management */ -__must_check int media_entity_pipeline_start (struct media_entity *entity, -struct media_pipeline *pipe) +__must_check int __media_entity_pipeline_start (struct media_entity *entity, +struct media_pipeline *pipe) {struct media_device *mdev = entity->graph_obj.mdev;struct media_entity_graph *graph = &pipe->graph;
@@ -374,8 +374,6 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,struct media_link *link;int ret; -mutex_lock (&mdev->graph_mutex); -if (!pipe->streaming_count++) { ret =media_entity_graph_walk_init (&pipe->graph, mdev);if (ret)
@@ -456,8 +454,6 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity, } } -mutex_unlock (&mdev->graph_mutex); -return 0 ; error:
@@ -487,19 +483,28 @@ error_graph_walk_start:if (!--pipe->streaming_count)media_entity_graph_walk_cleanup (graph); -mutex_unlock (&mdev->graph_mutex); +return ret; +} +EXPORT_SYMBOL_GPL (__media_entity_pipeline_start); +__must_check int media_entity_pipeline_start (struct media_entity *entity, +struct media_pipeline *pipe) +{ +struct media_device *mdev = entity->graph_obj.mdev; +int ret; + +mutex_lock (&mdev->graph_mutex); + ret =__media_entity_pipeline_start (entity, pipe); +mutex_unlock (&mdev->graph_mutex);return ret; }EXPORT_SYMBOL_GPL (media_entity_pipeline_start); -void media_entity_pipeline_stop (struct media_entity *entity) +void __media_entity_pipeline_stop (struct media_entity *entity) { -struct media_device *mdev = entity->graph_obj.mdev;struct media_entity_graph *graph = &entity->pipe->graph;struct media_pipeline *pipe = entity->pipe; -mutex_lock (&mdev->graph_mutex);WARN_ON (!pipe->streaming_count);media_entity_graph_walk_start (graph, entity);
@@ -516,6 +521,15 @@ void media_entity_pipeline_stop(struct media_entity *entity)if (!--pipe->streaming_count)media_entity_graph_walk_cleanup (graph); +} +EXPORT_SYMBOL_GPL (__media_entity_pipeline_stop); + +void media_entity_pipeline_stop (struct media_entity *entity) +{ +struct media_device *mdev = entity->graph_obj.mdev; + +mutex_lock (&mdev->graph_mutex); +__media_entity_pipeline_stop (entity);mutex_unlock (&mdev->graph_mutex); }EXPORT_SYMBOL_GPL (media_entity_pipeline_stop);
include/media/media-entity.h +19 -0
@@ -832,6 +832,16 @@ media_entity_graph_walk_next(struct media_entity_graph *graph);*/ __must_check int media_entity_pipeline_start (struct media_entity *entity,struct media_pipeline *pipe); +/** +* __media_entity_pipeline_start - Mark a pipeline as streaming +* +* @entity: Starting entity +* @pipe: Media pipeline to be assigned to all entities in the pipeline. +* +* Note: This is the non-locking version of media_entity_pipeline_start() +*/ +__must_check int __media_entity_pipeline_start (struct media_entity *entity, +struct media_pipeline *pipe);/** * media_entity_pipeline_stop - Mark a pipeline as not streaming
@@ -848,6 +858,15 @@ __must_check int media_entity_pipeline_start(struct media_entity *entity,void media_entity_pipeline_stop (struct media_entity *entity);/** +* __media_entity_pipeline_stop - Mark a pipeline as not streaming +* +* @entity: Starting entity +* +* Note: This is the non-locking version of media_entity_pipeline_stop() +*/ +void __media_entity_pipeline_stop (struct media_entity *entity); + +/** * media_devnode_create() - creates and initializes a device node interface * * @mdev: pointer to struct &media_device
Signature · 1 line
2.5.0
PATCH v3 9/22 media: v4l-core add enable/disable source common interfaces
In reply to Shuah KhanAdd a new interfaces to be used by v4l-core to invoke enable source and disable_source handlers in the media_device. The enable_source helper function invokes the enable_source handler to find media source entity connected to the entity and check is it is available or busy. If source is available, link is activated and pipeline is started. The disable_source helper function invokes the disable_source handler to deactivate and stop the pipeline.
--- drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/v4l2-mc.c | 52 +++++++++++++++++++++++++++++++ include/media/v4l2-dev.h | 1 + include/media/v4l2-mc.h | 65 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-mc.c
drivers/media/v4l2-core/Makefile +1 -0
@@ -16,6 +16,7 @@ endif ifeq ($(CONFIG_TRACEPOINTS),y) videodev-objs += vb2-trace.o v4l2-trace.o endif +videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o obj-$(CONFIG_VIDEO_V4L2) += videodev.o obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
drivers/media/v4l2-core/v4l2-mc.c new file +52 -0
52 lines not on this page · raw message
include/media/v4l2-dev.h +1 -0
@@ -87,6 +87,7 @@ struct video_device#if defined(CONFIG_MEDIA_CONTROLLER )struct media_entity entity;struct media_intf_devnode *intf_devnode; +struct media_pipeline pipe;#endif /* device ops */ const struct v4l2_file_operations *fops;
include/media/v4l2-mc.h +65 -0
74 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v3 10/22 media: Move au8522_media_pads enum to au8522.h from au8522_priv.h
In reply to Shuah KhanMove the au8522_media_pads enum to au8522.h from au8522_priv.h to export them. This will allow au0828-core to use these defines instead of hard-coding them them.
--- drivers/media/dvb-frontends/au8522.h | 7 +++++++ drivers/media/dvb-frontends/au8522_priv.h | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/media/dvb-frontends/au8522.h +7 -0
@@ -90,4 +90,11 @@ enum au8522_audio_input { AU8522_AUDIO_SIF, }; +enum au8522_media_pads { +AU8522_PAD_INPUT , +AU8522_PAD_VID_OUT , +AU8522_PAD_VBI_OUT , + +AU8522_NUM_PADS +};#endif /* __AU8522_H__ */
drivers/media/dvb-frontends/au8522_priv.h +0 -8
@@ -39,14 +39,6 @@#define AU8522_DIGITAL_MODE 1#define AU8522_SUSPEND_MODE 2 -enum au8522_media_pads { -AU8522_PAD_INPUT , -AU8522_PAD_VID_OUT , -AU8522_PAD_VBI_OUT , - -AU8522_NUM_PADS -}; -struct au8522_state {struct i2c_client *c;struct i2c_adapter *i2c;
Signature · 1 line
2.5.0
PATCH v3 11/22 media: au8522 change to create MC pad for ALSA Audio Out
In reply to Shuah KhanAdd new pad for ALSA Audio Out to au8522_media_pads.
--- drivers/media/dvb-frontends/au8522.h | 1 + drivers/media/dvb-frontends/au8522_decoder.c | 1 + 2 files changed, 2 insertions(+)
drivers/media/dvb-frontends/au8522.h +1 -0
@@ -94,6 +94,7 @@ enum au8522_media_pads {AU8522_PAD_INPUT ,AU8522_PAD_VID_OUT ,AU8522_PAD_VBI_OUT , +AU8522_PAD_AUDIO_OUT , AU8522_NUM_PADS };
drivers/media/dvb-frontends/au8522_decoder.c +1 -0
@@ -766,6 +766,7 @@ static int au8522_probe(struct i2c_client *client, state->pads[AU8522_PAD_INPUT ].flags =MEDIA_PAD_FL_SINK ; state->pads[AU8522_PAD_VID_OUT ].flags =MEDIA_PAD_FL_SOURCE ; state->pads[AU8522_PAD_VBI_OUT ].flags =MEDIA_PAD_FL_SOURCE ; + state->pads[AU8522_PAD_AUDIO_OUT ].flags =MEDIA_PAD_FL_SOURCE ; sd->entity.function =MEDIA_ENT_F_ATV_DECODER ; ret = media_entity_pads_init(&sd->entity, ARRAY_SIZE(state->pads),
Signature · 1 line
2.5.0
PATCH v3 12/22 media: au0828 Use au8522_media_pads enum for pad defines
In reply to Shuah KhanChange au0828-core to use au8522_media_pads enum defines instead of hard-coding the pad values.
--- drivers/media/usb/au0828/au0828-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/usb/au0828/au0828-core.c +5 -2
@@ -20,6 +20,7 @@*/ #include "au0828.h" +#include "au8522.h" #include <linux/module.h> #include <linux/slab.h>
@@ -282,11 +283,13 @@ static int au0828_create_media_graph(struct au0828_dev *dev)if (ret)return ret; } - ret =media_create_pad_link (decoder,1 , &dev->vdev.entity,0 , + ret =media_create_pad_link (decoder,AU8522_PAD_VID_OUT , + &dev->vdev.entity,0 ,MEDIA_LNK_FL_ENABLED );if (ret)return ret; - ret =media_create_pad_link (decoder,2 , &dev->vbi_dev.entity,0 , + ret =media_create_pad_link (decoder,AU8522_PAD_VBI_OUT , + &dev->vbi_dev.entity,0 ,MEDIA_LNK_FL_ENABLED );if (ret)return ret;
Signature · 1 line
2.5.0
PATCH v3 13/22 media: Change v4l-core to check if source is free
In reply to Shuah KhanChange s_input, s_fmt, s_tuner, s_frequency, querystd, s_hw_freq_seek, and vb2_core_streamon interfaces that alter the tuner configuration to check if it is free, by calling v4l_enable_media_source(). If source isn't free, return -EBUSY. v4l_disable_media_source() is called from v4l2_fh_exit() to release tuner (source). vb2_core_streamon() uses v4l_vb2q_enable_media_source().
--- drivers/media/v4l2-core/v4l2-fh.c | 2 ++ drivers/media/v4l2-core/v4l2-ioctl.c | 30 ++++++++++++++++++++++++++++++ drivers/media/v4l2-core/videobuf2-core.c | 4 ++++ 3 files changed, 36 insertions(+)
drivers/media/v4l2-core/v4l2-fh.c +2 -0
@@ -29,6 +29,7 @@#include <media/v4l2-fh.h> #include <media/v4l2-event.h> #include <media/v4l2-ioctl.h> +#include <media/v4l2-mc.h> void v4l2_fh_init (struct v4l2_fh *fh,struct video_device *vdev) {
@@ -92,6 +93,7 @@ void v4l2_fh_exit(struct v4l2_fh *fh) {if (fh->vdev ==NULL )return ; +v4l_disable_media_source (fh->vdev);v4l2_event_unsubscribe_all (fh); fh->vdev =NULL ; }
drivers/media/v4l2-core/v4l2-ioctl.c +30 -0
@@ -27,6 +27,7 @@#include <media/v4l2-event.h> #include <media/v4l2-device.h> #include <media/videobuf2-v4l2.h> +#include <media/v4l2-mc.h> #include <trace/events/v4l2.h>
@@ -1041,6 +1042,12 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,static int v4l_s_input (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vfd =video_devdata (file); +int ret; + + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;return ops->vidioc_s_input (file, fh, *(unsigned int *)arg); }
@@ -1448,6 +1455,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,bool is_tx = vfd->vfl_dir !=VFL_DIR_RX ;int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;v4l_sanitize_format (p);switch (p->type) {
@@ -1637,7 +1647,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, {struct video_device *vfd =video_devdata (file);struct v4l2_tuner *p = arg; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret; p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ;return ops->vidioc_s_tuner (file, fh, p);
@@ -1691,7 +1705,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,struct video_device *vfd =video_devdata (file);const struct v4l2_frequency *p = arg;enum v4l2_tuner_type type; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;if (vfd->vfl_type ==VFL_TYPE_SDR ) {if (p->type !=V4L2_TUNER_SDR && p->type !=V4L2_TUNER_RF )return -EINVAL ;
@@ -1746,7 +1764,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops, {struct video_device *vfd =video_devdata (file);v4l2_std_id id = *(v4l2_std_id *)arg, norm; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret; norm = id & vfd->tvnorms;if (vfd->tvnorms && !norm)/* Check if std is supported */ return -EINVAL ;
@@ -1760,7 +1782,11 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops, {struct video_device *vfd =video_devdata (file);v4l2_std_id *p = arg; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;/* * If no signal is detected, then the driver should return * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with
@@ -1779,7 +1805,11 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops,struct video_device *vfd =video_devdata (file);struct v4l2_hw_freq_seek *p = arg;enum v4l2_tuner_type type; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;/* s_hw_freq_seek is not supported for SDR for now */ if (vfd->vfl_type ==VFL_TYPE_SDR )return -EINVAL ;
drivers/media/v4l2-core/videobuf2-core.c +4 -0
@@ -25,6 +25,7 @@#include <linux/kthread.h> #include <media/videobuf2-core.h> +#include <media/v4l2-mc.h> #include <trace/events/vb2.h>
@@ -1873,6 +1874,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)* are available. */ if (q->queued_count >= q->min_buffers_needed) { + ret =v4l_vb2q_enable_media_source (q); +if (ret) +return ret; ret =vb2_start_streaming (q);if (ret) {__vb2_queue_cancel (q);
Signature · 1 line
2.5.0
Re: [PATCH v3 13/22] media: Change v4l-core to check if source is free
Hello Shuah,
This patch seems to cause issues with my setup. Basically, when I try to tune to a channel, I get an oops. I'm using TechnoTrend CT2-4650 PCIe DVB-T tuner (cx23885).
Here's the oops:
[ 548.443272] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 [ 548.452036] IP: [<ffffffffc020ffc9>] v4l_vb2q_enable_media_source+0x9/0x50 [videodev] [ 548.460792] PGD b820e067 PUD bb3df067 PMD 0 [ 548.465582] Oops: 0000 [#1] SMP [ 548.469199] Modules linked in: sp2(OE) si2157(OE) si2168(OE)
cx25840(OE) cx23885(OE) altera_ci(OE) tda18271(OE) altera_stapl(OE) videobuf2_dvb(OE) m88ds3103(OE) tveeprom(OE) cx2341x(OE) dvb_core(OE) rc_core(OE) videobuf2_dma_sg(OE) videobuf2_memops(OE) frame_vector(POE) v4l2_common(OE) videobuf2_v4l2(OE) videobuf2_core(OE) videodev(OE) media(OE) i2c_mux snd_pcm snd_timer snd soundcore des_generic md4 nls_utf8 cifs fscache ipmi_ssif intel_powerclamp coretemp kvm_intel kvm crct10dif_pclmul crc32_pclmul ghash_clmulni_intel gpio_ich aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd serio_raw i7core_edac ipmi_si edac_core shpchp ipmi_msghandler tpm_infineon lpc_ich lp 8250_fintek mac_hid parport igb i2c_algo_bit dca ahci ptp libahci pps_core [last unloaded:
tveeprom]
[ 548.546864] CPU: 12 PID: 18651 Comm: dvbv5-scan Tainted: P IOE 4.1.7-040107-generic #201509131330 [ 548.557833] Hardware name: HP ProLiant DL160 G6 , BIOS O33 07/01/2013 [ 548.565117] task: ffff880239c9b250 ti: ffff88013a738000 task.ti: ffff88013a738000 [ 548.573466] RIP: 0010:[<ffffffffc020ffc9>] [<ffffffffc020ffc9>] v4l_vb2q_enable_media_source+0x9/0x50 [videodev] [ 548.584936] RSP: 0018:ffff88013a73bba0 EFLAGS: 00010287 [ 548.590862] RAX: 0000000000000000 RBX: ffff88023a55e828 RCX: ffff88023a55e9b0 [ 548.598824] RDX: 0000000000000002 RSI: 0000000000000001 RDI: ffff88023a55e828 [ 548.606788] RBP: ffff88013a73bbc8 R08: 00000000000002f0 R09: 0000000000000000 [ 548.614751] R10: ffffffff81ab5eb7 R11: ffffea0000dad080 R12: ffff88013a7c7000 [ 548.622712] R13: 0000000000000000 R14: ffff88023a55e9a8 R15: 0000000000000020 [ 548.630675] FS: 00007fe55f94d740(0000) GS:ffff88013bb80000(0000) knlGS:0000000000000000 [ 548.639704] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 548.646114] CR2: 0000000000000010 CR3: 00000000baa41000 CR4: 00000000000006e0 [ 548.654076] Stack: [ 548.656318] ffffffffc01caf15 ffff88013a7c7000 0000000000000000 ffff88023a55e9a8 [ 548.664610] ffff88023a55e828 ffff88013a73bc18 ffffffffc01cce13 ffffffffc01cd689 [ 548.672902] 0000002000000001 8000000000000163 ffff88023a55e828 ffffffffc01f2220 [ 548.681194] Call Trace: [ 548.683926] [<ffffffffc01caf15>] ? vb2_core_streamon+0x125/0x170 [videobuf2_core] [ 548.692376] [<ffffffffc01cce13>] __vb2_init_fileio+0x273/0x2f0 [videobuf2_core] [ 548.700631] [<ffffffffc01cd689>] ? vb2_thread_start+0x69/0x9e0 [videobuf2_core] [ 548.708886] [<ffffffffc01f2220>] ? vb2_dvb_start_feed+0xc0/0xc0 [videobuf2_dvb] [ 548.717141] [<ffffffffc01cd6b6>] vb2_thread_start+0x96/0x9e0 [videobuf2_core] [ 548.725204] [<ffffffff811bea35>] ? map_vm_area+0x35/0x40 [ 548.731228] [<ffffffffc01f21e8>] vb2_dvb_start_feed+0x88/0xc0 [videobuf2_dvb] [ 548.739290] [<ffffffffc03548c1>] dmx_section_feed_start_filtering+0xe1/0x1b0 [dvb_core] [ 548.748322] [<ffffffffc03532fe>] dvb_dmxdev_filter_start+0x20e/0x470 [dvb_core] [ 548.756578] [<ffffffffc0353803>] dvb_demux_do_ioctl+0x2a3/0x700 [dvb_core] [ 548.764349] [<ffffffffc0351625>] dvb_usercopy+0x115/0x190 [dvb_core] [ 548.771539] [<ffffffff810b11e4>] ? update_curr+0xe4/0x180 [ 548.777663] [<ffffffffc0353560>] ? dvb_dmxdev_filter_start+0x470/0x470 [dvb_core] [ 548.786112] [<ffffffff810af509>] ? pick_next_entity+0xa9/0x190 [ 548.792716] [<ffffffff810b6c1b>] ? pick_next_task_fair+0x65b/0x910 [ 548.799710] [<ffffffffc0351975>] dvb_demux_ioctl+0x15/0x20 [dvb_core] [ 548.806994] [<ffffffff8120ce68>] do_vfs_ioctl+0x2f8/0x510 [ 548.813117] [<ffffffff817d44e6>] ? __schedule+0x386/0x9a0 [ 548.819237] [<ffffffff8120d101>] SyS_ioctl+0x81/0xa0 [ 548.824872] [<ffffffff817d4b37>] ? schedule+0x37/0x90 [ 548.830608] [<ffffffff810159bb>] ? math_state_restore+0xdb/0x1d0 [ 548.837401] [<ffffffff817d8ab2>] system_call_fastpath+0x16/0x75 [ 548.844103] Code: 8b 80 c8 05 00 00 48 85 c0 74 07 55 48 89 e5 ff d0 5d f3 c3 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 66 66 66 66 90 48 8b 47 18 <48> 8b 78 10 48 8b 07 48 85 c0 74 2b 48 8b 90 c0 05 00 00 31 c0 [ 548.865851] RIP [<ffffffffc020ffc9>] v4l_vb2q_enable_media_source+0x9/0x50 [videodev] [ 548.874704] RSP <ffff88013a73bba0> [ 548.878593] CR2: 0000000000000010 [ 548.882304] ---[ end trace 38ce56384a5e39e2 ]---
Here's the git bisect result:
77fa4e072998705883c4dc672963b4bf7483cea9 is the first bad commit commit 77fa4e072998705883c4dc672963b4bf7483cea9
Author: Shuah Khan <[email protected]> Date: Thu Feb 11 21:41:29 2016 -0200
[media] media: Change v4l-core to check if source is free
Change s_input, s_fmt, s_tuner, s_frequency, querystd, s_hw_freq_seek, and vb2_core_streamon interfaces that alter the tuner configuration to check if it is free, by calling v4l_enable_media_source().
If source isn't free, return -EBUSY.
v4l_disable_media_source() is called from v4l2_fh_exit() to release tuner (source).
vb2_core_streamon() uses v4l_vb2q_enable_media_source().
:040000 040000 853ab8842fcbd6c3add680cedff54b1c352d4768990ddc77b888d935d969859c087e581307365ed8 M drivers
After reverting this single patch, the tuner worked normally again.
Cheers,
-olli
Quoted 159 lines · Shuah Khan
Change
s_input,s_fmt,s_tuner,s_frequency, querystd,s_hw_freq_seek, andvb2_core_streamoninterfaces that alter the tuner configuration to check if it is free, by callingv4l_enable_media_source(). If source isn't free, return-EBUSY.v4l_disable_media_source()is called fromv4l2_fh_exit()to release tuner (source).vb2_core_streamon()usesv4l_vb2q_enable_media_source().Signed-off-by Shuah Khan <[email protected]>--- drivers/media/v4l2-core/v4l2-fh.c | 2 ++ drivers/media/v4l2-core/v4l2-ioctl.c | 30 ++++++++++++++++++++++++++++++ drivers/media/v4l2-core/videobuf2-core.c | 4 ++++ 3 files changed, 36 insertions(+)drivers/media/v4l2-core/v4l2-fh.c +2
-0@@ -29,6 +29,7 @@#include <media/v4l2-fh.h> #include <media/v4l2-event.h> #include <media/v4l2-ioctl.h> +#include <media/v4l2-mc.h> void v4l2_fh_init (struct v4l2_fh *fh,struct video_device *vdev) {@@ -92,6 +93,7 @@ void v4l2_fh_exit(struct v4l2_fh *fh) {if (fh->vdev ==NULL )return ; +v4l_disable_media_source (fh->vdev);v4l2_event_unsubscribe_all (fh); fh->vdev =NULL ; }drivers/media/v4l2-core/v4l2-ioctl.c +30
-0@@ -27,6 +27,7 @@#include <media/v4l2-event.h> #include <media/v4l2-device.h> #include <media/videobuf2-v4l2.h> +#include <media/v4l2-mc.h> #include <trace/events/v4l2.h> @@ -1041,6 +1042,12 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,static int v4l_s_input (const struct v4l2_ioctl_ops *ops,struct file *file,void *fh,void *arg) { +struct video_device *vfd =video_devdata (file); +int ret; + + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;return ops->vidioc_s_input (file, fh, *(unsigned int *)arg); }@@ -1448,6 +1455,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops,bool is_tx = vfd->vfl_dir !=VFL_DIR_RX ;int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;v4l_sanitize_format (p);switch (p->type) {@@ -1637,7 +1647,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, {struct video_device *vfd =video_devdata (file);struct v4l2_tuner *p = arg; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret; p->type = (vfd->vfl_type ==VFL_TYPE_RADIO ) ?V4L2_TUNER_RADIO :V4L2_TUNER_ANALOG_TV ;return ops->vidioc_s_tuner (file, fh, p);@@ -1691,7 +1705,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops,struct video_device *vfd =video_devdata (file);const struct v4l2_frequency *p = arg;enum v4l2_tuner_type type; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;if (vfd->vfl_type ==VFL_TYPE_SDR ) {if (p->type !=V4L2_TUNER_SDR && p->type !=V4L2_TUNER_RF )return -EINVAL ;@@ -1746,7 +1764,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops, {struct video_device *vfd =video_devdata (file);v4l2_std_id id = *(v4l2_std_id *)arg, norm; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret; norm = id & vfd->tvnorms;if (vfd->tvnorms && !norm)/* Check if std is supported */ return -EINVAL ;@@ -1760,7 +1782,11 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops, {struct video_device *vfd =video_devdata (file);v4l2_std_id *p = arg; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;/* * If no signal is detected, then the driver should return * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with @@ -1779,7 +1805,11 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops,struct video_device *vfd =video_devdata (file);struct v4l2_hw_freq_seek *p = arg;enum v4l2_tuner_type type; +int ret; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret;/* s_hw_freq_seek is not supported for SDR for now */ if (vfd->vfl_type ==VFL_TYPE_SDR )return -EINVAL ;drivers/media/v4l2-core/videobuf2-core.c +4
-1@@ -25,6 +25,7 @@#include <linux/kthread.h> #include <media/videobuf2-core.h> +#include <media/v4l2-mc.h> #include <trace/events/vb2.h> @@ -1873,6 +1874,9 @@ int vb2_core_streamon(struct vb2_queue *q, unsigned int type)* are available. */ if (q->queued_count >= q->min_buffers_needed) { + ret =v4l_vb2q_enable_media_source (q); +if (ret) +return ret; ret =vb2_start_streaming (q);if (ret) {__vb2_queue_cancel (q); --2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 13/22] media: Change v4l-core to check if source is free
Quoted 6 lines · Olli Salonen
Hello Shuah,
This patch seems to cause issues with my setup. Basically, when I try to tune to a channel, I get an oops. I'm using TechnoTrend CT2-4650 PCIe DVB-T tuner (cx23885).
Quoted 6 lines
Here's the oops:
[ 548.443272] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 [ 548.452036] IP: [<ffffffffc020ffc9>]
v4l_vb2q_enable_media_source+0x9/0x50[videodev]
Hi Olli,
Will you be able to use gdb and tell me which source line is the cause? Could you give this following patch a try and if it fixes the problem?
thanks,
-- Shuah
drivers/media/v4l2-core/v4l2-mc.c +3 -1
@@ -214,6 +214,8 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q) {struct v4l2_fh *fh = q->owner; -return v4l_enable_media_source (fh->vdev); +if (fh && fh->vdev) +return v4l_enable_media_source (fh->vdev); +return 0 ; }EXPORT_SYMBOL_GPL (v4l_vb2q_enable_media_source);
shuah@anduin:~/lkml/linux_media_feb27_2016$ git diff > temp.diff shuah@anduin:~/lkml/linux_media_feb27_2016$ cat temp.diff
drivers/media/v4l2-core/v4l2-mc.c +3 -1
@@ -214,6 +214,8 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q) {struct v4l2_fh *fh = q->owner; -return v4l_enable_media_source (fh->vdev); +if (fh && fh->vdev) +return v4l_enable_media_source (fh->vdev); +return 0 ; }EXPORT_SYMBOL_GPL (v4l_vb2q_enable_media_source);
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Re: [PATCH v3 13/22] media: Change v4l-core to check if source is free
Quoted 14 lines · Shuah Khan
Quoted 6 lines · Olli Salonen
Hello Shuah,
This patch seems to cause issues with my setup. Basically, when I try to tune to a channel, I get an oops. I'm using TechnoTrend CT2-4650 PCIe DVB-T tuner (cx23885).
Quoted 6 lines
Here's the oops:
[ 548.443272] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 [ 548.452036] IP: [<ffffffffc020ffc9>]
v4l_vb2q_enable_media_source+0x9/0x50[videodev]
Quoted 9 lines
Hi Olli,
Will you be able to use gdb and tell me which source line is the cause? Could you give this following patch a try and if it fixes the problem?
thanks,
-- Shuah
Sorry - diff included twice: here is the correct diff:
drivers/media/v4l2-core/v4l2-mc.c +3 -1
@@ -214,6 +214,8 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q) {struct v4l2_fh *fh = q->owner; -return v4l_enable_media_source (fh->vdev); +if (fh && fh->vdev) +return v4l_enable_media_source (fh->vdev); +return 0 ; }EXPORT_SYMBOL_GPL (v4l_vb2q_enable_media_source);
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
PATCH v3 14/22 media: au0828 change to use Managed Media Controller API
In reply to Shuah KhanChange 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.
--- drivers/media/usb/au0828/au0828-core.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/media/usb/au0828/au0828-core.c +15 -14
@@ -135,10 +135,10 @@ static void au0828_unregister_media_device(struct au0828_dev *dev) {#ifdef CONFIG_MEDIA_CONTROLLER -if (dev->media_dev) { +if (dev->media_dev && +media_devnode_is_registered (&dev->media_dev->devnode)) {media_device_unregister (dev->media_dev);media_device_cleanup (dev->media_dev); -kfree (dev->media_dev); dev->media_dev =NULL ; }#endif
@@ -224,23 +224,24 @@ static int au0828_media_device_init(struct au0828_dev *dev,#ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev; - mdev =kzalloc (sizeof (*mdev),GFP_KERNEL ); + mdev =media_device_get_devres (&udev->dev);if (!mdev)return -ENOMEM ; - mdev->dev = &udev->dev; +if (!media_devnode_is_registered (&mdev->devnode)) { + mdev->dev = &udev->dev; -if (!dev->board.name) -strlcpy (mdev->model,"unknown au0828" ,sizeof (mdev->model)); -else -strlcpy (mdev->model, dev->board.name,sizeof (mdev->model)); -if (udev->serial) -strlcpy (mdev->serial, udev->serial,sizeof (mdev->serial)); -strcpy (mdev->bus_info, udev->devpath); - mdev->hw_revision =le16_to_cpu (udev->descriptor.bcdDevice); - mdev->driver_version =LINUX_VERSION_CODE ; +if (udev->product) +strlcpy (mdev->model, udev->product, +sizeof (mdev->model)); +if (udev->serial) +strlcpy (mdev->serial, udev->serial, +sizeof (mdev->serial)); +strcpy (mdev->bus_info, udev->devpath); + mdev->hw_revision =le16_to_cpu (udev->descriptor.bcdDevice); -media_device_init (mdev); +media_device_init (mdev); + } dev->media_dev = mdev;#endif
Signature · 1 line
2.5.0
PATCH v3 15/22 media: au0828 handle media_init and media_register window
In reply to Shuah KhanMedia 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.
--- drivers/media/usb/au0828/au0828-core.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/media/usb/au0828/au0828-core.c +24 -2
@@ -228,7 +228,8 @@ static int au0828_media_device_init(struct au0828_dev *dev,if (!mdev)return -ENOMEM ; -if (!media_devnode_is_registered (&mdev->devnode)) { +/* check if media device is already initialized */ +if (!mdev->dev) { mdev->dev = &udev->dev;if (udev->product)
@@ -328,6 +329,27 @@ static int au0828_create_media_graph(struct au0828_dev *dev)return 0 ; } +static int au0828_media_device_register (struct au0828_dev *dev, +struct usb_device *udev) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +int ret; + +if (dev->media_dev && + !media_devnode_is_registered (&dev->media_dev->devnode)) { + +/* register media device */ + ret =media_device_register (dev->media_dev); +if (ret) { +dev_err (&udev->dev, +"Media Device Register Error: %d\n" , ret); +return ret; + } + } +#endif +return 0 ; +} +static int au0828_usb_probe (struct usb_interface *interface,const struct usb_device_id *id) {
@@ -455,7 +477,7 @@ static int au0828_usb_probe(struct usb_interface *interface, }#ifdef CONFIG_MEDIA_CONTROLLER - retval =media_device_register (dev->media_dev); + retval =au0828_media_device_register (dev, usbdev);#endif done:
Signature · 1 line
2.5.0
PATCH v3 16/22 media: au0828 create tuner to decoder link in disabled state
In reply to Shuah KhanCreate tuner to demod pad link in disabled state to avoid disable step when tuner resource is requested by dvb.
--- drivers/media/usb/au0828/au0828-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/au0828/au0828-core.c +2 -2
@@ -279,9 +279,9 @@ static int au0828_create_media_graph(struct au0828_dev *dev)return -EINVAL ;if (tuner) { +/* create tuner to decoder link in deactivated state */ ret =media_create_pad_link (tuner,TUNER_PAD_OUTPUT , - decoder,0 , -MEDIA_LNK_FL_ENABLED ); + decoder,0 ,0 );if (ret)return ret; }
Signature · 1 line
2.5.0
PATCH v3 17/22 media: au0828 disable tuner to demod link
In reply to Shuah KhanChange 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.
--- drivers/media/usb/au0828/au0828-core.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/media/usb/au0828/au0828-core.c +19 -1
@@ -255,7 +255,7 @@ static int au0828_create_media_graph(struct au0828_dev *dev)#ifdef CONFIG_MEDIA_CONTROLLER struct media_device *mdev = dev->media_dev;struct media_entity *entity; -struct media_entity *tuner =NULL , *decoder =NULL ; +struct media_entity *tuner =NULL , *decoder =NULL , *demod =NULL ;int i, ret;if (!mdev)
@@ -269,6 +269,9 @@ static int au0828_create_media_graph(struct au0828_dev *dev)case MEDIA_ENT_F_ATV_DECODER : decoder = entity;break ; +case MEDIA_ENT_F_DTV_DEMOD : + demod = entity; +break ; } }
@@ -325,6 +328,21 @@ static int au0828_create_media_graph(struct au0828_dev *dev) break; } } + +/* +* Disable tuner to demod link to avoid disable step +* when tuner is requested by video or audio +*/ +if (tuner && demod) { +struct media_link *link; + +list_for_each_entry (link, &demod->links, list) { +if (link->sink->entity == demod && + link->source->entity == tuner) { +media_entity_setup_link (link,0 ); + } + } + }#endif return 0 ; }
Signature · 1 line
2.5.0
PATCH v3 18/22 media: au0828-core register entity_notify hook
In reply to Shuah KhanRegister 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.
--- drivers/media/usb/au0828/au0828-core.c | 43 ++++++++++++++++++++++++++++++++-- drivers/media/usb/au0828/au0828.h | 1 + 2 files changed, 42 insertions(+), 2 deletions(-)
drivers/media/usb/au0828/au0828-core.c +41 -2
@@ -347,14 +347,42 @@ static int au0828_create_media_graph(struct au0828_dev *dev)return 0 ; } +void au0828_media_graph_notify (struct media_entity *new,void *notify_data) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct au0828_dev *dev = (struct au0828_dev *) notify_data; +int ret; + +if (!dev->decoder) +return ; + +switch (new->function) { +case MEDIA_ENT_F_AUDIO_MIXER : + ret =media_create_pad_link (dev->decoder, +AU8522_PAD_AUDIO_OUT , + new,0 , +MEDIA_LNK_FL_ENABLED ); +if (ret) +dev_err (&dev->usbdev->dev, +"Mixer Pad Link Create Error: %d\n" , + ret); +break ; +default : +break ; + } +#endif +} +static int au0828_media_device_register (struct au0828_dev *dev,struct usb_device *udev) {#ifdef CONFIG_MEDIA_CONTROLLER int ret; -if (dev->media_dev && - !media_devnode_is_registered (&dev->media_dev->devnode)) { +if (!dev->media_dev) +return 0 ; + +if (!media_devnode_is_registered (&dev->media_dev->devnode)) {/* register media device */ ret =media_device_register (dev->media_dev);
@@ -364,6 +392,17 @@ static int au0828_media_device_register(struct au0828_dev *dev, return ret; } } +/* register entity_notify callback */ + dev->entity_notify.notify_data = (void *) dev; + dev->entity_notify.notify = (void *) au0828_media_graph_notify; + ret =media_device_register_entity_notify (dev->media_dev, + &dev->entity_notify); +if (ret) { +dev_err (&udev->dev, +"Media Device register entity_notify Error: %d\n" , + ret); +return ret; + }#endif return 0 ; }
drivers/media/usb/au0828/au0828.h +1 -0
@@ -283,6 +283,7 @@ struct au0828_dev {struct media_entity *decoder;struct media_entity input_ent[AU0828_MAX_INPUT ];struct media_pad input_pad[AU0828_MAX_INPUT ]; +struct media_entity_notify entity_notify;#endif };
Signature · 1 line
2.5.0
PATCH v3 19/22 media: au0828 add enable, disable source handlers
In reply to Shuah KhanAdd 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.
--- drivers/media/usb/au0828/au0828-core.c | 202 +++++++++++++++++++++++++++++++++ drivers/media/usb/au0828/au0828.h | 5 + 2 files changed, 207 insertions(+)
drivers/media/usb/au0828/au0828-core.c +202 -0
@@ -282,6 +282,7 @@ static int au0828_create_media_graph(struct au0828_dev *dev)return -EINVAL ;if (tuner) { + dev->tuner = tuner;/* create tuner to decoder link in deactivated state */ ret =media_create_pad_link (tuner,TUNER_PAD_OUTPUT , decoder,0 ,0 );
@@ -373,6 +374,203 @@ void au0828_media_graph_notify(struct media_entity *new, void *notify_data)#endif } +static int au0828_enable_source (struct media_entity *entity, +struct media_pipeline *pipe) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +struct media_entity *source, *find_source; +struct media_entity *sink; +struct media_link *link, *found_link =NULL ; +int ret =0 ; +struct media_device *mdev = entity->graph_obj.mdev; +struct au0828_dev *dev; + +if (!mdev) +return -ENODEV ; + +mutex_lock (&mdev->graph_mutex); + + dev = mdev->source_priv; + +/* +* For Audio and V4L2 entity, find the link to which decoder +* is the sink. Look for an active link between decoder and +* source (tuner/s-video/Composite), if one exists, nothing +* to do. If not, look for any active links between source +* and any other entity. If one exists, source is busy. If +* source is free, setup link and start pipeline from source. +* For DVB FE entity, the source for the link is the tuner. +* Check if tuner is available and setup link and start +* pipeline. +*/ +if (entity->function ==MEDIA_ENT_F_DTV_DEMOD ) { + sink = entity; + find_source = dev->tuner; + }else { +/* Analog isn't configured or register failed */ +if (!dev->decoder) { + ret = -ENODEV ; + goto end; + } + + sink = dev->decoder; + +/* +* Default input is tuner and default input_type +* is AU0828_VMUX_TELEVISION. +* FIXME: +* There is a problem when s_input is called to +* change the default input. s_input will try to +* enable_source before attempting to change the +* input on the device, and will end up enabling +* default source which is tuner. +* +* Additional logic is necessary in au0828 +* to detect that the input has changed and +* enable the right source. +*/ + +if (dev->input_type ==AU0828_VMUX_TELEVISION ) + find_source = dev->tuner; +else if (dev->input_type ==AU0828_VMUX_SVIDEO || + dev->input_type ==AU0828_VMUX_COMPOSITE ) + find_source = &dev->input_ent[dev->input_type]; +else { +/* unknown input - let user select input */ + ret =0 ; + goto end; + } + } + +/* Is an active link between sink and source */ +if (dev->active_link) { +/* +* If DVB is using the tuner and calling entity is +* audio/video, the following check will be false, +* since sink is different. Result is Busy. +*/ +if (dev->active_link->sink->entity == sink && + dev->active_link->source->entity == find_source) { +/* +* Either ALSA or Video own tuner. sink is +* the same for both. Prevent Video stepping +* on ALSA when ALSA owns the source. +*/ +if (dev->active_link_owner != entity && + dev->active_link_owner->function == +MEDIA_ENT_F_AUDIO_CAPTURE ) { +pr_debug ("ALSA has the tuner\n" ); + ret = -EBUSY ; + goto end; + } + ret =0 ; + goto end; + }else { + ret = -EBUSY ; + goto end; + } + } + +list_for_each_entry (link, &sink->links, list) { +/* Check sink, and source */ +if (link->sink->entity == sink && + link->source->entity == find_source) { + found_link = link; +break ; + } + } + +if (!found_link) { + ret = -ENODEV ; + goto end; + } + +/* activate link between source and sink and start pipeline */ + source = found_link->source->entity; + ret =__media_entity_setup_link (found_link,MEDIA_LNK_FL_ENABLED ); +if (ret) { +pr_err ("Activate tuner link %s->%s. Error %d\n" , + source->name, sink->name, ret); + goto end; + } + + ret =__media_entity_pipeline_start (entity, pipe); +if (ret) { +pr_err ("Start Pipeline: %s->%s Error %d\n" , + source->name, entity->name, ret); + ret =__media_entity_setup_link (found_link,0 ); +pr_err ("Deactivate link Error %d\n" , ret); + goto end; + } +/* +* save active link and active link owner to avoid audio +* deactivating video owned link from disable_source and +* vice versa +*/ + dev->active_link = found_link; + dev->active_link_owner = entity; + dev->active_source = source; + dev->active_sink = sink; + +pr_debug ("Enabled Source: %s->%s->%s Ret %d\n" , + dev->active_source->name, dev->active_sink->name, + dev->active_link_owner->name, ret); +end: +mutex_unlock (&mdev->graph_mutex); +pr_debug ("au0828_enable_source() end %s %d %d\n" , + entity->name, entity->function, ret); +return ret; +#endif +return 0 ; +} + +static void au0828_disable_source (struct media_entity *entity) +{ +#ifdef CONFIG_MEDIA_CONTROLLER +int ret =0 ; +struct media_device *mdev = entity->graph_obj.mdev; +struct au0828_dev *dev; + +if (!mdev) +return ; + +mutex_lock (&mdev->graph_mutex); + dev = mdev->source_priv; + +if (!dev->active_link) { + ret = -ENODEV ; + goto end; + } + +/* link is active - stop pipeline from source (tuner) */ +if (dev->active_link->sink->entity == dev->active_sink && + dev->active_link->source->entity == dev->active_source) { +/* +* prevent video from deactivating link when audio +* has active pipeline +*/ +if (dev->active_link_owner != entity) + goto end; +__media_entity_pipeline_stop (entity); + ret =__media_entity_setup_link (dev->active_link,0 ); +if (ret) +pr_err ("Deactivate link Error %d\n" , ret); + +pr_debug ("Disabled Source: %s->%s->%s Ret %d\n" , + dev->active_source->name, dev->active_sink->name, + dev->active_link_owner->name, ret); + + dev->active_link =NULL ; + dev->active_link_owner =NULL ; + dev->active_source =NULL ; + dev->active_sink =NULL ; + } + +end: +mutex_unlock (&mdev->graph_mutex); +#endif +} +static int au0828_media_device_register (struct au0828_dev *dev,struct usb_device *udev) {
@@ -403,6 +601,10 @@ static int au0828_media_device_register(struct au0828_dev *dev, ret); return ret; } +/* set enable_source */ + dev->media_dev->source_priv = (void *) dev; + dev->media_dev->enable_source = au0828_enable_source; + dev->media_dev->disable_source = au0828_disable_source;#endif return 0 ; }
drivers/media/usb/au0828/au0828.h +5 -0
@@ -284,6 +284,11 @@ struct au0828_dev {struct media_entity input_ent[AU0828_MAX_INPUT ];struct media_pad input_pad[AU0828_MAX_INPUT ];struct media_entity_notify entity_notify; +struct media_entity *tuner; +struct media_link *active_link; +struct media_entity *active_link_owner; +struct media_entity *active_source; +struct media_entity *active_sink;#endif };
Signature · 1 line
2.5.0
PATCH v3 20/22 media: dvb-frontend invoke enable/disable_source handlers
In reply to Shuah KhanChange dvb frontend to check if tuner is free when device opened in RW mode. Call to enable_source handler either returns with an active pipeline to tuner or error if tuner is busy. Tuner is released when frontend is released calling the disable_source handler.
--- drivers/media/dvb-core/dvb_frontend.c | 135 ++++++---------------------------- 1 file changed, 21 insertions(+), 114 deletions(-)
drivers/media/dvb-core/dvb_frontend.c +21 -114
@@ -134,7 +134,6 @@ struct dvb_frontend_private {#if defined(CONFIG_MEDIA_CONTROLLER_DVB )struct media_pipeline pipe; -struct media_entity *pipe_start_entity;#endif };
@@ -596,104 +595,12 @@ static void dvb_frontend_wakeup(struct dvb_frontend *fe)wake_up_interruptible (&fepriv->wait_queue); } -/** -* dvb_enable_media_tuner() - tries to enable the DVB tuner -* -* @fe: struct dvb_frontend pointer -* -* This function ensures that just one media tuner is enabled for a given -* frontend. It has two different behaviors: -* - For trivial devices with just one tuner: -* it just enables the existing tuner->fe link -* - For devices with more than one tuner: -* It is up to the driver to implement the logic that will enable one tuner -* and disable the other ones. However, if more than one tuner is enabled for -* the same frontend, it will print an error message and return -EINVAL. -* -* At return, it will return the error code returned by media_entity_setup_link, -* or 0 if everything is OK, if no tuner is linked to the frontend or if the -* mdev is NULL. -*/ -#ifdef CONFIG_MEDIA_CONTROLLER_DVB -static int dvb_enable_media_tuner (struct dvb_frontend *fe) -{ -struct dvb_frontend_private *fepriv = fe->frontend_priv; -struct dvb_adapter *adapter = fe->dvb; -struct media_device *mdev = adapter->mdev; -struct media_entity *entity, *source; -struct media_link *link, *found_link =NULL ; -int ret, n_links =0 , active_links =0 ; - - fepriv->pipe_start_entity =NULL ; - -if (!mdev) -return 0 ; - - entity = fepriv->dvbdev->entity; - fepriv->pipe_start_entity = entity; - -list_for_each_entry (link, &entity->links, list) { -if (link->sink->entity == entity) { - found_link = link; - n_links++; -if (link->flags &MEDIA_LNK_FL_ENABLED ) - active_links++; - } - } - -if (!n_links || active_links ==1 || !found_link) -return 0 ; - -/* -* If a frontend has more than one tuner linked, it is up to the driver -* to select with one will be the active one, as the frontend core can't -* guess. If the driver doesn't do that, it is a bug. -*/ -if (n_links >1 && active_links !=1 ) { -dev_err (fe->dvb->device, -"WARNING: there are %d active links among %d tuners. This is a driver's bug!\n" , - active_links, n_links); -return -EINVAL ; - } - - source = found_link->source->entity; - fepriv->pipe_start_entity = source; -list_for_each_entry (link, &source->links, list) { -struct media_entity *sink; -int flags =0 ; - - sink = link->sink->entity; -if (sink == entity) - flags =MEDIA_LNK_FL_ENABLED ; - - ret =media_entity_setup_link (link, flags); -if (ret) { -dev_err (fe->dvb->device, -"Couldn't change link %s->%s to %s. Error %d\n" , - source->name, sink->name, - flags ?"enabled" :"disabled" , - ret); -return ret; - }else -dev_dbg (fe->dvb->device, -"link %s->%s was %s\n" , - source->name, sink->name, - flags ?"ENABLED" :"disabled" ); - } -return 0 ; -} -#endif -static int dvb_frontend_thread (void *data) {struct dvb_frontend *fe = data;struct dvb_frontend_private *fepriv = fe->frontend_priv;enum fe_status s;enum dvbfe_algo algo; -#ifdef CONFIG_MEDIA_CONTROLLER_DVB -int ret; -#endif -bool re_tune = false;bool semheld = false;
@@ -706,20 +613,6 @@ static int dvb_frontend_thread(void *data) fepriv->wakeup =0 ; fepriv->reinitialise =0 ; -#ifdef CONFIG_MEDIA_CONTROLLER_DVB - ret =dvb_enable_media_tuner (fe); -if (ret) { -/* FIXME: return an error if it fails */ -dev_info (fe->dvb->device, -"proceeding with FE task\n" ); - }else if (fepriv->pipe_start_entity) { - ret =media_entity_pipeline_start (fepriv->pipe_start_entity, - &fepriv->pipe); -if (ret) -return ret; - } -#endif -dvb_frontend_init (fe);set_freezable ();
@@ -829,12 +722,6 @@ restart: } } -#ifdef CONFIG_MEDIA_CONTROLLER_DVB -if (fepriv->pipe_start_entity) -media_entity_pipeline_stop (fepriv->pipe_start_entity); - fepriv->pipe_start_entity =NULL ; -#endif -if (dvb_powerdown_on_sleep) {if (fe->ops.set_voltage) fe->ops.set_voltage (fe,SEC_VOLTAGE_OFF );
@@ -2612,9 +2499,20 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) fepriv->tone =-1 ; fepriv->voltage =-1 ; +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +if (fe->dvb->mdev && fe->dvb->mdev->enable_source) { + ret = fe->dvb->mdev->enable_source (dvbdev->entity, + &fepriv->pipe); +if (ret) { +dev_err (fe->dvb->device, +"Tuner is busy. Error %d\n" , ret); + goto err2; + } + } +#endif ret =dvb_frontend_start (fe);if (ret) - goto err2; + goto err3;/* empty event queue */ fepriv->events.eventr = fepriv->events.eventw =0 ;
@@ -2624,7 +2522,12 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)mutex_unlock (&adapter->mfe_lock);return ret; +err3: +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +if (fe->dvb->mdev && fe->dvb->mdev->disable_source) + fe->dvb->mdev->disable_source (dvbdev->entity); err2: +#endif dvb_generic_release (inode, file); err1:if (dvbdev->users ==-1 && fe->ops.ts_bus_ctrl)
@@ -2653,6 +2556,10 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)if (dvbdev->users ==-1 ) {wake_up (&fepriv->wait_queue); +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +if (fe->dvb->mdev && fe->dvb->mdev->disable_source) + fe->dvb->mdev->disable_source (dvbdev->entity); +#endif if (fe->exit !=DVB_FE_NO_EXIT )wake_up (&dvbdev->wait_queue);if (fe->ops.ts_bus_ctrl)
Signature · 1 line
2.5.0
PATCH v3 21/22 media: au0828 video change to use v4l_enable_media_source()
In reply to Shuah KhanChange 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.
--- drivers/media/usb/au0828/au0828-video.c | 102 ++++++++++++-------------------- 1 file changed, 39 insertions(+), 63 deletions(-)
drivers/media/usb/au0828/au0828-video.c +39 -63
@@ -638,64 +638,6 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)return rc; } -static int au0828_enable_analog_tuner (struct au0828_dev *dev) -{ -#ifdef CONFIG_MEDIA_CONTROLLER -struct media_device *mdev = dev->media_dev; -struct media_entity *source; -struct media_link *link, *found_link =NULL ; -int ret, active_links =0 ; - -if (!mdev || !dev->decoder) -return 0 ; - -/* -* This will find the tuner that is connected into the decoder. -* Technically, this is not 100% correct, as the device may be -* using an analog input instead of the tuner. However, as we can't -* do DVB streaming while the DMA engine is being used for V4L2, -* this should be enough for the actual needs. -*/ -list_for_each_entry (link, &dev->decoder->links, list) { -if (link->sink->entity == dev->decoder) { - found_link = link; -if (link->flags &MEDIA_LNK_FL_ENABLED ) - active_links++; -break ; - } - } - -if (active_links ==1 || !found_link) -return 0 ; - - source = found_link->source->entity; -list_for_each_entry (link, &source->links, list) { -struct media_entity *sink; -int flags =0 ; - - sink = link->sink->entity; - -if (sink == dev->decoder) - flags =MEDIA_LNK_FL_ENABLED ; - - ret =media_entity_setup_link (link, flags); -if (ret) { -pr_err ( -"Couldn't change link %s->%s to %s. Error %d\n" , - source->name, sink->name, - flags ?"enabled" :"disabled" , - ret); -return ret; - }else -au0828_isocdbg ( -"link %s->%s was %s\n" , - source->name, sink->name, - flags ?"ENABLED" :"disabled" ); - } -#endif -return 0 ; -} -static int queue_setup (struct vb2_queue *vq,unsigned int *nbuffers,unsigned int *nplanes,unsigned int sizes[],void *alloc_ctxs[])
@@ -707,9 +649,6 @@ static int queue_setup(struct vb2_queue *vq,return sizes[0 ] < size ? -EINVAL :0 ; *nplanes =1 ; sizes[0 ] = size; - -au0828_enable_analog_tuner (dev); -return 0 ; }
@@ -1067,8 +1006,39 @@ static int au0828_v4l2_close(struct file *filp) goto end;if (dev->users ==1 ) { -/* Save some power by putting tuner to sleep */ -v4l2_device_call_all (&dev->v4l2_dev,0 , core, s_power,0 ); +/* +* Avoid putting tuner in sleep if DVB or ALSA are +* streaming. +* +* On most USB devices like au0828 the tuner can +* be safely put in sleep stare here if ALSA isn't +* streaming. Exceptions are some very old USB tuner +* models such as em28xx-based WinTV USB2 which have +* a separate audio output jack. The devices that have +* a separate audio output jack have analog tuners, +* like Philips FM1236. Those devices are always on, +* so the s_power callback are silently ignored. +* So, the current logic here does the following: +* Disable (put tuner to sleep) when +* - ALSA and DVB aren't not streaming; +* - the last V4L2 file handler is closed. +* +* FIXME: +* +* Additionally, this logic could be improved to +* disable the media source if the above conditions +* are met and if the device: +* - doesn't have a separate audio out plug (or +* - doesn't use a silicon tuner like xc2028/3028/4000/5000). +* +* Once this additional logic is in place, a callback +* is needed to enable the media source and power on +* the tuner, for radio to work. +*/ + ret =v4l_enable_media_source (vdev); +if (ret ==0 ) +v4l2_device_call_all (&dev->v4l2_dev,0 , core, + s_power,0 ); dev->std_set_in_tuner_core =0 ;/* When close the device, set the usb intf0 into alt0 to free
@@ -1469,10 +1439,16 @@ static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audiostatic int vidioc_g_tuner (struct file *file,void *priv,struct v4l2_tuner *t) {struct au0828_dev *dev =video_drvdata (file); +struct video_device *vfd =video_devdata (file); +int ret;if (t->index !=0 )return -EINVAL ; + ret =v4l_enable_media_source (vfd); +if (ret) +return ret; +dprintk (1 ,"%s called std_set %d dev_state %d\n" , __func__, dev->std_set_in_tuner_core, dev->dev_state);
Signature · 1 line
2.5.0
PATCH v3 22/22 sound/usb: Use Media Controller API to share media resources
In reply to Shuah KhanChange ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
snd_usb_hw_params() will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it from snd_usb_hw_free(). If resource is busy, -EBUSY is returned.
Media specific cleanup is done in usb_audio_disconnect().
--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.h
sound/usb/Kconfig +4 -0
@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORT help Say Y here to include support for USB audio and USB MIDI devices.
@@ -22,6 +23,9 @@ config SND_USB_AUDIO To compile this driver as a module, choose M here: the module will be called snd-usb-audio. +config SND_USB_AUDIO_USE_MEDIA_CONTROLLER + bool + config SND_USB_UA101 tristate "Edirol UA-101/UA-1000 driver" select SND_PCM
sound/usb/Makefile +2 -0
@@ -15,6 +15,8 @@ snd-usb-audio-objs := card.o \ quirks.o \ stream.o +snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o + snd-usbmidi-lib-objs := midi.o # Toplevel Module Dependency
sound/usb/card.c +14 -0
@@ -66,6 +66,7 @@#include "format.h" #include "power.h" #include "stream.h" +#include "media.h" MODULE_AUTHOR ("Takashi Iwai <[email protected]>" );MODULE_DESCRIPTION ("USB Audio" );
@@ -561,6 +562,11 @@ static int usb_audio_probe(struct usb_interface *intf,if (err <0 ) goto __error; +if (quirk->media_device) { +/* don't want to fail when media_device_create() fails */ +media_device_create (chip, intf); + } + usb_chip[chip->index] = chip; chip->num_interfaces++;usb_set_intfdata (intf, chip);
@@ -617,6 +623,14 @@ static void usb_audio_disconnect(struct usb_interface *intf)list_for_each (p, &chip->midi_list) {snd_usbmidi_disconnect (p); } +/* +* Nice to check quirk && quirk->media_device +* need some special handlings. Doesn't look like +* we have access to quirk here +* Acceses mixer_list +*/ +media_device_delete (chip); +/* release mixer resources */ list_for_each_entry (mixer, &chip->mixer_list, list) {snd_usb_mixer_disconnect (mixer);
sound/usb/card.h +3 -0
@@ -105,6 +105,8 @@ struct snd_usb_endpoint {struct list_head list; }; +struct media_ctl ; +struct snd_usb_substream {struct snd_usb_stream *stream;struct usb_device *dev;
@@ -156,6 +158,7 @@ struct snd_usb_substream { } dsd_dop;bool trigger_tstamp_pending_update;/* trigger timestamp being updated from initial estimate */ +struct media_ctl *media_ctl; };struct snd_usb_stream {
sound/usb/media.c new file +318 -0
318 lines not on this page · raw message
sound/usb/media.h new file +72 -0
72 lines not on this page · raw message
sound/usb/mixer.h +3 -0
@@ -3,6 +3,8 @@#include <sound/info.h> +struct media_mixer_ctl ; +struct usb_mixer_interface {struct snd_usb_audio *chip;struct usb_host_interface *hostif;
@@ -22,6 +24,7 @@ struct usb_mixer_interface {struct urb *rc_urb;struct usb_ctrlrequest *rc_setup_packet;u8 rc_buffer[6 ]; +struct media_mixer_ctl *media_mixer_ctl; };#define MAX_CHANNELS 16/* max logical channels */
sound/usb/pcm.c +23 -5
@@ -35,6 +35,7 @@#include "pcm.h" #include "clock.h" #include "power.h" +#include "media.h" #define SUBSTREAM_FLAG_DATA_EP_STARTED 0#define SUBSTREAM_FLAG_SYNC_EP_STARTED 1
@@ -715,10 +716,14 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,struct audioformat *fmt;int ret; + ret =media_start_pipeline (subs); +if (ret) +return ret; + ret =snd_pcm_lib_alloc_vmalloc_buffer (substream,params_buffer_bytes (hw_params));if (ret <0 ) -return ret; + goto err_ret; subs->pcm_format =params_format (hw_params); subs->period_bytes =params_period_bytes (hw_params);
@@ -732,22 +737,27 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,dev_dbg (&subs->dev->dev,"cannot set format: format = %#x, rate = %d, channels = %d\n" , subs->pcm_format, subs->cur_rate, subs->channels); -return -EINVAL ; + ret = -EINVAL ; + goto err_ret; } ret =snd_usb_lock_shutdown (subs->stream->chip);if (ret <0 ) -return ret; + goto err_ret; ret =set_format (subs, fmt);snd_usb_unlock_shutdown (subs->stream->chip);if (ret <0 ) -return ret; + goto err_ret; subs->interface = fmt->iface; subs->altset_idx = fmt->altset_idx; subs->need_setup_ep = true;return 0 ; + +err_ret: +media_stop_pipeline (subs); +return ret; }/*
@@ -759,6 +769,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) {struct snd_usb_substream *subs = substream->runtime->private_data; +media_stop_pipeline (subs); subs->cur_audiofmt =NULL ; subs->cur_rate =0 ; subs->period_bytes =0 ;
@@ -1219,6 +1230,7 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction)struct snd_usb_stream *as =snd_pcm_substream_chip (substream);struct snd_pcm_runtime *runtime = substream->runtime;struct snd_usb_substream *subs = &as->substream[direction]; +int ret; subs->interface =-1 ; subs->altset_idx =0 ;
@@ -1232,7 +1244,12 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction) subs->dsd_dop.channel =0 ; subs->dsd_dop.marker =1 ; -return setup_hw_info (runtime, subs); + ret =setup_hw_info (runtime, subs); +if (ret ==0 ) + ret =media_stream_init (subs, as->pcm, direction); +if (ret) +snd_usb_autosuspend (subs->stream->chip); +return ret; }static int snd_usb_pcm_close (struct snd_pcm_substream *substream,int direction)
@@ -1241,6 +1258,7 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)struct snd_usb_substream *subs = &as->substream[direction];stop_endpoints (subs, true); +media_stop_pipeline (subs);if (subs->interface >=0 && !snd_usb_lock_shutdown (subs->stream->chip)) {
sound/usb/quirks-table.h +1 -0
@@ -2886,6 +2886,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), .product_name = pname, \ .ifnum = QUIRK_ANY_INTERFACE, \ .type = QUIRK_AUDIO_ALIGN_TRANSFER, \ + .media_device = 1, \ } \ }
sound/usb/stream.c +2 -0
@@ -36,6 +36,7 @@#include "format.h" #include "clock.h" #include "stream.h" +#include "media.h" /* * free a substream
@@ -52,6 +53,7 @@ static void free_substream(struct snd_usb_substream *subs)kfree (fp); }kfree (subs->rate_list.list); +media_stream_delete (subs); }
sound/usb/usbaudio.h +6 -0
@@ -30,6 +30,9 @@* */ +struct media_device ; +struct media_intf_devnode ; +struct snd_usb_audio {int index;struct usb_device *dev;
@@ -60,6 +63,8 @@ struct snd_usb_audio {bool autoclock;/* from the 'autoclock' module param */ struct usb_host_interface *ctrl_intf;/* the audio control interface */ +struct media_device *media_dev; +struct media_intf_devnode *ctl_intf_media_devnode; }; #define usb_audio_err(chip, fmt, args...) \
@@ -110,6 +115,7 @@ struct snd_usb_audio_quirk {const char *product_name;int16_t ifnum;uint16_t type; +bool media_device;const void *data; };
Signature · 1 line
2.5.0
Re: [PATCH v3 22/22] sound/usb: Use Media Controller API to share media resources
Quoted 8 lines · Shuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
Quoted 8 lines
snd_usb_hw_params()will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it fromsnd_usb_hw_free(). If resource is busy,-EBUSYis returned.Media specific cleanup is done in
usb_audio_disconnect().Signed-off-by Shuah Khan <[email protected]>
Hi Takashi,
Hope you are okay with this version. I addressed all your comments. Could you please Ack it or let me know if there is something I still need to address.
thanks,
-- Shuah
Quoted 695 lines
--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.hsound/usb/Kconfig +4
-0@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORT help Say Y here to include support for USB audio and USB MIDI devices.@@ -22,6 +23,9 @@ config SND_USB_AUDIO To compile this driver as a module, choose M here: the module will be called snd-usb-audio. +config SND_USB_AUDIO_USE_MEDIA_CONTROLLER + bool + config SND_USB_UA101 tristate "Edirol UA-101/UA-1000 driver" select SND_PCMsound/usb/Makefile +2
-0@@ -15,6 +15,8 @@ snd-usb-audio-objs := card.o \ quirks.o \ stream.o +snd-usb-audio-$(CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER) += media.o + snd-usbmidi-lib-objs := midi.o # Toplevel Module Dependencysound/usb/card.c +14
-0@@ -66,6 +66,7 @@#include "format.h" #include "power.h" #include "stream.h" +#include "media.h" MODULE_AUTHOR ("Takashi Iwai <[email protected]>" );MODULE_DESCRIPTION ("USB Audio" );@@ -561,6 +562,11 @@ static int usb_audio_probe(struct usb_interface *intf,if (err <0 ) goto __error; +if (quirk->media_device) { +/* don't want to fail when media_device_create() fails */ +media_device_create (chip, intf); + } + usb_chip[chip->index] = chip; chip->num_interfaces++;usb_set_intfdata (intf, chip);@@ -617,6 +623,14 @@ static void usb_audio_disconnect(struct usb_interface *intf)list_for_each (p, &chip->midi_list) {snd_usbmidi_disconnect (p); } +/* +* Nice to check quirk && quirk->media_device +* need some special handlings. Doesn't look like +* we have access to quirk here +* Acceses mixer_list +*/ +media_device_delete (chip); +/* release mixer resources */ list_for_each_entry (mixer, &chip->mixer_list, list) {snd_usb_mixer_disconnect (mixer);sound/usb/card.h +3
-0@@ -105,6 +105,8 @@ struct snd_usb_endpoint {struct list_head list; }; +struct media_ctl ; +struct snd_usb_substream {struct snd_usb_stream *stream;struct usb_device *dev;@@ -156,6 +158,7 @@ struct snd_usb_substream { } dsd_dop;bool trigger_tstamp_pending_update;/* trigger timestamp being updated from initial estimate */ +struct media_ctl *media_ctl; };struct snd_usb_stream {sound/usb/media.c new file +318
-0@@ -0,0 +1,318 @@ +/* +* media.c - Media Controller specific ALSA driver code +* +* Copyright (c) 2016 Shuah Khan <[email protected]> +* Copyright (c) 2016 Samsung Electronics Co., Ltd. +* +* This file is released under the GPLv2. +*/ + +/* +* This file adds Media Controller support to ALSA driver +* to use the Media Controller API to share tuner with DVB +* and V4L2 drivers that control media device. Media device +* is created based on existing quirks framework. Using this +* approach, the media controller API usage can be added for +* a specific device. +*/ + +#include <linux/init.h> +#include <linux/list.h> +#include <linux/mutex.h> +#include <linux/slab.h> +#include <linux/usb.h> + +#include <sound/pcm.h> +#include <sound/core.h> + +#include "usbaudio.h" +#include "card.h" +#include "mixer.h" +#include "media.h" + +static int media_enable_source (struct media_ctl *mctl) +{ +if (mctl && mctl->media_dev->enable_source) +return mctl->media_dev->enable_source (&mctl->media_entity, + &mctl->media_pipe); +return 0 ; +} + +static void media_disable_source (struct media_ctl *mctl) +{ +if (mctl && mctl->media_dev->disable_source) + mctl->media_dev->disable_source (&mctl->media_entity); +} + +int media_stream_init (struct snd_usb_substream *subs,struct snd_pcm *pcm, +int stream) +{ +struct media_device *mdev; +struct media_ctl *mctl; +struct device *pcm_dev = &pcm->streams[stream].dev; +u32 intf_type; +int ret =0 ; +u16 mixer_pad; +struct media_entity *entity; + + mdev = subs->stream->chip->media_dev; +if (!mdev) +return -ENODEV ; + +if (subs->media_ctl) +return 0 ; + +/* allocate media_ctl */ + mctl =kzalloc (sizeof (*mctl),GFP_KERNEL ); +if (!mctl) +return -ENOMEM ; + + mctl->media_dev = mdev; +if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + intf_type =MEDIA_INTF_T_ALSA_PCM_PLAYBACK ; + mctl->media_entity.function =MEDIA_ENT_F_AUDIO_PLAYBACK ; + mctl->media_pad.flags =MEDIA_PAD_FL_SOURCE ; + mixer_pad =1 ; + }else { + intf_type =MEDIA_INTF_T_ALSA_PCM_CAPTURE ; + mctl->media_entity.function =MEDIA_ENT_F_AUDIO_CAPTURE ; + mctl->media_pad.flags =MEDIA_PAD_FL_SINK ; + mixer_pad =2 ; + } + mctl->media_entity.name = pcm->name; +media_entity_pads_init (&mctl->media_entity,1 , &mctl->media_pad); + ret =media_device_register_entity (mctl->media_dev, + &mctl->media_entity); +if (ret) + goto err1; + + mctl->intf_devnode =media_devnode_create (mdev, intf_type,0 , +MAJOR (pcm_dev->devt), +MINOR (pcm_dev->devt)); +if (!mctl->intf_devnode) { + ret = -ENOMEM ; + goto err2; + } + mctl->intf_link =media_create_intf_link (&mctl->media_entity, + &mctl->intf_devnode->intf, +MEDIA_LNK_FL_ENABLED ); +if (!mctl->intf_link) { + ret = -ENOMEM ; + goto err3; + } + +/* create link between mixer and audio */ +media_device_for_each_entity (entity, mdev) { +switch (entity->function) { +case MEDIA_ENT_F_AUDIO_MIXER : + ret =media_create_pad_link (entity, mixer_pad, + &mctl->media_entity,0 , +MEDIA_LNK_FL_ENABLED ); +if (ret) + goto err4; +break ; + } + } + + subs->media_ctl = mctl; +return 0 ; + +err4: +media_remove_intf_link (mctl->intf_link); +err3: +media_devnode_remove (mctl->intf_devnode); +err2: +media_device_unregister_entity (&mctl->media_entity); +err1: +kfree (mctl); +return ret; +} + +void media_stream_delete (struct snd_usb_substream *subs) +{ +struct media_ctl *mctl = subs->media_ctl; + +if (mctl && mctl->media_dev) { +struct media_device *mdev; + + mdev = subs->stream->chip->media_dev; +if (mdev &&media_devnode_is_registered (&mdev->devnode)) { +media_devnode_remove (mctl->intf_devnode); +media_device_unregister_entity (&mctl->media_entity); +media_entity_cleanup (&mctl->media_entity); + } +kfree (mctl); + subs->media_ctl =NULL ; + } +} + +int media_start_pipeline (struct snd_usb_substream *subs) +{ +struct media_ctl *mctl = subs->media_ctl; + +if (mctl) +return media_enable_source (mctl); +return 0 ; +} + +void media_stop_pipeline (struct snd_usb_substream *subs) +{ +struct media_ctl *mctl = subs->media_ctl; + +if (mctl) +media_disable_source (mctl); +} + +int media_mixer_init (struct snd_usb_audio *chip) +{ +struct device *ctl_dev = &chip->card->ctl_dev; +struct media_intf_devnode *ctl_intf; +struct usb_mixer_interface *mixer; +struct media_device *mdev = chip->media_dev; +struct media_mixer_ctl *mctl; +u32 intf_type =MEDIA_INTF_T_ALSA_CONTROL ; +int ret; + +if (!mdev) +return -ENODEV ; + + ctl_intf = chip->ctl_intf_media_devnode; +if (!ctl_intf) { + ctl_intf =media_devnode_create (mdev, intf_type,0 , +MAJOR (ctl_dev->devt), +MINOR (ctl_dev->devt)); +if (!ctl_intf) +return -ENOMEM ; + chip->ctl_intf_media_devnode = ctl_intf; + } + +list_for_each_entry (mixer, &chip->mixer_list, list) { + +if (mixer->media_mixer_ctl) +continue ; + +/* allocate media_mixer_ctl */ + mctl =kzalloc (sizeof (*mctl),GFP_KERNEL ); +if (!mctl) +return -ENOMEM ; + + mctl->media_dev = mdev; + mctl->media_entity.function =MEDIA_ENT_F_AUDIO_MIXER ; + mctl->media_entity.name = chip->card->mixername; + mctl->media_pad[0 ].flags =MEDIA_PAD_FL_SINK ; + mctl->media_pad[1 ].flags =MEDIA_PAD_FL_SOURCE ; + mctl->media_pad[2 ].flags =MEDIA_PAD_FL_SOURCE ; +media_entity_pads_init (&mctl->media_entity,MEDIA_MIXER_PAD_MAX , + mctl->media_pad); + ret =media_device_register_entity (mctl->media_dev, + &mctl->media_entity); +if (ret) { +kfree (mctl); +return ret; + } + + mctl->intf_link =media_create_intf_link (&mctl->media_entity, + &ctl_intf->intf, +MEDIA_LNK_FL_ENABLED ); +if (!mctl->intf_link) { +media_device_unregister_entity (&mctl->media_entity); +media_entity_cleanup (&mctl->media_entity); +kfree (mctl); +return -ENOMEM ; + } + mctl->intf_devnode = ctl_intf; + mixer->media_mixer_ctl = mctl; + } +return 0 ; +} + +static void media_mixer_delete (struct snd_usb_audio *chip) +{ +struct usb_mixer_interface *mixer; +struct media_device *mdev = chip->media_dev; + +if (!mdev) +return ; + +list_for_each_entry (mixer, &chip->mixer_list, list) { +struct media_mixer_ctl *mctl; + + mctl = mixer->media_mixer_ctl; +if (!mixer->media_mixer_ctl) +continue ; + +if (media_devnode_is_registered (&mdev->devnode)) { +media_device_unregister_entity (&mctl->media_entity); +media_entity_cleanup (&mctl->media_entity); + } +kfree (mctl); + mixer->media_mixer_ctl =NULL ; + } +if (media_devnode_is_registered (&mdev->devnode)) +media_devnode_remove (chip->ctl_intf_media_devnode); + chip->ctl_intf_media_devnode =NULL ; +} + +int media_device_create (struct snd_usb_audio *chip, +struct usb_interface *iface) +{ +struct media_device *mdev; +struct usb_device *usbdev =interface_to_usbdev (iface); +int ret; + + mdev =media_device_get_devres (&usbdev->dev); +if (!mdev) +return -ENOMEM ; +if (!mdev->dev) { +/* register media device */ + mdev->dev = &usbdev->dev; +if (usbdev->product) +strlcpy (mdev->model, usbdev->product, +sizeof (mdev->model)); +if (usbdev->serial) +strlcpy (mdev->serial, usbdev->serial, +sizeof (mdev->serial)); +strcpy (mdev->bus_info, usbdev->devpath); + mdev->hw_revision =le16_to_cpu (usbdev->descriptor.bcdDevice); +media_device_init (mdev); + } +if (!media_devnode_is_registered (&mdev->devnode)) { + ret =media_device_register (mdev); +if (ret) { +dev_err (&usbdev->dev, +"Couldn't register media device. Error: %d\n" , + ret); +return ret; + } + } + +/* save media device - avoid lookups */ + chip->media_dev = mdev; + +/* Create media entities for mixer and control dev */ + ret =media_mixer_init (chip); +if (ret) { +dev_err (&usbdev->dev, +"Couldn't create media mixer entities. Error: %d\n" , + ret); + +/* clear saved media_dev */ + chip->media_dev =NULL ; + +return ret; + } +return 0 ; +} + +void media_device_delete (struct snd_usb_audio *chip) +{ +struct media_device *mdev = chip->media_dev; + +media_mixer_delete (chip); + +if (mdev) { +if (media_devnode_is_registered (&mdev->devnode)) +media_device_unregister (mdev); + chip->media_dev =NULL ; + } +}sound/usb/media.h new file +72
-0@@ -0,0 +1,72 @@ +/* +* media.h - Media Controller specific ALSA driver code +* +* Copyright (c) 2016 Shuah Khan <[email protected]> +* Copyright (c) 2016 Samsung Electronics Co., Ltd. +* +* This file is released under the GPLv2. +*/ + +/* +* This file adds Media Controller support to ALSA driver +* to use the Media Controller API to share tuner with DVB +* and V4L2 drivers that control media device. Media device +* is created based on existing quirks framework. Using this +* approach, the media controller API usage can be added for +* a specific device. +*/ +#ifndef __MEDIA_H + +#ifdef CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER + +#include <media/media-device.h> +#include <media/media-entity.h> +#include <sound/asound.h> + +struct media_ctl { +struct media_device *media_dev; +struct media_entity media_entity; +struct media_intf_devnode *intf_devnode; +struct media_link *intf_link; +struct media_pad media_pad; +struct media_pipeline media_pipe; +}; + +/* +* One source pad each for SNDRV_PCM_STREAM_CAPTURE and +* SNDRV_PCM_STREAM_PLAYBACK. One for sink pad to link +* to AUDIO Source +*/ +#define MEDIA_MIXER_PAD_MAX (SNDRV_PCM_STREAM_LAST + 2) + +struct media_mixer_ctl { +struct media_device *media_dev; +struct media_entity media_entity; +struct media_intf_devnode *intf_devnode; +struct media_link *intf_link; +struct media_pad media_pad[MEDIA_MIXER_PAD_MAX ]; +struct media_pipeline media_pipe; +}; + +int media_device_create (struct snd_usb_audio *chip, +struct usb_interface *iface); +void media_device_delete (struct snd_usb_audio *chip); +int media_stream_init (struct snd_usb_substream *subs,struct snd_pcm *pcm, +int stream); +void media_stream_delete (struct snd_usb_substream *subs); +int media_start_pipeline (struct snd_usb_substream *subs); +void media_stop_pipeline (struct snd_usb_substream *subs); +#else +static inline int media_device_create (struct snd_usb_audio *chip, +struct usb_interface *iface) + {return 0 ; } +static inline void media_device_delete (struct snd_usb_audio *chip) { } +static inline int media_stream_init (struct snd_usb_substream *subs, +struct snd_pcm *pcm,int stream) + {return 0 ; } +static inline void media_stream_delete (struct snd_usb_substream *subs) { } +static inline int media_start_pipeline (struct snd_usb_substream *subs) + {return 0 ; } +static inline void media_stop_pipeline (struct snd_usb_substream *subs) { } +#endif +#endif /* __MEDIA_H */ sound/usb/mixer.h +3
-0@@ -3,6 +3,8 @@#include <sound/info.h> +struct media_mixer_ctl ; +struct usb_mixer_interface {struct snd_usb_audio *chip;struct usb_host_interface *hostif;@@ -22,6 +24,7 @@ struct usb_mixer_interface {struct urb *rc_urb;struct usb_ctrlrequest *rc_setup_packet;u8 rc_buffer[6 ]; +struct media_mixer_ctl *media_mixer_ctl; };#define MAX_CHANNELS 16/* max logical channels */ sound/usb/pcm.c +23
-5@@ -35,6 +35,7 @@#include "pcm.h" #include "clock.h" #include "power.h" +#include "media.h" #define SUBSTREAM_FLAG_DATA_EP_STARTED 0#define SUBSTREAM_FLAG_SYNC_EP_STARTED 1@@ -715,10 +716,14 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,struct audioformat *fmt;int ret; + ret =media_start_pipeline (subs); +if (ret) +return ret; + ret =snd_pcm_lib_alloc_vmalloc_buffer (substream,params_buffer_bytes (hw_params));if (ret <0 ) -return ret; + goto err_ret; subs->pcm_format =params_format (hw_params); subs->period_bytes =params_period_bytes (hw_params);@@ -732,22 +737,27 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,dev_dbg (&subs->dev->dev,"cannot set format: format = %#x, rate = %d, channels = %d\n" , subs->pcm_format, subs->cur_rate, subs->channels); -return -EINVAL ; + ret = -EINVAL ; + goto err_ret; } ret =snd_usb_lock_shutdown (subs->stream->chip);if (ret <0 ) -return ret; + goto err_ret; ret =set_format (subs, fmt);snd_usb_unlock_shutdown (subs->stream->chip);if (ret <0 ) -return ret; + goto err_ret; subs->interface = fmt->iface; subs->altset_idx = fmt->altset_idx; subs->need_setup_ep = true;return 0 ; + +err_ret: +media_stop_pipeline (subs); +return ret; }/* @@ -759,6 +769,7 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream) {struct snd_usb_substream *subs = substream->runtime->private_data; +media_stop_pipeline (subs); subs->cur_audiofmt =NULL ; subs->cur_rate =0 ; subs->period_bytes =0 ;@@ -1219,6 +1230,7 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction)struct snd_usb_stream *as =snd_pcm_substream_chip (substream);struct snd_pcm_runtime *runtime = substream->runtime;struct snd_usb_substream *subs = &as->substream[direction]; +int ret; subs->interface =-1 ; subs->altset_idx =0 ;@@ -1232,7 +1244,12 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction) subs->dsd_dop.channel =0 ; subs->dsd_dop.marker =1 ; -return setup_hw_info (runtime, subs); + ret =setup_hw_info (runtime, subs); +if (ret ==0 ) + ret =media_stream_init (subs, as->pcm, direction); +if (ret) +snd_usb_autosuspend (subs->stream->chip); +return ret; }static int snd_usb_pcm_close (struct snd_pcm_substream *substream,int direction)@@ -1241,6 +1258,7 @@ static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction)struct snd_usb_substream *subs = &as->substream[direction];stop_endpoints (subs, true); +media_stop_pipeline (subs);if (subs->interface >=0 && !snd_usb_lock_shutdown (subs->stream->chip)) {sound/usb/quirks-table.h +1
-0@@ -2886,6 +2886,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), .product_name = pname, \ .ifnum = QUIRK_ANY_INTERFACE, \ .type = QUIRK_AUDIO_ALIGN_TRANSFER, \ + .media_device = 1, \ } \ }sound/usb/stream.c +2
-0@@ -36,6 +36,7 @@#include "format.h" #include "clock.h" #include "stream.h" +#include "media.h" /* * free a substream @@ -52,6 +53,7 @@ static void free_substream(struct snd_usb_substream *subs)kfree (fp); }kfree (subs->rate_list.list); +media_stream_delete (subs); }sound/usb/usbaudio.h +6
-0@@ -30,6 +30,9 @@* */ +struct media_device ; +struct media_intf_devnode ; +struct snd_usb_audio {int index;struct usb_device *dev;@@ -60,6 +63,8 @@ struct snd_usb_audio {bool autoclock;/* from the 'autoclock' module param */ struct usb_host_interface *ctrl_intf;/* the audio control interface */ +struct media_device *media_dev; +struct media_intf_devnode *ctl_intf_media_devnode; }; #define usb_audio_err(chip, fmt, args...) \@@ -110,6 +115,7 @@ struct snd_usb_audio_quirk {const char *product_name;int16_t ifnum;uint16_t type; +bool media_device;const void *data; };
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Re: [PATCH v3 22/22] sound/usb: Use Media Controller API to share media resources
In reply to Shuah KhanQuoted 38 lines · Shuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
snd_usb_hw_params()will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it fromsnd_usb_hw_free(). If resource is busy,-EBUSYis returned.Media specific cleanup is done in
usb_audio_disconnect().Signed-off-by Shuah Khan <[email protected]>--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.hsound/usb/Kconfig +0
-0
sound/usb/Kconfig config SND_USB_AUDIO · line 18
Quoted 4 lines
sound/usb/Kconfig +1
-0@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORT
Looking at the media Kconfig again, this would be broken if MEDIA_SUPPORT=m and SND_USB_AUDIO=y. The ugly workaround is something like:
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND)
Other than that, it looks more or less OK to me.
The way how media_stream_init() gets called is a bit worrisome, but it should work practically. Another concern is about the disconnection. Can all function calls in media_device_delete() be safe even if it's called while the application still opens the MC device?
In anyway, such a thing can be improved later once after we get this merged, too. So, feel fee to take my ack.
thanks,
Takashi
Re: [PATCH v3 22/22] sound/usb: Use Media Controller API to share media resources
Quoted 48 lines · Takashi Iwai
Quoted 38 lines · Shuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
snd_usb_hw_params()will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it fromsnd_usb_hw_free(). If resource is busy,-EBUSYis returned.Media specific cleanup is done in
usb_audio_disconnect().Signed-off-by Shuah Khan <[email protected]>--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.hsound/usb/Kconfig +0
-0sound/usb/Kconfig config SND_USB_AUDIO · line 18
Quoted 4 lines
sound/usb/Kconfig +1
-0@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORTLooking at the media
Kconfigagain, this would be broken if MEDIA_SUPPORT=m and SND_USB_AUDIO=y. The ugly workaround is something like:
Quoted 2 lines
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND)
My current config is MEDIA_SUPPORT=m and SND_USB_AUDIO=y It is working and I didn't see any issues so far. Maybe the current change is good. I am hoping kbuild-bot can find issues (if any) once it gets merged.
Quoted 6 lines
Other than that, it looks more or less OK to me.
The way howmedia_stream_init()gets called is a bit worrisome, but it should work practically. Another concern is about the disconnection. Can all function calls inmedia_device_delete()be safe even if it's called while the application still opens the MC device?
Right. I have been looking into device removal path when ioctls are active and I can resolve any issues that might surface while an audio app is active when device is removed.
Quoted 5 lines
In anyway, such a thing can be improved later once after we get this merged, too. So, feel fee to take my ack.
Acked-by Takashi Iwai <[email protected]>
thanks for the Ack
-- Shuah
Quoted 6 lines
thanks,
Takashi
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Re: [PATCH v3 22/22] sound/usb: Use Media Controller API to share media resources
Quoted 53 lines · Shuah Khan
Quoted 48 lines · Takashi Iwai
Quoted 38 lines · Shuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
snd_usb_hw_params()will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it fromsnd_usb_hw_free(). If resource is busy,-EBUSYis returned.Media specific cleanup is done in
usb_audio_disconnect().Signed-off-by Shuah Khan <[email protected]>--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.hsound/usb/Kconfig +0
-0sound/usb/Kconfig config SND_USB_AUDIO · line 18
Quoted 4 lines
sound/usb/Kconfig +1
-0@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORTLooking at the media
Kconfigagain, this would be broken if MEDIA_SUPPORT=m and SND_USB_AUDIO=y. The ugly workaround is something like:Quoted 2 lines
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND)
Quoted 2 lines
My current config is MEDIA_SUPPORT=m and SND_USB_AUDIO=y It is working and I didn't see any issues so far.
Hmm, how does it be? In drivers/media/Makefile:
ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
obj-$(CONFIG_MEDIA_SUPPORT) += media.o
endif
So it's a module. Meanwhile you have reference from usb-audio driver that is built-in kernel. How is the symbol resolved?
Quoted 11 lines
Maybe
the current change is good. I am hoping kbuild-bot can find issues (if any) once it gets merged.Quoted 6 lines
Other than that, it looks more or less OK to me.
The way howmedia_stream_init()gets called is a bit worrisome, but it should work practically. Another concern is about the disconnection. Can all function calls inmedia_device_delete()be safe even if it's called while the application still opens the MC device?
Quoted 3 lines
Right. I have been looking into device removal path when ioctls are active and I can resolve any issues that might surface while an audio app is active when device is removed.
So, it's 100% safe to call all these media_*() functions while the device is being accessed before closing?
Takashi
Re: [PATCH v3 22/22] sound/usb: Use Media Controller API to share media resources
Quoted 58 lines · Takashi Iwai
Quoted 53 lines · Shuah Khan
Quoted 48 lines · Takashi Iwai
Quoted 38 lines · Shuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
snd_usb_hw_params()will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it fromsnd_usb_hw_free(). If resource is busy,-EBUSYis returned.Media specific cleanup is done in
usb_audio_disconnect().Signed-off-by Shuah Khan <[email protected]>--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.hsound/usb/Kconfig +0
-0sound/usb/Kconfig config SND_USB_AUDIO · line 18
Quoted 4 lines
sound/usb/Kconfig +1
-0@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORTLooking at the media
Kconfigagain, this would be broken if MEDIA_SUPPORT=m and SND_USB_AUDIO=y. The ugly workaround is something like:Quoted 2 lines
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND)Quoted 2 lines
My current config is MEDIA_SUPPORT=m and SND_USB_AUDIO=y It is working and I didn't see any issues so far.
Quoted 8 lines
Hmm, how does it be? In
drivers/media/Makefile:ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
obj-$(CONFIG_MEDIA_SUPPORT) += media.o
endifSo it's a module. Meanwhile you have reference from usb-audio driver that is built-in kernel. How is the symbol resolved?
Sorry my mistake. I misspoke. My config had:CONFIG_MEDIA_SUPPORT=m CONFIG_MEDIA_CONTROLLER=y CONFIG_SND_USB_AUDIO=m
The following doesn't work as you pointed out.
CONFIG_MEDIA_SUPPORT=mCONFIG_MEDIA_CONTROLLER=yCONFIG_SND_USB_AUDIO=y
okay here is what will work for all of the possible combinations of CONFIG_MEDIA_SUPPORT and CONFIG_SND_USB_AUDIO
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER \
if MEDIA_CONTROLLER && ((MEDIA_SUPPORT=y) || (MEDIA_SUPPORT=m && SND_USB_AUDIO=m))The above will cover the cases when
1. CONFIG_MEDIA_SUPPORT and CONFIG_SND_USB_AUDIO are both modules CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER is selected
2. CONFIG_MEDIA_SUPPORT=y and CONFIG_SND_USB_AUDIO=m CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER is selected
3. CONFIG_MEDIA_SUPPORT=y and CONFIG_SND_USB_AUDIO=y CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER is selected
4. CONFIG_MEDIA_SUPPORT=m and CONFIG_SND_USB_AUDIO=y This is when we don't want CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER selected
I verified all of the above combinations to make sure the logic works.
If you think of a better way to do this please let me know. I will go ahead and send patch v4 with the above change and you can decide if that is acceptable.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Other than that, it looks more or less OK to me.
The way howmedia_stream_init()gets called is a bit worrisome, but it should work practically. Another concern is about the disconnection. Can all function calls inmedia_device_delete()be safe even if it's called while the application still opens the MC device?
Quoted 7 lines
Quoted 3 lines
Right. I have been looking into device removal path when ioctls are active and I can resolve any issues that might surface while an audio app is active when device is removed.
So, it's 100% safe to call all these media_*() functions while the device is being accessed before closing?
There is a known problem with device removal when media device file is open and ioctl is in progress. This isn't specific to this patch series, a general problem that is related to media device removal in general.
I am working on a fix for this problem. As you said, earlier, I can work on fixing issues after the merge.
thanks,
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Re: [PATCH v3 22/22] sound/usb: Use Media Controller API to share media resources
Quoted 102 lines · Shuah Khan
Quoted 58 lines · Takashi Iwai
Quoted 53 lines · Shuah Khan
Quoted 48 lines · Takashi Iwai
Quoted 38 lines · Shuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
snd_usb_hw_params()will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it fromsnd_usb_hw_free(). If resource is busy,-EBUSYis returned.Media specific cleanup is done in
usb_audio_disconnect().Signed-off-by Shuah Khan <[email protected]>--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.hsound/usb/Kconfig +0
-0sound/usb/Kconfig config SND_USB_AUDIO · line 18
Quoted 4 lines
sound/usb/Kconfig +1
-0@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORTLooking at the media
Kconfigagain, this would be broken if MEDIA_SUPPORT=m and SND_USB_AUDIO=y. The ugly workaround is something like:Quoted 2 lines
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND)Quoted 2 lines
My current config is MEDIA_SUPPORT=m and SND_USB_AUDIO=y It is working and I didn't see any issues so far.
Quoted 8 lines
Hmm, how does it be? In
drivers/media/Makefile:ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
obj-$(CONFIG_MEDIA_SUPPORT) += media.o
endifSo it's a module. Meanwhile you have reference from usb-audio driver that is built-in kernel. How is the symbol resolved?
Sorry my mistake. I misspoke. My config had:
CONFIG_MEDIA_SUPPORT=mCONFIG_MEDIA_CONTROLLER=yCONFIG_SND_USB_AUDIO=mThe following doesn't work as you pointed out.
CONFIG_MEDIA_SUPPORT=mCONFIG_MEDIA_CONTROLLER=yCONFIG_SND_USB_AUDIO=yokay here is what will work for all of the possible combinations of
CONFIG_MEDIA_SUPPORTandCONFIG_SND_USB_AUDIOselect SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && ((MEDIA_SUPPORT=y) || (MEDIA_SUPPORT=m && SND_USB_AUDIO=m))The above will cover the cases when
1.
CONFIG_MEDIA_SUPPORTandCONFIG_SND_USB_AUDIOare both modulesCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected2.
CONFIG_MEDIA_SUPPORT=yandCONFIG_SND_USB_AUDIO=mCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected3.
CONFIG_MEDIA_SUPPORT=yandCONFIG_SND_USB_AUDIO=yCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected4.
CONFIG_MEDIA_SUPPORT=mandCONFIG_SND_USB_AUDIO=yThis is when we don't wantCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERselected
Quoted 6 lines
I verified all of the above combinations to make sure the logic works.
If you think of a better way to do this please let me know. I will go ahead and send patch v4 with the above change and you can decide if that is acceptable.
I'm not 100% sure whether CONFIG_SND_USB_AUDIO=m can be put there as conditional inside CONFIG_SND_USB_AUDIO definition. Maybe a safer form would be like:
config SND_USB_AUDIO_USE_MEDIA_CONTROLLER
bool
default y
depends on SND_USB_AUDIO
depends on MEDIA_CONTROLLER
depends on (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO)
and drop select from SND_USB_AUDIO.
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Other than that, it looks more or less OK to me.
The way howmedia_stream_init()gets called is a bit worrisome, but it should work practically. Another concern is about the disconnection. Can all function calls inmedia_device_delete()be safe even if it's called while the application still opens the MC device?Quoted 7 lines
Quoted 3 lines
Right. I have been looking into device removal path when ioctls are active and I can resolve any issues that might surface while an audio app is active when device is removed.
So, it's 100% safe to call all these media_*() functions while the device is being accessed before closing?
Quoted 8 lines
There is a known problem with device removal when media device file is open and ioctl is in progress. This isn't specific to this patch series, a general problem that is related to media device removal in general.
I am working on a fix for this problem. As you said, earlier, I can work on fixing issues after the merge.
OK, understood.
Takashi
Re: [PATCH v3 22/22] sound/usb: Use Media Controller API to share media resources
Em Sat, 27 Feb 2016 08:48:05 +0100
Takashi Iwai <[email protected]> escreveu:
Quoted 145 lines
Quoted 102 lines · Shuah Khan
Quoted 58 lines · Takashi Iwai
Quoted 53 lines · Shuah Khan
Quoted 48 lines · Takashi Iwai
Quoted 38 lines · Shuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
snd_usb_hw_params()will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it fromsnd_usb_hw_free(). If resource is busy,-EBUSYis returned.Media specific cleanup is done in
usb_audio_disconnect().Signed-off-by Shuah Khan <[email protected]>--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.hsound/usb/Kconfig +0
-0sound/usb/Kconfig config SND_USB_AUDIO · line 18
Quoted 4 lines
sound/usb/Kconfig +1
-0@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORTLooking at the media
Kconfigagain, this would be broken if MEDIA_SUPPORT=m and SND_USB_AUDIO=y. The ugly workaround is something like:Quoted 2 lines
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND)Quoted 2 lines
My current config is MEDIA_SUPPORT=m and SND_USB_AUDIO=y It is working and I didn't see any issues so far.
Quoted 8 lines
Hmm, how does it be? In
drivers/media/Makefile:ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
obj-$(CONFIG_MEDIA_SUPPORT) += media.o
endifSo it's a module. Meanwhile you have reference from usb-audio driver that is built-in kernel. How is the symbol resolved?
Sorry my mistake. I misspoke. My config had:
CONFIG_MEDIA_SUPPORT=mCONFIG_MEDIA_CONTROLLER=yCONFIG_SND_USB_AUDIO=mThe following doesn't work as you pointed out.
CONFIG_MEDIA_SUPPORT=mCONFIG_MEDIA_CONTROLLER=yCONFIG_SND_USB_AUDIO=yokay here is what will work for all of the possible combinations of
CONFIG_MEDIA_SUPPORTandCONFIG_SND_USB_AUDIOselect SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && ((MEDIA_SUPPORT=y) || (MEDIA_SUPPORT=m && SND_USB_AUDIO=m))The above will cover the cases when
1.
CONFIG_MEDIA_SUPPORTandCONFIG_SND_USB_AUDIOare both modulesCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected2.
CONFIG_MEDIA_SUPPORT=yandCONFIG_SND_USB_AUDIO=mCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected3.
CONFIG_MEDIA_SUPPORT=yandCONFIG_SND_USB_AUDIO=yCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected4.
CONFIG_MEDIA_SUPPORT=mandCONFIG_SND_USB_AUDIO=yThis is when we don't wantCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERselectedQuoted 6 lines
I verified all of the above combinations to make sure the logic works.
If you think of a better way to do this please let me know. I will go ahead and send patch v4 with the above change and you can decide if that is acceptable.
I'm not 100% sure whether
CONFIG_SND_USB_AUDIO=mcan be put there as conditional insideCONFIG_SND_USB_AUDIOdefinition. Maybe a safer form would be like:config
SND_USB_AUDIO_USE_MEDIA_CONTROLLER
bool
default y
depends onSND_USB_AUDIO
depends onMEDIA_CONTROLLER
depends on (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO)and drop select from
SND_USB_AUDIO.Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Other than that, it looks more or less OK to me.
The way howmedia_stream_init()gets called is a bit worrisome, but it should work practically. Another concern is about the disconnection. Can all function calls inmedia_device_delete()be safe even if it's called while the application still opens the MC device?Quoted 7 lines
Quoted 3 lines
Right. I have been looking into device removal path when ioctls are active and I can resolve any issues that might surface while an audio app is active when device is removed.
So, it's 100% safe to call all these media_*() functions while the device is being accessed before closing?
There is a known problem with device removal when media device file is open and ioctl is in progress. This isn't specific to this patch series, a general problem that is related to media device removal in general.
Quoted 7 lines
Quoted 2 lines
I am working on a fix for this problem. As you said, earlier, I can work on fixing issues after the merge.
OK, understood.
Takashi
As there are still some issues here, I decided to apply all but this one, in order to avoid having compilation issues with random configs.
Shuah,
As there were several conflicts when I applied the initial 21 patches from this series, please apply this one on the top of the latest tree.
As this patch touches only at sound, it is independent, so you won't need to rebase it. However, I might have solved some conflicts badly, a final test wouldn't hurt ;)
Regards,
Mauro
Re: [PATCH v3 22/22] sound/usb: Use Media Controller API to share media resources
In reply to Takashi IwaiQuoted 145 lines · Takashi Iwai
Quoted 102 lines · Shuah Khan
Quoted 58 lines · Takashi Iwai
Quoted 53 lines · Shuah Khan
Quoted 48 lines · Takashi Iwai
Quoted 38 lines · Shuah Khan
Change ALSA driver to use Media Controller API to share media resources with DVB and V4L2 drivers on a AU0828 media device. Media Controller specific initialization is done after sound card is registered. ALSA creates Media interface and entity function graph nodes for Control, Mixer, PCM Playback, and PCM Capture devices.
snd_usb_hw_params()will call Media Controller enable source handler interface to request the media resource. If resource request is granted, it will release it fromsnd_usb_hw_free(). If resource is busy,-EBUSYis returned.Media specific cleanup is done in
usb_audio_disconnect().Signed-off-by Shuah Khan <[email protected]>--- sound/usb/Kconfig | 4 + sound/usb/Makefile | 2 + sound/usb/card.c | 14 +++ sound/usb/card.h | 3 + sound/usb/media.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 72 +++++++++++ sound/usb/mixer.h | 3 + sound/usb/pcm.c | 28 ++++- sound/usb/quirks-table.h | 1 + sound/usb/stream.c | 2 + sound/usb/usbaudio.h | 6 + 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 sound/usb/media.c create mode 100644 sound/usb/media.hsound/usb/Kconfig +0
-0sound/usb/Kconfig config SND_USB_AUDIO · line 18
Quoted 4 lines
sound/usb/Kconfig +1
-0@@ -15,6 +15,7 @@ config SND_USB_AUDIO select SND_RAWMIDI select SND_PCM select BITREVERSE + select SND_USB_AUDIO_USE_MEDIA_CONTROLLER if MEDIA_CONTROLLER && MEDIA_SUPPORTLooking at the media
Kconfigagain, this would be broken if MEDIA_SUPPORT=m and SND_USB_AUDIO=y. The ugly workaround is something like:Quoted 2 lines
select SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND)Quoted 2 lines
My current config is MEDIA_SUPPORT=m and SND_USB_AUDIO=y It is working and I didn't see any issues so far.
Quoted 8 lines
Hmm, how does it be? In
drivers/media/Makefile:ifeq ($(CONFIG_MEDIA_CONTROLLER),y)
obj-$(CONFIG_MEDIA_SUPPORT) += media.o
endifSo it's a module. Meanwhile you have reference from usb-audio driver that is built-in kernel. How is the symbol resolved?
Sorry my mistake. I misspoke. My config had:
CONFIG_MEDIA_SUPPORT=mCONFIG_MEDIA_CONTROLLER=yCONFIG_SND_USB_AUDIO=mThe following doesn't work as you pointed out.
CONFIG_MEDIA_SUPPORT=mCONFIG_MEDIA_CONTROLLER=yCONFIG_SND_USB_AUDIO=yokay here is what will work for all of the possible combinations of
CONFIG_MEDIA_SUPPORTandCONFIG_SND_USB_AUDIOselect SND_USB_AUDIO_USE_MEDIA_CONTROLLER \ if MEDIA_CONTROLLER && ((MEDIA_SUPPORT=y) || (MEDIA_SUPPORT=m && SND_USB_AUDIO=m))The above will cover the cases when
1.
CONFIG_MEDIA_SUPPORTandCONFIG_SND_USB_AUDIOare both modulesCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected2.
CONFIG_MEDIA_SUPPORT=yandCONFIG_SND_USB_AUDIO=mCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected3.
CONFIG_MEDIA_SUPPORT=yandCONFIG_SND_USB_AUDIO=yCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERis selected4.
CONFIG_MEDIA_SUPPORT=mandCONFIG_SND_USB_AUDIO=yThis is when we don't wantCONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLERselectedQuoted 6 lines
I verified all of the above combinations to make sure the logic works.
If you think of a better way to do this please let me know. I will go ahead and send patch v4 with the above change and you can decide if that is acceptable.
I'm not 100% sure whether
CONFIG_SND_USB_AUDIO=mcan be put there as conditional insideCONFIG_SND_USB_AUDIOdefinition. Maybe a safer form would be like:config
SND_USB_AUDIO_USE_MEDIA_CONTROLLER
bool
default y
depends onSND_USB_AUDIO
depends onMEDIA_CONTROLLER
depends on (MEDIA_SUPPORT=y || MEDIA_SUPPORT=SND_USB_AUDIO)and drop select from
SND_USB_AUDIO.Quoted 20 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Other than that, it looks more or less OK to me.
The way howmedia_stream_init()gets called is a bit worrisome, but it should work practically. Another concern is about the disconnection. Can all function calls inmedia_device_delete()be safe even if it's called while the application still opens the MC device?Quoted 7 lines
Quoted 3 lines
Right. I have been looking into device removal path when ioctls are active and I can resolve any issues that might surface while an audio app is active when device is removed.
So, it's 100% safe to call all these media_*() functions while the device is being accessed before closing?
There is a known problem with device removal when media device file is open and ioctl is in progress. This isn't specific to this patch series, a general problem that is related to media device removal in general.
Quoted 6 lines
Quoted 2 lines
I am working on a fix for this problem. As you said, earlier, I can work on fixing issues after the merge.
OK, understood.
Hi Takashi,
I sent patch v4 that works for all combinations of MEDIA_SUPPORT and SND_USB_AUDIO.
Please review and Ack if you are okay with this version. Thanks for your help with the Kconfig file changes.
-- Shuah
Signature · 5 lines
Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978