aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ubicom32/files/sound/ubicom32/ubi32.h
blob: f43a2150b4336f9ce09dc610d331ff9a1da2bc73 (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
/*
 * sound/ubicom32/ubi32.h
 *	Common header file for all ubi32- sound drivers
 *
 * (C) Copyright 2009, Ubicom, Inc.
 *
 * This file is part of the Ubicom32 Linux Kernel Port.
 *
 * The Ubicom32 Linux Kernel Port 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, either version 2 of the
 * License, or (at your option) any later version.
 *
 * The Ubicom32 Linux Kernel Port 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 Ubicom32 Linux Kernel Port.  If not,
 * see <http://www.gnu.org/licenses/>.
 */

#ifndef _UBI32_H
#define _UBI32_H

#define SND_UBI32_DEBUG 0 // Debug flag

#include <linux/platform_device.h>
#include <asm/devtree.h>
#include <asm/audio.h>
#include <asm/ubi32-pcm.h>

struct ubi32_snd_priv;

typedef int (*set_channels_t)(struct ubi32_snd_priv *priv, int channels);
typedef int (*set_rate_t)(struct ubi32_snd_priv *priv, int rate);

struct ubi32_snd_priv {
	/*
	 * Any variables that are needed locally here but NOT in
	 * the VP itself should go in here.
	 */
	struct snd_card *card;
	struct snd_pcm *pcm;

	/*
	 * capture (1) or playback (0)
	 */
	int is_capture;
	/*
	 * DAC parameters.  These are the parameters for the specific
	 * DAC we are driving.  The I2S component can run at a range
	 * of frequencies, but the DAC may be limited.  We may want
	 * to make this an array of some sort in the future?
	 *
	 * min/max_sample_rate if set to 0 are ignored.
	 */
	int max_sample_rate;
	int min_sample_rate;

	/*
	 * The size a period (group) of audio samples.  The VP does
	 * not need to know this; each DMA transfer is made to be
	 * one period.
	 */
	u32_t period_size;

	spinlock_t ubi32_lock;

	struct audio_regs *ar;
	struct audio_dev_regs *adr;
	u32 irq_idx;
	u8 tx_irq;
	u8 rx_irq;

	void *client;

	/*
	 * Operations which the base DAC driver can implement
	 */
	set_channels_t set_channels;
	set_rate_t set_rate;

	/*
	 * platform data
	 */
	struct ubi32pcm_platform_data *pdata;

	/*
	 * Private driver data (used for DAC driver control, etc)
	 */
	void *drvdata;
};

#define snd_ubi32_priv_get_drv(priv) ((priv)->drvdata)
#define snd_ubi32_priv_set_drv(priv, data) (((priv)->drvdata) = (void *)(data))

extern int snd_ubi32_pcm_probe(struct ubi32_snd_priv *ubi32_priv, struct platform_device *pdev);
extern void snd_ubi32_pcm_remove(struct ubi32_snd_priv *ubi32_priv);

#endif