From: "Jörg Krause" <joerg.krause@embedded.rocks>
To: Takashi Iwai <tiwai@suse.de>, Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH] pcm: softvol: add support for S24_LE
Date: Tue, 12 Sep 2017 16:15:58 +0200 [thread overview]
Message-ID: <1505225758.2863.11.camel@embedded.rocks> (raw)
In-Reply-To: <s5h377spezh.wl-tiwai@suse.de>
On Tue, 2017-09-12 at 09:12 +0200, Takashi Iwai wrote:
> On Tue, 12 Sep 2017 09:02:47 +0200,
> Clemens Ladisch wrote:
> >
> > Jörg Krause wrote:
> > > The i.MX6UL has a Synchronous Audio Interface (SAI), where the data in
> > > the FIFO can be aligned anywhere within the 32-bit wide register
> > > through the use of the First Bit Shifted configuration field. In the
> > > corresponding Linux SAI driver the FBS field is set the way that data
> > > alignment for 24-bit data is:
> > >
> > > 31 30 29 28 | 27 26 25 24 | 23 22 21 20 | .. | 3 2 1 0
> > > ## ## ## ## ## ## ## ## [ DATA[23:0] ]
> >
> > This indeed is S24_LE.
> >
> > Which is an extremely uncommon format. If possible, the driver should
> > be changed to align to the sample's MSB to the memory word's MSB, and
> > then label it as S32_LE.
> >
> > > > S24_LE cannot be handled with the same algorithm as S32_LE.
> >
> > To be precise: the sign in bit 23 must be preserved.
>
> I guess the simple calculation with S24_LE using the current code
> would work as long as the upper 8 bits are ignored by hardware.
> The upper 8 bits would hold bogus bits, and clearing this would be an
> extra action we'd need in addition.
Thanks! I've copied the area convertion macro for S24_3LE and
explicitly set the upper 8 bits to 0:
"""
#define CONVERT_AREA_S24_LE() do { \
unsigned int ch, fr; \
unsigned char *src, *dst; \
int tmp; \
for (ch = 0; ch < channels; ch++) { \
src_area = &src_areas[ch]; \
dst_area = &dst_areas[ch]; \
src = snd_pcm_channel_area_addr(src_area, src_offset); \
dst = snd_pcm_channel_area_addr(dst_area, dst_offset); \
src_step = snd_pcm_channel_area_step(src_area); \
dst_step = snd_pcm_channel_area_step(dst_area); \
GET_VOL_SCALE; \
fr = frames; \
if (! vol_scale) { \
while (fr--) { \
dst[0] = dst[1] = dst[2] = dst[3] = 0; \
dst += dst_step; \
} \
} else if (vol_scale == 0xffff) { \
while (fr--) { \
dst[0] = src[0]; \
dst[1] = src[1]; \
dst[2] = src[2]; \
dst[3] = 0; \
src += dst_step; \
dst += src_step; \
} \
} else { \
while (fr--) { \
tmp = src[0] | \
(src[1] << 8) | \
(((signed char *) src)[2] << 16); \
tmp = MULTI_DIV_24(tmp, vol_scale); \
dst[0] = tmp; \
dst[1] = tmp >> 8; \
dst[2] = tmp >> 16; \
dst[3] = 0; \
src += dst_step; \
dst += src_step; \
} \
} \
} \
} while (0)
"""
Is that okay?
Jörg Krause
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2017-09-12 14:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-08 10:11 [PATCH] pcm: softvol: add support for S24_LE Jörg Krause
2017-09-08 10:52 ` Clemens Ladisch
2017-09-12 6:13 ` Jörg Krause
2017-09-12 6:19 ` Clemens Ladisch
2017-09-12 6:49 ` Jörg Krause
2017-09-12 7:02 ` Clemens Ladisch
2017-09-12 7:12 ` Takashi Iwai
2017-09-12 14:15 ` Jörg Krause [this message]
2017-09-12 14:32 ` Takashi Iwai
2017-09-12 14:53 ` Takashi Sakamoto
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=1505225758.2863.11.camel@embedded.rocks \
--to=joerg.krause@embedded.rocks \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--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.