blob: 06da991e91e396485ef35a5a6e52b73181073753 [file] [log] [blame]
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -08001/*
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -07002 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -08003 * Not a contribution.
4 *
5 * Copyright (C) 2013 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#ifndef OFFLOAD_EFFECT_BUNDLE_H
21#define OFFLOAD_EFFECT_BUNDLE_H
22
23#include <tinyalsa/asoundlib.h>
Subhash Chandra Bose Naripeddy090a2aa2014-01-30 14:03:12 -080024#include <sound/audio_effects.h>
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080025#include "effect_api.h"
26
27/* Retry for delay for mixer open */
28#define RETRY_NUMBER 10
29#define RETRY_US 500000
30
31#define MIXER_CARD 0
32#define SOUND_CARD 0
33
34extern const struct effect_interface_s effect_interface;
35
36typedef struct output_context_s output_context_t;
37typedef struct effect_ops_s effect_ops_t;
38typedef struct effect_context_s effect_context_t;
39
40struct output_context_s {
41 /* node in active_outputs_list */
42 struct listnode outputs_list_node;
43 /* io handle */
44 audio_io_handle_t handle;
45 /* list of effects attached to this output */
46 struct listnode effects_list;
47 /* pcm device id */
48 int pcm_device_id;
49 struct mixer *mixer;
50 struct mixer_ctl *ctl;
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070051 struct mixer_ctl *ref_ctl;
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080052};
53
54/* effect specific operations.
55 * Only the init() and process() operations must be defined.
56 * Others are optional.
57 */
58struct effect_ops_s {
59 int (*init)(effect_context_t *context);
60 int (*release)(effect_context_t *context);
61 int (*reset)(effect_context_t *context);
62 int (*enable)(effect_context_t *context);
63 int (*start)(effect_context_t *context, output_context_t *output);
64 int (*stop)(effect_context_t *context, output_context_t *output);
65 int (*disable)(effect_context_t *context);
66 int (*process)(effect_context_t *context, audio_buffer_t *in, audio_buffer_t *out);
67 int (*set_parameter)(effect_context_t *context, effect_param_t *param, uint32_t size);
68 int (*get_parameter)(effect_context_t *context, effect_param_t *param, uint32_t *size);
69 int (*set_device)(effect_context_t *context, uint32_t device);
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070070 int (*set_hw_acc_mode)(effect_context_t *context, int32_t value);
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080071 int (*command)(effect_context_t *context, uint32_t cmdCode, uint32_t cmdSize,
72 void *pCmdData, uint32_t *replySize, void *pReplyData);
73};
74
75struct effect_context_s {
76 const struct effect_interface_s *itfe;
77 /* node in created_effects_list */
78 struct listnode effects_list_node;
79 /* node in output_context_t.effects_list */
80 struct listnode output_node;
81 effect_config_t config;
82 const effect_descriptor_t *desc;
83 /* io handle of the output the effect is attached to */
84 audio_io_handle_t out_handle;
85 uint32_t state;
86 bool offload_enabled;
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070087 bool hw_acc_enabled;
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080088 effect_ops_t ops;
89};
90
91int set_config(effect_context_t *context, effect_config_t *config);
92
wjiang50b81f42014-08-06 08:03:14 +080093bool effect_is_active(effect_context_t *context);
94
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080095#endif /* OFFLOAD_EFFECT_BUNDLE_H */