Date: Sat, 6 Aug 2016 15:38:25 GMT From: iateaca@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r307280 - soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve Message-ID: <201608061538.u76FcPok074709@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: iateaca Date: Sat Aug 6 15:38:25 2016 New Revision: 307280 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=307280 Log: redesign the init interface if the hda codec: add 2 more parameters (play and rec) in order to transmit the codec the name of the audio devices M hda_codec.c M pci_hda.c M pci_hda.h Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c ============================================================================== --- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c Sat Aug 6 13:32:40 2016 (r307279) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c Sat Aug 6 15:38:25 2016 (r307280) @@ -155,7 +155,7 @@ * HDA Codec module function declarations */ static int -hda_codec_init(struct hda_codec_inst *hci, const char *opts); +hda_codec_init(struct hda_codec_inst *hci, const char *play, const char *rec, const char *opts); static int hda_codec_reset(struct hda_codec_inst *hci); static int @@ -200,12 +200,6 @@ [HDA_PARAM_OUTPUT_AMP_CAP] = 0x00, /* None */ \ [HDA_PARAM_GPIO_COUNT] = 0x00, \ -#define HDA_CODEC_FG_NONE_DESC \ - [HDA_CODEC_FG_NID] = { \ - [HDA_PARAM_SUB_NODE_COUNT] = 0x00000000, /* 0 Subnodes, StartNid = 0 */ \ - HDA_CODEC_FG_COMMON_DESC \ - }, \ - #define HDA_CODEC_FG_OUTPUT_DESC \ [HDA_CODEC_FG_NID] = { \ [HDA_PARAM_SUB_NODE_COUNT] = 0x00020002, /* 2 Subnodes, StartNid = 2 */ \ @@ -277,11 +271,6 @@ [HDA_PARAM_OUTPUT_AMP_CAP] = 0x00, /* None */ \ }, \ -static const uint32_t hda_codec_none_parameters[][HDA_CODEC_PARAMS_COUNT] = { - HDA_CODEC_ROOT_DESC - HDA_CODEC_FG_NONE_DESC -}; - static const uint32_t hda_codec_output_parameters[][HDA_CODEC_PARAMS_COUNT] = { HDA_CODEC_ROOT_DESC HDA_CODEC_FG_OUTPUT_DESC @@ -334,21 +323,31 @@ */ static int -hda_codec_init(struct hda_codec_inst *hci, const char *opts) +hda_codec_init(struct hda_codec_inst *hci, const char *play, const char *rec, const char *opts) { struct hda_codec_softc *sc = NULL; struct hda_codec_stream *st = NULL; int err; + if (!(play || rec)) + return -1; + DPRINTF("cad: 0x%x opts: %s\n", hci->cad, opts); sc = calloc(1, sizeof(*sc)); if (!sc) return -1; + if (play && rec) + sc->get_parameters = hda_codec_duplex_parameters; + else { + if (play) + sc->get_parameters = hda_codec_output_parameters; + else + sc->get_parameters = hda_codec_input_parameters; + } sc->subsystem_id = HDA_CODEC_SUBSYSTEM_ID; sc->no_nodes = HDA_CODEC_NODES_COUNT; - sc->get_parameters = hda_codec_duplex_parameters; sc->conn_list = hda_codec_conn_list; sc->conf_default = hda_codec_conf_default; sc->pin_ctrl_default = hda_codec_pin_ctrl_default; @@ -358,31 +357,35 @@ /* * Initialize the Audio Output stream */ - st = &sc->streams[HDA_CODEC_STREAM_OUTPUT]; - - err = hda_audio_ctxt_init(&st->actx, "hda-audio-output", hda_codec_audio_output_do_transfer, hda_codec_audio_output_do_setup, sc); - assert(!err); + if (play) { + st = &sc->streams[HDA_CODEC_STREAM_OUTPUT]; - /* TODO Get the name of the sound device from the config string */ - st->aud = audio_init("/dev/dsp0", 1); - if (!st->aud) { - DPRINTF("Fail to init the output audio player\n"); - return -1; + err = hda_audio_ctxt_init(&st->actx, "hda-audio-output", + hda_codec_audio_output_do_transfer, hda_codec_audio_output_do_setup, sc); + assert(!err); + + st->aud = audio_init(play, 1); + if (!st->aud) { + DPRINTF("Fail to init the output audio player\n"); + return -1; + } } /* * Initialize the Audio Input stream */ - st = &sc->streams[HDA_CODEC_STREAM_INPUT]; - - err = hda_audio_ctxt_init(&st->actx, "hda-audio-input", hda_codec_audio_input_do_transfer, hda_codec_audio_input_do_setup, sc); - assert(!err); + if (rec) { + st = &sc->streams[HDA_CODEC_STREAM_INPUT]; - /* TODO Get the name of the sound device from the config string */ - st->aud = audio_init("/dev/dsp1", 0); - if (!st->aud) { - DPRINTF("Fail to init the input audio player\n"); - return -1; + err = hda_audio_ctxt_init(&st->actx, "hda-audio-input", + hda_codec_audio_input_do_transfer, hda_codec_audio_input_do_setup, sc); + assert(!err); + + st->aud = audio_init(rec, 0); + if (!st->aud) { + DPRINTF("Fail to init the input audio player\n"); + return -1; + } } sc->hci = hci; Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c ============================================================================== --- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Sat Aug 6 13:32:40 2016 (r307279) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Sat Aug 6 15:38:25 2016 (r307280) @@ -432,7 +432,7 @@ return -1; } - return codec->init(hci, NULL); + return codec->init(hci, "/dev/dsp0", "/dev/dsp1", NULL); } static struct hda_codec_class * Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h ============================================================================== --- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h Sat Aug 6 13:32:40 2016 (r307279) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h Sat Aug 6 15:38:25 2016 (r307280) @@ -42,7 +42,7 @@ struct hda_codec_class { char *name; - int (*init)(struct hda_codec_inst *hci, const char *opts); + int (*init)(struct hda_codec_inst *hci, const char *play, const char *rec, const char *opts); int (*reset)(struct hda_codec_inst *hci); int (*command)(struct hda_codec_inst *hci, uint32_t cmd_data); int (*notify)(struct hda_codec_inst *hci, uint8_t run, uint8_t stream, uint8_t dir);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608061538.u76FcPok074709>