|
20 | 20 | struct sof_widget_data {
|
21 | 21 | int ctrl_type;
|
22 | 22 | int ipc_cmd;
|
23 |
| - struct sof_abi_hdr *pdata; |
| 23 | + void *pdata; |
| 24 | + size_t pdata_size; |
24 | 25 | struct snd_sof_control *control;
|
25 | 26 | };
|
26 | 27 |
|
@@ -784,16 +785,26 @@ static int sof_get_control_data(struct snd_soc_component *scomp,
|
784 | 785 | }
|
785 | 786 |
|
786 | 787 | cdata = wdata[i].control->ipc_control_data;
|
787 |
| - wdata[i].pdata = cdata->data; |
788 |
| - if (!wdata[i].pdata) |
789 |
| - return -EINVAL; |
790 | 788 |
|
791 |
| - /* make sure data is valid - data can be updated at runtime */ |
792 |
| - if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES && |
793 |
| - wdata[i].pdata->magic != SOF_ABI_MAGIC) |
794 |
| - return -EINVAL; |
| 789 | + if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES) { |
| 790 | + /* make sure data is valid - data can be updated at runtime */ |
| 791 | + if (cdata->data->magic != SOF_ABI_MAGIC) |
| 792 | + return -EINVAL; |
| 793 | + |
| 794 | + wdata[i].pdata = cdata->data->data; |
| 795 | + wdata[i].pdata_size = cdata->data->size; |
| 796 | + } else { |
| 797 | + /* points to the control data union */ |
| 798 | + wdata[i].pdata = cdata->chanv; |
| 799 | + /* |
| 800 | + * wdata[i].control->size is calculated with struct_size |
| 801 | + * and includes the size of struct sof_ipc_ctrl_data |
| 802 | + */ |
| 803 | + wdata[i].pdata_size = wdata[i].control->size - |
| 804 | + sizeof(struct sof_ipc_ctrl_data); |
| 805 | + } |
795 | 806 |
|
796 |
| - *size += wdata[i].pdata->size; |
| 807 | + *size += wdata[i].pdata_size; |
797 | 808 |
|
798 | 809 | /* get data type */
|
799 | 810 | switch (cdata->cmd) {
|
@@ -876,10 +887,12 @@ static int sof_process_load(struct snd_soc_component *scomp,
|
876 | 887 | */
|
877 | 888 | if (ipc_data_size) {
|
878 | 889 | for (i = 0; i < widget->num_kcontrols; i++) {
|
879 |
| - memcpy(&process->data[offset], |
880 |
| - wdata[i].pdata->data, |
881 |
| - wdata[i].pdata->size); |
882 |
| - offset += wdata[i].pdata->size; |
| 890 | + if (!wdata[i].pdata_size) |
| 891 | + continue; |
| 892 | + |
| 893 | + memcpy(&process->data[offset], wdata[i].pdata, |
| 894 | + wdata[i].pdata_size); |
| 895 | + offset += wdata[i].pdata_size; |
883 | 896 | }
|
884 | 897 | }
|
885 | 898 |
|
|
0 commit comments