All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com
Subject: Re: [RFC] ALSA: add new alsa control byte extended
Date: Fri, 29 Nov 2013 14:04:51 +0530	[thread overview]
Message-ID: <20131129083451.GF8834@intel.com> (raw)
In-Reply-To: <s5hzjoneft5.wl%tiwai@suse.de>

On Fri, Nov 29, 2013 at 10:08:06AM +0100, Takashi Iwai wrote:
> At Fri, 29 Nov 2013 13:14:59 +0530,
> Vinod Koul wrote:
> > 
> > On Fri, Nov 29, 2013 at 08:46:03AM +0100, Takashi Iwai wrote:
> > > At Fri, 29 Nov 2013 09:59:57 +0530,
> > > Vinod Koul wrote:
> > > > 
> > > > As discussed in the last Audio uConf we need to improve byte controls to allow
> > > > larger size data to be sent to DSPs  The modern DSPs require alsa byte controls
> > > > size which far exceeds the today 512bytes limit. In order for usermode to send
> > > > larger sizes (few 100s of KBs) along with size information we add extended byte
> > > > control interface which sends any size bytes parameter buffer for DSPs to use
> > > > Obviosly the size must be supported by the device and would be required to
> > > > inform the max size allowed for the control.
> > > 
> > > My primary question is -- must this be a control element?
> > I think yes. With controls we have an easy way to send parameter bytes and a
> > good support from both kernel and usermode, so leveraging that would make sense.
> 
> But it means that we have to extend / fix allover places using the
> control elements.  And the variable size isn't handled there, so far.
> It's the biggest concern.
> 
> For example, how would you read such a control element?  Currently,
> all the control element values have the same static size, so the data
> is just there to read.  OTOH, if you read data with an unknown size,
> you have to query the size at first, allocate the buffer, then read
> the data.  It's a completely different flow.
> 
> > Mostly here the limit of 512 is hitting folks and IMO arbitrarily increasing
> > size doesn't help. For DSPs the algorithm coefficients can be larger 
> 
> Well, it's basically a kind of abuse of control elements, IMO...

well we can go off and do another API for parameters by adding a new
ioctl and then add support in current usermode code for this new interface.
Your concerns and compatiblity questions are certainly valid, i was hoping that
we could still manage to use control interface and keep reuse of existing
infrastructure.

Btw would it be posssible that we still ensumerate the "parameter" element as
control but use different read-write mechanism for variable size data. I am
thinking No, but if think something is doable here then it would be good.

--
~Vinod



> 
> > Here i was thinking of just adding a new API in libraries to access this new
> > control type so that users can send large parameter blobs.
> > 
> > mixer_ctl_set_bytes_ext(struct mixer_ctl *ctl, const void *data, size_t len)
> > {
> > 	struct snd_ctl_elem_value ev;
> > 
> > 	/*usual init code */
> > 
> > 	switch (ctl->info->type) {
> > 	case SNDRV_CTL_ELEM_TYPE_BYTES_EXT:
> > 		ev.value.bytes_ext.size = len;
> > 		ev.value.bytes_ext.data = (__u64)data;
> > 	break;
> > 	default:
> > 		return -EINVAL;
> > 	}
> > 	return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev);
> > }
> > 
> > in kernel-side, the .put handler for kcontrol implemented in drivers would then
> > copy the userdata and send it to DSPs.
> 
> If you create a new API function, why we need to stick with the
> control elements?
> 
> > So in that respect this becomes quite simple to implement without adding lots of
> > parallel code and uses the infrastruture we already have.
> > 
> > > Why it can't be implemented in hwdep, for example?  In the past, we
> > > already implemented DSP firmware loader in the hwdep side.  It's a bit
> > > complicated (and limited) for a few driver usages, but it was more or
> > > less standardized for them.
> > > 
> > > My concern extending control element is that it'd need the rewrite in
> > > the whole control API in user-space side, too.  alsactl accesses the
> > > whole control elements and save/restore them, for example.
> > I am not sure I got your comment on rewriting control API. I though the union
> > here makes the ABI itself not to change so existing implementations which don't
> > use this new control type will not be impacted and for newer DSP we can add new
> > APIs like above to take benifit.
> 
> You'll change SNDRV_CTL_ELEM_TYPE_LAST.  It means you'll need to look
> over all codes that refer to this and fix them.  (Not only in
> alsa-lib.)  That is, it's difficult to know how an old app reacts when
> it received an unknown data type.
> 
> I just don't want to go the way "let's break and wait to see whether
> people start whining".  At least for the old rock solid stuff.
> 
> > For save-restore part (though i havent looked at alsactl so might be wrong here)
> > yes, for this new control type, we would have to allocate buffers and then
> > destroy on restore. Eventually we will need to do so if we need alsactl suppport
> > for such devices. But shouldnt the change be less intrusive as it would be
> > limited to one control type.
> 
> So, you'd suggest to do save/restore unlimited size of data via
> alsactl?
> 
> > > Also, sharing scalar data and a reference pointer in the same union is
> > > a bit error-prone.
> > Can you elobrate a bit here and if we go down this path then how do we go about
> > it
> 
> Currently the data are stored in the fixed size of union.  You can
> read the all data there.  If a program sets some wrong type or value
> in the data, nothing severe would happen.  Just a wrong data is
> transferred.  But, with a reference pointer, a wrong data triggers the
> segfault, crashes the whole program.
> 
> > One orthogonal question: why do we have bunch of deprecated pointers in the
> > unions and is anyone still using it? I guess this would be bit of history lesson
> > :)
> 
> No it's never used in reality, and this was a big pain in the kernel
> side because we had to convert the data for the 32/64bit compatible
> ioctls.  That's why it was deprecated.  The data field remains there
> just for ABI compatibility reason.
> 
> 
> Takashi

-- 

  reply	other threads:[~2013-11-29  9:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-29  4:29 [RFC] ALSA: add new alsa control byte extended Vinod Koul
2013-11-29  7:27 ` Jarkko Nikula
2013-11-29  7:18   ` Vinod Koul
2013-11-29  7:46 ` Takashi Iwai
2013-11-29  7:44   ` Vinod Koul
2013-11-29  9:08     ` Takashi Iwai
2013-11-29  8:34       ` Vinod Koul [this message]
2013-11-29  9:40       ` Jaroslav Kysela
2013-11-29  9:48         ` Takashi Iwai
2013-11-29 10:10           ` Jaroslav Kysela
2013-11-29 11:25             ` Mark Brown
2013-11-29 11:31               ` Takashi Iwai
2013-11-29 12:27                 ` Mark Brown
2013-11-29 11:05           ` Mark Brown
2013-11-29 10:29             ` Vinod Koul
2013-11-29 11:46               ` Mark Brown
2013-11-29 13:19                 ` Vinod Koul
2013-11-29 13:11               ` Charles Keepax
2013-11-29 13:28                 ` Vinod Koul
2013-11-29 14:17                 ` Mark Brown

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=20131129083451.GF8834@intel.com \
    --to=vinod.koul@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.