[Linux1394-cvslog] rev 644 - branches/rawiso
Brought to you by:
aeb,
bencollins
From: SVN U. <dm...@li...> - 2002-10-25 03:54:28
|
Author: dmaas Date: 2002-10-24 23:54:19 -0400 (Thu, 24 Oct 2002) New Revision: 644 Modified: branches/rawiso/hosts.h branches/rawiso/ieee1394_core.c branches/rawiso/iso.c branches/rawiso/iso.h branches/rawiso/ohci1394.c branches/rawiso/raw1394.c branches/rawiso/raw1394.h Log: rawiso kernel API changes Modified: branches/rawiso/iso.h ============================================================================== --- branches/rawiso/iso.h (original) +++ branches/rawiso/iso.h 2002-10-24 23:54:21.000000000 -0400 @@ -83,14 +83,14 @@ /* used for cycle matching */ int first_packet_cycle; - int driver_started; + int driver_init, driver_started; }; /* functions available to high-level drivers (e.g. raw1394) */ -/* allocate the buffer and DMA context - transmission will begin - at the first following call to xmit_produce() */ -struct hpsb_iso* hpsb_iso_xmit_start(struct hpsb_host *host, +/* allocate the buffer and DMA context */ + +struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host, unsigned int buf_packets, unsigned int max_packet_size, int channel, @@ -98,26 +98,26 @@ int irq_interval, wait_queue_head_t *waitq); -/* N packets have been written to the buffer and can be queued for transmission */ -int hpsb_iso_xmit_produce(struct hpsb_iso *xmit, unsigned int n_packets); - -/* halt transmission, deallocate buffer and DMA context */ -void hpsb_iso_xmit_stop(struct hpsb_iso *iso); - -/* allocate the buffer and DMA context, and start filling the buffer - with packets */ -struct hpsb_iso* hpsb_iso_recv_start(struct hpsb_host *host, +struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host, unsigned int buf_packets, unsigned int max_packet_size, int channel, int irq_interval, wait_queue_head_t *waitq); -/* N packets have been read out of the buffer, re-use the buffer space */ -int hpsb_iso_recv_consume(struct hpsb_iso *recv, unsigned int n_packets); +/* start/stop DMA */ +int hpsb_iso_start(struct hpsb_iso *iso, int start_on_cycle); +void hpsb_iso_stop(struct hpsb_iso *iso); -/* halt reception, deallocate buffer and DMA context */ -void hpsb_iso_recv_stop(struct hpsb_iso *iso); +/* deallocate buffer and DMA context */ +void hpsb_iso_shutdown(struct hpsb_iso *iso); + + +/* N packets have been written to the buffer and can be queued for transmission */ +int hpsb_iso_xmit_queue_packets(struct hpsb_iso *xmit, unsigned int n_packets); + +/* N packets have been read out of the buffer, re-use the buffer space */ +int hpsb_iso_recv_release_packets(struct hpsb_iso *recv, unsigned int n_packets); /* returns # of packets ready to send or receive */ int hpsb_iso_n_ready(struct hpsb_iso *iso); Modified: branches/rawiso/ieee1394_core.c ============================================================================== --- branches/rawiso/ieee1394_core.c (original) +++ branches/rawiso/ieee1394_core.c 2002-10-24 23:54:21.000000000 -0400 @@ -1130,12 +1130,13 @@ EXPORT_SYMBOL(highlevel_remove_host); EXPORT_SYMBOL(highlevel_host_reset); -EXPORT_SYMBOL(hpsb_iso_xmit_start); -EXPORT_SYMBOL(hpsb_iso_xmit_produce); -EXPORT_SYMBOL(hpsb_iso_xmit_stop); -EXPORT_SYMBOL(hpsb_iso_recv_start); -EXPORT_SYMBOL(hpsb_iso_recv_consume); -EXPORT_SYMBOL(hpsb_iso_recv_stop); +EXPORT_SYMBOL(hpsb_iso_xmit_init); +EXPORT_SYMBOL(hpsb_iso_recv_init); +EXPORT_SYMBOL(hpsb_iso_start); +EXPORT_SYMBOL(hpsb_iso_stop); +EXPORT_SYMBOL(hpsb_iso_shutdown); +EXPORT_SYMBOL(hpsb_iso_xmit_queue_packets); +EXPORT_SYMBOL(hpsb_iso_recv_release_packets); EXPORT_SYMBOL(hpsb_iso_n_ready); EXPORT_SYMBOL(hpsb_iso_packet_data); EXPORT_SYMBOL(hpsb_iso_packet_info); Modified: branches/rawiso/ohci1394.c ============================================================================== --- branches/rawiso/ohci1394.c (original) +++ branches/rawiso/ohci1394.c 2002-10-24 23:54:21.000000000 -0400 @@ -1005,11 +1005,12 @@ static void ohci_iso_recv_task(unsigned long data); static void ohci_iso_recv_stop(struct hpsb_iso *iso); +static void ohci_iso_recv_shutdown(struct hpsb_iso *iso); static void ohci_iso_recv_program(struct hpsb_iso *iso); -static int ohci_iso_recv_start_dma(struct hpsb_iso *iso); +static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle); -static int ohci_iso_recv_start(struct hpsb_iso *iso) +static int ohci_iso_recv_init(struct hpsb_iso *iso) { struct ohci_iso_recv *recv; unsigned int prog_size; @@ -1053,22 +1054,25 @@ /* write the DMA program */ ohci_iso_recv_program(iso); - - /* go! */ - if(ohci_iso_recv_start_dma(iso)) - goto err; return 0; err: - ohci_iso_recv_stop(iso); + ohci_iso_recv_shutdown(iso); return ret; } - static void ohci_iso_recv_stop(struct hpsb_iso *iso) { struct ohci_iso_recv *recv = iso->hostdata; + + /* halt DMA */ + ohci1394_stop_context(recv->ohci, recv->ContextControlClear, NULL); +} + +static void ohci_iso_recv_shutdown(struct hpsb_iso *iso) +{ + struct ohci_iso_recv *recv = iso->hostdata; if(recv->task_active) { /* halt DMA */ @@ -1148,7 +1152,7 @@ /* the final descriptor's branch address and Z should be left at 0 */ } -static int ohci_iso_recv_start_dma(struct hpsb_iso *iso) +static int ohci_iso_recv_start(struct hpsb_iso *iso, int cycle) { struct ohci_iso_recv *recv = iso->hostdata; u32 command; @@ -1162,6 +1166,10 @@ /* match on all tags, listen on channel */ reg_write(recv->ohci, recv->ContextMatch, 0xF0000000 | iso->channel); + if(cycle != -1) { + /* XXX use cycleMatch */ + } + /* address of first descriptor block */ command = dma_prog_region_offset_to_bus(&recv->prog, recv->pkt_dma * sizeof(struct dma_cmd)); command |= 1; /* Z=1 */ @@ -1187,7 +1195,7 @@ return 0; } -static void ohci_iso_recv_consume_one(struct hpsb_iso *iso) +static void ohci_iso_recv_release_one(struct hpsb_iso *iso) { struct ohci_iso_recv *recv = iso->hostdata; @@ -1222,11 +1230,11 @@ atomic_inc(&iso->n_dma_packets); } -static void ohci_iso_recv_consume(struct hpsb_iso *iso, int n_packets) +static void ohci_iso_recv_release(struct hpsb_iso *iso, int n_packets) { int i; for(i = 0; i < n_packets; i++) - ohci_iso_recv_consume_one(iso); + ohci_iso_recv_release_one(iso); } static void ohci_iso_recv_task(unsigned long data) @@ -1334,9 +1342,9 @@ struct dma_cmd output_last; }; -static int ohci_iso_xmit_start(struct hpsb_iso *iso); -static int ohci_iso_xmit_start_dma(struct hpsb_iso *iso, int cycle); -static void ohci_iso_xmit_stop(struct hpsb_iso *iso); +static int ohci_iso_xmit_init(struct hpsb_iso *iso); +static int ohci_iso_xmit_start(struct hpsb_iso *iso, int cycle); +static void ohci_iso_xmit_shutdown(struct hpsb_iso *iso); static void ohci_iso_xmit_task(unsigned long data); static int ohci_iso_xmit_suggest_start_cycle(struct ti_ohci *ohci) @@ -1361,7 +1369,7 @@ return ((sec & 0x3) << 13) | cyc; } -static int ohci_iso_xmit_start(struct hpsb_iso *iso) +static int ohci_iso_xmit_init(struct hpsb_iso *iso) { struct ohci_iso_xmit *xmit; unsigned int prog_size; @@ -1409,13 +1417,19 @@ return 0; err: - ohci_iso_xmit_stop(iso); + ohci_iso_xmit_shutdown(iso); return ret; } static void ohci_iso_xmit_stop(struct hpsb_iso *iso) { struct ohci_iso_xmit *xmit = iso->hostdata; + ohci1394_stop_context(xmit->ohci, xmit->ContextControlClear, NULL); +} + +static void ohci_iso_xmit_shutdown(struct hpsb_iso *iso) +{ + struct ohci_iso_xmit *xmit = iso->hostdata; if(xmit->task_active) { /* halt DMA */ @@ -1487,7 +1501,7 @@ } } -static void ohci_iso_xmit_produce_one(struct hpsb_iso *iso) +static void ohci_iso_xmit_queue_one(struct hpsb_iso *iso) { struct ohci_iso_xmit *xmit = iso->hostdata; struct hpsb_iso_packet_info *info; @@ -1572,23 +1586,14 @@ atomic_inc(&iso->n_dma_packets); } -static void ohci_iso_xmit_produce(struct hpsb_iso *iso, int n_packets) +static void ohci_iso_xmit_queue(struct hpsb_iso *iso, int n_packets) { - struct ohci_iso_xmit *xmit = iso->hostdata; int i; - - /* record the starting cycle here, since produce_one() bumps first_packet_cycle */ - int starting_cycle = iso->first_packet_cycle; - for(i = 0; i < n_packets; i++) - ohci_iso_xmit_produce_one(iso); - - /* if DMA is not running, start it up */ - if(!(reg_read(xmit->ohci, xmit->ContextControlSet) & 0x8000)) - ohci_iso_xmit_start_dma(iso, starting_cycle); + ohci_iso_xmit_queue_one(iso); } -static int ohci_iso_xmit_start_dma(struct hpsb_iso *iso, int cycle) +static int ohci_iso_xmit_start(struct hpsb_iso *iso, int cycle) { struct ohci_iso_xmit *xmit = iso->hostdata; @@ -1601,7 +1606,7 @@ dma_prog_region_offset_to_bus(&xmit->prog, xmit->pkt_dma * sizeof(struct iso_xmit_cmd)) | 3); /* cycle match */ - if(cycle >= 0) { + if(cycle != -1) { reg_write(xmit->ohci, xmit->ContextControlSet, 0x80000000 | (cycle << 16)); } @@ -1627,22 +1632,34 @@ { switch(cmd) { + case XMIT_INIT: + return ohci_iso_xmit_init(iso); case XMIT_START: - return ohci_iso_xmit_start(iso); - case XMIT_PRODUCE: - ohci_iso_xmit_produce(iso, arg); - return 0; + return ohci_iso_xmit_start(iso, arg); case XMIT_STOP: ohci_iso_xmit_stop(iso); return 0; - case RECV_START: - return ohci_iso_recv_start(iso); - case RECV_CONSUME: - ohci_iso_recv_consume(iso, arg); + case XMIT_QUEUE: + ohci_iso_xmit_queue(iso, arg); return 0; + case XMIT_SHUTDOWN: + ohci_iso_xmit_shutdown(iso); + return 0; + + case RECV_INIT: + return ohci_iso_recv_init(iso); + case RECV_START: + return ohci_iso_recv_start(iso, arg); case RECV_STOP: ohci_iso_recv_stop(iso); return 0; + case RECV_RELEASE: + ohci_iso_recv_release(iso, arg); + return 0; + case RECV_SHUTDOWN: + ohci_iso_recv_shutdown(iso); + return 0; + default: PRINT_G(KERN_ERR, "ohci_isoctl cmd %d not implemented yet", cmd); Modified: branches/rawiso/raw1394.c ============================================================================== --- branches/rawiso/raw1394.c (original) +++ branches/rawiso/raw1394.c 2002-10-24 23:54:21.000000000 -0400 @@ -893,68 +893,79 @@ return retval; } -/* ISO operations */ +/* new ISO operations */ -static int raw1394_iso_start_xmit(struct file_info *fi, void *uaddr) +static void raw1394_iso_fill_status(struct hpsb_iso *iso, struct raw1394_iso_status *stat) { - struct raw1394_kernel_iso_config config; + stat->config.buf_packets = iso->buf_packets; + stat->config.max_packet_size = iso->max_packet_size; + stat->config.channel = iso->channel; + stat->config.speed = iso->speed; + stat->config.irq_interval = iso->irq_interval; + stat->buf_stride = iso->buf_stride; + stat->packet_data_offset = iso->packet_data_offset; + stat->packet_info_offset = iso->packet_info_offset; + stat->first_packet = iso->first_packet; + stat->n_packets = hpsb_iso_n_ready(iso); + stat->overflows = atomic_read(&iso->overflows); + stat->first_packet_cycle = iso->first_packet_cycle; +} + +static int raw1394_iso_xmit_init(struct file_info *fi, void *uaddr) +{ + struct raw1394_iso_status stat; - if(copy_from_user(&config, uaddr, sizeof(config))) + if(copy_from_user(&stat, uaddr, sizeof(stat))) return -EFAULT; - fi->iso_handle = hpsb_iso_xmit_start(fi->host, - config.buf_packets, - config.max_packet_size, - config.channel, - config.speed, - config.irq_interval, - &fi->poll_wait_complete); + fi->iso_handle = hpsb_iso_xmit_init(fi->host, + stat.config.buf_packets, + stat.config.max_packet_size, + stat.config.channel, + stat.config.speed, + stat.config.irq_interval, + &fi->poll_wait_complete); if(!fi->iso_handle) return -ENOMEM; - + fi->iso_state = RAW1394_ISO_XMIT; + + raw1394_iso_fill_status(fi->iso_handle, &stat); + if(copy_to_user(uaddr, &stat, sizeof(stat))) + return -EFAULT; return 0; } -static int raw1394_iso_start_recv(struct file_info *fi, void *uaddr) +static int raw1394_iso_recv_init(struct file_info *fi, void *uaddr) { - struct raw1394_kernel_iso_config config; + struct raw1394_iso_status stat; - if(copy_from_user(&config, uaddr, sizeof(config))) + if(copy_from_user(&stat, uaddr, sizeof(stat))) return -EFAULT; - fi->iso_handle = hpsb_iso_recv_start(fi->host, - config.buf_packets, - config.max_packet_size, - config.channel, - config.irq_interval, - &fi->poll_wait_complete); + fi->iso_handle = hpsb_iso_recv_init(fi->host, + stat.config.buf_packets, + stat.config.max_packet_size, + stat.config.channel, + stat.config.irq_interval, + &fi->poll_wait_complete); if(!fi->iso_handle) return -ENOMEM; - + fi->iso_state = RAW1394_ISO_RECV; + + raw1394_iso_fill_status(fi->iso_handle, &stat); + if(copy_to_user(uaddr, &stat, sizeof(stat))) + return -EFAULT; return 0; } static int raw1394_iso_get_status(struct file_info *fi, void *uaddr) { - struct raw1394_kernel_iso_status stat; + struct raw1394_iso_status stat; struct hpsb_iso *iso = fi->iso_handle; - - stat.config.buf_packets = iso->buf_packets; - stat.config.max_packet_size = iso->max_packet_size; - stat.config.channel = iso->channel; - stat.config.speed = iso->speed; - stat.config.irq_interval = iso->irq_interval; - - stat.buf_stride = iso->buf_stride; - stat.packet_data_offset = iso->packet_data_offset; - stat.packet_info_offset = iso->packet_info_offset; - stat.first_packet = iso->first_packet; - stat.n_packets = hpsb_iso_n_ready(iso); - stat.overflows = atomic_read(&iso->overflows); - stat.first_packet_cycle = iso->first_packet_cycle; - + + raw1394_iso_fill_status(fi->iso_handle, &stat); if(copy_to_user(uaddr, &stat, sizeof(stat))) return -EFAULT; @@ -964,15 +975,12 @@ return 0; } -static void raw1394_iso_stop(struct file_info *fi) +static void raw1394_iso_shutdown(struct file_info *fi) { - if(fi->iso_state == RAW1394_ISO_RECV) - hpsb_iso_recv_stop(fi->iso_handle); - else - hpsb_iso_xmit_stop(fi->iso_handle); - - fi->iso_handle = NULL; + if(fi->iso_handle) + hpsb_iso_shutdown(fi->iso_handle); + fi->iso_handle = NULL; fi->iso_state = RAW1394_ISO_INACTIVE; } @@ -996,33 +1004,49 @@ switch(fi->iso_state) { case RAW1394_ISO_INACTIVE: switch(cmd) { - case RAW1394_ISO_START_XMIT: - return raw1394_iso_start_xmit(fi, (void*) arg); - case RAW1394_ISO_START_RECV: - return raw1394_iso_start_recv(fi, (void*) arg); + case RAW1394_ISO_XMIT_INIT: + return raw1394_iso_xmit_init(fi, (void*) arg); + case RAW1394_ISO_RECV_INIT: + return raw1394_iso_recv_init(fi, (void*) arg); default: break; } break; case RAW1394_ISO_RECV: switch(cmd) { + case RAW1394_ISO_START: + return hpsb_iso_start(fi->iso_handle, arg); + case RAW1394_ISO_STOP: + hpsb_iso_stop(fi->iso_handle); + return 0; + case RAW1394_ISO_GET_STATUS: return raw1394_iso_get_status(fi, (void*) arg); + case RAW1394_ISO_PRODUCE_CONSUME: - return hpsb_iso_recv_consume(fi->iso_handle, arg); - case RAW1394_ISO_STOP: - raw1394_iso_stop(fi); + return hpsb_iso_recv_release_packets(fi->iso_handle, arg); + + case RAW1394_ISO_SHUTDOWN: + raw1394_iso_shutdown(fi); return 0; } break; case RAW1394_ISO_XMIT: switch(cmd) { + case RAW1394_ISO_START: + return hpsb_iso_start(fi->iso_handle, arg); + case RAW1394_ISO_STOP: + hpsb_iso_stop(fi->iso_handle); + return 0; + case RAW1394_ISO_GET_STATUS: return raw1394_iso_get_status(fi, (void*) arg); + case RAW1394_ISO_PRODUCE_CONSUME: - return hpsb_iso_xmit_produce(fi->iso_handle, arg); - case RAW1394_ISO_STOP: - raw1394_iso_stop(fi); + return hpsb_iso_xmit_queue_packets(fi->iso_handle, arg); + + case RAW1394_ISO_SHUTDOWN: + raw1394_iso_shutdown(fi); return 0; } break; @@ -1093,7 +1117,7 @@ int done = 0, i; if(fi->iso_state != RAW1394_ISO_INACTIVE) - raw1394_iso_stop(fi); + raw1394_iso_shutdown(fi); for (i = 0; i < 64; i++) { if (fi->listen_channels & (1ULL << i)) { Modified: branches/rawiso/raw1394.h ============================================================================== --- branches/rawiso/raw1394.h (original) +++ branches/rawiso/raw1394.h 2002-10-24 23:54:21.000000000 -0400 @@ -72,14 +72,25 @@ /* new ISO API */ /* ioctls */ -#define RAW1394_ISO_START_XMIT 1 -#define RAW1394_ISO_START_RECV 2 -#define RAW1394_ISO_GET_STATUS 3 +#define RAW1394_ISO_XMIT_INIT 1 +#define RAW1394_ISO_RECV_INIT 2 +#define RAW1394_ISO_START 3 #define RAW1394_ISO_STOP 4 -#define RAW1394_ISO_PRODUCE_CONSUME 5 +#define RAW1394_ISO_GET_STATUS 5 +#define RAW1394_ISO_PRODUCE_CONSUME 6 +#define RAW1394_ISO_SHUTDOWN 7 + +/* per-packet metadata embedded in the ringbuffer */ +/* must be identical to hpsb_iso_packet_info in iso.h! */ +struct raw1394_iso_packet_info { + unsigned short len; + unsigned char channel; + unsigned char tag; + unsigned char tcode; + unsigned char sy; +}; -/* argument to RAW1394_ISO_START_RECV, XMIT */ -struct raw1394_kernel_iso_config { +struct raw1394_iso_config { unsigned int buf_packets; unsigned int max_packet_size; int channel; @@ -87,9 +98,10 @@ int irq_interval; }; -struct raw1394_kernel_iso_status { +/* argument to RAW1394_ISO_XMIT/RECV_INIT and RAW1394_ISO_GET_STATUS */ +struct raw1394_iso_status { /* current settings */ - struct raw1394_kernel_iso_config config; + struct raw1394_iso_config config; /* byte offset between successive packets in the buffer */ int buf_stride; Modified: branches/rawiso/hosts.h ============================================================================== --- branches/rawiso/hosts.h (original) +++ branches/rawiso/hosts.h 2002-10-24 23:54:21.000000000 -0400 @@ -100,15 +100,25 @@ }; enum isoctl_cmd { - /* see iso.h for the meanings of these commands */ + /* see iso.h... + * INIT = allocate resources + * START = begin transmission/reception (arg: cycle) + * STOP = halt transmission/reception + * QUEUE/RELEASE = produce/consume packets (arg: # of packets) + * SHUTDOWN = deallocate resources + */ + XMIT_INIT, XMIT_START, - XMIT_PRODUCE, XMIT_STOP, + XMIT_QUEUE, + XMIT_SHUTDOWN, + RECV_INIT, RECV_START, - RECV_CONSUME, - RECV_STOP + RECV_STOP, + RECV_RELEASE, + RECV_SHUTDOWN, }; enum reset_types { Modified: branches/rawiso/iso.c ============================================================================== --- branches/rawiso/iso.c (original) +++ branches/rawiso/iso.c 2002-10-24 23:54:21.000000000 -0400 @@ -11,17 +11,28 @@ #include "iso.h" -static void hpsb_iso_common_stop(struct hpsb_iso *iso) +void hpsb_iso_stop(struct hpsb_iso *iso) { - if(iso->driver_started) { - iso->host->driver->isoctl(iso, iso->type == HPSB_ISO_XMIT ? XMIT_STOP : RECV_STOP, 0); + if(!iso->driver_started) + return; + + iso->host->driver->isoctl(iso, iso->type == HPSB_ISO_XMIT ? XMIT_STOP : RECV_STOP, 0); + iso->driver_started = 0; +} + +void hpsb_iso_shutdown(struct hpsb_iso *iso) +{ + if(iso->driver_init) { + hpsb_iso_stop(iso); + iso->host->driver->isoctl(iso, iso->type == HPSB_ISO_XMIT ? XMIT_SHUTDOWN : RECV_SHUTDOWN, 0); + iso->driver_init = 0; } dma_region_free(&iso->buf); kfree(iso); } -static struct hpsb_iso* hpsb_iso_common_start(struct hpsb_host *host, enum hpsb_iso_type type, +static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_iso_type type, unsigned int buf_packets, unsigned int max_packet_size, int channel, @@ -60,7 +71,7 @@ iso = kmalloc(sizeof(*iso), SLAB_KERNEL); if(!iso) return NULL; - + iso->type = type; iso->host = host; iso->hostdata = NULL; @@ -85,6 +96,7 @@ atomic_set(&iso->overflows, 0); iso->first_packet_cycle = 0; + iso->driver_init = 0; iso->driver_started = 0; /* allocate the packet buffer */ @@ -95,7 +107,7 @@ return iso; err: - hpsb_iso_common_stop(iso); + hpsb_iso_shutdown(iso); return NULL; } @@ -105,70 +117,75 @@ } -struct hpsb_iso* hpsb_iso_xmit_start(struct hpsb_host *host, - unsigned int buf_packets, - unsigned int max_packet_size, - int channel, - int speed, - int irq_interval, - wait_queue_head_t *waitq) -{ - struct hpsb_iso *iso = hpsb_iso_common_start(host, HPSB_ISO_XMIT, - buf_packets, max_packet_size, - channel, irq_interval, waitq); +struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host, + unsigned int buf_packets, + unsigned int max_packet_size, + int channel, + int speed, + int irq_interval, + wait_queue_head_t *waitq) +{ + struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_XMIT, + buf_packets, max_packet_size, + channel, irq_interval, waitq); if(!iso) return NULL; iso->speed = speed; /* tell the driver to start working */ - if(host->driver->isoctl(iso, XMIT_START, 0)) + if(host->driver->isoctl(iso, XMIT_INIT, 0)) goto err; - iso->driver_started = 1; + iso->driver_init = 1; return iso; err: - hpsb_iso_common_stop(iso); + hpsb_iso_shutdown(iso); return NULL; } -struct hpsb_iso* hpsb_iso_recv_start(struct hpsb_host *host, - unsigned int buf_packets, - unsigned int max_packet_size, - int channel, - int irq_interval, - wait_queue_head_t *waitq) -{ - struct hpsb_iso *iso = hpsb_iso_common_start(host, HPSB_ISO_RECV, - buf_packets, max_packet_size, - channel, irq_interval, waitq); +struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host, + unsigned int buf_packets, + unsigned int max_packet_size, + int channel, + int irq_interval, + wait_queue_head_t *waitq) +{ + struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_RECV, + buf_packets, max_packet_size, + channel, irq_interval, waitq); if(!iso) return NULL; /* tell the driver to start working */ - if(host->driver->isoctl(iso, RECV_START, 0)) + if(host->driver->isoctl(iso, RECV_INIT, 0)) goto err; - iso->driver_started = 1; + iso->driver_init = 1; return iso; err: - hpsb_iso_common_stop(iso); + hpsb_iso_shutdown(iso); return NULL; } -void hpsb_iso_xmit_stop(struct hpsb_iso *iso) +int hpsb_iso_start(struct hpsb_iso *iso, int cycle) { - hpsb_iso_common_stop(iso); -} + int retval = 0; + + if(iso->driver_started) + return 0; -void hpsb_iso_recv_stop(struct hpsb_iso *iso) -{ - hpsb_iso_common_stop(iso); + retval = iso->host->driver->isoctl(iso, iso->type == HPSB_ISO_XMIT ? XMIT_START : RECV_START, cycle); + if(retval) + return retval; + + iso->driver_started = 1; + return retval; } -int hpsb_iso_xmit_produce(struct hpsb_iso *iso, unsigned int n_packets) +int hpsb_iso_xmit_queue_packets(struct hpsb_iso *iso, unsigned int n_packets) { int i; int pkt = iso->first_packet; @@ -177,7 +194,7 @@ for(i = 0; i < n_packets; i++) { struct hpsb_iso_packet_info *info = hpsb_iso_packet_info(iso, pkt); if(info->len > iso->max_packet_size) { - printk(KERN_ERR "hpsb_iso_xmit_produce: packet too long (%u, max is %u)\n", + printk(KERN_ERR "hpsb_iso_xmit_queue_packets: packet too long (%u, max is %u)\n", info->len, iso->max_packet_size); return -EINVAL; } @@ -185,22 +202,22 @@ pkt = (pkt+1) % iso->buf_packets; } - return iso->host->driver->isoctl(iso, XMIT_PRODUCE, n_packets); + return iso->host->driver->isoctl(iso, XMIT_QUEUE, n_packets); } -int hpsb_iso_recv_consume(struct hpsb_iso *iso, unsigned int n_packets) +int hpsb_iso_recv_release_packets(struct hpsb_iso *iso, unsigned int n_packets) { - return iso->host->driver->isoctl(iso, RECV_CONSUME, n_packets); + return iso->host->driver->isoctl(iso, RECV_RELEASE, n_packets); } unsigned char* hpsb_iso_packet_data(struct hpsb_iso *iso, unsigned int pkt) { - return (iso->buf.kvirt + pkt * iso->buf_stride) + iso->packet_data_offset; + return (iso->buf.kvirt + pkt * iso->buf_stride) + + iso->packet_data_offset; } struct hpsb_iso_packet_info* hpsb_iso_packet_info(struct hpsb_iso *iso, unsigned int pkt) { - return (struct hpsb_iso_packet_info*) (iso->buf.kvirt + - pkt * iso->buf_stride + - iso->packet_info_offset); + return (struct hpsb_iso_packet_info*) ((iso->buf.kvirt + pkt * iso->buf_stride) + + iso->packet_info_offset); } |