blob: af55405f5dec81b0e5d4f7b7829c9ea981b5ee77 [file] [log] [blame]
Wai Yew CHAY8cc72362009-05-14 08:05:58 +02001/**
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
24enum CHIPTYP {
25 ATC20K1,
26 ATC20K2,
27 ATCNONE
28};
29
Takashi Iwai94701952009-06-08 18:10:32 +020030enum CTCARDS {
31 /* 20k1 models */
32 CTSB055X,
Takashi Iwaia8f43102009-06-22 07:36:52 +020033 CT20K1_MODEL_FIRST = CTSB055X,
Takashi Iwai94701952009-06-08 18:10:32 +020034 CTSB073X,
35 CTUAA,
36 CT20K1_UNKNOWN,
37 /* 20k2 models */
38 CTSB0760,
Takashi Iwaia8f43102009-06-22 07:36:52 +020039 CT20K2_MODEL_FIRST = CTSB0760,
Takashi Iwai94701952009-06-08 18:10:32 +020040 CTHENDRIX,
41 CTSB0880,
Takashi Iwaia8f43102009-06-22 07:36:52 +020042 CT20K2_UNKNOWN,
Takashi Iwai94701952009-06-08 18:10:32 +020043 NUM_CTCARDS /* This should always be the last */
44};
45
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020046/* Type of input source for ADC */
47enum ADCSRC{
48 ADC_MICIN,
49 ADC_LINEIN,
50 ADC_VIDEO,
51 ADC_AUX,
52 ADC_NONE /* Switch to digital input */
53};
54
55struct card_conf {
56 /* device virtual mem page table page physical addr
57 * (supporting one page table page now) */
58 unsigned long vm_pgt_phys;
59 unsigned int rsr; /* reference sample rate in Hzs*/
60 unsigned int msr; /* master sample rate in rsrs */
61};
62
63struct hw {
64 int (*card_init)(struct hw *hw, struct card_conf *info);
65 int (*card_stop)(struct hw *hw);
66 int (*pll_init)(struct hw *hw, unsigned int rsr);
Wai Yew CHAY29959a02009-06-22 14:52:34 +020067#ifdef CONFIG_PM
68 int (*suspend)(struct hw *hw, pm_message_t state);
69 int (*resume)(struct hw *hw, struct card_conf *info);
70#endif
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020071 int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source);
72 int (*select_adc_source)(struct hw *hw, enum ADCSRC source);
73 int (*have_digit_io_switch)(struct hw *hw);
74
75 /* SRC operations */
76 int (*src_rsc_get_ctrl_blk)(void **rblk);
77 int (*src_rsc_put_ctrl_blk)(void *blk);
78 int (*src_set_state)(void *blk, unsigned int state);
79 int (*src_set_bm)(void *blk, unsigned int bm);
80 int (*src_set_rsr)(void *blk, unsigned int rsr);
81 int (*src_set_sf)(void *blk, unsigned int sf);
82 int (*src_set_wr)(void *blk, unsigned int wr);
83 int (*src_set_pm)(void *blk, unsigned int pm);
84 int (*src_set_rom)(void *blk, unsigned int rom);
85 int (*src_set_vo)(void *blk, unsigned int vo);
86 int (*src_set_st)(void *blk, unsigned int st);
87 int (*src_set_ie)(void *blk, unsigned int ie);
88 int (*src_set_ilsz)(void *blk, unsigned int ilsz);
89 int (*src_set_bp)(void *blk, unsigned int bp);
90 int (*src_set_cisz)(void *blk, unsigned int cisz);
91 int (*src_set_ca)(void *blk, unsigned int ca);
92 int (*src_set_sa)(void *blk, unsigned int sa);
93 int (*src_set_la)(void *blk, unsigned int la);
94 int (*src_set_pitch)(void *blk, unsigned int pitch);
95 int (*src_set_clear_zbufs)(void *blk, unsigned int clear);
96 int (*src_set_dirty)(void *blk, unsigned int flags);
97 int (*src_set_dirty_all)(void *blk);
98 int (*src_commit_write)(struct hw *hw, unsigned int idx, void *blk);
99 int (*src_get_ca)(struct hw *hw, unsigned int idx, void *blk);
100 unsigned int (*src_get_dirty)(void *blk);
101 unsigned int (*src_dirty_conj_mask)(void);
102 int (*src_mgr_get_ctrl_blk)(void **rblk);
103 int (*src_mgr_put_ctrl_blk)(void *blk);
104 /* syncly enable src @idx */
105 int (*src_mgr_enbs_src)(void *blk, unsigned int idx);
106 /* enable src @idx */
107 int (*src_mgr_enb_src)(void *blk, unsigned int idx);
108 /* disable src @idx */
109 int (*src_mgr_dsb_src)(void *blk, unsigned int idx);
110 int (*src_mgr_commit_write)(struct hw *hw, void *blk);
111
112 /* SRC Input Mapper operations */
113 int (*srcimp_mgr_get_ctrl_blk)(void **rblk);
114 int (*srcimp_mgr_put_ctrl_blk)(void *blk);
115 int (*srcimp_mgr_set_imaparc)(void *blk, unsigned int slot);
116 int (*srcimp_mgr_set_imapuser)(void *blk, unsigned int user);
117 int (*srcimp_mgr_set_imapnxt)(void *blk, unsigned int next);
118 int (*srcimp_mgr_set_imapaddr)(void *blk, unsigned int addr);
119 int (*srcimp_mgr_commit_write)(struct hw *hw, void *blk);
120
121 /* AMIXER operations */
122 int (*amixer_rsc_get_ctrl_blk)(void **rblk);
123 int (*amixer_rsc_put_ctrl_blk)(void *blk);
124 int (*amixer_mgr_get_ctrl_blk)(void **rblk);
125 int (*amixer_mgr_put_ctrl_blk)(void *blk);
126 int (*amixer_set_mode)(void *blk, unsigned int mode);
127 int (*amixer_set_iv)(void *blk, unsigned int iv);
128 int (*amixer_set_x)(void *blk, unsigned int x);
129 int (*amixer_set_y)(void *blk, unsigned int y);
130 int (*amixer_set_sadr)(void *blk, unsigned int sadr);
131 int (*amixer_set_se)(void *blk, unsigned int se);
132 int (*amixer_set_dirty)(void *blk, unsigned int flags);
133 int (*amixer_set_dirty_all)(void *blk);
134 int (*amixer_commit_write)(struct hw *hw, unsigned int idx, void *blk);
135 int (*amixer_get_y)(void *blk);
136 unsigned int (*amixer_get_dirty)(void *blk);
137
138 /* DAIO operations */
139 int (*dai_get_ctrl_blk)(void **rblk);
140 int (*dai_put_ctrl_blk)(void *blk);
141 int (*dai_srt_set_srco)(void *blk, unsigned int src);
142 int (*dai_srt_set_srcm)(void *blk, unsigned int src);
143 int (*dai_srt_set_rsr)(void *blk, unsigned int rsr);
144 int (*dai_srt_set_drat)(void *blk, unsigned int drat);
145 int (*dai_srt_set_ec)(void *blk, unsigned int ec);
146 int (*dai_srt_set_et)(void *blk, unsigned int et);
147 int (*dai_commit_write)(struct hw *hw, unsigned int idx, void *blk);
148 int (*dao_get_ctrl_blk)(void **rblk);
149 int (*dao_put_ctrl_blk)(void *blk);
150 int (*dao_set_spos)(void *blk, unsigned int spos);
151 int (*dao_commit_write)(struct hw *hw, unsigned int idx, void *blk);
152 int (*dao_get_spos)(void *blk, unsigned int *spos);
153
154 int (*daio_mgr_get_ctrl_blk)(struct hw *hw, void **rblk);
155 int (*daio_mgr_put_ctrl_blk)(void *blk);
156 int (*daio_mgr_enb_dai)(void *blk, unsigned int idx);
157 int (*daio_mgr_dsb_dai)(void *blk, unsigned int idx);
158 int (*daio_mgr_enb_dao)(void *blk, unsigned int idx);
159 int (*daio_mgr_dsb_dao)(void *blk, unsigned int idx);
160 int (*daio_mgr_dao_init)(void *blk, unsigned int idx,
161 unsigned int conf);
162 int (*daio_mgr_set_imaparc)(void *blk, unsigned int slot);
163 int (*daio_mgr_set_imapnxt)(void *blk, unsigned int next);
164 int (*daio_mgr_set_imapaddr)(void *blk, unsigned int addr);
165 int (*daio_mgr_commit_write)(struct hw *hw, void *blk);
166
Takashi Iwaib7bbf872009-06-05 16:11:07 +0200167 int (*set_timer_irq)(struct hw *hw, int enable);
168 int (*set_timer_tick)(struct hw *hw, unsigned int tick);
Takashi Iwai54de6bc2009-06-08 10:21:07 +0200169 unsigned int (*get_wc)(struct hw *hw);
Takashi Iwaib7bbf872009-06-05 16:11:07 +0200170
171 void (*irq_callback)(void *data, unsigned int bit);
172 void *irq_callback_data;
173
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200174 struct pci_dev *pci; /* the pci kernel structure of this card */
175 int irq;
176 unsigned long io_base;
177 unsigned long mem_base;
Takashi Iwai94701952009-06-08 18:10:32 +0200178
179 enum CHIPTYP chip_type;
180 enum CTCARDS model;
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200181};
182
Takashi Iwai94701952009-06-08 18:10:32 +0200183int create_hw_obj(struct pci_dev *pci, enum CHIPTYP chip_type,
184 enum CTCARDS model, struct hw **rhw);
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200185int destroy_hw_obj(struct hw *hw);
186
187unsigned int get_field(unsigned int data, unsigned int field);
188void set_field(unsigned int *data, unsigned int field, unsigned int value);
189
Takashi Iwaib7bbf872009-06-05 16:11:07 +0200190/* IRQ bits */
191#define PLL_INT (1 << 10) /* PLL input-clock out-of-range */
192#define FI_INT (1 << 9) /* forced interrupt */
193#define IT_INT (1 << 8) /* timer interrupt */
194#define PCI_INT (1 << 7) /* PCI bus error pending */
195#define URT_INT (1 << 6) /* UART Tx/Rx */
196#define GPI_INT (1 << 5) /* GPI pin */
197#define MIX_INT (1 << 4) /* mixer parameter segment FIFO channels */
198#define DAI_INT (1 << 3) /* DAI (SR-tracker or SPDIF-receiver) */
199#define TP_INT (1 << 2) /* transport priority queue */
200#define DSP_INT (1 << 1) /* DSP */
201#define SRC_INT (1 << 0) /* SRC channels */
202
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200203#endif /* CTHARDWARE_H */