Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
0004  *
0005  * @File    cthardware.h
0006  *
0007  * @Brief
0008  * This file contains the definition of hardware access methord.
0009  *
0010  * @Author  Liu Chun
0011  * @Date    May 13 2008
0012  */
0013 
0014 #ifndef CTHARDWARE_H
0015 #define CTHARDWARE_H
0016 
0017 #include <linux/types.h>
0018 #include <linux/pci.h>
0019 #include <sound/core.h>
0020 
0021 enum CHIPTYP {
0022     ATC20K1,
0023     ATC20K2,
0024     ATCNONE
0025 };
0026 
0027 enum CTCARDS {
0028     /* 20k1 models */
0029     CTSB046X,
0030     CT20K1_MODEL_FIRST = CTSB046X,
0031     CTSB055X,
0032     CTSB073X,
0033     CTUAA,
0034     CT20K1_UNKNOWN,
0035     /* 20k2 models */
0036     CTSB0760,
0037     CT20K2_MODEL_FIRST = CTSB0760,
0038     CTHENDRIX,
0039     CTSB0880,
0040     CTSB1270,
0041     CT20K2_UNKNOWN,
0042     NUM_CTCARDS     /* This should always be the last */
0043 };
0044 
0045 /* Type of input source for ADC */
0046 enum ADCSRC{
0047     ADC_MICIN,
0048     ADC_LINEIN,
0049     ADC_VIDEO,
0050     ADC_AUX,
0051     ADC_NONE    /* Switch to digital input */
0052 };
0053 
0054 struct card_conf {
0055     /* device virtual mem page table page physical addr
0056      * (supporting one page table page now) */
0057     unsigned long vm_pgt_phys;
0058     unsigned int rsr;   /* reference sample rate in Hzs*/
0059     unsigned int msr;   /* master sample rate in rsrs */
0060 };
0061 
0062 struct capabilities {
0063     unsigned int digit_io_switch:1;
0064     unsigned int dedicated_mic:1;
0065     unsigned int output_switch:1;
0066     unsigned int mic_source_switch:1;
0067 };
0068 
0069 struct hw {
0070     int (*card_init)(struct hw *hw, struct card_conf *info);
0071     int (*card_stop)(struct hw *hw);
0072     int (*pll_init)(struct hw *hw, unsigned int rsr);
0073 #ifdef CONFIG_PM_SLEEP
0074     int (*suspend)(struct hw *hw);
0075     int (*resume)(struct hw *hw, struct card_conf *info);
0076 #endif
0077     int (*is_adc_source_selected)(struct hw *hw, enum ADCSRC source);
0078     int (*select_adc_source)(struct hw *hw, enum ADCSRC source);
0079     struct capabilities (*capabilities)(struct hw *hw);
0080     int (*output_switch_get)(struct hw *hw);
0081     int (*output_switch_put)(struct hw *hw, int position);
0082     int (*mic_source_switch_get)(struct hw *hw);
0083     int (*mic_source_switch_put)(struct hw *hw, int position);
0084 
0085     /* SRC operations */
0086     int (*src_rsc_get_ctrl_blk)(void **rblk);
0087     int (*src_rsc_put_ctrl_blk)(void *blk);
0088     int (*src_set_state)(void *blk, unsigned int state);
0089     int (*src_set_bm)(void *blk, unsigned int bm);
0090     int (*src_set_rsr)(void *blk, unsigned int rsr);
0091     int (*src_set_sf)(void *blk, unsigned int sf);
0092     int (*src_set_wr)(void *blk, unsigned int wr);
0093     int (*src_set_pm)(void *blk, unsigned int pm);
0094     int (*src_set_rom)(void *blk, unsigned int rom);
0095     int (*src_set_vo)(void *blk, unsigned int vo);
0096     int (*src_set_st)(void *blk, unsigned int st);
0097     int (*src_set_ie)(void *blk, unsigned int ie);
0098     int (*src_set_ilsz)(void *blk, unsigned int ilsz);
0099     int (*src_set_bp)(void *blk, unsigned int bp);
0100     int (*src_set_cisz)(void *blk, unsigned int cisz);
0101     int (*src_set_ca)(void *blk, unsigned int ca);
0102     int (*src_set_sa)(void *blk, unsigned int sa);
0103     int (*src_set_la)(void *blk, unsigned int la);
0104     int (*src_set_pitch)(void *blk, unsigned int pitch);
0105     int (*src_set_clear_zbufs)(void *blk, unsigned int clear);
0106     int (*src_set_dirty)(void *blk, unsigned int flags);
0107     int (*src_set_dirty_all)(void *blk);
0108     int (*src_commit_write)(struct hw *hw, unsigned int idx, void *blk);
0109     int (*src_get_ca)(struct hw *hw, unsigned int idx, void *blk);
0110     unsigned int (*src_get_dirty)(void *blk);
0111     unsigned int (*src_dirty_conj_mask)(void);
0112     int (*src_mgr_get_ctrl_blk)(void **rblk);
0113     int (*src_mgr_put_ctrl_blk)(void *blk);
0114     /* syncly enable src @idx */
0115     int (*src_mgr_enbs_src)(void *blk, unsigned int idx);
0116     /* enable src @idx */
0117     int (*src_mgr_enb_src)(void *blk, unsigned int idx);
0118     /* disable src @idx */
0119     int (*src_mgr_dsb_src)(void *blk, unsigned int idx);
0120     int (*src_mgr_commit_write)(struct hw *hw, void *blk);
0121 
0122     /* SRC Input Mapper operations */
0123     int (*srcimp_mgr_get_ctrl_blk)(void **rblk);
0124     int (*srcimp_mgr_put_ctrl_blk)(void *blk);
0125     int (*srcimp_mgr_set_imaparc)(void *blk, unsigned int slot);
0126     int (*srcimp_mgr_set_imapuser)(void *blk, unsigned int user);
0127     int (*srcimp_mgr_set_imapnxt)(void *blk, unsigned int next);
0128     int (*srcimp_mgr_set_imapaddr)(void *blk, unsigned int addr);
0129     int (*srcimp_mgr_commit_write)(struct hw *hw, void *blk);
0130 
0131     /* AMIXER operations */
0132     int (*amixer_rsc_get_ctrl_blk)(void **rblk);
0133     int (*amixer_rsc_put_ctrl_blk)(void *blk);
0134     int (*amixer_mgr_get_ctrl_blk)(void **rblk);
0135     int (*amixer_mgr_put_ctrl_blk)(void *blk);
0136     int (*amixer_set_mode)(void *blk, unsigned int mode);
0137     int (*amixer_set_iv)(void *blk, unsigned int iv);
0138     int (*amixer_set_x)(void *blk, unsigned int x);
0139     int (*amixer_set_y)(void *blk, unsigned int y);
0140     int (*amixer_set_sadr)(void *blk, unsigned int sadr);
0141     int (*amixer_set_se)(void *blk, unsigned int se);
0142     int (*amixer_set_dirty)(void *blk, unsigned int flags);
0143     int (*amixer_set_dirty_all)(void *blk);
0144     int (*amixer_commit_write)(struct hw *hw, unsigned int idx, void *blk);
0145     int (*amixer_get_y)(void *blk);
0146     unsigned int (*amixer_get_dirty)(void *blk);
0147 
0148     /* DAIO operations */
0149     int (*dai_get_ctrl_blk)(void **rblk);
0150     int (*dai_put_ctrl_blk)(void *blk);
0151     int (*dai_srt_set_srco)(void *blk, unsigned int src);
0152     int (*dai_srt_set_srcm)(void *blk, unsigned int src);
0153     int (*dai_srt_set_rsr)(void *blk, unsigned int rsr);
0154     int (*dai_srt_set_drat)(void *blk, unsigned int drat);
0155     int (*dai_srt_set_ec)(void *blk, unsigned int ec);
0156     int (*dai_srt_set_et)(void *blk, unsigned int et);
0157     int (*dai_commit_write)(struct hw *hw, unsigned int idx, void *blk);
0158     int (*dao_get_ctrl_blk)(void **rblk);
0159     int (*dao_put_ctrl_blk)(void *blk);
0160     int (*dao_set_spos)(void *blk, unsigned int spos);
0161     int (*dao_commit_write)(struct hw *hw, unsigned int idx, void *blk);
0162     int (*dao_get_spos)(void *blk, unsigned int *spos);
0163 
0164     int (*daio_mgr_get_ctrl_blk)(struct hw *hw, void **rblk);
0165     int (*daio_mgr_put_ctrl_blk)(void *blk);
0166     int (*daio_mgr_enb_dai)(void *blk, unsigned int idx);
0167     int (*daio_mgr_dsb_dai)(void *blk, unsigned int idx);
0168     int (*daio_mgr_enb_dao)(void *blk, unsigned int idx);
0169     int (*daio_mgr_dsb_dao)(void *blk, unsigned int idx);
0170     int (*daio_mgr_dao_init)(void *blk, unsigned int idx,
0171                         unsigned int conf);
0172     int (*daio_mgr_set_imaparc)(void *blk, unsigned int slot);
0173     int (*daio_mgr_set_imapnxt)(void *blk, unsigned int next);
0174     int (*daio_mgr_set_imapaddr)(void *blk, unsigned int addr);
0175     int (*daio_mgr_commit_write)(struct hw *hw, void *blk);
0176 
0177     int (*set_timer_irq)(struct hw *hw, int enable);
0178     int (*set_timer_tick)(struct hw *hw, unsigned int tick);
0179     unsigned int (*get_wc)(struct hw *hw);
0180 
0181     void (*irq_callback)(void *data, unsigned int bit);
0182     void *irq_callback_data;
0183 
0184     struct pci_dev *pci;    /* the pci kernel structure of this card */
0185     struct snd_card *card;  /* pointer to this card */
0186     int irq;
0187     unsigned long io_base;
0188     void __iomem *mem_base;
0189 
0190     enum CHIPTYP chip_type;
0191     enum CTCARDS model;
0192 };
0193 
0194 int create_hw_obj(struct pci_dev *pci, enum CHIPTYP chip_type,
0195           enum CTCARDS model, struct hw **rhw);
0196 int destroy_hw_obj(struct hw *hw);
0197 
0198 unsigned int get_field(unsigned int data, unsigned int field);
0199 void set_field(unsigned int *data, unsigned int field, unsigned int value);
0200 
0201 /* IRQ bits */
0202 #define PLL_INT     (1 << 10) /* PLL input-clock out-of-range */
0203 #define FI_INT      (1 << 9)  /* forced interrupt */
0204 #define IT_INT      (1 << 8)  /* timer interrupt */
0205 #define PCI_INT     (1 << 7)  /* PCI bus error pending */
0206 #define URT_INT     (1 << 6)  /* UART Tx/Rx */
0207 #define GPI_INT     (1 << 5)  /* GPI pin */
0208 #define MIX_INT     (1 << 4)  /* mixer parameter segment FIFO channels */
0209 #define DAI_INT     (1 << 3)  /* DAI (SR-tracker or SPDIF-receiver) */
0210 #define TP_INT      (1 << 2)  /* transport priority queue */
0211 #define DSP_INT     (1 << 1)  /* DSP */
0212 #define SRC_INT     (1 << 0)  /* SRC channels */
0213 
0214 #endif /* CTHARDWARE_H */