From owner-svn-soc-all@freebsd.org Wed Aug 10 16:15:30 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 097F2BB46AC for ; Wed, 10 Aug 2016 16:15:30 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E2730139E for ; Wed, 10 Aug 2016 16:15:29 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u7AGFTtB028783 for ; Wed, 10 Aug 2016 16:15:29 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u7AGFTII028746 for svn-soc-all@FreeBSD.org; Wed, 10 Aug 2016 16:15:29 GMT (envelope-from iateaca@FreeBSD.org) Date: Wed, 10 Aug 2016 16:15:29 GMT Message-Id: <201608101615.u7AGFTII028746@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iateaca@FreeBSD.org using -f From: iateaca@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r307409 - soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2016 16:15:30 -0000 Author: iateaca Date: Wed Aug 10 16:15:28 2016 New Revision: 307409 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=307409 Log: parse the configuration options and look after play= and rec= keys in order to get the audio device backends M pci_hda.c Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c ============================================================================== --- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Wed Aug 10 15:45:25 2016 (r307408) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Wed Aug 10 16:15:28 2016 (r307409) @@ -112,13 +112,16 @@ static inline void hda_set_field_by_offset(struct hda_softc *sc, uint32_t offset, uint32_t mask, uint32_t value); +static uint8_t +hda_parse_config(const char *opts, const char *key, char *val); static struct hda_softc *hda_init(const char *opts); static void hda_update_intr(struct hda_softc *sc); static void hda_response_interrupt(struct hda_softc *sc); static int -hda_codec_constructor(struct hda_softc *sc, struct hda_codec_class *codec); +hda_codec_constructor(struct hda_softc *sc, struct hda_codec_class *codec, + const char *play, const char *rec, const char *opts); static struct hda_codec_class * hda_find_codec_class(const char *name); @@ -311,11 +314,60 @@ return; } +static uint8_t +hda_parse_config(const char *opts, const char *key, char *val) +{ + char buf[64]; + char *s = buf; + char *tmp = NULL; + int len; + int i; + + if (!opts) + return 0; + + len = strlen(opts); + + if (len >= 64) { + DPRINTF("Opts too big\n"); + return 0; + } + + DPRINTF("opts: %s\n", opts); + + strcpy(buf, opts); + + for (i = 0; i < len; i++) + if (buf[i] == ',') { + buf[i] = 0; + tmp = buf + i + 1; + break; + } + + if (!memcmp(s, key, strlen(key))) { + strncpy(val, s + strlen(key), 64); + return 1; + } + + if (!tmp) + return 0; + + s = tmp; + if (!memcmp(s, key, strlen(key))) { + strncpy(val, s + strlen(key), 64); + return 1; + } + + return 0; +} + static struct hda_softc *hda_init(const char *opts) { struct hda_softc *sc = NULL; struct hda_codec_class *codec = NULL; - int err; + char play[64]; + char rec[64]; + int err, p, r; #if DEBUG_HDA == 1 dbg = fopen("/tmp/bhyve_hda.log", "w+"); @@ -335,8 +387,13 @@ */ codec = hda_find_codec_class("hda_codec"); if (codec) { - err = hda_codec_constructor(sc, codec); - assert(!err); + p = hda_parse_config(opts, "play=", play); + r = hda_parse_config(opts, "rec=", rec); + DPRINTF("play: %s rec: %s\n", play, rec); + if (p | r) { + err = hda_codec_constructor(sc, codec, p ? play : NULL, r ? rec : NULL, NULL); + assert(!err); + } } return sc; @@ -409,7 +466,8 @@ } static int -hda_codec_constructor(struct hda_softc *sc, struct hda_codec_class *codec) +hda_codec_constructor(struct hda_softc *sc, struct hda_codec_class *codec, + const char *play, const char *rec, const char *opts) { struct hda_codec_inst *hci = NULL; @@ -432,7 +490,7 @@ return -1; } - return codec->init(hci, "/dev/dsp0", "/dev/dsp1", NULL); + return codec->init(hci, play, rec, opts); } static struct hda_codec_class * From owner-svn-soc-all@freebsd.org Wed Aug 10 17:25:11 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B8F6EBB5E41 for ; Wed, 10 Aug 2016 17:25:11 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AC5CD107A for ; Wed, 10 Aug 2016 17:25:11 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u7AHPB2j009264 for ; Wed, 10 Aug 2016 17:25:11 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u7AHPBaZ009223 for svn-soc-all@FreeBSD.org; Wed, 10 Aug 2016 17:25:11 GMT (envelope-from iateaca@FreeBSD.org) Date: Wed, 10 Aug 2016 17:25:11 GMT Message-Id: <201608101725.u7AHPBaZ009223@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iateaca@FreeBSD.org using -f From: iateaca@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r307412 - soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2016 17:25:11 -0000 Author: iateaca Date: Wed Aug 10 17:25:10 2016 New Revision: 307412 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=307412 Log: it is not necessary to check for error on notify codec M pci_hda.c Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c ============================================================================== --- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Wed Aug 10 16:31:15 2016 (r307411) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Wed Aug 10 17:25:10 2016 (r307412) @@ -653,7 +653,6 @@ uint32_t sdctl = 0; uint8_t strm = 0; uint8_t dir = 0; - int err; int i; assert(!st->run); @@ -715,8 +714,7 @@ st->run = 1; - err = hda_notify_codecs(sc, 1, strm, dir); - assert(!err); + hda_notify_codecs(sc, 1, strm, dir); return 0; } @@ -727,14 +725,12 @@ struct hda_stream_desc *st = &sc->streams[stream_ind]; uint8_t strm = st->stream; uint8_t dir = st->dir; - int err; DPRINTF("stream: 0x%x, strm: 0x%x, dir: 0x%x\n", stream_ind, strm, dir); st->run = 0; - err = hda_notify_codecs(sc, 0, strm, dir); - assert(!err); + hda_notify_codecs(sc, 0, strm, dir); return 0; }