aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/aw2/aw2-saa7146.h
blob: 5b35e358937f8422b4263887fffd7efae917662a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*****************************************************************************
 *
 * Copyright (C) 2008 Cedric Bregardis <cedric.bregardis@free.fr> and
 * Jean-Christian Hassler <jhassler@free.fr>
 *
 * This file is part of the Audiowerk2 ALSA driver
 *
 * The Audiowerk2 ALSA driver is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2.
 *
 * The Audiowerk2 ALSA driver is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Audiowerk2 ALSA driver; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 *****************************************************************************/

#ifndef AW2_SAA7146_H
#define AW2_SAA7146_H

#define NB_STREAM_PLAYBACK 2
#define NB_STREAM_CAPTURE 1

#define NUM_STREAM_PLAYBACK_ANA 0
#define NUM_STREAM_PLAYBACK_DIG 1

#define NUM_STREAM_CAPTURE_ANA 0

typedef void (*snd_aw2_saa7146_it_cb) (void *);

struct snd_aw2_saa7146_cb_param {
	snd_aw2_saa7146_it_cb p_it_callback;
	void *p_callback_param;
};

/* definition of the chip-specific record */

struct snd_aw2_saa7146 {
	void __iomem *base_addr;
};

extern void snd_aw2_saa7146_setup(struct snd_aw2_saa7146 *chip,
				  void __iomem *pci_base_addr);
extern int snd_aw2_saa7146_free(struct snd_aw2_saa7146 *chip);

extern void snd_aw2_saa7146_pcm_init_playback(struct snd_aw2_saa7146 *chip,
					      int stream_number,
					      unsigned long dma_addr,
					      unsigned long period_size,
					      unsigned long buffer_size);
extern void snd_aw2_saa7146_pcm_init_capture(struct snd_aw2_saa7146 *chip,
					     int stream_number,
					     unsigned long dma_addr,
					     unsigned long period_size,
					     unsigned long buffer_size);
extern void snd_aw2_saa7146_define_it_playback_callback(unsigned int
							stream_number,
							snd_aw2_saa7146_it_cb
							p_it_callback,
							void *p_callback_param);
extern void snd_aw2_saa7146_define_it_capture_callback(unsigned int
						       stream_number,
						       snd_aw2_saa7146_it_cb
						       p_it_callback,
						       void *p_callback_param);
extern void snd_aw2_saa7146_pcm_trigger_start_capture(struct snd_aw2_saa7146
						      *chip, int stream_number);
extern void snd_aw2_saa7146_pcm_trigger_stop_capture(struct snd_aw2_saa7146
						     *chip, int stream_number);

extern void snd_aw2_saa7146_pcm_trigger_start_playback(struct snd_aw2_saa7146
						       *chip,
						       int stream_number);
extern void snd_aw2_saa7146_pcm_trigger_stop_playback(struct snd_aw2_saa7146
						      *chip, int stream_number);

extern irqreturn_t snd_aw2_saa7146_interrupt(int irq, void *dev_id);
extern unsigned int snd_aw2_saa7146_get_hw_ptr_playback(struct snd_aw2_saa7146
							*chip,
							int stream_number,
							unsigned char
							*start_addr,
							unsigned int
							buffer_size);
extern unsigned int snd_aw2_saa7146_get_hw_ptr_capture(struct snd_aw2_saa7146
						       *chip,
						       int stream_number,
						       unsigned char
						       *start_addr,
						       unsigned int
						       buffer_size);

extern void snd_aw2_saa7146_use_digital_input(struct snd_aw2_saa7146 *chip,
					      int use_digital);

extern int snd_aw2_saa7146_is_using_digital_input(struct snd_aw2_saa7146
						  *chip);

#endif
ass="p">{ if (!backup_state.empty() && backup_state.back().count(k) == 0) backup_state.back()[k] = current_state.count(k) ? new T(current_state.at(k)) : nullptr; current_state[k] = v; } void unset(const Key &k) { if (!backup_state.empty() && backup_state.back().count(k) == 0) backup_state.back()[k] = current_state.count(k) ? new T(current_state.at(k)) : nullptr; current_state.erase(k); } const T &get(const Key &k) { if (current_state.count(k) == 0) return empty_tuple; return current_state.at(k); } void reset(const Key &k) { for (int i = GetSize(backup_state)-1; i >= 0; i--) if (backup_state[i].count(k) != 0) { if (backup_state[i].at(k) == nullptr) current_state.erase(k); else current_state[k] = *backup_state[i].at(k); return; } current_state.erase(k); } const dict<Key, T, OPS> &stdmap() { return current_state; } void save() { backup_state.resize(backup_state.size()+1); } void restore() { log_assert(!backup_state.empty()); for (auto &it : backup_state.back()) if (it.second != nullptr) { current_state[it.first] = *it.second; delete it.second; } else current_state.erase(it.first); backup_state.pop_back(); } ~stackmap() { while (!backup_state.empty()) restore(); } }; // ------------------------------------------------ // A simple class for topological sorting // ------------------------------------------------ template<typename T, typename C = std::less<T>> struct TopoSort { bool analyze_loops, found_loops; std::map<T, std::set<T, C>, C> database; std::set<std::set<T, C>> loops; std::vector<T> sorted; TopoSort() { analyze_loops = true; found_loops = false; } void node(T n) { if (database.count(n) == 0) database[n] = std::set<T, C>(); } void edge(T left, T right) { node(left); database[right].insert(left); } void sort_worker(const T &n, std::set<T, C> &marked_cells, std::set<T, C> &active_cells, std::vector<T> &active_stack) { if (active_cells.count(n)) { found_loops = true; if (analyze_loops) { std::set<T, C> loop; for (int i = GetSize(active_stack)-1; i >= 0; i--) { loop.insert(active_stack[i]); if (active_stack[i] == n) break; } loops.insert(loop); } return; } if (marked_cells.count(n)) return; if (!database.at(n).empty()) { if (analyze_loops) active_stack.push_back(n); active_cells.insert(n); for (auto &left_n : database.at(n)) sort_worker(left_n, marked_cells, active_cells, active_stack); if (analyze_loops) active_stack.pop_back(); active_cells.erase(n); } marked_cells.insert(n); sorted.push_back(n); } bool sort() { loops.clear(); sorted.clear(); found_loops = false; std::set<T, C> marked_cells; std::set<T, C> active_cells; std::vector<T> active_stack; for (auto &it : database) sort_worker(it.first, marked_cells, active_cells, active_stack); log_assert(GetSize(sorted) == GetSize(database)); return !found_loops; } }; YOSYS_NAMESPACE_END #endif