aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/metronomefb.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-10-12 06:35:23 -0400
committerIngo Molnar <mingo@elte.hu>2008-10-12 06:37:32 -0400
commit365d46dc9be9b3c833990a06f3994b1987eda578 (patch)
tree9397d1304144a288411f2118707f44ff5e862fa6 /drivers/video/metronomefb.c
parent5dc64a3442b98eaa0e3730c35fcf00cf962a93e7 (diff)
parentfd048088306656824958e7783ffcee27e241b361 (diff)
Merge branch 'linus' into x86/xen
Conflicts: arch/x86/kernel/cpu/common.c arch/x86/kernel/process_64.c arch/x86/xen/enlighten.c
Diffstat (limited to 'drivers/video/metronomefb.c')
-rw-r--r--drivers/video/metronomefb.c288
1 files changed, 154 insertions, 134 deletions
diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
index cc4c038a1b3f..afeed0611e3e 100644
--- a/drivers/video/metronomefb.c
+++ b/drivers/video/metronomefb.c
@@ -40,29 +40,63 @@
40 40
41#include <asm/unaligned.h> 41#include <asm/unaligned.h>
42 42
43
44#define DEBUG 1
45#ifdef DEBUG
46#define DPRINTK(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a)
47#else
48#define DPRINTK(f, a...)
49#endif
50
51
52/* Display specific information */ 43/* Display specific information */
53#define DPY_W 832 44#define DPY_W 832
54#define DPY_H 622 45#define DPY_H 622
55 46
47static int user_wfm_size;
48
56/* frame differs from image. frame includes non-visible pixels */ 49/* frame differs from image. frame includes non-visible pixels */
57struct epd_frame { 50struct epd_frame {
58 int fw; /* frame width */ 51 int fw; /* frame width */
59 int fh; /* frame height */ 52 int fh; /* frame height */
53 u16 config[4];
54 int wfm_size;
60}; 55};
61 56
62static struct epd_frame epd_frame_table[] = { 57static struct epd_frame epd_frame_table[] = {
63 { 58 {
64 .fw = 832, 59 .fw = 832,
65 .fh = 622 60 .fh = 622,
61 .config = {
62 15 /* sdlew */
63 | 2 << 8 /* sdosz */
64 | 0 << 11 /* sdor */
65 | 0 << 12 /* sdces */
66 | 0 << 15, /* sdcer */
67 42 /* gdspl */
68 | 1 << 8 /* gdr1 */
69 | 1 << 9 /* sdshr */
70 | 0 << 15, /* gdspp */
71 18 /* gdspw */
72 | 0 << 15, /* dispc */
73 599 /* vdlc */
74 | 0 << 11 /* dsi */
75 | 0 << 12, /* dsic */
76 },
77 .wfm_size = 47001,
78 },
79 {
80 .fw = 1088,
81 .fh = 791,
82 .config = {
83 0x0104,
84 0x031f,
85 0x0088,
86 0x02ff,
87 },
88 .wfm_size = 46770,
89 },
90 {
91 .fw = 1200,
92 .fh = 842,
93 .config = {
94 0x0101,
95 0x030e,
96 0x0012,
97 0x0280,
98 },
99 .wfm_size = 46770,
66 }, 100 },
67}; 101};
68 102
@@ -134,9 +168,8 @@ static u16 calc_img_cksum(u16 *start, int length)
134} 168}
135 169
136/* here we decode the incoming waveform file and populate metromem */ 170/* here we decode the incoming waveform file and populate metromem */
137#define EXP_WFORM_SIZE 47001 171static int __devinit load_waveform(u8 *mem, size_t size, int m, int t,
138static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, 172 struct metronomefb_par *par)
139 u8 *frame_count)
140{ 173{
141 int tta; 174 int tta;
142 int wmta; 175 int wmta;
@@ -148,26 +181,31 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,
148 int wfm_idx, owfm_idx; 181 int wfm_idx, owfm_idx;
149 int mem_idx = 0; 182 int mem_idx = 0;
150 struct waveform_hdr *wfm_hdr; 183 struct waveform_hdr *wfm_hdr;
184 u8 *metromem = par->metromem_wfm;
185 struct device *dev = par->info->dev;
151 186
152 if (size != EXP_WFORM_SIZE) { 187 if (user_wfm_size)
153 printk(KERN_ERR "Error: unexpected size %d != %d\n", size, 188 epd_frame_table[par->dt].wfm_size = user_wfm_size;
154 EXP_WFORM_SIZE); 189
190 if (size != epd_frame_table[par->dt].wfm_size) {
191 dev_err(dev, "Error: unexpected size %d != %d\n", size,
192 epd_frame_table[par->dt].wfm_size);
155 return -EINVAL; 193 return -EINVAL;
156 } 194 }
157 195
158 wfm_hdr = (struct waveform_hdr *) mem; 196 wfm_hdr = (struct waveform_hdr *) mem;
159 197
160 if (wfm_hdr->fvsn != 1) { 198 if (wfm_hdr->fvsn != 1) {
161 printk(KERN_ERR "Error: bad fvsn %x\n", wfm_hdr->fvsn); 199 dev_err(dev, "Error: bad fvsn %x\n", wfm_hdr->fvsn);
162 return -EINVAL; 200 return -EINVAL;
163 } 201 }
164 if (wfm_hdr->luts != 0) { 202 if (wfm_hdr->luts != 0) {
165 printk(KERN_ERR "Error: bad luts %x\n", wfm_hdr->luts); 203 dev_err(dev, "Error: bad luts %x\n", wfm_hdr->luts);
166 return -EINVAL; 204 return -EINVAL;
167 } 205 }
168 cksum = calc_cksum(32, 47, mem); 206 cksum = calc_cksum(32, 47, mem);
169 if (cksum != wfm_hdr->wfm_cs) { 207 if (cksum != wfm_hdr->wfm_cs) {
170 printk(KERN_ERR "Error: bad cksum %x != %x\n", cksum, 208 dev_err(dev, "Error: bad cksum %x != %x\n", cksum,
171 wfm_hdr->wfm_cs); 209 wfm_hdr->wfm_cs);
172 return -EINVAL; 210 return -EINVAL;
173 } 211 }
@@ -175,7 +213,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,
175 wfm_hdr->trc += 1; 213 wfm_hdr->trc += 1;
176 for (i = 0; i < 5; i++) { 214 for (i = 0; i < 5; i++) {
177 if (*(wfm_hdr->stuff2a + i) != 0) { 215 if (*(wfm_hdr->stuff2a + i) != 0) {
178 printk(KERN_ERR "Error: unexpected value in padding\n"); 216 dev_err(dev, "Error: unexpected value in padding\n");
179 return -EINVAL; 217 return -EINVAL;
180 } 218 }
181 } 219 }
@@ -200,7 +238,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,
200 return -EINVAL; 238 return -EINVAL;
201 cksum = calc_cksum(sizeof(*wfm_hdr), cksum_idx, mem); 239 cksum = calc_cksum(sizeof(*wfm_hdr), cksum_idx, mem);
202 if (cksum != mem[cksum_idx]) { 240 if (cksum != mem[cksum_idx]) {
203 printk(KERN_ERR "Error: bad temperature range table cksum" 241 dev_err(dev, "Error: bad temperature range table cksum"
204 " %x != %x\n", cksum, mem[cksum_idx]); 242 " %x != %x\n", cksum, mem[cksum_idx]);
205 return -EINVAL; 243 return -EINVAL;
206 } 244 }
@@ -212,7 +250,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,
212 return -EINVAL; 250 return -EINVAL;
213 cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); 251 cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem);
214 if (cksum != mem[cksum_idx]) { 252 if (cksum != mem[cksum_idx]) {
215 printk(KERN_ERR "Error: bad mode table address cksum" 253 dev_err(dev, "Error: bad mode table address cksum"
216 " %x != %x\n", cksum, mem[cksum_idx]); 254 " %x != %x\n", cksum, mem[cksum_idx]);
217 return -EINVAL; 255 return -EINVAL;
218 } 256 }
@@ -224,7 +262,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,
224 return -EINVAL; 262 return -EINVAL;
225 cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); 263 cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem);
226 if (cksum != mem[cksum_idx]) { 264 if (cksum != mem[cksum_idx]) {
227 printk(KERN_ERR "Error: bad temperature table address cksum" 265 dev_err(dev, "Error: bad temperature table address cksum"
228 " %x != %x\n", cksum, mem[cksum_idx]); 266 " %x != %x\n", cksum, mem[cksum_idx]);
229 return -EINVAL; 267 return -EINVAL;
230 } 268 }
@@ -259,11 +297,11 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,
259 return -EINVAL; 297 return -EINVAL;
260 cksum = calc_cksum(owfm_idx, cksum_idx, mem); 298 cksum = calc_cksum(owfm_idx, cksum_idx, mem);
261 if (cksum != mem[cksum_idx]) { 299 if (cksum != mem[cksum_idx]) {
262 printk(KERN_ERR "Error: bad waveform data cksum" 300 dev_err(dev, "Error: bad waveform data cksum"
263 " %x != %x\n", cksum, mem[cksum_idx]); 301 " %x != %x\n", cksum, mem[cksum_idx]);
264 return -EINVAL; 302 return -EINVAL;
265 } 303 }
266 *frame_count = (mem_idx/64); 304 par->frame_count = (mem_idx/64);
267 305
268 return 0; 306 return 0;
269} 307}
@@ -274,15 +312,12 @@ static int metronome_display_cmd(struct metronomefb_par *par)
274 u16 cs; 312 u16 cs;
275 u16 opcode; 313 u16 opcode;
276 static u8 borderval; 314 static u8 borderval;
277 u8 *ptr;
278 315
279 /* setup display command 316 /* setup display command
280 we can't immediately set the opcode since the controller 317 we can't immediately set the opcode since the controller
281 will try parse the command before we've set it all up 318 will try parse the command before we've set it all up
282 so we just set cs here and set the opcode at the end */ 319 so we just set cs here and set the opcode at the end */
283 320
284 ptr = par->metromem;
285
286 if (par->metromem_cmd->opcode == 0xCC40) 321 if (par->metromem_cmd->opcode == 0xCC40)
287 opcode = cs = 0xCC41; 322 opcode = cs = 0xCC41;
288 else 323 else
@@ -335,44 +370,17 @@ static int __devinit metronome_powerup_cmd(struct metronomefb_par *par)
335 370
336static int __devinit metronome_config_cmd(struct metronomefb_par *par) 371static int __devinit metronome_config_cmd(struct metronomefb_par *par)
337{ 372{
338 int i;
339 u16 cs;
340
341 /* setup config command 373 /* setup config command
342 we can't immediately set the opcode since the controller 374 we can't immediately set the opcode since the controller
343 will try parse the command before we've set it all up 375 will try parse the command before we've set it all up */
344 so we just set cs here and set the opcode at the end */
345
346 cs = 0xCC10;
347
348 /* set the 12 args ( 8 bytes ) for config. see spec for meanings */
349 i = 0;
350 par->metromem_cmd->args[i] = 15 /* sdlew */
351 | 2 << 8 /* sdosz */
352 | 0 << 11 /* sdor */
353 | 0 << 12 /* sdces */
354 | 0 << 15; /* sdcer */
355 cs += par->metromem_cmd->args[i++];
356
357 par->metromem_cmd->args[i] = 42 /* gdspl */
358 | 1 << 8 /* gdr1 */
359 | 1 << 9 /* sdshr */
360 | 0 << 15; /* gdspp */
361 cs += par->metromem_cmd->args[i++];
362
363 par->metromem_cmd->args[i] = 18 /* gdspw */
364 | 0 << 15; /* dispc */
365 cs += par->metromem_cmd->args[i++];
366
367 par->metromem_cmd->args[i] = 599 /* vdlc */
368 | 0 << 11 /* dsi */
369 | 0 << 12; /* dsic */
370 cs += par->metromem_cmd->args[i++];
371 376
377 memcpy(par->metromem_cmd->args, epd_frame_table[par->dt].config,
378 sizeof(epd_frame_table[par->dt].config));
372 /* the rest are 0 */ 379 /* the rest are 0 */
373 memset((u8 *) (par->metromem_cmd->args + i), 0, (32-i)*2); 380 memset((u8 *) (par->metromem_cmd->args + 4), 0, (32-4)*2);
374 381
375 par->metromem_cmd->csum = cs; 382 par->metromem_cmd->csum = 0xCC10;
383 par->metromem_cmd->csum += calc_img_cksum(par->metromem_cmd->args, 4);
376 par->metromem_cmd->opcode = 0xCC10; /* config cmd */ 384 par->metromem_cmd->opcode = 0xCC10; /* config cmd */
377 385
378 return par->board->met_wait_event(par); 386 return par->board->met_wait_event(par);
@@ -408,12 +416,9 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par)
408{ 416{
409 int res; 417 int res;
410 418
411 par->board->init_gpio_regs(par); 419 res = par->board->setup_io(par);
412 420 if (res)
413 par->board->init_lcdc_regs(par); 421 return res;
414
415 /* now that lcd is setup, setup dma descriptor */
416 par->board->post_dma_setup(par);
417 422
418 res = metronome_powerup_cmd(par); 423 res = metronome_powerup_cmd(par);
419 if (res) 424 if (res)
@@ -430,16 +435,16 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par)
430 435
431static void metronomefb_dpy_update(struct metronomefb_par *par) 436static void metronomefb_dpy_update(struct metronomefb_par *par)
432{ 437{
438 int fbsize;
433 u16 cksum; 439 u16 cksum;
434 unsigned char *buf = (unsigned char __force *)par->info->screen_base; 440 unsigned char *buf = (unsigned char __force *)par->info->screen_base;
435 441
442 fbsize = par->info->fix.smem_len;
436 /* copy from vm to metromem */ 443 /* copy from vm to metromem */
437 memcpy(par->metromem_img, buf, DPY_W*DPY_H); 444 memcpy(par->metromem_img, buf, fbsize);
438 445
439 cksum = calc_img_cksum((u16 *) par->metromem_img, 446 cksum = calc_img_cksum((u16 *) par->metromem_img, fbsize/2);
440 (epd_frame_table[0].fw * DPY_H)/2); 447 *((u16 *)(par->metromem_img) + fbsize/2) = cksum;
441 *((u16 *)(par->metromem_img) +
442 (epd_frame_table[0].fw * DPY_H)/2) = cksum;
443 metronome_display_cmd(par); 448 metronome_display_cmd(par);
444} 449}
445 450
@@ -574,8 +579,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
574 unsigned char *videomemory; 579 unsigned char *videomemory;
575 struct metronomefb_par *par; 580 struct metronomefb_par *par;
576 const struct firmware *fw_entry; 581 const struct firmware *fw_entry;
577 int cmd_size, wfm_size, img_size, padding_size, totalsize;
578 int i; 582 int i;
583 int panel_type;
584 int fw, fh;
585 int epd_dt_index;
579 586
580 /* pick up board specific routines */ 587 /* pick up board specific routines */
581 board = dev->dev.platform_data; 588 board = dev->dev.platform_data;
@@ -586,96 +593,108 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
586 if (!try_module_get(board->owner)) 593 if (!try_module_get(board->owner))
587 return -ENODEV; 594 return -ENODEV;
588 595
596 info = framebuffer_alloc(sizeof(struct metronomefb_par), &dev->dev);
597 if (!info)
598 goto err;
599
589 /* we have two blocks of memory. 600 /* we have two blocks of memory.
590 info->screen_base which is vm, and is the fb used by apps. 601 info->screen_base which is vm, and is the fb used by apps.
591 par->metromem which is physically contiguous memory and 602 par->metromem which is physically contiguous memory and
592 contains the display controller commands, waveform, 603 contains the display controller commands, waveform,
593 processed image data and padding. this is the data pulled 604 processed image data and padding. this is the data pulled
594 by the device's LCD controller and pushed to Metronome */ 605 by the device's LCD controller and pushed to Metronome.
606 the metromem memory is allocated by the board driver and
607 is provided to us */
608
609 panel_type = board->get_panel_type();
610 switch (panel_type) {
611 case 6:
612 epd_dt_index = 0;
613 break;
614 case 8:
615 epd_dt_index = 1;
616 break;
617 case 97:
618 epd_dt_index = 2;
619 break;
620 default:
621 dev_err(&dev->dev, "Unexpected panel type. Defaulting to 6\n");
622 epd_dt_index = 0;
623 break;
624 }
625
626 fw = epd_frame_table[epd_dt_index].fw;
627 fh = epd_frame_table[epd_dt_index].fh;
595 628
596 videomemorysize = (DPY_W*DPY_H); 629 /* we need to add a spare page because our csum caching scheme walks
630 * to the end of the page */
631 videomemorysize = PAGE_SIZE + (fw * fh);
597 videomemory = vmalloc(videomemorysize); 632 videomemory = vmalloc(videomemorysize);
598 if (!videomemory) 633 if (!videomemory)
599 return -ENOMEM; 634 goto err_fb_rel;
600 635
601 memset(videomemory, 0, videomemorysize); 636 memset(videomemory, 0, videomemorysize);
602 637
603 info = framebuffer_alloc(sizeof(struct metronomefb_par), &dev->dev);
604 if (!info)
605 goto err_vfree;
606
607 info->screen_base = (char __force __iomem *)videomemory; 638 info->screen_base = (char __force __iomem *)videomemory;
608 info->fbops = &metronomefb_ops; 639 info->fbops = &metronomefb_ops;
609 640
641 metronomefb_fix.line_length = fw;
642 metronomefb_var.xres = fw;
643 metronomefb_var.yres = fh;
644 metronomefb_var.xres_virtual = fw;
645 metronomefb_var.yres_virtual = fh;
610 info->var = metronomefb_var; 646 info->var = metronomefb_var;
611 info->fix = metronomefb_fix; 647 info->fix = metronomefb_fix;
612 info->fix.smem_len = videomemorysize; 648 info->fix.smem_len = videomemorysize;
613 par = info->par; 649 par = info->par;
614 par->info = info; 650 par->info = info;
615 par->board = board; 651 par->board = board;
652 par->dt = epd_dt_index;
616 init_waitqueue_head(&par->waitq); 653 init_waitqueue_head(&par->waitq);
617 654
618 /* this table caches per page csum values. */ 655 /* this table caches per page csum values. */
619 par->csum_table = vmalloc(videomemorysize/PAGE_SIZE); 656 par->csum_table = vmalloc(videomemorysize/PAGE_SIZE);
620 if (!par->csum_table) 657 if (!par->csum_table)
658 goto err_vfree;
659
660 /* the physical framebuffer that we use is setup by
661 * the platform device driver. It will provide us
662 * with cmd, wfm and image memory in a contiguous area. */
663 retval = board->setup_fb(par);
664 if (retval) {
665 dev_err(&dev->dev, "Failed to setup fb\n");
621 goto err_csum_table; 666 goto err_csum_table;
667 }
622 668
623 /* the metromem buffer is divided as follows: 669 /* after this point we should have a framebuffer */
624 command | CRC | padding 670 if ((!par->metromem_wfm) || (!par->metromem_img) ||
625 16kb waveform data | CRC | padding 671 (!par->metromem_dma)) {
626 image data | CRC 672 dev_err(&dev->dev, "fb access failure\n");
627 and an extra 256 bytes for dma descriptors 673 retval = -EINVAL;
628 eg: IW=832 IH=622 WS=128 674 goto err_csum_table;
629 */
630
631 cmd_size = 1 * epd_frame_table[0].fw;
632 wfm_size = ((16*1024 + 2 + epd_frame_table[0].fw - 1)
633 / epd_frame_table[0].fw) * epd_frame_table[0].fw;
634 img_size = epd_frame_table[0].fh * epd_frame_table[0].fw;
635 padding_size = 4 * epd_frame_table[0].fw;
636 totalsize = cmd_size + wfm_size + img_size + padding_size;
637 par->metromemsize = PAGE_ALIGN(totalsize + 256);
638 DPRINTK("desired memory size = %d\n", par->metromemsize);
639 dev->dev.coherent_dma_mask = 0xffffffffull;
640 par->metromem = dma_alloc_writecombine(&dev->dev, par->metromemsize,
641 &par->metromem_dma, GFP_KERNEL);
642 if (!par->metromem) {
643 printk(KERN_ERR
644 "metronomefb: unable to allocate dma buffer\n");
645 goto err_vfree;
646 } 675 }
647 676
648 info->fix.smem_start = par->metromem_dma; 677 info->fix.smem_start = par->metromem_dma;
649 par->metromem_cmd = (struct metromem_cmd *) par->metromem;
650 par->metromem_wfm = par->metromem + cmd_size;
651 par->metromem_img = par->metromem + cmd_size + wfm_size;
652 par->metromem_img_csum = (u16 *) (par->metromem_img +
653 (epd_frame_table[0].fw * DPY_H));
654 DPRINTK("img offset=0x%x\n", cmd_size + wfm_size);
655 par->metromem_desc = (struct metromem_desc *) (par->metromem + cmd_size
656 + wfm_size + img_size + padding_size);
657 par->metromem_desc_dma = par->metromem_dma + cmd_size + wfm_size
658 + img_size + padding_size;
659 678
660 /* load the waveform in. assume mode 3, temp 31 for now 679 /* load the waveform in. assume mode 3, temp 31 for now
661 a) request the waveform file from userspace 680 a) request the waveform file from userspace
662 b) process waveform and decode into metromem */ 681 b) process waveform and decode into metromem */
663 retval = request_firmware(&fw_entry, "metronome.wbf", &dev->dev); 682 retval = request_firmware(&fw_entry, "metronome.wbf", &dev->dev);
664 if (retval < 0) { 683 if (retval < 0) {
665 printk(KERN_ERR "metronomefb: couldn't get waveform\n"); 684 dev_err(&dev->dev, "Failed to get waveform\n");
666 goto err_dma_free; 685 goto err_csum_table;
667 } 686 }
668 687
669 retval = load_waveform((u8 *) fw_entry->data, fw_entry->size, 688 retval = load_waveform((u8 *) fw_entry->data, fw_entry->size, 3, 31,
670 par->metromem_wfm, 3, 31, &par->frame_count); 689 par);
671 release_firmware(fw_entry); 690 release_firmware(fw_entry);
672 if (retval < 0) { 691 if (retval < 0) {
673 printk(KERN_ERR "metronomefb: couldn't process waveform\n"); 692 dev_err(&dev->dev, "Failed processing waveform\n");
674 goto err_dma_free; 693 goto err_csum_table;
675 } 694 }
676 695
677 if (board->setup_irq(info)) 696 if (board->setup_irq(info))
678 goto err_dma_free; 697 goto err_csum_table;
679 698
680 retval = metronome_init_regs(par); 699 retval = metronome_init_regs(par);
681 if (retval < 0) 700 if (retval < 0)
@@ -688,8 +707,8 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
688 707
689 retval = fb_alloc_cmap(&info->cmap, 8, 0); 708 retval = fb_alloc_cmap(&info->cmap, 8, 0);
690 if (retval < 0) { 709 if (retval < 0) {
691 printk(KERN_ERR "Failed to allocate colormap\n"); 710 dev_err(&dev->dev, "Failed to allocate colormap\n");
692 goto err_fb_rel; 711 goto err_free_irq;
693 } 712 }
694 713
695 /* set cmap */ 714 /* set cmap */
@@ -704,7 +723,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
704 723
705 platform_set_drvdata(dev, info); 724 platform_set_drvdata(dev, info);
706 725
707 printk(KERN_INFO 726 dev_dbg(&dev->dev,
708 "fb%d: Metronome frame buffer device, using %dK of video" 727 "fb%d: Metronome frame buffer device, using %dK of video"
709 " memory\n", info->node, videomemorysize >> 10); 728 " memory\n", info->node, videomemorysize >> 10);
710 729
@@ -712,17 +731,15 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
712 731
713err_cmap: 732err_cmap:
714 fb_dealloc_cmap(&info->cmap); 733 fb_dealloc_cmap(&info->cmap);
715err_fb_rel:
716 framebuffer_release(info);
717err_free_irq: 734err_free_irq:
718 board->free_irq(info); 735 board->cleanup(par);
719err_dma_free:
720 dma_free_writecombine(&dev->dev, par->metromemsize, par->metromem,
721 par->metromem_dma);
722err_csum_table: 736err_csum_table:
723 vfree(par->csum_table); 737 vfree(par->csum_table);
724err_vfree: 738err_vfree:
725 vfree(videomemory); 739 vfree(videomemory);
740err_fb_rel:
741 framebuffer_release(info);
742err:
726 module_put(board->owner); 743 module_put(board->owner);
727 return retval; 744 return retval;
728} 745}
@@ -733,15 +750,15 @@ static int __devexit metronomefb_remove(struct platform_device *dev)
733 750
734 if (info) { 751 if (info) {
735 struct metronomefb_par *par = info->par; 752 struct metronomefb_par *par = info->par;
753
754 unregister_framebuffer(info);
736 fb_deferred_io_cleanup(info); 755 fb_deferred_io_cleanup(info);
737 dma_free_writecombine(&dev->dev, par->metromemsize,
738 par->metromem, par->metromem_dma);
739 fb_dealloc_cmap(&info->cmap); 756 fb_dealloc_cmap(&info->cmap);
757 par->board->cleanup(par);
740 vfree(par->csum_table); 758 vfree(par->csum_table);
741 unregister_framebuffer(info);
742 vfree((void __force *)info->screen_base); 759 vfree((void __force *)info->screen_base);
743 par->board->free_irq(info);
744 module_put(par->board->owner); 760 module_put(par->board->owner);
761 dev_dbg(&dev->dev, "calling release\n");
745 framebuffer_release(info); 762 framebuffer_release(info);
746 } 763 }
747 return 0; 764 return 0;
@@ -766,6 +783,9 @@ static void __exit metronomefb_exit(void)
766 platform_driver_unregister(&metronomefb_driver); 783 platform_driver_unregister(&metronomefb_driver);
767} 784}
768 785
786module_param(user_wfm_size, uint, 0);
787MODULE_PARM_DESC(user_wfm_size, "Set custom waveform size");
788
769module_init(metronomefb_init); 789module_init(metronomefb_init);
770module_exit(metronomefb_exit); 790module_exit(metronomefb_exit);
771 791