summaryrefslogtreecommitdiffstats
path: root/drivers/media/rc/keymaps/rc-imon-mce.c
blob: b89e3569e76ac5535ef81e36cf3a630291c88164 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// SPDX-License-Identifier: GPL-2.0-or-later
/* rc5-imon-mce.c - Keytable for Windows Media Center RC-6 remotes for use
 * with the SoundGraph iMON/Antec Veris hardware IR decoder
 *
 * Copyright (c) 2010 by Jarod Wilson <jarod@redhat.com>
 */

#include <media/rc-map.h>
#include <linux/module.h>

/* mce-mode imon mce remote key table */
static struct rc_map_table imon_mce[] = {
	/* keys sorted mostly by frequency of use to optimize lookups */
	{ 0x800ff415, KEY_REWIND },
	{ 0x800ff414, KEY_FASTFORWARD },
	{ 0x800ff41b, KEY_PREVIOUS },
	{ 0x800ff41a, KEY_NEXT },

	{ 0x800ff416, KEY_PLAY },
	{ 0x800ff418, KEY_PAUSE },
	{ 0x800ff419, KEY_STOP },
	{ 0x800ff417, KEY_RECORD },

	{ 0x02000052, KEY_UP },
	{ 0x02000051, KEY_DOWN },
	{ 0x02000050, KEY_LEFT },
	{ 0x0200004f, KEY_RIGHT },

	{ 0x800ff41e, KEY_UP },
	{ 0x800ff41f, KEY_DOWN },
	{ 0x800ff420, KEY_LEFT },
	{ 0x800ff421, KEY_RIGHT },

	/* 0x800ff40b also KEY_NUMERIC_POUND on some receivers */
	{ 0x800ff40b, KEY_ENTER },
	{ 0x02000028, KEY_ENTER },
/* the OK and Enter buttons decode to the same value on some remotes
	{ 0x02000028, KEY_OK }, */
	{ 0x800ff422, KEY_OK },
	{ 0x0200002a, KEY_EXIT },
	{ 0x800ff423, KEY_EXIT },
	{ 0x02000029, KEY_DELETE },
	/* 0x800ff40a also KEY_NUMERIC_STAR on some receivers */
	{ 0x800ff40a, KEY_DELETE },

	{ 0x800ff40e, KEY_MUTE },
	{ 0x800ff410, KEY_VOLUMEUP },
	{ 0x800ff411, KEY_VOLUMEDOWN },
	{ 0x800ff412, KEY_CHANNELUP },
	{ 0x800ff413, KEY_CHANNELDOWN },

	{ 0x0200001e, KEY_NUMERIC_1 },
	{ 0x0200001f, KEY_NUMERIC_2 },
	{ 0x02000020, KEY_NUMERIC_3 },
	{ 0x02000021, KEY_NUMERIC_4 },
	{ 0x02000022, KEY_NUMERIC_5 },
	{ 0x02000023, KEY_NUMERIC_6 },
	{ 0x02000024, KEY_NUMERIC_7 },
	{ 0x02000025, KEY_NUMERIC_8 },
	{ 0x02000026, KEY_NUMERIC_9 },
	{ 0x02000027, KEY_NUMERIC_0 },

	{ 0x800ff401, KEY_NUMERIC_1 },
	{ 0x800ff402, KEY_NUMERIC_2 },
	{ 0x800ff403, KEY_NUMERIC_3 },
	{ 0x800ff404, KEY_NUMERIC_4 },
	{ 0x800ff405, KEY_NUMERIC_5 },
	{ 0x800ff406, KEY_NUMERIC_6 },
	{ 0x800ff407, KEY_NUMERIC_7 },
	{ 0x800ff408, KEY_NUMERIC_8 },
	{ 0x800ff409, KEY_NUMERIC_9 },
	{ 0x800ff400, KEY_NUMERIC_0 },

	{ 0x02200025, KEY_NUMERIC_STAR },
	{ 0x02200020, KEY_NUMERIC_POUND },
	/* 0x800ff41d also KEY_BLUE on some receivers */
	{ 0x800ff41d, KEY_NUMERIC_STAR },
	/* 0x800ff41c also KEY_PREVIOUS on some receivers */
	{ 0x800ff41c, KEY_NUMERIC_POUND },

	{ 0x800ff446, KEY_TV },
	{ 0x800ff447, KEY_AUDIO }, /* My Music */
	{ 0x800ff448, KEY_PVR }, /* RecordedTV */
	{ 0x800ff449, KEY_CAMERA },
	{ 0x800ff44a, KEY_VIDEO },
	/* 0x800ff424 also KEY_MENU on some receivers */
	{ 0x800ff424, KEY_DVD },
	/* 0x800ff425 also KEY_GREEN on some receivers */
	{ 0x800ff425, KEY_TUNER }, /* LiveTV */
	{ 0x800ff450, KEY_RADIO },

	{ 0x800ff44c, KEY_LANGUAGE },
	{ 0x800ff427, KEY_ZOOM }, /* Aspect */

	{ 0x800ff45b, KEY_RED },
	{ 0x800ff45c, KEY_GREEN },
	{ 0x800ff45d, KEY_YELLOW },
	{ 0x800ff45e, KEY_BLUE },

	{ 0x800ff466, KEY_RED },
	/* { 0x800ff425, KEY_GREEN }, */
	{ 0x800ff468, KEY_YELLOW },
	/* { 0x800ff41d, KEY_BLUE }, */

	{ 0x800ff40f, KEY_INFO },
	{ 0x800ff426, KEY_EPG }, /* Guide */
	{ 0x800ff45a, KEY_SUBTITLE }, /* Caption/Teletext */
	{ 0x800ff44d, KEY_TITLE },

	{ 0x800ff40c, KEY_POWER },
	{ 0x800ff40d, KEY_MEDIA }, /* Windows MCE button */

};

static struct rc_map_list imon_mce_map = {
	.map = {
		.scan     = imon_mce,
		.size     = ARRAY_SIZE(imon_mce),
		/* its RC6, but w/a hardware decoder */
		.rc_proto = RC_PROTO_RC6_MCE,
		.name     = RC_MAP_IMON_MCE,
	}
};

static int __init init_rc_map_imon_mce(void)
{
	return rc_map_register(&imon_mce_map);
}

static void __exit exit_rc_map_imon_mce(void)
{
	rc_map_unregister(&imon_mce_map);
}

