blob: 67120bb78a3319dda506b3371c624917f772f68a [file] [log] [blame]
Googler9398cc32022-12-02 17:21:52 +08001/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
Googler9726be62022-12-14 05:53:31 +00002/*
Googler9398cc32022-12-02 17:21:52 +08003 * Copyright (c) 2019 Amlogic, Inc. All rights reserved.
Googler9726be62022-12-14 05:53:31 +00004 */
Googler4f18c0c2022-09-20 17:23:36 +08005
6#ifndef __AML_LOOPBACK_HW_H__
7#define __AML_LOOPBACK_HW_H__
8
Googler38bda472022-08-19 10:07:08 -07009#include <linux/types.h>
Googler9726be62022-12-14 05:53:31 +000010#include "loopback.h"
Googler9398cc32022-12-02 17:21:52 +080011#include "resample.h"
12
13struct mux_conf {
14 char name[32];
15 unsigned int val;
16 unsigned int reg;
17 unsigned int shift;
18 unsigned int mask;
19};
20
21#define AUDIO_SRC_CONFIG(_name, _val, _reg, _shift, _mask) \
22{ .name = (_name), .val = (_val), .reg = (_reg),\
23 .shift = (_shift), .mask = (_mask)}
Googler38bda472022-08-19 10:07:08 -070024
25struct data_cfg {
Googler4f18c0c2022-09-20 17:23:36 +080026 /*
27 * 0: extend bits as "0"
28 * 1: extend bits as "msb"
29 */
30 unsigned int ext_signed;
Googler38bda472022-08-19 10:07:08 -070031 /* channel number */
Googler4f18c0c2022-09-20 17:23:36 +080032 unsigned int chnum;
Googler38bda472022-08-19 10:07:08 -070033 /* channel selected */
Googler4f18c0c2022-09-20 17:23:36 +080034 unsigned int chmask;
Googler38bda472022-08-19 10:07:08 -070035 /* combined data */
36 unsigned int type;
37 /* the msb positioin in data */
38 unsigned int m;
39 /* the lsb position in data */
40 unsigned int n;
41
42 /* loopback datalb src */
43 unsigned int src;
44
Googler9398cc32022-12-02 17:21:52 +080045 unsigned int loopback_src;
Googler38bda472022-08-19 10:07:08 -070046
47 /* channel and mask in new ctrol register */
48 bool ch_ctrl_switch;
49
50 /* enable resample B for loopback*/
51 unsigned int resample_enable;
Googler9398cc32022-12-02 17:21:52 +080052 /* srcs from chipinfo */
53 struct mux_conf *srcs;
54 struct mux_conf *tdmin_lb_srcs;
Googler4f18c0c2022-09-20 17:23:36 +080055};
56
Googler9398cc32022-12-02 17:21:52 +080057void tdminlb_set_clk(enum datalb_src lb_src, int sclk_div, int ratio, bool enable);
58void tdminlb_set_format(int i2s_fmt);
Googler9726be62022-12-14 05:53:31 +000059void tdminlb_set_ctrl(enum datalb_src src);
Googler9398cc32022-12-02 17:21:52 +080060void tdminlb_enable(int tdm_index, int in_enable);
61void tdminlb_fifo_enable(int is_enable);
62void tdminlb_set_format(int i2s_fmt);
Googler9726be62022-12-14 05:53:31 +000063void tdminlb_set_lanemask_and_chswap
64 (int swap, int lane_mask, unsigned int mask);
Googler38bda472022-08-19 10:07:08 -070065
Googler9398cc32022-12-02 17:21:52 +080066void tdminlb_set_src(int src);
67void lb_set_datain_src(int id, int src);
68void lb_set_datain_cfg(int id, struct data_cfg *datain_cfg);
69void lb_set_datalb_cfg(int id, struct data_cfg *datalb_cfg, bool multi_bits_lbsrcs);
Googler9726be62022-12-14 05:53:31 +000070void lb_enable(int id, bool enable, bool chnum_en);
Googler9726be62022-12-14 05:53:31 +000071void lb_set_chnum_en(int id, bool en, bool chnum_en);
Googler9398cc32022-12-02 17:21:52 +080072void loopback_src_set(int id, struct mux_conf *conf, int version);
Googler9726be62022-12-14 05:53:31 +000073
74enum lb_out_rate {
75 MIC_RATE,
76 LB_RATE,
77};
78
79void lb_set_mode(int id, enum lb_out_rate rate);
Googler4f18c0c2022-09-20 17:23:36 +080080#endif