diff options
Diffstat (limited to 'sys/dev/sound/pci/hda')
| -rw-r--r-- | sys/dev/sound/pci/hda/hdaa.c | 77 | ||||
| -rw-r--r-- | sys/dev/sound/pci/hda/hdaa_patches.c | 9 | ||||
| -rw-r--r-- | sys/dev/sound/pci/hda/hdac.c | 27 | ||||
| -rw-r--r-- | sys/dev/sound/pci/hda/hdac.h | 4 | ||||
| -rw-r--r-- | sys/dev/sound/pci/hda/hdac_private.h | 2 | ||||
| -rw-r--r-- | sys/dev/sound/pci/hda/hdacc.c | 6 |
6 files changed, 81 insertions, 44 deletions
diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c index 1e486b01b168..7dec437de944 100644 --- a/sys/dev/sound/pci/hda/hdaa.c +++ b/sys/dev/sound/pci/hda/hdaa.c @@ -47,9 +47,9 @@ #include "mixer_if.h" -#define hdaa_lock(devinfo) snd_mtxlock((devinfo)->lock) -#define hdaa_unlock(devinfo) snd_mtxunlock((devinfo)->lock) -#define hdaa_lockassert(devinfo) snd_mtxassert((devinfo)->lock) +#define hdaa_lock(devinfo) mtx_lock((devinfo)->lock) +#define hdaa_unlock(devinfo) mtx_unlock((devinfo)->lock) +#define hdaa_lockassert(devinfo) mtx_assert((devinfo)->lock, MA_OWNED) static const struct { const char *key; @@ -532,9 +532,11 @@ static void hdaa_presence_handler(struct hdaa_widget *w) { struct hdaa_devinfo *devinfo = w->devinfo; - struct hdaa_audio_as *as; + struct hdaa_audio_as *as, *asp; + char buf[32]; uint32_t res; - int connected, old; + int connected, old, i; + bool active; if (w->enable == 0 || w->type != HDA_PARAM_AUDIO_WIDGET_CAP_TYPE_PIN_COMPLEX) @@ -552,13 +554,6 @@ hdaa_presence_handler(struct hdaa_widget *w) if (connected == old) return; w->wclass.pin.connected = connected; - HDA_BOOTVERBOSE( - if (connected || old != 2) { - device_printf(devinfo->dev, - "Pin sense: nid=%d sense=0x%08x (%sconnected)\n", - w->nid, res, !connected ? "dis" : ""); - } - ); as = &devinfo->as[w->bindas]; if (as->hpredir >= 0 && as->pins[15] == w->nid) @@ -567,6 +562,38 @@ hdaa_presence_handler(struct hdaa_widget *w) hdaa_autorecsrc_handler(as, w); if (old != 2) hdaa_channels_handler(as); + + if (connected || old != 2) { + HDA_BOOTVERBOSE( + device_printf(devinfo->dev, + "Pin sense: nid=%d sense=0x%08x (%sconnected)\n", + w->nid, res, !connected ? "dis" : ""); + ); + if (as->hpredir >= 0) + return; + for (i = 0, active = false; i < devinfo->num_devs; i++) { + if (device_get_unit(devinfo->devs[i].dev) == snd_unit) { + active = true; + break; + } + } + /* Proceed only if we are currently using this codec. */ + if (!active) + return; + for (i = 0; i < devinfo->ascnt; i++) { + asp = &devinfo->as[i]; + if (!asp->enable) + continue; + if ((connected && asp->index == as->index) || + (!connected && asp->dir == as->dir)) { + snprintf(buf, sizeof(buf), "cdev=dsp%d", + device_get_unit(asp->pdevinfo->dev)); + devctl_notify("SND", "CONN", + asp->dir == HDAA_CTL_IN ? "IN" : "OUT", buf); + break; + } + } + } } /* @@ -2054,10 +2081,10 @@ hdaa_channel_setfragments(kobj_t obj, void *data, { struct hdaa_chan *ch = data; - blksz -= blksz % lcm(HDA_DMA_ALIGNMENT, sndbuf_getalign(ch->b)); + blksz -= blksz % lcm(HDA_DMA_ALIGNMENT, ch->b->align); - if (blksz > (sndbuf_getmaxsize(ch->b) / HDA_BDL_MIN)) - blksz = sndbuf_getmaxsize(ch->b) / HDA_BDL_MIN; + if (blksz > (ch->b->maxsize / HDA_BDL_MIN)) + blksz = ch->b->maxsize / HDA_BDL_MIN; if (blksz < HDA_BLK_MIN) blksz = HDA_BLK_MIN; if (blkcnt > HDA_BDL_MAX) @@ -2065,7 +2092,7 @@ hdaa_channel_setfragments(kobj_t obj, void *data, if (blkcnt < HDA_BDL_MIN) blkcnt = HDA_BDL_MIN; - while ((blksz * blkcnt) > sndbuf_getmaxsize(ch->b)) { + while ((blksz * blkcnt) > ch->b->maxsize) { if ((blkcnt >> 1) >= HDA_BDL_MIN) blkcnt >>= 1; else if ((blksz >> 1) >= HDA_BLK_MIN) @@ -2074,14 +2101,14 @@ hdaa_channel_setfragments(kobj_t obj, void *data, break; } - if ((sndbuf_getblksz(ch->b) != blksz || - sndbuf_getblkcnt(ch->b) != blkcnt) && + if ((ch->b->blksz != blksz || + ch->b->blkcnt != blkcnt) && sndbuf_resize(ch->b, blkcnt, blksz) != 0) device_printf(ch->devinfo->dev, "%s: failed blksz=%u blkcnt=%u\n", __func__, blksz, blkcnt); - ch->blksz = sndbuf_getblksz(ch->b); - ch->blkcnt = sndbuf_getblkcnt(ch->b); + ch->blksz = ch->b->blksz; + ch->blkcnt = ch->b->blkcnt; return (0); } @@ -2142,7 +2169,7 @@ hdaa_channel_start(struct hdaa_chan *ch) ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid); HDAC_STREAM_START(device_get_parent(devinfo->dev), devinfo->dev, ch->dir == PCMDIR_PLAY ? 1 : 0, ch->sid, - sndbuf_getbufaddr(ch->b), ch->blksz, ch->blkcnt); + ch->b->buf_addr, ch->blksz, ch->blkcnt); ch->flags |= HDAA_CHN_RUNNING; return (0); } @@ -6194,15 +6221,15 @@ hdaa_configure(device_t dev) ); hdaa_patch_direct(devinfo); HDA_BOOTHVERBOSE( - device_printf(dev, "Pin sense init...\n"); - ); - hdaa_sense_init(devinfo); - HDA_BOOTHVERBOSE( device_printf(dev, "Creating PCM devices...\n"); ); hdaa_unlock(devinfo); hdaa_create_pcms(devinfo); hdaa_lock(devinfo); + HDA_BOOTHVERBOSE( + device_printf(dev, "Pin sense init...\n"); + ); + hdaa_sense_init(devinfo); HDA_BOOTVERBOSE( if (devinfo->quirks != 0) { diff --git a/sys/dev/sound/pci/hda/hdaa_patches.c b/sys/dev/sound/pci/hda/hdaa_patches.c index 8967cb49125c..d4267aae80f8 100644 --- a/sys/dev/sound/pci/hda/hdaa_patches.c +++ b/sys/dev/sound/pci/hda/hdaa_patches.c @@ -341,7 +341,8 @@ hdac_pin_patch(struct hdaa_widget *w) } else if (id == HDA_CODEC_ALC257 && (subid == LENOVO_L5AMD_SUBVENDOR || subid == LENOVO_L5INTEL_SUBVENDOR || - subid == LENOVO_IDEAPAD3_SUBVENDOR)) { + subid == LENOVO_IDEAPAD3_SUBVENDOR || + subid == LENOVO_V15_SUBVENDOR)) { switch (nid) { case 20: patch_str = "as=1 seq=0"; @@ -362,8 +363,10 @@ hdac_pin_patch(struct hdaa_widget *w) patch_str = "as=3 seq=15 color=Black loc=Left"; break; } - } else if (id == HDA_CODEC_ALC295 && - subid == FRAMEWORK_LAPTOP_0005_SUBVENDOR) { + } else if ((id == HDA_CODEC_ALC295 && + subid == FRAMEWORK_LAPTOP_0005_SUBVENDOR) || + (id == HDA_CODEC_ALC285 && + subid == FRAMEWORK_LAPTOP_000D_SUBVENDOR)) { switch (nid) { case 20: /* diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c index 900578b73de4..d1de81e7ba29 100644 --- a/sys/dev/sound/pci/hda/hdac.c +++ b/sys/dev/sound/pci/hda/hdac.c @@ -51,9 +51,9 @@ #define HDA_DRV_TEST_REV "20120126_0002" -#define hdac_lock(sc) snd_mtxlock((sc)->lock) -#define hdac_unlock(sc) snd_mtxunlock((sc)->lock) -#define hdac_lockassert(sc) snd_mtxassert((sc)->lock) +#define hdac_lock(sc) mtx_lock(&(sc)->lock) +#define hdac_unlock(sc) mtx_unlock(&(sc)->lock) +#define hdac_lockassert(sc) mtx_assert(&(sc)->lock, MA_OWNED) #define HDAC_QUIRK_64BIT (1 << 0) #define HDAC_QUIRK_DMAPOS (1 << 1) @@ -133,6 +133,7 @@ static const struct { { HDA_INTEL_PCH, "Intel Ibex Peak", 0, 0 }, { HDA_INTEL_PCH2, "Intel Ibex Peak", 0, 0 }, { HDA_INTEL_ELLK, "Intel Elkhart Lake", 0, 0 }, + { HDA_INTEL_ELLK2, "Intel Elkhart Lake", 0, 0 }, { HDA_INTEL_JLK2, "Intel Jasper Lake", 0, 0 }, { HDA_INTEL_BXTNP, "Intel Broxton-P", 0, 0 }, { HDA_INTEL_SCH, "Intel SCH", 0, 0 }, @@ -169,6 +170,7 @@ static const struct { { HDA_NVIDIA_GF119, "NVIDIA GF119", 0, 0 }, { HDA_NVIDIA_GF110_1, "NVIDIA GF110", 0, HDAC_QUIRK_MSI }, { HDA_NVIDIA_GF110_2, "NVIDIA GF110", 0, HDAC_QUIRK_MSI }, + { HDA_ATI_RAVEN, "ATI Raven", 0, 0 }, { HDA_ATI_SB450, "ATI SB450", 0, 0 }, { HDA_ATI_SB600, "ATI SB600", 0, 0 }, { HDA_ATI_RS600, "ATI RS600", 0, 0 }, @@ -1169,7 +1171,8 @@ hdac_attach(device_t dev) } } - sc->lock = snd_mtxcreate(device_get_nameunit(dev), "HDA driver mutex"); + mtx_init(&sc->lock, device_get_nameunit(dev), "HDA driver mutex", + MTX_DEF); sc->dev = dev; TASK_INIT(&sc->unsolq_task, 0, hdac_unsolq_task, sc); callout_init(&sc->poll_callout, 1); @@ -1372,7 +1375,7 @@ hdac_attach_fail: hdac_dma_free(sc, &sc->rirb_dma); hdac_dma_free(sc, &sc->corb_dma); hdac_mem_free(sc); - snd_mtxfree(sc->lock); + mtx_destroy(&sc->lock); return (ENXIO); } @@ -1773,17 +1776,17 @@ hdac_detach(device_t dev) struct hdac_softc *sc = device_get_softc(dev); int i, error; + callout_drain(&sc->poll_callout); + hdac_irq_free(sc); + taskqueue_drain(taskqueue_thread, &sc->unsolq_task); + error = bus_generic_detach(dev); if (error != 0) return (error); hdac_lock(sc); - callout_stop(&sc->poll_callout); hdac_reset(sc, false); hdac_unlock(sc); - callout_drain(&sc->poll_callout); - taskqueue_drain(taskqueue_thread, &sc->unsolq_task); - hdac_irq_free(sc); for (i = 0; i < sc->num_ss; i++) hdac_dma_free(sc, &sc->streams[i].bdl); @@ -1796,7 +1799,7 @@ hdac_detach(device_t dev) sc->chan_dmat = NULL; } hdac_mem_free(sc); - snd_mtxfree(sc->lock); + mtx_destroy(&sc->lock); return (0); } @@ -1886,7 +1889,7 @@ hdac_get_mtx(device_t dev, device_t child) { struct hdac_softc *sc = device_get_softc(dev); - return (sc->lock); + return (&sc->lock); } static uint32_t @@ -2206,4 +2209,4 @@ static driver_t hdac_driver = { sizeof(struct hdac_softc), }; -DRIVER_MODULE(snd_hda, pci, hdac_driver, NULL, NULL); +DRIVER_MODULE_ORDERED(snd_hda, pci, hdac_driver, NULL, NULL, SI_ORDER_ANY); diff --git a/sys/dev/sound/pci/hda/hdac.h b/sys/dev/sound/pci/hda/hdac.h index 223434a214b1..bc0ae651a3b6 100644 --- a/sys/dev/sound/pci/hda/hdac.h +++ b/sys/dev/sound/pci/hda/hdac.h @@ -66,6 +66,7 @@ #define HDA_INTEL_PCH HDA_MODEL_CONSTRUCT(INTEL, 0x3b56) #define HDA_INTEL_PCH2 HDA_MODEL_CONSTRUCT(INTEL, 0x3b57) #define HDA_INTEL_ELLK HDA_MODEL_CONSTRUCT(INTEL, 0x4b55) +#define HDA_INTEL_ELLK2 HDA_MODEL_CONSTRUCT(INTEL, 0x4b58) #define HDA_INTEL_JLK2 HDA_MODEL_CONSTRUCT(INTEL, 0x4dc8) #define HDA_INTEL_BXTNP HDA_MODEL_CONSTRUCT(INTEL, 0x5a98) #define HDA_INTEL_MACBOOKPRO92 HDA_MODEL_CONSTRUCT(INTEL, 0x7270) @@ -153,6 +154,7 @@ /* ATI */ #define ATI_VENDORID 0x1002 +#define HDA_ATI_RAVEN HDA_MODEL_CONSTRUCT(ATI, 0x15de) #define HDA_ATI_SB450 HDA_MODEL_CONSTRUCT(ATI, 0x437b) #define HDA_ATI_SB600 HDA_MODEL_CONSTRUCT(ATI, 0x4383) #define HDA_ATI_RS600 HDA_MODEL_CONSTRUCT(ATI, 0x793b) @@ -388,6 +390,7 @@ #define LENOVO_3000_SUBVENDOR HDA_MODEL_CONSTRUCT(LENOVO, 0x384e) #define LENOVO_IDEAPAD330_SUBVENDOR HDA_MODEL_CONSTRUCT(LENOVO, 0x3808) #define LENOVO_IDEAPAD3_SUBVENDOR HDA_MODEL_CONSTRUCT(LENOVO, 0x3881) +#define LENOVO_V15_SUBVENDOR HDA_MODEL_CONSTRUCT(LENOVO, 0x3886) #define LENOVO_ALL_SUBVENDOR HDA_MODEL_CONSTRUCT(LENOVO, 0xffff) /* Samsung */ @@ -535,6 +538,7 @@ #define FRAMEWORK_LAPTOP_0003_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x0003) #define FRAMEWORK_LAPTOP_0005_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x0005) #define FRAMEWORK_LAPTOP_0006_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x0006) +#define FRAMEWORK_LAPTOP_000D_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x000d) /* All codecs you can eat... */ #define HDA_CODEC_CONSTRUCT(vendor, id) \ diff --git a/sys/dev/sound/pci/hda/hdac_private.h b/sys/dev/sound/pci/hda/hdac_private.h index c434bface240..0c6fe41fd5de 100644 --- a/sys/dev/sound/pci/hda/hdac_private.h +++ b/sys/dev/sound/pci/hda/hdac_private.h @@ -162,7 +162,7 @@ struct hdac_stream { struct hdac_softc { device_t dev; - struct mtx *lock; + struct mtx lock; struct intr_config_hook intrhook; diff --git a/sys/dev/sound/pci/hda/hdacc.c b/sys/dev/sound/pci/hda/hdacc.c index 4198982c9c2a..b001daa549b1 100644 --- a/sys/dev/sound/pci/hda/hdacc.c +++ b/sys/dev/sound/pci/hda/hdacc.c @@ -60,9 +60,9 @@ struct hdacc_softc { struct hdacc_fg *fgs; }; -#define hdacc_lock(codec) snd_mtxlock((codec)->lock) -#define hdacc_unlock(codec) snd_mtxunlock((codec)->lock) -#define hdacc_lockassert(codec) snd_mtxassert((codec)->lock) +#define hdacc_lock(codec) mtx_lock((codec)->lock) +#define hdacc_unlock(codec) mtx_unlock((codec)->lock) +#define hdacc_lockassert(codec) mtx_assert((codec)->lock, MA_OWNED) MALLOC_DEFINE(M_HDACC, "hdacc", "HDA CODEC"); |
