Merge branch 'master' into upstream-fixes
[powerpc.git] / drivers / media / video / cx25840 / cx25840-core.c
index cb9e862..7bb7589 100644 (file)
@@ -104,8 +104,8 @@ u32 cx25840_read4(struct i2c_client * client, u16 addr)
        if (i2c_master_recv(client, buffer, 4) < 4)
                return 0;
 
-       return (buffer[0] << 24) | (buffer[1] << 16) |
-           (buffer[2] << 8) | buffer[3];
+       return (buffer[3] << 24) | (buffer[2] << 16) |
+           (buffer[1] << 8) | buffer[0];
 }
 
 int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned and_mask,
@@ -617,95 +617,6 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
 
 /* ----------------------------------------------------------------------- */
 
-static struct v4l2_queryctrl cx25836_qctrl[] = {
-       {
-               .id            = V4L2_CID_BRIGHTNESS,
-               .type          = V4L2_CTRL_TYPE_INTEGER,
-               .name          = "Brightness",
-               .minimum       = 0,
-               .maximum       = 255,
-               .step          = 1,
-               .default_value = 128,
-               .flags         = 0,
-       }, {
-               .id            = V4L2_CID_CONTRAST,
-               .type          = V4L2_CTRL_TYPE_INTEGER,
-               .name          = "Contrast",
-               .minimum       = 0,
-               .maximum       = 127,
-               .step          = 1,
-               .default_value = 64,
-               .flags         = 0,
-       }, {
-               .id            = V4L2_CID_SATURATION,
-               .type          = V4L2_CTRL_TYPE_INTEGER,
-               .name          = "Saturation",
-               .minimum       = 0,
-               .maximum       = 127,
-               .step          = 1,
-               .default_value = 64,
-               .flags         = 0,
-       }, {
-               .id            = V4L2_CID_HUE,
-               .type          = V4L2_CTRL_TYPE_INTEGER,
-               .name          = "Hue",
-               .minimum       = -128,
-               .maximum       = 127,
-               .step          = 1,
-               .default_value = 0,
-               .flags         = 0,
-       },
-};
-
-static struct v4l2_queryctrl cx25840_qctrl[] = {
-       {
-               .id            = V4L2_CID_AUDIO_VOLUME,
-               .type          = V4L2_CTRL_TYPE_INTEGER,
-               .name          = "Volume",
-               .minimum       = 0,
-               .maximum       = 65535,
-               .step          = 65535/100,
-               .default_value = 58880,
-               .flags         = 0,
-       }, {
-               .id            = V4L2_CID_AUDIO_BALANCE,
-               .type          = V4L2_CTRL_TYPE_INTEGER,
-               .name          = "Balance",
-               .minimum       = 0,
-               .maximum       = 65535,
-               .step          = 65535/100,
-               .default_value = 32768,
-               .flags         = 0,
-       }, {
-               .id            = V4L2_CID_AUDIO_MUTE,
-               .type          = V4L2_CTRL_TYPE_BOOLEAN,
-               .name          = "Mute",
-               .minimum       = 0,
-               .maximum       = 1,
-               .step          = 1,
-               .default_value = 1,
-               .flags         = 0,
-       }, {
-               .id            = V4L2_CID_AUDIO_BASS,
-               .type          = V4L2_CTRL_TYPE_INTEGER,
-               .name          = "Bass",
-               .minimum       = 0,
-               .maximum       = 65535,
-               .step          = 65535/100,
-               .default_value = 32768,
-       }, {
-               .id            = V4L2_CID_AUDIO_TREBLE,
-               .type          = V4L2_CTRL_TYPE_INTEGER,
-               .name          = "Treble",
-               .minimum       = 0,
-               .maximum       = 65535,
-               .step          = 65535/100,
-               .default_value = 32768,
-       },
-};
-
-/* ----------------------------------------------------------------------- */
-
 static int cx25840_command(struct i2c_client *client, unsigned int cmd,
                           void *arg)
 {
@@ -773,21 +684,29 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
        case VIDIOC_QUERYCTRL:
        {
                struct v4l2_queryctrl *qc = arg;
-               int i;
 
-               for (i = 0; i < ARRAY_SIZE(cx25836_qctrl); i++)
-                       if (qc->id && qc->id == cx25836_qctrl[i].id) {
-                               memcpy(qc, &cx25836_qctrl[i], sizeof(*qc));
-                               return 0;
-                       }
+               switch (qc->id) {
+                       case V4L2_CID_BRIGHTNESS:
+                       case V4L2_CID_CONTRAST:
+                       case V4L2_CID_SATURATION:
+                       case V4L2_CID_HUE:
+                               return v4l2_ctrl_query_fill_std(qc);
+                       default:
+                               break;
+               }
                if (state->is_cx25836)
                        return -EINVAL;
 
-               for (i = 0; i < ARRAY_SIZE(cx25840_qctrl); i++)
-                       if (qc->id && qc->id == cx25840_qctrl[i].id) {
-                               memcpy(qc, &cx25840_qctrl[i], sizeof(*qc));
-                               return 0;
-                       }
+               switch (qc->id) {
+                       case V4L2_CID_AUDIO_VOLUME:
+                       case V4L2_CID_AUDIO_MUTE:
+                       case V4L2_CID_AUDIO_BALANCE:
+                       case V4L2_CID_AUDIO_BASS:
+                       case V4L2_CID_AUDIO_TREBLE:
+                               return v4l2_ctrl_query_fill_std(qc);
+                       default:
+                               return -EINVAL;
+               }
                return -EINVAL;
        }