/shark/trunk/drivers/usb/serial/pl2303.c |
---|
259,9 → 259,8 |
spin_lock_irqsave(&priv->lock, flags); |
if (!priv->termios_initialized) { |
printk(KERN_INFO "@####### termios initializated\n"); |
*(port->tty->termios) = tty_std_termios; |
port->tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL; |
port->tty->termios->c_cflag = B4800 | CS8 | CREAD | HUPCL | CLOCAL; |
priv->termios_initialized = 1; |
} |
436,7 → 435,6 |
/* Setup termios */ |
if (port->tty) { |
printk(KERN_INFO "#####@ set termios"); |
pl2303_set_termios (port, &tmp_termios); |
} |
/shark/trunk/drivers/usb/serial/usb-serial.c |
---|
434,6 → 434,7 |
int i; |
dbg("%s", __FUNCTION__); |
printk("Returning serial %d ports %d\n", serial->minor, serial->num_ports); |
if (serial == NULL) |
return; |
1228,7 → 1229,7 |
port->dev.release = &port_release; |
snprintf26(&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); |
dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id); |
/*dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id);*/ |
device_register (&port->dev); |
} |
1342,7 → 1343,7 |
usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL; |
usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; |
usb_serial_tty_driver->init_termios = tty_std_termios; |
usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
usb_serial_tty_driver->init_termios.c_cflag = B4800 | CS8 | CREAD | HUPCL | CLOCAL; |
tty_set_operations(usb_serial_tty_driver, &serial_ops); |
result = tty_register_driver(usb_serial_tty_driver); |
if (result) { |
/shark/trunk/drivers/usb/serial/tty_io.c |
---|
54,7 → 54,7 |
struct termios tty_std_termios = { /* for the benefit of tty drivers */ |
.c_iflag = ICRNL | IXON, |
.c_oflag = OPOST | ONLCR, |
.c_cflag = B38400 | CS8 | CREAD | HUPCL, |
.c_cflag = B4800 | CS8 | CREAD | HUPCL, |
.c_lflag = ISIG | ICANON | ECHO | ECHOE | ECHOK | |
ECHOCTL | ECHOKE | IEXTEN, |
.c_cc = INIT_C_CC |
127,14 → 127,40 |
} |
void tty_flip_buffer_push(struct tty_struct *tty) |
/* |
* This routine is called out of the software interrupt to flush data |
* from the flip buffer to the line discipline. |
*/ |
static void flush_to_ldisc(void *private_) |
{ |
printk(KERN_INFO "%c\n", *(tty->flip.char_buf_ptr -1)); |
struct tty_struct *tty = (struct tty_struct *) private_; |
unsigned char *cp; |
char *fp; |
int count; |
if (tty->flip.buf_num) { |
cp = tty->flip.char_buf + TTY_FLIPBUF_SIZE; |
fp = tty->flip.flag_buf + TTY_FLIPBUF_SIZE; |
tty->flip.buf_num = 0; |
tty->flip.char_buf_ptr = tty->flip.char_buf; |
tty->flip.flag_buf_ptr = tty->flip.flag_buf; |
} else { |
cp = tty->flip.char_buf; |
fp = tty->flip.flag_buf; |
tty->flip.buf_num = 1; |
tty->flip.char_buf_ptr = tty->flip.char_buf + TTY_FLIPBUF_SIZE; |
tty->flip.flag_buf_ptr = tty->flip.flag_buf + TTY_FLIPBUF_SIZE; |
} |
count = tty->flip.count; |
tty->flip.count = 0; |
static void flush_to_ldisc(void *private_) |
tty->ldisc.receive_buf(tty, cp, fp, count); |
} |
void tty_flip_buffer_push(struct tty_struct *tty) |
{ |
flush_to_ldisc((void *) tty); |
} |
static struct tty_struct *alloc_tty_struct(void) |
142,8 → 168,8 |
struct tty_struct *tty; |
tty = kmalloc(sizeof(struct tty_struct), GFP_KERNEL); |
// if (tty) |
// memset(tty, 0, sizeof(struct tty_struct)); |
if (tty) |
memset(tty, 0, sizeof(struct tty_struct)); |
return tty; |
} |
178,10 → 204,65 |
extern int serial_open (struct tty_struct *tty, struct file * filp); |
extern int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count); |
struct tty_struct *tty; |
int serial_usbport_open(int port_number) |
static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) |
{ |
const unsigned char *p; |
char *f, flags = TTY_NORMAL; |
int i; |
char buf[64]; |
unsigned long cpuflags; |
if (!tty->read_buf) |
return; |
spin_lock_irqsave(&tty->read_lock, cpuflags); |
i = min(N_TTY_BUF_SIZE - tty->read_cnt, \ |
N_TTY_BUF_SIZE - tty->read_head); |
i = min(count, i); |
memcpy(tty->read_buf + tty->read_head, cp, i); |
tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1); |
tty->read_cnt += i; |
spin_unlock_irqrestore(&tty->read_lock, cpuflags); |
//** for (i=0; i<count; i++) |
//** printk("%c", *(cp+i) ); |
} |
/* |
* Check whether to call the driver.unthrottle function. |
* We test the TTY_THROTTLED bit first so that it always |
* indicates the current state. |
*/ |
static void check_unthrottle(struct tty_struct * tty) |
{ |
if (tty->count && |
test_and_clear_bit(TTY_THROTTLED, &tty->flags) && |
tty->driver->unthrottle) |
tty->driver->unthrottle(tty); |
} |
/* |
* Reset the read buffer counters, clear the flags, |
* and make sure the driver is unthrottled. Called |
* from n_tty_open() and n_tty_flush_buffer(). |
*/ |
static void reset_buffer_flags(struct tty_struct *tty) |
{ |
unsigned long flags; |
spin_lock_irqsave(&tty->read_lock, flags); |
tty->read_head = tty->read_tail = tty->read_cnt = 0; |
spin_unlock_irqrestore(&tty->read_lock, flags); |
tty->canon_head = tty->canon_data = tty->erasing = 0; |
memset(&tty->read_flags, 0, sizeof tty->read_flags); |
check_unthrottle(tty); |
} |
int serial_usbport_open(void **private, int port_number) |
{ |
int retval; |
struct tty_struct *tty; |
tty = alloc_tty_struct(); |
if(!tty) |
goto fail_no_mem; |
188,23 → 269,51 |
initialize_tty_struct (tty); |
tty->termios = malloc (sizeof(struct termios)); |
tty->termios = kmalloc (sizeof(struct termios), GFP_KERNEL); |
*(tty->termios) = tty_std_termios; |
tty->index = port_number; |
tty->ldisc.receive_buf = n_tty_receive_buf; |
if (!tty->read_buf) { |
tty->read_buf = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL); |
if (!tty->read_buf) |
return -ENOMEM; |
} |
memset(tty->read_buf, 0, N_TTY_BUF_SIZE); |
reset_buffer_flags(tty); |
retval = serial_open(tty, NULL); |
*private = (void*)tty; |
return retval; |
fail_no_mem: |
return -ENOMEM; |
} |
int serial_usbport_write(const unsigned char *buf, int count) |
int serial_usbport_write(void *private, const unsigned char *buf, int count) |
{ |
int retval; |
struct tty_struct *tty = (struct tty_struct*) private; |
retval = serial_write(tty, 0, buf, count); |
return retval; |
} |
// printk(KERN_DEBUG "######### retval=%d\n", retval); |
int serial_usbport_read(void *private, char* data_in) |
{ |
char c; |
struct tty_struct *tty = (struct tty_struct*) private; |
unsigned long flags; |
if (tty->read_cnt) |
{ |
c = tty->read_buf[tty->read_tail]; |
tty->read_tail = ((tty->read_tail+1) & \ |
(N_TTY_BUF_SIZE-1)); |
tty->read_cnt--; |
*data_in = c; |
return 1; |
} |
*data_in = 0; |
return 0; |
} |
/shark/trunk/drivers/usb/serial/bus.c |
---|
57,6 → 57,7 |
struct usb_serial_port *port; |
int retval = 0; |
int minor; |
int i; |
port = to_usb_serial_port(dev); |
if (!port) { |
82,6 → 83,8 |
dev_info(&port->serial->dev->dev, |
"%s converter now attached to ttyUSB%d (or usb/tts/%d for devfs)\n", |
driver->name, minor, minor); |
/* for (i=0; i<20; i++) |
printk("ttyusb%d\n", minor);*/ |
exit: |
return retval; |
/shark/trunk/drivers/usb/include/drivers/shark_usbserial26.h |
---|
0,0 → 1,18 |
#ifndef __SHARK_USBSERIAL26_H__ |
#define __SHARK_USBSERIAL26_H__ |
struct shark_tty_usbcom { |
void *tty; |
int port_number; |
}; |
int shark_usb_serial_init(void); |
void shark_usb_serial_close(void); |
int |
shark_usbcom_open(struct shark_tty_usbcom *tty_usb, int port_number); |
char |
shark_usbcom_read(struct shark_tty_usbcom *tty_usb); |
#endif |
/shark/trunk/drivers/usb/include/drivers/shark_pwc26.h |
---|
0,0 → 1,17 |
#ifndef __SHARK_PWC26_H__ |
#define __SHARK_PWC26_H__ |
struct PWC26_DEVICE |
{ |
void* private_data; |
int width; |
int height; |
BYTE* imgptr; |
}; |
void shark_PWC_init(); |
int shark_PWC_read(struct PWC26_DEVICE *pwc26); |
int shark_PWC_open(struct PWC26_DEVICE *pwc26, int width, int height, int fps, int quality, int webcamnr); |
void shark_PWC_close(struct PWC26_DEVICE *pwc26); |
#endif |
/shark/trunk/drivers/usb/shark_glue/shark_usb.c |
---|
9,6 → 9,9 |
extern int uhci_hcd_init(void); |
extern void uhci_hcd_cleanup(void); |
extern int ehci_hcd_init(void); |
extern void ehci_hcd_cleanup(void); |
extern int usb_mouse_init(void); |
extern void usb_mouse_exit(void); |
28,6 → 31,7 |
return 0; |
usb_init(); |
ehci_hcd_init(); |
ohci_hcd_pci_init(); |
uhci_hcd_init(); |
usb_mouse_init(); |
45,6 → 49,7 |
if (usb_installed == FALSE) |
return -1; |
ehci_hcd_cleanup(); |
ohci_hcd_pci_cleanup(); |
uhci_hcd_cleanup(); |
usb_mouse_exit(); |
51,6 → 56,8 |
usb_kbd_exit(); |
hid_exit(); |
usb_exit(); |
usb_installed = FALSE; |
return 0; |
} |
/shark/trunk/drivers/usb/shark_glue/shark_pwc.c |
---|
0,0 → 1,273 |
#include <linuxcomp.h> |
#include <linux/config.h> |
#include <linux/types.h> |
#include <linux/major.h> |
#include <linux/errno.h> |
#include <linux/signal.h> |
#include "media/pwc-ioctl.h" |
#include <linux/videodev.h> |
#include <drivers/shark_pwc26.h> |
/* |
* shark lowlevel wrapper |
*/ |
struct PWC_data { |
struct file* file; |
struct pwc_imagesize RealSize; |
struct pwc_coord m_ViewSize, m_RealSize; |
struct pwc_coord m_Offset; |
struct video_capability Capability; |
struct pwc_probe Probe; |
struct video_picture Picture; |
struct video_window Window; |
struct pwc_video_command VideoCmd; |
void *m_pPWCXBuffer, *m_pInputBuffer, *m_pImageBuffer; |
int m_Frames, len, m_UseRaw, m_ImageSize, m_ImageLen; |
int m_Type, m_Bandlength, m_Bayer; |
int m_InputLen; |
}; |
extern int usb_pwc_init(); |
extern void* malloc(size_t size); |
extern int pwc_video_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg); |
extern int pwc_video_open(struct inode *inode, struct file *file); |
extern int pwc_video_close(struct inode *inode, struct file *file); |
extern ssize_t pwc_video_read(struct file *file, char *buf, size_t count, loff_t *ppos); |
extern int pwc_video_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsigned long arg); |
void shark_PWC_init() |
{ |
usb_pwc_init(); |
} |
int shark_PWC_open(struct PWC26_DEVICE *pwc26, int width, int height, int fps, int quality, int webcamnr) |
{ |
int err; |
struct PWC_data *pwc_data; |
struct file *file; |
struct inode *inode; |
pwc_data = malloc(sizeof(struct PWC_data)); |
pwc26->private_data = (void*)pwc_data; |
if (!pwc_data) |
return -ENOMEM; |
memset(pwc_data, 0, sizeof(struct PWC_data)); |
file = malloc(sizeof(struct file)); |
if (!file) |
return -ENOMEM; |
file->f_dentry= malloc(sizeof(struct dentry)); |
if (!file->f_dentry) |
return -ENOMEM; |
file->f_dentry->d_inode = malloc(sizeof(struct inode)); |
if (!file->f_dentry->d_inode) |
return -ENOMEM; |
file->f_dentry->d_inode->i_rdev = webcamnr; |
inode = file->f_dentry->d_inode; |
pwc_data->file = file; |
pwc_data->m_ViewSize.x = width; |
pwc_data->m_ViewSize.y = height; |
pwc_data->m_Frames = fps; |
pwc_data->m_RealSize = pwc_data->m_ViewSize; |
pwc_data->m_Offset.x = 0; |
pwc_data->m_Offset.y = 0; |
pwc_data->m_UseRaw = TRUE; |
pwc_data->m_Bayer = FALSE; |
pwc_data->m_pInputBuffer = NULL; |
pwc_data->m_InputLen = 0; |
pwc_data->m_pImageBuffer = NULL; |
pwc_data->m_ImageLen = NULL; |
pwc_data->m_Type = NULL; |
pwc_data->m_pPWCXBuffer = malloc(60000); // large enoug for all cams |
if (!pwc_data->m_pPWCXBuffer) |
return -ENOMEM; |
err=pwc_video_open(inode, file); |
if (err <0) |
return err; |
pwc_video_do_ioctl(inode, file, VIDIOCGCAP, &pwc_data->Capability); |
printk(KERN_INFO "Capability->type= %d\n", pwc_data->Capability.type); |
printk(KERN_INFO "Capability->channels =%d\n",pwc_data->Capability.channels); |
printk(KERN_INFO "Capability->audios=%d\n",pwc_data->Capability.audios); |
printk(KERN_INFO "Capability->minwidth=%d\n",pwc_data->Capability.minwidth); |
printk(KERN_INFO "Capability->minheight=%d\n",pwc_data->Capability.minheight); |
printk(KERN_INFO "Capability->maxwidth=%d\n",pwc_data->Capability.maxwidth); |
printk(KERN_INFO "Capability->maxheight=%d\n",pwc_data->Capability.maxheight); |
memset(&pwc_data->Probe, 0, sizeof(pwc_data->Probe)); |
pwc_video_do_ioctl(inode, file, VIDIOCPWCPROBE, &pwc_data->Probe); |
pwc_video_do_ioctl(inode, file, VIDIOCGPICT, &pwc_data->Picture); |
if (pwc_data->m_UseRaw) |
pwc_data->Picture.palette = VIDEO_PALETTE_RAW; |
else |
pwc_data->Picture.palette = VIDEO_PALETTE_YUV420P; |
pwc_video_do_ioctl(inode, file, VIDIOCSPICT, &pwc_data->Picture); |
pwc_video_do_ioctl(inode, file, VIDIOCGWIN, &pwc_data->Window); |
/* unavailable in pwc 10.x */ |
if (pwc_data->m_Bayer) |
{ |
// special raw Bayer mode |
pwc_data->m_ViewSize.x = 640; |
pwc_data->m_ViewSize.y = 480; |
pwc_data->m_Frames = 5; |
pwc_data->m_RealSize = pwc_data->m_ViewSize; |
} |
pwc_data->Window.width = pwc_data->m_ViewSize.x; |
pwc_data->Window.height = pwc_data->m_ViewSize.y; |
pwc_data->Window.flags = (pwc_data->m_Frames << PWC_FPS_SHIFT); |
if (pwc_data->m_Bayer) |
pwc_data->Window.flags |= PWC_FPS_SNAPSHOT; |
pwc_video_do_ioctl(inode, file, VIDIOCSWIN, &pwc_data->Window); |
if (pwc_data->m_UseRaw) |
{ |
pwc_video_do_ioctl(inode, file, VIDIOCPWCGVIDCMD, &pwc_data->VideoCmd); |
pwc_data->m_Type = pwc_data->VideoCmd.type; |
pwc_data->m_InputLen = pwc_data->VideoCmd.frame_size; |
pwc_data->m_Bandlength = pwc_data->VideoCmd.bandlength; |
if (pwc_data->m_Bandlength > 0) |
{ |
switch(pwc_data->m_Type) |
{ |
case 645: |
case 646: |
pwcx_init_decompress_Nala(pwc_data->m_Type, pwc_data->VideoCmd.release, &pwc_data->VideoCmd.command_buf, pwc_data->m_pPWCXBuffer); |
break; |
case 675: |
case 680: |
case 690: |
pwcx_init_decompress_Timon(pwc_data->m_Type, pwc_data->VideoCmd.release, &pwc_data->VideoCmd.command_buf, pwc_data->m_pPWCXBuffer); |
break; |
case 720: |
case 730: |
case 740: |
case 750: |
pwcx_init_decompress_Kiara(pwc_data->m_Type, pwc_data->VideoCmd.release, &pwc_data->VideoCmd.command_buf, pwc_data->m_pPWCXBuffer); |
break; |
default: |
// qDebug("Unknown type of camera (%d)!", VideoCmd.type); |
break; |
} // ..switch |
} // ..m_Bandlength > 0 |
if (pwc_video_do_ioctl(inode, file, VIDIOCPWCGREALSIZE, &pwc_data->RealSize) == 0) |
{ |
pwc_data->m_Offset.x = (pwc_data->m_ViewSize.x - pwc_data->RealSize.width) / 2; |
pwc_data->m_Offset.y = (pwc_data->m_ViewSize.y - pwc_data->RealSize.height) / 2; |
} |
} |
pwc_data->m_ImageLen = pwc_data->m_ViewSize.x * pwc_data->m_ViewSize.y * 3; |
pwc_data->m_pImageBuffer = malloc (pwc_data->m_ImageLen); |
if (pwc_data->m_UseRaw) |
{ |
pwc_data->m_pInputBuffer = malloc(pwc_data->m_InputLen); |
} |
else |
{ |
if (pwc_data->m_pImageBuffer != 0) |
{ |
pwc_data->m_pInputBuffer = pwc_data->m_pImageBuffer; |
pwc_data->m_InputLen = pwc_data->m_ImageLen; |
} |
} |
pwc26->width=pwc_data->m_ViewSize.x ; |
pwc26->height=pwc_data->m_ViewSize.y ; |
pwc26->imgptr=(BYTE*)pwc_data->m_pImageBuffer; |
return 0; |
} |
int shark_PWC_read(struct PWC26_DEVICE *pwc26) |
{ |
int len; |
struct PWC_data *pwc_data = (struct PWC_data*)pwc26->private_data; |
if (pwc_data->m_pInputBuffer == 0 || pwc_data->m_pImageBuffer == 0) |
return -666; |
len = pwc_video_read(pwc_data->file, pwc_data->m_pInputBuffer, pwc_data->m_InputLen, 0); |
if (len > 0 && pwc_data->m_Bandlength > 0) |
{ |
switch(pwc_data->m_Type) |
{ |
case 645: |
case 646: |
pwcx_decompress_Nala(&pwc_data->m_RealSize, &pwc_data->m_ViewSize, &pwc_data->m_Offset, \ |
pwc_data->m_pInputBuffer, pwc_data->m_pImageBuffer, \ |
PWCX_FLAG_PLANAR, \ |
pwc_data->m_pPWCXBuffer, pwc_data->m_Bandlength); |
break; |
case 675: |
case 680: |
case 690: |
pwcx_decompress_Timon(&pwc_data->m_RealSize, &pwc_data->m_ViewSize, &pwc_data->m_Offset, \ |
pwc_data->m_pInputBuffer, pwc_data->m_pImageBuffer, \ |
PWCX_FLAG_PLANAR, \ |
pwc_data->m_pPWCXBuffer, pwc_data->m_Bandlength); |
break; |
case 720: |
case 730: |
case 740: |
case 750: |
pwcx_decompress_Kiara(&pwc_data->m_RealSize, &pwc_data->m_ViewSize, &pwc_data->m_Offset, \ |
pwc_data->m_pInputBuffer, pwc_data->m_pImageBuffer, \ |
PWCX_FLAG_PLANAR | (pwc_data->m_Bayer ? PWCX_FLAG_BAYER : 0), \ |
pwc_data->m_pPWCXBuffer, pwc_data->m_Bandlength); |
break; |
} |
} |
return len; |
} |
void shark_PWC_close(struct PWC26_DEVICE *pwc26) |
{ |
struct file *file; |
struct inode *inode; |
struct PWC_data *pwc_data = (struct PWC_data*)pwc26->private_data; |
if (!pwc_data) |
return; |
free(pwc_data->m_pPWCXBuffer); |
file = pwc_data->file; |
inode = file->f_dentry->d_inode; |
// pwc_video_close(inode, file); |
free(inode); |
free(file->f_dentry); |
free(file); |
free(pwc_data); |
} |
/shark/trunk/drivers/usb/shark_glue/shark_serial.c |
---|
0,0 → 1,56 |
#include <kernel/kern.h> |
#include <drivers/shark_usbserial26.h> |
extern int usb_serial_init(); |
extern void usb_serial_exit(void); |
extern int pl2303_init(); |
extern void pl2303_exit(); |
extern int serial_usbport_open(void *tty, int port_number); |
extern int serial_usbport_write(void *tty, const unsigned char *buf, int count); |
extern int serial_usbport_read(void *private, char* data_in); |
int shark_usb_serial_init() |
{ |
usb_serial_init(); |
pl2303_init(); |
return 0; |
} |
void shark_usb_serial_close() |
{ |
usb_serial_exit(); |
pl2303_exit(); |
} |
int shark_usbcom_open(struct shark_tty_usbcom *tty_usb, int port_number) |
{ |
int retval; |
tty_usb->port_number = port_number; |
retval = serial_usbport_open(&tty_usb->tty, tty_usb->port_number); |
return retval; |
} |
int shark_usbcom_write(struct shark_tty_usbcom *tty_usb, const unsigned char *buf, int count) |
{ |
int retval; |
retval = serial_usbport_write(tty_usb->tty, buf, count); |
return retval; |
} |
char shark_usbcom_read(struct shark_tty_usbcom *tty_usb) |
{ |
int retval; |
char data_in; |
while ((retval = serial_usbport_read(tty_usb->tty, &data_in)) == 0); |
return data_in; |
/* do the hard stuff*/ |
} |
/shark/trunk/drivers/usb/core/hcd.c |
---|
1168,6 → 1168,7 |
struct device *sys = 0; |
unsigned long flags; |
struct completion_splice splice; |
struct list_head *tmp; /* 2.6.1 */ |
int retval; |
if (!urb) |
1206,10 → 1207,22 |
*/ |
WARN_ON (!HCD_IS_RUNNING (hcd->state) && hcd->state != USB_STATE_HALT); |
/* insist the urb is still queued */ |
list_for_each(tmp, &dev->urb_list) { |
if (tmp == &urb->urb_list) |
break; |
} |
if (tmp != &urb->urb_list) { |
retval = -EINVAL; |
goto done; |
} |
/* removed for 2.6.1 |
if (!urb->hcpriv) { |
retval = -EINVAL; |
goto done; |
} |
*/ |
/* Any status except -EINPROGRESS means something already started to |
* unlink this URB from the hardware. So there's no more work to do. |
/shark/trunk/drivers/usb/core/buffer.c |
---|
114,9 → 114,9 |
for (i = 0; i < HCD_BUFFER_POOLS; i++) { |
if (size <= pool_max [i]) |
return pci_pool_alloc (hcd->pool [i], mem_flags, dma); |
return pci_pool_alloc_usb (hcd->pool [i], mem_flags, dma); |
} |
return pci_alloc_consistent (hcd->pdev, size, dma); |
return pci_alloc_consistent_usb (hcd->pdev, size, dma); |
} |
void hcd_buffer_free ( |
/shark/trunk/drivers/usb/core/hub.c |
---|
128,14 → 128,22 |
static void hub_irq(struct urb *urb, struct pt_regs *regs) |
{ |
struct usb_hub *hub = (struct usb_hub *)urb->context; |
unsigned long flags; |
//** unsigned long flags; 2.6.1 |
int status; |
spin_lock(&hub_event_lock); |
hub->urb_active = 0; |
if (hub->urb_complete) { /* disconnect or rmmod */ |
complete(hub->urb_complete); |
goto done; |
} |
switch (urb->status) { |
case -ENOENT: /* synchronous unlink */ |
case -ECONNRESET: /* async unlink */ |
case -ESHUTDOWN: /* hardware going away */ |
return; |
goto done; |
//** return; 2.6.1 |
default: /* presumably an error */ |
/* Cause a hub reset after 10 consecutive errors */ |
153,12 → 161,12 |
hub->nerrors = 0; |
/* Something happened, let khubd figure it out */ |
spin_lock_irqsave(&hub_event_lock, flags); |
//** spin_lock_irqsave(&hub_event_lock, flags); 2.6.1 |
if (list_empty(&hub->event_list)) { |
list_add(&hub->event_list, &hub_event_list); |
wake_up(&khubd_wait); |
} |
spin_unlock_irqrestore(&hub_event_lock, flags); |
//** spin_unlock_irqrestore(&hub_event_lock, flags); 2.6.1 |
resubmit: |
if ((status = usb_submit_urb (hub->urb, GFP_ATOMIC)) != 0 |
165,6 → 173,11 |
/* ENODEV means we raced disconnect() */ |
&& status != -ENODEV) |
dev_err (&hub->intf->dev, "resubmit --> %d\n", urb->status); |
if (status == 0) |
hub->urb_active = 1; |
done: |
spin_unlock(&hub_event_lock); |
} |
/* USB 2.0 spec Section 11.24.2.3 */ |
469,6 → 482,7 |
message = "couldn't submit status urb"; |
goto fail; |
} |
hub->urb_active = 1; |
/* Wake up khubd */ |
wake_up(&khubd_wait); |
487,6 → 501,7 |
static void hub_disconnect(struct usb_interface *intf) |
{ |
struct usb_hub *hub = usb_get_intfdata (intf); |
DECLARE_COMPLETION(urb_complete); |
unsigned long flags; |
if (!hub) |
494,12 → 509,11 |
usb_set_intfdata (intf, NULL); |
spin_lock_irqsave(&hub_event_lock, flags); |
hub->urb_complete = &urb_complete; |
/* Delete it and then reset it */ |
list_del(&hub->event_list); |
INIT_LIST_HEAD(&hub->event_list); |
list_del(&hub->hub_list); |
INIT_LIST_HEAD(&hub->hub_list); |
list_del_init(&hub->event_list); |
list_del_init(&hub->hub_list); |
spin_unlock_irqrestore(&hub_event_lock, flags); |
512,6 → 526,8 |
if (hub->urb) { |
usb_unlink_urb(hub->urb); |
if (hub->urb_active) |
wait_for_completion(&urb_complete); |
usb_free_urb(hub->urb); |
hub->urb = NULL; |
} |
1152,7 → 1168,6 |
// if (current->flags & PF_FREEZE) |
// refrigerator(PF_IOTHREAD); |
} while (!signal_pending(current)); |
printk(KERN_DEBUG "File: %s @hub_thread_exit\n", __FILE__); |
dbg("hub_thread exiting"); |
complete_and_exit(&khubd_exited, 0); |
/shark/trunk/drivers/usb/core/hub.h |
---|
172,6 → 172,8 |
struct usb_hub { |
struct usb_interface *intf; /* the "real" device */ |
struct urb *urb; /* for interrupt polling pipe */ |
struct completion *urb_complete; /* wait for urb to end */ |
unsigned int urb_active:1; |
/* buffer for urb ... 1 bit each for hub and children, rounded up */ |
char (*buffer)[(USB_MAXCHILDREN + 1 + 7) / 8]; |
/shark/trunk/drivers/usb/core/message.c |
---|
26,7 → 26,6 |
static void usb_api_blocking_completion(struct urb *urb, struct pt_regs *regs) |
{ |
//printk(KERN_INFO "api\n"); |
complete((struct completion *)urb->context); |
} |
50,9 → 49,7 |
struct completion done; |
struct timer_list timer; |
int status; |
struct pt_regs *regs; |
init_completion(&done); |
urb->context = &done; |
urb->transfer_flags |= URB_ASYNC_UNLINK; |
318,15 → 315,6 |
int urb_flags; |
int dma; |
{ |
int i; |
for (i=0; i<20; i++) |
{ |
wait_ms26(300); |
printk(KERN_INFO "usb_sg_init!!!!!!!\n"); |
} |
} |
if (!io || !dev || !sg |
|| usb_pipecontrol (pipe) |
|| usb_pipeisoc (pipe) |
1115,7 → 1103,8 |
goto out; |
dev->actconfig = cp; |
if (!configuration) |
//** if (!configuration) 2.6.1 |
if (!cp) |
dev->state = USB_STATE_ADDRESS; |
else { |
dev->state = USB_STATE_CONFIGURED; |
/shark/trunk/drivers/usb/core/usb.c |
---|
95,12 → 95,14 |
if (!driver->probe) |
return error; |
/* driver claim() doesn't yet affect dev->driver... */ |
if (intf->driver) |
return error; |
id = usb_match_id (intf, driver->id_table); |
if (id) { |
dev_dbg (dev, "%s - got id\n", __FUNCTION__); |
down (&driver->serialize); |
error = driver->probe (intf, id); |
up (&driver->serialize); |
} |
if (!error) |
intf->driver = driver; |
111,21 → 113,21 |
int usb_unbind_interface(struct device *dev) |
{ |
struct usb_interface *intf = to_usb_interface(dev); |
struct usb_driver *driver = to_usb_driver(dev->driver); |
struct usb_driver *driver = intf->driver; |
down(&driver->serialize); |
/* release all urbs for this interface */ |
usb_disable_interface(interface_to_usbdev(intf), intf); |
if (intf->driver && intf->driver->disconnect) |
intf->driver->disconnect(intf); |
if (driver && driver->disconnect) |
driver->disconnect(intf); |
/* force a release and re-initialize the interface */ |
usb_driver_release_interface(driver, intf); |
/* reset other interface state */ |
usb_set_interface(interface_to_usbdev(intf), |
intf->altsetting[0].desc.bInterfaceNumber, |
0); |
usb_set_intfdata(intf, NULL); |
intf->driver = NULL; |
up(&driver->serialize); |
return 0; |
} |
272,20 → 274,12 |
if (!iface || !driver) |
return -EINVAL; |
/* this is mainly to lock against usbfs */ |
lock_kernel(); |
if (iface->driver) { |
unlock_kernel(); |
err ("%s driver booted %s off interface %p", |
driver->name, iface->driver->name, iface); |
if (iface->driver) |
return -EBUSY; |
} else { |
dbg("%s driver claimed interface %p", driver->name, iface); |
} |
/* FIXME should device_bind_driver() */ |
iface->driver = driver; |
usb_set_intfdata(iface, priv); |
unlock_kernel(); |
return 0; |
} |
329,9 → 323,15 |
void usb_driver_release_interface(struct usb_driver *driver, struct usb_interface *iface) |
{ |
/* this should never happen, don't release something that's not ours */ |
if (iface->driver && iface->driver != driver) |
if (!iface || !iface->driver || iface->driver != driver) |
return; |
if (iface->dev.driver) { |
/* FIXME should be the ONLY case here */ |
device_release_driver(&iface->dev); |
return; |
} |
usb_set_interface(interface_to_usbdev(iface), |
iface->altsetting[0].desc.bInterfaceNumber, |
0); |
582,7 → 582,7 |
* FIXME reduce hardwired intelligence here |
*/ |
envp [i++] = scratch; |
length += snprintf (scratch, buffer_size - length, |
length += snprintf26 (scratch, buffer_size - length, |
"DEVICE=/proc/bus/usb/%03d/%03d", |
usb_dev->bus->busnum, usb_dev->devnum); |
if ((buffer_size - length <= 0) || (i >= num_envp)) |
593,7 → 593,7 |
/* per-device configurations are common */ |
envp [i++] = scratch; |
length += snprintf (scratch, buffer_size - length, "PRODUCT=%x/%x/%x", |
length += snprintf26 (scratch, buffer_size - length, "PRODUCT=%x/%x/%x", |
usb_dev->descriptor.idVendor, |
usb_dev->descriptor.idProduct, |
usb_dev->descriptor.bcdDevice); |
604,7 → 604,7 |
/* class-based driver binding models */ |
envp [i++] = scratch; |
length += snprintf (scratch, buffer_size - length, "TYPE=%d/%d/%d", |
length += snprintf26 (scratch, buffer_size - length, "TYPE=%d/%d/%d", |
usb_dev->descriptor.bDeviceClass, |
usb_dev->descriptor.bDeviceSubClass, |
usb_dev->descriptor.bDeviceProtocol); |
621,7 → 621,7 |
* $DEVPATH/bInterfaceNumber if necessary. |
*/ |
envp [i++] = scratch; |
length += snprintf (scratch, buffer_size - length, |
length += snprintf26 (scratch, buffer_size - length, |
"INTERFACE=%d/%d/%d", |
intf->altsetting[alt].desc.bInterfaceClass, |
intf->altsetting[alt].desc.bInterfaceSubClass, |
993,7 → 993,9 |
int err = -EINVAL; |
int i; |
int j; |
int config; |
/* |
* Set the driver for the usb device to point to the "generic" driver. |
* This prevents the main usb device from being sent to the usb bus |
1109,21 → 1111,35 |
/* choose and set the configuration. that registers the interfaces |
* with the driver core, and lets usb device drivers bind to them. |
* NOTE: should interact with hub power budgeting. |
*/ |
config = dev->config[0].desc.bConfigurationValue; |
if (dev->descriptor.bNumConfigurations != 1) { |
for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { |
/* heuristic: Linux is more likely to have class |
* drivers, so avoid vendor-specific interfaces. |
*/ |
if (dev->config[i].interface[0]->altsetting |
->desc.bInterfaceClass |
== USB_CLASS_VENDOR_SPEC) |
continue; |
config = dev->config[i].desc.bConfigurationValue; |
break; |
} |
dev_info(&dev->dev, |
"configuration #%d chosen from %d choices\n", |
dev->config[0].desc.bConfigurationValue, |
config, |
dev->descriptor.bNumConfigurations); |
} |
err = usb_set_configuration(dev, |
dev->config[0].desc.bConfigurationValue); |
err = usb_set_configuration(dev, config); |
if (err) { |
dev_err(&dev->dev, "can't set config #%d, error %d\n", |
dev->config[0].desc.bConfigurationValue, err); |
config, err); |
device_del(&dev->dev); |
goto fail; |
} |
/* USB device state == configured ... usable */ |
/* add a /proc/bus/usb entry */ |
/shark/trunk/drivers/usb/host/ohci-mem.c |
---|
13,7 → 13,7 |
* There's basically three types of memory: |
* - data used only by the HCD ... kmalloc is fine |
* - async and periodic schedules, shared by HC and HCD ... these |
* need to use pci_pool or pci_alloc_consistent |
* need to use pci_pool or pci_alloc_consistent_usb |
* - driver buffers, read/written by HC ... the hcd glue or the |
* device driver provides us with dma addresses |
* |
96,7 → 96,7 |
dma_addr_t dma; |
struct td *td; |
td = pci_pool_alloc (hc->td_cache, mem_flags, &dma); |
td = pci_pool_alloc_usb (hc->td_cache, mem_flags, &dma); |
if (td) { |
/* in case hc fetches it, make it look dead */ |
memset (td, 0, sizeof *td); |
130,7 → 130,7 |
dma_addr_t dma; |
struct ed *ed; |
ed = pci_pool_alloc (hc->ed_cache, mem_flags, &dma); |
ed = pci_pool_alloc_usb (hc->ed_cache, mem_flags, &dma); |
if (ed) { |
memset (ed, 0, sizeof (*ed)); |
INIT_LIST_HEAD (&ed->td_list); |
/shark/trunk/drivers/usb/host/ehci-hcd.c |
---|
121,8 → 121,10 |
/* Initial IRQ latency: lower than default */ |
static int log2_irq_thresh = 0; // 0 to 6 |
module_param (log2_irq_thresh, int, S_IRUGO); |
/*module_param (log2_irq_thresh, int, S_IRUGO); |
MODULE_PARM_DESC (log2_irq_thresh, "log2 IRQ latency, 1-64 microframes"); |
*/ |
#define INTR_MASK (STS_IAA | STS_FATAL | STS_ERR | STS_INT) |
483,7 → 485,7 |
* involved with the root hub. |
*/ |
ehci->reboot_notifier.notifier_call = ehci_reboot; |
register_reboot_notifier (&ehci->reboot_notifier); |
// register_reboot_notifier (&ehci->reboot_notifier); |
ehci->hcd.state = USB_STATE_RUNNING; |
writel (FLAG_CF, &ehci->regs->configured_flag); |
540,7 → 542,7 |
/* let companion controllers work when we aren't */ |
writel (0, &ehci->regs->configured_flag); |
unregister_reboot_notifier (&ehci->reboot_notifier); |
// unregister_reboot_notifier (&ehci->reboot_notifier); |
remove_debug_files (ehci); |
1011,7 → 1013,7 |
MODULE_AUTHOR (DRIVER_AUTHOR); |
MODULE_LICENSE ("GPL"); |
static int __init init (void) |
/*static*/ int __init ehci_hcd_init (void) |
{ |
if (usb_disabled()) |
return -ENODEV; |
1023,10 → 1025,10 |
return pci_module_init (&ehci_pci_driver); |
} |
module_init (init); |
//module_init (init); |
static void __exit cleanup (void) |
/*static*/ void __exit ehci_hcd_cleanup (void) |
{ |
pci_unregister_driver (&ehci_pci_driver); |
} |
module_exit (cleanup); |
//module_exit (cleanup); |
/shark/trunk/drivers/usb/host/ehci.h |
---|
134,7 → 134,7 |
t = EHCI_SHRINK_JIFFIES; |
break; |
} |
t += jiffies; |
t += jiffies26; |
// all timings except IAA watchdog can be overridden. |
// async queue SHRINK often precedes IAA. while it's ready |
// to go OFF neither can matter, and afterwards the IO |
/shark/trunk/drivers/usb/host/ohci-hcd.c |
---|
40,7 → 40,7 |
* 2001/03/24 td/ed hashing to remove bus_to_virt (Steve Longerbeam); |
pci_map_single (db) |
* 2001/03/21 td and dev/ed allocation uses new pci_pool API (db) |
* 2001/03/07 hcca allocation uses pci_alloc_consistent (Steve Longerbeam) |
* 2001/03/07 hcca allocation uses pci_alloc_consistent_usb (Steve Longerbeam) |
* |
* 2000/09/26 fixed races in removing the private portion of the urb |
* 2000/09/07 disable bulk and control lists when unlinking the last |
/shark/trunk/drivers/usb/host/uhci-hcd.c |
---|
145,7 → 145,7 |
dma_addr_t dma_handle; |
struct uhci_td *td; |
td = pci_pool_alloc(uhci->td_pool, GFP_ATOMIC, &dma_handle); |
td = pci_pool_alloc_usb(uhci->td_pool, GFP_ATOMIC, &dma_handle); |
if (!td) |
return NULL; |
305,7 → 305,7 |
dma_addr_t dma_handle; |
struct uhci_qh *qh; |
qh = pci_pool_alloc(uhci->qh_pool, GFP_ATOMIC, &dma_handle); |
qh = pci_pool_alloc_usb(uhci->qh_pool, GFP_ATOMIC, &dma_handle); |
if (!qh) |
return NULL; |
2208,6 → 2208,11 |
uhci->io_addr = (unsigned long) hcd->regs; |
/* Turn off all interrupts 2.6.1 */ |
outw(0, uhci->io_addr + USBINTR); |
/* Maybe kick BIOS off this hardware. Then reset, so we won't get |
* interrupts from any previous setup. |
*/ |
2280,7 → 2285,7 |
spin_lock_init(&uhci->frame_list_lock); |
uhci->fl = pci_alloc_consistent(hcd->pdev, sizeof(*uhci->fl), &dma_handle); |
uhci->fl = pci_alloc_consistent_usb(hcd->pdev, sizeof(*uhci->fl), &dma_handle); |
if (!uhci->fl) { |
err("unable to allocate consistent memory for frame list"); |
goto err_alloc_fl; |
/shark/trunk/drivers/usb/host/ehci-mem.c |
---|
24,7 → 24,7 |
* There's basically three types of memory: |
* - data used only by the HCD ... kmalloc is fine |
* - async and periodic schedules, shared by HC and HCD ... these |
* need to use pci_pool or pci_alloc_consistent |
* need to use pci_pool or pci_alloc_consistent_usb |
* - driver buffers, read/written by HC ... single shot DMA mapped |
* |
* There's also PCI "register" data, which is memory mapped. |
74,7 → 74,7 |
struct ehci_qtd *qtd; |
dma_addr_t dma; |
qtd = pci_pool_alloc (ehci->qtd_pool, flags, &dma); |
qtd = pci_pool_alloc_usb (ehci->qtd_pool, flags, &dma); |
if (qtd != 0) { |
ehci_qtd_init (qtd, dma); |
} |
93,7 → 93,7 |
dma_addr_t dma; |
qh = (struct ehci_qh *) |
pci_pool_alloc (ehci->qh_pool, flags, &dma); |
pci_pool_alloc_usb (ehci->qh_pool, flags, &dma); |
if (!qh) |
return qh; |
224,7 → 224,7 |
/* Hardware periodic table */ |
ehci->periodic = (u32 *) |
pci_alloc_consistent (ehci->hcd.pdev, |
pci_alloc_consistent_usb (ehci->hcd.pdev, |
ehci->periodic_size * sizeof (u32), |
&ehci->periodic_dma); |
if (ehci->periodic == 0) { |
/shark/trunk/drivers/usb/host/ohci-pci.c |
---|
46,7 → 46,7 |
int ret; |
if (hcd->pdev) { |
ohci->hcca = pci_alloc_consistent (hcd->pdev, |
ohci->hcca = pci_alloc_consistent_usb (hcd->pdev, |
sizeof *ohci->hcca, &ohci->hcca_dma); |
if (!ohci->hcca) |
/shark/trunk/drivers/usb/host/ehci-sched.c |
---|
626,7 → 626,7 |
for (frame_index = 0, first_itd = 0; |
frame_index < urb->number_of_packets; |
frame_index++) { |
itd = pci_pool_alloc (ehci->itd_pool, mem_flags, &itd_dma); |
itd = pci_pool_alloc_usb (ehci->itd_pool, mem_flags, &itd_dma); |
if (!itd) { |
status = -ENOMEM; |
goto fail; |