1 /* Copyright (c) 2014, The Linux Foundation. All rights reserved.
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.
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.
13 #ifndef _AUDIO_CAL_UTILS_H
14 #define _AUDIO_CAL_UTILS_H
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"
30 int32_t ion_map_handle;
31 struct ion_client *ion_client;
32 struct ion_handle *ion_handle;
35 struct cal_block_data {
36 size_t client_info_size;
39 struct list_head list;
40 struct cal_data cal_data;
41 struct mem_map_data map_data;
42 int32_t buffer_number;
45 struct cal_util_callbacks {
47 (int32_t cal_type, struct cal_block_data *cal_block);
49 (int32_t cal_type, struct cal_block_data *cal_block);
51 (struct cal_block_data *cal_block, void *user_data);
54 struct cal_type_info {
55 struct audio_cal_reg reg;
56 struct cal_util_callbacks cal_util_callbacks;
59 struct cal_type_data {
60 struct cal_type_info info;
62 struct list_head cal_blocks;
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);
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);
84 void cal_utils_clear_cal_block_q6maps(int num_cal_types,
85 struct cal_type_data **cal_type);
88 /* common matching functions used to add blocks */
89 bool cal_utils_match_buf_num(struct cal_block_data *cal_block,
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);
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);
100 /* Version of the cal type*/
101 int32_t cal_utils_get_cal_type_version(void *cal_type_data);