socsvn commit: r304147 - soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve
iateaca at FreeBSD.org
iateaca at FreeBSD.org
Sun May 29 10:56:56 UTC 2016
Author: iateaca
Date: Sun May 29 10:56:54 2016
New Revision: 304147
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=304147
Log:
design the hda operations registered to codec (signal, repsonse, xfer)
add codec reset function
implement signal_status_chande; called by codec
M bhyve/hda_codec.c
M bhyve/pci_hda.c
M bhyve/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 Sun May 29 07:39:56 2016 (r304146)
+++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c Sun May 29 10:56:54 2016 (r304147)
@@ -2,6 +2,11 @@
#include "pci_hda.h"
static int
+hda_codec_init(struct hda_codec_inst *hci, const char *opts);
+static int
+hda_codec_reset(struct hda_codec_inst *hci);
+
+static int
hda_codec_init(struct hda_codec_inst *hci, const char *opts)
{
DPRINTF("cad: 0x%x opts: %s\n", hci->cad, opts);
@@ -9,9 +14,27 @@
return 0;
}
+static int
+hda_codec_reset(struct hda_codec_inst *hci)
+{
+ struct hda_ops *hops = NULL;
+
+ assert(hci);
+
+ hops = hci->hops;
+ assert(hops);
+
+ DPRINTF("cad: 0x%x\n", hci->cad);
+
+ hops->signal(hci);
+
+ return 0;
+}
+
struct hda_codec_class hda_codec = {
.name = "hda_codec",
.init = hda_codec_init,
+ .reset = hda_codec_reset,
};
HDA_EMUL_SET(hda_codec);
Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c
==============================================================================
--- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Sun May 29 07:39:56 2016 (r304146)
+++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Sun May 29 10:56:54 2016 (r304147)
@@ -12,7 +12,7 @@
#define HDA_OSS_NO 0x04
#define HDA_ISS_NO 0x04
-#define HDA_CODEC_MAX 0x10
+#define HDA_CODEC_MAX 0x0f
#define HDA_LAST_OFFSET (0x80 + ((HDA_ISS_NO) * 0x20) + ((HDA_OSS_NO) * 0x20))
#define HDA_CORB_ENTRY_LEN 0x04
#define HDA_RIRB_ENTRY_LEN 0x08
@@ -61,7 +61,10 @@
static struct hda_codec_class *
hda_find_codec_class(const char *name);
-static void hda_reset_regs(struct hda_softc *sc);
+static void
+hda_reset(struct hda_softc *sc);
+static void
+hda_reset_regs(struct hda_softc *sc);
static uint32_t
hda_read(struct hda_softc *sc, uint32_t offset);
static int
@@ -97,6 +100,9 @@
static void
hda_set_sdctl(struct hda_softc *sc, uint32_t offset, uint32_t old);
+static int
+hda_signal_state_change(struct hda_codec_inst *hci);
+
/*
* PCI HDA function declarations
*/
@@ -151,6 +157,10 @@
[HDAC_RIRBSIZE_RIRBSIZE_MASK] = 0,
};
+static struct hda_ops hops = {
+ .signal = hda_signal_state_change,
+};
+
struct pci_devemu pci_de_hda = {
.pe_emu = "hda",
.pe_init = pci_hda_init,
@@ -246,7 +256,9 @@
return -1;
hci->hda = sc;
+ hci->hops = &hops;
hci->cad = sc->codecs_no;
+ hci->codec = codec;
sc->codecs[sc->codecs_no++] = hci;
@@ -271,7 +283,31 @@
return NULL;
}
-static void hda_reset_regs(struct hda_softc *sc)
+static void
+hda_reset(struct hda_softc *sc)
+{
+ int i;
+ struct hda_codec_inst *hci = NULL;
+ struct hda_codec_class *codec = NULL;
+
+ hda_reset_regs(sc);
+
+ /* Reset each codec */
+ for (i = 0; i < sc->codecs_no; i++) {
+ hci = sc->codecs[i];
+ assert(hci);
+
+ codec = hci->codec;
+ assert(codec);
+
+ codec->reset(hci);
+ }
+
+ return;
+}
+
+static void
+hda_reset_regs(struct hda_softc *sc)
{
DPRINTF("Reset the HDA controller registers ...\n");
@@ -445,8 +481,7 @@
uint32_t value = sc->regs[offset];
if (!(value & HDAC_GCTL_CRST)) {
- hda_reset_regs(sc);
- hda_set_reg_by_offset(sc, HDAC_STATESTS, 0x0001);
+ hda_reset(sc);
}
return;
@@ -525,6 +560,25 @@
return;
}
+static int
+hda_signal_state_change(struct hda_codec_inst *hci)
+{
+ struct hda_softc *sc = NULL;
+ uint32_t sdiwake = 0;
+
+ assert(hci);
+ assert(hci->hda);
+
+ DPRINTF("cad: 0x%x\n", hci->cad);
+
+ sc = hci->hda;
+ sdiwake = 1 << hci->cad;
+
+ hda_set_field_by_offset(sc, HDAC_STATESTS, sdiwake, sdiwake);
+
+ return 0;
+}
+
/*
* PCI HDA function definitions
*/
Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h
==============================================================================
--- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h Sun May 29 07:39:56 2016 (r304146)
+++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h Sun May 29 10:56:54 2016 (r304147)
@@ -26,9 +26,12 @@
#endif
struct hda_softc;
+struct hda_codec_class;
struct hda_codec_inst {
+ struct hda_codec_class *codec;
struct hda_softc *hda;
+ struct hda_ops *hops;
uint8_t cad;
void *priv;
};
@@ -36,6 +39,11 @@
struct hda_codec_class {
char *name;
int (*init)(struct hda_codec_inst *hci, const char *opts);
+ int (*reset)(struct hda_codec_inst *hci);
+};
+
+struct hda_ops {
+ int (*signal)(struct hda_codec_inst *hci);
};
#define HDA_EMUL_SET(x) DATA_SET(hda_codec_class_set, x);
More information about the svn-soc-all
mailing list