aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap/abe/abe_main.c
blob: ba123fecbba03b87a0802029b38108d6cd6a6638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
/*

  This file is provided under a dual BSD/GPLv2 license.  When using or
  redistributing this file, you may do so under either license.

  GPL LICENSE SUMMARY

  Copyright(c) 2010-2011 Texas Instruments Incorporated,
  All rights reserved.

  This program is free software; you can redistribute it and/or modify
  it under the terms of version 2 of the GNU General Public License as
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  The full GNU General Public License is included in this distribution
  in the file called LICENSE.GPL.

  BSD LICENSE

  Copyright(c) 2010-2011 Texas Instruments Incorporated,
  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in
      the documentation and/or other materials provided with the
      distribution.
    * Neither the name of Texas Instruments Incorporated nor the names of
      its contributors may be used to endorse or promote products derived
      from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/slab.h>

#include "abe_legacy.h"
#include "abe_dbg.h"
#include "abe_port.h"


struct omap_abe_equ {
	/* type of filter */
	u32 equ_type;
	/* filter length */
	u32 equ_length;
	union {
		/* parameters are the direct and recursive coefficients in */
		/* Q6.26 integer fixed-point format. */
		s32 type1[NBEQ1];
		struct {
			/* center frequency of the band [Hz] */
			s32 freq[NBEQ2];
			/* gain of each band. [dB] */
			s32 gain[NBEQ2];
			/* Q factor of this band [dB] */
			s32 q[NBEQ2];
		} type2;
	} coef;
	s32 equ_param3;
};

#include "abe_gain.h"
#include "abe_aess.h"
#include "abe_seq.h"


int omap_abe_connect_debug_trace(struct omap_abe *abe,
				 struct omap_abe_dma *dma2);

int omap_abe_reset_hal(struct omap_abe *abe);
int omap_abe_load_fw(struct omap_abe *abe, u32 *firmware);
int omap_abe_reload_fw(struct omap_abe *abe, u32 *firmware);
u32* omap_abe_get_default_fw(struct omap_abe *abe);
int omap_abe_wakeup(struct omap_abe *abe);
int omap_abe_irq_processing(struct omap_abe *abe);
int omap_abe_clear_irq(struct omap_abe *abe);
int omap_abe_disable_irq(struct omap_abe *abe);
int omap_abe_set_debug_trace(struct omap_abe_dbg *dbg, int debug);
int omap_abe_set_ping_pong_buffer(struct omap_abe *abe,
						u32 port, u32 n_bytes);
int omap_abe_read_next_ping_pong_buffer(struct omap_abe *abe,
						u32 port, u32 *p, u32 *n);
int omap_abe_init_ping_pong_buffer(struct omap_abe *abe,
					u32 id, u32 size_bytes, u32 n_buffers,
					u32 *p);
int omap_abe_read_offset_from_ping_buffer(struct omap_abe *abe,
						u32 id, u32 *n);
int omap_abe_set_router_configuration(struct omap_abe *abe,
					u32 id, u32 k, u32 *param);
int omap_abe_set_opp_processing(struct omap_abe *abe, u32 opp);
int omap_abe_disable_data_transfer(struct omap_abe *abe, u32 id);
int omap_abe_enable_data_transfer(struct omap_abe *abe, u32 id);
int omap_abe_connect_cbpr_dmareq_port(struct omap_abe *abe,
						u32 id, abe_data_format_t *f,
						u32 d,
						abe_dma_t *returned_dma_t);
int omap_abe_connect_irq_ping_pong_port(struct omap_abe *abe,
					     u32 id, abe_data_format_t *f,
					     u32 subroutine_id, u32 size,
					     u32 *sink, u32 dsp_mcu_flag);
int omap_abe_connect_serial_port(struct omap_abe *abe,
				 u32 id, abe_data_format_t *f,
				 u32 mcbsp_id);
int omap_abe_read_port_address(struct omap_abe *abe,
			       u32 port, abe_dma_t *dma2);
int omap_abe_check_activity(struct omap_abe *abe);

int omap_abe_use_compensated_gain(struct omap_abe *abe, int on_off);
int omap_abe_write_equalizer(struct omap_abe *abe,
			     u32 id, struct omap_abe_equ *param);

