ALSA: ctxfi - Fix PCM device naming
[safe/jmp/linux-2.6] / sound / pci / ctxfi / ctatc.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        ctatc.h
9  *
10  * @Brief
11  * This file contains the definition of the device resource management object.
12  *
13  * @Author      Liu Chun
14  * @Date        Mar 28 2008
15  *
16  */
17
18 #ifndef CTATC_H
19 #define CTATC_H
20
21 #include <linux/types.h>
22 #include <linux/spinlock_types.h>
23 #include <linux/pci.h>
24 #include <linux/timer.h>
25 #include <sound/core.h>
26
27 #include "ctvmem.h"
28 #include "ctresource.h"
29
30 enum CTALSADEVS {               /* Types of alsa devices */
31         FRONT,
32         SURROUND,
33         CLFE,
34         SIDE,
35         IEC958,
36         MIXER,
37         NUM_CTALSADEVS          /* This should always be the last */
38 };
39
40 enum CTCARDS {
41         CTSB0760,
42         CTHENDRIX,
43         CTSB08801,
44         CTSB08802,
45         CTSB08803,
46         NUM_CTCARDS             /* This should always be the last */
47 };
48
49 struct ct_atc_chip_sub_details {
50         u16 subsys;
51         const char *nm_model;
52 };
53
54 struct ct_atc_chip_details {
55         u16 vendor;
56         u16 device;
57         const struct ct_atc_chip_sub_details *sub_details;
58         const char *nm_card;
59 };
60
61 struct ct_atc;
62
63 /* alsa pcm stream descriptor */
64 struct ct_atc_pcm {
65         struct snd_pcm_substream *substream;
66         void (*interrupt)(struct ct_atc_pcm *apcm);
67         unsigned int started:1;
68         unsigned int stop_timer:1;
69         struct timer_list timer;
70         spinlock_t timer_lock;
71         unsigned int position;
72
73         /* Only mono and interleaved modes are supported now. */
74         struct ct_vm_block *vm_block;
75         void *src;              /* SRC for interacting with host memory */
76         void **srccs;           /* SRCs for sample rate conversion */
77         void **srcimps;         /* SRC Input Mappers */
78         void **amixers;         /* AMIXERs for routing converted data */
79         void *mono;             /* A SUM resource for mixing chs to one */
80         unsigned char n_srcc;   /* Number of converting SRCs */
81         unsigned char n_srcimp; /* Number of SRC Input Mappers */
82         unsigned char n_amixer; /* Number of AMIXERs */
83 };
84
85 /* Chip resource management object */
86 struct ct_atc {
87         struct pci_dev *pci;
88         struct snd_card *card;
89         unsigned int rsr; /* reference sample rate in Hz */
90         unsigned int msr; /* master sample rate in rsr */
91         unsigned int pll_rate; /* current rate of Phase Lock Loop */
92
93         const struct ct_atc_chip_details *chip_details;
94         enum CTCARDS model;
95         /* Create all alsa devices */
96         int (*create_alsa_devs)(struct ct_atc *atc);
97
98         struct ct_vm *vm; /* device virtual memory manager for this card */
99         int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
100         void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
101         unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index);
102
103         spinlock_t atc_lock;
104
105         int (*pcm_playback_prepare)(struct ct_atc *atc,
106                                     struct ct_atc_pcm *apcm);
107         int (*pcm_playback_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
108         int (*pcm_playback_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
109         int (*pcm_playback_position)(struct ct_atc *atc,
110                                      struct ct_atc_pcm *apcm);
111         int (*spdif_passthru_playback_prepare)(struct ct_atc *atc,
112                                                struct ct_atc_pcm *apcm);
113         int (*pcm_capture_prepare)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
114         int (*pcm_capture_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
115         int (*pcm_capture_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
116         int (*pcm_capture_position)(struct ct_atc *atc,
117                                     struct ct_atc_pcm *apcm);
118         int (*pcm_release_resources)(struct ct_atc *atc,
119                                      struct ct_atc_pcm *apcm);
120         int (*select_line_in)(struct ct_atc *atc);
121         int (*select_mic_in)(struct ct_atc *atc);
122         int (*select_digit_io)(struct ct_atc *atc);
123         int (*line_front_unmute)(struct ct_atc *atc, unsigned char state);
124         int (*line_surround_unmute)(struct ct_atc *atc, unsigned char state);
125         int (*line_clfe_unmute)(struct ct_atc *atc, unsigned char state);
126         int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state);
127         int (*line_in_unmute)(struct ct_atc *atc, unsigned char state);
128         int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state);
129         int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state);
130         int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status);
131         int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status);
132         int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
133         int (*have_digit_io_switch)(struct ct_atc *atc);
134
135         /* Don't touch! Used for internal object. */
136         void *rsc_mgrs[NUM_RSCTYP]; /* chip resource managers */
137         void *mixer;            /* internal mixer object */
138         void *hw;               /* chip specific hardware access object */
139         void **daios;           /* digital audio io resources */
140         void **pcm;             /* SUMs for collecting all pcm stream */
141         void **srcs;            /* Sample Rate Converters for input signal */
142         void **srcimps;         /* input mappers for SRCs */
143         unsigned char n_daio;
144         unsigned char n_src;
145         unsigned char n_srcimp;
146         unsigned char n_pcm;
147 };
148
149
150 int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
151                             unsigned int rsr, unsigned int msr,
152                             struct ct_atc **ratc);
153
154 #endif /* CTATC_H */