aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Endriss <o.endriss@gmx.de>2007-08-09 00:03:42 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:04:43 -0400
commitc471b331dda9fdfaf67832998d0b2c848777ab4a (patch)
treea4b950597813d921612dca18206aa5b19cf30e2a
parenta18255bef2a62632ed442fdb90b091193cbabca5 (diff)
V4L/DVB (5986): dvb_frontend: Fixed GET_INFO ioctl and check of frequency limits
The calculation of frequency limits ignored tuner-specific frequency limits. Range checks and GET_INFO ioctl updated accordingly. Signed-off-by: Oliver Endriss <o.endriss@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index fd9bac5eb25e..1a1b2405b0f4 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -697,17 +697,35 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
697 return 0; 697 return 0;
698} 698}
699 699
700static void dvb_frontend_get_frequeny_limits(struct dvb_frontend *fe,
701 u32 *freq_min, u32 *freq_max)
702{
703 *freq_min = max(fe->ops.info.frequency_min, fe->ops.tuner_ops.info.frequency_min);
704
705 if (fe->ops.info.frequency_max == 0)
706 *freq_max = fe->ops.tuner_ops.info.frequency_max;
707 else if (fe->ops.tuner_ops.info.frequency_max == 0)
708 *freq_max = fe->ops.info.frequency_max;
709 else
710 *freq_max = min(fe->ops.info.frequency_max, fe->ops.tuner_ops.info.frequency_max);
711
712 if (*freq_min == 0 || *freq_max == 0)
713 printk(KERN_WARNING "DVB: frontend %u frequency limits undefined - fix the driver\n",
714 fe->dvb->num);
715}
716
700static int dvb_frontend_check_parameters(struct dvb_frontend *fe, 717static int dvb_frontend_check_parameters(struct dvb_frontend *fe,
701 struct dvb_frontend_parameters *parms) 718 struct dvb_frontend_parameters *parms)
702{ 719{
720 u32 freq_min;
721 u32 freq_max;
722
703 /* range check: frequency */ 723 /* range check: frequency */
704 if ((fe->ops.info.frequency_min && 724 dvb_frontend_get_frequeny_limits(fe, &freq_min, &freq_max);
705 parms->frequency < fe->ops.info.frequency_min) || 725 if ((freq_min && parms->frequency < freq_min) ||
706 (fe->ops.info.frequency_max && 726 (freq_max && parms->frequency > freq_max)) {
707 parms->frequency > fe->ops.info.frequency_max)) {
708 printk(KERN_WARNING "DVB: frontend %u frequency %u out of range (%u..%u)\n", 727 printk(KERN_WARNING "DVB: frontend %u frequency %u out of range (%u..%u)\n",
709 fe->dvb->num, parms->frequency, 728 fe->dvb->num, parms->frequency, freq_min, freq_max);
710 fe->ops.info.frequency_min, fe->ops.info.frequency_max);
711 return -EINVAL; 729 return -EINVAL;
712 } 730 }
713 731
@@ -763,6 +781,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
763 case FE_GET_INFO: { 781 case FE_GET_INFO: {
764 struct dvb_frontend_info* info = parg; 782 struct dvb_frontend_info* info = parg;
765 memcpy(info, &fe->ops.info, sizeof(struct dvb_frontend_info)); 783 memcpy(info, &fe->ops.info, sizeof(struct dvb_frontend_info));
784 dvb_frontend_get_frequeny_limits(fe, &info->frequency_min, &info->frequency_max);
766 785
767 /* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't 786 /* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't
768 * do it, it is done for it. */ 787 * do it, it is done for it. */