--- margi2/margi.c 2001/03/19 23:49:15 1.10 +++ margi2/margi.c 2001/03/29 23:12:01 1.11 @@ -169,9 +169,8 @@ static dev_link_t *dev_list = NULL; (inb, outb, readb, writeb, etc) for card IO. */ - void DACSetFrequency(struct cvdv_cards *card, int khz, int multiple) { - u8 b = read_indexed_register(card, IIO_OSC_AUD); + uint8_t b = read_indexed_register(card, IIO_OSC_AUD); b &= 0xf8; @@ -206,7 +205,7 @@ int MargiFreeBuffers(struct cvdv_cards * } -int MargiSetBuffers(struct cvdv_cards *card, u32 size) +int MargiSetBuffers(struct cvdv_cards *card, uint32_t size) { MargiFreeBuffers(card); printk(KERN_DEBUG LOGNAME ": -- MargiSetBuffers(%d)\n", @@ -243,27 +242,27 @@ 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); + int fill; + + fill = ring_read_rest(&(card->rbuf)); + if (!card->use_ring) return 0; - if (!card->channelrun){ + if (fill > 3*card->rbuf.size/4 && !card->channelrun){ DecoderStartChannel(card); + card->DMAABusy = 1; } - card->DMAABusy = 1; count = ring_write(&(card->rbuf),data,count); + return count; } int DecoderStartChannel(struct cvdv_cards *card) { - //DecoderSetByte(card,0x007,0x01); // channel start DecoderMaskByte(card, 0x007, 0xC3, 0xC3); // channel start - //DecoderSetByte(card,0x005,0x01); // invert channel clock on - //DecoderDelByte(card,0x005,0x02); // channel request mode off - //DecoderDelByte(card,0x005,0x04); // channel pause off - //DecoderDelByte(card,0x005,0x08); // channel bypass enable off + #ifdef BYPASS DecoderMaskByte(card,0x005,0x0F,0x08); #else @@ -275,17 +274,16 @@ int DecoderStartChannel(struct cvdv_card int DecoderStopChannel(struct cvdv_cards *card) { - // DecoderDelByte(card,0x007,0x01); // channel reset DecoderMaskByte(card, 0x007, 0xC3, 0xC2); // channel reset DecoderSetByte(card, 0x005, 0x04); // channel pause card->channelrun = 0; return 0; } -u32 DecoderGetAudioBufferSpace(struct cvdv_cards *card) +uint32_t DecoderGetAudioBufferSpace(struct cvdv_cards *card) { - u32 MaxSize, Size; + uint32_t MaxSize, Size; MaxSize = card->AudioESSize; Size = DecoderGetAudioESLevel(card); @@ -296,10 +294,10 @@ u32 DecoderGetAudioBufferSpace(struct cv } -u32 DecoderGetVideoBufferSpace(struct cvdv_cards *card) +uint32_t DecoderGetVideoBufferSpace(struct cvdv_cards *card) { - u32 MaxSize, Size; + uint32_t MaxSize, Size; MaxSize = card->VideoESSize; Size = DecoderGetVideoESLevel(card); @@ -310,26 +308,26 @@ u32 DecoderGetVideoBufferSpace(struct cv } -u32 DecoderGetBufferSpace(struct cvdv_cards *card) +uint32_t DecoderGetBufferSpace(struct cvdv_cards *card) { - u32 audio,video; + uint32_t audio,video; audio = DecoderGetAudioBufferSpace(card); video = DecoderGetVideoBufferSpace(card); if (audio > 2048) audio -= 2048; - if (video > 16384) video -= 16384; + if (video > 2048) video -= 2048; if (audio < video) return audio; return video; } -int MargiWriteDirect(struct cvdv_cards *card, u32 count, const char *buf) +int MargiWriteDirect(struct cvdv_cards *card, uint32_t count, const char *buf) { - u32 size = 0; + uint32_t size = 0; u_char stat; dev_link_t *link = &(((margi_info_t *) card->margi)->link); - u8 data; + uint8_t data; stat = read_lsi_status(card); if (stat & LSI_ARQ) { @@ -367,11 +365,11 @@ int MargiWriteDirect(struct cvdv_cards * static int ringDMA (struct cvdv_cards *card){ - u32 size = 0; + uint32_t size = 0; u_char stat; dev_link_t *link = &(((margi_info_t *) card->margi)->link); - u32 count=0; - u8 data; + uint32_t count=0; + uint8_t data; count = ring_read_rest(&(card->rbuf)); @@ -382,11 +380,11 @@ static int ringDMA (struct cvdv_cards *c stat = read_lsi_status(card); - /* - printk(KERN_DEBUG LOGNAME +#if 0 + printk(KERN_ERR LOGNAME ": -- stat: %d readpos: %d writepos: %d \n", stat,card->rbuf.read_pos,card->rbuf.write_pos); - */ +#endif if (stat & LSI_ARQ) { stat = read_lsi_status(card); } @@ -406,18 +404,20 @@ static int ringDMA (struct cvdv_cards *c if (!size && !card->DecoderOpen ){ - printk(KERN_DEBUG LOGNAME + printk(KERN_ERR LOGNAME ": -- PREPARE IT ALREADY\n"); Prepare(card); card->startingV = 1; card->startingA = 1; } - /* + if (count > size) count = size & 0xfffffffc; - printk(KERN_DEBUG LOGNAME +#if 0 + printk(KERN_ERR LOGNAME ": -- stat: %d length: %d size: %d startV: %d startA: %d\n", stat,count,size, card->startingV, card->startingA); - */ +#endif + if (count) { ring_read_direct(&(card->rbuf), link->io.BasePort1+DIO_LSI_STATUS, @@ -504,8 +504,8 @@ void MaskByte(struct cvdv_cards *card, i -#define MAXWRITE 1024 * 100 -#define MAX_COUNT 20 +#define MAXWRITE CHANNELBUFFERSIZE +#define MAX_COUNT 10 #ifdef USE_BH struct cvdv_cards *bh_card; @@ -543,9 +543,8 @@ static void do_margi(struct cvdv_cards * void L64014Intr_function(struct cvdv_cards *card) { - u8 control,mask,stat; + uint8_t control,mask,stat; int try; - int count; control= read_indexed_register(card, IIO_IRQ_CONTROL); if (control & IRQ_EN){ @@ -555,29 +554,14 @@ void L64014Intr_function(struct cvdv_car stat = read_indexed_register(card, IIO_IRQ_STATUS); try = 0; while ( (try++ < 100) && (stat & mask) ){ - - if (stat & DEC_INT) { - write_indexed_register(card,IIO_IRQ_CONTROL, - control & (~DEC_EN)); - write_indexed_register(card,IIO_IRQ_CONTROL, - control); - - if(card->use_ring){ - L64021Intr(card); - } - } - if (stat & VSYNC_INT) { - + + if (stat & VSYNC_INT) { + write_indexed_register(card,IIO_IRQ_CONTROL, control & (~VSYNC_EN)); write_indexed_register(card,IIO_IRQ_CONTROL, control); - if(card->use_ring){ - L64021Intr(card); - } - count = ring_read_rest(&(card->rbuf)); - if (count) card->DMAABusy = 1; if (card->DMAABusy){ @@ -587,7 +571,21 @@ void L64014Intr_function(struct cvdv_car #else do_margi(card); #endif - } + if(card->use_ring){ + L64021Intr(card); + } + } + } + + if (stat & DEC_INT) { + write_indexed_register(card,IIO_IRQ_CONTROL, + control & (~DEC_EN)); + write_indexed_register(card,IIO_IRQ_CONTROL, + control); + + if(card->use_ring){ + L64021Intr(card); + } } stat = read_indexed_register(card, IIO_IRQ_STATUS); @@ -653,7 +651,7 @@ int L64014RemoveIntr(struct cvdv_cards * } void l64020Reset(struct cvdv_cards *card){ - u8 data; + uint8_t data; data = read_indexed_register(card, IIO_LSI_CONTROL); @@ -675,17 +673,17 @@ void l64020Reset(struct cvdv_cards *card void ZV_init(struct cvdv_cards *card) { - u32 delay, activel; - u8 reg; + uint32_t delay, activel; + uint8_t reg; delay = 235; activel = delay + 1448; // init delay and active lines write_indexed_register(card, IIO_VIDEO_HOR_DELAY, - (u8)(delay & 0x00FF)); + (uint8_t)(delay & 0x00FF)); write_indexed_register(card, IIO_VIDEO_HOR_ACTIVE, - (u8)(activel & 0x00FF)); - reg = ((u8)((activel >> 4) & 0x0070))|((u8)((delay >> 8) & 0x0007)); + (uint8_t)(activel & 0x00FF)); + reg = ((uint8_t)((activel >> 4) & 0x0070))|((uint8_t)((delay >> 8) & 0x0007)); write_indexed_register(card, IIO_VIDEO_HOR_HIGH, reg); //init video @@ -699,7 +697,7 @@ void ZV_init(struct cvdv_cards *card) int L64014Init(struct cvdv_cards *card) { - u16 testram[16]; + uint16_t testram[16]; int i, err; printk(KERN_DEBUG LOGNAME ": -- L64014Init\n");