Commit 18318e00 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (4192): Use control helpers for saa7115, cx25840, msp3400.

Replace hardcoded control description by the standard ones supplied
by v4l2-common.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 5d1a9ae6
...@@ -617,95 +617,6 @@ static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) ...@@ -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, static int cx25840_command(struct i2c_client *client, unsigned int cmd,
void *arg) void *arg)
{ {
...@@ -773,21 +684,29 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd, ...@@ -773,21 +684,29 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
case VIDIOC_QUERYCTRL: case VIDIOC_QUERYCTRL:
{ {
struct v4l2_queryctrl *qc = arg; struct v4l2_queryctrl *qc = arg;
int i;
for (i = 0; i < ARRAY_SIZE(cx25836_qctrl); i++) switch (qc->id) {
if (qc->id && qc->id == cx25836_qctrl[i].id) { case V4L2_CID_BRIGHTNESS:
memcpy(qc, &cx25836_qctrl[i], sizeof(*qc)); case V4L2_CID_CONTRAST:
return 0; case V4L2_CID_SATURATION:
} case V4L2_CID_HUE:
return v4l2_ctrl_query_fill_std(qc);
default:
break;
}
if (state->is_cx25836) if (state->is_cx25836)
return -EINVAL; return -EINVAL;
for (i = 0; i < ARRAY_SIZE(cx25840_qctrl); i++) switch (qc->id) {
if (qc->id && qc->id == cx25840_qctrl[i].id) { case V4L2_CID_AUDIO_VOLUME:
memcpy(qc, &cx25840_qctrl[i], sizeof(*qc)); case V4L2_CID_AUDIO_MUTE:
return 0; 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; return -EINVAL;
} }
......
...@@ -385,67 +385,6 @@ static int msp_mode_v4l1_to_v4l2(int mode) ...@@ -385,67 +385,6 @@ static int msp_mode_v4l1_to_v4l2(int mode)
return V4L2_TUNER_MODE_MONO; return V4L2_TUNER_MODE_MONO;
} }
static struct v4l2_queryctrl msp_qctrl_std[] = {
{
.id = V4L2_CID_AUDIO_VOLUME,
.name = "Volume",
.minimum = 0,
.maximum = 65535,
.step = 65535/100,
.default_value = 58880,
.flags = 0,
.type = V4L2_CTRL_TYPE_INTEGER,
},{
.id = V4L2_CID_AUDIO_MUTE,
.name = "Mute",
.minimum = 0,
.maximum = 1,
.step = 1,
.default_value = 1,
.flags = 0,
.type = V4L2_CTRL_TYPE_BOOLEAN,
},
};
static struct v4l2_queryctrl msp_qctrl_sound_processing[] = {
{
.id = V4L2_CID_AUDIO_BALANCE,
.name = "Balance",
.minimum = 0,
.maximum = 65535,
.step = 65535/100,
.default_value = 32768,
.flags = 0,
.type = V4L2_CTRL_TYPE_INTEGER,
},{
.id = V4L2_CID_AUDIO_BASS,
.name = "Bass",
.minimum = 0,
.maximum = 65535,
.step = 65535/100,
.default_value = 32768,
.type = V4L2_CTRL_TYPE_INTEGER,
},{
.id = V4L2_CID_AUDIO_TREBLE,
.name = "Treble",
.minimum = 0,
.maximum = 65535,
.step = 65535/100,
.default_value = 32768,
.type = V4L2_CTRL_TYPE_INTEGER,
},{
.id = V4L2_CID_AUDIO_LOUDNESS,
.name = "Loudness",
.minimum = 0,
.maximum = 1,
.step = 1,
.default_value = 1,
.flags = 0,
.type = V4L2_CTRL_TYPE_BOOLEAN,
},
};
static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl) static int msp_get_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
{ {
struct msp_state *state = i2c_get_clientdata(client); struct msp_state *state = i2c_get_clientdata(client);
...@@ -753,21 +692,25 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -753,21 +692,25 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
case VIDIOC_QUERYCTRL: case VIDIOC_QUERYCTRL:
{ {
struct v4l2_queryctrl *qc = arg; struct v4l2_queryctrl *qc = arg;
int i;
for (i = 0; i < ARRAY_SIZE(msp_qctrl_std); i++) switch (qc->id) {
if (qc->id && qc->id == msp_qctrl_std[i].id) { case V4L2_CID_AUDIO_VOLUME:
memcpy(qc, &msp_qctrl_std[i], sizeof(*qc)); case V4L2_CID_AUDIO_MUTE:
return 0; return v4l2_ctrl_query_fill_std(qc);
} default:
break;
}
if (!state->has_sound_processing) if (!state->has_sound_processing)
return -EINVAL; return -EINVAL;
for (i = 0; i < ARRAY_SIZE(msp_qctrl_sound_processing); i++) switch (qc->id) {
if (qc->id && qc->id == msp_qctrl_sound_processing[i].id) { case V4L2_CID_AUDIO_LOUDNESS:
memcpy(qc, &msp_qctrl_sound_processing[i], sizeof(*qc)); case V4L2_CID_AUDIO_BALANCE:
return 0; case V4L2_CID_AUDIO_BASS:
} case V4L2_CID_AUDIO_TREBLE:
return -EINVAL; return v4l2_ctrl_query_fill_std(qc);
default:
return -EINVAL;
}
} }
case VIDIOC_G_CTRL: case VIDIOC_G_CTRL:
......
...@@ -1090,48 +1090,6 @@ static void saa7115_decode_vbi_line(struct i2c_client *client, ...@@ -1090,48 +1090,6 @@ static void saa7115_decode_vbi_line(struct i2c_client *client,
/* ============ SAA7115 AUDIO settings (end) ============= */ /* ============ SAA7115 AUDIO settings (end) ============= */
static struct v4l2_queryctrl saa7115_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 int saa7115_command(struct i2c_client *client, unsigned int cmd, void *arg) static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *arg)
{ {
struct saa7115_state *state = i2c_get_clientdata(client); struct saa7115_state *state = i2c_get_clientdata(client);
...@@ -1175,14 +1133,16 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar ...@@ -1175,14 +1133,16 @@ static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *ar
case VIDIOC_QUERYCTRL: case VIDIOC_QUERYCTRL:
{ {
struct v4l2_queryctrl *qc = arg; struct v4l2_queryctrl *qc = arg;
int i;
for (i = 0; i < ARRAY_SIZE(saa7115_qctrl); i++) switch (qc->id) {
if (qc->id && qc->id == saa7115_qctrl[i].id) { case V4L2_CID_BRIGHTNESS:
memcpy(qc, &saa7115_qctrl[i], sizeof(*qc)); case V4L2_CID_CONTRAST:
return 0; case V4L2_CID_SATURATION:
} case V4L2_CID_HUE:
return -EINVAL; return v4l2_ctrl_query_fill_std(qc);
default:
return -EINVAL;
}
} }
case VIDIOC_G_STD: case VIDIOC_G_STD:
......
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