blob: 6bad27e06f4d42ec4745aea0fc322664699f1301 [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 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>
Takashi Iwai635c2652009-06-13 10:12:59 +020022#include <linux/mutex.h>
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020023#include <linux/pci.h>
24#include <linux/timer.h>
25#include <sound/core.h>
26
27#include "ctvmem.h"
28#include "ctresource.h"
29
30enum CTALSADEVS { /* Types of alsa devices */
31 FRONT,
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020032 SURROUND,
Takashi Iwai8372d4982009-06-02 14:27:56 +020033 CLFE,
34 SIDE,
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020035 IEC958,
36 MIXER,
37 NUM_CTALSADEVS /* This should always be the last */
38};
39
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020040struct ct_atc_chip_sub_details {
41 u16 subsys;
42 const char *nm_model;
43};
44
45struct ct_atc_chip_details {
46 u16 vendor;
47 u16 device;
48 const struct ct_atc_chip_sub_details *sub_details;
49 const char *nm_card;
50};
51
52struct ct_atc;
Takashi Iwaib7bbf872009-06-05 16:11:07 +020053struct ct_timer;
54struct ct_timer_instance;
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020055
56/* alsa pcm stream descriptor */
57struct ct_atc_pcm {
58 struct snd_pcm_substream *substream;
59 void (*interrupt)(struct ct_atc_pcm *apcm);
Takashi Iwaib7bbf872009-06-05 16:11:07 +020060 struct ct_timer_instance *timer;
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020061 unsigned int started:1;
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020062
63 /* Only mono and interleaved modes are supported now. */
64 struct ct_vm_block *vm_block;
65 void *src; /* SRC for interacting with host memory */
66 void **srccs; /* SRCs for sample rate conversion */
67 void **srcimps; /* SRC Input Mappers */
68 void **amixers; /* AMIXERs for routing converted data */
69 void *mono; /* A SUM resource for mixing chs to one */
70 unsigned char n_srcc; /* Number of converting SRCs */
71 unsigned char n_srcimp; /* Number of SRC Input Mappers */
72 unsigned char n_amixer; /* Number of AMIXERs */
73};
74
75/* Chip resource management object */
76struct ct_atc {
77 struct pci_dev *pci;
78 struct snd_card *card;
79 unsigned int rsr; /* reference sample rate in Hz */
80 unsigned int msr; /* master sample rate in rsr */
81 unsigned int pll_rate; /* current rate of Phase Lock Loop */
82
Takashi Iwai94701952009-06-08 18:10:32 +020083 int chip_type;
84 int model;
85 const char *chip_name;
86 const char *model_name;
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020087
88 struct ct_vm *vm; /* device virtual memory manager for this card */
89 int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
90 void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
91 unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index);
92
Takashi Iwai635c2652009-06-13 10:12:59 +020093 struct mutex atc_mutex;
Wai Yew CHAY8cc72362009-05-14 08:05:58 +020094
95 int (*pcm_playback_prepare)(struct ct_atc *atc,
96 struct ct_atc_pcm *apcm);
97 int (*pcm_playback_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
98 int (*pcm_playback_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
99 int (*pcm_playback_position)(struct ct_atc *atc,
100 struct ct_atc_pcm *apcm);
101 int (*spdif_passthru_playback_prepare)(struct ct_atc *atc,
102 struct ct_atc_pcm *apcm);
103 int (*pcm_capture_prepare)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
104 int (*pcm_capture_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
105 int (*pcm_capture_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
106 int (*pcm_capture_position)(struct ct_atc *atc,
107 struct ct_atc_pcm *apcm);
108 int (*pcm_release_resources)(struct ct_atc *atc,
109 struct ct_atc_pcm *apcm);
110 int (*select_line_in)(struct ct_atc *atc);
111 int (*select_mic_in)(struct ct_atc *atc);
112 int (*select_digit_io)(struct ct_atc *atc);
113 int (*line_front_unmute)(struct ct_atc *atc, unsigned char state);
114 int (*line_surround_unmute)(struct ct_atc *atc, unsigned char state);
115 int (*line_clfe_unmute)(struct ct_atc *atc, unsigned char state);
116 int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state);
117 int (*line_in_unmute)(struct ct_atc *atc, unsigned char state);
Harry Butterworth55309212011-06-11 16:02:06 +0800118 int (*mic_unmute)(struct ct_atc *atc, unsigned char state);
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200119 int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state);
120 int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state);
121 int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status);
122 int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status);
123 int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
124 int (*have_digit_io_switch)(struct ct_atc *atc);
Harry Butterworth55309212011-06-11 16:02:06 +0800125 int (*have_dedicated_mic)(struct ct_atc *atc);
126 int (*have_output_switch)(struct ct_atc *atc);
127 int (*output_switch_get)(struct ct_atc *atc);
128 int (*output_switch_put)(struct ct_atc *atc, int position);
129 int (*have_mic_source_switch)(struct ct_atc *atc);
130 int (*mic_source_switch_get)(struct ct_atc *atc);
131 int (*mic_source_switch_put)(struct ct_atc *atc, int position);
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200132
133 /* Don't touch! Used for internal object. */
134 void *rsc_mgrs[NUM_RSCTYP]; /* chip resource managers */
135 void *mixer; /* internal mixer object */
136 void *hw; /* chip specific hardware access object */
137 void **daios; /* digital audio io resources */
138 void **pcm; /* SUMs for collecting all pcm stream */
139 void **srcs; /* Sample Rate Converters for input signal */
140 void **srcimps; /* input mappers for SRCs */
141 unsigned char n_daio;
142 unsigned char n_src;
143 unsigned char n_srcimp;
144 unsigned char n_pcm;
Takashi Iwaib7bbf872009-06-05 16:11:07 +0200145
146 struct ct_timer *timer;
Wai Yew CHAY29959a02009-06-22 14:52:34 +0200147
148#ifdef CONFIG_PM
149 int (*suspend)(struct ct_atc *atc, pm_message_t state);
150 int (*resume)(struct ct_atc *atc);
151#define NUM_PCMS (NUM_CTALSADEVS - 1)
152 struct snd_pcm *pcms[NUM_PCMS];
153#endif
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200154};
155
156
157int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
Takashi Iwai94701952009-06-08 18:10:32 +0200158 unsigned int rsr, unsigned int msr, int chip_type,
Takashi Iwai408bffd2010-01-14 09:19:46 +0100159 unsigned int subsysid, struct ct_atc **ratc);
Takashi Iwai2a36f672009-06-05 16:34:10 +0200160int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc);
Wai Yew CHAY8cc72362009-05-14 08:05:58 +0200161
162#endif /* CTATC_H */