int omap_abe_disable_gain(struct omap_abe *abe, u32 id, u32 p);
int omap_abe_enable_gain(struct omap_abe *abe, u32 id, u32 p);
int omap_abe_mute_gain(struct omap_abe *abe, u32 id, u32 p);
int omap_abe_unmute_gain(struct omap_abe *abe, u32 id, u32 p);

int omap_abe_write_gain(struct omap_abe *abe,
			u32 id, s32 f_g, u32 ramp, u32 p);
int omap_abe_write_mixer(struct omap_abe *abe,
			 u32 id, s32 f_g, u32 f_ramp, u32 p);
int omap_abe_read_gain(struct omap_abe *abe,
		       u32 id, u32 *f_g, u32 p);
int omap_abe_read_mixer(struct omap_abe *abe,
			u32 id, u32 *f_g, u32 p);
int omap_abe_mono_mixer(struct omap_abe *abe, u32 id, u32 on_off);

extern struct omap_abe *abe;

#if 0
/**
 * abe_init_mem - Allocate Kernel space memory map for ABE
 *
 * Memory map of ABE memory space for PMEM/DMEM/SMEM/DMEM
 */
void abe_init_mem(void __iomem *_io_base)
{
	omap_abe_init_mem(abe, _io_base);
}
EXPORT_SYMBOL(abe_init_mem);

struct omap_abe* abe_probe_aess(void)
{
	return omap_abe_probe_aess(abe);
}
EXPORT_SYMBOL(abe_probe_aess);

void abe_remove_aess(void)
{
	omap_abe_remove_aess(abe);
}
EXPORT_SYMBOL(abe_remove_aess);

void abe_add_subroutine(u32 *id, abe_subroutine2 f,
						u32 nparam, u32 *params)
{
	omap_abe_add_subroutine(abe, id, f, nparam, params);
}
EXPORT_SYMBOL(abe_add_subroutine);

#endif

/**
 * abe_reset_hal - reset the ABE/HAL
 * @rdev: regulator source
 * @constraints: constraints to apply
 *
 * Operations : reset the HAL by reloading the static variables and
 * default AESS registers.
 * Called after a PRCM cold-start reset of ABE
 */
u32 abe_reset_hal(void)
{
	omap_abe_reset_hal(abe);
	return 0;
}
EXPORT_SYMBOL(abe_reset_hal);

/**
 * abe_load_fw - Load ABE Firmware and initialize memories
 *
 */
u32 abe_load_fw(u32 *firmware)
{
	omap_abe_load_fw(abe, firmware);
	return 0;
}
EXPORT_SYMBOL(abe_load_fw);

/**
 * abe_reload_fw - Reload ABE Firmware and initialize memories
 *
 */
u32 abe_reload_fw(u32 *firmware)
{
	omap_abe_reload_fw(abe, firmware);
	return 0;
}
EXPORT_SYMBOL(abe_reload_fw);

u32* abe_get_default_fw(void)
{
	return omap_abe_get_default_fw(abe);
}
EXPORT_SYMBOL(abe_get_default_fw);

/**
 * abe_wakeup - Wakeup ABE
 *
 * Wakeup ABE in case of retention
 */
u32 abe_wakeup(void)
{
	omap_abe_wakeup(abe);
	return 0;
}
EXPORT_SYMBOL(abe_wakeup);

/**
 * abe_irq_processing - Process ABE interrupt
 *
 * This subroutine is call upon reception of "MA_IRQ_99 ABE_MPU_IRQ" Audio
 * back-end interrupt. This subroutine will check the ATC Hrdware, the
 * IRQ_FIFO from the AE and act accordingly. Some IRQ source are originated
 * for the delivery of "end of time sequenced tasks" notifications, some are
 * originated from the Ping-Pong protocols, some are generated from
 * the embedded debugger when the firmware stops on programmable break-points,
 * etc ...
 */
u32 abe_irq_processing(void)
{
	omap_abe_irq_processing(abe);
	return 0;
}
EXPORT_SYMBOL(abe_irq_processing);

/**
 * abe_clear_irq - clear ABE interrupt
 *
 * This subroutine is call to clear MCU Irq
 */
u32 abe_clear_irq(void)
{
	omap_abe_clear_irq(abe);
	return 0;
}
EXPORT_SYMBOL(abe_clear_irq);

/**
 * abe_disable_irq - disable MCU/DSP ABE interrupt
 *
 * This subroutine is disabling ABE MCU/DSP Irq
 */
u32 abe_disable_irq(void)
{
	omap_abe_disable_irq(abe);

	return 0;
}
EXPORT_SYMBOL(abe_disable_irq);

/**
 * abe_write_event_generator - Selects event generator source
 * @e: Event Generation Counter, McPDM, DMIC or default.
 *
 * Loads the AESS event generator hardware source.
 * Loads the firmware parameters accordingly.
 * Indicates to the FW which data stream is the most important to preserve
 * in case all the streams are asynchronous.
 * If the parameter is "default", then HAL decides which Event source
 * is the best appropriate based on the opened ports.
 *
 * When neither the DMIC and the McPDM are activated, the AE will have
 * its EVENT generator programmed with the EVENT_COUNTER.
 * The event counter will be tuned in order to deliver a pulse frequency higher
 * than 96 kHz.
 * The DPLL output at 100% OPP is MCLK = (32768kHz x6000) = 196.608kHz
 * The ratio is (MCLK/96000)+(1<<1) = 2050
 * (1<<1) in order to have the same speed at 50% and 100% OPP
 * (only 15 MSB bits are used at OPP50%)
 */
u32 abe_write_event_generator(u32 e) // should integarte abe as parameter
{
	omap_abe_write_event_generator(abe, e);
	return 0;
}
EXPORT_SYMBOL(abe_write_event_generator);

/**
 * abe_start_event_generator - Starts event generator source
 *
 * Start the event genrator of AESS. No more event will be send to AESS engine.
 * Upper layer must wait 1/96kHz to be sure that engine reaches
 * the IDLE instruction.
 */
u32 abe_stop_event_generator(void)
{
	omap_abe_stop_event_generator(abe);
	return 0;
}
EXPORT_SYMBOL(abe_stop_event_generator);

/**
 * abe_connect_debug_trace
 * @dma2:pointer to the DMEM trace buffer
 *
 * returns the address and size of the real-time debug trace buffer,
 * the content of which will vary from one firmware release to another
 */
u32 abe_connect_debug_trace(abe_dma_t *dma2)
{
	omap_abe_connect_debug_trace(abe, (struct omap_abe_dma *)dma2);
	return 0;
}
EXPORT_SYMBOL(abe_connect_debug_trace);

/**
 * abe_set_debug_trace
 * @debug: debug ID from a list to be defined
 *
 * loads a mask which filters the debug trace to dedicated types of data
 */
u32 abe_set_debug_trace(abe_dbg_t debug)
{
	omap_abe_set_debug_trace(&abe->dbg, (int)(debug));
	return 0;
}
EXPORT_SYMBOL(abe_set_debug_trace);

/**
 * abe_set_ping_pong_buffer
 * @port: ABE port ID
 * @n_bytes: Size of Ping/Pong buffer
 *
 * Updates the next ping-pong buffer with "size" bytes copied from the
 * host processor. This API notifies the FW that the data transfer is done.
 */
u32 abe_set_ping_pong_buffer(u32 port, u32 n_bytes)
{
	omap_abe_set_ping_pong_buffer(abe, port, n_bytes);
	return 0;
}
EXPORT_SYMBOL(abe_set_ping_pong_buffer);

/**
 * abe_read_next_ping_pong_buffer
 * @port: ABE portID
 * @p: Next buffer address (pointer)
 * @n: Next buffer size (pointer)
 *
 * Tell the next base address of the next ping_pong Buffer and its size
 */
u32 abe_read_next_ping_pong_buffer(u32 port, u32 *p, u32 *n)
{
	omap_abe_read_next_ping_pong_buffer(abe, port, p, n);
	return 0;
}
EXPORT_SYMBOL(abe_read_next_ping_pong_buffer);

/**
 * abe_init_ping_pong_buffer
 * @id: ABE port ID
 * @size_bytes:size of the ping pong
 * @n_buffers:number of buffers (2 = ping/pong)
 * @p:returned address of the ping-pong list of base addresses
 *	(byte offset from DMEM start)
 *
 * Computes the base address of the ping_pong buffers
 */
