--- margi2/margi.c 2001/03/15 15:58:16 1.9 +++ margi2/margi.c 2001/03/19 23:49:15 1.10 @@ -252,15 +252,6 @@ int MargiPush(struct cvdv_cards *card, i } card->DMAABusy = 1; - /* - while (ring_write_rest(&(card->rbuf)) < count && co < 100){ - printk("buffer waiting to write\n"); - co++; -// interruptible_sleep_on(&card->wqA); -// if (signal_pending(current)) -// return 0; - } - */ count = ring_write(&(card->rbuf),data,count); return count; } @@ -326,8 +317,8 @@ u32 DecoderGetBufferSpace(struct cvdv_ca audio = DecoderGetAudioBufferSpace(card); video = DecoderGetVideoBufferSpace(card); - //if (audio > 2048) audio -= 2048; - //if (video > 16384) video -= 16384; + if (audio > 2048) audio -= 2048; + if (video > 16384) video -= 16384; if (audio < video) return audio; return video; @@ -382,15 +373,17 @@ static int ringDMA (struct cvdv_cards *c u32 count=0; u8 data; + count = ring_read_rest(&(card->rbuf)); if (count < 2048) { - card->DMAABusy = 0; wake_up_interruptible(&(card->wqA)); return 0; } + stat = read_lsi_status(card); + /* - printk(KERN_DEBUG LOGNAME + printk(KERN_DEBUG LOGNAME ": -- stat: %d readpos: %d writepos: %d \n", stat,card->rbuf.read_pos,card->rbuf.write_pos); */ @@ -432,7 +425,6 @@ static int ringDMA (struct cvdv_cards *c } } else { count = 0; - //card->DMAABusy = 0; } return count; @@ -442,40 +434,67 @@ static int ringDMA (struct cvdv_cards *c u_char read_indexed_register(struct cvdv_cards * card, int addr) { dev_link_t *link = &(((margi_info_t *) card->margi)->link); - + u_char data; +#ifdef NOINT + spin_lock(&card->timelock); +#endif outb(addr, link->io.BasePort1 + DIO_CONTROL_INDEX); - return (inb(link->io.BasePort1 + DIO_CONTROL_DATA)); + data = (inb(link->io.BasePort1 + DIO_CONTROL_DATA)); +#ifdef NOINT + spin_unlock(&card->timelock); +#endif + return data; } void write_indexed_register(struct cvdv_cards *card, int addr, u_char data) { dev_link_t *link = &(((margi_info_t *) card->margi)->link); - +#ifdef NOINT + spin_lock(&card->timelock); +#endif outb(addr, link->io.BasePort1 + DIO_CONTROL_INDEX); outb(data, link->io.BasePort1 + DIO_CONTROL_DATA); + +#ifdef NOINT + spin_unlock(&card->timelock); +#endif } void WriteByte(struct cvdv_cards *card, int addr, u_char data) { dev_link_t *link = &(((margi_info_t *) card->margi)->link); +#ifdef NOINT + spin_lock(&card->timelock); +#endif outb((u_char) (addr & 255), link->io.BasePort1 + DIO_LSI_INDEX_LOW); outb(((addr & 256) ? 1 : 0), link->io.BasePort1 + DIO_LSI_INDEX_HIGH); outb(data, link->io.BasePort1 + DIO_LSI_DATA); +#ifdef NOINT + spin_unlock(&card->timelock); +#endif } u_char ReadByte(struct cvdv_cards *card, int addr) { dev_link_t *link = &(((margi_info_t *) card->margi)->link); + u_char data; +#ifdef NOINT + spin_lock(&card->timelock); +#endif outb((u_char) (addr & 255), link->io.BasePort1 + DIO_LSI_INDEX_LOW); outb(((addr & 256) ? 1 : 0), link->io.BasePort1 + DIO_LSI_INDEX_HIGH); - return inb(link->io.BasePort1 + DIO_LSI_DATA); + data = inb(link->io.BasePort1 + DIO_LSI_DATA); +#ifdef NOINT + spin_unlock(&card->timelock); +#endif + return data; } void MaskByte(struct cvdv_cards *card, int addr, u_char mask, u_char bits) @@ -485,8 +504,8 @@ void MaskByte(struct cvdv_cards *card, i -#define MAXWRITE 65536 -#define MAX_COUNT 30 +#define MAXWRITE 1024 * 100 +#define MAX_COUNT 20 #ifdef USE_BH struct cvdv_cards *bh_card; @@ -556,8 +575,10 @@ void L64014Intr_function(struct cvdv_car if(card->use_ring){ L64021Intr(card); } + count = ring_read_rest(&(card->rbuf)); - if (count) card->DMAABusy=1; + if (count) card->DMAABusy = 1; + if (card->DMAABusy){ #ifdef USE_BH @@ -580,18 +601,15 @@ void L64014Intr_function(struct cvdv_car 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); + if ( card->open ) + add_timer(&card->timer); } #endif @@ -603,11 +621,13 @@ void L64014Intr(int irq, void *dev_id, s struct cvdv_cards *card = &(margi->card); u_char dio_index, lsi_index_low, lsi_index_high; +#ifdef NOINT + spin_lock(&card->timelock); +#endif //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); + lsi_index_high = inb(margi->link.io.BasePort1 + DIO_LSI_INDEX_HIGH); L64014Intr_function(card); @@ -616,6 +636,9 @@ void L64014Intr(int irq, void *dev_id, s outb(dio_index, margi->link.io.BasePort1 + DIO_CONTROL_INDEX); outb(lsi_index_low, margi->link.io.BasePort1 + DIO_LSI_INDEX_LOW); outb(lsi_index_high,margi->link.io.BasePort1 + DIO_LSI_INDEX_HIGH); +#ifdef NOINT + spin_unlock(&card->timelock); +#endif } int L64014RemoveIntr(struct cvdv_cards *card) @@ -1175,7 +1198,6 @@ static void margi_config(dev_link_t * li dev->node.major = major_device_number; dev->node.minor = minor; link->dev = &dev->node; - v4l_init(card); #ifdef DVB dvb_register(card); #endif @@ -1277,7 +1299,6 @@ static void margi_release(u_long arg) mdelay(100); #endif CloseCard(card); - video_unregister_device(&card->video); #ifdef DVB dvb_unregister(card); #endif