aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-video.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-01-09 16:03:58 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-09 16:03:58 -0500
commitf17578decc40df8fceff82b106582e30bdfb3189 (patch)
tree911a435a2094ac03ae649f020237674224e4124a /drivers/media/video/cx88/cx88-video.c
parent682e852e2638ed0aff84aa51181c9e5d2f939562 (diff)
parentcec418346e5a411e907293aba7cc21ac53c95834 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
Diffstat (limited to 'drivers/media/video/cx88/cx88-video.c')
-rw-r--r--drivers/media/video/cx88/cx88-video.c94
1 files changed, 45 insertions, 49 deletions
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 24a48f8a48c1..9a02515fe18b 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -33,6 +33,7 @@
33#include <asm/div64.h> 33#include <asm/div64.h>
34 34
35#include "cx88.h" 35#include "cx88.h"
36#include <media/v4l2-common.h>
36 37
37/* Include V4L1 specific functions. Should be removed soon */ 38/* Include V4L1 specific functions. Should be removed soon */
38#include <linux/videodev.h> 39#include <linux/videodev.h>
@@ -240,7 +241,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
240 .minimum = 0, 241 .minimum = 0,
241 .maximum = 0xff, 242 .maximum = 0xff,
242 .step = 1, 243 .step = 1,
243 .default_value = 0, 244 .default_value = 0x3f,
244 .type = V4L2_CTRL_TYPE_INTEGER, 245 .type = V4L2_CTRL_TYPE_INTEGER,
245 }, 246 },
246 .off = 0, 247 .off = 0,
@@ -271,7 +272,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
271 .minimum = 0, 272 .minimum = 0,
272 .maximum = 0xff, 273 .maximum = 0xff,
273 .step = 1, 274 .step = 1,
274 .default_value = 0, 275 .default_value = 0x7f,
275 .type = V4L2_CTRL_TYPE_INTEGER, 276 .type = V4L2_CTRL_TYPE_INTEGER,
276 }, 277 },
277 .off = 0, 278 .off = 0,
@@ -285,6 +286,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
285 .name = "Mute", 286 .name = "Mute",
286 .minimum = 0, 287 .minimum = 0,
287 .maximum = 1, 288 .maximum = 1,
289 .default_value = 1,
288 .type = V4L2_CTRL_TYPE_BOOLEAN, 290 .type = V4L2_CTRL_TYPE_BOOLEAN,
289 }, 291 },
290 .reg = AUD_VOL_CTL, 292 .reg = AUD_VOL_CTL,
@@ -298,7 +300,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
298 .minimum = 0, 300 .minimum = 0,
299 .maximum = 0x3f, 301 .maximum = 0x3f,
300 .step = 1, 302 .step = 1,
301 .default_value = 0, 303 .default_value = 0x1f,
302 .type = V4L2_CTRL_TYPE_INTEGER, 304 .type = V4L2_CTRL_TYPE_INTEGER,
303 }, 305 },
304 .reg = AUD_VOL_CTL, 306 .reg = AUD_VOL_CTL,
@@ -917,6 +919,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; 919 ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift;
918 break; 920 break;
919 } 921 }
922 printk("get_control id=0x%X reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
923 ctl->id, c->reg, ctl->value,
924 c->mask, c->sreg ? " [shadowed]" : "");
920 return 0; 925 return 0;
921} 926}
922 927
@@ -925,13 +930,13 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
925{ 930{
926 /* struct cx88_core *core = dev->core; */ 931 /* struct cx88_core *core = dev->core; */
927 struct cx88_ctrl *c = NULL; 932 struct cx88_ctrl *c = NULL;
928 u32 v_sat_value; 933 u32 value,mask;
929 u32 value;
930 int i; 934 int i;
931 935 for (i = 0; i < CX8800_CTLS; i++) {
932 for (i = 0; i < CX8800_CTLS; i++) 936 if (cx8800_ctls[i].v.id == ctl->id) {
933 if (cx8800_ctls[i].v.id == ctl->id)
934 c = &cx8800_ctls[i]; 937 c = &cx8800_ctls[i];
938 }
939 }
935 if (NULL == c) 940 if (NULL == c)
936 return -EINVAL; 941 return -EINVAL;
937 942
@@ -939,6 +944,7 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
939 ctl->value = c->v.minimum; 944 ctl->value = c->v.minimum;
940 if (ctl->value > c->v.maximum) 945 if (ctl->value > c->v.maximum)
941 ctl->value = c->v.maximum; 946 ctl->value = c->v.maximum;
947 mask=c->mask;
942 switch (ctl->id) { 948 switch (ctl->id) {
943 case V4L2_CID_AUDIO_BALANCE: 949 case V4L2_CID_AUDIO_BALANCE:
944 value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value; 950 value = (ctl->value < 0x40) ? (0x40 - ctl->value) : ctl->value;
@@ -948,56 +954,44 @@ static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
948 break; 954 break;
949 case V4L2_CID_SATURATION: 955 case V4L2_CID_SATURATION:
950 /* special v_sat handling */ 956 /* special v_sat handling */
951 v_sat_value = ctl->value - (0x7f - 0x5a); 957
952 if (v_sat_value > 0xff) 958 value = ((ctl->value - c->off) << c->shift) & c->mask;
953 v_sat_value = 0xff; 959
954 if (v_sat_value < 0x00) 960 if (core->tvnorm->id & V4L2_STD_SECAM) {
955 v_sat_value = 0x00; 961 /* For SECAM, both U and V sat should be equal */
956 cx_andor(MO_UV_SATURATION, 0xff00, v_sat_value << 8); 962 value=value<<8|value;
957 /* fall through to default route for u_sat */ 963 } else {
964 /* Keeps U Saturation proportional to V Sat */
965 value=(value*0x5a)/0x7f<<8|value;
966 }
967 mask=0xffff;
968 break;
958 default: 969 default:
959 value = ((ctl->value - c->off) << c->shift) & c->mask; 970 value = ((ctl->value - c->off) << c->shift) & c->mask;
960 break; 971 break;
961 } 972 }
962 dprintk(1,"set_control id=0x%X reg=0x%x val=0x%x%s\n", 973 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]" : ""); 974 ctl->id, c->reg, value,
975 mask, c->sreg ? " [shadowed]" : "");
964 if (c->sreg) { 976 if (c->sreg) {
965 cx_sandor(c->sreg, c->reg, c->mask, value); 977 cx_sandor(c->sreg, c->reg, mask, value);
966 } else { 978 } else {
967 cx_andor(c->reg, c->mask, value); 979 cx_andor(c->reg, mask, value);
968 } 980 }
969 return 0; 981 return 0;
970} 982}
971 983
972/* static void init_controls(struct cx8800_dev *dev) */
973static void init_controls(struct cx88_core *core) 984static void init_controls(struct cx88_core *core)
974{ 985{
975 static struct v4l2_control mute = { 986 struct v4l2_control ctrl;
976 .id = V4L2_CID_AUDIO_MUTE, 987 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 988
996 set_control(core,&mute); 989 for (i = 0; i < CX8800_CTLS; i++) {
997 set_control(core,&volume); 990 ctrl.id=cx8800_ctls[i].v.id;
998 set_control(core,&hue); 991 ctrl.value=cx8800_ctls[i].v.default_value
999 set_control(core,&contrast); 992 +cx8800_ctls[i].off;
1000 set_control(core,&brightness); 993 set_control(core, &ctrl);
994 }
1001} 995}
1002 996
1003/* ------------------------------------------------------------------ */ 997/* ------------------------------------------------------------------ */
@@ -1125,7 +1119,7 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1125 int err; 1119 int err;
1126 1120
1127 if (video_debug > 1) 1121 if (video_debug > 1)
1128 cx88_print_ioctl(core->name,cmd); 1122 v4l_print_ioctl(core->name,cmd);
1129 switch (cmd) { 1123 switch (cmd) {
1130 1124
1131 /* --- capabilities ------------------------------------------ */ 1125 /* --- capabilities ------------------------------------------ */
@@ -1261,7 +1255,7 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1261 1255
1262 dprintk( 1, "CORE IOCTL: 0x%x\n", cmd ); 1256 dprintk( 1, "CORE IOCTL: 0x%x\n", cmd );
1263 if (video_debug > 1) 1257 if (video_debug > 1)
1264 cx88_print_ioctl(core->name,cmd); 1258 v4l_print_ioctl(core->name,cmd);
1265 1259
1266 switch (cmd) { 1260 switch (cmd) {
1267 /* ---------- tv norms ---------- */ 1261 /* ---------- tv norms ---------- */
@@ -1481,7 +1475,7 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
1481 struct cx88_core *core = dev->core; 1475 struct cx88_core *core = dev->core;
1482 1476
1483 if (video_debug > 1) 1477 if (video_debug > 1)
1484 cx88_print_ioctl(core->name,cmd); 1478 v4l_print_ioctl(core->name,cmd);
1485 1479
1486 switch (cmd) { 1480 switch (cmd) {
1487 case VIDIOC_QUERYCAP: 1481 case VIDIOC_QUERYCAP:
@@ -1740,6 +1734,7 @@ static struct file_operations video_fops =
1740 .poll = video_poll, 1734 .poll = video_poll,
1741 .mmap = video_mmap, 1735 .mmap = video_mmap,
1742 .ioctl = video_ioctl, 1736 .ioctl = video_ioctl,
1737 .compat_ioctl = v4l_compat_ioctl32,
1743 .llseek = no_llseek, 1738 .llseek = no_llseek,
1744}; 1739};
1745 1740
@@ -1767,6 +1762,7 @@ static struct file_operations radio_fops =
1767 .open = video_open, 1762 .open = video_open,
1768 .release = video_release, 1763 .release = video_release,
1769 .ioctl = radio_ioctl, 1764 .ioctl = radio_ioctl,
1765 .compat_ioctl = v4l_compat_ioctl32,
1770 .llseek = no_llseek, 1766 .llseek = no_llseek,
1771}; 1767};
1772 1768
@@ -1928,8 +1924,8 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1928 1924
1929 /* initial device configuration */ 1925 /* initial device configuration */
1930 down(&core->lock); 1926 down(&core->lock);
1931 init_controls(core);
1932 cx88_set_tvnorm(core,tvnorms); 1927 cx88_set_tvnorm(core,tvnorms);
1928 init_controls(core);
1933 video_mux(core,0); 1929 video_mux(core,0);
1934 up(&core->lock); 1930 up(&core->lock);
1935 1931