diff options
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-video.c')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-video.c | 125 |
1 files changed, 69 insertions, 56 deletions
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 525b5b77c13a..24d579723b55 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
@@ -540,22 +540,12 @@ void res_free(struct saa7134_dev *dev, struct saa7134_fh *fh, unsigned int bits) | |||
540 | 540 | ||
541 | /* ------------------------------------------------------------------ */ | 541 | /* ------------------------------------------------------------------ */ |
542 | 542 | ||
543 | static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm) | 543 | void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm) |
544 | { | 544 | { |
545 | int luma_control,sync_control,mux; | ||
546 | 545 | ||
547 | dprintk("set tv norm = %s\n",norm->name); | 546 | dprintk("set tv norm = %s\n",norm->name); |
548 | dev->tvnorm = norm; | 547 | dev->tvnorm = norm; |
549 | 548 | ||
550 | mux = card_in(dev,dev->ctl_input).vmux; | ||
551 | luma_control = norm->luma_control; | ||
552 | sync_control = norm->sync_control; | ||
553 | |||
554 | if (mux > 5) | ||
555 | luma_control |= 0x80; /* svideo */ | ||
556 | if (noninterlaced || dev->nosignal) | ||
557 | sync_control |= 0x20; | ||
558 | |||
559 | /* setup cropping */ | 549 | /* setup cropping */ |
560 | dev->crop_bounds.left = norm->h_start; | 550 | dev->crop_bounds.left = norm->h_start; |
561 | dev->crop_defrect.left = norm->h_start; | 551 | dev->crop_defrect.left = norm->h_start; |
@@ -570,6 +560,40 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm) | |||
570 | 560 | ||
571 | dev->crop_current = dev->crop_defrect; | 561 | dev->crop_current = dev->crop_defrect; |
572 | 562 | ||
563 | saa7134_set_decoder(dev); | ||
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 | } | ||
573 | |||
574 | static void video_mux(struct saa7134_dev *dev, int input) | ||
575 | { | ||
576 | dprintk("video input = %d [%s]\n", input, card_in(dev, input).name); | ||
577 | dev->ctl_input = input; | ||
578 | set_tvnorm(dev, dev->tvnorm); | ||
579 | saa7134_tvaudio_setinput(dev, &card_in(dev, input)); | ||
580 | } | ||
581 | |||
582 | void saa7134_set_decoder(struct saa7134_dev *dev) | ||
583 | { | ||
584 | int luma_control, sync_control, mux; | ||
585 | |||
586 | struct saa7134_tvnorm *norm = dev->tvnorm; | ||
587 | mux = card_in(dev, dev->ctl_input).vmux; | ||
588 | |||
589 | luma_control = norm->luma_control; | ||
590 | sync_control = norm->sync_control; | ||
591 | |||
592 | if (mux > 5) | ||
593 | luma_control |= 0x80; /* svideo */ | ||
594 | if (noninterlaced || dev->nosignal) | ||
595 | sync_control |= 0x20; | ||
596 | |||
573 | /* setup video decoder */ | 597 | /* setup video decoder */ |
574 | saa_writeb(SAA7134_INCR_DELAY, 0x08); | 598 | saa_writeb(SAA7134_INCR_DELAY, 0x08); |
575 | saa_writeb(SAA7134_ANALOG_IN_CTRL1, 0xc0 | mux); | 599 | saa_writeb(SAA7134_ANALOG_IN_CTRL1, 0xc0 | mux); |
@@ -604,23 +628,6 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm) | |||
604 | saa_writeb(SAA7134_MISC_VGATE_MSB, norm->vgate_misc); | 628 | saa_writeb(SAA7134_MISC_VGATE_MSB, norm->vgate_misc); |
605 | saa_writeb(SAA7134_RAW_DATA_GAIN, 0x40); | 629 | saa_writeb(SAA7134_RAW_DATA_GAIN, 0x40); |
606 | saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); | 630 | saa_writeb(SAA7134_RAW_DATA_OFFSET, 0x80); |
607 | |||
608 | /* only tell the tuner if this is a tv input */ | ||
609 | if (card_in(dev,dev->ctl_input).tv) { | ||
610 | if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290) | ||
611 | && ((card(dev).tuner_config == 1) | ||
612 | || (card(dev).tuner_config == 2))) | ||
613 | saa7134_set_gpio(dev, 22, 5); | ||
614 | saa7134_i2c_call_clients(dev,VIDIOC_S_STD,&norm->id); | ||
615 | } | ||
616 | } | ||
617 | |||
618 | static void video_mux(struct saa7134_dev *dev, int input) | ||
619 | { | ||
620 | dprintk("video input = %d [%s]\n",input,card_in(dev,input).name); | ||
621 | dev->ctl_input = input; | ||
622 | set_tvnorm(dev,dev->tvnorm); | ||
623 | saa7134_tvaudio_setinput(dev,&card_in(dev,input)); | ||
624 | } | 631 | } |
625 | 632 | ||
626 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) | 633 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) |
@@ -2399,34 +2406,40 @@ int saa7134_video_init1(struct saa7134_dev *dev) | |||
2399 | dev->video_q.timeout.data = (unsigned long)(&dev->video_q); | 2406 | dev->video_q.timeout.data = (unsigned long)(&dev->video_q); |
2400 | dev->video_q.dev = dev; | 2407 | dev->video_q.dev = dev; |
2401 | 2408 | ||
2402 | if (saa7134_boards[dev->board].video_out) { | 2409 | if (saa7134_boards[dev->board].video_out) |
2403 | /* enable video output */ | 2410 | saa7134_videoport_init(dev); |
2404 | int vo = saa7134_boards[dev->board].video_out; | 2411 | |
2405 | int video_reg; | 2412 | return 0; |
2406 | unsigned int vid_port_opts = saa7134_boards[dev->board].vid_port_opts; | 2413 | } |
2407 | saa_writeb(SAA7134_VIDEO_PORT_CTRL0, video_out[vo][0]); | 2414 | |
2408 | video_reg = video_out[vo][1]; | 2415 | int saa7134_videoport_init(struct saa7134_dev *dev) |
2409 | if (vid_port_opts & SET_T_CODE_POLARITY_NON_INVERTED) | 2416 | { |
2410 | video_reg &= ~VP_T_CODE_P_INVERTED; | 2417 | /* enable video output */ |
2411 | saa_writeb(SAA7134_VIDEO_PORT_CTRL1, video_reg); | 2418 | int vo = saa7134_boards[dev->board].video_out; |
2412 | saa_writeb(SAA7134_VIDEO_PORT_CTRL2, video_out[vo][2]); | 2419 | int video_reg; |
2413 | saa_writeb(SAA7134_VIDEO_PORT_CTRL3, video_out[vo][3]); | 2420 | unsigned int vid_port_opts = saa7134_boards[dev->board].vid_port_opts; |
2414 | saa_writeb(SAA7134_VIDEO_PORT_CTRL4, video_out[vo][4]); | 2421 | saa_writeb(SAA7134_VIDEO_PORT_CTRL0, video_out[vo][0]); |
2415 | video_reg = video_out[vo][5]; | 2422 | video_reg = video_out[vo][1]; |
2416 | if (vid_port_opts & SET_CLOCK_NOT_DELAYED) | 2423 | if (vid_port_opts & SET_T_CODE_POLARITY_NON_INVERTED) |
2417 | video_reg &= ~VP_CLK_CTRL2_DELAYED; | 2424 | video_reg &= ~VP_T_CODE_P_INVERTED; |
2418 | if (vid_port_opts & SET_CLOCK_INVERTED) | 2425 | saa_writeb(SAA7134_VIDEO_PORT_CTRL1, video_reg); |
2419 | video_reg |= VP_CLK_CTRL1_INVERTED; | 2426 | saa_writeb(SAA7134_VIDEO_PORT_CTRL2, video_out[vo][2]); |
2420 | saa_writeb(SAA7134_VIDEO_PORT_CTRL5, video_reg); | 2427 | saa_writeb(SAA7134_VIDEO_PORT_CTRL3, video_out[vo][3]); |
2421 | video_reg = video_out[vo][6]; | 2428 | saa_writeb(SAA7134_VIDEO_PORT_CTRL4, video_out[vo][4]); |
2422 | if (vid_port_opts & SET_VSYNC_OFF) { | 2429 | video_reg = video_out[vo][5]; |
2423 | video_reg &= ~VP_VS_TYPE_MASK; | 2430 | if (vid_port_opts & SET_CLOCK_NOT_DELAYED) |
2424 | video_reg |= VP_VS_TYPE_OFF; | 2431 | video_reg &= ~VP_CLK_CTRL2_DELAYED; |
2425 | } | 2432 | if (vid_port_opts & SET_CLOCK_INVERTED) |
2426 | saa_writeb(SAA7134_VIDEO_PORT_CTRL6, video_reg); | 2433 | video_reg |= VP_CLK_CTRL1_INVERTED; |
2427 | saa_writeb(SAA7134_VIDEO_PORT_CTRL7, video_out[vo][7]); | 2434 | saa_writeb(SAA7134_VIDEO_PORT_CTRL5, video_reg); |
2428 | saa_writeb(SAA7134_VIDEO_PORT_CTRL8, video_out[vo][8]); | 2435 | video_reg = video_out[vo][6]; |
2429 | } | 2436 | if (vid_port_opts & SET_VSYNC_OFF) { |
2437 | video_reg &= ~VP_VS_TYPE_MASK; | ||
2438 | video_reg |= VP_VS_TYPE_OFF; | ||
2439 | } | ||
2440 | saa_writeb(SAA7134_VIDEO_PORT_CTRL6, video_reg); | ||
2441 | saa_writeb(SAA7134_VIDEO_PORT_CTRL7, video_out[vo][7]); | ||
2442 | saa_writeb(SAA7134_VIDEO_PORT_CTRL8, video_out[vo][8]); | ||
2430 | 2443 | ||
2431 | return 0; | 2444 | return 0; |
2432 | } | 2445 | } |