Example #1
0
int discoverAVC( int* port, octlet_t guid )
{
	rom1394_directory rom_dir;
	raw1394handle_t handle;
	int device = -1;
	int i, j = 0;
	int m = raw1394_get_num_ports();

	if ( *port >= 0 )
	{
		/* search on explicit port */
		j = *port;
		m = *port + 1;
	}

	for ( ; j < m && device == -1; j++ )
	{
		handle = raw1394_open( j );
		for ( i = 0; i < raw1394_get_nodecount( handle ); ++i )
		{
			if ( guid != 0 )
			{
				/* select explicitly by GUID */
				if ( guid == rom1394_get_guid( handle, i ) )
				{
					device = i;
					*port = j;
					break;
				}
			}
			else
			{
				/* select first AV/C Tape Reccorder Player node */
				if ( rom1394_get_directory( handle, i, &rom_dir ) < 0 )
				{
					fprintf( stderr, "error reading config rom directory for node %d\n", i );
					continue;
				}
				if ( ( rom1394_get_node_type( &rom_dir ) == ROM1394_NODE_TYPE_AVC ) &&
				        avc1394_check_subunit_type( handle, i, AVC1394_SUBUNIT_TYPE_VCR ) )
				{
					device = i;
					*port = j;
					break;
				}
			}
		}
		raw1394_close( handle );
	}

	return device;
}
static void
gst_hdv1394src_update_device_name (GstHDV1394Src * src)
{
    raw1394handle_t handle;
    gint portcount, port, nodecount, node;
    rom1394_directory directory;

    g_free (src->device_name);
    src->device_name = NULL;

    GST_LOG_OBJECT (src, "updating device name for current GUID");

    handle = raw1394_new_handle ();

    if (handle == NULL)
        goto gethandle_failed;

    portcount = raw1394_get_port_info (handle, NULL, 0);
    for (port = 0; port < portcount; port++) {
        if (raw1394_set_port (handle, port) >= 0) {
            nodecount = raw1394_get_nodecount (handle);
            for (node = 0; node < nodecount; node++) {
                if (src->guid == rom1394_get_guid (handle, node)) {
                    if (rom1394_get_directory (handle, node, &directory) >= 0) {
                        g_free (src->device_name);
                        src->device_name = g_strdup (directory.label);
                        rom1394_free_directory (&directory);
                        goto done;
                    } else {
                        GST_WARNING ("error reading rom directory for node %d", node);
                    }
                }
            }
        }
    }

    src->device_name = g_strdup ("Unknown");      /* FIXME: translate? */

done:

    raw1394_destroy_handle (handle);
    return;

    /* ERRORS */
gethandle_failed:
    {
        GST_WARNING ("failed to get raw1394 handle: %s", g_strerror (errno));
        src->device_name = g_strdup ("Unknown");    /* FIXME: translate? */
        return;
    }
}
Example #3
0
static GValueArray *
gst_1394_get_guid_array (void)
{
  GValueArray *result = NULL;
  raw1394handle_t handle = NULL;
  int num_ports = 0;
  int port = 0;
  int num_nodes = 0;
  int node = 0;
  rom1394_directory directory;
  GValue value = { 0, };

  handle = raw1394_new_handle ();

  if (handle == NULL)
    return NULL;

  num_ports = raw1394_get_port_info (handle, NULL, 0);
  for (port = 0; port < num_ports; port++) {
    if (raw1394_set_port (handle, port) >= 0) {
      num_nodes = raw1394_get_nodecount (handle);
      for (node = 0; node < num_nodes; node++) {
        rom1394_get_directory (handle, node, &directory);
        if (rom1394_get_node_type (&directory) == ROM1394_NODE_TYPE_AVC &&
            avc1394_check_subunit_type (handle, node,
                AVC1394_SUBUNIT_TYPE_VCR)) {
          if (result == NULL)
            result = g_value_array_new (3);     /* looks like a sensible default */
          g_value_init (&value, G_TYPE_UINT64);
          g_value_set_uint64 (&value, rom1394_get_guid (handle, node));
          g_value_array_append (result, &value);
          g_value_unset (&value);
        }
      }
    }
  }

  return result;
}
Example #4
0
int
SlaveDevice::init_config_rom(raw1394handle_t handle)
{
    int retval, i;
    quadlet_t rom[0x100];
    size_t rom_size;
    unsigned char rom_version;
    rom1394_directory dir;
    char *leaf;

    /* get the current rom image */
    retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version);
    rom_size = rom1394_get_size(rom);
