drivers/video/fbdev/wmt_ge_rops.c

Source file repositories/reference/linux-study-clean/drivers/video/fbdev/wmt_ge_rops.c

File Facts

System
Linux kernel
Corpus path
drivers/video/fbdev/wmt_ge_rops.c
Extension
.c
Size
5260 bytes
Lines
192
Domain
Driver Families
Bucket
drivers/video
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  linux/drivers/video/wmt_ge_rops.c
 *
 *  Accelerators for raster operations using WonderMedia Graphics Engine
 *
 *  Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
 */

#include <linux/export.h>
#include <linux/module.h>
#include <linux/fb.h>
#include <linux/io.h>
#include <linux/platform_device.h>

#include "wmt_ge_rops.h"

#define GE_COMMAND_OFF		0x00
#define GE_DEPTH_OFF		0x04
#define GE_HIGHCOLOR_OFF	0x08
#define GE_ROPCODE_OFF		0x14
#define GE_FIRE_OFF		0x18
#define GE_SRCBASE_OFF		0x20
#define GE_SRCDISPW_OFF		0x24
#define GE_SRCDISPH_OFF		0x28
#define GE_SRCAREAX_OFF		0x2c
#define GE_SRCAREAY_OFF		0x30
#define GE_SRCAREAW_OFF		0x34
#define GE_SRCAREAH_OFF		0x38
#define GE_DESTBASE_OFF		0x3c
#define GE_DESTDISPW_OFF	0x40
#define GE_DESTDISPH_OFF	0x44
#define GE_DESTAREAX_OFF	0x48
#define GE_DESTAREAY_OFF	0x4c
#define GE_DESTAREAW_OFF	0x50
#define GE_DESTAREAH_OFF	0x54
#define GE_PAT0C_OFF		0x88	/* Pattern 0 color */
#define GE_ENABLE_OFF		0xec
#define GE_INTEN_OFF		0xf0
#define GE_STATUS_OFF		0xf8

static void __iomem *regbase;

/* from the spec it seems more like depth than bits per pixel */
static inline unsigned long pixel_to_pat(u32 depth, u32 pixel, struct fb_info *p)
{
	switch (depth) {
	case 1:
		return ~0ul*pixel;
	case 2:
		return ~0ul/3*pixel;
	case 4:
		return ~0ul/15*pixel;
	case 8:
		return ~0ul/255*pixel;
	case 12:
	case 15:
	case 16:
		return ~0ul/0xffff*pixel;
	case 18:
	case 24:
		return 0x1000001ul*pixel;
	case 32:
		return pixel;
	default:
		fb_warn_once(p, "%s: unsupported pixelformat %d\n", __func__, depth);
		return 0;
	}
}

void wmt_ge_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
{
	unsigned long fg, pat;

	if (p->state != FBINFO_STATE_RUNNING)
		return;

	if (p->fix.visual == FB_VISUAL_TRUECOLOR ||
	    p->fix.visual == FB_VISUAL_DIRECTCOLOR)
		fg = ((u32 *) (p->pseudo_palette))[rect->color];
	else
		fg = rect->color;

	pat = pixel_to_pat(p->var.bits_per_pixel, fg, p);

	if (p->fbops->fb_sync)
		p->fbops->fb_sync(p);

	writel(p->var.bits_per_pixel == 32 ? 3 :
	      (p->var.bits_per_pixel == 8 ? 0 : 1), regbase + GE_DEPTH_OFF);

Annotation

Implementation Notes