1/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6#ifndef CRAS_MIX_OPS_H_
7#define CRAS_MIX_OPS_H_
8
9#include <stdint.h>
10
11#include "cras_system_state.h"
12
13extern const struct cras_mix_ops mixer_ops;
14extern const struct cras_mix_ops mixer_ops_sse42;
15extern const struct cras_mix_ops mixer_ops_avx;
16extern const struct cras_mix_ops mixer_ops_avx2;
17extern const struct cras_mix_ops mixer_ops_fma;
18
19/* Struct containing ops to implement mix/scale on a buffer of samples.
20 * Different architecture can provide different implementations and wraps
21 * the implementations into cras_mix_ops.
22 * Different sample formats will be handled by different implementations.
23 * The usage of each operation is explained in cras_mix.h
24 *
25 * Members:
26 *   scale_buffer_increment: See cras_scale_buffer_increment.
27 *   scale_buffer: See cras_scale_buffer.
28 *   add: See cras_mix_add.
29 *   add_scale_stride: See cras_mix_add_scale_stride.
30 *   mute_buffer: cras_mix_mute_buffer.
31 */
32struct cras_mix_ops {
33	void (*scale_buffer_increment)(snd_pcm_format_t fmt, uint8_t *buff,
34				       unsigned int count, float scaler,
35				       float increment, int step);
36	void (*scale_buffer)(snd_pcm_format_t fmt, uint8_t *buff,
37			unsigned int count, float scaler);
38	void (*add)(snd_pcm_format_t fmt, uint8_t *dst, uint8_t *src,
39		  unsigned int count, unsigned int index,
40		  int mute, float mix_vol);
41	void (*add_scale_stride)(snd_pcm_format_t fmt, uint8_t *dst,
42			uint8_t *src, unsigned int count,
43			unsigned int dst_stride, unsigned int src_stride,
44			float scaler);
45	size_t (*mute_buffer)(uint8_t *dst,
46			    size_t frame_bytes,
47			    size_t count);
48};
49#endif
50