don't try to set frequencies lower or higher than the tuner's allowed

range -- the v4l2 spec says "when the requested frequency is not possible
the driver assumes the closest possible value".
This commit is contained in:
jmcneill 2010-12-26 23:41:45 +00:00
parent 3b9ac1bb43
commit 97dc26a286
1 changed files with 15 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: video.c,v 1.25 2010/12/24 20:54:28 jmcneill Exp $ */
/* $NetBSD: video.c,v 1.26 2010/12/26 23:41:45 jmcneill Exp $ */
/*
* Copyright (c) 2008 Patrick Mahoney <pat@polycrystal.org>
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.25 2010/12/24 20:54:28 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: video.c,v 1.26 2010/12/26 23:41:45 jmcneill Exp $");
#include "video.h"
#if NVIDEO > 0
@ -1319,12 +1319,24 @@ video_set_frequency(struct video_softc *sc, struct v4l2_frequency *freq)
{
const struct video_hw_if *hw = sc->hw_if;
struct video_frequency vfreq;
struct video_tuner vt;
int error;
if (hw->set_frequency == NULL)
if (hw->set_frequency == NULL || hw->get_tuner == NULL)
return ENOTTY;
if (freq->type != V4L2_TUNER_ANALOG_TV)
return EINVAL;
vt.index = freq->tuner;
error = hw->get_tuner(sc->hw_softc, &vt);
if (error)
return error;
if (freq->frequency < vt.freq_lo)
freq->frequency = vt.freq_lo;
else if (freq->frequency > vt.freq_hi)
freq->frequency = vt.freq_hi;
vfreq.tuner_index = freq->tuner;
vfreq.frequency = freq->frequency;