aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/pci/cx25821/cx25821-video.c313
-rw-r--r--drivers/media/pci/cx25821/cx25821-video.h74
-rw-r--r--drivers/media/pci/cx25821/cx25821.h9
3 files changed, 153 insertions, 243 deletions
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c
index 9ddc7ac03a73..9e948eff6b88 100644
--- a/drivers/media/pci/cx25821/cx25821-video.c
+++ b/drivers/media/pci/cx25821/cx25821-video.c
@@ -46,15 +46,13 @@ static unsigned int irq_debug;
46module_param(irq_debug, int, 0644); 46module_param(irq_debug, int, 0644);
47MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]"); 47MODULE_PARM_DESC(irq_debug, "enable debug messages [IRQ handler]");
48 48
49unsigned int vid_limit = 16; 49static unsigned int vid_limit = 16;
50module_param(vid_limit, int, 0644); 50module_param(vid_limit, int, 0644);
51MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes"); 51MODULE_PARM_DESC(vid_limit, "capture memory limit in megabytes");
52 52
53static void cx25821_init_controls(struct cx25821_dev *dev, int chan_num);
54
55#define FORMAT_FLAGS_PACKED 0x01 53#define FORMAT_FLAGS_PACKED 0x01
56 54
57struct cx25821_fmt formats[] = { 55static const struct cx25821_fmt formats[] = {
58 { 56 {
59 .name = "8 bpp, gray", 57 .name = "8 bpp, gray",
60 .fourcc = V4L2_PIX_FMT_GREY, 58 .fourcc = V4L2_PIX_FMT_GREY,
@@ -83,12 +81,7 @@ struct cx25821_fmt formats[] = {
83 }, 81 },
84}; 82};
85 83
86int cx25821_get_format_size(void) 84static const struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc)
87{
88 return ARRAY_SIZE(formats);
89}
90
91struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc)
92{ 85{
93 unsigned int i; 86 unsigned int i;
94 87
@@ -138,7 +131,7 @@ void cx25821_video_wakeup(struct cx25821_dev *dev, struct cx25821_dmaqueue *q,
138 pr_err("%s: %d buffers handled (should be 1)\n", __func__, bc); 131 pr_err("%s: %d buffers handled (should be 1)\n", __func__, bc);
139} 132}
140 133
141int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm) 134static int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm)
142{ 135{
143 dprintk(1, "%s(norm = 0x%08x) name: [%s]\n", 136 dprintk(1, "%s(norm = 0x%08x) name: [%s]\n",
144 __func__, (unsigned int)norm, v4l2_norm_to_name(norm)); 137 __func__, (unsigned int)norm, v4l2_norm_to_name(norm));
@@ -151,7 +144,7 @@ int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm)
151 return 0; 144 return 0;
152} 145}
153 146
154struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, 147static struct video_device *cx25821_vdev_init(struct cx25821_dev *dev,
155 struct pci_dev *pci, 148 struct pci_dev *pci,
156 const struct video_device *template, 149 const struct video_device *template,
157 char *type) 150 char *type)
@@ -237,7 +230,7 @@ void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh,
237 mutex_unlock(&dev->lock); 230 mutex_unlock(&dev->lock);
238} 231}
239 232
240int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input) 233static int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input)
241{ 234{
242 struct v4l2_routing route; 235 struct v4l2_routing route;
243 memset(&route, 0, sizeof(route)); 236 memset(&route, 0, sizeof(route));
@@ -403,7 +396,7 @@ int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status)
403 return handled; 396 return handled;
404} 397}
405 398
406int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count, 399static int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count,
407 unsigned int *size) 400 unsigned int *size)
408{ 401{
409 struct cx25821_fh *fh = q->priv_data; 402 struct cx25821_fh *fh = q->priv_data;
@@ -419,7 +412,7 @@ int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count,
419 return 0; 412 return 0;
420} 413}
421 414
422int cx25821_buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, 415static int cx25821_buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
423 enum v4l2_field field) 416 enum v4l2_field field)
424{ 417{
425 struct cx25821_fh *fh = q->priv_data; 418 struct cx25821_fh *fh = q->priv_data;
@@ -546,7 +539,7 @@ fail:
546 return rc; 539 return rc;
547} 540}
548 541
549void cx25821_buffer_release(struct videobuf_queue *q, 542static void cx25821_buffer_release(struct videobuf_queue *q,
550 struct videobuf_buffer *vb) 543 struct videobuf_buffer *vb)
551{ 544{
552 struct cx25821_buffer *buf = 545 struct cx25821_buffer *buf =
@@ -555,7 +548,7 @@ void cx25821_buffer_release(struct videobuf_queue *q,
555 cx25821_free_buffer(q, buf); 548 cx25821_free_buffer(q, buf);
556} 549}
557 550
558struct videobuf_queue *get_queue(struct cx25821_fh *fh) 551static struct videobuf_queue *get_queue(struct cx25821_fh *fh)
559{ 552{
560 switch (fh->type) { 553 switch (fh->type) {
561 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 554 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -566,7 +559,7 @@ struct videobuf_queue *get_queue(struct cx25821_fh *fh)
566 } 559 }
567} 560}
568 561
569int cx25821_get_resource(struct cx25821_fh *fh, int resource) 562static int cx25821_get_resource(struct cx25821_fh *fh, int resource)
570{ 563{
571 switch (fh->type) { 564 switch (fh->type) {
572 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 565 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -577,7 +570,7 @@ int cx25821_get_resource(struct cx25821_fh *fh, int resource)
577 } 570 }
578} 571}
579 572
580int cx25821_video_mmap(struct file *file, struct vm_area_struct *vma) 573static int cx25821_video_mmap(struct file *file, struct vm_area_struct *vma)
581{ 574{
582 struct cx25821_fh *fh = file->private_data; 575 struct cx25821_fh *fh = file->private_data;
583 576
@@ -795,6 +788,70 @@ static int video_release(struct file *file)
795 return 0; 788 return 0;
796} 789}
797 790
791/* VIDEO IOCTLS */
792static int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
793 struct v4l2_format *f)
794{
795 struct cx25821_fh *fh = priv;
796
797 f->fmt.pix.width = fh->width;
798 f->fmt.pix.height = fh->height;
799 f->fmt.pix.field = fh->vidq.field;
800 f->fmt.pix.pixelformat = fh->fmt->fourcc;
801 f->fmt.pix.bytesperline = (f->fmt.pix.width * fh->fmt->depth) >> 3;
802 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
803
804 return 0;
805}
806
807static int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
808 struct v4l2_format *f)
809{
810 const struct cx25821_fmt *fmt;
811 enum v4l2_field field;
812 unsigned int maxw, maxh;
813
814 fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat);
815 if (NULL == fmt)
816 return -EINVAL;
817
818 field = f->fmt.pix.field;
819 maxw = 720;
820 maxh = 576;
821
822 if (V4L2_FIELD_ANY == field) {
823 if (f->fmt.pix.height > maxh / 2)
824 field = V4L2_FIELD_INTERLACED;
825 else
826 field = V4L2_FIELD_TOP;
827 }
828
829 switch (field) {
830 case V4L2_FIELD_TOP:
831 case V4L2_FIELD_BOTTOM:
832 maxh = maxh / 2;
833 break;
834 case V4L2_FIELD_INTERLACED:
835 break;
836 default:
837 return -EINVAL;
838 }
839
840 f->fmt.pix.field = field;
841 if (f->fmt.pix.height < 32)
842 f->fmt.pix.height = 32;
843 if (f->fmt.pix.height > maxh)
844 f->fmt.pix.height = maxh;
845 if (f->fmt.pix.width < 48)
846 f->fmt.pix.width = 48;
847 if (f->fmt.pix.width > maxw)
848 f->fmt.pix.width = maxw;
849 f->fmt.pix.width &= ~0x03;
850 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
851 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
852
853 return 0;
854}
798static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) 855static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
799{ 856{
800 struct cx25821_fh *fh = priv; 857 struct cx25821_fh *fh = priv;
@@ -832,6 +889,43 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
832 return 0; 889 return 0;
833} 890}
834 891
892static int cx25821_is_valid_width(u32 width, v4l2_std_id tvnorm)
893{
894 if (tvnorm == V4L2_STD_PAL_BG) {
895 if (width == 352 || width == 720)
896 return 1;
897 else
898 return 0;
899 }
900
901 if (tvnorm == V4L2_STD_NTSC_M) {
902 if (width == 320 || width == 352 || width == 720)
903 return 1;
904 else
905 return 0;
906 }
907 return 0;
908}
909
910static int cx25821_is_valid_height(u32 height, v4l2_std_id tvnorm)
911{
912 if (tvnorm == V4L2_STD_PAL_BG) {
913 if (height == 576 || height == 288)
914 return 1;
915 else
916 return 0;
917 }
918
919 if (tvnorm == V4L2_STD_NTSC_M) {
920 if (height == 480 || height == 240)
921 return 1;
922 else
923 return 0;
924 }
925
926 return 0;
927}
928
835static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, 929static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
836 struct v4l2_format *f) 930 struct v4l2_format *f)
837{ 931{
@@ -918,89 +1012,8 @@ static int vidioc_log_status(struct file *file, void *priv)
918 return 0; 1012 return 0;
919} 1013}
920 1014
921static int vidioc_s_ctrl(struct file *file, void *priv,
922 struct v4l2_control *ctl)
923{
924 struct cx25821_fh *fh = priv;
925 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
926 int err;
927
928 if (fh) {
929 err = v4l2_prio_check(&dev->channels[fh->channel_id].prio,
930 fh->prio);
931 if (0 != err)
932 return err;
933 }
934
935 return cx25821_set_control(dev, ctl, fh->channel_id);
936}
937
938/* VIDEO IOCTLS */
939int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
940 struct v4l2_format *f)
941{
942 struct cx25821_fh *fh = priv;
943
944 f->fmt.pix.width = fh->width;
945 f->fmt.pix.height = fh->height;
946 f->fmt.pix.field = fh->vidq.field;
947 f->fmt.pix.pixelformat = fh->fmt->fourcc;
948 f->fmt.pix.bytesperline = (f->fmt.pix.width * fh->fmt->depth) >> 3;
949 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
950
951 return 0;
952}
953
954int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
955 struct v4l2_format *f)
956{
957 struct cx25821_fmt *fmt;
958 enum v4l2_field field;
959 unsigned int maxw, maxh;
960
961 fmt = cx25821_format_by_fourcc(f->fmt.pix.pixelformat);
962 if (NULL == fmt)
963 return -EINVAL;
964
965 field = f->fmt.pix.field;
966 maxw = 720;
967 maxh = 576;
968
969 if (V4L2_FIELD_ANY == field) {
970 if (f->fmt.pix.height > maxh / 2)
971 field = V4L2_FIELD_INTERLACED;
972 else
973 field = V4L2_FIELD_TOP;
974 }
975
976 switch (field) {
977 case V4L2_FIELD_TOP:
978 case V4L2_FIELD_BOTTOM:
979 maxh = maxh / 2;
980 break;
981 case V4L2_FIELD_INTERLACED:
982 break;
983 default:
984 return -EINVAL;
985 }
986
987 f->fmt.pix.field = field;
988 if (f->fmt.pix.height < 32)
989 f->fmt.pix.height = 32;
990 if (f->fmt.pix.height > maxh)
991 f->fmt.pix.height = maxh;
992 if (f->fmt.pix.width < 48)
993 f->fmt.pix.width = 48;
994 if (f->fmt.pix.width > maxw)
995 f->fmt.pix.width = maxw;
996 f->fmt.pix.width &= ~0x03;
997 f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
998 f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
999
1000 return 0;
1001}
1002 1015
1003int cx25821_vidioc_querycap(struct file *file, void *priv, 1016static int cx25821_vidioc_querycap(struct file *file, void *priv,
1004 struct v4l2_capability *cap) 1017 struct v4l2_capability *cap)
1005{ 1018{
1006 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; 1019 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
@@ -1020,7 +1033,7 @@ int cx25821_vidioc_querycap(struct file *file, void *priv,
1020 return 0; 1033 return 0;
1021} 1034}
1022 1035
1023int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv, 1036static int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
1024 struct v4l2_fmtdesc *f) 1037 struct v4l2_fmtdesc *f)
1025{ 1038{
1026 if (unlikely(f->index >= ARRAY_SIZE(formats))) 1039 if (unlikely(f->index >= ARRAY_SIZE(formats)))
@@ -1032,27 +1045,27 @@ int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
1032 return 0; 1045 return 0;
1033} 1046}
1034 1047
1035int cx25821_vidioc_reqbufs(struct file *file, void *priv, 1048static int cx25821_vidioc_reqbufs(struct file *file, void *priv,
1036 struct v4l2_requestbuffers *p) 1049 struct v4l2_requestbuffers *p)
1037{ 1050{
1038 struct cx25821_fh *fh = priv; 1051 struct cx25821_fh *fh = priv;
1039 return videobuf_reqbufs(get_queue(fh), p); 1052 return videobuf_reqbufs(get_queue(fh), p);
1040} 1053}
1041 1054
1042int cx25821_vidioc_querybuf(struct file *file, void *priv, 1055static int cx25821_vidioc_querybuf(struct file *file, void *priv,
1043 struct v4l2_buffer *p) 1056 struct v4l2_buffer *p)
1044{ 1057{
1045 struct cx25821_fh *fh = priv; 1058 struct cx25821_fh *fh = priv;
1046 return videobuf_querybuf(get_queue(fh), p); 1059 return videobuf_querybuf(get_queue(fh), p);
1047} 1060}
1048 1061
1049int cx25821_vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) 1062static int cx25821_vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p)
1050{ 1063{
1051 struct cx25821_fh *fh = priv; 1064 struct cx25821_fh *fh = priv;
1052 return videobuf_qbuf(get_queue(fh), p); 1065 return videobuf_qbuf(get_queue(fh), p);
1053} 1066}
1054 1067
1055int cx25821_vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p) 1068static int cx25821_vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p)
1056{ 1069{
1057 struct cx25821_dev *dev = ((struct cx25821_fh *)f)->dev; 1070 struct cx25821_dev *dev = ((struct cx25821_fh *)f)->dev;
1058 struct cx25821_fh *fh = f; 1071 struct cx25821_fh *fh = f;
@@ -1062,7 +1075,7 @@ int cx25821_vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p)
1062 return 0; 1075 return 0;
1063} 1076}
1064 1077
1065int cx25821_vidioc_s_priority(struct file *file, void *f, 1078static int cx25821_vidioc_s_priority(struct file *file, void *f,
1066 enum v4l2_priority prio) 1079 enum v4l2_priority prio)
1067{ 1080{
1068 struct cx25821_fh *fh = f; 1081 struct cx25821_fh *fh = f;
@@ -1072,7 +1085,7 @@ int cx25821_vidioc_s_priority(struct file *file, void *f,
1072 prio); 1085 prio);
1073} 1086}
1074 1087
1075int cx25821_vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorms) 1088static int cx25821_vidioc_g_std(struct file *file, void *priv, v4l2_std_id *tvnorms)
1076{ 1089{
1077 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; 1090 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
1078 1091
@@ -1107,18 +1120,20 @@ int cx25821_vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms)
1107 return 0; 1120 return 0;
1108} 1121}
1109 1122
1110int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i) 1123static int cx25821_vidioc_enum_input(struct file *file, void *priv,
1124 struct v4l2_input *i)
1111{ 1125{
1112 static const char * const iname[] = { 1126 static const char * const iname[] = {
1113 [CX25821_VMUX_COMPOSITE] = "Composite", 1127 [CX25821_VMUX_COMPOSITE] = "Composite",
1114 [CX25821_VMUX_SVIDEO] = "S-Video", 1128 [CX25821_VMUX_SVIDEO] = "S-Video",
1115 [CX25821_VMUX_DEBUG] = "for debug only", 1129 [CX25821_VMUX_DEBUG] = "for debug only",
1116 }; 1130 };
1131 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
1117 unsigned int n; 1132 unsigned int n;
1118 dprintk(1, "%s()\n", __func__); 1133 dprintk(1, "%s()\n", __func__);
1119 1134
1120 n = i->index; 1135 n = i->index;
1121 if (n >= 2) 1136 if (n >= CX25821_NR_INPUT)
1122 return -EINVAL; 1137 return -EINVAL;
1123 1138
1124 if (0 == INPUT(n)->type) 1139 if (0 == INPUT(n)->type)
@@ -1131,15 +1146,7 @@ int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i)
1131 return 0; 1146 return 0;
1132} 1147}
1133 1148
1134int cx25821_vidioc_enum_input(struct file *file, void *priv, 1149static int cx25821_vidioc_g_input(struct file *file, void *priv, unsigned int *i)
1135 struct v4l2_input *i)
1136{
1137 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
1138 dprintk(1, "%s()\n", __func__);
1139 return cx25821_enum_input(dev, i);
1140}
1141
1142int cx25821_vidioc_g_input(struct file *file, void *priv, unsigned int *i)
1143{ 1150{
1144 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; 1151 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
1145 1152
@@ -1148,7 +1155,7 @@ int cx25821_vidioc_g_input(struct file *file, void *priv, unsigned int *i)
1148 return 0; 1155 return 0;
1149} 1156}
1150 1157
1151int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i) 1158static int cx25821_vidioc_s_input(struct file *file, void *priv, unsigned int i)
1152{ 1159{
1153 struct cx25821_fh *fh = priv; 1160 struct cx25821_fh *fh = priv;
1154 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; 1161 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
@@ -1262,7 +1269,7 @@ static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl)
1262 return 0; 1269 return 0;
1263} 1270}
1264 1271
1265int cx25821_vidioc_queryctrl(struct file *file, void *priv, 1272static int cx25821_vidioc_queryctrl(struct file *file, void *priv,
1266 struct v4l2_queryctrl *qctrl) 1273 struct v4l2_queryctrl *qctrl)
1267{ 1274{
1268 return cx25821_ctrl_query(qctrl); 1275 return cx25821_ctrl_query(qctrl);
@@ -1281,7 +1288,7 @@ static const struct v4l2_queryctrl *ctrl_by_id(unsigned int id)
1281 return NULL; 1288 return NULL;
1282} 1289}
1283 1290
1284int cx25821_vidioc_g_ctrl(struct file *file, void *priv, 1291static int cx25821_vidioc_g_ctrl(struct file *file, void *priv,
1285 struct v4l2_control *ctl) 1292 struct v4l2_control *ctl)
1286{ 1293{
1287 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; 1294 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
@@ -1310,7 +1317,7 @@ int cx25821_vidioc_g_ctrl(struct file *file, void *priv,
1310 return 0; 1317 return 0;
1311} 1318}
1312 1319
1313int cx25821_set_control(struct cx25821_dev *dev, 1320static int cx25821_set_control(struct cx25821_dev *dev,
1314 struct v4l2_control *ctl, int chan_num) 1321 struct v4l2_control *ctl, int chan_num)
1315{ 1322{
1316 int err; 1323 int err;
@@ -1360,6 +1367,23 @@ int cx25821_set_control(struct cx25821_dev *dev,
1360 return err; 1367 return err;
1361} 1368}
1362 1369
1370static int vidioc_s_ctrl(struct file *file, void *priv,
1371 struct v4l2_control *ctl)
1372{
1373 struct cx25821_fh *fh = priv;
1374 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
1375 int err;
1376
1377 if (fh) {
1378 err = v4l2_prio_check(&dev->channels[fh->channel_id].prio,
1379 fh->prio);
1380 if (0 != err)
1381 return err;
1382 }
1383
1384 return cx25821_set_control(dev, ctl, fh->channel_id);
1385}
1386
1363static void cx25821_init_controls(struct cx25821_dev *dev, int chan_num) 1387static void cx25821_init_controls(struct cx25821_dev *dev, int chan_num)
1364{ 1388{
1365 struct v4l2_control ctrl; 1389 struct v4l2_control ctrl;
@@ -1372,7 +1396,7 @@ static void cx25821_init_controls(struct cx25821_dev *dev, int chan_num)
1372 } 1396 }
1373} 1397}
1374 1398
1375int cx25821_vidioc_cropcap(struct file *file, void *priv, 1399static int cx25821_vidioc_cropcap(struct file *file, void *priv,
1376 struct v4l2_cropcap *cropcap) 1400 struct v4l2_cropcap *cropcap)
1377{ 1401{
1378 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; 1402 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
@@ -1391,7 +1415,7 @@ int cx25821_vidioc_cropcap(struct file *file, void *priv,
1391 return 0; 1415 return 0;
1392} 1416}
1393 1417
1394int cx25821_vidioc_s_crop(struct file *file, void *priv, const struct v4l2_crop *crop) 1418static int cx25821_vidioc_s_crop(struct file *file, void *priv, const struct v4l2_crop *crop)
1395{ 1419{
1396 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev; 1420 struct cx25821_dev *dev = ((struct cx25821_fh *)priv)->dev;
1397 struct cx25821_fh *fh = priv; 1421 struct cx25821_fh *fh = priv;
@@ -1407,49 +1431,12 @@ int cx25821_vidioc_s_crop(struct file *file, void *priv, const struct v4l2_crop
1407 return -EINVAL; 1431 return -EINVAL;
1408} 1432}
1409 1433
1410int cx25821_vidioc_g_crop(struct file *file, void *priv, struct v4l2_crop *crop) 1434static int cx25821_vidioc_g_crop(struct file *file, void *priv, struct v4l2_crop *crop)
1411{ 1435{
1412 /* cx25821_vidioc_g_crop not supported */ 1436 /* cx25821_vidioc_g_crop not supported */
1413 return -EINVAL; 1437 return -EINVAL;
1414} 1438}
1415 1439
1416int cx25821_is_valid_width(u32 width, v4l2_std_id tvnorm)
1417{
1418 if (tvnorm == V4L2_STD_PAL_BG) {
1419 if (width == 352 || width == 720)
1420 return 1;
1421 else
1422 return 0;
1423 }
1424
1425 if (tvnorm == V4L2_STD_NTSC_M) {
1426 if (width == 320 || width == 352 || width == 720)
1427 return 1;
1428 else
1429 return 0;
1430 }
1431 return 0;
1432}
1433
1434int cx25821_is_valid_height(u32 height, v4l2_std_id tvnorm)
1435{
1436 if (tvnorm == V4L2_STD_PAL_BG) {
1437 if (height == 576 || height == 288)
1438 return 1;
1439 else
1440 return 0;
1441 }
1442
1443 if (tvnorm == V4L2_STD_NTSC_M) {
1444 if (height == 480 || height == 240)
1445 return 1;
1446 else
1447 return 0;
1448 }
1449
1450 return 0;
1451}
1452
1453static long video_ioctl_upstream9(struct file *file, unsigned int cmd, 1440static long video_ioctl_upstream9(struct file *file, unsigned int cmd,
1454 unsigned long arg) 1441 unsigned long arg)
1455{ 1442{
diff --git a/drivers/media/pci/cx25821/cx25821-video.h b/drivers/media/pci/cx25821/cx25821-video.h
index 505b7f0b45b4..9d70020d9256 100644
--- a/drivers/media/pci/cx25821/cx25821-video.h
+++ b/drivers/media/pci/cx25821/cx25821-video.h
@@ -63,97 +63,23 @@ do { \
63#define MEDUSA_READ 910 63#define MEDUSA_READ 910
64#define MEDUSA_WRITE 911 64#define MEDUSA_WRITE 911
65 65
66extern unsigned int vid_limit;
67
68#define FORMAT_FLAGS_PACKED 0x01 66#define FORMAT_FLAGS_PACKED 0x01
69extern struct cx25821_fmt formats[];
70extern struct cx25821_fmt *cx25821_format_by_fourcc(unsigned int fourcc);
71extern struct cx25821_data timeout_data[MAX_VID_CHANNEL_NUM];
72
73extern void cx25821_video_wakeup(struct cx25821_dev *dev, 67extern void cx25821_video_wakeup(struct cx25821_dev *dev,
74 struct cx25821_dmaqueue *q, u32 count); 68 struct cx25821_dmaqueue *q, u32 count);
75 69
76extern int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm);
77
78extern int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh, 70extern int cx25821_res_get(struct cx25821_dev *dev, struct cx25821_fh *fh,
79 unsigned int bit); 71 unsigned int bit);
80extern int cx25821_res_check(struct cx25821_fh *fh, unsigned int bit); 72extern int cx25821_res_check(struct cx25821_fh *fh, unsigned int bit);
81extern int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit); 73extern int cx25821_res_locked(struct cx25821_fh *fh, unsigned int bit);
82extern void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh, 74extern void cx25821_res_free(struct cx25821_dev *dev, struct cx25821_fh *fh,
83 unsigned int bits); 75 unsigned int bits);
84extern int cx25821_video_mux(struct cx25821_dev *dev, unsigned int input);
85extern int cx25821_start_video_dma(struct cx25821_dev *dev, 76extern int cx25821_start_video_dma(struct cx25821_dev *dev,
86 struct cx25821_dmaqueue *q, 77 struct cx25821_dmaqueue *q,
87 struct cx25821_buffer *buf, 78 struct cx25821_buffer *buf,
88 const struct sram_channel *channel); 79 const struct sram_channel *channel);
89 80
90extern int cx25821_set_scale(struct cx25821_dev *dev, unsigned int width,
91 unsigned int height, enum v4l2_field field);
92extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status); 81extern int cx25821_video_irq(struct cx25821_dev *dev, int chan_num, u32 status);
93extern void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num); 82extern void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num);
94extern int cx25821_video_register(struct cx25821_dev *dev); 83extern int cx25821_video_register(struct cx25821_dev *dev);
95extern int cx25821_get_format_size(void);
96
97extern int cx25821_buffer_setup(struct videobuf_queue *q, unsigned int *count,
98 unsigned int *size);
99extern int cx25821_buffer_prepare(struct videobuf_queue *q,
100 struct videobuf_buffer *vb,
101 enum v4l2_field field);
102extern void cx25821_buffer_release(struct videobuf_queue *q,
103 struct videobuf_buffer *vb);
104extern struct videobuf_queue *get_queue(struct cx25821_fh *fh);
105extern int cx25821_get_resource(struct cx25821_fh *fh, int resource);
106extern int cx25821_video_mmap(struct file *file, struct vm_area_struct *vma);
107extern int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
108 struct v4l2_format *f);
109extern int cx25821_vidioc_querycap(struct file *file, void *priv,
110 struct v4l2_capability *cap);
111extern int cx25821_vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
112 struct v4l2_fmtdesc *f);
113extern int cx25821_vidioc_reqbufs(struct file *file, void *priv,
114 struct v4l2_requestbuffers *p);
115extern int cx25821_vidioc_querybuf(struct file *file, void *priv,
116 struct v4l2_buffer *p);
117extern int cx25821_vidioc_qbuf(struct file *file, void *priv,
118 struct v4l2_buffer *p);
119extern int cx25821_vidioc_s_std(struct file *file, void *priv,
120 v4l2_std_id tvnorms);
121extern int cx25821_enum_input(struct cx25821_dev *dev, struct v4l2_input *i);
122extern int cx25821_vidioc_enum_input(struct file *file, void *priv,
123 struct v4l2_input *i);
124extern int cx25821_vidioc_g_input(struct file *file, void *priv,
125 unsigned int *i);
126extern int cx25821_vidioc_s_input(struct file *file, void *priv,
127 unsigned int i);
128extern int cx25821_vidioc_g_ctrl(struct file *file, void *priv,
129 struct v4l2_control *ctl);
130extern int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
131 struct v4l2_format *f);
132extern int cx25821_vidioc_g_register(struct file *file, void *fh,
133 struct v4l2_dbg_register *reg);
134extern int cx25821_vidioc_s_register(struct file *file, void *fh,
135 const struct v4l2_dbg_register *reg);
136
137extern int cx25821_is_valid_width(u32 width, v4l2_std_id tvnorm);
138extern int cx25821_is_valid_height(u32 height, v4l2_std_id tvnorm);
139
140extern int cx25821_vidioc_g_priority(struct file *file, void *f,
141 enum v4l2_priority *p);
142extern int cx25821_vidioc_s_priority(struct file *file, void *f,
143 enum v4l2_priority prio);
144
145extern int cx25821_vidioc_queryctrl(struct file *file, void *priv,
146 struct v4l2_queryctrl *qctrl);
147extern int cx25821_set_control(struct cx25821_dev *dev,
148 struct v4l2_control *ctrl, int chan_num);
149
150extern int cx25821_vidioc_cropcap(struct file *file, void *fh,
151 struct v4l2_cropcap *cropcap);
152extern int cx25821_vidioc_s_crop(struct file *file, void *priv,
153 const struct v4l2_crop *crop);
154extern int cx25821_vidioc_g_crop(struct file *file, void *priv,
155 struct v4l2_crop *crop);
156 84
157extern int cx25821_vidioc_querystd(struct file *file, void *priv,
158 v4l2_std_id *norm);
159#endif 85#endif
diff --git a/drivers/media/pci/cx25821/cx25821.h b/drivers/media/pci/cx25821/cx25821.h
index 195b00407b5a..033993f1fb08 100644
--- a/drivers/media/pci/cx25821/cx25821.h
+++ b/drivers/media/pci/cx25821/cx25821.h
@@ -127,7 +127,7 @@ struct cx25821_fh {
127 enum v4l2_priority prio; 127 enum v4l2_priority prio;
128 128
129 /* video capture */ 129 /* video capture */
130 struct cx25821_fmt *fmt; 130 const struct cx25821_fmt *fmt;
131 unsigned int width, height; 131 unsigned int width, height;
132 int channel_id; 132 int channel_id;
133 struct videobuf_queue vidq; 133 struct videobuf_queue vidq;
@@ -152,7 +152,7 @@ struct cx25821_buffer {
152 /* cx25821 specific */ 152 /* cx25821 specific */
153 unsigned int bpl; 153 unsigned int bpl;
154 struct btcx_riscmem risc; 154 struct btcx_riscmem risc;
155 struct cx25821_fmt *fmt; 155 const struct cx25821_fmt *fmt;
156 u32 count; 156 u32 count;
157}; 157};
158 158
@@ -565,8 +565,5 @@ extern int cx25821_sram_channel_setup_upstream(struct cx25821_dev *dev,
565 unsigned int bpl, u32 risc); 565 unsigned int bpl, u32 risc);
566extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel, 566extern void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel,
567 u32 format); 567 u32 format);
568extern struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, 568
569 struct pci_dev *pci,
570 const struct video_device *template,
571 char *type);
572#endif 569#endif