treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / sound / soc / sprd / sprd-mcdt.h
blob9cc7e207ac7663e8ed438f953e808b3635392fa2
1 // SPDX-License-Identifier: GPL-2.0
3 #ifndef __SPRD_MCDT_H
4 #define __SPRD_MCDT_H
6 enum sprd_mcdt_channel_type {
7 SPRD_MCDT_DAC_CHAN,
8 SPRD_MCDT_ADC_CHAN,
9 SPRD_MCDT_UNKNOWN_CHAN,
12 enum sprd_mcdt_dma_chan {
13 SPRD_MCDT_DMA_CH0,
14 SPRD_MCDT_DMA_CH1,
15 SPRD_MCDT_DMA_CH2,
16 SPRD_MCDT_DMA_CH3,
17 SPRD_MCDT_DMA_CH4,
20 struct sprd_mcdt_chan_callback {
21 void (*notify)(void *data);
22 void *data;
25 /**
26 * struct sprd_mcdt_chan - this struct represents a single channel instance
27 * @mcdt: the mcdt controller
28 * @id: channel id
29 * @fifo_phys: channel fifo physical address which is used for DMA transfer
30 * @type: channel type
31 * @cb: channel fifo interrupt's callback interface to notify the fifo events
32 * @dma_enable: indicate if use DMA mode to transfer data
33 * @int_enable: indicate if use interrupt mode to notify users to read or
34 * write data manually
35 * @list: used to link into the global list
37 * Note: users should not modify any members of this structure.
39 struct sprd_mcdt_chan {
40 struct sprd_mcdt_dev *mcdt;
41 u8 id;
42 unsigned long fifo_phys;
43 enum sprd_mcdt_channel_type type;
44 enum sprd_mcdt_dma_chan dma_chan;
45 struct sprd_mcdt_chan_callback *cb;
46 bool dma_enable;
47 bool int_enable;
48 struct list_head list;
51 #ifdef CONFIG_SND_SOC_SPRD_MCDT
52 struct sprd_mcdt_chan *sprd_mcdt_request_chan(u8 channel,
53 enum sprd_mcdt_channel_type type);
54 void sprd_mcdt_free_chan(struct sprd_mcdt_chan *chan);
56 int sprd_mcdt_chan_write(struct sprd_mcdt_chan *chan, char *tx_buf, u32 size);
57 int sprd_mcdt_chan_read(struct sprd_mcdt_chan *chan, char *rx_buf, u32 size);
58 int sprd_mcdt_chan_int_enable(struct sprd_mcdt_chan *chan, u32 water_mark,
59 struct sprd_mcdt_chan_callback *cb);
60 void sprd_mcdt_chan_int_disable(struct sprd_mcdt_chan *chan);
62 int sprd_mcdt_chan_dma_enable(struct sprd_mcdt_chan *chan,
63 enum sprd_mcdt_dma_chan dma_chan, u32 water_mark);
64 void sprd_mcdt_chan_dma_disable(struct sprd_mcdt_chan *chan);
66 #else
68 struct sprd_mcdt_chan *sprd_mcdt_request_chan(u8 channel,
69 enum sprd_mcdt_channel_type type)
71 return NULL;
74 void sprd_mcdt_free_chan(struct sprd_mcdt_chan *chan)
75 { }
77 int sprd_mcdt_chan_write(struct sprd_mcdt_chan *chan, char *tx_buf, u32 size)
79 return -EINVAL;
82 int sprd_mcdt_chan_read(struct sprd_mcdt_chan *chan, char *rx_buf, u32 size)
84 return 0;
87 int sprd_mcdt_chan_int_enable(struct sprd_mcdt_chan *chan, u32 water_mark,
88 struct sprd_mcdt_chan_callback *cb)
90 return -EINVAL;
93 void sprd_mcdt_chan_int_disable(struct sprd_mcdt_chan *chan)
94 { }
96 int sprd_mcdt_chan_dma_enable(struct sprd_mcdt_chan *chan,
97 enum sprd_mcdt_dma_chan dma_chan, u32 water_mark)
99 return -EINVAL;
102 void sprd_mcdt_chan_dma_disable(struct sprd_mcdt_chan *chan)
105 #endif
107 #endif /* __SPRD_MCDT_H */