Exemplo n.º 1
0
/*{{{  PlaybackRemoveStream*/
int PlaybackRemoveStream       (struct PlaybackContext_s*       Playback,
                                struct StreamContext_s*         Stream)
{
    int         Result  = 0;

    BACKEND_DEBUG ("%p: Usage = %d\n", Playback, Playback->UsageCount);

    if ((Playback == NULL) || (Stream == NULL))
    {
        BACKEND_ERROR("Unable to remove stream (%p) from playback (%p) if either is NULL\n", Stream, Playback);
        return -EINVAL;
    }

    mutex_lock (&(Playback->Lock));

    if (Stream->Handle != NULL)
    {
        Result = Stream->Delete (Playback->Handle, Stream->Handle);
        if (Result < 0)
            BACKEND_ERROR("Failed to remove stream from playback\n");
    }

    if (Stream->Buffer != NULL)
        bigphysarea_free_pages (Stream->Buffer);
    kfree (Stream);

    Playback->UsageCount--;
    mutex_unlock (&(Playback->Lock));

    return Result;
}
Exemplo n.º 2
0
void bfree(void* mem, unsigned long size)
{
	if (mem) {
		unsigned long adr = (unsigned long)mem;
		unsigned long siz = size;
		while (siz > 0) {
			mem_map_unreserve(virt_to_page(phys_to_virt(adr)));
			adr += PAGE_SIZE;
			siz -= PAGE_SIZE;
		}
#ifdef CONFIG_BIGPHYS_AREA
		bigphysarea_free_pages(mem);
#else
		free_pages((unsigned long)mem,get_order(size));
#endif
	}
}
Exemplo n.º 3
0
void bigphysarea_free(caddr_t addr, int size)
{
    (void)size;
    bigphysarea_free_pages(addr);
}
Exemplo n.º 4
0
/** ============================================================================
 *  @func   MEM_Free
 *
 *  @desc   Frees up the specified chunk of memory.
 *
 *  @modif  None
 *  ============================================================================
 */
EXPORT_API
DSP_STATUS
MEM_Free (IN Pvoid * ptr, IN Pvoid arg)
{
    DSP_STATUS       status   = DSP_SOK ;
    MemFreeAttrs *   freeArg  = NULL    ;

    TRC_2ENTER ("MEM_Free", ptr, arg) ;

    DBC_Require (ptr != NULL) ;
    DBC_Require (MEM_IsInitialized == TRUE) ;

    /*  ------------------------------------------------------------------------
     *  Validate arguments
     *  ------------------------------------------------------------------------
     */
    if (ptr == NULL) {
        status = DSP_EPOINTER ;
        SET_FAILURE_REASON ;
    }
    else if (*ptr == NULL) {
        status = DSP_EPOINTER ;
        SET_FAILURE_REASON ;
    }
    else {
        if (arg == MEM_DEFAULT) {
            /*  ----------------------------------------------------------------
             *  Free allocations from 'default' memory area
             *  ----------------------------------------------------------------
             */
            vfree (*ptr) ;

#if defined (DDSP_DEBUG)
            MEM_DefaultFree++ ;
#endif    /* if defined (DDSP_DEBUG) */
        }
        else {
            /*  ----------------------------------------------------------------
             *  Free OS dependent allocation from 'special' memory area(s).
             *  ----------------------------------------------------------------
             */
            freeArg = (MemFreeAttrs *) arg ;

            if (freeArg->bigArea == TRUE) {
#if (  (defined (DM6437_PHYINTERFACE) && (DM6437_PHYINTERFACE  == PCI_INTERFACE))                                  \
     ||(defined (DM642_PHYINTERFACE)  && (DM642_PHYINTERFACE  == PCI_INTERFACE))                                  \
     ||(defined (DM648_PHYINTERFACE)  && (DM648_PHYINTERFACE  == PCI_INTERFACE)))
                bigphysarea_free_pages ((caddr_t) *ptr) ;
#elif (defined (DM6437_PHYINTERFACE) && (DM6437_PHYINTERFACE == VLYNQ_INTERFACE))

#else
                TRC_0PRINT (
                           TRC_LEVEL4,
                           "BigPhys allocation is supported on this platform") ;
#endif /* if (DM6437_PHYINTERFACE == PCI_INTERFACE)... */
            }
            else {
                dma_free_coherent (NULL,
                                   freeArg->size,
                                   *ptr,
                                   (dma_addr_t) freeArg->physicalAddress) ;
            }

#if defined (DDSP_DEBUG)
            MEM_SpecialFree++ ;
#endif    /* if defined (DDSP_DEBUG) */
        }

        *ptr = NULL ;
    }

    TRC_1LEAVE ("MEM_Free", status) ;

    return status ;
}
Exemplo n.º 5
0
/*{{{  PlaybackAddStream*/
int PlaybackAddStream          (struct PlaybackContext_s*       Playback,
                                char*                           Media,
                                char*                           Format,
                                char*                           Encoding,
                                unsigned int                    DemuxId,
                                unsigned int                    SurfaceId,
                                struct StreamContext_s**        Stream)
{
    int                         Result;
    unsigned int                NewStream       = false;
    unsigned int                Demux           = false;

