Skip to contentSkip to conversation

atiixp_modem.c patch + problem.

PATCH Sasha Khapyorsky 1 participant 1 message Jul 7, 2004

lore
Share & tools
lore
#0 lore raw

Hello All,

I've played with atiixp modem driver and there is the patch for atiixp_modem.c (also attached to [ALSA - driver 0000259]). Now the driver is able to setup HOOK state and line level,rate.

However there still be a problem, and I need your suggestions to solve this.

The problem is that there is 32-bit (only?) dma transfer, but modem expects 16-bit samples (1 channel, S16_LE). For instance: with 1 channel capture setup dma data actually looks like 2 channels frames (valid samples are in right channel), sample rate is doubled and readi() returns buffer with 2 channels frames.

I think that valid samples may be separated by using copy() callback, but not sure that this is optimal and suitable way.

Also since I don't have sophisticated spec for this hardware, I am not sure that there is no possibility just to setup DMA appropriately.

Any suggestions?

TIA,

Sasha.

Index: alsa-driver/pci/atiixp_modem.c
===================================================================
RCS file: /cvsroot/alsa/alsa-driver/pci/atiixp_modem.c,v retrieving revision 1.6

pci/atiixp_modem.c +22 -11
diff -u -b -B -r1.6 atiixp_modem.c
@@ -155,8 +155,11 @@
 #define ATI_REG_MODEM_OUT_DMA3_DT_CUR	0x64
 #define ATI_REG_MODEM_OUT_DMA12_DT_SIZE	0x68
 #define ATI_REG_MODEM_OUT_DMA3_DT_SIZE	0x6c
-#define ATI_REG_MODEM_OUT_GPIO		0x70
-#define ATI_REG_MODEM_IN_GPIO		0x74
+#define ATI_REG_MODEM_OUT_FIFO_USED     0x70
+#define ATI_REG_MODEM_OUT_GPIO		0x74
+#define  ATI_REG_MODEM_OUT_GPIO_EN	   1
+#define  ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT 5
+#define ATI_REG_MODEM_IN_GPIO		0x78
 
 #define ATI_REG_MODEM_MIRROR		0x7c
 #define ATI_REG_AUDIO_MIRROR		0x80
@@ -355,7 +358,7 @@
 		dma->period_bytes = dma->periods = 0; /* clear */
 	}
 
-	if (dma->periods == dma->periods && dma->period_bytes == period_bytes)
+	if (dma->periods == periods && dma->period_bytes == period_bytes)
 		return 0;
 
 	/* reset DMA before changing the descriptor table */
@@ -676,6 +679,7 @@
 {
 	atiixp_t *chip = snd_pcm_substream_chip(substream);
 	atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data;
+	unsigned int reg = 0;
 	int i;
 
 	snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL);
@@ -683,15 +687,22 @@
 	if (cmd != SNDRV_PCM_TRIGGER_START && cmd != SNDRV_PCM_TRIGGER_STOP)
 		return -EINVAL;
 
+	spin_lock(&chip->reg_lock);
+
+	/* hook off/on: via GPIO_OUT */
 	for (i = 0; i < NUM_ATI_CODECS; i++) {
-		if (chip->ac97[i])
-			snd_ac97_update_bits(chip->ac97[i], AC97_GPIO_STATUS,
-					     AC97_GPIO_LINE1_OH,
-					     cmd == SNDRV_PCM_TRIGGER_START ?
-					     AC97_GPIO_LINE1_OH : 0);
+		if (chip->ac97[i]) {
+			reg = snd_ac97_read(chip->ac97[i], AC97_GPIO_STATUS);
+			break;
 	}
+	}
+	if(cmd == SNDRV_PCM_TRIGGER_START)
+		reg |= AC97_GPIO_LINE1_OH;
+	else
+		reg &= ~AC97_GPIO_LINE1_OH;
+	reg = (reg << ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT) | ATI_REG_MODEM_OUT_GPIO_EN ;
+	atiixp_write(chip, MODEM_OUT_GPIO, reg);
 
-	spin_lock(&chip->reg_lock);
 	if (cmd == SNDRV_PCM_TRIGGER_START) {
 		dma->ops->enable_transfer(chip, 1);
 		dma->running = 1;
@@ -818,8 +829,8 @@
 	for (i = 0; i < NUM_ATI_CODECS; i++) {
 		if (! chip->ac97[i])
 			continue;
-		snd_ac97_update(chip->ac97[i], AC97_LINE1_RATE, params_rate(hw_params));
-		snd_ac97_update(chip->ac97[i], AC97_LINE1_LEVEL, 0);
+		snd_ac97_write(chip->ac97[i], AC97_LINE1_RATE, params_rate(hw_params));
+		snd_ac97_write(chip->ac97[i], AC97_LINE1_LEVEL, 0);
 	}
 
 	return err;