| 1 |
|
| 2 |
|
| 3 |
#include <commonlib/bsd/helpers.h> |
| 4 |
#include <soc/nhlt.h> |
| 5 |
|
| 6 |
static const struct nhlt_format_config max98927_render_formats[] = { |
| 7 |
|
| 8 |
{ |
| 9 |
.num_channels = 2, |
| 10 |
.sample_freq_khz = 48, |
| 11 |
.container_bits_per_sample = 16, |
| 12 |
.valid_bits_per_sample = 16, |
| 13 |
.speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT, |
| 14 |
.settings_file = "max98927-render-2ch-48khz-16b.bin", |
| 15 |
}, |
| 16 |
}; |
| 17 |
|
| 18 |
static const struct nhlt_format_config max98927_capture_formats[] = { |
| 19 |
|
| 20 |
{ |
| 21 |
.num_channels = 4, |
| 22 |
.sample_freq_khz = 48, |
| 23 |
.container_bits_per_sample = 32, |
| 24 |
.valid_bits_per_sample = 16, |
| 25 |
.speaker_mask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | |
| 26 |
SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT, |
| 27 |
.settings_file = "max98927-render-2ch-48khz-16b.bin", |
| 28 |
}, |
| 29 |
}; |
| 30 |
|
| 31 |
static struct nhlt_feedback_config render_config = { |
| 32 |
.tdm_config = { |
| 33 |
.virtual_slot = 0x0, |
| 34 |
.config_type = NHLT_TDM_RENDER_FEEDBACK, |
| 35 |
}, |
| 36 |
.feedback_virtual_slot = 2, |
| 37 |
.feedback_channels = 4, |
| 38 |
.feedback_valid_bits_per_sample = 16, |
| 39 |
}; |
| 40 |
|
| 41 |
static struct nhlt_feedback_config capture_config = { |
| 42 |
.tdm_config = { |
| 43 |
.virtual_slot = 0x2, |
| 44 |
.config_type = NHLT_TDM_RENDER_FEEDBACK, |
| 45 |
}, |
| 46 |
.feedback_virtual_slot = 0, |
| 47 |
.feedback_channels = 2, |
| 48 |
.feedback_valid_bits_per_sample = 16, |
| 49 |
}; |
| 50 |
|
| 51 |
|
| 52 |
static struct nhlt_endp_descriptor max98927_descriptors[] = { |
| 53 |
{ |
| 54 |
.link = NHLT_LINK_SSP, |
| 55 |
.device = NHLT_SSP_DEV_I2S, |
| 56 |
.direction = NHLT_DIR_RENDER, |
| 57 |
.vid = NHLT_VID, |
| 58 |
.did = NHLT_DID_SSP, |
| 59 |
.cfg = &render_config, |
| 60 |
.cfg_size = sizeof(render_config), |
| 61 |
.formats = max98927_render_formats, |
| 62 |
.num_formats = ARRAY_SIZE(max98927_render_formats), |
| 63 |
}, |
| 64 |
{ |
| 65 |
.link = NHLT_LINK_SSP, |
| 66 |
.device = NHLT_SSP_DEV_I2S, |
| 67 |
.direction = NHLT_DIR_CAPTURE, |
| 68 |
.vid = NHLT_VID, |
| 69 |
.did = NHLT_DID_SSP, |
| 70 |
.cfg = &capture_config, |
| 71 |
.cfg_size = sizeof(capture_config), |
| 72 |
.formats = max98927_capture_formats, |
| 73 |
.num_formats = ARRAY_SIZE(max98927_capture_formats), |
| 74 |
}, |
| 75 |
}; |
| 76 |
|
| 77 |
int nhlt_soc_add_max98927(struct nhlt *nhlt, int hwlink, int render_slot, |
| 78 |
int feedback_slot) |
| 79 |
{ |
| 80 |
render_config.tdm_config.virtual_slot = render_slot; |
| 81 |
render_config.feedback_virtual_slot = feedback_slot; |
| 82 |
capture_config.tdm_config.virtual_slot = feedback_slot; |
| 83 |
capture_config.feedback_virtual_slot = render_slot; |
| 84 |
|
| 85 |
|
| 86 |
return nhlt_add_ssp_endpoints(nhlt, hwlink, max98927_descriptors, |
| 87 |
ARRAY_SIZE(max98927_descriptors)); |
| 88 |
} |