aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa7134')
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c111
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c44
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c12
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c29
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c32
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c28
-rw-r--r--drivers/media/video/saa7134/saa7134.h7
7 files changed, 105 insertions, 158 deletions
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index 57f1f5d409e0..002e70a33a4f 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -71,7 +71,6 @@ static const struct v4l2_format v4l2_format_table[] =
71 71
72struct saa6752hs_state { 72struct saa6752hs_state {
73 struct i2c_client client; 73 struct i2c_client client;
74 struct v4l2_mpeg_compression old_params;
75 struct saa6752hs_mpeg_params params; 74 struct saa6752hs_mpeg_params params;
76 enum saa6752hs_videoformat video_format; 75 enum saa6752hs_videoformat video_format;
77 v4l2_std_id standard; 76 v4l2_std_id standard;
@@ -161,35 +160,6 @@ static struct saa6752hs_mpeg_params param_defaults =
161 .au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K, 160 .au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K,
162}; 161};
163 162
164static struct v4l2_mpeg_compression old_param_defaults =
165{
166 .st_type = V4L2_MPEG_TS_2,
167 .st_bitrate = {
168 .mode = V4L2_BITRATE_CBR,
169 .target = 7000,
170 },
171
172 .ts_pid_pmt = 16,
173 .ts_pid_video = 260,
174 .ts_pid_audio = 256,
175 .ts_pid_pcr = 259,
176
177 .vi_type = V4L2_MPEG_VI_2,
178 .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3,
179 .vi_bitrate = {
180 .mode = V4L2_BITRATE_VBR,
181 .target = 4000,
182 .max = 6000,
183 },
184
185 .au_type = V4L2_MPEG_AU_2_II,
186 .au_bitrate = {
187 .mode = V4L2_BITRATE_CBR,
188 .target = 256,
189 },
190
191};
192
193/* ---------------------------------------------------------------------- */ 163/* ---------------------------------------------------------------------- */
194 164
195static int saa6752hs_chip_command(struct i2c_client* client, 165static int saa6752hs_chip_command(struct i2c_client* client,
@@ -362,74 +332,6 @@ static void saa6752hs_set_subsampling(struct i2c_client* client,
362} 332}
363 333
364 334
365static void saa6752hs_old_set_params(struct i2c_client* client,
366 struct v4l2_mpeg_compression* params)
367{
368 struct saa6752hs_state *h = i2c_get_clientdata(client);
369
370 /* check PIDs */
371 if (params->ts_pid_pmt <= MPEG_PID_MAX) {
372 h->old_params.ts_pid_pmt = params->ts_pid_pmt;
373 h->params.ts_pid_pmt = params->ts_pid_pmt;
374 }
375 if (params->ts_pid_pcr <= MPEG_PID_MAX) {
376 h->old_params.ts_pid_pcr = params->ts_pid_pcr;
377 h->params.ts_pid_pcr = params->ts_pid_pcr;
378 }
379 if (params->ts_pid_video <= MPEG_PID_MAX) {
380 h->old_params.ts_pid_video = params->ts_pid_video;
381 h->params.ts_pid_video = params->ts_pid_video;
382 }
383 if (params->ts_pid_audio <= MPEG_PID_MAX) {
384 h->old_params.ts_pid_audio = params->ts_pid_audio;
385 h->params.ts_pid_audio = params->ts_pid_audio;
386 }
387
388 /* check bitrate parameters */
389 if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) ||
390 (params->vi_bitrate.mode == V4L2_BITRATE_VBR)) {
391 h->old_params.vi_bitrate.mode = params->vi_bitrate.mode;
392 h->params.vi_bitrate_mode = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ?
393 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR : V4L2_MPEG_VIDEO_BITRATE_MODE_CBR;
394 }
395 if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
396 h->old_params.st_bitrate.target = params->st_bitrate.target;
397 if (params->vi_bitrate.mode != V4L2_BITRATE_NONE)
398 h->old_params.vi_bitrate.target = params->vi_bitrate.target;
399 if (params->vi_bitrate.mode == V4L2_BITRATE_VBR)
400 h->old_params.vi_bitrate.max = params->vi_bitrate.max;
401 if (params->au_bitrate.mode != V4L2_BITRATE_NONE)
402 h->old_params.au_bitrate.target = params->au_bitrate.target;
403
404 /* aspect ratio */
405 if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3 ||
406 params->vi_aspect_ratio == V4L2_MPEG_ASPECT_16_9) {
407 h->old_params.vi_aspect_ratio = params->vi_aspect_ratio;
408 if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3)
409 h->params.vi_aspect = V4L2_MPEG_VIDEO_ASPECT_4x3;
410 else
411 h->params.vi_aspect = V4L2_MPEG_VIDEO_ASPECT_16x9;
412 }
413
414 /* range checks */
415 if (h->old_params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX)
416 h->old_params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX;
417 if (h->old_params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX)
418 h->old_params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX;
419 if (h->old_params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX)
420 h->old_params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX;
421 h->params.vi_bitrate = params->vi_bitrate.target;
422 h->params.vi_bitrate_peak = params->vi_bitrate.max;
423 if (h->old_params.au_bitrate.target <= 256) {
424 h->old_params.au_bitrate.target = 256;
425 h->params.au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K;
426 }
427 else {
428 h->old_params.au_bitrate.target = 384;
429 h->params.au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_384K;
430 }
431}
432
433static int handle_ctrl(struct saa6752hs_mpeg_params *params, 335static int handle_ctrl(struct saa6752hs_mpeg_params *params,
434 struct v4l2_ext_control *ctrl, unsigned int cmd) 336 struct v4l2_ext_control *ctrl, unsigned int cmd)
435{ 337{
@@ -697,7 +599,6 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
697 return -ENOMEM; 599 return -ENOMEM;
698 h->client = client_template; 600 h->client = client_template;
699 h->params = param_defaults; 601 h->params = param_defaults;
700 h->old_params = old_param_defaults;
701 h->client.adapter = adap; 602 h->client.adapter = adap;
702 h->client.addr = addr; 603 h->client.addr = addr;
703 604
@@ -734,23 +635,11 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
734{ 635{
735 struct saa6752hs_state *h = i2c_get_clientdata(client); 636 struct saa6752hs_state *h = i2c_get_clientdata(client);
736 struct v4l2_ext_controls *ctrls = arg; 637 struct v4l2_ext_controls *ctrls = arg;
737 struct v4l2_mpeg_compression *old_params = arg;
738 struct saa6752hs_mpeg_params params; 638 struct saa6752hs_mpeg_params params;
739 int err = 0; 639 int err = 0;
740 int i; 640 int i;
741 641
742 switch (cmd) { 642 switch (cmd) {
743 case VIDIOC_S_MPEGCOMP:
744 if (NULL == old_params) {
745 /* apply settings and start encoder */
746 saa6752hs_init(client);
747 break;
748 }
749 saa6752hs_old_set_params(client, old_params);
750 /* fall through */
751 case VIDIOC_G_MPEGCOMP:
752 *old_params = h->old_params;
753 break;
754 case VIDIOC_S_EXT_CTRLS: 643 case VIDIOC_S_EXT_CTRLS:
755 if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) 644 if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
756 return -EINVAL; 645 return -EINVAL;
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 1a4a24471f20..a499eea379e6 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -429,7 +429,7 @@ int saa7134_set_dmabits(struct saa7134_dev *dev)
429 429
430 assert_spin_locked(&dev->slock); 430 assert_spin_locked(&dev->slock);
431 431
432 if (dev->inresume) 432 if (dev->insuspend)
433 return 0; 433 return 0;
434 434
435 /* video capture -- dma 0 + video task A */ 435 /* video capture -- dma 0 + video task A */
@@ -563,6 +563,9 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id)
563 unsigned long report,status; 563 unsigned long report,status;
564 int loop, handled = 0; 564 int loop, handled = 0;
565 565
566 if (dev->insuspend)
567 goto out;
568
566 for (loop = 0; loop < 10; loop++) { 569 for (loop = 0; loop < 10; loop++) {
567 report = saa_readl(SAA7134_IRQ_REPORT); 570 report = saa_readl(SAA7134_IRQ_REPORT);
568 status = saa_readl(SAA7134_IRQ_STATUS); 571 status = saa_readl(SAA7134_IRQ_STATUS);
@@ -1163,6 +1166,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1163 kfree(dev); 1166 kfree(dev);
1164} 1167}
1165 1168
1169#ifdef CONFIG_PM
1166static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) 1170static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
1167{ 1171{
1168 1172
@@ -1176,6 +1180,19 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
1176 saa_writel(SAA7134_IRQ2, 0); 1180 saa_writel(SAA7134_IRQ2, 0);
1177 saa_writel(SAA7134_MAIN_CTRL, 0); 1181 saa_writel(SAA7134_MAIN_CTRL, 0);
1178 1182
1183 synchronize_irq(pci_dev->irq);
1184 dev->insuspend = 1;
1185
1186 /* Disable timeout timers - if we have active buffers, we will
1187 fill them on resume*/
1188
1189 del_timer(&dev->video_q.timeout);
1190 del_timer(&dev->vbi_q.timeout);
1191 del_timer(&dev->ts_q.timeout);
1192
1193 if (dev->remote)
1194 saa7134_ir_stop(dev);
1195
1179 pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); 1196 pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
1180 pci_save_state(pci_dev); 1197 pci_save_state(pci_dev);
1181 1198
@@ -1194,24 +1211,27 @@ static int saa7134_resume(struct pci_dev *pci_dev)
1194 /* Do things that are done in saa7134_initdev , 1211 /* Do things that are done in saa7134_initdev ,
1195 except of initializing memory structures.*/ 1212 except of initializing memory structures.*/
1196 1213
1197 dev->inresume = 1;
1198 saa7134_board_init1(dev); 1214 saa7134_board_init1(dev);
1199 1215
1216 /* saa7134_hwinit1 */
1200 if (saa7134_boards[dev->board].video_out) 1217 if (saa7134_boards[dev->board].video_out)
1201 saa7134_videoport_init(dev); 1218 saa7134_videoport_init(dev);
1202
1203 if (card_has_mpeg(dev)) 1219 if (card_has_mpeg(dev))
1204 saa7134_ts_init_hw(dev); 1220 saa7134_ts_init_hw(dev);
1205 1221 if (dev->remote)
1222 saa7134_ir_start(dev, dev->remote);
1206 saa7134_hw_enable1(dev); 1223 saa7134_hw_enable1(dev);
1207 saa7134_set_decoder(dev); 1224
1208 saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); 1225
1209 saa7134_board_init2(dev); 1226 saa7134_board_init2(dev);
1210 saa7134_hw_enable2(dev);
1211 1227
1228 /*saa7134_hwinit2*/
1229 saa7134_set_tvnorm_hw(dev);
1212 saa7134_tvaudio_setmute(dev); 1230 saa7134_tvaudio_setmute(dev);
1213 saa7134_tvaudio_setvolume(dev, dev->ctl_volume); 1231 saa7134_tvaudio_setvolume(dev, dev->ctl_volume);
1232 saa7134_tvaudio_do_scan(dev);
1214 saa7134_enable_i2s(dev); 1233 saa7134_enable_i2s(dev);
1234 saa7134_hw_enable2(dev);
1215 1235
1216 /*resume unfinished buffer(s)*/ 1236 /*resume unfinished buffer(s)*/
1217 spin_lock_irqsave(&dev->slock, flags); 1237 spin_lock_irqsave(&dev->slock, flags);
@@ -1219,13 +1239,19 @@ static int saa7134_resume(struct pci_dev *pci_dev)
1219 saa7134_buffer_requeue(dev, &dev->vbi_q); 1239 saa7134_buffer_requeue(dev, &dev->vbi_q);
1220 saa7134_buffer_requeue(dev, &dev->ts_q); 1240 saa7134_buffer_requeue(dev, &dev->ts_q);
1221 1241
1242 /* FIXME: Disable DMA audio sound - temporary till proper support
1243 is implemented*/
1244
1245 dev->dmasound.dma_running = 0;
1246
1222 /* start DMA now*/ 1247 /* start DMA now*/
1223 dev->inresume = 0; 1248 dev->insuspend = 0;
1224 saa7134_set_dmabits(dev); 1249 saa7134_set_dmabits(dev);
1225 spin_unlock_irqrestore(&dev->slock, flags); 1250 spin_unlock_irqrestore(&dev->slock, flags);
1226 1251
1227 return 0; 1252 return 0;
1228} 1253}
1254#endif
1229 1255
1230/* ----------------------------------------------------------- */ 1256/* ----------------------------------------------------------- */
1231 1257
@@ -1262,8 +1288,10 @@ static struct pci_driver saa7134_pci_driver = {
1262 .id_table = saa7134_pci_tbl, 1288 .id_table = saa7134_pci_tbl,
1263 .probe = saa7134_initdev, 1289 .probe = saa7134_initdev,
1264 .remove = __devexit_p(saa7134_finidev), 1290 .remove = __devexit_p(saa7134_finidev),
1291#ifdef CONFIG_PM
1265 .suspend = saa7134_suspend, 1292 .suspend = saa7134_suspend,
1266 .resume = saa7134_resume 1293 .resume = saa7134_resume
1294#endif
1267}; 1295};
1268 1296
1269static int saa7134_init(void) 1297static int saa7134_init(void)
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 34ca874dd7fe..75d0c5bf46d2 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -284,17 +284,6 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
284 case VIDIOC_S_CTRL: 284 case VIDIOC_S_CTRL:
285 return saa7134_common_ioctl(dev, cmd, arg); 285 return saa7134_common_ioctl(dev, cmd, arg);
286 286
287 case VIDIOC_S_MPEGCOMP:
288 printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. "
289 "Replace with VIDIOC_S_EXT_CTRLS!");
290 saa7134_i2c_call_clients(dev, VIDIOC_S_MPEGCOMP, arg);
291 ts_init_encoder(dev);
292 return 0;
293 case VIDIOC_G_MPEGCOMP:
294 printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. "
295 "Replace with VIDIOC_G_EXT_CTRLS!");
296 saa7134_i2c_call_clients(dev, VIDIOC_G_MPEGCOMP, arg);
297 return 0;
298 case VIDIOC_S_EXT_CTRLS: 287 case VIDIOC_S_EXT_CTRLS:
299 /* count == 0 is abused in saa6752hs.c, so that special 288 /* count == 0 is abused in saa6752hs.c, so that special
300 case is handled here explicitly. */ 289 case is handled here explicitly. */
@@ -342,7 +331,6 @@ static struct video_device saa7134_empress_template =
342 .name = "saa7134-empress", 331 .name = "saa7134-empress",
343 .type = 0 /* FIXME */, 332 .type = 0 /* FIXME */,
344 .type2 = 0 /* FIXME */, 333 .type2 = 0 /* FIXME */,
345 .hardware = 0,
346 .fops = &ts_fops, 334 .fops = &ts_fops,
347 .minor = -1, 335 .minor = -1,
348}; 336};
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 80d2644f765a..3abaa1b8ac9d 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -44,6 +44,14 @@ module_param(ir_rc5_remote_gap, int, 0644);
44static int ir_rc5_key_timeout = 115; 44static int ir_rc5_key_timeout = 115;
45module_param(ir_rc5_key_timeout, int, 0644); 45module_param(ir_rc5_key_timeout, int, 0644);
46 46
47static int repeat_delay = 500;
48module_param(repeat_delay, int, 0644);
49MODULE_PARM_DESC(repeat_delay, "delay before key repeat started");
50static int repeat_period = 33;
51module_param(repeat_period, int, 0644);
52MODULE_PARM_DESC(repeat_period, "repeat period between"
53 "keypresses when key is down");
54
47#define dprintk(fmt, arg...) if (ir_debug) \ 55#define dprintk(fmt, arg...) if (ir_debug) \
48 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) 56 printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
49#define i2cdprintk(fmt, arg...) if (ir_debug) \ 57#define i2cdprintk(fmt, arg...) if (ir_debug) \
@@ -59,6 +67,13 @@ static int build_key(struct saa7134_dev *dev)
59 struct card_ir *ir = dev->remote; 67 struct card_ir *ir = dev->remote;
60 u32 gpio, data; 68 u32 gpio, data;
61 69
70 /* here comes the additional handshake steps for some cards */
71 switch (dev->board) {
72 case SAA7134_BOARD_GOTVIEW_7135:
73 saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80);
74 saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80);
75 break;
76 }
62 /* rising SAA7134_GPIO_GPRESCAN reads the status */ 77 /* rising SAA7134_GPIO_GPRESCAN reads the status */
63 saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); 78 saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
64 saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); 79 saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
@@ -159,7 +174,7 @@ static void saa7134_input_timer(unsigned long data)
159 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); 174 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
160} 175}
161 176
162static void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) 177void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
163{ 178{
164 if (ir->polling) { 179 if (ir->polling) {
165 setup_timer(&ir->timer, saa7134_input_timer, 180 setup_timer(&ir->timer, saa7134_input_timer,
@@ -182,7 +197,7 @@ static void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
182 } 197 }
183} 198}
184 199
185static void saa7134_ir_stop(struct saa7134_dev *dev) 200void saa7134_ir_stop(struct saa7134_dev *dev)
186{ 201{
187 if (dev->remote->polling) 202 if (dev->remote->polling)
188 del_timer_sync(&dev->remote->timer); 203 del_timer_sync(&dev->remote->timer);
@@ -285,10 +300,10 @@ int saa7134_input_init1(struct saa7134_dev *dev)
285 break; 300 break;
286 case SAA7134_BOARD_GOTVIEW_7135: 301 case SAA7134_BOARD_GOTVIEW_7135:
287 ir_codes = ir_codes_gotview7135; 302 ir_codes = ir_codes_gotview7135;
288 mask_keycode = 0x0003EC; 303 mask_keycode = 0x0003CC;
289 mask_keyup = 0x008000;
290 mask_keydown = 0x000010; 304 mask_keydown = 0x000010;
291 polling = 50; // ms 305 polling = 5; /* ms */
306 saa_setb(SAA7134_GPIO_GPMODE1, 0x80);
292 break; 307 break;
293 case SAA7134_BOARD_VIDEOMATE_TV_PVR: 308 case SAA7134_BOARD_VIDEOMATE_TV_PVR:
294 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: 309 case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
@@ -386,6 +401,10 @@ int saa7134_input_init1(struct saa7134_dev *dev)
386 if (err) 401 if (err)
387 goto err_out_stop; 402 goto err_out_stop;
388 403
404 /* the remote isn't as bouncy as a keyboard */
405 ir->dev->rep[REP_DELAY] = repeat_delay;
406 ir->dev->rep[REP_PERIOD] = repeat_period;
407
389 return 0; 408 return 0;
390 409
391 err_out_stop: 410 err_out_stop:
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index 1b9e39a5ea47..f8e304c76232 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -27,6 +27,7 @@
27#include <linux/kthread.h> 27#include <linux/kthread.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/freezer.h>
30#include <asm/div64.h> 31#include <asm/div64.h>
31 32
32#include "saa7134-reg.h" 33#include "saa7134-reg.h"
@@ -231,7 +232,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
231 } 232 }
232 233
233 if (dev->hw_mute == mute && 234 if (dev->hw_mute == mute &&
234 dev->hw_input == in && !dev->inresume) { 235 dev->hw_input == in && !dev->insuspend) {
235 dprintk("mute/input: nothing to do [mute=%d,input=%s]\n", 236 dprintk("mute/input: nothing to do [mute=%d,input=%s]\n",
236 mute,in->name); 237 mute,in->name);
237 return; 238 return;
@@ -502,13 +503,17 @@ static int tvaudio_thread(void *data)
502 unsigned int i, audio, nscan; 503 unsigned int i, audio, nscan;
503 int max1,max2,carrier,rx,mode,lastmode,default_carrier; 504 int max1,max2,carrier,rx,mode,lastmode,default_carrier;
504 505
505 allow_signal(SIGTERM); 506
507 set_freezable();
508
506 for (;;) { 509 for (;;) {
507 tvaudio_sleep(dev,-1); 510 tvaudio_sleep(dev,-1);
508 if (kthread_should_stop() || signal_pending(current)) 511 if (kthread_should_stop())
509 goto done; 512 goto done;
510 513
511 restart: 514 restart:
515 try_to_freeze();
516
512 dev->thread.scan1 = dev->thread.scan2; 517 dev->thread.scan1 = dev->thread.scan2;
513 dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); 518 dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1);
514 dev->tvaudio = NULL; 519 dev->tvaudio = NULL;
@@ -612,9 +617,12 @@ static int tvaudio_thread(void *data)
612 617
613 lastmode = 42; 618 lastmode = 42;
614 for (;;) { 619 for (;;) {
620
621 try_to_freeze();
622
615 if (tvaudio_sleep(dev,5000)) 623 if (tvaudio_sleep(dev,5000))
616 goto restart; 624 goto restart;
617 if (kthread_should_stop() || signal_pending(current)) 625 if (kthread_should_stop())
618 break; 626 break;
619 if (UNSET == dev->thread.mode) { 627 if (UNSET == dev->thread.mode) {
620 rx = tvaudio_getstereo(dev,&tvaudio[i]); 628 rx = tvaudio_getstereo(dev,&tvaudio[i]);
@@ -630,6 +638,7 @@ static int tvaudio_thread(void *data)
630 } 638 }
631 639
632 done: 640 done:
641 dev->thread.stopped = 1;
633 return 0; 642 return 0;
634} 643}
635 644
@@ -777,7 +786,8 @@ static int tvaudio_thread_ddep(void *data)
777 struct saa7134_dev *dev = data; 786 struct saa7134_dev *dev = data;
778 u32 value, norms, clock; 787 u32 value, norms, clock;
779 788
780 allow_signal(SIGTERM); 789
790 set_freezable();
781 791
782 clock = saa7134_boards[dev->board].audio_clock; 792 clock = saa7134_boards[dev->board].audio_clock;
783 if (UNSET != audio_clock_override) 793 if (UNSET != audio_clock_override)
@@ -790,10 +800,13 @@ static int tvaudio_thread_ddep(void *data)
790 800
791 for (;;) { 801 for (;;) {
792 tvaudio_sleep(dev,-1); 802 tvaudio_sleep(dev,-1);
793 if (kthread_should_stop() || signal_pending(current)) 803 if (kthread_should_stop())
794 goto done; 804 goto done;
795 805
796 restart: 806 restart:
807
808 try_to_freeze();
809
797 dev->thread.scan1 = dev->thread.scan2; 810 dev->thread.scan1 = dev->thread.scan2;
798 dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); 811 dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1);
799 812
@@ -870,6 +883,7 @@ static int tvaudio_thread_ddep(void *data)
870 } 883 }
871 884
872 done: 885 done:
886 dev->thread.stopped = 1;
873 return 0; 887 return 0;
874} 888}
875 889
@@ -997,7 +1011,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev)
997int saa7134_tvaudio_fini(struct saa7134_dev *dev) 1011int saa7134_tvaudio_fini(struct saa7134_dev *dev)
998{ 1012{
999 /* shutdown tvaudio thread */ 1013 /* shutdown tvaudio thread */
1000 if (dev->thread.thread) 1014 if (dev->thread.thread && !dev->thread.stopped)
1001 kthread_stop(dev->thread.thread); 1015 kthread_stop(dev->thread.thread);
1002 1016
1003 saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ 1017 saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */
@@ -1013,7 +1027,9 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev)
1013 } else if (dev->thread.thread) { 1027 } else if (dev->thread.thread) {
1014 dev->thread.mode = UNSET; 1028 dev->thread.mode = UNSET;
1015 dev->thread.scan2++; 1029 dev->thread.scan2++;
1016 wake_up_process(dev->thread.thread); 1030
1031 if (!dev->insuspend && !dev->thread.stopped)
1032 wake_up_process(dev->thread.thread);
1017 } else { 1033 } else {
1018 dev->automute = 0; 1034 dev->automute = 0;
1019 saa7134_tvaudio_setmute(dev); 1035 saa7134_tvaudio_setmute(dev);
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 471b92793c12..3b9ffb4b648a 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -560,15 +560,8 @@ void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
560 560
561 dev->crop_current = dev->crop_defrect; 561 dev->crop_current = dev->crop_defrect;
562 562
563 saa7134_set_decoder(dev); 563 saa7134_set_tvnorm_hw(dev);
564 564
565 if (card_in(dev, dev->ctl_input).tv) {
566 if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290)
567 && ((card(dev).tuner_config == 1)
568 || (card(dev).tuner_config == 2)))
569 saa7134_set_gpio(dev, 22, 5);
570 saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &norm->id);
571 }
572} 565}
573 566
574static void video_mux(struct saa7134_dev *dev, int input) 567static void video_mux(struct saa7134_dev *dev, int input)
@@ -579,7 +572,8 @@ static void video_mux(struct saa7134_dev *dev, int input)
579 saa7134_tvaudio_setinput(dev, &card_in(dev, input)); 572 saa7134_tvaudio_setinput(dev, &card_in(dev, input));
580} 573}
581 574
582void saa7134_set_decoder(struct saa7134_dev *dev) 575
576static void saa7134_set_decoder(struct saa7134_dev *dev)
583{ 577{
584 int luma_control, sync_control, mux; 578 int luma_control, sync_control, mux;
585 579
@@ -630,6 +624,19 @@ void saa7134_set_decoder(struct saa7134_dev *dev)
630 saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); 624 saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80);
631} 625}
632 626
627void saa7134_set_tvnorm_hw(struct saa7134_dev *dev)
628{
629 saa7134_set_decoder(dev);
630
631 if (card_in(dev, dev->ctl_input).tv) {
632 if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290)
633 && ((card(dev).tuner_config == 1)
634 || (card(dev).tuner_config == 2)))
635 saa7134_set_gpio(dev, 22, 5);
636 saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id);
637 }
638}
639
633static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) 640static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale)
634{ 641{
635 static const struct { 642 static const struct {
@@ -2352,7 +2359,6 @@ struct video_device saa7134_video_template =
2352 .name = "saa7134-video", 2359 .name = "saa7134-video",
2353 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER| 2360 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|
2354 VID_TYPE_CLIPPING|VID_TYPE_SCALES, 2361 VID_TYPE_CLIPPING|VID_TYPE_SCALES,
2355 .hardware = 0,
2356 .fops = &video_fops, 2362 .fops = &video_fops,
2357 .minor = -1, 2363 .minor = -1,
2358}; 2364};
@@ -2361,7 +2367,6 @@ struct video_device saa7134_vbi_template =
2361{ 2367{
2362 .name = "saa7134-vbi", 2368 .name = "saa7134-vbi",
2363 .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT, 2369 .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT,
2364 .hardware = 0,
2365 .fops = &video_fops, 2370 .fops = &video_fops,
2366 .minor = -1, 2371 .minor = -1,
2367}; 2372};
@@ -2370,7 +2375,6 @@ struct video_device saa7134_radio_template =
2370{ 2375{
2371 .name = "saa7134-radio", 2376 .name = "saa7134-radio",
2372 .type = VID_TYPE_TUNER, 2377 .type = VID_TYPE_TUNER,
2373 .hardware = 0,
2374 .fops = &radio_fops, 2378 .fops = &radio_fops,
2375 .minor = -1, 2379 .minor = -1,
2376}; 2380};
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 28ec6804bd5d..66a390c321a7 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -333,6 +333,7 @@ struct saa7134_thread {
333 unsigned int scan1; 333 unsigned int scan1;
334 unsigned int scan2; 334 unsigned int scan2;
335 unsigned int mode; 335 unsigned int mode;
336 unsigned int stopped;
336}; 337};
337 338
338/* buffer for one video/vbi/ts frame */ 339/* buffer for one video/vbi/ts frame */
@@ -524,7 +525,7 @@ struct saa7134_dev {
524 unsigned int hw_mute; 525 unsigned int hw_mute;
525 int last_carrier; 526 int last_carrier;
526 int nosignal; 527 int nosignal;
527 unsigned int inresume; 528 unsigned int insuspend;
528 529
529 /* SAA7134_MPEG_* */ 530 /* SAA7134_MPEG_* */
530 struct saa7134_ts ts; 531 struct saa7134_ts ts;
@@ -632,7 +633,7 @@ extern struct video_device saa7134_radio_template;
632 633
633void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm); 634void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm);
634int saa7134_videoport_init(struct saa7134_dev *dev); 635int saa7134_videoport_init(struct saa7134_dev *dev);
635void saa7134_set_decoder(struct saa7134_dev *dev); 636void saa7134_set_tvnorm_hw(struct saa7134_dev *dev);
636 637
637int saa7134_common_ioctl(struct saa7134_dev *dev, 638int saa7134_common_ioctl(struct saa7134_dev *dev,
638 unsigned int cmd, void *arg); 639 unsigned int cmd, void *arg);
@@ -706,6 +707,8 @@ int saa7134_input_init1(struct saa7134_dev *dev);
706void saa7134_input_fini(struct saa7134_dev *dev); 707void saa7134_input_fini(struct saa7134_dev *dev);
707void saa7134_input_irq(struct saa7134_dev *dev); 708void saa7134_input_irq(struct saa7134_dev *dev);
708void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); 709void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir);
710void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir);
711void saa7134_ir_stop(struct saa7134_dev *dev);
709 712
710 713
711/* 714/*