Add mixer and control interface media entities
Subsystems (2)
v3 cover Add mixer and control interface media entities
This patch v3 series adds the following:
A fix to media_stream_delete() to remove intf devnode.
Add support for creating MEDIA_ENT_F_AUDIO_MIXER entity for each mixer and a MEDIA_INTF_T_ALSA_CONTROL control interface entity that links to mixer entities. MEDIA_INTF_T_ALSA_CONTROL entity corresponds to the control device for the card.
Change au0828_create_media_graph() to create pad link between MEDIA_ENT_F_AUDIO_MIXER entity and decoder's AU8522_PAD_AUDIO_OUT. With mixer entity now linked to decoder, change to link MEDIA_ENT_F_AUDIO_CAPTURE to mixer's source pad
In addition, this patch series consists of fixes to compile warnings found by kbuild bot, and an additional fix in media stream cleanup path.
Changes since v2:
1. Addressed Takashi's comments on the following ALSA patch:
sound/usb: Create media mixer function and control interface entities
2. Include patches to fix compile warnings found by kbuild bot, and an additional fix in media stream cleanup path.
3. No changes to patches 1 and 3.
4. Changed patches: 2
5. New patches: 4,5, and 6
Changes since v1:
1. Included the fix to media_stream_delete() which was by mistake not included in the patch v1.
2. Fixed mixer to decoder link and mixer to capture node links based on Mauro Chehab's review comments on the media graph.
This patch series is dependent on an earlier patch series-es:
Patch series v2:
https://www.mail-archive.com/[email protected]/msg93084.html
Patch series v1:
Update ALSA, and au0828 drivers to use Managed Media Controller API:
https://www.mail-archive.com/[email protected]/msg92752.html
Please find the media graphs for ALSA work with mixer and control interface nodes: (these are generated using mc_next_gen_test tool.
https://drive.google.com/folderview?id=0B0NIL0BQg-AlLWE3SzAxazBJWm8&usp=sharing
v4l2-utils patch adds mixer node support mc_next_gen_test tool:
https://www.mail-archive.com/[email protected]/msg93086.html
Shuah Khan (6):
sound/usb: Fix media_stream_delete() to remove intf devnode sound/usb: Create media mixer function and control interface entities
media: au0828 create link between ALSA Mixer and decoder sound/usb: Fix media_stream_init() and media_stream_delete() error
paths
media: Fix compile warning when CONFIG_MEDIA_CONTROLLER_DVB is
disabled
media: au0828-core fix ignoring return value errors
drivers/media/dvb-core/dvb_frontend.c | 2 +- drivers/media/usb/au0828/au0828-core.c | 38 +++++++++--- drivers/media/usb/au0828/au0828.h | 1 + sound/usb/card.c | 5 ++ sound/usb/media.c | 102 ++++++++++++++++++++++++++++++++- sound/usb/media.h | 20 +++++++ sound/usb/mixer.h | 1 + sound/usb/usbaudio.h | 1 + 8 files changed, 158 insertions(+), 12 deletions(-)
Signature · 1 line
2.5.0
PATCH v3 1/6 sound/usb: Fix media_stream_delete() to remove intf devnode
media_stream_delete() doesn't remove intf_devnode. Fix it to call media_devnode_remove() to remove the intf_devnode.
--- sound/usb/media.c | 1 + 1 file changed, 1 insertion(+)
sound/usb/media.c +1 -0
@@ -173,6 +173,7 @@ void media_stream_delete(struct snd_usb_substream *subs) mdev =media_device_find_devres (&subs->dev->dev);if (mdev) {media_entity_remove_links (&mctl->media_entity); +media_devnode_remove (mctl->intf_devnode);media_device_unregister_entity (&mctl->media_entity);media_entity_cleanup (&mctl->media_entity); }
Signature · 1 line
2.5.0
PATCH v3 2/6 sound/usb: Create media mixer function and control interface entities
In reply to Shuah KhanAdd support for creating MEDIA_ENT_F_AUDIO_MIXER entity for each mixer and a MEDIA_INTF_T_ALSA_CONTROL control interface entity that links to mixer entities. MEDIA_INTF_T_ALSA_CONTROL entity corresponds to the control device for the card.
--- sound/usb/card.c | 5 +++ sound/usb/media.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sound/usb/media.h | 20 ++++++++++++ sound/usb/mixer.h | 1 + sound/usb/usbaudio.h | 1 + 5 files changed, 119 insertions(+)
sound/usb/card.c +5 -0
@@ -560,6 +560,9 @@ static int usb_audio_probe(struct usb_interface *intf,if (err <0 ) goto __error; +/* Create media entities for mixer and control dev */ +media_mixer_init (chip); + usb_chip[chip->index] = chip; chip->num_interfaces++; chip->probing =0 ;
@@ -616,6 +619,8 @@ static void usb_audio_disconnect(struct usb_interface *intf)list_for_each (p, &chip->midi_list) {snd_usbmidi_disconnect (p); } +/* delete mixer media resources */ +media_mixer_delete (chip);/* release mixer resources */ list_for_each_entry (mixer, &chip->mixer_list, list) {snd_usb_mixer_disconnect (mixer);
sound/usb/media.c +92 -0
96 lines not on this page · raw message
sound/usb/media.h +20 -0
@@ -20,6 +20,7 @@ #ifdef 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;
@@ -30,6 +31,21 @@ struct media_ctl {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_init (struct snd_usb_audio *chip,struct usb_interface *iface);void media_device_delete (struct usb_interface *iface); int media_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,
@@ -37,6 +53,8 @@ int media_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,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); +int media_mixer_init (struct snd_usb_audio *chip); +void media_mixer_delete (struct snd_usb_audio *chip);#else static inline int media_device_init (struct snd_usb_audio *chip,struct usb_interface *iface)
@@ -49,5 +67,7 @@ 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) { } +static int media_mixer_init (struct snd_usb_audio *chip) {return 0 ; } +static void media_mixer_delete (struct snd_usb_audio *chip) { }#endif #endif /* __MEDIA_H */
sound/usb/mixer.h +1 -0
@@ -22,6 +22,7 @@ struct usb_mixer_interface {struct urb *rc_urb;struct usb_ctrlrequest *rc_setup_packet;u8 rc_buffer[6 ]; +void *media_mixer_ctl; };#define MAX_CHANNELS 16/* max logical channels */
sound/usb/usbaudio.h +1 -0
@@ -59,6 +59,7 @@ struct snd_usb_audio {bool autoclock;/* from the 'autoclock' module param */ struct usb_host_interface *ctrl_intf;/* the audio control interface */ +void *ctl_intf_media_devnode; }; #define usb_audio_err(chip, fmt, args...) \
Signature · 1 line
2.5.0
PATCH v3 3/6 media: au0828 create link between ALSA Mixer and decoder
In reply to Shuah KhanChange au0828_create_media_graph() to create pad link between MEDIA_ENT_F_AUDIO_MIXER entity and decoder's AU8522_PAD_AUDIO_OUT. With mixer entity now linked to decoder, change to link MEDIA_ENT_F_AUDIO_CAPTURE to mixer's source pad.
--- drivers/media/usb/au0828/au0828-core.c | 17 ++++++++++++++--- drivers/media/usb/au0828/au0828.h | 1 + 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/media/usb/au0828/au0828-core.c +14 -3
@@ -225,6 +225,7 @@ void au0828_create_media_graph(struct media_entity *new, void *notify_data)struct media_entity *entity;struct media_entity *tuner =NULL , *decoder =NULL ;struct media_entity *audio_capture =NULL ; +struct media_entity *mixer =NULL ;int i, ret;if (!mdev)
@@ -245,6 +246,9 @@ void au0828_create_media_graph(struct media_entity *new, void *notify_data)case MEDIA_ENT_F_AUDIO_CAPTURE : audio_capture = entity;break ; +case MEDIA_ENT_F_AUDIO_MIXER : + mixer = entity; +break ; } }
@@ -309,13 +313,20 @@ void au0828_create_media_graph(struct media_entity *new, void *notify_data) } } -if (audio_capture && !dev->audio_capture_linked) { - ret =media_create_pad_link (decoder,AU8522_PAD_AUDIO_OUT , - audio_capture,0 , +if (mixer && audio_capture && !dev->audio_capture_linked) { + ret =media_create_pad_link (mixer,1 , audio_capture,0 ,MEDIA_LNK_FL_ENABLED );if (ret ==0 ) dev->audio_capture_linked =1 ; } + +if (mixer && !dev->mixer_linked) { + ret =media_create_pad_link (decoder,AU8522_PAD_AUDIO_OUT , + mixer,0 , +MEDIA_LNK_FL_ENABLED ); +if (ret ==0 ) + dev->mixer_linked =1 ; + }#endif }
drivers/media/usb/au0828/au0828.h +1 -0
@@ -288,6 +288,7 @@ struct au0828_dev {bool vdev_linked;bool vbi_linked;bool audio_capture_linked; +bool mixer_linked;struct media_link *active_link;struct media_entity *active_link_owner;#endif
Signature · 1 line
2.5.0
PATCH v3 4/6 sound/usb: Fix media_stream_init() and media_stream_delete() error paths
In reply to Shuah KhanFix media_stream_init() to free memory in error paths. Fix media_stream_delete() to remove unnecessary set media_dev pointer to null before free mctl.
--- sound/usb/media.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/usb/media.c +6 -3
@@ -127,7 +127,6 @@ int media_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,if (!mctl)return -ENOMEM ; - subs->media_ctl = (void *) mctl; mctl->media_dev = mdev;if (stream ==SNDRV_PCM_STREAM_PLAYBACK ) { intf_type =MEDIA_INTF_T_ALSA_PCM_PLAYBACK ;
@@ -143,13 +142,16 @@ int media_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,media_entity_init (&mctl->media_entity,1 , &mctl->media_pad); ret =media_device_register_entity (mctl->media_dev, &mctl->media_entity); -if (ret) +if (ret) { +kfree (mctl);return ret; + } mctl->intf_devnode =media_devnode_create (mdev, intf_type,0 ,MAJOR (pcm_dev->devt),MINOR (pcm_dev->devt));if (!mctl->intf_devnode) {media_device_unregister_entity (&mctl->media_entity); +kfree (mctl);return -ENOMEM ; } mctl->intf_link = media_create_intf_link(&mctl->media_entity,
@@ -158,8 +160,10 @@ int media_stream_init(struct snd_usb_substream *subs, struct snd_pcm *pcm,if (!mctl->intf_link) {media_devnode_remove (mctl->intf_devnode);media_device_unregister_entity (&mctl->media_entity); +kfree (mctl);return -ENOMEM ; } + subs->media_ctl = (void *) mctl;return 0 ; }
@@ -177,7 +181,6 @@ void media_stream_delete(struct snd_usb_substream *subs)media_device_unregister_entity (&mctl->media_entity);media_entity_cleanup (&mctl->media_entity); } - mctl->media_dev =NULL ;kfree (mctl); subs->media_ctl =NULL ; }
Signature · 1 line
2.5.0
PATCH v3 5/6 media: Fix compile warning when CONFIG_MEDIA_CONTROLLER_DVB is disabled
In reply to Shuah KhanFix the following compile warning when CONFIG_MEDIA_CONTROLLER_DVB is disabled:
drivers/media/dvb-core/dvb_frontend.c: In function 'dvb_frontend_open':drivers/media/dvb-core/dvb_frontend.c:2526:1: warning: label 'err2' defined but not used [-Wunused-label] err2:
--- drivers/media/dvb-core/dvb_frontend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-core/dvb_frontend.c +1 -1
@@ -2522,8 +2522,8 @@ err3:#ifdef CONFIG_MEDIA_CONTROLLER_DVB if (fe->dvb->mdev && fe->dvb->mdev->disable_source) fe->dvb->mdev->disable_source (dvbdev->entity); -#endif err2: +#endif dvb_generic_release (inode, file); err1:if (dvbdev->users ==-1 && fe->ops.ts_bus_ctrl)
Signature · 1 line
2.5.0
PATCH v3 6/6 media: au0828-core fix ignoring return value errors
In reply to Shuah KhanFix the ignoring return value errors found during kbuild bot compile test.
drivers/media/usb/au0828/au0828-core.c:298:5: warning: ignoring return value of 'media_create_pad_link', declared with attribute warn_unused_result [-Wunused-result]
drivers/media/usb/au0828/au0828-core.c:356:2: warning: ignoring return value of 'media_device_register_entity_notify', declared with attribute warn_unused_result [-Wunused-result]
--- drivers/media/usb/au0828/au0828-core.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/media/usb/au0828/au0828-core.c +16 -5
@@ -299,15 +299,20 @@ void au0828_create_media_graph(struct media_entity *new, void *notify_data)if (!tuner)break ; -media_create_pad_link (ent,0 , tuner, -TUNER_PAD_RF_INPUT , -MEDIA_LNK_FL_ENABLED ); + ret =media_create_pad_link (ent,0 , tuner, +TUNER_PAD_RF_INPUT , +MEDIA_LNK_FL_ENABLED ); +if (ret) +pr_err ("Create pad link err %d\n" , ret);break ;case AU0828_VMUX_COMPOSITE :case AU0828_VMUX_SVIDEO :default :/* AU0828_VMUX_DEBUG */ /* FIXME: fix the decoder PAD */ -media_create_pad_link (ent,0 , decoder,0 ,0 ); + ret =media_create_pad_link (ent,0 , decoder, +0 ,0 ); +if (ret) +pr_err ("Create pad link err %d\n" , ret);break ; } }
@@ -504,7 +509,13 @@ static void au0828_media_device_register(struct au0828_dev *dev,/* register entity_notify callback */ dev->entity_notify.notify_data = (void *) dev; dev->entity_notify.notify = au0828_create_media_graph; -media_device_register_entity_notify (mdev, &dev->entity_notify); + ret =media_device_register_entity_notify (mdev, &dev->entity_notify); +if (ret) { +dev_err (&udev->dev, +"Couldn't register entity_notify handler. Error: %d\n" , + ret); +return ; + }/* set enable_source */ mdev->source_priv = (void *) dev;
Signature · 1 line
2.5.0