Advertisement
Guest User

advamation patch 1

a guest
Jun 3rd, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 11.34 KB | None | 0 0
  1. --- advamationfb.c.v1   2014-05-02 13:50:06.000000000 +0200
  2. +++ advamationfb.c.v2   2016-03-05 19:37:13.788917566 +0100
  3. @@ -8,7 +8,7 @@
  4.  - add/remove displays dynamically via sysfs
  5.  - configurable width, height and bits-per-pixel
  6.  
  7. -:Version:   2014-04-30
  8. +:Version:   2016-02-29
  9.  :Status:    experimental
  10.  
  11.  :Author:    Advamation, Roland Koebler (support@advamation.de)
  12. @@ -46,18 +46,19 @@
  13.  
  14.  #include <linux/mutex.h>
  15.  
  16. -
  17. +#define ADVAMATIONFB_DRVNAME     "advamationfb"                // 19 char max
  18. +#define ADVAMATIONFB_VFB_MAX     32                    // Linux/include/uapi/linux/fb.h => FB_MAX = 32
  19.  //========================================
  20.  // data / structures
  21.  
  22. -struct platform_device *pdevs[32];
  23. +struct platform_device *pdevs[ADVAMATIONFB_VFB_MAX];
  24.  //TODO static DEFINE_MUTEX(advamationfb_lock);   //TODO?
  25.  
  26.  //----------------------------------------
  27.  struct advamationfb_cfg {
  28.         unsigned int width;
  29.         unsigned int height;
  30. -       unsigned int bpp;       // 16: RGB565, 24: RGB888, 32: RGB8888
  31. +       unsigned int bpp;       // 8: RGB332, 16: RGB565, 24: RGB888, 32: RGB8888
  32.         unsigned int maxfps;    // TODO: for deferred IO
  33.  
  34.         atomic_t open_count;    // number of clients which use this framebuffer
  35. @@ -173,7 +174,7 @@
  36.  {
  37.         //TODO: definition of loff_t? why *ppos?
  38.         ssize_t res;
  39. -       log_info(LEVEL_DEBUG, "%s(..., count %d, ppos %llu)", __func__, count, *ppos);
  40. +       log_info(LEVEL_DEBUG, "%s(..., count %zu, ppos %llu)", __func__, count, *ppos);
  41.         res = fb_sys_write(info, buf, count, ppos);
  42.         return res;
  43.  }
  44. @@ -242,7 +243,7 @@
  45.  
  46.         //---------------------
  47.         // platform device
  48. -       if(pdev->id < 0 || pdev->id > 32 || pdevs[pdev->id]) {
  49. +       if(pdev->id < 0 || pdev->id > ADVAMATIONFB_VFB_MAX || pdevs[pdev->id]) {
  50.                 log_pdev(LEVEL_ERROR, "Invalid platform-device id. (%d).", pdev->id);
  51.                 return -EINVAL;
  52.         }
  53. @@ -297,42 +298,44 @@
  54.         //info->var.height          = // in mm TODO; .vfb: -1
  55.         //info->var.width           = // in mm TODO; .vfb: -1
  56.  
  57. -//     info->var.grayscale = 0;    //TODO: optionally use grayscale?? (or other/generic filters? -> or display gamma?)
  58. +       // http://linuxtv.org/downloads/v4l-dvb-apis/packed-rgb.html
  59. +       info->var.grayscale = 0;    //TODO: add support (or other/generic filters? -> or display gamma?)
  60.         switch(cfg->bpp) {
  61. +               case(8):    // RGB332
  62. +                       info->var.bits_per_pixel = 8;
  63. +                       info->var.red.length    =  3;   info->var.red.offset    =  5;   info->var.red.msb_right   = 0;
  64. +                       info->var.green.length  =  3;   info->var.green.offset  =  2;   info->var.green.msb_right = 0;
  65. +                       info->var.blue.length   =  2;   info->var.blue.offset   =  0;   info->var.blue.msb_right  = 0;
  66. +                       info->var.transp.length =  0;   info->var.transp.offset =  0;   info->var.transp.msb_right= 0;
  67. +                       break;
  68. +
  69.                 case(16):   // RGB565
  70.                         info->var.bits_per_pixel = 16;
  71. -                       info->var.red.length    =  5;   info->var.red.offset    = 11;
  72. -                       info->var.green.length  =  6;   info->var.green.offset  =  5;
  73. -                       info->var.blue.length   =  5;   info->var.blue.offset   =  0;
  74. -                       info->var.transp.length =  0;   info->var.transp.offset =  0;
  75. -                       //info->var.red.msb_right   = 0 //TODO: ?
  76. -                       //info->var.green.msb_right = 0
  77. -                       //info->var.blue.msb_right  = 0
  78. +                       info->var.red.length    =  5;   info->var.red.offset    = 11;   info->var.red.msb_right   = 0;
  79. +                       info->var.green.length  =  6;   info->var.green.offset  =  5;   info->var.green.msb_right = 0;
  80. +                       info->var.blue.length   =  5;   info->var.blue.offset   =  0;   info->var.blue.msb_right  = 0;
  81. +                       info->var.transp.length =  0;   info->var.transp.offset =  0;   info->var.transp.msb_right= 0;
  82.                         break;
  83. +
  84.                 case(24):   // RGB888
  85.                         info->var.bits_per_pixel = 24;
  86. -                       info->var.red.length    =  5;   info->var.red.offset    = 11;
  87. -                       info->var.red.length    =  8;   info->var.red.offset    = 16;
  88. -                       info->var.green.length  =  8;   info->var.green.offset  =  8;
  89. -                       info->var.blue.length   =  8;   info->var.blue.offset   =  0;
  90. -                       info->var.transp.length =  0;   info->var.transp.offset =  0;
  91. -                       //info->var.red.msb_right   = 0
  92. -                       //info->var.green.msb_right = 0
  93. -                       //info->var.blue.msb_right  = 0
  94. +                       info->var.red.length    =  8;   info->var.red.offset    = 16;   info->var.red.msb_right   = 0;
  95. +                       info->var.green.length  =  8;   info->var.green.offset  =  8;   info->var.green.msb_right = 0;
  96. +                       info->var.blue.length   =  8;   info->var.blue.offset   =  0;   info->var.blue.msb_right  = 0;
  97. +                       info->var.transp.length =  0;   info->var.transp.offset =  0;   info->var.transp.msb_right= 0;
  98.                         break;
  99. +
  100.                 case(32):   // RGB8888
  101.                 default:
  102.                         info->var.bits_per_pixel = 32;
  103. -                       info->var.red.length    =  5;   info->var.red.offset    = 11;
  104. -                       info->var.red.length    =  8;   info->var.red.offset    = 24;
  105. -                       info->var.green.length  =  8;   info->var.green.offset  = 16;
  106. -                       info->var.blue.length   =  8;   info->var.blue.offset   =  8;
  107. -                       info->var.transp.length =  8;   info->var.transp.offset =  0;
  108. -                       //info->var.red.msb_right   = 0
  109. -                       //info->var.green.msb_right = 0
  110. -                       //info->var.blue.msb_right  = 0
  111. +                       info->var.red.length    =  8;   info->var.red.offset    = 16;   info->var.red.msb_right   = 0;
  112. +                       info->var.green.length  =  8;   info->var.green.offset  =  8;   info->var.green.msb_right = 0;
  113. +                       info->var.blue.length   =  8;   info->var.blue.offset   =  0;   info->var.blue.msb_right  = 0;
  114. +                       info->var.transp.length =  8;   info->var.transp.offset = 24;   info->var.transp.msb_right= 0;
  115.                         break;
  116.         }
  117. +
  118. +
  119.         info->var.nonstd        = 1;        //TODO: ???, .vfb:--, .fbtft:set
  120.         info->var.activate      = FB_ACTIVATE_NOW;
  121.         info->var.vmode         = FB_VMODE_NONINTERLACED;
  122. @@ -359,7 +362,7 @@
  123.                 goto failure;
  124.         }
  125.  
  126. -       log_pdev(LEVEL_MESSAGE, "fb%d: using %ldK of video memory.", info->node, videomemory_size >> 10);
  127. +       log(LEVEL_INFO, "fb%d: using %ldK of video memory.", info->node, videomemory_size >> 10);
  128.  
  129.         //---------------------
  130.         info->par       = cfg;
  131. @@ -395,7 +398,7 @@
  132.  
  133.         //---------------------
  134.         // platform device list
  135. -       if(pdev->id < 0 || pdev->id > 32 || !pdevs[pdev->id]) {
  136. +       if(pdev->id < 0 || pdev->id > ADVAMATIONFB_VFB_MAX || !pdevs[pdev->id]) {
  137.                 log_pdev(LEVEL_ERROR, "Invalid platform-device id. (%d)", pdev->id);
  138.                 return -EINVAL;
  139.         }
  140. @@ -433,7 +436,7 @@
  141.         //.suspend =
  142.         //.resume =
  143.         .driver = {
  144. -               .name   = "advamationfb",
  145. +               .name   = ADVAMATIONFB_DRVNAME,
  146.                 .owner  = THIS_MODULE,
  147.         },
  148.         //.id_table = advamationfb_ids,
  149. @@ -468,18 +471,18 @@
  150.         struct advamationfb_cfg cfg;
  151.         struct platform_device *ret2;
  152.  
  153. -       log(LEVEL_INFO, "%s(..., '%s', %d)", __func__, buf, count);
  154. +       log(LEVEL_INFO, "%s(..., '%s', %zu)", __func__, buf, count);
  155.  
  156.         //---------------------
  157.         // parse parameters
  158.         if(count == 0) {
  159. -               log(LEVEL_ERROR, "new_device: Missing parameters.");
  160. +               log(LEVEL_ERROR, "new_device: Missing parameters : 'width,height,bpp'.");
  161.                 return -EINVAL;
  162.         }
  163.  
  164.         // width
  165.         cfg.width = atoi(buf, 0, count);
  166. -       if(cfg.width < 1 || cfg.width > 1024) {
  167. +       if(cfg.width < 1 ) {
  168.                 log(LEVEL_ERROR, "new_device: Invalid/missing parameter 'width'.");
  169.                 return -EINVAL;
  170.         }
  171. @@ -493,7 +496,7 @@
  172.         }
  173.         i = sep - buf + 1;
  174.         cfg.height = atoi(buf, i, count);
  175. -       if(cfg.height < 1 || cfg.height > 1024) {
  176. +       if(cfg.height < 1 ) {
  177.                 log(LEVEL_ERROR, "new_device: Invalid/missing parameter 'height'.");
  178.                 return -EINVAL;
  179.         }
  180. @@ -507,7 +510,7 @@
  181.         }
  182.         i = sep - buf + 1;
  183.         cfg.bpp = atoi(buf, i, count);
  184. -       if(cfg.bpp != 16  &&  cfg.bpp != 24  &&  cfg.bpp != 32) {
  185. +       if(cfg.bpp != 8 && cfg.bpp != 16  &&  cfg.bpp != 24  &&  cfg.bpp != 32) {
  186.                 log(LEVEL_ERROR, "new_device: Invalid parameter 'bpp'.");
  187.                 return -EINVAL;
  188.         }
  189. @@ -524,10 +527,10 @@
  190.  
  191.         //---------------------
  192.         // register device
  193. -       for(i=0; i<32; i++)
  194. +       for(i=0; i<ADVAMATIONFB_VFB_MAX; i++)
  195.                 if(pdevs[i] == NULL)
  196.                         break;
  197. -       if(i >= 32 || pdevs[i]) {
  198. +       if(i >= ADVAMATIONFB_VFB_MAX || pdevs[i]) {
  199.                 log(LEVEL_ERROR, "Too many devices.");
  200.                 return -EBUSY; //TODO
  201.         }
  202. @@ -550,7 +553,7 @@
  203.  {
  204.         int id;
  205.         struct advamationfb_cfg *cfg;
  206. -       log(LEVEL_INFO, "%s(... '%s', %d)", __func__, buf, count);
  207. +       log(LEVEL_INFO, "%s(... '%s', %zu)", __func__, buf, count);
  208.  
  209.         //---------------------
  210.         // parse parameters
  211. @@ -561,7 +564,7 @@
  212.  
  213.         // id
  214.         id = atoi(buf, 0, count);
  215. -       if(id < 0 || id > 32) {
  216. +       if(id < 0 || id > ADVAMATIONFB_VFB_MAX) {
  217.                 log(LEVEL_ERROR, "delete_device: Invalid/missing parameter 'id'.");
  218.                 return -EINVAL;
  219.         }
  220. @@ -594,7 +597,7 @@
  221.         log(LEVEL_INFO, "%s()", __func__);
  222.  
  223.         ret = 0;
  224. -       for(i=0; i<32; i++) {
  225. +       for(i=0; i<ADVAMATIONFB_VFB_MAX; i++) {
  226.                 if(pdevs[i]) {
  227.                         cfg = pdevs[i]->dev.platform_data;
  228.                         ret += scnprintf(buf+ret, PAGE_SIZE-ret, "%d: fb%d, %dx%dx%d\n", i, cfg->info->node, cfg->width, cfg->height, cfg->bpp);
  229. @@ -654,7 +657,7 @@
  230.         }
  231.  
  232.         // init devices
  233. -       for(i=0; i<32; i++)
  234. +       for(i=0; i<ADVAMATIONFB_VFB_MAX; i++)
  235.                 pdevs[i] = NULL;
  236.  
  237.         // init sysfs (create sysfs-attributes)
  238. @@ -679,7 +682,7 @@
  239.         advamationfb_sysfs_exit();
  240.  
  241.         // unregister devices
  242. -       for(i=0; i<32; i++)
  243. +       for(i=0; i<ADVAMATIONFB_VFB_MAX; i++)
  244.                 if(pdevs[i])
  245.                         platform_device_unregister(pdevs[i]);
  246.  
  247. @@ -694,7 +697,9 @@
  248.  module_init(advamationfb_init);                // insmod
  249.  module_exit(advamationfb_exit);                // rmmod
  250.  
  251. +MODULE_ALIAS(ADVAMATIONFB_DRVNAME);
  252.  MODULE_DESCRIPTION("Advamation Framebuffer driver");
  253.  MODULE_AUTHOR("Roland Koebler");
  254. -MODULE_LICENSE("Dual BSD/GPL");
  255. +MODULE_LICENSE("Dual BSD/GPL");                // expected values are in linux/module.h
  256. +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement