aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7115.c
diff options
context:
space:
mode:
authorDevin Heitmueller <dheitmueller@kernellabs.com>2010-03-11 19:49:24 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:50:16 -0400
commit87a6fe4a530cc01081d19cdec4738433972fb0ee (patch)
treedc33b1b814c4b215d712c4a62873de13e66f4ca0 /drivers/media/video/saa7115.c
parent7a01f6dbc7abb85a6ec048dd45db92ef1b91fe78 (diff)
V4L/DVB: saa115: add support for chroma AGC and chroma gain
Add support for chroma agc and gain to the saa7115 driver. This allows for users to do manual adjustment for abnormal signal conditions. This work was sponsored by EyeMagnet Limited. Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7115.c')
-rw-r--r--drivers/media/video/saa7115.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 7d11660922f4..f96071c66055 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -74,6 +74,7 @@ struct saa711x_state {
74 int contrast; 74 int contrast;
75 int hue; 75 int hue;
76 int sat; 76 int sat;
77 int chroma_agc;
77 int width; 78 int width;
78 int height; 79 int height;
79 u32 ident; 80 u32 ident;
@@ -743,6 +744,7 @@ static int saa711x_s_clock_freq(struct v4l2_subdev *sd, u32 freq)
743static int saa711x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl) 744static int saa711x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
744{ 745{
745 struct saa711x_state *state = to_state(sd); 746 struct saa711x_state *state = to_state(sd);
747 u8 val;
746 748
747 switch (ctrl->id) { 749 switch (ctrl->id) {
748 case V4L2_CID_BRIGHTNESS: 750 case V4L2_CID_BRIGHTNESS:
@@ -784,7 +786,21 @@ static int saa711x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
784 state->hue = ctrl->value; 786 state->hue = ctrl->value;
785 saa711x_write(sd, R_0D_CHROMA_HUE_CNTL, state->hue); 787 saa711x_write(sd, R_0D_CHROMA_HUE_CNTL, state->hue);
786 break; 788 break;
787 789 case V4L2_CID_CHROMA_AGC:
790 val = saa711x_read(sd, R_0F_CHROMA_GAIN_CNTL);
791 state->chroma_agc = ctrl->value;
792 if (ctrl->value)
793 val &= 0x7f;
794 else
795 val |= 0x80;
796 saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, val);
797 break;
798 case V4L2_CID_CHROMA_GAIN:
799 /* Chroma gain cannot be set when AGC is enabled */
800 if (state->chroma_agc == 1)
801 return -EINVAL;
802 saa711x_write(sd, R_0F_CHROMA_GAIN_CNTL, ctrl->value | 0x80);
803 break;
788 default: 804 default:
789 return -EINVAL; 805 return -EINVAL;
790 } 806 }
@@ -809,6 +825,12 @@ static int saa711x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
809 case V4L2_CID_HUE: 825 case V4L2_CID_HUE:
810 ctrl->value = state->hue; 826 ctrl->value = state->hue;
811 break; 827 break;
828 case V4L2_CID_CHROMA_AGC:
829 ctrl->value = state->chroma_agc;
830 break;
831 case V4L2_CID_CHROMA_GAIN:
832 ctrl->value = saa711x_read(sd, R_0F_CHROMA_GAIN_CNTL) & 0x7f;
833 break;
812 default: 834 default:
813 return -EINVAL; 835 return -EINVAL;
814 } 836 }
@@ -1209,6 +1231,19 @@ static int saa711x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc)
1209 return v4l2_ctrl_query_fill(qc, 0, 127, 1, 64); 1231 return v4l2_ctrl_query_fill(qc, 0, 127, 1, 64);
1210 case V4L2_CID_HUE: 1232 case V4L2_CID_HUE:
1211 return v4l2_ctrl_query_fill(qc, -128, 127, 1, 0); 1233 return v4l2_ctrl_query_fill(qc, -128, 127, 1, 0);
1234 case V4L2_CID_CHROMA_AGC:
1235 return v4l2_ctrl_query_fill(qc, 0, 1, 1, 1);
1236 case V4L2_CID_CHROMA_GAIN:
1237 qc->type = V4L2_CTRL_TYPE_INTEGER;
1238 qc->flags = V4L2_CTRL_FLAG_SLIDER;
1239 qc->minimum = 0;
1240 qc->maximum = 127;
1241 qc->step = 1;
1242 qc->default_value = 0x30;
1243 qc->reserved[0] = 0;
1244 qc->reserved[1] = 0;
1245 strlcpy(qc->name, "chroma_gain", sizeof(qc->name));
1246 return 0;
1212 default: 1247 default:
1213 return -EINVAL; 1248 return -EINVAL;
1214 } 1249 }
@@ -1593,6 +1628,7 @@ static int saa711x_probe(struct i2c_client *client,
1593 state->contrast = 64; 1628 state->contrast = 64;
1594 state->hue = 0; 1629 state->hue = 0;
1595 state->sat = 64; 1630 state->sat = 64;
1631 state->chroma_agc = 1;
1596 switch (chip_id) { 1632 switch (chip_id) {
1597 case '1': 1633 case '1':
1598 state->ident = V4L2_IDENT_SAA7111; 1634 state->ident = V4L2_IDENT_SAA7111;