patch-2.4.19 linux-2.4.19/drivers/ieee1394/video1394.c
Next file: linux-2.4.19/drivers/input/joydev.c
Previous file: linux-2.4.19/drivers/ieee1394/sbp2.h
Back to the patch index
Back to the overall index
- Lines: 1416
- Date:
Fri Aug 2 17:39:44 2002
- Orig file:
linux-2.4.18/drivers/ieee1394/video1394.c
- Orig date:
Mon Feb 25 11:37:58 2002
diff -urN linux-2.4.18/drivers/ieee1394/video1394.c linux-2.4.19/drivers/ieee1394/video1394.c
@@ -18,6 +18,9 @@
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+/* jds -- add private data to file to keep track of iso contexts associated
+ with each open -- so release won't kill all iso transfers */
+
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/list.h>
@@ -31,19 +34,12 @@
#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/smp_lock.h>
-#include <asm/byteorder.h>
-#include <asm/atomic.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/tqueue.h>
#include <linux/delay.h>
#include <linux/devfs_fs_kernel.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <linux/sched.h>
-#include <asm/segment.h>
+#include <asm/bitops.h>
#include <linux/types.h>
#include <linux/wrapper.h>
#include <linux/vmalloc.h>
@@ -59,7 +55,6 @@
#include "ohci1394.h"
-#define VIDEO1394_MAJOR 172
#define ISO_CHANNELS 64
#define ISO_RECEIVE 0
#define ISO_TRANSMIT 1
@@ -72,6 +67,14 @@
#define vmalloc_32(x) vmalloc(x)
#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,3))
+#define remap_page_range_1394(vma, start, addr, size, prot) \
+ remap_page_range(start, addr, size, prot)
+#else
+#define remap_page_range_1394(vma, start, addr, size, prot) \
+ remap_page_range(vma, start, addr, size, prot)
+#endif
+
struct it_dma_prg {
struct dma_cmd begin;
quadlet_t data[4];
@@ -81,6 +84,7 @@
struct dma_iso_ctx {
struct ti_ohci *ohci;
+ int type; /* ISO_TRANSMIT or ISO_RECEIVE */
int ctx;
int channel;
int last_buffer;
@@ -108,6 +112,8 @@
spinlock_t lock;
unsigned int syt_offset;
int flags;
+
+ struct list_head link;
};
struct video_card {
@@ -115,9 +121,12 @@
struct list_head list;
int id;
devfs_handle_t devfs;
+};
- struct dma_iso_ctx **ir_context;
- struct dma_iso_ctx **it_context;
+
+struct file_ctx {
+ struct video_card *video;
+ struct list_head context_list;
struct dma_iso_ctx *current_ctx;
};
@@ -145,7 +154,7 @@
printk(level "video1394_%d: " fmt "\n" , card , ## args)
static void irq_handler(int card, quadlet_t isoRecvIntEvent,
- quadlet_t isoXmitIntEvent);
+ quadlet_t isoXmitIntEvent, void *data);
static LIST_HEAD(video1394_cards);
static spinlock_t video1394_cards_lock = SPIN_LOCK_UNLOCKED;
@@ -153,94 +162,41 @@
static devfs_handle_t devfs_handle;
static struct hpsb_highlevel *hl_handle = NULL;
-static struct video_template video_tmpl = { irq_handler };
-
/* Code taken from bttv.c */
/*******************************/
/* Memory management functions */
/*******************************/
-#define MDEBUG(x) do { } while(0) /* Debug memory management */
-
-/* [DaveM] I've recoded most of this so that:
- * 1) It's easier to tell what is happening
- * 2) It's more portable, especially for translating things
- * out of vmalloc mapped areas in the kernel.
- * 3) Less unnecessary translations happen.
- *
- * The code used to assume that the kernel vmalloc mappings
- * existed in the page tables of every process, this is simply
- * not guaranteed. We now use pgd_offset_k which is the
- * defined way to get at the kernel page tables.
- */
-
-/* Given PGD from the address space's page table, return the kernel
- * virtual mapping of the physical memory mapped at ADR.
- */
-static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr)
-{
- unsigned long ret = 0UL;
- pmd_t *pmd;
- pte_t *ptep, pte;
-
- if (!pgd_none(*pgd)) {
- pmd = pmd_offset(pgd, adr);
- if (!pmd_none(*pmd)) {
- ptep = pte_offset(pmd, adr);
- pte = *ptep;
- if(pte_present(pte)) {
- ret = (unsigned long)
- page_address(pte_page(pte));
- ret |= (adr & (PAGE_SIZE - 1));
- }
- }
- }
- MDEBUG(printk("uv2kva(%lx-->%lx)", adr, ret));
- return ret;
-}
-
-static inline unsigned long uvirt_to_bus(unsigned long adr)
-{
- unsigned long kva, ret;
-
- kva = uvirt_to_kva(pgd_offset(current->mm, adr), adr);
- ret = virt_to_bus((void *)kva);
- MDEBUG(printk("uv2b(%lx-->%lx)", adr, ret));
- return ret;
-}
-
static inline unsigned long kvirt_to_bus(unsigned long adr)
{
- unsigned long va, kva, ret;
+ unsigned long kva, ret;
- va = VMALLOC_VMADDR(adr);
- kva = uvirt_to_kva(pgd_offset_k(va), va);
+ kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
+ kva |= adr & (PAGE_SIZE-1); /* restore the offset */
ret = virt_to_bus((void *)kva);
- MDEBUG(printk("kv2b(%lx-->%lx)", adr, ret));
- return ret;
+ return ret;
}
/* Here we want the physical address of the memory.
- * This is used when initializing the contents of the
- * area and marking the pages as reserved.
+ * This is used when initializing the contents of the area.
*/
static inline unsigned long kvirt_to_pa(unsigned long adr)
{
- unsigned long va, kva, ret;
+ unsigned long kva, ret;
- va = VMALLOC_VMADDR(adr);
- kva = uvirt_to_kva(pgd_offset_k(va), va);
+ kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
+ kva |= adr & (PAGE_SIZE-1); /* restore the offset */
ret = __pa(kva);
- MDEBUG(printk("kv2pa(%lx-->%lx)", adr, ret));
return ret;
}
static void * rvmalloc(unsigned long size)
{
void * mem;
- unsigned long adr, page;
-
+ unsigned long adr;
+
+ size=PAGE_ALIGN(size);
mem=vmalloc_32(size);
if (mem)
{
@@ -249,8 +205,7 @@
adr=(unsigned long) mem;
while (size > 0)
{
- page = kvirt_to_pa(adr);
- mem_map_reserve(virt_to_page(__va(page)));
+ mem_map_reserve(vmalloc_to_page((void *)adr));
adr+=PAGE_SIZE;
size-=PAGE_SIZE;
}
@@ -260,15 +215,14 @@
static void rvfree(void * mem, unsigned long size)
{
- unsigned long adr, page;
-
+ unsigned long adr;
+
if (mem)
{
adr=(unsigned long) mem;
- while (size > 0)
+ while ((long) size > 0)
{
- page = kvirt_to_pa(adr);
- mem_map_unreserve(virt_to_page(__va(page)));
+ mem_map_unreserve(vmalloc_to_page((void *)adr));
adr+=PAGE_SIZE;
size-=PAGE_SIZE;
}
@@ -277,56 +231,75 @@
}
/* End of code taken from bttv.c */
-static int free_dma_iso_ctx(struct dma_iso_ctx **d)
+static int free_dma_iso_ctx(struct dma_iso_ctx *d)
{
int i;
- struct ti_ohci *ohci;
+ unsigned long *usage;
- if ((*d)==NULL) return -1;
-
- ohci = (struct ti_ohci *)(*d)->ohci;
-
- DBGMSG(ohci->id, "Freeing dma_iso_ctx %d", (*d)->ctx);
-
- ohci1394_stop_context(ohci, (*d)->ctrlClear, NULL);
+ DBGMSG(d->ohci->id, "Freeing dma_iso_ctx %d", d->ctx);
- if ((*d)->buf) rvfree((void *)(*d)->buf,
- (*d)->num_desc * (*d)->buf_size);
+ ohci1394_stop_context(d->ohci, d->ctrlClear, NULL);
+ ohci1394_unhook_irq(d->ohci, irq_handler, d);
- if ((*d)->ir_prg) {
- for (i=0;i<(*d)->num_desc;i++)
- if ((*d)->ir_prg[i]) kfree((*d)->ir_prg[i]);
- kfree((*d)->ir_prg);
- }
-
- if ((*d)->it_prg) {
- for (i=0;i<(*d)->num_desc;i++)
- if ((*d)->it_prg[i]) kfree((*d)->it_prg[i]);
- kfree((*d)->it_prg);
- }
+ if (d->buf)
+ rvfree((void *)d->buf, d->num_desc * d->buf_size);
- if ((*d)->buffer_status)
- kfree((*d)->buffer_status);
- if ((*d)->buffer_time)
- kfree((*d)->buffer_time);
- if ((*d)->last_used_cmd)
- kfree((*d)->last_used_cmd);
- if ((*d)->next_buffer)
- kfree((*d)->next_buffer);
+ if (d->ir_prg) {
+ for (i=0;i<d->num_desc;i++)
+ if (d->ir_prg[i]) kfree(d->ir_prg[i]);
+ kfree(d->ir_prg);
+ }
+
+ if (d->it_prg) {
+ for (i=0;i<d->num_desc;i++)
+ if (d->it_prg[i]) kfree(d->it_prg[i]);
+ kfree(d->it_prg);
+ }
+
+ if (d->buffer_status)
+ kfree(d->buffer_status);
+ if (d->buffer_time)
+ kfree(d->buffer_time);
+ if (d->last_used_cmd)
+ kfree(d->last_used_cmd);
+ if (d->next_buffer)
+ kfree(d->next_buffer);
+
+ usage = (d->type == ISO_RECEIVE) ? &d->ohci->ir_ctx_usage :
+ &d->ohci->it_ctx_usage;
+
+ /* clear the ISO context usage bit */
+ clear_bit(d->ctx, usage);
+ list_del(&d->link);
- kfree(*d);
- *d = NULL;
+ kfree(d);
return 0;
}
static struct dma_iso_ctx *
-alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int ctx, int num_desc,
+alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
int buf_size, int channel, unsigned int packet_size)
{
struct dma_iso_ctx *d=NULL;
int i;
+ unsigned long *usage = (type == ISO_RECEIVE) ? &ohci->ir_ctx_usage :
+ &ohci->it_ctx_usage;
+
+ /* try to claim the ISO context usage bit */
+ for (i = 0; i < ohci->nb_iso_rcv_ctx; i++) {
+ if (!test_and_set_bit(i, usage)) {
+ PRINT(KERN_ERR, ohci->id, "Free iso ctx %d found", i);
+ break;
+ }
+ }
+
+ if (i == ohci->nb_iso_rcv_ctx) {
+ PRINT(KERN_ERR, ohci->id, "No DMA contexts available");
+ return NULL;
+ }
+
d = (struct dma_iso_ctx *)kmalloc(sizeof(struct dma_iso_ctx),
GFP_KERNEL);
if (d==NULL) {
@@ -337,7 +310,8 @@
memset(d, 0, sizeof(struct dma_iso_ctx));
d->ohci = (void *)ohci;
- d->ctx = ctx;
+ d->type = type;
+ d->ctx = i;
d->channel = channel;
d->num_desc = num_desc;
d->frame_size = buf_size;
@@ -350,11 +324,17 @@
d->ir_prg = NULL;
init_waitqueue_head(&d->waitq);
+ if (ohci1394_hook_irq(ohci, irq_handler, d) != 0) {
+ PRINT(KERN_ERR, ohci->id, "ohci1394_hook_irq() failed");
+ free_dma_iso_ctx(d);
+ return NULL;
+ }
+
d->buf = rvmalloc(d->num_desc * d->buf_size);
if (d->buf == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate dma buffer");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
memset(d->buf, 0, d->num_desc * d->buf_size);
@@ -371,7 +351,7 @@
if (d->ir_prg == NULL) {
PRINT(KERN_ERR, ohci->id,
"Failed to allocate dma ir prg");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
memset(d->ir_prg, 0, d->num_desc * sizeof(struct dma_cmd *));
@@ -387,7 +367,7 @@
if (d->ir_prg[i] == NULL) {
PRINT(KERN_ERR, ohci->id,
"Failed to allocate dma ir prg");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
}
@@ -403,7 +383,7 @@
if (d->it_prg == NULL) {
PRINT(KERN_ERR, ohci->id,
"Failed to allocate dma it prg");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
memset(d->it_prg, 0, d->num_desc*sizeof(struct it_dma_prg *));
@@ -415,7 +395,7 @@
"Packet size %d (page_size: %ld) "
"not yet supported\n",
packet_size, PAGE_SIZE);
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
@@ -434,7 +414,7 @@
if (d->it_prg[i] == NULL) {
PRINT(KERN_ERR, ohci->id,
"Failed to allocate dma it prg");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
}
@@ -451,22 +431,22 @@
if (d->buffer_status == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate buffer_status");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
if (d->buffer_time == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate buffer_time");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
if (d->last_used_cmd == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate last_used_cmd");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
if (d->next_buffer == NULL) {
PRINT(KERN_ERR, ohci->id, "Failed to allocate next_buffer");
- free_dma_iso_ctx(&d);
+ free_dma_iso_ctx(d);
return NULL;
}
memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int));
@@ -487,11 +467,11 @@
static void reset_ir_status(struct dma_iso_ctx *d, int n)
{
int i;
- d->ir_prg[n][0].status = 4;
- d->ir_prg[n][1].status = PAGE_SIZE-4;
+ d->ir_prg[n][0].status = cpu_to_le32(4);
+ d->ir_prg[n][1].status = cpu_to_le32(PAGE_SIZE-4);
for (i=2;i<d->nb_cmd-1;i++)
- d->ir_prg[n][i].status = PAGE_SIZE;
- d->ir_prg[n][i].status = d->left_size;
+ d->ir_prg[n][i].status = cpu_to_le32(PAGE_SIZE);
+ d->ir_prg[n][i].status = cpu_to_le32(d->left_size);
}
static void initialize_dma_ir_prg(struct dma_iso_ctx *d, int n, int flags)
@@ -501,38 +481,38 @@
int i;
/* the first descriptor will read only 4 bytes */
- ir_prg[0].control = DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
- DMA_CTL_BRANCH | 4;
+ ir_prg[0].control = cpu_to_le32(DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
+ DMA_CTL_BRANCH | 4);
/* set the sync flag */
if (flags & VIDEO1394_SYNC_FRAMES)
- ir_prg[0].control |= DMA_CTL_WAIT;
+ ir_prg[0].control |= cpu_to_le32(DMA_CTL_WAIT);
- ir_prg[0].address = kvirt_to_bus(buf);
- ir_prg[0].branchAddress = (virt_to_bus(&(ir_prg[1].control))
- & 0xfffffff0) | 0x1;
+ ir_prg[0].address = cpu_to_le32(kvirt_to_bus(buf));
+ ir_prg[0].branchAddress = cpu_to_le32((virt_to_bus(&(ir_prg[1].control))
+ & 0xfffffff0) | 0x1);
/* the second descriptor will read PAGE_SIZE-4 bytes */
- ir_prg[1].control = DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
- DMA_CTL_BRANCH | (PAGE_SIZE-4);
- ir_prg[1].address = kvirt_to_bus(buf+4);
- ir_prg[1].branchAddress = (virt_to_bus(&(ir_prg[2].control))
- & 0xfffffff0) | 0x1;
+ ir_prg[1].control = cpu_to_le32(DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
+ DMA_CTL_BRANCH | (PAGE_SIZE-4));
+ ir_prg[1].address = cpu_to_le32(kvirt_to_bus(buf+4));
+ ir_prg[1].branchAddress = cpu_to_le32((virt_to_bus(&(ir_prg[2].control))
+ & 0xfffffff0) | 0x1);
for (i=2;i<d->nb_cmd-1;i++) {
- ir_prg[i].control = DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
- DMA_CTL_BRANCH | PAGE_SIZE;
- ir_prg[i].address = kvirt_to_bus(buf+(i-1)*PAGE_SIZE);
+ ir_prg[i].control = cpu_to_le32(DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
+ DMA_CTL_BRANCH | PAGE_SIZE);
+ ir_prg[i].address = cpu_to_le32(kvirt_to_bus(buf+(i-1)*PAGE_SIZE));
ir_prg[i].branchAddress =
- (virt_to_bus(&(ir_prg[i+1].control))
- & 0xfffffff0) | 0x1;
+ cpu_to_le32((virt_to_bus(&(ir_prg[i+1].control))
+ & 0xfffffff0) | 0x1);
}
/* the last descriptor will generate an interrupt */
- ir_prg[i].control = DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
- DMA_CTL_IRQ | DMA_CTL_BRANCH | d->left_size;
- ir_prg[i].address = kvirt_to_bus(buf+(i-1)*PAGE_SIZE);
+ ir_prg[i].control = cpu_to_le32(DMA_CTL_INPUT_MORE | DMA_CTL_UPDATE |
+ DMA_CTL_IRQ | DMA_CTL_BRANCH | d->left_size);
+ ir_prg[i].address = cpu_to_le32(kvirt_to_bus(buf+(i-1)*PAGE_SIZE));
}
static void initialize_dma_ir_ctx(struct dma_iso_ctx *d, int tag, int flags)
@@ -568,38 +548,19 @@
}
/* find which context is listening to this channel */
-int ir_ctx_listening(struct video_card *video, int channel)
-{
- int i;
- struct ti_ohci *ohci = video->ohci;
-
- for (i=0;i<ohci->nb_iso_rcv_ctx-1;i++)
- if (video->ir_context[i]) {
- if (video->ir_context[i]->channel==channel)
- return i;
- }
-
- PRINT(KERN_ERR, ohci->id, "No iso context is listening to channel %d",
- channel);
-
- return -1;
-}
-
-int it_ctx_talking(struct video_card *video, int channel)
+static struct dma_iso_ctx *
+find_ctx(struct list_head *list, int type, int channel)
{
- int i;
- struct ti_ohci *ohci = video->ohci;
+ struct list_head *lh;
- for (i=0;i<ohci->nb_iso_xmit_ctx;i++)
- if (video->it_context[i]) {
- if (video->it_context[i]->channel==channel)
- return i;
- }
-
- PRINT(KERN_ERR, ohci->id, "No iso context is talking to channel %d",
- channel);
+ list_for_each(lh, list) {
+ struct dma_iso_ctx *ctx;
+ ctx = list_entry(lh, struct dma_iso_ctx, link);
+ if (ctx->type == type && ctx->channel == channel)
+ return ctx;
+ }
- return -1;
+ return NULL;
}
int wakeup_dma_ir_ctx(struct ti_ohci *ohci, struct dma_iso_ctx *d)
@@ -614,10 +575,14 @@
spin_lock(&d->lock);
for (i=0;i<d->num_desc;i++) {
- if (d->ir_prg[i][d->nb_cmd-1].status & 0xFFFF0000) {
+ if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) {
reset_ir_status(d, i);
d->buffer_status[i] = VIDEO1394_BUFFER_READY;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
+ get_fast_time(&d->buffer_time[i]);
+#else
do_gettimeofday(&d->buffer_time[i]);
+#endif
}
}
spin_unlock(&d->lock);
@@ -646,7 +611,7 @@
buf[7] = timeStamp & 0xff;
/* if first packet is empty packet, then put timestamp into the next full one too */
- if ( (d->it_prg[n][0].data[1] >>16) == 0x008) {
+ if ( (le32_to_cpu(d->it_prg[n][0].data[1]) >>16) == 0x008) {
buf += d->packet_size;
buf[6] = timeStamp >> 8;
buf[7] = timeStamp & 0xff;
@@ -665,7 +630,7 @@
buf[7] = timeStamp & 0xff;
/* if first packet is empty packet, then put timestamp into the next full one too */
- if ( (d->it_prg[n][0].data[1] >>16) == 0x008) {
+ if ( (le32_to_cpu(d->it_prg[n][0].data[1]) >>16) == 0x008) {
buf += d->packet_size;
buf[6] = timeStamp >> 8;
buf[7] = timeStamp & 0xff;
@@ -689,7 +654,8 @@
spin_lock(&d->lock);
for (i=0;i<d->num_desc;i++) {
- if (d->it_prg[i][d->last_used_cmd[i]].end.status& 0xFFFF0000) {
+ if (d->it_prg[i][d->last_used_cmd[i]].end.status&
+ cpu_to_le32(0xFFFF0000)) {
int next = d->next_buffer[i];
put_timestamp(ohci, d, next);
d->it_prg[i][d->last_used_cmd[i]].end.status = 0;
@@ -709,39 +675,40 @@
d->last_used_cmd[n] = d->nb_cmd - 1;
for (i=0;i<d->nb_cmd;i++) {
- it_prg[i].begin.control = DMA_CTL_OUTPUT_MORE |
- DMA_CTL_IMMEDIATE | 8 ;
+ it_prg[i].begin.control = cpu_to_le32(DMA_CTL_OUTPUT_MORE |
+ DMA_CTL_IMMEDIATE | 8) ;
it_prg[i].begin.address = 0;
it_prg[i].begin.status = 0;
- it_prg[i].data[0] =
+ it_prg[i].data[0] = cpu_to_le32(
(SPEED_100 << 16)
| (/* tag */ 1 << 14)
| (d->channel << 8)
- | (TCODE_ISO_DATA << 4);
- if (i==0) it_prg[i].data[0] |= sync_tag;
- it_prg[i].data[1] = d->packet_size << 16;
+ | (TCODE_ISO_DATA << 4));
+ if (i==0) it_prg[i].data[0] |= cpu_to_le32(sync_tag);
+ it_prg[i].data[1] = cpu_to_le32(d->packet_size << 16);
it_prg[i].data[2] = 0;
it_prg[i].data[3] = 0;
- it_prg[i].end.control = DMA_CTL_OUTPUT_LAST | DMA_CTL_BRANCH;
+ it_prg[i].end.control = cpu_to_le32(DMA_CTL_OUTPUT_LAST |
+ DMA_CTL_BRANCH);
it_prg[i].end.address =
- kvirt_to_bus(buf+i*d->packet_size);
+ cpu_to_le32(kvirt_to_bus(buf+i*d->packet_size));
if (i<d->nb_cmd-1) {
- it_prg[i].end.control |= d->packet_size;
+ it_prg[i].end.control |= cpu_to_le32(d->packet_size);
it_prg[i].begin.branchAddress =
- (virt_to_bus(&(it_prg[i+1].begin.control))
- & 0xfffffff0) | 0x3;
+ cpu_to_le32((virt_to_bus(&(it_prg[i+1].begin.control))
+ & 0xfffffff0) | 0x3);
it_prg[i].end.branchAddress =
- (virt_to_bus(&(it_prg[i+1].begin.control))
- & 0xfffffff0) | 0x3;
+ cpu_to_le32((virt_to_bus(&(it_prg[i+1].begin.control))
+ & 0xfffffff0) | 0x3);
}
else {
/* the last prg generates an interrupt */
- it_prg[i].end.control |= DMA_CTL_UPDATE |
- DMA_CTL_IRQ | d->left_size;
+ it_prg[i].end.control |= cpu_to_le32(DMA_CTL_UPDATE |
+ DMA_CTL_IRQ | d->left_size);
/* the last prg doesn't branch */
it_prg[i].begin.branchAddress = 0;
it_prg[i].end.branchAddress = 0;
@@ -780,21 +747,21 @@
} else {
size = packet_sizes[i];
}
- it_prg[i].data[1] = size << 16;
- it_prg[i].end.control = DMA_CTL_OUTPUT_LAST | DMA_CTL_BRANCH;
+ it_prg[i].data[1] = cpu_to_le32(size << 16);
+ it_prg[i].end.control = cpu_to_le32(DMA_CTL_OUTPUT_LAST | DMA_CTL_BRANCH);
if (i < d->nb_cmd-1 && packet_sizes[i+1] != 0) {
- it_prg[i].end.control |= size;
+ it_prg[i].end.control |= cpu_to_le32(size);
it_prg[i].begin.branchAddress =
- (virt_to_bus(&(it_prg[i+1].begin.control))
- & 0xfffffff0) | 0x3;
+ cpu_to_le32((virt_to_bus(&(it_prg[i+1].begin.control))
+ & 0xfffffff0) | 0x3);
it_prg[i].end.branchAddress =
- (virt_to_bus(&(it_prg[i+1].begin.control))
- & 0xfffffff0) | 0x3;
+ cpu_to_le32((virt_to_bus(&(it_prg[i+1].begin.control))
+ & 0xfffffff0) | 0x3);
} else {
/* the last prg generates an interrupt */
- it_prg[i].end.control |= DMA_CTL_UPDATE |
- DMA_CTL_IRQ | size;
+ it_prg[i].end.control |= cpu_to_le32(DMA_CTL_UPDATE |
+ DMA_CTL_IRQ | size);
/* the last prg doesn't branch */
it_prg[i].begin.branchAddress = 0;
it_prg[i].end.branchAddress = 0;
@@ -822,13 +789,14 @@
reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, 1<<d->ctx);
}
-static int do_iso_mmap(struct ti_ohci *ohci, struct dma_iso_ctx *d,
- const char *adr, unsigned long size)
+static int do_iso_mmap(struct ti_ohci *ohci, struct dma_iso_ctx *d,
+ struct vm_area_struct *vma)
{
- unsigned long start=(unsigned long) adr;
- unsigned long page,pos;
+ unsigned long start = vma->vm_start;
+ unsigned long size = vma->vm_end - vma->vm_start;
+ unsigned long page, pos;
- if (size>d->num_desc * d->buf_size) {
+ if (size > d->num_desc * d->buf_size) {
PRINT(KERN_ERR, ohci->id,
"iso context %d buf size is different from mmap size",
d->ctx);
@@ -840,14 +808,14 @@
return -EINVAL;
}
- pos=(unsigned long) d->buf;
+ pos = (unsigned long) d->buf;
while (size > 0) {
page = kvirt_to_pa(pos);
- if (remap_page_range(start, page, PAGE_SIZE, PAGE_SHARED))
+ if (remap_page_range_1394(vma, start, page, PAGE_SIZE, PAGE_SHARED))
return -EAGAIN;
- start+=PAGE_SIZE;
- pos+=PAGE_SIZE;
- size-=PAGE_SIZE;
+ start += PAGE_SIZE;
+ pos += PAGE_SIZE;
+ size -= PAGE_SIZE;
}
return 0;
}
@@ -855,29 +823,10 @@
static int video1394_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
- struct video_card *video = NULL;
- struct ti_ohci *ohci = NULL;
+ struct file_ctx *ctx = (struct file_ctx *)file->private_data;
+ struct video_card *video = ctx->video;
+ struct ti_ohci *ohci = video->ohci;
unsigned long flags;
- struct list_head *lh;
-
- spin_lock_irqsave(&video1394_cards_lock, flags);
- if (!list_empty(&video1394_cards)) {
- struct video_card *p;
- list_for_each(lh, &video1394_cards) {
- p = list_entry(lh, struct video_card, list);
- if (p->id == MINOR(inode->i_rdev)) {
- video = p;
- ohci = video->ohci;
- break;
- }
- }
- }
- spin_unlock_irqrestore(&video1394_cards_lock, flags);
-
- if (video == NULL) {
- PRINT_G(KERN_ERR, __FUNCTION__": Unknown video card for minor %d", MINOR(inode->i_rdev));
- return -EFAULT;
- }
switch(cmd)
{
@@ -886,6 +835,7 @@
{
struct video1394_mmap v;
u64 mask;
+ struct dma_iso_ctx *d;
int i;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
@@ -897,7 +847,7 @@
for (i=0; i<ISO_CHANNELS; i++) {
if (!(ohci->ISO_channel_usage & mask)) {
v.channel = i;
- PRINT(KERN_INFO, ohci->id, "Found free channel %d\n", i);
+ PRINT(KERN_INFO, ohci->id, "Found free channel %d", i);
break;
}
mask = mask << 1;
@@ -920,7 +870,7 @@
return -EFAULT;
}
ohci->ISO_channel_usage |= mask;
-
+
if (v.buf_size<=0) {
PRINT(KERN_ERR, ohci->id,
"Invalid %d length buffer requested",v.buf_size);
@@ -941,67 +891,47 @@
}
if (cmd == VIDEO1394_LISTEN_CHANNEL) {
- /* find a free iso receive context */
- for (i=0;i<ohci->nb_iso_rcv_ctx-1;i++)
- if (video->ir_context[i]==NULL) break;
-
- if (i==(ohci->nb_iso_rcv_ctx-1)) {
- PRINT(KERN_ERR, ohci->id,
- "No iso context available");
- return -EFAULT;
- }
+ d = alloc_dma_iso_ctx(ohci, ISO_RECEIVE,
+ v.nb_buffers, v.buf_size,
+ v.channel, 0);
- video->ir_context[i] =
- alloc_dma_iso_ctx(ohci, ISO_RECEIVE, i+1,
- v.nb_buffers, v.buf_size,
- v.channel, 0);
-
- if (video->ir_context[i] == NULL) {
+ if (d == NULL) {
PRINT(KERN_ERR, ohci->id,
"Couldn't allocate ir context");
return -EFAULT;
}
- initialize_dma_ir_ctx(video->ir_context[i],
- v.sync_tag, v.flags);
+ initialize_dma_ir_ctx(d, v.sync_tag, v.flags);
- video->current_ctx = video->ir_context[i];
+ ctx->current_ctx = d;
- v.buf_size = video->ir_context[i]->buf_size;
+ v.buf_size = d->buf_size;
+ list_add_tail(&d->link, &ctx->context_list);
PRINT(KERN_INFO, ohci->id,
- "iso context %d listen on channel %d", i+1,
- v.channel);
+ "iso context %d listen on channel %d",
+ d->ctx, v.channel);
}
else {
- /* find a free iso transmit context */
- for (i=0;i<ohci->nb_iso_xmit_ctx;i++)
- if (video->it_context[i]==NULL) break;
-
- if (i==ohci->nb_iso_xmit_ctx) {
- PRINT(KERN_ERR, ohci->id,
- "No iso context available");
- return -EFAULT;
- }
-
- video->it_context[i] =
- alloc_dma_iso_ctx(ohci, ISO_TRANSMIT, i,
- v.nb_buffers, v.buf_size,
- v.channel, v.packet_size);
+ d = alloc_dma_iso_ctx(ohci, ISO_TRANSMIT,
+ v.nb_buffers, v.buf_size,
+ v.channel, v.packet_size);
- if (video->it_context[i] == NULL) {
+ if (d == NULL) {
PRINT(KERN_ERR, ohci->id,
"Couldn't allocate it context");
return -EFAULT;
}
- initialize_dma_it_ctx(video->it_context[i],
- v.sync_tag, v.syt_offset, v.flags);
+ initialize_dma_it_ctx(d, v.sync_tag,
+ v.syt_offset, v.flags);
- video->current_ctx = video->it_context[i];
+ ctx->current_ctx = d;
- v.buf_size = video->it_context[i]->buf_size;
+ v.buf_size = d->buf_size;
+
+ list_add_tail(&d->link, &ctx->context_list);
PRINT(KERN_INFO, ohci->id,
- "Iso context %d talk on channel %d", i,
+ "Iso context %d talk on channel %d", d->ctx,
v.channel);
}
@@ -1015,7 +945,7 @@
{
int channel;
u64 mask;
- int i;
+ struct dma_iso_ctx *d;
if(copy_from_user(&channel, (void *)arg, sizeof(int)))
return -EFAULT;
@@ -1031,28 +961,19 @@
"Channel %d is not being used", channel);
return -EFAULT;
}
- ohci->ISO_channel_usage &= ~mask;
-
- if (cmd == VIDEO1394_UNLISTEN_CHANNEL) {
- i = ir_ctx_listening(video, channel);
- if (i<0) return -EFAULT;
- free_dma_iso_ctx(&video->ir_context[i]);
-
- PRINT(KERN_INFO, ohci->id,
- "Iso context %d stop listening on channel %d",
- i+1, channel);
- }
- else {
- i = it_ctx_talking(video, channel);
- if (i<0) return -EFAULT;
+ /* Mark this channel as unused */
+ ohci->ISO_channel_usage &= ~mask;
- free_dma_iso_ctx(&video->it_context[i]);
+ if (cmd == VIDEO1394_UNLISTEN_CHANNEL)
+ d = find_ctx(&ctx->context_list, ISO_RECEIVE, channel);
+ else
+ d = find_ctx(&ctx->context_list, ISO_TRANSMIT, channel);
- PRINT(KERN_INFO, ohci->id,
- "Iso context %d stop talking on channel %d",
- i, channel);
- }
+ if (d == NULL) return -EFAULT;
+ PRINT(KERN_INFO, ohci->id, "Iso context %d "
+ "stop talking on channel %d", d->ctx, channel);
+ free_dma_iso_ctx(d);
return 0;
}
@@ -1060,14 +981,11 @@
{
struct video1394_wait v;
struct dma_iso_ctx *d;
- int i;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
- i = ir_ctx_listening(video, v.channel);
- if (i<0) return -EFAULT;
- d = video->ir_context[i];
+ d = find_ctx(&ctx->context_list, ISO_RECEIVE, v.channel);
if ((v.buffer<0) || (v.buffer>d->num_desc)) {
PRINT(KERN_ERR, ohci->id,
@@ -1088,8 +1006,8 @@
if (d->last_buffer>=0)
d->ir_prg[d->last_buffer][d->nb_cmd-1].branchAddress =
- (virt_to_bus(&(d->ir_prg[v.buffer][0].control))
- & 0xfffffff0) | 0x1;
+ cpu_to_le32((virt_to_bus(&(d->ir_prg[v.buffer][0].control))
+ & 0xfffffff0) | 0x1);
d->last_buffer = v.buffer;
@@ -1129,9 +1047,7 @@
if(copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
- i = ir_ctx_listening(video, v.channel);
- if (i<0) return -EFAULT;
- d = video->ir_context[i];
+ d = find_ctx(&ctx->context_list, ISO_RECEIVE, v.channel);
if ((v.buffer<0) || (v.buffer>d->num_desc)) {
PRINT(KERN_ERR, ohci->id,
@@ -1208,14 +1124,11 @@
struct video1394_wait v;
struct video1394_queue_variable qv;
struct dma_iso_ctx *d;
- int i;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
- i = it_ctx_talking(video, v.channel);
- if (i<0) return -EFAULT;
- d = video->it_context[i];
+ d = find_ctx(&ctx->context_list, ISO_TRANSMIT, v.channel);
if ((v.buffer<0) || (v.buffer>d->num_desc)) {
PRINT(KERN_ERR, ohci->id,
@@ -1253,14 +1166,14 @@
d->it_prg[d->last_buffer]
[ d->last_used_cmd[d->last_buffer]
].end.branchAddress =
- (virt_to_bus(&(d->it_prg[v.buffer][0].begin.control))
- & 0xfffffff0) | 0x3;
+ cpu_to_le32((virt_to_bus(&(d->it_prg[v.buffer][0].begin.control))
+ & 0xfffffff0) | 0x3);
d->it_prg[d->last_buffer]
[d->last_used_cmd[d->last_buffer]
].begin.branchAddress =
- (virt_to_bus(&(d->it_prg[v.buffer][0].begin.control))
- & 0xfffffff0) | 0x3;
+ cpu_to_le32((virt_to_bus(&(d->it_prg[v.buffer][0].begin.control))
+ & 0xfffffff0) | 0x3);
d->next_buffer[d->last_buffer] = v.buffer;
}
d->last_buffer = v.buffer;
@@ -1300,14 +1213,11 @@
{
struct video1394_wait v;
struct dma_iso_ctx *d;
- int i;
if(copy_from_user(&v, (void *)arg, sizeof(v)))
return -EFAULT;
- i = it_ctx_talking(video, v.channel);
- if (i<0) return -EFAULT;
- d = video->it_context[i];
+ d = find_ctx(&ctx->context_list, ISO_TRANSMIT, v.channel);
if ((v.buffer<0) || (v.buffer>d->num_desc)) {
PRINT(KERN_ERR, ohci->id,
@@ -1357,60 +1267,36 @@
int video1394_mmap(struct file *file, struct vm_area_struct *vma)
{
- struct video_card *video = NULL;
- struct ti_ohci *ohci;
+ struct file_ctx *ctx = (struct file_ctx *)file->private_data;
+ struct video_card *video = ctx->video;
+ struct ti_ohci *ohci = video->ohci;
int res = -EINVAL;
- unsigned long flags;
- struct list_head *lh;
-
- spin_lock_irqsave(&video1394_cards_lock, flags);
- if (!list_empty(&video1394_cards)) {
- struct video_card *p;
- list_for_each(lh, &video1394_cards) {
- p = list_entry(lh, struct video_card, list);
- if (p->id == MINOR(file->f_dentry->d_inode->i_rdev)) {
- video = p;
- break;
- }
- }
- }
- spin_unlock_irqrestore(&video1394_cards_lock, flags);
-
- if (video == NULL) {
- PRINT_G(KERN_ERR, __FUNCTION__": Unknown video card for minor %d",
- MINOR(file->f_dentry->d_inode->i_rdev));
- return -EFAULT;
- }
lock_kernel();
ohci = video->ohci;
- if (video->current_ctx == NULL) {
+ if (ctx->current_ctx == NULL) {
PRINT(KERN_ERR, ohci->id, "Current iso context not set");
} else
- res = do_iso_mmap(ohci, video->current_ctx,
- (char *)vma->vm_start,
- (unsigned long)(vma->vm_end-vma->vm_start));
+ res = do_iso_mmap(ohci, ctx->current_ctx, vma);
unlock_kernel();
return res;
}
static int video1394_open(struct inode *inode, struct file *file)
{
- int i = MINOR(inode->i_rdev);
+ int i = ieee1394_file_to_instance(file);
unsigned long flags;
struct video_card *video = NULL;
struct list_head *lh;
+ struct file_ctx *ctx;
spin_lock_irqsave(&video1394_cards_lock, flags);
- if (!list_empty(&video1394_cards)) {
- struct video_card *p;
- list_for_each(lh, &video1394_cards) {
- p = list_entry(lh, struct video_card, list);
- if (p->id == i) {
- video = p;
- break;
- }
+ list_for_each(lh, &video1394_cards) {
+ struct video_card *p = list_entry(lh, struct video_card, list);
+ if (p->id == i) {
+ video = p;
+ break;
}
}
spin_unlock_irqrestore(&video1394_cards_lock, flags);
@@ -1418,136 +1304,85 @@
if (video == NULL)
return -EIO;
- V22_COMPAT_MOD_INC_USE_COUNT;
+ ctx = kmalloc(sizeof(struct file_ctx), GFP_KERNEL);
+ if (ctx == NULL) {
+ PRINT(KERN_ERR, video->ohci->id, "Cannot malloc file_ctx");
+ return -ENOMEM;
+ }
+
+ memset(ctx, 0, sizeof(struct file_ctx));
+ ctx->video = video;
+ INIT_LIST_HEAD(&ctx->context_list);
+ ctx->current_ctx = NULL;
+ file->private_data = ctx;
return 0;
}
static int video1394_release(struct inode *inode, struct file *file)
{
- struct video_card *video = NULL;
- struct ti_ohci *ohci;
+ struct file_ctx *ctx = (struct file_ctx *)file->private_data;
+ struct video_card *video = ctx->video;
+ struct ti_ohci *ohci = video->ohci;
+ struct list_head *lh, *next;
u64 mask;
- int i;
- unsigned long flags;
- struct list_head *lh;
- spin_lock_irqsave(&video1394_cards_lock, flags);
- if (!list_empty(&video1394_cards)) {
- struct video_card *p;
- list_for_each(lh, &video1394_cards) {
- p = list_entry(lh, struct video_card, list);
- if (p->id == MINOR(inode->i_rdev)) {
- video = p;
- break;
- }
- }
- }
- spin_unlock_irqrestore(&video1394_cards_lock, flags);
-
- if (video == NULL) {
- PRINT_G(KERN_ERR, __FUNCTION__": Unknown device for minor %d",
- MINOR(inode->i_rdev));
- return 1;
+ lock_kernel();
+ list_for_each_safe(lh, next, &ctx->context_list) {
+ struct dma_iso_ctx *d;
+ d = list_entry(lh, struct dma_iso_ctx, link);
+ mask = (u64) 1 << d->channel;
+
+ if (!(ohci->ISO_channel_usage & mask))
+ PRINT(KERN_ERR, ohci->id, "On release: Channel %d "
+ "is not being used", d->channel);
+ else
+ ohci->ISO_channel_usage &= ~mask;
+ PRINT(KERN_INFO, ohci->id, "On release: Iso %s context "
+ "%d stop listening on channel %d",
+ d->type == ISO_RECEIVE ? "receive" : "transmit",
+ d->ctx, d->channel);
+ free_dma_iso_ctx(d);
}
- ohci = video->ohci;
-
- lock_kernel();
- for (i=0;i<ohci->nb_iso_rcv_ctx-1;i++)
- if (video->ir_context[i]) {
- mask = (u64)0x1<<video->ir_context[i]->channel;
- if (!(ohci->ISO_channel_usage & mask))
- PRINT(KERN_ERR, ohci->id,
- "Channel %d is not being used",
- video->ir_context[i]->channel);
- else
- ohci->ISO_channel_usage &= ~mask;
- PRINT(KERN_INFO, ohci->id,
- "Iso receive context %d stop listening "
- "on channel %d", i+1,
- video->ir_context[i]->channel);
- free_dma_iso_ctx(&video->ir_context[i]);
- }
+ kfree(ctx);
+ file->private_data = NULL;
- for (i=0;i<ohci->nb_iso_xmit_ctx;i++)
- if (video->it_context[i]) {
- mask = (u64)0x1<<video->it_context[i]->channel;
- if (!(ohci->ISO_channel_usage & mask))
- PRINT(KERN_ERR, ohci->id,
- "Channel %d is not being used",
- video->it_context[i]->channel);
- else
- ohci->ISO_channel_usage &= ~mask;
- PRINT(KERN_INFO, ohci->id,
- "Iso transmit context %d stop talking "
- "on channel %d", i+1,
- video->it_context[i]->channel);
- free_dma_iso_ctx(&video->it_context[i]);
- }
-
- V22_COMPAT_MOD_DEC_USE_COUNT;
-
unlock_kernel();
return 0;
}
static void irq_handler(int card, quadlet_t isoRecvIntEvent,
- quadlet_t isoXmitIntEvent)
+ quadlet_t isoXmitIntEvent, void *data)
{
- int i;
- unsigned long flags;
- struct video_card *video = NULL;
- struct list_head *lh;
-
- spin_lock_irqsave(&video1394_cards_lock, flags);
- if (!list_empty(&video1394_cards)) {
- struct video_card *p;
- list_for_each(lh, &video1394_cards) {
- p = list_entry(lh, struct video_card, list);
- if (p->id == card) {
- video = p;
- break;
- }
- }
- }
- spin_unlock_irqrestore(&video1394_cards_lock, flags);
+ struct dma_iso_ctx *d = (struct dma_iso_ctx *) data;
- if (video == NULL) {
- PRINT_G(KERN_ERR, __FUNCTION__": Unknown card number %d!!",
- card);
- return;
- }
-
DBGMSG(card, "Iso event Recv: %08x Xmit: %08x",
isoRecvIntEvent, isoXmitIntEvent);
- for (i=0;i<video->ohci->nb_iso_rcv_ctx-1;i++)
- if (isoRecvIntEvent & (1<<(i+1)))
- wakeup_dma_ir_ctx(video->ohci,
- video->ir_context[i]);
-
- for (i=0;i<video->ohci->nb_iso_xmit_ctx;i++)
- if (isoXmitIntEvent & (1<<i))
- wakeup_dma_it_ctx(video->ohci,
- video->it_context[i]);
+ if (d->type == ISO_RECEIVE && isoRecvIntEvent & (1 << d->ctx))
+ wakeup_dma_ir_ctx(d->ohci, d);
+ if (d->type == ISO_TRANSMIT && isoXmitIntEvent & (1 << d->ctx))
+ wakeup_dma_it_ctx(d->ohci, d);
}
static struct file_operations video1394_fops=
{
- OWNER_THIS_MODULE
- ioctl: video1394_ioctl,
- mmap: video1394_mmap,
- open: video1394_open,
- release: video1394_release
+ .owner = THIS_MODULE,
+ .ioctl = video1394_ioctl,
+ .mmap = video1394_mmap,
+ .open = video1394_open,
+ .release = video1394_release
};
static int video1394_init(struct ti_ohci *ohci)
{
- struct video_card *video = kmalloc(sizeof(struct video_card), GFP_KERNEL);
+ struct video_card *video;
unsigned long flags;
char name[16];
+ int minor;
+ video = kmalloc(sizeof(struct video_card), GFP_KERNEL);
if (video == NULL) {
PRINT(KERN_ERR, ohci->id, "Cannot allocate video_card");
return -1;
@@ -1560,42 +1395,14 @@
list_add_tail(&video->list, &video1394_cards);
spin_unlock_irqrestore(&video1394_cards_lock, flags);
- if (ohci1394_register_video(ohci, &video_tmpl)<0) {
- PRINT(KERN_ERR, ohci->id, "Register_video failed");
- return -1;
- }
-
video->id = ohci->id;
video->ohci = ohci;
- /* Iso receive dma contexts */
- video->ir_context = (struct dma_iso_ctx **)
- kmalloc((ohci->nb_iso_rcv_ctx-1)*
- sizeof(struct dma_iso_ctx *), GFP_KERNEL);
- if (video->ir_context)
- memset(video->ir_context, 0,
- (ohci->nb_iso_rcv_ctx-1)*sizeof(struct dma_iso_ctx *));
- else {
- PRINT(KERN_ERR, ohci->id, "Cannot allocate ir_context");
- return -1;
- }
-
- /* Iso transmit dma contexts */
- video->it_context = (struct dma_iso_ctx **)
- kmalloc(ohci->nb_iso_xmit_ctx *
- sizeof(struct dma_iso_ctx *), GFP_KERNEL);
- if (video->it_context)
- memset(video->it_context, 0,
- ohci->nb_iso_xmit_ctx * sizeof(struct dma_iso_ctx *));
- else {
- PRINT(KERN_ERR, ohci->id, "Cannot allocate it_context");
- return -1;
- }
-
sprintf(name, "%d", video->id);
+ minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + video->id;
video->devfs = devfs_register(devfs_handle, name,
DEVFS_FL_AUTO_OWNER,
- VIDEO1394_MAJOR, 0,
+ IEEE1394_MAJOR, minor,
S_IFCHR | S_IRUSR | S_IWUSR,
&video1394_fops, NULL);
@@ -1605,27 +1412,7 @@
/* Must be called under spinlock */
static void remove_card(struct video_card *video)
{
- int i;
-
- ohci1394_unregister_video(video->ohci, &video_tmpl);
-
devfs_unregister(video->devfs);
-
- /* Free the iso receive contexts */
- if (video->ir_context) {
- for (i=0;i<video->ohci->nb_iso_rcv_ctx-1;i++) {
- free_dma_iso_ctx(&video->ir_context[i]);
- }
- kfree(video->ir_context);
- }
-
- /* Free the iso transmit contexts */
- if (video->it_context) {
- for (i=0;i<video->ohci->nb_iso_xmit_ctx;i++) {
- free_dma_iso_ctx(&video->it_context[i]);
- }
- kfree(video->it_context);
- }
list_del(&video->list);
kfree(video);
@@ -1639,7 +1426,7 @@
struct video_card *p;
/* We only work with the OHCI-1394 driver */
- if (strcmp(host->template->name, OHCI1394_DRIVER_NAME))
+ if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME))
return;
ohci = (struct ti_ohci *)host->hostdata;
@@ -1662,7 +1449,7 @@
struct ti_ohci *ohci;
/* We only work with the OHCI-1394 driver */
- if (strcmp(host->template->name, OHCI1394_DRIVER_NAME))
+ if (strcmp(host->driver->name, OHCI1394_DRIVER_NAME))
return;
ohci = (struct ti_ohci *)host->hostdata;
@@ -1673,8 +1460,8 @@
}
static struct hpsb_highlevel_ops hl_ops = {
- add_host: video1394_add_host,
- remove_host: video1394_remove_host,
+ .add_host = video1394_add_host,
+ .remove_host = video1394_remove_host,
};
MODULE_AUTHOR("Sebastien Rougeaux <sebastien.rougeaux@anu.edu.au>");
@@ -1687,19 +1474,19 @@
hpsb_unregister_highlevel (hl_handle);
devfs_unregister(devfs_handle);
- devfs_unregister_chrdev(VIDEO1394_MAJOR, VIDEO1394_DRIVER_NAME);
-
+ ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_VIDEO1394);
+
PRINT_G(KERN_INFO, "Removed " VIDEO1394_DRIVER_NAME " module");
}
static int __init video1394_init_module (void)
{
- if (devfs_register_chrdev(VIDEO1394_MAJOR, VIDEO1394_DRIVER_NAME,
- &video1394_fops)) {
- PRINT_G(KERN_ERR, "video1394: unable to get major %d\n",
- VIDEO1394_MAJOR);
- return -EIO;
- }
+ if (ieee1394_register_chardev(IEEE1394_MINOR_BLOCK_VIDEO1394,
+ THIS_MODULE, &video1394_fops)) {
+ PRINT_G(KERN_ERR, "video1394: unable to get minor device block");
+ return -EIO;
+ }
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)
devfs_handle = devfs_mk_dir(NULL, VIDEO1394_DRIVER_NAME,
strlen(VIDEO1394_DRIVER_NAME), NULL);
@@ -1711,7 +1498,7 @@
if (hl_handle == NULL) {
PRINT_G(KERN_ERR, "No more memory for driver\n");
devfs_unregister(devfs_handle);
- devfs_unregister_chrdev(VIDEO1394_MAJOR, VIDEO1394_DRIVER_NAME);
+ ieee1394_unregister_chardev(IEEE1394_MINOR_BLOCK_VIDEO1394);
return -ENOMEM;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)