module_init(init_rc_map_imon_mce)
module_exit(exit_rc_map_imon_mce)

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jarod Wilson <jarod@redhat.com>");
8; unsigned char _blue =blue>>8; unsigned char _regno=regno; /* * Set a single color register. The values supplied are * already rounded down to the hardware's capabilities * (according to the entries in the `var' structure). Return * != 0 for invalid regno. */ if (regno >= info->cmap.len) return 1; while (in_be16(fb_regs + 0x6002) & 0x4) udelay(1); out_be16(fb_regs + 0x60ba, 0xff); out_be16(fb_regs + 0x60b2, _red); out_be16(fb_regs + 0x60b4, _green); out_be16(fb_regs + 0x60b6, _blue); out_be16(fb_regs + 0x60b8, ~_regno); out_be16(fb_regs + 0x60f0, 0xff); udelay(100); while (in_be16(fb_regs + 0x6002) & 0x4) udelay(1); out_be16(fb_regs + 0x60b2, 0); out_be16(fb_regs + 0x60b4, 0); out_be16(fb_regs + 0x60b6, 0); out_be16(fb_regs + 0x60b8, 0); return 0; } /* 0 unblank, 1 blank, 2 no vsync, 3 no hsync, 4 off */ static int hpfb_blank(int blank, struct fb_info *info) { out_8(fb_regs + TC_NBLANK, (blank ? 0x00 : fb_bitmask)); return 0; } static void topcat_blit(int x0, int y0, int x1, int y1, int w, int h, int rr) { if (rr >= 0) { while (in_8(fb_regs + BUSY) & fb_bitmask) ; } out_8(fb_regs + TC_FBEN, fb_bitmask); if (rr >= 0) { out_8(fb_regs + TC_WEN, fb_bitmask); out_8(fb_regs + WMRR, rr); } out_be16(fb_regs + SOURCE_X, x0); out_be16(fb_regs + SOURCE_Y, y0); out_be16(fb_regs + DEST_X, x1); out_be16(fb_regs + DEST_Y, y1); out_be16(fb_regs + WWIDTH, w); out_be16(fb_regs + WHEIGHT, h); out_8(fb_regs + WMOVE, fb_bitmask); } static void hpfb_copyarea(struct fb_info *info, const struct fb_copyarea *area) { topcat_blit(area->sx, area->sy, area->dx, area->dy, area->width, area->height, RR_COPY); } static void hpfb_fillrect(struct fb_info *p, const struct fb_fillrect *region) { u8 clr; clr = region->color & 0xff; while (in_8(fb_regs + BUSY) & fb_bitmask) ; /* Foreground */ out_8(fb_regs + TC_WEN, fb_bitmask & clr); out_8(fb_regs + WMRR, (region->rop == ROP_COPY ? RR_SET : RR_INVERT)); /* Background */ out_8(fb_regs + TC_WEN, fb_bitmask & ~clr); out_8(fb_regs + WMRR, (region->rop == ROP_COPY ? RR_CLEAR : RR_NOOP)); topcat_blit(region->dx, region->dy, region->dx, region->dy, region->width, region->height, -1); } static int hpfb_sync(struct fb_info *info) { /* * Since we also access the framebuffer directly, we have to wait * until the block mover is finished */ while (in_8(fb_regs + BUSY) & fb_bitmask) ; out_8(fb_regs + TC_WEN, fb_bitmask); out_8(fb_regs + TC_PRR, RR_COPY); out_8(fb_regs + TC_FBEN, fb_bitmask); return 0; } static struct fb_ops hpfb_ops = { .owner = THIS_MODULE, .fb_setcolreg = hpfb_setcolreg, .fb_blank = hpfb_blank, .fb_fillrect = hpfb_fillrect, .fb_copyarea = hpfb_copyarea, .fb_imageblit = cfb_imageblit, .fb_sync = hpfb_sync, }; /* Common to all HP framebuffers */ #define HPFB_FBWMSB 0x05 /* Frame buffer width */ #define HPFB_FBWLSB 0x07 #define HPFB_FBHMSB 0x09 /* Frame buffer height */ #define HPFB_FBHLSB 0x0b #define HPFB_DWMSB 0x0d /* Display width */ #define HPFB_DWLSB 0x0f #define HPFB_DHMSB 0x11 /* Display height */ #define HPFB_DHLSB 0x13 #define HPFB_NUMPLANES 0x5b /* Number of colour planes */ #define HPFB_FBOMSB 0x5d /* Frame buffer offset */ #define HPFB_FBOLSB 0x5f static int hpfb_init_one(unsigned long phys_base, unsigned long virt_base) { unsigned long fboff, fb_width, fb_height, fb_start; int ret; fb_regs = virt_base; fboff = (in_8(fb_regs + HPFB_FBOMSB) << 8) | in_8(fb_regs + HPFB_FBOLSB); fb_info.fix.smem_start = (in_8(fb_regs + fboff) << 16); if (phys_base >= DIOII_BASE) { fb_info.fix.smem_start += phys_base; } if (DIO_SECID(fb_regs) != DIO_ID2_TOPCAT) { /* This is the magic incantation the HP X server uses to make Catseye boards work. */ while (in_be16(fb_regs+0x4800) & 1) ; out_be16(fb_regs+0x4800, 0); /* Catseye status */ out_be16(fb_regs+0x4510, 0); /* VB */ out_be16(fb_regs+0x4512, 0); /* TCNTRL */ out_be16(fb_regs+0x4514, 0); /* ACNTRL */ out_be16(fb_regs+0x4516, 0); /* PNCNTRL */ out_be16(fb_regs+0x4206, 0x90); /* RUG Command/Status */ out_be16(fb_regs+0x60a2, 0); /* Overlay Mask */ out_be16(fb_regs+0x60bc, 0); /* Ram Select */ } /* * Fill in the available video resolution */ fb_width = (in_8(fb_regs + HPFB_FBWMSB) << 8) | in_8(fb_regs + HPFB_FBWLSB); fb_info.fix.line_length = fb_width; fb_height = (in_8(fb_regs + HPFB_FBHMSB) << 8) | in_8(fb_regs + HPFB_FBHLSB); fb_info.fix.smem_len = fb_width * fb_height; fb_start = (unsigned long)ioremap_wt(fb_info.fix.smem_start, fb_info.fix.smem_len); hpfb_defined.xres = (in_8(fb_regs + HPFB_DWMSB) << 8) | in_8(fb_regs + HPFB_DWLSB); hpfb_defined.yres = (in_8(fb_regs + HPFB_DHMSB) << 8) | in_8(fb_regs + HPFB_DHLSB); hpfb_defined.xres_virtual = hpfb_defined.xres; hpfb_defined.yres_virtual = hpfb_defined.yres; hpfb_defined.bits_per_pixel = in_8(fb_regs + HPFB_NUMPLANES); printk(KERN_INFO "hpfb: framebuffer at 0x%lx, mapped to 0x%lx, size %dk\n", fb_info.fix.smem_start, fb_start, fb_info.fix.smem_len/1024); printk(KERN_INFO "hpfb: mode is %dx%dx%d, linelength=%d\n", hpfb_defined.xres, hpfb_defined.yres, hpfb_defined.bits_per_pixel, fb_info.fix.line_length); /* * Give the hardware a bit of a prod and work out how many bits per * pixel are supported. */ out_8(fb_regs + TC_WEN, 0xff); out_8(fb_regs + TC_PRR, RR_COPY); out_8(fb_regs + TC_FBEN, 0xff); out_8(fb_start, 0xff); fb_bitmask = in_8(fb_start); out_8(fb_start, 0); /* * Enable reading/writing of all the planes. */ out_8(fb_regs + TC_WEN, fb_bitmask); out_8(fb_regs + TC_PRR, RR_COPY); out_8(fb_regs + TC_REN, fb_bitmask); out_8(fb_regs + TC_FBEN, fb_bitmask); /* * Clear the screen. */ topcat_blit(0, 0, 0, 0, fb_width, fb_height, RR_CLEAR); /* * Let there be consoles.. */ if (DIO_SECID(fb_regs) == DIO_ID2_TOPCAT) strcat(fb_info.fix.id, "Topcat"); else strcat(fb_info.fix.id, "Catseye"); fb_info.fbops = &hpfb_ops; fb_info.flags = FBINFO_DEFAULT; fb_info.var = hpfb_defined; fb_info.screen_base = (char *)fb_start; ret = fb_alloc_cmap(&fb_info.cmap, 1 << hpfb_defined.bits_per_pixel, 0); if (ret < 0) goto unmap_screen_base; ret = register_framebuffer(&fb_info); if (ret < 0) goto dealloc_cmap; fb_info(&fb_info, "%s frame buffer device\n", fb_info.fix.id); return 0; dealloc_cmap: fb_dealloc_cmap(&fb_info.cmap); unmap_screen_base: if (fb_info.screen_base) { iounmap(fb_info.screen_base); fb_info.screen_base = NULL; } return ret; } /* * Check that the secondary ID indicates that we have some hope of working with this * framebuffer. The catseye boards are pretty much like topcats and we can muddle through. */ #define topcat_sid_ok(x) (((x) == DIO_ID2_LRCATSEYE) || ((x) == DIO_ID2_HRCCATSEYE) \ || ((x) == DIO_ID2_HRMCATSEYE) || ((x) == DIO_ID2_TOPCAT)) /* * Initialise the framebuffer */ static int hpfb_dio_probe(struct dio_dev *d, const struct dio_device_id *ent) { unsigned long paddr, vaddr; paddr = d->resource.start; if (!request_mem_region(d->resource.start, resource_size(&d->resource), d->name)) return -EBUSY; if (d->scode >= DIOII_SCBASE) { vaddr = (unsigned long)ioremap(paddr, resource_size(&d->resource)); } else { vaddr = paddr + DIO_VIRADDRBASE; } printk(KERN_INFO "Topcat found at DIO select code %d " "(secondary id %02x)\n", d->scode, (d->id >> 8) & 0xff); if (hpfb_init_one(paddr, vaddr)) { if (d->scode >= DIOII_SCBASE) iounmap((void *)vaddr); return -ENOMEM; } return 0; } static void hpfb_remove_one(struct dio_dev *d) { unregister_framebuffer(&fb_info); if (d->scode >= DIOII_SCBASE) iounmap((void *)fb_regs); release_mem_region(d->resource.start, resource_size(&d->resource)); fb_dealloc_cmap(&fb_info.cmap); if (fb_info.screen_base) iounmap(fb_info.screen_base); } static struct dio_device_id hpfb_dio_tbl[] = { { DIO_ENCODE_ID(DIO_ID_FBUFFER, DIO_ID2_LRCATSEYE) }, { DIO_ENCODE_ID(DIO_ID_FBUFFER, DIO_ID2_HRCCATSEYE) }, { DIO_ENCODE_ID(DIO_ID_FBUFFER, DIO_ID2_HRMCATSEYE) }, { DIO_ENCODE_ID(DIO_ID_FBUFFER, DIO_ID2_TOPCAT) }, { 0 } }; static struct dio_driver hpfb_driver = { .name = "hpfb", .id_table = hpfb_dio_tbl, .probe = hpfb_dio_probe, .remove = hpfb_remove_one, }; int __init hpfb_init(void) { unsigned int sid; unsigned char i; int err; /* Topcats can be on the internal IO bus or real DIO devices. * The internal variant sits at 0x560000; it has primary * and secondary ID registers just like the DIO version. * So we merge the two detection routines. * * Perhaps this #define should be in a global header file: * I believe it's common to all internal fbs, not just topcat. */ #define INTFBVADDR 0xf0560000 #define INTFBPADDR 0x560000 if (!MACH_IS_HP300) return -ENODEV; if (fb_get_options("hpfb", NULL)) return -ENODEV; err = dio_register_driver(&hpfb_driver); if (err) return err; err = probe_kernel_read(&i, (unsigned char *)INTFBVADDR + DIO_IDOFF, 1); if (!err && (i == DIO_ID_FBUFFER) && topcat_sid_ok(sid = DIO_SECID(INTFBVADDR))) { if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat")) return -EBUSY; printk(KERN_INFO "Internal Topcat found (secondary id %02x)\n", sid); if (hpfb_init_one(INTFBPADDR, INTFBVADDR)) { return -ENOMEM; } } return 0; } void __exit hpfb_cleanup_module(void) { dio_unregister_driver(&hpfb_driver); } module_init(hpfb_init); module_exit(hpfb_cleanup_module); MODULE_LICENSE("GPL");