+static void map_pd_inst_probes(void *key, void *value, void *user_data)
+{
+ GHashTable *probe_map;
+ GHashTable *probe_indices;
+ GSList *probe_list;
+ struct srd_decoder_inst *di;
+ GVariant *var;
+ void *probe_id;
+ void *channel_target;
+ struct sr_channel *ch;
+ GHashTableIter iter;
+ int num_channels;
+
+ probe_map = value;
+ probe_list = user_data;
+
+ di = srd_inst_find_by_id(srd_sess, key);
+ if (!di) {
+ g_critical("Protocol decoder instance \"%s\" not found.",
+ (char *)key);
+ return;
+ }
+ probe_indices = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ (GDestroyNotify)g_variant_unref);
+
+ g_hash_table_iter_init(&iter, probe_map);
+ while (g_hash_table_iter_next(&iter, &probe_id, &channel_target)) {
+ ch = find_channel(probe_list, channel_target);
+ if (!ch) {
+ g_printerr("cli: No channel with name \"%s\" found.\n",
+ (char *)channel_target);
+ continue;
+ }
+ if (!ch->enabled)
+ g_printerr("cli: Target channel \"%s\" not enabled.\n",
+ (char *)channel_target);
+
+ var = g_variant_new_int32(ch->index);
+ g_variant_ref_sink(var);
+ g_hash_table_insert(probe_indices, g_strdup(probe_id), var);
+ }
+
+ num_channels = g_slist_length(probe_list);
+ srd_inst_probe_set_all(di, probe_indices, (num_channels + 7) / 8);
+}
+
+void map_pd_probes(struct sr_dev_inst *sdi)
+{
+ if (pd_probe_maps) {
+ g_hash_table_foreach(pd_probe_maps, &map_pd_inst_probes,
+ sdi->channels);
+ g_hash_table_destroy(pd_probe_maps);
+ pd_probe_maps = NULL;
+ }
+}
+