| 1 | /* |
| 2 | * sound/ubicom32/ubi32.h |
| 3 | * Common header file for all ubi32- sound drivers |
| 4 | * |
| 5 | * (C) Copyright 2009, Ubicom, Inc. |
| 6 | * |
| 7 | * This file is part of the Ubicom32 Linux Kernel Port. |
| 8 | * |
| 9 | * The Ubicom32 Linux Kernel Port is free software: you can redistribute |
| 10 | * it and/or modify it under the terms of the GNU General Public License |
| 11 | * as published by the Free Software Foundation, either version 2 of the |
| 12 | * License, or (at your option) any later version. |
| 13 | * |
| 14 | * The Ubicom32 Linux Kernel Port is distributed in the hope that it |
| 15 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
| 16 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 17 | * the GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with the Ubicom32 Linux Kernel Port. If not, |
| 21 | * see <http://www.gnu.org/licenses/>. |
| 22 | */ |
| 23 | |
| 24 | #ifndef _UBI32_H |
| 25 | #define _UBI32_H |
| 26 | |
| 27 | #define SND_UBI32_DEBUG 0 // Debug flag |
| 28 | |
| 29 | #include <linux/platform_device.h> |
| 30 | #include <asm/devtree.h> |
| 31 | #include <asm/audio.h> |
| 32 | #include <asm/ubi32-pcm.h> |
| 33 | |
| 34 | struct ubi32_snd_priv; |
| 35 | |
| 36 | typedef int (*set_channels_t)(struct ubi32_snd_priv *priv, int channels); |
| 37 | typedef int (*set_rate_t)(struct ubi32_snd_priv *priv, int rate); |
| 38 | |
| 39 | struct ubi32_snd_priv { |
| 40 | /* |
| 41 | * Any variables that are needed locally here but NOT in |
| 42 | * the VP itself should go in here. |
| 43 | */ |
| 44 | struct snd_card *card; |
| 45 | struct snd_pcm *pcm; |
| 46 | |
| 47 | /* |
| 48 | * capture (1) or playback (0) |
| 49 | */ |
| 50 | int is_capture; |
| 51 | /* |
| 52 | * DAC parameters. These are the parameters for the specific |
| 53 | * DAC we are driving. The I2S component can run at a range |
| 54 | * of frequencies, but the DAC may be limited. We may want |
| 55 | * to make this an array of some sort in the future? |
| 56 | * |
| 57 | * min/max_sample_rate if set to 0 are ignored. |
| 58 | */ |
| 59 | int max_sample_rate; |
| 60 | int min_sample_rate; |
| 61 | |
| 62 | /* |
| 63 | * The size a period (group) of audio samples. The VP does |
| 64 | * not need to know this; each DMA transfer is made to be |
| 65 | * one period. |
| 66 | */ |
| 67 | u32_t period_size; |
| 68 | |
| 69 | spinlock_t ubi32_lock; |
| 70 | |
| 71 | struct audio_regs *ar; |
| 72 | struct audio_dev_regs *adr; |
| 73 | u32 irq_idx; |
| 74 | u8 tx_irq; |
| 75 | u8 rx_irq; |
| 76 | |
| 77 | void *client; |
| 78 | |
| 79 | /* |
| 80 | * Operations which the base DAC driver can implement |
| 81 | */ |
| 82 | set_channels_t set_channels; |
| 83 | set_rate_t set_rate; |
| 84 | |
| 85 | /* |
| 86 | * platform data |
| 87 | */ |
| 88 | struct ubi32pcm_platform_data *pdata; |
| 89 | |
| 90 | /* |
| 91 | * Private driver data (used for DAC driver control, etc) |
| 92 | */ |
| 93 | void *drvdata; |
| 94 | }; |
| 95 | |
| 96 | #define snd_ubi32_priv_get_drv(priv) ((priv)->drvdata) |
| 97 | #define snd_ubi32_priv_set_drv(priv, data) (((priv)->drvdata) = (void *)(data)) |
| 98 | |
| 99 | extern int snd_ubi32_pcm_probe(struct ubi32_snd_priv *ubi32_priv, struct platform_device *pdev); |
| 100 | extern void snd_ubi32_pcm_remove(struct ubi32_snd_priv *ubi32_priv); |
| 101 | |
| 102 | #endif |
| 103 | |