sof-client.c (5c68005083d620b1499fc81926a514d39ae8b88c) | sof-client.c (70dad53ddff0778c4920a1ee9eb1cfea539d4e91) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2// 3// Copyright(c) 2022 Intel Corporation. All rights reserved. 4// 5// Authors: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> 6// Peter Ujfalusi <peter.ujfalusi@linux.intel.com> 7// 8 9#include <linux/debugfs.h> 10#include <linux/errno.h> 11#include <linux/list.h> 12#include <linux/module.h> 13#include <linux/mutex.h> 14#include <linux/slab.h> 15#include <sound/sof/ipc4/header.h> 16#include "ops.h" 17#include "sof-client.h" 18#include "sof-priv.h" | 1// SPDX-License-Identifier: GPL-2.0-only 2// 3// Copyright(c) 2022 Intel Corporation. All rights reserved. 4// 5// Authors: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> 6// Peter Ujfalusi <peter.ujfalusi@linux.intel.com> 7// 8 9#include <linux/debugfs.h> 10#include <linux/errno.h> 11#include <linux/list.h> 12#include <linux/module.h> 13#include <linux/mutex.h> 14#include <linux/slab.h> 15#include <sound/sof/ipc4/header.h> 16#include "ops.h" 17#include "sof-client.h" 18#include "sof-priv.h" |
19#include "ipc3-priv.h" |
|
19#include "ipc4-priv.h" 20 21/** 22 * struct sof_ipc_event_entry - IPC client event description 23 * @ipc_msg_type: IPC msg type of the event the client is interested 24 * @cdev: sof_client_dev of the requesting client 25 * @callback: Callback function of the client 26 * @list: item in SOF core client event list --- 94 unchanged lines hidden (view full) --- 121static inline int sof_register_ipc_msg_injector(struct snd_sof_dev *sdev) 122{ 123 return 0; 124} 125 126static inline void sof_unregister_ipc_msg_injector(struct snd_sof_dev *sdev) {} 127#endif /* CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR */ 128 | 20#include "ipc4-priv.h" 21 22/** 23 * struct sof_ipc_event_entry - IPC client event description 24 * @ipc_msg_type: IPC msg type of the event the client is interested 25 * @cdev: sof_client_dev of the requesting client 26 * @callback: Callback function of the client 27 * @list: item in SOF core client event list --- 94 unchanged lines hidden (view full) --- 122static inline int sof_register_ipc_msg_injector(struct snd_sof_dev *sdev) 123{ 124 return 0; 125} 126 127static inline void sof_unregister_ipc_msg_injector(struct snd_sof_dev *sdev) {} 128#endif /* CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR */ 129 |
130#if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_KERNEL_INJECTOR) 131static int sof_register_ipc_kernel_injector(struct snd_sof_dev *sdev) 132{ 133 /* Only IPC3 supported right now */ 134 if (sdev->pdata->ipc_type != SOF_IPC) 135 return 0; 136 137 return sof_client_dev_register(sdev, "kernel_injector", 0, NULL, 0); 138} 139 140static void sof_unregister_ipc_kernel_injector(struct snd_sof_dev *sdev) 141{ 142 sof_client_dev_unregister(sdev, "kernel_injector", 0); 143} 144#else 145static inline int sof_register_ipc_kernel_injector(struct snd_sof_dev *sdev) 146{ 147 return 0; 148} 149 150static inline void sof_unregister_ipc_kernel_injector(struct snd_sof_dev *sdev) {} 151#endif /* CONFIG_SND_SOC_SOF_DEBUG_IPC_KERNEL_INJECTOR */ 152 |
|
129int sof_register_clients(struct snd_sof_dev *sdev) 130{ 131 int ret; 132 133 if (sdev->dspless_mode_selected) 134 return 0; 135 136 /* Register platform independent client devices */ --- 4 unchanged lines hidden (view full) --- 141 } 142 143 ret = sof_register_ipc_msg_injector(sdev); 144 if (ret) { 145 dev_err(sdev->dev, "IPC message injector client registration failed\n"); 146 goto err_msg_injector; 147 } 148 | 153int sof_register_clients(struct snd_sof_dev *sdev) 154{ 155 int ret; 156 157 if (sdev->dspless_mode_selected) 158 return 0; 159 160 /* Register platform independent client devices */ --- 4 unchanged lines hidden (view full) --- 165 } 166 167 ret = sof_register_ipc_msg_injector(sdev); 168 if (ret) { 169 dev_err(sdev->dev, "IPC message injector client registration failed\n"); 170 goto err_msg_injector; 171 } 172 |
173 ret = sof_register_ipc_kernel_injector(sdev); 174 if (ret) { 175 dev_err(sdev->dev, "IPC kernel injector client registration failed\n"); 176 goto err_kernel_injector; 177 } 178 |
|
149 /* Platform depndent client device registration */ 150 151 if (sof_ops(sdev) && sof_ops(sdev)->register_ipc_clients) 152 ret = sof_ops(sdev)->register_ipc_clients(sdev); 153 154 if (!ret) 155 return 0; 156 | 179 /* Platform depndent client device registration */ 180 181 if (sof_ops(sdev) && sof_ops(sdev)->register_ipc_clients) 182 ret = sof_ops(sdev)->register_ipc_clients(sdev); 183 184 if (!ret) 185 return 0; 186 |
187 sof_unregister_ipc_kernel_injector(sdev); 188 189err_kernel_injector: |
|
157 sof_unregister_ipc_msg_injector(sdev); 158 159err_msg_injector: 160 sof_unregister_ipc_flood_test(sdev); 161 162 return ret; 163} 164 165void sof_unregister_clients(struct snd_sof_dev *sdev) 166{ 167 if (sof_ops(sdev) && sof_ops(sdev)->unregister_ipc_clients) 168 sof_ops(sdev)->unregister_ipc_clients(sdev); 169 | 190 sof_unregister_ipc_msg_injector(sdev); 191 192err_msg_injector: 193 sof_unregister_ipc_flood_test(sdev); 194 195 return ret; 196} 197 198void sof_unregister_clients(struct snd_sof_dev *sdev) 199{ 200 if (sof_ops(sdev) && sof_ops(sdev)->unregister_ipc_clients) 201 sof_ops(sdev)->unregister_ipc_clients(sdev); 202 |
203 sof_unregister_ipc_kernel_injector(sdev); |
|
170 sof_unregister_ipc_msg_injector(sdev); 171 sof_unregister_ipc_flood_test(sdev); 172} 173 174int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id, 175 const void *data, size_t size) 176{ 177 struct auxiliary_device *auxdev; --- 86 unchanged lines hidden (view full) --- 264 return sof_ipc_tx_message(cdev->sdev->ipc, ipc_msg, msg->data_size, 265 reply_data, reply_bytes); 266 } 267 268 return -EINVAL; 269} 270EXPORT_SYMBOL_NS_GPL(sof_client_ipc_tx_message, SND_SOC_SOF_CLIENT); 271 | 204 sof_unregister_ipc_msg_injector(sdev); 205 sof_unregister_ipc_flood_test(sdev); 206} 207 208int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id, 209 const void *data, size_t size) 210{ 211 struct auxiliary_device *auxdev; --- 86 unchanged lines hidden (view full) --- 298 return sof_ipc_tx_message(cdev->sdev->ipc, ipc_msg, msg->data_size, 299 reply_data, reply_bytes); 300 } 301 302 return -EINVAL; 303} 304EXPORT_SYMBOL_NS_GPL(sof_client_ipc_tx_message, SND_SOC_SOF_CLIENT); 305 |
306int sof_client_ipc_rx_message(struct sof_client_dev *cdev, void *ipc_msg, void *msg_buf) 307{ 308 if (cdev->sdev->pdata->ipc_type == SOF_IPC) { 309 struct sof_ipc_cmd_hdr *hdr = ipc_msg; 310 311 if (hdr->size < sizeof(hdr)) { 312 dev_err(cdev->sdev->dev, "The received message size is invalid\n"); 313 return -EINVAL; 314 } 315 316 sof_ipc3_do_rx_work(cdev->sdev, ipc_msg, msg_buf); 317 return 0; 318 } 319 320 return -EOPNOTSUPP; 321} 322EXPORT_SYMBOL_NS_GPL(sof_client_ipc_rx_message, SND_SOC_SOF_CLIENT); 323 |
|
272int sof_client_ipc_set_get_data(struct sof_client_dev *cdev, void *ipc_msg, 273 bool set) 274{ 275 if (cdev->sdev->pdata->ipc_type == SOF_IPC) { 276 struct sof_ipc_cmd_hdr *hdr = ipc_msg; 277 278 return sof_ipc_set_get_data(cdev->sdev->ipc, ipc_msg, hdr->size, 279 set); --- 281 unchanged lines hidden --- | 324int sof_client_ipc_set_get_data(struct sof_client_dev *cdev, void *ipc_msg, 325 bool set) 326{ 327 if (cdev->sdev->pdata->ipc_type == SOF_IPC) { 328 struct sof_ipc_cmd_hdr *hdr = ipc_msg; 329 330 return sof_ipc_set_get_data(cdev->sdev->ipc, ipc_msg, hdr->size, 331 set); --- 281 unchanged lines hidden --- |