提交 c81c8b68 编写于 作者: G Greg Kroah-Hartman 提交者: Stefan Richter

DVB: add firesat driver

Original code written by Christian Dolzer <c.dolzer@digital-everywhere.com>

Cleaned up by Greg.

Major cleanup and reorg by Manu Abraham <manu@linuxtv.org>

Additions also by Ben Backx <ben@bbackx.com>

Cc: Christian Dolzer <c.dolzer@digital-everywhere.com>
Cc: Andreas Monitzer <andy@monitzer.com>
Cc: Manu Abraham <manu@linuxtv.org>
Cc: Fabio De Lorenzo <delorenzo.fabio@gmail.com>
Cc: Robert Berger <robert.berger@reliableembeddedsystems.com>
Signed-off-by: NBen Backx <ben@bbackx.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>

Added missing dependency to dvb/firesat/Kconfig,
Reported-by: NRandy Dunlap <randy.dunlap@oracle.com>

Tweaked dvb/Makefile.
Signed-off-by: NStefan Richter <stefanr@s5r6.in-berlin.de>
上级 f7e603ad
...@@ -51,6 +51,8 @@ comment "Supported SDMC DM1105 Adapters" ...@@ -51,6 +51,8 @@ comment "Supported SDMC DM1105 Adapters"
depends on DVB_CORE && PCI && I2C depends on DVB_CORE && PCI && I2C
source "drivers/media/dvb/dm1105/Kconfig" source "drivers/media/dvb/dm1105/Kconfig"
source "drivers/media/dvb/firesat/Kconfig"
comment "Supported DVB Frontends" comment "Supported DVB Frontends"
depends on DVB_CORE depends on DVB_CORE
source "drivers/media/dvb/frontends/Kconfig" source "drivers/media/dvb/frontends/Kconfig"
......
...@@ -3,3 +3,5 @@ ...@@ -3,3 +3,5 @@
# #
obj-y := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ dvb-usb/ pluto2/ siano/ dm1105/ obj-y := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ dvb-usb/ pluto2/ siano/ dm1105/
obj-$(CONFIG_DVB_FIRESAT) += firesat/
config DVB_FIRESAT
tristate "FireSAT devices"
depends on DVB_CORE && IEEE1394 && INPUT
help
Support for external IEEE1394 adapters designed by Digital Everywhere and
produced by El Gato, shipped under the brand name 'FireDTV/FloppyDTV'.
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.
firesat-objs := firesat_1394.o \
firesat_dvb.o \
firesat_fe.o \
avc_api.o \
cmp.o \
firesat-rc.o \
firesat-ci.o
obj-$(CONFIG_DVB_FIRESAT) += firesat.o
EXTRA_CFLAGS := -Idrivers/ieee1394
EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
此差异已折叠。
/***************************************************************************
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 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
**************************************************************/
// digital everywhere vendor ID
#define SFE_VENDOR_DE_COMPANYID_0 0x00
#define SFE_VENDOR_DE_COMPANYID_1 0x12
#define SFE_VENDOR_DE_COMPANYID_2 0x87
#define SFE_VENDOR_MAX_NR_COMPONENTS 0x4
#define SFE_VENDOR_MAX_NR_SERVICES 0x3
#define SFE_VENDOR_MAX_NR_DSD_ELEMENTS 0x10
// vendor commands
#define SFE_VENDOR_OPCODE_REGISTER_REMOTE_CONTROL 0x0A
#define SFE_VENDOR_OPCODE_LNB_CONTROL 0x52
#define SFE_VENDOR_OPCODE_TUNE_QPSK 0x58 // QPSK command for DVB-S
// TODO: following vendor specific commands needs to be implemented
#define SFE_VENDOR_OPCODE_GET_FIRMWARE_VERSION 0x00
#define SFE_VENDOR_OPCODE_HOST2CA 0x56
#define SFE_VENDOR_OPCODE_CA2HOST 0x57
#define SFE_VENDOR_OPCODE_CISTATUS 0x59
#define SFE_VENDOR_OPCODE_TUNE_QPSK2 0x60 // QPSK command for DVB-S2 devices
//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 AVCTuner_GetTS(struct firesat *firesat);
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);
#endif
#include "cmp.h"
#include <ieee1394.h>
#include <nodemgr.h>
#include <highlevel.h>
#include <ohci1394.h>
#include <hosts.h>
#include <ieee1394_core.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
/* hpsb_lock is being removed from the kernel-source,
* therefor we define our own 'firesat_hpsb_lock'*/
int send_packet_and_wait(struct hpsb_packet *packet);
int firesat_hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
u64 addr, int extcode, quadlet_t * data, quadlet_t arg) {
struct hpsb_packet *packet;
int retval = 0;
BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg);
if (!packet)
return -ENOMEM;
packet->generation = generation;
retval = send_packet_and_wait(packet);
if (retval < 0)
goto hpsb_lock_fail;
retval = hpsb_packet_success(packet);
if (retval == 0) {
*data = packet->data[0];
}
hpsb_lock_fail:
hpsb_free_tlabel(packet);
hpsb_free_packet(packet);
return retval;
}
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 = firesat_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",__func__,firesat->nodeentry->nodeid);
if (result < 0) {
printk("%s: cannot read oPCR\n", __func__);
return result;
} else {
printk(KERN_INFO "%s: oPCR = %08x\n",__func__,test_oPCR);
do {
OPCR *hilf= (OPCR*) &test_oPCR;
if (!hilf->OnLine) {
printk("%s: Output offline; oPCR: %08x\n", __func__, 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",__func__,hilf->ChNr,iso_channel);
return -EBUSY;
} else
printk(KERN_INFO "%s: Overlaying existing connection; connection counter was: %u\n",__func__, 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",__func__);
printk(KERN_INFO "%s: oPCR_old: %08x, oPCR_new: %08x\n",__func__, 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",__func__);
return result;
}
if ((old_oPCR != test_oPCR) && (!((OPCR*) &old_oPCR)->PTPConnCount))
{
printk("%s: change of oPCR failed -> freeing resources\n",__func__);
// 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",__func__);
if (result < 0) {
printk("%s: cannot read oPCR\n", __func__);
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", __func__, 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", __func__);
result=cmp_lock(firesat, &test_oPCR, oPCR_address, old_oPCR, 2);
if (result < 0) {
printk("%s: cannot compare_swap oPCR\n",__func__);
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;
}
static void complete_packet(void *data) {
complete((struct completion *) data);
}
int send_packet_and_wait(struct hpsb_packet *packet) {
struct completion done;
int retval;
init_completion(&done);
hpsb_set_packet_complete_task(packet, complete_packet, &done);
retval = hpsb_send_packet(packet);
if (retval == 0)
wait_for_completion(&done);
return retval;
}
#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
#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",__func__,cmd);
switch(cmd) {
case CA_RESET:
// TODO: Needs to be implemented with new AVC Vendor commands
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;
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);
return dvb_generic_ioctl(inode, file, cmd, arg);
}
static int firesat_ca_io_open(struct inode *inode, struct file *file) {
printk(KERN_INFO "%s!\n",__func__);
return dvb_generic_open(inode, file);
}
static int firesat_ca_io_release(struct inode *inode, struct file *file) {
printk(KERN_INFO "%s!\n",__func__);
return dvb_generic_release(inode, file);
}
static unsigned int firesat_ca_io_poll(struct file *file, poll_table *wait) {
// printk(KERN_INFO "%s!\n",__func__);
return POLLIN;
}
static struct file_operations firesat_ca_fops = {
.owner = THIS_MODULE,
.read = NULL, // There is no low level read anymore
.write = NULL, // There is no low level write anymore
.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;
// 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);
}
#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
#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);
return input_register_device(&firesat_idev);
}
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(KERN_DEBUG "%s: invalid key code 0x%04x\n", __func__,
code);
return -EINVAL;
}
input_report_key(&firesat_idev, keycode, 1);
input_report_key(&firesat_idev, keycode, 0);
return 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
#ifndef __FIRESAT_H
#define __FIRESAT_H
#include "dvb_frontend.h"
#include "dmxdev.h"
#include "dvb_demux.h"
#include "dvb_net.h"
#include <linux/semaphore.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_frontend *fe;
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;
/* firesat_dvb.c */
extern int firesat_start_feed(struct dvb_demux_feed *dvbdmxfeed);
extern int firesat_stop_feed(struct dvb_demux_feed *dvbdmxfeed);
extern int firesat_dvbdev_init(struct firesat *firesat,
struct device *dev,
struct dvb_frontend *fe);
/* firesat_fe.c */
extern int firesat_frontend_attach(struct firesat *firesat, struct dvb_frontend *fe);
#endif
/*
* FireSAT DVB driver
*
* Copyright (c) 2004 Andreas Monitzer <andy@monitzer.com>
* Copyright (c) 2007-2008 Ben Backx <ben@bbackx.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 <linux/interrupt.h>
#include <linux/semaphore.h>
#include <ieee1394_hotplug.h>
#include <nodemgr.h>
#include <highlevel.h>
#include <ohci1394.h>
#include <hosts.h>
#include <dvbdev.h>
#include "firesat.h"
#include "avc_api.h"
#include "cmp.h"
#include "firesat-rc.h"
#include "firesat-ci.h"
#define FIRESAT_Vendor_ID 0x001287
static struct ieee1394_device_id firesat_id_table[] = {
{
/* FloppyDTV S/CI and FloppyDTV S2 */
.match_flags = IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID,
.model_id = 0x000024,
.specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff,
},{
/* FloppyDTV T/CI */
.match_flags = IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID,
.model_id = 0x000025,
.specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff,
},{
/* FloppyDTV C/CI */
.match_flags = IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID,
.model_id = 0x000026,
.specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff,
},{
/* FireDTV S/CI and FloppyDTV S2 */
.match_flags = IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID,
.model_id = 0x000034,
.specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff,
},{
/* FireDTV T/CI */
.match_flags = IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID,
.model_id = 0x000035,
.specifier_id = AVC_UNIT_SPEC_ID_ENTRY & 0xffffff,
},{
/* FireDTV C/CI */
.match_flags = IEEE1394_MATCH_MODEL_ID | IEEE1394_MATCH_SPECIFIER_ID,
.model_id = 0x000036,
.specifier_id = AVC_UNIT_SPEC_ID_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,
// FIXME .iso_receive = iso_receive,
.fcp_request = fcp_request,
};
static void firesat_add_host (struct hpsb_host *host)
{
struct ti_ohci *ohci = (struct ti_ohci *)host->hostdata;
/* We only work with the OHCI-1394 driver */
if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME))
return;
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)
{
}
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;
};
};
#if 0
static void iso_receive(struct hpsb_host *host,
int channel,
quadlet_t *data,
size_t length)
{
struct firesat *firesat = NULL;
struct firesat *firesat_entry;
unsigned long flags;
// printk(KERN_INFO "FireSAT iso_receive: channel %d, length = %d\n", channel, length);
if (length <= 12)
return; // ignore empty packets
else {
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",__func__, length, data[0],data[1],data[2],data[3],data[4]);
while (count--) {
if (buf[sizeof(quadlet_t) /*timestamp*/] == 0x47)
dvb_dmx_swfilter_packets(&firesat->demux, &buf[sizeof(quadlet_t)], 1);
else
printk("%s: invalid packet, skipping\n", __func__);
buf += 188 + sizeof (quadlet_t) /* timestamp */;
}
}
}
}
#endif
static void fcp_request(struct hpsb_host *host,
int nodeid,
int direction,
int cts,
u8 *data,
size_t length)
{
struct firesat *firesat = NULL;
struct firesat *firesat_entry;
unsigned long flags;
if (length > 0 && ((data[0] & 0xf0) >> 4) == 0) {
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", __func__);
} // else ignore
}
static int firesat_probe(struct device *dev)
{
struct unit_directory *ud = container_of(dev, struct unit_directory, device);
struct firesat *firesat;
struct dvb_frontend *fe;
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", __func__);
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", __func__);
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)) ||
!(fe = kmalloc(sizeof (struct dvb_frontend), GFP_KERNEL))) {
printk("%s: couldn't allocate memory.\n", __func__);
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", __func__);
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",__func__);
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", __func__, subunitcount);
firesat->subunit = subunit;
if (AVCIdentifySubunit(firesat, NULL, (int*)&firesat->type, &firesat->has_ci)) {
printk("%s: cannot identify subunit %d\n", __func__, subunit);
spin_lock_irqsave(&firesat_list_lock, flags);
list_del(&firesat->list);
spin_unlock_irqrestore(&firesat_list_lock, flags);
kfree(firesat);
continue;
}
// ----
firesat_dvbdev_init(firesat, dev, fe);
// ----
firesats[subunit] = firesat;
} // loop for all tuners
//beta ;-) Disable remote control stuff to avoid crashing
//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 dvb_frontend* fe;
struct firesat **firesats = ud->device.driver_data;
int k;
unsigned long flags;
if (firesats) {
for (k = 0; k < 2; k++)
if (firesats[k]) {
if (firesats[k]->has_ci)
firesat_ca_release(firesats[k]);
#if 0
if (!(fe = kmalloc(sizeof (struct dvb_frontend), GFP_KERNEL))) {
fe->ops = firesat_ops;
fe->dvb = firesats[k]->adapter;
dvb_unregister_frontend(fe);
kfree(fe);
}
#endif
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]->adapter);
kfree(firesats[k]->respfrm);
kfree(firesats[k]);
}
kfree(firesats);
} else
printk("%s: can't get firesat handle\n", __func__);
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)
{
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",
.id_table = firesat_id_table,
.update = firesat_update,
.driver = {
//.name and .bus are filled in for us in more recent linux versions
//.name = "FireSAT",
//.bus = &ieee1394_bus_type,
.probe = firesat_probe,
.remove = firesat_remove,
},
};
static int __init firesat_init(void)
{
int ret;
printk(KERN_INFO "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;
}
//Crash in this function, just disable RC for the time being...
//Don't forget to uncomment in firesat_exit and firesat_probe when you enable this.
/*if((ret=firesat_register_rc()))
printk("%s: firesat_register_rc return error code %d (ignored)\n", __func__, ret);*/
return 0;
}
static void __exit firesat_exit(void)
{
hpsb_unregister_protocol(&firesat_driver);
hpsb_unregister_highlevel(&firesat_highlevel);
printk(KERN_INFO "FireSAT quit\n");
}
module_init(firesat_init);
module_exit(firesat_exit);
MODULE_AUTHOR("Andreas Monitzer <andy@monitzer.com>");
MODULE_AUTHOR("Ben Backx <ben@bbackx.com>");
MODULE_DESCRIPTION("FireSAT DVB Driver");
MODULE_LICENSE("GPL");
MODULE_SUPPORTED_DEVICE("FireSAT DVB");
#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 <linux/interrupt.h>
#include <linux/semaphore.h>
#include <ieee1394_hotplug.h>
#include <nodemgr.h>
#include <highlevel.h>
#include <ohci1394.h>
#include <hosts.h>
#include <dvbdev.h>
#include "firesat.h"
#include "avc_api.h"
#include "cmp.h"
#include "firesat-rc.h"
#include "firesat-ci.h"
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
static struct firesat_channel *firesat_channel_allocate(struct firesat *firesat)
{
int k;
printk(KERN_INFO "%s\n", __func__);
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",__func__,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;
}
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",__func__,dvbdmxfeed->pid);
switch (dvbdmxfeed->type) {
case DMX_TYPE_TS:
case DMX_TYPE_SEC:
break;
default:
printk("%s: invalid type %u\n",__func__,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:
//Dirty fix to keep firesat->channel pid-list up to date
for(k=0;k<16;k++){
if(firesat->channel[k].active == 0)
firesat->channel[k].pid =
dvbdmxfeed->pid;
break;
}
channel = firesat_channel_allocate(firesat);
break;
default:
printk("%s: invalid pes type %u\n",__func__, dvbdmxfeed->pes_type);
return -EINVAL;
}
} else {
channel = firesat_channel_allocate(firesat);
}
if (!channel) {
printk("%s: busy!\n", __func__);
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(dvbdmxfeed->pid == 8192) {
if((k=AVCTuner_GetTS(firesat))) {
firesat_channel_release(firesat, channel);
printk("%s: AVCTuner_GetTS failed with error %d\n",
__func__,k);
return k;
}
}
else {
if((k=AVCTuner_SetPIDs(firesat, pidc, pids))) {
firesat_channel_release(firesat, channel);
printk("%s: AVCTuner_SetPIDs failed with error %d\n",
__func__,k);
return k;
}
}
return 0;
}
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", __func__, 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)
if (&firesat->channel[k] !=
(struct firesat_channel *)dvbdmxfeed->priv)
pids[l++] = firesat->channel[k].pid;
else
firesat->channel[k].active = 0;
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;
}
int firesat_dvbdev_init(struct firesat *firesat,
struct device *dev,
struct dvb_frontend *fe)
{
int result;
firesat->has_ci = 1; // TEMP workaround
#if 0
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",
__func__, firesat->type,subunit);
firesat->model_name = "Unknown";
firesat->frontend_info = NULL;
}
#endif
/* // ------- CRAP -----------
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;
}
*/
//initialising firesat->adapter before calling dvb_register_adapter
if (!(firesat->adapter = kmalloc(sizeof (struct dvb_adapter), GFP_KERNEL))) {
printk("%s: couldn't allocate memory.\n", __func__);
kfree(firesat->adapter);
kfree(firesat);
return -ENOMEM;
}
if ((result = dvb_register_adapter(firesat->adapter,
firesat->model_name,
THIS_MODULE,
dev, adapter_nr)) < 0) {
printk("%s: dvb_register_adapter failed: error %d\n", __func__, result);
#if 0
/* ### cleanup */
spin_lock_irqsave(&firesat_list_lock, flags);
list_del(&firesat->list);
spin_unlock_irqrestore(&firesat_list_lock, flags);
#endif
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", __func__,
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",
__func__, 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", __func__,
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", __func__,
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);
// fe->ops = firesat_ops;
// fe->dvb = firesat->adapter;
firesat_frontend_attach(firesat, fe);
fe->sec_priv = firesat; //IMPORTANT, functions depend on this!!!
if ((result= dvb_register_frontend(firesat->adapter, fe)) < 0) {
printk("%s: dvb_register_frontend_new failed: error %d\n", __func__, result);
/* ### cleanup */
return result;
}
if (firesat->has_ci)
firesat_ca_init(firesat);
return 0;
}
#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 <linux/interrupt.h>
#include <linux/semaphore.h>
#include <ieee1394_hotplug.h>
#include <nodemgr.h>
#include <highlevel.h>
#include <ohci1394.h>
#include <hosts.h>
#include <dvbdev.h>
#include "firesat.h"
#include "avc_api.h"
#include "cmp.h"
#include "firesat-rc.h"
#include "firesat-ci.h"
static int firesat_dvb_init(struct dvb_frontend *fe)
{
struct firesat *firesat = fe->sec_priv;
printk("fdi: 1\n");
firesat->isochannel = firesat->adapter->num; //<< 1 | (firesat->subunit & 0x1); // ### ask IRM
printk("fdi: 2\n");
try_CMPEstablishPPconnection(firesat, firesat->subunit, firesat->isochannel);
printk("fdi: 3\n");
//FIXME hpsb_listen_channel(&firesat_highlevel, firesat->host, firesat->isochannel);
printk("fdi: 4\n");
return 0;
}
static int firesat_sleep(struct dvb_frontend *fe)
{
struct firesat *firesat = fe->sec_priv;
//FIXME hpsb_unlisten_channel(&firesat_highlevel, firesat->host, firesat->isochannel);
try_CMPBreakPPconnection(firesat, firesat->subunit, firesat->isochannel);
firesat->isochannel = -1;
return 0;
}
static int firesat_diseqc_send_master_cmd(struct dvb_frontend *fe,
struct dvb_diseqc_master_cmd *cmd)
{
struct firesat *firesat = fe->sec_priv;
return AVCLNBControl(firesat, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE,
LNBCONTROL_DONTCARE, 1, cmd);
}
static int firesat_diseqc_send_burst(struct dvb_frontend *fe,
fe_sec_mini_cmd_t minicmd)
{
return 0;
}
static int firesat_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
{
struct firesat *firesat = fe->sec_priv;
firesat->tone = tone;
return 0;
}
static int firesat_set_voltage(struct dvb_frontend *fe,
fe_sec_voltage_t voltage)
{
struct firesat *firesat = fe->sec_priv;
firesat->voltage = voltage;
return 0;
}
static int firesat_read_status (struct dvb_frontend *fe, fe_status_t *status)
{
struct firesat *firesat = fe->sec_priv;
ANTENNA_INPUT_INFO info;
if (AVCTunerStatus(firesat, &info))
return -EINVAL;
if (info.NoRF)
*status = 0;
else
*status = *status = FE_HAS_SIGNAL |
FE_HAS_VITERBI |
FE_HAS_SYNC |
FE_HAS_CARRIER |
FE_HAS_LOCK;
return 0;
}
static int firesat_read_ber (struct dvb_frontend *fe, u32 *ber)
{
struct firesat *firesat = fe->sec_priv;
ANTENNA_INPUT_INFO info;
if (AVCTunerStatus(firesat, &info))
return -EINVAL;
*ber = ((info.BER[0] << 24) & 0xff) |
((info.BER[1] << 16) & 0xff) |
((info.BER[2] << 8) & 0xff) |
(info.BER[3] & 0xff);
return 0;
}
static int firesat_read_signal_strength (struct dvb_frontend *fe, u16 *strength)
{
struct firesat *firesat = fe->sec_priv;
ANTENNA_INPUT_INFO info;
u16 *signal = strength;
if (AVCTunerStatus(firesat, &info))
return -EINVAL;
*signal = info.SignalStrength;
return 0;
}
static int firesat_read_snr(struct dvb_frontend *fe, u16 *snr)
{
return -EOPNOTSUPP;
}
static int firesat_read_uncorrected_blocks(struct dvb_frontend *fe, u32 *ucblocks)
{
return -EOPNOTSUPP;
}
static int firesat_set_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params)
{
struct firesat *firesat = fe->sec_priv;
if (AVCTuner_DSD(firesat, params, NULL) != ACCEPTED)
return -EINVAL;
else
return 0; //not sure of this...
}
static int firesat_get_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params)
{
return -EOPNOTSUPP;
}
static struct dvb_frontend_info firesat_S_frontend_info;
static struct dvb_frontend_info firesat_C_frontend_info;
static struct dvb_frontend_info firesat_T_frontend_info;
static struct dvb_frontend_ops firesat_ops = {
.init = firesat_dvb_init,
.sleep = firesat_sleep,
.set_frontend = firesat_set_frontend,
.get_frontend = firesat_get_frontend,
.read_status = firesat_read_status,
.read_ber = firesat_read_ber,
.read_signal_strength = firesat_read_signal_strength,
.read_snr = firesat_read_snr,
.read_ucblocks = firesat_read_uncorrected_blocks,
.diseqc_send_master_cmd = firesat_diseqc_send_master_cmd,
.diseqc_send_burst = firesat_diseqc_send_burst,
.set_tone = firesat_set_tone,
.set_voltage = firesat_set_voltage,
};
int firesat_frontend_attach(struct firesat *firesat, struct dvb_frontend *fe)
{
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",
// __func__, firesat->type,subunit);
printk("%s: unknown model type 0x%x !\n",
__func__, firesat->type);
firesat->model_name = "Unknown";
firesat->frontend_info = NULL;
}
fe->ops = firesat_ops;
fe->dvb = firesat->adapter;
return 0;
}
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,
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册