diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-03-10 16:19:12 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-04-27 14:44:29 -0400 |
commit | d4e7ee36f988d2757c218d61c2f334df0a1acd45 (patch) | |
tree | 918ae83260cdd99e0c673aade74ea88baec5810b /drivers/media/video/ivtv | |
parent | d46c17d7aa12e30b612acae35535fcd64f2db3d6 (diff) |
V4L/DVB (5411): Use v4l_printk_ioctl for debug
Using v4l_printk_ioctl saves a lot of code duplication. Also moved a few
ioctl cases to another function, improving the ioctl grouping.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/ivtv')
-rw-r--r-- | drivers/media/video/ivtv/ivtv-ioctl.c | 256 |
1 files changed, 104 insertions, 152 deletions
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index 6f80941e49ec..2a4edb150d3e 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
@@ -632,7 +632,7 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype, | |||
632 | return 0; | 632 | return 0; |
633 | } | 633 | } |
634 | 634 | ||
635 | static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg) | 635 | static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg) |
636 | { | 636 | { |
637 | struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data; | 637 | struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data; |
638 | struct ivtv *itv = id->itv; | 638 | struct ivtv *itv = id->itv; |
@@ -641,7 +641,6 @@ static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg) | |||
641 | switch (cmd) { | 641 | switch (cmd) { |
642 | /* ioctls to allow direct access to the encoder registers for testing */ | 642 | /* ioctls to allow direct access to the encoder registers for testing */ |
643 | case VIDIOC_DBG_G_REGISTER: | 643 | case VIDIOC_DBG_G_REGISTER: |
644 | IVTV_DEBUG_IOCTL("VIDIOC_DBG_G_REGISTER\n"); | ||
645 | if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 644 | if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) |
646 | return ivtv_itvc(itv, cmd, arg); | 645 | return ivtv_itvc(itv, cmd, arg); |
647 | if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) | 646 | if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) |
@@ -649,7 +648,6 @@ static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg) | |||
649 | return ivtv_call_i2c_client(itv, reg->match_chip, cmd, arg); | 648 | return ivtv_call_i2c_client(itv, reg->match_chip, cmd, arg); |
650 | 649 | ||
651 | case VIDIOC_DBG_S_REGISTER: | 650 | case VIDIOC_DBG_S_REGISTER: |
652 | IVTV_DEBUG_IOCTL("VIDIOC_DBG_S_REGISTER\n"); | ||
653 | if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) | 651 | if (v4l2_chip_match_host(reg->match_type, reg->match_chip)) |
654 | return ivtv_itvc(itv, cmd, arg); | 652 | return ivtv_itvc(itv, cmd, arg); |
655 | if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) | 653 | if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER) |
@@ -659,7 +657,6 @@ static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg) | |||
659 | case VIDIOC_G_CHIP_IDENT: { | 657 | case VIDIOC_G_CHIP_IDENT: { |
660 | struct v4l2_chip_ident *chip = arg; | 658 | struct v4l2_chip_ident *chip = arg; |
661 | 659 | ||
662 | IVTV_DEBUG_IOCTL("VIDIOC_G_CHIP_IDENT\n"); | ||
663 | chip->ident = V4L2_IDENT_NONE; | 660 | chip->ident = V4L2_IDENT_NONE; |
664 | chip->revision = 0; | 661 | chip->revision = 0; |
665 | if (reg->match_type == V4L2_CHIP_MATCH_HOST) { | 662 | if (reg->match_type == V4L2_CHIP_MATCH_HOST) { |
@@ -680,13 +677,11 @@ static int ivtv_internal_ioctls(struct file *filp, unsigned int cmd, void *arg) | |||
680 | case VIDIOC_INT_S_AUDIO_ROUTING: { | 677 | case VIDIOC_INT_S_AUDIO_ROUTING: { |
681 | struct v4l2_routing *route = arg; | 678 | struct v4l2_routing *route = arg; |
682 | 679 | ||
683 | IVTV_DEBUG_IOCTL("VIDIOC_INT_S_AUDIO_ROUTING\n"); | ||
684 | ivtv_audio_set_route(itv, route); | 680 | ivtv_audio_set_route(itv, route); |
685 | break; | 681 | break; |
686 | } | 682 | } |
687 | 683 | ||
688 | case VIDIOC_INT_RESET: | 684 | case VIDIOC_INT_RESET: |
689 | IVTV_DEBUG_IOCTL("VIDIOC_INT_RESET\n"); | ||
690 | ivtv_reset_ir_gpio(itv); | 685 | ivtv_reset_ir_gpio(itv); |
691 | break; | 686 | break; |
692 | 687 | ||
@@ -721,8 +716,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
721 | case VIDIOC_QUERYCAP:{ | 716 | case VIDIOC_QUERYCAP:{ |
722 | struct v4l2_capability *vcap = arg; | 717 | struct v4l2_capability *vcap = arg; |
723 | 718 | ||
724 | IVTV_DEBUG_IOCTL("VIDIOC_QUERYCAP\n"); | ||
725 | |||
726 | memset(vcap, 0, sizeof(*vcap)); | 719 | memset(vcap, 0, sizeof(*vcap)); |
727 | strcpy(vcap->driver, IVTV_DRIVER_NAME); /* driver name */ | 720 | strcpy(vcap->driver, IVTV_DRIVER_NAME); /* driver name */ |
728 | strcpy(vcap->card, itv->card_name); /* card type */ | 721 | strcpy(vcap->card, itv->card_name); /* card type */ |
@@ -739,15 +732,12 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
739 | case VIDIOC_ENUMAUDIO:{ | 732 | case VIDIOC_ENUMAUDIO:{ |
740 | struct v4l2_audio *vin = arg; | 733 | struct v4l2_audio *vin = arg; |
741 | 734 | ||
742 | IVTV_DEBUG_IOCTL("VIDIOC_ENUMAUDIO\n"); | ||
743 | |||
744 | return ivtv_get_audio_input(itv, vin->index, vin); | 735 | return ivtv_get_audio_input(itv, vin->index, vin); |
745 | } | 736 | } |
746 | 737 | ||
747 | case VIDIOC_G_AUDIO:{ | 738 | case VIDIOC_G_AUDIO:{ |
748 | struct v4l2_audio *vin = arg; | 739 | struct v4l2_audio *vin = arg; |
749 | 740 | ||
750 | IVTV_DEBUG_IOCTL("VIDIOC_G_AUDIO\n"); | ||
751 | vin->index = itv->audio_input; | 741 | vin->index = itv->audio_input; |
752 | return ivtv_get_audio_input(itv, vin->index, vin); | 742 | return ivtv_get_audio_input(itv, vin->index, vin); |
753 | } | 743 | } |
@@ -755,8 +745,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
755 | case VIDIOC_S_AUDIO:{ | 745 | case VIDIOC_S_AUDIO:{ |
756 | struct v4l2_audio *vout = arg; | 746 | struct v4l2_audio *vout = arg; |
757 | 747 | ||
758 | IVTV_DEBUG_IOCTL("VIDIOC_S_AUDIO\n"); | ||
759 | |||
760 | if (vout->index >= itv->nof_audio_inputs) | 748 | if (vout->index >= itv->nof_audio_inputs) |
761 | return -EINVAL; | 749 | return -EINVAL; |
762 | itv->audio_input = vout->index; | 750 | itv->audio_input = vout->index; |
@@ -767,8 +755,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
767 | case VIDIOC_ENUMAUDOUT:{ | 755 | case VIDIOC_ENUMAUDOUT:{ |
768 | struct v4l2_audioout *vin = arg; | 756 | struct v4l2_audioout *vin = arg; |
769 | 757 | ||
770 | IVTV_DEBUG_IOCTL("VIDIOC_ENUMAUDOUT\n"); | ||
771 | |||
772 | /* set it to defaults from our table */ | 758 | /* set it to defaults from our table */ |
773 | return ivtv_get_audio_output(itv, vin->index, vin); | 759 | return ivtv_get_audio_output(itv, vin->index, vin); |
774 | } | 760 | } |
@@ -776,7 +762,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
776 | case VIDIOC_G_AUDOUT:{ | 762 | case VIDIOC_G_AUDOUT:{ |
777 | struct v4l2_audioout *vin = arg; | 763 | struct v4l2_audioout *vin = arg; |
778 | 764 | ||
779 | IVTV_DEBUG_IOCTL("VIDIOC_G_AUDOUT\n"); | ||
780 | vin->index = 0; | 765 | vin->index = 0; |
781 | return ivtv_get_audio_output(itv, vin->index, vin); | 766 | return ivtv_get_audio_output(itv, vin->index, vin); |
782 | } | 767 | } |
@@ -784,16 +769,12 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
784 | case VIDIOC_S_AUDOUT:{ | 769 | case VIDIOC_S_AUDOUT:{ |
785 | struct v4l2_audioout *vout = arg; | 770 | struct v4l2_audioout *vout = arg; |
786 | 771 | ||
787 | IVTV_DEBUG_IOCTL("VIDIOC_S_AUDOUT\n"); | ||
788 | |||
789 | return ivtv_get_audio_output(itv, vout->index, vout); | 772 | return ivtv_get_audio_output(itv, vout->index, vout); |
790 | } | 773 | } |
791 | 774 | ||
792 | case VIDIOC_ENUMINPUT:{ | 775 | case VIDIOC_ENUMINPUT:{ |
793 | struct v4l2_input *vin = arg; | 776 | struct v4l2_input *vin = arg; |
794 | 777 | ||
795 | IVTV_DEBUG_IOCTL("VIDIOC_ENUMINPUT\n"); | ||
796 | |||
797 | /* set it to defaults from our table */ | 778 | /* set it to defaults from our table */ |
798 | return ivtv_get_input(itv, vin->index, vin); | 779 | return ivtv_get_input(itv, vin->index, vin); |
799 | } | 780 | } |
@@ -801,8 +782,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
801 | case VIDIOC_ENUMOUTPUT:{ | 782 | case VIDIOC_ENUMOUTPUT:{ |
802 | struct v4l2_output *vout = arg; | 783 | struct v4l2_output *vout = arg; |
803 | 784 | ||
804 | IVTV_DEBUG_IOCTL("VIDIOC_ENUMOUTPUT\n"); | ||
805 | |||
806 | return ivtv_get_output(itv, vout->index, vout); | 785 | return ivtv_get_output(itv, vout->index, vout); |
807 | } | 786 | } |
808 | 787 | ||
@@ -810,11 +789,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
810 | case VIDIOC_S_FMT: { | 789 | case VIDIOC_S_FMT: { |
811 | struct v4l2_format *fmt = arg; | 790 | struct v4l2_format *fmt = arg; |
812 | 791 | ||
813 | if (cmd == VIDIOC_S_FMT) { | ||
814 | IVTV_DEBUG_IOCTL("VIDIOC_S_FMT\n"); | ||
815 | } else { | ||
816 | IVTV_DEBUG_IOCTL("VIDIOC_TRY_FMT\n"); | ||
817 | } | ||
818 | return ivtv_try_or_set_fmt(itv, id->type, fmt, cmd == VIDIOC_S_FMT); | 792 | return ivtv_try_or_set_fmt(itv, id->type, fmt, cmd == VIDIOC_S_FMT); |
819 | } | 793 | } |
820 | 794 | ||
@@ -822,7 +796,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
822 | struct v4l2_format *fmt = arg; | 796 | struct v4l2_format *fmt = arg; |
823 | int type = fmt->type; | 797 | int type = fmt->type; |
824 | 798 | ||
825 | IVTV_DEBUG_IOCTL("VIDIOC_G_FMT\n"); | ||
826 | memset(fmt, 0, sizeof(*fmt)); | 799 | memset(fmt, 0, sizeof(*fmt)); |
827 | fmt->type = type; | 800 | fmt->type = type; |
828 | return ivtv_get_fmt(itv, id->type, fmt); | 801 | return ivtv_get_fmt(itv, id->type, fmt); |
@@ -831,7 +804,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
831 | case VIDIOC_S_CROP: { | 804 | case VIDIOC_S_CROP: { |
832 | struct v4l2_crop *crop = arg; | 805 | struct v4l2_crop *crop = arg; |
833 | 806 | ||
834 | IVTV_DEBUG_IOCTL("VIDIOC_S_CROP\n"); | ||
835 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 807 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
836 | return -EINVAL; | 808 | return -EINVAL; |
837 | return itv->video_dec_func(itv, VIDIOC_S_CROP, arg); | 809 | return itv->video_dec_func(itv, VIDIOC_S_CROP, arg); |
@@ -840,7 +812,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
840 | case VIDIOC_G_CROP: { | 812 | case VIDIOC_G_CROP: { |
841 | struct v4l2_crop *crop = arg; | 813 | struct v4l2_crop *crop = arg; |
842 | 814 | ||
843 | IVTV_DEBUG_IOCTL("VIDIOC_G_CROP\n"); | ||
844 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 815 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
845 | return -EINVAL; | 816 | return -EINVAL; |
846 | return itv->video_dec_func(itv, VIDIOC_G_CROP, arg); | 817 | return itv->video_dec_func(itv, VIDIOC_G_CROP, arg); |
@@ -878,8 +849,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
878 | } | 849 | } |
879 | 850 | ||
880 | case VIDIOC_G_INPUT:{ | 851 | case VIDIOC_G_INPUT:{ |
881 | IVTV_DEBUG_IOCTL("VIDIOC_G_INPUT\n"); | ||
882 | |||
883 | *(int *)arg = itv->active_input; | 852 | *(int *)arg = itv->active_input; |
884 | break; | 853 | break; |
885 | } | 854 | } |
@@ -887,8 +856,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
887 | case VIDIOC_S_INPUT:{ | 856 | case VIDIOC_S_INPUT:{ |
888 | int inp = *(int *)arg; | 857 | int inp = *(int *)arg; |
889 | 858 | ||
890 | IVTV_DEBUG_IOCTL("VIDIOC_S_INPUT\n"); | ||
891 | |||
892 | if (inp < 0 || inp >= itv->nof_inputs) | 859 | if (inp < 0 || inp >= itv->nof_inputs) |
893 | return -EINVAL; | 860 | return -EINVAL; |
894 | 861 | ||
@@ -914,8 +881,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
914 | } | 881 | } |
915 | 882 | ||
916 | case VIDIOC_G_OUTPUT:{ | 883 | case VIDIOC_G_OUTPUT:{ |
917 | IVTV_DEBUG_IOCTL("VIDIOC_G_OUTPUT\n"); | ||
918 | |||
919 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) | 884 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) |
920 | return -EINVAL; | 885 | return -EINVAL; |
921 | *(int *)arg = itv->active_output; | 886 | *(int *)arg = itv->active_output; |
@@ -926,8 +891,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
926 | int outp = *(int *)arg; | 891 | int outp = *(int *)arg; |
927 | struct v4l2_routing route; | 892 | struct v4l2_routing route; |
928 | 893 | ||
929 | IVTV_DEBUG_IOCTL("VIDIOC_S_OUTPUT\n"); | ||
930 | |||
931 | if (outp >= itv->card->nof_outputs) | 894 | if (outp >= itv->card->nof_outputs) |
932 | return -EINVAL; | 895 | return -EINVAL; |
933 | 896 | ||
@@ -948,8 +911,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
948 | case VIDIOC_G_FREQUENCY:{ | 911 | case VIDIOC_G_FREQUENCY:{ |
949 | struct v4l2_frequency *vf = arg; | 912 | struct v4l2_frequency *vf = arg; |
950 | 913 | ||
951 | IVTV_DEBUG_IOCTL("VIDIOC_G_FREQUENCY\n"); | ||
952 | |||
953 | if (vf->tuner != 0) | 914 | if (vf->tuner != 0) |
954 | return -EINVAL; | 915 | return -EINVAL; |
955 | ivtv_call_i2c_clients(itv, cmd, arg); | 916 | ivtv_call_i2c_clients(itv, cmd, arg); |
@@ -959,8 +920,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
959 | case VIDIOC_S_FREQUENCY:{ | 920 | case VIDIOC_S_FREQUENCY:{ |
960 | struct v4l2_frequency vf = *(struct v4l2_frequency *)arg; | 921 | struct v4l2_frequency vf = *(struct v4l2_frequency *)arg; |
961 | 922 | ||
962 | IVTV_DEBUG_IOCTL("VIDIOC_S_FREQUENCY\n"); | ||
963 | |||
964 | if (vf.tuner != 0) | 923 | if (vf.tuner != 0) |
965 | return -EINVAL; | 924 | return -EINVAL; |
966 | 925 | ||
@@ -975,8 +934,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
975 | struct v4l2_standard *vs = arg; | 934 | struct v4l2_standard *vs = arg; |
976 | int idx = vs->index; | 935 | int idx = vs->index; |
977 | 936 | ||
978 | IVTV_DEBUG_IOCTL("VIDIOC_ENUMSTD\n"); | ||
979 | |||
980 | if (idx < 0 || idx >= ARRAY_SIZE(enum_stds)) | 937 | if (idx < 0 || idx >= ARRAY_SIZE(enum_stds)) |
981 | return -EINVAL; | 938 | return -EINVAL; |
982 | 939 | ||
@@ -989,7 +946,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
989 | } | 946 | } |
990 | 947 | ||
991 | case VIDIOC_G_STD:{ | 948 | case VIDIOC_G_STD:{ |
992 | IVTV_DEBUG_IOCTL("VIDIOC_G_STD\n"); | ||
993 | *(v4l2_std_id *) arg = itv->std; | 949 | *(v4l2_std_id *) arg = itv->std; |
994 | break; | 950 | break; |
995 | } | 951 | } |
@@ -997,8 +953,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
997 | case VIDIOC_S_STD: { | 953 | case VIDIOC_S_STD: { |
998 | v4l2_std_id std = *(v4l2_std_id *) arg; | 954 | v4l2_std_id std = *(v4l2_std_id *) arg; |
999 | 955 | ||
1000 | IVTV_DEBUG_IOCTL("VIDIOC_S_STD\n"); | ||
1001 | |||
1002 | if ((std & V4L2_STD_ALL) == 0) | 956 | if ((std & V4L2_STD_ALL) == 0) |
1003 | return -EINVAL; | 957 | return -EINVAL; |
1004 | 958 | ||
@@ -1049,8 +1003,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
1049 | case VIDIOC_S_TUNER: { /* Setting tuner can only set audio mode */ | 1003 | case VIDIOC_S_TUNER: { /* Setting tuner can only set audio mode */ |
1050 | struct v4l2_tuner *vt = arg; | 1004 | struct v4l2_tuner *vt = arg; |
1051 | 1005 | ||
1052 | IVTV_DEBUG_IOCTL("VIDIOC_S_TUNER\n"); | ||
1053 | |||
1054 | if (vt->index != 0) | 1006 | if (vt->index != 0) |
1055 | return -EINVAL; | 1007 | return -EINVAL; |
1056 | 1008 | ||
@@ -1061,8 +1013,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
1061 | case VIDIOC_G_TUNER: { | 1013 | case VIDIOC_G_TUNER: { |
1062 | struct v4l2_tuner *vt = arg; | 1014 | struct v4l2_tuner *vt = arg; |
1063 | 1015 | ||
1064 | IVTV_DEBUG_IOCTL("VIDIOC_G_TUNER\n"); | ||
1065 | |||
1066 | if (vt->index != 0) | 1016 | if (vt->index != 0) |
1067 | return -EINVAL; | 1017 | return -EINVAL; |
1068 | 1018 | ||
@@ -1085,7 +1035,6 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
1085 | int f, l; | 1035 | int f, l; |
1086 | enum v4l2_buf_type type = cap->type; | 1036 | enum v4l2_buf_type type = cap->type; |
1087 | 1037 | ||
1088 | IVTV_DEBUG_IOCTL("VIDIOC_G_SLICED_VBI_CAP\n"); | ||
1089 | memset(cap, 0, sizeof(*cap)); | 1038 | memset(cap, 0, sizeof(*cap)); |
1090 | cap->type = type; | 1039 | cap->type = type; |
1091 | if (type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) { | 1040 | if (type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) { |
@@ -1113,6 +1062,89 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
1113 | return -EINVAL; | 1062 | return -EINVAL; |
1114 | } | 1063 | } |
1115 | 1064 | ||
1065 | case VIDIOC_G_ENC_INDEX: { | ||
1066 | struct v4l2_enc_idx *idx = arg; | ||
1067 | int i; | ||
1068 | |||
1069 | idx->entries = (itv->pgm_info_write_idx + IVTV_MAX_PGM_INDEX - itv->pgm_info_read_idx) % | ||
1070 | IVTV_MAX_PGM_INDEX; | ||
1071 | if (idx->entries > V4L2_ENC_IDX_ENTRIES) | ||
1072 | idx->entries = V4L2_ENC_IDX_ENTRIES; | ||
1073 | for (i = 0; i < idx->entries; i++) { | ||
1074 | idx->entry[i] = itv->pgm_info[(itv->pgm_info_read_idx + i) % IVTV_MAX_PGM_INDEX]; | ||
1075 | } | ||
1076 | itv->pgm_info_read_idx = (itv->pgm_info_read_idx + idx->entries) % IVTV_MAX_PGM_INDEX; | ||
1077 | break; | ||
1078 | } | ||
1079 | |||
1080 | case VIDIOC_ENCODER_CMD: | ||
1081 | case VIDIOC_TRY_ENCODER_CMD: { | ||
1082 | struct v4l2_encoder_cmd *enc = arg; | ||
1083 | int try = cmd == VIDIOC_TRY_ENCODER_CMD; | ||
1084 | |||
1085 | switch (enc->cmd) { | ||
1086 | case V4L2_ENC_CMD_START: | ||
1087 | return ivtv_start_capture(id); | ||
1088 | |||
1089 | case V4L2_ENC_CMD_STOP: | ||
1090 | ivtv_stop_capture(id, enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END); | ||
1091 | return 0; | ||
1092 | |||
1093 | case V4L2_ENC_CMD_PAUSE: | ||
1094 | if (!atomic_read(&itv->capturing)) | ||
1095 | return -EPERM; | ||
1096 | if (test_and_set_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags)) | ||
1097 | return 0; | ||
1098 | ivtv_mute(itv); | ||
1099 | ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 0); | ||
1100 | break; | ||
1101 | |||
1102 | case V4L2_ENC_CMD_RESUME: | ||
1103 | if (!atomic_read(&itv->capturing)) | ||
1104 | return -EPERM; | ||
1105 | if (!test_and_clear_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags)) | ||
1106 | return 0; | ||
1107 | ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 1); | ||
1108 | ivtv_unmute(itv); | ||
1109 | break; | ||
1110 | } | ||
1111 | break; | ||
1112 | } | ||
1113 | |||
1114 | case VIDIOC_G_FBUF: { | ||
1115 | struct v4l2_framebuffer *fb = arg; | ||
1116 | |||
1117 | memset(fb, 0, sizeof(*fb)); | ||
1118 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) | ||
1119 | break; | ||
1120 | fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY | | ||
1121 | V4L2_FBUF_CAP_LOCAL_ALPHA | V4L2_FBUF_CAP_GLOBAL_ALPHA; | ||
1122 | fb->fmt.pixelformat = itv->osd_pixelformat; | ||
1123 | fb->fmt.width = itv->osd_rect.width; | ||
1124 | fb->fmt.height = itv->osd_rect.height; | ||
1125 | fb->fmt.left = itv->osd_rect.left; | ||
1126 | fb->fmt.top = itv->osd_rect.top; | ||
1127 | fb->base = (void *)itv->osd_video_pbase; | ||
1128 | if (itv->osd_global_alpha_state) | ||
1129 | fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; | ||
1130 | if (itv->osd_local_alpha_state) | ||
1131 | fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; | ||
1132 | if (itv->osd_color_key_state) | ||
1133 | fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY; | ||
1134 | break; | ||
1135 | } | ||
1136 | |||
1137 | case VIDIOC_S_FBUF: { | ||
1138 | struct v4l2_framebuffer *fb = arg; | ||
1139 | |||
1140 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) | ||
1141 | break; | ||
1142 | itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; | ||
1143 | itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0; | ||
1144 | itv->osd_color_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; | ||
1145 | break; | ||
1146 | } | ||
1147 | |||
1116 | case VIDIOC_LOG_STATUS: | 1148 | case VIDIOC_LOG_STATUS: |
1117 | { | 1149 | { |
1118 | int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT; | 1150 | int has_output = itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT; |
@@ -1175,7 +1207,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
1175 | return 0; | 1207 | return 0; |
1176 | } | 1208 | } |
1177 | 1209 | ||
1178 | static int ivtv_ivtv_ioctls(struct file *filp, unsigned int cmd, void *arg) | 1210 | static int ivtv_decoder_ioctls(struct file *filp, unsigned int cmd, void *arg) |
1179 | { | 1211 | { |
1180 | struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data; | 1212 | struct ivtv_open_id *id = (struct ivtv_open_id *)filp->private_data; |
1181 | struct ivtv *itv = id->itv; | 1213 | struct ivtv *itv = id->itv; |
@@ -1355,96 +1387,6 @@ static int ivtv_ivtv_ioctls(struct file *filp, unsigned int cmd, void *arg) | |||
1355 | break; | 1387 | break; |
1356 | } | 1388 | } |
1357 | 1389 | ||
1358 | case VIDIOC_G_ENC_INDEX: { | ||
1359 | struct v4l2_enc_idx *idx = arg; | ||
1360 | int i; | ||
1361 | |||
1362 | IVTV_DEBUG_IOCTL("VIDIOC_G_ENC_INDEX\n"); | ||
1363 | idx->entries = (itv->pgm_info_write_idx + IVTV_MAX_PGM_INDEX - itv->pgm_info_read_idx) % | ||
1364 | IVTV_MAX_PGM_INDEX; | ||
1365 | if (idx->entries > V4L2_ENC_IDX_ENTRIES) | ||
1366 | idx->entries = V4L2_ENC_IDX_ENTRIES; | ||
1367 | for (i = 0; i < idx->entries; i++) { | ||
1368 | idx->entry[i] = itv->pgm_info[(itv->pgm_info_read_idx + i) % IVTV_MAX_PGM_INDEX]; | ||
1369 | } | ||
1370 | itv->pgm_info_read_idx = (itv->pgm_info_read_idx + idx->entries) % IVTV_MAX_PGM_INDEX; | ||
1371 | break; | ||
1372 | } | ||
1373 | |||
1374 | case VIDIOC_ENCODER_CMD: | ||
1375 | case VIDIOC_TRY_ENCODER_CMD: { | ||
1376 | struct v4l2_encoder_cmd *enc = arg; | ||
1377 | int try = cmd == VIDIOC_TRY_ENCODER_CMD; | ||
1378 | |||
1379 | if (try) | ||
1380 | IVTV_DEBUG_IOCTL("VIDIOC_TRY_ENCODER_CMD\n"); | ||
1381 | else | ||
1382 | IVTV_DEBUG_IOCTL("VIDIOC_ENCODER_CMD\n"); | ||
1383 | switch (enc->cmd) { | ||
1384 | case V4L2_ENC_CMD_START: | ||
1385 | return ivtv_start_capture(id); | ||
1386 | |||
1387 | case V4L2_ENC_CMD_STOP: | ||
1388 | ivtv_stop_capture(id, enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END); | ||
1389 | return 0; | ||
1390 | |||
1391 | case V4L2_ENC_CMD_PAUSE: | ||
1392 | if (!atomic_read(&itv->capturing)) | ||
1393 | return -EPERM; | ||
1394 | if (test_and_set_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags)) | ||
1395 | return 0; | ||
1396 | ivtv_mute(itv); | ||
1397 | ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 0); | ||
1398 | break; | ||
1399 | |||
1400 | case V4L2_ENC_CMD_RESUME: | ||
1401 | if (!atomic_read(&itv->capturing)) | ||
1402 | return -EPERM; | ||
1403 | if (!test_and_clear_bit(IVTV_F_I_ENC_PAUSED, &itv->i_flags)) | ||
1404 | return 0; | ||
1405 | ivtv_vapi(itv, CX2341X_ENC_PAUSE_ENCODER, 1, 1); | ||
1406 | ivtv_unmute(itv); | ||
1407 | break; | ||
1408 | } | ||
1409 | break; | ||
1410 | } | ||
1411 | |||
1412 | case VIDIOC_G_FBUF: { | ||
1413 | struct v4l2_framebuffer *fb = arg; | ||
1414 | |||
1415 | IVTV_DEBUG_IOCTL("VIDIOC_G_FBUF\n"); | ||
1416 | memset(fb, 0, sizeof(*fb)); | ||
1417 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) | ||
1418 | break; | ||
1419 | fb->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_CHROMAKEY | | ||
1420 | V4L2_FBUF_CAP_LOCAL_ALPHA | V4L2_FBUF_CAP_GLOBAL_ALPHA; | ||
1421 | fb->fmt.pixelformat = itv->osd_pixelformat; | ||
1422 | fb->fmt.width = itv->osd_rect.width; | ||
1423 | fb->fmt.height = itv->osd_rect.height; | ||
1424 | fb->fmt.left = itv->osd_rect.left; | ||
1425 | fb->fmt.top = itv->osd_rect.top; | ||
1426 | fb->base = (void *)itv->osd_video_pbase; | ||
1427 | if (itv->osd_global_alpha_state) | ||
1428 | fb->flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; | ||
1429 | if (itv->osd_local_alpha_state) | ||
1430 | fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; | ||
1431 | if (itv->osd_color_key_state) | ||
1432 | fb->flags |= V4L2_FBUF_FLAG_CHROMAKEY; | ||
1433 | break; | ||
1434 | } | ||
1435 | |||
1436 | case VIDIOC_S_FBUF: { | ||
1437 | struct v4l2_framebuffer *fb = arg; | ||
1438 | |||
1439 | IVTV_DEBUG_IOCTL("VIDIOC_S_FBUF\n"); | ||
1440 | if (!(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT_OVERLAY)) | ||
1441 | break; | ||
1442 | itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; | ||
1443 | itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0; | ||
1444 | itv->osd_color_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; | ||
1445 | break; | ||
1446 | } | ||
1447 | |||
1448 | default: | 1390 | default: |
1449 | return -EINVAL; | 1391 | return -EINVAL; |
1450 | } | 1392 | } |
@@ -1458,8 +1400,6 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, | |||
1458 | struct ivtv *itv = id->itv; | 1400 | struct ivtv *itv = id->itv; |
1459 | int ret; | 1401 | int ret; |
1460 | 1402 | ||
1461 | IVTV_DEBUG_IOCTL("v4l2 ioctl 0x%08x\n", cmd); | ||
1462 | |||
1463 | /* check priority */ | 1403 | /* check priority */ |
1464 | switch (cmd) { | 1404 | switch (cmd) { |
1465 | case VIDIOC_S_CTRL: | 1405 | case VIDIOC_S_CTRL: |
@@ -1485,7 +1425,11 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, | |||
1485 | case VIDIOC_G_CHIP_IDENT: | 1425 | case VIDIOC_G_CHIP_IDENT: |
1486 | case VIDIOC_INT_S_AUDIO_ROUTING: | 1426 | case VIDIOC_INT_S_AUDIO_ROUTING: |
1487 | case VIDIOC_INT_RESET: | 1427 | case VIDIOC_INT_RESET: |
1488 | return ivtv_internal_ioctls(filp, cmd, arg); | 1428 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { |
1429 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); | ||
1430 | v4l_printk_ioctl(cmd); | ||
1431 | } | ||
1432 | return ivtv_debug_ioctls(filp, cmd, arg); | ||
1489 | 1433 | ||
1490 | case VIDIOC_G_PRIORITY: | 1434 | case VIDIOC_G_PRIORITY: |
1491 | case VIDIOC_S_PRIORITY: | 1435 | case VIDIOC_S_PRIORITY: |
@@ -1517,6 +1461,15 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, | |||
1517 | case VIDIOC_G_AUDOUT: | 1461 | case VIDIOC_G_AUDOUT: |
1518 | case VIDIOC_G_SLICED_VBI_CAP: | 1462 | case VIDIOC_G_SLICED_VBI_CAP: |
1519 | case VIDIOC_LOG_STATUS: | 1463 | case VIDIOC_LOG_STATUS: |
1464 | case VIDIOC_G_ENC_INDEX: | ||
1465 | case VIDIOC_ENCODER_CMD: | ||
1466 | case VIDIOC_TRY_ENCODER_CMD: | ||
1467 | case VIDIOC_G_FBUF: | ||
1468 | case VIDIOC_S_FBUF: | ||
1469 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { | ||
1470 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); | ||
1471 | v4l_printk_ioctl(cmd); | ||
1472 | } | ||
1520 | return ivtv_v4l2_ioctls(itv, filp, cmd, arg); | 1473 | return ivtv_v4l2_ioctls(itv, filp, cmd, arg); |
1521 | 1474 | ||
1522 | case VIDIOC_QUERYMENU: | 1475 | case VIDIOC_QUERYMENU: |
@@ -1526,6 +1479,10 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, | |||
1526 | case VIDIOC_S_EXT_CTRLS: | 1479 | case VIDIOC_S_EXT_CTRLS: |
1527 | case VIDIOC_G_EXT_CTRLS: | 1480 | case VIDIOC_G_EXT_CTRLS: |
1528 | case VIDIOC_TRY_EXT_CTRLS: | 1481 | case VIDIOC_TRY_EXT_CTRLS: |
1482 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { | ||
1483 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); | ||
1484 | v4l_printk_ioctl(cmd); | ||
1485 | } | ||
1529 | return ivtv_control_ioctls(itv, cmd, arg); | 1486 | return ivtv_control_ioctls(itv, cmd, arg); |
1530 | 1487 | ||
1531 | case IVTV_IOC_DMA_FRAME: | 1488 | case IVTV_IOC_DMA_FRAME: |
@@ -1538,12 +1495,7 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, | |||
1538 | case VIDEO_CONTINUE: | 1495 | case VIDEO_CONTINUE: |
1539 | case VIDEO_COMMAND: | 1496 | case VIDEO_COMMAND: |
1540 | case VIDEO_TRY_COMMAND: | 1497 | case VIDEO_TRY_COMMAND: |
1541 | case VIDIOC_G_ENC_INDEX: | 1498 | return ivtv_decoder_ioctls(filp, cmd, arg); |
1542 | case VIDIOC_ENCODER_CMD: | ||
1543 | case VIDIOC_TRY_ENCODER_CMD: | ||
1544 | case VIDIOC_G_FBUF: | ||
1545 | case VIDIOC_S_FBUF: | ||
1546 | return ivtv_ivtv_ioctls(filp, cmd, arg); | ||
1547 | 1499 | ||
1548 | case 0x00005401: /* Handle isatty() calls */ | 1500 | case 0x00005401: /* Handle isatty() calls */ |
1549 | return -EINVAL; | 1501 | return -EINVAL; |