Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2018 20:00:56 +0000 (UTC)
From:      Justin Hibbits <jhibbits@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336931 - head/sys/dev/sound/pci/hda
Message-ID:  <201807302000.w6UK0usQ049964@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhibbits
Date: Mon Jul 30 20:00:56 2018
New Revision: 336931
URL: https://svnweb.freebsd.org/changeset/base/336931

Log:
  snd_hda: Make codec control path endian safe
  
  The CORB and RIRB buffers exist in DMA memory, but the device reads them as
  little-endian only.  Read and write as LE into the DMA memory block, to work on
  BE platforms.

Modified:
  head/sys/dev/sound/pci/hda/hdac.c

Modified: head/sys/dev/sound/pci/hda/hdac.c
==============================================================================
--- head/sys/dev/sound/pci/hda/hdac.c	Mon Jul 30 19:44:14 2018	(r336930)
+++ head/sys/dev/sound/pci/hda/hdac.c	Mon Jul 30 20:00:56 2018	(r336931)
@@ -41,6 +41,7 @@
 #include <dev/pci/pcivar.h>
 
 #include <sys/ctype.h>
+#include <sys/endian.h>
 #include <sys/taskqueue.h>
 
 #include <dev/sound/pci/hda/hdac_private.h>
@@ -900,7 +901,7 @@ hdac_rirb_flush(struct hdac_softc *sc)
 {
 	struct hdac_rirb *rirb_base, *rirb;
 	nid_t cad;
-	uint32_t resp;
+	uint32_t resp, resp_ex;
 	uint8_t rirbwp;
 	int ret;
 
@@ -916,9 +917,10 @@ hdac_rirb_flush(struct hdac_softc *sc)
 		sc->rirb_rp++;
 		sc->rirb_rp %= sc->rirb_size;
 		rirb = &rirb_base[sc->rirb_rp];
-		cad = HDAC_RIRB_RESPONSE_EX_SDATA_IN(rirb->response_ex);
-		resp = rirb->response;
-		if (rirb->response_ex & HDAC_RIRB_RESPONSE_EX_UNSOLICITED) {
+		resp = le32toh(rirb->response);
+		resp_ex = le32toh(rirb->response_ex);
+		cad = HDAC_RIRB_RESPONSE_EX_SDATA_IN(resp_ex);
+		if (resp_ex & HDAC_RIRB_RESPONSE_EX_UNSOLICITED) {
 			sc->unsolq[sc->unsolq_wp++] = resp;
 			sc->unsolq_wp %= HDAC_UNSOLQ_MAX;
 			sc->unsolq[sc->unsolq_wp++] = cad;
@@ -985,7 +987,7 @@ hdac_send_command(struct hdac_softc *sc, nid_t cad, ui
 	bus_dmamap_sync(sc->corb_dma.dma_tag,
 	    sc->corb_dma.dma_map, BUS_DMASYNC_PREWRITE);
 #endif
-	corb[sc->corb_wp] = verb;
+	corb[sc->corb_wp] = htole32(verb);
 #if 0
 	bus_dmamap_sync(sc->corb_dma.dma_tag,
 	    sc->corb_dma.dma_map, BUS_DMASYNC_POSTWRITE);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807302000.w6UK0usQ049964>