diff options
Diffstat (limited to 'drivers/media/video/saa7134')
-rw-r--r-- | drivers/media/video/saa7134/saa6752hs.c | 111 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-core.c | 44 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-empress.c | 12 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-input.c | 29 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-tvaudio.c | 32 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-video.c | 28 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 7 |
7 files changed, 105 insertions, 158 deletions
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 57f1f5d409e..002e70a33a4 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[] = struct saa6752hs_state { struct i2c_client client; - struct v4l2_mpeg_compression old_params; struct saa6752hs_mpeg_params params; enum saa6752hs_videoformat video_format; v4l2_std_id standard; @@ -161,35 +160,6 @@ static struct saa6752hs_mpeg_params param_defaults = .au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K, }; -static struct v4l2_mpeg_compression old_param_defaults = -{ - .st_type = V4L2_MPEG_TS_2, - .st_bitrate = { - .mode = V4L2_BITRATE_CBR, - .target = 7000, - }, - - .ts_pid_pmt = 16, - .ts_pid_video = 260, - .ts_pid_audio = 256, - .ts_pid_pcr = 259, - - .vi_type = V4L2_MPEG_VI_2, - .vi_aspect_ratio = V4L2_MPEG_ASPECT_4_3, - .vi_bitrate = { - .mode = V4L2_BITRATE_VBR, - .target = 4000, - .max = 6000, - }, - - .au_type = V4L2_MPEG_AU_2_II, - .au_bitrate = { - .mode = V4L2_BITRATE_CBR, - .target = 256, - }, - -}; - /* ---------------------------------------------------------------------- */ static int saa6752hs_chip_command(struct i2c_client* client, @@ -362,74 +332,6 @@ static void saa6752hs_set_subsampling(struct i2c_client* client, } -static void saa6752hs_old_set_params(struct i2c_client* client, - struct v4l2_mpeg_compression* params) -{ - struct saa6752hs_state *h = i2c_get_clientdata(client); - - /* check PIDs */ - if (params->ts_pid_pmt <= MPEG_PID_MAX) { - h->old_params.ts_pid_pmt = params->ts_pid_pmt; - h->params.ts_pid_pmt = params->ts_pid_pmt; - } - if (params->ts_pid_pcr <= MPEG_PID_MAX) { - h->old_params.ts_pid_pcr = params->ts_pid_pcr; - h->params.ts_pid_pcr = params->ts_pid_pcr; - } - if (params->ts_pid_video <= MPEG_PID_MAX) { - h->old_params.ts_pid_video = params->ts_pid_video; - h->params.ts_pid_video = params->ts_pid_video; - } - if (params->ts_pid_audio <= MPEG_PID_MAX) { - h->old_params.ts_pid_audio = params->ts_pid_audio; - h->params.ts_pid_audio = params->ts_pid_audio; - } - - /* check bitrate parameters */ - if ((params->vi_bitrate.mode == V4L2_BITRATE_CBR) || - (params->vi_bitrate.mode == V4L2_BITRATE_VBR)) { - h->old_params.vi_bitrate.mode = params->vi_bitrate.mode; - h->params.vi_bitrate_mode = (params->vi_bitrate.mode == V4L2_BITRATE_VBR) ? - V4L2_MPEG_VIDEO_BITRATE_MODE_VBR : V4L2_MPEG_VIDEO_BITRATE_MODE_CBR; - } - if (params->vi_bitrate.mode != V4L2_BITRATE_NONE) - h->old_params.st_bitrate.target = params->st_bitrate.target; - if (params->vi_bitrate.mode != V4L2_BITRATE_NONE) - h->old_params.vi_bitrate.target = params->vi_bitrate.target; - if (params->vi_bitrate.mode == V4L2_BITRATE_VBR) - h->old_params.vi_bitrate.max = params->vi_bitrate.max; - if (params->au_bitrate.mode != V4L2_BITRATE_NONE) - h->old_params.au_bitrate.target = params->au_bitrate.target; - - /* aspect ratio */ - if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3 || - params->vi_aspect_ratio == V4L2_MPEG_ASPECT_16_9) { - h->old_params.vi_aspect_ratio = params->vi_aspect_ratio; - if (params->vi_aspect_ratio == V4L2_MPEG_ASPECT_4_3) - h->params.vi_aspect = V4L2_MPEG_VIDEO_ASPECT_4x3; - else - h->params.vi_aspect = V4L2_MPEG_VIDEO_ASPECT_16x9; - } - - /* range checks */ - if (h->old_params.st_bitrate.target > MPEG_TOTAL_TARGET_BITRATE_MAX) - h->old_params.st_bitrate.target = MPEG_TOTAL_TARGET_BITRATE_MAX; - if (h->old_params.vi_bitrate.target > MPEG_VIDEO_TARGET_BITRATE_MAX) - h->old_params.vi_bitrate.target = MPEG_VIDEO_TARGET_BITRATE_MAX; - if (h->old_params.vi_bitrate.max > MPEG_VIDEO_MAX_BITRATE_MAX) - h->old_params.vi_bitrate.max = MPEG_VIDEO_MAX_BITRATE_MAX; - h->params.vi_bitrate = params->vi_bitrate.target; - h->params.vi_bitrate_peak = params->vi_bitrate.max; - if (h->old_params.au_bitrate.target <= 256) { - h->old_params.au_bitrate.target = 256; - h->params.au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_256K; - } - else { - h->old_params.au_bitrate.target = 384; - h->params.au_l2_bitrate = V4L2_MPEG_AUDIO_L2_BITRATE_384K; - } -} - static int handle_ctrl(struct saa6752hs_mpeg_params *params, struct v4l2_ext_control *ctrl, unsigned int cmd) { @@ -697,7 +599,6 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind) return -ENOMEM; h->client = client_template; h->params = param_defaults; - h->old_params = old_param_defaults; h->client.adapter = adap; h->client.addr = addr; @@ -734,23 +635,11 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg) { struct saa6752hs_state *h = i2c_get_clientdata(client); struct v4l2_ext_controls *ctrls = arg; - struct v4l2_mpeg_compression *old_params = arg; struct saa6752hs_mpeg_params params; int err = 0; int i; switch (cmd) { - case VIDIOC_S_MPEGCOMP: - if (NULL == old_params) { - /* apply settings and start encoder */ - saa6752hs_init(client); - break; - } - saa6752hs_old_set_params(client, old_params); - /* fall through */ - case VIDIOC_G_MPEGCOMP: - *old_params = h->old_params; - break; case VIDIOC_S_EXT_CTRLS: if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) return -EINVAL; diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 1a4a24471f2..a499eea379e 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) assert_spin_locked(&dev->slock); - if (dev->inresume) + if (dev->insuspend) return 0; /* video capture -- dma 0 + video task A */ @@ -563,6 +563,9 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id) unsigned long report,status; int loop, handled = 0; + if (dev->insuspend) + goto out; + for (loop = 0; loop < 10; loop++) { report = saa_readl(SAA7134_IRQ_REPORT); status = saa_readl(SAA7134_IRQ_STATUS); @@ -1163,6 +1166,7 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) kfree(dev); } +#ifdef CONFIG_PM static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) { @@ -1176,6 +1180,19 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) saa_writel(SAA7134_IRQ2, 0); saa_writel(SAA7134_MAIN_CTRL, 0); + synchronize_irq(pci_dev->irq); + dev->insuspend = 1; + + /* Disable timeout timers - if we have active buffers, we will + fill them on resume*/ + + del_timer(&dev->video_q.timeout); + del_timer(&dev->vbi_q.timeout); + del_timer(&dev->ts_q.timeout); + + if (dev->remote) + saa7134_ir_stop(dev); + pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); pci_save_state(pci_dev); @@ -1194,24 +1211,27 @@ static int saa7134_resume(struct pci_dev *pci_dev) /* Do things that are done in saa7134_initdev , except of initializing memory structures.*/ - dev->inresume = 1; saa7134_board_init1(dev); + /* saa7134_hwinit1 */ if (saa7134_boards[dev->board].video_out) saa7134_videoport_init(dev); - if (card_has_mpeg(dev)) saa7134_ts_init_hw(dev); - + if (dev->remote) + saa7134_ir_start(dev, dev->remote); saa7134_hw_enable1(dev); - saa7134_set_decoder(dev); - saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); + + saa7134_board_init2(dev); - saa7134_hw_enable2(dev); + /*saa7134_hwinit2*/ + saa7134_set_tvnorm_hw(dev); saa7134_tvaudio_setmute(dev); saa7134_tvaudio_setvolume(dev, dev->ctl_volume); + saa7134_tvaudio_do_scan(dev); saa7134_enable_i2s(dev); + saa7134_hw_enable2(dev); /*resume unfinished buffer(s)*/ spin_lock_irqsave(&dev->slock, flags); @@ -1219,13 +1239,19 @@ static int saa7134_resume(struct pci_dev *pci_dev) saa7134_buffer_requeue(dev, &dev->vbi_q); saa7134_buffer_requeue(dev, &dev->ts_q); + /* FIXME: Disable DMA audio sound - temporary till proper support + is implemented*/ + + dev->dmasound.dma_running = 0; + /* start DMA now*/ - dev->inresume = 0; + dev->insuspend = 0; saa7134_set_dmabits(dev); spin_unlock_irqrestore(&dev->slock, flags); return 0; } +#endif /* ----------------------------------------------------------- */ @@ -1262,8 +1288,10 @@ static struct pci_driver saa7134_pci_driver = { .id_table = saa7134_pci_tbl, .probe = saa7134_initdev, .remove = __devexit_p(saa7134_finidev), +#ifdef CONFIG_PM .suspend = saa7134_suspend, .resume = saa7134_resume +#endif }; static int saa7134_init(void) diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index 34ca874dd7f..75d0c5bf46d 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, case VIDIOC_S_CTRL: return saa7134_common_ioctl(dev, cmd, arg); - case VIDIOC_S_MPEGCOMP: - printk(KERN_WARNING "VIDIOC_S_MPEGCOMP is obsolete. " - "Replace with VIDIOC_S_EXT_CTRLS!"); - saa7134_i2c_call_clients(dev, VIDIOC_S_MPEGCOMP, arg); - ts_init_encoder(dev); - return 0; - case VIDIOC_G_MPEGCOMP: - printk(KERN_WARNING "VIDIOC_G_MPEGCOMP is obsolete. " - "Replace with VIDIOC_G_EXT_CTRLS!"); - saa7134_i2c_call_clients(dev, VIDIOC_G_MPEGCOMP, arg); - return 0; case VIDIOC_S_EXT_CTRLS: /* count == 0 is abused in saa6752hs.c, so that special case is handled here explicitly. */ @@ -342,7 +331,6 @@ static struct video_device saa7134_empress_template = .name = "saa7134-empress", .type = 0 /* FIXME */, .type2 = 0 /* FIXME */, - .hardware = 0, .fops = &ts_fops, .minor = -1, }; diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index 80d2644f765..3abaa1b8ac9 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); static int ir_rc5_key_timeout = 115; module_param(ir_rc5_key_timeout, int, 0644); +static int repeat_delay = 500; +module_param(repeat_delay, int, 0644); +MODULE_PARM_DESC(repeat_delay, "delay before key repeat started"); +static int repeat_period = 33; +module_param(repeat_period, int, 0644); +MODULE_PARM_DESC(repeat_period, "repeat period between" + "keypresses when key is down"); + #define dprintk(fmt, arg...) if (ir_debug) \ printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg) #define i2cdprintk(fmt, arg...) if (ir_debug) \ @@ -59,6 +67,13 @@ static int build_key(struct saa7134_dev *dev) struct card_ir *ir = dev->remote; u32 gpio, data; + /* here comes the additional handshake steps for some cards */ + switch (dev->board) { + case SAA7134_BOARD_GOTVIEW_7135: + saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80); + saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80); + break; + } /* rising SAA7134_GPIO_GPRESCAN reads the status */ saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN); @@ -159,7 +174,7 @@ static void saa7134_input_timer(unsigned long data) mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); } -static void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) +void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) { if (ir->polling) { setup_timer(&ir->timer, saa7134_input_timer, @@ -182,7 +197,7 @@ static void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir) } } -static void saa7134_ir_stop(struct saa7134_dev *dev) +void saa7134_ir_stop(struct saa7134_dev *dev) { if (dev->remote->polling) del_timer_sync(&dev->remote->timer); @@ -285,10 +300,10 @@ int saa7134_input_init1(struct saa7134_dev *dev) break; case SAA7134_BOARD_GOTVIEW_7135: ir_codes = ir_codes_gotview7135; - mask_keycode = 0x0003EC; - mask_keyup = 0x008000; + mask_keycode = 0x0003CC; mask_keydown = 0x000010; - polling = 50; // ms + polling = 5; /* ms */ + saa_setb(SAA7134_GPIO_GPMODE1, 0x80); break; case SAA7134_BOARD_VIDEOMATE_TV_PVR: case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS: @@ -386,6 +401,10 @@ int saa7134_input_init1(struct saa7134_dev *dev) if (err) goto err_out_stop; + /* the remote isn't as bouncy as a keyboard */ + ir->dev->rep[REP_DELAY] = repeat_delay; + ir->dev->rep[REP_PERIOD] = repeat_period; + return 0; err_out_stop: diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index 1b9e39a5ea4..f8e304c7623 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c @@ -27,6 +27,7 @@ #include <linux/kthread.h> #include <linux/slab.h> #include <linux/delay.h> +#include <linux/freezer.h> #include <asm/div64.h> #include "saa7134-reg.h" @@ -231,7 +232,7 @@ static void mute_input_7134(struct saa7134_dev *dev) } if (dev->hw_mute == mute && - dev->hw_input == in && !dev->inresume) { + dev->hw_input == in && !dev->insuspend) { dprintk("mute/input: nothing to do [mute=%d,input=%s]\n", mute,in->name); return; @@ -502,13 +503,17 @@ static int tvaudio_thread(void *data) unsigned int i, audio, nscan; int max1,max2,carrier,rx,mode,lastmode,default_carrier; - allow_signal(SIGTERM); + + set_freezable(); + for (;;) { tvaudio_sleep(dev,-1); - if (kthread_should_stop() || signal_pending(current)) + if (kthread_should_stop()) goto done; restart: + try_to_freeze(); + dev->thread.scan1 = dev->thread.scan2; dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); dev->tvaudio = NULL; @@ -612,9 +617,12 @@ static int tvaudio_thread(void *data) lastmode = 42; for (;;) { + + try_to_freeze(); + if (tvaudio_sleep(dev,5000)) goto restart; - if (kthread_should_stop() || signal_pending(current)) + if (kthread_should_stop()) break; if (UNSET == dev->thread.mode) { rx = tvaudio_getstereo(dev,&tvaudio[i]); @@ -630,6 +638,7 @@ static int tvaudio_thread(void *data) } done: + dev->thread.stopped = 1; return 0; } @@ -777,7 +786,8 @@ static int tvaudio_thread_ddep(void *data) struct saa7134_dev *dev = data; u32 value, norms, clock; - allow_signal(SIGTERM); + + set_freezable(); clock = saa7134_boards[dev->board].audio_clock; if (UNSET != audio_clock_override) @@ -790,10 +800,13 @@ static int tvaudio_thread_ddep(void *data) for (;;) { tvaudio_sleep(dev,-1); - if (kthread_should_stop() || signal_pending(current)) + if (kthread_should_stop()) goto done; restart: + + try_to_freeze(); + dev->thread.scan1 = dev->thread.scan2; dprintk("tvaudio thread scan start [%d]\n",dev->thread.scan1); @@ -870,6 +883,7 @@ static int tvaudio_thread_ddep(void *data) } done: + dev->thread.stopped = 1; return 0; } @@ -997,7 +1011,7 @@ int saa7134_tvaudio_init2(struct saa7134_dev *dev) int saa7134_tvaudio_fini(struct saa7134_dev *dev) { /* shutdown tvaudio thread */ - if (dev->thread.thread) + if (dev->thread.thread && !dev->thread.stopped) kthread_stop(dev->thread.thread); saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x07, 0x00); /* LINE1 */ @@ -1013,7 +1027,9 @@ int saa7134_tvaudio_do_scan(struct saa7134_dev *dev) } else if (dev->thread.thread) { dev->thread.mode = UNSET; dev->thread.scan2++; - wake_up_process(dev->thread.thread); + + if (!dev->insuspend && !dev->thread.stopped) + wake_up_process(dev->thread.thread); } else { dev->automute = 0; saa7134_tvaudio_setmute(dev); diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 471b92793c1..3b9ffb4b648 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) dev->crop_current = dev->crop_defrect; - saa7134_set_decoder(dev); + saa7134_set_tvnorm_hw(dev); - if (card_in(dev, dev->ctl_input).tv) { - if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290) - && ((card(dev).tuner_config == 1) - || (card(dev).tuner_config == 2))) - saa7134_set_gpio(dev, 22, 5); - saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &norm->id); - } } static void video_mux(struct saa7134_dev *dev, int input) @@ -579,7 +572,8 @@ static void video_mux(struct saa7134_dev *dev, int input) saa7134_tvaudio_setinput(dev, &card_in(dev, input)); } -void saa7134_set_decoder(struct saa7134_dev *dev) + +static void saa7134_set_decoder(struct saa7134_dev *dev) { int luma_control, sync_control, mux; @@ -630,6 +624,19 @@ void saa7134_set_decoder(struct saa7134_dev *dev) saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); } +void saa7134_set_tvnorm_hw(struct saa7134_dev *dev) +{ + saa7134_set_decoder(dev); + + if (card_in(dev, dev->ctl_input).tv) { + if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290) + && ((card(dev).tuner_config == 1) + || (card(dev).tuner_config == 2))) + saa7134_set_gpio(dev, 22, 5); + saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); + } +} + static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) { static const struct { @@ -2352,7 +2359,6 @@ struct video_device saa7134_video_template = .name = "saa7134-video", .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER| VID_TYPE_CLIPPING|VID_TYPE_SCALES, - .hardware = 0, .fops = &video_fops, .minor = -1, }; @@ -2361,7 +2367,6 @@ struct video_device saa7134_vbi_template = { .name = "saa7134-vbi", .type = VID_TYPE_TUNER|VID_TYPE_TELETEXT, - .hardware = 0, .fops = &video_fops, .minor = -1, }; @@ -2370,7 +2375,6 @@ struct video_device saa7134_radio_template = { .name = "saa7134-radio", .type = VID_TYPE_TUNER, - .hardware = 0, .fops = &radio_fops, .minor = -1, }; diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 28ec6804bd5..66a390c321a 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h @@ -333,6 +333,7 @@ struct saa7134_thread { unsigned int scan1; unsigned int scan2; unsigned int mode; + unsigned int stopped; }; /* buffer for one video/vbi/ts frame */ @@ -524,7 +525,7 @@ struct saa7134_dev { unsigned int hw_mute; int last_carrier; int nosignal; - unsigned int inresume; + unsigned int insuspend; /* SAA7134_MPEG_* */ struct saa7134_ts ts; @@ -632,7 +633,7 @@ extern struct video_device saa7134_radio_template; void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm); int saa7134_videoport_init(struct saa7134_dev *dev); -void saa7134_set_decoder(struct saa7134_dev *dev); +void saa7134_set_tvnorm_hw(struct saa7134_dev *dev); int saa7134_common_ioctl(struct saa7134_dev *dev, unsigned int cmd, void *arg); @@ -706,6 +707,8 @@ int saa7134_input_init1(struct saa7134_dev *dev); void saa7134_input_fini(struct saa7134_dev *dev); void saa7134_input_irq(struct saa7134_dev *dev); void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir); +void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir); +void saa7134_ir_stop(struct saa7134_dev *dev); /* |