root/drivers/video/fbdev/wmt_ge_rops.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. wmt_ge_fillrect
  2. wmt_ge_copyarea
  3. wmt_ge_sync
  4. wmt_ge_rops_probe
  5. wmt_ge_rops_remove

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  *  linux/drivers/video/wmt_ge_rops.c
   4  *
   5  *  Accelerators for raster operations using WonderMedia Graphics Engine
   6  *
   7  *  Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
   8  */
   9 
  10 #include <linux/module.h>
  11 #include <linux/fb.h>
  12 #include <linux/platform_device.h>
  13 #include "core/fb_draw.h"
  14 
  15 #define GE_COMMAND_OFF          0x00
  16 #define GE_DEPTH_OFF            0x04
  17 #define GE_HIGHCOLOR_OFF        0x08
  18 #define GE_ROPCODE_OFF          0x14
  19 #define GE_FIRE_OFF             0x18
  20 #define GE_SRCBASE_OFF          0x20
  21 #define GE_SRCDISPW_OFF         0x24
  22 #define GE_SRCDISPH_OFF         0x28
  23 #define GE_SRCAREAX_OFF         0x2c
  24 #define GE_SRCAREAY_OFF         0x30
  25 #define GE_SRCAREAW_OFF         0x34
  26 #define GE_SRCAREAH_OFF         0x38
  27 #define GE_DESTBASE_OFF         0x3c
  28 #define GE_DESTDISPW_OFF        0x40
  29 #define GE_DESTDISPH_OFF        0x44
  30 #define GE_DESTAREAX_OFF        0x48
  31 #define GE_DESTAREAY_OFF        0x4c
  32 #define GE_DESTAREAW_OFF        0x50
  33 #define GE_DESTAREAH_OFF        0x54
  34 #define GE_PAT0C_OFF            0x88    /* Pattern 0 color */
  35 #define GE_ENABLE_OFF           0xec
  36 #define GE_INTEN_OFF            0xf0
  37 #define GE_STATUS_OFF           0xf8
  38 
  39 static void __iomem *regbase;
  40 
  41 void wmt_ge_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
  42 {
  43         unsigned long fg, pat;
  44 
  45         if (p->state != FBINFO_STATE_RUNNING)
  46                 return;
  47 
  48         if (p->fix.visual == FB_VISUAL_TRUECOLOR ||
  49             p->fix.visual == FB_VISUAL_DIRECTCOLOR)
  50                 fg = ((u32 *) (p->pseudo_palette))[rect->color];
  51         else
  52                 fg = rect->color;
  53 
  54         pat = pixel_to_pat(p->var.bits_per_pixel, fg);
  55 
  56         if (p->fbops->fb_sync)
  57                 p->fbops->fb_sync(p);
  58 
  59         writel(p->var.bits_per_pixel == 32 ? 3 :
  60               (p->var.bits_per_pixel == 8 ? 0 : 1), regbase + GE_DEPTH_OFF);
  61         writel(p->var.bits_per_pixel == 15 ? 1 : 0, regbase + GE_HIGHCOLOR_OFF);
  62         writel(p->fix.smem_start, regbase + GE_DESTBASE_OFF);
  63         writel(p->var.xres_virtual - 1, regbase + GE_DESTDISPW_OFF);
  64         writel(p->var.yres_virtual - 1, regbase + GE_DESTDISPH_OFF);
  65         writel(rect->dx, regbase + GE_DESTAREAX_OFF);
  66         writel(rect->dy, regbase + GE_DESTAREAY_OFF);
  67         writel(rect->width - 1, regbase + GE_DESTAREAW_OFF);
  68         writel(rect->height - 1, regbase + GE_DESTAREAH_OFF);
  69 
  70         writel(pat, regbase + GE_PAT0C_OFF);
  71         writel(1, regbase + GE_COMMAND_OFF);
  72         writel(rect->rop == ROP_XOR ? 0x5a : 0xf0, regbase + GE_ROPCODE_OFF);
  73         writel(1, regbase + GE_FIRE_OFF);
  74 }
  75 EXPORT_SYMBOL_GPL(wmt_ge_fillrect);
  76 
  77 void wmt_ge_copyarea(struct fb_info *p, const struct fb_copyarea *area)
  78 {
  79         if (p->state != FBINFO_STATE_RUNNING)
  80                 return;
  81 
  82         if (p->fbops->fb_sync)
  83                 p->fbops->fb_sync(p);
  84 
  85         writel(p->var.bits_per_pixel > 16 ? 3 :
  86               (p->var.bits_per_pixel > 8 ? 1 : 0), regbase + GE_DEPTH_OFF);
  87 
  88         writel(p->fix.smem_start, regbase + GE_SRCBASE_OFF);
  89         writel(p->var.xres_virtual - 1, regbase + GE_SRCDISPW_OFF);
  90         writel(p->var.yres_virtual - 1, regbase + GE_SRCDISPH_OFF);
  91         writel(area->sx, regbase + GE_SRCAREAX_OFF);
  92         writel(area->sy, regbase + GE_SRCAREAY_OFF);
  93         writel(area->width - 1, regbase + GE_SRCAREAW_OFF);
  94         writel(area->height - 1, regbase + GE_SRCAREAH_OFF);
  95 
  96         writel(p->fix.smem_start, regbase + GE_DESTBASE_OFF);
  97         writel(p->var.xres_virtual - 1, regbase + GE_DESTDISPW_OFF);
  98         writel(p->var.yres_virtual - 1, regbase + GE_DESTDISPH_OFF);
  99         writel(area->dx, regbase + GE_DESTAREAX_OFF);
 100         writel(area->dy, regbase + GE_DESTAREAY_OFF);
 101         writel(area->width - 1, regbase + GE_DESTAREAW_OFF);
 102         writel(area->height - 1, regbase + GE_DESTAREAH_OFF);
 103 
 104         writel(0xcc, regbase + GE_ROPCODE_OFF);
 105         writel(1, regbase + GE_COMMAND_OFF);
 106         writel(1, regbase + GE_FIRE_OFF);
 107 }
 108 EXPORT_SYMBOL_GPL(wmt_ge_copyarea);
 109 
 110 int wmt_ge_sync(struct fb_info *p)
 111 {
 112         int loops = 5000000;
 113         while ((readl(regbase + GE_STATUS_OFF) & 4) && --loops)
 114                 cpu_relax();
 115         return loops > 0 ? 0 : -EBUSY;
 116 }
 117 EXPORT_SYMBOL_GPL(wmt_ge_sync);
 118 
 119 static int wmt_ge_rops_probe(struct platform_device *pdev)
 120 {
 121         struct resource *res;
 122 
 123         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 124         if (res == NULL) {
 125                 dev_err(&pdev->dev, "no I/O memory resource defined\n");
 126                 return -ENODEV;
 127         }
 128 
 129         /* Only one ROP engine is presently supported. */
 130         if (unlikely(regbase)) {
 131                 WARN_ON(1);
 132                 return -EBUSY;
 133         }
 134 
 135         regbase = ioremap(res->start, resource_size(res));
 136         if (regbase == NULL) {
 137                 dev_err(&pdev->dev, "failed to map I/O memory\n");
 138                 return -EBUSY;
 139         }
 140 
 141         writel(1, regbase + GE_ENABLE_OFF);
 142         printk(KERN_INFO "Enabled support for WMT GE raster acceleration\n");
 143 
 144         return 0;
 145 }
 146 
 147 static int wmt_ge_rops_remove(struct platform_device *pdev)
 148 {
 149         iounmap(regbase);
 150         return 0;
 151 }
 152 
 153 static const struct of_device_id wmt_dt_ids[] = {
 154         { .compatible = "wm,prizm-ge-rops", },
 155         { /* sentinel */ }
 156 };
 157 
 158 static struct platform_driver wmt_ge_rops_driver = {
 159         .probe          = wmt_ge_rops_probe,
 160         .remove         = wmt_ge_rops_remove,
 161         .driver         = {
 162                 .name   = "wmt_ge_rops",
 163                 .of_match_table = wmt_dt_ids,
 164         },
 165 };
 166 
 167 module_platform_driver(wmt_ge_rops_driver);
 168 
 169 MODULE_AUTHOR("Alexey Charkov <alchark@gmail.com>");
 170 MODULE_DESCRIPTION("Accelerators for raster operations using "
 171                    "WonderMedia Graphics Engine");
 172 MODULE_LICENSE("GPL v2");
 173 MODULE_DEVICE_TABLE(of, wmt_dt_ids);

/* [<][>][^][v][top][bottom][index][help] */