Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
firewire: OHCI 1.0 Isochronous Receive support

+155 -20
+155 -20
drivers/firewire/fw-ohci.c
··· 437 437 flush_writes(ctx->ohci); 438 438 } 439 439 440 + static struct descriptor * 441 + find_branch_descriptor(struct descriptor *d, int z) 442 + { 443 + int b, key; 444 + 445 + b = (le16_to_cpu(d->control) & DESCRIPTOR_BRANCH_ALWAYS) >> 2; 446 + key = (le16_to_cpu(d->control) & DESCRIPTOR_KEY_IMMEDIATE) >> 8; 447 + 448 + /* figure out which descriptor the branch address goes in */ 449 + if (z == 2 && (b == 3 || key == 2)) 450 + return d; 451 + else 452 + return d + z - 1; 453 + } 454 + 440 455 static void context_tasklet(unsigned long data) 441 456 { 442 457 struct context *ctx = (struct context *) data; ··· 470 455 address = le32_to_cpu(last->branch_address); 471 456 z = address & 0xf; 472 457 d = ctx->buffer + (address - ctx->buffer_bus) / sizeof(*d); 473 - last = (z == 2) ? d : d + z - 1; 458 + last = find_branch_descriptor(d, z); 474 459 475 460 if (!ctx->callback(ctx, d, last)) 476 461 break; ··· 581 566 582 567 ctx->head_descriptor = d + z + extra; 583 568 ctx->prev_descriptor->branch_address = cpu_to_le32(d_bus | z); 584 - ctx->prev_descriptor = z == 2 ? d : d + z - 1; 569 + ctx->prev_descriptor = find_branch_descriptor(d, z); 585 570 586 571 dma_sync_single_for_device(ctx->ohci->card.device, ctx->buffer_bus, 587 572 ctx->buffer_size, DMA_TO_DEVICE); ··· 670 655 driver_data = (struct driver_data *) &d[3]; 671 656 driver_data->packet = packet; 672 657 packet->driver_data = driver_data; 673 - 658 + 674 659 if (packet->payload_length > 0) { 675 660 payload_bus = 676 661 dma_map_single(ohci->card.device, packet->payload, ··· 918 903 919 904 if (retval < 0) 920 905 packet->callback(packet, &ctx->ohci->card, packet->ack); 921 - 906 + 922 907 } 923 908 924 909 static void bus_reset_tasklet(unsigned long data) ··· 1446 1431 return 1; 1447 1432 } 1448 1433 1434 + static int handle_ir_packet_per_buffer(struct context *context, 1435 + struct descriptor *d, 1436 + struct descriptor *last) 1437 + { 1438 + struct iso_context *ctx = 1439 + container_of(context, struct iso_context, context); 1440 + struct descriptor *pd = d + 1; 1441 + __le32 *ir_header; 1442 + size_t header_length; 1443 + void *p, *end; 1444 + int i, z; 1445 + 1446 + if (pd->res_count == pd->req_count) 1447 + /* Descriptor(s) not done yet, stop iteration */ 1448 + return 0; 1449 + 1450 + header_length = le16_to_cpu(d->req_count); 1451 + 1452 + i = ctx->header_length; 1453 + z = le32_to_cpu(pd->branch_address) & 0xf; 1454 + p = d + z; 1455 + end = p + header_length; 1456 + 1457 + while (p < end && i + ctx->base.header_size <= PAGE_SIZE) { 1458 + /* 1459 + * The iso header is byteswapped to little endian by 1460 + * the controller, but the remaining header quadlets 1461 + * are big endian. We want to present all the headers 1462 + * as big endian, so we have to swap the first quadlet. 1463 + */ 1464 + *(u32 *) (ctx->header + i) = __swab32(*(u32 *) (p + 4)); 1465 + memcpy(ctx->header + i + 4, p + 8, ctx->base.header_size - 4); 1466 + i += ctx->base.header_size; 1467 + p += ctx->base.header_size + 4; 1468 + } 1469 + 1470 + ctx->header_length = i; 1471 + 1472 + if (le16_to_cpu(pd->control) & DESCRIPTOR_IRQ_ALWAYS) { 1473 + ir_header = (__le32 *) (d + z); 1474 + ctx->base.callback(&ctx->base, 1475 + le32_to_cpu(ir_header[0]) & 0xffff, 1476 + ctx->header_length, ctx->header, 1477 + ctx->base.callback_data); 1478 + ctx->header_length = 0; 1479 + } 1480 + 1481 + 1482 + return 1; 1483 + } 1484 + 1449 1485 static int handle_it_packet(struct context *context, 1450 1486 struct descriptor *d, 1451 1487 struct descriptor *last) ··· 1532 1466 } else { 1533 1467 mask = &ohci->ir_context_mask; 1534 1468 list = ohci->ir_context_list; 1535 - callback = handle_ir_dualbuffer_packet; 1469 + if (ohci->version >= OHCI_VERSION_1_1) 1470 + callback = handle_ir_dualbuffer_packet; 1471 + else 1472 + callback = handle_ir_packet_per_buffer; 1536 1473 } 1537 - 1538 - /* FIXME: We need a fallback for pre 1.1 OHCI. */ 1539 - if (callback == handle_ir_dualbuffer_packet && 1540 - ohci->version < OHCI_VERSION_1_1) 1541 - return ERR_PTR(-ENOSYS); 1542 1474 1543 1475 spin_lock_irqsave(&ohci->lock, flags); 1544 1476 index = ffs(*mask) - 1; ··· 1596 1532 context_run(&ctx->context, match); 1597 1533 } else { 1598 1534 index = ctx - ohci->ir_context_list; 1599 - control = IR_CONTEXT_DUAL_BUFFER_MODE | IR_CONTEXT_ISOCH_HEADER; 1535 + control = IR_CONTEXT_ISOCH_HEADER; 1536 + if (ohci->version >= OHCI_VERSION_1_1) 1537 + control |= IR_CONTEXT_DUAL_BUFFER_MODE; 1600 1538 match = (tags << 28) | (sync << 8) | ctx->base.channel; 1601 1539 if (cycle >= 0) { 1602 1540 match |= (cycle & 0x07fff) << 12; ··· 1804 1738 offset = payload & ~PAGE_MASK; 1805 1739 rest = p->payload_length; 1806 1740 1807 - /* FIXME: OHCI 1.0 doesn't support dual buffer receive */ 1808 1741 /* FIXME: make packet-per-buffer/dual-buffer a context option */ 1809 1742 while (rest > 0) { 1810 1743 d = context_get_descriptors(&ctx->context, ··· 1842 1777 } 1843 1778 1844 1779 static int 1780 + ohci_queue_iso_receive_packet_per_buffer(struct fw_iso_context *base, 1781 + struct fw_iso_packet *packet, 1782 + struct fw_iso_buffer *buffer, 1783 + unsigned long payload) 1784 + { 1785 + struct iso_context *ctx = container_of(base, struct iso_context, base); 1786 + struct descriptor *d = NULL, *pd = NULL; 1787 + struct fw_iso_packet *p; 1788 + dma_addr_t d_bus, page_bus; 1789 + u32 z, header_z, rest; 1790 + int i, page, offset, packet_count, header_size; 1791 + 1792 + if (packet->skip) { 1793 + d = context_get_descriptors(&ctx->context, 1, &d_bus); 1794 + if (d == NULL) 1795 + return -ENOMEM; 1796 + 1797 + d->control = cpu_to_le16(DESCRIPTOR_STATUS | 1798 + DESCRIPTOR_INPUT_LAST | 1799 + DESCRIPTOR_BRANCH_ALWAYS | 1800 + DESCRIPTOR_WAIT); 1801 + context_append(&ctx->context, d, 1, 0); 1802 + } 1803 + 1804 + /* one descriptor for header, one for payload */ 1805 + /* FIXME: handle cases where we need multiple desc. for payload */ 1806 + z = 2; 1807 + p = packet; 1808 + 1809 + /* 1810 + * The OHCI controller puts the status word in the 1811 + * buffer too, so we need 4 extra bytes per packet. 1812 + */ 1813 + packet_count = p->header_length / ctx->base.header_size; 1814 + header_size = packet_count * (ctx->base.header_size + 4); 1815 + 1816 + /* Get header size in number of descriptors. */ 1817 + header_z = DIV_ROUND_UP(header_size, sizeof(*d)); 1818 + page = payload >> PAGE_SHIFT; 1819 + offset = payload & ~PAGE_MASK; 1820 + rest = p->payload_length; 1821 + 1822 + for (i = 0; i < packet_count; i++) { 1823 + /* d points to the header descriptor */ 1824 + d = context_get_descriptors(&ctx->context, 1825 + z + header_z, &d_bus); 1826 + if (d == NULL) 1827 + return -ENOMEM; 1828 + 1829 + d->control = cpu_to_le16(DESCRIPTOR_INPUT_MORE); 1830 + d->req_count = cpu_to_le16(header_size); 1831 + d->res_count = d->req_count; 1832 + d->data_address = cpu_to_le32(d_bus + (z * sizeof(*d))); 1833 + 1834 + /* pd points to the payload descriptor */ 1835 + pd = d + 1; 1836 + pd->control = cpu_to_le16(DESCRIPTOR_STATUS | 1837 + DESCRIPTOR_INPUT_LAST | 1838 + DESCRIPTOR_BRANCH_ALWAYS); 1839 + if (p->interrupt) 1840 + pd->control |= cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS); 1841 + 1842 + pd->req_count = cpu_to_le16(rest); 1843 + pd->res_count = pd->req_count; 1844 + 1845 + page_bus = page_private(buffer->pages[page]); 1846 + pd->data_address = cpu_to_le32(page_bus + offset); 1847 + 1848 + context_append(&ctx->context, d, z, header_z); 1849 + } 1850 + 1851 + return 0; 1852 + } 1853 + 1854 + static int 1845 1855 ohci_queue_iso(struct fw_iso_context *base, 1846 1856 struct fw_iso_packet *packet, 1847 1857 struct fw_iso_buffer *buffer, ··· 1930 1790 return ohci_queue_iso_receive_dualbuffer(base, packet, 1931 1791 buffer, payload); 1932 1792 else 1933 - /* FIXME: Implement fallback for OHCI 1.0 controllers. */ 1934 - return -ENOSYS; 1793 + return ohci_queue_iso_receive_packet_per_buffer(base, packet, 1794 + buffer, 1795 + payload); 1935 1796 } 1936 1797 1937 1798 static const struct fw_card_driver ohci_driver = { ··· 2052 1911 ohci->version = reg_read(ohci, OHCI1394_Version) & 0x00ff00ff; 2053 1912 fw_notify("Added fw-ohci device %s, OHCI version %x.%x\n", 2054 1913 dev->dev.bus_id, ohci->version >> 16, ohci->version & 0xff); 2055 - if (ohci->version < OHCI_VERSION_1_1) { 2056 - fw_notify(" Isochronous I/O is not yet implemented for " 2057 - "OHCI 1.0 chips.\n"); 2058 - fw_notify(" Cameras, audio devices etc. won't work on " 2059 - "this controller with this driver version.\n"); 2060 - } 2061 1914 return 0; 2062 1915 2063 1916 fail_self_id: