diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-01-20 11:59:22 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-02-21 10:34:45 -0500 |
commit | 23154f2f3b8c3c7c58548c518f28195b0d0a6c64 (patch) | |
tree | 7439643a3a71afab61c780759c44cdc325e486b3 /drivers/media/video | |
parent | ed10b06d8da204ce5f8d1b5b1a9d4df6565847c9 (diff) |
V4L/DVB (5105): Reorder some ioctl handlers
Reorder some ioctl handlers to make easy to convert to video_ioctl2
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/cx88/cx88-blackbird.c | 150 |
1 files changed, 80 insertions, 70 deletions
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index 2eb31ff0c1f4..0ba6ef39b04c 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c | |||
@@ -816,8 +816,7 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, | |||
816 | cap->capabilities = | 816 | cap->capabilities = |
817 | V4L2_CAP_VIDEO_CAPTURE | | 817 | V4L2_CAP_VIDEO_CAPTURE | |
818 | V4L2_CAP_READWRITE | | 818 | V4L2_CAP_READWRITE | |
819 | V4L2_CAP_STREAMING | | 819 | V4L2_CAP_STREAMING; |
820 | 0; | ||
821 | if (UNSET != core->tuner_type) | 820 | if (UNSET != core->tuner_type) |
822 | cap->capabilities |= V4L2_CAP_TUNER; | 821 | cap->capabilities |= V4L2_CAP_TUNER; |
823 | 822 | ||
@@ -928,7 +927,6 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, | |||
928 | return cx2341x_ext_ctrls(&dev->params, f, cmd); | 927 | return cx2341x_ext_ctrls(&dev->params, f, cmd); |
929 | } | 928 | } |
930 | case VIDIOC_S_EXT_CTRLS: | 929 | case VIDIOC_S_EXT_CTRLS: |
931 | case VIDIOC_TRY_EXT_CTRLS: | ||
932 | { | 930 | { |
933 | struct v4l2_ext_controls *f = arg; | 931 | struct v4l2_ext_controls *f = arg; |
934 | struct cx2341x_mpeg_params p; | 932 | struct cx2341x_mpeg_params p; |
@@ -937,13 +935,25 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file, | |||
937 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | 935 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) |
938 | return -EINVAL; | 936 | return -EINVAL; |
939 | p = dev->params; | 937 | p = dev->params; |
940 | err = cx2341x_ext_ctrls(&p, f, cmd); | 938 | err = cx2341x_ext_ctrls(&p, VIDIOC_S_EXT_CTRLS, cmd); |
941 | if (err == 0 && cmd == VIDIOC_S_EXT_CTRLS) { | 939 | if (err == 0 && cmd == VIDIOC_S_EXT_CTRLS) { |
942 | err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p); | 940 | err = cx2341x_update(dev, blackbird_mbox_func, &dev->params, &p); |
943 | dev->params = p; | 941 | dev->params = p; |
944 | } | 942 | } |
945 | return err; | 943 | return err; |
946 | } | 944 | } |
945 | case VIDIOC_TRY_EXT_CTRLS: | ||
946 | { | ||
947 | struct v4l2_ext_controls *f = arg; | ||
948 | struct cx2341x_mpeg_params p; | ||
949 | int err; | ||
950 | |||
951 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
952 | return -EINVAL; | ||
953 | p = dev->params; | ||
954 | err = cx2341x_ext_ctrls(&p, VIDIOC_TRY_EXT_CTRLS, cmd); | ||
955 | return err; | ||
956 | } | ||
947 | case VIDIOC_S_FREQUENCY: | 957 | case VIDIOC_S_FREQUENCY: |
948 | { | 958 | { |
949 | blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, | 959 | blackbird_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, |
@@ -1006,46 +1016,6 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, | |||
1006 | } | 1016 | } |
1007 | 1017 | ||
1008 | switch (cmd) { | 1018 | switch (cmd) { |
1009 | /* ---------- tv norms ---------- */ | ||
1010 | case VIDIOC_ENUMSTD: | ||
1011 | { | ||
1012 | struct v4l2_standard *e = arg; | ||
1013 | unsigned int i; | ||
1014 | |||
1015 | i = e->index; | ||
1016 | if (i >= ARRAY_SIZE(tvnorms)) | ||
1017 | return -EINVAL; | ||
1018 | err = v4l2_video_std_construct(e, tvnorms[e->index].id, | ||
1019 | tvnorms[e->index].name); | ||
1020 | e->index = i; | ||
1021 | if (err < 0) | ||
1022 | return err; | ||
1023 | return 0; | ||
1024 | } | ||
1025 | case VIDIOC_G_STD: | ||
1026 | { | ||
1027 | v4l2_std_id *id = arg; | ||
1028 | |||
1029 | *id = core->tvnorm; | ||
1030 | return 0; | ||
1031 | } | ||
1032 | case VIDIOC_S_STD: | ||
1033 | { | ||
1034 | v4l2_std_id *id = arg; | ||
1035 | unsigned int i; | ||
1036 | |||
1037 | for(i = 0; i < ARRAY_SIZE(tvnorms); i++) | ||
1038 | if (*id & tvnorms[i].id) | ||
1039 | break; | ||
1040 | if (i == ARRAY_SIZE(tvnorms)) | ||
1041 | return -EINVAL; | ||
1042 | |||
1043 | mutex_lock(&core->lock); | ||
1044 | cx88_set_tvnorm(core,tvnorms[i].id); | ||
1045 | mutex_unlock(&core->lock); | ||
1046 | return 0; | ||
1047 | } | ||
1048 | |||
1049 | /* ------ input switching ---------- */ | 1019 | /* ------ input switching ---------- */ |
1050 | case VIDIOC_ENUMINPUT: | 1020 | case VIDIOC_ENUMINPUT: |
1051 | { | 1021 | { |
@@ -1079,6 +1049,28 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, | |||
1079 | i->std |= tvnorms[n].id; | 1049 | i->std |= tvnorms[n].id; |
1080 | return 0; | 1050 | return 0; |
1081 | } | 1051 | } |
1052 | case VIDIOC_G_CTRL: | ||
1053 | return cx88_get_control(core,arg); | ||
1054 | case VIDIOC_S_CTRL: | ||
1055 | return cx88_set_control(core,arg); | ||
1056 | |||
1057 | case VIDIOC_G_FREQUENCY: | ||
1058 | { | ||
1059 | struct v4l2_frequency *f = arg; | ||
1060 | |||
1061 | memset(f,0,sizeof(*f)); | ||
1062 | |||
1063 | if (UNSET == core->tuner_type) | ||
1064 | return -EINVAL; | ||
1065 | |||
1066 | /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ | ||
1067 | f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
1068 | f->frequency = core->freq; | ||
1069 | |||
1070 | cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f); | ||
1071 | |||
1072 | return 0; | ||
1073 | } | ||
1082 | case VIDIOC_G_INPUT: | 1074 | case VIDIOC_G_INPUT: |
1083 | { | 1075 | { |
1084 | unsigned int *i = arg; | 1076 | unsigned int *i = arg; |
@@ -1100,23 +1092,6 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, | |||
1100 | } | 1092 | } |
1101 | 1093 | ||
1102 | 1094 | ||
1103 | |||
1104 | /* --- controls ---------------------------------------------- */ | ||
1105 | case VIDIOC_QUERYCTRL: | ||
1106 | { | ||
1107 | struct v4l2_queryctrl *qctrl = arg; | ||
1108 | |||
1109 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | ||
1110 | if (unlikely(qctrl->id == 0)) | ||
1111 | return -EINVAL; | ||
1112 | return cx8800_ctrl_query(qctrl); | ||
1113 | } | ||
1114 | case VIDIOC_G_CTRL: | ||
1115 | return cx88_get_control(core,arg); | ||
1116 | case VIDIOC_S_CTRL: | ||
1117 | return cx88_set_control(core,arg); | ||
1118 | |||
1119 | /* --- tuner ioctls ------------------------------------------ */ | ||
1120 | case VIDIOC_G_TUNER: | 1095 | case VIDIOC_G_TUNER: |
1121 | { | 1096 | { |
1122 | struct v4l2_tuner *t = arg; | 1097 | struct v4l2_tuner *t = arg; |
@@ -1149,23 +1124,58 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, | |||
1149 | cx88_set_stereo(core, t->audmode, 1); | 1124 | cx88_set_stereo(core, t->audmode, 1); |
1150 | return 0; | 1125 | return 0; |
1151 | } | 1126 | } |
1152 | case VIDIOC_G_FREQUENCY: | 1127 | /* ---------- tv norms ---------- */ |
1128 | case VIDIOC_S_STD: | ||
1153 | { | 1129 | { |
1154 | struct v4l2_frequency *f = arg; | 1130 | v4l2_std_id *id = arg; |
1155 | 1131 | unsigned int i; | |
1156 | memset(f,0,sizeof(*f)); | ||
1157 | 1132 | ||
1158 | if (UNSET == core->tuner_type) | 1133 | for(i = 0; i < ARRAY_SIZE(tvnorms); i++) |
1134 | if (*id & tvnorms[i].id) | ||
1135 | break; | ||
1136 | if (i == ARRAY_SIZE(tvnorms)) | ||
1159 | return -EINVAL; | 1137 | return -EINVAL; |
1160 | 1138 | ||
1161 | /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */ | 1139 | mutex_lock(&core->lock); |
1162 | f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1140 | cx88_set_tvnorm(core,tvnorms[i].id); |
1163 | f->frequency = core->freq; | 1141 | mutex_unlock(&core->lock); |
1142 | return 0; | ||
1143 | } | ||
1144 | case VIDIOC_ENUMSTD: | ||
1145 | { | ||
1146 | struct v4l2_standard *e = arg; | ||
1147 | unsigned int i; | ||
1164 | 1148 | ||
1165 | cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f); | 1149 | i = e->index; |
1150 | if (i >= ARRAY_SIZE(tvnorms)) | ||
1151 | return -EINVAL; | ||
1152 | err = v4l2_video_std_construct(e, tvnorms[e->index].id, | ||
1153 | tvnorms[e->index].name); | ||
1154 | e->index = i; | ||
1155 | if (err < 0) | ||
1156 | return err; | ||
1157 | return 0; | ||
1158 | } | ||
1159 | case VIDIOC_G_STD: | ||
1160 | { | ||
1161 | v4l2_std_id *id = arg; | ||
1166 | 1162 | ||
1163 | *id = core->tvnorm; | ||
1167 | return 0; | 1164 | return 0; |
1168 | } | 1165 | } |
1166 | |||
1167 | |||
1168 | /* --- controls ---------------------------------------------- */ | ||
1169 | case VIDIOC_QUERYCTRL: | ||
1170 | { | ||
1171 | struct v4l2_queryctrl *qctrl = arg; | ||
1172 | |||
1173 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | ||
1174 | if (unlikely(qctrl->id == 0)) | ||
1175 | return -EINVAL; | ||
1176 | return cx8800_ctrl_query(qctrl); | ||
1177 | } | ||
1178 | /* --- tuner ioctls ------------------------------------------ */ | ||
1169 | case VIDIOC_S_FREQUENCY: | 1179 | case VIDIOC_S_FREQUENCY: |
1170 | { | 1180 | { |
1171 | struct v4l2_frequency *f = arg; | 1181 | struct v4l2_frequency *f = arg; |