Path: blob/master/sound/soc/blackfin/bf5xx-sport.h
10817 views
/*1* File: bf5xx_sport.h2* Based on:3* Author: Roy Huang <[email protected]>4*5* Created:6* Description:7*8* Copyright 2004-2007 Analog Devices Inc.9*10* Bugs: Enter bugs at http://blackfin.uclinux.org/11*12* This program is free software; you can redistribute it and/or modify13* it under the terms of the GNU General Public License as published by14* the Free Software Foundation; either version 2 of the License, or15* (at your option) any later version.16*17* This program is distributed in the hope that it will be useful,18* but WITHOUT ANY WARRANTY; without even the implied warranty of19* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20* GNU General Public License for more details.21*22* You should have received a copy of the GNU General Public License23* along with this program; if not, see the file COPYING, or write24* to the Free Software Foundation, Inc.,25* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA26*/272829#ifndef __BF5XX_SPORT_H__30#define __BF5XX_SPORT_H__3132#include <linux/types.h>33#include <linux/wait.h>34#include <linux/workqueue.h>35#include <linux/platform_device.h>36#include <asm/dma.h>37#include <asm/bfin_sport.h>3839#define DESC_ELEMENT_COUNT 94041struct sport_device {42int num;43int dma_rx_chan;44int dma_tx_chan;45int err_irq;46const unsigned short *pin_req;47struct sport_register *regs;4849unsigned char *rx_buf;50unsigned char *tx_buf;51unsigned int rx_fragsize;52unsigned int tx_fragsize;53unsigned int rx_frags;54unsigned int tx_frags;55unsigned int wdsize;5657/* for dummy dma transfer */58void *dummy_buf;59unsigned int dummy_count;6061/* DMA descriptor ring head of current audio stream*/62struct dmasg *dma_rx_desc;63struct dmasg *dma_tx_desc;64unsigned int rx_desc_bytes;65unsigned int tx_desc_bytes;6667unsigned int rx_run:1; /* rx is running */68unsigned int tx_run:1; /* tx is running */6970struct dmasg *dummy_rx_desc;71struct dmasg *dummy_tx_desc;7273struct dmasg *curr_rx_desc;74struct dmasg *curr_tx_desc;7576int rx_curr_frag;77int tx_curr_frag;7879unsigned int rcr1;80unsigned int rcr2;81int rx_tdm_count;8283unsigned int tcr1;84unsigned int tcr2;85int tx_tdm_count;8687void (*rx_callback)(void *data);88void *rx_data;89void (*tx_callback)(void *data);90void *tx_data;91void (*err_callback)(void *data);92void *err_data;93unsigned char *tx_dma_buf;94unsigned char *rx_dma_buf;95#ifdef CONFIG_SND_BF5XX_MMAP_SUPPORT96dma_addr_t tx_dma_phy;97dma_addr_t rx_dma_phy;98int tx_pos;/*pcm sample count*/99int rx_pos;100unsigned int tx_buffer_size;101unsigned int rx_buffer_size;102int tx_delay_pos;103int once;104#endif105void *private_data;106};107108struct sport_param {109int num;110int dma_rx_chan;111int dma_tx_chan;112int err_irq;113const unsigned short *pin_req;114struct sport_register *regs;115unsigned int wdsize;116unsigned int dummy_count;117void *private_data;118};119120struct sport_device *sport_init(struct platform_device *pdev,121unsigned int wdsize, unsigned int dummy_count, size_t priv_size);122123void sport_done(struct sport_device *sport);124125/* first use these ...*/126127/* note: multichannel is in units of 8 channels, tdm_count is number of channels128* NOT / 8 ! all channels are enabled by default */129int sport_set_multichannel(struct sport_device *sport, int tdm_count,130u32 mask, int packed);131132int sport_config_rx(struct sport_device *sport,133unsigned int rcr1, unsigned int rcr2,134unsigned int clkdiv, unsigned int fsdiv);135136int sport_config_tx(struct sport_device *sport,137unsigned int tcr1, unsigned int tcr2,138unsigned int clkdiv, unsigned int fsdiv);139140/* ... then these: */141142/* buffer size (in bytes) == fragcount * fragsize_bytes */143144/* this is not a very general api, it sets the dma to 2d autobuffer mode */145146int sport_config_rx_dma(struct sport_device *sport, void *buf,147int fragcount, size_t fragsize_bytes);148149int sport_config_tx_dma(struct sport_device *sport, void *buf,150int fragcount, size_t fragsize_bytes);151152int sport_tx_start(struct sport_device *sport);153int sport_tx_stop(struct sport_device *sport);154int sport_rx_start(struct sport_device *sport);155int sport_rx_stop(struct sport_device *sport);156157/* for use in interrupt handler */158unsigned long sport_curr_offset_rx(struct sport_device *sport);159unsigned long sport_curr_offset_tx(struct sport_device *sport);160161void sport_incfrag(struct sport_device *sport, int *frag, int tx);162void sport_decfrag(struct sport_device *sport, int *frag, int tx);163164int sport_set_rx_callback(struct sport_device *sport,165void (*rx_callback)(void *), void *rx_data);166int sport_set_tx_callback(struct sport_device *sport,167void (*tx_callback)(void *), void *tx_data);168int sport_set_err_callback(struct sport_device *sport,169void (*err_callback)(void *), void *err_data);170171int sport_send_and_recv(struct sport_device *sport, u8 *out_data, \172u8 *in_data, int len);173#endif /* BF53X_SPORT_H */174175176