u32 abe_init_ping_pong_buffer(u32 id, u32 size_bytes, u32 n_buffers,
					u32 *p)
{
	omap_abe_init_ping_pong_buffer(abe, id, size_bytes, n_buffers, p);
	return 0;
}
EXPORT_SYMBOL(abe_init_ping_pong_buffer);

/**
 * abe_read_offset_from_ping_buffer
 * @id: ABE port ID
 * @n:  returned address of the offset
 *	from the ping buffer start address (in samples)
 *
 * Computes the current firmware ping pong read pointer location,
 * expressed in samples, as the offset from the start address of ping buffer.
 */
u32 abe_read_offset_from_ping_buffer(u32 id, u32 *n)
{
	omap_abe_read_offset_from_ping_buffer(abe, id, n);
	return 0;
}
EXPORT_SYMBOL(abe_read_offset_from_ping_buffer);

/**
 * abe_write_equalizer
 * @id: name of the equalizer
 * @param : equalizer coefficients
 *
 * Load the coefficients in CMEM.
 */
u32 abe_write_equalizer(u32 id, abe_equ_t *param)
{
	omap_abe_write_equalizer(abe, id, (struct omap_abe_equ *)param);
	return 0;
}
EXPORT_SYMBOL(abe_write_equalizer);
/**
 * abe_disable_gain
 * Parameters:
 *	mixer id
 *	sub-port id
 *
 */
u32 abe_disable_gain(u32 id, u32 p)
{
	omap_abe_disable_gain(abe, id, p);
	return 0;
}
EXPORT_SYMBOL(abe_disable_gain);
/**
 * abe_enable_gain
 * Parameters:
 *	mixer id
 *	sub-port id
 *
 */
u32 abe_enable_gain(u32 id, u32 p)
{
	omap_abe_enable_gain(abe, id, p);
	return 0;
}
EXPORT_SYMBOL(abe_enable_gain);

/**
 * abe_mute_gain
 * Parameters:
 *	mixer id
 *	sub-port id
 *
 */
u32 abe_mute_gain(u32 id, u32 p)
{
	omap_abe_mute_gain(abe, id, p);
	return 0;
}
EXPORT_SYMBOL(abe_mute_gain);

/**
 * abe_unmute_gain
 * Parameters:
 *	mixer id
 *	sub-port id
 *
 */
u32 abe_unmute_gain(u32 id, u32 p)
{
	omap_abe_unmute_gain(abe, id, p);
	return 0;
}
EXPORT_SYMBOL(abe_unmute_gain);

/**
 * abe_write_gain
 * @id: gain name or mixer name
 * @f_g: list of input gains of the mixer
 * @ramp: gain ramp speed factor
 * @p: list of ports corresponding to the above gains
 *
 * Loads the gain coefficients to FW memory. This API can be called when
 * the corresponding MIXER is not activated. After reloading the firmware
 * the default coefficients corresponds to "all input and output mixer's gain
 * in mute state". A mixer is disabled with a network reconfiguration
 * corresponding to an OPP value.
 */
u32 abe_write_gain(u32 id, s32 f_g, u32 ramp, u32 p)
{
	omap_abe_write_gain(abe, id, f_g, ramp, p);
	return 0;
}
EXPORT_SYMBOL(abe_write_gain);

/**
 * abe_write_mixer
 * @id: name of the mixer
 * @param: input gains and delay ramp of the mixer
 * @p: port corresponding to the above gains
 *
 * Load the gain coefficients in FW memory. This API can be called when
 * the corresponding MIXER is not activated. After reloading the firmware
 * the default coefficients corresponds to "all input and output mixer's
 * gain in mute state". A mixer is disabled with a network reconfiguration
 * corresponding to an OPP value.
 */
u32 abe_write_mixer(u32 id, s32 f_g, u32 f_ramp, u32 p)
{
	omap_abe_write_gain(abe, id, f_g, f_ramp, p);
	return 0;
}
EXPORT_SYMBOL(abe_write_mixer);

/**
 * abe_read_gain
 * @id: name of the mixer
 * @param: list of input gains of the mixer
 * @p: list of port corresponding to the above gains
 *
 */
u32 abe_read_gain(u32 id, u32 *f_g, u32 p)
{
	omap_abe_read_gain(abe, id, f_g, p);
	return 0;
}
EXPORT_SYMBOL(abe_read_gain);

/**
 * abe_read_mixer
 * @id: name of the mixer
 * @param: gains of the mixer
 * @p: port corresponding to the above gains
 *
 * Load the gain coefficients in FW memory. This API can be called when
 * the corresponding MIXER is not activated. After reloading the firmware
 * the default coefficients corresponds to "all input and output mixer's
 * gain in mute state". A mixer is disabled with a network reconfiguration
 * corresponding to an OPP value.
 */
u32 abe_read_mixer(u32 id, u32 *f_g, u32 p)
{
	omap_abe_read_gain(abe, id, f_g, p);
	return 0;
}
EXPORT_SYMBOL(abe_read_mixer);

/**
 * abe_set_router_configuration
 * @Id: name of the router
 * @Conf: id of the configuration
 * @param: list of output index of the route
 *
 * The uplink router takes its input from DMIC (6 samples), AMIC (2 samples)
 * and PORT1/2 (2 stereo ports). Each sample will be individually stored in
 * an intermediate table of 10 elements.
 *
 * Example of router table parameter for voice uplink with phoenix microphones
 *
 * indexes 0 .. 9 = MM_UL description (digital MICs and MMEXTIN)
 *	DMIC1_L_labelID, DMIC1_R_labelID, DMIC2_L_labelID, DMIC2_R_labelID,
 *	MM_EXT_IN_L_labelID, MM_EXT_IN_R_labelID, ZERO_labelID, ZERO_labelID,
 *	ZERO_labelID, ZERO_labelID,
 * indexes 10 .. 11 = MM_UL2 description (recording on DMIC3)
 *	DMIC3_L_labelID, DMIC3_R_labelID,
 * indexes 12 .. 13 = VX_UL description (VXUL based on PDMUL data)
 *	AMIC_L_labelID, AMIC_R_labelID,
 * indexes 14 .. 15 = RESERVED (NULL)
 *	ZERO_labelID, ZERO_labelID,
 */
u32 abe_set_router_configuration(u32 id, u32 k, u32 *param)
{
	omap_abe_set_router_configuration(abe, id, k, param);
	return 0;
}
EXPORT_SYMBOL(abe_set_router_configuration);

/**
 * abe_set_opp_processing - Set OPP mode for ABE Firmware
 * @opp: OOPP mode
 *
 * New processing network and OPP:
 * 0: Ultra Lowest power consumption audio player (no post-processing, no mixer)
 * 1: OPP 25% (simple multimedia features, including low-power player)
 * 2: OPP 50% (multimedia and voice calls)
 * 3: OPP100% ( multimedia complex use-cases)
 *
 * Rearranges the FW task network to the corresponding OPP list of features.
 * The corresponding AE ports are supposed to be set/reset accordingly before
 * this switch.
 *
 */
u32 abe_set_opp_processing(u32 opp)
{
	omap_abe_set_opp_processing(abe, opp);
	return 0;
}
EXPORT_SYMBOL(abe_set_opp_processing);

/**
 * abe_disable_data_transfer
 * @id: ABE port id
 *
 * disables the ATC descriptor and stop IO/port activities
 * disable the IO task (@f = 0)
 * clear ATC DMEM buffer, ATC enabled
 */
u32 abe_disable_data_transfer(u32 id)
{
	omap_abe_disable_data_transfer(abe, id);
	return 0;
}
EXPORT_SYMBOL(abe_disable_data_transfer);

/**
 * abe_enable_data_transfer
 * @ip: ABE port id
 *
 * enables the ATC descriptor
 * reset ATC pointers
 * enable the IO task (@f <> 0)
 */
u32 abe_enable_data_transfer(u32 id)
{
	omap_abe_enable_data_transfer(abe, id);
	return 0;
}
EXPORT_SYMBOL(abe_enable_data_transfer);

/**
 * abe_connect_cbpr_dmareq_port
 * @id: port name
 * @f: desired data format
 * @d: desired dma_request line (0..7)
 * @a: returned pointer to the base address of the CBPr register and number of
 *	samples to exchange during a DMA_request.
 *
 * enables the data echange between a DMA and the ABE through the
 *	CBPr registers of AESS.
 */
