Merge branch 'topic/asoc' into for-linus
[pandora-kernel.git] / sound / pci / ctxfi / cthardware.h
1 /**
2  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
3  *
4  * This source file is released under GPL v2 license (no other versions).
5  * See the COPYING file included in the main directory of this source
6  * distribution for the license terms and conditions.
7  *
8  * @File        cthardware.h
9  *
10  * @Brief
11  * This file contains the definition of hardware access methord.
12  *
13  * @Author      Liu Chun
14  * @Date        May 13 2008
15  *
16  */
17
18 #ifndef CTHARDWARE_H
19 #define CTHARDWARE_H
20
21 #include <linux/types.h>
22 #include <linux/pci.h>
23
24 enum CHIPTYP {
25         ATC20K1,
26         ATC20K2,
27         ATCNONE
28 };
29
30 enum CTCARDS {
31         /* 20k1 models */
32         CTSB055X,
33         CTSB073X,
34         CTUAA,
35         CT20K1_UNKNOWN,
36         /* 20k2 models */
37         CTSB0760,
38         CTHENDRIX,
39         CTSB0880,
40         NUM_CTCARDS             /* This should always be the last */
41 };
42
43 /* Type of input source for ADC */
44 enum ADCSRC{
45         ADC_MICIN,
46         ADC_LINEIN,
47         ADC_VIDEO,
48         ADC_AUX,
49         ADC_NONE        /* Switch to digital input */
50 };
51
52 struct card_conf {
53         /* device virtual mem page table page physical addr
54          * (supporting one page table page now) */
55         unsigned long vm_pgt_phys;
56         unsigned int rsr;       /* reference sample rate in Hzs*/
57         unsigned int msr;       /* master sample rate in rsrs */
58 };
59
60 struct hw {
61         int (*card_init)(struct hw *hw, struct card_conf *info);
62         int (*card_stop)(struct hw *hw);
63         int (*pll_init)(struct hw *hw, unsigned int rsr);
64         int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source);
65         int (*select_adc_source)(struct hw *hw, enum ADCSRC source);
66         int (*have_digit_io_switch)(struct hw *hw);
67
68         /* SRC operations */
69         int (*src_rsc_get_ctrl_blk)(void **rblk);
70         int (*src_rsc_put_ctrl_blk)(void *blk);
71         int (*src_set_state)(void *blk, unsigned int state);
72         int (*src_set_bm)(void *blk, unsigned int bm);
73         int (*src_set_rsr)(void *blk, unsigned int rsr);
74         int (*src_set_sf)(void *blk, unsigned int sf);
75         int (*src_set_wr)(void *blk, unsigned int wr);
76         int (*src_set_pm)(void *blk, unsigned int pm);
77         int (*src_set_rom)(void *blk, unsigned int rom);
78         int (*src_set_vo)(void *blk, unsigned int vo);
79         int (*src_set_st)(void *blk, unsigned int st);
80         int (*src_set_ie)(void *blk, unsigned int ie);
81         int (*src_set_ilsz)(void *blk, unsigned int ilsz);
82         int (*src_set_bp)(void *blk, unsigned int bp);
83         int (*src_set_cisz)(void *blk, unsigned int cisz);
84         int (*src_set_ca)(void *blk, unsigned int ca);
85         int (*src_set_sa)(void *blk, unsigned int sa);
86         int (*src_set_la)(void *blk, unsigned int la);
87         int (*src_set_pitch)(void *blk, unsigned int pitch);
88         int (*src_set_clear_zbufs)(void *blk, unsigned int clear);
89         int (*src_set_dirty)(void *blk, unsigned int flags);
90         int (*src_set_dirty_all)(void *blk);
91         int (*src_commit_write)(struct hw *hw, unsigned int idx, void *blk);
92         int (*src_get_ca)(struct hw *hw, unsigned int idx, void *blk);
93         unsigned int (*src_get_dirty)(void *blk);
94         unsigned int (*src_dirty_conj_mask)(void);
95         int (*src_mgr_get_ctrl_blk)(void **rblk);
96         int (*src_mgr_put_ctrl_blk)(void *blk);
97         /* syncly enable src @idx */
98         int (*src_mgr_enbs_src)(void *blk, unsigned int idx);
99         /* enable src @idx */
100         int (*src_mgr_enb_src)(void *blk, unsigned int idx);
101         /* disable src @idx */
102         int (*src_mgr_dsb_src)(void *blk, unsigned int idx);
103         int (*src_mgr_commit_write)(struct hw *hw, void *blk);
104
105         /* SRC Input Mapper operations */
106         int (*srcimp_mgr_get_ctrl_blk)(void **rblk);
107         int (*srcimp_mgr_put_ctrl_blk)(void *blk);
108         int (*srcimp_mgr_set_imaparc)(void *blk, unsigned int slot);
109         int (*srcimp_mgr_set_imapuser)(void *blk, unsigned int user);
110         int (*srcimp_mgr_set_imapnxt)(void *blk, unsigned int next);
111         int (*srcimp_mgr_set_imapaddr)(void *blk, unsigned int addr);
112         int (*srcimp_mgr_commit_write)(struct hw *hw, void *blk);
113
114         /* AMIXER operations */
115         int (*amixer_rsc_get_ctrl_blk)(void **rblk);
116         int (*amixer_rsc_put_ctrl_blk)(void *blk);
117         int (*amixer_mgr_get_ctrl_blk)(void **rblk);
118         int (*amixer_mgr_put_ctrl_blk)(void *blk);
119         int (*amixer_set_mode)(void *blk, unsigned int mode);
120         int (*amixer_set_iv)(void *blk, unsigned int iv);
121         int (*amixer_set_x)(void *blk, unsigned int x);
122         int (*amixer_set_y)(void *blk, unsigned int y);
123         int (*amixer_set_sadr)(void *blk, unsigned int sadr);
124         int (*amixer_set_se)(void *blk, unsigned int se);
125         int (*amixer_set_dirty)(void *blk, unsigned int flags);
126         int (*amixer_set_dirty_all)(void *blk);
127         int (*amixer_commit_write)(struct hw *hw, unsigned int idx, void *blk);
128         int (*amixer_get_y)(void *blk);
129         unsigned int (*amixer_get_dirty)(void *blk);
130
131         /* DAIO operations */
132         int (*dai_get_ctrl_blk)(void **rblk);
133         int (*dai_put_ctrl_blk)(void *blk);
134         int (*dai_srt_set_srco)(void *blk, unsigned int src);
135         int (*dai_srt_set_srcm)(void *blk, unsigned int src);
136         int (*dai_srt_set_rsr)(void *blk, unsigned int rsr);
137         int (*dai_srt_set_drat)(void *blk, unsigned int drat);
138         int (*dai_srt_set_ec)(void *blk, unsigned int ec);
139         int (*dai_srt_set_et)(void *blk, unsigned int et);
140         int (*dai_commit_write)(struct hw *hw, unsigned int idx, void *blk);
141         int (*dao_get_ctrl_blk)(void **rblk);
142         int (*dao_put_ctrl_blk)(void *blk);
143         int (*dao_set_spos)(void *blk, unsigned int spos);
144         int (*dao_commit_write)(struct hw *hw, unsigned int idx, void *blk);
145         int (*dao_get_spos)(void *blk, unsigned int *spos);
146
147         int (*daio_mgr_get_ctrl_blk)(struct hw *hw, void **rblk);
148         int (*daio_mgr_put_ctrl_blk)(void *blk);
149         int (*daio_mgr_enb_dai)(void *blk, unsigned int idx);
150         int (*daio_mgr_dsb_dai)(void *blk, unsigned int idx);
151         int (*daio_mgr_enb_dao)(void *blk, unsigned int idx);
152         int (*daio_mgr_dsb_dao)(void *blk, unsigned int idx);
153         int (*daio_mgr_dao_init)(void *blk, unsigned int idx,
154                                                 unsigned int conf);
155         int (*daio_mgr_set_imaparc)(void *blk, unsigned int slot);
156         int (*daio_mgr_set_imapnxt)(void *blk, unsigned int next);
157         int (*daio_mgr_set_imapaddr)(void *blk, unsigned int addr);
158         int (*daio_mgr_commit_write)(struct hw *hw, void *blk);
159
160         int (*set_timer_irq)(struct hw *hw, int enable);
161         int (*set_timer_tick)(struct hw *hw, unsigned int tick);
162         unsigned int (*get_wc)(struct hw *hw);
163
164         void (*irq_callback)(void *data, unsigned int bit);
165         void *irq_callback_data;
166
167         struct pci_dev *pci;    /* the pci kernel structure of this card */
168         int irq;
169         unsigned long io_base;
170         unsigned long mem_base;
171
172         enum CHIPTYP chip_type;
173         enum CTCARDS model;
174 };
175
176 int create_hw_obj(struct pci_dev *pci, enum CHIPTYP chip_type,
177                   enum CTCARDS model, struct hw **rhw);
178 int destroy_hw_obj(struct hw *hw);
179
180 unsigned int get_field(unsigned int data, unsigned int field);
181 void set_field(unsigned int *data, unsigned int field, unsigned int value);
182
183 /* IRQ bits */
184 #define PLL_INT         (1 << 10) /* PLL input-clock out-of-range */
185 #define FI_INT          (1 << 9)  /* forced interrupt */
186 #define IT_INT          (1 << 8)  /* timer interrupt */
187 #define PCI_INT         (1 << 7)  /* PCI bus error pending */
188 #define URT_INT         (1 << 6)  /* UART Tx/Rx */
189 #define GPI_INT         (1 << 5)  /* GPI pin */
190 #define MIX_INT         (1 << 4)  /* mixer parameter segment FIFO channels */
191 #define DAI_INT         (1 << 3)  /* DAI (SR-tracker or SPDIF-receiver) */
192 #define TP_INT          (1 << 2)  /* transport priority queue */
193 #define DSP_INT         (1 << 1)  /* DSP */
194 #define SRC_INT         (1 << 0)  /* SRC channels */
195
196 #endif /* CTHARDWARE_H */