Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ad339a2 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

[media] tuner-core.c: don't change type field in g_tuner or g_frequency



The tuner core should not silently change the type field in g_tuner and
g_frequency. If the tuner is in a different mode than the one that was
requested, then just fill in what you can and don't attempt to read afc,
signal or rxsubchans values.

Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d118e294
Loading
Loading
Loading
Loading
+19 −19
Original line number Diff line number Diff line
@@ -1101,8 +1101,7 @@ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)

	if (check_mode(t, f->type) == -EINVAL)
		return 0;
	f->type = t->mode;
	if (fe_tuner_ops->get_frequency && !t->standby) {
	if (f->type == t->mode && fe_tuner_ops->get_frequency && !t->standby) {
		u32 abs_freq;

		fe_tuner_ops->get_frequency(&t->fe, &abs_freq);
@@ -1110,7 +1109,7 @@ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
			DIV_ROUND_CLOSEST(abs_freq * 2, 125) :
			DIV_ROUND_CLOSEST(abs_freq, 62500);
	} else {
		f->frequency = (V4L2_TUNER_RADIO == t->mode) ?
		f->frequency = (V4L2_TUNER_RADIO == f->type) ?
			t->radio_freq : t->tv_freq;
	}
	return 0;
@@ -1134,18 +1133,18 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)

	if (check_mode(t, vt->type) == -EINVAL)
		return 0;
	vt->type = t->mode;
	if (analog_ops->get_afc)
	if (vt->type == t->mode && analog_ops->get_afc)
		vt->afc = analog_ops->get_afc(&t->fe);
	if (t->mode == V4L2_TUNER_ANALOG_TV)
	if (vt->type == V4L2_TUNER_ANALOG_TV)
		vt->capability |= V4L2_TUNER_CAP_NORM;
	if (t->mode != V4L2_TUNER_RADIO) {
	if (vt->type != V4L2_TUNER_RADIO) {
		vt->rangelow = tv_range[0] * 16;
		vt->rangehigh = tv_range[1] * 16;
		return 0;
	}

	/* radio mode */
	if (vt->type == t->mode) {
		vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
		if (fe_tuner_ops->get_status) {
			u32 tuner_status;
@@ -1158,8 +1157,9 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
		}
		if (analog_ops->has_signal)
			vt->signal = analog_ops->has_signal(&t->fe);
	vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
		vt->audmode = t->audmode;
	}
	vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
	vt->rangelow = radio_range[0] * 16000;
	vt->rangehigh = radio_range[1] * 16000;