Lines Matching refs:dev

78 	struct ufx_data *dev;  member
134 static struct urb *ufx_get_urb(struct ufx_data *dev);
135 static int ufx_submit_urb(struct ufx_data *dev, struct urb * urb, size_t len);
136 static int ufx_alloc_urb_list(struct ufx_data *dev, int count, size_t size);
137 static void ufx_free_urb_list(struct ufx_data *dev);
142 static int ufx_reg_read(struct ufx_data *dev, u32 index, u32 *data) in ufx_reg_read() argument
147 BUG_ON(!dev); in ufx_reg_read()
152 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), in ufx_reg_read()
168 static int ufx_reg_write(struct ufx_data *dev, u32 index, u32 data) in ufx_reg_write() argument
173 BUG_ON(!dev); in ufx_reg_write()
181 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), in ufx_reg_write()
195 static int ufx_reg_clear_and_set_bits(struct ufx_data *dev, u32 index, in ufx_reg_clear_and_set_bits() argument
199 int status = ufx_reg_read(dev, index, &data); in ufx_reg_clear_and_set_bits()
206 status = ufx_reg_write(dev, index, data); in ufx_reg_clear_and_set_bits()
213 static int ufx_reg_set_bits(struct ufx_data *dev, u32 index, u32 bits) in ufx_reg_set_bits() argument
215 return ufx_reg_clear_and_set_bits(dev, index, 0, bits); in ufx_reg_set_bits()
218 static int ufx_reg_clear_bits(struct ufx_data *dev, u32 index, u32 bits) in ufx_reg_clear_bits() argument
220 return ufx_reg_clear_and_set_bits(dev, index, bits, 0); in ufx_reg_clear_bits()
223 static int ufx_lite_reset(struct ufx_data *dev) in ufx_lite_reset() argument
228 status = ufx_reg_write(dev, 0x3008, 0x00000001); in ufx_lite_reset()
231 status = ufx_reg_read(dev, 0x3008, &value); in ufx_lite_reset()
238 static int ufx_blank(struct ufx_data *dev, bool wait) in ufx_blank() argument
243 int status = ufx_reg_read(dev, 0x2004, &dc_sts); in ufx_blank()
246 status = ufx_reg_read(dev, 0x2000, &dc_ctrl); in ufx_blank()
255 status = ufx_reg_write(dev, 0x2000, dc_ctrl); in ufx_blank()
263 status = ufx_reg_read(dev, 0x2004, &dc_sts); in ufx_blank()
275 static int ufx_unblank(struct ufx_data *dev, bool wait) in ufx_unblank() argument
280 int status = ufx_reg_read(dev, 0x2004, &dc_sts); in ufx_unblank()
283 status = ufx_reg_read(dev, 0x2000, &dc_ctrl); in ufx_unblank()
292 status = ufx_reg_write(dev, 0x2000, dc_ctrl); in ufx_unblank()
300 status = ufx_reg_read(dev, 0x2004, &dc_sts); in ufx_unblank()
312 static int ufx_disable(struct ufx_data *dev, bool wait) in ufx_disable() argument
317 int status = ufx_reg_read(dev, 0x2004, &dc_sts); in ufx_disable()
320 status = ufx_reg_read(dev, 0x2000, &dc_ctrl); in ufx_disable()
329 status = ufx_reg_write(dev, 0x2000, dc_ctrl); in ufx_disable()
337 status = ufx_reg_read(dev, 0x2004, &dc_sts); in ufx_disable()
349 static int ufx_enable(struct ufx_data *dev, bool wait) in ufx_enable() argument
354 int status = ufx_reg_read(dev, 0x2004, &dc_sts); in ufx_enable()
357 status = ufx_reg_read(dev, 0x2000, &dc_ctrl); in ufx_enable()
366 status = ufx_reg_write(dev, 0x2000, dc_ctrl); in ufx_enable()
374 status = ufx_reg_read(dev, 0x2004, &dc_sts); in ufx_enable()
385 static int ufx_config_sys_clk(struct ufx_data *dev) in ufx_config_sys_clk() argument
387 int status = ufx_reg_write(dev, 0x700C, 0x8000000F); in ufx_config_sys_clk()
390 status = ufx_reg_write(dev, 0x7014, 0x0010024F); in ufx_config_sys_clk()
393 status = ufx_reg_write(dev, 0x7010, 0x00000000); in ufx_config_sys_clk()
396 status = ufx_reg_clear_bits(dev, 0x700C, 0x0000000A); in ufx_config_sys_clk()
400 status = ufx_reg_clear_bits(dev, 0x700C, 0x80000000); in ufx_config_sys_clk()
406 static int ufx_config_ddr2(struct ufx_data *dev) in ufx_config_ddr2() argument
411 status = ufx_reg_write(dev, 0x0004, 0x001F0F77); in ufx_config_ddr2()
414 status = ufx_reg_write(dev, 0x0008, 0xFFF00000); in ufx_config_ddr2()
417 status = ufx_reg_write(dev, 0x000C, 0x0FFF2222); in ufx_config_ddr2()
420 status = ufx_reg_write(dev, 0x0010, 0x00030814); in ufx_config_ddr2()
423 status = ufx_reg_write(dev, 0x0014, 0x00500019); in ufx_config_ddr2()
426 status = ufx_reg_write(dev, 0x0018, 0x020D0F15); in ufx_config_ddr2()
429 status = ufx_reg_write(dev, 0x001C, 0x02532305); in ufx_config_ddr2()
432 status = ufx_reg_write(dev, 0x0020, 0x0B030905); in ufx_config_ddr2()
435 status = ufx_reg_write(dev, 0x0024, 0x00000827); in ufx_config_ddr2()
438 status = ufx_reg_write(dev, 0x0028, 0x00000000); in ufx_config_ddr2()
441 status = ufx_reg_write(dev, 0x002C, 0x00000042); in ufx_config_ddr2()
444 status = ufx_reg_write(dev, 0x0030, 0x09520000); in ufx_config_ddr2()
447 status = ufx_reg_write(dev, 0x0034, 0x02223314); in ufx_config_ddr2()
450 status = ufx_reg_write(dev, 0x0038, 0x00430043); in ufx_config_ddr2()
453 status = ufx_reg_write(dev, 0x003C, 0xF00F000F); in ufx_config_ddr2()
456 status = ufx_reg_write(dev, 0x0040, 0xF380F00F); in ufx_config_ddr2()
459 status = ufx_reg_write(dev, 0x0044, 0xF00F0496); in ufx_config_ddr2()
462 status = ufx_reg_write(dev, 0x0048, 0x03080406); in ufx_config_ddr2()
465 status = ufx_reg_write(dev, 0x004C, 0x00001000); in ufx_config_ddr2()
468 status = ufx_reg_write(dev, 0x005C, 0x00000007); in ufx_config_ddr2()
471 status = ufx_reg_write(dev, 0x0100, 0x54F00012); in ufx_config_ddr2()
474 status = ufx_reg_write(dev, 0x0104, 0x00004012); in ufx_config_ddr2()
477 status = ufx_reg_write(dev, 0x0118, 0x40404040); in ufx_config_ddr2()
480 status = ufx_reg_write(dev, 0x0000, 0x00000001); in ufx_config_ddr2()
484 status = ufx_reg_read(dev, 0x0000, &tmp); in ufx_config_ddr2()
614 static int ufx_config_pix_clk(struct ufx_data *dev, u32 pixclock) in ufx_config_pix_clk() argument
630 status = ufx_reg_write(dev, 0x7000, 0x8000000F); in ufx_config_pix_clk()
635 status = ufx_reg_write(dev, 0x7008, value); in ufx_config_pix_clk()
640 status = ufx_reg_write(dev, 0x7004, value); in ufx_config_pix_clk()
643 status = ufx_reg_clear_bits(dev, 0x7000, 0x00000005); in ufx_config_pix_clk()
648 status = ufx_reg_clear_bits(dev, 0x7000, 0x0000000A); in ufx_config_pix_clk()
653 status = ufx_reg_clear_bits(dev, 0x7000, 0x80000000); in ufx_config_pix_clk()
659 static int ufx_set_vid_mode(struct ufx_data *dev, struct fb_var_screeninfo *var) in ufx_set_vid_mode() argument
665 int status = ufx_reg_write(dev, 0x8028, 0); in ufx_set_vid_mode()
668 status = ufx_reg_write(dev, 0x8024, 0); in ufx_set_vid_mode()
672 status = ufx_blank(dev, true); in ufx_set_vid_mode()
675 status = ufx_disable(dev, true); in ufx_set_vid_mode()
678 status = ufx_config_pix_clk(dev, var->pixclock); in ufx_set_vid_mode()
681 status = ufx_reg_write(dev, 0x2000, 0x00000104); in ufx_set_vid_mode()
693 status = ufx_reg_write(dev, 0x2008, temp); in ufx_set_vid_mode()
697 status = ufx_reg_write(dev, 0x200C, temp); in ufx_set_vid_mode()
701 status = ufx_reg_write(dev, 0x2010, temp); in ufx_set_vid_mode()
713 status = ufx_reg_write(dev, 0x2014, temp); in ufx_set_vid_mode()
717 status = ufx_reg_write(dev, 0x2018, temp); in ufx_set_vid_mode()
721 status = ufx_reg_write(dev, 0x201C, temp); in ufx_set_vid_mode()
724 status = ufx_reg_write(dev, 0x2020, 0x00000000); in ufx_set_vid_mode()
727 status = ufx_reg_write(dev, 0x2024, 0x00000000); in ufx_set_vid_mode()
733 status = ufx_reg_write(dev, 0x2028, temp); in ufx_set_vid_mode()
737 status = ufx_reg_write(dev, 0x2040, 0); in ufx_set_vid_mode()
740 status = ufx_reg_write(dev, 0x2044, 0); in ufx_set_vid_mode()
743 status = ufx_reg_write(dev, 0x2048, 0); in ufx_set_vid_mode()
754 status = ufx_reg_write(dev, 0x2040, temp); in ufx_set_vid_mode()
758 status = ufx_enable(dev, true); in ufx_set_vid_mode()
762 status = ufx_unblank(dev, true); in ufx_set_vid_mode()
766 status = ufx_reg_write(dev, 0x8028, 0x00000003); in ufx_set_vid_mode()
770 status = ufx_reg_write(dev, 0x8024, 0x00000007); in ufx_set_vid_mode()
814 static void ufx_raw_rect(struct ufx_data *dev, u16 *cmd, int x, int y, in ufx_raw_rect() argument
821 BUG_ON(!dev); in ufx_raw_rect()
822 BUG_ON(!dev->info); in ufx_raw_rect()
839 cmd[10] = cpu_to_le16(0x4000 | dev->info->var.xres); in ufx_raw_rect()
842 cmd[11] = cpu_to_le16(dev->info->var.yres); in ufx_raw_rect()
846 const int line_offset = dev->info->fix.line_length * (y + line); in ufx_raw_rect()
849 (char *)dev->info->fix.smem_start + byte_offset, width * BPP); in ufx_raw_rect()
853 static int ufx_handle_damage(struct ufx_data *dev, int x, int y, in ufx_handle_damage() argument
860 (x + width > dev->info->var.xres) || in ufx_handle_damage()
861 (y + height > dev->info->var.yres)) in ufx_handle_damage()
864 if (!atomic_read(&dev->usb_active)) in ufx_handle_damage()
868 struct urb *urb = ufx_get_urb(dev); in ufx_handle_damage()
885 ufx_raw_rect(dev, urb->transfer_buffer, x, (y + start_line), width, urb_lines); in ufx_handle_damage()
888 status = ufx_submit_urb(dev, urb, len); in ufx_handle_damage()
905 struct ufx_data *dev = info->par; in ufx_ops_write() local
915 ufx_handle_damage(dev, 0, start, info->var.xres, lines); in ufx_ops_write()
925 struct ufx_data *dev = info->par; in ufx_ops_copyarea() local
929 ufx_handle_damage(dev, area->dx, area->dy, in ufx_ops_copyarea()
936 struct ufx_data *dev = info->par; in ufx_ops_imageblit() local
940 ufx_handle_damage(dev, image->dx, image->dy, in ufx_ops_imageblit()
947 struct ufx_data *dev = info->par; in ufx_ops_fillrect() local
951 ufx_handle_damage(dev, rect->dx, rect->dy, rect->width, in ufx_ops_fillrect()
961 struct ufx_data *dev = info->par; in ufx_dpy_deferred_io() local
967 if (!atomic_read(&dev->usb_active)) in ufx_dpy_deferred_io()
975 const int width = dev->info->var.xres; in ufx_dpy_deferred_io()
978 height = min(height, (int)(dev->info->var.yres - y)); in ufx_dpy_deferred_io()
980 BUG_ON(y >= dev->info->var.yres); in ufx_dpy_deferred_io()
981 BUG_ON((y + height) > dev->info->var.yres); in ufx_dpy_deferred_io()
983 ufx_handle_damage(dev, x, y, width, height); in ufx_dpy_deferred_io()
990 struct ufx_data *dev = info->par; in ufx_ops_ioctl() local
993 if (!atomic_read(&dev->usb_active)) in ufx_ops_ioctl()
999 if (copy_to_user(edid, dev->edid, dev->edid_size)) in ufx_ops_ioctl()
1029 ufx_handle_damage(dev, area->x, area->y, area->w, area->h); in ufx_ops_ioctl()
1067 struct ufx_data *dev = info->par; in ufx_ops_open() local
1078 if (dev->virtualized) { in ufx_ops_open()
1083 dev->fb_count++; in ufx_ops_open()
1085 kref_get(&dev->kref); in ufx_ops_open()
1103 info->node, user, info, dev->fb_count); in ufx_ops_open()
1117 struct ufx_data *dev = container_of(kref, struct ufx_data, kref); in ufx_free() local
1119 kfree(dev); in ufx_free()
1124 struct ufx_data *dev = info->par; in ufx_ops_destory() local
1133 kref_put(&dev->kref, ufx_free); in ufx_ops_destory()
1142 up(&unode->dev->urbs.limit_sem); in ufx_release_urb_work()
1145 static void ufx_free_framebuffer(struct ufx_data *dev) in ufx_free_framebuffer() argument
1147 struct fb_info *info = dev->info; in ufx_free_framebuffer()
1157 dev->info = NULL; in ufx_free_framebuffer()
1160 kref_put(&dev->kref, ufx_free); in ufx_free_framebuffer()
1168 struct ufx_data *dev = info->par; in ufx_ops_release() local
1172 dev->fb_count--; in ufx_ops_release()
1175 if (dev->virtualized && (dev->fb_count == 0)) in ufx_ops_release()
1176 ufx_free_framebuffer(dev); in ufx_ops_release()
1178 if ((dev->fb_count == 0) && (info->fbdefio)) { in ufx_ops_release()
1185 info->node, user, dev->fb_count); in ufx_ops_release()
1187 kref_put(&dev->kref, ufx_free); in ufx_ops_release()
1250 struct ufx_data *dev = info->par; in ufx_ops_set_par() local
1256 result = ufx_set_vid_mode(dev, &info->var); in ufx_ops_set_par()
1258 if ((result == 0) && (dev->fb_count == 0)) { in ufx_ops_set_par()
1264 ufx_handle_damage(dev, 0, 0, info->var.xres, info->var.yres); in ufx_ops_set_par()
1277 struct ufx_data *dev = info->par; in ufx_ops_blank() local
1278 ufx_set_vid_mode(dev, &info->var); in ufx_ops_blank()
1302 static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info) in ufx_realloc_framebuffer() argument
1336 static int ufx_i2c_init(struct ufx_data *dev) in ufx_i2c_init() argument
1341 int status = ufx_reg_write(dev, 0x106C, 0x00); in ufx_i2c_init()
1346 status = ufx_reg_write(dev, 0x1018, 12); in ufx_i2c_init()
1350 status = ufx_reg_write(dev, 0x1014, 6); in ufx_i2c_init()
1353 status = ufx_reg_read(dev, 0x1000, &tmp); in ufx_i2c_init()
1366 status = ufx_reg_write(dev, 0x1000, tmp); in ufx_i2c_init()
1370 status = ufx_reg_clear_and_set_bits(dev, 0x1004, 0xC00, 0x000); in ufx_i2c_init()
1374 status = ufx_reg_write(dev, 0x106C, 0x01); in ufx_i2c_init()
1381 static int ufx_i2c_configure(struct ufx_data *dev) in ufx_i2c_configure() argument
1383 int status = ufx_reg_write(dev, 0x106C, 0x00); in ufx_i2c_configure()
1386 status = ufx_reg_write(dev, 0x3010, 0x00000000); in ufx_i2c_configure()
1390 status = ufx_reg_clear_and_set_bits(dev, 0x1004, 0x3FF, (0xA0 >> 1)); in ufx_i2c_configure()
1393 status = ufx_reg_write(dev, 0x106C, 0x01); in ufx_i2c_configure()
1401 static int ufx_i2c_wait_busy(struct ufx_data *dev) in ufx_i2c_wait_busy() argument
1407 status = ufx_reg_read(dev, 0x1100, &tmp); in ufx_i2c_wait_busy()
1426 status = ufx_reg_write(dev, 0x1100, 0x40000000); in ufx_i2c_wait_busy()
1433 static int ufx_read_edid(struct ufx_data *dev, u8 *edid, int edid_len) in ufx_read_edid() argument
1440 status = ufx_i2c_configure(dev); in ufx_read_edid()
1451 status = ufx_reg_write(dev, 0x1100, temp); in ufx_read_edid()
1455 status = ufx_reg_write(dev, 0x1100, temp); in ufx_read_edid()
1458 status = ufx_i2c_wait_busy(dev); in ufx_read_edid()
1463 status = ufx_reg_read(dev, data_reg_addr, edid_u32++); in ufx_read_edid()
1492 static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info, in ufx_setup_modes() argument
1515 i = ufx_read_edid(dev, edid, EDID_LENGTH); in ufx_setup_modes()
1521 dev->edid = edid; in ufx_setup_modes()
1522 dev->edid_size = i; in ufx_setup_modes()
1531 if (dev->edid) { in ufx_setup_modes()
1532 fb_edid_to_monspecs(dev->edid, &info->monspecs); in ufx_setup_modes()
1544 dev->edid = edid; in ufx_setup_modes()
1545 dev->edid_size = default_edid_size; in ufx_setup_modes()
1594 if ((default_vmode != NULL) && (dev->fb_count == 0)) { in ufx_setup_modes()
1604 result = ufx_realloc_framebuffer(dev, info); in ufx_setup_modes()
1610 if (edid && (dev->edid != edid)) in ufx_setup_modes()
1623 struct ufx_data *dev; in ufx_usb_probe() local
1632 dev = kzalloc(sizeof(*dev), GFP_KERNEL); in ufx_usb_probe()
1633 if (dev == NULL) { in ufx_usb_probe()
1634 dev_err(&usbdev->dev, "ufx_usb_probe: failed alloc of dev struct\n"); in ufx_usb_probe()
1639 kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */ in ufx_usb_probe()
1640 kref_get(&dev->kref); /* matching kref_put in free_framebuffer_work */ in ufx_usb_probe()
1642 dev->udev = usbdev; in ufx_usb_probe()
1643 dev->gdev = &usbdev->dev; /* our generic struct device * */ in ufx_usb_probe()
1644 usb_set_intfdata(interface, dev); in ufx_usb_probe()
1646 dev_dbg(dev->gdev, "%s %s - serial #%s\n", in ufx_usb_probe()
1648 dev_dbg(dev->gdev, "vid_%04x&pid_%04x&rev_%04x driver's ufx_data struct at %p\n", in ufx_usb_probe()
1651 le16_to_cpu(usbdev->descriptor.bcdDevice), dev); in ufx_usb_probe()
1652 dev_dbg(dev->gdev, "console enable=%d\n", console); in ufx_usb_probe()
1653 dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio); in ufx_usb_probe()
1655 if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) { in ufx_usb_probe()
1656 dev_err(dev->gdev, "ufx_alloc_urb_list failed\n"); in ufx_usb_probe()
1663 info = framebuffer_alloc(0, &usbdev->dev); in ufx_usb_probe()
1665 dev_err(dev->gdev, "framebuffer_alloc failed\n"); in ufx_usb_probe()
1669 dev->info = info; in ufx_usb_probe()
1670 info->par = dev; in ufx_usb_probe()
1671 info->pseudo_palette = dev->pseudo_palette; in ufx_usb_probe()
1677 dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval); in ufx_usb_probe()
1681 retval = ufx_reg_read(dev, 0x3000, &id_rev); in ufx_usb_probe()
1683 dev_dbg(dev->gdev, "ID_REV register value 0x%08x", id_rev); in ufx_usb_probe()
1685 retval = ufx_reg_read(dev, 0x3004, &fpga_rev); in ufx_usb_probe()
1687 dev_dbg(dev->gdev, "FPGA_REV register value 0x%08x", fpga_rev); in ufx_usb_probe()
1689 dev_dbg(dev->gdev, "resetting device"); in ufx_usb_probe()
1690 retval = ufx_lite_reset(dev); in ufx_usb_probe()
1693 dev_dbg(dev->gdev, "configuring system clock"); in ufx_usb_probe()
1694 retval = ufx_config_sys_clk(dev); in ufx_usb_probe()
1697 dev_dbg(dev->gdev, "configuring DDR2 controller"); in ufx_usb_probe()
1698 retval = ufx_config_ddr2(dev); in ufx_usb_probe()
1701 dev_dbg(dev->gdev, "configuring I2C controller"); in ufx_usb_probe()
1702 retval = ufx_i2c_init(dev); in ufx_usb_probe()
1705 dev_dbg(dev->gdev, "selecting display mode"); in ufx_usb_probe()
1706 retval = ufx_setup_modes(dev, info, NULL, 0); in ufx_usb_probe()
1709 retval = ufx_reg_set_bits(dev, 0x4000, 0x00000001); in ufx_usb_probe()
1711 dev_err(dev->gdev, "error %d enabling graphics engine", retval); in ufx_usb_probe()
1716 atomic_set(&dev->usb_active, 1); in ufx_usb_probe()
1718 dev_dbg(dev->gdev, "checking var"); in ufx_usb_probe()
1721 dev_err(dev->gdev, "error %d ufx_ops_check_var", retval); in ufx_usb_probe()
1725 dev_dbg(dev->gdev, "setting par"); in ufx_usb_probe()
1728 dev_err(dev->gdev, "error %d ufx_ops_set_par", retval); in ufx_usb_probe()
1732 dev_dbg(dev->gdev, "registering framebuffer"); in ufx_usb_probe()
1735 dev_err(dev->gdev, "error %d register_framebuffer", retval); in ufx_usb_probe()
1739 dev_info(dev->gdev, "SMSC UDX USB device /dev/fb%d attached. %dx%d resolution." in ufx_usb_probe()
1746 atomic_set(&dev->usb_active, 0); in ufx_usb_probe()
1756 if (dev->urbs.count > 0) in ufx_usb_probe()
1757 ufx_free_urb_list(dev); in ufx_usb_probe()
1759 kref_put(&dev->kref, ufx_free); /* ref for framebuffer */ in ufx_usb_probe()
1760 kref_put(&dev->kref, ufx_free); /* last ref from kref_init */ in ufx_usb_probe()
1766 struct ufx_data *dev; in ufx_usb_disconnect() local
1771 dev = usb_get_intfdata(interface); in ufx_usb_disconnect()
1772 info = dev->info; in ufx_usb_disconnect()
1777 dev->virtualized = true; in ufx_usb_disconnect()
1780 atomic_set(&dev->usb_active, 0); in ufx_usb_disconnect()
1785 if (dev->fb_count == 0) in ufx_usb_disconnect()
1786 ufx_free_framebuffer(dev); in ufx_usb_disconnect()
1789 if (dev->urbs.count > 0) in ufx_usb_disconnect()
1790 ufx_free_urb_list(dev); in ufx_usb_disconnect()
1792 pr_debug("freeing ufx_data %p", dev); in ufx_usb_disconnect()
1811 struct ufx_data *dev = unode->dev; in ufx_urb_completion() local
1821 atomic_set(&dev->lost_pixels, 1); in ufx_urb_completion()
1825 urb->transfer_buffer_length = dev->urbs.size; /* reset to actual */ in ufx_urb_completion()
1827 spin_lock_irqsave(&dev->urbs.lock, flags); in ufx_urb_completion()
1828 list_add_tail(&unode->entry, &dev->urbs.list); in ufx_urb_completion()
1829 dev->urbs.available++; in ufx_urb_completion()
1830 spin_unlock_irqrestore(&dev->urbs.lock, flags); in ufx_urb_completion()
1837 up(&dev->urbs.limit_sem); in ufx_urb_completion()
1840 static void ufx_free_urb_list(struct ufx_data *dev) in ufx_free_urb_list() argument
1842 int count = dev->urbs.count; in ufx_free_urb_list()
1854 ret = down_interruptible(&dev->urbs.limit_sem); in ufx_free_urb_list()
1858 spin_lock_irqsave(&dev->urbs.lock, flags); in ufx_free_urb_list()
1860 node = dev->urbs.list.next; /* have reserved one with sem */ in ufx_free_urb_list()
1863 spin_unlock_irqrestore(&dev->urbs.lock, flags); in ufx_free_urb_list()
1869 usb_free_coherent(urb->dev, dev->urbs.size, in ufx_free_urb_list()
1876 static int ufx_alloc_urb_list(struct ufx_data *dev, int count, size_t size) in ufx_alloc_urb_list() argument
1883 spin_lock_init(&dev->urbs.lock); in ufx_alloc_urb_list()
1885 dev->urbs.size = size; in ufx_alloc_urb_list()
1886 INIT_LIST_HEAD(&dev->urbs.list); in ufx_alloc_urb_list()
1892 unode->dev = dev; in ufx_alloc_urb_list()
1904 buf = usb_alloc_coherent(dev->udev, size, GFP_KERNEL, in ufx_alloc_urb_list()
1913 usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 1), in ufx_alloc_urb_list()
1917 list_add_tail(&unode->entry, &dev->urbs.list); in ufx_alloc_urb_list()
1922 sema_init(&dev->urbs.limit_sem, i); in ufx_alloc_urb_list()
1923 dev->urbs.count = i; in ufx_alloc_urb_list()
1924 dev->urbs.available = i; in ufx_alloc_urb_list()
1931 static struct urb *ufx_get_urb(struct ufx_data *dev) in ufx_get_urb() argument
1940 ret = down_timeout(&dev->urbs.limit_sem, GET_URB_TIMEOUT); in ufx_get_urb()
1942 atomic_set(&dev->lost_pixels, 1); in ufx_get_urb()
1944 ret, dev->urbs.available); in ufx_get_urb()
1948 spin_lock_irqsave(&dev->urbs.lock, flags); in ufx_get_urb()
1950 BUG_ON(list_empty(&dev->urbs.list)); /* reserved one with limit_sem */ in ufx_get_urb()
1951 entry = dev->urbs.list.next; in ufx_get_urb()
1953 dev->urbs.available--; in ufx_get_urb()
1955 spin_unlock_irqrestore(&dev->urbs.lock, flags); in ufx_get_urb()
1964 static int ufx_submit_urb(struct ufx_data *dev, struct urb *urb, size_t len) in ufx_submit_urb() argument
1968 BUG_ON(len > dev->urbs.size); in ufx_submit_urb()
1974 atomic_set(&dev->lost_pixels, 1); in ufx_submit_urb()