static void _bootstrap (ArvUvDevice *uv_device) { ArvDevice *device = ARV_DEVICE (uv_device); guint64 offset; guint32 response_time; guint64 manifest_table_address; guint64 device_capability; guint32 max_cmd_transfer; guint32 max_ack_transfer; guint32 u3vcp_capability; guint64 sirm_offset; guint32 si_info; guint32 si_control; guint64 si_req_payload_size; guint32 si_req_leader_size; guint32 si_req_trailer_size; guint32 si_max_leader_size; guint32 si_payload_size; guint32 si_payload_count; guint32 si_transfer1_size; guint32 si_transfer2_size; guint32 si_max_trailer_size; guint64 manifest_n_entries; ArvUvcpManifestEntry entry; ArvUvcpManifestSchemaType schema_type; GString *string; void *data; char manufacturer[64]; arv_debug_device ("Get genicam"); arv_device_read_memory(device, ARV_ABRM_MANUFACTURER_NAME, 64, &manufacturer, NULL); manufacturer[63] = 0; arv_debug_device ("MANUFACTURER_NAME = '%s'", manufacturer); arv_device_read_memory (device, ARV_ABRM_SBRM_ADDRESS, sizeof (guint64), &offset, NULL); arv_device_read_memory (device, ARV_ABRM_MAX_DEVICE_RESPONSE_TIME, sizeof (guint32), &response_time, NULL); arv_device_read_memory (device, ARV_ABRM_DEVICE_CAPABILITY, sizeof (guint64), &device_capability, NULL); arv_device_read_memory (device, ARV_ABRM_MANIFEST_TABLE_ADDRESS, sizeof (guint64), &manifest_table_address, NULL); arv_debug_device ("MAX_DEVICE_RESPONSE_TIME = 0x%08x", response_time); arv_debug_device ("DEVICE_CAPABILITY = 0x%016lx", device_capability); arv_debug_device ("SRBM_ADDRESS = 0x%016lx", offset); arv_debug_device ("MANIFEST_TABLE_ADDRESS = 0x%016lx", manifest_table_address); uv_device->priv->timeout_ms = MAX (ARV_UVCP_DEFAULT_RESPONSE_TIME_MS, response_time); arv_device_read_memory (device, offset + ARV_SBRM_U3VCP_CAPABILITY, sizeof (guint32), &u3vcp_capability, NULL); arv_device_read_memory (device, offset + ARV_SBRM_MAX_CMD_TRANSFER, sizeof (guint32), &max_cmd_transfer, NULL); arv_device_read_memory (device, offset + ARV_SBRM_MAX_ACK_TRANSFER, sizeof (guint32), &max_ack_transfer, NULL); arv_device_read_memory (device, offset + ARV_SBRM_SIRM_ADDRESS, sizeof (guint64), &sirm_offset, NULL); arv_debug_device ("U3VCP_CAPABILITY = 0x%08x", u3vcp_capability); arv_debug_device ("MAX_CMD_TRANSFER = 0x%08x", max_cmd_transfer); arv_debug_device ("MAX_ACK_TRANSFER = 0x%08x", max_ack_transfer); arv_debug_device ("SIRM_OFFSET = 0x%016lx", sirm_offset); uv_device->priv->cmd_packet_size_max = MIN (uv_device->priv->cmd_packet_size_max, max_cmd_transfer); uv_device->priv->ack_packet_size_max = MIN (uv_device->priv->ack_packet_size_max, max_ack_transfer); arv_device_read_memory (device, sirm_offset + ARV_SI_INFO, sizeof (si_info), &si_info, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_CONTROL, sizeof (si_control), &si_control, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_PAYLOAD_SIZE, sizeof (si_req_payload_size), &si_req_payload_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_LEADER_SIZE, sizeof (si_req_leader_size), &si_req_leader_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_REQ_TRAILER_SIZE, sizeof (si_req_trailer_size), &si_req_trailer_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_MAX_LEADER_SIZE, sizeof (si_max_leader_size), &si_max_leader_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_PAYLOAD_SIZE, sizeof (si_payload_size), &si_payload_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_PAYLOAD_COUNT, sizeof (si_payload_count), &si_payload_count, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_TRANSFER1_SIZE, sizeof (si_transfer1_size), &si_transfer1_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_TRANSFER2_SIZE, sizeof (si_transfer2_size), &si_transfer2_size, NULL); arv_device_read_memory (device, sirm_offset + ARV_SI_MAX_TRAILER_SIZE, sizeof (si_max_trailer_size), &si_max_trailer_size, NULL); arv_debug_device ("SI_INFO = 0x%08x", si_info); arv_debug_device ("SI_CONTROL = 0x%08x", si_control); arv_debug_device ("SI_REQ_PAYLOAD_SIZE = 0x%016lx", si_req_payload_size); arv_debug_device ("SI_REQ_LEADER_SIZE = 0x%08x", si_req_leader_size); arv_debug_device ("SI_REQ_TRAILER_SIZE = 0x%08x", si_req_trailer_size); arv_debug_device ("SI_MAX_LEADER_SIZE = 0x%08x", si_max_leader_size); arv_debug_device ("SI_PAYLOAD_SIZE = 0x%08x", si_payload_size); arv_debug_device ("SI_PAYLOAD_COUNT = 0x%08x", si_payload_count); arv_debug_device ("SI_TRANSFER1_SIZE = 0x%08x", si_transfer1_size); arv_debug_device ("SI_TRANSFER2_SIZE = 0x%08x", si_transfer2_size); arv_debug_device ("SI_MAX_TRAILER_SIZE = 0x%08x", si_max_trailer_size); arv_device_read_memory (device, manifest_table_address, sizeof (guint64), &manifest_n_entries, NULL); arv_device_read_memory (device, manifest_table_address + 0x08, sizeof (entry), &entry, NULL); arv_debug_device ("MANIFEST_N_ENTRIES = 0x%016lx", manifest_n_entries); string = g_string_new (""); arv_g_string_append_hex_dump (string, &entry, sizeof (entry)); arv_debug_device ("MANIFEST ENTRY\n%s", string->str); g_string_free (string, TRUE); arv_debug_device ("genicam address = 0x%016lx", entry.address); arv_debug_device ("genicam size = 0x%016lx", entry.size); data = g_malloc0 (entry.size); arv_device_read_memory (device, entry.address, entry.size, data, NULL); #if 0 string = g_string_new (""); arv_g_string_append_hex_dump (string, data, entry.size); arv_debug_device ("GENICAM\n%s", string->str); g_string_free (string, TRUE); #endif schema_type = arv_uvcp_manifest_entry_get_schema_type (&entry); switch (schema_type) { case ARV_UVCP_SCHEMA_ZIP: { ArvZip *zip; const GSList *zip_files; zip = arv_zip_new (data, entry.size); zip_files = arv_zip_get_file_list (zip); if (zip_files != NULL) { const char *zip_filename; zip_filename = arv_zip_file_get_name (zip_files->data); uv_device->priv->genicam_xml = arv_zip_get_file (zip, zip_filename, &uv_device->priv->genicam_xml_size); arv_debug_device ("zip file = %s", zip_filename); #if 0 string = g_string_new (""); arv_g_string_append_hex_dump (string, uv_device->priv->genicam_xml, uv_device->priv->genicam_xml_size); arv_debug_device ("GENICAM\n%s", string->str); g_string_free (string, TRUE); #endif uv_device->priv->genicam = arv_gc_new (ARV_DEVICE (uv_device), uv_device->priv->genicam_xml, uv_device->priv->genicam_xml_size); } arv_zip_free (zip); g_free (data); } break; case ARV_UVCP_SCHEMA_RAW: { uv_device->priv->genicam_xml = data; uv_device->priv->genicam_xml_size = entry.size; uv_device->priv->genicam = arv_gc_new (ARV_DEVICE (uv_device), uv_device->priv->genicam_xml, uv_device->priv->genicam_xml_size); } break; default: arv_warning_device ("Unknown USB3Vision manifest schema type (%d)", schema_type); } #if 0 arv_debug_device("GENICAM\n:%s", uv_device->priv->genicam_xml); #endif }
static char * _load_genicam (ArvGvDevice *gv_device, guint32 address, size_t *size) { char filename[ARV_GVBS_XML_URL_SIZE]; char **tokens; char *genicam = NULL; g_return_val_if_fail (size != NULL, NULL); *size = 0; if (!arv_device_read_memory (ARV_DEVICE (gv_device), address, ARV_GVBS_XML_URL_SIZE, filename, NULL)) return NULL; filename[ARV_GVBS_XML_URL_SIZE - 1] = '\0'; arv_debug_device ("[GvDevice::load_genicam] xml url = '%s' at 0x%x", filename, address); tokens = g_regex_split (arv_gv_device_get_url_regex (), filename, 0); if (tokens[0] != NULL) { if (g_strcmp0 (tokens[1], "File:") == 0) g_file_get_contents (filename, &genicam, NULL, NULL); else if (g_strcmp0 (tokens[1], "Local:") == 0 && tokens[2] != NULL && tokens[3] != NULL && tokens[4] != NULL) { guint32 file_address; guint32 file_size; file_address = strtoul (tokens[3], NULL, 16); file_size = strtoul (tokens[4], NULL, 16); arv_debug_device ("[GvDevice::load_genicam] Xml address = 0x%x - size = 0x%x - %s", file_address, file_size, tokens[2]); if (file_size > 0) { genicam = g_malloc (file_size); if (arv_device_read_memory (ARV_DEVICE (gv_device), file_address, file_size, genicam, NULL)) { genicam [file_size - 1] = '\0'; if (g_str_has_suffix (tokens[2], ".zip")) { ArvZip *zip; const GSList *zip_files; arv_debug_device ("[GvDevice::load_genicam] Zipped xml data"); zip = arv_zip_new (genicam, file_size); zip_files = arv_zip_get_file_list (zip); if (zip_files != NULL) { const char *zip_filename; void *tmp_buffer; size_t tmp_buffer_size; zip_filename = arv_zip_file_get_name (zip_files->data); tmp_buffer = arv_zip_get_file (zip, zip_filename, &tmp_buffer_size); g_free (genicam); file_size = tmp_buffer_size; genicam = tmp_buffer; } else arv_warning_device ("[GvDevice::load_genicam] Invalid format"); arv_zip_free (zip); } *size = file_size; } else { g_free (genicam); genicam = NULL; *size = 0; } } } } g_strfreev (tokens); return genicam; }