summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/conf/include/agl_ebisu.inc
blob: d684f814db45475c8a81c03b9e97dafdb3d7950f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
require conf/include/agl_rcar.inc
SOC_FAMILY = "r8a77990"
BOARD_NAME = "ebisu"

DTB_SUFFIX = "r8a77990-ebisu"

DISTRO_FEATURES:remove = " use_eva_pkg"

# Configuration for USB 3.0
MACHINE_FEATURES:append = " usb3"

IMAGE_INSTALL:append = " gstreamer1.0-omx gstreamer1.0-plugin-vspfilter"
IMAGE_INSTALL:append = " kernel-module-mmngr kernel-module-mmngrbuf kernel-module-uvcs-drv kernel-module-vspm-if"
/* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Video On Demand Samples
 *
 * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * You may also obtain this software under a propriety license from Microchip.
 * Please contact Microchip for further information.
 *
 */

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <pthread.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "Console.h"

///Our shared memory key
static int shmkey = 072162537;
//The minimum priority
static ConsolePrio_t minPrio = PRIO_LOW;

/*! \cond PRIVATE */
typedef struct
{
    ///The first process will setup the critical section and set this variable to true.
    bool initialized;
    ///If set to true, multiple processeses are synced via shared memory.
    bool processSynced;
    ///If set to true, there is an segmented print ongoing (Start, Continue, Exit).
    bool criticalSection;
    //If is in a critical segmented print, this variable will hold the prio for Start, Continue, Exit.
    ConsolePrio_t criticalSectionPrio;
    ///Handle of the shared mutex.
    pthread_mutex_t mutex;
} sharedData_t;
/*! \endcond */

/*----------------------------------------------------------*/
/*! \brief Pointer to the shared memory instance.
 */
/*----------------------------------------------------------*/
static sharedData_t *data = NULL;

void ConsoleInit( bool synchronizeProcesses )
{
    pthread_mutexattr_t attr;

    if( synchronizeProcesses )
    {
        int shmid = shmget( shmkey, sizeof( sharedData_t ), IPC_CREAT | 0666 );
        if( ( sharedData_t * )-1 == ( data = ( sharedData_t* )shmat( shmid, NULL, 0 ) ) )
        {
            data = NULL;
            fprintf( stderr, RED"ConsoleInit failed, because shared memory could not be accessed."RESETCOLOR"\n" );
            return;
        }
    }
    else
    {
        data = ( sharedData_t * )calloc( 1, sizeof( sharedData_t ) );
    }
    if( ( NULL != data ) && !data->initialized )
    {
        data->processSynced = synchronizeProcesses;
        data->initialized = true;
        data->criticalSection = false;

        pthread_mutexattr_init( &attr );
        if( synchronizeProcesses )
            pthread_mutexattr_setpshared( &attr, PTHREAD_PROCESS_SHARED );
        else
            pthread_mutexattr_setpshared( &attr, PTHREAD_PROCESS_PRIVATE );
        pthread_mutex_init( &data->mutex, &attr );
    }
}

void ConsoleDeinit( void )
{
    if( NULL != data && !data->processSynced )
    {
        free( data );
        data = NULL;
    }
}

void ConsoleSetPrio( ConsolePrio_t prio )
{
    minPrio = prio;
}

void ConsolePrintf( ConsolePrio_t prio, const char *statement, ... )
{
    int err;
    if( prio < minPrio || NULL == statement )
        return;
    if( NULL == data )
    {
        fprintf( stderr, RED"ConsolePrintf data was null"RESETCOLOR"\n" );
        return;
    }
    if( 0 != ( err = pthread_mutex_lock( &data->mutex ) ) )
    {
        fprintf( stderr, RED"ConsolePrintf, pthread_mutex_lock error: %d"RESETCOLOR"\n", err );
        return;
    }

    va_list args;
    va_start( args, statement );
    vfprintf( stderr, statement, args );
    va_end( args );

    if( 0 != ( err = pthread_mutex_unlock( &data->mutex ) ) )
    {
        fprintf( stderr, RED"ConsolePrintf, pthread_mutex_unlock error: %d"RESETCOLOR"\n", err );
        return;
    }
}

void ConsolePrintfStart( ConsolePrio_t prio, const char *statement, ... )
{
    int err;
    if( NULL == data )
    {
        fprintf( stderr, RED"ConsolePrintfStart data was null"RESETCOLOR"\n" );
        return;
    }
    if( 0 != ( err = pthread_mutex_lock( &data->mutex ) ) )
    {
        fprintf( stderr, RED"ConsolePrintfStart, pthread_mutex_lock error: %d"RESETCOLOR"\n", err );
        return;
    }
    data->criticalSection = true;
    data->criticalSectionPrio = prio;

    if( data->criticalSectionPrio >= minPrio && NULL != statement )
    {
        va_list args;
        va_start( args, statement );
        vfprintf( stderr, statement, args );
        va_end( args );
    }
}

void ConsolePrintfContinue( const char *statement, ... )
{
    if( NULL == data )
    {
        fprintf( stderr, RED"ConsolePrintfContinue data was null"RESETCOLOR"\n" );
        return;
    }
    if( !data->criticalSection )
    {
        fprintf( stderr, RED"ConsolePrintfContinue not in critical section"RESETCOLOR"\n" );
        return;
    }

    if( data->criticalSectionPrio >= minPrio && NULL != statement )
    {
        va_list args;
        va_start( args, statement );
        vfprintf( stderr, statement, args );
        va_end( args );
    }
}

void ConsolePrintfExit( const char *statement, ... )
{
    int err;
    if( NULL == data )
    {
        fprintf( stderr, RED"ConsolePrintfExit data was null"RESETCOLOR"\n" );
        return;
    }
    if( !data->criticalSection )
    {
        fprintf( stderr, RED"ConsolePrintfExit not in critical section"RESETCOLOR"\n" );
        return;
    }
    if( data->criticalSectionPrio >= minPrio && NULL != statement )
    {
        va_list args;
        va_start( args, statement );
        vfprintf( stderr, statement, args );
        va_end( args );
    }
    data->criticalSection = false;
    if( 0 != ( err = pthread_mutex_unlock( &data->mutex ) ) )
    {
        fprintf( stderr, RED"ConsolePrintfExit, pthread_mutex_unlock error: %d"RESETCOLOR"\n", err );
    }
}