From 5b513ea826a257bfa13e6083edd93815242f3730 Mon Sep 17 00:00:00 2001 From: "xyzzy@t2.domain.actdsltmp" Date: Thu, 30 Mar 2006 19:53:32 +0100 Subject: Fix memory leak in dvr open From: Trent Piepho The dvr device could be opened multiple times simultaneously in O_RDONLY mode. Each open after the first would allocate a new dvr buffer (1880 KB) and leak the old buffer. The first close would de-allocate the dvr buffer and cause all other open dvrs to stop working. This patch allows only a single O_RDONLY open of the drv device, as per the API specification. Multiple O_WRONLY opens are still allowed and don't appear to cause any problems. Signed-off-by: Trent Piepho Signed-off-by: Andrew de Quincey --- linux/drivers/media/dvb/dvb-core/dmxdev.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dmxdev.c b/linux/drivers/media/dvb/dvb-core/dmxdev.c index 09e96e9dd..04578df3f 100644 --- a/linux/drivers/media/dvb/dvb-core/dmxdev.c +++ b/linux/drivers/media/dvb/dvb-core/dmxdev.c @@ -141,12 +141,18 @@ static int dvb_dvr_open(struct inode *inode, struct file *file) } if ((file->f_flags & O_ACCMODE) == O_RDONLY) { - void *mem = vmalloc(DVR_BUFFER_SIZE); + void *mem; + if (!dvbdev->readers) { + mutex_unlock(&dmxdev->mutex); + return -EBUSY; + } + mem = vmalloc(DVR_BUFFER_SIZE); if (!mem) { mutex_unlock(&dmxdev->mutex); return -ENOMEM; } dvb_ringbuffer_init(&dmxdev->dvr_buffer, mem, DVR_BUFFER_SIZE); + dvbdev->readers--; } if ((file->f_flags & O_ACCMODE) == O_WRONLY) { @@ -184,6 +190,7 @@ static int dvb_dvr_release(struct inode *inode, struct file *file) dmxdev->dvr_orig_fe); } if ((file->f_flags & O_ACCMODE) == O_RDONLY) { + dvbdev->readers++; if (dmxdev->dvr_buffer.data) { void *mem = dmxdev->dvr_buffer.data; mb(); @@ -1029,8 +1036,7 @@ static struct file_operations dvb_dvr_fops = { static struct dvb_device dvbdev_dvr = { .priv = NULL, - .users = 1, - .writers = 1, + .readers = 1, .fops = &dvb_dvr_fops }; -- cgit v1.2.3 From ec2c10b2d67b9015a2f4e174d482a4b076d38507 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Thu, 30 Mar 2006 19:53:35 +0100 Subject: Fix budget-av CAM reset From: Andrew de Quincey Unfortunately on the budget-av board, the CAM reset line is tied to the frontend reset line, so resetting the CAM also zaps the frontend. This breaks the tda1004x at least, and causes it to fail to tune until the budget-av module is reloaded. This patch adds an exported function to dvb_frontend that allows a card to forcibly reinitialise a frontend. The budget-av now does this on CAM reset, which corrects this problem. Note: other CA interface implementations (e.g. budget-ci) do not need this since they do not tie the CAM reset line to the frontend reset line. Signed-off-by: Andrew de Quincey --- linux/drivers/media/dvb/dvb-core/dvb_frontend.c | 18 +++++++++++++++++- linux/drivers/media/dvb/dvb-core/dvb_frontend.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c index 55a91bb18..875033330 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -105,6 +105,7 @@ struct dvb_frontend_private { fe_status_t status; unsigned long tune_mode_flags; unsigned int delay; + unsigned int reinitialise; /* swzigzag values */ unsigned int state; @@ -121,6 +122,7 @@ struct dvb_frontend_private { unsigned int check_wrapped; }; +static void dvb_frontend_wakeup(struct dvb_frontend *fe); static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) { @@ -213,6 +215,15 @@ static void dvb_frontend_init(struct dvb_frontend *fe) fe->ops->init(fe); } +void dvb_frontend_reinitialise(struct dvb_frontend *fe) +{ + struct dvb_frontend_private *fepriv = fe->frontend_priv; + + fepriv->reinitialise = 1; + dvb_frontend_wakeup(fe); +} +EXPORT_SYMBOL(dvb_frontend_reinitialise); + static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepriv, int locked) { int q2; @@ -505,8 +516,8 @@ static int dvb_frontend_thread(void *data) fepriv->quality = 0; fepriv->delay = 3*HZ; fepriv->status = 0; - dvb_frontend_init(fe); fepriv->wakeup = 0; + fepriv->reinitialise = 1; while (1) { up(&fepriv->sem); /* is locked when we enter the thread... */ @@ -530,6 +541,11 @@ static int dvb_frontend_thread(void *data) if (down_interruptible(&fepriv->sem)) break; + if (fepriv->reinitialise) { + dvb_frontend_init(fe); + fepriv->reinitialise = 0; + } + /* do an iteration of the tuning loop */ if (fe->ops->tune) { /* have we been asked to retune? */ diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h index d5aee5ad6..5926a3b74 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h @@ -112,6 +112,8 @@ extern int dvb_register_frontend(struct dvb_adapter* dvb, extern int dvb_unregister_frontend(struct dvb_frontend* fe); +extern void dvb_frontend_reinitialise(struct dvb_frontend *fe); + extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec); extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime); -- cgit v1.2.3 From 1022e152b0486dbbc19e49c9bbbdec12a0637418 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 2 Apr 2006 09:07:01 -0300 Subject: [PATCH] mark f_ops const in the inode From: Arjan van de Ven Mark the f_ops members of inodes as const, as well as fix the ripple-through this causes by places that copy this f_ops and then "do stuff" with it. kernel-sync Signed-off-by: Arjan van de Ven Signed-off-by: Alexey Dobriyan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- linux/drivers/media/dvb/dvb-core/dvbdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.c b/linux/drivers/media/dvb/dvb-core/dvbdev.c index 123ea8344..85d6a6c65 100644 --- a/linux/drivers/media/dvb/dvb-core/dvbdev.c +++ b/linux/drivers/media/dvb/dvb-core/dvbdev.c @@ -93,7 +93,7 @@ static int dvb_device_open(struct inode *inode, struct file *file) if (dvbdev && dvbdev->fops) { int err = 0; - struct file_operations *old_fops; + const struct file_operations *old_fops; file->private_data = dvbdev; old_fops = file->f_op; -- cgit v1.2.3 From cc7536722d24a3deec8ac51616e26f5dc267f112 Mon Sep 17 00:00:00 2001 From: Michael Krufky Date: Mon, 3 Apr 2006 23:49:27 -0400 Subject: fix warning: assignment discards qualifiers from pointer target type From: Michael Krufky The following warning in all kernels < 2.6.17 is caused by changeset a875912f0aada25949e3201bcd97e177040fa782 : http://linuxtv.org/hg/v4l-dvb?cmd=changeset;node=a875912f0aad videodev.c: In function 'video_open': videodev.c:131: warning: assignment discards qualifiers from pointer target type videodev.c:136: warning: assignment discards qualifiers from pointer target type dvbdev.c: In function 'dvb_device_open': dvbdev.c:105: warning: assignment discards qualifiers from pointer target type This changeset restores backwards-compatability. Signed-off-by: Michael Krufky --- linux/drivers/media/dvb/dvb-core/dvbdev.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.c b/linux/drivers/media/dvb/dvb-core/dvbdev.c index 85d6a6c65..9b824c31b 100644 --- a/linux/drivers/media/dvb/dvb-core/dvbdev.c +++ b/linux/drivers/media/dvb/dvb-core/dvbdev.c @@ -93,7 +93,11 @@ static int dvb_device_open(struct inode *inode, struct file *file) if (dvbdev && dvbdev->fops) { int err = 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17) const struct file_operations *old_fops; +#else + struct file_operations *old_fops; +#endif file->private_data = dvbdev; old_fops = file->f_op; -- cgit v1.2.3 From 90f7453adee2bcad39c6630b760358eb799f238d Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Tue, 4 Apr 2006 13:41:47 +0100 Subject: Fix mutex in dvb_register_device to work. From: Andrew de Quincey This mutex is meant to stop two devices getting the same ID. dvbdev_get_free_id() scans the list of already allocated devices to find a free id. Unfortunately, since the mutex is unlocked before the card is added to the above list, it is still possible for two of them to get the same id. Solution: move the mutex after the list_add. Its debatable whether this mutex lock is actually needed, but I'm unwilling to just remove it in case something does depend on it. Signed-off-by: Andrew de Quincey --- linux/drivers/media/dvb/dvb-core/dvbdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.c b/linux/drivers/media/dvb/dvb-core/dvbdev.c index 9b824c31b..041ed7fd1 100644 --- a/linux/drivers/media/dvb/dvb-core/dvbdev.c +++ b/linux/drivers/media/dvb/dvb-core/dvbdev.c @@ -230,8 +230,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, return -ENOMEM; } - mutex_unlock(&dvbdev_register_lock); - memcpy(dvbdev, template, sizeof(struct dvb_device)); dvbdev->type = type; dvbdev->id = id; @@ -242,6 +240,8 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, list_add_tail (&dvbdev->list_head, &adap->device_list); + mutex_unlock(&dvbdev_register_lock); + devfs_mk_cdev(MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), S_IFCHR | S_IRUSR | S_IWUSR, "dvb/adapter%d/%s%d", adap->num, dnames[type], id); -- cgit v1.2.3 From 7c0ef076eb4257ba9803b2312a5e734101900d4b Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Wed, 5 Apr 2006 16:36:51 -0300 Subject: Remove DMX_GET_EVENT and associated data structures From: Andreas Oberritter The ioctl DMX_GET_EVENT has never been implemented. I guess no software is using it because of its lack of implementation. Future software won't use it, too, because this API doesn't make much sense the way it is: Frontend events have their own different API. Scrambling events can't be generated in a useful way by the hardware I know of. Signed-off-by: Andreas Oberritter Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/dvb/dvb-core/dmxdev.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dmxdev.c b/linux/drivers/media/dvb/dvb-core/dmxdev.c index 04578df3f..988499dfd 100644 --- a/linux/drivers/media/dvb/dvb-core/dmxdev.c +++ b/linux/drivers/media/dvb/dvb-core/dmxdev.c @@ -872,9 +872,6 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file, mutex_unlock(&dmxdevfilter->mutex); break; - case DMX_GET_EVENT: - break; - case DMX_GET_PES_PIDS: if (!dmxdev->demux->get_pes_pids) { ret = -EINVAL; -- cgit v1.2.3 From c2f7c5def32f35793a62672ab9cbb40e61e371f5 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Thu, 6 Apr 2006 18:32:23 +0100 Subject: Set tone/voltage again if the frontend was reinitialised --- linux/drivers/media/dvb/dvb-core/dvb_frontend.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c index 875033330..62063b00d 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -106,6 +106,8 @@ struct dvb_frontend_private { unsigned long tune_mode_flags; unsigned int delay; unsigned int reinitialise; + int tone; + int voltage; /* swzigzag values */ unsigned int state; @@ -543,6 +545,12 @@ static int dvb_frontend_thread(void *data) if (fepriv->reinitialise) { dvb_frontend_init(fe); + if (fepriv->tone != -1) { + fe->ops->set_tone(fe, fepriv->tone); + } + if (fepriv->voltage != -1) { + fe->ops->set_voltage(fe, fepriv->voltage); + } fepriv->reinitialise = 0; } @@ -794,6 +802,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, case FE_SET_TONE: if (fe->ops->set_tone) { err = fe->ops->set_tone(fe, (fe_sec_tone_mode_t) parg); + fepriv->tone = (fe_sec_tone_mode_t) parg; fepriv->state = FESTATE_DISEQC; fepriv->status = 0; } @@ -802,6 +811,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, case FE_SET_VOLTAGE: if (fe->ops->set_voltage) { err = fe->ops->set_voltage(fe, (fe_sec_voltage_t) parg); + fepriv->voltage = (fe_sec_voltage_t) parg; fepriv->state = FESTATE_DISEQC; fepriv->status = 0; } @@ -1001,6 +1011,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) /* normal tune mode when opened R/W */ fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT; + fepriv->tone = -1; + fepriv->voltage = -1; } return ret; -- cgit v1.2.3 From c3bf1b32148a59bc0a8e58c126d642236c7febc1 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Mon, 10 Apr 2006 09:27:37 -0300 Subject: Add sysfs device links to dvb devices From: Andrew de Quincey Currently in /sys/class/dvb/dvbX.demuxY/ we have: dev uevent With the patch, we have (for a PCI DVB device): dev device -> ../../../devices/pci0000:00/0000:00:1e.0/0000:03:0d.0 uevent So userspace tools can (finally) work out which physical device a DVB adapter refers to. Previously you had to kinda look through dmesg and hope that it hadn't been dumped out of the buffer. This makes debugging a lot easier if the system has been up for a long time! This is done by adding an extra 'struct device *' parameter to dvb_register_adapter(). It will work with any kind of standard linux 'device'. Additionally, if someone has an embedded system which does things differently, they can simply supply 'NULL' and the behaviour will be as before - the link will simply not appear. Signed-off-by: Andrew de Quincey Ack'd-by: Manu Abraham Acked-by: Michael Krufky --- linux/drivers/media/dvb/dvb-core/dvbdev.c | 5 +++-- linux/drivers/media/dvb/dvb-core/dvbdev.h | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.c b/linux/drivers/media/dvb/dvb-core/dvbdev.c index 041ed7fd1..66d9ffdb4 100644 --- a/linux/drivers/media/dvb/dvb-core/dvbdev.c +++ b/linux/drivers/media/dvb/dvb-core/dvbdev.c @@ -247,7 +247,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, "dvb/adapter%d/%s%d", adap->num, dnames[type], id); class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), - NULL, "dvb%d.%s%d", adap->num, dnames[type], id); + adap->device, "dvb%d.%s%d", adap->num, dnames[type], id); dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", adap->num, dnames[type], id, nums2minor(adap->num, type, id), @@ -296,7 +296,7 @@ skip: } -int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct module *module) +int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct module *module, struct device *device) { int num; @@ -317,6 +317,7 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu adap->num = num; adap->name = name; adap->module = module; + adap->device = device; list_add_tail (&adap->list_head, &dvb_adapter_list); diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.h b/linux/drivers/media/dvb/dvb-core/dvbdev.h index 9f5f984cc..9ec9cecf5 100644 --- a/linux/drivers/media/dvb/dvb-core/dvbdev.h +++ b/linux/drivers/media/dvb/dvb-core/dvbdev.h @@ -52,6 +52,8 @@ struct dvb_adapter { u8 proposed_mac [6]; void* priv; + struct device *device; + struct module *module; }; @@ -77,7 +79,7 @@ struct dvb_device { }; -extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module); +extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module, struct device *device); extern int dvb_unregister_adapter (struct dvb_adapter *adap); extern int dvb_register_device (struct dvb_adapter *adap, -- cgit v1.2.3 From 9bf95407c2d498d0a55fa10b54379ae9871bfe1a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 11 Apr 2006 10:21:37 -0300 Subject: Fix a type error in dvb_frontend.c From: Uwe Bugla Signed-off-by: Uwe Bugla Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/dvb/dvb-core/dvb_frontend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c index 62063b00d..12e890e06 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -56,7 +56,7 @@ MODULE_PARM_DESC(dvb_force_auto_inversion, "0: normal (default), 1: INVERSION_AU module_param(dvb_override_tune_delay, int, 0644); MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt"); module_param(dvb_powerdown_on_sleep, int, 0644); -MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB volatage off on sleep (default)"); +MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB voltage off on sleep (default)"); #define dprintk if (dvb_frontend_debug) printk -- cgit v1.2.3 From 0b7b4dd67a96eb2d7e89b62e39266c073a925f3d Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Tue, 18 Apr 2006 21:47:09 +0100 Subject: DVB core changes for PLL refactoring From: Andrew de Quincey Add tuner_ops structure. Add calls into dvb_frontend to support the new tuner architecture. Signed-off-by: Andrew de Quincey --- linux/drivers/media/dvb/dvb-core/dvb_frontend.c | 15 ++++ linux/drivers/media/dvb/dvb-core/dvb_frontend.h | 112 ++++++++++++++++++++++++ 2 files changed, 127 insertions(+) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c index 12e890e06..bc752929f 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -215,6 +215,11 @@ static void dvb_frontend_init(struct dvb_frontend *fe) if (fe->ops->init) fe->ops->init(fe); + if (fe->ops->tuner_ops.init) { + fe->ops->tuner_ops.init(fe); + if (fe->ops->i2c_gate_ctrl) + fe->ops->i2c_gate_ctrl(fe, 0); + } } void dvb_frontend_reinitialise(struct dvb_frontend *fe) @@ -577,6 +582,11 @@ static int dvb_frontend_thread(void *data) if (dvb_powerdown_on_sleep) if (fe->ops->set_voltage) fe->ops->set_voltage(fe, SEC_VOLTAGE_OFF); + if (fe->ops->tuner_ops.sleep) { + fe->ops->tuner_ops.sleep(fe); + if (fe->ops->i2c_gate_ctrl) + fe->ops->i2c_gate_ctrl(fe, 0); + } if (fe->ops->sleep) fe->ops->sleep(fe); } @@ -1091,6 +1101,11 @@ int dvb_unregister_frontend(struct dvb_frontend* fe) mutex_lock(&frontend_mutex); dvb_unregister_device (fepriv->dvbdev); dvb_frontend_stop (fe); + if (fe->ops->tuner_ops.release) { + fe->ops->tuner_ops.release(fe); + if (fe->ops->i2c_gate_ctrl) + fe->ops->i2c_gate_ctrl(fe, 0); + } if (fe->ops->release) fe->ops->release(fe); else diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h index 5926a3b74..e0148a9e6 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h @@ -49,6 +49,115 @@ struct dvb_frontend_tune_settings { struct dvb_frontend; +struct dvb_tuner_info { + char name[128]; + + u32 frequency_min; + u32 frequency_max; + u32 frequency_step; + + u32 bandwidth_min; + u32 bandwidth_max; + u32 bandwidth_step; +}; + +struct dvb_tuner_ops { + /** + * Description of the tuner. + */ + struct dvb_tuner_info info; + + /** + * Cleanup an attached tuner. + * + * @param fe dvb_frontend structure to clean it up from. + * @return 0 on success, <0 on failure. + */ + int (*release)(struct dvb_frontend *fe); + + /** + * Initialise a tuner. + * + * @param fe dvb_frontend structure. + * @return 0 on success, <0 on failure. + */ + int (*init)(struct dvb_frontend *fe); + + /** + * Set a tuner into low power mode. + * + * @param fe dvb_frontend structure. + * @return 0 on success, <0 on failure. + */ + int (*sleep)(struct dvb_frontend *fe); + + /** + * This is for simple PLLs - set all parameters in one go. + * + * @param fe The dvb_frontend structure. + * @param p The parameters to set. + * @return 0 on success, <0 on failure. + */ + int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p); + + /** + * This is support for demods like the mt352 - fills out the supplied buffer with what to write. + * + * @param fe The dvb_frontend structure. + * @param p The parameters to set. + * @param buf The buffer to fill with data. For an i2c tuner, the first byte should be the tuner i2c address in linux format. + * @param buf_len Size of buffer in bytes. + * @return Number of bytes used, or <0 on failure. + */ + int (*pllbuf)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len); + + /** + * Get the frequency the tuner was actually set to. + * + * @param fe The dvb_frontend structure. + * @param frequency Where to put it. + * @return 0 on success, or <0 on failure. + */ + int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency); + + /** + * Get the bandwidth the tuner was actually set to. + * + * @param fe The dvb_frontend structure. + * @param bandwidth Where to put it. + * @return 0 on success, or <0 on failure. + */ + int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth); + + /** + * Get the tuner's status. + * + * @param fe The dvb_frontend structure. + * @param status Where to put it. + * @return 0 on success, or <0 on failure. + */ +#define TUNER_STATUS_LOCKED 1 + int (*get_status)(struct dvb_frontend *fe, u32 *status); + + /** + * Set the frequency of the tuner - for complex tuners. + * + * @param fe The dvb_frontend structure. + * @param frequency What to set. + * @return 0 on success, or <0 on failure. + */ + int (*set_frequency)(struct dvb_frontend *fe, u32 frequency); + + /** + * Set the bandwidth of the tuner - for complex tuners. + * + * @param fe The dvb_frontend structure. + * @param bandwidth What to set. + * @return 0 on success, or <0 on failure. + */ + int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth); +}; + struct dvb_frontend_ops { struct dvb_frontend_info info; @@ -86,6 +195,8 @@ struct dvb_frontend_ops { int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg); int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd); int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable); + + struct dvb_tuner_ops tuner_ops; }; #define MAX_EVENT 8 @@ -103,6 +214,7 @@ struct dvb_frontend { struct dvb_frontend_ops* ops; struct dvb_adapter *dvb; void* demodulator_priv; + void* tuner_priv; void* frontend_priv; void* misc_priv; }; -- cgit v1.2.3 From b641e6d90fe3ff6e71a613888d1c1ec22842adda Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Wed, 19 Apr 2006 01:37:20 +0100 Subject: Trim documentation From: Andrew de Quincey Trim excess documentation down to the essentials. Signed-off-by: Andrew de Quincey --- linux/drivers/media/dvb/dvb-core/dvb_frontend.h | 85 ++----------------------- 1 file changed, 7 insertions(+), 78 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h index e0148a9e6..05ec9954b 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h @@ -62,99 +62,28 @@ struct dvb_tuner_info { }; struct dvb_tuner_ops { - /** - * Description of the tuner. - */ + struct dvb_tuner_info info; - /** - * Cleanup an attached tuner. - * - * @param fe dvb_frontend structure to clean it up from. - * @return 0 on success, <0 on failure. - */ int (*release)(struct dvb_frontend *fe); - - /** - * Initialise a tuner. - * - * @param fe dvb_frontend structure. - * @return 0 on success, <0 on failure. - */ int (*init)(struct dvb_frontend *fe); - - /** - * Set a tuner into low power mode. - * - * @param fe dvb_frontend structure. - * @return 0 on success, <0 on failure. - */ int (*sleep)(struct dvb_frontend *fe); - /** - * This is for simple PLLs - set all parameters in one go. - * - * @param fe The dvb_frontend structure. - * @param p The parameters to set. - * @return 0 on success, <0 on failure. - */ + /** This is for simple PLLs - set all parameters in one go. */ int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p); - /** - * This is support for demods like the mt352 - fills out the supplied buffer with what to write. - * - * @param fe The dvb_frontend structure. - * @param p The parameters to set. - * @param buf The buffer to fill with data. For an i2c tuner, the first byte should be the tuner i2c address in linux format. - * @param buf_len Size of buffer in bytes. - * @return Number of bytes used, or <0 on failure. - */ - int (*pllbuf)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len); - - /** - * Get the frequency the tuner was actually set to. - * - * @param fe The dvb_frontend structure. - * @param frequency Where to put it. - * @return 0 on success, or <0 on failure. - */ - int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency); + /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */ + int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len); - /** - * Get the bandwidth the tuner was actually set to. - * - * @param fe The dvb_frontend structure. - * @param bandwidth Where to put it. - * @return 0 on success, or <0 on failure. - */ + int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency); int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth); - /** - * Get the tuner's status. - * - * @param fe The dvb_frontend structure. - * @param status Where to put it. - * @return 0 on success, or <0 on failure. - */ #define TUNER_STATUS_LOCKED 1 int (*get_status)(struct dvb_frontend *fe, u32 *status); - /** - * Set the frequency of the tuner - for complex tuners. - * - * @param fe The dvb_frontend structure. - * @param frequency What to set. - * @return 0 on success, or <0 on failure. - */ + /** These are provided seperately from set_params in order to facilitate silicon + * tuners which require sophisticated tuning loops, controlling each parameter seperately. */ int (*set_frequency)(struct dvb_frontend *fe, u32 frequency); - - /** - * Set the bandwidth of the tuner - for complex tuners. - * - * @param fe The dvb_frontend structure. - * @param bandwidth What to set. - * @return 0 on success, or <0 on failure. - */ int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth); }; -- cgit v1.2.3 From 9a31a0d73f490c724252a18e59a5313561380c8c Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 2 May 2006 09:01:13 -0300 Subject: Core: ULE fixes and RFC4326 additions From: Christian Praehauser Fix some problems regarding support for Unidirectional Lightweight Encapsulation (ULE) in dvbnet.c. The original ULE code was based on a draft. In the meantime, ULE has been published in RFC 4326 (ftp://ftp.rfc-editor.org/in-notes/rfc4326.txt). With these fixes, and some additions (which are included in the patch), the decaps code should now be complient to RFC4326. Signed-off-by: Christian Praehauser Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/dvb/dvb-core/dvb_net.c | 230 +++++++++++++++++++---------- 1 file changed, 154 insertions(+), 76 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c index 5f3c9b71f..a1989e336 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_net.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c @@ -12,7 +12,7 @@ * Hilmar Linder * and Wolfram Stering * - * ULE Decaps according to draft-ietf-ipdvb-ule-03.txt. + * ULE Decaps according to RFC 4326. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -42,6 +42,9 @@ * Bugfixes and robustness improvements. * Filtering on dest MAC addresses, if present (D-Bit = 0) * ULE_DEBUG compile-time option. + * Apr 2006: cp v3: Bugfixes and compliency with RFC 4326 (ULE) by + * Christian Praehauser , + * Paris Lodron University of Salzburg. */ /* @@ -49,9 +52,6 @@ * * Unloading does not work for 2.6.9 kernels: a refcount doesn't go to zero. * - * TS_FEED callback is called once for every single TS cell although it is - * registered (in dvb_net_feed_start()) for 100 TS cells (used for dvb_net_ule()). - * */ #include @@ -92,6 +92,9 @@ static inline __u32 iov_crc32( __u32 c, struct kvec *iov, unsigned int cnt ) #ifdef ULE_DEBUG +#define MAC_ADDR_PRINTFMT "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x" +#define MAX_ADDR_PRINTFMT_ARGS(macap) (macap)[0],(macap)[1],(macap)[2],(macap)[3],(macap)[4],(macap)[5] + #define isprint(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) static void hexdump( const unsigned char *buf, unsigned short len ) @@ -221,6 +224,8 @@ static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, #define ULE_TEST 0 #define ULE_BRIDGED 1 +#define ULE_OPTEXTHDR_PADDING 0 + static int ule_test_sndu( struct dvb_net_priv *p ) { return -1; @@ -228,14 +233,28 @@ static int ule_test_sndu( struct dvb_net_priv *p ) static int ule_bridged_sndu( struct dvb_net_priv *p ) { - /* BRIDGE SNDU handling sucks in draft-ietf-ipdvb-ule-03.txt. - * This has to be the last extension header, otherwise it won't work. - * Blame the authors! + struct ethhdr *hdr = (struct ethhdr*) p->ule_next_hdr; + if(ntohs(hdr->h_proto) < 1536) { + int framelen = p->ule_sndu_len - ((p->ule_next_hdr+sizeof(struct ethhdr)) - p->ule_skb->data); + /* A frame Type < 1536 for a bridged frame, introduces a LLC Length field. */ + if(framelen != ntohs(hdr->h_proto)) { + return -1; + } + } + /* Note: + * From RFC4326: + * "A bridged SNDU is a Mandatory Extension Header of Type 1. + * It must be the final (or only) extension header specified in the header chain of a SNDU." + * The 'ule_bridged' flag will cause the extension header processing loop to terminate. */ p->ule_bridged = 1; return 0; } +static int ule_exthdr_padding(struct dvb_net_priv *p) +{ + return 0; +} /** Handle ULE extension headers. * Function is called after a successful CRC32 verification of an ULE SNDU to complete its decoding. @@ -249,7 +268,8 @@ static int handle_one_ule_extension( struct dvb_net_priv *p ) { [0] = ule_test_sndu, [1] = ule_bridged_sndu, [2] = NULL, }; /* Table of optional extension header handlers. The header type is the index. */ - static int (*ule_optional_ext_handlers[255])( struct dvb_net_priv *p ) = { NULL, }; + static int (*ule_optional_ext_handlers[255])( struct dvb_net_priv *p ) = + { [0] = ule_exthdr_padding, [1] = NULL, }; int ext_len = 0; unsigned char hlen = (p->ule_sndu_type & 0x0700) >> 8; @@ -260,25 +280,31 @@ static int handle_one_ule_extension( struct dvb_net_priv *p ) /* Mandatory extension header */ if (ule_mandatory_ext_handlers[htype]) { ext_len = ule_mandatory_ext_handlers[htype]( p ); - p->ule_next_hdr += ext_len; - if (! p->ule_bridged) { - p->ule_sndu_type = ntohs( *(unsigned short *)p->ule_next_hdr ); - p->ule_next_hdr += 2; - } else { - p->ule_sndu_type = ntohs( *(unsigned short *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN)) ); - /* This assures the extension handling loop will terminate. */ + if(ext_len >= 0) { + p->ule_next_hdr += ext_len; + if (!p->ule_bridged) { + p->ule_sndu_type = ntohs(*(unsigned short *)p->ule_next_hdr); + p->ule_next_hdr += 2; + } else { + p->ule_sndu_type = ntohs(*(unsigned short *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN))); + /* This assures the extension handling loop will terminate. */ + } } + // else: extension handler failed or SNDU should be discarded } else ext_len = -1; /* SNDU has to be discarded. */ } else { /* Optional extension header. Calculate the length. */ - ext_len = hlen << 2; + ext_len = hlen << 1; /* Process the optional extension header according to its type. */ if (ule_optional_ext_handlers[htype]) (void)ule_optional_ext_handlers[htype]( p ); p->ule_next_hdr += ext_len; - p->ule_sndu_type = ntohs( *(unsigned short *)p->ule_next_hdr ); - p->ule_next_hdr += 2; + p->ule_sndu_type = ntohs( *(unsigned short *)(p->ule_next_hdr-2) ); + /* + * note: the length of the next header type is included in the + * length of THIS optional extension header + */ } return ext_len; @@ -291,8 +317,14 @@ static int handle_ule_extensions( struct dvb_net_priv *p ) p->ule_next_hdr = p->ule_skb->data; do { l = handle_one_ule_extension( p ); - if (l == -1) return -1; /* Stop extension header processing and discard SNDU. */ + if (l < 0) + return l; /* Stop extension header processing and discard SNDU. */ total_ext_len += l; +#ifdef ULE_DEBUG + dprintk("handle_ule_extensions: ule_next_hdr=%p, ule_sndu_type=%i, " + "l=%i, total_ext_len=%i\n", p->ule_next_hdr, + (int) p->ule_sndu_type, l, total_ext_len); +#endif } while (p->ule_sndu_type < 1536); @@ -362,8 +394,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) if (priv->ule_skb) { dev_kfree_skb( priv->ule_skb ); /* Prepare for next SNDU. */ - ((struct dvb_net_priv *) dev->priv)->stats.rx_errors++; - ((struct dvb_net_priv *) dev->priv)->stats.rx_frame_errors++; + priv->stats.rx_errors++; + priv->stats.rx_frame_errors++; } reset_ule(priv); priv->need_pusi = 1; @@ -403,27 +435,25 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) } } - /* Check continuity counter. */ if (new_ts) { + /* Check continuity counter. */ if ((ts[3] & 0x0F) == priv->tscc) priv->tscc = (priv->tscc + 1) & 0x0F; else { /* TS discontinuity handling: */ printk(KERN_WARNING "%lu: TS discontinuity: got %#x, " - "exptected %#x.\n", priv->ts_count, ts[3] & 0x0F, priv->tscc); + "expected %#x.\n", priv->ts_count, ts[3] & 0x0F, priv->tscc); /* Drop partly decoded SNDU, reset state, resync on PUSI. */ if (priv->ule_skb) { dev_kfree_skb( priv->ule_skb ); /* Prepare for next SNDU. */ // reset_ule(priv); moved to below. - ((struct dvb_net_priv *) dev->priv)->stats.rx_errors++; - ((struct dvb_net_priv *) dev->priv)->stats.rx_frame_errors++; + priv->stats.rx_errors++; + priv->stats.rx_frame_errors++; } reset_ule(priv); /* skip to next PUSI. */ priv->need_pusi = 1; - ts += TS_SZ; - priv->ts_count++; continue; } /* If we still have an incomplete payload, but PUSI is @@ -432,7 +462,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) * cells (continuity counter wrap). */ if (ts[1] & TS_PUSI) { if (! priv->need_pusi) { - if (*from_where > 181) { + if (!(*from_where < (ts_remain-1)) || *from_where != priv->ule_sndu_remain) { /* Pointer field is invalid. Drop this TS cell and any started ULE SNDU. */ printk(KERN_WARNING "%lu: Invalid pointer " "field: %u.\n", priv->ts_count, *from_where); @@ -445,8 +475,6 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) } reset_ule(priv); priv->need_pusi = 1; - ts += TS_SZ; - priv->ts_count++; continue; } /* Skip pointer field (we're processing a @@ -459,8 +487,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) if (priv->ule_sndu_remain > 183) { /* Current SNDU lacks more data than there could be available in the * current TS cell. */ - ((struct dvb_net_priv *) dev->priv)->stats.rx_errors++; - ((struct dvb_net_priv *) dev->priv)->stats.rx_length_errors++; + priv->stats.rx_errors++; + priv->stats.rx_length_errors++; printk(KERN_WARNING "%lu: Expected %d more SNDU bytes, but " "got PUSI (pf %d, ts_remain %d). Flushing incomplete payload.\n", priv->ts_count, priv->ule_sndu_remain, ts[4], ts_remain); @@ -499,9 +527,11 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) } else priv->ule_dbit = 0; - if (priv->ule_sndu_len > 32763) { + if (priv->ule_sndu_len < 5) { printk(KERN_WARNING "%lu: Invalid ULE SNDU length %u. " "Resyncing.\n", priv->ts_count, priv->ule_sndu_len); + priv->stats.rx_errors++; + priv->stats.rx_length_errors++; priv->ule_sndu_len = 0; priv->need_pusi = 1; new_ts = 1; @@ -615,58 +645,103 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) ule_dump = 1; #endif - ((struct dvb_net_priv *) dev->priv)->stats.rx_errors++; - ((struct dvb_net_priv *) dev->priv)->stats.rx_crc_errors++; + priv->stats.rx_errors++; + priv->stats.rx_crc_errors++; dev_kfree_skb(priv->ule_skb); } else { /* CRC32 verified OK. */ + u8 dest_addr[ETH_ALEN]; + static const u8 bc_addr[ETH_ALEN] = + { [ 0 ... ETH_ALEN-1] = 0xff }; + + /* CRC32 was OK. Remove it from skb. */ + priv->ule_skb->tail -= 4; + priv->ule_skb->len -= 4; + + if (!priv->ule_dbit) { + /* + * The destination MAC address is the + * next data in the skb. It comes + * before any extension headers. + * + * Check if the payload of this SNDU + * should be passed up the stack. + */ + register int drop = 0; + if (priv->rx_mode != RX_MODE_PROMISC) { + if (priv->ule_skb->data[0] & 0x01) { + /* multicast or broadcast */ + if (memcmp(priv->ule_skb->data, bc_addr, ETH_ALEN)) { + /* multicast */ + if (priv->rx_mode == RX_MODE_MULTI) { + int i; + for(i = 0; i < priv->multi_num && memcmp(priv->ule_skb->data, priv->multi_macs[i], ETH_ALEN); i++) + ; + if (i == priv->multi_num) + drop = 1; + } else if (priv->rx_mode != RX_MODE_ALL_MULTI) + drop = 1; /* no broadcast; */ + /* else: all multicast mode: accept all multicast packets */ + } + /* else: broadcast */ + } + else if (memcmp(priv->ule_skb->data, dev->dev_addr, ETH_ALEN)) + drop = 1; + /* else: destination address matches the MAC address of our receiver device */ + } + /* else: promiscious mode; pass everything up the stack */ + + if (drop) { +#ifdef ULE_DEBUG + dprintk("Dropping SNDU: MAC destination address does not match: dest addr: "MAC_ADDR_PRINTFMT", dev addr: "MAC_ADDR_PRINTFMT"\n", + MAX_ADDR_PRINTFMT_ARGS(priv->ule_skb->data), MAX_ADDR_PRINTFMT_ARGS(dev->dev_addr)); +#endif + dev_kfree_skb(priv->ule_skb); + goto sndu_done; + } + else + { + memcpy(dest_addr, priv->ule_skb->data, ETH_ALEN); + skb_pull(priv->ule_skb, ETH_ALEN); + } + } + /* Handle ULE Extension Headers. */ if (priv->ule_sndu_type < 1536) { /* There is an extension header. Handle it accordingly. */ - int l = handle_ule_extensions( priv ); + int l = handle_ule_extensions(priv); if (l < 0) { /* Mandatory extension header unknown or TEST SNDU. Drop it. */ // printk( KERN_WARNING "Dropping SNDU, extension headers.\n" ); - dev_kfree_skb( priv->ule_skb ); + dev_kfree_skb(priv->ule_skb); goto sndu_done; } - skb_pull( priv->ule_skb, l ); + skb_pull(priv->ule_skb, l); } - /* CRC32 was OK. Remove it from skb. */ - priv->ule_skb->tail -= 4; - priv->ule_skb->len -= 4; - - /* Filter on receiver's destination MAC address, if present. */ - if (!priv->ule_dbit) { - /* The destination MAC address is the next data in the skb. */ - if (memcmp( priv->ule_skb->data, dev->dev_addr, ETH_ALEN )) { - /* MAC addresses don't match. Drop SNDU. */ - // printk( KERN_WARNING "Dropping SNDU, MAC address.\n" ); - dev_kfree_skb( priv->ule_skb ); - goto sndu_done; - } - if (! priv->ule_bridged) { - skb_push( priv->ule_skb, ETH_ALEN + 2 ); - ethh = (struct ethhdr *)priv->ule_skb->data; - memcpy( ethh->h_dest, ethh->h_source, ETH_ALEN ); - memset( ethh->h_source, 0, ETH_ALEN ); - ethh->h_proto = htons( priv->ule_sndu_type ); - } else { - /* Skip the Receiver destination MAC address. */ - skb_pull( priv->ule_skb, ETH_ALEN ); - } - } else { - if (! priv->ule_bridged) { - skb_push( priv->ule_skb, ETH_HLEN ); - ethh = (struct ethhdr *)priv->ule_skb->data; - memcpy( ethh->h_dest, dev->dev_addr, ETH_ALEN ); - memset( ethh->h_source, 0, ETH_ALEN ); - ethh->h_proto = htons( priv->ule_sndu_type ); - } else { - /* skb is in correct state; nothing to do. */ + /* + * Construct/assure correct ethernet header. + * Note: in bridged mode (priv->ule_bridged != + * 0) we already have the (original) ethernet + * header at the start of the payload (after + * optional dest. address and any extension + * headers). + */ + + if (!priv->ule_bridged) { + skb_push(priv->ule_skb, ETH_HLEN); + ethh = (struct ethhdr *)priv->ule_skb->data; + if (!priv->ule_dbit) { + /* dest_addr buffer is only valid if priv->ule_dbit == 0 */ + memcpy(ethh->h_dest, dest_addr, ETH_ALEN); + memset(ethh->h_source, 0, ETH_ALEN); } + else /* zeroize source and dest */ + memset( ethh, 0, ETH_ALEN*2 ); + + ethh->h_proto = htons(priv->ule_sndu_type); } + /* else: skb is in correct state; nothing to do. */ priv->ule_bridged = 0; /* Stuff into kernel's protocol stack. */ @@ -675,8 +750,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) * receive the packet anyhow. */ /* if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST) priv->ule_skb->pkt_type = PACKET_HOST; */ - ((struct dvb_net_priv *) dev->priv)->stats.rx_packets++; - ((struct dvb_net_priv *) dev->priv)->stats.rx_bytes += priv->ule_skb->len; + priv->stats.rx_packets++; + priv->stats.rx_bytes += priv->ule_skb->len; netif_rx(priv->ule_skb); } sndu_done: @@ -951,7 +1026,7 @@ static int dvb_net_feed_start(struct net_device *dev) dprintk("%s: start filtering\n", __FUNCTION__); priv->secfeed->start_filtering(priv->secfeed); } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) { - struct timespec timeout = { 0, 30000000 }; // 30 msec + struct timespec timeout = { 0, 10000000 }; // 10 msec /* we have payloads encapsulated in TS */ dprintk("%s: alloc tsfeed\n", __FUNCTION__); @@ -963,10 +1038,13 @@ static int dvb_net_feed_start(struct net_device *dev) /* Set netdevice pointer for ts decaps callback. */ priv->tsfeed->priv = (void *)dev; - ret = priv->tsfeed->set(priv->tsfeed, priv->pid, - TS_PACKET, DMX_TS_PES_OTHER, + ret = priv->tsfeed->set(priv->tsfeed, + priv->pid, /* pid */ + TS_PACKET, /* type */ + DMX_TS_PES_OTHER, /* pes type */ 32768, /* circular buffer size */ - timeout); + timeout /* timeout */ + ); if (ret < 0) { printk("%s: could not set ts feed\n", dev->name); -- cgit v1.2.3 From 304dfa39df9db3695e21bd87ac2c84819c889359 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Thu, 4 May 2006 16:39:44 +0100 Subject: Fix CI interface on KNC1 DVBT and DVBC cards From: Andrew de Quincey These cards need special handling for CI - reinitialising the frontend device when the CI module is reset. Additionally the tda10021 needs to be set into a different transport stream mode when a CI module is present. Signed-off-by: Andrew de Quincey --- linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 25 +++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 00347a750..2a03bf53c 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c @@ -1060,8 +1060,18 @@ static int dvb_ca_en50221_thread(void *data) break; case DVB_CA_SLOTSTATE_VALIDATE: - if (dvb_ca_en50221_parse_attributes(ca, slot) - != 0) { + if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) { + /* we need this extra check for annoying interfaces like the budget-av */ + if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && + (ca->pub->poll_slot_status)) { + int status = ca->pub->poll_slot_status(ca->pub, slot, 0); + if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) { + ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; + dvb_ca_en50221_thread_update_delay(ca); + break; + } + } + printk("dvb_ca adapter %d: Invalid PC card inserted :(\n", ca->dvbdev->adapter->num); ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; @@ -1108,6 +1118,17 @@ static int dvb_ca_en50221_thread(void *data) case DVB_CA_SLOTSTATE_LINKINIT: if (dvb_ca_en50221_link_init(ca, slot) != 0) { + /* we need this extra check for annoying interfaces like the budget-av */ + if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) && + (ca->pub->poll_slot_status)) { + int status = ca->pub->poll_slot_status(ca->pub, slot, 0); + if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) { + ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; + dvb_ca_en50221_thread_update_delay(ca); + break; + } + } + printk("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n", ca->dvbdev->adapter->num); ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; dvb_ca_en50221_thread_update_delay(ca); -- cgit v1.2.3 From b4d9770fbc462b4f10ebbf8950e94654309352c2 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 5 May 2006 22:24:46 +0400 Subject: Add frontend support for new Delivery systems and modulations -DVB-S2, 8PSK and higher order modulations, some advanced DVB-S2 features require additional support at the demux level -DVB-T, Add support for HP/LP stream selection -DVB-H, Add basic support to the frontend API -DSS, basic frontend API support only, will require additional support at the demux level Ack'd by: Marcel Siegert Acked-by: Andrew de Quincey Ack'd by: Patrick Boettcher Signed-off-by: Manu Abraham --- linux/drivers/media/dvb/dvb-core/dvb_frontend.c | 80 ++++++++++++++++++++++++- linux/drivers/media/dvb/dvb-core/dvb_frontend.h | 9 ++- 2 files changed, 86 insertions(+), 3 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c index bc752929f..5d980ee9d 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -94,6 +94,8 @@ struct dvb_frontend_private { /* thread/frontend values */ struct dvb_device *dvbdev; struct dvb_frontend_parameters parameters; + struct dvb_frontend_params params; + struct dvb_frontend_cap caps; struct dvb_fe_events events; struct semaphore sem; struct list_head list_head; @@ -124,6 +126,62 @@ struct dvb_frontend_private { unsigned int check_wrapped; }; +struct modcod_table { + __u32 modcod; + __u32 modulation; + __u32 fecrate; +}; + +struct modcod_table dvbs2_modcod_lookup[] = { + { FE_MODCOD_DUMMY_PLFRAME, FE_MOD_NONE, FE_FECRATE_NONE }, + { FE_MODCOD_QPSK_1_4, FE_MOD_QPSK, FE_FECRATE_1_4 }, + { FE_MODCOD_QPSK_1_3, FE_MOD_QPSK, FE_FECRATE_1_3 }, + { FE_MODCOD_QPSK_2_5, FE_MOD_QPSK, FE_FECRATE_2_5 }, + { FE_MODCOD_QPSK_1_2, FE_MOD_QPSK, FE_FECRATE_1_2 }, + { FE_MODCOD_QPSK_3_5, FE_MOD_QPSK, FE_FECRATE_3_5 }, + { FE_MODCOD_QPSK_2_3, FE_MOD_QPSK, FE_FECRATE_2_3 }, + { FE_MODCOD_QPSK_3_4, FE_MOD_QPSK, FE_FECRATE_3_4 }, + { FE_MODCOD_QPSK_4_5, FE_MOD_QPSK, FE_FECRATE_4_5 }, + { FE_MODCOD_QPSK_5_6, FE_MOD_QPSK, FE_FECRATE_5_6 }, + { FE_MODCOD_QPSK_8_9, FE_MOD_QPSK, FE_FECRATE_8_9 }, + { FE_MODCOD_QPSK_9_10, FE_MOD_QPSK, FE_FECRATE_9_10 }, + { FE_MODCOD_8PSK_3_5, FE_MOD_8PSK, FE_FECRATE_3_5 }, + { FE_MODCOD_8PSK_2_3, FE_MOD_8PSK, FE_FECRATE_2_3 }, + { FE_MODCOD_8PSK_3_4, FE_MOD_8PSK, FE_FECRATE_3_4 }, + { FE_MODCOD_8PSK_5_6, FE_MOD_8PSK, FE_FECRATE_5_6 }, + { FE_MODCOD_8PSK_8_9, FE_MOD_8PSK, FE_FECRATE_8_9 }, + { FE_MODCOD_8PSK_9_10, FE_MOD_8PSK, FE_FECRATE_9_10 }, + { FE_MODCOD_16APSK_2_3, FE_MOD_16APSK, FE_FECRATE_2_3 }, + { FE_MODCOD_16APSK_3_4, FE_MOD_16APSK, FE_FECRATE_3_4 }, + { FE_MODCOD_16APSK_4_5, FE_MOD_16APSK, FE_FECRATE_4_5 }, + { FE_MODCOD_16APSK_5_6, FE_MOD_16APSK, FE_FECRATE_5_6 }, + { FE_MODCOD_16APSK_8_9, FE_MOD_16APSK, FE_FECRATE_8_9 }, + { FE_MODCOD_16APSK_9_10, FE_MOD_16APSK, FE_FECRATE_9_10 }, + { FE_MODCOD_32APSK_3_4, FE_MOD_32APSK, FE_FECRATE_3_4 }, + { FE_MODCOD_32APSK_4_5, FE_MOD_32APSK, FE_FECRATE_4_5 }, + { FE_MODCOD_32APSK_5_6, FE_MOD_32APSK, FE_FECRATE_5_6 }, + { FE_MODCOD_32APSK_8_9, FE_MOD_32APSK, FE_FECRATE_8_9 }, + { FE_MODCOD_32APSK_9_10, FE_MOD_32APSK, FE_FECRATE_9_10 }, + { FE_MODCOD_RESERVED_1, FE_MOD_RSVD, FE_FECRATE_RSVD }, + { FE_MODCOD_BPSK_1_3, FE_MOD_BPSK, FE_FECRATE_1_3 }, + { FE_MODCOD_BPSK_1_4, FE_MOD_BPSK, FE_FECRATE_1_4 }, + { FE_MODCOD_RESERVED_2, FE_MOD_RSVD, FE_FECRATE_RSVD } +}; + +int decode_dvbs2_modcod(struct dvb_frontend *fe, enum fe_modcod modcod) +{ + struct modcod_table *table = dvbs2_modcod_lookup; + struct dvb_frontend_private *fepriv = fe->frontend_priv; + struct dvb_frontend_params *params = &fepriv->params; + + table += modcod; + params->delsys.dvbs2.modulation = table->modulation; + params->delsys.dvbs2.fecrate = table->fecrate; + + return 0; +} +EXPORT_SYMBOL(decode_dvbs2_modcod); + static void dvb_frontend_wakeup(struct dvb_frontend *fe); static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) @@ -508,7 +566,7 @@ static int dvb_frontend_thread(void *data) unsigned long timeout; char name [15]; fe_status_t s; - struct dvb_frontend_parameters *params; + struct dvb_frontend_params *params; dprintk("%s\n", __FUNCTION__); @@ -564,7 +622,7 @@ static int dvb_frontend_thread(void *data) /* have we been asked to retune? */ params = NULL; if (fepriv->state & FESTATE_RETUNE) { - params = &fepriv->parameters; + params = &fepriv->params; fepriv->state = FESTATE_TUNED; } @@ -977,6 +1035,24 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, case FE_SET_FRONTEND_TUNE_MODE: fepriv->tune_mode_flags = (unsigned long) parg; break; + + case FE_GET_CAPS: + if (fe->ops->get_caps) { + memcpy(parg, &fepriv->caps, sizeof (struct dvb_frontend_cap)); + err = fe->ops->get_caps(fe, (struct dvb_frontend_cap*) parg); + } + break; + + case FE_SET_PARAMS: + if (fe->ops->set_params) + err = fe->ops->set_params(fe, (struct dvb_frontend_params*) parg); + break; + + case FE_GET_PARAMS: + if (fe->ops->get_params){ + memcpy(parg, &fepriv->params, sizeof (struct dvb_frontend_params)); + err = fe->ops->get_params(fe, (struct dvb_frontend_params*) parg); + } }; up (&fepriv->sem); diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h index 05ec9954b..4d1b45be0 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h @@ -98,7 +98,7 @@ struct dvb_frontend_ops { /* if this is set, it overrides the default swzigzag */ int (*tune)(struct dvb_frontend* fe, - struct dvb_frontend_parameters* params, + struct dvb_frontend_params* params, unsigned int mode_flags, int *delay, fe_status_t *status); @@ -125,6 +125,11 @@ struct dvb_frontend_ops { int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd); int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable); + /* New callbacks based on the new IOCTL's */ + int (*get_caps)(struct dvb_frontend* fe, struct dvb_frontend_cap* caps); + int (*set_params)(struct dvb_frontend* fe, struct dvb_frontend_params* params); + int (*get_params)(struct dvb_frontend* fe, struct dvb_frontend_params* params); + struct dvb_tuner_ops tuner_ops; }; @@ -158,4 +163,6 @@ extern void dvb_frontend_reinitialise(struct dvb_frontend *fe); extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec); extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime); +extern int decode_dvbs2_modcod(struct dvb_frontend *fe, enum fe_modcod modcod); + #endif -- cgit v1.2.3 From 9af6ebbba1b633bd0a5636df1c4645b72feb7ad2 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Sat, 6 May 2006 02:12:19 +0400 Subject: Add math routines required by DVB demods From: Christoph Pfister Signed-off-by: Christoph Pfister Signed-off-by: Manu Abraham --- linux/drivers/media/dvb/dvb-core/Makefile | 6 +- linux/drivers/media/dvb/dvb-core/dvb_math.c | 144 ++++++++++++++++++++++++++++ linux/drivers/media/dvb/dvb-core/dvb_math.h | 58 +++++++++++ 3 files changed, 205 insertions(+), 3 deletions(-) create mode 100644 linux/drivers/media/dvb/dvb-core/dvb_math.c create mode 100644 linux/drivers/media/dvb/dvb-core/dvb_math.h (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/Makefile b/linux/drivers/media/dvb/dvb-core/Makefile index 7adb50c1e..11054657f 100644 --- a/linux/drivers/media/dvb/dvb-core/Makefile +++ b/linux/drivers/media/dvb/dvb-core/Makefile @@ -2,8 +2,8 @@ # Makefile for the kernel DVB device drivers. # -dvb-core-objs = dvbdev.o dmxdev.o dvb_demux.o dvb_filter.o \ - dvb_ca_en50221.o dvb_frontend.o \ - dvb_net.o dvb_ringbuffer.o +dvb-core-objs = dvbdev.o dmxdev.o dvb_demux.o dvb_filter.o \ + dvb_ca_en50221.o dvb_frontend.o \ + dvb_net.o dvb_ringbuffer.o dvb_math.o obj-$(CONFIG_DVB_CORE) += dvb-core.o diff --git a/linux/drivers/media/dvb/dvb-core/dvb_math.c b/linux/drivers/media/dvb/dvb-core/dvb_math.c new file mode 100644 index 000000000..db6d6b7f7 --- /dev/null +++ b/linux/drivers/media/dvb/dvb-core/dvb_math.c @@ -0,0 +1,144 @@ +/* + * dvb-math provides some complex fixed-point math + * operations shared between the dvb related stuff + * + * Copyright (C) 2006 Christoph Pfister (christophpfister@gmail.com) + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include "dvb_math.h" + +const unsigned short logtable[256] = { + 0x0000, 0x0171, 0x02e0, 0x044e, 0x05ba, 0x0725, 0x088e, 0x09f7, + 0x0b5d, 0x0cc3, 0x0e27, 0x0f8a, 0x10eb, 0x124b, 0x13aa, 0x1508, + 0x1664, 0x17bf, 0x1919, 0x1a71, 0x1bc8, 0x1d1e, 0x1e73, 0x1fc6, + 0x2119, 0x226a, 0x23ba, 0x2508, 0x2656, 0x27a2, 0x28ed, 0x2a37, + 0x2b80, 0x2cc8, 0x2e0f, 0x2f54, 0x3098, 0x31dc, 0x331e, 0x345f, + 0x359f, 0x36de, 0x381b, 0x3958, 0x3a94, 0x3bce, 0x3d08, 0x3e41, + 0x3f78, 0x40af, 0x41e4, 0x4319, 0x444c, 0x457f, 0x46b0, 0x47e1, + 0x4910, 0x4a3f, 0x4b6c, 0x4c99, 0x4dc5, 0x4eef, 0x5019, 0x5142, + 0x526a, 0x5391, 0x54b7, 0x55dc, 0x5700, 0x5824, 0x5946, 0x5a68, + 0x5b89, 0x5ca8, 0x5dc7, 0x5ee5, 0x6003, 0x611f, 0x623a, 0x6355, + 0x646f, 0x6588, 0x66a0, 0x67b7, 0x68ce, 0x69e4, 0x6af8, 0x6c0c, + 0x6d20, 0x6e32, 0x6f44, 0x7055, 0x7165, 0x7274, 0x7383, 0x7490, + 0x759d, 0x76aa, 0x77b5, 0x78c0, 0x79ca, 0x7ad3, 0x7bdb, 0x7ce3, + 0x7dea, 0x7ef0, 0x7ff6, 0x80fb, 0x81ff, 0x8302, 0x8405, 0x8507, + 0x8608, 0x8709, 0x8809, 0x8908, 0x8a06, 0x8b04, 0x8c01, 0x8cfe, + 0x8dfa, 0x8ef5, 0x8fef, 0x90e9, 0x91e2, 0x92db, 0x93d2, 0x94ca, + 0x95c0, 0x96b6, 0x97ab, 0x98a0, 0x9994, 0x9a87, 0x9b7a, 0x9c6c, + 0x9d5e, 0x9e4f, 0x9f3f, 0xa02e, 0xa11e, 0xa20c, 0xa2fa, 0xa3e7, + 0xa4d4, 0xa5c0, 0xa6ab, 0xa796, 0xa881, 0xa96a, 0xaa53, 0xab3c, + 0xac24, 0xad0c, 0xadf2, 0xaed9, 0xafbe, 0xb0a4, 0xb188, 0xb26c, + 0xb350, 0xb433, 0xb515, 0xb5f7, 0xb6d9, 0xb7ba, 0xb89a, 0xb97a, + 0xba59, 0xbb38, 0xbc16, 0xbcf4, 0xbdd1, 0xbead, 0xbf8a, 0xc065, + 0xc140, 0xc21b, 0xc2f5, 0xc3cf, 0xc4a8, 0xc580, 0xc658, 0xc730, + 0xc807, 0xc8de, 0xc9b4, 0xca8a, 0xcb5f, 0xcc34, 0xcd08, 0xcddc, + 0xceaf, 0xcf82, 0xd054, 0xd126, 0xd1f7, 0xd2c8, 0xd399, 0xd469, + 0xd538, 0xd607, 0xd6d6, 0xd7a4, 0xd872, 0xd93f, 0xda0c, 0xdad9, + 0xdba5, 0xdc70, 0xdd3b, 0xde06, 0xded0, 0xdf9a, 0xe063, 0xe12c, + 0xe1f5, 0xe2bd, 0xe385, 0xe44c, 0xe513, 0xe5d9, 0xe69f, 0xe765, + 0xe82a, 0xe8ef, 0xe9b3, 0xea77, 0xeb3b, 0xebfe, 0xecc1, 0xed83, + 0xee45, 0xef06, 0xefc8, 0xf088, 0xf149, 0xf209, 0xf2c8, 0xf387, + 0xf446, 0xf505, 0xf5c3, 0xf680, 0xf73e, 0xf7fb, 0xf8b7, 0xf973, + 0xfa2f, 0xfaea, 0xfba5, 0xfc60, 0xfd1a, 0xfdd4, 0xfe8e, 0xff47 +}; + +unsigned int intlog2(u32 value) +{ + /** + * returns: log2(value) * 2^24 + * wrong result if value = 0 (log2(0) is undefined) + */ + unsigned int msb; + unsigned int logentry; + unsigned int significand; + unsigned int interpolation; + + if (unlikely(value == 0)) { + WARN_ON(1); + return 0; + } + + /* first detect the msb (count begins at 0) */ + msb = fls(value) - 1; + + /** + * now we use a logtable after the following method: + * + * log2(2^x * y) * 2^24 = x * 2^24 + log2(y) * 2^24 + * where x = msb and therefore 1 <= y < 2 + * first y is determined by shifting the value left + * so that msb is bit 31 + * 0x00231f56 -> 0x8C7D5800 + * the result is y * 2^31 -> "significand" + * then the highest 9 bits are used for a table lookup + * the highest bit is discarded because it's always set + * the highest nine bits in our example are 100011000 + * so we would use the entry 0x18 + */ + significand = value << (31 - msb); + logentry = (significand >> 23) & 0xff; + + /** + * last step we do is interpolation because of the + * limitations of the log table the error is that part of + * the significand which isn't used for lookup then we + * compute the ratio between the error and the next table entry + * and interpolate it between the log table entry used and the + * next one the biggest error possible is 0x7fffff + * (in our example it's 0x7D5800) + * needed value for next table entry is 0x800000 + * so the interpolation is + * (error / 0x800000) * (logtable_next - logtable_current) + * in the implementation the division is moved to the end for + * better accuracy there is also an overflow correction if + * logtable_next is 256 + */ + interpolation = ((significand & 0x7fffff) * + ((logtable[(logentry + 1) & 0xff] - + logtable[logentry]) & 0xffff)) >> 15; + + /* now we return the result */ + return ((msb << 24) + (logtable[logentry] << 8) + interpolation); +} +EXPORT_SYMBOL(intlog2); + +unsigned int intlog10(u32 value) +{ + /** + * returns: log10(value) * 2^24 + * wrong result if value = 0 (log10(0) is undefined) + */ + u64 log; + + if (unlikely(value == 0)) { + WARN_ON(1); + return 0; + } + + log = intlog2(value); + + /** + * we use the following method: + * log10(x) = log2(x) * log10(2) + */ + + return (log * 646456993) >> 31; +} +EXPORT_SYMBOL(intlog10); diff --git a/linux/drivers/media/dvb/dvb-core/dvb_math.h b/linux/drivers/media/dvb/dvb-core/dvb_math.h new file mode 100644 index 000000000..aecc867e9 --- /dev/null +++ b/linux/drivers/media/dvb/dvb-core/dvb_math.h @@ -0,0 +1,58 @@ +/* + * dvb-math provides some complex fixed-point math + * operations shared between the dvb related stuff + * + * Copyright (C) 2006 Christoph Pfister (christophpfister@gmail.com) + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __DVB_MATH_H +#define __DVB_MATH_H + +#include + +/** + * computes log2 of a value; the result is shifted left by 24 bits + * + * to use rational values you can use the following method: + * intlog2(value) = intlog2(value * 2^x) - x * 2^24 + * + * example: intlog2(8) will give 3 << 24 = 3 * 2^24 + * example: intlog2(9) will give 3 << 24 + ... = 3.16... * 2^24 + * example: intlog2(1.5) = intlog2(3) - 2^24 = 0.584... * 2^24 + * + * @param value The value (must be != 0) + * @return log2(value) * 2^24 + */ +extern unsigned int intlog2(u32 value); + +/** + * computes log10 of a value; the result is shifted left by 24 bits + * + * to use rational values you can use the following method: + * intlog10(value) = intlog10(value * 10^x) - x * 2^24 + * + * example: intlog10(1000) will give 3 << 24 = 3 * 2^24 + * due to the implementation intlog10(1000) might be not exactly 3 * 2^24 + * + * look at intlog2 for similar examples + * + * @param value The value (must be != 0) + * @return log10(value) * 2^24 + */ +extern unsigned int intlog10(u32 value); + +#endif -- cgit v1.2.3 From 9a5a7b6c35191d8c0681eba05fa6b2d0e63c4583 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sun, 7 May 2006 19:10:00 -0300 Subject: revert manu's multiproto patch by his ask. From: Mauro Carvalho Chehab Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/dvb/dvb-core/dvb_frontend.c | 80 +------------------------ linux/drivers/media/dvb/dvb-core/dvb_frontend.h | 9 +-- 2 files changed, 3 insertions(+), 86 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c index 5d980ee9d..bc752929f 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -94,8 +94,6 @@ struct dvb_frontend_private { /* thread/frontend values */ struct dvb_device *dvbdev; struct dvb_frontend_parameters parameters; - struct dvb_frontend_params params; - struct dvb_frontend_cap caps; struct dvb_fe_events events; struct semaphore sem; struct list_head list_head; @@ -126,62 +124,6 @@ struct dvb_frontend_private { unsigned int check_wrapped; }; -struct modcod_table { - __u32 modcod; - __u32 modulation; - __u32 fecrate; -}; - -struct modcod_table dvbs2_modcod_lookup[] = { - { FE_MODCOD_DUMMY_PLFRAME, FE_MOD_NONE, FE_FECRATE_NONE }, - { FE_MODCOD_QPSK_1_4, FE_MOD_QPSK, FE_FECRATE_1_4 }, - { FE_MODCOD_QPSK_1_3, FE_MOD_QPSK, FE_FECRATE_1_3 }, - { FE_MODCOD_QPSK_2_5, FE_MOD_QPSK, FE_FECRATE_2_5 }, - { FE_MODCOD_QPSK_1_2, FE_MOD_QPSK, FE_FECRATE_1_2 }, - { FE_MODCOD_QPSK_3_5, FE_MOD_QPSK, FE_FECRATE_3_5 }, - { FE_MODCOD_QPSK_2_3, FE_MOD_QPSK, FE_FECRATE_2_3 }, - { FE_MODCOD_QPSK_3_4, FE_MOD_QPSK, FE_FECRATE_3_4 }, - { FE_MODCOD_QPSK_4_5, FE_MOD_QPSK, FE_FECRATE_4_5 }, - { FE_MODCOD_QPSK_5_6, FE_MOD_QPSK, FE_FECRATE_5_6 }, - { FE_MODCOD_QPSK_8_9, FE_MOD_QPSK, FE_FECRATE_8_9 }, - { FE_MODCOD_QPSK_9_10, FE_MOD_QPSK, FE_FECRATE_9_10 }, - { FE_MODCOD_8PSK_3_5, FE_MOD_8PSK, FE_FECRATE_3_5 }, - { FE_MODCOD_8PSK_2_3, FE_MOD_8PSK, FE_FECRATE_2_3 }, - { FE_MODCOD_8PSK_3_4, FE_MOD_8PSK, FE_FECRATE_3_4 }, - { FE_MODCOD_8PSK_5_6, FE_MOD_8PSK, FE_FECRATE_5_6 }, - { FE_MODCOD_8PSK_8_9, FE_MOD_8PSK, FE_FECRATE_8_9 }, - { FE_MODCOD_8PSK_9_10, FE_MOD_8PSK, FE_FECRATE_9_10 }, - { FE_MODCOD_16APSK_2_3, FE_MOD_16APSK, FE_FECRATE_2_3 }, - { FE_MODCOD_16APSK_3_4, FE_MOD_16APSK, FE_FECRATE_3_4 }, - { FE_MODCOD_16APSK_4_5, FE_MOD_16APSK, FE_FECRATE_4_5 }, - { FE_MODCOD_16APSK_5_6, FE_MOD_16APSK, FE_FECRATE_5_6 }, - { FE_MODCOD_16APSK_8_9, FE_MOD_16APSK, FE_FECRATE_8_9 }, - { FE_MODCOD_16APSK_9_10, FE_MOD_16APSK, FE_FECRATE_9_10 }, - { FE_MODCOD_32APSK_3_4, FE_MOD_32APSK, FE_FECRATE_3_4 }, - { FE_MODCOD_32APSK_4_5, FE_MOD_32APSK, FE_FECRATE_4_5 }, - { FE_MODCOD_32APSK_5_6, FE_MOD_32APSK, FE_FECRATE_5_6 }, - { FE_MODCOD_32APSK_8_9, FE_MOD_32APSK, FE_FECRATE_8_9 }, - { FE_MODCOD_32APSK_9_10, FE_MOD_32APSK, FE_FECRATE_9_10 }, - { FE_MODCOD_RESERVED_1, FE_MOD_RSVD, FE_FECRATE_RSVD }, - { FE_MODCOD_BPSK_1_3, FE_MOD_BPSK, FE_FECRATE_1_3 }, - { FE_MODCOD_BPSK_1_4, FE_MOD_BPSK, FE_FECRATE_1_4 }, - { FE_MODCOD_RESERVED_2, FE_MOD_RSVD, FE_FECRATE_RSVD } -}; - -int decode_dvbs2_modcod(struct dvb_frontend *fe, enum fe_modcod modcod) -{ - struct modcod_table *table = dvbs2_modcod_lookup; - struct dvb_frontend_private *fepriv = fe->frontend_priv; - struct dvb_frontend_params *params = &fepriv->params; - - table += modcod; - params->delsys.dvbs2.modulation = table->modulation; - params->delsys.dvbs2.fecrate = table->fecrate; - - return 0; -} -EXPORT_SYMBOL(decode_dvbs2_modcod); - static void dvb_frontend_wakeup(struct dvb_frontend *fe); static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) @@ -566,7 +508,7 @@ static int dvb_frontend_thread(void *data) unsigned long timeout; char name [15]; fe_status_t s; - struct dvb_frontend_params *params; + struct dvb_frontend_parameters *params; dprintk("%s\n", __FUNCTION__); @@ -622,7 +564,7 @@ static int dvb_frontend_thread(void *data) /* have we been asked to retune? */ params = NULL; if (fepriv->state & FESTATE_RETUNE) { - params = &fepriv->params; + params = &fepriv->parameters; fepriv->state = FESTATE_TUNED; } @@ -1035,24 +977,6 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, case FE_SET_FRONTEND_TUNE_MODE: fepriv->tune_mode_flags = (unsigned long) parg; break; - - case FE_GET_CAPS: - if (fe->ops->get_caps) { - memcpy(parg, &fepriv->caps, sizeof (struct dvb_frontend_cap)); - err = fe->ops->get_caps(fe, (struct dvb_frontend_cap*) parg); - } - break; - - case FE_SET_PARAMS: - if (fe->ops->set_params) - err = fe->ops->set_params(fe, (struct dvb_frontend_params*) parg); - break; - - case FE_GET_PARAMS: - if (fe->ops->get_params){ - memcpy(parg, &fepriv->params, sizeof (struct dvb_frontend_params)); - err = fe->ops->get_params(fe, (struct dvb_frontend_params*) parg); - } }; up (&fepriv->sem); diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h index 4d1b45be0..05ec9954b 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.h @@ -98,7 +98,7 @@ struct dvb_frontend_ops { /* if this is set, it overrides the default swzigzag */ int (*tune)(struct dvb_frontend* fe, - struct dvb_frontend_params* params, + struct dvb_frontend_parameters* params, unsigned int mode_flags, int *delay, fe_status_t *status); @@ -125,11 +125,6 @@ struct dvb_frontend_ops { int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd); int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable); - /* New callbacks based on the new IOCTL's */ - int (*get_caps)(struct dvb_frontend* fe, struct dvb_frontend_cap* caps); - int (*set_params)(struct dvb_frontend* fe, struct dvb_frontend_params* params); - int (*get_params)(struct dvb_frontend* fe, struct dvb_frontend_params* params); - struct dvb_tuner_ops tuner_ops; }; @@ -163,6 +158,4 @@ extern void dvb_frontend_reinitialise(struct dvb_frontend *fe); extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec); extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime); -extern int decode_dvbs2_modcod(struct dvb_frontend *fe, enum fe_modcod modcod); - #endif -- cgit v1.2.3 From f778635ea05c9a95f8f1c3df6e6348a2980ffe97 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Mon, 8 May 2006 23:06:32 +0400 Subject: Add missing include From: Manu Abraham Signed-off-by: Manu Abraham --- linux/drivers/media/dvb/dvb-core/dvb_math.c | 1 + 1 file changed, 1 insertion(+) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_math.c b/linux/drivers/media/dvb/dvb-core/dvb_math.c index db6d6b7f7..b201dbfc1 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_math.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_math.c @@ -21,6 +21,7 @@ #include #include +#include #include #include "dvb_math.h" -- cgit v1.2.3 From a55bfded81a0bffe5d07618b1983ad4abc6c2fbb Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Mon, 8 May 2006 23:14:56 +0400 Subject: make the table static From: Christoph Pfister Signed-off-by: Christoph Pfister Signed-off-by: Manu Abraham --- linux/drivers/media/dvb/dvb-core/dvb_math.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linux/drivers/media/dvb/dvb-core') diff --git a/linux/drivers/media/dvb/dvb-core/dvb_math.c b/linux/drivers/media/dvb/dvb-core/dvb_math.c index b201dbfc1..beb7c93aa 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_math.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_math.c @@ -25,7 +25,7 @@ #include #include "dvb_math.h" -const unsigned short logtable[256] = { +static const unsigned short logtable[256] = { 0x0000, 0x0171, 0x02e0, 0x044e, 0x05ba, 0x0725, 0x088e, 0x09f7, 0x0b5d, 0x0cc3, 0x0e27, 0x0f8a, 0x10eb, 0x124b, 0x13aa, 0x1508, 0x1664, 0x17bf, 0x1919, 0x1a71, 0x1bc8, 0x1d1e, 0x1e73, 0x1fc6, -- cgit v1.2.3