diff mbox

[RFCv3,09/10,media] tuner-core: add support to get the tuner frequency range

Message ID 1366570839-662-10-git-send-email-mchehab@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab April 21, 2013, 7 p.m. UTC
For SDR, the tuner range is different than TV or radio
ranges. Only the actual tuner driver knows what's the
range supported by the device. So, call the tuner to
get it, if the tuner supports. Otherwise, keep the TV
range, as is it broader than the radio one.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/dvb-core/dvb_frontend.h | 2 ++
 drivers/media/v4l2-core/tuner-core.c  | 7 +++++++
 2 files changed, 9 insertions(+)
diff mbox

Patch

diff --git a/drivers/media/dvb-core/dvb_frontend.h b/drivers/media/dvb-core/dvb_frontend.h
index 371b6ca..74a50e6 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -215,6 +215,8 @@  struct dvb_tuner_ops {
 	int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
 	int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
 	int (*get_if_frequency)(struct dvb_frontend *fe, u32 *frequency);
+	int (*get_tuner_freq_range)(struct dvb_frontend *fe,
+				    u32 *min_freq, u32 *max_freq);
 
 #define TUNER_STATUS_LOCKED 1
 #define TUNER_STATUS_STEREO 2
diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c
index abdcda4..28bbcad 100644
--- a/drivers/media/v4l2-core/tuner-core.c
+++ b/drivers/media/v4l2-core/tuner-core.c
@@ -460,6 +460,13 @@  static void set_type(struct i2c_client *c, unsigned int type,
 		t->tv_range[i] = tv_range[i] * 16;
 	}
 
+	if (fe_tuner_ops->get_tuner_freq_range) {
+		u32 min, max;
+		fe_tuner_ops->get_tuner_freq_range(&t->fe, &min, &max);
+		t->sdr_range[0] = min / 16;
+		t->sdr_range[1] = max / 16;
+	}
+
 	tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n",
 		  c->adapter->name, c->driver->driver.name, c->addr << 1, type,
 		  t->mode_mask);