Re: h5400 h5500 h5550 OSS patches to support monoaudio

From: Jim Kaba <jkaba_at_sarnoff.com>
Date: Mon, 28 Mar 2005 11:25:45 -0500

Phil,
  Normally I'd agree with you 100%. I believe this case may be different
though. I was on the fence about whether to implement this stereo<-->mono
conversion in the driver versus in the application, but some of the
arguments (below) convinced me that in this case it was appropriate for the
driver.

  8KHz mono sound I/O *seems* be be somewhat of a "bare minimum" standard
-- kind of a least common denominator for support. This is at least true
for OSS, and possibly ALSA as well. (I'm quite new to both, having only
dabbled in audio over the years, so correct me if I'm wrong.) In fact, the
default OSS driver settings for interacting directly with /dev/dsp are
supposed to be 8KHz mono 16bits per sample. The fact that the h5xxx OSS
drivers didn't support this format while all the documentation about OSS
suggested they should, by default, threw us for a loop for a while.

  My experience with iPAQs and Familiar only includes h3800s, h5400s and
h5500s. But my guess is that all the older platforms (the h3800s for sure)
supported mono input and output native to the hardware codec. I don't know
if the other newer platforms use codecs that dropped mono audio like the
h5xxx series did. But I would say that the current situation is that some
programs work on some iPAQ models and not on other models *RIGHT NOW* and
that this patch fixes that fact, at least for the h5xxx series. One of the
"jobs" of device driver is to hide the details of the hardware and to
provide a common interface to the applications. With this patch, I'm now
able to use the same software that I used on our 3800s, while without this
patch I'll have to hack any audio application I want to use to be sure that
it supports the other formats.

  So, in this particular case I wouldn't quite call this an *arbitrary*
transform -- but rather it provides an implementation of functionality in
one place (in the driver) so that that functionality doesn't have to be
replicated in multiple places (the applications.)

  I don't know if any of these arguments convinced you. Hopefully others
will weigh-in one way or the other to shed some additional light on the
subject.

Jim
  

Phil Blundell wrote:
>
> Jim, thanks for the patch.
>
> I'm somewhat reluctant to apply this to the tree, though, unless there
> is an overriding need to do so. Generally, we have taken the attitude
> that the application software ought to be handling any necessary format
> conversions, rather than implementing arbitrary transforms in the
> kernel. Adding this stuff to the kernel drivers will mean that programs
> work on some iPAQ models but not others, which would be a little
> unfortunate.
>
> Is there a strong reason why this stuff needs to be done in the kernel
> for your applications?
>
> p.
>
> On Fri, 2005-03-25 at 17:56 -0500, Jim Kaba wrote:
> > Hi,
> > Attached are two patches to the 5400 OSS sound drivers to implement
> > stereo to mono audio conversion. When queried, the drivers will claim support
> > for mono input and output. When configured for mono mode, these changes
> > will automatically convert the ak4535 "stereo" mic input to mono input as
> > seen by the user-space code. These driver changes will convert a mono
> > output stream from user-space to stereo for the ak4535 hardware.
> >
> > This code makes heavy reuse of code that was already in the drivers to
> > handle the funky "8KHz-16KHz conversions" that were originally thought to
> > be needed to compensate for hardware deficiencies, so thanks to the
> > original author of that code for the leg up.
> >
> > These patches were pretty heavily tested with some custom audio apps and
> > with the open-source audio conferencing tool RAT, so they should be good to
> > go.
> >
> > These patches are made against today's (March 25) cvs HEAD. You may need
> > to tweak the base kernel directory name at the top of each one to get it to
> > apply smoothly.
> >
> > h5400_mono_conversion.patch1 contains all the changes required to the
> > pxa-audio.c file to do the stereo<->mono conversion. It "lies" to the user
> > application when it queries about the amount of data available for reading
> > writing. This is done to compensate for that fact that the actual amount
> > of data read or written will be off by a factor of 2 compared to what is
> > physically available. (This is needed for optimized programs that want to
> > do non-blocking reads).
> >
> > h5400_mono_conversion.patch2 contains some support changes to h5400-audio.c
> > to let the user-space programs know that the driver supports mono data
> > streams.
> >
> > Enjoy!
> >
> > Jim
> >
> > --
> > ----------------------------------------------------------------------
> > James T. Kaba
> > Sarnoff Corporation There are 10 kinds of people in the world:
> > jkaba_at_sarnoff.com those who understand binary, and those who don't.
> > 609-734-2246

-- 
----------------------------------------------------------------------
James T. Kaba                   
Sarnoff Corporation   There are 10 kinds of people in the world:
jkaba_at_sarnoff.com     those who understand binary, and those who don't.
609-734-2246
Received on Mon Mar 28 2005 - 11:30:07 EST

This archive was generated by hypermail 2.2.0 : Mon Jul 25 2005 - 17:20:11 EDT