Commit c15000b4 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6

* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6:
  [media] msp3400: fill in v4l2_tuner based on vt->type field
  [media] tuner-core.c: don't change type field in g_tuner or g_frequency
  [media] cx18/ivtv: fix g_tuner support
  [media] tuner-core: power up tuner when called with s_power(1)
  [media] v4l2-ioctl.c: check for valid tuner type in S_HW_FREQ_SEEK
  [media] tuner-core: simplify the standard fixup
  [media] tuner-core/v4l2-subdev: document that the type field has to be filled in
  [media] v4l2-subdev.h: remove unused s_mode tuner op
  [media] feature-removal-schedule: change in how radio device nodes are handled
  [media] bttv: fix s_tuner for radio
  [media] pvrusb2: fix g/s_tuner support
  [media] v4l2-ioctl.c: prefill tuner type for g_frequency and g/s_tuner
  [media] tuner-core: fix tuner_resume: use t->mode instead of t->type
  [media] tuner-core: fix s_std and s_tuner
parents 9ddf7f50 ddc6ff31
...@@ -583,3 +583,25 @@ Why: Superseded by the UVCIOC_CTRL_QUERY ioctl. ...@@ -583,3 +583,25 @@ Why: Superseded by the UVCIOC_CTRL_QUERY ioctl.
Who: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Who: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---------------------------- ----------------------------
What: For VIDIOC_S_FREQUENCY the type field must match the device node's type.
If not, return -EINVAL.
When: 3.2
Why: It makes no sense to switch the tuner to radio mode by calling
VIDIOC_S_FREQUENCY on a video node, or to switch the tuner to tv mode by
calling VIDIOC_S_FREQUENCY on a radio node. This is the first step of a
move to more consistent handling of tv and radio tuners.
Who: Hans Verkuil <hans.verkuil@cisco.com>
----------------------------
What: Opening a radio device node will no longer automatically switch the
tuner mode from tv to radio.
When: 3.3
Why: Just opening a V4L device should not change the state of the hardware
like that. It's very unexpected and against the V4L spec. Instead, you
switch to radio mode by calling VIDIOC_S_FREQUENCY. This is the second
and last step of the move to consistent handling of tv and radio tuners.
Who: Hans Verkuil <hans.verkuil@cisco.com>
----------------------------
...@@ -3474,7 +3474,7 @@ static int radio_s_tuner(struct file *file, void *priv, ...@@ -3474,7 +3474,7 @@ static int radio_s_tuner(struct file *file, void *priv,
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
bttv_call_all(btv, tuner, g_tuner, t); bttv_call_all(btv, tuner, s_tuner, t);
return 0; return 0;
} }
......
...@@ -695,14 +695,10 @@ static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) ...@@ -695,14 +695,10 @@ static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
cx18_call_all(cx, tuner, g_tuner, vt); cx18_call_all(cx, tuner, g_tuner, vt);
if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { if (vt->type == V4L2_TUNER_RADIO)
strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name)); strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name));
vt->type = V4L2_TUNER_RADIO; else
} else {
strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name)); strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name));
vt->type = V4L2_TUNER_ANALOG_TV;
}
return 0; return 0;
} }
......
...@@ -1184,14 +1184,10 @@ static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt) ...@@ -1184,14 +1184,10 @@ static int ivtv_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
ivtv_call_all(itv, tuner, g_tuner, vt); ivtv_call_all(itv, tuner, g_tuner, vt);
if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) { if (vt->type == V4L2_TUNER_RADIO)
strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name)); strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name));
vt->type = V4L2_TUNER_RADIO; else
} else {
strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name)); strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name));
vt->type = V4L2_TUNER_ANALOG_TV;
}
return 0; return 0;
} }
......
...@@ -480,12 +480,14 @@ static int msp_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) ...@@ -480,12 +480,14 @@ static int msp_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
struct msp_state *state = to_state(sd); struct msp_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd); struct i2c_client *client = v4l2_get_subdevdata(sd);
if (state->radio) if (vt->type != V4L2_TUNER_ANALOG_TV)
return 0; return 0;
if (!state->radio) {
if (state->opmode == OPMODE_AUTOSELECT) if (state->opmode == OPMODE_AUTOSELECT)
msp_detect_stereo(client); msp_detect_stereo(client);
vt->audmode = state->audmode;
vt->rxsubchans = state->rxsubchans; vt->rxsubchans = state->rxsubchans;
}
vt->audmode = state->audmode;
vt->capability |= V4L2_TUNER_CAP_STEREO | vt->capability |= V4L2_TUNER_CAP_STEREO |
V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2; V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2;
return 0; return 0;
......
...@@ -3046,6 +3046,8 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw) ...@@ -3046,6 +3046,8 @@ static void pvr2_subdev_update(struct pvr2_hdw *hdw)
if (hdw->input_dirty || hdw->audiomode_dirty || hdw->force_dirty) { if (hdw->input_dirty || hdw->audiomode_dirty || hdw->force_dirty) {
struct v4l2_tuner vt; struct v4l2_tuner vt;
memset(&vt, 0, sizeof(vt)); memset(&vt, 0, sizeof(vt));
vt.type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
vt.audmode = hdw->audiomode_val; vt.audmode = hdw->audiomode_val;
v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, s_tuner, &vt); v4l2_device_call_all(&hdw->v4l2_dev, 0, tuner, s_tuner, &vt);
} }
...@@ -5171,6 +5173,8 @@ void pvr2_hdw_status_poll(struct pvr2_hdw *hdw) ...@@ -5171,6 +5173,8 @@ void pvr2_hdw_status_poll(struct pvr2_hdw *hdw)
{ {
struct v4l2_tuner *vtp = &hdw->tuner_signal_info; struct v4l2_tuner *vtp = &hdw->tuner_signal_info;
memset(vtp, 0, sizeof(*vtp)); memset(vtp, 0, sizeof(*vtp));
vtp->type = (hdw->input_val == PVR2_CVAL_INPUT_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
hdw->tuner_signal_stale = 0; hdw->tuner_signal_stale = 0;
/* Note: There apparently is no replacement for VIDIOC_CROPCAP /* Note: There apparently is no replacement for VIDIOC_CROPCAP
using v4l2-subdev - therefore we can't support that AT ALL right using v4l2-subdev - therefore we can't support that AT ALL right
......
...@@ -724,19 +724,15 @@ static inline int check_mode(struct tuner *t, enum v4l2_tuner_type mode) ...@@ -724,19 +724,15 @@ static inline int check_mode(struct tuner *t, enum v4l2_tuner_type mode)
} }
/** /**
* set_mode_freq - Switch tuner to other mode. * set_mode - Switch tuner to other mode.
* @client: struct i2c_client pointer
* @t: a pointer to the module's internal struct_tuner * @t: a pointer to the module's internal struct_tuner
* @mode: enum v4l2_type (radio or TV) * @mode: enum v4l2_type (radio or TV)
* @freq: frequency to set (0 means to use the previous one)
* *
* If tuner doesn't support the needed mode (radio or TV), prints a * If tuner doesn't support the needed mode (radio or TV), prints a
* debug message and returns -EINVAL, changing its state to standby. * debug message and returns -EINVAL, changing its state to standby.
* Otherwise, changes the state and sets frequency to the last value, if * Otherwise, changes the mode and returns 0.
* the tuner can sleep or if it supports both Radio and TV.
*/ */
static int set_mode_freq(struct i2c_client *client, struct tuner *t, static int set_mode(struct tuner *t, enum v4l2_tuner_type mode)
enum v4l2_tuner_type mode, unsigned int freq)
{ {
struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops;
...@@ -752,17 +748,27 @@ static int set_mode_freq(struct i2c_client *client, struct tuner *t, ...@@ -752,17 +748,27 @@ static int set_mode_freq(struct i2c_client *client, struct tuner *t,
t->mode = mode; t->mode = mode;
tuner_dbg("Changing to mode %d\n", mode); tuner_dbg("Changing to mode %d\n", mode);
} }
return 0;
}
/**
* set_freq - Set the tuner to the desired frequency.
* @t: a pointer to the module's internal struct_tuner
* @freq: frequency to set (0 means to use the current frequency)
*/
static void set_freq(struct tuner *t, unsigned int freq)
{
struct i2c_client *client = v4l2_get_subdevdata(&t->sd);
if (t->mode == V4L2_TUNER_RADIO) { if (t->mode == V4L2_TUNER_RADIO) {
if (freq) if (!freq)
t->radio_freq = freq; freq = t->radio_freq;
set_radio_freq(client, t->radio_freq); set_radio_freq(client, freq);
} else { } else {
if (freq) if (!freq)
t->tv_freq = freq; freq = t->tv_freq;
set_tv_freq(client, t->tv_freq); set_tv_freq(client, freq);
} }
return 0;
} }
/* /*
...@@ -818,6 +824,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -818,6 +824,7 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
* tuner_fixup_std - force a given video standard variant * tuner_fixup_std - force a given video standard variant
* *
* @t: tuner internal struct * @t: tuner internal struct
* @std: TV standard
* *
* A few devices or drivers have problem to detect some standard variations. * A few devices or drivers have problem to detect some standard variations.
* On other operational systems, the drivers generally have a per-country * On other operational systems, the drivers generally have a per-country
...@@ -827,57 +834,39 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -827,57 +834,39 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
* to distinguish all video standard variations, a modprobe parameter can * to distinguish all video standard variations, a modprobe parameter can
* be used to force a video standard match. * be used to force a video standard match.
*/ */
static int tuner_fixup_std(struct tuner *t) static v4l2_std_id tuner_fixup_std(struct tuner *t, v4l2_std_id std)
{ {
if ((t->std & V4L2_STD_PAL) == V4L2_STD_PAL) { if (pal[0] != '-' && (std & V4L2_STD_PAL) == V4L2_STD_PAL) {
switch (pal[0]) { switch (pal[0]) {
case '6': case '6':
tuner_dbg("insmod fixup: PAL => PAL-60\n"); return V4L2_STD_PAL_60;
t->std = V4L2_STD_PAL_60;
break;
case 'b': case 'b':
case 'B': case 'B':
case 'g': case 'g':
case 'G': case 'G':
tuner_dbg("insmod fixup: PAL => PAL-BG\n"); return V4L2_STD_PAL_BG;
t->std = V4L2_STD_PAL_BG;
break;
case 'i': case 'i':
case 'I': case 'I':
tuner_dbg("insmod fixup: PAL => PAL-I\n"); return V4L2_STD_PAL_I;
t->std = V4L2_STD_PAL_I;
break;
case 'd': case 'd':
case 'D': case 'D':
case 'k': case 'k':
case 'K': case 'K':
tuner_dbg("insmod fixup: PAL => PAL-DK\n"); return V4L2_STD_PAL_DK;
t->std = V4L2_STD_PAL_DK;
break;
case 'M': case 'M':
case 'm': case 'm':
tuner_dbg("insmod fixup: PAL => PAL-M\n"); return V4L2_STD_PAL_M;
t->std = V4L2_STD_PAL_M;
break;
case 'N': case 'N':
case 'n': case 'n':
if (pal[1] == 'c' || pal[1] == 'C') { if (pal[1] == 'c' || pal[1] == 'C')
tuner_dbg("insmod fixup: PAL => PAL-Nc\n"); return V4L2_STD_PAL_Nc;
t->std = V4L2_STD_PAL_Nc; return V4L2_STD_PAL_N;
} else {
tuner_dbg("insmod fixup: PAL => PAL-N\n");
t->std = V4L2_STD_PAL_N;
}
break;
case '-':
/* default parameter, do nothing */
break;
default: default:
tuner_warn("pal= argument not recognised\n"); tuner_warn("pal= argument not recognised\n");
break; break;
} }
} }
if ((t->std & V4L2_STD_SECAM) == V4L2_STD_SECAM) { if (secam[0] != '-' && (std & V4L2_STD_SECAM) == V4L2_STD_SECAM) {
switch (secam[0]) { switch (secam[0]) {
case 'b': case 'b':
case 'B': case 'B':
...@@ -885,63 +874,42 @@ static int tuner_fixup_std(struct tuner *t) ...@@ -885,63 +874,42 @@ static int tuner_fixup_std(struct tuner *t)
case 'G': case 'G':
case 'h': case 'h':
case 'H': case 'H':
tuner_dbg("insmod fixup: SECAM => SECAM-BGH\n"); return V4L2_STD_SECAM_B |
t->std = V4L2_STD_SECAM_B |
V4L2_STD_SECAM_G | V4L2_STD_SECAM_G |
V4L2_STD_SECAM_H; V4L2_STD_SECAM_H;
break;
case 'd': case 'd':
case 'D': case 'D':
case 'k': case 'k':
case 'K': case 'K':
tuner_dbg("insmod fixup: SECAM => SECAM-DK\n"); return V4L2_STD_SECAM_DK;
t->std = V4L2_STD_SECAM_DK;
break;
case 'l': case 'l':
case 'L': case 'L':
if ((secam[1] == 'C') || (secam[1] == 'c')) { if ((secam[1] == 'C') || (secam[1] == 'c'))
tuner_dbg("insmod fixup: SECAM => SECAM-L'\n"); return V4L2_STD_SECAM_LC;
t->std = V4L2_STD_SECAM_LC; return V4L2_STD_SECAM_L;
} else {
tuner_dbg("insmod fixup: SECAM => SECAM-L\n");
t->std = V4L2_STD_SECAM_L;
}
break;
case '-':
/* default parameter, do nothing */
break;
default: default:
tuner_warn("secam= argument not recognised\n"); tuner_warn("secam= argument not recognised\n");
break; break;
} }
} }
if ((t->std & V4L2_STD_NTSC) == V4L2_STD_NTSC) { if (ntsc[0] != '-' && (std & V4L2_STD_NTSC) == V4L2_STD_NTSC) {
switch (ntsc[0]) { switch (ntsc[0]) {
case 'm': case 'm':
case 'M': case 'M':
tuner_dbg("insmod fixup: NTSC => NTSC-M\n"); return V4L2_STD_NTSC_M;
t->std = V4L2_STD_NTSC_M;
break;
case 'j': case 'j':
case 'J': case 'J':
tuner_dbg("insmod fixup: NTSC => NTSC_M_JP\n"); return V4L2_STD_NTSC_M_JP;
t->std = V4L2_STD_NTSC_M_JP;
break;
case 'k': case 'k':
case 'K': case 'K':
tuner_dbg("insmod fixup: NTSC => NTSC_M_KR\n"); return V4L2_STD_NTSC_M_KR;
t->std = V4L2_STD_NTSC_M_KR;
break;
case '-':
/* default parameter, do nothing */
break;
default: default:
tuner_info("ntsc= argument not recognised\n"); tuner_info("ntsc= argument not recognised\n");
break; break;
} }
} }
return 0; return std;
} }
/* /*
...@@ -1058,10 +1026,9 @@ static void tuner_status(struct dvb_frontend *fe) ...@@ -1058,10 +1026,9 @@ static void tuner_status(struct dvb_frontend *fe)
static int tuner_s_radio(struct v4l2_subdev *sd) static int tuner_s_radio(struct v4l2_subdev *sd)
{ {
struct tuner *t = to_tuner(sd); struct tuner *t = to_tuner(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
if (set_mode_freq(client, t, V4L2_TUNER_RADIO, 0) == -EINVAL) if (set_mode(t, V4L2_TUNER_RADIO) == 0)
return 0; set_freq(t, 0);
return 0; return 0;
} }
...@@ -1072,16 +1039,20 @@ static int tuner_s_radio(struct v4l2_subdev *sd) ...@@ -1072,16 +1039,20 @@ static int tuner_s_radio(struct v4l2_subdev *sd)
/** /**
* tuner_s_power - controls the power state of the tuner * tuner_s_power - controls the power state of the tuner
* @sd: pointer to struct v4l2_subdev * @sd: pointer to struct v4l2_subdev
* @on: a zero value puts the tuner to sleep * @on: a zero value puts the tuner to sleep, non-zero wakes it up
*/ */
static int tuner_s_power(struct v4l2_subdev *sd, int on) static int tuner_s_power(struct v4l2_subdev *sd, int on)
{ {
struct tuner *t = to_tuner(sd); struct tuner *t = to_tuner(sd);
struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops; struct analog_demod_ops *analog_ops = &t->fe.ops.analog_ops;
/* FIXME: Why this function don't wake the tuner if on != 0 ? */ if (on) {
if (on) if (t->standby && set_mode(t, t->mode) == 0) {
tuner_dbg("Waking up tuner\n");
set_freq(t, 0);
}
return 0; return 0;
}
tuner_dbg("Putting tuner to sleep\n"); tuner_dbg("Putting tuner to sleep\n");
t->standby = true; t->standby = true;
...@@ -1093,28 +1064,36 @@ static int tuner_s_power(struct v4l2_subdev *sd, int on) ...@@ -1093,28 +1064,36 @@ static int tuner_s_power(struct v4l2_subdev *sd, int on)
static int tuner_s_std(struct v4l2_subdev *sd, v4l2_std_id std) static int tuner_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
{ {
struct tuner *t = to_tuner(sd); struct tuner *t = to_tuner(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
if (set_mode_freq(client, t, V4L2_TUNER_ANALOG_TV, 0) == -EINVAL) if (set_mode(t, V4L2_TUNER_ANALOG_TV))
return 0; return 0;
t->std = std; t->std = tuner_fixup_std(t, std);
tuner_fixup_std(t); if (t->std != std)
tuner_dbg("Fixup standard %llx to %llx\n", std, t->std);
set_freq(t, 0);
return 0; return 0;
} }
static int tuner_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) static int tuner_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
{ {
struct tuner *t = to_tuner(sd); struct tuner *t = to_tuner(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
if (set_mode_freq(client, t, f->type, f->frequency) == -EINVAL)
return 0;
if (set_mode(t, f->type) == 0)
set_freq(t, f->frequency);
return 0; return 0;
} }
/**
* tuner_g_frequency - Get the tuned frequency for the tuner
* @sd: pointer to struct v4l2_subdev
* @f: pointer to struct v4l2_frequency
*
* At return, the structure f will be filled with tuner frequency
* if the tuner matches the f->type.
* Note: f->type should be initialized before calling it.
* This is done by either video_ioctl2 or by the bridge driver.
*/
static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
{ {
struct tuner *t = to_tuner(sd); struct tuner *t = to_tuner(sd);
...@@ -1122,8 +1101,7 @@ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) ...@@ -1122,8 +1101,7 @@ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
if (check_mode(t, f->type) == -EINVAL) if (check_mode(t, f->type) == -EINVAL)
return 0; return 0;
f->type = t->mode; if (f->type == t->mode && fe_tuner_ops->get_frequency && !t->standby) {
if (fe_tuner_ops->get_frequency && !t->standby) {
u32 abs_freq; u32 abs_freq;
fe_tuner_ops->get_frequency(&t->fe, &abs_freq); fe_tuner_ops->get_frequency(&t->fe, &abs_freq);
...@@ -1131,12 +1109,22 @@ static int tuner_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f) ...@@ -1131,12 +1109,22 @@ 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 * 2, 125) :
DIV_ROUND_CLOSEST(abs_freq, 62500); DIV_ROUND_CLOSEST(abs_freq, 62500);
} else { } else {
f->frequency = (V4L2_TUNER_RADIO == t->mode) ? f->frequency = (V4L2_TUNER_RADIO == f->type) ?
t->radio_freq : t->tv_freq; t->radio_freq : t->tv_freq;
} }
return 0; return 0;
} }
/**
* tuner_g_tuner - Fill in tuner information
* @sd: pointer to struct v4l2_subdev
* @vt: pointer to struct v4l2_tuner
*
* At return, the structure vt will be filled with tuner information
* if the tuner matches vt->type.
* Note: vt->type should be initialized before calling it.
* This is done by either video_ioctl2 or by the bridge driver.
*/
static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
{ {
struct tuner *t = to_tuner(sd); struct tuner *t = to_tuner(sd);
...@@ -1145,18 +1133,18 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) ...@@ -1145,18 +1133,18 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
if (check_mode(t, vt->type) == -EINVAL) if (check_mode(t, vt->type) == -EINVAL)
return 0; return 0;
vt->type = t->mode; if (vt->type == t->mode && analog_ops->get_afc)
if (analog_ops->get_afc)
vt->afc = analog_ops->get_afc(&t->fe); 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; 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->rangelow = tv_range[0] * 16;
vt->rangehigh = tv_range[1] * 16; vt->rangehigh = tv_range[1] * 16;
return 0; return 0;
} }
/* radio mode */ /* radio mode */
if (vt->type == t->mode) {
vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; vt->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO;
if (fe_tuner_ops->get_status) { if (fe_tuner_ops->get_status) {
u32 tuner_status; u32 tuner_status;
...@@ -1169,24 +1157,34 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) ...@@ -1169,24 +1157,34 @@ static int tuner_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
} }
if (analog_ops->has_signal) if (analog_ops->has_signal)
vt->signal = analog_ops->has_signal(&t->fe); vt->signal = analog_ops->has_signal(&t->fe);
vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
vt->audmode = t->audmode; vt->audmode = t->audmode;
}
vt->capability |= V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO;
vt->rangelow = radio_range[0] * 16000; vt->rangelow = radio_range[0] * 16000;
vt->rangehigh = radio_range[1] * 16000; vt->rangehigh = radio_range[1] * 16000;
return 0; return 0;
} }
/**
* tuner_s_tuner - Set the tuner's audio mode
* @sd: pointer to struct v4l2_subdev
* @vt: pointer to struct v4l2_tuner
*
* Sets the audio mode if the tuner matches vt->type.
* Note: vt->type should be initialized before calling it.
* This is done by either video_ioctl2 or by the bridge driver.
*/
static int tuner_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt) static int tuner_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
{ {
struct tuner *t = to_tuner(sd); struct tuner *t = to_tuner(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
if (set_mode_freq(client, t, vt->type, 0) == -EINVAL) if (set_mode(t, vt->type))
return 0; return 0;
if (t->mode == V4L2_TUNER_RADIO) if (t->mode == V4L2_TUNER_RADIO)
t->audmode = vt->audmode; t->audmode = vt->audmode;
set_freq(t, 0);
return 0; return 0;
} }
...@@ -1221,7 +1219,8 @@ static int tuner_resume(struct i2c_client *c) ...@@ -1221,7 +1219,8 @@ static int tuner_resume(struct i2c_client *c)
tuner_dbg("resume\n"); tuner_dbg("resume\n");
if (!t->standby) if (!t->standby)
set_mode_freq(c, t, t->type, 0); if (set_mode(t, t->mode) == 0)
set_freq(t, 0);
return 0; return 0;
} }
......
...@@ -1822,6 +1822,8 @@ static long __video_do_ioctl(struct file *file, ...@@ -1822,6 +1822,8 @@ static long __video_do_ioctl(struct file *file,
if (!ops->vidioc_g_tuner) if (!ops->vidioc_g_tuner)
break; break;
p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
ret = ops->vidioc_g_tuner(file, fh, p); ret = ops->vidioc_g_tuner(file, fh, p);
if (!ret) if (!ret)
dbgarg(cmd, "index=%d, name=%s, type=%d, " dbgarg(cmd, "index=%d, name=%s, type=%d, "
...@@ -1840,6 +1842,8 @@ static long __video_do_ioctl(struct file *file, ...@@ -1840,6 +1842,8 @@ static long __video_do_ioctl(struct file *file,
if (!ops->vidioc_s_tuner) if (!ops->vidioc_s_tuner)
break; break;
p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
dbgarg(cmd, "index=%d, name=%s, type=%d, " dbgarg(cmd, "index=%d, name=%s, type=%d, "
"capability=0x%x, rangelow=%d, " "capability=0x%x, rangelow=%d, "
"rangehigh=%d, signal=%d, afc=%d, " "rangehigh=%d, signal=%d, afc=%d, "
...@@ -1858,6 +1862,8 @@ static long __video_do_ioctl(struct file *file, ...@@ -1858,6 +1862,8 @@ static long __video_do_ioctl(struct file *file,
if (!ops->vidioc_g_frequency) if (!ops->vidioc_g_frequency)
break; break;
p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
ret = ops->vidioc_g_frequency(file, fh, p); ret = ops->vidioc_g_frequency(file, fh, p);
if (!ret) if (!ret)
dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n", dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n",
...@@ -1940,12 +1946,18 @@ static long __video_do_ioctl(struct file *file, ...@@ -1940,12 +1946,18 @@ static long __video_do_ioctl(struct file *file,
case VIDIOC_S_HW_FREQ_SEEK: case VIDIOC_S_HW_FREQ_SEEK:
{ {
struct v4l2_hw_freq_seek *p = arg; struct v4l2_hw_freq_seek *p = arg;
enum v4l2_tuner_type type;
if (!ops->vidioc_s_hw_freq_seek) if (!ops->vidioc_s_hw_freq_seek)
break; break;
type = (vfd->vfl_type == VFL_TYPE_RADIO) ?
V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
dbgarg(cmd, dbgarg(cmd,
"tuner=%d, type=%d, seek_upward=%d, wrap_around=%d\n", "tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u\n",
p->tuner, p->type, p->seek_upward, p->wrap_around); p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing);
if (p->type != type)
ret = -EINVAL;
else
ret = ops->vidioc_s_hw_freq_seek(file, fh, p); ret = ops->vidioc_s_hw_freq_seek(file, fh, p);
break; break;
} }
......
...@@ -173,16 +173,20 @@ struct v4l2_subdev_core_ops { ...@@ -173,16 +173,20 @@ struct v4l2_subdev_core_ops {
struct v4l2_event_subscription *sub); struct v4l2_event_subscription *sub);
}; };
/* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio. /* s_radio: v4l device was opened in radio mode.
s_radio: v4l device was opened in Radio mode, to be replaced by s_mode. g_frequency: freq->type must be filled in. Normally done by video_ioctl2
or the bridge driver.
g_tuner:
s_tuner: vt->type must be filled in. Normally done by video_ioctl2 or the
bridge driver.
s_type_addr: sets tuner type and its I2C addr. s_type_addr: sets tuner type and its I2C addr.
s_config: sets tda9887 specific stuff, like port1, port2 and qss s_config: sets tda9887 specific stuff, like port1, port2 and qss
*/ */
struct v4l2_subdev_tuner_ops { struct v4l2_subdev_tuner_ops {
int (*s_mode)(struct v4l2_subdev *sd, enum v4l2_tuner_type);
int (*s_radio)(struct v4l2_subdev *sd); int (*s_radio)(struct v4l2_subdev *sd);
int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); int (*s_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq); int (*g_frequency)(struct v4l2_subdev *sd, struct v4l2_frequency *freq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment