Commit 6d04203c authored by Frej Drejhammar's avatar Frej Drejhammar Committed by Mauro Carvalho Chehab

V4L/DVB (7451): cx88: Add user control for chroma AGC

The cx2388x family has support for chroma AGC. This patch implements a
the V4L2_CID_CHROMA_AGC control for the cx2388x family. By default
chroma AGC is disabled, as in previous versions of the driver.

Signed-off-by: "Frej Drejhammar <frej.drejhammar@gmail.com>"
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 1c412d12
...@@ -693,7 +693,7 @@ static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qc ...@@ -693,7 +693,7 @@ static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qc
return -EINVAL; return -EINVAL;
/* Standard V4L2 controls */ /* Standard V4L2 controls */
if (cx8800_ctrl_query(qctrl) == 0) if (cx8800_ctrl_query(dev->core, qctrl) == 0)
return 0; return 0;
/* MPEG V4L2 controls */ /* MPEG V4L2 controls */
...@@ -933,7 +933,7 @@ static int vidioc_queryctrl (struct file *file, void *priv, ...@@ -933,7 +933,7 @@ static int vidioc_queryctrl (struct file *file, void *priv,
qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
if (unlikely(qctrl->id == 0)) if (unlikely(qctrl->id == 0))
return -EINVAL; return -EINVAL;
return cx8800_ctrl_query(qctrl); return cx8800_ctrl_query(dev->core, qctrl);
} }
static int vidioc_enum_input (struct file *file, void *priv, static int vidioc_enum_input (struct file *file, void *priv,
......
...@@ -929,7 +929,11 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) ...@@ -929,7 +929,11 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n",
cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f);
cx_andor(MO_INPUT_FORMAT, 0xf, cxiformat); /* Chroma AGC must be disabled if SECAM is used */
if (norm & V4L2_STD_SECAM)
cx_andor(MO_INPUT_FORMAT, 0x40f, cxiformat);
else
cx_andor(MO_INPUT_FORMAT, 0xf, cxiformat);
// FIXME: as-is from DScaler // FIXME: as-is from DScaler
dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n",
......
...@@ -228,6 +228,18 @@ static struct cx88_ctrl cx8800_ctls[] = { ...@@ -228,6 +228,18 @@ static struct cx88_ctrl cx8800_ctls[] = {
.mask = 0x00ff, .mask = 0x00ff,
.shift = 0, .shift = 0,
},{ },{
.v = {
.id = V4L2_CID_CHROMA_AGC,
.name = "Chroma AGC",
.minimum = 0,
.maximum = 1,
.default_value = 0x0,
.type = V4L2_CTRL_TYPE_BOOLEAN,
},
.reg = MO_INPUT_FORMAT,
.mask = 1 << 10,
.shift = 10,
}, {
/* --- audio --- */ /* --- audio --- */
.v = { .v = {
.id = V4L2_CID_AUDIO_MUTE, .id = V4L2_CID_AUDIO_MUTE,
...@@ -282,6 +294,7 @@ const u32 cx88_user_ctrls[] = { ...@@ -282,6 +294,7 @@ const u32 cx88_user_ctrls[] = {
V4L2_CID_AUDIO_VOLUME, V4L2_CID_AUDIO_VOLUME,
V4L2_CID_AUDIO_BALANCE, V4L2_CID_AUDIO_BALANCE,
V4L2_CID_AUDIO_MUTE, V4L2_CID_AUDIO_MUTE,
V4L2_CID_CHROMA_AGC,
0 0
}; };
EXPORT_SYMBOL(cx88_user_ctrls); EXPORT_SYMBOL(cx88_user_ctrls);
...@@ -291,7 +304,7 @@ static const u32 *ctrl_classes[] = { ...@@ -291,7 +304,7 @@ static const u32 *ctrl_classes[] = {
NULL NULL
}; };
int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl) int cx8800_ctrl_query(struct cx88_core *core, struct v4l2_queryctrl *qctrl)
{ {
int i; int i;
...@@ -306,6 +319,11 @@ int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl) ...@@ -306,6 +319,11 @@ int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl)
return 0; return 0;
} }
*qctrl = cx8800_ctls[i].v; *qctrl = cx8800_ctls[i].v;
/* Report chroma AGC as inactive when SECAM is selected */
if (cx8800_ctls[i].v.id == V4L2_CID_CHROMA_AGC &&
core->tvnorm & V4L2_STD_SECAM)
qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE;
return 0; return 0;
} }
EXPORT_SYMBOL(cx8800_ctrl_query); EXPORT_SYMBOL(cx8800_ctrl_query);
...@@ -976,6 +994,12 @@ int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl) ...@@ -976,6 +994,12 @@ int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl)
} }
mask=0xffff; mask=0xffff;
break; break;
case V4L2_CID_CHROMA_AGC:
/* Do not allow chroma AGC to be enabled for SECAM */
value = ((ctl->value - c->off) << c->shift) & c->mask;
if (core->tvnorm & V4L2_STD_SECAM && value)
return -EINVAL;
break;
default: default:
value = ((ctl->value - c->off) << c->shift) & c->mask; value = ((ctl->value - c->off) << c->shift) & c->mask;
break; break;
...@@ -1268,10 +1292,12 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int i) ...@@ -1268,10 +1292,12 @@ 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 *qctrl) struct v4l2_queryctrl *qctrl)
{ {
struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core;
qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
if (unlikely(qctrl->id == 0)) if (unlikely(qctrl->id == 0))
return -EINVAL; return -EINVAL;
return cx8800_ctrl_query(qctrl); return cx8800_ctrl_query(core, qctrl);
} }
static int vidioc_g_ctrl (struct file *file, void *priv, static int vidioc_g_ctrl (struct file *file, void *priv,
......
...@@ -651,7 +651,8 @@ void cx8802_cancel_buffers(struct cx8802_dev *dev); ...@@ -651,7 +651,8 @@ void cx8802_cancel_buffers(struct cx8802_dev *dev);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* cx88-video.c*/ /* cx88-video.c*/
extern const u32 cx88_user_ctrls[]; extern const u32 cx88_user_ctrls[];
extern int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl); extern int cx8800_ctrl_query(struct cx88_core *core,
struct v4l2_queryctrl *qctrl);
int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i); int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i);
int cx88_set_freq (struct cx88_core *core,struct v4l2_frequency *f); int cx88_set_freq (struct cx88_core *core,struct v4l2_frequency *f);
int cx88_get_control(struct cx88_core *core, struct v4l2_control *ctl); int cx88_get_control(struct cx88_core *core, struct v4l2_control *ctl);
......
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