//     printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version);
//     for (i = 0; i < rom_size; i++)
//     {
//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4);
//         printf(" %08x", CondSwapFromBus32(rom[i]));
//     }
//     printf("\n");

    /* get the local directory */
    rom1394_get_directory( handle, raw1394_get_local_id(handle) & 0x3f, &dir);

    /* change the vendor description for kicks */
    i = strlen(dir.textual_leafs[0]);
    strncpy(dir.textual_leafs[0], FFADO_BOUNCE_SERVER_VENDORNAME "                                          ", i);

    dir.vendor_id=FFADO_BOUNCE_SERVER_VENDORID;
    dir.model_id=FFADO_BOUNCE_SERVER_MODELID;

    /* update the rom */
    retval = rom1394_set_directory(rom, &dir);
//     printf("rom1394_set_directory returned %d, romsize %d:",retval,rom_size);
//     for (i = 0; i < rom_size; i++)
//     {
//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4);
//         printf(" %08x", CondSwapFromBus32(rom[i]));
//     }
//     printf("\n");

    /* free the allocated mem for the textual leaves */
    rom1394_free_directory( &dir);

    /* add an AV/C unit directory */
    dir.unit_spec_id    = FFADO_BOUNCE_SERVER_SPECID;
    dir.unit_sw_version = 0x00010001;
    leaf = (char*)FFADO_BOUNCE_SERVER_MODELNAME;
    dir.nr_textual_leafs = 1;
    dir.textual_leafs = &leaf;

    /* manipulate the rom */
    retval = rom1394_add_unit( rom, &dir);

    /* get the computed size of the rom image */
    rom_size = rom1394_get_size(rom);

//     printf("rom1394_add_unit_directory returned %d, romsize %d:",retval,rom_size);
//     for (i = 0; i < rom_size; i++)
//     {
//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4);
//         printf(" %08x", CondSwapFromBus32(rom[i]));
//     }
//     printf("\n");
//
    /* convert computed rom size from quadlets to bytes before update */
    rom_size *= sizeof(quadlet_t);
    retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version);
//     printf("update_config_rom returned %d\n",retval);

    retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version);
//     printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version);
//     for (i = 0; i < rom_size; i++)
//     {
//         if (i % 4 == 0) printf("\n0x%04x:", CSR_CONFIG_ROM+i*4);
//         printf(" %08x", CondSwapFromBus32(rom[i]));
//     }
//     printf("\n");

