From: Rene Herman <rene.herman@keyaccess.nl>
To: Landis McGauhey <b3zdomny@hotmail.com>
Cc: Takashi Iwai <tiwai@suse.de>,
alsa-user@lists.sourceforge.net,
ALSA devel <alsa-devel@alsa-project.org>
Subject: Re: [Alsa-user] is this card supported by ALSA?
Date: Tue, 15 Jul 2008 16:42:05 +0200 [thread overview]
Message-ID: <487CB73D.4050808@keyaccess.nl> (raw)
In-Reply-To: <s5hod4zxm9v.wl%tiwai@suse.de>
[-- Attachment #1: Type: text/plain, Size: 1510 bytes --]
On 15-07-08 16:19, Takashi Iwai wrote:
> The below is a patch to improve the codec access routines in a bit
> more robust way (and clean-ups, too). Give it a try.
Thank you for taking this...
Landis, if it's easier for you due to webmail stuff, I'm attaching the
patch to this message so that it might be easier for you to save it
(Takashi posted it "inline" in the message).
The way to use this is very similar to what you did for the OSS driver
patch. You save this somewhere, then from the root of the source tree
(from /usr/src/linux-2.6.25.9 it was...) you do
# patch -p1 --dry-run < /some/where/ens1371-ac97.diff
and upon seeing that complete without errors, without the --dry-run:
# patch -p1 --dry-run < /some/where/ens1371-ac97.diff
You then recompile the kernel with "make" (which should now only
recompile the snd-ens1371 driver) and do a "make modules_install" after
it finishes.
Then, make sure no old driver for the card is loaded:
# modprobe -r snd-ens1371
# modprobe -r es1371
and load the new one:
# modprobe snd-ens1371
then up and unmute volumes in alsamixer again and try if you have sound
with "speaker-test" or "aplay foo.wav".
If you do, you should blacklist the now installed OSS es1371 driver (add
"blacklist es1371" to /etc/modprobe.d/blacklist) and make sure
snd-ens1371 is no longer blacklisted. If all's well, working sound
should then survive a reboot (and a future kernel would include the fix
autonmatically so things just work out of the box).
Rene.
[-- Attachment #2: ens1371-ac97.diff --]
[-- Type: text/plain, Size: 7633 bytes --]
diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 72d85a5..cd74fb2 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -461,8 +461,6 @@ MODULE_DEVICE_TABLE(pci, snd_audiopci_ids);
* constants
*/
-#define POLL_COUNT 0xa000
-
#ifdef CHIP1370
static unsigned int snd_es1370_fixed_rates[] =
{5512, 11025, 22050, 44100};
@@ -514,14 +512,16 @@ static const unsigned int snd_ensoniq_sample_shift[] =
static unsigned int snd_es1371_wait_src_ready(struct ensoniq * ensoniq)
{
- unsigned int t, r = 0;
+ unsigned int r = 0;
+ unsigned long end_time;
- for (t = 0; t < POLL_COUNT; t++) {
+ end_time = jiffies + msecs_to_jiffies(100);
+ do {
r = inl(ES_REG(ensoniq, 1371_SMPRATE));
if ((r & ES_1371_SRC_RAM_BUSY) == 0)
return r;
- cond_resched();
- }
+ schedule_timeout_uninterruptible(1);
+ } while (time_after_eq(end_time, jiffies));
snd_printk(KERN_ERR "wait source ready timeout 0x%lx [0x%x]\n",
ES_REG(ensoniq, 1371_SMPRATE), r);
return 0;
@@ -529,7 +529,7 @@ static unsigned int snd_es1371_wait_src_ready(struct ensoniq * ensoniq)
static unsigned int snd_es1371_src_read(struct ensoniq * ensoniq, unsigned short reg)
{
- unsigned int temp, i, orig, r;
+ unsigned int temp, orig, r;
/* wait for ready */
temp = orig = snd_es1371_wait_src_ready(ensoniq);
@@ -545,11 +545,13 @@ static unsigned int snd_es1371_src_read(struct ensoniq * ensoniq, unsigned short
if ((temp & 0x00870000) != 0x00010000) {
/* wait for the right state */
- for (i = 0; i < POLL_COUNT; i++) {
+ unsigned long end_time = jiffies + msecs_to_jiffies(100);
+ do {
temp = inl(ES_REG(ensoniq, 1371_SMPRATE));
if ((temp & 0x00870000) == 0x00010000)
break;
- }
+ schedule_timeout_uninterruptible(1);
+ } while (time_after_eq(end_time, jiffies));
}
/* hide the state bits */
@@ -602,104 +604,90 @@ static void snd_es1370_codec_write(struct snd_ak4531 *ak4531,
#ifdef CHIP1371
+static int _es1371_wait_wip(struct ensoniq *ensoniq)
+{
+ unsigned long end_time;
+
+ end_time = jiffies + msecs_to_jiffies(100);
+ do {
+ if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP))
+ return 0;
+ } while (time_after_eq(end_time, jiffies));
+ snd_printk(KERN_ERR "codec wait timeout, status = 0x%x\n",
+ inl(ES_REG(ensoniq, 1371_CODEC)));
+ return -EINVAL;
+}
+
+static void _es1371_codec_write(struct ensoniq *ensoniq,
+ unsigned int val)
+{
+ unsigned int x;
+ unsigned long end_time;
+
+ _es1371_wait_wip(ensoniq);
+ /* save the current state for latter */
+ x = snd_es1371_wait_src_ready(ensoniq);
+ outl((x & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 |
+ ES_1371_DIS_P2 | ES_1371_DIS_R1)) | 0x00010000,
+ ES_REG(ensoniq, 1371_SMPRATE));
+ /* wait for not busy (state 0) first to avoid
+ transition states */
+ end_time = jiffies + msecs_to_jiffies(100);
+ do {
+ if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) ==
+ 0x00000000)
+ break;
+ } while (time_after_eq(end_time, jiffies));
+ /* wait for a SAFE time to write addr/data and then do it, dammit */
+ end_time = jiffies + msecs_to_jiffies(100);
+ do {
+ if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) ==
+ 0x00010000)
+ break;
+ } while (time_after_eq(end_time, jiffies));
+ outl(val, ES_REG(ensoniq, 1371_CODEC));
+ /* restore SRC reg */
+ snd_es1371_wait_src_ready(ensoniq);
+ outl(x, ES_REG(ensoniq, 1371_SMPRATE));
+}
+
static void snd_es1371_codec_write(struct snd_ac97 *ac97,
unsigned short reg, unsigned short val)
{
struct ensoniq *ensoniq = ac97->private_data;
- unsigned int t, x;
mutex_lock(&ensoniq->src_mutex);
- for (t = 0; t < POLL_COUNT; t++) {
- if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) {
- /* save the current state for latter */
- x = snd_es1371_wait_src_ready(ensoniq);
- outl((x & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 |
- ES_1371_DIS_P2 | ES_1371_DIS_R1)) | 0x00010000,
- ES_REG(ensoniq, 1371_SMPRATE));
- /* wait for not busy (state 0) first to avoid
- transition states */
- for (t = 0; t < POLL_COUNT; t++) {
- if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) ==
- 0x00000000)
- break;
- }
- /* wait for a SAFE time to write addr/data and then do it, dammit */
- for (t = 0; t < POLL_COUNT; t++) {
- if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) ==
- 0x00010000)
- break;
- }
- outl(ES_1371_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1371_CODEC));
- /* restore SRC reg */
- snd_es1371_wait_src_ready(ensoniq);
- outl(x, ES_REG(ensoniq, 1371_SMPRATE));
- mutex_unlock(&ensoniq->src_mutex);
- return;
- }
- }
+ _es1371_codec_write(ensoniq, ES_1371_CODEC_WRITE(reg, val));
mutex_unlock(&ensoniq->src_mutex);
- snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n",
- ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
}
static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97,
unsigned short reg)
{
struct ensoniq *ensoniq = ac97->private_data;
- unsigned int t, x, fail = 0;
+ unsigned int fail;
+ unsigned long end_time;
- __again:
mutex_lock(&ensoniq->src_mutex);
- for (t = 0; t < POLL_COUNT; t++) {
- if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) {
- /* save the current state for latter */
- x = snd_es1371_wait_src_ready(ensoniq);
- outl((x & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 |
- ES_1371_DIS_P2 | ES_1371_DIS_R1)) | 0x00010000,
- ES_REG(ensoniq, 1371_SMPRATE));
- /* wait for not busy (state 0) first to avoid
- transition states */
- for (t = 0; t < POLL_COUNT; t++) {
- if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) ==
- 0x00000000)
- break;
+ for (fail = 0; fail < 10; fail++) {
+ _es1371_codec_write(ensoniq, ES_1371_CODEC_READS(reg));
+ /* wait for WIP again */
+ _es1371_wait_wip(ensoniq);
+ /* now wait for the stinkin' data (RDY) */
+ end_time = jiffies + msecs_to_jiffies(100);
+ do {
+ unsigned int x = inl(ES_REG(ensoniq, 1371_CODEC));
+ if (x & ES_1371_CODEC_RDY) {
+ mutex_unlock(&ensoniq->src_mutex);
+ return ES_1371_CODEC_READ(x);
}
- /* wait for a SAFE time to write addr/data and then do it, dammit */
- for (t = 0; t < POLL_COUNT; t++) {
- if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) ==
- 0x00010000)
- break;
- }
- outl(ES_1371_CODEC_READS(reg), ES_REG(ensoniq, 1371_CODEC));
- /* restore SRC reg */
- snd_es1371_wait_src_ready(ensoniq);
- outl(x, ES_REG(ensoniq, 1371_SMPRATE));
- /* wait for WIP again */
- for (t = 0; t < POLL_COUNT; t++) {
- if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP))
- break;
- }
- /* now wait for the stinkin' data (RDY) */
- for (t = 0; t < POLL_COUNT; t++) {
- if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) {
- mutex_unlock(&ensoniq->src_mutex);
- return ES_1371_CODEC_READ(x);
- }
- }
- mutex_unlock(&ensoniq->src_mutex);
- if (++fail > 10) {
- snd_printk(KERN_ERR "codec read timeout (final) "
- "at 0x%lx, reg = 0x%x [0x%x]\n",
- ES_REG(ensoniq, 1371_CODEC), reg,
- inl(ES_REG(ensoniq, 1371_CODEC)));
- return 0;
- }
- goto __again;
- }
+ } while (time_after_eq(end_time, jiffies));
}
+ snd_printk(KERN_ERR "codec read timeout (final) "
+ "at 0x%lx, reg = 0x%x [0x%x]\n",
+ ES_REG(ensoniq, 1371_CODEC), reg,
+ inl(ES_REG(ensoniq, 1371_CODEC)));
mutex_unlock(&ensoniq->src_mutex);
- snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n",
- ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
return 0;
}
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2008-07-15 14:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <BLU137-W526424D3E9A79DA1437849959A0@phx.gbl>
[not found] ` <48701633.7040601@keyaccess.nl>
[not found] ` <loom.20080708T141841-614@post.gmane.org>
[not found] ` <4873AB3B.1070403@keyaccess.nl>
[not found] ` <4873CED6.2040704@keyaccess.nl>
[not found] ` <4873D033.8010604@keyaccess.nl>
[not found] ` <BLU137-W434EEB6A014E95FD1E225C95910@phx.gbl>
[not found] ` <48769D84.1050102@keyaccess.nl>
[not found] ` <BLU137-W51DDE8E1756609BBE5CF7F95910@phx.gbl>
[not found] ` <4876A0DE.2050803@keyaccess.nl>
[not found] ` <BLU137-W23A4FF48E97AC32476FD6095900@phx.gbl>
[not found] ` <4876AC75.2010305@keyaccess.nl>
[not found] ` <BLU137-W541C318CC744C4BF6461DE95900@phx.gbl>
[not found] ` <4876B329.80700@keyaccess.nl>
[not found] ` <BLU137-W3234537335E7D553F03AF195900@phx.gbl>
[not found] ` <48798CF7.6020303@keyaccess.nl>
[not found] ` <loom.20080714T232812-533@post.gmane.org>
2008-07-15 0:11 ` [Alsa-user] is this card supported by ALSA? Rene Herman
2008-07-15 4:12 ` Landis McGauhey
2008-07-15 13:11 ` Takashi Iwai
2008-07-15 13:56 ` Landis McGauhey
2008-07-15 14:19 ` Takashi Iwai
2008-07-15 14:42 ` Rene Herman [this message]
2008-07-15 14:52 ` Landis McGauhey
2008-07-15 14:59 ` Rene Herman
2008-07-15 15:01 ` Sergei Steshenko
2008-07-15 15:06 ` [Alsa-user] " Rene Herman
2008-07-15 15:25 ` Landis McGauhey
2008-07-15 15:36 ` [Alsa-user] " Rene Herman
2008-07-15 16:45 ` Landis McGauhey
2008-07-15 16:52 ` Rene Herman
2008-07-15 17:08 ` Landis McGauhey
2008-07-15 15:38 ` Landis McGauhey
2008-07-15 17:02 ` [Alsa-user] " Rene Herman
2008-07-15 14:49 ` Landis McGauhey
2008-07-15 20:28 Landis McGauhey
2008-07-16 9:16 ` Rene Herman
2008-07-16 11:07 ` [Alsa-user] " Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2008-07-16 13:38 Landis McGauhey
2008-07-16 14:40 ` [Alsa-user] " Rene Herman
2008-07-16 14:44 ` Rene Herman
2008-07-16 14:52 ` Rene Herman
2008-07-16 18:00 Landis McGauhey
2008-07-16 18:50 ` Rene Herman
2008-07-18 16:31 ` Rene Herman
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=487CB73D.4050808@keyaccess.nl \
--to=rene.herman@keyaccess.nl \
--cc=alsa-devel@alsa-project.org \
--cc=alsa-user@lists.sourceforge.net \
--cc=b3zdomny@hotmail.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.