/* In this function, 2 means input and output */ int snd_bebob_discover(struct snd_bebob *bebob) { /* the number of plugs for input and output */ unsigned short bus_plugs[2]; unsigned short ext_plugs[2]; int type, i; int err; err = avc_generic_get_plug_info(bebob->unit, bus_plugs, ext_plugs); if (err < 0) goto end; /* * This module supports one PCR input plug and one PCR output plug * then ignores the others. */ for (i = 0; i < 2; i += 1) { if (bus_plugs[i] == 0) { err = -EIO; goto end; } err = avc_bridgeco_get_plug_type(bebob->unit, i, 0, &type); if (err < 0) goto end; else if (type != 0x00) { err = -EIO; goto end; } } /* store formations */ for (i = 0; i < 2; i += 1) { err = fill_stream_formations(bebob, i, 0); if (err < 0) goto end; } err = 0; end: return err; }
int snd_bebob_stream_discover(struct snd_bebob *bebob) { const struct snd_bebob_clock_spec *clk_spec = bebob->spec->clock; u8 plugs[AVC_PLUG_INFO_BUF_BYTES], addr[AVC_BRIDGECO_ADDR_BYTES]; enum avc_bridgeco_plug_type type; unsigned int i; int err; /* the number of plugs for isoc in/out, ext in/out */ err = avc_general_get_plug_info(bebob->unit, 0x1f, 0x07, 0x00, plugs); if (err < 0) { dev_err(&bebob->unit->device, "fail to get info for isoc/external in/out plugs: %d\n", err); goto end; } /* * This module supports at least one isoc input plug and one isoc * output plug. */ if ((plugs[0] == 0) || (plugs[1] == 0)) { err = -ENOSYS; goto end; } avc_bridgeco_fill_unit_addr(addr, AVC_BRIDGECO_PLUG_DIR_IN, AVC_BRIDGECO_PLUG_UNIT_ISOC, 0); err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); if (err < 0) { dev_err(&bebob->unit->device, "fail to get type for isoc in plug 0: %d\n", err); goto end; } else if (type != AVC_BRIDGECO_PLUG_TYPE_ISOC) { err = -ENOSYS; goto end; } err = fill_stream_formations(bebob, AVC_BRIDGECO_PLUG_DIR_IN, 0); if (err < 0) goto end; avc_bridgeco_fill_unit_addr(addr, AVC_BRIDGECO_PLUG_DIR_OUT, AVC_BRIDGECO_PLUG_UNIT_ISOC, 0); err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); if (err < 0) { dev_err(&bebob->unit->device, "fail to get type for isoc out plug 0: %d\n", err); goto end; } else if (type != AVC_BRIDGECO_PLUG_TYPE_ISOC) { err = -ENOSYS; goto end; } err = fill_stream_formations(bebob, AVC_BRIDGECO_PLUG_DIR_OUT, 0); if (err < 0) goto end; /* count external input plugs for MIDI */ bebob->midi_input_ports = 0; for (i = 0; i < plugs[2]; i++) { avc_bridgeco_fill_unit_addr(addr, AVC_BRIDGECO_PLUG_DIR_IN, AVC_BRIDGECO_PLUG_UNIT_EXT, i); err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); if (err < 0) { dev_err(&bebob->unit->device, "fail to get type for external in plug %d: %d\n", i, err); goto end; } else if (type == AVC_BRIDGECO_PLUG_TYPE_MIDI) { bebob->midi_input_ports++; } } /* count external output plugs for MIDI */ bebob->midi_output_ports = 0; for (i = 0; i < plugs[3]; i++) { avc_bridgeco_fill_unit_addr(addr, AVC_BRIDGECO_PLUG_DIR_OUT, AVC_BRIDGECO_PLUG_UNIT_EXT, i); err = avc_bridgeco_get_plug_type(bebob->unit, addr, &type); if (err < 0) { dev_err(&bebob->unit->device, "fail to get type for external out plug %d: %d\n", i, err); goto end; } else if (type == AVC_BRIDGECO_PLUG_TYPE_MIDI) { bebob->midi_output_ports++; } } /* for check source of clock later */ if (!clk_spec) err = seek_msu_sync_input_plug(bebob); end: return err; }