int StartFeed (struct dvb_demux_feed* Feed) { struct dvb_demux* DvbDemux = Feed->demux; struct dmxdev_filter* Filter = (struct dmxdev_filter*)Feed->feed.ts.priv; struct dmx_pes_filter_params* Params = &Filter->params.pes; struct DeviceContext_s* Context = (struct DeviceContext_s*)DvbDemux->priv; struct DvbContext_s* DvbContext = Context->DvbContext; int Result = 0; int i; unsigned int Video = false; unsigned int Audio = false; #ifdef __TDT__ struct DeviceContext_s *AvContext = NULL; #endif DVB_DEBUG ("(demux%d)\n", Context->Id); /* either numRunningFeeds == 0 and reset_tsm == 1 or reset_tsm > 1 */ #ifdef __TDT__ // fix recoding freezer on tuner0 and demux1/2 or tuner1 and demux0/2 or tuner2 and demux0/1 int tsm_reset = 1; for (i = 0; i < DVB_MAX_DEVICES_PER_ADAPTER; i++) { struct DeviceContext_s* DeviceContext = &DvbContext->DeviceContext[i]; if(DeviceContext->numRunningFeeds != 0) tsm_reset = 0; } if (tsm_reset && reset_tsm) { printk(KERN_WARNING "reset_tsm: %d numRunningFeeds: %d => calling stm_tsm_init(1)\n", reset_tsm, Context->numRunningFeeds); stm_tsm_init(1); } #else if (Context->numRunningFeeds == 0 && reset_tsm) { printk(KERN_WARNING "reset_tsm: %d numRunningFeeds: %d => calling stm_tsm_init(1)\n", reset_tsm, Context->numRunningFeeds); stm_tsm_init(1); } #endif #if defined(ADB_BOX)//tutaj if (glowica == SINGLE) { if ((Context->pPtiSession->source==DMX_SOURCE_FRONT1)&&(StartFeed_!=NULL)) StartFeed_(Feed); } else if (glowica == TWIN) { if ((Context->pPtiSession->source==DMX_SOURCE_FRONT2)&&(StartFeed_!=NULL)) StartFeed_(Feed); } #endif #ifdef __TDT__ #ifdef no_subtitles if ((Feed->type == DMX_TYPE_TS) && (Feed->pes_type > DMX_TS_PES_OTHER)) { DVB_DEBUG ("pes_type %d > %d (OTHER)>\n", Feed->pes_type, DMX_TS_PES_OTHER); return -EINVAL; } #endif DVB_DEBUG("t = %d, pt = %d, pid = %d\n", Feed->type, Feed->pes_type, Feed->pid); #endif switch (Feed->type) { case DMX_TYPE_TS: if (Feed->pes_type > DMX_TS_PES_OTHER) return -EINVAL; for (i = 0; i < DVB_MAX_DEVICES_PER_ADAPTER; i++) { if (Feed->pes_type == AudioId[i]) { Audio = true; break; } if (Feed->pes_type == VideoId[i]) { Video = true; break; } } #ifdef __TDT__ AvContext = &Context->DvbContext->DeviceContext[i]; //fix freeze if record starts in background //AvContext->DemuxContext = Context; //videotext & subtitles (other) if ((Feed->pes_type == DMX_TS_PES_TELETEXT) || (Feed->pes_type == DMX_TS_PES_OTHER)) { mutex_lock (&(DvbContext->Lock)); Context->numRunningFeeds++; //printk("%s:%d numRunningFeeds: %d\n", __func__,__LINE__,Context->numRunningFeeds); stpti_start_feed (Feed, Context); mutex_unlock (&(DvbContext->Lock)); break; } #endif if (!Audio && !Video) { #ifdef __TDT__ DVB_DEBUG ("pes_type = %d\n<\n", Feed->pes_type); #endif /*mutex_unlock (&(DvbContext->Lock)); This doesn't look right we haven't taken it yet*/ return 0; } mutex_lock (&(DvbContext->Lock)); #ifndef __TDT__ if ((Video && !Context->VideoOpenWrite) || (Audio && !Context->AudioOpenWrite)) { mutex_unlock (&(DvbContext->Lock)); return -EBADF; } #endif if ((Context->Playback == NULL) && (Context->SyncContext->Playback == NULL)) { Result = DvbPlaybackCreate (&Context->Playback); if (Result < 0) { mutex_unlock (&(DvbContext->Lock)); return Result; } Context->SyncContext->Playback = Context->Playback; if (Context->PlaySpeed != DVB_SPEED_NORMAL_PLAY) { Result = VideoIoctlSetSpeed (Context, Context->PlaySpeed); if (Result < 0) #ifdef __TDT__ { mutex_unlock (&(DvbContext->Lock)); return Result; } #else return Result; #endif } #ifdef __TDT__ if ((Context->VideoPlayInterval.start != DVB_TIME_NOT_BOUNDED) || (Context->VideoPlayInterval.end != DVB_TIME_NOT_BOUNDED)) { Result = VideoIoctlSetPlayInterval (Context, &Context->AudioPlayInterval); if (Result < 0) { mutex_unlock (&(DvbContext->Lock)); return Result; } } #endif } else if (Context->Playback == NULL) Context->Playback = Context->SyncContext->Playback; else if (Context->SyncContext->Playback == NULL) Context->SyncContext->Playback = Context->Playback; else if (Context->Playback != Context->SyncContext->Playback) DVB_ERROR ("Context playback not equal to sync context playback\n"); if (Context->DemuxStream == NULL) { Result = DvbPlaybackAddDemux (Context->Playback, Context->DemuxContext->Id, &Context->DemuxStream); if (Result < 0) { mutex_unlock (&(DvbContext->Lock)); return Result; } } #ifdef __TDT__ if (Video) { Context->numRunningFeeds++; //printk("%s:%d numRunningFeeds: %d\n", __func__,__LINE__,Context->numRunningFeeds); stpti_start_feed (Feed, Context); if(Feed->ts_type & TS_DECODER) VideoIoctlSetId (AvContext, Feed->pid); } else if (Audio) { Context->numRunningFeeds++; //printk("%s:%d numRunningFeeds: %d\n", __func__,__LINE__,Context->numRunningFeeds); stpti_start_feed (Feed, Context); if(Feed->ts_type & TS_DECODER) AudioIoctlSetId (AvContext, Feed->pid); } #else if (Video) { struct DeviceContext_s* VideoContext = &Context->DvbContext->DeviceContext[i]; VideoContext->DemuxContext = Context; VideoIoctlSetId (VideoContext, Feed->pid | (Params->flags & DMX_FILTER_BY_PRIORITY_MASK)); VideoIoctlPlay (VideoContext); if ((Context->VideoPlayInterval.start != DVB_TIME_NOT_BOUNDED) || (Context->VideoPlayInterval.end != DVB_TIME_NOT_BOUNDED)) VideoIoctlSetPlayInterval (Context, &Context->AudioPlayInterval); } else { struct DeviceContext_s* AudioContext = &Context->DvbContext->DeviceContext[i]; AudioContext->DemuxContext = Context; AudioIoctlSetId (AudioContext, Feed->pid | (Params->flags & DMX_FILTER_BY_PRIORITY_MASK)); AudioIoctlPlay (AudioContext); if ((Context->AudioPlayInterval.start != DVB_TIME_NOT_BOUNDED) || (Context->AudioPlayInterval.end != DVB_TIME_NOT_BOUNDED)) AudioIoctlSetPlayInterval (Context, &Context->AudioPlayInterval); } #endif mutex_unlock (&(DvbContext->Lock)); break; case DMX_TYPE_SEC: #ifdef __TDT__ //DVB_DEBUG ("feed type = SEC\n"); mutex_lock (&(DvbContext->Lock)); Context->numRunningFeeds++; //printk("%s:%d numRunningFeeds: %d\n", __func__,__LINE__,Context->numRunningFeeds); stpti_start_feed (Feed, Context); mutex_unlock (&(DvbContext->Lock)); #endif break; default: #ifdef __TDT DVB_DEBUG ("< (type = %d unknown\n", Feed->type); #endif return -EINVAL; } return 0; }
int proc_video_pal_h_start_write(struct file* file, const char __user* buf, unsigned long count, void* data) { char* page; ssize_t ret = -ENOMEM; /* int result; */ int value; char* myString = kmalloc(count + 1, GFP_KERNEL); #ifdef VERY_VERBOSE printk("%s %ld - ", __FUNCTION__, count); #endif mutex_lock(&(ProcDeviceContext->DvbContext->Lock)); page = (char*)__get_free_page(GFP_KERNEL); if (page) { void* fb; struct fb_info* info; struct fb_var_screeninfo screen_info; int createNew = 0; ret = -EFAULT; if (copy_from_user(page, buf, count)) goto out; strncpy(myString, page, count); myString[count] = '\0'; #ifdef VERY_VERBOSE printk("%s\n", myString); #endif sscanf(myString, "%x", &value); fb = stmfb_get_fbinfo_ptr(); info = (struct fb_info*) fb; memcpy(&screen_info, &info->var, sizeof(struct fb_var_screeninfo)); if (fb != NULL) { int err; /* otherwise we got EBUSY from stmfb device */ /* Dagobert: Bugfix: "demux stop" bug; ticket #10 */ if (ProcDeviceContext != NULL) { if (ProcDeviceContext->VideoState.play_state != VIDEO_STOPPED) VideoIoctlStop(ProcDeviceContext, 1); if (isDisplayCreated(BACKEND_VIDEO_ID, ProcDeviceContext->Id)) { createNew = 1; #ifdef VERY_VERBOSE printk("delete display\n"); #endif DvbDisplayDelete(BACKEND_VIDEO_ID, ProcDeviceContext->Id); } } info->flags |= FBINFO_MISC_USEREVENT; screen_info.left_margin = value; err = fb_set_var(fb, &screen_info); if (err != 0) printk("error setting new resolution %d\n", err); if ((ProcDeviceContext != NULL) && (createNew == 1)) { #ifdef VERY_VERBOSE printk("create new display\n"); #endif DisplayCreate(BACKEND_VIDEO_ID, ProcDeviceContext->Id); VideoIoctlPlay(ProcDeviceContext); err = DvbStreamSetOutputWindow(ProcDeviceContext->VideoStream, 0, 0, screen_info.xres, screen_info.yres); if (err != 0) { printk("failed to set output window %d, %d, %d\n", screen_info.xres, screen_info.yres, err); } #ifdef VERY_VERBOSE else printk("set output window to %d, %d ok\n", screen_info.xres, screen_info.yres); #endif } } else { printk("Cannot get stmfb_info struct\n"); } /* always return count to avoid endless loop */ ret = count; } out: free_page((unsigned long)page); kfree(myString); mutex_unlock(&(ProcDeviceContext->DvbContext->Lock)); return ret; }
int StartFeed (struct dvb_demux_feed* Feed) { struct dvb_demux* DvbDemux = Feed->demux; struct DeviceContext_s* Context = (struct DeviceContext_s*)DvbDemux->priv; struct DvbContext_s* DvbContext = Context->DvbContext; int Result = 0; int i; unsigned int Video = false; unsigned int Audio = false; if (Feed->pes_type > DMX_TS_PES_OTHER) return -EINVAL; switch (Feed->type) { case DMX_TYPE_TS: for (i = 0; i < DVB_MAX_DEVICES_PER_ADAPTER; i++) { if (Feed->pes_type == AudioId[i]) { Audio = true; break; } if (Feed->pes_type == VideoId[i]) { Video = true; break; } } if (!Audio && !Video) return 0; mutex_lock (&(DvbContext->Lock)); if ((Context->Playback == NULL) && (Context->DemuxContext->Playback == NULL)) { Result = DvbPlaybackCreate (&Context->Playback); if (Result < 0) return Result; if (Context != Context->DemuxContext) Context->DemuxContext->Playback = Context->Playback; } if ((Context->DemuxStream == NULL) && (Context->DemuxContext->DemuxStream == NULL)) { Result = DvbPlaybackAddDemux (Context->Playback, Context->DemuxContext->Id, &Context->DemuxStream); if (Result < 0) { mutex_unlock (&(DvbContext->Lock)); return Result; } if (Context != Context->DemuxContext) Context->DemuxContext->DemuxStream = Context->DemuxStream; } if (Video) { struct DeviceContext_s* VideoContext = &Context->DvbContext->DeviceContext[i]; VideoContext->DemuxContext = Context; VideoIoctlSetId (VideoContext, Feed->pid); VideoIoctlPlay (VideoContext); } else { struct DeviceContext_s* AudioContext = &Context->DvbContext->DeviceContext[i]; AudioContext->DemuxContext = Context; AudioIoctlSetId (AudioContext, Feed->pid); AudioIoctlPlay (AudioContext); } mutex_unlock (&(DvbContext->Lock)); break; case DMX_TYPE_SEC: break; default: return -EINVAL; } return 0; }
/* hack hack ;-) */ int proc_video_videomode_write(struct file* file, const char __user* buf, unsigned long count, void* data) { char* page; ssize_t ret = -ENOMEM; /* int result; */ int vLoop; int new_count; char* myString = kmalloc(count + 1, GFP_KERNEL); void* fb; struct fb_info *info; #ifdef VERY_VERBOSE printk("%s %ld - ", __FUNCTION__, count); #endif mutex_lock(&(ProcDeviceContext->DvbContext->Lock)); fb = stmfb_get_fbinfo_ptr(); info = (struct fb_info*) fb; page = (char*)__get_free_page(GFP_KERNEL); if (page) { int modeToSet = -1; int aktmode = -1; ret = -EFAULT; if (copy_from_user(page, buf, count)) goto out; /* Dagobert: echo add a \n which will be counted as a char */ if (page[count - 1] == '\n') new_count = count - 1; else new_count = count; strncpy(myString, page, new_count); myString[new_count] = '\0'; #ifdef VERY_VERBOSE printk("%s\n", myString); #endif //whithout -1 write a unsupportet string hangs the driver for (vLoop = 0; vLoop < (sizeof(Options) / sizeof(struct Modes)) - 1; vLoop++) { if (Options[vLoop].xres == info->var.xres && Options[vLoop].yres == info->var.yres && Options[vLoop].vxres == info->var.xres_virtual && Options[vLoop].vyres == info->var.yres_virtual && Options[vLoop].pixclock == info->var.pixclock && Options[vLoop].left == info->var.left_margin && Options[vLoop].right == info->var.right_margin && Options[vLoop].upper == info->var.upper_margin && Options[vLoop].lower == info->var.lower_margin && Options[vLoop].hslen == info->var.hsync_len && Options[vLoop].vslen == info->var.vsync_len && Options[vLoop].sync == info->var.sync/* && Options[vLoop].vmode == info->var.vmode*/) { aktmode = vLoop; } if (strncmp(myString, Options[vLoop].name, new_count) == 0) { printk("Found mode to set %s at %d\n", Options[vLoop].name, vLoop); modeToSet = vLoop; } } if (aktmode == modeToSet) modeToSet = -1; if (modeToSet != -1) { struct fb_var_screeninfo screen_info; int createNew = 0; memcpy(&screen_info, &info->var, sizeof(struct fb_var_screeninfo)); if (fb != NULL) { int err; /* otherwise we got EBUSY from stmfb device */ /* Dagobert: Bugfix: "demux stop" bug; ticket #10 */ if (ProcDeviceContext != NULL) { if (ProcDeviceContext->VideoState.play_state != VIDEO_STOPPED) VideoIoctlStop(ProcDeviceContext, 1); if (isDisplayCreated(BACKEND_VIDEO_ID, ProcDeviceContext->Id)) { createNew = 1; #ifdef VERY_VERBOSE printk("delete display\n"); #endif DvbDisplayDelete(BACKEND_VIDEO_ID, ProcDeviceContext->Id); } } info->flags |= FBINFO_MISC_USEREVENT; screen_info.xres = Options[modeToSet].xres; /* visible resolution */ screen_info.yres = Options[modeToSet].yres; screen_info.xres_virtual = Options[modeToSet].vxres; /* virtual resolution */ screen_info.yres_virtual = Options[modeToSet].vyres; screen_info.pixclock = Options[modeToSet].pixclock; screen_info.left_margin = Options[modeToSet].left; screen_info.right_margin = Options[modeToSet].right; screen_info.upper_margin = Options[modeToSet].upper; screen_info.lower_margin = Options[modeToSet].lower; screen_info.hsync_len = Options[modeToSet].hslen; screen_info.vsync_len = Options[modeToSet].vslen; screen_info.sync = Options[modeToSet].sync; screen_info.vmode = Options[modeToSet].vmode; screen_info.activate = FB_ACTIVATE_FORCE; err = fb_set_var(fb, &screen_info); if (err != 0) printk("error setting new resolution %d\n", err); if ((ProcDeviceContext != NULL) && (createNew == 1)) { #ifdef VERY_VERBOSE printk("create new display\n"); #endif DisplayCreate(BACKEND_VIDEO_ID, ProcDeviceContext->Id); VideoIoctlPlay(ProcDeviceContext); err = DvbStreamSetOutputWindow(ProcDeviceContext->VideoStream, 0, 0, Options[modeToSet].xres, Options[modeToSet].yres); if (err != 0) { printk("failed to set output window %d, %d, %d\n", Options[modeToSet].xres, Options[modeToSet].yres, err); } #ifdef VERY_VERBOSE else printk("set output window to %d, %d ok\n", Options[modeToSet].xres, Options[modeToSet].yres); #endif } } else { printk("Cannot get stmfb_info struct\n"); } } /* always return count to avoid endless loop */ ret = count; } out: free_page((unsigned long)page); kfree(myString); mutex_unlock(&(ProcDeviceContext->DvbContext->Lock)); return ret; }