All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adrian Knoth <adi@drcomp.erfurt.thur.de>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: Allocating DMA buffer for non-PCM
Date: Thu, 14 Feb 2013 19:46:39 +0100	[thread overview]
Message-ID: <511D310F.8020207@drcomp.erfurt.thur.de> (raw)
In-Reply-To: <511D2688.3020002@ladisch.de>

On 02/14/2013 07:01 PM, Clemens Ladisch wrote:

>> On Thu, Feb 14, 2013 at 06:46:30PM +0100, Clemens Ladisch wrote:
>>>> Would you say that the following is the proper way to allocate a DMA
>>>> buffer used to hold level data?
>>>>
>>>> 	err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG,
>>>> 			snd_dma_pci_data(hdspm->pci),
>>>> 			MADIFX_LEVEL_BUFFER_SIZE, &hdspm->dmaLevelBuffer);
>>>>
>>>>     hdspm->level_buffer = snd_sgbuf_get_ptr(&(hdspm->dmaLevelBuffer), 0);
>>>
>>> I don't see the code asking for the address of the second page, so I
>>> guess there isn't one.
>>
>> Exactly.
> 
> So MADIFX_LEVEL_BUFFER_SIZE is guaranteed to not exceed the page size
> on all architectures?

Absolutely not, it's known to be multiples of the page size, but the
purpose of hdspm->level_buffer is to hold the continuous virtual
address, so apparently, I was using the wrong getter function in the
first place (I was actually looking for .area).

The code for accessing the other pages was omitted for the sake of
simplicity, but since you've asked, here it is:

   	/* Fill level page table */
	for (i = 0; i < MADIFX_NUM_LEVEL_PAGES; i++) {
		levelPageTable[i] = snd_sgbuf_get_addr(&(hdspm->dmaLevelBuffer),
				i * MADIFX_HARDWARE_PAGE_SIZE);

	}

	/* Write level page table to device */
	lpti = (MADIFX == hdspm->io_type) ? MADIFX_LPTI_HMFX :
		MADIFX_LPTI_MFXT;

	for (i = 0; i < MADIFX_NUM_LEVEL_PAGES; i++) {
		madifx_write(hdspm, MADIFX_PAGE_ADDRESS_LIST + (4 * (lpti + i)),
				levelPageTable[i]);
	}



Cheers

  reply	other threads:[~2013-02-14 18:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-14 17:03 Allocating DMA buffer for non-PCM Adrian Knoth
2013-02-14 17:14 ` Takashi Iwai
2013-02-14 17:26   ` Adrian Knoth
2013-02-15  6:22     ` Takashi Iwai
2013-02-14 17:46 ` Clemens Ladisch
2013-02-14 17:52   ` Adrian Knoth
2013-02-14 18:01     ` Clemens Ladisch
2013-02-14 18:46       ` Adrian Knoth [this message]
2013-02-15  9:04         ` Takashi Iwai

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=511D310F.8020207@drcomp.erfurt.thur.de \
    --to=adi@drcomp.erfurt.thur.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.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.