Commit 2e70db9a authored by Dean Anderson's avatar Dean Anderson Committed by Mauro Carvalho Chehab

V4L/DVB: s2255drv: cleanup of V4L2 controls

Signed-off-by: default avatarDean Anderson <dean@sensoray.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 3fa00605
...@@ -310,7 +310,7 @@ struct s2255_fh { ...@@ -310,7 +310,7 @@ struct s2255_fh {
/* Need DSP version 5+ for video status feature */ /* Need DSP version 5+ for video status feature */
#define S2255_MIN_DSP_STATUS 5 #define S2255_MIN_DSP_STATUS 5
#define S2255_MAJOR_VERSION 1 #define S2255_MAJOR_VERSION 1
#define S2255_MINOR_VERSION 16 #define S2255_MINOR_VERSION 17
#define S2255_RELEASE 0 #define S2255_RELEASE 0
#define S2255_VERSION KERNEL_VERSION(S2255_MAJOR_VERSION, \ #define S2255_VERSION KERNEL_VERSION(S2255_MAJOR_VERSION, \
S2255_MINOR_VERSION, \ S2255_MINOR_VERSION, \
...@@ -384,49 +384,6 @@ MODULE_DEVICE_TABLE(usb, s2255_table); ...@@ -384,49 +384,6 @@ MODULE_DEVICE_TABLE(usb, s2255_table);
#define BUFFER_TIMEOUT msecs_to_jiffies(400) #define BUFFER_TIMEOUT msecs_to_jiffies(400)
/* supported controls */
static struct v4l2_queryctrl s2255_qctrl[] = {
{
.id = V4L2_CID_BRIGHTNESS,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Brightness",
.minimum = -127,
.maximum = 128,
.step = 1,
.default_value = 0,
.flags = 0,
}, {
.id = V4L2_CID_CONTRAST,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Contrast",
.minimum = 0,
.maximum = 255,
.step = 0x1,
.default_value = DEF_CONTRAST,
.flags = 0,
}, {
.id = V4L2_CID_SATURATION,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Saturation",
.minimum = 0,
.maximum = 255,
.step = 0x1,
.default_value = DEF_SATURATION,
.flags = 0,
}, {
.id = V4L2_CID_HUE,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Hue",
.minimum = 0,
.maximum = 255,
.step = 0x1,
.default_value = DEF_HUE,
.flags = 0,
}
};
static int qctl_regs[ARRAY_SIZE(s2255_qctrl)];
/* image formats. */ /* image formats. */
static const struct s2255_fmt formats[] = { static const struct s2255_fmt formats[] = {
{ {
...@@ -1472,74 +1429,82 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) ...@@ -1472,74 +1429,82 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
static int vidioc_queryctrl(struct file *file, void *priv, static int vidioc_queryctrl(struct file *file, void *priv,
struct v4l2_queryctrl *qc) struct v4l2_queryctrl *qc)
{ {
int i; switch (qc->id) {
case V4L2_CID_BRIGHTNESS:
for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++) v4l2_ctrl_query_fill(qc, -127, 127, 1, DEF_BRIGHT);
if (qc->id && qc->id == s2255_qctrl[i].id) { break;
memcpy(qc, &(s2255_qctrl[i]), sizeof(*qc)); case V4L2_CID_CONTRAST:
return 0; v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_CONTRAST);
} break;
case V4L2_CID_SATURATION:
dprintk(4, "query_ctrl -EINVAL %d\n", qc->id); v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_SATURATION);
return -EINVAL; break;
case V4L2_CID_HUE:
v4l2_ctrl_query_fill(qc, 0, 255, 1, DEF_HUE);
break;
default:
return -EINVAL;
}
dprintk(4, "%s, id %d\n", __func__, qc->id);
return 0;
} }
static int vidioc_g_ctrl(struct file *file, void *priv, static int vidioc_g_ctrl(struct file *file, void *priv,
struct v4l2_control *ctrl) struct v4l2_control *ctrl)
{ {
int i; struct s2255_fh *fh = priv;
switch (ctrl->id) {
for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++) case V4L2_CID_BRIGHTNESS:
if (ctrl->id == s2255_qctrl[i].id) { ctrl->value = fh->mode.bright;
ctrl->value = qctl_regs[i]; break;
return 0; case V4L2_CID_CONTRAST:
} ctrl->value = fh->mode.contrast;
dprintk(4, "g_ctrl -EINVAL\n"); break;
case V4L2_CID_SATURATION:
return -EINVAL; ctrl->value = fh->mode.saturation;
break;
case V4L2_CID_HUE:
ctrl->value = fh->mode.hue;
break;
default:
return -EINVAL;
}
dprintk(4, "%s, id %d val %d\n", __func__, ctrl->id, ctrl->value);
return 0;
} }
static int vidioc_s_ctrl(struct file *file, void *priv, static int vidioc_s_ctrl(struct file *file, void *priv,
struct v4l2_control *ctrl) struct v4l2_control *ctrl)
{ {
int i;
struct s2255_fh *fh = priv; struct s2255_fh *fh = priv;
struct s2255_dev *dev = fh->dev; struct s2255_dev *dev = fh->dev;
struct s2255_mode *mode; struct s2255_mode *mode;
mode = &fh->mode; mode = &fh->mode;
dprintk(4, "vidioc_s_ctrl\n"); dprintk(4, "%s\n", __func__);
for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++) { /* update the mode to the corresponding value */
if (ctrl->id == s2255_qctrl[i].id) { switch (ctrl->id) {
if (ctrl->value < s2255_qctrl[i].minimum || case V4L2_CID_BRIGHTNESS:
ctrl->value > s2255_qctrl[i].maximum) mode->bright = ctrl->value;
return -ERANGE; break;
case V4L2_CID_CONTRAST:
qctl_regs[i] = ctrl->value; mode->contrast = ctrl->value;
/* update the mode to the corresponding value */ break;
switch (ctrl->id) { case V4L2_CID_HUE:
case V4L2_CID_BRIGHTNESS: mode->hue = ctrl->value;
mode->bright = ctrl->value; break;
break; case V4L2_CID_SATURATION:
case V4L2_CID_CONTRAST: mode->saturation = ctrl->value;
mode->contrast = ctrl->value; break;
break; default:
case V4L2_CID_HUE: return -EINVAL;
mode->hue = ctrl->value;
break;
case V4L2_CID_SATURATION:
mode->saturation = ctrl->value;
break;
}
mode->restart = 0;
/* set mode here. Note: stream does not need restarted.
some V4L programs restart stream unnecessarily
after a s_crtl.
*/
s2255_set_mode(dev, fh->channel, mode);
return 0;
}
} }
return -EINVAL; mode->restart = 0;
/* set mode here. Note: stream does not need restarted.
some V4L programs restart stream unnecessarily
after a s_crtl.
*/
s2255_set_mode(dev, fh->channel, mode);
return 0;
} }
static int vidioc_g_jpegcomp(struct file *file, void *priv, static int vidioc_g_jpegcomp(struct file *file, void *priv,
...@@ -1701,18 +1666,11 @@ static int s2255_open(struct file *file) ...@@ -1701,18 +1666,11 @@ static int s2255_open(struct file *file)
fh->width = LINE_SZ_4CIFS_NTSC; fh->width = LINE_SZ_4CIFS_NTSC;
fh->height = NUM_LINES_4CIFS_NTSC * 2; fh->height = NUM_LINES_4CIFS_NTSC * 2;
fh->channel = cur_channel; fh->channel = cur_channel;
/* configure channel to default state */ /* configure channel to default state */
if (!dev->chn_configured[cur_channel]) { if (!dev->chn_configured[cur_channel]) {
s2255_set_mode(dev, cur_channel, &fh->mode); s2255_set_mode(dev, cur_channel, &fh->mode);
dev->chn_configured[cur_channel] = 1; dev->chn_configured[cur_channel] = 1;
} }
/* Put all controls at a sane state */
for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
qctl_regs[i] = s2255_qctrl[i].default_value;
dprintk(1, "s2255drv: open dev=%s type=%s users=%d\n", dprintk(1, "s2255drv: open dev=%s type=%s users=%d\n",
video_device_node_name(vdev), v4l2_type_names[type], video_device_node_name(vdev), v4l2_type_names[type],
dev->users[cur_channel]); dev->users[cur_channel]);
......
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