···150150151151 The frontend module sp887x.o, requires an external firmware.152152 Please use the command "get_dvb_firmware sp887x" to download153153- it. Then copy it to /usr/lib/hotplug/firmware.153153+ it. Then copy it to /usr/lib/hotplug/firmware or /lib/firmware/154154+ (depending on configuration of firmware hotplug).154155155156Receiving DVB-T in Australia156157
+20-3
Documentation/dvb/get_dvb_firmware
···23232424@components = ( "sp8870", "sp887x", "tda10045", "tda10046", "av7110", "dec2000t",2525 "dec2540t", "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",2626- "or51211", "or51132_qam", "or51132_vsb");2626+ "or51211", "or51132_qam", "or51132_vsb", "bluebird");27272828# Check args2929syntax() if (scalar(@ARGV) != 1);···3434 if ($cid eq $components[$i]) {3535 $outfile = eval($cid);3636 die $@ if $@;3737- print STDERR "Firmware $outfile extracted successfully. Now copy it to either /lib/firmware or /usr/lib/hotplug/firmware/ (depending on your hotplug version).\n";3737+ print STDERR <<EOF;3838+Firmware $outfile extracted successfully.3939+Now copy it to either /usr/lib/hotplug/firmware or /lib/firmware4040+(depending on configuration of firmware hotplug).4141+EOF3842 exit(0);3943 }4044}···247243 my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);248244249245 checkstandard();250250-246246+251247 wgetfile($sourcefile, $url);252248 unzip($sourcefile, $tmpdir);253249 verify("$tmpdir/SkyNETU.sys", $hash);···310306 verify($fwfile, $hash);311307312308 $fwfile;309309+}310310+311311+sub bluebird {312312+ my $url = "http://www.linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw";313313+ my $outfile = "dvb-usb-bluebird-01.fw";314314+ my $hash = "658397cb9eba9101af9031302671f49d";315315+316316+ checkstandard();317317+318318+ wgetfile($outfile, $url);319319+ verify($outfile,$hash);320320+321321+ $outfile;313322}314323315324# ---------------------------------------------------------------
+2-1
Documentation/dvb/ttusb-dec.txt
···4141For 2.6 kernels the firmware is loaded at the point that the driver module is4242loaded. See linux/Documentation/dvb/firmware.txt for more information.43434444-Copy the three files downloaded above into the /usr/lib/hotplug/firmware directory.4444+Copy the three files downloaded above into the /usr/lib/hotplug/firmware or4545+/lib/firmware directory (depending on configuration of firmware hotplug).
···283283 hw_buffer->msg[4] = 0x03;284284 hw_buffer->msg[5] = length & 0xff;285285 hw_buffer->msg[6] = 0x00;286286+286287 /*287288 * Need to compute length for EN50221 section 8.3.2, for the time being288289 * assuming 8.3.2 is not applicable289290 */290291 memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length);291292 }293293+292294 return 0;293295}294294-295296296297static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply)297298{
-16
drivers/media/dvb/bt8xx/dvb-bt8xx.c
···600600 struct dst_state* state = NULL;601601602602 switch(type) {603603-#ifdef BTTV_BOARD_DVICO_DVBT_LITE604603 case BTTV_BOARD_DVICO_DVBT_LITE:605604 card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter);606605 if (card->fe != NULL) {···607608 card->fe->ops->info.frequency_max = 862000000;608609 }609610 break;610610-#endif611611612612-#ifdef BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE613612 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:614613 lgdt330x_reset(card);615614 card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter);616615 if (card->fe != NULL)617616 dprintk ("dvb_bt8xx: lgdt330x detected\n");618617 break;619619-#endif620618621621-#ifdef BTTV_BOARD_TWINHAN_VP3021622622- case BTTV_BOARD_TWINHAN_VP3021:623623-#else624619 case BTTV_BOARD_NEBULA_DIGITV:625625-#endif626620 /*627621 * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK);628622 * this would be a cleaner solution than trying each frontend in turn.···804812 card->irq_err_ignore = 0;805813 break;806814807807-#ifdef BTTV_BOARD_DVICO_DVBT_LITE808815 case BTTV_BOARD_DVICO_DVBT_LITE:809809-#endif810816 card->gpio_mode = 0x0400C060;811817 card->op_sync_orin = 0;812818 card->irq_err_ignore = 0;···813823 * DA_APP(parallel) */814824 break;815825816816-#ifdef BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE817826 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:818818-#endif819827 card->gpio_mode = 0x0400c060;820828 card->op_sync_orin = BT878_RISC_SYNC_MASK;821829 card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;822830 break;823831824824-#ifdef BTTV_BOARD_TWINHAN_VP3021825825- case BTTV_BOARD_TWINHAN_VP3021:826826-#else827832 case BTTV_BOARD_NEBULA_DIGITV:828828-#endif829833 case BTTV_BOARD_AVDVBT_761:830834 card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);831835 card->op_sync_orin = 0;
+10-10
drivers/media/dvb/cinergyT2/Kconfig
···2121config DVB_CINERGYT2_STREAM_URB_COUNT2222 int "Number of queued USB Request Blocks for Highspeed Stream Transfers"2323 depends on DVB_CINERGYT2_TUNING2424- default "32"2424+ default "32"2525 help2626 USB Request Blocks for Highspeed Stream transfers are scheduled in2727 a queue for the Host Controller.28282929 Usually the default value is a safe choice.30303131- You may increase this number if you are using this device in a 3232- Server Environment with many high-traffic USB Highspeed devices 3131+ You may increase this number if you are using this device in a3232+ Server Environment with many high-traffic USB Highspeed devices3333 sharing the same USB bus.343435353636config DVB_CINERGYT2_STREAM_BUF_SIZE3737 int "Size of URB Stream Buffers for Highspeed Transfers"3838 depends on DVB_CINERGYT2_TUNING3939- default "512"3939+ default "512"4040 help4141 Should be a multiple of native buffer size of 512 bytes.4242 Default value is a safe choice.43434444- You may increase this number if you are using this device in a 4545- Server Environment with many high-traffic USB Highspeed devices 4444+ You may increase this number if you are using this device in a4545+ Server Environment with many high-traffic USB Highspeed devices4646 sharing the same USB bus.474748484949config DVB_CINERGYT2_QUERY_INTERVAL5050 int "Status update interval [milliseconds]"5151 depends on DVB_CINERGYT2_TUNING5252- default "250"5252+ default "250"5353 help5454 This is the interval for status readouts from the demodulator.5555 You may try lower values if you need more responsive signal quality···6464config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE6565 bool "Register the onboard IR Remote Control Receiver as Input Device"6666 depends on DVB_CINERGYT2_TUNING6767- default "yes"6767+ default "yes"6868 help6969- Enable this option if you want to use the onboard Infrared Remote 6969+ Enable this option if you want to use the onboard Infrared Remote7070 Control Receiver as Linux-Input device.71717272 Right now only the keycode table for the default Remote Control···7777config DVB_CINERGYT2_RC_QUERY_INTERVAL7878 int "Infrared Remote Controller update interval [milliseconds]"7979 depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE8080- default "50"8080+ default "50"8181 help8282 If you have a very fast-repeating remote control you can try lower8383 values, for normal consumer receivers the default value should be
+57-29
drivers/media/dvb/cinergyT2/cinergyT2.c
···131131132132 wait_queue_head_t poll_wq;133133 int pending_fe_events;134134+ int disconnect_pending;135135+ atomic_t inuse;134136135137 void *streambuf;136138 dma_addr_t streambuf_dmahandle;···345343 struct dvb_demux *demux = dvbdmxfeed->demux;346344 struct cinergyt2 *cinergyt2 = demux->priv;347345348348- if (down_interruptible(&cinergyt2->sem))346346+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))349347 return -ERESTARTSYS;350348351349 if (cinergyt2->streaming == 0)···361359 struct dvb_demux *demux = dvbdmxfeed->demux;362360 struct cinergyt2 *cinergyt2 = demux->priv;363361364364- if (down_interruptible(&cinergyt2->sem))362362+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))365363 return -ERESTARTSYS;366364367365 if (--cinergyt2->streaming == 0)···481479{482480 struct dvb_device *dvbdev = file->private_data;483481 struct cinergyt2 *cinergyt2 = dvbdev->priv;484484- int err;482482+ int err = -ERESTARTSYS;485483486486- if ((err = dvb_generic_open(inode, file)))487487- return err;488488-489489- if (down_interruptible(&cinergyt2->sem))484484+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))490485 return -ERESTARTSYS;486486+487487+ if ((err = dvb_generic_open(inode, file))) {488488+ up(&cinergyt2->sem);489489+ return err;490490+ }491491+491492492493 if ((file->f_flags & O_ACCMODE) != O_RDONLY) {493494 cinergyt2_sleep(cinergyt2, 0);494495 schedule_delayed_work(&cinergyt2->query_work, HZ/2);495496 }496497498498+ atomic_inc(&cinergyt2->inuse);499499+497500 up(&cinergyt2->sem);498501 return 0;502502+}503503+504504+static void cinergyt2_unregister(struct cinergyt2 *cinergyt2)505505+{506506+ dvb_unregister_device(cinergyt2->fedev);507507+ dvb_unregister_adapter(&cinergyt2->adapter);508508+509509+ cinergyt2_free_stream_urbs(cinergyt2);510510+ kfree(cinergyt2);499511}500512501513static int cinergyt2_release (struct inode *inode, struct file *file)···520504 if (down_interruptible(&cinergyt2->sem))521505 return -ERESTARTSYS;522506523523- if ((file->f_flags & O_ACCMODE) != O_RDONLY) {507507+ if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) {524508 cancel_delayed_work(&cinergyt2->query_work);525509 flush_scheduled_work();526510 cinergyt2_sleep(cinergyt2, 1);527511 }528512529513 up(&cinergyt2->sem);514514+515515+ if (atomic_dec_and_test(&cinergyt2->inuse) && cinergyt2->disconnect_pending) {516516+ warn("delayed unregister in release");517517+ cinergyt2_unregister(cinergyt2);518518+ }530519531520 return dvb_generic_release(inode, file);532521}···540519{541520 struct dvb_device *dvbdev = file->private_data;542521 struct cinergyt2 *cinergyt2 = dvbdev->priv;522522+523523+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))524524+ return -ERESTARTSYS;525525+543526 poll_wait(file, &cinergyt2->poll_wq, wait);527527+528528+ up(&cinergyt2->sem);529529+544530 return (POLLIN | POLLRDNORM | POLLPRI);545531}546532···592564 (__u16 __user *) arg);593565594566 case FE_READ_UNCORRECTED_BLOCKS:595595- /* UNC are already converted to host byte order... */596596- return put_user(stat->uncorrected_block_count,597597- (__u32 __user *) arg);567567+ {568568+ uint32_t unc_count;598569570570+ unc_count = stat->uncorrected_block_count;571571+ stat->uncorrected_block_count = 0;572572+573573+ /* UNC are already converted to host byte order... */574574+ return put_user(unc_count,(__u32 __user *) arg);575575+ }599576 case FE_SET_FRONTEND:600577 {601578 struct dvbt_set_parameters_msg *param = &cinergyt2->param;···613580 if (copy_from_user(&p, (void __user*) arg, sizeof(p)))614581 return -EFAULT;615582616616- if (down_interruptible(&cinergyt2->sem))583583+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))617584 return -ERESTARTSYS;618585619586 param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;···724691 struct cinergyt2_rc_event rc_events[12];725692 int n, len, i;726693727727- if (down_interruptible(&cinergyt2->sem))694694+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))728695 return;729696730697 len = cinergyt2_command(cinergyt2, buf, sizeof(buf),···819786static void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2)820787{821788 cancel_delayed_work(&cinergyt2->rc_query_work);822822- flush_scheduled_work();823789 input_unregister_device(cinergyt2->rc_input_dev);824790}825791···849817 uint8_t lock_bits;850818 uint32_t unc;851819852852- if (down_interruptible(&cinergyt2->sem))820820+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))853821 return;854822855823 unc = s->uncorrected_block_count;···949917{950918 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);951919952952- if (down_interruptible(&cinergyt2->sem))953953- return;920920+ flush_scheduled_work();954921955922 cinergyt2_unregister_rc(cinergyt2);956923957957- cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx);958958- dvb_net_release(&cinergyt2->dvbnet);959959- dvb_dmxdev_release(&cinergyt2->dmxdev);960960- dvb_dmx_release(&cinergyt2->demux);961961- dvb_unregister_device(cinergyt2->fedev);962962- dvb_unregister_adapter(&cinergyt2->adapter);924924+ cancel_delayed_work(&cinergyt2->query_work);925925+ wake_up_interruptible(&cinergyt2->poll_wq);963926964964- cinergyt2_free_stream_urbs(cinergyt2);965965- up(&cinergyt2->sem);966966- kfree(cinergyt2);927927+ cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx);928928+ cinergyt2->disconnect_pending = 1;929929+930930+ if (!atomic_read(&cinergyt2->inuse))931931+ cinergyt2_unregister(cinergyt2);967932}968933969934static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)970935{971936 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);972937973973- if (down_interruptible(&cinergyt2->sem))938938+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))974939 return -ERESTARTSYS;975940976941 if (state.event > PM_EVENT_ON) {···990961 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);991962 struct dvbt_set_parameters_msg *param = &cinergyt2->param;992963993993- if (down_interruptible(&cinergyt2->sem))964964+ if (cinergyt2->disconnect_pending || down_interruptible(&cinergyt2->sem))994965 return -ERESTARTSYS;995966996967 if (!cinergyt2->sleeping) {···1043101410441015MODULE_LICENSE("GPL");10451016MODULE_AUTHOR("Holger Waechtler, Daniel Mack");10461046-
+1-1
drivers/media/dvb/dvb-core/Kconfig
···55 help66 DVB core utility functions for device handling, software fallbacks etc.77 Say Y when you have a DVB card and want to use it. Say Y if your want88- to build your drivers outside the kernel, but need the DVB core. All 88+ to build your drivers outside the kernel, but need the DVB core. All99 in-kernel drivers will select this automatically if needed.1010 If unsure say N.1111
···92929393struct dvb_frontend_private {94949595+ /* thread/frontend values */9596 struct dvb_device *dvbdev;9697 struct dvb_frontend_parameters parameters;9798 struct dvb_fe_events events;···101100 wait_queue_head_t wait_queue;102101 pid_t thread_pid;103102 unsigned long release_jiffies;104104- int state;105105- int bending;106106- int lnb_drift;107107- int inversion;108108- int auto_step;109109- int auto_sub_step;110110- int started_auto_step;111111- int min_delay;112112- int max_drift;113113- int step_size;114114- int exit;115115- int wakeup;103103+ unsigned int exit;104104+ unsigned int wakeup;116105 fe_status_t status;117117- fe_sec_tone_mode_t tone;106106+ unsigned long tune_mode_flags;107107+ unsigned int delay;108108+109109+ /* swzigzag values */110110+ unsigned int state;111111+ unsigned int bending;112112+ int lnb_drift;113113+ unsigned int inversion;114114+ unsigned int auto_step;115115+ unsigned int auto_sub_step;116116+ unsigned int started_auto_step;117117+ unsigned int min_delay;118118+ unsigned int max_drift;119119+ unsigned int step_size;120120+ int quality;121121+ unsigned int check_wrapped;118122};119123120124···214208 fe->ops->init(fe);215209}216210217217-static void update_delay(int *quality, int *delay, int min_delay, int locked)211211+static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepriv, int locked)218212{219219- int q2;213213+ int q2;220214221221- dprintk ("%s\n", __FUNCTION__);215215+ dprintk ("%s\n", __FUNCTION__);222216223223- if (locked)224224- (*quality) = (*quality * 220 + 36*256) / 256;225225- else226226- (*quality) = (*quality * 220 + 0) / 256;217217+ if (locked)218218+ (fepriv->quality) = (fepriv->quality * 220 + 36*256) / 256;219219+ else220220+ (fepriv->quality) = (fepriv->quality * 220 + 0) / 256;227221228228- q2 = *quality - 128;229229- q2 *= q2;222222+ q2 = fepriv->quality - 128;223223+ q2 *= q2;230224231231- *delay = min_delay + q2 * HZ / (128*128);225225+ fepriv->delay = fepriv->min_delay + q2 * HZ / (128*128);232226}233227234228/**···238232 * @param check_wrapped Checks if an iteration has completed. DO NOT SET ON THE FIRST ATTEMPT239233 * @returns Number of complete iterations that have been performed.240234 */241241-static int dvb_frontend_autotune(struct dvb_frontend *fe, int check_wrapped)235235+static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wrapped)242236{243237 int autoinversion;244238 int ready = 0;···327321 return 0;328322}329323324324+static void dvb_frontend_swzigzag(struct dvb_frontend *fe)325325+{326326+ fe_status_t s;327327+ struct dvb_frontend_private *fepriv = fe->frontend_priv;328328+329329+ /* if we've got no parameters, just keep idling */330330+ if (fepriv->state & FESTATE_IDLE) {331331+ fepriv->delay = 3*HZ;332332+ fepriv->quality = 0;333333+ return;334334+ }335335+336336+ /* in SCAN mode, we just set the frontend when asked and leave it alone */337337+ if (fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT) {338338+ if (fepriv->state & FESTATE_RETUNE) {339339+ if (fe->ops->set_frontend)340340+ fe->ops->set_frontend(fe, &fepriv->parameters);341341+ fepriv->state = FESTATE_TUNED;342342+ }343343+ fepriv->delay = 3*HZ;344344+ fepriv->quality = 0;345345+ return;346346+ }347347+348348+ /* get the frontend status */349349+ if (fepriv->state & FESTATE_RETUNE) {350350+ s = 0;351351+ } else {352352+ if (fe->ops->read_status)353353+ fe->ops->read_status(fe, &s);354354+ if (s != fepriv->status) {355355+ dvb_frontend_add_event(fe, s);356356+ fepriv->status = s;357357+ }358358+ }359359+360360+ /* if we're not tuned, and we have a lock, move to the TUNED state */361361+ if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) {362362+ dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);363363+ fepriv->state = FESTATE_TUNED;364364+365365+ /* if we're tuned, then we have determined the correct inversion */366366+ if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&367367+ (fepriv->parameters.inversion == INVERSION_AUTO)) {368368+ fepriv->parameters.inversion = fepriv->inversion;369369+ }370370+ return;371371+ }372372+373373+ /* if we are tuned already, check we're still locked */374374+ if (fepriv->state & FESTATE_TUNED) {375375+ dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);376376+377377+ /* we're tuned, and the lock is still good... */378378+ if (s & FE_HAS_LOCK) {379379+ return;380380+ } else { /* if we _WERE_ tuned, but now don't have a lock */381381+ fepriv->state = FESTATE_ZIGZAG_FAST;382382+ fepriv->started_auto_step = fepriv->auto_step;383383+ fepriv->check_wrapped = 0;384384+ }385385+ }386386+387387+ /* don't actually do anything if we're in the LOSTLOCK state,388388+ * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */389389+ if ((fepriv->state & FESTATE_LOSTLOCK) &&390390+ (fe->ops->info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) {391391+ dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);392392+ return;393393+ }394394+395395+ /* don't do anything if we're in the DISEQC state, since this396396+ * might be someone with a motorized dish controlled by DISEQC.397397+ * If its actually a re-tune, there will be a SET_FRONTEND soon enough. */398398+ if (fepriv->state & FESTATE_DISEQC) {399399+ dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);400400+ return;401401+ }402402+403403+ /* if we're in the RETUNE state, set everything up for a brand404404+ * new scan, keeping the current inversion setting, as the next405405+ * tune is _very_ likely to require the same */406406+ if (fepriv->state & FESTATE_RETUNE) {407407+ fepriv->lnb_drift = 0;408408+ fepriv->auto_step = 0;409409+ fepriv->auto_sub_step = 0;410410+ fepriv->started_auto_step = 0;411411+ fepriv->check_wrapped = 0;412412+ }413413+414414+ /* fast zigzag. */415415+ if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) {416416+ fepriv->delay = fepriv->min_delay;417417+418418+ /* peform a tune */419419+ if (dvb_frontend_swzigzag_autotune(fe, fepriv->check_wrapped)) {420420+ /* OK, if we've run out of trials at the fast speed.421421+ * Drop back to slow for the _next_ attempt */422422+ fepriv->state = FESTATE_SEARCHING_SLOW;423423+ fepriv->started_auto_step = fepriv->auto_step;424424+ return;425425+ }426426+ fepriv->check_wrapped = 1;427427+428428+ /* if we've just retuned, enter the ZIGZAG_FAST state.429429+ * This ensures we cannot return from an430430+ * FE_SET_FRONTEND ioctl before the first frontend tune431431+ * occurs */432432+ if (fepriv->state & FESTATE_RETUNE) {433433+ fepriv->state = FESTATE_TUNING_FAST;434434+ }435435+ }436436+437437+ /* slow zigzag */438438+ if (fepriv->state & FESTATE_SEARCHING_SLOW) {439439+ dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);440440+441441+ /* Note: don't bother checking for wrapping; we stay in this442442+ * state until we get a lock */443443+ dvb_frontend_swzigzag_autotune(fe, 0);444444+ }445445+}446446+330447static int dvb_frontend_is_exiting(struct dvb_frontend *fe)331448{332449 struct dvb_frontend_private *fepriv = fe->frontend_priv;···459330460331 if (fepriv->dvbdev->writers == 1)461332 if (time_after(jiffies, fepriv->release_jiffies +462462- dvb_shutdown_timeout * HZ))333333+ dvb_shutdown_timeout * HZ))463334 return 1;464335465336 return 0;···484355 wake_up_interruptible(&fepriv->wait_queue);485356}486357487487-/*488488- * FIXME: use linux/kthread.h489489- */490358static int dvb_frontend_thread(void *data)491359{492360 struct dvb_frontend *fe = data;493361 struct dvb_frontend_private *fepriv = fe->frontend_priv;494362 unsigned long timeout;495363 char name [15];496496- int quality = 0, delay = 3*HZ;497364 fe_status_t s;498498- int check_wrapped = 0;365365+ struct dvb_frontend_parameters *params;499366500367 dprintk("%s\n", __FUNCTION__);501368···502377 sigfillset(¤t->blocked);503378 unlock_kernel();504379380380+ fepriv->check_wrapped = 0;381381+ fepriv->quality = 0;382382+ fepriv->delay = 3*HZ;505383 fepriv->status = 0;506384 dvb_frontend_init(fe);507385 fepriv->wakeup = 0;···514386515387 timeout = wait_event_interruptible_timeout(fepriv->wait_queue,516388 dvb_frontend_should_wakeup(fe),517517- delay);389389+ fepriv->delay);518390 if (0 != dvb_frontend_is_exiting(fe)) {519391 /* got signal or quitting */520392 break;···525397 if (down_interruptible(&fepriv->sem))526398 break;527399528528- /* if we've got no parameters, just keep idling */529529- if (fepriv->state & FESTATE_IDLE) {530530- delay = 3*HZ;531531- quality = 0;532532- continue;533533- }400400+ /* do an iteration of the tuning loop */401401+ if (fe->ops->tune) {402402+ /* have we been asked to retune? */403403+ params = NULL;404404+ if (fepriv->state & FESTATE_RETUNE) {405405+ params = &fepriv->parameters;406406+ fepriv->state = FESTATE_TUNED;407407+ }534408535535- /* get the frontend status */536536- if (fepriv->state & FESTATE_RETUNE) {537537- s = 0;538538- } else {539539- if (fe->ops->read_status)540540- fe->ops->read_status(fe, &s);409409+ fe->ops->tune(fe, params, fepriv->tune_mode_flags, &fepriv->delay, &s);541410 if (s != fepriv->status) {542411 dvb_frontend_add_event(fe, s);543412 fepriv->status = s;544413 }545545- }546546- /* if we're not tuned, and we have a lock, move to the TUNED state */547547- if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) {548548- update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);549549- fepriv->state = FESTATE_TUNED;550550-551551- /* if we're tuned, then we have determined the correct inversion */552552- if ((!(fe->ops->info.caps & FE_CAN_INVERSION_AUTO)) &&553553- (fepriv->parameters.inversion == INVERSION_AUTO)) {554554- fepriv->parameters.inversion = fepriv->inversion;555555- }556556- continue;557557- }558558-559559- /* if we are tuned already, check we're still locked */560560- if (fepriv->state & FESTATE_TUNED) {561561- update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);562562-563563- /* we're tuned, and the lock is still good... */564564- if (s & FE_HAS_LOCK)565565- continue;566566- else { /* if we _WERE_ tuned, but now don't have a lock */567567- fepriv->state = FESTATE_ZIGZAG_FAST;568568- fepriv->started_auto_step = fepriv->auto_step;569569- check_wrapped = 0;570570- }571571- }572572-573573- /* don't actually do anything if we're in the LOSTLOCK state,574574- * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */575575- if ((fepriv->state & FESTATE_LOSTLOCK) &&576576- (fe->ops->info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) {577577- update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);578578- continue;579579- }580580-581581- /* don't do anything if we're in the DISEQC state, since this582582- * might be someone with a motorized dish controlled by DISEQC.583583- * If its actually a re-tune, there will be a SET_FRONTEND soon enough. */584584- if (fepriv->state & FESTATE_DISEQC) {585585- update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);586586- continue;587587- }588588-589589- /* if we're in the RETUNE state, set everything up for a brand590590- * new scan, keeping the current inversion setting, as the next591591- * tune is _very_ likely to require the same */592592- if (fepriv->state & FESTATE_RETUNE) {593593- fepriv->lnb_drift = 0;594594- fepriv->auto_step = 0;595595- fepriv->auto_sub_step = 0;596596- fepriv->started_auto_step = 0;597597- check_wrapped = 0;598598- }599599-600600- /* fast zigzag. */601601- if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) {602602- delay = fepriv->min_delay;603603-604604- /* peform a tune */605605- if (dvb_frontend_autotune(fe, check_wrapped)) {606606- /* OK, if we've run out of trials at the fast speed.607607- * Drop back to slow for the _next_ attempt */608608- fepriv->state = FESTATE_SEARCHING_SLOW;609609- fepriv->started_auto_step = fepriv->auto_step;610610- continue;611611- }612612- check_wrapped = 1;613613-614614- /* if we've just retuned, enter the ZIGZAG_FAST state.615615- * This ensures we cannot return from an616616- * FE_SET_FRONTEND ioctl before the first frontend tune617617- * occurs */618618- if (fepriv->state & FESTATE_RETUNE) {619619- fepriv->state = FESTATE_TUNING_FAST;620620- }621621- }622622-623623- /* slow zigzag */624624- if (fepriv->state & FESTATE_SEARCHING_SLOW) {625625- update_delay(&quality, &delay, fepriv->min_delay, s & FE_HAS_LOCK);626626-627627- /* Note: don't bother checking for wrapping; we stay in this628628- * state until we get a lock */629629- dvb_frontend_autotune(fe, 0);414414+ } else {415415+ dvb_frontend_swzigzag(fe);630416 }631417 }632418···775733 err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg);776734 fepriv->state = FESTATE_DISEQC;777735 fepriv->status = 0;778778- fepriv->tone = (fe_sec_tone_mode_t) parg;779736 }780737 break;781738···788747789748 case FE_DISHNETWORK_SEND_LEGACY_CMD:790749 if (fe->ops->dishnetwork_send_legacy_command) {791791- err = fe->ops->dishnetwork_send_legacy_command(fe, (unsigned int) parg);750750+ err = fe->ops->dishnetwork_send_legacy_command(fe, (unsigned long) parg);792751 fepriv->state = FESTATE_DISEQC;793752 fepriv->status = 0;794753 } else if (fe->ops->set_voltage) {···808767 * initialization, so parg is 8 bits and does not809768 * include the initialization or start bit810769 */811811- unsigned int cmd = ((unsigned int) parg) << 1;770770+ unsigned long cmd = ((unsigned long) parg) << 1;812771 struct timeval nexttime;813772 struct timeval tv[10];814773 int i;815774 u8 last = 1;816775 if (dvb_frontend_debug)817817- printk("%s switch command: 0x%04x\n", __FUNCTION__, cmd);776776+ printk("%s switch command: 0x%04lx\n", __FUNCTION__, cmd);818777 do_gettimeofday(&nexttime);819778 if (dvb_frontend_debug)820779 memcpy(&tv[0], &nexttime, sizeof(struct timeval));···855814856815 case FE_ENABLE_HIGH_LNB_VOLTAGE:857816 if (fe->ops->enable_high_lnb_voltage)858858- err = fe->ops->enable_high_lnb_voltage(fe, (int) parg);817817+ err = fe->ops->enable_high_lnb_voltage(fe, (long) parg);859818 break;860819861820 case FE_SET_FRONTEND: {···932891 err = fe->ops->get_frontend(fe, (struct dvb_frontend_parameters*) parg);933892 }934893 break;894894+895895+ case FE_SET_FRONTEND_TUNE_MODE:896896+ fepriv->tune_mode_flags = (unsigned long) parg;897897+ break;935898 };936899937900 up (&fepriv->sem);···977932978933 /* empty event queue */979934 fepriv->events.eventr = fepriv->events.eventw = 0;935935+936936+ /* normal tune mode when opened R/W */937937+ fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT;980938 }981939982940 return ret;···1038990 init_MUTEX (&fepriv->events.sem);1039991 fe->dvb = dvb;1040992 fepriv->inversion = INVERSION_OFF;10411041- fepriv->tone = SEC_TONE_OFF;10429931043994 printk ("DVB: registering frontend %i (%s)...\n",1044995 fe->dvb->num,
+13-3
drivers/media/dvb/dvb-core/dvb_frontend.h
···5858 int (*init)(struct dvb_frontend* fe);5959 int (*sleep)(struct dvb_frontend* fe);60606161+ /* if this is set, it overrides the default swzigzag */6262+ int (*tune)(struct dvb_frontend* fe,6363+ struct dvb_frontend_parameters* params,6464+ unsigned int mode_flags,6565+ int *delay,6666+ fe_status_t *status);6767+6868+ /* these two are only used for the swzigzag code */6169 int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);6262- int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);6370 int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);7171+7272+ int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);64736574 int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);6675 int (*read_ber)(struct dvb_frontend* fe, u32* ber);···8374 int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);8475 int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);8576 int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);8686- int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, int arg);8787- int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned int cmd);7777+ int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);7878+ int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);7979+ int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);8880};89819082#define MAX_EVENT 8
+3-3
drivers/media/dvb/dvb-core/dvb_net.c
···12221222 return if_num;12231223}1224122412251225-static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num)12251225+static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned long num)12261226{12271227 struct net_device *net = dvbnet->device[num];12281228 struct dvb_net_priv *priv;···1296129612971297 if (!capable(CAP_SYS_ADMIN))12981298 return -EPERM;12991299- if ((unsigned int) parg >= DVB_NET_DEVICES_MAX)12991299+ if ((unsigned long) parg >= DVB_NET_DEVICES_MAX)13001300 return -EINVAL;13011301- ret = dvb_net_remove_if(dvbnet, (unsigned int) parg);13011301+ ret = dvb_net_remove_if(dvbnet, (unsigned long) parg);13021302 if (!ret)13031303 module_put(dvbdev->adapter->module);13041304 return ret;
+16-16
drivers/media/dvb/dvb-core/dvb_ringbuffer.c
···112112 split = (rbuf->pread + len > rbuf->size) ? rbuf->size - rbuf->pread : 0;113113 if (split > 0) {114114 if (!usermem)115115- memcpy(buf, rbuf->data+rbuf->pread, split);115115+ memcpy(buf, rbuf->data+rbuf->pread, split);116116 else117117- if (copy_to_user(buf, rbuf->data+rbuf->pread, split))118118- return -EFAULT;117117+ if (copy_to_user(buf, rbuf->data+rbuf->pread, split))118118+ return -EFAULT;119119 buf += split;120120 todo -= split;121121 rbuf->pread = 0;···124124 memcpy(buf, rbuf->data+rbuf->pread, todo);125125 else126126 if (copy_to_user(buf, rbuf->data+rbuf->pread, todo))127127- return -EFAULT;127127+ return -EFAULT;128128129129 rbuf->pread = (rbuf->pread + todo) % rbuf->size;130130···167167}168168169169ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx,170170- int offset, u8* buf, size_t len, int usermem)170170+ int offset, u8* buf, size_t len, int usermem)171171{172172 size_t todo;173173 size_t split;···183183 split = ((idx + len) > rbuf->size) ? rbuf->size - idx : 0;184184 if (split > 0) {185185 if (!usermem)186186- memcpy(buf, rbuf->data+idx, split);186186+ memcpy(buf, rbuf->data+idx, split);187187 else188188- if (copy_to_user(buf, rbuf->data+idx, split))189189- return -EFAULT;188188+ if (copy_to_user(buf, rbuf->data+idx, split))189189+ return -EFAULT;190190 buf += split;191191 todo -= split;192192 idx = 0;···195195 memcpy(buf, rbuf->data+idx, todo);196196 else197197 if (copy_to_user(buf, rbuf->data+idx, todo))198198- return -EFAULT;198198+ return -EFAULT;199199200200 return len;201201}···209209 // clean up disposed packets210210 while(dvb_ringbuffer_avail(rbuf) > DVB_RINGBUFFER_PKTHDRSIZE) {211211 if (DVB_RINGBUFFER_PEEK(rbuf, 2) == PKT_DISPOSED) {212212- pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8;213213- pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1);214214- DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE);212212+ pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8;213213+ pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1);214214+ DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE);215215 } else {216216- // first packet is not disposed, so we stop cleaning now217217- break;216216+ // first packet is not disposed, so we stop cleaning now217217+ break;218218 }219219 }220220}···242242 curpktstatus = rbuf->data[(idx + 2) % rbuf->size];243243244244 if (curpktstatus == PKT_READY) {245245- *pktlen = curpktlen;246246- return idx;245245+ *pktlen = curpktlen;246246+ return idx;247247 }248248249249 consumed += curpktlen + DVB_RINGBUFFER_PKTHDRSIZE;
+4-4
drivers/media/dvb/dvb-core/dvb_ringbuffer.h
···106106** returns number of bytes transferred or -EFAULT107107*/108108extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf,109109- size_t len, int usermem);109109+ size_t len, int usermem);110110111111112112/* write routines & macros */···121121** returns number of bytes transferred or -EFAULT122122*/123123extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf,124124- size_t len);124124+ size_t len);125125126126127127/**···133133 * returns Number of bytes written, or -EFAULT, -ENOMEM, -EVINAL.134134 */135135extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf,136136- size_t len);136136+ size_t len);137137138138/**139139 * Read from a packet in the ringbuffer. Note: unlike dvb_ringbuffer_read(), this···149149 * returns Number of bytes read, or -EFAULT.150150 */151151extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx,152152- int offset, u8* buf, size_t len, int usermem);152152+ int offset, u8* buf, size_t len, int usermem);153153154154/**155155 * Dispose of a packet in the ring buffer.
+11-11
drivers/media/dvb/dvb-core/dvbdev.c
···9292 old_fops = file->f_op;9393 file->f_op = fops_get(dvbdev->fops);9494 if(file->f_op->open)9595- err = file->f_op->open(inode,file);9595+ err = file->f_op->open(inode,file);9696 if (err) {9797- fops_put(file->f_op);9898- file->f_op = fops_get(old_fops);9797+ fops_put(file->f_op);9898+ file->f_op = fops_get(old_fops);9999 }100100 fops_put(old_fops);101101 return err;···356356 case _IOC_WRITE:357357 case (_IOC_WRITE | _IOC_READ):358358 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {359359- parg = sbuf;359359+ parg = sbuf;360360 } else {361361- /* too big to allocate from stack */362362- mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);363363- if (NULL == mbuf)364364- return -ENOMEM;365365- parg = mbuf;361361+ /* too big to allocate from stack */362362+ mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);363363+ if (NULL == mbuf)364364+ return -ENOMEM;365365+ parg = mbuf;366366 }367367368368 err = -EFAULT;369369 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))370370- goto out;370370+ goto out;371371 break;372372 }373373···384384 case _IOC_READ:385385 case (_IOC_WRITE | _IOC_READ):386386 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))387387- err = -EFAULT;387387+ err = -EFAULT;388388 break;389389 }390390
+1-1
drivers/media/dvb/dvb-core/dvbdev.h
···9797generic_usercopy() someday... */98989999extern int dvb_usercopy(struct inode *inode, struct file *file,100100- unsigned int cmd, unsigned long arg,100100+ unsigned int cmd, unsigned long arg,101101 int (*func)(struct inode *inode, struct file *file,102102 unsigned int cmd, void *arg));103103
+16-10
drivers/media/dvb/dvb-usb/Kconfig
···3737 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.38383939 Devices supported by this driver:4040- TwinhanDTV USB-Ter (VP7041)4141- TwinhanDTV Magic Box (VP7041e)4242- KWorld/JetWay/ADSTech V-Stream XPERT DTV - DVB-T USB1.1 and USB2.04343- Hama DVB-T USB1.1-Box4444- DiBcom USB1.1 reference devices (non-public)4545- Ultima Electronic/Artec T1 USB TVBOX4646- Compro Videomate DVB-U2000 - DVB-T USB4747- Grandtec DVB-T USB4848- Avermedia AverTV DVBT USB1.14940 Artec T1 USB1.1 boxes4141+ Avermedia AverTV DVBT USB1.14242+ Compro Videomate DVB-U2000 - DVB-T USB4343+ DiBcom USB1.1 reference devices (non-public)4444+ Grandtec DVB-T USB4545+ Hama DVB-T USB1.1-Box4646+ KWorld/JetWay/ADSTech V-Stream XPERT DTV - DVB-T USB1.1 and USB2.04747+ TwinhanDTV Magic Box (VP7041e)4848+ TwinhanDTV USB-Ter (VP7041)4949+ Ultima Electronic/Artec T1 USB TVBOX50505151 The VP7041 seems to be identical to "CTS Portable" (Chinese5252 Television System).53535454 Say Y if you own such a device and want to use it. You should build it as5555 a module.5656+5757+config DVB_USB_DIBUSB_MB_FAULTY5858+ bool "Support faulty USB IDs"5959+ depends on DVB_USB_DIBUSB_MB6060+ help6161+ Support for faulty USB IDs due to an invalid EEPROM on some Artec devices.56625763config DVB_USB_DIBUSB_MC5864 tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)"···6963 DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.70647165 Devices supported by this driver:7272- DiBcom USB2.0 reference devices (non-public)7366 Artec T1 USB2.0 boxes6767+ DiBcom USB2.0 reference devices (non-public)74687569 Say Y if you own such a device and want to use it. You should build it as7670 a module.
···138138139139 int ret = -ENOMEM,cold=0;140140141141+ if (du != NULL)142142+ *du = NULL;143143+141144 if ((desc = dvb_usb_find_device(udev,props,&cold)) == NULL) {142145 deb_err("something went very wrong, device was not found in current device list - let's see what comes next.\n");143146 return -ENODEV;···148145149146 if (cold) {150147 info("found a '%s' in cold state, will try to load a firmware",desc->name);151151- ret = usb_cypress_load_firmware(udev,props->firmware,props->usb_ctrl);152152- } else {153153- info("found a '%s' in warm state.",desc->name);154154- d = kmalloc(sizeof(struct dvb_usb_device),GFP_KERNEL);155155- if (d == NULL) {156156- err("no memory for 'struct dvb_usb_device'");148148+ ret = dvb_usb_download_firmware(udev,props);149149+ if (!props->no_reconnect)157150 return ret;158158- }159159- memset(d,0,sizeof(struct dvb_usb_device));160160-161161- d->udev = udev;162162- memcpy(&d->props,props,sizeof(struct dvb_usb_properties));163163- d->desc = desc;164164- d->owner = owner;165165-166166- if (d->props.size_of_priv > 0) {167167- d->priv = kmalloc(d->props.size_of_priv,GFP_KERNEL);168168- if (d->priv == NULL) {169169- err("no memory for priv in 'struct dvb_usb_device'");170170- kfree(d);171171- return -ENOMEM;172172- }173173- memset(d->priv,0,d->props.size_of_priv);174174- }175175-176176- usb_set_intfdata(intf, d);177177-178178- if (du != NULL)179179- *du = d;180180-181181- ret = dvb_usb_init(d);182151 }152152+153153+ info("found a '%s' in warm state.",desc->name);154154+ d = kmalloc(sizeof(struct dvb_usb_device),GFP_KERNEL);155155+ if (d == NULL) {156156+ err("no memory for 'struct dvb_usb_device'");157157+ return ret;158158+ }159159+ memset(d,0,sizeof(struct dvb_usb_device));160160+161161+ d->udev = udev;162162+ memcpy(&d->props,props,sizeof(struct dvb_usb_properties));163163+ d->desc = desc;164164+ d->owner = owner;165165+166166+ if (d->props.size_of_priv > 0) {167167+ d->priv = kmalloc(d->props.size_of_priv,GFP_KERNEL);168168+ if (d->priv == NULL) {169169+ err("no memory for priv in 'struct dvb_usb_device'");170170+ kfree(d);171171+ return -ENOMEM;172172+ }173173+ memset(d->priv,0,d->props.size_of_priv);174174+ }175175+176176+ usb_set_intfdata(intf, d);177177+178178+ if (du != NULL)179179+ *du = d;180180+181181+ ret = dvb_usb_init(d);183182184183 if (ret == 0)185184 info("%s successfully initialized and connected.",desc->name);
+23-6
drivers/media/dvb/dvb-usb/dvb-usb.h
···10101111#include <linux/config.h>1212#include <linux/input.h>1313-#include <linux/module.h>1413#include <linux/usb.h>1414+#include <linux/firmware.h>15151616#include "dvb_frontend.h"1717#include "dvb_demux.h"···9494 * @usb_ctrl: which USB device-side controller is in use. Needed for firmware9595 * download.9696 * @firmware: name of the firmware file.9797- *9797+ * @download_firmware: called to download the firmware when the usb_ctrl is9898+ * DEVICE_SPECIFIC.9999+ * @no_reconnect: device doesn't do a reconnect after downloading the firmware,100100+ so do the warm initialization right after it101101+98102 * @size_of_priv: how many bytes shall be allocated for the private field99103 * of struct dvb_usb_device.100104 *···146142 int caps;147143 int pid_filter_count;148144149149-#define CYPRESS_AN2135 0150150-#define CYPRESS_AN2235 1151151-#define CYPRESS_FX2 2145145+#define DEVICE_SPECIFIC 0146146+#define CYPRESS_AN2135 1147147+#define CYPRESS_AN2235 2148148+#define CYPRESS_FX2 3152149 int usb_ctrl;153153- const char *firmware;150150+ const char firmware[FIRMWARE_NAME_MAX];151151+ int (*download_firmware) (struct usb_device *, const struct firmware *);152152+ int no_reconnect;154153155154 int size_of_priv;156155···333326extern int dvb_usb_pll_set(struct dvb_frontend *, struct dvb_frontend_parameters *, u8[]);334327extern int dvb_usb_pll_set_i2c(struct dvb_frontend *, struct dvb_frontend_parameters *);335328329329+/* commonly used firmware download types and function */330330+struct hexline {331331+ u8 len;332332+ u32 addr;333333+ u8 type;334334+ u8 data[255];335335+ u8 chk;336336+};337337+extern int dvb_usb_get_hexline(const struct firmware *, struct hexline *, int *);338338+extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);336339337340#endif
···1616 help1717 A DVB-S tuner module. Say Y when you want to support this frontend.18181919+config DVB_CX241232020+ tristate "Conexant CX24123 based"2121+ depends on DVB_CORE2222+ help2323+ A DVB-S tuner module. Say Y when you want to support this frontend.2424+1925config DVB_TDA80832026 tristate "Philips TDA8083 based"2127 depends on DVB_CORE···5650 depends on DVB_CORE57515852config DVB_SP88705959- tristate "Spase sp8870 based"5353+ tristate "Spase sp8870 based"6054 depends on DVB_CORE6155 select FW_LOADER6256 help6363- A DVB-T tuner module. Say Y when you want to support this frontend.5757+ A DVB-T tuner module. Say Y when you want to support this frontend.64586559 This driver needs external firmware. Please use the command6660 "<kerneldir>/Documentation/dvb/get_dvb_firmware sp8870" to6767- download/extract it, and then copy it to /usr/lib/hotplug/firmware.6161+ download/extract it, and then copy it to /usr/lib/hotplug/firmware6262+ or /lib/firmware (depending on configuration of firmware hotplug).68636964config DVB_SP887X7070- tristate "Spase sp887x based"6565+ tristate "Spase sp887x based"7166 depends on DVB_CORE7267 select FW_LOADER7368 help···76697770 This driver needs external firmware. Please use the command7871 "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to7979- download/extract it, and then copy it to /usr/lib/hotplug/firmware.7272+ download/extract it, and then copy it to /usr/lib/hotplug/firmware7373+ or /lib/firmware (depending on configuration of firmware hotplug).80748175config DVB_CX227008276 tristate "Conexant CX22700 based"···8678 A DVB-T tuner module. Say Y when you want to support this frontend.87798880config DVB_CX227028989- tristate "Conexant cx22702 demodulator (OFDM)"9090- depends on DVB_CORE9191- help9292- A DVB-T tuner module. Say Y when you want to support this frontend.8181+ tristate "Conexant cx22702 demodulator (OFDM)"8282+ depends on DVB_CORE8383+ help8484+ A DVB-T tuner module. Say Y when you want to support this frontend.93859486config DVB_L647819587 tristate "LSI L64781"···1069810799 This driver needs external firmware. Please use the commands108100 "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",109109- "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to110110- download/extract them, and then copy them to /usr/lib/hotplug/firmware.101101+ "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to102102+ download/extract them, and then copy them to /usr/lib/hotplug/firmware103103+ or /lib/firmware (depending on configuration of firmware hotplug).111104112105config DVB_NXT6000113106 tristate "NxtWave Communications NXT6000 based"···149140 tristate "VLSI VES1820 based"150141 depends on DVB_CORE151142 help152152- A DVB-C tuner module. Say Y when you want to support this frontend.143143+ A DVB-C tuner module. Say Y when you want to support this frontend.153144154145config DVB_TDA10021155146 tristate "Philips TDA10021 based"156147 depends on DVB_CORE157148 help158158- A DVB-C tuner module. Say Y when you want to support this frontend.149149+ A DVB-C tuner module. Say Y when you want to support this frontend.159150160151config DVB_STV0297161152 tristate "ST STV0297 based"···173164 help174165 An ATSC 8VSB tuner module. Say Y when you want to support this frontend.175166167167+ This driver needs external firmware. Please use the command168168+ "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" to169169+ download/extract it, and then copy it to /usr/lib/hotplug/firmware170170+ or /lib/firmware (depending on configuration of firmware hotplug).171171+176172config DVB_NXT200X177173 tristate "Nextwave NXT2002/NXT2004 based"178174 depends on DVB_CORE···185171 help186172 An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want187173 to support this frontend.174174+175175+ This driver needs external firmware. Please use the commands176176+ "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" and177177+ "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2004" to178178+ download/extract them, and then copy them to /usr/lib/hotplug/firmware179179+ or /lib/firmware (depending on configuration of firmware hotplug).188180189181config DVB_OR51211190182 tristate "or51211 based (pcHDTV HD2000 card)"
···255255 bcm3510_register_value b;256256 int ret;257257258258- if ((ret < bcm3510_readB(st,0xfa,&b)) < 0)258258+ if ((ret = bcm3510_readB(st,0xfa,&b)) < 0)259259 return ret;260260261261 b.BERCTL_fa.RESYNC = 0; bcm3510_writeB(st,0xfa,b);···623623 err("could not load firmware (%s): %d",BCM3510_DEFAULT_FIRMWARE,ret);624624 return ret;625625 }626626- deb_info("got firmware: %d\n",fw->size);626626+ deb_info("got firmware: %zd\n",fw->size);627627628628 b = fw->data;629629 for (i = 0; i < fw->size;) {630630 addr = le16_to_cpu( *( (u16 *)&b[i] ) );631631 len = le16_to_cpu( *( (u16 *)&b[i+2] ) );632632- deb_info("firmware chunk, addr: 0x%04x, len: 0x%04x, total length: 0x%04x\n",addr,len,fw->size);632632+ deb_info("firmware chunk, addr: 0x%04x, len: 0x%04x, total length: 0x%04zx\n",addr,len,fw->size);633633 if ((ret = bcm3510_write_ram(st,addr,&b[i+4],len)) < 0) {634634 err("firmware download failed: %d\n",ret);635635 return ret;
+16-6
drivers/media/dvb/frontends/cx22702.c
···195195 return 0;196196}197197198198+static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)199199+{200200+ struct cx22702_state* state = fe->demodulator_priv;201201+ dprintk ("%s(%d)\n", __FUNCTION__, enable);202202+ if (enable)203203+ return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe);204204+ else205205+ return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) | 1);206206+}207207+198208/* Talk to the demod, set the FEC, GUARD, QAM settings etc */199209static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p)200210{···212202 struct cx22702_state* state = fe->demodulator_priv;213203214204 /* set PLL */215215- cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);205205+ cx22702_i2c_gate_ctrl(fe, 1);216206 if (state->config->pll_set) {217207 state->config->pll_set(fe, p);218208 } else if (state->config->pll_desc) {···226216 } else {227217 BUG();228218 }229229- cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);219219+ cx22702_i2c_gate_ctrl(fe, 0);230220231221 /* set inversion */232222 cx22702_set_inversion (state, p->inversion);···359349 cx22702_writereg (state, 0xf8, (state->config->output_mode << 1) & 0x02);360350361351 /* init PLL */362362- if (state->config->pll_init) {363363- cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) & 0xfe);352352+ if (state->config->pll_init)364353 state->config->pll_init(fe);365365- cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);366366- }354354+355355+ cx22702_i2c_gate_ctrl(fe, 0);367356368357 return 0;369358}···540531 .read_signal_strength = cx22702_read_signal_strength,541532 .read_snr = cx22702_read_snr,542533 .read_ucblocks = cx22702_read_ucblocks,534534+ .i2c_gate_ctrl = cx22702_i2c_gate_ctrl,543535};544536545537module_param(debug, int, 0644);
+11-12
drivers/media/dvb/frontends/cx24110.c
···2727#include <linux/module.h>2828#include <linux/moduleparam.h>2929#include <linux/init.h>3030-#include <linux/jiffies.h>31303231#include "dvb_frontend.h"3332#include "cx24110.h"···55565657static struct {u8 reg; u8 data;} cx24110_regdata[]=5758 /* Comments beginning with @ denote this value should5858- be the default */5959+ be the default */5960 {{0x09,0x01}, /* SoftResetAll */6061 {0x09,0x00}, /* release reset */6162 {0x01,0xe8}, /* MSB of code rate 27.5MS/s */···6667 {0x07,0x01}, /* @ Fclk, i.e. sampling clock, 60MHz */6768 {0x0a,0x00}, /* @ partial chip disables, do not set */6869 {0x0b,0x01}, /* set output clock in gapped mode, start signal low6969- active for first byte */7070+ active for first byte */7071 {0x0c,0x11}, /* no parity bytes, large hold time, serial data out */7172 {0x0d,0x6f}, /* @ RS Sync/Unsync thresholds */7273 {0x10,0x40}, /* chip doc is misleading here: write bit 6 as 17373- to avoid starting the BER counter. Reset the7474- CRC test bit. Finite counting selected */7474+ to avoid starting the BER counter. Reset the7575+ CRC test bit. Finite counting selected */7576 {0x15,0xff}, /* @ size of the limited time window for RS BER7676- estimation. It is <value>*256 RS blocks, this7777- gives approx. 2.6 sec at 27.5MS/s, rate 3/4 */7777+ estimation. It is <value>*256 RS blocks, this7878+ gives approx. 2.6 sec at 27.5MS/s, rate 3/4 */7879 {0x16,0x00}, /* @ enable all RS output ports */7980 {0x17,0x04}, /* @ time window allowed for the RS to sync */8081 {0x18,0xae}, /* @ allow all standard DVB code rates to be scanned8181- for automatically */8282+ for automatically */8283 /* leave the current code rate and normalization8383- registers as they are after reset... */8484+ registers as they are after reset... */8485 {0x21,0x10}, /* @ during AutoAcq, search each viterbi setting8585- only once */8686+ only once */8687 {0x23,0x18}, /* @ size of the limited time window for Viterbi BER8787- estimation. It is <value>*65536 channel bits, i.e.8888- approx. 38ms at 27.5MS/s, rate 3/4 */8888+ estimation. It is <value>*65536 channel bits, i.e.8989+ approx. 38ms at 27.5MS/s, rate 3/4 */8990 {0x24,0x24}, /* do not trigger Viterbi CRC test. Finite count window */9091 /* leave front-end AGC parameters at default values */9192 /* leave decimation AGC parameters at default values */
+889
drivers/media/dvb/frontends/cx24123.c
···11+/*22+ Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver33+44+ Copyright (C) 2005 Steven Toth <stoth@hauppauge.com>55+66+ Support for KWorld DVB-S 100 by Vadim Catana <skystar@moldova.cc>77+88+ This program is free software; you can redistribute it and/or modify99+ it under the terms of the GNU General Public License as published by1010+ the Free Software Foundation; either version 2 of the License, or1111+ (at your option) any later version.1212+1313+ This program is distributed in the hope that it will be useful,1414+ but WITHOUT ANY WARRANTY; without even the implied warranty of1515+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1616+ GNU General Public License for more details.1717+1818+ You should have received a copy of the GNU General Public License1919+ along with this program; if not, write to the Free Software2020+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2121+*/2222+2323+#include <linux/slab.h>2424+#include <linux/kernel.h>2525+#include <linux/module.h>2626+#include <linux/moduleparam.h>2727+#include <linux/init.h>2828+2929+#include "dvb_frontend.h"3030+#include "cx24123.h"3131+3232+static int debug;3333+#define dprintk(args...) \3434+ do { \3535+ if (debug) printk (KERN_DEBUG "cx24123: " args); \3636+ } while (0)3737+3838+struct cx24123_state3939+{4040+ struct i2c_adapter* i2c;4141+ struct dvb_frontend_ops ops;4242+ const struct cx24123_config* config;4343+4444+ struct dvb_frontend frontend;4545+4646+ u32 lastber;4747+ u16 snr;4848+ u8 lnbreg;4949+5050+ /* Some PLL specifics for tuning */5151+ u32 VCAarg;5252+ u32 VGAarg;5353+ u32 bandselectarg;5454+ u32 pllarg;5555+5656+ /* The Demod/Tuner can't easily provide these, we cache them */5757+ u32 currentfreq;5858+ u32 currentsymbolrate;5959+};6060+6161+/* Various tuner defaults need to be established for a given symbol rate Sps */6262+static struct6363+{6464+ u32 symbolrate_low;6565+ u32 symbolrate_high;6666+ u32 VCAslope;6767+ u32 VCAoffset;6868+ u32 VGA1offset;6969+ u32 VGA2offset;7070+ u32 VCAprogdata;7171+ u32 VGAprogdata;7272+} cx24123_AGC_vals[] =7373+{7474+ {7575+ .symbolrate_low = 1000000,7676+ .symbolrate_high = 4999999,7777+ .VCAslope = 0x07,7878+ .VCAoffset = 0x0f,7979+ .VGA1offset = 0x1f8,8080+ .VGA2offset = 0x1f8,8181+ .VGAprogdata = (2 << 18) | (0x1f8 << 9) | 0x1f8,8282+ .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x07,8383+ },8484+ {8585+ .symbolrate_low = 5000000,8686+ .symbolrate_high = 14999999,8787+ .VCAslope = 0x1f,8888+ .VCAoffset = 0x1f,8989+ .VGA1offset = 0x1e0,9090+ .VGA2offset = 0x180,9191+ .VGAprogdata = (2 << 18) | (0x180 << 9) | 0x1e0,9292+ .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x1f,9393+ },9494+ {9595+ .symbolrate_low = 15000000,9696+ .symbolrate_high = 45000000,9797+ .VCAslope = 0x3f,9898+ .VCAoffset = 0x3f,9999+ .VGA1offset = 0x180,100100+ .VGA2offset = 0x100,101101+ .VGAprogdata = (2 << 18) | (0x100 << 9) | 0x180,102102+ .VCAprogdata = (4 << 18) | (0x07 << 9) | 0x3f,103103+ },104104+};105105+106106+/*107107+ * Various tuner defaults need to be established for a given frequency kHz.108108+ * fixme: The bounds on the bands do not match the doc in real life.109109+ * fixme: Some of them have been moved, other might need adjustment.110110+ */111111+static struct112112+{113113+ u32 freq_low;114114+ u32 freq_high;115115+ u32 bandselect;116116+ u32 VCOdivider;117117+ u32 VCOnumber;118118+ u32 progdata;119119+} cx24123_bandselect_vals[] =120120+{121121+ {122122+ .freq_low = 950000,123123+ .freq_high = 1018999,124124+ .bandselect = 0x40,125125+ .VCOdivider = 4,126126+ .VCOnumber = 7,127127+ .progdata = (0 << 18) | (0 << 9) | 0x40,128128+ },129129+ {130130+ .freq_low = 1019000,131131+ .freq_high = 1074999,132132+ .bandselect = 0x80,133133+ .VCOdivider = 4,134134+ .VCOnumber = 8,135135+ .progdata = (0 << 18) | (0 << 9) | 0x80,136136+ },137137+ {138138+ .freq_low = 1075000,139139+ .freq_high = 1227999,140140+ .bandselect = 0x01,141141+ .VCOdivider = 2,142142+ .VCOnumber = 1,143143+ .progdata = (0 << 18) | (1 << 9) | 0x01,144144+ },145145+ {146146+ .freq_low = 1228000,147147+ .freq_high = 1349999,148148+ .bandselect = 0x02,149149+ .VCOdivider = 2,150150+ .VCOnumber = 2,151151+ .progdata = (0 << 18) | (1 << 9) | 0x02,152152+ },153153+ {154154+ .freq_low = 1350000,155155+ .freq_high = 1481999,156156+ .bandselect = 0x04,157157+ .VCOdivider = 2,158158+ .VCOnumber = 3,159159+ .progdata = (0 << 18) | (1 << 9) | 0x04,160160+ },161161+ {162162+ .freq_low = 1482000,163163+ .freq_high = 1595999,164164+ .bandselect = 0x08,165165+ .VCOdivider = 2,166166+ .VCOnumber = 4,167167+ .progdata = (0 << 18) | (1 << 9) | 0x08,168168+ },169169+ {170170+ .freq_low = 1596000,171171+ .freq_high = 1717999,172172+ .bandselect = 0x10,173173+ .VCOdivider = 2,174174+ .VCOnumber = 5,175175+ .progdata = (0 << 18) | (1 << 9) | 0x10,176176+ },177177+ {178178+ .freq_low = 1718000,179179+ .freq_high = 1855999,180180+ .bandselect = 0x20,181181+ .VCOdivider = 2,182182+ .VCOnumber = 6,183183+ .progdata = (0 << 18) | (1 << 9) | 0x20,184184+ },185185+ {186186+ .freq_low = 1856000,187187+ .freq_high = 2035999,188188+ .bandselect = 0x40,189189+ .VCOdivider = 2,190190+ .VCOnumber = 7,191191+ .progdata = (0 << 18) | (1 << 9) | 0x40,192192+ },193193+ {194194+ .freq_low = 2036000,195195+ .freq_high = 2149999,196196+ .bandselect = 0x80,197197+ .VCOdivider = 2,198198+ .VCOnumber = 8,199199+ .progdata = (0 << 18) | (1 << 9) | 0x80,200200+ },201201+};202202+203203+static struct {204204+ u8 reg;205205+ u8 data;206206+} cx24123_regdata[] =207207+{208208+ {0x00, 0x03}, /* Reset system */209209+ {0x00, 0x00}, /* Clear reset */210210+ {0x01, 0x3b}, /* Apply sensible defaults, from an i2c sniffer */211211+ {0x03, 0x07},212212+ {0x04, 0x10},213213+ {0x05, 0x04},214214+ {0x06, 0x31},215215+ {0x0d, 0x02},216216+ {0x0e, 0x03},217217+ {0x0f, 0xfe},218218+ {0x10, 0x01},219219+ {0x14, 0x01},220220+ {0x15, 0x98},221221+ {0x16, 0x00},222222+ {0x17, 0x01},223223+ {0x1b, 0x05},224224+ {0x1c, 0x80},225225+ {0x1d, 0x00},226226+ {0x1e, 0x00},227227+ {0x20, 0x41},228228+ {0x21, 0x15},229229+ {0x27, 0x14},230230+ {0x28, 0x46},231231+ {0x29, 0x00},232232+ {0x2a, 0xb0},233233+ {0x2b, 0x73},234234+ {0x2c, 0x00},235235+ {0x2d, 0x00},236236+ {0x2e, 0x00},237237+ {0x2f, 0x00},238238+ {0x30, 0x00},239239+ {0x31, 0x00},240240+ {0x32, 0x8c},241241+ {0x33, 0x00},242242+ {0x34, 0x00},243243+ {0x35, 0x03},244244+ {0x36, 0x02},245245+ {0x37, 0x3a},246246+ {0x3a, 0x00}, /* Enable AGC accumulator */247247+ {0x44, 0x00},248248+ {0x45, 0x00},249249+ {0x46, 0x05},250250+ {0x56, 0x41},251251+ {0x57, 0xff},252252+ {0x67, 0x83},253253+};254254+255255+static int cx24123_writereg(struct cx24123_state* state, int reg, int data)256256+{257257+ u8 buf[] = { reg, data };258258+ struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };259259+ int err;260260+261261+ if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {262262+ printk("%s: writereg error(err == %i, reg == 0x%02x,"263263+ " data == 0x%02x)\n", __FUNCTION__, err, reg, data);264264+ return -EREMOTEIO;265265+ }266266+267267+ return 0;268268+}269269+270270+static int cx24123_writelnbreg(struct cx24123_state* state, int reg, int data)271271+{272272+ u8 buf[] = { reg, data };273273+ /* fixme: put the intersil addr int the config */274274+ struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = buf, .len = 2 };275275+ int err;276276+277277+ if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {278278+ printk("%s: writelnbreg error (err == %i, reg == 0x%02x,"279279+ " data == 0x%02x)\n", __FUNCTION__, err, reg, data);280280+ return -EREMOTEIO;281281+ }282282+283283+ /* cache the write, no way to read back */284284+ state->lnbreg = data;285285+286286+ return 0;287287+}288288+289289+static int cx24123_readreg(struct cx24123_state* state, u8 reg)290290+{291291+ int ret;292292+ u8 b0[] = { reg };293293+ u8 b1[] = { 0 };294294+ struct i2c_msg msg[] = {295295+ { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },296296+ { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 }297297+ };298298+299299+ ret = i2c_transfer(state->i2c, msg, 2);300300+301301+ if (ret != 2) {302302+ printk("%s: reg=0x%x (error=%d)\n", __FUNCTION__, reg, ret);303303+ return ret;304304+ }305305+306306+ return b1[0];307307+}308308+309309+static int cx24123_readlnbreg(struct cx24123_state* state, u8 reg)310310+{311311+ return state->lnbreg;312312+}313313+314314+static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion)315315+{316316+ switch (inversion) {317317+ case INVERSION_OFF:318318+ cx24123_writereg(state, 0x0e, cx24123_readreg(state, 0x0e) & 0x7f);319319+ cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) | 0x80);320320+ break;321321+ case INVERSION_ON:322322+ cx24123_writereg(state, 0x0e, cx24123_readreg(state, 0x0e) | 0x80);323323+ cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) | 0x80);324324+ break;325325+ case INVERSION_AUTO:326326+ cx24123_writereg(state, 0x10, cx24123_readreg(state, 0x10) & 0x7f);327327+ break;328328+ default:329329+ return -EINVAL;330330+ }331331+332332+ return 0;333333+}334334+335335+static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion)336336+{337337+ u8 val;338338+339339+ val = cx24123_readreg(state, 0x1b) >> 7;340340+341341+ if (val == 0)342342+ *inversion = INVERSION_OFF;343343+ else344344+ *inversion = INVERSION_ON;345345+346346+ return 0;347347+}348348+349349+static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec)350350+{351351+ if ( (fec < FEC_NONE) || (fec > FEC_AUTO) )352352+ fec = FEC_AUTO;353353+354354+ /* Hardware has 5/11 and 3/5 but are never unused */355355+ switch (fec) {356356+ case FEC_NONE:357357+ return cx24123_writereg(state, 0x0f, 0x01);358358+ case FEC_1_2:359359+ return cx24123_writereg(state, 0x0f, 0x02);360360+ case FEC_2_3:361361+ return cx24123_writereg(state, 0x0f, 0x04);362362+ case FEC_3_4:363363+ return cx24123_writereg(state, 0x0f, 0x08);364364+ case FEC_5_6:365365+ return cx24123_writereg(state, 0x0f, 0x20);366366+ case FEC_7_8:367367+ return cx24123_writereg(state, 0x0f, 0x80);368368+ case FEC_AUTO:369369+ return cx24123_writereg(state, 0x0f, 0xae);370370+ default:371371+ return -EOPNOTSUPP;372372+ }373373+}374374+375375+static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec)376376+{377377+ int ret;378378+ u8 val;379379+380380+ ret = cx24123_readreg (state, 0x1b);381381+ if (ret < 0)382382+ return ret;383383+ val = ret & 0x07;384384+ switch (val) {385385+ case 1:386386+ *fec = FEC_1_2;387387+ break;388388+ case 3:389389+ *fec = FEC_2_3;390390+ break;391391+ case 4:392392+ *fec = FEC_3_4;393393+ break;394394+ case 5:395395+ *fec = FEC_4_5;396396+ break;397397+ case 6:398398+ *fec = FEC_5_6;399399+ break;400400+ case 7:401401+ *fec = FEC_7_8;402402+ break;403403+ case 2: /* *fec = FEC_3_5; break; */404404+ case 0: /* *fec = FEC_5_11; break; */405405+ *fec = FEC_AUTO;406406+ break;407407+ default:408408+ *fec = FEC_NONE; // can't happen409409+ }410410+411411+ return 0;412412+}413413+414414+/* fixme: Symbol rates < 3MSps may not work because of precision loss */415415+static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate)416416+{417417+ u32 val;418418+419419+ val = (srate / 1185) * 100;420420+421421+ /* Compensate for scaling up, by removing 17 symbols per 1Msps */422422+ val = val - (17 * (srate / 1000000));423423+424424+ cx24123_writereg(state, 0x08, (val >> 16) & 0xff );425425+ cx24123_writereg(state, 0x09, (val >> 8) & 0xff );426426+ cx24123_writereg(state, 0x0a, (val ) & 0xff );427427+428428+ return 0;429429+}430430+431431+/*432432+ * Based on the required frequency and symbolrate, the tuner AGC has to be configured433433+ * and the correct band selected. Calculate those values434434+ */435435+static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)436436+{437437+ struct cx24123_state *state = fe->demodulator_priv;438438+ u32 ndiv = 0, adiv = 0, vco_div = 0;439439+ int i = 0;440440+441441+ /* Defaults for low freq, low rate */442442+ state->VCAarg = cx24123_AGC_vals[0].VCAprogdata;443443+ state->VGAarg = cx24123_AGC_vals[0].VGAprogdata;444444+ state->bandselectarg = cx24123_bandselect_vals[0].progdata;445445+ vco_div = cx24123_bandselect_vals[0].VCOdivider;446446+447447+ /* For the given symbolerate, determine the VCA and VGA programming bits */448448+ for (i = 0; i < sizeof(cx24123_AGC_vals) / sizeof(cx24123_AGC_vals[0]); i++)449449+ {450450+ if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) &&451451+ (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) {452452+ state->VCAarg = cx24123_AGC_vals[i].VCAprogdata;453453+ state->VGAarg = cx24123_AGC_vals[i].VGAprogdata;454454+ }455455+ }456456+457457+ /* For the given frequency, determine the bandselect programming bits */458458+ for (i = 0; i < sizeof(cx24123_bandselect_vals) / sizeof(cx24123_bandselect_vals[0]); i++)459459+ {460460+ if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) &&461461+ (cx24123_bandselect_vals[i].freq_high >= p->frequency) ) {462462+ state->bandselectarg = cx24123_bandselect_vals[i].progdata;463463+ vco_div = cx24123_bandselect_vals[i].VCOdivider;464464+ }465465+ }466466+467467+ /* Determine the N/A dividers for the requested lband freq (in kHz). */468468+ /* Note: 10111 (kHz) is the Crystal Freq and divider of 10. */469469+ ndiv = ( ((p->frequency * vco_div) / (10111 / 10) / 2) / 32) & 0x1ff;470470+ adiv = ( ((p->frequency * vco_div) / (10111 / 10) / 2) % 32) & 0x1f;471471+472472+ if (adiv == 0)473473+ adiv++;474474+475475+ /* determine the correct pll frequency values. */476476+ /* Command 11, refdiv 11, cpump polarity 1, cpump current 3mA 10. */477477+ state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (2 << 14);478478+ state->pllarg |= (ndiv << 5) | adiv;479479+480480+ return 0;481481+}482482+483483+/*484484+ * Tuner data is 21 bits long, must be left-aligned in data.485485+ * Tuner cx24109 is written through a dedicated 3wire interface on the demod chip.486486+ */487487+static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data)488488+{489489+ struct cx24123_state *state = fe->demodulator_priv;490490+ unsigned long timeout;491491+492492+ /* align the 21 bytes into to bit23 boundary */493493+ data = data << 3;494494+495495+ /* Reset the demod pll word length to 0x15 bits */496496+ cx24123_writereg(state, 0x21, 0x15);497497+498498+ /* write the msb 8 bits, wait for the send to be completed */499499+ timeout = jiffies + msecs_to_jiffies(40);500500+ cx24123_writereg(state, 0x22, (data >> 16) & 0xff);501501+ while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {502502+ if (time_after(jiffies, timeout)) {503503+ printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);504504+ return -EREMOTEIO;505505+ }506506+ msleep(10);507507+ }508508+509509+ /* send another 8 bytes, wait for the send to be completed */510510+ timeout = jiffies + msecs_to_jiffies(40);511511+ cx24123_writereg(state, 0x22, (data>>8) & 0xff );512512+ while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {513513+ if (time_after(jiffies, timeout)) {514514+ printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);515515+ return -EREMOTEIO;516516+ }517517+ msleep(10);518518+ }519519+520520+ /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */521521+ timeout = jiffies + msecs_to_jiffies(40);522522+ cx24123_writereg(state, 0x22, (data) & 0xff );523523+ while ((cx24123_readreg(state, 0x20) & 0x80)) {524524+ if (time_after(jiffies, timeout)) {525525+ printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);526526+ return -EREMOTEIO;527527+ }528528+ msleep(10);529529+ }530530+531531+ /* Trigger the demod to configure the tuner */532532+ cx24123_writereg(state, 0x20, cx24123_readreg(state, 0x20) | 2);533533+ cx24123_writereg(state, 0x20, cx24123_readreg(state, 0x20) & 0xfd);534534+535535+ return 0;536536+}537537+538538+static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)539539+{540540+ struct cx24123_state *state = fe->demodulator_priv;541541+542542+ if (cx24123_pll_calculate(fe, p) != 0) {543543+ printk("%s: cx24123_pll_calcutate failed\n",__FUNCTION__);544544+ return -EINVAL;545545+ }546546+547547+ /* Write the new VCO/VGA */548548+ cx24123_pll_writereg(fe, p, state->VCAarg);549549+ cx24123_pll_writereg(fe, p, state->VGAarg);550550+551551+ /* Write the new bandselect and pll args */552552+ cx24123_pll_writereg(fe, p, state->bandselectarg);553553+ cx24123_pll_writereg(fe, p, state->pllarg);554554+555555+ return 0;556556+}557557+558558+static int cx24123_initfe(struct dvb_frontend* fe)559559+{560560+ struct cx24123_state *state = fe->demodulator_priv;561561+ int i;562562+563563+ /* Configure the demod to a good set of defaults */564564+ for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++)565565+ cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data);566566+567567+ if (state->config->pll_init)568568+ state->config->pll_init(fe);569569+570570+ /* Configure the LNB for 14V */571571+ if (state->config->use_isl6421)572572+ cx24123_writelnbreg(state, 0x0, 0x2a);573573+574574+ return 0;575575+}576576+577577+static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)578578+{579579+ struct cx24123_state *state = fe->demodulator_priv;580580+ u8 val;581581+582582+ switch (state->config->use_isl6421) {583583+584584+ case 1:585585+586586+ val = cx24123_readlnbreg(state, 0x0);587587+588588+ switch (voltage) {589589+ case SEC_VOLTAGE_13:590590+ return cx24123_writelnbreg(state, 0x0, val & 0x32); /* V 13v */591591+ case SEC_VOLTAGE_18:592592+ return cx24123_writelnbreg(state, 0x0, val | 0x04); /* H 18v */593593+ case SEC_VOLTAGE_OFF:594594+ return cx24123_writelnbreg(state, 0x0, val & 0x30);595595+ default:596596+ return -EINVAL;597597+ };598598+599599+ case 0:600600+601601+ val = cx24123_readreg(state, 0x29);602602+603603+ switch (voltage) {604604+ case SEC_VOLTAGE_13:605605+ dprintk("%s: setting voltage 13V\n", __FUNCTION__);606606+ if (state->config->enable_lnb_voltage)607607+ state->config->enable_lnb_voltage(fe, 1);608608+ return cx24123_writereg(state, 0x29, val | 0x80);609609+ case SEC_VOLTAGE_18:610610+ dprintk("%s: setting voltage 18V\n", __FUNCTION__);611611+ if (state->config->enable_lnb_voltage)612612+ state->config->enable_lnb_voltage(fe, 1);613613+ return cx24123_writereg(state, 0x29, val & 0x7f);614614+ case SEC_VOLTAGE_OFF:615615+ dprintk("%s: setting voltage off\n", __FUNCTION__);616616+ if (state->config->enable_lnb_voltage)617617+ state->config->enable_lnb_voltage(fe, 0);618618+ return 0;619619+ default:620620+ return -EINVAL;621621+ };622622+ }623623+624624+ return 0;625625+}626626+627627+static int cx24123_send_diseqc_msg(struct dvb_frontend* fe,628628+ struct dvb_diseqc_master_cmd *cmd)629629+{630630+ /* fixme: Implement diseqc */631631+ printk("%s: No support yet\n",__FUNCTION__);632632+633633+ return -ENOTSUPP;634634+}635635+636636+static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status)637637+{638638+ struct cx24123_state *state = fe->demodulator_priv;639639+640640+ int sync = cx24123_readreg(state, 0x14);641641+ int lock = cx24123_readreg(state, 0x20);642642+643643+ *status = 0;644644+ if (lock & 0x01)645645+ *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL;646646+ if (sync & 0x04)647647+ *status |= FE_HAS_VITERBI;648648+ if (sync & 0x08)649649+ *status |= FE_HAS_CARRIER;650650+ if (sync & 0x80)651651+ *status |= FE_HAS_SYNC | FE_HAS_LOCK;652652+653653+ return 0;654654+}655655+656656+/*657657+ * Configured to return the measurement of errors in blocks, because no UCBLOCKS value658658+ * is available, so this value doubles up to satisfy both measurements659659+ */660660+static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber)661661+{662662+ struct cx24123_state *state = fe->demodulator_priv;663663+664664+ state->lastber =665665+ ((cx24123_readreg(state, 0x1c) & 0x3f) << 16) |666666+ (cx24123_readreg(state, 0x1d) << 8 |667667+ cx24123_readreg(state, 0x1e));668668+669669+ /* Do the signal quality processing here, it's derived from the BER. */670670+ /* Scale the BER from a 24bit to a SNR 16 bit where higher = better */671671+ if (state->lastber < 5000)672672+ state->snr = 655*100;673673+ else if ( (state->lastber >= 5000) && (state->lastber < 55000) )674674+ state->snr = 655*90;675675+ else if ( (state->lastber >= 55000) && (state->lastber < 150000) )676676+ state->snr = 655*80;677677+ else if ( (state->lastber >= 150000) && (state->lastber < 250000) )678678+ state->snr = 655*70;679679+ else if ( (state->lastber >= 250000) && (state->lastber < 450000) )680680+ state->snr = 655*65;681681+ else682682+ state->snr = 0;683683+684684+ *ber = state->lastber;685685+686686+ return 0;687687+}688688+689689+static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)690690+{691691+ struct cx24123_state *state = fe->demodulator_priv;692692+ *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */693693+694694+ return 0;695695+}696696+697697+static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr)698698+{699699+ struct cx24123_state *state = fe->demodulator_priv;700700+ *snr = state->snr;701701+702702+ return 0;703703+}704704+705705+static int cx24123_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)706706+{707707+ struct cx24123_state *state = fe->demodulator_priv;708708+ *ucblocks = state->lastber;709709+710710+ return 0;711711+}712712+713713+static int cx24123_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)714714+{715715+ struct cx24123_state *state = fe->demodulator_priv;716716+717717+ if (state->config->set_ts_params)718718+ state->config->set_ts_params(fe, 0);719719+720720+ state->currentfreq=p->frequency;721721+ state->currentsymbolrate = p->u.qpsk.symbol_rate;722722+723723+ cx24123_set_inversion(state, p->inversion);724724+ cx24123_set_fec(state, p->u.qpsk.fec_inner);725725+ cx24123_set_symbolrate(state, p->u.qpsk.symbol_rate);726726+ cx24123_pll_tune(fe, p);727727+728728+ /* Enable automatic aquisition and reset cycle */729729+ cx24123_writereg(state, 0x03, (cx24123_readreg(state, 0x03) | 0x07));730730+ cx24123_writereg(state, 0x00, 0x10);731731+ cx24123_writereg(state, 0x00, 0);732732+733733+ return 0;734734+}735735+736736+static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)737737+{738738+ struct cx24123_state *state = fe->demodulator_priv;739739+740740+ if (cx24123_get_inversion(state, &p->inversion) != 0) {741741+ printk("%s: Failed to get inversion status\n",__FUNCTION__);742742+ return -EREMOTEIO;743743+ }744744+ if (cx24123_get_fec(state, &p->u.qpsk.fec_inner) != 0) {745745+ printk("%s: Failed to get fec status\n",__FUNCTION__);746746+ return -EREMOTEIO;747747+ }748748+ p->frequency = state->currentfreq;749749+ p->u.qpsk.symbol_rate = state->currentsymbolrate;750750+751751+ return 0;752752+}753753+754754+static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)755755+{756756+ struct cx24123_state *state = fe->demodulator_priv;757757+ u8 val;758758+759759+ switch (state->config->use_isl6421) {760760+ case 1:761761+762762+ val = cx24123_readlnbreg(state, 0x0);763763+764764+ switch (tone) {765765+ case SEC_TONE_ON:766766+ return cx24123_writelnbreg(state, 0x0, val | 0x10);767767+ case SEC_TONE_OFF:768768+ return cx24123_writelnbreg(state, 0x0, val & 0x2f);769769+ default:770770+ printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone);771771+ return -EINVAL;772772+ }773773+774774+ case 0:775775+776776+ val = cx24123_readreg(state, 0x29);777777+778778+ switch (tone) {779779+ case SEC_TONE_ON:780780+ dprintk("%s: setting tone on\n", __FUNCTION__);781781+ return cx24123_writereg(state, 0x29, val | 0x10);782782+ case SEC_TONE_OFF:783783+ dprintk("%s: setting tone off\n",__FUNCTION__);784784+ return cx24123_writereg(state, 0x29, val & 0xef);785785+ default:786786+ printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone);787787+ return -EINVAL;788788+ }789789+ }790790+791791+ return 0;792792+}793793+794794+static void cx24123_release(struct dvb_frontend* fe)795795+{796796+ struct cx24123_state* state = fe->demodulator_priv;797797+ dprintk("%s\n",__FUNCTION__);798798+ kfree(state);799799+}800800+801801+static struct dvb_frontend_ops cx24123_ops;802802+803803+struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,804804+ struct i2c_adapter* i2c)805805+{806806+ struct cx24123_state* state = NULL;807807+ int ret;808808+809809+ dprintk("%s\n",__FUNCTION__);810810+811811+ /* allocate memory for the internal state */812812+ state = kmalloc(sizeof(struct cx24123_state), GFP_KERNEL);813813+ if (state == NULL) {814814+ printk("Unable to kmalloc\n");815815+ goto error;816816+ }817817+818818+ /* setup the state */819819+ state->config = config;820820+ state->i2c = i2c;821821+ memcpy(&state->ops, &cx24123_ops, sizeof(struct dvb_frontend_ops));822822+ state->lastber = 0;823823+ state->snr = 0;824824+ state->lnbreg = 0;825825+ state->VCAarg = 0;826826+ state->VGAarg = 0;827827+ state->bandselectarg = 0;828828+ state->pllarg = 0;829829+ state->currentfreq = 0;830830+ state->currentsymbolrate = 0;831831+832832+ /* check if the demod is there */833833+ ret = cx24123_readreg(state, 0x00);834834+ if ((ret != 0xd1) && (ret != 0xe1)) {835835+ printk("Version != d1 or e1\n");836836+ goto error;837837+ }838838+839839+ /* create dvb_frontend */840840+ state->frontend.ops = &state->ops;841841+ state->frontend.demodulator_priv = state;842842+ return &state->frontend;843843+844844+error:845845+ kfree(state);846846+847847+ return NULL;848848+}849849+850850+static struct dvb_frontend_ops cx24123_ops = {851851+852852+ .info = {853853+ .name = "Conexant CX24123/CX24109",854854+ .type = FE_QPSK,855855+ .frequency_min = 950000,856856+ .frequency_max = 2150000,857857+ .frequency_stepsize = 1011, /* kHz for QPSK frontends */858858+ .frequency_tolerance = 29500,859859+ .symbol_rate_min = 1000000,860860+ .symbol_rate_max = 45000000,861861+ .caps = FE_CAN_INVERSION_AUTO |862862+ FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |863863+ FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |864864+ FE_CAN_QPSK | FE_CAN_RECOVER865865+ },866866+867867+ .release = cx24123_release,868868+869869+ .init = cx24123_initfe,870870+ .set_frontend = cx24123_set_frontend,871871+ .get_frontend = cx24123_get_frontend,872872+ .read_status = cx24123_read_status,873873+ .read_ber = cx24123_read_ber,874874+ .read_signal_strength = cx24123_read_signal_strength,875875+ .read_snr = cx24123_read_snr,876876+ .read_ucblocks = cx24123_read_ucblocks,877877+ .diseqc_send_master_cmd = cx24123_send_diseqc_msg,878878+ .set_tone = cx24123_set_tone,879879+ .set_voltage = cx24123_set_voltage,880880+};881881+882882+module_param(debug, int, 0644);883883+MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");884884+885885+MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24123/cx24109 hardware");886886+MODULE_AUTHOR("Steven Toth");887887+MODULE_LICENSE("GPL");888888+889889+EXPORT_SYMBOL(cx24123_attach);
+51
drivers/media/dvb/frontends/cx24123.h
···11+/*22+ Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver33+44+ Copyright (C) 2005 Steven Toth <stoth@hauppauge.com>55+66+ This program is free software; you can redistribute it and/or modify77+ it under the terms of the GNU General Public License as published by88+ the Free Software Foundation; either version 2 of the License, or99+ (at your option) any later version.1010+1111+ This program is distributed in the hope that it will be useful,1212+ but WITHOUT ANY WARRANTY; without even the implied warranty of1313+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1414+ GNU General Public License for more details.1515+1616+ You should have received a copy of the GNU General Public License1717+ along with this program; if not, write to the Free Software1818+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.1919+*/2020+2121+#ifndef CX24123_H2222+#define CX24123_H2323+2424+#include <linux/dvb/frontend.h>2525+2626+struct cx24123_config2727+{2828+ /* the demodulator's i2c address */2929+ u8 demod_address;3030+3131+ /*3232+ cards like Hauppauge Nova-S Plus/Nova-SE2 use an Intersil ISL6421 chip3333+ for LNB control, while KWorld DVB-S 100 use the LNBDC and LNBTone bits3434+ from register 0x29 of the CX24123 demodulator3535+ */3636+ int use_isl6421;3737+3838+ /* PLL maintenance */3939+ int (*pll_init)(struct dvb_frontend* fe);4040+ int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);4141+4242+ /* Need to set device param for start_dma */4343+ int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);4444+4545+ void (*enable_lnb_voltage)(struct dvb_frontend* fe, int on);4646+};4747+4848+extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,4949+ struct i2c_adapter* i2c);5050+5151+#endif /* CX24123_H */
···2727 * DViCO FusionHDTV 3 Gold-T2828 * DViCO FusionHDTV 5 Gold2929 * DViCO FusionHDTV 5 Lite3030+ * DViCO FusionHDTV 5 USB Gold3031 * Air2PC/AirStar 2 ATSC 3rd generation (HD5000)3132 *3233 * TODO:···403402 state->config->pll_set(fe, param);404403405404 /* Keep track of the new frequency */405405+ /* FIXME this is the wrong way to do this... */406406+ /* The tuner is shared with the video4linux analog API */406407 state->current_frequency = param->frequency;407408408409 lgdt330x_SwReset(state);
+2-1
drivers/media/dvb/frontends/nxt2002.c
···2222/*2323 * This driver needs external firmware. Please use the command2424 * "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" to2525- * download/extract it, and then copy it to /usr/lib/hotplug/firmware.2525+ * download/extract it, and then copy it to /usr/lib/hotplug/firmware2626+ * or /lib/firmware (depending on configuration of firmware hotplug).2627 */2728#define NXT2002_DEFAULT_FIRMWARE "dvb-fe-nxt2002.fw"2829#define CRC_CCIT_MASK 0x1021
···2525/*2626 * This driver needs external firmware. Please use the command2727 * "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to2828- * download/extract it, and then copy it to /usr/lib/hotplug/firmware.2828+ * download/extract it, and then copy it to /usr/lib/hotplug/firmware2929+ * or /lib/firmware (depending on configuration of firmware hotplug).2930 */3031#define OR51211_DEFAULT_FIRMWARE "dvb-fe-or51211.fw"3132···113112 u8 tudata[585];114113 int i;115114116116- dprintk("Firmware is %d bytes\n",fw->size);115115+ dprintk("Firmware is %zd bytes\n",fw->size);117116118117 /* Get eprom data */119118 tudata[0] = 17;
···2222/*2323 * This driver needs external firmware. Please use the command2424 * "<kerneldir>/Documentation/dvb/get_dvb_firmware alps_tdlb7" to2525- * download/extract it, and then copy it to /usr/lib/hotplug/firmware.2525+ * download/extract it, and then copy it to /usr/lib/hotplug/firmware2626+ * or /lib/firmware (depending on configuration of firmware hotplug).2627 */2728#define SP8870_DEFAULT_FIRMWARE "dvb-fe-sp8870.fw"2829
+3-2
drivers/media/dvb/frontends/sp887x.c
···55/*66 * This driver needs external firmware. Please use the command77 * "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to88- * download/extract it, and then copy it to /usr/lib/hotplug/firmware.88+ * download/extract it, and then copy it to /usr/lib/hotplug/firmware99+ * or /lib/firmware (depending on configuration of firmware hotplug).910 */1011#define SP887X_DEFAULT_FIRMWARE "dvb-fe-sp887x.fw"1112···582581 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |583582 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |584583 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |585585- FE_CAN_RECOVER584584+ FE_CAN_RECOVER586585 },587586588587 .release = sp887x_release,
+10-2
drivers/media/dvb/frontends/stv0299.c
···131131 return ret == 2 ? 0 : ret;132132}133133134134+int stv0299_enable_plli2c (struct dvb_frontend* fe)135135+{136136+ struct stv0299_state* state = fe->demodulator_priv;137137+138138+ return stv0299_writeregI(state, 0x05, 0xb5); /* enable i2c repeater on stv0299 */139139+}140140+134141static int stv0299_set_FEC (struct stv0299_state* state, fe_code_rate_t fec)135142{136143 dprintk ("%s\n", __FUNCTION__);···394387 };395388}396389397397-static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, u32 cmd)390390+static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long cmd)398391{399392 struct stv0299_state* state = fe->demodulator_priv;400393 u8 reg0x08;···414407415408 cmd = cmd << 1;416409 if (debug_legacy_dish_switch)417417- printk ("%s switch command: 0x%04x\n",__FUNCTION__, cmd);410410+ printk ("%s switch command: 0x%04lx\n",__FUNCTION__, cmd);418411419412 do_gettimeofday (&nexttime);420413 if (debug_legacy_dish_switch)···724717 "Andreas Oberritter, Andrew de Quincey, Kenneth Aafl�y");725718MODULE_LICENSE("GPL");726719720720+EXPORT_SYMBOL(stv0299_enable_plli2c);727721EXPORT_SYMBOL(stv0299_writereg);728722EXPORT_SYMBOL(stv0299_attach);
···2323 * This driver needs external firmware. Please use the commands2424 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",2525 * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to2626- * download/extract them, and then copy them to /usr/lib/hotplug/firmware.2626+ * download/extract them, and then copy them to /usr/lib/hotplug/firmware2727+ * or /lib/firmware (depending on configuration of firmware hotplug).2728 */2829#define TDA10045_DEFAULT_FIRMWARE "dvb-fe-tda10045.fw"2930#define TDA10046_DEFAULT_FIRMWARE "dvb-fe-tda10046.fw"···272271static int tda10046h_set_bandwidth(struct tda1004x_state *state,273272 fe_bandwidth_t bandwidth)274273{275275- static u8 bandwidth_6mhz[] = { 0x80, 0x15, 0xfe, 0xab, 0x8e };276276- static u8 bandwidth_7mhz[] = { 0x6e, 0x02, 0x53, 0xc8, 0x25 };277277- static u8 bandwidth_8mhz[] = { 0x60, 0x12, 0xa8, 0xe4, 0xbd };274274+ static u8 bandwidth_6mhz_53M[] = { 0x7b, 0x2e, 0x11, 0xf0, 0xd2 };275275+ static u8 bandwidth_7mhz_53M[] = { 0x6a, 0x02, 0x6a, 0x43, 0x9f };276276+ static u8 bandwidth_8mhz_53M[] = { 0x5c, 0x32, 0xc2, 0x96, 0x6d };278277278278+ static u8 bandwidth_6mhz_48M[] = { 0x70, 0x02, 0x49, 0x24, 0x92 };279279+ static u8 bandwidth_7mhz_48M[] = { 0x60, 0x02, 0xaa, 0xaa, 0xab };280280+ static u8 bandwidth_8mhz_48M[] = { 0x54, 0x03, 0x0c, 0x30, 0xc3 };281281+ int tda10046_clk53m;282282+283283+ if ((state->config->if_freq == TDA10046_FREQ_045) ||284284+ (state->config->if_freq == TDA10046_FREQ_052))285285+ tda10046_clk53m = 0;286286+ else287287+ tda10046_clk53m = 1;279288 switch (bandwidth) {280289 case BANDWIDTH_6_MHZ:281281- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz, sizeof(bandwidth_6mhz));290290+ if (tda10046_clk53m)291291+ tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz_53M,292292+ sizeof(bandwidth_6mhz_53M));293293+ else294294+ tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz_48M,295295+ sizeof(bandwidth_6mhz_48M));282296 if (state->config->if_freq == TDA10046_FREQ_045) {283283- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x09);284284- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x4f);297297+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0a);298298+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xab);285299 }286300 break;287301288302 case BANDWIDTH_7_MHZ:289289- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz, sizeof(bandwidth_7mhz));303303+ if (tda10046_clk53m)304304+ tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz_53M,305305+ sizeof(bandwidth_7mhz_53M));306306+ else307307+ tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz_48M,308308+ sizeof(bandwidth_7mhz_48M));290309 if (state->config->if_freq == TDA10046_FREQ_045) {291291- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0a);292292- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x79);310310+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);311311+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x00);293312 }294313 break;295314296315 case BANDWIDTH_8_MHZ:297297- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz, sizeof(bandwidth_8mhz));316316+ if (tda10046_clk53m)317317+ tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz_53M,318318+ sizeof(bandwidth_8mhz_53M));319319+ else320320+ tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz_48M,321321+ sizeof(bandwidth_8mhz_48M));298322 if (state->config->if_freq == TDA10046_FREQ_045) {299299- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b);300300- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3);323323+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0d);324324+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x55);301325 }302326 break;303327···444418static void tda10046_init_plls(struct dvb_frontend* fe)445419{446420 struct tda1004x_state* state = fe->demodulator_priv;421421+ int tda10046_clk53m;422422+423423+ if ((state->config->if_freq == TDA10046_FREQ_045) ||424424+ (state->config->if_freq == TDA10046_FREQ_052))425425+ tda10046_clk53m = 0;426426+ else427427+ tda10046_clk53m = 1;447428448429 tda1004x_write_byteI(state, TDA10046H_CONFPLL1, 0xf0);449449- tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x0a); // PLL M = 10430430+ if(tda10046_clk53m) {431431+ printk(KERN_INFO "tda1004x: setting up plls for 53MHz sampling clock\n");432432+ tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x08); // PLL M = 8433433+ } else {434434+ printk(KERN_INFO "tda1004x: setting up plls for 48MHz sampling clock\n");435435+ tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x03); // PLL M = 3436436+ }450437 if (state->config->xtal_freq == TDA10046_XTAL_4M ) {451438 dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __FUNCTION__);452439 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0···467428 dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __FUNCTION__);468429 tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 3); // PLL P = 0, N = 3469430 }470470- tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99);431431+ if(tda10046_clk53m)432432+ tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 0x67);433433+ else434434+ tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 0x72);435435+ /* Note clock frequency is handled implicitly */471436 switch (state->config->if_freq) {472472- case TDA10046_FREQ_3617:473473- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);474474- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c);475475- break;476476- case TDA10046_FREQ_3613:477477- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);478478- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x13);479479- break;480437 case TDA10046_FREQ_045:481481- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b);482482- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3);438438+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);439439+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x00);483440 break;484441 case TDA10046_FREQ_052:485485- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);486486- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x06);442442+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0d);443443+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xc7);444444+ break;445445+ case TDA10046_FREQ_3617:446446+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd7);447447+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x59);448448+ break;449449+ case TDA10046_FREQ_3613:450450+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd7);451451+ tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x3f);487452 break;488453 }489454 tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz455455+ /* let the PLLs settle */456456+ msleep(120);490457}491458492459static int tda10046_fwupload(struct dvb_frontend* fe)···507462 /* let the clocks recover from sleep */508463 msleep(5);509464465465+ /* The PLLs need to be reprogrammed after sleep */466466+ tda10046_init_plls(fe);467467+510468 /* don't re-upload unless necessary */511469 if (tda1004x_check_upload_ok(state) == 0)512470 return 0;513513-514514- /* set parameters */515515- tda10046_init_plls(fe);516471517472 if (state->config->request_firmware != NULL) {518473 /* request the firmware, this will block until someone uploads it */···529484 return ret;530485 } else {531486 /* boot from firmware eeprom */532532- /* Hac Note: we might need to do some GPIO Magic here */533487 printk(KERN_INFO "tda1004x: booting from eeprom\n");534488 tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4);535489 msleep(300);···650606651607 // tda setup652608 tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer653653- tda1004x_write_byteI(state, TDA1004X_AUTO, 7); // select HP stream654654- tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer609609+ tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87); // 100 ppm crystal, select HP stream610610+ tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer655611656656- tda10046_init_plls(fe);657612 switch (state->config->agc_config) {658613 case TDA10046_AGC_DEFAULT:659614 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x00); // AGC setup···669626 case TDA10046_AGC_TDA827X:670627 tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup671628 tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold672672- tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x0E); // Gain Renormalize673673- tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities629629+ tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize630630+ tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x6a); // set AGC polarities674631 break;675632 }633633+ tda1004x_write_byteI(state, TDA1004X_CONFADC2, 0x38);676634 tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on677635 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // }678636 tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values679637 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // }680638 tda1004x_write_byteI(state, TDA10046H_AGC_IF_MAX, 0xff); // }681681- tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 1); // IF gain 2, TUN gain 1639639+ tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 0x12); // IF gain 2, TUN gain 1682640 tda1004x_write_byteI(state, TDA10046H_CVBER_CTRL, 0x1a); // 10^6 VBER measurement bits683641 tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config684642 tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0xc0); // MPEG2 interface config685643 tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7);686686-687687- tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE2, 0xe1); // tristate setup688688- tda1004x_write_byteI(state, TDA10046H_GPIO_OUT_SEL, 0xcc); // GPIO output config689689- tda1004x_write_byteI(state, TDA10046H_GPIO_SELECT, 8); // GPIO select690644691645 state->initialised = 1;692646 return 0;···726686727687 // Set standard params.. or put them to auto728688 if ((fe_params->u.ofdm.code_rate_HP == FEC_AUTO) ||729729- (fe_params->u.ofdm.code_rate_LP == FEC_AUTO) ||730730- (fe_params->u.ofdm.constellation == QAM_AUTO) ||731731- (fe_params->u.ofdm.hierarchy_information == HIERARCHY_AUTO)) {689689+ (fe_params->u.ofdm.code_rate_LP == FEC_AUTO) ||690690+ (fe_params->u.ofdm.constellation == QAM_AUTO) ||691691+ (fe_params->u.ofdm.hierarchy_information == HIERARCHY_AUTO)) {732692 tda1004x_write_mask(state, TDA1004X_AUTO, 1, 1); // enable auto733693 tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x03, 0); // turn off constellation bits734694 tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 0); // turn off hierarchy bits···891851static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_parameters *fe_params)892852{893853 struct tda1004x_state* state = fe->demodulator_priv;854854+894855 dprintk("%s\n", __FUNCTION__);895856896857 // inversion status···916875 break;917876 }918877 break;919919-920878 case TDA1004X_DEMOD_TDA10046:921879 switch (tda1004x_read_byte(state, TDA10046H_TIME_WREF1)) {922922- case 0x60:880880+ case 0x5c:881881+ case 0x54:923882 fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;924883 break;925925- case 0x6e:884884+ case 0x6a:885885+ case 0x60:926886 fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;927887 break;928928- case 0x80:888888+ case 0x7b:889889+ case 0x70:929890 fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;930891 break;931892 }
+1-1
drivers/media/dvb/pluto2/Kconfig
···88 Support for PCI cards based on the Pluto2 FPGA like the Satelco99 Easywatch Mobile Terrestrial DVB-T Receiver.10101111- Since these cards have no MPEG decoder onboard, they transmit1111+ Since these cards have no MPEG decoder onboard, they transmit1212 only compressed MPEG data over the PCI bus, so you need1313 an external software decoder to watch TV on your computer.1414
+4-3
drivers/media/dvb/ttpci/Kconfig
···1818 This driver only supports the fullfeatured cards with1919 onboard MPEG2 decoder.20202121- This driver needs an external firmware. Please use the script2222- "<kerneldir>/Documentation/dvb/get_dvb_firmware av7110" to2323- download/extract it, and then copy it to /usr/lib/hotplug/firmware.2121+ This driver needs an external firmware. Please use the script2222+ "<kerneldir>/Documentation/dvb/get_dvb_firmware av7110" to2323+ download/extract it, and then copy it to /usr/lib/hotplug/firmware2424+ or /lib/firmware (depending on configuration of firmware hotplug).24252526 Say Y if you own such a card and want to use it.2627
···404404 tasklet_init(&budget->vpe_tasklet, vpeirq, (unsigned long) budget);405405406406 /* frontend power on */407407- if (bi->type == BUDGET_FS_ACTIVY)408408- saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI);409409- else407407+ if (bi->type != BUDGET_FS_ACTIVY)410408 saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);411409412410 if (budget_register(budget) == 0) {
+10-3
drivers/media/dvb/ttpci/budget.c
···112112 * Routines for the Fujitsu Siemens Activy budget card113113 * 22 kHz tone and DiSEqC are handled by the frontend.114114 * Voltage must be set here.115115+ * GPIO 1: LNBP EN, GPIO 2: LNBP VSEL115116 */116117static int SetVoltage_Activy (struct budget *budget, fe_sec_voltage_t voltage)117118{···122121123122 switch (voltage) {124123 case SEC_VOLTAGE_13:124124+ saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI);125125 saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTLO);126126 break;127127 case SEC_VOLTAGE_18:128128+ saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI);128129 saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);130130+ break;131131+ case SEC_VOLTAGE_OFF:132132+ saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTLO);129133 break;130134 default:131135 return -EINVAL;···212206 return 0;213207}214208215215-static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend* fe, int arg)209209+static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend* fe, long arg)216210{217211 struct budget* budget = (struct budget*) fe->dvb->priv;218212 u8 buf;···586580 if (budget->dvb_frontend) {587581 budget->dvb_frontend->ops->set_voltage = lnbp21_set_voltage;588582 budget->dvb_frontend->ops->enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;583583+ budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL;589584 if (lnbp21_init(budget)) {590585 printk("%s: No LNBP21 found!\n", __FUNCTION__);591586 goto error_out;···631624 budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap);632625 if (budget->dvb_frontend) {633626 budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage;634634- break;627627+ budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL;635628 }636629 break;637630···639632 budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap);640633 if (budget->dvb_frontend) {641634 budget->dvb_frontend->ops->set_voltage = siemens_budget_set_voltage;642642- break;635635+ budget->dvb_frontend->ops->dishnetwork_send_legacy_command = NULL;643636 }644637 break;645638
+1-1
drivers/media/dvb/ttpci/ttpci-eeprom.c
···1313 Holger Waechtler Convergence14141515 Copyright (C) 2002-2003 Ralph Metzler <rjkm@metzlerbros.de>1616- Metzler Brothers Systementwicklung GbR1616+ Metzler Brothers Systementwicklung GbR17171818 This program is free software; you can redistribute it and/or modify1919 it under the terms of the GNU General Public License as published by
+1-1
drivers/media/dvb/ttusb-budget/Kconfig
···1010 Support for external USB adapters designed by Technotrend and1111 produced by Hauppauge, shipped under the brand name 'Nova-USB'.12121313- These devices don't have a MPEG decoder built in, so you need1313+ These devices don't have a MPEG decoder built in, so you need1414 an external software decoder to watch TV.15151616 Say Y if you own such a device and want to use it.
+7-6
drivers/media/dvb/ttusb-dec/Kconfig
···88 produced by Hauppauge, shipped under the brand name 'DEC2000-t'99 and 'DEC3000-s'.10101111- Even if these devices have a MPEG decoder built in, they transmit1111+ Even if these devices have a MPEG decoder built in, they transmit1212 only compressed MPEG data over the USB bus, so you need1313 an external software decoder to watch TV on your computer.14141515- This driver needs external firmware. Please use the commands1616- "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2000t",1717- "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2540t",1818- "<kerneldir>/Documentation/dvb/get_dvb_firmware dec3000s",1919- download/extract them, and then copy them to /usr/lib/hotplug/firmware.1515+ This driver needs external firmware. Please use the commands1616+ "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2000t",1717+ "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2540t",1818+ "<kerneldir>/Documentation/dvb/get_dvb_firmware dec3000s",1919+ download/extract them, and then copy them to /usr/lib/hotplug/firmware2020+ or /lib/firmware (depending on configuration of firmware hotplug).20212122 Say Y if you own such a device and want to use it.
+10-10
drivers/media/dvb/ttusb-dec/ttusb_dec.c
···369369370370static int ttusb_dec_audio_pes2ts_cb(void *priv, unsigned char *data)371371{372372- struct ttusb_dec *dec = (struct ttusb_dec *)priv;372372+ struct ttusb_dec *dec = priv;373373374374 dec->audio_filter->feed->cb.ts(data, 188, NULL, 0,375375 &dec->audio_filter->feed->feed.ts,···380380381381static int ttusb_dec_video_pes2ts_cb(void *priv, unsigned char *data)382382{383383- struct ttusb_dec *dec = (struct ttusb_dec *)priv;383383+ struct ttusb_dec *dec = priv;384384385385 dec->video_filter->feed->cb.ts(data, 188, NULL, 0,386386 &dec->video_filter->feed->feed.ts,···965965966966 case DMX_TS_PES_TELETEXT:967967 dec->pid[DMX_PES_TELETEXT] = dvbdmxfeed->pid;968968- dprintk(" pes_type: DMX_TS_PES_TELETEXT\n");969969- break;968968+ dprintk(" pes_type: DMX_TS_PES_TELETEXT(not supported)\n");969969+ return -ENOSYS;970970971971 case DMX_TS_PES_PCR:972972 dprintk(" pes_type: DMX_TS_PES_PCR\n");···975975 break;976976977977 case DMX_TS_PES_OTHER:978978- dprintk(" pes_type: DMX_TS_PES_OTHER\n");979979- break;978978+ dprintk(" pes_type: DMX_TS_PES_OTHER(not supported)\n");979979+ return -ENOSYS;980980981981 default:982982 dprintk(" pes_type: unknown (%d)\n", dvbdmxfeed->pes_type);···11821182 (unsigned long)dec);11831183}1184118411851185-static int ttusb_init_rc(struct ttusb_dec *dec)11851185+static int ttusb_init_rc( struct ttusb_dec *dec)11861186{11871187 struct input_dev *input_dev;11881188 u8 b[] = { 0x00, 0x01 };···12031203 input_dev->keycode = rc_keys;1204120412051205 for (i = 0; i < ARRAY_SIZE(rc_keys); i++)12061206- set_bit(rc_keys[i], input_dev->keybit);12061206+ set_bit(rc_keys[i], input_dev->keybit);1207120712081208 input_register_device(input_dev);1209120912101210 if (usb_submit_urb(dec->irq_urb, GFP_KERNEL))12111211 printk("%s: usb_submit_urb failed\n",__FUNCTION__);12121212-12131212 /* enable irq pipe */12141213 ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL);12151214···13941395 /* We can't trust the USB IDs that some firmwares13951396 give the box */13961397 switch (model) {13981398+ case 0x00070001:13971399 case 0x00070008:13981400 case 0x0007000c:13991401 ttusb_dec_set_model(dec, TTUSB_DEC3000S);···15881588 int param_length, const u8 params[],15891589 int *result_length, u8 cmd_result[])15901590{15911591- struct ttusb_dec* dec = (struct ttusb_dec*) fe->dvb->priv;15911591+ struct ttusb_dec* dec = fe->dvb->priv;15921592 return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result);15931593}15941594
···7788comment "Video Adapters"991010+config VIDEO_ADV_DEBUG1111+ bool "Enable advanced debug functionality"1212+ depends on VIDEO_DEV1313+ default n1414+ ---help---1515+ Say Y here to enable advanced debugging functionality on some1616+ V4L devices.1717+ In doubt, say N.1818+1019config VIDEO_BT8481120 tristate "BT848 Video For Linux"1221 depends on VIDEO_DEV && PCI && I2C···351342 depends on VIDEO_DEV && I2C && EXPERIMENTAL352343 ---help---353344 Say Y here to compile drivers for SAA7115, SAA7127 and CX25840354354- video decoders.345345+ video decoders.355346356347endmenu
···16161717#include <linux/videodev.h>1818#include <linux/i2c.h>1919+#include <media/ir-common.h>2020+#include <media/ir-kbd-i2c.h>19212022/* ---------------------------------------------------------- */2123/* exported by bttv-cards.c */···165163#define BTTV_BOARD_OSPREY440 0x8c166164#define BTTV_BOARD_ASOUND_SKYEYE 0x8d167165#define BTTV_BOARD_SABRENT_TVFM 0x8e166166+#define BTTV_BOARD_HAUPPAUGE_IMPACTVCB 0x8f168167169168/* i2c address list */170169#define I2C_TSA5522 0xc2···213210214211struct bttv;215212213213+214214+struct bttv_ir {215215+ struct input_dev *dev;216216+ struct ir_input_state ir;217217+ char name[32];218218+ char phys[32];219219+220220+ /* Usual gpio signalling */221221+222222+ u32 mask_keycode;223223+ u32 mask_keydown;224224+ u32 mask_keyup;225225+ u32 polling;226226+ u32 last_gpio;227227+ struct work_struct work;228228+ struct timer_list timer;229229+230230+ /* RC5 gpio */231231+ u32 rc5_gpio;232232+ struct timer_list timer_end; /* timer_end for code completion */233233+ struct timer_list timer_keyup; /* timer_end for key release */234234+ u32 last_rc5; /* last good rc5 code */235235+ u32 last_bit; /* last raw bit seen */236236+ u32 code; /* raw code under construction */237237+ struct timeval base_time; /* time of last seen code */238238+ int active; /* building raw code */239239+};240240+216241struct tvcard217242{218243 char *name;···266235 unsigned int has_dvb:1;267236 unsigned int has_remote:1;268237 unsigned int no_gpioirq:1;269269- unsigned int any_irq:1;270238271239 /* other settings */272240 unsigned int pll;···365335 struct device_driver drv;366336 char wanted[BUS_ID_SIZE];367337 void (*gpio_irq)(struct bttv_sub_device *sub);368368- int (*any_irq)(struct bttv_sub_device *sub);369338};370339#define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)371340···391362extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,392363 unsigned char b2, int both);393364extern void bttv_readee(struct bttv *btv, unsigned char *eedata, int addr);365365+366366+extern int bttv_input_init(struct bttv *dev);367367+extern void bttv_input_fini(struct bttv *dev);368368+extern void bttv_input_irq(struct bttv *dev);394369395370#endif /* _BTTV_H_ */396371/*
+9-4
drivers/media/video/bttvp.h
···73737474#define UNSET (-1U)75757676+#define clamp(x, low, high) min (max (low, x), high)7777+7678/* ---------------------------------------------------------- */77797880struct bttv_tvnorm {···9088 u8 vbipack;9189 u16 vtotal;9290 int sram;9191+ /* ITU-R frame line number of the first VBI line we can9292+ capture, of the first and second field. */9393+ u16 vbistart[2];9394};9495extern const struct bttv_tvnorm bttv_tvnorms[];9596···214209int bttv_sub_add_device(struct bttv_core *core, char *name);215210int bttv_sub_del_devices(struct bttv_core *core);216211void bttv_gpio_irq(struct bttv_core *core);217217-int bttv_any_irq(struct bttv_core *core);218212219213220214/* ---------------------------------------------------------- */···274270 /* card configuration info */275271 unsigned int cardid; /* pci subsystem id (bt878 based ones) */276272 unsigned int tuner_type; /* tuner chip type */277277- unsigned int pinnacle_id;273273+ unsigned int tda9887_conf;278274 unsigned int svhs;279275 struct bttv_pll_info pll;280276 int triton1;281277 int gpioirq;282282- int any_irq;278278+ int (*custom_irq)(struct bttv *btv);279279+283280 int use_i2c_hw;284281285282 /* old gpio interface */···305300306301 /* infrared remote */307302 int has_remote;308308- struct bttv_input *remote;303303+ struct bttv_ir *remote;309304310305 /* locking */311306 spinlock_t s_lock;
···2727#include <linux/i2c.h>2828#include <linux/i2c-id.h>2929#include <linux/videodev.h>3030-#include <media/audiochip.h>3030+#include <media/v4l2-common.h>31313232MODULE_DESCRIPTION("i2c device driver for cs53l32a Audio ADC");3333MODULE_AUTHOR("Martin Vaughan");···3838module_param(debug, bool, 0644);39394040MODULE_PARM_DESC(debug, "Debugging messages\n\t\t\t0=Off (default), 1=On");4141-4242-#define cs53l32a_dbg(fmt, arg...) \4343- do { \4444- if (debug) \4545- printk(KERN_INFO "%s debug %d-%04x: " fmt, \4646- client->driver->driver.name, \4747- i2c_adapter_id(client->adapter), client->addr , ## arg); \4848- } while (0)4949-5050-#define cs53l32a_err(fmt, arg...) do { \5151- printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \5252- i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)5353-#define cs53l32a_info(fmt, arg...) do { \5454- printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \5555- i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)56415742static unsigned short normal_i2c[] = { 0x22 >> 1, I2C_CLIENT_END };5843···5974static int cs53l32a_command(struct i2c_client *client, unsigned int cmd,6075 void *arg)6176{6262- int *input = arg;7777+ struct v4l2_audio *input = arg;7878+ struct v4l2_control *ctrl = arg;63796480 switch (cmd) {6565- case AUDC_SET_INPUT:6666- switch (*input) {6767- case AUDIO_TUNER:6868- cs53l32a_write(client, 0x01, 0x01);6969- break;7070- case AUDIO_EXTERN:7171- cs53l32a_write(client, 0x01, 0x21);7272- break;7373- case AUDIO_MUTE:7474- cs53l32a_write(client, 0x03, 0xF0);7575- break;7676- case AUDIO_UNMUTE:7777- cs53l32a_write(client, 0x03, 0x30);7878- break;7979- default:8080- cs53l32a_err("Invalid input %d.\n", *input);8181+ case VIDIOC_S_AUDIO:8282+ /* There are 2 physical inputs, but the second input can be8383+ placed in two modes, the first mode bypasses the PGA (gain),8484+ the second goes through the PGA. Hence there are three8585+ possible inputs to choose from. */8686+ if (input->index > 2) {8787+ v4l_err(client, "Invalid input %d.\n", input->index);8188 return -EINVAL;8289 }9090+ cs53l32a_write(client, 0x01, 0x01 + (input->index << 4));9191+ break;9292+9393+ case VIDIOC_G_AUDIO:9494+ memset(input, 0, sizeof(*input));9595+ input->index = (cs53l32a_read(client, 0x01) >> 4) & 3;9696+ break;9797+9898+ case VIDIOC_G_CTRL:9999+ if (ctrl->id == V4L2_CID_AUDIO_MUTE) {100100+ ctrl->value = (cs53l32a_read(client, 0x03) & 0xc0) != 0;101101+ break;102102+ }103103+ if (ctrl->id != V4L2_CID_AUDIO_VOLUME)104104+ return -EINVAL;105105+ ctrl->value = (s8)cs53l32a_read(client, 0x04);83106 break;8410785108 case VIDIOC_S_CTRL:8686- {8787- struct v4l2_control *ctrl = arg;8888-8989- if (ctrl->id != V4L2_CID_AUDIO_VOLUME)9090- return -EINVAL;9191- if (ctrl->value > 12 || ctrl->value < -90)9292- return -EINVAL;9393- cs53l32a_write(client, 0x04, (u8) ctrl->value);9494- cs53l32a_write(client, 0x05, (u8) ctrl->value);109109+ if (ctrl->id == V4L2_CID_AUDIO_MUTE) {110110+ cs53l32a_write(client, 0x03, ctrl->value ? 0xf0 : 0x30);95111 break;96112 }113113+ if (ctrl->id != V4L2_CID_AUDIO_VOLUME)114114+ return -EINVAL;115115+ if (ctrl->value > 12 || ctrl->value < -96)116116+ return -EINVAL;117117+ cs53l32a_write(client, 0x04, (u8) ctrl->value);118118+ cs53l32a_write(client, 0x05, (u8) ctrl->value);119119+ break;9712098121 case VIDIOC_LOG_STATUS:99122 {100123 u8 v = cs53l32a_read(client, 0x01);101124 u8 m = cs53l32a_read(client, 0x03);125125+ s8 vol = cs53l32a_read(client, 0x04);102126103103- cs53l32a_info("Input: %s%s\n",104104- v == 0x21 ? "external line in" : "tuner",127127+ v4l_info(client, "Input: %d%s\n", (v >> 4) & 3,105128 (m & 0xC0) ? " (muted)" : "");129129+ v4l_info(client, "Volume: %d dB\n", vol);106130 break;107131 }108132···151157 client->driver = &i2c_driver;152158 snprintf(client->name, sizeof(client->name) - 1, "cs53l32a");153159154154- cs53l32a_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name);160160+ v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name);155161156162 for (i = 1; i <= 7; i++) {157163 u8 v = cs53l32a_read(client, i);158164159159- cs53l32a_dbg("Read Reg %d %02x\n", i, v);165165+ v4l_dbg(1, client, "Read Reg %d %02x\n", i, v);160166 }161167162168 /* Set cs53l32a internal register for Adaptec 2010/2410 setup */···174180 for (i = 1; i <= 7; i++) {175181 u8 v = cs53l32a_read(client, i);176182177177- cs53l32a_dbg("Read Reg %d %02x\n", i, v);183183+ v4l_dbg(1, client, "Read Reg %d %02x\n", i, v);178184 }179185180186 i2c_attach_client(client);···184190185191static int cs53l32a_probe(struct i2c_adapter *adapter)186192{187187-#ifdef I2C_CLASS_TV_ANALOG188193 if (adapter->class & I2C_CLASS_TV_ANALOG)189189-#else190190- if (adapter->id == I2C_HW_B_BT848)191191-#endif192194 return i2c_probe(adapter, &addr_data, cs53l32a_attach);193195 return 0;194196}
+36-55
drivers/media/video/cx25840/cx25840-audio.c
···23232424#include "cx25840.h"25252626-inline static int set_audclk_freq(struct i2c_client *client,2727- enum v4l2_audio_clock_freq freq)2626+static int set_audclk_freq(struct i2c_client *client, u32 freq)2827{2928 struct cx25840_state *state = i2c_get_clientdata(client);2929+3030+ if (freq != 32000 && freq != 44100 && freq != 48000)3131+ return -EINVAL;30323133 /* assert soft reset */3234 cx25840_and_or(client, 0x810, ~0x1, 0x01);···3735 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */3836 cx25840_write(client, 0x127, 0x50);39374040- switch (state->audio_input) {4141- case AUDIO_TUNER:3838+ if (state->aud_input != CX25840_AUDIO_SERIAL) {4239 switch (freq) {4343- case V4L2_AUDCLK_32_KHZ:4040+ case 32000:4441 /* VID_PLL and AUX_PLL */4542 cx25840_write4(client, 0x108, 0x0f040610);4643···5251 cx25840_write4(client, 0x90c, 0x7ff70108);5352 break;54535555- case V4L2_AUDCLK_441_KHZ:5454+ case 44100:5655 /* VID_PLL and AUX_PLL */5756 cx25840_write4(client, 0x108, 0x0f040910);5857···6564 cx25840_write4(client, 0x90c, 0x596d0108);6665 break;67666868- case V4L2_AUDCLK_48_KHZ:6767+ case 48000:6968 /* VID_PLL and AUX_PLL */7069 cx25840_write4(client, 0x108, 0x0f040a10);7170···7877 cx25840_write4(client, 0x90c, 0xaa4f0108);7978 break;8079 }8181- break;8282-8383- case AUDIO_EXTERN_1:8484- case AUDIO_EXTERN_2:8585- case AUDIO_INTERN:8686- case AUDIO_RADIO:8080+ } else {8781 switch (freq) {8888- case V4L2_AUDCLK_32_KHZ:8282+ case 32000:8983 /* VID_PLL and AUX_PLL */9084 cx25840_write4(client, 0x108, 0x0f04081e);9185···99103 cx25840_write(client, 0x127, 0x54);100104 break;101105102102- case V4L2_AUDCLK_441_KHZ:106106+ case 44100:103107 /* VID_PLL and AUX_PLL */104108 cx25840_write4(client, 0x108, 0x0f040918);105109···115119 cx25840_write4(client, 0x90c, 0x85730108);116120 break;117121118118- case V4L2_AUDCLK_48_KHZ:122122+ case 48000:119123 /* VID_PLL and AUX_PLL */120124 cx25840_write4(client, 0x108, 0x0f040a18);121125···131135 cx25840_write4(client, 0x90c, 0x55550108);132136 break;133137 }134134- break;135138 }136139137140 /* deassert soft reset */···141146 return 0;142147}143148144144-static int set_input(struct i2c_client *client, int audio_input)149149+void cx25840_audio_set_path(struct i2c_client *client)145150{146151 struct cx25840_state *state = i2c_get_clientdata(client);147147-148148- cx25840_dbg("set audio input (%d)\n", audio_input);149152150153 /* stop microcontroller */151154 cx25840_and_or(client, 0x803, ~0x10, 0);···151158 /* Mute everything to prevent the PFFT! */152159 cx25840_write(client, 0x8d3, 0x1f);153160154154- switch (audio_input) {155155- case AUDIO_TUNER:156156- /* Set Path1 to Analog Demod Main Channel */157157- cx25840_write4(client, 0x8d0, 0x7038061f);158158-159159- /* When the microcontroller detects the160160- * audio format, it will unmute the lines */161161- cx25840_and_or(client, 0x803, ~0x10, 0x10);162162- break;163163-164164- case AUDIO_EXTERN_1:165165- case AUDIO_EXTERN_2:166166- case AUDIO_INTERN:167167- case AUDIO_RADIO:161161+ if (state->aud_input == CX25840_AUDIO_SERIAL) {168162 /* Set Path1 to Serial Audio Input */169163 cx25840_write4(client, 0x8d0, 0x12100101);170164171165 /* The microcontroller should not be started for the172166 * non-tuner inputs: autodetection is specific for173167 * TV audio. */174174- break;168168+ } else {169169+ /* Set Path1 to Analog Demod Main Channel */170170+ cx25840_write4(client, 0x8d0, 0x7038061f);175171176176- default:177177- cx25840_dbg("Invalid audio input selection %d\n", audio_input);178178- return -EINVAL;172172+ /* When the microcontroller detects the173173+ * audio format, it will unmute the lines */174174+ cx25840_and_or(client, 0x803, ~0x10, 0x10);179175 }180176181181- state->audio_input = audio_input;182182-183183- return set_audclk_freq(client, state->audclk_freq);177177+ set_audclk_freq(client, state->audclk_freq);184178}185179186186-inline static int get_volume(struct i2c_client *client)180180+static int get_volume(struct i2c_client *client)187181{188182 /* Volume runs +18dB to -96dB in 1/2dB steps189183 * change to fit the msp3400 -114dB to +12dB range */···181201 return vol << 9;182202}183203184184-inline static void set_volume(struct i2c_client *client, int volume)204204+static void set_volume(struct i2c_client *client, int volume)185205{186206 /* First convert the volume to msp3400 values (0-127) */187207 int vol = volume >> 9;···198218 cx25840_write(client, 0x8d4, 228 - (vol * 2));199219}200220201201-inline static int get_bass(struct i2c_client *client)221221+static int get_bass(struct i2c_client *client)202222{203223 /* bass is 49 steps +12dB to -12dB */204224···208228 return bass;209229}210230211211-inline static void set_bass(struct i2c_client *client, int bass)231231+static void set_bass(struct i2c_client *client, int bass)212232{213233 /* PATH1_EQ_BASS_VOL */214234 cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff));215235}216236217217-inline static int get_treble(struct i2c_client *client)237237+static int get_treble(struct i2c_client *client)218238{219239 /* treble is 49 steps +12dB to -12dB */220240···224244 return treble;225245}226246227227-inline static void set_treble(struct i2c_client *client, int treble)247247+static void set_treble(struct i2c_client *client, int treble)228248{229249 /* PATH1_EQ_TREBLE_VOL */230250 cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff));231251}232252233233-inline static int get_balance(struct i2c_client *client)253253+static int get_balance(struct i2c_client *client)234254{235255 /* balance is 7 bit, 0 to -96dB */236256···244264 return balance << 8;245265}246266247247-inline static void set_balance(struct i2c_client *client, int balance)267267+static void set_balance(struct i2c_client *client, int balance)248268{249269 int bal = balance >> 8;250270 if (bal > 0x80) {···260280 }261281}262282263263-inline static int get_mute(struct i2c_client *client)283283+static int get_mute(struct i2c_client *client)264284{265285 /* check SRC1_MUTE_EN */266286 return cx25840_read(client, 0x8d3) & 0x2 ? 1 : 0;267287}268288269269-inline static void set_mute(struct i2c_client *client, int mute)289289+static void set_mute(struct i2c_client *client, int mute)270290{271291 struct cx25840_state *state = i2c_get_clientdata(client);272292273273- if (state->audio_input == AUDIO_TUNER) {293293+ if (state->aud_input != CX25840_AUDIO_SERIAL) {274294 /* Must turn off microcontroller in order to mute sound.275295 * Not sure if this is the best method, but it does work.276296 * If the microcontroller is running, then it will undo any···294314 struct v4l2_control *ctrl = arg;295315296316 switch (cmd) {297297- case AUDC_SET_INPUT:298298- return set_input(client, *(int *)arg);299317 case VIDIOC_INT_AUDIO_CLOCK_FREQ:300300- return set_audclk_freq(client, *(enum v4l2_audio_clock_freq *)arg);318318+ return set_audclk_freq(client, *(u32 *)arg);319319+301320 case VIDIOC_G_CTRL:302321 switch (ctrl->id) {303322 case V4L2_CID_AUDIO_VOLUME:···318339 return -EINVAL;319340 }320341 break;342342+321343 case VIDIOC_S_CTRL:322344 switch (ctrl->id) {323345 case V4L2_CID_AUDIO_VOLUME:···340360 return -EINVAL;341361 }342362 break;363363+343364 default:344365 return -EINVAL;345366 }
+239-149
drivers/media/video/cx25840/cx25840-core.c
···4343static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };444445454646-int cx25840_debug = 0;4646+int debug = 0;47474848-module_param(cx25840_debug, bool, 0644);4848+module_param(debug, bool, 0644);49495050-MODULE_PARM_DESC(cx25840_debug, "Debugging messages [0=Off (default) 1=On]");5050+MODULE_PARM_DESC(debug, "Debugging messages [0=Off (default) 1=On]");51515252I2C_CLIENT_INSMOD;5353···115115116116/* ----------------------------------------------------------------------- */117117118118-static int set_input(struct i2c_client *, enum cx25840_input);119119-static void input_change(struct i2c_client *);118118+static int set_input(struct i2c_client *client, enum cx25840_video_input vid_input,119119+ enum cx25840_audio_input aud_input);120120static void log_status(struct i2c_client *client);121121122122/* ----------------------------------------------------------------------- */123123124124-static inline void init_dll1(struct i2c_client *client)124124+static void init_dll1(struct i2c_client *client)125125{126126 /* This is the Hauppauge sequence used to127127 * initialize the Delay Lock Loop 1 (ADC DLL). */···135135 cx25840_write(client, 0x15b, 0x10);136136}137137138138-static inline void init_dll2(struct i2c_client *client)138138+static void init_dll2(struct i2c_client *client)139139{140140 /* This is the Hauppauge sequence used to141141 * initialize the Delay Lock Loop 2 (ADC DLL). */···195195 /* AC97 shift */196196 cx25840_write(client, 0x8cf, 0x0f);197197198198- /* (re)set video input */199199- set_input(client, state->input);200200- /* (re)set audio input */201201- cx25840_audio(client, AUDC_SET_INPUT, &state->audio_input);198198+ /* (re)set input */199199+ set_input(client, state->vid_input, state->aud_input);202200203201 /* start microcontroller */204202 cx25840_and_or(client, 0x803, ~0x10, 0x10);···221223 cx25840_write(client, 0x80b, 0x10);222224 } else if (std & V4L2_STD_NTSC) {223225 /* NTSC */224224- if (state->cardtype == CARDTYPE_PVR150_WORKAROUND) {226226+ if (state->pvr150_workaround) {225227 /* Certain Hauppauge PVR150 models have a hardware bug226228 that causes audio to drop out. For these models the227229 audio standard must be set explicitly.···257259 }258260}259261260260-static int set_input(struct i2c_client *client, enum cx25840_input input)262262+static int set_input(struct i2c_client *client, enum cx25840_video_input vid_input,263263+ enum cx25840_audio_input aud_input)261264{262265 struct cx25840_state *state = i2c_get_clientdata(client);266266+ u8 is_composite = (vid_input >= CX25840_COMPOSITE1 &&267267+ vid_input <= CX25840_COMPOSITE8);268268+ u8 reg;263269264264- cx25840_dbg("decoder set input (%d)\n", input);270270+ v4l_dbg(1, client, "decoder set video input %d, audio input %d\n",271271+ vid_input, aud_input);265272266266- switch (input) {267267- case CX25840_TUNER:268268- cx25840_dbg("now setting Tuner input\n");273273+ if (is_composite) {274274+ reg = 0xf0 + (vid_input - CX25840_COMPOSITE1);275275+ } else {276276+ int luma = vid_input & 0xf0;277277+ int chroma = vid_input & 0xf00;269278270270- if (state->cardtype == CARDTYPE_PVR150 ||271271- state->cardtype == CARDTYPE_PVR150_WORKAROUND) {272272- /* CH_SEL_ADC2=1 */273273- cx25840_and_or(client, 0x102, ~0x2, 0x02);279279+ if ((vid_input & ~0xff0) ||280280+ luma < CX25840_SVIDEO_LUMA1 || luma > CX25840_SVIDEO_LUMA4 ||281281+ chroma < CX25840_SVIDEO_CHROMA4 || chroma > CX25840_SVIDEO_CHROMA8) {282282+ v4l_err(client, "0x%04x is not a valid video input!\n", vid_input);283283+ return -EINVAL;274284 }275275-276276- /* Video Input Control */277277- if (state->cardtype == CARDTYPE_PG600) {278278- cx25840_write(client, 0x103, 0x11);285285+ reg = 0xf0 + ((luma - CX25840_SVIDEO_LUMA1) >> 4);286286+ if (chroma >= CX25840_SVIDEO_CHROMA7) {287287+ reg &= 0x3f;288288+ reg |= (chroma - CX25840_SVIDEO_CHROMA7) >> 2;279289 } else {280280- cx25840_write(client, 0x103, 0x46);290290+ reg &= 0xcf;291291+ reg |= (chroma - CX25840_SVIDEO_CHROMA4) >> 4;281292 }293293+ }282294283283- /* INPUT_MODE=0 */284284- cx25840_and_or(client, 0x401, ~0x6, 0x00);295295+ switch (aud_input) {296296+ case CX25840_AUDIO_SERIAL:297297+ /* do nothing, use serial audio input */285298 break;286286-287287- case CX25840_COMPOSITE0:288288- case CX25840_COMPOSITE1:289289- cx25840_dbg("now setting Composite input\n");290290-291291- /* Video Input Control */292292- if (state->cardtype == CARDTYPE_PG600) {293293- cx25840_write(client, 0x103, 0x00);294294- } else {295295- cx25840_write(client, 0x103, 0x02);296296- }297297-298298- /* INPUT_MODE=0 */299299- cx25840_and_or(client, 0x401, ~0x6, 0x00);300300- break;301301-302302- case CX25840_SVIDEO0:303303- case CX25840_SVIDEO1:304304- cx25840_dbg("now setting S-Video input\n");305305-306306- /* CH_SEL_ADC2=0 */307307- cx25840_and_or(client, 0x102, ~0x2, 0x00);308308-309309- /* Video Input Control */310310- if (state->cardtype == CARDTYPE_PG600) {311311- cx25840_write(client, 0x103, 0x02);312312- } else {313313- cx25840_write(client, 0x103, 0x10);314314- }315315-316316- /* INPUT_MODE=1 */317317- cx25840_and_or(client, 0x401, ~0x6, 0x02);318318- break;299299+ case CX25840_AUDIO4: reg &= ~0x30; break;300300+ case CX25840_AUDIO5: reg &= ~0x30; reg |= 0x10; break;301301+ case CX25840_AUDIO6: reg &= ~0x30; reg |= 0x20; break;302302+ case CX25840_AUDIO7: reg &= ~0xc0; break;303303+ case CX25840_AUDIO8: reg &= ~0xc0; reg |= 0x40; break;319304320305 default:321321- cx25840_err("%d is not a valid input!\n", input);306306+ v4l_err(client, "0x%04x is not a valid audio input!\n", aud_input);322307 return -EINVAL;323308 }324309325325- state->input = input;310310+ cx25840_write(client, 0x103, reg);311311+ /* Set INPUT_MODE to Composite (0) or S-Video (1) */312312+ cx25840_and_or(client, 0x401, ~0x6, is_composite ? 0 : 0x02);313313+ /* Set CH_SEL_ADC2 to 1 if input comes from CH3 */314314+ cx25840_and_or(client, 0x102, ~0x2, (reg & 0x80) == 0 ? 2 : 0);315315+ /* Set DUAL_MODE_ADC2 to 1 if input comes from both CH2 and CH3 */316316+ if ((reg & 0xc0) != 0xc0 && (reg & 0x30) != 0x30)317317+ cx25840_and_or(client, 0x102, ~0x4, 4);318318+ else319319+ cx25840_and_or(client, 0x102, ~0x4, 0);320320+321321+ state->vid_input = vid_input;322322+ state->aud_input = aud_input;323323+ cx25840_audio_set_path(client);326324 input_change(client);327325 return 0;328326}···389395 struct cx25840_state *state = i2c_get_clientdata(client);390396391397 switch (ctrl->id) {392392- case CX25840_CID_CARDTYPE:393393- switch (ctrl->value) {394394- case CARDTYPE_PVR150:395395- case CARDTYPE_PVR150_WORKAROUND:396396- case CARDTYPE_PG600:397397- state->cardtype = ctrl->value;398398- break;399399- default:400400- return -ERANGE;401401- }402402-403403- set_input(client, state->input);398398+ case CX25840_CID_ENABLE_PVR150_WORKAROUND:399399+ state->pvr150_workaround = ctrl->value;400400+ set_input(client, state->vid_input, state->aud_input);404401 break;405402406403 case V4L2_CID_BRIGHTNESS:407404 if (ctrl->value < 0 || ctrl->value > 255) {408408- cx25840_err("invalid brightness setting %d\n",405405+ v4l_err(client, "invalid brightness setting %d\n",409406 ctrl->value);410407 return -ERANGE;411408 }···406421407422 case V4L2_CID_CONTRAST:408423 if (ctrl->value < 0 || ctrl->value > 127) {409409- cx25840_err("invalid contrast setting %d\n",424424+ v4l_err(client, "invalid contrast setting %d\n",410425 ctrl->value);411426 return -ERANGE;412427 }···416431417432 case V4L2_CID_SATURATION:418433 if (ctrl->value < 0 || ctrl->value > 127) {419419- cx25840_err("invalid saturation setting %d\n",434434+ v4l_err(client, "invalid saturation setting %d\n",420435 ctrl->value);421436 return -ERANGE;422437 }···427442428443 case V4L2_CID_HUE:429444 if (ctrl->value < -127 || ctrl->value > 127) {430430- cx25840_err("invalid hue setting %d\n", ctrl->value);445445+ v4l_err(client, "invalid hue setting %d\n", ctrl->value);431446 return -ERANGE;432447 }433448···440455 case V4L2_CID_AUDIO_BALANCE:441456 case V4L2_CID_AUDIO_MUTE:442457 return cx25840_audio(client, VIDIOC_S_CTRL, ctrl);458458+459459+ default:460460+ return -EINVAL;443461 }444462445463 return 0;···453465 struct cx25840_state *state = i2c_get_clientdata(client);454466455467 switch (ctrl->id) {456456- case CX25840_CID_CARDTYPE:457457- ctrl->value = state->cardtype;468468+ case CX25840_CID_ENABLE_PVR150_WORKAROUND:469469+ ctrl->value = state->pvr150_workaround;458470 break;459471 case V4L2_CID_BRIGHTNESS:460460- ctrl->value = cx25840_read(client, 0x414) + 128;472472+ ctrl->value = (s8)cx25840_read(client, 0x414) + 128;461473 break;462474 case V4L2_CID_CONTRAST:463475 ctrl->value = cx25840_read(client, 0x415) >> 1;···466478 ctrl->value = cx25840_read(client, 0x420) >> 1;467479 break;468480 case V4L2_CID_HUE:469469- ctrl->value = cx25840_read(client, 0x422);481481+ ctrl->value = (s8)cx25840_read(client, 0x422);470482 break;471483 case V4L2_CID_AUDIO_VOLUME:472484 case V4L2_CID_AUDIO_BASS:···515527516528 if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) ||517529 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {518518- cx25840_err("%dx%d is not a valid size!\n",530530+ v4l_err(client, "%dx%d is not a valid size!\n",519531 pix->width, pix->height);520532 return -ERANGE;521533 }···533545 else534546 filter = 3;535547536536- cx25840_dbg("decoder set size %dx%d -> scale %ux%u\n",548548+ v4l_dbg(1, client, "decoder set size %dx%d -> scale %ux%u\n",537549 pix->width, pix->height, HSC, VSC);538550539551 /* HSCALE=HSC */···562574563575/* ----------------------------------------------------------------------- */564576577577+static struct v4l2_queryctrl cx25840_qctrl[] = {578578+ {579579+ .id = V4L2_CID_BRIGHTNESS,580580+ .type = V4L2_CTRL_TYPE_INTEGER,581581+ .name = "Brightness",582582+ .minimum = 0,583583+ .maximum = 255,584584+ .step = 1,585585+ .default_value = 128,586586+ .flags = 0,587587+ }, {588588+ .id = V4L2_CID_CONTRAST,589589+ .type = V4L2_CTRL_TYPE_INTEGER,590590+ .name = "Contrast",591591+ .minimum = 0,592592+ .maximum = 255,593593+ .step = 1,594594+ .default_value = 64,595595+ .flags = 0,596596+ }, {597597+ .id = V4L2_CID_SATURATION,598598+ .type = V4L2_CTRL_TYPE_INTEGER,599599+ .name = "Saturation",600600+ .minimum = 0,601601+ .maximum = 255,602602+ .step = 1,603603+ .default_value = 64,604604+ .flags = 0,605605+ }, {606606+ .id = V4L2_CID_HUE,607607+ .type = V4L2_CTRL_TYPE_INTEGER,608608+ .name = "Hue",609609+ .minimum = -128,610610+ .maximum = 127,611611+ .step = 1,612612+ .default_value = 0,613613+ .flags = 0,614614+ }, {615615+ .id = V4L2_CID_AUDIO_VOLUME,616616+ .type = V4L2_CTRL_TYPE_INTEGER,617617+ .name = "Volume",618618+ .minimum = 0,619619+ .maximum = 65535,620620+ .step = 65535/100,621621+ .default_value = 58880,622622+ .flags = 0,623623+ }, {624624+ .id = V4L2_CID_AUDIO_BALANCE,625625+ .type = V4L2_CTRL_TYPE_INTEGER,626626+ .name = "Balance",627627+ .minimum = 0,628628+ .maximum = 65535,629629+ .step = 65535/100,630630+ .default_value = 32768,631631+ .flags = 0,632632+ }, {633633+ .id = V4L2_CID_AUDIO_MUTE,634634+ .type = V4L2_CTRL_TYPE_BOOLEAN,635635+ .name = "Mute",636636+ .minimum = 0,637637+ .maximum = 1,638638+ .step = 1,639639+ .default_value = 1,640640+ .flags = 0,641641+ }, {642642+ .id = V4L2_CID_AUDIO_BASS,643643+ .type = V4L2_CTRL_TYPE_INTEGER,644644+ .name = "Bass",645645+ .minimum = 0,646646+ .maximum = 65535,647647+ .step = 65535/100,648648+ .default_value = 32768,649649+ }, {650650+ .id = V4L2_CID_AUDIO_TREBLE,651651+ .type = V4L2_CTRL_TYPE_INTEGER,652652+ .name = "Treble",653653+ .minimum = 0,654654+ .maximum = 65535,655655+ .step = 65535/100,656656+ .default_value = 32768,657657+ },658658+};659659+660660+/* ----------------------------------------------------------------------- */661661+565662static int cx25840_command(struct i2c_client *client, unsigned int cmd,566663 void *arg)567664{568665 struct cx25840_state *state = i2c_get_clientdata(client);569666 struct v4l2_tuner *vt = arg;570570- int result = 0;571667572668 switch (cmd) {573573- case 0:574574- break;575575-576669#ifdef CONFIG_VIDEO_ADV_DEBUG577670 /* ioctls to allow direct access to the578671 * cx25840 registers for testing */···684615 return cx25840_vbi(client, cmd, arg);685616686617 case VIDIOC_INT_AUDIO_CLOCK_FREQ:687687- case AUDC_SET_INPUT:688688- result = cx25840_audio(client, cmd, arg);689689- break;618618+ return cx25840_audio(client, cmd, arg);690619691620 case VIDIOC_STREAMON:692692- cx25840_dbg("enable output\n");621621+ v4l_dbg(1, client, "enable output\n");693622 cx25840_write(client, 0x115, 0x8c);694623 cx25840_write(client, 0x116, 0x07);695624 break;696625697626 case VIDIOC_STREAMOFF:698698- cx25840_dbg("disable output\n");627627+ v4l_dbg(1, client, "disable output\n");699628 cx25840_write(client, 0x115, 0x00);700629 cx25840_write(client, 0x116, 0x00);701630 break;···703636 break;704637705638 case VIDIOC_G_CTRL:706706- result = get_v4lctrl(client, (struct v4l2_control *)arg);707707- break;639639+ return get_v4lctrl(client, (struct v4l2_control *)arg);708640709641 case VIDIOC_S_CTRL:710710- result = set_v4lctrl(client, (struct v4l2_control *)arg);711711- break;642642+ return set_v4lctrl(client, (struct v4l2_control *)arg);643643+644644+ case VIDIOC_QUERYCTRL:645645+ {646646+ struct v4l2_queryctrl *qc = arg;647647+ int i;648648+649649+ for (i = 0; i < ARRAY_SIZE(cx25840_qctrl); i++)650650+ if (qc->id && qc->id == cx25840_qctrl[i].id) {651651+ memcpy(qc, &cx25840_qctrl[i], sizeof(*qc));652652+ return 0;653653+ }654654+ return -EINVAL;655655+ }712656713657 case VIDIOC_G_STD:714658 *(v4l2_std_id *)arg = cx25840_get_v4lstd(client);715659 break;716660717661 case VIDIOC_S_STD:718718- result = set_v4lstd(client, *(v4l2_std_id *)arg);662662+ state->radio = 0;663663+ return set_v4lstd(client, *(v4l2_std_id *)arg);664664+665665+ case AUDC_SET_RADIO:666666+ state->radio = 1;719667 break;720668721669 case VIDIOC_G_INPUT:722722- *(int *)arg = state->input;670670+ *(int *)arg = state->vid_input;723671 break;724672725673 case VIDIOC_S_INPUT:726726- result = set_input(client, *(int *)arg);674674+ return set_input(client, *(enum cx25840_video_input *)arg, state->aud_input);675675+676676+ case VIDIOC_S_AUDIO:677677+ {678678+ struct v4l2_audio *input = arg;679679+680680+ return set_input(client, state->vid_input, input->index);681681+ }682682+683683+ case VIDIOC_G_AUDIO:684684+ {685685+ struct v4l2_audio *input = arg;686686+687687+ memset(input, 0, sizeof(*input));688688+ input->index = state->aud_input;727689 break;690690+ }728691729692 case VIDIOC_S_FREQUENCY:730693 input_change(client);···766669 u8 pref = cx25840_read(client, 0x809) & 0xf;767670 u8 vpres = cx25840_read(client, 0x80a) & 0x10;768671 int val = 0;672672+673673+ if (state->radio)674674+ break;769675770676 vt->capability |=771677 V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 |···824724 break;825725826726 case VIDIOC_G_FMT:827827- result = get_v4lfmt(client, (struct v4l2_format *)arg);828828- break;727727+ return get_v4lfmt(client, (struct v4l2_format *)arg);829728830729 case VIDIOC_S_FMT:831831- result = set_v4lfmt(client, (struct v4l2_format *)arg);832832- break;730730+ return set_v4lfmt(client, (struct v4l2_format *)arg);833731834732 case VIDIOC_INT_RESET:835733 cx25840_initialize(client, 0);···839741 break;840742841743 default:842842- cx25840_err("invalid ioctl %x\n", cmd);843744 return -EINVAL;844745 }845746846846- return result;747747+ return 0;847748}848749849750/* ----------------------------------------------------------------------- */···872775 client->driver = &i2c_driver_cx25840;873776 snprintf(client->name, sizeof(client->name) - 1, "cx25840");874777875875- cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1);778778+ v4l_dbg(1, client, "detecting cx25840 client on address 0x%x\n", address << 1);876779877780 device_id = cx25840_read(client, 0x101) << 8;878781 device_id |= cx25840_read(client, 0x100);···880783 /* The high byte of the device ID should be881784 * 0x84 if chip is present */882785 if ((device_id & 0xff00) != 0x8400) {883883- cx25840_dbg("cx25840 not found\n");786786+ v4l_dbg(1, client, "cx25840 not found\n");884787 kfree(client);885788 return 0;886789 }887790888888- cx25840_info("cx25%3x-2%x found @ 0x%x (%s)\n",791791+ v4l_info(client, "cx25%3x-2%x found @ 0x%x (%s)\n",889792 (device_id & 0xfff0) >> 4,890793 (device_id & 0x0f) < 3 ? (device_id & 0x0f) + 1 : 3,891794 address << 1, adapter->name);···898801899802 i2c_set_clientdata(client, state);900803 memset(state, 0, sizeof(struct cx25840_state));901901- state->input = CX25840_TUNER;902902- state->audclk_freq = V4L2_AUDCLK_48_KHZ;903903- state->audio_input = AUDIO_TUNER;904904- state->cardtype = CARDTYPE_PVR150;804804+ state->vid_input = CX25840_COMPOSITE7;805805+ state->aud_input = CX25840_AUDIO8;806806+ state->audclk_freq = 48000;807807+ state->pvr150_workaround = 0;905808906809 cx25840_initialize(client, 1);907810···912815913816static int cx25840_attach_adapter(struct i2c_adapter *adapter)914817{915915-#ifdef I2C_CLASS_TV_ANALOG916818 if (adapter->class & I2C_CLASS_TV_ANALOG)917917-#else918918- if (adapter->id == I2C_HW_B_BT848)919919-#endif920819 return i2c_probe(adapter, &addr_data, &cx25840_detect_client);921820 return 0;922821}···939846 .driver = {940847 .name = "cx25840",941848 },942942-943849 .id = I2C_DRIVERID_CX25840,944944-945850 .attach_adapter = cx25840_attach_adapter,946851 .detach_client = cx25840_detach_client,947852 .command = cx25840_command,···983892 u8 pref_mode = cx25840_read(client, 0x809);984893 u8 afc0 = cx25840_read(client, 0x80b);985894 u8 mute_ctl = cx25840_read(client, 0x8d3);895895+ int vid_input = state->vid_input;896896+ int aud_input = state->aud_input;986897 char *p;987898988988- cx25840_info("Video signal: %spresent\n",899899+ v4l_info(client, "Video signal: %spresent\n",989900 (microctrl_vidfmt & 0x10) ? "" : "not ");990990- cx25840_info("Detected format: %s\n",901901+ v4l_info(client, "Detected format: %s\n",991902 fmt_strs[gen_stat1 & 0xf]);992903993904 switch (mod_det_stat0) {···1004911 case 0xfe: p = "forced mode"; break;1005912 default: p = "not defined";1006913 }10071007- cx25840_info("Detected audio mode: %s\n", p);914914+ v4l_info(client, "Detected audio mode: %s\n", p);10089151009916 switch (mod_det_stat1) {1010917 case 0x00: p = "not defined"; break;···1030937 case 0xff: p = "no detected audio standard"; break;1031938 default: p = "not defined";1032939 }10331033- cx25840_info("Detected audio standard: %s\n", p);10341034- cx25840_info("Audio muted: %s\n",940940+ v4l_info(client, "Detected audio standard: %s\n", p);941941+ v4l_info(client, "Audio muted: %s\n",1035942 (mute_ctl & 0x2) ? "yes" : "no");10361036- cx25840_info("Audio microcontroller: %s\n",943943+ v4l_info(client, "Audio microcontroller: %s\n",1037944 (download_ctl & 0x10) ? "running" : "stopped");10389451039946 switch (audio_config >> 4) {···1055962 case 0x0f: p = "automatic detection"; break;1056963 default: p = "undefined";1057964 }10581058- cx25840_info("Configured audio standard: %s\n", p);965965+ v4l_info(client, "Configured audio standard: %s\n", p);10599661060967 if ((audio_config >> 4) < 0xF) {1061968 switch (audio_config & 0xF) {···1072979 case 0x0a: p = "SAP"; break;1073980 default: p = "undefined";1074981 }10751075- cx25840_info("Configured audio mode: %s\n", p);982982+ v4l_info(client, "Configured audio mode: %s\n", p);1076983 } else {1077984 switch (audio_config & 0xF) {1078985 case 0x00: p = "BG"; break;···1088995 case 0x0f: p = "automatic standard and mode detection"; break;1089996 default: p = "undefined";1090997 }10911091- cx25840_info("Configured audio system: %s\n", p);998998+ v4l_info(client, "Configured audio system: %s\n", p);1092999 }1093100010941094- cx25840_info("Specified standard: %s\n",10011001+ v4l_info(client, "Specified standard: %s\n",10951002 vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection");1096100310971097- switch (state->input) {10981098- case CX25840_COMPOSITE0: p = "Composite 0"; break;10991099- case CX25840_COMPOSITE1: p = "Composite 1"; break;11001100- case CX25840_SVIDEO0: p = "S-Video 0"; break;11011101- case CX25840_SVIDEO1: p = "S-Video 1"; break;11021102- case CX25840_TUNER: p = "Tuner"; break;10041004+ if (vid_input >= CX25840_COMPOSITE1 &&10051005+ vid_input <= CX25840_COMPOSITE8) {10061006+ v4l_info(client, "Specified video input: Composite %d\n",10071007+ vid_input - CX25840_COMPOSITE1 + 1);10081008+ } else {10091009+ v4l_info(client, "Specified video input: S-Video (Luma In%d, Chroma In%d)\n",10101010+ (vid_input & 0xf0) >> 4, (vid_input & 0xf00) >> 8);11031011 }11041104- cx25840_info("Specified input: %s\n", p);11051105- cx25840_info("Specified audio input: %s\n",11061106- state->audio_input == 0 ? "Tuner" : "External");10121012+ if (aud_input) {10131013+ v4l_info(client, "Specified audio input: Tuner (In%d)\n", aud_input);10141014+ } else {10151015+ v4l_info(client, "Specified audio input: External\n");10161016+ }1107101711081108- switch (state->audclk_freq) {11091109- case V4L2_AUDCLK_441_KHZ: p = "44.1 kHz"; break;11101110- case V4L2_AUDCLK_48_KHZ: p = "48 kHz"; break;11111111- case V4L2_AUDCLK_32_KHZ: p = "32 kHz"; break;11121112- default: p = "undefined";11131113- }11141114- cx25840_info("Specified audioclock freq: %s\n", p);10181018+ v4l_info(client, "Specified audioclock freq: %d Hz\n", state->audclk_freq);1115101911161020 switch (pref_mode & 0xf) {11171021 case 0: p = "mono/language A"; break;···11211031 case 7: p = "language AB"; break;11221032 default: p = "undefined";11231033 }11241124- cx25840_info("Preferred audio mode: %s\n", p);10341034+ v4l_info(client, "Preferred audio mode: %s\n", p);1125103511261036 if ((audio_config & 0xf) == 0xf) {11271037 switch ((afc0 >> 3) & 0x3) {···11301040 case 2: p = "autodetect"; break;11311041 default: p = "undefined";11321042 }11331133- cx25840_info("Selected 65 MHz format: %s\n", p);10431043+ v4l_info(client, "Selected 65 MHz format: %s\n", p);1134104411351045 switch (afc0 & 0x7) {11361046 case 0: p = "chroma"; break;···11401050 case 4: p = "autodetect"; break;11411051 default: p = "undefined";11421052 }11431143- cx25840_info("Selected 45 MHz format: %s\n", p);10531053+ v4l_info(client, "Selected 45 MHz format: %s\n", p);11441054 }11451055}
+22-14
drivers/media/video/cx25840/cx25840-firmware.c
···1515 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.1616 */17171818-1918#include <linux/module.h>2019#include <linux/i2c.h>2120#include <linux/i2c-algo-bit.h>···3738MODULE_PARM_DESC(fastfw, "Load firmware fast [0=100MHz 1=333MHz (default)]");3839MODULE_PARM_DESC(firmware, "Firmware image [default: " FWFILE "]");39404040-static inline void set_i2c_delay(struct i2c_client *client, int delay)4141+static void set_i2c_delay(struct i2c_client *client, int delay)4142{4243 struct i2c_algo_bit_data *algod = client->adapter->algo_data;4344···5152 }5253}53545454-static inline void start_fw_load(struct i2c_client *client)5555+static void start_fw_load(struct i2c_client *client)5556{5657 /* DL_ADDR_LB=0 DL_ADDR_HB=0 */5758 cx25840_write(client, 0x800, 0x00);···6566 set_i2c_delay(client, 3);6667}67686868-static inline void end_fw_load(struct i2c_client *client)6969+static void end_fw_load(struct i2c_client *client)6970{7071 if (fastfw)7172 set_i2c_delay(client, 10);···7677 cx25840_write(client, 0x803, 0x03);7778}78797979-static inline int check_fw_load(struct i2c_client *client, int size)8080+static int check_fw_load(struct i2c_client *client, int size)8081{8182 /* DL_ADDR_HB DL_ADDR_LB */8283 int s = cx25840_read(client, 0x801) << 8;8384 s |= cx25840_read(client, 0x800);84858586 if (size != s) {8686- cx25840_err("firmware %s load failed\n", firmware);8787+ v4l_err(client, "firmware %s load failed\n", firmware);8788 return -EINVAL;8889 }89909090- cx25840_info("loaded %s firmware (%d bytes)\n", firmware, size);9191+ v4l_info(client, "loaded %s firmware (%d bytes)\n", firmware, size);9192 return 0;9293}93949494-static inline int fw_write(struct i2c_client *client, u8 * data, int size)9595+static int fw_write(struct i2c_client *client, u8 * data, int size)9596{9696- if (i2c_master_send(client, data, size) < size) {9797+ int sent;9898+9999+ if ((sent = i2c_master_send(client, data, size)) < size) {9710098101 if (fastfw) {9999- cx25840_err("333MHz i2c firmware load failed\n");102102+ v4l_err(client, "333MHz i2c firmware load failed\n");100103 fastfw = 0;101104 set_i2c_delay(client, 10);102105106106+ if (sent > 2) {107107+ u16 dl_addr = cx25840_read(client, 0x801) << 8;108108+ dl_addr |= cx25840_read(client, 0x800);109109+ dl_addr -= sent - 2;110110+ cx25840_write(client, 0x801, dl_addr >> 8);111111+ cx25840_write(client, 0x800, dl_addr & 0xff);112112+ }113113+103114 if (i2c_master_send(client, data, size) < size) {104104- cx25840_err105105- ("100MHz i2c firmware load failed\n");115115+ v4l_err(client, "100MHz i2c firmware load failed\n");106116 return -ENOSYS;107117 }108118109119 } else {110110- cx25840_err("firmware load i2c failure\n");120120+ v4l_err(client, "firmware load i2c failure\n");111121 return -ENOSYS;112122 }113123···132124 int size, send, retval;133125134126 if (request_firmware(&fw, firmware, FWDEV(client)) != 0) {135135- cx25840_err("unable to open firmware %s\n", firmware);127127+ v4l_err(client, "unable to open firmware %s\n", firmware);136128 return -EINVAL;137129 }138130
+2-2
drivers/media/video/cx25840/cx25840-vbi.c
···22222323#include "cx25840.h"24242525-static inline int odd_parity(u8 c)2525+static int odd_parity(u8 c)2626{2727 c ^= (c >> 4);2828 c ^= (c >> 2);···3131 return c & 1;3232}33333434-static inline int decode_vps(u8 * dst, u8 * p)3434+static int decode_vps(u8 * dst, u8 * p)3535{3636 static const u8 biphase_tbl[] = {3737 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
+47-34
drivers/media/video/cx25840/cx25840.h
···2424#include <linux/videodev2.h>2525#include <linux/i2c.h>26262727-extern int cx25840_debug;2828-2929-#define cx25840_dbg(fmt, arg...) do { if (cx25840_debug) \3030- printk(KERN_INFO "%s debug %d-%04x: " fmt, \3131- client->driver->driver.name, \3232- i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)3333-3434-#define cx25840_err(fmt, arg...) do { \3535- printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \3636- i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)3737-3838-#define cx25840_info(fmt, arg...) do { \3939- printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \4040- i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)4141-4242-#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0)4343-4444-/* The CARDTYPE_PVR150_WORKAROUND cardtype activates a workaround for a4545- hardware bug that is present in PVR150 (and possible PVR500) cards that4646- have certain NTSC tuners (tveeprom model numbers 85, 99 and 112). The2727+/* ENABLE_PVR150_WORKAROUND activates a workaround for a hardware bug that is2828+ present in Hauppauge PVR-150 (and possibly PVR-500) cards that have2929+ certain NTSC tuners (tveeprom tuner model numbers 85, 99 and 112). The4730 audio autodetect fails on some channels for these models and the workaround4831 is to select the audio standard explicitly. Many thanks to Hauppauge for4932 providing this information. */5050-enum cx25840_cardtype {5151- CARDTYPE_PVR150,5252- CARDTYPE_PG600,5353- CARDTYPE_PVR150_WORKAROUND,3333+#define CX25840_CID_ENABLE_PVR150_WORKAROUND (V4L2_CID_PRIVATE_BASE+0)3434+3535+enum cx25840_video_input {3636+ /* Composite video inputs In1-In8 */3737+ CX25840_COMPOSITE1 = 1,3838+ CX25840_COMPOSITE2,3939+ CX25840_COMPOSITE3,4040+ CX25840_COMPOSITE4,4141+ CX25840_COMPOSITE5,4242+ CX25840_COMPOSITE6,4343+ CX25840_COMPOSITE7,4444+ CX25840_COMPOSITE8,4545+4646+ /* S-Video inputs consist of one luma input (In1-In4) ORed with one4747+ chroma input (In5-In8) */4848+ CX25840_SVIDEO_LUMA1 = 0x10,4949+ CX25840_SVIDEO_LUMA2 = 0x20,5050+ CX25840_SVIDEO_LUMA3 = 0x30,5151+ CX25840_SVIDEO_LUMA4 = 0x40,5252+ CX25840_SVIDEO_CHROMA4 = 0x400,5353+ CX25840_SVIDEO_CHROMA5 = 0x500,5454+ CX25840_SVIDEO_CHROMA6 = 0x600,5555+ CX25840_SVIDEO_CHROMA7 = 0x700,5656+ CX25840_SVIDEO_CHROMA8 = 0x800,5757+5858+ /* S-Video aliases for common luma/chroma combinations */5959+ CX25840_SVIDEO1 = 0x510,6060+ CX25840_SVIDEO2 = 0x620,6161+ CX25840_SVIDEO3 = 0x730,6262+ CX25840_SVIDEO4 = 0x840,5463};55645656-enum cx25840_input {5757- CX25840_TUNER,5858- CX25840_COMPOSITE0,5959- CX25840_COMPOSITE1,6060- CX25840_SVIDEO0,6161- CX25840_SVIDEO16565+enum cx25840_audio_input {6666+ /* Audio inputs: serial or In4-In8 */6767+ CX25840_AUDIO_SERIAL,6868+ CX25840_AUDIO4 = 4,6969+ CX25840_AUDIO5,7070+ CX25840_AUDIO6,7171+ CX25840_AUDIO7,7272+ CX25840_AUDIO8,6273};63746475struct cx25840_state {6565- enum cx25840_cardtype cardtype;6666- enum cx25840_input input;6767- int audio_input;6868- enum v4l2_audio_clock_freq audclk_freq;7676+ int pvr150_workaround;7777+ int radio;7878+ enum cx25840_video_input vid_input;7979+ enum cx25840_audio_input aud_input;8080+ u32 audclk_freq;6981};70827183/* ----------------------------------------------------------------------- */···9684/* ----------------------------------------------------------------------- */9785/* cx25850-audio.c */9886int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg);8787+void cx25840_audio_set_path(struct i2c_client *client);998810089/* ----------------------------------------------------------------------- */10190/* cx25850-vbi.c */
+25
drivers/media/video/cx88/Kconfig
···2929 You must also select one or more DVB/ATSC demodulators.3030 If you are unsure which you need, choose all of them.31313232+config VIDEO_CX88_ALSA3333+ tristate "ALSA DMA audio support"3434+ depends on VIDEO_CX88 && SND3535+ select SND_PCM_OSS3636+ ---help---3737+ This is a video4linux driver for direct (DMA) audio on3838+ Conexant 2388x based TV cards.3939+ It only works with boards with function 01 enabled.4040+ To check if your board supports, use lspci -n.4141+ If supported, you should see 1471:8801 or 1471:88114242+ PCI device.4343+4444+ To compile this driver as a module, choose M here: the4545+ module will be called cx88-alsa.4646+3247config VIDEO_CX88_DVB_ALL_FRONTENDS3348 bool "Build all supported frontends for cx2388x based TV cards"3449 default y···5338 select DVB_CX227025439 select DVB_LGDT330X5540 select DVB_NXT200X4141+ select DVB_CX241235642 ---help---5743 This builds cx88-dvb with all currently supported frontend5844 demodulators. If you wish to tweak your configuration, and···10589 ---help---10690 This adds ATSC 8VSB and QAM64/256 support for cards based on the10791 Connexant 2388x chip and the NXT2002/NXT2004 demodulator.9292+9393+config VIDEO_CX88_DVB_CX241239494+ bool "Conexant CX24123 DVB-S Support"9595+ default y9696+ depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS9797+ select DVB_CX241239898+ ---help---9999+ This adds DVB-S support for cards based on the100100+ Connexant 2388x chip and the CX24123 demodulator.
···7878 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:7979 cx_write(TS_SOP_STAT, 1<<13);8080 break;8181+ case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:8282+ case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:8383+ cx_write(MO_PINMUX_IO, 0x88); /* Enable MPEG parallel IO and video signal pins */8484+ udelay(100);8585+ break;8186 default:8287 cx_write(TS_SOP_STAT, 0x00);8388 break;
+9-1
drivers/media/video/cx88/cx88-tvaudio.c
···132132{133133 u32 volume;134134135135+#ifndef USING_CX88_ALSA135136 /* restart dma; This avoids buzz in NICAM and is good in others */136137 cx88_stop_audio_dma(core);138138+#endif137139 cx_write(AUD_RATE_THRES_DMD, 0x000000C0);140140+#ifndef USING_CX88_ALSA138141 cx88_start_audio_dma(core);142142+#endif139143140144 if (cx88_boards[core->board].blackbird) {141145 /* sets sound input from external adc */142142- cx_set(AUD_CTL, EN_I2SIN_ENABLE);146146+ if (core->board == CX88_BOARD_HAUPPAUGE_ROSLYN)147147+ cx_clear(AUD_CTL, EN_I2SIN_ENABLE);148148+ else149149+ cx_set(AUD_CTL, EN_I2SIN_ENABLE);150150+143151 cx_write(AUD_I2SINPUTCNTL, 4);144152 cx_write(AUD_BAUDRATE, 1);145153 /* 'pass-thru mode': this enables the i2s output to the mpeg encoder */
···11+/*22+33+ cx88-vp3054-i2c.c -- support for the secondary I2C bus of the44+ DNTV Live! DVB-T Pro (VP-3054), wired as:55+ GPIO[0] -> SCL, GPIO[1] -> SDA66+77+ (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>88+99+ This program is free software; you can redistribute it and/or modify1010+ it under the terms of the GNU General Public License as published by1111+ the Free Software Foundation; either version 2 of the License, or1212+ (at your option) any later version.1313+1414+ This program is distributed in the hope that it will be useful,1515+ but WITHOUT ANY WARRANTY; without even the implied warranty of1616+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1717+ GNU General Public License for more details.1818+1919+ You should have received a copy of the GNU General Public License2020+ along with this program; if not, write to the Free Software2121+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2222+2323+*/2424+2525+#include <linux/module.h>2626+#include <linux/moduleparam.h>2727+#include <linux/init.h>2828+2929+#include <asm/io.h>3030+3131+#include "cx88.h"3232+#include "cx88-vp3054-i2c.h"3333+3434+3535+/* ----------------------------------------------------------------------- */3636+3737+static void vp3054_bit_setscl(void *data, int state)3838+{3939+ struct cx8802_dev *dev = data;4040+ struct cx88_core *core = dev->core;4141+ struct vp3054_i2c_state *vp3054_i2c = dev->card_priv;4242+4343+ if (state) {4444+ vp3054_i2c->state |= 0x0001; /* SCL high */4545+ vp3054_i2c->state &= ~0x0100; /* external pullup */4646+ } else {4747+ vp3054_i2c->state &= ~0x0001; /* SCL low */4848+ vp3054_i2c->state |= 0x0100; /* drive pin */4949+ }5050+ cx_write(MO_GP0_IO, 0x010000 | vp3054_i2c->state);5151+ cx_read(MO_GP0_IO);5252+}5353+5454+static void vp3054_bit_setsda(void *data, int state)5555+{5656+ struct cx8802_dev *dev = data;5757+ struct cx88_core *core = dev->core;5858+ struct vp3054_i2c_state *vp3054_i2c = dev->card_priv;5959+6060+ if (state) {6161+ vp3054_i2c->state |= 0x0002; /* SDA high */6262+ vp3054_i2c->state &= ~0x0200; /* tristate pin */6363+ } else {6464+ vp3054_i2c->state &= ~0x0002; /* SDA low */6565+ vp3054_i2c->state |= 0x0200; /* drive pin */6666+ }6767+ cx_write(MO_GP0_IO, 0x020000 | vp3054_i2c->state);6868+ cx_read(MO_GP0_IO);6969+}7070+7171+static int vp3054_bit_getscl(void *data)7272+{7373+ struct cx8802_dev *dev = data;7474+ struct cx88_core *core = dev->core;7575+ u32 state;7676+7777+ state = cx_read(MO_GP0_IO);7878+ return (state & 0x01) ? 1 : 0;7979+}8080+8181+static int vp3054_bit_getsda(void *data)8282+{8383+ struct cx8802_dev *dev = data;8484+ struct cx88_core *core = dev->core;8585+ u32 state;8686+8787+ state = cx_read(MO_GP0_IO);8888+ return (state & 0x02) ? 1 : 0;8989+}9090+9191+/* ----------------------------------------------------------------------- */9292+9393+static struct i2c_algo_bit_data vp3054_i2c_algo_template = {9494+ .setsda = vp3054_bit_setsda,9595+ .setscl = vp3054_bit_setscl,9696+ .getsda = vp3054_bit_getsda,9797+ .getscl = vp3054_bit_getscl,9898+ .udelay = 16,9999+ .mdelay = 10,100100+ .timeout = 200,101101+};102102+103103+/* ----------------------------------------------------------------------- */104104+105105+static struct i2c_adapter vp3054_i2c_adap_template = {106106+ .name = "cx2388x",107107+ .owner = THIS_MODULE,108108+ .id = I2C_HW_B_CX2388x,109109+};110110+111111+static struct i2c_client vp3054_i2c_client_template = {112112+ .name = "VP-3054",113113+};114114+115115+int vp3054_i2c_probe(struct cx8802_dev *dev)116116+{117117+ struct cx88_core *core = dev->core;118118+ struct vp3054_i2c_state *vp3054_i2c;119119+ int rc;120120+121121+ if (core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO)122122+ return 0;123123+124124+ dev->card_priv = kzalloc(sizeof(*vp3054_i2c), GFP_KERNEL);125125+ if (dev->card_priv == NULL)126126+ return -ENOMEM;127127+ vp3054_i2c = dev->card_priv;128128+129129+ memcpy(&vp3054_i2c->adap, &vp3054_i2c_adap_template,130130+ sizeof(vp3054_i2c->adap));131131+ memcpy(&vp3054_i2c->algo, &vp3054_i2c_algo_template,132132+ sizeof(vp3054_i2c->algo));133133+ memcpy(&vp3054_i2c->client, &vp3054_i2c_client_template,134134+ sizeof(vp3054_i2c->client));135135+136136+ vp3054_i2c->adap.class |= I2C_CLASS_TV_DIGITAL;137137+138138+ vp3054_i2c->adap.dev.parent = &dev->pci->dev;139139+ strlcpy(vp3054_i2c->adap.name, core->name,140140+ sizeof(vp3054_i2c->adap.name));141141+ vp3054_i2c->algo.data = dev;142142+ i2c_set_adapdata(&vp3054_i2c->adap, dev);143143+ vp3054_i2c->adap.algo_data = &vp3054_i2c->algo;144144+ vp3054_i2c->client.adapter = &vp3054_i2c->adap;145145+146146+ vp3054_bit_setscl(dev,1);147147+ vp3054_bit_setsda(dev,1);148148+149149+ rc = i2c_bit_add_bus(&vp3054_i2c->adap);150150+ if (0 != rc) {151151+ printk("%s: vp3054_i2c register FAILED\n", core->name);152152+153153+ kfree(dev->card_priv);154154+ dev->card_priv = NULL;155155+ }156156+157157+ return rc;158158+}159159+160160+void vp3054_i2c_remove(struct cx8802_dev *dev)161161+{162162+ struct vp3054_i2c_state *vp3054_i2c = dev->card_priv;163163+164164+ if (vp3054_i2c == NULL ||165165+ dev->core->board != CX88_BOARD_DNTV_LIVE_DVB_T_PRO)166166+ return;167167+168168+ i2c_bit_del_bus(&vp3054_i2c->adap);169169+ kfree(vp3054_i2c);170170+}171171+172172+EXPORT_SYMBOL(vp3054_i2c_probe);173173+EXPORT_SYMBOL(vp3054_i2c_remove);
+35
drivers/media/video/cx88/cx88-vp3054-i2c.h
···11+/*22+33+ cx88-vp3054-i2c.h -- support for the secondary I2C bus of the44+ DNTV Live! DVB-T Pro (VP-3054), wired as:55+ GPIO[0] -> SCL, GPIO[1] -> SDA66+77+ (c) 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>88+99+ This program is free software; you can redistribute it and/or modify1010+ it under the terms of the GNU General Public License as published by1111+ the Free Software Foundation; either version 2 of the License, or1212+ (at your option) any later version.1313+1414+ This program is distributed in the hope that it will be useful,1515+ but WITHOUT ANY WARRANTY; without even the implied warranty of1616+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1717+ GNU General Public License for more details.1818+1919+ You should have received a copy of the GNU General Public License2020+ along with this program; if not, write to the Free Software2121+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.2222+2323+*/2424+2525+/* ----------------------------------------------------------------------- */2626+struct vp3054_i2c_state {2727+ struct i2c_adapter adap;2828+ struct i2c_algo_bit_data algo;2929+ struct i2c_client client;3030+ u32 state;3131+};3232+3333+/* ----------------------------------------------------------------------- */3434+int vp3054_i2c_probe(struct cx8802_dev *dev);3535+void vp3054_i2c_remove(struct cx8802_dev *dev);
···32323333#include "em28xx.h"3434#include <media/tuner.h>3535+#include <media/v4l2-common.h>35363637#define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \3738 "Markus Rechberger <mrechberger@gmail.com>, " \···107106#define TVNORMS ARRAY_SIZE(tvnorms)108107109108/* supported controls */109109+/* Common to all boards */110110static struct v4l2_queryctrl em28xx_qctrl[] = {111111+ {112112+ .id = V4L2_CID_AUDIO_VOLUME,113113+ .type = V4L2_CTRL_TYPE_INTEGER,114114+ .name = "Volume",115115+ .minimum = 0x0,116116+ .maximum = 0x1f,117117+ .step = 0x1,118118+ .default_value = 0x1f,119119+ .flags = 0,120120+ },{121121+ .id = V4L2_CID_AUDIO_MUTE,122122+ .type = V4L2_CTRL_TYPE_BOOLEAN,123123+ .name = "Mute",124124+ .minimum = 0,125125+ .maximum = 1,126126+ .step = 1,127127+ .default_value = 1,128128+ .flags = 0,129129+ }130130+};131131+132132+/* FIXME: These are specific to saa711x - should be moved to its code */133133+static struct v4l2_queryctrl saa711x_qctrl[] = {111134 {112135 .id = V4L2_CID_BRIGHTNESS,113136 .type = V4L2_CTRL_TYPE_INTEGER,···160135 .default_value = 0x10,161136 .flags = 0,162137 },{163163- .id = V4L2_CID_AUDIO_VOLUME,164164- .type = V4L2_CTRL_TYPE_INTEGER,165165- .name = "Volume",166166- .minimum = 0x0,167167- .maximum = 0x1f,168168- .step = 0x1,169169- .default_value = 0x1f,170170- .flags = 0,171171- },{172172- .id = V4L2_CID_AUDIO_MUTE,173173- .type = V4L2_CTRL_TYPE_BOOLEAN,174174- .name = "Mute",175175- .minimum = 0,176176- .maximum = 1,177177- .step = 1,178178- .default_value = 1,179179- .flags = 0,180180- },{181138 .id = V4L2_CID_RED_BALANCE,182139 .type = V4L2_CTRL_TYPE_INTEGER,183140 .name = "Red chroma balance",···186179 .step = 0x1,187180 .default_value = 0x20,188181 .flags = 0,189189- }182182+ }190183};191184192185static struct usb_driver em28xx_usb_driver;···287280 em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput);288281289282 if (dev->has_msp34xx) {283283+ if (dev->i2s_speed)284284+ em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed);290285 em28xx_i2c_call_clients(dev, VIDIOC_S_AUDIO, &dev->ctl_ainput);291286 ainput = EM28XX_AUDIO_SRC_TUNER;292287 em28xx_audio_source(dev, ainput);···683674 */684675static int em28xx_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl)685676{686686- s32 tmp;687677 switch (ctrl->id) {688678 case V4L2_CID_AUDIO_MUTE:689679 ctrl->value = dev->mute;···690682 case V4L2_CID_AUDIO_VOLUME:691683 ctrl->value = dev->volume;692684 return 0;685685+ default:686686+ return -EINVAL;687687+ }688688+}689689+690690+/*FIXME: should be moved to saa711x */691691+static int saa711x_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl)692692+{693693+ s32 tmp;694694+ switch (ctrl->id) {693695 case V4L2_CID_BRIGHTNESS:694696 if ((tmp = em28xx_brightness_get(dev)) < 0)695697 return -EIO;···749731 case V4L2_CID_AUDIO_VOLUME:750732 dev->volume = ctrl->value;751733 return em28xx_audio_analog_set(dev);734734+ default:735735+ return -EINVAL;736736+ }737737+}738738+739739+/*FIXME: should be moved to saa711x */740740+static int saa711x_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl)741741+{742742+ switch (ctrl->id) {752743 case V4L2_CID_BRIGHTNESS:753744 return em28xx_brightness_set(dev, ctrl->value);754745 case V4L2_CID_CONTRAST:···1021994 case VIDIOC_QUERYCTRL:1022995 {1023996 struct v4l2_queryctrl *qc = arg;10241024- u8 i, n;10251025- n = sizeof(em28xx_qctrl) / sizeof(em28xx_qctrl[0]);10261026- for (i = 0; i < n; i++)10271027- if (qc->id && qc->id == em28xx_qctrl[i].id) {10281028- memcpy(qc, &(em28xx_qctrl[i]),997997+ int i, id=qc->id;998998+999999+ memset(qc,0,sizeof(*qc));10001000+ qc->id=id;10011001+10021002+ if (!dev->has_msp34xx) {10031003+ for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) {10041004+ if (qc->id && qc->id == em28xx_qctrl[i].id) {10051005+ memcpy(qc, &(em28xx_qctrl[i]),10061006+ sizeof(*qc));10071007+ return 0;10081008+ }10091009+ }10101010+ }10111011+ if (dev->decoder == EM28XX_TVP5150) {10121012+ em28xx_i2c_call_clients(dev,cmd,qc);10131013+ if (qc->type)10141014+ return 0;10151015+ else10161016+ return -EINVAL;10171017+ }10181018+ for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) {10191019+ if (qc->id && qc->id == saa711x_qctrl[i].id) {10201020+ memcpy(qc, &(saa711x_qctrl[i]),10291021 sizeof(*qc));10301022 return 0;10311023 }10241024+ }1032102510331026 return -EINVAL;10341027 }···10561009 case VIDIOC_G_CTRL:10571010 {10581011 struct v4l2_control *ctrl = arg;10121012+ int retval=-EINVAL;1059101310141014+ if (!dev->has_msp34xx)10151015+ retval=em28xx_get_ctrl(dev, ctrl);10161016+ if (retval==-EINVAL) {10171017+ if (dev->decoder == EM28XX_TVP5150) {10181018+ em28xx_i2c_call_clients(dev,cmd,arg);10191019+ return 0;10201020+ }1060102110611061- return em28xx_get_ctrl(dev, ctrl);10221022+ return saa711x_get_ctrl(dev, ctrl);10231023+ } else return retval;10621024 }1063102510641064- case VIDIOC_S_CTRL_OLD: /* ??? */10651026 case VIDIOC_S_CTRL:10661027 {10671028 struct v4l2_control *ctrl = arg;10681068- u8 i, n;10291029+ u8 i;1069103010701070-10711071- n = sizeof(em28xx_qctrl) / sizeof(em28xx_qctrl[0]);10721072- for (i = 0; i < n; i++)10731073- if (ctrl->id == em28xx_qctrl[i].id) {10741074- if (ctrl->value <10751075- em28xx_qctrl[i].minimum10761076- || ctrl->value >10771077- em28xx_qctrl[i].maximum)10781078- return -ERANGE;10791079-10801080- return em28xx_set_ctrl(dev, ctrl);10311031+ if (!dev->has_msp34xx){10321032+ for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) {10331033+ if (ctrl->id == em28xx_qctrl[i].id) {10341034+ if (ctrl->value <10351035+ em28xx_qctrl[i].minimum10361036+ || ctrl->value >10371037+ em28xx_qctrl[i].maximum)10381038+ return -ERANGE;10391039+ return em28xx_set_ctrl(dev, ctrl);10401040+ }10811041 }10421042+ }10431043+10441044+ if (dev->decoder == EM28XX_TVP5150) {10451045+ em28xx_i2c_call_clients(dev,cmd,arg);10461046+ return 0;10471047+ } else if (!dev->has_msp34xx) {10481048+ for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) {10491049+ if (ctrl->id == em28xx_qctrl[i].id) {10501050+ if (ctrl->value <10511051+ em28xx_qctrl[i].minimum10521052+ || ctrl->value >10531053+ em28xx_qctrl[i].maximum)10541054+ return -ERANGE;10551055+ return em28xx_set_ctrl(dev, ctrl);10561056+ }10571057+ }10581058+ for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) {10591059+ if (ctrl->id == saa711x_qctrl[i].id) {10601060+ if (ctrl->value <10611061+ saa711x_qctrl[i].minimum10621062+ || ctrl->value >10631063+ saa711x_qctrl[i].maximum)10641064+ return -ERANGE;10651065+ return saa711x_set_ctrl(dev, ctrl);10661066+ }10671067+ }10681068+ }10691069+10821070 return -EINVAL;10831071 }10841072···12691187 return -ENODEV;1270118812711189 if (video_debug > 1)12721272- em28xx_print_ioctl(dev->name,cmd);11901190+ v4l_print_ioctl(dev->name,cmd);1273119112741192 switch (cmd) {12751193···16461564 .poll = em28xx_v4l2_poll,16471565 .mmap = em28xx_v4l2_mmap,16481566 .llseek = no_llseek,15671567+ .compat_ioctl = v4l_compat_ioctl32,15681568+16491569};1650157016511571/******************************** usb interface *****************************************/···19321848 struct em28xx *dev = usb_get_intfdata(interface);19331849 usb_set_intfdata(interface, NULL);1934185018511851+/*FIXME: IR should be disconnected */18521852+19351853 if (!dev)19361854 return;18551855+1937185619381857 down_write(&em28xx_disconnect);19391858
+3-3
drivers/media/video/em28xx/em28xx.h
···11/*22- em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB video capture devices22+ em28xx.h - driver for Empia EM2800/EM2820/2840 USB video capture devices3344 Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com>55 Ludovico Cavedon <cavedon@sssup.it>···216216 unsigned int has_msp34xx:1;217217 unsigned int has_tda9887:1;218218219219+ u32 i2s_speed; /* I2S speed for audio digital stream */220220+219221 enum em28xx_decoder decoder;220222221223 int tuner_type; /* type of the tuner */···294292void em28xx_set_ir(struct em28xx * dev,struct IR_i2c *ir);295293296294/* Provided by em28xx-core.c */297297-298298-void em28xx_print_ioctl(char *name, unsigned int cmd);299295300296u32 em28xx_request_buffers(struct em28xx *dev, u32 count);301297void em28xx_queue_unusedframes(struct em28xx *dev);
···6868{6969 struct video_device *vfd = container_of(cd, struct video_device, class_dev);70707171-#if 1 /* needed until all drivers are fixed */7171+#if 17272+ /* needed until all drivers are fixed */7273 if (!vfd->release)7374 return;7475#endif···339338 if (vfd->dev)340339 vfd->class_dev.dev = vfd->dev;341340 vfd->class_dev.class = &video_class;342342- vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);341341+ vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);343342 strlcpy(vfd->class_dev.class_id, vfd->devfs_name + 4, BUS_ID_SIZE);344343 class_device_register(&vfd->class_dev);345344 class_device_create_file(&vfd->class_dev,346346- &class_device_attr_name);345345+ &class_device_attr_name);347346348348-#if 1 /* needed until all drivers are fixed */347347+#if 1348348+ /* needed until all drivers are fixed */349349 if (!vfd->release)350350 printk(KERN_WARNING "videodev: \"%s\" has no release callback. "351351 "Please fix your driver for proper sysfs support, see "
···207207 return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));208208}209209210210-struct video_tuner32 {211211- compat_int_t tuner;212212- char name[32];213213- compat_ulong_t rangelow, rangehigh;214214- u32 flags; /* It is really u32 in videodev.h */215215- u16 mode, signal;216216-};217217-218218-static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)219219-{220220- int i;221221-222222- if(get_user(kp->tuner, &up->tuner))223223- return -EFAULT;224224- for(i = 0; i < 32; i++)225225- __get_user(kp->name[i], &up->name[i]);226226- __get_user(kp->rangelow, &up->rangelow);227227- __get_user(kp->rangehigh, &up->rangehigh);228228- __get_user(kp->flags, &up->flags);229229- __get_user(kp->mode, &up->mode);230230- __get_user(kp->signal, &up->signal);231231- return 0;232232-}233233-234234-static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up)235235-{236236- int i;237237-238238- if(put_user(kp->tuner, &up->tuner))239239- return -EFAULT;240240- for(i = 0; i < 32; i++)241241- __put_user(kp->name[i], &up->name[i]);242242- __put_user(kp->rangelow, &up->rangelow);243243- __put_user(kp->rangehigh, &up->rangehigh);244244- __put_user(kp->flags, &up->flags);245245- __put_user(kp->mode, &up->mode);246246- __put_user(kp->signal, &up->signal);247247- return 0;248248-}249249-250250-struct video_buffer32 {251251- compat_caddr_t base;252252- compat_int_t height, width, depth, bytesperline;253253-};254254-255255-static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)256256-{257257- u32 tmp;258258-259259- if (get_user(tmp, &up->base))260260- return -EFAULT;261261-262262- /* This is actually a physical address stored263263- * as a void pointer.264264- */265265- kp->base = (void *)(unsigned long) tmp;266266-267267- __get_user(kp->height, &up->height);268268- __get_user(kp->width, &up->width);269269- __get_user(kp->depth, &up->depth);270270- __get_user(kp->bytesperline, &up->bytesperline);271271- return 0;272272-}273273-274274-static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up)275275-{276276- u32 tmp = (u32)((unsigned long)kp->base);277277-278278- if(put_user(tmp, &up->base))279279- return -EFAULT;280280- __put_user(kp->height, &up->height);281281- __put_user(kp->width, &up->width);282282- __put_user(kp->depth, &up->depth);283283- __put_user(kp->bytesperline, &up->bytesperline);284284- return 0;285285-}286286-287287-struct video_clip32 {288288- s32 x, y, width, height; /* Its really s32 in videodev.h */289289- compat_caddr_t next;290290-};291291-292292-struct video_window32 {293293- u32 x, y, width, height, chromakey, flags;294294- compat_caddr_t clips;295295- compat_int_t clipcount;296296-};297297-298298-/* You get back everything except the clips... */299299-static int put_video_window32(struct video_window *kp, struct video_window32 __user *up)300300-{301301- if(put_user(kp->x, &up->x))302302- return -EFAULT;303303- __put_user(kp->y, &up->y);304304- __put_user(kp->width, &up->width);305305- __put_user(kp->height, &up->height);306306- __put_user(kp->chromakey, &up->chromakey);307307- __put_user(kp->flags, &up->flags);308308- __put_user(kp->clipcount, &up->clipcount);309309- return 0;310310-}311311-312312-#define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)313313-#define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)314314-#define VIDIOCGWIN32 _IOR('v',9, struct video_window32)315315-#define VIDIOCSWIN32 _IOW('v',10, struct video_window32)316316-#define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32)317317-#define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32)318318-#define VIDIOCGFREQ32 _IOR('v',14, u32)319319-#define VIDIOCSFREQ32 _IOW('v',15, u32)320320-321321-enum {322322- MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip)323323-};324324-325325-static int do_set_window(unsigned int fd, unsigned int cmd, unsigned long arg)326326-{327327- struct video_window32 __user *up = compat_ptr(arg);328328- struct video_window __user *vw;329329- struct video_clip __user *p;330330- int nclips;331331- u32 n;332332-333333- if (get_user(nclips, &up->clipcount))334334- return -EFAULT;335335-336336- /* Peculiar interface... */337337- if (nclips < 0)338338- nclips = VIDEO_CLIPMAP_SIZE;339339-340340- if (nclips > MaxClips)341341- return -ENOMEM;342342-343343- vw = compat_alloc_user_space(sizeof(struct video_window) +344344- nclips * sizeof(struct video_clip));345345-346346- p = nclips ? (struct video_clip __user *)(vw + 1) : NULL;347347-348348- if (get_user(n, &up->x) || put_user(n, &vw->x) ||349349- get_user(n, &up->y) || put_user(n, &vw->y) ||350350- get_user(n, &up->width) || put_user(n, &vw->width) ||351351- get_user(n, &up->height) || put_user(n, &vw->height) ||352352- get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) ||353353- get_user(n, &up->flags) || put_user(n, &vw->flags) ||354354- get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) ||355355- get_user(n, &up->clips) || put_user(p, &vw->clips))356356- return -EFAULT;357357-358358- if (nclips) {359359- struct video_clip32 __user *u = compat_ptr(n);360360- int i;361361- if (!u)362362- return -EINVAL;363363- for (i = 0; i < nclips; i++, u++, p++) {364364- s32 v;365365- if (get_user(v, &u->x) ||366366- put_user(v, &p->x) ||367367- get_user(v, &u->y) ||368368- put_user(v, &p->y) ||369369- get_user(v, &u->width) ||370370- put_user(v, &p->width) ||371371- get_user(v, &u->height) ||372372- put_user(v, &p->height) ||373373- put_user(NULL, &p->next))374374- return -EFAULT;375375- }376376- }377377-378378- return sys_ioctl(fd, VIDIOCSWIN, (unsigned long)p);379379-}380380-381381-static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)382382-{383383- union {384384- struct video_tuner vt;385385- struct video_buffer vb;386386- struct video_window vw;387387- unsigned long vx;388388- } karg;389389- mm_segment_t old_fs = get_fs();390390- void __user *up = compat_ptr(arg);391391- int err = 0;392392-393393- /* First, convert the command. */394394- switch(cmd) {395395- case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;396396- case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;397397- case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;398398- case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break;399399- case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;400400- case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;401401- case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;402402- };403403-404404- switch(cmd) {405405- case VIDIOCSTUNER:406406- case VIDIOCGTUNER:407407- err = get_video_tuner32(&karg.vt, up);408408- break;409409-410410- case VIDIOCSFBUF:411411- err = get_video_buffer32(&karg.vb, up);412412- break;413413-414414- case VIDIOCSFREQ:415415- err = get_user(karg.vx, (u32 __user *)up);416416- break;417417- };418418- if(err)419419- goto out;420420-421421- set_fs(KERNEL_DS);422422- err = sys_ioctl(fd, cmd, (unsigned long)&karg);423423- set_fs(old_fs);424424-425425- if(err == 0) {426426- switch(cmd) {427427- case VIDIOCGTUNER:428428- err = put_video_tuner32(&karg.vt, up);429429- break;430430-431431- case VIDIOCGWIN:432432- err = put_video_window32(&karg.vw, up);433433- break;434434-435435- case VIDIOCGFBUF:436436- err = put_video_buffer32(&karg.vb, up);437437- break;438438-439439- case VIDIOCGFREQ:440440- err = put_user(((u32)karg.vx), (u32 __user *)up);441441- break;442442- };443443- }444444-out:445445- return err;446446-}447447-448210struct compat_dmx_event {449211 dmx_event_t event;450212 compat_time_t timeStamp;···27773015#ifdef CONFIG_JBD_DEBUG27783016HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl)27793017#endif27802780-HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl)27812781-HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl)27822782-HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl)27832783-HANDLE_IOCTL(VIDIOCSWIN32, do_set_window)27842784-HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl)27852785-HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl)27862786-HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl)27872787-HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl)27883018/* One SMB ioctl needs translations. */27893019#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)27903020HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
-26
include/linux/compat_ioctl.h
···218218COMPATIBLE_IOCTL(VT_RESIZEX)219219COMPATIBLE_IOCTL(VT_LOCKSWITCH)220220COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)221221-/* Little v */222222-/* Little v, the video4linux ioctls (conflict?) */223223-COMPATIBLE_IOCTL(VIDIOCGCAP)224224-COMPATIBLE_IOCTL(VIDIOCGCHAN)225225-COMPATIBLE_IOCTL(VIDIOCSCHAN)226226-COMPATIBLE_IOCTL(VIDIOCGPICT)227227-COMPATIBLE_IOCTL(VIDIOCSPICT)228228-COMPATIBLE_IOCTL(VIDIOCCAPTURE)229229-COMPATIBLE_IOCTL(VIDIOCKEY)230230-COMPATIBLE_IOCTL(VIDIOCGAUDIO)231231-COMPATIBLE_IOCTL(VIDIOCSAUDIO)232232-COMPATIBLE_IOCTL(VIDIOCSYNC)233233-COMPATIBLE_IOCTL(VIDIOCMCAPTURE)234234-COMPATIBLE_IOCTL(VIDIOCGMBUF)235235-COMPATIBLE_IOCTL(VIDIOCGUNIT)236236-COMPATIBLE_IOCTL(VIDIOCGCAPTURE)237237-COMPATIBLE_IOCTL(VIDIOCSCAPTURE)238238-/* BTTV specific... */239239-COMPATIBLE_IOCTL(_IOW('v', BASE_VIDIOCPRIVATE+0, char [256]))240240-COMPATIBLE_IOCTL(_IOR('v', BASE_VIDIOCPRIVATE+1, char [256]))241241-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int))242242-COMPATIBLE_IOCTL(_IOW('v' , BASE_VIDIOCPRIVATE+3, char [16])) /* struct bttv_pll_info */243243-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+4, int))244244-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+5, int))245245-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+6, int))246246-COMPATIBLE_IOCTL(_IOR('v' , BASE_VIDIOCPRIVATE+7, int))247221/* Little p (/dev/rtc, /dev/envctrl, etc.) */248222COMPATIBLE_IOCTL(RTC_AIE_ON)249223COMPATIBLE_IOCTL(RTC_AIE_OFF)
+10
include/linux/dvb/frontend.h
···240240};241241242242243243+/**244244+ * When set, this flag will disable any zigzagging or other "normal" tuning245245+ * behaviour. Additionally, there will be no automatic monitoring of the lock246246+ * status, and hence no frontend events will be generated. If a frontend device247247+ * is closed, this flag will be automatically turned off when the device is248248+ * reopened read-write.249249+ */250250+#define FE_TUNE_MODE_ONESHOT 0x01251251+243252244253#define FE_GET_INFO _IOR('o', 61, struct dvb_frontend_info)245254···269260270261#define FE_SET_FRONTEND _IOW('o', 76, struct dvb_frontend_parameters)271262#define FE_GET_FRONTEND _IOR('o', 77, struct dvb_frontend_parameters)263263+#define FE_SET_FRONTEND_TUNE_MODE _IO('o', 81) /* unsigned int */272264#define FE_GET_EVENT _IOR('o', 78, struct dvb_frontend_event)273265274266#define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
+1
include/linux/i2c-id.h
···103103#define I2C_DRIVERID_SAA711X 73 /* saa711x video encoders */104104#define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */105105#define I2C_DRIVERID_INFRARED 75 /* I2C InfraRed on Video boards */106106+#define I2C_DRIVERID_TVP5150 76 /* TVP5150 video decoder */106107107108#define I2C_DRIVERID_I2CDEV 900108109#define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */
+2
include/linux/video_decoder.h
···11#ifndef _LINUX_VIDEO_DECODER_H22#define _LINUX_VIDEO_DECODER_H3344+#define HAVE_VIDEO_DECODER 155+46struct video_decoder_capability { /* this name is too long */57 __u32 flags;68#define VIDEO_DECODER_PAL 1 /* can decode PAL signal */
+13-3
include/linux/videodev2.h
···642642#define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000)643643#define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000)644644645645+/* some merged standards */646646+#define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC)647647+#define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B)648648+#define V4L2_STD_GH (V4L2_STD_PAL_G|V4L2_STD_PAL_H|V4L2_STD_SECAM_G|V4L2_STD_SECAM_H)649649+#define V4L2_STD_DK (V4L2_STD_PAL_DK|V4L2_STD_SECAM_DK)650650+645651/* some common needed stuff */646652#define V4L2_STD_PAL_BG (V4L2_STD_PAL_B |\647653 V4L2_STD_PAL_B1 |\···668662 V4L2_STD_SECAM_G |\669663 V4L2_STD_SECAM_H |\670664 V4L2_STD_SECAM_DK |\671671- V4L2_STD_SECAM_L)665665+ V4L2_STD_SECAM_L |\666666+ V4L2_STD_SECAM_LC)672667673668#define V4L2_STD_525_60 (V4L2_STD_PAL_M |\674669 V4L2_STD_PAL_60 |\···895888896889/* Flags for the 'mode' field */897890#define V4L2_AUDMODE_AVL 0x00001898898-#define V4L2_AUDMODE_32BITS 0x00002899891900892struct v4l2_audioout901893{···11161110/* names for fancy debug output */11171111extern char *v4l2_field_names[];11181112extern char *v4l2_type_names[];11191119-extern char *v4l2_ioctl_names[];1120111311211114/* Compatibility layer interface -- v4l1-compat module */11221115typedef int (*v4l2_kioctl)(struct inode *inode, struct file *file,11231116 unsigned int cmd, void *arg);11241117int v4l_compat_translate_ioctl(struct inode *inode, struct file *file,11251118 int cmd, void *arg, v4l2_kioctl driver_ioctl);11191119+11201120+/* 32 Bits compatibility layer for 64 bits processors */11211121+extern long v4l_compat_ioctl32(struct file *file, unsigned int cmd,11221122+ unsigned long arg);11231123+1126112411271125#endif /* __KERNEL__ */11281126#endif /* __LINUX_VIDEODEV2_H */
-16
include/media/audiochip.h
···23232424/* ---------------------------------------------------------------------- */25252626-/* v4l device was opened in Radio mode */2727-#define AUDC_SET_RADIO _IO('m',2)2828-/* select from TV,radio,extern,MUTE */2929-#define AUDC_SET_INPUT _IOW('m',17,int)3030-3126/* audio inputs */3227#define AUDIO_TUNER 0x003328#define AUDIO_RADIO 0x01···3540#define AUDIO_MUTE 0x803641#define AUDIO_UNMUTE 0x8137423838-/* all the stuff below is obsolete and just here for reference. I'll3939- * remove it once the driver is tested and works fine.4040- *4141- * Instead creating alot of tiny API's for all kinds of different4242- * chips, we'll just pass throuth the v4l ioctl structs (v4l2 not4343- * yet...). It is a bit less flexible, but most/all used i2c chips4444- * make sense in v4l context only. So I think that's acceptable...4545- */4646-4747-/* misc stuff to pass around config info to i2c chips */4848-#define AUDC_CONFIG_PINNACLE _IOW('m',32,int)4943#endif /* AUDIOCHIP_H */
+2
include/media/saa7146_vv.h
···178178179179 struct saa7146_extension_ioctls *ioctls;180180 int (*ioctl)(struct saa7146_fh*, unsigned int cmd, void *arg);181181+182182+ struct file_operations vbi_fops;181183};182184183185struct saa7146_use_ops {
+46-52
include/media/tuner.h
···8282#define TUNER_PHILIPS_FM1236_MK3 4383838484#define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */8585-/* Microtune mergeged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */8585+/* Microtune merged with Temic 12/31/1999 partially financed by Alps - these may be similar to Temic */8686#define TUNER_MICROTUNE_4049FM5 458787-#define TUNER_MICROTUNE_4042_FI5 468787+#define TUNER_PANASONIC_VP27 468888#define TUNER_LG_NTSC_TAPE 4789899090#define TUNER_TNF_8831BGFF 48···102102#define TUNER_YMEC_TVF_8531MF 58103103#define TUNER_YMEC_TVF_5533MF 59 /* Pixelview Pro Ultra NTSC */104104105105-#define TUNER_THOMSON_DTT7611 60 /* DViCO FusionHDTV 3 Gold-T */105105+#define TUNER_THOMSON_DTT761X 60 /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */106106#define TUNER_TENA_9533_DI 61107107#define TUNER_TEA5767 62 /* Only FM Radio Tuner */108108#define TUNER_PHILIPS_FMD1216ME_MK3 63···115115#define TUNER_PHILIPS_TUV1236D 68 /* ATI HDTV Wonder */116116#define TUNER_TNF_5335MF 69 /* Sabrent Bt848 */117117118118-#define NOTUNER 0119119-#define PAL 1 /* PAL_BG */120120-#define PAL_I 2121121-#define NTSC 3122122-#define SECAM 4123123-#define ATSC 5124124-#define RADIO 6125125-126126-#define NoTuner 0127127-#define Philips 1128128-#define TEMIC 2129129-#define Sony 3130130-#define Alps 4131131-#define LGINNOTEK 5132132-#define SHARP 6133133-#define Samsung 7134134-#define Microtune 8135135-#define HITACHI 9136136-#define Panasonic 10137137-#define TCL 11138138-#define THOMSON 12139139-140140-#define TUNER_SET_TYPE_ADDR _IOW('T',3,int)141141-#define TUNER_SET_STANDBY _IOW('T',4,int)142142-#define TDA9887_SET_CONFIG _IOW('t',5,int)143143-144118/* tv card specific */145145-# define TDA9887_PRESENT (1<<0)146146-# define TDA9887_PORT1_INACTIVE (1<<1)147147-# define TDA9887_PORT2_INACTIVE (1<<2)148148-# define TDA9887_QSS (1<<3)149149-# define TDA9887_INTERCARRIER (1<<4)150150-# define TDA9887_PORT1_ACTIVE (1<<5)151151-# define TDA9887_PORT2_ACTIVE (1<<6)152152-# define TDA9887_INTERCARRIER_NTSC (1<<7)119119+#define TDA9887_PRESENT (1<<0)120120+#define TDA9887_PORT1_INACTIVE (1<<1)121121+#define TDA9887_PORT2_INACTIVE (1<<2)122122+#define TDA9887_QSS (1<<3)123123+#define TDA9887_INTERCARRIER (1<<4)124124+#define TDA9887_PORT1_ACTIVE (1<<5)125125+#define TDA9887_PORT2_ACTIVE (1<<6)126126+#define TDA9887_INTERCARRIER_NTSC (1<<7)127127+/* Tuner takeover point adjustment, in dB, -16 <= top <= 15 */128128+#define TDA9887_TOP_MASK (0x3f << 8)129129+#define TDA9887_TOP_SET (1 << 13)130130+#define TDA9887_TOP(top) (TDA9887_TOP_SET | (((16 + (top)) & 0x1f) << 8))131131+153132/* config options */154154-# define TDA9887_DEEMPHASIS_MASK (3<<16)155155-# define TDA9887_DEEMPHASIS_NONE (1<<16)156156-# define TDA9887_DEEMPHASIS_50 (2<<16)157157-# define TDA9887_DEEMPHASIS_75 (3<<16)158158-# define TDA9887_AUTOMUTE (1<<18)133133+#define TDA9887_DEEMPHASIS_MASK (3<<16)134134+#define TDA9887_DEEMPHASIS_NONE (1<<16)135135+#define TDA9887_DEEMPHASIS_50 (2<<16)136136+#define TDA9887_DEEMPHASIS_75 (3<<16)137137+#define TDA9887_AUTOMUTE (1<<18)159138160139#ifdef __KERNEL__161140···146167 T_STANDBY = 1 << 31147168};148169170170+/* Older boards only had a single tuner device. Nowadays multiple tuner171171+ devices may be present on a single board. Using TUNER_SET_TYPE_ADDR172172+ to pass the tuner_setup structure it is possible to setup each tuner173173+ device in turn.174174+175175+ Since multiple devices may be present it is no longer sufficient to176176+ send a command to a single i2c device. Instead you should broadcast177177+ the command to all i2c devices.178178+179179+ By setting the mode_mask correctly you can select which commands are180180+ accepted by a specific tuner device. For example, set mode_mask to181181+ T_RADIO if the device is a radio-only tuner. That specific tuner will182182+ only accept commands when the tuner is in radio mode and ignore them183183+ when the tuner is set to TV mode.184184+ */185185+149186struct tuner_setup {150150- unsigned short addr;151151- unsigned int type;152152- unsigned int mode_mask;187187+ unsigned short addr; /* I2C address */188188+ unsigned int type; /* Tuner type */189189+ unsigned int mode_mask; /* Allowed tuner modes */153190};154191155192struct tuner {···202207 void (*standby)(struct i2c_client *c);203208};204209205205-extern unsigned int tuner_debug;206210extern unsigned const int tuner_count;207211208212extern int microtune_init(struct i2c_client *c);···213219214220#define tuner_warn(fmt, arg...) do {\215221 printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \216216- t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0)222222+ i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)217223#define tuner_info(fmt, arg...) do {\218224 printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \219219- t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0)225225+ i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)220226#define tuner_dbg(fmt, arg...) do {\221221- if (tuner_debug) \222222- printk(KERN_DEBUG "%s %d-%04x: " fmt, \223223- t->i2c.driver->driver.name, \224224- t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0)227227+ extern int debug; \228228+ if (debug) \229229+ printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \230230+ i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)225231226232#endif /* __KERNEL__ */227233
+76-9
include/media/v4l2-common.h
···2626#ifndef V4L2_COMMON_H_2727#define V4L2_COMMON_H_28282929-/* VIDIOC_INT_AUDIO_CLOCK_FREQ */3030-enum v4l2_audio_clock_freq {3131- V4L2_AUDCLK_32_KHZ = 32000,3232- V4L2_AUDCLK_441_KHZ = 44100,3333- V4L2_AUDCLK_48_KHZ = 48000,3434-};2929+/* v4l debugging and diagnostics */3030+3131+/* Common printk constucts for v4l-i2c drivers. These macros create a unique3232+ prefix consisting of the driver name, the adapter number and the i2c3333+ address. */3434+#define v4l_printk(level, name, adapter, addr, fmt, arg...) \3535+ printk(level "%s %d-%04x: " fmt, name, i2c_adapter_id(adapter), addr , ## arg)3636+3737+#define v4l_client_printk(level, client, fmt, arg...) \3838+ v4l_printk(level, (client)->driver->driver.name, (client)->adapter, \3939+ (client)->addr, fmt , ## arg)4040+4141+#define v4l_err(client, fmt, arg...) \4242+ v4l_client_printk(KERN_ERR, client, fmt , ## arg)4343+4444+#define v4l_warn(client, fmt, arg...) \4545+ v4l_client_printk(KERN_WARNING, client, fmt , ## arg)4646+4747+#define v4l_info(client, fmt, arg...) \4848+ v4l_client_printk(KERN_INFO, client, fmt , ## arg)4949+5050+/* These three macros assume that the debug level is set with a module5151+ parameter called 'debug'. */5252+#define v4l_dbg(level, client, fmt, arg...) \5353+ do { \5454+ extern int debug; \5555+ if (debug >= (level)) \5656+ v4l_client_printk(KERN_DEBUG, client, fmt , ## arg); \5757+ } while (0)5858+5959+/* Prints the ioctl in a human-readable format */6060+extern void v4l_printk_ioctl(unsigned int cmd);6161+6262+/* Use this macro for non-I2C drivers. Pass the driver name as the first arg. */6363+#define v4l_print_ioctl(name, cmd) \6464+ do { \6565+ printk(KERN_DEBUG "%s: ", name); \6666+ v4l_printk_ioctl(cmd); \6767+ } while (0)6868+6969+/* Use this macro in I2C drivers where 'client' is the struct i2c_client7070+ pointer */7171+#define v4l_i2c_print_ioctl(client, cmd) \7272+ do { \7373+ v4l_client_printk(KERN_DEBUG, client, ""); \7474+ v4l_printk_ioctl(cmd); \7575+ } while (0)7676+7777+/* ------------------------------------------------------------------------- */7878+7979+/* Internal ioctls */35803681/* VIDIOC_INT_G_REGISTER and VIDIOC_INT_S_REGISTER */3782struct v4l2_register {···11570 V4L2_IDENT_CX25843 = 243,11671};117727373+/* audio ioctls */7474+/* v4l device was opened in Radio mode */7575+#define AUDC_SET_RADIO _IO('d',88)7676+/* select from TV,radio,extern,MUTE */7777+#define AUDC_SET_INPUT _IOW('d',89,int)7878+7979+/* tuner ioctls */8080+/* Sets tuner type and its I2C addr */8181+#define TUNER_SET_TYPE_ADDR _IOW('d',90,int)8282+/* Puts tuner on powersaving state, disabling it, except for i2c */8383+#define TUNER_SET_STANDBY _IOW('d',91,int)8484+/* Sets tda9887 specific stuff, like port1, port2 and qss */8585+#define TDA9887_SET_CONFIG _IOW('d',92,int)8686+11887/* only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */11988#define VIDIOC_INT_S_REGISTER _IOR ('d', 100, struct v4l2_register)12089#define VIDIOC_INT_G_REGISTER _IOWR('d', 101, struct v4l2_register)···13677/* Reset the I2C chip */13778#define VIDIOC_INT_RESET _IO ('d', 102)13879139139-/* Set the frequency of the audio clock output.8080+/* Set the frequency (in Hz) of the audio clock output.14081 Used to slave an audio processor to the video decoder, ensuring that audio141141- and video remain synchronized. */142142-#define VIDIOC_INT_AUDIO_CLOCK_FREQ _IOR ('d', 103, enum v4l2_audio_clock_freq)8282+ and video remain synchronized.8383+ Usual values for the frequency are 48000, 44100 or 32000 Hz.8484+ If the frequency is not supported, then -EINVAL is returned. */8585+#define VIDIOC_INT_AUDIO_CLOCK_FREQ _IOW ('d', 103, u32)1438614487/* Video decoders that support sliced VBI need to implement this ioctl.14588 Field p of the v4l2_sliced_vbi_line struct is set to the start of the VBI···167106/* Returns the chip identifier or V4L2_IDENT_UNKNOWN if no identification can168107 be made. */169108#define VIDIOC_INT_G_CHIP_IDENT _IOR ('d', 107, enum v4l2_chip_ident *)109109+110110+/* Sets I2S speed in bps. This is used to provide a standard way to select I2S111111+ clock used by driving digital audio streams at some board designs.112112+ Usual values for the frequency are 1024000 and 2048000.113113+ If the frequency is not supported, then -EINVAL is returned. */114114+#define VIDIOC_INT_I2S_CLOCK_FREQ _IOW ('d', 108, u32)170115171116#endif /* V4L2_COMMON_H_ */