+static void create_ports_for_profile(struct userdata *u, pa_card_new_data *card_new_data, pa_card_profile *profile) {
+ pa_device_port *port;
+ enum profile *d;
+
+ d = PA_CARD_PROFILE_DATA(profile);
+
+ switch (*d) {
+ case PROFILE_A2DP:
+ pa_assert_se(port = pa_device_port_new(u->core, "a2dp-output", _("Bluetooth High Quality (A2DP)"), 0));
+ pa_assert_se(pa_hashmap_put(card_new_data->ports, port->name, port) >= 0);
+ port->is_output = 1;
+ port->is_input = 0;
+ port->priority = profile->priority * 100;
+ pa_hashmap_put(port->profiles, profile->name, profile);
+ break;
+
+ case PROFILE_A2DP_SOURCE:
+ pa_assert_se(port = pa_device_port_new(u->core, "a2dp-input", _("Bluetooth High Quality (A2DP)"), 0));
+ pa_assert_se(pa_hashmap_put(card_new_data->ports, port->name, port) >= 0);
+ port->is_output = 0;
+ port->is_input = 1;
+ port->priority = profile->priority * 100;
+ pa_hashmap_put(port->profiles, profile->name, profile);
+ break;
+
+ case PROFILE_HSP:
+ pa_assert_se(port = pa_device_port_new(u->core, "hsp-output", _("Bluetooth Telephony (HSP/HFP)"), 0));
+ pa_assert_se(pa_hashmap_put(card_new_data->ports, port->name, port) >= 0);
+ port->is_output = 1;
+ port->is_input = 0;
+ port->priority = profile->priority * 100;
+ pa_hashmap_put(port->profiles, profile->name, profile);
+
+ pa_assert_se(port = pa_device_port_new(u->core, "hsp-input", _("Bluetooth Telephony (HSP/HFP)"), 0));
+ pa_assert_se(pa_hashmap_put(card_new_data->ports, port->name, port) >= 0);
+ port->is_output = 0;
+ port->is_input = 1;
+ port->priority = profile->priority * 100;
+ pa_hashmap_put(port->profiles, profile->name, profile);
+ break;
+
+ case PROFILE_HFGW:
+ pa_assert_se(port = pa_device_port_new(u->core, "hfgw-output", _("Bluetooth Handsfree Gateway"), 0));
+ pa_assert_se(pa_hashmap_put(card_new_data->ports, port->name, port) >= 0);
+ port->is_output = 1;
+ port->is_input = 0;
+ port->priority = profile->priority * 100;
+ pa_hashmap_put(port->profiles, profile->name, profile);
+
+ pa_assert_se(port = pa_device_port_new(u->core, "hfgw-input", _("Bluetooth Handsfree Gateway"), 0));
+ pa_assert_se(pa_hashmap_put(card_new_data->ports, port->name, port) >= 0);
+ port->is_output = 0;
+ port->is_input = 1;
+ port->priority = profile->priority * 100;
+ pa_hashmap_put(port->profiles, profile->name, profile);
+ break;
+
+ default:
+ pa_assert_not_reached();
+ }
+
+}
+