All of lore.kernel.org
 help / color / mirror / Atom feed
* Mixer control for signed gain value
@ 2011-06-23  6:32 Patrick Lai
  2011-06-23 10:37 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Lai @ 2011-06-23  6:32 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mark Brown, lrg

Hi,

The CODEC I am working with takes byte-long gain value in two's 
complement form.
In soc-core.c, the closest functions I see are
  snd_soc_info_volsw_s8
snd_soc_get_volsw_s8
snd_soc_set_volsw_s8

These functions are coded to work with two integer values. For my
purpose, I suppose that I can always set 2nd integer input as zero.
However, would I still be able to set volume like
amixer sset "Codec Gain" 100 as percentage. If yes, how will amixer
know to put upper 8 bits of 16 bit gain in 2nd integer value element?

Thanks
Patrick


-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Mixer control for signed gain value
  2011-06-23  6:32 Mixer control for signed gain value Patrick Lai
@ 2011-06-23 10:37 ` Mark Brown
  2011-06-28 16:21   ` Patrick Lai
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2011-06-23 10:37 UTC (permalink / raw)
  To: Patrick Lai; +Cc: alsa-devel, lrg

On Wed, Jun 22, 2011 at 11:32:19PM -0700, Patrick Lai wrote:

> The CODEC I am working with takes byte-long gain value in two's
> complement form.
> In soc-core.c, the closest functions I see are
>  snd_soc_info_volsw_s8
> snd_soc_get_volsw_s8
> snd_soc_set_volsw_s8

> These functions are coded to work with two integer values. For my
> purpose, I suppose that I can always set 2nd integer input as zero.
> However, would I still be able to set volume like
> amixer sset "Codec Gain" 100 as percentage. If yes, how will amixer
> know to put upper 8 bits of 16 bit gain in 2nd integer value element?

Could you clarify what the control you're dealing with is?  You say
above that your gains are byte long but here you're talking about them
actually being 16 bit.  If they're 16 bit you probably need to write a
new control type.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Mixer control for signed gain value
  2011-06-23 10:37 ` Mark Brown
@ 2011-06-28 16:21   ` Patrick Lai
  2011-06-28 16:32     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick Lai @ 2011-06-28 16:21 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, lrg

On 6/23/2011 3:37 AM, Mark Brown wrote:
> On Wed, Jun 22, 2011 at 11:32:19PM -0700, Patrick Lai wrote:
>
>> The CODEC I am working with takes byte-long gain value in two's
>> complement form.
>> In soc-core.c, the closest functions I see are
>>   snd_soc_info_volsw_s8
>> snd_soc_get_volsw_s8
>> snd_soc_set_volsw_s8
>
>> These functions are coded to work with two integer values. For my
>> purpose, I suppose that I can always set 2nd integer input as zero.
>> However, would I still be able to set volume like
>> amixer sset "Codec Gain" 100 as percentage. If yes, how will amixer
>> know to put upper 8 bits of 16 bit gain in 2nd integer value element?
>
> Could you clarify what the control you're dealing with is?  You say
> above that your gains are byte long but here you're talking about them
> actually being 16 bit.  If they're 16 bit you probably need to write a
> new control type.

Yes, CODEC in question takes byte-long signed gain value and would like
to reuse snd_soc_xxx_volsw_xx mixer callback functions in soc-core.c.
The only functions I see handle signed value are
snd_soc_info_volsw_s8, snd_soc_get_volsw_s8, snd_soc_get_volsw_s8
Unless I am mistaken, these functions deal with two signed byte-long
values which get concatenated into 16-bit value. Perhaps, original
purpose is to set left and right 8-bit gain values at the same time on
a single codec register which takes 16-bit value.
So, my question is whether I should reuse volsw_s8 mixer control
functions and have mixer application ignore integer.value[1] to suit my
purpose or redefine new set of mixer control functions i.e
snd_soc_set_volsw_single_s8. Otherwise, is there existing alternative
to handle set/put byte-long signed value?

Thanks
Patrick

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Mixer control for signed gain value
  2011-06-28 16:21   ` Patrick Lai
@ 2011-06-28 16:32     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-06-28 16:32 UTC (permalink / raw)
  To: Patrick Lai; +Cc: alsa-devel, lrg

On Tue, Jun 28, 2011 at 09:21:31AM -0700, Patrick Lai wrote:

> Yes, CODEC in question takes byte-long signed gain value and would like
> to reuse snd_soc_xxx_volsw_xx mixer callback functions in soc-core.c.
> The only functions I see handle signed value are
> snd_soc_info_volsw_s8, snd_soc_get_volsw_s8, snd_soc_get_volsw_s8
> Unless I am mistaken, these functions deal with two signed byte-long
> values which get concatenated into 16-bit value. Perhaps, original

No, they shouldn't do that - they should handle stereo pairs in a single
register.  Looks like they just need a little massaging to cope with
mono controls.

> So, my question is whether I should reuse volsw_s8 mixer control
> functions and have mixer application ignore integer.value[1] to suit my
> purpose or redefine new set of mixer control functions i.e
> snd_soc_set_volsw_single_s8. Otherwise, is there existing alternative
> to handle set/put byte-long signed value?

Make the current controls handle mono.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-28 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-23  6:32 Mixer control for signed gain value Patrick Lai
2011-06-23 10:37 ` Mark Brown
2011-06-28 16:21   ` Patrick Lai
2011-06-28 16:32     ` Mark Brown

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.