예제 #1
0
int dres_update_accessory_mode(const char *device, const char *mode)
{
#define NUM_DRES_VARS 2               /* &accessory_name, &accessory_mode */
    static int  warn = 1;
    char       *goal = "update_accessory_mode";
    char       *vars[NUM_DRES_VARS * 3 + 1];
    int         i, status;

    vars[i=0] = "accessory_name";
    vars[++i] = DRES_VARTYPE('s');
    vars[++i] = DRES_VARVALUE(device);
    vars[++i] = "accessory_mode";
    vars[++i] = DRES_VARTYPE('s');
    vars[++i] = DRES_VARVALUE(mode);
    vars[++i] = NULL;
            
    status = resolve(goal, vars);

    if (status < 0) {
        if (!warn) {
            OHM_WARNING("accessory: resolve('%s', '%s', '%s') failed",
                        goal, device, mode);
            warn = FALSE;
        }
    }
    else if (!status)
        OHM_ERROR("accessory: resolving '%s' failed", goal);
    
    return status;
#undef NUM_DRES_VARS
}
예제 #2
0
void videoipc_update_section(uint32_t mask, pid_t *pids, int npid)
{
#define SECTION_DATA(sec)                                              \
    secnam = #sec "users";                                             \
    maxpid = VIDEOIPC_MAX_##sec##_USERS;                               \
    idxptr = &ipc->sec##users.idx;                                     \
    oldidx = *idxptr;                                                  \
    newidx = (oldidx+1 >= DIM(ipc->sec##users.set)) ? 0 : oldidx+1;    \
    oldset = (videoipc_set_t *)&ipc->sec##users.set[oldidx];           \
    newset = (videoipc_set_t *)&ipc->sec##users.set[newidx];

    const char *secnam;
    int maxpid;
    int8_t oldidx, newidx, *idxptr;
    videoipc_set_t *oldset, *newset;

    if (pids && npid > 0) {
        switch (mask) {

        case VIDEOIPC_XVIDEO_SECTION:
            SECTION_DATA(XV);
            break;
            
        default:
            OHM_DEBUG(DBG_IPC, "unsupported section mask 0x%x", mask);
            return;
        }

        if (npid > maxpid) {
            OHM_WARNING("videoipc: too long (%d) %s PID list. "
                        "Truncating to the allowed maximum of %d",
                        secnam, npid, maxpid);
            npid = maxpid;
        }

        if (npid != oldset->npid || memcmp(pids, oldset->pids, npid)) {
            OHM_DEBUG(DBG_IPC, "%s section in videoipc shared memory updated. "
                      "New index is %u", secnam, newidx);

            newset->time = update.time;
            newset->npid = npid;
            memcpy(newset->pids, pids, npid * sizeof(pid_t));
            
            *idxptr = newidx;

            update.mask |= mask;
        }
    }

#undef SECTION_DATA
}
예제 #3
0
/********************
 * plugin_init
 ********************/
static void
plugin_init(OhmPlugin *plugin)
{
    if (!OHM_DEBUG_INIT(vibra))
        OHM_WARNING("vibra: failed to register for debugging");
    
    if (signaling_register == NULL || signaling_unregister == NULL) {
        OHM_ERROR("vibra: signaling interface not available");
        exit(1);
    }

    select_driver(&context, plugin);
    
    ep_init(&context, signaling_register);
    context.driver->init(&context, plugin);
    
    OHM_INFO("vibra: plugin ready...");
}
예제 #4
0
/********************
 * console_init
 ********************/
static int
console_init(char *address)
{
    char *signature;
    
#define IMPORT(name, ptr) ({                                            \
            signature = (char *)ptr##_SIGNATURE;                        \
            ohm_module_find_method((name), &signature, (void *)&(ptr)); \
        })

    extension_init();
    
    if (!strcmp(address, "disabled")) {
        OHM_INFO("resolver: console disabled");
        return 0;
    }
    
    if (!IMPORT("console.open", console_open)) {
        OHM_INFO("resolver: no console methods available, console disabled");
        return 0;
    }
    
    IMPORT("console.close" , console_close);
    IMPORT("console.printf", console_printf);
    IMPORT("console.grab"  , console_grab);
    IMPORT("console.ungrab", console_ungrab);

    if (console_close == NULL || console_printf == NULL ||
        console_grab == NULL || console_ungrab == NULL) {
        OHM_WARNING("resolver: missing console methods, console disabled");
        return 0;
    }
    
    
    OHM_INFO("resolver: using console %s", address);
    
    console = console_open(address,
                           console_opened, console_closed, console_input,
                           NULL, FALSE);
    
    return console < 0 ? EINVAL : 0;
#undef IMPORT    
}
예제 #5
0
/********************
 * plugin_init
 ********************/
static void
plugin_init(OhmPlugin *plugin)
{
    if (!OHM_DEBUG_INIT(backlight))
        OHM_WARNING("backlight: failed to register for debugging");
    
    if (signaling_register == NULL || signaling_unregister == NULL) {
        OHM_ERROR("backlight: signaling interface not available");
        exit(1);
    }

    context.resolve      = resolve;
    context.process_info = process_info;
    
    BACKLIGHT_SAVE_STATE(&context, "off");

    ep_init(&context, signaling_register);

    select_driver(&context, plugin);
    context.driver->init(&context, plugin);
    
    OHM_INFO("backlight: plugin ready...");
}
예제 #6
0
static int init_shmem(void)
{
    static int    flags = O_RDWR | O_CREAT;
    static mode_t mode  = S_IRUSR|S_IWUSR | S_IRGRP | S_IROTH; /* 644 */

    size_t        page;
    struct stat   st;
    
    do { /* not a loop */
        page   = sysconf(_SC_PAGESIZE);
        length = ((sizeof(videoipc_t) + page - 1) / page) * page;
        
        if ((fd = shm_open(VIDEOIPC_SHARED_OBJECT, flags, mode)) < 0) {
            OHM_ERROR("videoep: can't create shared memory object '%s': %s",
                      VIDEOIPC_SHARED_OBJECT, strerror(errno));
            break;
        }
        
        if (fstat(fd, &st) < 0) {
            OHM_ERROR("videoep: failed to stat shared memory object '%s': %s",
                      VIDEOIPC_SHARED_OBJECT, strerror(errno));
            break;
        }
        
        if (st.st_size < length) {
            if (!init_shfile(fd, length))
                break;
        }
        
        if ((ipc = mmap(NULL,length, PROT_WRITE,MAP_SHARED, fd, 0)) == NOIPC) {
            OHM_ERROR("videoep: failed to map shared memory of '%s': %s",
                      VIDEOIPC_SHARED_OBJECT, strerror(errno));
            break;
        }
        
        if (ipc->version.major != VIDEOIPC_MAJOR_VERSION) {
            OHM_ERROR("videoep: shared memory '%s' version mismatch. Shared "
                      "memory version %d.%d  plugin version %d.%d",
                      VIDEOIPC_SHARED_OBJECT,
                      (int)ipc->version.major, (int)ipc->version.minor,
                      VIDEOIPC_MAJOR_VERSION , VIDEOIPC_MINOR_VERSION);
            errno = EINVAL;
            break;
        }
        else {
            if (ipc->version.minor == VIDEOIPC_MINOR_VERSION) {
                OHM_INFO("videoep: shared memory '%s' is OK (version %d.%d)",
                         VIDEOIPC_SHARED_OBJECT,
                         (int)ipc->version.major, (int)ipc->version.minor);
            }
            else {
                OHM_WARNING("videoep: shared memory '%s' version mismatch. "
                            "shmem version %d.%d <> plugin version %d.%d",
                            VIDEOIPC_SHARED_OBJECT,
                            (int)ipc->version.major, (int)ipc->version.minor,
                            VIDEOIPC_MAJOR_VERSION , VIDEOIPC_MINOR_VERSION);
            }
        }
        
        /* everything was OK */
        return TRUE;
        
    } while (0);
    
    /*
     * something went wrong
     */
    exit_shmem();
    
    return FALSE;
}