--- margi2/cvdv.c 2001/03/14 01:43:11 1.9 +++ margi2/cvdv.c 2001/03/15 15:58:16 1.10 @@ -518,8 +518,9 @@ int DecoderWriteBlock(struct cvdv_cards // printk(KERN_DEBUG LOGNAME // ": DecoderWriteBlock - buffers only filled with %d instead of %d bytes\n", // res, size); - if (card->DMAABusy) + if (card->DMAABusy){ interruptible_sleep_on(&card->wqA); + } } if (card->startingDVDV) { @@ -556,6 +557,9 @@ static long margi_write(struct video_dev // int B3=0, B5=0, C0=0, E0=0, BD=0, BF=0; int res; int channel=0; + long int out=0; + + card->nonblock = nonblock; if (card != NULL) { if (count > 0) { // Do we have data? @@ -571,10 +575,19 @@ static long margi_write(struct video_dev if (!card->use_ring) MargiSetBuffers(card, NBBUF* CHANNELBUFFERSIZE); - if (!(count = MargiPush(card, count, data))){ - if (card->DMAABusy) - interruptible_sleep_on( - &card->wqA); + + while (!card->nonblock && out < count){ + out += MargiPush(card, count, data); + if (out < count || card->DMAABusy){ + interruptible_sleep_on(&card->wqA); + } + } + if (card->nonblock) { + out = MargiPush(card, count, data); + if (card->DMAABusy){ + interruptible_sleep_on(&card->wqA); + } + } break; @@ -585,7 +598,7 @@ static long margi_write(struct video_dev break; } } - return count; + return out; } else { printk(KERN_ERR LOGNAME ": Video Decoder Prepare failed: device with this minor number not found\n"); @@ -609,7 +622,7 @@ static unsigned int PSpoll(struct file * minorlist[MINOR(file->f_dentry->d_inode->i_rdev) % MAXDEV]; // minor number modulo 16 if (card != NULL) { poll_wait(file, &card->wqA , table); - if (ring_read_rest(&(card->rbuf)) && + if ( ring_write_rest(&(card->rbuf)) && card->videostate.playState==VIDEO_PLAYING) return POLLOUT | POLLWRNORM; else return 0; @@ -632,6 +645,7 @@ static int PSioctl(struct inode *inode, struct drawcmd *dc; struct decodercmd *command; u16 attr; + if (card != NULL) { if (_IOC_TYPE(cmd) == CVDV_IOCTL_MAGIC) switch (_IOC_NR(cmd)) { @@ -717,13 +731,18 @@ static int PSioctl(struct inode *inode, } case IOCTL_DECODER: command = (struct decodercmd *) arg; + printk(KERN_DEBUG LOGNAME ":IOCTL: _IOC_TYPE:%d IOC_NR:%d cmd:%d\n", + _IOC_TYPE(cmd),_IOC_NR(cmd),command->cmd); switch (command->cmd) { - /* + case Decoder_CSS: + /* return DecoderCSS(card, command->param1, command->data1); */ + break; + case Decoder_Set_Videosystem: printk(KERN_DEBUG LOGNAME ": -- Decoder_Set_Videosystem\n"); @@ -731,12 +750,16 @@ static int PSioctl(struct inode *inode, (videosystem) command->param1; SetVideoSystem(card); return 0; + break; + case Decoder_Set_Streamtype: printk(KERN_DEBUG LOGNAME ": -- Decoder_Set_Streamtype\n"); card->setup.streamtype = (stream_type) command->param1; return 0; + break; + case Decoder_Set_Audiotype: printk(KERN_DEBUG LOGNAME ": -- Decoder_Set_Audiotype\n"); @@ -744,6 +767,8 @@ static int PSioctl(struct inode *inode, (audio_type) command->param1; DecoderPrepareAudio(card); return 0; + break; + case Decoder_Set_VideoStreamID: printk(KERN_DEBUG LOGNAME ": -- Decoder_Set_VideoStreamID\n"); @@ -751,6 +776,8 @@ static int PSioctl(struct inode *inode, command->param1; DecoderPrepareVideo(card); return 0; + break; + case Decoder_Set_AudioStreamID: printk(KERN_DEBUG LOGNAME ": -- Decoder_Set_AudioStreamID 0x%02X 0x%02X\n",command->param1,command->param2); @@ -762,6 +789,8 @@ static int PSioctl(struct inode *inode, DecoderSelectAudioID(card); card->lastaattr = attr; return 0; + break; + case Decoder_Still_Put: return DecoderShowStill(card, command-> @@ -772,6 +801,8 @@ static int PSioctl(struct inode *inode, data1, command-> data2); + break; + case Decoder_Still_Get: return DecoderGetStill(card, &command-> @@ -782,6 +813,8 @@ static int PSioctl(struct inode *inode, data1, command-> data2); + break; + case Decoder_Pause: // pause{param1} 0=run 1=pause 2=toggle if (command->param1 == 2) { if (card->paused) @@ -797,6 +830,36 @@ static int PSioctl(struct inode *inode, DecoderPause(card); } return 0; + + /* Too buggy + case Decoder_FFWD: // pause{param1} =normal 1=ffwd 2=toggle + if (command->param1 == 2) { + if (card->videoffwd) + card->videoffwd = 0; + else + card->videoffwd = 2; + } else { + if (!command->param1) + card->videoffwd = 0; + else + card->videoffwd = 2; + } + return 0; + + case Decoder_Slow: // pause{param1} =normal 1=slow 2=toggle + if (command->param1 == 2) { + if (card->videoslow) + card->videoslow = 0; + else + card->videoslow = 4; + } else { + if (!command->param1) + card->videoslow = 0; + else + card->videoslow = 4; + } + return 0; + */ case Decoder_Highlight: // active{param1}, color information(SL_COLI or AC_COLI){data1[4]}, button position(BTN_POSI){data2[6]} return DecoderHighlight(card, command-> @@ -898,7 +961,7 @@ static int margi_open(struct video_devic int closed; if (card != NULL) { - printk(KERN_DEBUG LOGNAME ": -- PSopen \n"); + printk(KERN_DEBUG LOGNAME ": -- open \n"); CloseCard(card); OSDClose(card); #ifdef NOINT @@ -933,7 +996,7 @@ static int margi_open(struct video_devic static int PSopen(struct inode *inode, struct file *file) { struct cvdv_cards *card = minorlist[MINOR(inode->i_rdev) % MAXDEV]; // minor number modulo 16 - return margi_open((struct video_device *) card,0); + return margi_open((struct video_device *) card,1); } @@ -1193,8 +1256,10 @@ dvbdev_ioctl(struct dvb_device *dvbdev, case VIDEO_STOP: DecoderPause(card); card->videostate.playState = VIDEO_STOPPED; - VideoSetBackground(card, 1, 0, 0, 0); + if (card->videostate.videoBlank) + VideoSetBackground(card, 1, 0, 0, 0); + return 0; case VIDEO_PLAY: @@ -1274,13 +1339,16 @@ dvbdev_ioctl(struct dvb_device *dvbdev, } case VIDEO_FAST_FORWARD: - if (card->videostate.streamSource!=VIDEO_SOURCE_MEMORY) - return -EPERM; + if (card->videostate.streamSource != + VIDEO_SOURCE_MEMORY) + return -EPERM; + card->videoffwd = 2; break; case VIDEO_SLOWMOTION: if (card->videostate.streamSource!=VIDEO_SOURCE_MEMORY) return -EPERM; + card->videoslow = arg; break;