aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7164
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2010-11-12 16:32:36 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-29 05:16:39 -0500
commitbc25068495b110fcdf35a22f43d32637e99fd018 (patch)
tree569ce8d98e0d46e583f5e897e8aa36cd3dd88bf7 /drivers/media/video/saa7164
parent0e72cc8b8d48ba05e705f432fb99aaa0ea6737c6 (diff)
[media] saa7164: Checkpatch compliance cleanup
Checkpatch compliance cleanup across files in the saa7164 driver. Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7164')
-rw-r--r--drivers/media/video/saa7164/saa7164-api.c123
-rw-r--r--drivers/media/video/saa7164/saa7164-buffer.c92
-rw-r--r--drivers/media/video/saa7164/saa7164-bus.c16
-rw-r--r--drivers/media/video/saa7164/saa7164-cards.c2
-rw-r--r--drivers/media/video/saa7164/saa7164-cmd.c10
-rw-r--r--drivers/media/video/saa7164/saa7164-core.c38
-rw-r--r--drivers/media/video/saa7164/saa7164-encoder.c33
-rw-r--r--drivers/media/video/saa7164/saa7164-fw.c8
-rw-r--r--drivers/media/video/saa7164/saa7164-i2c.c4
-rw-r--r--drivers/media/video/saa7164/saa7164-vbi.c37
-rw-r--r--drivers/media/video/saa7164/saa7164.h15
11 files changed, 215 insertions, 163 deletions
diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c
index ad3bc4154176..bd86d970f4c2 100644
--- a/drivers/media/video/saa7164/saa7164-api.c
+++ b/drivers/media/video/saa7164/saa7164-api.c
@@ -40,9 +40,8 @@ int saa7164_api_get_load_info(struct saa7164_dev *dev, struct tmFwInfoStruct *i)
40 40
41 ret = saa7164_cmd_send(dev, 0, GET_CUR, 41 ret = saa7164_cmd_send(dev, 0, GET_CUR,
42 GET_FW_STATUS_CONTROL, sizeof(struct tmFwInfoStruct), i); 42 GET_FW_STATUS_CONTROL, sizeof(struct tmFwInfoStruct), i);
43 if (ret != SAA_OK) { 43 if (ret != SAA_OK)
44 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 44 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
45 }
46 45
47 printk(KERN_INFO "saa7164[%d]-CPU: %d percent", dev->nr, i->CPULoad); 46 printk(KERN_INFO "saa7164[%d]-CPU: %d percent", dev->nr, i->CPULoad);
48 47
@@ -63,14 +62,15 @@ int saa7164_api_collect_debug(struct saa7164_dev *dev)
63 62
64 ret = saa7164_cmd_send(dev, 0, GET_CUR, 63 ret = saa7164_cmd_send(dev, 0, GET_CUR,
65 GET_DEBUG_DATA_CONTROL, sizeof(d), &d); 64 GET_DEBUG_DATA_CONTROL, sizeof(d), &d);
66 if (ret != SAA_OK) { 65 if (ret != SAA_OK)
67 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 66 printk(KERN_ERR "%s() error, ret = 0x%x\n",
68 } 67 __func__, ret);
69 68
70 if (d.dwResult != SAA_OK) 69 if (d.dwResult != SAA_OK)
71 break; 70 break;
72 71
73 printk(KERN_INFO "saa7164[%d]-FWMSG: %s", dev->nr, d.ucDebugData); 72 printk(KERN_INFO "saa7164[%d]-FWMSG: %s", dev->nr,
73 d.ucDebugData);
74 } 74 }
75 75
76 return 0; 76 return 0;
@@ -86,9 +86,9 @@ int saa7164_api_set_debug(struct saa7164_dev *dev, u8 level)
86 /* Retrieve current state */ 86 /* Retrieve current state */
87 ret = saa7164_cmd_send(dev, 0, GET_CUR, 87 ret = saa7164_cmd_send(dev, 0, GET_CUR,
88 SET_DEBUG_LEVEL_CONTROL, sizeof(lvl), &lvl); 88 SET_DEBUG_LEVEL_CONTROL, sizeof(lvl), &lvl);
89 if (ret != SAA_OK) { 89 if (ret != SAA_OK)
90 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 90 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
91 } 91
92 dprintk(DBGLVL_API, "%s() Was %d\n", __func__, lvl.dwDebugLevel); 92 dprintk(DBGLVL_API, "%s() Was %d\n", __func__, lvl.dwDebugLevel);
93 93
94 lvl.dwDebugLevel = level; 94 lvl.dwDebugLevel = level;
@@ -96,9 +96,8 @@ int saa7164_api_set_debug(struct saa7164_dev *dev, u8 level)
96 /* set new state */ 96 /* set new state */
97 ret = saa7164_cmd_send(dev, 0, SET_CUR, 97 ret = saa7164_cmd_send(dev, 0, SET_CUR,
98 SET_DEBUG_LEVEL_CONTROL, sizeof(lvl), &lvl); 98 SET_DEBUG_LEVEL_CONTROL, sizeof(lvl), &lvl);
99 if (ret != SAA_OK) { 99 if (ret != SAA_OK)
100 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 100 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
101 }
102 101
103 return ret; 102 return ret;
104} 103}
@@ -152,8 +151,10 @@ int saa7164_api_set_vbi_format(struct saa7164_port *port)
152 dprintk(DBGLVL_API, "SET/COMMIT Verified\n"); 151 dprintk(DBGLVL_API, "SET/COMMIT Verified\n");
153 152
154 dprintk(DBGLVL_API, "rsp.bmHint = 0x%x\n", rsp.bmHint); 153 dprintk(DBGLVL_API, "rsp.bmHint = 0x%x\n", rsp.bmHint);
155 dprintk(DBGLVL_API, "rsp.bFormatIndex = 0x%x\n", rsp.bFormatIndex); 154 dprintk(DBGLVL_API, "rsp.bFormatIndex = 0x%x\n",
156 dprintk(DBGLVL_API, "rsp.bFrameIndex = 0x%x\n", rsp.bFrameIndex); 155 rsp.bFormatIndex);
156 dprintk(DBGLVL_API, "rsp.bFrameIndex = 0x%x\n",
157 rsp.bFrameIndex);
157 } else 158 } else
158 printk(KERN_ERR "%s() compare failed\n", __func__); 159 printk(KERN_ERR "%s() compare failed\n", __func__);
159 } 160 }
@@ -210,14 +211,17 @@ int saa7164_api_set_encoder(struct saa7164_port *port)
210 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 211 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
211 212
212 /* Establish video bitrates */ 213 /* Establish video bitrates */
213 if (port->encoder_params.bitrate_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) 214 if (port->encoder_params.bitrate_mode ==
215 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR)
214 vb.ucVideoBitRateMode = EU_VIDEO_BIT_RATE_MODE_CONSTANT; 216 vb.ucVideoBitRateMode = EU_VIDEO_BIT_RATE_MODE_CONSTANT;
215 else 217 else
216 vb.ucVideoBitRateMode = EU_VIDEO_BIT_RATE_MODE_VARIABLE_PEAK; 218 vb.ucVideoBitRateMode = EU_VIDEO_BIT_RATE_MODE_VARIABLE_PEAK;
217 vb.dwVideoBitRate = port->encoder_params.bitrate; 219 vb.dwVideoBitRate = port->encoder_params.bitrate;
218 vb.dwVideoBitRatePeak = port->encoder_params.bitrate_peak; 220 vb.dwVideoBitRatePeak = port->encoder_params.bitrate_peak;
219 ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR, 221 ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR,
220 EU_VIDEO_BIT_RATE_CONTROL, sizeof(struct tmComResEncVideoBitRate), &vb); 222 EU_VIDEO_BIT_RATE_CONTROL,
223 sizeof(struct tmComResEncVideoBitRate),
224 &vb);
221 if (ret != SAA_OK) 225 if (ret != SAA_OK)
222 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 226 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
223 227
@@ -226,9 +230,12 @@ int saa7164_api_set_encoder(struct saa7164_port *port)
226 ab.dwAudioBitRate = 384000; 230 ab.dwAudioBitRate = 384000;
227 ab.dwAudioBitRatePeak = ab.dwAudioBitRate; 231 ab.dwAudioBitRatePeak = ab.dwAudioBitRate;
228 ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR, 232 ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, SET_CUR,
229 EU_AUDIO_BIT_RATE_CONTROL, sizeof(struct tmComResEncAudioBitRate), &ab); 233 EU_AUDIO_BIT_RATE_CONTROL,
234 sizeof(struct tmComResEncAudioBitRate),
235 &ab);
230 if (ret != SAA_OK) 236 if (ret != SAA_OK)
231 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 237 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__,
238 ret);
232 239
233 saa7164_api_set_aspect_ratio(port); 240 saa7164_api_set_aspect_ratio(port);
234 saa7164_api_set_gop_size(port); 241 saa7164_api_set_gop_size(port);
@@ -244,7 +251,8 @@ int saa7164_api_get_encoder(struct saa7164_port *port)
244 struct tmComResEncVideoInputAspectRatio ar; 251 struct tmComResEncVideoInputAspectRatio ar;
245 int ret; 252 int ret;
246 253
247 dprintk(DBGLVL_ENC, "%s() unitid=0x%x\n", __func__, port->hwcfg.sourceid); 254 dprintk(DBGLVL_ENC, "%s() unitid=0x%x\n", __func__,
255 port->hwcfg.sourceid);
248 256
249 port->encoder_profile = 0; 257 port->encoder_profile = 0;
250 port->video_format = 0; 258 port->video_format = 0;
@@ -257,7 +265,8 @@ int saa7164_api_get_encoder(struct saa7164_port *port)
257 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 265 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
258 266
259 ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, GET_CUR, 267 ret = saa7164_cmd_send(port->dev, port->hwcfg.sourceid, GET_CUR,
260 EU_VIDEO_RESOLUTION_CONTROL, sizeof(u8), &port->video_resolution); 268 EU_VIDEO_RESOLUTION_CONTROL, sizeof(u8),
269 &port->video_resolution);
261 if (ret != SAA_OK) 270 if (ret != SAA_OK)
262 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 271 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
263 272
@@ -294,13 +303,20 @@ int saa7164_api_get_encoder(struct saa7164_port *port)
294 dprintk(DBGLVL_ENC, "video_format = %d\n", port->video_format); 303 dprintk(DBGLVL_ENC, "video_format = %d\n", port->video_format);
295 dprintk(DBGLVL_ENC, "audio_format = %d\n", port->audio_format); 304 dprintk(DBGLVL_ENC, "audio_format = %d\n", port->audio_format);
296 dprintk(DBGLVL_ENC, "video_resolution= %d\n", port->video_resolution); 305 dprintk(DBGLVL_ENC, "video_resolution= %d\n", port->video_resolution);
297 dprintk(DBGLVL_ENC, "v.ucVideoBitRateMode = %d\n", v.ucVideoBitRateMode); 306 dprintk(DBGLVL_ENC, "v.ucVideoBitRateMode = %d\n",
298 dprintk(DBGLVL_ENC, "v.dwVideoBitRate = %d\n", v.dwVideoBitRate); 307 v.ucVideoBitRateMode);
299 dprintk(DBGLVL_ENC, "v.dwVideoBitRatePeak = %d\n", v.dwVideoBitRatePeak); 308 dprintk(DBGLVL_ENC, "v.dwVideoBitRate = %d\n",
300 dprintk(DBGLVL_ENC, "a.ucVideoBitRateMode = %d\n", a.ucAudioBitRateMode); 309 v.dwVideoBitRate);
301 dprintk(DBGLVL_ENC, "a.dwVideoBitRate = %d\n", a.dwAudioBitRate); 310 dprintk(DBGLVL_ENC, "v.dwVideoBitRatePeak = %d\n",
302 dprintk(DBGLVL_ENC, "a.dwVideoBitRatePeak = %d\n", a.dwAudioBitRatePeak); 311 v.dwVideoBitRatePeak);
303 dprintk(DBGLVL_ENC, "aspect.width / height = %d:%d\n", ar.width, ar.height); 312 dprintk(DBGLVL_ENC, "a.ucVideoBitRateMode = %d\n",
313 a.ucAudioBitRateMode);
314 dprintk(DBGLVL_ENC, "a.dwVideoBitRate = %d\n",
315 a.dwAudioBitRate);
316 dprintk(DBGLVL_ENC, "a.dwVideoBitRatePeak = %d\n",
317 a.dwAudioBitRatePeak);
318 dprintk(DBGLVL_ENC, "aspect.width / height = %d:%d\n",
319 ar.width, ar.height);
304 320
305 return ret; 321 return ret;
306} 322}
@@ -439,7 +455,8 @@ int saa7164_api_set_videomux(struct saa7164_port *port)
439 455
440 /* Audio Mux */ 456 /* Audio Mux */
441 ret = saa7164_cmd_send(port->dev, port->audfeat.sourceid, SET_CUR, 457 ret = saa7164_cmd_send(port->dev, port->audfeat.sourceid, SET_CUR,
442 SU_INPUT_SELECT_CONTROL, sizeof(u8), &inputs[port->mux_input - 1]); 458 SU_INPUT_SELECT_CONTROL, sizeof(u8),
459 &inputs[port->mux_input - 1]);
443 if (ret != SAA_OK) 460 if (ret != SAA_OK)
444 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 461 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
445 462
@@ -492,7 +509,8 @@ int saa7164_api_set_audio_volume(struct saa7164_port *port, s8 level)
492 if (ret != SAA_OK) 509 if (ret != SAA_OK)
493 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 510 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
494 511
495 dprintk(DBGLVL_API, "%s(%d) min=%d max=%d cur=%d\n", __func__, level, min, max, v); 512 dprintk(DBGLVL_API, "%s(%d) min=%d max=%d cur=%d\n", __func__,
513 level, min, max, v);
496 514
497 v = level; 515 v = level;
498 if (v < min) 516 if (v < min)
@@ -517,7 +535,8 @@ int saa7164_api_set_audio_volume(struct saa7164_port *port, s8 level)
517 if (ret != SAA_OK) 535 if (ret != SAA_OK)
518 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 536 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
519 537
520 dprintk(DBGLVL_API, "%s(%d) min=%d max=%d cur=%d\n", __func__, level, min, max, v); 538 dprintk(DBGLVL_API, "%s(%d) min=%d max=%d cur=%d\n", __func__,
539 level, min, max, v);
521 540
522 return ret; 541 return ret;
523} 542}
@@ -539,7 +558,8 @@ int saa7164_api_set_audio_std(struct saa7164_port *port)
539 lvl.ucSAP_Level = TMHW_LEV_ADJ_SAPLEV_DEFAULT; 558 lvl.ucSAP_Level = TMHW_LEV_ADJ_SAPLEV_DEFAULT;
540 lvl.ucADC_Level = TMHW_LEV_ADJ_ADCLEV_DEFAULT; 559 lvl.ucADC_Level = TMHW_LEV_ADJ_ADCLEV_DEFAULT;
541 ret = saa7164_cmd_send(port->dev, port->audfeat.unitid, SET_CUR, 560 ret = saa7164_cmd_send(port->dev, port->audfeat.unitid, SET_CUR,
542 AUDIO_DEFAULT_CONTROL, sizeof(struct tmComResAudioDefaults), &lvl); 561 AUDIO_DEFAULT_CONTROL, sizeof(struct tmComResAudioDefaults),
562 &lvl);
543 if (ret != SAA_OK) 563 if (ret != SAA_OK)
544 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); 564 printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret);
545 565
@@ -555,7 +575,8 @@ int saa7164_api_set_audio_std(struct saa7164_port *port)
555 ret = saa7164_cmd_send(port->dev, port->tunerunit.unitid, SET_CUR, 575 ret = saa7164_cmd_send(port->dev, port->tunerunit.unitid, SET_CUR,
556 TU_STANDARD_CONTROL, sizeof(tvaudio), &tvaudio); 576 TU_STANDARD_CONTROL, sizeof(tvaudio), &tvaudio);
557 if (ret != SAA_OK) 577 if (ret != SAA_OK)
558 printk(KERN_ERR "%s() TU_STANDARD_CONTROL error, ret = 0x%x\n", __func__, ret); 578 printk(KERN_ERR "%s() TU_STANDARD_CONTROL error, ret = 0x%x\n",
579 __func__, ret);
559 return ret; 580 return ret;
560} 581}
561 582
@@ -575,7 +596,9 @@ int saa7164_api_set_audio_detection(struct saa7164_port *port, int autodetect)
575 ret = saa7164_cmd_send(port->dev, port->tunerunit.unitid, SET_CUR, 596 ret = saa7164_cmd_send(port->dev, port->tunerunit.unitid, SET_CUR,
576 TU_STANDARD_AUTO_CONTROL, sizeof(p), &p); 597 TU_STANDARD_AUTO_CONTROL, sizeof(p), &p);
577 if (ret != SAA_OK) 598 if (ret != SAA_OK)
578 printk(KERN_ERR "%s() TU_STANDARD_AUTO_CONTROL error, ret = 0x%x\n", __func__, ret); 599 printk(KERN_ERR
600 "%s() TU_STANDARD_AUTO_CONTROL error, ret = 0x%x\n",
601 __func__, ret);
579 602
580 return ret; 603 return ret;
581} 604}
@@ -646,9 +669,9 @@ int saa7164_api_set_dif(struct saa7164_port *port, u8 reg, u8 val)
646 EXU_REGISTER_ACCESS_CONTROL, len, &buf); 669 EXU_REGISTER_ACCESS_CONTROL, len, &buf);
647 if (ret != SAA_OK) 670 if (ret != SAA_OK)
648 printk(KERN_ERR "%s() error, ret(2) = 0x%x\n", __func__, ret); 671 printk(KERN_ERR "%s() error, ret(2) = 0x%x\n", __func__, ret);
649 672#if 0
650 //saa7164_dumphex16(dev, buf, 16); 673 saa7164_dumphex16(dev, buf, 16);
651 674#endif
652 return ret == SAA_OK ? 0 : -EIO; 675 return ret == SAA_OK ? 0 : -EIO;
653} 676}
654 677
@@ -696,7 +719,8 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std)
696 } else { 719 } else {
697 /* Unknown standard, assume DTV */ 720 /* Unknown standard, assume DTV */
698 dprintk(DBGLVL_API, " Unknown (assuming DTV)\n"); 721 dprintk(DBGLVL_API, " Unknown (assuming DTV)\n");
699 saa7164_api_set_dif(port, 0x00, 0x80); /* Undefined Video Standard */ 722 /* Undefinded Video Standard */
723 saa7164_api_set_dif(port, 0x00, 0x80);
700 agc_disable = 1; 724 agc_disable = 1;
701 } 725 }
702 726
@@ -933,7 +957,7 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
933 if (hdr->type != CS_INTERFACE) 957 if (hdr->type != CS_INTERFACE)
934 return SAA_ERR_NOT_SUPPORTED; 958 return SAA_ERR_NOT_SUPPORTED;
935 959
936 dprintk(DBGLVL_API, "@ 0x%x = \n", idx); 960 dprintk(DBGLVL_API, "@ 0x%x =\n", idx);
937 switch (hdr->subtype) { 961 switch (hdr->subtype) {
938 case GENERAL_REQUEST: 962 case GENERAL_REQUEST:
939 dprintk(DBGLVL_API, " GENERAL_REQUEST\n"); 963 dprintk(DBGLVL_API, " GENERAL_REQUEST\n");
@@ -1085,7 +1109,8 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
1085 vbiport = &dev->ports[SAA7164_PORT_VBI2]; 1109 vbiport = &dev->ports[SAA7164_PORT_VBI2];
1086 memcpy(&vbiport->hwcfg, vcoutputtermhdr, 1110 memcpy(&vbiport->hwcfg, vcoutputtermhdr,
1087 sizeof(*vcoutputtermhdr)); 1111 sizeof(*vcoutputtermhdr));
1088 memcpy(&vbiport->vbi_fmt_ntsc, vbifmt, sizeof(*vbifmt)); 1112 memcpy(&vbiport->vbi_fmt_ntsc, vbifmt,
1113 sizeof(*vbifmt));
1089 saa7164_api_configure_port_vbi(dev, 1114 saa7164_api_configure_port_vbi(dev,
1090 vbiport); 1115 vbiport);
1091 break; 1116 break;
@@ -1134,7 +1159,9 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
1134 encport = &dev->ports[SAA7164_PORT_ENC2]; 1159 encport = &dev->ports[SAA7164_PORT_ENC2];
1135 memcpy(&encport->tunerunit, tunerunithdr, 1160 memcpy(&encport->tunerunit, tunerunithdr,
1136 sizeof(struct tmComResTunerDescrHeader)); 1161 sizeof(struct tmComResTunerDescrHeader));
1137 dprintk(DBGLVL_API, " (becomes dev->enc[%d] tuner)\n", encport->nr); 1162 dprintk(DBGLVL_API,
1163 " (becomes dev->enc[%d] tuner)\n",
1164 encport->nr);
1138 } 1165 }
1139 break; 1166 break;
1140 case VC_SELECTOR_UNIT: 1167 case VC_SELECTOR_UNIT:
@@ -1163,7 +1190,8 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
1163 encport = &dev->ports[SAA7164_PORT_ENC2]; 1190 encport = &dev->ports[SAA7164_PORT_ENC2];
1164 memcpy(&encport->vidproc, pdh, 1191 memcpy(&encport->vidproc, pdh,
1165 sizeof(struct tmComResProcDescrHeader)); 1192 sizeof(struct tmComResProcDescrHeader));
1166 dprintk(DBGLVL_API, " (becomes dev->enc[%d])\n", encport->nr); 1193 dprintk(DBGLVL_API, " (becomes dev->enc[%d])\n",
1194 encport->nr);
1167 } 1195 }
1168 break; 1196 break;
1169 case FEATURE_UNIT: 1197 case FEATURE_UNIT:
@@ -1181,15 +1209,18 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
1181 encport = &dev->ports[SAA7164_PORT_ENC2]; 1209 encport = &dev->ports[SAA7164_PORT_ENC2];
1182 memcpy(&encport->audfeat, afd, 1210 memcpy(&encport->audfeat, afd,
1183 sizeof(struct tmComResAFeatureDescrHeader)); 1211 sizeof(struct tmComResAFeatureDescrHeader));
1184 dprintk(DBGLVL_API, " (becomes dev->enc[%d])\n", encport->nr); 1212 dprintk(DBGLVL_API, " (becomes dev->enc[%d])\n",
1213 encport->nr);
1185 break; 1214 break;
1186 case ENCODER_UNIT: 1215 case ENCODER_UNIT:
1187 edh = (struct tmComResEncoderDescrHeader *)(buf + idx); 1216 edh = (struct tmComResEncoderDescrHeader *)(buf + idx);
1188 dprintk(DBGLVL_API, " ENCODER_UNIT\n"); 1217 dprintk(DBGLVL_API, " ENCODER_UNIT\n");
1189 dprintk(DBGLVL_API, " subtype = 0x%x\n", edh->subtype); 1218 dprintk(DBGLVL_API, " subtype = 0x%x\n", edh->subtype);
1190 dprintk(DBGLVL_API, " unitid = 0x%x\n", edh->unitid); 1219 dprintk(DBGLVL_API, " unitid = 0x%x\n", edh->unitid);
1191 dprintk(DBGLVL_API, " vsourceid = 0x%x\n", edh->vsourceid); 1220 dprintk(DBGLVL_API, " vsourceid = 0x%x\n",
1192 dprintk(DBGLVL_API, " asourceid = 0x%x\n", edh->asourceid); 1221 edh->vsourceid);
1222 dprintk(DBGLVL_API, " asourceid = 0x%x\n",
1223 edh->asourceid);
1193 dprintk(DBGLVL_API, " iunit = 0x%x\n", edh->iunit); 1224 dprintk(DBGLVL_API, " iunit = 0x%x\n", edh->iunit);
1194 if (edh->iunit == edh->unitid) { 1225 if (edh->iunit == edh->unitid) {
1195 if (currpath == 1) 1226 if (currpath == 1)
@@ -1198,7 +1229,9 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
1198 encport = &dev->ports[SAA7164_PORT_ENC2]; 1229 encport = &dev->ports[SAA7164_PORT_ENC2];
1199 memcpy(&encport->encunit, edh, 1230 memcpy(&encport->encunit, edh,
1200 sizeof(struct tmComResEncoderDescrHeader)); 1231 sizeof(struct tmComResEncoderDescrHeader));
1201 dprintk(DBGLVL_API, " (becomes dev->enc[%d])\n", encport->nr); 1232 dprintk(DBGLVL_API,
1233 " (becomes dev->enc[%d])\n",
1234 encport->nr);
1202 } 1235 }
1203 break; 1236 break;
1204 case EXTENSION_UNIT: 1237 case EXTENSION_UNIT:
@@ -1262,7 +1295,9 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len)
1262 encport = &dev->ports[SAA7164_PORT_ENC2]; 1295 encport = &dev->ports[SAA7164_PORT_ENC2];
1263 memcpy(&encport->ifunit, exthdr, 1296 memcpy(&encport->ifunit, exthdr,
1264 sizeof(struct tmComResExtDevDescrHeader)); 1297 sizeof(struct tmComResExtDevDescrHeader));
1265 dprintk(DBGLVL_API, " (becomes dev->enc[%d])\n", encport->nr); 1298 dprintk(DBGLVL_API,
1299 " (becomes dev->enc[%d])\n",
1300 encport->nr);
1266 } 1301 }
1267 break; 1302 break;
1268 case PVC_INFRARED_UNIT: 1303 case PVC_INFRARED_UNIT:
diff --git a/drivers/media/video/saa7164/saa7164-buffer.c b/drivers/media/video/saa7164/saa7164-buffer.c
index 7230912acc7d..ddd25211c9e8 100644
--- a/drivers/media/video/saa7164/saa7164-buffer.c
+++ b/drivers/media/video/saa7164/saa7164-buffer.c
@@ -24,46 +24,46 @@
24#include "saa7164.h" 24#include "saa7164.h"
25 25
26/* The PCI address space for buffer handling looks like this: 26/* The PCI address space for buffer handling looks like this:
27 27 *
28 +-u32 wide-------------+ 28 * +-u32 wide-------------+
29 | + 29 * | +
30 +-u64 wide------------------------------------+ 30 * +-u64 wide------------------------------------+
31 + + 31 * + +
32 +----------------------+ 32 * +----------------------+
33 | CurrentBufferPtr + Pointer to current PCI buffer >-+ 33 * | CurrentBufferPtr + Pointer to current PCI buffer >-+
34 +----------------------+ | 34 * +----------------------+ |
35 | Unused + | 35 * | Unused + |
36 +----------------------+ | 36 * +----------------------+ |
37 | Pitch + = 188 (bytes) | 37 * | Pitch + = 188 (bytes) |
38 +----------------------+ | 38 * +----------------------+ |
39 | PCI buffer size + = pitch * number of lines (312) | 39 * | PCI buffer size + = pitch * number of lines (312) |
40 +----------------------+ | 40 * +----------------------+ |
41 |0| Buf0 Write Offset + | 41 * |0| Buf0 Write Offset + |
42 +----------------------+ v 42 * +----------------------+ v
43 |1| Buf1 Write Offset + | 43 * |1| Buf1 Write Offset + |
44 +----------------------+ | 44 * +----------------------+ |
45 |2| Buf2 Write Offset + | 45 * |2| Buf2 Write Offset + |
46 +----------------------+ | 46 * +----------------------+ |
47 |3| Buf3 Write Offset + | 47 * |3| Buf3 Write Offset + |
48 +----------------------+ | 48 * +----------------------+ |
49 ... More write offsets | 49 * ... More write offsets |
50 +---------------------------------------------+ | 50 * +---------------------------------------------+ |
51 +0| set of ptrs to PCI pagetables + | 51 * +0| set of ptrs to PCI pagetables + |
52 +---------------------------------------------+ | 52 * +---------------------------------------------+ |
53 +1| set of ptrs to PCI pagetables + <--------+ 53 * +1| set of ptrs to PCI pagetables + <--------+
54 +---------------------------------------------+ 54 * +---------------------------------------------+
55 +2| set of ptrs to PCI pagetables + 55 * +2| set of ptrs to PCI pagetables +
56 +---------------------------------------------+ 56 * +---------------------------------------------+
57 +3| set of ptrs to PCI pagetables + >--+ 57 * +3| set of ptrs to PCI pagetables + >--+
58 +---------------------------------------------+ | 58 * +---------------------------------------------+ |
59 ... More buffer pointers | +----------------+ 59 * ... More buffer pointers | +----------------+
60 +->| pt[0] TS data | 60 * +->| pt[0] TS data |
61 | +----------------+ 61 * | +----------------+
62 | 62 * |
63 | +----------------+ 63 * | +----------------+
64 +->| pt[1] TS data | 64 * +->| pt[1] TS data |
65 | +----------------+ 65 * | +----------------+
66 | etc 66 * | etc
67 */ 67 */
68 68
69void saa7164_buffer_display(struct saa7164_buffer *buf) 69void saa7164_buffer_display(struct saa7164_buffer *buf)
@@ -283,7 +283,8 @@ int saa7164_buffer_cfg_port(struct saa7164_port *port)
283 return 0; 283 return 0;
284} 284}
285 285
286struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev, u32 len) 286struct saa7164_user_buffer *saa7164_buffer_alloc_user(struct saa7164_dev *dev,
287 u32 len)
287{ 288{
288 struct saa7164_user_buffer *buf; 289 struct saa7164_user_buffer *buf;
289 290
@@ -313,12 +314,9 @@ void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf)
313 if (!buf) 314 if (!buf)
314 return; 315 return;
315 316
316 if (buf->data) { 317 kfree(buf->data);
317 kfree(buf->data); 318 buf->data = 0;
318 buf->data = 0;
319 }
320 319
321 if (buf) 320 kfree(buf);
322 kfree(buf);
323} 321}
324 322
diff --git a/drivers/media/video/saa7164/saa7164-bus.c b/drivers/media/video/saa7164/saa7164-bus.c
index 30d5283da41e..b2b0d97101d0 100644
--- a/drivers/media/video/saa7164/saa7164-bus.c
+++ b/drivers/media/video/saa7164/saa7164-bus.c
@@ -43,7 +43,8 @@ int saa7164_bus_setup(struct saa7164_dev *dev)
43 43
44 b->m_dwSizeGetRing = SAA_DEVICE_BUFFERBLOCKSIZE; 44 b->m_dwSizeGetRing = SAA_DEVICE_BUFFERBLOCKSIZE;
45 45
46 b->m_dwSetWritePos = ((u32)dev->intfdesc.BARLocation) + (2 * sizeof(u64)); 46 b->m_dwSetWritePos = ((u32)dev->intfdesc.BARLocation) +
47 (2 * sizeof(u64));
47 b->m_dwSetReadPos = b->m_dwSetWritePos + (1 * sizeof(u32)); 48 b->m_dwSetReadPos = b->m_dwSetWritePos + (1 * sizeof(u32));
48 49
49 b->m_dwGetWritePos = b->m_dwSetWritePos + (2 * sizeof(u32)); 50 b->m_dwGetWritePos = b->m_dwSetWritePos + (2 * sizeof(u32));
@@ -105,7 +106,8 @@ void saa7164_bus_verify(struct saa7164_dev *dev)
105 } 106 }
106} 107}
107 108
108void saa7164_bus_dumpmsg(struct saa7164_dev *dev, struct tmComResInfo* m, void *buf) 109void saa7164_bus_dumpmsg(struct saa7164_dev *dev, struct tmComResInfo* m,
110 void *buf)
109{ 111{
110 dprintk(DBGLVL_BUS, "Dumping msg structure:\n"); 112 dprintk(DBGLVL_BUS, "Dumping msg structure:\n");
111 dprintk(DBGLVL_BUS, " .id = %d\n", m->id); 113 dprintk(DBGLVL_BUS, " .id = %d\n", m->id);
@@ -129,7 +131,8 @@ void saa7164_bus_dumpmsg(struct saa7164_dev *dev, struct tmComResInfo* m, void *
129 * SAA_OK The function executed successfully. 131 * SAA_OK The function executed successfully.
130 * < 0 One or more members are not initialized. 132 * < 0 One or more members are not initialized.
131 */ 133 */
132int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, void *buf) 134int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
135 void *buf)
133{ 136{
134 struct tmComResBusInfo *bus = &dev->bus; 137 struct tmComResBusInfo *bus = &dev->bus;
135 u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp; 138 u32 bytes_to_write, free_write_space, timeout, curr_srp, curr_swp;
@@ -294,14 +297,15 @@ out:
294/* 297/*
295 * Receive a command or a response from the bus. The implementation does not 298 * Receive a command or a response from the bus. The implementation does not
296 * know if it is a command or a response it simply dequeues the data, 299 * know if it is a command or a response it simply dequeues the data,
297 * depending on the bus information given in the struct tmComResBusInfo structure. 300 * depending on the bus information given in the struct tmComResBusInfo
301 * structure.
298 * 302 *
299 * Return Value: 303 * Return Value:
300 * 0 The function executed successfully. 304 * 0 The function executed successfully.
301 * < 0 One or more members are not initialized. 305 * < 0 One or more members are not initialized.
302 */ 306 */
303int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, void *buf, 307int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
304 int peekonly) 308 void *buf, int peekonly)
305{ 309{
306 struct tmComResBusInfo *bus = &dev->bus; 310 struct tmComResBusInfo *bus = &dev->bus;
307 u32 bytes_to_read, write_distance, curr_grp, curr_gwp, 311 u32 bytes_to_read, write_distance, curr_grp, curr_gwp,
diff --git a/drivers/media/video/saa7164/saa7164-cards.c b/drivers/media/video/saa7164/saa7164-cards.c
index 4cb634e952a6..69822a4e7275 100644
--- a/drivers/media/video/saa7164/saa7164-cards.c
+++ b/drivers/media/video/saa7164/saa7164-cards.c
@@ -482,7 +482,7 @@ void saa7164_gpio_setup(struct saa7164_dev *dev)
482 saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2); 482 saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
483 saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3); 483 saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
484 484
485 msleep(10); 485 msleep(20);
486 486
487 saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2); 487 saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
488 saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3); 488 saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
diff --git a/drivers/media/video/saa7164/saa7164-cmd.c b/drivers/media/video/saa7164/saa7164-cmd.c
index 301a9e302f45..a97ae17b36c2 100644
--- a/drivers/media/video/saa7164/saa7164-cmd.c
+++ b/drivers/media/video/saa7164/saa7164-cmd.c
@@ -122,8 +122,8 @@ int saa7164_irq_dequeue(struct saa7164_dev *dev)
122 return ret; 122 return ret;
123 } 123 }
124 124
125 /* It's unlikely to have more than 4 or 5 pending messages, ensure we exit 125 /* It's unlikely to have more than 4 or 5 pending messages,
126 * at some point regardles. 126 * ensure we exit at some point regardless.
127 */ 127 */
128 } while (i++ < 32); 128 } while (i++ < 32);
129 129
@@ -186,7 +186,8 @@ int saa7164_cmd_dequeue(struct saa7164_dev *dev)
186 return SAA_OK; 186 return SAA_OK;
187} 187}
188 188
189int saa7164_cmd_set(struct saa7164_dev *dev, struct tmComResInfo* msg, void *buf) 189int saa7164_cmd_set(struct saa7164_dev *dev, struct tmComResInfo *msg,
190 void *buf)
190{ 191{
191 struct tmComResBusInfo *bus = &dev->bus; 192 struct tmComResBusInfo *bus = &dev->bus;
192 u8 cmd_sent; 193 u8 cmd_sent;
@@ -292,7 +293,8 @@ int saa7164_cmd_wait(struct saa7164_dev *dev, u8 seqno)
292 * We typically are signalled in < 50ms but it can 293 * We typically are signalled in < 50ms but it can
293 * take MUCH longer. 294 * take MUCH longer.
294 */ 295 */
295 wait_event_timeout(*q, dev->cmds[seqno].signalled, (HZ * waitsecs)); 296 wait_event_timeout(*q, dev->cmds[seqno].signalled,
297 (HZ * waitsecs));
296 r = time_before(jiffies, stamp + (HZ * waitsecs)); 298 r = time_before(jiffies, stamp + (HZ * waitsecs));
297 if (r) 299 if (r)
298 ret = SAA_OK; 300 ret = SAA_OK;
diff --git a/drivers/media/video/saa7164/saa7164-core.c b/drivers/media/video/saa7164/saa7164-core.c
index b66f78f7042c..d6bf3f82cc34 100644
--- a/drivers/media/video/saa7164/saa7164-core.c
+++ b/drivers/media/video/saa7164/saa7164-core.c
@@ -40,12 +40,12 @@ MODULE_AUTHOR("Steven Toth <stoth@kernellabs.com>");
40MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
41 41
42/* 42/*
43 1 Basic 43 * 1 Basic
44 2 44 * 2
45 4 i2c 45 * 4 i2c
46 8 api 46 * 8 api
47 16 cmd 47 * 16 cmd
48 32 bus 48 * 32 bus
49 */ 49 */
50 50
51unsigned int saa_debug; 51unsigned int saa_debug;
@@ -82,7 +82,8 @@ MODULE_PARM_DESC(crc_checking, "enable crc sanity checking on buffers");
82 82
83unsigned int guard_checking = 1; 83unsigned int guard_checking = 1;
84module_param(guard_checking, int, 0644); 84module_param(guard_checking, int, 0644);
85MODULE_PARM_DESC(guard_checking, "enable dma sanity checking for buffer overruns"); 85MODULE_PARM_DESC(guard_checking,
86 "enable dma sanity checking for buffer overruns");
86 87
87static unsigned int saa7164_devcount; 88static unsigned int saa7164_devcount;
88 89
@@ -123,7 +124,9 @@ static void saa7164_pack_verifier(struct saa7164_buffer *buf)
123 if ((*(p + i + 0) != 0x00) || (*(p + i + 1) != 0x00) || 124 if ((*(p + i + 0) != 0x00) || (*(p + i + 1) != 0x00) ||
124 (*(p + i + 2) != 0x01) || (*(p + i + 3) != 0xBA)) { 125 (*(p + i + 2) != 0x01) || (*(p + i + 3) != 0xBA)) {
125 printk(KERN_ERR "No pack at 0x%x\n", i); 126 printk(KERN_ERR "No pack at 0x%x\n", i);
126// saa7164_dumphex16FF(buf->port->dev, (p + i), 32); 127#if 0
128 saa7164_dumphex16FF(buf->port->dev, (p + i), 32);
129#endif
127 } 130 }
128 } 131 }
129} 132}
@@ -199,19 +202,16 @@ static void saa7164_histogram_reset(struct saa7164_histogram *hg, char *name)
199 strcpy(hg->name, name); 202 strcpy(hg->name, name);
200 203
201 /* First 30ms x 1ms */ 204 /* First 30ms x 1ms */
202 for (i = 0; i < 30; i++) { 205 for (i = 0; i < 30; i++)
203 hg->counter1[0 + i].val = i; 206 hg->counter1[0 + i].val = i;
204 }
205 207
206 /* 30 - 200ms x 10ms */ 208 /* 30 - 200ms x 10ms */
207 for (i = 0; i < 18; i++) { 209 for (i = 0; i < 18; i++)
208 hg->counter1[30 + i].val = 30 + (i * 10); 210 hg->counter1[30 + i].val = 30 + (i * 10);
209 }
210 211
211 /* 200 - 2000ms x 100ms */ 212 /* 200 - 2000ms x 100ms */
212 for (i = 0; i < 15; i++) { 213 for (i = 0; i < 15; i++)
213 hg->counter1[48 + i].val = 200 + (i * 200); 214 hg->counter1[48 + i].val = 200 + (i * 200);
214 }
215 215
216 /* Catch all massive value (2secs) */ 216 /* Catch all massive value (2secs) */
217 hg->counter1[55].val = 2000; 217 hg->counter1[55].val = 2000;
@@ -315,7 +315,9 @@ static void saa7164_work_enchandler_helper(struct saa7164_port *port, int bufnr)
315 (*(p + buf->actual_size + 0x13) != 0xff)) { 315 (*(p + buf->actual_size + 0x13) != 0xff)) {
316 printk(KERN_ERR "%s() buf %p guard buffer breach\n", 316 printk(KERN_ERR "%s() buf %p guard buffer breach\n",
317 __func__, buf); 317 __func__, buf);
318// saa7164_dumphex16FF(dev, (p + buf->actual_size) - 32 , 64); 318#if 0
319 saa7164_dumphex16FF(dev, (p + buf->actual_size) - 32 , 64);
320#endif
319 } 321 }
320 } 322 }
321 323
@@ -961,9 +963,7 @@ static int saa7164_port_init(struct saa7164_dev *dev, int portnr)
961 963
962 /* We need a deferred interrupt handler for cmd handling */ 964 /* We need a deferred interrupt handler for cmd handling */
963 INIT_WORK(&port->workenc, saa7164_work_enchandler); 965 INIT_WORK(&port->workenc, saa7164_work_enchandler);
964 } 966 } else if ((portnr == SAA7164_PORT_VBI1) || (portnr == SAA7164_PORT_VBI2)) {
965 else
966 if ((portnr == SAA7164_PORT_VBI1) || (portnr == SAA7164_PORT_VBI2)) {
967 port->type = SAA7164_MPEG_VBI; 967 port->type = SAA7164_MPEG_VBI;
968 968
969 /* We need a deferred interrupt handler for cmd handling */ 969 /* We need a deferred interrupt handler for cmd handling */
@@ -1169,7 +1169,7 @@ static int saa7164_proc_open(struct inode *inode, struct file *filp)
1169 return single_open(filp, saa7164_proc_show, NULL); 1169 return single_open(filp, saa7164_proc_show, NULL);
1170} 1170}
1171 1171
1172static struct file_operations saa7164_proc_fops = { 1172static const struct file_operations saa7164_proc_fops = {
1173 .open = saa7164_proc_open, 1173 .open = saa7164_proc_open,
1174 .read = seq_read, 1174 .read = seq_read,
1175 .llseek = seq_lseek, 1175 .llseek = seq_lseek,
diff --git a/drivers/media/video/saa7164/saa7164-encoder.c b/drivers/media/video/saa7164/saa7164-encoder.c
index cbb53d0ee979..1838408cd5cb 100644
--- a/drivers/media/video/saa7164/saa7164-encoder.c
+++ b/drivers/media/video/saa7164/saa7164-encoder.c
@@ -125,16 +125,22 @@ static int saa7164_encoder_buffers_alloc(struct saa7164_port *port)
125 125
126 dprintk(DBGLVL_ENC, "%s()\n", __func__); 126 dprintk(DBGLVL_ENC, "%s()\n", __func__);
127 127
128 if (port->encoder_params.stream_type == V4L2_MPEG_STREAM_TYPE_MPEG2_PS) { 128 if (port->encoder_params.stream_type ==
129 dprintk(DBGLVL_ENC, "%s() type=V4L2_MPEG_STREAM_TYPE_MPEG2_PS\n", __func__); 129 V4L2_MPEG_STREAM_TYPE_MPEG2_PS) {
130 dprintk(DBGLVL_ENC,
131 "%s() type=V4L2_MPEG_STREAM_TYPE_MPEG2_PS\n",
132 __func__);
130 params->samplesperline = 128; 133 params->samplesperline = 128;
131 params->numberoflines = 256; 134 params->numberoflines = 256;
132 params->pitch = 128; 135 params->pitch = 128;
133 params->numpagetables = 2 + 136 params->numpagetables = 2 +
134 ((SAA7164_PS_NUMBER_OF_LINES * 128) / PAGE_SIZE); 137 ((SAA7164_PS_NUMBER_OF_LINES * 128) / PAGE_SIZE);
135 } else 138 } else
136 if (port->encoder_params.stream_type == V4L2_MPEG_STREAM_TYPE_MPEG2_TS) { 139 if (port->encoder_params.stream_type ==
137 dprintk(DBGLVL_ENC, "%s() type=V4L2_MPEG_STREAM_TYPE_MPEG2_TS\n", __func__); 140 V4L2_MPEG_STREAM_TYPE_MPEG2_TS) {
141 dprintk(DBGLVL_ENC,
142 "%s() type=V4L2_MPEG_STREAM_TYPE_MPEG2_TS\n",
143 __func__);
138 params->samplesperline = 188; 144 params->samplesperline = 188;
139 params->numberoflines = 312; 145 params->numberoflines = 312;
140 params->pitch = 188; 146 params->pitch = 188;
@@ -826,7 +832,8 @@ static int fill_queryctrl(struct saa7164_encoder_params *params,
826 return v4l2_ctrl_query_fill(c, 1, 255, 1, 15); 832 return v4l2_ctrl_query_fill(c, 1, 255, 1, 15);
827 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: 833 case V4L2_CID_MPEG_VIDEO_BITRATE_MODE:
828 return v4l2_ctrl_query_fill(c, 834 return v4l2_ctrl_query_fill(c,
829 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, 835 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR,
836 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR,
830 1, V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); 837 1, V4L2_MPEG_VIDEO_BITRATE_MODE_VBR);
831 case V4L2_CID_MPEG_VIDEO_B_FRAMES: 838 case V4L2_CID_MPEG_VIDEO_B_FRAMES:
832 return v4l2_ctrl_query_fill(c, 839 return v4l2_ctrl_query_fill(c,
@@ -1113,7 +1120,9 @@ struct saa7164_user_buffer *saa7164_enc_next_buf(struct saa7164_port *port)
1113 if (crc_checking) { 1120 if (crc_checking) {
1114 crc = crc32(0, ubuf->data, ubuf->actual_size); 1121 crc = crc32(0, ubuf->data, ubuf->actual_size);
1115 if (crc != ubuf->crc) { 1122 if (crc != ubuf->crc) {
1116 printk(KERN_ERR "%s() ubuf %p crc became invalid, was 0x%x became 0x%x\n", __func__, 1123 printk(KERN_ERR
1124 "%s() ubuf %p crc became invalid, was 0x%x became 0x%x\n",
1125 __func__,
1117 ubuf, ubuf->crc, crc); 1126 ubuf, ubuf->crc, crc);
1118 } 1127 }
1119 } 1128 }
@@ -1201,9 +1210,8 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
1201 buffer += cnt; 1210 buffer += cnt;
1202 ret += cnt; 1211 ret += cnt;
1203 1212
1204 if (ubuf->pos > ubuf->actual_size) { 1213 if (ubuf->pos > ubuf->actual_size)
1205 printk(KERN_ERR "read() pos > actual, huh?\n"); 1214 printk(KERN_ERR "read() pos > actual, huh?\n");
1206 }
1207 1215
1208 if (ubuf->pos == ubuf->actual_size) { 1216 if (ubuf->pos == ubuf->actual_size) {
1209 1217
@@ -1227,16 +1235,16 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
1227 } 1235 }
1228 } 1236 }
1229err: 1237err:
1230 if (!ret && !ubuf) { 1238 if (!ret && !ubuf)
1231 ret = -EAGAIN; 1239 ret = -EAGAIN;
1232 }
1233 1240
1234 return ret; 1241 return ret;
1235} 1242}
1236 1243
1237static unsigned int fops_poll(struct file *file, poll_table *wait) 1244static unsigned int fops_poll(struct file *file, poll_table *wait)
1238{ 1245{
1239 struct saa7164_encoder_fh *fh = (struct saa7164_encoder_fh *)file->private_data; 1246 struct saa7164_encoder_fh *fh =
1247 (struct saa7164_encoder_fh *)file->private_data;
1240 struct saa7164_port *port = fh->port; 1248 struct saa7164_port *port = fh->port;
1241 struct saa7164_user_buffer *ubuf; 1249 struct saa7164_user_buffer *ubuf;
1242 unsigned int mask = 0; 1250 unsigned int mask = 0;
@@ -1249,9 +1257,8 @@ static unsigned int fops_poll(struct file *file, poll_table *wait)
1249 saa7164_histogram_update(&port->poll_interval, 1257 saa7164_histogram_update(&port->poll_interval,
1250 port->last_poll_msecs_diff); 1258 port->last_poll_msecs_diff);
1251 1259
1252 if (!video_is_registered(port->v4l_device)) { 1260 if (!video_is_registered(port->v4l_device))
1253 return -EIO; 1261 return -EIO;
1254 }
1255 1262
1256 if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) { 1263 if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) {
1257 if (atomic_inc_return(&port->v4l_reader_count) == 1) { 1264 if (atomic_inc_return(&port->v4l_reader_count) == 1) {
diff --git a/drivers/media/video/saa7164/saa7164-fw.c b/drivers/media/video/saa7164/saa7164-fw.c
index 484533c32bb1..22b02323dca9 100644
--- a/drivers/media/video/saa7164/saa7164-fw.c
+++ b/drivers/media/video/saa7164/saa7164-fw.c
@@ -178,7 +178,7 @@ int saa7164_downloadimage(struct saa7164_dev *dev, u8 *src, u32 srcsize,
178 goto out; 178 goto out;
179 } 179 }
180 180
181 msleep(10); 181 msleep(10); /* Checkpatch throws a < 20ms warning */
182 if (timeout++ > 60) 182 if (timeout++ > 60)
183 break; 183 break;
184 } 184 }
@@ -235,7 +235,7 @@ int saa7164_downloadfirmware(struct saa7164_dev *dev)
235 while (err_flags != SAA_DEVICE_IMAGE_BOOTING) { 235 while (err_flags != SAA_DEVICE_IMAGE_BOOTING) {
236 dprintk(DBGLVL_FW, "%s() err_flags = %x\n", 236 dprintk(DBGLVL_FW, "%s() err_flags = %x\n",
237 __func__, err_flags); 237 __func__, err_flags);
238 msleep(10); 238 msleep(10); /* Checkpatch throws a < 20ms warning */
239 239
240 if (err_flags & SAA_DEVICE_IMAGE_CORRUPT) { 240 if (err_flags & SAA_DEVICE_IMAGE_CORRUPT) {
241 printk(KERN_ERR "%s() firmware corrupt\n", 241 printk(KERN_ERR "%s() firmware corrupt\n",
@@ -294,7 +294,7 @@ int saa7164_downloadfirmware(struct saa7164_dev *dev)
294 while (err_flags != SAA_DEVICE_IMAGE_BOOTING) { 294 while (err_flags != SAA_DEVICE_IMAGE_BOOTING) {
295 dprintk(DBGLVL_FW, "%s() err_flags2 = %x\n", 295 dprintk(DBGLVL_FW, "%s() err_flags2 = %x\n",
296 __func__, err_flags); 296 __func__, err_flags);
297 msleep(10); 297 msleep(10); /* Checkpatch throws a < 20ms warning */
298 298
299 if (err_flags & SAA_DEVICE_IMAGE_CORRUPT) { 299 if (err_flags & SAA_DEVICE_IMAGE_CORRUPT) {
300 printk(KERN_ERR 300 printk(KERN_ERR
@@ -365,7 +365,7 @@ int saa7164_downloadfirmware(struct saa7164_dev *dev)
365 365
366 first_timeout = SAA_DEVICE_TIMEOUT; 366 first_timeout = SAA_DEVICE_TIMEOUT;
367 while (first_timeout) { 367 while (first_timeout) {
368 msleep(10); 368 msleep(10); /* Checkpatch throws a < 20ms warning */
369 369
370 version = 370 version =
371 saa7164_getcurrentfirmwareversion(dev); 371 saa7164_getcurrentfirmwareversion(dev);
diff --git a/drivers/media/video/saa7164/saa7164-i2c.c b/drivers/media/video/saa7164/saa7164-i2c.c
index b5167d33650a..26148f76cba2 100644
--- a/drivers/media/video/saa7164/saa7164-i2c.c
+++ b/drivers/media/video/saa7164/saa7164-i2c.c
@@ -23,7 +23,7 @@
23#include <linux/moduleparam.h> 23#include <linux/moduleparam.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <asm/io.h> 26#include <linux/io.h>
27 27
28#include "saa7164.h" 28#include "saa7164.h"
29 29
@@ -65,7 +65,7 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
65 } 65 }
66 return num; 66 return num;
67 67
68 err: 68err:
69 return retval; 69 return retval;
70} 70}
71 71
diff --git a/drivers/media/video/saa7164/saa7164-vbi.c b/drivers/media/video/saa7164/saa7164-vbi.c
index 323c7cdca37b..8abbe6d661e4 100644
--- a/drivers/media/video/saa7164/saa7164-vbi.c
+++ b/drivers/media/video/saa7164/saa7164-vbi.c
@@ -51,11 +51,15 @@ static void saa7164_vbi_configure(struct saa7164_port *port)
51 /* Set up the DIF (enable it) for analog mode by default */ 51 /* Set up the DIF (enable it) for analog mode by default */
52 saa7164_api_initialize_dif(port); 52 saa7164_api_initialize_dif(port);
53 53
54// /* Configure the correct video standard */ 54 /* Configure the correct video standard */
55// saa7164_api_configure_dif(port, port->encodernorm.id); 55#if 0
56 saa7164_api_configure_dif(port, port->encodernorm.id);
57#endif
56 58
57// /* Ensure the audio decoder is correct configured */ 59#if 0
58// saa7164_api_set_audio_std(port); 60 /* Ensure the audio decoder is correct configured */
61 saa7164_api_set_audio_std(port);
62#endif
59 dprintk(DBGLVL_VBI, "%s() ends\n", __func__); 63 dprintk(DBGLVL_VBI, "%s() ends\n", __func__);
60} 64}
61 65
@@ -919,8 +923,10 @@ static int saa7164_vbi_start_streaming(struct saa7164_port *port)
919 saa7164_vbi_buffers_alloc(port); 923 saa7164_vbi_buffers_alloc(port);
920 924
921 /* Configure the encoder with any cache values */ 925 /* Configure the encoder with any cache values */
922// saa7164_api_set_encoder(port); 926#if 0
923// saa7164_api_get_encoder(port); 927 saa7164_api_set_encoder(port);
928 saa7164_api_get_encoder(port);
929#endif
924 930
925 /* Place the empty buffers on the hardware */ 931 /* Place the empty buffers on the hardware */
926 saa7164_buffer_cfg_port(port); 932 saa7164_buffer_cfg_port(port);
@@ -1060,7 +1066,8 @@ struct saa7164_user_buffer *saa7164_vbi_next_buf(struct saa7164_port *port)
1060 if (crc_checking) { 1066 if (crc_checking) {
1061 crc = crc32(0, ubuf->data, ubuf->actual_size); 1067 crc = crc32(0, ubuf->data, ubuf->actual_size);
1062 if (crc != ubuf->crc) { 1068 if (crc != ubuf->crc) {
1063 printk(KERN_ERR "%s() ubuf %p crc became invalid, was 0x%x became 0x%x\n", __func__, 1069 printk(KERN_ERR "%s() ubuf %p crc became invalid, was 0x%x became 0x%x\n",
1070 __func__,
1064 ubuf, ubuf->crc, crc); 1071 ubuf, ubuf->crc, crc);
1065 } 1072 }
1066 } 1073 }
@@ -1148,9 +1155,8 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
1148 buffer += cnt; 1155 buffer += cnt;
1149 ret += cnt; 1156 ret += cnt;
1150 1157
1151 if (ubuf->pos > ubuf->actual_size) { 1158 if (ubuf->pos > ubuf->actual_size)
1152 printk(KERN_ERR "read() pos > actual, huh?\n"); 1159 printk(KERN_ERR "read() pos > actual, huh?\n");
1153 }
1154 1160
1155 if (ubuf->pos == ubuf->actual_size) { 1161 if (ubuf->pos == ubuf->actual_size) {
1156 1162
@@ -1197,9 +1203,8 @@ static unsigned int fops_poll(struct file *file, poll_table *wait)
1197 saa7164_histogram_update(&port->poll_interval, 1203 saa7164_histogram_update(&port->poll_interval,
1198 port->last_poll_msecs_diff); 1204 port->last_poll_msecs_diff);
1199 1205
1200 if (!video_is_registered(port->v4l_device)) { 1206 if (!video_is_registered(port->v4l_device))
1201 return -EIO; 1207 return -EIO;
1202 }
1203 1208
1204 if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) { 1209 if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) {
1205 if (atomic_inc_return(&port->v4l_reader_count) == 1) { 1210 if (atomic_inc_return(&port->v4l_reader_count) == 1) {
@@ -1257,10 +1262,14 @@ static const struct v4l2_ioctl_ops vbi_ioctl_ops = {
1257 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls, 1262 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls,
1258 .vidioc_log_status = vidioc_log_status, 1263 .vidioc_log_status = vidioc_log_status,
1259 .vidioc_queryctrl = vidioc_queryctrl, 1264 .vidioc_queryctrl = vidioc_queryctrl,
1260// .vidioc_g_chip_ident = saa7164_g_chip_ident, 1265#if 0
1266 .vidioc_g_chip_ident = saa7164_g_chip_ident,
1267#endif
1261#ifdef CONFIG_VIDEO_ADV_DEBUG 1268#ifdef CONFIG_VIDEO_ADV_DEBUG
1262// .vidioc_g_register = saa7164_g_register, 1269#if 0
1263// .vidioc_s_register = saa7164_s_register, 1270 .vidioc_g_register = saa7164_g_register,
1271 .vidioc_s_register = saa7164_s_register,
1272#endif
1264#endif 1273#endif
1265 .vidioc_g_fmt_vbi_cap = saa7164_vbi_fmt, 1274 .vidioc_g_fmt_vbi_cap = saa7164_vbi_fmt,
1266 .vidioc_try_fmt_vbi_cap = saa7164_vbi_fmt, 1275 .vidioc_try_fmt_vbi_cap = saa7164_vbi_fmt,
diff --git a/drivers/media/video/saa7164/saa7164.h b/drivers/media/video/saa7164/saa7164.h
index 74df9c627a96..16745d2fb349 100644
--- a/drivers/media/video/saa7164/saa7164.h
+++ b/drivers/media/video/saa7164/saa7164.h
@@ -113,7 +113,8 @@
113#define DBGLVL_THR 4096 113#define DBGLVL_THR 4096
114#define DBGLVL_CPU 8192 114#define DBGLVL_CPU 8192
115 115
116#define SAA7164_NORMS (V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443) 116#define SAA7164_NORMS \
117 (V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_JP | V4L2_STD_NTSC_443)
117 118
118enum port_t { 119enum port_t {
119 SAA7164_MPEG_UNDEFINED = 0, 120 SAA7164_MPEG_UNDEFINED = 0,
@@ -182,15 +183,11 @@ struct saa7164_subid {
182 183
183struct saa7164_encoder_fh { 184struct saa7164_encoder_fh {
184 struct saa7164_port *port; 185 struct saa7164_port *port;
185// u32 freq;
186// u32 tuner_type;
187 atomic_t v4l_reading; 186 atomic_t v4l_reading;
188}; 187};
189 188
190struct saa7164_vbi_fh { 189struct saa7164_vbi_fh {
191 struct saa7164_port *port; 190 struct saa7164_port *port;
192// u32 freq;
193// u32 tuner_type;
194 atomic_t v4l_reading; 191 atomic_t v4l_reading;
195}; 192};
196 193
@@ -265,8 +262,6 @@ struct saa7164_ctrl {
265struct saa7164_tvnorm { 262struct saa7164_tvnorm {
266 char *name; 263 char *name;
267 v4l2_std_id id; 264 v4l2_std_id id;
268// u32 cxiformat;
269// u32 cxoformat;
270}; 265};
271 266
272struct saa7164_encoder_params { 267struct saa7164_encoder_params {
@@ -510,7 +505,8 @@ extern void saa7164_call_i2c_clients(struct saa7164_i2c *bus,
510/* saa7164-bus.c */ 505/* saa7164-bus.c */
511int saa7164_bus_setup(struct saa7164_dev *dev); 506int saa7164_bus_setup(struct saa7164_dev *dev);
512void saa7164_bus_dump(struct saa7164_dev *dev); 507void saa7164_bus_dump(struct saa7164_dev *dev);
513int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg, void *buf); 508int saa7164_bus_set(struct saa7164_dev *dev, struct tmComResInfo* msg,
509 void *buf);
514int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg, 510int saa7164_bus_get(struct saa7164_dev *dev, struct tmComResInfo* msg,
515 void *buf, int peekonly); 511 void *buf, int peekonly);
516 512
@@ -552,7 +548,8 @@ int saa7164_api_get_videomux(struct saa7164_port *port);
552int saa7164_api_set_vbi_format(struct saa7164_port *port); 548int saa7164_api_set_vbi_format(struct saa7164_port *port);
553int saa7164_api_set_debug(struct saa7164_dev *dev, u8 level); 549int saa7164_api_set_debug(struct saa7164_dev *dev, u8 level);
554int saa7164_api_collect_debug(struct saa7164_dev *dev); 550int saa7164_api_collect_debug(struct saa7164_dev *dev);
555int saa7164_api_get_load_info(struct saa7164_dev *dev, struct tmFwInfoStruct *i); 551int saa7164_api_get_load_info(struct saa7164_dev *dev,
552 struct tmFwInfoStruct *i);
556 553
557/* ----------------------------------------------------------- */ 554/* ----------------------------------------------------------- */
558/* saa7164-cards.c */ 555/* saa7164-cards.c */