    BACKEND_DEBUG ("%p\n", Playback);

    if (Backend->Ops == NULL)
        return -ENODEV;

    if (Playback == NULL)                                       /* No playback to start stream in */
        return -EINVAL;

    if ((*Stream != NULL) && ((*Stream)->Handle != NULL))       /* Device already has this stream */
        return -EINVAL;

    if (*Stream == NULL)
    {
        *Stream     = kzalloc (sizeof(struct StreamContext_s), GFP_KERNEL);
        if (*Stream == NULL)
        {
            BACKEND_ERROR("Unable to create stream context - insufficient memory\n");
            return -ENOMEM;
        }

        if (Media == NULL)
        {
            (*Stream)->BufferLength             = DEMUX_BUFFER_SIZE;
            (*Stream)->Inject                   = Backend->Ops->demux_inject_data;
            (*Stream)->Delete                   = Backend->Ops->playback_remove_demux;
            Demux                               = true;
        }
        else
        {
            if (DemuxId == DEMUX_INVALID_ID)
                (*Stream)->BufferLength         = (strcmp (Media, BACKEND_AUDIO_ID) == 0) ? AUDIO_STREAM_BUFFER_SIZE : VIDEO_STREAM_BUFFER_SIZE;
            else
            /* The stream is part of a demux so it doesn't need its own buffer */
            {
                (*Stream)->BufferLength         = 0;
                (*Stream)->Buffer               = NULL;
                if (strcmp (Encoding, BACKEND_AUTO_ID) == 0)    /* default to mpeg2 play */
                {
                    BACKEND_DEBUG("Transport stream - Defaulting to mpeg2\n");
                    Encoding                    = BACKEND_MPEG2_ID;
                }
            }

            (*Stream)->Inject                   = Backend->Ops->stream_inject_data;
            (*Stream)->InjectPacket             = Backend->Ops->stream_inject_data_packet;
            (*Stream)->Delete                   = Backend->Ops->playback_remove_stream;
        }

        if ((*Stream)->BufferLength != 0)
        {
            (*Stream)->Buffer                   = bigphysarea_alloc ((*Stream)->BufferLength);
            if ((*Stream)->Buffer == NULL)
            {
                BACKEND_ERROR("Unable to create stream buffer - insufficient memory\n");
                kfree (*Stream);
                *Stream                         = NULL;
                return -ENOMEM;
            }
        }
        NewStream       = true;
    }

    mutex_lock (&(Playback->Lock));
    if ((Encoding != NULL) && (strcmp (Encoding, BACKEND_AUTO_ID) == 0))
    {
        (*Stream)->Handle       = NULL;
        Result                  = STREAM_INCOMPLETE;
    }
    else if (Demux)
        Result  = Backend->Ops->playback_add_demux     (Playback->Handle,
                                                        DemuxId,
                                                        &(*Stream)->Handle);
    else
        Result  = Backend->Ops->playback_add_stream    (Playback->Handle,
                                                        Media,
                                                        Format,
                                                        Encoding,
                                                        SurfaceId,
                                                        &(*Stream)->Handle);

    if (Result < 0)
    {
        BACKEND_ERROR("Unable to create stream context\n");
        if ((*Stream)->Buffer != NULL)
            bigphysarea_free_pages ((*Stream)->Buffer);
        kfree (*Stream);
        *Stream         = NULL;
    }
    else
    {
        mutex_init (&((*Stream)->Lock));
        if (NewStream)
        {
            Playback->UsageCount++;

            (*Stream)->DataToWrite      = 0;
        }
    }
    mutex_unlock (&(Playback->Lock));

    BACKEND_DEBUG ("%p: Usage = %d\n", Playback, Playback->UsageCount);
    return Result;
}