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 proc_vmpeg_0_dst_all_write(struct file *file, const char __user *buf, unsigned long count, void *data) { char *page; ssize_t ret = -ENOMEM; int err, x, y; void* fb; struct fb_info *info; struct fb_var_screeninfo screen_info; char* myString = kmalloc(count + 1, GFP_KERNEL); struct DeviceContext_s *pContext = (struct DeviceContext_s*)data; #ifdef VERY_VERBOSE printk("%s %d - ", __FUNCTION__, (unsigned int)count); #endif fb = stmfb_get_fbinfo_ptr(); info = (struct fb_info*) fb; memcpy(&screen_info, &info->var, sizeof(struct fb_var_screeninfo)); if (fb != NULL) { y = screen_info.yres; x = screen_info.xres; } else { y = 576; x = 720; } page = (char *)__get_free_page(GFP_KERNEL); if (page) { int l, t, w, h; 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 %x %x %x", &l ,&t, &w, &h); #ifdef VERY_VERBOSE printk("%x, %x, %x, %x\n", l, t, w, h); #endif if (pContext != NULL) { mutex_lock (&(pContext->DvbContext->Lock)); h = y*h/576; w = x*w/720; l = x*l/720; t = y*t/576; #ifdef VERY_VERBOSE printk("%x, %x, %x, %x\n", l, t, w, h); #endif err = DvbStreamSetOutputWindow(pContext->VideoStream, l, t, w, h); if (err != 0) printk("failed to set output window %d\n", err); #ifdef VERY_VERBOSE else printk("set output window ok %d %d %d %d\n", l, t, w, h); #endif mutex_unlock (&(pContext->DvbContext->Lock)); } /* always return count to avoid endless loop */ ret = count; } out: free_page((unsigned long)page); kfree(myString); return ret; }
/* 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; }