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; }
/******************************************************************************** * \brief Shut down this feed * StopFeed is called by the demux device immediately after finishing * demuxing data. ********************************************************************************/ int StopFeed (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;*/ #ifdef __TDT__ int i = 0; #endif #if defined(ADB_BOX)//tutaj if (glowica == SINGLE) { if ((Context->pPtiSession->source==DMX_SOURCE_FRONT1)&&(StopFeed_!=NULL)) StopFeed_(Feed); } else if (glowica == TWIN) { if ((Context->pPtiSession->source==DMX_SOURCE_FRONT2)&&(StopFeed_!=NULL)) StopFeed_(Feed); } #endif switch (Feed->type) { case DMX_TYPE_TS: #ifdef __TDT__ for (i = 0; i < DVB_MAX_DEVICES_PER_ADAPTER; i++) { if (Feed->pes_type == AudioId[i]) { mutex_lock (&(DvbContext->Lock)); /*AvContext = &Context->DvbContext->DeviceContext[i]; if(Feed->ts_type & TS_DECODER) { AudioIoctlSetAvSync (AvContext, 0); AudioIoctlStop (AvContext); }*/ stpti_stop_feed(Feed, Context); Context->numRunningFeeds--; //printk("%s:%d numRunningFeeds: %d\n", __func__,__LINE__,Context->numRunningFeeds); mutex_unlock (&(DvbContext->Lock)); if (Context->numRunningFeeds < 0) printk(KERN_ERR "%s: numRunningFeeds < 0: %d\n", __func__, Context->numRunningFeeds); break; } if (Feed->pes_type == VideoId[i]) { mutex_lock (&(DvbContext->Lock)); /*AvContext = &Context->DvbContext->DeviceContext[i]; if(Feed->ts_type & TS_DECODER) VideoIoctlStop(AvContext, AvContext->VideoState.video_blank);*/ stpti_stop_feed(Feed, Context); Context->numRunningFeeds--; //printk("%s:%d numRunningFeeds: %d\n", __func__,__LINE__,Context->numRunningFeeds); mutex_unlock (&(DvbContext->Lock)); if (Context->numRunningFeeds < 0) printk(KERN_ERR "%s: numRunningFeeds < 0: %d\n", __func__, Context->numRunningFeeds); break; } //videotext & subtitles (other) // FIXME: TTX1, TTX2, TTX3, PCR1 etc. if ((Feed->pes_type == DMX_TS_PES_TELETEXT) || (Feed->pes_type == DMX_TS_PES_OTHER)) { mutex_lock (&(DvbContext->Lock)); stpti_stop_feed(Feed, Context); Context->numRunningFeeds--; //printk("%s:%d numRunningFeeds: %d\n", __func__,__LINE__,Context->numRunningFeeds); mutex_unlock (&(DvbContext->Lock)); if (Context->numRunningFeeds < 0) printk(KERN_ERR "%s: numRunningFeeds < 0: %d\n", __func__, Context->numRunningFeeds); break; } else if (Feed->pes_type == DMX_TS_PES_PCR) break; } if (i >= DVB_MAX_DEVICES_PER_ADAPTER) { printk("%s(): INVALID PES TYPE (%d, %d)\n", __func__, Feed->pid, Feed->pes_type); return -EINVAL; } break; #else mutex_lock (&(DvbContext->Lock)); if (((Feed->pes_type == DMX_TS_PES_VIDEO) && !Context->VideoOpenWrite) || ((Feed->pes_type == DMX_TS_PES_AUDIO) && !Context->AudioOpenWrite)) { mutex_unlock (&(DvbContext->Lock)); return -EBADF; } switch (Feed->pes_type) { case DMX_TS_PES_VIDEO: VideoIoctlStop (Context, Context->VideoState.video_blank); break; case DMX_TS_PES_AUDIO: AudioIoctlStop (Context); break; case DMX_TS_PES_TELETEXT: case DMX_TS_PES_PCR: case DMX_TS_PES_OTHER: break; default: mutex_unlock (&(DvbContext->Lock)); return -EINVAL; } mutex_unlock (&(DvbContext->Lock)); /* if ((Context->AudioId == DEMUX_INVALID_ID) && (Context->VideoId == DEMUX_INVALID_ID) && (Context->DemuxStream != NULL)) { Result = DvbPlaybackRemoveDemux (Context->Playback, Context->DemuxStream); Context->DemuxContext->DemuxStream = NULL; if (Context != Context->DemuxContext) Context->DemuxContext->DemuxStream = NULL; } */ break; #endif case DMX_TYPE_SEC: #ifdef __TDT__ mutex_lock (&(DvbContext->Lock)); stpti_stop_feed(Feed, Context); Context->numRunningFeeds--; //printk("%s:%d numRunningFeeds: %d\n", __func__,__LINE__,Context->numRunningFeeds); mutex_unlock (&(DvbContext->Lock)); if (Context->numRunningFeeds < 0) printk(KERN_ERR "%s: numRunningFeeds < 0: %d\n", __func__, Context->numRunningFeeds); #endif break; default: #ifdef __TDT printk("%s(): INVALID FEED TYPE (%d)\n", __func__, Feed->type); #endif 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; }