Skip to contentSkip to conversation

Help with AD1816 driver please...

DISCUSSION Ken Arromdee 3 participants 6 messages Feb 3, 2006 – Feb 9, 2006

lore
Share & tools
lore
#0 lore raw

I'm probably the only person who uses this driver (four years ago it wasn't working at all and wasn't fixed until I reported the problem).

At any rate, I just tried using my card (Shark Predator ISA) for capture, which I never did before. It didn't work--it gave a weird repeating sound and eventually the following error:
arecord: pcm_read:1196: read error: Input/output error
I highly suspect the driver is causing the problem. It's obviously never been tested, and capture works fine in Windows 98. Also, I know the weird sound was a driver problem, because I was able to fix it (the version I patched is the one in Mandrake 10.1). I still get the pcm_read I/O error, however.

Here's the patch. Is there anyone willing to officially make this change in CVS, and/or help me fix the I/O error?

*** ad1816a_lib.c.orig 2006-02-02 21:25:00.869143712 -0500
--- ad1816a_lib.c 2006-02-02 21:29:13.142792288 -0500
***************
*** 179,185 ****

static int snd_ad1816a_trigger(ad1816a_t *chip, unsigned char what,
! int channel, int cmd)
{
int error = 0;

--- 179,185 ----

static int snd_ad1816a_trigger(ad1816a_t *chip, unsigned char what,
! int channel, int cmd, int iscapture)
{
int error = 0;

***************
*** 188,197 ****
case SNDRV_PCM_TRIGGER_STOP:
spin_lock(&chip->lock);
cmd = (cmd == SNDRV_PCM_TRIGGER_START) ? 0xff: 0x00;
! if (what & AD1816A_PLAYBACK_ENABLE)
snd_ad1816a_out_mask(chip, AD1816A_PLAYBACK_CONFIG,
AD1816A_PLAYBACK_ENABLE, cmd);
! if (what & AD1816A_CAPTURE_ENABLE)
snd_ad1816a_out_mask(chip, AD1816A_CAPTURE_CONFIG,
AD1816A_CAPTURE_ENABLE, cmd);
spin_unlock(&chip->lock);
--- 188,201 ----
case SNDRV_PCM_TRIGGER_STOP:
spin_lock(&chip->lock);
cmd = (cmd == SNDRV_PCM_TRIGGER_START) ? 0xff: 0x00;
! /* if (what & AD1816A_PLAYBACK_ENABLE) */
! /* That is not valid, because playback and capture enable
! * are the same bit pattern, just to different addresses
! */
! if (!iscapture)
snd_ad1816a_out_mask(chip, AD1816A_PLAYBACK_CONFIG,
AD1816A_PLAYBACK_ENABLE, cmd);
! if (iscapture)
snd_ad1816a_out_mask(chip, AD1816A_CAPTURE_CONFIG,
AD1816A_CAPTURE_ENABLE, cmd);
spin_unlock(&chip->lock);
***************
*** 208,221 ****
{
ad1816a_t *chip = snd_pcm_substream_chip(substream); return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE,
! SNDRV_PCM_STREAM_PLAYBACK, cmd);
}

static int snd_ad1816a_capture_trigger(snd_pcm_substream_t *substream, int cmd) {
ad1816a_t *chip = snd_pcm_substream_chip(substream);
return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE,
! SNDRV_PCM_STREAM_CAPTURE, cmd);
}

static int snd_ad1816a_hw_params(snd_pcm_substream_t * substream,
--- 212,225 ----
{
ad1816a_t *chip = snd_pcm_substream_chip(substream); return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE,
! SNDRV_PCM_STREAM_PLAYBACK, cmd, 0);
}

static int snd_ad1816a_capture_trigger(snd_pcm_substream_t *substream, int cmd) {
ad1816a_t *chip = snd_pcm_substream_chip(substream);
return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE,
! SNDRV_PCM_STREAM_CAPTURE, cmd, 1);
}

static int snd_ad1816a_hw_params(snd_pcm_substream_t * substream,

-------------------------------------------------------
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 5 lines · Ken Arromdee

Here's the patch. Is there anyone willing to officially make this change in
CVS, and/or help me fix the I/O error?

Can you regenerate with patch -Nru?

Lee

-------------------------------------------------------
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
Quoted 4 lines · Lee Revell
Quoted 3 lines

Here's the patch. Is there anyone willing to officially make this change in
CVS, and/or help me fix the I/O error?

Can you regenerate with patch -Nru?

I'm not sure what you're asking. If you're asking if the patch I mailed out works against current source code using patch -Nru, no it doesn't (variable names and whitespace have changed).

If you want a patch against current source code, here it is. Disclaimer: I haven't tried to compile this, so hope I made no stupid typoes.

*** ad1816a_lib.c.orig 2006-02-02 23:32:50.691921760 -0500
--- ad1816a_lib.c 2006-02-02 23:38:54.755575672 -0500
***************
*** 174,180 ****

static int snd_ad1816a_trigger(struct snd_ad1816a *chip, unsigned char what,
! int channel, int cmd)

  {
      int error = 0;

--- 174,180 ----

static int snd_ad1816a_trigger(struct snd_ad1816a *chip, unsigned char what,
! int channel, int cmd, int iscapture)

  {
      int error = 0;

***************
*** 183,192 ****
case SNDRV_PCM_TRIGGER_STOP:
spin_lock(&chip->lock);
cmd = (cmd == SNDRV_PCM_TRIGGER_START) ? 0xff: 0x00;
! if (what & AD1816A_PLAYBACK_ENABLE)
snd_ad1816a_out_mask(chip, AD1816A_PLAYBACK_CONFIG,
AD1816A_PLAYBACK_ENABLE, cmd);
! if (what & AD1816A_CAPTURE_ENABLE)
snd_ad1816a_out_mask(chip, AD1816A_CAPTURE_CONFIG,
AD1816A_CAPTURE_ENABLE, cmd);
spin_unlock(&chip->lock);
--- 183,196 ----
case SNDRV_PCM_TRIGGER_STOP:
spin_lock(&chip->lock);
cmd = (cmd == SNDRV_PCM_TRIGGER_START) ? 0xff: 0x00;
! /* if (what & AD1816A_PLAYBACK_ENABLE) */
! /* That is not valid, because playback and capture enable
! * are the same bit pattern, just to different addresses
! */
! if (!iscapture)
snd_ad1816a_out_mask(chip, AD1816A_PLAYBACK_CONFIG,
AD1816A_PLAYBACK_ENABLE, cmd);
! if (iscapture)
snd_ad1816a_out_mask(chip, AD1816A_CAPTURE_CONFIG,
AD1816A_CAPTURE_ENABLE, cmd);
spin_unlock(&chip->lock);
***************
*** 203,216 ****

  {
      struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
      return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE,

! SNDRV_PCM_STREAM_PLAYBACK, cmd);
}

static int snd_ad1816a_capture_trigger(struct snd_pcm_substream *substream, int cmd)

  {
      struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
      return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE,

! SNDRV_PCM_STREAM_CAPTURE, cmd);
}

static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream,
--- 207,220 ----

  {
      struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
      return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE,

! SNDRV_PCM_STREAM_PLAYBACK, cmd, 0);
}

static int snd_ad1816a_capture_trigger(struct snd_pcm_substream *substream, int cmd)

  {
      struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
      return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE,

! SNDRV_PCM_STREAM_CAPTURE, cmd, 1);
}

static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream,

-------------------------------------------------------
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

#3 lore raw
Quoted 4 lines · Ken Arromdee
Quoted 3 lines · Lee Revell
Quoted 3 lines

Here's the patch. Is there anyone willing to officially make this change in
CVS, and/or help me fix the I/O error?

Quoted 8 lines
Quoted 1 line

Can you regenerate with patch -Nru?

I'm not sure what you're asking. If you're asking if the patch I mailed out works against current source code using patch -Nru, no it doesn't (variable names and whitespace have changed).

If you want a patch against current source code, here it is. Disclaimer: I haven't tried to compile this, so hope I made no stupid typoes.

Sorry, I meant, diff -Nru (unified diff format)

Lee

-------------------------------------------------------
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

#4 lore raw

Here's the diff.

Note that this only fixes half of the problem. I haven't been able to figure out the other half.

ad1816a_lib.c renamed from ad1816a_lib.c.orig +9 -5
@@ -174,7 +174,7 @@
 
 
 static int snd_ad1816a_trigger(struct snd_ad1816a *chip, unsigned char what,
-	           int channel, int cmd)
+	           int channel, int cmd, int iscapture)
 {
     int error = 0;
 
@@ -183,10 +183,14 @@
     case SNDRV_PCM_TRIGGER_STOP:
 	spin_lock(&chip->lock);
 	cmd = (cmd == SNDRV_PCM_TRIGGER_START) ? 0xff: 0x00;
-	if (what & AD1816A_PLAYBACK_ENABLE)
+	/* if (what & AD1816A_PLAYBACK_ENABLE) */
+	/* That is not valid, because playback and capture enable
+	 * are the same bit pattern, just to different addresses
+	 */
+	if (!iscapture)
 	    snd_ad1816a_out_mask(chip, AD1816A_PLAYBACK_CONFIG,
 		AD1816A_PLAYBACK_ENABLE, cmd);
-	if (what & AD1816A_CAPTURE_ENABLE)
+	if (iscapture)
 	    snd_ad1816a_out_mask(chip, AD1816A_CAPTURE_CONFIG,
 		AD1816A_CAPTURE_ENABLE, cmd);
 	spin_unlock(&chip->lock);
@@ -203,14 +207,14 @@
 {
     struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
     return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE,
-	SNDRV_PCM_STREAM_PLAYBACK, cmd);
+	SNDRV_PCM_STREAM_PLAYBACK, cmd, 0);
 }
 
 static int snd_ad1816a_capture_trigger(struct snd_pcm_substream *substream, int cmd)
 {
     struct snd_ad1816a *chip = snd_pcm_substream_chip(substream);
     return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE,
-	SNDRV_PCM_STREAM_CAPTURE, cmd);
+	SNDRV_PCM_STREAM_CAPTURE, cmd, 1);
 }
 
 static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream,

-------------------------------------------------------
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

#5 lore raw

At Fri, 3 Feb 2006 09:52:54 -0800 (PST),

Quoted 5 lines · Ken Arromdee

Here's the diff.

Note that this only fixes half of the problem. I haven't been able to figure out the other half.

Thanks, committed to CVS with minor modification since it wasn't applied cleanly.

Takashi

-------------------------------------------------------
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