dsbr100.c (0612ec48762bf8712db1925b2e67246d2237ebab) | dsbr100.c (5aff308c5e73307fc495b89b6421b491f56d3657) |
---|---|
1/* A driver for the D-Link DSB-R100 USB radio. The R100 plugs 2 into both the USB and an analog audio input, so this thing 3 only deals with initialisation and frequency setting, the 4 audio data has to be handled by a sound driver. 5 6 Major issue: I can't find out where the device reports the signal 7 strength, and indeed the windows software appearantly just looks 8 at the stereo indicator as well. So, scanning will only find --- 19 unchanged lines hidden (view full) --- 28 GNU General Public License for more details. 29 30 You should have received a copy of the GNU General Public License 31 along with this program; if not, write to the Free Software 32 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 33 34 History: 35 | 1/* A driver for the D-Link DSB-R100 USB radio. The R100 plugs 2 into both the USB and an analog audio input, so this thing 3 only deals with initialisation and frequency setting, the 4 audio data has to be handled by a sound driver. 5 6 Major issue: I can't find out where the device reports the signal 7 strength, and indeed the windows software appearantly just looks 8 at the stereo indicator as well. So, scanning will only find --- 19 unchanged lines hidden (view full) --- 28 GNU General Public License for more details. 29 30 You should have received a copy of the GNU General Public License 31 along with this program; if not, write to the Free Software 32 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 33 34 History: 35 |
36 Version 0.41-ac1: 37 Alan Cox: Some cleanups and fixes 38 39 Version 0.41: 40 Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org> 41 |
|
36 Version 0.40: | 42 Version 0.40: |
37 Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing | 43 Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing |
38 39 Version 0.30: 40 Markus: Updates for 2.5.x kernel and more ISO compliant source 41 42 Version 0.25: 43 PSL and Markus: Cleanup, radio now doesn't stop on device close 44 45 Version 0.24: --- 14 unchanged lines hidden (view full) --- 60 Version 0.2: 61 Brad Hards <bradh@dynamite.com.au>: Fixes to make it work as non-module 62 Markus: Copyright clarification 63 64 Version 0.01: Markus: initial release 65 66*/ 67 | 44 45 Version 0.30: 46 Markus: Updates for 2.5.x kernel and more ISO compliant source 47 48 Version 0.25: 49 PSL and Markus: Cleanup, radio now doesn't stop on device close 50 51 Version 0.24: --- 14 unchanged lines hidden (view full) --- 66 Version 0.2: 67 Brad Hards <bradh@dynamite.com.au>: Fixes to make it work as non-module 68 Markus: Copyright clarification 69 70 Version 0.01: Markus: initial release 71 72*/ 73 |
68 | |
69#include <linux/kernel.h> 70#include <linux/module.h> 71#include <linux/init.h> 72#include <linux/slab.h> 73#include <linux/input.h> | 74#include <linux/kernel.h> 75#include <linux/module.h> 76#include <linux/init.h> 77#include <linux/slab.h> 78#include <linux/input.h> |
74#include <linux/videodev.h> | 79#include <linux/videodev2.h> |
75#include <media/v4l2-common.h> 76#include <linux/usb.h> 77#include <linux/smp_lock.h> 78 79/* 80 * Version Information 81 */ | 80#include <media/v4l2-common.h> 81#include <linux/usb.h> 82#include <linux/smp_lock.h> 83 84/* 85 * Version Information 86 */ |
82#define DRIVER_VERSION "v0.40" | 87#include <linux/version.h> /* for KERNEL_VERSION MACRO */ 88 89#define DRIVER_VERSION "v0.41" 90#define RADIO_VERSION KERNEL_VERSION(0,4,1) 91 92static struct v4l2_queryctrl radio_qctrl[] = { 93 { 94 .id = V4L2_CID_AUDIO_MUTE, 95 .name = "Mute", 96 .minimum = 0, 97 .maximum = 1, 98 .default_value = 1, 99 .type = V4L2_CTRL_TYPE_BOOLEAN, 100 } 101}; 102 |
83#define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" 84#define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" 85 86#define DSB100_VENDOR 0x04b4 87#define DSB100_PRODUCT 0x1002 88 89/* Commands the device appears to understand */ 90#define DSB100_TUNE 1 --- 15 unchanged lines hidden (view full) --- 106 unsigned int cmd, unsigned long arg); 107static int usb_dsbr100_open(struct inode *inode, struct file *file); 108static int usb_dsbr100_close(struct inode *inode, struct file *file); 109 110static int radio_nr = -1; 111module_param(radio_nr, int, 0); 112 113/* Data for one (physical) device */ | 103#define DRIVER_AUTHOR "Markus Demleitner <msdemlei@tucana.harvard.edu>" 104#define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver" 105 106#define DSB100_VENDOR 0x04b4 107#define DSB100_PRODUCT 0x1002 108 109/* Commands the device appears to understand */ 110#define DSB100_TUNE 1 --- 15 unchanged lines hidden (view full) --- 126 unsigned int cmd, unsigned long arg); 127static int usb_dsbr100_open(struct inode *inode, struct file *file); 128static int usb_dsbr100_close(struct inode *inode, struct file *file); 129 130static int radio_nr = -1; 131module_param(radio_nr, int, 0); 132 133/* Data for one (physical) device */ |
114typedef struct { | 134struct dsbr100_device { |
115 struct usb_device *usbdev; 116 struct video_device *videodev; 117 unsigned char transfer_buffer[TB_LEN]; 118 int curfreq; 119 int stereo; 120 int users; 121 int removed; | 135 struct usb_device *usbdev; 136 struct video_device *videodev; 137 unsigned char transfer_buffer[TB_LEN]; 138 int curfreq; 139 int stereo; 140 int users; 141 int removed; |
122} dsbr100_device; | 142 int muted; 143}; |
123 124 125/* File system interface */ 126static struct file_operations usb_dsbr100_fops = { 127 .owner = THIS_MODULE, 128 .open = usb_dsbr100_open, 129 .release = usb_dsbr100_close, 130 .ioctl = usb_dsbr100_ioctl, 131 .compat_ioctl = v4l_compat_ioctl32, 132 .llseek = no_llseek, 133}; 134 135/* V4L interface */ 136static struct video_device dsbr100_videodev_template= 137{ 138 .owner = THIS_MODULE, 139 .name = "D-Link DSB-R 100", 140 .type = VID_TYPE_TUNER, | 144 145 146/* File system interface */ 147static struct file_operations usb_dsbr100_fops = { 148 .owner = THIS_MODULE, 149 .open = usb_dsbr100_open, 150 .release = usb_dsbr100_close, 151 .ioctl = usb_dsbr100_ioctl, 152 .compat_ioctl = v4l_compat_ioctl32, 153 .llseek = no_llseek, 154}; 155 156/* V4L interface */ 157static struct video_device dsbr100_videodev_template= 158{ 159 .owner = THIS_MODULE, 160 .name = "D-Link DSB-R 100", 161 .type = VID_TYPE_TUNER, |
141 .hardware = VID_HARDWARE_AZTECH, | |
142 .fops = &usb_dsbr100_fops, 143 .release = video_device_release, 144}; 145 146static struct usb_device_id usb_dsbr100_device_table [] = { 147 { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) }, 148 { } /* Terminating entry */ 149}; --- 6 unchanged lines hidden (view full) --- 156 .probe = usb_dsbr100_probe, 157 .disconnect = usb_dsbr100_disconnect, 158 .id_table = usb_dsbr100_device_table, 159}; 160 161/* Low-level device interface begins here */ 162 163/* switch on radio */ | 162 .fops = &usb_dsbr100_fops, 163 .release = video_device_release, 164}; 165 166static struct usb_device_id usb_dsbr100_device_table [] = { 167 { USB_DEVICE(DSB100_VENDOR, DSB100_PRODUCT) }, 168 { } /* Terminating entry */ 169}; --- 6 unchanged lines hidden (view full) --- 176 .probe = usb_dsbr100_probe, 177 .disconnect = usb_dsbr100_disconnect, 178 .id_table = usb_dsbr100_device_table, 179}; 180 181/* Low-level device interface begins here */ 182 183/* switch on radio */ |
164static int dsbr100_start(dsbr100_device *radio) | 184static int dsbr100_start(struct dsbr100_device *radio) |
165{ 166 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 167 USB_REQ_GET_STATUS, 168 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 169 0x00, 0xC7, radio->transfer_buffer, 8, 300)<0 || 170 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 171 DSB100_ONOFF, 172 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 173 0x01, 0x00, radio->transfer_buffer, 8, 300)<0) 174 return -1; | 185{ 186 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 187 USB_REQ_GET_STATUS, 188 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 189 0x00, 0xC7, radio->transfer_buffer, 8, 300)<0 || 190 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 191 DSB100_ONOFF, 192 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 193 0x01, 0x00, radio->transfer_buffer, 8, 300)<0) 194 return -1; |
195 radio->muted=0; |
|
175 return (radio->transfer_buffer)[0]; 176} 177 178 179/* switch off radio */ | 196 return (radio->transfer_buffer)[0]; 197} 198 199 200/* switch off radio */ |
180static int dsbr100_stop(dsbr100_device *radio) | 201static int dsbr100_stop(struct dsbr100_device *radio) |
181{ 182 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 183 USB_REQ_GET_STATUS, 184 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 185 0x16, 0x1C, radio->transfer_buffer, 8, 300)<0 || 186 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 187 DSB100_ONOFF, 188 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 189 0x00, 0x00, radio->transfer_buffer, 8, 300)<0) 190 return -1; | 202{ 203 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 204 USB_REQ_GET_STATUS, 205 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 206 0x16, 0x1C, radio->transfer_buffer, 8, 300)<0 || 207 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 208 DSB100_ONOFF, 209 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 210 0x00, 0x00, radio->transfer_buffer, 8, 300)<0) 211 return -1; |
212 radio->muted=1; |
|
191 return (radio->transfer_buffer)[0]; 192} 193 194/* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */ | 213 return (radio->transfer_buffer)[0]; 214} 215 216/* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */ |
195static int dsbr100_setfreq(dsbr100_device *radio, int freq) | 217static int dsbr100_setfreq(struct dsbr100_device *radio, int freq) |
196{ 197 freq = (freq/16*80)/1000+856; 198 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 199 DSB100_TUNE, 200 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 201 (freq>>8)&0x00ff, freq&0xff, 202 radio->transfer_buffer, 8, 300)<0 || 203 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), --- 8 unchanged lines hidden (view full) --- 212 return -1; 213 } 214 radio->stereo = ! ((radio->transfer_buffer)[0]&0x01); 215 return (radio->transfer_buffer)[0]; 216} 217 218/* return the device status. This is, in effect, just whether it 219sees a stereo signal or not. Pity. */ | 218{ 219 freq = (freq/16*80)/1000+856; 220 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 221 DSB100_TUNE, 222 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 223 (freq>>8)&0x00ff, freq&0xff, 224 radio->transfer_buffer, 8, 300)<0 || 225 usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), --- 8 unchanged lines hidden (view full) --- 234 return -1; 235 } 236 radio->stereo = ! ((radio->transfer_buffer)[0]&0x01); 237 return (radio->transfer_buffer)[0]; 238} 239 240/* return the device status. This is, in effect, just whether it 241sees a stereo signal or not. Pity. */ |
220static void dsbr100_getstat(dsbr100_device *radio) | 242static void dsbr100_getstat(struct dsbr100_device *radio) |
221{ 222 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 223 USB_REQ_GET_STATUS, 224 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 225 0x00 , 0x24, radio->transfer_buffer, 8, 300)<0) 226 radio->stereo = -1; 227 else 228 radio->stereo = ! (radio->transfer_buffer[0]&0x01); 229} 230 231 232/* USB subsystem interface begins here */ 233 234/* check if the device is present and register with v4l and 235usb if it is */ 236static int usb_dsbr100_probe(struct usb_interface *intf, 237 const struct usb_device_id *id) 238{ | 243{ 244 if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0), 245 USB_REQ_GET_STATUS, 246 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 247 0x00 , 0x24, radio->transfer_buffer, 8, 300)<0) 248 radio->stereo = -1; 249 else 250 radio->stereo = ! (radio->transfer_buffer[0]&0x01); 251} 252 253 254/* USB subsystem interface begins here */ 255 256/* check if the device is present and register with v4l and 257usb if it is */ 258static int usb_dsbr100_probe(struct usb_interface *intf, 259 const struct usb_device_id *id) 260{ |
239 dsbr100_device *radio; | 261 struct dsbr100_device *radio; |
240 | 262 |
241 if (!(radio = kmalloc(sizeof(dsbr100_device), GFP_KERNEL))) | 263 if (!(radio = kmalloc(sizeof(struct dsbr100_device), GFP_KERNEL))) |
242 return -ENOMEM; 243 if (!(radio->videodev = video_device_alloc())) { 244 kfree(radio); 245 return -ENOMEM; 246 } 247 memcpy(radio->videodev, &dsbr100_videodev_template, 248 sizeof(dsbr100_videodev_template)); 249 radio->removed = 0; --- 16 unchanged lines hidden (view full) --- 266if nothing keeps us from doing it. If something is still 267keeping us busy, the release callback of v4l will take care 268of releasing it. stv680.c does not relase its private 269data, so I don't do this here either. Checking out the 270code I'd expect I better did that, but if there's a memory 271leak here it's tiny (~50 bytes per disconnect) */ 272static void usb_dsbr100_disconnect(struct usb_interface *intf) 273{ | 264 return -ENOMEM; 265 if (!(radio->videodev = video_device_alloc())) { 266 kfree(radio); 267 return -ENOMEM; 268 } 269 memcpy(radio->videodev, &dsbr100_videodev_template, 270 sizeof(dsbr100_videodev_template)); 271 radio->removed = 0; --- 16 unchanged lines hidden (view full) --- 288if nothing keeps us from doing it. If something is still 289keeping us busy, the release callback of v4l will take care 290of releasing it. stv680.c does not relase its private 291data, so I don't do this here either. Checking out the 292code I'd expect I better did that, but if there's a memory 293leak here it's tiny (~50 bytes per disconnect) */ 294static void usb_dsbr100_disconnect(struct usb_interface *intf) 295{ |
274 dsbr100_device *radio = usb_get_intfdata(intf); | 296 struct dsbr100_device *radio = usb_get_intfdata(intf); |
275 276 usb_set_intfdata (intf, NULL); 277 if (radio) { 278 video_unregister_device(radio->videodev); 279 radio->videodev = NULL; 280 if (radio->users) { 281 kfree(radio); 282 } else { 283 radio->removed = 1; 284 } 285 } 286} 287 288 289/* Video for Linux interface */ 290 291static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file, 292 unsigned int cmd, void *arg) 293{ | 297 298 usb_set_intfdata (intf, NULL); 299 if (radio) { 300 video_unregister_device(radio->videodev); 301 radio->videodev = NULL; 302 if (radio->users) { 303 kfree(radio); 304 } else { 305 radio->removed = 1; 306 } 307 } 308} 309 310 311/* Video for Linux interface */ 312 313static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file, 314 unsigned int cmd, void *arg) 315{ |
294 dsbr100_device *radio=video_get_drvdata(video_devdata(file)); | 316 struct dsbr100_device *radio=video_get_drvdata(video_devdata(file)); |
295 296 if (!radio) 297 return -EIO; 298 299 switch(cmd) { | 317 318 if (!radio) 319 return -EIO; 320 321 switch(cmd) { |
300 case VIDIOCGCAP: { 301 struct video_capability *v = arg; | 322 case VIDIOC_QUERYCAP: 323 { 324 struct v4l2_capability *v = arg; 325 memset(v,0,sizeof(*v)); 326 strlcpy(v->driver, "dsbr100", sizeof (v->driver)); 327 strlcpy(v->card, "D-Link R-100 USB FM Radio", sizeof (v->card)); 328 sprintf(v->bus_info,"ISA"); 329 v->version = RADIO_VERSION; 330 v->capabilities = V4L2_CAP_TUNER; |
302 | 331 |
303 memset(v, 0, sizeof(*v)); 304 v->type = VID_TYPE_TUNER; 305 v->channels = 1; 306 v->audios = 1; 307 strcpy(v->name, "D-Link R-100 USB FM Radio"); | |
308 return 0; 309 } | 332 return 0; 333 } |
310 case VIDIOCGTUNER: { 311 struct video_tuner *v = arg; | 334 case VIDIOC_G_TUNER: 335 { 336 struct v4l2_tuner *v = arg; |
312 | 337 |
313 dsbr100_getstat(radio); 314 if(v->tuner) /* Only 1 tuner */ | 338 if (v->index > 0) |
315 return -EINVAL; | 339 return -EINVAL; |
340 341 dsbr100_getstat(radio); 342 343 memset(v,0,sizeof(*v)); 344 strcpy(v->name, "FM"); 345 v->type = V4L2_TUNER_RADIO; 346 |
|
316 v->rangelow = FREQ_MIN*FREQ_MUL; 317 v->rangehigh = FREQ_MAX*FREQ_MUL; | 347 v->rangelow = FREQ_MIN*FREQ_MUL; 348 v->rangehigh = FREQ_MAX*FREQ_MUL; |
318 v->flags = VIDEO_TUNER_LOW; 319 v->mode = VIDEO_MODE_AUTO; 320 v->signal = radio->stereo*0x7000; 321 /* Don't know how to get signal strength */ 322 v->flags |= VIDEO_TUNER_STEREO_ON*radio->stereo; 323 strcpy(v->name, "DSB R-100"); 324 return 0; 325 } 326 case VIDIOCSTUNER: { 327 struct video_tuner *v = arg; | 349 v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; 350 v->capability=V4L2_TUNER_CAP_LOW; 351 if(radio->stereo) 352 v->audmode = V4L2_TUNER_MODE_STEREO; 353 else 354 v->audmode = V4L2_TUNER_MODE_MONO; 355 v->signal = 0xFFFF; /* We can't get the signal strength */ |
328 | 356 |
329 if(v->tuner!=0) 330 return -EINVAL; 331 /* Only 1 tuner so no setting needed ! */ | |
332 return 0; 333 } | 357 return 0; 358 } |
334 case VIDIOCGFREQ: { 335 int *freq = arg; | 359 case VIDIOC_S_TUNER: 360 { 361 struct v4l2_tuner *v = arg; |
336 | 362 |
337 if (radio->curfreq==-1) | 363 if (v->index > 0) |
338 return -EINVAL; | 364 return -EINVAL; |
339 *freq = radio->curfreq; | 365 |
340 return 0; 341 } | 366 return 0; 367 } |
342 case VIDIOCSFREQ: { 343 int *freq = arg; | 368 case VIDIOC_S_FREQUENCY: 369 { 370 struct v4l2_frequency *f = arg; |
344 | 371 |
345 radio->curfreq = *freq; | 372 radio->curfreq = f->frequency; |
346 if (dsbr100_setfreq(radio, radio->curfreq)==-1) 347 warn("Set frequency failed"); 348 return 0; 349 } | 373 if (dsbr100_setfreq(radio, radio->curfreq)==-1) 374 warn("Set frequency failed"); 375 return 0; 376 } |
350 case VIDIOCGAUDIO: { 351 struct video_audio *v = arg; | 377 case VIDIOC_G_FREQUENCY: 378 { 379 struct v4l2_frequency *f = arg; |
352 | 380 |
353 memset(v, 0, sizeof(*v)); 354 v->flags |= VIDEO_AUDIO_MUTABLE; 355 v->mode = VIDEO_SOUND_STEREO; 356 v->volume = 1; 357 v->step = 1; 358 strcpy(v->name, "Radio"); | 381 f->type = V4L2_TUNER_RADIO; 382 f->frequency = radio->curfreq; 383 |
359 return 0; 360 } | 384 return 0; 385 } |
361 case VIDIOCSAUDIO: { 362 struct video_audio *v = arg; | 386 case VIDIOC_QUERYCTRL: 387 { 388 struct v4l2_queryctrl *qc = arg; 389 int i; |
363 | 390 |
364 if (v->audio) 365 return -EINVAL; 366 if (v->flags&VIDEO_AUDIO_MUTE) { 367 if (dsbr100_stop(radio)==-1) 368 warn("Radio did not respond properly"); | 391 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { 392 if (qc->id && qc->id == radio_qctrl[i].id) { 393 memcpy(qc, &(radio_qctrl[i]), 394 sizeof(*qc)); 395 return 0; 396 } |
369 } | 397 } |
370 else 371 if (dsbr100_start(radio)==-1) 372 warn("Radio did not respond properly"); 373 return 0; | 398 return -EINVAL; |
374 } | 399 } |
400 case VIDIOC_G_CTRL: 401 { 402 struct v4l2_control *ctrl= arg; 403 404 switch (ctrl->id) { 405 case V4L2_CID_AUDIO_MUTE: 406 ctrl->value=radio->muted; 407 return 0; 408 } 409 return -EINVAL; 410 } 411 case VIDIOC_S_CTRL: 412 { 413 struct v4l2_control *ctrl= arg; 414 415 switch (ctrl->id) { 416 case V4L2_CID_AUDIO_MUTE: 417 if (ctrl->value) { 418 if (dsbr100_stop(radio)==-1) 419 warn("Radio did not respond properly"); 420 } else { 421 if (dsbr100_start(radio)==-1) 422 warn("Radio did not respond properly"); 423 } 424 return 0; 425 } 426 return -EINVAL; 427 } |
|
375 default: | 428 default: |
376 return -ENOIOCTLCMD; | 429 return v4l_compat_translate_ioctl(inode,file,cmd,arg, 430 usb_dsbr100_do_ioctl); |
377 } 378} 379 380static int usb_dsbr100_ioctl(struct inode *inode, struct file *file, 381 unsigned int cmd, unsigned long arg) 382{ 383 return video_usercopy(inode, file, cmd, arg, usb_dsbr100_do_ioctl); 384} 385 386static int usb_dsbr100_open(struct inode *inode, struct file *file) 387{ | 431 } 432} 433 434static int usb_dsbr100_ioctl(struct inode *inode, struct file *file, 435 unsigned int cmd, unsigned long arg) 436{ 437 return video_usercopy(inode, file, cmd, arg, usb_dsbr100_do_ioctl); 438} 439 440static int usb_dsbr100_open(struct inode *inode, struct file *file) 441{ |
388 dsbr100_device *radio=video_get_drvdata(video_devdata(file)); | 442 struct dsbr100_device *radio=video_get_drvdata(video_devdata(file)); |
389 390 radio->users = 1; | 443 444 radio->users = 1; |
445 radio->muted = 1; 446 |
|
391 if (dsbr100_start(radio)<0) { 392 warn("Radio did not start up properly"); 393 radio->users = 0; 394 return -EIO; 395 } 396 dsbr100_setfreq(radio, radio->curfreq); 397 return 0; 398} 399 400static int usb_dsbr100_close(struct inode *inode, struct file *file) 401{ | 447 if (dsbr100_start(radio)<0) { 448 warn("Radio did not start up properly"); 449 radio->users = 0; 450 return -EIO; 451 } 452 dsbr100_setfreq(radio, radio->curfreq); 453 return 0; 454} 455 456static int usb_dsbr100_close(struct inode *inode, struct file *file) 457{ |
402 dsbr100_device *radio=video_get_drvdata(video_devdata(file)); | 458 struct dsbr100_device *radio=video_get_drvdata(video_devdata(file)); |
403 404 if (!radio) 405 return -ENODEV; 406 radio->users = 0; 407 if (radio->removed) { 408 kfree(radio); 409 } 410 return 0; --- 20 unchanged lines hidden --- | 459 460 if (!radio) 461 return -ENODEV; 462 radio->users = 0; 463 if (radio->removed) { 464 kfree(radio); 465 } 466 return 0; --- 20 unchanged lines hidden --- |