Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c5cbc1b7 in mainline


Ignore:
Timestamp:
2012-07-19T17:02:52Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
2e01b3f
Parents:
1bebadee
Message:

sb16: Use dmamem_map_anonymous to map sound buffer.

It will be enlarged later.

Location:
uspace/drv/audio/sb16
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/dsp.c

    r1bebadee rc5cbc1b7  
    3333 */
    3434
     35#include <as.h>
    3536#include <bool.h>
     37#include <ddi.h>
    3638#include <devman.h>
    3739#include <device/hw_res.h>
     
    4143#include <audio_pcm_iface.h>
    4244
    43 #include "dma.h"
    4445#include "ddf_log.h"
    4546#include "dsp_commands.h"
    4647#include "dsp.h"
    4748
    48 #define MAX_BUFFER_SIZE (PAGE_SIZE)
     49/* Maximum allowed transfer size for ISA DMA transfers is 64kB */
     50#define MAX_BUFFER_SIZE (4 * 1024) // use 4kB for now
    4951
    5052#ifndef DSP_RETRY_COUNT
     
    103105        async_sess_t *sess = devman_parent_device_connect(EXCHANGE_ATOMIC,
    104106            dsp->sb_dev->handle, IPC_FLAG_BLOCKING);
    105         if (!sess)
    106                 return ENOMEM;
    107107
    108108        const int ret = hw_res_dma_channel_setup(sess,
    109109            dsp->dma16_channel, pa, size,
    110110            DMA_MODE_READ | DMA_MODE_AUTO | DMA_MODE_ON_DEMAND);
     111
    111112        async_hangup(sess);
    112113        return ret;
     
    118119        if (size > MAX_BUFFER_SIZE || size == 0 || (size % 2) == 1)
    119120                size = MAX_BUFFER_SIZE;
    120         uint8_t *buffer = dma_create_buffer24(size);
    121         if (buffer == NULL) {
     121        void *buffer = NULL, *pa = NULL;
     122        int ret = dmamem_map_anonymous(size, AS_AREA_WRITE | AS_AREA_READ,
     123            0, &pa, &buffer);
     124        if (ret != EOK) {
    122125                ddf_log_error("Failed to allocate DMA buffer.");
    123126                return ENOMEM;
    124127        }
    125128
    126         const uintptr_t pa = addr_to_phys(buffer);
    127         assert(pa < (1 << 25));
    128 
    129         /* Set 16 bit channel */
    130         const int ret = sb_setup_dma(dsp, pa, size);
     129        ddf_log_verbose("Setup dma buffer at %p(%p).", buffer, pa, size);
     130        assert((uintptr_t)pa < (1 << 25));
     131
     132        /* Setup 16 bit channel */
     133        ret = sb_setup_dma(dsp, (uintptr_t)pa, size);
    131134        if (ret == EOK) {
    132135                dsp->buffer.data = buffer;
    133136                dsp->buffer.size = size;
    134                 bzero(dsp->buffer.data, dsp->buffer.size);
    135137        } else {
    136138                ddf_log_error("Failed to setup DMA16 channel: %s.",
    137139                    str_error(ret));
    138                 dma_destroy_buffer(buffer);
     140                dmamem_unmap_anonymous(buffer);
    139141        }
    140142        return ret;
     
    143145static inline void sb_clear_buffer(sb_dsp_t *dsp)
    144146{
    145         dma_destroy_buffer(dsp->buffer.data);
     147        assert(dsp);
     148        dmamem_unmap_anonymous(dsp->buffer.data);
    146149        dsp->buffer.data = NULL;
    147150        dsp->buffer.size = 0;
Note: See TracChangeset for help on using the changeset viewer.