Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: mchehab@osg.samsung.com, perex@perex.cz, chehabrafael@gmail.com,
	hans.verkuil@cisco.com, prabhakar.csengg@gmail.com,
	chris.j.arges@canonical.com, linux-media@vger.kernel.org,
	alsa-devel@alsa-project.org, Shuah Khan <shuahkh@osg.samsung.com>
Subject: Re: [PATCH MC Next Gen v2 2/3] sound/usb: Create media mixer function and control interface entities
Date: Tue, 3 Nov 2015 09:43:49 -0700	[thread overview]
Message-ID: <5638E445.50900@osg.samsung.com> (raw)
In-Reply-To: <s5hy4efnjad.wl-tiwai@suse.de>

On 11/03/2015 09:23 AM, Takashi Iwai wrote:
> On Tue, 03 Nov 2015 17:06:45 +0100,
> Shuah Khan wrote:
>>
>> On 10/25/2015 03:37 PM, Shuah Khan wrote:
>>> On 10/22/2015 01:16 AM, Takashi Iwai wrote:
>>>> On Wed, 21 Oct 2015 01:25:15 +0200,
>>>> Shuah Khan wrote:
>>>>>
>>>>> 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.
>>>>>
>>>>> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
>>>>> ---
>>>>>   sound/usb/card.c     |  5 +++
>>>>>   sound/usb/media.c    | 89
>>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>   sound/usb/media.h    | 20 ++++++++++++
>>>>>   sound/usb/mixer.h    |  1 +
>>>>>   sound/usb/usbaudio.h |  1 +
>>>>>   5 files changed, 116 insertions(+)
>>>>>
>>>>> diff --git a/sound/usb/card.c b/sound/usb/card.c
>>>>> index 469d2bf..d004cb4 100644
>>>>> --- a/sound/usb/card.c
>>>>> +++ b/sound/usb/card.c
>>>>> @@ -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);
>>>>> diff --git a/sound/usb/media.c b/sound/usb/media.c
>>>>> index 0cbfee6..a26ea8b 100644
>>>>> --- a/sound/usb/media.c
>>>>> +++ b/sound/usb/media.c
>>>>> @@ -199,4 +199,93 @@ void media_stop_pipeline(struct
>>>>> snd_usb_substream *subs)
>>>>>       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;
>>>>> +    struct media_mixer_ctl *mctl;
>>>>> +    u32 intf_type = MEDIA_INTF_T_ALSA_CONTROL;
>>>>> +    int ret;
>>>>> +
>>>>> +    mdev = media_device_find_devres(&chip->dev->dev);
>>>>> +    if (!mdev)
>>>>> +        return -ENODEV;
>>>>> +
>>>>> +    ctl_intf = (struct media_intf_devnode *)
>>>>> chip->ctl_intf_media_devnode;
>>>>
>>>> Why do we need cast?  Can't chip->ctl_intf_media_devnode itself be
>>>> struct media_intf_devndoe pointer?
>>>
>>> Yeah. There is no need to cast here. I will fix it.
>>
>> Sorry I misspoke. The reason for this cast is ctl_intf_media_devnode
>> is void to avoid including media.h and other media files in usbaudio.h
> 
> You can declare the struct without definition in each header file.
> So just declare it and use it in usbaudio.h like:
> 
> struct media_intf_devnode;
> 
> struct snd_usb_audio {
> 	....
> 	struct media_intf_devnode *ctl_intf_media_devnode;
> 	....
> 
> And even if you're using a void pointer there instead of the explicit
> struct pointer, the cast is superfluous.  The implicit cast between a
> void pointer and any other pointer is valid in plain C.
> 

Yes. cast is definitely not necessary. I will drop the cast and leave
the rest alone.

thanks,
-- Shuah


-- 
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
shuahkh@osg.samsung.com | (970) 217-8978

  reply	other threads:[~2015-11-03 16:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20 23:25 [PATCH MC Next Gen v2 0/3] Add mixer and control interface media entities Shuah Khan
2015-10-20 23:25 ` [PATCH MC Next Gen v2 1/3] sound/usb: Fix media_stream_delete() to remove intf devnode Shuah Khan
2015-10-20 23:25 ` [PATCH MC Next Gen v2 2/3] sound/usb: Create media mixer function and control interface entities Shuah Khan
2015-10-22  7:16   ` Takashi Iwai
2015-10-25 21:37     ` Shuah Khan
2015-11-03 16:06       ` Shuah Khan
2015-11-03 16:23         ` Takashi Iwai
2015-11-03 16:43           ` Shuah Khan [this message]
2015-10-20 23:25 ` [PATCH MC Next Gen v2 3/3] media: au0828 create link between ALSA Mixer and decoder Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5638E445.50900@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=chehabrafael@gmail.com \
    --cc=chris.j.arges@canonical.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    --cc=perex@perex.cz \
    --cc=prabhakar.csengg@gmail.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox