diff options
author | Aaron Durbin <adurbin@chromium.org> | 2016-06-28 15:00:30 -0500 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2016-06-29 23:15:29 +0200 |
commit | e9657bc8dc6dc94216fcbbc9b83c12b210c32be9 (patch) | |
tree | bfdd123492d1f2287299e0542ab80bb97e624998 /src | |
parent | 5e0a9c7436f77a4e488d77c80fba38cd00b67e67 (diff) |
soc/intel/skylake: refactor nhlt support
Utilize the new NHLT helper functions by driving the NHLT
endpoints through data descriptors.
Change-Id: I80838214d3615b83d4939ec2d96a4fd7050d5920
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/15488
Tested-by: build bot (Jenkins)
Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/soc/intel/skylake/include/soc/nhlt.h | 15 | ||||
-rw-r--r-- | src/soc/intel/skylake/nhlt/dmic.c | 81 | ||||
-rw-r--r-- | src/soc/intel/skylake/nhlt/max98357.c | 33 | ||||
-rw-r--r-- | src/soc/intel/skylake/nhlt/nau88l25.c | 74 | ||||
-rw-r--r-- | src/soc/intel/skylake/nhlt/nhlt.c | 70 | ||||
-rw-r--r-- | src/soc/intel/skylake/nhlt/ssm4567.c | 57 |
6 files changed, 136 insertions, 194 deletions
diff --git a/src/soc/intel/skylake/include/soc/nhlt.h b/src/soc/intel/skylake/include/soc/nhlt.h index 3800bb978d..008dd0d907 100644 --- a/src/soc/intel/skylake/include/soc/nhlt.h +++ b/src/soc/intel/skylake/include/soc/nhlt.h @@ -18,9 +18,14 @@ #include <nhlt.h> +#define NHLT_VID 0x8086 +#define NHLT_DID_DMIC 0xae20 +#define NHLT_DID_BT 0xae30 +#define NHLT_DID_SSP 0xae34 + /* - * Skylake NHLT device and hardware link types. These values are to be used - * with nhlt_soc_add_endpoint(). + * Skylake NHLT link types. These values are to be used for the hwlink + * fields in the functions below to specify which link a device is on. */ enum { @@ -30,12 +35,6 @@ enum { AUDIO_LINK_DMIC, }; -enum { - AUDIO_DEV_I2S, - AUDIO_DEV_DMIC, - AUDIO_DEV_BT, -}; - /* * Add a dmic array composed of the provided number of channels. The skylake * SoC currently only supports dmic arrays on the dmic signals. Either 2 diff --git a/src/soc/intel/skylake/nhlt/dmic.c b/src/soc/intel/skylake/nhlt/dmic.c index 6e14891f18..a7684bdefd 100644 --- a/src/soc/intel/skylake/nhlt/dmic.c +++ b/src/soc/intel/skylake/nhlt/dmic.c @@ -14,9 +14,8 @@ */ #include <soc/nhlt.h> -#include <string.h> -static const struct nhlt_format_config dmic_2ch_cfg[] = { +static const struct nhlt_format_config dmic_2ch_formats[] = { /* 48 KHz 16-bits per sample. */ { .num_channels = 2, @@ -37,7 +36,28 @@ static const struct nhlt_format_config dmic_2ch_cfg[] = { }, }; -static const struct nhlt_format_config dmic_4ch_cfg[] = { +static const struct nhlt_dmic_array_config dmic_2ch_mic_config = { + .tdm_config = { + .config_type = NHLT_TDM_MIC_ARRAY, + }, + .array_type = NHLT_MIC_ARRAY_2CH_SMALL, +}; + +static const struct nhlt_endp_descriptor dmic_2ch_descriptors[] = { + { + .link = NHLT_LINK_PDM, + .device = NHLT_PDM_DEV, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_DMIC, + .cfg = &dmic_2ch_mic_config, + .cfg_size = sizeof(dmic_2ch_mic_config), + .formats = dmic_2ch_formats, + .num_formats = ARRAY_SIZE(dmic_2ch_formats), + }, +}; + +static const struct nhlt_format_config dmic_4ch_formats[] = { /* 48 KHz 16-bits per sample. */ { .num_channels = 4, @@ -60,42 +80,37 @@ static const struct nhlt_format_config dmic_4ch_cfg[] = { }, }; -int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels) -{ - struct nhlt_endpoint *endp; - struct nhlt_dmic_array_config mic_config; - const struct nhlt_format_config *formats; - size_t num_formats; - - if (num_channels != 2 && num_channels != 4) - return -1; - - endp = nhlt_soc_add_endpoint(nhlt, AUDIO_LINK_DMIC, AUDIO_DEV_DMIC, - NHLT_DIR_CAPTURE); - - if (endp == NULL) - return -1; +static const struct nhlt_dmic_array_config dmic_4ch_mic_config = { + .tdm_config = { + .config_type = NHLT_TDM_MIC_ARRAY, + }, + .array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED, +}; - memset(&mic_config, 0, sizeof(mic_config)); - mic_config.tdm_config.config_type = NHLT_TDM_MIC_ARRAY; +static const struct nhlt_endp_descriptor dmic_4ch_descriptors[] = { + { + .link = NHLT_LINK_PDM, + .device = NHLT_PDM_DEV, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_DMIC, + .cfg = &dmic_4ch_mic_config, + .cfg_size = sizeof(dmic_4ch_mic_config), + .formats = dmic_4ch_formats, + .num_formats = ARRAY_SIZE(dmic_4ch_formats), + }, +}; +int nhlt_soc_add_dmic_array(struct nhlt *nhlt, int num_channels) +{ switch (num_channels) { case 2: - formats = dmic_2ch_cfg; - num_formats = ARRAY_SIZE(dmic_2ch_cfg); - mic_config.array_type = NHLT_MIC_ARRAY_2CH_SMALL; - break; + return nhlt_add_endpoints(nhlt, dmic_2ch_descriptors, + ARRAY_SIZE(dmic_2ch_descriptors)); case 4: - formats = dmic_4ch_cfg; - num_formats = ARRAY_SIZE(dmic_4ch_cfg); - mic_config.array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED; - break; + return nhlt_add_endpoints(nhlt, dmic_4ch_descriptors, + ARRAY_SIZE(dmic_4ch_descriptors)); default: return -1; } - - if (nhlt_endpoint_append_config(endp, &mic_config, sizeof(mic_config))) - return -1; - - return nhlt_endpoint_add_formats(endp, formats, num_formats); } diff --git a/src/soc/intel/skylake/nhlt/max98357.c b/src/soc/intel/skylake/nhlt/max98357.c index fa14dd2f61..b2abc26cea 100644 --- a/src/soc/intel/skylake/nhlt/max98357.c +++ b/src/soc/intel/skylake/nhlt/max98357.c @@ -15,7 +15,7 @@ #include <soc/nhlt.h> -static const struct nhlt_format_config max98357_render_cfg[] = { +static const struct nhlt_format_config max98357_render_formats[] = { /* 48 KHz 24-bits per sample. */ { .num_channels = 2, @@ -27,22 +27,21 @@ static const struct nhlt_format_config max98357_render_cfg[] = { }, }; +static const struct nhlt_endp_descriptor max98357_descriptors[] = { + { + .link = NHLT_LINK_SSP, + .device = NHLT_SSP_DEV_I2S, + .direction = NHLT_DIR_RENDER, + .vid = NHLT_VID, + .did = NHLT_DID_SSP, + .formats = max98357_render_formats, + .num_formats = ARRAY_SIZE(max98357_render_formats), + }, +}; + int nhlt_soc_add_max98357(struct nhlt *nhlt, int hwlink) { - struct nhlt_endpoint *endp; - - /* Render Endpoint */ - endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S, - NHLT_DIR_RENDER); - - if (endp == NULL) - return -1; - - if (nhlt_endpoint_add_formats(endp, max98357_render_cfg, - ARRAY_SIZE(max98357_render_cfg))) - return -1; - - nhlt_next_instance(nhlt, NHLT_LINK_SSP); - - return 0; + /* Virtual bus id of SSP links are the hardware port ids proper. */ + return nhlt_add_ssp_endpoints(nhlt, hwlink, max98357_descriptors, + ARRAY_SIZE(max98357_descriptors)); } diff --git a/src/soc/intel/skylake/nhlt/nau88l25.c b/src/soc/intel/skylake/nhlt/nau88l25.c index 0a6dd1b53b..dd91435acb 100644 --- a/src/soc/intel/skylake/nhlt/nau88l25.c +++ b/src/soc/intel/skylake/nhlt/nau88l25.c @@ -17,7 +17,7 @@ /* The same DSP firmware settings are used for both the capture and * render endpoints. */ -static const struct nhlt_format_config nau88l25_cfg[] = { +static const struct nhlt_format_config nau88l25_formats[] = { /* 48 KHz 24-bits per sample. */ { .num_channels = 2, @@ -29,45 +29,43 @@ static const struct nhlt_format_config nau88l25_cfg[] = { }, }; -int nhlt_soc_add_nau88l25(struct nhlt *nhlt, int hwlink) -{ - struct nhlt_endpoint *endp; - /* The nau88l25 just has headphones and a mic. Both the capture and - * render endpoints occupy the same virtual slot. */ - struct nhlt_tdm_config tdm_config = { - .virtual_slot = 0, - .config_type = NHLT_TDM_BASIC, - }; - const void *fmt_cfg = nau88l25_cfg; - size_t fmt_sz = ARRAY_SIZE(nau88l25_cfg); +/* The nau88l25 just has headphones and a mic. Both the capture and render + * endpoints occupy the same virtual slot. */ +static const struct nhlt_tdm_config tdm_config = { + .virtual_slot = 0, + .config_type = NHLT_TDM_BASIC, +}; +static const struct nhlt_endp_descriptor nau88l25_descriptors[] = { /* Render Endpoint */ - endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S, - NHLT_DIR_RENDER); - - if (endp == NULL) - return -1; - - if (nhlt_endpoint_append_config(endp, &tdm_config, sizeof(tdm_config))) - return -1; - - if (nhlt_endpoint_add_formats(endp, fmt_cfg, fmt_sz)) - return -1; - + { + .link = NHLT_LINK_SSP, + .device = NHLT_SSP_DEV_I2S, + .direction = NHLT_DIR_RENDER, + .vid = NHLT_VID, + .did = NHLT_DID_SSP, + .cfg = &tdm_config, + .cfg_size = sizeof(tdm_config), + .formats = nau88l25_formats, + .num_formats = ARRAY_SIZE(nau88l25_formats), + }, /* Capture Endpoint */ - endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S, - NHLT_DIR_CAPTURE); - - if (endp == NULL) - return -1; - - if (nhlt_endpoint_append_config(endp, &tdm_config, sizeof(tdm_config))) - return -1; - - if (nhlt_endpoint_add_formats(endp, fmt_cfg, fmt_sz)) - return -1; - - nhlt_next_instance(nhlt, NHLT_LINK_SSP); + { + .link = NHLT_LINK_SSP, + .device = NHLT_SSP_DEV_I2S, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_SSP, + .cfg = &tdm_config, + .cfg_size = sizeof(tdm_config), + .formats = nau88l25_formats, + .num_formats = ARRAY_SIZE(nau88l25_formats), + }, +}; - return 0; +int nhlt_soc_add_nau88l25(struct nhlt *nhlt, int hwlink) +{ + /* Virtual bus id of SSP links are the hardware port ids proper. */ + return nhlt_add_ssp_endpoints(nhlt, hwlink, nau88l25_descriptors, + ARRAY_SIZE(nau88l25_descriptors)); } diff --git a/src/soc/intel/skylake/nhlt/nhlt.c b/src/soc/intel/skylake/nhlt/nhlt.c index 6ef906a00e..d498152406 100644 --- a/src/soc/intel/skylake/nhlt/nhlt.c +++ b/src/soc/intel/skylake/nhlt/nhlt.c @@ -14,76 +14,8 @@ */ #include <cbmem.h> +#include <nhlt.h> #include <soc/acpi.h> -#include <soc/nhlt.h> - -#define NHLT_VID 0x8086 -#define NHLT_DID_DMIC 0xae20 -#define NHLT_DID_BT 0xae30 -#define NHLT_DID_SSP 0xae34 - -struct nhlt_endpoint *nhlt_soc_add_endpoint(struct nhlt *nhlt, int soc_hwintf, - int soc_devtype, int dir) -{ - int nhlt_link_type; - int nhlt_dev_type; - uint16_t did; - struct nhlt_endpoint *endp; - - /* Check link type and device type. */ - switch (soc_hwintf) { - case AUDIO_LINK_SSP0: - case AUDIO_LINK_SSP1: - /* Only I2S devices on SSP0 and SSP1. */ - if (soc_devtype != AUDIO_DEV_I2S) - return NULL; - nhlt_link_type = NHLT_LINK_SSP; - break; - case AUDIO_LINK_SSP2: - /* Only Bluetooth devices on SSP2. */ - if (soc_devtype != AUDIO_DEV_BT) - return NULL; - nhlt_link_type = NHLT_LINK_SSP; - break; - case AUDIO_LINK_DMIC: - /* Only DMIC devices on DMIC links. */ - if (soc_devtype != AUDIO_DEV_DMIC) - return NULL; - nhlt_link_type = NHLT_LINK_PDM; - break; - default: - return NULL; - } - - switch (soc_devtype) { - case AUDIO_DEV_I2S: - nhlt_dev_type = NHLT_SSP_DEV_I2S; - did = NHLT_DID_SSP; - break; - case AUDIO_DEV_DMIC: - nhlt_dev_type = NHLT_PDM_DEV; - did = NHLT_DID_DMIC; - break; - case AUDIO_DEV_BT: - nhlt_dev_type = NHLT_SSP_DEV_BT; - did = NHLT_DID_BT; - break; - default: - return NULL; - } - - endp = nhlt_add_endpoint(nhlt, nhlt_link_type, nhlt_dev_type, dir, - NHLT_VID, did); - - if (endp == NULL) - return NULL; - - /* Virtual bus id of SSP links are the hardware port ids proper. */ - if (nhlt_link_type == NHLT_LINK_SSP) - endp->virtual_bus_id = soc_hwintf; - - return endp; -} uintptr_t nhlt_soc_serialize(struct nhlt *nhlt, uintptr_t acpi_addr) { diff --git a/src/soc/intel/skylake/nhlt/ssm4567.c b/src/soc/intel/skylake/nhlt/ssm4567.c index 55d9481852..6808bffe3a 100644 --- a/src/soc/intel/skylake/nhlt/ssm4567.c +++ b/src/soc/intel/skylake/nhlt/ssm4567.c @@ -15,7 +15,7 @@ #include <soc/nhlt.h> -static const struct nhlt_format_config ssm4567_render_cfg[] = { +static const struct nhlt_format_config ssm4567_render_formats[] = { /* 48 KHz 24-bits per sample. */ { .num_channels = 2, @@ -28,7 +28,7 @@ static const struct nhlt_format_config ssm4567_render_cfg[] = { }; /* Capture Blob used for IV feedback for Speaker Protection Algorithm */ -static const struct nhlt_format_config ssm4567_capture_cfg[] = { +static const struct nhlt_format_config ssm4567_capture_formats[] = { /* 48 KHz 32-bits per sample. */ { .num_channels = 4, @@ -39,33 +39,32 @@ static const struct nhlt_format_config ssm4567_capture_cfg[] = { }, }; -int nhlt_soc_add_ssm4567(struct nhlt *nhlt, int hwlink) -{ - struct nhlt_endpoint *endp; - +static const struct nhlt_endp_descriptor ssm4567_descriptors[] = { /* Render Endpoint */ - endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S, - NHLT_DIR_RENDER); - - if (endp == NULL) - return -1; - - if (nhlt_endpoint_add_formats(endp, ssm4567_render_cfg, - ARRAY_SIZE(ssm4567_render_cfg))) - return -1; - - /* Capture Endpoint for IV Feedback */ - endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S, - NHLT_DIR_CAPTURE); - - if (endp == NULL) - return -1; - - if (nhlt_endpoint_add_formats(endp, ssm4567_capture_cfg, - ARRAY_SIZE(ssm4567_capture_cfg))) - return -1; - - nhlt_next_instance(nhlt, NHLT_LINK_SSP); + { + .link = NHLT_LINK_SSP, + .device = NHLT_SSP_DEV_I2S, + .direction = NHLT_DIR_RENDER, + .vid = NHLT_VID, + .did = NHLT_DID_SSP, + .formats = ssm4567_render_formats, + .num_formats = ARRAY_SIZE(ssm4567_render_formats), + }, + /* Capture Endpoint */ + { + .link = NHLT_LINK_SSP, + .device = NHLT_SSP_DEV_I2S, + .direction = NHLT_DIR_CAPTURE, + .vid = NHLT_VID, + .did = NHLT_DID_SSP, + .formats = ssm4567_capture_formats, + .num_formats = ARRAY_SIZE(ssm4567_capture_formats), + }, +}; - return 0; +int nhlt_soc_add_ssm4567(struct nhlt *nhlt, int hwlink) +{ + /* Virtual bus id of SSP links are the hardware port ids proper. */ + return nhlt_add_ssp_endpoints(nhlt, hwlink, ssm4567_descriptors, + ARRAY_SIZE(ssm4567_descriptors)); } |