• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: sample data
15  * This file should be changed only infrequently and with great care.
16  */
17 
18 #include "diag.h"
19 #include "soc_diag_cmd_id.h"
20 #include "diag_adapt_layer.h"
21 #include "log_oam_pcm.h"
22 #include "diag_bt_sample_data.h"
23 #include "diag_sample_data_st.h"
24 #include "sample_data_adapt.h"
25 
diag_cmd_sample_data(uint16_t cmd_id,void * cmd_param,uint16_t cmd_param_size,diag_option_t * option)26 errcode_t diag_cmd_sample_data(uint16_t cmd_id, void *cmd_param, uint16_t cmd_param_size, diag_option_t *option)
27 {
28     uint32_t ret;
29     diag_sample_data_ind_t sample_data_ind;
30     diag_sample_data_cmd_t *sample_data_cmd = cmd_param;
31     uint32_t transmit_id = sample_data_cmd->transmit_id;
32 
33     unused(cmd_param_size);
34 
35     switch (transmit_id) {
36         case DIAG_SAMPLE_DATA_TRANSMIT_ID_SCO_IN:
37         case DIAG_SAMPLE_DATA_TRANSMIT_ID_SCO_OUT:
38         case DIAG_SAMPLE_DATA_TRANSMIT_ID_SNOOP:
39             if (sample_data_cmd->flag == 1) {
40                 ret = diag_sample_data_report_start(transmit_id);
41             } else {
42                 ret = diag_sample_data_report_stop(transmit_id);
43             }
44             break;
45         default:
46             dfx_log_err("transmit_id(0x%x) not support\r\n", transmit_id);
47             ret = ERRCODE_FAIL;
48             break;
49     }
50 
51     sample_data_ind.ret = ret;
52     sample_data_ind.flag = sample_data_cmd->flag;
53     sample_data_ind.transmit_id = sample_data_cmd->transmit_id;
54 
55     uapi_diag_report_packet(cmd_id, option, (uint8_t *)(&sample_data_ind),
56                             (uint16_t)sizeof(diag_sample_data_ind_t), true);
57 
58     return ERRCODE_SUCC;
59 }
60 
zdiag_adapt_sample_data_report(uint8_t * sdt_buf,uint16_t sdt_buf_size)61 void zdiag_adapt_sample_data_report(uint8_t *sdt_buf, uint16_t sdt_buf_size)
62 {
63     om_pcm_header_t *om_pcm = (om_pcm_header_t*)sdt_buf;
64     uint32_t prime_id = om_pcm->header.prime_id;
65     uint32_t transmit_id;
66 
67     switch (prime_id) {
68         case OM_PCM_SINK:
69             transmit_id = DIAG_SAMPLE_DATA_TRANSMIT_ID_SCO_IN;
70             break;
71         case OM_PCM_SOURCE:
72             transmit_id = DIAG_SAMPLE_DATA_TRANSMIT_ID_SCO_OUT;
73             break;
74         case OM_SNOOP_BUF:
75             transmit_id = DIAG_SAMPLE_DATA_TRANSMIT_ID_SNOOP;
76             break;
77         default:
78             dfx_log_err("sample_data prime_id(0x%x) not support\r\n", prime_id);
79             return;
80     }
81 
82     diag_sample_data_report(transmit_id, sdt_buf + sizeof(om_pcm_header_t),
83                             sdt_buf_size - sizeof(om_pcm_header_t) - sizeof(uint8_t));
84 }
85