All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Igor Kotrasiński" <ikk_pl@yahoo.co.uk>
To: alsa-devel@alsa-project.org
Subject: OSS virtual driver - dma buffer size problems
Date: Tue, 28 Jan 2014 14:47:41 +0100	[thread overview]
Message-ID: <52E7B4FD.5060100@yahoo.co.uk> (raw)

Hello,

I'm trying to get the "cuckoo" OSS module (virtual ALSA driver) to work, 
and have some trouble properly setting up the dma buffer size. Relevant 
code (old type names are properly typedeffed from new ones) is:

static snd_pcm_hardware_t snd_cuckoo_playback = {
   .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
            SNDRV_PCM_INFO_BLOCK_TRANSFER |
            SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START),
   .channels_min = 1,
   .channels_max = 2,
   .buffer_bytes_max = (64 * 1024),
   .period_bytes_min = 64,
   .period_bytes_max = (32 * 1024),
   .periods_min = 2,
   .periods_max = 1024,
   (...)
};


static snd_pcm_ops_t snd_cuckoo_playback_ops = {
   .open = snd_cuckoo_playback_open,
   .hw_params = snd_cuckoo_playback_hw_params,
   .prepare = snd_cuckoo_playback_prepare,
   (...)
};

static int
snd_cuckoo_playback_hw_params (snd_pcm_substream_t * substream,
                                snd_pcm_hw_params_t * hw_params)
{
   cuckoo_t *chip = snd_pcm_substream_chip (substream);
   snd_pcm_runtime_t *runtime = substream->runtime;
   dmap_t *dmap; //relevant buffer data here
   snd_dma_buffer_t *dmab;

   (...)

   if (runtime->dma_buffer_p)
     dmab = runtime->dma_buffer_p;
   else
     dmab = &(substream->dma_buffer);

   dmab->area = dmap->dmabuf;
   dmab->addr = dmap->dmabuf_phys;
   dmab->bytes = dmap -> buffsize; //supposed to be 4096
   snd_pcm_set_runtime_buffer(substream, dmab);
   memset (dmap->dmabuf, 0, dmap->buffsize);
   return 0;
}

Inspecting values in snd_cuckoo_playback_prepare shows that 
runtime->dma_bytes is correctly set to 4096, but runtime->buffer_size is 
16384 (with frame_bits == 32) and snd_pcm_lib_buffer_bytes(substream) 
returns 65536. If not aborted, it indeed overwrites the kernel. What is 
the correct way to pass a manually initialized dma buffer?

             reply	other threads:[~2014-01-28 13:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 13:47 Igor Kotrasiński [this message]
     [not found] <mailman.1317.1390977963.844.alsa-devel@alsa-project.org>
2014-01-29 14:47 ` OSS virtual driver - dma buffer size problems Igor Kotrasiński

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=52E7B4FD.5060100@yahoo.co.uk \
    --to=ikk_pl@yahoo.co.uk \
    --cc=alsa-devel@alsa-project.org \
    /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.