18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci// Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. 38c2ecf20Sopenharmony_ci// Copyright (c) 2018, Linaro Limited 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include "q6dsp-common.h" 68c2ecf20Sopenharmony_ci#include <linux/kernel.h> 78c2ecf20Sopenharmony_ci#include <linux/module.h> 88c2ecf20Sopenharmony_ci#include <linux/string.h> 98c2ecf20Sopenharmony_ci#include <linux/errno.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciint q6dsp_map_channels(u8 ch_map[PCM_MAX_NUM_CHANNEL], int ch) 128c2ecf20Sopenharmony_ci{ 138c2ecf20Sopenharmony_ci memset(ch_map, 0, PCM_MAX_NUM_CHANNEL); 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci switch (ch) { 168c2ecf20Sopenharmony_ci case 1: 178c2ecf20Sopenharmony_ci ch_map[0] = PCM_CHANNEL_FC; 188c2ecf20Sopenharmony_ci break; 198c2ecf20Sopenharmony_ci case 2: 208c2ecf20Sopenharmony_ci ch_map[0] = PCM_CHANNEL_FL; 218c2ecf20Sopenharmony_ci ch_map[1] = PCM_CHANNEL_FR; 228c2ecf20Sopenharmony_ci break; 238c2ecf20Sopenharmony_ci case 3: 248c2ecf20Sopenharmony_ci ch_map[0] = PCM_CHANNEL_FL; 258c2ecf20Sopenharmony_ci ch_map[1] = PCM_CHANNEL_FR; 268c2ecf20Sopenharmony_ci ch_map[2] = PCM_CHANNEL_FC; 278c2ecf20Sopenharmony_ci break; 288c2ecf20Sopenharmony_ci case 4: 298c2ecf20Sopenharmony_ci ch_map[0] = PCM_CHANNEL_FL; 308c2ecf20Sopenharmony_ci ch_map[1] = PCM_CHANNEL_FR; 318c2ecf20Sopenharmony_ci ch_map[2] = PCM_CHANNEL_LS; 328c2ecf20Sopenharmony_ci ch_map[3] = PCM_CHANNEL_RS; 338c2ecf20Sopenharmony_ci break; 348c2ecf20Sopenharmony_ci case 5: 358c2ecf20Sopenharmony_ci ch_map[0] = PCM_CHANNEL_FL; 368c2ecf20Sopenharmony_ci ch_map[1] = PCM_CHANNEL_FR; 378c2ecf20Sopenharmony_ci ch_map[2] = PCM_CHANNEL_FC; 388c2ecf20Sopenharmony_ci ch_map[3] = PCM_CHANNEL_LS; 398c2ecf20Sopenharmony_ci ch_map[4] = PCM_CHANNEL_RS; 408c2ecf20Sopenharmony_ci break; 418c2ecf20Sopenharmony_ci case 6: 428c2ecf20Sopenharmony_ci ch_map[0] = PCM_CHANNEL_FL; 438c2ecf20Sopenharmony_ci ch_map[1] = PCM_CHANNEL_FR; 448c2ecf20Sopenharmony_ci ch_map[2] = PCM_CHANNEL_LFE; 458c2ecf20Sopenharmony_ci ch_map[3] = PCM_CHANNEL_FC; 468c2ecf20Sopenharmony_ci ch_map[4] = PCM_CHANNEL_LS; 478c2ecf20Sopenharmony_ci ch_map[5] = PCM_CHANNEL_RS; 488c2ecf20Sopenharmony_ci break; 498c2ecf20Sopenharmony_ci case 8: 508c2ecf20Sopenharmony_ci ch_map[0] = PCM_CHANNEL_FL; 518c2ecf20Sopenharmony_ci ch_map[1] = PCM_CHANNEL_FR; 528c2ecf20Sopenharmony_ci ch_map[2] = PCM_CHANNEL_LFE; 538c2ecf20Sopenharmony_ci ch_map[3] = PCM_CHANNEL_FC; 548c2ecf20Sopenharmony_ci ch_map[4] = PCM_CHANNEL_LS; 558c2ecf20Sopenharmony_ci ch_map[5] = PCM_CHANNEL_RS; 568c2ecf20Sopenharmony_ci ch_map[6] = PCM_CHANNEL_LB; 578c2ecf20Sopenharmony_ci ch_map[7] = PCM_CHANNEL_RB; 588c2ecf20Sopenharmony_ci break; 598c2ecf20Sopenharmony_ci default: 608c2ecf20Sopenharmony_ci return -EINVAL; 618c2ecf20Sopenharmony_ci } 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci return 0; 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(q6dsp_map_channels); 668c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2"); 67