--- margi2/margi.c 2001/02/01 14:47:33 1.6 +++ margi2/margi.c 2001/03/06 23:39:26 1.7 @@ -79,7 +79,6 @@ MODULE_PARM(irq_list, "1-4i"); extern unsigned int major_device_number; extern struct file_operations cvdv_fileops; - typedef struct margi_info_t { dev_link_t link; dev_node_t node; @@ -242,8 +241,6 @@ int MargiFlush (struct cvdv_cards *card) } - - int MargiPush(struct cvdv_cards *card, int count, const char *data) { // printk(KERN_DEBUG LOGNAME ": -- MargiPush(%d,0x%08lX)\n",count,(long)data); @@ -336,6 +333,47 @@ u32 DecoderGetBufferSpace(struct cvdv_ca return video; } +int MargiWriteDirect(struct cvdv_cards *card, u32 count, const char *buf) +{ + u32 size = 0; + u_char stat; + dev_link_t *link = &(((margi_info_t *) card->margi)->link); + u8 data; + + stat = read_lsi_status(card); + if (stat & LSI_ARQ) { + stat = read_lsi_status(card); + } + printk(KERN_DEBUG LOGNAME ": -- stat: %d \n",stat); + + if (stat & LSI_READY){ + data = read_indexed_register(card, IIO_LSI_CONTROL); + data |= RR; + write_indexed_register(card, IIO_LSI_CONTROL, data); + return 0; + } + + if ((stat & LSI_ARQ) == 0) { + size = DecoderGetBufferSpace(card); + if (count > size) count = size & 0xfffffffc; + if (count>=2048) count &=0xfffff800; + count &=0xfffffffc; + + if (count > size) count = size & 0xfffffffc; + printk(KERN_DEBUG LOGNAME ": -- stat:%d length:%d size:%d\n", + stat, count, size); + if (count) { + outsl_ns(link->io.BasePort1+DIO_LSI_STATUS, + buf,count); + + } + } else { + count = 0; + } + + return count; +} + static int ringDMA (struct cvdv_cards *card){ u32 size = 0; @@ -381,10 +419,9 @@ static int ringDMA (struct cvdv_cards *c card->startingV = 1; card->startingA = 1; } - + /* if (count > size) count = size & 0xfffffffc; - - /* printk(KERN_DEBUG LOGNAME + printk(KERN_DEBUG LOGNAME ": -- stat: %d length: %d size: %d startV: %d startA: %d\n", stat,count,size, card->startingV, card->startingA); */ @@ -448,8 +485,8 @@ void MaskByte(struct cvdv_cards *card, i -#define MAXWRITE 49000 -#define MAX_COUNT 10 +#define MAXWRITE 65536 +#define MAX_COUNT 30 #ifdef USE_BH struct cvdv_cards *bh_card; @@ -482,21 +519,15 @@ static void do_margi(struct cvdv_cards * } -void L64014Intr(int irq, void *dev_id, struct pt_regs *regs) + + + +void L64014Intr_function(struct cvdv_cards *card) { - margi_info_t *margi = dev_id; - struct cvdv_cards *card = &(margi->card); - u_char dio_index, lsi_index_low, lsi_index_high; u8 control,mask,stat; int try; int count; - //save registers - dio_index = inb(margi->link.io.BasePort1 + DIO_CONTROL_INDEX); - lsi_index_low = inb(margi->link.io.BasePort1 + DIO_LSI_INDEX_LOW); - lsi_index_high = - inb(margi->link.io.BasePort1 + DIO_LSI_INDEX_HIGH); - control= read_indexed_register(card, IIO_IRQ_CONTROL); if (control & IRQ_EN){ mask = 0; @@ -542,6 +573,45 @@ void L64014Intr(int irq, void *dev_id, s } } +} + + +#ifdef NOINT +void Timerfunction(unsigned long data) +{ + struct cvdv_cards *card = (struct cvdv_cards *) data; + int i; + + //spin_lock(&card->timelock); + i = del_timer(&card->timer); + L64014Intr_function(card); + //spin_unlock(&card->timelock); + // printk(KERN_DEBUG LOGNAME ": -- timer: %d \n", i); + + card->timer.function = Timerfunction; + card->timer.data=(unsigned long) card; + card->timer.expires=jiffies+1; + add_timer(&card->timer); + +} +#endif + + +void L64014Intr(int irq, void *dev_id, struct pt_regs *regs) +{ + margi_info_t *margi = dev_id; + struct cvdv_cards *card = &(margi->card); + u_char dio_index, lsi_index_low, lsi_index_high; + + //save registers + dio_index = inb(margi->link.io.BasePort1 + DIO_CONTROL_INDEX); + lsi_index_low = inb(margi->link.io.BasePort1 + DIO_LSI_INDEX_LOW); + lsi_index_high = + inb(margi->link.io.BasePort1 + DIO_LSI_INDEX_HIGH); + + + L64014Intr_function(card); + //load registers outb(dio_index, margi->link.io.BasePort1 + DIO_CONTROL_INDEX); outb(lsi_index_low, margi->link.io.BasePort1 + DIO_LSI_INDEX_LOW); @@ -580,6 +650,30 @@ void l64020Reset(struct cvdv_cards *card //write_indexed_register(card, IIO_LSI_CONTROL, DR); } +void ZV_init(struct cvdv_cards *card) +{ + u32 delay, activel; + u8 reg; + delay = 235; + activel = delay + 1448; + + // init delay and active lines + write_indexed_register(card, IIO_VIDEO_HOR_DELAY, + (u8)(delay & 0x00FF)); + write_indexed_register(card, IIO_VIDEO_HOR_ACTIVE, + (u8)(activel & 0x00FF)); + reg = ((u8)((activel >> 4) & 0x0070))|((u8)((delay >> 8) & 0x0007)); + write_indexed_register(card, IIO_VIDEO_HOR_HIGH, reg); + + //init video + reg = read_indexed_register(card, IIO_VIDEO_CONTROL0); + reg |= (ZVCLK13 | ZV16BIT | ZVCLKINV); + write_indexed_register(card, IIO_VIDEO_CONTROL0, reg); + reg = read_indexed_register(card, IIO_VIDEO_CONTROL1); + reg |= (ZV_OVERRIDE | ZV_ENABLE); + write_indexed_register(card, IIO_VIDEO_CONTROL1, reg); +} + int L64014Init(struct cvdv_cards *card) { u16 testram[16]; @@ -623,6 +717,9 @@ int L64014Init(struct cvdv_cards *card) printk("Decoder Status: %d\n", read_lsi_status(card)); printk("lsi stat %d\n", DecoderReadByte(card, 0x005)); +#ifdef USE_ZV + ZV_init(card); +#endif L64021Init(card); // Find out how much DRAM we have @@ -680,6 +777,7 @@ void CardDeInit(struct cvdv_cards *card) CloseCard(card); MargiFlush(card); MargiFreeBuffers(card); + L64014RemoveIntr(card); card_init(card, 0); } @@ -762,7 +860,12 @@ static dev_link_t *margi_attach(void) */ link->conf.Attributes = 0; link->conf.Vcc = 50; + +#ifndef USE_ZV link->conf.IntType = INT_MEMORY_AND_IO; +#else + link->conf.IntType = INT_ZOOMED_VIDEO; +#endif /* Register with Card Services */ link->next = dev_list; @@ -947,26 +1050,23 @@ static void margi_config(dev_link_t * li link->conf.Vpp1 = link->conf.Vpp2 = dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; - /* Do we need to allocate an interrupt? */ - // if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) - //link->conf.Attributes |= CONF_ENABLE_IRQ; /* Allocate an interrupt line. Note that this does not assign a handler to the interrupt, unless the 'Handler' member of the irq structure is initialized. */ - +#ifndef NOINT link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; link->irq.Handler = &L64014Intr; link->irq.Instance = link; - link->conf.Attributes |= CONF_ENABLE_IRQ; - + link->conf.Attributes |= CONF_ENABLE_IRQ; #ifdef USE_BH init_bh(MARGI_BH, do_margi_bh); #endif if (link->conf.Attributes & CONF_ENABLE_IRQ) CS_CHECK(RequestIRQ, link->handle, &link->irq); +#endif /* IO window settings */ link->io.NumPorts1 = link->io.NumPorts2 = 0; @@ -1069,11 +1169,16 @@ static void margi_config(dev_link_t * li ": ERROR: Failed to install Char-device %d, error %d\n", CVDV_MAJOR, i); } + + sprintf(dev->node.dev_name, "margi"); dev->node.major = major_device_number; dev->node.minor = minor; link->dev = &dev->node; - + v4l_init(card); +#ifdef DVB + dvb_register(card); +#endif /* Finally, report what we've done */ printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", dev->node.dev_name, link->conf.ConfigIndex, @@ -1102,7 +1207,7 @@ static void margi_config(dev_link_t * li write_indexed_register(card, IIO_GPIO_CONTROL, 0x07); L64014Init(card); - + // default: color bars VideoSetBackground(card, 1, 0, 0, 0); // black SetVideoSystem(card); @@ -1113,6 +1218,7 @@ static void margi_config(dev_link_t * li write_indexed_register(card, IIO_IRQ_CONTROL, IRQ_POL | IRQ_EN | VSYNC_EN); // write_indexed_register(card, IIO_IRQ_CONTROL, 0x24); + OSDOpen(card, 50, 50, 150, 150, 2, 1); OSDTest(card); } @@ -1164,18 +1270,27 @@ static void margi_release(u_long arg) unregister_chrdev(major_device_number, CVDV_PROCNAME); CardDeInit(card); +#ifndef NOINT #ifdef USE_BH remove_bh(MARGI_BH); #endif mdelay(100); +#endif + CloseCard(card); + video_unregister_device(&card->video); +#ifdef DVB + dvb_unregister(card); +#endif /* Don't bother checking to see if these succeed or not */ if (link->win) CardServices(ReleaseWindow, link->win); CardServices(ReleaseConfiguration, link->handle); if (link->io.NumPorts1) CardServices(ReleaseIO, link->handle, &link->io); +#ifndef NOINT if (link->irq.AssignedIRQ) CardServices(ReleaseIRQ, link->handle, &link->irq); +#endif link->state &= ~DEV_CONFIG; if (link->state & DEV_STALE_LINK)