V4L/DVB (3256): When in radio mode ignore VIDIOC_G_TUNER
authorHans Verkuil <hverkuil@xs4all.nl>
Mon, 9 Jan 2006 17:25:44 +0000 (15:25 -0200)
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>
Mon, 9 Jan 2006 17:25:44 +0000 (15:25 -0200)
- Detect when AUDC_SET_RADIO is called.
- When in radio mode ignore VIDIOC_G_TUNER.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
drivers/media/video/cx25840/cx25840-core.c
drivers/media/video/cx25840/cx25840.h
drivers/media/video/saa7115.c

index a897d6b..0760726 100644 (file)
@@ -440,6 +440,9 @@ static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
        case V4L2_CID_AUDIO_BALANCE:
        case V4L2_CID_AUDIO_MUTE:
                return cx25840_audio(client, VIDIOC_S_CTRL, ctrl);
+
+       default:
+               return -EINVAL;
        }
 
        return 0;
@@ -564,12 +567,8 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
 {
        struct cx25840_state *state = i2c_get_clientdata(client);
        struct v4l2_tuner *vt = arg;
-       int result = 0;
 
        switch (cmd) {
-       case 0:
-               break;
-
 #ifdef CONFIG_VIDEO_ADV_DEBUG
        /* ioctls to allow direct access to the
         * cx25840 registers for testing */
@@ -600,8 +599,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
                return cx25840_vbi(client, cmd, arg);
 
        case VIDIOC_INT_AUDIO_CLOCK_FREQ:
-               result = cx25840_audio(client, cmd, arg);
-               break;
+               return cx25840_audio(client, cmd, arg);
 
        case VIDIOC_STREAMON:
                cx25840_dbg("enable output\n");
@@ -620,19 +618,21 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
                break;
 
        case VIDIOC_G_CTRL:
-               result = get_v4lctrl(client, (struct v4l2_control *)arg);
-               break;
+               return get_v4lctrl(client, (struct v4l2_control *)arg);
 
        case VIDIOC_S_CTRL:
-               result = set_v4lctrl(client, (struct v4l2_control *)arg);
-               break;
+               return set_v4lctrl(client, (struct v4l2_control *)arg);
 
        case VIDIOC_G_STD:
                *(v4l2_std_id *)arg = cx25840_get_v4lstd(client);
                break;
 
        case VIDIOC_S_STD:
-               result = set_v4lstd(client, *(v4l2_std_id *)arg);
+               state->radio = 0;
+               return set_v4lstd(client, *(v4l2_std_id *)arg);
+
+       case AUDC_SET_RADIO:
+               state->radio = 1;
                break;
 
        case VIDIOC_G_INPUT:
@@ -640,15 +640,13 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
                break;
 
        case VIDIOC_S_INPUT:
-               result = set_input(client, *(enum cx25840_video_input *)arg, state->aud_input);
-               break;
+               return set_input(client, *(enum cx25840_video_input *)arg, state->aud_input);
 
        case VIDIOC_S_AUDIO:
        {
                struct v4l2_audio *input = arg;
 
-               result = set_input(client, state->vid_input, input->index);
-               break;
+               return set_input(client, state->vid_input, input->index);
        }
 
        case VIDIOC_G_AUDIO:
@@ -671,6 +669,9 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
                u8 vpres = cx25840_read(client, 0x80a) & 0x10;
                int val = 0;
 
+               if (state->radio)
+                       break;
+
                vt->capability |=
                    V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 |
                    V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
@@ -725,12 +726,10 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
                break;
 
        case VIDIOC_G_FMT:
-               result = get_v4lfmt(client, (struct v4l2_format *)arg);
-               break;
+               return get_v4lfmt(client, (struct v4l2_format *)arg);
 
        case VIDIOC_S_FMT:
-               result = set_v4lfmt(client, (struct v4l2_format *)arg);
-               break;
+               return set_v4lfmt(client, (struct v4l2_format *)arg);
 
        case VIDIOC_INT_RESET:
                cx25840_initialize(client, 0);
@@ -742,11 +741,10 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
                break;
 
        default:
-               cx25840_err("invalid ioctl %x\n", cmd);
                return -EINVAL;
        }
 
-       return result;
+       return 0;
 }
 
 /* ----------------------------------------------------------------------- */
index 3dc67e7..dc58d42 100644 (file)
@@ -89,6 +89,7 @@ enum cx25840_audio_input {
 
 struct cx25840_state {
        int pvr150_workaround;
+       int radio;
        enum cx25840_video_input vid_input;
        enum cx25840_audio_input aud_input;
        u32 audclk_freq;
index 5d33d09..9f550fd 100644 (file)
@@ -74,6 +74,7 @@ struct saa7115_state {
        v4l2_std_id std;
        int input;
        int enable;
+       int radio;
        int bright;
        int contrast;
        int hue;
@@ -634,6 +635,9 @@ static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *c
                state->hue = ctrl->value;
                saa7115_write(client, 0x0d, state->hue);
                break;
+
+       default:
+               return -EINVAL;
        }
 
        return 0;
@@ -1043,6 +1047,8 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
                struct v4l2_tuner *vt = arg;
                int status;
 
+               if (state->radio)
+                       break;
                status = saa7115_read(client, 0x1f);
 
                saa7115_dbg("status: 0x%02x\n", status);
@@ -1065,9 +1071,14 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
                break;
 
        case VIDIOC_S_STD:
+               state->radio = 0;
                saa7115_set_v4lstd(client, *(v4l2_std_id *)arg);
                break;
 
+       case AUDC_SET_RADIO:
+               state->radio = 1;
+               break;
+
        case VIDIOC_G_INPUT:
                *(int *)arg = state->input;
                break;
@@ -1230,6 +1241,7 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
        state->std = V4L2_STD_NTSC;
        state->input = -1;
        state->enable = 1;
+       state->radio = 0;
        state->bright = 128;
        state->contrast = 64;
        state->hue = 0;