//     printf("You need to reload your ieee1394 modules to reset the rom.\n");

    return 0;
}
Example #5
0
void AVC1394Control::initialize()
{
	int i;

	current_command = COMMAND_NONE;
	device = -1;

	device_lock = new Mutex("AVC1394Control::device_lock");

#ifdef RAW1394_V_0_8
	handle = raw1394_get_handle();
#else
	handle = raw1394_new_handle();
#endif
//printf("AVC1394Control::initialize(): 1\n");
	if(!handle)
	{
//printf("AVC1394Control::initialize(): 2\n");
		if(!errno)
		{
//printf("AVC1394Control::initialize(): 3\n");
			fprintf(stderr, "AVC1394Control::initialize(): Not Compatable!\n");
		} 
		else 
		{
//printf("AVC1394Control::initialize(): 4\n");
			fprintf(stderr, "AVC1394Control::initialize(): couldn't get handle\n");
		}
		return;
	}

	if(raw1394_set_port(handle, 0) < 0) {
//printf("AVC1394Control::initialize(): 5\n");
		perror("AVC1394Control::initialize(): couldn't set port");
//		raw1394_destroy_handle(handle);
		return;
	}

	for(i = 0; i < raw1394_get_nodecount(handle); i++)
	{
		if(rom1394_get_directory(handle, i, &rom_dir) < 0)
		{
//printf("AVC1394Control::initialize(): 6\n");
			fprintf(stderr, "AVC1394Control::initialize(): node %d\n", i);
//			raw1394_destroy_handle(handle);
			return;
		}
		
		if((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) &&
			avc1394_check_subunit_type(handle, i, AVC1394_SUBUNIT_TYPE_VCR))
		{
//printf("AVC1394Control::initialize(): 7\n");
			device = i;
			break;
		}
	}

	if(device == -1)
	{
//printf("AVC1394Control::initialize(): 8\n");
		fprintf(stderr, "AVC1394Control::initialize(): No AV/C Devices\n");
//		raw1394_destroy_handle(handle);
		return;
	}

}
Example #6
0
int main(int argc, char **argv)
{
	raw1394handle_t handle;
	int retval;
	quadlet_t rom[0x100];
	size_t rom_size;
	unsigned char rom_version;
	rom1394_directory dir;
	char *(leaf[2]);
	
	handle = raw1394_new_handle();
	
	if (!handle) {
		if (!errno) {
				printf(not_compatible);
		} else {
				perror("couldn't get handle");
				printf(not_loaded);
		}
		exit(EXIT_FAILURE);
	}
	
	if (raw1394_set_port(handle, 0) < 0) {
		perror("couldn't set port");
		exit(EXIT_FAILURE);
	}
	
	/* get the current rom image */
	retval=raw1394_get_config_rom(handle, rom, 0x100, &rom_size, &rom_version);
	rom_size = rom1394_get_size(rom);
	printf("get_config_rom returned %d, romsize %d, rom_version %d:",retval,rom_size,rom_version);
	
	/* get the local directory */
	rom1394_get_directory( handle, raw1394_get_local_id(handle) & 0x3f, &dir);
	
	/* free the allocated mem for the textual leaves */
	rom1394_free_directory( &dir);
	
	/* add an RFC 2734 unit directory */
	dir.unit_spec_id    = 0x0000005e;
	dir.unit_sw_version = 0x00000001;
	leaf[0] = "IANA";
    leaf[1] = "IPv4";
	dir.nr_textual_leafs = 2;
	dir.textual_leafs = leaf;
	
	/* manipulate the rom */
	retval = rom1394_add_unit( rom, &dir);
	
	/* get the computed size of the rom image */
	rom_size = rom1394_get_size(rom);
	
	printf("rom1394_add_unit_directory returned %d, romsize %d:",retval,rom_size);
	
	/* convert computed rom size from quadlets to bytes before update */
	rom_size *= sizeof(quadlet_t);
	retval = raw1394_update_config_rom(handle, rom, rom_size, rom_version);
	printf("update_config_rom returned %d\n",retval);
	printf("You need to reload your ieee1394 modules to reset the rom.\n");
    
    raw1394_reset_bus(handle);
	
	exit(EXIT_SUCCESS);
}
static int
gst_hdv1394src_discover_avc_node (GstHDV1394Src * src)
{
    int node = -1;
    int i, j = 0;
    int m = src->num_ports;

    if (src->port >= 0) {
        /* search on explicit port */
        j = src->port;
        m = j + 1;
    }

    /* loop over all our ports */
    for (; j < m && node == -1; j++) {
        raw1394handle_t handle;
        struct raw1394_portinfo pinf[16];

        /* open the port */
        handle = raw1394_new_handle ();
        if (!handle) {
            GST_WARNING ("raw1394 - failed to get handle: %s.\n", strerror (errno));
            continue;
        }
        if (raw1394_get_port_info (handle, pinf, 16) < 0) {
            GST_WARNING ("raw1394 - failed to get port info: %s.\n",
                         strerror (errno));
            goto next;
        }

        /* tell raw1394 which host adapter to use */
        if (raw1394_set_port (handle, j) < 0) {
            GST_WARNING ("raw1394 - failed to set set port: %s.\n", strerror (errno));
            goto next;
        }

        /* now loop over all the nodes */
        for (i = 0; i < raw1394_get_nodecount (handle); i++) {
            /* are we looking for an explicit GUID ? */
            if (src->guid != 0) {
                if (src->guid == rom1394_get_guid (handle, i)) {
                    node = i;
                    src->port = j;
                    g_free (src->uri);
                    src->uri = g_strdup_printf ("dv://%d", src->port);
                    break;
                }
            } else {
                rom1394_directory rom_dir;

                /* select first AV/C Tape Recorder Player node */
                if (rom1394_get_directory (handle, i, &rom_dir) < 0) {
                    GST_WARNING ("error reading config rom directory for node %d\n", i);
                    continue;
                }
                if ((rom1394_get_node_type (&rom_dir) == ROM1394_NODE_TYPE_AVC) &&
                        avc1394_check_subunit_type (handle, i, AVC1394_SUBUNIT_TYPE_VCR)) {
                    node = i;
                    src->port = j;
                    src->guid = rom1394_get_guid (handle, i);
                    g_free (src->uri);
                    src->uri = g_strdup_printf ("dv://%d", src->port);
                    g_free (src->device_name);
                    src->device_name = g_strdup (rom_dir.label);
                    break;
                }
                rom1394_free_directory (&rom_dir);
            }
        }
next:
        raw1394_destroy_handle (handle);
    }
    return node;
}