diff options
author | Kuninori Morimoto <morimoto.kuninori@renesas.com> | 2009-02-23 10:12:58 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:52 -0400 |
commit | 2941e81f64c2c3f99d03be09790f610dd6fedf64 (patch) | |
tree | 27d5c1a930cbbbdbe050602b08dd0cf854fff73f /drivers/media/video/ov772x.c | |
parent | 2d9329f3a551b50350a15d19edd9ab3df6c6bad0 (diff) |
V4L/DVB (10666): ov772x: move configuration from start_capture() to set_fmt()
soc_camera framework requires, that camera configuration is performed in
set_fmt, and start_capture and stop_capture only turn the camera on/off.
This patch modifies ov772x to comply to this requirement.
Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/ov772x.c')
-rw-r--r-- | drivers/media/video/ov772x.c | 125 |
1 files changed, 62 insertions, 63 deletions
diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c index 4d8ac6fd89fb..4d54e1899571 100644 --- a/drivers/media/video/ov772x.c +++ b/drivers/media/video/ov772x.c | |||
@@ -500,9 +500,8 @@ static const struct soc_camera_data_format ov772x_fmt_lists[] = { | |||
500 | /* | 500 | /* |
501 | * color format list | 501 | * color format list |
502 | */ | 502 | */ |
503 | #define T_YUYV 0 | ||
504 | static const struct ov772x_color_format ov772x_cfmts[] = { | 503 | static const struct ov772x_color_format ov772x_cfmts[] = { |
505 | [T_YUYV] = { | 504 | { |
506 | SETFOURCC(YUYV), | 505 | SETFOURCC(YUYV), |
507 | .regs = ov772x_YYUV_regs, | 506 | .regs = ov772x_YYUV_regs, |
508 | }, | 507 | }, |
@@ -635,74 +634,20 @@ static int ov772x_release(struct soc_camera_device *icd) | |||
635 | static int ov772x_start_capture(struct soc_camera_device *icd) | 634 | static int ov772x_start_capture(struct soc_camera_device *icd) |
636 | { | 635 | { |
637 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); | 636 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); |
638 | int ret; | ||
639 | |||
640 | if (!priv->win) | ||
641 | priv->win = &ov772x_win_vga; | ||
642 | if (!priv->fmt) | ||
643 | priv->fmt = &ov772x_cfmts[T_YUYV]; | ||
644 | |||
645 | /* | ||
646 | * reset hardware | ||
647 | */ | ||
648 | ov772x_reset(priv->client); | ||
649 | |||
650 | /* | ||
651 | * set color format | ||
652 | */ | ||
653 | ret = ov772x_write_array(priv->client, priv->fmt->regs); | ||
654 | if (ret < 0) | ||
655 | goto start_end; | ||
656 | |||
657 | /* | ||
658 | * set size format | ||
659 | */ | ||
660 | ret = ov772x_write_array(priv->client, priv->win->regs); | ||
661 | if (ret < 0) | ||
662 | goto start_end; | ||
663 | |||
664 | /* | ||
665 | * set COM7 bit ( QVGA or VGA ) | ||
666 | */ | ||
667 | ret = ov772x_mask_set(priv->client, | ||
668 | COM7, SLCT_MASK, priv->win->com7_bit); | ||
669 | if (ret < 0) | ||
670 | goto start_end; | ||
671 | 637 | ||
672 | /* | 638 | if (!priv->win || !priv->fmt) { |
673 | * set UV setting | 639 | dev_err(&icd->dev, "norm or win select error\n"); |
674 | */ | 640 | return -EPERM; |
675 | if (priv->fmt->option & OP_UV) { | ||
676 | ret = ov772x_mask_set(priv->client, | ||
677 | DSP_CTRL3, UV_MASK, UV_ON); | ||
678 | if (ret < 0) | ||
679 | goto start_end; | ||
680 | } | ||
681 | |||
682 | /* | ||
683 | * set SWAP setting | ||
684 | */ | ||
685 | if (priv->fmt->option & OP_SWAP_RGB) { | ||
686 | ret = ov772x_mask_set(priv->client, | ||
687 | COM3, SWAP_MASK, SWAP_RGB); | ||
688 | if (ret < 0) | ||
689 | goto start_end; | ||
690 | } | 641 | } |
691 | 642 | ||
692 | dev_dbg(&icd->dev, | 643 | dev_dbg(&icd->dev, |
693 | "format %s, win %s\n", priv->fmt->name, priv->win->name); | 644 | "format %s, win %s\n", priv->fmt->name, priv->win->name); |
694 | 645 | ||
695 | start_end: | 646 | return 0; |
696 | priv->fmt = NULL; | ||
697 | priv->win = NULL; | ||
698 | |||
699 | return ret; | ||
700 | } | 647 | } |
701 | 648 | ||
702 | static int ov772x_stop_capture(struct soc_camera_device *icd) | 649 | static int ov772x_stop_capture(struct soc_camera_device *icd) |
703 | { | 650 | { |
704 | struct ov772x_priv *priv = container_of(icd, struct ov772x_priv, icd); | ||
705 | ov772x_reset(priv->client); | ||
706 | return 0; | 651 | return 0; |
707 | } | 652 | } |
708 | 653 | ||
@@ -787,7 +732,6 @@ ov772x_select_win(u32 width, u32 height) | |||
787 | return win; | 732 | return win; |
788 | } | 733 | } |
789 | 734 | ||
790 | |||
791 | static int ov772x_set_fmt(struct soc_camera_device *icd, | 735 | static int ov772x_set_fmt(struct soc_camera_device *icd, |
792 | __u32 pixfmt, | 736 | __u32 pixfmt, |
793 | struct v4l2_rect *rect) | 737 | struct v4l2_rect *rect) |
@@ -803,16 +747,72 @@ static int ov772x_set_fmt(struct soc_camera_device *icd, | |||
803 | for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++) { | 747 | for (i = 0; i < ARRAY_SIZE(ov772x_cfmts); i++) { |
804 | if (pixfmt == ov772x_cfmts[i].fourcc) { | 748 | if (pixfmt == ov772x_cfmts[i].fourcc) { |
805 | priv->fmt = ov772x_cfmts + i; | 749 | priv->fmt = ov772x_cfmts + i; |
806 | ret = 0; | ||
807 | break; | 750 | break; |
808 | } | 751 | } |
809 | } | 752 | } |
753 | if (!priv->fmt) | ||
754 | goto ov772x_set_fmt_error; | ||
810 | 755 | ||
811 | /* | 756 | /* |
812 | * select win | 757 | * select win |
813 | */ | 758 | */ |
814 | priv->win = ov772x_select_win(rect->width, rect->height); | 759 | priv->win = ov772x_select_win(rect->width, rect->height); |
815 | 760 | ||
761 | /* | ||
762 | * reset hardware | ||
763 | */ | ||
764 | ov772x_reset(priv->client); | ||
765 | |||
766 | /* | ||
767 | * set color format | ||
768 | */ | ||
769 | ret = ov772x_write_array(priv->client, priv->fmt->regs); | ||
770 | if (ret < 0) | ||
771 | goto ov772x_set_fmt_error; | ||
772 | |||
773 | /* | ||
774 | * set size format | ||
775 | */ | ||
776 | ret = ov772x_write_array(priv->client, priv->win->regs); | ||
777 | if (ret < 0) | ||
778 | goto ov772x_set_fmt_error; | ||
779 | |||
780 | /* | ||
781 | * set COM7 bit ( QVGA or VGA ) | ||
782 | */ | ||
783 | ret = ov772x_mask_set(priv->client, | ||
784 | COM7, SLCT_MASK, priv->win->com7_bit); | ||
785 | if (ret < 0) | ||
786 | goto ov772x_set_fmt_error; | ||
787 | |||
788 | /* | ||
789 | * set UV setting | ||
790 | */ | ||
791 | if (priv->fmt->option & OP_UV) { | ||
792 | ret = ov772x_mask_set(priv->client, | ||
793 | DSP_CTRL3, UV_MASK, UV_ON); | ||
794 | if (ret < 0) | ||
795 | goto ov772x_set_fmt_error; | ||
796 | } | ||
797 | |||
798 | /* | ||
799 | * set SWAP setting | ||
800 | */ | ||
801 | if (priv->fmt->option & OP_SWAP_RGB) { | ||
802 | ret = ov772x_mask_set(priv->client, | ||
803 | COM3, SWAP_MASK, SWAP_RGB); | ||
804 | if (ret < 0) | ||
805 | goto ov772x_set_fmt_error; | ||
806 | } | ||
807 | |||
808 | return ret; | ||
809 | |||
810 | ov772x_set_fmt_error: | ||
811 | |||
812 | ov772x_reset(priv->client); | ||
813 | priv->win = NULL; | ||
814 | priv->fmt = NULL; | ||
815 | |||
816 | return ret; | 816 | return ret; |
817 | } | 817 | } |
818 | 818 | ||
@@ -889,7 +889,6 @@ static int ov772x_video_probe(struct soc_camera_device *icd) | |||
889 | i2c_smbus_read_byte_data(priv->client, MIDH), | 889 | i2c_smbus_read_byte_data(priv->client, MIDH), |
890 | i2c_smbus_read_byte_data(priv->client, MIDL)); | 890 | i2c_smbus_read_byte_data(priv->client, MIDL)); |
891 | 891 | ||
892 | |||
893 | return soc_camera_video_start(icd); | 892 | return soc_camera_video_start(icd); |
894 | } | 893 | } |
895 | 894 | ||