u32 abe_connect_cbpr_dmareq_port(u32 id, abe_data_format_t *f, u32 d,
					   abe_dma_t *returned_dma_t)
{
	omap_abe_connect_cbpr_dmareq_port(abe, id, f, d, returned_dma_t);
	return 0;
}
EXPORT_SYMBOL(abe_connect_cbpr_dmareq_port);

/**
 * abe_connect_irq_ping_pong_port
 * @id: port name
 * @f: desired data format
 * @I: index of the call-back subroutine to call
 * @s: half-buffer (ping) size
 * @p: returned base address of the first (ping) buffer)
 *
 * enables the data echanges between a direct access to the DMEM
 * memory of ABE using cache flush. On each IRQ activation a subroutine
 * registered with "abe_plug_subroutine" will be called. This subroutine
 * will generate an amount of samples, send them to DMEM memory and call
 * "abe_set_ping_pong_buffer" to notify the new amount of samples in the
 * pong buffer.
 */
u32 abe_connect_irq_ping_pong_port(u32 id, abe_data_format_t *f,
					     u32 subroutine_id, u32 size,
					     u32 *sink, u32 dsp_mcu_flag)
{
	omap_abe_connect_irq_ping_pong_port(abe, id, f, subroutine_id, size,
					     sink, dsp_mcu_flag);
	return 0;
}
EXPORT_SYMBOL(abe_connect_irq_ping_pong_port);

/**
 * abe_connect_serial_port()
 * @id: port name
 * @f: data format
 * @i: peripheral ID (McBSP #1, #2, #3)
 *
 * Operations : enables the data echanges between a McBSP and an ATC buffer in
 * DMEM. This API is used connect 48kHz McBSP streams to MM_DL and 8/16kHz
 * voice streams to VX_UL, VX_DL, BT_VX_UL, BT_VX_DL. It abstracts the
 * abe_write_port API.
 */
u32 abe_connect_serial_port(u32 id, abe_data_format_t *f,
				      u32 mcbsp_id)
{
	omap_abe_connect_serial_port(abe, id, f, mcbsp_id);
	return 0;
}
EXPORT_SYMBOL(abe_connect_serial_port);

/**
 * abe_read_port_address
 * @dma: output pointer to the DMA iteration and data destination pointer
 *
 * This API returns the address of the DMA register used on this audio port.
 * Depending on the protocol being used, adds the base address offset L3
 * (DMA) or MPU (ARM)
 */
u32 abe_read_port_address(u32 port, abe_dma_t *dma2)
{
	omap_abe_read_port_address(abe, port, dma2);
	return 0;
}
EXPORT_SYMBOL(abe_read_port_address);

/**
 * abe_check_activity - Check if some ABE activity.
 *
 * Check if any ABE ports are running.
 * return 1: still activity on ABE
 * return 0: no more activity on ABE. Event generator can be stopped
 *
 */
u32 abe_check_activity(void)
{
	return (u32)omap_abe_check_activity(abe);
}
EXPORT_SYMBOL(abe_check_activity);
/**
 * abe_use_compensated_gain
 * @on_off:
 *
 * Selects the automatic Mixer's gain management
 * on_off = 1 allows the "abe_write_gain" to adjust the overall
 * gains of the mixer to be tuned not to create saturation
 */
abehal_status abe_use_compensated_gain(u32 on_off)
{
	omap_abe_use_compensated_gain(abe, (int)(on_off));
	return 0;
}

/**
 * abe_mono_mixer
 * @id: name of the mixer (MIXDL1, MIXDL2, MIXAUDUL)
 * on_off: enable\disable flag
 *
 * This API Programs DL1Mixer or DL2Mixer to output mono data
 * on both left and right data paths.
 */
int abe_mono_mixer(u32 id, u32 on_off)
{
	return omap_abe_mono_mixer(abe, id, on_off);
}
EXPORT_SYMBOL(abe_mono_mixer);

/**
 * abe_write_select_pdm_output - Select the path for OPP25 route input
 *
 * Parameters:
 *   path: 1 for output om headset, 2 for output on handsfree,
 *	 3 for output on headset and handsfree at the same time
 *
 */
void abe_write_select_pdm_output(u32 path)
{
	abe->mcpdm_path = path;
}
EXPORT_SYMBOL(abe_write_select_pdm_output);

EXPORT_SYMBOL(abe_use_compensated_gain);