Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (5534): Radio-rtrack2.c Replace rt_ioctl to use video_ioctl2

Convert radio-rtrack2 to use video_ioctl2

Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by

Douglas Landgraf and committed by
Mauro Carvalho Chehab
25f30389 941491f3

+120 -123
+120 -123
drivers/media/radio/radio-rtrack2.c
··· 122 122 return 0; 123 123 } 124 124 125 + static int vidioc_querycap(struct file *file, void *priv, 126 + struct v4l2_capability *v) 127 + { 128 + strlcpy(v->driver, "radio-rtrack2", sizeof(v->driver)); 129 + strlcpy(v->card, "RadioTrack II", sizeof(v->card)); 130 + sprintf(v->bus_info, "ISA"); 131 + v->version = RADIO_VERSION; 132 + v->capabilities = V4L2_CAP_TUNER; 133 + return 0; 134 + } 135 + 136 + static int vidioc_s_tuner(struct file *file, void *priv, 137 + struct v4l2_tuner *v) 138 + { 139 + if (v->index > 0) 140 + return -EINVAL; 141 + 142 + return 0; 143 + } 144 + 125 145 static int rt_getsigstr(struct rt_device *dev) 126 146 { 127 147 if (inb(io) & 2) /* bit set = no signal present */ ··· 149 129 return 1; /* signal present */ 150 130 } 151 131 152 - static int rt_do_ioctl(struct inode *inode, struct file *file, 153 - unsigned int cmd, void *arg) 132 + static int vidioc_g_tuner(struct file *file, void *priv, 133 + struct v4l2_tuner *v) 154 134 { 155 135 struct video_device *dev = video_devdata(file); 156 - struct rt_device *rt=dev->priv; 136 + struct rt_device *rt = dev->priv; 157 137 158 - switch(cmd) 159 - { 160 - case VIDIOC_QUERYCAP: 161 - { 162 - struct v4l2_capability *v = arg; 163 - memset(v,0,sizeof(*v)); 164 - strlcpy(v->driver, "radio-rtrack2", sizeof (v->driver)); 165 - strlcpy(v->card, "RadioTrack II", sizeof (v->card)); 166 - sprintf(v->bus_info,"ISA"); 167 - v->version = RADIO_VERSION; 168 - v->capabilities = V4L2_CAP_TUNER; 138 + if (v->index > 0) 139 + return -EINVAL; 169 140 170 - return 0; 171 - } 172 - case VIDIOC_G_TUNER: 173 - { 174 - struct v4l2_tuner *v = arg; 175 - 176 - if (v->index > 0) 177 - return -EINVAL; 178 - 179 - memset(v,0,sizeof(*v)); 180 - strcpy(v->name, "FM"); 181 - v->type = V4L2_TUNER_RADIO; 182 - 183 - v->rangelow=(88*16000); 184 - v->rangehigh=(108*16000); 185 - v->rxsubchans =V4L2_TUNER_SUB_MONO; 186 - v->capability=V4L2_TUNER_CAP_LOW; 187 - v->audmode = V4L2_TUNER_MODE_MONO; 188 - v->signal=0xFFFF*rt_getsigstr(rt); 189 - 190 - return 0; 191 - } 192 - case VIDIOC_S_TUNER: 193 - { 194 - struct v4l2_tuner *v = arg; 195 - 196 - if (v->index > 0) 197 - return -EINVAL; 198 - 199 - return 0; 200 - } 201 - case VIDIOC_S_FREQUENCY: 202 - { 203 - struct v4l2_frequency *f = arg; 204 - 205 - rt->curfreq = f->frequency; 206 - rt_setfreq(rt, rt->curfreq); 207 - return 0; 208 - } 209 - case VIDIOC_G_FREQUENCY: 210 - { 211 - struct v4l2_frequency *f = arg; 212 - 213 - f->type = V4L2_TUNER_RADIO; 214 - f->frequency = rt->curfreq; 215 - 216 - return 0; 217 - } 218 - case VIDIOC_QUERYCTRL: 219 - { 220 - struct v4l2_queryctrl *qc = arg; 221 - int i; 222 - 223 - for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 224 - if (qc->id && qc->id == radio_qctrl[i].id) { 225 - memcpy(qc, &(radio_qctrl[i]), 226 - sizeof(*qc)); 227 - return (0); 228 - } 229 - } 230 - return -EINVAL; 231 - } 232 - case VIDIOC_G_CTRL: 233 - { 234 - struct v4l2_control *ctrl= arg; 235 - 236 - switch (ctrl->id) { 237 - case V4L2_CID_AUDIO_MUTE: 238 - ctrl->value=rt->muted; 239 - return (0); 240 - case V4L2_CID_AUDIO_VOLUME: 241 - if (rt->muted) 242 - ctrl->value=0; 243 - else 244 - ctrl->value=65535; 245 - return (0); 246 - } 247 - return -EINVAL; 248 - } 249 - case VIDIOC_S_CTRL: 250 - { 251 - struct v4l2_control *ctrl= arg; 252 - 253 - switch (ctrl->id) { 254 - case V4L2_CID_AUDIO_MUTE: 255 - if (ctrl->value) { 256 - rt_mute(rt); 257 - } else { 258 - rt_unmute(rt); 259 - } 260 - return (0); 261 - case V4L2_CID_AUDIO_VOLUME: 262 - if (ctrl->value) { 263 - rt_unmute(rt); 264 - } else { 265 - rt_mute(rt); 266 - } 267 - return (0); 268 - } 269 - return -EINVAL; 270 - } 271 - default: 272 - return v4l_compat_translate_ioctl(inode,file,cmd,arg, 273 - rt_do_ioctl); 274 - } 141 + strcpy(v->name, "FM"); 142 + v->type = V4L2_TUNER_RADIO; 143 + v->rangelow = (88*16000); 144 + v->rangehigh = (108*16000); 145 + v->rxsubchans = V4L2_TUNER_SUB_MONO; 146 + v->capability = V4L2_TUNER_CAP_LOW; 147 + v->audmode = V4L2_TUNER_MODE_MONO; 148 + v->signal = 0xFFFF*rt_getsigstr(rt); 149 + return 0; 275 150 } 276 151 277 - static int rt_ioctl(struct inode *inode, struct file *file, 278 - unsigned int cmd, unsigned long arg) 152 + static int vidioc_s_frequency(struct file *file, void *priv, 153 + struct v4l2_frequency *f) 279 154 { 280 - return video_usercopy(inode, file, cmd, arg, rt_do_ioctl); 155 + struct video_device *dev = video_devdata(file); 156 + struct rt_device *rt = dev->priv; 157 + 158 + rt->curfreq = f->frequency; 159 + rt_setfreq(rt, rt->curfreq); 160 + return 0; 161 + } 162 + 163 + static int vidioc_g_frequency(struct file *file, void *priv, 164 + struct v4l2_frequency *f) 165 + { 166 + struct video_device *dev = video_devdata(file); 167 + struct rt_device *rt = dev->priv; 168 + 169 + f->type = V4L2_TUNER_RADIO; 170 + f->frequency = rt->curfreq; 171 + return 0; 172 + } 173 + 174 + static int vidioc_queryctrl(struct file *file, void *priv, 175 + struct v4l2_queryctrl *qc) 176 + { 177 + int i; 178 + 179 + for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 180 + if (qc->id && qc->id == radio_qctrl[i].id) { 181 + memcpy(qc, &(radio_qctrl[i]), 182 + sizeof(*qc)); 183 + return 0; 184 + } 185 + } 186 + return -EINVAL; 187 + } 188 + 189 + static int vidioc_g_ctrl(struct file *file, void *priv, 190 + struct v4l2_control *ctrl) 191 + { 192 + struct video_device *dev = video_devdata(file); 193 + struct rt_device *rt = dev->priv; 194 + 195 + switch (ctrl->id) { 196 + case V4L2_CID_AUDIO_MUTE: 197 + ctrl->value = rt->muted; 198 + return 0; 199 + case V4L2_CID_AUDIO_VOLUME: 200 + if (rt->muted) 201 + ctrl->value = 0; 202 + else 203 + ctrl->value = 65535; 204 + return 0; 205 + } 206 + return -EINVAL; 207 + } 208 + 209 + static int vidioc_s_ctrl(struct file *file, void *priv, 210 + struct v4l2_control *ctrl) 211 + { 212 + struct video_device *dev = video_devdata(file); 213 + struct rt_device *rt = dev->priv; 214 + 215 + switch (ctrl->id) { 216 + case V4L2_CID_AUDIO_MUTE: 217 + if (ctrl->value) 218 + rt_mute(rt); 219 + else 220 + rt_unmute(rt); 221 + return 0; 222 + case V4L2_CID_AUDIO_VOLUME: 223 + if (ctrl->value) 224 + rt_unmute(rt); 225 + else 226 + rt_mute(rt); 227 + return 0; 228 + } 229 + return -EINVAL; 281 230 } 282 231 283 232 static struct rt_device rtrack2_unit; ··· 255 266 .owner = THIS_MODULE, 256 267 .open = video_exclusive_open, 257 268 .release = video_exclusive_release, 258 - .ioctl = rt_ioctl, 269 + .ioctl = video_ioctl2, 259 270 .compat_ioctl = v4l_compat_ioctl32, 260 271 .llseek = no_llseek, 261 272 }; ··· 267 278 .type = VID_TYPE_TUNER, 268 279 .hardware = 0, 269 280 .fops = &rtrack2_fops, 281 + .vidioc_querycap = vidioc_querycap, 282 + .vidioc_g_tuner = vidioc_g_tuner, 283 + .vidioc_s_tuner = vidioc_s_tuner, 284 + .vidioc_g_frequency = vidioc_g_frequency, 285 + .vidioc_s_frequency = vidioc_s_frequency, 286 + .vidioc_queryctrl = vidioc_queryctrl, 287 + .vidioc_g_ctrl = vidioc_g_ctrl, 288 + .vidioc_s_ctrl = vidioc_s_ctrl, 270 289 }; 271 290 272 291 static int __init rtrack2_init(void)