OSDN Git Service

Revert "usb: dwc3: turn off VBUS when leaving host mode"
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / sound / audio_cal_utils.h
1 /* Copyright (c) 2014, The Linux Foundation. All rights reserved.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 and
5  * only version 2 as published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  */
13 #ifndef _AUDIO_CAL_UTILS_H
14 #define _AUDIO_CAL_UTILS_H
15
16 #include <linux/msm_ion.h>
17 #include <linux/msm_audio_ion.h>
18 #include <linux/msm_audio_calibration.h>
19 #include "audio_calibration.h"
20
21 struct cal_data {
22         size_t          size;
23         void            *kvaddr;
24         phys_addr_t     paddr;
25 };
26
27 struct mem_map_data {
28         size_t                  map_size;
29         int32_t                 q6map_handle;
30         int32_t                 ion_map_handle;
31         struct ion_client       *ion_client;
32         struct ion_handle       *ion_handle;
33 };
34
35 struct cal_block_data {
36         size_t                  client_info_size;
37         void                    *client_info;
38         void                    *cal_info;
39         struct list_head        list;
40         struct cal_data         cal_data;
41         struct mem_map_data     map_data;
42         int32_t                 buffer_number;
43 };
44
45 struct cal_util_callbacks {
46         int (*map_cal)
47                 (int32_t cal_type, struct cal_block_data *cal_block);
48         int (*unmap_cal)
49                 (int32_t cal_type, struct cal_block_data *cal_block);
50         bool (*match_block)
51                 (struct cal_block_data *cal_block, void *user_data);
52 };
53
54 struct cal_type_info {
55         struct audio_cal_reg            reg;
56         struct cal_util_callbacks       cal_util_callbacks;
57 };
58
59 struct cal_type_data {
60         struct cal_type_info            info;
61         struct mutex                    lock;
62         struct list_head                cal_blocks;
63 };
64
65
66 /* to register & degregister with cal util driver */
67 int cal_utils_create_cal_types(int num_cal_types,
68                         struct cal_type_data **cal_type,
69                         struct cal_type_info *info);
70 void cal_utils_destroy_cal_types(int num_cal_types,
71                         struct cal_type_data **cal_type);
72
73 /* common functions for callbacks */
74 int cal_utils_alloc_cal(size_t data_size, void *data,
75                         struct cal_type_data *cal_type,
76                         size_t client_info_size, void *client_info);
77 int cal_utils_dealloc_cal(size_t data_size, void *data,
78                         struct cal_type_data *cal_type);
79 int cal_utils_set_cal(size_t data_size, void *data,
80                         struct cal_type_data *cal_type,
81                         size_t client_info_size, void *client_info);
82
83 /* use for SSR */
84 void cal_utils_clear_cal_block_q6maps(int num_cal_types,
85                                         struct cal_type_data **cal_type);
86
87
88 /* common matching functions used to add blocks */
89 bool cal_utils_match_buf_num(struct cal_block_data *cal_block,
90                                         void *user_data);
91
92 /* common matching functions to find cal blocks */
93 struct cal_block_data *cal_utils_get_only_cal_block(
94                         struct cal_type_data *cal_type);
95
96 /* Size of calibration specific data */
97 size_t get_cal_info_size(int32_t cal_type);
98 size_t get_user_cal_type_size(int32_t cal_type);
99
100 /* Version of the cal type*/
101 int32_t cal_utils_get_cal_type_version(void *cal_type_data);
102 #endif