| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 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> | 
| Takashi Iwai | 635c265 | 2009-06-13 10:12:59 +0200 | [diff] [blame] | 22 | #include <linux/mutex.h> | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 23 | #include <linux/pci.h> | 
 | 24 | #include <linux/timer.h> | 
 | 25 | #include <sound/core.h> | 
 | 26 |  | 
 | 27 | #include "ctvmem.h" | 
| Harry Butterworth | b028b81 | 2011-06-11 17:41:13 +0800 | [diff] [blame] | 28 | #include "cthardware.h" | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 29 | #include "ctresource.h" | 
 | 30 |  | 
 | 31 | enum CTALSADEVS {		/* Types of alsa devices */ | 
 | 32 | 	FRONT, | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 33 | 	SURROUND, | 
| Takashi Iwai | 8372d498 | 2009-06-02 14:27:56 +0200 | [diff] [blame] | 34 | 	CLFE, | 
 | 35 | 	SIDE, | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 36 | 	IEC958, | 
 | 37 | 	MIXER, | 
 | 38 | 	NUM_CTALSADEVS		/* This should always be the last */ | 
 | 39 | }; | 
 | 40 |  | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 41 | struct ct_atc_chip_sub_details { | 
 | 42 | 	u16 subsys; | 
 | 43 | 	const char *nm_model; | 
 | 44 | }; | 
 | 45 |  | 
 | 46 | struct ct_atc_chip_details { | 
 | 47 | 	u16 vendor; | 
 | 48 | 	u16 device; | 
 | 49 | 	const struct ct_atc_chip_sub_details *sub_details; | 
 | 50 | 	const char *nm_card; | 
 | 51 | }; | 
 | 52 |  | 
 | 53 | struct ct_atc; | 
| Takashi Iwai | b7bbf87 | 2009-06-05 16:11:07 +0200 | [diff] [blame] | 54 | struct ct_timer; | 
 | 55 | struct ct_timer_instance; | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 56 |  | 
 | 57 | /* alsa pcm stream descriptor */ | 
 | 58 | struct ct_atc_pcm { | 
 | 59 | 	struct snd_pcm_substream *substream; | 
 | 60 | 	void (*interrupt)(struct ct_atc_pcm *apcm); | 
| Takashi Iwai | b7bbf87 | 2009-06-05 16:11:07 +0200 | [diff] [blame] | 61 | 	struct ct_timer_instance *timer; | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 62 | 	unsigned int started:1; | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 63 |  | 
 | 64 | 	/* Only mono and interleaved modes are supported now. */ | 
 | 65 | 	struct ct_vm_block *vm_block; | 
 | 66 | 	void *src;		/* SRC for interacting with host memory */ | 
 | 67 | 	void **srccs;		/* SRCs for sample rate conversion */ | 
 | 68 | 	void **srcimps;		/* SRC Input Mappers */ | 
 | 69 | 	void **amixers;		/* AMIXERs for routing converted data */ | 
 | 70 | 	void *mono;		/* A SUM resource for mixing chs to one */ | 
 | 71 | 	unsigned char n_srcc;	/* Number of converting SRCs */ | 
 | 72 | 	unsigned char n_srcimp;	/* Number of SRC Input Mappers */ | 
 | 73 | 	unsigned char n_amixer;	/* Number of AMIXERs */ | 
 | 74 | }; | 
 | 75 |  | 
 | 76 | /* Chip resource management object */ | 
 | 77 | struct ct_atc { | 
 | 78 | 	struct pci_dev *pci; | 
 | 79 | 	struct snd_card *card; | 
 | 80 | 	unsigned int rsr; /* reference sample rate in Hz */ | 
 | 81 | 	unsigned int msr; /* master sample rate in rsr */ | 
 | 82 | 	unsigned int pll_rate; /* current rate of Phase Lock Loop */ | 
 | 83 |  | 
| Takashi Iwai | 9470195 | 2009-06-08 18:10:32 +0200 | [diff] [blame] | 84 | 	int chip_type; | 
 | 85 | 	int model; | 
 | 86 | 	const char *chip_name; | 
 | 87 | 	const char *model_name; | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 88 |  | 
 | 89 | 	struct ct_vm *vm; /* device virtual memory manager for this card */ | 
 | 90 | 	int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm); | 
 | 91 | 	void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm); | 
 | 92 | 	unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index); | 
 | 93 |  | 
| Takashi Iwai | 635c265 | 2009-06-13 10:12:59 +0200 | [diff] [blame] | 94 | 	struct mutex atc_mutex; | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 95 |  | 
 | 96 | 	int (*pcm_playback_prepare)(struct ct_atc *atc, | 
 | 97 | 				    struct ct_atc_pcm *apcm); | 
 | 98 | 	int (*pcm_playback_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm); | 
 | 99 | 	int (*pcm_playback_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm); | 
 | 100 | 	int (*pcm_playback_position)(struct ct_atc *atc, | 
 | 101 | 				     struct ct_atc_pcm *apcm); | 
 | 102 | 	int (*spdif_passthru_playback_prepare)(struct ct_atc *atc, | 
 | 103 | 					       struct ct_atc_pcm *apcm); | 
 | 104 | 	int (*pcm_capture_prepare)(struct ct_atc *atc, struct ct_atc_pcm *apcm); | 
 | 105 | 	int (*pcm_capture_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm); | 
 | 106 | 	int (*pcm_capture_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm); | 
 | 107 | 	int (*pcm_capture_position)(struct ct_atc *atc, | 
 | 108 | 				    struct ct_atc_pcm *apcm); | 
 | 109 | 	int (*pcm_release_resources)(struct ct_atc *atc, | 
 | 110 | 				     struct ct_atc_pcm *apcm); | 
 | 111 | 	int (*select_line_in)(struct ct_atc *atc); | 
 | 112 | 	int (*select_mic_in)(struct ct_atc *atc); | 
 | 113 | 	int (*select_digit_io)(struct ct_atc *atc); | 
 | 114 | 	int (*line_front_unmute)(struct ct_atc *atc, unsigned char state); | 
 | 115 | 	int (*line_surround_unmute)(struct ct_atc *atc, unsigned char state); | 
 | 116 | 	int (*line_clfe_unmute)(struct ct_atc *atc, unsigned char state); | 
 | 117 | 	int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state); | 
 | 118 | 	int (*line_in_unmute)(struct ct_atc *atc, unsigned char state); | 
| Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 119 | 	int (*mic_unmute)(struct ct_atc *atc, unsigned char state); | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 120 | 	int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state); | 
 | 121 | 	int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state); | 
 | 122 | 	int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status); | 
 | 123 | 	int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status); | 
 | 124 | 	int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state); | 
| Harry Butterworth | b028b81 | 2011-06-11 17:41:13 +0800 | [diff] [blame] | 125 | 	struct capabilities (*capabilities)(struct ct_atc *atc); | 
| Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 126 | 	int (*output_switch_get)(struct ct_atc *atc); | 
 | 127 | 	int (*output_switch_put)(struct ct_atc *atc, int position); | 
| Harry Butterworth | 5530921 | 2011-06-11 16:02:06 +0800 | [diff] [blame] | 128 | 	int (*mic_source_switch_get)(struct ct_atc *atc); | 
 | 129 | 	int (*mic_source_switch_put)(struct ct_atc *atc, int position); | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 130 |  | 
 | 131 | 	/* Don't touch! Used for internal object. */ | 
 | 132 | 	void *rsc_mgrs[NUM_RSCTYP]; /* chip resource managers */ | 
 | 133 | 	void *mixer;		/* internal mixer object */ | 
 | 134 | 	void *hw;		/* chip specific hardware access object */ | 
 | 135 | 	void **daios;		/* digital audio io resources */ | 
 | 136 | 	void **pcm;		/* SUMs for collecting all pcm stream */ | 
 | 137 | 	void **srcs;		/* Sample Rate Converters for input signal */ | 
 | 138 | 	void **srcimps;		/* input mappers for SRCs */ | 
 | 139 | 	unsigned char n_daio; | 
 | 140 | 	unsigned char n_src; | 
 | 141 | 	unsigned char n_srcimp; | 
 | 142 | 	unsigned char n_pcm; | 
| Takashi Iwai | b7bbf87 | 2009-06-05 16:11:07 +0200 | [diff] [blame] | 143 |  | 
 | 144 | 	struct ct_timer *timer; | 
| Wai Yew CHAY | 29959a0 | 2009-06-22 14:52:34 +0200 | [diff] [blame] | 145 |  | 
 | 146 | #ifdef CONFIG_PM | 
 | 147 | 	int (*suspend)(struct ct_atc *atc, pm_message_t state); | 
 | 148 | 	int (*resume)(struct ct_atc *atc); | 
 | 149 | #define NUM_PCMS (NUM_CTALSADEVS - 1) | 
 | 150 | 	struct snd_pcm *pcms[NUM_PCMS]; | 
 | 151 | #endif | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 152 | }; | 
 | 153 |  | 
 | 154 |  | 
 | 155 | int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci, | 
| Takashi Iwai | 9470195 | 2009-06-08 18:10:32 +0200 | [diff] [blame] | 156 | 			    unsigned int rsr, unsigned int msr, int chip_type, | 
| Takashi Iwai | 408bffd | 2010-01-14 09:19:46 +0100 | [diff] [blame] | 157 | 			    unsigned int subsysid, struct ct_atc **ratc); | 
| Takashi Iwai | 2a36f67 | 2009-06-05 16:34:10 +0200 | [diff] [blame] | 158 | int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc); | 
| Wai Yew CHAY | 8cc7236 | 2009-05-14 08:05:58 +0200 | [diff] [blame] | 159 |  | 
 | 160 | #endif /* CTATC_H */ |