blob: efe69eec7a63b53a7cff8eb67c2aa844e2e47d63 [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
Sharad Sangleb27354b2015-06-18 15:58:55 +053030#ifdef HW_ACCELERATED_EFFECTS
31#define EFFECT_CMD_HW_ACC 20
32#endif
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080033#define MIXER_CARD 0
34#define SOUND_CARD 0
35
36extern const struct effect_interface_s effect_interface;
37
38typedef struct output_context_s output_context_t;
39typedef struct effect_ops_s effect_ops_t;
40typedef struct effect_context_s effect_context_t;
41
42struct output_context_s {
43 /* node in active_outputs_list */
44 struct listnode outputs_list_node;
45 /* io handle */
46 audio_io_handle_t handle;
47 /* list of effects attached to this output */
48 struct listnode effects_list;
49 /* pcm device id */
50 int pcm_device_id;
51 struct mixer *mixer;
52 struct mixer_ctl *ctl;
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070053 struct mixer_ctl *ref_ctl;
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080054};
55
56/* effect specific operations.
57 * Only the init() and process() operations must be defined.
58 * Others are optional.
59 */
60struct effect_ops_s {
61 int (*init)(effect_context_t *context);
62 int (*release)(effect_context_t *context);
63 int (*reset)(effect_context_t *context);
64 int (*enable)(effect_context_t *context);
65 int (*start)(effect_context_t *context, output_context_t *output);
66 int (*stop)(effect_context_t *context, output_context_t *output);
67 int (*disable)(effect_context_t *context);
68 int (*process)(effect_context_t *context, audio_buffer_t *in, audio_buffer_t *out);
69 int (*set_parameter)(effect_context_t *context, effect_param_t *param, uint32_t size);
70 int (*get_parameter)(effect_context_t *context, effect_param_t *param, uint32_t *size);
71 int (*set_device)(effect_context_t *context, uint32_t device);
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070072 int (*set_hw_acc_mode)(effect_context_t *context, int32_t value);
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080073 int (*command)(effect_context_t *context, uint32_t cmdCode, uint32_t cmdSize,
74 void *pCmdData, uint32_t *replySize, void *pReplyData);
75};
76
77struct effect_context_s {
78 const struct effect_interface_s *itfe;
79 /* node in created_effects_list */
80 struct listnode effects_list_node;
81 /* node in output_context_t.effects_list */
82 struct listnode output_node;
83 effect_config_t config;
84 const effect_descriptor_t *desc;
85 /* io handle of the output the effect is attached to */
86 audio_io_handle_t out_handle;
87 uint32_t state;
88 bool offload_enabled;
Subhash Chandra Bose Naripeddye40a7cd2014-06-03 19:42:41 -070089 bool hw_acc_enabled;
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080090 effect_ops_t ops;
91};
92
93int set_config(effect_context_t *context, effect_config_t *config);
94
wjiang50b81f42014-08-06 08:03:14 +080095bool effect_is_active(effect_context_t *context);
96
Subhash Chandra Bose Naripeddy3eedc002013-11-12 20:45:15 -080097#endif /* OFFLOAD_EFFECT_BUNDLE_H */