diff options
-rw-r--r-- | linux/sound/oss/btaudio.c | 1156 | ||||
-rw-r--r-- | v4l/Kconfig.sound | 26 | ||||
-rw-r--r-- | v4l/Makefile.sound | 11 | ||||
-rw-r--r-- | v4l_experimental/firesat/Kconfig | 11 | ||||
-rw-r--r-- | v4l_experimental/firesat/Makefile | 11 | ||||
-rw-r--r-- | v4l_experimental/firesat/avc_api.c | 953 | ||||
-rw-r--r-- | v4l_experimental/firesat/avc_api.h | 435 | ||||
-rw-r--r-- | v4l_experimental/firesat/cmp.c | 176 | ||||
-rw-r--r-- | v4l_experimental/firesat/cmp.h | 9 | ||||
-rw-r--r-- | v4l_experimental/firesat/firesat-ci.c | 124 | ||||
-rw-r--r-- | v4l_experimental/firesat/firesat-ci.h | 9 | ||||
-rw-r--r-- | v4l_experimental/firesat/firesat-rc.c | 83 | ||||
-rw-r--r-- | v4l_experimental/firesat/firesat-rc.h | 9 | ||||
-rw-r--r-- | v4l_experimental/firesat/firesat.c | 917 | ||||
-rw-r--r-- | v4l_experimental/firesat/firesat.h | 72 |
15 files changed, 0 insertions, 4002 deletions
diff --git a/linux/sound/oss/btaudio.c b/linux/sound/oss/btaudio.c deleted file mode 100644 index cf10bf82a..000000000 --- a/linux/sound/oss/btaudio.c +++ /dev/null @@ -1,1156 +0,0 @@ -/* - btaudio - bt878 audio dma driver for linux 2.4.x - - (c) 2000-2002 Gerd Knorr <kraxel@bytesex.org> - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include <linux/module.h> -#include <linux/errno.h> -#include <linux/pci.h> -#include <linux/sched.h> -#include <linux/signal.h> -#include <linux/types.h> -#include <linux/interrupt.h> -#include <linux/init.h> -#include <linux/poll.h> -#include <linux/sound.h> -#include <linux/soundcard.h> -#include <linux/slab.h> -#include <linux/kdev_t.h> -#include <linux/mutex.h> - -#include <asm/uaccess.h> -#include <asm/io.h> -#include "compat.h" - - -/* mmio access */ -#define btwrite(dat,adr) writel((dat), (bta->mmio+(adr))) -#define btread(adr) readl(bta->mmio+(adr)) - -#define btand(dat,adr) btwrite((dat) & btread(adr), adr) -#define btor(dat,adr) btwrite((dat) | btread(adr), adr) -#define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr) - -/* registers (shifted because bta->mmio is long) */ -#define REG_INT_STAT (0x100 >> 2) -#define REG_INT_MASK (0x104 >> 2) -#define REG_GPIO_DMA_CTL (0x10c >> 2) -#define REG_PACKET_LEN (0x110 >> 2) -#define REG_RISC_STRT_ADD (0x114 >> 2) -#define REG_RISC_COUNT (0x120 >> 2) - -/* IRQ bits - REG_INT_(STAT|MASK) */ -#define IRQ_SCERR (1 << 19) -#define IRQ_OCERR (1 << 18) -#define IRQ_PABORT (1 << 17) -#define IRQ_RIPERR (1 << 16) -#define IRQ_PPERR (1 << 15) -#define IRQ_FDSR (1 << 14) -#define IRQ_FTRGT (1 << 13) -#define IRQ_FBUS (1 << 12) -#define IRQ_RISCI (1 << 11) -#define IRQ_OFLOW (1 << 3) - -#define IRQ_BTAUDIO (IRQ_SCERR | IRQ_OCERR | IRQ_PABORT | IRQ_RIPERR |\ - IRQ_PPERR | IRQ_FDSR | IRQ_FTRGT | IRQ_FBUS |\ - IRQ_RISCI) - -/* REG_GPIO_DMA_CTL bits */ -#define DMA_CTL_A_PWRDN (1 << 26) -#define DMA_CTL_DA_SBR (1 << 14) -#define DMA_CTL_DA_ES2 (1 << 13) -#define DMA_CTL_ACAP_EN (1 << 4) -#define DMA_CTL_RISC_EN (1 << 1) -#define DMA_CTL_FIFO_EN (1 << 0) - -/* RISC instructions */ -#define RISC_WRITE (0x01 << 28) -#define RISC_JUMP (0x07 << 28) -#define RISC_SYNC (0x08 << 28) - -/* RISC bits */ -#define RISC_WR_SOL (1 << 27) -#define RISC_WR_EOL (1 << 26) -#define RISC_IRQ (1 << 24) -#define RISC_SYNC_RESYNC (1 << 15) -#define RISC_SYNC_FM1 0x06 -#define RISC_SYNC_VRO 0x0c - -#define HWBASE_AD (448000) - -/* -------------------------------------------------------------- */ - -struct btaudio { - /* linked list */ - struct btaudio *next; - - /* device info */ - int dsp_digital; - int dsp_analog; - int mixer_dev; - struct pci_dev *pci; - unsigned int irq; - unsigned long mem; - unsigned long __iomem *mmio; - - /* locking */ - int users; - struct mutex lock; - - /* risc instructions */ - unsigned int risc_size; - unsigned long *risc_cpu; - dma_addr_t risc_dma; - - /* audio data */ - unsigned int buf_size; - unsigned char *buf_cpu; - dma_addr_t buf_dma; - - /* buffer setup */ - int line_bytes; - int line_count; - int block_bytes; - int block_count; - - /* read fifo management */ - int recording; - int dma_block; - int read_offset; - int read_count; - wait_queue_head_t readq; - - /* settings */ - int gain[3]; - int source; - int bits; - int decimation; - int mixcount; - int sampleshift; - int channels; - int analog; - int rate; -}; - -struct cardinfo { - char *name; - int rate; -}; - -static struct btaudio *btaudios; -static unsigned int debug; -static unsigned int irq_debug; - -/* -------------------------------------------------------------- */ - -#define BUF_DEFAULT 128*1024 -#define BUF_MIN 8192 - -static int alloc_buffer(struct btaudio *bta) -{ - if (NULL == bta->buf_cpu) { - for (bta->buf_size = BUF_DEFAULT; bta->buf_size >= BUF_MIN; - bta->buf_size = bta->buf_size >> 1) { - bta->buf_cpu = pci_alloc_consistent - (bta->pci, bta->buf_size, &bta->buf_dma); - if (NULL != bta->buf_cpu) - break; - } - if (NULL == bta->buf_cpu) - return -ENOMEM; - memset(bta->buf_cpu,0,bta->buf_size); - } - if (NULL == bta->risc_cpu) { - bta->risc_size = PAGE_SIZE; - bta->risc_cpu = pci_alloc_consistent - (bta->pci, bta->risc_size, &bta->risc_dma); - if (NULL == bta->risc_cpu) { - pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->buf_dma); - bta->buf_cpu = NULL; - return -ENOMEM; - } - } - return 0; -} - -static void free_buffer(struct btaudio *bta) -{ - if (NULL != bta->buf_cpu) { - pci_free_consistent(bta->pci, bta->buf_size, - bta->buf_cpu, bta->buf_dma); - bta->buf_cpu = NULL; - } - if (NULL != bta->risc_cpu) { - pci_free_consistent(bta->pci, bta->risc_size, - bta->risc_cpu, bta->risc_dma); - bta->risc_cpu = NULL; - } -} - -static int make_risc(struct btaudio *bta) -{ - int rp, bp, line, block; - unsigned long risc; - - bta->block_bytes = bta->buf_size >> 4; - bta->block_count = 1 << 4; - bta->line_bytes = bta->block_bytes; - bta->line_count = bta->block_count; - while (bta->line_bytes > 4095) { - bta->line_bytes >>= 1; - bta->line_count <<= 1; - } - if (bta->line_count > 255) - return -EINVAL; - if (debug) - printk(KERN_DEBUG - "btaudio: bufsize=%d - bs=%d bc=%d - ls=%d, lc=%d\n", - bta->buf_size,bta->block_bytes,bta->block_count, - bta->line_bytes,bta->line_count); - rp = 0; bp = 0; - block = 0; - bta->risc_cpu[rp++] = cpu_to_le32(RISC_SYNC|RISC_SYNC_FM1); - bta->risc_cpu[rp++] = cpu_to_le32(0); - for (line = 0; line < bta->line_count; line++) { - risc = RISC_WRITE | RISC_WR_SOL | RISC_WR_EOL; - risc |= bta->line_bytes; - if (0 == (bp & (bta->block_bytes-1))) { - risc |= RISC_IRQ; - risc |= (block & 0x0f) << 16; - risc |= (~block & 0x0f) << 20; - block++; - } - bta->risc_cpu[rp++] = cpu_to_le32(risc); - bta->risc_cpu[rp++] = cpu_to_le32(bta->buf_dma + bp); - bp += bta->line_bytes; - } - bta->risc_cpu[rp++] = cpu_to_le32(RISC_SYNC|RISC_SYNC_VRO); - bta->risc_cpu[rp++] = cpu_to_le32(0); - bta->risc_cpu[rp++] = cpu_to_le32(RISC_JUMP); - bta->risc_cpu[rp++] = cpu_to_le32(bta->risc_dma); - return 0; -} - -static int start_recording(struct btaudio *bta) -{ - int ret; - - if (0 != (ret = alloc_buffer(bta))) - return ret; - if (0 != (ret = make_risc(bta))) - return ret; - - btwrite(bta->risc_dma, REG_RISC_STRT_ADD); - btwrite((bta->line_count << 16) | bta->line_bytes, - REG_PACKET_LEN); - btwrite(IRQ_BTAUDIO, REG_INT_MASK); - if (bta->analog) { - btwrite(DMA_CTL_ACAP_EN | - DMA_CTL_RISC_EN | - DMA_CTL_FIFO_EN | - DMA_CTL_DA_ES2 | - ((bta->bits == 8) ? DMA_CTL_DA_SBR : 0) | - (bta->gain[bta->source] << 28) | - (bta->source << 24) | - (bta->decimation << 8), - REG_GPIO_DMA_CTL); - } else { - btwrite(DMA_CTL_ACAP_EN | - DMA_CTL_RISC_EN | - DMA_CTL_FIFO_EN | - DMA_CTL_DA_ES2 | - DMA_CTL_A_PWRDN | - (1 << 6) | - ((bta->bits == 8) ? DMA_CTL_DA_SBR : 0) | - (bta->gain[bta->source] << 28) | - (bta->source << 24) | - (bta->decimation << 8), - REG_GPIO_DMA_CTL); - } - bta->dma_block = 0; - bta->read_offset = 0; - bta->read_count = 0; - bta->recording = 1; - if (debug) - printk(KERN_DEBUG "btaudio: recording started\n"); - return 0; -} - -static void stop_recording(struct btaudio *bta) -{ - btand(~15, REG_GPIO_DMA_CTL); - bta->recording = 0; - if (debug) - printk(KERN_DEBUG "btaudio: recording stopped\n"); -} - - -/* -------------------------------------------------------------- */ - -static int btaudio_mixer_open(struct inode *inode, struct file *file) -{ - int minor = iminor(inode); - struct btaudio *bta; - - for (bta = btaudios; bta != NULL; bta = bta->next) - if (bta->mixer_dev == minor) - break; - if (NULL == bta) - return -ENODEV; - - if (debug) - printk("btaudio: open mixer [%d]\n",minor); - file->private_data = bta; - return 0; -} - -static int btaudio_mixer_release(struct inode *inode, struct file *file) -{ - return 0; -} - -static int btaudio_mixer_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - struct btaudio *bta = file->private_data; - int ret,val=0,i=0; - void __user *argp = (void __user *)arg; - - if (cmd == SOUND_MIXER_INFO) { - mixer_info info; - memset(&info,0,sizeof(info)); - strlcpy(info.id,"bt878",sizeof(info.id)); - strlcpy(info.name,"Brooktree Bt878 audio",sizeof(info.name)); - info.modify_counter = bta->mixcount; - if (copy_to_user(argp, &info, sizeof(info))) - return -EFAULT; - return 0; - } - if (cmd == SOUND_OLD_MIXER_INFO) { - _old_mixer_info info; - memset(&info,0,sizeof(info)); - strlcpy(info.id, "bt878", sizeof(info.id)); - strlcpy(info.name,"Brooktree Bt878 audio",sizeof(info.name)); - if (copy_to_user(argp, &info, sizeof(info))) - return -EFAULT; - return 0; - } - if (cmd == OSS_GETVERSION) - return put_user(SOUND_VERSION, (int __user *)argp); - - /* read */ - if (_SIOC_DIR(cmd) & _SIOC_WRITE) - if (get_user(val, (int __user *)argp)) - return -EFAULT; - - switch (cmd) { - case MIXER_READ(SOUND_MIXER_CAPS): - ret = SOUND_CAP_EXCL_INPUT; - break; - case MIXER_READ(SOUND_MIXER_STEREODEVS): - ret = 0; - break; - case MIXER_READ(SOUND_MIXER_RECMASK): - case MIXER_READ(SOUND_MIXER_DEVMASK): - ret = SOUND_MASK_LINE1|SOUND_MASK_LINE2|SOUND_MASK_LINE3; - break; - - case MIXER_WRITE(SOUND_MIXER_RECSRC): - if (val & SOUND_MASK_LINE1 && bta->source != 0) - bta->source = 0; - else if (val & SOUND_MASK_LINE2 && bta->source != 1) - bta->source = 1; - else if (val & SOUND_MASK_LINE3 && bta->source != 2) - bta->source = 2; - btaor((bta->gain[bta->source] << 28) | - (bta->source << 24), - 0x0cffffff, REG_GPIO_DMA_CTL); - case MIXER_READ(SOUND_MIXER_RECSRC): - switch (bta->source) { - case 0: ret = SOUND_MASK_LINE1; break; - case 1: ret = SOUND_MASK_LINE2; break; - case 2: ret = SOUND_MASK_LINE3; break; - default: ret = 0; - } - break; - - case MIXER_WRITE(SOUND_MIXER_LINE1): - case MIXER_WRITE(SOUND_MIXER_LINE2): - case MIXER_WRITE(SOUND_MIXER_LINE3): - if (MIXER_WRITE(SOUND_MIXER_LINE1) == cmd) - i = 0; - if (MIXER_WRITE(SOUND_MIXER_LINE2) == cmd) - i = 1; - if (MIXER_WRITE(SOUND_MIXER_LINE3) == cmd) - i = 2; - bta->gain[i] = (val & 0xff) * 15 / 100; - if (bta->gain[i] > 15) bta->gain[i] = 15; - if (bta->gain[i] < 0) bta->gain[i] = 0; - if (i == bta->source) - btaor((bta->gain[bta->source]<<28), - 0x0fffffff, REG_GPIO_DMA_CTL); - ret = bta->gain[i] * 100 / 15; - ret |= ret << 8; - break; - - case MIXER_READ(SOUND_MIXER_LINE1): - case MIXER_READ(SOUND_MIXER_LINE2): - case MIXER_READ(SOUND_MIXER_LINE3): - if (MIXER_READ(SOUND_MIXER_LINE1) == cmd) - i = 0; - if (MIXER_READ(SOUND_MIXER_LINE2) == cmd) - i = 1; - if (MIXER_READ(SOUND_MIXER_LINE3) == cmd) - i = 2; - ret = bta->gain[i] * 100 / 15; - ret |= ret << 8; - break; - - default: - return -EINVAL; - } - if (put_user(ret, (int __user *)argp)) - return -EFAULT; - return 0; -} - -static const struct file_operations btaudio_mixer_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .open = btaudio_mixer_open, - .release = btaudio_mixer_release, - .ioctl = btaudio_mixer_ioctl, -}; - -/* -------------------------------------------------------------- */ - -static int btaudio_dsp_open(struct inode *inode, struct file *file, - struct btaudio *bta, int analog) -{ - mutex_lock(&bta->lock); - if (bta->users) - goto busy; - bta->users++; - file->private_data = bta; - - bta->analog = analog; - bta->dma_block = 0; - bta->read_offset = 0; - bta->read_count = 0; - bta->sampleshift = 0; - - mutex_unlock(&bta->lock); - return 0; - - busy: - mutex_unlock(&bta->lock); - return -EBUSY; -} - -static int btaudio_dsp_open_digital(struct inode *inode, struct file *file) -{ - int minor = iminor(inode); - struct btaudio *bta; - - for (bta = btaudios; bta != NULL; bta = bta->next) - if (bta->dsp_digital == minor) - break; - if (NULL == bta) - return -ENODEV; - - if (debug) - printk("btaudio: open digital dsp [%d]\n",minor); - return btaudio_dsp_open(inode,file,bta,0); -} - -static int btaudio_dsp_open_analog(struct inode *inode, struct file *file) -{ - int minor = iminor(inode); - struct btaudio *bta; - - for (bta = btaudios; bta != NULL; bta = bta->next) - if (bta->dsp_analog == minor) - break; - if (NULL == bta) - return -ENODEV; - - if (debug) - printk("btaudio: open analog dsp [%d]\n",minor); - return btaudio_dsp_open(inode,file,bta,1); -} - -static int btaudio_dsp_release(struct inode *inode, struct file *file) -{ - struct btaudio *bta = file->private_data; - - mutex_lock(&bta->lock); - if (bta->recording) - stop_recording(bta); - bta->users--; - mutex_unlock(&bta->lock); - return 0; -} - -static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer, - size_t swcount, loff_t *ppos) -{ - struct btaudio *bta = file->private_data; - int hwcount = swcount << bta->sampleshift; - int nsrc, ndst, err, ret = 0; - DECLARE_WAITQUEUE(wait, current); - - add_wait_queue(&bta->readq, &wait); - mutex_lock(&bta->lock); - while (swcount > 0) { - if (0 == bta->read_count) { - if (!bta->recording) { - if (0 != (err = start_recording(bta))) { - if (0 == ret) - ret = err; - break; - } - } - if (file->f_flags & O_NONBLOCK) { - if (0 == ret) - ret = -EAGAIN; - break; - } - mutex_unlock(&bta->lock); - current->state = TASK_INTERRUPTIBLE; - schedule(); - mutex_lock(&bta->lock); - if(signal_pending(current)) { - if (0 == ret) - ret = -EINTR; - break; - } - } - nsrc = (bta->read_count < hwcount) ? bta->read_count : hwcount; - if (nsrc > bta->buf_size - bta->read_offset) - nsrc = bta->buf_size - bta->read_offset; - ndst = nsrc >> bta->sampleshift; - - if ((bta->analog && 0 == bta->sampleshift) || - (!bta->analog && 2 == bta->channels)) { - /* just copy */ - if (copy_to_user(buffer + ret, bta->buf_cpu + bta->read_offset, nsrc)) { - if (0 == ret) - ret = -EFAULT; - break; - } - - } else if (!bta->analog) { - /* stereo => mono (digital audio) */ - __s16 *src = (__s16*)(bta->buf_cpu + bta->read_offset); - __s16 __user *dst = (__s16 __user *)(buffer + ret); - __s16 avg; - int n = ndst>>1; - if (!access_ok(VERIFY_WRITE, dst, ndst)) { - if (0 == ret) - ret = -EFAULT; - break; - } - for (; n; n--, dst++) { - avg = (__s16)le16_to_cpu(*src) / 2; src++; - avg += (__s16)le16_to_cpu(*src) / 2; src++; - __put_user(cpu_to_le16(avg),dst); - } - - } else if (8 == bta->bits) { - /* copy + byte downsampling (audio A/D) */ - __u8 *src = bta->buf_cpu + bta->read_offset; - __u8 __user *dst = buffer + ret; - int n = ndst; - if (!access_ok(VERIFY_WRITE, dst, ndst)) { - if (0 == ret) - ret = -EFAULT; - break; - } - for (; n; n--, src += (1 << bta->sampleshift), dst++) - __put_user(*src, dst); - - } else { - /* copy + word downsampling (audio A/D) */ - __u16 *src = (__u16*)(bta->buf_cpu + bta->read_offset); - __u16 __user *dst = (__u16 __user *)(buffer + ret); - int n = ndst>>1; - if (!access_ok(VERIFY_WRITE,dst,ndst)) { - if (0 == ret) - ret = -EFAULT; - break; - } - for (; n; n--, src += (1 << bta->sampleshift), dst++) - __put_user(*src, dst); - } - - ret += ndst; - swcount -= ndst; - hwcount -= nsrc; - bta->read_count -= nsrc; - bta->read_offset += nsrc; - if (bta->read_offset == bta->buf_size) - bta->read_offset = 0; - } - mutex_unlock(&bta->lock); - remove_wait_queue(&bta->readq, &wait); - current->state = TASK_RUNNING; - return ret; -} - -static ssize_t btaudio_dsp_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - return -EINVAL; -} - -static int btaudio_dsp_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - struct btaudio *bta = file->private_data; - int s, i, ret, val = 0; - void __user *argp = (void __user *)arg; - int __user *p = argp; - - switch (cmd) { - case OSS_GETVERSION: - return put_user(SOUND_VERSION, p); - case SNDCTL_DSP_GETCAPS: - return 0; - - case SNDCTL_DSP_SPEED: - if (get_user(val, p)) - return -EFAULT; - if (bta->analog) { - for (s = 0; s < 16; s++) - if (val << s >= HWBASE_AD*4/15) - break; - for (i = 15; i >= 5; i--) - if (val << s <= HWBASE_AD*4/i) - break; - bta->sampleshift = s; - bta->decimation = i; - if (debug) - printk(KERN_DEBUG "btaudio: rate: req=%d " - "dec=%d shift=%d hwrate=%d swrate=%d\n", - val,i,s,(HWBASE_AD*4/i),(HWBASE_AD*4/i)>>s); - } else { - bta->sampleshift = (bta->channels == 2) ? 0 : 1; - bta->decimation = 0; - } - if (bta->recording) { - mutex_lock(&bta->lock); - stop_recording(bta); - start_recording(bta); - mutex_unlock(&bta->lock); - } - /* fall through */ - case SOUND_PCM_READ_RATE: - if (bta->analog) { - return put_user(HWBASE_AD*4/bta->decimation>>bta->sampleshift, p); - } else { - return put_user(bta->rate, p); - } - - case SNDCTL_DSP_STEREO: - if (!bta->analog) { - if (get_user(val, p)) - return -EFAULT; - bta->channels = (val > 0) ? 2 : 1; - bta->sampleshift = (bta->channels == 2) ? 0 : 1; - if (debug) - printk(KERN_INFO - "btaudio: stereo=%d channels=%d\n", - val,bta->channels); - } else { - if (val == 1) - return -EFAULT; - else { - bta->channels = 1; - if (debug) - printk(KERN_INFO - "btaudio: stereo=0 channels=1\n"); - } - } - return put_user((bta->channels)-1, p); - - case SNDCTL_DSP_CHANNELS: - if (!bta->analog) { - if (get_user(val, p)) - return -EFAULT; - bta->channels = (val > 1) ? 2 : 1; - bta->sampleshift = (bta->channels == 2) ? 0 : 1; - if (debug) - printk(KERN_DEBUG - "btaudio: val=%d channels=%d\n", - val,bta->channels); - } - /* fall through */ - case SOUND_PCM_READ_CHANNELS: - return put_user(bta->channels, p); - - case SNDCTL_DSP_GETFMTS: /* Returns a mask */ - if (bta->analog) - return put_user(AFMT_S16_LE|AFMT_S8, p); - else - return put_user(AFMT_S16_LE, p); - - case SNDCTL_DSP_SETFMT: /* Selects ONE fmt*/ - if (get_user(val, p)) - return -EFAULT; - if (val != AFMT_QUERY) { - if (bta->analog) - bta->bits = (val == AFMT_S8) ? 8 : 16; - else - bta->bits = 16; - if (bta->recording) { - mutex_lock(&bta->lock); - stop_recording(bta); - start_recording(bta); - mutex_unlock(&bta->lock); - } - } - if (debug) - printk(KERN_DEBUG "btaudio: fmt: bits=%d\n",bta->bits); - return put_user((bta->bits==16) ? AFMT_S16_LE : AFMT_S8, - p); - break; - case SOUND_PCM_READ_BITS: - return put_user(bta->bits, p); - - case SNDCTL_DSP_NONBLOCK: - file->f_flags |= O_NONBLOCK; - return 0; - - case SNDCTL_DSP_RESET: - if (bta->recording) { - mutex_lock(&bta->lock); - stop_recording(bta); - mutex_unlock(&bta->lock); - } - return 0; - case SNDCTL_DSP_GETBLKSIZE: - if (!bta->recording) { - if (0 != (ret = alloc_buffer(bta))) - return ret; - if (0 != (ret = make_risc(bta))) - return ret; - } - return put_user(bta->block_bytes>>bta->sampleshift,p); - - case SNDCTL_DSP_SYNC: - /* NOP */ - return 0; - case SNDCTL_DSP_GETISPACE: - { - audio_buf_info info; - if (!bta->recording) - return -EINVAL; - info.fragsize = bta->block_bytes>>bta->sampleshift; - info.fragstotal = bta->block_count; - info.bytes = bta->read_count; - info.fragments = info.bytes / info.fragsize; - if (debug) - printk(KERN_DEBUG "btaudio: SNDCTL_DSP_GETISPACE " - "returns %d/%d/%d/%d\n", - info.fragsize, info.fragstotal, - info.bytes, info.fragments); - if (copy_to_user(argp, &info, sizeof(info))) - return -EFAULT; - return 0; - } -#if 0 /* TODO */ - case SNDCTL_DSP_GETTRIGGER: - case SNDCTL_DSP_SETTRIGGER: - case SNDCTL_DSP_SETFRAGMENT: -#endif - default: - return -EINVAL; - } -} - -static unsigned int btaudio_dsp_poll(struct file *file, struct poll_table_struct *wait) -{ - struct btaudio *bta = file->private_data; - unsigned int mask = 0; - - poll_wait(file, &bta->readq, wait); - - if (0 != bta->read_count) - mask |= (POLLIN | POLLRDNORM); - - return mask; -} - -static const struct file_operations btaudio_digital_dsp_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .open = btaudio_dsp_open_digital, - .release = btaudio_dsp_release, - .read = btaudio_dsp_read, - .write = btaudio_dsp_write, - .ioctl = btaudio_dsp_ioctl, - .poll = btaudio_dsp_poll, -}; - -static const struct file_operations btaudio_analog_dsp_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .open = btaudio_dsp_open_analog, - .release = btaudio_dsp_release, - .read = btaudio_dsp_read, - .write = btaudio_dsp_write, - .ioctl = btaudio_dsp_ioctl, - .poll = btaudio_dsp_poll, -}; - -/* -------------------------------------------------------------- */ - -static char *irq_name[] = { "", "", "", "OFLOW", "", "", "", "", "", "", "", - "RISCI", "FBUS", "FTRGT", "FDSR", "PPERR", - "RIPERR", "PABORT", "OCERR", "SCERR" }; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) -static irqreturn_t btaudio_irq(int irq, void *dev_id, struct pt_regs * regs) -#else -static irqreturn_t btaudio_irq(int irq, void *dev_id) -#endif -{ - int count = 0; - u32 stat,astat; - struct btaudio *bta = dev_id; - int handled = 0; - - for (;;) { - count++; - stat = btread(REG_INT_STAT); - astat = stat & btread(REG_INT_MASK); - if (!astat) - return IRQ_RETVAL(handled); - handled = 1; - btwrite(astat,REG_INT_STAT); - - if (irq_debug) { - int i; - printk(KERN_DEBUG "btaudio: irq loop=%d risc=%x, bits:", - count, stat>>28); - for (i = 0; i < (sizeof(irq_name)/sizeof(char*)); i++) { - if (stat & (1 << i)) - printk(" %s",irq_name[i]); - if (astat & (1 << i)) - printk("*"); - } - printk("\n"); - } - if (stat & IRQ_RISCI) { - int blocks; - blocks = (stat >> 28) - bta->dma_block; - if (blocks < 0) - blocks += bta->block_count; - bta->dma_block = stat >> 28; - if (bta->read_count + 2*bta->block_bytes > bta->buf_size) { - stop_recording(bta); - printk(KERN_INFO "btaudio: buffer overrun\n"); - } - if (blocks > 0) { - bta->read_count += blocks * bta->block_bytes; - wake_up_interruptible(&bta->readq); - } - } - if (count > 10) { - printk(KERN_WARNING - "btaudio: Oops - irq mask cleared\n"); - btwrite(0, REG_INT_MASK); - } - } - return IRQ_NONE; -} - -/* -------------------------------------------------------------- */ - -static unsigned int dsp1 = -1; -static unsigned int dsp2 = -1; -static unsigned int mixer = -1; -static int latency = -1; -static int digital = 1; -static int analog = 1; -static int rate; - -#define BTA_OSPREY200 1 - -static struct cardinfo cards[] = { - [0] = { - .name = "default", - .rate = 32000, - }, - [BTA_OSPREY200] = { - .name = "Osprey 200", - .rate = 44100, - }, -}; - -static int __devinit btaudio_probe(struct pci_dev *pci_dev, - const struct pci_device_id *pci_id) -{ - struct btaudio *bta; - struct cardinfo *card = &cards[pci_id->driver_data]; - unsigned char revision,lat; - int rc = -EBUSY; - - if (pci_enable_device(pci_dev)) - return -EIO; - if (!request_mem_region(pci_resource_start(pci_dev,0), - pci_resource_len(pci_dev,0), - "btaudio")) { - return -EBUSY; - } - - bta = kzalloc(sizeof(*bta),GFP_ATOMIC); - if (!bta) { - rc = -ENOMEM; - goto fail0; - } - - bta->pci = pci_dev; - bta->irq = pci_dev->irq; - bta->mem = pci_resource_start(pci_dev,0); - bta->mmio = ioremap(pci_resource_start(pci_dev,0), - pci_resource_len(pci_dev,0)); - - bta->source = 1; - bta->bits = 8; - bta->channels = 1; - if (bta->analog) { - bta->decimation = 15; - } else { - bta->decimation = 0; - bta->sampleshift = 1; - } - - /* sample rate */ - bta->rate = card->rate; - if (rate) - bta->rate = rate; - - mutex_init(&bta->lock); - init_waitqueue_head(&bta->readq); - - if (-1 != latency) { - printk(KERN_INFO "btaudio: setting pci latency timer to %d\n", - latency); - pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, latency); - } - pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &revision); - pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &lat); - printk(KERN_INFO "btaudio: Bt%x (rev %d) at %02x:%02x.%x, ", - pci_dev->device,revision,pci_dev->bus->number, - PCI_SLOT(pci_dev->devfn),PCI_FUNC(pci_dev->devfn)); - printk("irq: %d, latency: %d, mmio: 0x%lx\n", - bta->irq, lat, bta->mem); - printk("btaudio: using card config \"%s\"\n", card->name); - - /* init hw */ - btwrite(0, REG_GPIO_DMA_CTL); - btwrite(0, REG_INT_MASK); - btwrite(~0U, REG_INT_STAT); - pci_set_master(pci_dev); - - if ((rc = request_irq(bta->irq, btaudio_irq, IRQF_SHARED|IRQF_DISABLED, - "btaudio",(void *)bta)) < 0) { - printk(KERN_WARNING - "btaudio: can't request irq (rc=%d)\n",rc); - goto fail1; - } - - /* register devices */ - if (digital) { - rc = bta->dsp_digital = -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) - register_sound_dsp(&btaudio_digital_dsp_fops, dsp1); -#else - register_sound_dsp((struct file_operations *)&btaudio_digital_dsp_fops, dsp1); -#endif - if (rc < 0) { - printk(KERN_WARNING - "btaudio: can't register digital dsp (rc=%d)\n",rc); - goto fail2; - } - printk(KERN_INFO "btaudio: registered device dsp%d [digital]\n", - bta->dsp_digital >> 4); - } - if (analog) { - rc = bta->dsp_analog = -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) - register_sound_dsp(&btaudio_analog_dsp_fops, dsp2); -#else - register_sound_dsp((struct file_operations *)&btaudio_analog_dsp_fops, dsp2); -#endif - if (rc < 0) { - printk(KERN_WARNING - "btaudio: can't register analog dsp (rc=%d)\n",rc); - goto fail3; - } - printk(KERN_INFO "btaudio: registered device dsp%d [analog]\n", - bta->dsp_analog >> 4); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) - rc = bta->mixer_dev = register_sound_mixer(&btaudio_mixer_fops, mixer); -#else - rc = bta->mixer_dev = register_sound_mixer((struct file_operations *)&btaudio_mixer_fops, mixer); -#endif - if (rc < 0) { - printk(KERN_WARNING - "btaudio: can't register mixer (rc=%d)\n",rc); - goto fail4; - } - printk(KERN_INFO "btaudio: registered device mixer%d\n", - bta->mixer_dev >> 4); - } - - /* hook into linked list */ - bta->next = btaudios; - btaudios = bta; - - pci_set_drvdata(pci_dev,bta); - return 0; - - fail4: - unregister_sound_dsp(bta->dsp_analog); - fail3: - if (digital) - unregister_sound_dsp(bta->dsp_digital); - fail2: - free_irq(bta->irq,bta); - fail1: - iounmap(bta->mmio); - kfree(bta); - fail0: - release_mem_region(pci_resource_start(pci_dev,0), - pci_resource_len(pci_dev,0)); - return rc; -} - -static void __devexit btaudio_remove(struct pci_dev *pci_dev) -{ - struct btaudio *bta = pci_get_drvdata(pci_dev); - struct btaudio *walk; - - /* turn off all DMA / IRQs */ - btand(~15, REG_GPIO_DMA_CTL); - btwrite(0, REG_INT_MASK); - btwrite(~0U, REG_INT_STAT); - - /* unregister devices */ - if (digital) { - unregister_sound_dsp(bta->dsp_digital); - } - if (analog) { - unregister_sound_dsp(bta->dsp_analog); - unregister_sound_mixer(bta->mixer_dev); - } - - /* free resources */ - free_buffer(bta); - free_irq(bta->irq,bta); - release_mem_region(pci_resource_start(pci_dev,0), - pci_resource_len(pci_dev,0)); - iounmap(bta->mmio); - - /* remove from linked list */ - if (bta == btaudios) { - btaudios = NULL; - } else { - for (walk = btaudios; walk->next != bta; walk = walk->next) - ; /* if (NULL == walk->next) BUG(); */ - walk->next = bta->next; - } - - pci_set_drvdata(pci_dev, NULL); - kfree(bta); - return; -} - -/* -------------------------------------------------------------- */ - -static struct pci_device_id btaudio_pci_tbl[] = { - { - .vendor = PCI_VENDOR_ID_BROOKTREE, - .device = 0x0878, - .subvendor = 0x0070, - .subdevice = 0xff01, - .driver_data = BTA_OSPREY200, - },{ - .vendor = PCI_VENDOR_ID_BROOKTREE, - .device = 0x0878, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - },{ - .vendor = PCI_VENDOR_ID_BROOKTREE, - .device = 0x0878, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - },{ - /* --- end of list --- */ - } -}; - -static struct pci_driver btaudio_pci_driver = { - .name = "btaudio", - .id_table = btaudio_pci_tbl, - .probe = btaudio_probe, - .remove = __devexit_p(btaudio_remove), -}; - -static int btaudio_init_module(void) -{ - printk(KERN_INFO "btaudio: driver version 0.7 loaded [%s%s%s]\n", - digital ? "digital" : "", - analog && digital ? "+" : "", - analog ? "analog" : ""); - return pci_register_driver(&btaudio_pci_driver); -} - -static void btaudio_cleanup_module(void) -{ - pci_unregister_driver(&btaudio_pci_driver); - return; -} - -module_init(btaudio_init_module); -module_exit(btaudio_cleanup_module); - -module_param(dsp1, int, S_IRUGO); -module_param(dsp2, int, S_IRUGO); -module_param(mixer, int, S_IRUGO); -module_param(debug, int, S_IRUGO | S_IWUSR); -module_param(irq_debug, int, S_IRUGO | S_IWUSR); -module_param(digital, int, S_IRUGO); -module_param(analog, int, S_IRUGO); -module_param(rate, int, S_IRUGO); -module_param(latency, int, S_IRUGO); -MODULE_PARM_DESC(latency,"pci latency timer"); - -MODULE_DEVICE_TABLE(pci, btaudio_pci_tbl); -MODULE_DESCRIPTION("bt878 audio dma driver"); -MODULE_AUTHOR("Gerd Knorr"); -MODULE_LICENSE("GPL"); - -/* - * Local variables: - * c-basic-offset: 8 - * End: - */ diff --git a/v4l/Kconfig.sound b/v4l/Kconfig.sound index 597c9c72b..55be75cce 100644 --- a/v4l/Kconfig.sound +++ b/v4l/Kconfig.sound @@ -45,30 +45,4 @@ config SND_FM801_TEA575X This will enable support for the old V4L1 API. -# This is part of sound/oss/Kconfig -comment "OSS sound" - -config SOUND_BT878 - tristate "BT878 audio dma" - depends on SOUND_PRIME && PCI - ---help--- - Audio DMA support for bt878 based grabber boards. As you might have - already noticed, bt878 is listed with two functions in /proc/pci. - Function 0 does the video stuff (bt848 compatible), function 1 does - the same for audio data. This is a driver for the audio part of - the chip. If you say 'Y' here you get a oss-compatible dsp device - where you can record from. If you want just watch TV you probably - don't need this driver as most TV cards handle sound with a short - cable from the TV card to your sound card's line-in. - - To compile this driver as a module, choose M here: the module will - be called btaudio. - -config SOUND_TVMIXER - tristate "TV card (bt848) mixer support" - depends on SOUND_PRIME && I2C && VIDEO_V4L1 - help - Support for audio mixer facilities on the BT848 TV frame-grabber - card. - endmenu diff --git a/v4l/Makefile.sound b/v4l/Makefile.sound index 941dbc65c..38e868629 100644 --- a/v4l/Makefile.sound +++ b/v4l/Makefile.sound @@ -3,10 +3,6 @@ snd-bt87x-objs := bt87x.o obj-$(CONFIG_SND_BT87X) += snd-bt87x.o -# From sound/oss/Makefile - -obj-$(CONFIG_SOUND_BT878) += btaudio.o - # From sound/i2c/other/Makefile snd-tea575x-tuner-objs := tea575x-tuner.o obj-$(CONFIG_SND_FM801_TEA575X) += snd-tea575x-tuner.o @@ -22,13 +18,6 @@ sound-install install-sound:: for i in $$files;do if [ -e $$i ]; then echo -n "$$i "; \ install -m 644 -c $$i $(KDIRA)/$$dir; fi; done; echo; - @dir="sound/oss"; \ - files='btaudio.ko'; \ - echo -e "\nInstalling $(KDIRA)/$$dir files:"; \ - install -d $(KDIRA)/$$dir; \ - for i in $$files;do if [ -e $$i ]; then echo -n "$$i "; \ - install -m 644 -c $$i $(KDIRA)/$$dir; fi; done; echo; - @dir="sound/i2c/other"; \ files='snd-tea575x-tuner.ko'; \ echo -e "\nInstalling $(KDIRA)/$$dir files:"; \ diff --git a/v4l_experimental/firesat/Kconfig b/v4l_experimental/firesat/Kconfig deleted file mode 100644 index fe8c82b32..000000000 --- a/v4l_experimental/firesat/Kconfig +++ /dev/null @@ -1,11 +0,0 @@ -config DVB_FIRESAT - tristate "FireSAT devices" - depends on DVB_CORE && ieee1394 - help - Support for external IEEE1394 adapters designed by Digital Everywhere and - produced by El Gato, shipped under the brand name 'EyeTV 300/400'. - - These devices don't have a MPEG decoder built in, so you need - an external software decoder to watch TV. - - Say Y if you own such a device and want to use it. diff --git a/v4l_experimental/firesat/Makefile b/v4l_experimental/firesat/Makefile deleted file mode 100644 index 54e93b366..000000000 --- a/v4l_experimental/firesat/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -obj-$(CONFIG_DVB_FIRESAT) := dvb-firesat.o - -dvb-firesat-objs := firesat.o avc_api.o cmp.o firesat-rc.o - -EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ - -firesat.c: firesat.h avc_api.h cmp.h firesat-rc.h firesat-ci.h -avc_api.c: avc_api.h firesat.h -cmp.c: cmp.h avc_api.h -firesat-rc.c: firesat-rc.h -firesat-ci.c: firesat-ci.h diff --git a/v4l_experimental/firesat/avc_api.c b/v4l_experimental/firesat/avc_api.c deleted file mode 100644 index eb597eaa4..000000000 --- a/v4l_experimental/firesat/avc_api.c +++ /dev/null @@ -1,953 +0,0 @@ -/* - * FireSAT AVC driver - * - * Copyright (c) 2004 Andreas Monitzer <andy@monitzer.com> - * - * This program 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. - */ - -#include <ieee1394_transactions.h> -#include <nodemgr.h> -#include <asm/byteorder.h> -#include <linux/delay.h> -#include "firesat.h" -#include "avc_api.h" -#include "firesat-rc.h" - -#define RESPONSE_REGISTER 0xFFFFF0000D00ULL -#define COMMAND_REGISTER 0xFFFFF0000B00ULL -#define PCR_BASE_ADDRESS 0xFFFFF0000900ULL - -static int __AVCRegisterRemoteControl(struct firesat*firesat, int internal); - -/* Frees an allocated packet */ -static void avc_free_packet(struct hpsb_packet *packet) -{ - hpsb_free_tlabel(packet); - hpsb_free_packet(packet); -} - -/* - * Goofy routine that basically does a down_timeout function. - * Stolen from sbp2.c - */ -static int avc_down_timeout(atomic_t *done, int timeout) -{ - int i; - - for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) { - set_current_state(TASK_INTERRUPTIBLE); - if (schedule_timeout(HZ/10)) /* 100ms */ - return(1); - } - return ((i > 0) ? 0:1); -} - -static int __AVCWrite(struct firesat *firesat, const AVCCmdFrm *CmdFrm, AVCRspFrm *RspFrm) { - struct hpsb_packet *packet; - struct node_entry *ne; - - ne = firesat->nodeentry; - if(!ne) { - printk("%s: lost node!\n",__FUNCTION__); - return -EIO; - } - - /* need all input data */ - if(!firesat || !ne || !CmdFrm) - return -EINVAL; - -// printk(KERN_INFO "AVCWrite command %x\n",CmdFrm->opcode); - -// for(k=0;k<CmdFrm->length;k++) -// printk(KERN_INFO "CmdFrm[%d] = %08x\n", k, ((quadlet_t*)CmdFrm)[k]); - - packet=hpsb_make_writepacket(ne->host, ne->nodeid, COMMAND_REGISTER, - (quadlet_t*)CmdFrm, CmdFrm->length); - - hpsb_set_packet_complete_task(packet, (void (*)(void*))avc_free_packet, - packet); - - hpsb_node_fill_packet(ne, packet); - - if(RspFrm) - atomic_set(&firesat->avc_reply_received, 0); - - if (hpsb_send_packet(packet) < 0) { - avc_free_packet(packet); - atomic_set(&firesat->avc_reply_received, 1); - return -EIO; - } - - if(RspFrm) { - if(avc_down_timeout(&firesat->avc_reply_received,HZ/2)) { - printk("%s: timeout waiting for avc response\n",__FUNCTION__); - atomic_set(&firesat->avc_reply_received, 1); - return -ETIMEDOUT; - } - - memcpy(RspFrm,firesat->respfrm,firesat->resp_length); - } - - return 0; -} - -int AVCWrite(struct firesat*firesat, const AVCCmdFrm *CmdFrm, AVCRspFrm *RspFrm) { - int ret; - if(down_interruptible(&firesat->avc_sem)) - return -EINTR; - - ret = __AVCWrite(firesat, CmdFrm, RspFrm); - - up(&firesat->avc_sem); - return ret; -} - -static void do_schedule_remotecontrol(unsigned long ignored); -DECLARE_TASKLET(schedule_remotecontrol, do_schedule_remotecontrol, 0); - -static void do_schedule_remotecontrol(unsigned long ignored) { - struct firesat *firesat; - unsigned long flags; - - spin_lock_irqsave(&firesat_list_lock, flags); - list_for_each_entry(firesat,&firesat_list,list) { - if(atomic_read(&firesat->reschedule_remotecontrol) == 1) { - if(down_trylock(&firesat->avc_sem)) - tasklet_schedule(&schedule_remotecontrol); - else { - if(__AVCRegisterRemoteControl(firesat, 1) == 0) - atomic_set(&firesat->reschedule_remotecontrol, 0); - else - tasklet_schedule(&schedule_remotecontrol); - - up(&firesat->avc_sem); - } - } - } - spin_unlock_irqrestore(&firesat_list_lock, flags); -} - -int AVCRecv(struct firesat *firesat, u8 *data, size_t length) { -// printk(KERN_INFO "%s\n",__FUNCTION__); - - // remote control handling - - AVCRspFrm *RspFrm = (AVCRspFrm*)data; - - if(/*RspFrm->length >= 8 && ###*/ - ((RspFrm->operand[0] == SFE_VENDOR_DE_COMPANYID_0 && - RspFrm->operand[1] == SFE_VENDOR_DE_COMPANYID_1 && - RspFrm->operand[2] == SFE_VENDOR_DE_COMPANYID_2) || - (RspFrm->operand[0] == SFE_VENDOR_EL_COMPANYID_0 && - RspFrm->operand[1] == SFE_VENDOR_EL_COMPANYID_1 && - RspFrm->operand[2] == SFE_VENDOR_EL_COMPANYID_2)) && - RspFrm->operand[3] == SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL) { - if(RspFrm->resp == CHANGED) { -// printk(KERN_INFO "%s: code = %02x %02x\n",__FUNCTION__,RspFrm->operand[4],RspFrm->operand[5]); - firesat_got_remotecontrolcode((((u16)RspFrm->operand[4]) << 8) | ((u16)RspFrm->operand[5])); - - // schedule - atomic_set(&firesat->reschedule_remotecontrol, 1); - tasklet_schedule(&schedule_remotecontrol); - } else if(RspFrm->resp != INTERIM) - printk(KERN_INFO "%s: remote control result = %d\n",__FUNCTION__, RspFrm->resp); - return 0; - } - - if(atomic_read(&firesat->avc_reply_received) == 1) { - printk("%s: received out-of-order AVC response, ignored\n",__FUNCTION__); - return -EINVAL; - } -// AVCRspFrm *resp=(AVCRspFrm *)data; -// int k; -/* - printk(KERN_INFO "resp=0x%x\n",resp->resp); - printk(KERN_INFO "cts=0x%x\n",resp->cts); - printk(KERN_INFO "suid=0x%x\n",resp->suid); - printk(KERN_INFO "sutyp=0x%x\n",resp->sutyp); - printk(KERN_INFO "opcode=0x%x\n",resp->opcode); - printk(KERN_INFO "length=%d\n",resp->length); -*/ -// for(k=0;k<2;k++) -// printk(KERN_INFO "operand[%d]=%02x\n",k,resp->operand[k]); - - memcpy(firesat->respfrm,data,length); - firesat->resp_length=length; - - atomic_set(&firesat->avc_reply_received, 1); - - return 0; -} - -// tuning command for setting the relative LNB frequency (not supported by the AVC standard) -static void AVCTuner_DSD_directcmd(struct firesat *firesat, struct dvb_frontend_parameters *params, AVCCmdFrm *CmdFrm) { - memset(CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm->cts = AVC; - CmdFrm->ctype = CONTROL; - CmdFrm->sutyp = 0x5; - CmdFrm->suid = firesat->subunit; - CmdFrm->opcode = VENDOR; - - /* ### should check for elgato and use SFE_VENDOR_EL_COMPANYID_0 in this case */ - CmdFrm->operand[0]=SFE_VENDOR_DE_COMPANYID_0; - CmdFrm->operand[1]=SFE_VENDOR_DE_COMPANYID_1; - CmdFrm->operand[2]=SFE_VENDOR_DE_COMPANYID_2; - CmdFrm->operand[3]=0x58; - - printk(KERN_INFO "%s: tuning to frequency %u\n",__FUNCTION__,params->frequency); - - CmdFrm->operand[4] = (params->frequency >> 24) & 0xFF; - CmdFrm->operand[5] = (params->frequency >> 16) & 0xFF; - CmdFrm->operand[6] = (params->frequency >> 8) & 0xFF; - CmdFrm->operand[7] = params->frequency & 0xFF; - - printk(KERN_INFO "%s: symbol rate = %uBd\n",__FUNCTION__,params->u.qpsk.symbol_rate); - - CmdFrm->operand[8] = ((params->u.qpsk.symbol_rate/1000) >> 8) & 0xFF; - CmdFrm->operand[9] = (params->u.qpsk.symbol_rate/1000) & 0xFF; - - switch(params->u.qpsk.fec_inner) { - case FEC_1_2: - CmdFrm->operand[10] = 0x1; - break; - case FEC_2_3: - CmdFrm->operand[10] = 0x2; - break; - case FEC_3_4: - CmdFrm->operand[10] = 0x3; - break; - case FEC_5_6: - CmdFrm->operand[10] = 0x4; - break; - case FEC_7_8: - CmdFrm->operand[10] = 0x5; - break; - case FEC_4_5: - case FEC_8_9: - case FEC_AUTO: - default: - CmdFrm->operand[10] = 0x0; - } - - if(firesat->voltage == 0xff) - CmdFrm->operand[11] = 0xff; - else - CmdFrm->operand[11] = (firesat->voltage==SEC_VOLTAGE_18)?0:1; // polarisation - if(firesat->tone == 0xff) - CmdFrm->operand[12] = 0xff; - else - CmdFrm->operand[12] = (firesat->tone==SEC_TONE_ON)?1:0; // band - - CmdFrm->length = 16; -} - -int AVCTuner_DSD(struct firesat *firesat, struct dvb_frontend_parameters *params, BYTE *status) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - M_VALID_FLAGS flags; - int k; - -// printk(KERN_INFO "%s\n", __FUNCTION__); - - if(firesat->type == FireSAT_DVB_S) - AVCTuner_DSD_directcmd(firesat, params, &CmdFrm); - else { - if(firesat->type == FireSAT_DVB_T) { - flags.Bits_T.GuardInterval = (params->u.ofdm.guard_interval != GUARD_INTERVAL_AUTO); - flags.Bits_T.CodeRateLPStream = (params->u.ofdm.code_rate_LP != FEC_AUTO); - flags.Bits_T.CodeRateHPStream = (params->u.ofdm.code_rate_HP != FEC_AUTO); - flags.Bits_T.HierarchyInfo = (params->u.ofdm.hierarchy_information != HIERARCHY_AUTO); - flags.Bits_T.Constellation = (params->u.ofdm.constellation != QAM_AUTO); - flags.Bits_T.Bandwidth = (params->u.ofdm.bandwidth != BANDWIDTH_AUTO); - flags.Bits_T.CenterFrequency = 1; - flags.Bits_T.reserved1 = 0; - flags.Bits_T.reserved2 = 0; - flags.Bits_T.OtherFrequencyFlag = 0; - flags.Bits_T.TransmissionMode = (params->u.ofdm.transmission_mode != TRANSMISSION_MODE_AUTO); - flags.Bits_T.NetworkId = 0; - } else { - flags.Bits.Modulation = 0; - if(firesat->type == FireSAT_DVB_S) { - flags.Bits.FEC_inner = 1; - } else if(firesat->type == FireSAT_DVB_C) { - flags.Bits.FEC_inner = 0; - } - flags.Bits.FEC_outer = 0; - flags.Bits.Symbol_Rate = 1; - flags.Bits.Frequency = 1; - flags.Bits.Orbital_Pos = 0; - if(firesat->type == FireSAT_DVB_S) { - flags.Bits.Polarisation = 1; - } else if(firesat->type == FireSAT_DVB_C) { - flags.Bits.Polarisation = 0; - } - flags.Bits.reserved_fields = 0; - flags.Bits.reserved1 = 0; - flags.Bits.Network_ID = 0; - } - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts = AVC; - CmdFrm.ctype = CONTROL; - CmdFrm.sutyp = 0x5; - CmdFrm.suid = firesat->subunit; - CmdFrm.opcode = DSD; - - CmdFrm.operand[0] = 0; // source plug - CmdFrm.operand[1] = 0xD2; // subfunction replace - CmdFrm.operand[2] = 0x20; // system id = DVB - CmdFrm.operand[3] = 0x00; // antenna number - CmdFrm.operand[4] = (firesat->type == FireSAT_DVB_T)?0x0c:0x11; // system_specific_multiplex selection_length - CmdFrm.operand[5] = flags.Valid_Word.ByteHi; // valid_flags [0] - CmdFrm.operand[6] = flags.Valid_Word.ByteLo; // valid_flags [1] - - if(firesat->type == FireSAT_DVB_T) { - CmdFrm.operand[7] = 0x0; - CmdFrm.operand[8] = (params->frequency/10) >> 24; - CmdFrm.operand[9] = ((params->frequency/10) >> 16) & 0xFF; - CmdFrm.operand[10] = ((params->frequency/10) >> 8) & 0xFF; - CmdFrm.operand[11] = (params->frequency/10) & 0xFF; - switch(params->u.ofdm.bandwidth) { - case BANDWIDTH_7_MHZ: - CmdFrm.operand[12] = 0x20; - break; - case BANDWIDTH_8_MHZ: - case BANDWIDTH_6_MHZ: // not defined by AVC spec - case BANDWIDTH_AUTO: - default: - CmdFrm.operand[12] = 0x00; - } - switch(params->u.ofdm.constellation) { - case QAM_16: - CmdFrm.operand[13] = 1 << 6; - break; - case QAM_64: - CmdFrm.operand[13] = 2 << 6; - break; - case QPSK: - default: - CmdFrm.operand[13] = 0x00; - } - switch(params->u.ofdm.hierarchy_information) { - case HIERARCHY_1: - CmdFrm.operand[13] |= 1 << 3; - break; - case HIERARCHY_2: - CmdFrm.operand[13] |= 2 << 3; - break; - case HIERARCHY_4: - CmdFrm.operand[13] |= 3 << 3; - break; - case HIERARCHY_AUTO: - case HIERARCHY_NONE: - default: - break; - } - switch(params->u.ofdm.code_rate_HP) { - case FEC_2_3: - CmdFrm.operand[13] |= 1; - break; - case FEC_3_4: - CmdFrm.operand[13] |= 2; - break; - case FEC_5_6: - CmdFrm.operand[13] |= 3; - break; - case FEC_7_8: - CmdFrm.operand[13] |= 4; - break; - case FEC_1_2: - default: - break; - } - switch(params->u.ofdm.code_rate_LP) { - case FEC_2_3: - CmdFrm.operand[14] = 1 << 5; - break; - case FEC_3_4: - CmdFrm.operand[14] = 2 << 5; - break; - case FEC_5_6: - CmdFrm.operand[14] = 3 << 5; - break; - case FEC_7_8: - CmdFrm.operand[14] = 4 << 5; - break; - case FEC_1_2: - default: - CmdFrm.operand[14] = 0x00; - break; - } - switch(params->u.ofdm.guard_interval) { - case GUARD_INTERVAL_1_16: - CmdFrm.operand[14] |= 1 << 3; - break; - case GUARD_INTERVAL_1_8: - CmdFrm.operand[14] |= 2 << 3; - break; - case GUARD_INTERVAL_1_4: - CmdFrm.operand[14] |= 3 << 3; - break; - case GUARD_INTERVAL_1_32: - case GUARD_INTERVAL_AUTO: - default: - break; - } - switch(params->u.ofdm.transmission_mode) { - case TRANSMISSION_MODE_8K: - CmdFrm.operand[14] |= 1 << 1; - break; - case TRANSMISSION_MODE_2K: - case TRANSMISSION_MODE_AUTO: - default: - break; - } - - CmdFrm.operand[15] = 0x00; // network_ID[0] - CmdFrm.operand[16] = 0x00; // network_ID[1] - CmdFrm.operand[17] = 0x00; // Nr_of_dsd_sel_specs = 0 - > No PIDs are transmitted - - CmdFrm.length = 20; - } else { - CmdFrm.operand[7] = 0x00; - CmdFrm.operand[8] = (((firesat->voltage==SEC_VOLTAGE_18)?0:1)<<6); /* 0 = H, 1 = V */ - CmdFrm.operand[9] = 0x00; - CmdFrm.operand[10] = 0x00; - - if(firesat->type == FireSAT_DVB_S) { - /* ### relative frequency -> absolute frequency */ - CmdFrm.operand[11] = (((params->frequency/4) >> 16) & 0xFF) | (2 << 6); - CmdFrm.operand[12] = ((params->frequency/4) >> 8) & 0xFF; - CmdFrm.operand[13] = (params->frequency/4) & 0xFF; - } else if(firesat->type == FireSAT_DVB_C) { - CmdFrm.operand[11] = (((params->frequency/4000) >> 16) & 0xFF) | (2 << 6); - CmdFrm.operand[12] = ((params->frequency/4000) >> 8) & 0xFF; - CmdFrm.operand[13] = (params->frequency/4000) & 0xFF; - } - - CmdFrm.operand[14] = ((params->u.qpsk.symbol_rate/1000) >> 12) & 0xFF; - CmdFrm.operand[15] = ((params->u.qpsk.symbol_rate/1000) >> 4) & 0xFF; - CmdFrm.operand[16] = ((params->u.qpsk.symbol_rate/1000) << 4) & 0xF0; - - CmdFrm.operand[17] = 0x00; - switch(params->u.qpsk.fec_inner) { - case FEC_1_2: - CmdFrm.operand[18] = 0x1; - break; - case FEC_2_3: - CmdFrm.operand[18] = 0x2; - break; - case FEC_3_4: - CmdFrm.operand[18] = 0x3; - break; - case FEC_5_6: - CmdFrm.operand[18] = 0x4; - break; - case FEC_7_8: - CmdFrm.operand[18] = 0x5; - break; - case FEC_4_5: - case FEC_8_9: - case FEC_AUTO: - default: - CmdFrm.operand[18] = 0x0; - } - if(firesat->type == FireSAT_DVB_S) { - CmdFrm.operand[19] = 0x08; // modulation - } else if(firesat->type == FireSAT_DVB_C) { - switch(params->u.qam.modulation) { - case QAM_16: - CmdFrm.operand[19] = 0x08; // modulation - break; - case QAM_32: - CmdFrm.operand[19] = 0x10; // modulation - break; - case QAM_64: - CmdFrm.operand[19] = 0x18; // modulation - break; - case QAM_128: - CmdFrm.operand[19] = 0x20; // modulation - break; - case QAM_256: - CmdFrm.operand[19] = 0x28; // modulation - break; - case QAM_AUTO: - default: - CmdFrm.operand[19] = 0x00; // modulation - } - } - CmdFrm.operand[20] = 0x00; - CmdFrm.operand[21] = 0x00; - CmdFrm.operand[22] = 0x00; // Nr_of_dsd_sel_specs = 0 - > No PIDs are transmitted - - CmdFrm.length=28; - } - } // AVCTuner_DSD_direct - - if((k=AVCWrite(firesat,&CmdFrm,&RspFrm))) - return k; - -// msleep(250); - mdelay(500); - - if(status) - *status=RspFrm.operand[2]; - return 0; -} - -int AVCTuner_SetPIDs(struct firesat *firesat, unsigned char pidc, u16 pid[]) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - int pos,k; - - printk(KERN_INFO "%s\n", __FUNCTION__); - - if(pidc > 16 && pidc != 0xFF) - return -EINVAL; - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts = AVC; - CmdFrm.ctype = CONTROL; - CmdFrm.sutyp = 0x5; - CmdFrm.suid = firesat->subunit; - CmdFrm.opcode = DSD; - - CmdFrm.operand[0] = 0; // source plug - CmdFrm.operand[1] = 0xD2; // subfunction replace - CmdFrm.operand[2] = 0x20; // system id = DVB - CmdFrm.operand[3] = 0x00; // antenna number - CmdFrm.operand[4] = 0x11; // system_specific_multiplex selection_length - CmdFrm.operand[5] = 0x00; // valid_flags [0] - CmdFrm.operand[6] = 0x00; // valid_flags [1] - - if(firesat->type == FireSAT_DVB_T) { -/* CmdFrm.operand[7] = 0x00; - CmdFrm.operand[8] = 0x00;//(params->frequency/10) >> 24; - CmdFrm.operand[9] = 0x00;//((params->frequency/10) >> 16) & 0xFF; - CmdFrm.operand[10] = 0x00;//((params->frequency/10) >> 8) & 0xFF; - CmdFrm.operand[11] = 0x00;//(params->frequency/10) & 0xFF; - CmdFrm.operand[12] = 0x00; - CmdFrm.operand[13] = 0x00; - CmdFrm.operand[14] = 0x00; - - CmdFrm.operand[15] = 0x00; // network_ID[0] - CmdFrm.operand[16] = 0x00; // network_ID[1] -*/ CmdFrm.operand[17] = pidc; // Nr_of_dsd_sel_specs - - pos=18; - } else { -/* CmdFrm.operand[7] = 0x00; - CmdFrm.operand[8] = 0x00; - CmdFrm.operand[9] = 0x00; - CmdFrm.operand[10] = 0x00; - - CmdFrm.operand[11] = 0x00;//(((params->frequency/4) >> 16) & 0xFF) | (2 << 6); - CmdFrm.operand[12] = 0x00;//((params->frequency/4) >> 8) & 0xFF; - CmdFrm.operand[13] = 0x00;//(params->frequency/4) & 0xFF; - - CmdFrm.operand[14] = 0x00;//((params->u.qpsk.symbol_rate/1000) >> 12) & 0xFF; - CmdFrm.operand[15] = 0x00;//((params->u.qpsk.symbol_rate/1000) >> 4) & 0xFF; - CmdFrm.operand[16] = 0x00;//((params->u.qpsk.symbol_rate/1000) << 4) & 0xF0; - - CmdFrm.operand[17] = 0x00; - CmdFrm.operand[18] = 0x00; - CmdFrm.operand[19] = 0x00; // modulation - CmdFrm.operand[20] = 0x00; - CmdFrm.operand[21] = 0x00;*/ - CmdFrm.operand[22] = pidc; // Nr_of_dsd_sel_specs - - pos=23; - } - if(pidc != 0xFF) - for(k=0;k<pidc;k++) { - CmdFrm.operand[pos++] = 0x13; // flowfunction relay - CmdFrm.operand[pos++] = 0x80; // dsd_sel_spec_valid_flags -> PID - CmdFrm.operand[pos++] = (pid[k] >> 8) & 0x1F; - CmdFrm.operand[pos++] = pid[k] & 0xFF; - CmdFrm.operand[pos++] = 0x00; // tableID - CmdFrm.operand[pos++] = 0x00; // filter_length - } - - CmdFrm.length = pos+3; - - if((pos+3)%4) - CmdFrm.length += 4 - ((pos+3)%4); - - if((k=AVCWrite(firesat,&CmdFrm,&RspFrm))) - return k; - - mdelay(250); - - return 0; -} - -int AVCIdentifySubunit(struct firesat *firesat, unsigned char *systemId, int *transport, int *has_ci) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - - memset(&CmdFrm,0,sizeof(AVCCmdFrm)); - - CmdFrm.cts = AVC; - CmdFrm.ctype = CONTROL; - CmdFrm.sutyp = 0x5; // tuner - CmdFrm.suid = firesat->subunit; - CmdFrm.opcode = READ_DESCRIPTOR; - - CmdFrm.operand[0]=DESCRIPTOR_SUBUNIT_IDENTIFIER; - CmdFrm.operand[1]=0xff; - CmdFrm.operand[2]=0x00; - CmdFrm.operand[3]=0x00; // length highbyte - CmdFrm.operand[4]=0x08; // length lowbyte - CmdFrm.operand[5]=0x00; // offset highbyte - CmdFrm.operand[6]=0x0d; // offset lowbyte - - CmdFrm.length=12; - - if(AVCWrite(firesat,&CmdFrm,&RspFrm)<0) - return -EIO; - - if(RspFrm.resp != STABLE && RspFrm.resp != ACCEPTED) { - printk("%s: AVCWrite returned error code %d\n",__FUNCTION__,RspFrm.resp); - return -EINVAL; - } - if(((RspFrm.operand[3] << 8) + RspFrm.operand[4]) != 8) { - printk("%s: Invalid response length\n",__FUNCTION__); - return -EINVAL; - } - if(systemId) - *systemId = RspFrm.operand[7]; - if(transport) - *transport = RspFrm.operand[14] & 0x7; - switch(RspFrm.operand[14] & 0x7) { - case 1: - printk(KERN_INFO "%s: found DVB/S\n",__FUNCTION__); - break; - case 2: - printk(KERN_INFO "%s: found DVB/C\n",__FUNCTION__); - break; - case 3: - printk(KERN_INFO "%s: found DVB/T\n",__FUNCTION__); - break; - default: - printk(KERN_INFO "%s: found unknown tuner id %u\n",__FUNCTION__,RspFrm.operand[14] & 0x7); - } - if(has_ci) - *has_ci = (RspFrm.operand[14] >> 4) & 0x1; - return 0; -} - -int AVCTunerStatus(struct firesat *firesat, ANTENNA_INPUT_INFO *antenna_input_info) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - int length; - - printk(KERN_INFO "%s\n", __FUNCTION__); - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts=AVC; - CmdFrm.ctype=CONTROL; - CmdFrm.sutyp=0x05; // tuner - CmdFrm.suid=firesat->subunit; - CmdFrm.opcode=READ_DESCRIPTOR; - - CmdFrm.operand[0]=DESCRIPTOR_TUNER_STATUS; - CmdFrm.operand[1]=0xff; - CmdFrm.operand[2]=0x00; - CmdFrm.operand[3]=sizeof(ANTENNA_INPUT_INFO) >> 8; - CmdFrm.operand[4]=sizeof(ANTENNA_INPUT_INFO) & 0xFF; - CmdFrm.operand[5]=0x00; - CmdFrm.operand[6]=0x03; - CmdFrm.length=12; - //Absenden des AVC request und warten auf response - if (AVCWrite(firesat,&CmdFrm,&RspFrm) < 0) - return -EIO; - - if(RspFrm.resp != STABLE && RspFrm.resp != ACCEPTED) { - printk("%s: AVCWrite returned code %d\n",__FUNCTION__,RspFrm.resp); - return -EINVAL; - } - - length = (RspFrm.operand[3] << 8) + RspFrm.operand[4]; - if(length == sizeof(ANTENNA_INPUT_INFO)) - { - memcpy(antenna_input_info,&RspFrm.operand[7],length); - return 0; - } - printk("%s: invalid info returned from AVC\n",__FUNCTION__); - return -EINVAL; -} - -int AVCLNBControl(struct firesat *firesat, char voltage, char burst, char conttone, char nrdiseq, struct dvb_diseqc_master_cmd *diseqcmd) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - int i,j; - - printk(KERN_INFO "%s: voltage = %x, burst = %x, conttone = %x\n",__FUNCTION__,voltage,burst,conttone); - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts=AVC; - CmdFrm.ctype=CONTROL; - CmdFrm.sutyp=0x05; - CmdFrm.suid=firesat->subunit; - CmdFrm.opcode=VENDOR; - - /* ### should check for elgato and use SFE_VENDOR_EL_COMPANYID_0 in this case */ - CmdFrm.operand[0]=SFE_VENDOR_DE_COMPANYID_0; - CmdFrm.operand[1]=SFE_VENDOR_DE_COMPANYID_1; - CmdFrm.operand[2]=SFE_VENDOR_DE_COMPANYID_2; - CmdFrm.operand[3]=SFE_VENDOR_OPCODE_LNB_CONTROL; - - CmdFrm.operand[4]=voltage; - CmdFrm.operand[5]=nrdiseq; - - i=6; - - for(j=0;j<nrdiseq;j++) { - int k; - printk(KERN_INFO "%s: diseq %d len %x\n",__FUNCTION__,j,diseqcmd[j].msg_len); - CmdFrm.operand[i++]=diseqcmd[j].msg_len; - - for(k=0;k<diseqcmd[j].msg_len;k++) { - printk(KERN_INFO "%s: diseq %d msg[%d] = %x\n",__FUNCTION__,j,k,diseqcmd[j].msg[k]); - CmdFrm.operand[i++]=diseqcmd[j].msg[k]; - } - } - - CmdFrm.operand[i++]=burst; - CmdFrm.operand[i++]=conttone; - - CmdFrm.length=i+3; - if((i+3)%4) - CmdFrm.length += 4 - ((i+3)%4); - -/* for(j=0;j<CmdFrm.length;j++) - printk(KERN_INFO "%s: CmdFrm.operand[%d]=0x%x\n",__FUNCTION__,j,CmdFrm.operand[j]); - - printk(KERN_INFO "%s: cmdfrm.length = %u\n",__FUNCTION__,CmdFrm.length); - */ - if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0) - return -EIO; - - if(RspFrm.resp != ACCEPTED) { - printk("%s: AVCWrite returned code %d\n",__FUNCTION__,RspFrm.resp); - return -EINVAL; - } - - return 0; -} - -int AVCSubUnitInfo(struct firesat*firesat, char *subunitcount) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts = AVC; - CmdFrm.ctype = STATUS; - CmdFrm.sutyp = 0x1f; - CmdFrm.suid = 0x7; - CmdFrm.opcode = SUBUNIT_Info; - - CmdFrm.operand[0] = 0x07; - CmdFrm.operand[1] = 0xff; - CmdFrm.operand[2] = 0xff; - CmdFrm.operand[3] = 0xff; - CmdFrm.operand[4] = 0xff; - - CmdFrm.length = 8; - - if(AVCWrite(firesat,&CmdFrm,&RspFrm) < 0) - return -EIO; - - if(RspFrm.resp != STABLE) { - printk("%s: AVCWrite returned code %d\n",__FUNCTION__,RspFrm.resp); - return -EINVAL; - } - - if(subunitcount) - *subunitcount = (RspFrm.operand[1] & 0x7) + 1; - - return 0; -} - -static int __AVCRegisterRemoteControl(struct firesat*firesat, int internal) { - AVCCmdFrm CmdFrm; - -// printk(KERN_INFO "%s\n",__FUNCTION__); - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts = AVC; - CmdFrm.ctype = NOTIFY; - CmdFrm.sutyp = 0x1f; - CmdFrm.suid = 0x7; - CmdFrm.opcode = VENDOR; - - CmdFrm.operand[0] = SFE_VENDOR_DE_COMPANYID_0; - CmdFrm.operand[1] = SFE_VENDOR_DE_COMPANYID_1; - CmdFrm.operand[2] = SFE_VENDOR_DE_COMPANYID_2; -// CmdFrm.operand[0] = SFE_VENDOR_EL_COMPANYID_0; -// CmdFrm.operand[1] = SFE_VENDOR_EL_COMPANYID_1; -// CmdFrm.operand[2] = SFE_VENDOR_EL_COMPANYID_2; - CmdFrm.operand[3] = SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL; - - CmdFrm.length = 8; - - if(internal) { - if(__AVCWrite(firesat,&CmdFrm,NULL) < 0) - return -EIO; - } else - if(AVCWrite(firesat,&CmdFrm,NULL) < 0) - return -EIO; - - return 0; -} - -int AVCRegisterRemoteControl(struct firesat*firesat) { - return __AVCRegisterRemoteControl(firesat, 0); -} - -int AVCResetTPDU(struct firesat*firesat) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts = AVC; - CmdFrm.ctype = CONTROL; - CmdFrm.sutyp = 0x05; - CmdFrm.suid = firesat->subunit; - CmdFrm.opcode = VENDOR; - - CmdFrm.operand[0] = SFE_VENDOR_DE_COMPANYID_0; - CmdFrm.operand[1] = SFE_VENDOR_DE_COMPANYID_1; - CmdFrm.operand[2] = SFE_VENDOR_DE_COMPANYID_2; -// CmdFrm.operand[0] = SFE_VENDOR_EL_COMPANYID_0; -// CmdFrm.operand[1] = SFE_VENDOR_EL_COMPANYID_1; -// CmdFrm.operand[2] = SFE_VENDOR_EL_COMPANYID_2; - CmdFrm.operand[3] = SFE_VENDOR_OPCODE_CI_RESET; - - CmdFrm.operand[4] = 0x00; // 0x00 = hard, 0x01 = soft - - CmdFrm.length = 8; - if(AVCWrite(firesat, &CmdFrm, &RspFrm) < 0) - return -EIO; - - if(RspFrm.resp != STABLE) { - printk("%s: AVCWrite returned error %d\n", __FUNCTION__, RspFrm.resp); - return RspFrm.resp; - } - - return 0; -} - -int AVCWriteTPDU(struct firesat*firesat, const char *tpdupacket, int length) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - - if(length < 0 || length > 505 || tpdupacket == NULL) - return -EINVAL; - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts = AVC; - CmdFrm.ctype = CONTROL; - CmdFrm.sutyp = 0x05; - CmdFrm.suid = firesat->subunit; - CmdFrm.opcode = VENDOR; - - CmdFrm.operand[0] = SFE_VENDOR_DE_COMPANYID_0; - CmdFrm.operand[1] = SFE_VENDOR_DE_COMPANYID_1; - CmdFrm.operand[2] = SFE_VENDOR_DE_COMPANYID_2; -// CmdFrm.operand[0] = SFE_VENDOR_EL_COMPANYID_0; -// CmdFrm.operand[1] = SFE_VENDOR_EL_COMPANYID_1; -// CmdFrm.operand[2] = SFE_VENDOR_EL_COMPANYID_2; - CmdFrm.operand[3] = SFE_VENDOR_OPCODE_CI_WRITE_TPDU; - - memcpy(&CmdFrm.operand[6], tpdupacket, length); - - CmdFrm.length = length + 9; - CmdFrm.operand[4] = (CmdFrm.length >> 8) & 0xFF; - CmdFrm.operand[5] = CmdFrm.length & 0xFF; - - if(CmdFrm.length % 4) - CmdFrm.length += 4 - (CmdFrm.length % 4); - - if(AVCWrite(firesat, &CmdFrm, &RspFrm) < 0) - return -EIO; - - if(RspFrm.resp != STABLE) { - printk("%s: AVCWrite returned error %d\n",__FUNCTION__,RspFrm.resp); - return RspFrm.resp; - } - return 0; -} - -int AVCReadTPDU(struct firesat*firesat, char *tpdupacket, int *length) { - AVCCmdFrm CmdFrm; - AVCRspFrm RspFrm; - - if(!length || !tpdupacket) - return -EINVAL; - - memset(&CmdFrm, 0, sizeof(AVCCmdFrm)); - - CmdFrm.cts = AVC; - CmdFrm.ctype = STATUS; - CmdFrm.sutyp = 0x05; - CmdFrm.suid = firesat->subunit; - CmdFrm.opcode = VENDOR; - -// CmdFrm.operand[0] = SFE_VENDOR_EL_COMPANYID_0; - CmdFrm.operand[0] = SFE_VENDOR_DE_COMPANYID_0; -// CmdFrm.operand[1] = SFE_VENDOR_EL_COMPANYID_1; - CmdFrm.operand[1] = SFE_VENDOR_DE_COMPANYID_1; -// CmdFrm.operand[2] = SFE_VENDOR_EL_COMPANYID_2; - CmdFrm.operand[2] = SFE_VENDOR_DE_COMPANYID_2; -// CmdFrm.operand[3] = SFE_VENDOR_OPCODE_CI_READ_TPDU; - - CmdFrm.length = 8; - - if(AVCWrite(firesat, &CmdFrm, &RspFrm) < 0) - return -EIO; - - if(RspFrm.resp != STABLE) { - printk("%s: AVCWrite returned error %d\n",__FUNCTION__,RspFrm.resp); - return RspFrm.resp; - } - - switch(RspFrm.operand[4]) { - case 0x00: { - int len = (RspFrm.operand[5] << 8) + RspFrm.operand[6]; - if(len < *length) - *length = len; - if(*length > 0) - memcpy(tpdupacket, &RspFrm.operand[7], *length); - break; - } - case 0xFF: - printk("%s: No CI module present\n",__FUNCTION__); - return -EINVAL; - case 0xFE: - printk("%s: No CI data\n",__FUNCTION__); - *length = 0; - break; - case 0xFD: - printk("%s: CI error\n",__FUNCTION__); - return -EIO; - default: - printk("%s: unknown CI error\n",__FUNCTION__); - return -EINVAL; - } - return 0; -} - diff --git a/v4l_experimental/firesat/avc_api.h b/v4l_experimental/firesat/avc_api.h deleted file mode 100644 index 7948a8f9d..000000000 --- a/v4l_experimental/firesat/avc_api.h +++ /dev/null @@ -1,435 +0,0 @@ -/*************************************************************************** - avc_api.h - description - ------------------- - begin : Wed May 1 2000 - copyright : (C) 2000 by Manfred Weihs - copyright : (C) 2003 by Philipp Gutgsell - email : 0014guph@edu.fh-kaernten.ac.at - ***************************************************************************/ - -/*************************************************************************** - * * - * This program 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. * - * * - ***************************************************************************/ - -/* - This is based on code written by Peter Halwachs, Thomas Groiss and Andreas Monitzer. -*/ - - -#ifndef __AVC_API_H__ -#define __AVC_API_H__ - -#include <linux/dvb/frontend.h> - -#define BYTE unsigned char -#define WORD unsigned short -#define DWORD unsigned long -#define ULONG unsigned long -#define LONG long - - -/************************************************************* - - FCP Address range - -**************************************************************/ - -#define RESPONSE_REGISTER 0xFFFFF0000D00ULL -#define COMMAND_REGISTER 0xFFFFF0000B00ULL -#define PCR_BASE_ADDRESS 0xFFFFF0000900ULL - - -/********************** ********************* *************** - - definition of structures - -*************************************************************/ - -typedef struct -{ - int Nr_SourcePlugs; - int Nr_DestinationPlugs; -} TunerInfo; - - -/*********************************************** - - supported cts - -************************************************/ - -#define AVC 0x0 - -// FCP command frame with ctype = 0x0 is AVC command frame - -#ifdef __LITTLE_ENDIAN - -// Definition FCP Command Frame -typedef struct _AVCCmdFrm -{ - // AV/C command frame - BYTE ctype : 4 ; // command type - BYTE cts : 4 ; // always 0x0 for AVC - BYTE suid : 3 ; // subunit ID - BYTE sutyp : 5 ; // subunit_typ - BYTE opcode : 8 ; // opcode - BYTE operand[509] ; // array of operands [1-507] - int length; //length of the command frame -} AVCCmdFrm ; - -// Definition FCP Response Frame -typedef struct _AVCRspFrm -{ - // AV/C response frame - BYTE resp : 4 ; // response type - BYTE cts : 4 ; // always 0x0 for AVC - BYTE suid : 3 ; // subunit ID - BYTE sutyp : 5 ; // subunit_typ - BYTE opcode : 8 ; // opcode - BYTE operand[509] ; // array of operands [1-507] - int length; //length of the response frame -} AVCRspFrm ; - -#else - -typedef struct _AVCCmdFrm -{ - BYTE cts:4; - BYTE ctype:4; - BYTE sutyp:5; - BYTE suid:3; - BYTE opcode; - BYTE operand[509]; - int length; -} AVCCmdFrm; - -typedef struct _AVCRspFrm -{ - BYTE cts:4; - BYTE resp:4; - BYTE sutyp:5; - BYTE suid:3; - BYTE opcode; - BYTE operand[509]; - int length; -} AVCRspFrm; - -#endif - -/************************************************************* - - - AVC command types (ctype) - -**************************************************************/// - - -#define CONTROL 0x00 -#define STATUS 0x01 -#define INQUIRY 0x02 -#define NOTIFY 0x03 - -/************************************************************* - - AVC respond types - -**************************************************************/// - -#define NOT_IMPLEMENTED 0x8 -#define ACCEPTED 0x9 -#define REJECTED 0xA -#define STABLE 0xC -#define CHANGED 0xD -#define INTERIM 0xF - -/************************************************************* - - AVC FW UPDATE Responses - -**************************************************************/// - -#define FW_INVALID_COUNT 0x4 -#define FW_INVALID_CRC 0x5 -#define FW_SUCCESS 0x6 -#define FW_ERROR 0x7 -#define FW_START_BURNING 0x8 -#define FW_INVALID_HW_VERSION 0x9 - -/************************************************************* - - AVC opcodes - -**************************************************************/// -#define CONNECT 0x24 -#define DISCONNECT 0x25 -#define UNIT_INFO 0x30 -#define SUBUNIT_Info 0x31 -#define VENDOR 0x00 - -#define PLUG_INFO 0x02 -#define OPEN_DESCRIPTOR 0x08 -#define READ_DESCRIPTOR 0x09 -#define OBJECT_NUMBER_SELECT 0x0D - -/************************************************************* - - AVCTuner opcodes - -**************************************************************/ - -#define DSIT 0xC8 -#define DSD 0xCB -#define DESCRIPTOR_TUNER_STATUS 0x80 -#define DESCRIPTOR_SUBUNIT_IDENTIFIER 0x00 - -/************************************************************* - - AVCTuner list types - -**************************************************************/ - -#define Multiplex_List 0x80 -#define Service_List 0x82 - -/************************************************************* - - AVCTuner object entries - -**************************************************************/ - -#define Multiplex 0x80 -#define Service 0x82 -#define Service_with_specified_components 0x83 -#define Preferred_components 0x90 -#define Component 0x84 - -/************************************************************* - - Vendor-specific commands - -**************************************************************/ - -#define SFE_VENDOR_EL_COMPANYID_0 0x00 -#define SFE_VENDOR_EL_COMPANYID_1 0x0C -#define SFE_VENDOR_EL_COMPANYID_2 0x6C -#define SFE_VENDOR_DE_COMPANYID_0 0x00 -#define SFE_VENDOR_DE_COMPANYID_1 0x12 -#define SFE_VENDOR_DE_COMPANYID_2 0x87 - -#define SFE_VENDOR_OPCODE_SET_LNB_PARAMS 0x50 -#define SFE_VENDOR_OPCODE_GET_LNB_PARAMS 0x51 -#define SFE_VENDOR_OPCODE_LNB_CONTROL 0x52 - -#define SFE_VENDOR_OPCODE_CI_READ_TPDU 0x54 -#define SFE_VENDOR_OPCODE_CI_WRITE_TPDU 0x53 -#define SFE_VENDOR_OPCODE_CI_RESET 0x55 - -#define SFE_VENDOR_MAX_NR_COMPONENTS 0x4 -#define SFE_VENDOR_MAX_NR_SERVICES 0x3 -#define SFE_VENDOR_MAX_NR_DSD_ELEMENTS 0x10 - -#define SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL 0x0A - - -//AVCTuner DVB identifier service_ID - -#define DVB 0x20 - -/************************************************************* - - AVC descriptor types - -**************************************************************/ - -#define Subunit_Identifier_Descriptor 0x00 -#define Tuner_Status_Descriptor 0x80 - -typedef struct -{ - BYTE Subunit_Type; - BYTE Max_Subunit_ID; -} SUBUNIT_INFO; - -/************************************************************* - - AVCTuner DVB object IDs are 6 byte long - -**************************************************************/ - -typedef struct -{ - BYTE Byte0; - BYTE Byte1; - BYTE Byte2; - BYTE Byte3; - BYTE Byte4; - BYTE Byte5; - -}OBJECT_ID; - -/************************************************************* - - MULIPLEX Structs - -**************************************************************/ -typedef struct -{ -#ifdef __LITTLE_ENDIAN - BYTE RF_frequency_hByte:6; - BYTE raster_Frequency:2;//Bit7,6 raster frequency -#else - BYTE raster_Frequency:2; - BYTE RF_frequency_hByte:6; -#endif - BYTE RF_frequency_mByte; - BYTE RF_frequency_lByte; - -}FREQUENCY; - -#ifdef __LITTLE_ENDIAN - -typedef struct -{ - BYTE Modulation :1; - BYTE FEC_inner :1; - BYTE FEC_outer :1; - BYTE Symbol_Rate :1; - BYTE Frequency :1; - BYTE Orbital_Pos :1; - BYTE Polarisation :1; - BYTE reserved_fields :1; - BYTE reserved1 :7; - BYTE Network_ID :1; - -}MULTIPLEX_VALID_FLAGS; - -typedef struct -{ - BYTE GuardInterval:1; - BYTE CodeRateLPStream:1; - BYTE CodeRateHPStream:1; - BYTE HierarchyInfo:1; - BYTE Constellation:1; - BYTE Bandwidth:1; - BYTE CenterFrequency:1; - BYTE reserved1:1; - BYTE reserved2:5; - BYTE OtherFrequencyFlag:1; - BYTE TransmissionMode:1; - BYTE NetworkId:1; -}MULTIPLEX_VALID_FLAGS_DVBT; - -#else - -typedef struct -{ - BYTE reserved_fields:1; - BYTE Polarisation:1; - BYTE Orbital_Pos:1; - BYTE Frequency:1; - BYTE Symbol_Rate:1; - BYTE FEC_outer:1; - BYTE FEC_inner:1; - BYTE Modulation:1; - BYTE Network_ID:1; - BYTE reserved1:7; -}MULTIPLEX_VALID_FLAGS; - -typedef struct -{ - BYTE reserved1:1; - BYTE CenterFrequency:1; - BYTE Bandwidth:1; - BYTE Constellation:1; - BYTE HierarchyInfo:1; - BYTE CodeRateHPStream:1; - BYTE CodeRateLPStream:1; - BYTE GuardInterval:1; - BYTE NetworkId:1; - BYTE TransmissionMode:1; - BYTE OtherFrequencyFlag:1; - BYTE reserved2:5; -}MULTIPLEX_VALID_FLAGS_DVBT; - -#endif - -typedef union -{ - - MULTIPLEX_VALID_FLAGS Bits; - MULTIPLEX_VALID_FLAGS_DVBT Bits_T; - struct - { - BYTE ByteHi; - BYTE ByteLo; - } Valid_Word; - -} M_VALID_FLAGS; - -typedef struct -{ -#ifdef __LITTLE_ENDIAN - BYTE ActiveSystem; - BYTE reserved:5; - BYTE NoRF:1; - BYTE Moving:1; - BYTE Searching:1; - - BYTE SelectedAntenna:7; - BYTE Input:1; - - BYTE BER[4]; - - BYTE SignalStrength; - FREQUENCY Frequency; - - BYTE ManDepInfoLength; -#else - BYTE ActiveSystem; - BYTE Searching:1; - BYTE Moving:1; - BYTE NoRF:1; - BYTE reserved:5; - - BYTE Input:1; - BYTE SelectedAntenna:7; - - BYTE BER[4]; - - BYTE SignalStrength; - FREQUENCY Frequency; - - BYTE ManDepInfoLength; -#endif -} ANTENNA_INPUT_INFO; // 11 Byte - -#define LNBCONTROL_DONTCARE 0xff - -extern int AVCWrite(struct firesat *firesat, const AVCCmdFrm *CmdFrm, AVCRspFrm *RspFrm); -extern int AVCRecv(struct firesat *firesat, u8 *data, size_t length); - -extern int AVCTuner_DSIT(struct firesat *firesat, - int Source_Plug, - struct dvb_frontend_parameters *params, - BYTE *status); - -extern int AVCTunerStatus(struct firesat *firesat, ANTENNA_INPUT_INFO *antenna_input_info); -extern int AVCTuner_DSD(struct firesat *firesat, struct dvb_frontend_parameters *params, BYTE *status); -extern int AVCTuner_SetPIDs(struct firesat *firesat, unsigned char pidc, u16 pid[]); - -extern int AVCIdentifySubunit(struct firesat *firesat, unsigned char *systemId, int *transport, int *has_ci); -extern int AVCLNBControl(struct firesat *firesat, char voltage, char burst, char conttone, char nrdiseq, struct dvb_diseqc_master_cmd *diseqcmd); -extern int AVCSubUnitInfo(struct firesat *firesat, char *subunitcount); -extern int AVCRegisterRemoteControl(struct firesat *firesat); - -extern int AVCResetTPDU(struct firesat *firesat); -extern int AVCWriteTPDU(struct firesat *firesat, const char *tpdupacket, int length); -extern int AVCReadTPDU(struct firesat *firesat, char *tpdupacket, int *length); - -#endif - diff --git a/v4l_experimental/firesat/cmp.c b/v4l_experimental/firesat/cmp.c deleted file mode 100644 index 29f8a7d3c..000000000 --- a/v4l_experimental/firesat/cmp.c +++ /dev/null @@ -1,176 +0,0 @@ -#include "cmp.h" -#include <ieee1394.h> -#include <nodemgr.h> -#include <highlevel.h> -#include <ohci1394.h> -#include <hosts.h> -#include <ieee1394_transactions.h> -#include "avc_api.h" - -typedef struct _OPCR -{ - BYTE PTPConnCount : 6 ; // Point to point connect. counter - BYTE BrConnCount : 1 ; // Broadcast connection counter - BYTE OnLine : 1 ; // On Line - - BYTE ChNr : 6 ; // Channel number - BYTE Res : 2 ; // Reserved - - BYTE PayloadHi : 2 ; // Payoad high bits - BYTE OvhdID : 4 ; // Overhead ID - BYTE DataRate : 2 ; // Data Rate - - BYTE PayloadLo ; // Payoad low byte -} OPCR ; - -#define FIRESAT_SPEED IEEE1394_SPEED_400 - -static int cmp_read(struct firesat *firesat, void *buffer, u64 addr, size_t length) { - int ret; - if(down_interruptible(&firesat->avc_sem)) - return -EINTR; - - ret = hpsb_read(firesat->host, firesat->nodeentry->nodeid, firesat->nodeentry->generation, - addr, buffer, length); - - up(&firesat->avc_sem); - return ret; -} - -static int cmp_lock(struct firesat *firesat, quadlet_t *data, u64 addr, quadlet_t arg, int ext_tcode) { - int ret; - if(down_interruptible(&firesat->avc_sem)) - return -EINTR; - - ret = hpsb_lock(firesat->host, firesat->nodeentry->nodeid, firesat->nodeentry->generation, - addr, ext_tcode, data, arg); - - up(&firesat->avc_sem); - return ret; -} - -//try establishing a point-to-point connection (may be interrupted by a busreset -int try_CMPEstablishPPconnection(struct firesat *firesat, int output_plug, int iso_channel) { - unsigned int BWU; //bandwidth to allocate - - quadlet_t old_oPCR,test_oPCR = 0x0; - u64 oPCR_address=0xfffff0000904ull+(output_plug << 2); - int result=cmp_read(firesat, &test_oPCR, oPCR_address, 4); - - printk(KERN_INFO "%s: nodeid = %d\n",__FUNCTION__,firesat->nodeentry->nodeid); - - if (result < 0) { - printk("%s: cannot read oPCR\n", __FUNCTION__); - return result; - } else { - printk(KERN_INFO "%s: oPCR = %08x\n",__FUNCTION__,test_oPCR); - do { - OPCR *hilf= (OPCR*) &test_oPCR; - - if (!hilf->OnLine) { - printk("%s: Output offline; oPCR: %08x\n", __FUNCTION__, test_oPCR); - return -EBUSY; - } else { - quadlet_t new_oPCR; - - old_oPCR=test_oPCR; - if (hilf->PTPConnCount) { - if (hilf->ChNr != iso_channel) { - printk("%s: Output plug has already connection on channel %u; cannot change it to channel %u\n",__FUNCTION__,hilf->ChNr,iso_channel); - return -EBUSY; - } else - printk(KERN_INFO "%s: Overlaying existing connection; connection counter was: %u\n",__FUNCTION__, hilf->PTPConnCount); - BWU=0; //we allocate no bandwidth (is this necessary?) - } else { - hilf->ChNr=iso_channel; - hilf->DataRate=FIRESAT_SPEED; - - hilf->OvhdID=0; //FIXME: that is for worst case -> optimize - BWU=hilf->OvhdID?hilf->OvhdID*32:512; - BWU += (hilf->PayloadLo + (hilf->PayloadHi << 8) +3) * (2 << (3-hilf->DataRate)); -/* if (allocate_1394_resources(iso_channel,BWU)) - { - cout << "Allocation of resources failed\n"; - return -2; - }*/ - } - - hilf->PTPConnCount++; - new_oPCR=test_oPCR; - printk(KERN_INFO "%s: trying compare_swap...\n",__FUNCTION__); - printk(KERN_INFO "%s: oPCR_old: %08x, oPCR_new: %08x\n",__FUNCTION__, old_oPCR, new_oPCR); - result=cmp_lock(firesat, &test_oPCR, oPCR_address, old_oPCR, 2); - - if (result < 0) { - printk("%s: cannot compare_swap oPCR\n",__FUNCTION__); - return result; - } - if ((old_oPCR != test_oPCR) && (!((OPCR*) &old_oPCR)->PTPConnCount)) - { - printk("%s: change of oPCR failed -> freeing resources\n",__FUNCTION__); -// hilf= (OPCR*) &new_oPCR; -// unsigned int BWU=hilf->OvhdID?hilf->OvhdID*32:512; -// BWU += (hilf->Payload+3) * (2 << (3-hilf->DataRate)); -/* if (deallocate_1394_resources(iso_channel,BWU)) - { - - cout << "Deallocation of resources failed\n"; - return -3; - }*/ - } - } - } - while (old_oPCR != test_oPCR); - } - return 0; -} - -//try breaking a point-to-point connection (may be interrupted by a busreset -int try_CMPBreakPPconnection(struct firesat *firesat, int output_plug,int iso_channel) { - quadlet_t old_oPCR,test_oPCR; - - u64 oPCR_address=0xfffff0000904ull+(output_plug << 2); - int result=cmp_read(firesat, &test_oPCR, oPCR_address, 4); - - printk(KERN_INFO "%s\n",__FUNCTION__); - - if (result < 0) { - printk("%s: cannot read oPCR\n", __FUNCTION__); - return result; - } else { - do { - OPCR *hilf= (OPCR*) &test_oPCR; - - if (!hilf->OnLine || !hilf->PTPConnCount || hilf->ChNr != iso_channel) { - printk("%s: Output plug does not have PtP-connection on that channel; oPCR: %08x\n", __FUNCTION__, test_oPCR); - return -EINVAL; - } else { - quadlet_t new_oPCR; - old_oPCR=test_oPCR; - hilf->PTPConnCount--; - new_oPCR=test_oPCR; - -// printk(KERN_INFO "%s: trying compare_swap...\n", __FUNCTION__); - result=cmp_lock(firesat, &test_oPCR, oPCR_address, old_oPCR, 2); - if (result < 0) { - printk("%s: cannot compare_swap oPCR\n",__FUNCTION__); - return result; - } - } - - } while (old_oPCR != test_oPCR); - -/* hilf = (OPCR*) &old_oPCR; - if (hilf->PTPConnCount == 1) { // if we were the last owner of this connection - cout << "deallocating 1394 resources\n"; - unsigned int BWU=hilf->OvhdID?hilf->OvhdID*32:512; - BWU += (hilf->PayloadLo + (hilf->PayloadHi << 8) +3) * (2 << (3-hilf->DataRate)); - if (deallocate_1394_resources(iso_channel,BWU)) - { - cout << "Deallocation of resources failed\n"; - return -3; - } - }*/ - } - return 0; -} diff --git a/v4l_experimental/firesat/cmp.h b/v4l_experimental/firesat/cmp.h deleted file mode 100644 index d43fbc29f..000000000 --- a/v4l_experimental/firesat/cmp.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __FIRESAT__CMP_H_ -#define __FIRESAT__CMP_H_ - -#include "firesat.h" - -extern int try_CMPEstablishPPconnection(struct firesat *firesat, int output_plug, int iso_channel); -extern int try_CMPBreakPPconnection(struct firesat *firesat, int output_plug,int iso_channel); - -#endif diff --git a/v4l_experimental/firesat/firesat-ci.c b/v4l_experimental/firesat/firesat-ci.c deleted file mode 100644 index 3d005cb56..000000000 --- a/v4l_experimental/firesat/firesat-ci.c +++ /dev/null @@ -1,124 +0,0 @@ -#include "firesat-ci.h" -#include "firesat.h" -#include "avc_api.h" - -#include <linux/dvb/ca.h> - -#include "dvbdev.h" - -static int firesat_ca_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *parg) { - struct firesat *firesat = (struct firesat*)((struct dvb_device*)file->private_data)->priv; - int err; - -// printk(KERN_INFO "%s: ioctl %d\n",__FUNCTION__,cmd); - - switch(cmd) { - case CA_RESET: - err = AVCResetTPDU(firesat); -// if(err==0) - mdelay(3000); - break; - case CA_GET_CAP: { - ca_caps_t *cap=(ca_caps_t*)parg; - cap->slot_num = 1; - cap->slot_type = CA_CI_LINK; - cap->descr_num = 1; - cap->descr_type = CA_DSS; // ### peter fragen! - - err = 0; - break; - } - case CA_GET_SLOT_INFO: { - ca_slot_info_t *slot=(ca_slot_info_t*)parg; - if(slot->num == 0) { - slot->type = CA_CI | CA_CI_LINK | CA_DESCR; - slot->flags = CA_CI_MODULE_PRESENT | CA_CI_MODULE_READY; - } else { - slot->type = 0; - slot->flags = 0; - } - err = 0; - break; - } - default: - err=-EINVAL; - } - return err; -} - -static int firesat_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { - return dvb_usercopy(inode, file, cmd, arg, firesat_ca_do_ioctl); -} - -static ssize_t firesat_ca_io_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { - struct firesat *firesat = (struct firesat*)((struct dvb_device*)file->private_data)->priv; - char *data=kmalloc(count,GFP_KERNEL); -// printk(KERN_INFO "%s: count = %d\n",__FUNCTION__, count); - copy_from_user(data,buf,count); - int r=AVCWriteTPDU(firesat, data, count); - kfree(data); - if(!r) - return count; - printk("%s: failed writing data\n",__FUNCTION__); - return 0; -} - -static ssize_t firesat_ca_io_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - struct firesat *firesat = (struct firesat*)((struct dvb_device*)file->private_data)->priv; - char *data=kmalloc(count,GFP_KERNEL); -// printk(KERN_INFO "%s: count = %d\n",__FUNCTION__,count); - int r=AVCReadTPDU(firesat, data, &count); - if(!r) { - copy_to_user(buf,data,count); - kfree(data); - return count; - } - kfree(data); - return 0; -} - -static int firesat_ca_io_open(struct inode *inode, struct file *file) { - printk(KERN_INFO "%s!\n",__FUNCTION__); - return dvb_generic_open(inode, file); -} - -static int firesat_ca_io_release(struct inode *inode, struct file *file) { - printk(KERN_INFO "%s!\n",__FUNCTION__); - return dvb_generic_release(inode, file); -} - -static unsigned int firesat_ca_io_poll(struct file *file, poll_table *wait) { -// printk(KERN_INFO "%s!\n",__FUNCTION__); - return POLLIN; -} - -static struct file_operations firesat_ca_fops = { - .owner = THIS_MODULE, - .read = firesat_ca_io_read, - .write = firesat_ca_io_write, - .ioctl = firesat_ca_ioctl, - .open = firesat_ca_io_open, - .release = firesat_ca_io_release, - .poll = firesat_ca_io_poll, -}; - -static struct dvb_device firesat_ca = { - .priv = NULL, - .users = 1, - .readers = 1, - .writers = 1, - .fops = &firesat_ca_fops, -}; - -int firesat_ca_init(struct firesat *firesat) { - int ret = dvb_register_device(firesat->adapter, &firesat->cadev, &firesat_ca, firesat, DVB_DEVICE_CA); - if(ret) return ret; - AVCResetTPDU(firesat); - // avoid unnecessary delays, we're not talking to the CI yet anyways - return 0; -} - -void firesat_ca_release(struct firesat *firesat) { - dvb_unregister_device(firesat->cadev); -} - diff --git a/v4l_experimental/firesat/firesat-ci.h b/v4l_experimental/firesat/firesat-ci.h deleted file mode 100644 index dafe3f0f0..000000000 --- a/v4l_experimental/firesat/firesat-ci.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __FIRESAT_CA_H -#define __FIRESAT_CA_H - -#include "firesat.h" - -int firesat_ca_init(struct firesat *firesat); -void firesat_ca_release(struct firesat *firesat); - -#endif diff --git a/v4l_experimental/firesat/firesat-rc.c b/v4l_experimental/firesat/firesat-rc.c deleted file mode 100644 index 702f90f6c..000000000 --- a/v4l_experimental/firesat/firesat-rc.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "firesat.h" -#include "firesat-rc.h" - -#include <linux/input.h> - -static u16 firesat_irtable[] = { - KEY_ESC, - KEY_F9, - KEY_1, - KEY_2, - KEY_3, - KEY_4, - KEY_5, - KEY_6, - KEY_7, - KEY_8, - KEY_9, - KEY_I, - KEY_0, - KEY_ENTER, - KEY_RED, - KEY_UP, - KEY_GREEN, - KEY_F10, - KEY_SPACE, - KEY_F11, - KEY_YELLOW, - KEY_DOWN, - KEY_BLUE, - KEY_Z, - KEY_P, - KEY_PAGEDOWN, - KEY_LEFT, - KEY_W, - KEY_RIGHT, - KEY_P, - KEY_M, - KEY_R, - KEY_V, - KEY_C, - 0 -}; - -static struct input_dev firesat_idev; - -int firesat_register_rc(void) { - int index; - - memset(&firesat_idev, 0, sizeof(firesat_idev)); - - firesat_idev.evbit[0] = BIT(EV_KEY); - - for(index=0;firesat_irtable[index] != 0; index++) - set_bit(firesat_irtable[index], firesat_idev.keybit); - - input_register_device(&firesat_idev); - - return 0; -} - -int firesat_unregister_rc(void) { - input_unregister_device(&firesat_idev); - return 0; -} - -int firesat_got_remotecontrolcode(u16 code) { - u16 keycode; - - if(code > 0x4500 && code < 0x4520) - keycode = firesat_irtable[code - 0x4501]; - else if(code > 0x453f && code < 0x4543) - keycode = firesat_irtable[code - 0x4521]; - else { - printk("%s: invalid key code 0x%04x\n",__FUNCTION__,code); - return -EINVAL; - } - - input_report_key(&firesat_idev, keycode, 1); - input_report_key(&firesat_idev, keycode, 0); - - return 0; -} - diff --git a/v4l_experimental/firesat/firesat-rc.h b/v4l_experimental/firesat/firesat-rc.h deleted file mode 100644 index e89a8069b..000000000 --- a/v4l_experimental/firesat/firesat-rc.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __FIRESAT_LIRC_H -#define __FIRESAT_LIRC_H - -extern int firesat_register_rc(void); -extern int firesat_unregister_rc(void); -extern int firesat_got_remotecontrolcode(u16 code); - -#endif - diff --git a/v4l_experimental/firesat/firesat.c b/v4l_experimental/firesat/firesat.c deleted file mode 100644 index dcf268702..000000000 --- a/v4l_experimental/firesat/firesat.c +++ /dev/null @@ -1,917 +0,0 @@ -/* - * FireSAT DVB driver - * - * Copyright (c) 2004 Andreas Monitzer <andy@monitzer.com> - * - * This program 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. - */ -#include <linux/init.h> -#include <linux/slab.h> -#include <linux/wait.h> -#include <linux/module.h> -#include <linux/delay.h> -#include <linux/time.h> -#include <linux/errno.h> -#include <asm/semaphore.h> -#include <ieee1394_hotplug.h> -#include <nodemgr.h> -#include <highlevel.h> -#include <ohci1394.h> -#include <hosts.h> - -/*#include "dvb_frontend.h" -#include "dmxdev.h" -#include "dvb_demux.h" -#include "dvb_net.h" - -#include <linux/dvb/frontend.h> -#include <linux/dvb/dmx.h>*/ -#include "firesat.h" -#include "avc_api.h" -#include "cmp.h" -#include "firesat-rc.h" -#include "firesat-ci.h" - -#define FIRESAT_Vendor_ID 0x001287 - -/*** HOTPLUG STUFF **********************************************************/ -/* - * Export information about protocols/devices supported by this driver. - */ -static struct ieee1394_device_id firesat_id_table[] = { - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, - .model_id = 0x11, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, - .model_id = 0x12, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x13, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x14, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x21, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x22, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x23, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x24, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x25, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x26, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x27, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x34, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x35, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { - .match_flags = /*IEEE1394_MATCH_VENDOR_ID |*/ IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, -// .vendor_id = FIRESAT_Vendor_ID & 0xffffff, -// .vendor_id = 0x000000, - .model_id = 0x36, - .specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = AVC_SW_VERSION_ENTRY & 0xffffff - }, - { } -}; - -MODULE_DEVICE_TABLE(ieee1394, firesat_id_table); - -/* list of all firesat devices */ -LIST_HEAD(firesat_list); -spinlock_t firesat_list_lock = SPIN_LOCK_UNLOCKED; - -static void firesat_add_host (struct hpsb_host *host); -static void firesat_remove_host (struct hpsb_host *host); -static void firesat_host_reset(struct hpsb_host *host); -static void iso_receive(struct hpsb_host *host, int channel, quadlet_t *data, - size_t length); -static void fcp_request(struct hpsb_host *host, int nodeid, int direction, - int cts, u8 *data, size_t length); - -static struct hpsb_highlevel firesat_highlevel = { - .name = "FireSAT", - .add_host = firesat_add_host, - .remove_host = firesat_remove_host, - .host_reset = firesat_host_reset, - .iso_receive = iso_receive, - .fcp_request = fcp_request, -}; - - -static struct dvb_frontend_info firesat_S_frontend_info = { - .name = "FireSAT DVB-S Frontend", - .type = FE_QPSK, - .frequency_min = 950000, - .frequency_max = 2150000, - .frequency_stepsize = 125, - .symbol_rate_min = 1000000, - .symbol_rate_max = 40000000, - .caps = FE_CAN_INVERSION_AUTO | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | - FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | - FE_CAN_FEC_AUTO | FE_CAN_QPSK, -}; - -static struct dvb_frontend_info firesat_C_frontend_info = { - .name = "FireSAT DVB-C Frontend", - .type = FE_QAM, - .frequency_min = 47000000, - .frequency_max = 866000000, - .frequency_stepsize = 62500, - .symbol_rate_min = 870000, - .symbol_rate_max = 6900000, - .caps = FE_CAN_INVERSION_AUTO | FE_CAN_QAM_16 | FE_CAN_QAM_32 | - FE_CAN_QAM_64 | FE_CAN_QAM_128 | FE_CAN_QAM_256 | - FE_CAN_QAM_AUTO, -}; - -static struct dvb_frontend_info firesat_T_frontend_info = { - .name = "FireSAT DVB-T Frontend", - .type = FE_OFDM, - .frequency_min = 49000000, - .frequency_max = 861000000, - .frequency_stepsize = 62500, - .caps = FE_CAN_INVERSION_AUTO | FE_CAN_FEC_2_3 | - FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | - FE_CAN_HIERARCHY_AUTO, -}; - -static void firesat_add_host (struct hpsb_host *host) { - struct ti_ohci *ohci; -// printk(KERN_INFO "FireSAT add_host (nodeid = 0x%x)\n",host->node_id); - - /* We only work with the OHCI-1394 driver */ - if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME)) - return; - - ohci = (struct ti_ohci *)host->hostdata; - - if (!hpsb_create_hostinfo(&firesat_highlevel, host, 0)) { - printk(KERN_ERR "Cannot allocate hostinfo\n"); - return; - } - - hpsb_set_hostinfo(&firesat_highlevel, host, ohci); - hpsb_set_hostinfo_key(&firesat_highlevel, host, ohci->host->id); -} - -static void firesat_remove_host (struct hpsb_host *host) { -// printk(KERN_INFO "FireSAT remove_host (nodeid = 0x%x)\n",host->node_id); -} - -static void firesat_host_reset(struct hpsb_host *host) { - printk(KERN_INFO "FireSAT host_reset (nodeid = 0x%x, hosts active = %d)\n",host->node_id,host->nodes_active); -} - -struct firewireheader { - union { - struct { - unsigned char tcode:4; - unsigned char sy:4; - unsigned char tag:2; - unsigned char channel:6; - - unsigned char length_l; - unsigned char length_h; - } hdr; - unsigned long val; - }; -}; - -struct CIPHeader { - union { - struct { - unsigned char syncbits:2; - unsigned char sid:6; - unsigned char dbs; - unsigned char fn:2; - unsigned char qpc:3; - unsigned char sph:1; - unsigned char rsv:2; - unsigned char dbc; - unsigned char syncbits2:2; - unsigned char fmt:6; - unsigned long fdf:24; - } cip; - unsigned long long val; - }; -}; - -struct MPEG2Header { - union { - struct { - unsigned char sync; // must be 0x47 - unsigned char transport_error_indicator:1; - unsigned char payload_unit_start_indicator:1; - unsigned char transport_priority:1; - unsigned short pid:13; - unsigned char transport_scrambling_control:2; - unsigned char adaption_field_control:2; - unsigned char continuity_counter:4; - } hdr; - unsigned long val; - }; -}; - -static void iso_receive(struct hpsb_host *host, int channel, quadlet_t *data, - size_t length) { -// printk(KERN_INFO "FireSAT iso_receive: channel %d, length = %d\n", channel, length); - - if(length <= 12) - return; // ignore empty packets - else { - struct firesat *firesat=NULL; - struct firesat *firesat_entry; - unsigned long flags; - - spin_lock_irqsave(&firesat_list_lock, flags); - list_for_each_entry(firesat_entry,&firesat_list,list) { - if(firesat_entry->host == host && firesat_entry->isochannel == channel) { - firesat=firesat_entry; - break; - } - } - spin_unlock_irqrestore(&firesat_list_lock, flags); - - if(firesat) { - char *buf=((char*)data) + sizeof(struct firewireheader)+sizeof(struct CIPHeader); - int count = (length-sizeof(struct CIPHeader)) / 192; - -// printk(KERN_INFO "%s: length = %u\n data[0] = %08x\n data[1] = %08x\n data[2] = %08x\n data[3] = %08x\n data[4] = %08x\n",__FUNCTION__, length, data[0],data[1],data[2],data[3],data[4]); - - while (count--) { - - if(buf[sizeof(quadlet_t) /*timestamp*/] == 0x47) - dvb_dmx_swfilter_packet(&firesat->demux, &buf[sizeof(quadlet_t)]); - else - printk("%s: invalid packet, skipping\n", __FUNCTION__); - buf += 188 + sizeof(quadlet_t) /* timestamp */; - } - } - } -} - -static void fcp_request(struct hpsb_host *host, int nodeid, int direction, - int cts, u8 *data, size_t length) { -// printk(KERN_INFO "FireSAT fcp_request length=%d\n",length); - if(length>0 && ((data[0] & 0xF0) >> 4) == 0) { - struct firesat *firesat=NULL; - struct firesat *firesat_entry; - unsigned long flags; - - spin_lock_irqsave(&firesat_list_lock, flags); - list_for_each_entry(firesat_entry,&firesat_list,list) { - if(firesat_entry->host == host && firesat_entry->nodeentry->nodeid == nodeid && (firesat_entry->subunit == (data[1]&0x7) || (firesat_entry->subunit == 0 && (data[1]&0x7) == 0x7))) { - firesat=firesat_entry; - break; - } - } - spin_unlock_irqrestore(&firesat_list_lock, flags); - - if(firesat) - AVCRecv(firesat,data,length); - else - printk("%s: received fcp request from unknown source, ignored\n",__FUNCTION__); - } // else ignore -} - -static int firesat_frontend_ioctl(struct dvb_frontend *frontend, - unsigned int cmd, void *arg) { - struct firesat *firesat=frontend->data; - - switch(cmd) { - case FE_INIT: - firesat->isochannel = firesat->adapter->num << 1 | (firesat->subunit & 0x1); // ### ask IRM - try_CMPEstablishPPconnection(firesat, firesat->subunit, firesat->isochannel); - hpsb_listen_channel(&firesat_highlevel, firesat->host, firesat->isochannel); - break; - case FE_SLEEP: - hpsb_unlisten_channel(&firesat_highlevel, firesat->host, firesat->isochannel); - try_CMPBreakPPconnection(firesat, firesat->subunit, firesat->isochannel); - firesat->isochannel = -1; - break; - case FE_GET_INFO: -// printk(KERN_INFO "FE_GET_INFO\n"); - memcpy(arg, firesat->frontend_info, - sizeof (struct dvb_frontend_info)); - break; - case FE_DISEQC_RESET_OVERLOAD: - case FE_DISEQC_RECV_SLAVE_REPLY: - return -EOPNOTSUPP; - case FE_DISEQC_SEND_MASTER_CMD: - return AVCLNBControl(firesat, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE, 1, (struct dvb_diseqc_master_cmd *)arg); - return 0; - case FE_DISEQC_SEND_BURST: - return 0; -// return AVCLNBControl(firesat, LNBCONTROL_DONTCARE, (((fe_sec_mini_cmd_t)arg)==SEC_MINI_A)?0:1, LNBCONTROL_DONTCARE, 0, NULL); - case FE_SET_TONE: -// return AVCLNBControl(firesat, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE, (((fe_sec_tone_mode_t) arg)==SEC_TONE_ON)?1:0, 0, NULL); - firesat->tone = (fe_sec_tone_mode_t)arg; - return 0; - case FE_SET_VOLTAGE: -// printk(KERN_INFO "FE_SET_VOLTAGE\n"); - firesat->voltage=(fe_sec_voltage_t) arg; - return 0; -// return AVCLNBControl(firesat, ((fe_sec_voltage_t) arg, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE, 0, NULL); - case FE_ENABLE_HIGH_LNB_VOLTAGE: - return -EOPNOTSUPP; - case FE_READ_STATUS: { - ANTENNA_INPUT_INFO info; - fe_status_t *status = (fe_status_t *)arg; -// printk(KERN_INFO "%s: FE_READ_STATUS\n", __FUNCTION__); - - if(AVCTunerStatus(firesat,&info)) { - return -EINVAL; - } -// printk(KERN_INFO "%s: NoRF=%c\n",__FUNCTION__,info.NoRF?'y':'n'); - if(info.NoRF) - *status = 0; - else - *status = *status = FE_HAS_SIGNAL | FE_HAS_VITERBI | - FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK; - - break; - } - case FE_READ_BER: { - ANTENNA_INPUT_INFO info; - u32 *ber = (u32 *)arg; -// printk(KERN_INFO "%s: FE_READ_BER\n", __FUNCTION__); - - if(AVCTunerStatus(firesat,&info)) { - return -EINVAL; - } - -// *ber = *(u32*)info.BER; /* might need some byte ordering correction */ - *ber = ((info.BER[0] << 24) & 0xFF) | ((info.BER[1] << 16) & 0xFF) | ((info.BER[2] << 8) & 0xFF) | (info.BER[3] & 0xFF); - - break; - } - case FE_READ_SIGNAL_STRENGTH: { - ANTENNA_INPUT_INFO info; - u16 *signal = (u16 *)arg; -// printk(KERN_INFO "%s: FE_READ_SIGNAL_STRENGTH\n", __FUNCTION__); - - if(AVCTunerStatus(firesat,&info)) { - return -EINVAL; - } - - *signal = info.SignalStrength; - - break; - } - case FE_READ_SNR: - case FE_READ_UNCORRECTED_BLOCKS: - return -EOPNOTSUPP; - case FE_SET_FRONTEND: { - struct dvb_frontend_parameters *p = - (struct dvb_frontend_parameters *)arg; -// printk(KERN_INFO "FE_GET_INFO\n"); - -// printk(KERN_INFO "%s: FE_SET_FRONTEND\n", __FUNCTION__); - -// printk(KERN_INFO " frequency->%d\n", p->frequency); -// printk(KERN_INFO " symbol_rate->%d\n",p->u.qam.symbol_rate); -// printk(KERN_INFO " inversion->%d\n", p->inversion); - -// if(AVCTuner_DSIT(firesat, 0/*###*/, p, NULL)) -// return -EINVAL; - if(AVCTuner_DSD(firesat, p, NULL) != ACCEPTED) - return -EINVAL; - - break; - } - case FE_GET_FRONTEND: - case FE_GET_EVENT: - return -EOPNOTSUPP; - default: - return -EINVAL; - } - - return 0; -} - -static struct firesat_channel *firesat_channel_allocate(struct firesat *firesat) { - int k; - - printk(KERN_INFO "%s\n",__FUNCTION__); - - if(down_interruptible(&firesat->demux_sem)) - return NULL; - - for(k=0;k<16;k++) { - printk(KERN_INFO "%s: channel %d: active = %d, pid = 0x%x\n",__FUNCTION__,k,firesat->channel[k].active,firesat->channel[k].pid); - if(firesat->channel[k].active == 0) { - firesat->channel[k].active = 1; - up(&firesat->demux_sem); - return &firesat->channel[k]; - } - } - - up(&firesat->demux_sem); - return NULL; // no more channels available -} - -static int firesat_channel_collect(struct firesat *firesat, int *pidc, u16 pid[]) { - int k, l=0; - - if(down_interruptible(&firesat->demux_sem)) - return -EINTR; - - for(k=0;k<16;k++) - if(firesat->channel[k].active == 1) - pid[l++] = firesat->channel[k].pid; - - up(&firesat->demux_sem); - - *pidc = l; - - return 0; -} - -static int firesat_channel_release(struct firesat *firesat, struct firesat_channel *channel) { - if(down_interruptible(&firesat->demux_sem)) - return -EINTR; - - channel->active = 0; - - up(&firesat->demux_sem); - return 0; -} - -static int firesat_start_feed(struct dvb_demux_feed *dvbdmxfeed) { - struct firesat *firesat=(struct firesat*)dvbdmxfeed->demux->priv; - struct firesat_channel *channel; - int pidc,k; - u16 pids[16]; - - printk(KERN_INFO "%s (pid %u)\n",__FUNCTION__,dvbdmxfeed->pid); - - switch (dvbdmxfeed->type) { - case DMX_TYPE_TS: - case DMX_TYPE_SEC: - break; - default: - printk("%s: invalid type %u\n",__FUNCTION__,dvbdmxfeed->type); - return -EINVAL; - } - - if (dvbdmxfeed->type == DMX_TYPE_TS) { - switch (dvbdmxfeed->pes_type) { - case DMX_TS_PES_VIDEO: - case DMX_TS_PES_AUDIO: - case DMX_TS_PES_TELETEXT: - case DMX_TS_PES_PCR: - case DMX_TS_PES_OTHER: - channel = firesat_channel_allocate(firesat); - break; - default: - printk("%s: invalid pes type %u\n",__FUNCTION__,dvbdmxfeed->pes_type); - return -EINVAL; - } - } else { - channel = firesat_channel_allocate(firesat); - } - - if(!channel) { - printk("%s: busy!\n",__FUNCTION__); - return -EBUSY; - } - - dvbdmxfeed->priv = channel; - - channel->dvbdmxfeed = dvbdmxfeed; - channel->pid = dvbdmxfeed->pid; - channel->type = dvbdmxfeed->type; - channel->firesat = firesat; - - if(firesat_channel_collect(firesat, &pidc, pids)) { - firesat_channel_release(firesat, channel); - return -EINTR; - } - - if((k=AVCTuner_SetPIDs(firesat, pidc, pids))) { - firesat_channel_release(firesat, channel); - printk("%s: AVCTuner failed with error %d\n",__FUNCTION__,k); - return k; - } - - return 0; -} - -static int firesat_stop_feed(struct dvb_demux_feed *dvbdmxfeed) { - struct dvb_demux *demux = dvbdmxfeed->demux; - struct firesat *firesat=(struct firesat*)demux->priv; - int k, l=0; - u16 pids[16]; - - printk(KERN_INFO "%s (pid %u)\n",__FUNCTION__,dvbdmxfeed->pid); - - if (dvbdmxfeed->type == DMX_TYPE_TS && !((dvbdmxfeed->ts_type & TS_PACKET) && - (demux->dmx.frontend->source != DMX_MEMORY_FE))) { - if (dvbdmxfeed->ts_type & TS_DECODER) { - if (dvbdmxfeed->pes_type >= DMX_TS_PES_OTHER || - !demux->pesfilter[dvbdmxfeed->pes_type]) - return -EINVAL; - demux->pids[dvbdmxfeed->pes_type] |= 0x8000; - demux->pesfilter[dvbdmxfeed->pes_type] = 0; - } - if (!(dvbdmxfeed->ts_type & TS_DECODER && - dvbdmxfeed->pes_type < DMX_TS_PES_OTHER)) { - return 0; - } - } - - if(down_interruptible(&firesat->demux_sem)) - return -EINTR; - - // list except channel to be removed - for(k=0;k<16;k++) - if(firesat->channel[k].active == 1 && &firesat->channel[k] != (struct firesat_channel*)dvbdmxfeed->priv) - pids[l++] = firesat->channel[k].pid; - - if((k=AVCTuner_SetPIDs(firesat, l, pids))) { - up(&firesat->demux_sem); - return k; - } - - ((struct firesat_channel*)dvbdmxfeed->priv)->active = 0; - - up(&firesat->demux_sem); - - return 0; -} - -static int firesat_probe(struct device *dev) { - struct unit_directory *ud=container_of(dev, struct unit_directory, device); - struct firesat *firesat; - unsigned long flags; - int result; - unsigned char subunitcount=0xff,subunit; - struct firesat **firesats=kmalloc(sizeof(void*)*2,GFP_KERNEL); - - if(!firesats) { - printk("%s: couldn't allocate memory.\n", __FUNCTION__); - return -ENOMEM; - } - -// printk(KERN_INFO "FireSAT: Detected device with GUID %08lx%04lx%04lx\n",(unsigned long)((ud->ne->guid)>>32),(unsigned long)(ud->ne->guid & 0xFFFF),(unsigned long)ud->ne->guid_vendor_id); - printk(KERN_INFO "%s: loading device\n", __FUNCTION__); - - firesats[0]=NULL; - firesats[1]=NULL; - - ud->device.driver_data = firesats; - - for(subunit=0;subunit<subunitcount;subunit++) { - if (!(firesat = kmalloc(sizeof(struct firesat), GFP_KERNEL))) { - printk("%s: couldn't allocate memory.\n", __FUNCTION__); - kfree(firesats); - return -ENOMEM; - } - - memset(firesat, 0, sizeof(struct firesat)); - firesat->host=ud->ne->host; - firesat->guid=ud->ne->guid; - firesat->guid_vendor_id=ud->ne->guid_vendor_id; - firesat->nodeentry=ud->ne; - firesat->isochannel=-1; - firesat->tone = 0xff; - firesat->voltage = 0xff; - if(!(firesat->respfrm = kmalloc(sizeof(AVCRspFrm), GFP_KERNEL))) { - printk("%s: couldn't allocate memory.\n", __FUNCTION__); - kfree(firesat); - return -ENOMEM; - } - - sema_init(&firesat->avc_sem, 1); - atomic_set(&firesat->avc_reply_received, 1); - sema_init(&firesat->demux_sem, 1); - atomic_set(&firesat->reschedule_remotecontrol, 0); - - spin_lock_irqsave(&firesat_list_lock, flags); - INIT_LIST_HEAD(&firesat->list); - list_add_tail(&firesat->list, &firesat_list); - spin_unlock_irqrestore(&firesat_list_lock, flags); - - if(subunit == 0) { - firesat->subunit = 0x7; // 0x7 = don't care - if(AVCSubUnitInfo(firesat, &subunitcount)) { - printk("%s: AVC subunit info command failed.\n",__FUNCTION__); - spin_lock_irqsave(&firesat_list_lock, flags); - list_del(&firesat->list); - spin_unlock_irqrestore(&firesat_list_lock, flags); - kfree(firesat); - return -EIO; - } - } - - printk(KERN_INFO "%s: subunit count = %d\n",__FUNCTION__,subunitcount); - - firesat->subunit=subunit; - - if(AVCIdentifySubunit(firesat,NULL,(int*)&firesat->type,&firesat->has_ci)) { - printk("%s: cannot identify subunit %d\n",__FUNCTION__,subunit); - spin_lock_irqsave(&firesat_list_lock, flags); - list_del(&firesat->list); - spin_unlock_irqrestore(&firesat_list_lock, flags); - kfree(firesat); - continue; - } - firesat->has_ci=1; // TEMP workaround - - switch(firesat->type) { - case FireSAT_DVB_S: - firesat->model_name="FireSAT DVB-S"; - firesat->frontend_info=&firesat_S_frontend_info; - break; - case FireSAT_DVB_C: - firesat->model_name="FireSAT DVB-C"; - firesat->frontend_info=&firesat_C_frontend_info; - break; - case FireSAT_DVB_T: - firesat->model_name="FireSAT DVB-T"; - firesat->frontend_info=&firesat_T_frontend_info; - break; - default: - printk("%s: unknown model type 0x%x on subunit %d!\n",__FUNCTION__,firesat->type,subunit); - firesat->model_name="Unknown"; - firesat->frontend_info=NULL; - } - if(!firesat->frontend_info) { - spin_lock_irqsave(&firesat_list_lock, flags); - list_del(&firesat->list); - spin_unlock_irqrestore(&firesat_list_lock, flags); - kfree(firesat); - continue; - } - - if ((result = dvb_register_adapter(&firesat->adapter, - firesat->model_name, THIS_MODULE)) < 0) { - printk("%s: dvb_register_adapter failed: error %d\n", - __FUNCTION__, result); - - /* ### cleanup */ - spin_lock_irqsave(&firesat_list_lock, flags); - list_del(&firesat->list); - spin_unlock_irqrestore(&firesat_list_lock, flags); - kfree(firesat); - - return result; - } - - firesat->demux.dmx.capabilities = 0/*DMX_TS_FILTERING | DMX_SECTION_FILTERING*/; - - firesat->demux.priv = (void *)firesat; - firesat->demux.filternum = 16; - firesat->demux.feednum = 16; - firesat->demux.start_feed = firesat_start_feed; - firesat->demux.stop_feed = firesat_stop_feed; - - firesat->demux.write_to_decoder = NULL; - - if ((result = dvb_dmx_init(&firesat->demux)) < 0) { - printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, - result); - - dvb_unregister_adapter(firesat->adapter); - - return result; - } - - firesat->dmxdev.filternum = 16; - firesat->dmxdev.demux = &firesat->demux.dmx; - firesat->dmxdev.capabilities = 0; - - if ((result = dvb_dmxdev_init(&firesat->dmxdev, firesat->adapter)) < 0) { - printk("%s: dvb_dmxdev_init failed: error %d\n", - __FUNCTION__, result); - - dvb_dmx_release(&firesat->demux); - dvb_unregister_adapter(firesat->adapter); - - return result; - } - - firesat->frontend.source = DMX_FRONTEND_0; - - if ((result = firesat->demux.dmx.add_frontend(&firesat->demux.dmx, - &firesat->frontend)) < 0) { - printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, - result); - - dvb_dmxdev_release(&firesat->dmxdev); - dvb_dmx_release(&firesat->demux); - dvb_unregister_adapter(firesat->adapter); - - return result; - } - - if ((result = firesat->demux.dmx.connect_frontend(&firesat->demux.dmx, - &firesat->frontend)) < 0) { - printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, - result); - - firesat->demux.dmx.remove_frontend(&firesat->demux.dmx, &firesat->frontend); - dvb_dmxdev_release(&firesat->dmxdev); - dvb_dmx_release(&firesat->demux); - dvb_unregister_adapter(firesat->adapter); - - return result; - } - - dvb_net_init(firesat->adapter, &firesat->dvbnet, &firesat->demux.dmx); - - if((result= dvb_register_frontend(firesat_frontend_ioctl,firesat->adapter,firesat,firesat->frontend_info,THIS_MODULE)) < 0) { - printk("%s: dvb_register_frontend_new failed: error %d\n", __FUNCTION__, result); - /* ### cleanup */ - - return result; - } - - if(firesat->has_ci) - firesat_ca_init(firesat); - - firesats[subunit] = firesat; - } // loop fuer alle tuner am board - - if(firesats[0]) - AVCRegisterRemoteControl(firesats[0]); - - return 0; -} - -static int firesat_remove(struct device *dev) { - struct unit_directory *ud=container_of(dev, struct unit_directory, device); - struct firesat **firesats=ud->device.driver_data; - - if(firesats) { - int k; - for(k=0;k<2;k++) - if(firesats[k]) { - unsigned long flags; - if(firesats[k]->has_ci) - firesat_ca_release(firesats[k]); - dvb_unregister_frontend(firesat_frontend_ioctl,firesats[k]->adapter); - - dvb_net_release(&firesats[k]->dvbnet); - firesats[k]->demux.dmx.close(&firesats[k]->demux.dmx); - firesats[k]->demux.dmx.remove_frontend(&firesats[k]->demux.dmx, &firesats[k]->frontend); - dvb_dmxdev_release(&firesats[k]->dmxdev); - dvb_dmx_release(&firesats[k]->demux); - dvb_unregister_adapter(firesats[k]->adapter); - - spin_lock_irqsave(&firesat_list_lock, flags); - list_del(&firesats[k]->list); - spin_unlock_irqrestore(&firesat_list_lock, flags); - - kfree(firesats[k]->respfrm); - kfree(firesats[k]); - } - kfree(firesats); - } else - printk("%s: can't get firesat handle\n",__FUNCTION__); - - printk(KERN_INFO "FireSAT: Removing device with vendor id 0x%x, model id 0x%x.\n",ud->vendor_id,ud->model_id); - return 0; -} - -static int firesat_update(struct unit_directory *ud) { -// printk(KERN_INFO "FireSAT: Found device with vendor id 0x%x, model id 0x%x\n", ud->vendor_id,ud->model_id); - struct firesat **firesats=ud->device.driver_data; - int k; - // loop over subunits - - for(k=0;k<2;k++) - if(firesats[k]) { - firesats[k]->nodeentry=ud->ne; - - if(firesats[k]->isochannel >= 0) - try_CMPEstablishPPconnection(firesats[k], firesats[k]->subunit, firesats[k]->isochannel); - } - - return 0; -} - -static struct hpsb_protocol_driver firesat_driver = { - .name = "FireSAT DVB", - .id_table = firesat_id_table, - .update = firesat_update, - .driver = { - .name = "firesat", - .bus = &ieee1394_bus_type, - .probe = firesat_probe, - .remove = firesat_remove, - }, -}; - -static int __init firesat_init(void) -{ - int ret; - printk("FireSAT loaded\n"); - hpsb_register_highlevel(&firesat_highlevel); - ret = hpsb_register_protocol(&firesat_driver); - if(ret) { - printk(KERN_ERR "FireSAT: failed to register protocol\n"); - hpsb_unregister_highlevel(&firesat_highlevel); - return ret; - } - - if((ret=firesat_register_rc())) - printk("%s: firesat_register_rc return error code %d (ignored)\n",__FUNCTION__,ret); - - return 0; -} - -static void __exit firesat_exit(void){ - firesat_unregister_rc(); - - hpsb_unregister_protocol(&firesat_driver); - hpsb_unregister_highlevel(&firesat_highlevel); - printk("FireSAT quit\n"); -} - -module_init(firesat_init); -module_exit(firesat_exit); - -MODULE_AUTHOR("Andreas Monitzer <andy@monitzer.com>"); -MODULE_DESCRIPTION("FireSAT DVB Driver"); -MODULE_LICENSE("GPL"); -MODULE_SUPPORTED_DEVICE("FireSAT DVB"); diff --git a/v4l_experimental/firesat/firesat.h b/v4l_experimental/firesat/firesat.h deleted file mode 100644 index c3a614b2a..000000000 --- a/v4l_experimental/firesat/firesat.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef __FIRESAT_H -#define __FIRESAT_H - -#include "dvb_frontend.h" -#include "dmxdev.h" -#include "dvb_demux.h" -#include "dvb_net.h" - -#include <linux/dvb/frontend.h> -#include <linux/dvb/dmx.h> - -enum model_type { - FireSAT_DVB_S = 1, - FireSAT_DVB_C = 2, - FireSAT_DVB_T = 3 -}; - -struct firesat { - struct dvb_demux dvb_demux; - char *model_name; - - /* DVB bits */ - struct dvb_adapter *adapter; - struct dmxdev dmxdev; - struct dvb_demux demux; - struct dmx_frontend frontend; - struct dvb_net dvbnet; - struct dvb_frontend_info *frontend_info; - - struct dvb_device *cadev; - int has_ci; - - struct semaphore avc_sem; - atomic_t avc_reply_received; - - atomic_t reschedule_remotecontrol; - - struct firesat_channel { - struct firesat *firesat; - struct dvb_demux_feed *dvbdmxfeed; - - int active; - int id; - int pid; - int type; /* 1 - TS, 2 - Filter */ - } channel[16]; - struct semaphore demux_sem; - - /* needed by avc_api */ - void *respfrm; - int resp_length; - -// nodeid_t nodeid; - struct hpsb_host *host; - u64 guid; /* GUID of this node */ - u32 guid_vendor_id; /* Top 24bits of guid */ - struct node_entry *nodeentry; - - enum model_type type; - char subunit; - fe_sec_voltage_t voltage; - fe_sec_tone_mode_t tone; - - int isochannel; - - struct list_head list; -}; - -extern struct list_head firesat_list; -extern spinlock_t firesat_list_lock; - -#endif |