Commit 70f00044 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

V4L/DVB (3162): Some fixes at cx88 controls

- Now, default control values at cx88_cx8800_ctls are honored
- default value for contrast/saturation were changed to be
in line with available documentation for the chipset;
- Removed some bad coding at set_control;
- U/V Saturation now changes proportionally
Signed-off-by: default avatarMichael Krufky <mkrufky@m1k.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@brturbo.com.br>
parent 5ea892f1
...@@ -240,7 +240,7 @@ static struct cx88_ctrl cx8800_ctls[] = { ...@@ -240,7 +240,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
.minimum = 0, .minimum = 0,
.maximum = 0xff, .maximum = 0xff,
.step = 1, .step = 1,
.default_value = 0, .default_value = 0x3f,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
}, },
.off = 0, .off = 0,
...@@ -271,7 +271,7 @@ static struct cx88_ctrl cx8800_ctls[] = { ...@@ -271,7 +271,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
.minimum = 0, .minimum = 0,
.maximum = 0xff, .maximum = 0xff,
.step = 1, .step = 1,
.default_value = 0, .default_value = 0x7f,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
}, },
.off = 0, .off = 0,
...@@ -285,6 +285,7 @@ static struct cx88_ctrl cx8800_ctls[] = { ...@@ -285,6 +285,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
.name = "Mute", .name = "Mute",
.minimum = 0, .minimum = 0,
.maximum = 1, .maximum = 1,
.default_value = 1,
.type = V4L2_CTRL_TYPE_BOOLEAN, .type = V4L2_CTRL_TYPE_BOOLEAN,
}, },
.reg = AUD_VOL_CTL, .reg = AUD_VOL_CTL,
...@@ -298,7 +299,7 @@ static struct cx88_ctrl cx8800_ctls[] = { ...@@ -298,7 +299,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
.minimum = 0, .minimum = 0,
.maximum = 0x3f, .maximum = 0x3f,
.step = 1, .step = 1,
.default_value = 0, .default_value = 0x1f,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
}, },
.reg = AUD_VOL_CTL, .reg = AUD_VOL_CTL,
...@@ -917,6 +918,9 @@ static int get_control(struct cx88_core *core, struct v4l2_control *ctl) ...@@ -917,6 +918,9 @@ static int get_control(struct cx88_core *core, struct v4l2_control *ctl)
ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift; ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift;
break; break;
} }
printk("get_control id=0x%X reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
ctl->id, c->reg, ctl->value,
c->mask, c->sreg ? " [shadowed]" : "");
return 0; return 0;
} }
...@@ -925,13 +929,13 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl) ...@@ -925,13 +929,13 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
{ {
/* struct cx88_core *core = dev->core; */ /* struct cx88_core *core = dev->core; */
struct cx88_ctrl *c = NULL; struct cx88_ctrl *c = NULL;
u32 v_sat_value; u32 value,mask;
u32 value;
int i; int i;
for (i = 0; i < CX8800_CTLS; i++) {
for (i = 0; i < CX8800_CTLS; i++) if (cx8800_ctls[i].v.id == ctl->id) {
if (cx8800_ctls[i].v.id == ctl->id)
c = &cx8800_ctls[i]; c = &cx8800_ctls[i];
}
}
if (NULL == c) if (NULL == c)
return -EINVAL; return -EINVAL;
...@@ -939,6 +943,7 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl) ...@@ -939,6 +943,7 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
ctl->value = c->v.minimum; ctl->value = c->v.minimum;
if (ctl->value > c->v.maximum) if (ctl->value > c->v.maximum)
ctl->value = c->v.maximum; ctl->value = c->v.maximum;
mask=c->mask;
switch (ctl->id) { switch (ctl->id) {
case V4L2_CID_AUDIO_BALANCE: case V4L2_CID_AUDIO_BALANCE:
value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value; value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value;
...@@ -948,56 +953,44 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl) ...@@ -948,56 +953,44 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
break; break;
case V4L2_CID_SATURATION: case V4L2_CID_SATURATION:
/* special v_sat handling */ /* special v_sat handling */
v_sat_value = ctl->value - (0x7f - 0x5a);
if (v_sat_value > 0xff) value = ((ctl->value - c->off) << c->shift) & c->mask;
v_sat_value = 0xff;
if (v_sat_value < 0x00) if (core->tvnorm->id & V4L2_STD_SECAM) {
v_sat_value = 0x00; /* For SECAM, both U and V sat should be equal */
cx_andor(MO_UV_SATURATION, 0xff00, v_sat_value << 8); value=value<<8|value;
/* fall through to default route for u_sat */ } else {
/* Keeps U Saturation proportional to V Sat */
value=(value*0x5a)/0x7f<<8|value;
}
mask=0xffff;
break;
default: default:
value = ((ctl->value - c->off) << c->shift) & c->mask; value = ((ctl->value - c->off) << c->shift) & c->mask;
break; break;
} }
dprintk(1,"set_control id=0x%X reg=0x%x val=0x%x%s\n", printk("set_control id=0x%X reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
ctl->id, c->reg, value, c->sreg ? " [shadowed]" : ""); ctl->id, c->reg, value,
mask, c->sreg ? " [shadowed]" : "");
if (c->sreg) { if (c->sreg) {
cx_sandor(c->sreg, c->reg, c->mask, value); cx_sandor(c->sreg, c->reg, mask, value);
} else { } else {
cx_andor(c->reg, c->mask, value); cx_andor(c->reg, mask, value);
} }
return 0; return 0;
} }
/* static void init_controls(struct cx8800_dev *dev) */
static void init_controls(struct cx88_core *core) static void init_controls(struct cx88_core *core)
{ {
static struct v4l2_control mute = { struct v4l2_control ctrl;
.id = V4L2_CID_AUDIO_MUTE, int i;
.value = 1,
};
static struct v4l2_control volume = {
.id = V4L2_CID_AUDIO_VOLUME,
.value = 0x3f,
};
static struct v4l2_control hue = {
.id = V4L2_CID_HUE,
.value = 0x80,
};
static struct v4l2_control contrast = {
.id = V4L2_CID_CONTRAST,
.value = 0x80,
};
static struct v4l2_control brightness = {
.id = V4L2_CID_BRIGHTNESS,
.value = 0x80,
};
set_control(core,&mute); for (i = 0; i < CX8800_CTLS; i++) {
set_control(core,&volume); ctrl.id=cx8800_ctls[i].v.id;
set_control(core,&hue); ctrl.value=cx8800_ctls[i].v.default_value
set_control(core,&contrast); +cx8800_ctls[i].off;
set_control(core,&brightness); set_control(core, &ctrl);
}
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
...@@ -1930,8 +1923,8 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1930,8 +1923,8 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
/* initial device configuration */ /* initial device configuration */
down(&core->lock); down(&core->lock);
init_controls(core);
cx88_set_tvnorm(core,tvnorms); cx88_set_tvnorm(core,tvnorms);
init_controls(core);
video_mux(core,0); video_mux(core,0);
up(&core->lock); up(&core->lock);
......
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