diff options
author | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2006-01-09 12:25:26 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2006-01-09 12:25:26 -0500 |
commit | 70f00044a2107a2c7d654bf1d3e0494f77777f47 (patch) | |
tree | 929354504de7bbcfab5530d7edd1c190bafa6ffc /drivers/media/video/cx88 | |
parent | 5ea892f156310132a1bd37c45c3ca09663cfb9fb (diff) |
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: Michael Krufky <mkrufky@m1k.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'drivers/media/video/cx88')
-rw-r--r-- | drivers/media/video/cx88/cx88-video.c | 85 |
1 files changed, 39 insertions, 46 deletions
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index bc025c46aedf..b76abb9b8961 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -240,7 +240,7 @@ static struct cx88_ctrl cx8800_ctls[] = { | |||
240 | .minimum = 0, | 240 | .minimum = 0, |
241 | .maximum = 0xff, | 241 | .maximum = 0xff, |
242 | .step = 1, | 242 | .step = 1, |
243 | .default_value = 0, | 243 | .default_value = 0x3f, |
244 | .type = V4L2_CTRL_TYPE_INTEGER, | 244 | .type = V4L2_CTRL_TYPE_INTEGER, |
245 | }, | 245 | }, |
246 | .off = 0, | 246 | .off = 0, |
@@ -271,7 +271,7 @@ static struct cx88_ctrl cx8800_ctls[] = { | |||
271 | .minimum = 0, | 271 | .minimum = 0, |
272 | .maximum = 0xff, | 272 | .maximum = 0xff, |
273 | .step = 1, | 273 | .step = 1, |
274 | .default_value = 0, | 274 | .default_value = 0x7f, |
275 | .type = V4L2_CTRL_TYPE_INTEGER, | 275 | .type = V4L2_CTRL_TYPE_INTEGER, |
276 | }, | 276 | }, |
277 | .off = 0, | 277 | .off = 0, |
@@ -285,6 +285,7 @@ static struct cx88_ctrl cx8800_ctls[] = { | |||
285 | .name = "Mute", | 285 | .name = "Mute", |
286 | .minimum = 0, | 286 | .minimum = 0, |
287 | .maximum = 1, | 287 | .maximum = 1, |
288 | .default_value = 1, | ||
288 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 289 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
289 | }, | 290 | }, |
290 | .reg = AUD_VOL_CTL, | 291 | .reg = AUD_VOL_CTL, |
@@ -298,7 +299,7 @@ static struct cx88_ctrl cx8800_ctls[] = { | |||
298 | .minimum = 0, | 299 | .minimum = 0, |
299 | .maximum = 0x3f, | 300 | .maximum = 0x3f, |
300 | .step = 1, | 301 | .step = 1, |
301 | .default_value = 0, | 302 | .default_value = 0x1f, |
302 | .type = V4L2_CTRL_TYPE_INTEGER, | 303 | .type = V4L2_CTRL_TYPE_INTEGER, |
303 | }, | 304 | }, |
304 | .reg = AUD_VOL_CTL, | 305 | .reg = AUD_VOL_CTL, |
@@ -917,6 +918,9 @@ static int get_control(struct cx88_core *core, struct v4l2_control *ctl) | |||
917 | ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift; | 918 | ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift; |
918 | break; | 919 | break; |
919 | } | 920 | } |
921 | printk("get_control id=0x%X reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", | ||
922 | ctl->id, c->reg, ctl->value, | ||
923 | c->mask, c->sreg ? " [shadowed]" : ""); | ||
920 | return 0; | 924 | return 0; |
921 | } | 925 | } |
922 | 926 | ||
@@ -925,13 +929,13 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl) | |||
925 | { | 929 | { |
926 | /* struct cx88_core *core = dev->core; */ | 930 | /* struct cx88_core *core = dev->core; */ |
927 | struct cx88_ctrl *c = NULL; | 931 | struct cx88_ctrl *c = NULL; |
928 | u32 v_sat_value; | 932 | u32 value,mask; |
929 | u32 value; | ||
930 | int i; | 933 | int i; |
931 | 934 | for (i = 0; i < CX8800_CTLS; i++) { | |
932 | for (i = 0; i < CX8800_CTLS; i++) | 935 | if (cx8800_ctls[i].v.id == ctl->id) { |
933 | if (cx8800_ctls[i].v.id == ctl->id) | ||
934 | c = &cx8800_ctls[i]; | 936 | c = &cx8800_ctls[i]; |
937 | } | ||
938 | } | ||
935 | if (NULL == c) | 939 | if (NULL == c) |
936 | return -EINVAL; | 940 | return -EINVAL; |
937 | 941 | ||
@@ -939,6 +943,7 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl) | |||
939 | ctl->value = c->v.minimum; | 943 | ctl->value = c->v.minimum; |
940 | if (ctl->value > c->v.maximum) | 944 | if (ctl->value > c->v.maximum) |
941 | ctl->value = c->v.maximum; | 945 | ctl->value = c->v.maximum; |
946 | mask=c->mask; | ||
942 | switch (ctl->id) { | 947 | switch (ctl->id) { |
943 | case V4L2_CID_AUDIO_BALANCE: | 948 | case V4L2_CID_AUDIO_BALANCE: |
944 | value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value; | 949 | 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 | break; | 953 | break; |
949 | case V4L2_CID_SATURATION: | 954 | case V4L2_CID_SATURATION: |
950 | /* special v_sat handling */ | 955 | /* special v_sat handling */ |
951 | v_sat_value = ctl->value - (0x7f - 0x5a); | 956 | |
952 | if (v_sat_value > 0xff) | 957 | value = ((ctl->value - c->off) << c->shift) & c->mask; |
953 | v_sat_value = 0xff; | 958 | |
954 | if (v_sat_value < 0x00) | 959 | if (core->tvnorm->id & V4L2_STD_SECAM) { |
955 | v_sat_value = 0x00; | 960 | /* For SECAM, both U and V sat should be equal */ |
956 | cx_andor(MO_UV_SATURATION, 0xff00, v_sat_value << 8); | 961 | value=value<<8|value; |
957 | /* fall through to default route for u_sat */ | 962 | } else { |
963 | /* Keeps U Saturation proportional to V Sat */ | ||
964 | value=(value*0x5a)/0x7f<<8|value; | ||
965 | } | ||
966 | mask=0xffff; | ||
967 | break; | ||
958 | default: | 968 | default: |
959 | value = ((ctl->value - c->off) << c->shift) & c->mask; | 969 | value = ((ctl->value - c->off) << c->shift) & c->mask; |
960 | break; | 970 | break; |
961 | } | 971 | } |
962 | dprintk(1,"set_control id=0x%X reg=0x%x val=0x%x%s\n", | 972 | printk("set_control id=0x%X reg=0x%02x val=0x%02x (mask 0x%02x)%s\n", |
963 | ctl->id, c->reg, value, c->sreg ? " [shadowed]" : ""); | 973 | ctl->id, c->reg, value, |
974 | mask, c->sreg ? " [shadowed]" : ""); | ||
964 | if (c->sreg) { | 975 | if (c->sreg) { |
965 | cx_sandor(c->sreg, c->reg, c->mask, value); | 976 | cx_sandor(c->sreg, c->reg, mask, value); |
966 | } else { | 977 | } else { |
967 | cx_andor(c->reg, c->mask, value); | 978 | cx_andor(c->reg, mask, value); |
968 | } | 979 | } |
969 | return 0; | 980 | return 0; |
970 | } | 981 | } |
971 | 982 | ||
972 | /* static void init_controls(struct cx8800_dev *dev) */ | ||
973 | static void init_controls(struct cx88_core *core) | 983 | static void init_controls(struct cx88_core *core) |
974 | { | 984 | { |
975 | static struct v4l2_control mute = { | 985 | struct v4l2_control ctrl; |
976 | .id = V4L2_CID_AUDIO_MUTE, | 986 | int i; |
977 | .value = 1, | ||
978 | }; | ||
979 | static struct v4l2_control volume = { | ||
980 | .id = V4L2_CID_AUDIO_VOLUME, | ||
981 | .value = 0x3f, | ||
982 | }; | ||
983 | static struct v4l2_control hue = { | ||
984 | .id = V4L2_CID_HUE, | ||
985 | .value = 0x80, | ||
986 | }; | ||
987 | static struct v4l2_control contrast = { | ||
988 | .id = V4L2_CID_CONTRAST, | ||
989 | .value = 0x80, | ||
990 | }; | ||
991 | static struct v4l2_control brightness = { | ||
992 | .id = V4L2_CID_BRIGHTNESS, | ||
993 | .value = 0x80, | ||
994 | }; | ||
995 | 987 | ||
996 | set_control(core,&mute); | 988 | for (i = 0; i < CX8800_CTLS; i++) { |
997 | set_control(core,&volume); | 989 | ctrl.id=cx8800_ctls[i].v.id; |
998 | set_control(core,&hue); | 990 | ctrl.value=cx8800_ctls[i].v.default_value |
999 | set_control(core,&contrast); | 991 | +cx8800_ctls[i].off; |
1000 | set_control(core,&brightness); | 992 | set_control(core, &ctrl); |
993 | } | ||
1001 | } | 994 | } |
1002 | 995 | ||
1003 | /* ------------------------------------------------------------------ */ | 996 | /* ------------------------------------------------------------------ */ |
@@ -1930,8 +1923,8 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
1930 | 1923 | ||
1931 | /* initial device configuration */ | 1924 | /* initial device configuration */ |
1932 | down(&core->lock); | 1925 | down(&core->lock); |
1933 | init_controls(core); | ||
1934 | cx88_set_tvnorm(core,tvnorms); | 1926 | cx88_set_tvnorm(core,tvnorms); |
1927 | init_controls(core); | ||
1935 | video_mux(core,0); | 1928 | video_mux(core,0); |
1936 | up(&core->lock); | 1929 | up(&core->lock); |
1937 | 1930 | ||