socsvn commit: r305285 - soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve
iateaca at FreeBSD.org
iateaca at FreeBSD.org
Fri Jun 17 15:06:50 UTC 2016
Author: iateaca
Date: Fri Jun 17 15:06:49 2016
New Revision: 305285
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305285
Log:
design the hda_codec_stream data structure
add one hda_codec_stream data for the audio output converter
add specific handlers per node in order to implement the verb commands
M bhyve/hda_codec.c
Modified:
soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c
Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c
==============================================================================
--- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c Fri Jun 17 09:07:27 2016 (r305284)
+++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c Fri Jun 17 15:06:49 2016 (r305285)
@@ -12,6 +12,9 @@
#define HDA_CODEC_AUDIO_OUTPUT_NID 0x02
#define HDA_CODEC_PIN_OUTPUT_NID 0x03
+#define HDA_CODEC_STREAMS_COUNT 0x01
+#define HDA_CODEC_STREAM_OUTPUT 0x00
+
#define HDA_CODEC_PARAMS_COUNT 0x14
#define HDA_CODEC_CONN_LIST_COUNT 0x01
#define HDA_CODEC_RESPONSE_EX_UNSOL 0x10
@@ -46,6 +49,15 @@
* HDA Codec data structures
*/
+struct hda_codec_softc;
+
+typedef uint32_t (*verb_func_t)(struct hda_codec_softc *sc, uint16_t verb, uint16_t payload);
+
+struct hda_codec_stream {
+ uint8_t stream;
+ uint8_t channel;
+ uint16_t fmt;
+};
struct hda_codec_softc {
uint32_t subsystem_id;
@@ -54,6 +66,9 @@
const uint8_t (*conn_list)[HDA_CODEC_CONN_LIST_COUNT];
const uint32_t *conf_default;
const uint8_t *pin_ctrl_default;
+ const verb_func_t *verb_handlers;
+
+ struct hda_codec_stream streams[HDA_CODEC_STREAMS_COUNT];
};
/*
@@ -66,6 +81,8 @@
static int
hda_codec_command(struct hda_codec_inst *hci, uint32_t cmd_data);
+uint32_t hda_codec_audio_output_nid(struct hda_codec_softc *sc, uint16_t verb, uint16_t payload);
+
/*
* HDA Codec global data
*/
@@ -129,6 +146,10 @@
[HDA_CODEC_PIN_OUTPUT_NID] = HDA_CODEC_PIN_WIDGET_CTRL_OUT_ENABLE,
};
+static const verb_func_t hda_codec_verb_handlers[HDA_CODEC_NODES_COUNT] = {
+ [HDA_CODEC_AUDIO_OUTPUT_NID] = hda_codec_audio_output_nid,
+};
+
/*
* HDA Codec module function definitions
*/
@@ -150,6 +171,7 @@
sc->conn_list = hda_codec_conn_list;
sc->conf_default = hda_codec_conf_default;
sc->pin_ctrl_default = hda_codec_pin_ctrl_default;
+ sc->verb_handlers = hda_codec_verb_handlers;
DPRINTF("HDA Codec nodes: %d\n", sc->no_nodes);
hci->priv = sc;
@@ -206,6 +228,8 @@
sc = (struct hda_codec_softc *)hci->priv;
assert(sc);
+ assert(nid < sc->no_nodes);
+
if (!hops->response) {
DPRINTF("The controller ops does not implement the response function\n");
return -1;
@@ -213,35 +237,29 @@
switch (verb) {
case HDA_CMD_VERB_GET_PARAMETER:
- if (nid < sc->no_nodes)
- res = sc->get_parameters[nid][payload];
- else
- DPRINTF("GET_PARAMETER(nid: %d) not described\n", nid);
+ res = sc->get_parameters[nid][payload];
break;
case HDA_CMD_VERB_GET_CONN_LIST_ENTRY:
- assert(nid < sc->no_nodes);
res = sc->conn_list[nid][0];
break;
case HDA_CMD_VERB_GET_PIN_WIDGET_CTRL:
- assert(nid < sc->no_nodes);
res = sc->pin_ctrl_default[nid];
break;
case HDA_CMD_VERB_GET_PIN_SENSE:
res = HDA_CODEC_PIN_SENSE_PRESENCE_PLUGGED;
break;
case HDA_CMD_VERB_GET_CONFIGURATION_DEFAULT:
- assert(nid < sc->no_nodes);
res = sc->conf_default[nid];
break;
case HDA_CMD_VERB_GET_SUBSYSTEM_ID:
res = sc->subsystem_id;
break;
- case HDA_CMD_VERB_SET_AMP_GAIN_MUTE:
- /* TODO - handle this command */
- break;
default:
- /* TODO - call a specific handler per node */
- DPRINTF("Unknown VERB: 0x%x\n", verb);
+ assert(sc->verb_handlers);
+ if (sc->verb_handlers[nid])
+ res = sc->verb_handlers[nid](sc, verb, payload);
+ else
+ DPRINTF("Unknown VERB: 0x%x\n", verb);
break;
}
@@ -251,6 +269,31 @@
return hops->response(hci, res, HDA_CODEC_RESPONSE_EX_SOL);
}
+uint32_t hda_codec_audio_output_nid(struct hda_codec_softc *sc, uint16_t verb, uint16_t payload)
+{
+ struct hda_codec_stream *st = NULL;
+ uint32_t res = 0;
+
+ DPRINTF("verb: 0x%x, payload, 0x%x\n", verb, payload);
+
+ st = &sc->streams[HDA_CODEC_STREAM_OUTPUT];
+
+ switch (verb) {
+ case HDA_CMD_VERB_SET_CONV_FMT:
+ st->fmt = payload;
+ break;
+ case HDA_CMD_VERB_SET_CONV_STREAM_CHAN:
+ st->channel = payload & 0x0f;
+ st->stream = (payload >> 4) & 0x0f;
+ break;
+ default:
+ DPRINTF("Unknown VERB: 0x%x\n", verb);
+ break;
+ }
+
+ return res;
+}
+
struct hda_codec_class hda_codec = {
.name = "hda_codec",
.init = hda_codec_init,
More information about the svn-soc-all
mailing list