/* * $Id: saa7134-dvb.c,v 1.7 2005/01/04 16:31:20 kraxel Exp $ * * (c) 2004 Gerd Knorr [SuSE Labs] * * 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 #include #include #include #include #include #include #include #include "saa7134-reg.h" #include "saa7134.h" #include "dvb-pll.h" #include "mt352.h" #include "mt352_priv.h" /* FIXME */ MODULE_AUTHOR("Gerd Knorr [SuSE Labs]"); MODULE_LICENSE("GPL"); /* ------------------------------------------------------------------ */ static int mt352_pinnacle_init(struct dvb_frontend* fe) { static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x39 }; static u8 reset [] = { RESET, 0x80 }; static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; static u8 agc_cfg [] = { AGC_TARGET, 0x20, 0x20 }; static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 }; #if 0 // general purpose port pins static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; #endif struct saa7134_dev *dev= fe->dvb->priv; printk("%s: %s called\n",dev->name,__FUNCTION__); mt352_write(fe, clock_config, sizeof(clock_config)); udelay(200); mt352_write(fe, reset, sizeof(reset)); mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); mt352_write(fe, agc_cfg, sizeof(agc_cfg)); mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); #if 0 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); #endif return 0; } static int mt352_pinnacle_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf) { static u8 buf[][3] = { /* set bandwidth (ADC frequency is 20.333 MHz) */ [ BANDWIDTH_6_MHZ ] = { TRL_NOMINAL_RATE_1, 0x56, 0x55 }, [ BANDWIDTH_7_MHZ ] = { TRL_NOMINAL_RATE_1, 0x64, 0xB8 }, [ BANDWIDTH_8_MHZ ] = { TRL_NOMINAL_RATE_1, 0x73, 0x1C }, }; struct saa7134_dev *dev= fe->dvb->priv; struct v4l2_frequency f; int bw = params->u.ofdm.bandwidth; printk("%s: %s called (freq=%d,bw=%d)\n",dev->name,__FUNCTION__, params->frequency,bw); /* set frequency */ f.tuner = 0; f.type = V4L2_TUNER_ANALOG_TV; /* FIXME */ f.frequency = params->frequency / 1000 * 16 / 1000; saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f); memset(pllbuf,0,5); if (bw < ARRAY_SIZE(buf) && NULL != buf[bw]) { #if 1 /* dirty hack time -- fixup mt352 buffer which has * adc freq 20.48 MHz values hardcoded */ pllbuf[-4] = buf[bw][1]; pllbuf[-3] = buf[bw][2]; pllbuf[-2] = 0x31; /* if 36.1667 + adc 20.333 */ pllbuf[-1] = 0xD9; #else mt352_write(fe, buf[bw], 3); #endif } return 0; } static struct mt352_config pinnacle_300i = { .demod_address = 0x3c >> 1, .demod_init = mt352_pinnacle_init, .pll_set = mt352_pinnacle_pll_set, }; /* ------------------------------------------------------------------ */ static int dvb_init(struct saa7134_dev *dev) { /* init struct videobuf_dvb */ dev->dvb.name = dev->name; videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops, dev->pci, &dev->slock, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, sizeof(struct saa7134_buf), dev); switch (dev->board) { case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: printk("%s: pinnacle 300i dvb setup\n",dev->name); dev->dvb.frontend = mt352_attach(&pinnacle_300i, &dev->i2c_adap); break; default: printk("%s: Huh? unknown DVB card?\n",dev->name); break; } if (NULL == dev->dvb.frontend) { printk("%s: frontend initialization failed\n",dev->name); return -1; } /* register everything else */ return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); } static int dvb_fini(struct saa7134_dev *dev) { printk("%s: %s\n",dev->name,__FUNCTION__); videobuf_dvb_unregister(&dev->dvb); return 0; } static struct saa7134_mpeg_ops dvb_ops = { .type = SAA7134_MPEG_DVB, .init = dvb_init, .fini = dvb_fini, }; static int __init dvb_register(void) { return saa7134_ts_register(&dvb_ops); } static void __exit dvb_unregister(void) { saa7134_ts_unregister(&dvb_ops); } module_init(dvb_register); module_exit(dvb_unregister); /* ------------------------------------------------------------------ */ /* * Local variables: * c-basic-offset: 8 * compile-command: "make DVB=1" * End: */