Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- advamationfb.c.v1 2014-05-02 13:50:06.000000000 +0200
- +++ advamationfb.c.v2 2016-03-05 19:37:13.788917566 +0100
- @@ -8,7 +8,7 @@
- - add/remove displays dynamically via sysfs
- - configurable width, height and bits-per-pixel
- -:Version: 2014-04-30
- +:Version: 2016-02-29
- :Status: experimental
- :Author: Advamation, Roland Koebler (support@advamation.de)
- @@ -46,18 +46,19 @@
- #include <linux/mutex.h>
- -
- +#define ADVAMATIONFB_DRVNAME "advamationfb" // 19 char max
- +#define ADVAMATIONFB_VFB_MAX 32 // Linux/include/uapi/linux/fb.h => FB_MAX = 32
- //========================================
- // data / structures
- -struct platform_device *pdevs[32];
- +struct platform_device *pdevs[ADVAMATIONFB_VFB_MAX];
- //TODO static DEFINE_MUTEX(advamationfb_lock); //TODO?
- //----------------------------------------
- struct advamationfb_cfg {
- unsigned int width;
- unsigned int height;
- - unsigned int bpp; // 16: RGB565, 24: RGB888, 32: RGB8888
- + unsigned int bpp; // 8: RGB332, 16: RGB565, 24: RGB888, 32: RGB8888
- unsigned int maxfps; // TODO: for deferred IO
- atomic_t open_count; // number of clients which use this framebuffer
- @@ -173,7 +174,7 @@
- {
- //TODO: definition of loff_t? why *ppos?
- ssize_t res;
- - log_info(LEVEL_DEBUG, "%s(..., count %d, ppos %llu)", __func__, count, *ppos);
- + log_info(LEVEL_DEBUG, "%s(..., count %zu, ppos %llu)", __func__, count, *ppos);
- res = fb_sys_write(info, buf, count, ppos);
- return res;
- }
- @@ -242,7 +243,7 @@
- //---------------------
- // platform device
- - if(pdev->id < 0 || pdev->id > 32 || pdevs[pdev->id]) {
- + if(pdev->id < 0 || pdev->id > ADVAMATIONFB_VFB_MAX || pdevs[pdev->id]) {
- log_pdev(LEVEL_ERROR, "Invalid platform-device id. (%d).", pdev->id);
- return -EINVAL;
- }
- @@ -297,42 +298,44 @@
- //info->var.height = // in mm TODO; .vfb: -1
- //info->var.width = // in mm TODO; .vfb: -1
- -// info->var.grayscale = 0; //TODO: optionally use grayscale?? (or other/generic filters? -> or display gamma?)
- + // http://linuxtv.org/downloads/v4l-dvb-apis/packed-rgb.html
- + info->var.grayscale = 0; //TODO: add support (or other/generic filters? -> or display gamma?)
- switch(cfg->bpp) {
- + case(8): // RGB332
- + info->var.bits_per_pixel = 8;
- + info->var.red.length = 3; info->var.red.offset = 5; info->var.red.msb_right = 0;
- + info->var.green.length = 3; info->var.green.offset = 2; info->var.green.msb_right = 0;
- + info->var.blue.length = 2; info->var.blue.offset = 0; info->var.blue.msb_right = 0;
- + info->var.transp.length = 0; info->var.transp.offset = 0; info->var.transp.msb_right= 0;
- + break;
- +
- case(16): // RGB565
- info->var.bits_per_pixel = 16;
- - info->var.red.length = 5; info->var.red.offset = 11;
- - info->var.green.length = 6; info->var.green.offset = 5;
- - info->var.blue.length = 5; info->var.blue.offset = 0;
- - info->var.transp.length = 0; info->var.transp.offset = 0;
- - //info->var.red.msb_right = 0 //TODO: ?
- - //info->var.green.msb_right = 0
- - //info->var.blue.msb_right = 0
- + info->var.red.length = 5; info->var.red.offset = 11; info->var.red.msb_right = 0;
- + info->var.green.length = 6; info->var.green.offset = 5; info->var.green.msb_right = 0;
- + info->var.blue.length = 5; info->var.blue.offset = 0; info->var.blue.msb_right = 0;
- + info->var.transp.length = 0; info->var.transp.offset = 0; info->var.transp.msb_right= 0;
- break;
- +
- case(24): // RGB888
- info->var.bits_per_pixel = 24;
- - info->var.red.length = 5; info->var.red.offset = 11;
- - info->var.red.length = 8; info->var.red.offset = 16;
- - info->var.green.length = 8; info->var.green.offset = 8;
- - info->var.blue.length = 8; info->var.blue.offset = 0;
- - info->var.transp.length = 0; info->var.transp.offset = 0;
- - //info->var.red.msb_right = 0
- - //info->var.green.msb_right = 0
- - //info->var.blue.msb_right = 0
- + info->var.red.length = 8; info->var.red.offset = 16; info->var.red.msb_right = 0;
- + info->var.green.length = 8; info->var.green.offset = 8; info->var.green.msb_right = 0;
- + info->var.blue.length = 8; info->var.blue.offset = 0; info->var.blue.msb_right = 0;
- + info->var.transp.length = 0; info->var.transp.offset = 0; info->var.transp.msb_right= 0;
- break;
- +
- case(32): // RGB8888
- default:
- info->var.bits_per_pixel = 32;
- - info->var.red.length = 5; info->var.red.offset = 11;
- - info->var.red.length = 8; info->var.red.offset = 24;
- - info->var.green.length = 8; info->var.green.offset = 16;
- - info->var.blue.length = 8; info->var.blue.offset = 8;
- - info->var.transp.length = 8; info->var.transp.offset = 0;
- - //info->var.red.msb_right = 0
- - //info->var.green.msb_right = 0
- - //info->var.blue.msb_right = 0
- + info->var.red.length = 8; info->var.red.offset = 16; info->var.red.msb_right = 0;
- + info->var.green.length = 8; info->var.green.offset = 8; info->var.green.msb_right = 0;
- + info->var.blue.length = 8; info->var.blue.offset = 0; info->var.blue.msb_right = 0;
- + info->var.transp.length = 8; info->var.transp.offset = 24; info->var.transp.msb_right= 0;
- break;
- }
- +
- +
- info->var.nonstd = 1; //TODO: ???, .vfb:--, .fbtft:set
- info->var.activate = FB_ACTIVATE_NOW;
- info->var.vmode = FB_VMODE_NONINTERLACED;
- @@ -359,7 +362,7 @@
- goto failure;
- }
- - log_pdev(LEVEL_MESSAGE, "fb%d: using %ldK of video memory.", info->node, videomemory_size >> 10);
- + log(LEVEL_INFO, "fb%d: using %ldK of video memory.", info->node, videomemory_size >> 10);
- //---------------------
- info->par = cfg;
- @@ -395,7 +398,7 @@
- //---------------------
- // platform device list
- - if(pdev->id < 0 || pdev->id > 32 || !pdevs[pdev->id]) {
- + if(pdev->id < 0 || pdev->id > ADVAMATIONFB_VFB_MAX || !pdevs[pdev->id]) {
- log_pdev(LEVEL_ERROR, "Invalid platform-device id. (%d)", pdev->id);
- return -EINVAL;
- }
- @@ -433,7 +436,7 @@
- //.suspend =
- //.resume =
- .driver = {
- - .name = "advamationfb",
- + .name = ADVAMATIONFB_DRVNAME,
- .owner = THIS_MODULE,
- },
- //.id_table = advamationfb_ids,
- @@ -468,18 +471,18 @@
- struct advamationfb_cfg cfg;
- struct platform_device *ret2;
- - log(LEVEL_INFO, "%s(..., '%s', %d)", __func__, buf, count);
- + log(LEVEL_INFO, "%s(..., '%s', %zu)", __func__, buf, count);
- //---------------------
- // parse parameters
- if(count == 0) {
- - log(LEVEL_ERROR, "new_device: Missing parameters.");
- + log(LEVEL_ERROR, "new_device: Missing parameters : 'width,height,bpp'.");
- return -EINVAL;
- }
- // width
- cfg.width = atoi(buf, 0, count);
- - if(cfg.width < 1 || cfg.width > 1024) {
- + if(cfg.width < 1 ) {
- log(LEVEL_ERROR, "new_device: Invalid/missing parameter 'width'.");
- return -EINVAL;
- }
- @@ -493,7 +496,7 @@
- }
- i = sep - buf + 1;
- cfg.height = atoi(buf, i, count);
- - if(cfg.height < 1 || cfg.height > 1024) {
- + if(cfg.height < 1 ) {
- log(LEVEL_ERROR, "new_device: Invalid/missing parameter 'height'.");
- return -EINVAL;
- }
- @@ -507,7 +510,7 @@
- }
- i = sep - buf + 1;
- cfg.bpp = atoi(buf, i, count);
- - if(cfg.bpp != 16 && cfg.bpp != 24 && cfg.bpp != 32) {
- + if(cfg.bpp != 8 && cfg.bpp != 16 && cfg.bpp != 24 && cfg.bpp != 32) {
- log(LEVEL_ERROR, "new_device: Invalid parameter 'bpp'.");
- return -EINVAL;
- }
- @@ -524,10 +527,10 @@
- //---------------------
- // register device
- - for(i=0; i<32; i++)
- + for(i=0; i<ADVAMATIONFB_VFB_MAX; i++)
- if(pdevs[i] == NULL)
- break;
- - if(i >= 32 || pdevs[i]) {
- + if(i >= ADVAMATIONFB_VFB_MAX || pdevs[i]) {
- log(LEVEL_ERROR, "Too many devices.");
- return -EBUSY; //TODO
- }
- @@ -550,7 +553,7 @@
- {
- int id;
- struct advamationfb_cfg *cfg;
- - log(LEVEL_INFO, "%s(... '%s', %d)", __func__, buf, count);
- + log(LEVEL_INFO, "%s(... '%s', %zu)", __func__, buf, count);
- //---------------------
- // parse parameters
- @@ -561,7 +564,7 @@
- // id
- id = atoi(buf, 0, count);
- - if(id < 0 || id > 32) {
- + if(id < 0 || id > ADVAMATIONFB_VFB_MAX) {
- log(LEVEL_ERROR, "delete_device: Invalid/missing parameter 'id'.");
- return -EINVAL;
- }
- @@ -594,7 +597,7 @@
- log(LEVEL_INFO, "%s()", __func__);
- ret = 0;
- - for(i=0; i<32; i++) {
- + for(i=0; i<ADVAMATIONFB_VFB_MAX; i++) {
- if(pdevs[i]) {
- cfg = pdevs[i]->dev.platform_data;
- ret += scnprintf(buf+ret, PAGE_SIZE-ret, "%d: fb%d, %dx%dx%d\n", i, cfg->info->node, cfg->width, cfg->height, cfg->bpp);
- @@ -654,7 +657,7 @@
- }
- // init devices
- - for(i=0; i<32; i++)
- + for(i=0; i<ADVAMATIONFB_VFB_MAX; i++)
- pdevs[i] = NULL;
- // init sysfs (create sysfs-attributes)
- @@ -679,7 +682,7 @@
- advamationfb_sysfs_exit();
- // unregister devices
- - for(i=0; i<32; i++)
- + for(i=0; i<ADVAMATIONFB_VFB_MAX; i++)
- if(pdevs[i])
- platform_device_unregister(pdevs[i]);
- @@ -694,7 +697,9 @@
- module_init(advamationfb_init); // insmod
- module_exit(advamationfb_exit); // rmmod
- +MODULE_ALIAS(ADVAMATIONFB_DRVNAME);
- MODULE_DESCRIPTION("Advamation Framebuffer driver");
- MODULE_AUTHOR("Roland Koebler");
- -MODULE_LICENSE("Dual BSD/GPL");
- +MODULE_LICENSE("Dual BSD/GPL"); // expected values are in linux/module.h
- +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement