lib/slave_config.c
changeset 1264 e7882f246d7a
parent 1259 5f9d1abbee71
child 1266 dd1f501c4070
equal deleted inserted replaced
1263:f44720defbc5 1264:e7882f246d7a
    37 #include <errno.h>
    37 #include <errno.h>
    38 #include <string.h>
    38 #include <string.h>
    39 
    39 
    40 #include "slave_config.h"
    40 #include "slave_config.h"
    41 #include "domain.h"
    41 #include "domain.h"
       
    42 #include "voe_handler.h"
    42 #include "master.h"
    43 #include "master.h"
    43 #include "master/ioctl.h"
    44 #include "master/ioctl.h"
    44 
    45 
    45 /*****************************************************************************/
    46 /*****************************************************************************/
    46 
    47 
   304 /*****************************************************************************/
   305 /*****************************************************************************/
   305 
   306 
   306 ec_voe_handler_t *ecrt_slave_config_create_voe_handler(ec_slave_config_t *sc,
   307 ec_voe_handler_t *ecrt_slave_config_create_voe_handler(ec_slave_config_t *sc,
   307         size_t size)
   308         size_t size)
   308 {
   309 {
   309     return 0; // TODO
   310     ec_ioctl_voe_t data;
       
   311     ec_voe_handler_t *voe;
       
   312     unsigned int index;
       
   313 
       
   314     voe = malloc(sizeof(ec_voe_handler_t));
       
   315     if (!voe) {
       
   316         fprintf(stderr, "Failed to allocate memory.\n");
       
   317         return 0;
       
   318     }
       
   319 
       
   320     if (size) {
       
   321         voe->data = malloc(size);
       
   322         if (!voe->data) {
       
   323             fprintf(stderr, "Failed to allocate %u bytes of VoE data"
       
   324                     " memory.\n", size);
       
   325             free(voe);
       
   326             return 0;
       
   327         }
       
   328     } else {
       
   329         voe->data = NULL;
       
   330     }
       
   331 
       
   332     data.config_index = sc->index;
       
   333     data.size = size;
       
   334     
       
   335     if (ioctl(sc->master->fd, EC_IOCTL_SC_VOE, &data) == -1) {
       
   336         fprintf(stderr, "Failed to create VoE handler: %s\n",
       
   337                 strerror(errno));
       
   338         if (voe->data)
       
   339             free(voe->data);
       
   340         free(voe);
       
   341         return NULL; 
       
   342     }
       
   343 
       
   344     voe->config = sc;
       
   345     voe->index = data.voe_index;
       
   346     voe->data_size = size;
       
   347     voe->mem_size = size;
       
   348     return voe;
   310 }
   349 }
   311 
   350 
   312 /*****************************************************************************/
   351 /*****************************************************************************/
   313 
   352 
   314 void ecrt_slave_config_state(const ec_slave_config_t *sc,
   353 void ecrt_slave_config_state(const ec_slave_config_t *sc,