Re: [PATCH] V4L Driver for AVerMedia USB FM Radio
Oliver Neukum <[email protected]>
| Newsgroups | gmane.linux.usb.devel,gmane.comp.video.video4linux |
|---|---|
| Message-ID | <[email protected]> |
Am Donnerstag 11 Oktober 2007 schrieb Faidon Liambotis: > Add a Video4Linux driver for AVerMedia's USB FM radio. > > Signed-off-by: Faidon Liambotis <[email protected]> > --- +/* Low-level device interface begins here */ +static int amusb_command_raw(struct amusb_device *radio, char cmd, char arg, + int args, int extrabytes) +{ + int retv, wrotelen; + char b[8] = { + 0x00, 0x55, 0xaa, + args, + cmd, arg, + 0x00, + extrabytes + }; + + retv = usb_bulk_msg(radio->usbdev, usb_sndbulkpipe(radio->usbdev, 0x02), + b, sizeof(b), &wrotelen, 300); You are doing DMA on the stack. You must allocate b with kmalloc(). +/* set a frequency, freq is defined by v4l's TUNER_LOW, i.e. 1/16th kHz */ +static int amusb_setfreq(struct amusb_device *radio, int freq) +{ + char b[3]; + + radio->curfreq = freq; + freq = (freq + FREQ_MAGIC_OFFSET) / 200; /* V4L -> tuner frequency */ + + b[0] = (freq >> 8) & 0xff; + b[1] = freq & 0xff; 1. Again DMA on the stack 2. Please use cpu_to_le16 +/* return the current frequency */ +static int amusb_getfreq(struct amusb_device *radio) +{ + int retv, f; + unsigned char b[8]; + retv = amusb_function(radio, AMUSB_GET_FREQ, 0, b, 8); + if (retv < 8) + return retv; + + f = b[1] * 0xff + b[2]; Please use le16_to_cpu() +/* Video4Linux v2 interface */ +static int usb_amusb_do_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, void *arg) +{ + struct amusb_device *radio = video_get_drvdata(video_devdata(file)); + + if (!radio) + return -EIO; Better -ENODEV. There's no use hiding the reason Regards Oliver ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel