Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: The Source <thesourcehim@gmail.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: sbxfi - What works/doesn't summary
Date: Wed, 29 Oct 2008 10:29:10 +0100	[thread overview]
Message-ID: <s5hiqrblpg9.wl%tiwai@suse.de> (raw)
In-Reply-To: <4907F158.3040608@gmail.com>

At Wed, 29 Oct 2008 08:15:04 +0300,
The Source wrote:
> 
> Ok, was able to get hw_params:
> access: MMAP_INTERLEAVED
> format: S16_LE
> subformat: STD
> channels: 2
> rate: 48000 (48000/1)
> period_size: 1088
> buffer_size: 4352
> 
> Why so weird values?

Maybe related with the default sample rate 44.1kHz?  Who knows...

Does the patch below have any influence?
This restricts the period/buffer size aligned to 1024 bytes.
Also, it may fix the PCM pointer calculation somehow.


Takashi

---
diff --git a/sound/pci/sbxfi/sbxfi.c b/sound/pci/sbxfi/sbxfi.c
index e67f768..a2d908e 100644
--- a/sound/pci/sbxfi/sbxfi.c
+++ b/sound/pci/sbxfi/sbxfi.c
@@ -122,6 +122,9 @@ struct sbxfi_port {
 	/* TLB entry */
 	int tlb_index;
 	unsigned int tlb_pages;
+	/* buffer pointers */
+	unsigned int start_addr;
+	unsigned int buffer_bytes;
 	/* status */
 	int state;
 	int need_update;
@@ -527,8 +530,8 @@ static void sbxfi_playback_start(struct sbxfi *chip, struct sbxfi_port *port)
 	if (port->tlb_index < 0)
 		return;
 	runtime = port->substream->runtime;
-	start = port->tlb_index * SBXFI_PAGE_SIZE;
-	loop = start + frames_to_bytes(runtime, runtime->buffer_size);
+	start = port->start_addr;
+	loop = start + port->buffer_bytes;
 
 	switch (runtime->rate) {
 	case 48000:
@@ -579,8 +582,8 @@ static void sbxfi_capture_start(struct sbxfi *chip, struct sbxfi_port *port)
 	if (port->tlb_index < 0)
 		return;
 	runtime = port->substream->runtime;
-	start = port->tlb_index * SBXFI_PAGE_SIZE;
-	loop = start + frames_to_bytes(runtime, runtime->buffer_size);
+	start = port->start_addr;
+	loop = start + port->buffer_bytes;
 
 	switch (runtime->rate) {
 	case 48000:
@@ -1320,9 +1323,9 @@ static int sbxfi_playback_open(struct snd_pcm_substream *substream)
 	set_rate_limit(chip, runtime);
 	snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
 	snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-				   128);
+				   1024 /*128*/);
 	snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
-				   128);
+				   1024 /*128*/);
 	return 0;
 }
 
@@ -1349,9 +1352,9 @@ static int sbxfi_capture_open(struct snd_pcm_substream *substream)
 	set_rate_limit(chip, runtime);
 	snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
 	snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
-				   128);
+				   1024 /*128*/);
 	snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
-				   128);
+				   1024 /*128*/);
 	return 0;
 }
 
@@ -1399,6 +1402,9 @@ static int sbxfi_playback_prepare(struct snd_pcm_substream *substream)
 	port->frag_count = runtime->period_size;
 	port->need_update = 0;
 
+	port->start_addr = port->tlb_index * SBXFI_PAGE_SIZE;
+	port->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size);
+
 	sbxfi_setup_play_pitch(chip, port);
 	sbxfi_setup_play_mixer(chip, port);
 	sbxfi_setup_play_mapper(chip, port);
@@ -1417,6 +1423,9 @@ static int sbxfi_capture_prepare(struct snd_pcm_substream *substream)
 	port->frag_count = runtime->period_size;
 	port->need_update = 0;
 
+	port->start_addr = port->tlb_index * SBXFI_PAGE_SIZE;
+	port->buffer_bytes = frames_to_bytes(runtime, runtime->buffer_size);
+
 	sbxfi_init_adc(chip, chip->capsrc, chip->micboost);
 
 	sbxfi_setup_capture_mapper(chip, port);
@@ -1477,10 +1486,12 @@ sbxfi_pcm_pointer(struct snd_pcm_substream *substream)
 	unsigned int pos;
 
 	pos = sbxfi_read(chip, SRCCA(port->src[0])) & 0x03ffffff;
-	pos -= port->tlb_index * SBXFI_PAGE_SIZE;
+	pos -= port->start_addr;
 	/* The pointer is always 128 bytes ahead */
 	if (pos >= CA_OFFSET)
 		pos -= CA_OFFSET;
+	else
+		pos = pos + port->buffer_bytes - CA_OFFSET;
 	pos = bytes_to_frames(runtime, pos);
 	pos %= runtime->buffer_size;
 	LOG(2, "POINTER = 0x%x\n", pos);

  reply	other threads:[~2008-10-29  9:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-28 11:42 sbxfi - What works/doesn't summary Jason Harvey
2008-10-28 12:47 ` The Source
2008-10-28 17:40   ` Jason Harvey
2008-10-28 19:02     ` Takashi Iwai
2008-10-28 19:33       ` Jason Harvey
2008-10-28 19:36         ` Takashi Iwai
2008-10-28 20:15           ` Jason Harvey
2008-10-29  4:28             ` The Source
2008-10-29  4:45             ` The Source
2008-10-29  5:03               ` The Source
2008-10-29  5:07                 ` The Source
2008-10-29  5:15                   ` The Source
2008-10-29  9:29                     ` Takashi Iwai [this message]
2008-10-29 16:12                       ` The Source
2008-10-29  9:31                 ` Takashi Iwai
2008-10-29 15:55                 ` Jason Harvey
     [not found]                 ` <49088718.8000308@jasonline.co.uk>
2008-10-29 15:58                   ` Takashi Iwai
2008-10-29 17:01                     ` Jason Harvey

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=s5hiqrblpg9.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=thesourcehim@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox