ctatc.h 5.4 KB
Newer Older
W
Wai Yew CHAY 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/**
 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
 *
 * This source file is released under GPL v2 license (no other versions).
 * See the COPYING file included in the main directory of this source
 * distribution for the license terms and conditions.
 *
 * @File	ctatc.h
 *
 * @Brief
 * This file contains the definition of the device resource management object.
 *
 * @Author	Liu Chun
 * @Date 	Mar 28 2008
 *
 */

#ifndef CTATC_H
#define CTATC_H

#include <linux/types.h>
22
#include <linux/mutex.h>
W
Wai Yew CHAY 已提交
23 24 25 26 27 28 29 30 31 32
#include <linux/pci.h>
#include <linux/timer.h>
#include <sound/core.h>

#include "ctvmem.h"
#include "ctresource.h"

enum CTALSADEVS {		/* Types of alsa devices */
	FRONT,
	SURROUND,
33 34
	CLFE,
	SIDE,
W
Wai Yew CHAY 已提交
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
	IEC958,
	MIXER,
	NUM_CTALSADEVS		/* This should always be the last */
};

struct ct_atc_chip_sub_details {
	u16 subsys;
	const char *nm_model;
};

struct ct_atc_chip_details {
	u16 vendor;
	u16 device;
	const struct ct_atc_chip_sub_details *sub_details;
	const char *nm_card;
};

struct ct_atc;
53 54
struct ct_timer;
struct ct_timer_instance;
W
Wai Yew CHAY 已提交
55 56 57 58 59

/* alsa pcm stream descriptor */
struct ct_atc_pcm {
	struct snd_pcm_substream *substream;
	void (*interrupt)(struct ct_atc_pcm *apcm);
60
	struct ct_timer_instance *timer;
W
Wai Yew CHAY 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
	unsigned int started:1;

	/* Only mono and interleaved modes are supported now. */
	struct ct_vm_block *vm_block;
	void *src;		/* SRC for interacting with host memory */
	void **srccs;		/* SRCs for sample rate conversion */
	void **srcimps;		/* SRC Input Mappers */
	void **amixers;		/* AMIXERs for routing converted data */
	void *mono;		/* A SUM resource for mixing chs to one */
	unsigned char n_srcc;	/* Number of converting SRCs */
	unsigned char n_srcimp;	/* Number of SRC Input Mappers */
	unsigned char n_amixer;	/* Number of AMIXERs */
};

/* Chip resource management object */
struct ct_atc {
	struct pci_dev *pci;
	struct snd_card *card;
	unsigned int rsr; /* reference sample rate in Hz */
	unsigned int msr; /* master sample rate in rsr */
	unsigned int pll_rate; /* current rate of Phase Lock Loop */

83 84 85 86
	int chip_type;
	int model;
	const char *chip_name;
	const char *model_name;
W
Wai Yew CHAY 已提交
87 88 89 90 91 92

	struct ct_vm *vm; /* device virtual memory manager for this card */
	int (*map_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
	void (*unmap_audio_buffer)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
	unsigned long (*get_ptp_phys)(struct ct_atc *atc, int index);

93
	struct mutex atc_mutex;
W
Wai Yew CHAY 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

	int (*pcm_playback_prepare)(struct ct_atc *atc,
				    struct ct_atc_pcm *apcm);
	int (*pcm_playback_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
	int (*pcm_playback_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
	int (*pcm_playback_position)(struct ct_atc *atc,
				     struct ct_atc_pcm *apcm);
	int (*spdif_passthru_playback_prepare)(struct ct_atc *atc,
					       struct ct_atc_pcm *apcm);
	int (*pcm_capture_prepare)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
	int (*pcm_capture_start)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
	int (*pcm_capture_stop)(struct ct_atc *atc, struct ct_atc_pcm *apcm);
	int (*pcm_capture_position)(struct ct_atc *atc,
				    struct ct_atc_pcm *apcm);
	int (*pcm_release_resources)(struct ct_atc *atc,
				     struct ct_atc_pcm *apcm);
	int (*select_line_in)(struct ct_atc *atc);
	int (*select_mic_in)(struct ct_atc *atc);
	int (*select_digit_io)(struct ct_atc *atc);
	int (*line_front_unmute)(struct ct_atc *atc, unsigned char state);
	int (*line_surround_unmute)(struct ct_atc *atc, unsigned char state);
	int (*line_clfe_unmute)(struct ct_atc *atc, unsigned char state);
	int (*line_rear_unmute)(struct ct_atc *atc, unsigned char state);
	int (*line_in_unmute)(struct ct_atc *atc, unsigned char state);
118
	int (*mic_unmute)(struct ct_atc *atc, unsigned char state);
W
Wai Yew CHAY 已提交
119 120 121 122 123 124
	int (*spdif_out_unmute)(struct ct_atc *atc, unsigned char state);
	int (*spdif_in_unmute)(struct ct_atc *atc, unsigned char state);
	int (*spdif_out_get_status)(struct ct_atc *atc, unsigned int *status);
	int (*spdif_out_set_status)(struct ct_atc *atc, unsigned int status);
	int (*spdif_out_passthru)(struct ct_atc *atc, unsigned char state);
	int (*have_digit_io_switch)(struct ct_atc *atc);
125 126 127 128 129 130 131
	int (*have_dedicated_mic)(struct ct_atc *atc);
	int (*have_output_switch)(struct ct_atc *atc);
	int (*output_switch_get)(struct ct_atc *atc);
	int (*output_switch_put)(struct ct_atc *atc, int position);
	int (*have_mic_source_switch)(struct ct_atc *atc);
	int (*mic_source_switch_get)(struct ct_atc *atc);
	int (*mic_source_switch_put)(struct ct_atc *atc, int position);
W
Wai Yew CHAY 已提交
132 133 134 135 136 137 138 139 140 141 142 143 144

	/* Don't touch! Used for internal object. */
	void *rsc_mgrs[NUM_RSCTYP]; /* chip resource managers */
	void *mixer;		/* internal mixer object */
	void *hw;		/* chip specific hardware access object */
	void **daios;		/* digital audio io resources */
	void **pcm;		/* SUMs for collecting all pcm stream */
	void **srcs;		/* Sample Rate Converters for input signal */
	void **srcimps;		/* input mappers for SRCs */
	unsigned char n_daio;
	unsigned char n_src;
	unsigned char n_srcimp;
	unsigned char n_pcm;
145 146

	struct ct_timer *timer;
W
Wai Yew CHAY 已提交
147 148 149 150 151 152 153

#ifdef CONFIG_PM
	int (*suspend)(struct ct_atc *atc, pm_message_t state);
	int (*resume)(struct ct_atc *atc);
#define NUM_PCMS (NUM_CTALSADEVS - 1)
	struct snd_pcm *pcms[NUM_PCMS];
#endif
W
Wai Yew CHAY 已提交
154 155 156 157
};


int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
158
			    unsigned int rsr, unsigned int msr, int chip_type,
159
			    unsigned int subsysid, struct ct_atc **ratc);
T
Takashi Iwai 已提交
160
int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc);
W
Wai Yew CHAY 已提交
161 162

#endif /* CTATC_H */