📄 omap_disp_out.c
字号:
if (!buffer || (count == 0)) return 0; if (strncmp(buffer, "enable", 6) == 0) { if ((rc = omap2_disp_lpr_enable())) { printk("can't enable lpr!\n"); return rc; } } else if (strncmp(buffer, "disable", 7) == 0) { if ((rc = omap2_disp_lpr_disable())) { printk("can't disable lpr!\n"); return rc; } } else { return -EINVAL; } return count;}static ssize_t gfx_fifo_low_threshold_show(struct class_device *cdev, char *buf){ int thrs; omap2_disp_get_dss(); thrs = omap2_disp_get_gfx_fifo_low_threshold(); omap2_disp_put_dss(); return sprintf(buf, "%d\n", thrs); }static ssize_t gfx_fifo_low_threshold_store(struct class_device *cdev, const char *buffer, size_t count){ unsigned int v; if (!buffer || (count == 0)){ return 0; } if (sscanf(buffer, "%d", &v) != 1) { printk(KERN_ERR "gfx_fifo_low_threshold: Invalid value\n"); return -EINVAL; } omap2_disp_get_dss(); omap2_disp_set_gfx_fifo_low_threshold(v); omap2_disp_put_dss(); return count; }static ssize_t gfx_fifo_high_threshold_show(struct class_device *cdev, char *buf){ int thrs; omap2_disp_get_dss(); thrs = omap2_disp_get_gfx_fifo_high_threshold(); omap2_disp_put_dss(); return sprintf(buf, "%d\n", thrs); }static ssize_t gfx_fifo_high_threshold_store(struct class_device *cdev, const char *buffer, size_t count){ unsigned int v; if (!buffer || (count == 0)){ return 0; } if (sscanf(buffer, "%d", &v) != 1) { printk(KERN_ERR "gfx_fifo_high_threshold: Invalid value\n"); return -EINVAL; } omap2_disp_get_dss(); omap2_disp_set_gfx_fifo_high_threshold(v); omap2_disp_put_dss(); return count; }static ssize_t tv_standard_show(struct class_device *cdev, char *buf){ int p = 0; int current_tvstd; omap2_disp_get_dss(); current_tvstd = omap2_disp_get_tvstandard(); switch (current_tvstd) { case PAL_BDGHI: p = sprintf(buf, "pal_bdghi\n"); break; case PAL_NC: p = sprintf(buf, "pal_nc\n"); break; case PAL_N: p = sprintf(buf, "pal_n\n"); break; case PAL_M: p = sprintf(buf, "pal_m\n"); break; case PAL_60: p = sprintf(buf, "pal_60\n"); break; case NTSC_M: p = sprintf(buf, "ntsc_m\n"); break; case NTSC_J: p = sprintf(buf, "ntsc_j\n"); break; case NTSC_443: p = sprintf(buf, "ntsc_443\n"); break; } omap2_disp_put_dss(); return (p);}static ssize_ttv_standard_store(struct class_device *cdev, const char *buffer, size_t count){ int tv_std; if (!buffer || (count == 0)) return 0; if (strncmp(buffer, "pal_bdghi", 9) == 0) tv_std = PAL_BDGHI; else if (strncmp(buffer, "pal_nc", 6) == 0) tv_std = PAL_NC; else if (strncmp(buffer, "pal_n", 5) == 0) tv_std = PAL_N; else if (strncmp(buffer, "pal_m", 5) == 0) tv_std = PAL_M; else if (strncmp(buffer, "pal_60", 6) == 0) tv_std = PAL_60; else if (strncmp(buffer, "ntsc_m", 6) == 0) tv_std = NTSC_M; else if (strncmp(buffer, "ntsc_j", 6) == 0) tv_std = NTSC_J; else if (strncmp(buffer, "ntsc_443", 8) == 0) tv_std = NTSC_443; else return -EINVAL; omap2_disp_get_all_clks(); omap2_disp_set_tvstandard(tv_std); omap2_disp_put_all_clks(); return count; }#define DECLARE_ATTR(_name,_mode,_show,_store) \{ \ .attr = { .name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \ .show = _show, \ .store = _store, \}static struct class_device_attribute bl_class_device_attributes[] = { DECLARE_ATTR(dithering, S_IRWXUGO, dithering_show, dithering_store), DECLARE_ATTR(graphics, S_IRWXUGO, graphics_show, graphics_store), DECLARE_ATTR(video1, S_IRWXUGO, video1_show, video1_store), DECLARE_ATTR(video2, S_IRWXUGO, video2_show, video2_store), DECLARE_ATTR(lcdbacklight, S_IRWXUGO, lcdbacklight_show, lcdbacklight_store), DECLARE_ATTR(lcd_data_lines, S_IRWXUGO, lcd_data_lines_show, lcd_data_lines_store), DECLARE_ATTR(frame_buffer, S_IRWXUGO, fb_out_show, fb_out_store), DECLARE_ATTR(lcd_alphablend, S_IRWXUGO, lcd_alphablend_show, lcd_alphablend_store), DECLARE_ATTR(tv_alphablend, S_IRWXUGO, tv_alphablend_show, tv_alphablend_store), DECLARE_ATTR(gfx_global_alpha, S_IRWXUGO, gfx_global_alpha_show, gfx_global_alpha_store), DECLARE_ATTR(vid2_global_alpha, S_IRWXUGO, vid2_global_alpha_show, vid2_global_alpha_store), DECLARE_ATTR(lpr, S_IRWXUGO, lpr_show, lpr_store), DECLARE_ATTR(gfx_fifo_low_threshold, S_IRWXUGO, gfx_fifo_low_threshold_show, gfx_fifo_low_threshold_store), DECLARE_ATTR(gfx_fifo_high_threshold, S_IRWXUGO, gfx_fifo_high_threshold_show, gfx_fifo_high_threshold_store), DECLARE_ATTR(tv_standard, 0644, tv_standard_show, tv_standard_store),};static int create_sysfs_files(void){ int rc=0,i,ret; if((ret = class_register(&dispc_class)) != 0 ) return ret; bd = kmalloc(sizeof(struct board_properties), GFP_KERNEL); if (unlikely(!bd)) return -ENOMEM; bd->owner = THIS_MODULE; new_bd = kmalloc(sizeof(struct dispc_device), GFP_KERNEL); if (unlikely(!new_bd)) return -ENOMEM; new_bd->props = bd; memset(&new_bd->class_dev, 0, sizeof(new_bd->class_dev)); new_bd->class_dev.class = &dispc_class; strlcpy(new_bd->class_dev.class_id, "omap_disp_control", KOBJ_NAME_LEN); rc = class_device_register(&new_bd->class_dev); if (unlikely(rc)) { kfree(new_bd); return -EPERM; } for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) { rc = class_device_create_file(&new_bd->class_dev, &bl_class_device_attributes[i]); if (unlikely(rc)) { while (--i >= 0){ class_device_remove_file(&new_bd->class_dev, &bl_class_device_attributes[i]); } class_device_unregister(&new_bd->class_dev); /* No need to kfree(new_bd) since release() method does it for us*/ return -EPERM; } } return 0;}static voidremove_sysfs_files(void){ int i; for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) { class_device_remove_file(&new_bd->class_dev, &bl_class_device_attributes[i]); } class_device_unregister(&new_bd->class_dev);}static int __initomap2_dispout_init(void){ if (create_sysfs_files() < 0) { printk(KERN_ERR DRIVER "Could not create sysfs files for display control\n"); return -ENODEV; } /* Register the driver with LDM */ if (platform_driver_register(&omap2_lcd_driver)) { printk(KERN_ERR DRIVER ": failed to register omap2_lcd driver\n"); return -ENODEV; } /* Register the device with LDM */ if (platform_device_register(&lcd_device)) { printk(KERN_ERR DRIVER ": failed to register lcd device\n"); platform_driver_unregister(&omap2_lcd_driver); return -ENODEV; } /* Register the driver with LDM */ if (platform_driver_register(&omap2_tv_driver)) { printk(KERN_ERR DRIVER ": failed to register omap2_tv driver\n"); return -ENODEV; } /* Register the device with LDM */ if (platform_device_register(&tv_device)) { printk(KERN_ERR DRIVER ": failed to register tv device\n"); platform_driver_unregister(&omap2_tv_driver); return -ENODEV; } return 0;}device_initcall(omap2_dispout_init);static void __exitomap2_dispout_exit(void){ remove_sysfs_files(); lcd_exit(); platform_device_unregister(&lcd_device); platform_driver_unregister(&omap2_lcd_driver); tv_exit(); platform_device_unregister(&tv_device); platform_driver_unregister(&omap2_tv_driver);}module_exit(omap2_dispout_exit);/*---------------------------------------------------------------------------*//* Framebuffer related *//* We're intializing the virtual framebuffer dimensions to * (H4_XRES, H4_YRES*3) in order to support triple buffering. The * onscreen framebuffer can be flipped via the panning ioctl by specifying * offsets of (0, 0), (0, H4_YRES), or (0, 2*H4_YRES). */static struct fb_var_screeninfo h4_lcd_var = { .xres = H4_LCD_XRES, .yres = H4_LCD_YRES, .xres_virtual = H4_LCD_XRES, .yres_virtual = H4_LCD_YRES*2, .xoffset = 0, .yoffset = 0, .bits_per_pixel = 16, .grayscale = 0, .red = {11, 5, 0}, .green = { 5, 6, 0}, .blue = { 0, 5, 0}, .transp = { 0, 0, 0}, .nonstd = 0, .activate = FB_ACTIVATE_NOW, .height = -1, .width = -1, .accel_flags = 0, .pixclock = H4_LCD_PIXCLOCK_MAX,/* picoseconds */ .left_margin = 40, /* pixclocks */ .right_margin = 4, /* pixclocks */ .upper_margin = 8, /* line clocks */ .lower_margin = 2, .hsync_len = 4, /* pixclocks */ .vsync_len = 2, /* line clocks */ .sync = 0, .vmode = FB_VMODE_NONINTERLACED, .rotate = 0, .reserved[0] = 0,};static struct fb_var_screeninfo ntsc_tv_var = {/* NTSC frame size is 720 * 480, * but due to overscan, about 640 x 430 is visible */ .xres = 640, .yres = 430, .xres_virtual = 720, .yres_virtual = 480 * 2, .xoffset = 0, .yoffset = 0, .bits_per_pixel = 16, .grayscale = 0, .red = {11, 5, 0}, .green = { 5, 6, 0}, .blue = { 0, 5, 0}, .transp = { 0, 0, 0}, .nonstd = 0, .activate = FB_ACTIVATE_NOW, .height = -1, .width = -1, .accel_flags = 0, .pixclock = 0, /* picoseconds */ .left_margin = 0, /* pixclocks */ .right_margin = 0, /* pixclocks */ .upper_margin = 0, /* line clocks */ .lower_margin = 0, /* line clocks */ .hsync_len = 0, /* pixclocks */ .vsync_len = 0, /* line clocks */ .sync = 0, .vmode = FB_VMODE_INTERLACED, .rotate = 0, .reserved[0] = 0,};static struct fb_var_screeninfo pal_tv_var = {/* PAL frame size is 720 * 546, * but due to overscan, about 640 x 520 is visible */ .xres = 640, .yres = 480, .xres_virtual = 720, .yres_virtual = 576 * 2, .xoffset = 0, .yoffset = 0, .bits_per_pixel = 16, .grayscale = 0, .red = {11, 5, 0}, .green = { 5, 6, 0}, .blue = { 0, 5, 0}, .transp = { 0, 0, 0}, .nonstd = 0, .activate = FB_ACTIVATE_NOW, .height = -1, .width = -1, .accel_flags = 0, .pixclock = 0, /* picoseconds */ .left_margin = 0, /* pixclocks */ .right_margin = 0, /* pixclocks */ .upper_margin = 0, /* line clocks */ .lower_margin = 0, /* line clocks */ .hsync_len = 0, /* pixclocks */ .vsync_len = 0, /* line clocks */ .sync = 0, .vmode = FB_VMODE_INTERLACED, .rotate = 0, .reserved[0] = 0,};voidget_panel_default_var(struct fb_var_screeninfo *var, int output_dev){ if (output_dev == OMAP2_OUTPUT_LCD) { memcpy((struct fb_var_screeninfo *) var, &h4_lcd_var, sizeof(*var)); } else if (output_dev == OMAP2_OUTPUT_TV) { int tv = omap2_disp_get_tvstandard(); if(tv == PAL_BDGHI || tv == PAL_NC || tv == PAL_N || tv == PAL_M || tv == PAL_60){ memcpy((struct fb_var_screeninfo *) var, &pal_tv_var, sizeof(*var)); }else { memcpy((struct fb_var_screeninfo *) var, &ntsc_tv_var, sizeof(*var)); } }}u32get_panel_pixclock_max(int output_dev){ if (output_dev == OMAP2_OUTPUT_LCD) { return H4_LCD_PIXCLOCK_MAX; } else if (output_dev == OMAP2_OUTPUT_TV) { return ~0; } return -EINVAL;}u32get_panel_pixclock_min(int output_dev){ if (output_dev == OMAP2_OUTPUT_LCD) { return H4_LCD_PIXCLOCK_MIN; } else if (output_dev == OMAP2_OUTPUT_TV) { return 0; } return -EINVAL;}EXPORT_SYMBOL(get_panel_default_var);EXPORT_SYMBOL(get_panel_pixclock_max);EXPORT_SYMBOL(get_panel_pixclock_min);MODULE_DESCRIPTION(DRIVER_DESC);MODULE_LICENSE("GPL");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -