--- margi2/margi.c 2000/12/03 22:41:07 1.1 +++ margi2/margi.c 2000/12/12 02:09:11 1.2 @@ -177,6 +177,9 @@ void DACSetFrequency(struct cvdv_cards * b &= 0xf8; switch (khz){ + case 32: + b |= 0x04; + break; case 48: b |= 0x00; break; @@ -241,178 +244,6 @@ int MargiFlush (struct cvdv_cards *card) -void init_p2t(p2t_t *p) -{ - memset(p->pes,0,PBUFFER); - p->type = AUDIO; - p->pos = 0; - p->frags = 0; -} - -void clear_p2t(p2t_t *p) -{ - memset(p->pes,0,PBUFFER); - p->pos = 0; - p->frags = 0; -} - - -long int find_pes_header(u8 const *buf, long int length, int *frags) -{ - int c = 0; - int found = 0; - - *frags = 0; - - while (c < length-3 && !found) { - if (buf[c] == 0x00 && buf[c+1] == 0x00 && - buf[c+2] == 0x01) { - switch ( buf[c+3] ) { - - case PROG_STREAM_MAP: - case PRIVATE_STREAM2: - case PROG_STREAM_DIR: - case ECM_STREAM : - case EMM_STREAM : - case PADDING_STREAM : - case DSM_CC_STREAM : - case ISO13522_STREAM: - case PRIVATE_STREAM1: - case AUDIO_STREAM_S ... AUDIO_STREAM_E: - case VIDEO_STREAM_S ... VIDEO_STREAM_E: - found = 1; - break; - - default: - c++; - break; - } - } else c++; - } - if (c == length-3 && !found){ - if (buf[length-1] == 0x00) *frags = 1; - if (buf[length-2] == 0x00 && - buf[length-1] == 0x00) *frags = 2; - if (buf[length-3] == 0x00 && - buf[length-2] == 0x00 && - buf[length-1] == 0x01) *frags = 3; - return -1; - } - - return c; -} - -void pes_out( u8 const *buf, long int length,p2t_t *p) -{ - - if ( length > 3 && - buf[0] == 0x00 && buf[1] == 0x00 && buf[2] == 0x01 ) - switch (buf[3]){ - case PROG_STREAM_MAP: - case PRIVATE_STREAM2: - case PROG_STREAM_DIR: - case ECM_STREAM : - case EMM_STREAM : - case PADDING_STREAM : - case DSM_CC_STREAM : - case ISO13522_STREAM: - case PRIVATE_STREAM1: - case AUDIO_STREAM_S ... AUDIO_STREAM_E: - p->type = AUDIO; - break; - case VIDEO_STREAM_S ... VIDEO_STREAM_E: - p->type = VIDEO; - break; - default: - break; - } - - -} - -void get_pes( u8 const *buf, long int length, p2t_t *p) -{ - int c,c2,l,add; - int check; - - c = 0; - c2 = 0; - if (p->frags){ - check = 0; - switch(p->frags){ - case 1: - if ( buf[c] == 0x00 && buf[c+1] == 0x01 ){ - check = 1; - c += 2; - } - break; - case 2: - if ( buf[c] == 0x01 ){ - check = 1; - c++; - } - break; - case 3: - check = 1; - } - if(check){ - switch ( buf[c] ) { - - case PROG_STREAM_MAP: - case PRIVATE_STREAM2: - case PROG_STREAM_DIR: - case ECM_STREAM : - case EMM_STREAM : - case PADDING_STREAM : - case DSM_CC_STREAM : - case ISO13522_STREAM: - case PRIVATE_STREAM1: - case AUDIO_STREAM_S ... AUDIO_STREAM_E: - case VIDEO_STREAM_S ... VIDEO_STREAM_E: - p->pes[0] = 0x00; - p->pes[1] = 0x00; - p->pes[2] = 0x01; - p->pes[3] = buf[c]; - p->pos=4; - /* - memcpy(p->pes+p->pos,buf+c, - PBUFFER-p->pos); - c += PBUFFER-p->pos; - p->pos = PBUFFER; - */ - pes_out(p->pes,p->pos,p); - clear_p2t(p); - break; - - default: - c=0; - break; - } - } - p->frags = 0; - } - - add = 0; - while (c < length){ - c2 = find_pes_header(buf+c+add,length-c-add,&p->frags); - if (c2 >= 0) { - c2 += c+add; - if (c2 > c){ - pes_out(buf+c,c2-c,p); - c = c2; - clear_p2t(p); - add = 0; - } else add = 1; - } else { - l = length-c; - pes_out(buf+c,l,p); - c = length; - } - } -} - - - int MargiPush(struct cvdv_cards *card, int count, const char *data) { // printk(KERN_DEBUG LOGNAME ": -- MargiPush(%d,0x%08lX)\n",count,(long)data); @@ -498,8 +329,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; @@ -518,8 +349,7 @@ static int ringDMA (struct cvdv_cards *c card->DMAABusy = 0; wake_up_interruptible(&(card->wqA)); return 0; - } else if ( card->stream.sh.valid && - card->setup.audioselect == audio_none) + } else if ( card->stream.sh.valid ) DecoderStartDecode(card);