Commit 2b7f4a04 authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] DVB: Update DVB budget drivers

 - [DVB] budget-av: patch by Kenneth Aafløy to add support for Typhoon
   DVB-S budget card
 - [DVB] budget.c: support for Fujitsu-Siemens Activy Card
 - [DVB] budget-ci: add preliminary CI support
parent 2343a8c0
...@@ -39,6 +39,7 @@ struct budget_av { ...@@ -39,6 +39,7 @@ struct budget_av {
struct budget budget; struct budget budget;
struct video_device vd; struct video_device vd;
int cur_input; int cur_input;
int has_saa7113;
}; };
/**************************************************************************** /****************************************************************************
...@@ -149,6 +150,9 @@ static int saa7113_setinput (struct budget_av *budget_av, int input) ...@@ -149,6 +150,9 @@ static int saa7113_setinput (struct budget_av *budget_av, int input)
{ {
struct budget *budget = &budget_av->budget; struct budget *budget = &budget_av->budget;
if ( 1 != budget_av->has_saa7113 )
return -ENODEV;
if (input == 1) { if (input == 1) {
i2c_writereg(budget->i2c_bus, 0x4a, 0x02, 0xc7); i2c_writereg(budget->i2c_bus, 0x4a, 0x02, 0xc7);
i2c_writereg(budget->i2c_bus, 0x4a, 0x09, 0x80); i2c_writereg(budget->i2c_bus, 0x4a, 0x09, 0x80);
...@@ -170,11 +174,13 @@ static int budget_av_detach (struct saa7146_dev *dev) ...@@ -170,11 +174,13 @@ static int budget_av_detach (struct saa7146_dev *dev)
DEB_EE(("dev: %p\n",dev)); DEB_EE(("dev: %p\n",dev));
if ( 1 == budget_av->has_saa7113 ) {
saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO); saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
dvb_delay(200); dvb_delay(200);
saa7146_unregister_device (&budget_av->vd, dev); saa7146_unregister_device (&budget_av->vd, dev);
}
err = ttpci_budget_deinit (&budget_av->budget); err = ttpci_budget_deinit (&budget_av->budget);
...@@ -221,11 +227,8 @@ static int budget_av_attach (struct saa7146_dev* dev, ...@@ -221,11 +227,8 @@ static int budget_av_attach (struct saa7146_dev* dev,
saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTHI); saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTHI);
dvb_delay(500); dvb_delay(500);
if ((err = saa7113_init (budget_av))) { if ( 0 == saa7113_init(budget_av) ) {
/* fixme: proper cleanup here */ budget_av->has_saa7113 = 1;
ERR(("cannot init saa7113.\n"));
return err;
}
if ( 0 != saa7146_vv_init(dev,&vv_data)) { if ( 0 != saa7146_vv_init(dev,&vv_data)) {
/* fixme: proper cleanup here */ /* fixme: proper cleanup here */
...@@ -246,14 +249,12 @@ static int budget_av_attach (struct saa7146_dev* dev, ...@@ -246,14 +249,12 @@ static int budget_av_attach (struct saa7146_dev* dev,
SAA7146_HPS_SYNC_PORT_A); SAA7146_HPS_SYNC_PORT_A);
saa7113_setinput (budget_av, 0); saa7113_setinput (budget_av, 0);
} else {
budget_av->has_saa7113 = 0;
/* what is this? since we don't support open()/close()
notifications, we simply put this into the release handler... */
/*
saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO); saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
set_current_state(TASK_INTERRUPTIBLE); }
schedule_timeout (20);
*/
/* fixme: find some sane values here... */ /* fixme: find some sane values here... */
saa7146_write(dev, PCI_BT_V1, 0x1c00101f); saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
...@@ -333,13 +334,13 @@ static int av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg) ...@@ -333,13 +334,13 @@ static int av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
static struct saa7146_standard standard[] = { static struct saa7146_standard standard[] = {
{ {
.name = "PAL", .id = V4L2_STD_PAL, .name = "PAL", .id = V4L2_STD_PAL,
.v_offset = 0x17, .v_field = 288, .v_calc = 576, .v_offset = 0x17, .v_field = 288,
.h_offset = 0x14, .h_pixels = 680, .h_calc = 680+1, .h_offset = 0x14, .h_pixels = 680,
.v_max_out = 576, .h_max_out = 768, .v_max_out = 576, .h_max_out = 768
}, { }, {
.name = "NTSC", .id = V4L2_STD_NTSC, .name = "NTSC", .id = V4L2_STD_NTSC,
.v_offset = 0x16, .v_field = 240, .v_calc = 480, .v_offset = 0x16, .v_field = 240,
.h_offset = 0x06, .h_pixels = 708, .h_calc = 708+1, .h_offset = 0x06, .h_pixels = 708,
.v_max_out = 480, .h_max_out = 640, .v_max_out = 480, .h_max_out = 640,
} }
}; };
......
This diff is collapsed.
/*
* budget-core.c: driver for the SAA7146 based Budget DVB cards
*
* Compiled from various sources by Michael Hunold <michael@mihu.de>
*
* Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
*
* Copyright (C) 1999-2002 Ralph Metzler
* & Marcus Metzler for convergence integrated media GmbH
*
* 26feb2004 Support for FS Activy Card (Grundig tuner) by
* Michael Dreher <michael@5dot1.de>,
* Oliver Endriss <o.endriss@gmx.de>,
* Andreas 'randy' Weinberger
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
*
*
* the project's page is at http://www.linuxtv.org/dvb/
*/
#include "budget.h" #include "budget.h"
#include "ttpci-eeprom.h" #include "ttpci-eeprom.h"
...@@ -38,10 +74,33 @@ static int start_ts_capture (struct budget *budget) ...@@ -38,10 +74,33 @@ static int start_ts_capture (struct budget *budget)
budget->tsf=0xff; budget->tsf=0xff;
budget->ttbp=0; budget->ttbp=0;
/*
* Signal path on the Activy:
*
* tuner -> SAA7146 port A -> SAA7146 BRS -> SAA7146 DMA3 -> memory
*
* Since the tuner feeds 204 bytes packets into the SAA7146,
* DMA3 is configured to strip the trailing 16 FEC bytes:
* Pitch: 188, NumBytes3: 188, NumLines3: 1024
*/
if (budget->card->type == BUDGET_FS_ACTIVY) {
saa7146_write(dev, DD1_INIT, 0x04000000);
saa7146_write(dev, MC2, (MASK_09 | MASK_25));
saa7146_write(dev, BRS_CTRL, 0x00000000);
} else {
if (budget->video_port == BUDGET_VIDEO_PORTA) {
saa7146_write(dev, DD1_INIT, 0x06000200);
saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
saa7146_write(dev, BRS_CTRL, 0x00000000);
} else {
saa7146_write(dev, DD1_INIT, 0x02000600); saa7146_write(dev, DD1_INIT, 0x02000600);
saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26)); saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
saa7146_write(dev, BRS_CTRL, 0x60000000); saa7146_write(dev, BRS_CTRL, 0x60000000);
}
}
saa7146_write(dev, MC2, (MASK_08 | MASK_24)); saa7146_write(dev, MC2, (MASK_08 | MASK_24));
mdelay(10); mdelay(10);
...@@ -49,9 +108,15 @@ static int start_ts_capture (struct budget *budget) ...@@ -49,9 +108,15 @@ static int start_ts_capture (struct budget *budget)
saa7146_write(dev, BASE_EVEN3, 0); saa7146_write(dev, BASE_EVEN3, 0);
saa7146_write(dev, PROT_ADDR3, TS_WIDTH*TS_HEIGHT); saa7146_write(dev, PROT_ADDR3, TS_WIDTH*TS_HEIGHT);
saa7146_write(dev, BASE_PAGE3, budget->pt.dma |ME1|0x90); saa7146_write(dev, BASE_PAGE3, budget->pt.dma |ME1|0x90);
saa7146_write(dev, PITCH3, TS_WIDTH);
if (budget->card->type == BUDGET_FS_ACTIVY) {
saa7146_write(dev, PITCH3, TS_WIDTH/2);
saa7146_write(dev, NUM_LINE_BYTE3, ((TS_HEIGHT*2)<<16)|(TS_WIDTH/2));
} else {
saa7146_write(dev, PITCH3, TS_WIDTH);
saa7146_write(dev, NUM_LINE_BYTE3, (TS_HEIGHT<<16)|TS_WIDTH); saa7146_write(dev, NUM_LINE_BYTE3, (TS_HEIGHT<<16)|TS_WIDTH);
}
saa7146_write(dev, MC2, (MASK_04 | MASK_20)); saa7146_write(dev, MC2, (MASK_04 | MASK_20));
saa7146_write(dev, MC1, (MASK_04 | MASK_20)); // DMA3 on saa7146_write(dev, MC1, (MASK_04 | MASK_20)); // DMA3 on
...@@ -99,23 +164,31 @@ static int budget_start_feed(struct dvb_demux_feed *feed) ...@@ -99,23 +164,31 @@ static int budget_start_feed(struct dvb_demux_feed *feed)
{ {
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
struct budget *budget = (struct budget*) demux->priv; struct budget *budget = (struct budget*) demux->priv;
int status;
DEB_EE(("budget: %p\n",budget)); DEB_EE(("budget: %p\n",budget));
if (!demux->dmx.frontend) if (!demux->dmx.frontend)
return -EINVAL; return -EINVAL;
return start_ts_capture (budget); spin_lock(&budget->feedlock);
status = start_ts_capture (budget);
spin_unlock(&budget->feedlock);
return status;
} }
static int budget_stop_feed(struct dvb_demux_feed *feed) static int budget_stop_feed(struct dvb_demux_feed *feed)
{ {
struct dvb_demux *demux = feed->demux; struct dvb_demux *demux = feed->demux;
struct budget *budget = (struct budget *) demux->priv; struct budget *budget = (struct budget *) demux->priv;
int status;
DEB_EE(("budget: %p\n",budget)); DEB_EE(("budget: %p\n",budget));
return stop_ts_capture (budget); spin_lock(&budget->feedlock);
status = stop_ts_capture (budget);
spin_unlock(&budget->feedlock);
return status;
} }
...@@ -208,18 +281,27 @@ int ttpci_budget_init (struct budget *budget, ...@@ -208,18 +281,27 @@ int ttpci_budget_init (struct budget *budget,
budget->card = bi; budget->card = bi;
budget->dev = (struct saa7146_dev *) dev; budget->dev = (struct saa7146_dev *) dev;
dvb_register_adapter(&budget->dvb_adapter, budget->card->name); dvb_register_adapter(&budget->dvb_adapter, budget->card->name, THIS_MODULE);
/* set dd1 stream a & b */ /* set dd1 stream a & b */
saa7146_write(dev, DD1_STREAM_B, 0x00000000); saa7146_write(dev, DD1_STREAM_B, 0x00000000);
saa7146_write(dev, MC2, (MASK_09 | MASK_25));
saa7146_write(dev, MC2, (MASK_10 | MASK_26));
saa7146_write(dev, DD1_INIT, 0x02000000); saa7146_write(dev, DD1_INIT, 0x02000000);
saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26)); saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
if (bi->type != BUDGET_FS_ACTIVY)
budget->video_port = BUDGET_VIDEO_PORTB;
else
budget->video_port = BUDGET_VIDEO_PORTA;
spin_lock_init(&budget->feedlock);
/* the Siemens DVB needs this if you want to have the i2c chips /* the Siemens DVB needs this if you want to have the i2c chips
get recognized before the main driver is loaded */ get recognized before the main driver is loaded */
saa7146_write(dev, GPIO_CTRL, 0x500000); if (bi->type != BUDGET_FS_ACTIVY)
saa7146_write(dev, GPIO_CTRL, 0x500000); /* GPIO 3 = 1 */
saa7146_i2c_adapter_prepare(dev, NULL, SAA7146_I2C_BUS_BIT_RATE_120); saa7146_i2c_adapter_prepare(dev, NULL, 0, SAA7146_I2C_BUS_BIT_RATE_120);
budget->i2c_bus = dvb_register_i2c_bus (master_xfer, dev, budget->i2c_bus = dvb_register_i2c_bus (master_xfer, dev,
budget->dvb_adapter, 0); budget->dvb_adapter, 0);
...@@ -242,7 +324,11 @@ int ttpci_budget_init (struct budget *budget, ...@@ -242,7 +324,11 @@ int ttpci_budget_init (struct budget *budget,
tasklet_init (&budget->vpe_tasklet, vpeirq, (unsigned long) budget); tasklet_init (&budget->vpe_tasklet, vpeirq, (unsigned long) budget);
saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI); /* frontend power on */ /* frontend power on */
if (bi->type == BUDGET_FS_ACTIVY)
saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI);
else
saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
if (budget_register(budget) == 0) { if (budget_register(budget) == 0) {
return 0; return 0;
...@@ -292,10 +378,28 @@ void ttpci_budget_irq10_handler (struct saa7146_dev* dev, u32 *isr) ...@@ -292,10 +378,28 @@ void ttpci_budget_irq10_handler (struct saa7146_dev* dev, u32 *isr)
tasklet_schedule (&budget->vpe_tasklet); tasklet_schedule (&budget->vpe_tasklet);
} }
void ttpci_budget_set_video_port(struct saa7146_dev* dev, int video_port)
{
struct budget *budget = (struct budget*)dev->ext_priv;
spin_lock(&budget->feedlock);
budget->video_port = video_port;
if (budget->feeding) {
int oldfeeding = budget->feeding;
budget->feeding = 1;
stop_ts_capture(budget);
start_ts_capture(budget);
budget->feeding = oldfeeding;
}
spin_unlock(&budget->feedlock);
}
EXPORT_SYMBOL_GPL(ttpci_budget_init); EXPORT_SYMBOL_GPL(ttpci_budget_init);
EXPORT_SYMBOL_GPL(ttpci_budget_deinit); EXPORT_SYMBOL_GPL(ttpci_budget_deinit);
EXPORT_SYMBOL_GPL(ttpci_budget_irq10_handler); EXPORT_SYMBOL_GPL(ttpci_budget_irq10_handler);
EXPORT_SYMBOL_GPL(ttpci_budget_set_video_port);
EXPORT_SYMBOL_GPL(budget_debug); EXPORT_SYMBOL_GPL(budget_debug);
MODULE_PARM(budget_debug,"i"); MODULE_PARM(budget_debug,"i");
......
...@@ -8,6 +8,11 @@ ...@@ -8,6 +8,11 @@
* Copyright (C) 1999-2002 Ralph Metzler * Copyright (C) 1999-2002 Ralph Metzler
* & Marcus Metzler for convergence integrated media GmbH * & Marcus Metzler for convergence integrated media GmbH
* *
* 26feb2004 Support for FS Activy Card (Grundig tuner) by
* Michael Dreher <michael@5dot1.de>,
* Oliver Endriss <o.endriss@gmx.de> and
* Andreas 'randy' Weinberger
*
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
...@@ -142,6 +147,49 @@ int budget_diseqc_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg) ...@@ -142,6 +147,49 @@ int budget_diseqc_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
} }
/*
* Routines for the Fujitsu Siemens Activy budget card
* 22 kHz tone and DiSEqC are handled by the frontend.
* Voltage must be set here.
*/
static int SetVoltage_Activy (struct budget *budget, fe_sec_voltage_t voltage)
{
struct saa7146_dev *dev=budget->dev;
DEB_EE(("budget: %p\n",budget));
switch (voltage) {
case SEC_VOLTAGE_13:
saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTLO);
break;
case SEC_VOLTAGE_18:
saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
break;
default:
return -EINVAL;
}
return 0;
}
static int budget_ioctl_activy (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
struct budget *budget = fe->before_after_data;
DEB_EE(("budget: %p\n",budget));
switch (cmd) {
case FE_SET_VOLTAGE:
return SetVoltage_Activy (budget, (fe_sec_voltage_t) arg);
default:
return -EOPNOTSUPP;
}
return 0;
}
static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info) static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
{ {
struct budget *budget = NULL; struct budget *budget = NULL;
...@@ -160,6 +208,10 @@ static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_ ...@@ -160,6 +208,10 @@ static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_
return err; return err;
} }
if (budget->card->type == BUDGET_FS_ACTIVY)
dvb_add_frontend_ioctls (budget->dvb_adapter,
budget_ioctl_activy, NULL, budget);
else
dvb_add_frontend_ioctls (budget->dvb_adapter, dvb_add_frontend_ioctls (budget->dvb_adapter,
budget_diseqc_ioctl, NULL, budget); budget_diseqc_ioctl, NULL, budget);
...@@ -174,6 +226,10 @@ static int budget_detach (struct saa7146_dev* dev) ...@@ -174,6 +226,10 @@ static int budget_detach (struct saa7146_dev* dev)
struct budget *budget = (struct budget*) dev->ext_priv; struct budget *budget = (struct budget*) dev->ext_priv;
int err; int err;
if (budget->card->type == BUDGET_FS_ACTIVY)
dvb_remove_frontend_ioctls (budget->dvb_adapter,
budget_ioctl_activy, NULL);
else
dvb_remove_frontend_ioctls (budget->dvb_adapter, dvb_remove_frontend_ioctls (budget->dvb_adapter,
budget_diseqc_ioctl, NULL); budget_diseqc_ioctl, NULL);
...@@ -193,6 +249,7 @@ MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT); ...@@ -193,6 +249,7 @@ MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT); MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT);
MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT); MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC); MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC);
MAKE_BUDGET_INFO(fsacs, "Fujitsu Siemens Activy Budget-S PCI", BUDGET_FS_ACTIVY);
/* Uncomment for Budget Patch */ /* Uncomment for Budget Patch */
/*MAKE_BUDGET_INFO(fs_1_3,"Siemens/Technotrend/Hauppauge PCI rev1.3+Budget_Patch", BUDGET_PATCH);*/ /*MAKE_BUDGET_INFO(fs_1_3,"Siemens/Technotrend/Hauppauge PCI rev1.3+Budget_Patch", BUDGET_PATCH);*/
...@@ -203,6 +260,7 @@ static struct pci_device_id pci_tbl[] = { ...@@ -203,6 +260,7 @@ static struct pci_device_id pci_tbl[] = {
MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004), MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004),
MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005), MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005),
MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013), MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
MAKE_EXTENSION_PCI(fsacs, 0x1131, 0x4f61),
{ {
.vendor = 0, .vendor = 0,
} }
......
...@@ -46,10 +46,15 @@ struct budget { ...@@ -46,10 +46,15 @@ struct budget {
int fe_synced; int fe_synced;
struct semaphore pid_mutex; struct semaphore pid_mutex;
int ci_present;
int video_port;
u8 tsf; u8 tsf;
u32 ttbp; u32 ttbp;
int feeding; int feeding;
spinlock_t feedlock;
struct dvb_adapter *dvb_adapter; struct dvb_adapter *dvb_adapter;
void *priv; void *priv;
}; };
...@@ -73,13 +78,17 @@ static struct saa7146_pci_extension_data x_var = { \ ...@@ -73,13 +78,17 @@ static struct saa7146_pci_extension_data x_var = { \
#define BUDGET_TT_HW_DISEQC 1 #define BUDGET_TT_HW_DISEQC 1
#define BUDGET_KNC1 2 #define BUDGET_KNC1 2
#define BUDGET_PATCH 3 #define BUDGET_PATCH 3
#define BUDGET_FS_ACTIVY 4
#define BUDGET_VIDEO_PORTA 0
#define BUDGET_VIDEO_PORTB 1
extern int ttpci_budget_init (struct budget *budget, extern int ttpci_budget_init (struct budget *budget,
struct saa7146_dev* dev, struct saa7146_dev* dev,
struct saa7146_pci_extension_data *info); struct saa7146_pci_extension_data *info);
extern int ttpci_budget_deinit (struct budget *budget); extern int ttpci_budget_deinit (struct budget *budget);
extern void ttpci_budget_irq10_handler (struct saa7146_dev* dev, u32 *isr); extern void ttpci_budget_irq10_handler (struct saa7146_dev* dev, u32 *isr);
extern void ttpci_budget_set_video_port(struct saa7146_dev* dev, int video_port);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment