Re: [PATCH RFCv3 08/10] [media] tuner-core: store tuner ranges at tuner struct
On Monday, April 22, 2013 14:12:57 Mauro Carvalho Chehab wrote: Em 22-04-2013 04:22, Hans Verkuil escreveu: On Sun April 21 2013 21:00:37 Mauro Carvalho Chehab wrote: Instead of using global values for tuner ranges, store them internally. That fixes the need of using a different range for SDR radio, and will help to latter add a tuner ops to retrieve the tuner range for SDR mode. Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com --- drivers/media/v4l2-core/tuner-core.c | 59 ++-- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index e54b5ae..abdcda4 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -67,8 +67,8 @@ static char secam[] = --; static char ntsc[] = -; module_param_named(debug, tuner_debug, int, 0644); -module_param_array(tv_range, int, NULL, 0644); -module_param_array(radio_range, int, NULL, 0644); +module_param_array(tv_range, int, NULL, 0444); +module_param_array(radio_range, int, NULL, 0444); Shouldn't we add a sdr_range here as well? I don't think it is needed to have a modprobe parameter for that. If user wants to change the range, VIDIOC_S_TUNER can be used. You can't change the range using S_TUNER, it's not a settable field. Btw, I was tempted to even remove those ;) I'd either remove them or add an sdr_range rather than leaving it in an inconsistent state. Regards, Hans -- To unsubscribe from this list: send the line unsubscribe linux-media in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH RFCv3 08/10] [media] tuner-core: store tuner ranges at tuner struct
On Sun April 21 2013 21:00:37 Mauro Carvalho Chehab wrote: Instead of using global values for tuner ranges, store them internally. That fixes the need of using a different range for SDR radio, and will help to latter add a tuner ops to retrieve the tuner range for SDR mode. Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com --- drivers/media/v4l2-core/tuner-core.c | 59 ++-- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index e54b5ae..abdcda4 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -67,8 +67,8 @@ static char secam[] = --; static char ntsc[] = -; module_param_named(debug, tuner_debug, int, 0644); -module_param_array(tv_range, int, NULL, 0644); -module_param_array(radio_range, int, NULL, 0644); +module_param_array(tv_range, int, NULL, 0444); +module_param_array(radio_range, int, NULL, 0444); Shouldn't we add a sdr_range here as well? module_param_string(pal, pal, sizeof(pal), 0644); module_param_string(secam, secam, sizeof(secam), 0644); module_param_string(ntsc, ntsc, sizeof(ntsc), 0644); @@ -134,6 +134,8 @@ struct tuner { unsigned inttype; /* chip type id */ void*config; const char *name; + + u32 radio_range[2], tv_range[2], sdr_range[2]; }; /* @@ -266,7 +268,7 @@ static void set_type(struct i2c_client *c, unsigned int type, struct dvb_tuner_ops *fe_tuner_ops = t-fe.ops.tuner_ops; struct analog_demod_ops *analog_ops = t-fe.ops.analog_ops; unsigned char buffer[4]; - int tune_now = 1; + int i, tune_now = 1; if (type == UNSET || type == TUNER_ABSENT) { tuner_dbg(tuner 0x%02x: Tuner type absent\n, c-addr); @@ -451,6 +453,13 @@ static void set_type(struct i2c_client *c, unsigned int type, set_tv_freq(c, t-tv_freq); } + /* Initializes the tuner ranges from modprobe parameters */ + for (i = 0; i 2; i++) { + t-radio_range[i] = radio_range[i] * 16000; + t-sdr_range[i] = tv_range[i] * 16000; + t-tv_range[i] = tv_range[i] * 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); @@ -831,16 +840,16 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) tuner_warn(Tuner has no way to set tv freq\n); return; } - if (freq tv_range[0] * 16 || freq tv_range[1] * 16) { + if (freq t-tv_range[0] || freq t-tv_range[1]) { tuner_dbg(TV freq (%d.%02d) out of range (%d-%d)\n, -freq / 16, freq % 16 * 100 / 16, tv_range[0], -tv_range[1]); +freq / 16, freq % 16 * 100 / 16, t-tv_range[0] / 16, +t-tv_range[1] / 16); /* V4L2 spec: if the freq is not possible then the closest possible value should be selected */ - if (freq tv_range[0] * 16) - freq = tv_range[0] * 16; + if (freq t-tv_range[0]) + freq = t-tv_range[0]; else - freq = tv_range[1] * 16; + freq = t-tv_range[1]; } params.frequency = freq; tuner_dbg(tv freq set to %d.%02d\n, @@ -957,7 +966,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) { struct tuner *t = to_tuner(i2c_get_clientdata(c)); struct analog_demod_ops *analog_ops = t-fe.ops.analog_ops; - + u32 *range; struct analog_parameters params = { .mode = t-mode, .audmode = t-audmode, @@ -972,16 +981,22 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) tuner_warn(tuner has no way to set radio frequency\n); return; } - if (freq radio_range[0] * 16000 || freq radio_range[1] * 16000) { + + if (V4L2_TUNER_IS_SDR(t-mode)) + range = t-sdr_range; + else + range = t-radio_range; + + if (freq range[0] || freq range[1]) { tuner_dbg(radio freq (%d.%02d) out of range (%d-%d)\n, freq / 16000, freq % 16000 * 100 / 16000, -radio_range[0], radio_range[1]); +range[0] / 16000, range[1] / 16000); /* V4L2 spec: if the freq is not possible then the closest possible value should be selected */ - if (freq radio_range[0] * 16000) - freq = radio_range[0] * 16000; + if (freq range[0]) + freq = range[0]; else -
Re: [PATCH RFCv3 08/10] [media] tuner-core: store tuner ranges at tuner struct
Em 22-04-2013 04:22, Hans Verkuil escreveu: On Sun April 21 2013 21:00:37 Mauro Carvalho Chehab wrote: Instead of using global values for tuner ranges, store them internally. That fixes the need of using a different range for SDR radio, and will help to latter add a tuner ops to retrieve the tuner range for SDR mode. Signed-off-by: Mauro Carvalho Chehab mche...@redhat.com --- drivers/media/v4l2-core/tuner-core.c | 59 ++-- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/media/v4l2-core/tuner-core.c b/drivers/media/v4l2-core/tuner-core.c index e54b5ae..abdcda4 100644 --- a/drivers/media/v4l2-core/tuner-core.c +++ b/drivers/media/v4l2-core/tuner-core.c @@ -67,8 +67,8 @@ static char secam[] = --; static char ntsc[] = -; module_param_named(debug, tuner_debug, int, 0644); -module_param_array(tv_range, int, NULL, 0644); -module_param_array(radio_range, int, NULL, 0644); +module_param_array(tv_range, int, NULL, 0444); +module_param_array(radio_range, int, NULL, 0444); Shouldn't we add a sdr_range here as well? I don't think it is needed to have a modprobe parameter for that. If user wants to change the range, VIDIOC_S_TUNER can be used. Btw, I was tempted to even remove those ;) module_param_string(pal, pal, sizeof(pal), 0644); module_param_string(secam, secam, sizeof(secam), 0644); module_param_string(ntsc, ntsc, sizeof(ntsc), 0644); @@ -134,6 +134,8 @@ struct tuner { unsigned inttype; /* chip type id */ void*config; const char *name; + + u32 radio_range[2], tv_range[2], sdr_range[2]; }; /* @@ -266,7 +268,7 @@ static void set_type(struct i2c_client *c, unsigned int type, struct dvb_tuner_ops *fe_tuner_ops = t-fe.ops.tuner_ops; struct analog_demod_ops *analog_ops = t-fe.ops.analog_ops; unsigned char buffer[4]; - int tune_now = 1; + int i, tune_now = 1; if (type == UNSET || type == TUNER_ABSENT) { tuner_dbg(tuner 0x%02x: Tuner type absent\n, c-addr); @@ -451,6 +453,13 @@ static void set_type(struct i2c_client *c, unsigned int type, set_tv_freq(c, t-tv_freq); } + /* Initializes the tuner ranges from modprobe parameters */ + for (i = 0; i 2; i++) { + t-radio_range[i] = radio_range[i] * 16000; + t-sdr_range[i] = tv_range[i] * 16000; + t-tv_range[i] = tv_range[i] * 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); @@ -831,16 +840,16 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) tuner_warn(Tuner has no way to set tv freq\n); return; } - if (freq tv_range[0] * 16 || freq tv_range[1] * 16) { + if (freq t-tv_range[0] || freq t-tv_range[1]) { tuner_dbg(TV freq (%d.%02d) out of range (%d-%d)\n, - freq / 16, freq % 16 * 100 / 16, tv_range[0], - tv_range[1]); + freq / 16, freq % 16 * 100 / 16, t-tv_range[0] / 16, + t-tv_range[1] / 16); /* V4L2 spec: if the freq is not possible then the closest possible value should be selected */ - if (freq tv_range[0] * 16) - freq = tv_range[0] * 16; + if (freq t-tv_range[0]) + freq = t-tv_range[0]; else - freq = tv_range[1] * 16; + freq = t-tv_range[1]; } params.frequency = freq; tuner_dbg(tv freq set to %d.%02d\n, @@ -957,7 +966,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) { struct tuner *t = to_tuner(i2c_get_clientdata(c)); struct analog_demod_ops *analog_ops = t-fe.ops.analog_ops; - + u32 *range; struct analog_parameters params = { .mode = t-mode, .audmode = t-audmode, @@ -972,16 +981,22 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq) tuner_warn(tuner has no way to set radio frequency\n); return; } - if (freq radio_range[0] * 16000 || freq radio_range[1] * 16000) { + + if (V4L2_TUNER_IS_SDR(t-mode)) + range = t-sdr_range; + else + range = t-radio_range; + + if (freq range[0] || freq range[1]) { tuner_dbg(radio freq (%d.%02d) out of range (%d-%d)\n, freq / 16000, freq % 16000 * 100 / 16000, - radio_range[0], radio_range[1]); + range[0] / 16000, range[1] / 16000); /* V4L2 spec: if the freq is not possible then the closest