Example #1
0
int avb_join_multicast_group(unsigned char addr[6])
{
  int found = -1;
  
  for (int i=0;i<AVB_MAX_MMRP_GROUPS;i++)
    if (entries[i].active && addr_eq(addr, entries[i].addr)) 
      found = i;

  if (found == -1) 
    for (int i=0;i<AVB_MAX_MMRP_GROUPS;i++)
      if (!entries[i].active) {
        found = i;
        break;
      }

  if (found == -1)
    for (int i=0;i<AVB_MAX_MMRP_GROUPS;i++)
      if (entries[i].active && mrp_is_observer(entries[i].attr)) {
        found = i;
        break;
      }


  if (found != -1) {
    entries[found].active = 1;
    memcpy(entries[found].addr, addr, 6);
    mrp_mad_begin(entries[found].attr);
    mrp_mad_join(entries[found].attr, 1);
    return 1;
  }

  return 0;
}
Example #2
0
void avb_start(void) {
  avb_1722_maap_rerequest_addresses();

  mrp_mad_begin(domain_attr);
  mrp_mad_join(domain_attr, 1);

}
Example #3
0
int avb_join_vlan(int vlan)
{
  int found = -1;
  
  for (int i=0;i<AVB_MAX_NUM_VLAN;i++)
    if (entries[i].active && (entries[i].vlan == vlan)) 
      found = i;

  if (found == -1) 
    for (int i=0;i<AVB_MAX_NUM_VLAN;i++)
      if (!entries[i].active) {
        found = i;
        break;
      }

  if (found == -1)
    for (int i=0;i<AVB_MAX_NUM_VLAN;i++)
      if (entries[i].active && mrp_is_observer(entries[i].attr)) {
        found = i;
        break;
      }

  if (found != -1) {
    entries[found].active = 1;
    entries[found].vlan = vlan;
    mrp_mad_begin(entries[found].attr);
    mrp_mad_join(entries[found].attr, 1);
    return 1;
  }

  return 0;
}
Example #4
0
void srp_domain_join(void)
{
  for (int i=0; i < MRP_NUM_PORTS; i++)
  {
      mrp_mad_begin(domain_attr[i]);
      mrp_mad_join(domain_attr[i], 1);
  }
}
Example #5
0
int getset_avb_sink_state(int set, 
                          int sink_num, 
                          enum avb_sink_state_t *state)
{
  if (sink_num < AVB_NUM_SINKS) {
    avb_sink_info_t *sink = &sinks[sink_num]; 
    if (set) {
      if (sink->stream.state == AVB_SINK_STATE_DISABLED &&
          *state == AVB_SINK_STATE_POTENTIAL) {
        chanend c = sink->listener_ctl;
        int clk_ctl;
        xc_abi_outuint(c, AVB1722_CONFIGURE_LISTENER_STREAM);
        xc_abi_outuint(c, sink->stream.local_id);
        xc_abi_outuint(c, sink->stream.sync);
        xc_abi_outuint(c, sink->stream.rate);
        xc_abi_outuint(c, sink->stream.num_channels);
        for (int i=0;i<sink->stream.num_channels;i++) {
          xc_abi_outuint(c, outputs[sink->stream.map[i]].fifo);
        }                       
        (void) xc_abi_inuint(c);

        clk_ctl = outputs[sink->stream.map[0]].clk_ctl;

        if (!isnull(media_clock_svr)) {
        	media_clock_register(media_clock_svr, clk_ctl, sink->stream.sync);
        }

        { int router_link;
         
          xc_abi_outuint(c, AVB1722_GET_ROUTER_LINK);
          router_link = xc_abi_inuint(c);
          
          avb_1722_add_stream_mapping(c_mac_tx,
                                      sink->stream.streamId,
                                      router_link,
                                      sink->stream.local_id);
        }

#ifndef AVB_EXCLUDE_MVRP
        if (sink->stream.vlan)
          avb_join_vlan(sink->stream.vlan);
#endif

#ifdef AVB_INCLUDE_MMRP
        if (sink->addr[0] & 1) 
          avb_join_multicast_group(sink->addr);
#endif

        mrp_mad_begin(sink->stream.srp_talker_attr);
        mrp_mad_begin(sink->stream.srp_talker_failed_attr);
        mrp_mad_begin(sink->stream.srp_listener_attr);
        mrp_mad_join(sink->stream.srp_listener_attr, 1);
      }
      else if (sink->stream.state != AVB_SINK_STATE_DISABLED &&
              *state == AVB_SINK_STATE_DISABLED) {

		  chanend c = sink->listener_ctl;
		  xc_abi_outuint(c, AVB1722_DISABLE_LISTENER_STREAM);
		  xc_abi_outuint(c, sink->stream.local_id);
		  (void) xc_abi_inuint(c);

    	  mrp_mad_leave(sink->stream.srp_listener_attr);

#ifdef AVB_INCLUDE_MMRP
        if (sink->addr[0] & 1)
          avb_leave_multicast_group(sink->addr);
#endif

#ifndef AVB_EXCLUDE_MVRP
        if (sink->stream.vlan)
          avb_leave_vlan(sink->stream.vlan);
#endif
      }
      sink->stream.state = *state;
    }
    *state = sink->stream.state;
    return 1;
  }
  else 
    return 0;
}
Example #6
0
int getset_avb_source_state(int set, 
                            int source_num, 
                            enum avb_source_state_t *state)
{
  if (source_num < AVB_NUM_SOURCES) {
    avb_source_info_t *source = &sources[source_num]; 
    if (set) {      
      if (source->stream.state == AVB_SOURCE_STATE_DISABLED &&
          *state == AVB_SOURCE_STATE_POTENTIAL) {
        // enable the source
        int valid = 1;
        int clk_ctl;

        if (source->stream.num_channels <= 0)
          valid = 0;

        clk_ctl = inputs[source->stream.map[0]].clk_ctl;

        // check that the map is ok
        for (int i=0;i<source->stream.num_channels;i++) {
          if (inputs[source->stream.map[i]].mapped_to != UNMAPPED)
            valid = 0;
          if (inputs[source->stream.map[i]].clk_ctl != clk_ctl)
            valid = 0;
        }
        

        if (valid) {
          chanend c = source->talker_ctl;
          unsigned fifo_mask = 0;

          for (int i=0;i<source->stream.num_channels;i++) {
            inputs[source->stream.map[i]].mapped_to = source_num;
            fifo_mask |= (1 << source->stream.map[i]);
          }
          
          xc_abi_outuint(c, AVB1722_CONFIGURE_TALKER_STREAM);
          xc_abi_outuint(c, source->stream.local_id);
          xc_abi_outuint(c, source->stream.format);
          for (int i=0; i < 6;i++) {
            xc_abi_outuint(c, source->dest[i]);
          }
          xc_abi_outuint(c, source_num);
          xc_abi_outuint(c, source->stream.num_channels);
          xc_abi_outuint(c, fifo_mask);
          for (int i=0;i<source->stream.num_channels;i++) {
            xc_abi_outuint(c, inputs[source->stream.map[i]].fifo);
          }
          xc_abi_outuint(c, source->stream.rate);
          if (source->presentation)
            xc_abi_outuint(c, source->presentation);
          else
            xc_abi_outuint(c, AVB_DEFAULT_PRESENTATION_TIME_DELAY_NS);
          
          (void) xc_abi_inuint(c);

          

          mrp_mad_begin(source->stream.srp_talker_attr);
          mrp_mad_begin(source->stream.srp_talker_failed_attr);
          mrp_mad_begin(source->stream.srp_listener_attr);
          mrp_mad_join(source->stream.srp_talker_attr, 1);

          if (!isnull(media_clock_svr)) {
        	  media_clock_register(media_clock_svr, clk_ctl, source->stream.sync);
          }

#if defined(AVB_TRANSMIT_BEFORE_RESERVATION)
          {
        	chanend c = source->talker_ctl;
            xc_abi_outuint(c, AVB1722_TALKER_GO);
            xc_abi_outuint(c, source->stream.local_id);
            (void) xc_abi_inuint(c); //ACK

            simple_printf("Stream #%d on\n", source_num);
          }
#else
          simple_printf("Stream #%d ready\n", source_num);
#endif

        }
      }
      else if (source->stream.state == AVB_SOURCE_STATE_ENABLED &&
          *state == AVB_SOURCE_STATE_POTENTIAL) {
    	  // stop transmission

          chanend c = source->talker_ctl;
          xc_abi_outuint(c, AVB1722_TALKER_STOP);
          xc_abi_outuint(c, source->stream.local_id);
          (void) xc_abi_inuint(c); //ACK

          simple_printf("Stream #%d off\n", source_num);
      }
      else if (source->stream.state == AVB_SOURCE_STATE_POTENTIAL &&
               *state == AVB_SOURCE_STATE_ENABLED) {
        // start transmitting

        simple_printf("Stream #%d on\n", source_num);
        chanend c = source->talker_ctl;
        xc_abi_outuint(c, AVB1722_TALKER_GO);
        xc_abi_outuint(c, source->stream.local_id);
        (void) xc_abi_inuint(c); //ACK        
      }
      else if (source->stream.state != AVB_SOURCE_STATE_DISABLED &&
               *state == AVB_SOURCE_STATE_DISABLED) {
        // disabled the source
          for (int i=0;i<source->stream.num_channels;i++) {
            inputs[source->stream.map[i]].mapped_to = UNMAPPED;
          }
          chanend c = source->talker_ctl;
          xc_abi_outuint(c, AVB1722_TALKER_STOP);
          xc_abi_outuint(c, source->stream.local_id);
          (void) xc_abi_inuint(c); //ACK

          // And remove the group
          mrp_mad_leave(source->stream.srp_talker_attr);
      }
      avb_set_talker_bandwidth();
      source->stream.state = *state;
    }
    *state = source->stream.state;
    return 1;
  }
  else 
    return 0;
}