Skip to contentSkip to conversation

Sampling PCM data inside driver for DC offset correction

DISCUSSION Jonathan Woithe 2 participants 3 messages Feb 10, 2006 – Feb 12, 2006

lore
Share & tools
lore
#0 lore raw

Hi all

I am pondering the possibility of adding a DC level correction to ALSA (or at least the hda/ALC260 driver). The ALC260 (among other Realtek codecs) suffers from an appreciable DC offset which makes metering somewhat confusing. The problem is that the actual value of the DC offset depends on the chip, so a static value programmed into the driver isn't going to work.

What I was thinking of was to grab a short sample of PCM data during driver setup and using this to deduce the nominal DC offset. This would then be applied to outgoing capture data, probably as it's copied to userspace.

So the questions are:

1) does this kind of thing belong in the ALSA driver, or is it something for ALSA lib? Using the plug layer isn't an option since I want the DC correction to be active for jack, which uses hw for (AFAIK) performance reasons.

2) if a kernel solution is appropriate, how does one go about capturing a single short buffer of samples within the kernel driver itself?

3) any other suggestions as to how best to effect such a correction?

Regards
jonathan

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

#1 lore raw
Quoted 6 lines · Jonathan Woithe

I am pondering the possibility of adding a DC level correction to ALSA (or at least the hda/ALC260 driver). The ALC260 (among other Realtek codecs) suffers from an appreciable DC offset which makes metering somewhat confusing. The problem is that the actual value of the DC offset depends on the chip, so a static value programmed into the driver isn't going to work.

Quoted 7 lines

What I was thinking of was to grab a short sample of PCM data during driver setup and using this to deduce the nominal DC offset. This would then be applied to outgoing capture data, probably as it's copied to userspace.

So the questions are:

1) does this kind of thing belong in the ALSA driver,

No. This is something that could be useful for any device.

Quoted 1 line

or is it something for ALSA lib?

Yes. This is what the plugin mechanism was designed for.

Quoted 2 lines

Using the plug layer isn't an option since I want the DC correction to be active for jack, which uses hw for (AFAIK) performance reasons.

"hw" is just the default name; jack supports plugins just fine. And it probably would make sense to use a Jack client for DC level correction.

Quoted 2 lines

2) if a kernel solution is appropriate, how does one go about capturing a single short buffer of samples within the kernel driver itself?

The intel8x0 driver does something like this to detect the actual clock rate.

Quoted 1 line

3) any other suggestions as to how best to effect such a correction?

IMNSHO Realtek codecs are junk and do not deserve to have their crappiness hidden by the driver.

Regards,
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

#2 lore raw

Re: Sampling PCM data inside driver for DC offset

Quoted 5 lines
Quoted 5 lines

I am pondering the possibility of adding a DC level correction to ALSA (or at least the hda/ALC260 driver). The ALC260 (among other Realtek codecs) suffers from an appreciable DC offset which makes metering somewhat confusing. ...

Quoted 7 lines
Quoted 1 line

1) does this kind of thing belong in the ALSA driver,

No. This is something that could be useful for any device.

Quoted 1 line

or is it something for ALSA lib?

Yes. This is what the plugin mechanism was designed for.

No problem.

Quoted 5 lines
Quoted 2 lines

Using the plug layer isn't an option since I want the DC correction to be active for jack, which uses hw for (AFAIK) performance reasons.

"hw" is just the default name; jack supports plugins just fine. And it probably would make sense to use a Jack client for DC level correction.

Ok. At some point in the past I seem to recall seeing a jack message when the plug layer was (probably) in use suggesting the direct hardware access for performance reasons. I can't recall the precise situation though and it was some time ago, so it could well be a moot point these days.

Quoted 5 lines
Quoted 2 lines

2) if a kernel solution is appropriate, how does one go about capturing a single short buffer of samples within the kernel driver itself?

The intel8x0 driver does something like this to detect the actual clock rate.

Thanks, I'll check this out for reference/interest.

Quoted 4 lines
Quoted 1 line

3) any other suggestions as to how best to effect such a correction?

IMNSHO Realtek codecs are junk and do not deserve to have their crappiness hidden by the driver.

That's a fair comment I think, but sometimes it's all you've got and within limits they can produce usable results.

Regards
jonathan

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642